aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-08-29 08:59:05 -0400
committerMark Brown <broonie@linaro.org>2013-08-29 08:59:05 -0400
commitb5f9a9d5113efe11a3b9dad600a6f833274da595 (patch)
tree6db5fb34a2d590086e25f7f682fecb5f43e6b283
parenta1216394e620d0dfbb03c712ae3210e7b77c9e11 (diff)
parent8d4d08ce8319ae26227c4dd558405963c14c2037 (diff)
Merge remote-tracking branch 'spi/topic/rspi' into spi-pdata
Conflicts: drivers/spi/spi-rspi.c
-rw-r--r--Documentation/ABI/testing/sysfs-driver-xen-blkback17
-rw-r--r--Documentation/ABI/testing/sysfs-driver-xen-blkfront10
-rw-r--r--Documentation/bcache.txt37
-rw-r--r--Documentation/cpu-hotplug.txt6
-rw-r--r--Documentation/devicetree/bindings/clock/imx27-clock.txt1
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt2
-rw-r--r--Documentation/ja_JP/HOWTO44
-rw-r--r--MAINTAINERS36
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/alpha/include/asm/atomic.h88
-rw-r--r--arch/alpha/include/asm/param.h8
-rw-r--r--arch/alpha/include/asm/spinlock.h4
-rw-r--r--arch/alpha/include/asm/unistd.h3
-rw-r--r--arch/alpha/include/uapi/asm/param.h7
-rw-r--r--arch/alpha/include/uapi/asm/unistd.h2
-rw-r--r--arch/alpha/kernel/entry.S399
-rw-r--r--arch/alpha/kernel/irq_alpha.c2
-rw-r--r--arch/alpha/kernel/smp.c15
-rw-r--r--arch/alpha/kernel/sys_dp264.c8
-rw-r--r--arch/alpha/kernel/sys_marvel.c3
-rw-r--r--arch/alpha/kernel/systbls.S2
-rw-r--r--arch/alpha/kernel/time.c4
-rw-r--r--arch/alpha/kernel/traps.c12
-rw-r--r--arch/arm/Kconfig3
-rw-r--r--arch/arm/boot/dts/atlas6.dtsi22
-rw-r--r--arch/arm/boot/dts/imx28-apx4devkit.dts2
-rw-r--r--arch/arm/boot/dts/imx28-evk.dts2
-rw-r--r--arch/arm/boot/dts/imx28-m28evk.dts2
-rw-r--r--arch/arm/boot/dts/imx28.dtsi1
-rw-r--r--arch/arm/boot/dts/imx51-babbage.dts13
-rw-r--r--arch/arm/boot/dts/imx53-mba53.dts2
-rw-r--r--arch/arm/boot/dts/imx53.dtsi32
-rw-r--r--arch/arm/boot/dts/prima2.dtsi16
-rw-r--r--arch/arm/boot/dts/stih416-pinctrl.dtsi10
-rw-r--r--arch/arm/boot/dts/stih416.dtsi2
-rw-r--r--arch/arm/boot/dts/twl4030.dtsi6
-rw-r--r--arch/arm/boot/dts/vf610.dtsi8
-rw-r--r--arch/arm/common/edma.c1
-rw-r--r--arch/arm/common/mcpm_platsmp.c4
-rw-r--r--arch/arm/configs/da8xx_omapl_defconfig2
-rw-r--r--arch/arm/configs/davinci_all_defconfig2
-rw-r--r--arch/arm/configs/multi_v7_defconfig6
-rw-r--r--arch/arm/configs/nhk8815_defconfig7
-rw-r--r--arch/arm/include/asm/arch_timer.h2
-rw-r--r--arch/arm/kernel/head-common.S1
-rw-r--r--arch/arm/kernel/head-nommu.S1
-rw-r--r--arch/arm/kernel/head.S1
-rw-r--r--arch/arm/kernel/hw_breakpoint.c4
-rw-r--r--arch/arm/kernel/perf_event_cpu.c6
-rw-r--r--arch/arm/kernel/psci_smp.c3
-rw-r--r--arch/arm/kernel/smp.c18
-rw-r--r--arch/arm/kernel/smp_twd.c6
-rw-r--r--arch/arm/lib/delay.c2
-rw-r--r--arch/arm/mach-davinci/board-dm365-evm.c2
-rw-r--r--arch/arm/mach-davinci/dm355.c2
-rw-r--r--arch/arm/mach-davinci/dm365.c2
-rw-r--r--arch/arm/mach-exynos/Kconfig1
-rw-r--r--arch/arm/mach-exynos/Makefile2
-rw-r--r--arch/arm/mach-exynos/common.c26
-rw-r--r--arch/arm/mach-exynos/common.h1
-rw-r--r--arch/arm/mach-exynos/cpuidle.c1
-rw-r--r--arch/arm/mach-exynos/headsmp.S2
-rw-r--r--arch/arm/mach-exynos/include/mach/memory.h5
-rw-r--r--arch/arm/mach-exynos/platsmp.c4
-rw-r--r--arch/arm/mach-exynos/pm.c6
-rw-r--r--arch/arm/mach-footbridge/dc21285.c2
-rw-r--r--arch/arm/mach-highbank/highbank.c7
-rw-r--r--arch/arm/mach-highbank/platsmp.c2
-rw-r--r--arch/arm/mach-imx/clk-imx6q.c5
-rw-r--r--arch/arm/mach-imx/clk-vf610.c2
-rw-r--r--arch/arm/mach-imx/mx27.h2
-rw-r--r--arch/arm/mach-imx/platsmp.c2
-rw-r--r--arch/arm/mach-keystone/keystone.c2
-rw-r--r--arch/arm/mach-keystone/platsmp.c2
-rw-r--r--arch/arm/mach-msm/headsmp.S2
-rw-r--r--arch/arm/mach-msm/platsmp.c6
-rw-r--r--arch/arm/mach-msm/timer.c4
-rw-r--r--arch/arm/mach-mvebu/coherency.c2
-rw-r--r--arch/arm/mach-mvebu/headsmp.S2
-rw-r--r--arch/arm/mach-mvebu/platsmp.c5
-rw-r--r--arch/arm/mach-omap2/Kconfig2
-rw-r--r--arch/arm/mach-omap2/board-generic.c23
-rw-r--r--arch/arm/mach-omap2/omap-headsmp.S2
-rw-r--r--arch/arm/mach-omap2/omap-mpuss-lowpower.c2
-rw-r--r--arch/arm/mach-omap2/omap-smp.c4
-rw-r--r--arch/arm/mach-omap2/omap-wakeupgen.c4
-rw-r--r--arch/arm/mach-prima2/headsmp.S2
-rw-r--r--arch/arm/mach-prima2/platsmp.c4
-rw-r--r--arch/arm/mach-pxa/em-x270.c17
-rw-r--r--arch/arm/mach-pxa/mainstone.c3
-rw-r--r--arch/arm/mach-pxa/pcm990-baseboard.c3
-rw-r--r--arch/arm/mach-pxa/poodle.c4
-rw-r--r--arch/arm/mach-pxa/spitz.c4
-rw-r--r--arch/arm/mach-pxa/stargate2.c3
-rw-r--r--arch/arm/mach-s3c24xx/Kconfig2
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2410.c161
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2440.c3
-rw-r--r--arch/arm/mach-shmobile/headsmp-scu.S1
-rw-r--r--arch/arm/mach-shmobile/headsmp.S2
-rw-r--r--arch/arm/mach-shmobile/smp-emev2.c2
-rw-r--r--arch/arm/mach-shmobile/smp-r8a7779.c2
-rw-r--r--arch/arm/mach-shmobile/smp-sh73a0.c2
-rw-r--r--arch/arm/mach-socfpga/headsmp.S1
-rw-r--r--arch/arm/mach-socfpga/platsmp.c2
-rw-r--r--arch/arm/mach-spear/generic.h2
-rw-r--r--arch/arm/mach-spear/platsmp.c4
-rw-r--r--arch/arm/mach-sti/Kconfig3
-rw-r--r--arch/arm/mach-sti/platsmp.c6
-rw-r--r--arch/arm/mach-tegra/platsmp.c4
-rw-r--r--arch/arm/mach-tegra/pm.c2
-rw-r--r--arch/arm/mach-ux500/platsmp.c4
-rw-r--r--arch/arm/mach-zynq/common.c2
-rw-r--r--arch/arm/mach-zynq/common.h2
-rw-r--r--arch/arm/mach-zynq/headsmp.S2
-rw-r--r--arch/arm/mach-zynq/platsmp.c6
-rw-r--r--arch/arm/mm/proc-arm1020.S2
-rw-r--r--arch/arm/mm/proc-arm1020e.S2
-rw-r--r--arch/arm/mm/proc-arm1022.S2
-rw-r--r--arch/arm/mm/proc-arm1026.S3
-rw-r--r--arch/arm/mm/proc-arm720.S2
-rw-r--r--arch/arm/mm/proc-arm740.S2
-rw-r--r--arch/arm/mm/proc-arm7tdmi.S2
-rw-r--r--arch/arm/mm/proc-arm920.S2
-rw-r--r--arch/arm/mm/proc-arm922.S2
-rw-r--r--arch/arm/mm/proc-arm925.S2
-rw-r--r--arch/arm/mm/proc-arm926.S2
-rw-r--r--arch/arm/mm/proc-arm940.S2
-rw-r--r--arch/arm/mm/proc-arm946.S2
-rw-r--r--arch/arm/mm/proc-arm9tdmi.S2
-rw-r--r--arch/arm/mm/proc-fa526.S2
-rw-r--r--arch/arm/mm/proc-feroceon.S2
-rw-r--r--arch/arm/mm/proc-mohawk.S2
-rw-r--r--arch/arm/mm/proc-sa110.S2
-rw-r--r--arch/arm/mm/proc-sa1100.S2
-rw-r--r--arch/arm/mm/proc-v6.S2
-rw-r--r--arch/arm/mm/proc-v7-2level.S4
-rw-r--r--arch/arm/mm/proc-v7-3level.S4
-rw-r--r--arch/arm/mm/proc-v7.S2
-rw-r--r--arch/arm/mm/proc-xsc3.S2
-rw-r--r--arch/arm/mm/proc-xscale.S2
-rw-r--r--arch/arm/plat-samsung/Kconfig7
-rw-r--r--arch/arm/plat-samsung/Makefile2
-rw-r--r--arch/arm/plat-samsung/include/plat/clock.h5
-rw-r--r--arch/arm/plat-samsung/include/plat/pm.h8
-rw-r--r--arch/arm/plat-samsung/pm.c14
-rw-r--r--arch/arm/plat-versatile/platsmp.c6
-rw-r--r--arch/arm64/include/asm/arch_timer.h2
-rw-r--r--arch/arm64/include/asm/debug-monitors.h7
-rw-r--r--arch/arm64/include/asm/system_misc.h3
-rw-r--r--arch/arm64/include/asm/thread_info.h4
-rw-r--r--arch/arm64/include/asm/virt.h13
-rw-r--r--arch/arm64/kernel/debug-monitors.c6
-rw-r--r--arch/arm64/kernel/entry.S2
-rw-r--r--arch/arm64/kernel/hw_breakpoint.c4
-rw-r--r--arch/arm64/kernel/process.c4
-rw-r--r--arch/arm64/kernel/smp.c23
-rw-r--r--arch/arm64/mm/fault.c46
-rw-r--r--arch/blackfin/kernel/perf_event.c2
-rw-r--r--arch/blackfin/kernel/setup.c4
-rw-r--r--arch/blackfin/mach-bf561/smp.c6
-rw-r--r--arch/blackfin/mach-common/cache-c.c4
-rw-r--r--arch/blackfin/mach-common/ints-priority.c2
-rw-r--r--arch/blackfin/mach-common/smp.c18
-rw-r--r--arch/cris/arch-v32/kernel/smp.c2
-rw-r--r--arch/frv/kernel/setup.c2
-rw-r--r--arch/hexagon/kernel/setup.c2
-rw-r--r--arch/hexagon/kernel/smp.c4
-rw-r--r--arch/m32r/kernel/smpboot.c2
-rw-r--r--arch/metag/kernel/perf/perf_event.c6
-rw-r--r--arch/metag/kernel/smp.c22
-rw-r--r--arch/metag/kernel/traps.c2
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/ath79/setup.c2
-rw-r--r--arch/mips/cavium-octeon/octeon-irq.c12
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c5
-rw-r--r--arch/mips/cavium-octeon/smp.c6
-rw-r--r--arch/mips/include/asm/uasm.h37
-rw-r--r--arch/mips/kernel/bmips_vec.S4
-rw-r--r--arch/mips/kernel/cevt-bcm1480.c2
-rw-r--r--arch/mips/kernel/cevt-gic.c2
-rw-r--r--arch/mips/kernel/cevt-r4k.c2
-rw-r--r--arch/mips/kernel/cevt-sb1250.c2
-rw-r--r--arch/mips/kernel/cevt-smtc.c2
-rw-r--r--arch/mips/kernel/cpu-bugs64.c2
-rw-r--r--arch/mips/kernel/cpu-probe.c14
-rw-r--r--arch/mips/kernel/head.S4
-rw-r--r--arch/mips/kernel/smp-bmips.c8
-rw-r--r--arch/mips/kernel/smp-mt.c6
-rw-r--r--arch/mips/kernel/smp-up.c6
-rw-r--r--arch/mips/kernel/smp.c6
-rw-r--r--arch/mips/kernel/smtc.c2
-rw-r--r--arch/mips/kernel/spram.c14
-rw-r--r--arch/mips/kernel/sync-r4k.c12
-rw-r--r--arch/mips/kernel/traps.c13
-rw-r--r--arch/mips/kernel/watch.c2
-rw-r--r--arch/mips/kvm/Kconfig1
-rw-r--r--arch/mips/lantiq/irq.c2
-rw-r--r--arch/mips/lib/uncached.c2
-rw-r--r--arch/mips/mm/c-octeon.c6
-rw-r--r--arch/mips/mm/c-r3k.c8
-rw-r--r--arch/mips/mm/c-r4k.c34
-rw-r--r--arch/mips/mm/c-tx39.c2
-rw-r--r--arch/mips/mm/cache.c2
-rw-r--r--arch/mips/mm/cex-sb1.S4
-rw-r--r--arch/mips/mm/page.c40
-rw-r--r--arch/mips/mm/sc-ip22.c2
-rw-r--r--arch/mips/mm/sc-mips.c2
-rw-r--r--arch/mips/mm/sc-r5k.c2
-rw-r--r--arch/mips/mm/sc-rm7k.c12
-rw-r--r--arch/mips/mm/tlb-r3k.c2
-rw-r--r--arch/mips/mm/tlb-r4k.c4
-rw-r--r--arch/mips/mm/tlb-r8k.c4
-rw-r--r--arch/mips/mm/tlbex.c148
-rw-r--r--arch/mips/mm/uasm-micromips.c10
-rw-r--r--arch/mips/mm/uasm-mips.c10
-rw-r--r--arch/mips/mm/uasm.c106
-rw-r--r--arch/mips/mti-malta/malta-smtc.c6
-rw-r--r--arch/mips/mti-malta/malta-time.c2
-rw-r--r--arch/mips/mti-sead3/sead3-time.c2
-rw-r--r--arch/mips/netlogic/common/irq.c68
-rw-r--r--arch/mips/netlogic/common/smp.c4
-rw-r--r--arch/mips/netlogic/common/smpboot.S4
-rw-r--r--arch/mips/netlogic/common/time.c2
-rw-r--r--arch/mips/netlogic/dts/xlp_evp.dts3
-rw-r--r--arch/mips/netlogic/dts/xlp_svp.dts3
-rw-r--r--arch/mips/netlogic/xlp/usb-init.c2
-rw-r--r--arch/mips/netlogic/xlr/wakeup.c2
-rw-r--r--arch/mips/pci/pci-ip27.c2
-rw-r--r--arch/mips/pmcs-msp71xx/msp_smtc.c7
-rw-r--r--arch/mips/pmcs-msp71xx/msp_time.c2
-rw-r--r--arch/mips/pnx833x/common/interrupts.c2
-rw-r--r--arch/mips/powertv/time.c2
-rw-r--r--arch/mips/ralink/irq.c2
-rw-r--r--arch/mips/sgi-ip27/ip27-init.c4
-rw-r--r--arch/mips/sgi-ip27/ip27-smp.c6
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c6
-rw-r--r--arch/mips/sgi-ip27/ip27-xtalk.c6
-rw-r--r--arch/mips/sibyte/bcm1480/smp.c8
-rw-r--r--arch/mips/sibyte/sb1250/smp.c8
-rw-r--r--arch/openrisc/kernel/setup.c2
-rw-r--r--arch/parisc/kernel/firmware.c14
-rw-r--r--arch/parisc/kernel/hardware.c2
-rw-r--r--arch/parisc/kernel/processor.c6
-rw-r--r--arch/parisc/kernel/smp.c8
-rw-r--r--arch/powerpc/include/asm/eeh.h30
-rw-r--r--arch/powerpc/include/asm/hw_irq.h7
-rw-r--r--arch/powerpc/include/asm/module.h5
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h1
-rw-r--r--arch/powerpc/include/asm/reg.h3
-rw-r--r--arch/powerpc/kernel/cputable.c20
-rw-r--r--arch/powerpc/kernel/eeh.c70
-rw-r--r--arch/powerpc/kernel/eeh_cache.c18
-rw-r--r--arch/powerpc/kernel/eeh_driver.c77
-rw-r--r--arch/powerpc/kernel/eeh_pe.c58
-rw-r--r--arch/powerpc/kernel/eeh_sysfs.c21
-rw-r--r--arch/powerpc/kernel/pci-common.c2
-rw-r--r--arch/powerpc/kernel/pci-hotplug.c49
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c56
-rw-r--r--arch/powerpc/kernel/prom_init.c5
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S3
-rw-r--r--arch/powerpc/mm/hash_native_64.c12
-rw-r--r--arch/powerpc/perf/core-book3s.c5
-rw-r--r--arch/powerpc/perf/power8-pmu.c24
-rw-r--r--arch/powerpc/platforms/powernv/eeh-powernv.c17
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c2
-rw-r--r--arch/powerpc/platforms/pseries/Kconfig1
-rw-r--r--arch/powerpc/platforms/pseries/eeh_pseries.c67
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c2
-rw-r--r--arch/powerpc/platforms/pseries/ras.c3
-rw-r--r--arch/s390/include/asm/processor.h10
-rw-r--r--arch/s390/include/asm/switch_to.h4
-rw-r--r--arch/s390/include/uapi/asm/ptrace.h1
-rw-r--r--arch/s390/kernel/cache.c15
-rw-r--r--arch/s390/kernel/crash_dump.c51
-rw-r--r--arch/s390/kernel/perf_cpum_cf.c4
-rw-r--r--arch/s390/kernel/processor.c2
-rw-r--r--arch/s390/kernel/ptrace.c50
-rw-r--r--arch/s390/kernel/smp.c17
-rw-r--r--arch/s390/kernel/sysinfo.c2
-rw-r--r--arch/s390/kernel/vtime.c6
-rw-r--r--arch/s390/mm/fault.c4
-rw-r--r--arch/s390/net/bpf_jit_comp.c113
-rw-r--r--arch/score/mm/tlb-score.c2
-rw-r--r--arch/sh/kernel/cpu/init.c18
-rw-r--r--arch/sh/kernel/cpu/sh2/probe.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/probe.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/probe.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/smp-shx3.c6
-rw-r--r--arch/sh/kernel/cpu/sh5/probe.c2
-rw-r--r--arch/sh/kernel/perf_event.c4
-rw-r--r--arch/sh/kernel/process.c2
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh/kernel/smp.c8
-rw-r--r--arch/sh/kernel/traps_32.c2
-rw-r--r--arch/sh/kernel/traps_64.c2
-rw-r--r--arch/sh/mm/tlb-sh5.c2
-rw-r--r--arch/sparc/kernel/ds.c11
-rw-r--r--arch/sparc/kernel/entry.h2
-rw-r--r--arch/sparc/kernel/hvtramp.S1
-rw-r--r--arch/sparc/kernel/irq_64.c5
-rw-r--r--arch/sparc/kernel/leon_smp.c10
-rw-r--r--arch/sparc/kernel/mdesc.c34
-rw-r--r--arch/sparc/kernel/smp_32.c20
-rw-r--r--arch/sparc/kernel/smp_64.c9
-rw-r--r--arch/sparc/kernel/sun4d_smp.c6
-rw-r--r--arch/sparc/kernel/sun4m_smp.c6
-rw-r--r--arch/sparc/kernel/sysfs.c4
-rw-r--r--arch/sparc/kernel/trampoline_32.S3
-rw-r--r--arch/sparc/kernel/trampoline_64.S2
-rw-r--r--arch/sparc/mm/init_64.c2
-rw-r--r--arch/sparc/mm/srmmu.c12
-rw-r--r--arch/tile/kernel/irq.c2
-rw-r--r--arch/tile/kernel/messaging.c2
-rw-r--r--arch/tile/kernel/setup.c12
-rw-r--r--arch/tile/kernel/smpboot.c8
-rw-r--r--arch/tile/kernel/time.c2
-rw-r--r--arch/um/include/shared/frame_kern.h8
-rw-r--r--arch/um/kernel/signal.c4
-rw-r--r--arch/um/kernel/skas/mmu.c2
-rw-r--r--arch/um/kernel/skas/uaccess.c2
-rw-r--r--arch/um/os-Linux/mem.c230
-rw-r--r--arch/um/os-Linux/signal.c8
-rw-r--r--arch/um/os-Linux/skas/process.c19
-rw-r--r--arch/x86/crypto/Makefile2
-rw-r--r--arch/x86/crypto/crct10dif-pcl-asm_64.S643
-rw-r--r--arch/x86/crypto/crct10dif-pclmul_glue.c151
-rw-r--r--arch/x86/include/asm/cpu.h2
-rw-r--r--arch/x86/include/asm/microcode.h4
-rw-r--r--arch/x86/include/asm/microcode_amd.h4
-rw-r--r--arch/x86/include/asm/microcode_intel.h4
-rw-r--r--arch/x86/include/asm/mmconfig.h4
-rw-r--r--arch/x86/include/asm/mpspec.h2
-rw-r--r--arch/x86/include/asm/numa.h6
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/include/asm/prom.h2
-rw-r--r--arch/x86/include/asm/smp.h2
-rw-r--r--arch/x86/kernel/acpi/boot.c6
-rw-r--r--arch/x86/kernel/acpi/sleep.c18
-rw-r--r--arch/x86/kernel/apic/apic.c30
-rw-r--r--arch/x86/kernel/apic/apic_numachip.c2
-rw-r--r--arch/x86/kernel/apic/es7000_32.c2
-rw-r--r--arch/x86/kernel/apic/numaq_32.c2
-rw-r--r--arch/x86/kernel/apic/x2apic_cluster.c2
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c14
-rw-r--r--arch/x86/kernel/cpu/amd.c33
-rw-r--r--arch/x86/kernel/cpu/centaur.c26
-rw-r--r--arch/x86/kernel/cpu/common.c64
-rw-r--r--arch/x86/kernel/cpu/cyrix.c40
-rw-r--r--arch/x86/kernel/cpu/hypervisor.c2
-rw-r--r--arch/x86/kernel/cpu/intel.c30
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c55
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c23
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c14
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c9
-rw-r--r--arch/x86/kernel/cpu/perf_event.c2
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd_ibs.c2
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd_uncore.c31
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c20
-rw-r--r--arch/x86/kernel/cpu/rdrand.c2
-rw-r--r--arch/x86/kernel/cpu/scattered.c4
-rw-r--r--arch/x86/kernel/cpu/topology.c2
-rw-r--r--arch/x86/kernel/cpu/transmeta.c6
-rw-r--r--arch/x86/kernel/cpu/umc.c2
-rw-r--r--arch/x86/kernel/cpu/vmware.c2
-rw-r--r--arch/x86/kernel/cpuid.c7
-rw-r--r--arch/x86/kernel/devicetree.c2
-rw-r--r--arch/x86/kernel/head_32.S1
-rw-r--r--arch/x86/kernel/head_64.S15
-rw-r--r--arch/x86/kernel/i387.c10
-rw-r--r--arch/x86/kernel/irq_32.c2
-rw-r--r--arch/x86/kernel/kvm.c10
-rw-r--r--arch/x86/kernel/kvmclock.c2
-rw-r--r--arch/x86/kernel/microcode_amd_early.c8
-rw-r--r--arch/x86/kernel/microcode_core.c2
-rw-r--r--arch/x86/kernel/microcode_core_early.c6
-rw-r--r--arch/x86/kernel/microcode_intel_early.c26
-rw-r--r--arch/x86/kernel/mmconf-fam10h_64.c12
-rw-r--r--arch/x86/kernel/msr.c6
-rw-r--r--arch/x86/kernel/process.c2
-rw-r--r--arch/x86/kernel/setup.c2
-rw-r--r--arch/x86/kernel/smpboot.c28
-rw-r--r--arch/x86/kernel/tboot.c6
-rw-r--r--arch/x86/kernel/tracepoint.c6
-rw-r--r--arch/x86/kernel/traps.c12
-rw-r--r--arch/x86/kernel/tsc.c4
-rw-r--r--arch/x86/kernel/tsc_sync.c18
-rw-r--r--arch/x86/kernel/vsyscall_64.c6
-rw-r--r--arch/x86/kernel/x86_init.c4
-rw-r--r--arch/x86/kernel/xsave.c4
-rw-r--r--arch/x86/kvm/mmu.c7
-rw-r--r--arch/x86/mm/mmio-mod.c4
-rw-r--r--arch/x86/mm/numa.c12
-rw-r--r--arch/x86/mm/numa_emulation.c12
-rw-r--r--arch/x86/mm/setup_nx.c4
-rw-r--r--arch/x86/pci/amd_bus.c8
-rw-r--r--arch/x86/platform/ce4100/ce4100.c3
-rw-r--r--arch/x86/platform/efi/efi.c7
-rw-r--r--arch/x86/platform/mrst/mrst.c4
-rw-r--r--arch/x86/um/signal.c1
-rw-r--r--arch/x86/xen/enlighten.c6
-rw-r--r--arch/x86/xen/setup.c6
-rw-r--r--arch/x86/xen/smp.c12
-rw-r--r--arch/x86/xen/spinlock.c2
-rw-r--r--arch/x86/xen/xen-ops.h2
-rw-r--r--arch/xtensa/kernel/time.c2
-rw-r--r--block/blk-iopoll.c6
-rw-r--r--block/blk-softirq.c6
-rw-r--r--crypto/Kconfig19
-rw-r--r--crypto/Makefile1
-rw-r--r--crypto/crct10dif.c178
-rw-r--r--crypto/tcrypt.c8
-rw-r--r--crypto/testmgr.c10
-rw-r--r--crypto/testmgr.h33
-rw-r--r--drivers/acpi/acpi_memhotplug.c1
-rw-r--r--drivers/acpi/acpi_processor.c2
-rw-r--r--drivers/acpi/acpica/aclocal.h13
-rw-r--r--drivers/acpi/internal.h9
-rw-r--r--drivers/acpi/processor_core.c8
-rw-r--r--drivers/acpi/processor_driver.c8
-rw-r--r--drivers/acpi/processor_idle.c6
-rw-r--r--drivers/acpi/scan.c13
-rw-r--r--drivers/acpi/video.c31
-rw-r--r--drivers/acpi/video_detect.c8
-rw-r--r--drivers/ata/Kconfig11
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c9
-rw-r--r--drivers/ata/ahci_imx.c236
-rw-r--r--drivers/ata/ata_piix.c2
-rw-r--r--drivers/ata/libata-scsi.c6
-rw-r--r--drivers/ata/sata_inic162x.c14
-rw-r--r--drivers/base/core.c120
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/base/platform.c1
-rw-r--r--drivers/base/regmap/regmap.c2
-rw-r--r--drivers/base/topology.c10
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/drbd/drbd_actlog.c21
-rw-r--r--drivers/block/drbd/drbd_int.h15
-rw-r--r--drivers/block/drbd/drbd_main.c61
-rw-r--r--drivers/block/drbd/drbd_nl.c185
-rw-r--r--drivers/block/drbd/drbd_receiver.c12
-rw-r--r--drivers/block/drbd/drbd_state.c4
-rw-r--r--drivers/block/rsxx/core.c359
-rw-r--r--drivers/block/rsxx/cregs.c14
-rw-r--r--drivers/block/rsxx/dev.c33
-rw-r--r--drivers/block/rsxx/dma.c185
-rw-r--r--drivers/block/rsxx/rsxx_priv.h10
-rw-r--r--drivers/block/xen-blkback/blkback.c872
-rw-r--r--drivers/block/xen-blkback/common.h147
-rw-r--r--drivers/block/xen-blkback/xenbus.c85
-rw-r--r--drivers/block/xen-blkfront.c532
-rw-r--r--drivers/clocksource/arm_arch_timer.c8
-rw-r--r--drivers/clocksource/arm_global_timer.c8
-rw-r--r--drivers/clocksource/dummy_timer.c6
-rw-r--r--drivers/clocksource/exynos_mct.c4
-rw-r--r--drivers/clocksource/metag_generic.c6
-rw-r--r--drivers/clocksource/time-armada-370-xp.c4
-rw-r--r--drivers/clocksource/timer-marco.c4
-rw-r--r--drivers/cpufreq/cpufreq.c6
-rw-r--r--drivers/cpufreq/cpufreq_governor.c3
-rw-r--r--drivers/cpufreq/cpufreq_stats.c8
-rw-r--r--drivers/cpufreq/dbx500-cpufreq.c2
-rw-r--r--drivers/cpufreq/intel_pstate.c16
-rw-r--r--drivers/cpufreq/longhaul.c6
-rw-r--r--drivers/cpufreq/longhaul.h26
-rw-r--r--drivers/cpufreq/longrun.c6
-rw-r--r--drivers/cpufreq/omap-cpufreq.c2
-rw-r--r--drivers/cpufreq/powernow-k7.c8
-rw-r--r--drivers/cpufreq/powernow-k8.c6
-rw-r--r--drivers/cpufreq/s3c24xx-cpufreq.c4
-rw-r--r--drivers/crypto/caam/caamhash.c2
-rw-r--r--drivers/edac/edac_mc.c9
-rw-r--r--drivers/edac/edac_mc_sysfs.c28
-rw-r--r--drivers/edac/i5100_edac.c2
-rw-r--r--drivers/firmware/efi/efivars.c3
-rw-r--r--drivers/gpio/gpio-msm-v2.c2
-rw-r--r--drivers/gpio/gpio-omap.c84
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c27
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c19
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c17
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h3
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c101
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c10
-rw-r--r--drivers/gpu/drm/i915/intel_display.c69
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c5
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c19
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c12
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c6
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c41
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c38
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/falcon.c19
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/vp/nve0.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/include/engine/falcon.h2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c21
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c69
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c15
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fence.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c6
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c46
-rw-r--r--drivers/gpu/drm/qxl/qxl_cmd.c42
-rw-r--r--drivers/gpu/drm/qxl/qxl_display.c70
-rw-r--r--drivers/gpu/drm/qxl/qxl_draw.c263
-rw-r--r--drivers/gpu/drm/qxl/qxl_drv.h76
-rw-r--r--drivers/gpu/drm/qxl/qxl_fb.c184
-rw-r--r--drivers/gpu/drm/qxl/qxl_fence.c10
-rw-r--r--drivers/gpu/drm/qxl/qxl_gem.c2
-rw-r--r--drivers/gpu/drm/qxl/qxl_image.c111
-rw-r--r--drivers/gpu/drm/qxl/qxl_ioctl.c319
-rw-r--r--drivers/gpu/drm/qxl/qxl_object.c70
-rw-r--r--drivers/gpu/drm/qxl/qxl_object.h6
-rw-r--r--drivers/gpu/drm/qxl/qxl_release.c212
-rw-r--r--drivers/gpu/drm/qxl/qxl_ttm.c2
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c43
-rw-r--r--drivers/gpu/drm/radeon/cik.c59
-rw-r--r--drivers/gpu/drm/radeon/cikd.h16
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c13
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c6
-rw-r--r--drivers/gpu/drm/radeon/ni.c182
-rw-r--r--drivers/gpu/drm/radeon/nid.h16
-rw-r--r--drivers/gpu/drm/radeon/r100.c11
-rw-r--r--drivers/gpu/drm/radeon/r600.c105
-rw-r--r--drivers/gpu/drm/radeon/r600_dpm.c4
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c6
-rw-r--r--drivers/gpu/drm/radeon/r600d.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon.h10
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c14
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h7
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c40
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c159
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_sa.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c111
-rw-r--r--drivers/gpu/drm/radeon/rs780_dpm.c25
-rw-r--r--drivers/gpu/drm/radeon/rs780d.h3
-rw-r--r--drivers/gpu/drm/radeon/rv6xx_dpm.c55
-rw-r--r--drivers/gpu/drm/radeon/rv770.c2
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.c14
-rw-r--r--drivers/gpu/drm/radeon/si.c298
-rw-r--r--drivers/gpu/drm/radeon/sid.h14
-rw-r--r--drivers/gpu/drm/radeon/sumo_dpm.c14
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_drv.c9
-rw-r--r--drivers/gpu/drm/shmobile/shmob_drm_drv.c9
-rw-r--r--drivers/hv/hv_balloon.c21
-rw-r--r--drivers/hv/vmbus_drv.c8
-rw-r--r--drivers/hwmon/abx500.c2
-rw-r--r--drivers/hwmon/coretemp.c39
-rw-r--r--drivers/hwmon/via-cputemp.c8
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c1
-rw-r--r--drivers/iio/dac/ad7303.c4
-rw-r--r--drivers/iio/industrialio-trigger.c2
-rw-r--r--drivers/iio/inkern.c2
-rw-r--r--drivers/iio/pressure/st_pressure_core.c6
-rw-r--r--drivers/irqchip/irq-gic.c8
-rw-r--r--drivers/md/bcache/alloc.c46
-rw-r--r--drivers/md/bcache/bcache.h61
-rw-r--r--drivers/md/bcache/bset.c56
-rw-r--r--drivers/md/bcache/bset.h4
-rw-r--r--drivers/md/bcache/btree.c451
-rw-r--r--drivers/md/bcache/btree.h35
-rw-r--r--drivers/md/bcache/closure.c6
-rw-r--r--drivers/md/bcache/debug.c178
-rw-r--r--drivers/md/bcache/debug.h11
-rw-r--r--drivers/md/bcache/io.c68
-rw-r--r--drivers/md/bcache/journal.c25
-rw-r--r--drivers/md/bcache/movinggc.c24
-rw-r--r--drivers/md/bcache/request.c197
-rw-r--r--drivers/md/bcache/request.h2
-rw-r--r--drivers/md/bcache/super.c171
-rw-r--r--drivers/md/bcache/sysfs.c68
-rw-r--r--drivers/md/bcache/trace.c47
-rw-r--r--drivers/md/bcache/util.c17
-rw-r--r--drivers/md/bcache/util.h6
-rw-r--r--drivers/md/bcache/writeback.c133
-rw-r--r--drivers/md/bcache/writeback.h64
-rw-r--r--drivers/md/md.c14
-rw-r--r--drivers/md/raid1.c53
-rw-r--r--drivers/md/raid10.c19
-rw-r--r--drivers/md/raid5.c15
-rw-r--r--drivers/md/raid5.h1
-rw-r--r--drivers/media/pci/saa7134/saa7134-alsa.c2
-rw-r--r--drivers/misc/atmel-ssc.c11
-rw-r--r--drivers/misc/mei/hbm.c2
-rw-r--r--drivers/misc/mei/hw-me.c14
-rw-r--r--drivers/misc/mei/init.c3
-rw-r--r--drivers/mmc/host/pxamci.c2
-rw-r--r--drivers/net/ethernet/atheros/atl1e/atl1e_main.c24
-rw-r--r--drivers/net/ethernet/broadcom/Kconfig1
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c14
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/debugfs.c2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c4
-rw-r--r--drivers/net/macvtap.c65
-rw-r--r--drivers/net/tun.c62
-rw-r--r--drivers/net/vxlan.c6
-rw-r--r--drivers/net/xen-netfront.c31
-rw-r--r--drivers/of/irq.c6
-rw-r--r--drivers/oprofile/timer_int.c4
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c1
-rw-r--r--drivers/pinctrl/core.c1
-rw-r--r--drivers/pinctrl/pinctrl-single.c2
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-sh73a0.c1
-rw-r--r--drivers/pinctrl/sirf/pinctrl-atlas6.c24
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c2
-rw-r--r--drivers/pnp/resource.c1
-rw-r--r--drivers/s390/cio/qdio_main.c4
-rw-r--r--drivers/s390/crypto/ap_bus.c1
-rw-r--r--drivers/scsi/isci/request.c2
-rw-r--r--drivers/scsi/isci/task.c9
-rw-r--r--drivers/scsi/mvsas/mv_sas.c11
-rw-r--r--drivers/scsi/mvsas/mv_sas.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c11
-rw-r--r--drivers/scsi/sd.c22
-rw-r--r--drivers/spi/spi-altera.c12
-rw-r--r--drivers/spi/spi-nuc900.c13
-rw-r--r--drivers/spi/spi-rspi.c17
-rw-r--r--drivers/spi/spi-s3c64xx.c3
-rw-r--r--drivers/spi/spi-xilinx.c16
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/android/logger.c4
-rw-r--r--drivers/staging/comedi/TODO2
-rw-r--r--drivers/staging/comedi/comedi_fops.c32
-rw-r--r--drivers/staging/csr/Kconfig9
-rw-r--r--drivers/staging/csr/LICENSE.txt39
-rw-r--r--drivers/staging/csr/Makefile73
-rw-r--r--drivers/staging/csr/bh.c404
-rw-r--r--drivers/staging/csr/csr_framework_ext.c40
-rw-r--r--drivers/staging/csr/csr_framework_ext.h35
-rw-r--r--drivers/staging/csr/csr_framework_ext_types.h30
-rw-r--r--drivers/staging/csr/csr_log.h223
-rw-r--r--drivers/staging/csr/csr_log_configure.h39
-rw-r--r--drivers/staging/csr/csr_log_text.h124
-rw-r--r--drivers/staging/csr/csr_macro.h39
-rw-r--r--drivers/staging/csr/csr_msg_transport.h17
-rw-r--r--drivers/staging/csr/csr_msgconv.c291
-rw-r--r--drivers/staging/csr/csr_msgconv.h78
-rw-r--r--drivers/staging/csr/csr_prim_defs.h55
-rw-r--r--drivers/staging/csr/csr_result.h17
-rw-r--r--drivers/staging/csr/csr_sched.h85
-rw-r--r--drivers/staging/csr/csr_sdio.h723
-rw-r--r--drivers/staging/csr/csr_serialize_primitive_types.c100
-rw-r--r--drivers/staging/csr/csr_time.c33
-rw-r--r--drivers/staging/csr/csr_time.h76
-rw-r--r--drivers/staging/csr/csr_util.c15
-rw-r--r--drivers/staging/csr/csr_wifi_common.h101
-rw-r--r--drivers/staging/csr/csr_wifi_fsm.h240
-rw-r--r--drivers/staging/csr/csr_wifi_fsm_event.h42
-rw-r--r--drivers/staging/csr/csr_wifi_fsm_types.h430
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card.h114
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio.c4001
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio.h694
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c2595
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c1713
-rw-r--r--drivers/staging/csr/csr_wifi_hip_chiphelper.c793
-rw-r--r--drivers/staging/csr/csr_wifi_hip_chiphelper.h407
-rw-r--r--drivers/staging/csr/csr_wifi_hip_chiphelper_private.h200
-rw-r--r--drivers/staging/csr/csr_wifi_hip_conversions.h73
-rw-r--r--drivers/staging/csr/csr_wifi_hip_download.c819
-rw-r--r--drivers/staging/csr/csr_wifi_hip_dump.c837
-rw-r--r--drivers/staging/csr/csr_wifi_hip_packing.c4804
-rw-r--r--drivers/staging/csr/csr_wifi_hip_send.c415
-rw-r--r--drivers/staging/csr/csr_wifi_hip_signals.c1313
-rw-r--r--drivers/staging/csr/csr_wifi_hip_signals.h128
-rw-r--r--drivers/staging/csr/csr_wifi_hip_sigs.h1417
-rw-r--r--drivers/staging/csr/csr_wifi_hip_ta_sampling.c541
-rw-r--r--drivers/staging/csr/csr_wifi_hip_ta_sampling.h66
-rw-r--r--drivers/staging/csr/csr_wifi_hip_udi.c173
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi.h871
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c41
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi_udi.h52
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifihw.h59
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifiversion.h30
-rw-r--r--drivers/staging/csr/csr_wifi_hip_xbv.c1076
-rw-r--r--drivers/staging/csr/csr_wifi_hip_xbv.h119
-rw-r--r--drivers/staging/csr/csr_wifi_hostio_prim.h18
-rw-r--r--drivers/staging/csr/csr_wifi_lib.h103
-rw-r--r--drivers/staging/csr/csr_wifi_msgconv.h49
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_converter_init.c90
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_converter_init.h41
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c84
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c39
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_lib.h495
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_prim.h494
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_sef.c30
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_sef.h21
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_serialize.c909
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_serialize.h94
-rw-r--r--drivers/staging/csr/csr_wifi_nme_converter_init.h38
-rw-r--r--drivers/staging/csr/csr_wifi_nme_lib.h991
-rw-r--r--drivers/staging/csr/csr_wifi_nme_prim.h1657
-rw-r--r--drivers/staging/csr/csr_wifi_nme_serialize.h166
-rw-r--r--drivers/staging/csr/csr_wifi_nme_task.h27
-rw-r--r--drivers/staging/csr/csr_wifi_private_common.h81
-rw-r--r--drivers/staging/csr/csr_wifi_result.h27
-rw-r--r--drivers/staging/csr/csr_wifi_router_converter_init.c82
-rw-r--r--drivers/staging/csr/csr_wifi_router_converter_init.h34
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c134
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h34
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c108
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c87
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_lib.h2082
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_prim.h2113
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_sef.c46
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_sef.h51
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_serialize.c2591
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_serialize.h333
-rw-r--r--drivers/staging/csr/csr_wifi_router_free_downstream_contents.c53
-rw-r--r--drivers/staging/csr/csr_wifi_router_free_upstream_contents.c47
-rw-r--r--drivers/staging/csr/csr_wifi_router_lib.h417
-rw-r--r--drivers/staging/csr/csr_wifi_router_prim.h421
-rw-r--r--drivers/staging/csr/csr_wifi_router_sef.c19
-rw-r--r--drivers/staging/csr/csr_wifi_router_sef.h25
-rw-r--r--drivers/staging/csr/csr_wifi_router_serialize.c418
-rw-r--r--drivers/staging/csr/csr_wifi_router_serialize.h67
-rw-r--r--drivers/staging/csr/csr_wifi_router_task.h25
-rw-r--r--drivers/staging/csr/csr_wifi_router_transport.c199
-rw-r--r--drivers/staging/csr/csr_wifi_serialize_primitive_types.c256
-rw-r--r--drivers/staging/csr/csr_wifi_sme_ap_lib.h774
-rw-r--r--drivers/staging/csr/csr_wifi_sme_ap_prim.h1030
-rw-r--r--drivers/staging/csr/csr_wifi_sme_converter_init.c201
-rw-r--r--drivers/staging/csr/csr_wifi_sme_converter_init.h34
-rw-r--r--drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c187
-rw-r--r--drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c275
-rw-r--r--drivers/staging/csr/csr_wifi_sme_lib.h4303
-rw-r--r--drivers/staging/csr/csr_wifi_sme_prim.h6510
-rw-r--r--drivers/staging/csr/csr_wifi_sme_sef.c85
-rw-r--r--drivers/staging/csr/csr_wifi_sme_sef.h142
-rw-r--r--drivers/staging/csr/csr_wifi_sme_serialize.c5809
-rw-r--r--drivers/staging/csr/csr_wifi_sme_serialize.h666
-rw-r--r--drivers/staging/csr/csr_wifi_sme_task.h25
-rw-r--r--drivers/staging/csr/csr_wifi_vif_utils.h27
-rw-r--r--drivers/staging/csr/data_tx.c54
-rw-r--r--drivers/staging/csr/drv.c2193
-rw-r--r--drivers/staging/csr/firmware.c396
-rw-r--r--drivers/staging/csr/inet.c104
-rw-r--r--drivers/staging/csr/init_hw.c108
-rw-r--r--drivers/staging/csr/io.c1098
-rw-r--r--drivers/staging/csr/mlme.c433
-rw-r--r--drivers/staging/csr/monitor.c384
-rw-r--r--drivers/staging/csr/netdev.c3307
-rw-r--r--drivers/staging/csr/os.c477
-rw-r--r--drivers/staging/csr/putest.c685
-rw-r--r--drivers/staging/csr/sdio_events.c134
-rw-r--r--drivers/staging/csr/sdio_mmc.c1288
-rw-r--r--drivers/staging/csr/sdio_stubs.c82
-rw-r--r--drivers/staging/csr/sme_blocking.c1466
-rw-r--r--drivers/staging/csr/sme_mgt.c1012
-rw-r--r--drivers/staging/csr/sme_native.c566
-rw-r--r--drivers/staging/csr/sme_sys.c3260
-rw-r--r--drivers/staging/csr/sme_userspace.c315
-rw-r--r--drivers/staging/csr/sme_userspace.h38
-rw-r--r--drivers/staging/csr/sme_wext.c3327
-rw-r--r--drivers/staging/csr/ul_int.c528
-rw-r--r--drivers/staging/csr/unifi_clients.h129
-rw-r--r--drivers/staging/csr/unifi_config.h34
-rw-r--r--drivers/staging/csr/unifi_dbg.c110
-rw-r--r--drivers/staging/csr/unifi_event.c692
-rw-r--r--drivers/staging/csr/unifi_native.h257
-rw-r--r--drivers/staging/csr/unifi_os.h122
-rw-r--r--drivers/staging/csr/unifi_pdu_processing.c3729
-rw-r--r--drivers/staging/csr/unifi_priv.h1136
-rw-r--r--drivers/staging/csr/unifi_sme.c1225
-rw-r--r--drivers/staging/csr/unifi_sme.h245
-rw-r--r--drivers/staging/csr/unifi_wext.h108
-rw-r--r--drivers/staging/csr/unifiio.h398
-rw-r--r--drivers/staging/csr/wext_events.c283
-rw-r--r--drivers/staging/frontier/alphatrack.c2
-rw-r--r--drivers/staging/gdm72xx/gdm_qos.c2
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_core.c2
-rw-r--r--drivers/staging/iio/adc/ad7291.c1
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c18
-rw-r--r--drivers/staging/imx-drm/Kconfig1
-rw-r--r--drivers/staging/line6/pcm.c5
-rw-r--r--drivers/staging/tidspbridge/pmgr/dbll.c7
-rw-r--r--drivers/staging/zram/zram_drv.c6
-rw-r--r--drivers/thermal/x86_pkg_temp_thermal.c18
-rw-r--r--drivers/tty/serial/8250/8250_early.c3
-rw-r--r--drivers/tty/serial/Kconfig2
-rw-r--r--drivers/tty/synclinkmp.c2
-rw-r--r--drivers/usb/core/hub.c48
-rw-r--r--drivers/usb/core/hub.h3
-rw-r--r--drivers/usb/dwc3/Kconfig2
-rw-r--r--drivers/usb/dwc3/core.c2
-rw-r--r--drivers/usb/dwc3/core.h4
-rw-r--r--drivers/usb/dwc3/gadget.c1
-rw-r--r--drivers/usb/gadget/Kconfig5
-rw-r--r--drivers/usb/gadget/at91_udc.c16
-rw-r--r--drivers/usb/gadget/f_ecm.c7
-rw-r--r--drivers/usb/gadget/f_eem.c7
-rw-r--r--drivers/usb/gadget/f_ncm.c7
-rw-r--r--drivers/usb/gadget/f_phonet.c7
-rw-r--r--drivers/usb/gadget/f_rndis.c7
-rw-r--r--drivers/usb/gadget/f_subset.c7
-rw-r--r--drivers/usb/gadget/fotg210-udc.c4
-rw-r--r--drivers/usb/gadget/mv_u3d_core.c4
-rw-r--r--drivers/usb/gadget/udc-core.c6
-rw-r--r--drivers/usb/host/ehci-hub.c1
-rw-r--r--drivers/usb/host/pci-quirks.h1
-rw-r--r--drivers/usb/host/xhci-pci.c1
-rw-r--r--drivers/usb/host/xhci-ring.c2
-rw-r--r--drivers/usb/host/xhci.c17
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c1
-rw-r--r--drivers/usb/phy/phy-omap-usb3.c2
-rw-r--r--drivers/usb/phy/phy-samsung-usb2.c2
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c4
-rw-r--r--drivers/usb/serial/cp210x.c4
-rw-r--r--drivers/usb/serial/mos7840.c25
-rw-r--r--drivers/usb/serial/option.c23
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/vhost/net.c37
-rw-r--r--drivers/vhost/scsi.c17
-rw-r--r--drivers/vhost/test.c6
-rw-r--r--drivers/vhost/vhost.h10
-rw-r--r--drivers/video/backlight/max8925_bl.c41
-rw-r--r--drivers/video/uvesafb.c2
-rw-r--r--drivers/xen/xen-acpi-cpuhotplug.c2
-rw-r--r--fs/btrfs/extent-tree.c27
-rw-r--r--fs/btrfs/scrub.c2
-rw-r--r--fs/ext3/namei.c2
-rw-r--r--fs/ext4/balloc.c4
-rw-r--r--fs/ext4/extents.c23
-rw-r--r--fs/ext4/extents_status.c73
-rw-r--r--fs/ext4/inode.c19
-rw-r--r--fs/ext4/mballoc.c11
-rw-r--r--fs/ext4/namei.c2
-rw-r--r--fs/ext4/page-io.c35
-rw-r--r--fs/ext4/super.c14
-rw-r--r--fs/fuse/dir.c51
-rw-r--r--fs/lockd/svclock.c4
-rw-r--r--fs/nfs/nfs4xdr.c21
-rw-r--r--fs/nfsd/nfs4proc.c2
-rw-r--r--fs/nfsd/nfsd.h1
-rw-r--r--fs/nfsd/nfssvc.c13
-rw-r--r--fs/nfsd/vfs.c5
-rw-r--r--fs/open.c2
-rw-r--r--fs/proc/vmcore.c2
-rw-r--r--fs/super.c25
-rw-r--r--fs/sysfs/group.c70
-rw-r--r--fs/xfs/xfs_dinode.h3
-rw-r--r--fs/xfs/xfs_inode.c31
-rw-r--r--fs/xfs/xfs_log_recover.c13
-rw-r--r--include/acpi/acpixf.h1
-rw-r--r--include/acpi/actypes.h15
-rw-r--r--include/dt-bindings/clock/vf610-clock.h4
-rw-r--r--include/dt-bindings/pinctrl/am33xx.h2
-rw-r--r--include/linux/cgroup.h3
-rw-r--r--include/linux/cgroup_subsys.h45
-rw-r--r--include/linux/cpu.h2
-rw-r--r--include/linux/crc-t10dif.h4
-rw-r--r--include/linux/dcache.h2
-rw-r--r--include/linux/device.h37
-rw-r--r--include/linux/drbd.h6
-rw-r--r--include/linux/drbd_genl.h2
-rw-r--r--include/linux/drbd_limits.h9
-rw-r--r--include/linux/edac.h7
-rw-r--r--include/linux/if_vlan.h3
-rw-r--r--include/linux/iio/iio.h4
-rw-r--r--include/linux/list.h11
-rw-r--r--include/linux/mfd/syscon/imx6q-iomuxc-gpr.h137
-rw-r--r--include/linux/perf_event.h2
-rw-r--r--include/linux/platform_data/mmc-pxamci.h2
-rw-r--r--include/linux/pm_wakeup.h4
-rw-r--r--include/linux/shdma-base.h4
-rw-r--r--include/linux/sysfs.h64
-rw-r--r--include/linux/usb.h11
-rw-r--r--include/trace/events/bcache.h381
-rw-r--r--include/trace/ftrace.h4
-rw-r--r--include/uapi/asm-generic/fcntl.h4
-rw-r--r--include/uapi/linux/usb/ch11.h11
-rw-r--r--include/xen/interface/io/blkif.h53
-rw-r--r--include/xen/interface/io/ring.h5
-rw-r--r--init/calibrate.c13
-rw-r--r--kernel/cgroup.c31
-rw-r--r--kernel/cpu.c6
-rw-r--r--kernel/events/core.c6
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/hrtimer.c6
-rw-r--r--kernel/power/autosleep.c3
-rw-r--r--kernel/printk.c2
-rw-r--r--kernel/profile.c2
-rw-r--r--kernel/rcutorture.c6
-rw-r--r--kernel/rcutree.c6
-rw-r--r--kernel/rcutree.h4
-rw-r--r--kernel/rcutree_plugin.h6
-rw-r--r--kernel/relay.c2
-rw-r--r--kernel/sched/core.c12
-rw-r--r--kernel/sched/fair.c2
-rw-r--r--kernel/smp.c2
-rw-r--r--kernel/smpboot.c2
-rw-r--r--kernel/softirq.c8
-rw-r--r--kernel/time/tick-sched.c2
-rw-r--r--kernel/timer.c10
-rw-r--r--kernel/trace/ftrace.c18
-rw-r--r--kernel/trace/ring_buffer.c26
-rw-r--r--kernel/trace/trace.c227
-rw-r--r--kernel/trace/trace.h18
-rw-r--r--kernel/trace/trace_event_perf.c10
-rw-r--r--kernel/trace/trace_events.c98
-rw-r--r--kernel/trace/trace_events_filter.c4
-rw-r--r--kernel/trace/trace_functions.c2
-rw-r--r--kernel/trace/trace_functions_graph.c54
-rw-r--r--kernel/trace/trace_kprobe.c29
-rw-r--r--kernel/trace/trace_mmiotrace.c8
-rw-r--r--kernel/trace/trace_output.c14
-rw-r--r--kernel/trace/trace_syscalls.c26
-rw-r--r--kernel/trace/trace_uprobe.c2
-rw-r--r--kernel/wait.c3
-rw-r--r--kernel/workqueue.c4
-rw-r--r--lib/Kconfig2
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--lib/crc-t10dif.c73
-rw-r--r--lib/earlycpio.c2
-rw-r--r--lib/mpi/longlong.h17
-rw-r--r--lib/percpu_counter.c2
-rw-r--r--mm/backing-dev.c2
-rw-r--r--mm/memcontrol.c2
-rw-r--r--mm/page-writeback.c4
-rw-r--r--mm/slab.c10
-rw-r--r--mm/slub.c4
-rw-r--r--mm/vmstat.c6
-rw-r--r--net/8021q/vlan_core.c2
-rw-r--r--net/8021q/vlan_dev.c7
-rw-r--r--net/core/dev.c11
-rw-r--r--net/core/ethtool.c30
-rw-r--r--net/core/flow.c4
-rw-r--r--net/ethernet/eth.c21
-rw-r--r--net/ipv4/ip_input.c7
-rw-r--r--net/ipv6/ndisc.c6
-rw-r--r--net/irda/irlan/irlan_eth.c31
-rw-r--r--net/iucv/iucv.c2
-rw-r--r--net/sched/sch_qfq.c85
-rw-r--r--net/sunrpc/clnt.c1
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_marshal.c20
-rw-r--r--sound/arm/pxa2xx-pcm-lib.c2
-rw-r--r--sound/core/seq/oss/seq_oss_init.c16
-rw-r--r--sound/core/seq/oss/seq_oss_midi.c2
-rw-r--r--sound/oss/vwsnd.c4
-rw-r--r--sound/pci/asihpi/asihpi.c3
-rw-r--r--sound/pci/atiixp.c2
-rw-r--r--sound/pci/atiixp_modem.c2
-rw-r--r--sound/pci/hda/patch_hdmi.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c13
-rw-r--r--sound/soc/atmel/atmel-pcm-dma.c2
-rw-r--r--sound/soc/cirrus/ep93xx-ac97.c4
-rw-r--r--sound/soc/codecs/max98088.c2
-rw-r--r--sound/soc/codecs/sgtl5000.c5
-rw-r--r--sound/soc/codecs/sgtl5000.h2
-rw-r--r--sound/soc/codecs/wm8978.c1
-rw-r--r--sound/soc/codecs/wm8994.c4
-rw-r--r--sound/soc/omap/mcbsp.c39
-rw-r--r--sound/soc/omap/omap-dmic.c11
-rw-r--r--sound/soc/omap/omap-mcpdm.c16
-rw-r--r--sound/soc/omap/omap-pcm.c17
-rw-r--r--sound/soc/s6000/s6000-pcm.c2
-rw-r--r--sound/soc/samsung/i2s.c8
-rw-r--r--sound/soc/soc-core.c4
-rw-r--r--sound/soc/tegra/tegra20_ac97.c6
-rw-r--r--sound/soc/tegra/tegra20_spdif.c4
-rw-r--r--sound/usb/6fire/pcm.c14
-rw-r--r--sound/usb/hiface/pcm.c2
-rw-r--r--sound/usb/misc/ua101.c14
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c4
-rw-r--r--tools/hv/hv_kvp_daemon.c5
977 files changed, 10375 insertions, 98490 deletions
diff --git a/Documentation/ABI/testing/sysfs-driver-xen-blkback b/Documentation/ABI/testing/sysfs-driver-xen-blkback
new file mode 100644
index 000000000000..8bb43b66eb55
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-xen-blkback
@@ -0,0 +1,17 @@
1What: /sys/module/xen_blkback/parameters/max_buffer_pages
2Date: March 2013
3KernelVersion: 3.11
4Contact: Roger Pau Monné <roger.pau@citrix.com>
5Description:
6 Maximum number of free pages to keep in each block
7 backend buffer.
8
9What: /sys/module/xen_blkback/parameters/max_persistent_grants
10Date: March 2013
11KernelVersion: 3.11
12Contact: Roger Pau Monné <roger.pau@citrix.com>
13Description:
14 Maximum number of grants to map persistently in
15 blkback. If the frontend tries to use more than
16 max_persistent_grants, the LRU kicks in and starts
17 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
index 000000000000..c0a6cb7eb314
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-xen-blkfront
@@ -0,0 +1,10 @@
1What: /sys/module/xen_blkfront/parameters/max
2Date: June 2013
3KernelVersion: 3.11
4Contact: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
5Description:
6 Maximum number of segments that the frontend will negotiate
7 with the backend for indirect descriptors. The default value
8 is 32 - higher value means more potential throughput but more
9 memory usage. The backend picks the minimum of the frontend
10 and its default backend value.
diff --git a/Documentation/bcache.txt b/Documentation/bcache.txt
index c3365f26b2d9..32b6c3189d98 100644
--- a/Documentation/bcache.txt
+++ b/Documentation/bcache.txt
@@ -46,29 +46,33 @@ you format your backing devices and cache device at the same time, you won't
46have to manually attach: 46have to manually attach:
47 make-bcache -B /dev/sda /dev/sdb -C /dev/sdc 47 make-bcache -B /dev/sda /dev/sdb -C /dev/sdc
48 48
49To make bcache devices known to the kernel, echo them to /sys/fs/bcache/register: 49bcache-tools now ships udev rules, and bcache devices are known to the kernel
50immediately. Without udev, you can manually register devices like this:
50 51
51 echo /dev/sdb > /sys/fs/bcache/register 52 echo /dev/sdb > /sys/fs/bcache/register
52 echo /dev/sdc > /sys/fs/bcache/register 53 echo /dev/sdc > /sys/fs/bcache/register
53 54
54To register your bcache devices automatically, you could add something like 55Registering the backing device makes the bcache device show up in /dev; you can
55this to an init script: 56now format it and use it as normal. But the first time using a new bcache
57device, it'll be running in passthrough mode until you attach it to a cache.
58See the section on attaching.
56 59
57 echo /dev/sd* > /sys/fs/bcache/register_quiet 60The devices show up as:
58 61
59It'll look for bcache superblocks and ignore everything that doesn't have one. 62 /dev/bcache<N>
60 63
61Registering the backing device makes the bcache show up in /dev; you can now 64As well as (with udev):
62format it and use it as normal. But the first time using a new bcache device,
63it'll be running in passthrough mode until you attach it to a cache. See the
64section on attaching.
65 65
66The devices show up at /dev/bcacheN, and can be controlled via sysfs from 66 /dev/bcache/by-uuid/<uuid>
67/sys/block/bcacheN/bcache: 67 /dev/bcache/by-label/<label>
68
69To get started:
68 70
69 mkfs.ext4 /dev/bcache0 71 mkfs.ext4 /dev/bcache0
70 mount /dev/bcache0 /mnt 72 mount /dev/bcache0 /mnt
71 73
74You can control bcache devices through sysfs at /sys/block/bcache<N>/bcache .
75
72Cache devices are managed as sets; multiple caches per set isn't supported yet 76Cache devices are managed as sets; multiple caches per set isn't supported yet
73but will allow for mirroring of metadata and dirty data in the future. Your new 77but will allow for mirroring of metadata and dirty data in the future. Your new
74cache set shows up as /sys/fs/bcache/<UUID> 78cache 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
80device to a cache set is done thusly, with the UUID of the cache set in 84device to a cache set is done thusly, with the UUID of the cache set in
81/sys/fs/bcache: 85/sys/fs/bcache:
82 86
83 echo <UUID> > /sys/block/bcache0/bcache/attach 87 echo <CSET-UUID> > /sys/block/bcache0/bcache/attach
84 88
85This only has to be done once. The next time you reboot, just reregister all 89This only has to be done once. The next time you reboot, just reregister all
86your bcache devices. If a backing device has data in a cache somewhere, the 90your bcache devices. If a backing device has data in a cache somewhere, the
87/dev/bcache# device won't be created until the cache shows up - particularly 91/dev/bcache<N> device won't be created until the cache shows up - particularly
88important if you have writeback caching turned on. 92important if you have writeback caching turned on.
89 93
90If you're booting up and your cache device is gone and never coming back, you 94If 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.
191 195
192SYSFS - BACKING DEVICE: 196SYSFS - BACKING DEVICE:
193 197
198Available at /sys/block/<bdev>/bcache, /sys/block/bcache*/bcache and
199(if attached) /sys/fs/bcache/<cset-uuid>/bdev*
200
194attach 201attach
195 Echo the UUID of a cache set to this file to enable caching. 202 Echo the UUID of a cache set to this file to enable caching.
196 203
@@ -300,6 +307,8 @@ cache_readaheads
300 307
301SYSFS - CACHE SET: 308SYSFS - CACHE SET:
302 309
310Available at /sys/fs/bcache/<cset-uuid>
311
303average_key_size 312average_key_size
304 Average data per key in the btree. 313 Average data per key in the btree.
305 314
@@ -390,6 +399,8 @@ trigger_gc
390 399
391SYSFS - CACHE DEVICE: 400SYSFS - CACHE DEVICE:
392 401
402Available at /sys/block/<cdev>/bcache
403
393block_size 404block_size
394 Minimum granularity of writes - should match hardware sector size. 405 Minimum granularity of writes - should match hardware sector size.
395 406
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
index edd4b4df3932..786dc82f98ce 100644
--- a/Documentation/cpu-hotplug.txt
+++ b/Documentation/cpu-hotplug.txt
@@ -267,8 +267,8 @@ Q: If i have some kernel code that needs to be aware of CPU arrival and
267A: This is what you would need in your kernel code to receive notifications. 267A: This is what you would need in your kernel code to receive notifications.
268 268
269 #include <linux/cpu.h> 269 #include <linux/cpu.h>
270 static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb, 270 static int foobar_cpu_callback(struct notifier_block *nfb,
271 unsigned long action, void *hcpu) 271 unsigned long action, void *hcpu)
272 { 272 {
273 unsigned int cpu = (unsigned long)hcpu; 273 unsigned int cpu = (unsigned long)hcpu;
274 274
@@ -285,7 +285,7 @@ A: This is what you would need in your kernel code to receive notifications.
285 return NOTIFY_OK; 285 return NOTIFY_OK;
286 } 286 }
287 287
288 static struct notifier_block __cpuinitdata foobar_cpu_notifer = 288 static struct notifier_block foobar_cpu_notifer =
289 { 289 {
290 .notifier_call = foobar_cpu_callback, 290 .notifier_call = foobar_cpu_callback,
291 }; 291 };
diff --git a/Documentation/devicetree/bindings/clock/imx27-clock.txt b/Documentation/devicetree/bindings/clock/imx27-clock.txt
index ab1a56e9de9d..7a2070393732 100644
--- a/Documentation/devicetree/bindings/clock/imx27-clock.txt
+++ b/Documentation/devicetree/bindings/clock/imx27-clock.txt
@@ -98,6 +98,7 @@ clocks and IDs.
98 fpm 83 98 fpm 83
99 mpll_osc_sel 84 99 mpll_osc_sel 84
100 mpll_sel 85 100 mpll_sel 85
101 spll_gate 86
101 102
102Examples: 103Examples:
103 104
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index d5a79caec147..366ce9b87240 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -26,6 +26,7 @@ est ESTeem Wireless Modems
26fsl Freescale Semiconductor 26fsl Freescale Semiconductor
27GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc. 27GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc.
28gef GE Fanuc Intelligent Platforms Embedded Systems, Inc. 28gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
29hisilicon Hisilicon Limited.
29hp Hewlett Packard 30hp Hewlett Packard
30ibm International Business Machines (IBM) 31ibm International Business Machines (IBM)
31idt Integrated Device Technologies, Inc. 32idt Integrated Device Technologies, Inc.
@@ -43,6 +44,7 @@ nxp NXP Semiconductors
43onnn ON Semiconductor Corp. 44onnn ON Semiconductor Corp.
44picochip Picochip Ltd 45picochip Picochip Ltd
45powervr PowerVR (deprecated, use img) 46powervr PowerVR (deprecated, use img)
47qca Qualcomm Atheros, Inc.
46qcom Qualcomm, Inc. 48qcom Qualcomm, Inc.
47ralink Mediatek/Ralink Technology Corp. 49ralink Mediatek/Ralink Technology Corp.
48ramtron Ramtron International 50ramtron Ramtron International
diff --git a/Documentation/ja_JP/HOWTO b/Documentation/ja_JP/HOWTO
index 050d37fe6d40..8148a47fc70e 100644
--- a/Documentation/ja_JP/HOWTO
+++ b/Documentation/ja_JP/HOWTO
@@ -11,14 +11,14 @@ for non English (read: Japanese) speakers and is not intended as a
11fork. So if you have any comments or updates for this file, please try 11fork. So if you have any comments or updates for this file, please try
12to update the original English file first. 12to update the original English file first.
13 13
14Last Updated: 2011/03/31 14Last Updated: 2013/07/19
15================================== 15==================================
16ã“ã‚Œã¯ã€ 16ã“ã‚Œã¯ã€
17linux-2.6.38/Documentation/HOWTO 17linux-3.10/Documentation/HOWTO
18ã®å’Œè¨³ã§ã™ã€‚ 18ã®å’Œè¨³ã§ã™ã€‚
19 19
20翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ > 20翻訳団体: JF プロジェクト < http://linuxjf.sourceforge.jp/ >
21翻訳日: 2011/3/28 21翻訳日: 2013/7/19
22翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com> 22翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com>
23校正者: æ¾å€‰ã•ã‚“ <nbh--mats at nifty dot com> 23校正者: æ¾å€‰ã•ã‚“ <nbh--mats at nifty dot com>
24 å°æž— é›…å…¸ã•ã‚“ (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp> 24 å°æž— é›…å…¸ã•ã‚“ (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp>
@@ -245,7 +245,7 @@ Linux カーãƒãƒ«ã‚½ãƒ¼ã‚¹ãƒ„リーã®ä¸­ã«å«ã¾ã‚Œã‚‹ã€ãã‚Œã„ã«ã—ã€ä¿
245自己å‚照方å¼ã§ã€ç´¢å¼•ãŒã¤ã„㟠web å½¢å¼ã§ã€ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã‚’å‚ç…§ã™ã‚‹ã“ã¨ãŒ 245自己å‚照方å¼ã§ã€ç´¢å¼•ãŒã¤ã„㟠web å½¢å¼ã§ã€ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã‚’å‚ç…§ã™ã‚‹ã“ã¨ãŒ
246ã§ãã¾ã™ã€‚ã“ã®æœ€æ–°ã®ç´ æ™´ã—ã„カーãƒãƒ«ã‚³ãƒ¼ãƒ‰ã®ãƒªãƒã‚¸ãƒˆãƒªã¯ä»¥ä¸‹ã§è¦‹ã¤ã‹ã‚Š 246ã§ãã¾ã™ã€‚ã“ã®æœ€æ–°ã®ç´ æ™´ã—ã„カーãƒãƒ«ã‚³ãƒ¼ãƒ‰ã®ãƒªãƒã‚¸ãƒˆãƒªã¯ä»¥ä¸‹ã§è¦‹ã¤ã‹ã‚Š
247ã¾ã™- 247ã¾ã™-
248 http://sosdg.org/~qiyong/lxr/ 248 http://lxr.linux.no/+trees
249 249
250開発プロセス 250開発プロセス
251----------------------- 251-----------------------
@@ -253,24 +253,24 @@ Linux カーãƒãƒ«ã‚½ãƒ¼ã‚¹ãƒ„リーã®ä¸­ã«å«ã¾ã‚Œã‚‹ã€ãã‚Œã„ã«ã—ã€ä¿
253Linux カーãƒãƒ«ã®é–‹ç™ºãƒ—ロセスã¯ç¾åœ¨å¹¾ã¤ã‹ã®ç•°ãªã‚‹ãƒ¡ã‚¤ãƒ³ã‚«ãƒ¼ãƒãƒ«ã€Œãƒ–ラン 253Linux カーãƒãƒ«ã®é–‹ç™ºãƒ—ロセスã¯ç¾åœ¨å¹¾ã¤ã‹ã®ç•°ãªã‚‹ãƒ¡ã‚¤ãƒ³ã‚«ãƒ¼ãƒãƒ«ã€Œãƒ–ラン
254ãƒã€ã¨å¤šæ•°ã®ã‚µãƒ–システム毎ã®ã‚«ãƒ¼ãƒãƒ«ãƒ–ランãƒã‹ã‚‰æ§‹æˆã•ã‚Œã¾ã™ã€‚ 254ãƒã€ã¨å¤šæ•°ã®ã‚µãƒ–システム毎ã®ã‚«ãƒ¼ãƒãƒ«ãƒ–ランãƒã‹ã‚‰æ§‹æˆã•ã‚Œã¾ã™ã€‚
255ã“れらã®ãƒ–ランãƒã¨ã¯- 255ã“れらã®ãƒ–ランãƒã¨ã¯-
256 - メイン㮠2.6.x カーãƒãƒ«ãƒ„リー 256 - メイン㮠3.x カーãƒãƒ«ãƒ„リー
257 - 2.6.x.y -stable カーãƒãƒ«ãƒ„リー 257 - 3.x.y -stable カーãƒãƒ«ãƒ„リー
258 - 2.6.x -git カーãƒãƒ«ãƒ‘ッム258 - 3.x -git カーãƒãƒ«ãƒ‘ッãƒ
259 - サブシステム毎ã®ã‚«ãƒ¼ãƒãƒ«ãƒ„リーã¨ãƒ‘ッム259 - サブシステム毎ã®ã‚«ãƒ¼ãƒãƒ«ãƒ„リーã¨ãƒ‘ッãƒ
260 - çµ±åˆãƒ†ã‚¹ãƒˆã®ãŸã‚ã® 2.6.x -next カーãƒãƒ«ãƒ„リー 260 - çµ±åˆãƒ†ã‚¹ãƒˆã®ãŸã‚ã® 3.x -next カーãƒãƒ«ãƒ„リー
261 261
2622.6.x カーãƒãƒ«ãƒ„リー 2623.x カーãƒãƒ«ãƒ„リー
263----------------- 263-----------------
264 264
2652.6.x カーãƒãƒ«ã¯ Linus Torvalds ã«ã‚ˆã£ã¦ãƒ¡ãƒ³ãƒ†ãƒŠãƒ³ã‚¹ã•ã‚Œã€kernel.org 2653.x カーãƒãƒ«ã¯ Linus Torvalds ã«ã‚ˆã£ã¦ãƒ¡ãƒ³ãƒ†ãƒŠãƒ³ã‚¹ã•ã‚Œã€kernel.org
266ã® pub/linux/kernel/v2.6/ ディレクトリã«å­˜åœ¨ã—ã¾ã™ã€‚ã“ã®é–‹ç™ºãƒ—ロセス㯠266ã® pub/linux/kernel/v3.x/ ディレクトリã«å­˜åœ¨ã—ã¾ã™ã€‚ã“ã®é–‹ç™ºãƒ—ロセスã¯
267以下ã®ã¨ãŠã‚Š- 267以下ã®ã¨ãŠã‚Š-
268 268
269 - æ–°ã—ã„カーãƒãƒ«ãŒãƒªãƒªãƒ¼ã‚¹ã•ã‚ŒãŸç›´å¾Œã«ã€2週間ã®ç‰¹åˆ¥æœŸé–“ãŒè¨­ã‘られ〠269 - æ–°ã—ã„カーãƒãƒ«ãŒãƒªãƒªãƒ¼ã‚¹ã•ã‚ŒãŸç›´å¾Œã«ã€2週間ã®ç‰¹åˆ¥æœŸé–“ãŒè¨­ã‘られã€
270 ã“ã®æœŸé–“中ã«ã€ãƒ¡ãƒ³ãƒ†ãƒŠé”㯠Linus ã«å¤§ããªå·®åˆ†ã‚’é€ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ 270 ã“ã®æœŸé–“中ã«ã€ãƒ¡ãƒ³ãƒ†ãƒŠé”㯠Linus ã«å¤§ããªå·®åˆ†ã‚’é€ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
271 ã“ã®ã‚ˆã†ãªå·®åˆ†ã¯é€šå¸¸ -next カーãƒãƒ«ã«æ•°é€±é–“å«ã¾ã‚Œã¦ããŸãƒ‘ッãƒã§ã™ã€‚ 271 ã“ã®ã‚ˆã†ãªå·®åˆ†ã¯é€šå¸¸ -next カーãƒãƒ«ã«æ•°é€±é–“å«ã¾ã‚Œã¦ããŸãƒ‘ッãƒã§ã™ã€‚
272 大ããªå¤‰æ›´ã¯ git(カーãƒãƒ«ã®ã‚½ãƒ¼ã‚¹ç®¡ç†ãƒ„ールã€è©³ç´°ã¯ 272 大ããªå¤‰æ›´ã¯ git(カーãƒãƒ«ã®ã‚½ãƒ¼ã‚¹ç®¡ç†ãƒ„ールã€è©³ç´°ã¯
273 http://git-scm.com/ å‚ç…§) を使ã£ã¦é€ã‚‹ã®ãŒå¥½ã¾ã—ã„ã‚„ã‚Šæ–¹ã§ã™ãŒã€ãƒ‘ッ 273 http://git-scm.com/ å‚ç…§) を使ã£ã¦é€ã‚‹ã®ãŒå¥½ã¾ã—ã„ã‚„ã‚Šæ–¹ã§ã™ãŒã€ãƒ‘ッ
274 ãƒãƒ•ã‚¡ã‚¤ãƒ«ã®å½¢å¼ã®ã¾ã¾é€ã‚‹ã®ã§ã‚‚å分ã§ã™ã€‚ 274 ãƒãƒ•ã‚¡ã‚¤ãƒ«ã®å½¢å¼ã®ã¾ã¾é€ã‚‹ã®ã§ã‚‚å分ã§ã™ã€‚
275 275
276 - 2週間後ã€-rc1 カーãƒãƒ«ãŒãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã€ã“ã®å¾Œã«ã¯ã‚«ãƒ¼ãƒãƒ«å…¨ä½“ã®å®‰å®š 276 - 2週間後ã€-rc1 カーãƒãƒ«ãŒãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã€ã“ã®å¾Œã«ã¯ã‚«ãƒ¼ãƒãƒ«å…¨ä½“ã®å®‰å®š
@@ -302,20 +302,20 @@ Andrew Morton ㌠Linux-kernel メーリングリストã«ã‚«ãƒ¼ãƒãƒ«ãƒªãƒªãƒ¼ã
302 実ã«èªè­˜ã•ã‚ŒãŸãƒã‚°ã®çŠ¶æ³ã«ã‚ˆã‚Šãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã‚‹ã®ã§ã‚ã‚Šã€å‰ã‚‚ã£ã¦æ±ºã‚ら 302 実ã«èªè­˜ã•ã‚ŒãŸãƒã‚°ã®çŠ¶æ³ã«ã‚ˆã‚Šãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã‚‹ã®ã§ã‚ã‚Šã€å‰ã‚‚ã£ã¦æ±ºã‚ら
303 ã‚ŒãŸè¨ˆç”»ã«ã‚ˆã£ã¦ãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã‚‹ã‚‚ã®ã§ã¯ãªã„ã‹ã‚‰ã§ã™ã€‚〠303 ã‚ŒãŸè¨ˆç”»ã«ã‚ˆã£ã¦ãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã‚‹ã‚‚ã®ã§ã¯ãªã„ã‹ã‚‰ã§ã™ã€‚ã€
304 304
3052.6.x.y -stable カーãƒãƒ«ãƒ„リー 3053.x.y -stable カーãƒãƒ«ãƒ„リー
306--------------------------- 306---------------------------
307 307
308ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ãŒ4ã¤ã®æ•°å­—ã«åˆ†ã‹ã‚Œã¦ã„るカーãƒãƒ«ã¯ -stable カーãƒãƒ«ã§ã™ã€‚ 308ãƒãƒ¼ã‚¸ãƒ§ãƒ³ç•ªå·ãŒ3ã¤ã®æ•°å­—ã«åˆ†ã‹ã‚Œã¦ã„るカーãƒãƒ«ã¯ -stable カーãƒãƒ«ã§ã™ã€‚
309ã“ã‚Œã«ã¯ã€2.6.x カーãƒãƒ«ã§è¦‹ã¤ã‹ã£ãŸã‚»ã‚­ãƒ¥ãƒªãƒ†ã‚£å•é¡Œã‚„é‡å¤§ãªå¾Œæˆ»ã‚Šã«å¯¾ 309ã“ã‚Œã«ã¯ã€3.x カーãƒãƒ«ã§è¦‹ã¤ã‹ã£ãŸã‚»ã‚­ãƒ¥ãƒªãƒ†ã‚£å•é¡Œã‚„é‡å¤§ãªå¾Œæˆ»ã‚Šã«å¯¾
310ã™ã‚‹æ¯”較的å°ã•ã„é‡è¦ãªä¿®æ­£ãŒå«ã¾ã‚Œã¾ã™ã€‚ 310ã™ã‚‹æ¯”較的å°ã•ã„é‡è¦ãªä¿®æ­£ãŒå«ã¾ã‚Œã¾ã™ã€‚
311 311
312ã“ã‚Œã¯ã€é–‹ç™º/実験的ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ãƒ†ã‚¹ãƒˆã«å”力ã™ã‚‹ã“ã¨ã«èˆˆå‘³ãŒç„¡ã〠312ã“ã‚Œã¯ã€é–‹ç™º/実験的ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®ãƒ†ã‚¹ãƒˆã«å”力ã™ã‚‹ã“ã¨ã«èˆˆå‘³ãŒç„¡ãã€
313最新ã®å®‰å®šã—ãŸã‚«ãƒ¼ãƒãƒ«ã‚’使ã„ãŸã„ユーザã«æŽ¨å¥¨ã™ã‚‹ãƒ–ランãƒã§ã™ã€‚ 313最新ã®å®‰å®šã—ãŸã‚«ãƒ¼ãƒãƒ«ã‚’使ã„ãŸã„ユーザã«æŽ¨å¥¨ã™ã‚‹ãƒ–ランãƒã§ã™ã€‚
314 314
315ã‚‚ã—ã€2.6.x.y カーãƒãƒ«ãŒå­˜åœ¨ã—ãªã„å ´åˆã«ã¯ã€ç•ªå·ãŒä¸€ç•ªå¤§ãã„ 2.6.x ㌠315ã‚‚ã—ã€3.x.y カーãƒãƒ«ãŒå­˜åœ¨ã—ãªã„å ´åˆã«ã¯ã€ç•ªå·ãŒä¸€ç•ªå¤§ãã„ 3.x ãŒ
316最新ã®å®‰å®šç‰ˆã‚«ãƒ¼ãƒãƒ«ã§ã™ã€‚ 316最新ã®å®‰å®šç‰ˆã‚«ãƒ¼ãƒãƒ«ã§ã™ã€‚
317 317
3182.6.x.y 㯠"stable" ãƒãƒ¼ãƒ  <stable@kernel.org> ã§ãƒ¡ãƒ³ãƒ†ã•ã‚Œã¦ãŠã‚Šã€å¿… 3183.x.y 㯠"stable" ãƒãƒ¼ãƒ  <stable@kernel.org> ã§ãƒ¡ãƒ³ãƒ†ã•ã‚Œã¦ãŠã‚Šã€å¿…
319è¦ã«å¿œã˜ã¦ãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã¾ã™ã€‚通常ã®ãƒªãƒªãƒ¼ã‚¹æœŸé–“㯠2週間毎ã§ã™ãŒã€å·®ã—迫㣠319è¦ã«å¿œã˜ã¦ãƒªãƒªãƒ¼ã‚¹ã•ã‚Œã¾ã™ã€‚通常ã®ãƒªãƒªãƒ¼ã‚¹æœŸé–“㯠2週間毎ã§ã™ãŒã€å·®ã—è¿«ã£
320ãŸå•é¡ŒãŒãªã‘ã‚Œã°ã‚‚ã†å°‘ã—é•·ããªã‚‹ã“ã¨ã‚‚ã‚ã‚Šã¾ã™ã€‚セキュリティ関連ã®å•é¡Œ 320ãŸå•é¡ŒãŒãªã‘ã‚Œã°ã‚‚ã†å°‘ã—é•·ããªã‚‹ã“ã¨ã‚‚ã‚ã‚Šã¾ã™ã€‚セキュリティ関連ã®å•é¡Œ
321ã®å ´åˆã¯ã“ã‚Œã«å¯¾ã—ã¦ã ã„ãŸã„ã®å ´åˆã€ã™ãã«ãƒªãƒªãƒ¼ã‚¹ãŒã•ã‚Œã¾ã™ã€‚ 321ã®å ´åˆã¯ã“ã‚Œã«å¯¾ã—ã¦ã ã„ãŸã„ã®å ´åˆã€ã™ãã«ãƒªãƒªãƒ¼ã‚¹ãŒã•ã‚Œã¾ã™ã€‚
@@ -324,7 +324,7 @@ Andrew Morton ㌠Linux-kernel メーリングリストã«ã‚«ãƒ¼ãƒãƒ«ãƒªãƒªãƒ¼ã
324イルã«ã¯ã©ã®ã‚ˆã†ãªç¨®é¡žã®å¤‰æ›´ãŒ -stable ツリーã«å—ã‘入れå¯èƒ½ã‹ã€ã¾ãŸãƒª 324イルã«ã¯ã©ã®ã‚ˆã†ãªç¨®é¡žã®å¤‰æ›´ãŒ -stable ツリーã«å—ã‘入れå¯èƒ½ã‹ã€ã¾ãŸãƒª
325リースプロセスãŒã©ã†å‹•ãã‹ãŒè¨˜è¿°ã•ã‚Œã¦ã„ã¾ã™ã€‚ 325リースプロセスãŒã©ã†å‹•ãã‹ãŒè¨˜è¿°ã•ã‚Œã¦ã„ã¾ã™ã€‚
326 326
3272.6.x -git パッム3273.x -git パッãƒ
328------------------ 328------------------
329 329
330git リãƒã‚¸ãƒˆãƒªã§ç®¡ç†ã•ã‚Œã¦ã„ã‚‹Linus ã®ã‚«ãƒ¼ãƒãƒ«ãƒ„リーã®æ¯Žæ—¥ã®ã‚¹ãƒŠãƒƒãƒ— 330git リãƒã‚¸ãƒˆãƒªã§ç®¡ç†ã•ã‚Œã¦ã„ã‚‹Linus ã®ã‚«ãƒ¼ãƒãƒ«ãƒ„リーã®æ¯Žæ—¥ã®ã‚¹ãƒŠãƒƒãƒ—
@@ -358,14 +358,14 @@ quilt シリーズã¨ã—ã¦å…¬é–‹ã•ã‚Œã¦ã„るパッãƒã‚­ãƒ¥ãƒ¼ã‚‚使ã‚ã‚Œã
358ã‚’ã¤ã‘ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚大部分ã®ã“れら㮠patchwork ã®ã‚µã‚¤ãƒˆã¯ 358ã‚’ã¤ã‘ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚大部分ã®ã“れら㮠patchwork ã®ã‚µã‚¤ãƒˆã¯
359http://patchwork.kernel.org/ ã§ãƒªã‚¹ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚ 359http://patchwork.kernel.org/ ã§ãƒªã‚¹ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚
360 360
361çµ±åˆãƒ†ã‚¹ãƒˆã®ãŸã‚ã® 2.6.x -next カーãƒãƒ«ãƒ„リー 361çµ±åˆãƒ†ã‚¹ãƒˆã®ãŸã‚ã® 3.x -next カーãƒãƒ«ãƒ„リー
362--------------------------------------------- 362---------------------------------------------
363 363
364サブシステムツリーã®æ›´æ–°å†…容ãŒãƒ¡ã‚¤ãƒ³ãƒ©ã‚¤ãƒ³ã® 2.6.x ツリーã«ãƒžãƒ¼ã‚¸ã•ã‚Œ 364サブシステムツリーã®æ›´æ–°å†…容ãŒãƒ¡ã‚¤ãƒ³ãƒ©ã‚¤ãƒ³ã® 3.x ツリーã«ãƒžãƒ¼ã‚¸ã•ã‚Œ
365ã‚‹å‰ã«ã€ãれらã¯çµ±åˆãƒ†ã‚¹ãƒˆã•ã‚Œã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ã“ã®ç›®çš„ã®ãŸã‚ã€å®Ÿè³ªçš„ 365ã‚‹å‰ã«ã€ãれらã¯çµ±åˆãƒ†ã‚¹ãƒˆã•ã‚Œã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ã“ã®ç›®çš„ã®ãŸã‚ã€å®Ÿè³ªçš„
366ã«å…¨ã‚µãƒ–システムツリーã‹ã‚‰ã»ã¼æ¯Žæ—¥ãƒ—ルã•ã‚Œã¦ã§ãる特別ãªãƒ†ã‚¹ãƒˆç”¨ã®ãƒª 366ã«å…¨ã‚µãƒ–システムツリーã‹ã‚‰ã»ã¼æ¯Žæ—¥ãƒ—ルã•ã‚Œã¦ã§ãる特別ãªãƒ†ã‚¹ãƒˆç”¨ã®ãƒª
367ãƒã‚¸ãƒˆãƒªãŒå­˜åœ¨ã—ã¾ã™- 367ãƒã‚¸ãƒˆãƒªãŒå­˜åœ¨ã—ã¾ã™-
368 http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git 368 http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
369 http://linux.f-seidel.de/linux-next/pmwiki/ 369 http://linux.f-seidel.de/linux-next/pmwiki/
370 370
371ã“ã®ã‚„ã‚Šæ–¹ã«ã‚ˆã£ã¦ã€-next カーãƒãƒ«ã¯æ¬¡ã®ãƒžãƒ¼ã‚¸æ©Ÿä¼šã§ã©ã‚“ãªã‚‚ã®ãŒãƒ¡ã‚¤ãƒ³ 371ã“ã®ã‚„ã‚Šæ–¹ã«ã‚ˆã£ã¦ã€-next カーãƒãƒ«ã¯æ¬¡ã®ãƒžãƒ¼ã‚¸æ©Ÿä¼šã§ã©ã‚“ãªã‚‚ã®ãŒãƒ¡ã‚¤ãƒ³
diff --git a/MAINTAINERS b/MAINTAINERS
index bf61e04291ab..a26b10e52aea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1642,7 +1642,7 @@ S: Maintained
1642F: drivers/net/hamradio/baycom* 1642F: drivers/net/hamradio/baycom*
1643 1643
1644BCACHE (BLOCK LAYER CACHE) 1644BCACHE (BLOCK LAYER CACHE)
1645M: Kent Overstreet <koverstreet@google.com> 1645M: Kent Overstreet <kmo@daterainc.com>
1646L: linux-bcache@vger.kernel.org 1646L: linux-bcache@vger.kernel.org
1647W: http://bcache.evilpiepirate.org 1647W: http://bcache.evilpiepirate.org
1648S: Maintained: 1648S: Maintained:
@@ -3346,7 +3346,7 @@ F: Documentation/firmware_class/
3346F: drivers/base/firmware*.c 3346F: drivers/base/firmware*.c
3347F: include/linux/firmware.h 3347F: include/linux/firmware.h
3348 3348
3349FLASHSYSTEM DRIVER (IBM FlashSystem 70/80 PCI SSD Flash Card) 3349FLASH ADAPTER DRIVER (IBM Flash Adapter 900GB Full Height PCI Flash Card)
3350M: Joshua Morris <josh.h.morris@us.ibm.com> 3350M: Joshua Morris <josh.h.morris@us.ibm.com>
3351M: Philip Kelleher <pjk1939@linux.vnet.ibm.com> 3351M: Philip Kelleher <pjk1939@linux.vnet.ibm.com>
3352S: Maintained 3352S: Maintained
@@ -3622,11 +3622,9 @@ F: drivers/isdn/gigaset/
3622F: include/uapi/linux/gigaset_dev.h 3622F: include/uapi/linux/gigaset_dev.h
3623 3623
3624GPIO SUBSYSTEM 3624GPIO SUBSYSTEM
3625M: Grant Likely <grant.likely@linaro.org>
3626M: Linus Walleij <linus.walleij@linaro.org> 3625M: Linus Walleij <linus.walleij@linaro.org>
3627S: Maintained 3626S: Maintained
3628L: linux-gpio@vger.kernel.org 3627L: linux-gpio@vger.kernel.org
3629T: git git://git.secretlab.ca/git/linux-2.6.git
3630F: Documentation/gpio.txt 3628F: Documentation/gpio.txt
3631F: drivers/gpio/ 3629F: drivers/gpio/
3632F: include/linux/gpio* 3630F: include/linux/gpio*
@@ -4472,8 +4470,6 @@ F: drivers/irqchip/
4472 4470
4473IRQ DOMAINS (IRQ NUMBER MAPPING LIBRARY) 4471IRQ DOMAINS (IRQ NUMBER MAPPING LIBRARY)
4474M: Benjamin Herrenschmidt <benh@kernel.crashing.org> 4472M: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4475M: Grant Likely <grant.likely@linaro.org>
4476T: git git://git.secretlab.ca/git/linux-2.6.git irqdomain/next
4477S: Maintained 4473S: Maintained
4478F: Documentation/IRQ-domain.txt 4474F: Documentation/IRQ-domain.txt
4479F: include/linux/irqdomain.h 4475F: include/linux/irqdomain.h
@@ -4990,7 +4986,7 @@ F: arch/powerpc/platforms/44x/
4990 4986
4991LINUX FOR POWERPC EMBEDDED XILINX VIRTEX 4987LINUX FOR POWERPC EMBEDDED XILINX VIRTEX
4992L: linuxppc-dev@lists.ozlabs.org 4988L: linuxppc-dev@lists.ozlabs.org
4993S: Unmaintained 4989S: Orphan
4994F: arch/powerpc/*/*virtex* 4990F: arch/powerpc/*/*virtex*
4995F: arch/powerpc/*/*/*virtex* 4991F: arch/powerpc/*/*/*virtex*
4996 4992
@@ -5886,7 +5882,7 @@ OMAP DEVICE TREE SUPPORT
5886M: Benoît Cousson <b-cousson@ti.com> 5882M: Benoît Cousson <b-cousson@ti.com>
5887M: Tony Lindgren <tony@atomide.com> 5883M: Tony Lindgren <tony@atomide.com>
5888L: linux-omap@vger.kernel.org 5884L: linux-omap@vger.kernel.org
5889L: devicetree-discuss@lists.ozlabs.org (moderated for non-subscribers) 5885L: devicetree@vger.kernel.org
5890S: Maintained 5886S: Maintained
5891F: arch/arm/boot/dts/*omap* 5887F: arch/arm/boot/dts/*omap*
5892F: arch/arm/boot/dts/*am3* 5888F: arch/arm/boot/dts/*am3*
@@ -6050,17 +6046,28 @@ F: drivers/i2c/busses/i2c-ocores.c
6050OPEN FIRMWARE AND FLATTENED DEVICE TREE 6046OPEN FIRMWARE AND FLATTENED DEVICE TREE
6051M: Grant Likely <grant.likely@linaro.org> 6047M: Grant Likely <grant.likely@linaro.org>
6052M: Rob Herring <rob.herring@calxeda.com> 6048M: Rob Herring <rob.herring@calxeda.com>
6053L: devicetree-discuss@lists.ozlabs.org (moderated for non-subscribers) 6049L: devicetree@vger.kernel.org
6054W: http://fdt.secretlab.ca 6050W: http://fdt.secretlab.ca
6055T: git git://git.secretlab.ca/git/linux-2.6.git 6051T: git git://git.secretlab.ca/git/linux-2.6.git
6056S: Maintained 6052S: Maintained
6057F: Documentation/devicetree 6053F: drivers/of/
6058F: drivers/of
6059F: include/linux/of*.h 6054F: include/linux/of*.h
6060F: scripts/dtc 6055F: scripts/dtc/
6061K: of_get_property 6056K: of_get_property
6062K: of_match_table 6057K: of_match_table
6063 6058
6059OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
6060M: Rob Herring <rob.herring@calxeda.com>
6061M: Pawel Moll <pawel.moll@arm.com>
6062M: Mark Rutland <mark.rutland@arm.com>
6063M: Stephen Warren <swarren@wwwdotorg.org>
6064M: Ian Campbell <ian.campbell@citrix.com>
6065L: devicetree@vger.kernel.org
6066S: Maintained
6067F: Documentation/devicetree/
6068F: arch/*/boot/dts/
6069F: include/dt-bindings/
6070
6064OPENRISC ARCHITECTURE 6071OPENRISC ARCHITECTURE
6065M: Jonas Bonn <jonas@southpole.se> 6072M: Jonas Bonn <jonas@southpole.se>
6066W: http://openrisc.net 6073W: http://openrisc.net
@@ -7746,7 +7753,6 @@ F: drivers/clk/spear/
7746 7753
7747SPI SUBSYSTEM 7754SPI SUBSYSTEM
7748M: Mark Brown <broonie@kernel.org> 7755M: Mark Brown <broonie@kernel.org>
7749M: Grant Likely <grant.likely@linaro.org>
7750L: linux-spi@vger.kernel.org 7756L: linux-spi@vger.kernel.org
7751T: git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 7757T: git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
7752Q: http://patchwork.kernel.org/project/spi-devel-general/list/ 7758Q: http://patchwork.kernel.org/project/spi-devel-general/list/
@@ -7812,7 +7818,7 @@ F: drivers/staging/asus_oled/
7812 7818
7813STAGING - COMEDI 7819STAGING - COMEDI
7814M: Ian Abbott <abbotti@mev.co.uk> 7820M: Ian Abbott <abbotti@mev.co.uk>
7815M: Mori Hess <fmhess@users.sourceforge.net> 7821M: H Hartley Sweeten <hsweeten@visionengravers.com>
7816S: Odd Fixes 7822S: Odd Fixes
7817F: drivers/staging/comedi/ 7823F: drivers/staging/comedi/
7818 7824
@@ -9288,7 +9294,7 @@ S: Maintained
9288F: drivers/net/ethernet/xilinx/xilinx_axienet* 9294F: drivers/net/ethernet/xilinx/xilinx_axienet*
9289 9295
9290XILINX SYSTEMACE DRIVER 9296XILINX SYSTEMACE DRIVER
9291S: Unmaintained 9297S: Orphan
9292F: drivers/block/xsysace.c 9298F: drivers/block/xsysace.c
9293 9299
9294XILINX UARTLITE SERIAL DRIVER 9300XILINX UARTLITE SERIAL DRIVER
diff --git a/Makefile b/Makefile
index 9262ba8da4f9..95a8e55feceb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 11 2PATCHLEVEL = 11
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc3
5NAME = Linux for Workgroups 5NAME = Linux for Workgroups
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 837a1f2d8b96..082d9b4b5472 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -15,6 +15,7 @@ config ALPHA
15 select ARCH_WANT_OPTIONAL_GPIOLIB 15 select ARCH_WANT_OPTIONAL_GPIOLIB
16 select ARCH_WANT_IPC_PARSE_VERSION 16 select ARCH_WANT_IPC_PARSE_VERSION
17 select ARCH_HAVE_NMI_SAFE_CMPXCHG 17 select ARCH_HAVE_NMI_SAFE_CMPXCHG
18 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
18 select GENERIC_SMP_IDLE_THREAD 19 select GENERIC_SMP_IDLE_THREAD
19 select GENERIC_CMOS_UPDATE 20 select GENERIC_CMOS_UPDATE
20 select GENERIC_STRNCPY_FROM_USER 21 select GENERIC_STRNCPY_FROM_USER
diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
index c2cbe4fc391c..78b03ef39f6f 100644
--- a/arch/alpha/include/asm/atomic.h
+++ b/arch/alpha/include/asm/atomic.h
@@ -186,17 +186,24 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
186 */ 186 */
187static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u) 187static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
188{ 188{
189 int c, old; 189 int c, new, old;
190 c = atomic_read(v); 190 smp_mb();
191 for (;;) { 191 __asm__ __volatile__(
192 if (unlikely(c == (u))) 192 "1: ldl_l %[old],%[mem]\n"
193 break; 193 " cmpeq %[old],%[u],%[c]\n"
194 old = atomic_cmpxchg((v), c, c + (a)); 194 " addl %[old],%[a],%[new]\n"
195 if (likely(old == c)) 195 " bne %[c],2f\n"
196 break; 196 " stl_c %[new],%[mem]\n"
197 c = old; 197 " beq %[new],3f\n"
198 } 198 "2:\n"
199 return c; 199 ".subsection 2\n"
200 "3: br 1b\n"
201 ".previous"
202 : [old] "=&r"(old), [new] "=&r"(new), [c] "=&r"(c)
203 : [mem] "m"(*v), [a] "rI"(a), [u] "rI"((long)u)
204 : "memory");
205 smp_mb();
206 return old;
200} 207}
201 208
202 209
@@ -207,21 +214,56 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
207 * @u: ...unless v is equal to u. 214 * @u: ...unless v is equal to u.
208 * 215 *
209 * Atomically adds @a to @v, so long as it was not @u. 216 * Atomically adds @a to @v, so long as it was not @u.
210 * Returns the old value of @v. 217 * Returns true iff @v was not @u.
211 */ 218 */
212static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) 219static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
213{ 220{
214 long c, old; 221 long c, tmp;
215 c = atomic64_read(v); 222 smp_mb();
216 for (;;) { 223 __asm__ __volatile__(
217 if (unlikely(c == (u))) 224 "1: ldq_l %[tmp],%[mem]\n"
218 break; 225 " cmpeq %[tmp],%[u],%[c]\n"
219 old = atomic64_cmpxchg((v), c, c + (a)); 226 " addq %[tmp],%[a],%[tmp]\n"
220 if (likely(old == c)) 227 " bne %[c],2f\n"
221 break; 228 " stq_c %[tmp],%[mem]\n"
222 c = old; 229 " beq %[tmp],3f\n"
223 } 230 "2:\n"
224 return c != (u); 231 ".subsection 2\n"
232 "3: br 1b\n"
233 ".previous"
234 : [tmp] "=&r"(tmp), [c] "=&r"(c)
235 : [mem] "m"(*v), [a] "rI"(a), [u] "rI"(u)
236 : "memory");
237 smp_mb();
238 return !c;
239}
240
241/*
242 * atomic64_dec_if_positive - decrement by 1 if old value positive
243 * @v: pointer of type atomic_t
244 *
245 * The function returns the old value of *v minus 1, even if
246 * the atomic variable, v, was not decremented.
247 */
248static inline long atomic64_dec_if_positive(atomic64_t *v)
249{
250 long old, tmp;
251 smp_mb();
252 __asm__ __volatile__(
253 "1: ldq_l %[old],%[mem]\n"
254 " subq %[old],1,%[tmp]\n"
255 " ble %[old],2f\n"
256 " stq_c %[tmp],%[mem]\n"
257 " beq %[tmp],3f\n"
258 "2:\n"
259 ".subsection 2\n"
260 "3: br 1b\n"
261 ".previous"
262 : [old] "=&r"(old), [tmp] "=&r"(tmp)
263 : [mem] "m"(*v)
264 : "memory");
265 smp_mb();
266 return old - 1;
225} 267}
226 268
227#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) 269#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
diff --git a/arch/alpha/include/asm/param.h b/arch/alpha/include/asm/param.h
index bf46af51941b..a5b68b268bcf 100644
--- a/arch/alpha/include/asm/param.h
+++ b/arch/alpha/include/asm/param.h
@@ -3,7 +3,9 @@
3 3
4#include <uapi/asm/param.h> 4#include <uapi/asm/param.h>
5 5
6#define HZ CONFIG_HZ 6# undef HZ
7#define USER_HZ HZ 7# define HZ CONFIG_HZ
8# define CLOCKS_PER_SEC HZ /* frequency at which times() counts */ 8# define USER_HZ 1024
9# define CLOCKS_PER_SEC USER_HZ /* frequency at which times() counts */
10
9#endif /* _ASM_ALPHA_PARAM_H */ 11#endif /* _ASM_ALPHA_PARAM_H */
diff --git a/arch/alpha/include/asm/spinlock.h b/arch/alpha/include/asm/spinlock.h
index 3bba21e41b81..37b570d01202 100644
--- a/arch/alpha/include/asm/spinlock.h
+++ b/arch/alpha/include/asm/spinlock.h
@@ -168,8 +168,4 @@ static inline void arch_write_unlock(arch_rwlock_t * lock)
168#define arch_read_lock_flags(lock, flags) arch_read_lock(lock) 168#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
169#define arch_write_lock_flags(lock, flags) arch_write_lock(lock) 169#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
170 170
171#define arch_spin_relax(lock) cpu_relax()
172#define arch_read_relax(lock) cpu_relax()
173#define arch_write_relax(lock) cpu_relax()
174
175#endif /* _ALPHA_SPINLOCK_H */ 171#endif /* _ALPHA_SPINLOCK_H */
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h
index 43baee17acdf..f2c94402e2c8 100644
--- a/arch/alpha/include/asm/unistd.h
+++ b/arch/alpha/include/asm/unistd.h
@@ -3,8 +3,7 @@
3 3
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6 6#define NR_SYSCALLS 508
7#define NR_SYSCALLS 506
8 7
9#define __ARCH_WANT_OLD_READDIR 8#define __ARCH_WANT_OLD_READDIR
10#define __ARCH_WANT_STAT64 9#define __ARCH_WANT_STAT64
diff --git a/arch/alpha/include/uapi/asm/param.h b/arch/alpha/include/uapi/asm/param.h
index 29daed819ebd..dbcd9834af6d 100644
--- a/arch/alpha/include/uapi/asm/param.h
+++ b/arch/alpha/include/uapi/asm/param.h
@@ -1,13 +1,7 @@
1#ifndef _UAPI_ASM_ALPHA_PARAM_H 1#ifndef _UAPI_ASM_ALPHA_PARAM_H
2#define _UAPI_ASM_ALPHA_PARAM_H 2#define _UAPI_ASM_ALPHA_PARAM_H
3 3
4/* ??? Gross. I don't want to parameterize this, and supposedly the
5 hardware ignores reprogramming. We also need userland buy-in to the
6 change in HZ, since this is visible in the wait4 resources etc. */
7
8#ifndef __KERNEL__
9#define HZ 1024 4#define HZ 1024
10#endif
11 5
12#define EXEC_PAGESIZE 8192 6#define EXEC_PAGESIZE 8192
13 7
@@ -17,5 +11,4 @@
17 11
18#define MAXHOSTNAMELEN 64 /* max length of hostname */ 12#define MAXHOSTNAMELEN 64 /* max length of hostname */
19 13
20
21#endif /* _UAPI_ASM_ALPHA_PARAM_H */ 14#endif /* _UAPI_ASM_ALPHA_PARAM_H */
diff --git a/arch/alpha/include/uapi/asm/unistd.h b/arch/alpha/include/uapi/asm/unistd.h
index 801d28bcea51..53ae7bb1bfd1 100644
--- a/arch/alpha/include/uapi/asm/unistd.h
+++ b/arch/alpha/include/uapi/asm/unistd.h
@@ -467,5 +467,7 @@
467#define __NR_sendmmsg 503 467#define __NR_sendmmsg 503
468#define __NR_process_vm_readv 504 468#define __NR_process_vm_readv 504
469#define __NR_process_vm_writev 505 469#define __NR_process_vm_writev 505
470#define __NR_kcmp 506
471#define __NR_finit_module 507
470 472
471#endif /* _UAPI_ALPHA_UNISTD_H */ 473#endif /* _UAPI_ALPHA_UNISTD_H */
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index f62a994ef126..a969b95ee5ac 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -12,11 +12,32 @@
12 12
13 .text 13 .text
14 .set noat 14 .set noat
15 .cfi_sections .debug_frame
15 16
16/* Stack offsets. */ 17/* Stack offsets. */
17#define SP_OFF 184 18#define SP_OFF 184
18#define SWITCH_STACK_SIZE 320 19#define SWITCH_STACK_SIZE 320
19 20
21.macro CFI_START_OSF_FRAME func
22 .align 4
23 .globl \func
24 .type \func,@function
25\func:
26 .cfi_startproc simple
27 .cfi_return_column 64
28 .cfi_def_cfa $sp, 48
29 .cfi_rel_offset 64, 8
30 .cfi_rel_offset $gp, 16
31 .cfi_rel_offset $16, 24
32 .cfi_rel_offset $17, 32
33 .cfi_rel_offset $18, 40
34.endm
35
36.macro CFI_END_OSF_FRAME func
37 .cfi_endproc
38 .size \func, . - \func
39.endm
40
20/* 41/*
21 * This defines the normal kernel pt-regs layout. 42 * This defines the normal kernel pt-regs layout.
22 * 43 *
@@ -27,100 +48,158 @@
27 * the palcode-provided values are available to the signal handler. 48 * the palcode-provided values are available to the signal handler.
28 */ 49 */
29 50
30#define SAVE_ALL \ 51.macro SAVE_ALL
31 subq $sp, SP_OFF, $sp; \ 52 subq $sp, SP_OFF, $sp
32 stq $0, 0($sp); \ 53 .cfi_adjust_cfa_offset SP_OFF
33 stq $1, 8($sp); \ 54 stq $0, 0($sp)
34 stq $2, 16($sp); \ 55 stq $1, 8($sp)
35 stq $3, 24($sp); \ 56 stq $2, 16($sp)
36 stq $4, 32($sp); \ 57 stq $3, 24($sp)
37 stq $28, 144($sp); \ 58 stq $4, 32($sp)
38 lda $2, alpha_mv; \ 59 stq $28, 144($sp)
39 stq $5, 40($sp); \ 60 .cfi_rel_offset $0, 0
40 stq $6, 48($sp); \ 61 .cfi_rel_offset $1, 8
41 stq $7, 56($sp); \ 62 .cfi_rel_offset $2, 16
42 stq $8, 64($sp); \ 63 .cfi_rel_offset $3, 24
43 stq $19, 72($sp); \ 64 .cfi_rel_offset $4, 32
44 stq $20, 80($sp); \ 65 .cfi_rel_offset $28, 144
45 stq $21, 88($sp); \ 66 lda $2, alpha_mv
46 ldq $2, HAE_CACHE($2); \ 67 stq $5, 40($sp)
47 stq $22, 96($sp); \ 68 stq $6, 48($sp)
48 stq $23, 104($sp); \ 69 stq $7, 56($sp)
49 stq $24, 112($sp); \ 70 stq $8, 64($sp)
50 stq $25, 120($sp); \ 71 stq $19, 72($sp)
51 stq $26, 128($sp); \ 72 stq $20, 80($sp)
52 stq $27, 136($sp); \ 73 stq $21, 88($sp)
53 stq $2, 152($sp); \ 74 ldq $2, HAE_CACHE($2)
54 stq $16, 160($sp); \ 75 stq $22, 96($sp)
55 stq $17, 168($sp); \ 76 stq $23, 104($sp)
77 stq $24, 112($sp)
78 stq $25, 120($sp)
79 stq $26, 128($sp)
80 stq $27, 136($sp)
81 stq $2, 152($sp)
82 stq $16, 160($sp)
83 stq $17, 168($sp)
56 stq $18, 176($sp) 84 stq $18, 176($sp)
85 .cfi_rel_offset $5, 40
86 .cfi_rel_offset $6, 48
87 .cfi_rel_offset $7, 56
88 .cfi_rel_offset $8, 64
89 .cfi_rel_offset $19, 72
90 .cfi_rel_offset $20, 80
91 .cfi_rel_offset $21, 88
92 .cfi_rel_offset $22, 96
93 .cfi_rel_offset $23, 104
94 .cfi_rel_offset $24, 112
95 .cfi_rel_offset $25, 120
96 .cfi_rel_offset $26, 128
97 .cfi_rel_offset $27, 136
98.endm
57 99
58#define RESTORE_ALL \ 100.macro RESTORE_ALL
59 lda $19, alpha_mv; \ 101 lda $19, alpha_mv
60 ldq $0, 0($sp); \ 102 ldq $0, 0($sp)
61 ldq $1, 8($sp); \ 103 ldq $1, 8($sp)
62 ldq $2, 16($sp); \ 104 ldq $2, 16($sp)
63 ldq $3, 24($sp); \ 105 ldq $3, 24($sp)
64 ldq $21, 152($sp); \ 106 ldq $21, 152($sp)
65 ldq $20, HAE_CACHE($19); \ 107 ldq $20, HAE_CACHE($19)
66 ldq $4, 32($sp); \ 108 ldq $4, 32($sp)
67 ldq $5, 40($sp); \ 109 ldq $5, 40($sp)
68 ldq $6, 48($sp); \ 110 ldq $6, 48($sp)
69 ldq $7, 56($sp); \ 111 ldq $7, 56($sp)
70 subq $20, $21, $20; \ 112 subq $20, $21, $20
71 ldq $8, 64($sp); \ 113 ldq $8, 64($sp)
72 beq $20, 99f; \ 114 beq $20, 99f
73 ldq $20, HAE_REG($19); \ 115 ldq $20, HAE_REG($19)
74 stq $21, HAE_CACHE($19); \ 116 stq $21, HAE_CACHE($19)
75 stq $21, 0($20); \ 117 stq $21, 0($20)
7699:; \ 11899: ldq $19, 72($sp)
77 ldq $19, 72($sp); \ 119 ldq $20, 80($sp)
78 ldq $20, 80($sp); \ 120 ldq $21, 88($sp)
79 ldq $21, 88($sp); \ 121 ldq $22, 96($sp)
80 ldq $22, 96($sp); \ 122 ldq $23, 104($sp)
81 ldq $23, 104($sp); \ 123 ldq $24, 112($sp)
82 ldq $24, 112($sp); \ 124 ldq $25, 120($sp)
83 ldq $25, 120($sp); \ 125 ldq $26, 128($sp)
84 ldq $26, 128($sp); \ 126 ldq $27, 136($sp)
85 ldq $27, 136($sp); \ 127 ldq $28, 144($sp)
86 ldq $28, 144($sp); \
87 addq $sp, SP_OFF, $sp 128 addq $sp, SP_OFF, $sp
129 .cfi_restore $0
130 .cfi_restore $1
131 .cfi_restore $2
132 .cfi_restore $3
133 .cfi_restore $4
134 .cfi_restore $5
135 .cfi_restore $6
136 .cfi_restore $7
137 .cfi_restore $8
138 .cfi_restore $19
139 .cfi_restore $20
140 .cfi_restore $21
141 .cfi_restore $22
142 .cfi_restore $23
143 .cfi_restore $24
144 .cfi_restore $25
145 .cfi_restore $26
146 .cfi_restore $27
147 .cfi_restore $28
148 .cfi_adjust_cfa_offset -SP_OFF
149.endm
150
151.macro DO_SWITCH_STACK
152 bsr $1, do_switch_stack
153 .cfi_adjust_cfa_offset SWITCH_STACK_SIZE
154 .cfi_rel_offset $9, 0
155 .cfi_rel_offset $10, 8
156 .cfi_rel_offset $11, 16
157 .cfi_rel_offset $12, 24
158 .cfi_rel_offset $13, 32
159 .cfi_rel_offset $14, 40
160 .cfi_rel_offset $15, 48
161 /* We don't really care about the FP registers for debugging. */
162.endm
163
164.macro UNDO_SWITCH_STACK
165 bsr $1, undo_switch_stack
166 .cfi_restore $9
167 .cfi_restore $10
168 .cfi_restore $11
169 .cfi_restore $12
170 .cfi_restore $13
171 .cfi_restore $14
172 .cfi_restore $15
173 .cfi_adjust_cfa_offset -SWITCH_STACK_SIZE
174.endm
88 175
89/* 176/*
90 * Non-syscall kernel entry points. 177 * Non-syscall kernel entry points.
91 */ 178 */
92 179
93 .align 4 180CFI_START_OSF_FRAME entInt
94 .globl entInt
95 .ent entInt
96entInt:
97 SAVE_ALL 181 SAVE_ALL
98 lda $8, 0x3fff 182 lda $8, 0x3fff
99 lda $26, ret_from_sys_call 183 lda $26, ret_from_sys_call
100 bic $sp, $8, $8 184 bic $sp, $8, $8
101 mov $sp, $19 185 mov $sp, $19
102 jsr $31, do_entInt 186 jsr $31, do_entInt
103.end entInt 187CFI_END_OSF_FRAME entInt
104 188
105 .align 4 189CFI_START_OSF_FRAME entArith
106 .globl entArith
107 .ent entArith
108entArith:
109 SAVE_ALL 190 SAVE_ALL
110 lda $8, 0x3fff 191 lda $8, 0x3fff
111 lda $26, ret_from_sys_call 192 lda $26, ret_from_sys_call
112 bic $sp, $8, $8 193 bic $sp, $8, $8
113 mov $sp, $18 194 mov $sp, $18
114 jsr $31, do_entArith 195 jsr $31, do_entArith
115.end entArith 196CFI_END_OSF_FRAME entArith
116 197
117 .align 4 198CFI_START_OSF_FRAME entMM
118 .globl entMM
119 .ent entMM
120entMM:
121 SAVE_ALL 199 SAVE_ALL
122/* save $9 - $15 so the inline exception code can manipulate them. */ 200/* save $9 - $15 so the inline exception code can manipulate them. */
123 subq $sp, 56, $sp 201 subq $sp, 56, $sp
202 .cfi_adjust_cfa_offset 56
124 stq $9, 0($sp) 203 stq $9, 0($sp)
125 stq $10, 8($sp) 204 stq $10, 8($sp)
126 stq $11, 16($sp) 205 stq $11, 16($sp)
@@ -128,6 +207,13 @@ entMM:
128 stq $13, 32($sp) 207 stq $13, 32($sp)
129 stq $14, 40($sp) 208 stq $14, 40($sp)
130 stq $15, 48($sp) 209 stq $15, 48($sp)
210 .cfi_rel_offset $9, 0
211 .cfi_rel_offset $10, 8
212 .cfi_rel_offset $11, 16
213 .cfi_rel_offset $12, 24
214 .cfi_rel_offset $13, 32
215 .cfi_rel_offset $14, 40
216 .cfi_rel_offset $15, 48
131 addq $sp, 56, $19 217 addq $sp, 56, $19
132/* handle the fault */ 218/* handle the fault */
133 lda $8, 0x3fff 219 lda $8, 0x3fff
@@ -142,28 +228,33 @@ entMM:
142 ldq $14, 40($sp) 228 ldq $14, 40($sp)
143 ldq $15, 48($sp) 229 ldq $15, 48($sp)
144 addq $sp, 56, $sp 230 addq $sp, 56, $sp
231 .cfi_restore $9
232 .cfi_restore $10
233 .cfi_restore $11
234 .cfi_restore $12
235 .cfi_restore $13
236 .cfi_restore $14
237 .cfi_restore $15
238 .cfi_adjust_cfa_offset -56
145/* finish up the syscall as normal. */ 239/* finish up the syscall as normal. */
146 br ret_from_sys_call 240 br ret_from_sys_call
147.end entMM 241CFI_END_OSF_FRAME entMM
148 242
149 .align 4 243CFI_START_OSF_FRAME entIF
150 .globl entIF
151 .ent entIF
152entIF:
153 SAVE_ALL 244 SAVE_ALL
154 lda $8, 0x3fff 245 lda $8, 0x3fff
155 lda $26, ret_from_sys_call 246 lda $26, ret_from_sys_call
156 bic $sp, $8, $8 247 bic $sp, $8, $8
157 mov $sp, $17 248 mov $sp, $17
158 jsr $31, do_entIF 249 jsr $31, do_entIF
159.end entIF 250CFI_END_OSF_FRAME entIF
160 251
161 .align 4 252CFI_START_OSF_FRAME entUna
162 .globl entUna
163 .ent entUna
164entUna:
165 lda $sp, -256($sp) 253 lda $sp, -256($sp)
254 .cfi_adjust_cfa_offset 256
166 stq $0, 0($sp) 255 stq $0, 0($sp)
256 .cfi_rel_offset $0, 0
257 .cfi_remember_state
167 ldq $0, 256($sp) /* get PS */ 258 ldq $0, 256($sp) /* get PS */
168 stq $1, 8($sp) 259 stq $1, 8($sp)
169 stq $2, 16($sp) 260 stq $2, 16($sp)
@@ -195,6 +286,32 @@ entUna:
195 stq $28, 224($sp) 286 stq $28, 224($sp)
196 mov $sp, $19 287 mov $sp, $19
197 stq $gp, 232($sp) 288 stq $gp, 232($sp)
289 .cfi_rel_offset $1, 1*8
290 .cfi_rel_offset $2, 2*8
291 .cfi_rel_offset $3, 3*8
292 .cfi_rel_offset $4, 4*8
293 .cfi_rel_offset $5, 5*8
294 .cfi_rel_offset $6, 6*8
295 .cfi_rel_offset $7, 7*8
296 .cfi_rel_offset $8, 8*8
297 .cfi_rel_offset $9, 9*8
298 .cfi_rel_offset $10, 10*8
299 .cfi_rel_offset $11, 11*8
300 .cfi_rel_offset $12, 12*8
301 .cfi_rel_offset $13, 13*8
302 .cfi_rel_offset $14, 14*8
303 .cfi_rel_offset $15, 15*8
304 .cfi_rel_offset $19, 19*8
305 .cfi_rel_offset $20, 20*8
306 .cfi_rel_offset $21, 21*8
307 .cfi_rel_offset $22, 22*8
308 .cfi_rel_offset $23, 23*8
309 .cfi_rel_offset $24, 24*8
310 .cfi_rel_offset $25, 25*8
311 .cfi_rel_offset $26, 26*8
312 .cfi_rel_offset $27, 27*8
313 .cfi_rel_offset $28, 28*8
314 .cfi_rel_offset $29, 29*8
198 lda $8, 0x3fff 315 lda $8, 0x3fff
199 stq $31, 248($sp) 316 stq $31, 248($sp)
200 bic $sp, $8, $8 317 bic $sp, $8, $8
@@ -228,16 +345,45 @@ entUna:
228 ldq $28, 224($sp) 345 ldq $28, 224($sp)
229 ldq $gp, 232($sp) 346 ldq $gp, 232($sp)
230 lda $sp, 256($sp) 347 lda $sp, 256($sp)
348 .cfi_restore $1
349 .cfi_restore $2
350 .cfi_restore $3
351 .cfi_restore $4
352 .cfi_restore $5
353 .cfi_restore $6
354 .cfi_restore $7
355 .cfi_restore $8
356 .cfi_restore $9
357 .cfi_restore $10
358 .cfi_restore $11
359 .cfi_restore $12
360 .cfi_restore $13
361 .cfi_restore $14
362 .cfi_restore $15
363 .cfi_restore $19
364 .cfi_restore $20
365 .cfi_restore $21
366 .cfi_restore $22
367 .cfi_restore $23
368 .cfi_restore $24
369 .cfi_restore $25
370 .cfi_restore $26
371 .cfi_restore $27
372 .cfi_restore $28
373 .cfi_restore $29
374 .cfi_adjust_cfa_offset -256
231 call_pal PAL_rti 375 call_pal PAL_rti
232.end entUna
233 376
234 .align 4 377 .align 4
235 .ent entUnaUser
236entUnaUser: 378entUnaUser:
379 .cfi_restore_state
237 ldq $0, 0($sp) /* restore original $0 */ 380 ldq $0, 0($sp) /* restore original $0 */
238 lda $sp, 256($sp) /* pop entUna's stack frame */ 381 lda $sp, 256($sp) /* pop entUna's stack frame */
382 .cfi_restore $0
383 .cfi_adjust_cfa_offset -256
239 SAVE_ALL /* setup normal kernel stack */ 384 SAVE_ALL /* setup normal kernel stack */
240 lda $sp, -56($sp) 385 lda $sp, -56($sp)
386 .cfi_adjust_cfa_offset 56
241 stq $9, 0($sp) 387 stq $9, 0($sp)
242 stq $10, 8($sp) 388 stq $10, 8($sp)
243 stq $11, 16($sp) 389 stq $11, 16($sp)
@@ -245,6 +391,13 @@ entUnaUser:
245 stq $13, 32($sp) 391 stq $13, 32($sp)
246 stq $14, 40($sp) 392 stq $14, 40($sp)
247 stq $15, 48($sp) 393 stq $15, 48($sp)
394 .cfi_rel_offset $9, 0
395 .cfi_rel_offset $10, 8
396 .cfi_rel_offset $11, 16
397 .cfi_rel_offset $12, 24
398 .cfi_rel_offset $13, 32
399 .cfi_rel_offset $14, 40
400 .cfi_rel_offset $15, 48
248 lda $8, 0x3fff 401 lda $8, 0x3fff
249 addq $sp, 56, $19 402 addq $sp, 56, $19
250 bic $sp, $8, $8 403 bic $sp, $8, $8
@@ -257,20 +410,25 @@ entUnaUser:
257 ldq $14, 40($sp) 410 ldq $14, 40($sp)
258 ldq $15, 48($sp) 411 ldq $15, 48($sp)
259 lda $sp, 56($sp) 412 lda $sp, 56($sp)
413 .cfi_restore $9
414 .cfi_restore $10
415 .cfi_restore $11
416 .cfi_restore $12
417 .cfi_restore $13
418 .cfi_restore $14
419 .cfi_restore $15
420 .cfi_adjust_cfa_offset -56
260 br ret_from_sys_call 421 br ret_from_sys_call
261.end entUnaUser 422CFI_END_OSF_FRAME entUna
262 423
263 .align 4 424CFI_START_OSF_FRAME entDbg
264 .globl entDbg
265 .ent entDbg
266entDbg:
267 SAVE_ALL 425 SAVE_ALL
268 lda $8, 0x3fff 426 lda $8, 0x3fff
269 lda $26, ret_from_sys_call 427 lda $26, ret_from_sys_call
270 bic $sp, $8, $8 428 bic $sp, $8, $8
271 mov $sp, $16 429 mov $sp, $16
272 jsr $31, do_entDbg 430 jsr $31, do_entDbg
273.end entDbg 431CFI_END_OSF_FRAME entDbg
274 432
275/* 433/*
276 * The system call entry point is special. Most importantly, it looks 434 * The system call entry point is special. Most importantly, it looks
@@ -285,8 +443,12 @@ entDbg:
285 443
286 .align 4 444 .align 4
287 .globl entSys 445 .globl entSys
288 .globl ret_from_sys_call 446 .type entSys, @function
289 .ent entSys 447 .cfi_startproc simple
448 .cfi_return_column 64
449 .cfi_def_cfa $sp, 48
450 .cfi_rel_offset 64, 8
451 .cfi_rel_offset $gp, 16
290entSys: 452entSys:
291 SAVE_ALL 453 SAVE_ALL
292 lda $8, 0x3fff 454 lda $8, 0x3fff
@@ -300,6 +462,9 @@ entSys:
300 stq $17, SP_OFF+32($sp) 462 stq $17, SP_OFF+32($sp)
301 s8addq $0, $5, $5 463 s8addq $0, $5, $5
302 stq $18, SP_OFF+40($sp) 464 stq $18, SP_OFF+40($sp)
465 .cfi_rel_offset $16, SP_OFF+24
466 .cfi_rel_offset $17, SP_OFF+32
467 .cfi_rel_offset $18, SP_OFF+40
303 blbs $3, strace 468 blbs $3, strace
304 beq $4, 1f 469 beq $4, 1f
305 ldq $27, 0($5) 470 ldq $27, 0($5)
@@ -310,6 +475,7 @@ entSys:
310 stq $31, 72($sp) /* a3=0 => no error */ 475 stq $31, 72($sp) /* a3=0 => no error */
311 476
312 .align 4 477 .align 4
478 .globl ret_from_sys_call
313ret_from_sys_call: 479ret_from_sys_call:
314 cmovne $26, 0, $18 /* $18 = 0 => non-restartable */ 480 cmovne $26, 0, $18 /* $18 = 0 => non-restartable */
315 ldq $0, SP_OFF($sp) 481 ldq $0, SP_OFF($sp)
@@ -324,10 +490,12 @@ ret_to_user:
324 and $17, _TIF_WORK_MASK, $2 490 and $17, _TIF_WORK_MASK, $2
325 bne $2, work_pending 491 bne $2, work_pending
326restore_all: 492restore_all:
493 .cfi_remember_state
327 RESTORE_ALL 494 RESTORE_ALL
328 call_pal PAL_rti 495 call_pal PAL_rti
329 496
330ret_to_kernel: 497ret_to_kernel:
498 .cfi_restore_state
331 lda $16, 7 499 lda $16, 7
332 call_pal PAL_swpipl 500 call_pal PAL_swpipl
333 br restore_all 501 br restore_all
@@ -356,7 +524,6 @@ $ret_success:
356 stq $0, 0($sp) 524 stq $0, 0($sp)
357 stq $31, 72($sp) /* a3=0 => no error */ 525 stq $31, 72($sp) /* a3=0 => no error */
358 br ret_from_sys_call 526 br ret_from_sys_call
359.end entSys
360 527
361/* 528/*
362 * Do all cleanup when returning from all interrupts and system calls. 529 * Do all cleanup when returning from all interrupts and system calls.
@@ -370,7 +537,7 @@ $ret_success:
370 */ 537 */
371 538
372 .align 4 539 .align 4
373 .ent work_pending 540 .type work_pending, @function
374work_pending: 541work_pending:
375 and $17, _TIF_NOTIFY_RESUME | _TIF_SIGPENDING, $2 542 and $17, _TIF_NOTIFY_RESUME | _TIF_SIGPENDING, $2
376 bne $2, $work_notifysig 543 bne $2, $work_notifysig
@@ -387,23 +554,22 @@ $work_resched:
387 554
388$work_notifysig: 555$work_notifysig:
389 mov $sp, $16 556 mov $sp, $16
390 bsr $1, do_switch_stack 557 DO_SWITCH_STACK
391 jsr $26, do_work_pending 558 jsr $26, do_work_pending
392 bsr $1, undo_switch_stack 559 UNDO_SWITCH_STACK
393 br restore_all 560 br restore_all
394.end work_pending
395 561
396/* 562/*
397 * PTRACE syscall handler 563 * PTRACE syscall handler
398 */ 564 */
399 565
400 .align 4 566 .align 4
401 .ent strace 567 .type strace, @function
402strace: 568strace:
403 /* set up signal stack, call syscall_trace */ 569 /* set up signal stack, call syscall_trace */
404 bsr $1, do_switch_stack 570 DO_SWITCH_STACK
405 jsr $26, syscall_trace_enter /* returns the syscall number */ 571 jsr $26, syscall_trace_enter /* returns the syscall number */
406 bsr $1, undo_switch_stack 572 UNDO_SWITCH_STACK
407 573
408 /* get the arguments back.. */ 574 /* get the arguments back.. */
409 ldq $16, SP_OFF+24($sp) 575 ldq $16, SP_OFF+24($sp)
@@ -431,9 +597,9 @@ ret_from_straced:
431$strace_success: 597$strace_success:
432 stq $0, 0($sp) /* save return value */ 598 stq $0, 0($sp) /* save return value */
433 599
434 bsr $1, do_switch_stack 600 DO_SWITCH_STACK
435 jsr $26, syscall_trace_leave 601 jsr $26, syscall_trace_leave
436 bsr $1, undo_switch_stack 602 UNDO_SWITCH_STACK
437 br $31, ret_from_sys_call 603 br $31, ret_from_sys_call
438 604
439 .align 3 605 .align 3
@@ -447,26 +613,31 @@ $strace_error:
447 stq $0, 0($sp) 613 stq $0, 0($sp)
448 stq $1, 72($sp) /* a3 for return */ 614 stq $1, 72($sp) /* a3 for return */
449 615
450 bsr $1, do_switch_stack 616 DO_SWITCH_STACK
451 mov $18, $9 /* save old syscall number */ 617 mov $18, $9 /* save old syscall number */
452 mov $19, $10 /* save old a3 */ 618 mov $19, $10 /* save old a3 */
453 jsr $26, syscall_trace_leave 619 jsr $26, syscall_trace_leave
454 mov $9, $18 620 mov $9, $18
455 mov $10, $19 621 mov $10, $19
456 bsr $1, undo_switch_stack 622 UNDO_SWITCH_STACK
457 623
458 mov $31, $26 /* tell "ret_from_sys_call" we can restart */ 624 mov $31, $26 /* tell "ret_from_sys_call" we can restart */
459 br ret_from_sys_call 625 br ret_from_sys_call
460.end strace 626CFI_END_OSF_FRAME entSys
461 627
462/* 628/*
463 * Save and restore the switch stack -- aka the balance of the user context. 629 * Save and restore the switch stack -- aka the balance of the user context.
464 */ 630 */
465 631
466 .align 4 632 .align 4
467 .ent do_switch_stack 633 .type do_switch_stack, @function
634 .cfi_startproc simple
635 .cfi_return_column 64
636 .cfi_def_cfa $sp, 0
637 .cfi_register 64, $1
468do_switch_stack: 638do_switch_stack:
469 lda $sp, -SWITCH_STACK_SIZE($sp) 639 lda $sp, -SWITCH_STACK_SIZE($sp)
640 .cfi_adjust_cfa_offset SWITCH_STACK_SIZE
470 stq $9, 0($sp) 641 stq $9, 0($sp)
471 stq $10, 8($sp) 642 stq $10, 8($sp)
472 stq $11, 16($sp) 643 stq $11, 16($sp)
@@ -510,10 +681,14 @@ do_switch_stack:
510 stt $f0, 312($sp) # save fpcr in slot of $f31 681 stt $f0, 312($sp) # save fpcr in slot of $f31
511 ldt $f0, 64($sp) # dont let "do_switch_stack" change fp state. 682 ldt $f0, 64($sp) # dont let "do_switch_stack" change fp state.
512 ret $31, ($1), 1 683 ret $31, ($1), 1
513.end do_switch_stack 684 .cfi_endproc
685 .size do_switch_stack, .-do_switch_stack
514 686
515 .align 4 687 .align 4
516 .ent undo_switch_stack 688 .type undo_switch_stack, @function
689 .cfi_startproc simple
690 .cfi_def_cfa $sp, 0
691 .cfi_register 64, $1
517undo_switch_stack: 692undo_switch_stack:
518 ldq $9, 0($sp) 693 ldq $9, 0($sp)
519 ldq $10, 8($sp) 694 ldq $10, 8($sp)
@@ -558,7 +733,8 @@ undo_switch_stack:
558 ldt $f30, 304($sp) 733 ldt $f30, 304($sp)
559 lda $sp, SWITCH_STACK_SIZE($sp) 734 lda $sp, SWITCH_STACK_SIZE($sp)
560 ret $31, ($1), 1 735 ret $31, ($1), 1
561.end undo_switch_stack 736 .cfi_endproc
737 .size undo_switch_stack, .-undo_switch_stack
562 738
563/* 739/*
564 * The meat of the context switch code. 740 * The meat of the context switch code.
@@ -566,17 +742,18 @@ undo_switch_stack:
566 742
567 .align 4 743 .align 4
568 .globl alpha_switch_to 744 .globl alpha_switch_to
569 .ent alpha_switch_to 745 .type alpha_switch_to, @function
746 .cfi_startproc
570alpha_switch_to: 747alpha_switch_to:
571 .prologue 0 748 DO_SWITCH_STACK
572 bsr $1, do_switch_stack
573 call_pal PAL_swpctx 749 call_pal PAL_swpctx
574 lda $8, 0x3fff 750 lda $8, 0x3fff
575 bsr $1, undo_switch_stack 751 UNDO_SWITCH_STACK
576 bic $sp, $8, $8 752 bic $sp, $8, $8
577 mov $17, $0 753 mov $17, $0
578 ret 754 ret
579.end alpha_switch_to 755 .cfi_endproc
756 .size alpha_switch_to, .-alpha_switch_to
580 757
581/* 758/*
582 * New processes begin life here. 759 * New processes begin life here.
diff --git a/arch/alpha/kernel/irq_alpha.c b/arch/alpha/kernel/irq_alpha.c
index f433fc11877a..28e4429596f3 100644
--- a/arch/alpha/kernel/irq_alpha.c
+++ b/arch/alpha/kernel/irq_alpha.c
@@ -236,7 +236,7 @@ void __init
236init_rtc_irq(void) 236init_rtc_irq(void)
237{ 237{
238 irq_set_chip_and_handler_name(RTC_IRQ, &dummy_irq_chip, 238 irq_set_chip_and_handler_name(RTC_IRQ, &dummy_irq_chip,
239 handle_simple_irq, "RTC"); 239 handle_percpu_irq, "RTC");
240 setup_irq(RTC_IRQ, &timer_irqaction); 240 setup_irq(RTC_IRQ, &timer_irqaction);
241} 241}
242 242
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 7b60834fb4b2..9dbbcb3b9146 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -116,7 +116,7 @@ wait_boot_cpu_to_stop(int cpuid)
116/* 116/*
117 * Where secondaries begin a life of C. 117 * Where secondaries begin a life of C.
118 */ 118 */
119void __cpuinit 119void
120smp_callin(void) 120smp_callin(void)
121{ 121{
122 int cpuid = hard_smp_processor_id(); 122 int cpuid = hard_smp_processor_id();
@@ -194,7 +194,7 @@ wait_for_txrdy (unsigned long cpumask)
194 * Send a message to a secondary's console. "START" is one such 194 * Send a message to a secondary's console. "START" is one such
195 * interesting message. ;-) 195 * interesting message. ;-)
196 */ 196 */
197static void __cpuinit 197static void
198send_secondary_console_msg(char *str, int cpuid) 198send_secondary_console_msg(char *str, int cpuid)
199{ 199{
200 struct percpu_struct *cpu; 200 struct percpu_struct *cpu;
@@ -264,9 +264,10 @@ recv_secondary_console_msg(void)
264 if (cnt <= 0 || cnt >= 80) 264 if (cnt <= 0 || cnt >= 80)
265 strcpy(buf, "<<< BOGUS MSG >>>"); 265 strcpy(buf, "<<< BOGUS MSG >>>");
266 else { 266 else {
267 cp1 = (char *) &cpu->ipc_buffer[11]; 267 cp1 = (char *) &cpu->ipc_buffer[1];
268 cp2 = buf; 268 cp2 = buf;
269 strcpy(cp2, cp1); 269 memcpy(cp2, cp1, cnt);
270 cp2[cnt] = '\0';
270 271
271 while ((cp2 = strchr(cp2, '\r')) != 0) { 272 while ((cp2 = strchr(cp2, '\r')) != 0) {
272 *cp2 = ' '; 273 *cp2 = ' ';
@@ -285,7 +286,7 @@ recv_secondary_console_msg(void)
285/* 286/*
286 * Convince the console to have a secondary cpu begin execution. 287 * Convince the console to have a secondary cpu begin execution.
287 */ 288 */
288static int __cpuinit 289static int
289secondary_cpu_start(int cpuid, struct task_struct *idle) 290secondary_cpu_start(int cpuid, struct task_struct *idle)
290{ 291{
291 struct percpu_struct *cpu; 292 struct percpu_struct *cpu;
@@ -356,7 +357,7 @@ secondary_cpu_start(int cpuid, struct task_struct *idle)
356/* 357/*
357 * Bring one cpu online. 358 * Bring one cpu online.
358 */ 359 */
359static int __cpuinit 360static int
360smp_boot_one_cpu(int cpuid, struct task_struct *idle) 361smp_boot_one_cpu(int cpuid, struct task_struct *idle)
361{ 362{
362 unsigned long timeout; 363 unsigned long timeout;
@@ -472,7 +473,7 @@ smp_prepare_boot_cpu(void)
472{ 473{
473} 474}
474 475
475int __cpuinit 476int
476__cpu_up(unsigned int cpu, struct task_struct *tidle) 477__cpu_up(unsigned int cpu, struct task_struct *tidle)
477{ 478{
478 smp_boot_one_cpu(cpu, tidle); 479 smp_boot_one_cpu(cpu, tidle);
diff --git a/arch/alpha/kernel/sys_dp264.c b/arch/alpha/kernel/sys_dp264.c
index 5bf401f7ea97..6c35159bc00e 100644
--- a/arch/alpha/kernel/sys_dp264.c
+++ b/arch/alpha/kernel/sys_dp264.c
@@ -190,9 +190,6 @@ static struct irq_chip clipper_irq_type = {
190static void 190static void
191dp264_device_interrupt(unsigned long vector) 191dp264_device_interrupt(unsigned long vector)
192{ 192{
193#if 1
194 printk("dp264_device_interrupt: NOT IMPLEMENTED YET!!\n");
195#else
196 unsigned long pld; 193 unsigned long pld;
197 unsigned int i; 194 unsigned int i;
198 195
@@ -210,12 +207,7 @@ dp264_device_interrupt(unsigned long vector)
210 isa_device_interrupt(vector); 207 isa_device_interrupt(vector);
211 else 208 else
212 handle_irq(16 + i); 209 handle_irq(16 + i);
213#if 0
214 TSUNAMI_cchip->dir0.csr = 1UL << i; mb();
215 tmp = TSUNAMI_cchip->dir0.csr;
216#endif
217 } 210 }
218#endif
219} 211}
220 212
221static void 213static void
diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c
index 407accc80877..c92e389ff219 100644
--- a/arch/alpha/kernel/sys_marvel.c
+++ b/arch/alpha/kernel/sys_marvel.c
@@ -317,8 +317,9 @@ marvel_init_irq(void)
317} 317}
318 318
319static int 319static int
320marvel_map_irq(struct pci_dev *dev, u8 slot, u8 pin) 320marvel_map_irq(const struct pci_dev *cdev, u8 slot, u8 pin)
321{ 321{
322 struct pci_dev *dev = (struct pci_dev *)cdev;
322 struct pci_controller *hose = dev->sysdata; 323 struct pci_controller *hose = dev->sysdata;
323 struct io7_port *io7_port = hose->sysdata; 324 struct io7_port *io7_port = hose->sysdata;
324 struct io7 *io7 = io7_port->io7; 325 struct io7 *io7 = io7_port->io7;
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 4284ec798ec9..dca9b3fb0071 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -524,6 +524,8 @@ sys_call_table:
524 .quad sys_sendmmsg 524 .quad sys_sendmmsg
525 .quad sys_process_vm_readv 525 .quad sys_process_vm_readv
526 .quad sys_process_vm_writev /* 505 */ 526 .quad sys_process_vm_writev /* 505 */
527 .quad sys_kcmp
528 .quad sys_finit_module
527 529
528 .size sys_call_table, . - sys_call_table 530 .size sys_call_table, . - sys_call_table
529 .type sys_call_table, @object 531 .type sys_call_table, @object
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index e336694ca042..ea3395036556 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -105,9 +105,7 @@ void arch_irq_work_raise(void)
105 105
106static inline __u32 rpcc(void) 106static inline __u32 rpcc(void)
107{ 107{
108 __u32 result; 108 return __builtin_alpha_rpcc();
109 asm volatile ("rpcc %0" : "=r"(result));
110 return result;
111} 109}
112 110
113int update_persistent_clock(struct timespec now) 111int update_persistent_clock(struct timespec now)
diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index affccb959a9e..bd0665cdc840 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -32,7 +32,7 @@
32 32
33static int opDEC_fix; 33static int opDEC_fix;
34 34
35static void __cpuinit 35static void
36opDEC_check(void) 36opDEC_check(void)
37{ 37{
38 __asm__ __volatile__ ( 38 __asm__ __volatile__ (
@@ -66,8 +66,8 @@ dik_show_regs(struct pt_regs *regs, unsigned long *r9_15)
66{ 66{
67 printk("pc = [<%016lx>] ra = [<%016lx>] ps = %04lx %s\n", 67 printk("pc = [<%016lx>] ra = [<%016lx>] ps = %04lx %s\n",
68 regs->pc, regs->r26, regs->ps, print_tainted()); 68 regs->pc, regs->r26, regs->ps, print_tainted());
69 print_symbol("pc is at %s\n", regs->pc); 69 printk("pc is at %pSR\n", (void *)regs->pc);
70 print_symbol("ra is at %s\n", regs->r26 ); 70 printk("ra is at %pSR\n", (void *)regs->r26);
71 printk("v0 = %016lx t0 = %016lx t1 = %016lx\n", 71 printk("v0 = %016lx t0 = %016lx t1 = %016lx\n",
72 regs->r0, regs->r1, regs->r2); 72 regs->r0, regs->r1, regs->r2);
73 printk("t2 = %016lx t3 = %016lx t4 = %016lx\n", 73 printk("t2 = %016lx t3 = %016lx t4 = %016lx\n",
@@ -132,9 +132,7 @@ dik_show_trace(unsigned long *sp)
132 continue; 132 continue;
133 if (tmp >= (unsigned long) &_etext) 133 if (tmp >= (unsigned long) &_etext)
134 continue; 134 continue;
135 printk("[<%lx>]", tmp); 135 printk("[<%lx>] %pSR\n", tmp, (void *)tmp);
136 print_symbol(" %s", tmp);
137 printk("\n");
138 if (i > 40) { 136 if (i > 40) {
139 printk(" ..."); 137 printk(" ...");
140 break; 138 break;
@@ -1059,7 +1057,7 @@ give_sigbus:
1059 return; 1057 return;
1060} 1058}
1061 1059
1062void __cpuinit 1060void
1063trap_init(void) 1061trap_init(void)
1064{ 1062{
1065 /* Tell PAL-code what global pointer we want in the kernel. */ 1063 /* Tell PAL-code what global pointer we want in the kernel. */
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ba412e02ec0c..37c0f4e978d4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1600,8 +1600,7 @@ config LOCAL_TIMERS
1600config ARCH_NR_GPIO 1600config ARCH_NR_GPIO
1601 int 1601 int
1602 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA 1602 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA
1603 default 512 if SOC_OMAP5 1603 default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5
1604 default 512 if ARCH_KEYSTONE
1605 default 392 if ARCH_U8500 1604 default 392 if ARCH_U8500
1606 default 352 if ARCH_VT8500 1605 default 352 if ARCH_VT8500
1607 default 288 if ARCH_SUNXI 1606 default 288 if ARCH_SUNXI
diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi
index 9866cd736dee..a0f2721ea583 100644
--- a/arch/arm/boot/dts/atlas6.dtsi
+++ b/arch/arm/boot/dts/atlas6.dtsi
@@ -485,6 +485,12 @@
485 sirf,function = "usp0"; 485 sirf,function = "usp0";
486 }; 486 };
487 }; 487 };
488 usp0_uart_nostreamctrl_pins_a: usp0@1 {
489 usp0 {
490 sirf,pins = "usp0_uart_nostreamctrl_grp";
491 sirf,function = "usp0_uart_nostreamctrl";
492 };
493 };
488 usp1_pins_a: usp1@0 { 494 usp1_pins_a: usp1@0 {
489 usp1 { 495 usp1 {
490 sirf,pins = "usp1grp"; 496 sirf,pins = "usp1grp";
@@ -515,16 +521,16 @@
515 sirf,function = "pulse_count"; 521 sirf,function = "pulse_count";
516 }; 522 };
517 }; 523 };
518 cko0_rst_pins_a: cko0_rst@0 { 524 cko0_pins_a: cko0@0 {
519 cko0_rst { 525 cko0 {
520 sirf,pins = "cko0_rstgrp"; 526 sirf,pins = "cko0grp";
521 sirf,function = "cko0_rst"; 527 sirf,function = "cko0";
522 }; 528 };
523 }; 529 };
524 cko1_rst_pins_a: cko1_rst@0 { 530 cko1_pins_a: cko1@0 {
525 cko1_rst { 531 cko1 {
526 sirf,pins = "cko1_rstgrp"; 532 sirf,pins = "cko1grp";
527 sirf,function = "cko1_rst"; 533 sirf,function = "cko1";
528 }; 534 };
529 }; 535 };
530 }; 536 };
diff --git a/arch/arm/boot/dts/imx28-apx4devkit.dts b/arch/arm/boot/dts/imx28-apx4devkit.dts
index 43bf3c796cba..0e7fed47bd8d 100644
--- a/arch/arm/boot/dts/imx28-apx4devkit.dts
+++ b/arch/arm/boot/dts/imx28-apx4devkit.dts
@@ -147,7 +147,7 @@
147 reg = <0x0a>; 147 reg = <0x0a>;
148 VDDA-supply = <&reg_3p3v>; 148 VDDA-supply = <&reg_3p3v>;
149 VDDIO-supply = <&reg_3p3v>; 149 VDDIO-supply = <&reg_3p3v>;
150 150 clocks = <&saif0>;
151 }; 151 };
152 152
153 pcf8563: rtc@51 { 153 pcf8563: rtc@51 {
diff --git a/arch/arm/boot/dts/imx28-evk.dts b/arch/arm/boot/dts/imx28-evk.dts
index 1f0d38d7b16f..e035f4664b97 100644
--- a/arch/arm/boot/dts/imx28-evk.dts
+++ b/arch/arm/boot/dts/imx28-evk.dts
@@ -195,7 +195,7 @@
195 reg = <0x0a>; 195 reg = <0x0a>;
196 VDDA-supply = <&reg_3p3v>; 196 VDDA-supply = <&reg_3p3v>;
197 VDDIO-supply = <&reg_3p3v>; 197 VDDIO-supply = <&reg_3p3v>;
198 198 clocks = <&saif0>;
199 }; 199 };
200 200
201 at24@51 { 201 at24@51 {
diff --git a/arch/arm/boot/dts/imx28-m28evk.dts b/arch/arm/boot/dts/imx28-m28evk.dts
index 880df2f13be8..44d9da57736e 100644
--- a/arch/arm/boot/dts/imx28-m28evk.dts
+++ b/arch/arm/boot/dts/imx28-m28evk.dts
@@ -184,7 +184,7 @@
184 reg = <0x0a>; 184 reg = <0x0a>;
185 VDDA-supply = <&reg_3p3v>; 185 VDDA-supply = <&reg_3p3v>;
186 VDDIO-supply = <&reg_3p3v>; 186 VDDIO-supply = <&reg_3p3v>;
187 187 clocks = <&saif0>;
188 }; 188 };
189 189
190 eeprom: eeprom@51 { 190 eeprom: eeprom@51 {
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 6a8acb01b1d3..9524a0571281 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -837,6 +837,7 @@
837 compatible = "fsl,imx28-saif"; 837 compatible = "fsl,imx28-saif";
838 reg = <0x80042000 0x2000>; 838 reg = <0x80042000 0x2000>;
839 interrupts = <59 80>; 839 interrupts = <59 80>;
840 #clock-cells = <0>;
840 clocks = <&clks 53>; 841 clocks = <&clks 53>;
841 dmas = <&dma_apbx 4>; 842 dmas = <&dma_apbx 4>;
842 dma-names = "rx-tx"; 843 dma-names = "rx-tx";
diff --git a/arch/arm/boot/dts/imx51-babbage.dts b/arch/arm/boot/dts/imx51-babbage.dts
index 6dd9486c755b..ad3471ca17c7 100644
--- a/arch/arm/boot/dts/imx51-babbage.dts
+++ b/arch/arm/boot/dts/imx51-babbage.dts
@@ -61,6 +61,16 @@
61 mux-int-port = <2>; 61 mux-int-port = <2>;
62 mux-ext-port = <3>; 62 mux-ext-port = <3>;
63 }; 63 };
64
65 clocks {
66 clk_26M: codec_clock {
67 compatible = "fixed-clock";
68 reg=<0>;
69 #clock-cells = <0>;
70 clock-frequency = <26000000>;
71 gpios = <&gpio4 26 1>;
72 };
73 };
64}; 74};
65 75
66&esdhc1 { 76&esdhc1 {
@@ -229,6 +239,7 @@
229 MX51_PAD_EIM_A27__GPIO2_21 0x5 239 MX51_PAD_EIM_A27__GPIO2_21 0x5
230 MX51_PAD_CSPI1_SS0__GPIO4_24 0x85 240 MX51_PAD_CSPI1_SS0__GPIO4_24 0x85
231 MX51_PAD_CSPI1_SS1__GPIO4_25 0x85 241 MX51_PAD_CSPI1_SS1__GPIO4_25 0x85
242 MX51_PAD_CSPI1_RDY__GPIO4_26 0x80000000
232 >; 243 >;
233 }; 244 };
234 }; 245 };
@@ -255,7 +266,7 @@
255 sgtl5000: codec@0a { 266 sgtl5000: codec@0a {
256 compatible = "fsl,sgtl5000"; 267 compatible = "fsl,sgtl5000";
257 reg = <0x0a>; 268 reg = <0x0a>;
258 clock-frequency = <26000000>; 269 clocks = <&clk_26M>;
259 VDDA-supply = <&vdig_reg>; 270 VDDA-supply = <&vdig_reg>;
260 VDDIO-supply = <&vvideo_reg>; 271 VDDIO-supply = <&vvideo_reg>;
261 }; 272 };
diff --git a/arch/arm/boot/dts/imx53-mba53.dts b/arch/arm/boot/dts/imx53-mba53.dts
index aaa33bc99f78..a63090267941 100644
--- a/arch/arm/boot/dts/imx53-mba53.dts
+++ b/arch/arm/boot/dts/imx53-mba53.dts
@@ -27,7 +27,7 @@
27 27
28 backlight { 28 backlight {
29 compatible = "pwm-backlight"; 29 compatible = "pwm-backlight";
30 pwms = <&pwm2 0 50000 0 0>; 30 pwms = <&pwm2 0 50000>;
31 brightness-levels = <0 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100>; 31 brightness-levels = <0 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100>;
32 default-brightness-level = <10>; 32 default-brightness-level = <10>;
33 enable-gpios = <&gpio7 7 0>; 33 enable-gpios = <&gpio7 7 0>;
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 3895fbba8fce..569aa9f2c4ed 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -725,15 +725,15 @@
725 uart1 { 725 uart1 {
726 pinctrl_uart1_1: uart1grp-1 { 726 pinctrl_uart1_1: uart1grp-1 {
727 fsl,pins = < 727 fsl,pins = <
728 MX53_PAD_CSI0_DAT10__UART1_TXD_MUX 0x1c5 728 MX53_PAD_CSI0_DAT10__UART1_TXD_MUX 0x1e4
729 MX53_PAD_CSI0_DAT11__UART1_RXD_MUX 0x1c5 729 MX53_PAD_CSI0_DAT11__UART1_RXD_MUX 0x1e4
730 >; 730 >;
731 }; 731 };
732 732
733 pinctrl_uart1_2: uart1grp-2 { 733 pinctrl_uart1_2: uart1grp-2 {
734 fsl,pins = < 734 fsl,pins = <
735 MX53_PAD_PATA_DIOW__UART1_TXD_MUX 0x1c5 735 MX53_PAD_PATA_DIOW__UART1_TXD_MUX 0x1e4
736 MX53_PAD_PATA_DMACK__UART1_RXD_MUX 0x1c5 736 MX53_PAD_PATA_DMACK__UART1_RXD_MUX 0x1e4
737 >; 737 >;
738 }; 738 };
739 739
@@ -748,8 +748,8 @@
748 uart2 { 748 uart2 {
749 pinctrl_uart2_1: uart2grp-1 { 749 pinctrl_uart2_1: uart2grp-1 {
750 fsl,pins = < 750 fsl,pins = <
751 MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX 0x1c5 751 MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX 0x1e4
752 MX53_PAD_PATA_DMARQ__UART2_TXD_MUX 0x1c5 752 MX53_PAD_PATA_DMARQ__UART2_TXD_MUX 0x1e4
753 >; 753 >;
754 }; 754 };
755 755
@@ -766,17 +766,17 @@
766 uart3 { 766 uart3 {
767 pinctrl_uart3_1: uart3grp-1 { 767 pinctrl_uart3_1: uart3grp-1 {
768 fsl,pins = < 768 fsl,pins = <
769 MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1c5 769 MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1e4
770 MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1c5 770 MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1e4
771 MX53_PAD_PATA_DA_1__UART3_CTS 0x1c5 771 MX53_PAD_PATA_DA_1__UART3_CTS 0x1e4
772 MX53_PAD_PATA_DA_2__UART3_RTS 0x1c5 772 MX53_PAD_PATA_DA_2__UART3_RTS 0x1e4
773 >; 773 >;
774 }; 774 };
775 775
776 pinctrl_uart3_2: uart3grp-2 { 776 pinctrl_uart3_2: uart3grp-2 {
777 fsl,pins = < 777 fsl,pins = <
778 MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1c5 778 MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1e4
779 MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1c5 779 MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1e4
780 >; 780 >;
781 }; 781 };
782 782
@@ -785,8 +785,8 @@
785 uart4 { 785 uart4 {
786 pinctrl_uart4_1: uart4grp-1 { 786 pinctrl_uart4_1: uart4grp-1 {
787 fsl,pins = < 787 fsl,pins = <
788 MX53_PAD_KEY_COL0__UART4_TXD_MUX 0x1c5 788 MX53_PAD_KEY_COL0__UART4_TXD_MUX 0x1e4
789 MX53_PAD_KEY_ROW0__UART4_RXD_MUX 0x1c5 789 MX53_PAD_KEY_ROW0__UART4_RXD_MUX 0x1e4
790 >; 790 >;
791 }; 791 };
792 }; 792 };
@@ -794,8 +794,8 @@
794 uart5 { 794 uart5 {
795 pinctrl_uart5_1: uart5grp-1 { 795 pinctrl_uart5_1: uart5grp-1 {
796 fsl,pins = < 796 fsl,pins = <
797 MX53_PAD_KEY_COL1__UART5_TXD_MUX 0x1c5 797 MX53_PAD_KEY_COL1__UART5_TXD_MUX 0x1e4
798 MX53_PAD_KEY_ROW1__UART5_RXD_MUX 0x1c5 798 MX53_PAD_KEY_ROW1__UART5_RXD_MUX 0x1e4
799 >; 799 >;
800 }; 800 };
801 }; 801 };
diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi
index 05e9489cf95c..bbeb623fc2c6 100644
--- a/arch/arm/boot/dts/prima2.dtsi
+++ b/arch/arm/boot/dts/prima2.dtsi
@@ -515,16 +515,16 @@
515 sirf,function = "pulse_count"; 515 sirf,function = "pulse_count";
516 }; 516 };
517 }; 517 };
518 cko0_rst_pins_a: cko0_rst@0 { 518 cko0_pins_a: cko0@0 {
519 cko0_rst { 519 cko0 {
520 sirf,pins = "cko0_rstgrp"; 520 sirf,pins = "cko0grp";
521 sirf,function = "cko0_rst"; 521 sirf,function = "cko0";
522 }; 522 };
523 }; 523 };
524 cko1_rst_pins_a: cko1_rst@0 { 524 cko1_pins_a: cko1@0 {
525 cko1_rst { 525 cko1 {
526 sirf,pins = "cko1_rstgrp"; 526 sirf,pins = "cko1grp";
527 sirf,function = "cko1_rst"; 527 sirf,function = "cko1";
528 }; 528 };
529 }; 529 };
530 }; 530 };
diff --git a/arch/arm/boot/dts/stih416-pinctrl.dtsi b/arch/arm/boot/dts/stih416-pinctrl.dtsi
index 957b21a71b4b..0f246c979262 100644
--- a/arch/arm/boot/dts/stih416-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stih416-pinctrl.dtsi
@@ -166,6 +166,15 @@
166 reg = <0x9000 0x100>; 166 reg = <0x9000 0x100>;
167 st,bank-name = "PIO31"; 167 st,bank-name = "PIO31";
168 }; 168 };
169
170 serial2-oe {
171 pinctrl_serial2_oe: serial2-1 {
172 st,pins {
173 output-enable = <&PIO11 3 ALT2 OUT>;
174 };
175 };
176 };
177
169 }; 178 };
170 179
171 pin-controller-rear { 180 pin-controller-rear {
@@ -218,7 +227,6 @@
218 st,pins { 227 st,pins {
219 tx = <&PIO17 4 ALT2 OUT>; 228 tx = <&PIO17 4 ALT2 OUT>;
220 rx = <&PIO17 5 ALT2 IN>; 229 rx = <&PIO17 5 ALT2 IN>;
221 output-enable = <&PIO11 3 ALT2 OUT>;
222 }; 230 };
223 }; 231 };
224 }; 232 };
diff --git a/arch/arm/boot/dts/stih416.dtsi b/arch/arm/boot/dts/stih416.dtsi
index 3cecd9689a49..1a0326ea7d07 100644
--- a/arch/arm/boot/dts/stih416.dtsi
+++ b/arch/arm/boot/dts/stih416.dtsi
@@ -79,7 +79,7 @@
79 interrupts = <0 197 0>; 79 interrupts = <0 197 0>;
80 clocks = <&CLK_S_ICN_REG_0>; 80 clocks = <&CLK_S_ICN_REG_0>;
81 pinctrl-names = "default"; 81 pinctrl-names = "default";
82 pinctrl-0 = <&pinctrl_serial2>; 82 pinctrl-0 = <&pinctrl_serial2 &pinctrl_serial2_oe>;
83 }; 83 };
84 84
85 /* SBC_UART1 */ 85 /* SBC_UART1 */
diff --git a/arch/arm/boot/dts/twl4030.dtsi b/arch/arm/boot/dts/twl4030.dtsi
index b3034da00a37..ae6a17aed9ee 100644
--- a/arch/arm/boot/dts/twl4030.dtsi
+++ b/arch/arm/boot/dts/twl4030.dtsi
@@ -47,6 +47,12 @@
47 regulator-max-microvolt = <3150000>; 47 regulator-max-microvolt = <3150000>;
48 }; 48 };
49 49
50 vmmc2: regulator-vmmc2 {
51 compatible = "ti,twl4030-vmmc2";
52 regulator-min-microvolt = <1850000>;
53 regulator-max-microvolt = <3150000>;
54 };
55
50 vusb1v5: regulator-vusb1v5 { 56 vusb1v5: regulator-vusb1v5 {
51 compatible = "ti,twl4030-vusb1v5"; 57 compatible = "ti,twl4030-vusb1v5";
52 }; 58 };
diff --git a/arch/arm/boot/dts/vf610.dtsi b/arch/arm/boot/dts/vf610.dtsi
index e1eb7dadda80..67d929cf9804 100644
--- a/arch/arm/boot/dts/vf610.dtsi
+++ b/arch/arm/boot/dts/vf610.dtsi
@@ -442,8 +442,8 @@
442 compatible = "fsl,mvf600-fec"; 442 compatible = "fsl,mvf600-fec";
443 reg = <0x400d0000 0x1000>; 443 reg = <0x400d0000 0x1000>;
444 interrupts = <0 78 0x04>; 444 interrupts = <0 78 0x04>;
445 clocks = <&clks VF610_CLK_ENET>, 445 clocks = <&clks VF610_CLK_ENET0>,
446 <&clks VF610_CLK_ENET>, 446 <&clks VF610_CLK_ENET0>,
447 <&clks VF610_CLK_ENET>; 447 <&clks VF610_CLK_ENET>;
448 clock-names = "ipg", "ahb", "ptp"; 448 clock-names = "ipg", "ahb", "ptp";
449 status = "disabled"; 449 status = "disabled";
@@ -453,8 +453,8 @@
453 compatible = "fsl,mvf600-fec"; 453 compatible = "fsl,mvf600-fec";
454 reg = <0x400d1000 0x1000>; 454 reg = <0x400d1000 0x1000>;
455 interrupts = <0 79 0x04>; 455 interrupts = <0 79 0x04>;
456 clocks = <&clks VF610_CLK_ENET>, 456 clocks = <&clks VF610_CLK_ENET1>,
457 <&clks VF610_CLK_ENET>, 457 <&clks VF610_CLK_ENET1>,
458 <&clks VF610_CLK_ENET>; 458 <&clks VF610_CLK_ENET>;
459 clock-names = "ipg", "ahb", "ptp"; 459 clock-names = "ipg", "ahb", "ptp";
460 status = "disabled"; 460 status = "disabled";
diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
index a432e6c1dac1..39ad030ac0c7 100644
--- a/arch/arm/common/edma.c
+++ b/arch/arm/common/edma.c
@@ -26,7 +26,6 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/edma.h> 28#include <linux/edma.h>
29#include <linux/err.h>
30#include <linux/of_address.h> 29#include <linux/of_address.h>
31#include <linux/of_device.h> 30#include <linux/of_device.h>
32#include <linux/of_dma.h> 31#include <linux/of_dma.h>
diff --git a/arch/arm/common/mcpm_platsmp.c b/arch/arm/common/mcpm_platsmp.c
index 510e5b13aa2e..1bc34c7567fd 100644
--- a/arch/arm/common/mcpm_platsmp.c
+++ b/arch/arm/common/mcpm_platsmp.c
@@ -19,7 +19,7 @@
19#include <asm/smp.h> 19#include <asm/smp.h>
20#include <asm/smp_plat.h> 20#include <asm/smp_plat.h>
21 21
22static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle) 22static int mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
23{ 23{
24 unsigned int mpidr, pcpu, pcluster, ret; 24 unsigned int mpidr, pcpu, pcluster, ret;
25 extern void secondary_startup(void); 25 extern void secondary_startup(void);
@@ -40,7 +40,7 @@ static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *i
40 return 0; 40 return 0;
41} 41}
42 42
43static void __cpuinit mcpm_secondary_init(unsigned int cpu) 43static void mcpm_secondary_init(unsigned int cpu)
44{ 44{
45 mcpm_cpu_powered_up(); 45 mcpm_cpu_powered_up();
46} 46}
diff --git a/arch/arm/configs/da8xx_omapl_defconfig b/arch/arm/configs/da8xx_omapl_defconfig
index 7c868139bdb0..1571bea48bed 100644
--- a/arch/arm/configs/da8xx_omapl_defconfig
+++ b/arch/arm/configs/da8xx_omapl_defconfig
@@ -102,6 +102,8 @@ CONFIG_SND_SOC=m
102CONFIG_SND_DAVINCI_SOC=m 102CONFIG_SND_DAVINCI_SOC=m
103# CONFIG_HID_SUPPORT is not set 103# CONFIG_HID_SUPPORT is not set
104# CONFIG_USB_SUPPORT is not set 104# CONFIG_USB_SUPPORT is not set
105CONFIG_DMADEVICES=y
106CONFIG_TI_EDMA=y
105CONFIG_EXT2_FS=y 107CONFIG_EXT2_FS=y
106CONFIG_EXT3_FS=y 108CONFIG_EXT3_FS=y
107CONFIG_XFS_FS=m 109CONFIG_XFS_FS=m
diff --git a/arch/arm/configs/davinci_all_defconfig b/arch/arm/configs/davinci_all_defconfig
index c86fd75e181a..ab2f7378352c 100644
--- a/arch/arm/configs/davinci_all_defconfig
+++ b/arch/arm/configs/davinci_all_defconfig
@@ -162,6 +162,8 @@ CONFIG_LEDS_TRIGGERS=y
162CONFIG_LEDS_TRIGGER_TIMER=m 162CONFIG_LEDS_TRIGGER_TIMER=m
163CONFIG_LEDS_TRIGGER_HEARTBEAT=m 163CONFIG_LEDS_TRIGGER_HEARTBEAT=m
164CONFIG_RTC_CLASS=y 164CONFIG_RTC_CLASS=y
165CONFIG_DMADEVICES=y
166CONFIG_TI_EDMA=y
165CONFIG_EXT2_FS=y 167CONFIG_EXT2_FS=y
166CONFIG_EXT3_FS=y 168CONFIG_EXT3_FS=y
167CONFIG_XFS_FS=m 169CONFIG_XFS_FS=m
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index fe0bdc361d2c..6e572c64cf5a 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -53,6 +53,7 @@ CONFIG_IP_PNP=y
53CONFIG_IP_PNP_DHCP=y 53CONFIG_IP_PNP_DHCP=y
54CONFIG_DEVTMPFS=y 54CONFIG_DEVTMPFS=y
55CONFIG_DEVTMPFS_MOUNT=y 55CONFIG_DEVTMPFS_MOUNT=y
56CONFIG_OMAP_OCP2SCP=y
56CONFIG_BLK_DEV_SD=y 57CONFIG_BLK_DEV_SD=y
57CONFIG_ATA=y 58CONFIG_ATA=y
58CONFIG_SATA_AHCI_PLATFORM=y 59CONFIG_SATA_AHCI_PLATFORM=y
@@ -61,6 +62,7 @@ CONFIG_SATA_MV=y
61CONFIG_NETDEVICES=y 62CONFIG_NETDEVICES=y
62CONFIG_SUN4I_EMAC=y 63CONFIG_SUN4I_EMAC=y
63CONFIG_NET_CALXEDA_XGMAC=y 64CONFIG_NET_CALXEDA_XGMAC=y
65CONFIG_KS8851=y
64CONFIG_SMSC911X=y 66CONFIG_SMSC911X=y
65CONFIG_STMMAC_ETH=y 67CONFIG_STMMAC_ETH=y
66CONFIG_MDIO_SUN4I=y 68CONFIG_MDIO_SUN4I=y
@@ -89,6 +91,7 @@ CONFIG_I2C_DESIGNWARE_PLATFORM=y
89CONFIG_I2C_SIRF=y 91CONFIG_I2C_SIRF=y
90CONFIG_I2C_TEGRA=y 92CONFIG_I2C_TEGRA=y
91CONFIG_SPI=y 93CONFIG_SPI=y
94CONFIG_SPI_OMAP24XX=y
92CONFIG_SPI_PL022=y 95CONFIG_SPI_PL022=y
93CONFIG_SPI_SIRF=y 96CONFIG_SPI_SIRF=y
94CONFIG_SPI_TEGRA114=y 97CONFIG_SPI_TEGRA114=y
@@ -111,11 +114,12 @@ CONFIG_FB_SIMPLE=y
111CONFIG_USB=y 114CONFIG_USB=y
112CONFIG_USB_XHCI_HCD=y 115CONFIG_USB_XHCI_HCD=y
113CONFIG_USB_EHCI_HCD=y 116CONFIG_USB_EHCI_HCD=y
114CONFIG_USB_EHCI_MXC=y
115CONFIG_USB_EHCI_TEGRA=y 117CONFIG_USB_EHCI_TEGRA=y
116CONFIG_USB_EHCI_HCD_PLATFORM=y 118CONFIG_USB_EHCI_HCD_PLATFORM=y
117CONFIG_USB_ISP1760_HCD=y 119CONFIG_USB_ISP1760_HCD=y
118CONFIG_USB_STORAGE=y 120CONFIG_USB_STORAGE=y
121CONFIG_USB_CHIPIDEA=y
122CONFIG_USB_CHIPIDEA_HOST=y
119CONFIG_AB8500_USB=y 123CONFIG_AB8500_USB=y
120CONFIG_NOP_USB_XCEIV=y 124CONFIG_NOP_USB_XCEIV=y
121CONFIG_OMAP_USB2=y 125CONFIG_OMAP_USB2=y
diff --git a/arch/arm/configs/nhk8815_defconfig b/arch/arm/configs/nhk8815_defconfig
index 35f8cf299fa2..263ae3869e32 100644
--- a/arch/arm/configs/nhk8815_defconfig
+++ b/arch/arm/configs/nhk8815_defconfig
@@ -1,6 +1,8 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_NO_HZ_IDLE=y
5CONFIG_HIGH_RES_TIMERS=y
4CONFIG_IKCONFIG=y 6CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 7CONFIG_IKCONFIG_PROC=y
6CONFIG_LOG_BUF_SHIFT=14 8CONFIG_LOG_BUF_SHIFT=14
@@ -48,7 +50,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
48CONFIG_MTD=y 50CONFIG_MTD=y
49CONFIG_MTD_TESTS=m 51CONFIG_MTD_TESTS=m
50CONFIG_MTD_CMDLINE_PARTS=y 52CONFIG_MTD_CMDLINE_PARTS=y
51CONFIG_MTD_CHAR=y
52CONFIG_MTD_BLOCK=y 53CONFIG_MTD_BLOCK=y
53CONFIG_MTD_NAND_ECC_SMC=y 54CONFIG_MTD_NAND_ECC_SMC=y
54CONFIG_MTD_NAND=y 55CONFIG_MTD_NAND=y
@@ -94,8 +95,10 @@ CONFIG_I2C_GPIO=y
94CONFIG_I2C_NOMADIK=y 95CONFIG_I2C_NOMADIK=y
95CONFIG_DEBUG_GPIO=y 96CONFIG_DEBUG_GPIO=y
96# CONFIG_HWMON is not set 97# CONFIG_HWMON is not set
98CONFIG_REGULATOR=y
97CONFIG_MMC=y 99CONFIG_MMC=y
98CONFIG_MMC_CLKGATE=y 100CONFIG_MMC_UNSAFE_RESUME=y
101# CONFIG_MMC_BLOCK_BOUNCE is not set
99CONFIG_MMC_ARMMMCI=y 102CONFIG_MMC_ARMMMCI=y
100CONFIG_NEW_LEDS=y 103CONFIG_NEW_LEDS=y
101CONFIG_LEDS_CLASS=y 104CONFIG_LEDS_CLASS=y
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index accefe099182..e406d575c94f 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -89,7 +89,7 @@ static inline u64 arch_counter_get_cntvct(void)
89 return cval; 89 return cval;
90} 90}
91 91
92static inline void __cpuinit arch_counter_set_user_access(void) 92static inline void arch_counter_set_user_access(void)
93{ 93{
94 u32 cntkctl; 94 u32 cntkctl;
95 95
diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S
index 76ab5ca50610..47cd974e57ea 100644
--- a/arch/arm/kernel/head-common.S
+++ b/arch/arm/kernel/head-common.S
@@ -149,7 +149,6 @@ ENDPROC(lookup_processor_type)
149 * r5 = proc_info pointer in physical address space 149 * r5 = proc_info pointer in physical address space
150 * r9 = cpuid (preserved) 150 * r9 = cpuid (preserved)
151 */ 151 */
152 __CPUINIT
153__lookup_processor_type: 152__lookup_processor_type:
154 adr r3, __lookup_processor_type_data 153 adr r3, __lookup_processor_type_data
155 ldmia r3, {r4 - r6} 154 ldmia r3, {r4 - r6}
diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index 75f14cc3e073..b361de143756 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -87,7 +87,6 @@ ENTRY(stext)
87ENDPROC(stext) 87ENDPROC(stext)
88 88
89#ifdef CONFIG_SMP 89#ifdef CONFIG_SMP
90 __CPUINIT
91ENTRY(secondary_startup) 90ENTRY(secondary_startup)
92 /* 91 /*
93 * Common entry point for secondary CPUs. 92 * Common entry point for secondary CPUs.
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 45e8935cae4e..9cf6063020ae 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -343,7 +343,6 @@ __turn_mmu_on_loc:
343 .long __turn_mmu_on_end 343 .long __turn_mmu_on_end
344 344
345#if defined(CONFIG_SMP) 345#if defined(CONFIG_SMP)
346 __CPUINIT
347ENTRY(secondary_startup) 346ENTRY(secondary_startup)
348 /* 347 /*
349 * Common entry point for secondary CPUs. 348 * Common entry point for secondary CPUs.
diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
index 1fd749ee4a1b..7b95de601357 100644
--- a/arch/arm/kernel/hw_breakpoint.c
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -1020,7 +1020,7 @@ out_mdbgen:
1020 cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu)); 1020 cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu));
1021} 1021}
1022 1022
1023static int __cpuinit dbg_reset_notify(struct notifier_block *self, 1023static int dbg_reset_notify(struct notifier_block *self,
1024 unsigned long action, void *cpu) 1024 unsigned long action, void *cpu)
1025{ 1025{
1026 if ((action & ~CPU_TASKS_FROZEN) == CPU_ONLINE) 1026 if ((action & ~CPU_TASKS_FROZEN) == CPU_ONLINE)
@@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
1029 return NOTIFY_OK; 1029 return NOTIFY_OK;
1030} 1030}
1031 1031
1032static struct notifier_block __cpuinitdata dbg_reset_nb = { 1032static struct notifier_block dbg_reset_nb = {
1033 .notifier_call = dbg_reset_notify, 1033 .notifier_call = dbg_reset_notify,
1034}; 1034};
1035 1035
diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
index 1f2740e3dbc0..aebe0e99c153 100644
--- a/arch/arm/kernel/perf_event_cpu.c
+++ b/arch/arm/kernel/perf_event_cpu.c
@@ -157,8 +157,8 @@ static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
157 * UNKNOWN at reset, the PMU must be explicitly reset to avoid reading 157 * UNKNOWN at reset, the PMU must be explicitly reset to avoid reading
158 * junk values out of them. 158 * junk values out of them.
159 */ 159 */
160static int __cpuinit cpu_pmu_notify(struct notifier_block *b, 160static int cpu_pmu_notify(struct notifier_block *b, unsigned long action,
161 unsigned long action, void *hcpu) 161 void *hcpu)
162{ 162{
163 if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING) 163 if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING)
164 return NOTIFY_DONE; 164 return NOTIFY_DONE;
@@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
171 return NOTIFY_OK; 171 return NOTIFY_OK;
172} 172}
173 173
174static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = { 174static struct notifier_block cpu_pmu_hotplug_notifier = {
175 .notifier_call = cpu_pmu_notify, 175 .notifier_call = cpu_pmu_notify,
176}; 176};
177 177
diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c
index 219f1d73572a..70ded3fb42d9 100644
--- a/arch/arm/kernel/psci_smp.c
+++ b/arch/arm/kernel/psci_smp.c
@@ -46,8 +46,7 @@
46 46
47extern void secondary_startup(void); 47extern void secondary_startup(void);
48 48
49static int __cpuinit psci_boot_secondary(unsigned int cpu, 49static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle)
50 struct task_struct *idle)
51{ 50{
52 if (psci_ops.cpu_on) 51 if (psci_ops.cpu_on)
53 return psci_ops.cpu_on(cpu_logical_map(cpu), 52 return psci_ops.cpu_on(cpu_logical_map(cpu),
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index c5fb5469054b..c2b4f8f0be9a 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -58,7 +58,7 @@ struct secondary_data secondary_data;
58 * control for which core is the next to come out of the secondary 58 * control for which core is the next to come out of the secondary
59 * boot "holding pen" 59 * boot "holding pen"
60 */ 60 */
61volatile int __cpuinitdata pen_release = -1; 61volatile int pen_release = -1;
62 62
63enum ipi_msg_type { 63enum ipi_msg_type {
64 IPI_WAKEUP, 64 IPI_WAKEUP,
@@ -86,7 +86,7 @@ static unsigned long get_arch_pgd(pgd_t *pgd)
86 return pgdir >> ARCH_PGD_SHIFT; 86 return pgdir >> ARCH_PGD_SHIFT;
87} 87}
88 88
89int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) 89int __cpu_up(unsigned int cpu, struct task_struct *idle)
90{ 90{
91 int ret; 91 int ret;
92 92
@@ -138,7 +138,7 @@ void __init smp_init_cpus(void)
138 smp_ops.smp_init_cpus(); 138 smp_ops.smp_init_cpus();
139} 139}
140 140
141int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) 141int boot_secondary(unsigned int cpu, struct task_struct *idle)
142{ 142{
143 if (smp_ops.smp_boot_secondary) 143 if (smp_ops.smp_boot_secondary)
144 return smp_ops.smp_boot_secondary(cpu, idle); 144 return smp_ops.smp_boot_secondary(cpu, idle);
@@ -170,7 +170,7 @@ static int platform_cpu_disable(unsigned int cpu)
170/* 170/*
171 * __cpu_disable runs on the processor to be shutdown. 171 * __cpu_disable runs on the processor to be shutdown.
172 */ 172 */
173int __cpuinit __cpu_disable(void) 173int __cpu_disable(void)
174{ 174{
175 unsigned int cpu = smp_processor_id(); 175 unsigned int cpu = smp_processor_id();
176 int ret; 176 int ret;
@@ -216,7 +216,7 @@ static DECLARE_COMPLETION(cpu_died);
216 * called on the thread which is asking for a CPU to be shutdown - 216 * called on the thread which is asking for a CPU to be shutdown -
217 * waits until shutdown has completed, or it is timed out. 217 * waits until shutdown has completed, or it is timed out.
218 */ 218 */
219void __cpuinit __cpu_die(unsigned int cpu) 219void __cpu_die(unsigned int cpu)
220{ 220{
221 if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) { 221 if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) {
222 pr_err("CPU%u: cpu didn't die\n", cpu); 222 pr_err("CPU%u: cpu didn't die\n", cpu);
@@ -306,7 +306,7 @@ void __ref cpu_die(void)
306 * Called by both boot and secondaries to move global data into 306 * Called by both boot and secondaries to move global data into
307 * per-processor storage. 307 * per-processor storage.
308 */ 308 */
309static void __cpuinit smp_store_cpu_info(unsigned int cpuid) 309static void smp_store_cpu_info(unsigned int cpuid)
310{ 310{
311 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid); 311 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
312 312
@@ -322,7 +322,7 @@ static void percpu_timer_setup(void);
322 * This is the secondary CPU boot entry. We're using this CPUs 322 * This is the secondary CPU boot entry. We're using this CPUs
323 * idle thread stack, but a set of temporary page tables. 323 * idle thread stack, but a set of temporary page tables.
324 */ 324 */
325asmlinkage void __cpuinit secondary_start_kernel(void) 325asmlinkage void secondary_start_kernel(void)
326{ 326{
327 struct mm_struct *mm = &init_mm; 327 struct mm_struct *mm = &init_mm;
328 unsigned int cpu; 328 unsigned int cpu;
@@ -521,7 +521,7 @@ static void broadcast_timer_set_mode(enum clock_event_mode mode,
521{ 521{
522} 522}
523 523
524static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt) 524static void broadcast_timer_setup(struct clock_event_device *evt)
525{ 525{
526 evt->name = "dummy_timer"; 526 evt->name = "dummy_timer";
527 evt->features = CLOCK_EVT_FEAT_ONESHOT | 527 evt->features = CLOCK_EVT_FEAT_ONESHOT |
@@ -550,7 +550,7 @@ int local_timer_register(struct local_timer_ops *ops)
550} 550}
551#endif 551#endif
552 552
553static void __cpuinit percpu_timer_setup(void) 553static void percpu_timer_setup(void)
554{ 554{
555 unsigned int cpu = smp_processor_id(); 555 unsigned int cpu = smp_processor_id();
556 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); 556 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index f6fd1d4398c6..25956204ef23 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -187,7 +187,7 @@ core_initcall(twd_cpufreq_init);
187 187
188#endif 188#endif
189 189
190static void __cpuinit twd_calibrate_rate(void) 190static void twd_calibrate_rate(void)
191{ 191{
192 unsigned long count; 192 unsigned long count;
193 u64 waitjiffies; 193 u64 waitjiffies;
@@ -265,7 +265,7 @@ static void twd_get_clock(struct device_node *np)
265/* 265/*
266 * Setup the local clock events for a CPU. 266 * Setup the local clock events for a CPU.
267 */ 267 */
268static int __cpuinit twd_timer_setup(struct clock_event_device *clk) 268static int twd_timer_setup(struct clock_event_device *clk)
269{ 269{
270 struct clock_event_device **this_cpu_clk; 270 struct clock_event_device **this_cpu_clk;
271 int cpu = smp_processor_id(); 271 int cpu = smp_processor_id();
@@ -308,7 +308,7 @@ static int __cpuinit twd_timer_setup(struct clock_event_device *clk)
308 return 0; 308 return 0;
309} 309}
310 310
311static struct local_timer_ops twd_lt_ops __cpuinitdata = { 311static struct local_timer_ops twd_lt_ops = {
312 .setup = twd_timer_setup, 312 .setup = twd_timer_setup,
313 .stop = twd_timer_stop, 313 .stop = twd_timer_stop,
314}; 314};
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
index 64dbfa57204a..5306de350133 100644
--- a/arch/arm/lib/delay.c
+++ b/arch/arm/lib/delay.c
@@ -86,7 +86,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
86 } 86 }
87} 87}
88 88
89unsigned long __cpuinit calibrate_delay_is_known(void) 89unsigned long calibrate_delay_is_known(void)
90{ 90{
91 delay_calibrated = true; 91 delay_calibrated = true;
92 return lpj_fine; 92 return lpj_fine;
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index afbc439f11d4..4cdb61c54459 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -505,7 +505,7 @@ static struct vpbe_output dm365evm_vpbe_outputs[] = {
505/* 505/*
506 * Amplifiers on the board 506 * Amplifiers on the board
507 */ 507 */
508struct ths7303_platform_data ths7303_pdata = { 508static struct ths7303_platform_data ths7303_pdata = {
509 .ch_1 = 3, 509 .ch_1 = 3,
510 .ch_2 = 3, 510 .ch_2 = 3,
511 .ch_3 = 3, 511 .ch_3 = 3,
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 42ef53f62c6c..86100d179694 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -860,7 +860,7 @@ static struct platform_device dm355_vpbe_display = {
860 }, 860 },
861}; 861};
862 862
863struct venc_platform_data dm355_venc_pdata = { 863static struct venc_platform_data dm355_venc_pdata = {
864 .setup_pinmux = dm355_vpbe_setup_pinmux, 864 .setup_pinmux = dm355_vpbe_setup_pinmux,
865 .setup_clock = dm355_venc_setup_clock, 865 .setup_clock = dm355_venc_setup_clock,
866}; 866};
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index fa7af5eda52d..dad28029ba9b 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -1349,7 +1349,7 @@ static struct platform_device dm365_vpbe_display = {
1349 }, 1349 },
1350}; 1350};
1351 1351
1352struct venc_platform_data dm365_venc_pdata = { 1352static struct venc_platform_data dm365_venc_pdata = {
1353 .setup_pinmux = dm365_vpbe_setup_pinmux, 1353 .setup_pinmux = dm365_vpbe_setup_pinmux,
1354 .setup_clock = dm365_venc_setup_clock, 1354 .setup_clock = dm365_venc_setup_clock,
1355}; 1355};
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 855d4a7b462d..5952e68c76c4 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -92,6 +92,7 @@ config SOC_EXYNOS5440
92 bool "SAMSUNG EXYNOS5440" 92 bool "SAMSUNG EXYNOS5440"
93 default y 93 default y
94 depends on ARCH_EXYNOS5 94 depends on ARCH_EXYNOS5
95 select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
95 select ARCH_HAS_OPP 96 select ARCH_HAS_OPP
96 select HAVE_ARM_ARCH_TIMER 97 select HAVE_ARM_ARCH_TIMER
97 select AUTO_ZRELADDR 98 select AUTO_ZRELADDR
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index e970a7a4e278..53696154aead 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -14,7 +14,7 @@ obj- :=
14 14
15obj-$(CONFIG_ARCH_EXYNOS) += common.o 15obj-$(CONFIG_ARCH_EXYNOS) += common.o
16 16
17obj-$(CONFIG_PM) += pm.o 17obj-$(CONFIG_S5P_PM) += pm.o
18obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o 18obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
19obj-$(CONFIG_CPU_IDLE) += cpuidle.o 19obj-$(CONFIG_CPU_IDLE) += cpuidle.o
20 20
diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c
index 164685bd25c8..ba95e5db2501 100644
--- a/arch/arm/mach-exynos/common.c
+++ b/arch/arm/mach-exynos/common.c
@@ -58,7 +58,6 @@ static const char name_exynos5440[] = "EXYNOS5440";
58 58
59static void exynos4_map_io(void); 59static void exynos4_map_io(void);
60static void exynos5_map_io(void); 60static void exynos5_map_io(void);
61static void exynos5440_map_io(void);
62static int exynos_init(void); 61static int exynos_init(void);
63 62
64static struct cpu_table cpu_ids[] __initdata = { 63static struct cpu_table cpu_ids[] __initdata = {
@@ -95,7 +94,6 @@ static struct cpu_table cpu_ids[] __initdata = {
95 }, { 94 }, {
96 .idcode = EXYNOS5440_SOC_ID, 95 .idcode = EXYNOS5440_SOC_ID,
97 .idmask = EXYNOS5_SOC_MASK, 96 .idmask = EXYNOS5_SOC_MASK,
98 .map_io = exynos5440_map_io,
99 .init = exynos_init, 97 .init = exynos_init,
100 .name = name_exynos5440, 98 .name = name_exynos5440,
101 }, 99 },
@@ -150,11 +148,6 @@ static struct map_desc exynos4_iodesc[] __initdata = {
150 .length = SZ_64K, 148 .length = SZ_64K,
151 .type = MT_DEVICE, 149 .type = MT_DEVICE,
152 }, { 150 }, {
153 .virtual = (unsigned long)S3C_VA_UART,
154 .pfn = __phys_to_pfn(EXYNOS4_PA_UART),
155 .length = SZ_512K,
156 .type = MT_DEVICE,
157 }, {
158 .virtual = (unsigned long)S5P_VA_CMU, 151 .virtual = (unsigned long)S5P_VA_CMU,
159 .pfn = __phys_to_pfn(EXYNOS4_PA_CMU), 152 .pfn = __phys_to_pfn(EXYNOS4_PA_CMU),
160 .length = SZ_128K, 153 .length = SZ_128K,
@@ -268,20 +261,6 @@ static struct map_desc exynos5_iodesc[] __initdata = {
268 .pfn = __phys_to_pfn(EXYNOS5_PA_PMU), 261 .pfn = __phys_to_pfn(EXYNOS5_PA_PMU),
269 .length = SZ_64K, 262 .length = SZ_64K,
270 .type = MT_DEVICE, 263 .type = MT_DEVICE,
271 }, {
272 .virtual = (unsigned long)S3C_VA_UART,
273 .pfn = __phys_to_pfn(EXYNOS5_PA_UART),
274 .length = SZ_512K,
275 .type = MT_DEVICE,
276 },
277};
278
279static struct map_desc exynos5440_iodesc0[] __initdata = {
280 {
281 .virtual = (unsigned long)S3C_VA_UART,
282 .pfn = __phys_to_pfn(EXYNOS5440_PA_UART0),
283 .length = SZ_512K,
284 .type = MT_DEVICE,
285 }, 264 },
286}; 265};
287 266
@@ -388,11 +367,6 @@ static void __init exynos5_map_io(void)
388 iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc)); 367 iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc));
389} 368}
390 369
391static void __init exynos5440_map_io(void)
392{
393 iotable_init(exynos5440_iodesc0, ARRAY_SIZE(exynos5440_iodesc0));
394}
395
396void __init exynos_init_time(void) 370void __init exynos_init_time(void)
397{ 371{
398 of_clk_init(NULL); 372 of_clk_init(NULL);
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 3e156bcddcb4..972490fc09d6 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -97,6 +97,5 @@ struct exynos_pmu_conf {
97}; 97};
98 98
99extern void exynos_sys_powerdown_conf(enum sys_powerdown mode); 99extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
100extern void s3c_cpu_resume(void);
101 100
102#endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ 101#endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c
index 17a18ff3d71e..225ee8431c72 100644
--- a/arch/arm/mach-exynos/cpuidle.c
+++ b/arch/arm/mach-exynos/cpuidle.c
@@ -25,6 +25,7 @@
25#include <mach/regs-pmu.h> 25#include <mach/regs-pmu.h>
26 26
27#include <plat/cpu.h> 27#include <plat/cpu.h>
28#include <plat/pm.h>
28 29
29#include "common.h" 30#include "common.h"
30 31
diff --git a/arch/arm/mach-exynos/headsmp.S b/arch/arm/mach-exynos/headsmp.S
index 5364d4bfa8bc..cdd9d91e9933 100644
--- a/arch/arm/mach-exynos/headsmp.S
+++ b/arch/arm/mach-exynos/headsmp.S
@@ -13,8 +13,6 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <linux/init.h> 14#include <linux/init.h>
15 15
16 __CPUINIT
17
18/* 16/*
19 * exynos4 specific entry point for secondary CPUs. This provides 17 * exynos4 specific entry point for secondary CPUs. This provides
20 * a "holding pen" into which all secondary cores are held until we're 18 * a "holding pen" into which all secondary cores are held until we're
diff --git a/arch/arm/mach-exynos/include/mach/memory.h b/arch/arm/mach-exynos/include/mach/memory.h
index 374ef2cf7152..2a4cdb7cb326 100644
--- a/arch/arm/mach-exynos/include/mach/memory.h
+++ b/arch/arm/mach-exynos/include/mach/memory.h
@@ -15,8 +15,13 @@
15 15
16#define PLAT_PHYS_OFFSET UL(0x40000000) 16#define PLAT_PHYS_OFFSET UL(0x40000000)
17 17
18#ifndef CONFIG_ARM_LPAE
18/* Maximum of 256MiB in one bank */ 19/* Maximum of 256MiB in one bank */
19#define MAX_PHYSMEM_BITS 32 20#define MAX_PHYSMEM_BITS 32
20#define SECTION_SIZE_BITS 28 21#define SECTION_SIZE_BITS 28
22#else
23#define MAX_PHYSMEM_BITS 36
24#define SECTION_SIZE_BITS 31
25#endif
21 26
22#endif /* __ASM_ARCH_MEMORY_H */ 27#endif /* __ASM_ARCH_MEMORY_H */
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index deba1308ff16..58b43e6f9262 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -75,7 +75,7 @@ static void __iomem *scu_base_addr(void)
75 75
76static DEFINE_SPINLOCK(boot_lock); 76static DEFINE_SPINLOCK(boot_lock);
77 77
78static void __cpuinit exynos_secondary_init(unsigned int cpu) 78static void exynos_secondary_init(unsigned int cpu)
79{ 79{
80 /* 80 /*
81 * let the primary processor know we're out of the 81 * let the primary processor know we're out of the
@@ -90,7 +90,7 @@ static void __cpuinit exynos_secondary_init(unsigned int cpu)
90 spin_unlock(&boot_lock); 90 spin_unlock(&boot_lock);
91} 91}
92 92
93static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) 93static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
94{ 94{
95 unsigned long timeout; 95 unsigned long timeout;
96 unsigned long phys_cpu = cpu_logical_map(cpu); 96 unsigned long phys_cpu = cpu_logical_map(cpu);
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index 41c20692a13f..c679db577269 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -217,6 +217,9 @@ static __init int exynos_pm_drvinit(void)
217 struct clk *pll_base; 217 struct clk *pll_base;
218 unsigned int tmp; 218 unsigned int tmp;
219 219
220 if (soc_is_exynos5440())
221 return 0;
222
220 s3c_pm_init(); 223 s3c_pm_init();
221 224
222 /* All wakeup disable */ 225 /* All wakeup disable */
@@ -340,6 +343,9 @@ static struct syscore_ops exynos_pm_syscore_ops = {
340 343
341static __init int exynos_pm_syscore_init(void) 344static __init int exynos_pm_syscore_init(void)
342{ 345{
346 if (soc_is_exynos5440())
347 return 0;
348
343 register_syscore_ops(&exynos_pm_syscore_ops); 349 register_syscore_ops(&exynos_pm_syscore_ops);
344 return 0; 350 return 0;
345} 351}
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index a7cd2cf5e08d..3490a24f969e 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -276,8 +276,6 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
276 276
277 sys->mem_offset = DC21285_PCI_MEM; 277 sys->mem_offset = DC21285_PCI_MEM;
278 278
279 pci_ioremap_io(0, DC21285_PCI_IO);
280
281 pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset); 279 pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset);
282 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 280 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
283 281
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index dc5d6becd8c7..88815795fe26 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -115,6 +115,7 @@ static int highbank_platform_notifier(struct notifier_block *nb,
115{ 115{
116 struct resource *res; 116 struct resource *res;
117 int reg = -1; 117 int reg = -1;
118 u32 val;
118 struct device *dev = __dev; 119 struct device *dev = __dev;
119 120
120 if (event != BUS_NOTIFY_ADD_DEVICE) 121 if (event != BUS_NOTIFY_ADD_DEVICE)
@@ -141,10 +142,10 @@ static int highbank_platform_notifier(struct notifier_block *nb,
141 return NOTIFY_DONE; 142 return NOTIFY_DONE;
142 143
143 if (of_property_read_bool(dev->of_node, "dma-coherent")) { 144 if (of_property_read_bool(dev->of_node, "dma-coherent")) {
144 writel(0xff31, sregs_base + reg); 145 val = readl(sregs_base + reg);
146 writel(val | 0xff01, sregs_base + reg);
145 set_dma_ops(dev, &arm_coherent_dma_ops); 147 set_dma_ops(dev, &arm_coherent_dma_ops);
146 } else 148 }
147 writel(0, sregs_base + reg);
148 149
149 return NOTIFY_OK; 150 return NOTIFY_OK;
150} 151}
diff --git a/arch/arm/mach-highbank/platsmp.c b/arch/arm/mach-highbank/platsmp.c
index a984573e0d02..32d75cf55cbc 100644
--- a/arch/arm/mach-highbank/platsmp.c
+++ b/arch/arm/mach-highbank/platsmp.c
@@ -24,7 +24,7 @@
24 24
25extern void secondary_startup(void); 25extern void secondary_startup(void);
26 26
27static int __cpuinit highbank_boot_secondary(unsigned int cpu, struct task_struct *idle) 27static int highbank_boot_secondary(unsigned int cpu, struct task_struct *idle)
28{ 28{
29 highbank_set_cpu_jump(cpu, secondary_startup); 29 highbank_set_cpu_jump(cpu, secondary_startup);
30 arch_send_wakeup_ipi_mask(cpumask_of(cpu)); 30 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 4282e99f5ca1..86567d980b07 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -199,7 +199,8 @@ static const char *pcie_axi_sels[] = { "axi", "ahb", };
199static const char *ssi_sels[] = { "pll3_pfd2_508m", "pll3_pfd3_454m", "pll4_post_div", }; 199static const char *ssi_sels[] = { "pll3_pfd2_508m", "pll3_pfd3_454m", "pll4_post_div", };
200static const char *usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", }; 200static const char *usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
201static const char *enfc_sels[] = { "pll2_pfd0_352m", "pll2_bus", "pll3_usb_otg", "pll2_pfd2_396m", }; 201static const char *enfc_sels[] = { "pll2_pfd0_352m", "pll2_bus", "pll3_usb_otg", "pll2_pfd2_396m", };
202static const char *emi_sels[] = { "axi", "pll3_usb_otg", "pll2_pfd2_396m", "pll2_pfd0_352m", }; 202static const char *emi_sels[] = { "pll2_pfd2_396m", "pll3_usb_otg", "axi", "pll2_pfd0_352m", };
203static const char *emi_slow_sels[] = { "axi", "pll3_usb_otg", "pll2_pfd2_396m", "pll2_pfd0_352m", };
203static const char *vdo_axi_sels[] = { "axi", "ahb", }; 204static const char *vdo_axi_sels[] = { "axi", "ahb", };
204static const char *vpu_axi_sels[] = { "axi", "pll2_pfd2_396m", "pll2_pfd0_352m", }; 205static const char *vpu_axi_sels[] = { "axi", "pll2_pfd2_396m", "pll2_pfd0_352m", };
205static const char *cko1_sels[] = { "pll3_usb_otg", "pll2_bus", "pll1_sys", "pll5_video_div", 206static 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)
392 clk[usdhc4_sel] = imx_clk_mux("usdhc4_sel", base + 0x1c, 19, 1, usdhc_sels, ARRAY_SIZE(usdhc_sels)); 393 clk[usdhc4_sel] = imx_clk_mux("usdhc4_sel", base + 0x1c, 19, 1, usdhc_sels, ARRAY_SIZE(usdhc_sels));
393 clk[enfc_sel] = imx_clk_mux("enfc_sel", base + 0x2c, 16, 2, enfc_sels, ARRAY_SIZE(enfc_sels)); 394 clk[enfc_sel] = imx_clk_mux("enfc_sel", base + 0x2c, 16, 2, enfc_sels, ARRAY_SIZE(enfc_sels));
394 clk[emi_sel] = imx_clk_mux("emi_sel", base + 0x1c, 27, 2, emi_sels, ARRAY_SIZE(emi_sels)); 395 clk[emi_sel] = imx_clk_mux("emi_sel", base + 0x1c, 27, 2, emi_sels, ARRAY_SIZE(emi_sels));
395 clk[emi_slow_sel] = imx_clk_mux("emi_slow_sel", base + 0x1c, 29, 2, emi_sels, ARRAY_SIZE(emi_sels)); 396 clk[emi_slow_sel] = imx_clk_mux("emi_slow_sel", base + 0x1c, 29, 2, emi_slow_sels, ARRAY_SIZE(emi_slow_sels));
396 clk[vdo_axi_sel] = imx_clk_mux("vdo_axi_sel", base + 0x18, 11, 1, vdo_axi_sels, ARRAY_SIZE(vdo_axi_sels)); 397 clk[vdo_axi_sel] = imx_clk_mux("vdo_axi_sel", base + 0x18, 11, 1, vdo_axi_sels, ARRAY_SIZE(vdo_axi_sels));
397 clk[vpu_axi_sel] = imx_clk_mux("vpu_axi_sel", base + 0x18, 14, 2, vpu_axi_sels, ARRAY_SIZE(vpu_axi_sels)); 398 clk[vpu_axi_sel] = imx_clk_mux("vpu_axi_sel", base + 0x18, 14, 2, vpu_axi_sels, ARRAY_SIZE(vpu_axi_sels));
398 clk[cko1_sel] = imx_clk_mux("cko1_sel", base + 0x60, 0, 4, cko1_sels, ARRAY_SIZE(cko1_sels)); 399 clk[cko1_sel] = imx_clk_mux("cko1_sel", base + 0x60, 0, 4, cko1_sels, ARRAY_SIZE(cko1_sels));
diff --git a/arch/arm/mach-imx/clk-vf610.c b/arch/arm/mach-imx/clk-vf610.c
index d617c0b7c809..b169a396d93b 100644
--- a/arch/arm/mach-imx/clk-vf610.c
+++ b/arch/arm/mach-imx/clk-vf610.c
@@ -183,6 +183,8 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
183 clk[VF610_CLK_ENET_TS_SEL] = imx_clk_mux("enet_ts_sel", CCM_CSCMR2, 0, 3, enet_ts_sels, 7); 183 clk[VF610_CLK_ENET_TS_SEL] = imx_clk_mux("enet_ts_sel", CCM_CSCMR2, 0, 3, enet_ts_sels, 7);
184 clk[VF610_CLK_ENET] = imx_clk_gate("enet", "enet_sel", CCM_CSCDR1, 24); 184 clk[VF610_CLK_ENET] = imx_clk_gate("enet", "enet_sel", CCM_CSCDR1, 24);
185 clk[VF610_CLK_ENET_TS] = imx_clk_gate("enet_ts", "enet_ts_sel", CCM_CSCDR1, 23); 185 clk[VF610_CLK_ENET_TS] = imx_clk_gate("enet_ts", "enet_ts_sel", CCM_CSCDR1, 23);
186 clk[VF610_CLK_ENET0] = imx_clk_gate2("enet0", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(0));
187 clk[VF610_CLK_ENET1] = imx_clk_gate2("enet1", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(1));
186 188
187 clk[VF610_CLK_PIT] = imx_clk_gate2("pit", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(7)); 189 clk[VF610_CLK_PIT] = imx_clk_gate2("pit", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(7));
188 190
diff --git a/arch/arm/mach-imx/mx27.h b/arch/arm/mach-imx/mx27.h
index e074616d54ca..8a65f192e7f3 100644
--- a/arch/arm/mach-imx/mx27.h
+++ b/arch/arm/mach-imx/mx27.h
@@ -135,7 +135,7 @@
135#define MX27_INT_GPT4 (NR_IRQS_LEGACY + 4) 135#define MX27_INT_GPT4 (NR_IRQS_LEGACY + 4)
136#define MX27_INT_RTIC (NR_IRQS_LEGACY + 5) 136#define MX27_INT_RTIC (NR_IRQS_LEGACY + 5)
137#define MX27_INT_CSPI3 (NR_IRQS_LEGACY + 6) 137#define MX27_INT_CSPI3 (NR_IRQS_LEGACY + 6)
138#define MX27_INT_SDHC (NR_IRQS_LEGACY + 7) 138#define MX27_INT_MSHC (NR_IRQS_LEGACY + 7)
139#define MX27_INT_GPIO (NR_IRQS_LEGACY + 8) 139#define MX27_INT_GPIO (NR_IRQS_LEGACY + 8)
140#define MX27_INT_SDHC3 (NR_IRQS_LEGACY + 9) 140#define MX27_INT_SDHC3 (NR_IRQS_LEGACY + 9)
141#define MX27_INT_SDHC2 (NR_IRQS_LEGACY + 10) 141#define MX27_INT_SDHC2 (NR_IRQS_LEGACY + 10)
diff --git a/arch/arm/mach-imx/platsmp.c b/arch/arm/mach-imx/platsmp.c
index c6e1ab544882..1f24c1fdfea4 100644
--- a/arch/arm/mach-imx/platsmp.c
+++ b/arch/arm/mach-imx/platsmp.c
@@ -53,7 +53,7 @@ void imx_scu_standby_enable(void)
53 writel_relaxed(val, scu_base); 53 writel_relaxed(val, scu_base);
54} 54}
55 55
56static int __cpuinit imx_boot_secondary(unsigned int cpu, struct task_struct *idle) 56static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
57{ 57{
58 imx_set_cpu_jump(cpu, v7_secondary_startup); 58 imx_set_cpu_jump(cpu, v7_secondary_startup);
59 imx_enable_cpu(cpu, true); 59 imx_enable_cpu(cpu, true);
diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
index fe4d9ff93a7e..b661c5c2870a 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -49,7 +49,7 @@ static const char *keystone_match[] __initconst = {
49 NULL, 49 NULL,
50}; 50};
51 51
52void keystone_restart(char mode, const char *cmd) 52void keystone_restart(enum reboot_mode mode, const char *cmd)
53{ 53{
54 u32 val; 54 u32 val;
55 55
diff --git a/arch/arm/mach-keystone/platsmp.c b/arch/arm/mach-keystone/platsmp.c
index 1d4181e1daf2..14378e3fef16 100644
--- a/arch/arm/mach-keystone/platsmp.c
+++ b/arch/arm/mach-keystone/platsmp.c
@@ -21,7 +21,7 @@
21 21
22#include "keystone.h" 22#include "keystone.h"
23 23
24static int __cpuinit keystone_smp_boot_secondary(unsigned int cpu, 24static int keystone_smp_boot_secondary(unsigned int cpu,
25 struct task_struct *idle) 25 struct task_struct *idle)
26{ 26{
27 unsigned long start = virt_to_phys(&secondary_startup); 27 unsigned long start = virt_to_phys(&secondary_startup);
diff --git a/arch/arm/mach-msm/headsmp.S b/arch/arm/mach-msm/headsmp.S
index bcd5af223dea..6c62c3f82fe6 100644
--- a/arch/arm/mach-msm/headsmp.S
+++ b/arch/arm/mach-msm/headsmp.S
@@ -11,8 +11,6 @@
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12#include <linux/init.h> 12#include <linux/init.h>
13 13
14 __CPUINIT
15
16/* 14/*
17 * MSM specific entry point for secondary CPUs. This provides 15 * MSM specific entry point for secondary CPUs. This provides
18 * a "holding pen" into which all secondary cores are held until we're 16 * a "holding pen" into which all secondary cores are held until we're
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c
index 00cdb0a5dac8..3f06edcdd0ce 100644
--- a/arch/arm/mach-msm/platsmp.c
+++ b/arch/arm/mach-msm/platsmp.c
@@ -38,7 +38,7 @@ static inline int get_core_count(void)
38 return ((read_cpuid_id() >> 4) & 3) + 1; 38 return ((read_cpuid_id() >> 4) & 3) + 1;
39} 39}
40 40
41static void __cpuinit msm_secondary_init(unsigned int cpu) 41static void msm_secondary_init(unsigned int cpu)
42{ 42{
43 /* 43 /*
44 * let the primary processor know we're out of the 44 * let the primary processor know we're out of the
@@ -54,7 +54,7 @@ static void __cpuinit msm_secondary_init(unsigned int cpu)
54 spin_unlock(&boot_lock); 54 spin_unlock(&boot_lock);
55} 55}
56 56
57static __cpuinit void prepare_cold_cpu(unsigned int cpu) 57static void prepare_cold_cpu(unsigned int cpu)
58{ 58{
59 int ret; 59 int ret;
60 ret = scm_set_boot_addr(virt_to_phys(msm_secondary_startup), 60 ret = scm_set_boot_addr(virt_to_phys(msm_secondary_startup),
@@ -73,7 +73,7 @@ static __cpuinit void prepare_cold_cpu(unsigned int cpu)
73 "address\n"); 73 "address\n");
74} 74}
75 75
76static int __cpuinit msm_boot_secondary(unsigned int cpu, struct task_struct *idle) 76static int msm_boot_secondary(unsigned int cpu, struct task_struct *idle)
77{ 77{
78 unsigned long timeout; 78 unsigned long timeout;
79 static int cold_boot_done; 79 static int cold_boot_done;
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index b6418fd5fe0d..8697cfc0d0b6 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -139,7 +139,7 @@ static struct clocksource msm_clocksource = {
139}; 139};
140 140
141#ifdef CONFIG_LOCAL_TIMERS 141#ifdef CONFIG_LOCAL_TIMERS
142static int __cpuinit msm_local_timer_setup(struct clock_event_device *evt) 142static int msm_local_timer_setup(struct clock_event_device *evt)
143{ 143{
144 /* Use existing clock_event for cpu 0 */ 144 /* Use existing clock_event for cpu 0 */
145 if (!smp_processor_id()) 145 if (!smp_processor_id())
@@ -164,7 +164,7 @@ static void msm_local_timer_stop(struct clock_event_device *evt)
164 disable_percpu_irq(evt->irq); 164 disable_percpu_irq(evt->irq);
165} 165}
166 166
167static struct local_timer_ops msm_local_timer_ops __cpuinitdata = { 167static struct local_timer_ops msm_local_timer_ops = {
168 .setup = msm_local_timer_setup, 168 .setup = msm_local_timer_setup,
169 .stop = msm_local_timer_stop, 169 .stop = msm_local_timer_stop,
170}; 170};
diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index be117591f7f2..4c24303ec481 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -28,7 +28,7 @@
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include "armada-370-xp.h" 29#include "armada-370-xp.h"
30 30
31unsigned long __cpuinitdata coherency_phys_base; 31unsigned long coherency_phys_base;
32static void __iomem *coherency_base; 32static void __iomem *coherency_base;
33static void __iomem *coherency_cpu_base; 33static void __iomem *coherency_cpu_base;
34 34
diff --git a/arch/arm/mach-mvebu/headsmp.S b/arch/arm/mach-mvebu/headsmp.S
index 7147300c8af2..8a1b0c96e9ec 100644
--- a/arch/arm/mach-mvebu/headsmp.S
+++ b/arch/arm/mach-mvebu/headsmp.S
@@ -21,8 +21,6 @@
21#include <linux/linkage.h> 21#include <linux/linkage.h>
22#include <linux/init.h> 22#include <linux/init.h>
23 23
24 __CPUINIT
25
26/* 24/*
27 * Armada XP specific entry point for secondary CPUs. 25 * Armada XP specific entry point for secondary CPUs.
28 * We add the CPU to the coherency fabric and then jump to secondary 26 * We add the CPU to the coherency fabric and then jump to secondary
diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
index 93f2f3ab45f1..ce81d3031405 100644
--- a/arch/arm/mach-mvebu/platsmp.c
+++ b/arch/arm/mach-mvebu/platsmp.c
@@ -71,13 +71,12 @@ void __init set_secondary_cpus_clock(void)
71 } 71 }
72} 72}
73 73
74static void __cpuinit armada_xp_secondary_init(unsigned int cpu) 74static void armada_xp_secondary_init(unsigned int cpu)
75{ 75{
76 armada_xp_mpic_smp_cpu_init(); 76 armada_xp_mpic_smp_cpu_init();
77} 77}
78 78
79static int __cpuinit armada_xp_boot_secondary(unsigned int cpu, 79static int armada_xp_boot_secondary(unsigned int cpu, struct task_struct *idle)
80 struct task_struct *idle)
81{ 80{
82 pr_info("Booting CPU %d\n", cpu); 81 pr_info("Booting CPU %d\n", cpu);
83 82
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 627fa7e41fba..3eed0006d189 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -62,7 +62,7 @@ config SOC_OMAP5
62 select HAVE_SMP 62 select HAVE_SMP
63 select COMMON_CLK 63 select COMMON_CLK
64 select HAVE_ARM_ARCH_TIMER 64 select HAVE_ARM_ARCH_TIMER
65 select ARM_ERRATA_798181 65 select ARM_ERRATA_798181 if SMP
66 66
67config SOC_AM33XX 67config SOC_AM33XX
68 bool "AM33XX support" 68 bool "AM33XX support"
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index e5fbfed69aa2..be5d005ebad2 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -15,6 +15,7 @@
15#include <linux/of_irq.h> 15#include <linux/of_irq.h>
16#include <linux/of_platform.h> 16#include <linux/of_platform.h>
17#include <linux/irqdomain.h> 17#include <linux/irqdomain.h>
18#include <linux/clk.h>
18 19
19#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
20 21
@@ -35,6 +36,21 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
35 { } 36 { }
36}; 37};
37 38
39/*
40 * Create alias for USB host PHY clock.
41 * Remove this when clock phandle can be provided via DT
42 */
43static void __init legacy_init_ehci_clk(char *clkname)
44{
45 int ret;
46
47 ret = clk_add_alias("main_clk", NULL, clkname, NULL);
48 if (ret) {
49 pr_err("%s:Failed to add main_clk alias to %s :%d\n",
50 __func__, clkname, ret);
51 }
52}
53
38static void __init omap_generic_init(void) 54static void __init omap_generic_init(void)
39{ 55{
40 omap_sdrc_init(NULL, NULL); 56 omap_sdrc_init(NULL, NULL);
@@ -45,10 +61,15 @@ static void __init omap_generic_init(void)
45 * HACK: call display setup code for selected boards to enable omapdss. 61 * HACK: call display setup code for selected boards to enable omapdss.
46 * This will be removed when omapdss supports DT. 62 * This will be removed when omapdss supports DT.
47 */ 63 */
48 if (of_machine_is_compatible("ti,omap4-panda")) 64 if (of_machine_is_compatible("ti,omap4-panda")) {
49 omap4_panda_display_init_of(); 65 omap4_panda_display_init_of();
66 legacy_init_ehci_clk("auxclk3_ck");
67
68 }
50 else if (of_machine_is_compatible("ti,omap4-sdp")) 69 else if (of_machine_is_compatible("ti,omap4-sdp"))
51 omap_4430sdp_display_init_of(); 70 omap_4430sdp_display_init_of();
71 else if (of_machine_is_compatible("ti,omap5-uevm"))
72 legacy_init_ehci_clk("auxclk1_ck");
52} 73}
53 74
54#ifdef CONFIG_SOC_OMAP2420 75#ifdef CONFIG_SOC_OMAP2420
diff --git a/arch/arm/mach-omap2/omap-headsmp.S b/arch/arm/mach-omap2/omap-headsmp.S
index 4ea308114165..75e92952c18e 100644
--- a/arch/arm/mach-omap2/omap-headsmp.S
+++ b/arch/arm/mach-omap2/omap-headsmp.S
@@ -20,8 +20,6 @@
20 20
21#include "omap44xx.h" 21#include "omap44xx.h"
22 22
23 __CPUINIT
24
25/* Physical address needed since MMU not enabled yet on secondary core */ 23/* Physical address needed since MMU not enabled yet on secondary core */
26#define AUX_CORE_BOOT0_PA 0x48281800 24#define AUX_CORE_BOOT0_PA 0x48281800
27 25
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index f993a4188701..f991016e2a6a 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -291,7 +291,7 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
291 * @cpu : CPU ID 291 * @cpu : CPU ID
292 * @power_state: CPU low power state. 292 * @power_state: CPU low power state.
293 */ 293 */
294int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state) 294int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
295{ 295{
296 struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu); 296 struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu);
297 unsigned int cpu_state = 0; 297 unsigned int cpu_state = 0;
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 98a11463a843..8708b2a9da45 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -51,7 +51,7 @@ void __iomem *omap4_get_scu_base(void)
51 return scu_base; 51 return scu_base;
52} 52}
53 53
54static void __cpuinit omap4_secondary_init(unsigned int cpu) 54static void omap4_secondary_init(unsigned int cpu)
55{ 55{
56 /* 56 /*
57 * Configure ACTRL and enable NS SMP bit access on CPU1 on HS device. 57 * 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)
72 spin_unlock(&boot_lock); 72 spin_unlock(&boot_lock);
73} 73}
74 74
75static int __cpuinit omap4_boot_secondary(unsigned int cpu, struct task_struct *idle) 75static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
76{ 76{
77 static struct clockdomain *cpu1_clkdm; 77 static struct clockdomain *cpu1_clkdm;
78 static bool booted; 78 static bool booted;
diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
index f8bb3b9b6a76..813c61558a5f 100644
--- a/arch/arm/mach-omap2/omap-wakeupgen.c
+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
@@ -323,8 +323,8 @@ static void irq_save_secure_context(void)
323#endif 323#endif
324 324
325#ifdef CONFIG_HOTPLUG_CPU 325#ifdef CONFIG_HOTPLUG_CPU
326static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self, 326static int irq_cpu_hotplug_notify(struct notifier_block *self,
327 unsigned long action, void *hcpu) 327 unsigned long action, void *hcpu)
328{ 328{
329 unsigned int cpu = (unsigned int)hcpu; 329 unsigned int cpu = (unsigned int)hcpu;
330 330
diff --git a/arch/arm/mach-prima2/headsmp.S b/arch/arm/mach-prima2/headsmp.S
index 5b8a408d8921..d86fe33c5f53 100644
--- a/arch/arm/mach-prima2/headsmp.S
+++ b/arch/arm/mach-prima2/headsmp.S
@@ -9,8 +9,6 @@
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <linux/init.h> 10#include <linux/init.h>
11 11
12 __CPUINIT
13
14/* 12/*
15 * SIRFSOC specific entry point for secondary CPUs. This provides 13 * SIRFSOC specific entry point for secondary CPUs. This provides
16 * a "holding pen" into which all secondary cores are held until we're 14 * a "holding pen" into which all secondary cores are held until we're
diff --git a/arch/arm/mach-prima2/platsmp.c b/arch/arm/mach-prima2/platsmp.c
index 1c3de7bed841..3dbcb1ab6e37 100644
--- a/arch/arm/mach-prima2/platsmp.c
+++ b/arch/arm/mach-prima2/platsmp.c
@@ -44,7 +44,7 @@ void __init sirfsoc_map_scu(void)
44 scu_base = (void __iomem *)SIRFSOC_VA(base); 44 scu_base = (void __iomem *)SIRFSOC_VA(base);
45} 45}
46 46
47static void __cpuinit sirfsoc_secondary_init(unsigned int cpu) 47static void sirfsoc_secondary_init(unsigned int cpu)
48{ 48{
49 /* 49 /*
50 * let the primary processor know we're out of the 50 * let the primary processor know we're out of the
@@ -65,7 +65,7 @@ static struct of_device_id rsc_ids[] = {
65 {}, 65 {},
66}; 66};
67 67
68static int __cpuinit sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle) 68static int sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle)
69{ 69{
70 unsigned long timeout; 70 unsigned long timeout;
71 struct device_node *np; 71 struct device_node *np;
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index f6726bb4eb95..3a3362fa793e 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -477,16 +477,24 @@ static int em_x270_usb_hub_init(void)
477 /* USB Hub power-on and reset */ 477 /* USB Hub power-on and reset */
478 gpio_direction_output(usb_hub_reset, 1); 478 gpio_direction_output(usb_hub_reset, 1);
479 gpio_direction_output(GPIO9_USB_VBUS_EN, 0); 479 gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
480 regulator_enable(em_x270_usb_ldo); 480 err = regulator_enable(em_x270_usb_ldo);
481 if (err)
482 goto err_free_rst_gpio;
483
481 gpio_set_value(usb_hub_reset, 0); 484 gpio_set_value(usb_hub_reset, 0);
482 gpio_set_value(usb_hub_reset, 1); 485 gpio_set_value(usb_hub_reset, 1);
483 regulator_disable(em_x270_usb_ldo); 486 regulator_disable(em_x270_usb_ldo);
484 regulator_enable(em_x270_usb_ldo); 487 err = regulator_enable(em_x270_usb_ldo);
488 if (err)
489 goto err_free_rst_gpio;
490
485 gpio_set_value(usb_hub_reset, 0); 491 gpio_set_value(usb_hub_reset, 0);
486 gpio_set_value(GPIO9_USB_VBUS_EN, 1); 492 gpio_set_value(GPIO9_USB_VBUS_EN, 1);
487 493
488 return 0; 494 return 0;
489 495
496err_free_rst_gpio:
497 gpio_free(usb_hub_reset);
490err_free_vbus_gpio: 498err_free_vbus_gpio:
491 gpio_free(GPIO9_USB_VBUS_EN); 499 gpio_free(GPIO9_USB_VBUS_EN);
492err_free_usb_ldo: 500err_free_usb_ldo:
@@ -592,7 +600,7 @@ err_irq:
592 return err; 600 return err;
593} 601}
594 602
595static void em_x270_mci_setpower(struct device *dev, unsigned int vdd) 603static int em_x270_mci_setpower(struct device *dev, unsigned int vdd)
596{ 604{
597 struct pxamci_platform_data* p_d = dev->platform_data; 605 struct pxamci_platform_data* p_d = dev->platform_data;
598 606
@@ -600,10 +608,11 @@ static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
600 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000; 608 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
601 609
602 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV); 610 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
603 regulator_enable(em_x270_sdio_ldo); 611 return regulator_enable(em_x270_sdio_ldo);
604 } else { 612 } else {
605 regulator_disable(em_x270_sdio_ldo); 613 regulator_disable(em_x270_sdio_ldo);
606 } 614 }
615 return 0;
607} 616}
608 617
609static void em_x270_mci_exit(struct device *dev, void *data) 618static void em_x270_mci_exit(struct device *dev, void *data)
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index d2c652318376..dd70343c8708 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -408,7 +408,7 @@ static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_in
408 return err; 408 return err;
409} 409}
410 410
411static void mainstone_mci_setpower(struct device *dev, unsigned int vdd) 411static int mainstone_mci_setpower(struct device *dev, unsigned int vdd)
412{ 412{
413 struct pxamci_platform_data* p_d = dev->platform_data; 413 struct pxamci_platform_data* p_d = dev->platform_data;
414 414
@@ -420,6 +420,7 @@ static void mainstone_mci_setpower(struct device *dev, unsigned int vdd)
420 printk(KERN_DEBUG "%s: off\n", __func__); 420 printk(KERN_DEBUG "%s: off\n", __func__);
421 MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON; 421 MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON;
422 } 422 }
423 return 0;
423} 424}
424 425
425static void mainstone_mci_exit(struct device *dev, void *data) 426static void mainstone_mci_exit(struct device *dev, void *data)
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index fb7f1d1627dc..13e5b00eae90 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -335,7 +335,7 @@ static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
335 return err; 335 return err;
336} 336}
337 337
338static void pcm990_mci_setpower(struct device *dev, unsigned int vdd) 338static int pcm990_mci_setpower(struct device *dev, unsigned int vdd)
339{ 339{
340 struct pxamci_platform_data *p_d = dev->platform_data; 340 struct pxamci_platform_data *p_d = dev->platform_data;
341 u8 val; 341 u8 val;
@@ -348,6 +348,7 @@ static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
348 val &= ~PCM990_CTRL_MMC2PWR; 348 val &= ~PCM990_CTRL_MMC2PWR;
349 349
350 pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5); 350 pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5);
351 return 0;
351} 352}
352 353
353static void pcm990_mci_exit(struct device *dev, void *data) 354static void pcm990_mci_exit(struct device *dev, void *data)
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 711d37e26bd8..aedf053a1de5 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -258,7 +258,7 @@ err_free_2:
258 return err; 258 return err;
259} 259}
260 260
261static void poodle_mci_setpower(struct device *dev, unsigned int vdd) 261static int poodle_mci_setpower(struct device *dev, unsigned int vdd)
262{ 262{
263 struct pxamci_platform_data* p_d = dev->platform_data; 263 struct pxamci_platform_data* p_d = dev->platform_data;
264 264
@@ -270,6 +270,8 @@ static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
270 gpio_set_value(POODLE_GPIO_SD_PWR1, 0); 270 gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
271 gpio_set_value(POODLE_GPIO_SD_PWR, 0); 271 gpio_set_value(POODLE_GPIO_SD_PWR, 0);
272 } 272 }
273
274 return 0;
273} 275}
274 276
275static void poodle_mci_exit(struct device *dev, void *data) 277static void poodle_mci_exit(struct device *dev, void *data)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 2125df0444e7..4c29173026e8 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -598,7 +598,7 @@ static inline void spitz_spi_init(void) {}
598 * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to 598 * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to
599 * give the card a chance to fully insert/eject. 599 * give the card a chance to fully insert/eject.
600 */ 600 */
601static void spitz_mci_setpower(struct device *dev, unsigned int vdd) 601static int spitz_mci_setpower(struct device *dev, unsigned int vdd)
602{ 602{
603 struct pxamci_platform_data* p_d = dev->platform_data; 603 struct pxamci_platform_data* p_d = dev->platform_data;
604 604
@@ -606,6 +606,8 @@ static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
606 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V); 606 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V);
607 else 607 else
608 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0); 608 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0);
609
610 return 0;
609} 611}
610 612
611static struct pxamci_platform_data spitz_mci_platform_data = { 613static struct pxamci_platform_data spitz_mci_platform_data = {
diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 88fde43c948c..62aea3e835f3 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -734,9 +734,10 @@ static int stargate2_mci_init(struct device *dev,
734 * 734 *
735 * Very simple control. Either it is on or off and is controlled by 735 * Very simple control. Either it is on or off and is controlled by
736 * a gpio pin */ 736 * a gpio pin */
737static void stargate2_mci_setpower(struct device *dev, unsigned int vdd) 737static int stargate2_mci_setpower(struct device *dev, unsigned int vdd)
738{ 738{
739 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd); 739 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
740 return 0;
740} 741}
741 742
742static void stargate2_mci_exit(struct device *dev, void *data) 743static void stargate2_mci_exit(struct device *dev, void *data)
diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
index 6d9252e081ce..7791ac76f945 100644
--- a/arch/arm/mach-s3c24xx/Kconfig
+++ b/arch/arm/mach-s3c24xx/Kconfig
@@ -208,7 +208,7 @@ config S3C24XX_GPIO_EXTRA128
208 208
209config S3C24XX_PLL 209config S3C24XX_PLL
210 bool "Support CPUfreq changing of PLL frequency (EXPERIMENTAL)" 210 bool "Support CPUfreq changing of PLL frequency (EXPERIMENTAL)"
211 depends on ARM_S3C24XX 211 depends on ARM_S3C24XX_CPUFREQ
212 help 212 help
213 Compile in support for changing the PLL frequency from the 213 Compile in support for changing the PLL frequency from the
214 S3C24XX series CPUfreq driver. The PLL takes time to settle 214 S3C24XX series CPUfreq driver. The PLL takes time to settle
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2410.c b/arch/arm/mach-s3c24xx/clock-s3c2410.c
index 34fffdf6fc1d..564553694b54 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2410.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2410.c
@@ -119,66 +119,101 @@ static struct clk init_clocks_off[] = {
119 } 119 }
120}; 120};
121 121
122static struct clk init_clocks[] = { 122static struct clk clk_lcd = {
123 { 123 .name = "lcd",
124 .name = "lcd", 124 .parent = &clk_h,
125 .parent = &clk_h, 125 .enable = s3c2410_clkcon_enable,
126 .enable = s3c2410_clkcon_enable, 126 .ctrlbit = S3C2410_CLKCON_LCDC,
127 .ctrlbit = S3C2410_CLKCON_LCDC, 127};
128 }, { 128
129 .name = "gpio", 129static struct clk clk_gpio = {
130 .parent = &clk_p, 130 .name = "gpio",
131 .enable = s3c2410_clkcon_enable, 131 .parent = &clk_p,
132 .ctrlbit = S3C2410_CLKCON_GPIO, 132 .enable = s3c2410_clkcon_enable,
133 }, { 133 .ctrlbit = S3C2410_CLKCON_GPIO,
134 .name = "usb-host", 134};
135 .parent = &clk_h, 135
136 .enable = s3c2410_clkcon_enable, 136static struct clk clk_usb_host = {
137 .ctrlbit = S3C2410_CLKCON_USBH, 137 .name = "usb-host",
138 }, { 138 .parent = &clk_h,
139 .name = "usb-device", 139 .enable = s3c2410_clkcon_enable,
140 .parent = &clk_h, 140 .ctrlbit = S3C2410_CLKCON_USBH,
141 .enable = s3c2410_clkcon_enable, 141};
142 .ctrlbit = S3C2410_CLKCON_USBD, 142
143 }, { 143static struct clk clk_usb_device = {
144 .name = "timers", 144 .name = "usb-device",
145 .parent = &clk_p, 145 .parent = &clk_h,
146 .enable = s3c2410_clkcon_enable, 146 .enable = s3c2410_clkcon_enable,
147 .ctrlbit = S3C2410_CLKCON_PWMT, 147 .ctrlbit = S3C2410_CLKCON_USBD,
148 }, { 148};
149 .name = "uart", 149
150 .devname = "s3c2410-uart.0", 150static struct clk clk_timers = {
151 .parent = &clk_p, 151 .name = "timers",
152 .enable = s3c2410_clkcon_enable, 152 .parent = &clk_p,
153 .ctrlbit = S3C2410_CLKCON_UART0, 153 .enable = s3c2410_clkcon_enable,
154 }, { 154 .ctrlbit = S3C2410_CLKCON_PWMT,
155 .name = "uart", 155};
156 .devname = "s3c2410-uart.1", 156
157 .parent = &clk_p, 157struct clk s3c24xx_clk_uart0 = {
158 .enable = s3c2410_clkcon_enable, 158 .name = "uart",
159 .ctrlbit = S3C2410_CLKCON_UART1, 159 .devname = "s3c2410-uart.0",
160 }, { 160 .parent = &clk_p,
161 .name = "uart", 161 .enable = s3c2410_clkcon_enable,
162 .devname = "s3c2410-uart.2", 162 .ctrlbit = S3C2410_CLKCON_UART0,
163 .parent = &clk_p, 163};
164 .enable = s3c2410_clkcon_enable, 164
165 .ctrlbit = S3C2410_CLKCON_UART2, 165struct clk s3c24xx_clk_uart1 = {
166 }, { 166 .name = "uart",
167 .name = "rtc", 167 .devname = "s3c2410-uart.1",
168 .parent = &clk_p, 168 .parent = &clk_p,
169 .enable = s3c2410_clkcon_enable, 169 .enable = s3c2410_clkcon_enable,
170 .ctrlbit = S3C2410_CLKCON_RTC, 170 .ctrlbit = S3C2410_CLKCON_UART1,
171 }, { 171};
172 .name = "watchdog", 172
173 .parent = &clk_p, 173struct clk s3c24xx_clk_uart2 = {
174 .ctrlbit = 0, 174 .name = "uart",
175 }, { 175 .devname = "s3c2410-uart.2",
176 .name = "usb-bus-host", 176 .parent = &clk_p,
177 .parent = &clk_usb_bus, 177 .enable = s3c2410_clkcon_enable,
178 }, { 178 .ctrlbit = S3C2410_CLKCON_UART2,
179 .name = "usb-bus-gadget", 179};
180 .parent = &clk_usb_bus, 180
181 }, 181static struct clk clk_rtc = {
182 .name = "rtc",
183 .parent = &clk_p,
184 .enable = s3c2410_clkcon_enable,
185 .ctrlbit = S3C2410_CLKCON_RTC,
186};
187
188static struct clk clk_watchdog = {
189 .name = "watchdog",
190 .parent = &clk_p,
191 .ctrlbit = 0,
192};
193
194static struct clk clk_usb_bus_host = {
195 .name = "usb-bus-host",
196 .parent = &clk_usb_bus,
197};
198
199static struct clk clk_usb_bus_gadget = {
200 .name = "usb-bus-gadget",
201 .parent = &clk_usb_bus,
202};
203
204static struct clk *init_clocks[] = {
205 &clk_lcd,
206 &clk_gpio,
207 &clk_usb_host,
208 &clk_usb_device,
209 &clk_timers,
210 &s3c24xx_clk_uart0,
211 &s3c24xx_clk_uart1,
212 &s3c24xx_clk_uart2,
213 &clk_rtc,
214 &clk_watchdog,
215 &clk_usb_bus_host,
216 &clk_usb_bus_gadget,
182}; 217};
183 218
184/* s3c2410_baseclk_add() 219/* s3c2410_baseclk_add()
@@ -195,7 +230,6 @@ int __init s3c2410_baseclk_add(void)
195{ 230{
196 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW); 231 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
197 unsigned long clkcon = __raw_readl(S3C2410_CLKCON); 232 unsigned long clkcon = __raw_readl(S3C2410_CLKCON);
198 struct clk *clkp;
199 struct clk *xtal; 233 struct clk *xtal;
200 int ret; 234 int ret;
201 int ptr; 235 int ptr;
@@ -207,8 +241,9 @@ int __init s3c2410_baseclk_add(void)
207 241
208 /* register clocks from clock array */ 242 /* register clocks from clock array */
209 243
210 clkp = init_clocks; 244 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++) {
211 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) { 245 struct clk *clkp = init_clocks[ptr];
246
212 /* ensure that we note the clock state */ 247 /* ensure that we note the clock state */
213 248
214 clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0; 249 clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0;
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2440.c b/arch/arm/mach-s3c24xx/clock-s3c2440.c
index 1069b5680826..aaf006d1d6dc 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2440.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2440.c
@@ -166,6 +166,9 @@ static struct clk_lookup s3c2440_clk_lookup[] = {
166 CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk), 166 CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk),
167 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p), 167 CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p),
168 CLKDEV_INIT(NULL, "clk_uart_baud3", &s3c2440_clk_fclk_n), 168 CLKDEV_INIT(NULL, "clk_uart_baud3", &s3c2440_clk_fclk_n),
169 CLKDEV_INIT("s3c2440-uart.0", "uart", &s3c24xx_clk_uart0),
170 CLKDEV_INIT("s3c2440-uart.1", "uart", &s3c24xx_clk_uart1),
171 CLKDEV_INIT("s3c2440-uart.2", "uart", &s3c24xx_clk_uart2),
169 CLKDEV_INIT("s3c2440-camif", "camera", &s3c2440_clk_cam_upll), 172 CLKDEV_INIT("s3c2440-camif", "camera", &s3c2440_clk_cam_upll),
170}; 173};
171 174
diff --git a/arch/arm/mach-shmobile/headsmp-scu.S b/arch/arm/mach-shmobile/headsmp-scu.S
index 6f9865467258..bfd920083a3b 100644
--- a/arch/arm/mach-shmobile/headsmp-scu.S
+++ b/arch/arm/mach-shmobile/headsmp-scu.S
@@ -23,7 +23,6 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <asm/memory.h> 24#include <asm/memory.h>
25 25
26 __CPUINIT
27/* 26/*
28 * Boot code for secondary CPUs. 27 * Boot code for secondary CPUs.
29 * 28 *
diff --git a/arch/arm/mach-shmobile/headsmp.S b/arch/arm/mach-shmobile/headsmp.S
index 559d1ce5f57e..a9d212498987 100644
--- a/arch/arm/mach-shmobile/headsmp.S
+++ b/arch/arm/mach-shmobile/headsmp.S
@@ -14,8 +14,6 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <asm/memory.h> 15#include <asm/memory.h>
16 16
17 __CPUINIT
18
19ENTRY(shmobile_invalidate_start) 17ENTRY(shmobile_invalidate_start)
20 bl v7_invalidate_l1 18 bl v7_invalidate_l1
21 b secondary_startup 19 b secondary_startup
diff --git a/arch/arm/mach-shmobile/smp-emev2.c b/arch/arm/mach-shmobile/smp-emev2.c
index 80991b35f4ac..22a05a869d25 100644
--- a/arch/arm/mach-shmobile/smp-emev2.c
+++ b/arch/arm/mach-shmobile/smp-emev2.c
@@ -30,7 +30,7 @@
30 30
31#define EMEV2_SCU_BASE 0x1e000000 31#define EMEV2_SCU_BASE 0x1e000000
32 32
33static int __cpuinit emev2_boot_secondary(unsigned int cpu, struct task_struct *idle) 33static int emev2_boot_secondary(unsigned int cpu, struct task_struct *idle)
34{ 34{
35 arch_send_wakeup_ipi_mask(cpumask_of(cpu_logical_map(cpu))); 35 arch_send_wakeup_ipi_mask(cpumask_of(cpu_logical_map(cpu)));
36 return 0; 36 return 0;
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c
index 526cfaae81c1..9bdf810f2a87 100644
--- a/arch/arm/mach-shmobile/smp-r8a7779.c
+++ b/arch/arm/mach-shmobile/smp-r8a7779.c
@@ -81,7 +81,7 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu)
81 return ret ? ret : 1; 81 return ret ? ret : 1;
82} 82}
83 83
84static int __cpuinit r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) 84static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
85{ 85{
86 struct r8a7779_pm_ch *ch = NULL; 86 struct r8a7779_pm_ch *ch = NULL;
87 int ret = -EIO; 87 int ret = -EIO;
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index d613113a04bd..d5fc3ed4e315 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -48,7 +48,7 @@ void __init sh73a0_register_twd(void)
48} 48}
49#endif 49#endif
50 50
51static int __cpuinit sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle) 51static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
52{ 52{
53 cpu = cpu_logical_map(cpu); 53 cpu = cpu_logical_map(cpu);
54 54
diff --git a/arch/arm/mach-socfpga/headsmp.S b/arch/arm/mach-socfpga/headsmp.S
index 9004bfb1756e..95c115d8b5ee 100644
--- a/arch/arm/mach-socfpga/headsmp.S
+++ b/arch/arm/mach-socfpga/headsmp.S
@@ -10,7 +10,6 @@
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <linux/init.h> 11#include <linux/init.h>
12 12
13 __CPUINIT
14 .arch armv7-a 13 .arch armv7-a
15 14
16ENTRY(secondary_trampoline) 15ENTRY(secondary_trampoline)
diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c
index b51ce8c7929d..5356a72bc8ce 100644
--- a/arch/arm/mach-socfpga/platsmp.c
+++ b/arch/arm/mach-socfpga/platsmp.c
@@ -29,7 +29,7 @@
29 29
30#include "core.h" 30#include "core.h"
31 31
32static int __cpuinit socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle) 32static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
33{ 33{
34 int trampoline_size = &secondary_trampoline_end - &secondary_trampoline; 34 int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
35 35
diff --git a/arch/arm/mach-spear/generic.h b/arch/arm/mach-spear/generic.h
index 904f2c907b46..a99d90a4d09c 100644
--- a/arch/arm/mach-spear/generic.h
+++ b/arch/arm/mach-spear/generic.h
@@ -37,7 +37,7 @@ void __init spear13xx_l2x0_init(void);
37void spear_restart(enum reboot_mode, const char *); 37void spear_restart(enum reboot_mode, const char *);
38 38
39void spear13xx_secondary_startup(void); 39void spear13xx_secondary_startup(void);
40void __cpuinit spear13xx_cpu_die(unsigned int cpu); 40void spear13xx_cpu_die(unsigned int cpu);
41 41
42extern struct smp_operations spear13xx_smp_ops; 42extern struct smp_operations spear13xx_smp_ops;
43 43
diff --git a/arch/arm/mach-spear/platsmp.c b/arch/arm/mach-spear/platsmp.c
index 9c4c722c954e..5c4a19887b2b 100644
--- a/arch/arm/mach-spear/platsmp.c
+++ b/arch/arm/mach-spear/platsmp.c
@@ -24,7 +24,7 @@ static DEFINE_SPINLOCK(boot_lock);
24 24
25static void __iomem *scu_base = IOMEM(VA_SCU_BASE); 25static void __iomem *scu_base = IOMEM(VA_SCU_BASE);
26 26
27static void __cpuinit spear13xx_secondary_init(unsigned int cpu) 27static void spear13xx_secondary_init(unsigned int cpu)
28{ 28{
29 /* 29 /*
30 * let the primary processor know we're out of the 30 * let the primary processor know we're out of the
@@ -40,7 +40,7 @@ static void __cpuinit spear13xx_secondary_init(unsigned int cpu)
40 spin_unlock(&boot_lock); 40 spin_unlock(&boot_lock);
41} 41}
42 42
43static int __cpuinit spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle) 43static int spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle)
44{ 44{
45 unsigned long timeout; 45 unsigned long timeout;
46 46
diff --git a/arch/arm/mach-sti/Kconfig b/arch/arm/mach-sti/Kconfig
index d04e3bfe1918..835833e3c4f8 100644
--- a/arch/arm/mach-sti/Kconfig
+++ b/arch/arm/mach-sti/Kconfig
@@ -11,8 +11,9 @@ menuconfig ARCH_STI
11 select HAVE_SMP 11 select HAVE_SMP
12 select HAVE_ARM_SCU if SMP 12 select HAVE_ARM_SCU if SMP
13 select ARCH_REQUIRE_GPIOLIB 13 select ARCH_REQUIRE_GPIOLIB
14 select ARM_ERRATA_720789
15 select ARM_ERRATA_754322 14 select ARM_ERRATA_754322
15 select ARM_ERRATA_764369
16 select ARM_ERRATA_775420
16 select PL310_ERRATA_753970 if CACHE_PL310 17 select PL310_ERRATA_753970 if CACHE_PL310
17 select PL310_ERRATA_769419 if CACHE_PL310 18 select PL310_ERRATA_769419 if CACHE_PL310
18 help 19 help
diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c
index 977a863468fc..dce50d983a8e 100644
--- a/arch/arm/mach-sti/platsmp.c
+++ b/arch/arm/mach-sti/platsmp.c
@@ -27,7 +27,7 @@
27 27
28#include "smp.h" 28#include "smp.h"
29 29
30static void __cpuinit write_pen_release(int val) 30static void write_pen_release(int val)
31{ 31{
32 pen_release = val; 32 pen_release = val;
33 smp_wmb(); 33 smp_wmb();
@@ -37,7 +37,7 @@ static void __cpuinit write_pen_release(int val)
37 37
38static DEFINE_SPINLOCK(boot_lock); 38static DEFINE_SPINLOCK(boot_lock);
39 39
40void __cpuinit sti_secondary_init(unsigned int cpu) 40void sti_secondary_init(unsigned int cpu)
41{ 41{
42 trace_hardirqs_off(); 42 trace_hardirqs_off();
43 43
@@ -54,7 +54,7 @@ void __cpuinit sti_secondary_init(unsigned int cpu)
54 spin_unlock(&boot_lock); 54 spin_unlock(&boot_lock);
55} 55}
56 56
57int __cpuinit sti_boot_secondary(unsigned int cpu, struct task_struct *idle) 57int sti_boot_secondary(unsigned int cpu, struct task_struct *idle)
58{ 58{
59 unsigned long timeout; 59 unsigned long timeout;
60 60
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 24db4ac428ae..97b33a2a2d75 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -35,7 +35,7 @@
35 35
36static cpumask_t tegra_cpu_init_mask; 36static cpumask_t tegra_cpu_init_mask;
37 37
38static void __cpuinit tegra_secondary_init(unsigned int cpu) 38static void tegra_secondary_init(unsigned int cpu)
39{ 39{
40 cpumask_set_cpu(cpu, &tegra_cpu_init_mask); 40 cpumask_set_cpu(cpu, &tegra_cpu_init_mask);
41} 41}
@@ -167,7 +167,7 @@ static int tegra114_boot_secondary(unsigned int cpu, struct task_struct *idle)
167 return ret; 167 return ret;
168} 168}
169 169
170static int __cpuinit tegra_boot_secondary(unsigned int cpu, 170static int tegra_boot_secondary(unsigned int cpu,
171 struct task_struct *idle) 171 struct task_struct *idle)
172{ 172{
173 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20) 173 if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20)
diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c
index 94e69bee3da5..261fec140c06 100644
--- a/arch/arm/mach-tegra/pm.c
+++ b/arch/arm/mach-tegra/pm.c
@@ -191,7 +191,7 @@ static const char *lp_state[TEGRA_MAX_SUSPEND_MODE] = {
191 [TEGRA_SUSPEND_LP0] = "LP0", 191 [TEGRA_SUSPEND_LP0] = "LP0",
192}; 192};
193 193
194static int __cpuinit tegra_suspend_enter(suspend_state_t state) 194static int tegra_suspend_enter(suspend_state_t state)
195{ 195{
196 enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode(); 196 enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode();
197 197
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index 14d90469392f..1f296e796a4f 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -54,7 +54,7 @@ static void __iomem *scu_base_addr(void)
54 54
55static DEFINE_SPINLOCK(boot_lock); 55static DEFINE_SPINLOCK(boot_lock);
56 56
57static void __cpuinit ux500_secondary_init(unsigned int cpu) 57static void ux500_secondary_init(unsigned int cpu)
58{ 58{
59 /* 59 /*
60 * let the primary processor know we're out of the 60 * let the primary processor know we're out of the
@@ -69,7 +69,7 @@ static void __cpuinit ux500_secondary_init(unsigned int cpu)
69 spin_unlock(&boot_lock); 69 spin_unlock(&boot_lock);
70} 70}
71 71
72static int __cpuinit ux500_boot_secondary(unsigned int cpu, struct task_struct *idle) 72static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
73{ 73{
74 unsigned long timeout; 74 unsigned long timeout;
75 75
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 5b799c29886e..5f252569c689 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -91,7 +91,7 @@ static void __init zynq_map_io(void)
91 zynq_scu_map_io(); 91 zynq_scu_map_io();
92} 92}
93 93
94static void zynq_system_reset(char mode, const char *cmd) 94static void zynq_system_reset(enum reboot_mode mode, const char *cmd)
95{ 95{
96 zynq_slcr_system_reset(); 96 zynq_slcr_system_reset();
97} 97}
diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h
index fbbd0e21c404..3040d219570f 100644
--- a/arch/arm/mach-zynq/common.h
+++ b/arch/arm/mach-zynq/common.h
@@ -27,7 +27,7 @@ extern void secondary_startup(void);
27extern char zynq_secondary_trampoline; 27extern char zynq_secondary_trampoline;
28extern char zynq_secondary_trampoline_jump; 28extern char zynq_secondary_trampoline_jump;
29extern char zynq_secondary_trampoline_end; 29extern char zynq_secondary_trampoline_end;
30extern int __cpuinit zynq_cpun_start(u32 address, int cpu); 30extern int zynq_cpun_start(u32 address, int cpu);
31extern struct smp_operations zynq_smp_ops __initdata; 31extern struct smp_operations zynq_smp_ops __initdata;
32#endif 32#endif
33 33
diff --git a/arch/arm/mach-zynq/headsmp.S b/arch/arm/mach-zynq/headsmp.S
index d183cd234a9b..d4cd5f34fe5c 100644
--- a/arch/arm/mach-zynq/headsmp.S
+++ b/arch/arm/mach-zynq/headsmp.S
@@ -9,8 +9,6 @@
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <linux/init.h> 10#include <linux/init.h>
11 11
12 __CPUINIT
13
14ENTRY(zynq_secondary_trampoline) 12ENTRY(zynq_secondary_trampoline)
15 ldr r0, [pc] 13 ldr r0, [pc]
16 bx r0 14 bx r0
diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c
index 023f225493f2..689fbbc3d9c8 100644
--- a/arch/arm/mach-zynq/platsmp.c
+++ b/arch/arm/mach-zynq/platsmp.c
@@ -30,11 +30,11 @@
30/* 30/*
31 * Store number of cores in the system 31 * Store number of cores in the system
32 * Because of scu_get_core_count() must be in __init section and can't 32 * Because of scu_get_core_count() must be in __init section and can't
33 * be called from zynq_cpun_start() because it is in __cpuinit section. 33 * be called from zynq_cpun_start() because it is not in __init section.
34 */ 34 */
35static int ncores; 35static int ncores;
36 36
37int __cpuinit zynq_cpun_start(u32 address, int cpu) 37int zynq_cpun_start(u32 address, int cpu)
38{ 38{
39 u32 trampoline_code_size = &zynq_secondary_trampoline_end - 39 u32 trampoline_code_size = &zynq_secondary_trampoline_end -
40 &zynq_secondary_trampoline; 40 &zynq_secondary_trampoline;
@@ -92,7 +92,7 @@ int __cpuinit zynq_cpun_start(u32 address, int cpu)
92} 92}
93EXPORT_SYMBOL(zynq_cpun_start); 93EXPORT_SYMBOL(zynq_cpun_start);
94 94
95static int __cpuinit zynq_boot_secondary(unsigned int cpu, 95static int zynq_boot_secondary(unsigned int cpu,
96 struct task_struct *idle) 96 struct task_struct *idle)
97{ 97{
98 return zynq_cpun_start(virt_to_phys(secondary_startup), cpu); 98 return zynq_cpun_start(virt_to_phys(secondary_startup), cpu);
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 2bb61e703d6c..d1a2d05971e0 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -443,8 +443,6 @@ ENTRY(cpu_arm1020_set_pte_ext)
443#endif /* CONFIG_MMU */ 443#endif /* CONFIG_MMU */
444 mov pc, lr 444 mov pc, lr
445 445
446 __CPUINIT
447
448 .type __arm1020_setup, #function 446 .type __arm1020_setup, #function
449__arm1020_setup: 447__arm1020_setup:
450 mov r0, #0 448 mov r0, #0
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index 8f96aa40f510..9d89405c3d03 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -425,8 +425,6 @@ ENTRY(cpu_arm1020e_set_pte_ext)
425#endif /* CONFIG_MMU */ 425#endif /* CONFIG_MMU */
426 mov pc, lr 426 mov pc, lr
427 427
428 __CPUINIT
429
430 .type __arm1020e_setup, #function 428 .type __arm1020e_setup, #function
431__arm1020e_setup: 429__arm1020e_setup:
432 mov r0, #0 430 mov r0, #0
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index 8ebe4a469a22..6f01a0ae3b30 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -407,8 +407,6 @@ ENTRY(cpu_arm1022_set_pte_ext)
407#endif /* CONFIG_MMU */ 407#endif /* CONFIG_MMU */
408 mov pc, lr 408 mov pc, lr
409 409
410 __CPUINIT
411
412 .type __arm1022_setup, #function 410 .type __arm1022_setup, #function
413__arm1022_setup: 411__arm1022_setup:
414 mov r0, #0 412 mov r0, #0
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index 093fc7e520c3..4799a24b43e6 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -396,9 +396,6 @@ ENTRY(cpu_arm1026_set_pte_ext)
396#endif /* CONFIG_MMU */ 396#endif /* CONFIG_MMU */
397 mov pc, lr 397 mov pc, lr
398 398
399
400 __CPUINIT
401
402 .type __arm1026_setup, #function 399 .type __arm1026_setup, #function
403__arm1026_setup: 400__arm1026_setup:
404 mov r0, #0 401 mov r0, #0
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index 0ac908c7ade1..d42c37f9f5bc 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -116,8 +116,6 @@ ENTRY(cpu_arm720_reset)
116ENDPROC(cpu_arm720_reset) 116ENDPROC(cpu_arm720_reset)
117 .popsection 117 .popsection
118 118
119 __CPUINIT
120
121 .type __arm710_setup, #function 119 .type __arm710_setup, #function
122__arm710_setup: 120__arm710_setup:
123 mov r0, #0 121 mov r0, #0
diff --git a/arch/arm/mm/proc-arm740.S b/arch/arm/mm/proc-arm740.S
index fde2d2a794cf..9b0ae90cbf17 100644
--- a/arch/arm/mm/proc-arm740.S
+++ b/arch/arm/mm/proc-arm740.S
@@ -60,8 +60,6 @@ ENTRY(cpu_arm740_reset)
60ENDPROC(cpu_arm740_reset) 60ENDPROC(cpu_arm740_reset)
61 .popsection 61 .popsection
62 62
63 __CPUINIT
64
65 .type __arm740_setup, #function 63 .type __arm740_setup, #function
66__arm740_setup: 64__arm740_setup:
67 mov r0, #0 65 mov r0, #0
diff --git a/arch/arm/mm/proc-arm7tdmi.S b/arch/arm/mm/proc-arm7tdmi.S
index 6ddea3e464bd..f6cc3f63ce39 100644
--- a/arch/arm/mm/proc-arm7tdmi.S
+++ b/arch/arm/mm/proc-arm7tdmi.S
@@ -51,8 +51,6 @@ ENTRY(cpu_arm7tdmi_reset)
51ENDPROC(cpu_arm7tdmi_reset) 51ENDPROC(cpu_arm7tdmi_reset)
52 .popsection 52 .popsection
53 53
54 __CPUINIT
55
56 .type __arm7tdmi_setup, #function 54 .type __arm7tdmi_setup, #function
57__arm7tdmi_setup: 55__arm7tdmi_setup:
58 mov pc, lr 56 mov pc, lr
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index 2556cf1c2da1..549557df6d57 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -410,8 +410,6 @@ ENTRY(cpu_arm920_do_resume)
410ENDPROC(cpu_arm920_do_resume) 410ENDPROC(cpu_arm920_do_resume)
411#endif 411#endif
412 412
413 __CPUINIT
414
415 .type __arm920_setup, #function 413 .type __arm920_setup, #function
416__arm920_setup: 414__arm920_setup:
417 mov r0, #0 415 mov r0, #0
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index 4464c49d7449..2a758b06c6f6 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -388,8 +388,6 @@ ENTRY(cpu_arm922_set_pte_ext)
388#endif /* CONFIG_MMU */ 388#endif /* CONFIG_MMU */
389 mov pc, lr 389 mov pc, lr
390 390
391 __CPUINIT
392
393 .type __arm922_setup, #function 391 .type __arm922_setup, #function
394__arm922_setup: 392__arm922_setup:
395 mov r0, #0 393 mov r0, #0
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index 281eb9b9c1d6..97448c3acf38 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -438,8 +438,6 @@ ENTRY(cpu_arm925_set_pte_ext)
438#endif /* CONFIG_MMU */ 438#endif /* CONFIG_MMU */
439 mov pc, lr 439 mov pc, lr
440 440
441 __CPUINIT
442
443 .type __arm925_setup, #function 441 .type __arm925_setup, #function
444__arm925_setup: 442__arm925_setup:
445 mov r0, #0 443 mov r0, #0
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 344c8a548cc0..0f098f407c9f 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -425,8 +425,6 @@ ENTRY(cpu_arm926_do_resume)
425ENDPROC(cpu_arm926_do_resume) 425ENDPROC(cpu_arm926_do_resume)
426#endif 426#endif
427 427
428 __CPUINIT
429
430 .type __arm926_setup, #function 428 .type __arm926_setup, #function
431__arm926_setup: 429__arm926_setup:
432 mov r0, #0 430 mov r0, #0
diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S
index 8da189d4a402..1c39a704ff6e 100644
--- a/arch/arm/mm/proc-arm940.S
+++ b/arch/arm/mm/proc-arm940.S
@@ -273,8 +273,6 @@ ENDPROC(arm940_dma_unmap_area)
273 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S) 273 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
274 define_cache_functions arm940 274 define_cache_functions arm940
275 275
276 __CPUINIT
277
278 .type __arm940_setup, #function 276 .type __arm940_setup, #function
279__arm940_setup: 277__arm940_setup:
280 mov r0, #0 278 mov r0, #0
diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S
index f666cf34075a..0289cd905e73 100644
--- a/arch/arm/mm/proc-arm946.S
+++ b/arch/arm/mm/proc-arm946.S
@@ -326,8 +326,6 @@ ENTRY(cpu_arm946_dcache_clean_area)
326 mcr p15, 0, r0, c7, c10, 4 @ drain WB 326 mcr p15, 0, r0, c7, c10, 4 @ drain WB
327 mov pc, lr 327 mov pc, lr
328 328
329 __CPUINIT
330
331 .type __arm946_setup, #function 329 .type __arm946_setup, #function
332__arm946_setup: 330__arm946_setup:
333 mov r0, #0 331 mov r0, #0
diff --git a/arch/arm/mm/proc-arm9tdmi.S b/arch/arm/mm/proc-arm9tdmi.S
index 8881391dfb9e..f51197ba754a 100644
--- a/arch/arm/mm/proc-arm9tdmi.S
+++ b/arch/arm/mm/proc-arm9tdmi.S
@@ -51,8 +51,6 @@ ENTRY(cpu_arm9tdmi_reset)
51ENDPROC(cpu_arm9tdmi_reset) 51ENDPROC(cpu_arm9tdmi_reset)
52 .popsection 52 .popsection
53 53
54 __CPUINIT
55
56 .type __arm9tdmi_setup, #function 54 .type __arm9tdmi_setup, #function
57__arm9tdmi_setup: 55__arm9tdmi_setup:
58 mov pc, lr 56 mov pc, lr
diff --git a/arch/arm/mm/proc-fa526.S b/arch/arm/mm/proc-fa526.S
index aaeb6c127c7a..2dfc0f1d3bfd 100644
--- a/arch/arm/mm/proc-fa526.S
+++ b/arch/arm/mm/proc-fa526.S
@@ -135,8 +135,6 @@ ENTRY(cpu_fa526_set_pte_ext)
135#endif 135#endif
136 mov pc, lr 136 mov pc, lr
137 137
138 __CPUINIT
139
140 .type __fa526_setup, #function 138 .type __fa526_setup, #function
141__fa526_setup: 139__fa526_setup:
142 /* On return of this routine, r0 must carry correct flags for CFG register */ 140 /* On return of this routine, r0 must carry correct flags for CFG register */
diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S
index 4106b09e0c29..d5146b98c8d1 100644
--- a/arch/arm/mm/proc-feroceon.S
+++ b/arch/arm/mm/proc-feroceon.S
@@ -514,8 +514,6 @@ ENTRY(cpu_feroceon_set_pte_ext)
514#endif 514#endif
515 mov pc, lr 515 mov pc, lr
516 516
517 __CPUINIT
518
519 .type __feroceon_setup, #function 517 .type __feroceon_setup, #function
520__feroceon_setup: 518__feroceon_setup:
521 mov r0, #0 519 mov r0, #0
diff --git a/arch/arm/mm/proc-mohawk.S b/arch/arm/mm/proc-mohawk.S
index 0b60dd3d742a..40acba595731 100644
--- a/arch/arm/mm/proc-mohawk.S
+++ b/arch/arm/mm/proc-mohawk.S
@@ -383,8 +383,6 @@ ENTRY(cpu_mohawk_do_resume)
383ENDPROC(cpu_mohawk_do_resume) 383ENDPROC(cpu_mohawk_do_resume)
384#endif 384#endif
385 385
386 __CPUINIT
387
388 .type __mohawk_setup, #function 386 .type __mohawk_setup, #function
389__mohawk_setup: 387__mohawk_setup:
390 mov r0, #0 388 mov r0, #0
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index 775d70fba937..c45319c8f1d9 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -159,8 +159,6 @@ ENTRY(cpu_sa110_set_pte_ext)
159#endif 159#endif
160 mov pc, lr 160 mov pc, lr
161 161
162 __CPUINIT
163
164 .type __sa110_setup, #function 162 .type __sa110_setup, #function
165__sa110_setup: 163__sa110_setup:
166 mov r10, #0 164 mov r10, #0
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index d92dfd081429..09d241ae2dbe 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -198,8 +198,6 @@ ENTRY(cpu_sa1100_do_resume)
198ENDPROC(cpu_sa1100_do_resume) 198ENDPROC(cpu_sa1100_do_resume)
199#endif 199#endif
200 200
201 __CPUINIT
202
203 .type __sa1100_setup, #function 201 .type __sa1100_setup, #function
204__sa1100_setup: 202__sa1100_setup:
205 mov r0, #0 203 mov r0, #0
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 2d1ef87328a1..1128064fddcb 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -180,8 +180,6 @@ ENDPROC(cpu_v6_do_resume)
180 180
181 .align 181 .align
182 182
183 __CPUINIT
184
185/* 183/*
186 * __v6_setup 184 * __v6_setup
187 * 185 *
diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
index 9704097c450e..f64afb9f1bd5 100644
--- a/arch/arm/mm/proc-v7-2level.S
+++ b/arch/arm/mm/proc-v7-2level.S
@@ -160,8 +160,6 @@ ENDPROC(cpu_v7_set_pte_ext)
160 mcr p15, 0, \ttbr1, c2, c0, 1 @ load TTB1 160 mcr p15, 0, \ttbr1, c2, c0, 1 @ load TTB1
161 .endm 161 .endm
162 162
163 __CPUINIT
164
165 /* AT 163 /* AT
166 * TFR EV X F I D LR S 164 * TFR EV X F I D LR S
167 * .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM 165 * .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM
@@ -172,5 +170,3 @@ ENDPROC(cpu_v7_set_pte_ext)
172 .type v7_crval, #object 170 .type v7_crval, #object
173v7_crval: 171v7_crval:
174 crval clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c 172 crval clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c
175
176 .previous
diff --git a/arch/arm/mm/proc-v7-3level.S b/arch/arm/mm/proc-v7-3level.S
index 5ffe1956c6d9..c36ac69488c8 100644
--- a/arch/arm/mm/proc-v7-3level.S
+++ b/arch/arm/mm/proc-v7-3level.S
@@ -140,8 +140,6 @@ ENDPROC(cpu_v7_set_pte_ext)
140 mcrr p15, 0, \ttbr0, \zero, c2 @ load TTBR0 140 mcrr p15, 0, \ttbr0, \zero, c2 @ load TTBR0
141 .endm 141 .endm
142 142
143 __CPUINIT
144
145 /* 143 /*
146 * AT 144 * AT
147 * TFR EV X F IHD LR S 145 * TFR EV X F IHD LR S
@@ -153,5 +151,3 @@ ENDPROC(cpu_v7_set_pte_ext)
153 .type v7_crval, #object 151 .type v7_crval, #object
154v7_crval: 152v7_crval:
155 crval clear=0x0120c302, mmuset=0x30c23c7d, ucset=0x00c01c7c 153 crval clear=0x0120c302, mmuset=0x30c23c7d, ucset=0x00c01c7c
156
157 .previous
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 7ef3ad05df39..5c6d5a3050ea 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -167,8 +167,6 @@ ENDPROC(cpu_pj4b_do_idle)
167 167
168#endif 168#endif
169 169
170 __CPUINIT
171
172/* 170/*
173 * __v7_setup 171 * __v7_setup
174 * 172 *
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index e8efd83b6f25..dc1645890042 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -446,8 +446,6 @@ ENTRY(cpu_xsc3_do_resume)
446ENDPROC(cpu_xsc3_do_resume) 446ENDPROC(cpu_xsc3_do_resume)
447#endif 447#endif
448 448
449 __CPUINIT
450
451 .type __xsc3_setup, #function 449 .type __xsc3_setup, #function
452__xsc3_setup: 450__xsc3_setup:
453 mov r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE 451 mov r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index e766f889bfd6..d19b1cfcad91 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -558,8 +558,6 @@ ENTRY(cpu_xscale_do_resume)
558ENDPROC(cpu_xscale_do_resume) 558ENDPROC(cpu_xscale_do_resume)
559#endif 559#endif
560 560
561 __CPUINIT
562
563 .type __xscale_setup, #function 561 .type __xscale_setup, #function
564__xscale_setup: 562__xscale_setup:
565 mcr p15, 0, ip, c7, c7, 0 @ invalidate I, D caches & BTB 563 mcr p15, 0, ip, c7, c7, 0 @ invalidate I, D caches & BTB
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 3dc5cbea86cc..a5b5ff6e68d2 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -29,6 +29,13 @@ config PLAT_S5P
29 help 29 help
30 Base platform code for Samsung's S5P series SoC. 30 Base platform code for Samsung's S5P series SoC.
31 31
32config SAMSUNG_PM
33 bool
34 depends on PM && (PLAT_S3C24XX || ARCH_S3C64XX || ARCH_S5P64X0 || S5P_PM)
35 default y
36 help
37 Base platform power management code for samsung code
38
32if PLAT_SAMSUNG 39if PLAT_SAMSUNG
33 40
34# boot configurations 41# boot configurations
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 98d07d8fc7a7..199bbe304d02 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -51,7 +51,7 @@ obj-$(CONFIG_SAMSUNG_DMADEV) += dma-ops.o
51 51
52# PM support 52# PM support
53 53
54obj-$(CONFIG_PM) += pm.o 54obj-$(CONFIG_SAMSUNG_PM) += pm.o
55obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o 55obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o
56obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o 56obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o
57 57
diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat-samsung/include/plat/clock.h
index a62753dc15ba..df45d6edc98d 100644
--- a/arch/arm/plat-samsung/include/plat/clock.h
+++ b/arch/arm/plat-samsung/include/plat/clock.h
@@ -83,6 +83,11 @@ extern struct clk clk_ext;
83extern struct clksrc_clk clk_epllref; 83extern struct clksrc_clk clk_epllref;
84extern struct clksrc_clk clk_esysclk; 84extern struct clksrc_clk clk_esysclk;
85 85
86/* S3C24XX UART clocks */
87extern struct clk s3c24xx_clk_uart0;
88extern struct clk s3c24xx_clk_uart1;
89extern struct clk s3c24xx_clk_uart2;
90
86/* S3C64XX specific clocks */ 91/* S3C64XX specific clocks */
87extern struct clk clk_h2; 92extern struct clk clk_h2;
88extern struct clk clk_27m; 93extern struct clk clk_27m;
diff --git a/arch/arm/plat-samsung/include/plat/pm.h b/arch/arm/plat-samsung/include/plat/pm.h
index 5d47ca35cabd..6bc1a8f471e3 100644
--- a/arch/arm/plat-samsung/include/plat/pm.h
+++ b/arch/arm/plat-samsung/include/plat/pm.h
@@ -19,7 +19,7 @@
19 19
20struct device; 20struct device;
21 21
22#ifdef CONFIG_PM 22#ifdef CONFIG_SAMSUNG_PM
23 23
24extern __init int s3c_pm_init(void); 24extern __init int s3c_pm_init(void);
25extern __init int s3c64xx_pm_init(void); 25extern __init int s3c64xx_pm_init(void);
@@ -58,8 +58,6 @@ extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */
58 58
59/* from sleep.S */ 59/* from sleep.S */
60 60
61extern void s3c_cpu_resume(void);
62
63extern int s3c2410_cpu_suspend(unsigned long); 61extern int s3c2410_cpu_suspend(unsigned long);
64 62
65/* sleep save info */ 63/* sleep save info */
@@ -106,12 +104,14 @@ extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
106extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); 104extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
107extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count); 105extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);
108 106
109#ifdef CONFIG_PM 107#ifdef CONFIG_SAMSUNG_PM
110extern int s3c_irq_wake(struct irq_data *data, unsigned int state); 108extern int s3c_irq_wake(struct irq_data *data, unsigned int state);
111extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); 109extern int s3c_irqext_wake(struct irq_data *data, unsigned int state);
110extern void s3c_cpu_resume(void);
112#else 111#else
113#define s3c_irq_wake NULL 112#define s3c_irq_wake NULL
114#define s3c_irqext_wake NULL 113#define s3c_irqext_wake NULL
114#define s3c_cpu_resume NULL
115#endif 115#endif
116 116
117/* PM debug functions */ 117/* PM debug functions */
diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c
index ea3613642451..d0c23010b693 100644
--- a/arch/arm/plat-samsung/pm.c
+++ b/arch/arm/plat-samsung/pm.c
@@ -80,7 +80,7 @@ unsigned char pm_uart_udivslot;
80 80
81#ifdef CONFIG_SAMSUNG_PM_DEBUG 81#ifdef CONFIG_SAMSUNG_PM_DEBUG
82 82
83static struct pm_uart_save uart_save[CONFIG_SERIAL_SAMSUNG_UARTS]; 83static struct pm_uart_save uart_save;
84 84
85static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save) 85static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save)
86{ 86{
@@ -101,11 +101,7 @@ static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save)
101 101
102static void s3c_pm_save_uarts(void) 102static void s3c_pm_save_uarts(void)
103{ 103{
104 struct pm_uart_save *save = uart_save; 104 s3c_pm_save_uart(CONFIG_DEBUG_S3C_UART, &uart_save);
105 unsigned int uart;
106
107 for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
108 s3c_pm_save_uart(uart, save);
109} 105}
110 106
111static void s3c_pm_restore_uart(unsigned int uart, struct pm_uart_save *save) 107static 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)
126 122
127static void s3c_pm_restore_uarts(void) 123static void s3c_pm_restore_uarts(void)
128{ 124{
129 struct pm_uart_save *save = uart_save; 125 s3c_pm_restore_uart(CONFIG_DEBUG_S3C_UART, &uart_save);
130 unsigned int uart;
131
132 for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
133 s3c_pm_restore_uart(uart, save);
134} 126}
135#else 127#else
136static void s3c_pm_save_uarts(void) { } 128static void s3c_pm_save_uarts(void) { }
diff --git a/arch/arm/plat-versatile/platsmp.c b/arch/arm/plat-versatile/platsmp.c
index 1e1b2d769748..39895d892c3b 100644
--- a/arch/arm/plat-versatile/platsmp.c
+++ b/arch/arm/plat-versatile/platsmp.c
@@ -23,7 +23,7 @@
23 * observers, irrespective of whether they're taking part in coherency 23 * observers, irrespective of whether they're taking part in coherency
24 * or not. This is necessary for the hotplug code to work reliably. 24 * or not. This is necessary for the hotplug code to work reliably.
25 */ 25 */
26static void __cpuinit write_pen_release(int val) 26static void write_pen_release(int val)
27{ 27{
28 pen_release = val; 28 pen_release = val;
29 smp_wmb(); 29 smp_wmb();
@@ -33,7 +33,7 @@ static void __cpuinit write_pen_release(int val)
33 33
34static DEFINE_SPINLOCK(boot_lock); 34static DEFINE_SPINLOCK(boot_lock);
35 35
36void __cpuinit versatile_secondary_init(unsigned int cpu) 36void versatile_secondary_init(unsigned int cpu)
37{ 37{
38 /* 38 /*
39 * let the primary processor know we're out of the 39 * let the primary processor know we're out of the
@@ -48,7 +48,7 @@ void __cpuinit versatile_secondary_init(unsigned int cpu)
48 spin_unlock(&boot_lock); 48 spin_unlock(&boot_lock);
49} 49}
50 50
51int __cpuinit versatile_boot_secondary(unsigned int cpu, struct task_struct *idle) 51int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
52{ 52{
53 unsigned long timeout; 53 unsigned long timeout;
54 54
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index d56ed11ba9a3..98abd476992d 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -97,7 +97,7 @@ static inline u32 arch_timer_get_cntfrq(void)
97 return val; 97 return val;
98} 98}
99 99
100static inline void __cpuinit arch_counter_set_user_access(void) 100static inline void arch_counter_set_user_access(void)
101{ 101{
102 u32 cntkctl; 102 u32 cntkctl;
103 103
diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h
index ef8235c68c09..a2232d07be9d 100644
--- a/arch/arm64/include/asm/debug-monitors.h
+++ b/arch/arm64/include/asm/debug-monitors.h
@@ -83,14 +83,7 @@ static inline int reinstall_suspended_bps(struct pt_regs *regs)
83} 83}
84#endif 84#endif
85 85
86#ifdef CONFIG_COMPAT
87int aarch32_break_handler(struct pt_regs *regs); 86int aarch32_break_handler(struct pt_regs *regs);
88#else
89static int aarch32_break_handler(struct pt_regs *regs)
90{
91 return -EFAULT;
92}
93#endif
94 87
95#endif /* __ASSEMBLY */ 88#endif /* __ASSEMBLY */
96#endif /* __KERNEL__ */ 89#endif /* __KERNEL__ */
diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h
index a6e1750369ef..7a18fabbe0f6 100644
--- a/arch/arm64/include/asm/system_misc.h
+++ b/arch/arm64/include/asm/system_misc.h
@@ -23,6 +23,7 @@
23#include <linux/compiler.h> 23#include <linux/compiler.h>
24#include <linux/linkage.h> 24#include <linux/linkage.h>
25#include <linux/irqflags.h> 25#include <linux/irqflags.h>
26#include <linux/reboot.h>
26 27
27struct pt_regs; 28struct pt_regs;
28 29
@@ -41,7 +42,7 @@ extern void show_pte(struct mm_struct *mm, unsigned long addr);
41extern void __show_regs(struct pt_regs *); 42extern void __show_regs(struct pt_regs *);
42 43
43void soft_restart(unsigned long); 44void soft_restart(unsigned long);
44extern void (*arm_pm_restart)(char str, const char *cmd); 45extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
45 46
46#define UDBG_UNDEFINED (1 << 0) 47#define UDBG_UNDEFINED (1 << 0)
47#define UDBG_SYSCALL (1 << 1) 48#define UDBG_SYSCALL (1 << 1)
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index 3659e460071d..23a3c4791d86 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -24,10 +24,10 @@
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25 25
26#ifndef CONFIG_ARM64_64K_PAGES 26#ifndef CONFIG_ARM64_64K_PAGES
27#define THREAD_SIZE_ORDER 1 27#define THREAD_SIZE_ORDER 2
28#endif 28#endif
29 29
30#define THREAD_SIZE 8192 30#define THREAD_SIZE 16384
31#define THREAD_START_SP (THREAD_SIZE - 16) 31#define THREAD_START_SP (THREAD_SIZE - 16)
32 32
33#ifndef __ASSEMBLY__ 33#ifndef __ASSEMBLY__
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
index 439827271e3d..26e310c54344 100644
--- a/arch/arm64/include/asm/virt.h
+++ b/arch/arm64/include/asm/virt.h
@@ -21,6 +21,7 @@
21#define BOOT_CPU_MODE_EL2 (0x0e12b007) 21#define BOOT_CPU_MODE_EL2 (0x0e12b007)
22 22
23#ifndef __ASSEMBLY__ 23#ifndef __ASSEMBLY__
24#include <asm/cacheflush.h>
24 25
25/* 26/*
26 * __boot_cpu_mode records what mode CPUs were booted in. 27 * __boot_cpu_mode records what mode CPUs were booted in.
@@ -36,9 +37,20 @@ extern u32 __boot_cpu_mode[2];
36void __hyp_set_vectors(phys_addr_t phys_vector_base); 37void __hyp_set_vectors(phys_addr_t phys_vector_base);
37phys_addr_t __hyp_get_vectors(void); 38phys_addr_t __hyp_get_vectors(void);
38 39
40static inline void sync_boot_mode(void)
41{
42 /*
43 * As secondaries write to __boot_cpu_mode with caches disabled, we
44 * must flush the corresponding cache entries to ensure the visibility
45 * of their writes.
46 */
47 __flush_dcache_area(__boot_cpu_mode, sizeof(__boot_cpu_mode));
48}
49
39/* Reports the availability of HYP mode */ 50/* Reports the availability of HYP mode */
40static inline bool is_hyp_mode_available(void) 51static inline bool is_hyp_mode_available(void)
41{ 52{
53 sync_boot_mode();
42 return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 && 54 return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 &&
43 __boot_cpu_mode[1] == BOOT_CPU_MODE_EL2); 55 __boot_cpu_mode[1] == BOOT_CPU_MODE_EL2);
44} 56}
@@ -46,6 +58,7 @@ static inline bool is_hyp_mode_available(void)
46/* Check if the bootloader has booted CPUs in different modes */ 58/* Check if the bootloader has booted CPUs in different modes */
47static inline bool is_hyp_mode_mismatched(void) 59static inline bool is_hyp_mode_mismatched(void)
48{ 60{
61 sync_boot_mode();
49 return __boot_cpu_mode[0] != __boot_cpu_mode[1]; 62 return __boot_cpu_mode[0] != __boot_cpu_mode[1];
50} 63}
51 64
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index 08018e3df580..cbfacf7fb438 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -141,7 +141,7 @@ static void clear_os_lock(void *unused)
141 isb(); 141 isb();
142} 142}
143 143
144static int __cpuinit os_lock_notify(struct notifier_block *self, 144static int os_lock_notify(struct notifier_block *self,
145 unsigned long action, void *data) 145 unsigned long action, void *data)
146{ 146{
147 int cpu = (unsigned long)data; 147 int cpu = (unsigned long)data;
@@ -150,11 +150,11 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
150 return NOTIFY_OK; 150 return NOTIFY_OK;
151} 151}
152 152
153static struct notifier_block __cpuinitdata os_lock_nb = { 153static struct notifier_block os_lock_nb = {
154 .notifier_call = os_lock_notify, 154 .notifier_call = os_lock_notify,
155}; 155};
156 156
157static int __cpuinit debug_monitors_init(void) 157static int debug_monitors_init(void)
158{ 158{
159 /* Clear the OS lock. */ 159 /* Clear the OS lock. */
160 smp_call_function(clear_os_lock, NULL, 1); 160 smp_call_function(clear_os_lock, NULL, 1);
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 1d1314280a03..6ad781b21c08 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -121,7 +121,7 @@
121 121
122 .macro get_thread_info, rd 122 .macro get_thread_info, rd
123 mov \rd, sp 123 mov \rd, sp
124 and \rd, \rd, #~((1 << 13) - 1) // top of 8K stack 124 and \rd, \rd, #~(THREAD_SIZE - 1) // top of stack
125 .endm 125 .endm
126 126
127/* 127/*
diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index 5ab825c59db9..329218ca9ffb 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -821,7 +821,7 @@ static void reset_ctrl_regs(void *unused)
821 } 821 }
822} 822}
823 823
824static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self, 824static int hw_breakpoint_reset_notify(struct notifier_block *self,
825 unsigned long action, 825 unsigned long action,
826 void *hcpu) 826 void *hcpu)
827{ 827{
@@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
831 return NOTIFY_OK; 831 return NOTIFY_OK;
832} 832}
833 833
834static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = { 834static struct notifier_block hw_breakpoint_reset_nb = {
835 .notifier_call = hw_breakpoint_reset_notify, 835 .notifier_call = hw_breakpoint_reset_notify,
836}; 836};
837 837
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 46f02c3b5015..57fb55c44c90 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -81,7 +81,7 @@ void soft_restart(unsigned long addr)
81void (*pm_power_off)(void); 81void (*pm_power_off)(void);
82EXPORT_SYMBOL_GPL(pm_power_off); 82EXPORT_SYMBOL_GPL(pm_power_off);
83 83
84void (*arm_pm_restart)(char str, const char *cmd); 84void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
85EXPORT_SYMBOL_GPL(arm_pm_restart); 85EXPORT_SYMBOL_GPL(arm_pm_restart);
86 86
87void arch_cpu_idle_prepare(void) 87void arch_cpu_idle_prepare(void)
@@ -132,7 +132,7 @@ void machine_restart(char *cmd)
132 132
133 /* Now call the architecture specific reboot code. */ 133 /* Now call the architecture specific reboot code. */
134 if (arm_pm_restart) 134 if (arm_pm_restart)
135 arm_pm_restart('h', cmd); 135 arm_pm_restart(reboot_mode, cmd);
136 136
137 /* 137 /*
138 * Whoops - the architecture was unable to reboot. 138 * Whoops - the architecture was unable to reboot.
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 5d54e3717bf8..fee5cce83450 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -71,7 +71,7 @@ static DEFINE_RAW_SPINLOCK(boot_lock);
71 * in coherency or not. This is necessary for the hotplug code to work 71 * in coherency or not. This is necessary for the hotplug code to work
72 * reliably. 72 * reliably.
73 */ 73 */
74static void __cpuinit write_pen_release(u64 val) 74static void write_pen_release(u64 val)
75{ 75{
76 void *start = (void *)&secondary_holding_pen_release; 76 void *start = (void *)&secondary_holding_pen_release;
77 unsigned long size = sizeof(secondary_holding_pen_release); 77 unsigned long size = sizeof(secondary_holding_pen_release);
@@ -84,7 +84,7 @@ static void __cpuinit write_pen_release(u64 val)
84 * Boot a secondary CPU, and assign it the specified idle task. 84 * Boot a secondary CPU, and assign it the specified idle task.
85 * This also gives us the initial stack to use for this CPU. 85 * This also gives us the initial stack to use for this CPU.
86 */ 86 */
87static int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) 87static int boot_secondary(unsigned int cpu, struct task_struct *idle)
88{ 88{
89 unsigned long timeout; 89 unsigned long timeout;
90 90
@@ -122,7 +122,7 @@ static int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
122 122
123static DECLARE_COMPLETION(cpu_running); 123static DECLARE_COMPLETION(cpu_running);
124 124
125int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) 125int __cpu_up(unsigned int cpu, struct task_struct *idle)
126{ 126{
127 int ret; 127 int ret;
128 128
@@ -162,7 +162,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
162 * This is the secondary CPU boot entry. We're using this CPUs 162 * This is the secondary CPU boot entry. We're using this CPUs
163 * idle thread stack, but a set of temporary page tables. 163 * idle thread stack, but a set of temporary page tables.
164 */ 164 */
165asmlinkage void __cpuinit secondary_start_kernel(void) 165asmlinkage void secondary_start_kernel(void)
166{ 166{
167 struct mm_struct *mm = &init_mm; 167 struct mm_struct *mm = &init_mm;
168 unsigned int cpu = smp_processor_id(); 168 unsigned int cpu = smp_processor_id();
@@ -200,13 +200,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
200 raw_spin_unlock(&boot_lock); 200 raw_spin_unlock(&boot_lock);
201 201
202 /* 202 /*
203 * Enable local interrupts.
204 */
205 notify_cpu_starting(cpu);
206 local_irq_enable();
207 local_fiq_enable();
208
209 /*
210 * OK, now it's safe to let the boot CPU continue. Wait for 203 * OK, now it's safe to let the boot CPU continue. Wait for
211 * the CPU migration code to notice that the CPU is online 204 * the CPU migration code to notice that the CPU is online
212 * before we continue. 205 * before we continue.
@@ -215,6 +208,14 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
215 complete(&cpu_running); 208 complete(&cpu_running);
216 209
217 /* 210 /*
211 * Enable GIC and timers.
212 */
213 notify_cpu_starting(cpu);
214
215 local_irq_enable();
216 local_fiq_enable();
217
218 /*
218 * OK, it's off to the idle thread for us 219 * OK, it's off to the idle thread for us
219 */ 220 */
220 cpu_startup_entry(CPUHP_ONLINE); 221 cpu_startup_entry(CPUHP_ONLINE);
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 0ecac8980aae..6c8ba25bf6bb 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -152,25 +152,8 @@ void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
152#define ESR_CM (1 << 8) 152#define ESR_CM (1 << 8)
153#define ESR_LNX_EXEC (1 << 24) 153#define ESR_LNX_EXEC (1 << 24)
154 154
155/*
156 * Check that the permissions on the VMA allow for the fault which occurred.
157 * If we encountered a write fault, we must have write permission, otherwise
158 * we allow any permission.
159 */
160static inline bool access_error(unsigned int esr, struct vm_area_struct *vma)
161{
162 unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
163
164 if (esr & ESR_WRITE)
165 mask = VM_WRITE;
166 if (esr & ESR_LNX_EXEC)
167 mask = VM_EXEC;
168
169 return vma->vm_flags & mask ? false : true;
170}
171
172static int __do_page_fault(struct mm_struct *mm, unsigned long addr, 155static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
173 unsigned int esr, unsigned int flags, 156 unsigned int mm_flags, unsigned long vm_flags,
174 struct task_struct *tsk) 157 struct task_struct *tsk)
175{ 158{
176 struct vm_area_struct *vma; 159 struct vm_area_struct *vma;
@@ -188,12 +171,17 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
188 * it. 171 * it.
189 */ 172 */
190good_area: 173good_area:
191 if (access_error(esr, vma)) { 174 /*
175 * Check that the permissions on the VMA allow for the fault which
176 * occurred. If we encountered a write or exec fault, we must have
177 * appropriate permissions, otherwise we allow any permission.
178 */
179 if (!(vma->vm_flags & vm_flags)) {
192 fault = VM_FAULT_BADACCESS; 180 fault = VM_FAULT_BADACCESS;
193 goto out; 181 goto out;
194 } 182 }
195 183
196 return handle_mm_fault(mm, vma, addr & PAGE_MASK, flags); 184 return handle_mm_fault(mm, vma, addr & PAGE_MASK, mm_flags);
197 185
198check_stack: 186check_stack:
199 if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr)) 187 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,
208 struct task_struct *tsk; 196 struct task_struct *tsk;
209 struct mm_struct *mm; 197 struct mm_struct *mm;
210 int fault, sig, code; 198 int fault, sig, code;
211 bool write = (esr & ESR_WRITE) && !(esr & ESR_CM); 199 unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
212 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | 200 unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
213 (write ? FAULT_FLAG_WRITE : 0); 201
202 if (esr & ESR_LNX_EXEC) {
203 vm_flags = VM_EXEC;
204 } else if ((esr & ESR_WRITE) && !(esr & ESR_CM)) {
205 vm_flags = VM_WRITE;
206 mm_flags |= FAULT_FLAG_WRITE;
207 }
214 208
215 tsk = current; 209 tsk = current;
216 mm = tsk->mm; 210 mm = tsk->mm;
@@ -248,7 +242,7 @@ retry:
248#endif 242#endif
249 } 243 }
250 244
251 fault = __do_page_fault(mm, addr, esr, flags, tsk); 245 fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk);
252 246
253 /* 247 /*
254 * If we need to retry but a fatal signal is pending, handle the 248 * If we need to retry but a fatal signal is pending, handle the
@@ -265,7 +259,7 @@ retry:
265 */ 259 */
266 260
267 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); 261 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
268 if (flags & FAULT_FLAG_ALLOW_RETRY) { 262 if (mm_flags & FAULT_FLAG_ALLOW_RETRY) {
269 if (fault & VM_FAULT_MAJOR) { 263 if (fault & VM_FAULT_MAJOR) {
270 tsk->maj_flt++; 264 tsk->maj_flt++;
271 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, 265 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
@@ -280,7 +274,7 @@ retry:
280 * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of 274 * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of
281 * starvation. 275 * starvation.
282 */ 276 */
283 flags &= ~FAULT_FLAG_ALLOW_RETRY; 277 mm_flags &= ~FAULT_FLAG_ALLOW_RETRY;
284 goto retry; 278 goto retry;
285 } 279 }
286 } 280 }
diff --git a/arch/blackfin/kernel/perf_event.c b/arch/blackfin/kernel/perf_event.c
index e47d19ae3e06..974e55496db3 100644
--- a/arch/blackfin/kernel/perf_event.c
+++ b/arch/blackfin/kernel/perf_event.c
@@ -468,7 +468,7 @@ static void bfin_pmu_setup(int cpu)
468 memset(cpuhw, 0, sizeof(struct cpu_hw_events)); 468 memset(cpuhw, 0, sizeof(struct cpu_hw_events));
469} 469}
470 470
471static int __cpuinit 471static int
472bfin_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) 472bfin_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
473{ 473{
474 unsigned int cpu = (long)hcpu; 474 unsigned int cpu = (long)hcpu;
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 107b306b06f1..19ad0637e8ff 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -99,7 +99,7 @@ void __init generate_cplb_tables(void)
99} 99}
100#endif 100#endif
101 101
102void __cpuinit bfin_setup_caches(unsigned int cpu) 102void bfin_setup_caches(unsigned int cpu)
103{ 103{
104#ifdef CONFIG_BFIN_ICACHE 104#ifdef CONFIG_BFIN_ICACHE
105 bfin_icache_init(icplb_tbl[cpu]); 105 bfin_icache_init(icplb_tbl[cpu]);
@@ -165,7 +165,7 @@ void __cpuinit bfin_setup_caches(unsigned int cpu)
165#endif 165#endif
166} 166}
167 167
168void __cpuinit bfin_setup_cpudata(unsigned int cpu) 168void bfin_setup_cpudata(unsigned int cpu)
169{ 169{
170 struct blackfin_cpudata *cpudata = &per_cpu(cpu_data, cpu); 170 struct blackfin_cpudata *cpudata = &per_cpu(cpu_data, cpu);
171 171
diff --git a/arch/blackfin/mach-bf561/smp.c b/arch/blackfin/mach-bf561/smp.c
index c77a23bc9de3..11789beca75a 100644
--- a/arch/blackfin/mach-bf561/smp.c
+++ b/arch/blackfin/mach-bf561/smp.c
@@ -48,7 +48,7 @@ int __init setup_profiling_timer(unsigned int multiplier) /* not supported */
48 return -EINVAL; 48 return -EINVAL;
49} 49}
50 50
51void __cpuinit platform_secondary_init(unsigned int cpu) 51void platform_secondary_init(unsigned int cpu)
52{ 52{
53 /* Clone setup for peripheral interrupt sources from CoreA. */ 53 /* Clone setup for peripheral interrupt sources from CoreA. */
54 bfin_write_SICB_IMASK0(bfin_read_SIC_IMASK0()); 54 bfin_write_SICB_IMASK0(bfin_read_SIC_IMASK0());
@@ -73,7 +73,7 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
73 spin_unlock(&boot_lock); 73 spin_unlock(&boot_lock);
74} 74}
75 75
76int __cpuinit platform_boot_secondary(unsigned int cpu, struct task_struct *idle) 76int platform_boot_secondary(unsigned int cpu, struct task_struct *idle)
77{ 77{
78 unsigned long timeout; 78 unsigned long timeout;
79 79
@@ -154,7 +154,7 @@ void platform_clear_ipi(unsigned int cpu, int irq)
154 * Setup core B's local core timer. 154 * Setup core B's local core timer.
155 * In SMP, core timer is used for clock event device. 155 * In SMP, core timer is used for clock event device.
156 */ 156 */
157void __cpuinit bfin_local_timer_setup(void) 157void bfin_local_timer_setup(void)
158{ 158{
159#if defined(CONFIG_TICKSOURCE_CORETMR) 159#if defined(CONFIG_TICKSOURCE_CORETMR)
160 struct irq_data *data = irq_get_irq_data(IRQ_CORETMR); 160 struct irq_data *data = irq_get_irq_data(IRQ_CORETMR);
diff --git a/arch/blackfin/mach-common/cache-c.c b/arch/blackfin/mach-common/cache-c.c
index a60a24f5035d..0e1e451fd7d8 100644
--- a/arch/blackfin/mach-common/cache-c.c
+++ b/arch/blackfin/mach-common/cache-c.c
@@ -52,7 +52,7 @@ bfin_cache_init(struct cplb_entry *cplb_tbl, unsigned long cplb_addr,
52} 52}
53 53
54#ifdef CONFIG_BFIN_ICACHE 54#ifdef CONFIG_BFIN_ICACHE
55void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl) 55void bfin_icache_init(struct cplb_entry *icplb_tbl)
56{ 56{
57 bfin_cache_init(icplb_tbl, ICPLB_ADDR0, ICPLB_DATA0, IMEM_CONTROL, 57 bfin_cache_init(icplb_tbl, ICPLB_ADDR0, ICPLB_DATA0, IMEM_CONTROL,
58 (IMC | ENICPLB)); 58 (IMC | ENICPLB));
@@ -60,7 +60,7 @@ void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl)
60#endif 60#endif
61 61
62#ifdef CONFIG_BFIN_DCACHE 62#ifdef CONFIG_BFIN_DCACHE
63void __cpuinit bfin_dcache_init(struct cplb_entry *dcplb_tbl) 63void bfin_dcache_init(struct cplb_entry *dcplb_tbl)
64{ 64{
65 /* 65 /*
66 * Anomaly notes: 66 * Anomaly notes:
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index 6c0c6816a51a..d143fd8d2bc5 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -1281,7 +1281,7 @@ static struct irq_chip bfin_gpio_irqchip = {
1281 .irq_set_wake = bfin_gpio_set_wake, 1281 .irq_set_wake = bfin_gpio_set_wake,
1282}; 1282};
1283 1283
1284void __cpuinit init_exception_vectors(void) 1284void init_exception_vectors(void)
1285{ 1285{
1286 /* cannot program in software: 1286 /* cannot program in software:
1287 * evt0 - emulation (jtag) 1287 * evt0 - emulation (jtag)
diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c
index 961d8392e5e3..82f301c117a5 100644
--- a/arch/blackfin/mach-common/smp.c
+++ b/arch/blackfin/mach-common/smp.c
@@ -46,7 +46,7 @@ struct corelock_slot corelock __attribute__ ((__section__(".l2.bss")));
46unsigned long blackfin_iflush_l1_entry[NR_CPUS]; 46unsigned long blackfin_iflush_l1_entry[NR_CPUS];
47#endif 47#endif
48 48
49struct blackfin_initial_pda __cpuinitdata initial_pda_coreb; 49struct blackfin_initial_pda initial_pda_coreb;
50 50
51enum ipi_message_type { 51enum ipi_message_type {
52 BFIN_IPI_NONE, 52 BFIN_IPI_NONE,
@@ -147,7 +147,7 @@ static irqreturn_t ipi_handler_int1(int irq, void *dev_instance)
147 platform_clear_ipi(cpu, IRQ_SUPPLE_1); 147 platform_clear_ipi(cpu, IRQ_SUPPLE_1);
148 148
149 bfin_ipi_data = &__get_cpu_var(bfin_ipi); 149 bfin_ipi_data = &__get_cpu_var(bfin_ipi);
150 while ((pending = xchg(&bfin_ipi_data->bits, 0)) != 0) { 150 while ((pending = atomic_xchg(&bfin_ipi_data->bits, 0)) != 0) {
151 msg = 0; 151 msg = 0;
152 do { 152 do {
153 msg = find_next_bit(&pending, BITS_PER_LONG, msg + 1); 153 msg = find_next_bit(&pending, BITS_PER_LONG, msg + 1);
@@ -182,8 +182,8 @@ static void bfin_ipi_init(void)
182 struct ipi_data *bfin_ipi_data; 182 struct ipi_data *bfin_ipi_data;
183 for_each_possible_cpu(cpu) { 183 for_each_possible_cpu(cpu) {
184 bfin_ipi_data = &per_cpu(bfin_ipi, cpu); 184 bfin_ipi_data = &per_cpu(bfin_ipi, cpu);
185 bfin_ipi_data->bits = 0; 185 atomic_set(&bfin_ipi_data->bits, 0);
186 bfin_ipi_data->count = 0; 186 atomic_set(&bfin_ipi_data->count, 0);
187 } 187 }
188} 188}
189 189
@@ -246,7 +246,7 @@ void smp_send_stop(void)
246 return; 246 return;
247} 247}
248 248
249int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) 249int __cpu_up(unsigned int cpu, struct task_struct *idle)
250{ 250{
251 int ret; 251 int ret;
252 252
@@ -259,7 +259,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
259 return ret; 259 return ret;
260} 260}
261 261
262static void __cpuinit setup_secondary(unsigned int cpu) 262static void setup_secondary(unsigned int cpu)
263{ 263{
264 unsigned long ilat; 264 unsigned long ilat;
265 265
@@ -277,7 +277,7 @@ static void __cpuinit setup_secondary(unsigned int cpu)
277 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW; 277 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
278} 278}
279 279
280void __cpuinit secondary_start_kernel(void) 280void secondary_start_kernel(void)
281{ 281{
282 unsigned int cpu = smp_processor_id(); 282 unsigned int cpu = smp_processor_id();
283 struct mm_struct *mm = &init_mm; 283 struct mm_struct *mm = &init_mm;
@@ -402,7 +402,7 @@ EXPORT_SYMBOL(resync_core_dcache);
402#endif 402#endif
403 403
404#ifdef CONFIG_HOTPLUG_CPU 404#ifdef CONFIG_HOTPLUG_CPU
405int __cpuexit __cpu_disable(void) 405int __cpu_disable(void)
406{ 406{
407 unsigned int cpu = smp_processor_id(); 407 unsigned int cpu = smp_processor_id();
408 408
@@ -415,7 +415,7 @@ int __cpuexit __cpu_disable(void)
415 415
416static DECLARE_COMPLETION(cpu_killed); 416static DECLARE_COMPLETION(cpu_killed);
417 417
418int __cpuexit __cpu_die(unsigned int cpu) 418int __cpu_die(unsigned int cpu)
419{ 419{
420 return wait_for_completion_timeout(&cpu_killed, 5000); 420 return wait_for_completion_timeout(&cpu_killed, 5000);
421} 421}
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index cdd12028de0c..fe8e6039db2a 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -197,7 +197,7 @@ int setup_profiling_timer(unsigned int multiplier)
197 */ 197 */
198unsigned long cache_decay_ticks = 1; 198unsigned long cache_decay_ticks = 1;
199 199
200int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 200int __cpu_up(unsigned int cpu, struct task_struct *tidle)
201{ 201{
202 smp_boot_one_cpu(cpu, tidle); 202 smp_boot_one_cpu(cpu, tidle);
203 return cpu_online(cpu) ? 0 : -ENOSYS; 203 return cpu_online(cpu) ? 0 : -ENOSYS;
diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index ae3a6706419b..9f3a7a62d787 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -709,7 +709,7 @@ static void __init reserve_dma_coherent(void)
709/* 709/*
710 * calibrate the delay loop 710 * calibrate the delay loop
711 */ 711 */
712void __cpuinit calibrate_delay(void) 712void calibrate_delay(void)
713{ 713{
714 loops_per_jiffy = __delay_loops_MHz * (1000000 / HZ); 714 loops_per_jiffy = __delay_loops_MHz * (1000000 / HZ);
715 715
diff --git a/arch/hexagon/kernel/setup.c b/arch/hexagon/kernel/setup.c
index bfe13311d70d..29d1f1b00016 100644
--- a/arch/hexagon/kernel/setup.c
+++ b/arch/hexagon/kernel/setup.c
@@ -41,7 +41,7 @@ static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
41 41
42int on_simulator; 42int on_simulator;
43 43
44void __cpuinit calibrate_delay(void) 44void calibrate_delay(void)
45{ 45{
46 loops_per_jiffy = thread_freq_mhz * 1000000 / HZ; 46 loops_per_jiffy = thread_freq_mhz * 1000000 / HZ;
47} 47}
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c
index 0e364ca43198..9faaa940452b 100644
--- a/arch/hexagon/kernel/smp.c
+++ b/arch/hexagon/kernel/smp.c
@@ -146,7 +146,7 @@ void __init smp_prepare_boot_cpu(void)
146 * to point to current thread info 146 * to point to current thread info
147 */ 147 */
148 148
149void __cpuinit start_secondary(void) 149void start_secondary(void)
150{ 150{
151 unsigned int cpu; 151 unsigned int cpu;
152 unsigned long thread_ptr; 152 unsigned long thread_ptr;
@@ -194,7 +194,7 @@ void __cpuinit start_secondary(void)
194 * maintains control until "cpu_online(cpu)" is set. 194 * maintains control until "cpu_online(cpu)" is set.
195 */ 195 */
196 196
197int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) 197int __cpu_up(unsigned int cpu, struct task_struct *idle)
198{ 198{
199 struct thread_info *thread = (struct thread_info *)idle->stack; 199 struct thread_info *thread = (struct thread_info *)idle->stack;
200 void *stack_start; 200 void *stack_start;
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index 0ac558adc605..bb21f4f63170 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -343,7 +343,7 @@ static void __init do_boot_cpu(int phys_id)
343 } 343 }
344} 344}
345 345
346int __cpuinit __cpu_up(unsigned int cpu_id, struct task_struct *tidle) 346int __cpu_up(unsigned int cpu_id, struct task_struct *tidle)
347{ 347{
348 int timeout; 348 int timeout;
349 349
diff --git a/arch/metag/kernel/perf/perf_event.c b/arch/metag/kernel/perf/perf_event.c
index 5b18888ee364..5cc4d4dcf3cf 100644
--- a/arch/metag/kernel/perf/perf_event.c
+++ b/arch/metag/kernel/perf/perf_event.c
@@ -813,8 +813,8 @@ static struct metag_pmu _metag_pmu = {
813}; 813};
814 814
815/* PMU CPU hotplug notifier */ 815/* PMU CPU hotplug notifier */
816static int __cpuinit metag_pmu_cpu_notify(struct notifier_block *b, 816static int metag_pmu_cpu_notify(struct notifier_block *b, unsigned long action,
817 unsigned long action, void *hcpu) 817 void *hcpu)
818{ 818{
819 unsigned int cpu = (unsigned int)hcpu; 819 unsigned int cpu = (unsigned int)hcpu;
820 struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); 820 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,
828 return NOTIFY_OK; 828 return NOTIFY_OK;
829} 829}
830 830
831static struct notifier_block __cpuinitdata metag_pmu_notifier = { 831static struct notifier_block metag_pmu_notifier = {
832 .notifier_call = metag_pmu_cpu_notify, 832 .notifier_call = metag_pmu_cpu_notify,
833}; 833};
834 834
diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c
index e413875cf6d2..7c0113142981 100644
--- a/arch/metag/kernel/smp.c
+++ b/arch/metag/kernel/smp.c
@@ -68,7 +68,7 @@ static DECLARE_COMPLETION(cpu_running);
68/* 68/*
69 * "thread" is assumed to be a valid Meta hardware thread ID. 69 * "thread" is assumed to be a valid Meta hardware thread ID.
70 */ 70 */
71int __cpuinit boot_secondary(unsigned int thread, struct task_struct *idle) 71int boot_secondary(unsigned int thread, struct task_struct *idle)
72{ 72{
73 u32 val; 73 u32 val;
74 74
@@ -118,11 +118,9 @@ int __cpuinit boot_secondary(unsigned int thread, struct task_struct *idle)
118 * If the cache partition has changed, prints a message to the log describing 118 * If the cache partition has changed, prints a message to the log describing
119 * those changes. 119 * those changes.
120 */ 120 */
121static __cpuinit void describe_cachepart_change(unsigned int thread, 121static void describe_cachepart_change(unsigned int thread, const char *label,
122 const char *label, 122 unsigned int sz, unsigned int old,
123 unsigned int sz, 123 unsigned int new)
124 unsigned int old,
125 unsigned int new)
126{ 124{
127 unsigned int lor1, land1, gor1, gand1; 125 unsigned int lor1, land1, gor1, gand1;
128 unsigned int lor2, land2, gor2, gand2; 126 unsigned int lor2, land2, gor2, gand2;
@@ -170,7 +168,7 @@ static __cpuinit void describe_cachepart_change(unsigned int thread,
170 * Ensures that coherency is enabled and that the threads share the same cache 168 * Ensures that coherency is enabled and that the threads share the same cache
171 * partitions. 169 * partitions.
172 */ 170 */
173static __cpuinit void setup_smp_cache(unsigned int thread) 171static void setup_smp_cache(unsigned int thread)
174{ 172{
175 unsigned int this_thread, lflags; 173 unsigned int this_thread, lflags;
176 unsigned int dcsz, dcpart_this, dcpart_old, dcpart_new; 174 unsigned int dcsz, dcpart_this, dcpart_old, dcpart_new;
@@ -215,7 +213,7 @@ static __cpuinit void setup_smp_cache(unsigned int thread)
215 icpart_old, icpart_new); 213 icpart_old, icpart_new);
216} 214}
217 215
218int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) 216int __cpu_up(unsigned int cpu, struct task_struct *idle)
219{ 217{
220 unsigned int thread = cpu_2_hwthread_id[cpu]; 218 unsigned int thread = cpu_2_hwthread_id[cpu];
221 int ret; 219 int ret;
@@ -268,7 +266,7 @@ static DECLARE_COMPLETION(cpu_killed);
268/* 266/*
269 * __cpu_disable runs on the processor to be shutdown. 267 * __cpu_disable runs on the processor to be shutdown.
270 */ 268 */
271int __cpuexit __cpu_disable(void) 269int __cpu_disable(void)
272{ 270{
273 unsigned int cpu = smp_processor_id(); 271 unsigned int cpu = smp_processor_id();
274 272
@@ -299,7 +297,7 @@ int __cpuexit __cpu_disable(void)
299 * called on the thread which is asking for a CPU to be shutdown - 297 * called on the thread which is asking for a CPU to be shutdown -
300 * waits until shutdown has completed, or it is timed out. 298 * waits until shutdown has completed, or it is timed out.
301 */ 299 */
302void __cpuexit __cpu_die(unsigned int cpu) 300void __cpu_die(unsigned int cpu)
303{ 301{
304 if (!wait_for_completion_timeout(&cpu_killed, msecs_to_jiffies(1))) 302 if (!wait_for_completion_timeout(&cpu_killed, msecs_to_jiffies(1)))
305 pr_err("CPU%u: unable to kill\n", cpu); 303 pr_err("CPU%u: unable to kill\n", cpu);
@@ -311,7 +309,7 @@ void __cpuexit __cpu_die(unsigned int cpu)
311 * Note that we do not return from this function. If this cpu is 309 * Note that we do not return from this function. If this cpu is
312 * brought online again it will need to run secondary_startup(). 310 * brought online again it will need to run secondary_startup().
313 */ 311 */
314void __cpuexit cpu_die(void) 312void cpu_die(void)
315{ 313{
316 local_irq_disable(); 314 local_irq_disable();
317 idle_task_exit(); 315 idle_task_exit();
@@ -326,7 +324,7 @@ void __cpuexit cpu_die(void)
326 * Called by both boot and secondaries to move global data into 324 * Called by both boot and secondaries to move global data into
327 * per-processor storage. 325 * per-processor storage.
328 */ 326 */
329void __cpuinit smp_store_cpu_info(unsigned int cpuid) 327void smp_store_cpu_info(unsigned int cpuid)
330{ 328{
331 struct cpuinfo_metag *cpu_info = &per_cpu(cpu_data, cpuid); 329 struct cpuinfo_metag *cpu_info = &per_cpu(cpu_data, cpuid);
332 330
diff --git a/arch/metag/kernel/traps.c b/arch/metag/kernel/traps.c
index c00ade0228ef..25f9d1c2ffec 100644
--- a/arch/metag/kernel/traps.c
+++ b/arch/metag/kernel/traps.c
@@ -812,7 +812,7 @@ static void set_trigger_mask(unsigned int mask)
812} 812}
813#endif 813#endif
814 814
815void __cpuinit per_cpu_trap_init(unsigned long cpu) 815void per_cpu_trap_init(unsigned long cpu)
816{ 816{
817 TBIRES int_context; 817 TBIRES int_context;
818 unsigned int thread = cpu_2_hwthread_id[cpu]; 818 unsigned int thread = cpu_2_hwthread_id[cpu];
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 4758a8fd3e99..c3abed332301 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1702,6 +1702,7 @@ endchoice
1702 1702
1703config KVM_GUEST 1703config KVM_GUEST
1704 bool "KVM Guest Kernel" 1704 bool "KVM Guest Kernel"
1705 depends on BROKEN_ON_SMP
1705 help 1706 help
1706 Select this option if building a guest kernel for KVM (Trap & Emulate) mode 1707 Select this option if building a guest kernel for KVM (Trap & Emulate) mode
1707 1708
diff --git a/arch/mips/ath79/setup.c b/arch/mips/ath79/setup.c
index 8be4e856b8b8..80f4ecd42b0d 100644
--- a/arch/mips/ath79/setup.c
+++ b/arch/mips/ath79/setup.c
@@ -182,7 +182,7 @@ const char *get_system_type(void)
182 return ath79_sys_type; 182 return ath79_sys_type;
183} 183}
184 184
185unsigned int __cpuinit get_c0_compare_int(void) 185unsigned int get_c0_compare_int(void)
186{ 186{
187 return CP0_LEGACY_COMPARE_IRQ; 187 return CP0_LEGACY_COMPARE_IRQ;
188} 188}
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index 7181def6037a..9d36774bded1 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -1095,7 +1095,7 @@ static void octeon_irq_ip3_ciu(void)
1095 1095
1096static bool octeon_irq_use_ip4; 1096static bool octeon_irq_use_ip4;
1097 1097
1098static void __cpuinit octeon_irq_local_enable_ip4(void *arg) 1098static void octeon_irq_local_enable_ip4(void *arg)
1099{ 1099{
1100 set_c0_status(STATUSF_IP4); 1100 set_c0_status(STATUSF_IP4);
1101} 1101}
@@ -1110,21 +1110,21 @@ static void (*octeon_irq_ip2)(void);
1110static void (*octeon_irq_ip3)(void); 1110static void (*octeon_irq_ip3)(void);
1111static void (*octeon_irq_ip4)(void); 1111static void (*octeon_irq_ip4)(void);
1112 1112
1113void __cpuinitdata (*octeon_irq_setup_secondary)(void); 1113void (*octeon_irq_setup_secondary)(void);
1114 1114
1115void __cpuinit octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t h) 1115void octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t h)
1116{ 1116{
1117 octeon_irq_ip4 = h; 1117 octeon_irq_ip4 = h;
1118 octeon_irq_use_ip4 = true; 1118 octeon_irq_use_ip4 = true;
1119 on_each_cpu(octeon_irq_local_enable_ip4, NULL, 1); 1119 on_each_cpu(octeon_irq_local_enable_ip4, NULL, 1);
1120} 1120}
1121 1121
1122static void __cpuinit octeon_irq_percpu_enable(void) 1122static void octeon_irq_percpu_enable(void)
1123{ 1123{
1124 irq_cpu_online(); 1124 irq_cpu_online();
1125} 1125}
1126 1126
1127static void __cpuinit octeon_irq_init_ciu_percpu(void) 1127static void octeon_irq_init_ciu_percpu(void)
1128{ 1128{
1129 int coreid = cvmx_get_core_num(); 1129 int coreid = cvmx_get_core_num();
1130 1130
@@ -1167,7 +1167,7 @@ static void octeon_irq_init_ciu2_percpu(void)
1167 cvmx_read_csr(CVMX_CIU2_SUM_PPX_IP2(coreid)); 1167 cvmx_read_csr(CVMX_CIU2_SUM_PPX_IP2(coreid));
1168} 1168}
1169 1169
1170static void __cpuinit octeon_irq_setup_secondary_ciu(void) 1170static void octeon_irq_setup_secondary_ciu(void)
1171{ 1171{
1172 octeon_irq_init_ciu_percpu(); 1172 octeon_irq_init_ciu_percpu();
1173 octeon_irq_percpu_enable(); 1173 octeon_irq_percpu_enable();
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index 7b746e7bf7a1..1830874ff1e2 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -334,9 +334,10 @@ static void __init octeon_fdt_pip_iface(int pip, int idx, u64 *pmac)
334 char name_buffer[20]; 334 char name_buffer[20];
335 int iface; 335 int iface;
336 int p; 336 int p;
337 int count; 337 int count = 0;
338 338
339 count = cvmx_helper_interface_enumerate(idx); 339 if (cvmx_helper_interface_enumerate(idx) == 0)
340 count = cvmx_helper_ports_on_interface(idx);
340 341
341 snprintf(name_buffer, sizeof(name_buffer), "interface@%d", idx); 342 snprintf(name_buffer, sizeof(name_buffer), "interface@%d", idx);
342 iface = fdt_subnode_offset(initial_boot_params, pip, name_buffer); 343 iface = fdt_subnode_offset(initial_boot_params, pip, name_buffer);
diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
index 295137dfdc37..138cc80c5928 100644
--- a/arch/mips/cavium-octeon/smp.c
+++ b/arch/mips/cavium-octeon/smp.c
@@ -173,7 +173,7 @@ static void octeon_boot_secondary(int cpu, struct task_struct *idle)
173 * After we've done initial boot, this function is called to allow the 173 * After we've done initial boot, this function is called to allow the
174 * board code to clean up state, if needed 174 * board code to clean up state, if needed
175 */ 175 */
176static void __cpuinit octeon_init_secondary(void) 176static void octeon_init_secondary(void)
177{ 177{
178 unsigned int sr; 178 unsigned int sr;
179 179
@@ -375,7 +375,7 @@ static int octeon_update_boot_vector(unsigned int cpu)
375 return 0; 375 return 0;
376} 376}
377 377
378static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb, 378static int octeon_cpu_callback(struct notifier_block *nfb,
379 unsigned long action, void *hcpu) 379 unsigned long action, void *hcpu)
380{ 380{
381 unsigned int cpu = (unsigned long)hcpu; 381 unsigned int cpu = (unsigned long)hcpu;
@@ -394,7 +394,7 @@ static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb,
394 return NOTIFY_OK; 394 return NOTIFY_OK;
395} 395}
396 396
397static int __cpuinit register_cavium_notifier(void) 397static int register_cavium_notifier(void)
398{ 398{
399 hotcpu_notifier(octeon_cpu_callback, 0); 399 hotcpu_notifier(octeon_cpu_callback, 0);
400 return 0; 400 return 0;
diff --git a/arch/mips/include/asm/uasm.h b/arch/mips/include/asm/uasm.h
index 370d967725c2..c33a9564fb41 100644
--- a/arch/mips/include/asm/uasm.h
+++ b/arch/mips/include/asm/uasm.h
@@ -13,12 +13,8 @@
13 13
14#ifdef CONFIG_EXPORT_UASM 14#ifdef CONFIG_EXPORT_UASM
15#include <linux/export.h> 15#include <linux/export.h>
16#define __uasminit
17#define __uasminitdata
18#define UASM_EXPORT_SYMBOL(sym) EXPORT_SYMBOL(sym) 16#define UASM_EXPORT_SYMBOL(sym) EXPORT_SYMBOL(sym)
19#else 17#else
20#define __uasminit __cpuinit
21#define __uasminitdata __cpuinitdata
22#define UASM_EXPORT_SYMBOL(sym) 18#define UASM_EXPORT_SYMBOL(sym)
23#endif 19#endif
24 20
@@ -54,43 +50,36 @@
54#endif 50#endif
55 51
56#define Ip_u1u2u3(op) \ 52#define Ip_u1u2u3(op) \
57void __uasminit \ 53void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
58ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
59 54
60#define Ip_u2u1u3(op) \ 55#define Ip_u2u1u3(op) \
61void __uasminit \ 56void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
62ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
63 57
64#define Ip_u3u1u2(op) \ 58#define Ip_u3u1u2(op) \
65void __uasminit \ 59void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
66ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
67 60
68#define Ip_u1u2s3(op) \ 61#define Ip_u1u2s3(op) \
69void __uasminit \ 62void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
70ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
71 63
72#define Ip_u2s3u1(op) \ 64#define Ip_u2s3u1(op) \
73void __uasminit \ 65void ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c)
74ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c)
75 66
76#define Ip_u2u1s3(op) \ 67#define Ip_u2u1s3(op) \
77void __uasminit \ 68void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
78ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
79 69
80#define Ip_u2u1msbu3(op) \ 70#define Ip_u2u1msbu3(op) \
81void __uasminit \ 71void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \
82ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \
83 unsigned int d) 72 unsigned int d)
84 73
85#define Ip_u1u2(op) \ 74#define Ip_u1u2(op) \
86void __uasminit ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b) 75void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b)
87 76
88#define Ip_u1s2(op) \ 77#define Ip_u1s2(op) \
89void __uasminit ISAOPC(op)(u32 **buf, unsigned int a, signed int b) 78void ISAOPC(op)(u32 **buf, unsigned int a, signed int b)
90 79
91#define Ip_u1(op) void __uasminit ISAOPC(op)(u32 **buf, unsigned int a) 80#define Ip_u1(op) void ISAOPC(op)(u32 **buf, unsigned int a)
92 81
93#define Ip_0(op) void __uasminit ISAOPC(op)(u32 **buf) 82#define Ip_0(op) void ISAOPC(op)(u32 **buf)
94 83
95Ip_u2u1s3(_addiu); 84Ip_u2u1s3(_addiu);
96Ip_u3u1u2(_addu); 85Ip_u3u1u2(_addu);
@@ -163,7 +152,7 @@ struct uasm_label {
163 int lab; 152 int lab;
164}; 153};
165 154
166void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, 155void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr,
167 int lid); 156 int lid);
168#ifdef CONFIG_64BIT 157#ifdef CONFIG_64BIT
169int ISAFUNC(uasm_in_compat_space_p)(long addr); 158int 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);
174void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr); 163void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr);
175 164
176#define UASM_L_LA(lb) \ 165#define UASM_L_LA(lb) \
177static inline void __uasminit ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \ 166static inline void ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \
178{ \ 167{ \
179 ISAFUNC(uasm_build_label)(lab, addr, label##lb); \ 168 ISAFUNC(uasm_build_label)(lab, addr, label##lb); \
180} 169}
diff --git a/arch/mips/kernel/bmips_vec.S b/arch/mips/kernel/bmips_vec.S
index 64c4fd62cf08..f739aedcb509 100644
--- a/arch/mips/kernel/bmips_vec.S
+++ b/arch/mips/kernel/bmips_vec.S
@@ -28,8 +28,6 @@
28 .set mips0 28 .set mips0
29 .endm 29 .endm
30 30
31 __CPUINIT
32
33/*********************************************************************** 31/***********************************************************************
34 * Alternate CPU1 startup vector for BMIPS4350 32 * Alternate CPU1 startup vector for BMIPS4350
35 * 33 *
@@ -216,8 +214,6 @@ END(bmips_smp_int_vec)
216 * Certain CPUs support extending kseg0 to 1024MB. 214 * Certain CPUs support extending kseg0 to 1024MB.
217 ***********************************************************************/ 215 ***********************************************************************/
218 216
219 __CPUINIT
220
221LEAF(bmips_enable_xks01) 217LEAF(bmips_enable_xks01)
222 218
223#if defined(CONFIG_XKS01) 219#if defined(CONFIG_XKS01)
diff --git a/arch/mips/kernel/cevt-bcm1480.c b/arch/mips/kernel/cevt-bcm1480.c
index 15f618b40cf6..7976457184b1 100644
--- a/arch/mips/kernel/cevt-bcm1480.c
+++ b/arch/mips/kernel/cevt-bcm1480.c
@@ -109,7 +109,7 @@ static DEFINE_PER_CPU(struct clock_event_device, sibyte_hpt_clockevent);
109static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction); 109static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction);
110static DEFINE_PER_CPU(char [18], sibyte_hpt_name); 110static DEFINE_PER_CPU(char [18], sibyte_hpt_name);
111 111
112void __cpuinit sb1480_clockevent_init(void) 112void sb1480_clockevent_init(void)
113{ 113{
114 unsigned int cpu = smp_processor_id(); 114 unsigned int cpu = smp_processor_id();
115 unsigned int irq = K_BCM1480_INT_TIMER_0 + cpu; 115 unsigned int irq = K_BCM1480_INT_TIMER_0 + cpu;
diff --git a/arch/mips/kernel/cevt-gic.c b/arch/mips/kernel/cevt-gic.c
index 730eaf92c018..594cbbf16d62 100644
--- a/arch/mips/kernel/cevt-gic.c
+++ b/arch/mips/kernel/cevt-gic.c
@@ -59,7 +59,7 @@ void gic_event_handler(struct clock_event_device *dev)
59{ 59{
60} 60}
61 61
62int __cpuinit gic_clockevent_init(void) 62int gic_clockevent_init(void)
63{ 63{
64 unsigned int cpu = smp_processor_id(); 64 unsigned int cpu = smp_processor_id();
65 struct clock_event_device *cd; 65 struct clock_event_device *cd;
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 02033eaf8825..50d3f5a8d6bb 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -171,7 +171,7 @@ int c0_compare_int_usable(void)
171} 171}
172 172
173#ifndef CONFIG_MIPS_MT_SMTC 173#ifndef CONFIG_MIPS_MT_SMTC
174int __cpuinit r4k_clockevent_init(void) 174int r4k_clockevent_init(void)
175{ 175{
176 unsigned int cpu = smp_processor_id(); 176 unsigned int cpu = smp_processor_id();
177 struct clock_event_device *cd; 177 struct clock_event_device *cd;
diff --git a/arch/mips/kernel/cevt-sb1250.c b/arch/mips/kernel/cevt-sb1250.c
index 200f2778bf36..5ea6d6b1de15 100644
--- a/arch/mips/kernel/cevt-sb1250.c
+++ b/arch/mips/kernel/cevt-sb1250.c
@@ -107,7 +107,7 @@ static DEFINE_PER_CPU(struct clock_event_device, sibyte_hpt_clockevent);
107static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction); 107static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction);
108static DEFINE_PER_CPU(char [18], sibyte_hpt_name); 108static DEFINE_PER_CPU(char [18], sibyte_hpt_name);
109 109
110void __cpuinit sb1250_clockevent_init(void) 110void sb1250_clockevent_init(void)
111{ 111{
112 unsigned int cpu = smp_processor_id(); 112 unsigned int cpu = smp_processor_id();
113 unsigned int irq = K_INT_TIMER_0 + cpu; 113 unsigned int irq = K_INT_TIMER_0 + cpu;
diff --git a/arch/mips/kernel/cevt-smtc.c b/arch/mips/kernel/cevt-smtc.c
index 9de5ed7ef1a3..b6cf0a60d896 100644
--- a/arch/mips/kernel/cevt-smtc.c
+++ b/arch/mips/kernel/cevt-smtc.c
@@ -248,7 +248,7 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
248} 248}
249 249
250 250
251int __cpuinit smtc_clockevent_init(void) 251int smtc_clockevent_init(void)
252{ 252{
253 uint64_t mips_freq = mips_hpt_frequency; 253 uint64_t mips_freq = mips_hpt_frequency;
254 unsigned int cpu = smp_processor_id(); 254 unsigned int cpu = smp_processor_id();
diff --git a/arch/mips/kernel/cpu-bugs64.c b/arch/mips/kernel/cpu-bugs64.c
index 0c61df281ce6..2d80b5f1aeae 100644
--- a/arch/mips/kernel/cpu-bugs64.c
+++ b/arch/mips/kernel/cpu-bugs64.c
@@ -168,7 +168,7 @@ static inline void check_mult_sh(void)
168 panic(bug64hit, !R4000_WAR ? r4kwar : nowar); 168 panic(bug64hit, !R4000_WAR ? r4kwar : nowar);
169} 169}
170 170
171static volatile int daddi_ov __cpuinitdata; 171static volatile int daddi_ov;
172 172
173asmlinkage void __init do_daddi_ov(struct pt_regs *regs) 173asmlinkage void __init do_daddi_ov(struct pt_regs *regs)
174{ 174{
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index c7b1b3c5a761..4c6167a17875 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -27,7 +27,7 @@
27#include <asm/spram.h> 27#include <asm/spram.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29 29
30static int __cpuinitdata mips_fpu_disabled; 30static int mips_fpu_disabled;
31 31
32static int __init fpu_disable(char *s) 32static int __init fpu_disable(char *s)
33{ 33{
@@ -39,7 +39,7 @@ static int __init fpu_disable(char *s)
39 39
40__setup("nofpu", fpu_disable); 40__setup("nofpu", fpu_disable);
41 41
42int __cpuinitdata mips_dsp_disabled; 42int mips_dsp_disabled;
43 43
44static int __init dsp_disable(char *s) 44static int __init dsp_disable(char *s)
45{ 45{
@@ -134,7 +134,7 @@ static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
134#endif 134#endif
135} 135}
136 136
137static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa) 137static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
138{ 138{
139 switch (isa) { 139 switch (isa) {
140 case MIPS_CPU_ISA_M64R2: 140 case MIPS_CPU_ISA_M64R2:
@@ -159,7 +159,7 @@ static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa)
159 } 159 }
160} 160}
161 161
162static char unknown_isa[] __cpuinitdata = KERN_ERR \ 162static char unknown_isa[] = KERN_ERR \
163 "Unsupported ISA type, c0.config0: %d."; 163 "Unsupported ISA type, c0.config0: %d.";
164 164
165static inline unsigned int decode_config0(struct cpuinfo_mips *c) 165static inline unsigned int decode_config0(struct cpuinfo_mips *c)
@@ -290,7 +290,7 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c)
290 return config4 & MIPS_CONF_M; 290 return config4 & MIPS_CONF_M;
291} 291}
292 292
293static void __cpuinit decode_configs(struct cpuinfo_mips *c) 293static void decode_configs(struct cpuinfo_mips *c)
294{ 294{
295 int ok; 295 int ok;
296 296
@@ -962,7 +962,7 @@ EXPORT_SYMBOL(__ua_limit);
962const char *__cpu_name[NR_CPUS]; 962const char *__cpu_name[NR_CPUS];
963const char *__elf_platform; 963const char *__elf_platform;
964 964
965__cpuinit void cpu_probe(void) 965void cpu_probe(void)
966{ 966{
967 struct cpuinfo_mips *c = &current_cpu_data; 967 struct cpuinfo_mips *c = &current_cpu_data;
968 unsigned int cpu = smp_processor_id(); 968 unsigned int cpu = smp_processor_id();
@@ -1047,7 +1047,7 @@ __cpuinit void cpu_probe(void)
1047#endif 1047#endif
1048} 1048}
1049 1049
1050__cpuinit void cpu_report(void) 1050void cpu_report(void)
1051{ 1051{
1052 struct cpuinfo_mips *c = &current_cpu_data; 1052 struct cpuinfo_mips *c = &current_cpu_data;
1053 1053
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 099912324423..7b6a5b3e3acf 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -158,8 +158,6 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
158 j start_kernel 158 j start_kernel
159 END(kernel_entry) 159 END(kernel_entry)
160 160
161 __CPUINIT
162
163#ifdef CONFIG_SMP 161#ifdef CONFIG_SMP
164/* 162/*
165 * SMP slave cpus entry point. Board specific code for bootstrap calls this 163 * SMP slave cpus entry point. Board specific code for bootstrap calls this
@@ -188,5 +186,3 @@ NESTED(smp_bootstrap, 16, sp)
188 j start_secondary 186 j start_secondary
189 END(smp_bootstrap) 187 END(smp_bootstrap)
190#endif /* CONFIG_SMP */ 188#endif /* CONFIG_SMP */
191
192 __FINIT
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index aea6c0885838..c0bb4d59076a 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -173,7 +173,7 @@ static void bmips_boot_secondary(int cpu, struct task_struct *idle)
173 else { 173 else {
174#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) 174#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
175 /* Reset slave TP1 if booting from TP0 */ 175 /* Reset slave TP1 if booting from TP0 */
176 if (cpu_logical_map(cpu) == 0) 176 if (cpu_logical_map(cpu) == 1)
177 set_c0_brcm_cmt_ctrl(0x01); 177 set_c0_brcm_cmt_ctrl(0x01);
178#elif defined(CONFIG_CPU_BMIPS5000) 178#elif defined(CONFIG_CPU_BMIPS5000)
179 if (cpu & 0x01) 179 if (cpu & 0x01)
@@ -398,7 +398,7 @@ struct plat_smp_ops bmips_smp_ops = {
398 * UP BMIPS systems as well. 398 * UP BMIPS systems as well.
399 ***********************************************************************/ 399 ***********************************************************************/
400 400
401static void __cpuinit bmips_wr_vec(unsigned long dst, char *start, char *end) 401static void bmips_wr_vec(unsigned long dst, char *start, char *end)
402{ 402{
403 memcpy((void *)dst, start, end - start); 403 memcpy((void *)dst, start, end - start);
404 dma_cache_wback((unsigned long)start, end - start); 404 dma_cache_wback((unsigned long)start, end - start);
@@ -406,7 +406,7 @@ static void __cpuinit bmips_wr_vec(unsigned long dst, char *start, char *end)
406 instruction_hazard(); 406 instruction_hazard();
407} 407}
408 408
409static inline void __cpuinit bmips_nmi_handler_setup(void) 409static inline void bmips_nmi_handler_setup(void)
410{ 410{
411 bmips_wr_vec(BMIPS_NMI_RESET_VEC, &bmips_reset_nmi_vec, 411 bmips_wr_vec(BMIPS_NMI_RESET_VEC, &bmips_reset_nmi_vec,
412 &bmips_reset_nmi_vec_end); 412 &bmips_reset_nmi_vec_end);
@@ -414,7 +414,7 @@ static inline void __cpuinit bmips_nmi_handler_setup(void)
414 &bmips_smp_int_vec_end); 414 &bmips_smp_int_vec_end);
415} 415}
416 416
417void __cpuinit bmips_ebase_setup(void) 417void bmips_ebase_setup(void)
418{ 418{
419 unsigned long new_ebase = ebase; 419 unsigned long new_ebase = ebase;
420 void __iomem __maybe_unused *cbr; 420 void __iomem __maybe_unused *cbr;
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 3e5164c11cac..57a3f7a2b370 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -149,7 +149,7 @@ static void vsmp_send_ipi_mask(const struct cpumask *mask, unsigned int action)
149 vsmp_send_ipi_single(i, action); 149 vsmp_send_ipi_single(i, action);
150} 150}
151 151
152static void __cpuinit vsmp_init_secondary(void) 152static void vsmp_init_secondary(void)
153{ 153{
154#ifdef CONFIG_IRQ_GIC 154#ifdef CONFIG_IRQ_GIC
155 /* This is Malta specific: IPI,performance and timer interrupts */ 155 /* This is Malta specific: IPI,performance and timer interrupts */
@@ -162,7 +162,7 @@ static void __cpuinit vsmp_init_secondary(void)
162 STATUSF_IP6 | STATUSF_IP7); 162 STATUSF_IP6 | STATUSF_IP7);
163} 163}
164 164
165static void __cpuinit vsmp_smp_finish(void) 165static void vsmp_smp_finish(void)
166{ 166{
167 /* CDFIXME: remove this? */ 167 /* CDFIXME: remove this? */
168 write_c0_compare(read_c0_count() + (8* mips_hpt_frequency/HZ)); 168 write_c0_compare(read_c0_count() + (8* mips_hpt_frequency/HZ));
@@ -188,7 +188,7 @@ static void vsmp_cpus_done(void)
188 * (unsigned long)idle->thread_info the gp 188 * (unsigned long)idle->thread_info the gp
189 * assumes a 1:1 mapping of TC => VPE 189 * assumes a 1:1 mapping of TC => VPE
190 */ 190 */
191static void __cpuinit vsmp_boot_secondary(int cpu, struct task_struct *idle) 191static void vsmp_boot_secondary(int cpu, struct task_struct *idle)
192{ 192{
193 struct thread_info *gp = task_thread_info(idle); 193 struct thread_info *gp = task_thread_info(idle);
194 dvpe(); 194 dvpe();
diff --git a/arch/mips/kernel/smp-up.c b/arch/mips/kernel/smp-up.c
index 00500fea2750..7fde3e4d978f 100644
--- a/arch/mips/kernel/smp-up.c
+++ b/arch/mips/kernel/smp-up.c
@@ -28,11 +28,11 @@ static inline void up_send_ipi_mask(const struct cpumask *mask,
28 * After we've done initial boot, this function is called to allow the 28 * After we've done initial boot, this function is called to allow the
29 * board code to clean up state, if needed 29 * board code to clean up state, if needed
30 */ 30 */
31static void __cpuinit up_init_secondary(void) 31static void up_init_secondary(void)
32{ 32{
33} 33}
34 34
35static void __cpuinit up_smp_finish(void) 35static void up_smp_finish(void)
36{ 36{
37} 37}
38 38
@@ -44,7 +44,7 @@ static void up_cpus_done(void)
44/* 44/*
45 * Firmware CPU startup hook 45 * Firmware CPU startup hook
46 */ 46 */
47static void __cpuinit up_boot_secondary(int cpu, struct task_struct *idle) 47static void up_boot_secondary(int cpu, struct task_struct *idle)
48{ 48{
49} 49}
50 50
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 6e7862ab46cc..5c208ed8f856 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -86,7 +86,7 @@ static inline void set_cpu_sibling_map(int cpu)
86struct plat_smp_ops *mp_ops; 86struct plat_smp_ops *mp_ops;
87EXPORT_SYMBOL(mp_ops); 87EXPORT_SYMBOL(mp_ops);
88 88
89__cpuinit void register_smp_ops(struct plat_smp_ops *ops) 89void register_smp_ops(struct plat_smp_ops *ops)
90{ 90{
91 if (mp_ops) 91 if (mp_ops)
92 printk(KERN_WARNING "Overriding previously set SMP ops\n"); 92 printk(KERN_WARNING "Overriding previously set SMP ops\n");
@@ -98,7 +98,7 @@ __cpuinit void register_smp_ops(struct plat_smp_ops *ops)
98 * First C code run on the secondary CPUs after being started up by 98 * First C code run on the secondary CPUs after being started up by
99 * the master. 99 * the master.
100 */ 100 */
101asmlinkage __cpuinit void start_secondary(void) 101asmlinkage void start_secondary(void)
102{ 102{
103 unsigned int cpu; 103 unsigned int cpu;
104 104
@@ -197,7 +197,7 @@ void smp_prepare_boot_cpu(void)
197 cpu_set(0, cpu_callin_map); 197 cpu_set(0, cpu_callin_map);
198} 198}
199 199
200int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 200int __cpu_up(unsigned int cpu, struct task_struct *tidle)
201{ 201{
202 mp_ops->boot_secondary(cpu, tidle); 202 mp_ops->boot_secondary(cpu, tidle);
203 203
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 75a4fd709841..dfc1b911be04 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -645,7 +645,7 @@ void smtc_prepare_cpus(int cpus)
645 * (unsigned long)idle->thread_info the gp 645 * (unsigned long)idle->thread_info the gp
646 * 646 *
647 */ 647 */
648void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle) 648void smtc_boot_secondary(int cpu, struct task_struct *idle)
649{ 649{
650 extern u32 kernelsp[NR_CPUS]; 650 extern u32 kernelsp[NR_CPUS];
651 unsigned long flags; 651 unsigned long flags;
diff --git a/arch/mips/kernel/spram.c b/arch/mips/kernel/spram.c
index 6af08d896e20..93f86817f20a 100644
--- a/arch/mips/kernel/spram.c
+++ b/arch/mips/kernel/spram.c
@@ -37,7 +37,7 @@
37/* 37/*
38 * Different semantics to the set_c0_* function built by __BUILD_SET_C0 38 * Different semantics to the set_c0_* function built by __BUILD_SET_C0
39 */ 39 */
40static __cpuinit unsigned int bis_c0_errctl(unsigned int set) 40static unsigned int bis_c0_errctl(unsigned int set)
41{ 41{
42 unsigned int res; 42 unsigned int res;
43 res = read_c0_errctl(); 43 res = read_c0_errctl();
@@ -45,7 +45,7 @@ static __cpuinit unsigned int bis_c0_errctl(unsigned int set)
45 return res; 45 return res;
46} 46}
47 47
48static __cpuinit void ispram_store_tag(unsigned int offset, unsigned int data) 48static void ispram_store_tag(unsigned int offset, unsigned int data)
49{ 49{
50 unsigned int errctl; 50 unsigned int errctl;
51 51
@@ -64,7 +64,7 @@ static __cpuinit void ispram_store_tag(unsigned int offset, unsigned int data)
64} 64}
65 65
66 66
67static __cpuinit unsigned int ispram_load_tag(unsigned int offset) 67static unsigned int ispram_load_tag(unsigned int offset)
68{ 68{
69 unsigned int data; 69 unsigned int data;
70 unsigned int errctl; 70 unsigned int errctl;
@@ -82,7 +82,7 @@ static __cpuinit unsigned int ispram_load_tag(unsigned int offset)
82 return data; 82 return data;
83} 83}
84 84
85static __cpuinit void dspram_store_tag(unsigned int offset, unsigned int data) 85static void dspram_store_tag(unsigned int offset, unsigned int data)
86{ 86{
87 unsigned int errctl; 87 unsigned int errctl;
88 88
@@ -98,7 +98,7 @@ static __cpuinit void dspram_store_tag(unsigned int offset, unsigned int data)
98} 98}
99 99
100 100
101static __cpuinit unsigned int dspram_load_tag(unsigned int offset) 101static unsigned int dspram_load_tag(unsigned int offset)
102{ 102{
103 unsigned int data; 103 unsigned int data;
104 unsigned int errctl; 104 unsigned int errctl;
@@ -115,7 +115,7 @@ static __cpuinit unsigned int dspram_load_tag(unsigned int offset)
115 return data; 115 return data;
116} 116}
117 117
118static __cpuinit void probe_spram(char *type, 118static void probe_spram(char *type,
119 unsigned int base, 119 unsigned int base,
120 unsigned int (*read)(unsigned int), 120 unsigned int (*read)(unsigned int),
121 void (*write)(unsigned int, unsigned int)) 121 void (*write)(unsigned int, unsigned int))
@@ -196,7 +196,7 @@ static __cpuinit void probe_spram(char *type,
196 offset += 2 * SPRAM_TAG_STRIDE; 196 offset += 2 * SPRAM_TAG_STRIDE;
197 } 197 }
198} 198}
199void __cpuinit spram_config(void) 199void spram_config(void)
200{ 200{
201 struct cpuinfo_mips *c = &current_cpu_data; 201 struct cpuinfo_mips *c = &current_cpu_data;
202 unsigned int config0; 202 unsigned int config0;
diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
index 1ff43d5ac2c4..84536bf4a154 100644
--- a/arch/mips/kernel/sync-r4k.c
+++ b/arch/mips/kernel/sync-r4k.c
@@ -20,15 +20,15 @@
20#include <asm/barrier.h> 20#include <asm/barrier.h>
21#include <asm/mipsregs.h> 21#include <asm/mipsregs.h>
22 22
23static atomic_t __cpuinitdata count_start_flag = ATOMIC_INIT(0); 23static atomic_t count_start_flag = ATOMIC_INIT(0);
24static atomic_t __cpuinitdata count_count_start = ATOMIC_INIT(0); 24static atomic_t count_count_start = ATOMIC_INIT(0);
25static atomic_t __cpuinitdata count_count_stop = ATOMIC_INIT(0); 25static atomic_t count_count_stop = ATOMIC_INIT(0);
26static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0); 26static atomic_t count_reference = ATOMIC_INIT(0);
27 27
28#define COUNTON 100 28#define COUNTON 100
29#define NR_LOOPS 5 29#define NR_LOOPS 5
30 30
31void __cpuinit synchronise_count_master(int cpu) 31void synchronise_count_master(int cpu)
32{ 32{
33 int i; 33 int i;
34 unsigned long flags; 34 unsigned long flags;
@@ -106,7 +106,7 @@ void __cpuinit synchronise_count_master(int cpu)
106 printk("done.\n"); 106 printk("done.\n");
107} 107}
108 108
109void __cpuinit synchronise_count_slave(int cpu) 109void synchronise_count_slave(int cpu)
110{ 110{
111 int i; 111 int i;
112 unsigned int initcount; 112 unsigned int initcount;
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 0903d70b2cfe..aec3408edd4b 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -90,7 +90,7 @@ void (*board_nmi_handler_setup)(void);
90void (*board_ejtag_handler_setup)(void); 90void (*board_ejtag_handler_setup)(void);
91void (*board_bind_eic_interrupt)(int irq, int regset); 91void (*board_bind_eic_interrupt)(int irq, int regset);
92void (*board_ebase_setup)(void); 92void (*board_ebase_setup)(void);
93void __cpuinitdata(*board_cache_error_setup)(void); 93void(*board_cache_error_setup)(void);
94 94
95static void show_raw_backtrace(unsigned long reg29) 95static void show_raw_backtrace(unsigned long reg29)
96{ 96{
@@ -1242,7 +1242,6 @@ asmlinkage void do_mcheck(struct pt_regs *regs)
1242 panic("Caught Machine Check exception - %scaused by multiple " 1242 panic("Caught Machine Check exception - %scaused by multiple "
1243 "matching entries in the TLB.", 1243 "matching entries in the TLB.",
1244 (multi_match) ? "" : "not "); 1244 (multi_match) ? "" : "not ");
1245 exception_exit(prev_state);
1246} 1245}
1247 1246
1248asmlinkage void do_mt(struct pt_regs *regs) 1247asmlinkage void do_mt(struct pt_regs *regs)
@@ -1682,7 +1681,7 @@ int cp0_compare_irq_shift;
1682int cp0_perfcount_irq; 1681int cp0_perfcount_irq;
1683EXPORT_SYMBOL_GPL(cp0_perfcount_irq); 1682EXPORT_SYMBOL_GPL(cp0_perfcount_irq);
1684 1683
1685static int __cpuinitdata noulri; 1684static int noulri;
1686 1685
1687static int __init ulri_disable(char *s) 1686static int __init ulri_disable(char *s)
1688{ 1687{
@@ -1693,7 +1692,7 @@ static int __init ulri_disable(char *s)
1693} 1692}
1694__setup("noulri", ulri_disable); 1693__setup("noulri", ulri_disable);
1695 1694
1696void __cpuinit per_cpu_trap_init(bool is_boot_cpu) 1695void per_cpu_trap_init(bool is_boot_cpu)
1697{ 1696{
1698 unsigned int cpu = smp_processor_id(); 1697 unsigned int cpu = smp_processor_id();
1699 unsigned int status_set = ST0_CU0; 1698 unsigned int status_set = ST0_CU0;
@@ -1810,7 +1809,7 @@ void __cpuinit per_cpu_trap_init(bool is_boot_cpu)
1810} 1809}
1811 1810
1812/* Install CPU exception handler */ 1811/* Install CPU exception handler */
1813void __cpuinit set_handler(unsigned long offset, void *addr, unsigned long size) 1812void set_handler(unsigned long offset, void *addr, unsigned long size)
1814{ 1813{
1815#ifdef CONFIG_CPU_MICROMIPS 1814#ifdef CONFIG_CPU_MICROMIPS
1816 memcpy((void *)(ebase + offset), ((unsigned char *)addr - 1), size); 1815 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)
1820 local_flush_icache_range(ebase + offset, ebase + offset + size); 1819 local_flush_icache_range(ebase + offset, ebase + offset + size);
1821} 1820}
1822 1821
1823static char panic_null_cerr[] __cpuinitdata = 1822static char panic_null_cerr[] =
1824 "Trying to set NULL cache error exception handler"; 1823 "Trying to set NULL cache error exception handler";
1825 1824
1826/* 1825/*
@@ -1828,7 +1827,7 @@ static char panic_null_cerr[] __cpuinitdata =
1828 * This is suitable only for the cache error exception which is the only 1827 * This is suitable only for the cache error exception which is the only
1829 * exception handler that is being run uncached. 1828 * exception handler that is being run uncached.
1830 */ 1829 */
1831void __cpuinit set_uncached_handler(unsigned long offset, void *addr, 1830void set_uncached_handler(unsigned long offset, void *addr,
1832 unsigned long size) 1831 unsigned long size)
1833{ 1832{
1834 unsigned long uncached_ebase = CKSEG1ADDR(ebase); 1833 unsigned long uncached_ebase = CKSEG1ADDR(ebase);
diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c
index cbdc4de85bb4..2a03abb5bd2c 100644
--- a/arch/mips/kernel/watch.c
+++ b/arch/mips/kernel/watch.c
@@ -100,7 +100,7 @@ void mips_clear_watch_registers(void)
100 } 100 }
101} 101}
102 102
103__cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) 103void mips_probe_watch_registers(struct cpuinfo_mips *c)
104{ 104{
105 unsigned int t; 105 unsigned int t;
106 106
diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig
index 2c15590e55f7..30e334e823bd 100644
--- a/arch/mips/kvm/Kconfig
+++ b/arch/mips/kvm/Kconfig
@@ -5,7 +5,6 @@ source "virt/kvm/Kconfig"
5 5
6menuconfig VIRTUALIZATION 6menuconfig VIRTUALIZATION
7 bool "Virtualization" 7 bool "Virtualization"
8 depends on HAVE_KVM
9 ---help--- 8 ---help---
10 Say Y here to get to see options for using your Linux host to run 9 Say Y here to get to see options for using your Linux host to run
11 other operating systems inside virtual machines (guests). 10 other operating systems inside virtual machines (guests).
diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index 51194875f158..eb3e18659630 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -461,7 +461,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
461 return 0; 461 return 0;
462} 462}
463 463
464unsigned int __cpuinit get_c0_compare_int(void) 464unsigned int get_c0_compare_int(void)
465{ 465{
466 return MIPS_CPU_TIMER_IRQ; 466 return MIPS_CPU_TIMER_IRQ;
467} 467}
diff --git a/arch/mips/lib/uncached.c b/arch/mips/lib/uncached.c
index 65e3dfc4e585..d8522f8e842a 100644
--- a/arch/mips/lib/uncached.c
+++ b/arch/mips/lib/uncached.c
@@ -36,7 +36,7 @@
36 * values, so we can avoid sharing the same stack area between a cached 36 * values, so we can avoid sharing the same stack area between a cached
37 * and the uncached mode. 37 * and the uncached mode.
38 */ 38 */
39unsigned long __cpuinit run_uncached(void *func) 39unsigned long run_uncached(void *func)
40{ 40{
41 register long sp __asm__("$sp"); 41 register long sp __asm__("$sp");
42 register long ret __asm__("$2"); 42 register long ret __asm__("$2");
diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c
index 8557fb552863..a0bcdbb81d41 100644
--- a/arch/mips/mm/c-octeon.c
+++ b/arch/mips/mm/c-octeon.c
@@ -180,7 +180,7 @@ static void octeon_flush_kernel_vmap_range(unsigned long vaddr, int size)
180 * Probe Octeon's caches 180 * Probe Octeon's caches
181 * 181 *
182 */ 182 */
183static void __cpuinit probe_octeon(void) 183static void probe_octeon(void)
184{ 184{
185 unsigned long icache_size; 185 unsigned long icache_size;
186 unsigned long dcache_size; 186 unsigned long dcache_size;
@@ -251,7 +251,7 @@ static void __cpuinit probe_octeon(void)
251 } 251 }
252} 252}
253 253
254static void __cpuinit octeon_cache_error_setup(void) 254static void octeon_cache_error_setup(void)
255{ 255{
256 extern char except_vec2_octeon; 256 extern char except_vec2_octeon;
257 set_handler(0x100, &except_vec2_octeon, 0x80); 257 set_handler(0x100, &except_vec2_octeon, 0x80);
@@ -261,7 +261,7 @@ static void __cpuinit octeon_cache_error_setup(void)
261 * Setup the Octeon cache flush routines 261 * Setup the Octeon cache flush routines
262 * 262 *
263 */ 263 */
264void __cpuinit octeon_cache_init(void) 264void octeon_cache_init(void)
265{ 265{
266 probe_octeon(); 266 probe_octeon();
267 267
diff --git a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c
index 704dc735a59d..2fcde0c8ea02 100644
--- a/arch/mips/mm/c-r3k.c
+++ b/arch/mips/mm/c-r3k.c
@@ -26,7 +26,7 @@
26static unsigned long icache_size, dcache_size; /* Size in bytes */ 26static unsigned long icache_size, dcache_size; /* Size in bytes */
27static unsigned long icache_lsize, dcache_lsize; /* Size in bytes */ 27static unsigned long icache_lsize, dcache_lsize; /* Size in bytes */
28 28
29unsigned long __cpuinit r3k_cache_size(unsigned long ca_flags) 29unsigned long r3k_cache_size(unsigned long ca_flags)
30{ 30{
31 unsigned long flags, status, dummy, size; 31 unsigned long flags, status, dummy, size;
32 volatile unsigned long *p; 32 volatile unsigned long *p;
@@ -61,7 +61,7 @@ unsigned long __cpuinit r3k_cache_size(unsigned long ca_flags)
61 return size * sizeof(*p); 61 return size * sizeof(*p);
62} 62}
63 63
64unsigned long __cpuinit r3k_cache_lsize(unsigned long ca_flags) 64unsigned long r3k_cache_lsize(unsigned long ca_flags)
65{ 65{
66 unsigned long flags, status, lsize, i; 66 unsigned long flags, status, lsize, i;
67 volatile unsigned long *p; 67 volatile unsigned long *p;
@@ -90,7 +90,7 @@ unsigned long __cpuinit r3k_cache_lsize(unsigned long ca_flags)
90 return lsize * sizeof(*p); 90 return lsize * sizeof(*p);
91} 91}
92 92
93static void __cpuinit r3k_probe_cache(void) 93static void r3k_probe_cache(void)
94{ 94{
95 dcache_size = r3k_cache_size(ST0_ISC); 95 dcache_size = r3k_cache_size(ST0_ISC);
96 if (dcache_size) 96 if (dcache_size)
@@ -312,7 +312,7 @@ static void r3k_dma_cache_wback_inv(unsigned long start, unsigned long size)
312 r3k_flush_dcache_range(start, start + size); 312 r3k_flush_dcache_range(start, start + size);
313} 313}
314 314
315void __cpuinit r3k_cache_init(void) 315void r3k_cache_init(void)
316{ 316{
317 extern void build_clear_page(void); 317 extern void build_clear_page(void);
318 extern void build_copy_page(void); 318 extern void build_copy_page(void);
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 21813beec7a5..f749f687ee87 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -107,7 +107,7 @@ static inline void r4k_blast_dcache_page_dc64(unsigned long addr)
107 blast_dcache64_page(addr); 107 blast_dcache64_page(addr);
108} 108}
109 109
110static void __cpuinit r4k_blast_dcache_page_setup(void) 110static void r4k_blast_dcache_page_setup(void)
111{ 111{
112 unsigned long dc_lsize = cpu_dcache_line_size(); 112 unsigned long dc_lsize = cpu_dcache_line_size();
113 113
@@ -123,7 +123,7 @@ static void __cpuinit r4k_blast_dcache_page_setup(void)
123 123
124static void (* r4k_blast_dcache_page_indexed)(unsigned long addr); 124static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
125 125
126static void __cpuinit r4k_blast_dcache_page_indexed_setup(void) 126static void r4k_blast_dcache_page_indexed_setup(void)
127{ 127{
128 unsigned long dc_lsize = cpu_dcache_line_size(); 128 unsigned long dc_lsize = cpu_dcache_line_size();
129 129
@@ -140,7 +140,7 @@ static void __cpuinit r4k_blast_dcache_page_indexed_setup(void)
140void (* r4k_blast_dcache)(void); 140void (* r4k_blast_dcache)(void);
141EXPORT_SYMBOL(r4k_blast_dcache); 141EXPORT_SYMBOL(r4k_blast_dcache);
142 142
143static void __cpuinit r4k_blast_dcache_setup(void) 143static void r4k_blast_dcache_setup(void)
144{ 144{
145 unsigned long dc_lsize = cpu_dcache_line_size(); 145 unsigned long dc_lsize = cpu_dcache_line_size();
146 146
@@ -227,7 +227,7 @@ static inline void tx49_blast_icache32_page_indexed(unsigned long page)
227 227
228static void (* r4k_blast_icache_page)(unsigned long addr); 228static void (* r4k_blast_icache_page)(unsigned long addr);
229 229
230static void __cpuinit r4k_blast_icache_page_setup(void) 230static void r4k_blast_icache_page_setup(void)
231{ 231{
232 unsigned long ic_lsize = cpu_icache_line_size(); 232 unsigned long ic_lsize = cpu_icache_line_size();
233 233
@@ -244,7 +244,7 @@ static void __cpuinit r4k_blast_icache_page_setup(void)
244 244
245static void (* r4k_blast_icache_page_indexed)(unsigned long addr); 245static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
246 246
247static void __cpuinit r4k_blast_icache_page_indexed_setup(void) 247static void r4k_blast_icache_page_indexed_setup(void)
248{ 248{
249 unsigned long ic_lsize = cpu_icache_line_size(); 249 unsigned long ic_lsize = cpu_icache_line_size();
250 250
@@ -269,7 +269,7 @@ static void __cpuinit r4k_blast_icache_page_indexed_setup(void)
269void (* r4k_blast_icache)(void); 269void (* r4k_blast_icache)(void);
270EXPORT_SYMBOL(r4k_blast_icache); 270EXPORT_SYMBOL(r4k_blast_icache);
271 271
272static void __cpuinit r4k_blast_icache_setup(void) 272static void r4k_blast_icache_setup(void)
273{ 273{
274 unsigned long ic_lsize = cpu_icache_line_size(); 274 unsigned long ic_lsize = cpu_icache_line_size();
275 275
@@ -290,7 +290,7 @@ static void __cpuinit r4k_blast_icache_setup(void)
290 290
291static void (* r4k_blast_scache_page)(unsigned long addr); 291static void (* r4k_blast_scache_page)(unsigned long addr);
292 292
293static void __cpuinit r4k_blast_scache_page_setup(void) 293static void r4k_blast_scache_page_setup(void)
294{ 294{
295 unsigned long sc_lsize = cpu_scache_line_size(); 295 unsigned long sc_lsize = cpu_scache_line_size();
296 296
@@ -308,7 +308,7 @@ static void __cpuinit r4k_blast_scache_page_setup(void)
308 308
309static void (* r4k_blast_scache_page_indexed)(unsigned long addr); 309static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
310 310
311static void __cpuinit r4k_blast_scache_page_indexed_setup(void) 311static void r4k_blast_scache_page_indexed_setup(void)
312{ 312{
313 unsigned long sc_lsize = cpu_scache_line_size(); 313 unsigned long sc_lsize = cpu_scache_line_size();
314 314
@@ -326,7 +326,7 @@ static void __cpuinit r4k_blast_scache_page_indexed_setup(void)
326 326
327static void (* r4k_blast_scache)(void); 327static void (* r4k_blast_scache)(void);
328 328
329static void __cpuinit r4k_blast_scache_setup(void) 329static void r4k_blast_scache_setup(void)
330{ 330{
331 unsigned long sc_lsize = cpu_scache_line_size(); 331 unsigned long sc_lsize = cpu_scache_line_size();
332 332
@@ -797,11 +797,11 @@ static inline void alias_74k_erratum(struct cpuinfo_mips *c)
797 } 797 }
798} 798}
799 799
800static char *way_string[] __cpuinitdata = { NULL, "direct mapped", "2-way", 800static char *way_string[] = { NULL, "direct mapped", "2-way",
801 "3-way", "4-way", "5-way", "6-way", "7-way", "8-way" 801 "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
802}; 802};
803 803
804static void __cpuinit probe_pcache(void) 804static void probe_pcache(void)
805{ 805{
806 struct cpuinfo_mips *c = &current_cpu_data; 806 struct cpuinfo_mips *c = &current_cpu_data;
807 unsigned int config = read_c0_config(); 807 unsigned int config = read_c0_config();
@@ -1119,7 +1119,7 @@ static void __cpuinit probe_pcache(void)
1119 * executes in KSEG1 space or else you will crash and burn badly. You have 1119 * executes in KSEG1 space or else you will crash and burn badly. You have
1120 * been warned. 1120 * been warned.
1121 */ 1121 */
1122static int __cpuinit probe_scache(void) 1122static int probe_scache(void)
1123{ 1123{
1124 unsigned long flags, addr, begin, end, pow2; 1124 unsigned long flags, addr, begin, end, pow2;
1125 unsigned int config = read_c0_config(); 1125 unsigned int config = read_c0_config();
@@ -1196,7 +1196,7 @@ extern int r5k_sc_init(void);
1196extern int rm7k_sc_init(void); 1196extern int rm7k_sc_init(void);
1197extern int mips_sc_init(void); 1197extern int mips_sc_init(void);
1198 1198
1199static void __cpuinit setup_scache(void) 1199static void setup_scache(void)
1200{ 1200{
1201 struct cpuinfo_mips *c = &current_cpu_data; 1201 struct cpuinfo_mips *c = &current_cpu_data;
1202 unsigned int config = read_c0_config(); 1202 unsigned int config = read_c0_config();
@@ -1329,7 +1329,7 @@ static void nxp_pr4450_fixup_config(void)
1329 NXP_BARRIER(); 1329 NXP_BARRIER();
1330} 1330}
1331 1331
1332static int __cpuinitdata cca = -1; 1332static int cca = -1;
1333 1333
1334static int __init cca_setup(char *str) 1334static int __init cca_setup(char *str)
1335{ 1335{
@@ -1340,7 +1340,7 @@ static int __init cca_setup(char *str)
1340 1340
1341early_param("cca", cca_setup); 1341early_param("cca", cca_setup);
1342 1342
1343static void __cpuinit coherency_setup(void) 1343static void coherency_setup(void)
1344{ 1344{
1345 if (cca < 0 || cca > 7) 1345 if (cca < 0 || cca > 7)
1346 cca = read_c0_config() & CONF_CM_CMASK; 1346 cca = read_c0_config() & CONF_CM_CMASK;
@@ -1380,7 +1380,7 @@ static void __cpuinit coherency_setup(void)
1380 } 1380 }
1381} 1381}
1382 1382
1383static void __cpuinit r4k_cache_error_setup(void) 1383static void r4k_cache_error_setup(void)
1384{ 1384{
1385 extern char __weak except_vec2_generic; 1385 extern char __weak except_vec2_generic;
1386 extern char __weak except_vec2_sb1; 1386 extern char __weak except_vec2_sb1;
@@ -1398,7 +1398,7 @@ static void __cpuinit r4k_cache_error_setup(void)
1398 } 1398 }
1399} 1399}
1400 1400
1401void __cpuinit r4k_cache_init(void) 1401void r4k_cache_init(void)
1402{ 1402{
1403 extern void build_clear_page(void); 1403 extern void build_clear_page(void);
1404 extern void build_copy_page(void); 1404 extern void build_copy_page(void);
diff --git a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c
index ba9da270289f..8d909dbbf37f 100644
--- a/arch/mips/mm/c-tx39.c
+++ b/arch/mips/mm/c-tx39.c
@@ -344,7 +344,7 @@ static __init void tx39_probe_cache(void)
344 } 344 }
345} 345}
346 346
347void __cpuinit tx39_cache_init(void) 347void tx39_cache_init(void)
348{ 348{
349 extern void build_clear_page(void); 349 extern void build_clear_page(void);
350 extern void build_copy_page(void); 350 extern void build_copy_page(void);
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
index 5aeb3eb0b72f..15f813c303b4 100644
--- a/arch/mips/mm/cache.c
+++ b/arch/mips/mm/cache.c
@@ -182,7 +182,7 @@ static inline void setup_protection_map(void)
182 } 182 }
183} 183}
184 184
185void __cpuinit cpu_cache_init(void) 185void cpu_cache_init(void)
186{ 186{
187 if (cpu_has_3k_cache) { 187 if (cpu_has_3k_cache) {
188 extern void __weak r3k_cache_init(void); 188 extern void __weak r3k_cache_init(void);
diff --git a/arch/mips/mm/cex-sb1.S b/arch/mips/mm/cex-sb1.S
index fe1d887e8d70..191cf6e0c725 100644
--- a/arch/mips/mm/cex-sb1.S
+++ b/arch/mips/mm/cex-sb1.S
@@ -49,8 +49,6 @@
49 * (0x170-0x17f) are used to preserve k0, k1, and ra. 49 * (0x170-0x17f) are used to preserve k0, k1, and ra.
50 */ 50 */
51 51
52 __CPUINIT
53
54LEAF(except_vec2_sb1) 52LEAF(except_vec2_sb1)
55 /* 53 /*
56 * If this error is recoverable, we need to exit the handler 54 * If this error is recoverable, we need to exit the handler
@@ -142,8 +140,6 @@ unrecoverable:
142 140
143END(except_vec2_sb1) 141END(except_vec2_sb1)
144 142
145 __FINIT
146
147 LEAF(handle_vec2_sb1) 143 LEAF(handle_vec2_sb1)
148 mfc0 k0,CP0_CONFIG 144 mfc0 k0,CP0_CONFIG
149 li k1,~CONF_CM_CMASK 145 li k1,~CONF_CM_CMASK
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
index 2c0bd580b9da..218c2109a55d 100644
--- a/arch/mips/mm/page.c
+++ b/arch/mips/mm/page.c
@@ -66,29 +66,29 @@ UASM_L_LA(_copy_pref_both)
66UASM_L_LA(_copy_pref_store) 66UASM_L_LA(_copy_pref_store)
67 67
68/* We need one branch and therefore one relocation per target label. */ 68/* We need one branch and therefore one relocation per target label. */
69static struct uasm_label __cpuinitdata labels[5]; 69static struct uasm_label labels[5];
70static struct uasm_reloc __cpuinitdata relocs[5]; 70static struct uasm_reloc relocs[5];
71 71
72#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) 72#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
73#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) 73#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
74 74
75static int pref_bias_clear_store __cpuinitdata; 75static int pref_bias_clear_store;
76static int pref_bias_copy_load __cpuinitdata; 76static int pref_bias_copy_load;
77static int pref_bias_copy_store __cpuinitdata; 77static int pref_bias_copy_store;
78 78
79static u32 pref_src_mode __cpuinitdata; 79static u32 pref_src_mode;
80static u32 pref_dst_mode __cpuinitdata; 80static u32 pref_dst_mode;
81 81
82static int clear_word_size __cpuinitdata; 82static int clear_word_size;
83static int copy_word_size __cpuinitdata; 83static int copy_word_size;
84 84
85static int half_clear_loop_size __cpuinitdata; 85static int half_clear_loop_size;
86static int half_copy_loop_size __cpuinitdata; 86static int half_copy_loop_size;
87 87
88static int cache_line_size __cpuinitdata; 88static int cache_line_size;
89#define cache_line_mask() (cache_line_size - 1) 89#define cache_line_mask() (cache_line_size - 1)
90 90
91static inline void __cpuinit 91static inline void
92pg_addiu(u32 **buf, unsigned int reg1, unsigned int reg2, unsigned int off) 92pg_addiu(u32 **buf, unsigned int reg1, unsigned int reg2, unsigned int off)
93{ 93{
94 if (cpu_has_64bit_gp_regs && DADDI_WAR && r4k_daddiu_bug()) { 94 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)
108 } 108 }
109} 109}
110 110
111static void __cpuinit set_prefetch_parameters(void) 111static void set_prefetch_parameters(void)
112{ 112{
113 if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg) 113 if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg)
114 clear_word_size = 8; 114 clear_word_size = 8;
@@ -199,7 +199,7 @@ static void __cpuinit set_prefetch_parameters(void)
199 4 * copy_word_size)); 199 4 * copy_word_size));
200} 200}
201 201
202static void __cpuinit build_clear_store(u32 **buf, int off) 202static void build_clear_store(u32 **buf, int off)
203{ 203{
204 if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg) { 204 if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg) {
205 uasm_i_sd(buf, ZERO, off, A0); 205 uasm_i_sd(buf, ZERO, off, A0);
@@ -208,7 +208,7 @@ static void __cpuinit build_clear_store(u32 **buf, int off)
208 } 208 }
209} 209}
210 210
211static inline void __cpuinit build_clear_pref(u32 **buf, int off) 211static inline void build_clear_pref(u32 **buf, int off)
212{ 212{
213 if (off & cache_line_mask()) 213 if (off & cache_line_mask())
214 return; 214 return;
@@ -240,7 +240,7 @@ extern u32 __clear_page_end;
240extern u32 __copy_page_start; 240extern u32 __copy_page_start;
241extern u32 __copy_page_end; 241extern u32 __copy_page_end;
242 242
243void __cpuinit build_clear_page(void) 243void build_clear_page(void)
244{ 244{
245 int off; 245 int off;
246 u32 *buf = &__clear_page_start; 246 u32 *buf = &__clear_page_start;
@@ -333,7 +333,7 @@ void __cpuinit build_clear_page(void)
333 pr_debug("\t.set pop\n"); 333 pr_debug("\t.set pop\n");
334} 334}
335 335
336static void __cpuinit build_copy_load(u32 **buf, int reg, int off) 336static void build_copy_load(u32 **buf, int reg, int off)
337{ 337{
338 if (cpu_has_64bit_gp_regs) { 338 if (cpu_has_64bit_gp_regs) {
339 uasm_i_ld(buf, reg, off, A1); 339 uasm_i_ld(buf, reg, off, A1);
@@ -342,7 +342,7 @@ static void __cpuinit build_copy_load(u32 **buf, int reg, int off)
342 } 342 }
343} 343}
344 344
345static void __cpuinit build_copy_store(u32 **buf, int reg, int off) 345static void build_copy_store(u32 **buf, int reg, int off)
346{ 346{
347 if (cpu_has_64bit_gp_regs) { 347 if (cpu_has_64bit_gp_regs) {
348 uasm_i_sd(buf, reg, off, A0); 348 uasm_i_sd(buf, reg, off, A0);
@@ -387,7 +387,7 @@ static inline void build_copy_store_pref(u32 **buf, int off)
387 } 387 }
388} 388}
389 389
390void __cpuinit build_copy_page(void) 390void build_copy_page(void)
391{ 391{
392 int off; 392 int off;
393 u32 *buf = &__copy_page_start; 393 u32 *buf = &__copy_page_start;
diff --git a/arch/mips/mm/sc-ip22.c b/arch/mips/mm/sc-ip22.c
index c6aaed934d53..dc7c5a5214a9 100644
--- a/arch/mips/mm/sc-ip22.c
+++ b/arch/mips/mm/sc-ip22.c
@@ -167,7 +167,7 @@ static struct bcache_ops indy_sc_ops = {
167 .bc_inv = indy_sc_wback_invalidate 167 .bc_inv = indy_sc_wback_invalidate
168}; 168};
169 169
170void __cpuinit indy_sc_init(void) 170void indy_sc_init(void)
171{ 171{
172 if (indy_sc_probe()) { 172 if (indy_sc_probe()) {
173 indy_sc_enable(); 173 indy_sc_enable();
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index df96da7e939b..5d01392e3518 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -132,7 +132,7 @@ static inline int __init mips_sc_probe(void)
132 return 1; 132 return 1;
133} 133}
134 134
135int __cpuinit mips_sc_init(void) 135int mips_sc_init(void)
136{ 136{
137 int found = mips_sc_probe(); 137 int found = mips_sc_probe();
138 if (found) { 138 if (found) {
diff --git a/arch/mips/mm/sc-r5k.c b/arch/mips/mm/sc-r5k.c
index 8bc67720e145..0216ed6eaa2a 100644
--- a/arch/mips/mm/sc-r5k.c
+++ b/arch/mips/mm/sc-r5k.c
@@ -98,7 +98,7 @@ static struct bcache_ops r5k_sc_ops = {
98 .bc_inv = r5k_dma_cache_inv_sc 98 .bc_inv = r5k_dma_cache_inv_sc
99}; 99};
100 100
101void __cpuinit r5k_sc_init(void) 101void r5k_sc_init(void)
102{ 102{
103 if (r5k_sc_probe()) { 103 if (r5k_sc_probe()) {
104 r5k_sc_enable(); 104 r5k_sc_enable();
diff --git a/arch/mips/mm/sc-rm7k.c b/arch/mips/mm/sc-rm7k.c
index 274af3be1442..aaffbba33706 100644
--- a/arch/mips/mm/sc-rm7k.c
+++ b/arch/mips/mm/sc-rm7k.c
@@ -104,7 +104,7 @@ static void blast_rm7k_tcache(void)
104/* 104/*
105 * This function is executed in uncached address space. 105 * This function is executed in uncached address space.
106 */ 106 */
107static __cpuinit void __rm7k_tc_enable(void) 107static void __rm7k_tc_enable(void)
108{ 108{
109 int i; 109 int i;
110 110
@@ -117,7 +117,7 @@ static __cpuinit void __rm7k_tc_enable(void)
117 cache_op(Index_Store_Tag_T, CKSEG0ADDR(i)); 117 cache_op(Index_Store_Tag_T, CKSEG0ADDR(i));
118} 118}
119 119
120static __cpuinit void rm7k_tc_enable(void) 120static void rm7k_tc_enable(void)
121{ 121{
122 if (read_c0_config() & RM7K_CONF_TE) 122 if (read_c0_config() & RM7K_CONF_TE)
123 return; 123 return;
@@ -130,7 +130,7 @@ static __cpuinit void rm7k_tc_enable(void)
130/* 130/*
131 * This function is executed in uncached address space. 131 * This function is executed in uncached address space.
132 */ 132 */
133static __cpuinit void __rm7k_sc_enable(void) 133static void __rm7k_sc_enable(void)
134{ 134{
135 int i; 135 int i;
136 136
@@ -143,7 +143,7 @@ static __cpuinit void __rm7k_sc_enable(void)
143 cache_op(Index_Store_Tag_SD, CKSEG0ADDR(i)); 143 cache_op(Index_Store_Tag_SD, CKSEG0ADDR(i));
144} 144}
145 145
146static __cpuinit void rm7k_sc_enable(void) 146static void rm7k_sc_enable(void)
147{ 147{
148 if (read_c0_config() & RM7K_CONF_SE) 148 if (read_c0_config() & RM7K_CONF_SE)
149 return; 149 return;
@@ -184,7 +184,7 @@ static struct bcache_ops rm7k_sc_ops = {
184 * This is a probing function like the one found in c-r4k.c, we look for the 184 * This is a probing function like the one found in c-r4k.c, we look for the
185 * wrap around point with different addresses. 185 * wrap around point with different addresses.
186 */ 186 */
187static __cpuinit void __probe_tcache(void) 187static void __probe_tcache(void)
188{ 188{
189 unsigned long flags, addr, begin, end, pow2; 189 unsigned long flags, addr, begin, end, pow2;
190 190
@@ -226,7 +226,7 @@ static __cpuinit void __probe_tcache(void)
226 local_irq_restore(flags); 226 local_irq_restore(flags);
227} 227}
228 228
229void __cpuinit rm7k_sc_init(void) 229void rm7k_sc_init(void)
230{ 230{
231 struct cpuinfo_mips *c = &current_cpu_data; 231 struct cpuinfo_mips *c = &current_cpu_data;
232 unsigned int config = read_c0_config(); 232 unsigned int config = read_c0_config();
diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c
index a63d1ed0827f..9aca10994cd2 100644
--- a/arch/mips/mm/tlb-r3k.c
+++ b/arch/mips/mm/tlb-r3k.c
@@ -276,7 +276,7 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
276 } 276 }
277} 277}
278 278
279void __cpuinit tlb_init(void) 279void tlb_init(void)
280{ 280{
281 local_flush_tlb_all(); 281 local_flush_tlb_all();
282 282
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index c643de4c473a..00b26a67a06d 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -389,7 +389,7 @@ int __init has_transparent_hugepage(void)
389 389
390#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 390#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
391 391
392static int __cpuinitdata ntlb; 392static int ntlb;
393static int __init set_ntlb(char *str) 393static int __init set_ntlb(char *str)
394{ 394{
395 get_option(&str, &ntlb); 395 get_option(&str, &ntlb);
@@ -398,7 +398,7 @@ static int __init set_ntlb(char *str)
398 398
399__setup("ntlb=", set_ntlb); 399__setup("ntlb=", set_ntlb);
400 400
401void __cpuinit tlb_init(void) 401void tlb_init(void)
402{ 402{
403 /* 403 /*
404 * You should never change this register: 404 * You should never change this register:
diff --git a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c
index 91c2499f806a..6a99733a4440 100644
--- a/arch/mips/mm/tlb-r8k.c
+++ b/arch/mips/mm/tlb-r8k.c
@@ -213,14 +213,14 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
213 local_irq_restore(flags); 213 local_irq_restore(flags);
214} 214}
215 215
216static void __cpuinit probe_tlb(unsigned long config) 216static void probe_tlb(unsigned long config)
217{ 217{
218 struct cpuinfo_mips *c = &current_cpu_data; 218 struct cpuinfo_mips *c = &current_cpu_data;
219 219
220 c->tlbsize = 3 * 128; /* 3 sets each 128 entries */ 220 c->tlbsize = 3 * 128; /* 3 sets each 128 entries */
221} 221}
222 222
223void __cpuinit tlb_init(void) 223void tlb_init(void)
224{ 224{
225 unsigned int config = read_c0_config(); 225 unsigned int config = read_c0_config();
226 unsigned long status; 226 unsigned long status;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 9ab0f907a52c..556cb4815770 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -136,7 +136,7 @@ static int scratchpad_offset(int i)
136 * why; it's not an issue caused by the core RTL. 136 * why; it's not an issue caused by the core RTL.
137 * 137 *
138 */ 138 */
139static int __cpuinit m4kc_tlbp_war(void) 139static int m4kc_tlbp_war(void)
140{ 140{
141 return (current_cpu_data.processor_id & 0xffff00) == 141 return (current_cpu_data.processor_id & 0xffff00) ==
142 (PRID_COMP_MIPS | PRID_IMP_4KC); 142 (PRID_COMP_MIPS | PRID_IMP_4KC);
@@ -181,11 +181,9 @@ UASM_L_LA(_large_segbits_fault)
181UASM_L_LA(_tlb_huge_update) 181UASM_L_LA(_tlb_huge_update)
182#endif 182#endif
183 183
184static int __cpuinitdata hazard_instance; 184static int hazard_instance;
185 185
186static void __cpuinit uasm_bgezl_hazard(u32 **p, 186static void uasm_bgezl_hazard(u32 **p, struct uasm_reloc **r, int instance)
187 struct uasm_reloc **r,
188 int instance)
189{ 187{
190 switch (instance) { 188 switch (instance) {
191 case 0 ... 7: 189 case 0 ... 7:
@@ -196,9 +194,7 @@ static void __cpuinit uasm_bgezl_hazard(u32 **p,
196 } 194 }
197} 195}
198 196
199static void __cpuinit uasm_bgezl_label(struct uasm_label **l, 197static void uasm_bgezl_label(struct uasm_label **l, u32 **p, int instance)
200 u32 **p,
201 int instance)
202{ 198{
203 switch (instance) { 199 switch (instance) {
204 case 0 ... 7: 200 case 0 ... 7:
@@ -295,15 +291,15 @@ static inline void dump_handler(const char *symbol, const u32 *handler, int coun
295 * We deliberately chose a buffer size of 128, so we won't scribble 291 * We deliberately chose a buffer size of 128, so we won't scribble
296 * over anything important on overflow before we panic. 292 * over anything important on overflow before we panic.
297 */ 293 */
298static u32 tlb_handler[128] __cpuinitdata; 294static u32 tlb_handler[128];
299 295
300/* simply assume worst case size for labels and relocs */ 296/* simply assume worst case size for labels and relocs */
301static struct uasm_label labels[128] __cpuinitdata; 297static struct uasm_label labels[128];
302static struct uasm_reloc relocs[128] __cpuinitdata; 298static struct uasm_reloc relocs[128];
303 299
304static int check_for_high_segbits __cpuinitdata; 300static int check_for_high_segbits;
305 301
306static unsigned int kscratch_used_mask __cpuinitdata; 302static unsigned int kscratch_used_mask;
307 303
308static inline int __maybe_unused c0_kscratch(void) 304static inline int __maybe_unused c0_kscratch(void)
309{ 305{
@@ -316,7 +312,7 @@ static inline int __maybe_unused c0_kscratch(void)
316 } 312 }
317} 313}
318 314
319static int __cpuinit allocate_kscratch(void) 315static int allocate_kscratch(void)
320{ 316{
321 int r; 317 int r;
322 unsigned int a = cpu_data[0].kscratch_mask & ~kscratch_used_mask; 318 unsigned int a = cpu_data[0].kscratch_mask & ~kscratch_used_mask;
@@ -333,11 +329,11 @@ static int __cpuinit allocate_kscratch(void)
333 return r; 329 return r;
334} 330}
335 331
336static int scratch_reg __cpuinitdata; 332static int scratch_reg;
337static int pgd_reg __cpuinitdata; 333static int pgd_reg;
338enum vmalloc64_mode {not_refill, refill_scratch, refill_noscratch}; 334enum vmalloc64_mode {not_refill, refill_scratch, refill_noscratch};
339 335
340static struct work_registers __cpuinit build_get_work_registers(u32 **p) 336static struct work_registers build_get_work_registers(u32 **p)
341{ 337{
342 struct work_registers r; 338 struct work_registers r;
343 339
@@ -393,7 +389,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p)
393 return r; 389 return r;
394} 390}
395 391
396static void __cpuinit build_restore_work_registers(u32 **p) 392static void build_restore_work_registers(u32 **p)
397{ 393{
398 if (scratch_reg >= 0) { 394 if (scratch_reg >= 0) {
399 UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); 395 UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg);
@@ -418,7 +414,7 @@ extern unsigned long pgd_current[];
418/* 414/*
419 * The R3000 TLB handler is simple. 415 * The R3000 TLB handler is simple.
420 */ 416 */
421static void __cpuinit build_r3000_tlb_refill_handler(void) 417static void build_r3000_tlb_refill_handler(void)
422{ 418{
423 long pgdc = (long)pgd_current; 419 long pgdc = (long)pgd_current;
424 u32 *p; 420 u32 *p;
@@ -463,7 +459,7 @@ static void __cpuinit build_r3000_tlb_refill_handler(void)
463 * other one.To keep things simple, we first assume linear space, 459 * other one.To keep things simple, we first assume linear space,
464 * then we relocate it to the final handler layout as needed. 460 * then we relocate it to the final handler layout as needed.
465 */ 461 */
466static u32 final_handler[64] __cpuinitdata; 462static u32 final_handler[64];
467 463
468/* 464/*
469 * Hazards 465 * Hazards
@@ -487,7 +483,7 @@ static u32 final_handler[64] __cpuinitdata;
487 * 483 *
488 * As if we MIPS hackers wouldn't know how to nop pipelines happy ... 484 * As if we MIPS hackers wouldn't know how to nop pipelines happy ...
489 */ 485 */
490static void __cpuinit __maybe_unused build_tlb_probe_entry(u32 **p) 486static void __maybe_unused build_tlb_probe_entry(u32 **p)
491{ 487{
492 switch (current_cpu_type()) { 488 switch (current_cpu_type()) {
493 /* Found by experiment: R4600 v2.0/R4700 needs this, too. */ 489 /* 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)
511 */ 507 */
512enum tlb_write_entry { tlb_random, tlb_indexed }; 508enum tlb_write_entry { tlb_random, tlb_indexed };
513 509
514static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l, 510static void build_tlb_write_entry(u32 **p, struct uasm_label **l,
515 struct uasm_reloc **r, 511 struct uasm_reloc **r,
516 enum tlb_write_entry wmode) 512 enum tlb_write_entry wmode)
517{ 513{
518 void(*tlbw)(u32 **) = NULL; 514 void(*tlbw)(u32 **) = NULL;
519 515
@@ -647,8 +643,8 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
647 } 643 }
648} 644}
649 645
650static __cpuinit __maybe_unused void build_convert_pte_to_entrylo(u32 **p, 646static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
651 unsigned int reg) 647 unsigned int reg)
652{ 648{
653 if (cpu_has_rixi) { 649 if (cpu_has_rixi) {
654 UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL)); 650 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,
663 659
664#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT 660#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
665 661
666static __cpuinit void build_restore_pagemask(u32 **p, 662static void build_restore_pagemask(u32 **p, struct uasm_reloc **r,
667 struct uasm_reloc **r, 663 unsigned int tmp, enum label_id lid,
668 unsigned int tmp, 664 int restore_scratch)
669 enum label_id lid,
670 int restore_scratch)
671{ 665{
672 if (restore_scratch) { 666 if (restore_scratch) {
673 /* Reset default page size */ 667 /* Reset default page size */
@@ -706,12 +700,11 @@ static __cpuinit void build_restore_pagemask(u32 **p,
706 } 700 }
707} 701}
708 702
709static __cpuinit void build_huge_tlb_write_entry(u32 **p, 703static void build_huge_tlb_write_entry(u32 **p, struct uasm_label **l,
710 struct uasm_label **l, 704 struct uasm_reloc **r,
711 struct uasm_reloc **r, 705 unsigned int tmp,
712 unsigned int tmp, 706 enum tlb_write_entry wmode,
713 enum tlb_write_entry wmode, 707 int restore_scratch)
714 int restore_scratch)
715{ 708{
716 /* Set huge page tlb entry size */ 709 /* Set huge page tlb entry size */
717 uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16); 710 uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16);
@@ -726,9 +719,9 @@ static __cpuinit void build_huge_tlb_write_entry(u32 **p,
726/* 719/*
727 * Check if Huge PTE is present, if so then jump to LABEL. 720 * Check if Huge PTE is present, if so then jump to LABEL.
728 */ 721 */
729static void __cpuinit 722static void
730build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp, 723build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp,
731 unsigned int pmd, int lid) 724 unsigned int pmd, int lid)
732{ 725{
733 UASM_i_LW(p, tmp, 0, pmd); 726 UASM_i_LW(p, tmp, 0, pmd);
734 if (use_bbit_insns()) { 727 if (use_bbit_insns()) {
@@ -739,9 +732,8 @@ build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp,
739 } 732 }
740} 733}
741 734
742static __cpuinit void build_huge_update_entries(u32 **p, 735static void build_huge_update_entries(u32 **p, unsigned int pte,
743 unsigned int pte, 736 unsigned int tmp)
744 unsigned int tmp)
745{ 737{
746 int small_sequence; 738 int small_sequence;
747 739
@@ -771,11 +763,10 @@ static __cpuinit void build_huge_update_entries(u32 **p,
771 UASM_i_MTC0(p, pte, C0_ENTRYLO1); /* load it */ 763 UASM_i_MTC0(p, pte, C0_ENTRYLO1); /* load it */
772} 764}
773 765
774static __cpuinit void build_huge_handler_tail(u32 **p, 766static void build_huge_handler_tail(u32 **p, struct uasm_reloc **r,
775 struct uasm_reloc **r, 767 struct uasm_label **l,
776 struct uasm_label **l, 768 unsigned int pte,
777 unsigned int pte, 769 unsigned int ptr)
778 unsigned int ptr)
779{ 770{
780#ifdef CONFIG_SMP 771#ifdef CONFIG_SMP
781 UASM_i_SC(p, pte, 0, ptr); 772 UASM_i_SC(p, pte, 0, ptr);
@@ -794,7 +785,7 @@ static __cpuinit void build_huge_handler_tail(u32 **p,
794 * TMP and PTR are scratch. 785 * TMP and PTR are scratch.
795 * TMP will be clobbered, PTR will hold the pmd entry. 786 * TMP will be clobbered, PTR will hold the pmd entry.
796 */ 787 */
797static void __cpuinit 788static void
798build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, 789build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
799 unsigned int tmp, unsigned int ptr) 790 unsigned int tmp, unsigned int ptr)
800{ 791{
@@ -886,7 +877,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
886 * BVADDR is the faulting address, PTR is scratch. 877 * BVADDR is the faulting address, PTR is scratch.
887 * PTR will hold the pgd for vmalloc. 878 * PTR will hold the pgd for vmalloc.
888 */ 879 */
889static void __cpuinit 880static void
890build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, 881build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
891 unsigned int bvaddr, unsigned int ptr, 882 unsigned int bvaddr, unsigned int ptr,
892 enum vmalloc64_mode mode) 883 enum vmalloc64_mode mode)
@@ -956,7 +947,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
956 * TMP and PTR are scratch. 947 * TMP and PTR are scratch.
957 * TMP will be clobbered, PTR will hold the pgd entry. 948 * TMP will be clobbered, PTR will hold the pgd entry.
958 */ 949 */
959static void __cpuinit __maybe_unused 950static void __maybe_unused
960build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr) 951build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
961{ 952{
962 long pgdc = (long)pgd_current; 953 long pgdc = (long)pgd_current;
@@ -991,7 +982,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
991 982
992#endif /* !CONFIG_64BIT */ 983#endif /* !CONFIG_64BIT */
993 984
994static void __cpuinit build_adjust_context(u32 **p, unsigned int ctx) 985static void build_adjust_context(u32 **p, unsigned int ctx)
995{ 986{
996 unsigned int shift = 4 - (PTE_T_LOG2 + 1) + PAGE_SHIFT - 12; 987 unsigned int shift = 4 - (PTE_T_LOG2 + 1) + PAGE_SHIFT - 12;
997 unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1); 988 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)
1017 uasm_i_andi(p, ctx, ctx, mask); 1008 uasm_i_andi(p, ctx, ctx, mask);
1018} 1009}
1019 1010
1020static void __cpuinit build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr) 1011static void build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr)
1021{ 1012{
1022 /* 1013 /*
1023 * Bug workaround for the Nevada. It seems as if under certain 1014 * 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
1042 UASM_i_ADDU(p, ptr, ptr, tmp); /* add in offset */ 1033 UASM_i_ADDU(p, ptr, ptr, tmp); /* add in offset */
1043} 1034}
1044 1035
1045static void __cpuinit build_update_entries(u32 **p, unsigned int tmp, 1036static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
1046 unsigned int ptep)
1047{ 1037{
1048 /* 1038 /*
1049 * 64bit address support (36bit on a 32bit CPU) in a 32bit 1039 * 64bit address support (36bit on a 32bit CPU) in a 32bit
@@ -1104,7 +1094,7 @@ struct mips_huge_tlb_info {
1104 int restore_scratch; 1094 int restore_scratch;
1105}; 1095};
1106 1096
1107static struct mips_huge_tlb_info __cpuinit 1097static struct mips_huge_tlb_info
1108build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, 1098build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
1109 struct uasm_reloc **r, unsigned int tmp, 1099 struct uasm_reloc **r, unsigned int tmp,
1110 unsigned int ptr, int c0_scratch_reg) 1100 unsigned int ptr, int c0_scratch_reg)
@@ -1282,7 +1272,7 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
1282 */ 1272 */
1283#define MIPS64_REFILL_INSNS 32 1273#define MIPS64_REFILL_INSNS 32
1284 1274
1285static void __cpuinit build_r4000_tlb_refill_handler(void) 1275static void build_r4000_tlb_refill_handler(void)
1286{ 1276{
1287 u32 *p = tlb_handler; 1277 u32 *p = tlb_handler;
1288 struct uasm_label *l = labels; 1278 struct uasm_label *l = labels;
@@ -1462,11 +1452,11 @@ extern u32 handle_tlbm[], handle_tlbm_end[];
1462#ifdef CONFIG_MIPS_PGD_C0_CONTEXT 1452#ifdef CONFIG_MIPS_PGD_C0_CONTEXT
1463extern u32 tlbmiss_handler_setup_pgd[], tlbmiss_handler_setup_pgd_end[]; 1453extern u32 tlbmiss_handler_setup_pgd[], tlbmiss_handler_setup_pgd_end[];
1464 1454
1465static void __cpuinit build_r4000_setup_pgd(void) 1455static void build_r4000_setup_pgd(void)
1466{ 1456{
1467 const int a0 = 4; 1457 const int a0 = 4;
1468 const int a1 = 5; 1458 const int a1 = 5;
1469 u32 *p = tlbmiss_handler_setup_pgd_array; 1459 u32 *p = tlbmiss_handler_setup_pgd;
1470 const int tlbmiss_handler_setup_pgd_size = 1460 const int tlbmiss_handler_setup_pgd_size =
1471 tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd; 1461 tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd;
1472 struct uasm_label *l = labels; 1462 struct uasm_label *l = labels;
@@ -1513,7 +1503,7 @@ static void __cpuinit build_r4000_setup_pgd(void)
1513} 1503}
1514#endif 1504#endif
1515 1505
1516static void __cpuinit 1506static void
1517iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr) 1507iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr)
1518{ 1508{
1519#ifdef CONFIG_SMP 1509#ifdef CONFIG_SMP
@@ -1533,7 +1523,7 @@ iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr)
1533#endif 1523#endif
1534} 1524}
1535 1525
1536static void __cpuinit 1526static void
1537iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, 1527iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr,
1538 unsigned int mode) 1528 unsigned int mode)
1539{ 1529{
@@ -1593,7 +1583,7 @@ iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr,
1593 * the page table where this PTE is located, PTE will be re-loaded 1583 * the page table where this PTE is located, PTE will be re-loaded
1594 * with it's original value. 1584 * with it's original value.
1595 */ 1585 */
1596static void __cpuinit 1586static void
1597build_pte_present(u32 **p, struct uasm_reloc **r, 1587build_pte_present(u32 **p, struct uasm_reloc **r,
1598 int pte, int ptr, int scratch, enum label_id lid) 1588 int pte, int ptr, int scratch, enum label_id lid)
1599{ 1589{
@@ -1621,7 +1611,7 @@ build_pte_present(u32 **p, struct uasm_reloc **r,
1621} 1611}
1622 1612
1623/* Make PTE valid, store result in PTR. */ 1613/* Make PTE valid, store result in PTR. */
1624static void __cpuinit 1614static void
1625build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte, 1615build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte,
1626 unsigned int ptr) 1616 unsigned int ptr)
1627{ 1617{
@@ -1634,7 +1624,7 @@ build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte,
1634 * Check if PTE can be written to, if not branch to LABEL. Regardless 1624 * Check if PTE can be written to, if not branch to LABEL. Regardless
1635 * restore PTE with value from PTR when done. 1625 * restore PTE with value from PTR when done.
1636 */ 1626 */
1637static void __cpuinit 1627static void
1638build_pte_writable(u32 **p, struct uasm_reloc **r, 1628build_pte_writable(u32 **p, struct uasm_reloc **r,
1639 unsigned int pte, unsigned int ptr, int scratch, 1629 unsigned int pte, unsigned int ptr, int scratch,
1640 enum label_id lid) 1630 enum label_id lid)
@@ -1654,7 +1644,7 @@ build_pte_writable(u32 **p, struct uasm_reloc **r,
1654/* Make PTE writable, update software status bits as well, then store 1644/* Make PTE writable, update software status bits as well, then store
1655 * at PTR. 1645 * at PTR.
1656 */ 1646 */
1657static void __cpuinit 1647static void
1658build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte, 1648build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte,
1659 unsigned int ptr) 1649 unsigned int ptr)
1660{ 1650{
@@ -1668,7 +1658,7 @@ build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte,
1668 * Check if PTE can be modified, if not branch to LABEL. Regardless 1658 * Check if PTE can be modified, if not branch to LABEL. Regardless
1669 * restore PTE with value from PTR when done. 1659 * restore PTE with value from PTR when done.
1670 */ 1660 */
1671static void __cpuinit 1661static void
1672build_pte_modifiable(u32 **p, struct uasm_reloc **r, 1662build_pte_modifiable(u32 **p, struct uasm_reloc **r,
1673 unsigned int pte, unsigned int ptr, int scratch, 1663 unsigned int pte, unsigned int ptr, int scratch,
1674 enum label_id lid) 1664 enum label_id lid)
@@ -1697,7 +1687,7 @@ build_pte_modifiable(u32 **p, struct uasm_reloc **r,
1697 * This places the pte into ENTRYLO0 and writes it with tlbwi. 1687 * This places the pte into ENTRYLO0 and writes it with tlbwi.
1698 * Then it returns. 1688 * Then it returns.
1699 */ 1689 */
1700static void __cpuinit 1690static void
1701build_r3000_pte_reload_tlbwi(u32 **p, unsigned int pte, unsigned int tmp) 1691build_r3000_pte_reload_tlbwi(u32 **p, unsigned int pte, unsigned int tmp)
1702{ 1692{
1703 uasm_i_mtc0(p, pte, C0_ENTRYLO0); /* cp0 delay */ 1693 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)
1713 * may have the probe fail bit set as a result of a trap on a 1703 * may have the probe fail bit set as a result of a trap on a
1714 * kseg2 access, i.e. without refill. Then it returns. 1704 * kseg2 access, i.e. without refill. Then it returns.
1715 */ 1705 */
1716static void __cpuinit 1706static void
1717build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l, 1707build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l,
1718 struct uasm_reloc **r, unsigned int pte, 1708 struct uasm_reloc **r, unsigned int pte,
1719 unsigned int tmp) 1709 unsigned int tmp)
@@ -1731,7 +1721,7 @@ build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l,
1731 uasm_i_rfe(p); /* branch delay */ 1721 uasm_i_rfe(p); /* branch delay */
1732} 1722}
1733 1723
1734static void __cpuinit 1724static void
1735build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte, 1725build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte,
1736 unsigned int ptr) 1726 unsigned int ptr)
1737{ 1727{
@@ -1751,7 +1741,7 @@ build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte,
1751 uasm_i_tlbp(p); /* load delay */ 1741 uasm_i_tlbp(p); /* load delay */
1752} 1742}
1753 1743
1754static void __cpuinit build_r3000_tlb_load_handler(void) 1744static void build_r3000_tlb_load_handler(void)
1755{ 1745{
1756 u32 *p = handle_tlbl; 1746 u32 *p = handle_tlbl;
1757 const int handle_tlbl_size = handle_tlbl_end - handle_tlbl; 1747 const int handle_tlbl_size = handle_tlbl_end - handle_tlbl;
@@ -1782,7 +1772,7 @@ static void __cpuinit build_r3000_tlb_load_handler(void)
1782 dump_handler("r3000_tlb_load", handle_tlbl, handle_tlbl_size); 1772 dump_handler("r3000_tlb_load", handle_tlbl, handle_tlbl_size);
1783} 1773}
1784 1774
1785static void __cpuinit build_r3000_tlb_store_handler(void) 1775static void build_r3000_tlb_store_handler(void)
1786{ 1776{
1787 u32 *p = handle_tlbs; 1777 u32 *p = handle_tlbs;
1788 const int handle_tlbs_size = handle_tlbs_end - handle_tlbs; 1778 const int handle_tlbs_size = handle_tlbs_end - handle_tlbs;
@@ -1803,7 +1793,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void)
1803 uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff); 1793 uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff);
1804 uasm_i_nop(&p); 1794 uasm_i_nop(&p);
1805 1795
1806 if (p >= handle_tlbs) 1796 if (p >= handle_tlbs_end)
1807 panic("TLB store handler fastpath space exceeded"); 1797 panic("TLB store handler fastpath space exceeded");
1808 1798
1809 uasm_resolve_relocs(relocs, labels); 1799 uasm_resolve_relocs(relocs, labels);
@@ -1813,7 +1803,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void)
1813 dump_handler("r3000_tlb_store", handle_tlbs, handle_tlbs_size); 1803 dump_handler("r3000_tlb_store", handle_tlbs, handle_tlbs_size);
1814} 1804}
1815 1805
1816static void __cpuinit build_r3000_tlb_modify_handler(void) 1806static void build_r3000_tlb_modify_handler(void)
1817{ 1807{
1818 u32 *p = handle_tlbm; 1808 u32 *p = handle_tlbm;
1819 const int handle_tlbm_size = handle_tlbm_end - handle_tlbm; 1809 const int handle_tlbm_size = handle_tlbm_end - handle_tlbm;
@@ -1848,7 +1838,7 @@ static void __cpuinit build_r3000_tlb_modify_handler(void)
1848/* 1838/*
1849 * R4000 style TLB load/store/modify handlers. 1839 * R4000 style TLB load/store/modify handlers.
1850 */ 1840 */
1851static struct work_registers __cpuinit 1841static struct work_registers
1852build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l, 1842build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
1853 struct uasm_reloc **r) 1843 struct uasm_reloc **r)
1854{ 1844{
@@ -1884,7 +1874,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
1884 return wr; 1874 return wr;
1885} 1875}
1886 1876
1887static void __cpuinit 1877static void
1888build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l, 1878build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l,
1889 struct uasm_reloc **r, unsigned int tmp, 1879 struct uasm_reloc **r, unsigned int tmp,
1890 unsigned int ptr) 1880 unsigned int ptr)
@@ -1902,7 +1892,7 @@ build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l,
1902#endif 1892#endif
1903} 1893}
1904 1894
1905static void __cpuinit build_r4000_tlb_load_handler(void) 1895static void build_r4000_tlb_load_handler(void)
1906{ 1896{
1907 u32 *p = handle_tlbl; 1897 u32 *p = handle_tlbl;
1908 const int handle_tlbl_size = handle_tlbl_end - handle_tlbl; 1898 const int handle_tlbl_size = handle_tlbl_end - handle_tlbl;
@@ -2085,7 +2075,7 @@ static void __cpuinit build_r4000_tlb_load_handler(void)
2085 dump_handler("r4000_tlb_load", handle_tlbl, handle_tlbl_size); 2075 dump_handler("r4000_tlb_load", handle_tlbl, handle_tlbl_size);
2086} 2076}
2087 2077
2088static void __cpuinit build_r4000_tlb_store_handler(void) 2078static void build_r4000_tlb_store_handler(void)
2089{ 2079{
2090 u32 *p = handle_tlbs; 2080 u32 *p = handle_tlbs;
2091 const int handle_tlbs_size = handle_tlbs_end - handle_tlbs; 2081 const int handle_tlbs_size = handle_tlbs_end - handle_tlbs;
@@ -2140,7 +2130,7 @@ static void __cpuinit build_r4000_tlb_store_handler(void)
2140 dump_handler("r4000_tlb_store", handle_tlbs, handle_tlbs_size); 2130 dump_handler("r4000_tlb_store", handle_tlbs, handle_tlbs_size);
2141} 2131}
2142 2132
2143static void __cpuinit build_r4000_tlb_modify_handler(void) 2133static void build_r4000_tlb_modify_handler(void)
2144{ 2134{
2145 u32 *p = handle_tlbm; 2135 u32 *p = handle_tlbm;
2146 const int handle_tlbm_size = handle_tlbm_end - handle_tlbm; 2136 const int handle_tlbm_size = handle_tlbm_end - handle_tlbm;
@@ -2196,7 +2186,7 @@ static void __cpuinit build_r4000_tlb_modify_handler(void)
2196 dump_handler("r4000_tlb_modify", handle_tlbm, handle_tlbm_size); 2186 dump_handler("r4000_tlb_modify", handle_tlbm, handle_tlbm_size);
2197} 2187}
2198 2188
2199static void __cpuinit flush_tlb_handlers(void) 2189static void flush_tlb_handlers(void)
2200{ 2190{
2201 local_flush_icache_range((unsigned long)handle_tlbl, 2191 local_flush_icache_range((unsigned long)handle_tlbl,
2202 (unsigned long)handle_tlbl_end); 2192 (unsigned long)handle_tlbl_end);
@@ -2210,7 +2200,7 @@ static void __cpuinit flush_tlb_handlers(void)
2210#endif 2200#endif
2211} 2201}
2212 2202
2213void __cpuinit build_tlb_refill_handler(void) 2203void build_tlb_refill_handler(void)
2214{ 2204{
2215 /* 2205 /*
2216 * The refill handler is generated per-CPU, multi-node systems 2206 * The refill handler is generated per-CPU, multi-node systems
diff --git a/arch/mips/mm/uasm-micromips.c b/arch/mips/mm/uasm-micromips.c
index 162ee6d62788..060000fa653c 100644
--- a/arch/mips/mm/uasm-micromips.c
+++ b/arch/mips/mm/uasm-micromips.c
@@ -49,7 +49,7 @@
49 49
50#include "uasm.c" 50#include "uasm.c"
51 51
52static struct insn insn_table_MM[] __uasminitdata = { 52static struct insn insn_table_MM[] = {
53 { insn_addu, M(mm_pool32a_op, 0, 0, 0, 0, mm_addu32_op), RT | RS | RD }, 53 { insn_addu, M(mm_pool32a_op, 0, 0, 0, 0, mm_addu32_op), RT | RS | RD },
54 { insn_addiu, M(mm_addiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM }, 54 { insn_addiu, M(mm_addiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
55 { insn_and, M(mm_pool32a_op, 0, 0, 0, 0, mm_and_op), RT | RS | RD }, 55 { 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 = {
118 118
119#undef M 119#undef M
120 120
121static inline __uasminit u32 build_bimm(s32 arg) 121static inline u32 build_bimm(s32 arg)
122{ 122{
123 WARN(arg > 0xffff || arg < -0x10000, 123 WARN(arg > 0xffff || arg < -0x10000,
124 KERN_WARNING "Micro-assembler field overflow\n"); 124 KERN_WARNING "Micro-assembler field overflow\n");
@@ -128,7 +128,7 @@ static inline __uasminit u32 build_bimm(s32 arg)
128 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 1) & 0x7fff); 128 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 1) & 0x7fff);
129} 129}
130 130
131static inline __uasminit u32 build_jimm(u32 arg) 131static inline u32 build_jimm(u32 arg)
132{ 132{
133 133
134 WARN(arg & ~((JIMM_MASK << 2) | 1), 134 WARN(arg & ~((JIMM_MASK << 2) | 1),
@@ -141,7 +141,7 @@ static inline __uasminit u32 build_jimm(u32 arg)
141 * The order of opcode arguments is implicitly left to right, 141 * The order of opcode arguments is implicitly left to right,
142 * starting with RS and ending with FUNC or IMM. 142 * starting with RS and ending with FUNC or IMM.
143 */ 143 */
144static void __uasminit build_insn(u32 **buf, enum opcode opc, ...) 144static void build_insn(u32 **buf, enum opcode opc, ...)
145{ 145{
146 struct insn *ip = NULL; 146 struct insn *ip = NULL;
147 unsigned int i; 147 unsigned int i;
@@ -199,7 +199,7 @@ static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
199 (*buf)++; 199 (*buf)++;
200} 200}
201 201
202static inline void __uasminit 202static inline void
203__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab) 203__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab)
204{ 204{
205 long laddr = (long)lab->addr; 205 long laddr = (long)lab->addr;
diff --git a/arch/mips/mm/uasm-mips.c b/arch/mips/mm/uasm-mips.c
index 5fcdd8fe3e83..0c724589854e 100644
--- a/arch/mips/mm/uasm-mips.c
+++ b/arch/mips/mm/uasm-mips.c
@@ -49,7 +49,7 @@
49 49
50#include "uasm.c" 50#include "uasm.c"
51 51
52static struct insn insn_table[] __uasminitdata = { 52static struct insn insn_table[] = {
53 { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 53 { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
54 { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD }, 54 { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD },
55 { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 55 { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
@@ -119,7 +119,7 @@ static struct insn insn_table[] __uasminitdata = {
119 119
120#undef M 120#undef M
121 121
122static inline __uasminit u32 build_bimm(s32 arg) 122static inline u32 build_bimm(s32 arg)
123{ 123{
124 WARN(arg > 0x1ffff || arg < -0x20000, 124 WARN(arg > 0x1ffff || arg < -0x20000,
125 KERN_WARNING "Micro-assembler field overflow\n"); 125 KERN_WARNING "Micro-assembler field overflow\n");
@@ -129,7 +129,7 @@ static inline __uasminit u32 build_bimm(s32 arg)
129 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff); 129 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff);
130} 130}
131 131
132static inline __uasminit u32 build_jimm(u32 arg) 132static inline u32 build_jimm(u32 arg)
133{ 133{
134 WARN(arg & ~(JIMM_MASK << 2), 134 WARN(arg & ~(JIMM_MASK << 2),
135 KERN_WARNING "Micro-assembler field overflow\n"); 135 KERN_WARNING "Micro-assembler field overflow\n");
@@ -141,7 +141,7 @@ static inline __uasminit u32 build_jimm(u32 arg)
141 * The order of opcode arguments is implicitly left to right, 141 * The order of opcode arguments is implicitly left to right,
142 * starting with RS and ending with FUNC or IMM. 142 * starting with RS and ending with FUNC or IMM.
143 */ 143 */
144static void __uasminit build_insn(u32 **buf, enum opcode opc, ...) 144static void build_insn(u32 **buf, enum opcode opc, ...)
145{ 145{
146 struct insn *ip = NULL; 146 struct insn *ip = NULL;
147 unsigned int i; 147 unsigned int i;
@@ -187,7 +187,7 @@ static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
187 (*buf)++; 187 (*buf)++;
188} 188}
189 189
190static inline void __uasminit 190static inline void
191__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab) 191__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab)
192{ 192{
193 long laddr = (long)lab->addr; 193 long laddr = (long)lab->addr;
diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index 7eb5e4355d25..b9d14b6c7f58 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -63,35 +63,35 @@ struct insn {
63 enum fields fields; 63 enum fields fields;
64}; 64};
65 65
66static inline __uasminit u32 build_rs(u32 arg) 66static inline u32 build_rs(u32 arg)
67{ 67{
68 WARN(arg & ~RS_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 68 WARN(arg & ~RS_MASK, KERN_WARNING "Micro-assembler field overflow\n");
69 69
70 return (arg & RS_MASK) << RS_SH; 70 return (arg & RS_MASK) << RS_SH;
71} 71}
72 72
73static inline __uasminit u32 build_rt(u32 arg) 73static inline u32 build_rt(u32 arg)
74{ 74{
75 WARN(arg & ~RT_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 75 WARN(arg & ~RT_MASK, KERN_WARNING "Micro-assembler field overflow\n");
76 76
77 return (arg & RT_MASK) << RT_SH; 77 return (arg & RT_MASK) << RT_SH;
78} 78}
79 79
80static inline __uasminit u32 build_rd(u32 arg) 80static inline u32 build_rd(u32 arg)
81{ 81{
82 WARN(arg & ~RD_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 82 WARN(arg & ~RD_MASK, KERN_WARNING "Micro-assembler field overflow\n");
83 83
84 return (arg & RD_MASK) << RD_SH; 84 return (arg & RD_MASK) << RD_SH;
85} 85}
86 86
87static inline __uasminit u32 build_re(u32 arg) 87static inline u32 build_re(u32 arg)
88{ 88{
89 WARN(arg & ~RE_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 89 WARN(arg & ~RE_MASK, KERN_WARNING "Micro-assembler field overflow\n");
90 90
91 return (arg & RE_MASK) << RE_SH; 91 return (arg & RE_MASK) << RE_SH;
92} 92}
93 93
94static inline __uasminit u32 build_simm(s32 arg) 94static inline u32 build_simm(s32 arg)
95{ 95{
96 WARN(arg > 0x7fff || arg < -0x8000, 96 WARN(arg > 0x7fff || arg < -0x8000,
97 KERN_WARNING "Micro-assembler field overflow\n"); 97 KERN_WARNING "Micro-assembler field overflow\n");
@@ -99,14 +99,14 @@ static inline __uasminit u32 build_simm(s32 arg)
99 return arg & 0xffff; 99 return arg & 0xffff;
100} 100}
101 101
102static inline __uasminit u32 build_uimm(u32 arg) 102static inline u32 build_uimm(u32 arg)
103{ 103{
104 WARN(arg & ~IMM_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 104 WARN(arg & ~IMM_MASK, KERN_WARNING "Micro-assembler field overflow\n");
105 105
106 return arg & IMM_MASK; 106 return arg & IMM_MASK;
107} 107}
108 108
109static inline __uasminit u32 build_scimm(u32 arg) 109static inline u32 build_scimm(u32 arg)
110{ 110{
111 WARN(arg & ~SCIMM_MASK, 111 WARN(arg & ~SCIMM_MASK,
112 KERN_WARNING "Micro-assembler field overflow\n"); 112 KERN_WARNING "Micro-assembler field overflow\n");
@@ -114,21 +114,21 @@ static inline __uasminit u32 build_scimm(u32 arg)
114 return (arg & SCIMM_MASK) << SCIMM_SH; 114 return (arg & SCIMM_MASK) << SCIMM_SH;
115} 115}
116 116
117static inline __uasminit u32 build_func(u32 arg) 117static inline u32 build_func(u32 arg)
118{ 118{
119 WARN(arg & ~FUNC_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 119 WARN(arg & ~FUNC_MASK, KERN_WARNING "Micro-assembler field overflow\n");
120 120
121 return arg & FUNC_MASK; 121 return arg & FUNC_MASK;
122} 122}
123 123
124static inline __uasminit u32 build_set(u32 arg) 124static inline u32 build_set(u32 arg)
125{ 125{
126 WARN(arg & ~SET_MASK, KERN_WARNING "Micro-assembler field overflow\n"); 126 WARN(arg & ~SET_MASK, KERN_WARNING "Micro-assembler field overflow\n");
127 127
128 return arg & SET_MASK; 128 return arg & SET_MASK;
129} 129}
130 130
131static void __uasminit build_insn(u32 **buf, enum opcode opc, ...); 131static void build_insn(u32 **buf, enum opcode opc, ...);
132 132
133#define I_u1u2u3(op) \ 133#define I_u1u2u3(op) \
134Ip_u1u2u3(op) \ 134Ip_u1u2u3(op) \
@@ -286,7 +286,7 @@ I_u3u1u2(_ldx)
286 286
287#ifdef CONFIG_CPU_CAVIUM_OCTEON 287#ifdef CONFIG_CPU_CAVIUM_OCTEON
288#include <asm/octeon/octeon.h> 288#include <asm/octeon/octeon.h>
289void __uasminit ISAFUNC(uasm_i_pref)(u32 **buf, unsigned int a, signed int b, 289void ISAFUNC(uasm_i_pref)(u32 **buf, unsigned int a, signed int b,
290 unsigned int c) 290 unsigned int c)
291{ 291{
292 if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X) && a <= 24 && a != 5) 292 if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X) && a <= 24 && a != 5)
@@ -304,7 +304,7 @@ I_u2s3u1(_pref)
304#endif 304#endif
305 305
306/* Handle labels. */ 306/* Handle labels. */
307void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid) 307void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid)
308{ 308{
309 (*lab)->addr = addr; 309 (*lab)->addr = addr;
310 (*lab)->lab = lid; 310 (*lab)->lab = lid;
@@ -312,7 +312,7 @@ void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, in
312} 312}
313UASM_EXPORT_SYMBOL(ISAFUNC(uasm_build_label)); 313UASM_EXPORT_SYMBOL(ISAFUNC(uasm_build_label));
314 314
315int __uasminit ISAFUNC(uasm_in_compat_space_p)(long addr) 315int ISAFUNC(uasm_in_compat_space_p)(long addr)
316{ 316{
317 /* Is this address in 32bit compat space? */ 317 /* Is this address in 32bit compat space? */
318#ifdef CONFIG_64BIT 318#ifdef CONFIG_64BIT
@@ -323,7 +323,7 @@ int __uasminit ISAFUNC(uasm_in_compat_space_p)(long addr)
323} 323}
324UASM_EXPORT_SYMBOL(ISAFUNC(uasm_in_compat_space_p)); 324UASM_EXPORT_SYMBOL(ISAFUNC(uasm_in_compat_space_p));
325 325
326static int __uasminit uasm_rel_highest(long val) 326static int uasm_rel_highest(long val)
327{ 327{
328#ifdef CONFIG_64BIT 328#ifdef CONFIG_64BIT
329 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000; 329 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000;
@@ -332,7 +332,7 @@ static int __uasminit uasm_rel_highest(long val)
332#endif 332#endif
333} 333}
334 334
335static int __uasminit uasm_rel_higher(long val) 335static int uasm_rel_higher(long val)
336{ 336{
337#ifdef CONFIG_64BIT 337#ifdef CONFIG_64BIT
338 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000; 338 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000;
@@ -341,19 +341,19 @@ static int __uasminit uasm_rel_higher(long val)
341#endif 341#endif
342} 342}
343 343
344int __uasminit ISAFUNC(uasm_rel_hi)(long val) 344int ISAFUNC(uasm_rel_hi)(long val)
345{ 345{
346 return ((((val + 0x8000L) >> 16) & 0xffff) ^ 0x8000) - 0x8000; 346 return ((((val + 0x8000L) >> 16) & 0xffff) ^ 0x8000) - 0x8000;
347} 347}
348UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_hi)); 348UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_hi));
349 349
350int __uasminit ISAFUNC(uasm_rel_lo)(long val) 350int ISAFUNC(uasm_rel_lo)(long val)
351{ 351{
352 return ((val & 0xffff) ^ 0x8000) - 0x8000; 352 return ((val & 0xffff) ^ 0x8000) - 0x8000;
353} 353}
354UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_lo)); 354UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_lo));
355 355
356void __uasminit ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr) 356void ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr)
357{ 357{
358 if (!ISAFUNC(uasm_in_compat_space_p)(addr)) { 358 if (!ISAFUNC(uasm_in_compat_space_p)(addr)) {
359 ISAFUNC(uasm_i_lui)(buf, rs, uasm_rel_highest(addr)); 359 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)
371} 371}
372UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA_mostly)); 372UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA_mostly));
373 373
374void __uasminit ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr) 374void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr)
375{ 375{
376 ISAFUNC(UASM_i_LA_mostly)(buf, rs, addr); 376 ISAFUNC(UASM_i_LA_mostly)(buf, rs, addr);
377 if (ISAFUNC(uasm_rel_lo(addr))) { 377 if (ISAFUNC(uasm_rel_lo(addr))) {
@@ -386,8 +386,7 @@ void __uasminit ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr)
386UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA)); 386UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA));
387 387
388/* Handle relocations. */ 388/* Handle relocations. */
389void __uasminit 389void ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid)
390ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid)
391{ 390{
392 (*rel)->addr = addr; 391 (*rel)->addr = addr;
393 (*rel)->type = R_MIPS_PC16; 392 (*rel)->type = R_MIPS_PC16;
@@ -396,11 +395,11 @@ ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid)
396} 395}
397UASM_EXPORT_SYMBOL(ISAFUNC(uasm_r_mips_pc16)); 396UASM_EXPORT_SYMBOL(ISAFUNC(uasm_r_mips_pc16));
398 397
399static inline void __uasminit 398static inline void __resolve_relocs(struct uasm_reloc *rel,
400__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab); 399 struct uasm_label *lab);
401 400
402void __uasminit 401void ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel,
403ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, struct uasm_label *lab) 402 struct uasm_label *lab)
404{ 403{
405 struct uasm_label *l; 404 struct uasm_label *l;
406 405
@@ -411,8 +410,8 @@ ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, struct uasm_label *lab)
411} 410}
412UASM_EXPORT_SYMBOL(ISAFUNC(uasm_resolve_relocs)); 411UASM_EXPORT_SYMBOL(ISAFUNC(uasm_resolve_relocs));
413 412
414void __uasminit 413void ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end,
415ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end, long off) 414 long off)
416{ 415{
417 for (; rel->lab != UASM_LABEL_INVALID; rel++) 416 for (; rel->lab != UASM_LABEL_INVALID; rel++)
418 if (rel->addr >= first && rel->addr < end) 417 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
420} 419}
421UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_relocs)); 420UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_relocs));
422 421
423void __uasminit 422void ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end,
424ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end, long off) 423 long off)
425{ 424{
426 for (; lab->lab != UASM_LABEL_INVALID; lab++) 425 for (; lab->lab != UASM_LABEL_INVALID; lab++)
427 if (lab->addr >= first && lab->addr < end) 426 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
429} 428}
430UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_labels)); 429UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_labels));
431 430
432void __uasminit 431void ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab,
433ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, u32 *first, 432 u32 *first, u32 *end, u32 *target)
434 u32 *end, u32 *target)
435{ 433{
436 long off = (long)(target - first); 434 long off = (long)(target - first);
437 435
@@ -442,7 +440,7 @@ ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, u32 *
442} 440}
443UASM_EXPORT_SYMBOL(ISAFUNC(uasm_copy_handler)); 441UASM_EXPORT_SYMBOL(ISAFUNC(uasm_copy_handler));
444 442
445int __uasminit ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr) 443int ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr)
446{ 444{
447 for (; rel->lab != UASM_LABEL_INVALID; rel++) { 445 for (; rel->lab != UASM_LABEL_INVALID; rel++) {
448 if (rel->addr == addr 446 if (rel->addr == addr
@@ -456,83 +454,79 @@ int __uasminit ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr)
456UASM_EXPORT_SYMBOL(ISAFUNC(uasm_insn_has_bdelay)); 454UASM_EXPORT_SYMBOL(ISAFUNC(uasm_insn_has_bdelay));
457 455
458/* Convenience functions for labeled branches. */ 456/* Convenience functions for labeled branches. */
459void __uasminit 457void ISAFUNC(uasm_il_bltz)(u32 **p, struct uasm_reloc **r, unsigned int reg,
460ISAFUNC(uasm_il_bltz)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) 458 int lid)
461{ 459{
462 uasm_r_mips_pc16(r, *p, lid); 460 uasm_r_mips_pc16(r, *p, lid);
463 ISAFUNC(uasm_i_bltz)(p, reg, 0); 461 ISAFUNC(uasm_i_bltz)(p, reg, 0);
464} 462}
465UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bltz)); 463UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bltz));
466 464
467void __uasminit 465void ISAFUNC(uasm_il_b)(u32 **p, struct uasm_reloc **r, int lid)
468ISAFUNC(uasm_il_b)(u32 **p, struct uasm_reloc **r, int lid)
469{ 466{
470 uasm_r_mips_pc16(r, *p, lid); 467 uasm_r_mips_pc16(r, *p, lid);
471 ISAFUNC(uasm_i_b)(p, 0); 468 ISAFUNC(uasm_i_b)(p, 0);
472} 469}
473UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_b)); 470UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_b));
474 471
475void __uasminit 472void ISAFUNC(uasm_il_beqz)(u32 **p, struct uasm_reloc **r, unsigned int reg,
476ISAFUNC(uasm_il_beqz)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) 473 int lid)
477{ 474{
478 uasm_r_mips_pc16(r, *p, lid); 475 uasm_r_mips_pc16(r, *p, lid);
479 ISAFUNC(uasm_i_beqz)(p, reg, 0); 476 ISAFUNC(uasm_i_beqz)(p, reg, 0);
480} 477}
481UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqz)); 478UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqz));
482 479
483void __uasminit 480void ISAFUNC(uasm_il_beqzl)(u32 **p, struct uasm_reloc **r, unsigned int reg,
484ISAFUNC(uasm_il_beqzl)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) 481 int lid)
485{ 482{
486 uasm_r_mips_pc16(r, *p, lid); 483 uasm_r_mips_pc16(r, *p, lid);
487 ISAFUNC(uasm_i_beqzl)(p, reg, 0); 484 ISAFUNC(uasm_i_beqzl)(p, reg, 0);
488} 485}
489UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqzl)); 486UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqzl));
490 487
491void __uasminit 488void ISAFUNC(uasm_il_bne)(u32 **p, struct uasm_reloc **r, unsigned int reg1,
492ISAFUNC(uasm_il_bne)(u32 **p, struct uasm_reloc **r, unsigned int reg1, 489 unsigned int reg2, int lid)
493 unsigned int reg2, int lid)
494{ 490{
495 uasm_r_mips_pc16(r, *p, lid); 491 uasm_r_mips_pc16(r, *p, lid);
496 ISAFUNC(uasm_i_bne)(p, reg1, reg2, 0); 492 ISAFUNC(uasm_i_bne)(p, reg1, reg2, 0);
497} 493}
498UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bne)); 494UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bne));
499 495
500void __uasminit 496void ISAFUNC(uasm_il_bnez)(u32 **p, struct uasm_reloc **r, unsigned int reg,
501ISAFUNC(uasm_il_bnez)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) 497 int lid)
502{ 498{
503 uasm_r_mips_pc16(r, *p, lid); 499 uasm_r_mips_pc16(r, *p, lid);
504 ISAFUNC(uasm_i_bnez)(p, reg, 0); 500 ISAFUNC(uasm_i_bnez)(p, reg, 0);
505} 501}
506UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bnez)); 502UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bnez));
507 503
508void __uasminit 504void ISAFUNC(uasm_il_bgezl)(u32 **p, struct uasm_reloc **r, unsigned int reg,
509ISAFUNC(uasm_il_bgezl)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) 505 int lid)
510{ 506{
511 uasm_r_mips_pc16(r, *p, lid); 507 uasm_r_mips_pc16(r, *p, lid);
512 ISAFUNC(uasm_i_bgezl)(p, reg, 0); 508 ISAFUNC(uasm_i_bgezl)(p, reg, 0);
513} 509}
514UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgezl)); 510UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgezl));
515 511
516void __uasminit 512void ISAFUNC(uasm_il_bgez)(u32 **p, struct uasm_reloc **r, unsigned int reg,
517ISAFUNC(uasm_il_bgez)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) 513 int lid)
518{ 514{
519 uasm_r_mips_pc16(r, *p, lid); 515 uasm_r_mips_pc16(r, *p, lid);
520 ISAFUNC(uasm_i_bgez)(p, reg, 0); 516 ISAFUNC(uasm_i_bgez)(p, reg, 0);
521} 517}
522UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgez)); 518UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgez));
523 519
524void __uasminit 520void ISAFUNC(uasm_il_bbit0)(u32 **p, struct uasm_reloc **r, unsigned int reg,
525ISAFUNC(uasm_il_bbit0)(u32 **p, struct uasm_reloc **r, unsigned int reg, 521 unsigned int bit, int lid)
526 unsigned int bit, int lid)
527{ 522{
528 uasm_r_mips_pc16(r, *p, lid); 523 uasm_r_mips_pc16(r, *p, lid);
529 ISAFUNC(uasm_i_bbit0)(p, reg, bit, 0); 524 ISAFUNC(uasm_i_bbit0)(p, reg, bit, 0);
530} 525}
531UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bbit0)); 526UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bbit0));
532 527
533void __uasminit 528void ISAFUNC(uasm_il_bbit1)(u32 **p, struct uasm_reloc **r, unsigned int reg,
534ISAFUNC(uasm_il_bbit1)(u32 **p, struct uasm_reloc **r, unsigned int reg, 529 unsigned int bit, int lid)
535 unsigned int bit, int lid)
536{ 530{
537 uasm_r_mips_pc16(r, *p, lid); 531 uasm_r_mips_pc16(r, *p, lid);
538 ISAFUNC(uasm_i_bbit1)(p, reg, bit, 0); 532 ISAFUNC(uasm_i_bbit1)(p, reg, bit, 0);
diff --git a/arch/mips/mti-malta/malta-smtc.c b/arch/mips/mti-malta/malta-smtc.c
index becbf47506a5..c4849904f013 100644
--- a/arch/mips/mti-malta/malta-smtc.c
+++ b/arch/mips/mti-malta/malta-smtc.c
@@ -32,7 +32,7 @@ static void msmtc_send_ipi_mask(const struct cpumask *mask, unsigned int action)
32/* 32/*
33 * Post-config but pre-boot cleanup entry point 33 * Post-config but pre-boot cleanup entry point
34 */ 34 */
35static void __cpuinit msmtc_init_secondary(void) 35static void msmtc_init_secondary(void)
36{ 36{
37 int myvpe; 37 int myvpe;
38 38
@@ -53,7 +53,7 @@ static void __cpuinit msmtc_init_secondary(void)
53/* 53/*
54 * Platform "CPU" startup hook 54 * Platform "CPU" startup hook
55 */ 55 */
56static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle) 56static void msmtc_boot_secondary(int cpu, struct task_struct *idle)
57{ 57{
58 smtc_boot_secondary(cpu, idle); 58 smtc_boot_secondary(cpu, idle);
59} 59}
@@ -61,7 +61,7 @@ static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle)
61/* 61/*
62 * SMP initialization finalization entry point 62 * SMP initialization finalization entry point
63 */ 63 */
64static void __cpuinit msmtc_smp_finish(void) 64static void msmtc_smp_finish(void)
65{ 65{
66 smtc_smp_finish(); 66 smtc_smp_finish();
67} 67}
diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c
index 0ad305f75802..53aad4a35375 100644
--- a/arch/mips/mti-malta/malta-time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -150,7 +150,7 @@ static void __init plat_perf_setup(void)
150 } 150 }
151} 151}
152 152
153unsigned int __cpuinit get_c0_compare_int(void) 153unsigned int get_c0_compare_int(void)
154{ 154{
155#ifdef MSC01E_INT_BASE 155#ifdef MSC01E_INT_BASE
156 if (cpu_has_veic) { 156 if (cpu_has_veic) {
diff --git a/arch/mips/mti-sead3/sead3-time.c b/arch/mips/mti-sead3/sead3-time.c
index 96b42eb9b5e2..a43ea3cc0a3b 100644
--- a/arch/mips/mti-sead3/sead3-time.c
+++ b/arch/mips/mti-sead3/sead3-time.c
@@ -91,7 +91,7 @@ static void __init plat_perf_setup(void)
91 } 91 }
92} 92}
93 93
94unsigned int __cpuinit get_c0_compare_int(void) 94unsigned int get_c0_compare_int(void)
95{ 95{
96 if (cpu_has_vint) 96 if (cpu_has_vint)
97 set_vi_handler(cp0_compare_irq, mips_timer_dispatch); 97 set_vi_handler(cp0_compare_irq, mips_timer_dispatch);
diff --git a/arch/mips/netlogic/common/irq.c b/arch/mips/netlogic/common/irq.c
index 73facb2b33bb..1c7e3a1b81ab 100644
--- a/arch/mips/netlogic/common/irq.c
+++ b/arch/mips/netlogic/common/irq.c
@@ -40,6 +40,10 @@
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/irq.h> 41#include <linux/irq.h>
42 42
43#include <linux/irqdomain.h>
44#include <linux/of_address.h>
45#include <linux/of_irq.h>
46
43#include <asm/errno.h> 47#include <asm/errno.h>
44#include <asm/signal.h> 48#include <asm/signal.h>
45#include <asm/ptrace.h> 49#include <asm/ptrace.h>
@@ -223,17 +227,6 @@ static void nlm_init_node_irqs(int node)
223 nodep->irqmask = irqmask; 227 nodep->irqmask = irqmask;
224} 228}
225 229
226void __init arch_init_irq(void)
227{
228 /* Initialize the irq descriptors */
229 nlm_init_percpu_irqs();
230 nlm_init_node_irqs(0);
231 write_c0_eimr(nlm_current_node()->irqmask);
232#if defined(CONFIG_CPU_XLR)
233 nlm_setup_fmn_irq();
234#endif
235}
236
237void nlm_smp_irq_init(int hwcpuid) 230void nlm_smp_irq_init(int hwcpuid)
238{ 231{
239 int node, cpu; 232 int node, cpu;
@@ -266,3 +259,56 @@ asmlinkage void plat_irq_dispatch(void)
266 /* top level irq handling */ 259 /* top level irq handling */
267 do_IRQ(nlm_irq_to_xirq(node, i)); 260 do_IRQ(nlm_irq_to_xirq(node, i));
268} 261}
262
263#ifdef CONFIG_OF
264static struct irq_domain *xlp_pic_domain;
265
266static const struct irq_domain_ops xlp_pic_irq_domain_ops = {
267 .xlate = irq_domain_xlate_onetwocell,
268};
269
270static int __init xlp_of_pic_init(struct device_node *node,
271 struct device_node *parent)
272{
273 const int n_picirqs = PIC_IRT_LAST_IRQ - PIC_IRQ_BASE + 1;
274 struct resource res;
275 int socid, ret;
276
277 /* we need a hack to get the PIC's SoC chip id */
278 ret = of_address_to_resource(node, 0, &res);
279 if (ret < 0) {
280 pr_err("PIC %s: reg property not found!\n", node->name);
281 return -EINVAL;
282 }
283 socid = (res.start >> 18) & 0x3;
284 xlp_pic_domain = irq_domain_add_legacy(node, n_picirqs,
285 nlm_irq_to_xirq(socid, PIC_IRQ_BASE), PIC_IRQ_BASE,
286 &xlp_pic_irq_domain_ops, NULL);
287 if (xlp_pic_domain == NULL) {
288 pr_err("PIC %s: Creating legacy domain failed!\n", node->name);
289 return -EINVAL;
290 }
291 pr_info("Node %d: IRQ domain created for PIC@%pa\n", socid,
292 &res.start);
293 return 0;
294}
295
296static struct of_device_id __initdata xlp_pic_irq_ids[] = {
297 { .compatible = "netlogic,xlp-pic", .data = xlp_of_pic_init },
298 {},
299};
300#endif
301
302void __init arch_init_irq(void)
303{
304 /* Initialize the irq descriptors */
305 nlm_init_percpu_irqs();
306 nlm_init_node_irqs(0);
307 write_c0_eimr(nlm_current_node()->irqmask);
308#if defined(CONFIG_CPU_XLR)
309 nlm_setup_fmn_irq();
310#endif
311#if defined(CONFIG_OF)
312 of_irq_init(xlp_pic_irq_ids);
313#endif
314}
diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c
index 885d293b61da..4e35d9c453e2 100644
--- a/arch/mips/netlogic/common/smp.c
+++ b/arch/mips/netlogic/common/smp.c
@@ -116,7 +116,7 @@ void nlm_early_init_secondary(int cpu)
116/* 116/*
117 * Code to run on secondary just after probing the CPU 117 * Code to run on secondary just after probing the CPU
118 */ 118 */
119static void __cpuinit nlm_init_secondary(void) 119static void nlm_init_secondary(void)
120{ 120{
121 int hwtid; 121 int hwtid;
122 122
@@ -252,7 +252,7 @@ unsupp:
252 return 0; 252 return 0;
253} 253}
254 254
255int __cpuinit nlm_wakeup_secondary_cpus(void) 255int nlm_wakeup_secondary_cpus(void)
256{ 256{
257 u32 *reset_data; 257 u32 *reset_data;
258 int threadmode; 258 int threadmode;
diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S
index 528c46c5a170..aa6cff0a229b 100644
--- a/arch/mips/netlogic/common/smpboot.S
+++ b/arch/mips/netlogic/common/smpboot.S
@@ -70,7 +70,6 @@ FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
70 nop 70 nop
71 /* not reached */ 71 /* not reached */
72 72
73 __CPUINIT
74NESTED(nlm_boot_secondary_cpus, 16, sp) 73NESTED(nlm_boot_secondary_cpus, 16, sp)
75 /* Initialize CP0 Status */ 74 /* Initialize CP0 Status */
76 move t1, zero 75 move t1, zero
@@ -94,7 +93,6 @@ NESTED(nlm_boot_secondary_cpus, 16, sp)
94 jr t0 93 jr t0
95 nop 94 nop
96END(nlm_boot_secondary_cpus) 95END(nlm_boot_secondary_cpus)
97 __FINIT
98 96
99/* 97/*
100 * In case of RMIboot bootloader which is used on XLR boards, the CPUs 98 * In case of RMIboot bootloader which is used on XLR boards, the CPUs
@@ -102,7 +100,6 @@ END(nlm_boot_secondary_cpus)
102 * This will get them out of the bootloader code and into linux. Needed 100 * This will get them out of the bootloader code and into linux. Needed
103 * because the bootloader area will be taken and initialized by linux. 101 * because the bootloader area will be taken and initialized by linux.
104 */ 102 */
105 __CPUINIT
106NESTED(nlm_rmiboot_preboot, 16, sp) 103NESTED(nlm_rmiboot_preboot, 16, sp)
107 mfc0 t0, $15, 1 /* read ebase */ 104 mfc0 t0, $15, 1 /* read ebase */
108 andi t0, 0x1f /* t0 has the processor_id() */ 105 andi t0, 0x1f /* t0 has the processor_id() */
@@ -140,4 +137,3 @@ NESTED(nlm_rmiboot_preboot, 16, sp)
140 b 1b 137 b 1b
141 nop 138 nop
142END(nlm_rmiboot_preboot) 139END(nlm_rmiboot_preboot)
143 __FINIT
diff --git a/arch/mips/netlogic/common/time.c b/arch/mips/netlogic/common/time.c
index 5c56555380bb..045a396c57ce 100644
--- a/arch/mips/netlogic/common/time.c
+++ b/arch/mips/netlogic/common/time.c
@@ -54,7 +54,7 @@
54#error "Unknown CPU" 54#error "Unknown CPU"
55#endif 55#endif
56 56
57unsigned int __cpuinit get_c0_compare_int(void) 57unsigned int get_c0_compare_int(void)
58{ 58{
59 return IRQ_TIMER; 59 return IRQ_TIMER;
60} 60}
diff --git a/arch/mips/netlogic/dts/xlp_evp.dts b/arch/mips/netlogic/dts/xlp_evp.dts
index e14f42308064..06407033678e 100644
--- a/arch/mips/netlogic/dts/xlp_evp.dts
+++ b/arch/mips/netlogic/dts/xlp_evp.dts
@@ -76,10 +76,11 @@
76 }; 76 };
77 }; 77 };
78 pic: pic@4000 { 78 pic: pic@4000 {
79 interrupt-controller; 79 compatible = "netlogic,xlp-pic";
80 #address-cells = <0>; 80 #address-cells = <0>;
81 #interrupt-cells = <1>; 81 #interrupt-cells = <1>;
82 reg = <0 0x4000 0x200>; 82 reg = <0 0x4000 0x200>;
83 interrupt-controller;
83 }; 84 };
84 85
85 nor_flash@1,0 { 86 nor_flash@1,0 {
diff --git a/arch/mips/netlogic/dts/xlp_svp.dts b/arch/mips/netlogic/dts/xlp_svp.dts
index 8af4bdbe5d99..9c5db102df53 100644
--- a/arch/mips/netlogic/dts/xlp_svp.dts
+++ b/arch/mips/netlogic/dts/xlp_svp.dts
@@ -76,10 +76,11 @@
76 }; 76 };
77 }; 77 };
78 pic: pic@4000 { 78 pic: pic@4000 {
79 interrupt-controller; 79 compatible = "netlogic,xlp-pic";
80 #address-cells = <0>; 80 #address-cells = <0>;
81 #interrupt-cells = <1>; 81 #interrupt-cells = <1>;
82 reg = <0 0x4000 0x200>; 82 reg = <0 0x4000 0x200>;
83 interrupt-controller;
83 }; 84 };
84 85
85 nor_flash@1,0 { 86 nor_flash@1,0 {
diff --git a/arch/mips/netlogic/xlp/usb-init.c b/arch/mips/netlogic/xlp/usb-init.c
index 9c401dd78337..ef3897ef0dc7 100644
--- a/arch/mips/netlogic/xlp/usb-init.c
+++ b/arch/mips/netlogic/xlp/usb-init.c
@@ -119,7 +119,7 @@ static u64 xlp_usb_dmamask = ~(u32)0;
119static void nlm_usb_fixup_final(struct pci_dev *dev) 119static void nlm_usb_fixup_final(struct pci_dev *dev)
120{ 120{
121 dev->dev.dma_mask = &xlp_usb_dmamask; 121 dev->dev.dma_mask = &xlp_usb_dmamask;
122 dev->dev.coherent_dma_mask = DMA_BIT_MASK(64); 122 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
123 switch (dev->devfn) { 123 switch (dev->devfn) {
124 case 0x10: 124 case 0x10:
125 dev->irq = PIC_EHCI_0_IRQ; 125 dev->irq = PIC_EHCI_0_IRQ;
diff --git a/arch/mips/netlogic/xlr/wakeup.c b/arch/mips/netlogic/xlr/wakeup.c
index c06e4c9f0478..9fb81fa6272a 100644
--- a/arch/mips/netlogic/xlr/wakeup.c
+++ b/arch/mips/netlogic/xlr/wakeup.c
@@ -49,7 +49,7 @@
49#include <asm/netlogic/xlr/iomap.h> 49#include <asm/netlogic/xlr/iomap.h>
50#include <asm/netlogic/xlr/pic.h> 50#include <asm/netlogic/xlr/pic.h>
51 51
52int __cpuinit xlr_wakeup_secondary_cpus(void) 52int xlr_wakeup_secondary_cpus(void)
53{ 53{
54 struct nlm_soc_info *nodep; 54 struct nlm_soc_info *nodep;
55 unsigned int i, j, boot_cpu; 55 unsigned int i, j, boot_cpu;
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
index 7b2ac81e1f59..162b4cb29dba 100644
--- a/arch/mips/pci/pci-ip27.c
+++ b/arch/mips/pci/pci-ip27.c
@@ -42,7 +42,7 @@ int irq_to_slot[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS];
42 42
43extern struct pci_ops bridge_pci_ops; 43extern struct pci_ops bridge_pci_ops;
44 44
45int __cpuinit bridge_probe(nasid_t nasid, int widget_id, int masterwid) 45int bridge_probe(nasid_t nasid, int widget_id, int masterwid)
46{ 46{
47 unsigned long offset = NODE_OFFSET(nasid); 47 unsigned long offset = NODE_OFFSET(nasid);
48 struct bridge_controller *bc; 48 struct bridge_controller *bc;
diff --git a/arch/mips/pmcs-msp71xx/msp_smtc.c b/arch/mips/pmcs-msp71xx/msp_smtc.c
index c8dcc1c01e18..6b5607fce279 100644
--- a/arch/mips/pmcs-msp71xx/msp_smtc.c
+++ b/arch/mips/pmcs-msp71xx/msp_smtc.c
@@ -33,7 +33,7 @@ static void msp_smtc_send_ipi_mask(const struct cpumask *mask,
33/* 33/*
34 * Post-config but pre-boot cleanup entry point 34 * Post-config but pre-boot cleanup entry point
35 */ 35 */
36static void __cpuinit msp_smtc_init_secondary(void) 36static void msp_smtc_init_secondary(void)
37{ 37{
38 int myvpe; 38 int myvpe;
39 39
@@ -48,8 +48,7 @@ static void __cpuinit msp_smtc_init_secondary(void)
48/* 48/*
49 * Platform "CPU" startup hook 49 * Platform "CPU" startup hook
50 */ 50 */
51static void __cpuinit msp_smtc_boot_secondary(int cpu, 51static void msp_smtc_boot_secondary(int cpu, struct task_struct *idle)
52 struct task_struct *idle)
53{ 52{
54 smtc_boot_secondary(cpu, idle); 53 smtc_boot_secondary(cpu, idle);
55} 54}
@@ -57,7 +56,7 @@ static void __cpuinit msp_smtc_boot_secondary(int cpu,
57/* 56/*
58 * SMP initialization finalization entry point 57 * SMP initialization finalization entry point
59 */ 58 */
60static void __cpuinit msp_smtc_smp_finish(void) 59static void msp_smtc_smp_finish(void)
61{ 60{
62 smtc_smp_finish(); 61 smtc_smp_finish();
63} 62}
diff --git a/arch/mips/pmcs-msp71xx/msp_time.c b/arch/mips/pmcs-msp71xx/msp_time.c
index 8f12ecc55ace..fea917be0ff1 100644
--- a/arch/mips/pmcs-msp71xx/msp_time.c
+++ b/arch/mips/pmcs-msp71xx/msp_time.c
@@ -88,7 +88,7 @@ void __init plat_time_init(void)
88 mips_hpt_frequency = cpu_rate/2; 88 mips_hpt_frequency = cpu_rate/2;
89} 89}
90 90
91unsigned int __cpuinit get_c0_compare_int(void) 91unsigned int get_c0_compare_int(void)
92{ 92{
93 /* MIPS_MT modes may want timer for second VPE */ 93 /* MIPS_MT modes may want timer for second VPE */
94 if ((get_current_vpe()) && !tim_installed) { 94 if ((get_current_vpe()) && !tim_installed) {
diff --git a/arch/mips/pnx833x/common/interrupts.c b/arch/mips/pnx833x/common/interrupts.c
index a4a90596c0ad..e460865873c1 100644
--- a/arch/mips/pnx833x/common/interrupts.c
+++ b/arch/mips/pnx833x/common/interrupts.c
@@ -281,7 +281,7 @@ void __init arch_init_irq(void)
281 write_c0_status(read_c0_status() | IE_IRQ2); 281 write_c0_status(read_c0_status() | IE_IRQ2);
282} 282}
283 283
284unsigned int __cpuinit get_c0_compare_int(void) 284unsigned int get_c0_compare_int(void)
285{ 285{
286 if (cpu_has_vint) 286 if (cpu_has_vint)
287 set_vi_handler(cp0_compare_irq, pnx833x_timer_dispatch); 287 set_vi_handler(cp0_compare_irq, pnx833x_timer_dispatch);
diff --git a/arch/mips/powertv/time.c b/arch/mips/powertv/time.c
index 9fd7b67f2af7..f38b0d45eca9 100644
--- a/arch/mips/powertv/time.c
+++ b/arch/mips/powertv/time.c
@@ -25,7 +25,7 @@
25 25
26#include "powertv-clock.h" 26#include "powertv-clock.h"
27 27
28unsigned int __cpuinit get_c0_compare_int(void) 28unsigned int get_c0_compare_int(void)
29{ 29{
30 return irq_mips_timer; 30 return irq_mips_timer;
31} 31}
diff --git a/arch/mips/ralink/irq.c b/arch/mips/ralink/irq.c
index 320b1f1043ff..781b3d14a489 100644
--- a/arch/mips/ralink/irq.c
+++ b/arch/mips/ralink/irq.c
@@ -73,7 +73,7 @@ static struct irq_chip ralink_intc_irq_chip = {
73 .irq_mask_ack = ralink_intc_irq_mask, 73 .irq_mask_ack = ralink_intc_irq_mask,
74}; 74};
75 75
76unsigned int __cpuinit get_c0_compare_int(void) 76unsigned int get_c0_compare_int(void)
77{ 77{
78 return CP0_LEGACY_COMPARE_IRQ; 78 return CP0_LEGACY_COMPARE_IRQ;
79} 79}
diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c
index d41b1c6fb032..ee736bd103f8 100644
--- a/arch/mips/sgi-ip27/ip27-init.c
+++ b/arch/mips/sgi-ip27/ip27-init.c
@@ -54,7 +54,7 @@ extern void pcibr_setup(cnodeid_t);
54 54
55extern void xtalk_probe_node(cnodeid_t nid); 55extern void xtalk_probe_node(cnodeid_t nid);
56 56
57static void __cpuinit per_hub_init(cnodeid_t cnode) 57static void per_hub_init(cnodeid_t cnode)
58{ 58{
59 struct hub_data *hub = hub_data(cnode); 59 struct hub_data *hub = hub_data(cnode);
60 nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); 60 nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode);
@@ -110,7 +110,7 @@ static void __cpuinit per_hub_init(cnodeid_t cnode)
110 } 110 }
111} 111}
112 112
113void __cpuinit per_cpu_init(void) 113void per_cpu_init(void)
114{ 114{
115 int cpu = smp_processor_id(); 115 int cpu = smp_processor_id();
116 int slice = LOCAL_HUB_L(PI_CPU_NUM); 116 int slice = LOCAL_HUB_L(PI_CPU_NUM);
diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c
index f94638141b20..f4ea8aa79ba2 100644
--- a/arch/mips/sgi-ip27/ip27-smp.c
+++ b/arch/mips/sgi-ip27/ip27-smp.c
@@ -173,12 +173,12 @@ static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action)
173 ip27_send_ipi_single(i, action); 173 ip27_send_ipi_single(i, action);
174} 174}
175 175
176static void __cpuinit ip27_init_secondary(void) 176static void ip27_init_secondary(void)
177{ 177{
178 per_cpu_init(); 178 per_cpu_init();
179} 179}
180 180
181static void __cpuinit ip27_smp_finish(void) 181static void ip27_smp_finish(void)
182{ 182{
183 extern void hub_rt_clock_event_init(void); 183 extern void hub_rt_clock_event_init(void);
184 184
@@ -195,7 +195,7 @@ static void __init ip27_cpus_done(void)
195 * set sp to the kernel stack of the newly created idle process, gp to the proc 195 * set sp to the kernel stack of the newly created idle process, gp to the proc
196 * struct so that current_thread_info() will work. 196 * struct so that current_thread_info() will work.
197 */ 197 */
198static void __cpuinit ip27_boot_secondary(int cpu, struct task_struct *idle) 198static void ip27_boot_secondary(int cpu, struct task_struct *idle)
199{ 199{
200 unsigned long gp = (unsigned long)task_thread_info(idle); 200 unsigned long gp = (unsigned long)task_thread_info(idle);
201 unsigned long sp = __KSTK_TOS(idle); 201 unsigned long sp = __KSTK_TOS(idle);
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 2e21b761cb9c..1d97eaba0c5f 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -106,7 +106,7 @@ struct irqaction hub_rt_irqaction = {
106#define NSEC_PER_CYCLE 800 106#define NSEC_PER_CYCLE 800
107#define CYCLES_PER_SEC (NSEC_PER_SEC / NSEC_PER_CYCLE) 107#define CYCLES_PER_SEC (NSEC_PER_SEC / NSEC_PER_CYCLE)
108 108
109void __cpuinit hub_rt_clock_event_init(void) 109void hub_rt_clock_event_init(void)
110{ 110{
111 unsigned int cpu = smp_processor_id(); 111 unsigned int cpu = smp_processor_id();
112 struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu); 112 struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu);
@@ -173,7 +173,7 @@ void __init plat_time_init(void)
173 hub_rt_clock_event_init(); 173 hub_rt_clock_event_init();
174} 174}
175 175
176void __cpuinit cpu_time_init(void) 176void cpu_time_init(void)
177{ 177{
178 lboard_t *board; 178 lboard_t *board;
179 klcpu_t *cpu; 179 klcpu_t *cpu;
@@ -194,7 +194,7 @@ void __cpuinit cpu_time_init(void)
194 set_c0_status(SRB_TIMOCLK); 194 set_c0_status(SRB_TIMOCLK);
195} 195}
196 196
197void __cpuinit hub_rtc_init(cnodeid_t cnode) 197void hub_rtc_init(cnodeid_t cnode)
198{ 198{
199 199
200 /* 200 /*
diff --git a/arch/mips/sgi-ip27/ip27-xtalk.c b/arch/mips/sgi-ip27/ip27-xtalk.c
index a4df7d0f6f12..d59b820f528d 100644
--- a/arch/mips/sgi-ip27/ip27-xtalk.c
+++ b/arch/mips/sgi-ip27/ip27-xtalk.c
@@ -23,7 +23,7 @@
23 23
24extern int bridge_probe(nasid_t nasid, int widget, int masterwid); 24extern int bridge_probe(nasid_t nasid, int widget, int masterwid);
25 25
26static int __cpuinit probe_one_port(nasid_t nasid, int widget, int masterwid) 26static int probe_one_port(nasid_t nasid, int widget, int masterwid)
27{ 27{
28 widgetreg_t widget_id; 28 widgetreg_t widget_id;
29 xwidget_part_num_t partnum; 29 xwidget_part_num_t partnum;
@@ -47,7 +47,7 @@ static int __cpuinit probe_one_port(nasid_t nasid, int widget, int masterwid)
47 return 0; 47 return 0;
48} 48}
49 49
50static int __cpuinit xbow_probe(nasid_t nasid) 50static int xbow_probe(nasid_t nasid)
51{ 51{
52 lboard_t *brd; 52 lboard_t *brd;
53 klxbow_t *xbow_p; 53 klxbow_t *xbow_p;
@@ -100,7 +100,7 @@ static int __cpuinit xbow_probe(nasid_t nasid)
100 return 0; 100 return 0;
101} 101}
102 102
103void __cpuinit xtalk_probe_node(cnodeid_t nid) 103void xtalk_probe_node(cnodeid_t nid)
104{ 104{
105 volatile u64 hubreg; 105 volatile u64 hubreg;
106 nasid_t nasid; 106 nasid_t nasid;
diff --git a/arch/mips/sibyte/bcm1480/smp.c b/arch/mips/sibyte/bcm1480/smp.c
index de88e22694a0..54e2c4de15c1 100644
--- a/arch/mips/sibyte/bcm1480/smp.c
+++ b/arch/mips/sibyte/bcm1480/smp.c
@@ -60,7 +60,7 @@ static void *mailbox_0_regs[] = {
60/* 60/*
61 * SMP init and finish on secondary CPUs 61 * SMP init and finish on secondary CPUs
62 */ 62 */
63void __cpuinit bcm1480_smp_init(void) 63void bcm1480_smp_init(void)
64{ 64{
65 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 | 65 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
66 STATUSF_IP1 | STATUSF_IP0; 66 STATUSF_IP1 | STATUSF_IP0;
@@ -95,7 +95,7 @@ static void bcm1480_send_ipi_mask(const struct cpumask *mask,
95/* 95/*
96 * Code to run on secondary just after probing the CPU 96 * Code to run on secondary just after probing the CPU
97 */ 97 */
98static void __cpuinit bcm1480_init_secondary(void) 98static void bcm1480_init_secondary(void)
99{ 99{
100 extern void bcm1480_smp_init(void); 100 extern void bcm1480_smp_init(void);
101 101
@@ -106,7 +106,7 @@ static void __cpuinit bcm1480_init_secondary(void)
106 * Do any tidying up before marking online and running the idle 106 * Do any tidying up before marking online and running the idle
107 * loop 107 * loop
108 */ 108 */
109static void __cpuinit bcm1480_smp_finish(void) 109static void bcm1480_smp_finish(void)
110{ 110{
111 extern void sb1480_clockevent_init(void); 111 extern void sb1480_clockevent_init(void);
112 112
@@ -125,7 +125,7 @@ static void bcm1480_cpus_done(void)
125 * Setup the PC, SP, and GP of a secondary processor and start it 125 * Setup the PC, SP, and GP of a secondary processor and start it
126 * running! 126 * running!
127 */ 127 */
128static void __cpuinit bcm1480_boot_secondary(int cpu, struct task_struct *idle) 128static void bcm1480_boot_secondary(int cpu, struct task_struct *idle)
129{ 129{
130 int retval; 130 int retval;
131 131
diff --git a/arch/mips/sibyte/sb1250/smp.c b/arch/mips/sibyte/sb1250/smp.c
index 285cfef4ebc0..d7b942db0ea5 100644
--- a/arch/mips/sibyte/sb1250/smp.c
+++ b/arch/mips/sibyte/sb1250/smp.c
@@ -48,7 +48,7 @@ static void *mailbox_regs[] = {
48/* 48/*
49 * SMP init and finish on secondary CPUs 49 * SMP init and finish on secondary CPUs
50 */ 50 */
51void __cpuinit sb1250_smp_init(void) 51void sb1250_smp_init(void)
52{ 52{
53 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 | 53 unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
54 STATUSF_IP1 | STATUSF_IP0; 54 STATUSF_IP1 | STATUSF_IP0;
@@ -83,7 +83,7 @@ static inline void sb1250_send_ipi_mask(const struct cpumask *mask,
83/* 83/*
84 * Code to run on secondary just after probing the CPU 84 * Code to run on secondary just after probing the CPU
85 */ 85 */
86static void __cpuinit sb1250_init_secondary(void) 86static void sb1250_init_secondary(void)
87{ 87{
88 extern void sb1250_smp_init(void); 88 extern void sb1250_smp_init(void);
89 89
@@ -94,7 +94,7 @@ static void __cpuinit sb1250_init_secondary(void)
94 * Do any tidying up before marking online and running the idle 94 * Do any tidying up before marking online and running the idle
95 * loop 95 * loop
96 */ 96 */
97static void __cpuinit sb1250_smp_finish(void) 97static void sb1250_smp_finish(void)
98{ 98{
99 extern void sb1250_clockevent_init(void); 99 extern void sb1250_clockevent_init(void);
100 100
@@ -113,7 +113,7 @@ static void sb1250_cpus_done(void)
113 * Setup the PC, SP, and GP of a secondary processor and start it 113 * Setup the PC, SP, and GP of a secondary processor and start it
114 * running! 114 * running!
115 */ 115 */
116static void __cpuinit sb1250_boot_secondary(int cpu, struct task_struct *idle) 116static void sb1250_boot_secondary(int cpu, struct task_struct *idle)
117{ 117{
118 int retval; 118 int retval;
119 119
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
index f4d5bedc3b4f..d7359ffbcbdd 100644
--- a/arch/openrisc/kernel/setup.c
+++ b/arch/openrisc/kernel/setup.c
@@ -267,7 +267,7 @@ void __init detect_unit_config(unsigned long upr, unsigned long mask,
267 * 267 *
268 */ 268 */
269 269
270void __cpuinit calibrate_delay(void) 270void calibrate_delay(void)
271{ 271{
272 const int *val; 272 const int *val;
273 struct device_node *cpu = NULL; 273 struct device_node *cpu = NULL;
diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c
index f65fa480c905..22395901d47b 100644
--- a/arch/parisc/kernel/firmware.c
+++ b/arch/parisc/kernel/firmware.c
@@ -150,7 +150,7 @@ static void convert_to_wide(unsigned long *addr)
150} 150}
151 151
152#ifdef CONFIG_64BIT 152#ifdef CONFIG_64BIT
153void __cpuinit set_firmware_width_unlocked(void) 153void set_firmware_width_unlocked(void)
154{ 154{
155 int ret; 155 int ret;
156 156
@@ -167,7 +167,7 @@ void __cpuinit set_firmware_width_unlocked(void)
167 * This function must be called before any pdc_* function that uses the 167 * This function must be called before any pdc_* function that uses the
168 * convert_to_wide function. 168 * convert_to_wide function.
169 */ 169 */
170void __cpuinit set_firmware_width(void) 170void set_firmware_width(void)
171{ 171{
172 unsigned long flags; 172 unsigned long flags;
173 spin_lock_irqsave(&pdc_lock, flags); 173 spin_lock_irqsave(&pdc_lock, flags);
@@ -175,11 +175,13 @@ void __cpuinit set_firmware_width(void)
175 spin_unlock_irqrestore(&pdc_lock, flags); 175 spin_unlock_irqrestore(&pdc_lock, flags);
176} 176}
177#else 177#else
178void __cpuinit set_firmware_width_unlocked(void) { 178void set_firmware_width_unlocked(void)
179{
179 return; 180 return;
180} 181}
181 182
182void __cpuinit set_firmware_width(void) { 183void set_firmware_width(void)
184{
183 return; 185 return;
184} 186}
185#endif /*CONFIG_64BIT*/ 187#endif /*CONFIG_64BIT*/
@@ -301,7 +303,7 @@ int pdc_chassis_warn(unsigned long *warn)
301 return retval; 303 return retval;
302} 304}
303 305
304int __cpuinit pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info) 306int pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info)
305{ 307{
306 int ret; 308 int ret;
307 309
@@ -322,7 +324,7 @@ int __cpuinit pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info)
322 * This PDC call returns the presence and status of all the coprocessors 324 * This PDC call returns the presence and status of all the coprocessors
323 * attached to the processor. 325 * attached to the processor.
324 */ 326 */
325int __cpuinit pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info) 327int pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info)
326{ 328{
327 int ret; 329 int ret;
328 unsigned long flags; 330 unsigned long flags;
diff --git a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c
index 872275659d98..06cb3992907e 100644
--- a/arch/parisc/kernel/hardware.c
+++ b/arch/parisc/kernel/hardware.c
@@ -1367,7 +1367,7 @@ const char *parisc_hardware_description(struct parisc_device_id *id)
1367 1367
1368 1368
1369/* Interpret hversion (ret[0]) from PDC_MODEL(4)/PDC_MODEL_INFO(0) */ 1369/* Interpret hversion (ret[0]) from PDC_MODEL(4)/PDC_MODEL_INFO(0) */
1370enum cpu_type __cpuinit 1370enum cpu_type
1371parisc_get_cpu_type(unsigned long hversion) 1371parisc_get_cpu_type(unsigned long hversion)
1372{ 1372{
1373 struct hp_cpu_type_mask *ptr; 1373 struct hp_cpu_type_mask *ptr;
diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c
index 8a96c8ab9fe6..b68d977ce30f 100644
--- a/arch/parisc/kernel/processor.c
+++ b/arch/parisc/kernel/processor.c
@@ -73,7 +73,7 @@ extern int update_cr16_clocksource(void); /* from time.c */
73 * 73 *
74 * FIXME: doesn't do much yet... 74 * FIXME: doesn't do much yet...
75 */ 75 */
76static void __cpuinit 76static void
77init_percpu_prof(unsigned long cpunum) 77init_percpu_prof(unsigned long cpunum)
78{ 78{
79 struct cpuinfo_parisc *p; 79 struct cpuinfo_parisc *p;
@@ -92,7 +92,7 @@ init_percpu_prof(unsigned long cpunum)
92 * (return 1). If so, initialize the chip and tell other partners in crime 92 * (return 1). If so, initialize the chip and tell other partners in crime
93 * they have work to do. 93 * they have work to do.
94 */ 94 */
95static int __cpuinit processor_probe(struct parisc_device *dev) 95static int processor_probe(struct parisc_device *dev)
96{ 96{
97 unsigned long txn_addr; 97 unsigned long txn_addr;
98 unsigned long cpuid; 98 unsigned long cpuid;
@@ -299,7 +299,7 @@ void __init collect_boot_cpu_data(void)
299 * 299 *
300 * o Enable CPU profiling hooks. 300 * o Enable CPU profiling hooks.
301 */ 301 */
302int __cpuinit init_per_cpu(int cpunum) 302int init_per_cpu(int cpunum)
303{ 303{
304 int ret; 304 int ret;
305 struct pdc_coproc_cfg coproc_cfg; 305 struct pdc_coproc_cfg coproc_cfg;
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index e3614fb343e5..8a252f2d6c08 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -62,9 +62,9 @@ static int smp_debug_lvl = 0;
62volatile struct task_struct *smp_init_current_idle_task; 62volatile struct task_struct *smp_init_current_idle_task;
63 63
64/* track which CPU is booting */ 64/* track which CPU is booting */
65static volatile int cpu_now_booting __cpuinitdata; 65static volatile int cpu_now_booting;
66 66
67static int parisc_max_cpus __cpuinitdata = 1; 67static int parisc_max_cpus = 1;
68 68
69static DEFINE_PER_CPU(spinlock_t, ipi_lock); 69static DEFINE_PER_CPU(spinlock_t, ipi_lock);
70 70
@@ -328,7 +328,7 @@ void __init smp_callin(void)
328/* 328/*
329 * Bring one cpu online. 329 * Bring one cpu online.
330 */ 330 */
331int __cpuinit smp_boot_one_cpu(int cpuid, struct task_struct *idle) 331int smp_boot_one_cpu(int cpuid, struct task_struct *idle)
332{ 332{
333 const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid); 333 const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
334 long timeout; 334 long timeout;
@@ -424,7 +424,7 @@ void smp_cpus_done(unsigned int cpu_max)
424} 424}
425 425
426 426
427int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 427int __cpu_up(unsigned int cpu, struct task_struct *tidle)
428{ 428{
429 if (cpu != 0 && cpu < parisc_max_cpus) 429 if (cpu != 0 && cpu < parisc_max_cpus)
430 smp_boot_one_cpu(cpu, tidle); 430 smp_boot_one_cpu(cpu, tidle);
diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 09a8743143f3..d3e5e9bc8f94 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -55,6 +55,8 @@ struct device_node;
55#define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */ 55#define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */
56#define EEH_PE_PHB_DEAD (1 << 2) /* Dead PHB */ 56#define EEH_PE_PHB_DEAD (1 << 2) /* Dead PHB */
57 57
58#define EEH_PE_KEEP (1 << 8) /* Keep PE on hotplug */
59
58struct eeh_pe { 60struct eeh_pe {
59 int type; /* PE type: PHB/Bus/Device */ 61 int type; /* PE type: PHB/Bus/Device */
60 int state; /* PE EEH dependent mode */ 62 int state; /* PE EEH dependent mode */
@@ -72,8 +74,8 @@ struct eeh_pe {
72 struct list_head child; /* Child PEs */ 74 struct list_head child; /* Child PEs */
73}; 75};
74 76
75#define eeh_pe_for_each_dev(pe, edev) \ 77#define eeh_pe_for_each_dev(pe, edev, tmp) \
76 list_for_each_entry(edev, &pe->edevs, list) 78 list_for_each_entry_safe(edev, tmp, &pe->edevs, list)
77 79
78/* 80/*
79 * The struct is used to trace EEH state for the associated 81 * The struct is used to trace EEH state for the associated
@@ -82,7 +84,13 @@ struct eeh_pe {
82 * another tree except the currently existing tree of PCI 84 * another tree except the currently existing tree of PCI
83 * buses and PCI devices 85 * buses and PCI devices
84 */ 86 */
85#define EEH_DEV_IRQ_DISABLED (1<<0) /* Interrupt disabled */ 87#define EEH_DEV_BRIDGE (1 << 0) /* PCI bridge */
88#define EEH_DEV_ROOT_PORT (1 << 1) /* PCIe root port */
89#define EEH_DEV_DS_PORT (1 << 2) /* Downstream port */
90#define EEH_DEV_IRQ_DISABLED (1 << 3) /* Interrupt disabled */
91#define EEH_DEV_DISCONNECTED (1 << 4) /* Removing from PE */
92
93#define EEH_DEV_SYSFS (1 << 8) /* Sysfs created */
86 94
87struct eeh_dev { 95struct eeh_dev {
88 int mode; /* EEH mode */ 96 int mode; /* EEH mode */
@@ -90,11 +98,13 @@ struct eeh_dev {
90 int config_addr; /* Config address */ 98 int config_addr; /* Config address */
91 int pe_config_addr; /* PE config address */ 99 int pe_config_addr; /* PE config address */
92 u32 config_space[16]; /* Saved PCI config space */ 100 u32 config_space[16]; /* Saved PCI config space */
101 u8 pcie_cap; /* Saved PCIe capability */
93 struct eeh_pe *pe; /* Associated PE */ 102 struct eeh_pe *pe; /* Associated PE */
94 struct list_head list; /* Form link list in the PE */ 103 struct list_head list; /* Form link list in the PE */
95 struct pci_controller *phb; /* Associated PHB */ 104 struct pci_controller *phb; /* Associated PHB */
96 struct device_node *dn; /* Associated device node */ 105 struct device_node *dn; /* Associated device node */
97 struct pci_dev *pdev; /* Associated PCI device */ 106 struct pci_dev *pdev; /* Associated PCI device */
107 struct pci_bus *bus; /* PCI bus for partial hotplug */
98}; 108};
99 109
100static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev) 110static 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);
193struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb); 203struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
194struct eeh_pe *eeh_pe_get(struct eeh_dev *edev); 204struct eeh_pe *eeh_pe_get(struct eeh_dev *edev);
195int eeh_add_to_parent_pe(struct eeh_dev *edev); 205int eeh_add_to_parent_pe(struct eeh_dev *edev);
196int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe); 206int eeh_rmv_from_parent_pe(struct eeh_dev *edev);
197void eeh_pe_update_time_stamp(struct eeh_pe *pe); 207void eeh_pe_update_time_stamp(struct eeh_pe *pe);
208void *eeh_pe_traverse(struct eeh_pe *root,
209 eeh_traverse_func fn, void *flag);
198void *eeh_pe_dev_traverse(struct eeh_pe *root, 210void *eeh_pe_dev_traverse(struct eeh_pe *root,
199 eeh_traverse_func fn, void *flag); 211 eeh_traverse_func fn, void *flag);
200void eeh_pe_restore_bars(struct eeh_pe *pe); 212void eeh_pe_restore_bars(struct eeh_pe *pe);
@@ -209,10 +221,12 @@ unsigned long eeh_check_failure(const volatile void __iomem *token,
209 unsigned long val); 221 unsigned long val);
210int eeh_dev_check_failure(struct eeh_dev *edev); 222int eeh_dev_check_failure(struct eeh_dev *edev);
211void eeh_addr_cache_build(void); 223void eeh_addr_cache_build(void);
224void eeh_add_device_early(struct device_node *);
212void eeh_add_device_tree_early(struct device_node *); 225void eeh_add_device_tree_early(struct device_node *);
226void eeh_add_device_late(struct pci_dev *);
213void eeh_add_device_tree_late(struct pci_bus *); 227void eeh_add_device_tree_late(struct pci_bus *);
214void eeh_add_sysfs_files(struct pci_bus *); 228void eeh_add_sysfs_files(struct pci_bus *);
215void eeh_remove_bus_device(struct pci_dev *, int); 229void eeh_remove_device(struct pci_dev *);
216 230
217/** 231/**
218 * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure. 232 * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
@@ -252,13 +266,17 @@ static inline unsigned long eeh_check_failure(const volatile void __iomem *token
252 266
253static inline void eeh_addr_cache_build(void) { } 267static inline void eeh_addr_cache_build(void) { }
254 268
269static inline void eeh_add_device_early(struct device_node *dn) { }
270
255static inline void eeh_add_device_tree_early(struct device_node *dn) { } 271static inline void eeh_add_device_tree_early(struct device_node *dn) { }
256 272
273static inline void eeh_add_device_late(struct pci_dev *dev) { }
274
257static inline void eeh_add_device_tree_late(struct pci_bus *bus) { } 275static inline void eeh_add_device_tree_late(struct pci_bus *bus) { }
258 276
259static inline void eeh_add_sysfs_files(struct pci_bus *bus) { } 277static inline void eeh_add_sysfs_files(struct pci_bus *bus) { }
260 278
261static inline void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) { } 279static inline void eeh_remove_device(struct pci_dev *dev) { }
262 280
263#define EEH_POSSIBLE_ERROR(val, type) (0) 281#define EEH_POSSIBLE_ERROR(val, type) (0)
264#define EEH_IO_ERROR_VALUE(size) (-1UL) 282#define EEH_IO_ERROR_VALUE(size) (-1UL)
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index ba713f166fa5..10be1dd01c6b 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -96,10 +96,11 @@ static inline bool arch_irqs_disabled(void)
96#endif 96#endif
97 97
98#define hard_irq_disable() do { \ 98#define hard_irq_disable() do { \
99 u8 _was_enabled = get_paca()->soft_enabled; \ 99 u8 _was_enabled; \
100 __hard_irq_disable(); \ 100 __hard_irq_disable(); \
101 get_paca()->soft_enabled = 0; \ 101 _was_enabled = local_paca->soft_enabled; \
102 get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \ 102 local_paca->soft_enabled = 0; \
103 local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
103 if (_was_enabled) \ 104 if (_was_enabled) \
104 trace_hardirqs_off(); \ 105 trace_hardirqs_off(); \
105} while(0) 106} while(0)
diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h
index c1df590ec444..49fa55bfbac4 100644
--- a/arch/powerpc/include/asm/module.h
+++ b/arch/powerpc/include/asm/module.h
@@ -82,10 +82,9 @@ struct exception_table_entry;
82void sort_ex_table(struct exception_table_entry *start, 82void sort_ex_table(struct exception_table_entry *start,
83 struct exception_table_entry *finish); 83 struct exception_table_entry *finish);
84 84
85#ifdef CONFIG_MODVERSIONS 85#if defined(CONFIG_MODVERSIONS) && defined(CONFIG_PPC64)
86#define ARCH_RELOCATES_KCRCTAB 86#define ARCH_RELOCATES_KCRCTAB
87 87#define reloc_start PHYSICAL_START
88extern const unsigned long reloc_start[];
89#endif 88#endif
90#endif /* __KERNEL__ */ 89#endif /* __KERNEL__ */
91#endif /* _ASM_POWERPC_MODULE_H */ 90#endif /* _ASM_POWERPC_MODULE_H */
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 2c1d8cb9b265..32d0d2018faf 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -209,7 +209,6 @@ static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
209extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn); 209extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn);
210 210
211/** Remove all of the PCI devices under this bus */ 211/** Remove all of the PCI devices under this bus */
212extern void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe);
213extern void pcibios_remove_pci_devices(struct pci_bus *bus); 212extern void pcibios_remove_pci_devices(struct pci_bus *bus);
214 213
215/** Discover new pci devices under this bus, and add them */ 214/** Discover new pci devices under this bus, and add them */
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 5d7d9c2a5473..a6840e4e24f7 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1088,7 +1088,8 @@
1088#define PVR_970MP 0x0044 1088#define PVR_970MP 0x0044
1089#define PVR_970GX 0x0045 1089#define PVR_970GX 0x0045
1090#define PVR_POWER7p 0x004A 1090#define PVR_POWER7p 0x004A
1091#define PVR_POWER8 0x004B 1091#define PVR_POWER8E 0x004B
1092#define PVR_POWER8 0x004D
1092#define PVR_BE 0x0070 1093#define PVR_BE 0x0070
1093#define PVR_PA6T 0x0090 1094#define PVR_PA6T 0x0090
1094 1095
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 2a45d0f04385..22973a74df73 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -494,9 +494,27 @@ static struct cpu_spec __initdata cpu_specs[] = {
494 .cpu_restore = __restore_cpu_power7, 494 .cpu_restore = __restore_cpu_power7,
495 .platform = "power7+", 495 .platform = "power7+",
496 }, 496 },
497 { /* Power8 */ 497 { /* Power8E */
498 .pvr_mask = 0xffff0000, 498 .pvr_mask = 0xffff0000,
499 .pvr_value = 0x004b0000, 499 .pvr_value = 0x004b0000,
500 .cpu_name = "POWER8E (raw)",
501 .cpu_features = CPU_FTRS_POWER8,
502 .cpu_user_features = COMMON_USER_POWER8,
503 .cpu_user_features2 = COMMON_USER2_POWER8,
504 .mmu_features = MMU_FTRS_POWER8,
505 .icache_bsize = 128,
506 .dcache_bsize = 128,
507 .num_pmcs = 6,
508 .pmc_type = PPC_PMC_IBM,
509 .oprofile_cpu_type = "ppc64/power8",
510 .oprofile_type = PPC_OPROFILE_INVALID,
511 .cpu_setup = __setup_cpu_power8,
512 .cpu_restore = __restore_cpu_power8,
513 .platform = "power8",
514 },
515 { /* Power8 */
516 .pvr_mask = 0xffff0000,
517 .pvr_value = 0x004d0000,
500 .cpu_name = "POWER8 (raw)", 518 .cpu_name = "POWER8 (raw)",
501 .cpu_features = CPU_FTRS_POWER8, 519 .cpu_features = CPU_FTRS_POWER8,
502 .cpu_user_features = COMMON_USER_POWER8, 520 .cpu_user_features = COMMON_USER_POWER8,
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 39954fe941b8..ea9414c8088d 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -231,7 +231,7 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len)
231void eeh_slot_error_detail(struct eeh_pe *pe, int severity) 231void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
232{ 232{
233 size_t loglen = 0; 233 size_t loglen = 0;
234 struct eeh_dev *edev; 234 struct eeh_dev *edev, *tmp;
235 bool valid_cfg_log = true; 235 bool valid_cfg_log = true;
236 236
237 /* 237 /*
@@ -251,7 +251,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
251 eeh_pe_restore_bars(pe); 251 eeh_pe_restore_bars(pe);
252 252
253 pci_regs_buf[0] = 0; 253 pci_regs_buf[0] = 0;
254 eeh_pe_for_each_dev(pe, edev) { 254 eeh_pe_for_each_dev(pe, edev, tmp) {
255 loglen += eeh_gather_pci_data(edev, pci_regs_buf + loglen, 255 loglen += eeh_gather_pci_data(edev, pci_regs_buf + loglen,
256 EEH_PCI_REGS_LOG_LEN - loglen); 256 EEH_PCI_REGS_LOG_LEN - loglen);
257 } 257 }
@@ -499,8 +499,6 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon
499 } 499 }
500 500
501 eeh_dev_check_failure(edev); 501 eeh_dev_check_failure(edev);
502
503 pci_dev_put(eeh_dev_to_pci_dev(edev));
504 return val; 502 return val;
505} 503}
506 504
@@ -838,7 +836,7 @@ core_initcall_sync(eeh_init);
838 * on the CEC architecture, type of the device, on earlier boot 836 * on the CEC architecture, type of the device, on earlier boot
839 * command-line arguments & etc. 837 * command-line arguments & etc.
840 */ 838 */
841static void eeh_add_device_early(struct device_node *dn) 839void eeh_add_device_early(struct device_node *dn)
842{ 840{
843 struct pci_controller *phb; 841 struct pci_controller *phb;
844 842
@@ -886,7 +884,7 @@ EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
886 * This routine must be used to complete EEH initialization for PCI 884 * This routine must be used to complete EEH initialization for PCI
887 * devices that were added after system boot (e.g. hotplug, dlpar). 885 * devices that were added after system boot (e.g. hotplug, dlpar).
888 */ 886 */
889static void eeh_add_device_late(struct pci_dev *dev) 887void eeh_add_device_late(struct pci_dev *dev)
890{ 888{
891 struct device_node *dn; 889 struct device_node *dn;
892 struct eeh_dev *edev; 890 struct eeh_dev *edev;
@@ -902,9 +900,23 @@ static void eeh_add_device_late(struct pci_dev *dev)
902 pr_debug("EEH: Already referenced !\n"); 900 pr_debug("EEH: Already referenced !\n");
903 return; 901 return;
904 } 902 }
905 WARN_ON(edev->pdev);
906 903
907 pci_dev_get(dev); 904 /*
905 * The EEH cache might not be removed correctly because of
906 * unbalanced kref to the device during unplug time, which
907 * relies on pcibios_release_device(). So we have to remove
908 * that here explicitly.
909 */
910 if (edev->pdev) {
911 eeh_rmv_from_parent_pe(edev);
912 eeh_addr_cache_rmv_dev(edev->pdev);
913 eeh_sysfs_remove_device(edev->pdev);
914 edev->mode &= ~EEH_DEV_SYSFS;
915
916 edev->pdev = NULL;
917 dev->dev.archdata.edev = NULL;
918 }
919
908 edev->pdev = dev; 920 edev->pdev = dev;
909 dev->dev.archdata.edev = edev; 921 dev->dev.archdata.edev = edev;
910 922
@@ -967,7 +979,6 @@ EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
967/** 979/**
968 * eeh_remove_device - Undo EEH setup for the indicated pci device 980 * eeh_remove_device - Undo EEH setup for the indicated pci device
969 * @dev: pci device to be removed 981 * @dev: pci device to be removed
970 * @purge_pe: remove the PE or not
971 * 982 *
972 * This routine should be called when a device is removed from 983 * This routine should be called when a device is removed from
973 * a running system (e.g. by hotplug or dlpar). It unregisters 984 * a running system (e.g. by hotplug or dlpar). It unregisters
@@ -975,7 +986,7 @@ EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
975 * this device will no longer be detected after this call; thus, 986 * this device will no longer be detected after this call; thus,
976 * i/o errors affecting this slot may leave this device unusable. 987 * i/o errors affecting this slot may leave this device unusable.
977 */ 988 */
978static void eeh_remove_device(struct pci_dev *dev, int purge_pe) 989void eeh_remove_device(struct pci_dev *dev)
979{ 990{
980 struct eeh_dev *edev; 991 struct eeh_dev *edev;
981 992
@@ -986,42 +997,29 @@ static void eeh_remove_device(struct pci_dev *dev, int purge_pe)
986 /* Unregister the device with the EEH/PCI address search system */ 997 /* Unregister the device with the EEH/PCI address search system */
987 pr_debug("EEH: Removing device %s\n", pci_name(dev)); 998 pr_debug("EEH: Removing device %s\n", pci_name(dev));
988 999
989 if (!edev || !edev->pdev) { 1000 if (!edev || !edev->pdev || !edev->pe) {
990 pr_debug("EEH: Not referenced !\n"); 1001 pr_debug("EEH: Not referenced !\n");
991 return; 1002 return;
992 } 1003 }
1004
1005 /*
1006 * During the hotplug for EEH error recovery, we need the EEH
1007 * device attached to the parent PE in order for BAR restore
1008 * a bit later. So we keep it for BAR restore and remove it
1009 * from the parent PE during the BAR resotre.
1010 */
993 edev->pdev = NULL; 1011 edev->pdev = NULL;
994 dev->dev.archdata.edev = NULL; 1012 dev->dev.archdata.edev = NULL;
995 pci_dev_put(dev); 1013 if (!(edev->pe->state & EEH_PE_KEEP))
1014 eeh_rmv_from_parent_pe(edev);
1015 else
1016 edev->mode |= EEH_DEV_DISCONNECTED;
996 1017
997 eeh_rmv_from_parent_pe(edev, purge_pe);
998 eeh_addr_cache_rmv_dev(dev); 1018 eeh_addr_cache_rmv_dev(dev);
999 eeh_sysfs_remove_device(dev); 1019 eeh_sysfs_remove_device(dev);
1020 edev->mode &= ~EEH_DEV_SYSFS;
1000} 1021}
1001 1022
1002/**
1003 * eeh_remove_bus_device - Undo EEH setup for the indicated PCI device
1004 * @dev: PCI device
1005 * @purge_pe: remove the corresponding PE or not
1006 *
1007 * This routine must be called when a device is removed from the
1008 * running system through hotplug or dlpar. The corresponding
1009 * PCI address cache will be removed.
1010 */
1011void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe)
1012{
1013 struct pci_bus *bus = dev->subordinate;
1014 struct pci_dev *child, *tmp;
1015
1016 eeh_remove_device(dev, purge_pe);
1017
1018 if (bus && dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
1019 list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
1020 eeh_remove_bus_device(child, purge_pe);
1021 }
1022}
1023EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
1024
1025static int proc_eeh_show(struct seq_file *m, void *v) 1023static int proc_eeh_show(struct seq_file *m, void *v)
1026{ 1024{
1027 if (0 == eeh_subsystem_enabled) { 1025 if (0 == eeh_subsystem_enabled) {
diff --git a/arch/powerpc/kernel/eeh_cache.c b/arch/powerpc/kernel/eeh_cache.c
index f9ac1232a746..e8c9fd546a5c 100644
--- a/arch/powerpc/kernel/eeh_cache.c
+++ b/arch/powerpc/kernel/eeh_cache.c
@@ -68,16 +68,12 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr)
68 struct pci_io_addr_range *piar; 68 struct pci_io_addr_range *piar;
69 piar = rb_entry(n, struct pci_io_addr_range, rb_node); 69 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
70 70
71 if (addr < piar->addr_lo) { 71 if (addr < piar->addr_lo)
72 n = n->rb_left; 72 n = n->rb_left;
73 } else { 73 else if (addr > piar->addr_hi)
74 if (addr > piar->addr_hi) { 74 n = n->rb_right;
75 n = n->rb_right; 75 else
76 } else { 76 return piar->edev;
77 pci_dev_get(piar->pcidev);
78 return piar->edev;
79 }
80 }
81 } 77 }
82 78
83 return NULL; 79 return NULL;
@@ -156,7 +152,6 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
156 if (!piar) 152 if (!piar)
157 return NULL; 153 return NULL;
158 154
159 pci_dev_get(dev);
160 piar->addr_lo = alo; 155 piar->addr_lo = alo;
161 piar->addr_hi = ahi; 156 piar->addr_hi = ahi;
162 piar->edev = pci_dev_to_eeh_dev(dev); 157 piar->edev = pci_dev_to_eeh_dev(dev);
@@ -250,7 +245,6 @@ restart:
250 245
251 if (piar->pcidev == dev) { 246 if (piar->pcidev == dev) {
252 rb_erase(n, &pci_io_addr_cache_root.rb_root); 247 rb_erase(n, &pci_io_addr_cache_root.rb_root);
253 pci_dev_put(piar->pcidev);
254 kfree(piar); 248 kfree(piar);
255 goto restart; 249 goto restart;
256 } 250 }
@@ -302,12 +296,10 @@ void eeh_addr_cache_build(void)
302 if (!edev) 296 if (!edev)
303 continue; 297 continue;
304 298
305 pci_dev_get(dev); /* matching put is in eeh_remove_device() */
306 dev->dev.archdata.edev = edev; 299 dev->dev.archdata.edev = edev;
307 edev->pdev = dev; 300 edev->pdev = dev;
308 301
309 eeh_addr_cache_insert_dev(dev); 302 eeh_addr_cache_insert_dev(dev);
310
311 eeh_sysfs_add_device(dev); 303 eeh_sysfs_add_device(dev);
312 } 304 }
313 305
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index 2b1ce17cae50..36bed5a12750 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -143,10 +143,14 @@ static void eeh_disable_irq(struct pci_dev *dev)
143static void eeh_enable_irq(struct pci_dev *dev) 143static void eeh_enable_irq(struct pci_dev *dev)
144{ 144{
145 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); 145 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
146 struct irq_desc *desc;
146 147
147 if ((edev->mode) & EEH_DEV_IRQ_DISABLED) { 148 if ((edev->mode) & EEH_DEV_IRQ_DISABLED) {
148 edev->mode &= ~EEH_DEV_IRQ_DISABLED; 149 edev->mode &= ~EEH_DEV_IRQ_DISABLED;
149 enable_irq(dev->irq); 150
151 desc = irq_to_desc(dev->irq);
152 if (desc && desc->depth > 0)
153 enable_irq(dev->irq);
150 } 154 }
151} 155}
152 156
@@ -338,6 +342,54 @@ static void *eeh_report_failure(void *data, void *userdata)
338 return NULL; 342 return NULL;
339} 343}
340 344
345static void *eeh_rmv_device(void *data, void *userdata)
346{
347 struct pci_driver *driver;
348 struct eeh_dev *edev = (struct eeh_dev *)data;
349 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
350 int *removed = (int *)userdata;
351
352 /*
353 * Actually, we should remove the PCI bridges as well.
354 * However, that's lots of complexity to do that,
355 * particularly some of devices under the bridge might
356 * support EEH. So we just care about PCI devices for
357 * simplicity here.
358 */
359 if (!dev || (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE))
360 return NULL;
361 driver = eeh_pcid_get(dev);
362 if (driver && driver->err_handler)
363 return NULL;
364
365 /* Remove it from PCI subsystem */
366 pr_debug("EEH: Removing %s without EEH sensitive driver\n",
367 pci_name(dev));
368 edev->bus = dev->bus;
369 edev->mode |= EEH_DEV_DISCONNECTED;
370 (*removed)++;
371
372 pci_stop_and_remove_bus_device(dev);
373
374 return NULL;
375}
376
377static void *eeh_pe_detach_dev(void *data, void *userdata)
378{
379 struct eeh_pe *pe = (struct eeh_pe *)data;
380 struct eeh_dev *edev, *tmp;
381
382 eeh_pe_for_each_dev(pe, edev, tmp) {
383 if (!(edev->mode & EEH_DEV_DISCONNECTED))
384 continue;
385
386 edev->mode &= ~(EEH_DEV_DISCONNECTED | EEH_DEV_IRQ_DISABLED);
387 eeh_rmv_from_parent_pe(edev);
388 }
389
390 return NULL;
391}
392
341/** 393/**
342 * eeh_reset_device - Perform actual reset of a pci slot 394 * eeh_reset_device - Perform actual reset of a pci slot
343 * @pe: EEH PE 395 * @pe: EEH PE
@@ -349,8 +401,9 @@ static void *eeh_report_failure(void *data, void *userdata)
349 */ 401 */
350static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) 402static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
351{ 403{
404 struct pci_bus *frozen_bus = eeh_pe_bus_get(pe);
352 struct timeval tstamp; 405 struct timeval tstamp;
353 int cnt, rc; 406 int cnt, rc, removed = 0;
354 407
355 /* pcibios will clear the counter; save the value */ 408 /* pcibios will clear the counter; save the value */
356 cnt = pe->freeze_count; 409 cnt = pe->freeze_count;
@@ -362,8 +415,11 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
362 * devices are expected to be attached soon when calling 415 * devices are expected to be attached soon when calling
363 * into pcibios_add_pci_devices(). 416 * into pcibios_add_pci_devices().
364 */ 417 */
418 eeh_pe_state_mark(pe, EEH_PE_KEEP);
365 if (bus) 419 if (bus)
366 __pcibios_remove_pci_devices(bus, 0); 420 pcibios_remove_pci_devices(bus);
421 else if (frozen_bus)
422 eeh_pe_dev_traverse(pe, eeh_rmv_device, &removed);
367 423
368 /* Reset the pci controller. (Asserts RST#; resets config space). 424 /* Reset the pci controller. (Asserts RST#; resets config space).
369 * Reconfigure bridges and devices. Don't try to bring the system 425 * 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)
384 * potentially weird things happen. 440 * potentially weird things happen.
385 */ 441 */
386 if (bus) { 442 if (bus) {
443 pr_info("EEH: Sleep 5s ahead of complete hotplug\n");
387 ssleep(5); 444 ssleep(5);
445
446 /*
447 * The EEH device is still connected with its parent
448 * PE. We should disconnect it so the binding can be
449 * rebuilt when adding PCI devices.
450 */
451 eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
388 pcibios_add_pci_devices(bus); 452 pcibios_add_pci_devices(bus);
453 } else if (frozen_bus && removed) {
454 pr_info("EEH: Sleep 5s ahead of partial hotplug\n");
455 ssleep(5);
456
457 eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
458 pcibios_add_pci_devices(frozen_bus);
389 } 459 }
460 eeh_pe_state_clear(pe, EEH_PE_KEEP);
390 461
391 pe->tstamp = tstamp; 462 pe->tstamp = tstamp;
392 pe->freeze_count = cnt; 463 pe->freeze_count = cnt;
diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 016588a6f5ed..f9450537e335 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -149,8 +149,8 @@ static struct eeh_pe *eeh_pe_next(struct eeh_pe *pe,
149 * callback returns something other than NULL, or no more PEs 149 * callback returns something other than NULL, or no more PEs
150 * to be traversed. 150 * to be traversed.
151 */ 151 */
152static void *eeh_pe_traverse(struct eeh_pe *root, 152void *eeh_pe_traverse(struct eeh_pe *root,
153 eeh_traverse_func fn, void *flag) 153 eeh_traverse_func fn, void *flag)
154{ 154{
155 struct eeh_pe *pe; 155 struct eeh_pe *pe;
156 void *ret; 156 void *ret;
@@ -176,7 +176,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
176 eeh_traverse_func fn, void *flag) 176 eeh_traverse_func fn, void *flag)
177{ 177{
178 struct eeh_pe *pe; 178 struct eeh_pe *pe;
179 struct eeh_dev *edev; 179 struct eeh_dev *edev, *tmp;
180 void *ret; 180 void *ret;
181 181
182 if (!root) { 182 if (!root) {
@@ -186,7 +186,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
186 186
187 /* Traverse root PE */ 187 /* Traverse root PE */
188 for (pe = root; pe; pe = eeh_pe_next(pe, root)) { 188 for (pe = root; pe; pe = eeh_pe_next(pe, root)) {
189 eeh_pe_for_each_dev(pe, edev) { 189 eeh_pe_for_each_dev(pe, edev, tmp) {
190 ret = fn(edev, flag); 190 ret = fn(edev, flag);
191 if (ret) 191 if (ret)
192 return ret; 192 return ret;
@@ -333,7 +333,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
333 while (parent) { 333 while (parent) {
334 if (!(parent->type & EEH_PE_INVALID)) 334 if (!(parent->type & EEH_PE_INVALID))
335 break; 335 break;
336 parent->type &= ~EEH_PE_INVALID; 336 parent->type &= ~(EEH_PE_INVALID | EEH_PE_KEEP);
337 parent = parent->parent; 337 parent = parent->parent;
338 } 338 }
339 pr_debug("EEH: Add %s to Device PE#%x, Parent PE#%x\n", 339 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)
397/** 397/**
398 * eeh_rmv_from_parent_pe - Remove one EEH device from the associated PE 398 * eeh_rmv_from_parent_pe - Remove one EEH device from the associated PE
399 * @edev: EEH device 399 * @edev: EEH device
400 * @purge_pe: remove PE or not
401 * 400 *
402 * The PE hierarchy tree might be changed when doing PCI hotplug. 401 * The PE hierarchy tree might be changed when doing PCI hotplug.
403 * Also, the PCI devices or buses could be removed from the system 402 * Also, the PCI devices or buses could be removed from the system
404 * during EEH recovery. So we have to call the function remove the 403 * during EEH recovery. So we have to call the function remove the
405 * corresponding PE accordingly if necessary. 404 * corresponding PE accordingly if necessary.
406 */ 405 */
407int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe) 406int eeh_rmv_from_parent_pe(struct eeh_dev *edev)
408{ 407{
409 struct eeh_pe *pe, *parent, *child; 408 struct eeh_pe *pe, *parent, *child;
410 int cnt; 409 int cnt;
411 410
412 if (!edev->pe) { 411 if (!edev->pe) {
413 pr_warning("%s: No PE found for EEH device %s\n", 412 pr_debug("%s: No PE found for EEH device %s\n",
414 __func__, edev->dn->full_name); 413 __func__, edev->dn->full_name);
415 return -EEXIST; 414 return -EEXIST;
416 } 415 }
417 416
@@ -431,7 +430,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe)
431 if (pe->type & EEH_PE_PHB) 430 if (pe->type & EEH_PE_PHB)
432 break; 431 break;
433 432
434 if (purge_pe) { 433 if (!(pe->state & EEH_PE_KEEP)) {
435 if (list_empty(&pe->edevs) && 434 if (list_empty(&pe->edevs) &&
436 list_empty(&pe->child_list)) { 435 list_empty(&pe->child_list)) {
437 list_del(&pe->child); 436 list_del(&pe->child);
@@ -502,7 +501,7 @@ static void *__eeh_pe_state_mark(void *data, void *flag)
502{ 501{
503 struct eeh_pe *pe = (struct eeh_pe *)data; 502 struct eeh_pe *pe = (struct eeh_pe *)data;
504 int state = *((int *)flag); 503 int state = *((int *)flag);
505 struct eeh_dev *tmp; 504 struct eeh_dev *edev, *tmp;
506 struct pci_dev *pdev; 505 struct pci_dev *pdev;
507 506
508 /* 507 /*
@@ -512,8 +511,8 @@ static void *__eeh_pe_state_mark(void *data, void *flag)
512 * the PCI device driver. 511 * the PCI device driver.
513 */ 512 */
514 pe->state |= state; 513 pe->state |= state;
515 eeh_pe_for_each_dev(pe, tmp) { 514 eeh_pe_for_each_dev(pe, edev, tmp) {
516 pdev = eeh_dev_to_pci_dev(tmp); 515 pdev = eeh_dev_to_pci_dev(edev);
517 if (pdev) 516 if (pdev)
518 pdev->error_state = pci_channel_io_frozen; 517 pdev->error_state = pci_channel_io_frozen;
519 } 518 }
@@ -579,7 +578,7 @@ void eeh_pe_state_clear(struct eeh_pe *pe, int state)
579 * blocked on normal path during the stage. So we need utilize 578 * blocked on normal path during the stage. So we need utilize
580 * eeh operations, which is always permitted. 579 * eeh operations, which is always permitted.
581 */ 580 */
582static void eeh_bridge_check_link(struct pci_dev *pdev, 581static void eeh_bridge_check_link(struct eeh_dev *edev,
583 struct device_node *dn) 582 struct device_node *dn)
584{ 583{
585 int cap; 584 int cap;
@@ -590,16 +589,17 @@ static void eeh_bridge_check_link(struct pci_dev *pdev,
590 * We only check root port and downstream ports of 589 * We only check root port and downstream ports of
591 * PCIe switches 590 * PCIe switches
592 */ 591 */
593 if (!pci_is_pcie(pdev) || 592 if (!(edev->mode & (EEH_DEV_ROOT_PORT | EEH_DEV_DS_PORT)))
594 (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
595 pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
596 return; 593 return;
597 594
598 pr_debug("%s: Check PCIe link for %s ...\n", 595 pr_debug("%s: Check PCIe link for %04x:%02x:%02x.%01x ...\n",
599 __func__, pci_name(pdev)); 596 __func__, edev->phb->global_number,
597 edev->config_addr >> 8,
598 PCI_SLOT(edev->config_addr & 0xFF),
599 PCI_FUNC(edev->config_addr & 0xFF));
600 600
601 /* Check slot status */ 601 /* Check slot status */
602 cap = pdev->pcie_cap; 602 cap = edev->pcie_cap;
603 eeh_ops->read_config(dn, cap + PCI_EXP_SLTSTA, 2, &val); 603 eeh_ops->read_config(dn, cap + PCI_EXP_SLTSTA, 2, &val);
604 if (!(val & PCI_EXP_SLTSTA_PDS)) { 604 if (!(val & PCI_EXP_SLTSTA_PDS)) {
605 pr_debug(" No card in the slot (0x%04x) !\n", val); 605 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,
653#define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF)) 653#define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))
654#define SAVED_BYTE(OFF) (((u8 *)(edev->config_space))[BYTE_SWAP(OFF)]) 654#define SAVED_BYTE(OFF) (((u8 *)(edev->config_space))[BYTE_SWAP(OFF)])
655 655
656static void eeh_restore_bridge_bars(struct pci_dev *pdev, 656static void eeh_restore_bridge_bars(struct eeh_dev *edev,
657 struct eeh_dev *edev,
658 struct device_node *dn) 657 struct device_node *dn)
659{ 658{
660 int i; 659 int i;
@@ -680,7 +679,7 @@ static void eeh_restore_bridge_bars(struct pci_dev *pdev,
680 eeh_ops->write_config(dn, PCI_COMMAND, 4, edev->config_space[1]); 679 eeh_ops->write_config(dn, PCI_COMMAND, 4, edev->config_space[1]);
681 680
682 /* Check the PCIe link is ready */ 681 /* Check the PCIe link is ready */
683 eeh_bridge_check_link(pdev, dn); 682 eeh_bridge_check_link(edev, dn);
684} 683}
685 684
686static void eeh_restore_device_bars(struct eeh_dev *edev, 685static void eeh_restore_device_bars(struct eeh_dev *edev,
@@ -729,19 +728,12 @@ static void eeh_restore_device_bars(struct eeh_dev *edev,
729 */ 728 */
730static void *eeh_restore_one_device_bars(void *data, void *flag) 729static void *eeh_restore_one_device_bars(void *data, void *flag)
731{ 730{
732 struct pci_dev *pdev = NULL;
733 struct eeh_dev *edev = (struct eeh_dev *)data; 731 struct eeh_dev *edev = (struct eeh_dev *)data;
734 struct device_node *dn = eeh_dev_to_of_node(edev); 732 struct device_node *dn = eeh_dev_to_of_node(edev);
735 733
736 /* Trace the PCI bridge */ 734 /* Do special restore for bridges */
737 if (eeh_probe_mode_dev()) { 735 if (edev->mode & EEH_DEV_BRIDGE)
738 pdev = eeh_dev_to_pci_dev(edev); 736 eeh_restore_bridge_bars(edev, dn);
739 if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE)
740 pdev = NULL;
741 }
742
743 if (pdev)
744 eeh_restore_bridge_bars(pdev, edev, dn);
745 else 737 else
746 eeh_restore_device_bars(edev, dn); 738 eeh_restore_device_bars(edev, dn);
747 739
diff --git a/arch/powerpc/kernel/eeh_sysfs.c b/arch/powerpc/kernel/eeh_sysfs.c
index e7ae3484918c..5d753d4f2c75 100644
--- a/arch/powerpc/kernel/eeh_sysfs.c
+++ b/arch/powerpc/kernel/eeh_sysfs.c
@@ -56,19 +56,40 @@ EEH_SHOW_ATTR(eeh_pe_config_addr, pe_config_addr, "0x%x");
56 56
57void eeh_sysfs_add_device(struct pci_dev *pdev) 57void eeh_sysfs_add_device(struct pci_dev *pdev)
58{ 58{
59 struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
59 int rc=0; 60 int rc=0;
60 61
62 if (edev && (edev->mode & EEH_DEV_SYSFS))
63 return;
64
61 rc += device_create_file(&pdev->dev, &dev_attr_eeh_mode); 65 rc += device_create_file(&pdev->dev, &dev_attr_eeh_mode);
62 rc += device_create_file(&pdev->dev, &dev_attr_eeh_config_addr); 66 rc += device_create_file(&pdev->dev, &dev_attr_eeh_config_addr);
63 rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_config_addr); 67 rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);
64 68
65 if (rc) 69 if (rc)
66 printk(KERN_WARNING "EEH: Unable to create sysfs entries\n"); 70 printk(KERN_WARNING "EEH: Unable to create sysfs entries\n");
71 else if (edev)
72 edev->mode |= EEH_DEV_SYSFS;
67} 73}
68 74
69void eeh_sysfs_remove_device(struct pci_dev *pdev) 75void eeh_sysfs_remove_device(struct pci_dev *pdev)
70{ 76{
77 struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
78
79 /*
80 * The parent directory might have been removed. We needn't
81 * continue for that case.
82 */
83 if (!pdev->dev.kobj.sd) {
84 if (edev)
85 edev->mode &= ~EEH_DEV_SYSFS;
86 return;
87 }
88
71 device_remove_file(&pdev->dev, &dev_attr_eeh_mode); 89 device_remove_file(&pdev->dev, &dev_attr_eeh_mode);
72 device_remove_file(&pdev->dev, &dev_attr_eeh_config_addr); 90 device_remove_file(&pdev->dev, &dev_attr_eeh_config_addr);
73 device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr); 91 device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);
92
93 if (edev)
94 edev->mode &= ~EEH_DEV_SYSFS;
74} 95}
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index f46914a0f33e..7d22a675fe1a 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1462,6 +1462,8 @@ void pcibios_finish_adding_to_bus(struct pci_bus *bus)
1462 /* Allocate bus and devices resources */ 1462 /* Allocate bus and devices resources */
1463 pcibios_allocate_bus_resources(bus); 1463 pcibios_allocate_bus_resources(bus);
1464 pcibios_claim_one_bus(bus); 1464 pcibios_claim_one_bus(bus);
1465 if (!pci_has_flag(PCI_PROBE_ONLY))
1466 pci_assign_unassigned_bus_resources(bus);
1465 1467
1466 /* Fixup EEH */ 1468 /* Fixup EEH */
1467 eeh_add_device_tree_late(bus); 1469 eeh_add_device_tree_late(bus);
diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c
index 3f608800c06b..c1e17ae68a08 100644
--- a/arch/powerpc/kernel/pci-hotplug.c
+++ b/arch/powerpc/kernel/pci-hotplug.c
@@ -22,45 +22,40 @@
22#include <asm/eeh.h> 22#include <asm/eeh.h>
23 23
24/** 24/**
25 * __pcibios_remove_pci_devices - remove all devices under this bus 25 * pcibios_release_device - release PCI device
26 * @dev: PCI device
27 *
28 * The function is called before releasing the indicated PCI device.
29 */
30void pcibios_release_device(struct pci_dev *dev)
31{
32 eeh_remove_device(dev);
33}
34
35/**
36 * pcibios_remove_pci_devices - remove all devices under this bus
26 * @bus: the indicated PCI bus 37 * @bus: the indicated PCI bus
27 * @purge_pe: destroy the PE on removal of PCI devices
28 * 38 *
29 * Remove all of the PCI devices under this bus both from the 39 * Remove all of the PCI devices under this bus both from the
30 * linux pci device tree, and from the powerpc EEH address cache. 40 * linux pci device tree, and from the powerpc EEH address cache.
31 * By default, the corresponding PE will be destroied during the
32 * normal PCI hotplug path. For PCI hotplug during EEH recovery,
33 * the corresponding PE won't be destroied and deallocated.
34 */ 41 */
35void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe) 42void pcibios_remove_pci_devices(struct pci_bus *bus)
36{ 43{
37 struct pci_dev *dev, *tmp; 44 struct pci_dev *dev, *tmp;
38 struct pci_bus *child_bus; 45 struct pci_bus *child_bus;
39 46
40 /* First go down child busses */ 47 /* First go down child busses */
41 list_for_each_entry(child_bus, &bus->children, node) 48 list_for_each_entry(child_bus, &bus->children, node)
42 __pcibios_remove_pci_devices(child_bus, purge_pe); 49 pcibios_remove_pci_devices(child_bus);
43 50
44 pr_debug("PCI: Removing devices on bus %04x:%02x\n", 51 pr_debug("PCI: Removing devices on bus %04x:%02x\n",
45 pci_domain_nr(bus), bus->number); 52 pci_domain_nr(bus), bus->number);
46 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { 53 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
47 pr_debug(" * Removing %s...\n", pci_name(dev)); 54 pr_debug(" Removing %s...\n", pci_name(dev));
48 eeh_remove_bus_device(dev, purge_pe);
49 pci_stop_and_remove_bus_device(dev); 55 pci_stop_and_remove_bus_device(dev);
50 } 56 }
51} 57}
52 58
53/**
54 * pcibios_remove_pci_devices - remove all devices under this bus
55 * @bus: the indicated PCI bus
56 *
57 * Remove all of the PCI devices under this bus both from the
58 * linux pci device tree, and from the powerpc EEH address cache.
59 */
60void pcibios_remove_pci_devices(struct pci_bus *bus)
61{
62 __pcibios_remove_pci_devices(bus, 1);
63}
64EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices); 59EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices);
65 60
66/** 61/**
@@ -76,7 +71,7 @@ EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices);
76 */ 71 */
77void pcibios_add_pci_devices(struct pci_bus * bus) 72void pcibios_add_pci_devices(struct pci_bus * bus)
78{ 73{
79 int slotno, num, mode, pass, max; 74 int slotno, mode, pass, max;
80 struct pci_dev *dev; 75 struct pci_dev *dev;
81 struct device_node *dn = pci_bus_to_OF_node(bus); 76 struct device_node *dn = pci_bus_to_OF_node(bus);
82 77
@@ -90,11 +85,15 @@ void pcibios_add_pci_devices(struct pci_bus * bus)
90 /* use ofdt-based probe */ 85 /* use ofdt-based probe */
91 of_rescan_bus(dn, bus); 86 of_rescan_bus(dn, bus);
92 } else if (mode == PCI_PROBE_NORMAL) { 87 } else if (mode == PCI_PROBE_NORMAL) {
93 /* use legacy probe */ 88 /*
89 * Use legacy probe. In the partial hotplug case, we
90 * probably have grandchildren devices unplugged. So
91 * we don't check the return value from pci_scan_slot() in
92 * order for fully rescan all the way down to pick them up.
93 * They can have been removed during partial hotplug.
94 */
94 slotno = PCI_SLOT(PCI_DN(dn->child)->devfn); 95 slotno = PCI_SLOT(PCI_DN(dn->child)->devfn);
95 num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); 96 pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
96 if (!num)
97 return;
98 pcibios_setup_bus_devices(bus); 97 pcibios_setup_bus_devices(bus);
99 max = bus->busn_res.start; 98 max = bus->busn_res.start;
100 for (pass = 0; pass < 2; pass++) { 99 for (pass = 0; pass < 2; pass++) {
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 6b0ba5854d99..15d9105323bf 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -230,11 +230,14 @@ void of_scan_pci_bridge(struct pci_dev *dev)
230 return; 230 return;
231 } 231 }
232 232
233 bus = pci_add_new_bus(dev->bus, dev, busrange[0]); 233 bus = pci_find_bus(pci_domain_nr(dev->bus), busrange[0]);
234 if (!bus) { 234 if (!bus) {
235 printk(KERN_ERR "Failed to create pci bus for %s\n", 235 bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
236 node->full_name); 236 if (!bus) {
237 return; 237 printk(KERN_ERR "Failed to create pci bus for %s\n",
238 node->full_name);
239 return;
240 }
238 } 241 }
239 242
240 bus->primary = dev->bus->number; 243 bus->primary = dev->bus->number;
@@ -292,6 +295,38 @@ void of_scan_pci_bridge(struct pci_dev *dev)
292} 295}
293EXPORT_SYMBOL(of_scan_pci_bridge); 296EXPORT_SYMBOL(of_scan_pci_bridge);
294 297
298static struct pci_dev *of_scan_pci_dev(struct pci_bus *bus,
299 struct device_node *dn)
300{
301 struct pci_dev *dev = NULL;
302 const u32 *reg;
303 int reglen, devfn;
304
305 pr_debug(" * %s\n", dn->full_name);
306 if (!of_device_is_available(dn))
307 return NULL;
308
309 reg = of_get_property(dn, "reg", &reglen);
310 if (reg == NULL || reglen < 20)
311 return NULL;
312 devfn = (reg[0] >> 8) & 0xff;
313
314 /* Check if the PCI device is already there */
315 dev = pci_get_slot(bus, devfn);
316 if (dev) {
317 pci_dev_put(dev);
318 return dev;
319 }
320
321 /* create a new pci_dev for this device */
322 dev = of_create_pci_dev(dn, bus, devfn);
323 if (!dev)
324 return NULL;
325
326 pr_debug(" dev header type: %x\n", dev->hdr_type);
327 return dev;
328}
329
295/** 330/**
296 * __of_scan_bus - given a PCI bus node, setup bus and scan for child devices 331 * __of_scan_bus - given a PCI bus node, setup bus and scan for child devices
297 * @node: device tree node for the PCI bus 332 * @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,
302 int rescan_existing) 337 int rescan_existing)
303{ 338{
304 struct device_node *child; 339 struct device_node *child;
305 const u32 *reg;
306 int reglen, devfn;
307 struct pci_dev *dev; 340 struct pci_dev *dev;
308 341
309 pr_debug("of_scan_bus(%s) bus no %d...\n", 342 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,
311 344
312 /* Scan direct children */ 345 /* Scan direct children */
313 for_each_child_of_node(node, child) { 346 for_each_child_of_node(node, child) {
314 pr_debug(" * %s\n", child->full_name); 347 dev = of_scan_pci_dev(bus, child);
315 if (!of_device_is_available(child))
316 continue;
317 reg = of_get_property(child, "reg", &reglen);
318 if (reg == NULL || reglen < 20)
319 continue;
320 devfn = (reg[0] >> 8) & 0xff;
321
322 /* create a new pci_dev for this device */
323 dev = of_create_pci_dev(child, bus, devfn);
324 if (!dev) 348 if (!dev)
325 continue; 349 continue;
326 pr_debug(" dev header type: %x\n", dev->hdr_type); 350 pr_debug(" dev header type: %x\n", dev->hdr_type);
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 5eccda9fd33f..607902424e73 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -644,7 +644,8 @@ unsigned char ibm_architecture_vec[] = {
644 W(0xfffe0000), W(0x003a0000), /* POWER5/POWER5+ */ 644 W(0xfffe0000), W(0x003a0000), /* POWER5/POWER5+ */
645 W(0xffff0000), W(0x003e0000), /* POWER6 */ 645 W(0xffff0000), W(0x003e0000), /* POWER6 */
646 W(0xffff0000), W(0x003f0000), /* POWER7 */ 646 W(0xffff0000), W(0x003f0000), /* POWER7 */
647 W(0xffff0000), W(0x004b0000), /* POWER8 */ 647 W(0xffff0000), W(0x004b0000), /* POWER8E */
648 W(0xffff0000), W(0x004d0000), /* POWER8 */
648 W(0xffffffff), W(0x0f000004), /* all 2.07-compliant */ 649 W(0xffffffff), W(0x0f000004), /* all 2.07-compliant */
649 W(0xffffffff), W(0x0f000003), /* all 2.06-compliant */ 650 W(0xffffffff), W(0x0f000003), /* all 2.06-compliant */
650 W(0xffffffff), W(0x0f000002), /* all 2.05-compliant */ 651 W(0xffffffff), W(0x0f000002), /* all 2.05-compliant */
@@ -706,7 +707,7 @@ unsigned char ibm_architecture_vec[] = {
706 * must match by the macro below. Update the definition if 707 * must match by the macro below. Update the definition if
707 * the structure layout changes. 708 * the structure layout changes.
708 */ 709 */
709#define IBM_ARCH_VEC_NRCORES_OFFSET 117 710#define IBM_ARCH_VEC_NRCORES_OFFSET 125
710 W(NR_CPUS), /* number of cores supported */ 711 W(NR_CPUS), /* number of cores supported */
711 0, 712 0,
712 0, 713 0,
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 654e479802f2..f096e72262f4 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -38,9 +38,6 @@ jiffies = jiffies_64 + 4;
38#endif 38#endif
39SECTIONS 39SECTIONS
40{ 40{
41 . = 0;
42 reloc_start = .;
43
44 . = KERNELBASE; 41 . = KERNELBASE;
45 42
46/* 43/*
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 3f0c30ae4791..c33d939120c9 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -43,6 +43,7 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
43{ 43{
44 unsigned long va; 44 unsigned long va;
45 unsigned int penc; 45 unsigned int penc;
46 unsigned long sllp;
46 47
47 /* 48 /*
48 * We need 14 to 65 bits of va for a tlibe of 4K page 49 * 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)
64 /* clear out bits after (52) [0....52.....63] */ 65 /* clear out bits after (52) [0....52.....63] */
65 va &= ~((1ul << (64 - 52)) - 1); 66 va &= ~((1ul << (64 - 52)) - 1);
66 va |= ssize << 8; 67 va |= ssize << 8;
67 va |= mmu_psize_defs[apsize].sllp << 6; 68 sllp = ((mmu_psize_defs[apsize].sllp & SLB_VSID_L) >> 6) |
69 ((mmu_psize_defs[apsize].sllp & SLB_VSID_LP) >> 4);
70 va |= sllp << 5;
68 asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2) 71 asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2)
69 : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206) 72 : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
70 : "memory"); 73 : "memory");
@@ -98,6 +101,7 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
98{ 101{
99 unsigned long va; 102 unsigned long va;
100 unsigned int penc; 103 unsigned int penc;
104 unsigned long sllp;
101 105
102 /* VPN_SHIFT can be atmost 12 */ 106 /* VPN_SHIFT can be atmost 12 */
103 va = vpn << VPN_SHIFT; 107 va = vpn << VPN_SHIFT;
@@ -113,7 +117,9 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
113 /* clear out bits after(52) [0....52.....63] */ 117 /* clear out bits after(52) [0....52.....63] */
114 va &= ~((1ul << (64 - 52)) - 1); 118 va &= ~((1ul << (64 - 52)) - 1);
115 va |= ssize << 8; 119 va |= ssize << 8;
116 va |= mmu_psize_defs[apsize].sllp << 6; 120 sllp = ((mmu_psize_defs[apsize].sllp & SLB_VSID_L) >> 6) |
121 ((mmu_psize_defs[apsize].sllp & SLB_VSID_LP) >> 4);
122 va |= sllp << 5;
117 asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)" 123 asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)"
118 : : "r"(va) : "memory"); 124 : : "r"(va) : "memory");
119 break; 125 break;
@@ -554,6 +560,7 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
554 seg_off |= vpi << shift; 560 seg_off |= vpi << shift;
555 } 561 }
556 *vpn = vsid << (SID_SHIFT - VPN_SHIFT) | seg_off >> VPN_SHIFT; 562 *vpn = vsid << (SID_SHIFT - VPN_SHIFT) | seg_off >> VPN_SHIFT;
563 break;
557 case MMU_SEGSIZE_1T: 564 case MMU_SEGSIZE_1T:
558 /* We only have 40 - 23 bits of seg_off in avpn */ 565 /* We only have 40 - 23 bits of seg_off in avpn */
559 seg_off = (avpn & 0x1ffff) << 23; 566 seg_off = (avpn & 0x1ffff) << 23;
@@ -563,6 +570,7 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
563 seg_off |= vpi << shift; 570 seg_off |= vpi << shift;
564 } 571 }
565 *vpn = vsid << (SID_SHIFT_1T - VPN_SHIFT) | seg_off >> VPN_SHIFT; 572 *vpn = vsid << (SID_SHIFT_1T - VPN_SHIFT) | seg_off >> VPN_SHIFT;
573 break;
566 default: 574 default:
567 *vpn = size = 0; 575 *vpn = size = 0;
568 } 576 }
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index a3985aee77fe..24a45f91c65f 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1252,8 +1252,11 @@ nocheck:
1252 1252
1253 ret = 0; 1253 ret = 0;
1254 out: 1254 out:
1255 if (has_branch_stack(event)) 1255 if (has_branch_stack(event)) {
1256 power_pmu_bhrb_enable(event); 1256 power_pmu_bhrb_enable(event);
1257 cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
1258 event->attr.branch_sample_type);
1259 }
1257 1260
1258 perf_pmu_enable(event->pmu); 1261 perf_pmu_enable(event->pmu);
1259 local_irq_restore(flags); 1262 local_irq_restore(flags);
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index 96a64d6a8bdf..7466374d2787 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -561,18 +561,13 @@ static int power8_generic_events[] = {
561static u64 power8_bhrb_filter_map(u64 branch_sample_type) 561static u64 power8_bhrb_filter_map(u64 branch_sample_type)
562{ 562{
563 u64 pmu_bhrb_filter = 0; 563 u64 pmu_bhrb_filter = 0;
564 u64 br_privilege = branch_sample_type & ONLY_PLM;
565 564
566 /* BHRB and regular PMU events share the same prvillege state 565 /* BHRB and regular PMU events share the same privilege state
567 * filter configuration. BHRB is always recorded along with a 566 * filter configuration. BHRB is always recorded along with a
568 * regular PMU event. So privilege state filter criteria for BHRB 567 * regular PMU event. As the privilege state filter is handled
569 * and the companion PMU events has to be the same. As a default 568 * in the basic PMC configuration of the accompanying regular
570 * "perf record" tool sets all privillege bits ON when no filter 569 * PMU event, we ignore any separate BHRB specific request.
571 * criteria is provided in the command line. So as along as all
572 * privillege bits are ON or they are OFF, we are good to go.
573 */ 570 */
574 if ((br_privilege != 7) && (br_privilege != 0))
575 return -1;
576 571
577 /* No branch filter requested */ 572 /* No branch filter requested */
578 if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY) 573 if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY)
@@ -621,10 +616,19 @@ static struct power_pmu power8_pmu = {
621 616
622static int __init init_power8_pmu(void) 617static int __init init_power8_pmu(void)
623{ 618{
619 int rc;
620
624 if (!cur_cpu_spec->oprofile_cpu_type || 621 if (!cur_cpu_spec->oprofile_cpu_type ||
625 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power8")) 622 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power8"))
626 return -ENODEV; 623 return -ENODEV;
627 624
628 return register_power_pmu(&power8_pmu); 625 rc = register_power_pmu(&power8_pmu);
626 if (rc)
627 return rc;
628
629 /* Tell userspace that EBB is supported */
630 cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_EBB;
631
632 return 0;
629} 633}
630early_initcall(init_power8_pmu); 634early_initcall(init_power8_pmu);
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index 969cce73055a..79663d26e6ea 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -114,7 +114,7 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
114 * the root bridge. So it's not reasonable to continue 114 * the root bridge. So it's not reasonable to continue
115 * the probing. 115 * the probing.
116 */ 116 */
117 if (!dn || !edev) 117 if (!dn || !edev || edev->pe)
118 return 0; 118 return 0;
119 119
120 /* Skip for PCI-ISA bridge */ 120 /* Skip for PCI-ISA bridge */
@@ -122,8 +122,19 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
122 return 0; 122 return 0;
123 123
124 /* Initialize eeh device */ 124 /* Initialize eeh device */
125 edev->class_code = dev->class; 125 edev->class_code = dev->class;
126 edev->mode = 0; 126 edev->mode &= 0xFFFFFF00;
127 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
128 edev->mode |= EEH_DEV_BRIDGE;
129 if (pci_is_pcie(dev)) {
130 edev->pcie_cap = pci_pcie_cap(dev);
131
132 if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
133 edev->mode |= EEH_DEV_ROOT_PORT;
134 else if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM)
135 edev->mode |= EEH_DEV_DS_PORT;
136 }
137
127 edev->config_addr = ((dev->bus->number << 8) | dev->devfn); 138 edev->config_addr = ((dev->bus->number << 8) | dev->devfn);
128 edev->pe_config_addr = phb->bdfn_to_pe(phb, dev->bus, dev->devfn & 0xff); 139 edev->pe_config_addr = phb->bdfn_to_pe(phb, dev->bus, dev->devfn & 0xff);
129 140
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 49b57b9f835d..d8140b125e62 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1266,7 +1266,7 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1266 opal_pci_set_pe(phb_id, 0, 0, 7, 1, 1 , OPAL_MAP_PE); 1266 opal_pci_set_pe(phb_id, 0, 0, 7, 1, 1 , OPAL_MAP_PE);
1267} 1267}
1268 1268
1269void pnv_pci_init_ioda2_phb(struct device_node *np) 1269void __init pnv_pci_init_ioda2_phb(struct device_node *np)
1270{ 1270{
1271 pnv_pci_init_ioda_phb(np, 0, PNV_PHB_IODA2); 1271 pnv_pci_init_ioda_phb(np, 0, PNV_PHB_IODA2);
1272} 1272}
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index 1bd3399146ed..62b4f8025de0 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -19,7 +19,6 @@ config PPC_PSERIES
19 select ZLIB_DEFLATE 19 select ZLIB_DEFLATE
20 select PPC_DOORBELL 20 select PPC_DOORBELL
21 select HAVE_CONTEXT_TRACKING 21 select HAVE_CONTEXT_TRACKING
22 select HOTPLUG if SMP
23 select HOTPLUG_CPU if SMP 22 select HOTPLUG_CPU if SMP
24 default y 23 default y
25 24
diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
index b456b157d33d..7fbc25b1813f 100644
--- a/arch/powerpc/platforms/pseries/eeh_pseries.c
+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
@@ -133,6 +133,48 @@ static int pseries_eeh_init(void)
133 return 0; 133 return 0;
134} 134}
135 135
136static int pseries_eeh_cap_start(struct device_node *dn)
137{
138 struct pci_dn *pdn = PCI_DN(dn);
139 u32 status;
140
141 if (!pdn)
142 return 0;
143
144 rtas_read_config(pdn, PCI_STATUS, 2, &status);
145 if (!(status & PCI_STATUS_CAP_LIST))
146 return 0;
147
148 return PCI_CAPABILITY_LIST;
149}
150
151
152static int pseries_eeh_find_cap(struct device_node *dn, int cap)
153{
154 struct pci_dn *pdn = PCI_DN(dn);
155 int pos = pseries_eeh_cap_start(dn);
156 int cnt = 48; /* Maximal number of capabilities */
157 u32 id;
158
159 if (!pos)
160 return 0;
161
162 while (cnt--) {
163 rtas_read_config(pdn, pos, 1, &pos);
164 if (pos < 0x40)
165 break;
166 pos &= ~3;
167 rtas_read_config(pdn, pos + PCI_CAP_LIST_ID, 1, &id);
168 if (id == 0xff)
169 break;
170 if (id == cap)
171 return pos;
172 pos += PCI_CAP_LIST_NEXT;
173 }
174
175 return 0;
176}
177
136/** 178/**
137 * pseries_eeh_of_probe - EEH probe on the given device 179 * pseries_eeh_of_probe - EEH probe on the given device
138 * @dn: OF node 180 * @dn: OF node
@@ -146,14 +188,16 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag)
146{ 188{
147 struct eeh_dev *edev; 189 struct eeh_dev *edev;
148 struct eeh_pe pe; 190 struct eeh_pe pe;
191 struct pci_dn *pdn = PCI_DN(dn);
149 const u32 *class_code, *vendor_id, *device_id; 192 const u32 *class_code, *vendor_id, *device_id;
150 const u32 *regs; 193 const u32 *regs;
194 u32 pcie_flags;
151 int enable = 0; 195 int enable = 0;
152 int ret; 196 int ret;
153 197
154 /* Retrieve OF node and eeh device */ 198 /* Retrieve OF node and eeh device */
155 edev = of_node_to_eeh_dev(dn); 199 edev = of_node_to_eeh_dev(dn);
156 if (!of_device_is_available(dn)) 200 if (edev->pe || !of_device_is_available(dn))
157 return NULL; 201 return NULL;
158 202
159 /* Retrieve class/vendor/device IDs */ 203 /* Retrieve class/vendor/device IDs */
@@ -167,9 +211,26 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag)
167 if (dn->type && !strcmp(dn->type, "isa")) 211 if (dn->type && !strcmp(dn->type, "isa"))
168 return NULL; 212 return NULL;
169 213
170 /* Update class code and mode of eeh device */ 214 /*
215 * Update class code and mode of eeh device. We need
216 * correctly reflects that current device is root port
217 * or PCIe switch downstream port.
218 */
171 edev->class_code = *class_code; 219 edev->class_code = *class_code;
172 edev->mode = 0; 220 edev->pcie_cap = pseries_eeh_find_cap(dn, PCI_CAP_ID_EXP);
221 edev->mode &= 0xFFFFFF00;
222 if ((edev->class_code >> 8) == PCI_CLASS_BRIDGE_PCI) {
223 edev->mode |= EEH_DEV_BRIDGE;
224 if (edev->pcie_cap) {
225 rtas_read_config(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
226 2, &pcie_flags);
227 pcie_flags = (pcie_flags & PCI_EXP_FLAGS_TYPE) >> 4;
228 if (pcie_flags == PCI_EXP_TYPE_ROOT_PORT)
229 edev->mode |= EEH_DEV_ROOT_PORT;
230 else if (pcie_flags == PCI_EXP_TYPE_DOWNSTREAM)
231 edev->mode |= EEH_DEV_DS_PORT;
232 }
233 }
173 234
174 /* Retrieve the device address */ 235 /* Retrieve the device address */
175 regs = of_get_property(dn, "reg", NULL); 236 regs = of_get_property(dn, "reg", NULL);
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 02d6e21619bb..8bad880bd177 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -146,7 +146,7 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
146 flags = 0; 146 flags = 0;
147 147
148 /* Make pHyp happy */ 148 /* Make pHyp happy */
149 if ((rflags & _PAGE_NO_CACHE) & !(rflags & _PAGE_WRITETHRU)) 149 if ((rflags & _PAGE_NO_CACHE) && !(rflags & _PAGE_WRITETHRU))
150 hpte_r &= ~_PAGE_COHERENT; 150 hpte_r &= ~_PAGE_COHERENT;
151 if (firmware_has_feature(FW_FEATURE_XCMO) && !(hpte_r & HPTE_R_N)) 151 if (firmware_has_feature(FW_FEATURE_XCMO) && !(hpte_r & HPTE_R_N))
152 flags |= H_COALESCE_CAND; 152 flags |= H_COALESCE_CAND;
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 7b3cbde8c783..721c0586b284 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -287,6 +287,9 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
287 unsigned long *savep; 287 unsigned long *savep;
288 struct rtas_error_log *h, *errhdr = NULL; 288 struct rtas_error_log *h, *errhdr = NULL;
289 289
290 /* Mask top two bits */
291 regs->gpr[3] &= ~(0x3UL << 62);
292
290 if (!VALID_FWNMI_BUFFER(regs->gpr[3])) { 293 if (!VALID_FWNMI_BUFFER(regs->gpr[3])) {
291 printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]); 294 printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]);
292 return NULL; 295 return NULL;
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 6b499870662f..b0e6435b2f02 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -91,7 +91,15 @@ struct thread_struct {
91#endif 91#endif
92}; 92};
93 93
94#define PER_FLAG_NO_TE 1UL /* Flag to disable transactions. */ 94/* Flag to disable transactions. */
95#define PER_FLAG_NO_TE 1UL
96/* Flag to enable random transaction aborts. */
97#define PER_FLAG_TE_ABORT_RAND 2UL
98/* Flag to specify random transaction abort mode:
99 * - abort each transaction at a random instruction before TEND if set.
100 * - abort random transactions at a random instruction if cleared.
101 */
102#define PER_FLAG_TE_ABORT_RAND_TEND 4UL
95 103
96typedef struct thread_struct thread_struct; 104typedef struct thread_struct thread_struct;
97 105
diff --git a/arch/s390/include/asm/switch_to.h b/arch/s390/include/asm/switch_to.h
index f3a9e0f92704..80b6f11263c4 100644
--- a/arch/s390/include/asm/switch_to.h
+++ b/arch/s390/include/asm/switch_to.h
@@ -10,7 +10,7 @@
10#include <linux/thread_info.h> 10#include <linux/thread_info.h>
11 11
12extern struct task_struct *__switch_to(void *, void *); 12extern struct task_struct *__switch_to(void *, void *);
13extern void update_per_regs(struct task_struct *task); 13extern void update_cr_regs(struct task_struct *task);
14 14
15static inline void save_fp_regs(s390_fp_regs *fpregs) 15static inline void save_fp_regs(s390_fp_regs *fpregs)
16{ 16{
@@ -86,7 +86,7 @@ static inline void restore_access_regs(unsigned int *acrs)
86 restore_fp_regs(&next->thread.fp_regs); \ 86 restore_fp_regs(&next->thread.fp_regs); \
87 restore_access_regs(&next->thread.acrs[0]); \ 87 restore_access_regs(&next->thread.acrs[0]); \
88 restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ 88 restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
89 update_per_regs(next); \ 89 update_cr_regs(next); \
90 } \ 90 } \
91 prev = __switch_to(prev,next); \ 91 prev = __switch_to(prev,next); \
92} while (0) 92} while (0)
diff --git a/arch/s390/include/uapi/asm/ptrace.h b/arch/s390/include/uapi/asm/ptrace.h
index 3aa9f1ec5b29..7a84619e315e 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -400,6 +400,7 @@ typedef struct
400#define PTRACE_POKE_SYSTEM_CALL 0x5008 400#define PTRACE_POKE_SYSTEM_CALL 0x5008
401#define PTRACE_ENABLE_TE 0x5009 401#define PTRACE_ENABLE_TE 0x5009
402#define PTRACE_DISABLE_TE 0x5010 402#define PTRACE_DISABLE_TE 0x5010
403#define PTRACE_TE_ABORT_RAND 0x5011
403 404
404/* 405/*
405 * PT_PROT definition is loosely based on hppa bsd definition in 406 * PT_PROT definition is loosely based on hppa bsd definition in
diff --git a/arch/s390/kernel/cache.c b/arch/s390/kernel/cache.c
index 64b24650e4f8..dd62071624be 100644
--- a/arch/s390/kernel/cache.c
+++ b/arch/s390/kernel/cache.c
@@ -173,7 +173,7 @@ error:
173 } 173 }
174} 174}
175 175
176static struct cache_dir *__cpuinit cache_create_cache_dir(int cpu) 176static struct cache_dir *cache_create_cache_dir(int cpu)
177{ 177{
178 struct cache_dir *cache_dir; 178 struct cache_dir *cache_dir;
179 struct kobject *kobj = NULL; 179 struct kobject *kobj = NULL;
@@ -289,9 +289,8 @@ static struct kobj_type cache_index_type = {
289 .default_attrs = cache_index_default_attrs, 289 .default_attrs = cache_index_default_attrs,
290}; 290};
291 291
292static int __cpuinit cache_create_index_dir(struct cache_dir *cache_dir, 292static int cache_create_index_dir(struct cache_dir *cache_dir,
293 struct cache *cache, int index, 293 struct cache *cache, int index, int cpu)
294 int cpu)
295{ 294{
296 struct cache_index_dir *index_dir; 295 struct cache_index_dir *index_dir;
297 int rc; 296 int rc;
@@ -313,7 +312,7 @@ out:
313 return rc; 312 return rc;
314} 313}
315 314
316static int __cpuinit cache_add_cpu(int cpu) 315static int cache_add_cpu(int cpu)
317{ 316{
318 struct cache_dir *cache_dir; 317 struct cache_dir *cache_dir;
319 struct cache *cache; 318 struct cache *cache;
@@ -335,7 +334,7 @@ static int __cpuinit cache_add_cpu(int cpu)
335 return 0; 334 return 0;
336} 335}
337 336
338static void __cpuinit cache_remove_cpu(int cpu) 337static void cache_remove_cpu(int cpu)
339{ 338{
340 struct cache_index_dir *index, *next; 339 struct cache_index_dir *index, *next;
341 struct cache_dir *cache_dir; 340 struct cache_dir *cache_dir;
@@ -354,8 +353,8 @@ static void __cpuinit cache_remove_cpu(int cpu)
354 cache_dir_cpu[cpu] = NULL; 353 cache_dir_cpu[cpu] = NULL;
355} 354}
356 355
357static int __cpuinit cache_hotplug(struct notifier_block *nfb, 356static int cache_hotplug(struct notifier_block *nfb, unsigned long action,
358 unsigned long action, void *hcpu) 357 void *hcpu)
359{ 358{
360 int cpu = (long)hcpu; 359 int cpu = (long)hcpu;
361 int rc = 0; 360 int rc = 0;
diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
index f703d91bf720..d8f355657171 100644
--- a/arch/s390/kernel/crash_dump.c
+++ b/arch/s390/kernel/crash_dump.c
@@ -21,6 +21,48 @@
21#define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y))) 21#define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))
22#define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y)))) 22#define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y))))
23 23
24
25/*
26 * Return physical address for virtual address
27 */
28static inline void *load_real_addr(void *addr)
29{
30 unsigned long real_addr;
31
32 asm volatile(
33 " lra %0,0(%1)\n"
34 " jz 0f\n"
35 " la %0,0\n"
36 "0:"
37 : "=a" (real_addr) : "a" (addr) : "cc");
38 return (void *)real_addr;
39}
40
41/*
42 * Copy up to one page to vmalloc or real memory
43 */
44static ssize_t copy_page_real(void *buf, void *src, size_t csize)
45{
46 size_t size;
47
48 if (is_vmalloc_addr(buf)) {
49 BUG_ON(csize >= PAGE_SIZE);
50 /* If buf is not page aligned, copy first part */
51 size = min(roundup(__pa(buf), PAGE_SIZE) - __pa(buf), csize);
52 if (size) {
53 if (memcpy_real(load_real_addr(buf), src, size))
54 return -EFAULT;
55 buf += size;
56 src += size;
57 }
58 /* Copy second part */
59 size = csize - size;
60 return (size) ? memcpy_real(load_real_addr(buf), src, size) : 0;
61 } else {
62 return memcpy_real(buf, src, csize);
63 }
64}
65
24/* 66/*
25 * Copy one page from "oldmem" 67 * Copy one page from "oldmem"
26 * 68 *
@@ -32,6 +74,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
32 size_t csize, unsigned long offset, int userbuf) 74 size_t csize, unsigned long offset, int userbuf)
33{ 75{
34 unsigned long src; 76 unsigned long src;
77 int rc;
35 78
36 if (!csize) 79 if (!csize)
37 return 0; 80 return 0;
@@ -43,11 +86,11 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
43 src < OLDMEM_BASE + OLDMEM_SIZE) 86 src < OLDMEM_BASE + OLDMEM_SIZE)
44 src -= OLDMEM_BASE; 87 src -= OLDMEM_BASE;
45 if (userbuf) 88 if (userbuf)
46 copy_to_user_real((void __force __user *) buf, (void *) src, 89 rc = copy_to_user_real((void __force __user *) buf,
47 csize); 90 (void *) src, csize);
48 else 91 else
49 memcpy_real(buf, (void *) src, csize); 92 rc = copy_page_real(buf, (void *) src, csize);
50 return csize; 93 return (rc == 0) ? csize : rc;
51} 94}
52 95
53/* 96/*
diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
index 390d9ae57bb2..fb99c2057b85 100644
--- a/arch/s390/kernel/perf_cpum_cf.c
+++ b/arch/s390/kernel/perf_cpum_cf.c
@@ -639,8 +639,8 @@ static struct pmu cpumf_pmu = {
639 .cancel_txn = cpumf_pmu_cancel_txn, 639 .cancel_txn = cpumf_pmu_cancel_txn,
640}; 640};
641 641
642static int __cpuinit cpumf_pmu_notifier(struct notifier_block *self, 642static int cpumf_pmu_notifier(struct notifier_block *self, unsigned long action,
643 unsigned long action, void *hcpu) 643 void *hcpu)
644{ 644{
645 unsigned int cpu = (long) hcpu; 645 unsigned int cpu = (long) hcpu;
646 int flags; 646 int flags;
diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
index 753c41d0ffd3..24612029f450 100644
--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -21,7 +21,7 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id);
21/* 21/*
22 * cpu_init - initializes state that is per-CPU. 22 * cpu_init - initializes state that is per-CPU.
23 */ 23 */
24void __cpuinit cpu_init(void) 24void cpu_init(void)
25{ 25{
26 struct s390_idle_data *idle = &__get_cpu_var(s390_idle); 26 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
27 struct cpuid *id = &__get_cpu_var(cpu_id); 27 struct cpuid *id = &__get_cpu_var(cpu_id);
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index a314c57f4e94..e9fadb04e3c6 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -47,7 +47,7 @@ enum s390_regset {
47 REGSET_GENERAL_EXTENDED, 47 REGSET_GENERAL_EXTENDED,
48}; 48};
49 49
50void update_per_regs(struct task_struct *task) 50void update_cr_regs(struct task_struct *task)
51{ 51{
52 struct pt_regs *regs = task_pt_regs(task); 52 struct pt_regs *regs = task_pt_regs(task);
53 struct thread_struct *thread = &task->thread; 53 struct thread_struct *thread = &task->thread;
@@ -56,17 +56,25 @@ void update_per_regs(struct task_struct *task)
56#ifdef CONFIG_64BIT 56#ifdef CONFIG_64BIT
57 /* Take care of the enable/disable of transactional execution. */ 57 /* Take care of the enable/disable of transactional execution. */
58 if (MACHINE_HAS_TE) { 58 if (MACHINE_HAS_TE) {
59 unsigned long cr0, cr0_new; 59 unsigned long cr[3], cr_new[3];
60 60
61 __ctl_store(cr0, 0, 0); 61 __ctl_store(cr, 0, 2);
62 /* set or clear transaction execution bits 8 and 9. */ 62 cr_new[1] = cr[1];
63 /* Set or clear transaction execution TXC/PIFO bits 8 and 9. */
63 if (task->thread.per_flags & PER_FLAG_NO_TE) 64 if (task->thread.per_flags & PER_FLAG_NO_TE)
64 cr0_new = cr0 & ~(3UL << 54); 65 cr_new[0] = cr[0] & ~(3UL << 54);
65 else 66 else
66 cr0_new = cr0 | (3UL << 54); 67 cr_new[0] = cr[0] | (3UL << 54);
67 /* Only load control register 0 if necessary. */ 68 /* Set or clear transaction execution TDC bits 62 and 63. */
68 if (cr0 != cr0_new) 69 cr_new[2] = cr[2] & ~3UL;
69 __ctl_load(cr0_new, 0, 0); 70 if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND) {
71 if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND_TEND)
72 cr_new[2] |= 1UL;
73 else
74 cr_new[2] |= 2UL;
75 }
76 if (memcmp(&cr_new, &cr, sizeof(cr)))
77 __ctl_load(cr_new, 0, 2);
70 } 78 }
71#endif 79#endif
72 /* Copy user specified PER registers */ 80 /* Copy user specified PER registers */
@@ -100,14 +108,14 @@ void user_enable_single_step(struct task_struct *task)
100{ 108{
101 set_tsk_thread_flag(task, TIF_SINGLE_STEP); 109 set_tsk_thread_flag(task, TIF_SINGLE_STEP);
102 if (task == current) 110 if (task == current)
103 update_per_regs(task); 111 update_cr_regs(task);
104} 112}
105 113
106void user_disable_single_step(struct task_struct *task) 114void user_disable_single_step(struct task_struct *task)
107{ 115{
108 clear_tsk_thread_flag(task, TIF_SINGLE_STEP); 116 clear_tsk_thread_flag(task, TIF_SINGLE_STEP);
109 if (task == current) 117 if (task == current)
110 update_per_regs(task); 118 update_cr_regs(task);
111} 119}
112 120
113/* 121/*
@@ -447,6 +455,26 @@ long arch_ptrace(struct task_struct *child, long request,
447 if (!MACHINE_HAS_TE) 455 if (!MACHINE_HAS_TE)
448 return -EIO; 456 return -EIO;
449 child->thread.per_flags |= PER_FLAG_NO_TE; 457 child->thread.per_flags |= PER_FLAG_NO_TE;
458 child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND;
459 return 0;
460 case PTRACE_TE_ABORT_RAND:
461 if (!MACHINE_HAS_TE || (child->thread.per_flags & PER_FLAG_NO_TE))
462 return -EIO;
463 switch (data) {
464 case 0UL:
465 child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND;
466 break;
467 case 1UL:
468 child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND;
469 child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND_TEND;
470 break;
471 case 2UL:
472 child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND;
473 child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND_TEND;
474 break;
475 default:
476 return -EINVAL;
477 }
450 return 0; 478 return 0;
451 default: 479 default:
452 /* Removing high order bit from addr (only for 31 bit). */ 480 /* Removing high order bit from addr (only for 31 bit). */
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 15a016c10563..d386c4e9d2e5 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -165,7 +165,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit)
165 pcpu_sigp_retry(pcpu, order, 0); 165 pcpu_sigp_retry(pcpu, order, 0);
166} 166}
167 167
168static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) 168static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
169{ 169{
170 struct _lowcore *lc; 170 struct _lowcore *lc;
171 171
@@ -616,10 +616,9 @@ static struct sclp_cpu_info *smp_get_cpu_info(void)
616 return info; 616 return info;
617} 617}
618 618
619static int __cpuinit smp_add_present_cpu(int cpu); 619static int smp_add_present_cpu(int cpu);
620 620
621static int __cpuinit __smp_rescan_cpus(struct sclp_cpu_info *info, 621static int __smp_rescan_cpus(struct sclp_cpu_info *info, int sysfs_add)
622 int sysfs_add)
623{ 622{
624 struct pcpu *pcpu; 623 struct pcpu *pcpu;
625 cpumask_t avail; 624 cpumask_t avail;
@@ -685,7 +684,7 @@ static void __init smp_detect_cpus(void)
685/* 684/*
686 * Activate a secondary processor. 685 * Activate a secondary processor.
687 */ 686 */
688static void __cpuinit smp_start_secondary(void *cpuvoid) 687static void smp_start_secondary(void *cpuvoid)
689{ 688{
690 S390_lowcore.last_update_clock = get_tod_clock(); 689 S390_lowcore.last_update_clock = get_tod_clock();
691 S390_lowcore.restart_stack = (unsigned long) restart_stack; 690 S390_lowcore.restart_stack = (unsigned long) restart_stack;
@@ -708,7 +707,7 @@ static void __cpuinit smp_start_secondary(void *cpuvoid)
708} 707}
709 708
710/* Upping and downing of CPUs */ 709/* Upping and downing of CPUs */
711int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 710int __cpu_up(unsigned int cpu, struct task_struct *tidle)
712{ 711{
713 struct pcpu *pcpu; 712 struct pcpu *pcpu;
714 int rc; 713 int rc;
@@ -964,8 +963,8 @@ static struct attribute_group cpu_online_attr_group = {
964 .attrs = cpu_online_attrs, 963 .attrs = cpu_online_attrs,
965}; 964};
966 965
967static int __cpuinit smp_cpu_notify(struct notifier_block *self, 966static int smp_cpu_notify(struct notifier_block *self, unsigned long action,
968 unsigned long action, void *hcpu) 967 void *hcpu)
969{ 968{
970 unsigned int cpu = (unsigned int)(long)hcpu; 969 unsigned int cpu = (unsigned int)(long)hcpu;
971 struct cpu *c = &pcpu_devices[cpu].cpu; 970 struct cpu *c = &pcpu_devices[cpu].cpu;
@@ -983,7 +982,7 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self,
983 return notifier_from_errno(err); 982 return notifier_from_errno(err);
984} 983}
985 984
986static int __cpuinit smp_add_present_cpu(int cpu) 985static int smp_add_present_cpu(int cpu)
987{ 986{
988 struct cpu *c = &pcpu_devices[cpu].cpu; 987 struct cpu *c = &pcpu_devices[cpu].cpu;
989 struct device *s = &c->dev; 988 struct device *s = &c->dev;
diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index 62f89d98e880..811f542b8ed4 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -418,7 +418,7 @@ void s390_adjust_jiffies(void)
418/* 418/*
419 * calibrate the delay loop 419 * calibrate the delay loop
420 */ 420 */
421void __cpuinit calibrate_delay(void) 421void calibrate_delay(void)
422{ 422{
423 s390_adjust_jiffies(); 423 s390_adjust_jiffies();
424 /* Print the good old Bogomips line .. */ 424 /* Print the good old Bogomips line .. */
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 3fb09359eda6..9b9c1b78ec67 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -371,14 +371,14 @@ EXPORT_SYMBOL(del_virt_timer);
371/* 371/*
372 * Start the virtual CPU timer on the current CPU. 372 * Start the virtual CPU timer on the current CPU.
373 */ 373 */
374void __cpuinit init_cpu_vtimer(void) 374void init_cpu_vtimer(void)
375{ 375{
376 /* set initial cpu timer */ 376 /* set initial cpu timer */
377 set_vtimer(VTIMER_MAX_SLICE); 377 set_vtimer(VTIMER_MAX_SLICE);
378} 378}
379 379
380static int __cpuinit s390_nohz_notify(struct notifier_block *self, 380static int s390_nohz_notify(struct notifier_block *self, unsigned long action,
381 unsigned long action, void *hcpu) 381 void *hcpu)
382{ 382{
383 struct s390_idle_data *idle; 383 struct s390_idle_data *idle;
384 long cpu = (long) hcpu; 384 long cpu = (long) hcpu;
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 047c3e4c59a2..f00aefb66a4e 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -639,8 +639,8 @@ out:
639 put_task_struct(tsk); 639 put_task_struct(tsk);
640} 640}
641 641
642static int __cpuinit pfault_cpu_notify(struct notifier_block *self, 642static int pfault_cpu_notify(struct notifier_block *self, unsigned long action,
643 unsigned long action, void *hcpu) 643 void *hcpu)
644{ 644{
645 struct thread_struct *thread, *next; 645 struct thread_struct *thread, *next;
646 struct task_struct *tsk; 646 struct task_struct *tsk;
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 82f165f8078c..d5f10a43a58f 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -9,6 +9,8 @@
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/if_vlan.h> 10#include <linux/if_vlan.h>
11#include <linux/filter.h> 11#include <linux/filter.h>
12#include <linux/random.h>
13#include <linux/init.h>
12#include <asm/cacheflush.h> 14#include <asm/cacheflush.h>
13#include <asm/processor.h> 15#include <asm/processor.h>
14#include <asm/facility.h> 16#include <asm/facility.h>
@@ -221,6 +223,37 @@ static void bpf_jit_epilogue(struct bpf_jit *jit)
221 EMIT2(0x07fe); 223 EMIT2(0x07fe);
222} 224}
223 225
226/* Helper to find the offset of pkt_type in sk_buff
227 * Make sure its still a 3bit field starting at the MSBs within a byte.
228 */
229#define PKT_TYPE_MAX 0xe0
230static int pkt_type_offset;
231
232static int __init bpf_pkt_type_offset_init(void)
233{
234 struct sk_buff skb_probe = {
235 .pkt_type = ~0,
236 };
237 char *ct = (char *)&skb_probe;
238 int off;
239
240 pkt_type_offset = -1;
241 for (off = 0; off < sizeof(struct sk_buff); off++) {
242 if (!ct[off])
243 continue;
244 if (ct[off] == PKT_TYPE_MAX)
245 pkt_type_offset = off;
246 else {
247 /* Found non matching bit pattern, fix needed. */
248 WARN_ON_ONCE(1);
249 pkt_type_offset = -1;
250 return -1;
251 }
252 }
253 return 0;
254}
255device_initcall(bpf_pkt_type_offset_init);
256
224/* 257/*
225 * make sure we dont leak kernel information to user 258 * make sure we dont leak kernel information to user
226 */ 259 */
@@ -720,6 +753,16 @@ call_fn: /* lg %r1,<d(function)>(%r13) */
720 EMIT4_DISP(0x88500000, 12); 753 EMIT4_DISP(0x88500000, 12);
721 } 754 }
722 break; 755 break;
756 case BPF_S_ANC_PKTTYPE:
757 if (pkt_type_offset < 0)
758 goto out;
759 /* lhi %r5,0 */
760 EMIT4(0xa7580000);
761 /* ic %r5,<d(pkt_type_offset)>(%r2) */
762 EMIT4_DISP(0x43502000, pkt_type_offset);
763 /* srl %r5,5 */
764 EMIT4_DISP(0x88500000, 5);
765 break;
723 case BPF_S_ANC_CPU: /* A = smp_processor_id() */ 766 case BPF_S_ANC_CPU: /* A = smp_processor_id() */
724#ifdef CONFIG_SMP 767#ifdef CONFIG_SMP
725 /* l %r5,<d(cpu_nr)> */ 768 /* l %r5,<d(cpu_nr)> */
@@ -738,8 +781,41 @@ out:
738 return -1; 781 return -1;
739} 782}
740 783
784/*
785 * Note: for security reasons, bpf code will follow a randomly
786 * sized amount of illegal instructions.
787 */
788struct bpf_binary_header {
789 unsigned int pages;
790 u8 image[];
791};
792
793static struct bpf_binary_header *bpf_alloc_binary(unsigned int bpfsize,
794 u8 **image_ptr)
795{
796 struct bpf_binary_header *header;
797 unsigned int sz, hole;
798
799 /* Most BPF filters are really small, but if some of them fill a page,
800 * allow at least 128 extra bytes for illegal instructions.
801 */
802 sz = round_up(bpfsize + sizeof(*header) + 128, PAGE_SIZE);
803 header = module_alloc(sz);
804 if (!header)
805 return NULL;
806 memset(header, 0, sz);
807 header->pages = sz / PAGE_SIZE;
808 hole = sz - bpfsize + sizeof(*header);
809 /* Insert random number of illegal instructions before BPF code
810 * and make sure the first instruction starts at an even address.
811 */
812 *image_ptr = &header->image[(prandom_u32() % hole) & -2];
813 return header;
814}
815
741void bpf_jit_compile(struct sk_filter *fp) 816void bpf_jit_compile(struct sk_filter *fp)
742{ 817{
818 struct bpf_binary_header *header = NULL;
743 unsigned long size, prg_len, lit_len; 819 unsigned long size, prg_len, lit_len;
744 struct bpf_jit jit, cjit; 820 struct bpf_jit jit, cjit;
745 unsigned int *addrs; 821 unsigned int *addrs;
@@ -772,12 +848,11 @@ void bpf_jit_compile(struct sk_filter *fp)
772 } else if (jit.prg == cjit.prg && jit.lit == cjit.lit) { 848 } else if (jit.prg == cjit.prg && jit.lit == cjit.lit) {
773 prg_len = jit.prg - jit.start; 849 prg_len = jit.prg - jit.start;
774 lit_len = jit.lit - jit.mid; 850 lit_len = jit.lit - jit.mid;
775 size = max_t(unsigned long, prg_len + lit_len, 851 size = prg_len + lit_len;
776 sizeof(struct work_struct));
777 if (size >= BPF_SIZE_MAX) 852 if (size >= BPF_SIZE_MAX)
778 goto out; 853 goto out;
779 jit.start = module_alloc(size); 854 header = bpf_alloc_binary(size, &jit.start);
780 if (!jit.start) 855 if (!header)
781 goto out; 856 goto out;
782 jit.prg = jit.mid = jit.start + prg_len; 857 jit.prg = jit.mid = jit.start + prg_len;
783 jit.lit = jit.end = jit.start + prg_len + lit_len; 858 jit.lit = jit.end = jit.start + prg_len + lit_len;
@@ -788,37 +863,25 @@ void bpf_jit_compile(struct sk_filter *fp)
788 cjit = jit; 863 cjit = jit;
789 } 864 }
790 if (bpf_jit_enable > 1) { 865 if (bpf_jit_enable > 1) {
791 pr_err("flen=%d proglen=%lu pass=%d image=%p\n", 866 bpf_jit_dump(fp->len, jit.end - jit.start, pass, jit.start);
792 fp->len, jit.end - jit.start, pass, jit.start); 867 if (jit.start)
793 if (jit.start) {
794 printk(KERN_ERR "JIT code:\n");
795 print_fn_code(jit.start, jit.mid - jit.start); 868 print_fn_code(jit.start, jit.mid - jit.start);
796 print_hex_dump(KERN_ERR, "JIT literals:\n",
797 DUMP_PREFIX_ADDRESS, 16, 1,
798 jit.mid, jit.end - jit.mid, false);
799 }
800 } 869 }
801 if (jit.start) 870 if (jit.start) {
871 set_memory_ro((unsigned long)header, header->pages);
802 fp->bpf_func = (void *) jit.start; 872 fp->bpf_func = (void *) jit.start;
873 }
803out: 874out:
804 kfree(addrs); 875 kfree(addrs);
805} 876}
806 877
807static void jit_free_defer(struct work_struct *arg)
808{
809 module_free(NULL, arg);
810}
811
812/* run from softirq, we must use a work_struct to call
813 * module_free() from process context
814 */
815void bpf_jit_free(struct sk_filter *fp) 878void bpf_jit_free(struct sk_filter *fp)
816{ 879{
817 struct work_struct *work; 880 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
881 struct bpf_binary_header *header = (void *)addr;
818 882
819 if (fp->bpf_func == sk_run_filter) 883 if (fp->bpf_func == sk_run_filter)
820 return; 884 return;
821 work = (struct work_struct *)fp->bpf_func; 885 set_memory_rw(addr, header->pages);
822 INIT_WORK(work, jit_free_defer); 886 module_free(NULL, header);
823 schedule_work(work);
824} 887}
diff --git a/arch/score/mm/tlb-score.c b/arch/score/mm/tlb-score.c
index 6fdb100244c8..004073717de0 100644
--- a/arch/score/mm/tlb-score.c
+++ b/arch/score/mm/tlb-score.c
@@ -240,7 +240,7 @@ void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
240 local_irq_restore(flags); 240 local_irq_restore(flags);
241} 241}
242 242
243void __cpuinit tlb_init(void) 243void tlb_init(void)
244{ 244{
245 tlblock_set(0); 245 tlblock_set(0);
246 local_flush_tlb_all(); 246 local_flush_tlb_all();
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index 61a07dafcd46..ecf83cd158dc 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -43,9 +43,9 @@
43 * peripherals (nofpu, nodsp, and so forth). 43 * peripherals (nofpu, nodsp, and so forth).
44 */ 44 */
45#define onchip_setup(x) \ 45#define onchip_setup(x) \
46static int x##_disabled __cpuinitdata = !cpu_has_##x; \ 46static int x##_disabled = !cpu_has_##x; \
47 \ 47 \
48static int __cpuinit x##_setup(char *opts) \ 48static int x##_setup(char *opts) \
49{ \ 49{ \
50 x##_disabled = 1; \ 50 x##_disabled = 1; \
51 return 1; \ 51 return 1; \
@@ -59,7 +59,7 @@ onchip_setup(dsp);
59#define CPUOPM 0xff2f0000 59#define CPUOPM 0xff2f0000
60#define CPUOPM_RABD (1 << 5) 60#define CPUOPM_RABD (1 << 5)
61 61
62static void __cpuinit speculative_execution_init(void) 62static void speculative_execution_init(void)
63{ 63{
64 /* Clear RABD */ 64 /* Clear RABD */
65 __raw_writel(__raw_readl(CPUOPM) & ~CPUOPM_RABD, CPUOPM); 65 __raw_writel(__raw_readl(CPUOPM) & ~CPUOPM_RABD, CPUOPM);
@@ -78,7 +78,7 @@ static void __cpuinit speculative_execution_init(void)
78#define EXPMASK_BRDSSLP (1 << 1) 78#define EXPMASK_BRDSSLP (1 << 1)
79#define EXPMASK_MMCAW (1 << 4) 79#define EXPMASK_MMCAW (1 << 4)
80 80
81static void __cpuinit expmask_init(void) 81static void expmask_init(void)
82{ 82{
83 unsigned long expmask = __raw_readl(EXPMASK); 83 unsigned long expmask = __raw_readl(EXPMASK);
84 84
@@ -217,7 +217,7 @@ static void detect_cache_shape(void)
217 l2_cache_shape = -1; /* No S-cache */ 217 l2_cache_shape = -1; /* No S-cache */
218} 218}
219 219
220static void __cpuinit fpu_init(void) 220static void fpu_init(void)
221{ 221{
222 /* Disable the FPU */ 222 /* Disable the FPU */
223 if (fpu_disabled && (current_cpu_data.flags & CPU_HAS_FPU)) { 223 if (fpu_disabled && (current_cpu_data.flags & CPU_HAS_FPU)) {
@@ -230,7 +230,7 @@ static void __cpuinit fpu_init(void)
230} 230}
231 231
232#ifdef CONFIG_SH_DSP 232#ifdef CONFIG_SH_DSP
233static void __cpuinit release_dsp(void) 233static void release_dsp(void)
234{ 234{
235 unsigned long sr; 235 unsigned long sr;
236 236
@@ -244,7 +244,7 @@ static void __cpuinit release_dsp(void)
244 ); 244 );
245} 245}
246 246
247static void __cpuinit dsp_init(void) 247static void dsp_init(void)
248{ 248{
249 unsigned long sr; 249 unsigned long sr;
250 250
@@ -276,7 +276,7 @@ static void __cpuinit dsp_init(void)
276 release_dsp(); 276 release_dsp();
277} 277}
278#else 278#else
279static inline void __cpuinit dsp_init(void) { } 279static inline void dsp_init(void) { }
280#endif /* CONFIG_SH_DSP */ 280#endif /* CONFIG_SH_DSP */
281 281
282/** 282/**
@@ -295,7 +295,7 @@ static inline void __cpuinit dsp_init(void) { }
295 * Each processor family is still responsible for doing its own probing 295 * Each processor family is still responsible for doing its own probing
296 * and cache configuration in cpu_probe(). 296 * and cache configuration in cpu_probe().
297 */ 297 */
298asmlinkage void __cpuinit cpu_init(void) 298asmlinkage void cpu_init(void)
299{ 299{
300 current_thread_info()->cpu = hard_smp_processor_id(); 300 current_thread_info()->cpu = hard_smp_processor_id();
301 301
diff --git a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c
index bab8e75958ae..6c687ae812ef 100644
--- a/arch/sh/kernel/cpu/sh2/probe.c
+++ b/arch/sh/kernel/cpu/sh2/probe.c
@@ -13,7 +13,7 @@
13#include <asm/processor.h> 13#include <asm/processor.h>
14#include <asm/cache.h> 14#include <asm/cache.h>
15 15
16void __cpuinit cpu_probe(void) 16void cpu_probe(void)
17{ 17{
18#if defined(CONFIG_CPU_SUBTYPE_SH7619) 18#if defined(CONFIG_CPU_SUBTYPE_SH7619)
19 boot_cpu_data.type = CPU_SH7619; 19 boot_cpu_data.type = CPU_SH7619;
diff --git a/arch/sh/kernel/cpu/sh2a/probe.c b/arch/sh/kernel/cpu/sh2a/probe.c
index 5170b6aa4129..3f87971082f1 100644
--- a/arch/sh/kernel/cpu/sh2a/probe.c
+++ b/arch/sh/kernel/cpu/sh2a/probe.c
@@ -13,7 +13,7 @@
13#include <asm/processor.h> 13#include <asm/processor.h>
14#include <asm/cache.h> 14#include <asm/cache.h>
15 15
16void __cpuinit cpu_probe(void) 16void cpu_probe(void)
17{ 17{
18 boot_cpu_data.family = CPU_FAMILY_SH2A; 18 boot_cpu_data.family = CPU_FAMILY_SH2A;
19 19
diff --git a/arch/sh/kernel/cpu/sh3/probe.c b/arch/sh/kernel/cpu/sh3/probe.c
index bf23c322e164..426e1e1dcedc 100644
--- a/arch/sh/kernel/cpu/sh3/probe.c
+++ b/arch/sh/kernel/cpu/sh3/probe.c
@@ -16,7 +16,7 @@
16#include <asm/cache.h> 16#include <asm/cache.h>
17#include <asm/io.h> 17#include <asm/io.h>
18 18
19void __cpuinit cpu_probe(void) 19void cpu_probe(void)
20{ 20{
21 unsigned long addr0, addr1, data0, data1, data2, data3; 21 unsigned long addr0, addr1, data0, data1, data2, data3;
22 22
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index 0fbbd50bc8ad..a521bcf50695 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -15,7 +15,7 @@
15#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/cache.h> 16#include <asm/cache.h>
17 17
18void __cpuinit cpu_probe(void) 18void cpu_probe(void)
19{ 19{
20 unsigned long pvr, prr, cvr; 20 unsigned long pvr, prr, cvr;
21 unsigned long size; 21 unsigned long size;
diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index 03f2b55757cf..4a298808789c 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -124,7 +124,7 @@ static void shx3_update_boot_vector(unsigned int cpu)
124 __raw_writel(STBCR_RESET, STBCR_REG(cpu)); 124 __raw_writel(STBCR_RESET, STBCR_REG(cpu));
125} 125}
126 126
127static int __cpuinit 127static int
128shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 128shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
129{ 129{
130 unsigned int cpu = (unsigned int)hcpu; 130 unsigned int cpu = (unsigned int)hcpu;
@@ -143,11 +143,11 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
143 return NOTIFY_OK; 143 return NOTIFY_OK;
144} 144}
145 145
146static struct notifier_block __cpuinitdata shx3_cpu_notifier = { 146static struct notifier_block shx3_cpu_notifier = {
147 .notifier_call = shx3_cpu_callback, 147 .notifier_call = shx3_cpu_callback,
148}; 148};
149 149
150static int __cpuinit register_shx3_cpu_notifier(void) 150static int register_shx3_cpu_notifier(void)
151{ 151{
152 register_hotcpu_notifier(&shx3_cpu_notifier); 152 register_hotcpu_notifier(&shx3_cpu_notifier);
153 return 0; 153 return 0;
diff --git a/arch/sh/kernel/cpu/sh5/probe.c b/arch/sh/kernel/cpu/sh5/probe.c
index 9e882409e4e9..eca427c2f2f3 100644
--- a/arch/sh/kernel/cpu/sh5/probe.c
+++ b/arch/sh/kernel/cpu/sh5/probe.c
@@ -17,7 +17,7 @@
17#include <asm/cache.h> 17#include <asm/cache.h>
18#include <asm/tlb.h> 18#include <asm/tlb.h>
19 19
20void __cpuinit cpu_probe(void) 20void cpu_probe(void)
21{ 21{
22 unsigned long long cir; 22 unsigned long long cir;
23 23
diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c
index 068b8a2759b5..b9cefebda55c 100644
--- a/arch/sh/kernel/perf_event.c
+++ b/arch/sh/kernel/perf_event.c
@@ -367,7 +367,7 @@ static void sh_pmu_setup(int cpu)
367 memset(cpuhw, 0, sizeof(struct cpu_hw_events)); 367 memset(cpuhw, 0, sizeof(struct cpu_hw_events));
368} 368}
369 369
370static int __cpuinit 370static int
371sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) 371sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
372{ 372{
373 unsigned int cpu = (long)hcpu; 373 unsigned int cpu = (long)hcpu;
@@ -384,7 +384,7 @@ sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
384 return NOTIFY_OK; 384 return NOTIFY_OK;
385} 385}
386 386
387int __cpuinit register_sh_pmu(struct sh_pmu *_pmu) 387int register_sh_pmu(struct sh_pmu *_pmu)
388{ 388{
389 if (sh_pmu) 389 if (sh_pmu)
390 return -EBUSY; 390 return -EBUSY;
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 055d91b70305..53bc6c4c84ec 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -65,7 +65,7 @@ void arch_task_cache_init(void)
65# define HAVE_SOFTFP 0 65# define HAVE_SOFTFP 0
66#endif 66#endif
67 67
68void __cpuinit init_thread_xstate(void) 68void init_thread_xstate(void)
69{ 69{
70 if (boot_cpu_data.flags & CPU_HAS_FPU) 70 if (boot_cpu_data.flags & CPU_HAS_FPU)
71 xstate_size = sizeof(struct sh_fpu_hard_struct); 71 xstate_size = sizeof(struct sh_fpu_hard_struct);
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index ebe7a7d97215..1cf90e947dbf 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -172,7 +172,7 @@ disable:
172#endif 172#endif
173} 173}
174 174
175void __cpuinit calibrate_delay(void) 175void calibrate_delay(void)
176{ 176{
177 struct clk *clk = clk_get(NULL, "cpu_clk"); 177 struct clk *clk = clk_get(NULL, "cpu_clk");
178 178
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 45696451f0ea..86a7936a980b 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -37,7 +37,7 @@ struct plat_smp_ops *mp_ops = NULL;
37/* State of each CPU */ 37/* State of each CPU */
38DEFINE_PER_CPU(int, cpu_state) = { 0 }; 38DEFINE_PER_CPU(int, cpu_state) = { 0 };
39 39
40void __cpuinit register_smp_ops(struct plat_smp_ops *ops) 40void register_smp_ops(struct plat_smp_ops *ops)
41{ 41{
42 if (mp_ops) 42 if (mp_ops)
43 printk(KERN_WARNING "Overriding previously set SMP ops\n"); 43 printk(KERN_WARNING "Overriding previously set SMP ops\n");
@@ -45,7 +45,7 @@ void __cpuinit register_smp_ops(struct plat_smp_ops *ops)
45 mp_ops = ops; 45 mp_ops = ops;
46} 46}
47 47
48static inline void __cpuinit smp_store_cpu_info(unsigned int cpu) 48static inline void smp_store_cpu_info(unsigned int cpu)
49{ 49{
50 struct sh_cpuinfo *c = cpu_data + cpu; 50 struct sh_cpuinfo *c = cpu_data + cpu;
51 51
@@ -174,7 +174,7 @@ void native_play_dead(void)
174} 174}
175#endif 175#endif
176 176
177asmlinkage void __cpuinit start_secondary(void) 177asmlinkage void start_secondary(void)
178{ 178{
179 unsigned int cpu = smp_processor_id(); 179 unsigned int cpu = smp_processor_id();
180 struct mm_struct *mm = &init_mm; 180 struct mm_struct *mm = &init_mm;
@@ -215,7 +215,7 @@ extern struct {
215 void *thread_info; 215 void *thread_info;
216} stack_start; 216} stack_start;
217 217
218int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tsk) 218int __cpu_up(unsigned int cpu, struct task_struct *tsk)
219{ 219{
220 unsigned long timeout; 220 unsigned long timeout;
221 221
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index 5f513a64dedf..68e99f09171d 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -741,7 +741,7 @@ asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
741 die_if_kernel("exception", regs, ex); 741 die_if_kernel("exception", regs, ex);
742} 742}
743 743
744void __cpuinit per_cpu_trap_init(void) 744void per_cpu_trap_init(void)
745{ 745{
746 extern void *vbr_base; 746 extern void *vbr_base;
747 747
diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c
index f87d20da1791..112ea11c030d 100644
--- a/arch/sh/kernel/traps_64.c
+++ b/arch/sh/kernel/traps_64.c
@@ -810,7 +810,7 @@ asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
810 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0); 810 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);
811} 811}
812 812
813void __cpuinit per_cpu_trap_init(void) 813void per_cpu_trap_init(void)
814{ 814{
815 /* Nothing to do for now, VBR initialization later. */ 815 /* Nothing to do for now, VBR initialization later. */
816} 816}
diff --git a/arch/sh/mm/tlb-sh5.c b/arch/sh/mm/tlb-sh5.c
index ff1c40a31cbc..e4bb2a8e0a69 100644
--- a/arch/sh/mm/tlb-sh5.c
+++ b/arch/sh/mm/tlb-sh5.c
@@ -17,7 +17,7 @@
17/** 17/**
18 * sh64_tlb_init - Perform initial setup for the DTLB and ITLB. 18 * sh64_tlb_init - Perform initial setup for the DTLB and ITLB.
19 */ 19 */
20int __cpuinit sh64_tlb_init(void) 20int sh64_tlb_init(void)
21{ 21{
22 /* Assign some sane DTLB defaults */ 22 /* Assign some sane DTLB defaults */
23 cpu_data->dtlb.entries = 64; 23 cpu_data->dtlb.entries = 64;
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
index 11d460f6f9cc..62d6b153ffa2 100644
--- a/arch/sparc/kernel/ds.c
+++ b/arch/sparc/kernel/ds.c
@@ -528,10 +528,8 @@ static void dr_cpu_mark(struct ds_data *resp, int cpu, int ncpus,
528 } 528 }
529} 529}
530 530
531static int __cpuinit dr_cpu_configure(struct ds_info *dp, 531static int dr_cpu_configure(struct ds_info *dp, struct ds_cap_state *cp,
532 struct ds_cap_state *cp, 532 u64 req_num, cpumask_t *mask)
533 u64 req_num,
534 cpumask_t *mask)
535{ 533{
536 struct ds_data *resp; 534 struct ds_data *resp;
537 int resp_len, ncpus, cpu; 535 int resp_len, ncpus, cpu;
@@ -627,9 +625,8 @@ static int dr_cpu_unconfigure(struct ds_info *dp,
627 return 0; 625 return 0;
628} 626}
629 627
630static void __cpuinit dr_cpu_data(struct ds_info *dp, 628static void dr_cpu_data(struct ds_info *dp, struct ds_cap_state *cp, void *buf,
631 struct ds_cap_state *cp, 629 int len)
632 void *buf, int len)
633{ 630{
634 struct ds_data *data = buf; 631 struct ds_data *data = buf;
635 struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1); 632 struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1);
diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
index cc3c5cb47cda..9c179fbfb219 100644
--- a/arch/sparc/kernel/entry.h
+++ b/arch/sparc/kernel/entry.h
@@ -250,7 +250,7 @@ extern struct ino_bucket *ivector_table;
250extern unsigned long ivector_table_pa; 250extern unsigned long ivector_table_pa;
251 251
252extern void init_irqwork_curcpu(void); 252extern void init_irqwork_curcpu(void);
253extern void __cpuinit sun4v_register_mondo_queues(int this_cpu); 253extern void sun4v_register_mondo_queues(int this_cpu);
254 254
255#endif /* CONFIG_SPARC32 */ 255#endif /* CONFIG_SPARC32 */
256#endif /* _ENTRY_H */ 256#endif /* _ENTRY_H */
diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
index 605c960b2fa6..4eb1a5a1d544 100644
--- a/arch/sparc/kernel/hvtramp.S
+++ b/arch/sparc/kernel/hvtramp.S
@@ -16,7 +16,6 @@
16#include <asm/asi.h> 16#include <asm/asi.h>
17#include <asm/pil.h> 17#include <asm/pil.h>
18 18
19 __CPUINIT
20 .align 8 19 .align 8
21 .globl hv_cpu_startup, hv_cpu_startup_end 20 .globl hv_cpu_startup, hv_cpu_startup_end
22 21
diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
index 9bcbbe2c4e7e..d4840cec2c55 100644
--- a/arch/sparc/kernel/irq_64.c
+++ b/arch/sparc/kernel/irq_64.c
@@ -835,7 +835,8 @@ void notrace init_irqwork_curcpu(void)
835 * Therefore you cannot make any OBP calls, not even prom_printf, 835 * Therefore you cannot make any OBP calls, not even prom_printf,
836 * from these two routines. 836 * from these two routines.
837 */ 837 */
838static void __cpuinit notrace register_one_mondo(unsigned long paddr, unsigned long type, unsigned long qmask) 838static void notrace register_one_mondo(unsigned long paddr, unsigned long type,
839 unsigned long qmask)
839{ 840{
840 unsigned long num_entries = (qmask + 1) / 64; 841 unsigned long num_entries = (qmask + 1) / 64;
841 unsigned long status; 842 unsigned long status;
@@ -848,7 +849,7 @@ static void __cpuinit notrace register_one_mondo(unsigned long paddr, unsigned l
848 } 849 }
849} 850}
850 851
851void __cpuinit notrace sun4v_register_mondo_queues(int this_cpu) 852void notrace sun4v_register_mondo_queues(int this_cpu)
852{ 853{
853 struct trap_per_cpu *tb = &trap_block[this_cpu]; 854 struct trap_per_cpu *tb = &trap_block[this_cpu];
854 855
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index d7aa524b7283..6edf955f987c 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -54,7 +54,7 @@ extern ctxd_t *srmmu_ctx_table_phys;
54static int smp_processors_ready; 54static int smp_processors_ready;
55extern volatile unsigned long cpu_callin_map[NR_CPUS]; 55extern volatile unsigned long cpu_callin_map[NR_CPUS];
56extern cpumask_t smp_commenced_mask; 56extern cpumask_t smp_commenced_mask;
57void __cpuinit leon_configure_cache_smp(void); 57void leon_configure_cache_smp(void);
58static void leon_ipi_init(void); 58static void leon_ipi_init(void);
59 59
60/* IRQ number of LEON IPIs */ 60/* IRQ number of LEON IPIs */
@@ -69,12 +69,12 @@ static inline unsigned long do_swap(volatile unsigned long *ptr,
69 return val; 69 return val;
70} 70}
71 71
72void __cpuinit leon_cpu_pre_starting(void *arg) 72void leon_cpu_pre_starting(void *arg)
73{ 73{
74 leon_configure_cache_smp(); 74 leon_configure_cache_smp();
75} 75}
76 76
77void __cpuinit leon_cpu_pre_online(void *arg) 77void leon_cpu_pre_online(void *arg)
78{ 78{
79 int cpuid = hard_smp_processor_id(); 79 int cpuid = hard_smp_processor_id();
80 80
@@ -106,7 +106,7 @@ void __cpuinit leon_cpu_pre_online(void *arg)
106 106
107extern struct linux_prom_registers smp_penguin_ctable; 107extern struct linux_prom_registers smp_penguin_ctable;
108 108
109void __cpuinit leon_configure_cache_smp(void) 109void leon_configure_cache_smp(void)
110{ 110{
111 unsigned long cfg = sparc_leon3_get_dcachecfg(); 111 unsigned long cfg = sparc_leon3_get_dcachecfg();
112 int me = smp_processor_id(); 112 int me = smp_processor_id();
@@ -186,7 +186,7 @@ void __init leon_boot_cpus(void)
186 186
187} 187}
188 188
189int __cpuinit leon_boot_one_cpu(int i, struct task_struct *idle) 189int leon_boot_one_cpu(int i, struct task_struct *idle)
190{ 190{
191 int timeout; 191 int timeout;
192 192
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 831c001604e8..b90bf23e3aab 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -571,9 +571,7 @@ static void __init report_platform_properties(void)
571 mdesc_release(hp); 571 mdesc_release(hp);
572} 572}
573 573
574static void __cpuinit fill_in_one_cache(cpuinfo_sparc *c, 574static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp)
575 struct mdesc_handle *hp,
576 u64 mp)
577{ 575{
578 const u64 *level = mdesc_get_property(hp, mp, "level", NULL); 576 const u64 *level = mdesc_get_property(hp, mp, "level", NULL);
579 const u64 *size = mdesc_get_property(hp, mp, "size", NULL); 577 const u64 *size = mdesc_get_property(hp, mp, "size", NULL);
@@ -616,7 +614,7 @@ static void __cpuinit fill_in_one_cache(cpuinfo_sparc *c,
616 } 614 }
617} 615}
618 616
619static void __cpuinit mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id) 617static void mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id)
620{ 618{
621 u64 a; 619 u64 a;
622 620
@@ -649,7 +647,7 @@ static void __cpuinit mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id
649 } 647 }
650} 648}
651 649
652static void __cpuinit set_core_ids(struct mdesc_handle *hp) 650static void set_core_ids(struct mdesc_handle *hp)
653{ 651{
654 int idx; 652 int idx;
655 u64 mp; 653 u64 mp;
@@ -674,7 +672,7 @@ static void __cpuinit set_core_ids(struct mdesc_handle *hp)
674 } 672 }
675} 673}
676 674
677static void __cpuinit mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) 675static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id)
678{ 676{
679 u64 a; 677 u64 a;
680 678
@@ -693,7 +691,7 @@ static void __cpuinit mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id
693 } 691 }
694} 692}
695 693
696static void __cpuinit __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name) 694static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name)
697{ 695{
698 int idx; 696 int idx;
699 u64 mp; 697 u64 mp;
@@ -714,14 +712,14 @@ static void __cpuinit __set_proc_ids(struct mdesc_handle *hp, const char *exec_u
714 } 712 }
715} 713}
716 714
717static void __cpuinit set_proc_ids(struct mdesc_handle *hp) 715static void set_proc_ids(struct mdesc_handle *hp)
718{ 716{
719 __set_proc_ids(hp, "exec_unit"); 717 __set_proc_ids(hp, "exec_unit");
720 __set_proc_ids(hp, "exec-unit"); 718 __set_proc_ids(hp, "exec-unit");
721} 719}
722 720
723static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask, 721static void get_one_mondo_bits(const u64 *p, unsigned int *mask,
724 unsigned long def, unsigned long max) 722 unsigned long def, unsigned long max)
725{ 723{
726 u64 val; 724 u64 val;
727 725
@@ -742,8 +740,8 @@ use_default:
742 *mask = ((1U << def) * 64U) - 1U; 740 *mask = ((1U << def) * 64U) - 1U;
743} 741}
744 742
745static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp, 743static void get_mondo_data(struct mdesc_handle *hp, u64 mp,
746 struct trap_per_cpu *tb) 744 struct trap_per_cpu *tb)
747{ 745{
748 static int printed; 746 static int printed;
749 const u64 *val; 747 const u64 *val;
@@ -769,7 +767,7 @@ static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp,
769 } 767 }
770} 768}
771 769
772static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask) 770static void *mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask)
773{ 771{
774 struct mdesc_handle *hp = mdesc_grab(); 772 struct mdesc_handle *hp = mdesc_grab();
775 void *ret = NULL; 773 void *ret = NULL;
@@ -799,7 +797,8 @@ out:
799 return ret; 797 return ret;
800} 798}
801 799
802static void * __cpuinit record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) 800static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid,
801 void *arg)
803{ 802{
804 ncpus_probed++; 803 ncpus_probed++;
805#ifdef CONFIG_SMP 804#ifdef CONFIG_SMP
@@ -808,7 +807,7 @@ static void * __cpuinit record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpui
808 return NULL; 807 return NULL;
809} 808}
810 809
811void __cpuinit mdesc_populate_present_mask(cpumask_t *mask) 810void mdesc_populate_present_mask(cpumask_t *mask)
812{ 811{
813 if (tlb_type != hypervisor) 812 if (tlb_type != hypervisor)
814 return; 813 return;
@@ -841,7 +840,8 @@ void __init mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask)
841 mdesc_iterate_over_cpus(check_one_pgsz, pgsz_mask, mask); 840 mdesc_iterate_over_cpus(check_one_pgsz, pgsz_mask, mask);
842} 841}
843 842
844static void * __cpuinit fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) 843static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid,
844 void *arg)
845{ 845{
846 const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL); 846 const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL);
847 struct trap_per_cpu *tb; 847 struct trap_per_cpu *tb;
@@ -890,7 +890,7 @@ static void * __cpuinit fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpu
890 return NULL; 890 return NULL;
891} 891}
892 892
893void __cpuinit mdesc_fill_in_cpu_data(cpumask_t *mask) 893void mdesc_fill_in_cpu_data(cpumask_t *mask)
894{ 894{
895 struct mdesc_handle *hp; 895 struct mdesc_handle *hp;
896 896
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index e3f2b81c23f1..a102bfba6ea8 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -39,7 +39,7 @@
39#include "kernel.h" 39#include "kernel.h"
40#include "irq.h" 40#include "irq.h"
41 41
42volatile unsigned long cpu_callin_map[NR_CPUS] __cpuinitdata = {0,}; 42volatile unsigned long cpu_callin_map[NR_CPUS] = {0,};
43 43
44cpumask_t smp_commenced_mask = CPU_MASK_NONE; 44cpumask_t smp_commenced_mask = CPU_MASK_NONE;
45 45
@@ -53,7 +53,7 @@ const struct sparc32_ipi_ops *sparc32_ipi_ops;
53 * instruction which is much better... 53 * instruction which is much better...
54 */ 54 */
55 55
56void __cpuinit smp_store_cpu_info(int id) 56void smp_store_cpu_info(int id)
57{ 57{
58 int cpu_node; 58 int cpu_node;
59 int mid; 59 int mid;
@@ -120,7 +120,7 @@ void cpu_panic(void)
120 panic("SMP bolixed\n"); 120 panic("SMP bolixed\n");
121} 121}
122 122
123struct linux_prom_registers smp_penguin_ctable __cpuinitdata = { 0 }; 123struct linux_prom_registers smp_penguin_ctable = { 0 };
124 124
125void smp_send_reschedule(int cpu) 125void smp_send_reschedule(int cpu)
126{ 126{
@@ -259,10 +259,10 @@ void __init smp_prepare_boot_cpu(void)
259 set_cpu_possible(cpuid, true); 259 set_cpu_possible(cpuid, true);
260} 260}
261 261
262int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 262int __cpu_up(unsigned int cpu, struct task_struct *tidle)
263{ 263{
264 extern int __cpuinit smp4m_boot_one_cpu(int, struct task_struct *); 264 extern int smp4m_boot_one_cpu(int, struct task_struct *);
265 extern int __cpuinit smp4d_boot_one_cpu(int, struct task_struct *); 265 extern int smp4d_boot_one_cpu(int, struct task_struct *);
266 int ret=0; 266 int ret=0;
267 267
268 switch(sparc_cpu_model) { 268 switch(sparc_cpu_model) {
@@ -297,7 +297,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
297 return ret; 297 return ret;
298} 298}
299 299
300void __cpuinit arch_cpu_pre_starting(void *arg) 300void arch_cpu_pre_starting(void *arg)
301{ 301{
302 local_ops->cache_all(); 302 local_ops->cache_all();
303 local_ops->tlb_all(); 303 local_ops->tlb_all();
@@ -317,7 +317,7 @@ void __cpuinit arch_cpu_pre_starting(void *arg)
317 } 317 }
318} 318}
319 319
320void __cpuinit arch_cpu_pre_online(void *arg) 320void arch_cpu_pre_online(void *arg)
321{ 321{
322 unsigned int cpuid = hard_smp_processor_id(); 322 unsigned int cpuid = hard_smp_processor_id();
323 323
@@ -344,7 +344,7 @@ void __cpuinit arch_cpu_pre_online(void *arg)
344 } 344 }
345} 345}
346 346
347void __cpuinit sparc_start_secondary(void *arg) 347void sparc_start_secondary(void *arg)
348{ 348{
349 unsigned int cpu; 349 unsigned int cpu;
350 350
@@ -375,7 +375,7 @@ void __cpuinit sparc_start_secondary(void *arg)
375 BUG(); 375 BUG();
376} 376}
377 377
378void __cpuinit smp_callin(void) 378void smp_callin(void)
379{ 379{
380 sparc_start_secondary(NULL); 380 sparc_start_secondary(NULL);
381} 381}
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 77539eda928c..e142545244f2 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -87,7 +87,7 @@ extern void setup_sparc64_timer(void);
87 87
88static volatile unsigned long callin_flag = 0; 88static volatile unsigned long callin_flag = 0;
89 89
90void __cpuinit smp_callin(void) 90void smp_callin(void)
91{ 91{
92 int cpuid = hard_smp_processor_id(); 92 int cpuid = hard_smp_processor_id();
93 93
@@ -281,7 +281,8 @@ static unsigned long kimage_addr_to_ra(void *p)
281 return kern_base + (val - KERNBASE); 281 return kern_base + (val - KERNBASE);
282} 282}
283 283
284static void __cpuinit ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg, void **descrp) 284static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg,
285 void **descrp)
285{ 286{
286 extern unsigned long sparc64_ttable_tl0; 287 extern unsigned long sparc64_ttable_tl0;
287 extern unsigned long kern_locked_tte_data; 288 extern unsigned long kern_locked_tte_data;
@@ -342,7 +343,7 @@ extern unsigned long sparc64_cpu_startup;
342 */ 343 */
343static struct thread_info *cpu_new_thread = NULL; 344static struct thread_info *cpu_new_thread = NULL;
344 345
345static int __cpuinit smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle) 346static int smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle)
346{ 347{
347 unsigned long entry = 348 unsigned long entry =
348 (unsigned long)(&sparc64_cpu_startup); 349 (unsigned long)(&sparc64_cpu_startup);
@@ -1266,7 +1267,7 @@ void smp_fill_in_sib_core_maps(void)
1266 } 1267 }
1267} 1268}
1268 1269
1269int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 1270int __cpu_up(unsigned int cpu, struct task_struct *tidle)
1270{ 1271{
1271 int ret = smp_boot_one_cpu(cpu, tidle); 1272 int ret = smp_boot_one_cpu(cpu, tidle);
1272 1273
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index c9eb82f23d92..d5c319553fd0 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -50,7 +50,7 @@ static inline void show_leds(int cpuid)
50 "i" (ASI_M_CTL)); 50 "i" (ASI_M_CTL));
51} 51}
52 52
53void __cpuinit sun4d_cpu_pre_starting(void *arg) 53void sun4d_cpu_pre_starting(void *arg)
54{ 54{
55 int cpuid = hard_smp_processor_id(); 55 int cpuid = hard_smp_processor_id();
56 56
@@ -62,7 +62,7 @@ void __cpuinit sun4d_cpu_pre_starting(void *arg)
62 cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000); 62 cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000);
63} 63}
64 64
65void __cpuinit sun4d_cpu_pre_online(void *arg) 65void sun4d_cpu_pre_online(void *arg)
66{ 66{
67 unsigned long flags; 67 unsigned long flags;
68 int cpuid; 68 int cpuid;
@@ -118,7 +118,7 @@ void __init smp4d_boot_cpus(void)
118 local_ops->cache_all(); 118 local_ops->cache_all();
119} 119}
120 120
121int __cpuinit smp4d_boot_one_cpu(int i, struct task_struct *idle) 121int smp4d_boot_one_cpu(int i, struct task_struct *idle)
122{ 122{
123 unsigned long *entry = &sun4d_cpu_startup; 123 unsigned long *entry = &sun4d_cpu_startup;
124 int timeout; 124 int timeout;
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index 8a65f158153d..d3408e72d20c 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -34,11 +34,11 @@ swap_ulong(volatile unsigned long *ptr, unsigned long val)
34 return val; 34 return val;
35} 35}
36 36
37void __cpuinit sun4m_cpu_pre_starting(void *arg) 37void sun4m_cpu_pre_starting(void *arg)
38{ 38{
39} 39}
40 40
41void __cpuinit sun4m_cpu_pre_online(void *arg) 41void sun4m_cpu_pre_online(void *arg)
42{ 42{
43 int cpuid = hard_smp_processor_id(); 43 int cpuid = hard_smp_processor_id();
44 44
@@ -75,7 +75,7 @@ void __init smp4m_boot_cpus(void)
75 local_ops->cache_all(); 75 local_ops->cache_all();
76} 76}
77 77
78int __cpuinit smp4m_boot_one_cpu(int i, struct task_struct *idle) 78int smp4m_boot_one_cpu(int i, struct task_struct *idle)
79{ 79{
80 unsigned long *entry = &sun4m_cpu_startup; 80 unsigned long *entry = &sun4m_cpu_startup;
81 int timeout; 81 int timeout;
diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
index 654e8aad3bbe..c21c673e5f7c 100644
--- a/arch/sparc/kernel/sysfs.c
+++ b/arch/sparc/kernel/sysfs.c
@@ -246,7 +246,7 @@ static void unregister_cpu_online(unsigned int cpu)
246} 246}
247#endif 247#endif
248 248
249static int __cpuinit sysfs_cpu_notify(struct notifier_block *self, 249static int sysfs_cpu_notify(struct notifier_block *self,
250 unsigned long action, void *hcpu) 250 unsigned long action, void *hcpu)
251{ 251{
252 unsigned int cpu = (unsigned int)(long)hcpu; 252 unsigned int cpu = (unsigned int)(long)hcpu;
@@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
266 return NOTIFY_OK; 266 return NOTIFY_OK;
267} 267}
268 268
269static struct notifier_block __cpuinitdata sysfs_cpu_nb = { 269static struct notifier_block sysfs_cpu_nb = {
270 .notifier_call = sysfs_cpu_notify, 270 .notifier_call = sysfs_cpu_notify,
271}; 271};
272 272
diff --git a/arch/sparc/kernel/trampoline_32.S b/arch/sparc/kernel/trampoline_32.S
index 6cdb08cdabf0..76dcbd3c988a 100644
--- a/arch/sparc/kernel/trampoline_32.S
+++ b/arch/sparc/kernel/trampoline_32.S
@@ -18,7 +18,6 @@
18 .globl sun4m_cpu_startup 18 .globl sun4m_cpu_startup
19 .globl sun4d_cpu_startup 19 .globl sun4d_cpu_startup
20 20
21 __CPUINIT
22 .align 4 21 .align 4
23 22
24/* When we start up a cpu for the first time it enters this routine. 23/* When we start up a cpu for the first time it enters this routine.
@@ -94,7 +93,6 @@ smp_panic:
94/* CPUID in bootbus can be found at PA 0xff0140000 */ 93/* CPUID in bootbus can be found at PA 0xff0140000 */
95#define SUN4D_BOOTBUS_CPUID 0xf0140000 94#define SUN4D_BOOTBUS_CPUID 0xf0140000
96 95
97 __CPUINIT
98 .align 4 96 .align 4
99 97
100sun4d_cpu_startup: 98sun4d_cpu_startup:
@@ -146,7 +144,6 @@ sun4d_cpu_startup:
146 144
147 b,a smp_panic 145 b,a smp_panic
148 146
149 __CPUINIT
150 .align 4 147 .align 4
151 .global leon_smp_cpu_startup, smp_penguin_ctable 148 .global leon_smp_cpu_startup, smp_penguin_ctable
152 149
diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
index 2e973a26fbda..e0b1e13a0736 100644
--- a/arch/sparc/kernel/trampoline_64.S
+++ b/arch/sparc/kernel/trampoline_64.S
@@ -32,13 +32,11 @@ itlb_load:
32dtlb_load: 32dtlb_load:
33 .asciz "SUNW,dtlb-load" 33 .asciz "SUNW,dtlb-load"
34 34
35 /* XXX __cpuinit this thing XXX */
36#define TRAMP_STACK_SIZE 1024 35#define TRAMP_STACK_SIZE 1024
37 .align 16 36 .align 16
38tramp_stack: 37tramp_stack:
39 .skip TRAMP_STACK_SIZE 38 .skip TRAMP_STACK_SIZE
40 39
41 __CPUINIT
42 .align 8 40 .align 8
43 .globl sparc64_cpu_startup, sparc64_cpu_startup_end 41 .globl sparc64_cpu_startup, sparc64_cpu_startup_end
44sparc64_cpu_startup: 42sparc64_cpu_startup:
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index a9c42a7ffb6a..ed82edad1a39 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -1694,7 +1694,7 @@ static void __init sun4v_ktsb_init(void)
1694#endif 1694#endif
1695} 1695}
1696 1696
1697void __cpuinit sun4v_ktsb_register(void) 1697void sun4v_ktsb_register(void)
1698{ 1698{
1699 unsigned long pa, ret; 1699 unsigned long pa, ret;
1700 1700
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 036c2797dece..5d721df48a72 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -858,7 +858,7 @@ static void __init map_kernel(void)
858 } 858 }
859} 859}
860 860
861void (*poke_srmmu)(void) __cpuinitdata = NULL; 861void (*poke_srmmu)(void) = NULL;
862 862
863extern unsigned long bootmem_init(unsigned long *pages_avail); 863extern unsigned long bootmem_init(unsigned long *pages_avail);
864 864
@@ -1055,7 +1055,7 @@ static void __init init_vac_layout(void)
1055 (int)vac_cache_size, (int)vac_line_size); 1055 (int)vac_cache_size, (int)vac_line_size);
1056} 1056}
1057 1057
1058static void __cpuinit poke_hypersparc(void) 1058static void poke_hypersparc(void)
1059{ 1059{
1060 volatile unsigned long clear; 1060 volatile unsigned long clear;
1061 unsigned long mreg = srmmu_get_mmureg(); 1061 unsigned long mreg = srmmu_get_mmureg();
@@ -1107,7 +1107,7 @@ static void __init init_hypersparc(void)
1107 hypersparc_setup_blockops(); 1107 hypersparc_setup_blockops();
1108} 1108}
1109 1109
1110static void __cpuinit poke_swift(void) 1110static void poke_swift(void)
1111{ 1111{
1112 unsigned long mreg; 1112 unsigned long mreg;
1113 1113
@@ -1287,7 +1287,7 @@ static void turbosparc_flush_tlb_page(struct vm_area_struct *vma, unsigned long
1287} 1287}
1288 1288
1289 1289
1290static void __cpuinit poke_turbosparc(void) 1290static void poke_turbosparc(void)
1291{ 1291{
1292 unsigned long mreg = srmmu_get_mmureg(); 1292 unsigned long mreg = srmmu_get_mmureg();
1293 unsigned long ccreg; 1293 unsigned long ccreg;
@@ -1350,7 +1350,7 @@ static void __init init_turbosparc(void)
1350 poke_srmmu = poke_turbosparc; 1350 poke_srmmu = poke_turbosparc;
1351} 1351}
1352 1352
1353static void __cpuinit poke_tsunami(void) 1353static void poke_tsunami(void)
1354{ 1354{
1355 unsigned long mreg = srmmu_get_mmureg(); 1355 unsigned long mreg = srmmu_get_mmureg();
1356 1356
@@ -1391,7 +1391,7 @@ static void __init init_tsunami(void)
1391 tsunami_setup_blockops(); 1391 tsunami_setup_blockops();
1392} 1392}
1393 1393
1394static void __cpuinit poke_viking(void) 1394static void poke_viking(void)
1395{ 1395{
1396 unsigned long mreg = srmmu_get_mmureg(); 1396 unsigned long mreg = srmmu_get_mmureg();
1397 static int smp_catch; 1397 static int smp_catch;
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c
index 02e628065012..3ccf2cd7182e 100644
--- a/arch/tile/kernel/irq.c
+++ b/arch/tile/kernel/irq.c
@@ -220,7 +220,7 @@ void __init init_IRQ(void)
220 ipi_init(); 220 ipi_init();
221} 221}
222 222
223void __cpuinit setup_irq_regs(void) 223void setup_irq_regs(void)
224{ 224{
225 /* Enable interrupt delivery. */ 225 /* Enable interrupt delivery. */
226 unmask_irqs(~0UL); 226 unmask_irqs(~0UL);
diff --git a/arch/tile/kernel/messaging.c b/arch/tile/kernel/messaging.c
index 0858ee6b520f..00331af9525d 100644
--- a/arch/tile/kernel/messaging.c
+++ b/arch/tile/kernel/messaging.c
@@ -25,7 +25,7 @@
25/* All messages are stored here */ 25/* All messages are stored here */
26static DEFINE_PER_CPU(HV_MsgState, msg_state); 26static DEFINE_PER_CPU(HV_MsgState, msg_state);
27 27
28void __cpuinit init_messaging(void) 28void init_messaging(void)
29{ 29{
30 /* Allocate storage for messages in kernel space */ 30 /* Allocate storage for messages in kernel space */
31 HV_MsgState *state = &__get_cpu_var(msg_state); 31 HV_MsgState *state = &__get_cpu_var(msg_state);
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index 68b542677f6a..eceb8344280f 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -58,8 +58,8 @@ struct pglist_data node_data[MAX_NUMNODES] __read_mostly;
58EXPORT_SYMBOL(node_data); 58EXPORT_SYMBOL(node_data);
59 59
60/* Information on the NUMA nodes that we compute early */ 60/* Information on the NUMA nodes that we compute early */
61unsigned long __cpuinitdata node_start_pfn[MAX_NUMNODES]; 61unsigned long node_start_pfn[MAX_NUMNODES];
62unsigned long __cpuinitdata node_end_pfn[MAX_NUMNODES]; 62unsigned long node_end_pfn[MAX_NUMNODES];
63unsigned long __initdata node_memmap_pfn[MAX_NUMNODES]; 63unsigned long __initdata node_memmap_pfn[MAX_NUMNODES];
64unsigned long __initdata node_percpu_pfn[MAX_NUMNODES]; 64unsigned long __initdata node_percpu_pfn[MAX_NUMNODES];
65unsigned long __initdata node_free_pfn[MAX_NUMNODES]; 65unsigned long __initdata node_free_pfn[MAX_NUMNODES];
@@ -84,7 +84,7 @@ unsigned long __initdata boot_pc = (unsigned long)start_kernel;
84 84
85#ifdef CONFIG_HIGHMEM 85#ifdef CONFIG_HIGHMEM
86/* Page frame index of end of lowmem on each controller. */ 86/* Page frame index of end of lowmem on each controller. */
87unsigned long __cpuinitdata node_lowmem_end_pfn[MAX_NUMNODES]; 87unsigned long node_lowmem_end_pfn[MAX_NUMNODES];
88 88
89/* Number of pages that can be mapped into lowmem. */ 89/* Number of pages that can be mapped into lowmem. */
90static unsigned long __initdata mappable_physpages; 90static unsigned long __initdata mappable_physpages;
@@ -290,7 +290,7 @@ static void *__init setup_pa_va_mapping(void)
290 * This is up to 4 mappings for lowmem, one mapping per memory 290 * This is up to 4 mappings for lowmem, one mapping per memory
291 * controller, plus one for our text segment. 291 * controller, plus one for our text segment.
292 */ 292 */
293static void __cpuinit store_permanent_mappings(void) 293static void store_permanent_mappings(void)
294{ 294{
295 int i; 295 int i;
296 296
@@ -935,7 +935,7 @@ subsys_initcall(topology_init);
935 * So the values we set up here in the hypervisor may be overridden on 935 * So the values we set up here in the hypervisor may be overridden on
936 * the boot cpu as arguments are parsed. 936 * the boot cpu as arguments are parsed.
937 */ 937 */
938static __cpuinit void init_super_pages(void) 938static void init_super_pages(void)
939{ 939{
940#ifdef CONFIG_HUGETLB_SUPER_PAGES 940#ifdef CONFIG_HUGETLB_SUPER_PAGES
941 int i; 941 int i;
@@ -950,7 +950,7 @@ static __cpuinit void init_super_pages(void)
950 * 950 *
951 * Called from setup_arch() on the boot cpu, or online_secondary(). 951 * Called from setup_arch() on the boot cpu, or online_secondary().
952 */ 952 */
953void __cpuinit setup_cpu(int boot) 953void setup_cpu(int boot)
954{ 954{
955 /* The boot cpu sets up its permanent mappings much earlier. */ 955 /* The boot cpu sets up its permanent mappings much earlier. */
956 if (!boot) 956 if (!boot)
diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index 44bab29bf2f3..a535655b7089 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -133,14 +133,14 @@ static __init int reset_init_affinity(void)
133} 133}
134late_initcall(reset_init_affinity); 134late_initcall(reset_init_affinity);
135 135
136static struct cpumask cpu_started __cpuinitdata; 136static struct cpumask cpu_started;
137 137
138/* 138/*
139 * Activate a secondary processor. Very minimal; don't add anything 139 * Activate a secondary processor. Very minimal; don't add anything
140 * to this path without knowing what you're doing, since SMP booting 140 * to this path without knowing what you're doing, since SMP booting
141 * is pretty fragile. 141 * is pretty fragile.
142 */ 142 */
143static void __cpuinit start_secondary(void) 143static void start_secondary(void)
144{ 144{
145 int cpuid = smp_processor_id(); 145 int cpuid = smp_processor_id();
146 146
@@ -183,7 +183,7 @@ static void __cpuinit start_secondary(void)
183/* 183/*
184 * Bring a secondary processor online. 184 * Bring a secondary processor online.
185 */ 185 */
186void __cpuinit online_secondary(void) 186void online_secondary(void)
187{ 187{
188 /* 188 /*
189 * low-memory mappings have been cleared, flush them from 189 * low-memory mappings have been cleared, flush them from
@@ -210,7 +210,7 @@ void __cpuinit online_secondary(void)
210 cpu_startup_entry(CPUHP_ONLINE); 210 cpu_startup_entry(CPUHP_ONLINE);
211} 211}
212 212
213int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) 213int __cpu_up(unsigned int cpu, struct task_struct *tidle)
214{ 214{
215 /* Wait 5s total for all CPUs for them to come online */ 215 /* Wait 5s total for all CPUs for them to come online */
216 static int timeout; 216 static int timeout;
diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
index 5ac397ec6986..7c353d8c2da9 100644
--- a/arch/tile/kernel/time.c
+++ b/arch/tile/kernel/time.c
@@ -159,7 +159,7 @@ static DEFINE_PER_CPU(struct clock_event_device, tile_timer) = {
159 .set_mode = tile_timer_set_mode, 159 .set_mode = tile_timer_set_mode,
160}; 160};
161 161
162void __cpuinit setup_tile_timer(void) 162void setup_tile_timer(void)
163{ 163{
164 struct clock_event_device *evt = &__get_cpu_var(tile_timer); 164 struct clock_event_device *evt = &__get_cpu_var(tile_timer);
165 165
diff --git a/arch/um/include/shared/frame_kern.h b/arch/um/include/shared/frame_kern.h
index e584e40ee832..f2ca5702a4e2 100644
--- a/arch/um/include/shared/frame_kern.h
+++ b/arch/um/include/shared/frame_kern.h
@@ -6,13 +6,13 @@
6#ifndef __FRAME_KERN_H_ 6#ifndef __FRAME_KERN_H_
7#define __FRAME_KERN_H_ 7#define __FRAME_KERN_H_
8 8
9extern int setup_signal_stack_sc(unsigned long stack_top, int sig, 9extern int setup_signal_stack_sc(unsigned long stack_top, int sig,
10 struct k_sigaction *ka, 10 struct k_sigaction *ka,
11 struct pt_regs *regs, 11 struct pt_regs *regs,
12 sigset_t *mask); 12 sigset_t *mask);
13extern int setup_signal_stack_si(unsigned long stack_top, int sig, 13extern int setup_signal_stack_si(unsigned long stack_top, int sig,
14 struct k_sigaction *ka, 14 struct k_sigaction *ka,
15 struct pt_regs *regs, siginfo_t *info, 15 struct pt_regs *regs, struct siginfo *info,
16 sigset_t *mask); 16 sigset_t *mask);
17 17
18#endif 18#endif
diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index 3e831b3fd07b..f57e02e7910f 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -19,7 +19,7 @@ EXPORT_SYMBOL(unblock_signals);
19 * OK, we're invoking a handler 19 * OK, we're invoking a handler
20 */ 20 */
21static void handle_signal(struct pt_regs *regs, unsigned long signr, 21static void handle_signal(struct pt_regs *regs, unsigned long signr,
22 struct k_sigaction *ka, siginfo_t *info) 22 struct k_sigaction *ka, struct siginfo *info)
23{ 23{
24 sigset_t *oldset = sigmask_to_save(); 24 sigset_t *oldset = sigmask_to_save();
25 int singlestep = 0; 25 int singlestep = 0;
@@ -71,7 +71,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
71static int kern_do_signal(struct pt_regs *regs) 71static int kern_do_signal(struct pt_regs *regs)
72{ 72{
73 struct k_sigaction ka_copy; 73 struct k_sigaction ka_copy;
74 siginfo_t info; 74 struct siginfo info;
75 int sig, handled_sig = 0; 75 int sig, handled_sig = 0;
76 76
77 while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) { 77 while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index ff03067a3b14..007d5503f49b 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -123,7 +123,7 @@ void uml_setup_stubs(struct mm_struct *mm)
123 /* dup_mmap already holds mmap_sem */ 123 /* dup_mmap already holds mmap_sem */
124 err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START, 124 err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
125 VM_READ | VM_MAYREAD | VM_EXEC | 125 VM_READ | VM_MAYREAD | VM_EXEC |
126 VM_MAYEXEC | VM_DONTCOPY, 126 VM_MAYEXEC | VM_DONTCOPY | VM_PFNMAP,
127 mm->context.stub_pages); 127 mm->context.stub_pages);
128 if (err) { 128 if (err) {
129 printk(KERN_ERR "install_special_mapping returned %d\n", err); 129 printk(KERN_ERR "install_special_mapping returned %d\n", err);
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index 1d3e0c17340b..4ffb644d6c07 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -254,6 +254,6 @@ int strnlen_user(const void __user *str, int len)
254 n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count); 254 n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
255 if (n == 0) 255 if (n == 0)
256 return count + 1; 256 return count + 1;
257 return -EFAULT; 257 return 0;
258} 258}
259EXPORT_SYMBOL(strnlen_user); 259EXPORT_SYMBOL(strnlen_user);
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index ba4398056fe9..3c4af77e51a2 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -53,6 +53,25 @@ static void __init find_tempdir(void)
53} 53}
54 54
55/* 55/*
56 * Remove bytes from the front of the buffer and refill it so that if there's a
57 * partial string that we care about, it will be completed, and we can recognize
58 * it.
59 */
60static int pop(int fd, char *buf, size_t size, size_t npop)
61{
62 ssize_t n;
63 size_t len = strlen(&buf[npop]);
64
65 memmove(buf, &buf[npop], len + 1);
66 n = read(fd, &buf[len], size - len - 1);
67 if (n < 0)
68 return -errno;
69
70 buf[len + n] = '\0';
71 return 1;
72}
73
74/*
56 * This will return 1, with the first character in buf being the 75 * This will return 1, with the first character in buf being the
57 * character following the next instance of c in the file. This will 76 * character following the next instance of c in the file. This will
58 * read the file as needed. If there's an error, -errno is returned; 77 * read the file as needed. If there's an error, -errno is returned;
@@ -61,7 +80,6 @@ static void __init find_tempdir(void)
61static int next(int fd, char *buf, size_t size, char c) 80static int next(int fd, char *buf, size_t size, char c)
62{ 81{
63 ssize_t n; 82 ssize_t n;
64 size_t len;
65 char *ptr; 83 char *ptr;
66 84
67 while ((ptr = strchr(buf, c)) == NULL) { 85 while ((ptr = strchr(buf, c)) == NULL) {
@@ -74,20 +92,129 @@ static int next(int fd, char *buf, size_t size, char c)
74 buf[n] = '\0'; 92 buf[n] = '\0';
75 } 93 }
76 94
77 ptr++; 95 return pop(fd, buf, size, ptr - buf + 1);
78 len = strlen(ptr); 96}
79 memmove(buf, ptr, len + 1); 97
98/*
99 * Decode an octal-escaped and space-terminated path of the form used by
100 * /proc/mounts. May be used to decode a path in-place. "out" must be at least
101 * as large as the input. The output is always null-terminated. "len" gets the
102 * length of the output, excluding the trailing null. Returns 0 if a full path
103 * was successfully decoded, otherwise an error.
104 */
105static int decode_path(const char *in, char *out, size_t *len)
106{
107 char *first = out;
108 int c;
109 int i;
110 int ret = -EINVAL;
111 while (1) {
112 switch (*in) {
113 case '\0':
114 goto out;
115
116 case ' ':
117 ret = 0;
118 goto out;
119
120 case '\\':
121 in++;
122 c = 0;
123 for (i = 0; i < 3; i++) {
124 if (*in < '0' || *in > '7')
125 goto out;
126 c = (c << 3) | (*in++ - '0');
127 }
128 *(unsigned char *)out++ = (unsigned char) c;
129 break;
130
131 default:
132 *out++ = *in++;
133 break;
134 }
135 }
136
137out:
138 *out = '\0';
139 *len = out - first;
140 return ret;
141}
142
143/*
144 * Computes the length of s when encoded with three-digit octal escape sequences
145 * for the characters in chars.
146 */
147static size_t octal_encoded_length(const char *s, const char *chars)
148{
149 size_t len = strlen(s);
150 while ((s = strpbrk(s, chars)) != NULL) {
151 len += 3;
152 s++;
153 }
154
155 return len;
156}
157
158enum {
159 OUTCOME_NOTHING_MOUNTED,
160 OUTCOME_TMPFS_MOUNT,
161 OUTCOME_NON_TMPFS_MOUNT,
162};
163
164/* Read a line of /proc/mounts data looking for a tmpfs mount at "path". */
165static int read_mount(int fd, char *buf, size_t bufsize, const char *path,
166 int *outcome)
167{
168 int found;
169 int match;
170 char *space;
171 size_t len;
172
173 enum {
174 MATCH_NONE,
175 MATCH_EXACT,
176 MATCH_PARENT,
177 };
178
179 found = next(fd, buf, bufsize, ' ');
180 if (found != 1)
181 return found;
80 182
81 /* 183 /*
82 * Refill the buffer so that if there's a partial string that we care 184 * If there's no following space in the buffer, then this path is
83 * about, it will be completed, and we can recognize it. 185 * truncated, so it can't be the one we're looking for.
84 */ 186 */
85 n = read(fd, &buf[len], size - len - 1); 187 space = strchr(buf, ' ');
86 if (n < 0) 188 if (space) {
87 return -errno; 189 match = MATCH_NONE;
190 if (!decode_path(buf, buf, &len)) {
191 if (!strcmp(buf, path))
192 match = MATCH_EXACT;
193 else if (!strncmp(buf, path, len)
194 && (path[len] == '/' || !strcmp(buf, "/")))
195 match = MATCH_PARENT;
196 }
197
198 found = pop(fd, buf, bufsize, space - buf + 1);
199 if (found != 1)
200 return found;
201
202 switch (match) {
203 case MATCH_EXACT:
204 if (!strncmp(buf, "tmpfs", strlen("tmpfs")))
205 *outcome = OUTCOME_TMPFS_MOUNT;
206 else
207 *outcome = OUTCOME_NON_TMPFS_MOUNT;
208 break;
88 209
89 buf[len + n] = '\0'; 210 case MATCH_PARENT:
90 return 1; 211 /* This mount obscures any previous ones. */
212 *outcome = OUTCOME_NOTHING_MOUNTED;
213 break;
214 }
215 }
216
217 return next(fd, buf, bufsize, '\n');
91} 218}
92 219
93/* which_tmpdir is called only during early boot */ 220/* which_tmpdir is called only during early boot */
@@ -106,8 +233,12 @@ static int checked_tmpdir = 0;
106 */ 233 */
107static void which_tmpdir(void) 234static void which_tmpdir(void)
108{ 235{
109 int fd, found; 236 int fd;
110 char buf[128] = { '\0' }; 237 int found;
238 int outcome;
239 char *path;
240 char *buf;
241 size_t bufsize;
111 242
112 if (checked_tmpdir) 243 if (checked_tmpdir)
113 return; 244 return;
@@ -116,49 +247,66 @@ static void which_tmpdir(void)
116 247
117 printf("Checking for tmpfs mount on /dev/shm..."); 248 printf("Checking for tmpfs mount on /dev/shm...");
118 249
250 path = realpath("/dev/shm", NULL);
251 if (!path) {
252 printf("failed to check real path, errno = %d\n", errno);
253 return;
254 }
255 printf("%s...", path);
256
257 /*
258 * The buffer needs to be able to fit the full octal-escaped path, a
259 * space, and a trailing null in order to successfully decode it.
260 */
261 bufsize = octal_encoded_length(path, " \t\n\\") + 2;
262
263 if (bufsize < 128)
264 bufsize = 128;
265
266 buf = malloc(bufsize);
267 if (!buf) {
268 printf("malloc failed, errno = %d\n", errno);
269 goto out;
270 }
271 buf[0] = '\0';
272
119 fd = open("/proc/mounts", O_RDONLY); 273 fd = open("/proc/mounts", O_RDONLY);
120 if (fd < 0) { 274 if (fd < 0) {
121 printf("failed to open /proc/mounts, errno = %d\n", errno); 275 printf("failed to open /proc/mounts, errno = %d\n", errno);
122 return; 276 goto out1;
123 } 277 }
124 278
279 outcome = OUTCOME_NOTHING_MOUNTED;
125 while (1) { 280 while (1) {
126 found = next(fd, buf, ARRAY_SIZE(buf), ' '); 281 found = read_mount(fd, buf, bufsize, path, &outcome);
127 if (found != 1)
128 break;
129
130 if (!strncmp(buf, "/dev/shm", strlen("/dev/shm")))
131 goto found;
132
133 found = next(fd, buf, ARRAY_SIZE(buf), '\n');
134 if (found != 1) 282 if (found != 1)
135 break; 283 break;
136 } 284 }
137 285
138err: 286 if (found < 0) {
139 if (found == 0)
140 printf("nothing mounted on /dev/shm\n");
141 else if (found < 0)
142 printf("read returned errno %d\n", -found); 287 printf("read returned errno %d\n", -found);
288 } else {
289 switch (outcome) {
290 case OUTCOME_TMPFS_MOUNT:
291 printf("OK\n");
292 default_tmpdir = "/dev/shm";
293 break;
143 294
144out: 295 case OUTCOME_NON_TMPFS_MOUNT:
145 close(fd); 296 printf("not tmpfs\n");
146 297 break;
147 return;
148
149found:
150 found = next(fd, buf, ARRAY_SIZE(buf), ' ');
151 if (found != 1)
152 goto err;
153 298
154 if (strncmp(buf, "tmpfs", strlen("tmpfs"))) { 299 default:
155 printf("not tmpfs\n"); 300 printf("nothing mounted on /dev/shm\n");
156 goto out; 301 break;
302 }
157 } 303 }
158 304
159 printf("OK\n"); 305 close(fd);
160 default_tmpdir = "/dev/shm"; 306out1:
161 goto out; 307 free(buf);
308out:
309 free(path);
162} 310}
163 311
164static int __init make_tempfile(const char *template, char **out_tempname, 312static int __init make_tempfile(const char *template, char **out_tempname,
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 9d9f1b4bf826..905924b773d3 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -25,7 +25,7 @@ void (*sig_info[NSIG])(int, struct siginfo *, struct uml_pt_regs *) = {
25 [SIGIO] = sigio_handler, 25 [SIGIO] = sigio_handler,
26 [SIGVTALRM] = timer_handler }; 26 [SIGVTALRM] = timer_handler };
27 27
28static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc) 28static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)
29{ 29{
30 struct uml_pt_regs r; 30 struct uml_pt_regs r;
31 int save_errno = errno; 31 int save_errno = errno;
@@ -61,7 +61,7 @@ static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc)
61static int signals_enabled; 61static int signals_enabled;
62static unsigned int signals_pending; 62static unsigned int signals_pending;
63 63
64void sig_handler(int sig, siginfo_t *si, mcontext_t *mc) 64void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
65{ 65{
66 int enabled; 66 int enabled;
67 67
@@ -120,7 +120,7 @@ void set_sigstack(void *sig_stack, int size)
120 panic("enabling signal stack failed, errno = %d\n", errno); 120 panic("enabling signal stack failed, errno = %d\n", errno);
121} 121}
122 122
123static void (*handlers[_NSIG])(int sig, siginfo_t *si, mcontext_t *mc) = { 123static void (*handlers[_NSIG])(int sig, struct siginfo *si, mcontext_t *mc) = {
124 [SIGSEGV] = sig_handler, 124 [SIGSEGV] = sig_handler,
125 [SIGBUS] = sig_handler, 125 [SIGBUS] = sig_handler,
126 [SIGILL] = sig_handler, 126 [SIGILL] = sig_handler,
@@ -162,7 +162,7 @@ static void hard_handler(int sig, siginfo_t *si, void *p)
162 while ((sig = ffs(pending)) != 0){ 162 while ((sig = ffs(pending)) != 0){
163 sig--; 163 sig--;
164 pending &= ~(1 << sig); 164 pending &= ~(1 << sig);
165 (*handlers[sig])(sig, si, mc); 165 (*handlers[sig])(sig, (struct siginfo *)si, mc);
166 } 166 }
167 167
168 /* 168 /*
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 4625949bf1e4..d531879a4617 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -54,7 +54,7 @@ static int ptrace_dump_regs(int pid)
54 54
55void wait_stub_done(int pid) 55void wait_stub_done(int pid)
56{ 56{
57 int n, status, err; 57 int n, status, err, bad_stop = 0;
58 58
59 while (1) { 59 while (1) {
60 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL)); 60 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
@@ -74,6 +74,8 @@ void wait_stub_done(int pid)
74 74
75 if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) 75 if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0)
76 return; 76 return;
77 else
78 bad_stop = 1;
77 79
78bad_wait: 80bad_wait:
79 err = ptrace_dump_regs(pid); 81 err = ptrace_dump_regs(pid);
@@ -83,7 +85,10 @@ bad_wait:
83 printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, " 85 printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, "
84 "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno, 86 "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno,
85 status); 87 status);
86 fatal_sigsegv(); 88 if (bad_stop)
89 kill(pid, SIGKILL);
90 else
91 fatal_sigsegv();
87} 92}
88 93
89extern unsigned long current_stub_stack(void); 94extern unsigned long current_stub_stack(void);
@@ -409,7 +414,7 @@ void userspace(struct uml_pt_regs *regs)
409 if (WIFSTOPPED(status)) { 414 if (WIFSTOPPED(status)) {
410 int sig = WSTOPSIG(status); 415 int sig = WSTOPSIG(status);
411 416
412 ptrace(PTRACE_GETSIGINFO, pid, 0, &si); 417 ptrace(PTRACE_GETSIGINFO, pid, 0, (struct siginfo *)&si);
413 418
414 switch (sig) { 419 switch (sig) {
415 case SIGSEGV: 420 case SIGSEGV:
@@ -417,7 +422,7 @@ void userspace(struct uml_pt_regs *regs)
417 !ptrace_faultinfo) { 422 !ptrace_faultinfo) {
418 get_skas_faultinfo(pid, 423 get_skas_faultinfo(pid,
419 &regs->faultinfo); 424 &regs->faultinfo);
420 (*sig_info[SIGSEGV])(SIGSEGV, &si, 425 (*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si,
421 regs); 426 regs);
422 } 427 }
423 else handle_segv(pid, regs); 428 else handle_segv(pid, regs);
@@ -426,14 +431,14 @@ void userspace(struct uml_pt_regs *regs)
426 handle_trap(pid, regs, local_using_sysemu); 431 handle_trap(pid, regs, local_using_sysemu);
427 break; 432 break;
428 case SIGTRAP: 433 case SIGTRAP:
429 relay_signal(SIGTRAP, &si, regs); 434 relay_signal(SIGTRAP, (struct siginfo *)&si, regs);
430 break; 435 break;
431 case SIGVTALRM: 436 case SIGVTALRM:
432 now = os_nsecs(); 437 now = os_nsecs();
433 if (now < nsecs) 438 if (now < nsecs)
434 break; 439 break;
435 block_signals(); 440 block_signals();
436 (*sig_info[sig])(sig, &si, regs); 441 (*sig_info[sig])(sig, (struct siginfo *)&si, regs);
437 unblock_signals(); 442 unblock_signals();
438 nsecs = timer.it_value.tv_sec * 443 nsecs = timer.it_value.tv_sec *
439 UM_NSEC_PER_SEC + 444 UM_NSEC_PER_SEC +
@@ -447,7 +452,7 @@ void userspace(struct uml_pt_regs *regs)
447 case SIGFPE: 452 case SIGFPE:
448 case SIGWINCH: 453 case SIGWINCH:
449 block_signals(); 454 block_signals();
450 (*sig_info[sig])(sig, &si, regs); 455 (*sig_info[sig])(sig, (struct siginfo *)&si, regs);
451 unblock_signals(); 456 unblock_signals();
452 break; 457 break;
453 default: 458 default:
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index 7d6ba9db1be9..6c63c358a7e6 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -27,7 +27,6 @@ obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o
27obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o 27obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o
28obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o 28obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o
29obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o 29obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o
30obj-$(CONFIG_CRYPTO_CRCT10DIF_PCLMUL) += crct10dif-pclmul.o
31 30
32# These modules require assembler to support AVX. 31# These modules require assembler to support AVX.
33ifeq ($(avx_supported),yes) 32ifeq ($(avx_supported),yes)
@@ -82,4 +81,3 @@ crc32c-intel-$(CONFIG_64BIT) += crc32c-pcl-intel-asm_64.o
82crc32-pclmul-y := crc32-pclmul_asm.o crc32-pclmul_glue.o 81crc32-pclmul-y := crc32-pclmul_asm.o crc32-pclmul_glue.o
83sha256-ssse3-y := sha256-ssse3-asm.o sha256-avx-asm.o sha256-avx2-asm.o sha256_ssse3_glue.o 82sha256-ssse3-y := sha256-ssse3-asm.o sha256-avx-asm.o sha256-avx2-asm.o sha256_ssse3_glue.o
84sha512-ssse3-y := sha512-ssse3-asm.o sha512-avx-asm.o sha512-avx2-asm.o sha512_ssse3_glue.o 83sha512-ssse3-y := sha512-ssse3-asm.o sha512-avx-asm.o sha512-avx2-asm.o sha512_ssse3_glue.o
85crct10dif-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
index 35e97569d05f..000000000000
--- a/arch/x86/crypto/crct10dif-pcl-asm_64.S
+++ /dev/null
@@ -1,643 +0,0 @@
1########################################################################
2# Implement fast CRC-T10DIF computation with SSE and PCLMULQDQ instructions
3#
4# Copyright (c) 2013, Intel Corporation
5#
6# Authors:
7# Erdinc Ozturk <erdinc.ozturk@intel.com>
8# Vinodh Gopal <vinodh.gopal@intel.com>
9# James Guilford <james.guilford@intel.com>
10# Tim Chen <tim.c.chen@linux.intel.com>
11#
12# This software is available to you under a choice of one of two
13# licenses. You may choose to be licensed under the terms of the GNU
14# General Public License (GPL) Version 2, available from the file
15# COPYING in the main directory of this source tree, or the
16# OpenIB.org BSD license below:
17#
18# Redistribution and use in source and binary forms, with or without
19# modification, are permitted provided that the following conditions are
20# met:
21#
22# * Redistributions of source code must retain the above copyright
23# notice, this list of conditions and the following disclaimer.
24#
25# * Redistributions in binary form must reproduce the above copyright
26# notice, this list of conditions and the following disclaimer in the
27# documentation and/or other materials provided with the
28# distribution.
29#
30# * Neither the name of the Intel Corporation nor the names of its
31# contributors may be used to endorse or promote products derived from
32# this software without specific prior written permission.
33#
34#
35# THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY
36# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR
39# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
41# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46########################################################################
47# Function API:
48# UINT16 crc_t10dif_pcl(
49# UINT16 init_crc, //initial CRC value, 16 bits
50# const unsigned char *buf, //buffer pointer to calculate CRC on
51# UINT64 len //buffer length in bytes (64-bit data)
52# );
53#
54# Reference paper titled "Fast CRC Computation for Generic
55# Polynomials Using PCLMULQDQ Instruction"
56# URL: http://www.intel.com/content/dam/www/public/us/en/documents
57# /white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
58#
59#
60
61#include <linux/linkage.h>
62
63.text
64
65#define arg1 %rdi
66#define arg2 %rsi
67#define arg3 %rdx
68
69#define arg1_low32 %edi
70
71ENTRY(crc_t10dif_pcl)
72.align 16
73
74 # adjust the 16-bit initial_crc value, scale it to 32 bits
75 shl $16, arg1_low32
76
77 # Allocate Stack Space
78 mov %rsp, %rcx
79 sub $16*2, %rsp
80 # align stack to 16 byte boundary
81 and $~(0x10 - 1), %rsp
82
83 # check if smaller than 256
84 cmp $256, arg3
85
86 # for sizes less than 128, we can't fold 64B at a time...
87 jl _less_than_128
88
89
90 # load the initial crc value
91 movd arg1_low32, %xmm10 # initial crc
92
93 # crc value does not need to be byte-reflected, but it needs
94 # to be moved to the high part of the register.
95 # because data will be byte-reflected and will align with
96 # initial crc at correct place.
97 pslldq $12, %xmm10
98
99 movdqa SHUF_MASK(%rip), %xmm11
100 # receive the initial 64B data, xor the initial crc value
101 movdqu 16*0(arg2), %xmm0
102 movdqu 16*1(arg2), %xmm1
103 movdqu 16*2(arg2), %xmm2
104 movdqu 16*3(arg2), %xmm3
105 movdqu 16*4(arg2), %xmm4
106 movdqu 16*5(arg2), %xmm5
107 movdqu 16*6(arg2), %xmm6
108 movdqu 16*7(arg2), %xmm7
109
110 pshufb %xmm11, %xmm0
111 # XOR the initial_crc value
112 pxor %xmm10, %xmm0
113 pshufb %xmm11, %xmm1
114 pshufb %xmm11, %xmm2
115 pshufb %xmm11, %xmm3
116 pshufb %xmm11, %xmm4
117 pshufb %xmm11, %xmm5
118 pshufb %xmm11, %xmm6
119 pshufb %xmm11, %xmm7
120
121 movdqa rk3(%rip), %xmm10 #xmm10 has rk3 and rk4
122 #imm value of pclmulqdq instruction
123 #will determine which constant to use
124
125 #################################################################
126 # we subtract 256 instead of 128 to save one instruction from the loop
127 sub $256, arg3
128
129 # at this section of the code, there is 64*x+y (0<=y<64) bytes of
130 # buffer. The _fold_64_B_loop will fold 64B at a time
131 # until we have 64+y Bytes of buffer
132
133
134 # fold 64B at a time. This section of the code folds 4 xmm
135 # registers in parallel
136_fold_64_B_loop:
137
138 # update the buffer pointer
139 add $128, arg2 # buf += 64#
140
141 movdqu 16*0(arg2), %xmm9
142 movdqu 16*1(arg2), %xmm12
143 pshufb %xmm11, %xmm9
144 pshufb %xmm11, %xmm12
145 movdqa %xmm0, %xmm8
146 movdqa %xmm1, %xmm13
147 pclmulqdq $0x0 , %xmm10, %xmm0
148 pclmulqdq $0x11, %xmm10, %xmm8
149 pclmulqdq $0x0 , %xmm10, %xmm1
150 pclmulqdq $0x11, %xmm10, %xmm13
151 pxor %xmm9 , %xmm0
152 xorps %xmm8 , %xmm0
153 pxor %xmm12, %xmm1
154 xorps %xmm13, %xmm1
155
156 movdqu 16*2(arg2), %xmm9
157 movdqu 16*3(arg2), %xmm12
158 pshufb %xmm11, %xmm9
159 pshufb %xmm11, %xmm12
160 movdqa %xmm2, %xmm8
161 movdqa %xmm3, %xmm13
162 pclmulqdq $0x0, %xmm10, %xmm2
163 pclmulqdq $0x11, %xmm10, %xmm8
164 pclmulqdq $0x0, %xmm10, %xmm3
165 pclmulqdq $0x11, %xmm10, %xmm13
166 pxor %xmm9 , %xmm2
167 xorps %xmm8 , %xmm2
168 pxor %xmm12, %xmm3
169 xorps %xmm13, %xmm3
170
171 movdqu 16*4(arg2), %xmm9
172 movdqu 16*5(arg2), %xmm12
173 pshufb %xmm11, %xmm9
174 pshufb %xmm11, %xmm12
175 movdqa %xmm4, %xmm8
176 movdqa %xmm5, %xmm13
177 pclmulqdq $0x0, %xmm10, %xmm4
178 pclmulqdq $0x11, %xmm10, %xmm8
179 pclmulqdq $0x0, %xmm10, %xmm5
180 pclmulqdq $0x11, %xmm10, %xmm13
181 pxor %xmm9 , %xmm4
182 xorps %xmm8 , %xmm4
183 pxor %xmm12, %xmm5
184 xorps %xmm13, %xmm5
185
186 movdqu 16*6(arg2), %xmm9
187 movdqu 16*7(arg2), %xmm12
188 pshufb %xmm11, %xmm9
189 pshufb %xmm11, %xmm12
190 movdqa %xmm6 , %xmm8
191 movdqa %xmm7 , %xmm13
192 pclmulqdq $0x0 , %xmm10, %xmm6
193 pclmulqdq $0x11, %xmm10, %xmm8
194 pclmulqdq $0x0 , %xmm10, %xmm7
195 pclmulqdq $0x11, %xmm10, %xmm13
196 pxor %xmm9 , %xmm6
197 xorps %xmm8 , %xmm6
198 pxor %xmm12, %xmm7
199 xorps %xmm13, %xmm7
200
201 sub $128, arg3
202
203 # check if there is another 64B in the buffer to be able to fold
204 jge _fold_64_B_loop
205 ##################################################################
206
207
208 add $128, arg2
209 # at this point, the buffer pointer is pointing at the last y Bytes
210 # of the buffer the 64B of folded data is in 4 of the xmm
211 # registers: xmm0, xmm1, xmm2, xmm3
212
213
214 # fold the 8 xmm registers to 1 xmm register with different constants
215
216 movdqa rk9(%rip), %xmm10
217 movdqa %xmm0, %xmm8
218 pclmulqdq $0x11, %xmm10, %xmm0
219 pclmulqdq $0x0 , %xmm10, %xmm8
220 pxor %xmm8, %xmm7
221 xorps %xmm0, %xmm7
222
223 movdqa rk11(%rip), %xmm10
224 movdqa %xmm1, %xmm8
225 pclmulqdq $0x11, %xmm10, %xmm1
226 pclmulqdq $0x0 , %xmm10, %xmm8
227 pxor %xmm8, %xmm7
228 xorps %xmm1, %xmm7
229
230 movdqa rk13(%rip), %xmm10
231 movdqa %xmm2, %xmm8
232 pclmulqdq $0x11, %xmm10, %xmm2
233 pclmulqdq $0x0 , %xmm10, %xmm8
234 pxor %xmm8, %xmm7
235 pxor %xmm2, %xmm7
236
237 movdqa rk15(%rip), %xmm10
238 movdqa %xmm3, %xmm8
239 pclmulqdq $0x11, %xmm10, %xmm3
240 pclmulqdq $0x0 , %xmm10, %xmm8
241 pxor %xmm8, %xmm7
242 xorps %xmm3, %xmm7
243
244 movdqa rk17(%rip), %xmm10
245 movdqa %xmm4, %xmm8
246 pclmulqdq $0x11, %xmm10, %xmm4
247 pclmulqdq $0x0 , %xmm10, %xmm8
248 pxor %xmm8, %xmm7
249 pxor %xmm4, %xmm7
250
251 movdqa rk19(%rip), %xmm10
252 movdqa %xmm5, %xmm8
253 pclmulqdq $0x11, %xmm10, %xmm5
254 pclmulqdq $0x0 , %xmm10, %xmm8
255 pxor %xmm8, %xmm7
256 xorps %xmm5, %xmm7
257
258 movdqa rk1(%rip), %xmm10 #xmm10 has rk1 and rk2
259 #imm value of pclmulqdq instruction
260 #will determine which constant to use
261 movdqa %xmm6, %xmm8
262 pclmulqdq $0x11, %xmm10, %xmm6
263 pclmulqdq $0x0 , %xmm10, %xmm8
264 pxor %xmm8, %xmm7
265 pxor %xmm6, %xmm7
266
267
268 # instead of 64, we add 48 to the loop counter to save 1 instruction
269 # from the loop instead of a cmp instruction, we use the negative
270 # flag with the jl instruction
271 add $128-16, arg3
272 jl _final_reduction_for_128
273
274 # now we have 16+y bytes left to reduce. 16 Bytes is in register xmm7
275 # and the rest is in memory. We can fold 16 bytes at a time if y>=16
276 # continue folding 16B at a time
277
278_16B_reduction_loop:
279 movdqa %xmm7, %xmm8
280 pclmulqdq $0x11, %xmm10, %xmm7
281 pclmulqdq $0x0 , %xmm10, %xmm8
282 pxor %xmm8, %xmm7
283 movdqu (arg2), %xmm0
284 pshufb %xmm11, %xmm0
285 pxor %xmm0 , %xmm7
286 add $16, arg2
287 sub $16, arg3
288 # instead of a cmp instruction, we utilize the flags with the
289 # jge instruction equivalent of: cmp arg3, 16-16
290 # check if there is any more 16B in the buffer to be able to fold
291 jge _16B_reduction_loop
292
293 #now we have 16+z bytes left to reduce, where 0<= z < 16.
294 #first, we reduce the data in the xmm7 register
295
296
297_final_reduction_for_128:
298 # check if any more data to fold. If not, compute the CRC of
299 # the final 128 bits
300 add $16, arg3
301 je _128_done
302
303 # here we are getting data that is less than 16 bytes.
304 # since we know that there was data before the pointer, we can
305 # offset the input pointer before the actual point, to receive
306 # exactly 16 bytes. after that the registers need to be adjusted.
307_get_last_two_xmms:
308 movdqa %xmm7, %xmm2
309
310 movdqu -16(arg2, arg3), %xmm1
311 pshufb %xmm11, %xmm1
312
313 # get rid of the extra data that was loaded before
314 # load the shift constant
315 lea pshufb_shf_table+16(%rip), %rax
316 sub arg3, %rax
317 movdqu (%rax), %xmm0
318
319 # shift xmm2 to the left by arg3 bytes
320 pshufb %xmm0, %xmm2
321
322 # shift xmm7 to the right by 16-arg3 bytes
323 pxor mask1(%rip), %xmm0
324 pshufb %xmm0, %xmm7
325 pblendvb %xmm2, %xmm1 #xmm0 is implicit
326
327 # fold 16 Bytes
328 movdqa %xmm1, %xmm2
329 movdqa %xmm7, %xmm8
330 pclmulqdq $0x11, %xmm10, %xmm7
331 pclmulqdq $0x0 , %xmm10, %xmm8
332 pxor %xmm8, %xmm7
333 pxor %xmm2, %xmm7
334
335_128_done:
336 # compute crc of a 128-bit value
337 movdqa rk5(%rip), %xmm10 # rk5 and rk6 in xmm10
338 movdqa %xmm7, %xmm0
339
340 #64b fold
341 pclmulqdq $0x1, %xmm10, %xmm7
342 pslldq $8 , %xmm0
343 pxor %xmm0, %xmm7
344
345 #32b fold
346 movdqa %xmm7, %xmm0
347
348 pand mask2(%rip), %xmm0
349
350 psrldq $12, %xmm7
351 pclmulqdq $0x10, %xmm10, %xmm7
352 pxor %xmm0, %xmm7
353
354 #barrett reduction
355_barrett:
356 movdqa rk7(%rip), %xmm10 # rk7 and rk8 in xmm10
357 movdqa %xmm7, %xmm0
358 pclmulqdq $0x01, %xmm10, %xmm7
359 pslldq $4, %xmm7
360 pclmulqdq $0x11, %xmm10, %xmm7
361
362 pslldq $4, %xmm7
363 pxor %xmm0, %xmm7
364 pextrd $1, %xmm7, %eax
365
366_cleanup:
367 # scale the result back to 16 bits
368 shr $16, %eax
369 mov %rcx, %rsp
370 ret
371
372########################################################################
373
374.align 16
375_less_than_128:
376
377 # check if there is enough buffer to be able to fold 16B at a time
378 cmp $32, arg3
379 jl _less_than_32
380 movdqa SHUF_MASK(%rip), %xmm11
381
382 # now if there is, load the constants
383 movdqa rk1(%rip), %xmm10 # rk1 and rk2 in xmm10
384
385 movd arg1_low32, %xmm0 # get the initial crc value
386 pslldq $12, %xmm0 # align it to its correct place
387 movdqu (arg2), %xmm7 # load the plaintext
388 pshufb %xmm11, %xmm7 # byte-reflect the plaintext
389 pxor %xmm0, %xmm7
390
391
392 # update the buffer pointer
393 add $16, arg2
394
395 # update the counter. subtract 32 instead of 16 to save one
396 # instruction from the loop
397 sub $32, arg3
398
399 jmp _16B_reduction_loop
400
401
402.align 16
403_less_than_32:
404 # mov initial crc to the return value. this is necessary for
405 # zero-length buffers.
406 mov arg1_low32, %eax
407 test arg3, arg3
408 je _cleanup
409
410 movdqa SHUF_MASK(%rip), %xmm11
411
412 movd arg1_low32, %xmm0 # get the initial crc value
413 pslldq $12, %xmm0 # align it to its correct place
414
415 cmp $16, arg3
416 je _exact_16_left
417 jl _less_than_16_left
418
419 movdqu (arg2), %xmm7 # load the plaintext
420 pshufb %xmm11, %xmm7 # byte-reflect the plaintext
421 pxor %xmm0 , %xmm7 # xor the initial crc value
422 add $16, arg2
423 sub $16, arg3
424 movdqa rk1(%rip), %xmm10 # rk1 and rk2 in xmm10
425 jmp _get_last_two_xmms
426
427
428.align 16
429_less_than_16_left:
430 # use stack space to load data less than 16 bytes, zero-out
431 # the 16B in memory first.
432
433 pxor %xmm1, %xmm1
434 mov %rsp, %r11
435 movdqa %xmm1, (%r11)
436
437 cmp $4, arg3
438 jl _only_less_than_4
439
440 # backup the counter value
441 mov arg3, %r9
442 cmp $8, arg3
443 jl _less_than_8_left
444
445 # load 8 Bytes
446 mov (arg2), %rax
447 mov %rax, (%r11)
448 add $8, %r11
449 sub $8, arg3
450 add $8, arg2
451_less_than_8_left:
452
453 cmp $4, arg3
454 jl _less_than_4_left
455
456 # load 4 Bytes
457 mov (arg2), %eax
458 mov %eax, (%r11)
459 add $4, %r11
460 sub $4, arg3
461 add $4, arg2
462_less_than_4_left:
463
464 cmp $2, arg3
465 jl _less_than_2_left
466
467 # load 2 Bytes
468 mov (arg2), %ax
469 mov %ax, (%r11)
470 add $2, %r11
471 sub $2, arg3
472 add $2, arg2
473_less_than_2_left:
474 cmp $1, arg3
475 jl _zero_left
476
477 # load 1 Byte
478 mov (arg2), %al
479 mov %al, (%r11)
480_zero_left:
481 movdqa (%rsp), %xmm7
482 pshufb %xmm11, %xmm7
483 pxor %xmm0 , %xmm7 # xor the initial crc value
484
485 # shl r9, 4
486 lea pshufb_shf_table+16(%rip), %rax
487 sub %r9, %rax
488 movdqu (%rax), %xmm0
489 pxor mask1(%rip), %xmm0
490
491 pshufb %xmm0, %xmm7
492 jmp _128_done
493
494.align 16
495_exact_16_left:
496 movdqu (arg2), %xmm7
497 pshufb %xmm11, %xmm7
498 pxor %xmm0 , %xmm7 # xor the initial crc value
499
500 jmp _128_done
501
502_only_less_than_4:
503 cmp $3, arg3
504 jl _only_less_than_3
505
506 # load 3 Bytes
507 mov (arg2), %al
508 mov %al, (%r11)
509
510 mov 1(arg2), %al
511 mov %al, 1(%r11)
512
513 mov 2(arg2), %al
514 mov %al, 2(%r11)
515
516 movdqa (%rsp), %xmm7
517 pshufb %xmm11, %xmm7
518 pxor %xmm0 , %xmm7 # xor the initial crc value
519
520 psrldq $5, %xmm7
521
522 jmp _barrett
523_only_less_than_3:
524 cmp $2, arg3
525 jl _only_less_than_2
526
527 # load 2 Bytes
528 mov (arg2), %al
529 mov %al, (%r11)
530
531 mov 1(arg2), %al
532 mov %al, 1(%r11)
533
534 movdqa (%rsp), %xmm7
535 pshufb %xmm11, %xmm7
536 pxor %xmm0 , %xmm7 # xor the initial crc value
537
538 psrldq $6, %xmm7
539
540 jmp _barrett
541_only_less_than_2:
542
543 # load 1 Byte
544 mov (arg2), %al
545 mov %al, (%r11)
546
547 movdqa (%rsp), %xmm7
548 pshufb %xmm11, %xmm7
549 pxor %xmm0 , %xmm7 # xor the initial crc value
550
551 psrldq $7, %xmm7
552
553 jmp _barrett
554
555ENDPROC(crc_t10dif_pcl)
556
557.data
558
559# precomputed constants
560# these constants are precomputed from the poly:
561# 0x8bb70000 (0x8bb7 scaled to 32 bits)
562.align 16
563# Q = 0x18BB70000
564# rk1 = 2^(32*3) mod Q << 32
565# rk2 = 2^(32*5) mod Q << 32
566# rk3 = 2^(32*15) mod Q << 32
567# rk4 = 2^(32*17) mod Q << 32
568# rk5 = 2^(32*3) mod Q << 32
569# rk6 = 2^(32*2) mod Q << 32
570# rk7 = floor(2^64/Q)
571# rk8 = Q
572rk1:
573.quad 0x2d56000000000000
574rk2:
575.quad 0x06df000000000000
576rk3:
577.quad 0x9d9d000000000000
578rk4:
579.quad 0x7cf5000000000000
580rk5:
581.quad 0x2d56000000000000
582rk6:
583.quad 0x1368000000000000
584rk7:
585.quad 0x00000001f65a57f8
586rk8:
587.quad 0x000000018bb70000
588
589rk9:
590.quad 0xceae000000000000
591rk10:
592.quad 0xbfd6000000000000
593rk11:
594.quad 0x1e16000000000000
595rk12:
596.quad 0x713c000000000000
597rk13:
598.quad 0xf7f9000000000000
599rk14:
600.quad 0x80a6000000000000
601rk15:
602.quad 0x044c000000000000
603rk16:
604.quad 0xe658000000000000
605rk17:
606.quad 0xad18000000000000
607rk18:
608.quad 0xa497000000000000
609rk19:
610.quad 0x6ee3000000000000
611rk20:
612.quad 0xe7b5000000000000
613
614
615
616mask1:
617.octa 0x80808080808080808080808080808080
618mask2:
619.octa 0x00000000FFFFFFFFFFFFFFFFFFFFFFFF
620
621SHUF_MASK:
622.octa 0x000102030405060708090A0B0C0D0E0F
623
624pshufb_shf_table:
625# use these values for shift constants for the pshufb instruction
626# different alignments result in values as shown:
627# DDQ 0x008f8e8d8c8b8a898887868584838281 # shl 15 (16-1) / shr1
628# DDQ 0x01008f8e8d8c8b8a8988878685848382 # shl 14 (16-3) / shr2
629# DDQ 0x0201008f8e8d8c8b8a89888786858483 # shl 13 (16-4) / shr3
630# DDQ 0x030201008f8e8d8c8b8a898887868584 # shl 12 (16-4) / shr4
631# DDQ 0x04030201008f8e8d8c8b8a8988878685 # shl 11 (16-5) / shr5
632# DDQ 0x0504030201008f8e8d8c8b8a89888786 # shl 10 (16-6) / shr6
633# DDQ 0x060504030201008f8e8d8c8b8a898887 # shl 9 (16-7) / shr7
634# DDQ 0x07060504030201008f8e8d8c8b8a8988 # shl 8 (16-8) / shr8
635# DDQ 0x0807060504030201008f8e8d8c8b8a89 # shl 7 (16-9) / shr9
636# DDQ 0x090807060504030201008f8e8d8c8b8a # shl 6 (16-10) / shr10
637# DDQ 0x0a090807060504030201008f8e8d8c8b # shl 5 (16-11) / shr11
638# DDQ 0x0b0a090807060504030201008f8e8d8c # shl 4 (16-12) / shr12
639# DDQ 0x0c0b0a090807060504030201008f8e8d # shl 3 (16-13) / shr13
640# DDQ 0x0d0c0b0a090807060504030201008f8e # shl 2 (16-14) / shr14
641# DDQ 0x0e0d0c0b0a090807060504030201008f # shl 1 (16-15) / shr15
642.octa 0x8f8e8d8c8b8a89888786858483828100
643.octa 0x000e0d0c0b0a09080706050403020100
diff --git a/arch/x86/crypto/crct10dif-pclmul_glue.c b/arch/x86/crypto/crct10dif-pclmul_glue.c
deleted file mode 100644
index 7845d7fd54c0..000000000000
--- a/arch/x86/crypto/crct10dif-pclmul_glue.c
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * T10 Data Integrity Field CRC16 Crypto Transform using PCLMULQDQ Instructions
5 *
6 * Copyright (C) 2013 Intel Corporation
7 * Author: Tim Chen <tim.c.chen@linux.intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 */
24
25#include <linux/types.h>
26#include <linux/module.h>
27#include <linux/crc-t10dif.h>
28#include <crypto/internal/hash.h>
29#include <linux/init.h>
30#include <linux/string.h>
31#include <linux/kernel.h>
32#include <asm/i387.h>
33#include <asm/cpufeature.h>
34#include <asm/cpu_device_id.h>
35
36asmlinkage __u16 crc_t10dif_pcl(__u16 crc, const unsigned char *buf,
37 size_t len);
38
39struct chksum_desc_ctx {
40 __u16 crc;
41};
42
43/*
44 * Steps through buffer one byte at at time, calculates reflected
45 * crc using table.
46 */
47
48static int chksum_init(struct shash_desc *desc)
49{
50 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
51
52 ctx->crc = 0;
53
54 return 0;
55}
56
57static int chksum_update(struct shash_desc *desc, const u8 *data,
58 unsigned int length)
59{
60 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
61
62 if (irq_fpu_usable()) {
63 kernel_fpu_begin();
64 ctx->crc = crc_t10dif_pcl(ctx->crc, data, length);
65 kernel_fpu_end();
66 } else
67 ctx->crc = crc_t10dif_generic(ctx->crc, data, length);
68 return 0;
69}
70
71static int chksum_final(struct shash_desc *desc, u8 *out)
72{
73 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
74
75 *(__u16 *)out = ctx->crc;
76 return 0;
77}
78
79static int __chksum_finup(__u16 *crcp, const u8 *data, unsigned int len,
80 u8 *out)
81{
82 if (irq_fpu_usable()) {
83 kernel_fpu_begin();
84 *(__u16 *)out = crc_t10dif_pcl(*crcp, data, len);
85 kernel_fpu_end();
86 } else
87 *(__u16 *)out = crc_t10dif_generic(*crcp, data, len);
88 return 0;
89}
90
91static int chksum_finup(struct shash_desc *desc, const u8 *data,
92 unsigned int len, u8 *out)
93{
94 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
95
96 return __chksum_finup(&ctx->crc, data, len, out);
97}
98
99static int chksum_digest(struct shash_desc *desc, const u8 *data,
100 unsigned int length, u8 *out)
101{
102 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
103
104 return __chksum_finup(&ctx->crc, data, length, out);
105}
106
107static struct shash_alg alg = {
108 .digestsize = CRC_T10DIF_DIGEST_SIZE,
109 .init = chksum_init,
110 .update = chksum_update,
111 .final = chksum_final,
112 .finup = chksum_finup,
113 .digest = chksum_digest,
114 .descsize = sizeof(struct chksum_desc_ctx),
115 .base = {
116 .cra_name = "crct10dif",
117 .cra_driver_name = "crct10dif-pclmul",
118 .cra_priority = 200,
119 .cra_blocksize = CRC_T10DIF_BLOCK_SIZE,
120 .cra_module = THIS_MODULE,
121 }
122};
123
124static const struct x86_cpu_id crct10dif_cpu_id[] = {
125 X86_FEATURE_MATCH(X86_FEATURE_PCLMULQDQ),
126 {}
127};
128MODULE_DEVICE_TABLE(x86cpu, crct10dif_cpu_id);
129
130static int __init crct10dif_intel_mod_init(void)
131{
132 if (!x86_match_cpu(crct10dif_cpu_id))
133 return -ENODEV;
134
135 return crypto_register_shash(&alg);
136}
137
138static void __exit crct10dif_intel_mod_fini(void)
139{
140 crypto_unregister_shash(&alg);
141}
142
143module_init(crct10dif_intel_mod_init);
144module_exit(crct10dif_intel_mod_fini);
145
146MODULE_AUTHOR("Tim Chen <tim.c.chen@linux.intel.com>");
147MODULE_DESCRIPTION("T10 DIF CRC calculation accelerated with PCLMULQDQ.");
148MODULE_LICENSE("GPL");
149
150MODULE_ALIAS("crct10dif");
151MODULE_ALIAS("crct10dif-pclmul");
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index 5f9a1243190e..d2b12988d2ed 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -28,7 +28,7 @@ struct x86_cpu {
28#ifdef CONFIG_HOTPLUG_CPU 28#ifdef CONFIG_HOTPLUG_CPU
29extern int arch_register_cpu(int num); 29extern int arch_register_cpu(int num);
30extern void arch_unregister_cpu(int); 30extern void arch_unregister_cpu(int);
31extern void __cpuinit start_cpu0(void); 31extern void start_cpu0(void);
32#ifdef CONFIG_DEBUG_HOTPLUG_CPU0 32#ifdef CONFIG_DEBUG_HOTPLUG_CPU0
33extern int _debug_hotplug_cpu(int cpu, int action); 33extern int _debug_hotplug_cpu(int cpu, int action);
34#endif 34#endif
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index 6bc3985ee473..f98bd6625318 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -60,11 +60,11 @@ static inline void __exit exit_amd_microcode(void) {}
60#ifdef CONFIG_MICROCODE_EARLY 60#ifdef CONFIG_MICROCODE_EARLY
61#define MAX_UCODE_COUNT 128 61#define MAX_UCODE_COUNT 128
62extern void __init load_ucode_bsp(void); 62extern void __init load_ucode_bsp(void);
63extern void __cpuinit load_ucode_ap(void); 63extern void load_ucode_ap(void);
64extern int __init save_microcode_in_initrd(void); 64extern int __init save_microcode_in_initrd(void);
65#else 65#else
66static inline void __init load_ucode_bsp(void) {} 66static inline void __init load_ucode_bsp(void) {}
67static inline void __cpuinit load_ucode_ap(void) {} 67static inline void load_ucode_ap(void) {}
68static inline int __init save_microcode_in_initrd(void) 68static inline int __init save_microcode_in_initrd(void)
69{ 69{
70 return 0; 70 return 0;
diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h
index c6b043f40271..50e5c58ced23 100644
--- a/arch/x86/include/asm/microcode_amd.h
+++ b/arch/x86/include/asm/microcode_amd.h
@@ -67,11 +67,11 @@ extern enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size)
67extern u8 amd_bsp_mpb[MPB_MAX_SIZE]; 67extern u8 amd_bsp_mpb[MPB_MAX_SIZE];
68#endif 68#endif
69extern void __init load_ucode_amd_bsp(void); 69extern void __init load_ucode_amd_bsp(void);
70extern void __cpuinit load_ucode_amd_ap(void); 70extern void load_ucode_amd_ap(void);
71extern int __init save_microcode_in_initrd_amd(void); 71extern int __init save_microcode_in_initrd_amd(void);
72#else 72#else
73static inline void __init load_ucode_amd_bsp(void) {} 73static inline void __init load_ucode_amd_bsp(void) {}
74static inline void __cpuinit load_ucode_amd_ap(void) {} 74static inline void load_ucode_amd_ap(void) {}
75static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; } 75static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; }
76#endif 76#endif
77 77
diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h
index 87a085333cbf..9067166409bf 100644
--- a/arch/x86/include/asm/microcode_intel.h
+++ b/arch/x86/include/asm/microcode_intel.h
@@ -65,12 +65,12 @@ update_match_revision(struct microcode_header_intel *mc_header, int rev);
65 65
66#ifdef CONFIG_MICROCODE_INTEL_EARLY 66#ifdef CONFIG_MICROCODE_INTEL_EARLY
67extern void __init load_ucode_intel_bsp(void); 67extern void __init load_ucode_intel_bsp(void);
68extern void __cpuinit load_ucode_intel_ap(void); 68extern void load_ucode_intel_ap(void);
69extern void show_ucode_info_early(void); 69extern void show_ucode_info_early(void);
70extern int __init save_microcode_in_initrd_intel(void); 70extern int __init save_microcode_in_initrd_intel(void);
71#else 71#else
72static inline __init void load_ucode_intel_bsp(void) {} 72static inline __init void load_ucode_intel_bsp(void) {}
73static inline __cpuinit void load_ucode_intel_ap(void) {} 73static inline void load_ucode_intel_ap(void) {}
74static inline void show_ucode_info_early(void) {} 74static inline void show_ucode_info_early(void) {}
75static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; } 75static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; }
76#endif 76#endif
diff --git a/arch/x86/include/asm/mmconfig.h b/arch/x86/include/asm/mmconfig.h
index 9b119da1d105..04a3fed22cfe 100644
--- a/arch/x86/include/asm/mmconfig.h
+++ b/arch/x86/include/asm/mmconfig.h
@@ -2,8 +2,8 @@
2#define _ASM_X86_MMCONFIG_H 2#define _ASM_X86_MMCONFIG_H
3 3
4#ifdef CONFIG_PCI_MMCONFIG 4#ifdef CONFIG_PCI_MMCONFIG
5extern void __cpuinit fam10h_check_enable_mmcfg(void); 5extern void fam10h_check_enable_mmcfg(void);
6extern void __cpuinit check_enable_amd_mmconf_dmi(void); 6extern void check_enable_amd_mmconf_dmi(void);
7#else 7#else
8static inline void fam10h_check_enable_mmcfg(void) { } 8static inline void fam10h_check_enable_mmcfg(void) { }
9static inline void check_enable_amd_mmconf_dmi(void) { } 9static inline void check_enable_amd_mmconf_dmi(void) { }
diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index 3e2f42a4b872..626cf70082d7 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { }
94#define default_get_smp_config x86_init_uint_noop 94#define default_get_smp_config x86_init_uint_noop
95#endif 95#endif
96 96
97void __cpuinit generic_processor_info(int apicid, int version); 97void generic_processor_info(int apicid, int version);
98#ifdef CONFIG_ACPI 98#ifdef CONFIG_ACPI
99extern void mp_register_ioapic(int id, u32 address, u32 gsi_base); 99extern void mp_register_ioapic(int id, u32 address, u32 gsi_base);
100extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, 100extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h
index 1b99ee5c9f00..4064acae625d 100644
--- a/arch/x86/include/asm/numa.h
+++ b/arch/x86/include/asm/numa.h
@@ -39,7 +39,7 @@ static inline void set_apicid_to_node(int apicid, s16 node)
39 __apicid_to_node[apicid] = node; 39 __apicid_to_node[apicid] = node;
40} 40}
41 41
42extern int __cpuinit numa_cpu_node(int cpu); 42extern int numa_cpu_node(int cpu);
43 43
44#else /* CONFIG_NUMA */ 44#else /* CONFIG_NUMA */
45static inline void set_apicid_to_node(int apicid, s16 node) 45static inline void set_apicid_to_node(int apicid, s16 node)
@@ -60,8 +60,8 @@ static inline int numa_cpu_node(int cpu)
60extern void numa_set_node(int cpu, int node); 60extern void numa_set_node(int cpu, int node);
61extern void numa_clear_node(int cpu); 61extern void numa_clear_node(int cpu);
62extern void __init init_cpu_to_node(void); 62extern void __init init_cpu_to_node(void);
63extern void __cpuinit numa_add_cpu(int cpu); 63extern void numa_add_cpu(int cpu);
64extern void __cpuinit numa_remove_cpu(int cpu); 64extern void numa_remove_cpu(int cpu);
65#else /* CONFIG_NUMA */ 65#else /* CONFIG_NUMA */
66static inline void numa_set_node(int cpu, int node) { } 66static inline void numa_set_node(int cpu, int node) { }
67static inline void numa_clear_node(int cpu) { } 67static inline void numa_clear_node(int cpu) { }
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 29937c4f6ff8..24cf5aefb704 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -164,7 +164,7 @@ extern const struct seq_operations cpuinfo_op;
164#define cache_line_size() (boot_cpu_data.x86_cache_alignment) 164#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
165 165
166extern void cpu_detect(struct cpuinfo_x86 *c); 166extern void cpu_detect(struct cpuinfo_x86 *c);
167extern void __cpuinit fpu_detect(struct cpuinfo_x86 *c); 167extern void fpu_detect(struct cpuinfo_x86 *c);
168 168
169extern void early_cpu_init(void); 169extern void early_cpu_init(void);
170extern void identify_boot_cpu(void); 170extern void identify_boot_cpu(void);
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index 60bef663609a..bade6ac3b14f 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -27,7 +27,7 @@ extern int of_ioapic;
27extern u64 initial_dtb; 27extern u64 initial_dtb;
28extern void add_dtb(u64 data); 28extern void add_dtb(u64 data);
29extern void x86_add_irq_domains(void); 29extern void x86_add_irq_domains(void);
30void __cpuinit x86_of_pci_init(void); 30void x86_of_pci_init(void);
31void x86_dtb_init(void); 31void x86_dtb_init(void);
32#else 32#else
33static inline void add_dtb(u64 data) { } 33static inline void add_dtb(u64 data) { }
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index b073aaea747c..4137890e88e3 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -179,7 +179,7 @@ static inline int wbinvd_on_all_cpus(void)
179} 179}
180#endif /* CONFIG_SMP */ 180#endif /* CONFIG_SMP */
181 181
182extern unsigned disabled_cpus __cpuinitdata; 182extern unsigned disabled_cpus;
183 183
184#ifdef CONFIG_X86_32_SMP 184#ifdef CONFIG_X86_32_SMP
185/* 185/*
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index d81a972dd506..2627a81253ee 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -195,7 +195,7 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
195 return 0; 195 return 0;
196} 196}
197 197
198static void __cpuinit acpi_register_lapic(int id, u8 enabled) 198static void acpi_register_lapic(int id, u8 enabled)
199{ 199{
200 unsigned int ver = 0; 200 unsigned int ver = 0;
201 201
@@ -607,7 +607,7 @@ void __init acpi_set_irq_model_ioapic(void)
607#ifdef CONFIG_ACPI_HOTPLUG_CPU 607#ifdef CONFIG_ACPI_HOTPLUG_CPU
608#include <acpi/processor.h> 608#include <acpi/processor.h>
609 609
610static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 610static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
611{ 611{
612#ifdef CONFIG_ACPI_NUMA 612#ifdef CONFIG_ACPI_NUMA
613 int nid; 613 int nid;
@@ -620,7 +620,7 @@ static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
620#endif 620#endif
621} 621}
622 622
623static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu) 623static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
624{ 624{
625 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 625 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
626 union acpi_object *obj; 626 union acpi_object *obj;
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 2a34aaf3c8f1..33120100ff5e 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -48,9 +48,20 @@ int x86_acpi_suspend_lowlevel(void)
48#ifndef CONFIG_64BIT 48#ifndef CONFIG_64BIT
49 native_store_gdt((struct desc_ptr *)&header->pmode_gdt); 49 native_store_gdt((struct desc_ptr *)&header->pmode_gdt);
50 50
51 /*
52 * We have to check that we can write back the value, and not
53 * just read it. At least on 90 nm Pentium M (Family 6, Model
54 * 13), reading an invalid MSR is not guaranteed to trap, see
55 * Erratum X4 in "Intel Pentium M Processor on 90 nm Process
56 * with 2-MB L2 Cache and Intel® Processor A100 and A110 on 90
57 * nm process with 512-KB L2 Cache Specification Update".
58 */
51 if (!rdmsr_safe(MSR_EFER, 59 if (!rdmsr_safe(MSR_EFER,
52 &header->pmode_efer_low, 60 &header->pmode_efer_low,
53 &header->pmode_efer_high)) 61 &header->pmode_efer_high) &&
62 !wrmsr_safe(MSR_EFER,
63 header->pmode_efer_low,
64 header->pmode_efer_high))
54 header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER); 65 header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER);
55#endif /* !CONFIG_64BIT */ 66#endif /* !CONFIG_64BIT */
56 67
@@ -61,7 +72,10 @@ int x86_acpi_suspend_lowlevel(void)
61 } 72 }
62 if (!rdmsr_safe(MSR_IA32_MISC_ENABLE, 73 if (!rdmsr_safe(MSR_IA32_MISC_ENABLE,
63 &header->pmode_misc_en_low, 74 &header->pmode_misc_en_low,
64 &header->pmode_misc_en_high)) 75 &header->pmode_misc_en_high) &&
76 !wrmsr_safe(MSR_IA32_MISC_ENABLE,
77 header->pmode_misc_en_low,
78 header->pmode_misc_en_high))
65 header->pmode_behavior |= 79 header->pmode_behavior |=
66 (1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE); 80 (1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE);
67 header->realmode_flags = acpi_realmode_flags; 81 header->realmode_flags = acpi_realmode_flags;
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 99663b59123a..eca89c53a7f5 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -58,7 +58,7 @@
58 58
59unsigned int num_processors; 59unsigned int num_processors;
60 60
61unsigned disabled_cpus __cpuinitdata; 61unsigned disabled_cpus;
62 62
63/* Processor that is doing the boot up */ 63/* Processor that is doing the boot up */
64unsigned int boot_cpu_physical_apicid = -1U; 64unsigned int boot_cpu_physical_apicid = -1U;
@@ -544,7 +544,7 @@ static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
544 * Setup the local APIC timer for this CPU. Copy the initialized values 544 * Setup the local APIC timer for this CPU. Copy the initialized values
545 * of the boot CPU and register the clock event in the framework. 545 * of the boot CPU and register the clock event in the framework.
546 */ 546 */
547static void __cpuinit setup_APIC_timer(void) 547static void setup_APIC_timer(void)
548{ 548{
549 struct clock_event_device *levt = &__get_cpu_var(lapic_events); 549 struct clock_event_device *levt = &__get_cpu_var(lapic_events);
550 550
@@ -866,7 +866,7 @@ void __init setup_boot_APIC_clock(void)
866 setup_APIC_timer(); 866 setup_APIC_timer();
867} 867}
868 868
869void __cpuinit setup_secondary_APIC_clock(void) 869void setup_secondary_APIC_clock(void)
870{ 870{
871 setup_APIC_timer(); 871 setup_APIC_timer();
872} 872}
@@ -1229,7 +1229,7 @@ void __init init_bsp_APIC(void)
1229 apic_write(APIC_LVT1, value); 1229 apic_write(APIC_LVT1, value);
1230} 1230}
1231 1231
1232static void __cpuinit lapic_setup_esr(void) 1232static void lapic_setup_esr(void)
1233{ 1233{
1234 unsigned int oldvalue, value, maxlvt; 1234 unsigned int oldvalue, value, maxlvt;
1235 1235
@@ -1276,7 +1276,7 @@ static void __cpuinit lapic_setup_esr(void)
1276 * Used to setup local APIC while initializing BSP or bringin up APs. 1276 * Used to setup local APIC while initializing BSP or bringin up APs.
1277 * Always called with preemption disabled. 1277 * Always called with preemption disabled.
1278 */ 1278 */
1279void __cpuinit setup_local_APIC(void) 1279void setup_local_APIC(void)
1280{ 1280{
1281 int cpu = smp_processor_id(); 1281 int cpu = smp_processor_id();
1282 unsigned int value, queued; 1282 unsigned int value, queued;
@@ -1471,7 +1471,7 @@ void __cpuinit setup_local_APIC(void)
1471#endif 1471#endif
1472} 1472}
1473 1473
1474void __cpuinit end_local_APIC_setup(void) 1474void end_local_APIC_setup(void)
1475{ 1475{
1476 lapic_setup_esr(); 1476 lapic_setup_esr();
1477 1477
@@ -2107,7 +2107,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
2107 apic_write(APIC_LVT1, value); 2107 apic_write(APIC_LVT1, value);
2108} 2108}
2109 2109
2110void __cpuinit generic_processor_info(int apicid, int version) 2110void generic_processor_info(int apicid, int version)
2111{ 2111{
2112 int cpu, max = nr_cpu_ids; 2112 int cpu, max = nr_cpu_ids;
2113 bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, 2113 bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2377,7 +2377,7 @@ static struct syscore_ops lapic_syscore_ops = {
2377 .suspend = lapic_suspend, 2377 .suspend = lapic_suspend,
2378}; 2378};
2379 2379
2380static void __cpuinit apic_pm_activate(void) 2380static void apic_pm_activate(void)
2381{ 2381{
2382 apic_pm_state.active = 1; 2382 apic_pm_state.active = 1;
2383} 2383}
@@ -2402,7 +2402,7 @@ static void apic_pm_activate(void) { }
2402 2402
2403#ifdef CONFIG_X86_64 2403#ifdef CONFIG_X86_64
2404 2404
2405static int __cpuinit apic_cluster_num(void) 2405static int apic_cluster_num(void)
2406{ 2406{
2407 int i, clusters, zeros; 2407 int i, clusters, zeros;
2408 unsigned id; 2408 unsigned id;
@@ -2447,10 +2447,10 @@ static int __cpuinit apic_cluster_num(void)
2447 return clusters; 2447 return clusters;
2448} 2448}
2449 2449
2450static int __cpuinitdata multi_checked; 2450static int multi_checked;
2451static int __cpuinitdata multi; 2451static int multi;
2452 2452
2453static int __cpuinit set_multi(const struct dmi_system_id *d) 2453static int set_multi(const struct dmi_system_id *d)
2454{ 2454{
2455 if (multi) 2455 if (multi)
2456 return 0; 2456 return 0;
@@ -2459,7 +2459,7 @@ static int __cpuinit set_multi(const struct dmi_system_id *d)
2459 return 0; 2459 return 0;
2460} 2460}
2461 2461
2462static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = { 2462static const struct dmi_system_id multi_dmi_table[] = {
2463 { 2463 {
2464 .callback = set_multi, 2464 .callback = set_multi,
2465 .ident = "IBM System Summit2", 2465 .ident = "IBM System Summit2",
@@ -2471,7 +2471,7 @@ static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = {
2471 {} 2471 {}
2472}; 2472};
2473 2473
2474static void __cpuinit dmi_check_multi(void) 2474static void dmi_check_multi(void)
2475{ 2475{
2476 if (multi_checked) 2476 if (multi_checked)
2477 return; 2477 return;
@@ -2488,7 +2488,7 @@ static void __cpuinit dmi_check_multi(void)
2488 * multi-chassis. 2488 * multi-chassis.
2489 * Use DMI to check them 2489 * Use DMI to check them
2490 */ 2490 */
2491__cpuinit int apic_is_clustered_box(void) 2491int apic_is_clustered_box(void)
2492{ 2492{
2493 dmi_check_multi(); 2493 dmi_check_multi();
2494 if (multi) 2494 if (multi)
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index 9a9110918ca7..3e67f9e3d7ef 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -74,7 +74,7 @@ static int numachip_phys_pkg_id(int initial_apic_id, int index_msb)
74 return initial_apic_id >> index_msb; 74 return initial_apic_id >> index_msb;
75} 75}
76 76
77static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) 77static int numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip)
78{ 78{
79 union numachip_csr_g3_ext_irq_gen int_gen; 79 union numachip_csr_g3_ext_irq_gen int_gen;
80 80
diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
index 0874799a98c6..c55224731b2d 100644
--- a/arch/x86/kernel/apic/es7000_32.c
+++ b/arch/x86/kernel/apic/es7000_32.c
@@ -130,7 +130,7 @@ int es7000_plat;
130 */ 130 */
131 131
132 132
133static int __cpuinit wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip) 133static int wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip)
134{ 134{
135 unsigned long vect = 0, psaival = 0; 135 unsigned long vect = 0, psaival = 0;
136 136
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
index d661ee95cabf..1e42e8f305ee 100644
--- a/arch/x86/kernel/apic/numaq_32.c
+++ b/arch/x86/kernel/apic/numaq_32.c
@@ -105,7 +105,7 @@ static void __init smp_dump_qct(void)
105 } 105 }
106} 106}
107 107
108void __cpuinit numaq_tsc_disable(void) 108void numaq_tsc_disable(void)
109{ 109{
110 if (!found_numaq) 110 if (!found_numaq)
111 return; 111 return;
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index c88baa4ff0e5..140e29db478d 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -148,7 +148,7 @@ static void init_x2apic_ldr(void)
148 /* 148 /*
149 * At CPU state changes, update the x2apic cluster sibling info. 149 * At CPU state changes, update the x2apic cluster sibling info.
150 */ 150 */
151static int __cpuinit 151static int
152update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu) 152update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
153{ 153{
154 unsigned int this_cpu = (unsigned long)hcpu; 154 unsigned int this_cpu = (unsigned long)hcpu;
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 63092afb142e..1191ac1c9d25 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -209,7 +209,7 @@ EXPORT_SYMBOL_GPL(uv_possible_blades);
209unsigned long sn_rtc_cycles_per_second; 209unsigned long sn_rtc_cycles_per_second;
210EXPORT_SYMBOL(sn_rtc_cycles_per_second); 210EXPORT_SYMBOL(sn_rtc_cycles_per_second);
211 211
212static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) 212static int uv_wakeup_secondary(int phys_apicid, unsigned long start_rip)
213{ 213{
214#ifdef CONFIG_SMP 214#ifdef CONFIG_SMP
215 unsigned long val; 215 unsigned long val;
@@ -416,7 +416,7 @@ static struct apic __refdata apic_x2apic_uv_x = {
416 .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, 416 .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle,
417}; 417};
418 418
419static __cpuinit void set_x2apic_extra_bits(int pnode) 419static void set_x2apic_extra_bits(int pnode)
420{ 420{
421 __this_cpu_write(x2apic_extra_bits, pnode << uvh_apicid.s.pnode_shift); 421 __this_cpu_write(x2apic_extra_bits, pnode << uvh_apicid.s.pnode_shift);
422} 422}
@@ -735,7 +735,7 @@ static void uv_heartbeat(unsigned long ignored)
735 mod_timer_pinned(timer, jiffies + SCIR_CPU_HB_INTERVAL); 735 mod_timer_pinned(timer, jiffies + SCIR_CPU_HB_INTERVAL);
736} 736}
737 737
738static void __cpuinit uv_heartbeat_enable(int cpu) 738static void uv_heartbeat_enable(int cpu)
739{ 739{
740 while (!uv_cpu_hub_info(cpu)->scir.enabled) { 740 while (!uv_cpu_hub_info(cpu)->scir.enabled) {
741 struct timer_list *timer = &uv_cpu_hub_info(cpu)->scir.timer; 741 struct timer_list *timer = &uv_cpu_hub_info(cpu)->scir.timer;
@@ -752,7 +752,7 @@ static void __cpuinit uv_heartbeat_enable(int cpu)
752} 752}
753 753
754#ifdef CONFIG_HOTPLUG_CPU 754#ifdef CONFIG_HOTPLUG_CPU
755static void __cpuinit uv_heartbeat_disable(int cpu) 755static void uv_heartbeat_disable(int cpu)
756{ 756{
757 if (uv_cpu_hub_info(cpu)->scir.enabled) { 757 if (uv_cpu_hub_info(cpu)->scir.enabled) {
758 uv_cpu_hub_info(cpu)->scir.enabled = 0; 758 uv_cpu_hub_info(cpu)->scir.enabled = 0;
@@ -764,8 +764,8 @@ static void __cpuinit uv_heartbeat_disable(int cpu)
764/* 764/*
765 * cpu hotplug notifier 765 * cpu hotplug notifier
766 */ 766 */
767static __cpuinit int uv_scir_cpu_notify(struct notifier_block *self, 767static int uv_scir_cpu_notify(struct notifier_block *self, unsigned long action,
768 unsigned long action, void *hcpu) 768 void *hcpu)
769{ 769{
770 long cpu = (long)hcpu; 770 long cpu = (long)hcpu;
771 771
@@ -835,7 +835,7 @@ int uv_set_vga_state(struct pci_dev *pdev, bool decode,
835 * Called on each cpu to initialize the per_cpu UV data area. 835 * Called on each cpu to initialize the per_cpu UV data area.
836 * FIXME: hotplug not supported yet 836 * FIXME: hotplug not supported yet
837 */ 837 */
838void __cpuinit uv_cpu_init(void) 838void uv_cpu_init(void)
839{ 839{
840 /* CPU 0 initilization will be done via uv_system_init. */ 840 /* CPU 0 initilization will be done via uv_system_init. */
841 if (!uv_blade_info) 841 if (!uv_blade_info)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index c587a8757227..f654ecefea5b 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -69,7 +69,7 @@ static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
69extern void vide(void); 69extern void vide(void);
70__asm__(".align 4\nvide: ret"); 70__asm__(".align 4\nvide: ret");
71 71
72static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c) 72static void init_amd_k5(struct cpuinfo_x86 *c)
73{ 73{
74/* 74/*
75 * General Systems BIOSen alias the cpu frequency registers 75 * General Systems BIOSen alias the cpu frequency registers
@@ -87,7 +87,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
87} 87}
88 88
89 89
90static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c) 90static void init_amd_k6(struct cpuinfo_x86 *c)
91{ 91{
92 u32 l, h; 92 u32 l, h;
93 int mbytes = get_num_physpages() >> (20-PAGE_SHIFT); 93 int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
@@ -179,7 +179,7 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
179 } 179 }
180} 180}
181 181
182static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c) 182static void amd_k7_smp_check(struct cpuinfo_x86 *c)
183{ 183{
184 /* calling is from identify_secondary_cpu() ? */ 184 /* calling is from identify_secondary_cpu() ? */
185 if (!c->cpu_index) 185 if (!c->cpu_index)
@@ -222,7 +222,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c)
222 add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE); 222 add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE);
223} 223}
224 224
225static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c) 225static void init_amd_k7(struct cpuinfo_x86 *c)
226{ 226{
227 u32 l, h; 227 u32 l, h;
228 228
@@ -267,7 +267,7 @@ static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
267 * To workaround broken NUMA config. Read the comment in 267 * To workaround broken NUMA config. Read the comment in
268 * srat_detect_node(). 268 * srat_detect_node().
269 */ 269 */
270static int __cpuinit nearby_node(int apicid) 270static int nearby_node(int apicid)
271{ 271{
272 int i, node; 272 int i, node;
273 273
@@ -292,7 +292,7 @@ static int __cpuinit nearby_node(int apicid)
292 * (2) AMD processors supporting compute units 292 * (2) AMD processors supporting compute units
293 */ 293 */
294#ifdef CONFIG_X86_HT 294#ifdef CONFIG_X86_HT
295static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c) 295static void amd_get_topology(struct cpuinfo_x86 *c)
296{ 296{
297 u32 nodes, cores_per_cu = 1; 297 u32 nodes, cores_per_cu = 1;
298 u8 node_id; 298 u8 node_id;
@@ -342,7 +342,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
342 * On a AMD dual core setup the lower bits of the APIC id distingush the cores. 342 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
343 * Assumes number of cores is a power of two. 343 * Assumes number of cores is a power of two.
344 */ 344 */
345static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c) 345static void amd_detect_cmp(struct cpuinfo_x86 *c)
346{ 346{
347#ifdef CONFIG_X86_HT 347#ifdef CONFIG_X86_HT
348 unsigned bits; 348 unsigned bits;
@@ -369,7 +369,7 @@ u16 amd_get_nb_id(int cpu)
369} 369}
370EXPORT_SYMBOL_GPL(amd_get_nb_id); 370EXPORT_SYMBOL_GPL(amd_get_nb_id);
371 371
372static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) 372static void srat_detect_node(struct cpuinfo_x86 *c)
373{ 373{
374#ifdef CONFIG_NUMA 374#ifdef CONFIG_NUMA
375 int cpu = smp_processor_id(); 375 int cpu = smp_processor_id();
@@ -421,7 +421,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
421#endif 421#endif
422} 422}
423 423
424static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c) 424static void early_init_amd_mc(struct cpuinfo_x86 *c)
425{ 425{
426#ifdef CONFIG_X86_HT 426#ifdef CONFIG_X86_HT
427 unsigned bits, ecx; 427 unsigned bits, ecx;
@@ -447,7 +447,7 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
447#endif 447#endif
448} 448}
449 449
450static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c) 450static void bsp_init_amd(struct cpuinfo_x86 *c)
451{ 451{
452 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { 452 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
453 453
@@ -475,7 +475,7 @@ static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c)
475 } 475 }
476} 476}
477 477
478static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) 478static void early_init_amd(struct cpuinfo_x86 *c)
479{ 479{
480 early_init_amd_mc(c); 480 early_init_amd_mc(c);
481 481
@@ -514,7 +514,7 @@ static const int amd_erratum_383[];
514static const int amd_erratum_400[]; 514static const int amd_erratum_400[];
515static bool cpu_has_amd_erratum(const int *erratum); 515static bool cpu_has_amd_erratum(const int *erratum);
516 516
517static void __cpuinit init_amd(struct cpuinfo_x86 *c) 517static void init_amd(struct cpuinfo_x86 *c)
518{ 518{
519 u32 dummy; 519 u32 dummy;
520 unsigned long long value; 520 unsigned long long value;
@@ -740,8 +740,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
740} 740}
741 741
742#ifdef CONFIG_X86_32 742#ifdef CONFIG_X86_32
743static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, 743static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
744 unsigned int size)
745{ 744{
746 /* AMD errata T13 (order #21922) */ 745 /* AMD errata T13 (order #21922) */
747 if ((c->x86 == 6)) { 746 if ((c->x86 == 6)) {
@@ -757,7 +756,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
757} 756}
758#endif 757#endif
759 758
760static void __cpuinit cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c) 759static void cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c)
761{ 760{
762 tlb_flushall_shift = 5; 761 tlb_flushall_shift = 5;
763 762
@@ -765,7 +764,7 @@ static void __cpuinit cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c)
765 tlb_flushall_shift = 4; 764 tlb_flushall_shift = 4;
766} 765}
767 766
768static void __cpuinit cpu_detect_tlb_amd(struct cpuinfo_x86 *c) 767static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
769{ 768{
770 u32 ebx, eax, ecx, edx; 769 u32 ebx, eax, ecx, edx;
771 u16 mask = 0xfff; 770 u16 mask = 0xfff;
@@ -820,7 +819,7 @@ static void __cpuinit cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
820 cpu_set_tlb_flushall_shift(c); 819 cpu_set_tlb_flushall_shift(c);
821} 820}
822 821
823static const struct cpu_dev __cpuinitconst amd_cpu_dev = { 822static const struct cpu_dev amd_cpu_dev = {
824 .c_vendor = "AMD", 823 .c_vendor = "AMD",
825 .c_ident = { "AuthenticAMD" }, 824 .c_ident = { "AuthenticAMD" },
826#ifdef CONFIG_X86_32 825#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index 159103c0b1f4..fbf6c3bc2400 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -11,7 +11,7 @@
11 11
12#ifdef CONFIG_X86_OOSTORE 12#ifdef CONFIG_X86_OOSTORE
13 13
14static u32 __cpuinit power2(u32 x) 14static u32 power2(u32 x)
15{ 15{
16 u32 s = 1; 16 u32 s = 1;
17 17
@@ -25,7 +25,7 @@ static u32 __cpuinit power2(u32 x)
25/* 25/*
26 * Set up an actual MCR 26 * Set up an actual MCR
27 */ 27 */
28static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key) 28static void centaur_mcr_insert(int reg, u32 base, u32 size, int key)
29{ 29{
30 u32 lo, hi; 30 u32 lo, hi;
31 31
@@ -42,7 +42,7 @@ static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key)
42 * 42 *
43 * Shortcut: We know you can't put 4Gig of RAM on a winchip 43 * Shortcut: We know you can't put 4Gig of RAM on a winchip
44 */ 44 */
45static u32 __cpuinit ramtop(void) 45static u32 ramtop(void)
46{ 46{
47 u32 clip = 0xFFFFFFFFUL; 47 u32 clip = 0xFFFFFFFFUL;
48 u32 top = 0; 48 u32 top = 0;
@@ -91,7 +91,7 @@ static u32 __cpuinit ramtop(void)
91/* 91/*
92 * Compute a set of MCR's to give maximum coverage 92 * Compute a set of MCR's to give maximum coverage
93 */ 93 */
94static int __cpuinit centaur_mcr_compute(int nr, int key) 94static int centaur_mcr_compute(int nr, int key)
95{ 95{
96 u32 mem = ramtop(); 96 u32 mem = ramtop();
97 u32 root = power2(mem); 97 u32 root = power2(mem);
@@ -157,7 +157,7 @@ static int __cpuinit centaur_mcr_compute(int nr, int key)
157 return ct; 157 return ct;
158} 158}
159 159
160static void __cpuinit centaur_create_optimal_mcr(void) 160static void centaur_create_optimal_mcr(void)
161{ 161{
162 int used; 162 int used;
163 int i; 163 int i;
@@ -181,7 +181,7 @@ static void __cpuinit centaur_create_optimal_mcr(void)
181 wrmsr(MSR_IDT_MCR0+i, 0, 0); 181 wrmsr(MSR_IDT_MCR0+i, 0, 0);
182} 182}
183 183
184static void __cpuinit winchip2_create_optimal_mcr(void) 184static void winchip2_create_optimal_mcr(void)
185{ 185{
186 u32 lo, hi; 186 u32 lo, hi;
187 int used; 187 int used;
@@ -217,7 +217,7 @@ static void __cpuinit winchip2_create_optimal_mcr(void)
217/* 217/*
218 * Handle the MCR key on the Winchip 2. 218 * Handle the MCR key on the Winchip 2.
219 */ 219 */
220static void __cpuinit winchip2_unprotect_mcr(void) 220static void winchip2_unprotect_mcr(void)
221{ 221{
222 u32 lo, hi; 222 u32 lo, hi;
223 u32 key; 223 u32 key;
@@ -229,7 +229,7 @@ static void __cpuinit winchip2_unprotect_mcr(void)
229 wrmsr(MSR_IDT_MCR_CTRL, lo, hi); 229 wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
230} 230}
231 231
232static void __cpuinit winchip2_protect_mcr(void) 232static void winchip2_protect_mcr(void)
233{ 233{
234 u32 lo, hi; 234 u32 lo, hi;
235 235
@@ -247,7 +247,7 @@ static void __cpuinit winchip2_protect_mcr(void)
247#define RNG_ENABLED (1 << 3) 247#define RNG_ENABLED (1 << 3)
248#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */ 248#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */
249 249
250static void __cpuinit init_c3(struct cpuinfo_x86 *c) 250static void init_c3(struct cpuinfo_x86 *c)
251{ 251{
252 u32 lo, hi; 252 u32 lo, hi;
253 253
@@ -318,7 +318,7 @@ enum {
318 EAMD3D = 1<<20, 318 EAMD3D = 1<<20,
319}; 319};
320 320
321static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) 321static void early_init_centaur(struct cpuinfo_x86 *c)
322{ 322{
323 switch (c->x86) { 323 switch (c->x86) {
324#ifdef CONFIG_X86_32 324#ifdef CONFIG_X86_32
@@ -337,7 +337,7 @@ static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
337#endif 337#endif
338} 338}
339 339
340static void __cpuinit init_centaur(struct cpuinfo_x86 *c) 340static void init_centaur(struct cpuinfo_x86 *c)
341{ 341{
342#ifdef CONFIG_X86_32 342#ifdef CONFIG_X86_32
343 char *name; 343 char *name;
@@ -468,7 +468,7 @@ static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
468#endif 468#endif
469} 469}
470 470
471static unsigned int __cpuinit 471static unsigned int
472centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size) 472centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)
473{ 473{
474#ifdef CONFIG_X86_32 474#ifdef CONFIG_X86_32
@@ -488,7 +488,7 @@ centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)
488 return size; 488 return size;
489} 489}
490 490
491static const struct cpu_dev __cpuinitconst centaur_cpu_dev = { 491static const struct cpu_dev centaur_cpu_dev = {
492 .c_vendor = "Centaur", 492 .c_vendor = "Centaur",
493 .c_ident = { "CentaurHauls" }, 493 .c_ident = { "CentaurHauls" },
494 .c_early_init = early_init_centaur, 494 .c_early_init = early_init_centaur,
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 548bd039784e..25eb2747b063 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -63,7 +63,7 @@ void __init setup_cpu_local_masks(void)
63 alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); 63 alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask);
64} 64}
65 65
66static void __cpuinit default_init(struct cpuinfo_x86 *c) 66static void default_init(struct cpuinfo_x86 *c)
67{ 67{
68#ifdef CONFIG_X86_64 68#ifdef CONFIG_X86_64
69 cpu_detect_cache_sizes(c); 69 cpu_detect_cache_sizes(c);
@@ -80,13 +80,13 @@ static void __cpuinit default_init(struct cpuinfo_x86 *c)
80#endif 80#endif
81} 81}
82 82
83static const struct cpu_dev __cpuinitconst default_cpu = { 83static const struct cpu_dev default_cpu = {
84 .c_init = default_init, 84 .c_init = default_init,
85 .c_vendor = "Unknown", 85 .c_vendor = "Unknown",
86 .c_x86_vendor = X86_VENDOR_UNKNOWN, 86 .c_x86_vendor = X86_VENDOR_UNKNOWN,
87}; 87};
88 88
89static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu; 89static const struct cpu_dev *this_cpu = &default_cpu;
90 90
91DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { 91DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
92#ifdef CONFIG_X86_64 92#ifdef CONFIG_X86_64
@@ -160,8 +160,8 @@ static int __init x86_xsaveopt_setup(char *s)
160__setup("noxsaveopt", x86_xsaveopt_setup); 160__setup("noxsaveopt", x86_xsaveopt_setup);
161 161
162#ifdef CONFIG_X86_32 162#ifdef CONFIG_X86_32
163static int cachesize_override __cpuinitdata = -1; 163static int cachesize_override = -1;
164static int disable_x86_serial_nr __cpuinitdata = 1; 164static int disable_x86_serial_nr = 1;
165 165
166static int __init cachesize_setup(char *str) 166static int __init cachesize_setup(char *str)
167{ 167{
@@ -215,12 +215,12 @@ static inline int flag_is_changeable_p(u32 flag)
215} 215}
216 216
217/* Probe for the CPUID instruction */ 217/* Probe for the CPUID instruction */
218int __cpuinit have_cpuid_p(void) 218int have_cpuid_p(void)
219{ 219{
220 return flag_is_changeable_p(X86_EFLAGS_ID); 220 return flag_is_changeable_p(X86_EFLAGS_ID);
221} 221}
222 222
223static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) 223static void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
224{ 224{
225 unsigned long lo, hi; 225 unsigned long lo, hi;
226 226
@@ -298,7 +298,7 @@ struct cpuid_dependent_feature {
298 u32 level; 298 u32 level;
299}; 299};
300 300
301static const struct cpuid_dependent_feature __cpuinitconst 301static const struct cpuid_dependent_feature
302cpuid_dependent_features[] = { 302cpuid_dependent_features[] = {
303 { X86_FEATURE_MWAIT, 0x00000005 }, 303 { X86_FEATURE_MWAIT, 0x00000005 },
304 { X86_FEATURE_DCA, 0x00000009 }, 304 { X86_FEATURE_DCA, 0x00000009 },
@@ -306,7 +306,7 @@ cpuid_dependent_features[] = {
306 { 0, 0 } 306 { 0, 0 }
307}; 307};
308 308
309static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) 309static void filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
310{ 310{
311 const struct cpuid_dependent_feature *df; 311 const struct cpuid_dependent_feature *df;
312 312
@@ -344,7 +344,7 @@ static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
344 */ 344 */
345 345
346/* Look up CPU names by table lookup. */ 346/* Look up CPU names by table lookup. */
347static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c) 347static const char *table_lookup_model(struct cpuinfo_x86 *c)
348{ 348{
349 const struct cpu_model_info *info; 349 const struct cpu_model_info *info;
350 350
@@ -364,8 +364,8 @@ static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c)
364 return NULL; /* Not found */ 364 return NULL; /* Not found */
365} 365}
366 366
367__u32 cpu_caps_cleared[NCAPINTS] __cpuinitdata; 367__u32 cpu_caps_cleared[NCAPINTS];
368__u32 cpu_caps_set[NCAPINTS] __cpuinitdata; 368__u32 cpu_caps_set[NCAPINTS];
369 369
370void load_percpu_segment(int cpu) 370void load_percpu_segment(int cpu)
371{ 371{
@@ -394,9 +394,9 @@ void switch_to_new_gdt(int cpu)
394 load_percpu_segment(cpu); 394 load_percpu_segment(cpu);
395} 395}
396 396
397static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {}; 397static const struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
398 398
399static void __cpuinit get_model_name(struct cpuinfo_x86 *c) 399static void get_model_name(struct cpuinfo_x86 *c)
400{ 400{
401 unsigned int *v; 401 unsigned int *v;
402 char *p, *q; 402 char *p, *q;
@@ -425,7 +425,7 @@ static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
425 } 425 }
426} 426}
427 427
428void __cpuinit cpu_detect_cache_sizes(struct cpuinfo_x86 *c) 428void cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
429{ 429{
430 unsigned int n, dummy, ebx, ecx, edx, l2size; 430 unsigned int n, dummy, ebx, ecx, edx, l2size;
431 431
@@ -479,7 +479,7 @@ u16 __read_mostly tlb_lld_4m[NR_INFO];
479 */ 479 */
480s8 __read_mostly tlb_flushall_shift = -1; 480s8 __read_mostly tlb_flushall_shift = -1;
481 481
482void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c) 482void cpu_detect_tlb(struct cpuinfo_x86 *c)
483{ 483{
484 if (this_cpu->c_detect_tlb) 484 if (this_cpu->c_detect_tlb)
485 this_cpu->c_detect_tlb(c); 485 this_cpu->c_detect_tlb(c);
@@ -493,7 +493,7 @@ void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c)
493 tlb_flushall_shift); 493 tlb_flushall_shift);
494} 494}
495 495
496void __cpuinit detect_ht(struct cpuinfo_x86 *c) 496void detect_ht(struct cpuinfo_x86 *c)
497{ 497{
498#ifdef CONFIG_X86_HT 498#ifdef CONFIG_X86_HT
499 u32 eax, ebx, ecx, edx; 499 u32 eax, ebx, ecx, edx;
@@ -544,7 +544,7 @@ out:
544#endif 544#endif
545} 545}
546 546
547static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) 547static void get_cpu_vendor(struct cpuinfo_x86 *c)
548{ 548{
549 char *v = c->x86_vendor_id; 549 char *v = c->x86_vendor_id;
550 int i; 550 int i;
@@ -571,7 +571,7 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
571 this_cpu = &default_cpu; 571 this_cpu = &default_cpu;
572} 572}
573 573
574void __cpuinit cpu_detect(struct cpuinfo_x86 *c) 574void cpu_detect(struct cpuinfo_x86 *c)
575{ 575{
576 /* Get vendor name */ 576 /* Get vendor name */
577 cpuid(0x00000000, (unsigned int *)&c->cpuid_level, 577 cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
@@ -601,7 +601,7 @@ void __cpuinit cpu_detect(struct cpuinfo_x86 *c)
601 } 601 }
602} 602}
603 603
604void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) 604void get_cpu_cap(struct cpuinfo_x86 *c)
605{ 605{
606 u32 tfms, xlvl; 606 u32 tfms, xlvl;
607 u32 ebx; 607 u32 ebx;
@@ -652,7 +652,7 @@ void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
652 init_scattered_cpuid_features(c); 652 init_scattered_cpuid_features(c);
653} 653}
654 654
655static void __cpuinit identify_cpu_without_cpuid(struct cpuinfo_x86 *c) 655static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
656{ 656{
657#ifdef CONFIG_X86_32 657#ifdef CONFIG_X86_32
658 int i; 658 int i;
@@ -769,7 +769,7 @@ void __init early_cpu_init(void)
769 * unless we can find a reliable way to detect all the broken cases. 769 * unless we can find a reliable way to detect all the broken cases.
770 * Enable it explicitly on 64-bit for non-constant inputs of cpu_has(). 770 * Enable it explicitly on 64-bit for non-constant inputs of cpu_has().
771 */ 771 */
772static void __cpuinit detect_nopl(struct cpuinfo_x86 *c) 772static void detect_nopl(struct cpuinfo_x86 *c)
773{ 773{
774#ifdef CONFIG_X86_32 774#ifdef CONFIG_X86_32
775 clear_cpu_cap(c, X86_FEATURE_NOPL); 775 clear_cpu_cap(c, X86_FEATURE_NOPL);
@@ -778,7 +778,7 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
778#endif 778#endif
779} 779}
780 780
781static void __cpuinit generic_identify(struct cpuinfo_x86 *c) 781static void generic_identify(struct cpuinfo_x86 *c)
782{ 782{
783 c->extended_cpuid_level = 0; 783 c->extended_cpuid_level = 0;
784 784
@@ -815,7 +815,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
815/* 815/*
816 * This does the hard work of actually picking apart the CPU stuff... 816 * This does the hard work of actually picking apart the CPU stuff...
817 */ 817 */
818static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) 818static void identify_cpu(struct cpuinfo_x86 *c)
819{ 819{
820 int i; 820 int i;
821 821
@@ -960,7 +960,7 @@ void __init identify_boot_cpu(void)
960 cpu_detect_tlb(&boot_cpu_data); 960 cpu_detect_tlb(&boot_cpu_data);
961} 961}
962 962
963void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) 963void identify_secondary_cpu(struct cpuinfo_x86 *c)
964{ 964{
965 BUG_ON(c == &boot_cpu_data); 965 BUG_ON(c == &boot_cpu_data);
966 identify_cpu(c); 966 identify_cpu(c);
@@ -975,14 +975,14 @@ struct msr_range {
975 unsigned max; 975 unsigned max;
976}; 976};
977 977
978static const struct msr_range msr_range_array[] __cpuinitconst = { 978static const struct msr_range msr_range_array[] = {
979 { 0x00000000, 0x00000418}, 979 { 0x00000000, 0x00000418},
980 { 0xc0000000, 0xc000040b}, 980 { 0xc0000000, 0xc000040b},
981 { 0xc0010000, 0xc0010142}, 981 { 0xc0010000, 0xc0010142},
982 { 0xc0011000, 0xc001103b}, 982 { 0xc0011000, 0xc001103b},
983}; 983};
984 984
985static void __cpuinit __print_cpu_msr(void) 985static void __print_cpu_msr(void)
986{ 986{
987 unsigned index_min, index_max; 987 unsigned index_min, index_max;
988 unsigned index; 988 unsigned index;
@@ -1001,7 +1001,7 @@ static void __cpuinit __print_cpu_msr(void)
1001 } 1001 }
1002} 1002}
1003 1003
1004static int show_msr __cpuinitdata; 1004static int show_msr;
1005 1005
1006static __init int setup_show_msr(char *arg) 1006static __init int setup_show_msr(char *arg)
1007{ 1007{
@@ -1022,7 +1022,7 @@ static __init int setup_noclflush(char *arg)
1022} 1022}
1023__setup("noclflush", setup_noclflush); 1023__setup("noclflush", setup_noclflush);
1024 1024
1025void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) 1025void print_cpu_info(struct cpuinfo_x86 *c)
1026{ 1026{
1027 const char *vendor = NULL; 1027 const char *vendor = NULL;
1028 1028
@@ -1051,7 +1051,7 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
1051 print_cpu_msr(c); 1051 print_cpu_msr(c);
1052} 1052}
1053 1053
1054void __cpuinit print_cpu_msr(struct cpuinfo_x86 *c) 1054void print_cpu_msr(struct cpuinfo_x86 *c)
1055{ 1055{
1056 if (c->cpu_index < show_msr) 1056 if (c->cpu_index < show_msr)
1057 __print_cpu_msr(); 1057 __print_cpu_msr();
@@ -1216,7 +1216,7 @@ static void dbg_restore_debug_regs(void)
1216 */ 1216 */
1217#ifdef CONFIG_X86_64 1217#ifdef CONFIG_X86_64
1218 1218
1219void __cpuinit cpu_init(void) 1219void cpu_init(void)
1220{ 1220{
1221 struct orig_ist *oist; 1221 struct orig_ist *oist;
1222 struct task_struct *me; 1222 struct task_struct *me;
@@ -1315,7 +1315,7 @@ void __cpuinit cpu_init(void)
1315 1315
1316#else 1316#else
1317 1317
1318void __cpuinit cpu_init(void) 1318void cpu_init(void)
1319{ 1319{
1320 int cpu = smp_processor_id(); 1320 int cpu = smp_processor_id();
1321 struct task_struct *curr = current; 1321 struct task_struct *curr = current;
diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index 7582f475b163..d0969c75ab54 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -15,7 +15,7 @@
15/* 15/*
16 * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU 16 * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU
17 */ 17 */
18static void __cpuinit __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) 18static void __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
19{ 19{
20 unsigned char ccr2, ccr3; 20 unsigned char ccr2, ccr3;
21 21
@@ -44,7 +44,7 @@ static void __cpuinit __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
44 } 44 }
45} 45}
46 46
47static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) 47static void do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
48{ 48{
49 unsigned long flags; 49 unsigned long flags;
50 50
@@ -59,25 +59,25 @@ static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
59 * Actually since bugs.h doesn't even reference this perhaps someone should 59 * Actually since bugs.h doesn't even reference this perhaps someone should
60 * fix the documentation ??? 60 * fix the documentation ???
61 */ 61 */
62static unsigned char Cx86_dir0_msb __cpuinitdata = 0; 62static unsigned char Cx86_dir0_msb = 0;
63 63
64static const char __cpuinitconst Cx86_model[][9] = { 64static const char Cx86_model[][9] = {
65 "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ", 65 "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ",
66 "M II ", "Unknown" 66 "M II ", "Unknown"
67}; 67};
68static const char __cpuinitconst Cx486_name[][5] = { 68static const char Cx486_name[][5] = {
69 "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx", 69 "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx",
70 "SRx2", "DRx2" 70 "SRx2", "DRx2"
71}; 71};
72static const char __cpuinitconst Cx486S_name[][4] = { 72static const char Cx486S_name[][4] = {
73 "S", "S2", "Se", "S2e" 73 "S", "S2", "Se", "S2e"
74}; 74};
75static const char __cpuinitconst Cx486D_name[][4] = { 75static const char Cx486D_name[][4] = {
76 "DX", "DX2", "?", "?", "?", "DX4" 76 "DX", "DX2", "?", "?", "?", "DX4"
77}; 77};
78static char Cx86_cb[] __cpuinitdata = "?.5x Core/Bus Clock"; 78static char Cx86_cb[] = "?.5x Core/Bus Clock";
79static const char __cpuinitconst cyrix_model_mult1[] = "12??43"; 79static const char cyrix_model_mult1[] = "12??43";
80static const char __cpuinitconst cyrix_model_mult2[] = "12233445"; 80static const char cyrix_model_mult2[] = "12233445";
81 81
82/* 82/*
83 * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old 83 * 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";
87 * FIXME: our newer udelay uses the tsc. We don't need to frob with SLOP 87 * FIXME: our newer udelay uses the tsc. We don't need to frob with SLOP
88 */ 88 */
89 89
90static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c) 90static void check_cx686_slop(struct cpuinfo_x86 *c)
91{ 91{
92 unsigned long flags; 92 unsigned long flags;
93 93
@@ -112,7 +112,7 @@ static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c)
112} 112}
113 113
114 114
115static void __cpuinit set_cx86_reorder(void) 115static void set_cx86_reorder(void)
116{ 116{
117 u8 ccr3; 117 u8 ccr3;
118 118
@@ -127,7 +127,7 @@ static void __cpuinit set_cx86_reorder(void)
127 setCx86(CX86_CCR3, ccr3); 127 setCx86(CX86_CCR3, ccr3);
128} 128}
129 129
130static void __cpuinit set_cx86_memwb(void) 130static void set_cx86_memwb(void)
131{ 131{
132 printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n"); 132 printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n");
133 133
@@ -143,7 +143,7 @@ static void __cpuinit set_cx86_memwb(void)
143 * Configure later MediaGX and/or Geode processor. 143 * Configure later MediaGX and/or Geode processor.
144 */ 144 */
145 145
146static void __cpuinit geode_configure(void) 146static void geode_configure(void)
147{ 147{
148 unsigned long flags; 148 unsigned long flags;
149 u8 ccr3; 149 u8 ccr3;
@@ -166,7 +166,7 @@ static void __cpuinit geode_configure(void)
166 local_irq_restore(flags); 166 local_irq_restore(flags);
167} 167}
168 168
169static void __cpuinit early_init_cyrix(struct cpuinfo_x86 *c) 169static void early_init_cyrix(struct cpuinfo_x86 *c)
170{ 170{
171 unsigned char dir0, dir0_msn, dir1 = 0; 171 unsigned char dir0, dir0_msn, dir1 = 0;
172 172
@@ -185,7 +185,7 @@ static void __cpuinit early_init_cyrix(struct cpuinfo_x86 *c)
185 } 185 }
186} 186}
187 187
188static void __cpuinit init_cyrix(struct cpuinfo_x86 *c) 188static void init_cyrix(struct cpuinfo_x86 *c)
189{ 189{
190 unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0; 190 unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0;
191 char *buf = c->x86_model_id; 191 char *buf = c->x86_model_id;
@@ -356,7 +356,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
356/* 356/*
357 * Handle National Semiconductor branded processors 357 * Handle National Semiconductor branded processors
358 */ 358 */
359static void __cpuinit init_nsc(struct cpuinfo_x86 *c) 359static void init_nsc(struct cpuinfo_x86 *c)
360{ 360{
361 /* 361 /*
362 * There may be GX1 processors in the wild that are branded 362 * There may be GX1 processors in the wild that are branded
@@ -405,7 +405,7 @@ static inline int test_cyrix_52div(void)
405 return (unsigned char) (test >> 8) == 0x02; 405 return (unsigned char) (test >> 8) == 0x02;
406} 406}
407 407
408static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c) 408static void cyrix_identify(struct cpuinfo_x86 *c)
409{ 409{
410 /* Detect Cyrix with disabled CPUID */ 410 /* Detect Cyrix with disabled CPUID */
411 if (c->x86 == 4 && test_cyrix_52div()) { 411 if (c->x86 == 4 && test_cyrix_52div()) {
@@ -441,7 +441,7 @@ static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c)
441 } 441 }
442} 442}
443 443
444static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = { 444static const struct cpu_dev cyrix_cpu_dev = {
445 .c_vendor = "Cyrix", 445 .c_vendor = "Cyrix",
446 .c_ident = { "CyrixInstead" }, 446 .c_ident = { "CyrixInstead" },
447 .c_early_init = early_init_cyrix, 447 .c_early_init = early_init_cyrix,
@@ -452,7 +452,7 @@ static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = {
452 452
453cpu_dev_register(cyrix_cpu_dev); 453cpu_dev_register(cyrix_cpu_dev);
454 454
455static const struct cpu_dev __cpuinitconst nsc_cpu_dev = { 455static const struct cpu_dev nsc_cpu_dev = {
456 .c_vendor = "NSC", 456 .c_vendor = "NSC",
457 .c_ident = { "Geode by NSC" }, 457 .c_ident = { "Geode by NSC" },
458 .c_init = init_nsc, 458 .c_init = init_nsc,
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 1e7e84a02eba..87279212d318 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -60,7 +60,7 @@ detect_hypervisor_vendor(void)
60 } 60 }
61} 61}
62 62
63void __cpuinit init_hypervisor(struct cpuinfo_x86 *c) 63void init_hypervisor(struct cpuinfo_x86 *c)
64{ 64{
65 if (x86_hyper && x86_hyper->set_cpu_features) 65 if (x86_hyper && x86_hyper->set_cpu_features)
66 x86_hyper->set_cpu_features(c); 66 x86_hyper->set_cpu_features(c);
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 9b0c441c03f5..ec7299566f79 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -26,7 +26,7 @@
26#include <asm/apic.h> 26#include <asm/apic.h>
27#endif 27#endif
28 28
29static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) 29static void early_init_intel(struct cpuinfo_x86 *c)
30{ 30{
31 u64 misc_enable; 31 u64 misc_enable;
32 32
@@ -163,7 +163,7 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
163 * This is called before we do cpu ident work 163 * This is called before we do cpu ident work
164 */ 164 */
165 165
166int __cpuinit ppro_with_ram_bug(void) 166int ppro_with_ram_bug(void)
167{ 167{
168 /* Uses data from early_cpu_detect now */ 168 /* Uses data from early_cpu_detect now */
169 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && 169 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
@@ -176,7 +176,7 @@ int __cpuinit ppro_with_ram_bug(void)
176 return 0; 176 return 0;
177} 177}
178 178
179static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c) 179static void intel_smp_check(struct cpuinfo_x86 *c)
180{ 180{
181 /* calling is from identify_secondary_cpu() ? */ 181 /* calling is from identify_secondary_cpu() ? */
182 if (!c->cpu_index) 182 if (!c->cpu_index)
@@ -196,7 +196,7 @@ static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c)
196 } 196 }
197} 197}
198 198
199static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c) 199static void intel_workarounds(struct cpuinfo_x86 *c)
200{ 200{
201 unsigned long lo, hi; 201 unsigned long lo, hi;
202 202
@@ -275,12 +275,12 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
275 intel_smp_check(c); 275 intel_smp_check(c);
276} 276}
277#else 277#else
278static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c) 278static void intel_workarounds(struct cpuinfo_x86 *c)
279{ 279{
280} 280}
281#endif 281#endif
282 282
283static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) 283static void srat_detect_node(struct cpuinfo_x86 *c)
284{ 284{
285#ifdef CONFIG_NUMA 285#ifdef CONFIG_NUMA
286 unsigned node; 286 unsigned node;
@@ -300,7 +300,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
300/* 300/*
301 * find out the number of processor cores on the die 301 * find out the number of processor cores on the die
302 */ 302 */
303static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c) 303static int intel_num_cpu_cores(struct cpuinfo_x86 *c)
304{ 304{
305 unsigned int eax, ebx, ecx, edx; 305 unsigned int eax, ebx, ecx, edx;
306 306
@@ -315,7 +315,7 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
315 return 1; 315 return 1;
316} 316}
317 317
318static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c) 318static void detect_vmx_virtcap(struct cpuinfo_x86 *c)
319{ 319{
320 /* Intel VMX MSR indicated features */ 320 /* Intel VMX MSR indicated features */
321#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000 321#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000
@@ -353,7 +353,7 @@ static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
353 } 353 }
354} 354}
355 355
356static void __cpuinit init_intel(struct cpuinfo_x86 *c) 356static void init_intel(struct cpuinfo_x86 *c)
357{ 357{
358 unsigned int l2 = 0; 358 unsigned int l2 = 0;
359 359
@@ -472,7 +472,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
472} 472}
473 473
474#ifdef CONFIG_X86_32 474#ifdef CONFIG_X86_32
475static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned int size) 475static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
476{ 476{
477 /* 477 /*
478 * Intel PIII Tualatin. This comes in two flavours. 478 * 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
506 506
507#define STLB_4K 0x41 507#define STLB_4K 0x41
508 508
509static const struct _tlb_table intel_tlb_table[] __cpuinitconst = { 509static const struct _tlb_table intel_tlb_table[] = {
510 { 0x01, TLB_INST_4K, 32, " TLB_INST 4 KByte pages, 4-way set associative" }, 510 { 0x01, TLB_INST_4K, 32, " TLB_INST 4 KByte pages, 4-way set associative" },
511 { 0x02, TLB_INST_4M, 2, " TLB_INST 4 MByte pages, full associative" }, 511 { 0x02, TLB_INST_4M, 2, " TLB_INST 4 MByte pages, full associative" },
512 { 0x03, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way set associative" }, 512 { 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 = {
536 { 0x00, 0, 0 } 536 { 0x00, 0, 0 }
537}; 537};
538 538
539static void __cpuinit intel_tlb_lookup(const unsigned char desc) 539static void intel_tlb_lookup(const unsigned char desc)
540{ 540{
541 unsigned char k; 541 unsigned char k;
542 if (desc == 0) 542 if (desc == 0)
@@ -605,7 +605,7 @@ static void __cpuinit intel_tlb_lookup(const unsigned char desc)
605 } 605 }
606} 606}
607 607
608static void __cpuinit intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c) 608static void intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c)
609{ 609{
610 switch ((c->x86 << 8) + c->x86_model) { 610 switch ((c->x86 << 8) + c->x86_model) {
611 case 0x60f: /* original 65 nm celeron/pentium/core2/xeon, "Merom"/"Conroe" */ 611 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)
634 } 634 }
635} 635}
636 636
637static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c) 637static void intel_detect_tlb(struct cpuinfo_x86 *c)
638{ 638{
639 int i, j, n; 639 int i, j, n;
640 unsigned int regs[4]; 640 unsigned int regs[4];
@@ -661,7 +661,7 @@ static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c)
661 intel_tlb_flushall_shift_set(c); 661 intel_tlb_flushall_shift_set(c);
662} 662}
663 663
664static const struct cpu_dev __cpuinitconst intel_cpu_dev = { 664static const struct cpu_dev intel_cpu_dev = {
665 .c_vendor = "Intel", 665 .c_vendor = "Intel",
666 .c_ident = { "GenuineIntel" }, 666 .c_ident = { "GenuineIntel" },
667#ifdef CONFIG_X86_32 667#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 8dc72dda66fe..1414c90feaba 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -37,7 +37,7 @@ struct _cache_table {
37/* All the cache descriptor types we care about (no TLB or 37/* All the cache descriptor types we care about (no TLB or
38 trace cache entries) */ 38 trace cache entries) */
39 39
40static const struct _cache_table __cpuinitconst cache_table[] = 40static const struct _cache_table cache_table[] =
41{ 41{
42 { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */ 42 { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */
43 { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */ 43 { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */
@@ -203,7 +203,7 @@ union l3_cache {
203 unsigned val; 203 unsigned val;
204}; 204};
205 205
206static const unsigned short __cpuinitconst assocs[] = { 206static const unsigned short assocs[] = {
207 [1] = 1, 207 [1] = 1,
208 [2] = 2, 208 [2] = 2,
209 [4] = 4, 209 [4] = 4,
@@ -217,10 +217,10 @@ static const unsigned short __cpuinitconst assocs[] = {
217 [0xf] = 0xffff /* fully associative - no way to show this currently */ 217 [0xf] = 0xffff /* fully associative - no way to show this currently */
218}; 218};
219 219
220static const unsigned char __cpuinitconst levels[] = { 1, 1, 2, 3 }; 220static const unsigned char levels[] = { 1, 1, 2, 3 };
221static const unsigned char __cpuinitconst types[] = { 1, 2, 3, 3 }; 221static const unsigned char types[] = { 1, 2, 3, 3 };
222 222
223static void __cpuinit 223static void
224amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, 224amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
225 union _cpuid4_leaf_ebx *ebx, 225 union _cpuid4_leaf_ebx *ebx,
226 union _cpuid4_leaf_ecx *ecx) 226 union _cpuid4_leaf_ecx *ecx)
@@ -302,7 +302,7 @@ struct _cache_attr {
302/* 302/*
303 * L3 cache descriptors 303 * L3 cache descriptors
304 */ 304 */
305static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb) 305static void amd_calc_l3_indices(struct amd_northbridge *nb)
306{ 306{
307 struct amd_l3_cache *l3 = &nb->l3_cache; 307 struct amd_l3_cache *l3 = &nb->l3_cache;
308 unsigned int sc0, sc1, sc2, sc3; 308 unsigned int sc0, sc1, sc2, sc3;
@@ -325,7 +325,7 @@ static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb)
325 l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1; 325 l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1;
326} 326}
327 327
328static void __cpuinit amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index) 328static void amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index)
329{ 329{
330 int node; 330 int node;
331 331
@@ -528,8 +528,7 @@ static struct _cache_attr subcaches =
528#endif /* CONFIG_AMD_NB && CONFIG_SYSFS */ 528#endif /* CONFIG_AMD_NB && CONFIG_SYSFS */
529 529
530static int 530static int
531__cpuinit cpuid4_cache_lookup_regs(int index, 531cpuid4_cache_lookup_regs(int index, struct _cpuid4_info_regs *this_leaf)
532 struct _cpuid4_info_regs *this_leaf)
533{ 532{
534 union _cpuid4_leaf_eax eax; 533 union _cpuid4_leaf_eax eax;
535 union _cpuid4_leaf_ebx ebx; 534 union _cpuid4_leaf_ebx ebx;
@@ -560,7 +559,7 @@ __cpuinit cpuid4_cache_lookup_regs(int index,
560 return 0; 559 return 0;
561} 560}
562 561
563static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c) 562static int find_num_cache_leaves(struct cpuinfo_x86 *c)
564{ 563{
565 unsigned int eax, ebx, ecx, edx, op; 564 unsigned int eax, ebx, ecx, edx, op;
566 union _cpuid4_leaf_eax cache_eax; 565 union _cpuid4_leaf_eax cache_eax;
@@ -580,7 +579,7 @@ static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c)
580 return i; 579 return i;
581} 580}
582 581
583void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c) 582void init_amd_cacheinfo(struct cpuinfo_x86 *c)
584{ 583{
585 584
586 if (cpu_has_topoext) { 585 if (cpu_has_topoext) {
@@ -593,7 +592,7 @@ void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c)
593 } 592 }
594} 593}
595 594
596unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) 595unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c)
597{ 596{
598 /* Cache sizes */ 597 /* Cache sizes */
599 unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; 598 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);
744 743
745#ifdef CONFIG_SMP 744#ifdef CONFIG_SMP
746 745
747static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) 746static int cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
748{ 747{
749 struct _cpuid4_info *this_leaf; 748 struct _cpuid4_info *this_leaf;
750 int i, sibling; 749 int i, sibling;
@@ -793,7 +792,7 @@ static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
793 return 1; 792 return 1;
794} 793}
795 794
796static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) 795static void cache_shared_cpu_map_setup(unsigned int cpu, int index)
797{ 796{
798 struct _cpuid4_info *this_leaf, *sibling_leaf; 797 struct _cpuid4_info *this_leaf, *sibling_leaf;
799 unsigned long num_threads_sharing; 798 unsigned long num_threads_sharing;
@@ -828,7 +827,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
828 } 827 }
829 } 828 }
830} 829}
831static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) 830static void cache_remove_shared_cpu_map(unsigned int cpu, int index)
832{ 831{
833 struct _cpuid4_info *this_leaf, *sibling_leaf; 832 struct _cpuid4_info *this_leaf, *sibling_leaf;
834 int sibling; 833 int sibling;
@@ -841,16 +840,16 @@ static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
841 } 840 }
842} 841}
843#else 842#else
844static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) 843static void cache_shared_cpu_map_setup(unsigned int cpu, int index)
845{ 844{
846} 845}
847 846
848static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) 847static void cache_remove_shared_cpu_map(unsigned int cpu, int index)
849{ 848{
850} 849}
851#endif 850#endif
852 851
853static void __cpuinit free_cache_attributes(unsigned int cpu) 852static void free_cache_attributes(unsigned int cpu)
854{ 853{
855 int i; 854 int i;
856 855
@@ -861,7 +860,7 @@ static void __cpuinit free_cache_attributes(unsigned int cpu)
861 per_cpu(ici_cpuid4_info, cpu) = NULL; 860 per_cpu(ici_cpuid4_info, cpu) = NULL;
862} 861}
863 862
864static void __cpuinit get_cpu_leaves(void *_retval) 863static void get_cpu_leaves(void *_retval)
865{ 864{
866 int j, *retval = _retval, cpu = smp_processor_id(); 865 int j, *retval = _retval, cpu = smp_processor_id();
867 866
@@ -881,7 +880,7 @@ static void __cpuinit get_cpu_leaves(void *_retval)
881 } 880 }
882} 881}
883 882
884static int __cpuinit detect_cache_attributes(unsigned int cpu) 883static int detect_cache_attributes(unsigned int cpu)
885{ 884{
886 int retval; 885 int retval;
887 886
@@ -1015,7 +1014,7 @@ static struct attribute *default_attrs[] = {
1015}; 1014};
1016 1015
1017#ifdef CONFIG_AMD_NB 1016#ifdef CONFIG_AMD_NB
1018static struct attribute ** __cpuinit amd_l3_attrs(void) 1017static struct attribute **amd_l3_attrs(void)
1019{ 1018{
1020 static struct attribute **attrs; 1019 static struct attribute **attrs;
1021 int n; 1020 int n;
@@ -1091,7 +1090,7 @@ static struct kobj_type ktype_percpu_entry = {
1091 .sysfs_ops = &sysfs_ops, 1090 .sysfs_ops = &sysfs_ops,
1092}; 1091};
1093 1092
1094static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu) 1093static void cpuid4_cache_sysfs_exit(unsigned int cpu)
1095{ 1094{
1096 kfree(per_cpu(ici_cache_kobject, cpu)); 1095 kfree(per_cpu(ici_cache_kobject, cpu));
1097 kfree(per_cpu(ici_index_kobject, cpu)); 1096 kfree(per_cpu(ici_index_kobject, cpu));
@@ -1100,7 +1099,7 @@ static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu)
1100 free_cache_attributes(cpu); 1099 free_cache_attributes(cpu);
1101} 1100}
1102 1101
1103static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu) 1102static int cpuid4_cache_sysfs_init(unsigned int cpu)
1104{ 1103{
1105 int err; 1104 int err;
1106 1105
@@ -1132,7 +1131,7 @@ err_out:
1132static DECLARE_BITMAP(cache_dev_map, NR_CPUS); 1131static DECLARE_BITMAP(cache_dev_map, NR_CPUS);
1133 1132
1134/* Add/Remove cache interface for CPU device */ 1133/* Add/Remove cache interface for CPU device */
1135static int __cpuinit cache_add_dev(struct device *dev) 1134static int cache_add_dev(struct device *dev)
1136{ 1135{
1137 unsigned int cpu = dev->id; 1136 unsigned int cpu = dev->id;
1138 unsigned long i, j; 1137 unsigned long i, j;
@@ -1183,7 +1182,7 @@ static int __cpuinit cache_add_dev(struct device *dev)
1183 return 0; 1182 return 0;
1184} 1183}
1185 1184
1186static void __cpuinit cache_remove_dev(struct device *dev) 1185static void cache_remove_dev(struct device *dev)
1187{ 1186{
1188 unsigned int cpu = dev->id; 1187 unsigned int cpu = dev->id;
1189 unsigned long i; 1188 unsigned long i;
@@ -1200,8 +1199,8 @@ static void __cpuinit cache_remove_dev(struct device *dev)
1200 cpuid4_cache_sysfs_exit(cpu); 1199 cpuid4_cache_sysfs_exit(cpu);
1201} 1200}
1202 1201
1203static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb, 1202static int cacheinfo_cpu_callback(struct notifier_block *nfb,
1204 unsigned long action, void *hcpu) 1203 unsigned long action, void *hcpu)
1205{ 1204{
1206 unsigned int cpu = (unsigned long)hcpu; 1205 unsigned int cpu = (unsigned long)hcpu;
1207 struct device *dev; 1206 struct device *dev;
@@ -1220,7 +1219,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
1220 return NOTIFY_OK; 1219 return NOTIFY_OK;
1221} 1220}
1222 1221
1223static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = { 1222static struct notifier_block cacheinfo_cpu_notifier = {
1224 .notifier_call = cacheinfo_cpu_callback, 1223 .notifier_call = cacheinfo_cpu_callback,
1225}; 1224};
1226 1225
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index bf49cdbb010f..87a65c939bcd 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1363,7 +1363,7 @@ int mce_notify_irq(void)
1363} 1363}
1364EXPORT_SYMBOL_GPL(mce_notify_irq); 1364EXPORT_SYMBOL_GPL(mce_notify_irq);
1365 1365
1366static int __cpuinit __mcheck_cpu_mce_banks_init(void) 1366static int __mcheck_cpu_mce_banks_init(void)
1367{ 1367{
1368 int i; 1368 int i;
1369 u8 num_banks = mca_cfg.banks; 1369 u8 num_banks = mca_cfg.banks;
@@ -1384,7 +1384,7 @@ static int __cpuinit __mcheck_cpu_mce_banks_init(void)
1384/* 1384/*
1385 * Initialize Machine Checks for a CPU. 1385 * Initialize Machine Checks for a CPU.
1386 */ 1386 */
1387static int __cpuinit __mcheck_cpu_cap_init(void) 1387static int __mcheck_cpu_cap_init(void)
1388{ 1388{
1389 unsigned b; 1389 unsigned b;
1390 u64 cap; 1390 u64 cap;
@@ -1483,7 +1483,7 @@ static void quirk_sandybridge_ifu(int bank, struct mce *m, struct pt_regs *regs)
1483} 1483}
1484 1484
1485/* Add per CPU specific workarounds here */ 1485/* Add per CPU specific workarounds here */
1486static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) 1486static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
1487{ 1487{
1488 struct mca_config *cfg = &mca_cfg; 1488 struct mca_config *cfg = &mca_cfg;
1489 1489
@@ -1593,7 +1593,7 @@ static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
1593 return 0; 1593 return 0;
1594} 1594}
1595 1595
1596static int __cpuinit __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c) 1596static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
1597{ 1597{
1598 if (c->x86 != 5) 1598 if (c->x86 != 5)
1599 return 0; 1599 return 0;
@@ -1664,7 +1664,7 @@ void (*machine_check_vector)(struct pt_regs *, long error_code) =
1664 * Called for each booted CPU to set up machine checks. 1664 * Called for each booted CPU to set up machine checks.
1665 * Must be called with preempt off: 1665 * Must be called with preempt off:
1666 */ 1666 */
1667void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c) 1667void mcheck_cpu_init(struct cpuinfo_x86 *c)
1668{ 1668{
1669 if (mca_cfg.disabled) 1669 if (mca_cfg.disabled)
1670 return; 1670 return;
@@ -2082,7 +2082,6 @@ static struct bus_type mce_subsys = {
2082 2082
2083DEFINE_PER_CPU(struct device *, mce_device); 2083DEFINE_PER_CPU(struct device *, mce_device);
2084 2084
2085__cpuinitdata
2086void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); 2085void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
2087 2086
2088static inline struct mce_bank *attr_to_bank(struct device_attribute *attr) 2087static inline struct mce_bank *attr_to_bank(struct device_attribute *attr)
@@ -2228,7 +2227,7 @@ static void mce_device_release(struct device *dev)
2228} 2227}
2229 2228
2230/* Per cpu device init. All of the cpus still share the same ctrl bank: */ 2229/* Per cpu device init. All of the cpus still share the same ctrl bank: */
2231static __cpuinit int mce_device_create(unsigned int cpu) 2230static int mce_device_create(unsigned int cpu)
2232{ 2231{
2233 struct device *dev; 2232 struct device *dev;
2234 int err; 2233 int err;
@@ -2274,7 +2273,7 @@ error:
2274 return err; 2273 return err;
2275} 2274}
2276 2275
2277static __cpuinit void mce_device_remove(unsigned int cpu) 2276static void mce_device_remove(unsigned int cpu)
2278{ 2277{
2279 struct device *dev = per_cpu(mce_device, cpu); 2278 struct device *dev = per_cpu(mce_device, cpu);
2280 int i; 2279 int i;
@@ -2294,7 +2293,7 @@ static __cpuinit void mce_device_remove(unsigned int cpu)
2294} 2293}
2295 2294
2296/* Make sure there are no machine checks on offlined CPUs. */ 2295/* Make sure there are no machine checks on offlined CPUs. */
2297static void __cpuinit mce_disable_cpu(void *h) 2296static void mce_disable_cpu(void *h)
2298{ 2297{
2299 unsigned long action = *(unsigned long *)h; 2298 unsigned long action = *(unsigned long *)h;
2300 int i; 2299 int i;
@@ -2312,7 +2311,7 @@ static void __cpuinit mce_disable_cpu(void *h)
2312 } 2311 }
2313} 2312}
2314 2313
2315static void __cpuinit mce_reenable_cpu(void *h) 2314static void mce_reenable_cpu(void *h)
2316{ 2315{
2317 unsigned long action = *(unsigned long *)h; 2316 unsigned long action = *(unsigned long *)h;
2318 int i; 2317 int i;
@@ -2331,7 +2330,7 @@ static void __cpuinit mce_reenable_cpu(void *h)
2331} 2330}
2332 2331
2333/* Get notified when a cpu comes on/off. Be hotplug friendly. */ 2332/* Get notified when a cpu comes on/off. Be hotplug friendly. */
2334static int __cpuinit 2333static int
2335mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 2334mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
2336{ 2335{
2337 unsigned int cpu = (unsigned long)hcpu; 2336 unsigned int cpu = (unsigned long)hcpu;
@@ -2367,7 +2366,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
2367 return NOTIFY_OK; 2366 return NOTIFY_OK;
2368} 2367}
2369 2368
2370static struct notifier_block mce_cpu_notifier __cpuinitdata = { 2369static struct notifier_block mce_cpu_notifier = {
2371 .notifier_call = mce_cpu_callback, 2370 .notifier_call = mce_cpu_callback,
2372}; 2371};
2373 2372
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 9cb52767999a..603df4f74640 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -458,10 +458,8 @@ static struct kobj_type threshold_ktype = {
458 .default_attrs = default_attrs, 458 .default_attrs = default_attrs,
459}; 459};
460 460
461static __cpuinit int allocate_threshold_blocks(unsigned int cpu, 461static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
462 unsigned int bank, 462 unsigned int block, u32 address)
463 unsigned int block,
464 u32 address)
465{ 463{
466 struct threshold_block *b = NULL; 464 struct threshold_block *b = NULL;
467 u32 low, high; 465 u32 low, high;
@@ -543,7 +541,7 @@ out_free:
543 return err; 541 return err;
544} 542}
545 543
546static __cpuinit int __threshold_add_blocks(struct threshold_bank *b) 544static int __threshold_add_blocks(struct threshold_bank *b)
547{ 545{
548 struct list_head *head = &b->blocks->miscj; 546 struct list_head *head = &b->blocks->miscj;
549 struct threshold_block *pos = NULL; 547 struct threshold_block *pos = NULL;
@@ -567,7 +565,7 @@ static __cpuinit int __threshold_add_blocks(struct threshold_bank *b)
567 return err; 565 return err;
568} 566}
569 567
570static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) 568static int threshold_create_bank(unsigned int cpu, unsigned int bank)
571{ 569{
572 struct device *dev = per_cpu(mce_device, cpu); 570 struct device *dev = per_cpu(mce_device, cpu);
573 struct amd_northbridge *nb = NULL; 571 struct amd_northbridge *nb = NULL;
@@ -632,7 +630,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
632} 630}
633 631
634/* create dir/files for all valid threshold banks */ 632/* create dir/files for all valid threshold banks */
635static __cpuinit int threshold_create_device(unsigned int cpu) 633static int threshold_create_device(unsigned int cpu)
636{ 634{
637 unsigned int bank; 635 unsigned int bank;
638 struct threshold_bank **bp; 636 struct threshold_bank **bp;
@@ -736,7 +734,7 @@ static void threshold_remove_device(unsigned int cpu)
736} 734}
737 735
738/* get notified when a cpu comes on/off */ 736/* get notified when a cpu comes on/off */
739static void __cpuinit 737static void
740amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu) 738amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu)
741{ 739{
742 switch (action) { 740 switch (action) {
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 41e8e00a6637..3eec7de76efb 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -240,8 +240,7 @@ __setup("int_pln_enable", int_pln_enable_setup);
240 240
241#ifdef CONFIG_SYSFS 241#ifdef CONFIG_SYSFS
242/* Add/Remove thermal_throttle interface for CPU device: */ 242/* Add/Remove thermal_throttle interface for CPU device: */
243static __cpuinit int thermal_throttle_add_dev(struct device *dev, 243static int thermal_throttle_add_dev(struct device *dev, unsigned int cpu)
244 unsigned int cpu)
245{ 244{
246 int err; 245 int err;
247 struct cpuinfo_x86 *c = &cpu_data(cpu); 246 struct cpuinfo_x86 *c = &cpu_data(cpu);
@@ -267,7 +266,7 @@ static __cpuinit int thermal_throttle_add_dev(struct device *dev,
267 return err; 266 return err;
268} 267}
269 268
270static __cpuinit void thermal_throttle_remove_dev(struct device *dev) 269static void thermal_throttle_remove_dev(struct device *dev)
271{ 270{
272 sysfs_remove_group(&dev->kobj, &thermal_attr_group); 271 sysfs_remove_group(&dev->kobj, &thermal_attr_group);
273} 272}
@@ -276,7 +275,7 @@ static __cpuinit void thermal_throttle_remove_dev(struct device *dev)
276static DEFINE_MUTEX(therm_cpu_lock); 275static DEFINE_MUTEX(therm_cpu_lock);
277 276
278/* Get notified when a cpu comes on/off. Be hotplug friendly. */ 277/* Get notified when a cpu comes on/off. Be hotplug friendly. */
279static __cpuinit int 278static int
280thermal_throttle_cpu_callback(struct notifier_block *nfb, 279thermal_throttle_cpu_callback(struct notifier_block *nfb,
281 unsigned long action, 280 unsigned long action,
282 void *hcpu) 281 void *hcpu)
@@ -307,7 +306,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
307 return notifier_from_errno(err); 306 return notifier_from_errno(err);
308} 307}
309 308
310static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata = 309static struct notifier_block thermal_throttle_cpu_notifier =
311{ 310{
312 .notifier_call = thermal_throttle_cpu_callback, 311 .notifier_call = thermal_throttle_cpu_callback,
313}; 312};
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 9e581c5cf6d0..a7c7305030cc 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1295,7 +1295,7 @@ perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs)
1295struct event_constraint emptyconstraint; 1295struct event_constraint emptyconstraint;
1296struct event_constraint unconstrained; 1296struct event_constraint unconstrained;
1297 1297
1298static int __cpuinit 1298static int
1299x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) 1299x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
1300{ 1300{
1301 unsigned int cpu = (long)hcpu; 1301 unsigned int cpu = (long)hcpu;
diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
index 5f0581e713c2..e09f0bfb7b8f 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
@@ -851,7 +851,7 @@ static void clear_APIC_ibs(void *dummy)
851 setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1); 851 setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1);
852} 852}
853 853
854static int __cpuinit 854static int
855perf_ibs_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) 855perf_ibs_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
856{ 856{
857 switch (action & ~CPU_TASKS_FROZEN) { 857 switch (action & ~CPU_TASKS_FROZEN) {
diff --git a/arch/x86/kernel/cpu/perf_event_amd_uncore.c b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
index c0c661adf03e..754291adec33 100644
--- a/arch/x86/kernel/cpu/perf_event_amd_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_amd_uncore.c
@@ -288,13 +288,13 @@ static struct pmu amd_l2_pmu = {
288 .read = amd_uncore_read, 288 .read = amd_uncore_read,
289}; 289};
290 290
291static struct amd_uncore * __cpuinit amd_uncore_alloc(unsigned int cpu) 291static struct amd_uncore *amd_uncore_alloc(unsigned int cpu)
292{ 292{
293 return kzalloc_node(sizeof(struct amd_uncore), GFP_KERNEL, 293 return kzalloc_node(sizeof(struct amd_uncore), GFP_KERNEL,
294 cpu_to_node(cpu)); 294 cpu_to_node(cpu));
295} 295}
296 296
297static void __cpuinit amd_uncore_cpu_up_prepare(unsigned int cpu) 297static void amd_uncore_cpu_up_prepare(unsigned int cpu)
298{ 298{
299 struct amd_uncore *uncore; 299 struct amd_uncore *uncore;
300 300
@@ -322,8 +322,8 @@ static void __cpuinit amd_uncore_cpu_up_prepare(unsigned int cpu)
322} 322}
323 323
324static struct amd_uncore * 324static struct amd_uncore *
325__cpuinit amd_uncore_find_online_sibling(struct amd_uncore *this, 325amd_uncore_find_online_sibling(struct amd_uncore *this,
326 struct amd_uncore * __percpu *uncores) 326 struct amd_uncore * __percpu *uncores)
327{ 327{
328 unsigned int cpu; 328 unsigned int cpu;
329 struct amd_uncore *that; 329 struct amd_uncore *that;
@@ -348,7 +348,7 @@ __cpuinit amd_uncore_find_online_sibling(struct amd_uncore *this,
348 return this; 348 return this;
349} 349}
350 350
351static void __cpuinit amd_uncore_cpu_starting(unsigned int cpu) 351static void amd_uncore_cpu_starting(unsigned int cpu)
352{ 352{
353 unsigned int eax, ebx, ecx, edx; 353 unsigned int eax, ebx, ecx, edx;
354 struct amd_uncore *uncore; 354 struct amd_uncore *uncore;
@@ -376,8 +376,8 @@ static void __cpuinit amd_uncore_cpu_starting(unsigned int cpu)
376 } 376 }
377} 377}
378 378
379static void __cpuinit uncore_online(unsigned int cpu, 379static void uncore_online(unsigned int cpu,
380 struct amd_uncore * __percpu *uncores) 380 struct amd_uncore * __percpu *uncores)
381{ 381{
382 struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu); 382 struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu);
383 383
@@ -388,7 +388,7 @@ static void __cpuinit uncore_online(unsigned int cpu,
388 cpumask_set_cpu(cpu, uncore->active_mask); 388 cpumask_set_cpu(cpu, uncore->active_mask);
389} 389}
390 390
391static void __cpuinit amd_uncore_cpu_online(unsigned int cpu) 391static void amd_uncore_cpu_online(unsigned int cpu)
392{ 392{
393 if (amd_uncore_nb) 393 if (amd_uncore_nb)
394 uncore_online(cpu, amd_uncore_nb); 394 uncore_online(cpu, amd_uncore_nb);
@@ -397,8 +397,8 @@ static void __cpuinit amd_uncore_cpu_online(unsigned int cpu)
397 uncore_online(cpu, amd_uncore_l2); 397 uncore_online(cpu, amd_uncore_l2);
398} 398}
399 399
400static void __cpuinit uncore_down_prepare(unsigned int cpu, 400static void uncore_down_prepare(unsigned int cpu,
401 struct amd_uncore * __percpu *uncores) 401 struct amd_uncore * __percpu *uncores)
402{ 402{
403 unsigned int i; 403 unsigned int i;
404 struct amd_uncore *this = *per_cpu_ptr(uncores, cpu); 404 struct amd_uncore *this = *per_cpu_ptr(uncores, cpu);
@@ -423,7 +423,7 @@ static void __cpuinit uncore_down_prepare(unsigned int cpu,
423 } 423 }
424} 424}
425 425
426static void __cpuinit amd_uncore_cpu_down_prepare(unsigned int cpu) 426static void amd_uncore_cpu_down_prepare(unsigned int cpu)
427{ 427{
428 if (amd_uncore_nb) 428 if (amd_uncore_nb)
429 uncore_down_prepare(cpu, amd_uncore_nb); 429 uncore_down_prepare(cpu, amd_uncore_nb);
@@ -432,8 +432,7 @@ static void __cpuinit amd_uncore_cpu_down_prepare(unsigned int cpu)
432 uncore_down_prepare(cpu, amd_uncore_l2); 432 uncore_down_prepare(cpu, amd_uncore_l2);
433} 433}
434 434
435static void __cpuinit uncore_dead(unsigned int cpu, 435static void uncore_dead(unsigned int cpu, struct amd_uncore * __percpu *uncores)
436 struct amd_uncore * __percpu *uncores)
437{ 436{
438 struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu); 437 struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu);
439 438
@@ -445,7 +444,7 @@ static void __cpuinit uncore_dead(unsigned int cpu,
445 *per_cpu_ptr(amd_uncore_nb, cpu) = NULL; 444 *per_cpu_ptr(amd_uncore_nb, cpu) = NULL;
446} 445}
447 446
448static void __cpuinit amd_uncore_cpu_dead(unsigned int cpu) 447static void amd_uncore_cpu_dead(unsigned int cpu)
449{ 448{
450 if (amd_uncore_nb) 449 if (amd_uncore_nb)
451 uncore_dead(cpu, amd_uncore_nb); 450 uncore_dead(cpu, amd_uncore_nb);
@@ -454,7 +453,7 @@ static void __cpuinit amd_uncore_cpu_dead(unsigned int cpu)
454 uncore_dead(cpu, amd_uncore_l2); 453 uncore_dead(cpu, amd_uncore_l2);
455} 454}
456 455
457static int __cpuinit 456static int
458amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action, 457amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action,
459 void *hcpu) 458 void *hcpu)
460{ 459{
@@ -489,7 +488,7 @@ amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action,
489 return NOTIFY_OK; 488 return NOTIFY_OK;
490} 489}
491 490
492static struct notifier_block amd_uncore_cpu_notifier_block __cpuinitdata = { 491static struct notifier_block amd_uncore_cpu_notifier_block = {
493 .notifier_call = amd_uncore_cpu_notifier, 492 .notifier_call = amd_uncore_cpu_notifier,
494 .priority = CPU_PRI_PERF + 1, 493 .priority = CPU_PRI_PERF + 1,
495}; 494};
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 9dd99751ccf9..cad791dbde95 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -3297,7 +3297,7 @@ static void __init uncore_pci_exit(void)
3297/* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */ 3297/* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */
3298static LIST_HEAD(boxes_to_free); 3298static LIST_HEAD(boxes_to_free);
3299 3299
3300static void __cpuinit uncore_kfree_boxes(void) 3300static void uncore_kfree_boxes(void)
3301{ 3301{
3302 struct intel_uncore_box *box; 3302 struct intel_uncore_box *box;
3303 3303
@@ -3309,7 +3309,7 @@ static void __cpuinit uncore_kfree_boxes(void)
3309 } 3309 }
3310} 3310}
3311 3311
3312static void __cpuinit uncore_cpu_dying(int cpu) 3312static void uncore_cpu_dying(int cpu)
3313{ 3313{
3314 struct intel_uncore_type *type; 3314 struct intel_uncore_type *type;
3315 struct intel_uncore_pmu *pmu; 3315 struct intel_uncore_pmu *pmu;
@@ -3328,7 +3328,7 @@ static void __cpuinit uncore_cpu_dying(int cpu)
3328 } 3328 }
3329} 3329}
3330 3330
3331static int __cpuinit uncore_cpu_starting(int cpu) 3331static int uncore_cpu_starting(int cpu)
3332{ 3332{
3333 struct intel_uncore_type *type; 3333 struct intel_uncore_type *type;
3334 struct intel_uncore_pmu *pmu; 3334 struct intel_uncore_pmu *pmu;
@@ -3371,7 +3371,7 @@ static int __cpuinit uncore_cpu_starting(int cpu)
3371 return 0; 3371 return 0;
3372} 3372}
3373 3373
3374static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id) 3374static int uncore_cpu_prepare(int cpu, int phys_id)
3375{ 3375{
3376 struct intel_uncore_type *type; 3376 struct intel_uncore_type *type;
3377 struct intel_uncore_pmu *pmu; 3377 struct intel_uncore_pmu *pmu;
@@ -3397,7 +3397,7 @@ static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id)
3397 return 0; 3397 return 0;
3398} 3398}
3399 3399
3400static void __cpuinit 3400static void
3401uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_cpu) 3401uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_cpu)
3402{ 3402{
3403 struct intel_uncore_type *type; 3403 struct intel_uncore_type *type;
@@ -3435,7 +3435,7 @@ uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_c
3435 } 3435 }
3436} 3436}
3437 3437
3438static void __cpuinit uncore_event_exit_cpu(int cpu) 3438static void uncore_event_exit_cpu(int cpu)
3439{ 3439{
3440 int i, phys_id, target; 3440 int i, phys_id, target;
3441 3441
@@ -3463,7 +3463,7 @@ static void __cpuinit uncore_event_exit_cpu(int cpu)
3463 uncore_change_context(pci_uncores, cpu, target); 3463 uncore_change_context(pci_uncores, cpu, target);
3464} 3464}
3465 3465
3466static void __cpuinit uncore_event_init_cpu(int cpu) 3466static void uncore_event_init_cpu(int cpu)
3467{ 3467{
3468 int i, phys_id; 3468 int i, phys_id;
3469 3469
@@ -3479,8 +3479,8 @@ static void __cpuinit uncore_event_init_cpu(int cpu)
3479 uncore_change_context(pci_uncores, -1, cpu); 3479 uncore_change_context(pci_uncores, -1, cpu);
3480} 3480}
3481 3481
3482static int 3482static int uncore_cpu_notifier(struct notifier_block *self,
3483 __cpuinit uncore_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) 3483 unsigned long action, void *hcpu)
3484{ 3484{
3485 unsigned int cpu = (long)hcpu; 3485 unsigned int cpu = (long)hcpu;
3486 3486
@@ -3520,7 +3520,7 @@ static int
3520 return NOTIFY_OK; 3520 return NOTIFY_OK;
3521} 3521}
3522 3522
3523static struct notifier_block uncore_cpu_nb __cpuinitdata = { 3523static struct notifier_block uncore_cpu_nb = {
3524 .notifier_call = uncore_cpu_notifier, 3524 .notifier_call = uncore_cpu_notifier,
3525 /* 3525 /*
3526 * to migrate uncore events, our notifier should be executed 3526 * to migrate uncore events, our notifier should be executed
diff --git a/arch/x86/kernel/cpu/rdrand.c b/arch/x86/kernel/cpu/rdrand.c
index feca286c2bb4..88db010845cb 100644
--- a/arch/x86/kernel/cpu/rdrand.c
+++ b/arch/x86/kernel/cpu/rdrand.c
@@ -52,7 +52,7 @@ static inline int rdrand_long(unsigned long *v)
52 */ 52 */
53#define RESEED_LOOP ((512*128)/sizeof(unsigned long)) 53#define RESEED_LOOP ((512*128)/sizeof(unsigned long))
54 54
55void __cpuinit x86_init_rdrand(struct cpuinfo_x86 *c) 55void x86_init_rdrand(struct cpuinfo_x86 *c)
56{ 56{
57#ifdef CONFIG_ARCH_RANDOM 57#ifdef CONFIG_ARCH_RANDOM
58 unsigned long tmp; 58 unsigned long tmp;
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index d92b5dad15dd..f2cc63e9cf08 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -24,13 +24,13 @@ enum cpuid_regs {
24 CR_EBX 24 CR_EBX
25}; 25};
26 26
27void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) 27void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
28{ 28{
29 u32 max_level; 29 u32 max_level;
30 u32 regs[4]; 30 u32 regs[4];
31 const struct cpuid_bit *cb; 31 const struct cpuid_bit *cb;
32 32
33 static const struct cpuid_bit __cpuinitconst cpuid_bits[] = { 33 static const struct cpuid_bit cpuid_bits[] = {
34 { X86_FEATURE_DTHERM, CR_EAX, 0, 0x00000006, 0 }, 34 { X86_FEATURE_DTHERM, CR_EAX, 0, 0x00000006, 0 },
35 { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006, 0 }, 35 { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006, 0 },
36 { X86_FEATURE_ARAT, CR_EAX, 2, 0x00000006, 0 }, 36 { X86_FEATURE_ARAT, CR_EAX, 2, 0x00000006, 0 },
diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index 4397e987a1cf..4c60eaf0571c 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -26,7 +26,7 @@
26 * exists, use it for populating initial_apicid and cpu topology 26 * exists, use it for populating initial_apicid and cpu topology
27 * detection. 27 * detection.
28 */ 28 */
29void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) 29void detect_extended_topology(struct cpuinfo_x86 *c)
30{ 30{
31#ifdef CONFIG_SMP 31#ifdef CONFIG_SMP
32 unsigned int eax, ebx, ecx, edx, sub_index; 32 unsigned int eax, ebx, ecx, edx, sub_index;
diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmeta.c
index 28000743bbb0..aa0430d69b90 100644
--- a/arch/x86/kernel/cpu/transmeta.c
+++ b/arch/x86/kernel/cpu/transmeta.c
@@ -5,7 +5,7 @@
5#include <asm/msr.h> 5#include <asm/msr.h>
6#include "cpu.h" 6#include "cpu.h"
7 7
8static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c) 8static void early_init_transmeta(struct cpuinfo_x86 *c)
9{ 9{
10 u32 xlvl; 10 u32 xlvl;
11 11
@@ -17,7 +17,7 @@ static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c)
17 } 17 }
18} 18}
19 19
20static void __cpuinit init_transmeta(struct cpuinfo_x86 *c) 20static void init_transmeta(struct cpuinfo_x86 *c)
21{ 21{
22 unsigned int cap_mask, uk, max, dummy; 22 unsigned int cap_mask, uk, max, dummy;
23 unsigned int cms_rev1, cms_rev2; 23 unsigned int cms_rev1, cms_rev2;
@@ -98,7 +98,7 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
98#endif 98#endif
99} 99}
100 100
101static const struct cpu_dev __cpuinitconst transmeta_cpu_dev = { 101static const struct cpu_dev transmeta_cpu_dev = {
102 .c_vendor = "Transmeta", 102 .c_vendor = "Transmeta",
103 .c_ident = { "GenuineTMx86", "TransmetaCPU" }, 103 .c_ident = { "GenuineTMx86", "TransmetaCPU" },
104 .c_early_init = early_init_transmeta, 104 .c_early_init = early_init_transmeta,
diff --git a/arch/x86/kernel/cpu/umc.c b/arch/x86/kernel/cpu/umc.c
index fd2c37bf7acb..202759a14121 100644
--- a/arch/x86/kernel/cpu/umc.c
+++ b/arch/x86/kernel/cpu/umc.c
@@ -8,7 +8,7 @@
8 * so no special init takes place. 8 * so no special init takes place.
9 */ 9 */
10 10
11static const struct cpu_dev __cpuinitconst umc_cpu_dev = { 11static const struct cpu_dev umc_cpu_dev = {
12 .c_vendor = "UMC", 12 .c_vendor = "UMC",
13 .c_ident = { "UMC UMC UMC" }, 13 .c_ident = { "UMC UMC UMC" },
14 .c_models = { 14 .c_models = {
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 03a36321ec54..7076878404ec 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -122,7 +122,7 @@ static bool __init vmware_platform(void)
122 * so that the kernel could just trust the hypervisor with providing a 122 * so that the kernel could just trust the hypervisor with providing a
123 * reliable virtual TSC that is suitable for timekeeping. 123 * reliable virtual TSC that is suitable for timekeeping.
124 */ 124 */
125static void __cpuinit vmware_set_cpu_features(struct cpuinfo_x86 *c) 125static void vmware_set_cpu_features(struct cpuinfo_x86 *c)
126{ 126{
127 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 127 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
128 set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE); 128 set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 1e4dbcfe6d31..7d9481c743f8 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -137,7 +137,7 @@ static const struct file_operations cpuid_fops = {
137 .open = cpuid_open, 137 .open = cpuid_open,
138}; 138};
139 139
140static __cpuinit int cpuid_device_create(int cpu) 140static int cpuid_device_create(int cpu)
141{ 141{
142 struct device *dev; 142 struct device *dev;
143 143
@@ -151,9 +151,8 @@ static void cpuid_device_destroy(int cpu)
151 device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); 151 device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
152} 152}
153 153
154static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, 154static int cpuid_class_cpu_callback(struct notifier_block *nfb,
155 unsigned long action, 155 unsigned long action, void *hcpu)
156 void *hcpu)
157{ 156{
158 unsigned int cpu = (unsigned long)hcpu; 157 unsigned int cpu = (unsigned long)hcpu;
159 int err = 0; 158 int err = 0;
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 4934890e4db2..69eb2fa25494 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -133,7 +133,7 @@ static void x86_of_pci_irq_disable(struct pci_dev *dev)
133{ 133{
134} 134}
135 135
136void __cpuinit x86_of_pci_init(void) 136void x86_of_pci_init(void)
137{ 137{
138 pcibios_enable_irq = x86_of_pci_irq_enable; 138 pcibios_enable_irq = x86_of_pci_irq_enable;
139 pcibios_disable_irq = x86_of_pci_irq_disable; 139 pcibios_disable_irq = x86_of_pci_irq_disable;
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index e65ddc62e113..5dd87a89f011 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -292,7 +292,6 @@ ENDPROC(start_cpu0)
292 * If cpu hotplug is not supported then this code can go in init section 292 * If cpu hotplug is not supported then this code can go in init section
293 * which will be freed later 293 * which will be freed later
294 */ 294 */
295__CPUINIT
296ENTRY(startup_32_smp) 295ENTRY(startup_32_smp)
297 cld 296 cld
298 movl $(__BOOT_DS),%eax 297 movl $(__BOOT_DS),%eax
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 5e4d8a8a5c40..e1aabdb314c8 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -512,21 +512,6 @@ ENTRY(phys_base)
512 512
513#include "../../x86/xen/xen-head.S" 513#include "../../x86/xen/xen-head.S"
514 514
515 .section .bss, "aw", @nobits
516 .align L1_CACHE_BYTES
517ENTRY(idt_table)
518 .skip IDT_ENTRIES * 16
519
520 .align L1_CACHE_BYTES
521ENTRY(debug_idt_table)
522 .skip IDT_ENTRIES * 16
523
524#ifdef CONFIG_TRACING
525 .align L1_CACHE_BYTES
526ENTRY(trace_idt_table)
527 .skip IDT_ENTRIES * 16
528#endif
529
530 __PAGE_ALIGNED_BSS 515 __PAGE_ALIGNED_BSS
531NEXT_PAGE(empty_zero_page) 516NEXT_PAGE(empty_zero_page)
532 .skip PAGE_SIZE 517 .skip PAGE_SIZE
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index b627746f6b1a..202d24f0f7e7 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -108,9 +108,9 @@ EXPORT_SYMBOL(unlazy_fpu);
108unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu; 108unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu;
109unsigned int xstate_size; 109unsigned int xstate_size;
110EXPORT_SYMBOL_GPL(xstate_size); 110EXPORT_SYMBOL_GPL(xstate_size);
111static struct i387_fxsave_struct fx_scratch __cpuinitdata; 111static struct i387_fxsave_struct fx_scratch;
112 112
113static void __cpuinit mxcsr_feature_mask_init(void) 113static void mxcsr_feature_mask_init(void)
114{ 114{
115 unsigned long mask = 0; 115 unsigned long mask = 0;
116 116
@@ -124,7 +124,7 @@ static void __cpuinit mxcsr_feature_mask_init(void)
124 mxcsr_feature_mask &= mask; 124 mxcsr_feature_mask &= mask;
125} 125}
126 126
127static void __cpuinit init_thread_xstate(void) 127static void init_thread_xstate(void)
128{ 128{
129 /* 129 /*
130 * Note that xstate_size might be overwriten later during 130 * Note that xstate_size might be overwriten later during
@@ -153,7 +153,7 @@ static void __cpuinit init_thread_xstate(void)
153 * into all processes. 153 * into all processes.
154 */ 154 */
155 155
156void __cpuinit fpu_init(void) 156void fpu_init(void)
157{ 157{
158 unsigned long cr0; 158 unsigned long cr0;
159 unsigned long cr4_mask = 0; 159 unsigned long cr4_mask = 0;
@@ -608,7 +608,7 @@ static int __init no_387(char *s)
608 608
609__setup("no387", no_387); 609__setup("no387", no_387);
610 610
611void __cpuinit fpu_detect(struct cpuinfo_x86 *c) 611void fpu_detect(struct cpuinfo_x86 *c)
612{ 612{
613 unsigned long cr0; 613 unsigned long cr0;
614 u16 fsw, fcw; 614 u16 fsw, fcw;
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 344faf8d0d62..4186755f1d7c 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -119,7 +119,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
119/* 119/*
120 * allocate per-cpu stacks for hardirq and for softirq processing 120 * allocate per-cpu stacks for hardirq and for softirq processing
121 */ 121 */
122void __cpuinit irq_ctx_init(int cpu) 122void irq_ctx_init(int cpu)
123{ 123{
124 union irq_ctx *irqctx; 124 union irq_ctx *irqctx;
125 125
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index cd6d9a5a42f6..a96d32cc55b8 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -320,7 +320,7 @@ static void kvm_guest_apic_eoi_write(u32 reg, u32 val)
320 apic_write(APIC_EOI, APIC_EOI_ACK); 320 apic_write(APIC_EOI, APIC_EOI_ACK);
321} 321}
322 322
323void __cpuinit kvm_guest_cpu_init(void) 323void kvm_guest_cpu_init(void)
324{ 324{
325 if (!kvm_para_available()) 325 if (!kvm_para_available())
326 return; 326 return;
@@ -421,7 +421,7 @@ static void __init kvm_smp_prepare_boot_cpu(void)
421 native_smp_prepare_boot_cpu(); 421 native_smp_prepare_boot_cpu();
422} 422}
423 423
424static void __cpuinit kvm_guest_cpu_online(void *dummy) 424static void kvm_guest_cpu_online(void *dummy)
425{ 425{
426 kvm_guest_cpu_init(); 426 kvm_guest_cpu_init();
427} 427}
@@ -435,8 +435,8 @@ static void kvm_guest_cpu_offline(void *dummy)
435 apf_task_wake_all(); 435 apf_task_wake_all();
436} 436}
437 437
438static int __cpuinit kvm_cpu_notify(struct notifier_block *self, 438static int kvm_cpu_notify(struct notifier_block *self, unsigned long action,
439 unsigned long action, void *hcpu) 439 void *hcpu)
440{ 440{
441 int cpu = (unsigned long)hcpu; 441 int cpu = (unsigned long)hcpu;
442 switch (action) { 442 switch (action) {
@@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
455 return NOTIFY_OK; 455 return NOTIFY_OK;
456} 456}
457 457
458static struct notifier_block __cpuinitdata kvm_cpu_notifier = { 458static struct notifier_block kvm_cpu_notifier = {
459 .notifier_call = kvm_cpu_notify, 459 .notifier_call = kvm_cpu_notify,
460}; 460};
461#endif 461#endif
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 1f354f4b602b..1570e0741344 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -182,7 +182,7 @@ static void kvm_restore_sched_clock_state(void)
182} 182}
183 183
184#ifdef CONFIG_X86_LOCAL_APIC 184#ifdef CONFIG_X86_LOCAL_APIC
185static void __cpuinit kvm_setup_secondary_clock(void) 185static void kvm_setup_secondary_clock(void)
186{ 186{
187 /* 187 /*
188 * Now that the first cpu already had this clocksource initialized, 188 * Now that the first cpu already had this clocksource initialized,
diff --git a/arch/x86/kernel/microcode_amd_early.c b/arch/x86/kernel/microcode_amd_early.c
index 1ac6e9aee766..1d14ffee5749 100644
--- a/arch/x86/kernel/microcode_amd_early.c
+++ b/arch/x86/kernel/microcode_amd_early.c
@@ -82,7 +82,7 @@ static struct cpio_data __init find_ucode_in_initrd(void)
82 * load_microcode_amd() to save equivalent cpu table and microcode patches in 82 * load_microcode_amd() to save equivalent cpu table and microcode patches in
83 * kernel heap memory. 83 * kernel heap memory.
84 */ 84 */
85static void __cpuinit apply_ucode_in_initrd(void *ucode, size_t size) 85static void apply_ucode_in_initrd(void *ucode, size_t size)
86{ 86{
87 struct equiv_cpu_entry *eq; 87 struct equiv_cpu_entry *eq;
88 u32 *header; 88 u32 *header;
@@ -206,7 +206,7 @@ u8 amd_bsp_mpb[MPB_MAX_SIZE];
206 * save_microcode_in_initrd_amd() BSP's patch is copied to amd_bsp_mpb, which 206 * save_microcode_in_initrd_amd() BSP's patch is copied to amd_bsp_mpb, which
207 * is used upon resume from suspend. 207 * is used upon resume from suspend.
208 */ 208 */
209void __cpuinit load_ucode_amd_ap(void) 209void load_ucode_amd_ap(void)
210{ 210{
211 struct microcode_amd *mc; 211 struct microcode_amd *mc;
212 unsigned long *initrd; 212 unsigned long *initrd;
@@ -238,7 +238,7 @@ static void __init collect_cpu_sig_on_bsp(void *arg)
238 uci->cpu_sig.sig = cpuid_eax(0x00000001); 238 uci->cpu_sig.sig = cpuid_eax(0x00000001);
239} 239}
240#else 240#else
241static void __cpuinit collect_cpu_info_amd_early(struct cpuinfo_x86 *c, 241static void collect_cpu_info_amd_early(struct cpuinfo_x86 *c,
242 struct ucode_cpu_info *uci) 242 struct ucode_cpu_info *uci)
243{ 243{
244 u32 rev, eax; 244 u32 rev, eax;
@@ -252,7 +252,7 @@ static void __cpuinit collect_cpu_info_amd_early(struct cpuinfo_x86 *c,
252 c->x86 = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); 252 c->x86 = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
253} 253}
254 254
255void __cpuinit load_ucode_amd_ap(void) 255void load_ucode_amd_ap(void)
256{ 256{
257 unsigned int cpu = smp_processor_id(); 257 unsigned int cpu = smp_processor_id();
258 258
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index 22db92bbdf1a..15c987698b0f 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -468,7 +468,7 @@ static struct syscore_ops mc_syscore_ops = {
468 .resume = mc_bp_resume, 468 .resume = mc_bp_resume,
469}; 469};
470 470
471static __cpuinit int 471static int
472mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 472mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
473{ 473{
474 unsigned int cpu = (unsigned long)hcpu; 474 unsigned int cpu = (unsigned long)hcpu;
diff --git a/arch/x86/kernel/microcode_core_early.c b/arch/x86/kernel/microcode_core_early.c
index 86119f63db0c..be7f8514f577 100644
--- a/arch/x86/kernel/microcode_core_early.c
+++ b/arch/x86/kernel/microcode_core_early.c
@@ -41,7 +41,7 @@
41 * 41 *
42 * x86_vendor() gets vendor information directly through cpuid. 42 * x86_vendor() gets vendor information directly through cpuid.
43 */ 43 */
44static int __cpuinit x86_vendor(void) 44static int x86_vendor(void)
45{ 45{
46 u32 eax = 0x00000000; 46 u32 eax = 0x00000000;
47 u32 ebx, ecx = 0, edx; 47 u32 ebx, ecx = 0, edx;
@@ -57,7 +57,7 @@ static int __cpuinit x86_vendor(void)
57 return X86_VENDOR_UNKNOWN; 57 return X86_VENDOR_UNKNOWN;
58} 58}
59 59
60static int __cpuinit x86_family(void) 60static int x86_family(void)
61{ 61{
62 u32 eax = 0x00000001; 62 u32 eax = 0x00000001;
63 u32 ebx, ecx = 0, edx; 63 u32 ebx, ecx = 0, edx;
@@ -96,7 +96,7 @@ void __init load_ucode_bsp(void)
96 } 96 }
97} 97}
98 98
99void __cpuinit load_ucode_ap(void) 99void load_ucode_ap(void)
100{ 100{
101 int vendor, x86; 101 int vendor, x86;
102 102
diff --git a/arch/x86/kernel/microcode_intel_early.c b/arch/x86/kernel/microcode_intel_early.c
index dabef95506f3..1575deb2e636 100644
--- a/arch/x86/kernel/microcode_intel_early.c
+++ b/arch/x86/kernel/microcode_intel_early.c
@@ -34,7 +34,7 @@ struct mc_saved_data {
34 struct microcode_intel **mc_saved; 34 struct microcode_intel **mc_saved;
35} mc_saved_data; 35} mc_saved_data;
36 36
37static enum ucode_state __cpuinit 37static enum ucode_state
38generic_load_microcode_early(struct microcode_intel **mc_saved_p, 38generic_load_microcode_early(struct microcode_intel **mc_saved_p,
39 unsigned int mc_saved_count, 39 unsigned int mc_saved_count,
40 struct ucode_cpu_info *uci) 40 struct ucode_cpu_info *uci)
@@ -69,7 +69,7 @@ out:
69 return state; 69 return state;
70} 70}
71 71
72static void __cpuinit 72static void
73microcode_pointer(struct microcode_intel **mc_saved, 73microcode_pointer(struct microcode_intel **mc_saved,
74 unsigned long *mc_saved_in_initrd, 74 unsigned long *mc_saved_in_initrd,
75 unsigned long initrd_start, int mc_saved_count) 75 unsigned long initrd_start, int mc_saved_count)
@@ -82,7 +82,7 @@ microcode_pointer(struct microcode_intel **mc_saved,
82} 82}
83 83
84#ifdef CONFIG_X86_32 84#ifdef CONFIG_X86_32
85static void __cpuinit 85static void
86microcode_phys(struct microcode_intel **mc_saved_tmp, 86microcode_phys(struct microcode_intel **mc_saved_tmp,
87 struct mc_saved_data *mc_saved_data) 87 struct mc_saved_data *mc_saved_data)
88{ 88{
@@ -101,7 +101,7 @@ microcode_phys(struct microcode_intel **mc_saved_tmp,
101} 101}
102#endif 102#endif
103 103
104static enum ucode_state __cpuinit 104static enum ucode_state
105load_microcode(struct mc_saved_data *mc_saved_data, 105load_microcode(struct mc_saved_data *mc_saved_data,
106 unsigned long *mc_saved_in_initrd, 106 unsigned long *mc_saved_in_initrd,
107 unsigned long initrd_start, 107 unsigned long initrd_start,
@@ -375,7 +375,7 @@ do { \
375#define native_wrmsr(msr, low, high) \ 375#define native_wrmsr(msr, low, high) \
376 native_write_msr(msr, low, high); 376 native_write_msr(msr, low, high);
377 377
378static int __cpuinit collect_cpu_info_early(struct ucode_cpu_info *uci) 378static int collect_cpu_info_early(struct ucode_cpu_info *uci)
379{ 379{
380 unsigned int val[2]; 380 unsigned int val[2];
381 u8 x86, x86_model; 381 u8 x86, x86_model;
@@ -584,7 +584,7 @@ scan_microcode(unsigned long start, unsigned long end,
584/* 584/*
585 * Print ucode update info. 585 * Print ucode update info.
586 */ 586 */
587static void __cpuinit 587static void
588print_ucode_info(struct ucode_cpu_info *uci, unsigned int date) 588print_ucode_info(struct ucode_cpu_info *uci, unsigned int date)
589{ 589{
590 int cpu = smp_processor_id(); 590 int cpu = smp_processor_id();
@@ -605,7 +605,7 @@ static int current_mc_date;
605/* 605/*
606 * Print early updated ucode info after printk works. This is delayed info dump. 606 * Print early updated ucode info after printk works. This is delayed info dump.
607 */ 607 */
608void __cpuinit show_ucode_info_early(void) 608void show_ucode_info_early(void)
609{ 609{
610 struct ucode_cpu_info uci; 610 struct ucode_cpu_info uci;
611 611
@@ -621,7 +621,7 @@ void __cpuinit show_ucode_info_early(void)
621 * mc_saved_data.mc_saved and delay printing microcode info in 621 * mc_saved_data.mc_saved and delay printing microcode info in
622 * show_ucode_info_early() until printk() works. 622 * show_ucode_info_early() until printk() works.
623 */ 623 */
624static void __cpuinit print_ucode(struct ucode_cpu_info *uci) 624static void print_ucode(struct ucode_cpu_info *uci)
625{ 625{
626 struct microcode_intel *mc_intel; 626 struct microcode_intel *mc_intel;
627 int *delay_ucode_info_p; 627 int *delay_ucode_info_p;
@@ -643,12 +643,12 @@ static void __cpuinit print_ucode(struct ucode_cpu_info *uci)
643 * Flush global tlb. We only do this in x86_64 where paging has been enabled 643 * Flush global tlb. We only do this in x86_64 where paging has been enabled
644 * already and PGE should be enabled as well. 644 * already and PGE should be enabled as well.
645 */ 645 */
646static inline void __cpuinit flush_tlb_early(void) 646static inline void flush_tlb_early(void)
647{ 647{
648 __native_flush_tlb_global_irq_disabled(); 648 __native_flush_tlb_global_irq_disabled();
649} 649}
650 650
651static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci) 651static inline void print_ucode(struct ucode_cpu_info *uci)
652{ 652{
653 struct microcode_intel *mc_intel; 653 struct microcode_intel *mc_intel;
654 654
@@ -660,8 +660,8 @@ static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci)
660} 660}
661#endif 661#endif
662 662
663static int __cpuinit apply_microcode_early(struct mc_saved_data *mc_saved_data, 663static int apply_microcode_early(struct mc_saved_data *mc_saved_data,
664 struct ucode_cpu_info *uci) 664 struct ucode_cpu_info *uci)
665{ 665{
666 struct microcode_intel *mc_intel; 666 struct microcode_intel *mc_intel;
667 unsigned int val[2]; 667 unsigned int val[2];
@@ -763,7 +763,7 @@ load_ucode_intel_bsp(void)
763#endif 763#endif
764} 764}
765 765
766void __cpuinit load_ucode_intel_ap(void) 766void load_ucode_intel_ap(void)
767{ 767{
768 struct mc_saved_data *mc_saved_data_p; 768 struct mc_saved_data *mc_saved_data_p;
769 struct ucode_cpu_info uci; 769 struct ucode_cpu_info uci;
diff --git a/arch/x86/kernel/mmconf-fam10h_64.c b/arch/x86/kernel/mmconf-fam10h_64.c
index ac861b8348e2..f4c886d9165c 100644
--- a/arch/x86/kernel/mmconf-fam10h_64.c
+++ b/arch/x86/kernel/mmconf-fam10h_64.c
@@ -24,14 +24,14 @@ struct pci_hostbridge_probe {
24 u32 device; 24 u32 device;
25}; 25};
26 26
27static u64 __cpuinitdata fam10h_pci_mmconf_base; 27static u64 fam10h_pci_mmconf_base;
28 28
29static struct pci_hostbridge_probe pci_probes[] __cpuinitdata = { 29static struct pci_hostbridge_probe pci_probes[] = {
30 { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 }, 30 { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 },
31 { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 }, 31 { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 },
32}; 32};
33 33
34static int __cpuinit cmp_range(const void *x1, const void *x2) 34static int cmp_range(const void *x1, const void *x2)
35{ 35{
36 const struct range *r1 = x1; 36 const struct range *r1 = x1;
37 const struct range *r2 = x2; 37 const struct range *r2 = x2;
@@ -49,7 +49,7 @@ static int __cpuinit cmp_range(const void *x1, const void *x2)
49/* need to avoid (0xfd<<32), (0xfe<<32), and (0xff<<32), ht used space */ 49/* need to avoid (0xfd<<32), (0xfe<<32), and (0xff<<32), ht used space */
50#define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32) 50#define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32)
51#define BASE_VALID(b) ((b) + MMCONF_SIZE <= (0xfdULL<<32) || (b) >= (1ULL<<40)) 51#define BASE_VALID(b) ((b) + MMCONF_SIZE <= (0xfdULL<<32) || (b) >= (1ULL<<40))
52static void __cpuinit get_fam10h_pci_mmconf_base(void) 52static void get_fam10h_pci_mmconf_base(void)
53{ 53{
54 int i; 54 int i;
55 unsigned bus; 55 unsigned bus;
@@ -166,7 +166,7 @@ out:
166 fam10h_pci_mmconf_base = base; 166 fam10h_pci_mmconf_base = base;
167} 167}
168 168
169void __cpuinit fam10h_check_enable_mmcfg(void) 169void fam10h_check_enable_mmcfg(void)
170{ 170{
171 u64 val; 171 u64 val;
172 u32 address; 172 u32 address;
@@ -230,7 +230,7 @@ static const struct dmi_system_id __initconst mmconf_dmi_table[] = {
230 {} 230 {}
231}; 231};
232 232
233/* Called from a __cpuinit function, but only on the BSP. */ 233/* Called from a non __init function, but only on the BSP. */
234void __ref check_enable_amd_mmconf_dmi(void) 234void __ref check_enable_amd_mmconf_dmi(void)
235{ 235{
236 dmi_check_system(mmconf_dmi_table); 236 dmi_check_system(mmconf_dmi_table);
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index ce130493b802..88458faea2f8 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -200,7 +200,7 @@ static const struct file_operations msr_fops = {
200 .compat_ioctl = msr_ioctl, 200 .compat_ioctl = msr_ioctl,
201}; 201};
202 202
203static int __cpuinit msr_device_create(int cpu) 203static int msr_device_create(int cpu)
204{ 204{
205 struct device *dev; 205 struct device *dev;
206 206
@@ -214,8 +214,8 @@ static void msr_device_destroy(int cpu)
214 device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); 214 device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
215} 215}
216 216
217static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb, 217static int msr_class_cpu_callback(struct notifier_block *nfb,
218 unsigned long action, void *hcpu) 218 unsigned long action, void *hcpu)
219{ 219{
220 unsigned int cpu = (unsigned long)hcpu; 220 unsigned int cpu = (unsigned long)hcpu;
221 int err = 0; 221 int err = 0;
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 81a5f5e8f142..83369e5a1d27 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -398,7 +398,7 @@ static void amd_e400_idle(void)
398 default_idle(); 398 default_idle();
399} 399}
400 400
401void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 401void select_idle_routine(const struct cpuinfo_x86 *c)
402{ 402{
403#ifdef CONFIG_SMP 403#ifdef CONFIG_SMP
404 if (boot_option_idle_override == IDLE_POLL && smp_num_siblings > 1) 404 if (boot_option_idle_override == IDLE_POLL && smp_num_siblings > 1)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index e68709da8251..f8ec57815c05 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -170,7 +170,7 @@ static struct resource bss_resource = {
170 170
171#ifdef CONFIG_X86_32 171#ifdef CONFIG_X86_32
172/* cpu data as detected by the assembly code in head.S */ 172/* cpu data as detected by the assembly code in head.S */
173struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 173struct cpuinfo_x86 new_cpu_data = {
174 .wp_works_ok = -1, 174 .wp_works_ok = -1,
175}; 175};
176/* common cpu data for all cpus */ 176/* common cpu data for all cpus */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index bfd348e99369..aecc98a93d1b 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -130,7 +130,7 @@ atomic_t init_deasserted;
130 * Report back to the Boot Processor during boot time or to the caller processor 130 * Report back to the Boot Processor during boot time or to the caller processor
131 * during CPU online. 131 * during CPU online.
132 */ 132 */
133static void __cpuinit smp_callin(void) 133static void smp_callin(void)
134{ 134{
135 int cpuid, phys_id; 135 int cpuid, phys_id;
136 unsigned long timeout; 136 unsigned long timeout;
@@ -237,7 +237,7 @@ static int enable_start_cpu0;
237/* 237/*
238 * Activate a secondary processor. 238 * Activate a secondary processor.
239 */ 239 */
240notrace static void __cpuinit start_secondary(void *unused) 240static void notrace start_secondary(void *unused)
241{ 241{
242 /* 242 /*
243 * Don't put *anything* before cpu_init(), SMP booting is too 243 * Don't put *anything* before cpu_init(), SMP booting is too
@@ -300,7 +300,7 @@ void __init smp_store_boot_cpu_info(void)
300 * The bootstrap kernel entry code has set these up. Save them for 300 * The bootstrap kernel entry code has set these up. Save them for
301 * a given CPU 301 * a given CPU
302 */ 302 */
303void __cpuinit smp_store_cpu_info(int id) 303void smp_store_cpu_info(int id)
304{ 304{
305 struct cpuinfo_x86 *c = &cpu_data(id); 305 struct cpuinfo_x86 *c = &cpu_data(id);
306 306
@@ -313,7 +313,7 @@ void __cpuinit smp_store_cpu_info(int id)
313 identify_secondary_cpu(c); 313 identify_secondary_cpu(c);
314} 314}
315 315
316static bool __cpuinit 316static bool
317topology_sane(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o, const char *name) 317topology_sane(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o, const char *name)
318{ 318{
319 int cpu1 = c->cpu_index, cpu2 = o->cpu_index; 319 int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
@@ -330,7 +330,7 @@ do { \
330 cpumask_set_cpu((c2), cpu_##_m##_mask(c1)); \ 330 cpumask_set_cpu((c2), cpu_##_m##_mask(c1)); \
331} while (0) 331} while (0)
332 332
333static bool __cpuinit match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) 333static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
334{ 334{
335 if (cpu_has_topoext) { 335 if (cpu_has_topoext) {
336 int cpu1 = c->cpu_index, cpu2 = o->cpu_index; 336 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)
348 return false; 348 return false;
349} 349}
350 350
351static bool __cpuinit match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) 351static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
352{ 352{
353 int cpu1 = c->cpu_index, cpu2 = o->cpu_index; 353 int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
354 354
@@ -359,7 +359,7 @@ static bool __cpuinit match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
359 return false; 359 return false;
360} 360}
361 361
362static bool __cpuinit match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) 362static bool match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
363{ 363{
364 if (c->phys_proc_id == o->phys_proc_id) { 364 if (c->phys_proc_id == o->phys_proc_id) {
365 if (cpu_has(c, X86_FEATURE_AMD_DCM)) 365 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)
370 return false; 370 return false;
371} 371}
372 372
373void __cpuinit set_cpu_sibling_map(int cpu) 373void set_cpu_sibling_map(int cpu)
374{ 374{
375 bool has_smt = smp_num_siblings > 1; 375 bool has_smt = smp_num_siblings > 1;
376 bool has_mp = has_smt || boot_cpu_data.x86_max_cores > 1; 376 bool has_mp = has_smt || boot_cpu_data.x86_max_cores > 1;
@@ -499,7 +499,7 @@ void __inquire_remote_apic(int apicid)
499 * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this 499 * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this
500 * won't ... remember to clear down the APIC, etc later. 500 * won't ... remember to clear down the APIC, etc later.
501 */ 501 */
502int __cpuinit 502int
503wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip) 503wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
504{ 504{
505 unsigned long send_status, accept_status = 0; 505 unsigned long send_status, accept_status = 0;
@@ -533,7 +533,7 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
533 return (send_status | accept_status); 533 return (send_status | accept_status);
534} 534}
535 535
536static int __cpuinit 536static int
537wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) 537wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
538{ 538{
539 unsigned long send_status, accept_status = 0; 539 unsigned long send_status, accept_status = 0;
@@ -649,7 +649,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
649} 649}
650 650
651/* reduce the number of lines printed when booting a large cpu count system */ 651/* reduce the number of lines printed when booting a large cpu count system */
652static void __cpuinit announce_cpu(int cpu, int apicid) 652static void announce_cpu(int cpu, int apicid)
653{ 653{
654 static int current_node = -1; 654 static int current_node = -1;
655 int node = early_cpu_to_node(cpu); 655 int node = early_cpu_to_node(cpu);
@@ -691,7 +691,7 @@ static int wakeup_cpu0_nmi(unsigned int cmd, struct pt_regs *regs)
691 * We'll change this code in the future to wake up hard offlined CPU0 if 691 * We'll change this code in the future to wake up hard offlined CPU0 if
692 * real platform and request are available. 692 * real platform and request are available.
693 */ 693 */
694static int __cpuinit 694static int
695wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid, 695wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid,
696 int *cpu0_nmi_registered) 696 int *cpu0_nmi_registered)
697{ 697{
@@ -731,7 +731,7 @@ wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid,
731 * Returns zero if CPU booted OK, else error code from 731 * Returns zero if CPU booted OK, else error code from
732 * ->wakeup_secondary_cpu. 732 * ->wakeup_secondary_cpu.
733 */ 733 */
734static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle) 734static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
735{ 735{
736 volatile u32 *trampoline_status = 736 volatile u32 *trampoline_status =
737 (volatile u32 *) __va(real_mode_header->trampoline_status); 737 (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)
872 return boot_error; 872 return boot_error;
873} 873}
874 874
875int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle) 875int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
876{ 876{
877 int apicid = apic->cpu_present_to_apicid(cpu); 877 int apicid = apic->cpu_present_to_apicid(cpu);
878 unsigned long flags; 878 unsigned long flags;
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index 3ff42d2f046d..addf7b58f4e8 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -320,8 +320,8 @@ static int tboot_wait_for_aps(int num_aps)
320 return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps); 320 return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
321} 321}
322 322
323static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb, 323static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
324 unsigned long action, void *hcpu) 324 void *hcpu)
325{ 325{
326 switch (action) { 326 switch (action) {
327 case CPU_DYING: 327 case CPU_DYING:
@@ -334,7 +334,7 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
334 return NOTIFY_OK; 334 return NOTIFY_OK;
335} 335}
336 336
337static struct notifier_block tboot_cpu_notifier __cpuinitdata = 337static struct notifier_block tboot_cpu_notifier =
338{ 338{
339 .notifier_call = tboot_cpu_callback, 339 .notifier_call = tboot_cpu_callback,
340}; 340};
diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
index 4e584a8d6edd..1c113db9ed57 100644
--- a/arch/x86/kernel/tracepoint.c
+++ b/arch/x86/kernel/tracepoint.c
@@ -12,10 +12,8 @@ atomic_t trace_idt_ctr = ATOMIC_INIT(0);
12struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1, 12struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
13 (unsigned long) trace_idt_table }; 13 (unsigned long) trace_idt_table };
14 14
15#ifndef CONFIG_X86_64 15/* No need to be aligned, but done to keep all IDTs defined the same way. */
16gate_desc trace_idt_table[NR_VECTORS] __page_aligned_data 16gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
17 = { { { { 0, 0 } } }, };
18#endif
19 17
20static int trace_irq_vector_refcount; 18static int trace_irq_vector_refcount;
21static DEFINE_MUTEX(irq_vector_mutex); 19static DEFINE_MUTEX(irq_vector_mutex);
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index b0865e88d3cc..1b23a1c92746 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -63,19 +63,19 @@
63#include <asm/x86_init.h> 63#include <asm/x86_init.h>
64#include <asm/pgalloc.h> 64#include <asm/pgalloc.h>
65#include <asm/proto.h> 65#include <asm/proto.h>
66
67/* No need to be aligned, but done to keep all IDTs defined the same way. */
68gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
66#else 69#else
67#include <asm/processor-flags.h> 70#include <asm/processor-flags.h>
68#include <asm/setup.h> 71#include <asm/setup.h>
69 72
70asmlinkage int system_call(void); 73asmlinkage int system_call(void);
71
72/*
73 * The IDT has to be page-aligned to simplify the Pentium
74 * F0 0F bug workaround.
75 */
76gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
77#endif 74#endif
78 75
76/* Must be page-aligned because the real IDT is used in a fixmap. */
77gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
78
79DECLARE_BITMAP(used_vectors, NR_VECTORS); 79DECLARE_BITMAP(used_vectors, NR_VECTORS);
80EXPORT_SYMBOL_GPL(used_vectors); 80EXPORT_SYMBOL_GPL(used_vectors);
81 81
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 098b3cfda72e..6ff49247edf8 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -824,7 +824,7 @@ static void __init check_system_tsc_reliable(void)
824 * Make an educated guess if the TSC is trustworthy and synchronized 824 * Make an educated guess if the TSC is trustworthy and synchronized
825 * over all CPUs. 825 * over all CPUs.
826 */ 826 */
827__cpuinit int unsynchronized_tsc(void) 827int unsynchronized_tsc(void)
828{ 828{
829 if (!cpu_has_tsc || tsc_unstable) 829 if (!cpu_has_tsc || tsc_unstable)
830 return 1; 830 return 1;
@@ -1020,7 +1020,7 @@ void __init tsc_init(void)
1020 * been calibrated. This assumes that CONSTANT_TSC applies to all 1020 * been calibrated. This assumes that CONSTANT_TSC applies to all
1021 * cpus in the socket - this should be a safe assumption. 1021 * cpus in the socket - this should be a safe assumption.
1022 */ 1022 */
1023unsigned long __cpuinit calibrate_delay_is_known(void) 1023unsigned long calibrate_delay_is_known(void)
1024{ 1024{
1025 int i, cpu = smp_processor_id(); 1025 int i, cpu = smp_processor_id();
1026 1026
diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
index fc25e60a5884..adfdf56a3714 100644
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -25,24 +25,24 @@
25 * Entry/exit counters that make sure that both CPUs 25 * Entry/exit counters that make sure that both CPUs
26 * run the measurement code at once: 26 * run the measurement code at once:
27 */ 27 */
28static __cpuinitdata atomic_t start_count; 28static atomic_t start_count;
29static __cpuinitdata atomic_t stop_count; 29static atomic_t stop_count;
30 30
31/* 31/*
32 * We use a raw spinlock in this exceptional case, because 32 * We use a raw spinlock in this exceptional case, because
33 * we want to have the fastest, inlined, non-debug version 33 * we want to have the fastest, inlined, non-debug version
34 * of a critical section, to be able to prove TSC time-warps: 34 * of a critical section, to be able to prove TSC time-warps:
35 */ 35 */
36static __cpuinitdata arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED; 36static arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED;
37 37
38static __cpuinitdata cycles_t last_tsc; 38static cycles_t last_tsc;
39static __cpuinitdata cycles_t max_warp; 39static cycles_t max_warp;
40static __cpuinitdata int nr_warps; 40static int nr_warps;
41 41
42/* 42/*
43 * TSC-warp measurement loop running on both CPUs: 43 * TSC-warp measurement loop running on both CPUs:
44 */ 44 */
45static __cpuinit void check_tsc_warp(unsigned int timeout) 45static void check_tsc_warp(unsigned int timeout)
46{ 46{
47 cycles_t start, now, prev, end; 47 cycles_t start, now, prev, end;
48 int i; 48 int i;
@@ -121,7 +121,7 @@ static inline unsigned int loop_timeout(int cpu)
121 * Source CPU calls into this - it waits for the freshly booted 121 * Source CPU calls into this - it waits for the freshly booted
122 * target CPU to arrive and then starts the measurement: 122 * target CPU to arrive and then starts the measurement:
123 */ 123 */
124void __cpuinit check_tsc_sync_source(int cpu) 124void check_tsc_sync_source(int cpu)
125{ 125{
126 int cpus = 2; 126 int cpus = 2;
127 127
@@ -187,7 +187,7 @@ void __cpuinit check_tsc_sync_source(int cpu)
187/* 187/*
188 * Freshly booted CPUs call into this: 188 * Freshly booted CPUs call into this:
189 */ 189 */
190void __cpuinit check_tsc_sync_target(void) 190void check_tsc_sync_target(void)
191{ 191{
192 int cpus = 2; 192 int cpus = 2;
193 193
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 9a907a67be8f..1f96f9347ed9 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -331,7 +331,7 @@ sigsegv:
331 * Assume __initcall executes before all user space. Hopefully kmod 331 * Assume __initcall executes before all user space. Hopefully kmod
332 * doesn't violate that. We'll find out if it does. 332 * doesn't violate that. We'll find out if it does.
333 */ 333 */
334static void __cpuinit vsyscall_set_cpu(int cpu) 334static void vsyscall_set_cpu(int cpu)
335{ 335{
336 unsigned long d; 336 unsigned long d;
337 unsigned long node = 0; 337 unsigned long node = 0;
@@ -353,13 +353,13 @@ static void __cpuinit vsyscall_set_cpu(int cpu)
353 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_PER_CPU, &d, DESCTYPE_S); 353 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_PER_CPU, &d, DESCTYPE_S);
354} 354}
355 355
356static void __cpuinit cpu_vsyscall_init(void *arg) 356static void cpu_vsyscall_init(void *arg)
357{ 357{
358 /* preemption should be already off */ 358 /* preemption should be already off */
359 vsyscall_set_cpu(raw_smp_processor_id()); 359 vsyscall_set_cpu(raw_smp_processor_id());
360} 360}
361 361
362static int __cpuinit 362static int
363cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg) 363cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
364{ 364{
365 long cpu = (long)arg; 365 long cpu = (long)arg;
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 45a14dbbddaf..5f24c71accaa 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -25,7 +25,7 @@
25#include <asm/iommu.h> 25#include <asm/iommu.h>
26#include <asm/mach_traps.h> 26#include <asm/mach_traps.h>
27 27
28void __cpuinit x86_init_noop(void) { } 28void x86_init_noop(void) { }
29void __init x86_init_uint_noop(unsigned int unused) { } 29void __init x86_init_uint_noop(unsigned int unused) { }
30int __init iommu_init_noop(void) { return 0; } 30int __init iommu_init_noop(void) { return 0; }
31void iommu_shutdown_noop(void) { } 31void iommu_shutdown_noop(void) { }
@@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
85 }, 85 },
86}; 86};
87 87
88struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = { 88struct x86_cpuinit_ops x86_cpuinit = {
89 .early_percpu_clock_init = x86_init_noop, 89 .early_percpu_clock_init = x86_init_noop,
90 .setup_percpu_clockev = setup_secondary_APIC_clock, 90 .setup_percpu_clockev = setup_secondary_APIC_clock,
91}; 91};
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index d6c28acdf99c..422fd8223470 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -573,7 +573,7 @@ static void __init xstate_enable_boot_cpu(void)
573 * This is somewhat obfuscated due to the lack of powerful enough 573 * This is somewhat obfuscated due to the lack of powerful enough
574 * overrides for the section checks. 574 * overrides for the section checks.
575 */ 575 */
576void __cpuinit xsave_init(void) 576void xsave_init(void)
577{ 577{
578 static __refdata void (*next_func)(void) = xstate_enable_boot_cpu; 578 static __refdata void (*next_func)(void) = xstate_enable_boot_cpu;
579 void (*this_func)(void); 579 void (*this_func)(void);
@@ -594,7 +594,7 @@ static inline void __init eager_fpu_init_bp(void)
594 setup_init_fpu_buf(); 594 setup_init_fpu_buf();
595} 595}
596 596
597void __cpuinit eager_fpu_init(void) 597void eager_fpu_init(void)
598{ 598{
599 static __refdata void (*boot_func)(void) = eager_fpu_init_bp; 599 static __refdata void (*boot_func)(void) = eager_fpu_init_bp;
600 600
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 0d094da49541..9e9285ae9b94 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2811,6 +2811,13 @@ exit:
2811static bool page_fault_can_be_fast(struct kvm_vcpu *vcpu, u32 error_code) 2811static bool page_fault_can_be_fast(struct kvm_vcpu *vcpu, u32 error_code)
2812{ 2812{
2813 /* 2813 /*
2814 * Do not fix the mmio spte with invalid generation number which
2815 * need to be updated by slow page fault path.
2816 */
2817 if (unlikely(error_code & PFERR_RSVD_MASK))
2818 return false;
2819
2820 /*
2814 * #PF can be fast only if the shadow page table is present and it 2821 * #PF can be fast only if the shadow page table is present and it
2815 * is caused by write-protect, that means we just need change the 2822 * is caused by write-protect, that means we just need change the
2816 * W bit of the spte which can be done out of mmu-lock. 2823 * W bit of the spte which can be done out of mmu-lock.
diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
index dc0b727742f4..0057a7accfb1 100644
--- a/arch/x86/mm/mmio-mod.c
+++ b/arch/x86/mm/mmio-mod.c
@@ -410,9 +410,7 @@ out:
410 pr_warning("multiple CPUs still online, may miss events.\n"); 410 pr_warning("multiple CPUs still online, may miss events.\n");
411} 411}
412 412
413/* __ref because leave_uniprocessor calls cpu_up which is __cpuinit, 413static void leave_uniprocessor(void)
414 but this whole function is ifdefed CONFIG_HOTPLUG_CPU */
415static void __ref leave_uniprocessor(void)
416{ 414{
417 int cpu; 415 int cpu;
418 int err; 416 int err;
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index a71c4e207679..8bf93bae1f13 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -60,7 +60,7 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] = {
60 [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE 60 [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
61}; 61};
62 62
63int __cpuinit numa_cpu_node(int cpu) 63int numa_cpu_node(int cpu)
64{ 64{
65 int apicid = early_per_cpu(x86_cpu_to_apicid, cpu); 65 int apicid = early_per_cpu(x86_cpu_to_apicid, cpu);
66 66
@@ -691,12 +691,12 @@ void __init init_cpu_to_node(void)
691#ifndef CONFIG_DEBUG_PER_CPU_MAPS 691#ifndef CONFIG_DEBUG_PER_CPU_MAPS
692 692
693# ifndef CONFIG_NUMA_EMU 693# ifndef CONFIG_NUMA_EMU
694void __cpuinit numa_add_cpu(int cpu) 694void numa_add_cpu(int cpu)
695{ 695{
696 cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 696 cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);
697} 697}
698 698
699void __cpuinit numa_remove_cpu(int cpu) 699void numa_remove_cpu(int cpu)
700{ 700{
701 cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 701 cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);
702} 702}
@@ -763,17 +763,17 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)
763} 763}
764 764
765# ifndef CONFIG_NUMA_EMU 765# ifndef CONFIG_NUMA_EMU
766static void __cpuinit numa_set_cpumask(int cpu, bool enable) 766static void numa_set_cpumask(int cpu, bool enable)
767{ 767{
768 debug_cpumask_set_cpu(cpu, early_cpu_to_node(cpu), enable); 768 debug_cpumask_set_cpu(cpu, early_cpu_to_node(cpu), enable);
769} 769}
770 770
771void __cpuinit numa_add_cpu(int cpu) 771void numa_add_cpu(int cpu)
772{ 772{
773 numa_set_cpumask(cpu, true); 773 numa_set_cpumask(cpu, true);
774} 774}
775 775
776void __cpuinit numa_remove_cpu(int cpu) 776void numa_remove_cpu(int cpu)
777{ 777{
778 numa_set_cpumask(cpu, false); 778 numa_set_cpumask(cpu, false);
779} 779}
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index dbbbb47260cc..a8f90ce3dedf 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -10,7 +10,7 @@
10 10
11#include "numa_internal.h" 11#include "numa_internal.h"
12 12
13static int emu_nid_to_phys[MAX_NUMNODES] __cpuinitdata; 13static int emu_nid_to_phys[MAX_NUMNODES];
14static char *emu_cmdline __initdata; 14static char *emu_cmdline __initdata;
15 15
16void __init numa_emu_cmdline(char *str) 16void __init numa_emu_cmdline(char *str)
@@ -444,7 +444,7 @@ no_emu:
444} 444}
445 445
446#ifndef CONFIG_DEBUG_PER_CPU_MAPS 446#ifndef CONFIG_DEBUG_PER_CPU_MAPS
447void __cpuinit numa_add_cpu(int cpu) 447void numa_add_cpu(int cpu)
448{ 448{
449 int physnid, nid; 449 int physnid, nid;
450 450
@@ -462,7 +462,7 @@ void __cpuinit numa_add_cpu(int cpu)
462 cpumask_set_cpu(cpu, node_to_cpumask_map[nid]); 462 cpumask_set_cpu(cpu, node_to_cpumask_map[nid]);
463} 463}
464 464
465void __cpuinit numa_remove_cpu(int cpu) 465void numa_remove_cpu(int cpu)
466{ 466{
467 int i; 467 int i;
468 468
@@ -470,7 +470,7 @@ void __cpuinit numa_remove_cpu(int cpu)
470 cpumask_clear_cpu(cpu, node_to_cpumask_map[i]); 470 cpumask_clear_cpu(cpu, node_to_cpumask_map[i]);
471} 471}
472#else /* !CONFIG_DEBUG_PER_CPU_MAPS */ 472#else /* !CONFIG_DEBUG_PER_CPU_MAPS */
473static void __cpuinit numa_set_cpumask(int cpu, bool enable) 473static void numa_set_cpumask(int cpu, bool enable)
474{ 474{
475 int nid, physnid; 475 int nid, physnid;
476 476
@@ -490,12 +490,12 @@ static void __cpuinit numa_set_cpumask(int cpu, bool enable)
490 } 490 }
491} 491}
492 492
493void __cpuinit numa_add_cpu(int cpu) 493void numa_add_cpu(int cpu)
494{ 494{
495 numa_set_cpumask(cpu, true); 495 numa_set_cpumask(cpu, true);
496} 496}
497 497
498void __cpuinit numa_remove_cpu(int cpu) 498void numa_remove_cpu(int cpu)
499{ 499{
500 numa_set_cpumask(cpu, false); 500 numa_set_cpumask(cpu, false);
501} 501}
diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
index 410531d3c292..90555bf60aa4 100644
--- a/arch/x86/mm/setup_nx.c
+++ b/arch/x86/mm/setup_nx.c
@@ -5,7 +5,7 @@
5#include <asm/pgtable.h> 5#include <asm/pgtable.h>
6#include <asm/proto.h> 6#include <asm/proto.h>
7 7
8static int disable_nx __cpuinitdata; 8static int disable_nx;
9 9
10/* 10/*
11 * noexec = on|off 11 * noexec = on|off
@@ -29,7 +29,7 @@ static int __init noexec_setup(char *str)
29} 29}
30early_param("noexec", noexec_setup); 30early_param("noexec", noexec_setup);
31 31
32void __cpuinit x86_configure_nx(void) 32void x86_configure_nx(void)
33{ 33{
34 if (cpu_has_nx && !disable_nx) 34 if (cpu_has_nx && !disable_nx)
35 __supported_pte_mask |= _PAGE_NX; 35 __supported_pte_mask |= _PAGE_NX;
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index e9e6ed5cdf94..a48be98e9ded 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -312,7 +312,7 @@ static int __init early_fill_mp_bus_info(void)
312 312
313#define ENABLE_CF8_EXT_CFG (1ULL << 46) 313#define ENABLE_CF8_EXT_CFG (1ULL << 46)
314 314
315static void __cpuinit enable_pci_io_ecs(void *unused) 315static void enable_pci_io_ecs(void *unused)
316{ 316{
317 u64 reg; 317 u64 reg;
318 rdmsrl(MSR_AMD64_NB_CFG, reg); 318 rdmsrl(MSR_AMD64_NB_CFG, reg);
@@ -322,8 +322,8 @@ static void __cpuinit enable_pci_io_ecs(void *unused)
322 } 322 }
323} 323}
324 324
325static int __cpuinit amd_cpu_notify(struct notifier_block *self, 325static int amd_cpu_notify(struct notifier_block *self, unsigned long action,
326 unsigned long action, void *hcpu) 326 void *hcpu)
327{ 327{
328 int cpu = (long)hcpu; 328 int cpu = (long)hcpu;
329 switch (action) { 329 switch (action) {
@@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
337 return NOTIFY_OK; 337 return NOTIFY_OK;
338} 338}
339 339
340static struct notifier_block __cpuinitdata amd_cpu_notifier = { 340static struct notifier_block amd_cpu_notifier = {
341 .notifier_call = amd_cpu_notify, 341 .notifier_call = amd_cpu_notify,
342}; 342};
343 343
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index f8ab4945892e..643b8b5eee86 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/serial_reg.h> 15#include <linux/serial_reg.h>
16#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
17#include <linux/reboot.h>
17 18
18#include <asm/ce4100.h> 19#include <asm/ce4100.h>
19#include <asm/prom.h> 20#include <asm/prom.h>
@@ -134,7 +135,7 @@ static void __init sdv_arch_setup(void)
134} 135}
135 136
136#ifdef CONFIG_X86_IO_APIC 137#ifdef CONFIG_X86_IO_APIC
137static void __cpuinit sdv_pci_init(void) 138static void sdv_pci_init(void)
138{ 139{
139 x86_of_pci_init(); 140 x86_of_pci_init();
140 /* We can't set this earlier, because we need to calibrate the timer */ 141 /* We can't set this earlier, because we need to calibrate the timer */
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index c8d5577044bb..90f6ed127096 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -931,13 +931,6 @@ void __init efi_enter_virtual_mode(void)
931 va = efi_ioremap(md->phys_addr, size, 931 va = efi_ioremap(md->phys_addr, size,
932 md->type, md->attribute); 932 md->type, md->attribute);
933 933
934 if (!(md->attribute & EFI_MEMORY_RUNTIME)) {
935 if (!va)
936 pr_err("ioremap of 0x%llX failed!\n",
937 (unsigned long long)md->phys_addr);
938 continue;
939 }
940
941 md->virt_addr = (u64) (unsigned long) va; 934 md->virt_addr = (u64) (unsigned long) va;
942 935
943 if (!va) { 936 if (!va) {
diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
index a0a0a4389bbd..47fe66fe61f1 100644
--- a/arch/x86/platform/mrst/mrst.c
+++ b/arch/x86/platform/mrst/mrst.c
@@ -65,7 +65,7 @@
65 * lapic (always-on,ARAT) ------ 150 65 * lapic (always-on,ARAT) ------ 150
66 */ 66 */
67 67
68__cpuinitdata enum mrst_timer_options mrst_timer_options; 68enum mrst_timer_options mrst_timer_options;
69 69
70static u32 sfi_mtimer_usage[SFI_MTMR_MAX_NUM]; 70static u32 sfi_mtimer_usage[SFI_MTMR_MAX_NUM];
71static struct sfi_timer_table_entry sfi_mtimer_array[SFI_MTMR_MAX_NUM]; 71static struct sfi_timer_table_entry sfi_mtimer_array[SFI_MTMR_MAX_NUM];
@@ -248,7 +248,7 @@ static void __init mrst_time_init(void)
248 apbt_time_init(); 248 apbt_time_init();
249} 249}
250 250
251static void __cpuinit mrst_arch_setup(void) 251static void mrst_arch_setup(void)
252{ 252{
253 if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27) 253 if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27)
254 __mrst_cpu_chip = MRST_CPU_CHIP_PENWELL; 254 __mrst_cpu_chip = MRST_CPU_CHIP_PENWELL;
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index ae7319db18ee..5e04a1c899fa 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -508,7 +508,6 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
508{ 508{
509 struct rt_sigframe __user *frame; 509 struct rt_sigframe __user *frame;
510 int err = 0; 510 int err = 0;
511 struct task_struct *me = current;
512 511
513 frame = (struct rt_sigframe __user *) 512 frame = (struct rt_sigframe __user *)
514 round_down(stack_top - sizeof(struct rt_sigframe), 16); 513 round_down(stack_top - sizeof(struct rt_sigframe), 16);
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 2fa02bc50034..193097ef3d7d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1681,8 +1681,8 @@ static void __init init_hvm_pv_info(void)
1681 xen_domain_type = XEN_HVM_DOMAIN; 1681 xen_domain_type = XEN_HVM_DOMAIN;
1682} 1682}
1683 1683
1684static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, 1684static int xen_hvm_cpu_notify(struct notifier_block *self, unsigned long action,
1685 unsigned long action, void *hcpu) 1685 void *hcpu)
1686{ 1686{
1687 int cpu = (long)hcpu; 1687 int cpu = (long)hcpu;
1688 switch (action) { 1688 switch (action) {
@@ -1700,7 +1700,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
1700 return NOTIFY_OK; 1700 return NOTIFY_OK;
1701} 1701}
1702 1702
1703static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = { 1703static struct notifier_block xen_hvm_cpu_notifier = {
1704 .notifier_call = xen_hvm_cpu_notify, 1704 .notifier_call = xen_hvm_cpu_notify,
1705}; 1705};
1706 1706
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 94eac5c85cdc..056d11faef21 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -475,7 +475,7 @@ static void __init fiddle_vdso(void)
475#endif 475#endif
476} 476}
477 477
478static int __cpuinit register_callback(unsigned type, const void *func) 478static int register_callback(unsigned type, const void *func)
479{ 479{
480 struct callback_register callback = { 480 struct callback_register callback = {
481 .type = type, 481 .type = type,
@@ -486,7 +486,7 @@ static int __cpuinit register_callback(unsigned type, const void *func)
486 return HYPERVISOR_callback_op(CALLBACKOP_register, &callback); 486 return HYPERVISOR_callback_op(CALLBACKOP_register, &callback);
487} 487}
488 488
489void __cpuinit xen_enable_sysenter(void) 489void xen_enable_sysenter(void)
490{ 490{
491 int ret; 491 int ret;
492 unsigned sysenter_feature; 492 unsigned sysenter_feature;
@@ -505,7 +505,7 @@ void __cpuinit xen_enable_sysenter(void)
505 setup_clear_cpu_cap(sysenter_feature); 505 setup_clear_cpu_cap(sysenter_feature);
506} 506}
507 507
508void __cpuinit xen_enable_syscall(void) 508void xen_enable_syscall(void)
509{ 509{
510#ifdef CONFIG_X86_64 510#ifdef CONFIG_X86_64
511 int ret; 511 int ret;
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index c1367b29c3b1..ca92754eb846 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -65,7 +65,7 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)
65 return IRQ_HANDLED; 65 return IRQ_HANDLED;
66} 66}
67 67
68static void __cpuinit cpu_bringup(void) 68static void cpu_bringup(void)
69{ 69{
70 int cpu; 70 int cpu;
71 71
@@ -97,7 +97,7 @@ static void __cpuinit cpu_bringup(void)
97 wmb(); /* make sure everything is out */ 97 wmb(); /* make sure everything is out */
98} 98}
99 99
100static void __cpuinit cpu_bringup_and_idle(void) 100static void cpu_bringup_and_idle(void)
101{ 101{
102 cpu_bringup(); 102 cpu_bringup();
103 cpu_startup_entry(CPUHP_ONLINE); 103 cpu_startup_entry(CPUHP_ONLINE);
@@ -326,7 +326,7 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
326 set_cpu_present(cpu, true); 326 set_cpu_present(cpu, true);
327} 327}
328 328
329static int __cpuinit 329static int
330cpu_initialize_context(unsigned int cpu, struct task_struct *idle) 330cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
331{ 331{
332 struct vcpu_guest_context *ctxt; 332 struct vcpu_guest_context *ctxt;
@@ -397,7 +397,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
397 return 0; 397 return 0;
398} 398}
399 399
400static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle) 400static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
401{ 401{
402 int rc; 402 int rc;
403 403
@@ -470,7 +470,7 @@ static void xen_cpu_die(unsigned int cpu)
470 xen_teardown_timer(cpu); 470 xen_teardown_timer(cpu);
471} 471}
472 472
473static void __cpuinit xen_play_dead(void) /* used only with HOTPLUG_CPU */ 473static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
474{ 474{
475 play_dead_common(); 475 play_dead_common();
476 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL); 476 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
@@ -691,7 +691,7 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
691 xen_init_lock_cpu(0); 691 xen_init_lock_cpu(0);
692} 692}
693 693
694static int __cpuinit xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle) 694static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
695{ 695{
696 int rc; 696 int rc;
697 rc = native_cpu_up(cpu, tidle); 697 rc = native_cpu_up(cpu, tidle);
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index a40f8508e760..cf3caee356b3 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -361,7 +361,7 @@ static irqreturn_t dummy_handler(int irq, void *dev_id)
361 return IRQ_HANDLED; 361 return IRQ_HANDLED;
362} 362}
363 363
364void __cpuinit xen_init_lock_cpu(int cpu) 364void xen_init_lock_cpu(int cpu)
365{ 365{
366 int irq; 366 int irq;
367 char *name; 367 char *name;
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index a95b41744ad0..86782c5d7e2a 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -73,7 +73,7 @@ static inline void xen_hvm_smp_init(void) {}
73 73
74#ifdef CONFIG_PARAVIRT_SPINLOCKS 74#ifdef CONFIG_PARAVIRT_SPINLOCKS
75void __init xen_init_spinlocks(void); 75void __init xen_init_spinlocks(void);
76void __cpuinit xen_init_lock_cpu(int cpu); 76void xen_init_lock_cpu(int cpu);
77void xen_uninit_lock_cpu(int cpu); 77void xen_uninit_lock_cpu(int cpu);
78#else 78#else
79static inline void xen_init_spinlocks(void) 79static inline void xen_init_spinlocks(void)
diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index bdbb17312526..24bb0c1776ba 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -162,7 +162,7 @@ irqreturn_t timer_interrupt (int irq, void *dev_id)
162} 162}
163 163
164#ifndef CONFIG_GENERIC_CALIBRATE_DELAY 164#ifndef CONFIG_GENERIC_CALIBRATE_DELAY
165void __cpuinit calibrate_delay(void) 165void calibrate_delay(void)
166{ 166{
167 loops_per_jiffy = CCOUNT_PER_JIFFY; 167 loops_per_jiffy = CCOUNT_PER_JIFFY;
168 printk("Calibrating delay loop (skipped)... " 168 printk("Calibrating delay loop (skipped)... "
diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
index 58916afbbda5..4b8d9b541112 100644
--- a/block/blk-iopoll.c
+++ b/block/blk-iopoll.c
@@ -189,8 +189,8 @@ void blk_iopoll_init(struct blk_iopoll *iop, int weight, blk_iopoll_fn *poll_fn)
189} 189}
190EXPORT_SYMBOL(blk_iopoll_init); 190EXPORT_SYMBOL(blk_iopoll_init);
191 191
192static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self, 192static int blk_iopoll_cpu_notify(struct notifier_block *self,
193 unsigned long action, void *hcpu) 193 unsigned long action, void *hcpu)
194{ 194{
195 /* 195 /*
196 * If a CPU goes away, splice its entries to the current CPU 196 * 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,
209 return NOTIFY_OK; 209 return NOTIFY_OK;
210} 210}
211 211
212static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = { 212static struct notifier_block blk_iopoll_cpu_notifier = {
213 .notifier_call = blk_iopoll_cpu_notify, 213 .notifier_call = blk_iopoll_cpu_notify,
214}; 214};
215 215
diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 467c8de88642..ec9e60636f43 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -78,8 +78,8 @@ static int raise_blk_irq(int cpu, struct request *rq)
78} 78}
79#endif 79#endif
80 80
81static int __cpuinit blk_cpu_notify(struct notifier_block *self, 81static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
82 unsigned long action, void *hcpu) 82 void *hcpu)
83{ 83{
84 /* 84 /*
85 * If a CPU goes away, splice its entries to the current CPU 85 * 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,
98 return NOTIFY_OK; 98 return NOTIFY_OK;
99} 99}
100 100
101static struct notifier_block __cpuinitdata blk_cpu_notifier = { 101static struct notifier_block blk_cpu_notifier = {
102 .notifier_call = blk_cpu_notify, 102 .notifier_call = blk_cpu_notify,
103}; 103};
104 104
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 69ce573f1224..aca01164f002 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -376,25 +376,6 @@ config CRYPTO_CRC32_PCLMUL
376 which will enable any routine to use the CRC-32-IEEE 802.3 checksum 376 which will enable any routine to use the CRC-32-IEEE 802.3 checksum
377 and gain better performance as compared with the table implementation. 377 and gain better performance as compared with the table implementation.
378 378
379config CRYPTO_CRCT10DIF
380 tristate "CRCT10DIF algorithm"
381 select CRYPTO_HASH
382 help
383 CRC T10 Data Integrity Field computation is being cast as
384 a crypto transform. This allows for faster crc t10 diff
385 transforms to be used if they are available.
386
387config CRYPTO_CRCT10DIF_PCLMUL
388 tristate "CRCT10DIF PCLMULQDQ hardware acceleration"
389 depends on X86 && 64BIT && CRC_T10DIF
390 select CRYPTO_HASH
391 help
392 For x86_64 processors with SSE4.2 and PCLMULQDQ supported,
393 CRC T10 DIF PCLMULQDQ computation can be hardware
394 accelerated PCLMULQDQ instruction. This option will create
395 'crct10dif-plcmul' module, which is faster when computing the
396 crct10dif checksum as compared with the generic table implementation.
397
398config CRYPTO_GHASH 379config CRYPTO_GHASH
399 tristate "GHASH digest algorithm" 380 tristate "GHASH digest algorithm"
400 select CRYPTO_GF128MUL 381 select CRYPTO_GF128MUL
diff --git a/crypto/Makefile b/crypto/Makefile
index 2d5ed08a239f..2ba0df2f908f 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -83,7 +83,6 @@ obj-$(CONFIG_CRYPTO_ZLIB) += zlib.o
83obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o 83obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
84obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o 84obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
85obj-$(CONFIG_CRYPTO_CRC32) += crc32.o 85obj-$(CONFIG_CRYPTO_CRC32) += crc32.o
86obj-$(CONFIG_CRYPTO_CRCT10DIF) += crct10dif.o
87obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o 86obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
88obj-$(CONFIG_CRYPTO_LZO) += lzo.o 87obj-$(CONFIG_CRYPTO_LZO) += lzo.o
89obj-$(CONFIG_CRYPTO_LZ4) += lz4.o 88obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
diff --git a/crypto/crct10dif.c b/crypto/crct10dif.c
deleted file mode 100644
index 92aca96d6b98..000000000000
--- a/crypto/crct10dif.c
+++ /dev/null
@@ -1,178 +0,0 @@
1/*
2 * Cryptographic API.
3 *
4 * T10 Data Integrity Field CRC16 Crypto Transform
5 *
6 * Copyright (c) 2007 Oracle Corporation. All rights reserved.
7 * Written by Martin K. Petersen <martin.petersen@oracle.com>
8 * Copyright (C) 2013 Intel Corporation
9 * Author: Tim Chen <tim.c.chen@linux.intel.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 */
26
27#include <linux/types.h>
28#include <linux/module.h>
29#include <linux/crc-t10dif.h>
30#include <crypto/internal/hash.h>
31#include <linux/init.h>
32#include <linux/string.h>
33#include <linux/kernel.h>
34
35struct chksum_desc_ctx {
36 __u16 crc;
37};
38
39/* Table generated using the following polynomium:
40 * x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
41 * gt: 0x8bb7
42 */
43static const __u16 t10_dif_crc_table[256] = {
44 0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B,
45 0xEFBD, 0x640A, 0x7364, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6,
46 0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F, 0x7A11, 0xF1A6,
47 0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B,
48 0xA99A, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1,
49 0x4627, 0xCD90, 0xDAFE, 0x5149, 0xF422, 0x7F95, 0x68FB, 0xE34C,
50 0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B, 0x583C,
51 0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781,
52 0xD883, 0x5334, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8,
53 0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B, 0x0E8C, 0x19E2, 0x9255,
54 0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925,
55 0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698,
56 0x7119, 0xFAAE, 0xEDC0, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472,
57 0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716, 0xB078, 0x3BCF,
58 0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF,
59 0xCA69, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02,
60 0x3AB1, 0xB106, 0xA668, 0x2DDF, 0x88B4, 0x0303, 0x146D, 0x9FDA,
61 0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0, 0x7067,
62 0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17,
63 0x81C1, 0x0A76, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA,
64 0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E, 0xAA99, 0xBDF7, 0x3640,
65 0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD,
66 0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D,
67 0x285B, 0xA3EC, 0xB482, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30,
68 0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80, 0xCCEE, 0x4759,
69 0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4,
70 0xB6FF, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394,
71 0x5942, 0xD2F5, 0xC59B, 0x4E2C, 0xEB47, 0x60F0, 0x779E, 0xFC29,
72 0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574, 0xEEC3,
73 0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E,
74 0x1F65, 0x94D2, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E,
75 0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD, 0xC96A, 0xDE04, 0x55B3
76};
77
78__u16 crc_t10dif_generic(__u16 crc, const unsigned char *buffer, size_t len)
79{
80 unsigned int i;
81
82 for (i = 0 ; i < len ; i++)
83 crc = (crc << 8) ^ t10_dif_crc_table[((crc >> 8) ^ buffer[i]) & 0xff];
84
85 return crc;
86}
87EXPORT_SYMBOL(crc_t10dif_generic);
88
89/*
90 * Steps through buffer one byte at at time, calculates reflected
91 * crc using table.
92 */
93
94static int chksum_init(struct shash_desc *desc)
95{
96 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
97
98 ctx->crc = 0;
99
100 return 0;
101}
102
103static int chksum_update(struct shash_desc *desc, const u8 *data,
104 unsigned int length)
105{
106 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
107
108 ctx->crc = crc_t10dif_generic(ctx->crc, data, length);
109 return 0;
110}
111
112static int chksum_final(struct shash_desc *desc, u8 *out)
113{
114 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
115
116 *(__u16 *)out = ctx->crc;
117 return 0;
118}
119
120static int __chksum_finup(__u16 *crcp, const u8 *data, unsigned int len,
121 u8 *out)
122{
123 *(__u16 *)out = crc_t10dif_generic(*crcp, data, len);
124 return 0;
125}
126
127static int chksum_finup(struct shash_desc *desc, const u8 *data,
128 unsigned int len, u8 *out)
129{
130 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
131
132 return __chksum_finup(&ctx->crc, data, len, out);
133}
134
135static int chksum_digest(struct shash_desc *desc, const u8 *data,
136 unsigned int length, u8 *out)
137{
138 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
139
140 return __chksum_finup(&ctx->crc, data, length, out);
141}
142
143static struct shash_alg alg = {
144 .digestsize = CRC_T10DIF_DIGEST_SIZE,
145 .init = chksum_init,
146 .update = chksum_update,
147 .final = chksum_final,
148 .finup = chksum_finup,
149 .digest = chksum_digest,
150 .descsize = sizeof(struct chksum_desc_ctx),
151 .base = {
152 .cra_name = "crct10dif",
153 .cra_driver_name = "crct10dif-generic",
154 .cra_priority = 100,
155 .cra_blocksize = CRC_T10DIF_BLOCK_SIZE,
156 .cra_module = THIS_MODULE,
157 }
158};
159
160static int __init crct10dif_mod_init(void)
161{
162 int ret;
163
164 ret = crypto_register_shash(&alg);
165 return ret;
166}
167
168static void __exit crct10dif_mod_fini(void)
169{
170 crypto_unregister_shash(&alg);
171}
172
173module_init(crct10dif_mod_init);
174module_exit(crct10dif_mod_fini);
175
176MODULE_AUTHOR("Tim Chen <tim.c.chen@linux.intel.com>");
177MODULE_DESCRIPTION("T10 DIF CRC calculation.");
178MODULE_LICENSE("GPL");
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 25a5934f0e50..66d254ce0d11 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1174,10 +1174,6 @@ static int do_test(int m)
1174 ret += tcrypt_test("ghash"); 1174 ret += tcrypt_test("ghash");
1175 break; 1175 break;
1176 1176
1177 case 47:
1178 ret += tcrypt_test("crct10dif");
1179 break;
1180
1181 case 100: 1177 case 100:
1182 ret += tcrypt_test("hmac(md5)"); 1178 ret += tcrypt_test("hmac(md5)");
1183 break; 1179 break;
@@ -1502,10 +1498,6 @@ static int do_test(int m)
1502 test_hash_speed("crc32c", sec, generic_hash_speed_template); 1498 test_hash_speed("crc32c", sec, generic_hash_speed_template);
1503 if (mode > 300 && mode < 400) break; 1499 if (mode > 300 && mode < 400) break;
1504 1500
1505 case 320:
1506 test_hash_speed("crct10dif", sec, generic_hash_speed_template);
1507 if (mode > 300 && mode < 400) break;
1508
1509 case 399: 1501 case 399:
1510 break; 1502 break;
1511 1503
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 2f00607039e2..ecddf921a9db 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -2046,16 +2046,6 @@ static const struct alg_test_desc alg_test_descs[] = {
2046 } 2046 }
2047 } 2047 }
2048 }, { 2048 }, {
2049 .alg = "crct10dif",
2050 .test = alg_test_hash,
2051 .fips_allowed = 1,
2052 .suite = {
2053 .hash = {
2054 .vecs = crct10dif_tv_template,
2055 .count = CRCT10DIF_TEST_VECTORS
2056 }
2057 }
2058 }, {
2059 .alg = "cryptd(__driver-cbc-aes-aesni)", 2049 .alg = "cryptd(__driver-cbc-aes-aesni)",
2060 .test = alg_test_null, 2050 .test = alg_test_null,
2061 .fips_allowed = 1, 2051 .fips_allowed = 1,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 7d44aa3d6b44..1e701bc075b9 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -450,39 +450,6 @@ static struct hash_testvec rmd320_tv_template[] = {
450 } 450 }
451}; 451};
452 452
453#define CRCT10DIF_TEST_VECTORS 3
454static struct hash_testvec crct10dif_tv_template[] = {
455 {
456 .plaintext = "abc",
457 .psize = 3,
458#ifdef __LITTLE_ENDIAN
459 .digest = "\x3b\x44",
460#else
461 .digest = "\x44\x3b",
462#endif
463 }, {
464 .plaintext = "1234567890123456789012345678901234567890"
465 "123456789012345678901234567890123456789",
466 .psize = 79,
467#ifdef __LITTLE_ENDIAN
468 .digest = "\x70\x4b",
469#else
470 .digest = "\x4b\x70",
471#endif
472 }, {
473 .plaintext =
474 "abcddddddddddddddddddddddddddddddddddddddddddddddddddddd",
475 .psize = 56,
476#ifdef __LITTLE_ENDIAN
477 .digest = "\xe3\x9c",
478#else
479 .digest = "\x9c\xe3",
480#endif
481 .np = 2,
482 .tap = { 28, 28 }
483 }
484};
485
486/* 453/*
487 * SHA1 test vectors from from FIPS PUB 180-1 454 * SHA1 test vectors from from FIPS PUB 180-1
488 * Long vector from CAVS 5.0 455 * Long vector from CAVS 5.0
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index c711d1144044..999adb5499c7 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,6 +323,7 @@ static int acpi_memory_device_add(struct acpi_device *device,
323 /* Get the range from the _CRS */ 323 /* Get the range from the _CRS */
324 result = acpi_memory_get_device_resources(mem_device); 324 result = acpi_memory_get_device_resources(mem_device);
325 if (result) { 325 if (result) {
326 device->driver_data = NULL;
326 kfree(mem_device); 327 kfree(mem_device);
327 return result; 328 return result;
328 } 329 }
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index e9b01e35ac37..fd6c51cc3acb 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -340,7 +340,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
340 */ 340 */
341static DEFINE_PER_CPU(void *, processor_device_array); 341static DEFINE_PER_CPU(void *, processor_device_array);
342 342
343static int __cpuinit acpi_processor_add(struct acpi_device *device, 343static int acpi_processor_add(struct acpi_device *device,
344 const struct acpi_device_id *id) 344 const struct acpi_device_id *id)
345{ 345{
346 struct acpi_processor *pr; 346 struct acpi_processor *pr;
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index dfed26545ba2..d4a4901637cd 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -931,19 +931,6 @@ struct acpi_bit_register_info {
931 931
932/* Structs and definitions for _OSI support and I/O port validation */ 932/* Structs and definitions for _OSI support and I/O port validation */
933 933
934#define ACPI_OSI_WIN_2000 0x01
935#define ACPI_OSI_WIN_XP 0x02
936#define ACPI_OSI_WIN_XP_SP1 0x03
937#define ACPI_OSI_WINSRV_2003 0x04
938#define ACPI_OSI_WIN_XP_SP2 0x05
939#define ACPI_OSI_WINSRV_2003_SP1 0x06
940#define ACPI_OSI_WIN_VISTA 0x07
941#define ACPI_OSI_WINSRV_2008 0x08
942#define ACPI_OSI_WIN_VISTA_SP1 0x09
943#define ACPI_OSI_WIN_VISTA_SP2 0x0A
944#define ACPI_OSI_WIN_7 0x0B
945#define ACPI_OSI_WIN_8 0x0C
946
947#define ACPI_ALWAYS_ILLEGAL 0x00 934#define ACPI_ALWAYS_ILLEGAL 0x00
948 935
949struct acpi_interface_info { 936struct acpi_interface_info {
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 3a50a34fe176..5da44e81dd4d 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -164,4 +164,13 @@ struct platform_device;
164int acpi_create_platform_device(struct acpi_device *adev, 164int acpi_create_platform_device(struct acpi_device *adev,
165 const struct acpi_device_id *id); 165 const struct acpi_device_id *id);
166 166
167/*--------------------------------------------------------------------------
168 Video
169 -------------------------------------------------------------------------- */
170#if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
171bool acpi_video_backlight_quirks(void);
172#else
173static inline bool acpi_video_backlight_quirks(void) { return false; }
174#endif
175
167#endif /* _ACPI_INTERNAL_H_ */ 176#endif /* _ACPI_INTERNAL_H_ */
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 164d49569aeb..a5e9f4a5b281 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -253,7 +253,7 @@ static bool __init processor_physically_present(acpi_handle handle)
253 return true; 253 return true;
254} 254}
255 255
256static void __cpuinit acpi_set_pdc_bits(u32 *buf) 256static void acpi_set_pdc_bits(u32 *buf)
257{ 257{
258 buf[0] = ACPI_PDC_REVISION_ID; 258 buf[0] = ACPI_PDC_REVISION_ID;
259 buf[1] = 1; 259 buf[1] = 1;
@@ -265,7 +265,7 @@ static void __cpuinit acpi_set_pdc_bits(u32 *buf)
265 arch_acpi_set_pdc_bits(buf); 265 arch_acpi_set_pdc_bits(buf);
266} 266}
267 267
268static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void) 268static struct acpi_object_list *acpi_processor_alloc_pdc(void)
269{ 269{
270 struct acpi_object_list *obj_list; 270 struct acpi_object_list *obj_list;
271 union acpi_object *obj; 271 union acpi_object *obj;
@@ -308,7 +308,7 @@ static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void)
308 * _PDC is required for a BIOS-OS handshake for most of the newer 308 * _PDC is required for a BIOS-OS handshake for most of the newer
309 * ACPI processor features. 309 * ACPI processor features.
310 */ 310 */
311static int __cpuinit 311static int
312acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) 312acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
313{ 313{
314 acpi_status status = AE_OK; 314 acpi_status status = AE_OK;
@@ -336,7 +336,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
336 return status; 336 return status;
337} 337}
338 338
339void __cpuinit acpi_processor_set_pdc(acpi_handle handle) 339void acpi_processor_set_pdc(acpi_handle handle)
340{ 340{
341 struct acpi_object_list *obj_list; 341 struct acpi_object_list *obj_list;
342 342
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 823be116619e..870eaf5fa547 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -118,9 +118,9 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
118 return; 118 return;
119} 119}
120 120
121static __cpuinit int __acpi_processor_start(struct acpi_device *device); 121static int __acpi_processor_start(struct acpi_device *device);
122 122
123static int __cpuinit acpi_cpu_soft_notify(struct notifier_block *nfb, 123static int acpi_cpu_soft_notify(struct notifier_block *nfb,
124 unsigned long action, void *hcpu) 124 unsigned long action, void *hcpu)
125{ 125{
126 unsigned int cpu = (unsigned long)hcpu; 126 unsigned int cpu = (unsigned long)hcpu;
@@ -162,7 +162,7 @@ static struct notifier_block __refdata acpi_cpu_notifier =
162 .notifier_call = acpi_cpu_soft_notify, 162 .notifier_call = acpi_cpu_soft_notify,
163}; 163};
164 164
165static __cpuinit int __acpi_processor_start(struct acpi_device *device) 165static int __acpi_processor_start(struct acpi_device *device)
166{ 166{
167 struct acpi_processor *pr = acpi_driver_data(device); 167 struct acpi_processor *pr = acpi_driver_data(device);
168 acpi_status status; 168 acpi_status status;
@@ -226,7 +226,7 @@ static __cpuinit int __acpi_processor_start(struct acpi_device *device)
226 return result; 226 return result;
227} 227}
228 228
229static int __cpuinit acpi_processor_start(struct device *dev) 229static int acpi_processor_start(struct device *dev)
230{ 230{
231 struct acpi_device *device; 231 struct acpi_device *device;
232 232
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 0461ccc92c54..f98dd00b51a9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -96,9 +96,7 @@ static int set_max_cstate(const struct dmi_system_id *id)
96 return 0; 96 return 0;
97} 97}
98 98
99/* Actually this shouldn't be __cpuinitdata, would be better to fix the 99static struct dmi_system_id processor_power_dmi_table[] = {
100 callers to only run once -AK */
101static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
102 { set_max_cstate, "Clevo 5600D", { 100 { set_max_cstate, "Clevo 5600D", {
103 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 101 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
104 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")}, 102 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")},
@@ -1165,7 +1163,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1165 1163
1166static int acpi_processor_registered; 1164static int acpi_processor_registered;
1167 1165
1168int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) 1166int acpi_processor_power_init(struct acpi_processor *pr)
1169{ 1167{
1170 acpi_status status = 0; 1168 acpi_status status = 0;
1171 int retval; 1169 int retval;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 10985573aaa7..8a46c924effd 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -352,10 +352,12 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
352 mutex_lock(&acpi_scan_lock); 352 mutex_lock(&acpi_scan_lock);
353 lock_device_hotplug(); 353 lock_device_hotplug();
354 354
355 acpi_bus_get_device(handle, &device); 355 if (ost_source != ACPI_NOTIFY_BUS_CHECK) {
356 if (device) { 356 acpi_bus_get_device(handle, &device);
357 dev_warn(&device->dev, "Attempt to re-insert\n"); 357 if (device) {
358 goto out; 358 dev_warn(&device->dev, "Attempt to re-insert\n");
359 goto out;
360 }
359 } 361 }
360 acpi_evaluate_hotplug_ost(handle, ost_source, 362 acpi_evaluate_hotplug_ost(handle, ost_source,
361 ACPI_OST_SC_INSERT_IN_PROGRESS, NULL); 363 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,
1981 if (acpi_bus_get_device(handle, &device)) 1983 if (acpi_bus_get_device(handle, &device))
1982 return AE_CTRL_DEPTH; 1984 return AE_CTRL_DEPTH;
1983 1985
1986 if (device->handler)
1987 return AE_OK;
1988
1984 ret = acpi_scan_attach_handler(device); 1989 ret = acpi_scan_attach_handler(device);
1985 if (ret) 1990 if (ret)
1986 return ret > 0 ? AE_OK : AE_CTRL_DEPTH; 1991 return ret > 0 ? AE_OK : AE_CTRL_DEPTH;
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 5d7075d25700..0ec434d2586d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -44,6 +44,8 @@
44#include <linux/suspend.h> 44#include <linux/suspend.h>
45#include <acpi/video.h> 45#include <acpi/video.h>
46 46
47#include "internal.h"
48
47#define PREFIX "ACPI: " 49#define PREFIX "ACPI: "
48 50
49#define ACPI_VIDEO_BUS_NAME "Video Bus" 51#define ACPI_VIDEO_BUS_NAME "Video Bus"
@@ -450,6 +452,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
450 }, 452 },
451 { 453 {
452 .callback = video_ignore_initial_backlight, 454 .callback = video_ignore_initial_backlight,
455 .ident = "Fujitsu E753",
456 .matches = {
457 DMI_MATCH(DMI_BOARD_VENDOR, "FUJITSU"),
458 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E753"),
459 },
460 },
461 {
462 .callback = video_ignore_initial_backlight,
453 .ident = "HP Pavilion dm4", 463 .ident = "HP Pavilion dm4",
454 .matches = { 464 .matches = {
455 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 465 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
@@ -898,6 +908,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
898 device->cap._DDC = 1; 908 device->cap._DDC = 1;
899 } 909 }
900 910
911 if (acpi_video_init_brightness(device))
912 return;
913
901 if (acpi_video_backlight_support()) { 914 if (acpi_video_backlight_support()) {
902 struct backlight_properties props; 915 struct backlight_properties props;
903 struct pci_dev *pdev; 916 struct pci_dev *pdev;
@@ -907,9 +920,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
907 static int count = 0; 920 static int count = 0;
908 char *name; 921 char *name;
909 922
910 result = acpi_video_init_brightness(device);
911 if (result)
912 return;
913 name = kasprintf(GFP_KERNEL, "acpi_video%d", count); 923 name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
914 if (!name) 924 if (!name)
915 return; 925 return;
@@ -969,6 +979,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
969 if (result) 979 if (result)
970 printk(KERN_ERR PREFIX "Create sysfs link\n"); 980 printk(KERN_ERR PREFIX "Create sysfs link\n");
971 981
982 } else {
983 /* Remove the brightness object. */
984 kfree(device->brightness->levels);
985 kfree(device->brightness);
986 device->brightness = NULL;
972 } 987 }
973} 988}
974 989
@@ -1532,14 +1547,20 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1532 1547
1533/* acpi_video interface */ 1548/* acpi_video interface */
1534 1549
1550/*
1551 * Win8 requires setting bit2 of _DOS to let firmware know it shouldn't
1552 * preform any automatic brightness change on receiving a notification.
1553 */
1535static int acpi_video_bus_start_devices(struct acpi_video_bus *video) 1554static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
1536{ 1555{
1537 return acpi_video_bus_DOS(video, 0, 0); 1556 return acpi_video_bus_DOS(video, 0,
1557 acpi_video_backlight_quirks() ? 1 : 0);
1538} 1558}
1539 1559
1540static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) 1560static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1541{ 1561{
1542 return acpi_video_bus_DOS(video, 0, 1); 1562 return acpi_video_bus_DOS(video, 0,
1563 acpi_video_backlight_quirks() ? 0 : 1);
1543} 1564}
1544 1565
1545static void acpi_video_bus_notify(struct acpi_device *device, u32 event) 1566static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index e6bd910bc6ed..c3397748ba46 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -38,6 +38,8 @@
38#include <linux/dmi.h> 38#include <linux/dmi.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40 40
41#include "internal.h"
42
41#define PREFIX "ACPI: " 43#define PREFIX "ACPI: "
42 44
43ACPI_MODULE_NAME("video"); 45ACPI_MODULE_NAME("video");
@@ -234,6 +236,12 @@ static void acpi_video_caps_check(void)
234 acpi_video_get_capabilities(NULL); 236 acpi_video_get_capabilities(NULL);
235} 237}
236 238
239bool acpi_video_backlight_quirks(void)
240{
241 return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
242}
243EXPORT_SYMBOL(acpi_video_backlight_quirks);
244
237/* Promote the vendor interface instead of the generic video module. 245/* Promote the vendor interface instead of the generic video module.
238 * This function allow DMI blacklists to be implemented by externals 246 * This function allow DMI blacklists to be implemented by externals
239 * platform drivers instead of putting a big blacklist in video_detect.c 247 * platform drivers instead of putting a big blacklist in video_detect.c
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 80dc988f01e4..4e737728aee2 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -97,6 +97,15 @@ config SATA_AHCI_PLATFORM
97 97
98 If unsure, say N. 98 If unsure, say N.
99 99
100config AHCI_IMX
101 tristate "Freescale i.MX AHCI SATA support"
102 depends on SATA_AHCI_PLATFORM && MFD_SYSCON
103 help
104 This option enables support for the Freescale i.MX SoC's
105 onboard AHCI SATA.
106
107 If unsure, say N.
108
100config SATA_FSL 109config SATA_FSL
101 tristate "Freescale 3.0Gbps SATA support" 110 tristate "Freescale 3.0Gbps SATA support"
102 depends on FSL_SOC 111 depends on FSL_SOC
@@ -107,7 +116,7 @@ config SATA_FSL
107 If unsure, say N. 116 If unsure, say N.
108 117
109config SATA_INIC162X 118config SATA_INIC162X
110 tristate "Initio 162x SATA support" 119 tristate "Initio 162x SATA support (Very Experimental)"
111 depends on PCI 120 depends on PCI
112 help 121 help
113 This option enables support for Initio 162x Serial ATA. 122 This option enables support for Initio 162x Serial ATA.
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index c04d0fd038a3..46518c622460 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o
10obj-$(CONFIG_SATA_SIL24) += sata_sil24.o 10obj-$(CONFIG_SATA_SIL24) += sata_sil24.o
11obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o 11obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
12obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o 12obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
13obj-$(CONFIG_AHCI_IMX) += ahci_imx.o
13 14
14# SFF w/ custom DMA 15# SFF w/ custom DMA
15obj-$(CONFIG_PDC_ADMA) += pdc_adma.o 16obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 5064f3ea20f1..db4380d70031 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1146,11 +1146,18 @@ int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis)
1146 return rc; 1146 return rc;
1147 1147
1148 for (i = 0; i < host->n_ports; i++) { 1148 for (i = 0; i < host->n_ports; i++) {
1149 const char* desc;
1149 struct ahci_port_priv *pp = host->ports[i]->private_data; 1150 struct ahci_port_priv *pp = host->ports[i]->private_data;
1150 1151
1152 /* pp is NULL for dummy ports */
1153 if (pp)
1154 desc = pp->irq_desc;
1155 else
1156 desc = dev_driver_string(host->dev);
1157
1151 rc = devm_request_threaded_irq(host->dev, 1158 rc = devm_request_threaded_irq(host->dev,
1152 irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED, 1159 irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED,
1153 pp->irq_desc, host->ports[i]); 1160 desc, host->ports[i]);
1154 if (rc) 1161 if (rc)
1155 goto out_free_irqs; 1162 goto out_free_irqs;
1156 } 1163 }
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
new file mode 100644
index 000000000000..58debb0acc3a
--- /dev/null
+++ b/drivers/ata/ahci_imx.c
@@ -0,0 +1,236 @@
1/*
2 * Freescale IMX AHCI SATA platform driver
3 * Copyright 2013 Freescale Semiconductor, Inc.
4 *
5 * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/regmap.h>
24#include <linux/ahci_platform.h>
25#include <linux/of_device.h>
26#include <linux/mfd/syscon.h>
27#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
28#include "ahci.h"
29
30enum {
31 HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
32};
33
34struct imx_ahci_priv {
35 struct platform_device *ahci_pdev;
36 struct clk *sata_ref_clk;
37 struct clk *ahb_clk;
38 struct regmap *gpr;
39};
40
41static int imx6q_sata_init(struct device *dev, void __iomem *mmio)
42{
43 int ret = 0;
44 unsigned int reg_val;
45 struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent);
46
47 imxpriv->gpr =
48 syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
49 if (IS_ERR(imxpriv->gpr)) {
50 dev_err(dev, "failed to find fsl,imx6q-iomux-gpr regmap\n");
51 return PTR_ERR(imxpriv->gpr);
52 }
53
54 ret = clk_prepare_enable(imxpriv->sata_ref_clk);
55 if (ret < 0) {
56 dev_err(dev, "prepare-enable sata_ref clock err:%d\n", ret);
57 return ret;
58 }
59
60 /*
61 * set PHY Paremeters, two steps to configure the GPR13,
62 * one write for rest of parameters, mask of first write
63 * is 0x07fffffd, and the other one write for setting
64 * the mpll_clk_en.
65 */
66 regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK
67 | IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK
68 | IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK
69 | IMX6Q_GPR13_SATA_SPD_MODE_MASK
70 | IMX6Q_GPR13_SATA_MPLL_SS_EN
71 | IMX6Q_GPR13_SATA_TX_ATTEN_MASK
72 | IMX6Q_GPR13_SATA_TX_BOOST_MASK
73 | IMX6Q_GPR13_SATA_TX_LVL_MASK
74 | IMX6Q_GPR13_SATA_TX_EDGE_RATE
75 , IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB
76 | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M
77 | IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F
78 | IMX6Q_GPR13_SATA_SPD_MODE_3P0G
79 | IMX6Q_GPR13_SATA_MPLL_SS_EN
80 | IMX6Q_GPR13_SATA_TX_ATTEN_9_16
81 | IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB
82 | IMX6Q_GPR13_SATA_TX_LVL_1_025_V);
83 regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_MPLL_CLK_EN,
84 IMX6Q_GPR13_SATA_MPLL_CLK_EN);
85 usleep_range(100, 200);
86
87 /*
88 * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL,
89 * and IP vendor specific register HOST_TIMER1MS.
90 * Configure CAP_SSS (support stagered spin up).
91 * Implement the port0.
92 * Get the ahb clock rate, and configure the TIMER1MS register.
93 */
94 reg_val = readl(mmio + HOST_CAP);
95 if (!(reg_val & HOST_CAP_SSS)) {
96 reg_val |= HOST_CAP_SSS;
97 writel(reg_val, mmio + HOST_CAP);
98 }
99 reg_val = readl(mmio + HOST_PORTS_IMPL);
100 if (!(reg_val & 0x1)) {
101 reg_val |= 0x1;
102 writel(reg_val, mmio + HOST_PORTS_IMPL);
103 }
104
105 reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000;
106 writel(reg_val, mmio + HOST_TIMER1MS);
107
108 return 0;
109}
110
111static void imx6q_sata_exit(struct device *dev)
112{
113 struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent);
114
115 regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_MPLL_CLK_EN,
116 !IMX6Q_GPR13_SATA_MPLL_CLK_EN);
117 clk_disable_unprepare(imxpriv->sata_ref_clk);
118}
119
120static struct ahci_platform_data imx6q_sata_pdata = {
121 .init = imx6q_sata_init,
122 .exit = imx6q_sata_exit,
123};
124
125static const struct of_device_id imx_ahci_of_match[] = {
126 { .compatible = "fsl,imx6q-ahci", .data = &imx6q_sata_pdata},
127 {},
128};
129MODULE_DEVICE_TABLE(of, imx_ahci_of_match);
130
131static int imx_ahci_probe(struct platform_device *pdev)
132{
133 struct device *dev = &pdev->dev;
134 struct resource *mem, *irq, res[2];
135 const struct of_device_id *of_id;
136 const struct ahci_platform_data *pdata = NULL;
137 struct imx_ahci_priv *imxpriv;
138 struct device *ahci_dev;
139 struct platform_device *ahci_pdev;
140 int ret;
141
142 imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL);
143 if (!imxpriv) {
144 dev_err(dev, "can't alloc ahci_host_priv\n");
145 return -ENOMEM;
146 }
147
148 ahci_pdev = platform_device_alloc("ahci", -1);
149 if (!ahci_pdev)
150 return -ENODEV;
151
152 ahci_dev = &ahci_pdev->dev;
153 ahci_dev->parent = dev;
154
155 imxpriv->ahb_clk = devm_clk_get(dev, "ahb");
156 if (IS_ERR(imxpriv->ahb_clk)) {
157 dev_err(dev, "can't get ahb clock.\n");
158 ret = PTR_ERR(imxpriv->ahb_clk);
159 goto err_out;
160 }
161
162 imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref");
163 if (IS_ERR(imxpriv->sata_ref_clk)) {
164 dev_err(dev, "can't get sata_ref clock.\n");
165 ret = PTR_ERR(imxpriv->sata_ref_clk);
166 goto err_out;
167 }
168
169 imxpriv->ahci_pdev = ahci_pdev;
170 platform_set_drvdata(pdev, imxpriv);
171
172 of_id = of_match_device(imx_ahci_of_match, dev);
173 if (of_id) {
174 pdata = of_id->data;
175 } else {
176 ret = -EINVAL;
177 goto err_out;
178 }
179
180 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
181 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
182 if (!mem || !irq) {
183 dev_err(dev, "no mmio/irq resource\n");
184 ret = -ENOMEM;
185 goto err_out;
186 }
187
188 res[0] = *mem;
189 res[1] = *irq;
190
191 ahci_dev->coherent_dma_mask = DMA_BIT_MASK(32);
192 ahci_dev->dma_mask = &ahci_dev->coherent_dma_mask;
193 ahci_dev->of_node = dev->of_node;
194
195 ret = platform_device_add_resources(ahci_pdev, res, 2);
196 if (ret)
197 goto err_out;
198
199 ret = platform_device_add_data(ahci_pdev, pdata, sizeof(*pdata));
200 if (ret)
201 goto err_out;
202
203 ret = platform_device_add(ahci_pdev);
204 if (ret) {
205err_out:
206 platform_device_put(ahci_pdev);
207 return ret;
208 }
209
210 return 0;
211}
212
213static int imx_ahci_remove(struct platform_device *pdev)
214{
215 struct imx_ahci_priv *imxpriv = platform_get_drvdata(pdev);
216 struct platform_device *ahci_pdev = imxpriv->ahci_pdev;
217
218 platform_device_unregister(ahci_pdev);
219 return 0;
220}
221
222static struct platform_driver imx_ahci_driver = {
223 .probe = imx_ahci_probe,
224 .remove = imx_ahci_remove,
225 .driver = {
226 .name = "ahci-imx",
227 .owner = THIS_MODULE,
228 .of_match_table = imx_ahci_of_match,
229 },
230};
231module_platform_driver(imx_ahci_driver);
232
233MODULE_DESCRIPTION("Freescale i.MX AHCI SATA platform driver");
234MODULE_AUTHOR("Richard Zhu <Hong-Xing.Zhu@freescale.com>");
235MODULE_LICENSE("GPL");
236MODULE_ALIAS("ahci:imx");
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index b52a10c8eeb9..513ad7ed0c99 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -330,7 +330,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
330 /* SATA Controller IDE (Wellsburg) */ 330 /* SATA Controller IDE (Wellsburg) */
331 { 0x8086, 0x8d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, 331 { 0x8086, 0x8d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
332 /* SATA Controller IDE (Wellsburg) */ 332 /* SATA Controller IDE (Wellsburg) */
333 { 0x8086, 0x8d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 333 { 0x8086, 0x8d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_snb },
334 /* SATA Controller IDE (Wellsburg) */ 334 /* SATA Controller IDE (Wellsburg) */
335 { 0x8086, 0x8d60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, 335 { 0x8086, 0x8d60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
336 /* SATA Controller IDE (Wellsburg) */ 336 /* SATA Controller IDE (Wellsburg) */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 83c08907e042..b1e880a3c3da 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -206,8 +206,10 @@ static ssize_t ata_scsi_park_store(struct device *device,
206 unsigned long flags; 206 unsigned long flags;
207 int rc; 207 int rc;
208 208
209 rc = strict_strtol(buf, 10, &input); 209 rc = kstrtol(buf, 10, &input);
210 if (rc || input < -2) 210 if (rc)
211 return rc;
212 if (input < -2)
211 return -EINVAL; 213 return -EINVAL;
212 if (input > ATA_TMOUT_MAX_PARK) { 214 if (input > ATA_TMOUT_MAX_PARK) {
213 rc = -EOVERFLOW; 215 rc = -EOVERFLOW;
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index e45131748248..5c54d957370a 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -6,6 +6,18 @@
6 * 6 *
7 * This file is released under GPL v2. 7 * This file is released under GPL v2.
8 * 8 *
9 * **** WARNING ****
10 *
11 * This driver never worked properly and unfortunately data corruption is
12 * relatively common. There isn't anyone working on the driver and there's
13 * no support from the vendor. Do not use this driver in any production
14 * environment.
15 *
16 * http://thread.gmane.org/gmane.linux.debian.devel.bugs.rc/378525/focus=54491
17 * https://bugzilla.kernel.org/show_bug.cgi?id=60565
18 *
19 * *****************
20 *
9 * This controller is eccentric and easily locks up if something isn't 21 * This controller is eccentric and easily locks up if something isn't
10 * right. Documentation is available at initio's website but it only 22 * right. Documentation is available at initio's website but it only
11 * documents registers (not programming model). 23 * documents registers (not programming model).
@@ -807,6 +819,8 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
807 819
808 ata_print_version_once(&pdev->dev, DRV_VERSION); 820 ata_print_version_once(&pdev->dev, DRV_VERSION);
809 821
822 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");
823
810 /* alloc host */ 824 /* alloc host */
811 host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS); 825 host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS);
812 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); 826 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index dc3ea237f086..8856d74545d9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -528,9 +528,12 @@ static int device_add_attrs(struct device *dev)
528 int error; 528 int error;
529 529
530 if (class) { 530 if (class) {
531 error = device_add_attributes(dev, class->dev_attrs); 531 error = device_add_groups(dev, class->dev_groups);
532 if (error) 532 if (error)
533 return error; 533 return error;
534 error = device_add_attributes(dev, class->dev_attrs);
535 if (error)
536 goto err_remove_class_groups;
534 error = device_add_bin_attributes(dev, class->dev_bin_attrs); 537 error = device_add_bin_attributes(dev, class->dev_bin_attrs);
535 if (error) 538 if (error)
536 goto err_remove_class_attrs; 539 goto err_remove_class_attrs;
@@ -563,6 +566,9 @@ static int device_add_attrs(struct device *dev)
563 err_remove_class_attrs: 566 err_remove_class_attrs:
564 if (class) 567 if (class)
565 device_remove_attributes(dev, class->dev_attrs); 568 device_remove_attributes(dev, class->dev_attrs);
569 err_remove_class_groups:
570 if (class)
571 device_remove_groups(dev, class->dev_groups);
566 572
567 return error; 573 return error;
568} 574}
@@ -581,6 +587,7 @@ static void device_remove_attrs(struct device *dev)
581 if (class) { 587 if (class) {
582 device_remove_attributes(dev, class->dev_attrs); 588 device_remove_attributes(dev, class->dev_attrs);
583 device_remove_bin_attributes(dev, class->dev_bin_attrs); 589 device_remove_bin_attributes(dev, class->dev_bin_attrs);
590 device_remove_groups(dev, class->dev_groups);
584 } 591 }
585} 592}
586 593
@@ -1667,34 +1674,11 @@ static void device_create_release(struct device *dev)
1667 kfree(dev); 1674 kfree(dev);
1668} 1675}
1669 1676
1670/** 1677static struct device *
1671 * device_create_vargs - creates a device and registers it with sysfs 1678device_create_groups_vargs(struct class *class, struct device *parent,
1672 * @class: pointer to the struct class that this device should be registered to 1679 dev_t devt, void *drvdata,
1673 * @parent: pointer to the parent struct device of this new device, if any 1680 const struct attribute_group **groups,
1674 * @devt: the dev_t for the char device to be added 1681 const char *fmt, va_list args)
1675 * @drvdata: the data to be added to the device for callbacks
1676 * @fmt: string for the device's name
1677 * @args: va_list for the device's name
1678 *
1679 * This function can be used by char device classes. A struct device
1680 * will be created in sysfs, registered to the specified class.
1681 *
1682 * A "dev" file will be created, showing the dev_t for the device, if
1683 * the dev_t is not 0,0.
1684 * If a pointer to a parent struct device is passed in, the newly created
1685 * struct device will be a child of that device in sysfs.
1686 * The pointer to the struct device will be returned from the call.
1687 * Any further sysfs files that might be required can be created using this
1688 * pointer.
1689 *
1690 * Returns &struct device pointer on success, or ERR_PTR() on error.
1691 *
1692 * Note: the struct class passed to this function must have previously
1693 * been created with a call to class_create().
1694 */
1695struct device *device_create_vargs(struct class *class, struct device *parent,
1696 dev_t devt, void *drvdata, const char *fmt,
1697 va_list args)
1698{ 1682{
1699 struct device *dev = NULL; 1683 struct device *dev = NULL;
1700 int retval = -ENODEV; 1684 int retval = -ENODEV;
@@ -1711,6 +1695,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
1711 dev->devt = devt; 1695 dev->devt = devt;
1712 dev->class = class; 1696 dev->class = class;
1713 dev->parent = parent; 1697 dev->parent = parent;
1698 dev->groups = groups;
1714 dev->release = device_create_release; 1699 dev->release = device_create_release;
1715 dev_set_drvdata(dev, drvdata); 1700 dev_set_drvdata(dev, drvdata);
1716 1701
@@ -1728,6 +1713,39 @@ error:
1728 put_device(dev); 1713 put_device(dev);
1729 return ERR_PTR(retval); 1714 return ERR_PTR(retval);
1730} 1715}
1716
1717/**
1718 * device_create_vargs - creates a device and registers it with sysfs
1719 * @class: pointer to the struct class that this device should be registered to
1720 * @parent: pointer to the parent struct device of this new device, if any
1721 * @devt: the dev_t for the char device to be added
1722 * @drvdata: the data to be added to the device for callbacks
1723 * @fmt: string for the device's name
1724 * @args: va_list for the device's name
1725 *
1726 * This function can be used by char device classes. A struct device
1727 * will be created in sysfs, registered to the specified class.
1728 *
1729 * A "dev" file will be created, showing the dev_t for the device, if
1730 * the dev_t is not 0,0.
1731 * If a pointer to a parent struct device is passed in, the newly created
1732 * struct device will be a child of that device in sysfs.
1733 * The pointer to the struct device will be returned from the call.
1734 * Any further sysfs files that might be required can be created using this
1735 * pointer.
1736 *
1737 * Returns &struct device pointer on success, or ERR_PTR() on error.
1738 *
1739 * Note: the struct class passed to this function must have previously
1740 * been created with a call to class_create().
1741 */
1742struct device *device_create_vargs(struct class *class, struct device *parent,
1743 dev_t devt, void *drvdata, const char *fmt,
1744 va_list args)
1745{
1746 return device_create_groups_vargs(class, parent, devt, drvdata, NULL,
1747 fmt, args);
1748}
1731EXPORT_SYMBOL_GPL(device_create_vargs); 1749EXPORT_SYMBOL_GPL(device_create_vargs);
1732 1750
1733/** 1751/**
@@ -1767,6 +1785,50 @@ struct device *device_create(struct class *class, struct device *parent,
1767} 1785}
1768EXPORT_SYMBOL_GPL(device_create); 1786EXPORT_SYMBOL_GPL(device_create);
1769 1787
1788/**
1789 * device_create_with_groups - creates a device and registers it with sysfs
1790 * @class: pointer to the struct class that this device should be registered to
1791 * @parent: pointer to the parent struct device of this new device, if any
1792 * @devt: the dev_t for the char device to be added
1793 * @drvdata: the data to be added to the device for callbacks
1794 * @groups: NULL-terminated list of attribute groups to be created
1795 * @fmt: string for the device's name
1796 *
1797 * This function can be used by char device classes. A struct device
1798 * will be created in sysfs, registered to the specified class.
1799 * Additional attributes specified in the groups parameter will also
1800 * be created automatically.
1801 *
1802 * A "dev" file will be created, showing the dev_t for the device, if
1803 * the dev_t is not 0,0.
1804 * If a pointer to a parent struct device is passed in, the newly created
1805 * struct device will be a child of that device in sysfs.
1806 * The pointer to the struct device will be returned from the call.
1807 * Any further sysfs files that might be required can be created using this
1808 * pointer.
1809 *
1810 * Returns &struct device pointer on success, or ERR_PTR() on error.
1811 *
1812 * Note: the struct class passed to this function must have previously
1813 * been created with a call to class_create().
1814 */
1815struct device *device_create_with_groups(struct class *class,
1816 struct device *parent, dev_t devt,
1817 void *drvdata,
1818 const struct attribute_group **groups,
1819 const char *fmt, ...)
1820{
1821 va_list vargs;
1822 struct device *dev;
1823
1824 va_start(vargs, fmt);
1825 dev = device_create_groups_vargs(class, parent, devt, drvdata, groups,
1826 fmt, vargs);
1827 va_end(vargs);
1828 return dev;
1829}
1830EXPORT_SYMBOL_GPL(device_create_with_groups);
1831
1770static int __match_devt(struct device *dev, const void *data) 1832static int __match_devt(struct device *dev, const void *data)
1771{ 1833{
1772 const dev_t *devt = data; 1834 const dev_t *devt = data;
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index a16d20e389f0..4c358bc44c72 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -278,7 +278,7 @@ static void cpu_device_release(struct device *dev)
278 * 278 *
279 * Initialize and register the CPU device. 279 * Initialize and register the CPU device.
280 */ 280 */
281int __cpuinit register_cpu(struct cpu *cpu, int num) 281int register_cpu(struct cpu *cpu, int num)
282{ 282{
283 int error; 283 int error;
284 284
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 15789875128e..3c3197a8de41 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -522,6 +522,7 @@ static void platform_drv_shutdown(struct device *_dev)
522/** 522/**
523 * __platform_driver_register - register a driver for platform-level devices 523 * __platform_driver_register - register a driver for platform-level devices
524 * @drv: platform driver structure 524 * @drv: platform driver structure
525 * @owner: owning module/driver
525 */ 526 */
526int __platform_driver_register(struct platform_driver *drv, 527int __platform_driver_register(struct platform_driver *drv,
527 struct module *owner) 528 struct module *owner)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 95920583e31e..e0d0c7d8a5c5 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1853,7 +1853,7 @@ int regmap_async_complete(struct regmap *map)
1853 int ret; 1853 int ret;
1854 1854
1855 /* Nothing to do with no async support */ 1855 /* Nothing to do with no async support */
1856 if (!map->bus->async_write) 1856 if (!map->bus || !map->bus->async_write)
1857 return 0; 1857 return 0;
1858 1858
1859 trace_regmap_async_complete_start(map->dev); 1859 trace_regmap_async_complete_start(map->dev);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index ae989c57cd5e..2f5919ed91ab 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -143,22 +143,22 @@ static struct attribute_group topology_attr_group = {
143}; 143};
144 144
145/* Add/Remove cpu_topology interface for CPU device */ 145/* Add/Remove cpu_topology interface for CPU device */
146static int __cpuinit topology_add_dev(unsigned int cpu) 146static int topology_add_dev(unsigned int cpu)
147{ 147{
148 struct device *dev = get_cpu_device(cpu); 148 struct device *dev = get_cpu_device(cpu);
149 149
150 return sysfs_create_group(&dev->kobj, &topology_attr_group); 150 return sysfs_create_group(&dev->kobj, &topology_attr_group);
151} 151}
152 152
153static void __cpuinit topology_remove_dev(unsigned int cpu) 153static void topology_remove_dev(unsigned int cpu)
154{ 154{
155 struct device *dev = get_cpu_device(cpu); 155 struct device *dev = get_cpu_device(cpu);
156 156
157 sysfs_remove_group(&dev->kobj, &topology_attr_group); 157 sysfs_remove_group(&dev->kobj, &topology_attr_group);
158} 158}
159 159
160static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, 160static int topology_cpu_callback(struct notifier_block *nfb,
161 unsigned long action, void *hcpu) 161 unsigned long action, void *hcpu)
162{ 162{
163 unsigned int cpu = (unsigned long)hcpu; 163 unsigned int cpu = (unsigned long)hcpu;
164 int rc = 0; 164 int rc = 0;
@@ -178,7 +178,7 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
178 return notifier_from_errno(rc); 178 return notifier_from_errno(rc);
179} 179}
180 180
181static int __cpuinit topology_sysfs_init(void) 181static int topology_sysfs_init(void)
182{ 182{
183 int cpu; 183 int cpu;
184 int rc; 184 int rc;
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index b81ddfea1da0..e07a5fd58ad7 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -532,11 +532,11 @@ config BLK_DEV_RBD
532 If unsure, say N. 532 If unsure, say N.
533 533
534config BLK_DEV_RSXX 534config BLK_DEV_RSXX
535 tristate "IBM FlashSystem 70/80 PCIe SSD Device Driver" 535 tristate "IBM Flash Adapter 900GB Full Height PCIe Device Driver"
536 depends on PCI 536 depends on PCI
537 help 537 help
538 Device driver for IBM's high speed PCIe SSD 538 Device driver for IBM's high speed PCIe SSD
539 storage devices: FlashSystem-70 and FlashSystem-80. 539 storage device: Flash Adapter 900GB Full Height.
540 540
541 To compile this driver as a module, choose M here: the 541 To compile this driver as a module, choose M here: the
542 module will be called rsxx. 542 module will be called rsxx.
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 6608076dc39e..28c73ca320a8 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -659,6 +659,27 @@ void drbd_al_shrink(struct drbd_conf *mdev)
659 wake_up(&mdev->al_wait); 659 wake_up(&mdev->al_wait);
660} 660}
661 661
662int drbd_initialize_al(struct drbd_conf *mdev, void *buffer)
663{
664 struct al_transaction_on_disk *al = buffer;
665 struct drbd_md *md = &mdev->ldev->md;
666 sector_t al_base = md->md_offset + md->al_offset;
667 int al_size_4k = md->al_stripes * md->al_stripe_size_4k;
668 int i;
669
670 memset(al, 0, 4096);
671 al->magic = cpu_to_be32(DRBD_AL_MAGIC);
672 al->transaction_type = cpu_to_be16(AL_TR_INITIALIZED);
673 al->crc32c = cpu_to_be32(crc32c(0, al, 4096));
674
675 for (i = 0; i < al_size_4k; i++) {
676 int err = drbd_md_sync_page_io(mdev, mdev->ldev, al_base + i * 8, WRITE);
677 if (err)
678 return err;
679 }
680 return 0;
681}
682
662static int w_update_odbm(struct drbd_work *w, int unused) 683static int w_update_odbm(struct drbd_work *w, int unused)
663{ 684{
664 struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w); 685 struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w);
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index f943aacfdad8..2d7f608d181c 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -832,6 +832,7 @@ struct drbd_tconn { /* is a resource from the config file */
832 unsigned susp_nod:1; /* IO suspended because no data */ 832 unsigned susp_nod:1; /* IO suspended because no data */
833 unsigned susp_fen:1; /* IO suspended because fence peer handler runs */ 833 unsigned susp_fen:1; /* IO suspended because fence peer handler runs */
834 struct mutex cstate_mutex; /* Protects graceful disconnects */ 834 struct mutex cstate_mutex; /* Protects graceful disconnects */
835 unsigned int connect_cnt; /* Inc each time a connection is established */
835 836
836 unsigned long flags; 837 unsigned long flags;
837 struct net_conf *net_conf; /* content protected by rcu */ 838 struct net_conf *net_conf; /* content protected by rcu */
@@ -1132,6 +1133,7 @@ extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
1132void drbd_print_uuids(struct drbd_conf *mdev, const char *text); 1133void drbd_print_uuids(struct drbd_conf *mdev, const char *text);
1133 1134
1134extern void conn_md_sync(struct drbd_tconn *tconn); 1135extern void conn_md_sync(struct drbd_tconn *tconn);
1136extern void drbd_md_write(struct drbd_conf *mdev, void *buffer);
1135extern void drbd_md_sync(struct drbd_conf *mdev); 1137extern void drbd_md_sync(struct drbd_conf *mdev);
1136extern int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev); 1138extern int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev);
1137extern void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local); 1139extern 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);
1466extern void drbd_resume_io(struct drbd_conf *mdev); 1468extern void drbd_resume_io(struct drbd_conf *mdev);
1467extern char *ppsize(char *buf, unsigned long long size); 1469extern char *ppsize(char *buf, unsigned long long size);
1468extern sector_t drbd_new_dev_size(struct drbd_conf *, struct drbd_backing_dev *, sector_t, int); 1470extern sector_t drbd_new_dev_size(struct drbd_conf *, struct drbd_backing_dev *, sector_t, int);
1469enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew = 2 }; 1471enum determine_dev_size {
1470extern enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local); 1472 DS_ERROR_SHRINK = -3,
1473 DS_ERROR_SPACE_MD = -2,
1474 DS_ERROR = -1,
1475 DS_UNCHANGED = 0,
1476 DS_SHRUNK = 1,
1477 DS_GREW = 2
1478};
1479extern enum determine_dev_size
1480drbd_determine_dev_size(struct drbd_conf *, enum dds_flags, struct resize_parms *) __must_hold(local);
1471extern void resync_after_online_grow(struct drbd_conf *); 1481extern void resync_after_online_grow(struct drbd_conf *);
1472extern void drbd_reconsider_max_bio_size(struct drbd_conf *mdev); 1482extern void drbd_reconsider_max_bio_size(struct drbd_conf *mdev);
1473extern enum drbd_state_rv drbd_set_role(struct drbd_conf *mdev, 1483extern 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,
1633#define drbd_set_out_of_sync(mdev, sector, size) \ 1643#define drbd_set_out_of_sync(mdev, sector, size) \
1634 __drbd_set_out_of_sync(mdev, sector, size, __FILE__, __LINE__) 1644 __drbd_set_out_of_sync(mdev, sector, size, __FILE__, __LINE__)
1635extern void drbd_al_shrink(struct drbd_conf *mdev); 1645extern void drbd_al_shrink(struct drbd_conf *mdev);
1646extern int drbd_initialize_al(struct drbd_conf *, void *);
1636 1647
1637/* drbd_nl.c */ 1648/* drbd_nl.c */
1638/* state info broadcast */ 1649/* state info broadcast */
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index a5dca6affcbb..55635edf563b 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2762,8 +2762,6 @@ int __init drbd_init(void)
2762 /* 2762 /*
2763 * allocate all necessary structs 2763 * allocate all necessary structs
2764 */ 2764 */
2765 err = -ENOMEM;
2766
2767 init_waitqueue_head(&drbd_pp_wait); 2765 init_waitqueue_head(&drbd_pp_wait);
2768 2766
2769 drbd_proc = NULL; /* play safe for drbd_cleanup */ 2767 drbd_proc = NULL; /* play safe for drbd_cleanup */
@@ -2773,6 +2771,7 @@ int __init drbd_init(void)
2773 if (err) 2771 if (err)
2774 goto fail; 2772 goto fail;
2775 2773
2774 err = -ENOMEM;
2776 drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, &drbd_proc_fops, NULL); 2775 drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, &drbd_proc_fops, NULL);
2777 if (!drbd_proc) { 2776 if (!drbd_proc) {
2778 printk(KERN_ERR "drbd: unable to register proc file\n"); 2777 printk(KERN_ERR "drbd: unable to register proc file\n");
@@ -2803,7 +2802,6 @@ int __init drbd_init(void)
2803fail: 2802fail:
2804 drbd_cleanup(); 2803 drbd_cleanup();
2805 if (err == -ENOMEM) 2804 if (err == -ENOMEM)
2806 /* currently always the case */
2807 printk(KERN_ERR "drbd: ran out of memory\n"); 2805 printk(KERN_ERR "drbd: ran out of memory\n");
2808 else 2806 else
2809 printk(KERN_ERR "drbd: initialization failure\n"); 2807 printk(KERN_ERR "drbd: initialization failure\n");
@@ -2881,34 +2879,14 @@ struct meta_data_on_disk {
2881 u8 reserved_u8[4096 - (7*8 + 10*4)]; 2879 u8 reserved_u8[4096 - (7*8 + 10*4)];
2882} __packed; 2880} __packed;
2883 2881
2884/** 2882
2885 * drbd_md_sync() - Writes the meta data super block if the MD_DIRTY flag bit is set 2883
2886 * @mdev: DRBD device. 2884void drbd_md_write(struct drbd_conf *mdev, void *b)
2887 */
2888void drbd_md_sync(struct drbd_conf *mdev)
2889{ 2885{
2890 struct meta_data_on_disk *buffer; 2886 struct meta_data_on_disk *buffer = b;
2891 sector_t sector; 2887 sector_t sector;
2892 int i; 2888 int i;
2893 2889
2894 /* Don't accidentally change the DRBD meta data layout. */
2895 BUILD_BUG_ON(UI_SIZE != 4);
2896 BUILD_BUG_ON(sizeof(struct meta_data_on_disk) != 4096);
2897
2898 del_timer(&mdev->md_sync_timer);
2899 /* timer may be rearmed by drbd_md_mark_dirty() now. */
2900 if (!test_and_clear_bit(MD_DIRTY, &mdev->flags))
2901 return;
2902
2903 /* We use here D_FAILED and not D_ATTACHING because we try to write
2904 * metadata even if we detach due to a disk failure! */
2905 if (!get_ldev_if_state(mdev, D_FAILED))
2906 return;
2907
2908 buffer = drbd_md_get_buffer(mdev);
2909 if (!buffer)
2910 goto out;
2911
2912 memset(buffer, 0, sizeof(*buffer)); 2890 memset(buffer, 0, sizeof(*buffer));
2913 2891
2914 buffer->la_size_sect = cpu_to_be64(drbd_get_capacity(mdev->this_bdev)); 2892 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)
2937 dev_err(DEV, "meta data update failed!\n"); 2915 dev_err(DEV, "meta data update failed!\n");
2938 drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR); 2916 drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
2939 } 2917 }
2918}
2919
2920/**
2921 * drbd_md_sync() - Writes the meta data super block if the MD_DIRTY flag bit is set
2922 * @mdev: DRBD device.
2923 */
2924void drbd_md_sync(struct drbd_conf *mdev)
2925{
2926 struct meta_data_on_disk *buffer;
2927
2928 /* Don't accidentally change the DRBD meta data layout. */
2929 BUILD_BUG_ON(UI_SIZE != 4);
2930 BUILD_BUG_ON(sizeof(struct meta_data_on_disk) != 4096);
2931
2932 del_timer(&mdev->md_sync_timer);
2933 /* timer may be rearmed by drbd_md_mark_dirty() now. */
2934 if (!test_and_clear_bit(MD_DIRTY, &mdev->flags))
2935 return;
2936
2937 /* We use here D_FAILED and not D_ATTACHING because we try to write
2938 * metadata even if we detach due to a disk failure! */
2939 if (!get_ldev_if_state(mdev, D_FAILED))
2940 return;
2941
2942 buffer = drbd_md_get_buffer(mdev);
2943 if (!buffer)
2944 goto out;
2945
2946 drbd_md_write(mdev, buffer);
2940 2947
2941 /* Update mdev->ldev->md.la_size_sect, 2948 /* Update mdev->ldev->md.la_size_sect,
2942 * since we updated it on metadata. */ 2949 * since we updated it on metadata. */
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 9e3f441e7e84..8cc1e640f485 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -417,6 +417,7 @@ static enum drbd_fencing_p highest_fencing_policy(struct drbd_tconn *tconn)
417 417
418bool conn_try_outdate_peer(struct drbd_tconn *tconn) 418bool conn_try_outdate_peer(struct drbd_tconn *tconn)
419{ 419{
420 unsigned int connect_cnt;
420 union drbd_state mask = { }; 421 union drbd_state mask = { };
421 union drbd_state val = { }; 422 union drbd_state val = { };
422 enum drbd_fencing_p fp; 423 enum drbd_fencing_p fp;
@@ -428,6 +429,10 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
428 return false; 429 return false;
429 } 430 }
430 431
432 spin_lock_irq(&tconn->req_lock);
433 connect_cnt = tconn->connect_cnt;
434 spin_unlock_irq(&tconn->req_lock);
435
431 fp = highest_fencing_policy(tconn); 436 fp = highest_fencing_policy(tconn);
432 switch (fp) { 437 switch (fp) {
433 case FP_NOT_AVAIL: 438 case FP_NOT_AVAIL:
@@ -492,8 +497,14 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
492 here, because we might were able to re-establish the connection in the 497 here, because we might were able to re-establish the connection in the
493 meantime. */ 498 meantime. */
494 spin_lock_irq(&tconn->req_lock); 499 spin_lock_irq(&tconn->req_lock);
495 if (tconn->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &tconn->flags)) 500 if (tconn->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &tconn->flags)) {
496 _conn_request_state(tconn, mask, val, CS_VERBOSE); 501 if (tconn->connect_cnt != connect_cnt)
502 /* In case the connection was established and droped
503 while the fence-peer handler was running, ignore it */
504 conn_info(tconn, "Ignoring fence-peer exit code\n");
505 else
506 _conn_request_state(tconn, mask, val, CS_VERBOSE);
507 }
497 spin_unlock_irq(&tconn->req_lock); 508 spin_unlock_irq(&tconn->req_lock);
498 509
499 return conn_highest_pdsk(tconn) <= D_OUTDATED; 510 return conn_highest_pdsk(tconn) <= D_OUTDATED;
@@ -816,15 +827,20 @@ void drbd_resume_io(struct drbd_conf *mdev)
816 * Returns 0 on success, negative return values indicate errors. 827 * Returns 0 on success, negative return values indicate errors.
817 * You should call drbd_md_sync() after calling this function. 828 * You should call drbd_md_sync() after calling this function.
818 */ 829 */
819enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds_flags flags) __must_hold(local) 830enum determine_dev_size
831drbd_determine_dev_size(struct drbd_conf *mdev, enum dds_flags flags, struct resize_parms *rs) __must_hold(local)
820{ 832{
821 sector_t prev_first_sect, prev_size; /* previous meta location */ 833 sector_t prev_first_sect, prev_size; /* previous meta location */
822 sector_t la_size_sect, u_size; 834 sector_t la_size_sect, u_size;
835 struct drbd_md *md = &mdev->ldev->md;
836 u32 prev_al_stripe_size_4k;
837 u32 prev_al_stripes;
823 sector_t size; 838 sector_t size;
824 char ppb[10]; 839 char ppb[10];
840 void *buffer;
825 841
826 int md_moved, la_size_changed; 842 int md_moved, la_size_changed;
827 enum determine_dev_size rv = unchanged; 843 enum determine_dev_size rv = DS_UNCHANGED;
828 844
829 /* race: 845 /* race:
830 * application request passes inc_ap_bio, 846 * application request passes inc_ap_bio,
@@ -836,6 +852,11 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
836 * still lock the act_log to not trigger ASSERTs there. 852 * still lock the act_log to not trigger ASSERTs there.
837 */ 853 */
838 drbd_suspend_io(mdev); 854 drbd_suspend_io(mdev);
855 buffer = drbd_md_get_buffer(mdev); /* Lock meta-data IO */
856 if (!buffer) {
857 drbd_resume_io(mdev);
858 return DS_ERROR;
859 }
839 860
840 /* no wait necessary anymore, actually we could assert that */ 861 /* no wait necessary anymore, actually we could assert that */
841 wait_event(mdev->al_wait, lc_try_lock(mdev->act_log)); 862 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
844 prev_size = mdev->ldev->md.md_size_sect; 865 prev_size = mdev->ldev->md.md_size_sect;
845 la_size_sect = mdev->ldev->md.la_size_sect; 866 la_size_sect = mdev->ldev->md.la_size_sect;
846 867
847 /* TODO: should only be some assert here, not (re)init... */ 868 if (rs) {
869 /* rs is non NULL if we should change the AL layout only */
870
871 prev_al_stripes = md->al_stripes;
872 prev_al_stripe_size_4k = md->al_stripe_size_4k;
873
874 md->al_stripes = rs->al_stripes;
875 md->al_stripe_size_4k = rs->al_stripe_size / 4;
876 md->al_size_4k = (u64)rs->al_stripes * rs->al_stripe_size / 4;
877 }
878
848 drbd_md_set_sector_offsets(mdev, mdev->ldev); 879 drbd_md_set_sector_offsets(mdev, mdev->ldev);
849 880
850 rcu_read_lock(); 881 rcu_read_lock();
@@ -852,6 +883,21 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
852 rcu_read_unlock(); 883 rcu_read_unlock();
853 size = drbd_new_dev_size(mdev, mdev->ldev, u_size, flags & DDSF_FORCED); 884 size = drbd_new_dev_size(mdev, mdev->ldev, u_size, flags & DDSF_FORCED);
854 885
886 if (size < la_size_sect) {
887 if (rs && u_size == 0) {
888 /* Remove "rs &&" later. This check should always be active, but
889 right now the receiver expects the permissive behavior */
890 dev_warn(DEV, "Implicit shrink not allowed. "
891 "Use --size=%llus for explicit shrink.\n",
892 (unsigned long long)size);
893 rv = DS_ERROR_SHRINK;
894 }
895 if (u_size > size)
896 rv = DS_ERROR_SPACE_MD;
897 if (rv != DS_UNCHANGED)
898 goto err_out;
899 }
900
855 if (drbd_get_capacity(mdev->this_bdev) != size || 901 if (drbd_get_capacity(mdev->this_bdev) != size ||
856 drbd_bm_capacity(mdev) != size) { 902 drbd_bm_capacity(mdev) != size) {
857 int err; 903 int err;
@@ -867,7 +913,7 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
867 "Leaving size unchanged at size = %lu KB\n", 913 "Leaving size unchanged at size = %lu KB\n",
868 (unsigned long)size); 914 (unsigned long)size);
869 } 915 }
870 rv = dev_size_error; 916 rv = DS_ERROR;
871 } 917 }
872 /* racy, see comments above. */ 918 /* racy, see comments above. */
873 drbd_set_my_capacity(mdev, size); 919 drbd_set_my_capacity(mdev, size);
@@ -875,38 +921,57 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
875 dev_info(DEV, "size = %s (%llu KB)\n", ppsize(ppb, size>>1), 921 dev_info(DEV, "size = %s (%llu KB)\n", ppsize(ppb, size>>1),
876 (unsigned long long)size>>1); 922 (unsigned long long)size>>1);
877 } 923 }
878 if (rv == dev_size_error) 924 if (rv <= DS_ERROR)
879 goto out; 925 goto err_out;
880 926
881 la_size_changed = (la_size_sect != mdev->ldev->md.la_size_sect); 927 la_size_changed = (la_size_sect != mdev->ldev->md.la_size_sect);
882 928
883 md_moved = prev_first_sect != drbd_md_first_sector(mdev->ldev) 929 md_moved = prev_first_sect != drbd_md_first_sector(mdev->ldev)
884 || prev_size != mdev->ldev->md.md_size_sect; 930 || prev_size != mdev->ldev->md.md_size_sect;
885 931
886 if (la_size_changed || md_moved) { 932 if (la_size_changed || md_moved || rs) {
887 int err; 933 u32 prev_flags;
888 934
889 drbd_al_shrink(mdev); /* All extents inactive. */ 935 drbd_al_shrink(mdev); /* All extents inactive. */
936
937 prev_flags = md->flags;
938 md->flags &= ~MDF_PRIMARY_IND;
939 drbd_md_write(mdev, buffer);
940
890 dev_info(DEV, "Writing the whole bitmap, %s\n", 941 dev_info(DEV, "Writing the whole bitmap, %s\n",
891 la_size_changed && md_moved ? "size changed and md moved" : 942 la_size_changed && md_moved ? "size changed and md moved" :
892 la_size_changed ? "size changed" : "md moved"); 943 la_size_changed ? "size changed" : "md moved");
893 /* next line implicitly does drbd_suspend_io()+drbd_resume_io() */ 944 /* next line implicitly does drbd_suspend_io()+drbd_resume_io() */
894 err = drbd_bitmap_io(mdev, md_moved ? &drbd_bm_write_all : &drbd_bm_write, 945 drbd_bitmap_io(mdev, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
895 "size changed", BM_LOCKED_MASK); 946 "size changed", BM_LOCKED_MASK);
896 if (err) { 947 drbd_initialize_al(mdev, buffer);
897 rv = dev_size_error; 948
898 goto out; 949 md->flags = prev_flags;
899 } 950 drbd_md_write(mdev, buffer);
900 drbd_md_mark_dirty(mdev); 951
952 if (rs)
953 dev_info(DEV, "Changed AL layout to al-stripes = %d, al-stripe-size-kB = %d\n",
954 md->al_stripes, md->al_stripe_size_4k * 4);
901 } 955 }
902 956
903 if (size > la_size_sect) 957 if (size > la_size_sect)
904 rv = grew; 958 rv = DS_GREW;
905 if (size < la_size_sect) 959 if (size < la_size_sect)
906 rv = shrunk; 960 rv = DS_SHRUNK;
907out: 961
962 if (0) {
963 err_out:
964 if (rs) {
965 md->al_stripes = prev_al_stripes;
966 md->al_stripe_size_4k = prev_al_stripe_size_4k;
967 md->al_size_4k = (u64)prev_al_stripes * prev_al_stripe_size_4k;
968
969 drbd_md_set_sector_offsets(mdev, mdev->ldev);
970 }
971 }
908 lc_unlock(mdev->act_log); 972 lc_unlock(mdev->act_log);
909 wake_up(&mdev->al_wait); 973 wake_up(&mdev->al_wait);
974 drbd_md_put_buffer(mdev);
910 drbd_resume_io(mdev); 975 drbd_resume_io(mdev);
911 976
912 return rv; 977 return rv;
@@ -1607,11 +1672,11 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
1607 !drbd_md_test_flag(mdev->ldev, MDF_CONNECTED_IND)) 1672 !drbd_md_test_flag(mdev->ldev, MDF_CONNECTED_IND))
1608 set_bit(USE_DEGR_WFC_T, &mdev->flags); 1673 set_bit(USE_DEGR_WFC_T, &mdev->flags);
1609 1674
1610 dd = drbd_determine_dev_size(mdev, 0); 1675 dd = drbd_determine_dev_size(mdev, 0, NULL);
1611 if (dd == dev_size_error) { 1676 if (dd <= DS_ERROR) {
1612 retcode = ERR_NOMEM_BITMAP; 1677 retcode = ERR_NOMEM_BITMAP;
1613 goto force_diskless_dec; 1678 goto force_diskless_dec;
1614 } else if (dd == grew) 1679 } else if (dd == DS_GREW)
1615 set_bit(RESYNC_AFTER_NEG, &mdev->flags); 1680 set_bit(RESYNC_AFTER_NEG, &mdev->flags);
1616 1681
1617 if (drbd_md_test_flag(mdev->ldev, MDF_FULL_SYNC) || 1682 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)
2305 struct drbd_conf *mdev; 2370 struct drbd_conf *mdev;
2306 enum drbd_ret_code retcode; 2371 enum drbd_ret_code retcode;
2307 enum determine_dev_size dd; 2372 enum determine_dev_size dd;
2373 bool change_al_layout = false;
2308 enum dds_flags ddsf; 2374 enum dds_flags ddsf;
2309 sector_t u_size; 2375 sector_t u_size;
2310 int err; 2376 int err;
@@ -2315,31 +2381,33 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
2315 if (retcode != NO_ERROR) 2381 if (retcode != NO_ERROR)
2316 goto fail; 2382 goto fail;
2317 2383
2384 mdev = adm_ctx.mdev;
2385 if (!get_ldev(mdev)) {
2386 retcode = ERR_NO_DISK;
2387 goto fail;
2388 }
2389
2318 memset(&rs, 0, sizeof(struct resize_parms)); 2390 memset(&rs, 0, sizeof(struct resize_parms));
2391 rs.al_stripes = mdev->ldev->md.al_stripes;
2392 rs.al_stripe_size = mdev->ldev->md.al_stripe_size_4k * 4;
2319 if (info->attrs[DRBD_NLA_RESIZE_PARMS]) { 2393 if (info->attrs[DRBD_NLA_RESIZE_PARMS]) {
2320 err = resize_parms_from_attrs(&rs, info); 2394 err = resize_parms_from_attrs(&rs, info);
2321 if (err) { 2395 if (err) {
2322 retcode = ERR_MANDATORY_TAG; 2396 retcode = ERR_MANDATORY_TAG;
2323 drbd_msg_put_info(from_attrs_err_to_txt(err)); 2397 drbd_msg_put_info(from_attrs_err_to_txt(err));
2324 goto fail; 2398 goto fail_ldev;
2325 } 2399 }
2326 } 2400 }
2327 2401
2328 mdev = adm_ctx.mdev;
2329 if (mdev->state.conn > C_CONNECTED) { 2402 if (mdev->state.conn > C_CONNECTED) {
2330 retcode = ERR_RESIZE_RESYNC; 2403 retcode = ERR_RESIZE_RESYNC;
2331 goto fail; 2404 goto fail_ldev;
2332 } 2405 }
2333 2406
2334 if (mdev->state.role == R_SECONDARY && 2407 if (mdev->state.role == R_SECONDARY &&
2335 mdev->state.peer == R_SECONDARY) { 2408 mdev->state.peer == R_SECONDARY) {
2336 retcode = ERR_NO_PRIMARY; 2409 retcode = ERR_NO_PRIMARY;
2337 goto fail; 2410 goto fail_ldev;
2338 }
2339
2340 if (!get_ldev(mdev)) {
2341 retcode = ERR_NO_DISK;
2342 goto fail;
2343 } 2411 }
2344 2412
2345 if (rs.no_resync && mdev->tconn->agreed_pro_version < 93) { 2413 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)
2358 } 2426 }
2359 } 2427 }
2360 2428
2429 if (mdev->ldev->md.al_stripes != rs.al_stripes ||
2430 mdev->ldev->md.al_stripe_size_4k != rs.al_stripe_size / 4) {
2431 u32 al_size_k = rs.al_stripes * rs.al_stripe_size;
2432
2433 if (al_size_k > (16 * 1024 * 1024)) {
2434 retcode = ERR_MD_LAYOUT_TOO_BIG;
2435 goto fail_ldev;
2436 }
2437
2438 if (al_size_k < MD_32kB_SECT/2) {
2439 retcode = ERR_MD_LAYOUT_TOO_SMALL;
2440 goto fail_ldev;
2441 }
2442
2443 if (mdev->state.conn != C_CONNECTED) {
2444 retcode = ERR_MD_LAYOUT_CONNECTED;
2445 goto fail_ldev;
2446 }
2447
2448 change_al_layout = true;
2449 }
2450
2361 if (mdev->ldev->known_size != drbd_get_capacity(mdev->ldev->backing_bdev)) 2451 if (mdev->ldev->known_size != drbd_get_capacity(mdev->ldev->backing_bdev))
2362 mdev->ldev->known_size = drbd_get_capacity(mdev->ldev->backing_bdev); 2452 mdev->ldev->known_size = drbd_get_capacity(mdev->ldev->backing_bdev);
2363 2453
@@ -2373,16 +2463,22 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
2373 } 2463 }
2374 2464
2375 ddsf = (rs.resize_force ? DDSF_FORCED : 0) | (rs.no_resync ? DDSF_NO_RESYNC : 0); 2465 ddsf = (rs.resize_force ? DDSF_FORCED : 0) | (rs.no_resync ? DDSF_NO_RESYNC : 0);
2376 dd = drbd_determine_dev_size(mdev, ddsf); 2466 dd = drbd_determine_dev_size(mdev, ddsf, change_al_layout ? &rs : NULL);
2377 drbd_md_sync(mdev); 2467 drbd_md_sync(mdev);
2378 put_ldev(mdev); 2468 put_ldev(mdev);
2379 if (dd == dev_size_error) { 2469 if (dd == DS_ERROR) {
2380 retcode = ERR_NOMEM_BITMAP; 2470 retcode = ERR_NOMEM_BITMAP;
2381 goto fail; 2471 goto fail;
2472 } else if (dd == DS_ERROR_SPACE_MD) {
2473 retcode = ERR_MD_LAYOUT_NO_FIT;
2474 goto fail;
2475 } else if (dd == DS_ERROR_SHRINK) {
2476 retcode = ERR_IMPLICIT_SHRINK;
2477 goto fail;
2382 } 2478 }
2383 2479
2384 if (mdev->state.conn == C_CONNECTED) { 2480 if (mdev->state.conn == C_CONNECTED) {
2385 if (dd == grew) 2481 if (dd == DS_GREW)
2386 set_bit(RESIZE_PENDING, &mdev->flags); 2482 set_bit(RESIZE_PENDING, &mdev->flags);
2387 2483
2388 drbd_send_uuids(mdev); 2484 drbd_send_uuids(mdev);
@@ -2658,7 +2754,6 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
2658 const struct sib_info *sib) 2754 const struct sib_info *sib)
2659{ 2755{
2660 struct state_info *si = NULL; /* for sizeof(si->member); */ 2756 struct state_info *si = NULL; /* for sizeof(si->member); */
2661 struct net_conf *nc;
2662 struct nlattr *nla; 2757 struct nlattr *nla;
2663 int got_ldev; 2758 int got_ldev;
2664 int err = 0; 2759 int err = 0;
@@ -2688,13 +2783,19 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
2688 goto nla_put_failure; 2783 goto nla_put_failure;
2689 2784
2690 rcu_read_lock(); 2785 rcu_read_lock();
2691 if (got_ldev) 2786 if (got_ldev) {
2692 if (disk_conf_to_skb(skb, rcu_dereference(mdev->ldev->disk_conf), exclude_sensitive)) 2787 struct disk_conf *disk_conf;
2693 goto nla_put_failure;
2694 2788
2695 nc = rcu_dereference(mdev->tconn->net_conf); 2789 disk_conf = rcu_dereference(mdev->ldev->disk_conf);
2696 if (nc) 2790 err = disk_conf_to_skb(skb, disk_conf, exclude_sensitive);
2697 err = net_conf_to_skb(skb, nc, exclude_sensitive); 2791 }
2792 if (!err) {
2793 struct net_conf *nc;
2794
2795 nc = rcu_dereference(mdev->tconn->net_conf);
2796 if (nc)
2797 err = net_conf_to_skb(skb, nc, exclude_sensitive);
2798 }
2698 rcu_read_unlock(); 2799 rcu_read_unlock();
2699 if (err) 2800 if (err)
2700 goto nla_put_failure; 2801 goto nla_put_failure;
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 4222affff488..cc29cd3bf78b 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1039,6 +1039,8 @@ randomize:
1039 rcu_read_lock(); 1039 rcu_read_lock();
1040 idr_for_each_entry(&tconn->volumes, mdev, vnr) { 1040 idr_for_each_entry(&tconn->volumes, mdev, vnr) {
1041 kref_get(&mdev->kref); 1041 kref_get(&mdev->kref);
1042 rcu_read_unlock();
1043
1042 /* Prevent a race between resync-handshake and 1044 /* Prevent a race between resync-handshake and
1043 * being promoted to Primary. 1045 * being promoted to Primary.
1044 * 1046 *
@@ -1049,8 +1051,6 @@ randomize:
1049 mutex_lock(mdev->state_mutex); 1051 mutex_lock(mdev->state_mutex);
1050 mutex_unlock(mdev->state_mutex); 1052 mutex_unlock(mdev->state_mutex);
1051 1053
1052 rcu_read_unlock();
1053
1054 if (discard_my_data) 1054 if (discard_my_data)
1055 set_bit(DISCARD_MY_DATA, &mdev->flags); 1055 set_bit(DISCARD_MY_DATA, &mdev->flags);
1056 else 1056 else
@@ -3545,7 +3545,7 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
3545{ 3545{
3546 struct drbd_conf *mdev; 3546 struct drbd_conf *mdev;
3547 struct p_sizes *p = pi->data; 3547 struct p_sizes *p = pi->data;
3548 enum determine_dev_size dd = unchanged; 3548 enum determine_dev_size dd = DS_UNCHANGED;
3549 sector_t p_size, p_usize, my_usize; 3549 sector_t p_size, p_usize, my_usize;
3550 int ldsc = 0; /* local disk size changed */ 3550 int ldsc = 0; /* local disk size changed */
3551 enum dds_flags ddsf; 3551 enum dds_flags ddsf;
@@ -3617,9 +3617,9 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
3617 3617
3618 ddsf = be16_to_cpu(p->dds_flags); 3618 ddsf = be16_to_cpu(p->dds_flags);
3619 if (get_ldev(mdev)) { 3619 if (get_ldev(mdev)) {
3620 dd = drbd_determine_dev_size(mdev, ddsf); 3620 dd = drbd_determine_dev_size(mdev, ddsf, NULL);
3621 put_ldev(mdev); 3621 put_ldev(mdev);
3622 if (dd == dev_size_error) 3622 if (dd == DS_ERROR)
3623 return -EIO; 3623 return -EIO;
3624 drbd_md_sync(mdev); 3624 drbd_md_sync(mdev);
3625 } else { 3625 } else {
@@ -3647,7 +3647,7 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
3647 drbd_send_sizes(mdev, 0, ddsf); 3647 drbd_send_sizes(mdev, 0, ddsf);
3648 } 3648 }
3649 if (test_and_clear_bit(RESIZE_PENDING, &mdev->flags) || 3649 if (test_and_clear_bit(RESIZE_PENDING, &mdev->flags) ||
3650 (dd == grew && mdev->state.conn == C_CONNECTED)) { 3650 (dd == DS_GREW && mdev->state.conn == C_CONNECTED)) {
3651 if (mdev->state.pdsk >= D_INCONSISTENT && 3651 if (mdev->state.pdsk >= D_INCONSISTENT &&
3652 mdev->state.disk >= D_INCONSISTENT) { 3652 mdev->state.disk >= D_INCONSISTENT) {
3653 if (ddsf & DDSF_NO_RESYNC) 3653 if (ddsf & DDSF_NO_RESYNC)
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 90c5be2b1d30..216d47b7e88b 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -1115,8 +1115,10 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
1115 drbd_thread_restart_nowait(&mdev->tconn->receiver); 1115 drbd_thread_restart_nowait(&mdev->tconn->receiver);
1116 1116
1117 /* Resume AL writing if we get a connection */ 1117 /* Resume AL writing if we get a connection */
1118 if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) 1118 if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) {
1119 drbd_resume_al(mdev); 1119 drbd_resume_al(mdev);
1120 mdev->tconn->connect_cnt++;
1121 }
1120 1122
1121 /* remember last attach time so request_timer_fn() won't 1123 /* remember last attach time so request_timer_fn() won't
1122 * kill newly established sessions while we are still trying to thaw 1124 * kill newly established sessions while we are still trying to thaw
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 5af21f2db29c..6e85e21445eb 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -31,6 +31,8 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/bitops.h> 32#include <linux/bitops.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/debugfs.h>
35#include <linux/seq_file.h>
34 36
35#include <linux/genhd.h> 37#include <linux/genhd.h>
36#include <linux/idr.h> 38#include <linux/idr.h>
@@ -39,8 +41,9 @@
39#include "rsxx_cfg.h" 41#include "rsxx_cfg.h"
40 42
41#define NO_LEGACY 0 43#define NO_LEGACY 0
44#define SYNC_START_TIMEOUT (10 * 60) /* 10 minutes */
42 45
43MODULE_DESCRIPTION("IBM FlashSystem 70/80 PCIe SSD Device Driver"); 46MODULE_DESCRIPTION("IBM Flash Adapter 900GB Full Height Device Driver");
44MODULE_AUTHOR("Joshua Morris/Philip Kelleher, IBM"); 47MODULE_AUTHOR("Joshua Morris/Philip Kelleher, IBM");
45MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
46MODULE_VERSION(DRIVER_VERSION); 49MODULE_VERSION(DRIVER_VERSION);
@@ -49,9 +52,282 @@ static unsigned int force_legacy = NO_LEGACY;
49module_param(force_legacy, uint, 0444); 52module_param(force_legacy, uint, 0444);
50MODULE_PARM_DESC(force_legacy, "Force the use of legacy type PCI interrupts"); 53MODULE_PARM_DESC(force_legacy, "Force the use of legacy type PCI interrupts");
51 54
55static unsigned int sync_start = 1;
56module_param(sync_start, uint, 0444);
57MODULE_PARM_DESC(sync_start, "On by Default: Driver load will not complete "
58 "until the card startup has completed.");
59
52static DEFINE_IDA(rsxx_disk_ida); 60static DEFINE_IDA(rsxx_disk_ida);
53static DEFINE_SPINLOCK(rsxx_ida_lock); 61static DEFINE_SPINLOCK(rsxx_ida_lock);
54 62
63/* --------------------Debugfs Setup ------------------- */
64
65struct rsxx_cram {
66 u32 f_pos;
67 u32 offset;
68 void *i_private;
69};
70
71static int rsxx_attr_pci_regs_show(struct seq_file *m, void *p)
72{
73 struct rsxx_cardinfo *card = m->private;
74
75 seq_printf(m, "HWID 0x%08x\n",
76 ioread32(card->regmap + HWID));
77 seq_printf(m, "SCRATCH 0x%08x\n",
78 ioread32(card->regmap + SCRATCH));
79 seq_printf(m, "IER 0x%08x\n",
80 ioread32(card->regmap + IER));
81 seq_printf(m, "IPR 0x%08x\n",
82 ioread32(card->regmap + IPR));
83 seq_printf(m, "CREG_CMD 0x%08x\n",
84 ioread32(card->regmap + CREG_CMD));
85 seq_printf(m, "CREG_ADD 0x%08x\n",
86 ioread32(card->regmap + CREG_ADD));
87 seq_printf(m, "CREG_CNT 0x%08x\n",
88 ioread32(card->regmap + CREG_CNT));
89 seq_printf(m, "CREG_STAT 0x%08x\n",
90 ioread32(card->regmap + CREG_STAT));
91 seq_printf(m, "CREG_DATA0 0x%08x\n",
92 ioread32(card->regmap + CREG_DATA0));
93 seq_printf(m, "CREG_DATA1 0x%08x\n",
94 ioread32(card->regmap + CREG_DATA1));
95 seq_printf(m, "CREG_DATA2 0x%08x\n",
96 ioread32(card->regmap + CREG_DATA2));
97 seq_printf(m, "CREG_DATA3 0x%08x\n",
98 ioread32(card->regmap + CREG_DATA3));
99 seq_printf(m, "CREG_DATA4 0x%08x\n",
100 ioread32(card->regmap + CREG_DATA4));
101 seq_printf(m, "CREG_DATA5 0x%08x\n",
102 ioread32(card->regmap + CREG_DATA5));
103 seq_printf(m, "CREG_DATA6 0x%08x\n",
104 ioread32(card->regmap + CREG_DATA6));
105 seq_printf(m, "CREG_DATA7 0x%08x\n",
106 ioread32(card->regmap + CREG_DATA7));
107 seq_printf(m, "INTR_COAL 0x%08x\n",
108 ioread32(card->regmap + INTR_COAL));
109 seq_printf(m, "HW_ERROR 0x%08x\n",
110 ioread32(card->regmap + HW_ERROR));
111 seq_printf(m, "DEBUG0 0x%08x\n",
112 ioread32(card->regmap + PCI_DEBUG0));
113 seq_printf(m, "DEBUG1 0x%08x\n",
114 ioread32(card->regmap + PCI_DEBUG1));
115 seq_printf(m, "DEBUG2 0x%08x\n",
116 ioread32(card->regmap + PCI_DEBUG2));
117 seq_printf(m, "DEBUG3 0x%08x\n",
118 ioread32(card->regmap + PCI_DEBUG3));
119 seq_printf(m, "DEBUG4 0x%08x\n",
120 ioread32(card->regmap + PCI_DEBUG4));
121 seq_printf(m, "DEBUG5 0x%08x\n",
122 ioread32(card->regmap + PCI_DEBUG5));
123 seq_printf(m, "DEBUG6 0x%08x\n",
124 ioread32(card->regmap + PCI_DEBUG6));
125 seq_printf(m, "DEBUG7 0x%08x\n",
126 ioread32(card->regmap + PCI_DEBUG7));
127 seq_printf(m, "RECONFIG 0x%08x\n",
128 ioread32(card->regmap + PCI_RECONFIG));
129
130 return 0;
131}
132
133static int rsxx_attr_stats_show(struct seq_file *m, void *p)
134{
135 struct rsxx_cardinfo *card = m->private;
136 int i;
137
138 for (i = 0; i < card->n_targets; i++) {
139 seq_printf(m, "Ctrl %d CRC Errors = %d\n",
140 i, card->ctrl[i].stats.crc_errors);
141 seq_printf(m, "Ctrl %d Hard Errors = %d\n",
142 i, card->ctrl[i].stats.hard_errors);
143 seq_printf(m, "Ctrl %d Soft Errors = %d\n",
144 i, card->ctrl[i].stats.soft_errors);
145 seq_printf(m, "Ctrl %d Writes Issued = %d\n",
146 i, card->ctrl[i].stats.writes_issued);
147 seq_printf(m, "Ctrl %d Writes Failed = %d\n",
148 i, card->ctrl[i].stats.writes_failed);
149 seq_printf(m, "Ctrl %d Reads Issued = %d\n",
150 i, card->ctrl[i].stats.reads_issued);
151 seq_printf(m, "Ctrl %d Reads Failed = %d\n",
152 i, card->ctrl[i].stats.reads_failed);
153 seq_printf(m, "Ctrl %d Reads Retried = %d\n",
154 i, card->ctrl[i].stats.reads_retried);
155 seq_printf(m, "Ctrl %d Discards Issued = %d\n",
156 i, card->ctrl[i].stats.discards_issued);
157 seq_printf(m, "Ctrl %d Discards Failed = %d\n",
158 i, card->ctrl[i].stats.discards_failed);
159 seq_printf(m, "Ctrl %d DMA SW Errors = %d\n",
160 i, card->ctrl[i].stats.dma_sw_err);
161 seq_printf(m, "Ctrl %d DMA HW Faults = %d\n",
162 i, card->ctrl[i].stats.dma_hw_fault);
163 seq_printf(m, "Ctrl %d DMAs Cancelled = %d\n",
164 i, card->ctrl[i].stats.dma_cancelled);
165 seq_printf(m, "Ctrl %d SW Queue Depth = %d\n",
166 i, card->ctrl[i].stats.sw_q_depth);
167 seq_printf(m, "Ctrl %d HW Queue Depth = %d\n",
168 i, atomic_read(&card->ctrl[i].stats.hw_q_depth));
169 }
170
171 return 0;
172}
173
174static int rsxx_attr_stats_open(struct inode *inode, struct file *file)
175{
176 return single_open(file, rsxx_attr_stats_show, inode->i_private);
177}
178
179static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file)
180{
181 return single_open(file, rsxx_attr_pci_regs_show, inode->i_private);
182}
183
184static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
185 size_t cnt, loff_t *ppos)
186{
187 struct rsxx_cram *info = fp->private_data;
188 struct rsxx_cardinfo *card = info->i_private;
189 char *buf;
190 int st;
191
192 buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL);
193 if (!buf)
194 return -ENOMEM;
195
196 info->f_pos = (u32)*ppos + info->offset;
197
198 st = rsxx_creg_read(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
199 if (st)
200 return st;
201
202 st = copy_to_user(ubuf, buf, cnt);
203 if (st)
204 return st;
205
206 info->offset += cnt;
207
208 kfree(buf);
209
210 return cnt;
211}
212
213static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
214 size_t cnt, loff_t *ppos)
215{
216 struct rsxx_cram *info = fp->private_data;
217 struct rsxx_cardinfo *card = info->i_private;
218 char *buf;
219 int st;
220
221 buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL);
222 if (!buf)
223 return -ENOMEM;
224
225 st = copy_from_user(buf, ubuf, cnt);
226 if (st)
227 return st;
228
229 info->f_pos = (u32)*ppos + info->offset;
230
231 st = rsxx_creg_write(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
232 if (st)
233 return st;
234
235 info->offset += cnt;
236
237 kfree(buf);
238
239 return cnt;
240}
241
242static int rsxx_cram_open(struct inode *inode, struct file *file)
243{
244 struct rsxx_cram *info = kzalloc(sizeof(*info), GFP_KERNEL);
245 if (!info)
246 return -ENOMEM;
247
248 info->i_private = inode->i_private;
249 info->f_pos = file->f_pos;
250 file->private_data = info;
251
252 return 0;
253}
254
255static int rsxx_cram_release(struct inode *inode, struct file *file)
256{
257 struct rsxx_cram *info = file->private_data;
258
259 if (!info)
260 return 0;
261
262 kfree(info);
263 file->private_data = NULL;
264
265 return 0;
266}
267
268static const struct file_operations debugfs_cram_fops = {
269 .owner = THIS_MODULE,
270 .open = rsxx_cram_open,
271 .read = rsxx_cram_read,
272 .write = rsxx_cram_write,
273 .release = rsxx_cram_release,
274};
275
276static const struct file_operations debugfs_stats_fops = {
277 .owner = THIS_MODULE,
278 .open = rsxx_attr_stats_open,
279 .read = seq_read,
280 .llseek = seq_lseek,
281 .release = single_release,
282};
283
284static const struct file_operations debugfs_pci_regs_fops = {
285 .owner = THIS_MODULE,
286 .open = rsxx_attr_pci_regs_open,
287 .read = seq_read,
288 .llseek = seq_lseek,
289 .release = single_release,
290};
291
292static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card)
293{
294 struct dentry *debugfs_stats;
295 struct dentry *debugfs_pci_regs;
296 struct dentry *debugfs_cram;
297
298 card->debugfs_dir = debugfs_create_dir(card->gendisk->disk_name, NULL);
299 if (IS_ERR_OR_NULL(card->debugfs_dir))
300 goto failed_debugfs_dir;
301
302 debugfs_stats = debugfs_create_file("stats", S_IRUGO,
303 card->debugfs_dir, card,
304 &debugfs_stats_fops);
305 if (IS_ERR_OR_NULL(debugfs_stats))
306 goto failed_debugfs_stats;
307
308 debugfs_pci_regs = debugfs_create_file("pci_regs", S_IRUGO,
309 card->debugfs_dir, card,
310 &debugfs_pci_regs_fops);
311 if (IS_ERR_OR_NULL(debugfs_pci_regs))
312 goto failed_debugfs_pci_regs;
313
314 debugfs_cram = debugfs_create_file("cram", S_IRUGO | S_IWUSR,
315 card->debugfs_dir, card,
316 &debugfs_cram_fops);
317 if (IS_ERR_OR_NULL(debugfs_cram))
318 goto failed_debugfs_cram;
319
320 return;
321failed_debugfs_cram:
322 debugfs_remove(debugfs_pci_regs);
323failed_debugfs_pci_regs:
324 debugfs_remove(debugfs_stats);
325failed_debugfs_stats:
326 debugfs_remove(card->debugfs_dir);
327failed_debugfs_dir:
328 card->debugfs_dir = NULL;
329}
330
55/*----------------- Interrupt Control & Handling -------------------*/ 331/*----------------- Interrupt Control & Handling -------------------*/
56 332
57static void rsxx_mask_interrupts(struct rsxx_cardinfo *card) 333static void rsxx_mask_interrupts(struct rsxx_cardinfo *card)
@@ -163,12 +439,13 @@ static irqreturn_t rsxx_isr(int irq, void *pdata)
163 } 439 }
164 440
165 if (isr & CR_INTR_CREG) { 441 if (isr & CR_INTR_CREG) {
166 schedule_work(&card->creg_ctrl.done_work); 442 queue_work(card->creg_ctrl.creg_wq,
443 &card->creg_ctrl.done_work);
167 handled++; 444 handled++;
168 } 445 }
169 446
170 if (isr & CR_INTR_EVENT) { 447 if (isr & CR_INTR_EVENT) {
171 schedule_work(&card->event_work); 448 queue_work(card->event_wq, &card->event_work);
172 rsxx_disable_ier_and_isr(card, CR_INTR_EVENT); 449 rsxx_disable_ier_and_isr(card, CR_INTR_EVENT);
173 handled++; 450 handled++;
174 } 451 }
@@ -329,7 +606,7 @@ static int rsxx_eeh_frozen(struct pci_dev *dev)
329 int i; 606 int i;
330 int st; 607 int st;
331 608
332 dev_warn(&dev->dev, "IBM FlashSystem PCI: preparing for slot reset.\n"); 609 dev_warn(&dev->dev, "IBM Flash Adapter PCI: preparing for slot reset.\n");
333 610
334 card->eeh_state = 1; 611 card->eeh_state = 1;
335 rsxx_mask_interrupts(card); 612 rsxx_mask_interrupts(card);
@@ -367,15 +644,26 @@ static void rsxx_eeh_failure(struct pci_dev *dev)
367{ 644{
368 struct rsxx_cardinfo *card = pci_get_drvdata(dev); 645 struct rsxx_cardinfo *card = pci_get_drvdata(dev);
369 int i; 646 int i;
647 int cnt = 0;
370 648
371 dev_err(&dev->dev, "IBM FlashSystem PCI: disabling failed card.\n"); 649 dev_err(&dev->dev, "IBM Flash Adapter PCI: disabling failed card.\n");
372 650
373 card->eeh_state = 1; 651 card->eeh_state = 1;
652 card->halt = 1;
374 653
375 for (i = 0; i < card->n_targets; i++) 654 for (i = 0; i < card->n_targets; i++) {
376 del_timer_sync(&card->ctrl[i].activity_timer); 655 spin_lock_bh(&card->ctrl[i].queue_lock);
656 cnt = rsxx_cleanup_dma_queue(&card->ctrl[i],
657 &card->ctrl[i].queue);
658 spin_unlock_bh(&card->ctrl[i].queue_lock);
659
660 cnt += rsxx_dma_cancel(&card->ctrl[i]);
377 661
378 rsxx_eeh_cancel_dmas(card); 662 if (cnt)
663 dev_info(CARD_TO_DEV(card),
664 "Freed %d queued DMAs on channel %d\n",
665 cnt, card->ctrl[i].id);
666 }
379} 667}
380 668
381static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card) 669static 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)
432 int st; 720 int st;
433 721
434 dev_warn(&dev->dev, 722 dev_warn(&dev->dev,
435 "IBM FlashSystem PCI: recovering from slot reset.\n"); 723 "IBM Flash Adapter PCI: recovering from slot reset.\n");
436 724
437 st = pci_enable_device(dev); 725 st = pci_enable_device(dev);
438 if (st) 726 if (st)
@@ -485,7 +773,7 @@ static pci_ers_result_t rsxx_slot_reset(struct pci_dev *dev)
485 &card->ctrl[i].issue_dma_work); 773 &card->ctrl[i].issue_dma_work);
486 } 774 }
487 775
488 dev_info(&dev->dev, "IBM FlashSystem PCI: recovery complete.\n"); 776 dev_info(&dev->dev, "IBM Flash Adapter PCI: recovery complete.\n");
489 777
490 return PCI_ERS_RESULT_RECOVERED; 778 return PCI_ERS_RESULT_RECOVERED;
491 779
@@ -528,6 +816,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
528{ 816{
529 struct rsxx_cardinfo *card; 817 struct rsxx_cardinfo *card;
530 int st; 818 int st;
819 unsigned int sync_timeout;
531 820
532 dev_info(&dev->dev, "PCI-Flash SSD discovered\n"); 821 dev_info(&dev->dev, "PCI-Flash SSD discovered\n");
533 822
@@ -610,7 +899,11 @@ static int rsxx_pci_probe(struct pci_dev *dev,
610 } 899 }
611 900
612 /************* Setup Processor Command Interface *************/ 901 /************* Setup Processor Command Interface *************/
613 rsxx_creg_setup(card); 902 st = rsxx_creg_setup(card);
903 if (st) {
904 dev_err(CARD_TO_DEV(card), "Failed to setup creg interface.\n");
905 goto failed_creg_setup;
906 }
614 907
615 spin_lock_irq(&card->irq_lock); 908 spin_lock_irq(&card->irq_lock);
616 rsxx_enable_ier_and_isr(card, CR_INTR_CREG); 909 rsxx_enable_ier_and_isr(card, CR_INTR_CREG);
@@ -650,6 +943,12 @@ static int rsxx_pci_probe(struct pci_dev *dev,
650 } 943 }
651 944
652 /************* Setup Card Event Handler *************/ 945 /************* Setup Card Event Handler *************/
946 card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
947 if (!card->event_wq) {
948 dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
949 goto failed_event_handler;
950 }
951
653 INIT_WORK(&card->event_work, card_event_handler); 952 INIT_WORK(&card->event_work, card_event_handler);
654 953
655 st = rsxx_setup_dev(card); 954 st = rsxx_setup_dev(card);
@@ -676,6 +975,33 @@ static int rsxx_pci_probe(struct pci_dev *dev,
676 if (st) 975 if (st)
677 dev_crit(CARD_TO_DEV(card), 976 dev_crit(CARD_TO_DEV(card),
678 "Failed issuing card startup\n"); 977 "Failed issuing card startup\n");
978 if (sync_start) {
979 sync_timeout = SYNC_START_TIMEOUT;
980
981 dev_info(CARD_TO_DEV(card),
982 "Waiting for card to startup\n");
983
984 do {
985 ssleep(1);
986 sync_timeout--;
987
988 rsxx_get_card_state(card, &card->state);
989 } while (sync_timeout &&
990 (card->state == CARD_STATE_STARTING));
991
992 if (card->state == CARD_STATE_STARTING) {
993 dev_warn(CARD_TO_DEV(card),
994 "Card startup timed out\n");
995 card->size8 = 0;
996 } else {
997 dev_info(CARD_TO_DEV(card),
998 "card state: %s\n",
999 rsxx_card_state_to_str(card->state));
1000 st = rsxx_get_card_size8(card, &card->size8);
1001 if (st)
1002 card->size8 = 0;
1003 }
1004 }
679 } else if (card->state == CARD_STATE_GOOD || 1005 } else if (card->state == CARD_STATE_GOOD ||
680 card->state == CARD_STATE_RD_ONLY_FAULT) { 1006 card->state == CARD_STATE_RD_ONLY_FAULT) {
681 st = rsxx_get_card_size8(card, &card->size8); 1007 st = rsxx_get_card_size8(card, &card->size8);
@@ -685,12 +1011,21 @@ static int rsxx_pci_probe(struct pci_dev *dev,
685 1011
686 rsxx_attach_dev(card); 1012 rsxx_attach_dev(card);
687 1013
1014 /************* Setup Debugfs *************/
1015 rsxx_debugfs_dev_new(card);
1016
688 return 0; 1017 return 0;
689 1018
690failed_create_dev: 1019failed_create_dev:
1020 destroy_workqueue(card->event_wq);
1021 card->event_wq = NULL;
1022failed_event_handler:
691 rsxx_dma_destroy(card); 1023 rsxx_dma_destroy(card);
692failed_dma_setup: 1024failed_dma_setup:
693failed_compatiblity_check: 1025failed_compatiblity_check:
1026 destroy_workqueue(card->creg_ctrl.creg_wq);
1027 card->creg_ctrl.creg_wq = NULL;
1028failed_creg_setup:
694 spin_lock_irq(&card->irq_lock); 1029 spin_lock_irq(&card->irq_lock);
695 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); 1030 rsxx_disable_ier_and_isr(card, CR_INTR_ALL);
696 spin_unlock_irq(&card->irq_lock); 1031 spin_unlock_irq(&card->irq_lock);
@@ -756,6 +1091,8 @@ static void rsxx_pci_remove(struct pci_dev *dev)
756 /* Prevent work_structs from re-queuing themselves. */ 1091 /* Prevent work_structs from re-queuing themselves. */
757 card->halt = 1; 1092 card->halt = 1;
758 1093
1094 debugfs_remove_recursive(card->debugfs_dir);
1095
759 free_irq(dev->irq, card); 1096 free_irq(dev->irq, card);
760 1097
761 if (!force_legacy) 1098 if (!force_legacy)
diff --git a/drivers/block/rsxx/cregs.c b/drivers/block/rsxx/cregs.c
index 4b5c020a0a65..926dce9c452f 100644
--- a/drivers/block/rsxx/cregs.c
+++ b/drivers/block/rsxx/cregs.c
@@ -431,6 +431,15 @@ static int __issue_creg_rw(struct rsxx_cardinfo *card,
431 *hw_stat = completion.creg_status; 431 *hw_stat = completion.creg_status;
432 432
433 if (completion.st) { 433 if (completion.st) {
434 /*
435 * This read is needed to verify that there has not been any
436 * extreme errors that might have occurred, i.e. EEH. The
437 * function iowrite32 will not detect EEH errors, so it is
438 * necessary that we recover if such an error is the reason
439 * for the timeout. This is a dummy read.
440 */
441 ioread32(card->regmap + SCRATCH);
442
434 dev_warn(CARD_TO_DEV(card), 443 dev_warn(CARD_TO_DEV(card),
435 "creg command failed(%d x%08x)\n", 444 "creg command failed(%d x%08x)\n",
436 completion.st, addr); 445 completion.st, addr);
@@ -727,6 +736,11 @@ int rsxx_creg_setup(struct rsxx_cardinfo *card)
727{ 736{
728 card->creg_ctrl.active_cmd = NULL; 737 card->creg_ctrl.active_cmd = NULL;
729 738
739 card->creg_ctrl.creg_wq =
740 create_singlethread_workqueue(DRIVER_NAME"_creg");
741 if (!card->creg_ctrl.creg_wq)
742 return -ENOMEM;
743
730 INIT_WORK(&card->creg_ctrl.done_work, creg_cmd_done); 744 INIT_WORK(&card->creg_ctrl.done_work, creg_cmd_done);
731 mutex_init(&card->creg_ctrl.reset_lock); 745 mutex_init(&card->creg_ctrl.reset_lock);
732 INIT_LIST_HEAD(&card->creg_ctrl.queue); 746 INIT_LIST_HEAD(&card->creg_ctrl.queue);
diff --git a/drivers/block/rsxx/dev.c b/drivers/block/rsxx/dev.c
index 4346d17d2949..d7af441880be 100644
--- a/drivers/block/rsxx/dev.c
+++ b/drivers/block/rsxx/dev.c
@@ -155,7 +155,8 @@ static void bio_dma_done_cb(struct rsxx_cardinfo *card,
155 atomic_set(&meta->error, 1); 155 atomic_set(&meta->error, 1);
156 156
157 if (atomic_dec_and_test(&meta->pending_dmas)) { 157 if (atomic_dec_and_test(&meta->pending_dmas)) {
158 disk_stats_complete(card, meta->bio, meta->start_time); 158 if (!card->eeh_state && card->gendisk)
159 disk_stats_complete(card, meta->bio, meta->start_time);
159 160
160 bio_endio(meta->bio, atomic_read(&meta->error) ? -EIO : 0); 161 bio_endio(meta->bio, atomic_read(&meta->error) ? -EIO : 0);
161 kmem_cache_free(bio_meta_pool, meta); 162 kmem_cache_free(bio_meta_pool, meta);
@@ -170,6 +171,12 @@ static void rsxx_make_request(struct request_queue *q, struct bio *bio)
170 171
171 might_sleep(); 172 might_sleep();
172 173
174 if (!card)
175 goto req_err;
176
177 if (bio->bi_sector + (bio->bi_size >> 9) > get_capacity(card->gendisk))
178 goto req_err;
179
173 if (unlikely(card->halt)) { 180 if (unlikely(card->halt)) {
174 st = -EFAULT; 181 st = -EFAULT;
175 goto req_err; 182 goto req_err;
@@ -196,7 +203,8 @@ static void rsxx_make_request(struct request_queue *q, struct bio *bio)
196 atomic_set(&bio_meta->pending_dmas, 0); 203 atomic_set(&bio_meta->pending_dmas, 0);
197 bio_meta->start_time = jiffies; 204 bio_meta->start_time = jiffies;
198 205
199 disk_stats_start(card, bio); 206 if (!unlikely(card->halt))
207 disk_stats_start(card, bio);
200 208
201 dev_dbg(CARD_TO_DEV(card), "BIO[%c]: meta: %p addr8: x%llx size: %d\n", 209 dev_dbg(CARD_TO_DEV(card), "BIO[%c]: meta: %p addr8: x%llx size: %d\n",
202 bio_data_dir(bio) ? 'W' : 'R', bio_meta, 210 bio_data_dir(bio) ? 'W' : 'R', bio_meta,
@@ -225,24 +233,6 @@ static bool rsxx_discard_supported(struct rsxx_cardinfo *card)
225 return (pci_rev >= RSXX_DISCARD_SUPPORT); 233 return (pci_rev >= RSXX_DISCARD_SUPPORT);
226} 234}
227 235
228static unsigned short rsxx_get_logical_block_size(
229 struct rsxx_cardinfo *card)
230{
231 u32 capabilities = 0;
232 int st;
233
234 st = rsxx_get_card_capabilities(card, &capabilities);
235 if (st)
236 dev_warn(CARD_TO_DEV(card),
237 "Failed reading card capabilities register\n");
238
239 /* Earlier firmware did not have support for 512 byte accesses */
240 if (capabilities & CARD_CAP_SUBPAGE_WRITES)
241 return 512;
242 else
243 return RSXX_HW_BLK_SIZE;
244}
245
246int rsxx_attach_dev(struct rsxx_cardinfo *card) 236int rsxx_attach_dev(struct rsxx_cardinfo *card)
247{ 237{
248 mutex_lock(&card->dev_lock); 238 mutex_lock(&card->dev_lock);
@@ -305,7 +295,7 @@ int rsxx_setup_dev(struct rsxx_cardinfo *card)
305 return -ENOMEM; 295 return -ENOMEM;
306 } 296 }
307 297
308 blk_size = rsxx_get_logical_block_size(card); 298 blk_size = card->config.data.block_size;
309 299
310 blk_queue_make_request(card->queue, rsxx_make_request); 300 blk_queue_make_request(card->queue, rsxx_make_request);
311 blk_queue_bounce_limit(card->queue, BLK_BOUNCE_ANY); 301 blk_queue_bounce_limit(card->queue, BLK_BOUNCE_ANY);
@@ -347,6 +337,7 @@ void rsxx_destroy_dev(struct rsxx_cardinfo *card)
347 card->gendisk = NULL; 337 card->gendisk = NULL;
348 338
349 blk_cleanup_queue(card->queue); 339 blk_cleanup_queue(card->queue);
340 card->queue->queuedata = NULL;
350 unregister_blkdev(card->major, DRIVER_NAME); 341 unregister_blkdev(card->major, DRIVER_NAME);
351} 342}
352 343
diff --git a/drivers/block/rsxx/dma.c b/drivers/block/rsxx/dma.c
index 0607513cfb41..bed32f16b084 100644
--- a/drivers/block/rsxx/dma.c
+++ b/drivers/block/rsxx/dma.c
@@ -245,6 +245,22 @@ static void rsxx_complete_dma(struct rsxx_dma_ctrl *ctrl,
245 kmem_cache_free(rsxx_dma_pool, dma); 245 kmem_cache_free(rsxx_dma_pool, dma);
246} 246}
247 247
248int rsxx_cleanup_dma_queue(struct rsxx_dma_ctrl *ctrl,
249 struct list_head *q)
250{
251 struct rsxx_dma *dma;
252 struct rsxx_dma *tmp;
253 int cnt = 0;
254
255 list_for_each_entry_safe(dma, tmp, q, list) {
256 list_del(&dma->list);
257 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED);
258 cnt++;
259 }
260
261 return cnt;
262}
263
248static void rsxx_requeue_dma(struct rsxx_dma_ctrl *ctrl, 264static void rsxx_requeue_dma(struct rsxx_dma_ctrl *ctrl,
249 struct rsxx_dma *dma) 265 struct rsxx_dma *dma)
250{ 266{
@@ -252,9 +268,10 @@ static void rsxx_requeue_dma(struct rsxx_dma_ctrl *ctrl,
252 * Requeued DMAs go to the front of the queue so they are issued 268 * Requeued DMAs go to the front of the queue so they are issued
253 * first. 269 * first.
254 */ 270 */
255 spin_lock(&ctrl->queue_lock); 271 spin_lock_bh(&ctrl->queue_lock);
272 ctrl->stats.sw_q_depth++;
256 list_add(&dma->list, &ctrl->queue); 273 list_add(&dma->list, &ctrl->queue);
257 spin_unlock(&ctrl->queue_lock); 274 spin_unlock_bh(&ctrl->queue_lock);
258} 275}
259 276
260static void rsxx_handle_dma_error(struct rsxx_dma_ctrl *ctrl, 277static 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,
329static void dma_engine_stalled(unsigned long data) 346static void dma_engine_stalled(unsigned long data)
330{ 347{
331 struct rsxx_dma_ctrl *ctrl = (struct rsxx_dma_ctrl *)data; 348 struct rsxx_dma_ctrl *ctrl = (struct rsxx_dma_ctrl *)data;
349 int cnt;
332 350
333 if (atomic_read(&ctrl->stats.hw_q_depth) == 0 || 351 if (atomic_read(&ctrl->stats.hw_q_depth) == 0 ||
334 unlikely(ctrl->card->eeh_state)) 352 unlikely(ctrl->card->eeh_state))
@@ -349,18 +367,28 @@ static void dma_engine_stalled(unsigned long data)
349 "DMA channel %d has stalled, faulting interface.\n", 367 "DMA channel %d has stalled, faulting interface.\n",
350 ctrl->id); 368 ctrl->id);
351 ctrl->card->dma_fault = 1; 369 ctrl->card->dma_fault = 1;
370
371 /* Clean up the DMA queue */
372 spin_lock(&ctrl->queue_lock);
373 cnt = rsxx_cleanup_dma_queue(ctrl, &ctrl->queue);
374 spin_unlock(&ctrl->queue_lock);
375
376 cnt += rsxx_dma_cancel(ctrl);
377
378 if (cnt)
379 dev_info(CARD_TO_DEV(ctrl->card),
380 "Freed %d queued DMAs on channel %d\n",
381 cnt, ctrl->id);
352 } 382 }
353} 383}
354 384
355static void rsxx_issue_dmas(struct work_struct *work) 385static void rsxx_issue_dmas(struct rsxx_dma_ctrl *ctrl)
356{ 386{
357 struct rsxx_dma_ctrl *ctrl;
358 struct rsxx_dma *dma; 387 struct rsxx_dma *dma;
359 int tag; 388 int tag;
360 int cmds_pending = 0; 389 int cmds_pending = 0;
361 struct hw_cmd *hw_cmd_buf; 390 struct hw_cmd *hw_cmd_buf;
362 391
363 ctrl = container_of(work, struct rsxx_dma_ctrl, issue_dma_work);
364 hw_cmd_buf = ctrl->cmd.buf; 392 hw_cmd_buf = ctrl->cmd.buf;
365 393
366 if (unlikely(ctrl->card->halt) || 394 if (unlikely(ctrl->card->halt) ||
@@ -368,22 +396,22 @@ static void rsxx_issue_dmas(struct work_struct *work)
368 return; 396 return;
369 397
370 while (1) { 398 while (1) {
371 spin_lock(&ctrl->queue_lock); 399 spin_lock_bh(&ctrl->queue_lock);
372 if (list_empty(&ctrl->queue)) { 400 if (list_empty(&ctrl->queue)) {
373 spin_unlock(&ctrl->queue_lock); 401 spin_unlock_bh(&ctrl->queue_lock);
374 break; 402 break;
375 } 403 }
376 spin_unlock(&ctrl->queue_lock); 404 spin_unlock_bh(&ctrl->queue_lock);
377 405
378 tag = pop_tracker(ctrl->trackers); 406 tag = pop_tracker(ctrl->trackers);
379 if (tag == -1) 407 if (tag == -1)
380 break; 408 break;
381 409
382 spin_lock(&ctrl->queue_lock); 410 spin_lock_bh(&ctrl->queue_lock);
383 dma = list_entry(ctrl->queue.next, struct rsxx_dma, list); 411 dma = list_entry(ctrl->queue.next, struct rsxx_dma, list);
384 list_del(&dma->list); 412 list_del(&dma->list);
385 ctrl->stats.sw_q_depth--; 413 ctrl->stats.sw_q_depth--;
386 spin_unlock(&ctrl->queue_lock); 414 spin_unlock_bh(&ctrl->queue_lock);
387 415
388 /* 416 /*
389 * This will catch any DMAs that slipped in right before the 417 * This will catch any DMAs that slipped in right before the
@@ -440,9 +468,8 @@ static void rsxx_issue_dmas(struct work_struct *work)
440 } 468 }
441} 469}
442 470
443static void rsxx_dma_done(struct work_struct *work) 471static void rsxx_dma_done(struct rsxx_dma_ctrl *ctrl)
444{ 472{
445 struct rsxx_dma_ctrl *ctrl;
446 struct rsxx_dma *dma; 473 struct rsxx_dma *dma;
447 unsigned long flags; 474 unsigned long flags;
448 u16 count; 475 u16 count;
@@ -450,7 +477,6 @@ static void rsxx_dma_done(struct work_struct *work)
450 u8 tag; 477 u8 tag;
451 struct hw_status *hw_st_buf; 478 struct hw_status *hw_st_buf;
452 479
453 ctrl = container_of(work, struct rsxx_dma_ctrl, dma_done_work);
454 hw_st_buf = ctrl->status.buf; 480 hw_st_buf = ctrl->status.buf;
455 481
456 if (unlikely(ctrl->card->halt) || 482 if (unlikely(ctrl->card->halt) ||
@@ -520,33 +546,32 @@ static void rsxx_dma_done(struct work_struct *work)
520 rsxx_enable_ier(ctrl->card, CR_INTR_DMA(ctrl->id)); 546 rsxx_enable_ier(ctrl->card, CR_INTR_DMA(ctrl->id));
521 spin_unlock_irqrestore(&ctrl->card->irq_lock, flags); 547 spin_unlock_irqrestore(&ctrl->card->irq_lock, flags);
522 548
523 spin_lock(&ctrl->queue_lock); 549 spin_lock_bh(&ctrl->queue_lock);
524 if (ctrl->stats.sw_q_depth) 550 if (ctrl->stats.sw_q_depth)
525 queue_work(ctrl->issue_wq, &ctrl->issue_dma_work); 551 queue_work(ctrl->issue_wq, &ctrl->issue_dma_work);
526 spin_unlock(&ctrl->queue_lock); 552 spin_unlock_bh(&ctrl->queue_lock);
527} 553}
528 554
529static int rsxx_cleanup_dma_queue(struct rsxx_cardinfo *card, 555static void rsxx_schedule_issue(struct work_struct *work)
530 struct list_head *q)
531{ 556{
532 struct rsxx_dma *dma; 557 struct rsxx_dma_ctrl *ctrl;
533 struct rsxx_dma *tmp;
534 int cnt = 0;
535 558
536 list_for_each_entry_safe(dma, tmp, q, list) { 559 ctrl = container_of(work, struct rsxx_dma_ctrl, issue_dma_work);
537 list_del(&dma->list);
538 560
539 if (dma->dma_addr) 561 mutex_lock(&ctrl->work_lock);
540 pci_unmap_page(card->dev, dma->dma_addr, 562 rsxx_issue_dmas(ctrl);
541 get_dma_size(dma), 563 mutex_unlock(&ctrl->work_lock);
542 (dma->cmd == HW_CMD_BLK_WRITE) ? 564}
543 PCI_DMA_TODEVICE :
544 PCI_DMA_FROMDEVICE);
545 kmem_cache_free(rsxx_dma_pool, dma);
546 cnt++;
547 }
548 565
549 return cnt; 566static void rsxx_schedule_done(struct work_struct *work)
567{
568 struct rsxx_dma_ctrl *ctrl;
569
570 ctrl = container_of(work, struct rsxx_dma_ctrl, dma_done_work);
571
572 mutex_lock(&ctrl->work_lock);
573 rsxx_dma_done(ctrl);
574 mutex_unlock(&ctrl->work_lock);
550} 575}
551 576
552static int rsxx_queue_discard(struct rsxx_cardinfo *card, 577static int rsxx_queue_discard(struct rsxx_cardinfo *card,
@@ -698,10 +723,10 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
698 723
699 for (i = 0; i < card->n_targets; i++) { 724 for (i = 0; i < card->n_targets; i++) {
700 if (!list_empty(&dma_list[i])) { 725 if (!list_empty(&dma_list[i])) {
701 spin_lock(&card->ctrl[i].queue_lock); 726 spin_lock_bh(&card->ctrl[i].queue_lock);
702 card->ctrl[i].stats.sw_q_depth += dma_cnt[i]; 727 card->ctrl[i].stats.sw_q_depth += dma_cnt[i];
703 list_splice_tail(&dma_list[i], &card->ctrl[i].queue); 728 list_splice_tail(&dma_list[i], &card->ctrl[i].queue);
704 spin_unlock(&card->ctrl[i].queue_lock); 729 spin_unlock_bh(&card->ctrl[i].queue_lock);
705 730
706 queue_work(card->ctrl[i].issue_wq, 731 queue_work(card->ctrl[i].issue_wq,
707 &card->ctrl[i].issue_dma_work); 732 &card->ctrl[i].issue_dma_work);
@@ -711,8 +736,11 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
711 return 0; 736 return 0;
712 737
713bvec_err: 738bvec_err:
714 for (i = 0; i < card->n_targets; i++) 739 for (i = 0; i < card->n_targets; i++) {
715 rsxx_cleanup_dma_queue(card, &dma_list[i]); 740 spin_lock_bh(&card->ctrl[i].queue_lock);
741 rsxx_cleanup_dma_queue(&card->ctrl[i], &dma_list[i]);
742 spin_unlock_bh(&card->ctrl[i].queue_lock);
743 }
716 744
717 return st; 745 return st;
718} 746}
@@ -780,6 +808,7 @@ static int rsxx_dma_ctrl_init(struct pci_dev *dev,
780 spin_lock_init(&ctrl->trackers->lock); 808 spin_lock_init(&ctrl->trackers->lock);
781 809
782 spin_lock_init(&ctrl->queue_lock); 810 spin_lock_init(&ctrl->queue_lock);
811 mutex_init(&ctrl->work_lock);
783 INIT_LIST_HEAD(&ctrl->queue); 812 INIT_LIST_HEAD(&ctrl->queue);
784 813
785 setup_timer(&ctrl->activity_timer, dma_engine_stalled, 814 setup_timer(&ctrl->activity_timer, dma_engine_stalled,
@@ -793,8 +822,8 @@ static int rsxx_dma_ctrl_init(struct pci_dev *dev,
793 if (!ctrl->done_wq) 822 if (!ctrl->done_wq)
794 return -ENOMEM; 823 return -ENOMEM;
795 824
796 INIT_WORK(&ctrl->issue_dma_work, rsxx_issue_dmas); 825 INIT_WORK(&ctrl->issue_dma_work, rsxx_schedule_issue);
797 INIT_WORK(&ctrl->dma_done_work, rsxx_dma_done); 826 INIT_WORK(&ctrl->dma_done_work, rsxx_schedule_done);
798 827
799 st = rsxx_hw_buffers_init(dev, ctrl); 828 st = rsxx_hw_buffers_init(dev, ctrl);
800 if (st) 829 if (st)
@@ -918,13 +947,30 @@ failed_dma_setup:
918 return st; 947 return st;
919} 948}
920 949
950int rsxx_dma_cancel(struct rsxx_dma_ctrl *ctrl)
951{
952 struct rsxx_dma *dma;
953 int i;
954 int cnt = 0;
955
956 /* Clean up issued DMAs */
957 for (i = 0; i < RSXX_MAX_OUTSTANDING_CMDS; i++) {
958 dma = get_tracker_dma(ctrl->trackers, i);
959 if (dma) {
960 atomic_dec(&ctrl->stats.hw_q_depth);
961 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED);
962 push_tracker(ctrl->trackers, i);
963 cnt++;
964 }
965 }
966
967 return cnt;
968}
921 969
922void rsxx_dma_destroy(struct rsxx_cardinfo *card) 970void rsxx_dma_destroy(struct rsxx_cardinfo *card)
923{ 971{
924 struct rsxx_dma_ctrl *ctrl; 972 struct rsxx_dma_ctrl *ctrl;
925 struct rsxx_dma *dma; 973 int i;
926 int i, j;
927 int cnt = 0;
928 974
929 for (i = 0; i < card->n_targets; i++) { 975 for (i = 0; i < card->n_targets; i++) {
930 ctrl = &card->ctrl[i]; 976 ctrl = &card->ctrl[i];
@@ -943,33 +989,11 @@ void rsxx_dma_destroy(struct rsxx_cardinfo *card)
943 del_timer_sync(&ctrl->activity_timer); 989 del_timer_sync(&ctrl->activity_timer);
944 990
945 /* Clean up the DMA queue */ 991 /* Clean up the DMA queue */
946 spin_lock(&ctrl->queue_lock); 992 spin_lock_bh(&ctrl->queue_lock);
947 cnt = rsxx_cleanup_dma_queue(card, &ctrl->queue); 993 rsxx_cleanup_dma_queue(ctrl, &ctrl->queue);
948 spin_unlock(&ctrl->queue_lock); 994 spin_unlock_bh(&ctrl->queue_lock);
949
950 if (cnt)
951 dev_info(CARD_TO_DEV(card),
952 "Freed %d queued DMAs on channel %d\n",
953 cnt, i);
954
955 /* Clean up issued DMAs */
956 for (j = 0; j < RSXX_MAX_OUTSTANDING_CMDS; j++) {
957 dma = get_tracker_dma(ctrl->trackers, j);
958 if (dma) {
959 pci_unmap_page(card->dev, dma->dma_addr,
960 get_dma_size(dma),
961 (dma->cmd == HW_CMD_BLK_WRITE) ?
962 PCI_DMA_TODEVICE :
963 PCI_DMA_FROMDEVICE);
964 kmem_cache_free(rsxx_dma_pool, dma);
965 cnt++;
966 }
967 }
968 995
969 if (cnt) 996 rsxx_dma_cancel(ctrl);
970 dev_info(CARD_TO_DEV(card),
971 "Freed %d pending DMAs on channel %d\n",
972 cnt, i);
973 997
974 vfree(ctrl->trackers); 998 vfree(ctrl->trackers);
975 999
@@ -1013,7 +1037,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
1013 cnt++; 1037 cnt++;
1014 } 1038 }
1015 1039
1016 spin_lock(&card->ctrl[i].queue_lock); 1040 spin_lock_bh(&card->ctrl[i].queue_lock);
1017 list_splice(&issued_dmas[i], &card->ctrl[i].queue); 1041 list_splice(&issued_dmas[i], &card->ctrl[i].queue);
1018 1042
1019 atomic_sub(cnt, &card->ctrl[i].stats.hw_q_depth); 1043 atomic_sub(cnt, &card->ctrl[i].stats.hw_q_depth);
@@ -1028,7 +1052,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
1028 PCI_DMA_TODEVICE : 1052 PCI_DMA_TODEVICE :
1029 PCI_DMA_FROMDEVICE); 1053 PCI_DMA_FROMDEVICE);
1030 } 1054 }
1031 spin_unlock(&card->ctrl[i].queue_lock); 1055 spin_unlock_bh(&card->ctrl[i].queue_lock);
1032 } 1056 }
1033 1057
1034 kfree(issued_dmas); 1058 kfree(issued_dmas);
@@ -1036,30 +1060,13 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
1036 return 0; 1060 return 0;
1037} 1061}
1038 1062
1039void rsxx_eeh_cancel_dmas(struct rsxx_cardinfo *card)
1040{
1041 struct rsxx_dma *dma;
1042 struct rsxx_dma *tmp;
1043 int i;
1044
1045 for (i = 0; i < card->n_targets; i++) {
1046 spin_lock(&card->ctrl[i].queue_lock);
1047 list_for_each_entry_safe(dma, tmp, &card->ctrl[i].queue, list) {
1048 list_del(&dma->list);
1049
1050 rsxx_complete_dma(&card->ctrl[i], dma, DMA_CANCELLED);
1051 }
1052 spin_unlock(&card->ctrl[i].queue_lock);
1053 }
1054}
1055
1056int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card) 1063int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card)
1057{ 1064{
1058 struct rsxx_dma *dma; 1065 struct rsxx_dma *dma;
1059 int i; 1066 int i;
1060 1067
1061 for (i = 0; i < card->n_targets; i++) { 1068 for (i = 0; i < card->n_targets; i++) {
1062 spin_lock(&card->ctrl[i].queue_lock); 1069 spin_lock_bh(&card->ctrl[i].queue_lock);
1063 list_for_each_entry(dma, &card->ctrl[i].queue, list) { 1070 list_for_each_entry(dma, &card->ctrl[i].queue, list) {
1064 dma->dma_addr = pci_map_page(card->dev, dma->page, 1071 dma->dma_addr = pci_map_page(card->dev, dma->page,
1065 dma->pg_off, get_dma_size(dma), 1072 dma->pg_off, get_dma_size(dma),
@@ -1067,12 +1074,12 @@ int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card)
1067 PCI_DMA_TODEVICE : 1074 PCI_DMA_TODEVICE :
1068 PCI_DMA_FROMDEVICE); 1075 PCI_DMA_FROMDEVICE);
1069 if (!dma->dma_addr) { 1076 if (!dma->dma_addr) {
1070 spin_unlock(&card->ctrl[i].queue_lock); 1077 spin_unlock_bh(&card->ctrl[i].queue_lock);
1071 kmem_cache_free(rsxx_dma_pool, dma); 1078 kmem_cache_free(rsxx_dma_pool, dma);
1072 return -ENOMEM; 1079 return -ENOMEM;
1073 } 1080 }
1074 } 1081 }
1075 spin_unlock(&card->ctrl[i].queue_lock); 1082 spin_unlock_bh(&card->ctrl[i].queue_lock);
1076 } 1083 }
1077 1084
1078 return 0; 1085 return 0;
diff --git a/drivers/block/rsxx/rsxx_priv.h b/drivers/block/rsxx/rsxx_priv.h
index 382e8bf5c03b..5ad5055a4104 100644
--- a/drivers/block/rsxx/rsxx_priv.h
+++ b/drivers/block/rsxx/rsxx_priv.h
@@ -39,6 +39,7 @@
39#include <linux/vmalloc.h> 39#include <linux/vmalloc.h>
40#include <linux/timer.h> 40#include <linux/timer.h>
41#include <linux/ioctl.h> 41#include <linux/ioctl.h>
42#include <linux/delay.h>
42 43
43#include "rsxx.h" 44#include "rsxx.h"
44#include "rsxx_cfg.h" 45#include "rsxx_cfg.h"
@@ -114,6 +115,7 @@ struct rsxx_dma_ctrl {
114 struct timer_list activity_timer; 115 struct timer_list activity_timer;
115 struct dma_tracker_list *trackers; 116 struct dma_tracker_list *trackers;
116 struct rsxx_dma_stats stats; 117 struct rsxx_dma_stats stats;
118 struct mutex work_lock;
117}; 119};
118 120
119struct rsxx_cardinfo { 121struct rsxx_cardinfo {
@@ -134,6 +136,7 @@ struct rsxx_cardinfo {
134 spinlock_t lock; 136 spinlock_t lock;
135 bool active; 137 bool active;
136 struct creg_cmd *active_cmd; 138 struct creg_cmd *active_cmd;
139 struct workqueue_struct *creg_wq;
137 struct work_struct done_work; 140 struct work_struct done_work;
138 struct list_head queue; 141 struct list_head queue;
139 unsigned int q_depth; 142 unsigned int q_depth;
@@ -154,6 +157,7 @@ struct rsxx_cardinfo {
154 int buf_len; 157 int buf_len;
155 } log; 158 } log;
156 159
160 struct workqueue_struct *event_wq;
157 struct work_struct event_work; 161 struct work_struct event_work;
158 unsigned int state; 162 unsigned int state;
159 u64 size8; 163 u64 size8;
@@ -181,6 +185,8 @@ struct rsxx_cardinfo {
181 185
182 int n_targets; 186 int n_targets;
183 struct rsxx_dma_ctrl *ctrl; 187 struct rsxx_dma_ctrl *ctrl;
188
189 struct dentry *debugfs_dir;
184}; 190};
185 191
186enum rsxx_pci_regmap { 192enum rsxx_pci_regmap {
@@ -283,6 +289,7 @@ enum rsxx_creg_addr {
283 CREG_ADD_CAPABILITIES = 0x80001050, 289 CREG_ADD_CAPABILITIES = 0x80001050,
284 CREG_ADD_LOG = 0x80002000, 290 CREG_ADD_LOG = 0x80002000,
285 CREG_ADD_NUM_TARGETS = 0x80003000, 291 CREG_ADD_NUM_TARGETS = 0x80003000,
292 CREG_ADD_CRAM = 0xA0000000,
286 CREG_ADD_CONFIG = 0xB0000000, 293 CREG_ADD_CONFIG = 0xB0000000,
287}; 294};
288 295
@@ -372,6 +379,8 @@ typedef void (*rsxx_dma_cb)(struct rsxx_cardinfo *card,
372int rsxx_dma_setup(struct rsxx_cardinfo *card); 379int rsxx_dma_setup(struct rsxx_cardinfo *card);
373void rsxx_dma_destroy(struct rsxx_cardinfo *card); 380void rsxx_dma_destroy(struct rsxx_cardinfo *card);
374int rsxx_dma_init(void); 381int rsxx_dma_init(void);
382int rsxx_cleanup_dma_queue(struct rsxx_dma_ctrl *ctrl, struct list_head *q);
383int rsxx_dma_cancel(struct rsxx_dma_ctrl *ctrl);
375void rsxx_dma_cleanup(void); 384void rsxx_dma_cleanup(void);
376void rsxx_dma_queue_reset(struct rsxx_cardinfo *card); 385void rsxx_dma_queue_reset(struct rsxx_cardinfo *card);
377int rsxx_dma_configure(struct rsxx_cardinfo *card); 386int rsxx_dma_configure(struct rsxx_cardinfo *card);
@@ -382,7 +391,6 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
382 void *cb_data); 391 void *cb_data);
383int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl); 392int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl);
384int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card); 393int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card);
385void rsxx_eeh_cancel_dmas(struct rsxx_cardinfo *card);
386int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card); 394int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card);
387 395
388/***** cregs.c *****/ 396/***** cregs.c *****/
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index dd5b2fed97e9..bf4b9d282c04 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -50,110 +50,118 @@
50#include "common.h" 50#include "common.h"
51 51
52/* 52/*
53 * These are rather arbitrary. They are fairly large because adjacent requests 53 * Maximum number of unused free pages to keep in the internal buffer.
54 * pulled from a communication ring are quite likely to end up being part of 54 * Setting this to a value too low will reduce memory used in each backend,
55 * the same scatter/gather request at the disc. 55 * but can have a performance penalty.
56 * 56 *
57 * ** TRY INCREASING 'xen_blkif_reqs' IF WRITE SPEEDS SEEM TOO LOW ** 57 * A sane value is xen_blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST, but can
58 * 58 * be set to a lower value that might degrade performance on some intensive
59 * This will increase the chances of being able to write whole tracks. 59 * IO workloads.
60 * 64 should be enough to keep us competitive with Linux.
61 */ 60 */
62static int xen_blkif_reqs = 64;
63module_param_named(reqs, xen_blkif_reqs, int, 0);
64MODULE_PARM_DESC(reqs, "Number of blkback requests to allocate");
65 61
66/* Run-time switchable: /sys/module/blkback/parameters/ */ 62static int xen_blkif_max_buffer_pages = 1024;
67static unsigned int log_stats; 63module_param_named(max_buffer_pages, xen_blkif_max_buffer_pages, int, 0644);
68module_param(log_stats, int, 0644); 64MODULE_PARM_DESC(max_buffer_pages,
65"Maximum number of free pages to keep in each block backend buffer");
69 66
70/* 67/*
71 * Each outstanding request that we've passed to the lower device layers has a 68 * Maximum number of grants to map persistently in blkback. For maximum
72 * 'pending_req' allocated to it. Each buffer_head that completes decrements 69 * performance this should be the total numbers of grants that can be used
73 * the pendcnt towards zero. When it hits zero, the specified domain has a 70 * to fill the ring, but since this might become too high, specially with
74 * response queued for it, with the saved 'id' passed back. 71 * the use of indirect descriptors, we set it to a value that provides good
72 * performance without using too much memory.
73 *
74 * When the list of persistent grants is full we clean it up using a LRU
75 * algorithm.
75 */ 76 */
76struct pending_req {
77 struct xen_blkif *blkif;
78 u64 id;
79 int nr_pages;
80 atomic_t pendcnt;
81 unsigned short operation;
82 int status;
83 struct list_head free_list;
84 DECLARE_BITMAP(unmap_seg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
85};
86 77
87#define BLKBACK_INVALID_HANDLE (~0) 78static int xen_blkif_max_pgrants = 1056;
79module_param_named(max_persistent_grants, xen_blkif_max_pgrants, int, 0644);
80MODULE_PARM_DESC(max_persistent_grants,
81 "Maximum number of grants to map persistently");
88 82
89struct xen_blkbk { 83/*
90 struct pending_req *pending_reqs; 84 * The LRU mechanism to clean the lists of persistent grants needs to
91 /* List of all 'pending_req' available */ 85 * be executed periodically. The time interval between consecutive executions
92 struct list_head pending_free; 86 * of the purge mechanism is set in ms.
93 /* And its spinlock. */ 87 */
94 spinlock_t pending_free_lock; 88#define LRU_INTERVAL 100
95 wait_queue_head_t pending_free_wq;
96 /* The list of all pages that are available. */
97 struct page **pending_pages;
98 /* And the grant handles that are available. */
99 grant_handle_t *pending_grant_handles;
100};
101
102static struct xen_blkbk *blkbk;
103 89
104/* 90/*
105 * Maximum number of grant pages that can be mapped in blkback. 91 * When the persistent grants list is full we will remove unused grants
106 * BLKIF_MAX_SEGMENTS_PER_REQUEST * RING_SIZE is the maximum number of 92 * from the list. The percent number of grants to be removed at each LRU
107 * pages that blkback will persistently map. 93 * execution.
108 * Currently, this is:
109 * RING_SIZE = 32 (for all known ring types)
110 * BLKIF_MAX_SEGMENTS_PER_REQUEST = 11
111 * sizeof(struct persistent_gnt) = 48
112 * So the maximum memory used to store the grants is:
113 * 32 * 11 * 48 = 16896 bytes
114 */ 94 */
115static inline unsigned int max_mapped_grant_pages(enum blkif_protocol protocol) 95#define LRU_PERCENT_CLEAN 5
96
97/* Run-time switchable: /sys/module/blkback/parameters/ */
98static unsigned int log_stats;
99module_param(log_stats, int, 0644);
100
101#define BLKBACK_INVALID_HANDLE (~0)
102
103/* Number of free pages to remove on each call to free_xenballooned_pages */
104#define NUM_BATCH_FREE_PAGES 10
105
106static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
116{ 107{
117 switch (protocol) { 108 unsigned long flags;
118 case BLKIF_PROTOCOL_NATIVE: 109
119 return __CONST_RING_SIZE(blkif, PAGE_SIZE) * 110 spin_lock_irqsave(&blkif->free_pages_lock, flags);
120 BLKIF_MAX_SEGMENTS_PER_REQUEST; 111 if (list_empty(&blkif->free_pages)) {
121 case BLKIF_PROTOCOL_X86_32: 112 BUG_ON(blkif->free_pages_num != 0);
122 return __CONST_RING_SIZE(blkif_x86_32, PAGE_SIZE) * 113 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
123 BLKIF_MAX_SEGMENTS_PER_REQUEST; 114 return alloc_xenballooned_pages(1, page, false);
124 case BLKIF_PROTOCOL_X86_64:
125 return __CONST_RING_SIZE(blkif_x86_64, PAGE_SIZE) *
126 BLKIF_MAX_SEGMENTS_PER_REQUEST;
127 default:
128 BUG();
129 } 115 }
116 BUG_ON(blkif->free_pages_num == 0);
117 page[0] = list_first_entry(&blkif->free_pages, struct page, lru);
118 list_del(&page[0]->lru);
119 blkif->free_pages_num--;
120 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
121
130 return 0; 122 return 0;
131} 123}
132 124
133 125static inline void put_free_pages(struct xen_blkif *blkif, struct page **page,
134/* 126 int num)
135 * Little helpful macro to figure out the index and virtual address of the
136 * pending_pages[..]. For each 'pending_req' we have have up to
137 * BLKIF_MAX_SEGMENTS_PER_REQUEST (11) pages. The seg would be from 0 through
138 * 10 and would index in the pending_pages[..].
139 */
140static inline int vaddr_pagenr(struct pending_req *req, int seg)
141{ 127{
142 return (req - blkbk->pending_reqs) * 128 unsigned long flags;
143 BLKIF_MAX_SEGMENTS_PER_REQUEST + seg; 129 int i;
144}
145 130
146#define pending_page(req, seg) pending_pages[vaddr_pagenr(req, seg)] 131 spin_lock_irqsave(&blkif->free_pages_lock, flags);
132 for (i = 0; i < num; i++)
133 list_add(&page[i]->lru, &blkif->free_pages);
134 blkif->free_pages_num += num;
135 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
136}
147 137
148static inline unsigned long vaddr(struct pending_req *req, int seg) 138static inline void shrink_free_pagepool(struct xen_blkif *blkif, int num)
149{ 139{
150 unsigned long pfn = page_to_pfn(blkbk->pending_page(req, seg)); 140 /* Remove requested pages in batches of NUM_BATCH_FREE_PAGES */
151 return (unsigned long)pfn_to_kaddr(pfn); 141 struct page *page[NUM_BATCH_FREE_PAGES];
152} 142 unsigned int num_pages = 0;
143 unsigned long flags;
153 144
154#define pending_handle(_req, _seg) \ 145 spin_lock_irqsave(&blkif->free_pages_lock, flags);
155 (blkbk->pending_grant_handles[vaddr_pagenr(_req, _seg)]) 146 while (blkif->free_pages_num > num) {
147 BUG_ON(list_empty(&blkif->free_pages));
148 page[num_pages] = list_first_entry(&blkif->free_pages,
149 struct page, lru);
150 list_del(&page[num_pages]->lru);
151 blkif->free_pages_num--;
152 if (++num_pages == NUM_BATCH_FREE_PAGES) {
153 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
154 free_xenballooned_pages(num_pages, page);
155 spin_lock_irqsave(&blkif->free_pages_lock, flags);
156 num_pages = 0;
157 }
158 }
159 spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
160 if (num_pages != 0)
161 free_xenballooned_pages(num_pages, page);
162}
156 163
164#define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page)))
157 165
158static int do_block_io_op(struct xen_blkif *blkif); 166static int do_block_io_op(struct xen_blkif *blkif);
159static int dispatch_rw_block_io(struct xen_blkif *blkif, 167static int dispatch_rw_block_io(struct xen_blkif *blkif,
@@ -170,13 +178,29 @@ static void make_response(struct xen_blkif *blkif, u64 id,
170 (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL) 178 (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)
171 179
172 180
173static void add_persistent_gnt(struct rb_root *root, 181/*
182 * We don't need locking around the persistent grant helpers
183 * because blkback uses a single-thread for each backed, so we
184 * can be sure that this functions will never be called recursively.
185 *
186 * The only exception to that is put_persistent_grant, that can be called
187 * from interrupt context (by xen_blkbk_unmap), so we have to use atomic
188 * bit operations to modify the flags of a persistent grant and to count
189 * the number of used grants.
190 */
191static int add_persistent_gnt(struct xen_blkif *blkif,
174 struct persistent_gnt *persistent_gnt) 192 struct persistent_gnt *persistent_gnt)
175{ 193{
176 struct rb_node **new = &(root->rb_node), *parent = NULL; 194 struct rb_node **new = NULL, *parent = NULL;
177 struct persistent_gnt *this; 195 struct persistent_gnt *this;
178 196
197 if (blkif->persistent_gnt_c >= xen_blkif_max_pgrants) {
198 if (!blkif->vbd.overflow_max_grants)
199 blkif->vbd.overflow_max_grants = 1;
200 return -EBUSY;
201 }
179 /* Figure out where to put new node */ 202 /* Figure out where to put new node */
203 new = &blkif->persistent_gnts.rb_node;
180 while (*new) { 204 while (*new) {
181 this = container_of(*new, struct persistent_gnt, node); 205 this = container_of(*new, struct persistent_gnt, node);
182 206
@@ -186,22 +210,28 @@ static void add_persistent_gnt(struct rb_root *root,
186 else if (persistent_gnt->gnt > this->gnt) 210 else if (persistent_gnt->gnt > this->gnt)
187 new = &((*new)->rb_right); 211 new = &((*new)->rb_right);
188 else { 212 else {
189 pr_alert(DRV_PFX " trying to add a gref that's already in the tree\n"); 213 pr_alert_ratelimited(DRV_PFX " trying to add a gref that's already in the tree\n");
190 BUG(); 214 return -EINVAL;
191 } 215 }
192 } 216 }
193 217
218 bitmap_zero(persistent_gnt->flags, PERSISTENT_GNT_FLAGS_SIZE);
219 set_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags);
194 /* Add new node and rebalance tree. */ 220 /* Add new node and rebalance tree. */
195 rb_link_node(&(persistent_gnt->node), parent, new); 221 rb_link_node(&(persistent_gnt->node), parent, new);
196 rb_insert_color(&(persistent_gnt->node), root); 222 rb_insert_color(&(persistent_gnt->node), &blkif->persistent_gnts);
223 blkif->persistent_gnt_c++;
224 atomic_inc(&blkif->persistent_gnt_in_use);
225 return 0;
197} 226}
198 227
199static struct persistent_gnt *get_persistent_gnt(struct rb_root *root, 228static struct persistent_gnt *get_persistent_gnt(struct xen_blkif *blkif,
200 grant_ref_t gref) 229 grant_ref_t gref)
201{ 230{
202 struct persistent_gnt *data; 231 struct persistent_gnt *data;
203 struct rb_node *node = root->rb_node; 232 struct rb_node *node = NULL;
204 233
234 node = blkif->persistent_gnts.rb_node;
205 while (node) { 235 while (node) {
206 data = container_of(node, struct persistent_gnt, node); 236 data = container_of(node, struct persistent_gnt, node);
207 237
@@ -209,13 +239,31 @@ static struct persistent_gnt *get_persistent_gnt(struct rb_root *root,
209 node = node->rb_left; 239 node = node->rb_left;
210 else if (gref > data->gnt) 240 else if (gref > data->gnt)
211 node = node->rb_right; 241 node = node->rb_right;
212 else 242 else {
243 if(test_bit(PERSISTENT_GNT_ACTIVE, data->flags)) {
244 pr_alert_ratelimited(DRV_PFX " requesting a grant already in use\n");
245 return NULL;
246 }
247 set_bit(PERSISTENT_GNT_ACTIVE, data->flags);
248 atomic_inc(&blkif->persistent_gnt_in_use);
213 return data; 249 return data;
250 }
214 } 251 }
215 return NULL; 252 return NULL;
216} 253}
217 254
218static void free_persistent_gnts(struct rb_root *root, unsigned int num) 255static void put_persistent_gnt(struct xen_blkif *blkif,
256 struct persistent_gnt *persistent_gnt)
257{
258 if(!test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags))
259 pr_alert_ratelimited(DRV_PFX " freeing a grant already unused");
260 set_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
261 clear_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags);
262 atomic_dec(&blkif->persistent_gnt_in_use);
263}
264
265static void free_persistent_gnts(struct xen_blkif *blkif, struct rb_root *root,
266 unsigned int num)
219{ 267{
220 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 268 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
221 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 269 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
@@ -240,7 +288,7 @@ static void free_persistent_gnts(struct rb_root *root, unsigned int num)
240 ret = gnttab_unmap_refs(unmap, NULL, pages, 288 ret = gnttab_unmap_refs(unmap, NULL, pages,
241 segs_to_unmap); 289 segs_to_unmap);
242 BUG_ON(ret); 290 BUG_ON(ret);
243 free_xenballooned_pages(segs_to_unmap, pages); 291 put_free_pages(blkif, pages, segs_to_unmap);
244 segs_to_unmap = 0; 292 segs_to_unmap = 0;
245 } 293 }
246 294
@@ -251,21 +299,148 @@ static void free_persistent_gnts(struct rb_root *root, unsigned int num)
251 BUG_ON(num != 0); 299 BUG_ON(num != 0);
252} 300}
253 301
302static void unmap_purged_grants(struct work_struct *work)
303{
304 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
305 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
306 struct persistent_gnt *persistent_gnt;
307 int ret, segs_to_unmap = 0;
308 struct xen_blkif *blkif = container_of(work, typeof(*blkif), persistent_purge_work);
309
310 while(!list_empty(&blkif->persistent_purge_list)) {
311 persistent_gnt = list_first_entry(&blkif->persistent_purge_list,
312 struct persistent_gnt,
313 remove_node);
314 list_del(&persistent_gnt->remove_node);
315
316 gnttab_set_unmap_op(&unmap[segs_to_unmap],
317 vaddr(persistent_gnt->page),
318 GNTMAP_host_map,
319 persistent_gnt->handle);
320
321 pages[segs_to_unmap] = persistent_gnt->page;
322
323 if (++segs_to_unmap == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
324 ret = gnttab_unmap_refs(unmap, NULL, pages,
325 segs_to_unmap);
326 BUG_ON(ret);
327 put_free_pages(blkif, pages, segs_to_unmap);
328 segs_to_unmap = 0;
329 }
330 kfree(persistent_gnt);
331 }
332 if (segs_to_unmap > 0) {
333 ret = gnttab_unmap_refs(unmap, NULL, pages, segs_to_unmap);
334 BUG_ON(ret);
335 put_free_pages(blkif, pages, segs_to_unmap);
336 }
337}
338
339static void purge_persistent_gnt(struct xen_blkif *blkif)
340{
341 struct persistent_gnt *persistent_gnt;
342 struct rb_node *n;
343 unsigned int num_clean, total;
344 bool scan_used = false, clean_used = false;
345 struct rb_root *root;
346
347 if (blkif->persistent_gnt_c < xen_blkif_max_pgrants ||
348 (blkif->persistent_gnt_c == xen_blkif_max_pgrants &&
349 !blkif->vbd.overflow_max_grants)) {
350 return;
351 }
352
353 if (work_pending(&blkif->persistent_purge_work)) {
354 pr_alert_ratelimited(DRV_PFX "Scheduled work from previous purge is still pending, cannot purge list\n");
355 return;
356 }
357
358 num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN;
359 num_clean = blkif->persistent_gnt_c - xen_blkif_max_pgrants + num_clean;
360 num_clean = min(blkif->persistent_gnt_c, num_clean);
361 if ((num_clean == 0) ||
362 (num_clean > (blkif->persistent_gnt_c - atomic_read(&blkif->persistent_gnt_in_use))))
363 return;
364
365 /*
366 * At this point, we can assure that there will be no calls
367 * to get_persistent_grant (because we are executing this code from
368 * xen_blkif_schedule), there can only be calls to put_persistent_gnt,
369 * which means that the number of currently used grants will go down,
370 * but never up, so we will always be able to remove the requested
371 * number of grants.
372 */
373
374 total = num_clean;
375
376 pr_debug(DRV_PFX "Going to purge %u persistent grants\n", num_clean);
377
378 INIT_LIST_HEAD(&blkif->persistent_purge_list);
379 root = &blkif->persistent_gnts;
380purge_list:
381 foreach_grant_safe(persistent_gnt, n, root, node) {
382 BUG_ON(persistent_gnt->handle ==
383 BLKBACK_INVALID_HANDLE);
384
385 if (clean_used) {
386 clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
387 continue;
388 }
389
390 if (test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags))
391 continue;
392 if (!scan_used &&
393 (test_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags)))
394 continue;
395
396 rb_erase(&persistent_gnt->node, root);
397 list_add(&persistent_gnt->remove_node,
398 &blkif->persistent_purge_list);
399 if (--num_clean == 0)
400 goto finished;
401 }
402 /*
403 * If we get here it means we also need to start cleaning
404 * grants that were used since last purge in order to cope
405 * with the requested num
406 */
407 if (!scan_used && !clean_used) {
408 pr_debug(DRV_PFX "Still missing %u purged frames\n", num_clean);
409 scan_used = true;
410 goto purge_list;
411 }
412finished:
413 if (!clean_used) {
414 pr_debug(DRV_PFX "Finished scanning for grants to clean, removing used flag\n");
415 clean_used = true;
416 goto purge_list;
417 }
418
419 blkif->persistent_gnt_c -= (total - num_clean);
420 blkif->vbd.overflow_max_grants = 0;
421
422 /* We can defer this work */
423 INIT_WORK(&blkif->persistent_purge_work, unmap_purged_grants);
424 schedule_work(&blkif->persistent_purge_work);
425 pr_debug(DRV_PFX "Purged %u/%u\n", (total - num_clean), total);
426 return;
427}
428
254/* 429/*
255 * Retrieve from the 'pending_reqs' a free pending_req structure to be used. 430 * Retrieve from the 'pending_reqs' a free pending_req structure to be used.
256 */ 431 */
257static struct pending_req *alloc_req(void) 432static struct pending_req *alloc_req(struct xen_blkif *blkif)
258{ 433{
259 struct pending_req *req = NULL; 434 struct pending_req *req = NULL;
260 unsigned long flags; 435 unsigned long flags;
261 436
262 spin_lock_irqsave(&blkbk->pending_free_lock, flags); 437 spin_lock_irqsave(&blkif->pending_free_lock, flags);
263 if (!list_empty(&blkbk->pending_free)) { 438 if (!list_empty(&blkif->pending_free)) {
264 req = list_entry(blkbk->pending_free.next, struct pending_req, 439 req = list_entry(blkif->pending_free.next, struct pending_req,
265 free_list); 440 free_list);
266 list_del(&req->free_list); 441 list_del(&req->free_list);
267 } 442 }
268 spin_unlock_irqrestore(&blkbk->pending_free_lock, flags); 443 spin_unlock_irqrestore(&blkif->pending_free_lock, flags);
269 return req; 444 return req;
270} 445}
271 446
@@ -273,17 +448,17 @@ static struct pending_req *alloc_req(void)
273 * Return the 'pending_req' structure back to the freepool. We also 448 * Return the 'pending_req' structure back to the freepool. We also
274 * wake up the thread if it was waiting for a free page. 449 * wake up the thread if it was waiting for a free page.
275 */ 450 */
276static void free_req(struct pending_req *req) 451static void free_req(struct xen_blkif *blkif, struct pending_req *req)
277{ 452{
278 unsigned long flags; 453 unsigned long flags;
279 int was_empty; 454 int was_empty;
280 455
281 spin_lock_irqsave(&blkbk->pending_free_lock, flags); 456 spin_lock_irqsave(&blkif->pending_free_lock, flags);
282 was_empty = list_empty(&blkbk->pending_free); 457 was_empty = list_empty(&blkif->pending_free);
283 list_add(&req->free_list, &blkbk->pending_free); 458 list_add(&req->free_list, &blkif->pending_free);
284 spin_unlock_irqrestore(&blkbk->pending_free_lock, flags); 459 spin_unlock_irqrestore(&blkif->pending_free_lock, flags);
285 if (was_empty) 460 if (was_empty)
286 wake_up(&blkbk->pending_free_wq); 461 wake_up(&blkif->pending_free_wq);
287} 462}
288 463
289/* 464/*
@@ -382,10 +557,12 @@ irqreturn_t xen_blkif_be_int(int irq, void *dev_id)
382static void print_stats(struct xen_blkif *blkif) 557static void print_stats(struct xen_blkif *blkif)
383{ 558{
384 pr_info("xen-blkback (%s): oo %3llu | rd %4llu | wr %4llu | f %4llu" 559 pr_info("xen-blkback (%s): oo %3llu | rd %4llu | wr %4llu | f %4llu"
385 " | ds %4llu\n", 560 " | ds %4llu | pg: %4u/%4d\n",
386 current->comm, blkif->st_oo_req, 561 current->comm, blkif->st_oo_req,
387 blkif->st_rd_req, blkif->st_wr_req, 562 blkif->st_rd_req, blkif->st_wr_req,
388 blkif->st_f_req, blkif->st_ds_req); 563 blkif->st_f_req, blkif->st_ds_req,
564 blkif->persistent_gnt_c,
565 xen_blkif_max_pgrants);
389 blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000); 566 blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
390 blkif->st_rd_req = 0; 567 blkif->st_rd_req = 0;
391 blkif->st_wr_req = 0; 568 blkif->st_wr_req = 0;
@@ -397,6 +574,8 @@ int xen_blkif_schedule(void *arg)
397{ 574{
398 struct xen_blkif *blkif = arg; 575 struct xen_blkif *blkif = arg;
399 struct xen_vbd *vbd = &blkif->vbd; 576 struct xen_vbd *vbd = &blkif->vbd;
577 unsigned long timeout;
578 int ret;
400 579
401 xen_blkif_get(blkif); 580 xen_blkif_get(blkif);
402 581
@@ -406,27 +585,52 @@ int xen_blkif_schedule(void *arg)
406 if (unlikely(vbd->size != vbd_sz(vbd))) 585 if (unlikely(vbd->size != vbd_sz(vbd)))
407 xen_vbd_resize(blkif); 586 xen_vbd_resize(blkif);
408 587
409 wait_event_interruptible( 588 timeout = msecs_to_jiffies(LRU_INTERVAL);
589
590 timeout = wait_event_interruptible_timeout(
410 blkif->wq, 591 blkif->wq,
411 blkif->waiting_reqs || kthread_should_stop()); 592 blkif->waiting_reqs || kthread_should_stop(),
412 wait_event_interruptible( 593 timeout);
413 blkbk->pending_free_wq, 594 if (timeout == 0)
414 !list_empty(&blkbk->pending_free) || 595 goto purge_gnt_list;
415 kthread_should_stop()); 596 timeout = wait_event_interruptible_timeout(
597 blkif->pending_free_wq,
598 !list_empty(&blkif->pending_free) ||
599 kthread_should_stop(),
600 timeout);
601 if (timeout == 0)
602 goto purge_gnt_list;
416 603
417 blkif->waiting_reqs = 0; 604 blkif->waiting_reqs = 0;
418 smp_mb(); /* clear flag *before* checking for work */ 605 smp_mb(); /* clear flag *before* checking for work */
419 606
420 if (do_block_io_op(blkif)) 607 ret = do_block_io_op(blkif);
608 if (ret > 0)
421 blkif->waiting_reqs = 1; 609 blkif->waiting_reqs = 1;
610 if (ret == -EACCES)
611 wait_event_interruptible(blkif->shutdown_wq,
612 kthread_should_stop());
613
614purge_gnt_list:
615 if (blkif->vbd.feature_gnt_persistent &&
616 time_after(jiffies, blkif->next_lru)) {
617 purge_persistent_gnt(blkif);
618 blkif->next_lru = jiffies + msecs_to_jiffies(LRU_INTERVAL);
619 }
620
621 /* Shrink if we have more than xen_blkif_max_buffer_pages */
622 shrink_free_pagepool(blkif, xen_blkif_max_buffer_pages);
422 623
423 if (log_stats && time_after(jiffies, blkif->st_print)) 624 if (log_stats && time_after(jiffies, blkif->st_print))
424 print_stats(blkif); 625 print_stats(blkif);
425 } 626 }
426 627
628 /* Since we are shutting down remove all pages from the buffer */
629 shrink_free_pagepool(blkif, 0 /* All */);
630
427 /* Free all persistent grant pages */ 631 /* Free all persistent grant pages */
428 if (!RB_EMPTY_ROOT(&blkif->persistent_gnts)) 632 if (!RB_EMPTY_ROOT(&blkif->persistent_gnts))
429 free_persistent_gnts(&blkif->persistent_gnts, 633 free_persistent_gnts(blkif, &blkif->persistent_gnts,
430 blkif->persistent_gnt_c); 634 blkif->persistent_gnt_c);
431 635
432 BUG_ON(!RB_EMPTY_ROOT(&blkif->persistent_gnts)); 636 BUG_ON(!RB_EMPTY_ROOT(&blkif->persistent_gnts));
@@ -441,148 +645,98 @@ int xen_blkif_schedule(void *arg)
441 return 0; 645 return 0;
442} 646}
443 647
444struct seg_buf {
445 unsigned int offset;
446 unsigned int nsec;
447};
448/* 648/*
449 * Unmap the grant references, and also remove the M2P over-rides 649 * Unmap the grant references, and also remove the M2P over-rides
450 * used in the 'pending_req'. 650 * used in the 'pending_req'.
451 */ 651 */
452static void xen_blkbk_unmap(struct pending_req *req) 652static void xen_blkbk_unmap(struct xen_blkif *blkif,
653 struct grant_page *pages[],
654 int num)
453{ 655{
454 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 656 struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
455 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 657 struct page *unmap_pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
456 unsigned int i, invcount = 0; 658 unsigned int i, invcount = 0;
457 grant_handle_t handle;
458 int ret; 659 int ret;
459 660
460 for (i = 0; i < req->nr_pages; i++) { 661 for (i = 0; i < num; i++) {
461 if (!test_bit(i, req->unmap_seg)) 662 if (pages[i]->persistent_gnt != NULL) {
663 put_persistent_gnt(blkif, pages[i]->persistent_gnt);
462 continue; 664 continue;
463 handle = pending_handle(req, i); 665 }
464 if (handle == BLKBACK_INVALID_HANDLE) 666 if (pages[i]->handle == BLKBACK_INVALID_HANDLE)
465 continue; 667 continue;
466 gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i), 668 unmap_pages[invcount] = pages[i]->page;
467 GNTMAP_host_map, handle); 669 gnttab_set_unmap_op(&unmap[invcount], vaddr(pages[i]->page),
468 pending_handle(req, i) = BLKBACK_INVALID_HANDLE; 670 GNTMAP_host_map, pages[i]->handle);
469 pages[invcount] = virt_to_page(vaddr(req, i)); 671 pages[i]->handle = BLKBACK_INVALID_HANDLE;
470 invcount++; 672 if (++invcount == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
673 ret = gnttab_unmap_refs(unmap, NULL, unmap_pages,
674 invcount);
675 BUG_ON(ret);
676 put_free_pages(blkif, unmap_pages, invcount);
677 invcount = 0;
678 }
679 }
680 if (invcount) {
681 ret = gnttab_unmap_refs(unmap, NULL, unmap_pages, invcount);
682 BUG_ON(ret);
683 put_free_pages(blkif, unmap_pages, invcount);
471 } 684 }
472
473 ret = gnttab_unmap_refs(unmap, NULL, pages, invcount);
474 BUG_ON(ret);
475} 685}
476 686
477static int xen_blkbk_map(struct blkif_request *req, 687static int xen_blkbk_map(struct xen_blkif *blkif,
478 struct pending_req *pending_req, 688 struct grant_page *pages[],
479 struct seg_buf seg[], 689 int num, bool ro)
480 struct page *pages[])
481{ 690{
482 struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 691 struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
483 struct persistent_gnt *persistent_gnts[BLKIF_MAX_SEGMENTS_PER_REQUEST];
484 struct page *pages_to_gnt[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 692 struct page *pages_to_gnt[BLKIF_MAX_SEGMENTS_PER_REQUEST];
485 struct persistent_gnt *persistent_gnt = NULL; 693 struct persistent_gnt *persistent_gnt = NULL;
486 struct xen_blkif *blkif = pending_req->blkif;
487 phys_addr_t addr = 0; 694 phys_addr_t addr = 0;
488 int i, j; 695 int i, seg_idx, new_map_idx;
489 bool new_map;
490 int nseg = req->u.rw.nr_segments;
491 int segs_to_map = 0; 696 int segs_to_map = 0;
492 int ret = 0; 697 int ret = 0;
698 int last_map = 0, map_until = 0;
493 int use_persistent_gnts; 699 int use_persistent_gnts;
494 700
495 use_persistent_gnts = (blkif->vbd.feature_gnt_persistent); 701 use_persistent_gnts = (blkif->vbd.feature_gnt_persistent);
496 702
497 BUG_ON(blkif->persistent_gnt_c >
498 max_mapped_grant_pages(pending_req->blkif->blk_protocol));
499
500 /* 703 /*
501 * Fill out preq.nr_sects with proper amount of sectors, and setup 704 * Fill out preq.nr_sects with proper amount of sectors, and setup
502 * assign map[..] with the PFN of the page in our domain with the 705 * assign map[..] with the PFN of the page in our domain with the
503 * corresponding grant reference for each page. 706 * corresponding grant reference for each page.
504 */ 707 */
505 for (i = 0; i < nseg; i++) { 708again:
709 for (i = map_until; i < num; i++) {
506 uint32_t flags; 710 uint32_t flags;
507 711
508 if (use_persistent_gnts) 712 if (use_persistent_gnts)
509 persistent_gnt = get_persistent_gnt( 713 persistent_gnt = get_persistent_gnt(
510 &blkif->persistent_gnts, 714 blkif,
511 req->u.rw.seg[i].gref); 715 pages[i]->gref);
512 716
513 if (persistent_gnt) { 717 if (persistent_gnt) {
514 /* 718 /*
515 * We are using persistent grants and 719 * We are using persistent grants and
516 * the grant is already mapped 720 * the grant is already mapped
517 */ 721 */
518 new_map = false; 722 pages[i]->page = persistent_gnt->page;
519 } else if (use_persistent_gnts && 723 pages[i]->persistent_gnt = persistent_gnt;
520 blkif->persistent_gnt_c <
521 max_mapped_grant_pages(blkif->blk_protocol)) {
522 /*
523 * We are using persistent grants, the grant is
524 * not mapped but we have room for it
525 */
526 new_map = true;
527 persistent_gnt = kmalloc(
528 sizeof(struct persistent_gnt),
529 GFP_KERNEL);
530 if (!persistent_gnt)
531 return -ENOMEM;
532 if (alloc_xenballooned_pages(1, &persistent_gnt->page,
533 false)) {
534 kfree(persistent_gnt);
535 return -ENOMEM;
536 }
537 persistent_gnt->gnt = req->u.rw.seg[i].gref;
538 persistent_gnt->handle = BLKBACK_INVALID_HANDLE;
539
540 pages_to_gnt[segs_to_map] =
541 persistent_gnt->page;
542 addr = (unsigned long) pfn_to_kaddr(
543 page_to_pfn(persistent_gnt->page));
544
545 add_persistent_gnt(&blkif->persistent_gnts,
546 persistent_gnt);
547 blkif->persistent_gnt_c++;
548 pr_debug(DRV_PFX " grant %u added to the tree of persistent grants, using %u/%u\n",
549 persistent_gnt->gnt, blkif->persistent_gnt_c,
550 max_mapped_grant_pages(blkif->blk_protocol));
551 } else { 724 } else {
552 /* 725 if (get_free_page(blkif, &pages[i]->page))
553 * We are either using persistent grants and 726 goto out_of_memory;
554 * hit the maximum limit of grants mapped, 727 addr = vaddr(pages[i]->page);
555 * or we are not using persistent grants. 728 pages_to_gnt[segs_to_map] = pages[i]->page;
556 */ 729 pages[i]->persistent_gnt = NULL;
557 if (use_persistent_gnts &&
558 !blkif->vbd.overflow_max_grants) {
559 blkif->vbd.overflow_max_grants = 1;
560 pr_alert(DRV_PFX " domain %u, device %#x is using maximum number of persistent grants\n",
561 blkif->domid, blkif->vbd.handle);
562 }
563 new_map = true;
564 pages[i] = blkbk->pending_page(pending_req, i);
565 addr = vaddr(pending_req, i);
566 pages_to_gnt[segs_to_map] =
567 blkbk->pending_page(pending_req, i);
568 }
569
570 if (persistent_gnt) {
571 pages[i] = persistent_gnt->page;
572 persistent_gnts[i] = persistent_gnt;
573 } else {
574 persistent_gnts[i] = NULL;
575 }
576
577 if (new_map) {
578 flags = GNTMAP_host_map; 730 flags = GNTMAP_host_map;
579 if (!persistent_gnt && 731 if (!use_persistent_gnts && ro)
580 (pending_req->operation != BLKIF_OP_READ))
581 flags |= GNTMAP_readonly; 732 flags |= GNTMAP_readonly;
582 gnttab_set_map_op(&map[segs_to_map++], addr, 733 gnttab_set_map_op(&map[segs_to_map++], addr,
583 flags, req->u.rw.seg[i].gref, 734 flags, pages[i]->gref,
584 blkif->domid); 735 blkif->domid);
585 } 736 }
737 map_until = i + 1;
738 if (segs_to_map == BLKIF_MAX_SEGMENTS_PER_REQUEST)
739 break;
586 } 740 }
587 741
588 if (segs_to_map) { 742 if (segs_to_map) {
@@ -595,49 +749,133 @@ static int xen_blkbk_map(struct blkif_request *req,
595 * so that when we access vaddr(pending_req,i) it has the contents of 749 * so that when we access vaddr(pending_req,i) it has the contents of
596 * the page from the other domain. 750 * the page from the other domain.
597 */ 751 */
598 bitmap_zero(pending_req->unmap_seg, BLKIF_MAX_SEGMENTS_PER_REQUEST); 752 for (seg_idx = last_map, new_map_idx = 0; seg_idx < map_until; seg_idx++) {
599 for (i = 0, j = 0; i < nseg; i++) { 753 if (!pages[seg_idx]->persistent_gnt) {
600 if (!persistent_gnts[i] ||
601 persistent_gnts[i]->handle == BLKBACK_INVALID_HANDLE) {
602 /* This is a newly mapped grant */ 754 /* This is a newly mapped grant */
603 BUG_ON(j >= segs_to_map); 755 BUG_ON(new_map_idx >= segs_to_map);
604 if (unlikely(map[j].status != 0)) { 756 if (unlikely(map[new_map_idx].status != 0)) {
605 pr_debug(DRV_PFX "invalid buffer -- could not remap it\n"); 757 pr_debug(DRV_PFX "invalid buffer -- could not remap it\n");
606 map[j].handle = BLKBACK_INVALID_HANDLE; 758 pages[seg_idx]->handle = BLKBACK_INVALID_HANDLE;
607 ret |= 1; 759 ret |= 1;
608 if (persistent_gnts[i]) { 760 goto next;
609 rb_erase(&persistent_gnts[i]->node,
610 &blkif->persistent_gnts);
611 blkif->persistent_gnt_c--;
612 kfree(persistent_gnts[i]);
613 persistent_gnts[i] = NULL;
614 }
615 } 761 }
762 pages[seg_idx]->handle = map[new_map_idx].handle;
763 } else {
764 continue;
616 } 765 }
617 if (persistent_gnts[i]) { 766 if (use_persistent_gnts &&
618 if (persistent_gnts[i]->handle == 767 blkif->persistent_gnt_c < xen_blkif_max_pgrants) {
619 BLKBACK_INVALID_HANDLE) { 768 /*
769 * We are using persistent grants, the grant is
770 * not mapped but we might have room for it.
771 */
772 persistent_gnt = kmalloc(sizeof(struct persistent_gnt),
773 GFP_KERNEL);
774 if (!persistent_gnt) {
620 /* 775 /*
621 * If this is a new persistent grant 776 * If we don't have enough memory to
622 * save the handler 777 * allocate the persistent_gnt struct
778 * map this grant non-persistenly
623 */ 779 */
624 persistent_gnts[i]->handle = map[j++].handle; 780 goto next;
625 } 781 }
626 pending_handle(pending_req, i) = 782 persistent_gnt->gnt = map[new_map_idx].ref;
627 persistent_gnts[i]->handle; 783 persistent_gnt->handle = map[new_map_idx].handle;
784 persistent_gnt->page = pages[seg_idx]->page;
785 if (add_persistent_gnt(blkif,
786 persistent_gnt)) {
787 kfree(persistent_gnt);
788 persistent_gnt = NULL;
789 goto next;
790 }
791 pages[seg_idx]->persistent_gnt = persistent_gnt;
792 pr_debug(DRV_PFX " grant %u added to the tree of persistent grants, using %u/%u\n",
793 persistent_gnt->gnt, blkif->persistent_gnt_c,
794 xen_blkif_max_pgrants);
795 goto next;
796 }
797 if (use_persistent_gnts && !blkif->vbd.overflow_max_grants) {
798 blkif->vbd.overflow_max_grants = 1;
799 pr_debug(DRV_PFX " domain %u, device %#x is using maximum number of persistent grants\n",
800 blkif->domid, blkif->vbd.handle);
801 }
802 /*
803 * We could not map this grant persistently, so use it as
804 * a non-persistent grant.
805 */
806next:
807 new_map_idx++;
808 }
809 segs_to_map = 0;
810 last_map = map_until;
811 if (map_until != num)
812 goto again;
628 813
629 if (ret) 814 return ret;
630 continue; 815
631 } else { 816out_of_memory:
632 pending_handle(pending_req, i) = map[j++].handle; 817 pr_alert(DRV_PFX "%s: out of memory\n", __func__);
633 bitmap_set(pending_req->unmap_seg, i, 1); 818 put_free_pages(blkif, pages_to_gnt, segs_to_map);
819 return -ENOMEM;
820}
821
822static int xen_blkbk_map_seg(struct pending_req *pending_req)
823{
824 int rc;
825
826 rc = xen_blkbk_map(pending_req->blkif, pending_req->segments,
827 pending_req->nr_pages,
828 (pending_req->operation != BLKIF_OP_READ));
829
830 return rc;
831}
634 832
635 if (ret) 833static int xen_blkbk_parse_indirect(struct blkif_request *req,
636 continue; 834 struct pending_req *pending_req,
835 struct seg_buf seg[],
836 struct phys_req *preq)
837{
838 struct grant_page **pages = pending_req->indirect_pages;
839 struct xen_blkif *blkif = pending_req->blkif;
840 int indirect_grefs, rc, n, nseg, i;
841 struct blkif_request_segment_aligned *segments = NULL;
842
843 nseg = pending_req->nr_pages;
844 indirect_grefs = INDIRECT_PAGES(nseg);
845 BUG_ON(indirect_grefs > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
846
847 for (i = 0; i < indirect_grefs; i++)
848 pages[i]->gref = req->u.indirect.indirect_grefs[i];
849
850 rc = xen_blkbk_map(blkif, pages, indirect_grefs, true);
851 if (rc)
852 goto unmap;
853
854 for (n = 0, i = 0; n < nseg; n++) {
855 if ((n % SEGS_PER_INDIRECT_FRAME) == 0) {
856 /* Map indirect segments */
857 if (segments)
858 kunmap_atomic(segments);
859 segments = kmap_atomic(pages[n/SEGS_PER_INDIRECT_FRAME]->page);
860 }
861 i = n % SEGS_PER_INDIRECT_FRAME;
862 pending_req->segments[n]->gref = segments[i].gref;
863 seg[n].nsec = segments[i].last_sect -
864 segments[i].first_sect + 1;
865 seg[n].offset = (segments[i].first_sect << 9);
866 if ((segments[i].last_sect >= (PAGE_SIZE >> 9)) ||
867 (segments[i].last_sect < segments[i].first_sect)) {
868 rc = -EINVAL;
869 goto unmap;
637 } 870 }
638 seg[i].offset = (req->u.rw.seg[i].first_sect << 9); 871 preq->nr_sects += seg[n].nsec;
639 } 872 }
640 return ret; 873
874unmap:
875 if (segments)
876 kunmap_atomic(segments);
877 xen_blkbk_unmap(blkif, pages, indirect_grefs);
878 return rc;
641} 879}
642 880
643static int dispatch_discard_io(struct xen_blkif *blkif, 881static int dispatch_discard_io(struct xen_blkif *blkif,
@@ -647,7 +885,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
647 int status = BLKIF_RSP_OKAY; 885 int status = BLKIF_RSP_OKAY;
648 struct block_device *bdev = blkif->vbd.bdev; 886 struct block_device *bdev = blkif->vbd.bdev;
649 unsigned long secure; 887 unsigned long secure;
888 struct phys_req preq;
889
890 preq.sector_number = req->u.discard.sector_number;
891 preq.nr_sects = req->u.discard.nr_sectors;
650 892
893 err = xen_vbd_translate(&preq, blkif, WRITE);
894 if (err) {
895 pr_warn(DRV_PFX "access denied: DISCARD [%llu->%llu] on dev=%04x\n",
896 preq.sector_number,
897 preq.sector_number + preq.nr_sects, blkif->vbd.pdevice);
898 goto fail_response;
899 }
651 blkif->st_ds_req++; 900 blkif->st_ds_req++;
652 901
653 xen_blkif_get(blkif); 902 xen_blkif_get(blkif);
@@ -658,7 +907,7 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
658 err = blkdev_issue_discard(bdev, req->u.discard.sector_number, 907 err = blkdev_issue_discard(bdev, req->u.discard.sector_number,
659 req->u.discard.nr_sectors, 908 req->u.discard.nr_sectors,
660 GFP_KERNEL, secure); 909 GFP_KERNEL, secure);
661 910fail_response:
662 if (err == -EOPNOTSUPP) { 911 if (err == -EOPNOTSUPP) {
663 pr_debug(DRV_PFX "discard op failed, not supported\n"); 912 pr_debug(DRV_PFX "discard op failed, not supported\n");
664 status = BLKIF_RSP_EOPNOTSUPP; 913 status = BLKIF_RSP_EOPNOTSUPP;
@@ -674,7 +923,7 @@ static int dispatch_other_io(struct xen_blkif *blkif,
674 struct blkif_request *req, 923 struct blkif_request *req,
675 struct pending_req *pending_req) 924 struct pending_req *pending_req)
676{ 925{
677 free_req(pending_req); 926 free_req(blkif, pending_req);
678 make_response(blkif, req->u.other.id, req->operation, 927 make_response(blkif, req->u.other.id, req->operation,
679 BLKIF_RSP_EOPNOTSUPP); 928 BLKIF_RSP_EOPNOTSUPP);
680 return -EIO; 929 return -EIO;
@@ -726,7 +975,9 @@ static void __end_block_io_op(struct pending_req *pending_req, int error)
726 * the proper response on the ring. 975 * the proper response on the ring.
727 */ 976 */
728 if (atomic_dec_and_test(&pending_req->pendcnt)) { 977 if (atomic_dec_and_test(&pending_req->pendcnt)) {
729 xen_blkbk_unmap(pending_req); 978 xen_blkbk_unmap(pending_req->blkif,
979 pending_req->segments,
980 pending_req->nr_pages);
730 make_response(pending_req->blkif, pending_req->id, 981 make_response(pending_req->blkif, pending_req->id,
731 pending_req->operation, pending_req->status); 982 pending_req->operation, pending_req->status);
732 xen_blkif_put(pending_req->blkif); 983 xen_blkif_put(pending_req->blkif);
@@ -734,7 +985,7 @@ static void __end_block_io_op(struct pending_req *pending_req, int error)
734 if (atomic_read(&pending_req->blkif->drain)) 985 if (atomic_read(&pending_req->blkif->drain))
735 complete(&pending_req->blkif->drain_complete); 986 complete(&pending_req->blkif->drain_complete);
736 } 987 }
737 free_req(pending_req); 988 free_req(pending_req->blkif, pending_req);
738 } 989 }
739} 990}
740 991
@@ -767,6 +1018,12 @@ __do_block_io_op(struct xen_blkif *blkif)
767 rp = blk_rings->common.sring->req_prod; 1018 rp = blk_rings->common.sring->req_prod;
768 rmb(); /* Ensure we see queued requests up to 'rp'. */ 1019 rmb(); /* Ensure we see queued requests up to 'rp'. */
769 1020
1021 if (RING_REQUEST_PROD_OVERFLOW(&blk_rings->common, rp)) {
1022 rc = blk_rings->common.rsp_prod_pvt;
1023 pr_warn(DRV_PFX "Frontend provided bogus ring requests (%d - %d = %d). Halting ring processing on dev=%04x\n",
1024 rp, rc, rp - rc, blkif->vbd.pdevice);
1025 return -EACCES;
1026 }
770 while (rc != rp) { 1027 while (rc != rp) {
771 1028
772 if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc)) 1029 if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc))
@@ -777,7 +1034,7 @@ __do_block_io_op(struct xen_blkif *blkif)
777 break; 1034 break;
778 } 1035 }
779 1036
780 pending_req = alloc_req(); 1037 pending_req = alloc_req(blkif);
781 if (NULL == pending_req) { 1038 if (NULL == pending_req) {
782 blkif->st_oo_req++; 1039 blkif->st_oo_req++;
783 more_to_do = 1; 1040 more_to_do = 1;
@@ -807,11 +1064,12 @@ __do_block_io_op(struct xen_blkif *blkif)
807 case BLKIF_OP_WRITE: 1064 case BLKIF_OP_WRITE:
808 case BLKIF_OP_WRITE_BARRIER: 1065 case BLKIF_OP_WRITE_BARRIER:
809 case BLKIF_OP_FLUSH_DISKCACHE: 1066 case BLKIF_OP_FLUSH_DISKCACHE:
1067 case BLKIF_OP_INDIRECT:
810 if (dispatch_rw_block_io(blkif, &req, pending_req)) 1068 if (dispatch_rw_block_io(blkif, &req, pending_req))
811 goto done; 1069 goto done;
812 break; 1070 break;
813 case BLKIF_OP_DISCARD: 1071 case BLKIF_OP_DISCARD:
814 free_req(pending_req); 1072 free_req(blkif, pending_req);
815 if (dispatch_discard_io(blkif, &req)) 1073 if (dispatch_discard_io(blkif, &req))
816 goto done; 1074 goto done;
817 break; 1075 break;
@@ -853,17 +1111,28 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
853 struct pending_req *pending_req) 1111 struct pending_req *pending_req)
854{ 1112{
855 struct phys_req preq; 1113 struct phys_req preq;
856 struct seg_buf seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 1114 struct seg_buf *seg = pending_req->seg;
857 unsigned int nseg; 1115 unsigned int nseg;
858 struct bio *bio = NULL; 1116 struct bio *bio = NULL;
859 struct bio *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 1117 struct bio **biolist = pending_req->biolist;
860 int i, nbio = 0; 1118 int i, nbio = 0;
861 int operation; 1119 int operation;
862 struct blk_plug plug; 1120 struct blk_plug plug;
863 bool drain = false; 1121 bool drain = false;
864 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 1122 struct grant_page **pages = pending_req->segments;
1123 unsigned short req_operation;
1124
1125 req_operation = req->operation == BLKIF_OP_INDIRECT ?
1126 req->u.indirect.indirect_op : req->operation;
1127 if ((req->operation == BLKIF_OP_INDIRECT) &&
1128 (req_operation != BLKIF_OP_READ) &&
1129 (req_operation != BLKIF_OP_WRITE)) {
1130 pr_debug(DRV_PFX "Invalid indirect operation (%u)\n",
1131 req_operation);
1132 goto fail_response;
1133 }
865 1134
866 switch (req->operation) { 1135 switch (req_operation) {
867 case BLKIF_OP_READ: 1136 case BLKIF_OP_READ:
868 blkif->st_rd_req++; 1137 blkif->st_rd_req++;
869 operation = READ; 1138 operation = READ;
@@ -885,33 +1154,47 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
885 } 1154 }
886 1155
887 /* Check that the number of segments is sane. */ 1156 /* Check that the number of segments is sane. */
888 nseg = req->u.rw.nr_segments; 1157 nseg = req->operation == BLKIF_OP_INDIRECT ?
1158 req->u.indirect.nr_segments : req->u.rw.nr_segments;
889 1159
890 if (unlikely(nseg == 0 && operation != WRITE_FLUSH) || 1160 if (unlikely(nseg == 0 && operation != WRITE_FLUSH) ||
891 unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) { 1161 unlikely((req->operation != BLKIF_OP_INDIRECT) &&
1162 (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) ||
1163 unlikely((req->operation == BLKIF_OP_INDIRECT) &&
1164 (nseg > MAX_INDIRECT_SEGMENTS))) {
892 pr_debug(DRV_PFX "Bad number of segments in request (%d)\n", 1165 pr_debug(DRV_PFX "Bad number of segments in request (%d)\n",
893 nseg); 1166 nseg);
894 /* Haven't submitted any bio's yet. */ 1167 /* Haven't submitted any bio's yet. */
895 goto fail_response; 1168 goto fail_response;
896 } 1169 }
897 1170
898 preq.sector_number = req->u.rw.sector_number;
899 preq.nr_sects = 0; 1171 preq.nr_sects = 0;
900 1172
901 pending_req->blkif = blkif; 1173 pending_req->blkif = blkif;
902 pending_req->id = req->u.rw.id; 1174 pending_req->id = req->u.rw.id;
903 pending_req->operation = req->operation; 1175 pending_req->operation = req_operation;
904 pending_req->status = BLKIF_RSP_OKAY; 1176 pending_req->status = BLKIF_RSP_OKAY;
905 pending_req->nr_pages = nseg; 1177 pending_req->nr_pages = nseg;
906 1178
907 for (i = 0; i < nseg; i++) { 1179 if (req->operation != BLKIF_OP_INDIRECT) {
908 seg[i].nsec = req->u.rw.seg[i].last_sect - 1180 preq.dev = req->u.rw.handle;
909 req->u.rw.seg[i].first_sect + 1; 1181 preq.sector_number = req->u.rw.sector_number;
910 if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) || 1182 for (i = 0; i < nseg; i++) {
911 (req->u.rw.seg[i].last_sect < req->u.rw.seg[i].first_sect)) 1183 pages[i]->gref = req->u.rw.seg[i].gref;
1184 seg[i].nsec = req->u.rw.seg[i].last_sect -
1185 req->u.rw.seg[i].first_sect + 1;
1186 seg[i].offset = (req->u.rw.seg[i].first_sect << 9);
1187 if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) ||
1188 (req->u.rw.seg[i].last_sect <
1189 req->u.rw.seg[i].first_sect))
1190 goto fail_response;
1191 preq.nr_sects += seg[i].nsec;
1192 }
1193 } else {
1194 preq.dev = req->u.indirect.handle;
1195 preq.sector_number = req->u.indirect.sector_number;
1196 if (xen_blkbk_parse_indirect(req, pending_req, seg, &preq))
912 goto fail_response; 1197 goto fail_response;
913 preq.nr_sects += seg[i].nsec;
914
915 } 1198 }
916 1199
917 if (xen_vbd_translate(&preq, blkif, operation) != 0) { 1200 if (xen_vbd_translate(&preq, blkif, operation) != 0) {
@@ -948,7 +1231,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
948 * the hypercall to unmap the grants - that is all done in 1231 * the hypercall to unmap the grants - that is all done in
949 * xen_blkbk_unmap. 1232 * xen_blkbk_unmap.
950 */ 1233 */
951 if (xen_blkbk_map(req, pending_req, seg, pages)) 1234 if (xen_blkbk_map_seg(pending_req))
952 goto fail_flush; 1235 goto fail_flush;
953 1236
954 /* 1237 /*
@@ -960,11 +1243,12 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
960 for (i = 0; i < nseg; i++) { 1243 for (i = 0; i < nseg; i++) {
961 while ((bio == NULL) || 1244 while ((bio == NULL) ||
962 (bio_add_page(bio, 1245 (bio_add_page(bio,
963 pages[i], 1246 pages[i]->page,
964 seg[i].nsec << 9, 1247 seg[i].nsec << 9,
965 seg[i].offset) == 0)) { 1248 seg[i].offset) == 0)) {
966 1249
967 bio = bio_alloc(GFP_KERNEL, nseg-i); 1250 int nr_iovecs = min_t(int, (nseg-i), BIO_MAX_PAGES);
1251 bio = bio_alloc(GFP_KERNEL, nr_iovecs);
968 if (unlikely(bio == NULL)) 1252 if (unlikely(bio == NULL))
969 goto fail_put_bio; 1253 goto fail_put_bio;
970 1254
@@ -1009,11 +1293,12 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
1009 return 0; 1293 return 0;
1010 1294
1011 fail_flush: 1295 fail_flush:
1012 xen_blkbk_unmap(pending_req); 1296 xen_blkbk_unmap(blkif, pending_req->segments,
1297 pending_req->nr_pages);
1013 fail_response: 1298 fail_response:
1014 /* Haven't submitted any bio's yet. */ 1299 /* Haven't submitted any bio's yet. */
1015 make_response(blkif, req->u.rw.id, req->operation, BLKIF_RSP_ERROR); 1300 make_response(blkif, req->u.rw.id, req_operation, BLKIF_RSP_ERROR);
1016 free_req(pending_req); 1301 free_req(blkif, pending_req);
1017 msleep(1); /* back off a bit */ 1302 msleep(1); /* back off a bit */
1018 return -EIO; 1303 return -EIO;
1019 1304
@@ -1070,73 +1355,20 @@ static void make_response(struct xen_blkif *blkif, u64 id,
1070 1355
1071static int __init xen_blkif_init(void) 1356static int __init xen_blkif_init(void)
1072{ 1357{
1073 int i, mmap_pages;
1074 int rc = 0; 1358 int rc = 0;
1075 1359
1076 if (!xen_domain()) 1360 if (!xen_domain())
1077 return -ENODEV; 1361 return -ENODEV;
1078 1362
1079 blkbk = kzalloc(sizeof(struct xen_blkbk), GFP_KERNEL);
1080 if (!blkbk) {
1081 pr_alert(DRV_PFX "%s: out of memory!\n", __func__);
1082 return -ENOMEM;
1083 }
1084
1085 mmap_pages = xen_blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
1086
1087 blkbk->pending_reqs = kzalloc(sizeof(blkbk->pending_reqs[0]) *
1088 xen_blkif_reqs, GFP_KERNEL);
1089 blkbk->pending_grant_handles = kmalloc(sizeof(blkbk->pending_grant_handles[0]) *
1090 mmap_pages, GFP_KERNEL);
1091 blkbk->pending_pages = kzalloc(sizeof(blkbk->pending_pages[0]) *
1092 mmap_pages, GFP_KERNEL);
1093
1094 if (!blkbk->pending_reqs || !blkbk->pending_grant_handles ||
1095 !blkbk->pending_pages) {
1096 rc = -ENOMEM;
1097 goto out_of_memory;
1098 }
1099
1100 for (i = 0; i < mmap_pages; i++) {
1101 blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
1102 blkbk->pending_pages[i] = alloc_page(GFP_KERNEL);
1103 if (blkbk->pending_pages[i] == NULL) {
1104 rc = -ENOMEM;
1105 goto out_of_memory;
1106 }
1107 }
1108 rc = xen_blkif_interface_init(); 1363 rc = xen_blkif_interface_init();
1109 if (rc) 1364 if (rc)
1110 goto failed_init; 1365 goto failed_init;
1111 1366
1112 INIT_LIST_HEAD(&blkbk->pending_free);
1113 spin_lock_init(&blkbk->pending_free_lock);
1114 init_waitqueue_head(&blkbk->pending_free_wq);
1115
1116 for (i = 0; i < xen_blkif_reqs; i++)
1117 list_add_tail(&blkbk->pending_reqs[i].free_list,
1118 &blkbk->pending_free);
1119
1120 rc = xen_blkif_xenbus_init(); 1367 rc = xen_blkif_xenbus_init();
1121 if (rc) 1368 if (rc)
1122 goto failed_init; 1369 goto failed_init;
1123 1370
1124 return 0;
1125
1126 out_of_memory:
1127 pr_alert(DRV_PFX "%s: out of memory\n", __func__);
1128 failed_init: 1371 failed_init:
1129 kfree(blkbk->pending_reqs);
1130 kfree(blkbk->pending_grant_handles);
1131 if (blkbk->pending_pages) {
1132 for (i = 0; i < mmap_pages; i++) {
1133 if (blkbk->pending_pages[i])
1134 __free_page(blkbk->pending_pages[i]);
1135 }
1136 kfree(blkbk->pending_pages);
1137 }
1138 kfree(blkbk);
1139 blkbk = NULL;
1140 return rc; 1372 return rc;
1141} 1373}
1142 1374
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 60103e2517ba..8d8807563d99 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -50,6 +50,19 @@
50 __func__, __LINE__, ##args) 50 __func__, __LINE__, ##args)
51 51
52 52
53/*
54 * This is the maximum number of segments that would be allowed in indirect
55 * requests. This value will also be passed to the frontend.
56 */
57#define MAX_INDIRECT_SEGMENTS 256
58
59#define SEGS_PER_INDIRECT_FRAME \
60 (PAGE_SIZE/sizeof(struct blkif_request_segment_aligned))
61#define MAX_INDIRECT_PAGES \
62 ((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
63#define INDIRECT_PAGES(_segs) \
64 ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
65
53/* Not a real protocol. Used to generate ring structs which contain 66/* Not a real protocol. Used to generate ring structs which contain
54 * the elements common to all protocols only. This way we get a 67 * the elements common to all protocols only. This way we get a
55 * compiler-checkable way to use common struct elements, so we can 68 * compiler-checkable way to use common struct elements, so we can
@@ -83,12 +96,31 @@ struct blkif_x86_32_request_other {
83 uint64_t id; /* private guest value, echoed in resp */ 96 uint64_t id; /* private guest value, echoed in resp */
84} __attribute__((__packed__)); 97} __attribute__((__packed__));
85 98
99struct blkif_x86_32_request_indirect {
100 uint8_t indirect_op;
101 uint16_t nr_segments;
102 uint64_t id;
103 blkif_sector_t sector_number;
104 blkif_vdev_t handle;
105 uint16_t _pad1;
106 grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
107 /*
108 * The maximum number of indirect segments (and pages) that will
109 * be used is determined by MAX_INDIRECT_SEGMENTS, this value
110 * is also exported to the guest (via xenstore
111 * feature-max-indirect-segments entry), so the frontend knows how
112 * many indirect segments the backend supports.
113 */
114 uint64_t _pad2; /* make it 64 byte aligned */
115} __attribute__((__packed__));
116
86struct blkif_x86_32_request { 117struct blkif_x86_32_request {
87 uint8_t operation; /* BLKIF_OP_??? */ 118 uint8_t operation; /* BLKIF_OP_??? */
88 union { 119 union {
89 struct blkif_x86_32_request_rw rw; 120 struct blkif_x86_32_request_rw rw;
90 struct blkif_x86_32_request_discard discard; 121 struct blkif_x86_32_request_discard discard;
91 struct blkif_x86_32_request_other other; 122 struct blkif_x86_32_request_other other;
123 struct blkif_x86_32_request_indirect indirect;
92 } u; 124 } u;
93} __attribute__((__packed__)); 125} __attribute__((__packed__));
94 126
@@ -127,12 +159,32 @@ struct blkif_x86_64_request_other {
127 uint64_t id; /* private guest value, echoed in resp */ 159 uint64_t id; /* private guest value, echoed in resp */
128} __attribute__((__packed__)); 160} __attribute__((__packed__));
129 161
162struct blkif_x86_64_request_indirect {
163 uint8_t indirect_op;
164 uint16_t nr_segments;
165 uint32_t _pad1; /* offsetof(blkif_..,u.indirect.id)==8 */
166 uint64_t id;
167 blkif_sector_t sector_number;
168 blkif_vdev_t handle;
169 uint16_t _pad2;
170 grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
171 /*
172 * The maximum number of indirect segments (and pages) that will
173 * be used is determined by MAX_INDIRECT_SEGMENTS, this value
174 * is also exported to the guest (via xenstore
175 * feature-max-indirect-segments entry), so the frontend knows how
176 * many indirect segments the backend supports.
177 */
178 uint32_t _pad3; /* make it 64 byte aligned */
179} __attribute__((__packed__));
180
130struct blkif_x86_64_request { 181struct blkif_x86_64_request {
131 uint8_t operation; /* BLKIF_OP_??? */ 182 uint8_t operation; /* BLKIF_OP_??? */
132 union { 183 union {
133 struct blkif_x86_64_request_rw rw; 184 struct blkif_x86_64_request_rw rw;
134 struct blkif_x86_64_request_discard discard; 185 struct blkif_x86_64_request_discard discard;
135 struct blkif_x86_64_request_other other; 186 struct blkif_x86_64_request_other other;
187 struct blkif_x86_64_request_indirect indirect;
136 } u; 188 } u;
137} __attribute__((__packed__)); 189} __attribute__((__packed__));
138 190
@@ -182,12 +234,26 @@ struct xen_vbd {
182 234
183struct backend_info; 235struct backend_info;
184 236
237/* Number of available flags */
238#define PERSISTENT_GNT_FLAGS_SIZE 2
239/* This persistent grant is currently in use */
240#define PERSISTENT_GNT_ACTIVE 0
241/*
242 * This persistent grant has been used, this flag is set when we remove the
243 * PERSISTENT_GNT_ACTIVE, to know that this grant has been used recently.
244 */
245#define PERSISTENT_GNT_WAS_ACTIVE 1
246
247/* Number of requests that we can fit in a ring */
248#define XEN_BLKIF_REQS 32
185 249
186struct persistent_gnt { 250struct persistent_gnt {
187 struct page *page; 251 struct page *page;
188 grant_ref_t gnt; 252 grant_ref_t gnt;
189 grant_handle_t handle; 253 grant_handle_t handle;
254 DECLARE_BITMAP(flags, PERSISTENT_GNT_FLAGS_SIZE);
190 struct rb_node node; 255 struct rb_node node;
256 struct list_head remove_node;
191}; 257};
192 258
193struct xen_blkif { 259struct xen_blkif {
@@ -219,6 +285,23 @@ struct xen_blkif {
219 /* tree to store persistent grants */ 285 /* tree to store persistent grants */
220 struct rb_root persistent_gnts; 286 struct rb_root persistent_gnts;
221 unsigned int persistent_gnt_c; 287 unsigned int persistent_gnt_c;
288 atomic_t persistent_gnt_in_use;
289 unsigned long next_lru;
290
291 /* used by the kworker that offload work from the persistent purge */
292 struct list_head persistent_purge_list;
293 struct work_struct persistent_purge_work;
294
295 /* buffer of free pages to map grant refs */
296 spinlock_t free_pages_lock;
297 int free_pages_num;
298 struct list_head free_pages;
299
300 /* List of all 'pending_req' available */
301 struct list_head pending_free;
302 /* And its spinlock. */
303 spinlock_t pending_free_lock;
304 wait_queue_head_t pending_free_wq;
222 305
223 /* statistics */ 306 /* statistics */
224 unsigned long st_print; 307 unsigned long st_print;
@@ -231,6 +314,41 @@ struct xen_blkif {
231 unsigned long long st_wr_sect; 314 unsigned long long st_wr_sect;
232 315
233 wait_queue_head_t waiting_to_free; 316 wait_queue_head_t waiting_to_free;
317 /* Thread shutdown wait queue. */
318 wait_queue_head_t shutdown_wq;
319};
320
321struct seg_buf {
322 unsigned long offset;
323 unsigned int nsec;
324};
325
326struct grant_page {
327 struct page *page;
328 struct persistent_gnt *persistent_gnt;
329 grant_handle_t handle;
330 grant_ref_t gref;
331};
332
333/*
334 * Each outstanding request that we've passed to the lower device layers has a
335 * 'pending_req' allocated to it. Each buffer_head that completes decrements
336 * the pendcnt towards zero. When it hits zero, the specified domain has a
337 * response queued for it, with the saved 'id' passed back.
338 */
339struct pending_req {
340 struct xen_blkif *blkif;
341 u64 id;
342 int nr_pages;
343 atomic_t pendcnt;
344 unsigned short operation;
345 int status;
346 struct list_head free_list;
347 struct grant_page *segments[MAX_INDIRECT_SEGMENTS];
348 /* Indirect descriptors */
349 struct grant_page *indirect_pages[MAX_INDIRECT_PAGES];
350 struct seg_buf seg[MAX_INDIRECT_SEGMENTS];
351 struct bio *biolist[MAX_INDIRECT_SEGMENTS];
234}; 352};
235 353
236 354
@@ -257,6 +375,7 @@ int xen_blkif_xenbus_init(void);
257 375
258irqreturn_t xen_blkif_be_int(int irq, void *dev_id); 376irqreturn_t xen_blkif_be_int(int irq, void *dev_id);
259int xen_blkif_schedule(void *arg); 377int xen_blkif_schedule(void *arg);
378int xen_blkif_purge_persistent(void *arg);
260 379
261int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt, 380int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
262 struct backend_info *be, int state); 381 struct backend_info *be, int state);
@@ -268,7 +387,7 @@ struct xenbus_device *xen_blkbk_xenbus(struct backend_info *be);
268static inline void blkif_get_x86_32_req(struct blkif_request *dst, 387static inline void blkif_get_x86_32_req(struct blkif_request *dst,
269 struct blkif_x86_32_request *src) 388 struct blkif_x86_32_request *src)
270{ 389{
271 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST; 390 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j;
272 dst->operation = src->operation; 391 dst->operation = src->operation;
273 switch (src->operation) { 392 switch (src->operation) {
274 case BLKIF_OP_READ: 393 case BLKIF_OP_READ:
@@ -291,6 +410,18 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst,
291 dst->u.discard.sector_number = src->u.discard.sector_number; 410 dst->u.discard.sector_number = src->u.discard.sector_number;
292 dst->u.discard.nr_sectors = src->u.discard.nr_sectors; 411 dst->u.discard.nr_sectors = src->u.discard.nr_sectors;
293 break; 412 break;
413 case BLKIF_OP_INDIRECT:
414 dst->u.indirect.indirect_op = src->u.indirect.indirect_op;
415 dst->u.indirect.nr_segments = src->u.indirect.nr_segments;
416 dst->u.indirect.handle = src->u.indirect.handle;
417 dst->u.indirect.id = src->u.indirect.id;
418 dst->u.indirect.sector_number = src->u.indirect.sector_number;
419 barrier();
420 j = min(MAX_INDIRECT_PAGES, INDIRECT_PAGES(dst->u.indirect.nr_segments));
421 for (i = 0; i < j; i++)
422 dst->u.indirect.indirect_grefs[i] =
423 src->u.indirect.indirect_grefs[i];
424 break;
294 default: 425 default:
295 /* 426 /*
296 * Don't know how to translate this op. Only get the 427 * 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,
304static inline void blkif_get_x86_64_req(struct blkif_request *dst, 435static inline void blkif_get_x86_64_req(struct blkif_request *dst,
305 struct blkif_x86_64_request *src) 436 struct blkif_x86_64_request *src)
306{ 437{
307 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST; 438 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j;
308 dst->operation = src->operation; 439 dst->operation = src->operation;
309 switch (src->operation) { 440 switch (src->operation) {
310 case BLKIF_OP_READ: 441 case BLKIF_OP_READ:
@@ -327,6 +458,18 @@ static inline void blkif_get_x86_64_req(struct blkif_request *dst,
327 dst->u.discard.sector_number = src->u.discard.sector_number; 458 dst->u.discard.sector_number = src->u.discard.sector_number;
328 dst->u.discard.nr_sectors = src->u.discard.nr_sectors; 459 dst->u.discard.nr_sectors = src->u.discard.nr_sectors;
329 break; 460 break;
461 case BLKIF_OP_INDIRECT:
462 dst->u.indirect.indirect_op = src->u.indirect.indirect_op;
463 dst->u.indirect.nr_segments = src->u.indirect.nr_segments;
464 dst->u.indirect.handle = src->u.indirect.handle;
465 dst->u.indirect.id = src->u.indirect.id;
466 dst->u.indirect.sector_number = src->u.indirect.sector_number;
467 barrier();
468 j = min(MAX_INDIRECT_PAGES, INDIRECT_PAGES(dst->u.indirect.nr_segments));
469 for (i = 0; i < j; i++)
470 dst->u.indirect.indirect_grefs[i] =
471 src->u.indirect.indirect_grefs[i];
472 break;
330 default: 473 default:
331 /* 474 /*
332 * Don't know how to translate this op. Only get the 475 * Don't know how to translate this op. Only get the
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 04608a6502d7..fe5c3cd10c34 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -98,12 +98,17 @@ static void xen_update_blkif_status(struct xen_blkif *blkif)
98 err = PTR_ERR(blkif->xenblkd); 98 err = PTR_ERR(blkif->xenblkd);
99 blkif->xenblkd = NULL; 99 blkif->xenblkd = NULL;
100 xenbus_dev_error(blkif->be->dev, err, "start xenblkd"); 100 xenbus_dev_error(blkif->be->dev, err, "start xenblkd");
101 return;
101 } 102 }
102} 103}
103 104
104static struct xen_blkif *xen_blkif_alloc(domid_t domid) 105static struct xen_blkif *xen_blkif_alloc(domid_t domid)
105{ 106{
106 struct xen_blkif *blkif; 107 struct xen_blkif *blkif;
108 struct pending_req *req, *n;
109 int i, j;
110
111 BUILD_BUG_ON(MAX_INDIRECT_PAGES > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
107 112
108 blkif = kmem_cache_zalloc(xen_blkif_cachep, GFP_KERNEL); 113 blkif = kmem_cache_zalloc(xen_blkif_cachep, GFP_KERNEL);
109 if (!blkif) 114 if (!blkif)
@@ -118,8 +123,57 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
118 blkif->st_print = jiffies; 123 blkif->st_print = jiffies;
119 init_waitqueue_head(&blkif->waiting_to_free); 124 init_waitqueue_head(&blkif->waiting_to_free);
120 blkif->persistent_gnts.rb_node = NULL; 125 blkif->persistent_gnts.rb_node = NULL;
126 spin_lock_init(&blkif->free_pages_lock);
127 INIT_LIST_HEAD(&blkif->free_pages);
128 blkif->free_pages_num = 0;
129 atomic_set(&blkif->persistent_gnt_in_use, 0);
130
131 INIT_LIST_HEAD(&blkif->pending_free);
132
133 for (i = 0; i < XEN_BLKIF_REQS; i++) {
134 req = kzalloc(sizeof(*req), GFP_KERNEL);
135 if (!req)
136 goto fail;
137 list_add_tail(&req->free_list,
138 &blkif->pending_free);
139 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) {
140 req->segments[j] = kzalloc(sizeof(*req->segments[0]),
141 GFP_KERNEL);
142 if (!req->segments[j])
143 goto fail;
144 }
145 for (j = 0; j < MAX_INDIRECT_PAGES; j++) {
146 req->indirect_pages[j] = kzalloc(sizeof(*req->indirect_pages[0]),
147 GFP_KERNEL);
148 if (!req->indirect_pages[j])
149 goto fail;
150 }
151 }
152 spin_lock_init(&blkif->pending_free_lock);
153 init_waitqueue_head(&blkif->pending_free_wq);
154 init_waitqueue_head(&blkif->shutdown_wq);
121 155
122 return blkif; 156 return blkif;
157
158fail:
159 list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
160 list_del(&req->free_list);
161 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) {
162 if (!req->segments[j])
163 break;
164 kfree(req->segments[j]);
165 }
166 for (j = 0; j < MAX_INDIRECT_PAGES; j++) {
167 if (!req->indirect_pages[j])
168 break;
169 kfree(req->indirect_pages[j]);
170 }
171 kfree(req);
172 }
173
174 kmem_cache_free(xen_blkif_cachep, blkif);
175
176 return ERR_PTR(-ENOMEM);
123} 177}
124 178
125static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page, 179static 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)
178{ 232{
179 if (blkif->xenblkd) { 233 if (blkif->xenblkd) {
180 kthread_stop(blkif->xenblkd); 234 kthread_stop(blkif->xenblkd);
235 wake_up(&blkif->shutdown_wq);
181 blkif->xenblkd = NULL; 236 blkif->xenblkd = NULL;
182 } 237 }
183 238
@@ -198,8 +253,28 @@ static void xen_blkif_disconnect(struct xen_blkif *blkif)
198 253
199static void xen_blkif_free(struct xen_blkif *blkif) 254static void xen_blkif_free(struct xen_blkif *blkif)
200{ 255{
256 struct pending_req *req, *n;
257 int i = 0, j;
258
201 if (!atomic_dec_and_test(&blkif->refcnt)) 259 if (!atomic_dec_and_test(&blkif->refcnt))
202 BUG(); 260 BUG();
261
262 /* Check that there is no request in use */
263 list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
264 list_del(&req->free_list);
265
266 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++)
267 kfree(req->segments[j]);
268
269 for (j = 0; j < MAX_INDIRECT_PAGES; j++)
270 kfree(req->indirect_pages[j]);
271
272 kfree(req);
273 i++;
274 }
275
276 WARN_ON(i != XEN_BLKIF_REQS);
277
203 kmem_cache_free(xen_blkif_cachep, blkif); 278 kmem_cache_free(xen_blkif_cachep, blkif);
204} 279}
205 280
@@ -678,6 +753,11 @@ again:
678 dev->nodename); 753 dev->nodename);
679 goto abort; 754 goto abort;
680 } 755 }
756 err = xenbus_printf(xbt, dev->nodename, "feature-max-indirect-segments", "%u",
757 MAX_INDIRECT_SEGMENTS);
758 if (err)
759 dev_warn(&dev->dev, "writing %s/feature-max-indirect-segments (%d)",
760 dev->nodename, err);
681 761
682 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu", 762 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
683 (unsigned long long)vbd_sz(&be->blkif->vbd)); 763 (unsigned long long)vbd_sz(&be->blkif->vbd));
@@ -704,6 +784,11 @@ again:
704 dev->nodename); 784 dev->nodename);
705 goto abort; 785 goto abort;
706 } 786 }
787 err = xenbus_printf(xbt, dev->nodename, "physical-sector-size", "%u",
788 bdev_physical_block_size(be->blkif->vbd.bdev));
789 if (err)
790 xenbus_dev_error(dev, err, "writing %s/physical-sector-size",
791 dev->nodename);
707 792
708 err = xenbus_transaction_end(xbt, 0); 793 err = xenbus_transaction_end(xbt, 0);
709 if (err == -EAGAIN) 794 if (err == -EAGAIN)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index d89ef86220f4..a4660bbee8a6 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -74,12 +74,30 @@ struct grant {
74struct blk_shadow { 74struct blk_shadow {
75 struct blkif_request req; 75 struct blkif_request req;
76 struct request *request; 76 struct request *request;
77 struct grant *grants_used[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 77 struct grant **grants_used;
78 struct grant **indirect_grants;
79 struct scatterlist *sg;
80};
81
82struct split_bio {
83 struct bio *bio;
84 atomic_t pending;
85 int err;
78}; 86};
79 87
80static DEFINE_MUTEX(blkfront_mutex); 88static DEFINE_MUTEX(blkfront_mutex);
81static const struct block_device_operations xlvbd_block_fops; 89static const struct block_device_operations xlvbd_block_fops;
82 90
91/*
92 * Maximum number of segments in indirect requests, the actual value used by
93 * the frontend driver is the minimum of this value and the value provided
94 * by the backend driver.
95 */
96
97static unsigned int xen_blkif_max_segments = 32;
98module_param_named(max, xen_blkif_max_segments, int, S_IRUGO);
99MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests (default is 32)");
100
83#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE) 101#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE)
84 102
85/* 103/*
@@ -98,7 +116,6 @@ struct blkfront_info
98 enum blkif_state connected; 116 enum blkif_state connected;
99 int ring_ref; 117 int ring_ref;
100 struct blkif_front_ring ring; 118 struct blkif_front_ring ring;
101 struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
102 unsigned int evtchn, irq; 119 unsigned int evtchn, irq;
103 struct request_queue *rq; 120 struct request_queue *rq;
104 struct work_struct work; 121 struct work_struct work;
@@ -114,6 +131,7 @@ struct blkfront_info
114 unsigned int discard_granularity; 131 unsigned int discard_granularity;
115 unsigned int discard_alignment; 132 unsigned int discard_alignment;
116 unsigned int feature_persistent:1; 133 unsigned int feature_persistent:1;
134 unsigned int max_indirect_segments;
117 int is_ready; 135 int is_ready;
118}; 136};
119 137
@@ -142,6 +160,13 @@ static DEFINE_SPINLOCK(minor_lock);
142 160
143#define DEV_NAME "xvd" /* name in /dev */ 161#define DEV_NAME "xvd" /* name in /dev */
144 162
163#define SEGS_PER_INDIRECT_FRAME \
164 (PAGE_SIZE/sizeof(struct blkif_request_segment_aligned))
165#define INDIRECT_GREFS(_segs) \
166 ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
167
168static int blkfront_setup_indirect(struct blkfront_info *info);
169
145static int get_id_from_freelist(struct blkfront_info *info) 170static int get_id_from_freelist(struct blkfront_info *info)
146{ 171{
147 unsigned long free = info->shadow_free; 172 unsigned long free = info->shadow_free;
@@ -358,7 +383,8 @@ static int blkif_queue_request(struct request *req)
358 struct blkif_request *ring_req; 383 struct blkif_request *ring_req;
359 unsigned long id; 384 unsigned long id;
360 unsigned int fsect, lsect; 385 unsigned int fsect, lsect;
361 int i, ref; 386 int i, ref, n;
387 struct blkif_request_segment_aligned *segments = NULL;
362 388
363 /* 389 /*
364 * Used to store if we are able to queue the request by just using 390 * 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)
369 grant_ref_t gref_head; 395 grant_ref_t gref_head;
370 struct grant *gnt_list_entry = NULL; 396 struct grant *gnt_list_entry = NULL;
371 struct scatterlist *sg; 397 struct scatterlist *sg;
398 int nseg, max_grefs;
372 399
373 if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) 400 if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
374 return 1; 401 return 1;
375 402
376 /* Check if we have enought grants to allocate a requests */ 403 max_grefs = info->max_indirect_segments ?
377 if (info->persistent_gnts_c < BLKIF_MAX_SEGMENTS_PER_REQUEST) { 404 info->max_indirect_segments +
405 INDIRECT_GREFS(info->max_indirect_segments) :
406 BLKIF_MAX_SEGMENTS_PER_REQUEST;
407
408 /* Check if we have enough grants to allocate a requests */
409 if (info->persistent_gnts_c < max_grefs) {
378 new_persistent_gnts = 1; 410 new_persistent_gnts = 1;
379 if (gnttab_alloc_grant_references( 411 if (gnttab_alloc_grant_references(
380 BLKIF_MAX_SEGMENTS_PER_REQUEST - info->persistent_gnts_c, 412 max_grefs - info->persistent_gnts_c,
381 &gref_head) < 0) { 413 &gref_head) < 0) {
382 gnttab_request_free_callback( 414 gnttab_request_free_callback(
383 &info->callback, 415 &info->callback,
384 blkif_restart_queue_callback, 416 blkif_restart_queue_callback,
385 info, 417 info,
386 BLKIF_MAX_SEGMENTS_PER_REQUEST); 418 max_grefs);
387 return 1; 419 return 1;
388 } 420 }
389 } else 421 } else
@@ -394,42 +426,67 @@ static int blkif_queue_request(struct request *req)
394 id = get_id_from_freelist(info); 426 id = get_id_from_freelist(info);
395 info->shadow[id].request = req; 427 info->shadow[id].request = req;
396 428
397 ring_req->u.rw.id = id;
398 ring_req->u.rw.sector_number = (blkif_sector_t)blk_rq_pos(req);
399 ring_req->u.rw.handle = info->handle;
400
401 ring_req->operation = rq_data_dir(req) ?
402 BLKIF_OP_WRITE : BLKIF_OP_READ;
403
404 if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
405 /*
406 * Ideally we can do an unordered flush-to-disk. In case the
407 * backend onlysupports barriers, use that. A barrier request
408 * a superset of FUA, so we can implement it the same
409 * way. (It's also a FLUSH+FUA, since it is
410 * guaranteed ordered WRT previous writes.)
411 */
412 ring_req->operation = info->flush_op;
413 }
414
415 if (unlikely(req->cmd_flags & (REQ_DISCARD | REQ_SECURE))) { 429 if (unlikely(req->cmd_flags & (REQ_DISCARD | REQ_SECURE))) {
416 /* id, sector_number and handle are set above. */
417 ring_req->operation = BLKIF_OP_DISCARD; 430 ring_req->operation = BLKIF_OP_DISCARD;
418 ring_req->u.discard.nr_sectors = blk_rq_sectors(req); 431 ring_req->u.discard.nr_sectors = blk_rq_sectors(req);
432 ring_req->u.discard.id = id;
433 ring_req->u.discard.sector_number = (blkif_sector_t)blk_rq_pos(req);
419 if ((req->cmd_flags & REQ_SECURE) && info->feature_secdiscard) 434 if ((req->cmd_flags & REQ_SECURE) && info->feature_secdiscard)
420 ring_req->u.discard.flag = BLKIF_DISCARD_SECURE; 435 ring_req->u.discard.flag = BLKIF_DISCARD_SECURE;
421 else 436 else
422 ring_req->u.discard.flag = 0; 437 ring_req->u.discard.flag = 0;
423 } else { 438 } else {
424 ring_req->u.rw.nr_segments = blk_rq_map_sg(req->q, req, 439 BUG_ON(info->max_indirect_segments == 0 &&
425 info->sg); 440 req->nr_phys_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
426 BUG_ON(ring_req->u.rw.nr_segments > 441 BUG_ON(info->max_indirect_segments &&
427 BLKIF_MAX_SEGMENTS_PER_REQUEST); 442 req->nr_phys_segments > info->max_indirect_segments);
428 443 nseg = blk_rq_map_sg(req->q, req, info->shadow[id].sg);
429 for_each_sg(info->sg, sg, ring_req->u.rw.nr_segments, i) { 444 ring_req->u.rw.id = id;
445 if (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST) {
446 /*
447 * The indirect operation can only be a BLKIF_OP_READ or
448 * BLKIF_OP_WRITE
449 */
450 BUG_ON(req->cmd_flags & (REQ_FLUSH | REQ_FUA));
451 ring_req->operation = BLKIF_OP_INDIRECT;
452 ring_req->u.indirect.indirect_op = rq_data_dir(req) ?
453 BLKIF_OP_WRITE : BLKIF_OP_READ;
454 ring_req->u.indirect.sector_number = (blkif_sector_t)blk_rq_pos(req);
455 ring_req->u.indirect.handle = info->handle;
456 ring_req->u.indirect.nr_segments = nseg;
457 } else {
458 ring_req->u.rw.sector_number = (blkif_sector_t)blk_rq_pos(req);
459 ring_req->u.rw.handle = info->handle;
460 ring_req->operation = rq_data_dir(req) ?
461 BLKIF_OP_WRITE : BLKIF_OP_READ;
462 if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
463 /*
464 * Ideally we can do an unordered flush-to-disk. In case the
465 * backend onlysupports barriers, use that. A barrier request
466 * a superset of FUA, so we can implement it the same
467 * way. (It's also a FLUSH+FUA, since it is
468 * guaranteed ordered WRT previous writes.)
469 */
470 ring_req->operation = info->flush_op;
471 }
472 ring_req->u.rw.nr_segments = nseg;
473 }
474 for_each_sg(info->shadow[id].sg, sg, nseg, i) {
430 fsect = sg->offset >> 9; 475 fsect = sg->offset >> 9;
431 lsect = fsect + (sg->length >> 9) - 1; 476 lsect = fsect + (sg->length >> 9) - 1;
432 477
478 if ((ring_req->operation == BLKIF_OP_INDIRECT) &&
479 (i % SEGS_PER_INDIRECT_FRAME == 0)) {
480 if (segments)
481 kunmap_atomic(segments);
482
483 n = i / SEGS_PER_INDIRECT_FRAME;
484 gnt_list_entry = get_grant(&gref_head, info);
485 info->shadow[id].indirect_grants[n] = gnt_list_entry;
486 segments = kmap_atomic(pfn_to_page(gnt_list_entry->pfn));
487 ring_req->u.indirect.indirect_grefs[n] = gnt_list_entry->gref;
488 }
489
433 gnt_list_entry = get_grant(&gref_head, info); 490 gnt_list_entry = get_grant(&gref_head, info);
434 ref = gnt_list_entry->gref; 491 ref = gnt_list_entry->gref;
435 492
@@ -441,8 +498,7 @@ static int blkif_queue_request(struct request *req)
441 498
442 BUG_ON(sg->offset + sg->length > PAGE_SIZE); 499 BUG_ON(sg->offset + sg->length > PAGE_SIZE);
443 500
444 shared_data = kmap_atomic( 501 shared_data = kmap_atomic(pfn_to_page(gnt_list_entry->pfn));
445 pfn_to_page(gnt_list_entry->pfn));
446 bvec_data = kmap_atomic(sg_page(sg)); 502 bvec_data = kmap_atomic(sg_page(sg));
447 503
448 /* 504 /*
@@ -461,13 +517,23 @@ static int blkif_queue_request(struct request *req)
461 kunmap_atomic(bvec_data); 517 kunmap_atomic(bvec_data);
462 kunmap_atomic(shared_data); 518 kunmap_atomic(shared_data);
463 } 519 }
464 520 if (ring_req->operation != BLKIF_OP_INDIRECT) {
465 ring_req->u.rw.seg[i] = 521 ring_req->u.rw.seg[i] =
466 (struct blkif_request_segment) { 522 (struct blkif_request_segment) {
467 .gref = ref, 523 .gref = ref,
468 .first_sect = fsect, 524 .first_sect = fsect,
469 .last_sect = lsect }; 525 .last_sect = lsect };
526 } else {
527 n = i % SEGS_PER_INDIRECT_FRAME;
528 segments[n] =
529 (struct blkif_request_segment_aligned) {
530 .gref = ref,
531 .first_sect = fsect,
532 .last_sect = lsect };
533 }
470 } 534 }
535 if (segments)
536 kunmap_atomic(segments);
471 } 537 }
472 538
473 info->ring.req_prod_pvt++; 539 info->ring.req_prod_pvt++;
@@ -542,7 +608,9 @@ wait:
542 flush_requests(info); 608 flush_requests(info);
543} 609}
544 610
545static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) 611static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size,
612 unsigned int physical_sector_size,
613 unsigned int segments)
546{ 614{
547 struct request_queue *rq; 615 struct request_queue *rq;
548 struct blkfront_info *info = gd->private_data; 616 struct blkfront_info *info = gd->private_data;
@@ -564,14 +632,15 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
564 632
565 /* Hard sector size and max sectors impersonate the equiv. hardware. */ 633 /* Hard sector size and max sectors impersonate the equiv. hardware. */
566 blk_queue_logical_block_size(rq, sector_size); 634 blk_queue_logical_block_size(rq, sector_size);
567 blk_queue_max_hw_sectors(rq, 512); 635 blk_queue_physical_block_size(rq, physical_sector_size);
636 blk_queue_max_hw_sectors(rq, (segments * PAGE_SIZE) / 512);
568 637
569 /* Each segment in a request is up to an aligned page in size. */ 638 /* Each segment in a request is up to an aligned page in size. */
570 blk_queue_segment_boundary(rq, PAGE_SIZE - 1); 639 blk_queue_segment_boundary(rq, PAGE_SIZE - 1);
571 blk_queue_max_segment_size(rq, PAGE_SIZE); 640 blk_queue_max_segment_size(rq, PAGE_SIZE);
572 641
573 /* Ensure a merged request will fit in a single I/O ring slot. */ 642 /* Ensure a merged request will fit in a single I/O ring slot. */
574 blk_queue_max_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST); 643 blk_queue_max_segments(rq, segments);
575 644
576 /* Make sure buffer addresses are sector-aligned. */ 645 /* Make sure buffer addresses are sector-aligned. */
577 blk_queue_dma_alignment(rq, 511); 646 blk_queue_dma_alignment(rq, 511);
@@ -588,13 +657,16 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
588static void xlvbd_flush(struct blkfront_info *info) 657static void xlvbd_flush(struct blkfront_info *info)
589{ 658{
590 blk_queue_flush(info->rq, info->feature_flush); 659 blk_queue_flush(info->rq, info->feature_flush);
591 printk(KERN_INFO "blkfront: %s: %s: %s %s\n", 660 printk(KERN_INFO "blkfront: %s: %s: %s %s %s %s %s\n",
592 info->gd->disk_name, 661 info->gd->disk_name,
593 info->flush_op == BLKIF_OP_WRITE_BARRIER ? 662 info->flush_op == BLKIF_OP_WRITE_BARRIER ?
594 "barrier" : (info->flush_op == BLKIF_OP_FLUSH_DISKCACHE ? 663 "barrier" : (info->flush_op == BLKIF_OP_FLUSH_DISKCACHE ?
595 "flush diskcache" : "barrier or flush"), 664 "flush diskcache" : "barrier or flush"),
596 info->feature_flush ? "enabled" : "disabled", 665 info->feature_flush ? "enabled;" : "disabled;",
597 info->feature_persistent ? "using persistent grants" : ""); 666 "persistent grants:",
667 info->feature_persistent ? "enabled;" : "disabled;",
668 "indirect descriptors:",
669 info->max_indirect_segments ? "enabled;" : "disabled;");
598} 670}
599 671
600static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset) 672static 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)
667 739
668static int xlvbd_alloc_gendisk(blkif_sector_t capacity, 740static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
669 struct blkfront_info *info, 741 struct blkfront_info *info,
670 u16 vdisk_info, u16 sector_size) 742 u16 vdisk_info, u16 sector_size,
743 unsigned int physical_sector_size)
671{ 744{
672 struct gendisk *gd; 745 struct gendisk *gd;
673 int nr_minors = 1; 746 int nr_minors = 1;
@@ -734,7 +807,9 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
734 gd->driverfs_dev = &(info->xbdev->dev); 807 gd->driverfs_dev = &(info->xbdev->dev);
735 set_capacity(gd, capacity); 808 set_capacity(gd, capacity);
736 809
737 if (xlvbd_init_blk_queue(gd, sector_size)) { 810 if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size,
811 info->max_indirect_segments ? :
812 BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
738 del_gendisk(gd); 813 del_gendisk(gd);
739 goto release; 814 goto release;
740 } 815 }
@@ -818,6 +893,7 @@ static void blkif_free(struct blkfront_info *info, int suspend)
818{ 893{
819 struct grant *persistent_gnt; 894 struct grant *persistent_gnt;
820 struct grant *n; 895 struct grant *n;
896 int i, j, segs;
821 897
822 /* Prevent new requests being issued until we fix things up. */ 898 /* Prevent new requests being issued until we fix things up. */
823 spin_lock_irq(&info->io_lock); 899 spin_lock_irq(&info->io_lock);
@@ -843,6 +919,47 @@ static void blkif_free(struct blkfront_info *info, int suspend)
843 } 919 }
844 BUG_ON(info->persistent_gnts_c != 0); 920 BUG_ON(info->persistent_gnts_c != 0);
845 921
922 for (i = 0; i < BLK_RING_SIZE; i++) {
923 /*
924 * Clear persistent grants present in requests already
925 * on the shared ring
926 */
927 if (!info->shadow[i].request)
928 goto free_shadow;
929
930 segs = info->shadow[i].req.operation == BLKIF_OP_INDIRECT ?
931 info->shadow[i].req.u.indirect.nr_segments :
932 info->shadow[i].req.u.rw.nr_segments;
933 for (j = 0; j < segs; j++) {
934 persistent_gnt = info->shadow[i].grants_used[j];
935 gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
936 __free_page(pfn_to_page(persistent_gnt->pfn));
937 kfree(persistent_gnt);
938 }
939
940 if (info->shadow[i].req.operation != BLKIF_OP_INDIRECT)
941 /*
942 * If this is not an indirect operation don't try to
943 * free indirect segments
944 */
945 goto free_shadow;
946
947 for (j = 0; j < INDIRECT_GREFS(segs); j++) {
948 persistent_gnt = info->shadow[i].indirect_grants[j];
949 gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
950 __free_page(pfn_to_page(persistent_gnt->pfn));
951 kfree(persistent_gnt);
952 }
953
954free_shadow:
955 kfree(info->shadow[i].grants_used);
956 info->shadow[i].grants_used = NULL;
957 kfree(info->shadow[i].indirect_grants);
958 info->shadow[i].indirect_grants = NULL;
959 kfree(info->shadow[i].sg);
960 info->shadow[i].sg = NULL;
961 }
962
846 /* No more gnttab callback work. */ 963 /* No more gnttab callback work. */
847 gnttab_cancel_free_callback(&info->callback); 964 gnttab_cancel_free_callback(&info->callback);
848 spin_unlock_irq(&info->io_lock); 965 spin_unlock_irq(&info->io_lock);
@@ -867,12 +984,13 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
867 struct blkif_response *bret) 984 struct blkif_response *bret)
868{ 985{
869 int i = 0; 986 int i = 0;
870 struct bio_vec *bvec; 987 struct scatterlist *sg;
871 struct req_iterator iter;
872 unsigned long flags;
873 char *bvec_data; 988 char *bvec_data;
874 void *shared_data; 989 void *shared_data;
875 unsigned int offset = 0; 990 int nseg;
991
992 nseg = s->req.operation == BLKIF_OP_INDIRECT ?
993 s->req.u.indirect.nr_segments : s->req.u.rw.nr_segments;
876 994
877 if (bret->operation == BLKIF_OP_READ) { 995 if (bret->operation == BLKIF_OP_READ) {
878 /* 996 /*
@@ -881,26 +999,29 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
881 * than PAGE_SIZE, we have to keep track of the current offset, 999 * than PAGE_SIZE, we have to keep track of the current offset,
882 * to be sure we are copying the data from the right shared page. 1000 * to be sure we are copying the data from the right shared page.
883 */ 1001 */
884 rq_for_each_segment(bvec, s->request, iter) { 1002 for_each_sg(s->sg, sg, nseg, i) {
885 BUG_ON((bvec->bv_offset + bvec->bv_len) > PAGE_SIZE); 1003 BUG_ON(sg->offset + sg->length > PAGE_SIZE);
886 if (bvec->bv_offset < offset)
887 i++;
888 BUG_ON(i >= s->req.u.rw.nr_segments);
889 shared_data = kmap_atomic( 1004 shared_data = kmap_atomic(
890 pfn_to_page(s->grants_used[i]->pfn)); 1005 pfn_to_page(s->grants_used[i]->pfn));
891 bvec_data = bvec_kmap_irq(bvec, &flags); 1006 bvec_data = kmap_atomic(sg_page(sg));
892 memcpy(bvec_data, shared_data + bvec->bv_offset, 1007 memcpy(bvec_data + sg->offset,
893 bvec->bv_len); 1008 shared_data + sg->offset,
894 bvec_kunmap_irq(bvec_data, &flags); 1009 sg->length);
1010 kunmap_atomic(bvec_data);
895 kunmap_atomic(shared_data); 1011 kunmap_atomic(shared_data);
896 offset = bvec->bv_offset + bvec->bv_len;
897 } 1012 }
898 } 1013 }
899 /* Add the persistent grant into the list of free grants */ 1014 /* Add the persistent grant into the list of free grants */
900 for (i = 0; i < s->req.u.rw.nr_segments; i++) { 1015 for (i = 0; i < nseg; i++) {
901 list_add(&s->grants_used[i]->node, &info->persistent_gnts); 1016 list_add(&s->grants_used[i]->node, &info->persistent_gnts);
902 info->persistent_gnts_c++; 1017 info->persistent_gnts_c++;
903 } 1018 }
1019 if (s->req.operation == BLKIF_OP_INDIRECT) {
1020 for (i = 0; i < INDIRECT_GREFS(nseg); i++) {
1021 list_add(&s->indirect_grants[i]->node, &info->persistent_gnts);
1022 info->persistent_gnts_c++;
1023 }
1024 }
904} 1025}
905 1026
906static irqreturn_t blkif_interrupt(int irq, void *dev_id) 1027static irqreturn_t blkif_interrupt(int irq, void *dev_id)
@@ -1034,14 +1155,6 @@ static int setup_blkring(struct xenbus_device *dev,
1034 SHARED_RING_INIT(sring); 1155 SHARED_RING_INIT(sring);
1035 FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); 1156 FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
1036 1157
1037 sg_init_table(info->sg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
1038
1039 /* Allocate memory for grants */
1040 err = fill_grant_buffer(info, BLK_RING_SIZE *
1041 BLKIF_MAX_SEGMENTS_PER_REQUEST);
1042 if (err)
1043 goto fail;
1044
1045 err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring)); 1158 err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
1046 if (err < 0) { 1159 if (err < 0) {
1047 free_page((unsigned long)sring); 1160 free_page((unsigned long)sring);
@@ -1223,13 +1336,84 @@ static int blkfront_probe(struct xenbus_device *dev,
1223 return 0; 1336 return 0;
1224} 1337}
1225 1338
1339/*
1340 * This is a clone of md_trim_bio, used to split a bio into smaller ones
1341 */
1342static void trim_bio(struct bio *bio, int offset, int size)
1343{
1344 /* 'bio' is a cloned bio which we need to trim to match
1345 * the given offset and size.
1346 * This requires adjusting bi_sector, bi_size, and bi_io_vec
1347 */
1348 int i;
1349 struct bio_vec *bvec;
1350 int sofar = 0;
1351
1352 size <<= 9;
1353 if (offset == 0 && size == bio->bi_size)
1354 return;
1355
1356 bio->bi_sector += offset;
1357 bio->bi_size = size;
1358 offset <<= 9;
1359 clear_bit(BIO_SEG_VALID, &bio->bi_flags);
1360
1361 while (bio->bi_idx < bio->bi_vcnt &&
1362 bio->bi_io_vec[bio->bi_idx].bv_len <= offset) {
1363 /* remove this whole bio_vec */
1364 offset -= bio->bi_io_vec[bio->bi_idx].bv_len;
1365 bio->bi_idx++;
1366 }
1367 if (bio->bi_idx < bio->bi_vcnt) {
1368 bio->bi_io_vec[bio->bi_idx].bv_offset += offset;
1369 bio->bi_io_vec[bio->bi_idx].bv_len -= offset;
1370 }
1371 /* avoid any complications with bi_idx being non-zero*/
1372 if (bio->bi_idx) {
1373 memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx,
1374 (bio->bi_vcnt - bio->bi_idx) * sizeof(struct bio_vec));
1375 bio->bi_vcnt -= bio->bi_idx;
1376 bio->bi_idx = 0;
1377 }
1378 /* Make sure vcnt and last bv are not too big */
1379 bio_for_each_segment(bvec, bio, i) {
1380 if (sofar + bvec->bv_len > size)
1381 bvec->bv_len = size - sofar;
1382 if (bvec->bv_len == 0) {
1383 bio->bi_vcnt = i;
1384 break;
1385 }
1386 sofar += bvec->bv_len;
1387 }
1388}
1389
1390static void split_bio_end(struct bio *bio, int error)
1391{
1392 struct split_bio *split_bio = bio->bi_private;
1393
1394 if (error)
1395 split_bio->err = error;
1396
1397 if (atomic_dec_and_test(&split_bio->pending)) {
1398 split_bio->bio->bi_phys_segments = 0;
1399 bio_endio(split_bio->bio, split_bio->err);
1400 kfree(split_bio);
1401 }
1402 bio_put(bio);
1403}
1226 1404
1227static int blkif_recover(struct blkfront_info *info) 1405static int blkif_recover(struct blkfront_info *info)
1228{ 1406{
1229 int i; 1407 int i;
1230 struct blkif_request *req; 1408 struct request *req, *n;
1231 struct blk_shadow *copy; 1409 struct blk_shadow *copy;
1232 int j; 1410 int rc;
1411 struct bio *bio, *cloned_bio;
1412 struct bio_list bio_list, merge_bio;
1413 unsigned int segs, offset;
1414 int pending, size;
1415 struct split_bio *split_bio;
1416 struct list_head requests;
1233 1417
1234 /* Stage 1: Make a safe copy of the shadow state. */ 1418 /* Stage 1: Make a safe copy of the shadow state. */
1235 copy = kmemdup(info->shadow, sizeof(info->shadow), 1419 copy = kmemdup(info->shadow, sizeof(info->shadow),
@@ -1244,36 +1428,64 @@ static int blkif_recover(struct blkfront_info *info)
1244 info->shadow_free = info->ring.req_prod_pvt; 1428 info->shadow_free = info->ring.req_prod_pvt;
1245 info->shadow[BLK_RING_SIZE-1].req.u.rw.id = 0x0fffffff; 1429 info->shadow[BLK_RING_SIZE-1].req.u.rw.id = 0x0fffffff;
1246 1430
1247 /* Stage 3: Find pending requests and requeue them. */ 1431 rc = blkfront_setup_indirect(info);
1432 if (rc) {
1433 kfree(copy);
1434 return rc;
1435 }
1436
1437 segs = info->max_indirect_segments ? : BLKIF_MAX_SEGMENTS_PER_REQUEST;
1438 blk_queue_max_segments(info->rq, segs);
1439 bio_list_init(&bio_list);
1440 INIT_LIST_HEAD(&requests);
1248 for (i = 0; i < BLK_RING_SIZE; i++) { 1441 for (i = 0; i < BLK_RING_SIZE; i++) {
1249 /* Not in use? */ 1442 /* Not in use? */
1250 if (!copy[i].request) 1443 if (!copy[i].request)
1251 continue; 1444 continue;
1252 1445
1253 /* Grab a request slot and copy shadow state into it. */ 1446 /*
1254 req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt); 1447 * Get the bios in the request so we can re-queue them.
1255 *req = copy[i].req; 1448 */
1256 1449 if (copy[i].request->cmd_flags &
1257 /* We get a new request id, and must reset the shadow state. */ 1450 (REQ_FLUSH | REQ_FUA | REQ_DISCARD | REQ_SECURE)) {
1258 req->u.rw.id = get_id_from_freelist(info); 1451 /*
1259 memcpy(&info->shadow[req->u.rw.id], &copy[i], sizeof(copy[i])); 1452 * Flush operations don't contain bios, so
1260 1453 * we need to requeue the whole request
1261 if (req->operation != BLKIF_OP_DISCARD) { 1454 */
1262 /* Rewrite any grant references invalidated by susp/resume. */ 1455 list_add(&copy[i].request->queuelist, &requests);
1263 for (j = 0; j < req->u.rw.nr_segments; j++) 1456 continue;
1264 gnttab_grant_foreign_access_ref(
1265 req->u.rw.seg[j].gref,
1266 info->xbdev->otherend_id,
1267 pfn_to_mfn(copy[i].grants_used[j]->pfn),
1268 0);
1269 } 1457 }
1270 info->shadow[req->u.rw.id].req = *req; 1458 merge_bio.head = copy[i].request->bio;
1271 1459 merge_bio.tail = copy[i].request->biotail;
1272 info->ring.req_prod_pvt++; 1460 bio_list_merge(&bio_list, &merge_bio);
1461 copy[i].request->bio = NULL;
1462 blk_put_request(copy[i].request);
1273 } 1463 }
1274 1464
1275 kfree(copy); 1465 kfree(copy);
1276 1466
1467 /*
1468 * Empty the queue, this is important because we might have
1469 * requests in the queue with more segments than what we
1470 * can handle now.
1471 */
1472 spin_lock_irq(&info->io_lock);
1473 while ((req = blk_fetch_request(info->rq)) != NULL) {
1474 if (req->cmd_flags &
1475 (REQ_FLUSH | REQ_FUA | REQ_DISCARD | REQ_SECURE)) {
1476 list_add(&req->queuelist, &requests);
1477 continue;
1478 }
1479 merge_bio.head = req->bio;
1480 merge_bio.tail = req->biotail;
1481 bio_list_merge(&bio_list, &merge_bio);
1482 req->bio = NULL;
1483 if (req->cmd_flags & (REQ_FLUSH | REQ_FUA))
1484 pr_alert("diskcache flush request found!\n");
1485 __blk_put_request(info->rq, req);
1486 }
1487 spin_unlock_irq(&info->io_lock);
1488
1277 xenbus_switch_state(info->xbdev, XenbusStateConnected); 1489 xenbus_switch_state(info->xbdev, XenbusStateConnected);
1278 1490
1279 spin_lock_irq(&info->io_lock); 1491 spin_lock_irq(&info->io_lock);
@@ -1281,14 +1493,50 @@ static int blkif_recover(struct blkfront_info *info)
1281 /* Now safe for us to use the shared ring */ 1493 /* Now safe for us to use the shared ring */
1282 info->connected = BLKIF_STATE_CONNECTED; 1494 info->connected = BLKIF_STATE_CONNECTED;
1283 1495
1284 /* Send off requeued requests */
1285 flush_requests(info);
1286
1287 /* Kick any other new requests queued since we resumed */ 1496 /* Kick any other new requests queued since we resumed */
1288 kick_pending_request_queues(info); 1497 kick_pending_request_queues(info);
1289 1498
1499 list_for_each_entry_safe(req, n, &requests, queuelist) {
1500 /* Requeue pending requests (flush or discard) */
1501 list_del_init(&req->queuelist);
1502 BUG_ON(req->nr_phys_segments > segs);
1503 blk_requeue_request(info->rq, req);
1504 }
1290 spin_unlock_irq(&info->io_lock); 1505 spin_unlock_irq(&info->io_lock);
1291 1506
1507 while ((bio = bio_list_pop(&bio_list)) != NULL) {
1508 /* Traverse the list of pending bios and re-queue them */
1509 if (bio_segments(bio) > segs) {
1510 /*
1511 * This bio has more segments than what we can
1512 * handle, we have to split it.
1513 */
1514 pending = (bio_segments(bio) + segs - 1) / segs;
1515 split_bio = kzalloc(sizeof(*split_bio), GFP_NOIO);
1516 BUG_ON(split_bio == NULL);
1517 atomic_set(&split_bio->pending, pending);
1518 split_bio->bio = bio;
1519 for (i = 0; i < pending; i++) {
1520 offset = (i * segs * PAGE_SIZE) >> 9;
1521 size = min((unsigned int)(segs * PAGE_SIZE) >> 9,
1522 (unsigned int)(bio->bi_size >> 9) - offset);
1523 cloned_bio = bio_clone(bio, GFP_NOIO);
1524 BUG_ON(cloned_bio == NULL);
1525 trim_bio(cloned_bio, offset, size);
1526 cloned_bio->bi_private = split_bio;
1527 cloned_bio->bi_end_io = split_bio_end;
1528 submit_bio(cloned_bio->bi_rw, cloned_bio);
1529 }
1530 /*
1531 * Now we have to wait for all those smaller bios to
1532 * end, so we can also end the "parent" bio.
1533 */
1534 continue;
1535 }
1536 /* We don't need to split this bio */
1537 submit_bio(bio->bi_rw, bio);
1538 }
1539
1292 return 0; 1540 return 0;
1293} 1541}
1294 1542
@@ -1308,8 +1556,12 @@ static int blkfront_resume(struct xenbus_device *dev)
1308 blkif_free(info, info->connected == BLKIF_STATE_CONNECTED); 1556 blkif_free(info, info->connected == BLKIF_STATE_CONNECTED);
1309 1557
1310 err = talk_to_blkback(dev, info); 1558 err = talk_to_blkback(dev, info);
1311 if (info->connected == BLKIF_STATE_SUSPENDED && !err) 1559
1312 err = blkif_recover(info); 1560 /*
1561 * We have to wait for the backend to switch to
1562 * connected state, since we want to read which
1563 * features it supports.
1564 */
1313 1565
1314 return err; 1566 return err;
1315} 1567}
@@ -1387,6 +1639,60 @@ static void blkfront_setup_discard(struct blkfront_info *info)
1387 kfree(type); 1639 kfree(type);
1388} 1640}
1389 1641
1642static int blkfront_setup_indirect(struct blkfront_info *info)
1643{
1644 unsigned int indirect_segments, segs;
1645 int err, i;
1646
1647 err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
1648 "feature-max-indirect-segments", "%u", &indirect_segments,
1649 NULL);
1650 if (err) {
1651 info->max_indirect_segments = 0;
1652 segs = BLKIF_MAX_SEGMENTS_PER_REQUEST;
1653 } else {
1654 info->max_indirect_segments = min(indirect_segments,
1655 xen_blkif_max_segments);
1656 segs = info->max_indirect_segments;
1657 }
1658
1659 err = fill_grant_buffer(info, (segs + INDIRECT_GREFS(segs)) * BLK_RING_SIZE);
1660 if (err)
1661 goto out_of_memory;
1662
1663 for (i = 0; i < BLK_RING_SIZE; i++) {
1664 info->shadow[i].grants_used = kzalloc(
1665 sizeof(info->shadow[i].grants_used[0]) * segs,
1666 GFP_NOIO);
1667 info->shadow[i].sg = kzalloc(sizeof(info->shadow[i].sg[0]) * segs, GFP_NOIO);
1668 if (info->max_indirect_segments)
1669 info->shadow[i].indirect_grants = kzalloc(
1670 sizeof(info->shadow[i].indirect_grants[0]) *
1671 INDIRECT_GREFS(segs),
1672 GFP_NOIO);
1673 if ((info->shadow[i].grants_used == NULL) ||
1674 (info->shadow[i].sg == NULL) ||
1675 (info->max_indirect_segments &&
1676 (info->shadow[i].indirect_grants == NULL)))
1677 goto out_of_memory;
1678 sg_init_table(info->shadow[i].sg, segs);
1679 }
1680
1681
1682 return 0;
1683
1684out_of_memory:
1685 for (i = 0; i < BLK_RING_SIZE; i++) {
1686 kfree(info->shadow[i].grants_used);
1687 info->shadow[i].grants_used = NULL;
1688 kfree(info->shadow[i].sg);
1689 info->shadow[i].sg = NULL;
1690 kfree(info->shadow[i].indirect_grants);
1691 info->shadow[i].indirect_grants = NULL;
1692 }
1693 return -ENOMEM;
1694}
1695
1390/* 1696/*
1391 * Invoked when the backend is finally 'ready' (and has told produced 1697 * Invoked when the backend is finally 'ready' (and has told produced
1392 * the details about the physical device - #sectors, size, etc). 1698 * the details about the physical device - #sectors, size, etc).
@@ -1395,6 +1701,7 @@ static void blkfront_connect(struct blkfront_info *info)
1395{ 1701{
1396 unsigned long long sectors; 1702 unsigned long long sectors;
1397 unsigned long sector_size; 1703 unsigned long sector_size;
1704 unsigned int physical_sector_size;
1398 unsigned int binfo; 1705 unsigned int binfo;
1399 int err; 1706 int err;
1400 int barrier, flush, discard, persistent; 1707 int barrier, flush, discard, persistent;
@@ -1414,8 +1721,15 @@ static void blkfront_connect(struct blkfront_info *info)
1414 set_capacity(info->gd, sectors); 1721 set_capacity(info->gd, sectors);
1415 revalidate_disk(info->gd); 1722 revalidate_disk(info->gd);
1416 1723
1417 /* fall through */ 1724 return;
1418 case BLKIF_STATE_SUSPENDED: 1725 case BLKIF_STATE_SUSPENDED:
1726 /*
1727 * If we are recovering from suspension, we need to wait
1728 * for the backend to announce it's features before
1729 * reconnecting, at least we need to know if the backend
1730 * supports indirect descriptors, and how many.
1731 */
1732 blkif_recover(info);
1419 return; 1733 return;
1420 1734
1421 default: 1735 default:
@@ -1437,6 +1751,16 @@ static void blkfront_connect(struct blkfront_info *info)
1437 return; 1751 return;
1438 } 1752 }
1439 1753
1754 /*
1755 * physcial-sector-size is a newer field, so old backends may not
1756 * provide this. Assume physical sector size to be the same as
1757 * sector_size in that case.
1758 */
1759 err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
1760 "physical-sector-size", "%u", &physical_sector_size);
1761 if (err != 1)
1762 physical_sector_size = sector_size;
1763
1440 info->feature_flush = 0; 1764 info->feature_flush = 0;
1441 info->flush_op = 0; 1765 info->flush_op = 0;
1442 1766
@@ -1483,7 +1807,15 @@ static void blkfront_connect(struct blkfront_info *info)
1483 else 1807 else
1484 info->feature_persistent = persistent; 1808 info->feature_persistent = persistent;
1485 1809
1486 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size); 1810 err = blkfront_setup_indirect(info);
1811 if (err) {
1812 xenbus_dev_fatal(info->xbdev, err, "setup_indirect at %s",
1813 info->xbdev->otherend);
1814 return;
1815 }
1816
1817 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size,
1818 physical_sector_size);
1487 if (err) { 1819 if (err) {
1488 xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", 1820 xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s",
1489 info->xbdev->otherend); 1821 info->xbdev->otherend);
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 053d846ab5b1..ffadd836e0b5 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -123,7 +123,7 @@ static int arch_timer_set_next_event_phys(unsigned long evt,
123 return 0; 123 return 0;
124} 124}
125 125
126static int __cpuinit arch_timer_setup(struct clock_event_device *clk) 126static int arch_timer_setup(struct clock_event_device *clk)
127{ 127{
128 clk->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP; 128 clk->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP;
129 clk->name = "arch_sys_timer"; 129 clk->name = "arch_sys_timer";
@@ -221,7 +221,7 @@ struct timecounter *arch_timer_get_timecounter(void)
221 return &timecounter; 221 return &timecounter;
222} 222}
223 223
224static void __cpuinit arch_timer_stop(struct clock_event_device *clk) 224static void arch_timer_stop(struct clock_event_device *clk)
225{ 225{
226 pr_debug("arch_timer_teardown disable IRQ%d cpu #%d\n", 226 pr_debug("arch_timer_teardown disable IRQ%d cpu #%d\n",
227 clk->irq, smp_processor_id()); 227 clk->irq, smp_processor_id());
@@ -237,7 +237,7 @@ static void __cpuinit arch_timer_stop(struct clock_event_device *clk)
237 clk->set_mode(CLOCK_EVT_MODE_UNUSED, clk); 237 clk->set_mode(CLOCK_EVT_MODE_UNUSED, clk);
238} 238}
239 239
240static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self, 240static int arch_timer_cpu_notify(struct notifier_block *self,
241 unsigned long action, void *hcpu) 241 unsigned long action, void *hcpu)
242{ 242{
243 /* 243 /*
@@ -256,7 +256,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
256 return NOTIFY_OK; 256 return NOTIFY_OK;
257} 257}
258 258
259static struct notifier_block arch_timer_cpu_nb __cpuinitdata = { 259static struct notifier_block arch_timer_cpu_nb = {
260 .notifier_call = arch_timer_cpu_notify, 260 .notifier_call = arch_timer_cpu_notify,
261}; 261};
262 262
diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
index db8afc7427a6..b66c1f36066c 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -164,7 +164,7 @@ static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id)
164 return IRQ_HANDLED; 164 return IRQ_HANDLED;
165} 165}
166 166
167static int __cpuinit gt_clockevents_init(struct clock_event_device *clk) 167static int gt_clockevents_init(struct clock_event_device *clk)
168{ 168{
169 int cpu = smp_processor_id(); 169 int cpu = smp_processor_id();
170 170
@@ -221,8 +221,8 @@ static void __init gt_clocksource_init(void)
221 clocksource_register_hz(&gt_clocksource, gt_clk_rate); 221 clocksource_register_hz(&gt_clocksource, gt_clk_rate);
222} 222}
223 223
224static int __cpuinit gt_cpu_notify(struct notifier_block *self, 224static int gt_cpu_notify(struct notifier_block *self, unsigned long action,
225 unsigned long action, void *hcpu) 225 void *hcpu)
226{ 226{
227 switch (action & ~CPU_TASKS_FROZEN) { 227 switch (action & ~CPU_TASKS_FROZEN) {
228 case CPU_STARTING: 228 case CPU_STARTING:
@@ -235,7 +235,7 @@ static int __cpuinit gt_cpu_notify(struct notifier_block *self,
235 235
236 return NOTIFY_OK; 236 return NOTIFY_OK;
237} 237}
238static struct notifier_block gt_cpu_nb __cpuinitdata = { 238static struct notifier_block gt_cpu_nb = {
239 .notifier_call = gt_cpu_notify, 239 .notifier_call = gt_cpu_notify,
240}; 240};
241 241
diff --git a/drivers/clocksource/dummy_timer.c b/drivers/clocksource/dummy_timer.c
index 1f55f9620338..b3eb582d6a6f 100644
--- a/drivers/clocksource/dummy_timer.c
+++ b/drivers/clocksource/dummy_timer.c
@@ -25,7 +25,7 @@ static void dummy_timer_set_mode(enum clock_event_mode mode,
25 */ 25 */
26} 26}
27 27
28static void __cpuinit dummy_timer_setup(void) 28static void dummy_timer_setup(void)
29{ 29{
30 int cpu = smp_processor_id(); 30 int cpu = smp_processor_id();
31 struct clock_event_device *evt = __this_cpu_ptr(&dummy_timer_evt); 31 struct clock_event_device *evt = __this_cpu_ptr(&dummy_timer_evt);
@@ -41,7 +41,7 @@ static void __cpuinit dummy_timer_setup(void)
41 clockevents_register_device(evt); 41 clockevents_register_device(evt);
42} 42}
43 43
44static int __cpuinit dummy_timer_cpu_notify(struct notifier_block *self, 44static int dummy_timer_cpu_notify(struct notifier_block *self,
45 unsigned long action, void *hcpu) 45 unsigned long action, void *hcpu)
46{ 46{
47 if ((action & ~CPU_TASKS_FROZEN) == CPU_STARTING) 47 if ((action & ~CPU_TASKS_FROZEN) == CPU_STARTING)
@@ -50,7 +50,7 @@ static int __cpuinit dummy_timer_cpu_notify(struct notifier_block *self,
50 return NOTIFY_OK; 50 return NOTIFY_OK;
51} 51}
52 52
53static struct notifier_block dummy_timer_cpu_nb __cpuinitdata = { 53static struct notifier_block dummy_timer_cpu_nb = {
54 .notifier_call = dummy_timer_cpu_notify, 54 .notifier_call = dummy_timer_cpu_notify,
55}; 55};
56 56
diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index a70480409ea5..b2bbc415f120 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -400,7 +400,7 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
400 return IRQ_HANDLED; 400 return IRQ_HANDLED;
401} 401}
402 402
403static int __cpuinit exynos4_local_timer_setup(struct clock_event_device *evt) 403static int exynos4_local_timer_setup(struct clock_event_device *evt)
404{ 404{
405 struct mct_clock_event_device *mevt; 405 struct mct_clock_event_device *mevt;
406 unsigned int cpu = smp_processor_id(); 406 unsigned int cpu = smp_processor_id();
@@ -448,7 +448,7 @@ static void exynos4_local_timer_stop(struct clock_event_device *evt)
448 disable_percpu_irq(mct_irqs[MCT_L0_IRQ]); 448 disable_percpu_irq(mct_irqs[MCT_L0_IRQ]);
449} 449}
450 450
451static struct local_timer_ops exynos4_mct_tick_ops __cpuinitdata = { 451static struct local_timer_ops exynos4_mct_tick_ops = {
452 .setup = exynos4_local_timer_setup, 452 .setup = exynos4_local_timer_setup,
453 .stop = exynos4_local_timer_stop, 453 .stop = exynos4_local_timer_stop,
454}; 454};
diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
index 6722f0e2fe40..9e4db41abe3c 100644
--- a/drivers/clocksource/metag_generic.c
+++ b/drivers/clocksource/metag_generic.c
@@ -109,7 +109,7 @@ unsigned long long sched_clock(void)
109 return ticks << HARDWARE_TO_NS_SHIFT; 109 return ticks << HARDWARE_TO_NS_SHIFT;
110} 110}
111 111
112static void __cpuinit arch_timer_setup(unsigned int cpu) 112static void arch_timer_setup(unsigned int cpu)
113{ 113{
114 unsigned int txdivtime; 114 unsigned int txdivtime;
115 struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); 115 struct clock_event_device *clk = &per_cpu(local_clockevent, cpu);
@@ -154,7 +154,7 @@ static void __cpuinit arch_timer_setup(unsigned int cpu)
154 } 154 }
155} 155}
156 156
157static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self, 157static int arch_timer_cpu_notify(struct notifier_block *self,
158 unsigned long action, void *hcpu) 158 unsigned long action, void *hcpu)
159{ 159{
160 int cpu = (long)hcpu; 160 int cpu = (long)hcpu;
@@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
169 return NOTIFY_OK; 169 return NOTIFY_OK;
170} 170}
171 171
172static struct notifier_block __cpuinitdata arch_timer_cpu_nb = { 172static struct notifier_block arch_timer_cpu_nb = {
173 .notifier_call = arch_timer_cpu_notify, 173 .notifier_call = arch_timer_cpu_notify,
174}; 174};
175 175
diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c
index efdca3263afe..1b04b7e1d39b 100644
--- a/drivers/clocksource/time-armada-370-xp.c
+++ b/drivers/clocksource/time-armada-370-xp.c
@@ -167,7 +167,7 @@ static irqreturn_t armada_370_xp_timer_interrupt(int irq, void *dev_id)
167/* 167/*
168 * Setup the local clock events for a CPU. 168 * Setup the local clock events for a CPU.
169 */ 169 */
170static int __cpuinit armada_370_xp_timer_setup(struct clock_event_device *evt) 170static int armada_370_xp_timer_setup(struct clock_event_device *evt)
171{ 171{
172 u32 u; 172 u32 u;
173 int cpu = smp_processor_id(); 173 int cpu = smp_processor_id();
@@ -205,7 +205,7 @@ static void armada_370_xp_timer_stop(struct clock_event_device *evt)
205 disable_percpu_irq(evt->irq); 205 disable_percpu_irq(evt->irq);
206} 206}
207 207
208static struct local_timer_ops armada_370_xp_local_timer_ops __cpuinitdata = { 208static struct local_timer_ops armada_370_xp_local_timer_ops = {
209 .setup = armada_370_xp_timer_setup, 209 .setup = armada_370_xp_timer_setup,
210 .stop = armada_370_xp_timer_stop, 210 .stop = armada_370_xp_timer_stop,
211}; 211};
diff --git a/drivers/clocksource/timer-marco.c b/drivers/clocksource/timer-marco.c
index e5dc9129ca26..62876baa3ab9 100644
--- a/drivers/clocksource/timer-marco.c
+++ b/drivers/clocksource/timer-marco.c
@@ -184,7 +184,7 @@ static struct irqaction sirfsoc_timer1_irq = {
184 .handler = sirfsoc_timer_interrupt, 184 .handler = sirfsoc_timer_interrupt,
185}; 185};
186 186
187static int __cpuinit sirfsoc_local_timer_setup(struct clock_event_device *ce) 187static int sirfsoc_local_timer_setup(struct clock_event_device *ce)
188{ 188{
189 /* Use existing clock_event for cpu 0 */ 189 /* Use existing clock_event for cpu 0 */
190 if (!smp_processor_id()) 190 if (!smp_processor_id())
@@ -216,7 +216,7 @@ static void sirfsoc_local_timer_stop(struct clock_event_device *ce)
216 remove_irq(sirfsoc_timer1_irq.irq, &sirfsoc_timer1_irq); 216 remove_irq(sirfsoc_timer1_irq.irq, &sirfsoc_timer1_irq);
217} 217}
218 218
219static struct local_timer_ops sirfsoc_local_timer_ops __cpuinitdata = { 219static struct local_timer_ops sirfsoc_local_timer_ops = {
220 .setup = sirfsoc_local_timer_setup, 220 .setup = sirfsoc_local_timer_setup,
221 .stop = sirfsoc_local_timer_stop, 221 .stop = sirfsoc_local_timer_stop,
222}; 222};
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0937b8d6c2a4..a4ad7339588d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1932,7 +1932,7 @@ no_policy:
1932} 1932}
1933EXPORT_SYMBOL(cpufreq_update_policy); 1933EXPORT_SYMBOL(cpufreq_update_policy);
1934 1934
1935static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, 1935static int cpufreq_cpu_callback(struct notifier_block *nfb,
1936 unsigned long action, void *hcpu) 1936 unsigned long action, void *hcpu)
1937{ 1937{
1938 unsigned int cpu = (unsigned long)hcpu; 1938 unsigned int cpu = (unsigned long)hcpu;
@@ -1942,13 +1942,15 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
1942 if (dev) { 1942 if (dev) {
1943 switch (action) { 1943 switch (action) {
1944 case CPU_ONLINE: 1944 case CPU_ONLINE:
1945 case CPU_ONLINE_FROZEN:
1945 cpufreq_add_dev(dev, NULL); 1946 cpufreq_add_dev(dev, NULL);
1946 break; 1947 break;
1947 case CPU_DOWN_PREPARE: 1948 case CPU_DOWN_PREPARE:
1948 case CPU_UP_CANCELED_FROZEN: 1949 case CPU_DOWN_PREPARE_FROZEN:
1949 __cpufreq_remove_dev(dev, NULL); 1950 __cpufreq_remove_dev(dev, NULL);
1950 break; 1951 break;
1951 case CPU_DOWN_FAILED: 1952 case CPU_DOWN_FAILED:
1953 case CPU_DOWN_FAILED_FROZEN:
1952 cpufreq_add_dev(dev, NULL); 1954 cpufreq_add_dev(dev, NULL);
1953 break; 1955 break;
1954 } 1956 }
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 464587697561..7b839a8db2a7 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -25,7 +25,6 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <linux/cpu.h>
29 28
30#include "cpufreq_governor.h" 29#include "cpufreq_governor.h"
31 30
@@ -137,10 +136,8 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
137 if (!all_cpus) { 136 if (!all_cpus) {
138 __gov_queue_work(smp_processor_id(), dbs_data, delay); 137 __gov_queue_work(smp_processor_id(), dbs_data, delay);
139 } else { 138 } else {
140 get_online_cpus();
141 for_each_cpu(i, policy->cpus) 139 for_each_cpu(i, policy->cpus)
142 __gov_queue_work(i, dbs_data, delay); 140 __gov_queue_work(i, dbs_data, delay);
143 put_online_cpus();
144 } 141 }
145} 142}
146EXPORT_SYMBOL_GPL(gov_queue_work); 143EXPORT_SYMBOL_GPL(gov_queue_work);
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index cd9e81713a71..d37568c5ca9c 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -341,7 +341,7 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
341 return 0; 341 return 0;
342} 342}
343 343
344static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, 344static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
345 unsigned long action, 345 unsigned long action,
346 void *hcpu) 346 void *hcpu)
347{ 347{
@@ -353,13 +353,11 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
353 cpufreq_update_policy(cpu); 353 cpufreq_update_policy(cpu);
354 break; 354 break;
355 case CPU_DOWN_PREPARE: 355 case CPU_DOWN_PREPARE:
356 case CPU_DOWN_PREPARE_FROZEN:
356 cpufreq_stats_free_sysfs(cpu); 357 cpufreq_stats_free_sysfs(cpu);
357 break; 358 break;
358 case CPU_DEAD: 359 case CPU_DEAD:
359 cpufreq_stats_free_table(cpu); 360 case CPU_DEAD_FROZEN:
360 break;
361 case CPU_UP_CANCELED_FROZEN:
362 cpufreq_stats_free_sysfs(cpu);
363 cpufreq_stats_free_table(cpu); 361 cpufreq_stats_free_table(cpu);
364 break; 362 break;
365 } 363 }
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 1fdb02b9f1ec..26321cdc1946 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -82,7 +82,7 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
82 return freq_table[i].frequency; 82 return freq_table[i].frequency;
83} 83}
84 84
85static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) 85static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
86{ 86{
87 int res; 87 int res;
88 88
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 07f2840ad805..7cde885011ed 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -103,10 +103,10 @@ struct pstate_adjust_policy {
103static struct pstate_adjust_policy default_policy = { 103static struct pstate_adjust_policy default_policy = {
104 .sample_rate_ms = 10, 104 .sample_rate_ms = 10,
105 .deadband = 0, 105 .deadband = 0,
106 .setpoint = 109, 106 .setpoint = 97,
107 .p_gain_pct = 17, 107 .p_gain_pct = 20,
108 .d_gain_pct = 0, 108 .d_gain_pct = 0,
109 .i_gain_pct = 4, 109 .i_gain_pct = 0,
110}; 110};
111 111
112struct perf_limits { 112struct perf_limits {
@@ -468,12 +468,12 @@ static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
468static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu) 468static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu)
469{ 469{
470 int32_t busy_scaled; 470 int32_t busy_scaled;
471 int32_t core_busy, turbo_pstate, current_pstate; 471 int32_t core_busy, max_pstate, current_pstate;
472 472
473 core_busy = int_tofp(cpu->samples[cpu->sample_ptr].core_pct_busy); 473 core_busy = int_tofp(cpu->samples[cpu->sample_ptr].core_pct_busy);
474 turbo_pstate = int_tofp(cpu->pstate.turbo_pstate); 474 max_pstate = int_tofp(cpu->pstate.max_pstate);
475 current_pstate = int_tofp(cpu->pstate.current_pstate); 475 current_pstate = int_tofp(cpu->pstate.current_pstate);
476 busy_scaled = mul_fp(core_busy, div_fp(turbo_pstate, current_pstate)); 476 busy_scaled = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
477 477
478 return fp_toint(busy_scaled); 478 return fp_toint(busy_scaled);
479} 479}
@@ -617,7 +617,7 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
617 return 0; 617 return 0;
618} 618}
619 619
620static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy) 620static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
621{ 621{
622 int cpu = policy->cpu; 622 int cpu = policy->cpu;
623 623
@@ -627,7 +627,7 @@ static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy)
627 return 0; 627 return 0;
628} 628}
629 629
630static int __cpuinit intel_pstate_cpu_init(struct cpufreq_policy *policy) 630static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
631{ 631{
632 int rc, min_pstate, max_pstate; 632 int rc, min_pstate, max_pstate;
633 struct cpudata *cpu; 633 struct cpudata *cpu;
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index b6a0a7a406b0..8c49261df57d 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -422,7 +422,7 @@ static int guess_fsb(int mult)
422} 422}
423 423
424 424
425static int __cpuinit longhaul_get_ranges(void) 425static int longhaul_get_ranges(void)
426{ 426{
427 unsigned int i, j, k = 0; 427 unsigned int i, j, k = 0;
428 unsigned int ratio; 428 unsigned int ratio;
@@ -526,7 +526,7 @@ static int __cpuinit longhaul_get_ranges(void)
526} 526}
527 527
528 528
529static void __cpuinit longhaul_setup_voltagescaling(void) 529static void longhaul_setup_voltagescaling(void)
530{ 530{
531 union msr_longhaul longhaul; 531 union msr_longhaul longhaul;
532 struct mV_pos minvid, maxvid, vid; 532 struct mV_pos minvid, maxvid, vid;
@@ -780,7 +780,7 @@ static int longhaul_setup_southbridge(void)
780 return 0; 780 return 0;
781} 781}
782 782
783static int __cpuinit longhaul_cpu_init(struct cpufreq_policy *policy) 783static int longhaul_cpu_init(struct cpufreq_policy *policy)
784{ 784{
785 struct cpuinfo_x86 *c = &cpu_data(0); 785 struct cpuinfo_x86 *c = &cpu_data(0);
786 char *cpuname = NULL; 786 char *cpuname = NULL;
diff --git a/drivers/cpufreq/longhaul.h b/drivers/cpufreq/longhaul.h
index e2dc436099d1..1928b923a57b 100644
--- a/drivers/cpufreq/longhaul.h
+++ b/drivers/cpufreq/longhaul.h
@@ -56,7 +56,7 @@ union msr_longhaul {
56/* 56/*
57 * VIA C3 Samuel 1 & Samuel 2 (stepping 0) 57 * VIA C3 Samuel 1 & Samuel 2 (stepping 0)
58 */ 58 */
59static const int __cpuinitconst samuel1_mults[16] = { 59static const int samuel1_mults[16] = {
60 -1, /* 0000 -> RESERVED */ 60 -1, /* 0000 -> RESERVED */
61 30, /* 0001 -> 3.0x */ 61 30, /* 0001 -> 3.0x */
62 40, /* 0010 -> 4.0x */ 62 40, /* 0010 -> 4.0x */
@@ -75,7 +75,7 @@ static const int __cpuinitconst samuel1_mults[16] = {
75 -1, /* 1111 -> RESERVED */ 75 -1, /* 1111 -> RESERVED */
76}; 76};
77 77
78static const int __cpuinitconst samuel1_eblcr[16] = { 78static const int samuel1_eblcr[16] = {
79 50, /* 0000 -> RESERVED */ 79 50, /* 0000 -> RESERVED */
80 30, /* 0001 -> 3.0x */ 80 30, /* 0001 -> 3.0x */
81 40, /* 0010 -> 4.0x */ 81 40, /* 0010 -> 4.0x */
@@ -97,7 +97,7 @@ static const int __cpuinitconst samuel1_eblcr[16] = {
97/* 97/*
98 * VIA C3 Samuel2 Stepping 1->15 98 * VIA C3 Samuel2 Stepping 1->15
99 */ 99 */
100static const int __cpuinitconst samuel2_eblcr[16] = { 100static const int samuel2_eblcr[16] = {
101 50, /* 0000 -> 5.0x */ 101 50, /* 0000 -> 5.0x */
102 30, /* 0001 -> 3.0x */ 102 30, /* 0001 -> 3.0x */
103 40, /* 0010 -> 4.0x */ 103 40, /* 0010 -> 4.0x */
@@ -119,7 +119,7 @@ static const int __cpuinitconst samuel2_eblcr[16] = {
119/* 119/*
120 * VIA C3 Ezra 120 * VIA C3 Ezra
121 */ 121 */
122static const int __cpuinitconst ezra_mults[16] = { 122static const int ezra_mults[16] = {
123 100, /* 0000 -> 10.0x */ 123 100, /* 0000 -> 10.0x */
124 30, /* 0001 -> 3.0x */ 124 30, /* 0001 -> 3.0x */
125 40, /* 0010 -> 4.0x */ 125 40, /* 0010 -> 4.0x */
@@ -138,7 +138,7 @@ static const int __cpuinitconst ezra_mults[16] = {
138 120, /* 1111 -> 12.0x */ 138 120, /* 1111 -> 12.0x */
139}; 139};
140 140
141static const int __cpuinitconst ezra_eblcr[16] = { 141static const int ezra_eblcr[16] = {
142 50, /* 0000 -> 5.0x */ 142 50, /* 0000 -> 5.0x */
143 30, /* 0001 -> 3.0x */ 143 30, /* 0001 -> 3.0x */
144 40, /* 0010 -> 4.0x */ 144 40, /* 0010 -> 4.0x */
@@ -160,7 +160,7 @@ static const int __cpuinitconst ezra_eblcr[16] = {
160/* 160/*
161 * VIA C3 (Ezra-T) [C5M]. 161 * VIA C3 (Ezra-T) [C5M].
162 */ 162 */
163static const int __cpuinitconst ezrat_mults[32] = { 163static const int ezrat_mults[32] = {
164 100, /* 0000 -> 10.0x */ 164 100, /* 0000 -> 10.0x */
165 30, /* 0001 -> 3.0x */ 165 30, /* 0001 -> 3.0x */
166 40, /* 0010 -> 4.0x */ 166 40, /* 0010 -> 4.0x */
@@ -196,7 +196,7 @@ static const int __cpuinitconst ezrat_mults[32] = {
196 -1, /* 1111 -> RESERVED (12.0x) */ 196 -1, /* 1111 -> RESERVED (12.0x) */
197}; 197};
198 198
199static const int __cpuinitconst ezrat_eblcr[32] = { 199static const int ezrat_eblcr[32] = {
200 50, /* 0000 -> 5.0x */ 200 50, /* 0000 -> 5.0x */
201 30, /* 0001 -> 3.0x */ 201 30, /* 0001 -> 3.0x */
202 40, /* 0010 -> 4.0x */ 202 40, /* 0010 -> 4.0x */
@@ -235,7 +235,7 @@ static const int __cpuinitconst ezrat_eblcr[32] = {
235/* 235/*
236 * VIA C3 Nehemiah */ 236 * VIA C3 Nehemiah */
237 237
238static const int __cpuinitconst nehemiah_mults[32] = { 238static const int nehemiah_mults[32] = {
239 100, /* 0000 -> 10.0x */ 239 100, /* 0000 -> 10.0x */
240 -1, /* 0001 -> 16.0x */ 240 -1, /* 0001 -> 16.0x */
241 40, /* 0010 -> 4.0x */ 241 40, /* 0010 -> 4.0x */
@@ -270,7 +270,7 @@ static const int __cpuinitconst nehemiah_mults[32] = {
270 -1, /* 1111 -> 12.0x */ 270 -1, /* 1111 -> 12.0x */
271}; 271};
272 272
273static const int __cpuinitconst nehemiah_eblcr[32] = { 273static const int nehemiah_eblcr[32] = {
274 50, /* 0000 -> 5.0x */ 274 50, /* 0000 -> 5.0x */
275 160, /* 0001 -> 16.0x */ 275 160, /* 0001 -> 16.0x */
276 40, /* 0010 -> 4.0x */ 276 40, /* 0010 -> 4.0x */
@@ -315,7 +315,7 @@ struct mV_pos {
315 unsigned short pos; 315 unsigned short pos;
316}; 316};
317 317
318static const struct mV_pos __cpuinitconst vrm85_mV[32] = { 318static const struct mV_pos vrm85_mV[32] = {
319 {1250, 8}, {1200, 6}, {1150, 4}, {1100, 2}, 319 {1250, 8}, {1200, 6}, {1150, 4}, {1100, 2},
320 {1050, 0}, {1800, 30}, {1750, 28}, {1700, 26}, 320 {1050, 0}, {1800, 30}, {1750, 28}, {1700, 26},
321 {1650, 24}, {1600, 22}, {1550, 20}, {1500, 18}, 321 {1650, 24}, {1600, 22}, {1550, 20}, {1500, 18},
@@ -326,14 +326,14 @@ static const struct mV_pos __cpuinitconst vrm85_mV[32] = {
326 {1475, 17}, {1425, 15}, {1375, 13}, {1325, 11} 326 {1475, 17}, {1425, 15}, {1375, 13}, {1325, 11}
327}; 327};
328 328
329static const unsigned char __cpuinitconst mV_vrm85[32] = { 329static const unsigned char mV_vrm85[32] = {
330 0x04, 0x14, 0x03, 0x13, 0x02, 0x12, 0x01, 0x11, 330 0x04, 0x14, 0x03, 0x13, 0x02, 0x12, 0x01, 0x11,
331 0x00, 0x10, 0x0f, 0x1f, 0x0e, 0x1e, 0x0d, 0x1d, 331 0x00, 0x10, 0x0f, 0x1f, 0x0e, 0x1e, 0x0d, 0x1d,
332 0x0c, 0x1c, 0x0b, 0x1b, 0x0a, 0x1a, 0x09, 0x19, 332 0x0c, 0x1c, 0x0b, 0x1b, 0x0a, 0x1a, 0x09, 0x19,
333 0x08, 0x18, 0x07, 0x17, 0x06, 0x16, 0x05, 0x15 333 0x08, 0x18, 0x07, 0x17, 0x06, 0x16, 0x05, 0x15
334}; 334};
335 335
336static const struct mV_pos __cpuinitconst mobilevrm_mV[32] = { 336static const struct mV_pos mobilevrm_mV[32] = {
337 {1750, 31}, {1700, 30}, {1650, 29}, {1600, 28}, 337 {1750, 31}, {1700, 30}, {1650, 29}, {1600, 28},
338 {1550, 27}, {1500, 26}, {1450, 25}, {1400, 24}, 338 {1550, 27}, {1500, 26}, {1450, 25}, {1400, 24},
339 {1350, 23}, {1300, 22}, {1250, 21}, {1200, 20}, 339 {1350, 23}, {1300, 22}, {1250, 21}, {1200, 20},
@@ -344,7 +344,7 @@ static const struct mV_pos __cpuinitconst mobilevrm_mV[32] = {
344 {675, 3}, {650, 2}, {625, 1}, {600, 0} 344 {675, 3}, {650, 2}, {625, 1}, {600, 0}
345}; 345};
346 346
347static const unsigned char __cpuinitconst mV_mobilevrm[32] = { 347static const unsigned char mV_mobilevrm[32] = {
348 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 348 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
349 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 349 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
350 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 350 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c
index 8bc9f5fbbaeb..0fe041d1f77f 100644
--- a/drivers/cpufreq/longrun.c
+++ b/drivers/cpufreq/longrun.c
@@ -33,7 +33,7 @@ static unsigned int longrun_low_freq, longrun_high_freq;
33 * Reads the current LongRun policy by access to MSR_TMTA_LONGRUN_FLAGS 33 * Reads the current LongRun policy by access to MSR_TMTA_LONGRUN_FLAGS
34 * and MSR_TMTA_LONGRUN_CTRL 34 * and MSR_TMTA_LONGRUN_CTRL
35 */ 35 */
36static void __cpuinit longrun_get_policy(struct cpufreq_policy *policy) 36static void longrun_get_policy(struct cpufreq_policy *policy)
37{ 37{
38 u32 msr_lo, msr_hi; 38 u32 msr_lo, msr_hi;
39 39
@@ -163,7 +163,7 @@ static unsigned int longrun_get(unsigned int cpu)
163 * TMTA rules: 163 * TMTA rules:
164 * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq) 164 * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq)
165 */ 165 */
166static int __cpuinit longrun_determine_freqs(unsigned int *low_freq, 166static int longrun_determine_freqs(unsigned int *low_freq,
167 unsigned int *high_freq) 167 unsigned int *high_freq)
168{ 168{
169 u32 msr_lo, msr_hi; 169 u32 msr_lo, msr_hi;
@@ -256,7 +256,7 @@ static int __cpuinit longrun_determine_freqs(unsigned int *low_freq,
256} 256}
257 257
258 258
259static int __cpuinit longrun_cpu_init(struct cpufreq_policy *policy) 259static int longrun_cpu_init(struct cpufreq_policy *policy)
260{ 260{
261 int result = 0; 261 int result = 0;
262 262
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 29468a522ee9..f31fcfcad514 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -165,7 +165,7 @@ static inline void freq_table_free(void)
165 opp_free_cpufreq_table(mpu_dev, &freq_table); 165 opp_free_cpufreq_table(mpu_dev, &freq_table);
166} 166}
167 167
168static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) 168static int omap_cpu_init(struct cpufreq_policy *policy)
169{ 169{
170 int result = 0; 170 int result = 0;
171 171
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index b9f80b713fda..955870877935 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -563,7 +563,7 @@ static int powernow_verify(struct cpufreq_policy *policy)
563 * We will then get the same kind of behaviour already tested under 563 * We will then get the same kind of behaviour already tested under
564 * the "well-known" other OS. 564 * the "well-known" other OS.
565 */ 565 */
566static int __cpuinit fixup_sgtc(void) 566static int fixup_sgtc(void)
567{ 567{
568 unsigned int sgtc; 568 unsigned int sgtc;
569 unsigned int m; 569 unsigned int m;
@@ -597,7 +597,7 @@ static unsigned int powernow_get(unsigned int cpu)
597} 597}
598 598
599 599
600static int __cpuinit acer_cpufreq_pst(const struct dmi_system_id *d) 600static int acer_cpufreq_pst(const struct dmi_system_id *d)
601{ 601{
602 printk(KERN_WARNING PFX 602 printk(KERN_WARNING PFX
603 "%s laptop with broken PST tables in BIOS detected.\n", 603 "%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)
615 * A BIOS update is all that can save them. 615 * A BIOS update is all that can save them.
616 * Mention this, and disable cpufreq. 616 * Mention this, and disable cpufreq.
617 */ 617 */
618static struct dmi_system_id __cpuinitdata powernow_dmi_table[] = { 618static struct dmi_system_id powernow_dmi_table[] = {
619 { 619 {
620 .callback = acer_cpufreq_pst, 620 .callback = acer_cpufreq_pst,
621 .ident = "Acer Aspire", 621 .ident = "Acer Aspire",
@@ -627,7 +627,7 @@ static struct dmi_system_id __cpuinitdata powernow_dmi_table[] = {
627 { } 627 { }
628}; 628};
629 629
630static int __cpuinit powernow_cpu_init(struct cpufreq_policy *policy) 630static int powernow_cpu_init(struct cpufreq_policy *policy)
631{ 631{
632 union msr_fidvidstatus fidvidstatus; 632 union msr_fidvidstatus fidvidstatus;
633 int result; 633 int result;
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 78f018f2a5de..c39d189217cb 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1069,7 +1069,7 @@ struct init_on_cpu {
1069 int rc; 1069 int rc;
1070}; 1070};
1071 1071
1072static void __cpuinit powernowk8_cpu_init_on_cpu(void *_init_on_cpu) 1072static void powernowk8_cpu_init_on_cpu(void *_init_on_cpu)
1073{ 1073{
1074 struct init_on_cpu *init_on_cpu = _init_on_cpu; 1074 struct init_on_cpu *init_on_cpu = _init_on_cpu;
1075 1075
@@ -1096,7 +1096,7 @@ static const char missing_pss_msg[] =
1096 FW_BUG PFX "If that doesn't help, try upgrading your BIOS.\n"; 1096 FW_BUG PFX "If that doesn't help, try upgrading your BIOS.\n";
1097 1097
1098/* per CPU init entry point to the driver */ 1098/* per CPU init entry point to the driver */
1099static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) 1099static int powernowk8_cpu_init(struct cpufreq_policy *pol)
1100{ 1100{
1101 struct powernow_k8_data *data; 1101 struct powernow_k8_data *data;
1102 struct init_on_cpu init_on_cpu; 1102 struct init_on_cpu init_on_cpu;
@@ -1263,7 +1263,7 @@ static void __request_acpi_cpufreq(void)
1263} 1263}
1264 1264
1265/* driver entry point for init */ 1265/* driver entry point for init */
1266static int __cpuinit powernowk8_init(void) 1266static int powernowk8_init(void)
1267{ 1267{
1268 unsigned int i, supported_cpus = 0; 1268 unsigned int i, supported_cpus = 0;
1269 int ret; 1269 int ret;
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index 3513e7477160..87781eb20d6d 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -49,7 +49,7 @@ static struct clk *clk_hclk;
49static struct clk *clk_pclk; 49static struct clk *clk_pclk;
50static struct clk *clk_arm; 50static struct clk *clk_arm;
51 51
52#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS 52#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS
53struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void) 53struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void)
54{ 54{
55 return &cpu_cur; 55 return &cpu_cur;
@@ -59,7 +59,7 @@ struct s3c_iotimings *s3c_cpufreq_getiotimings(void)
59{ 59{
60 return &s3c24xx_iotiming; 60 return &s3c24xx_iotiming;
61} 61}
62#endif /* CONFIG_CPU_FREQ_S3C24XX_DEBUGFS */ 62#endif /* CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS */
63 63
64static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg) 64static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg)
65{ 65{
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 5996521a1caf..84573b4d6f92 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -429,7 +429,7 @@ static int hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in,
429 dma_addr_t src_dma, dst_dma; 429 dma_addr_t src_dma, dst_dma;
430 int ret = 0; 430 int ret = 0;
431 431
432 desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); 432 desc = kmalloc(CAAM_CMD_SZ * 8 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA);
433 if (!desc) { 433 if (!desc) {
434 dev_err(jrdev, "unable to allocate key input memory\n"); 434 dev_err(jrdev, "unable to allocate key input memory\n");
435 return -ENOMEM; 435 return -ENOMEM;
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 27e86d938262..89e109022d78 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -48,6 +48,8 @@ static LIST_HEAD(mc_devices);
48 */ 48 */
49static void const *edac_mc_owner; 49static void const *edac_mc_owner;
50 50
51static struct bus_type mc_bus[EDAC_MAX_MCS];
52
51unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf, 53unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
52 unsigned len) 54 unsigned len)
53{ 55{
@@ -723,6 +725,11 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
723 int ret = -EINVAL; 725 int ret = -EINVAL;
724 edac_dbg(0, "\n"); 726 edac_dbg(0, "\n");
725 727
728 if (mci->mc_idx >= EDAC_MAX_MCS) {
729 pr_warn_once("Too many memory controllers: %d\n", mci->mc_idx);
730 return -ENODEV;
731 }
732
726#ifdef CONFIG_EDAC_DEBUG 733#ifdef CONFIG_EDAC_DEBUG
727 if (edac_debug_level >= 3) 734 if (edac_debug_level >= 3)
728 edac_mc_dump_mci(mci); 735 edac_mc_dump_mci(mci);
@@ -762,6 +769,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
762 /* set load time so that error rate can be tracked */ 769 /* set load time so that error rate can be tracked */
763 mci->start_time = jiffies; 770 mci->start_time = jiffies;
764 771
772 mci->bus = &mc_bus[mci->mc_idx];
773
765 if (edac_create_sysfs_mci_device(mci)) { 774 if (edac_create_sysfs_mci_device(mci)) {
766 edac_mc_printk(mci, KERN_WARNING, 775 edac_mc_printk(mci, KERN_WARNING,
767 "failed to create sysfs device\n"); 776 "failed to create sysfs device\n");
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index ef15a7e613bc..e7c32c4f7837 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -370,7 +370,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
370 return -ENODEV; 370 return -ENODEV;
371 371
372 csrow->dev.type = &csrow_attr_type; 372 csrow->dev.type = &csrow_attr_type;
373 csrow->dev.bus = &mci->bus; 373 csrow->dev.bus = mci->bus;
374 device_initialize(&csrow->dev); 374 device_initialize(&csrow->dev);
375 csrow->dev.parent = &mci->dev; 375 csrow->dev.parent = &mci->dev;
376 csrow->mci = mci; 376 csrow->mci = mci;
@@ -605,7 +605,7 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci,
605 dimm->mci = mci; 605 dimm->mci = mci;
606 606
607 dimm->dev.type = &dimm_attr_type; 607 dimm->dev.type = &dimm_attr_type;
608 dimm->dev.bus = &mci->bus; 608 dimm->dev.bus = mci->bus;
609 device_initialize(&dimm->dev); 609 device_initialize(&dimm->dev);
610 610
611 dimm->dev.parent = &mci->dev; 611 dimm->dev.parent = &mci->dev;
@@ -975,11 +975,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
975 * The memory controller needs its own bus, in order to avoid 975 * The memory controller needs its own bus, in order to avoid
976 * namespace conflicts at /sys/bus/edac. 976 * namespace conflicts at /sys/bus/edac.
977 */ 977 */
978 mci->bus.name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx); 978 mci->bus->name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
979 if (!mci->bus.name) 979 if (!mci->bus->name)
980 return -ENOMEM; 980 return -ENOMEM;
981 edac_dbg(0, "creating bus %s\n", mci->bus.name); 981
982 err = bus_register(&mci->bus); 982 edac_dbg(0, "creating bus %s\n", mci->bus->name);
983
984 err = bus_register(mci->bus);
983 if (err < 0) 985 if (err < 0)
984 return err; 986 return err;
985 987
@@ -988,7 +990,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
988 device_initialize(&mci->dev); 990 device_initialize(&mci->dev);
989 991
990 mci->dev.parent = mci_pdev; 992 mci->dev.parent = mci_pdev;
991 mci->dev.bus = &mci->bus; 993 mci->dev.bus = mci->bus;
992 dev_set_name(&mci->dev, "mc%d", mci->mc_idx); 994 dev_set_name(&mci->dev, "mc%d", mci->mc_idx);
993 dev_set_drvdata(&mci->dev, mci); 995 dev_set_drvdata(&mci->dev, mci);
994 pm_runtime_forbid(&mci->dev); 996 pm_runtime_forbid(&mci->dev);
@@ -997,8 +999,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
997 err = device_add(&mci->dev); 999 err = device_add(&mci->dev);
998 if (err < 0) { 1000 if (err < 0) {
999 edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev)); 1001 edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
1000 bus_unregister(&mci->bus); 1002 bus_unregister(mci->bus);
1001 kfree(mci->bus.name); 1003 kfree(mci->bus->name);
1002 return err; 1004 return err;
1003 } 1005 }
1004 1006
@@ -1064,8 +1066,8 @@ fail:
1064 } 1066 }
1065fail2: 1067fail2:
1066 device_unregister(&mci->dev); 1068 device_unregister(&mci->dev);
1067 bus_unregister(&mci->bus); 1069 bus_unregister(mci->bus);
1068 kfree(mci->bus.name); 1070 kfree(mci->bus->name);
1069 return err; 1071 return err;
1070} 1072}
1071 1073
@@ -1098,8 +1100,8 @@ void edac_unregister_sysfs(struct mem_ctl_info *mci)
1098{ 1100{
1099 edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev)); 1101 edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev));
1100 device_unregister(&mci->dev); 1102 device_unregister(&mci->dev);
1101 bus_unregister(&mci->bus); 1103 bus_unregister(mci->bus);
1102 kfree(mci->bus.name); 1104 kfree(mci->bus->name);
1103} 1105}
1104 1106
1105static void mc_attr_release(struct device *dev) 1107static void mc_attr_release(struct device *dev)
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index 1b635178cc44..157b934e8ce3 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -974,7 +974,7 @@ static int i5100_setup_debugfs(struct mem_ctl_info *mci)
974 if (!i5100_debugfs) 974 if (!i5100_debugfs)
975 return -ENODEV; 975 return -ENODEV;
976 976
977 priv->debugfs = debugfs_create_dir(mci->bus.name, i5100_debugfs); 977 priv->debugfs = debugfs_create_dir(mci->bus->name, i5100_debugfs);
978 978
979 if (!priv->debugfs) 979 if (!priv->debugfs)
980 return -ENOMEM; 980 return -ENOMEM;
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index 8bd1bb6dbe47..8a7432a4b413 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -583,6 +583,9 @@ int efivars_sysfs_init(void)
583 struct kobject *parent_kobj = efivars_kobject(); 583 struct kobject *parent_kobj = efivars_kobject();
584 int error = 0; 584 int error = 0;
585 585
586 if (!efi_enabled(EFI_RUNTIME_SERVICES))
587 return -ENODEV;
588
586 /* No efivars has been registered yet */ 589 /* No efivars has been registered yet */
587 if (!parent_kobj) 590 if (!parent_kobj)
588 return 0; 591 return 0;
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c
index f4491a497cc8..c2fa77086eb5 100644
--- a/drivers/gpio/gpio-msm-v2.c
+++ b/drivers/gpio/gpio-msm-v2.c
@@ -378,7 +378,7 @@ static int msm_gpio_probe(struct platform_device *pdev)
378 int ret, ngpio; 378 int ret, ngpio;
379 struct resource *res; 379 struct resource *res;
380 380
381 if (!of_property_read_u32(pdev->dev.of_node, "ngpio", &ngpio)) { 381 if (of_property_read_u32(pdev->dev.of_node, "ngpio", &ngpio)) {
382 dev_err(&pdev->dev, "%s: ngpio property missing\n", __func__); 382 dev_err(&pdev->dev, "%s: ngpio property missing\n", __func__);
383 return -EINVAL; 383 return -EINVAL;
384 } 384 }
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index dfeb3a3a8f20..c57244ef428b 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1037,6 +1037,18 @@ omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start,
1037 IRQ_NOREQUEST | IRQ_NOPROBE, 0); 1037 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
1038} 1038}
1039 1039
1040#if defined(CONFIG_OF_GPIO)
1041static inline bool omap_gpio_chip_boot_dt(struct gpio_chip *chip)
1042{
1043 return chip->of_node != NULL;
1044}
1045#else
1046static inline bool omap_gpio_chip_boot_dt(struct gpio_chip *chip)
1047{
1048 return false;
1049}
1050#endif
1051
1040static void omap_gpio_chip_init(struct gpio_bank *bank) 1052static void omap_gpio_chip_init(struct gpio_bank *bank)
1041{ 1053{
1042 int j; 1054 int j;
@@ -1068,24 +1080,68 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
1068 1080
1069 gpiochip_add(&bank->chip); 1081 gpiochip_add(&bank->chip);
1070 1082
1071 for (j = 0; j < bank->width; j++) { 1083 /*
1072 int irq = irq_create_mapping(bank->domain, j); 1084 * REVISIT these explicit calls to irq_create_mapping()
1073 irq_set_lockdep_class(irq, &gpio_lock_class); 1085 * to do the GPIO to IRQ domain mapping for each GPIO in
1074 irq_set_chip_data(irq, bank); 1086 * the bank can be removed once all OMAP platforms have
1075 if (bank->is_mpuio) { 1087 * been migrated to Device Tree boot only.
1076 omap_mpuio_alloc_gc(bank, irq, bank->width); 1088 * Since in DT boot irq_create_mapping() is called from
1077 } else { 1089 * irq_create_of_mapping() only for the GPIO lines that
1078 irq_set_chip_and_handler(irq, &gpio_irq_chip, 1090 * are used as interrupts.
1079 handle_simple_irq); 1091 */
1080 set_irq_flags(irq, IRQF_VALID); 1092 if (!omap_gpio_chip_boot_dt(&bank->chip))
1081 } 1093 for (j = 0; j < bank->width; j++)
1082 } 1094 irq_create_mapping(bank->domain, j);
1083 irq_set_chained_handler(bank->irq, gpio_irq_handler); 1095 irq_set_chained_handler(bank->irq, gpio_irq_handler);
1084 irq_set_handler_data(bank->irq, bank); 1096 irq_set_handler_data(bank->irq, bank);
1085} 1097}
1086 1098
1087static const struct of_device_id omap_gpio_match[]; 1099static const struct of_device_id omap_gpio_match[];
1088 1100
1101static int omap_gpio_irq_map(struct irq_domain *d, unsigned int virq,
1102 irq_hw_number_t hwirq)
1103{
1104 struct gpio_bank *bank = d->host_data;
1105 int gpio;
1106 int ret;
1107
1108 if (!bank)
1109 return -EINVAL;
1110
1111 irq_set_lockdep_class(virq, &gpio_lock_class);
1112 irq_set_chip_data(virq, bank);
1113 if (bank->is_mpuio) {
1114 omap_mpuio_alloc_gc(bank, virq, bank->width);
1115 } else {
1116 irq_set_chip_and_handler(virq, &gpio_irq_chip,
1117 handle_simple_irq);
1118 set_irq_flags(virq, IRQF_VALID);
1119 }
1120
1121 /*
1122 * REVISIT most GPIO IRQ chip drivers need to call
1123 * gpio_request() before a GPIO line can be used as an
1124 * IRQ. Ideally this should be handled by the IRQ core
1125 * but until then this has to be done on a per driver
1126 * basis. Remove this once this is managed by the core.
1127 */
1128 if (omap_gpio_chip_boot_dt(&bank->chip)) {
1129 gpio = irq_to_gpio(bank, hwirq);
1130 ret = gpio_request_one(gpio, GPIOF_IN, NULL);
1131 if (ret) {
1132 dev_err(bank->dev, "Could not request GPIO%d\n", gpio);
1133 return ret;
1134 }
1135 }
1136
1137 return 0;
1138}
1139
1140static struct irq_domain_ops omap_gpio_irq_ops = {
1141 .xlate = irq_domain_xlate_onetwocell,
1142 .map = omap_gpio_irq_map,
1143};
1144
1089static int omap_gpio_probe(struct platform_device *pdev) 1145static int omap_gpio_probe(struct platform_device *pdev)
1090{ 1146{
1091 struct device *dev = &pdev->dev; 1147 struct device *dev = &pdev->dev;
@@ -1151,10 +1207,10 @@ static int omap_gpio_probe(struct platform_device *pdev)
1151 } 1207 }
1152 1208
1153 bank->domain = irq_domain_add_legacy(node, bank->width, irq_base, 1209 bank->domain = irq_domain_add_legacy(node, bank->width, irq_base,
1154 0, &irq_domain_simple_ops, NULL); 1210 0, &omap_gpio_irq_ops, bank);
1155#else 1211#else
1156 bank->domain = irq_domain_add_linear(node, bank->width, 1212 bank->domain = irq_domain_add_linear(node, bank->width,
1157 &irq_domain_simple_ops, NULL); 1213 &omap_gpio_irq_ops, bank);
1158#endif 1214#endif
1159 if (!bank->domain) { 1215 if (!bank->domain) {
1160 dev_err(dev, "Couldn't register an IRQ domain\n"); 1216 dev_err(dev, "Couldn't register an IRQ domain\n");
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 738a4294d820..6a647493ca7f 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -677,6 +677,11 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
677 /* don't break so fail path works correct */ 677 /* don't break so fail path works correct */
678 fail = 1; 678 fail = 1;
679 break; 679 break;
680
681 if (connector->dpms != DRM_MODE_DPMS_ON) {
682 DRM_DEBUG_KMS("connector dpms not on, full mode switch\n");
683 mode_changed = true;
684 }
680 } 685 }
681 } 686 }
682 687
@@ -754,6 +759,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
754 ret = -EINVAL; 759 ret = -EINVAL;
755 goto fail; 760 goto fail;
756 } 761 }
762 DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
763 for (i = 0; i < set->num_connectors; i++) {
764 DRM_DEBUG_KMS("\t[CONNECTOR:%d:%s] set DPMS on\n", set->connectors[i]->base.id,
765 drm_get_connector_name(set->connectors[i]));
766 set->connectors[i]->funcs->dpms(set->connectors[i], DRM_MODE_DPMS_ON);
767 }
757 } 768 }
758 drm_helper_disable_unused_functions(dev); 769 drm_helper_disable_unused_functions(dev);
759 } else if (fb_changed) { 770 } else if (fb_changed) {
@@ -771,22 +782,6 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
771 } 782 }
772 } 783 }
773 784
774 /*
775 * crtc set_config helpers implicit set the crtc and all connected
776 * encoders to DPMS on for a full mode set. But for just an fb update it
777 * doesn't do that. To not confuse userspace, do an explicit DPMS_ON
778 * unconditionally. This will also ensure driver internal dpms state is
779 * consistent again.
780 */
781 if (set->crtc->enabled) {
782 DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
783 for (i = 0; i < set->num_connectors; i++) {
784 DRM_DEBUG_KMS("\t[CONNECTOR:%d:%s] set DPMS on\n", set->connectors[i]->base.id,
785 drm_get_connector_name(set->connectors[i]));
786 set->connectors[i]->funcs->dpms(set->connectors[i], DRM_MODE_DPMS_ON);
787 }
788 }
789
790 kfree(save_connectors); 785 kfree(save_connectors);
791 kfree(save_encoders); 786 kfree(save_encoders);
792 kfree(save_crtcs); 787 kfree(save_crtcs);
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index adb319b53ecd..66c63808fa35 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1495,6 +1495,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1495 dev_priv->dev = dev; 1495 dev_priv->dev = dev;
1496 dev_priv->info = info; 1496 dev_priv->info = info;
1497 1497
1498 spin_lock_init(&dev_priv->irq_lock);
1499 spin_lock_init(&dev_priv->gpu_error.lock);
1500 spin_lock_init(&dev_priv->rps.lock);
1501 spin_lock_init(&dev_priv->gt_lock);
1502 spin_lock_init(&dev_priv->backlight.lock);
1503 mutex_init(&dev_priv->dpio_lock);
1504 mutex_init(&dev_priv->rps.hw_lock);
1505 mutex_init(&dev_priv->modeset_restore_lock);
1506
1498 i915_dump_device_info(dev_priv); 1507 i915_dump_device_info(dev_priv);
1499 1508
1500 if (i915_get_bridge_dev(dev)) { 1509 if (i915_get_bridge_dev(dev)) {
@@ -1585,6 +1594,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1585 intel_detect_pch(dev); 1594 intel_detect_pch(dev);
1586 1595
1587 intel_irq_init(dev); 1596 intel_irq_init(dev);
1597 intel_gt_sanitize(dev);
1588 intel_gt_init(dev); 1598 intel_gt_init(dev);
1589 1599
1590 /* Try to make sure MCHBAR is enabled before poking at it */ 1600 /* Try to make sure MCHBAR is enabled before poking at it */
@@ -1610,15 +1620,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1610 if (!IS_I945G(dev) && !IS_I945GM(dev)) 1620 if (!IS_I945G(dev) && !IS_I945GM(dev))
1611 pci_enable_msi(dev->pdev); 1621 pci_enable_msi(dev->pdev);
1612 1622
1613 spin_lock_init(&dev_priv->irq_lock);
1614 spin_lock_init(&dev_priv->gpu_error.lock);
1615 spin_lock_init(&dev_priv->rps.lock);
1616 spin_lock_init(&dev_priv->backlight.lock);
1617 mutex_init(&dev_priv->dpio_lock);
1618
1619 mutex_init(&dev_priv->rps.hw_lock);
1620 mutex_init(&dev_priv->modeset_restore_lock);
1621
1622 dev_priv->num_plane = 1; 1623 dev_priv->num_plane = 1;
1623 if (IS_VALLEYVIEW(dev)) 1624 if (IS_VALLEYVIEW(dev))
1624 dev_priv->num_plane = 2; 1625 dev_priv->num_plane = 2;
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 062cbda1bf4a..45b3c030f483 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -123,10 +123,10 @@ module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 060
123MODULE_PARM_DESC(preliminary_hw_support, 123MODULE_PARM_DESC(preliminary_hw_support,
124 "Enable preliminary hardware support. (default: false)"); 124 "Enable preliminary hardware support. (default: false)");
125 125
126int i915_disable_power_well __read_mostly = 0; 126int i915_disable_power_well __read_mostly = 1;
127module_param_named(disable_power_well, i915_disable_power_well, int, 0600); 127module_param_named(disable_power_well, i915_disable_power_well, int, 0600);
128MODULE_PARM_DESC(disable_power_well, 128MODULE_PARM_DESC(disable_power_well,
129 "Disable the power well when possible (default: false)"); 129 "Disable the power well when possible (default: true)");
130 130
131int i915_enable_ips __read_mostly = 1; 131int i915_enable_ips __read_mostly = 1;
132module_param_named(enable_ips, i915_enable_ips, int, 0600); 132module_param_named(enable_ips, i915_enable_ips, int, 0600);
@@ -706,7 +706,7 @@ static int i915_drm_thaw(struct drm_device *dev)
706{ 706{
707 int error = 0; 707 int error = 0;
708 708
709 intel_gt_reset(dev); 709 intel_gt_sanitize(dev);
710 710
711 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 711 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
712 mutex_lock(&dev->struct_mutex); 712 mutex_lock(&dev->struct_mutex);
@@ -732,7 +732,7 @@ int i915_resume(struct drm_device *dev)
732 732
733 pci_set_master(dev->pdev); 733 pci_set_master(dev->pdev);
734 734
735 intel_gt_reset(dev); 735 intel_gt_sanitize(dev);
736 736
737 /* 737 /*
738 * Platforms with opregion should have sane BIOS, older ones (gen3 and 738 * 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)
1253 1253
1254#define __i915_read(x, y) \ 1254#define __i915_read(x, y) \
1255u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \ 1255u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
1256 unsigned long irqflags; \
1256 u##x val = 0; \ 1257 u##x val = 0; \
1258 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1257 if (IS_GEN5(dev_priv->dev)) \ 1259 if (IS_GEN5(dev_priv->dev)) \
1258 ilk_dummy_write(dev_priv); \ 1260 ilk_dummy_write(dev_priv); \
1259 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1261 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1260 unsigned long irqflags; \
1261 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1262 if (dev_priv->forcewake_count == 0) \ 1262 if (dev_priv->forcewake_count == 0) \
1263 dev_priv->gt.force_wake_get(dev_priv); \ 1263 dev_priv->gt.force_wake_get(dev_priv); \
1264 val = read##y(dev_priv->regs + reg); \ 1264 val = read##y(dev_priv->regs + reg); \
1265 if (dev_priv->forcewake_count == 0) \ 1265 if (dev_priv->forcewake_count == 0) \
1266 dev_priv->gt.force_wake_put(dev_priv); \ 1266 dev_priv->gt.force_wake_put(dev_priv); \
1267 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1268 } else { \ 1267 } else { \
1269 val = read##y(dev_priv->regs + reg); \ 1268 val = read##y(dev_priv->regs + reg); \
1270 } \ 1269 } \
1270 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1271 trace_i915_reg_rw(false, reg, val, sizeof(val)); \ 1271 trace_i915_reg_rw(false, reg, val, sizeof(val)); \
1272 return val; \ 1272 return val; \
1273} 1273}
@@ -1280,8 +1280,10 @@ __i915_read(64, q)
1280 1280
1281#define __i915_write(x, y) \ 1281#define __i915_write(x, y) \
1282void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \ 1282void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1283 unsigned long irqflags; \
1283 u32 __fifo_ret = 0; \ 1284 u32 __fifo_ret = 0; \
1284 trace_i915_reg_rw(true, reg, val, sizeof(val)); \ 1285 trace_i915_reg_rw(true, reg, val, sizeof(val)); \
1286 spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
1285 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ 1287 if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
1286 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \ 1288 __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \
1287 } \ 1289 } \
@@ -1293,6 +1295,7 @@ void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
1293 gen6_gt_check_fifodbg(dev_priv); \ 1295 gen6_gt_check_fifodbg(dev_priv); \
1294 } \ 1296 } \
1295 hsw_unclaimed_reg_check(dev_priv, reg); \ 1297 hsw_unclaimed_reg_check(dev_priv, reg); \
1298 spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
1296} 1299}
1297__i915_write(8, b) 1300__i915_write(8, b)
1298__i915_write(16, w) 1301__i915_write(16, w)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a416645bcd23..d2ee3343c943 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -555,6 +555,7 @@ enum intel_sbi_destination {
555#define QUIRK_PIPEA_FORCE (1<<0) 555#define QUIRK_PIPEA_FORCE (1<<0)
556#define QUIRK_LVDS_SSC_DISABLE (1<<1) 556#define QUIRK_LVDS_SSC_DISABLE (1<<1)
557#define QUIRK_INVERT_BRIGHTNESS (1<<2) 557#define QUIRK_INVERT_BRIGHTNESS (1<<2)
558#define QUIRK_NO_PCH_PWM_ENABLE (1<<3)
558 559
559struct intel_fbdev; 560struct intel_fbdev;
560struct intel_fbc_work; 561struct intel_fbc_work;
@@ -1583,7 +1584,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged);
1583extern void intel_irq_init(struct drm_device *dev); 1584extern void intel_irq_init(struct drm_device *dev);
1584extern void intel_hpd_init(struct drm_device *dev); 1585extern void intel_hpd_init(struct drm_device *dev);
1585extern void intel_gt_init(struct drm_device *dev); 1586extern void intel_gt_init(struct drm_device *dev);
1586extern void intel_gt_reset(struct drm_device *dev); 1587extern void intel_gt_sanitize(struct drm_device *dev);
1587 1588
1588void i915_error_state_free(struct kref *error_ref); 1589void i915_error_state_free(struct kref *error_ref);
1589 1590
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4200c32407ec..d9e2208cfe98 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1880,6 +1880,10 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
1880 u32 seqno = intel_ring_get_seqno(ring); 1880 u32 seqno = intel_ring_get_seqno(ring);
1881 1881
1882 BUG_ON(ring == NULL); 1882 BUG_ON(ring == NULL);
1883 if (obj->ring != ring && obj->last_write_seqno) {
1884 /* Keep the seqno relative to the current ring */
1885 obj->last_write_seqno = seqno;
1886 }
1883 obj->ring = ring; 1887 obj->ring = ring;
1884 1888
1885 /* Add a reference if we're newly entering the active list. */ 1889 /* Add a reference if we're newly entering the active list. */
@@ -2254,7 +2258,17 @@ void i915_gem_restore_fences(struct drm_device *dev)
2254 2258
2255 for (i = 0; i < dev_priv->num_fence_regs; i++) { 2259 for (i = 0; i < dev_priv->num_fence_regs; i++) {
2256 struct drm_i915_fence_reg *reg = &dev_priv->fence_regs[i]; 2260 struct drm_i915_fence_reg *reg = &dev_priv->fence_regs[i];
2257 i915_gem_write_fence(dev, i, reg->obj); 2261
2262 /*
2263 * Commit delayed tiling changes if we have an object still
2264 * attached to the fence, otherwise just clear the fence.
2265 */
2266 if (reg->obj) {
2267 i915_gem_object_update_fence(reg->obj, reg,
2268 reg->obj->tiling_mode);
2269 } else {
2270 i915_gem_write_fence(dev, i, NULL);
2271 }
2258 } 2272 }
2259} 2273}
2260 2274
@@ -2653,7 +2667,6 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
2653 drm_i915_private_t *dev_priv = dev->dev_private; 2667 drm_i915_private_t *dev_priv = dev->dev_private;
2654 int fence_reg; 2668 int fence_reg;
2655 int fence_pitch_shift; 2669 int fence_pitch_shift;
2656 uint64_t val;
2657 2670
2658 if (INTEL_INFO(dev)->gen >= 6) { 2671 if (INTEL_INFO(dev)->gen >= 6) {
2659 fence_reg = FENCE_REG_SANDYBRIDGE_0; 2672 fence_reg = FENCE_REG_SANDYBRIDGE_0;
@@ -2663,8 +2676,23 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
2663 fence_pitch_shift = I965_FENCE_PITCH_SHIFT; 2676 fence_pitch_shift = I965_FENCE_PITCH_SHIFT;
2664 } 2677 }
2665 2678
2679 fence_reg += reg * 8;
2680
2681 /* To w/a incoherency with non-atomic 64-bit register updates,
2682 * we split the 64-bit update into two 32-bit writes. In order
2683 * for a partial fence not to be evaluated between writes, we
2684 * precede the update with write to turn off the fence register,
2685 * and only enable the fence as the last step.
2686 *
2687 * For extra levels of paranoia, we make sure each step lands
2688 * before applying the next step.
2689 */
2690 I915_WRITE(fence_reg, 0);
2691 POSTING_READ(fence_reg);
2692
2666 if (obj) { 2693 if (obj) {
2667 u32 size = obj->gtt_space->size; 2694 u32 size = obj->gtt_space->size;
2695 uint64_t val;
2668 2696
2669 val = (uint64_t)((obj->gtt_offset + size - 4096) & 2697 val = (uint64_t)((obj->gtt_offset + size - 4096) &
2670 0xfffff000) << 32; 2698 0xfffff000) << 32;
@@ -2673,12 +2701,16 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
2673 if (obj->tiling_mode == I915_TILING_Y) 2701 if (obj->tiling_mode == I915_TILING_Y)
2674 val |= 1 << I965_FENCE_TILING_Y_SHIFT; 2702 val |= 1 << I965_FENCE_TILING_Y_SHIFT;
2675 val |= I965_FENCE_REG_VALID; 2703 val |= I965_FENCE_REG_VALID;
2676 } else
2677 val = 0;
2678 2704
2679 fence_reg += reg * 8; 2705 I915_WRITE(fence_reg + 4, val >> 32);
2680 I915_WRITE64(fence_reg, val); 2706 POSTING_READ(fence_reg + 4);
2681 POSTING_READ(fence_reg); 2707
2708 I915_WRITE(fence_reg + 0, val);
2709 POSTING_READ(fence_reg);
2710 } else {
2711 I915_WRITE(fence_reg + 4, 0);
2712 POSTING_READ(fence_reg + 4);
2713 }
2682} 2714}
2683 2715
2684static void i915_write_fence_reg(struct drm_device *dev, int reg, 2716static 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,
2773 if (i915_gem_object_needs_mb(dev_priv->fence_regs[reg].obj)) 2805 if (i915_gem_object_needs_mb(dev_priv->fence_regs[reg].obj))
2774 mb(); 2806 mb();
2775 2807
2808 WARN(obj && (!obj->stride || !obj->tiling_mode),
2809 "bogus fence setup with stride: 0x%x, tiling mode: %i\n",
2810 obj->stride, obj->tiling_mode);
2811
2776 switch (INTEL_INFO(dev)->gen) { 2812 switch (INTEL_INFO(dev)->gen) {
2777 case 7: 2813 case 7:
2778 case 6: 2814 case 6:
@@ -2796,56 +2832,17 @@ static inline int fence_number(struct drm_i915_private *dev_priv,
2796 return fence - dev_priv->fence_regs; 2832 return fence - dev_priv->fence_regs;
2797} 2833}
2798 2834
2799struct write_fence {
2800 struct drm_device *dev;
2801 struct drm_i915_gem_object *obj;
2802 int fence;
2803};
2804
2805static void i915_gem_write_fence__ipi(void *data)
2806{
2807 struct write_fence *args = data;
2808
2809 /* Required for SNB+ with LLC */
2810 wbinvd();
2811
2812 /* Required for VLV */
2813 i915_gem_write_fence(args->dev, args->fence, args->obj);
2814}
2815
2816static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj, 2835static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
2817 struct drm_i915_fence_reg *fence, 2836 struct drm_i915_fence_reg *fence,
2818 bool enable) 2837 bool enable)
2819{ 2838{
2820 struct drm_i915_private *dev_priv = obj->base.dev->dev_private; 2839 struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
2821 struct write_fence args = { 2840 int reg = fence_number(dev_priv, fence);
2822 .dev = obj->base.dev, 2841
2823 .fence = fence_number(dev_priv, fence), 2842 i915_gem_write_fence(obj->base.dev, reg, enable ? obj : NULL);
2824 .obj = enable ? obj : NULL,
2825 };
2826
2827 /* In order to fully serialize access to the fenced region and
2828 * the update to the fence register we need to take extreme
2829 * measures on SNB+. In theory, the write to the fence register
2830 * flushes all memory transactions before, and coupled with the
2831 * mb() placed around the register write we serialise all memory
2832 * operations with respect to the changes in the tiler. Yet, on
2833 * SNB+ we need to take a step further and emit an explicit wbinvd()
2834 * on each processor in order to manually flush all memory
2835 * transactions before updating the fence register.
2836 *
2837 * However, Valleyview complicates matter. There the wbinvd is
2838 * insufficient and unlike SNB/IVB requires the serialising
2839 * register write. (Note that that register write by itself is
2840 * conversely not sufficient for SNB+.) To compromise, we do both.
2841 */
2842 if (INTEL_INFO(args.dev)->gen >= 6)
2843 on_each_cpu(i915_gem_write_fence__ipi, &args, 1);
2844 else
2845 i915_gem_write_fence(args.dev, args.fence, args.obj);
2846 2843
2847 if (enable) { 2844 if (enable) {
2848 obj->fence_reg = args.fence; 2845 obj->fence_reg = reg;
2849 fence->obj = obj; 2846 fence->obj = obj;
2850 list_move_tail(&fence->lru_list, &dev_priv->mm.fence_list); 2847 list_move_tail(&fence->lru_list, &dev_priv->mm.fence_list);
2851 } else { 2848 } else {
@@ -2853,6 +2850,7 @@ static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
2853 fence->obj = NULL; 2850 fence->obj = NULL;
2854 list_del_init(&fence->lru_list); 2851 list_del_init(&fence->lru_list);
2855 } 2852 }
2853 obj->fence_dirty = false;
2856} 2854}
2857 2855
2858static int 2856static int
@@ -2982,7 +2980,6 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
2982 return 0; 2980 return 0;
2983 2981
2984 i915_gem_object_update_fence(obj, reg, enable); 2982 i915_gem_object_update_fence(obj, reg, enable);
2985 obj->fence_dirty = false;
2986 2983
2987 return 0; 2984 return 0;
2988} 2985}
@@ -4611,7 +4608,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)
4611 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) 4608 list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list)
4612 if (obj->pages_pin_count == 0) 4609 if (obj->pages_pin_count == 0)
4613 cnt += obj->base.size >> PAGE_SHIFT; 4610 cnt += obj->base.size >> PAGE_SHIFT;
4614 list_for_each_entry(obj, &dev_priv->mm.inactive_list, global_list) 4611 list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list)
4615 if (obj->pin_count == 0 && obj->pages_pin_count == 0) 4612 if (obj->pin_count == 0 && obj->pages_pin_count == 0)
4616 cnt += obj->base.size >> PAGE_SHIFT; 4613 cnt += obj->base.size >> PAGE_SHIFT;
4617 4614
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 324211ac9c55..b042ee5c4070 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -301,7 +301,7 @@ static void intel_ddi_mode_set(struct drm_encoder *encoder,
301 struct intel_digital_port *intel_dig_port = 301 struct intel_digital_port *intel_dig_port =
302 enc_to_dig_port(encoder); 302 enc_to_dig_port(encoder);
303 303
304 intel_dp->DP = intel_dig_port->port_reversal | 304 intel_dp->DP = intel_dig_port->saved_port_bits |
305 DDI_BUF_CTL_ENABLE | DDI_BUF_EMP_400MV_0DB_HSW; 305 DDI_BUF_CTL_ENABLE | DDI_BUF_EMP_400MV_0DB_HSW;
306 intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count); 306 intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count);
307 307
@@ -1109,7 +1109,8 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
1109 * enabling the port. 1109 * enabling the port.
1110 */ 1110 */
1111 I915_WRITE(DDI_BUF_CTL(port), 1111 I915_WRITE(DDI_BUF_CTL(port),
1112 intel_dig_port->port_reversal | DDI_BUF_CTL_ENABLE); 1112 intel_dig_port->saved_port_bits |
1113 DDI_BUF_CTL_ENABLE);
1113 } else if (type == INTEL_OUTPUT_EDP) { 1114 } else if (type == INTEL_OUTPUT_EDP) {
1114 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 1115 struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
1115 1116
@@ -1347,8 +1348,9 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
1347 intel_encoder->get_config = intel_ddi_get_config; 1348 intel_encoder->get_config = intel_ddi_get_config;
1348 1349
1349 intel_dig_port->port = port; 1350 intel_dig_port->port = port;
1350 intel_dig_port->port_reversal = I915_READ(DDI_BUF_CTL(port)) & 1351 intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
1351 DDI_BUF_PORT_REVERSAL; 1352 (DDI_BUF_PORT_REVERSAL |
1353 DDI_A_4_LANES);
1352 intel_dig_port->dp.output_reg = DDI_BUF_CTL(port); 1354 intel_dig_port->dp.output_reg = DDI_BUF_CTL(port);
1353 1355
1354 intel_encoder->type = INTEL_OUTPUT_UNKNOWN; 1356 intel_encoder->type = INTEL_OUTPUT_UNKNOWN;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 85f3eb74d2b7..5fb305840db8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4913,22 +4913,19 @@ static void i9xx_get_pfit_config(struct intel_crtc *crtc,
4913 uint32_t tmp; 4913 uint32_t tmp;
4914 4914
4915 tmp = I915_READ(PFIT_CONTROL); 4915 tmp = I915_READ(PFIT_CONTROL);
4916 if (!(tmp & PFIT_ENABLE))
4917 return;
4916 4918
4919 /* Check whether the pfit is attached to our pipe. */
4917 if (INTEL_INFO(dev)->gen < 4) { 4920 if (INTEL_INFO(dev)->gen < 4) {
4918 if (crtc->pipe != PIPE_B) 4921 if (crtc->pipe != PIPE_B)
4919 return; 4922 return;
4920
4921 /* gen2/3 store dither state in pfit control, needs to match */
4922 pipe_config->gmch_pfit.control = tmp & PANEL_8TO6_DITHER_ENABLE;
4923 } else { 4923 } else {
4924 if ((tmp & PFIT_PIPE_MASK) != (crtc->pipe << PFIT_PIPE_SHIFT)) 4924 if ((tmp & PFIT_PIPE_MASK) != (crtc->pipe << PFIT_PIPE_SHIFT))
4925 return; 4925 return;
4926 } 4926 }
4927 4927
4928 if (!(tmp & PFIT_ENABLE)) 4928 pipe_config->gmch_pfit.control = tmp;
4929 return;
4930
4931 pipe_config->gmch_pfit.control = I915_READ(PFIT_CONTROL);
4932 pipe_config->gmch_pfit.pgm_ratios = I915_READ(PFIT_PGM_RATIOS); 4929 pipe_config->gmch_pfit.pgm_ratios = I915_READ(PFIT_PGM_RATIOS);
4933 if (INTEL_INFO(dev)->gen < 5) 4930 if (INTEL_INFO(dev)->gen < 5)
4934 pipe_config->gmch_pfit.lvds_border_bits = 4931 pipe_config->gmch_pfit.lvds_border_bits =
@@ -8317,6 +8314,8 @@ check_shared_dpll_state(struct drm_device *dev)
8317 pll->active, pll->refcount); 8314 pll->active, pll->refcount);
8318 WARN(pll->active && !pll->on, 8315 WARN(pll->active && !pll->on,
8319 "pll in active use but not on in sw tracking\n"); 8316 "pll in active use but not on in sw tracking\n");
8317 WARN(pll->on && !pll->active,
8318 "pll in on but not on in use in sw tracking\n");
8320 WARN(pll->on != active, 8319 WARN(pll->on != active,
8321 "pll on state mismatch (expected %i, found %i)\n", 8320 "pll on state mismatch (expected %i, found %i)\n",
8322 pll->on, active); 8321 pll->on, active);
@@ -8541,15 +8540,20 @@ static void intel_set_config_restore_state(struct drm_device *dev,
8541} 8540}
8542 8541
8543static bool 8542static bool
8544is_crtc_connector_off(struct drm_crtc *crtc, struct drm_connector *connectors, 8543is_crtc_connector_off(struct drm_mode_set *set)
8545 int num_connectors)
8546{ 8544{
8547 int i; 8545 int i;
8548 8546
8549 for (i = 0; i < num_connectors; i++) 8547 if (set->num_connectors == 0)
8550 if (connectors[i].encoder && 8548 return false;
8551 connectors[i].encoder->crtc == crtc && 8549
8552 connectors[i].dpms != DRM_MODE_DPMS_ON) 8550 if (WARN_ON(set->connectors == NULL))
8551 return false;
8552
8553 for (i = 0; i < set->num_connectors; i++)
8554 if (set->connectors[i]->encoder &&
8555 set->connectors[i]->encoder->crtc == set->crtc &&
8556 set->connectors[i]->dpms != DRM_MODE_DPMS_ON)
8553 return true; 8557 return true;
8554 8558
8555 return false; 8559 return false;
@@ -8562,10 +8566,8 @@ intel_set_config_compute_mode_changes(struct drm_mode_set *set,
8562 8566
8563 /* We should be able to check here if the fb has the same properties 8567 /* We should be able to check here if the fb has the same properties
8564 * and then just flip_or_move it */ 8568 * and then just flip_or_move it */
8565 if (set->connectors != NULL && 8569 if (is_crtc_connector_off(set)) {
8566 is_crtc_connector_off(set->crtc, *set->connectors, 8570 config->mode_changed = true;
8567 set->num_connectors)) {
8568 config->mode_changed = true;
8569 } else if (set->crtc->fb != set->fb) { 8571 } else if (set->crtc->fb != set->fb) {
8570 /* If we have no fb then treat it as a full mode set */ 8572 /* If we have no fb then treat it as a full mode set */
8571 if (set->crtc->fb == NULL) { 8573 if (set->crtc->fb == NULL) {
@@ -9398,6 +9400,17 @@ static void quirk_invert_brightness(struct drm_device *dev)
9398 DRM_INFO("applying inverted panel brightness quirk\n"); 9400 DRM_INFO("applying inverted panel brightness quirk\n");
9399} 9401}
9400 9402
9403/*
9404 * Some machines (Dell XPS13) suffer broken backlight controls if
9405 * BLM_PCH_PWM_ENABLE is set.
9406 */
9407static void quirk_no_pcm_pwm_enable(struct drm_device *dev)
9408{
9409 struct drm_i915_private *dev_priv = dev->dev_private;
9410 dev_priv->quirks |= QUIRK_NO_PCH_PWM_ENABLE;
9411 DRM_INFO("applying no-PCH_PWM_ENABLE quirk\n");
9412}
9413
9401struct intel_quirk { 9414struct intel_quirk {
9402 int device; 9415 int device;
9403 int subsystem_vendor; 9416 int subsystem_vendor;
@@ -9467,6 +9480,11 @@ static struct intel_quirk intel_quirks[] = {
9467 9480
9468 /* Acer Aspire 4736Z */ 9481 /* Acer Aspire 4736Z */
9469 { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness }, 9482 { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
9483
9484 /* Dell XPS13 HD Sandy Bridge */
9485 { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable },
9486 /* Dell XPS13 HD and XPS13 FHD Ivy Bridge */
9487 { 0x0166, 0x1028, 0x058b, quirk_no_pcm_pwm_enable },
9470}; 9488};
9471 9489
9472static void intel_init_quirks(struct drm_device *dev) 9490static void intel_init_quirks(struct drm_device *dev)
@@ -9817,8 +9835,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
9817 } 9835 }
9818 pll->refcount = pll->active; 9836 pll->refcount = pll->active;
9819 9837
9820 DRM_DEBUG_KMS("%s hw state readout: refcount %i\n", 9838 DRM_DEBUG_KMS("%s hw state readout: refcount %i, on %i\n",
9821 pll->name, pll->refcount); 9839 pll->name, pll->refcount, pll->on);
9822 } 9840 }
9823 9841
9824 list_for_each_entry(encoder, &dev->mode_config.encoder_list, 9842 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
@@ -9869,6 +9887,7 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
9869 struct drm_plane *plane; 9887 struct drm_plane *plane;
9870 struct intel_crtc *crtc; 9888 struct intel_crtc *crtc;
9871 struct intel_encoder *encoder; 9889 struct intel_encoder *encoder;
9890 int i;
9872 9891
9873 intel_modeset_readout_hw_state(dev); 9892 intel_modeset_readout_hw_state(dev);
9874 9893
@@ -9884,6 +9903,18 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
9884 intel_dump_pipe_config(crtc, &crtc->config, "[setup_hw_state]"); 9903 intel_dump_pipe_config(crtc, &crtc->config, "[setup_hw_state]");
9885 } 9904 }
9886 9905
9906 for (i = 0; i < dev_priv->num_shared_dpll; i++) {
9907 struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
9908
9909 if (!pll->on || pll->active)
9910 continue;
9911
9912 DRM_DEBUG_KMS("%s enabled but not in use, disabling\n", pll->name);
9913
9914 pll->disable(dev_priv, pll);
9915 pll->on = false;
9916 }
9917
9887 if (force_restore) { 9918 if (force_restore) {
9888 /* 9919 /*
9889 * We need to use raw interfaces for restoring state to avoid 9920 * We need to use raw interfaces for restoring state to avoid
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index b73971234013..26e162bb3a51 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -75,7 +75,12 @@ intel_dp_max_link_bw(struct intel_dp *intel_dp)
75 case DP_LINK_BW_1_62: 75 case DP_LINK_BW_1_62:
76 case DP_LINK_BW_2_7: 76 case DP_LINK_BW_2_7:
77 break; 77 break;
78 case DP_LINK_BW_5_4: /* 1.2 capable displays may advertise higher bw */
79 max_link_bw = DP_LINK_BW_2_7;
80 break;
78 default: 81 default:
82 WARN(1, "invalid max DP link bw val %x, using 1.62Gbps\n",
83 max_link_bw);
79 max_link_bw = DP_LINK_BW_1_62; 84 max_link_bw = DP_LINK_BW_1_62;
80 break; 85 break;
81 } 86 }
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index c8c9b6f48230..b7d6e09456ce 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -504,7 +504,7 @@ struct intel_dp {
504struct intel_digital_port { 504struct intel_digital_port {
505 struct intel_encoder base; 505 struct intel_encoder base;
506 enum port port; 506 enum port port;
507 u32 port_reversal; 507 u32 saved_port_bits;
508 struct intel_dp dp; 508 struct intel_dp dp;
509 struct intel_hdmi hdmi; 509 struct intel_hdmi hdmi;
510}; 510};
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 98df2a0c85bd..2fd3fd5b943e 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -785,10 +785,22 @@ static void intel_disable_hdmi(struct intel_encoder *encoder)
785 } 785 }
786} 786}
787 787
788static int hdmi_portclock_limit(struct intel_hdmi *hdmi)
789{
790 struct drm_device *dev = intel_hdmi_to_dev(hdmi);
791
792 if (IS_G4X(dev))
793 return 165000;
794 else if (IS_HASWELL(dev))
795 return 300000;
796 else
797 return 225000;
798}
799
788static int intel_hdmi_mode_valid(struct drm_connector *connector, 800static int intel_hdmi_mode_valid(struct drm_connector *connector,
789 struct drm_display_mode *mode) 801 struct drm_display_mode *mode)
790{ 802{
791 if (mode->clock > 165000) 803 if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector)))
792 return MODE_CLOCK_HIGH; 804 return MODE_CLOCK_HIGH;
793 if (mode->clock < 20000) 805 if (mode->clock < 20000)
794 return MODE_CLOCK_LOW; 806 return MODE_CLOCK_LOW;
@@ -806,6 +818,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
806 struct drm_device *dev = encoder->base.dev; 818 struct drm_device *dev = encoder->base.dev;
807 struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; 819 struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
808 int clock_12bpc = pipe_config->requested_mode.clock * 3 / 2; 820 int clock_12bpc = pipe_config->requested_mode.clock * 3 / 2;
821 int portclock_limit = hdmi_portclock_limit(intel_hdmi);
809 int desired_bpp; 822 int desired_bpp;
810 823
811 if (intel_hdmi->color_range_auto) { 824 if (intel_hdmi->color_range_auto) {
@@ -829,7 +842,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
829 * outputs. We also need to check that the higher clock still fits 842 * outputs. We also need to check that the higher clock still fits
830 * within limits. 843 * within limits.
831 */ 844 */
832 if (pipe_config->pipe_bpp > 8*3 && clock_12bpc <= 225000 845 if (pipe_config->pipe_bpp > 8*3 && clock_12bpc <= portclock_limit
833 && HAS_PCH_SPLIT(dev)) { 846 && HAS_PCH_SPLIT(dev)) {
834 DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n"); 847 DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n");
835 desired_bpp = 12*3; 848 desired_bpp = 12*3;
@@ -846,7 +859,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
846 pipe_config->pipe_bpp = desired_bpp; 859 pipe_config->pipe_bpp = desired_bpp;
847 } 860 }
848 861
849 if (adjusted_mode->clock > 225000) { 862 if (adjusted_mode->clock > portclock_limit) {
850 DRM_DEBUG_KMS("too high HDMI clock, rejecting mode\n"); 863 DRM_DEBUG_KMS("too high HDMI clock, rejecting mode\n");
851 return false; 864 return false;
852 } 865 }
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 021e8daa022d..61348eae2f04 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -109,6 +109,13 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
109 flags |= DRM_MODE_FLAG_PVSYNC; 109 flags |= DRM_MODE_FLAG_PVSYNC;
110 110
111 pipe_config->adjusted_mode.flags |= flags; 111 pipe_config->adjusted_mode.flags |= flags;
112
113 /* gen2/3 store dither state in pfit control, needs to match */
114 if (INTEL_INFO(dev)->gen < 4) {
115 tmp = I915_READ(PFIT_CONTROL);
116
117 pipe_config->gmch_pfit.control |= tmp & PANEL_8TO6_DITHER_ENABLE;
118 }
112} 119}
113 120
114/* The LVDS pin pair needs to be on before the DPLLs are enabled. 121/* 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,
290 297
291 intel_pch_panel_fitting(intel_crtc, pipe_config, 298 intel_pch_panel_fitting(intel_crtc, pipe_config,
292 intel_connector->panel.fitting_mode); 299 intel_connector->panel.fitting_mode);
293 return true;
294 } else { 300 } else {
295 intel_gmch_panel_fitting(intel_crtc, pipe_config, 301 intel_gmch_panel_fitting(intel_crtc, pipe_config,
296 intel_connector->panel.fitting_mode); 302 intel_connector->panel.fitting_mode);
297 }
298 303
299 drm_mode_set_crtcinfo(adjusted_mode, 0); 304 }
300 pipe_config->timings_set = true;
301 305
302 /* 306 /*
303 * XXX: It would be nice to support lower refresh rates on the 307 * XXX: It would be nice to support lower refresh rates on the
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 80bea1d3209f..67e2c1f1c9a8 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -194,6 +194,9 @@ void intel_gmch_panel_fitting(struct intel_crtc *intel_crtc,
194 adjusted_mode->vdisplay == mode->vdisplay) 194 adjusted_mode->vdisplay == mode->vdisplay)
195 goto out; 195 goto out;
196 196
197 drm_mode_set_crtcinfo(adjusted_mode, 0);
198 pipe_config->timings_set = true;
199
197 switch (fitting_mode) { 200 switch (fitting_mode) {
198 case DRM_MODE_SCALE_CENTER: 201 case DRM_MODE_SCALE_CENTER:
199 /* 202 /*
@@ -580,7 +583,8 @@ void intel_panel_enable_backlight(struct drm_device *dev,
580 POSTING_READ(reg); 583 POSTING_READ(reg);
581 I915_WRITE(reg, tmp | BLM_PWM_ENABLE); 584 I915_WRITE(reg, tmp | BLM_PWM_ENABLE);
582 585
583 if (HAS_PCH_SPLIT(dev)) { 586 if (HAS_PCH_SPLIT(dev) &&
587 !(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) {
584 tmp = I915_READ(BLC_PWM_PCH_CTL1); 588 tmp = I915_READ(BLC_PWM_PCH_CTL1);
585 tmp |= BLM_PCH_PWM_ENABLE; 589 tmp |= BLM_PCH_PWM_ENABLE;
586 tmp &= ~BLM_PCH_OVERRIDE_ENABLE; 590 tmp &= ~BLM_PCH_OVERRIDE_ENABLE;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index ccbdd83f5220..51a2a60f5bfc 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -5476,7 +5476,7 @@ static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
5476 gen6_gt_check_fifodbg(dev_priv); 5476 gen6_gt_check_fifodbg(dev_priv);
5477} 5477}
5478 5478
5479void intel_gt_reset(struct drm_device *dev) 5479void intel_gt_sanitize(struct drm_device *dev)
5480{ 5480{
5481 struct drm_i915_private *dev_priv = dev->dev_private; 5481 struct drm_i915_private *dev_priv = dev->dev_private;
5482 5482
@@ -5487,22 +5487,51 @@ void intel_gt_reset(struct drm_device *dev)
5487 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) 5487 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
5488 __gen6_gt_force_wake_mt_reset(dev_priv); 5488 __gen6_gt_force_wake_mt_reset(dev_priv);
5489 } 5489 }
5490
5491 /* BIOS often leaves RC6 enabled, but disable it for hw init */
5492 if (INTEL_INFO(dev)->gen >= 6)
5493 intel_disable_gt_powersave(dev);
5490} 5494}
5491 5495
5492void intel_gt_init(struct drm_device *dev) 5496void intel_gt_init(struct drm_device *dev)
5493{ 5497{
5494 struct drm_i915_private *dev_priv = dev->dev_private; 5498 struct drm_i915_private *dev_priv = dev->dev_private;
5495 5499
5496 spin_lock_init(&dev_priv->gt_lock);
5497
5498 intel_gt_reset(dev);
5499
5500 if (IS_VALLEYVIEW(dev)) { 5500 if (IS_VALLEYVIEW(dev)) {
5501 dev_priv->gt.force_wake_get = vlv_force_wake_get; 5501 dev_priv->gt.force_wake_get = vlv_force_wake_get;
5502 dev_priv->gt.force_wake_put = vlv_force_wake_put; 5502 dev_priv->gt.force_wake_put = vlv_force_wake_put;
5503 } else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) { 5503 } else if (IS_HASWELL(dev)) {
5504 dev_priv->gt.force_wake_get = __gen6_gt_force_wake_mt_get; 5504 dev_priv->gt.force_wake_get = __gen6_gt_force_wake_mt_get;
5505 dev_priv->gt.force_wake_put = __gen6_gt_force_wake_mt_put; 5505 dev_priv->gt.force_wake_put = __gen6_gt_force_wake_mt_put;
5506 } else if (IS_IVYBRIDGE(dev)) {
5507 u32 ecobus;
5508
5509 /* IVB configs may use multi-threaded forcewake */
5510
5511 /* A small trick here - if the bios hasn't configured
5512 * MT forcewake, and if the device is in RC6, then
5513 * force_wake_mt_get will not wake the device and the
5514 * ECOBUS read will return zero. Which will be
5515 * (correctly) interpreted by the test below as MT
5516 * forcewake being disabled.
5517 */
5518 mutex_lock(&dev->struct_mutex);
5519 __gen6_gt_force_wake_mt_get(dev_priv);
5520 ecobus = I915_READ_NOTRACE(ECOBUS);
5521 __gen6_gt_force_wake_mt_put(dev_priv);
5522 mutex_unlock(&dev->struct_mutex);
5523
5524 if (ecobus & FORCEWAKE_MT_ENABLE) {
5525 dev_priv->gt.force_wake_get =
5526 __gen6_gt_force_wake_mt_get;
5527 dev_priv->gt.force_wake_put =
5528 __gen6_gt_force_wake_mt_put;
5529 } else {
5530 DRM_INFO("No MT forcewake available on Ivybridge, this can result in issues\n");
5531 DRM_INFO("when using vblank-synced partial screen updates.\n");
5532 dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get;
5533 dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put;
5534 }
5506 } else if (IS_GEN6(dev)) { 5535 } else if (IS_GEN6(dev)) {
5507 dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get; 5536 dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get;
5508 dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put; 5537 dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index e51ab552046c..664118d8c1d6 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -379,6 +379,17 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring)
379 return I915_READ(acthd_reg); 379 return I915_READ(acthd_reg);
380} 380}
381 381
382static void ring_setup_phys_status_page(struct intel_ring_buffer *ring)
383{
384 struct drm_i915_private *dev_priv = ring->dev->dev_private;
385 u32 addr;
386
387 addr = dev_priv->status_page_dmah->busaddr;
388 if (INTEL_INFO(ring->dev)->gen >= 4)
389 addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0;
390 I915_WRITE(HWS_PGA, addr);
391}
392
382static int init_ring_common(struct intel_ring_buffer *ring) 393static int init_ring_common(struct intel_ring_buffer *ring)
383{ 394{
384 struct drm_device *dev = ring->dev; 395 struct drm_device *dev = ring->dev;
@@ -390,6 +401,11 @@ static int init_ring_common(struct intel_ring_buffer *ring)
390 if (HAS_FORCE_WAKE(dev)) 401 if (HAS_FORCE_WAKE(dev))
391 gen6_gt_force_wake_get(dev_priv); 402 gen6_gt_force_wake_get(dev_priv);
392 403
404 if (I915_NEED_GFX_HWS(dev))
405 intel_ring_setup_status_page(ring);
406 else
407 ring_setup_phys_status_page(ring);
408
393 /* Stop the ring if it's running. */ 409 /* Stop the ring if it's running. */
394 I915_WRITE_CTL(ring, 0); 410 I915_WRITE_CTL(ring, 0);
395 I915_WRITE_HEAD(ring, 0); 411 I915_WRITE_HEAD(ring, 0);
@@ -518,9 +534,6 @@ cleanup_pipe_control(struct intel_ring_buffer *ring)
518 struct pipe_control *pc = ring->private; 534 struct pipe_control *pc = ring->private;
519 struct drm_i915_gem_object *obj; 535 struct drm_i915_gem_object *obj;
520 536
521 if (!ring->private)
522 return;
523
524 obj = pc->obj; 537 obj = pc->obj;
525 538
526 kunmap(sg_page(obj->pages->sgl)); 539 kunmap(sg_page(obj->pages->sgl));
@@ -528,7 +541,6 @@ cleanup_pipe_control(struct intel_ring_buffer *ring)
528 drm_gem_object_unreference(&obj->base); 541 drm_gem_object_unreference(&obj->base);
529 542
530 kfree(pc); 543 kfree(pc);
531 ring->private = NULL;
532} 544}
533 545
534static int init_render_ring(struct intel_ring_buffer *ring) 546static int init_render_ring(struct intel_ring_buffer *ring)
@@ -601,7 +613,10 @@ static void render_ring_cleanup(struct intel_ring_buffer *ring)
601 if (HAS_BROKEN_CS_TLB(dev)) 613 if (HAS_BROKEN_CS_TLB(dev))
602 drm_gem_object_unreference(to_gem_object(ring->private)); 614 drm_gem_object_unreference(to_gem_object(ring->private));
603 615
604 cleanup_pipe_control(ring); 616 if (INTEL_INFO(dev)->gen >= 5)
617 cleanup_pipe_control(ring);
618
619 ring->private = NULL;
605} 620}
606 621
607static void 622static void
@@ -1223,7 +1238,6 @@ static int init_status_page(struct intel_ring_buffer *ring)
1223 ring->status_page.obj = obj; 1238 ring->status_page.obj = obj;
1224 memset(ring->status_page.page_addr, 0, PAGE_SIZE); 1239 memset(ring->status_page.page_addr, 0, PAGE_SIZE);
1225 1240
1226 intel_ring_setup_status_page(ring);
1227 DRM_DEBUG_DRIVER("%s hws offset: 0x%08x\n", 1241 DRM_DEBUG_DRIVER("%s hws offset: 0x%08x\n",
1228 ring->name, ring->status_page.gfx_addr); 1242 ring->name, ring->status_page.gfx_addr);
1229 1243
@@ -1237,10 +1251,9 @@ err:
1237 return ret; 1251 return ret;
1238} 1252}
1239 1253
1240static int init_phys_hws_pga(struct intel_ring_buffer *ring) 1254static int init_phys_status_page(struct intel_ring_buffer *ring)
1241{ 1255{
1242 struct drm_i915_private *dev_priv = ring->dev->dev_private; 1256 struct drm_i915_private *dev_priv = ring->dev->dev_private;
1243 u32 addr;
1244 1257
1245 if (!dev_priv->status_page_dmah) { 1258 if (!dev_priv->status_page_dmah) {
1246 dev_priv->status_page_dmah = 1259 dev_priv->status_page_dmah =
@@ -1249,11 +1262,6 @@ static int init_phys_hws_pga(struct intel_ring_buffer *ring)
1249 return -ENOMEM; 1262 return -ENOMEM;
1250 } 1263 }
1251 1264
1252 addr = dev_priv->status_page_dmah->busaddr;
1253 if (INTEL_INFO(ring->dev)->gen >= 4)
1254 addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0;
1255 I915_WRITE(HWS_PGA, addr);
1256
1257 ring->status_page.page_addr = dev_priv->status_page_dmah->vaddr; 1265 ring->status_page.page_addr = dev_priv->status_page_dmah->vaddr;
1258 memset(ring->status_page.page_addr, 0, PAGE_SIZE); 1266 memset(ring->status_page.page_addr, 0, PAGE_SIZE);
1259 1267
@@ -1281,7 +1289,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
1281 return ret; 1289 return ret;
1282 } else { 1290 } else {
1283 BUG_ON(ring->id != RCS); 1291 BUG_ON(ring->id != RCS);
1284 ret = init_phys_hws_pga(ring); 1292 ret = init_phys_status_page(ring);
1285 if (ret) 1293 if (ret)
1286 return ret; 1294 return ret;
1287 } 1295 }
@@ -1893,7 +1901,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
1893 } 1901 }
1894 1902
1895 if (!I915_NEED_GFX_HWS(dev)) { 1903 if (!I915_NEED_GFX_HWS(dev)) {
1896 ret = init_phys_hws_pga(ring); 1904 ret = init_phys_status_page(ring);
1897 if (ret) 1905 if (ret)
1898 return ret; 1906 return ret;
1899 } 1907 }
diff --git a/drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c
index 262c9f5f5f60..ce860de43e61 100644
--- a/drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c
@@ -90,6 +90,7 @@ nvc0_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
90 return ret; 90 return ret;
91 91
92 nv_subdev(priv)->unit = 0x00008000; 92 nv_subdev(priv)->unit = 0x00008000;
93 nv_subdev(priv)->intr = nouveau_falcon_intr;
93 nv_engine(priv)->cclass = &nvc0_bsp_cclass; 94 nv_engine(priv)->cclass = &nvc0_bsp_cclass;
94 nv_engine(priv)->sclass = nvc0_bsp_sclass; 95 nv_engine(priv)->sclass = nvc0_bsp_sclass;
95 return 0; 96 return 0;
diff --git a/drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c b/drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c
index c46882c83982..ba6aeca0285e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c
@@ -90,6 +90,7 @@ nve0_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
90 return ret; 90 return ret;
91 91
92 nv_subdev(priv)->unit = 0x00008000; 92 nv_subdev(priv)->unit = 0x00008000;
93 nv_subdev(priv)->intr = nouveau_falcon_intr;
93 nv_engine(priv)->cclass = &nve0_bsp_cclass; 94 nv_engine(priv)->cclass = &nve0_bsp_cclass;
94 nv_engine(priv)->sclass = nve0_bsp_sclass; 95 nv_engine(priv)->sclass = nve0_bsp_sclass;
95 return 0; 96 return 0;
diff --git a/drivers/gpu/drm/nouveau/core/engine/falcon.c b/drivers/gpu/drm/nouveau/core/engine/falcon.c
index 3c7a31f7590e..e03fc8e4dc1d 100644
--- a/drivers/gpu/drm/nouveau/core/engine/falcon.c
+++ b/drivers/gpu/drm/nouveau/core/engine/falcon.c
@@ -23,6 +23,25 @@
23#include <engine/falcon.h> 23#include <engine/falcon.h>
24#include <subdev/timer.h> 24#include <subdev/timer.h>
25 25
26void
27nouveau_falcon_intr(struct nouveau_subdev *subdev)
28{
29 struct nouveau_falcon *falcon = (void *)subdev;
30 u32 dispatch = nv_ro32(falcon, 0x01c);
31 u32 intr = nv_ro32(falcon, 0x008) & dispatch & ~(dispatch >> 16);
32
33 if (intr & 0x00000010) {
34 nv_debug(falcon, "ucode halted\n");
35 nv_wo32(falcon, 0x004, 0x00000010);
36 intr &= ~0x00000010;
37 }
38
39 if (intr) {
40 nv_error(falcon, "unhandled intr 0x%08x\n", intr);
41 nv_wo32(falcon, 0x004, intr);
42 }
43}
44
26u32 45u32
27_nouveau_falcon_rd32(struct nouveau_object *object, u64 addr) 46_nouveau_falcon_rd32(struct nouveau_object *object, u64 addr)
28{ 47{
diff --git a/drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c
index 98072c1ff360..73719aaa62d6 100644
--- a/drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c
@@ -90,6 +90,7 @@ nvc0_ppp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
90 return ret; 90 return ret;
91 91
92 nv_subdev(priv)->unit = 0x00000002; 92 nv_subdev(priv)->unit = 0x00000002;
93 nv_subdev(priv)->intr = nouveau_falcon_intr;
93 nv_engine(priv)->cclass = &nvc0_ppp_cclass; 94 nv_engine(priv)->cclass = &nvc0_ppp_cclass;
94 nv_engine(priv)->sclass = nvc0_ppp_sclass; 95 nv_engine(priv)->sclass = nvc0_ppp_sclass;
95 return 0; 96 return 0;
diff --git a/drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c
index 1879229b60eb..ac1f62aace72 100644
--- a/drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c
@@ -90,6 +90,7 @@ nvc0_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
90 return ret; 90 return ret;
91 91
92 nv_subdev(priv)->unit = 0x00020000; 92 nv_subdev(priv)->unit = 0x00020000;
93 nv_subdev(priv)->intr = nouveau_falcon_intr;
93 nv_engine(priv)->cclass = &nvc0_vp_cclass; 94 nv_engine(priv)->cclass = &nvc0_vp_cclass;
94 nv_engine(priv)->sclass = nvc0_vp_sclass; 95 nv_engine(priv)->sclass = nvc0_vp_sclass;
95 return 0; 96 return 0;
diff --git a/drivers/gpu/drm/nouveau/core/engine/vp/nve0.c b/drivers/gpu/drm/nouveau/core/engine/vp/nve0.c
index d28ecbf7bc49..d4c3108479c9 100644
--- a/drivers/gpu/drm/nouveau/core/engine/vp/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/vp/nve0.c
@@ -90,6 +90,7 @@ nve0_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
90 return ret; 90 return ret;
91 91
92 nv_subdev(priv)->unit = 0x00020000; 92 nv_subdev(priv)->unit = 0x00020000;
93 nv_subdev(priv)->intr = nouveau_falcon_intr;
93 nv_engine(priv)->cclass = &nve0_vp_cclass; 94 nv_engine(priv)->cclass = &nve0_vp_cclass;
94 nv_engine(priv)->sclass = nve0_vp_sclass; 95 nv_engine(priv)->sclass = nve0_vp_sclass;
95 return 0; 96 return 0;
diff --git a/drivers/gpu/drm/nouveau/core/include/engine/falcon.h b/drivers/gpu/drm/nouveau/core/include/engine/falcon.h
index 1edec386ab36..181aa7da524d 100644
--- a/drivers/gpu/drm/nouveau/core/include/engine/falcon.h
+++ b/drivers/gpu/drm/nouveau/core/include/engine/falcon.h
@@ -72,6 +72,8 @@ int nouveau_falcon_create_(struct nouveau_object *, struct nouveau_object *,
72 struct nouveau_oclass *, u32, bool, const char *, 72 struct nouveau_oclass *, u32, bool, const char *,
73 const char *, int, void **); 73 const char *, int, void **);
74 74
75void nouveau_falcon_intr(struct nouveau_subdev *subdev);
76
75#define _nouveau_falcon_dtor _nouveau_engine_dtor 77#define _nouveau_falcon_dtor _nouveau_engine_dtor
76int _nouveau_falcon_init(struct nouveau_object *); 78int _nouveau_falcon_init(struct nouveau_object *);
77int _nouveau_falcon_fini(struct nouveau_object *, bool); 79int _nouveau_falcon_fini(struct nouveau_object *, bool);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 4b1afb131380..4e7ee5f4155c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -148,6 +148,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
148 148
149 if (unlikely(nvbo->gem)) 149 if (unlikely(nvbo->gem))
150 DRM_ERROR("bo %p still attached to GEM object\n", bo); 150 DRM_ERROR("bo %p still attached to GEM object\n", bo);
151 WARN_ON(nvbo->pin_refcnt > 0);
151 nv10_bo_put_tile_region(dev, nvbo->tile, NULL); 152 nv10_bo_put_tile_region(dev, nvbo->tile, NULL);
152 kfree(nvbo); 153 kfree(nvbo);
153} 154}
@@ -197,6 +198,12 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
197 size_t acc_size; 198 size_t acc_size;
198 int ret; 199 int ret;
199 int type = ttm_bo_type_device; 200 int type = ttm_bo_type_device;
201 int max_size = INT_MAX & ~((1 << drm->client.base.vm->vmm->lpg_shift) - 1);
202
203 if (size <= 0 || size > max_size) {
204 nv_warn(drm, "skipped size %x\n", (u32)size);
205 return -EINVAL;
206 }
200 207
201 if (sg) 208 if (sg)
202 type = ttm_bo_type_sg; 209 type = ttm_bo_type_sg;
@@ -340,13 +347,15 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
340{ 347{
341 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); 348 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
342 struct ttm_buffer_object *bo = &nvbo->bo; 349 struct ttm_buffer_object *bo = &nvbo->bo;
343 int ret; 350 int ret, ref;
344 351
345 ret = ttm_bo_reserve(bo, false, false, false, 0); 352 ret = ttm_bo_reserve(bo, false, false, false, 0);
346 if (ret) 353 if (ret)
347 return ret; 354 return ret;
348 355
349 if (--nvbo->pin_refcnt) 356 ref = --nvbo->pin_refcnt;
357 WARN_ON_ONCE(ref < 0);
358 if (ref)
350 goto out; 359 goto out;
351 360
352 nouveau_bo_placement_set(nvbo, bo->mem.placement, 0); 361 nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);
@@ -578,7 +587,7 @@ nve0_bo_move_init(struct nouveau_channel *chan, u32 handle)
578 int ret = RING_SPACE(chan, 2); 587 int ret = RING_SPACE(chan, 2);
579 if (ret == 0) { 588 if (ret == 0) {
580 BEGIN_NVC0(chan, NvSubCopy, 0x0000, 1); 589 BEGIN_NVC0(chan, NvSubCopy, 0x0000, 1);
581 OUT_RING (chan, handle); 590 OUT_RING (chan, handle & 0x0000ffff);
582 FIRE_RING (chan); 591 FIRE_RING (chan);
583 } 592 }
584 return ret; 593 return ret;
@@ -973,7 +982,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
973 struct ttm_mem_reg *old_mem = &bo->mem; 982 struct ttm_mem_reg *old_mem = &bo->mem;
974 int ret; 983 int ret;
975 984
976 mutex_lock(&chan->cli->mutex); 985 mutex_lock_nested(&chan->cli->mutex, SINGLE_DEPTH_NESTING);
977 986
978 /* create temporary vmas for the transfer and attach them to the 987 /* create temporary vmas for the transfer and attach them to the
979 * old nouveau_mem node, these will get cleaned up after ttm has 988 * old nouveau_mem node, these will get cleaned up after ttm has
@@ -1014,7 +1023,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
1014 struct ttm_mem_reg *, struct ttm_mem_reg *); 1023 struct ttm_mem_reg *, struct ttm_mem_reg *);
1015 int (*init)(struct nouveau_channel *, u32 handle); 1024 int (*init)(struct nouveau_channel *, u32 handle);
1016 } _methods[] = { 1025 } _methods[] = {
1017 { "COPY", 0, 0xa0b5, nve0_bo_move_copy, nve0_bo_move_init }, 1026 { "COPY", 4, 0xa0b5, nve0_bo_move_copy, nve0_bo_move_init },
1018 { "GRCE", 0, 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init }, 1027 { "GRCE", 0, 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init },
1019 { "COPY1", 5, 0x90b8, nvc0_bo_move_copy, nvc0_bo_move_init }, 1028 { "COPY1", 5, 0x90b8, nvc0_bo_move_copy, nvc0_bo_move_init },
1020 { "COPY0", 4, 0x90b5, nvc0_bo_move_copy, nvc0_bo_move_init }, 1029 { "COPY0", 4, 0x90b5, nvc0_bo_move_copy, nvc0_bo_move_init },
@@ -1034,7 +1043,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
1034 struct nouveau_channel *chan; 1043 struct nouveau_channel *chan;
1035 u32 handle = (mthd->engine << 16) | mthd->oclass; 1044 u32 handle = (mthd->engine << 16) | mthd->oclass;
1036 1045
1037 if (mthd->init == nve0_bo_move_init) 1046 if (mthd->engine)
1038 chan = drm->cechan; 1047 chan = drm->cechan;
1039 else 1048 else
1040 chan = drm->channel; 1049 chan = drm->channel;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 708b2d1c0037..907d20ef6d4d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -138,7 +138,7 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
138{ 138{
139 struct nouveau_framebuffer *nouveau_fb; 139 struct nouveau_framebuffer *nouveau_fb;
140 struct drm_gem_object *gem; 140 struct drm_gem_object *gem;
141 int ret; 141 int ret = -ENOMEM;
142 142
143 gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]); 143 gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
144 if (!gem) 144 if (!gem)
@@ -146,15 +146,19 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
146 146
147 nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL); 147 nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL);
148 if (!nouveau_fb) 148 if (!nouveau_fb)
149 return ERR_PTR(-ENOMEM); 149 goto err_unref;
150 150
151 ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem)); 151 ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem));
152 if (ret) { 152 if (ret)
153 drm_gem_object_unreference(gem); 153 goto err;
154 return ERR_PTR(ret);
155 }
156 154
157 return &nouveau_fb->base; 155 return &nouveau_fb->base;
156
157err:
158 kfree(nouveau_fb);
159err_unref:
160 drm_gem_object_unreference(gem);
161 return ERR_PTR(ret);
158} 162}
159 163
160static const struct drm_mode_config_funcs nouveau_mode_config_funcs = { 164static 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,
524 struct nouveau_page_flip_state *s; 528 struct nouveau_page_flip_state *s;
525 struct nouveau_channel *chan = NULL; 529 struct nouveau_channel *chan = NULL;
526 struct nouveau_fence *fence; 530 struct nouveau_fence *fence;
527 struct list_head res; 531 struct ttm_validate_buffer resv[2] = {
528 struct ttm_validate_buffer res_val[2]; 532 { .bo = &old_bo->bo },
533 { .bo = &new_bo->bo },
534 };
529 struct ww_acquire_ctx ticket; 535 struct ww_acquire_ctx ticket;
536 LIST_HEAD(res);
530 int ret; 537 int ret;
531 538
532 if (!drm->channel) 539 if (!drm->channel)
@@ -545,27 +552,19 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
545 chan = drm->channel; 552 chan = drm->channel;
546 spin_unlock(&old_bo->bo.bdev->fence_lock); 553 spin_unlock(&old_bo->bo.bdev->fence_lock);
547 554
548 mutex_lock(&chan->cli->mutex);
549
550 if (new_bo != old_bo) { 555 if (new_bo != old_bo) {
551 ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM); 556 ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
552 if (likely(!ret)) { 557 if (ret)
553 res_val[0].bo = &old_bo->bo; 558 goto fail_free;
554 res_val[1].bo = &new_bo->bo;
555 INIT_LIST_HEAD(&res);
556 list_add_tail(&res_val[0].head, &res);
557 list_add_tail(&res_val[1].head, &res);
558 ret = ttm_eu_reserve_buffers(&ticket, &res);
559 if (ret)
560 nouveau_bo_unpin(new_bo);
561 }
562 } else
563 ret = ttm_bo_reserve(&new_bo->bo, false, false, false, 0);
564 559
565 if (ret) { 560 list_add(&resv[1].head, &res);
566 mutex_unlock(&chan->cli->mutex);
567 goto fail_free;
568 } 561 }
562 list_add(&resv[0].head, &res);
563
564 mutex_lock(&chan->cli->mutex);
565 ret = ttm_eu_reserve_buffers(&ticket, &res);
566 if (ret)
567 goto fail_unpin;
569 568
570 /* Initialize a page flip struct */ 569 /* Initialize a page flip struct */
571 *s = (struct nouveau_page_flip_state) 570 *s = (struct nouveau_page_flip_state)
@@ -576,10 +575,8 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
576 /* Emit a page flip */ 575 /* Emit a page flip */
577 if (nv_device(drm->device)->card_type >= NV_50) { 576 if (nv_device(drm->device)->card_type >= NV_50) {
578 ret = nv50_display_flip_next(crtc, fb, chan, 0); 577 ret = nv50_display_flip_next(crtc, fb, chan, 0);
579 if (ret) { 578 if (ret)
580 mutex_unlock(&chan->cli->mutex);
581 goto fail_unreserve; 579 goto fail_unreserve;
582 }
583 } 580 }
584 581
585 ret = nouveau_page_flip_emit(chan, old_bo, new_bo, s, &fence); 582 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,
590 /* Update the crtc struct and cleanup */ 587 /* Update the crtc struct and cleanup */
591 crtc->fb = fb; 588 crtc->fb = fb;
592 589
593 if (old_bo != new_bo) { 590 ttm_eu_fence_buffer_objects(&ticket, &res, fence);
594 ttm_eu_fence_buffer_objects(&ticket, &res, fence); 591 if (old_bo != new_bo)
595 nouveau_bo_unpin(old_bo); 592 nouveau_bo_unpin(old_bo);
596 } else {
597 nouveau_bo_fence(new_bo, fence);
598 ttm_bo_unreserve(&new_bo->bo);
599 }
600 nouveau_fence_unref(&fence); 593 nouveau_fence_unref(&fence);
601 return 0; 594 return 0;
602 595
603fail_unreserve: 596fail_unreserve:
604 if (old_bo != new_bo) { 597 ttm_eu_backoff_reservation(&ticket, &res);
605 ttm_eu_backoff_reservation(&ticket, &res); 598fail_unpin:
599 mutex_unlock(&chan->cli->mutex);
600 if (old_bo != new_bo)
606 nouveau_bo_unpin(new_bo); 601 nouveau_bo_unpin(new_bo);
607 } else
608 ttm_bo_unreserve(&new_bo->bo);
609fail_free: 602fail_free:
610 kfree(s); 603 kfree(s);
611 return ret; 604 return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 218a4b522fe5..61972668fd05 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -192,6 +192,18 @@ nouveau_accel_init(struct nouveau_drm *drm)
192 192
193 arg0 = NVE0_CHANNEL_IND_ENGINE_GR; 193 arg0 = NVE0_CHANNEL_IND_ENGINE_GR;
194 arg1 = 1; 194 arg1 = 1;
195 } else
196 if (device->chipset >= 0xa3 &&
197 device->chipset != 0xaa &&
198 device->chipset != 0xac) {
199 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE,
200 NVDRM_CHAN + 1, NvDmaFB, NvDmaTT,
201 &drm->cechan);
202 if (ret)
203 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
204
205 arg0 = NvDmaFB;
206 arg1 = NvDmaTT;
195 } else { 207 } else {
196 arg0 = NvDmaFB; 208 arg0 = NvDmaFB;
197 arg1 = NvDmaTT; 209 arg1 = NvDmaTT;
@@ -284,8 +296,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
284 return 0; 296 return 0;
285} 297}
286 298
287static struct lock_class_key drm_client_lock_class_key;
288
289static int 299static int
290nouveau_drm_load(struct drm_device *dev, unsigned long flags) 300nouveau_drm_load(struct drm_device *dev, unsigned long flags)
291{ 301{
@@ -297,7 +307,6 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
297 ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm); 307 ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm);
298 if (ret) 308 if (ret)
299 return ret; 309 return ret;
300 lockdep_set_class(&drm->client.mutex, &drm_client_lock_class_key);
301 310
302 dev->dev_private = drm; 311 dev->dev_private = drm;
303 drm->dev = dev; 312 drm->dev = dev;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 9352010030e9..4c1bc061fae2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -385,6 +385,7 @@ out_unlock:
385 mutex_unlock(&dev->struct_mutex); 385 mutex_unlock(&dev->struct_mutex);
386 if (chan) 386 if (chan)
387 nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma); 387 nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma);
388 nouveau_bo_unmap(nvbo);
388out_unpin: 389out_unpin:
389 nouveau_bo_unpin(nvbo); 390 nouveau_bo_unpin(nvbo);
390out_unref: 391out_unref:
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 1680d9187bab..be3149932c2d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -143,7 +143,7 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan)
143 int ret; 143 int ret;
144 144
145 fence->channel = chan; 145 fence->channel = chan;
146 fence->timeout = jiffies + (3 * DRM_HZ); 146 fence->timeout = jiffies + (15 * DRM_HZ);
147 fence->sequence = ++fctx->sequence; 147 fence->sequence = ++fctx->sequence;
148 148
149 ret = fctx->emit(fence); 149 ret = fctx->emit(fence);
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index e72d09c068a8..830cb7bad922 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -50,12 +50,6 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
50 return; 50 return;
51 nvbo->gem = NULL; 51 nvbo->gem = NULL;
52 52
53 /* Lockdep hates you for doing reserve with gem object lock held */
54 if (WARN_ON_ONCE(nvbo->pin_refcnt)) {
55 nvbo->pin_refcnt = 1;
56 nouveau_bo_unpin(nvbo);
57 }
58
59 if (gem->import_attach) 53 if (gem->import_attach)
60 drm_prime_gem_destroy(gem, nvbo->bo.sg); 54 drm_prime_gem_destroy(gem, nvbo->bo.sg);
61 55
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 54dc6355b0c2..8b40a36c1b57 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -355,6 +355,7 @@ struct nv50_oimm {
355 355
356struct nv50_head { 356struct nv50_head {
357 struct nouveau_crtc base; 357 struct nouveau_crtc base;
358 struct nouveau_bo *image;
358 struct nv50_curs curs; 359 struct nv50_curs curs;
359 struct nv50_sync sync; 360 struct nv50_sync sync;
360 struct nv50_ovly ovly; 361 struct nv50_ovly ovly;
@@ -517,9 +518,10 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
517{ 518{
518 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 519 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
519 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 520 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
521 struct nv50_head *head = nv50_head(crtc);
520 struct nv50_sync *sync = nv50_sync(crtc); 522 struct nv50_sync *sync = nv50_sync(crtc);
521 int head = nv_crtc->index, ret;
522 u32 *push; 523 u32 *push;
524 int ret;
523 525
524 swap_interval <<= 4; 526 swap_interval <<= 4;
525 if (swap_interval == 0) 527 if (swap_interval == 0)
@@ -537,7 +539,7 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
537 return ret; 539 return ret;
538 540
539 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2); 541 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2);
540 OUT_RING (chan, NvEvoSema0 + head); 542 OUT_RING (chan, NvEvoSema0 + nv_crtc->index);
541 OUT_RING (chan, sync->addr ^ 0x10); 543 OUT_RING (chan, sync->addr ^ 0x10);
542 BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1); 544 BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1);
543 OUT_RING (chan, sync->data + 1); 545 OUT_RING (chan, sync->data + 1);
@@ -546,7 +548,7 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
546 OUT_RING (chan, sync->data); 548 OUT_RING (chan, sync->data);
547 } else 549 } else
548 if (chan && nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) { 550 if (chan && nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) {
549 u64 addr = nv84_fence_crtc(chan, head) + sync->addr; 551 u64 addr = nv84_fence_crtc(chan, nv_crtc->index) + sync->addr;
550 ret = RING_SPACE(chan, 12); 552 ret = RING_SPACE(chan, 12);
551 if (ret) 553 if (ret)
552 return ret; 554 return ret;
@@ -565,7 +567,7 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
565 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL); 567 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL);
566 } else 568 } else
567 if (chan) { 569 if (chan) {
568 u64 addr = nv84_fence_crtc(chan, head) + sync->addr; 570 u64 addr = nv84_fence_crtc(chan, nv_crtc->index) + sync->addr;
569 ret = RING_SPACE(chan, 10); 571 ret = RING_SPACE(chan, 10);
570 if (ret) 572 if (ret)
571 return ret; 573 return ret;
@@ -630,6 +632,8 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
630 evo_mthd(push, 0x0080, 1); 632 evo_mthd(push, 0x0080, 1);
631 evo_data(push, 0x00000000); 633 evo_data(push, 0x00000000);
632 evo_kick(push, sync); 634 evo_kick(push, sync);
635
636 nouveau_bo_ref(nv_fb->nvbo, &head->image);
633 return 0; 637 return 0;
634} 638}
635 639
@@ -1038,18 +1042,17 @@ static int
1038nv50_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb) 1042nv50_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb)
1039{ 1043{
1040 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb); 1044 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb);
1045 struct nv50_head *head = nv50_head(crtc);
1041 int ret; 1046 int ret;
1042 1047
1043 ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM); 1048 ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM);
1044 if (ret) 1049 if (ret == 0) {
1045 return ret; 1050 if (head->image)
1046 1051 nouveau_bo_unpin(head->image);
1047 if (old_fb) { 1052 nouveau_bo_ref(nvfb->nvbo, &head->image);
1048 nvfb = nouveau_framebuffer(old_fb);
1049 nouveau_bo_unpin(nvfb->nvbo);
1050 } 1053 }
1051 1054
1052 return 0; 1055 return ret;
1053} 1056}
1054 1057
1055static int 1058static int
@@ -1198,6 +1201,15 @@ nv50_crtc_lut_load(struct drm_crtc *crtc)
1198 } 1201 }
1199} 1202}
1200 1203
1204static void
1205nv50_crtc_disable(struct drm_crtc *crtc)
1206{
1207 struct nv50_head *head = nv50_head(crtc);
1208 if (head->image)
1209 nouveau_bo_unpin(head->image);
1210 nouveau_bo_ref(NULL, &head->image);
1211}
1212
1201static int 1213static int
1202nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, 1214nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
1203 uint32_t handle, uint32_t width, uint32_t height) 1215 uint32_t handle, uint32_t width, uint32_t height)
@@ -1271,18 +1283,29 @@ nv50_crtc_destroy(struct drm_crtc *crtc)
1271 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1283 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1272 struct nv50_disp *disp = nv50_disp(crtc->dev); 1284 struct nv50_disp *disp = nv50_disp(crtc->dev);
1273 struct nv50_head *head = nv50_head(crtc); 1285 struct nv50_head *head = nv50_head(crtc);
1286
1274 nv50_dmac_destroy(disp->core, &head->ovly.base); 1287 nv50_dmac_destroy(disp->core, &head->ovly.base);
1275 nv50_pioc_destroy(disp->core, &head->oimm.base); 1288 nv50_pioc_destroy(disp->core, &head->oimm.base);
1276 nv50_dmac_destroy(disp->core, &head->sync.base); 1289 nv50_dmac_destroy(disp->core, &head->sync.base);
1277 nv50_pioc_destroy(disp->core, &head->curs.base); 1290 nv50_pioc_destroy(disp->core, &head->curs.base);
1291
1292 /*XXX: this shouldn't be necessary, but the core doesn't call
1293 * disconnect() during the cleanup paths
1294 */
1295 if (head->image)
1296 nouveau_bo_unpin(head->image);
1297 nouveau_bo_ref(NULL, &head->image);
1298
1278 nouveau_bo_unmap(nv_crtc->cursor.nvbo); 1299 nouveau_bo_unmap(nv_crtc->cursor.nvbo);
1279 if (nv_crtc->cursor.nvbo) 1300 if (nv_crtc->cursor.nvbo)
1280 nouveau_bo_unpin(nv_crtc->cursor.nvbo); 1301 nouveau_bo_unpin(nv_crtc->cursor.nvbo);
1281 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); 1302 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
1303
1282 nouveau_bo_unmap(nv_crtc->lut.nvbo); 1304 nouveau_bo_unmap(nv_crtc->lut.nvbo);
1283 if (nv_crtc->lut.nvbo) 1305 if (nv_crtc->lut.nvbo)
1284 nouveau_bo_unpin(nv_crtc->lut.nvbo); 1306 nouveau_bo_unpin(nv_crtc->lut.nvbo);
1285 nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); 1307 nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
1308
1286 drm_crtc_cleanup(crtc); 1309 drm_crtc_cleanup(crtc);
1287 kfree(crtc); 1310 kfree(crtc);
1288} 1311}
@@ -1296,6 +1319,7 @@ static const struct drm_crtc_helper_funcs nv50_crtc_hfunc = {
1296 .mode_set_base = nv50_crtc_mode_set_base, 1319 .mode_set_base = nv50_crtc_mode_set_base,
1297 .mode_set_base_atomic = nv50_crtc_mode_set_base_atomic, 1320 .mode_set_base_atomic = nv50_crtc_mode_set_base_atomic,
1298 .load_lut = nv50_crtc_lut_load, 1321 .load_lut = nv50_crtc_lut_load,
1322 .disable = nv50_crtc_disable,
1299}; 1323};
1300 1324
1301static const struct drm_crtc_funcs nv50_crtc_func = { 1325static const struct drm_crtc_funcs nv50_crtc_func = {
diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index 93c2f2cceb51..eb89653a7a17 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -179,9 +179,10 @@ qxl_push_command_ring_release(struct qxl_device *qdev, struct qxl_release *relea
179 uint32_t type, bool interruptible) 179 uint32_t type, bool interruptible)
180{ 180{
181 struct qxl_command cmd; 181 struct qxl_command cmd;
182 struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
182 183
183 cmd.type = type; 184 cmd.type = type;
184 cmd.data = qxl_bo_physical_address(qdev, release->bos[0], release->release_offset); 185 cmd.data = qxl_bo_physical_address(qdev, to_qxl_bo(entry->tv.bo), release->release_offset);
185 186
186 return qxl_ring_push(qdev->command_ring, &cmd, interruptible); 187 return qxl_ring_push(qdev->command_ring, &cmd, interruptible);
187} 188}
@@ -191,9 +192,10 @@ qxl_push_cursor_ring_release(struct qxl_device *qdev, struct qxl_release *releas
191 uint32_t type, bool interruptible) 192 uint32_t type, bool interruptible)
192{ 193{
193 struct qxl_command cmd; 194 struct qxl_command cmd;
195 struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
194 196
195 cmd.type = type; 197 cmd.type = type;
196 cmd.data = qxl_bo_physical_address(qdev, release->bos[0], release->release_offset); 198 cmd.data = qxl_bo_physical_address(qdev, to_qxl_bo(entry->tv.bo), release->release_offset);
197 199
198 return qxl_ring_push(qdev->cursor_ring, &cmd, interruptible); 200 return qxl_ring_push(qdev->cursor_ring, &cmd, interruptible);
199} 201}
@@ -214,7 +216,6 @@ int qxl_garbage_collect(struct qxl_device *qdev)
214 struct qxl_release *release; 216 struct qxl_release *release;
215 uint64_t id, next_id; 217 uint64_t id, next_id;
216 int i = 0; 218 int i = 0;
217 int ret;
218 union qxl_release_info *info; 219 union qxl_release_info *info;
219 220
220 while (qxl_ring_pop(qdev->release_ring, &id)) { 221 while (qxl_ring_pop(qdev->release_ring, &id)) {
@@ -224,17 +225,10 @@ int qxl_garbage_collect(struct qxl_device *qdev)
224 if (release == NULL) 225 if (release == NULL)
225 break; 226 break;
226 227
227 ret = qxl_release_reserve(qdev, release, false);
228 if (ret) {
229 qxl_io_log(qdev, "failed to reserve release on garbage collect %lld\n", id);
230 DRM_ERROR("failed to reserve release %lld\n", id);
231 }
232
233 info = qxl_release_map(qdev, release); 228 info = qxl_release_map(qdev, release);
234 next_id = info->next; 229 next_id = info->next;
235 qxl_release_unmap(qdev, release, info); 230 qxl_release_unmap(qdev, release, info);
236 231
237 qxl_release_unreserve(qdev, release);
238 QXL_INFO(qdev, "popped %lld, next %lld\n", id, 232 QXL_INFO(qdev, "popped %lld, next %lld\n", id,
239 next_id); 233 next_id);
240 234
@@ -259,27 +253,29 @@ int qxl_garbage_collect(struct qxl_device *qdev)
259 return i; 253 return i;
260} 254}
261 255
262int qxl_alloc_bo_reserved(struct qxl_device *qdev, unsigned long size, 256int qxl_alloc_bo_reserved(struct qxl_device *qdev,
257 struct qxl_release *release,
258 unsigned long size,
263 struct qxl_bo **_bo) 259 struct qxl_bo **_bo)
264{ 260{
265 struct qxl_bo *bo; 261 struct qxl_bo *bo;
266 int ret; 262 int ret;
267 263
268 ret = qxl_bo_create(qdev, size, false /* not kernel - device */, 264 ret = qxl_bo_create(qdev, size, false /* not kernel - device */,
269 QXL_GEM_DOMAIN_VRAM, NULL, &bo); 265 false, QXL_GEM_DOMAIN_VRAM, NULL, &bo);
270 if (ret) { 266 if (ret) {
271 DRM_ERROR("failed to allocate VRAM BO\n"); 267 DRM_ERROR("failed to allocate VRAM BO\n");
272 return ret; 268 return ret;
273 } 269 }
274 ret = qxl_bo_reserve(bo, false); 270 ret = qxl_release_list_add(release, bo);
275 if (unlikely(ret != 0)) 271 if (ret)
276 goto out_unref; 272 goto out_unref;
277 273
278 *_bo = bo; 274 *_bo = bo;
279 return 0; 275 return 0;
280out_unref: 276out_unref:
281 qxl_bo_unref(&bo); 277 qxl_bo_unref(&bo);
282 return 0; 278 return ret;
283} 279}
284 280
285static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port, bool intr) 281static 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,
503 if (ret) 499 if (ret)
504 return ret; 500 return ret;
505 501
502 ret = qxl_release_reserve_list(release, true);
503 if (ret)
504 return ret;
505
506 cmd = (struct qxl_surface_cmd *)qxl_release_map(qdev, release); 506 cmd = (struct qxl_surface_cmd *)qxl_release_map(qdev, release);
507 cmd->type = QXL_SURFACE_CMD_CREATE; 507 cmd->type = QXL_SURFACE_CMD_CREATE;
508 cmd->u.surface_create.format = surf->surf.format; 508 cmd->u.surface_create.format = surf->surf.format;
@@ -524,14 +524,11 @@ int qxl_hw_surface_alloc(struct qxl_device *qdev,
524 524
525 surf->surf_create = release; 525 surf->surf_create = release;
526 526
527 /* no need to add a release to the fence for this bo, 527 /* no need to add a release to the fence for this surface bo,
528 since it is only released when we ask to destroy the surface 528 since it is only released when we ask to destroy the surface
529 and it would never signal otherwise */ 529 and it would never signal otherwise */
530 qxl_fence_releaseable(qdev, release);
531
532 qxl_push_command_ring_release(qdev, release, QXL_CMD_SURFACE, false); 530 qxl_push_command_ring_release(qdev, release, QXL_CMD_SURFACE, false);
533 531 qxl_release_fence_buffer_objects(release);
534 qxl_release_unreserve(qdev, release);
535 532
536 surf->hw_surf_alloc = true; 533 surf->hw_surf_alloc = true;
537 spin_lock(&qdev->surf_id_idr_lock); 534 spin_lock(&qdev->surf_id_idr_lock);
@@ -573,12 +570,9 @@ int qxl_hw_surface_dealloc(struct qxl_device *qdev,
573 cmd->surface_id = id; 570 cmd->surface_id = id;
574 qxl_release_unmap(qdev, release, &cmd->release_info); 571 qxl_release_unmap(qdev, release, &cmd->release_info);
575 572
576 qxl_fence_releaseable(qdev, release);
577
578 qxl_push_command_ring_release(qdev, release, QXL_CMD_SURFACE, false); 573 qxl_push_command_ring_release(qdev, release, QXL_CMD_SURFACE, false);
579 574
580 qxl_release_unreserve(qdev, release); 575 qxl_release_fence_buffer_objects(release);
581
582 576
583 return 0; 577 return 0;
584} 578}
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index f76f5dd7bfc4..835caba026d3 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -179,7 +179,7 @@ static void qxl_crtc_destroy(struct drm_crtc *crtc)
179 kfree(qxl_crtc); 179 kfree(qxl_crtc);
180} 180}
181 181
182static void 182static int
183qxl_hide_cursor(struct qxl_device *qdev) 183qxl_hide_cursor(struct qxl_device *qdev)
184{ 184{
185 struct qxl_release *release; 185 struct qxl_release *release;
@@ -188,14 +188,22 @@ qxl_hide_cursor(struct qxl_device *qdev)
188 188
189 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), QXL_RELEASE_CURSOR_CMD, 189 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), QXL_RELEASE_CURSOR_CMD,
190 &release, NULL); 190 &release, NULL);
191 if (ret)
192 return ret;
193
194 ret = qxl_release_reserve_list(release, true);
195 if (ret) {
196 qxl_release_free(qdev, release);
197 return ret;
198 }
191 199
192 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release); 200 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
193 cmd->type = QXL_CURSOR_HIDE; 201 cmd->type = QXL_CURSOR_HIDE;
194 qxl_release_unmap(qdev, release, &cmd->release_info); 202 qxl_release_unmap(qdev, release, &cmd->release_info);
195 203
196 qxl_fence_releaseable(qdev, release);
197 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false); 204 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
198 qxl_release_unreserve(qdev, release); 205 qxl_release_fence_buffer_objects(release);
206 return 0;
199} 207}
200 208
201static int qxl_crtc_cursor_set2(struct drm_crtc *crtc, 209static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
@@ -216,10 +224,8 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
216 224
217 int size = 64*64*4; 225 int size = 64*64*4;
218 int ret = 0; 226 int ret = 0;
219 if (!handle) { 227 if (!handle)
220 qxl_hide_cursor(qdev); 228 return qxl_hide_cursor(qdev);
221 return 0;
222 }
223 229
224 obj = drm_gem_object_lookup(crtc->dev, file_priv, handle); 230 obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
225 if (!obj) { 231 if (!obj) {
@@ -234,8 +240,9 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
234 goto out_unref; 240 goto out_unref;
235 241
236 ret = qxl_bo_pin(user_bo, QXL_GEM_DOMAIN_CPU, NULL); 242 ret = qxl_bo_pin(user_bo, QXL_GEM_DOMAIN_CPU, NULL);
243 qxl_bo_unreserve(user_bo);
237 if (ret) 244 if (ret)
238 goto out_unreserve; 245 goto out_unref;
239 246
240 ret = qxl_bo_kmap(user_bo, &user_ptr); 247 ret = qxl_bo_kmap(user_bo, &user_ptr);
241 if (ret) 248 if (ret)
@@ -246,14 +253,20 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
246 &release, NULL); 253 &release, NULL);
247 if (ret) 254 if (ret)
248 goto out_kunmap; 255 goto out_kunmap;
249 ret = qxl_alloc_bo_reserved(qdev, sizeof(struct qxl_cursor) + size, 256
250 &cursor_bo); 257 ret = qxl_alloc_bo_reserved(qdev, release, sizeof(struct qxl_cursor) + size,
258 &cursor_bo);
251 if (ret) 259 if (ret)
252 goto out_free_release; 260 goto out_free_release;
253 ret = qxl_bo_kmap(cursor_bo, (void **)&cursor); 261
262 ret = qxl_release_reserve_list(release, false);
254 if (ret) 263 if (ret)
255 goto out_free_bo; 264 goto out_free_bo;
256 265
266 ret = qxl_bo_kmap(cursor_bo, (void **)&cursor);
267 if (ret)
268 goto out_backoff;
269
257 cursor->header.unique = 0; 270 cursor->header.unique = 0;
258 cursor->header.type = SPICE_CURSOR_TYPE_ALPHA; 271 cursor->header.type = SPICE_CURSOR_TYPE_ALPHA;
259 cursor->header.width = 64; 272 cursor->header.width = 64;
@@ -269,11 +282,7 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
269 282
270 qxl_bo_kunmap(cursor_bo); 283 qxl_bo_kunmap(cursor_bo);
271 284
272 /* finish with the userspace bo */
273 qxl_bo_kunmap(user_bo); 285 qxl_bo_kunmap(user_bo);
274 qxl_bo_unpin(user_bo);
275 qxl_bo_unreserve(user_bo);
276 drm_gem_object_unreference_unlocked(obj);
277 286
278 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release); 287 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
279 cmd->type = QXL_CURSOR_SET; 288 cmd->type = QXL_CURSOR_SET;
@@ -281,30 +290,35 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
281 cmd->u.set.position.y = qcrtc->cur_y; 290 cmd->u.set.position.y = qcrtc->cur_y;
282 291
283 cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0); 292 cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
284 qxl_release_add_res(qdev, release, cursor_bo);
285 293
286 cmd->u.set.visible = 1; 294 cmd->u.set.visible = 1;
287 qxl_release_unmap(qdev, release, &cmd->release_info); 295 qxl_release_unmap(qdev, release, &cmd->release_info);
288 296
289 qxl_fence_releaseable(qdev, release);
290 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false); 297 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
291 qxl_release_unreserve(qdev, release); 298 qxl_release_fence_buffer_objects(release);
299
300 /* finish with the userspace bo */
301 ret = qxl_bo_reserve(user_bo, false);
302 if (!ret) {
303 qxl_bo_unpin(user_bo);
304 qxl_bo_unreserve(user_bo);
305 }
306 drm_gem_object_unreference_unlocked(obj);
292 307
293 qxl_bo_unreserve(cursor_bo);
294 qxl_bo_unref(&cursor_bo); 308 qxl_bo_unref(&cursor_bo);
295 309
296 return ret; 310 return ret;
311
312out_backoff:
313 qxl_release_backoff_reserve_list(release);
297out_free_bo: 314out_free_bo:
298 qxl_bo_unref(&cursor_bo); 315 qxl_bo_unref(&cursor_bo);
299out_free_release: 316out_free_release:
300 qxl_release_unreserve(qdev, release);
301 qxl_release_free(qdev, release); 317 qxl_release_free(qdev, release);
302out_kunmap: 318out_kunmap:
303 qxl_bo_kunmap(user_bo); 319 qxl_bo_kunmap(user_bo);
304out_unpin: 320out_unpin:
305 qxl_bo_unpin(user_bo); 321 qxl_bo_unpin(user_bo);
306out_unreserve:
307 qxl_bo_unreserve(user_bo);
308out_unref: 322out_unref:
309 drm_gem_object_unreference_unlocked(obj); 323 drm_gem_object_unreference_unlocked(obj);
310 return ret; 324 return ret;
@@ -322,6 +336,14 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
322 336
323 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), QXL_RELEASE_CURSOR_CMD, 337 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), QXL_RELEASE_CURSOR_CMD,
324 &release, NULL); 338 &release, NULL);
339 if (ret)
340 return ret;
341
342 ret = qxl_release_reserve_list(release, true);
343 if (ret) {
344 qxl_release_free(qdev, release);
345 return ret;
346 }
325 347
326 qcrtc->cur_x = x; 348 qcrtc->cur_x = x;
327 qcrtc->cur_y = y; 349 qcrtc->cur_y = y;
@@ -332,9 +354,9 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
332 cmd->u.position.y = qcrtc->cur_y; 354 cmd->u.position.y = qcrtc->cur_y;
333 qxl_release_unmap(qdev, release, &cmd->release_info); 355 qxl_release_unmap(qdev, release, &cmd->release_info);
334 356
335 qxl_fence_releaseable(qdev, release);
336 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false); 357 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
337 qxl_release_unreserve(qdev, release); 358 qxl_release_fence_buffer_objects(release);
359
338 return 0; 360 return 0;
339} 361}
340 362
diff --git a/drivers/gpu/drm/qxl/qxl_draw.c b/drivers/gpu/drm/qxl/qxl_draw.c
index 3c8c3dbf9378..56e1d633875e 100644
--- a/drivers/gpu/drm/qxl/qxl_draw.c
+++ b/drivers/gpu/drm/qxl/qxl_draw.c
@@ -23,25 +23,29 @@
23#include "qxl_drv.h" 23#include "qxl_drv.h"
24#include "qxl_object.h" 24#include "qxl_object.h"
25 25
26static int alloc_clips(struct qxl_device *qdev,
27 struct qxl_release *release,
28 unsigned num_clips,
29 struct qxl_bo **clips_bo)
30{
31 int size = sizeof(struct qxl_clip_rects) + sizeof(struct qxl_rect) * num_clips;
32
33 return qxl_alloc_bo_reserved(qdev, release, size, clips_bo);
34}
35
26/* returns a pointer to the already allocated qxl_rect array inside 36/* returns a pointer to the already allocated qxl_rect array inside
27 * the qxl_clip_rects. This is *not* the same as the memory allocated 37 * the qxl_clip_rects. This is *not* the same as the memory allocated
28 * on the device, it is offset to qxl_clip_rects.chunk.data */ 38 * on the device, it is offset to qxl_clip_rects.chunk.data */
29static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev, 39static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev,
30 struct qxl_drawable *drawable, 40 struct qxl_drawable *drawable,
31 unsigned num_clips, 41 unsigned num_clips,
32 struct qxl_bo **clips_bo, 42 struct qxl_bo *clips_bo)
33 struct qxl_release *release)
34{ 43{
35 struct qxl_clip_rects *dev_clips; 44 struct qxl_clip_rects *dev_clips;
36 int ret; 45 int ret;
37 int size = sizeof(*dev_clips) + sizeof(struct qxl_rect) * num_clips;
38 ret = qxl_alloc_bo_reserved(qdev, size, clips_bo);
39 if (ret)
40 return NULL;
41 46
42 ret = qxl_bo_kmap(*clips_bo, (void **)&dev_clips); 47 ret = qxl_bo_kmap(clips_bo, (void **)&dev_clips);
43 if (ret) { 48 if (ret) {
44 qxl_bo_unref(clips_bo);
45 return NULL; 49 return NULL;
46 } 50 }
47 dev_clips->num_rects = num_clips; 51 dev_clips->num_rects = num_clips;
@@ -52,20 +56,34 @@ static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev,
52} 56}
53 57
54static int 58static int
59alloc_drawable(struct qxl_device *qdev, struct qxl_release **release)
60{
61 int ret;
62 ret = qxl_alloc_release_reserved(qdev, sizeof(struct qxl_drawable),
63 QXL_RELEASE_DRAWABLE, release,
64 NULL);
65 return ret;
66}
67
68static void
69free_drawable(struct qxl_device *qdev, struct qxl_release *release)
70{
71 qxl_release_free(qdev, release);
72}
73
74/* release needs to be reserved at this point */
75static int
55make_drawable(struct qxl_device *qdev, int surface, uint8_t type, 76make_drawable(struct qxl_device *qdev, int surface, uint8_t type,
56 const struct qxl_rect *rect, 77 const struct qxl_rect *rect,
57 struct qxl_release **release) 78 struct qxl_release *release)
58{ 79{
59 struct qxl_drawable *drawable; 80 struct qxl_drawable *drawable;
60 int i, ret; 81 int i;
61 82
62 ret = qxl_alloc_release_reserved(qdev, sizeof(*drawable), 83 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
63 QXL_RELEASE_DRAWABLE, release, 84 if (!drawable)
64 NULL); 85 return -ENOMEM;
65 if (ret)
66 return ret;
67 86
68 drawable = (struct qxl_drawable *)qxl_release_map(qdev, *release);
69 drawable->type = type; 87 drawable->type = type;
70 88
71 drawable->surface_id = surface; /* Only primary for now */ 89 drawable->surface_id = surface; /* Only primary for now */
@@ -91,14 +109,23 @@ make_drawable(struct qxl_device *qdev, int surface, uint8_t type,
91 drawable->bbox = *rect; 109 drawable->bbox = *rect;
92 110
93 drawable->mm_time = qdev->rom->mm_clock; 111 drawable->mm_time = qdev->rom->mm_clock;
94 qxl_release_unmap(qdev, *release, &drawable->release_info); 112 qxl_release_unmap(qdev, release, &drawable->release_info);
95 return 0; 113 return 0;
96} 114}
97 115
98static int qxl_palette_create_1bit(struct qxl_bo **palette_bo, 116static int alloc_palette_object(struct qxl_device *qdev,
117 struct qxl_release *release,
118 struct qxl_bo **palette_bo)
119{
120 return qxl_alloc_bo_reserved(qdev, release,
121 sizeof(struct qxl_palette) + sizeof(uint32_t) * 2,
122 palette_bo);
123}
124
125static int qxl_palette_create_1bit(struct qxl_bo *palette_bo,
126 struct qxl_release *release,
99 const struct qxl_fb_image *qxl_fb_image) 127 const struct qxl_fb_image *qxl_fb_image)
100{ 128{
101 struct qxl_device *qdev = qxl_fb_image->qdev;
102 const struct fb_image *fb_image = &qxl_fb_image->fb_image; 129 const struct fb_image *fb_image = &qxl_fb_image->fb_image;
103 uint32_t visual = qxl_fb_image->visual; 130 uint32_t visual = qxl_fb_image->visual;
104 const uint32_t *pseudo_palette = qxl_fb_image->pseudo_palette; 131 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,
108 static uint64_t unique; /* we make no attempt to actually set this 135 static uint64_t unique; /* we make no attempt to actually set this
109 * correctly globaly, since that would require 136 * correctly globaly, since that would require
110 * tracking all of our palettes. */ 137 * tracking all of our palettes. */
111 138 ret = qxl_bo_kmap(palette_bo, (void **)&pal);
112 ret = qxl_alloc_bo_reserved(qdev,
113 sizeof(struct qxl_palette) + sizeof(uint32_t) * 2,
114 palette_bo);
115
116 ret = qxl_bo_kmap(*palette_bo, (void **)&pal);
117 pal->num_ents = 2; 139 pal->num_ents = 2;
118 pal->unique = unique++; 140 pal->unique = unique++;
119 if (visual == FB_VISUAL_TRUECOLOR || visual == FB_VISUAL_DIRECTCOLOR) { 141 if (visual == FB_VISUAL_TRUECOLOR || visual == FB_VISUAL_DIRECTCOLOR) {
@@ -126,7 +148,7 @@ static int qxl_palette_create_1bit(struct qxl_bo **palette_bo,
126 } 148 }
127 pal->ents[0] = bgcolor; 149 pal->ents[0] = bgcolor;
128 pal->ents[1] = fgcolor; 150 pal->ents[1] = fgcolor;
129 qxl_bo_kunmap(*palette_bo); 151 qxl_bo_kunmap(palette_bo);
130 return 0; 152 return 0;
131} 153}
132 154
@@ -144,44 +166,63 @@ void qxl_draw_opaque_fb(const struct qxl_fb_image *qxl_fb_image,
144 const char *src = fb_image->data; 166 const char *src = fb_image->data;
145 int depth = fb_image->depth; 167 int depth = fb_image->depth;
146 struct qxl_release *release; 168 struct qxl_release *release;
147 struct qxl_bo *image_bo;
148 struct qxl_image *image; 169 struct qxl_image *image;
149 int ret; 170 int ret;
150 171 struct qxl_drm_image *dimage;
172 struct qxl_bo *palette_bo = NULL;
151 if (stride == 0) 173 if (stride == 0)
152 stride = depth * width / 8; 174 stride = depth * width / 8;
153 175
176 ret = alloc_drawable(qdev, &release);
177 if (ret)
178 return;
179
180 ret = qxl_image_alloc_objects(qdev, release,
181 &dimage,
182 height, stride);
183 if (ret)
184 goto out_free_drawable;
185
186 if (depth == 1) {
187 ret = alloc_palette_object(qdev, release, &palette_bo);
188 if (ret)
189 goto out_free_image;
190 }
191
192 /* do a reservation run over all the objects we just allocated */
193 ret = qxl_release_reserve_list(release, true);
194 if (ret)
195 goto out_free_palette;
196
154 rect.left = x; 197 rect.left = x;
155 rect.right = x + width; 198 rect.right = x + width;
156 rect.top = y; 199 rect.top = y;
157 rect.bottom = y + height; 200 rect.bottom = y + height;
158 201
159 ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &rect, &release); 202 ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &rect, release);
160 if (ret) 203 if (ret) {
161 return; 204 qxl_release_backoff_reserve_list(release);
205 goto out_free_palette;
206 }
162 207
163 ret = qxl_image_create(qdev, release, &image_bo, 208 ret = qxl_image_init(qdev, release, dimage,
164 (const uint8_t *)src, 0, 0, 209 (const uint8_t *)src, 0, 0,
165 width, height, depth, stride); 210 width, height, depth, stride);
166 if (ret) { 211 if (ret) {
167 qxl_release_unreserve(qdev, release); 212 qxl_release_backoff_reserve_list(release);
168 qxl_release_free(qdev, release); 213 qxl_release_free(qdev, release);
169 return; 214 return;
170 } 215 }
171 216
172 if (depth == 1) { 217 if (depth == 1) {
173 struct qxl_bo *palette_bo;
174 void *ptr; 218 void *ptr;
175 ret = qxl_palette_create_1bit(&palette_bo, qxl_fb_image); 219 ret = qxl_palette_create_1bit(palette_bo, release, qxl_fb_image);
176 qxl_release_add_res(qdev, release, palette_bo);
177 220
178 ptr = qxl_bo_kmap_atomic_page(qdev, image_bo, 0); 221 ptr = qxl_bo_kmap_atomic_page(qdev, dimage->bo, 0);
179 image = ptr; 222 image = ptr;
180 image->u.bitmap.palette = 223 image->u.bitmap.palette =
181 qxl_bo_physical_address(qdev, palette_bo, 0); 224 qxl_bo_physical_address(qdev, palette_bo, 0);
182 qxl_bo_kunmap_atomic_page(qdev, image_bo, ptr); 225 qxl_bo_kunmap_atomic_page(qdev, dimage->bo, ptr);
183 qxl_bo_unreserve(palette_bo);
184 qxl_bo_unref(&palette_bo);
185 } 226 }
186 227
187 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release); 228 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,
199 drawable->u.copy.mask.bitmap = 0; 240 drawable->u.copy.mask.bitmap = 0;
200 241
201 drawable->u.copy.src_bitmap = 242 drawable->u.copy.src_bitmap =
202 qxl_bo_physical_address(qdev, image_bo, 0); 243 qxl_bo_physical_address(qdev, dimage->bo, 0);
203 qxl_release_unmap(qdev, release, &drawable->release_info); 244 qxl_release_unmap(qdev, release, &drawable->release_info);
204 245
205 qxl_release_add_res(qdev, release, image_bo);
206 qxl_bo_unreserve(image_bo);
207 qxl_bo_unref(&image_bo);
208
209 qxl_fence_releaseable(qdev, release);
210 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false); 246 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
211 qxl_release_unreserve(qdev, release); 247 qxl_release_fence_buffer_objects(release);
248
249out_free_palette:
250 if (palette_bo)
251 qxl_bo_unref(&palette_bo);
252out_free_image:
253 qxl_image_free_objects(qdev, dimage);
254out_free_drawable:
255 if (ret)
256 free_drawable(qdev, release);
212} 257}
213 258
214/* push a draw command using the given clipping rectangles as 259/* push a draw command using the given clipping rectangles as
@@ -243,10 +288,14 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
243 int depth = qxl_fb->base.bits_per_pixel; 288 int depth = qxl_fb->base.bits_per_pixel;
244 uint8_t *surface_base; 289 uint8_t *surface_base;
245 struct qxl_release *release; 290 struct qxl_release *release;
246 struct qxl_bo *image_bo;
247 struct qxl_bo *clips_bo; 291 struct qxl_bo *clips_bo;
292 struct qxl_drm_image *dimage;
248 int ret; 293 int ret;
249 294
295 ret = alloc_drawable(qdev, &release);
296 if (ret)
297 return;
298
250 left = clips->x1; 299 left = clips->x1;
251 right = clips->x2; 300 right = clips->x2;
252 top = clips->y1; 301 top = clips->y1;
@@ -263,36 +312,52 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
263 312
264 width = right - left; 313 width = right - left;
265 height = bottom - top; 314 height = bottom - top;
315
316 ret = alloc_clips(qdev, release, num_clips, &clips_bo);
317 if (ret)
318 goto out_free_drawable;
319
320 ret = qxl_image_alloc_objects(qdev, release,
321 &dimage,
322 height, stride);
323 if (ret)
324 goto out_free_clips;
325
326 /* do a reservation run over all the objects we just allocated */
327 ret = qxl_release_reserve_list(release, true);
328 if (ret)
329 goto out_free_image;
330
266 drawable_rect.left = left; 331 drawable_rect.left = left;
267 drawable_rect.right = right; 332 drawable_rect.right = right;
268 drawable_rect.top = top; 333 drawable_rect.top = top;
269 drawable_rect.bottom = bottom; 334 drawable_rect.bottom = bottom;
335
270 ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &drawable_rect, 336 ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &drawable_rect,
271 &release); 337 release);
272 if (ret) 338 if (ret)
273 return; 339 goto out_release_backoff;
274 340
275 ret = qxl_bo_kmap(bo, (void **)&surface_base); 341 ret = qxl_bo_kmap(bo, (void **)&surface_base);
276 if (ret) 342 if (ret)
277 goto out_unref; 343 goto out_release_backoff;
278 344
279 ret = qxl_image_create(qdev, release, &image_bo, surface_base, 345
280 left, top, width, height, depth, stride); 346 ret = qxl_image_init(qdev, release, dimage, surface_base,
347 left, top, width, height, depth, stride);
281 qxl_bo_kunmap(bo); 348 qxl_bo_kunmap(bo);
282 if (ret) 349 if (ret)
283 goto out_unref; 350 goto out_release_backoff;
351
352 rects = drawable_set_clipping(qdev, drawable, num_clips, clips_bo);
353 if (!rects)
354 goto out_release_backoff;
284 355
285 rects = drawable_set_clipping(qdev, drawable, num_clips, &clips_bo, release);
286 if (!rects) {
287 qxl_bo_unref(&image_bo);
288 goto out_unref;
289 }
290 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release); 356 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
291 357
292 drawable->clip.type = SPICE_CLIP_TYPE_RECTS; 358 drawable->clip.type = SPICE_CLIP_TYPE_RECTS;
293 drawable->clip.data = qxl_bo_physical_address(qdev, 359 drawable->clip.data = qxl_bo_physical_address(qdev,
294 clips_bo, 0); 360 clips_bo, 0);
295 qxl_release_add_res(qdev, release, clips_bo);
296 361
297 drawable->u.copy.src_area.top = 0; 362 drawable->u.copy.src_area.top = 0;
298 drawable->u.copy.src_area.bottom = height; 363 drawable->u.copy.src_area.bottom = height;
@@ -306,11 +371,9 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
306 drawable->u.copy.mask.pos.y = 0; 371 drawable->u.copy.mask.pos.y = 0;
307 drawable->u.copy.mask.bitmap = 0; 372 drawable->u.copy.mask.bitmap = 0;
308 373
309 drawable->u.copy.src_bitmap = qxl_bo_physical_address(qdev, image_bo, 0); 374 drawable->u.copy.src_bitmap = qxl_bo_physical_address(qdev, dimage->bo, 0);
310 qxl_release_unmap(qdev, release, &drawable->release_info); 375 qxl_release_unmap(qdev, release, &drawable->release_info);
311 qxl_release_add_res(qdev, release, image_bo); 376
312 qxl_bo_unreserve(image_bo);
313 qxl_bo_unref(&image_bo);
314 clips_ptr = clips; 377 clips_ptr = clips;
315 for (i = 0; i < num_clips; i++, clips_ptr += inc) { 378 for (i = 0; i < num_clips; i++, clips_ptr += inc) {
316 rects[i].left = clips_ptr->x1; 379 rects[i].left = clips_ptr->x1;
@@ -319,17 +382,22 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
319 rects[i].bottom = clips_ptr->y2; 382 rects[i].bottom = clips_ptr->y2;
320 } 383 }
321 qxl_bo_kunmap(clips_bo); 384 qxl_bo_kunmap(clips_bo);
322 qxl_bo_unreserve(clips_bo);
323 qxl_bo_unref(&clips_bo);
324 385
325 qxl_fence_releaseable(qdev, release);
326 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false); 386 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
327 qxl_release_unreserve(qdev, release); 387 qxl_release_fence_buffer_objects(release);
328 return; 388
389out_release_backoff:
390 if (ret)
391 qxl_release_backoff_reserve_list(release);
392out_free_image:
393 qxl_image_free_objects(qdev, dimage);
394out_free_clips:
395 qxl_bo_unref(&clips_bo);
396out_free_drawable:
397 /* only free drawable on error */
398 if (ret)
399 free_drawable(qdev, release);
329 400
330out_unref:
331 qxl_release_unreserve(qdev, release);
332 qxl_release_free(qdev, release);
333} 401}
334 402
335void qxl_draw_copyarea(struct qxl_device *qdev, 403void qxl_draw_copyarea(struct qxl_device *qdev,
@@ -342,22 +410,36 @@ void qxl_draw_copyarea(struct qxl_device *qdev,
342 struct qxl_release *release; 410 struct qxl_release *release;
343 int ret; 411 int ret;
344 412
413 ret = alloc_drawable(qdev, &release);
414 if (ret)
415 return;
416
417 /* do a reservation run over all the objects we just allocated */
418 ret = qxl_release_reserve_list(release, true);
419 if (ret)
420 goto out_free_release;
421
345 rect.left = dx; 422 rect.left = dx;
346 rect.top = dy; 423 rect.top = dy;
347 rect.right = dx + width; 424 rect.right = dx + width;
348 rect.bottom = dy + height; 425 rect.bottom = dy + height;
349 ret = make_drawable(qdev, 0, QXL_COPY_BITS, &rect, &release); 426 ret = make_drawable(qdev, 0, QXL_COPY_BITS, &rect, release);
350 if (ret) 427 if (ret) {
351 return; 428 qxl_release_backoff_reserve_list(release);
429 goto out_free_release;
430 }
352 431
353 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release); 432 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
354 drawable->u.copy_bits.src_pos.x = sx; 433 drawable->u.copy_bits.src_pos.x = sx;
355 drawable->u.copy_bits.src_pos.y = sy; 434 drawable->u.copy_bits.src_pos.y = sy;
356
357 qxl_release_unmap(qdev, release, &drawable->release_info); 435 qxl_release_unmap(qdev, release, &drawable->release_info);
358 qxl_fence_releaseable(qdev, release); 436
359 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false); 437 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
360 qxl_release_unreserve(qdev, release); 438 qxl_release_fence_buffer_objects(release);
439
440out_free_release:
441 if (ret)
442 free_drawable(qdev, release);
361} 443}
362 444
363void qxl_draw_fill(struct qxl_draw_fill *qxl_draw_fill_rec) 445void 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)
370 struct qxl_release *release; 452 struct qxl_release *release;
371 int ret; 453 int ret;
372 454
373 ret = make_drawable(qdev, 0, QXL_DRAW_FILL, &rect, &release); 455 ret = alloc_drawable(qdev, &release);
374 if (ret) 456 if (ret)
375 return; 457 return;
376 458
459 /* do a reservation run over all the objects we just allocated */
460 ret = qxl_release_reserve_list(release, true);
461 if (ret)
462 goto out_free_release;
463
464 ret = make_drawable(qdev, 0, QXL_DRAW_FILL, &rect, release);
465 if (ret) {
466 qxl_release_backoff_reserve_list(release);
467 goto out_free_release;
468 }
469
377 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release); 470 drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
378 drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID; 471 drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;
379 drawable->u.fill.brush.u.color = color; 472 drawable->u.fill.brush.u.color = color;
@@ -384,7 +477,11 @@ void qxl_draw_fill(struct qxl_draw_fill *qxl_draw_fill_rec)
384 drawable->u.fill.mask.bitmap = 0; 477 drawable->u.fill.mask.bitmap = 0;
385 478
386 qxl_release_unmap(qdev, release, &drawable->release_info); 479 qxl_release_unmap(qdev, release, &drawable->release_info);
387 qxl_fence_releaseable(qdev, release); 480
388 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false); 481 qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
389 qxl_release_unreserve(qdev, release); 482 qxl_release_fence_buffer_objects(release);
483
484out_free_release:
485 if (ret)
486 free_drawable(qdev, release);
390} 487}
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index aacb791464a3..7e96f4f11738 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -42,6 +42,9 @@
42#include <ttm/ttm_placement.h> 42#include <ttm/ttm_placement.h>
43#include <ttm/ttm_module.h> 43#include <ttm/ttm_module.h>
44 44
45/* just for ttm_validate_buffer */
46#include <ttm/ttm_execbuf_util.h>
47
45#include <drm/qxl_drm.h> 48#include <drm/qxl_drm.h>
46#include "qxl_dev.h" 49#include "qxl_dev.h"
47 50
@@ -118,9 +121,9 @@ struct qxl_bo {
118 uint32_t surface_id; 121 uint32_t surface_id;
119 struct qxl_fence fence; /* per bo fence - list of releases */ 122 struct qxl_fence fence; /* per bo fence - list of releases */
120 struct qxl_release *surf_create; 123 struct qxl_release *surf_create;
121 atomic_t reserve_count;
122}; 124};
123#define gem_to_qxl_bo(gobj) container_of((gobj), struct qxl_bo, gem_base) 125#define gem_to_qxl_bo(gobj) container_of((gobj), struct qxl_bo, gem_base)
126#define to_qxl_bo(tobj) container_of((tobj), struct qxl_bo, tbo)
124 127
125struct qxl_gem { 128struct qxl_gem {
126 struct mutex mutex; 129 struct mutex mutex;
@@ -128,12 +131,7 @@ struct qxl_gem {
128}; 131};
129 132
130struct qxl_bo_list { 133struct qxl_bo_list {
131 struct list_head lhead; 134 struct ttm_validate_buffer tv;
132 struct qxl_bo *bo;
133};
134
135struct qxl_reloc_list {
136 struct list_head bos;
137}; 135};
138 136
139struct qxl_crtc { 137struct qxl_crtc {
@@ -195,10 +193,20 @@ enum {
195struct qxl_release { 193struct qxl_release {
196 int id; 194 int id;
197 int type; 195 int type;
198 int bo_count;
199 uint32_t release_offset; 196 uint32_t release_offset;
200 uint32_t surface_release_id; 197 uint32_t surface_release_id;
201 struct qxl_bo *bos[QXL_MAX_RES]; 198 struct ww_acquire_ctx ticket;
199 struct list_head bos;
200};
201
202struct qxl_drm_chunk {
203 struct list_head head;
204 struct qxl_bo *bo;
205};
206
207struct qxl_drm_image {
208 struct qxl_bo *bo;
209 struct list_head chunk_list;
202}; 210};
203 211
204struct qxl_fb_image { 212struct qxl_fb_image {
@@ -314,6 +322,7 @@ struct qxl_device {
314 struct workqueue_struct *gc_queue; 322 struct workqueue_struct *gc_queue;
315 struct work_struct gc_work; 323 struct work_struct gc_work;
316 324
325 struct work_struct fb_work;
317}; 326};
318 327
319/* forward declaration for QXL_INFO_IO */ 328/* forward declaration for QXL_INFO_IO */
@@ -433,12 +442,19 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma);
433 442
434/* qxl image */ 443/* qxl image */
435 444
436int qxl_image_create(struct qxl_device *qdev, 445int qxl_image_init(struct qxl_device *qdev,
437 struct qxl_release *release, 446 struct qxl_release *release,
438 struct qxl_bo **image_bo, 447 struct qxl_drm_image *dimage,
439 const uint8_t *data, 448 const uint8_t *data,
440 int x, int y, int width, int height, 449 int x, int y, int width, int height,
441 int depth, int stride); 450 int depth, int stride);
451int
452qxl_image_alloc_objects(struct qxl_device *qdev,
453 struct qxl_release *release,
454 struct qxl_drm_image **image_ptr,
455 int height, int stride);
456void qxl_image_free_objects(struct qxl_device *qdev, struct qxl_drm_image *dimage);
457
442void qxl_update_screen(struct qxl_device *qxl); 458void qxl_update_screen(struct qxl_device *qxl);
443 459
444/* qxl io operations (qxl_cmd.c) */ 460/* qxl io operations (qxl_cmd.c) */
@@ -459,20 +475,15 @@ int qxl_ring_push(struct qxl_ring *ring, const void *new_elt, bool interruptible
459void qxl_io_flush_release(struct qxl_device *qdev); 475void qxl_io_flush_release(struct qxl_device *qdev);
460void qxl_io_flush_surfaces(struct qxl_device *qdev); 476void qxl_io_flush_surfaces(struct qxl_device *qdev);
461 477
462int qxl_release_reserve(struct qxl_device *qdev,
463 struct qxl_release *release, bool no_wait);
464void qxl_release_unreserve(struct qxl_device *qdev,
465 struct qxl_release *release);
466union qxl_release_info *qxl_release_map(struct qxl_device *qdev, 478union qxl_release_info *qxl_release_map(struct qxl_device *qdev,
467 struct qxl_release *release); 479 struct qxl_release *release);
468void qxl_release_unmap(struct qxl_device *qdev, 480void qxl_release_unmap(struct qxl_device *qdev,
469 struct qxl_release *release, 481 struct qxl_release *release,
470 union qxl_release_info *info); 482 union qxl_release_info *info);
471/* 483int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo);
472 * qxl_bo_add_resource. 484int qxl_release_reserve_list(struct qxl_release *release, bool no_intr);
473 * 485void qxl_release_backoff_reserve_list(struct qxl_release *release);
474 */ 486void qxl_release_fence_buffer_objects(struct qxl_release *release);
475void qxl_bo_add_resource(struct qxl_bo *main_bo, struct qxl_bo *resource);
476 487
477int qxl_alloc_surface_release_reserved(struct qxl_device *qdev, 488int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
478 enum qxl_surface_cmd_type surface_cmd_type, 489 enum qxl_surface_cmd_type surface_cmd_type,
@@ -481,15 +492,16 @@ int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
481int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size, 492int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
482 int type, struct qxl_release **release, 493 int type, struct qxl_release **release,
483 struct qxl_bo **rbo); 494 struct qxl_bo **rbo);
484int qxl_fence_releaseable(struct qxl_device *qdev, 495
485 struct qxl_release *release);
486int 496int
487qxl_push_command_ring_release(struct qxl_device *qdev, struct qxl_release *release, 497qxl_push_command_ring_release(struct qxl_device *qdev, struct qxl_release *release,
488 uint32_t type, bool interruptible); 498 uint32_t type, bool interruptible);
489int 499int
490qxl_push_cursor_ring_release(struct qxl_device *qdev, struct qxl_release *release, 500qxl_push_cursor_ring_release(struct qxl_device *qdev, struct qxl_release *release,
491 uint32_t type, bool interruptible); 501 uint32_t type, bool interruptible);
492int qxl_alloc_bo_reserved(struct qxl_device *qdev, unsigned long size, 502int qxl_alloc_bo_reserved(struct qxl_device *qdev,
503 struct qxl_release *release,
504 unsigned long size,
493 struct qxl_bo **_bo); 505 struct qxl_bo **_bo);
494/* qxl drawing commands */ 506/* qxl drawing commands */
495 507
@@ -510,15 +522,9 @@ void qxl_draw_copyarea(struct qxl_device *qdev,
510 u32 sx, u32 sy, 522 u32 sx, u32 sy,
511 u32 dx, u32 dy); 523 u32 dx, u32 dy);
512 524
513uint64_t
514qxl_release_alloc(struct qxl_device *qdev, int type,
515 struct qxl_release **ret);
516
517void qxl_release_free(struct qxl_device *qdev, 525void qxl_release_free(struct qxl_device *qdev,
518 struct qxl_release *release); 526 struct qxl_release *release);
519void qxl_release_add_res(struct qxl_device *qdev, 527
520 struct qxl_release *release,
521 struct qxl_bo *bo);
522/* used by qxl_debugfs_release */ 528/* used by qxl_debugfs_release */
523struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev, 529struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
524 uint64_t id); 530 uint64_t id);
@@ -561,7 +567,7 @@ void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool freein
561int qxl_update_surface(struct qxl_device *qdev, struct qxl_bo *surf); 567int qxl_update_surface(struct qxl_device *qdev, struct qxl_bo *surf);
562 568
563/* qxl_fence.c */ 569/* qxl_fence.c */
564int qxl_fence_add_release(struct qxl_fence *qfence, uint32_t rel_id); 570void qxl_fence_add_release_locked(struct qxl_fence *qfence, uint32_t rel_id);
565int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id); 571int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id);
566int qxl_fence_init(struct qxl_device *qdev, struct qxl_fence *qfence); 572int qxl_fence_init(struct qxl_device *qdev, struct qxl_fence *qfence);
567void qxl_fence_fini(struct qxl_fence *qfence); 573void qxl_fence_fini(struct qxl_fence *qfence);
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 76f39d88d684..88722f233430 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -37,12 +37,29 @@
37 37
38#define QXL_DIRTY_DELAY (HZ / 30) 38#define QXL_DIRTY_DELAY (HZ / 30)
39 39
40#define QXL_FB_OP_FILLRECT 1
41#define QXL_FB_OP_COPYAREA 2
42#define QXL_FB_OP_IMAGEBLIT 3
43
44struct qxl_fb_op {
45 struct list_head head;
46 int op_type;
47 union {
48 struct fb_fillrect fr;
49 struct fb_copyarea ca;
50 struct fb_image ib;
51 } op;
52 void *img_data;
53};
54
40struct qxl_fbdev { 55struct qxl_fbdev {
41 struct drm_fb_helper helper; 56 struct drm_fb_helper helper;
42 struct qxl_framebuffer qfb; 57 struct qxl_framebuffer qfb;
43 struct list_head fbdev_list; 58 struct list_head fbdev_list;
44 struct qxl_device *qdev; 59 struct qxl_device *qdev;
45 60
61 spinlock_t delayed_ops_lock;
62 struct list_head delayed_ops;
46 void *shadow; 63 void *shadow;
47 int size; 64 int size;
48 65
@@ -164,8 +181,69 @@ static struct fb_deferred_io qxl_defio = {
164 .deferred_io = qxl_deferred_io, 181 .deferred_io = qxl_deferred_io,
165}; 182};
166 183
167static void qxl_fb_fillrect(struct fb_info *info, 184static void qxl_fb_delayed_fillrect(struct qxl_fbdev *qfbdev,
168 const struct fb_fillrect *fb_rect) 185 const struct fb_fillrect *fb_rect)
186{
187 struct qxl_fb_op *op;
188 unsigned long flags;
189
190 op = kmalloc(sizeof(struct qxl_fb_op), GFP_ATOMIC | __GFP_NOWARN);
191 if (!op)
192 return;
193
194 op->op.fr = *fb_rect;
195 op->img_data = NULL;
196 op->op_type = QXL_FB_OP_FILLRECT;
197
198 spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
199 list_add_tail(&op->head, &qfbdev->delayed_ops);
200 spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
201}
202
203static void qxl_fb_delayed_copyarea(struct qxl_fbdev *qfbdev,
204 const struct fb_copyarea *fb_copy)
205{
206 struct qxl_fb_op *op;
207 unsigned long flags;
208
209 op = kmalloc(sizeof(struct qxl_fb_op), GFP_ATOMIC | __GFP_NOWARN);
210 if (!op)
211 return;
212
213 op->op.ca = *fb_copy;
214 op->img_data = NULL;
215 op->op_type = QXL_FB_OP_COPYAREA;
216
217 spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
218 list_add_tail(&op->head, &qfbdev->delayed_ops);
219 spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
220}
221
222static void qxl_fb_delayed_imageblit(struct qxl_fbdev *qfbdev,
223 const struct fb_image *fb_image)
224{
225 struct qxl_fb_op *op;
226 unsigned long flags;
227 uint32_t size = fb_image->width * fb_image->height * (fb_image->depth >= 8 ? fb_image->depth / 8 : 1);
228
229 op = kmalloc(sizeof(struct qxl_fb_op) + size, GFP_ATOMIC | __GFP_NOWARN);
230 if (!op)
231 return;
232
233 op->op.ib = *fb_image;
234 op->img_data = (void *)(op + 1);
235 op->op_type = QXL_FB_OP_IMAGEBLIT;
236
237 memcpy(op->img_data, fb_image->data, size);
238
239 op->op.ib.data = op->img_data;
240 spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
241 list_add_tail(&op->head, &qfbdev->delayed_ops);
242 spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
243}
244
245static void qxl_fb_fillrect_internal(struct fb_info *info,
246 const struct fb_fillrect *fb_rect)
169{ 247{
170 struct qxl_fbdev *qfbdev = info->par; 248 struct qxl_fbdev *qfbdev = info->par;
171 struct qxl_device *qdev = qfbdev->qdev; 249 struct qxl_device *qdev = qfbdev->qdev;
@@ -203,17 +281,28 @@ static void qxl_fb_fillrect(struct fb_info *info,
203 qxl_draw_fill_rec.rect = rect; 281 qxl_draw_fill_rec.rect = rect;
204 qxl_draw_fill_rec.color = color; 282 qxl_draw_fill_rec.color = color;
205 qxl_draw_fill_rec.rop = rop; 283 qxl_draw_fill_rec.rop = rop;
284
285 qxl_draw_fill(&qxl_draw_fill_rec);
286}
287
288static void qxl_fb_fillrect(struct fb_info *info,
289 const struct fb_fillrect *fb_rect)
290{
291 struct qxl_fbdev *qfbdev = info->par;
292 struct qxl_device *qdev = qfbdev->qdev;
293
206 if (!drm_can_sleep()) { 294 if (!drm_can_sleep()) {
207 qxl_io_log(qdev, 295 qxl_fb_delayed_fillrect(qfbdev, fb_rect);
208 "%s: TODO use RCU, mysterious locks with spin_lock\n", 296 schedule_work(&qdev->fb_work);
209 __func__);
210 return; 297 return;
211 } 298 }
212 qxl_draw_fill(&qxl_draw_fill_rec); 299 /* make sure any previous work is done */
300 flush_work(&qdev->fb_work);
301 qxl_fb_fillrect_internal(info, fb_rect);
213} 302}
214 303
215static void qxl_fb_copyarea(struct fb_info *info, 304static void qxl_fb_copyarea_internal(struct fb_info *info,
216 const struct fb_copyarea *region) 305 const struct fb_copyarea *region)
217{ 306{
218 struct qxl_fbdev *qfbdev = info->par; 307 struct qxl_fbdev *qfbdev = info->par;
219 308
@@ -223,37 +312,89 @@ static void qxl_fb_copyarea(struct fb_info *info,
223 region->dx, region->dy); 312 region->dx, region->dy);
224} 313}
225 314
315static void qxl_fb_copyarea(struct fb_info *info,
316 const struct fb_copyarea *region)
317{
318 struct qxl_fbdev *qfbdev = info->par;
319 struct qxl_device *qdev = qfbdev->qdev;
320
321 if (!drm_can_sleep()) {
322 qxl_fb_delayed_copyarea(qfbdev, region);
323 schedule_work(&qdev->fb_work);
324 return;
325 }
326 /* make sure any previous work is done */
327 flush_work(&qdev->fb_work);
328 qxl_fb_copyarea_internal(info, region);
329}
330
226static void qxl_fb_imageblit_safe(struct qxl_fb_image *qxl_fb_image) 331static void qxl_fb_imageblit_safe(struct qxl_fb_image *qxl_fb_image)
227{ 332{
228 qxl_draw_opaque_fb(qxl_fb_image, 0); 333 qxl_draw_opaque_fb(qxl_fb_image, 0);
229} 334}
230 335
336static void qxl_fb_imageblit_internal(struct fb_info *info,
337 const struct fb_image *image)
338{
339 struct qxl_fbdev *qfbdev = info->par;
340 struct qxl_fb_image qxl_fb_image;
341
342 /* ensure proper order rendering operations - TODO: must do this
343 * for everything. */
344 qxl_fb_image_init(&qxl_fb_image, qfbdev->qdev, info, image);
345 qxl_fb_imageblit_safe(&qxl_fb_image);
346}
347
231static void qxl_fb_imageblit(struct fb_info *info, 348static void qxl_fb_imageblit(struct fb_info *info,
232 const struct fb_image *image) 349 const struct fb_image *image)
233{ 350{
234 struct qxl_fbdev *qfbdev = info->par; 351 struct qxl_fbdev *qfbdev = info->par;
235 struct qxl_device *qdev = qfbdev->qdev; 352 struct qxl_device *qdev = qfbdev->qdev;
236 struct qxl_fb_image qxl_fb_image;
237 353
238 if (!drm_can_sleep()) { 354 if (!drm_can_sleep()) {
239 /* we cannot do any ttm_bo allocation since that will fail on 355 qxl_fb_delayed_imageblit(qfbdev, image);
240 * ioremap_wc..__get_vm_area_node, so queue the work item 356 schedule_work(&qdev->fb_work);
241 * instead This can happen from printk inside an interrupt
242 * context, i.e.: smp_apic_timer_interrupt..check_cpu_stall */
243 qxl_io_log(qdev,
244 "%s: TODO use RCU, mysterious locks with spin_lock\n",
245 __func__);
246 return; 357 return;
247 } 358 }
359 /* make sure any previous work is done */
360 flush_work(&qdev->fb_work);
361 qxl_fb_imageblit_internal(info, image);
362}
248 363
249 /* ensure proper order of rendering operations - TODO: must do this 364static void qxl_fb_work(struct work_struct *work)
250 * for everything. */ 365{
251 qxl_fb_image_init(&qxl_fb_image, qfbdev->qdev, info, image); 366 struct qxl_device *qdev = container_of(work, struct qxl_device, fb_work);
252 qxl_fb_imageblit_safe(&qxl_fb_image); 367 unsigned long flags;
368 struct qxl_fb_op *entry, *tmp;
369 struct qxl_fbdev *qfbdev = qdev->mode_info.qfbdev;
370
371 /* since the irq context just adds entries to the end of the
372 list dropping the lock should be fine, as entry isn't modified
373 in the operation code */
374 spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
375 list_for_each_entry_safe(entry, tmp, &qfbdev->delayed_ops, head) {
376 spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
377 switch (entry->op_type) {
378 case QXL_FB_OP_FILLRECT:
379 qxl_fb_fillrect_internal(qfbdev->helper.fbdev, &entry->op.fr);
380 break;
381 case QXL_FB_OP_COPYAREA:
382 qxl_fb_copyarea_internal(qfbdev->helper.fbdev, &entry->op.ca);
383 break;
384 case QXL_FB_OP_IMAGEBLIT:
385 qxl_fb_imageblit_internal(qfbdev->helper.fbdev, &entry->op.ib);
386 break;
387 }
388 spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
389 list_del(&entry->head);
390 kfree(entry);
391 }
392 spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
253} 393}
254 394
255int qxl_fb_init(struct qxl_device *qdev) 395int qxl_fb_init(struct qxl_device *qdev)
256{ 396{
397 INIT_WORK(&qdev->fb_work, qxl_fb_work);
257 return 0; 398 return 0;
258} 399}
259 400
@@ -536,7 +677,8 @@ int qxl_fbdev_init(struct qxl_device *qdev)
536 qfbdev->qdev = qdev; 677 qfbdev->qdev = qdev;
537 qdev->mode_info.qfbdev = qfbdev; 678 qdev->mode_info.qfbdev = qfbdev;
538 qfbdev->helper.funcs = &qxl_fb_helper_funcs; 679 qfbdev->helper.funcs = &qxl_fb_helper_funcs;
539 680 spin_lock_init(&qfbdev->delayed_ops_lock);
681 INIT_LIST_HEAD(&qfbdev->delayed_ops);
540 ret = drm_fb_helper_init(qdev->ddev, &qfbdev->helper, 682 ret = drm_fb_helper_init(qdev->ddev, &qfbdev->helper,
541 qxl_num_crtc /* num_crtc - QXL supports just 1 */, 683 qxl_num_crtc /* num_crtc - QXL supports just 1 */,
542 QXLFB_CONN_LIMIT); 684 QXLFB_CONN_LIMIT);
diff --git a/drivers/gpu/drm/qxl/qxl_fence.c b/drivers/gpu/drm/qxl/qxl_fence.c
index 63c6715ad385..ae59e91cfb9a 100644
--- a/drivers/gpu/drm/qxl/qxl_fence.c
+++ b/drivers/gpu/drm/qxl/qxl_fence.c
@@ -49,17 +49,11 @@
49 49
50 For some reason every so often qxl hw fails to release, things go wrong. 50 For some reason every so often qxl hw fails to release, things go wrong.
51*/ 51*/
52 52/* must be called with the fence lock held */
53 53void qxl_fence_add_release_locked(struct qxl_fence *qfence, uint32_t rel_id)
54int qxl_fence_add_release(struct qxl_fence *qfence, uint32_t rel_id)
55{ 54{
56 struct qxl_bo *bo = container_of(qfence, struct qxl_bo, fence);
57
58 spin_lock(&bo->tbo.bdev->fence_lock);
59 radix_tree_insert(&qfence->tree, rel_id, qfence); 55 radix_tree_insert(&qfence->tree, rel_id, qfence);
60 qfence->num_active_releases++; 56 qfence->num_active_releases++;
61 spin_unlock(&bo->tbo.bdev->fence_lock);
62 return 0;
63} 57}
64 58
65int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id) 59int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id)
diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
index a235693aabba..25e1777fb0a2 100644
--- a/drivers/gpu/drm/qxl/qxl_gem.c
+++ b/drivers/gpu/drm/qxl/qxl_gem.c
@@ -55,7 +55,7 @@ int qxl_gem_object_create(struct qxl_device *qdev, int size,
55 /* At least align on page size */ 55 /* At least align on page size */
56 if (alignment < PAGE_SIZE) 56 if (alignment < PAGE_SIZE)
57 alignment = PAGE_SIZE; 57 alignment = PAGE_SIZE;
58 r = qxl_bo_create(qdev, size, kernel, initial_domain, surf, &qbo); 58 r = qxl_bo_create(qdev, size, kernel, false, initial_domain, surf, &qbo);
59 if (r) { 59 if (r) {
60 if (r != -ERESTARTSYS) 60 if (r != -ERESTARTSYS)
61 DRM_ERROR( 61 DRM_ERROR(
diff --git a/drivers/gpu/drm/qxl/qxl_image.c b/drivers/gpu/drm/qxl/qxl_image.c
index cf856206996b..7fbcc35e8ad3 100644
--- a/drivers/gpu/drm/qxl/qxl_image.c
+++ b/drivers/gpu/drm/qxl/qxl_image.c
@@ -30,31 +30,100 @@
30#include "qxl_object.h" 30#include "qxl_object.h"
31 31
32static int 32static int
33qxl_image_create_helper(struct qxl_device *qdev, 33qxl_allocate_chunk(struct qxl_device *qdev,
34 struct qxl_release *release,
35 struct qxl_drm_image *image,
36 unsigned int chunk_size)
37{
38 struct qxl_drm_chunk *chunk;
39 int ret;
40
41 chunk = kmalloc(sizeof(struct qxl_drm_chunk), GFP_KERNEL);
42 if (!chunk)
43 return -ENOMEM;
44
45 ret = qxl_alloc_bo_reserved(qdev, release, chunk_size, &chunk->bo);
46 if (ret) {
47 kfree(chunk);
48 return ret;
49 }
50
51 list_add_tail(&chunk->head, &image->chunk_list);
52 return 0;
53}
54
55int
56qxl_image_alloc_objects(struct qxl_device *qdev,
34 struct qxl_release *release, 57 struct qxl_release *release,
35 struct qxl_bo **image_bo, 58 struct qxl_drm_image **image_ptr,
36 const uint8_t *data, 59 int height, int stride)
37 int width, int height, 60{
38 int depth, unsigned int hash, 61 struct qxl_drm_image *image;
39 int stride) 62 int ret;
63
64 image = kmalloc(sizeof(struct qxl_drm_image), GFP_KERNEL);
65 if (!image)
66 return -ENOMEM;
67
68 INIT_LIST_HEAD(&image->chunk_list);
69
70 ret = qxl_alloc_bo_reserved(qdev, release, sizeof(struct qxl_image), &image->bo);
71 if (ret) {
72 kfree(image);
73 return ret;
74 }
75
76 ret = qxl_allocate_chunk(qdev, release, image, sizeof(struct qxl_data_chunk) + stride * height);
77 if (ret) {
78 qxl_bo_unref(&image->bo);
79 kfree(image);
80 return ret;
81 }
82 *image_ptr = image;
83 return 0;
84}
85
86void qxl_image_free_objects(struct qxl_device *qdev, struct qxl_drm_image *dimage)
40{ 87{
88 struct qxl_drm_chunk *chunk, *tmp;
89
90 list_for_each_entry_safe(chunk, tmp, &dimage->chunk_list, head) {
91 qxl_bo_unref(&chunk->bo);
92 kfree(chunk);
93 }
94
95 qxl_bo_unref(&dimage->bo);
96 kfree(dimage);
97}
98
99static int
100qxl_image_init_helper(struct qxl_device *qdev,
101 struct qxl_release *release,
102 struct qxl_drm_image *dimage,
103 const uint8_t *data,
104 int width, int height,
105 int depth, unsigned int hash,
106 int stride)
107{
108 struct qxl_drm_chunk *drv_chunk;
41 struct qxl_image *image; 109 struct qxl_image *image;
42 struct qxl_data_chunk *chunk; 110 struct qxl_data_chunk *chunk;
43 int i; 111 int i;
44 int chunk_stride; 112 int chunk_stride;
45 int linesize = width * depth / 8; 113 int linesize = width * depth / 8;
46 struct qxl_bo *chunk_bo; 114 struct qxl_bo *chunk_bo, *image_bo;
47 int ret;
48 void *ptr; 115 void *ptr;
49 /* Chunk */ 116 /* Chunk */
50 /* FIXME: Check integer overflow */ 117 /* FIXME: Check integer overflow */
51 /* TODO: variable number of chunks */ 118 /* TODO: variable number of chunks */
119
120 drv_chunk = list_first_entry(&dimage->chunk_list, struct qxl_drm_chunk, head);
121
122 chunk_bo = drv_chunk->bo;
52 chunk_stride = stride; /* TODO: should use linesize, but it renders 123 chunk_stride = stride; /* TODO: should use linesize, but it renders
53 wrong (check the bitmaps are sent correctly 124 wrong (check the bitmaps are sent correctly
54 first) */ 125 first) */
55 ret = qxl_alloc_bo_reserved(qdev, sizeof(*chunk) + height * chunk_stride, 126
56 &chunk_bo);
57
58 ptr = qxl_bo_kmap_atomic_page(qdev, chunk_bo, 0); 127 ptr = qxl_bo_kmap_atomic_page(qdev, chunk_bo, 0);
59 chunk = ptr; 128 chunk = ptr;
60 chunk->data_size = height * chunk_stride; 129 chunk->data_size = height * chunk_stride;
@@ -102,7 +171,6 @@ qxl_image_create_helper(struct qxl_device *qdev,
102 while (remain > 0) { 171 while (remain > 0) {
103 page_base = out_offset & PAGE_MASK; 172 page_base = out_offset & PAGE_MASK;
104 page_offset = offset_in_page(out_offset); 173 page_offset = offset_in_page(out_offset);
105
106 size = min((int)(PAGE_SIZE - page_offset), remain); 174 size = min((int)(PAGE_SIZE - page_offset), remain);
107 175
108 ptr = qxl_bo_kmap_atomic_page(qdev, chunk_bo, page_base); 176 ptr = qxl_bo_kmap_atomic_page(qdev, chunk_bo, page_base);
@@ -116,14 +184,10 @@ qxl_image_create_helper(struct qxl_device *qdev,
116 } 184 }
117 } 185 }
118 } 186 }
119
120
121 qxl_bo_kunmap(chunk_bo); 187 qxl_bo_kunmap(chunk_bo);
122 188
123 /* Image */ 189 image_bo = dimage->bo;
124 ret = qxl_alloc_bo_reserved(qdev, sizeof(*image), image_bo); 190 ptr = qxl_bo_kmap_atomic_page(qdev, image_bo, 0);
125
126 ptr = qxl_bo_kmap_atomic_page(qdev, *image_bo, 0);
127 image = ptr; 191 image = ptr;
128 192
129 image->descriptor.id = 0; 193 image->descriptor.id = 0;
@@ -154,23 +218,20 @@ qxl_image_create_helper(struct qxl_device *qdev,
154 image->u.bitmap.stride = chunk_stride; 218 image->u.bitmap.stride = chunk_stride;
155 image->u.bitmap.palette = 0; 219 image->u.bitmap.palette = 0;
156 image->u.bitmap.data = qxl_bo_physical_address(qdev, chunk_bo, 0); 220 image->u.bitmap.data = qxl_bo_physical_address(qdev, chunk_bo, 0);
157 qxl_release_add_res(qdev, release, chunk_bo);
158 qxl_bo_unreserve(chunk_bo);
159 qxl_bo_unref(&chunk_bo);
160 221
161 qxl_bo_kunmap_atomic_page(qdev, *image_bo, ptr); 222 qxl_bo_kunmap_atomic_page(qdev, image_bo, ptr);
162 223
163 return 0; 224 return 0;
164} 225}
165 226
166int qxl_image_create(struct qxl_device *qdev, 227int qxl_image_init(struct qxl_device *qdev,
167 struct qxl_release *release, 228 struct qxl_release *release,
168 struct qxl_bo **image_bo, 229 struct qxl_drm_image *dimage,
169 const uint8_t *data, 230 const uint8_t *data,
170 int x, int y, int width, int height, 231 int x, int y, int width, int height,
171 int depth, int stride) 232 int depth, int stride)
172{ 233{
173 data += y * stride + x * (depth / 8); 234 data += y * stride + x * (depth / 8);
174 return qxl_image_create_helper(qdev, release, image_bo, data, 235 return qxl_image_init_helper(qdev, release, dimage, data,
175 width, height, depth, 0, stride); 236 width, height, depth, 0, stride);
176} 237}
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 27f45e49250d..6de33563d6f1 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -68,55 +68,60 @@ static int qxl_map_ioctl(struct drm_device *dev, void *data,
68 &qxl_map->offset); 68 &qxl_map->offset);
69} 69}
70 70
71struct qxl_reloc_info {
72 int type;
73 struct qxl_bo *dst_bo;
74 uint32_t dst_offset;
75 struct qxl_bo *src_bo;
76 int src_offset;
77};
78
71/* 79/*
72 * dst must be validated, i.e. whole bo on vram/surfacesram (right now all bo's 80 * dst must be validated, i.e. whole bo on vram/surfacesram (right now all bo's
73 * are on vram). 81 * are on vram).
74 * *(dst + dst_off) = qxl_bo_physical_address(src, src_off) 82 * *(dst + dst_off) = qxl_bo_physical_address(src, src_off)
75 */ 83 */
76static void 84static void
77apply_reloc(struct qxl_device *qdev, struct qxl_bo *dst, uint64_t dst_off, 85apply_reloc(struct qxl_device *qdev, struct qxl_reloc_info *info)
78 struct qxl_bo *src, uint64_t src_off)
79{ 86{
80 void *reloc_page; 87 void *reloc_page;
81 88 reloc_page = qxl_bo_kmap_atomic_page(qdev, info->dst_bo, info->dst_offset & PAGE_MASK);
82 reloc_page = qxl_bo_kmap_atomic_page(qdev, dst, dst_off & PAGE_MASK); 89 *(uint64_t *)(reloc_page + (info->dst_offset & ~PAGE_MASK)) = qxl_bo_physical_address(qdev,
83 *(uint64_t *)(reloc_page + (dst_off & ~PAGE_MASK)) = qxl_bo_physical_address(qdev, 90 info->src_bo,
84 src, src_off); 91 info->src_offset);
85 qxl_bo_kunmap_atomic_page(qdev, dst, reloc_page); 92 qxl_bo_kunmap_atomic_page(qdev, info->dst_bo, reloc_page);
86} 93}
87 94
88static void 95static void
89apply_surf_reloc(struct qxl_device *qdev, struct qxl_bo *dst, uint64_t dst_off, 96apply_surf_reloc(struct qxl_device *qdev, struct qxl_reloc_info *info)
90 struct qxl_bo *src)
91{ 97{
92 uint32_t id = 0; 98 uint32_t id = 0;
93 void *reloc_page; 99 void *reloc_page;
94 100
95 if (src && !src->is_primary) 101 if (info->src_bo && !info->src_bo->is_primary)
96 id = src->surface_id; 102 id = info->src_bo->surface_id;
97 103
98 reloc_page = qxl_bo_kmap_atomic_page(qdev, dst, dst_off & PAGE_MASK); 104 reloc_page = qxl_bo_kmap_atomic_page(qdev, info->dst_bo, info->dst_offset & PAGE_MASK);
99 *(uint32_t *)(reloc_page + (dst_off & ~PAGE_MASK)) = id; 105 *(uint32_t *)(reloc_page + (info->dst_offset & ~PAGE_MASK)) = id;
100 qxl_bo_kunmap_atomic_page(qdev, dst, reloc_page); 106 qxl_bo_kunmap_atomic_page(qdev, info->dst_bo, reloc_page);
101} 107}
102 108
103/* return holding the reference to this object */ 109/* return holding the reference to this object */
104static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev, 110static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev,
105 struct drm_file *file_priv, uint64_t handle, 111 struct drm_file *file_priv, uint64_t handle,
106 struct qxl_reloc_list *reloc_list) 112 struct qxl_release *release)
107{ 113{
108 struct drm_gem_object *gobj; 114 struct drm_gem_object *gobj;
109 struct qxl_bo *qobj; 115 struct qxl_bo *qobj;
110 int ret; 116 int ret;
111 117
112 gobj = drm_gem_object_lookup(qdev->ddev, file_priv, handle); 118 gobj = drm_gem_object_lookup(qdev->ddev, file_priv, handle);
113 if (!gobj) { 119 if (!gobj)
114 DRM_ERROR("bad bo handle %lld\n", handle);
115 return NULL; 120 return NULL;
116 } 121
117 qobj = gem_to_qxl_bo(gobj); 122 qobj = gem_to_qxl_bo(gobj);
118 123
119 ret = qxl_bo_list_add(reloc_list, qobj); 124 ret = qxl_release_list_add(release, qobj);
120 if (ret) 125 if (ret)
121 return NULL; 126 return NULL;
122 127
@@ -129,151 +134,177 @@ static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev,
129 * However, the command as passed from user space must *not* contain the initial 134 * However, the command as passed from user space must *not* contain the initial
130 * QXLReleaseInfo struct (first XXX bytes) 135 * QXLReleaseInfo struct (first XXX bytes)
131 */ 136 */
132static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, 137static int qxl_process_single_command(struct qxl_device *qdev,
133 struct drm_file *file_priv) 138 struct drm_qxl_command *cmd,
139 struct drm_file *file_priv)
134{ 140{
135 struct qxl_device *qdev = dev->dev_private; 141 struct qxl_reloc_info *reloc_info;
136 struct drm_qxl_execbuffer *execbuffer = data; 142 int release_type;
137 struct drm_qxl_command user_cmd; 143 struct qxl_release *release;
138 int cmd_num; 144 struct qxl_bo *cmd_bo;
139 struct qxl_bo *reloc_src_bo;
140 struct qxl_bo *reloc_dst_bo;
141 struct drm_qxl_reloc reloc;
142 void *fb_cmd; 145 void *fb_cmd;
143 int i, ret; 146 int i, j, ret, num_relocs;
144 struct qxl_reloc_list reloc_list;
145 int unwritten; 147 int unwritten;
146 uint32_t reloc_dst_offset;
147 INIT_LIST_HEAD(&reloc_list.bos);
148 148
149 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) { 149 switch (cmd->type) {
150 struct qxl_release *release; 150 case QXL_CMD_DRAW:
151 struct qxl_bo *cmd_bo; 151 release_type = QXL_RELEASE_DRAWABLE;
152 int release_type; 152 break;
153 struct drm_qxl_command *commands = 153 case QXL_CMD_SURFACE:
154 (struct drm_qxl_command *)(uintptr_t)execbuffer->commands; 154 case QXL_CMD_CURSOR:
155 default:
156 DRM_DEBUG("Only draw commands in execbuffers\n");
157 return -EINVAL;
158 break;
159 }
155 160
156 if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num], 161 if (cmd->command_size > PAGE_SIZE - sizeof(union qxl_release_info))
157 sizeof(user_cmd))) 162 return -EINVAL;
158 return -EFAULT;
159 switch (user_cmd.type) {
160 case QXL_CMD_DRAW:
161 release_type = QXL_RELEASE_DRAWABLE;
162 break;
163 case QXL_CMD_SURFACE:
164 case QXL_CMD_CURSOR:
165 default:
166 DRM_DEBUG("Only draw commands in execbuffers\n");
167 return -EINVAL;
168 break;
169 }
170 163
171 if (user_cmd.command_size > PAGE_SIZE - sizeof(union qxl_release_info)) 164 if (!access_ok(VERIFY_READ,
172 return -EINVAL; 165 (void *)(unsigned long)cmd->command,
166 cmd->command_size))
167 return -EFAULT;
173 168
174 if (!access_ok(VERIFY_READ, 169 reloc_info = kmalloc(sizeof(struct qxl_reloc_info) * cmd->relocs_num, GFP_KERNEL);
175 (void *)(unsigned long)user_cmd.command, 170 if (!reloc_info)
176 user_cmd.command_size)) 171 return -ENOMEM;
177 return -EFAULT;
178 172
179 ret = qxl_alloc_release_reserved(qdev, 173 ret = qxl_alloc_release_reserved(qdev,
180 sizeof(union qxl_release_info) + 174 sizeof(union qxl_release_info) +
181 user_cmd.command_size, 175 cmd->command_size,
182 release_type, 176 release_type,
183 &release, 177 &release,
184 &cmd_bo); 178 &cmd_bo);
185 if (ret) 179 if (ret)
186 return ret; 180 goto out_free_reloc;
187 181
188 /* TODO copy slow path code from i915 */ 182 /* TODO copy slow path code from i915 */
189 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE)); 183 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
190 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); 184 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);
191 185
192 { 186 {
193 struct qxl_drawable *draw = fb_cmd; 187 struct qxl_drawable *draw = fb_cmd;
188 draw->mm_time = qdev->rom->mm_clock;
189 }
194 190
195 draw->mm_time = qdev->rom->mm_clock; 191 qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd);
196 } 192 if (unwritten) {
197 qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd); 193 DRM_ERROR("got unwritten %d\n", unwritten);
198 if (unwritten) { 194 ret = -EFAULT;
199 DRM_ERROR("got unwritten %d\n", unwritten); 195 goto out_free_release;
200 qxl_release_unreserve(qdev, release); 196 }
201 qxl_release_free(qdev, release); 197
202 return -EFAULT; 198 /* fill out reloc info structs */
199 num_relocs = 0;
200 for (i = 0; i < cmd->relocs_num; ++i) {
201 struct drm_qxl_reloc reloc;
202
203 if (DRM_COPY_FROM_USER(&reloc,
204 &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
205 sizeof(reloc))) {
206 ret = -EFAULT;
207 goto out_free_bos;
203 } 208 }
204 209
205 for (i = 0 ; i < user_cmd.relocs_num; ++i) { 210 /* add the bos to the list of bos to validate -
206 if (DRM_COPY_FROM_USER(&reloc, 211 need to validate first then process relocs? */
207 &((struct drm_qxl_reloc *)(uintptr_t)user_cmd.relocs)[i], 212 if (reloc.reloc_type != QXL_RELOC_TYPE_BO && reloc.reloc_type != QXL_RELOC_TYPE_SURF) {
208 sizeof(reloc))) { 213 DRM_DEBUG("unknown reloc type %d\n", reloc_info[i].type);
209 qxl_bo_list_unreserve(&reloc_list, true);
210 qxl_release_unreserve(qdev, release);
211 qxl_release_free(qdev, release);
212 return -EFAULT;
213 }
214 214
215 /* add the bos to the list of bos to validate - 215 ret = -EINVAL;
216 need to validate first then process relocs? */ 216 goto out_free_bos;
217 if (reloc.dst_handle) { 217 }
218 reloc_dst_bo = qxlhw_handle_to_bo(qdev, file_priv, 218 reloc_info[i].type = reloc.reloc_type;
219 reloc.dst_handle, &reloc_list); 219
220 if (!reloc_dst_bo) { 220 if (reloc.dst_handle) {
221 qxl_bo_list_unreserve(&reloc_list, true); 221 reloc_info[i].dst_bo = qxlhw_handle_to_bo(qdev, file_priv,
222 qxl_release_unreserve(qdev, release); 222 reloc.dst_handle, release);
223 qxl_release_free(qdev, release); 223 if (!reloc_info[i].dst_bo) {
224 return -EINVAL; 224 ret = -EINVAL;
225 } 225 reloc_info[i].src_bo = NULL;
226 reloc_dst_offset = 0; 226 goto out_free_bos;
227 } else {
228 reloc_dst_bo = cmd_bo;
229 reloc_dst_offset = release->release_offset;
230 } 227 }
231 228 reloc_info[i].dst_offset = reloc.dst_offset;
232 /* reserve and validate the reloc dst bo */ 229 } else {
233 if (reloc.reloc_type == QXL_RELOC_TYPE_BO || reloc.src_handle > 0) { 230 reloc_info[i].dst_bo = cmd_bo;
234 reloc_src_bo = 231 reloc_info[i].dst_offset = reloc.dst_offset + release->release_offset;
235 qxlhw_handle_to_bo(qdev, file_priv, 232 }
236 reloc.src_handle, &reloc_list); 233 num_relocs++;
237 if (!reloc_src_bo) { 234
238 if (reloc_dst_bo != cmd_bo) 235 /* reserve and validate the reloc dst bo */
239 drm_gem_object_unreference_unlocked(&reloc_dst_bo->gem_base); 236 if (reloc.reloc_type == QXL_RELOC_TYPE_BO || reloc.src_handle > 0) {
240 qxl_bo_list_unreserve(&reloc_list, true); 237 reloc_info[i].src_bo =
241 qxl_release_unreserve(qdev, release); 238 qxlhw_handle_to_bo(qdev, file_priv,
242 qxl_release_free(qdev, release); 239 reloc.src_handle, release);
243 return -EINVAL; 240 if (!reloc_info[i].src_bo) {
244 } 241 if (reloc_info[i].dst_bo != cmd_bo)
245 } else 242 drm_gem_object_unreference_unlocked(&reloc_info[i].dst_bo->gem_base);
246 reloc_src_bo = NULL; 243 ret = -EINVAL;
247 if (reloc.reloc_type == QXL_RELOC_TYPE_BO) { 244 goto out_free_bos;
248 apply_reloc(qdev, reloc_dst_bo, reloc_dst_offset + reloc.dst_offset,
249 reloc_src_bo, reloc.src_offset);
250 } else if (reloc.reloc_type == QXL_RELOC_TYPE_SURF) {
251 apply_surf_reloc(qdev, reloc_dst_bo, reloc_dst_offset + reloc.dst_offset, reloc_src_bo);
252 } else {
253 DRM_ERROR("unknown reloc type %d\n", reloc.reloc_type);
254 return -EINVAL;
255 } 245 }
246 reloc_info[i].src_offset = reloc.src_offset;
247 } else {
248 reloc_info[i].src_bo = NULL;
249 reloc_info[i].src_offset = 0;
250 }
251 }
256 252
257 if (reloc_src_bo && reloc_src_bo != cmd_bo) { 253 /* validate all buffers */
258 qxl_release_add_res(qdev, release, reloc_src_bo); 254 ret = qxl_release_reserve_list(release, false);
259 drm_gem_object_unreference_unlocked(&reloc_src_bo->gem_base); 255 if (ret)
260 } 256 goto out_free_bos;
261 257
262 if (reloc_dst_bo != cmd_bo) 258 for (i = 0; i < cmd->relocs_num; ++i) {
263 drm_gem_object_unreference_unlocked(&reloc_dst_bo->gem_base); 259 if (reloc_info[i].type == QXL_RELOC_TYPE_BO)
264 } 260 apply_reloc(qdev, &reloc_info[i]);
265 qxl_fence_releaseable(qdev, release); 261 else if (reloc_info[i].type == QXL_RELOC_TYPE_SURF)
262 apply_surf_reloc(qdev, &reloc_info[i]);
263 }
266 264
267 ret = qxl_push_command_ring_release(qdev, release, user_cmd.type, true); 265 ret = qxl_push_command_ring_release(qdev, release, cmd->type, true);
268 if (ret == -ERESTARTSYS) { 266 if (ret)
269 qxl_release_unreserve(qdev, release); 267 qxl_release_backoff_reserve_list(release);
270 qxl_release_free(qdev, release); 268 else
271 qxl_bo_list_unreserve(&reloc_list, true); 269 qxl_release_fence_buffer_objects(release);
270
271out_free_bos:
272 for (j = 0; j < num_relocs; j++) {
273 if (reloc_info[j].dst_bo != cmd_bo)
274 drm_gem_object_unreference_unlocked(&reloc_info[j].dst_bo->gem_base);
275 if (reloc_info[j].src_bo && reloc_info[j].src_bo != cmd_bo)
276 drm_gem_object_unreference_unlocked(&reloc_info[j].src_bo->gem_base);
277 }
278out_free_release:
279 if (ret)
280 qxl_release_free(qdev, release);
281out_free_reloc:
282 kfree(reloc_info);
283 return ret;
284}
285
286static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
287 struct drm_file *file_priv)
288{
289 struct qxl_device *qdev = dev->dev_private;
290 struct drm_qxl_execbuffer *execbuffer = data;
291 struct drm_qxl_command user_cmd;
292 int cmd_num;
293 int ret;
294
295 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
296
297 struct drm_qxl_command *commands =
298 (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
299
300 if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num],
301 sizeof(user_cmd)))
302 return -EFAULT;
303
304 ret = qxl_process_single_command(qdev, &user_cmd, file_priv);
305 if (ret)
272 return ret; 306 return ret;
273 }
274 qxl_release_unreserve(qdev, release);
275 } 307 }
276 qxl_bo_list_unreserve(&reloc_list, 0);
277 return 0; 308 return 0;
278} 309}
279 310
@@ -305,7 +336,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
305 goto out; 336 goto out;
306 337
307 if (!qobj->pin_count) { 338 if (!qobj->pin_count) {
308 qxl_ttm_placement_from_domain(qobj, qobj->type); 339 qxl_ttm_placement_from_domain(qobj, qobj->type, false);
309 ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, 340 ret = ttm_bo_validate(&qobj->tbo, &qobj->placement,
310 true, false); 341 true, false);
311 if (unlikely(ret)) 342 if (unlikely(ret))
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 1191fe7788c9..aa161cddd87e 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -51,20 +51,21 @@ bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo)
51 return false; 51 return false;
52} 52}
53 53
54void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain) 54void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned)
55{ 55{
56 u32 c = 0; 56 u32 c = 0;
57 u32 pflag = pinned ? TTM_PL_FLAG_NO_EVICT : 0;
57 58
58 qbo->placement.fpfn = 0; 59 qbo->placement.fpfn = 0;
59 qbo->placement.lpfn = 0; 60 qbo->placement.lpfn = 0;
60 qbo->placement.placement = qbo->placements; 61 qbo->placement.placement = qbo->placements;
61 qbo->placement.busy_placement = qbo->placements; 62 qbo->placement.busy_placement = qbo->placements;
62 if (domain == QXL_GEM_DOMAIN_VRAM) 63 if (domain == QXL_GEM_DOMAIN_VRAM)
63 qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_VRAM; 64 qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_VRAM | pflag;
64 if (domain == QXL_GEM_DOMAIN_SURFACE) 65 if (domain == QXL_GEM_DOMAIN_SURFACE)
65 qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_PRIV0; 66 qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_PRIV0 | pflag;
66 if (domain == QXL_GEM_DOMAIN_CPU) 67 if (domain == QXL_GEM_DOMAIN_CPU)
67 qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM; 68 qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | pflag;
68 if (!c) 69 if (!c)
69 qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM; 70 qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
70 qbo->placement.num_placement = c; 71 qbo->placement.num_placement = c;
@@ -73,7 +74,7 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain)
73 74
74 75
75int qxl_bo_create(struct qxl_device *qdev, 76int qxl_bo_create(struct qxl_device *qdev,
76 unsigned long size, bool kernel, u32 domain, 77 unsigned long size, bool kernel, bool pinned, u32 domain,
77 struct qxl_surface *surf, 78 struct qxl_surface *surf,
78 struct qxl_bo **bo_ptr) 79 struct qxl_bo **bo_ptr)
79{ 80{
@@ -99,15 +100,15 @@ int qxl_bo_create(struct qxl_device *qdev,
99 } 100 }
100 bo->gem_base.driver_private = NULL; 101 bo->gem_base.driver_private = NULL;
101 bo->type = domain; 102 bo->type = domain;
102 bo->pin_count = 0; 103 bo->pin_count = pinned ? 1 : 0;
103 bo->surface_id = 0; 104 bo->surface_id = 0;
104 qxl_fence_init(qdev, &bo->fence); 105 qxl_fence_init(qdev, &bo->fence);
105 INIT_LIST_HEAD(&bo->list); 106 INIT_LIST_HEAD(&bo->list);
106 atomic_set(&bo->reserve_count, 0); 107
107 if (surf) 108 if (surf)
108 bo->surf = *surf; 109 bo->surf = *surf;
109 110
110 qxl_ttm_placement_from_domain(bo, domain); 111 qxl_ttm_placement_from_domain(bo, domain, pinned);
111 112
112 r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type, 113 r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
113 &bo->placement, 0, !kernel, NULL, size, 114 &bo->placement, 0, !kernel, NULL, size,
@@ -228,7 +229,7 @@ struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo)
228int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr) 229int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr)
229{ 230{
230 struct qxl_device *qdev = (struct qxl_device *)bo->gem_base.dev->dev_private; 231 struct qxl_device *qdev = (struct qxl_device *)bo->gem_base.dev->dev_private;
231 int r, i; 232 int r;
232 233
233 if (bo->pin_count) { 234 if (bo->pin_count) {
234 bo->pin_count++; 235 bo->pin_count++;
@@ -236,9 +237,7 @@ int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr)
236 *gpu_addr = qxl_bo_gpu_offset(bo); 237 *gpu_addr = qxl_bo_gpu_offset(bo);
237 return 0; 238 return 0;
238 } 239 }
239 qxl_ttm_placement_from_domain(bo, domain); 240 qxl_ttm_placement_from_domain(bo, domain, true);
240 for (i = 0; i < bo->placement.num_placement; i++)
241 bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
242 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 241 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
243 if (likely(r == 0)) { 242 if (likely(r == 0)) {
244 bo->pin_count = 1; 243 bo->pin_count = 1;
@@ -317,53 +316,6 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo)
317 return 0; 316 return 0;
318} 317}
319 318
320void qxl_bo_list_unreserve(struct qxl_reloc_list *reloc_list, bool failed)
321{
322 struct qxl_bo_list *entry, *sf;
323
324 list_for_each_entry_safe(entry, sf, &reloc_list->bos, lhead) {
325 qxl_bo_unreserve(entry->bo);
326 list_del(&entry->lhead);
327 kfree(entry);
328 }
329}
330
331int qxl_bo_list_add(struct qxl_reloc_list *reloc_list, struct qxl_bo *bo)
332{
333 struct qxl_bo_list *entry;
334 int ret;
335
336 list_for_each_entry(entry, &reloc_list->bos, lhead) {
337 if (entry->bo == bo)
338 return 0;
339 }
340
341 entry = kmalloc(sizeof(struct qxl_bo_list), GFP_KERNEL);
342 if (!entry)
343 return -ENOMEM;
344
345 entry->bo = bo;
346 list_add(&entry->lhead, &reloc_list->bos);
347
348 ret = qxl_bo_reserve(bo, false);
349 if (ret)
350 return ret;
351
352 if (!bo->pin_count) {
353 qxl_ttm_placement_from_domain(bo, bo->type);
354 ret = ttm_bo_validate(&bo->tbo, &bo->placement,
355 true, false);
356 if (ret)
357 return ret;
358 }
359
360 /* allocate a surface for reserved + validated buffers */
361 ret = qxl_bo_check_id(bo->gem_base.dev->dev_private, bo);
362 if (ret)
363 return ret;
364 return 0;
365}
366
367int qxl_surf_evict(struct qxl_device *qdev) 319int qxl_surf_evict(struct qxl_device *qdev)
368{ 320{
369 return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV0); 321 return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV0);
diff --git a/drivers/gpu/drm/qxl/qxl_object.h b/drivers/gpu/drm/qxl/qxl_object.h
index ee7ad79ce781..8cb6167038e5 100644
--- a/drivers/gpu/drm/qxl/qxl_object.h
+++ b/drivers/gpu/drm/qxl/qxl_object.h
@@ -88,7 +88,7 @@ static inline int qxl_bo_wait(struct qxl_bo *bo, u32 *mem_type,
88 88
89extern int qxl_bo_create(struct qxl_device *qdev, 89extern int qxl_bo_create(struct qxl_device *qdev,
90 unsigned long size, 90 unsigned long size,
91 bool kernel, u32 domain, 91 bool kernel, bool pinned, u32 domain,
92 struct qxl_surface *surf, 92 struct qxl_surface *surf,
93 struct qxl_bo **bo_ptr); 93 struct qxl_bo **bo_ptr);
94extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr); 94extern 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);
99extern void qxl_bo_unref(struct qxl_bo **bo); 99extern void qxl_bo_unref(struct qxl_bo **bo);
100extern int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr); 100extern int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr);
101extern int qxl_bo_unpin(struct qxl_bo *bo); 101extern int qxl_bo_unpin(struct qxl_bo *bo);
102extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain); 102extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned);
103extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo); 103extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
104 104
105extern int qxl_bo_list_add(struct qxl_reloc_list *reloc_list, struct qxl_bo *bo);
106extern void qxl_bo_list_unreserve(struct qxl_reloc_list *reloc_list, bool failed);
107#endif 105#endif
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index b443d6751d5f..b61449e52cd5 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -38,7 +38,8 @@
38 38
39static const int release_size_per_bo[] = { RELEASE_SIZE, SURFACE_RELEASE_SIZE, RELEASE_SIZE }; 39static const int release_size_per_bo[] = { RELEASE_SIZE, SURFACE_RELEASE_SIZE, RELEASE_SIZE };
40static const int releases_per_bo[] = { RELEASES_PER_BO, SURFACE_RELEASES_PER_BO, RELEASES_PER_BO }; 40static const int releases_per_bo[] = { RELEASES_PER_BO, SURFACE_RELEASES_PER_BO, RELEASES_PER_BO };
41uint64_t 41
42static uint64_t
42qxl_release_alloc(struct qxl_device *qdev, int type, 43qxl_release_alloc(struct qxl_device *qdev, int type,
43 struct qxl_release **ret) 44 struct qxl_release **ret)
44{ 45{
@@ -53,9 +54,9 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
53 return 0; 54 return 0;
54 } 55 }
55 release->type = type; 56 release->type = type;
56 release->bo_count = 0;
57 release->release_offset = 0; 57 release->release_offset = 0;
58 release->surface_release_id = 0; 58 release->surface_release_id = 0;
59 INIT_LIST_HEAD(&release->bos);
59 60
60 idr_preload(GFP_KERNEL); 61 idr_preload(GFP_KERNEL);
61 spin_lock(&qdev->release_idr_lock); 62 spin_lock(&qdev->release_idr_lock);
@@ -77,20 +78,20 @@ void
77qxl_release_free(struct qxl_device *qdev, 78qxl_release_free(struct qxl_device *qdev,
78 struct qxl_release *release) 79 struct qxl_release *release)
79{ 80{
80 int i; 81 struct qxl_bo_list *entry, *tmp;
81 82 QXL_INFO(qdev, "release %d, type %d\n", release->id,
82 QXL_INFO(qdev, "release %d, type %d, %d bos\n", release->id, 83 release->type);
83 release->type, release->bo_count);
84 84
85 if (release->surface_release_id) 85 if (release->surface_release_id)
86 qxl_surface_id_dealloc(qdev, release->surface_release_id); 86 qxl_surface_id_dealloc(qdev, release->surface_release_id);
87 87
88 for (i = 0 ; i < release->bo_count; ++i) { 88 list_for_each_entry_safe(entry, tmp, &release->bos, tv.head) {
89 struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
89 QXL_INFO(qdev, "release %llx\n", 90 QXL_INFO(qdev, "release %llx\n",
90 release->bos[i]->tbo.addr_space_offset 91 entry->tv.bo->addr_space_offset
91 - DRM_FILE_OFFSET); 92 - DRM_FILE_OFFSET);
92 qxl_fence_remove_release(&release->bos[i]->fence, release->id); 93 qxl_fence_remove_release(&bo->fence, release->id);
93 qxl_bo_unref(&release->bos[i]); 94 qxl_bo_unref(&bo);
94 } 95 }
95 spin_lock(&qdev->release_idr_lock); 96 spin_lock(&qdev->release_idr_lock);
96 idr_remove(&qdev->release_idr, release->id); 97 idr_remove(&qdev->release_idr, release->id);
@@ -98,83 +99,117 @@ qxl_release_free(struct qxl_device *qdev,
98 kfree(release); 99 kfree(release);
99} 100}
100 101
101void
102qxl_release_add_res(struct qxl_device *qdev, struct qxl_release *release,
103 struct qxl_bo *bo)
104{
105 int i;
106 for (i = 0; i < release->bo_count; i++)
107 if (release->bos[i] == bo)
108 return;
109
110 if (release->bo_count >= QXL_MAX_RES) {
111 DRM_ERROR("exceeded max resource on a qxl_release item\n");
112 return;
113 }
114 release->bos[release->bo_count++] = qxl_bo_ref(bo);
115}
116
117static int qxl_release_bo_alloc(struct qxl_device *qdev, 102static int qxl_release_bo_alloc(struct qxl_device *qdev,
118 struct qxl_bo **bo) 103 struct qxl_bo **bo)
119{ 104{
120 int ret; 105 int ret;
121 ret = qxl_bo_create(qdev, PAGE_SIZE, false, QXL_GEM_DOMAIN_VRAM, NULL, 106 /* pin releases bo's they are too messy to evict */
107 ret = qxl_bo_create(qdev, PAGE_SIZE, false, true,
108 QXL_GEM_DOMAIN_VRAM, NULL,
122 bo); 109 bo);
123 return ret; 110 return ret;
124} 111}
125 112
126int qxl_release_reserve(struct qxl_device *qdev, 113int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)
127 struct qxl_release *release, bool no_wait) 114{
115 struct qxl_bo_list *entry;
116
117 list_for_each_entry(entry, &release->bos, tv.head) {
118 if (entry->tv.bo == &bo->tbo)
119 return 0;
120 }
121
122 entry = kmalloc(sizeof(struct qxl_bo_list), GFP_KERNEL);
123 if (!entry)
124 return -ENOMEM;
125
126 qxl_bo_ref(bo);
127 entry->tv.bo = &bo->tbo;
128 list_add_tail(&entry->tv.head, &release->bos);
129 return 0;
130}
131
132static int qxl_release_validate_bo(struct qxl_bo *bo)
128{ 133{
129 int ret; 134 int ret;
130 if (atomic_inc_return(&release->bos[0]->reserve_count) == 1) { 135
131 ret = qxl_bo_reserve(release->bos[0], no_wait); 136 if (!bo->pin_count) {
137 qxl_ttm_placement_from_domain(bo, bo->type, false);
138 ret = ttm_bo_validate(&bo->tbo, &bo->placement,
139 true, false);
132 if (ret) 140 if (ret)
133 return ret; 141 return ret;
134 } 142 }
143
144 /* allocate a surface for reserved + validated buffers */
145 ret = qxl_bo_check_id(bo->gem_base.dev->dev_private, bo);
146 if (ret)
147 return ret;
148 return 0;
149}
150
151int qxl_release_reserve_list(struct qxl_release *release, bool no_intr)
152{
153 int ret;
154 struct qxl_bo_list *entry;
155
156 /* if only one object on the release its the release itself
157 since these objects are pinned no need to reserve */
158 if (list_is_singular(&release->bos))
159 return 0;
160
161 ret = ttm_eu_reserve_buffers(&release->ticket, &release->bos);
162 if (ret)
163 return ret;
164
165 list_for_each_entry(entry, &release->bos, tv.head) {
166 struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
167
168 ret = qxl_release_validate_bo(bo);
169 if (ret) {
170 ttm_eu_backoff_reservation(&release->ticket, &release->bos);
171 return ret;
172 }
173 }
135 return 0; 174 return 0;
136} 175}
137 176
138void qxl_release_unreserve(struct qxl_device *qdev, 177void qxl_release_backoff_reserve_list(struct qxl_release *release)
139 struct qxl_release *release)
140{ 178{
141 if (atomic_dec_and_test(&release->bos[0]->reserve_count)) 179 /* if only one object on the release its the release itself
142 qxl_bo_unreserve(release->bos[0]); 180 since these objects are pinned no need to reserve */
181 if (list_is_singular(&release->bos))
182 return;
183
184 ttm_eu_backoff_reservation(&release->ticket, &release->bos);
143} 185}
144 186
187
145int qxl_alloc_surface_release_reserved(struct qxl_device *qdev, 188int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
146 enum qxl_surface_cmd_type surface_cmd_type, 189 enum qxl_surface_cmd_type surface_cmd_type,
147 struct qxl_release *create_rel, 190 struct qxl_release *create_rel,
148 struct qxl_release **release) 191 struct qxl_release **release)
149{ 192{
150 int ret;
151
152 if (surface_cmd_type == QXL_SURFACE_CMD_DESTROY && create_rel) { 193 if (surface_cmd_type == QXL_SURFACE_CMD_DESTROY && create_rel) {
153 int idr_ret; 194 int idr_ret;
195 struct qxl_bo_list *entry = list_first_entry(&create_rel->bos, struct qxl_bo_list, tv.head);
154 struct qxl_bo *bo; 196 struct qxl_bo *bo;
155 union qxl_release_info *info; 197 union qxl_release_info *info;
156 198
157 /* stash the release after the create command */ 199 /* stash the release after the create command */
158 idr_ret = qxl_release_alloc(qdev, QXL_RELEASE_SURFACE_CMD, release); 200 idr_ret = qxl_release_alloc(qdev, QXL_RELEASE_SURFACE_CMD, release);
159 bo = qxl_bo_ref(create_rel->bos[0]); 201 bo = qxl_bo_ref(to_qxl_bo(entry->tv.bo));
160 202
161 (*release)->release_offset = create_rel->release_offset + 64; 203 (*release)->release_offset = create_rel->release_offset + 64;
162 204
163 qxl_release_add_res(qdev, *release, bo); 205 qxl_release_list_add(*release, bo);
164 206
165 ret = qxl_release_reserve(qdev, *release, false);
166 if (ret) {
167 DRM_ERROR("release reserve failed\n");
168 goto out_unref;
169 }
170 info = qxl_release_map(qdev, *release); 207 info = qxl_release_map(qdev, *release);
171 info->id = idr_ret; 208 info->id = idr_ret;
172 qxl_release_unmap(qdev, *release, info); 209 qxl_release_unmap(qdev, *release, info);
173 210
174
175out_unref:
176 qxl_bo_unref(&bo); 211 qxl_bo_unref(&bo);
177 return ret; 212 return 0;
178 } 213 }
179 214
180 return qxl_alloc_release_reserved(qdev, sizeof(struct qxl_surface_cmd), 215 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,
187{ 222{
188 struct qxl_bo *bo; 223 struct qxl_bo *bo;
189 int idr_ret; 224 int idr_ret;
190 int ret; 225 int ret = 0;
191 union qxl_release_info *info; 226 union qxl_release_info *info;
192 int cur_idx; 227 int cur_idx;
193 228
@@ -216,11 +251,6 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
216 mutex_unlock(&qdev->release_mutex); 251 mutex_unlock(&qdev->release_mutex);
217 return ret; 252 return ret;
218 } 253 }
219
220 /* pin releases bo's they are too messy to evict */
221 ret = qxl_bo_reserve(qdev->current_release_bo[cur_idx], false);
222 qxl_bo_pin(qdev->current_release_bo[cur_idx], QXL_GEM_DOMAIN_VRAM, NULL);
223 qxl_bo_unreserve(qdev->current_release_bo[cur_idx]);
224 } 254 }
225 255
226 bo = qxl_bo_ref(qdev->current_release_bo[cur_idx]); 256 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,
231 if (rbo) 261 if (rbo)
232 *rbo = bo; 262 *rbo = bo;
233 263
234 qxl_release_add_res(qdev, *release, bo);
235
236 ret = qxl_release_reserve(qdev, *release, false);
237 mutex_unlock(&qdev->release_mutex); 264 mutex_unlock(&qdev->release_mutex);
238 if (ret) 265
239 goto out_unref; 266 qxl_release_list_add(*release, bo);
240 267
241 info = qxl_release_map(qdev, *release); 268 info = qxl_release_map(qdev, *release);
242 info->id = idr_ret; 269 info->id = idr_ret;
243 qxl_release_unmap(qdev, *release, info); 270 qxl_release_unmap(qdev, *release, info);
244 271
245out_unref:
246 qxl_bo_unref(&bo); 272 qxl_bo_unref(&bo);
247 return ret; 273 return ret;
248} 274}
249 275
250int qxl_fence_releaseable(struct qxl_device *qdev,
251 struct qxl_release *release)
252{
253 int i, ret;
254 for (i = 0; i < release->bo_count; i++) {
255 if (!release->bos[i]->tbo.sync_obj)
256 release->bos[i]->tbo.sync_obj = &release->bos[i]->fence;
257 ret = qxl_fence_add_release(&release->bos[i]->fence, release->id);
258 if (ret)
259 return ret;
260 }
261 return 0;
262}
263
264struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev, 276struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
265 uint64_t id) 277 uint64_t id)
266{ 278{
@@ -273,10 +285,7 @@ struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
273 DRM_ERROR("failed to find id in release_idr\n"); 285 DRM_ERROR("failed to find id in release_idr\n");
274 return NULL; 286 return NULL;
275 } 287 }
276 if (release->bo_count < 1) { 288
277 DRM_ERROR("read a released resource with 0 bos\n");
278 return NULL;
279 }
280 return release; 289 return release;
281} 290}
282 291
@@ -285,9 +294,12 @@ union qxl_release_info *qxl_release_map(struct qxl_device *qdev,
285{ 294{
286 void *ptr; 295 void *ptr;
287 union qxl_release_info *info; 296 union qxl_release_info *info;
288 struct qxl_bo *bo = release->bos[0]; 297 struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
298 struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
289 299
290 ptr = qxl_bo_kmap_atomic_page(qdev, bo, release->release_offset & PAGE_SIZE); 300 ptr = qxl_bo_kmap_atomic_page(qdev, bo, release->release_offset & PAGE_SIZE);
301 if (!ptr)
302 return NULL;
291 info = ptr + (release->release_offset & ~PAGE_SIZE); 303 info = ptr + (release->release_offset & ~PAGE_SIZE);
292 return info; 304 return info;
293} 305}
@@ -296,9 +308,51 @@ void qxl_release_unmap(struct qxl_device *qdev,
296 struct qxl_release *release, 308 struct qxl_release *release,
297 union qxl_release_info *info) 309 union qxl_release_info *info)
298{ 310{
299 struct qxl_bo *bo = release->bos[0]; 311 struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
312 struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
300 void *ptr; 313 void *ptr;
301 314
302 ptr = ((void *)info) - (release->release_offset & ~PAGE_SIZE); 315 ptr = ((void *)info) - (release->release_offset & ~PAGE_SIZE);
303 qxl_bo_kunmap_atomic_page(qdev, bo, ptr); 316 qxl_bo_kunmap_atomic_page(qdev, bo, ptr);
304} 317}
318
319void qxl_release_fence_buffer_objects(struct qxl_release *release)
320{
321 struct ttm_validate_buffer *entry;
322 struct ttm_buffer_object *bo;
323 struct ttm_bo_global *glob;
324 struct ttm_bo_device *bdev;
325 struct ttm_bo_driver *driver;
326 struct qxl_bo *qbo;
327
328 /* if only one object on the release its the release itself
329 since these objects are pinned no need to reserve */
330 if (list_is_singular(&release->bos))
331 return;
332
333 bo = list_first_entry(&release->bos, struct ttm_validate_buffer, head)->bo;
334 bdev = bo->bdev;
335 driver = bdev->driver;
336 glob = bo->glob;
337
338 spin_lock(&glob->lru_lock);
339 spin_lock(&bdev->fence_lock);
340
341 list_for_each_entry(entry, &release->bos, head) {
342 bo = entry->bo;
343 qbo = to_qxl_bo(bo);
344
345 if (!entry->bo->sync_obj)
346 entry->bo->sync_obj = &qbo->fence;
347
348 qxl_fence_add_release_locked(&qbo->fence, release->id);
349
350 ttm_bo_add_to_lru(bo);
351 ww_mutex_unlock(&bo->resv->lock);
352 entry->reserved = false;
353 }
354 spin_unlock(&bdev->fence_lock);
355 spin_unlock(&glob->lru_lock);
356 ww_acquire_fini(&release->ticket);
357}
358
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 489cb8cece4d..1dfd84cda2a1 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -206,7 +206,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
206 return; 206 return;
207 } 207 }
208 qbo = container_of(bo, struct qxl_bo, tbo); 208 qbo = container_of(bo, struct qxl_bo, tbo);
209 qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU); 209 qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU, false);
210 *placement = qbo->placement; 210 *placement = qbo->placement;
211} 211}
212 212
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 064023bed480..32501f6ec991 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -44,6 +44,41 @@ static char *pre_emph_names[] = {
44}; 44};
45 45
46/***** radeon AUX functions *****/ 46/***** radeon AUX functions *****/
47
48/* Atom needs data in little endian format
49 * so swap as appropriate when copying data to
50 * or from atom. Note that atom operates on
51 * dw units.
52 */
53static void radeon_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
54{
55#ifdef __BIG_ENDIAN
56 u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
57 u32 *dst32, *src32;
58 int i;
59
60 memcpy(src_tmp, src, num_bytes);
61 src32 = (u32 *)src_tmp;
62 dst32 = (u32 *)dst_tmp;
63 if (to_le) {
64 for (i = 0; i < ((num_bytes + 3) / 4); i++)
65 dst32[i] = cpu_to_le32(src32[i]);
66 memcpy(dst, dst_tmp, num_bytes);
67 } else {
68 u8 dws = num_bytes & ~3;
69 for (i = 0; i < ((num_bytes + 3) / 4); i++)
70 dst32[i] = le32_to_cpu(src32[i]);
71 memcpy(dst, dst_tmp, dws);
72 if (num_bytes % 4) {
73 for (i = 0; i < (num_bytes % 4); i++)
74 dst[dws+i] = dst_tmp[dws+i];
75 }
76 }
77#else
78 memcpy(dst, src, num_bytes);
79#endif
80}
81
47union aux_channel_transaction { 82union aux_channel_transaction {
48 PROCESS_AUX_CHANNEL_TRANSACTION_PS_ALLOCATION v1; 83 PROCESS_AUX_CHANNEL_TRANSACTION_PS_ALLOCATION v1;
49 PROCESS_AUX_CHANNEL_TRANSACTION_PARAMETERS_V2 v2; 84 PROCESS_AUX_CHANNEL_TRANSACTION_PARAMETERS_V2 v2;
@@ -65,10 +100,10 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
65 100
66 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1); 101 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);
67 102
68 memcpy(base, send, send_bytes); 103 radeon_copy_swap(base, send, send_bytes, true);
69 104
70 args.v1.lpAuxRequest = 0 + 4; 105 args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4));
71 args.v1.lpDataOut = 16 + 4; 106 args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4));
72 args.v1.ucDataOutLen = 0; 107 args.v1.ucDataOutLen = 0;
73 args.v1.ucChannelID = chan->rec.i2c_id; 108 args.v1.ucChannelID = chan->rec.i2c_id;
74 args.v1.ucDelay = delay / 10; 109 args.v1.ucDelay = delay / 10;
@@ -102,7 +137,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
102 recv_bytes = recv_size; 137 recv_bytes = recv_size;
103 138
104 if (recv && recv_size) 139 if (recv && recv_size)
105 memcpy(recv, base + 16, recv_bytes); 140 radeon_copy_swap(recv, base + 16, recv_bytes, false);
106 141
107 return recv_bytes; 142 return recv_bytes;
108} 143}
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index ed1d91025928..6dacec4e2090 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -22,7 +22,6 @@
22 * Authors: Alex Deucher 22 * Authors: Alex Deucher
23 */ 23 */
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/platform_device.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include "drmP.h" 27#include "drmP.h"
@@ -742,7 +741,6 @@ static int ci_mc_load_microcode(struct radeon_device *rdev)
742 */ 741 */
743static int cik_init_microcode(struct radeon_device *rdev) 742static int cik_init_microcode(struct radeon_device *rdev)
744{ 743{
745 struct platform_device *pdev;
746 const char *chip_name; 744 const char *chip_name;
747 size_t pfp_req_size, me_req_size, ce_req_size, 745 size_t pfp_req_size, me_req_size, ce_req_size,
748 mec_req_size, rlc_req_size, mc_req_size, 746 mec_req_size, rlc_req_size, mc_req_size,
@@ -752,13 +750,6 @@ static int cik_init_microcode(struct radeon_device *rdev)
752 750
753 DRM_DEBUG("\n"); 751 DRM_DEBUG("\n");
754 752
755 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
756 err = IS_ERR(pdev);
757 if (err) {
758 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
759 return -EINVAL;
760 }
761
762 switch (rdev->family) { 753 switch (rdev->family) {
763 case CHIP_BONAIRE: 754 case CHIP_BONAIRE:
764 chip_name = "BONAIRE"; 755 chip_name = "BONAIRE";
@@ -794,7 +785,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
794 DRM_INFO("Loading %s Microcode\n", chip_name); 785 DRM_INFO("Loading %s Microcode\n", chip_name);
795 786
796 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); 787 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
797 err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); 788 err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
798 if (err) 789 if (err)
799 goto out; 790 goto out;
800 if (rdev->pfp_fw->size != pfp_req_size) { 791 if (rdev->pfp_fw->size != pfp_req_size) {
@@ -806,7 +797,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
806 } 797 }
807 798
808 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); 799 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
809 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); 800 err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
810 if (err) 801 if (err)
811 goto out; 802 goto out;
812 if (rdev->me_fw->size != me_req_size) { 803 if (rdev->me_fw->size != me_req_size) {
@@ -817,7 +808,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
817 } 808 }
818 809
819 snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); 810 snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
820 err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev); 811 err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
821 if (err) 812 if (err)
822 goto out; 813 goto out;
823 if (rdev->ce_fw->size != ce_req_size) { 814 if (rdev->ce_fw->size != ce_req_size) {
@@ -828,7 +819,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
828 } 819 }
829 820
830 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name); 821 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name);
831 err = request_firmware(&rdev->mec_fw, fw_name, &pdev->dev); 822 err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev);
832 if (err) 823 if (err)
833 goto out; 824 goto out;
834 if (rdev->mec_fw->size != mec_req_size) { 825 if (rdev->mec_fw->size != mec_req_size) {
@@ -839,7 +830,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
839 } 830 }
840 831
841 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name); 832 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name);
842 err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); 833 err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
843 if (err) 834 if (err)
844 goto out; 835 goto out;
845 if (rdev->rlc_fw->size != rlc_req_size) { 836 if (rdev->rlc_fw->size != rlc_req_size) {
@@ -850,7 +841,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
850 } 841 }
851 842
852 snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name); 843 snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name);
853 err = request_firmware(&rdev->sdma_fw, fw_name, &pdev->dev); 844 err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev);
854 if (err) 845 if (err)
855 goto out; 846 goto out;
856 if (rdev->sdma_fw->size != sdma_req_size) { 847 if (rdev->sdma_fw->size != sdma_req_size) {
@@ -863,7 +854,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
863 /* No MC ucode on APUs */ 854 /* No MC ucode on APUs */
864 if (!(rdev->flags & RADEON_IS_IGP)) { 855 if (!(rdev->flags & RADEON_IS_IGP)) {
865 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); 856 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
866 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); 857 err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
867 if (err) 858 if (err)
868 goto out; 859 goto out;
869 if (rdev->mc_fw->size != mc_req_size) { 860 if (rdev->mc_fw->size != mc_req_size) {
@@ -875,8 +866,6 @@ static int cik_init_microcode(struct radeon_device *rdev)
875 } 866 }
876 867
877out: 868out:
878 platform_device_unregister(pdev);
879
880 if (err) { 869 if (err) {
881 if (err != -EINVAL) 870 if (err != -EINVAL)
882 printk(KERN_ERR 871 printk(KERN_ERR
@@ -4453,6 +4442,29 @@ void cik_vm_fini(struct radeon_device *rdev)
4453} 4442}
4454 4443
4455/** 4444/**
4445 * cik_vm_decode_fault - print human readable fault info
4446 *
4447 * @rdev: radeon_device pointer
4448 * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
4449 * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
4450 *
4451 * Print human readable fault information (CIK).
4452 */
4453static void cik_vm_decode_fault(struct radeon_device *rdev,
4454 u32 status, u32 addr, u32 mc_client)
4455{
4456 u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT;
4457 u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT;
4458 u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT;
4459 char *block = (char *)&mc_client;
4460
4461 printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n",
4462 protections, vmid, addr,
4463 (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read",
4464 block, mc_id);
4465}
4466
4467/**
4456 * cik_vm_flush - cik vm flush using the CP 4468 * cik_vm_flush - cik vm flush using the CP
4457 * 4469 *
4458 * @rdev: radeon_device pointer 4470 * @rdev: radeon_device pointer
@@ -5507,6 +5519,7 @@ int cik_irq_process(struct radeon_device *rdev)
5507 u32 ring_index; 5519 u32 ring_index;
5508 bool queue_hotplug = false; 5520 bool queue_hotplug = false;
5509 bool queue_reset = false; 5521 bool queue_reset = false;
5522 u32 addr, status, mc_client;
5510 5523
5511 if (!rdev->ih.enabled || rdev->shutdown) 5524 if (!rdev->ih.enabled || rdev->shutdown)
5512 return IRQ_NONE; 5525 return IRQ_NONE;
@@ -5742,11 +5755,15 @@ restart_ih:
5742 break; 5755 break;
5743 case 146: 5756 case 146:
5744 case 147: 5757 case 147:
5758 addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
5759 status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
5760 mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT);
5745 dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); 5761 dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
5746 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", 5762 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n",
5747 RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); 5763 addr);
5748 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", 5764 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
5749 RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); 5765 status);
5766 cik_vm_decode_fault(rdev, status, addr, mc_client);
5750 /* reset addr and status */ 5767 /* reset addr and status */
5751 WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); 5768 WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
5752 break; 5769 break;
@@ -6961,7 +6978,7 @@ int cik_uvd_resume(struct radeon_device *rdev)
6961 6978
6962 /* programm the VCPU memory controller bits 0-27 */ 6979 /* programm the VCPU memory controller bits 0-27 */
6963 addr = rdev->uvd.gpu_addr >> 3; 6980 addr = rdev->uvd.gpu_addr >> 3;
6964 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3; 6981 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3;
6965 WREG32(UVD_VCPU_CACHE_OFFSET0, addr); 6982 WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
6966 WREG32(UVD_VCPU_CACHE_SIZE0, size); 6983 WREG32(UVD_VCPU_CACHE_SIZE0, size);
6967 6984
diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h
index 63514b95889a..7e9275eaef80 100644
--- a/drivers/gpu/drm/radeon/cikd.h
+++ b/drivers/gpu/drm/radeon/cikd.h
@@ -136,6 +136,22 @@
136#define VM_INVALIDATE_RESPONSE 0x147c 136#define VM_INVALIDATE_RESPONSE 0x147c
137 137
138#define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC 138#define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC
139#define PROTECTIONS_MASK (0xf << 0)
140#define PROTECTIONS_SHIFT 0
141 /* bit 0: range
142 * bit 1: pde0
143 * bit 2: valid
144 * bit 3: read
145 * bit 4: write
146 */
147#define MEMORY_CLIENT_ID_MASK (0xff << 12)
148#define MEMORY_CLIENT_ID_SHIFT 12
149#define MEMORY_CLIENT_RW_MASK (1 << 24)
150#define MEMORY_CLIENT_RW_SHIFT 24
151#define FAULT_VMID_MASK (0xf << 25)
152#define FAULT_VMID_SHIFT 25
153
154#define VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT 0x14E4
139 155
140#define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC 156#define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC
141 157
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index e49059dc9b8f..038dcac7670c 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -139,6 +139,8 @@ void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
139void evergreen_program_aspm(struct radeon_device *rdev); 139void evergreen_program_aspm(struct radeon_device *rdev);
140extern void cayman_cp_int_cntl_setup(struct radeon_device *rdev, 140extern void cayman_cp_int_cntl_setup(struct radeon_device *rdev,
141 int ring, u32 cp_int_cntl); 141 int ring, u32 cp_int_cntl);
142extern void cayman_vm_decode_fault(struct radeon_device *rdev,
143 u32 status, u32 addr);
142 144
143static const u32 evergreen_golden_registers[] = 145static const u32 evergreen_golden_registers[] =
144{ 146{
@@ -4586,6 +4588,7 @@ int evergreen_irq_process(struct radeon_device *rdev)
4586 bool queue_hotplug = false; 4588 bool queue_hotplug = false;
4587 bool queue_hdmi = false; 4589 bool queue_hdmi = false;
4588 bool queue_thermal = false; 4590 bool queue_thermal = false;
4591 u32 status, addr;
4589 4592
4590 if (!rdev->ih.enabled || rdev->shutdown) 4593 if (!rdev->ih.enabled || rdev->shutdown)
4591 return IRQ_NONE; 4594 return IRQ_NONE;
@@ -4872,11 +4875,14 @@ restart_ih:
4872 break; 4875 break;
4873 case 146: 4876 case 146:
4874 case 147: 4877 case 147:
4878 addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
4879 status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
4875 dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); 4880 dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
4876 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", 4881 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n",
4877 RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); 4882 addr);
4878 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", 4883 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
4879 RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); 4884 status);
4885 cayman_vm_decode_fault(rdev, status, addr);
4880 /* reset addr and status */ 4886 /* reset addr and status */
4881 WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); 4887 WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
4882 break; 4888 break;
@@ -5509,6 +5515,9 @@ void evergreen_program_aspm(struct radeon_device *rdev)
5509 */ 5515 */
5510 bool fusion_platform = false; 5516 bool fusion_platform = false;
5511 5517
5518 if (radeon_aspm == 0)
5519 return;
5520
5512 if (!(rdev->flags & RADEON_IS_PCIE)) 5521 if (!(rdev->flags & RADEON_IS_PCIE))
5513 return; 5522 return;
5514 5523
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index b9c6f7675e59..b0d3fb341417 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -177,6 +177,9 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
177 uint32_t offset; 177 uint32_t offset;
178 ssize_t err; 178 ssize_t err;
179 179
180 if (!dig || !dig->afmt)
181 return;
182
180 /* Silent, r600_hdmi_enable will raise WARN for us */ 183 /* Silent, r600_hdmi_enable will raise WARN for us */
181 if (!dig->afmt->enabled) 184 if (!dig->afmt->enabled)
182 return; 185 return;
@@ -280,6 +283,9 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
280 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 283 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
281 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 284 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
282 285
286 if (!dig || !dig->afmt)
287 return;
288
283 /* Silent, r600_hdmi_enable will raise WARN for us */ 289 /* Silent, r600_hdmi_enable will raise WARN for us */
284 if (enable && dig->afmt->enabled) 290 if (enable && dig->afmt->enabled)
285 return; 291 return;
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index f30127cb30ef..56bd4f3be4fe 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -22,7 +22,6 @@
22 * Authors: Alex Deucher 22 * Authors: Alex Deucher
23 */ 23 */
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/platform_device.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <drm/drmP.h> 27#include <drm/drmP.h>
@@ -684,7 +683,6 @@ int ni_mc_load_microcode(struct radeon_device *rdev)
684 683
685int ni_init_microcode(struct radeon_device *rdev) 684int ni_init_microcode(struct radeon_device *rdev)
686{ 685{
687 struct platform_device *pdev;
688 const char *chip_name; 686 const char *chip_name;
689 const char *rlc_chip_name; 687 const char *rlc_chip_name;
690 size_t pfp_req_size, me_req_size, rlc_req_size, mc_req_size; 688 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)
694 692
695 DRM_DEBUG("\n"); 693 DRM_DEBUG("\n");
696 694
697 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
698 err = IS_ERR(pdev);
699 if (err) {
700 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
701 return -EINVAL;
702 }
703
704 switch (rdev->family) { 695 switch (rdev->family) {
705 case CHIP_BARTS: 696 case CHIP_BARTS:
706 chip_name = "BARTS"; 697 chip_name = "BARTS";
@@ -753,7 +744,7 @@ int ni_init_microcode(struct radeon_device *rdev)
753 DRM_INFO("Loading %s Microcode\n", chip_name); 744 DRM_INFO("Loading %s Microcode\n", chip_name);
754 745
755 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); 746 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
756 err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); 747 err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
757 if (err) 748 if (err)
758 goto out; 749 goto out;
759 if (rdev->pfp_fw->size != pfp_req_size) { 750 if (rdev->pfp_fw->size != pfp_req_size) {
@@ -765,7 +756,7 @@ int ni_init_microcode(struct radeon_device *rdev)
765 } 756 }
766 757
767 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); 758 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
768 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); 759 err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
769 if (err) 760 if (err)
770 goto out; 761 goto out;
771 if (rdev->me_fw->size != me_req_size) { 762 if (rdev->me_fw->size != me_req_size) {
@@ -776,7 +767,7 @@ int ni_init_microcode(struct radeon_device *rdev)
776 } 767 }
777 768
778 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); 769 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
779 err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); 770 err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
780 if (err) 771 if (err)
781 goto out; 772 goto out;
782 if (rdev->rlc_fw->size != rlc_req_size) { 773 if (rdev->rlc_fw->size != rlc_req_size) {
@@ -789,7 +780,7 @@ int ni_init_microcode(struct radeon_device *rdev)
789 /* no MC ucode on TN */ 780 /* no MC ucode on TN */
790 if (!(rdev->flags & RADEON_IS_IGP)) { 781 if (!(rdev->flags & RADEON_IS_IGP)) {
791 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); 782 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
792 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); 783 err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
793 if (err) 784 if (err)
794 goto out; 785 goto out;
795 if (rdev->mc_fw->size != mc_req_size) { 786 if (rdev->mc_fw->size != mc_req_size) {
@@ -802,7 +793,7 @@ int ni_init_microcode(struct radeon_device *rdev)
802 793
803 if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) { 794 if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) {
804 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); 795 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
805 err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev); 796 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
806 if (err) 797 if (err)
807 goto out; 798 goto out;
808 if (rdev->smc_fw->size != smc_req_size) { 799 if (rdev->smc_fw->size != smc_req_size) {
@@ -814,8 +805,6 @@ int ni_init_microcode(struct radeon_device *rdev)
814 } 805 }
815 806
816out: 807out:
817 platform_device_unregister(pdev);
818
819 if (err) { 808 if (err) {
820 if (err != -EINVAL) 809 if (err != -EINVAL)
821 printk(KERN_ERR 810 printk(KERN_ERR
@@ -2461,6 +2450,167 @@ void cayman_vm_fini(struct radeon_device *rdev)
2461{ 2450{
2462} 2451}
2463 2452
2453/**
2454 * cayman_vm_decode_fault - print human readable fault info
2455 *
2456 * @rdev: radeon_device pointer
2457 * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
2458 * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
2459 *
2460 * Print human readable fault information (cayman/TN).
2461 */
2462void cayman_vm_decode_fault(struct radeon_device *rdev,
2463 u32 status, u32 addr)
2464{
2465 u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT;
2466 u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT;
2467 u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT;
2468 char *block;
2469
2470 switch (mc_id) {
2471 case 32:
2472 case 16:
2473 case 96:
2474 case 80:
2475 case 160:
2476 case 144:
2477 case 224:
2478 case 208:
2479 block = "CB";
2480 break;
2481 case 33:
2482 case 17:
2483 case 97:
2484 case 81:
2485 case 161:
2486 case 145:
2487 case 225:
2488 case 209:
2489 block = "CB_FMASK";
2490 break;
2491 case 34:
2492 case 18:
2493 case 98:
2494 case 82:
2495 case 162:
2496 case 146:
2497 case 226:
2498 case 210:
2499 block = "CB_CMASK";
2500 break;
2501 case 35:
2502 case 19:
2503 case 99:
2504 case 83:
2505 case 163:
2506 case 147:
2507 case 227:
2508 case 211:
2509 block = "CB_IMMED";
2510 break;
2511 case 36:
2512 case 20:
2513 case 100:
2514 case 84:
2515 case 164:
2516 case 148:
2517 case 228:
2518 case 212:
2519 block = "DB";
2520 break;
2521 case 37:
2522 case 21:
2523 case 101:
2524 case 85:
2525 case 165:
2526 case 149:
2527 case 229:
2528 case 213:
2529 block = "DB_HTILE";
2530 break;
2531 case 38:
2532 case 22:
2533 case 102:
2534 case 86:
2535 case 166:
2536 case 150:
2537 case 230:
2538 case 214:
2539 block = "SX";
2540 break;
2541 case 39:
2542 case 23:
2543 case 103:
2544 case 87:
2545 case 167:
2546 case 151:
2547 case 231:
2548 case 215:
2549 block = "DB_STEN";
2550 break;
2551 case 40:
2552 case 24:
2553 case 104:
2554 case 88:
2555 case 232:
2556 case 216:
2557 case 168:
2558 case 152:
2559 block = "TC_TFETCH";
2560 break;
2561 case 41:
2562 case 25:
2563 case 105:
2564 case 89:
2565 case 233:
2566 case 217:
2567 case 169:
2568 case 153:
2569 block = "TC_VFETCH";
2570 break;
2571 case 42:
2572 case 26:
2573 case 106:
2574 case 90:
2575 case 234:
2576 case 218:
2577 case 170:
2578 case 154:
2579 block = "VC";
2580 break;
2581 case 112:
2582 block = "CP";
2583 break;
2584 case 113:
2585 case 114:
2586 block = "SH";
2587 break;
2588 case 115:
2589 block = "VGT";
2590 break;
2591 case 178:
2592 block = "IH";
2593 break;
2594 case 51:
2595 block = "RLC";
2596 break;
2597 case 55:
2598 block = "DMA";
2599 break;
2600 case 56:
2601 block = "HDP";
2602 break;
2603 default:
2604 block = "unknown";
2605 break;
2606 }
2607
2608 printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n",
2609 protections, vmid, addr,
2610 (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read",
2611 block, mc_id);
2612}
2613
2464#define R600_ENTRY_VALID (1 << 0) 2614#define R600_ENTRY_VALID (1 << 0)
2465#define R600_PTE_SYSTEM (1 << 1) 2615#define R600_PTE_SYSTEM (1 << 1)
2466#define R600_PTE_SNOOPED (1 << 2) 2616#define R600_PTE_SNOOPED (1 << 2)
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index fe24a93542ec..22421bc80c0d 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -133,6 +133,22 @@
133#define VM_CONTEXT1_CNTL2 0x1434 133#define VM_CONTEXT1_CNTL2 0x1434
134#define VM_INVALIDATE_REQUEST 0x1478 134#define VM_INVALIDATE_REQUEST 0x1478
135#define VM_INVALIDATE_RESPONSE 0x147c 135#define VM_INVALIDATE_RESPONSE 0x147c
136#define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC
137#define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC
138#define PROTECTIONS_MASK (0xf << 0)
139#define PROTECTIONS_SHIFT 0
140 /* bit 0: range
141 * bit 2: pde0
142 * bit 3: valid
143 * bit 4: read
144 * bit 5: write
145 */
146#define MEMORY_CLIENT_ID_MASK (0xff << 12)
147#define MEMORY_CLIENT_ID_SHIFT 12
148#define MEMORY_CLIENT_RW_MASK (1 << 24)
149#define MEMORY_CLIENT_RW_SHIFT 24
150#define FAULT_VMID_MASK (0x7 << 25)
151#define FAULT_VMID_SHIFT 25
136#define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR 0x1518 152#define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR 0x1518
137#define VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR 0x151c 153#define VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR 0x151c
138#define VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x153C 154#define VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x153C
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index c9affefd79f6..75349cdaa84b 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -39,7 +39,6 @@
39#include "atom.h" 39#include "atom.h"
40 40
41#include <linux/firmware.h> 41#include <linux/firmware.h>
42#include <linux/platform_device.h>
43#include <linux/module.h> 42#include <linux/module.h>
44 43
45#include "r100_reg_safe.h" 44#include "r100_reg_safe.h"
@@ -989,18 +988,11 @@ void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring)
989/* Load the microcode for the CP */ 988/* Load the microcode for the CP */
990static int r100_cp_init_microcode(struct radeon_device *rdev) 989static int r100_cp_init_microcode(struct radeon_device *rdev)
991{ 990{
992 struct platform_device *pdev;
993 const char *fw_name = NULL; 991 const char *fw_name = NULL;
994 int err; 992 int err;
995 993
996 DRM_DEBUG_KMS("\n"); 994 DRM_DEBUG_KMS("\n");
997 995
998 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
999 err = IS_ERR(pdev);
1000 if (err) {
1001 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
1002 return -EINVAL;
1003 }
1004 if ((rdev->family == CHIP_R100) || (rdev->family == CHIP_RV100) || 996 if ((rdev->family == CHIP_R100) || (rdev->family == CHIP_RV100) ||
1005 (rdev->family == CHIP_RV200) || (rdev->family == CHIP_RS100) || 997 (rdev->family == CHIP_RV200) || (rdev->family == CHIP_RS100) ||
1006 (rdev->family == CHIP_RS200)) { 998 (rdev->family == CHIP_RS200)) {
@@ -1042,8 +1034,7 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)
1042 fw_name = FIRMWARE_R520; 1034 fw_name = FIRMWARE_R520;
1043 } 1035 }
1044 1036
1045 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); 1037 err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
1046 platform_device_unregister(pdev);
1047 if (err) { 1038 if (err) {
1048 printk(KERN_ERR "radeon_cp: Failed to load firmware \"%s\"\n", 1039 printk(KERN_ERR "radeon_cp: Failed to load firmware \"%s\"\n",
1049 fw_name); 1040 fw_name);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 2d3655f7f41e..10f712e37003 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -28,7 +28,6 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/seq_file.h> 29#include <linux/seq_file.h>
30#include <linux/firmware.h> 30#include <linux/firmware.h>
31#include <linux/platform_device.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <drm/drmP.h> 32#include <drm/drmP.h>
34#include <drm/radeon_drm.h> 33#include <drm/radeon_drm.h>
@@ -2144,7 +2143,6 @@ void r600_cp_stop(struct radeon_device *rdev)
2144 2143
2145int r600_init_microcode(struct radeon_device *rdev) 2144int r600_init_microcode(struct radeon_device *rdev)
2146{ 2145{
2147 struct platform_device *pdev;
2148 const char *chip_name; 2146 const char *chip_name;
2149 const char *rlc_chip_name; 2147 const char *rlc_chip_name;
2150 const char *smc_chip_name = "RV770"; 2148 const char *smc_chip_name = "RV770";
@@ -2154,13 +2152,6 @@ int r600_init_microcode(struct radeon_device *rdev)
2154 2152
2155 DRM_DEBUG("\n"); 2153 DRM_DEBUG("\n");
2156 2154
2157 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
2158 err = IS_ERR(pdev);
2159 if (err) {
2160 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
2161 return -EINVAL;
2162 }
2163
2164 switch (rdev->family) { 2155 switch (rdev->family) {
2165 case CHIP_R600: 2156 case CHIP_R600:
2166 chip_name = "R600"; 2157 chip_name = "R600";
@@ -2272,7 +2263,7 @@ int r600_init_microcode(struct radeon_device *rdev)
2272 DRM_INFO("Loading %s Microcode\n", chip_name); 2263 DRM_INFO("Loading %s Microcode\n", chip_name);
2273 2264
2274 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); 2265 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
2275 err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); 2266 err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
2276 if (err) 2267 if (err)
2277 goto out; 2268 goto out;
2278 if (rdev->pfp_fw->size != pfp_req_size) { 2269 if (rdev->pfp_fw->size != pfp_req_size) {
@@ -2284,7 +2275,7 @@ int r600_init_microcode(struct radeon_device *rdev)
2284 } 2275 }
2285 2276
2286 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); 2277 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
2287 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); 2278 err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
2288 if (err) 2279 if (err)
2289 goto out; 2280 goto out;
2290 if (rdev->me_fw->size != me_req_size) { 2281 if (rdev->me_fw->size != me_req_size) {
@@ -2295,7 +2286,7 @@ int r600_init_microcode(struct radeon_device *rdev)
2295 } 2286 }
2296 2287
2297 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); 2288 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
2298 err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); 2289 err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
2299 if (err) 2290 if (err)
2300 goto out; 2291 goto out;
2301 if (rdev->rlc_fw->size != rlc_req_size) { 2292 if (rdev->rlc_fw->size != rlc_req_size) {
@@ -2307,7 +2298,7 @@ int r600_init_microcode(struct radeon_device *rdev)
2307 2298
2308 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) { 2299 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) {
2309 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name); 2300 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name);
2310 err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev); 2301 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
2311 if (err) 2302 if (err)
2312 goto out; 2303 goto out;
2313 if (rdev->smc_fw->size != smc_req_size) { 2304 if (rdev->smc_fw->size != smc_req_size) {
@@ -2319,8 +2310,6 @@ int r600_init_microcode(struct radeon_device *rdev)
2319 } 2310 }
2320 2311
2321out: 2312out:
2322 platform_device_unregister(pdev);
2323
2324 if (err) { 2313 if (err) {
2325 if (err != -EINVAL) 2314 if (err != -EINVAL)
2326 printk(KERN_ERR 2315 printk(KERN_ERR
@@ -3019,7 +3008,7 @@ void r600_uvd_fence_emit(struct radeon_device *rdev,
3019 struct radeon_fence *fence) 3008 struct radeon_fence *fence)
3020{ 3009{
3021 struct radeon_ring *ring = &rdev->ring[fence->ring]; 3010 struct radeon_ring *ring = &rdev->ring[fence->ring];
3022 uint32_t addr = rdev->fence_drv[fence->ring].gpu_addr; 3011 uint64_t addr = rdev->fence_drv[fence->ring].gpu_addr;
3023 3012
3024 radeon_ring_write(ring, PACKET0(UVD_CONTEXT_ID, 0)); 3013 radeon_ring_write(ring, PACKET0(UVD_CONTEXT_ID, 0));
3025 radeon_ring_write(ring, fence->seq); 3014 radeon_ring_write(ring, fence->seq);
@@ -3145,6 +3134,90 @@ int r600_copy_blit(struct radeon_device *rdev,
3145} 3134}
3146 3135
3147/** 3136/**
3137 * r600_copy_cpdma - copy pages using the CP DMA engine
3138 *
3139 * @rdev: radeon_device pointer
3140 * @src_offset: src GPU address
3141 * @dst_offset: dst GPU address
3142 * @num_gpu_pages: number of GPU pages to xfer
3143 * @fence: radeon fence object
3144 *
3145 * Copy GPU paging using the CP DMA engine (r6xx+).
3146 * Used by the radeon ttm implementation to move pages if
3147 * registered as the asic copy callback.
3148 */
3149int r600_copy_cpdma(struct radeon_device *rdev,
3150 uint64_t src_offset, uint64_t dst_offset,
3151 unsigned num_gpu_pages,
3152 struct radeon_fence **fence)
3153{
3154 struct radeon_semaphore *sem = NULL;
3155 int ring_index = rdev->asic->copy.blit_ring_index;
3156 struct radeon_ring *ring = &rdev->ring[ring_index];
3157 u32 size_in_bytes, cur_size_in_bytes, tmp;
3158 int i, num_loops;
3159 int r = 0;
3160
3161 r = radeon_semaphore_create(rdev, &sem);
3162 if (r) {
3163 DRM_ERROR("radeon: moving bo (%d).\n", r);
3164 return r;
3165 }
3166
3167 size_in_bytes = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT);
3168 num_loops = DIV_ROUND_UP(size_in_bytes, 0x1fffff);
3169 r = radeon_ring_lock(rdev, ring, num_loops * 6 + 24);
3170 if (r) {
3171 DRM_ERROR("radeon: moving bo (%d).\n", r);
3172 radeon_semaphore_free(rdev, &sem, NULL);
3173 return r;
3174 }
3175
3176 if (radeon_fence_need_sync(*fence, ring->idx)) {
3177 radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring,
3178 ring->idx);
3179 radeon_fence_note_sync(*fence, ring->idx);
3180 } else {
3181 radeon_semaphore_free(rdev, &sem, NULL);
3182 }
3183
3184 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
3185 radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
3186 radeon_ring_write(ring, WAIT_3D_IDLE_bit);
3187 for (i = 0; i < num_loops; i++) {
3188 cur_size_in_bytes = size_in_bytes;
3189 if (cur_size_in_bytes > 0x1fffff)
3190 cur_size_in_bytes = 0x1fffff;
3191 size_in_bytes -= cur_size_in_bytes;
3192 tmp = upper_32_bits(src_offset) & 0xff;
3193 if (size_in_bytes == 0)
3194 tmp |= PACKET3_CP_DMA_CP_SYNC;
3195 radeon_ring_write(ring, PACKET3(PACKET3_CP_DMA, 4));
3196 radeon_ring_write(ring, src_offset & 0xffffffff);
3197 radeon_ring_write(ring, tmp);
3198 radeon_ring_write(ring, dst_offset & 0xffffffff);
3199 radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff);
3200 radeon_ring_write(ring, cur_size_in_bytes);
3201 src_offset += cur_size_in_bytes;
3202 dst_offset += cur_size_in_bytes;
3203 }
3204 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
3205 radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
3206 radeon_ring_write(ring, WAIT_CP_DMA_IDLE_bit);
3207
3208 r = radeon_fence_emit(rdev, fence, ring->idx);
3209 if (r) {
3210 radeon_ring_unlock_undo(rdev, ring);
3211 return r;
3212 }
3213
3214 radeon_ring_unlock_commit(rdev, ring);
3215 radeon_semaphore_free(rdev, &sem, *fence);
3216
3217 return r;
3218}
3219
3220/**
3148 * r600_copy_dma - copy pages using the DMA engine 3221 * r600_copy_dma - copy pages using the DMA engine
3149 * 3222 *
3150 * @rdev: radeon_device pointer 3223 * @rdev: radeon_device pointer
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index b88f54b134ab..e5c860f4ccbe 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -278,9 +278,9 @@ bool r600_dynamicpm_enabled(struct radeon_device *rdev)
278void r600_enable_sclk_control(struct radeon_device *rdev, bool enable) 278void r600_enable_sclk_control(struct radeon_device *rdev, bool enable)
279{ 279{
280 if (enable) 280 if (enable)
281 WREG32_P(GENERAL_PWRMGT, 0, ~SCLK_PWRMGT_OFF); 281 WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF);
282 else 282 else
283 WREG32_P(GENERAL_PWRMGT, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF); 283 WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
284} 284}
285 285
286void r600_enable_mclk_control(struct radeon_device *rdev, bool enable) 286void r600_enable_mclk_control(struct radeon_device *rdev, bool enable)
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index e73b2a73494a..f48240bb8c56 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -266,6 +266,9 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
266 uint32_t offset; 266 uint32_t offset;
267 ssize_t err; 267 ssize_t err;
268 268
269 if (!dig || !dig->afmt)
270 return;
271
269 /* Silent, r600_hdmi_enable will raise WARN for us */ 272 /* Silent, r600_hdmi_enable will raise WARN for us */
270 if (!dig->afmt->enabled) 273 if (!dig->afmt->enabled)
271 return; 274 return;
@@ -448,6 +451,9 @@ void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
448 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 451 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
449 u32 hdmi = HDMI0_ERROR_ACK; 452 u32 hdmi = HDMI0_ERROR_ACK;
450 453
454 if (!dig || !dig->afmt)
455 return;
456
451 /* Silent, r600_hdmi_enable will raise WARN for us */ 457 /* Silent, r600_hdmi_enable will raise WARN for us */
452 if (enable && dig->afmt->enabled) 458 if (enable && dig->afmt->enabled)
453 return; 459 return;
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index f1b3084d8f51..8e3fe815edab 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -602,6 +602,7 @@
602#define L2_BUSY (1 << 0) 602#define L2_BUSY (1 << 0)
603 603
604#define WAIT_UNTIL 0x8040 604#define WAIT_UNTIL 0x8040
605#define WAIT_CP_DMA_IDLE_bit (1 << 8)
605#define WAIT_2D_IDLE_bit (1 << 14) 606#define WAIT_2D_IDLE_bit (1 << 14)
606#define WAIT_3D_IDLE_bit (1 << 15) 607#define WAIT_3D_IDLE_bit (1 << 15)
607#define WAIT_2D_IDLECLEAN_bit (1 << 16) 608#define WAIT_2D_IDLECLEAN_bit (1 << 16)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 9b7025d02cd0..2f08219c39b6 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -97,6 +97,7 @@ extern int radeon_msi;
97extern int radeon_lockup_timeout; 97extern int radeon_lockup_timeout;
98extern int radeon_fastfb; 98extern int radeon_fastfb;
99extern int radeon_dpm; 99extern int radeon_dpm;
100extern int radeon_aspm;
100 101
101/* 102/*
102 * Copy from radeon_drv.h so we don't have to include both and have conflicting 103 * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -455,6 +456,7 @@ struct radeon_sa_manager {
455 uint64_t gpu_addr; 456 uint64_t gpu_addr;
456 void *cpu_ptr; 457 void *cpu_ptr;
457 uint32_t domain; 458 uint32_t domain;
459 uint32_t align;
458}; 460};
459 461
460struct radeon_sa_bo; 462struct radeon_sa_bo;
@@ -783,6 +785,11 @@ struct radeon_mec {
783/* number of entries in page table */ 785/* number of entries in page table */
784#define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE) 786#define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
785 787
788/* PTBs (Page Table Blocks) need to be aligned to 32K */
789#define RADEON_VM_PTB_ALIGN_SIZE 32768
790#define RADEON_VM_PTB_ALIGN_MASK (RADEON_VM_PTB_ALIGN_SIZE - 1)
791#define RADEON_VM_PTB_ALIGN(a) (((a) + RADEON_VM_PTB_ALIGN_MASK) & ~RADEON_VM_PTB_ALIGN_MASK)
792
786struct radeon_vm { 793struct radeon_vm {
787 struct list_head list; 794 struct list_head list;
788 struct list_head va; 795 struct list_head va;
@@ -1460,6 +1467,8 @@ struct radeon_uvd {
1460 struct radeon_bo *vcpu_bo; 1467 struct radeon_bo *vcpu_bo;
1461 void *cpu_addr; 1468 void *cpu_addr;
1462 uint64_t gpu_addr; 1469 uint64_t gpu_addr;
1470 void *saved_bo;
1471 unsigned fw_size;
1463 atomic_t handles[RADEON_MAX_UVD_HANDLES]; 1472 atomic_t handles[RADEON_MAX_UVD_HANDLES];
1464 struct drm_file *filp[RADEON_MAX_UVD_HANDLES]; 1473 struct drm_file *filp[RADEON_MAX_UVD_HANDLES];
1465 struct delayed_work idle_work; 1474 struct delayed_work idle_work;
@@ -2054,7 +2063,6 @@ struct radeon_device {
2054 const struct firmware *rlc_fw; /* r6/700 RLC firmware */ 2063 const struct firmware *rlc_fw; /* r6/700 RLC firmware */
2055 const struct firmware *mc_fw; /* NI MC firmware */ 2064 const struct firmware *mc_fw; /* NI MC firmware */
2056 const struct firmware *ce_fw; /* SI CE firmware */ 2065 const struct firmware *ce_fw; /* SI CE firmware */
2057 const struct firmware *uvd_fw; /* UVD firmware */
2058 const struct firmware *mec_fw; /* CIK MEC firmware */ 2066 const struct firmware *mec_fw; /* CIK MEC firmware */
2059 const struct firmware *sdma_fw; /* CIK SDMA firmware */ 2067 const struct firmware *sdma_fw; /* CIK SDMA firmware */
2060 const struct firmware *smc_fw; /* SMC firmware */ 2068 const struct firmware *smc_fw; /* SMC firmware */
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
index 097077499cc6..f8f8b3113ddd 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -1026,8 +1026,8 @@ static struct radeon_asic r600_asic = {
1026 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, 1026 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1027 .dma = &r600_copy_dma, 1027 .dma = &r600_copy_dma,
1028 .dma_ring_index = R600_RING_TYPE_DMA_INDEX, 1028 .dma_ring_index = R600_RING_TYPE_DMA_INDEX,
1029 .copy = &r600_copy_dma, 1029 .copy = &r600_copy_cpdma,
1030 .copy_ring_index = R600_RING_TYPE_DMA_INDEX, 1030 .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1031 }, 1031 },
1032 .surface = { 1032 .surface = {
1033 .set_reg = r600_set_surface_reg, 1033 .set_reg = r600_set_surface_reg,
@@ -1119,8 +1119,8 @@ static struct radeon_asic rv6xx_asic = {
1119 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, 1119 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1120 .dma = &r600_copy_dma, 1120 .dma = &r600_copy_dma,
1121 .dma_ring_index = R600_RING_TYPE_DMA_INDEX, 1121 .dma_ring_index = R600_RING_TYPE_DMA_INDEX,
1122 .copy = &r600_copy_dma, 1122 .copy = &r600_copy_cpdma,
1123 .copy_ring_index = R600_RING_TYPE_DMA_INDEX, 1123 .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1124 }, 1124 },
1125 .surface = { 1125 .surface = {
1126 .set_reg = r600_set_surface_reg, 1126 .set_reg = r600_set_surface_reg,
@@ -1161,6 +1161,7 @@ static struct radeon_asic rv6xx_asic = {
1161 .get_mclk = &rv6xx_dpm_get_mclk, 1161 .get_mclk = &rv6xx_dpm_get_mclk,
1162 .print_power_state = &rv6xx_dpm_print_power_state, 1162 .print_power_state = &rv6xx_dpm_print_power_state,
1163 .debugfs_print_current_performance_level = &rv6xx_dpm_debugfs_print_current_performance_level, 1163 .debugfs_print_current_performance_level = &rv6xx_dpm_debugfs_print_current_performance_level,
1164 .force_performance_level = &rv6xx_dpm_force_performance_level,
1164 }, 1165 },
1165 .pflip = { 1166 .pflip = {
1166 .pre_page_flip = &rs600_pre_page_flip, 1167 .pre_page_flip = &rs600_pre_page_flip,
@@ -1229,8 +1230,8 @@ static struct radeon_asic rs780_asic = {
1229 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, 1230 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1230 .dma = &r600_copy_dma, 1231 .dma = &r600_copy_dma,
1231 .dma_ring_index = R600_RING_TYPE_DMA_INDEX, 1232 .dma_ring_index = R600_RING_TYPE_DMA_INDEX,
1232 .copy = &r600_copy_dma, 1233 .copy = &r600_copy_cpdma,
1233 .copy_ring_index = R600_RING_TYPE_DMA_INDEX, 1234 .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1234 }, 1235 },
1235 .surface = { 1236 .surface = {
1236 .set_reg = r600_set_surface_reg, 1237 .set_reg = r600_set_surface_reg,
@@ -1270,6 +1271,7 @@ static struct radeon_asic rs780_asic = {
1270 .get_sclk = &rs780_dpm_get_sclk, 1271 .get_sclk = &rs780_dpm_get_sclk,
1271 .get_mclk = &rs780_dpm_get_mclk, 1272 .get_mclk = &rs780_dpm_get_mclk,
1272 .print_power_state = &rs780_dpm_print_power_state, 1273 .print_power_state = &rs780_dpm_print_power_state,
1274 .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level,
1273 }, 1275 },
1274 .pflip = { 1276 .pflip = {
1275 .pre_page_flip = &rs600_pre_page_flip, 1277 .pre_page_flip = &rs600_pre_page_flip,
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 45d0693cddd5..902479fa737f 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -340,6 +340,9 @@ int r600_uvd_ring_test(struct radeon_device *rdev, struct radeon_ring *ring);
340int r600_copy_blit(struct radeon_device *rdev, 340int r600_copy_blit(struct radeon_device *rdev,
341 uint64_t src_offset, uint64_t dst_offset, 341 uint64_t src_offset, uint64_t dst_offset,
342 unsigned num_gpu_pages, struct radeon_fence **fence); 342 unsigned num_gpu_pages, struct radeon_fence **fence);
343int r600_copy_cpdma(struct radeon_device *rdev,
344 uint64_t src_offset, uint64_t dst_offset,
345 unsigned num_gpu_pages, struct radeon_fence **fence);
343int r600_copy_dma(struct radeon_device *rdev, 346int r600_copy_dma(struct radeon_device *rdev,
344 uint64_t src_offset, uint64_t dst_offset, 347 uint64_t src_offset, uint64_t dst_offset,
345 unsigned num_gpu_pages, struct radeon_fence **fence); 348 unsigned num_gpu_pages, struct radeon_fence **fence);
@@ -418,6 +421,8 @@ void rv6xx_dpm_print_power_state(struct radeon_device *rdev,
418 struct radeon_ps *ps); 421 struct radeon_ps *ps);
419void rv6xx_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, 422void rv6xx_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
420 struct seq_file *m); 423 struct seq_file *m);
424int rv6xx_dpm_force_performance_level(struct radeon_device *rdev,
425 enum radeon_dpm_forced_level level);
421/* rs780 dpm */ 426/* rs780 dpm */
422int rs780_dpm_init(struct radeon_device *rdev); 427int rs780_dpm_init(struct radeon_device *rdev);
423int rs780_dpm_enable(struct radeon_device *rdev); 428int rs780_dpm_enable(struct radeon_device *rdev);
@@ -430,6 +435,8 @@ u32 rs780_dpm_get_sclk(struct radeon_device *rdev, bool low);
430u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low); 435u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low);
431void rs780_dpm_print_power_state(struct radeon_device *rdev, 436void rs780_dpm_print_power_state(struct radeon_device *rdev,
432 struct radeon_ps *ps); 437 struct radeon_ps *ps);
438void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
439 struct seq_file *m);
433 440
434/* uvd */ 441/* uvd */
435int r600_uvd_init(struct radeon_device *rdev); 442int r600_uvd_init(struct radeon_device *rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index fbdaff55556b..e3f3e8841789 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -3513,7 +3513,6 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
3513 u8 frev, crev, i; 3513 u8 frev, crev, i;
3514 u16 data_offset, size; 3514 u16 data_offset, size;
3515 union vram_info *vram_info; 3515 union vram_info *vram_info;
3516 u8 *p;
3517 3516
3518 memset(mem_info, 0, sizeof(struct atom_memory_info)); 3517 memset(mem_info, 0, sizeof(struct atom_memory_info));
3519 3518
@@ -3529,13 +3528,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
3529 if (module_index < vram_info->v1_3.ucNumOfVRAMModule) { 3528 if (module_index < vram_info->v1_3.ucNumOfVRAMModule) {
3530 ATOM_VRAM_MODULE_V3 *vram_module = 3529 ATOM_VRAM_MODULE_V3 *vram_module =
3531 (ATOM_VRAM_MODULE_V3 *)vram_info->v1_3.aVramInfo; 3530 (ATOM_VRAM_MODULE_V3 *)vram_info->v1_3.aVramInfo;
3532 p = (u8 *)vram_info->v1_3.aVramInfo;
3533 3531
3534 for (i = 0; i < module_index; i++) { 3532 for (i = 0; i < module_index; i++) {
3535 vram_module = (ATOM_VRAM_MODULE_V3 *)p;
3536 if (le16_to_cpu(vram_module->usSize) == 0) 3533 if (le16_to_cpu(vram_module->usSize) == 0)
3537 return -EINVAL; 3534 return -EINVAL;
3538 p += le16_to_cpu(vram_module->usSize); 3535 vram_module = (ATOM_VRAM_MODULE_V3 *)
3536 ((u8 *)vram_module + le16_to_cpu(vram_module->usSize));
3539 } 3537 }
3540 mem_info->mem_vendor = vram_module->asMemory.ucMemoryVenderID & 0xf; 3538 mem_info->mem_vendor = vram_module->asMemory.ucMemoryVenderID & 0xf;
3541 mem_info->mem_type = vram_module->asMemory.ucMemoryType & 0xf0; 3539 mem_info->mem_type = vram_module->asMemory.ucMemoryType & 0xf0;
@@ -3547,13 +3545,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
3547 if (module_index < vram_info->v1_4.ucNumOfVRAMModule) { 3545 if (module_index < vram_info->v1_4.ucNumOfVRAMModule) {
3548 ATOM_VRAM_MODULE_V4 *vram_module = 3546 ATOM_VRAM_MODULE_V4 *vram_module =
3549 (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo; 3547 (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo;
3550 p = (u8 *)vram_info->v1_4.aVramInfo;
3551 3548
3552 for (i = 0; i < module_index; i++) { 3549 for (i = 0; i < module_index; i++) {
3553 vram_module = (ATOM_VRAM_MODULE_V4 *)p;
3554 if (le16_to_cpu(vram_module->usModuleSize) == 0) 3550 if (le16_to_cpu(vram_module->usModuleSize) == 0)
3555 return -EINVAL; 3551 return -EINVAL;
3556 p += le16_to_cpu(vram_module->usModuleSize); 3552 vram_module = (ATOM_VRAM_MODULE_V4 *)
3553 ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize));
3557 } 3554 }
3558 mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf; 3555 mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf;
3559 mem_info->mem_type = vram_module->ucMemoryType & 0xf0; 3556 mem_info->mem_type = vram_module->ucMemoryType & 0xf0;
@@ -3572,13 +3569,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
3572 if (module_index < vram_info->v2_1.ucNumOfVRAMModule) { 3569 if (module_index < vram_info->v2_1.ucNumOfVRAMModule) {
3573 ATOM_VRAM_MODULE_V7 *vram_module = 3570 ATOM_VRAM_MODULE_V7 *vram_module =
3574 (ATOM_VRAM_MODULE_V7 *)vram_info->v2_1.aVramInfo; 3571 (ATOM_VRAM_MODULE_V7 *)vram_info->v2_1.aVramInfo;
3575 p = (u8 *)vram_info->v2_1.aVramInfo;
3576 3572
3577 for (i = 0; i < module_index; i++) { 3573 for (i = 0; i < module_index; i++) {
3578 vram_module = (ATOM_VRAM_MODULE_V7 *)p;
3579 if (le16_to_cpu(vram_module->usModuleSize) == 0) 3574 if (le16_to_cpu(vram_module->usModuleSize) == 0)
3580 return -EINVAL; 3575 return -EINVAL;
3581 p += le16_to_cpu(vram_module->usModuleSize); 3576 vram_module = (ATOM_VRAM_MODULE_V7 *)
3577 ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize));
3582 } 3578 }
3583 mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf; 3579 mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf;
3584 mem_info->mem_type = vram_module->ucMemoryType & 0xf0; 3580 mem_info->mem_type = vram_module->ucMemoryType & 0xf0;
@@ -3628,21 +3624,19 @@ int radeon_atom_get_mclk_range_table(struct radeon_device *rdev,
3628 if (module_index < vram_info->v1_4.ucNumOfVRAMModule) { 3624 if (module_index < vram_info->v1_4.ucNumOfVRAMModule) {
3629 ATOM_VRAM_MODULE_V4 *vram_module = 3625 ATOM_VRAM_MODULE_V4 *vram_module =
3630 (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo; 3626 (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo;
3631 ATOM_MEMORY_TIMING_FORMAT *format;
3632 p = (u8 *)vram_info->v1_4.aVramInfo;
3633 3627
3634 for (i = 0; i < module_index; i++) { 3628 for (i = 0; i < module_index; i++) {
3635 vram_module = (ATOM_VRAM_MODULE_V4 *)p;
3636 if (le16_to_cpu(vram_module->usModuleSize) == 0) 3629 if (le16_to_cpu(vram_module->usModuleSize) == 0)
3637 return -EINVAL; 3630 return -EINVAL;
3638 p += le16_to_cpu(vram_module->usModuleSize); 3631 vram_module = (ATOM_VRAM_MODULE_V4 *)
3632 ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize));
3639 } 3633 }
3640 mclk_range_table->num_entries = (u8) 3634 mclk_range_table->num_entries = (u8)
3641 ((vram_module->usModuleSize - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) / 3635 ((le16_to_cpu(vram_module->usModuleSize) - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) /
3642 mem_timing_size); 3636 mem_timing_size);
3643 p = (u8 *)vram_module->asMemTiming; 3637 p = (u8 *)&vram_module->asMemTiming[0];
3644 for (i = 0; i < mclk_range_table->num_entries; i++) { 3638 for (i = 0; i < mclk_range_table->num_entries; i++) {
3645 format = (ATOM_MEMORY_TIMING_FORMAT *)p; 3639 ATOM_MEMORY_TIMING_FORMAT *format = (ATOM_MEMORY_TIMING_FORMAT *)p;
3646 mclk_range_table->mclk[i] = le32_to_cpu(format->ulClkRange); 3640 mclk_range_table->mclk[i] = le32_to_cpu(format->ulClkRange);
3647 p += mem_timing_size; 3641 p += mem_timing_size;
3648 } 3642 }
@@ -3705,17 +3699,21 @@ int radeon_atom_init_mc_reg_table(struct radeon_device *rdev,
3705 (ATOM_MEMORY_SETTING_DATA_BLOCK *) 3699 (ATOM_MEMORY_SETTING_DATA_BLOCK *)
3706 ((u8 *)reg_block + (2 * sizeof(u16)) + 3700 ((u8 *)reg_block + (2 * sizeof(u16)) +
3707 le16_to_cpu(reg_block->usRegIndexTblSize)); 3701 le16_to_cpu(reg_block->usRegIndexTblSize));
3702 ATOM_INIT_REG_INDEX_FORMAT *format = &reg_block->asRegIndexBuf[0];
3708 num_entries = (u8)((le16_to_cpu(reg_block->usRegIndexTblSize)) / 3703 num_entries = (u8)((le16_to_cpu(reg_block->usRegIndexTblSize)) /
3709 sizeof(ATOM_INIT_REG_INDEX_FORMAT)) - 1; 3704 sizeof(ATOM_INIT_REG_INDEX_FORMAT)) - 1;
3710 if (num_entries > VBIOS_MC_REGISTER_ARRAY_SIZE) 3705 if (num_entries > VBIOS_MC_REGISTER_ARRAY_SIZE)
3711 return -EINVAL; 3706 return -EINVAL;
3712 while (!(reg_block->asRegIndexBuf[i].ucPreRegDataLength & ACCESS_PLACEHOLDER) && 3707 while (i < num_entries) {
3713 (i < num_entries)) { 3708 if (format->ucPreRegDataLength & ACCESS_PLACEHOLDER)
3709 break;
3714 reg_table->mc_reg_address[i].s1 = 3710 reg_table->mc_reg_address[i].s1 =
3715 (u16)(le16_to_cpu(reg_block->asRegIndexBuf[i].usRegIndex)); 3711 (u16)(le16_to_cpu(format->usRegIndex));
3716 reg_table->mc_reg_address[i].pre_reg_data = 3712 reg_table->mc_reg_address[i].pre_reg_data =
3717 (u8)(reg_block->asRegIndexBuf[i].ucPreRegDataLength); 3713 (u8)(format->ucPreRegDataLength);
3718 i++; 3714 i++;
3715 format = (ATOM_INIT_REG_INDEX_FORMAT *)
3716 ((u8 *)format + sizeof(ATOM_INIT_REG_INDEX_FORMAT));
3719 } 3717 }
3720 reg_table->last = i; 3718 reg_table->last = i;
3721 while ((*(u32 *)reg_data != END_OF_REG_DATA_BLOCK) && 3719 while ((*(u32 *)reg_data != END_OF_REG_DATA_BLOCK) &&
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 78edadc9e86b..68ce36056019 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -147,7 +147,7 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
147 enum radeon_combios_table_offset table) 147 enum radeon_combios_table_offset table)
148{ 148{
149 struct radeon_device *rdev = dev->dev_private; 149 struct radeon_device *rdev = dev->dev_private;
150 int rev; 150 int rev, size;
151 uint16_t offset = 0, check_offset; 151 uint16_t offset = 0, check_offset;
152 152
153 if (!rdev->bios) 153 if (!rdev->bios)
@@ -156,174 +156,106 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
156 switch (table) { 156 switch (table) {
157 /* absolute offset tables */ 157 /* absolute offset tables */
158 case COMBIOS_ASIC_INIT_1_TABLE: 158 case COMBIOS_ASIC_INIT_1_TABLE:
159 check_offset = RBIOS16(rdev->bios_header_start + 0xc); 159 check_offset = 0xc;
160 if (check_offset)
161 offset = check_offset;
162 break; 160 break;
163 case COMBIOS_BIOS_SUPPORT_TABLE: 161 case COMBIOS_BIOS_SUPPORT_TABLE:
164 check_offset = RBIOS16(rdev->bios_header_start + 0x14); 162 check_offset = 0x14;
165 if (check_offset)
166 offset = check_offset;
167 break; 163 break;
168 case COMBIOS_DAC_PROGRAMMING_TABLE: 164 case COMBIOS_DAC_PROGRAMMING_TABLE:
169 check_offset = RBIOS16(rdev->bios_header_start + 0x2a); 165 check_offset = 0x2a;
170 if (check_offset)
171 offset = check_offset;
172 break; 166 break;
173 case COMBIOS_MAX_COLOR_DEPTH_TABLE: 167 case COMBIOS_MAX_COLOR_DEPTH_TABLE:
174 check_offset = RBIOS16(rdev->bios_header_start + 0x2c); 168 check_offset = 0x2c;
175 if (check_offset)
176 offset = check_offset;
177 break; 169 break;
178 case COMBIOS_CRTC_INFO_TABLE: 170 case COMBIOS_CRTC_INFO_TABLE:
179 check_offset = RBIOS16(rdev->bios_header_start + 0x2e); 171 check_offset = 0x2e;
180 if (check_offset)
181 offset = check_offset;
182 break; 172 break;
183 case COMBIOS_PLL_INFO_TABLE: 173 case COMBIOS_PLL_INFO_TABLE:
184 check_offset = RBIOS16(rdev->bios_header_start + 0x30); 174 check_offset = 0x30;
185 if (check_offset)
186 offset = check_offset;
187 break; 175 break;
188 case COMBIOS_TV_INFO_TABLE: 176 case COMBIOS_TV_INFO_TABLE:
189 check_offset = RBIOS16(rdev->bios_header_start + 0x32); 177 check_offset = 0x32;
190 if (check_offset)
191 offset = check_offset;
192 break; 178 break;
193 case COMBIOS_DFP_INFO_TABLE: 179 case COMBIOS_DFP_INFO_TABLE:
194 check_offset = RBIOS16(rdev->bios_header_start + 0x34); 180 check_offset = 0x34;
195 if (check_offset)
196 offset = check_offset;
197 break; 181 break;
198 case COMBIOS_HW_CONFIG_INFO_TABLE: 182 case COMBIOS_HW_CONFIG_INFO_TABLE:
199 check_offset = RBIOS16(rdev->bios_header_start + 0x36); 183 check_offset = 0x36;
200 if (check_offset)
201 offset = check_offset;
202 break; 184 break;
203 case COMBIOS_MULTIMEDIA_INFO_TABLE: 185 case COMBIOS_MULTIMEDIA_INFO_TABLE:
204 check_offset = RBIOS16(rdev->bios_header_start + 0x38); 186 check_offset = 0x38;
205 if (check_offset)
206 offset = check_offset;
207 break; 187 break;
208 case COMBIOS_TV_STD_PATCH_TABLE: 188 case COMBIOS_TV_STD_PATCH_TABLE:
209 check_offset = RBIOS16(rdev->bios_header_start + 0x3e); 189 check_offset = 0x3e;
210 if (check_offset)
211 offset = check_offset;
212 break; 190 break;
213 case COMBIOS_LCD_INFO_TABLE: 191 case COMBIOS_LCD_INFO_TABLE:
214 check_offset = RBIOS16(rdev->bios_header_start + 0x40); 192 check_offset = 0x40;
215 if (check_offset)
216 offset = check_offset;
217 break; 193 break;
218 case COMBIOS_MOBILE_INFO_TABLE: 194 case COMBIOS_MOBILE_INFO_TABLE:
219 check_offset = RBIOS16(rdev->bios_header_start + 0x42); 195 check_offset = 0x42;
220 if (check_offset)
221 offset = check_offset;
222 break; 196 break;
223 case COMBIOS_PLL_INIT_TABLE: 197 case COMBIOS_PLL_INIT_TABLE:
224 check_offset = RBIOS16(rdev->bios_header_start + 0x46); 198 check_offset = 0x46;
225 if (check_offset)
226 offset = check_offset;
227 break; 199 break;
228 case COMBIOS_MEM_CONFIG_TABLE: 200 case COMBIOS_MEM_CONFIG_TABLE:
229 check_offset = RBIOS16(rdev->bios_header_start + 0x48); 201 check_offset = 0x48;
230 if (check_offset)
231 offset = check_offset;
232 break; 202 break;
233 case COMBIOS_SAVE_MASK_TABLE: 203 case COMBIOS_SAVE_MASK_TABLE:
234 check_offset = RBIOS16(rdev->bios_header_start + 0x4a); 204 check_offset = 0x4a;
235 if (check_offset)
236 offset = check_offset;
237 break; 205 break;
238 case COMBIOS_HARDCODED_EDID_TABLE: 206 case COMBIOS_HARDCODED_EDID_TABLE:
239 check_offset = RBIOS16(rdev->bios_header_start + 0x4c); 207 check_offset = 0x4c;
240 if (check_offset)
241 offset = check_offset;
242 break; 208 break;
243 case COMBIOS_ASIC_INIT_2_TABLE: 209 case COMBIOS_ASIC_INIT_2_TABLE:
244 check_offset = RBIOS16(rdev->bios_header_start + 0x4e); 210 check_offset = 0x4e;
245 if (check_offset)
246 offset = check_offset;
247 break; 211 break;
248 case COMBIOS_CONNECTOR_INFO_TABLE: 212 case COMBIOS_CONNECTOR_INFO_TABLE:
249 check_offset = RBIOS16(rdev->bios_header_start + 0x50); 213 check_offset = 0x50;
250 if (check_offset)
251 offset = check_offset;
252 break; 214 break;
253 case COMBIOS_DYN_CLK_1_TABLE: 215 case COMBIOS_DYN_CLK_1_TABLE:
254 check_offset = RBIOS16(rdev->bios_header_start + 0x52); 216 check_offset = 0x52;
255 if (check_offset)
256 offset = check_offset;
257 break; 217 break;
258 case COMBIOS_RESERVED_MEM_TABLE: 218 case COMBIOS_RESERVED_MEM_TABLE:
259 check_offset = RBIOS16(rdev->bios_header_start + 0x54); 219 check_offset = 0x54;
260 if (check_offset)
261 offset = check_offset;
262 break; 220 break;
263 case COMBIOS_EXT_TMDS_INFO_TABLE: 221 case COMBIOS_EXT_TMDS_INFO_TABLE:
264 check_offset = RBIOS16(rdev->bios_header_start + 0x58); 222 check_offset = 0x58;
265 if (check_offset)
266 offset = check_offset;
267 break; 223 break;
268 case COMBIOS_MEM_CLK_INFO_TABLE: 224 case COMBIOS_MEM_CLK_INFO_TABLE:
269 check_offset = RBIOS16(rdev->bios_header_start + 0x5a); 225 check_offset = 0x5a;
270 if (check_offset)
271 offset = check_offset;
272 break; 226 break;
273 case COMBIOS_EXT_DAC_INFO_TABLE: 227 case COMBIOS_EXT_DAC_INFO_TABLE:
274 check_offset = RBIOS16(rdev->bios_header_start + 0x5c); 228 check_offset = 0x5c;
275 if (check_offset)
276 offset = check_offset;
277 break; 229 break;
278 case COMBIOS_MISC_INFO_TABLE: 230 case COMBIOS_MISC_INFO_TABLE:
279 check_offset = RBIOS16(rdev->bios_header_start + 0x5e); 231 check_offset = 0x5e;
280 if (check_offset)
281 offset = check_offset;
282 break; 232 break;
283 case COMBIOS_CRT_INFO_TABLE: 233 case COMBIOS_CRT_INFO_TABLE:
284 check_offset = RBIOS16(rdev->bios_header_start + 0x60); 234 check_offset = 0x60;
285 if (check_offset)
286 offset = check_offset;
287 break; 235 break;
288 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE: 236 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
289 check_offset = RBIOS16(rdev->bios_header_start + 0x62); 237 check_offset = 0x62;
290 if (check_offset)
291 offset = check_offset;
292 break; 238 break;
293 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE: 239 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
294 check_offset = RBIOS16(rdev->bios_header_start + 0x64); 240 check_offset = 0x64;
295 if (check_offset)
296 offset = check_offset;
297 break; 241 break;
298 case COMBIOS_FAN_SPEED_INFO_TABLE: 242 case COMBIOS_FAN_SPEED_INFO_TABLE:
299 check_offset = RBIOS16(rdev->bios_header_start + 0x66); 243 check_offset = 0x66;
300 if (check_offset)
301 offset = check_offset;
302 break; 244 break;
303 case COMBIOS_OVERDRIVE_INFO_TABLE: 245 case COMBIOS_OVERDRIVE_INFO_TABLE:
304 check_offset = RBIOS16(rdev->bios_header_start + 0x68); 246 check_offset = 0x68;
305 if (check_offset)
306 offset = check_offset;
307 break; 247 break;
308 case COMBIOS_OEM_INFO_TABLE: 248 case COMBIOS_OEM_INFO_TABLE:
309 check_offset = RBIOS16(rdev->bios_header_start + 0x6a); 249 check_offset = 0x6a;
310 if (check_offset)
311 offset = check_offset;
312 break; 250 break;
313 case COMBIOS_DYN_CLK_2_TABLE: 251 case COMBIOS_DYN_CLK_2_TABLE:
314 check_offset = RBIOS16(rdev->bios_header_start + 0x6c); 252 check_offset = 0x6c;
315 if (check_offset)
316 offset = check_offset;
317 break; 253 break;
318 case COMBIOS_POWER_CONNECTOR_INFO_TABLE: 254 case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
319 check_offset = RBIOS16(rdev->bios_header_start + 0x6e); 255 check_offset = 0x6e;
320 if (check_offset)
321 offset = check_offset;
322 break; 256 break;
323 case COMBIOS_I2C_INFO_TABLE: 257 case COMBIOS_I2C_INFO_TABLE:
324 check_offset = RBIOS16(rdev->bios_header_start + 0x70); 258 check_offset = 0x70;
325 if (check_offset)
326 offset = check_offset;
327 break; 259 break;
328 /* relative offset tables */ 260 /* relative offset tables */
329 case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */ 261 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,
439 } 371 }
440 break; 372 break;
441 default: 373 default:
374 check_offset = 0;
442 break; 375 break;
443 } 376 }
444 377
445 return offset; 378 size = RBIOS8(rdev->bios_header_start + 0x6);
379 /* check absolute offset tables */
380 if (table < COMBIOS_ASIC_INIT_3_TABLE && check_offset && check_offset < size)
381 offset = RBIOS16(rdev->bios_header_start + check_offset);
446 382
383 return offset;
447} 384}
448 385
449bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev) 386bool 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
965 dac = RBIOS8(dac_info + 0x3) & 0xf; 902 dac = RBIOS8(dac_info + 0x3) & 0xf;
966 p_dac->ps2_pdac_adj = (bg << 8) | (dac); 903 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
967 } 904 }
968 /* if the values are all zeros, use the table */ 905 /* if the values are zeros, use the table */
969 if (p_dac->ps2_pdac_adj) 906 if ((dac == 0) || (bg == 0))
907 found = 0;
908 else
970 found = 1; 909 found = 1;
971 } 910 }
972 911
973 /* quirks */ 912 /* quirks */
913 /* Radeon 7000 (RV100) */
914 if (((dev->pdev->device == 0x5159) &&
915 (dev->pdev->subsystem_vendor == 0x174B) &&
916 (dev->pdev->subsystem_device == 0x7c28)) ||
974 /* Radeon 9100 (R200) */ 917 /* Radeon 9100 (R200) */
975 if ((dev->pdev->device == 0x514D) && 918 ((dev->pdev->device == 0x514D) &&
976 (dev->pdev->subsystem_vendor == 0x174B) && 919 (dev->pdev->subsystem_vendor == 0x174B) &&
977 (dev->pdev->subsystem_device == 0x7149)) { 920 (dev->pdev->subsystem_device == 0x7149))) {
978 /* vbios value is bad, use the default */ 921 /* vbios value is bad, use the default */
979 found = 0; 922 found = 0;
980 } 923 }
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index e5419b350170..29876b1be8ec 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -167,6 +167,7 @@ int radeon_msi = -1;
167int radeon_lockup_timeout = 10000; 167int radeon_lockup_timeout = 10000;
168int radeon_fastfb = 0; 168int radeon_fastfb = 0;
169int radeon_dpm = -1; 169int radeon_dpm = -1;
170int radeon_aspm = -1;
170 171
171MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers"); 172MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
172module_param_named(no_wb, radeon_no_wb, int, 0444); 173module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -225,6 +226,9 @@ module_param_named(fastfb, radeon_fastfb, int, 0444);
225MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)"); 226MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)");
226module_param_named(dpm, radeon_dpm, int, 0444); 227module_param_named(dpm, radeon_dpm, int, 0444);
227 228
229MODULE_PARM_DESC(aspm, "ASPM support (1 = enable, 0 = disable, -1 = auto)");
230module_param_named(aspm, radeon_aspm, int, 0444);
231
228static struct pci_device_id pciidlist[] = { 232static struct pci_device_id pciidlist[] = {
229 radeon_PCI_IDS 233 radeon_PCI_IDS
230}; 234};
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index ddb8f8e04eb5..7ddb0efe2408 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -782,7 +782,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
782 782
783 } else { 783 } else {
784 /* put fence directly behind firmware */ 784 /* put fence directly behind firmware */
785 index = ALIGN(rdev->uvd_fw->size, 8); 785 index = ALIGN(rdev->uvd.fw_size, 8);
786 rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index; 786 rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index;
787 rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index; 787 rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index;
788 } 788 }
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 43ec4a401f07..6a51d943ccf4 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -467,6 +467,7 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
467 size *= 2; 467 size *= 2;
468 r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager, 468 r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager,
469 RADEON_GPU_PAGE_ALIGN(size), 469 RADEON_GPU_PAGE_ALIGN(size),
470 RADEON_VM_PTB_ALIGN_SIZE,
470 RADEON_GEM_DOMAIN_VRAM); 471 RADEON_GEM_DOMAIN_VRAM);
471 if (r) { 472 if (r) {
472 dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n", 473 dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n",
@@ -620,10 +621,10 @@ int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm)
620 } 621 }
621 622
622retry: 623retry:
623 pd_size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev)); 624 pd_size = radeon_vm_directory_size(rdev);
624 r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager, 625 r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
625 &vm->page_directory, pd_size, 626 &vm->page_directory, pd_size,
626 RADEON_GPU_PAGE_SIZE, false); 627 RADEON_VM_PTB_ALIGN_SIZE, false);
627 if (r == -ENOMEM) { 628 if (r == -ENOMEM) {
628 r = radeon_vm_evict(rdev, vm); 629 r = radeon_vm_evict(rdev, vm);
629 if (r) 630 if (r)
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index bcdefd1dcd43..081886b0642d 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -260,10 +260,6 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
260{ 260{
261 int r = 0; 261 int r = 0;
262 262
263 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
264 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
265 INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
266
267 spin_lock_init(&rdev->irq.lock); 263 spin_lock_init(&rdev->irq.lock);
268 r = drm_vblank_init(rdev->ddev, rdev->num_crtc); 264 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
269 if (r) { 265 if (r) {
@@ -285,6 +281,11 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
285 rdev->irq.installed = false; 281 rdev->irq.installed = false;
286 return r; 282 return r;
287 } 283 }
284
285 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
286 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
287 INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
288
288 DRM_INFO("radeon: irq initialized.\n"); 289 DRM_INFO("radeon: irq initialized.\n");
289 return 0; 290 return 0;
290} 291}
@@ -304,8 +305,8 @@ void radeon_irq_kms_fini(struct radeon_device *rdev)
304 rdev->irq.installed = false; 305 rdev->irq.installed = false;
305 if (rdev->msi_enabled) 306 if (rdev->msi_enabled)
306 pci_disable_msi(rdev->pdev); 307 pci_disable_msi(rdev->pdev);
308 flush_work(&rdev->hotplug_work);
307 } 309 }
308 flush_work(&rdev->hotplug_work);
309} 310}
310 311
311/** 312/**
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 0219d263e2df..2020bf4a3830 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -377,6 +377,7 @@ int radeon_bo_list_validate(struct ww_acquire_ctx *ticket,
377 domain = lobj->alt_domain; 377 domain = lobj->alt_domain;
378 goto retry; 378 goto retry;
379 } 379 }
380 ttm_eu_backoff_reservation(ticket, head);
380 return r; 381 return r;
381 } 382 }
382 } 383 }
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
index 91519a5622b4..49c82c480013 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -174,7 +174,7 @@ static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo)
174 174
175extern int radeon_sa_bo_manager_init(struct radeon_device *rdev, 175extern int radeon_sa_bo_manager_init(struct radeon_device *rdev,
176 struct radeon_sa_manager *sa_manager, 176 struct radeon_sa_manager *sa_manager,
177 unsigned size, u32 domain); 177 unsigned size, u32 align, u32 domain);
178extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev, 178extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev,
179 struct radeon_sa_manager *sa_manager); 179 struct radeon_sa_manager *sa_manager);
180extern int radeon_sa_bo_manager_start(struct radeon_device *rdev, 180extern int radeon_sa_bo_manager_start(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 5f1c51a776ed..fb5ea6208970 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -224,6 +224,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
224 } 224 }
225 r = radeon_sa_bo_manager_init(rdev, &rdev->ring_tmp_bo, 225 r = radeon_sa_bo_manager_init(rdev, &rdev->ring_tmp_bo,
226 RADEON_IB_POOL_SIZE*64*1024, 226 RADEON_IB_POOL_SIZE*64*1024,
227 RADEON_GPU_PAGE_SIZE,
227 RADEON_GEM_DOMAIN_GTT); 228 RADEON_GEM_DOMAIN_GTT);
228 if (r) { 229 if (r) {
229 return r; 230 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c
index 0abe5a9431bb..f0bac68254b7 100644
--- a/drivers/gpu/drm/radeon/radeon_sa.c
+++ b/drivers/gpu/drm/radeon/radeon_sa.c
@@ -49,7 +49,7 @@ static void radeon_sa_bo_try_free(struct radeon_sa_manager *sa_manager);
49 49
50int radeon_sa_bo_manager_init(struct radeon_device *rdev, 50int radeon_sa_bo_manager_init(struct radeon_device *rdev,
51 struct radeon_sa_manager *sa_manager, 51 struct radeon_sa_manager *sa_manager,
52 unsigned size, u32 domain) 52 unsigned size, u32 align, u32 domain)
53{ 53{
54 int i, r; 54 int i, r;
55 55
@@ -57,13 +57,14 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev,
57 sa_manager->bo = NULL; 57 sa_manager->bo = NULL;
58 sa_manager->size = size; 58 sa_manager->size = size;
59 sa_manager->domain = domain; 59 sa_manager->domain = domain;
60 sa_manager->align = align;
60 sa_manager->hole = &sa_manager->olist; 61 sa_manager->hole = &sa_manager->olist;
61 INIT_LIST_HEAD(&sa_manager->olist); 62 INIT_LIST_HEAD(&sa_manager->olist);
62 for (i = 0; i < RADEON_NUM_RINGS; ++i) { 63 for (i = 0; i < RADEON_NUM_RINGS; ++i) {
63 INIT_LIST_HEAD(&sa_manager->flist[i]); 64 INIT_LIST_HEAD(&sa_manager->flist[i]);
64 } 65 }
65 66
66 r = radeon_bo_create(rdev, size, RADEON_GPU_PAGE_SIZE, true, 67 r = radeon_bo_create(rdev, size, align, true,
67 domain, NULL, &sa_manager->bo); 68 domain, NULL, &sa_manager->bo);
68 if (r) { 69 if (r) {
69 dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r); 70 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,
317 unsigned tries[RADEON_NUM_RINGS]; 318 unsigned tries[RADEON_NUM_RINGS];
318 int i, r; 319 int i, r;
319 320
320 BUG_ON(align > RADEON_GPU_PAGE_SIZE); 321 BUG_ON(align > sa_manager->align);
321 BUG_ON(size > sa_manager->size); 322 BUG_ON(size > sa_manager->size);
322 323
323 *sa_bo = kmalloc(sizeof(struct radeon_sa_bo), GFP_KERNEL); 324 *sa_bo = kmalloc(sizeof(struct radeon_sa_bo), GFP_KERNEL);
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 41efcec28cd8..414fd145d20e 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -56,20 +56,13 @@ static void radeon_uvd_idle_work_handler(struct work_struct *work);
56 56
57int radeon_uvd_init(struct radeon_device *rdev) 57int radeon_uvd_init(struct radeon_device *rdev)
58{ 58{
59 struct platform_device *pdev; 59 const struct firmware *fw;
60 unsigned long bo_size; 60 unsigned long bo_size;
61 const char *fw_name; 61 const char *fw_name;
62 int i, r; 62 int i, r;
63 63
64 INIT_DELAYED_WORK(&rdev->uvd.idle_work, radeon_uvd_idle_work_handler); 64 INIT_DELAYED_WORK(&rdev->uvd.idle_work, radeon_uvd_idle_work_handler);
65 65
66 pdev = platform_device_register_simple("radeon_uvd", 0, NULL, 0);
67 r = IS_ERR(pdev);
68 if (r) {
69 dev_err(rdev->dev, "radeon_uvd: Failed to register firmware\n");
70 return -EINVAL;
71 }
72
73 switch (rdev->family) { 66 switch (rdev->family) {
74 case CHIP_RV710: 67 case CHIP_RV710:
75 case CHIP_RV730: 68 case CHIP_RV730:
@@ -112,17 +105,14 @@ int radeon_uvd_init(struct radeon_device *rdev)
112 return -EINVAL; 105 return -EINVAL;
113 } 106 }
114 107
115 r = request_firmware(&rdev->uvd_fw, fw_name, &pdev->dev); 108 r = request_firmware(&fw, fw_name, rdev->dev);
116 if (r) { 109 if (r) {
117 dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n", 110 dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
118 fw_name); 111 fw_name);
119 platform_device_unregister(pdev);
120 return r; 112 return r;
121 } 113 }
122 114
123 platform_device_unregister(pdev); 115 bo_size = RADEON_GPU_PAGE_ALIGN(fw->size + 8) +
124
125 bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) +
126 RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; 116 RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE;
127 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, 117 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
128 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo); 118 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo);
@@ -131,16 +121,35 @@ int radeon_uvd_init(struct radeon_device *rdev)
131 return r; 121 return r;
132 } 122 }
133 123
134 r = radeon_uvd_resume(rdev); 124 r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false);
135 if (r) 125 if (r) {
126 radeon_bo_unref(&rdev->uvd.vcpu_bo);
127 dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r);
136 return r; 128 return r;
129 }
137 130
138 memset(rdev->uvd.cpu_addr, 0, bo_size); 131 r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM,
139 memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); 132 &rdev->uvd.gpu_addr);
133 if (r) {
134 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
135 radeon_bo_unref(&rdev->uvd.vcpu_bo);
136 dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r);
137 return r;
138 }
140 139
141 r = radeon_uvd_suspend(rdev); 140 r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
142 if (r) 141 if (r) {
142 dev_err(rdev->dev, "(%d) UVD map failed\n", r);
143 return r; 143 return r;
144 }
145
146 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
147
148 rdev->uvd.fw_size = fw->size;
149 memset(rdev->uvd.cpu_addr, 0, bo_size);
150 memcpy(rdev->uvd.cpu_addr, fw->data, fw->size);
151
152 release_firmware(fw);
144 153
145 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { 154 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
146 atomic_set(&rdev->uvd.handles[i], 0); 155 atomic_set(&rdev->uvd.handles[i], 0);
@@ -152,71 +161,47 @@ int radeon_uvd_init(struct radeon_device *rdev)
152 161
153void radeon_uvd_fini(struct radeon_device *rdev) 162void radeon_uvd_fini(struct radeon_device *rdev)
154{ 163{
155 radeon_uvd_suspend(rdev);
156 radeon_bo_unref(&rdev->uvd.vcpu_bo);
157}
158
159int radeon_uvd_suspend(struct radeon_device *rdev)
160{
161 int r; 164 int r;
162 165
163 if (rdev->uvd.vcpu_bo == NULL) 166 if (rdev->uvd.vcpu_bo == NULL)
164 return 0; 167 return;
165 168
166 r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); 169 r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false);
167 if (!r) { 170 if (!r) {
168 radeon_bo_kunmap(rdev->uvd.vcpu_bo); 171 radeon_bo_kunmap(rdev->uvd.vcpu_bo);
169 radeon_bo_unpin(rdev->uvd.vcpu_bo); 172 radeon_bo_unpin(rdev->uvd.vcpu_bo);
170 rdev->uvd.cpu_addr = NULL;
171 if (!radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_CPU, NULL)) {
172 radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
173 }
174 radeon_bo_unreserve(rdev->uvd.vcpu_bo); 173 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
175
176 if (rdev->uvd.cpu_addr) {
177 radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_UVD_INDEX);
178 } else {
179 rdev->fence_drv[R600_RING_TYPE_UVD_INDEX].cpu_addr = NULL;
180 }
181 } 174 }
182 return r; 175
176 radeon_bo_unref(&rdev->uvd.vcpu_bo);
183} 177}
184 178
185int radeon_uvd_resume(struct radeon_device *rdev) 179int radeon_uvd_suspend(struct radeon_device *rdev)
186{ 180{
187 int r; 181 unsigned size;
188 182
189 if (rdev->uvd.vcpu_bo == NULL) 183 if (rdev->uvd.vcpu_bo == NULL)
190 return -EINVAL; 184 return 0;
191 185
192 r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); 186 size = radeon_bo_size(rdev->uvd.vcpu_bo);
193 if (r) { 187 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
194 radeon_bo_unref(&rdev->uvd.vcpu_bo); 188 memcpy(rdev->uvd.saved_bo, rdev->uvd.cpu_addr, size);
195 dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r);
196 return r;
197 }
198 189
199 /* Have been pin in cpu unmap unpin */ 190 return 0;
200 radeon_bo_kunmap(rdev->uvd.vcpu_bo); 191}
201 radeon_bo_unpin(rdev->uvd.vcpu_bo);
202 192
203 r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, 193int radeon_uvd_resume(struct radeon_device *rdev)
204 &rdev->uvd.gpu_addr); 194{
205 if (r) { 195 if (rdev->uvd.vcpu_bo == NULL)
206 radeon_bo_unreserve(rdev->uvd.vcpu_bo); 196 return -EINVAL;
207 radeon_bo_unref(&rdev->uvd.vcpu_bo);
208 dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r);
209 return r;
210 }
211 197
212 r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr); 198 if (rdev->uvd.saved_bo != NULL) {
213 if (r) { 199 unsigned size = radeon_bo_size(rdev->uvd.vcpu_bo);
214 dev_err(rdev->dev, "(%d) UVD map failed\n", r); 200 memcpy(rdev->uvd.cpu_addr, rdev->uvd.saved_bo, size);
215 return r; 201 kfree(rdev->uvd.saved_bo);
202 rdev->uvd.saved_bo = NULL;
216 } 203 }
217 204
218 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
219
220 return 0; 205 return 0;
221} 206}
222 207
diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c
index bef832a62fee..d1a1ce73bd45 100644
--- a/drivers/gpu/drm/radeon/rs780_dpm.c
+++ b/drivers/gpu/drm/radeon/rs780_dpm.c
@@ -28,6 +28,7 @@
28#include "r600_dpm.h" 28#include "r600_dpm.h"
29#include "rs780_dpm.h" 29#include "rs780_dpm.h"
30#include "atom.h" 30#include "atom.h"
31#include <linux/seq_file.h>
31 32
32static struct igp_ps *rs780_get_ps(struct radeon_ps *rps) 33static struct igp_ps *rs780_get_ps(struct radeon_ps *rps)
33{ 34{
@@ -961,3 +962,27 @@ u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low)
961 962
962 return pi->bootup_uma_clk; 963 return pi->bootup_uma_clk;
963} 964}
965
966void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
967 struct seq_file *m)
968{
969 struct radeon_ps *rps = rdev->pm.dpm.current_ps;
970 struct igp_ps *ps = rs780_get_ps(rps);
971 u32 current_fb_div = RREG32(FVTHROT_STATUS_REG0) & CURRENT_FEEDBACK_DIV_MASK;
972 u32 func_cntl = RREG32(CG_SPLL_FUNC_CNTL);
973 u32 ref_div = ((func_cntl & SPLL_REF_DIV_MASK) >> SPLL_REF_DIV_SHIFT) + 1;
974 u32 post_div = ((func_cntl & SPLL_SW_HILEN_MASK) >> SPLL_SW_HILEN_SHIFT) + 1 +
975 ((func_cntl & SPLL_SW_LOLEN_MASK) >> SPLL_SW_LOLEN_SHIFT) + 1;
976 u32 sclk = (rdev->clock.spll.reference_freq * current_fb_div) /
977 (post_div * ref_div);
978
979 seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
980
981 /* guess based on the current sclk */
982 if (sclk < (ps->sclk_low + 500))
983 seq_printf(m, "power level 0 sclk: %u vddc_index: %d\n",
984 ps->sclk_low, ps->min_voltage);
985 else
986 seq_printf(m, "power level 1 sclk: %u vddc_index: %d\n",
987 ps->sclk_high, ps->max_voltage);
988}
diff --git a/drivers/gpu/drm/radeon/rs780d.h b/drivers/gpu/drm/radeon/rs780d.h
index b1142ed1c628..cfbe9a43d97b 100644
--- a/drivers/gpu/drm/radeon/rs780d.h
+++ b/drivers/gpu/drm/radeon/rs780d.h
@@ -28,6 +28,7 @@
28# define SPLL_SLEEP (1 << 1) 28# define SPLL_SLEEP (1 << 1)
29# define SPLL_REF_DIV(x) ((x) << 2) 29# define SPLL_REF_DIV(x) ((x) << 2)
30# define SPLL_REF_DIV_MASK (7 << 2) 30# define SPLL_REF_DIV_MASK (7 << 2)
31# define SPLL_REF_DIV_SHIFT 2
31# define SPLL_FB_DIV(x) ((x) << 5) 32# define SPLL_FB_DIV(x) ((x) << 5)
32# define SPLL_FB_DIV_MASK (0xff << 2) 33# define SPLL_FB_DIV_MASK (0xff << 2)
33# define SPLL_FB_DIV_SHIFT 2 34# define SPLL_FB_DIV_SHIFT 2
@@ -36,8 +37,10 @@
36# define SPLL_PULSENUM_MASK (3 << 14) 37# define SPLL_PULSENUM_MASK (3 << 14)
37# define SPLL_SW_HILEN(x) ((x) << 16) 38# define SPLL_SW_HILEN(x) ((x) << 16)
38# define SPLL_SW_HILEN_MASK (0xf << 16) 39# define SPLL_SW_HILEN_MASK (0xf << 16)
40# define SPLL_SW_HILEN_SHIFT 16
39# define SPLL_SW_LOLEN(x) ((x) << 20) 41# define SPLL_SW_LOLEN(x) ((x) << 20)
40# define SPLL_SW_LOLEN_MASK (0xf << 20) 42# define SPLL_SW_LOLEN_MASK (0xf << 20)
43# define SPLL_SW_LOLEN_SHIFT 20
41# define SPLL_DIVEN (1 << 24) 44# define SPLL_DIVEN (1 << 24)
42# define SPLL_BYPASS_EN (1 << 25) 45# define SPLL_BYPASS_EN (1 << 25)
43# define SPLL_CHG_STATUS (1 << 29) 46# define SPLL_CHG_STATUS (1 << 29)
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index 8303de267ee5..363018c60412 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -819,7 +819,7 @@ static void rv6xx_program_memory_timing_parameters(struct radeon_device *rdev)
819 POWERMODE1(calculate_memory_refresh_rate(rdev, 819 POWERMODE1(calculate_memory_refresh_rate(rdev,
820 pi->hw.sclks[R600_POWER_LEVEL_MEDIUM])) | 820 pi->hw.sclks[R600_POWER_LEVEL_MEDIUM])) |
821 POWERMODE2(calculate_memory_refresh_rate(rdev, 821 POWERMODE2(calculate_memory_refresh_rate(rdev,
822 pi->hw.sclks[R600_POWER_LEVEL_MEDIUM])) | 822 pi->hw.sclks[R600_POWER_LEVEL_HIGH])) |
823 POWERMODE3(calculate_memory_refresh_rate(rdev, 823 POWERMODE3(calculate_memory_refresh_rate(rdev,
824 pi->hw.sclks[R600_POWER_LEVEL_HIGH]))); 824 pi->hw.sclks[R600_POWER_LEVEL_HIGH])));
825 WREG32(ARB_RFSH_RATE, arb_refresh_rate); 825 WREG32(ARB_RFSH_RATE, arb_refresh_rate);
@@ -1182,10 +1182,10 @@ static void rv6xx_program_display_gap(struct radeon_device *rdev)
1182 u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL); 1182 u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
1183 1183
1184 tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK); 1184 tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
1185 if (RREG32(AVIVO_D1CRTC_CONTROL) & AVIVO_CRTC_EN) { 1185 if (rdev->pm.dpm.new_active_crtcs & 1) {
1186 tmp |= DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK); 1186 tmp |= DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK);
1187 tmp |= DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE); 1187 tmp |= DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE);
1188 } else if (RREG32(AVIVO_D2CRTC_CONTROL) & AVIVO_CRTC_EN) { 1188 } else if (rdev->pm.dpm.new_active_crtcs & 2) {
1189 tmp |= DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE); 1189 tmp |= DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE);
1190 tmp |= DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK); 1190 tmp |= DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK);
1191 } else { 1191 } else {
@@ -1670,6 +1670,8 @@ int rv6xx_dpm_set_power_state(struct radeon_device *rdev)
1670 struct radeon_ps *old_ps = rdev->pm.dpm.current_ps; 1670 struct radeon_ps *old_ps = rdev->pm.dpm.current_ps;
1671 int ret; 1671 int ret;
1672 1672
1673 pi->restricted_levels = 0;
1674
1673 rv6xx_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); 1675 rv6xx_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
1674 1676
1675 rv6xx_clear_vc(rdev); 1677 rv6xx_clear_vc(rdev);
@@ -1756,6 +1758,8 @@ int rv6xx_dpm_set_power_state(struct radeon_device *rdev)
1756 1758
1757 rv6xx_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); 1759 rv6xx_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
1758 1760
1761 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
1762
1759 return 0; 1763 return 0;
1760} 1764}
1761 1765
@@ -1763,12 +1767,14 @@ void rv6xx_setup_asic(struct radeon_device *rdev)
1763{ 1767{
1764 r600_enable_acpi_pm(rdev); 1768 r600_enable_acpi_pm(rdev);
1765 1769
1766 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s) 1770 if (radeon_aspm != 0) {
1767 rv6xx_enable_l0s(rdev); 1771 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s)
1768 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1) 1772 rv6xx_enable_l0s(rdev);
1769 rv6xx_enable_l1(rdev); 1773 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1)
1770 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1) 1774 rv6xx_enable_l1(rdev);
1771 rv6xx_enable_pll_sleep_in_l1(rdev); 1775 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1)
1776 rv6xx_enable_pll_sleep_in_l1(rdev);
1777 }
1772} 1778}
1773 1779
1774void rv6xx_dpm_display_configuration_changed(struct radeon_device *rdev) 1780void rv6xx_dpm_display_configuration_changed(struct radeon_device *rdev)
@@ -2083,3 +2089,34 @@ u32 rv6xx_dpm_get_mclk(struct radeon_device *rdev, bool low)
2083 else 2089 else
2084 return requested_state->high.mclk; 2090 return requested_state->high.mclk;
2085} 2091}
2092
2093int rv6xx_dpm_force_performance_level(struct radeon_device *rdev,
2094 enum radeon_dpm_forced_level level)
2095{
2096 struct rv6xx_power_info *pi = rv6xx_get_pi(rdev);
2097
2098 if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
2099 pi->restricted_levels = 3;
2100 } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
2101 pi->restricted_levels = 2;
2102 } else {
2103 pi->restricted_levels = 0;
2104 }
2105
2106 rv6xx_clear_vc(rdev);
2107 r600_power_level_enable(rdev, R600_POWER_LEVEL_LOW, true);
2108 r600_set_at(rdev, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);
2109 r600_wait_for_power_level(rdev, R600_POWER_LEVEL_LOW);
2110 r600_power_level_enable(rdev, R600_POWER_LEVEL_HIGH, false);
2111 r600_power_level_enable(rdev, R600_POWER_LEVEL_MEDIUM, false);
2112 rv6xx_enable_medium(rdev);
2113 rv6xx_enable_high(rdev);
2114 if (pi->restricted_levels == 3)
2115 r600_power_level_enable(rdev, R600_POWER_LEVEL_LOW, false);
2116 rv6xx_program_vc(rdev);
2117 rv6xx_program_at(rdev);
2118
2119 rdev->pm.dpm.forced_level = level;
2120
2121 return 0;
2122}
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 4a62ad2e5399..30ea14e8854c 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -813,7 +813,7 @@ int rv770_uvd_resume(struct radeon_device *rdev)
813 813
814 /* programm the VCPU memory controller bits 0-27 */ 814 /* programm the VCPU memory controller bits 0-27 */
815 addr = rdev->uvd.gpu_addr >> 3; 815 addr = rdev->uvd.gpu_addr >> 3;
816 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3; 816 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3;
817 WREG32(UVD_VCPU_CACHE_OFFSET0, addr); 817 WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
818 WREG32(UVD_VCPU_CACHE_SIZE0, size); 818 WREG32(UVD_VCPU_CACHE_SIZE0, size);
819 819
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index d914e04ea39a..2d347925f77d 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -2099,12 +2099,14 @@ void rv770_dpm_setup_asic(struct radeon_device *rdev)
2099 2099
2100 rv770_enable_acpi_pm(rdev); 2100 rv770_enable_acpi_pm(rdev);
2101 2101
2102 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s) 2102 if (radeon_aspm != 0) {
2103 rv770_enable_l0s(rdev); 2103 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s)
2104 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1) 2104 rv770_enable_l0s(rdev);
2105 rv770_enable_l1(rdev); 2105 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1)
2106 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1) 2106 rv770_enable_l1(rdev);
2107 rv770_enable_pll_sleep_in_l1(rdev); 2107 if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1)
2108 rv770_enable_pll_sleep_in_l1(rdev);
2109 }
2108} 2110}
2109 2111
2110void rv770_dpm_display_configuration_changed(struct radeon_device *rdev) 2112void rv770_dpm_display_configuration_changed(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 234906709067..d325280e2f9f 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -22,7 +22,6 @@
22 * Authors: Alex Deucher 22 * Authors: Alex Deucher
23 */ 23 */
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/platform_device.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <drm/drmP.h> 27#include <drm/drmP.h>
@@ -1541,7 +1540,6 @@ static int si_mc_load_microcode(struct radeon_device *rdev)
1541 1540
1542static int si_init_microcode(struct radeon_device *rdev) 1541static int si_init_microcode(struct radeon_device *rdev)
1543{ 1542{
1544 struct platform_device *pdev;
1545 const char *chip_name; 1543 const char *chip_name;
1546 const char *rlc_chip_name; 1544 const char *rlc_chip_name;
1547 size_t pfp_req_size, me_req_size, ce_req_size, rlc_req_size, mc_req_size; 1545 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)
1551 1549
1552 DRM_DEBUG("\n"); 1550 DRM_DEBUG("\n");
1553 1551
1554 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
1555 err = IS_ERR(pdev);
1556 if (err) {
1557 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
1558 return -EINVAL;
1559 }
1560
1561 switch (rdev->family) { 1552 switch (rdev->family) {
1562 case CHIP_TAHITI: 1553 case CHIP_TAHITI:
1563 chip_name = "TAHITI"; 1554 chip_name = "TAHITI";
@@ -1615,7 +1606,7 @@ static int si_init_microcode(struct radeon_device *rdev)
1615 DRM_INFO("Loading %s Microcode\n", chip_name); 1606 DRM_INFO("Loading %s Microcode\n", chip_name);
1616 1607
1617 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); 1608 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
1618 err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); 1609 err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
1619 if (err) 1610 if (err)
1620 goto out; 1611 goto out;
1621 if (rdev->pfp_fw->size != pfp_req_size) { 1612 if (rdev->pfp_fw->size != pfp_req_size) {
@@ -1627,7 +1618,7 @@ static int si_init_microcode(struct radeon_device *rdev)
1627 } 1618 }
1628 1619
1629 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); 1620 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
1630 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); 1621 err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
1631 if (err) 1622 if (err)
1632 goto out; 1623 goto out;
1633 if (rdev->me_fw->size != me_req_size) { 1624 if (rdev->me_fw->size != me_req_size) {
@@ -1638,7 +1629,7 @@ static int si_init_microcode(struct radeon_device *rdev)
1638 } 1629 }
1639 1630
1640 snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); 1631 snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
1641 err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev); 1632 err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
1642 if (err) 1633 if (err)
1643 goto out; 1634 goto out;
1644 if (rdev->ce_fw->size != ce_req_size) { 1635 if (rdev->ce_fw->size != ce_req_size) {
@@ -1649,7 +1640,7 @@ static int si_init_microcode(struct radeon_device *rdev)
1649 } 1640 }
1650 1641
1651 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); 1642 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
1652 err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); 1643 err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
1653 if (err) 1644 if (err)
1654 goto out; 1645 goto out;
1655 if (rdev->rlc_fw->size != rlc_req_size) { 1646 if (rdev->rlc_fw->size != rlc_req_size) {
@@ -1660,7 +1651,7 @@ static int si_init_microcode(struct radeon_device *rdev)
1660 } 1651 }
1661 1652
1662 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); 1653 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
1663 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); 1654 err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
1664 if (err) 1655 if (err)
1665 goto out; 1656 goto out;
1666 if (rdev->mc_fw->size != mc_req_size) { 1657 if (rdev->mc_fw->size != mc_req_size) {
@@ -1671,7 +1662,7 @@ static int si_init_microcode(struct radeon_device *rdev)
1671 } 1662 }
1672 1663
1673 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); 1664 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
1674 err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev); 1665 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
1675 if (err) 1666 if (err)
1676 goto out; 1667 goto out;
1677 if (rdev->smc_fw->size != smc_req_size) { 1668 if (rdev->smc_fw->size != smc_req_size) {
@@ -1682,8 +1673,6 @@ static int si_init_microcode(struct radeon_device *rdev)
1682 } 1673 }
1683 1674
1684out: 1675out:
1685 platform_device_unregister(pdev);
1686
1687 if (err) { 1676 if (err) {
1688 if (err != -EINVAL) 1677 if (err != -EINVAL)
1689 printk(KERN_ERR 1678 printk(KERN_ERR
@@ -4401,6 +4390,270 @@ void si_vm_fini(struct radeon_device *rdev)
4401} 4390}
4402 4391
4403/** 4392/**
4393 * si_vm_decode_fault - print human readable fault info
4394 *
4395 * @rdev: radeon_device pointer
4396 * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
4397 * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
4398 *
4399 * Print human readable fault information (SI).
4400 */
4401static void si_vm_decode_fault(struct radeon_device *rdev,
4402 u32 status, u32 addr)
4403{
4404 u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT;
4405 u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT;
4406 u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT;
4407 char *block;
4408
4409 if (rdev->family == CHIP_TAHITI) {
4410 switch (mc_id) {
4411 case 160:
4412 case 144:
4413 case 96:
4414 case 80:
4415 case 224:
4416 case 208:
4417 case 32:
4418 case 16:
4419 block = "CB";
4420 break;
4421 case 161:
4422 case 145:
4423 case 97:
4424 case 81:
4425 case 225:
4426 case 209:
4427 case 33:
4428 case 17:
4429 block = "CB_FMASK";
4430 break;
4431 case 162:
4432 case 146:
4433 case 98:
4434 case 82:
4435 case 226:
4436 case 210:
4437 case 34:
4438 case 18:
4439 block = "CB_CMASK";
4440 break;
4441 case 163:
4442 case 147:
4443 case 99:
4444 case 83:
4445 case 227:
4446 case 211:
4447 case 35:
4448 case 19:
4449 block = "CB_IMMED";
4450 break;
4451 case 164:
4452 case 148:
4453 case 100:
4454 case 84:
4455 case 228:
4456 case 212:
4457 case 36:
4458 case 20:
4459 block = "DB";
4460 break;
4461 case 165:
4462 case 149:
4463 case 101:
4464 case 85:
4465 case 229:
4466 case 213:
4467 case 37:
4468 case 21:
4469 block = "DB_HTILE";
4470 break;
4471 case 167:
4472 case 151:
4473 case 103:
4474 case 87:
4475 case 231:
4476 case 215:
4477 case 39:
4478 case 23:
4479 block = "DB_STEN";
4480 break;
4481 case 72:
4482 case 68:
4483 case 64:
4484 case 8:
4485 case 4:
4486 case 0:
4487 case 136:
4488 case 132:
4489 case 128:
4490 case 200:
4491 case 196:
4492 case 192:
4493 block = "TC";
4494 break;
4495 case 112:
4496 case 48:
4497 block = "CP";
4498 break;
4499 case 49:
4500 case 177:
4501 case 50:
4502 case 178:
4503 block = "SH";
4504 break;
4505 case 53:
4506 case 190:
4507 block = "VGT";
4508 break;
4509 case 117:
4510 block = "IH";
4511 break;
4512 case 51:
4513 case 115:
4514 block = "RLC";
4515 break;
4516 case 119:
4517 case 183:
4518 block = "DMA0";
4519 break;
4520 case 61:
4521 block = "DMA1";
4522 break;
4523 case 248:
4524 case 120:
4525 block = "HDP";
4526 break;
4527 default:
4528 block = "unknown";
4529 break;
4530 }
4531 } else {
4532 switch (mc_id) {
4533 case 32:
4534 case 16:
4535 case 96:
4536 case 80:
4537 case 160:
4538 case 144:
4539 case 224:
4540 case 208:
4541 block = "CB";
4542 break;
4543 case 33:
4544 case 17:
4545 case 97:
4546 case 81:
4547 case 161:
4548 case 145:
4549 case 225:
4550 case 209:
4551 block = "CB_FMASK";
4552 break;
4553 case 34:
4554 case 18:
4555 case 98:
4556 case 82:
4557 case 162:
4558 case 146:
4559 case 226:
4560 case 210:
4561 block = "CB_CMASK";
4562 break;
4563 case 35:
4564 case 19:
4565 case 99:
4566 case 83:
4567 case 163:
4568 case 147:
4569 case 227:
4570 case 211:
4571 block = "CB_IMMED";
4572 break;
4573 case 36:
4574 case 20:
4575 case 100:
4576 case 84:
4577 case 164:
4578 case 148:
4579 case 228:
4580 case 212:
4581 block = "DB";
4582 break;
4583 case 37:
4584 case 21:
4585 case 101:
4586 case 85:
4587 case 165:
4588 case 149:
4589 case 229:
4590 case 213:
4591 block = "DB_HTILE";
4592 break;
4593 case 39:
4594 case 23:
4595 case 103:
4596 case 87:
4597 case 167:
4598 case 151:
4599 case 231:
4600 case 215:
4601 block = "DB_STEN";
4602 break;
4603 case 72:
4604 case 68:
4605 case 8:
4606 case 4:
4607 case 136:
4608 case 132:
4609 case 200:
4610 case 196:
4611 block = "TC";
4612 break;
4613 case 112:
4614 case 48:
4615 block = "CP";
4616 break;
4617 case 49:
4618 case 177:
4619 case 50:
4620 case 178:
4621 block = "SH";
4622 break;
4623 case 53:
4624 block = "VGT";
4625 break;
4626 case 117:
4627 block = "IH";
4628 break;
4629 case 51:
4630 case 115:
4631 block = "RLC";
4632 break;
4633 case 119:
4634 case 183:
4635 block = "DMA0";
4636 break;
4637 case 61:
4638 block = "DMA1";
4639 break;
4640 case 248:
4641 case 120:
4642 block = "HDP";
4643 break;
4644 default:
4645 block = "unknown";
4646 break;
4647 }
4648 }
4649
4650 printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n",
4651 protections, vmid, addr,
4652 (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read",
4653 block, mc_id);
4654}
4655
4656/**
4404 * si_vm_set_page - update the page tables using the CP 4657 * si_vm_set_page - update the page tables using the CP
4405 * 4658 *
4406 * @rdev: radeon_device pointer 4659 * @rdev: radeon_device pointer
@@ -5766,6 +6019,7 @@ int si_irq_process(struct radeon_device *rdev)
5766 u32 ring_index; 6019 u32 ring_index;
5767 bool queue_hotplug = false; 6020 bool queue_hotplug = false;
5768 bool queue_thermal = false; 6021 bool queue_thermal = false;
6022 u32 status, addr;
5769 6023
5770 if (!rdev->ih.enabled || rdev->shutdown) 6024 if (!rdev->ih.enabled || rdev->shutdown)
5771 return IRQ_NONE; 6025 return IRQ_NONE;
@@ -6001,11 +6255,14 @@ restart_ih:
6001 break; 6255 break;
6002 case 146: 6256 case 146:
6003 case 147: 6257 case 147:
6258 addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
6259 status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
6004 dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); 6260 dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
6005 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", 6261 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n",
6006 RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); 6262 addr);
6007 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", 6263 dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
6008 RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); 6264 status);
6265 si_vm_decode_fault(rdev, status, addr);
6009 /* reset addr and status */ 6266 /* reset addr and status */
6010 WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); 6267 WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
6011 break; 6268 break;
@@ -6796,6 +7053,9 @@ static void si_program_aspm(struct radeon_device *rdev)
6796 bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; 7053 bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
6797 bool disable_clkreq = false; 7054 bool disable_clkreq = false;
6798 7055
7056 if (radeon_aspm == 0)
7057 return;
7058
6799 if (!(rdev->flags & RADEON_IS_PCIE)) 7059 if (!(rdev->flags & RADEON_IS_PCIE))
6800 return; 7060 return;
6801 7061
diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
index 12a20eb77d0c..2c8da27a929f 100644
--- a/drivers/gpu/drm/radeon/sid.h
+++ b/drivers/gpu/drm/radeon/sid.h
@@ -367,6 +367,20 @@
367 367
368#define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC 368#define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC
369#define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC 369#define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC
370#define PROTECTIONS_MASK (0xf << 0)
371#define PROTECTIONS_SHIFT 0
372 /* bit 0: range
373 * bit 1: pde0
374 * bit 2: valid
375 * bit 3: read
376 * bit 4: write
377 */
378#define MEMORY_CLIENT_ID_MASK (0xff << 12)
379#define MEMORY_CLIENT_ID_SHIFT 12
380#define MEMORY_CLIENT_RW_MASK (1 << 24)
381#define MEMORY_CLIENT_RW_SHIFT 24
382#define FAULT_VMID_MASK (0xf << 25)
383#define FAULT_VMID_SHIFT 25
370 384
371#define VM_INVALIDATE_REQUEST 0x1478 385#define VM_INVALIDATE_REQUEST 0x1478
372#define VM_INVALIDATE_RESPONSE 0x147c 386#define VM_INVALIDATE_RESPONSE 0x147c
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c
index 11b6b9924f1b..c0a850319908 100644
--- a/drivers/gpu/drm/radeon/sumo_dpm.c
+++ b/drivers/gpu/drm/radeon/sumo_dpm.c
@@ -1732,7 +1732,13 @@ int sumo_dpm_init(struct radeon_device *rdev)
1732 pi->enable_sclk_ds = true; 1732 pi->enable_sclk_ds = true;
1733 pi->enable_dynamic_m3_arbiter = false; 1733 pi->enable_dynamic_m3_arbiter = false;
1734 pi->enable_dynamic_patch_ps = true; 1734 pi->enable_dynamic_patch_ps = true;
1735 pi->enable_gfx_power_gating = true; 1735 /* Some PALM chips don't seem to properly ungate gfx when UVD is in use;
1736 * for now just disable gfx PG.
1737 */
1738 if (rdev->family == CHIP_PALM)
1739 pi->enable_gfx_power_gating = false;
1740 else
1741 pi->enable_gfx_power_gating = true;
1736 pi->enable_gfx_clock_gating = true; 1742 pi->enable_gfx_clock_gating = true;
1737 pi->enable_mg_clock_gating = true; 1743 pi->enable_mg_clock_gating = true;
1738 pi->enable_auto_thermal_throttling = true; 1744 pi->enable_auto_thermal_throttling = true;
@@ -1845,6 +1851,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev,
1845 return 0; 1851 return 0;
1846 1852
1847 if (level == RADEON_DPM_FORCED_LEVEL_HIGH) { 1853 if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
1854 if (pi->enable_boost)
1855 sumo_enable_boost(rdev, rps, false);
1848 sumo_power_level_enable(rdev, ps->num_levels - 1, true); 1856 sumo_power_level_enable(rdev, ps->num_levels - 1, true);
1849 sumo_set_forced_level(rdev, ps->num_levels - 1); 1857 sumo_set_forced_level(rdev, ps->num_levels - 1);
1850 sumo_set_forced_mode_enabled(rdev); 1858 sumo_set_forced_mode_enabled(rdev);
@@ -1855,6 +1863,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev,
1855 sumo_set_forced_mode_enabled(rdev); 1863 sumo_set_forced_mode_enabled(rdev);
1856 sumo_set_forced_mode(rdev, false); 1864 sumo_set_forced_mode(rdev, false);
1857 } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) { 1865 } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
1866 if (pi->enable_boost)
1867 sumo_enable_boost(rdev, rps, false);
1858 sumo_power_level_enable(rdev, 0, true); 1868 sumo_power_level_enable(rdev, 0, true);
1859 sumo_set_forced_level(rdev, 0); 1869 sumo_set_forced_level(rdev, 0);
1860 sumo_set_forced_mode_enabled(rdev); 1870 sumo_set_forced_mode_enabled(rdev);
@@ -1868,6 +1878,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev,
1868 for (i = 0; i < ps->num_levels; i++) { 1878 for (i = 0; i < ps->num_levels; i++) {
1869 sumo_power_level_enable(rdev, i, true); 1879 sumo_power_level_enable(rdev, i, true);
1870 } 1880 }
1881 if (pi->enable_boost)
1882 sumo_enable_boost(rdev, rps, true);
1871 } 1883 }
1872 1884
1873 rdev->pm.dpm.forced_level = level; 1885 rdev->pm.dpm.forced_level = level;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index ff82877de876..dc0fe09b2ba1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -249,8 +249,13 @@ static struct drm_driver rcar_du_driver = {
249 .gem_vm_ops = &drm_gem_cma_vm_ops, 249 .gem_vm_ops = &drm_gem_cma_vm_ops,
250 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 250 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
251 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 251 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
252 .gem_prime_import = drm_gem_cma_dmabuf_import, 252 .gem_prime_import = drm_gem_prime_import,
253 .gem_prime_export = drm_gem_cma_dmabuf_export, 253 .gem_prime_export = drm_gem_prime_export,
254 .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
255 .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
256 .gem_prime_vmap = drm_gem_cma_prime_vmap,
257 .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
258 .gem_prime_mmap = drm_gem_cma_prime_mmap,
254 .dumb_create = rcar_du_dumb_create, 259 .dumb_create = rcar_du_dumb_create,
255 .dumb_map_offset = drm_gem_cma_dumb_map_offset, 260 .dumb_map_offset = drm_gem_cma_dumb_map_offset,
256 .dumb_destroy = drm_gem_cma_dumb_destroy, 261 .dumb_destroy = drm_gem_cma_dumb_destroy,
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index edc10181f551..5f83f9a3ef59 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -276,8 +276,13 @@ static struct drm_driver shmob_drm_driver = {
276 .gem_vm_ops = &drm_gem_cma_vm_ops, 276 .gem_vm_ops = &drm_gem_cma_vm_ops,
277 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 277 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
278 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 278 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
279 .gem_prime_import = drm_gem_cma_dmabuf_import, 279 .gem_prime_import = drm_gem_prime_import,
280 .gem_prime_export = drm_gem_cma_dmabuf_export, 280 .gem_prime_export = drm_gem_prime_export,
281 .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
282 .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
283 .gem_prime_vmap = drm_gem_cma_prime_vmap,
284 .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
285 .gem_prime_mmap = drm_gem_cma_prime_mmap,
281 .dumb_create = drm_gem_cma_dumb_create, 286 .dumb_create = drm_gem_cma_dumb_create,
282 .dumb_map_offset = drm_gem_cma_dumb_map_offset, 287 .dumb_map_offset = drm_gem_cma_dumb_map_offset,
283 .dumb_destroy = drm_gem_cma_dumb_destroy, 288 .dumb_destroy = drm_gem_cma_dumb_destroy,
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 4c605c70ebf9..deb5c25305af 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -562,7 +562,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
562 struct hv_hotadd_state *has) 562 struct hv_hotadd_state *has)
563{ 563{
564 int ret = 0; 564 int ret = 0;
565 int i, nid, t; 565 int i, nid;
566 unsigned long start_pfn; 566 unsigned long start_pfn;
567 unsigned long processed_pfn; 567 unsigned long processed_pfn;
568 unsigned long total_pfn = pfn_count; 568 unsigned long total_pfn = pfn_count;
@@ -607,14 +607,11 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
607 607
608 /* 608 /*
609 * Wait for the memory block to be onlined. 609 * Wait for the memory block to be onlined.
610 * Since the hot add has succeeded, it is ok to
611 * proceed even if the pages in the hot added region
612 * have not been "onlined" within the allowed time.
610 */ 613 */
611 t = wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); 614 wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ);
612 if (t == 0) {
613 pr_info("hot_add memory timedout\n");
614 has->ha_end_pfn -= HA_CHUNK;
615 has->covered_end_pfn -= processed_pfn;
616 break;
617 }
618 615
619 } 616 }
620 617
@@ -978,6 +975,14 @@ static void post_status(struct hv_dynmem_device *dm)
978 dm->num_pages_ballooned + 975 dm->num_pages_ballooned +
979 compute_balloon_floor(); 976 compute_balloon_floor();
980 977
978 /*
979 * If our transaction ID is no longer current, just don't
980 * send the status. This can happen if we were interrupted
981 * after we picked our transaction ID.
982 */
983 if (status.hdr.trans_id != atomic_read(&trans_id))
984 return;
985
981 vmbus_sendpacket(dm->dev->channel, &status, 986 vmbus_sendpacket(dm->dev->channel, &status,
982 sizeof(struct dm_status), 987 sizeof(struct dm_status),
983 (unsigned long)NULL, 988 (unsigned long)NULL,
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index a2464bf07c49..e8e071fc1d6d 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -690,7 +690,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
690 if (ret) 690 if (ret)
691 pr_err("Unable to register child device\n"); 691 pr_err("Unable to register child device\n");
692 else 692 else
693 pr_info("child device %s registered\n", 693 pr_debug("child device %s registered\n",
694 dev_name(&child_device_obj->device)); 694 dev_name(&child_device_obj->device));
695 695
696 return ret; 696 return ret;
@@ -702,14 +702,14 @@ int vmbus_device_register(struct hv_device *child_device_obj)
702 */ 702 */
703void vmbus_device_unregister(struct hv_device *device_obj) 703void vmbus_device_unregister(struct hv_device *device_obj)
704{ 704{
705 pr_debug("child device %s unregistered\n",
706 dev_name(&device_obj->device));
707
705 /* 708 /*
706 * Kick off the process of unregistering the device. 709 * Kick off the process of unregistering the device.
707 * This will call vmbus_remove() and eventually vmbus_device_release() 710 * This will call vmbus_remove() and eventually vmbus_device_release()
708 */ 711 */
709 device_unregister(&device_obj->device); 712 device_unregister(&device_obj->device);
710
711 pr_info("child device %s unregistered\n",
712 dev_name(&device_obj->device));
713} 713}
714 714
715 715
diff --git a/drivers/hwmon/abx500.c b/drivers/hwmon/abx500.c
index eee1134274c8..769fe20ec938 100644
--- a/drivers/hwmon/abx500.c
+++ b/drivers/hwmon/abx500.c
@@ -315,7 +315,7 @@ static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IWUSR | S_IRUGO,
315static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3); 315static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3);
316static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3); 316static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3);
317 317
318struct attribute *abx500_temp_attributes[] = { 318static struct attribute *abx500_temp_attributes[] = {
319 &sensor_dev_attr_name.dev_attr.attr, 319 &sensor_dev_attr_name.dev_attr.attr,
320 320
321 &sensor_dev_attr_temp1_label.dev_attr.attr, 321 &sensor_dev_attr_temp1_label.dev_attr.attr,
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index ade35cf3f488..2e5e2dc47eaf 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -195,7 +195,7 @@ struct tjmax {
195 int tjmax; 195 int tjmax;
196}; 196};
197 197
198static const struct tjmax __cpuinitconst tjmax_table[] = { 198static const struct tjmax tjmax_table[] = {
199 { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */ 199 { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */
200 { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */ 200 { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */
201 { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 Sodaville */ 201 { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 Sodaville */
@@ -211,7 +211,7 @@ struct tjmax_model {
211 211
212#define ANY 0xff 212#define ANY 0xff
213 213
214static const struct tjmax_model __cpuinitconst tjmax_model_table[] = { 214static const struct tjmax_model tjmax_model_table[] = {
215 { 0x1c, 10, 100000 }, /* D4xx, K4xx, N4xx, D5xx, K5xx, N5xx */ 215 { 0x1c, 10, 100000 }, /* D4xx, K4xx, N4xx, D5xx, K5xx, N5xx */
216 { 0x1c, ANY, 90000 }, /* Z5xx, N2xx, possibly others 216 { 0x1c, ANY, 90000 }, /* Z5xx, N2xx, possibly others
217 * Note: Also matches 230 and 330, 217 * Note: Also matches 230 and 330,
@@ -226,8 +226,7 @@ static const struct tjmax_model __cpuinitconst tjmax_model_table[] = {
226 { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */ 226 { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */
227}; 227};
228 228
229static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, 229static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
230 struct device *dev)
231{ 230{
232 /* The 100C is default for both mobile and non mobile CPUs */ 231 /* The 100C is default for both mobile and non mobile CPUs */
233 232
@@ -317,8 +316,7 @@ static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
317 return tjmax; 316 return tjmax;
318} 317}
319 318
320static int __cpuinit get_tjmax(struct cpuinfo_x86 *c, u32 id, 319static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
321 struct device *dev)
322{ 320{
323 int err; 321 int err;
324 u32 eax, edx; 322 u32 eax, edx;
@@ -367,8 +365,8 @@ static int create_name_attr(struct platform_data *pdata,
367 return device_create_file(dev, &pdata->name_attr); 365 return device_create_file(dev, &pdata->name_attr);
368} 366}
369 367
370static int __cpuinit create_core_attrs(struct temp_data *tdata, 368static int create_core_attrs(struct temp_data *tdata, struct device *dev,
371 struct device *dev, int attr_no) 369 int attr_no)
372{ 370{
373 int err, i; 371 int err, i;
374 static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev, 372 static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev,
@@ -401,7 +399,7 @@ exit_free:
401} 399}
402 400
403 401
404static int __cpuinit chk_ucode_version(unsigned int cpu) 402static int chk_ucode_version(unsigned int cpu)
405{ 403{
406 struct cpuinfo_x86 *c = &cpu_data(cpu); 404 struct cpuinfo_x86 *c = &cpu_data(cpu);
407 405
@@ -417,7 +415,7 @@ static int __cpuinit chk_ucode_version(unsigned int cpu)
417 return 0; 415 return 0;
418} 416}
419 417
420static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu) 418static struct platform_device *coretemp_get_pdev(unsigned int cpu)
421{ 419{
422 u16 phys_proc_id = TO_PHYS_ID(cpu); 420 u16 phys_proc_id = TO_PHYS_ID(cpu);
423 struct pdev_entry *p; 421 struct pdev_entry *p;
@@ -434,8 +432,7 @@ static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu)
434 return NULL; 432 return NULL;
435} 433}
436 434
437static struct temp_data __cpuinit *init_temp_data(unsigned int cpu, 435static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
438 int pkg_flag)
439{ 436{
440 struct temp_data *tdata; 437 struct temp_data *tdata;
441 438
@@ -453,8 +450,8 @@ static struct temp_data __cpuinit *init_temp_data(unsigned int cpu,
453 return tdata; 450 return tdata;
454} 451}
455 452
456static int __cpuinit create_core_data(struct platform_device *pdev, 453static int create_core_data(struct platform_device *pdev, unsigned int cpu,
457 unsigned int cpu, int pkg_flag) 454 int pkg_flag)
458{ 455{
459 struct temp_data *tdata; 456 struct temp_data *tdata;
460 struct platform_data *pdata = platform_get_drvdata(pdev); 457 struct platform_data *pdata = platform_get_drvdata(pdev);
@@ -524,7 +521,7 @@ exit_free:
524 return err; 521 return err;
525} 522}
526 523
527static void __cpuinit coretemp_add_core(unsigned int cpu, int pkg_flag) 524static void coretemp_add_core(unsigned int cpu, int pkg_flag)
528{ 525{
529 struct platform_device *pdev = coretemp_get_pdev(cpu); 526 struct platform_device *pdev = coretemp_get_pdev(cpu);
530 int err; 527 int err;
@@ -607,7 +604,7 @@ static struct platform_driver coretemp_driver = {
607 .remove = coretemp_remove, 604 .remove = coretemp_remove,
608}; 605};
609 606
610static int __cpuinit coretemp_device_add(unsigned int cpu) 607static int coretemp_device_add(unsigned int cpu)
611{ 608{
612 int err; 609 int err;
613 struct platform_device *pdev; 610 struct platform_device *pdev;
@@ -651,7 +648,7 @@ exit:
651 return err; 648 return err;
652} 649}
653 650
654static void __cpuinit coretemp_device_remove(unsigned int cpu) 651static void coretemp_device_remove(unsigned int cpu)
655{ 652{
656 struct pdev_entry *p, *n; 653 struct pdev_entry *p, *n;
657 u16 phys_proc_id = TO_PHYS_ID(cpu); 654 u16 phys_proc_id = TO_PHYS_ID(cpu);
@@ -667,7 +664,7 @@ static void __cpuinit coretemp_device_remove(unsigned int cpu)
667 mutex_unlock(&pdev_list_mutex); 664 mutex_unlock(&pdev_list_mutex);
668} 665}
669 666
670static bool __cpuinit is_any_core_online(struct platform_data *pdata) 667static bool is_any_core_online(struct platform_data *pdata)
671{ 668{
672 int i; 669 int i;
673 670
@@ -681,7 +678,7 @@ static bool __cpuinit is_any_core_online(struct platform_data *pdata)
681 return false; 678 return false;
682} 679}
683 680
684static void __cpuinit get_core_online(unsigned int cpu) 681static void get_core_online(unsigned int cpu)
685{ 682{
686 struct cpuinfo_x86 *c = &cpu_data(cpu); 683 struct cpuinfo_x86 *c = &cpu_data(cpu);
687 struct platform_device *pdev = coretemp_get_pdev(cpu); 684 struct platform_device *pdev = coretemp_get_pdev(cpu);
@@ -723,7 +720,7 @@ static void __cpuinit get_core_online(unsigned int cpu)
723 coretemp_add_core(cpu, 0); 720 coretemp_add_core(cpu, 0);
724} 721}
725 722
726static void __cpuinit put_core_offline(unsigned int cpu) 723static void put_core_offline(unsigned int cpu)
727{ 724{
728 int i, indx; 725 int i, indx;
729 struct platform_data *pdata; 726 struct platform_data *pdata;
@@ -771,7 +768,7 @@ static void __cpuinit put_core_offline(unsigned int cpu)
771 coretemp_device_remove(cpu); 768 coretemp_device_remove(cpu);
772} 769}
773 770
774static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb, 771static int coretemp_cpu_callback(struct notifier_block *nfb,
775 unsigned long action, void *hcpu) 772 unsigned long action, void *hcpu)
776{ 773{
777 unsigned int cpu = (unsigned long) hcpu; 774 unsigned int cpu = (unsigned long) hcpu;
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index 76f157b568ed..38944e94f65f 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -221,7 +221,7 @@ struct pdev_entry {
221static LIST_HEAD(pdev_list); 221static LIST_HEAD(pdev_list);
222static DEFINE_MUTEX(pdev_list_mutex); 222static DEFINE_MUTEX(pdev_list_mutex);
223 223
224static int __cpuinit via_cputemp_device_add(unsigned int cpu) 224static int via_cputemp_device_add(unsigned int cpu)
225{ 225{
226 int err; 226 int err;
227 struct platform_device *pdev; 227 struct platform_device *pdev;
@@ -262,7 +262,7 @@ exit:
262 return err; 262 return err;
263} 263}
264 264
265static void __cpuinit via_cputemp_device_remove(unsigned int cpu) 265static void via_cputemp_device_remove(unsigned int cpu)
266{ 266{
267 struct pdev_entry *p; 267 struct pdev_entry *p;
268 268
@@ -279,8 +279,8 @@ static void __cpuinit via_cputemp_device_remove(unsigned int cpu)
279 mutex_unlock(&pdev_list_mutex); 279 mutex_unlock(&pdev_list_mutex);
280} 280}
281 281
282static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb, 282static int via_cputemp_cpu_callback(struct notifier_block *nfb,
283 unsigned long action, void *hcpu) 283 unsigned long action, void *hcpu)
284{ 284{
285 unsigned int cpu = (unsigned long) hcpu; 285 unsigned int cpu = (unsigned long) hcpu;
286 286
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 4427e8e46a7f..0ad208a69c29 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -183,6 +183,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
183 183
184static const struct iio_info tiadc_info = { 184static const struct iio_info tiadc_info = {
185 .read_raw = &tiadc_read_raw, 185 .read_raw = &tiadc_read_raw,
186 .driver_module = THIS_MODULE,
186}; 187};
187 188
188static int tiadc_probe(struct platform_device *pdev) 189static int tiadc_probe(struct platform_device *pdev)
diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c
index 85aeef60dc5f..d546f50f9258 100644
--- a/drivers/iio/dac/ad7303.c
+++ b/drivers/iio/dac/ad7303.c
@@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi)
235 235
236 if (ext_ref) { 236 if (ext_ref) {
237 st->vref_reg = regulator_get(&spi->dev, "REF"); 237 st->vref_reg = regulator_get(&spi->dev, "REF");
238 if (IS_ERR(st->vref_reg)) 238 if (IS_ERR(st->vref_reg)) {
239 ret = PTR_ERR(st->vref_reg);
239 goto err_disable_vdd_reg; 240 goto err_disable_vdd_reg;
241 }
240 242
241 ret = regulator_enable(st->vref_reg); 243 ret = regulator_enable(st->vref_reg);
242 if (ret) 244 if (ret)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 4d6c7d84e155..ea8a4146620d 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
104 104
105 ida_simple_remove(&iio_trigger_ida, trig_info->id); 105 ida_simple_remove(&iio_trigger_ida, trig_info->id);
106 /* Possible issue in here */ 106 /* Possible issue in here */
107 device_unregister(&trig_info->dev); 107 device_del(&trig_info->dev);
108} 108}
109EXPORT_SYMBOL(iio_trigger_unregister); 109EXPORT_SYMBOL(iio_trigger_unregister);
110 110
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 98ddc323add0..0cf5f8e06cfc 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
451 int ret; 451 int ret;
452 452
453 ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); 453 ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
454 if (ret == 0) 454 if (ret >= 0)
455 raw64 += offset; 455 raw64 += offset;
456 456
457 scale_type = iio_channel_read(chan, &scale_val, &scale_val2, 457 scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 9c343b40665e..3ffbc56917b4 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -28,7 +28,9 @@
28#include <linux/iio/common/st_sensors.h> 28#include <linux/iio/common/st_sensors.h>
29#include "st_pressure.h" 29#include "st_pressure.h"
30 30
31#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10) 31#define ST_PRESS_LSB_PER_MBAR 4096UL
32#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \
33 ST_PRESS_LSB_PER_MBAR)
32#define ST_PRESS_NUMBER_DATA_CHANNELS 1 34#define ST_PRESS_NUMBER_DATA_CHANNELS 1
33 35
34/* DEFAULT VALUE FOR SENSORS */ 36/* DEFAULT VALUE FOR SENSORS */
@@ -51,8 +53,8 @@
51#define ST_PRESS_1_FS_ADDR 0x23 53#define ST_PRESS_1_FS_ADDR 0x23
52#define ST_PRESS_1_FS_MASK 0x30 54#define ST_PRESS_1_FS_MASK 0x30
53#define ST_PRESS_1_FS_AVL_1260_VAL 0x00 55#define ST_PRESS_1_FS_AVL_1260_VAL 0x00
54#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141)
55#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000 56#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000
57#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
56#define ST_PRESS_1_BDU_ADDR 0x20 58#define ST_PRESS_1_BDU_ADDR 0x20
57#define ST_PRESS_1_BDU_MASK 0x04 59#define ST_PRESS_1_BDU_MASK 0x04
58#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22 60#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 19ceaa60e0f4..ee7c50312066 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -414,7 +414,7 @@ static void __init gic_dist_init(struct gic_chip_data *gic)
414 writel_relaxed(1, base + GIC_DIST_CTRL); 414 writel_relaxed(1, base + GIC_DIST_CTRL);
415} 415}
416 416
417static void __cpuinit gic_cpu_init(struct gic_chip_data *gic) 417static void gic_cpu_init(struct gic_chip_data *gic)
418{ 418{
419 void __iomem *dist_base = gic_data_dist_base(gic); 419 void __iomem *dist_base = gic_data_dist_base(gic);
420 void __iomem *base = gic_data_cpu_base(gic); 420 void __iomem *base = gic_data_cpu_base(gic);
@@ -702,8 +702,8 @@ static int gic_irq_domain_xlate(struct irq_domain *d,
702} 702}
703 703
704#ifdef CONFIG_SMP 704#ifdef CONFIG_SMP
705static int __cpuinit gic_secondary_init(struct notifier_block *nfb, 705static int gic_secondary_init(struct notifier_block *nfb, unsigned long action,
706 unsigned long action, void *hcpu) 706 void *hcpu)
707{ 707{
708 if (action == CPU_STARTING || action == CPU_STARTING_FROZEN) 708 if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
709 gic_cpu_init(&gic_data[0]); 709 gic_cpu_init(&gic_data[0]);
@@ -714,7 +714,7 @@ static int __cpuinit gic_secondary_init(struct notifier_block *nfb,
714 * Notifier for enabling the GIC CPU interface. Set an arbitrarily high 714 * Notifier for enabling the GIC CPU interface. Set an arbitrarily high
715 * priority because the GIC needs to be up before the ARM generic timers. 715 * priority because the GIC needs to be up before the ARM generic timers.
716 */ 716 */
717static struct notifier_block __cpuinitdata gic_cpu_notifier = { 717static struct notifier_block gic_cpu_notifier = {
718 .notifier_call = gic_secondary_init, 718 .notifier_call = gic_secondary_init,
719 .priority = 100, 719 .priority = 100,
720}; 720};
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index 048f2947e08b..e45f5575fd4d 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -63,7 +63,10 @@
63#include "bcache.h" 63#include "bcache.h"
64#include "btree.h" 64#include "btree.h"
65 65
66#include <linux/freezer.h>
67#include <linux/kthread.h>
66#include <linux/random.h> 68#include <linux/random.h>
69#include <trace/events/bcache.h>
67 70
68#define MAX_IN_FLIGHT_DISCARDS 8U 71#define MAX_IN_FLIGHT_DISCARDS 8U
69 72
@@ -151,7 +154,7 @@ static void discard_finish(struct work_struct *w)
151 mutex_unlock(&ca->set->bucket_lock); 154 mutex_unlock(&ca->set->bucket_lock);
152 155
153 closure_wake_up(&ca->set->bucket_wait); 156 closure_wake_up(&ca->set->bucket_wait);
154 wake_up(&ca->set->alloc_wait); 157 wake_up_process(ca->alloc_thread);
155 158
156 closure_put(&ca->set->cl); 159 closure_put(&ca->set->cl);
157} 160}
@@ -350,38 +353,30 @@ static void invalidate_buckets(struct cache *ca)
350 break; 353 break;
351 } 354 }
352 355
353 pr_debug("free %zu/%zu free_inc %zu/%zu unused %zu/%zu", 356 trace_bcache_alloc_invalidate(ca);
354 fifo_used(&ca->free), ca->free.size,
355 fifo_used(&ca->free_inc), ca->free_inc.size,
356 fifo_used(&ca->unused), ca->unused.size);
357} 357}
358 358
359#define allocator_wait(ca, cond) \ 359#define allocator_wait(ca, cond) \
360do { \ 360do { \
361 DEFINE_WAIT(__wait); \
362 \
363 while (1) { \ 361 while (1) { \
364 prepare_to_wait(&ca->set->alloc_wait, \ 362 set_current_state(TASK_INTERRUPTIBLE); \
365 &__wait, TASK_INTERRUPTIBLE); \
366 if (cond) \ 363 if (cond) \
367 break; \ 364 break; \
368 \ 365 \
369 mutex_unlock(&(ca)->set->bucket_lock); \ 366 mutex_unlock(&(ca)->set->bucket_lock); \
370 if (test_bit(CACHE_SET_STOPPING_2, &ca->set->flags)) { \ 367 if (kthread_should_stop()) \
371 finish_wait(&ca->set->alloc_wait, &__wait); \ 368 return 0; \
372 closure_return(cl); \
373 } \
374 \ 369 \
370 try_to_freeze(); \
375 schedule(); \ 371 schedule(); \
376 mutex_lock(&(ca)->set->bucket_lock); \ 372 mutex_lock(&(ca)->set->bucket_lock); \
377 } \ 373 } \
378 \ 374 __set_current_state(TASK_RUNNING); \
379 finish_wait(&ca->set->alloc_wait, &__wait); \
380} while (0) 375} while (0)
381 376
382void bch_allocator_thread(struct closure *cl) 377static int bch_allocator_thread(void *arg)
383{ 378{
384 struct cache *ca = container_of(cl, struct cache, alloc); 379 struct cache *ca = arg;
385 380
386 mutex_lock(&ca->set->bucket_lock); 381 mutex_lock(&ca->set->bucket_lock);
387 382
@@ -442,7 +437,7 @@ long bch_bucket_alloc(struct cache *ca, unsigned watermark, struct closure *cl)
442{ 437{
443 long r = -1; 438 long r = -1;
444again: 439again:
445 wake_up(&ca->set->alloc_wait); 440 wake_up_process(ca->alloc_thread);
446 441
447 if (fifo_used(&ca->free) > ca->watermark[watermark] && 442 if (fifo_used(&ca->free) > ca->watermark[watermark] &&
448 fifo_pop(&ca->free, r)) { 443 fifo_pop(&ca->free, r)) {
@@ -476,9 +471,7 @@ again:
476 return r; 471 return r;
477 } 472 }
478 473
479 pr_debug("alloc failure: blocked %i free %zu free_inc %zu unused %zu", 474 trace_bcache_alloc_fail(ca);
480 atomic_read(&ca->set->prio_blocked), fifo_used(&ca->free),
481 fifo_used(&ca->free_inc), fifo_used(&ca->unused));
482 475
483 if (cl) { 476 if (cl) {
484 closure_wait(&ca->set->bucket_wait, cl); 477 closure_wait(&ca->set->bucket_wait, cl);
@@ -552,6 +545,17 @@ int bch_bucket_alloc_set(struct cache_set *c, unsigned watermark,
552 545
553/* Init */ 546/* Init */
554 547
548int bch_cache_allocator_start(struct cache *ca)
549{
550 struct task_struct *k = kthread_run(bch_allocator_thread,
551 ca, "bcache_allocator");
552 if (IS_ERR(k))
553 return PTR_ERR(k);
554
555 ca->alloc_thread = k;
556 return 0;
557}
558
555void bch_cache_allocator_exit(struct cache *ca) 559void bch_cache_allocator_exit(struct cache *ca)
556{ 560{
557 struct discard *d; 561 struct discard *d;
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index d3e15b42a4ab..b39f6f0b45f2 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -178,7 +178,6 @@
178#define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__ 178#define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__
179 179
180#include <linux/bio.h> 180#include <linux/bio.h>
181#include <linux/blktrace_api.h>
182#include <linux/kobject.h> 181#include <linux/kobject.h>
183#include <linux/list.h> 182#include <linux/list.h>
184#include <linux/mutex.h> 183#include <linux/mutex.h>
@@ -388,8 +387,6 @@ struct keybuf_key {
388typedef bool (keybuf_pred_fn)(struct keybuf *, struct bkey *); 387typedef bool (keybuf_pred_fn)(struct keybuf *, struct bkey *);
389 388
390struct keybuf { 389struct keybuf {
391 keybuf_pred_fn *key_predicate;
392
393 struct bkey last_scanned; 390 struct bkey last_scanned;
394 spinlock_t lock; 391 spinlock_t lock;
395 392
@@ -437,9 +434,12 @@ struct bcache_device {
437 434
438 /* If nonzero, we're detaching/unregistering from cache set */ 435 /* If nonzero, we're detaching/unregistering from cache set */
439 atomic_t detaching; 436 atomic_t detaching;
437 int flush_done;
438
439 uint64_t nr_stripes;
440 unsigned stripe_size_bits;
441 atomic_t *stripe_sectors_dirty;
440 442
441 atomic_long_t sectors_dirty;
442 unsigned long sectors_dirty_gc;
443 unsigned long sectors_dirty_last; 443 unsigned long sectors_dirty_last;
444 long sectors_dirty_derivative; 444 long sectors_dirty_derivative;
445 445
@@ -531,6 +531,7 @@ struct cached_dev {
531 unsigned sequential_merge:1; 531 unsigned sequential_merge:1;
532 unsigned verify:1; 532 unsigned verify:1;
533 533
534 unsigned partial_stripes_expensive:1;
534 unsigned writeback_metadata:1; 535 unsigned writeback_metadata:1;
535 unsigned writeback_running:1; 536 unsigned writeback_running:1;
536 unsigned char writeback_percent; 537 unsigned char writeback_percent;
@@ -565,8 +566,7 @@ struct cache {
565 566
566 unsigned watermark[WATERMARK_MAX]; 567 unsigned watermark[WATERMARK_MAX];
567 568
568 struct closure alloc; 569 struct task_struct *alloc_thread;
569 struct workqueue_struct *alloc_workqueue;
570 570
571 struct closure prio; 571 struct closure prio;
572 struct prio_set *disk_buckets; 572 struct prio_set *disk_buckets;
@@ -664,13 +664,9 @@ struct gc_stat {
664 * CACHE_SET_STOPPING always gets set first when we're closing down a cache set; 664 * CACHE_SET_STOPPING always gets set first when we're closing down a cache set;
665 * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e. 665 * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e.
666 * flushing dirty data). 666 * flushing dirty data).
667 *
668 * CACHE_SET_STOPPING_2 gets set at the last phase, when it's time to shut down
669 * the allocation thread.
670 */ 667 */
671#define CACHE_SET_UNREGISTERING 0 668#define CACHE_SET_UNREGISTERING 0
672#define CACHE_SET_STOPPING 1 669#define CACHE_SET_STOPPING 1
673#define CACHE_SET_STOPPING_2 2
674 670
675struct cache_set { 671struct cache_set {
676 struct closure cl; 672 struct closure cl;
@@ -703,9 +699,6 @@ struct cache_set {
703 /* For the btree cache */ 699 /* For the btree cache */
704 struct shrinker shrink; 700 struct shrinker shrink;
705 701
706 /* For the allocator itself */
707 wait_queue_head_t alloc_wait;
708
709 /* For the btree cache and anything allocation related */ 702 /* For the btree cache and anything allocation related */
710 struct mutex bucket_lock; 703 struct mutex bucket_lock;
711 704
@@ -823,10 +816,9 @@ struct cache_set {
823 816
824 /* 817 /*
825 * A btree node on disk could have too many bsets for an iterator to fit 818 * A btree node on disk could have too many bsets for an iterator to fit
826 * on the stack - this is a single element mempool for btree_read_work() 819 * on the stack - have to dynamically allocate them
827 */ 820 */
828 struct mutex fill_lock; 821 mempool_t *fill_iter;
829 struct btree_iter *fill_iter;
830 822
831 /* 823 /*
832 * btree_sort() is a merge sort and requires temporary space - single 824 * btree_sort() is a merge sort and requires temporary space - single
@@ -834,6 +826,7 @@ struct cache_set {
834 */ 826 */
835 struct mutex sort_lock; 827 struct mutex sort_lock;
836 struct bset *sort; 828 struct bset *sort;
829 unsigned sort_crit_factor;
837 830
838 /* List of buckets we're currently writing data to */ 831 /* List of buckets we're currently writing data to */
839 struct list_head data_buckets; 832 struct list_head data_buckets;
@@ -906,8 +899,6 @@ static inline unsigned local_clock_us(void)
906 return local_clock() >> 10; 899 return local_clock() >> 10;
907} 900}
908 901
909#define MAX_BSETS 4U
910
911#define BTREE_PRIO USHRT_MAX 902#define BTREE_PRIO USHRT_MAX
912#define INITIAL_PRIO 32768 903#define INITIAL_PRIO 32768
913 904
@@ -1112,23 +1103,6 @@ static inline void __bkey_put(struct cache_set *c, struct bkey *k)
1112 atomic_dec_bug(&PTR_BUCKET(c, k, i)->pin); 1103 atomic_dec_bug(&PTR_BUCKET(c, k, i)->pin);
1113} 1104}
1114 1105
1115/* Blktrace macros */
1116
1117#define blktrace_msg(c, fmt, ...) \
1118do { \
1119 struct request_queue *q = bdev_get_queue(c->bdev); \
1120 if (q) \
1121 blk_add_trace_msg(q, fmt, ##__VA_ARGS__); \
1122} while (0)
1123
1124#define blktrace_msg_all(s, fmt, ...) \
1125do { \
1126 struct cache *_c; \
1127 unsigned i; \
1128 for_each_cache(_c, (s), i) \
1129 blktrace_msg(_c, fmt, ##__VA_ARGS__); \
1130} while (0)
1131
1132static inline void cached_dev_put(struct cached_dev *dc) 1106static inline void cached_dev_put(struct cached_dev *dc)
1133{ 1107{
1134 if (atomic_dec_and_test(&dc->count)) 1108 if (atomic_dec_and_test(&dc->count))
@@ -1173,10 +1147,16 @@ static inline uint8_t bucket_disk_gen(struct bucket *b)
1173 static struct kobj_attribute ksysfs_##n = \ 1147 static struct kobj_attribute ksysfs_##n = \
1174 __ATTR(n, S_IWUSR|S_IRUSR, show, store) 1148 __ATTR(n, S_IWUSR|S_IRUSR, show, store)
1175 1149
1176/* Forward declarations */ 1150static inline void wake_up_allocators(struct cache_set *c)
1151{
1152 struct cache *ca;
1153 unsigned i;
1154
1155 for_each_cache(ca, c, i)
1156 wake_up_process(ca->alloc_thread);
1157}
1177 1158
1178void bch_writeback_queue(struct cached_dev *); 1159/* Forward declarations */
1179void bch_writeback_add(struct cached_dev *, unsigned);
1180 1160
1181void bch_count_io_errors(struct cache *, int, const char *); 1161void bch_count_io_errors(struct cache *, int, const char *);
1182void bch_bbio_count_io_errors(struct cache_set *, struct bio *, 1162void 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);
1193uint8_t bch_inc_gen(struct cache *, struct bucket *); 1173uint8_t bch_inc_gen(struct cache *, struct bucket *);
1194void bch_rescale_priorities(struct cache_set *, int); 1174void bch_rescale_priorities(struct cache_set *, int);
1195bool bch_bucket_add_unused(struct cache *, struct bucket *); 1175bool bch_bucket_add_unused(struct cache *, struct bucket *);
1196void bch_allocator_thread(struct closure *);
1197 1176
1198long bch_bucket_alloc(struct cache *, unsigned, struct closure *); 1177long bch_bucket_alloc(struct cache *, unsigned, struct closure *);
1199void bch_bucket_free(struct cache_set *, struct bkey *); 1178void bch_bucket_free(struct cache_set *, struct bkey *);
@@ -1241,9 +1220,9 @@ void bch_cache_set_stop(struct cache_set *);
1241struct cache_set *bch_cache_set_alloc(struct cache_sb *); 1220struct cache_set *bch_cache_set_alloc(struct cache_sb *);
1242void bch_btree_cache_free(struct cache_set *); 1221void bch_btree_cache_free(struct cache_set *);
1243int bch_btree_cache_alloc(struct cache_set *); 1222int bch_btree_cache_alloc(struct cache_set *);
1244void bch_cached_dev_writeback_init(struct cached_dev *);
1245void bch_moving_init_cache_set(struct cache_set *); 1223void bch_moving_init_cache_set(struct cache_set *);
1246 1224
1225int bch_cache_allocator_start(struct cache *ca);
1247void bch_cache_allocator_exit(struct cache *ca); 1226void bch_cache_allocator_exit(struct cache *ca);
1248int bch_cache_allocator_init(struct cache *ca); 1227int bch_cache_allocator_init(struct cache *ca);
1249 1228
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
index 1d27d3af3251..8010eed06a51 100644
--- a/drivers/md/bcache/bset.c
+++ b/drivers/md/bcache/bset.c
@@ -78,6 +78,7 @@ struct bkey *bch_keylist_pop(struct keylist *l)
78bool __bch_ptr_invalid(struct cache_set *c, int level, const struct bkey *k) 78bool __bch_ptr_invalid(struct cache_set *c, int level, const struct bkey *k)
79{ 79{
80 unsigned i; 80 unsigned i;
81 char buf[80];
81 82
82 if (level && (!KEY_PTRS(k) || !KEY_SIZE(k) || KEY_DIRTY(k))) 83 if (level && (!KEY_PTRS(k) || !KEY_SIZE(k) || KEY_DIRTY(k)))
83 goto bad; 84 goto bad;
@@ -102,7 +103,8 @@ bool __bch_ptr_invalid(struct cache_set *c, int level, const struct bkey *k)
102 103
103 return false; 104 return false;
104bad: 105bad:
105 cache_bug(c, "spotted bad key %s: %s", pkey(k), bch_ptr_status(c, k)); 106 bch_bkey_to_text(buf, sizeof(buf), k);
107 cache_bug(c, "spotted bad key %s: %s", buf, bch_ptr_status(c, k));
106 return true; 108 return true;
107} 109}
108 110
@@ -162,10 +164,16 @@ bool bch_ptr_bad(struct btree *b, const struct bkey *k)
162#ifdef CONFIG_BCACHE_EDEBUG 164#ifdef CONFIG_BCACHE_EDEBUG
163bug: 165bug:
164 mutex_unlock(&b->c->bucket_lock); 166 mutex_unlock(&b->c->bucket_lock);
165 btree_bug(b, 167
168 {
169 char buf[80];
170
171 bch_bkey_to_text(buf, sizeof(buf), k);
172 btree_bug(b,
166"inconsistent pointer %s: bucket %zu pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i", 173"inconsistent pointer %s: bucket %zu pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i",
167 pkey(k), PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin), 174 buf, PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin),
168 g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen); 175 g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen);
176 }
169 return true; 177 return true;
170#endif 178#endif
171} 179}
@@ -1084,33 +1092,39 @@ void bch_btree_sort_into(struct btree *b, struct btree *new)
1084 new->sets->size = 0; 1092 new->sets->size = 0;
1085} 1093}
1086 1094
1095#define SORT_CRIT (4096 / sizeof(uint64_t))
1096
1087void bch_btree_sort_lazy(struct btree *b) 1097void bch_btree_sort_lazy(struct btree *b)
1088{ 1098{
1089 if (b->nsets) { 1099 unsigned crit = SORT_CRIT;
1090 unsigned i, j, keys = 0, total; 1100 int i;
1091 1101
1092 for (i = 0; i <= b->nsets; i++) 1102 /* Don't sort if nothing to do */
1093 keys += b->sets[i].data->keys; 1103 if (!b->nsets)
1094 1104 goto out;
1095 total = keys;
1096 1105
1097 for (j = 0; j < b->nsets; j++) { 1106 /* If not a leaf node, always sort */
1098 if (keys * 2 < total || 1107 if (b->level) {
1099 keys < 1000) { 1108 bch_btree_sort(b);
1100 bch_btree_sort_partial(b, j); 1109 return;
1101 return; 1110 }
1102 }
1103 1111
1104 keys -= b->sets[j].data->keys; 1112 for (i = b->nsets - 1; i >= 0; --i) {
1105 } 1113 crit *= b->c->sort_crit_factor;
1106 1114
1107 /* Must sort if b->nsets == 3 or we'll overflow */ 1115 if (b->sets[i].data->keys < crit) {
1108 if (b->nsets >= (MAX_BSETS - 1) - b->level) { 1116 bch_btree_sort_partial(b, i);
1109 bch_btree_sort(b);
1110 return; 1117 return;
1111 } 1118 }
1112 } 1119 }
1113 1120
1121 /* Sort if we'd overflow */
1122 if (b->nsets + 1 == MAX_BSETS) {
1123 bch_btree_sort(b);
1124 return;
1125 }
1126
1127out:
1114 bset_build_written_tree(b); 1128 bset_build_written_tree(b);
1115} 1129}
1116 1130
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
index 57a9cff41546..ae115a253d73 100644
--- a/drivers/md/bcache/bset.h
+++ b/drivers/md/bcache/bset.h
@@ -1,6 +1,8 @@
1#ifndef _BCACHE_BSET_H 1#ifndef _BCACHE_BSET_H
2#define _BCACHE_BSET_H 2#define _BCACHE_BSET_H
3 3
4#include <linux/slab.h>
5
4/* 6/*
5 * BKEYS: 7 * BKEYS:
6 * 8 *
@@ -142,6 +144,8 @@
142 144
143/* Btree key comparison/iteration */ 145/* Btree key comparison/iteration */
144 146
147#define MAX_BSETS 4U
148
145struct btree_iter { 149struct btree_iter {
146 size_t size, used; 150 size_t size, used;
147 struct btree_iter_set { 151 struct btree_iter_set {
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 7a5658f04e62..ee372884c405 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -24,6 +24,7 @@
24#include "btree.h" 24#include "btree.h"
25#include "debug.h" 25#include "debug.h"
26#include "request.h" 26#include "request.h"
27#include "writeback.h"
27 28
28#include <linux/slab.h> 29#include <linux/slab.h>
29#include <linux/bitops.h> 30#include <linux/bitops.h>
@@ -134,44 +135,17 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
134 return crc ^ 0xffffffffffffffffULL; 135 return crc ^ 0xffffffffffffffffULL;
135} 136}
136 137
137static void btree_bio_endio(struct bio *bio, int error) 138static void bch_btree_node_read_done(struct btree *b)
138{ 139{
139 struct closure *cl = bio->bi_private;
140 struct btree *b = container_of(cl, struct btree, io.cl);
141
142 if (error)
143 set_btree_node_io_error(b);
144
145 bch_bbio_count_io_errors(b->c, bio, error, (bio->bi_rw & WRITE)
146 ? "writing btree" : "reading btree");
147 closure_put(cl);
148}
149
150static void btree_bio_init(struct btree *b)
151{
152 BUG_ON(b->bio);
153 b->bio = bch_bbio_alloc(b->c);
154
155 b->bio->bi_end_io = btree_bio_endio;
156 b->bio->bi_private = &b->io.cl;
157}
158
159void bch_btree_read_done(struct closure *cl)
160{
161 struct btree *b = container_of(cl, struct btree, io.cl);
162 struct bset *i = b->sets[0].data;
163 struct btree_iter *iter = b->c->fill_iter;
164 const char *err = "bad btree header"; 140 const char *err = "bad btree header";
165 BUG_ON(b->nsets || b->written); 141 struct bset *i = b->sets[0].data;
166 142 struct btree_iter *iter;
167 bch_bbio_free(b->bio, b->c);
168 b->bio = NULL;
169 143
170 mutex_lock(&b->c->fill_lock); 144 iter = mempool_alloc(b->c->fill_iter, GFP_NOWAIT);
145 iter->size = b->c->sb.bucket_size / b->c->sb.block_size;
171 iter->used = 0; 146 iter->used = 0;
172 147
173 if (btree_node_io_error(b) || 148 if (!i->seq)
174 !i->seq)
175 goto err; 149 goto err;
176 150
177 for (; 151 for (;
@@ -228,17 +202,8 @@ void bch_btree_read_done(struct closure *cl)
228 if (b->written < btree_blocks(b)) 202 if (b->written < btree_blocks(b))
229 bch_bset_init_next(b); 203 bch_bset_init_next(b);
230out: 204out:
231 205 mempool_free(iter, b->c->fill_iter);
232 mutex_unlock(&b->c->fill_lock); 206 return;
233
234 spin_lock(&b->c->btree_read_time_lock);
235 bch_time_stats_update(&b->c->btree_read_time, b->io_start_time);
236 spin_unlock(&b->c->btree_read_time_lock);
237
238 smp_wmb(); /* read_done is our write lock */
239 set_btree_node_read_done(b);
240
241 closure_return(cl);
242err: 207err:
243 set_btree_node_io_error(b); 208 set_btree_node_io_error(b);
244 bch_cache_set_error(b->c, "%s at bucket %zu, block %zu, %u keys", 209 bch_cache_set_error(b->c, "%s at bucket %zu, block %zu, %u keys",
@@ -247,48 +212,69 @@ err:
247 goto out; 212 goto out;
248} 213}
249 214
250void bch_btree_read(struct btree *b) 215static void btree_node_read_endio(struct bio *bio, int error)
216{
217 struct closure *cl = bio->bi_private;
218 closure_put(cl);
219}
220
221void bch_btree_node_read(struct btree *b)
251{ 222{
252 BUG_ON(b->nsets || b->written); 223 uint64_t start_time = local_clock();
224 struct closure cl;
225 struct bio *bio;
226
227 trace_bcache_btree_read(b);
228
229 closure_init_stack(&cl);
230
231 bio = bch_bbio_alloc(b->c);
232 bio->bi_rw = REQ_META|READ_SYNC;
233 bio->bi_size = KEY_SIZE(&b->key) << 9;
234 bio->bi_end_io = btree_node_read_endio;
235 bio->bi_private = &cl;
236
237 bch_bio_map(bio, b->sets[0].data);
238
239 bch_submit_bbio(bio, b->c, &b->key, 0);
240 closure_sync(&cl);
253 241
254 if (!closure_trylock(&b->io.cl, &b->c->cl)) 242 if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
255 BUG(); 243 set_btree_node_io_error(b);
256 244
257 b->io_start_time = local_clock(); 245 bch_bbio_free(bio, b->c);
258 246
259 btree_bio_init(b); 247 if (btree_node_io_error(b))
260 b->bio->bi_rw = REQ_META|READ_SYNC; 248 goto err;
261 b->bio->bi_size = KEY_SIZE(&b->key) << 9;
262 249
263 bch_bio_map(b->bio, b->sets[0].data); 250 bch_btree_node_read_done(b);
264 251
265 pr_debug("%s", pbtree(b)); 252 spin_lock(&b->c->btree_read_time_lock);
266 trace_bcache_btree_read(b->bio); 253 bch_time_stats_update(&b->c->btree_read_time, start_time);
267 bch_submit_bbio(b->bio, b->c, &b->key, 0); 254 spin_unlock(&b->c->btree_read_time_lock);
268 255
269 continue_at(&b->io.cl, bch_btree_read_done, system_wq); 256 return;
257err:
258 bch_cache_set_error(b->c, "io error reading bucket %lu",
259 PTR_BUCKET_NR(b->c, &b->key, 0));
270} 260}
271 261
272static void btree_complete_write(struct btree *b, struct btree_write *w) 262static void btree_complete_write(struct btree *b, struct btree_write *w)
273{ 263{
274 if (w->prio_blocked && 264 if (w->prio_blocked &&
275 !atomic_sub_return(w->prio_blocked, &b->c->prio_blocked)) 265 !atomic_sub_return(w->prio_blocked, &b->c->prio_blocked))
276 wake_up(&b->c->alloc_wait); 266 wake_up_allocators(b->c);
277 267
278 if (w->journal) { 268 if (w->journal) {
279 atomic_dec_bug(w->journal); 269 atomic_dec_bug(w->journal);
280 __closure_wake_up(&b->c->journal.wait); 270 __closure_wake_up(&b->c->journal.wait);
281 } 271 }
282 272
283 if (w->owner)
284 closure_put(w->owner);
285
286 w->prio_blocked = 0; 273 w->prio_blocked = 0;
287 w->journal = NULL; 274 w->journal = NULL;
288 w->owner = NULL;
289} 275}
290 276
291static void __btree_write_done(struct closure *cl) 277static void __btree_node_write_done(struct closure *cl)
292{ 278{
293 struct btree *b = container_of(cl, struct btree, io.cl); 279 struct btree *b = container_of(cl, struct btree, io.cl);
294 struct btree_write *w = btree_prev_write(b); 280 struct btree_write *w = btree_prev_write(b);
@@ -304,7 +290,7 @@ static void __btree_write_done(struct closure *cl)
304 closure_return(cl); 290 closure_return(cl);
305} 291}
306 292
307static void btree_write_done(struct closure *cl) 293static void btree_node_write_done(struct closure *cl)
308{ 294{
309 struct btree *b = container_of(cl, struct btree, io.cl); 295 struct btree *b = container_of(cl, struct btree, io.cl);
310 struct bio_vec *bv; 296 struct bio_vec *bv;
@@ -313,10 +299,22 @@ static void btree_write_done(struct closure *cl)
313 __bio_for_each_segment(bv, b->bio, n, 0) 299 __bio_for_each_segment(bv, b->bio, n, 0)
314 __free_page(bv->bv_page); 300 __free_page(bv->bv_page);
315 301
316 __btree_write_done(cl); 302 __btree_node_write_done(cl);
317} 303}
318 304
319static void do_btree_write(struct btree *b) 305static void btree_node_write_endio(struct bio *bio, int error)
306{
307 struct closure *cl = bio->bi_private;
308 struct btree *b = container_of(cl, struct btree, io.cl);
309
310 if (error)
311 set_btree_node_io_error(b);
312
313 bch_bbio_count_io_errors(b->c, bio, error, "writing btree");
314 closure_put(cl);
315}
316
317static void do_btree_node_write(struct btree *b)
320{ 318{
321 struct closure *cl = &b->io.cl; 319 struct closure *cl = &b->io.cl;
322 struct bset *i = b->sets[b->nsets].data; 320 struct bset *i = b->sets[b->nsets].data;
@@ -325,15 +323,34 @@ static void do_btree_write(struct btree *b)
325 i->version = BCACHE_BSET_VERSION; 323 i->version = BCACHE_BSET_VERSION;
326 i->csum = btree_csum_set(b, i); 324 i->csum = btree_csum_set(b, i);
327 325
328 btree_bio_init(b); 326 BUG_ON(b->bio);
329 b->bio->bi_rw = REQ_META|WRITE_SYNC; 327 b->bio = bch_bbio_alloc(b->c);
330 b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c); 328
329 b->bio->bi_end_io = btree_node_write_endio;
330 b->bio->bi_private = &b->io.cl;
331 b->bio->bi_rw = REQ_META|WRITE_SYNC|REQ_FUA;
332 b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c);
331 bch_bio_map(b->bio, i); 333 bch_bio_map(b->bio, i);
332 334
335 /*
336 * If we're appending to a leaf node, we don't technically need FUA -
337 * this write just needs to be persisted before the next journal write,
338 * which will be marked FLUSH|FUA.
339 *
340 * Similarly if we're writing a new btree root - the pointer is going to
341 * be in the next journal entry.
342 *
343 * But if we're writing a new btree node (that isn't a root) or
344 * appending to a non leaf btree node, we need either FUA or a flush
345 * when we write the parent with the new pointer. FUA is cheaper than a
346 * flush, and writes appending to leaf nodes aren't blocking anything so
347 * just make all btree node writes FUA to keep things sane.
348 */
349
333 bkey_copy(&k.key, &b->key); 350 bkey_copy(&k.key, &b->key);
334 SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i)); 351 SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i));
335 352
336 if (!bch_bio_alloc_pages(b->bio, GFP_NOIO)) { 353 if (!bio_alloc_pages(b->bio, GFP_NOIO)) {
337 int j; 354 int j;
338 struct bio_vec *bv; 355 struct bio_vec *bv;
339 void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); 356 void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
@@ -342,40 +359,41 @@ static void do_btree_write(struct btree *b)
342 memcpy(page_address(bv->bv_page), 359 memcpy(page_address(bv->bv_page),
343 base + j * PAGE_SIZE, PAGE_SIZE); 360 base + j * PAGE_SIZE, PAGE_SIZE);
344 361
345 trace_bcache_btree_write(b->bio);
346 bch_submit_bbio(b->bio, b->c, &k.key, 0); 362 bch_submit_bbio(b->bio, b->c, &k.key, 0);
347 363
348 continue_at(cl, btree_write_done, NULL); 364 continue_at(cl, btree_node_write_done, NULL);
349 } else { 365 } else {
350 b->bio->bi_vcnt = 0; 366 b->bio->bi_vcnt = 0;
351 bch_bio_map(b->bio, i); 367 bch_bio_map(b->bio, i);
352 368
353 trace_bcache_btree_write(b->bio);
354 bch_submit_bbio(b->bio, b->c, &k.key, 0); 369 bch_submit_bbio(b->bio, b->c, &k.key, 0);
355 370
356 closure_sync(cl); 371 closure_sync(cl);
357 __btree_write_done(cl); 372 __btree_node_write_done(cl);
358 } 373 }
359} 374}
360 375
361static void __btree_write(struct btree *b) 376void bch_btree_node_write(struct btree *b, struct closure *parent)
362{ 377{
363 struct bset *i = b->sets[b->nsets].data; 378 struct bset *i = b->sets[b->nsets].data;
364 379
380 trace_bcache_btree_write(b);
381
365 BUG_ON(current->bio_list); 382 BUG_ON(current->bio_list);
383 BUG_ON(b->written >= btree_blocks(b));
384 BUG_ON(b->written && !i->keys);
385 BUG_ON(b->sets->data->seq != i->seq);
386 bch_check_key_order(b, i);
366 387
367 closure_lock(&b->io, &b->c->cl);
368 cancel_delayed_work(&b->work); 388 cancel_delayed_work(&b->work);
369 389
390 /* If caller isn't waiting for write, parent refcount is cache set */
391 closure_lock(&b->io, parent ?: &b->c->cl);
392
370 clear_bit(BTREE_NODE_dirty, &b->flags); 393 clear_bit(BTREE_NODE_dirty, &b->flags);
371 change_bit(BTREE_NODE_write_idx, &b->flags); 394 change_bit(BTREE_NODE_write_idx, &b->flags);
372 395
373 bch_check_key_order(b, i); 396 do_btree_node_write(b);
374 BUG_ON(b->written && !i->keys);
375
376 do_btree_write(b);
377
378 pr_debug("%s block %i keys %i", pbtree(b), b->written, i->keys);
379 397
380 b->written += set_blocks(i, b->c); 398 b->written += set_blocks(i, b->c);
381 atomic_long_add(set_blocks(i, b->c) * b->c->sb.block_size, 399 atomic_long_add(set_blocks(i, b->c) * b->c->sb.block_size,
@@ -387,37 +405,31 @@ static void __btree_write(struct btree *b)
387 bch_bset_init_next(b); 405 bch_bset_init_next(b);
388} 406}
389 407
390static void btree_write_work(struct work_struct *w) 408static void btree_node_write_work(struct work_struct *w)
391{ 409{
392 struct btree *b = container_of(to_delayed_work(w), struct btree, work); 410 struct btree *b = container_of(to_delayed_work(w), struct btree, work);
393 411
394 down_write(&b->lock); 412 rw_lock(true, b, b->level);
395 413
396 if (btree_node_dirty(b)) 414 if (btree_node_dirty(b))
397 __btree_write(b); 415 bch_btree_node_write(b, NULL);
398 up_write(&b->lock); 416 rw_unlock(true, b);
399} 417}
400 418
401void bch_btree_write(struct btree *b, bool now, struct btree_op *op) 419static void bch_btree_leaf_dirty(struct btree *b, struct btree_op *op)
402{ 420{
403 struct bset *i = b->sets[b->nsets].data; 421 struct bset *i = b->sets[b->nsets].data;
404 struct btree_write *w = btree_current_write(b); 422 struct btree_write *w = btree_current_write(b);
405 423
406 BUG_ON(b->written && 424 BUG_ON(!b->written);
407 (b->written >= btree_blocks(b) || 425 BUG_ON(!i->keys);
408 i->seq != b->sets[0].data->seq ||
409 !i->keys));
410 426
411 if (!btree_node_dirty(b)) { 427 if (!btree_node_dirty(b))
412 set_btree_node_dirty(b); 428 queue_delayed_work(btree_io_wq, &b->work, 30 * HZ);
413 queue_delayed_work(btree_io_wq, &b->work,
414 msecs_to_jiffies(30000));
415 }
416 429
417 w->prio_blocked += b->prio_blocked; 430 set_btree_node_dirty(b);
418 b->prio_blocked = 0;
419 431
420 if (op && op->journal && !b->level) { 432 if (op && op->journal) {
421 if (w->journal && 433 if (w->journal &&
422 journal_pin_cmp(b->c, w, op)) { 434 journal_pin_cmp(b->c, w, op)) {
423 atomic_dec_bug(w->journal); 435 atomic_dec_bug(w->journal);
@@ -430,23 +442,10 @@ void bch_btree_write(struct btree *b, bool now, struct btree_op *op)
430 } 442 }
431 } 443 }
432 444
433 if (current->bio_list)
434 return;
435
436 /* Force write if set is too big */ 445 /* Force write if set is too big */
437 if (now || 446 if (set_bytes(i) > PAGE_SIZE - 48 &&
438 b->level || 447 !current->bio_list)
439 set_bytes(i) > PAGE_SIZE - 48) { 448 bch_btree_node_write(b, NULL);
440 if (op && now) {
441 /* Must wait on multiple writes */
442 BUG_ON(w->owner);
443 w->owner = &op->cl;
444 closure_get(&op->cl);
445 }
446
447 __btree_write(b);
448 }
449 BUG_ON(!b->written);
450} 449}
451 450
452/* 451/*
@@ -559,7 +558,7 @@ static struct btree *mca_bucket_alloc(struct cache_set *c,
559 init_rwsem(&b->lock); 558 init_rwsem(&b->lock);
560 lockdep_set_novalidate_class(&b->lock); 559 lockdep_set_novalidate_class(&b->lock);
561 INIT_LIST_HEAD(&b->list); 560 INIT_LIST_HEAD(&b->list);
562 INIT_DELAYED_WORK(&b->work, btree_write_work); 561 INIT_DELAYED_WORK(&b->work, btree_node_write_work);
563 b->c = c; 562 b->c = c;
564 closure_init_unlocked(&b->io); 563 closure_init_unlocked(&b->io);
565 564
@@ -582,7 +581,7 @@ static int mca_reap(struct btree *b, struct closure *cl, unsigned min_order)
582 BUG_ON(btree_node_dirty(b) && !b->sets[0].data); 581 BUG_ON(btree_node_dirty(b) && !b->sets[0].data);
583 582
584 if (cl && btree_node_dirty(b)) 583 if (cl && btree_node_dirty(b))
585 bch_btree_write(b, true, NULL); 584 bch_btree_node_write(b, NULL);
586 585
587 if (cl) 586 if (cl)
588 closure_wait_event_async(&b->io.wait, cl, 587 closure_wait_event_async(&b->io.wait, cl,
@@ -623,6 +622,13 @@ static int bch_mca_shrink(struct shrinker *shrink, struct shrink_control *sc)
623 else if (!mutex_trylock(&c->bucket_lock)) 622 else if (!mutex_trylock(&c->bucket_lock))
624 return -1; 623 return -1;
625 624
625 /*
626 * It's _really_ critical that we don't free too many btree nodes - we
627 * have to always leave ourselves a reserve. The reserve is how we
628 * guarantee that allocating memory for a new btree node can always
629 * succeed, so that inserting keys into the btree can always succeed and
630 * IO can always make forward progress:
631 */
626 nr /= c->btree_pages; 632 nr /= c->btree_pages;
627 nr = min_t(unsigned long, nr, mca_can_free(c)); 633 nr = min_t(unsigned long, nr, mca_can_free(c));
628 634
@@ -766,6 +772,8 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct bkey *k,
766 int ret = -ENOMEM; 772 int ret = -ENOMEM;
767 struct btree *i; 773 struct btree *i;
768 774
775 trace_bcache_btree_cache_cannibalize(c);
776
769 if (!cl) 777 if (!cl)
770 return ERR_PTR(-ENOMEM); 778 return ERR_PTR(-ENOMEM);
771 779
@@ -784,7 +792,6 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct bkey *k,
784 return ERR_PTR(-EAGAIN); 792 return ERR_PTR(-EAGAIN);
785 } 793 }
786 794
787 /* XXX: tracepoint */
788 c->try_harder = cl; 795 c->try_harder = cl;
789 c->try_harder_start = local_clock(); 796 c->try_harder_start = local_clock();
790retry: 797retry:
@@ -905,6 +912,9 @@ retry:
905 b = mca_find(c, k); 912 b = mca_find(c, k);
906 913
907 if (!b) { 914 if (!b) {
915 if (current->bio_list)
916 return ERR_PTR(-EAGAIN);
917
908 mutex_lock(&c->bucket_lock); 918 mutex_lock(&c->bucket_lock);
909 b = mca_alloc(c, k, level, &op->cl); 919 b = mca_alloc(c, k, level, &op->cl);
910 mutex_unlock(&c->bucket_lock); 920 mutex_unlock(&c->bucket_lock);
@@ -914,7 +924,7 @@ retry:
914 if (IS_ERR(b)) 924 if (IS_ERR(b))
915 return b; 925 return b;
916 926
917 bch_btree_read(b); 927 bch_btree_node_read(b);
918 928
919 if (!write) 929 if (!write)
920 downgrade_write(&b->lock); 930 downgrade_write(&b->lock);
@@ -937,15 +947,12 @@ retry:
937 for (; i <= b->nsets; i++) 947 for (; i <= b->nsets; i++)
938 prefetch(b->sets[i].data); 948 prefetch(b->sets[i].data);
939 949
940 if (!closure_wait_event(&b->io.wait, &op->cl, 950 if (btree_node_io_error(b)) {
941 btree_node_read_done(b))) {
942 rw_unlock(write, b);
943 b = ERR_PTR(-EAGAIN);
944 } else if (btree_node_io_error(b)) {
945 rw_unlock(write, b); 951 rw_unlock(write, b);
946 b = ERR_PTR(-EIO); 952 return ERR_PTR(-EIO);
947 } else 953 }
948 BUG_ON(!b->written); 954
955 BUG_ON(!b->written);
949 956
950 return b; 957 return b;
951} 958}
@@ -959,7 +966,7 @@ static void btree_node_prefetch(struct cache_set *c, struct bkey *k, int level)
959 mutex_unlock(&c->bucket_lock); 966 mutex_unlock(&c->bucket_lock);
960 967
961 if (!IS_ERR_OR_NULL(b)) { 968 if (!IS_ERR_OR_NULL(b)) {
962 bch_btree_read(b); 969 bch_btree_node_read(b);
963 rw_unlock(true, b); 970 rw_unlock(true, b);
964 } 971 }
965} 972}
@@ -970,24 +977,19 @@ static void btree_node_free(struct btree *b, struct btree_op *op)
970{ 977{
971 unsigned i; 978 unsigned i;
972 979
980 trace_bcache_btree_node_free(b);
981
973 /* 982 /*
974 * The BUG_ON() in btree_node_get() implies that we must have a write 983 * The BUG_ON() in btree_node_get() implies that we must have a write
975 * lock on parent to free or even invalidate a node 984 * lock on parent to free or even invalidate a node
976 */ 985 */
977 BUG_ON(op->lock <= b->level); 986 BUG_ON(op->lock <= b->level);
978 BUG_ON(b == b->c->root); 987 BUG_ON(b == b->c->root);
979 pr_debug("bucket %s", pbtree(b));
980 988
981 if (btree_node_dirty(b)) 989 if (btree_node_dirty(b))
982 btree_complete_write(b, btree_current_write(b)); 990 btree_complete_write(b, btree_current_write(b));
983 clear_bit(BTREE_NODE_dirty, &b->flags); 991 clear_bit(BTREE_NODE_dirty, &b->flags);
984 992
985 if (b->prio_blocked &&
986 !atomic_sub_return(b->prio_blocked, &b->c->prio_blocked))
987 wake_up(&b->c->alloc_wait);
988
989 b->prio_blocked = 0;
990
991 cancel_delayed_work(&b->work); 993 cancel_delayed_work(&b->work);
992 994
993 mutex_lock(&b->c->bucket_lock); 995 mutex_lock(&b->c->bucket_lock);
@@ -1028,17 +1030,20 @@ retry:
1028 goto retry; 1030 goto retry;
1029 } 1031 }
1030 1032
1031 set_btree_node_read_done(b);
1032 b->accessed = 1; 1033 b->accessed = 1;
1033 bch_bset_init_next(b); 1034 bch_bset_init_next(b);
1034 1035
1035 mutex_unlock(&c->bucket_lock); 1036 mutex_unlock(&c->bucket_lock);
1037
1038 trace_bcache_btree_node_alloc(b);
1036 return b; 1039 return b;
1037err_free: 1040err_free:
1038 bch_bucket_free(c, &k.key); 1041 bch_bucket_free(c, &k.key);
1039 __bkey_put(c, &k.key); 1042 __bkey_put(c, &k.key);
1040err: 1043err:
1041 mutex_unlock(&c->bucket_lock); 1044 mutex_unlock(&c->bucket_lock);
1045
1046 trace_bcache_btree_node_alloc_fail(b);
1042 return b; 1047 return b;
1043} 1048}
1044 1049
@@ -1137,11 +1142,8 @@ static int btree_gc_mark_node(struct btree *b, unsigned *keys,
1137 gc->nkeys++; 1142 gc->nkeys++;
1138 1143
1139 gc->data += KEY_SIZE(k); 1144 gc->data += KEY_SIZE(k);
1140 if (KEY_DIRTY(k)) { 1145 if (KEY_DIRTY(k))
1141 gc->dirty += KEY_SIZE(k); 1146 gc->dirty += KEY_SIZE(k);
1142 if (d)
1143 d->sectors_dirty_gc += KEY_SIZE(k);
1144 }
1145 } 1147 }
1146 1148
1147 for (t = b->sets; t <= &b->sets[b->nsets]; t++) 1149 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,
1166 1168
1167 if (!IS_ERR_OR_NULL(n)) { 1169 if (!IS_ERR_OR_NULL(n)) {
1168 swap(b, n); 1170 swap(b, n);
1171 __bkey_put(b->c, &b->key);
1169 1172
1170 memcpy(k->ptr, b->key.ptr, 1173 memcpy(k->ptr, b->key.ptr,
1171 sizeof(uint64_t) * KEY_PTRS(&b->key)); 1174 sizeof(uint64_t) * KEY_PTRS(&b->key));
1172 1175
1173 __bkey_put(b->c, &b->key);
1174 atomic_inc(&b->c->prio_blocked);
1175 b->prio_blocked++;
1176
1177 btree_node_free(n, op); 1176 btree_node_free(n, op);
1178 up_write(&n->lock); 1177 up_write(&n->lock);
1179 } 1178 }
@@ -1278,7 +1277,7 @@ static void btree_gc_coalesce(struct btree *b, struct btree_op *op,
1278 btree_node_free(r->b, op); 1277 btree_node_free(r->b, op);
1279 up_write(&r->b->lock); 1278 up_write(&r->b->lock);
1280 1279
1281 pr_debug("coalesced %u nodes", nodes); 1280 trace_bcache_btree_gc_coalesce(nodes);
1282 1281
1283 gc->nodes--; 1282 gc->nodes--;
1284 nodes--; 1283 nodes--;
@@ -1293,14 +1292,9 @@ static int btree_gc_recurse(struct btree *b, struct btree_op *op,
1293 void write(struct btree *r) 1292 void write(struct btree *r)
1294 { 1293 {
1295 if (!r->written) 1294 if (!r->written)
1296 bch_btree_write(r, true, op); 1295 bch_btree_node_write(r, &op->cl);
1297 else if (btree_node_dirty(r)) { 1296 else if (btree_node_dirty(r))
1298 BUG_ON(btree_current_write(r)->owner); 1297 bch_btree_node_write(r, writes);
1299 btree_current_write(r)->owner = writes;
1300 closure_get(writes);
1301
1302 bch_btree_write(r, true, NULL);
1303 }
1304 1298
1305 up_write(&r->lock); 1299 up_write(&r->lock);
1306 } 1300 }
@@ -1386,9 +1380,7 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op,
1386 ret = btree_gc_recurse(b, op, writes, gc); 1380 ret = btree_gc_recurse(b, op, writes, gc);
1387 1381
1388 if (!b->written || btree_node_dirty(b)) { 1382 if (!b->written || btree_node_dirty(b)) {
1389 atomic_inc(&b->c->prio_blocked); 1383 bch_btree_node_write(b, n ? &op->cl : NULL);
1390 b->prio_blocked++;
1391 bch_btree_write(b, true, n ? op : NULL);
1392 } 1384 }
1393 1385
1394 if (!IS_ERR_OR_NULL(n)) { 1386 if (!IS_ERR_OR_NULL(n)) {
@@ -1405,7 +1397,6 @@ static void btree_gc_start(struct cache_set *c)
1405{ 1397{
1406 struct cache *ca; 1398 struct cache *ca;
1407 struct bucket *b; 1399 struct bucket *b;
1408 struct bcache_device **d;
1409 unsigned i; 1400 unsigned i;
1410 1401
1411 if (!c->gc_mark_valid) 1402 if (!c->gc_mark_valid)
@@ -1419,16 +1410,12 @@ static void btree_gc_start(struct cache_set *c)
1419 for_each_cache(ca, c, i) 1410 for_each_cache(ca, c, i)
1420 for_each_bucket(b, ca) { 1411 for_each_bucket(b, ca) {
1421 b->gc_gen = b->gen; 1412 b->gc_gen = b->gen;
1422 if (!atomic_read(&b->pin)) 1413 if (!atomic_read(&b->pin)) {
1423 SET_GC_MARK(b, GC_MARK_RECLAIMABLE); 1414 SET_GC_MARK(b, GC_MARK_RECLAIMABLE);
1415 SET_GC_SECTORS_USED(b, 0);
1416 }
1424 } 1417 }
1425 1418
1426 for (d = c->devices;
1427 d < c->devices + c->nr_uuids;
1428 d++)
1429 if (*d)
1430 (*d)->sectors_dirty_gc = 0;
1431
1432 mutex_unlock(&c->bucket_lock); 1419 mutex_unlock(&c->bucket_lock);
1433} 1420}
1434 1421
@@ -1437,7 +1424,6 @@ size_t bch_btree_gc_finish(struct cache_set *c)
1437 size_t available = 0; 1424 size_t available = 0;
1438 struct bucket *b; 1425 struct bucket *b;
1439 struct cache *ca; 1426 struct cache *ca;
1440 struct bcache_device **d;
1441 unsigned i; 1427 unsigned i;
1442 1428
1443 mutex_lock(&c->bucket_lock); 1429 mutex_lock(&c->bucket_lock);
@@ -1480,22 +1466,6 @@ size_t bch_btree_gc_finish(struct cache_set *c)
1480 } 1466 }
1481 } 1467 }
1482 1468
1483 for (d = c->devices;
1484 d < c->devices + c->nr_uuids;
1485 d++)
1486 if (*d) {
1487 unsigned long last =
1488 atomic_long_read(&((*d)->sectors_dirty));
1489 long difference = (*d)->sectors_dirty_gc - last;
1490
1491 pr_debug("sectors dirty off by %li", difference);
1492
1493 (*d)->sectors_dirty_last += difference;
1494
1495 atomic_long_set(&((*d)->sectors_dirty),
1496 (*d)->sectors_dirty_gc);
1497 }
1498
1499 mutex_unlock(&c->bucket_lock); 1469 mutex_unlock(&c->bucket_lock);
1500 return available; 1470 return available;
1501} 1471}
@@ -1508,10 +1478,9 @@ static void bch_btree_gc(struct closure *cl)
1508 struct gc_stat stats; 1478 struct gc_stat stats;
1509 struct closure writes; 1479 struct closure writes;
1510 struct btree_op op; 1480 struct btree_op op;
1511
1512 uint64_t start_time = local_clock(); 1481 uint64_t start_time = local_clock();
1513 trace_bcache_gc_start(c->sb.set_uuid); 1482
1514 blktrace_msg_all(c, "Starting gc"); 1483 trace_bcache_gc_start(c);
1515 1484
1516 memset(&stats, 0, sizeof(struct gc_stat)); 1485 memset(&stats, 0, sizeof(struct gc_stat));
1517 closure_init_stack(&writes); 1486 closure_init_stack(&writes);
@@ -1520,14 +1489,14 @@ static void bch_btree_gc(struct closure *cl)
1520 1489
1521 btree_gc_start(c); 1490 btree_gc_start(c);
1522 1491
1492 atomic_inc(&c->prio_blocked);
1493
1523 ret = btree_root(gc_root, c, &op, &writes, &stats); 1494 ret = btree_root(gc_root, c, &op, &writes, &stats);
1524 closure_sync(&op.cl); 1495 closure_sync(&op.cl);
1525 closure_sync(&writes); 1496 closure_sync(&writes);
1526 1497
1527 if (ret) { 1498 if (ret) {
1528 blktrace_msg_all(c, "Stopped gc");
1529 pr_warn("gc failed!"); 1499 pr_warn("gc failed!");
1530
1531 continue_at(cl, bch_btree_gc, bch_gc_wq); 1500 continue_at(cl, bch_btree_gc, bch_gc_wq);
1532 } 1501 }
1533 1502
@@ -1537,6 +1506,9 @@ static void bch_btree_gc(struct closure *cl)
1537 1506
1538 available = bch_btree_gc_finish(c); 1507 available = bch_btree_gc_finish(c);
1539 1508
1509 atomic_dec(&c->prio_blocked);
1510 wake_up_allocators(c);
1511
1540 bch_time_stats_update(&c->btree_gc_time, start_time); 1512 bch_time_stats_update(&c->btree_gc_time, start_time);
1541 1513
1542 stats.key_bytes *= sizeof(uint64_t); 1514 stats.key_bytes *= sizeof(uint64_t);
@@ -1544,10 +1516,8 @@ static void bch_btree_gc(struct closure *cl)
1544 stats.data <<= 9; 1516 stats.data <<= 9;
1545 stats.in_use = (c->nbuckets - available) * 100 / c->nbuckets; 1517 stats.in_use = (c->nbuckets - available) * 100 / c->nbuckets;
1546 memcpy(&c->gc_stats, &stats, sizeof(struct gc_stat)); 1518 memcpy(&c->gc_stats, &stats, sizeof(struct gc_stat));
1547 blktrace_msg_all(c, "Finished gc");
1548 1519
1549 trace_bcache_gc_end(c->sb.set_uuid); 1520 trace_bcache_gc_end(c);
1550 wake_up(&c->alloc_wait);
1551 1521
1552 continue_at(cl, bch_moving_gc, bch_gc_wq); 1522 continue_at(cl, bch_moving_gc, bch_gc_wq);
1553} 1523}
@@ -1654,14 +1624,14 @@ static bool fix_overlapping_extents(struct btree *b,
1654 struct btree_iter *iter, 1624 struct btree_iter *iter,
1655 struct btree_op *op) 1625 struct btree_op *op)
1656{ 1626{
1657 void subtract_dirty(struct bkey *k, int sectors) 1627 void subtract_dirty(struct bkey *k, uint64_t offset, int sectors)
1658 { 1628 {
1659 struct bcache_device *d = b->c->devices[KEY_INODE(k)]; 1629 if (KEY_DIRTY(k))
1660 1630 bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
1661 if (KEY_DIRTY(k) && d) 1631 offset, -sectors);
1662 atomic_long_sub(sectors, &d->sectors_dirty);
1663 } 1632 }
1664 1633
1634 uint64_t old_offset;
1665 unsigned old_size, sectors_found = 0; 1635 unsigned old_size, sectors_found = 0;
1666 1636
1667 while (1) { 1637 while (1) {
@@ -1673,6 +1643,7 @@ static bool fix_overlapping_extents(struct btree *b,
1673 if (bkey_cmp(k, &START_KEY(insert)) <= 0) 1643 if (bkey_cmp(k, &START_KEY(insert)) <= 0)
1674 continue; 1644 continue;
1675 1645
1646 old_offset = KEY_START(k);
1676 old_size = KEY_SIZE(k); 1647 old_size = KEY_SIZE(k);
1677 1648
1678 /* 1649 /*
@@ -1728,7 +1699,7 @@ static bool fix_overlapping_extents(struct btree *b,
1728 1699
1729 struct bkey *top; 1700 struct bkey *top;
1730 1701
1731 subtract_dirty(k, KEY_SIZE(insert)); 1702 subtract_dirty(k, KEY_START(insert), KEY_SIZE(insert));
1732 1703
1733 if (bkey_written(b, k)) { 1704 if (bkey_written(b, k)) {
1734 /* 1705 /*
@@ -1775,7 +1746,7 @@ static bool fix_overlapping_extents(struct btree *b,
1775 } 1746 }
1776 } 1747 }
1777 1748
1778 subtract_dirty(k, old_size - KEY_SIZE(k)); 1749 subtract_dirty(k, old_offset, old_size - KEY_SIZE(k));
1779 } 1750 }
1780 1751
1781check_failed: 1752check_failed:
@@ -1798,7 +1769,7 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
1798{ 1769{
1799 struct bset *i = b->sets[b->nsets].data; 1770 struct bset *i = b->sets[b->nsets].data;
1800 struct bkey *m, *prev; 1771 struct bkey *m, *prev;
1801 const char *status = "insert"; 1772 unsigned status = BTREE_INSERT_STATUS_INSERT;
1802 1773
1803 BUG_ON(bkey_cmp(k, &b->key) > 0); 1774 BUG_ON(bkey_cmp(k, &b->key) > 0);
1804 BUG_ON(b->level && !KEY_PTRS(k)); 1775 BUG_ON(b->level && !KEY_PTRS(k));
@@ -1831,17 +1802,17 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
1831 goto insert; 1802 goto insert;
1832 1803
1833 /* prev is in the tree, if we merge we're done */ 1804 /* prev is in the tree, if we merge we're done */
1834 status = "back merging"; 1805 status = BTREE_INSERT_STATUS_BACK_MERGE;
1835 if (prev && 1806 if (prev &&
1836 bch_bkey_try_merge(b, prev, k)) 1807 bch_bkey_try_merge(b, prev, k))
1837 goto merged; 1808 goto merged;
1838 1809
1839 status = "overwrote front"; 1810 status = BTREE_INSERT_STATUS_OVERWROTE;
1840 if (m != end(i) && 1811 if (m != end(i) &&
1841 KEY_PTRS(m) == KEY_PTRS(k) && !KEY_SIZE(m)) 1812 KEY_PTRS(m) == KEY_PTRS(k) && !KEY_SIZE(m))
1842 goto copy; 1813 goto copy;
1843 1814
1844 status = "front merge"; 1815 status = BTREE_INSERT_STATUS_FRONT_MERGE;
1845 if (m != end(i) && 1816 if (m != end(i) &&
1846 bch_bkey_try_merge(b, k, m)) 1817 bch_bkey_try_merge(b, k, m))
1847 goto copy; 1818 goto copy;
@@ -1851,21 +1822,21 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
1851insert: shift_keys(b, m, k); 1822insert: shift_keys(b, m, k);
1852copy: bkey_copy(m, k); 1823copy: bkey_copy(m, k);
1853merged: 1824merged:
1854 bch_check_keys(b, "%s for %s at %s: %s", status, 1825 if (KEY_DIRTY(k))
1855 op_type(op), pbtree(b), pkey(k)); 1826 bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
1856 bch_check_key_order_msg(b, i, "%s for %s at %s: %s", status, 1827 KEY_START(k), KEY_SIZE(k));
1857 op_type(op), pbtree(b), pkey(k)); 1828
1829 bch_check_keys(b, "%u for %s", status, op_type(op));
1858 1830
1859 if (b->level && !KEY_OFFSET(k)) 1831 if (b->level && !KEY_OFFSET(k))
1860 b->prio_blocked++; 1832 btree_current_write(b)->prio_blocked++;
1861 1833
1862 pr_debug("%s for %s at %s: %s", status, 1834 trace_bcache_btree_insert_key(b, k, op->type, status);
1863 op_type(op), pbtree(b), pkey(k));
1864 1835
1865 return true; 1836 return true;
1866} 1837}
1867 1838
1868bool bch_btree_insert_keys(struct btree *b, struct btree_op *op) 1839static bool bch_btree_insert_keys(struct btree *b, struct btree_op *op)
1869{ 1840{
1870 bool ret = false; 1841 bool ret = false;
1871 struct bkey *k; 1842 struct bkey *k;
@@ -1896,7 +1867,7 @@ bool bch_btree_insert_check_key(struct btree *b, struct btree_op *op,
1896 should_split(b)) 1867 should_split(b))
1897 goto out; 1868 goto out;
1898 1869
1899 op->replace = KEY(op->inode, bio_end(bio), bio_sectors(bio)); 1870 op->replace = KEY(op->inode, bio_end_sector(bio), bio_sectors(bio));
1900 1871
1901 SET_KEY_PTRS(&op->replace, 1); 1872 SET_KEY_PTRS(&op->replace, 1);
1902 get_random_bytes(&op->replace.ptr[0], sizeof(uint64_t)); 1873 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,
1907 1878
1908 BUG_ON(op->type != BTREE_INSERT); 1879 BUG_ON(op->type != BTREE_INSERT);
1909 BUG_ON(!btree_insert_key(b, op, &tmp.k)); 1880 BUG_ON(!btree_insert_key(b, op, &tmp.k));
1910 bch_btree_write(b, false, NULL);
1911 ret = true; 1881 ret = true;
1912out: 1882out:
1913 downgrade_write(&b->lock); 1883 downgrade_write(&b->lock);
@@ -1929,12 +1899,11 @@ static int btree_split(struct btree *b, struct btree_op *op)
1929 1899
1930 split = set_blocks(n1->sets[0].data, n1->c) > (btree_blocks(b) * 4) / 5; 1900 split = set_blocks(n1->sets[0].data, n1->c) > (btree_blocks(b) * 4) / 5;
1931 1901
1932 pr_debug("%ssplitting at %s keys %i", split ? "" : "not ",
1933 pbtree(b), n1->sets[0].data->keys);
1934
1935 if (split) { 1902 if (split) {
1936 unsigned keys = 0; 1903 unsigned keys = 0;
1937 1904
1905 trace_bcache_btree_node_split(b, n1->sets[0].data->keys);
1906
1938 n2 = bch_btree_node_alloc(b->c, b->level, &op->cl); 1907 n2 = bch_btree_node_alloc(b->c, b->level, &op->cl);
1939 if (IS_ERR(n2)) 1908 if (IS_ERR(n2))
1940 goto err_free1; 1909 goto err_free1;
@@ -1967,18 +1936,21 @@ static int btree_split(struct btree *b, struct btree_op *op)
1967 bkey_copy_key(&n2->key, &b->key); 1936 bkey_copy_key(&n2->key, &b->key);
1968 1937
1969 bch_keylist_add(&op->keys, &n2->key); 1938 bch_keylist_add(&op->keys, &n2->key);
1970 bch_btree_write(n2, true, op); 1939 bch_btree_node_write(n2, &op->cl);
1971 rw_unlock(true, n2); 1940 rw_unlock(true, n2);
1972 } else 1941 } else {
1942 trace_bcache_btree_node_compact(b, n1->sets[0].data->keys);
1943
1973 bch_btree_insert_keys(n1, op); 1944 bch_btree_insert_keys(n1, op);
1945 }
1974 1946
1975 bch_keylist_add(&op->keys, &n1->key); 1947 bch_keylist_add(&op->keys, &n1->key);
1976 bch_btree_write(n1, true, op); 1948 bch_btree_node_write(n1, &op->cl);
1977 1949
1978 if (n3) { 1950 if (n3) {
1979 bkey_copy_key(&n3->key, &MAX_KEY); 1951 bkey_copy_key(&n3->key, &MAX_KEY);
1980 bch_btree_insert_keys(n3, op); 1952 bch_btree_insert_keys(n3, op);
1981 bch_btree_write(n3, true, op); 1953 bch_btree_node_write(n3, &op->cl);
1982 1954
1983 closure_sync(&op->cl); 1955 closure_sync(&op->cl);
1984 bch_btree_set_root(n3); 1956 bch_btree_set_root(n3);
@@ -2082,8 +2054,12 @@ static int bch_btree_insert_recurse(struct btree *b, struct btree_op *op,
2082 2054
2083 BUG_ON(write_block(b) != b->sets[b->nsets].data); 2055 BUG_ON(write_block(b) != b->sets[b->nsets].data);
2084 2056
2085 if (bch_btree_insert_keys(b, op)) 2057 if (bch_btree_insert_keys(b, op)) {
2086 bch_btree_write(b, false, op); 2058 if (!b->level)
2059 bch_btree_leaf_dirty(b, op);
2060 else
2061 bch_btree_node_write(b, &op->cl);
2062 }
2087 } 2063 }
2088 2064
2089 return 0; 2065 return 0;
@@ -2140,6 +2116,11 @@ int bch_btree_insert(struct btree_op *op, struct cache_set *c)
2140void bch_btree_set_root(struct btree *b) 2116void bch_btree_set_root(struct btree *b)
2141{ 2117{
2142 unsigned i; 2118 unsigned i;
2119 struct closure cl;
2120
2121 closure_init_stack(&cl);
2122
2123 trace_bcache_btree_set_root(b);
2143 2124
2144 BUG_ON(!b->written); 2125 BUG_ON(!b->written);
2145 2126
@@ -2153,8 +2134,8 @@ void bch_btree_set_root(struct btree *b)
2153 b->c->root = b; 2134 b->c->root = b;
2154 __bkey_put(b->c, &b->key); 2135 __bkey_put(b->c, &b->key);
2155 2136
2156 bch_journal_meta(b->c, NULL); 2137 bch_journal_meta(b->c, &cl);
2157 pr_debug("%s for %pf", pbtree(b), __builtin_return_address(0)); 2138 closure_sync(&cl);
2158} 2139}
2159 2140
2160/* Cache lookup */ 2141/* Cache lookup */
@@ -2215,9 +2196,6 @@ static int submit_partial_cache_hit(struct btree *b, struct btree_op *op,
2215 KEY_OFFSET(k) - bio->bi_sector); 2196 KEY_OFFSET(k) - bio->bi_sector);
2216 2197
2217 n = bch_bio_split(bio, sectors, GFP_NOIO, s->d->bio_split); 2198 n = bch_bio_split(bio, sectors, GFP_NOIO, s->d->bio_split);
2218 if (!n)
2219 return -EAGAIN;
2220
2221 if (n == bio) 2199 if (n == bio)
2222 op->lookup_done = true; 2200 op->lookup_done = true;
2223 2201
@@ -2240,7 +2218,6 @@ static int submit_partial_cache_hit(struct btree *b, struct btree_op *op,
2240 n->bi_end_io = bch_cache_read_endio; 2218 n->bi_end_io = bch_cache_read_endio;
2241 n->bi_private = &s->cl; 2219 n->bi_private = &s->cl;
2242 2220
2243 trace_bcache_cache_hit(n);
2244 __bch_submit_bbio(n, b->c); 2221 __bch_submit_bbio(n, b->c);
2245 } 2222 }
2246 2223
@@ -2257,9 +2234,6 @@ int bch_btree_search_recurse(struct btree *b, struct btree_op *op)
2257 struct btree_iter iter; 2234 struct btree_iter iter;
2258 bch_btree_iter_init(b, &iter, &KEY(op->inode, bio->bi_sector, 0)); 2235 bch_btree_iter_init(b, &iter, &KEY(op->inode, bio->bi_sector, 0));
2259 2236
2260 pr_debug("at %s searching for %u:%llu", pbtree(b), op->inode,
2261 (uint64_t) bio->bi_sector);
2262
2263 do { 2237 do {
2264 k = bch_btree_iter_next_filter(&iter, b, bch_ptr_bad); 2238 k = bch_btree_iter_next_filter(&iter, b, bch_ptr_bad);
2265 if (!k) { 2239 if (!k) {
@@ -2303,7 +2277,8 @@ static inline int keybuf_nonoverlapping_cmp(struct keybuf_key *l,
2303} 2277}
2304 2278
2305static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op, 2279static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op,
2306 struct keybuf *buf, struct bkey *end) 2280 struct keybuf *buf, struct bkey *end,
2281 keybuf_pred_fn *pred)
2307{ 2282{
2308 struct btree_iter iter; 2283 struct btree_iter iter;
2309 bch_btree_iter_init(b, &iter, &buf->last_scanned); 2284 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,
2322 if (bkey_cmp(&buf->last_scanned, end) >= 0) 2297 if (bkey_cmp(&buf->last_scanned, end) >= 0)
2323 break; 2298 break;
2324 2299
2325 if (buf->key_predicate(buf, k)) { 2300 if (pred(buf, k)) {
2326 struct keybuf_key *w; 2301 struct keybuf_key *w;
2327 2302
2328 pr_debug("%s", pkey(k));
2329
2330 spin_lock(&buf->lock); 2303 spin_lock(&buf->lock);
2331 2304
2332 w = array_alloc(&buf->freelist); 2305 w = array_alloc(&buf->freelist);
@@ -2343,7 +2316,7 @@ static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op,
2343 if (!k) 2316 if (!k)
2344 break; 2317 break;
2345 2318
2346 btree(refill_keybuf, k, b, op, buf, end); 2319 btree(refill_keybuf, k, b, op, buf, end, pred);
2347 /* 2320 /*
2348 * Might get an error here, but can't really do anything 2321 * Might get an error here, but can't really do anything
2349 * and it'll get logged elsewhere. Just read what we 2322 * 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,
2361} 2334}
2362 2335
2363void bch_refill_keybuf(struct cache_set *c, struct keybuf *buf, 2336void bch_refill_keybuf(struct cache_set *c, struct keybuf *buf,
2364 struct bkey *end) 2337 struct bkey *end, keybuf_pred_fn *pred)
2365{ 2338{
2366 struct bkey start = buf->last_scanned; 2339 struct bkey start = buf->last_scanned;
2367 struct btree_op op; 2340 struct btree_op op;
@@ -2369,7 +2342,7 @@ void bch_refill_keybuf(struct cache_set *c, struct keybuf *buf,
2369 2342
2370 cond_resched(); 2343 cond_resched();
2371 2344
2372 btree_root(refill_keybuf, c, &op, buf, end); 2345 btree_root(refill_keybuf, c, &op, buf, end, pred);
2373 closure_sync(&op.cl); 2346 closure_sync(&op.cl);
2374 2347
2375 pr_debug("found %s keys from %llu:%llu to %llu:%llu", 2348 pr_debug("found %s keys from %llu:%llu to %llu:%llu",
@@ -2455,7 +2428,8 @@ struct keybuf_key *bch_keybuf_next(struct keybuf *buf)
2455 2428
2456struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c, 2429struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
2457 struct keybuf *buf, 2430 struct keybuf *buf,
2458 struct bkey *end) 2431 struct bkey *end,
2432 keybuf_pred_fn *pred)
2459{ 2433{
2460 struct keybuf_key *ret; 2434 struct keybuf_key *ret;
2461 2435
@@ -2469,15 +2443,14 @@ struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
2469 break; 2443 break;
2470 } 2444 }
2471 2445
2472 bch_refill_keybuf(c, buf, end); 2446 bch_refill_keybuf(c, buf, end, pred);
2473 } 2447 }
2474 2448
2475 return ret; 2449 return ret;
2476} 2450}
2477 2451
2478void bch_keybuf_init(struct keybuf *buf, keybuf_pred_fn *fn) 2452void bch_keybuf_init(struct keybuf *buf)
2479{ 2453{
2480 buf->key_predicate = fn;
2481 buf->last_scanned = MAX_KEY; 2454 buf->last_scanned = MAX_KEY;
2482 buf->keys = RB_ROOT; 2455 buf->keys = RB_ROOT;
2483 2456
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h
index af4a7092a28c..3333d3723633 100644
--- a/drivers/md/bcache/btree.h
+++ b/drivers/md/bcache/btree.h
@@ -102,7 +102,6 @@
102#include "debug.h" 102#include "debug.h"
103 103
104struct btree_write { 104struct btree_write {
105 struct closure *owner;
106 atomic_t *journal; 105 atomic_t *journal;
107 106
108 /* If btree_split() frees a btree node, it writes a new pointer to that 107 /* If btree_split() frees a btree node, it writes a new pointer to that
@@ -142,16 +141,12 @@ struct btree {
142 */ 141 */
143 struct bset_tree sets[MAX_BSETS]; 142 struct bset_tree sets[MAX_BSETS];
144 143
145 /* Used to refcount bio splits, also protects b->bio */ 144 /* For outstanding btree writes, used as a lock - protects write_idx */
146 struct closure_with_waitlist io; 145 struct closure_with_waitlist io;
147 146
148 /* Gets transferred to w->prio_blocked - see the comment there */
149 int prio_blocked;
150
151 struct list_head list; 147 struct list_head list;
152 struct delayed_work work; 148 struct delayed_work work;
153 149
154 uint64_t io_start_time;
155 struct btree_write writes[2]; 150 struct btree_write writes[2];
156 struct bio *bio; 151 struct bio *bio;
157}; 152};
@@ -164,13 +159,11 @@ static inline void set_btree_node_ ## flag(struct btree *b) \
164{ set_bit(BTREE_NODE_ ## flag, &b->flags); } \ 159{ set_bit(BTREE_NODE_ ## flag, &b->flags); } \
165 160
166enum btree_flags { 161enum btree_flags {
167 BTREE_NODE_read_done,
168 BTREE_NODE_io_error, 162 BTREE_NODE_io_error,
169 BTREE_NODE_dirty, 163 BTREE_NODE_dirty,
170 BTREE_NODE_write_idx, 164 BTREE_NODE_write_idx,
171}; 165};
172 166
173BTREE_FLAG(read_done);
174BTREE_FLAG(io_error); 167BTREE_FLAG(io_error);
175BTREE_FLAG(dirty); 168BTREE_FLAG(dirty);
176BTREE_FLAG(write_idx); 169BTREE_FLAG(write_idx);
@@ -278,6 +271,13 @@ struct btree_op {
278 BKEY_PADDED(replace); 271 BKEY_PADDED(replace);
279}; 272};
280 273
274enum {
275 BTREE_INSERT_STATUS_INSERT,
276 BTREE_INSERT_STATUS_BACK_MERGE,
277 BTREE_INSERT_STATUS_OVERWROTE,
278 BTREE_INSERT_STATUS_FRONT_MERGE,
279};
280
281void bch_btree_op_init_stack(struct btree_op *); 281void bch_btree_op_init_stack(struct btree_op *);
282 282
283static inline void rw_lock(bool w, struct btree *b, int level) 283static 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)
293#ifdef CONFIG_BCACHE_EDEBUG 293#ifdef CONFIG_BCACHE_EDEBUG
294 unsigned i; 294 unsigned i;
295 295
296 if (w && 296 if (w && b->key.ptr[0])
297 b->key.ptr[0] &&
298 btree_node_read_done(b))
299 for (i = 0; i <= b->nsets; i++) 297 for (i = 0; i <= b->nsets; i++)
300 bch_check_key_order(b, b->sets[i].data); 298 bch_check_key_order(b, b->sets[i].data);
301#endif 299#endif
@@ -370,9 +368,8 @@ static inline bool should_split(struct btree *b)
370 > btree_blocks(b)); 368 > btree_blocks(b));
371} 369}
372 370
373void bch_btree_read_done(struct closure *); 371void bch_btree_node_read(struct btree *);
374void bch_btree_read(struct btree *); 372void bch_btree_node_write(struct btree *, struct closure *);
375void bch_btree_write(struct btree *b, bool now, struct btree_op *op);
376 373
377void bch_cannibalize_unlock(struct cache_set *, struct closure *); 374void bch_cannibalize_unlock(struct cache_set *, struct closure *);
378void bch_btree_set_root(struct btree *); 375void bch_btree_set_root(struct btree *);
@@ -380,7 +377,6 @@ struct btree *bch_btree_node_alloc(struct cache_set *, int, struct closure *);
380struct btree *bch_btree_node_get(struct cache_set *, struct bkey *, 377struct btree *bch_btree_node_get(struct cache_set *, struct bkey *,
381 int, struct btree_op *); 378 int, struct btree_op *);
382 379
383bool bch_btree_insert_keys(struct btree *, struct btree_op *);
384bool bch_btree_insert_check_key(struct btree *, struct btree_op *, 380bool bch_btree_insert_check_key(struct btree *, struct btree_op *,
385 struct bio *); 381 struct bio *);
386int bch_btree_insert(struct btree_op *, struct cache_set *); 382int bch_btree_insert(struct btree_op *, struct cache_set *);
@@ -393,13 +389,14 @@ void bch_moving_gc(struct closure *);
393int bch_btree_check(struct cache_set *, struct btree_op *); 389int bch_btree_check(struct cache_set *, struct btree_op *);
394uint8_t __bch_btree_mark_key(struct cache_set *, int, struct bkey *); 390uint8_t __bch_btree_mark_key(struct cache_set *, int, struct bkey *);
395 391
396void bch_keybuf_init(struct keybuf *, keybuf_pred_fn *); 392void bch_keybuf_init(struct keybuf *);
397void bch_refill_keybuf(struct cache_set *, struct keybuf *, struct bkey *); 393void bch_refill_keybuf(struct cache_set *, struct keybuf *, struct bkey *,
394 keybuf_pred_fn *);
398bool bch_keybuf_check_overlapping(struct keybuf *, struct bkey *, 395bool bch_keybuf_check_overlapping(struct keybuf *, struct bkey *,
399 struct bkey *); 396 struct bkey *);
400void bch_keybuf_del(struct keybuf *, struct keybuf_key *); 397void bch_keybuf_del(struct keybuf *, struct keybuf_key *);
401struct keybuf_key *bch_keybuf_next(struct keybuf *); 398struct keybuf_key *bch_keybuf_next(struct keybuf *);
402struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *, 399struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *, struct keybuf *,
403 struct keybuf *, struct bkey *); 400 struct bkey *, keybuf_pred_fn *);
404 401
405#endif 402#endif
diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
index bd05a9a8c7cf..9aba2017f0d1 100644
--- a/drivers/md/bcache/closure.c
+++ b/drivers/md/bcache/closure.c
@@ -66,16 +66,18 @@ static inline void closure_put_after_sub(struct closure *cl, int flags)
66 } else { 66 } else {
67 struct closure *parent = cl->parent; 67 struct closure *parent = cl->parent;
68 struct closure_waitlist *wait = closure_waitlist(cl); 68 struct closure_waitlist *wait = closure_waitlist(cl);
69 closure_fn *destructor = cl->fn;
69 70
70 closure_debug_destroy(cl); 71 closure_debug_destroy(cl);
71 72
73 smp_mb();
72 atomic_set(&cl->remaining, -1); 74 atomic_set(&cl->remaining, -1);
73 75
74 if (wait) 76 if (wait)
75 closure_wake_up(wait); 77 closure_wake_up(wait);
76 78
77 if (cl->fn) 79 if (destructor)
78 cl->fn(cl); 80 destructor(cl);
79 81
80 if (parent) 82 if (parent)
81 closure_put(parent); 83 closure_put(parent);
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 89fd5204924e..88e6411eab4f 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -47,11 +47,10 @@ const char *bch_ptr_status(struct cache_set *c, const struct bkey *k)
47 return ""; 47 return "";
48} 48}
49 49
50struct keyprint_hack bch_pkey(const struct bkey *k) 50int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k)
51{ 51{
52 unsigned i = 0; 52 unsigned i = 0;
53 struct keyprint_hack r; 53 char *out = buf, *end = buf + size;
54 char *out = r.s, *end = r.s + KEYHACK_SIZE;
55 54
56#define p(...) (out += scnprintf(out, end - out, __VA_ARGS__)) 55#define p(...) (out += scnprintf(out, end - out, __VA_ARGS__))
57 56
@@ -75,16 +74,14 @@ struct keyprint_hack bch_pkey(const struct bkey *k)
75 if (KEY_CSUM(k)) 74 if (KEY_CSUM(k))
76 p(" cs%llu %llx", KEY_CSUM(k), k->ptr[1]); 75 p(" cs%llu %llx", KEY_CSUM(k), k->ptr[1]);
77#undef p 76#undef p
78 return r; 77 return out - buf;
79} 78}
80 79
81struct keyprint_hack bch_pbtree(const struct btree *b) 80int bch_btree_to_text(char *buf, size_t size, const struct btree *b)
82{ 81{
83 struct keyprint_hack r; 82 return scnprintf(buf, size, "%zu level %i/%i",
84 83 PTR_BUCKET_NR(b->c, &b->key, 0),
85 snprintf(r.s, 40, "%zu level %i/%i", PTR_BUCKET_NR(b->c, &b->key, 0), 84 b->level, b->c->root ? b->c->root->level : -1);
86 b->level, b->c->root ? b->c->root->level : -1);
87 return r;
88} 85}
89 86
90#if defined(CONFIG_BCACHE_DEBUG) || defined(CONFIG_BCACHE_EDEBUG) 87#if defined(CONFIG_BCACHE_DEBUG) || defined(CONFIG_BCACHE_EDEBUG)
@@ -100,10 +97,12 @@ static void dump_bset(struct btree *b, struct bset *i)
100{ 97{
101 struct bkey *k; 98 struct bkey *k;
102 unsigned j; 99 unsigned j;
100 char buf[80];
103 101
104 for (k = i->start; k < end(i); k = bkey_next(k)) { 102 for (k = i->start; k < end(i); k = bkey_next(k)) {
103 bch_bkey_to_text(buf, sizeof(buf), k);
105 printk(KERN_ERR "block %zu key %zi/%u: %s", index(i, b), 104 printk(KERN_ERR "block %zu key %zi/%u: %s", index(i, b),
106 (uint64_t *) k - i->d, i->keys, pkey(k)); 105 (uint64_t *) k - i->d, i->keys, buf);
107 106
108 for (j = 0; j < KEY_PTRS(k); j++) { 107 for (j = 0; j < KEY_PTRS(k); j++) {
109 size_t n = PTR_BUCKET_NR(b->c, k, j); 108 size_t n = PTR_BUCKET_NR(b->c, k, j);
@@ -144,7 +143,7 @@ void bch_btree_verify(struct btree *b, struct bset *new)
144 v->written = 0; 143 v->written = 0;
145 v->level = b->level; 144 v->level = b->level;
146 145
147 bch_btree_read(v); 146 bch_btree_node_read(v);
148 closure_wait_event(&v->io.wait, &cl, 147 closure_wait_event(&v->io.wait, &cl,
149 atomic_read(&b->io.cl.remaining) == -1); 148 atomic_read(&b->io.cl.remaining) == -1);
150 149
@@ -200,7 +199,7 @@ void bch_data_verify(struct search *s)
200 if (!check) 199 if (!check)
201 return; 200 return;
202 201
203 if (bch_bio_alloc_pages(check, GFP_NOIO)) 202 if (bio_alloc_pages(check, GFP_NOIO))
204 goto out_put; 203 goto out_put;
205 204
206 check->bi_rw = READ_SYNC; 205 check->bi_rw = READ_SYNC;
@@ -252,6 +251,7 @@ static void vdump_bucket_and_panic(struct btree *b, const char *fmt,
252 va_list args) 251 va_list args)
253{ 252{
254 unsigned i; 253 unsigned i;
254 char buf[80];
255 255
256 console_lock(); 256 console_lock();
257 257
@@ -262,7 +262,8 @@ static void vdump_bucket_and_panic(struct btree *b, const char *fmt,
262 262
263 console_unlock(); 263 console_unlock();
264 264
265 panic("at %s\n", pbtree(b)); 265 bch_btree_to_text(buf, sizeof(buf), b);
266 panic("at %s\n", buf);
266} 267}
267 268
268void bch_check_key_order_msg(struct btree *b, struct bset *i, 269void 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,
337{ 338{
338 struct dump_iterator *i = file->private_data; 339 struct dump_iterator *i = file->private_data;
339 ssize_t ret = 0; 340 ssize_t ret = 0;
341 char kbuf[80];
340 342
341 while (size) { 343 while (size) {
342 struct keybuf_key *w; 344 struct keybuf_key *w;
@@ -355,11 +357,12 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf,
355 if (i->bytes) 357 if (i->bytes)
356 break; 358 break;
357 359
358 w = bch_keybuf_next_rescan(i->c, &i->keys, &MAX_KEY); 360 w = bch_keybuf_next_rescan(i->c, &i->keys, &MAX_KEY, dump_pred);
359 if (!w) 361 if (!w)
360 break; 362 break;
361 363
362 i->bytes = snprintf(i->buf, PAGE_SIZE, "%s\n", pkey(&w->key)); 364 bch_bkey_to_text(kbuf, sizeof(kbuf), &w->key);
365 i->bytes = snprintf(i->buf, PAGE_SIZE, "%s\n", kbuf);
363 bch_keybuf_del(&i->keys, w); 366 bch_keybuf_del(&i->keys, w);
364 } 367 }
365 368
@@ -377,7 +380,7 @@ static int bch_dump_open(struct inode *inode, struct file *file)
377 380
378 file->private_data = i; 381 file->private_data = i;
379 i->c = c; 382 i->c = c;
380 bch_keybuf_init(&i->keys, dump_pred); 383 bch_keybuf_init(&i->keys);
381 i->keys.last_scanned = KEY(0, 0, 0); 384 i->keys.last_scanned = KEY(0, 0, 0);
382 385
383 return 0; 386 return 0;
@@ -409,142 +412,6 @@ void bch_debug_init_cache_set(struct cache_set *c)
409 412
410#endif 413#endif
411 414
412/* Fuzz tester has rotted: */
413#if 0
414
415static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a,
416 const char *buffer, size_t size)
417{
418 void dump(struct btree *b)
419 {
420 struct bset *i;
421
422 for (i = b->sets[0].data;
423 index(i, b) < btree_blocks(b) &&
424 i->seq == b->sets[0].data->seq;
425 i = ((void *) i) + set_blocks(i, b->c) * block_bytes(b->c))
426 dump_bset(b, i);
427 }
428
429 struct cache_sb *sb;
430 struct cache_set *c;
431 struct btree *all[3], *b, *fill, *orig;
432 int j;
433
434 struct btree_op op;
435 bch_btree_op_init_stack(&op);
436
437 sb = kzalloc(sizeof(struct cache_sb), GFP_KERNEL);
438 if (!sb)
439 return -ENOMEM;
440
441 sb->bucket_size = 128;
442 sb->block_size = 4;
443
444 c = bch_cache_set_alloc(sb);
445 if (!c)
446 return -ENOMEM;
447
448 for (j = 0; j < 3; j++) {
449 BUG_ON(list_empty(&c->btree_cache));
450 all[j] = list_first_entry(&c->btree_cache, struct btree, list);
451 list_del_init(&all[j]->list);
452
453 all[j]->key = KEY(0, 0, c->sb.bucket_size);
454 bkey_copy_key(&all[j]->key, &MAX_KEY);
455 }
456
457 b = all[0];
458 fill = all[1];
459 orig = all[2];
460
461 while (1) {
462 for (j = 0; j < 3; j++)
463 all[j]->written = all[j]->nsets = 0;
464
465 bch_bset_init_next(b);
466
467 while (1) {
468 struct bset *i = write_block(b);
469 struct bkey *k = op.keys.top;
470 unsigned rand;
471
472 bkey_init(k);
473 rand = get_random_int();
474
475 op.type = rand & 1
476 ? BTREE_INSERT
477 : BTREE_REPLACE;
478 rand >>= 1;
479
480 SET_KEY_SIZE(k, bucket_remainder(c, rand));
481 rand >>= c->bucket_bits;
482 rand &= 1024 * 512 - 1;
483 rand += c->sb.bucket_size;
484 SET_KEY_OFFSET(k, rand);
485#if 0
486 SET_KEY_PTRS(k, 1);
487#endif
488 bch_keylist_push(&op.keys);
489 bch_btree_insert_keys(b, &op);
490
491 if (should_split(b) ||
492 set_blocks(i, b->c) !=
493 __set_blocks(i, i->keys + 15, b->c)) {
494 i->csum = csum_set(i);
495
496 memcpy(write_block(fill),
497 i, set_bytes(i));
498
499 b->written += set_blocks(i, b->c);
500 fill->written = b->written;
501 if (b->written == btree_blocks(b))
502 break;
503
504 bch_btree_sort_lazy(b);
505 bch_bset_init_next(b);
506 }
507 }
508
509 memcpy(orig->sets[0].data,
510 fill->sets[0].data,
511 btree_bytes(c));
512
513 bch_btree_sort(b);
514 fill->written = 0;
515 bch_btree_read_done(&fill->io.cl);
516
517 if (b->sets[0].data->keys != fill->sets[0].data->keys ||
518 memcmp(b->sets[0].data->start,
519 fill->sets[0].data->start,
520 b->sets[0].data->keys * sizeof(uint64_t))) {
521 struct bset *i = b->sets[0].data;
522 struct bkey *k, *l;
523
524 for (k = i->start,
525 l = fill->sets[0].data->start;
526 k < end(i);
527 k = bkey_next(k), l = bkey_next(l))
528 if (bkey_cmp(k, l) ||
529 KEY_SIZE(k) != KEY_SIZE(l))
530 pr_err("key %zi differs: %s != %s",
531 (uint64_t *) k - i->d,
532 pkey(k), pkey(l));
533
534 for (j = 0; j < 3; j++) {
535 pr_err("**** Set %i ****", j);
536 dump(all[j]);
537 }
538 panic("\n");
539 }
540
541 pr_info("fuzz complete: %i keys", b->sets[0].data->keys);
542 }
543}
544
545kobj_attribute_write(fuzz, btree_fuzz);
546#endif
547
548void bch_debug_exit(void) 415void bch_debug_exit(void)
549{ 416{
550 if (!IS_ERR_OR_NULL(debug)) 417 if (!IS_ERR_OR_NULL(debug))
@@ -554,11 +421,6 @@ void bch_debug_exit(void)
554int __init bch_debug_init(struct kobject *kobj) 421int __init bch_debug_init(struct kobject *kobj)
555{ 422{
556 int ret = 0; 423 int ret = 0;
557#if 0
558 ret = sysfs_create_file(kobj, &ksysfs_fuzz.attr);
559 if (ret)
560 return ret;
561#endif
562 424
563 debug = debugfs_create_dir("bcache", NULL); 425 debug = debugfs_create_dir("bcache", NULL);
564 return ret; 426 return ret;
diff --git a/drivers/md/bcache/debug.h b/drivers/md/bcache/debug.h
index f9378a218148..1c39b5a2489b 100644
--- a/drivers/md/bcache/debug.h
+++ b/drivers/md/bcache/debug.h
@@ -3,15 +3,8 @@
3 3
4/* Btree/bkey debug printing */ 4/* Btree/bkey debug printing */
5 5
6#define KEYHACK_SIZE 80 6int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k);
7struct keyprint_hack { 7int bch_btree_to_text(char *buf, size_t size, const struct btree *b);
8 char s[KEYHACK_SIZE];
9};
10
11struct keyprint_hack bch_pkey(const struct bkey *k);
12struct keyprint_hack bch_pbtree(const struct btree *b);
13#define pkey(k) (&bch_pkey(k).s[0])
14#define pbtree(b) (&bch_pbtree(b).s[0])
15 8
16#ifdef CONFIG_BCACHE_EDEBUG 9#ifdef CONFIG_BCACHE_EDEBUG
17 10
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index 48efd4dea645..9056632995b1 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -9,6 +9,8 @@
9#include "bset.h" 9#include "bset.h"
10#include "debug.h" 10#include "debug.h"
11 11
12#include <linux/blkdev.h>
13
12static void bch_bi_idx_hack_endio(struct bio *bio, int error) 14static void bch_bi_idx_hack_endio(struct bio *bio, int error)
13{ 15{
14 struct bio *p = bio->bi_private; 16 struct bio *p = bio->bi_private;
@@ -66,13 +68,6 @@ static void bch_generic_make_request_hack(struct bio *bio)
66 * The newly allocated bio will point to @bio's bi_io_vec, if the split was on a 68 * The newly allocated bio will point to @bio's bi_io_vec, if the split was on a
67 * bvec boundry; it is the caller's responsibility to ensure that @bio is not 69 * bvec boundry; it is the caller's responsibility to ensure that @bio is not
68 * freed before the split. 70 * freed before the split.
69 *
70 * If bch_bio_split() is running under generic_make_request(), it's not safe to
71 * allocate more than one bio from the same bio set. Therefore, if it is running
72 * under generic_make_request() it masks out __GFP_WAIT when doing the
73 * allocation. The caller must check for failure if there's any possibility of
74 * it being called from under generic_make_request(); it is then the caller's
75 * responsibility to retry from a safe context (by e.g. punting to workqueue).
76 */ 71 */
77struct bio *bch_bio_split(struct bio *bio, int sectors, 72struct bio *bch_bio_split(struct bio *bio, int sectors,
78 gfp_t gfp, struct bio_set *bs) 73 gfp_t gfp, struct bio_set *bs)
@@ -83,20 +78,13 @@ struct bio *bch_bio_split(struct bio *bio, int sectors,
83 78
84 BUG_ON(sectors <= 0); 79 BUG_ON(sectors <= 0);
85 80
86 /*
87 * If we're being called from underneath generic_make_request() and we
88 * already allocated any bios from this bio set, we risk deadlock if we
89 * use the mempool. So instead, we possibly fail and let the caller punt
90 * to workqueue or somesuch and retry in a safe context.
91 */
92 if (current->bio_list)
93 gfp &= ~__GFP_WAIT;
94
95 if (sectors >= bio_sectors(bio)) 81 if (sectors >= bio_sectors(bio))
96 return bio; 82 return bio;
97 83
98 if (bio->bi_rw & REQ_DISCARD) { 84 if (bio->bi_rw & REQ_DISCARD) {
99 ret = bio_alloc_bioset(gfp, 1, bs); 85 ret = bio_alloc_bioset(gfp, 1, bs);
86 if (!ret)
87 return NULL;
100 idx = 0; 88 idx = 0;
101 goto out; 89 goto out;
102 } 90 }
@@ -160,17 +148,18 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
160 struct request_queue *q = bdev_get_queue(bio->bi_bdev); 148 struct request_queue *q = bdev_get_queue(bio->bi_bdev);
161 unsigned max_segments = min_t(unsigned, BIO_MAX_PAGES, 149 unsigned max_segments = min_t(unsigned, BIO_MAX_PAGES,
162 queue_max_segments(q)); 150 queue_max_segments(q));
163 struct bio_vec *bv, *end = bio_iovec(bio) +
164 min_t(int, bio_segments(bio), max_segments);
165 151
166 if (bio->bi_rw & REQ_DISCARD) 152 if (bio->bi_rw & REQ_DISCARD)
167 return min(ret, q->limits.max_discard_sectors); 153 return min(ret, q->limits.max_discard_sectors);
168 154
169 if (bio_segments(bio) > max_segments || 155 if (bio_segments(bio) > max_segments ||
170 q->merge_bvec_fn) { 156 q->merge_bvec_fn) {
157 struct bio_vec *bv;
158 int i, seg = 0;
159
171 ret = 0; 160 ret = 0;
172 161
173 for (bv = bio_iovec(bio); bv < end; bv++) { 162 bio_for_each_segment(bv, bio, i) {
174 struct bvec_merge_data bvm = { 163 struct bvec_merge_data bvm = {
175 .bi_bdev = bio->bi_bdev, 164 .bi_bdev = bio->bi_bdev,
176 .bi_sector = bio->bi_sector, 165 .bi_sector = bio->bi_sector,
@@ -178,10 +167,14 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
178 .bi_rw = bio->bi_rw, 167 .bi_rw = bio->bi_rw,
179 }; 168 };
180 169
170 if (seg == max_segments)
171 break;
172
181 if (q->merge_bvec_fn && 173 if (q->merge_bvec_fn &&
182 q->merge_bvec_fn(q, &bvm, bv) < (int) bv->bv_len) 174 q->merge_bvec_fn(q, &bvm, bv) < (int) bv->bv_len)
183 break; 175 break;
184 176
177 seg++;
185 ret += bv->bv_len >> 9; 178 ret += bv->bv_len >> 9;
186 } 179 }
187 } 180 }
@@ -218,30 +211,10 @@ static void bch_bio_submit_split_endio(struct bio *bio, int error)
218 closure_put(cl); 211 closure_put(cl);
219} 212}
220 213
221static void __bch_bio_submit_split(struct closure *cl)
222{
223 struct bio_split_hook *s = container_of(cl, struct bio_split_hook, cl);
224 struct bio *bio = s->bio, *n;
225
226 do {
227 n = bch_bio_split(bio, bch_bio_max_sectors(bio),
228 GFP_NOIO, s->p->bio_split);
229 if (!n)
230 continue_at(cl, __bch_bio_submit_split, system_wq);
231
232 n->bi_end_io = bch_bio_submit_split_endio;
233 n->bi_private = cl;
234
235 closure_get(cl);
236 bch_generic_make_request_hack(n);
237 } while (n != bio);
238
239 continue_at(cl, bch_bio_submit_split_done, NULL);
240}
241
242void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p) 214void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p)
243{ 215{
244 struct bio_split_hook *s; 216 struct bio_split_hook *s;
217 struct bio *n;
245 218
246 if (!bio_has_data(bio) && !(bio->bi_rw & REQ_DISCARD)) 219 if (!bio_has_data(bio) && !(bio->bi_rw & REQ_DISCARD))
247 goto submit; 220 goto submit;
@@ -250,6 +223,7 @@ void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p)
250 goto submit; 223 goto submit;
251 224
252 s = mempool_alloc(p->bio_split_hook, GFP_NOIO); 225 s = mempool_alloc(p->bio_split_hook, GFP_NOIO);
226 closure_init(&s->cl, NULL);
253 227
254 s->bio = bio; 228 s->bio = bio;
255 s->p = p; 229 s->p = p;
@@ -257,8 +231,18 @@ void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p)
257 s->bi_private = bio->bi_private; 231 s->bi_private = bio->bi_private;
258 bio_get(bio); 232 bio_get(bio);
259 233
260 closure_call(&s->cl, __bch_bio_submit_split, NULL, NULL); 234 do {
261 return; 235 n = bch_bio_split(bio, bch_bio_max_sectors(bio),
236 GFP_NOIO, s->p->bio_split);
237
238 n->bi_end_io = bch_bio_submit_split_endio;
239 n->bi_private = &s->cl;
240
241 closure_get(&s->cl);
242 bch_generic_make_request_hack(n);
243 } while (n != bio);
244
245 continue_at(&s->cl, bch_bio_submit_split_done, NULL);
262submit: 246submit:
263 bch_generic_make_request_hack(bio); 247 bch_generic_make_request_hack(bio);
264} 248}
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 8c8dfdcd9d4c..ba95ab84b2be 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -9,6 +9,8 @@
9#include "debug.h" 9#include "debug.h"
10#include "request.h" 10#include "request.h"
11 11
12#include <trace/events/bcache.h>
13
12/* 14/*
13 * Journal replay/recovery: 15 * Journal replay/recovery:
14 * 16 *
@@ -182,9 +184,14 @@ bsearch:
182 pr_debug("starting binary search, l %u r %u", l, r); 184 pr_debug("starting binary search, l %u r %u", l, r);
183 185
184 while (l + 1 < r) { 186 while (l + 1 < r) {
187 seq = list_entry(list->prev, struct journal_replay,
188 list)->j.seq;
189
185 m = (l + r) >> 1; 190 m = (l + r) >> 1;
191 read_bucket(m);
186 192
187 if (read_bucket(m)) 193 if (seq != list_entry(list->prev, struct journal_replay,
194 list)->j.seq)
188 l = m; 195 l = m;
189 else 196 else
190 r = m; 197 r = m;
@@ -300,7 +307,8 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list,
300 for (k = i->j.start; 307 for (k = i->j.start;
301 k < end(&i->j); 308 k < end(&i->j);
302 k = bkey_next(k)) { 309 k = bkey_next(k)) {
303 pr_debug("%s", pkey(k)); 310 trace_bcache_journal_replay_key(k);
311
304 bkey_copy(op->keys.top, k); 312 bkey_copy(op->keys.top, k);
305 bch_keylist_push(&op->keys); 313 bch_keylist_push(&op->keys);
306 314
@@ -384,7 +392,7 @@ out:
384 return; 392 return;
385found: 393found:
386 if (btree_node_dirty(best)) 394 if (btree_node_dirty(best))
387 bch_btree_write(best, true, NULL); 395 bch_btree_node_write(best, NULL);
388 rw_unlock(true, best); 396 rw_unlock(true, best);
389} 397}
390 398
@@ -617,7 +625,7 @@ static void journal_write_unlocked(struct closure *cl)
617 bio_reset(bio); 625 bio_reset(bio);
618 bio->bi_sector = PTR_OFFSET(k, i); 626 bio->bi_sector = PTR_OFFSET(k, i);
619 bio->bi_bdev = ca->bdev; 627 bio->bi_bdev = ca->bdev;
620 bio->bi_rw = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH; 628 bio->bi_rw = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH|REQ_FUA;
621 bio->bi_size = sectors << 9; 629 bio->bi_size = sectors << 9;
622 630
623 bio->bi_end_io = journal_write_endio; 631 bio->bi_end_io = journal_write_endio;
@@ -712,7 +720,8 @@ void bch_journal(struct closure *cl)
712 spin_lock(&c->journal.lock); 720 spin_lock(&c->journal.lock);
713 721
714 if (journal_full(&c->journal)) { 722 if (journal_full(&c->journal)) {
715 /* XXX: tracepoint */ 723 trace_bcache_journal_full(c);
724
716 closure_wait(&c->journal.wait, cl); 725 closure_wait(&c->journal.wait, cl);
717 726
718 journal_reclaim(c); 727 journal_reclaim(c);
@@ -728,13 +737,15 @@ void bch_journal(struct closure *cl)
728 737
729 if (b * c->sb.block_size > PAGE_SECTORS << JSET_BITS || 738 if (b * c->sb.block_size > PAGE_SECTORS << JSET_BITS ||
730 b > c->journal.blocks_free) { 739 b > c->journal.blocks_free) {
731 /* XXX: If we were inserting so many keys that they won't fit in 740 trace_bcache_journal_entry_full(c);
741
742 /*
743 * XXX: If we were inserting so many keys that they won't fit in
732 * an _empty_ journal write, we'll deadlock. For now, handle 744 * an _empty_ journal write, we'll deadlock. For now, handle
733 * this in bch_keylist_realloc() - but something to think about. 745 * this in bch_keylist_realloc() - but something to think about.
734 */ 746 */
735 BUG_ON(!w->data->keys); 747 BUG_ON(!w->data->keys);
736 748
737 /* XXX: tracepoint */
738 BUG_ON(!closure_wait(&w->wait, cl)); 749 BUG_ON(!closure_wait(&w->wait, cl));
739 750
740 closure_flush(&c->journal.io); 751 closure_flush(&c->journal.io);
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
index 8589512c972e..1a3b4f4786c3 100644
--- a/drivers/md/bcache/movinggc.c
+++ b/drivers/md/bcache/movinggc.c
@@ -9,6 +9,8 @@
9#include "debug.h" 9#include "debug.h"
10#include "request.h" 10#include "request.h"
11 11
12#include <trace/events/bcache.h>
13
12struct moving_io { 14struct moving_io {
13 struct keybuf_key *w; 15 struct keybuf_key *w;
14 struct search s; 16 struct search s;
@@ -44,14 +46,14 @@ static void write_moving_finish(struct closure *cl)
44{ 46{
45 struct moving_io *io = container_of(cl, struct moving_io, s.cl); 47 struct moving_io *io = container_of(cl, struct moving_io, s.cl);
46 struct bio *bio = &io->bio.bio; 48 struct bio *bio = &io->bio.bio;
47 struct bio_vec *bv = bio_iovec_idx(bio, bio->bi_vcnt); 49 struct bio_vec *bv;
50 int i;
48 51
49 while (bv-- != bio->bi_io_vec) 52 bio_for_each_segment_all(bv, bio, i)
50 __free_page(bv->bv_page); 53 __free_page(bv->bv_page);
51 54
52 pr_debug("%s %s", io->s.op.insert_collision 55 if (io->s.op.insert_collision)
53 ? "collision moving" : "moved", 56 trace_bcache_gc_copy_collision(&io->w->key);
54 pkey(&io->w->key));
55 57
56 bch_keybuf_del(&io->s.op.c->moving_gc_keys, io->w); 58 bch_keybuf_del(&io->s.op.c->moving_gc_keys, io->w);
57 59
@@ -94,8 +96,6 @@ static void write_moving(struct closure *cl)
94 struct moving_io *io = container_of(s, struct moving_io, s); 96 struct moving_io *io = container_of(s, struct moving_io, s);
95 97
96 if (!s->error) { 98 if (!s->error) {
97 trace_bcache_write_moving(&io->bio.bio);
98
99 moving_init(io); 99 moving_init(io);
100 100
101 io->bio.bio.bi_sector = KEY_START(&io->w->key); 101 io->bio.bio.bi_sector = KEY_START(&io->w->key);
@@ -122,7 +122,6 @@ static void read_moving_submit(struct closure *cl)
122 struct moving_io *io = container_of(s, struct moving_io, s); 122 struct moving_io *io = container_of(s, struct moving_io, s);
123 struct bio *bio = &io->bio.bio; 123 struct bio *bio = &io->bio.bio;
124 124
125 trace_bcache_read_moving(bio);
126 bch_submit_bbio(bio, s->op.c, &io->w->key, 0); 125 bch_submit_bbio(bio, s->op.c, &io->w->key, 0);
127 126
128 continue_at(cl, write_moving, bch_gc_wq); 127 continue_at(cl, write_moving, bch_gc_wq);
@@ -138,7 +137,8 @@ static void read_moving(struct closure *cl)
138 /* XXX: if we error, background writeback could stall indefinitely */ 137 /* XXX: if we error, background writeback could stall indefinitely */
139 138
140 while (!test_bit(CACHE_SET_STOPPING, &c->flags)) { 139 while (!test_bit(CACHE_SET_STOPPING, &c->flags)) {
141 w = bch_keybuf_next_rescan(c, &c->moving_gc_keys, &MAX_KEY); 140 w = bch_keybuf_next_rescan(c, &c->moving_gc_keys,
141 &MAX_KEY, moving_pred);
142 if (!w) 142 if (!w)
143 break; 143 break;
144 144
@@ -159,10 +159,10 @@ static void read_moving(struct closure *cl)
159 bio->bi_rw = READ; 159 bio->bi_rw = READ;
160 bio->bi_end_io = read_moving_endio; 160 bio->bi_end_io = read_moving_endio;
161 161
162 if (bch_bio_alloc_pages(bio, GFP_KERNEL)) 162 if (bio_alloc_pages(bio, GFP_KERNEL))
163 goto err; 163 goto err;
164 164
165 pr_debug("%s", pkey(&w->key)); 165 trace_bcache_gc_copy(&w->key);
166 166
167 closure_call(&io->s.cl, read_moving_submit, NULL, &c->gc.cl); 167 closure_call(&io->s.cl, read_moving_submit, NULL, &c->gc.cl);
168 168
@@ -250,5 +250,5 @@ void bch_moving_gc(struct closure *cl)
250 250
251void bch_moving_init_cache_set(struct cache_set *c) 251void bch_moving_init_cache_set(struct cache_set *c)
252{ 252{
253 bch_keybuf_init(&c->moving_gc_keys, moving_pred); 253 bch_keybuf_init(&c->moving_gc_keys);
254} 254}
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index e5ff12e52d5b..786a1a4f74d8 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -10,6 +10,7 @@
10#include "btree.h" 10#include "btree.h"
11#include "debug.h" 11#include "debug.h"
12#include "request.h" 12#include "request.h"
13#include "writeback.h"
13 14
14#include <linux/cgroup.h> 15#include <linux/cgroup.h>
15#include <linux/module.h> 16#include <linux/module.h>
@@ -21,8 +22,6 @@
21 22
22#define CUTOFF_CACHE_ADD 95 23#define CUTOFF_CACHE_ADD 95
23#define CUTOFF_CACHE_READA 90 24#define CUTOFF_CACHE_READA 90
24#define CUTOFF_WRITEBACK 50
25#define CUTOFF_WRITEBACK_SYNC 75
26 25
27struct kmem_cache *bch_search_cache; 26struct kmem_cache *bch_search_cache;
28 27
@@ -489,6 +488,12 @@ static void bch_insert_data_loop(struct closure *cl)
489 bch_queue_gc(op->c); 488 bch_queue_gc(op->c);
490 } 489 }
491 490
491 /*
492 * Journal writes are marked REQ_FLUSH; if the original write was a
493 * flush, it'll wait on the journal write.
494 */
495 bio->bi_rw &= ~(REQ_FLUSH|REQ_FUA);
496
492 do { 497 do {
493 unsigned i; 498 unsigned i;
494 struct bkey *k; 499 struct bkey *k;
@@ -510,10 +515,6 @@ static void bch_insert_data_loop(struct closure *cl)
510 goto err; 515 goto err;
511 516
512 n = bch_bio_split(bio, KEY_SIZE(k), GFP_NOIO, split); 517 n = bch_bio_split(bio, KEY_SIZE(k), GFP_NOIO, split);
513 if (!n) {
514 __bkey_put(op->c, k);
515 continue_at(cl, bch_insert_data_loop, bcache_wq);
516 }
517 518
518 n->bi_end_io = bch_insert_data_endio; 519 n->bi_end_io = bch_insert_data_endio;
519 n->bi_private = cl; 520 n->bi_private = cl;
@@ -530,10 +531,9 @@ static void bch_insert_data_loop(struct closure *cl)
530 if (KEY_CSUM(k)) 531 if (KEY_CSUM(k))
531 bio_csum(n, k); 532 bio_csum(n, k);
532 533
533 pr_debug("%s", pkey(k)); 534 trace_bcache_cache_insert(k);
534 bch_keylist_push(&op->keys); 535 bch_keylist_push(&op->keys);
535 536
536 trace_bcache_cache_insert(n, n->bi_sector, n->bi_bdev);
537 n->bi_rw |= REQ_WRITE; 537 n->bi_rw |= REQ_WRITE;
538 bch_submit_bbio(n, op->c, k, 0); 538 bch_submit_bbio(n, op->c, k, 0);
539 } while (n != bio); 539 } while (n != bio);
@@ -716,7 +716,7 @@ static struct search *search_alloc(struct bio *bio, struct bcache_device *d)
716 s->task = current; 716 s->task = current;
717 s->orig_bio = bio; 717 s->orig_bio = bio;
718 s->write = (bio->bi_rw & REQ_WRITE) != 0; 718 s->write = (bio->bi_rw & REQ_WRITE) != 0;
719 s->op.flush_journal = (bio->bi_rw & REQ_FLUSH) != 0; 719 s->op.flush_journal = (bio->bi_rw & (REQ_FLUSH|REQ_FUA)) != 0;
720 s->op.skip = (bio->bi_rw & REQ_DISCARD) != 0; 720 s->op.skip = (bio->bi_rw & REQ_DISCARD) != 0;
721 s->recoverable = 1; 721 s->recoverable = 1;
722 s->start_time = jiffies; 722 s->start_time = jiffies;
@@ -784,11 +784,8 @@ static void request_read_error(struct closure *cl)
784 int i; 784 int i;
785 785
786 if (s->recoverable) { 786 if (s->recoverable) {
787 /* The cache read failed, but we can retry from the backing 787 /* Retry from the backing device: */
788 * device. 788 trace_bcache_read_retry(s->orig_bio);
789 */
790 pr_debug("recovering at sector %llu",
791 (uint64_t) s->orig_bio->bi_sector);
792 789
793 s->error = 0; 790 s->error = 0;
794 bv = s->bio.bio.bi_io_vec; 791 bv = s->bio.bio.bi_io_vec;
@@ -806,7 +803,6 @@ static void request_read_error(struct closure *cl)
806 803
807 /* XXX: invalidate cache */ 804 /* XXX: invalidate cache */
808 805
809 trace_bcache_read_retry(&s->bio.bio);
810 closure_bio_submit(&s->bio.bio, &s->cl, s->d); 806 closure_bio_submit(&s->bio.bio, &s->cl, s->d);
811 } 807 }
812 808
@@ -827,53 +823,13 @@ static void request_read_done(struct closure *cl)
827 */ 823 */
828 824
829 if (s->op.cache_bio) { 825 if (s->op.cache_bio) {
830 struct bio_vec *src, *dst;
831 unsigned src_offset, dst_offset, bytes;
832 void *dst_ptr;
833
834 bio_reset(s->op.cache_bio); 826 bio_reset(s->op.cache_bio);
835 s->op.cache_bio->bi_sector = s->cache_miss->bi_sector; 827 s->op.cache_bio->bi_sector = s->cache_miss->bi_sector;
836 s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev; 828 s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev;
837 s->op.cache_bio->bi_size = s->cache_bio_sectors << 9; 829 s->op.cache_bio->bi_size = s->cache_bio_sectors << 9;
838 bch_bio_map(s->op.cache_bio, NULL); 830 bch_bio_map(s->op.cache_bio, NULL);
839 831
840 src = bio_iovec(s->op.cache_bio); 832 bio_copy_data(s->cache_miss, s->op.cache_bio);
841 dst = bio_iovec(s->cache_miss);
842 src_offset = src->bv_offset;
843 dst_offset = dst->bv_offset;
844 dst_ptr = kmap(dst->bv_page);
845
846 while (1) {
847 if (dst_offset == dst->bv_offset + dst->bv_len) {
848 kunmap(dst->bv_page);
849 dst++;
850 if (dst == bio_iovec_idx(s->cache_miss,
851 s->cache_miss->bi_vcnt))
852 break;
853
854 dst_offset = dst->bv_offset;
855 dst_ptr = kmap(dst->bv_page);
856 }
857
858 if (src_offset == src->bv_offset + src->bv_len) {
859 src++;
860 if (src == bio_iovec_idx(s->op.cache_bio,
861 s->op.cache_bio->bi_vcnt))
862 BUG();
863
864 src_offset = src->bv_offset;
865 }
866
867 bytes = min(dst->bv_offset + dst->bv_len - dst_offset,
868 src->bv_offset + src->bv_len - src_offset);
869
870 memcpy(dst_ptr + dst_offset,
871 page_address(src->bv_page) + src_offset,
872 bytes);
873
874 src_offset += bytes;
875 dst_offset += bytes;
876 }
877 833
878 bio_put(s->cache_miss); 834 bio_put(s->cache_miss);
879 s->cache_miss = NULL; 835 s->cache_miss = NULL;
@@ -899,6 +855,7 @@ static void request_read_done_bh(struct closure *cl)
899 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); 855 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
900 856
901 bch_mark_cache_accounting(s, !s->cache_miss, s->op.skip); 857 bch_mark_cache_accounting(s, !s->cache_miss, s->op.skip);
858 trace_bcache_read(s->orig_bio, !s->cache_miss, s->op.skip);
902 859
903 if (s->error) 860 if (s->error)
904 continue_at_nobarrier(cl, request_read_error, bcache_wq); 861 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,
917 struct bio *miss; 874 struct bio *miss;
918 875
919 miss = bch_bio_split(bio, sectors, GFP_NOIO, s->d->bio_split); 876 miss = bch_bio_split(bio, sectors, GFP_NOIO, s->d->bio_split);
920 if (!miss)
921 return -EAGAIN;
922
923 if (miss == bio) 877 if (miss == bio)
924 s->op.lookup_done = true; 878 s->op.lookup_done = true;
925 879
@@ -938,8 +892,9 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
938 reada = min(dc->readahead >> 9, 892 reada = min(dc->readahead >> 9,
939 sectors - bio_sectors(miss)); 893 sectors - bio_sectors(miss));
940 894
941 if (bio_end(miss) + reada > bdev_sectors(miss->bi_bdev)) 895 if (bio_end_sector(miss) + reada > bdev_sectors(miss->bi_bdev))
942 reada = bdev_sectors(miss->bi_bdev) - bio_end(miss); 896 reada = bdev_sectors(miss->bi_bdev) -
897 bio_end_sector(miss);
943 } 898 }
944 899
945 s->cache_bio_sectors = bio_sectors(miss) + reada; 900 s->cache_bio_sectors = bio_sectors(miss) + reada;
@@ -963,13 +918,12 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
963 goto out_put; 918 goto out_put;
964 919
965 bch_bio_map(s->op.cache_bio, NULL); 920 bch_bio_map(s->op.cache_bio, NULL);
966 if (bch_bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO)) 921 if (bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
967 goto out_put; 922 goto out_put;
968 923
969 s->cache_miss = miss; 924 s->cache_miss = miss;
970 bio_get(s->op.cache_bio); 925 bio_get(s->op.cache_bio);
971 926
972 trace_bcache_cache_miss(s->orig_bio);
973 closure_bio_submit(s->op.cache_bio, &s->cl, s->d); 927 closure_bio_submit(s->op.cache_bio, &s->cl, s->d);
974 928
975 return ret; 929 return ret;
@@ -1002,24 +956,13 @@ static void cached_dev_write_complete(struct closure *cl)
1002 cached_dev_bio_complete(cl); 956 cached_dev_bio_complete(cl);
1003} 957}
1004 958
1005static bool should_writeback(struct cached_dev *dc, struct bio *bio)
1006{
1007 unsigned threshold = (bio->bi_rw & REQ_SYNC)
1008 ? CUTOFF_WRITEBACK_SYNC
1009 : CUTOFF_WRITEBACK;
1010
1011 return !atomic_read(&dc->disk.detaching) &&
1012 cache_mode(dc, bio) == CACHE_MODE_WRITEBACK &&
1013 dc->disk.c->gc_stats.in_use < threshold;
1014}
1015
1016static void request_write(struct cached_dev *dc, struct search *s) 959static void request_write(struct cached_dev *dc, struct search *s)
1017{ 960{
1018 struct closure *cl = &s->cl; 961 struct closure *cl = &s->cl;
1019 struct bio *bio = &s->bio.bio; 962 struct bio *bio = &s->bio.bio;
1020 struct bkey start, end; 963 struct bkey start, end;
1021 start = KEY(dc->disk.id, bio->bi_sector, 0); 964 start = KEY(dc->disk.id, bio->bi_sector, 0);
1022 end = KEY(dc->disk.id, bio_end(bio), 0); 965 end = KEY(dc->disk.id, bio_end_sector(bio), 0);
1023 966
1024 bch_keybuf_check_overlapping(&s->op.c->moving_gc_keys, &start, &end); 967 bch_keybuf_check_overlapping(&s->op.c->moving_gc_keys, &start, &end);
1025 968
@@ -1034,22 +977,37 @@ static void request_write(struct cached_dev *dc, struct search *s)
1034 if (bio->bi_rw & REQ_DISCARD) 977 if (bio->bi_rw & REQ_DISCARD)
1035 goto skip; 978 goto skip;
1036 979
980 if (should_writeback(dc, s->orig_bio,
981 cache_mode(dc, bio),
982 s->op.skip)) {
983 s->op.skip = false;
984 s->writeback = true;
985 }
986
1037 if (s->op.skip) 987 if (s->op.skip)
1038 goto skip; 988 goto skip;
1039 989
1040 if (should_writeback(dc, s->orig_bio)) 990 trace_bcache_write(s->orig_bio, s->writeback, s->op.skip);
1041 s->writeback = true;
1042 991
1043 if (!s->writeback) { 992 if (!s->writeback) {
1044 s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO, 993 s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO,
1045 dc->disk.bio_split); 994 dc->disk.bio_split);
1046 995
1047 trace_bcache_writethrough(s->orig_bio);
1048 closure_bio_submit(bio, cl, s->d); 996 closure_bio_submit(bio, cl, s->d);
1049 } else { 997 } else {
1050 s->op.cache_bio = bio; 998 bch_writeback_add(dc);
1051 trace_bcache_writeback(s->orig_bio); 999
1052 bch_writeback_add(dc, bio_sectors(bio)); 1000 if (s->op.flush_journal) {
1001 /* Also need to send a flush to the backing device */
1002 s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO,
1003 dc->disk.bio_split);
1004
1005 bio->bi_size = 0;
1006 bio->bi_vcnt = 0;
1007 closure_bio_submit(bio, cl, s->d);
1008 } else {
1009 s->op.cache_bio = bio;
1010 }
1053 } 1011 }
1054out: 1012out:
1055 closure_call(&s->op.cl, bch_insert_data, NULL, cl); 1013 closure_call(&s->op.cl, bch_insert_data, NULL, cl);
@@ -1058,7 +1016,6 @@ skip:
1058 s->op.skip = true; 1016 s->op.skip = true;
1059 s->op.cache_bio = s->orig_bio; 1017 s->op.cache_bio = s->orig_bio;
1060 bio_get(s->op.cache_bio); 1018 bio_get(s->op.cache_bio);
1061 trace_bcache_write_skip(s->orig_bio);
1062 1019
1063 if ((bio->bi_rw & REQ_DISCARD) && 1020 if ((bio->bi_rw & REQ_DISCARD) &&
1064 !blk_queue_discard(bdev_get_queue(dc->bdev))) 1021 !blk_queue_discard(bdev_get_queue(dc->bdev)))
@@ -1088,9 +1045,10 @@ static void request_nodata(struct cached_dev *dc, struct search *s)
1088 1045
1089/* Cached devices - read & write stuff */ 1046/* Cached devices - read & write stuff */
1090 1047
1091int bch_get_congested(struct cache_set *c) 1048unsigned bch_get_congested(struct cache_set *c)
1092{ 1049{
1093 int i; 1050 int i;
1051 long rand;
1094 1052
1095 if (!c->congested_read_threshold_us && 1053 if (!c->congested_read_threshold_us &&
1096 !c->congested_write_threshold_us) 1054 !c->congested_write_threshold_us)
@@ -1106,7 +1064,13 @@ int bch_get_congested(struct cache_set *c)
1106 1064
1107 i += CONGESTED_MAX; 1065 i += CONGESTED_MAX;
1108 1066
1109 return i <= 0 ? 1 : fract_exp_two(i, 6); 1067 if (i > 0)
1068 i = fract_exp_two(i, 6);
1069
1070 rand = get_random_int();
1071 i -= bitmap_weight(&rand, BITS_PER_LONG);
1072
1073 return i > 0 ? i : 1;
1110} 1074}
1111 1075
1112static void add_sequential(struct task_struct *t) 1076static void add_sequential(struct task_struct *t)
@@ -1126,10 +1090,8 @@ static void check_should_skip(struct cached_dev *dc, struct search *s)
1126{ 1090{
1127 struct cache_set *c = s->op.c; 1091 struct cache_set *c = s->op.c;
1128 struct bio *bio = &s->bio.bio; 1092 struct bio *bio = &s->bio.bio;
1129
1130 long rand;
1131 int cutoff = bch_get_congested(c);
1132 unsigned mode = cache_mode(dc, bio); 1093 unsigned mode = cache_mode(dc, bio);
1094 unsigned sectors, congested = bch_get_congested(c);
1133 1095
1134 if (atomic_read(&dc->disk.detaching) || 1096 if (atomic_read(&dc->disk.detaching) ||
1135 c->gc_stats.in_use > CUTOFF_CACHE_ADD || 1097 c->gc_stats.in_use > CUTOFF_CACHE_ADD ||
@@ -1147,17 +1109,14 @@ static void check_should_skip(struct cached_dev *dc, struct search *s)
1147 goto skip; 1109 goto skip;
1148 } 1110 }
1149 1111
1150 if (!cutoff) { 1112 if (!congested && !dc->sequential_cutoff)
1151 cutoff = dc->sequential_cutoff >> 9; 1113 goto rescale;
1152 1114
1153 if (!cutoff) 1115 if (!congested &&
1154 goto rescale; 1116 mode == CACHE_MODE_WRITEBACK &&
1155 1117 (bio->bi_rw & REQ_WRITE) &&
1156 if (mode == CACHE_MODE_WRITEBACK && 1118 (bio->bi_rw & REQ_SYNC))
1157 (bio->bi_rw & REQ_WRITE) && 1119 goto rescale;
1158 (bio->bi_rw & REQ_SYNC))
1159 goto rescale;
1160 }
1161 1120
1162 if (dc->sequential_merge) { 1121 if (dc->sequential_merge) {
1163 struct io *i; 1122 struct io *i;
@@ -1177,7 +1136,7 @@ found:
1177 if (i->sequential + bio->bi_size > i->sequential) 1136 if (i->sequential + bio->bi_size > i->sequential)
1178 i->sequential += bio->bi_size; 1137 i->sequential += bio->bi_size;
1179 1138
1180 i->last = bio_end(bio); 1139 i->last = bio_end_sector(bio);
1181 i->jiffies = jiffies + msecs_to_jiffies(5000); 1140 i->jiffies = jiffies + msecs_to_jiffies(5000);
1182 s->task->sequential_io = i->sequential; 1141 s->task->sequential_io = i->sequential;
1183 1142
@@ -1192,12 +1151,19 @@ found:
1192 add_sequential(s->task); 1151 add_sequential(s->task);
1193 } 1152 }
1194 1153
1195 rand = get_random_int(); 1154 sectors = max(s->task->sequential_io,
1196 cutoff -= bitmap_weight(&rand, BITS_PER_LONG); 1155 s->task->sequential_io_avg) >> 9;
1197 1156
1198 if (cutoff <= (int) (max(s->task->sequential_io, 1157 if (dc->sequential_cutoff &&
1199 s->task->sequential_io_avg) >> 9)) 1158 sectors >= dc->sequential_cutoff >> 9) {
1159 trace_bcache_bypass_sequential(s->orig_bio);
1200 goto skip; 1160 goto skip;
1161 }
1162
1163 if (congested && sectors >= congested) {
1164 trace_bcache_bypass_congested(s->orig_bio);
1165 goto skip;
1166 }
1201 1167
1202rescale: 1168rescale:
1203 bch_rescale_priorities(c, bio_sectors(bio)); 1169 bch_rescale_priorities(c, bio_sectors(bio));
@@ -1288,30 +1254,25 @@ void bch_cached_dev_request_init(struct cached_dev *dc)
1288static int flash_dev_cache_miss(struct btree *b, struct search *s, 1254static int flash_dev_cache_miss(struct btree *b, struct search *s,
1289 struct bio *bio, unsigned sectors) 1255 struct bio *bio, unsigned sectors)
1290{ 1256{
1257 struct bio_vec *bv;
1258 int i;
1259
1291 /* Zero fill bio */ 1260 /* Zero fill bio */
1292 1261
1293 while (bio->bi_idx != bio->bi_vcnt) { 1262 bio_for_each_segment(bv, bio, i) {
1294 struct bio_vec *bv = bio_iovec(bio);
1295 unsigned j = min(bv->bv_len >> 9, sectors); 1263 unsigned j = min(bv->bv_len >> 9, sectors);
1296 1264
1297 void *p = kmap(bv->bv_page); 1265 void *p = kmap(bv->bv_page);
1298 memset(p + bv->bv_offset, 0, j << 9); 1266 memset(p + bv->bv_offset, 0, j << 9);
1299 kunmap(bv->bv_page); 1267 kunmap(bv->bv_page);
1300 1268
1301 bv->bv_len -= j << 9; 1269 sectors -= j;
1302 bv->bv_offset += j << 9;
1303
1304 if (bv->bv_len)
1305 return 0;
1306
1307 bio->bi_sector += j;
1308 bio->bi_size -= j << 9;
1309
1310 bio->bi_idx++;
1311 sectors -= j;
1312 } 1270 }
1313 1271
1314 s->op.lookup_done = true; 1272 bio_advance(bio, min(sectors << 9, bio->bi_size));
1273
1274 if (!bio->bi_size)
1275 s->op.lookup_done = true;
1315 1276
1316 return 0; 1277 return 0;
1317} 1278}
@@ -1338,8 +1299,8 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio)
1338 closure_call(&s->op.cl, btree_read_async, NULL, cl); 1299 closure_call(&s->op.cl, btree_read_async, NULL, cl);
1339 } else if (bio_has_data(bio) || s->op.skip) { 1300 } else if (bio_has_data(bio) || s->op.skip) {
1340 bch_keybuf_check_overlapping(&s->op.c->moving_gc_keys, 1301 bch_keybuf_check_overlapping(&s->op.c->moving_gc_keys,
1341 &KEY(d->id, bio->bi_sector, 0), 1302 &KEY(d->id, bio->bi_sector, 0),
1342 &KEY(d->id, bio_end(bio), 0)); 1303 &KEY(d->id, bio_end_sector(bio), 0));
1343 1304
1344 s->writeback = true; 1305 s->writeback = true;
1345 s->op.cache_bio = bio; 1306 s->op.cache_bio = bio;
diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h
index 254d9ab5707c..57dc4784f4f4 100644
--- a/drivers/md/bcache/request.h
+++ b/drivers/md/bcache/request.h
@@ -30,7 +30,7 @@ struct search {
30}; 30};
31 31
32void bch_cache_read_endio(struct bio *, int); 32void bch_cache_read_endio(struct bio *, int);
33int bch_get_congested(struct cache_set *); 33unsigned bch_get_congested(struct cache_set *);
34void bch_insert_data(struct closure *cl); 34void bch_insert_data(struct closure *cl);
35void bch_btree_insert_async(struct closure *); 35void bch_btree_insert_async(struct closure *);
36void bch_cache_read_endio(struct bio *, int); 36void bch_cache_read_endio(struct bio *, int);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f88e2b653a3f..547c4c57b052 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -10,10 +10,13 @@
10#include "btree.h" 10#include "btree.h"
11#include "debug.h" 11#include "debug.h"
12#include "request.h" 12#include "request.h"
13#include "writeback.h"
13 14
15#include <linux/blkdev.h>
14#include <linux/buffer_head.h> 16#include <linux/buffer_head.h>
15#include <linux/debugfs.h> 17#include <linux/debugfs.h>
16#include <linux/genhd.h> 18#include <linux/genhd.h>
19#include <linux/kthread.h>
17#include <linux/module.h> 20#include <linux/module.h>
18#include <linux/random.h> 21#include <linux/random.h>
19#include <linux/reboot.h> 22#include <linux/reboot.h>
@@ -342,6 +345,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
342 struct closure *cl = &c->uuid_write.cl; 345 struct closure *cl = &c->uuid_write.cl;
343 struct uuid_entry *u; 346 struct uuid_entry *u;
344 unsigned i; 347 unsigned i;
348 char buf[80];
345 349
346 BUG_ON(!parent); 350 BUG_ON(!parent);
347 closure_lock(&c->uuid_write, parent); 351 closure_lock(&c->uuid_write, parent);
@@ -362,8 +366,8 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
362 break; 366 break;
363 } 367 }
364 368
365 pr_debug("%s UUIDs at %s", rw & REQ_WRITE ? "wrote" : "read", 369 bch_bkey_to_text(buf, sizeof(buf), k);
366 pkey(&c->uuid_bucket)); 370 pr_debug("%s UUIDs at %s", rw & REQ_WRITE ? "wrote" : "read", buf);
367 371
368 for (u = c->uuids; u < c->uuids + c->nr_uuids; u++) 372 for (u = c->uuids; u < c->uuids + c->nr_uuids; u++)
369 if (!bch_is_zero(u->uuid, 16)) 373 if (!bch_is_zero(u->uuid, 16))
@@ -543,7 +547,6 @@ void bch_prio_write(struct cache *ca)
543 547
544 pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free), 548 pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free),
545 fifo_used(&ca->free_inc), fifo_used(&ca->unused)); 549 fifo_used(&ca->free_inc), fifo_used(&ca->unused));
546 blktrace_msg(ca, "Starting priorities: " buckets_free(ca));
547 550
548 for (i = prio_buckets(ca) - 1; i >= 0; --i) { 551 for (i = prio_buckets(ca) - 1; i >= 0; --i) {
549 long bucket; 552 long bucket;
@@ -704,7 +707,8 @@ static void bcache_device_detach(struct bcache_device *d)
704 atomic_set(&d->detaching, 0); 707 atomic_set(&d->detaching, 0);
705 } 708 }
706 709
707 bcache_device_unlink(d); 710 if (!d->flush_done)
711 bcache_device_unlink(d);
708 712
709 d->c->devices[d->id] = NULL; 713 d->c->devices[d->id] = NULL;
710 closure_put(&d->c->caching); 714 closure_put(&d->c->caching);
@@ -743,13 +747,35 @@ static void bcache_device_free(struct bcache_device *d)
743 mempool_destroy(d->unaligned_bvec); 747 mempool_destroy(d->unaligned_bvec);
744 if (d->bio_split) 748 if (d->bio_split)
745 bioset_free(d->bio_split); 749 bioset_free(d->bio_split);
750 if (is_vmalloc_addr(d->stripe_sectors_dirty))
751 vfree(d->stripe_sectors_dirty);
752 else
753 kfree(d->stripe_sectors_dirty);
746 754
747 closure_debug_destroy(&d->cl); 755 closure_debug_destroy(&d->cl);
748} 756}
749 757
750static int bcache_device_init(struct bcache_device *d, unsigned block_size) 758static int bcache_device_init(struct bcache_device *d, unsigned block_size,
759 sector_t sectors)
751{ 760{
752 struct request_queue *q; 761 struct request_queue *q;
762 size_t n;
763
764 if (!d->stripe_size_bits)
765 d->stripe_size_bits = 31;
766
767 d->nr_stripes = round_up(sectors, 1 << d->stripe_size_bits) >>
768 d->stripe_size_bits;
769
770 if (!d->nr_stripes || d->nr_stripes > SIZE_MAX / sizeof(atomic_t))
771 return -ENOMEM;
772
773 n = d->nr_stripes * sizeof(atomic_t);
774 d->stripe_sectors_dirty = n < PAGE_SIZE << 6
775 ? kzalloc(n, GFP_KERNEL)
776 : vzalloc(n);
777 if (!d->stripe_sectors_dirty)
778 return -ENOMEM;
753 779
754 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || 780 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
755 !(d->unaligned_bvec = mempool_create_kmalloc_pool(1, 781 !(d->unaligned_bvec = mempool_create_kmalloc_pool(1,
@@ -759,6 +785,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size)
759 !(q = blk_alloc_queue(GFP_KERNEL))) 785 !(q = blk_alloc_queue(GFP_KERNEL)))
760 return -ENOMEM; 786 return -ENOMEM;
761 787
788 set_capacity(d->disk, sectors);
762 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", bcache_minor); 789 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", bcache_minor);
763 790
764 d->disk->major = bcache_major; 791 d->disk->major = bcache_major;
@@ -781,6 +808,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size)
781 set_bit(QUEUE_FLAG_NONROT, &d->disk->queue->queue_flags); 808 set_bit(QUEUE_FLAG_NONROT, &d->disk->queue->queue_flags);
782 set_bit(QUEUE_FLAG_DISCARD, &d->disk->queue->queue_flags); 809 set_bit(QUEUE_FLAG_DISCARD, &d->disk->queue->queue_flags);
783 810
811 blk_queue_flush(q, REQ_FLUSH|REQ_FUA);
812
784 return 0; 813 return 0;
785} 814}
786 815
@@ -800,6 +829,17 @@ static void calc_cached_dev_sectors(struct cache_set *c)
800void bch_cached_dev_run(struct cached_dev *dc) 829void bch_cached_dev_run(struct cached_dev *dc)
801{ 830{
802 struct bcache_device *d = &dc->disk; 831 struct bcache_device *d = &dc->disk;
832 char buf[SB_LABEL_SIZE + 1];
833 char *env[] = {
834 "DRIVER=bcache",
835 kasprintf(GFP_KERNEL, "CACHED_UUID=%pU", dc->sb.uuid),
836 NULL,
837 NULL,
838 };
839
840 memcpy(buf, dc->sb.label, SB_LABEL_SIZE);
841 buf[SB_LABEL_SIZE] = '\0';
842 env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf);
803 843
804 if (atomic_xchg(&dc->running, 1)) 844 if (atomic_xchg(&dc->running, 1))
805 return; 845 return;
@@ -816,10 +856,12 @@ void bch_cached_dev_run(struct cached_dev *dc)
816 856
817 add_disk(d->disk); 857 add_disk(d->disk);
818 bd_link_disk_holder(dc->bdev, dc->disk.disk); 858 bd_link_disk_holder(dc->bdev, dc->disk.disk);
819#if 0 859 /* won't show up in the uevent file, use udevadm monitor -e instead
820 char *env[] = { "SYMLINK=label" , NULL }; 860 * only class / kset properties are persistent */
821 kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env); 861 kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env);
822#endif 862 kfree(env[1]);
863 kfree(env[2]);
864
823 if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") || 865 if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
824 sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache")) 866 sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache"))
825 pr_debug("error creating sysfs link"); 867 pr_debug("error creating sysfs link");
@@ -960,6 +1002,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
960 atomic_set(&dc->count, 1); 1002 atomic_set(&dc->count, 1);
961 1003
962 if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) { 1004 if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
1005 bch_sectors_dirty_init(dc);
963 atomic_set(&dc->has_dirty, 1); 1006 atomic_set(&dc->has_dirty, 1);
964 atomic_inc(&dc->count); 1007 atomic_inc(&dc->count);
965 bch_writeback_queue(dc); 1008 bch_writeback_queue(dc);
@@ -1014,6 +1057,14 @@ static void cached_dev_flush(struct closure *cl)
1014 struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl); 1057 struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl);
1015 struct bcache_device *d = &dc->disk; 1058 struct bcache_device *d = &dc->disk;
1016 1059
1060 mutex_lock(&bch_register_lock);
1061 d->flush_done = 1;
1062
1063 if (d->c)
1064 bcache_device_unlink(d);
1065
1066 mutex_unlock(&bch_register_lock);
1067
1017 bch_cache_accounting_destroy(&dc->accounting); 1068 bch_cache_accounting_destroy(&dc->accounting);
1018 kobject_del(&d->kobj); 1069 kobject_del(&d->kobj);
1019 1070
@@ -1045,7 +1096,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
1045 hlist_add_head(&io->hash, dc->io_hash + RECENT_IO); 1096 hlist_add_head(&io->hash, dc->io_hash + RECENT_IO);
1046 } 1097 }
1047 1098
1048 ret = bcache_device_init(&dc->disk, block_size); 1099 ret = bcache_device_init(&dc->disk, block_size,
1100 dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
1049 if (ret) 1101 if (ret)
1050 return ret; 1102 return ret;
1051 1103
@@ -1144,11 +1196,10 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
1144 1196
1145 kobject_init(&d->kobj, &bch_flash_dev_ktype); 1197 kobject_init(&d->kobj, &bch_flash_dev_ktype);
1146 1198
1147 if (bcache_device_init(d, block_bytes(c))) 1199 if (bcache_device_init(d, block_bytes(c), u->sectors))
1148 goto err; 1200 goto err;
1149 1201
1150 bcache_device_attach(d, c, u - c->uuids); 1202 bcache_device_attach(d, c, u - c->uuids);
1151 set_capacity(d->disk, u->sectors);
1152 bch_flash_dev_request_init(d); 1203 bch_flash_dev_request_init(d);
1153 add_disk(d->disk); 1204 add_disk(d->disk);
1154 1205
@@ -1255,9 +1306,10 @@ static void cache_set_free(struct closure *cl)
1255 free_pages((unsigned long) c->uuids, ilog2(bucket_pages(c))); 1306 free_pages((unsigned long) c->uuids, ilog2(bucket_pages(c)));
1256 free_pages((unsigned long) c->sort, ilog2(bucket_pages(c))); 1307 free_pages((unsigned long) c->sort, ilog2(bucket_pages(c)));
1257 1308
1258 kfree(c->fill_iter);
1259 if (c->bio_split) 1309 if (c->bio_split)
1260 bioset_free(c->bio_split); 1310 bioset_free(c->bio_split);
1311 if (c->fill_iter)
1312 mempool_destroy(c->fill_iter);
1261 if (c->bio_meta) 1313 if (c->bio_meta)
1262 mempool_destroy(c->bio_meta); 1314 mempool_destroy(c->bio_meta);
1263 if (c->search) 1315 if (c->search)
@@ -1278,11 +1330,9 @@ static void cache_set_free(struct closure *cl)
1278static void cache_set_flush(struct closure *cl) 1330static void cache_set_flush(struct closure *cl)
1279{ 1331{
1280 struct cache_set *c = container_of(cl, struct cache_set, caching); 1332 struct cache_set *c = container_of(cl, struct cache_set, caching);
1333 struct cache *ca;
1281 struct btree *b; 1334 struct btree *b;
1282 1335 unsigned i;
1283 /* Shut down allocator threads */
1284 set_bit(CACHE_SET_STOPPING_2, &c->flags);
1285 wake_up(&c->alloc_wait);
1286 1336
1287 bch_cache_accounting_destroy(&c->accounting); 1337 bch_cache_accounting_destroy(&c->accounting);
1288 1338
@@ -1295,7 +1345,11 @@ static void cache_set_flush(struct closure *cl)
1295 /* Should skip this if we're unregistering because of an error */ 1345 /* Should skip this if we're unregistering because of an error */
1296 list_for_each_entry(b, &c->btree_cache, list) 1346 list_for_each_entry(b, &c->btree_cache, list)
1297 if (btree_node_dirty(b)) 1347 if (btree_node_dirty(b))
1298 bch_btree_write(b, true, NULL); 1348 bch_btree_node_write(b, NULL);
1349
1350 for_each_cache(ca, c, i)
1351 if (ca->alloc_thread)
1352 kthread_stop(ca->alloc_thread);
1299 1353
1300 closure_return(cl); 1354 closure_return(cl);
1301} 1355}
@@ -1303,18 +1357,22 @@ static void cache_set_flush(struct closure *cl)
1303static void __cache_set_unregister(struct closure *cl) 1357static void __cache_set_unregister(struct closure *cl)
1304{ 1358{
1305 struct cache_set *c = container_of(cl, struct cache_set, caching); 1359 struct cache_set *c = container_of(cl, struct cache_set, caching);
1306 struct cached_dev *dc, *t; 1360 struct cached_dev *dc;
1307 size_t i; 1361 size_t i;
1308 1362
1309 mutex_lock(&bch_register_lock); 1363 mutex_lock(&bch_register_lock);
1310 1364
1311 if (test_bit(CACHE_SET_UNREGISTERING, &c->flags))
1312 list_for_each_entry_safe(dc, t, &c->cached_devs, list)
1313 bch_cached_dev_detach(dc);
1314
1315 for (i = 0; i < c->nr_uuids; i++) 1365 for (i = 0; i < c->nr_uuids; i++)
1316 if (c->devices[i] && UUID_FLASH_ONLY(&c->uuids[i])) 1366 if (c->devices[i]) {
1317 bcache_device_stop(c->devices[i]); 1367 if (!UUID_FLASH_ONLY(&c->uuids[i]) &&
1368 test_bit(CACHE_SET_UNREGISTERING, &c->flags)) {
1369 dc = container_of(c->devices[i],
1370 struct cached_dev, disk);
1371 bch_cached_dev_detach(dc);
1372 } else {
1373 bcache_device_stop(c->devices[i]);
1374 }
1375 }
1318 1376
1319 mutex_unlock(&bch_register_lock); 1377 mutex_unlock(&bch_register_lock);
1320 1378
@@ -1373,9 +1431,9 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
1373 c->btree_pages = max_t(int, c->btree_pages / 4, 1431 c->btree_pages = max_t(int, c->btree_pages / 4,
1374 BTREE_MAX_PAGES); 1432 BTREE_MAX_PAGES);
1375 1433
1376 init_waitqueue_head(&c->alloc_wait); 1434 c->sort_crit_factor = int_sqrt(c->btree_pages);
1435
1377 mutex_init(&c->bucket_lock); 1436 mutex_init(&c->bucket_lock);
1378 mutex_init(&c->fill_lock);
1379 mutex_init(&c->sort_lock); 1437 mutex_init(&c->sort_lock);
1380 spin_lock_init(&c->sort_time_lock); 1438 spin_lock_init(&c->sort_time_lock);
1381 closure_init_unlocked(&c->sb_write); 1439 closure_init_unlocked(&c->sb_write);
@@ -1401,8 +1459,8 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
1401 !(c->bio_meta = mempool_create_kmalloc_pool(2, 1459 !(c->bio_meta = mempool_create_kmalloc_pool(2,
1402 sizeof(struct bbio) + sizeof(struct bio_vec) * 1460 sizeof(struct bbio) + sizeof(struct bio_vec) *
1403 bucket_pages(c))) || 1461 bucket_pages(c))) ||
1462 !(c->fill_iter = mempool_create_kmalloc_pool(1, iter_size)) ||
1404 !(c->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || 1463 !(c->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
1405 !(c->fill_iter = kmalloc(iter_size, GFP_KERNEL)) ||
1406 !(c->sort = alloc_bucket_pages(GFP_KERNEL, c)) || 1464 !(c->sort = alloc_bucket_pages(GFP_KERNEL, c)) ||
1407 !(c->uuids = alloc_bucket_pages(GFP_KERNEL, c)) || 1465 !(c->uuids = alloc_bucket_pages(GFP_KERNEL, c)) ||
1408 bch_journal_alloc(c) || 1466 bch_journal_alloc(c) ||
@@ -1410,8 +1468,6 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
1410 bch_open_buckets_alloc(c)) 1468 bch_open_buckets_alloc(c))
1411 goto err; 1469 goto err;
1412 1470
1413 c->fill_iter->size = sb->bucket_size / sb->block_size;
1414
1415 c->congested_read_threshold_us = 2000; 1471 c->congested_read_threshold_us = 2000;
1416 c->congested_write_threshold_us = 20000; 1472 c->congested_write_threshold_us = 20000;
1417 c->error_limit = 8 << IO_ERROR_SHIFT; 1473 c->error_limit = 8 << IO_ERROR_SHIFT;
@@ -1496,9 +1552,10 @@ static void run_cache_set(struct cache_set *c)
1496 */ 1552 */
1497 bch_journal_next(&c->journal); 1553 bch_journal_next(&c->journal);
1498 1554
1555 err = "error starting allocator thread";
1499 for_each_cache(ca, c, i) 1556 for_each_cache(ca, c, i)
1500 closure_call(&ca->alloc, bch_allocator_thread, 1557 if (bch_cache_allocator_start(ca))
1501 system_wq, &c->cl); 1558 goto err;
1502 1559
1503 /* 1560 /*
1504 * First place it's safe to allocate: btree_check() and 1561 * First place it's safe to allocate: btree_check() and
@@ -1531,17 +1588,16 @@ static void run_cache_set(struct cache_set *c)
1531 1588
1532 bch_btree_gc_finish(c); 1589 bch_btree_gc_finish(c);
1533 1590
1591 err = "error starting allocator thread";
1534 for_each_cache(ca, c, i) 1592 for_each_cache(ca, c, i)
1535 closure_call(&ca->alloc, bch_allocator_thread, 1593 if (bch_cache_allocator_start(ca))
1536 ca->alloc_workqueue, &c->cl); 1594 goto err;
1537 1595
1538 mutex_lock(&c->bucket_lock); 1596 mutex_lock(&c->bucket_lock);
1539 for_each_cache(ca, c, i) 1597 for_each_cache(ca, c, i)
1540 bch_prio_write(ca); 1598 bch_prio_write(ca);
1541 mutex_unlock(&c->bucket_lock); 1599 mutex_unlock(&c->bucket_lock);
1542 1600
1543 wake_up(&c->alloc_wait);
1544
1545 err = "cannot allocate new UUID bucket"; 1601 err = "cannot allocate new UUID bucket";
1546 if (__uuid_write(c)) 1602 if (__uuid_write(c))
1547 goto err_unlock_gc; 1603 goto err_unlock_gc;
@@ -1552,7 +1608,7 @@ static void run_cache_set(struct cache_set *c)
1552 goto err_unlock_gc; 1608 goto err_unlock_gc;
1553 1609
1554 bkey_copy_key(&c->root->key, &MAX_KEY); 1610 bkey_copy_key(&c->root->key, &MAX_KEY);
1555 bch_btree_write(c->root, true, &op); 1611 bch_btree_node_write(c->root, &op.cl);
1556 1612
1557 bch_btree_set_root(c->root); 1613 bch_btree_set_root(c->root);
1558 rw_unlock(true, c->root); 1614 rw_unlock(true, c->root);
@@ -1673,9 +1729,6 @@ void bch_cache_release(struct kobject *kobj)
1673 1729
1674 bio_split_pool_free(&ca->bio_split_hook); 1730 bio_split_pool_free(&ca->bio_split_hook);
1675 1731
1676 if (ca->alloc_workqueue)
1677 destroy_workqueue(ca->alloc_workqueue);
1678
1679 free_pages((unsigned long) ca->disk_buckets, ilog2(bucket_pages(ca))); 1732 free_pages((unsigned long) ca->disk_buckets, ilog2(bucket_pages(ca)));
1680 kfree(ca->prio_buckets); 1733 kfree(ca->prio_buckets);
1681 vfree(ca->buckets); 1734 vfree(ca->buckets);
@@ -1723,7 +1776,6 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca)
1723 !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) * 1776 !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) *
1724 2, GFP_KERNEL)) || 1777 2, GFP_KERNEL)) ||
1725 !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)) || 1778 !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)) ||
1726 !(ca->alloc_workqueue = alloc_workqueue("bch_allocator", 0, 1)) ||
1727 bio_split_pool_init(&ca->bio_split_hook)) 1779 bio_split_pool_init(&ca->bio_split_hook))
1728 return -ENOMEM; 1780 return -ENOMEM;
1729 1781
@@ -1786,6 +1838,36 @@ static ssize_t register_bcache(struct kobject *, struct kobj_attribute *,
1786kobj_attribute_write(register, register_bcache); 1838kobj_attribute_write(register, register_bcache);
1787kobj_attribute_write(register_quiet, register_bcache); 1839kobj_attribute_write(register_quiet, register_bcache);
1788 1840
1841static bool bch_is_open_backing(struct block_device *bdev) {
1842 struct cache_set *c, *tc;
1843 struct cached_dev *dc, *t;
1844
1845 list_for_each_entry_safe(c, tc, &bch_cache_sets, list)
1846 list_for_each_entry_safe(dc, t, &c->cached_devs, list)
1847 if (dc->bdev == bdev)
1848 return true;
1849 list_for_each_entry_safe(dc, t, &uncached_devices, list)
1850 if (dc->bdev == bdev)
1851 return true;
1852 return false;
1853}
1854
1855static bool bch_is_open_cache(struct block_device *bdev) {
1856 struct cache_set *c, *tc;
1857 struct cache *ca;
1858 unsigned i;
1859
1860 list_for_each_entry_safe(c, tc, &bch_cache_sets, list)
1861 for_each_cache(ca, c, i)
1862 if (ca->bdev == bdev)
1863 return true;
1864 return false;
1865}
1866
1867static bool bch_is_open(struct block_device *bdev) {
1868 return bch_is_open_cache(bdev) || bch_is_open_backing(bdev);
1869}
1870
1789static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, 1871static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
1790 const char *buffer, size_t size) 1872 const char *buffer, size_t size)
1791{ 1873{
@@ -1810,8 +1892,13 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
1810 FMODE_READ|FMODE_WRITE|FMODE_EXCL, 1892 FMODE_READ|FMODE_WRITE|FMODE_EXCL,
1811 sb); 1893 sb);
1812 if (IS_ERR(bdev)) { 1894 if (IS_ERR(bdev)) {
1813 if (bdev == ERR_PTR(-EBUSY)) 1895 if (bdev == ERR_PTR(-EBUSY)) {
1814 err = "device busy"; 1896 bdev = lookup_bdev(strim(path));
1897 if (!IS_ERR(bdev) && bch_is_open(bdev))
1898 err = "device already registered";
1899 else
1900 err = "device busy";
1901 }
1815 goto err; 1902 goto err;
1816 } 1903 }
1817 1904
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 4d9cca47e4c6..12a2c2846f99 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -9,7 +9,9 @@
9#include "sysfs.h" 9#include "sysfs.h"
10#include "btree.h" 10#include "btree.h"
11#include "request.h" 11#include "request.h"
12#include "writeback.h"
12 13
14#include <linux/blkdev.h>
13#include <linux/sort.h> 15#include <linux/sort.h>
14 16
15static const char * const cache_replacement_policies[] = { 17static const char * const cache_replacement_policies[] = {
@@ -79,6 +81,9 @@ rw_attribute(writeback_rate_p_term_inverse);
79rw_attribute(writeback_rate_d_smooth); 81rw_attribute(writeback_rate_d_smooth);
80read_attribute(writeback_rate_debug); 82read_attribute(writeback_rate_debug);
81 83
84read_attribute(stripe_size);
85read_attribute(partial_stripes_expensive);
86
82rw_attribute(synchronous); 87rw_attribute(synchronous);
83rw_attribute(journal_delay_ms); 88rw_attribute(journal_delay_ms);
84rw_attribute(discard); 89rw_attribute(discard);
@@ -127,7 +132,7 @@ SHOW(__bch_cached_dev)
127 char derivative[20]; 132 char derivative[20];
128 char target[20]; 133 char target[20];
129 bch_hprint(dirty, 134 bch_hprint(dirty,
130 atomic_long_read(&dc->disk.sectors_dirty) << 9); 135 bcache_dev_sectors_dirty(&dc->disk) << 9);
131 bch_hprint(derivative, dc->writeback_rate_derivative << 9); 136 bch_hprint(derivative, dc->writeback_rate_derivative << 9);
132 bch_hprint(target, dc->writeback_rate_target << 9); 137 bch_hprint(target, dc->writeback_rate_target << 9);
133 138
@@ -143,7 +148,10 @@ SHOW(__bch_cached_dev)
143 } 148 }
144 149
145 sysfs_hprint(dirty_data, 150 sysfs_hprint(dirty_data,
146 atomic_long_read(&dc->disk.sectors_dirty) << 9); 151 bcache_dev_sectors_dirty(&dc->disk) << 9);
152
153 sysfs_hprint(stripe_size, (1 << dc->disk.stripe_size_bits) << 9);
154 var_printf(partial_stripes_expensive, "%u");
147 155
148 var_printf(sequential_merge, "%i"); 156 var_printf(sequential_merge, "%i");
149 var_hprint(sequential_cutoff); 157 var_hprint(sequential_cutoff);
@@ -170,6 +178,7 @@ STORE(__cached_dev)
170 disk.kobj); 178 disk.kobj);
171 unsigned v = size; 179 unsigned v = size;
172 struct cache_set *c; 180 struct cache_set *c;
181 struct kobj_uevent_env *env;
173 182
174#define d_strtoul(var) sysfs_strtoul(var, dc->var) 183#define d_strtoul(var) sysfs_strtoul(var, dc->var)
175#define d_strtoi_h(var) sysfs_hatoi(var, dc->var) 184#define d_strtoi_h(var) sysfs_hatoi(var, dc->var)
@@ -214,6 +223,7 @@ STORE(__cached_dev)
214 } 223 }
215 224
216 if (attr == &sysfs_label) { 225 if (attr == &sysfs_label) {
226 /* note: endlines are preserved */
217 memcpy(dc->sb.label, buf, SB_LABEL_SIZE); 227 memcpy(dc->sb.label, buf, SB_LABEL_SIZE);
218 bch_write_bdev_super(dc, NULL); 228 bch_write_bdev_super(dc, NULL);
219 if (dc->disk.c) { 229 if (dc->disk.c) {
@@ -221,6 +231,15 @@ STORE(__cached_dev)
221 buf, SB_LABEL_SIZE); 231 buf, SB_LABEL_SIZE);
222 bch_uuid_write(dc->disk.c); 232 bch_uuid_write(dc->disk.c);
223 } 233 }
234 env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
235 if (!env)
236 return -ENOMEM;
237 add_uevent_var(env, "DRIVER=bcache");
238 add_uevent_var(env, "CACHED_UUID=%pU", dc->sb.uuid),
239 add_uevent_var(env, "CACHED_LABEL=%s", buf);
240 kobject_uevent_env(
241 &disk_to_dev(dc->disk.disk)->kobj, KOBJ_CHANGE, env->envp);
242 kfree(env);
224 } 243 }
225 244
226 if (attr == &sysfs_attach) { 245 if (attr == &sysfs_attach) {
@@ -284,6 +303,8 @@ static struct attribute *bch_cached_dev_files[] = {
284 &sysfs_writeback_rate_d_smooth, 303 &sysfs_writeback_rate_d_smooth,
285 &sysfs_writeback_rate_debug, 304 &sysfs_writeback_rate_debug,
286 &sysfs_dirty_data, 305 &sysfs_dirty_data,
306 &sysfs_stripe_size,
307 &sysfs_partial_stripes_expensive,
287 &sysfs_sequential_cutoff, 308 &sysfs_sequential_cutoff,
288 &sysfs_sequential_merge, 309 &sysfs_sequential_merge,
289 &sysfs_clear_stats, 310 &sysfs_clear_stats,
@@ -665,12 +686,10 @@ SHOW(__bch_cache)
665 int cmp(const void *l, const void *r) 686 int cmp(const void *l, const void *r)
666 { return *((uint16_t *) r) - *((uint16_t *) l); } 687 { return *((uint16_t *) r) - *((uint16_t *) l); }
667 688
668 /* Number of quantiles we compute */
669 const unsigned nq = 31;
670
671 size_t n = ca->sb.nbuckets, i, unused, btree; 689 size_t n = ca->sb.nbuckets, i, unused, btree;
672 uint64_t sum = 0; 690 uint64_t sum = 0;
673 uint16_t q[nq], *p, *cached; 691 /* Compute 31 quantiles */
692 uint16_t q[31], *p, *cached;
674 ssize_t ret; 693 ssize_t ret;
675 694
676 cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t)); 695 cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t));
@@ -703,26 +722,29 @@ SHOW(__bch_cache)
703 if (n) 722 if (n)
704 do_div(sum, n); 723 do_div(sum, n);
705 724
706 for (i = 0; i < nq; i++) 725 for (i = 0; i < ARRAY_SIZE(q); i++)
707 q[i] = INITIAL_PRIO - cached[n * (i + 1) / (nq + 1)]; 726 q[i] = INITIAL_PRIO - cached[n * (i + 1) /
727 (ARRAY_SIZE(q) + 1)];
708 728
709 vfree(p); 729 vfree(p);
710 730
711 ret = snprintf(buf, PAGE_SIZE, 731 ret = scnprintf(buf, PAGE_SIZE,
712 "Unused: %zu%%\n" 732 "Unused: %zu%%\n"
713 "Metadata: %zu%%\n" 733 "Metadata: %zu%%\n"
714 "Average: %llu\n" 734 "Average: %llu\n"
715 "Sectors per Q: %zu\n" 735 "Sectors per Q: %zu\n"
716 "Quantiles: [", 736 "Quantiles: [",
717 unused * 100 / (size_t) ca->sb.nbuckets, 737 unused * 100 / (size_t) ca->sb.nbuckets,
718 btree * 100 / (size_t) ca->sb.nbuckets, sum, 738 btree * 100 / (size_t) ca->sb.nbuckets, sum,
719 n * ca->sb.bucket_size / (nq + 1)); 739 n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
720 740
721 for (i = 0; i < nq && ret < (ssize_t) PAGE_SIZE; i++) 741 for (i = 0; i < ARRAY_SIZE(q); i++)
722 ret += snprintf(buf + ret, PAGE_SIZE - ret, 742 ret += scnprintf(buf + ret, PAGE_SIZE - ret,
723 i < nq - 1 ? "%u " : "%u]\n", q[i]); 743 "%u ", q[i]);
724 744 ret--;
725 buf[PAGE_SIZE - 1] = '\0'; 745
746 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n");
747
726 return ret; 748 return ret;
727 } 749 }
728 750
diff --git a/drivers/md/bcache/trace.c b/drivers/md/bcache/trace.c
index 983f9bb411bc..f7b6c197f90f 100644
--- a/drivers/md/bcache/trace.c
+++ b/drivers/md/bcache/trace.c
@@ -2,6 +2,7 @@
2#include "btree.h" 2#include "btree.h"
3#include "request.h" 3#include "request.h"
4 4
5#include <linux/blktrace_api.h>
5#include <linux/module.h> 6#include <linux/module.h>
6 7
7#define CREATE_TRACE_POINTS 8#define CREATE_TRACE_POINTS
@@ -9,18 +10,44 @@
9 10
10EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_request_start); 11EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_request_start);
11EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_request_end); 12EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_request_end);
12EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_passthrough); 13
13EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_hit); 14EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_bypass_sequential);
14EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_miss); 15EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_bypass_congested);
16
17EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read);
18EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_write);
15EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read_retry); 19EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read_retry);
16EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writethrough); 20
17EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writeback); 21EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_insert);
18EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_write_skip); 22
23EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_replay_key);
24EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_write);
25EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_full);
26EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_entry_full);
27
28EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_cache_cannibalize);
29
19EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_read); 30EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_read);
20EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_write); 31EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_write);
21EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_write_dirty); 32
22EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read_dirty); 33EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_alloc);
23EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_write); 34EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_alloc_fail);
24EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_insert); 35EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_free);
36
37EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_gc_coalesce);
25EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_start); 38EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_start);
26EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_end); 39EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_end);
40EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_copy);
41EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_copy_collision);
42
43EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_insert_key);
44
45EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_split);
46EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_compact);
47EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_set_root);
48
49EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_alloc_invalidate);
50EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_alloc_fail);
51
52EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writeback);
53EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writeback_collision);
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index da3a99e85b1e..98eb81159a22 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -228,23 +228,6 @@ start: bv->bv_len = min_t(size_t, PAGE_SIZE - bv->bv_offset,
228 } 228 }
229} 229}
230 230
231int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp)
232{
233 int i;
234 struct bio_vec *bv;
235
236 bio_for_each_segment(bv, bio, i) {
237 bv->bv_page = alloc_page(gfp);
238 if (!bv->bv_page) {
239 while (bv-- != bio->bi_io_vec + bio->bi_idx)
240 __free_page(bv->bv_page);
241 return -ENOMEM;
242 }
243 }
244
245 return 0;
246}
247
248/* 231/*
249 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any 232 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
250 * use permitted, subject to terms of PostgreSQL license; see.) 233 * use permitted, subject to terms of PostgreSQL license; see.)
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
index 577393e38c3a..1ae2a73ad85f 100644
--- a/drivers/md/bcache/util.h
+++ b/drivers/md/bcache/util.h
@@ -15,8 +15,6 @@
15 15
16struct closure; 16struct closure;
17 17
18#include <trace/events/bcache.h>
19
20#ifdef CONFIG_BCACHE_EDEBUG 18#ifdef CONFIG_BCACHE_EDEBUG
21 19
22#define atomic_dec_bug(v) BUG_ON(atomic_dec_return(v) < 0) 20#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)
566 return x; 564 return x;
567} 565}
568 566
569#define bio_end(bio) ((bio)->bi_sector + bio_sectors(bio))
570
571void bch_bio_map(struct bio *bio, void *base); 567void bch_bio_map(struct bio *bio, void *base);
572 568
573int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp);
574
575static inline sector_t bdev_sectors(struct block_device *bdev) 569static inline sector_t bdev_sectors(struct block_device *bdev)
576{ 570{
577 return bdev->bd_inode->i_size >> 9; 571 return bdev->bd_inode->i_size >> 9;
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 2714ed3991d1..22cbff551628 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -9,6 +9,9 @@
9#include "bcache.h" 9#include "bcache.h"
10#include "btree.h" 10#include "btree.h"
11#include "debug.h" 11#include "debug.h"
12#include "writeback.h"
13
14#include <trace/events/bcache.h>
12 15
13static struct workqueue_struct *dirty_wq; 16static struct workqueue_struct *dirty_wq;
14 17
@@ -36,7 +39,7 @@ static void __update_writeback_rate(struct cached_dev *dc)
36 39
37 int change = 0; 40 int change = 0;
38 int64_t error; 41 int64_t error;
39 int64_t dirty = atomic_long_read(&dc->disk.sectors_dirty); 42 int64_t dirty = bcache_dev_sectors_dirty(&dc->disk);
40 int64_t derivative = dirty - dc->disk.sectors_dirty_last; 43 int64_t derivative = dirty - dc->disk.sectors_dirty_last;
41 44
42 dc->disk.sectors_dirty_last = dirty; 45 dc->disk.sectors_dirty_last = dirty;
@@ -105,6 +108,31 @@ static bool dirty_pred(struct keybuf *buf, struct bkey *k)
105 return KEY_DIRTY(k); 108 return KEY_DIRTY(k);
106} 109}
107 110
111static bool dirty_full_stripe_pred(struct keybuf *buf, struct bkey *k)
112{
113 uint64_t stripe;
114 unsigned nr_sectors = KEY_SIZE(k);
115 struct cached_dev *dc = container_of(buf, struct cached_dev,
116 writeback_keys);
117 unsigned stripe_size = 1 << dc->disk.stripe_size_bits;
118
119 if (!KEY_DIRTY(k))
120 return false;
121
122 stripe = KEY_START(k) >> dc->disk.stripe_size_bits;
123 while (1) {
124 if (atomic_read(dc->disk.stripe_sectors_dirty + stripe) !=
125 stripe_size)
126 return false;
127
128 if (nr_sectors <= stripe_size)
129 return true;
130
131 nr_sectors -= stripe_size;
132 stripe++;
133 }
134}
135
108static void dirty_init(struct keybuf_key *w) 136static void dirty_init(struct keybuf_key *w)
109{ 137{
110 struct dirty_io *io = w->private; 138 struct dirty_io *io = w->private;
@@ -149,7 +177,22 @@ static void refill_dirty(struct closure *cl)
149 searched_from_start = true; 177 searched_from_start = true;
150 } 178 }
151 179
152 bch_refill_keybuf(dc->disk.c, buf, &end); 180 if (dc->partial_stripes_expensive) {
181 uint64_t i;
182
183 for (i = 0; i < dc->disk.nr_stripes; i++)
184 if (atomic_read(dc->disk.stripe_sectors_dirty + i) ==
185 1 << dc->disk.stripe_size_bits)
186 goto full_stripes;
187
188 goto normal_refill;
189full_stripes:
190 bch_refill_keybuf(dc->disk.c, buf, &end,
191 dirty_full_stripe_pred);
192 } else {
193normal_refill:
194 bch_refill_keybuf(dc->disk.c, buf, &end, dirty_pred);
195 }
153 196
154 if (bkey_cmp(&buf->last_scanned, &end) >= 0 && searched_from_start) { 197 if (bkey_cmp(&buf->last_scanned, &end) >= 0 && searched_from_start) {
155 /* Searched the entire btree - delay awhile */ 198 /* Searched the entire btree - delay awhile */
@@ -181,10 +224,8 @@ void bch_writeback_queue(struct cached_dev *dc)
181 } 224 }
182} 225}
183 226
184void bch_writeback_add(struct cached_dev *dc, unsigned sectors) 227void bch_writeback_add(struct cached_dev *dc)
185{ 228{
186 atomic_long_add(sectors, &dc->disk.sectors_dirty);
187
188 if (!atomic_read(&dc->has_dirty) && 229 if (!atomic_read(&dc->has_dirty) &&
189 !atomic_xchg(&dc->has_dirty, 1)) { 230 !atomic_xchg(&dc->has_dirty, 1)) {
190 atomic_inc(&dc->count); 231 atomic_inc(&dc->count);
@@ -203,6 +244,34 @@ void bch_writeback_add(struct cached_dev *dc, unsigned sectors)
203 } 244 }
204} 245}
205 246
247void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,
248 uint64_t offset, int nr_sectors)
249{
250 struct bcache_device *d = c->devices[inode];
251 unsigned stripe_size, stripe_offset;
252 uint64_t stripe;
253
254 if (!d)
255 return;
256
257 stripe_size = 1 << d->stripe_size_bits;
258 stripe = offset >> d->stripe_size_bits;
259 stripe_offset = offset & (stripe_size - 1);
260
261 while (nr_sectors) {
262 int s = min_t(unsigned, abs(nr_sectors),
263 stripe_size - stripe_offset);
264
265 if (nr_sectors < 0)
266 s = -s;
267
268 atomic_add(s, d->stripe_sectors_dirty + stripe);
269 nr_sectors -= s;
270 stripe_offset = 0;
271 stripe++;
272 }
273}
274
206/* Background writeback - IO loop */ 275/* Background writeback - IO loop */
207 276
208static void dirty_io_destructor(struct closure *cl) 277static void dirty_io_destructor(struct closure *cl)
@@ -216,9 +285,10 @@ static void write_dirty_finish(struct closure *cl)
216 struct dirty_io *io = container_of(cl, struct dirty_io, cl); 285 struct dirty_io *io = container_of(cl, struct dirty_io, cl);
217 struct keybuf_key *w = io->bio.bi_private; 286 struct keybuf_key *w = io->bio.bi_private;
218 struct cached_dev *dc = io->dc; 287 struct cached_dev *dc = io->dc;
219 struct bio_vec *bv = bio_iovec_idx(&io->bio, io->bio.bi_vcnt); 288 struct bio_vec *bv;
289 int i;
220 290
221 while (bv-- != io->bio.bi_io_vec) 291 bio_for_each_segment_all(bv, &io->bio, i)
222 __free_page(bv->bv_page); 292 __free_page(bv->bv_page);
223 293
224 /* This is kind of a dumb way of signalling errors. */ 294 /* This is kind of a dumb way of signalling errors. */
@@ -236,10 +306,12 @@ static void write_dirty_finish(struct closure *cl)
236 for (i = 0; i < KEY_PTRS(&w->key); i++) 306 for (i = 0; i < KEY_PTRS(&w->key); i++)
237 atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin); 307 atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin);
238 308
239 pr_debug("clearing %s", pkey(&w->key));
240 bch_btree_insert(&op, dc->disk.c); 309 bch_btree_insert(&op, dc->disk.c);
241 closure_sync(&op.cl); 310 closure_sync(&op.cl);
242 311
312 if (op.insert_collision)
313 trace_bcache_writeback_collision(&w->key);
314
243 atomic_long_inc(op.insert_collision 315 atomic_long_inc(op.insert_collision
244 ? &dc->disk.c->writeback_keys_failed 316 ? &dc->disk.c->writeback_keys_failed
245 : &dc->disk.c->writeback_keys_done); 317 : &dc->disk.c->writeback_keys_done);
@@ -275,7 +347,6 @@ static void write_dirty(struct closure *cl)
275 io->bio.bi_bdev = io->dc->bdev; 347 io->bio.bi_bdev = io->dc->bdev;
276 io->bio.bi_end_io = dirty_endio; 348 io->bio.bi_end_io = dirty_endio;
277 349
278 trace_bcache_write_dirty(&io->bio);
279 closure_bio_submit(&io->bio, cl, &io->dc->disk); 350 closure_bio_submit(&io->bio, cl, &io->dc->disk);
280 351
281 continue_at(cl, write_dirty_finish, dirty_wq); 352 continue_at(cl, write_dirty_finish, dirty_wq);
@@ -296,7 +367,6 @@ static void read_dirty_submit(struct closure *cl)
296{ 367{
297 struct dirty_io *io = container_of(cl, struct dirty_io, cl); 368 struct dirty_io *io = container_of(cl, struct dirty_io, cl);
298 369
299 trace_bcache_read_dirty(&io->bio);
300 closure_bio_submit(&io->bio, cl, &io->dc->disk); 370 closure_bio_submit(&io->bio, cl, &io->dc->disk);
301 371
302 continue_at(cl, write_dirty, dirty_wq); 372 continue_at(cl, write_dirty, dirty_wq);
@@ -349,10 +419,10 @@ static void read_dirty(struct closure *cl)
349 io->bio.bi_rw = READ; 419 io->bio.bi_rw = READ;
350 io->bio.bi_end_io = read_dirty_endio; 420 io->bio.bi_end_io = read_dirty_endio;
351 421
352 if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL)) 422 if (bio_alloc_pages(&io->bio, GFP_KERNEL))
353 goto err_free; 423 goto err_free;
354 424
355 pr_debug("%s", pkey(&w->key)); 425 trace_bcache_writeback(&w->key);
356 426
357 closure_call(&io->cl, read_dirty_submit, NULL, &dc->disk.cl); 427 closure_call(&io->cl, read_dirty_submit, NULL, &dc->disk.cl);
358 428
@@ -375,12 +445,49 @@ err:
375 refill_dirty(cl); 445 refill_dirty(cl);
376} 446}
377 447
448/* Init */
449
450static int bch_btree_sectors_dirty_init(struct btree *b, struct btree_op *op,
451 struct cached_dev *dc)
452{
453 struct bkey *k;
454 struct btree_iter iter;
455
456 bch_btree_iter_init(b, &iter, &KEY(dc->disk.id, 0, 0));
457 while ((k = bch_btree_iter_next_filter(&iter, b, bch_ptr_bad)))
458 if (!b->level) {
459 if (KEY_INODE(k) > dc->disk.id)
460 break;
461
462 if (KEY_DIRTY(k))
463 bcache_dev_sectors_dirty_add(b->c, dc->disk.id,
464 KEY_START(k),
465 KEY_SIZE(k));
466 } else {
467 btree(sectors_dirty_init, k, b, op, dc);
468 if (KEY_INODE(k) > dc->disk.id)
469 break;
470
471 cond_resched();
472 }
473
474 return 0;
475}
476
477void bch_sectors_dirty_init(struct cached_dev *dc)
478{
479 struct btree_op op;
480
481 bch_btree_op_init_stack(&op);
482 btree_root(sectors_dirty_init, dc->disk.c, &op, dc);
483}
484
378void bch_cached_dev_writeback_init(struct cached_dev *dc) 485void bch_cached_dev_writeback_init(struct cached_dev *dc)
379{ 486{
380 closure_init_unlocked(&dc->writeback); 487 closure_init_unlocked(&dc->writeback);
381 init_rwsem(&dc->writeback_lock); 488 init_rwsem(&dc->writeback_lock);
382 489
383 bch_keybuf_init(&dc->writeback_keys, dirty_pred); 490 bch_keybuf_init(&dc->writeback_keys);
384 491
385 dc->writeback_metadata = true; 492 dc->writeback_metadata = true;
386 dc->writeback_running = true; 493 dc->writeback_running = true;
diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h
new file mode 100644
index 000000000000..c91f61bb95b6
--- /dev/null
+++ b/drivers/md/bcache/writeback.h
@@ -0,0 +1,64 @@
1#ifndef _BCACHE_WRITEBACK_H
2#define _BCACHE_WRITEBACK_H
3
4#define CUTOFF_WRITEBACK 40
5#define CUTOFF_WRITEBACK_SYNC 70
6
7static inline uint64_t bcache_dev_sectors_dirty(struct bcache_device *d)
8{
9 uint64_t i, ret = 0;
10
11 for (i = 0; i < d->nr_stripes; i++)
12 ret += atomic_read(d->stripe_sectors_dirty + i);
13
14 return ret;
15}
16
17static inline bool bcache_dev_stripe_dirty(struct bcache_device *d,
18 uint64_t offset,
19 unsigned nr_sectors)
20{
21 uint64_t stripe = offset >> d->stripe_size_bits;
22
23 while (1) {
24 if (atomic_read(d->stripe_sectors_dirty + stripe))
25 return true;
26
27 if (nr_sectors <= 1 << d->stripe_size_bits)
28 return false;
29
30 nr_sectors -= 1 << d->stripe_size_bits;
31 stripe++;
32 }
33}
34
35static inline bool should_writeback(struct cached_dev *dc, struct bio *bio,
36 unsigned cache_mode, bool would_skip)
37{
38 unsigned in_use = dc->disk.c->gc_stats.in_use;
39
40 if (cache_mode != CACHE_MODE_WRITEBACK ||
41 atomic_read(&dc->disk.detaching) ||
42 in_use > CUTOFF_WRITEBACK_SYNC)
43 return false;
44
45 if (dc->partial_stripes_expensive &&
46 bcache_dev_stripe_dirty(&dc->disk, bio->bi_sector,
47 bio_sectors(bio)))
48 return true;
49
50 if (would_skip)
51 return false;
52
53 return bio->bi_rw & REQ_SYNC ||
54 in_use <= CUTOFF_WRITEBACK;
55}
56
57void bcache_dev_sectors_dirty_add(struct cache_set *, unsigned, uint64_t, int);
58void bch_writeback_queue(struct cached_dev *);
59void bch_writeback_add(struct cached_dev *);
60
61void bch_sectors_dirty_init(struct cached_dev *dc);
62void bch_cached_dev_writeback_init(struct cached_dev *);
63
64#endif
diff --git a/drivers/md/md.c b/drivers/md/md.c
index dddc87bcf64a..9f13e13506ef 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7716,20 +7716,6 @@ static int remove_and_add_spares(struct mddev *mddev,
7716 continue; 7716 continue;
7717 7717
7718 rdev->recovery_offset = 0; 7718 rdev->recovery_offset = 0;
7719 if (rdev->saved_raid_disk >= 0 && mddev->in_sync) {
7720 spin_lock_irq(&mddev->write_lock);
7721 if (mddev->in_sync)
7722 /* OK, this device, which is in_sync,
7723 * will definitely be noticed before
7724 * the next write, so recovery isn't
7725 * needed.
7726 */
7727 rdev->recovery_offset = mddev->recovery_cp;
7728 spin_unlock_irq(&mddev->write_lock);
7729 }
7730 if (mddev->ro && rdev->recovery_offset != MaxSector)
7731 /* not safe to add this disk now */
7732 continue;
7733 if (mddev->pers-> 7719 if (mddev->pers->
7734 hot_add_disk(mddev, rdev) == 0) { 7720 hot_add_disk(mddev, rdev) == 0) {
7735 if (sysfs_link_rdev(mddev, rdev)) 7721 if (sysfs_link_rdev(mddev, rdev))
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ec734588a1c6..d60412c7f995 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1849,6 +1849,36 @@ static int process_checks(struct r1bio *r1_bio)
1849 int i; 1849 int i;
1850 int vcnt; 1850 int vcnt;
1851 1851
1852 /* Fix variable parts of all bios */
1853 vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
1854 for (i = 0; i < conf->raid_disks * 2; i++) {
1855 int j;
1856 int size;
1857 struct bio *b = r1_bio->bios[i];
1858 if (b->bi_end_io != end_sync_read)
1859 continue;
1860 /* fixup the bio for reuse */
1861 bio_reset(b);
1862 b->bi_vcnt = vcnt;
1863 b->bi_size = r1_bio->sectors << 9;
1864 b->bi_sector = r1_bio->sector +
1865 conf->mirrors[i].rdev->data_offset;
1866 b->bi_bdev = conf->mirrors[i].rdev->bdev;
1867 b->bi_end_io = end_sync_read;
1868 b->bi_private = r1_bio;
1869
1870 size = b->bi_size;
1871 for (j = 0; j < vcnt ; j++) {
1872 struct bio_vec *bi;
1873 bi = &b->bi_io_vec[j];
1874 bi->bv_offset = 0;
1875 if (size > PAGE_SIZE)
1876 bi->bv_len = PAGE_SIZE;
1877 else
1878 bi->bv_len = size;
1879 size -= PAGE_SIZE;
1880 }
1881 }
1852 for (primary = 0; primary < conf->raid_disks * 2; primary++) 1882 for (primary = 0; primary < conf->raid_disks * 2; primary++)
1853 if (r1_bio->bios[primary]->bi_end_io == end_sync_read && 1883 if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
1854 test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) { 1884 test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) {
@@ -1857,12 +1887,10 @@ static int process_checks(struct r1bio *r1_bio)
1857 break; 1887 break;
1858 } 1888 }
1859 r1_bio->read_disk = primary; 1889 r1_bio->read_disk = primary;
1860 vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
1861 for (i = 0; i < conf->raid_disks * 2; i++) { 1890 for (i = 0; i < conf->raid_disks * 2; i++) {
1862 int j; 1891 int j;
1863 struct bio *pbio = r1_bio->bios[primary]; 1892 struct bio *pbio = r1_bio->bios[primary];
1864 struct bio *sbio = r1_bio->bios[i]; 1893 struct bio *sbio = r1_bio->bios[i];
1865 int size;
1866 1894
1867 if (sbio->bi_end_io != end_sync_read) 1895 if (sbio->bi_end_io != end_sync_read)
1868 continue; 1896 continue;
@@ -1888,27 +1916,6 @@ static int process_checks(struct r1bio *r1_bio)
1888 rdev_dec_pending(conf->mirrors[i].rdev, mddev); 1916 rdev_dec_pending(conf->mirrors[i].rdev, mddev);
1889 continue; 1917 continue;
1890 } 1918 }
1891 /* fixup the bio for reuse */
1892 bio_reset(sbio);
1893 sbio->bi_vcnt = vcnt;
1894 sbio->bi_size = r1_bio->sectors << 9;
1895 sbio->bi_sector = r1_bio->sector +
1896 conf->mirrors[i].rdev->data_offset;
1897 sbio->bi_bdev = conf->mirrors[i].rdev->bdev;
1898 sbio->bi_end_io = end_sync_read;
1899 sbio->bi_private = r1_bio;
1900
1901 size = sbio->bi_size;
1902 for (j = 0; j < vcnt ; j++) {
1903 struct bio_vec *bi;
1904 bi = &sbio->bi_io_vec[j];
1905 bi->bv_offset = 0;
1906 if (size > PAGE_SIZE)
1907 bi->bv_len = PAGE_SIZE;
1908 else
1909 bi->bv_len = size;
1910 size -= PAGE_SIZE;
1911 }
1912 1919
1913 bio_copy_data(sbio, pbio); 1920 bio_copy_data(sbio, pbio);
1914 } 1921 }
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index cd066b63bdaf..df7b0a06b0ea 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2097,11 +2097,17 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
2097 * both 'first' and 'i', so we just compare them. 2097 * both 'first' and 'i', so we just compare them.
2098 * All vec entries are PAGE_SIZE; 2098 * All vec entries are PAGE_SIZE;
2099 */ 2099 */
2100 for (j = 0; j < vcnt; j++) 2100 int sectors = r10_bio->sectors;
2101 for (j = 0; j < vcnt; j++) {
2102 int len = PAGE_SIZE;
2103 if (sectors < (len / 512))
2104 len = sectors * 512;
2101 if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), 2105 if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
2102 page_address(tbio->bi_io_vec[j].bv_page), 2106 page_address(tbio->bi_io_vec[j].bv_page),
2103 fbio->bi_io_vec[j].bv_len)) 2107 len))
2104 break; 2108 break;
2109 sectors -= len/512;
2110 }
2105 if (j == vcnt) 2111 if (j == vcnt)
2106 continue; 2112 continue;
2107 atomic64_add(r10_bio->sectors, &mddev->resync_mismatches); 2113 atomic64_add(r10_bio->sectors, &mddev->resync_mismatches);
@@ -2284,12 +2290,18 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)
2284 d = r10_bio->devs[1].devnum; 2290 d = r10_bio->devs[1].devnum;
2285 wbio = r10_bio->devs[1].bio; 2291 wbio = r10_bio->devs[1].bio;
2286 wbio2 = r10_bio->devs[1].repl_bio; 2292 wbio2 = r10_bio->devs[1].repl_bio;
2293 /* Need to test wbio2->bi_end_io before we call
2294 * generic_make_request as if the former is NULL,
2295 * the latter is free to free wbio2.
2296 */
2297 if (wbio2 && !wbio2->bi_end_io)
2298 wbio2 = NULL;
2287 if (wbio->bi_end_io) { 2299 if (wbio->bi_end_io) {
2288 atomic_inc(&conf->mirrors[d].rdev->nr_pending); 2300 atomic_inc(&conf->mirrors[d].rdev->nr_pending);
2289 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); 2301 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio));
2290 generic_make_request(wbio); 2302 generic_make_request(wbio);
2291 } 2303 }
2292 if (wbio2 && wbio2->bi_end_io) { 2304 if (wbio2) {
2293 atomic_inc(&conf->mirrors[d].replacement->nr_pending); 2305 atomic_inc(&conf->mirrors[d].replacement->nr_pending);
2294 md_sync_acct(conf->mirrors[d].replacement->bdev, 2306 md_sync_acct(conf->mirrors[d].replacement->bdev,
2295 bio_sectors(wbio2)); 2307 bio_sectors(wbio2));
@@ -3407,6 +3419,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
3407 3419
3408 if (bio->bi_end_io == end_sync_read) { 3420 if (bio->bi_end_io == end_sync_read) {
3409 md_sync_acct(bio->bi_bdev, nr_sectors); 3421 md_sync_acct(bio->bi_bdev, nr_sectors);
3422 set_bit(BIO_UPTODATE, &bio->bi_flags);
3410 generic_make_request(bio); 3423 generic_make_request(bio);
3411 } 3424 }
3412 } 3425 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 2bf094a587cb..78ea44336e75 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3462,6 +3462,7 @@ static void handle_stripe(struct stripe_head *sh)
3462 test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) { 3462 test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
3463 set_bit(STRIPE_SYNCING, &sh->state); 3463 set_bit(STRIPE_SYNCING, &sh->state);
3464 clear_bit(STRIPE_INSYNC, &sh->state); 3464 clear_bit(STRIPE_INSYNC, &sh->state);
3465 clear_bit(STRIPE_REPLACED, &sh->state);
3465 } 3466 }
3466 spin_unlock(&sh->stripe_lock); 3467 spin_unlock(&sh->stripe_lock);
3467 } 3468 }
@@ -3607,19 +3608,23 @@ static void handle_stripe(struct stripe_head *sh)
3607 handle_parity_checks5(conf, sh, &s, disks); 3608 handle_parity_checks5(conf, sh, &s, disks);
3608 } 3609 }
3609 3610
3610 if (s.replacing && s.locked == 0 3611 if ((s.replacing || s.syncing) && s.locked == 0
3611 && !test_bit(STRIPE_INSYNC, &sh->state)) { 3612 && !test_bit(STRIPE_COMPUTE_RUN, &sh->state)
3613 && !test_bit(STRIPE_REPLACED, &sh->state)) {
3612 /* Write out to replacement devices where possible */ 3614 /* Write out to replacement devices where possible */
3613 for (i = 0; i < conf->raid_disks; i++) 3615 for (i = 0; i < conf->raid_disks; i++)
3614 if (test_bit(R5_UPTODATE, &sh->dev[i].flags) && 3616 if (test_bit(R5_NeedReplace, &sh->dev[i].flags)) {
3615 test_bit(R5_NeedReplace, &sh->dev[i].flags)) { 3617 WARN_ON(!test_bit(R5_UPTODATE, &sh->dev[i].flags));
3616 set_bit(R5_WantReplace, &sh->dev[i].flags); 3618 set_bit(R5_WantReplace, &sh->dev[i].flags);
3617 set_bit(R5_LOCKED, &sh->dev[i].flags); 3619 set_bit(R5_LOCKED, &sh->dev[i].flags);
3618 s.locked++; 3620 s.locked++;
3619 } 3621 }
3620 set_bit(STRIPE_INSYNC, &sh->state); 3622 if (s.replacing)
3623 set_bit(STRIPE_INSYNC, &sh->state);
3624 set_bit(STRIPE_REPLACED, &sh->state);
3621 } 3625 }
3622 if ((s.syncing || s.replacing) && s.locked == 0 && 3626 if ((s.syncing || s.replacing) && s.locked == 0 &&
3627 !test_bit(STRIPE_COMPUTE_RUN, &sh->state) &&
3623 test_bit(STRIPE_INSYNC, &sh->state)) { 3628 test_bit(STRIPE_INSYNC, &sh->state)) {
3624 md_done_sync(conf->mddev, STRIPE_SECTORS, 1); 3629 md_done_sync(conf->mddev, STRIPE_SECTORS, 1);
3625 clear_bit(STRIPE_SYNCING, &sh->state); 3630 clear_bit(STRIPE_SYNCING, &sh->state);
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index b0b663b119a8..70c49329ca9a 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -306,6 +306,7 @@ enum {
306 STRIPE_SYNC_REQUESTED, 306 STRIPE_SYNC_REQUESTED,
307 STRIPE_SYNCING, 307 STRIPE_SYNCING,
308 STRIPE_INSYNC, 308 STRIPE_INSYNC,
309 STRIPE_REPLACED,
309 STRIPE_PREREAD_ACTIVE, 310 STRIPE_PREREAD_ACTIVE,
310 STRIPE_DELAYED, 311 STRIPE_DELAYED,
311 STRIPE_DEGRADED, 312 STRIPE_DEGRADED,
diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c
index 10460fd3ce39..dbcdfbf8aed0 100644
--- a/drivers/media/pci/saa7134/saa7134-alsa.c
+++ b/drivers/media/pci/saa7134/saa7134-alsa.c
@@ -172,7 +172,9 @@ static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
172 dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count, 172 dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
173 dev->dmasound.bufsize, dev->dmasound.blocks); 173 dev->dmasound.bufsize, dev->dmasound.blocks);
174 spin_unlock(&dev->slock); 174 spin_unlock(&dev->slock);
175 snd_pcm_stream_lock(dev->dmasound.substream);
175 snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN); 176 snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
177 snd_pcm_stream_unlock(dev->dmasound.substream);
176 return; 178 return;
177 } 179 }
178 180
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index f7b90661e321..e068a76a5f6f 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -66,14 +66,19 @@ EXPORT_SYMBOL(ssc_request);
66 66
67void ssc_free(struct ssc_device *ssc) 67void ssc_free(struct ssc_device *ssc)
68{ 68{
69 bool disable_clk = true;
70
69 spin_lock(&user_lock); 71 spin_lock(&user_lock);
70 if (ssc->user) { 72 if (ssc->user)
71 ssc->user--; 73 ssc->user--;
72 clk_disable_unprepare(ssc->clk); 74 else {
73 } else { 75 disable_clk = false;
74 dev_dbg(&ssc->pdev->dev, "device already free\n"); 76 dev_dbg(&ssc->pdev->dev, "device already free\n");
75 } 77 }
76 spin_unlock(&user_lock); 78 spin_unlock(&user_lock);
79
80 if (disable_clk)
81 clk_disable_unprepare(ssc->clk);
77} 82}
78EXPORT_SYMBOL(ssc_free); 83EXPORT_SYMBOL(ssc_free);
79 84
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index f9296abcf02a..6127ab64bb39 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -167,7 +167,7 @@ int mei_hbm_start_req(struct mei_device *dev)
167 167
168 dev->hbm_state = MEI_HBM_IDLE; 168 dev->hbm_state = MEI_HBM_IDLE;
169 if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) { 169 if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
170 dev_err(&dev->pdev->dev, "version message writet failed\n"); 170 dev_err(&dev->pdev->dev, "version message write failed\n");
171 dev->dev_state = MEI_DEV_RESETTING; 171 dev->dev_state = MEI_DEV_RESETTING;
172 mei_reset(dev, 1); 172 mei_reset(dev, 1);
173 return -ENODEV; 173 return -ENODEV;
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index e4f8dec4dc3c..b22c7e247225 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -239,14 +239,18 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)
239 if (mei_me_hw_is_ready(dev)) 239 if (mei_me_hw_is_ready(dev))
240 return 0; 240 return 0;
241 241
242 dev->recvd_hw_ready = false;
242 mutex_unlock(&dev->device_lock); 243 mutex_unlock(&dev->device_lock);
243 err = wait_event_interruptible_timeout(dev->wait_hw_ready, 244 err = wait_event_interruptible_timeout(dev->wait_hw_ready,
244 dev->recvd_hw_ready, MEI_INTEROP_TIMEOUT); 245 dev->recvd_hw_ready,
246 mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT));
245 mutex_lock(&dev->device_lock); 247 mutex_lock(&dev->device_lock);
246 if (!err && !dev->recvd_hw_ready) { 248 if (!err && !dev->recvd_hw_ready) {
249 if (!err)
250 err = -ETIMEDOUT;
247 dev_err(&dev->pdev->dev, 251 dev_err(&dev->pdev->dev,
248 "wait hw ready failed. status = 0x%x\n", err); 252 "wait hw ready failed. status = %d\n", err);
249 return -ETIMEDOUT; 253 return err;
250 } 254 }
251 255
252 dev->recvd_hw_ready = false; 256 dev->recvd_hw_ready = false;
@@ -483,7 +487,9 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
483 /* check if ME wants a reset */ 487 /* check if ME wants a reset */
484 if (!mei_hw_is_ready(dev) && 488 if (!mei_hw_is_ready(dev) &&
485 dev->dev_state != MEI_DEV_RESETTING && 489 dev->dev_state != MEI_DEV_RESETTING &&
486 dev->dev_state != MEI_DEV_INITIALIZING) { 490 dev->dev_state != MEI_DEV_INITIALIZING &&
491 dev->dev_state != MEI_DEV_POWER_DOWN &&
492 dev->dev_state != MEI_DEV_POWER_UP) {
487 dev_dbg(&dev->pdev->dev, "FW not ready.\n"); 493 dev_dbg(&dev->pdev->dev, "FW not ready.\n");
488 mei_reset(dev, 1); 494 mei_reset(dev, 1);
489 mutex_unlock(&dev->device_lock); 495 mutex_unlock(&dev->device_lock);
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index ed1d75203af6..e6f16f83ecde 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -148,7 +148,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
148 148
149 dev->hbm_state = MEI_HBM_IDLE; 149 dev->hbm_state = MEI_HBM_IDLE;
150 150
151 if (dev->dev_state != MEI_DEV_INITIALIZING) { 151 if (dev->dev_state != MEI_DEV_INITIALIZING &&
152 dev->dev_state != MEI_DEV_POWER_UP) {
152 if (dev->dev_state != MEI_DEV_DISABLED && 153 if (dev->dev_state != MEI_DEV_DISABLED &&
153 dev->dev_state != MEI_DEV_POWER_DOWN) 154 dev->dev_state != MEI_DEV_POWER_DOWN)
154 dev->dev_state = MEI_DEV_RESETTING; 155 dev->dev_state = MEI_DEV_RESETTING;
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 847b1996ce8e..2c5a91bb8ec3 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -128,7 +128,7 @@ static inline int pxamci_set_power(struct pxamci_host *host,
128 !!on ^ host->pdata->gpio_power_invert); 128 !!on ^ host->pdata->gpio_power_invert);
129 } 129 }
130 if (!host->vcc && host->pdata && host->pdata->setpower) 130 if (!host->vcc && host->pdata && host->pdata->setpower)
131 host->pdata->setpower(mmc_dev(host->mmc), vdd); 131 return host->pdata->setpower(mmc_dev(host->mmc), vdd);
132 132
133 return 0; 133 return 0;
134} 134}
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 6d1a62a84c9d..1966444590f6 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -1678,6 +1678,7 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
1678 u16 f; 1678 u16 f;
1679 int segment; 1679 int segment;
1680 int ring_start = adapter->tx_ring.next_to_use; 1680 int ring_start = adapter->tx_ring.next_to_use;
1681 int ring_end;
1681 1682
1682 nr_frags = skb_shinfo(skb)->nr_frags; 1683 nr_frags = skb_shinfo(skb)->nr_frags;
1683 segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK; 1684 segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK;
@@ -1721,6 +1722,15 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
1721 map_len, PCI_DMA_TODEVICE); 1722 map_len, PCI_DMA_TODEVICE);
1722 1723
1723 if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { 1724 if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) {
1725 /* We need to unwind the mappings we've done */
1726 ring_end = adapter->tx_ring.next_to_use;
1727 adapter->tx_ring.next_to_use = ring_start;
1728 while (adapter->tx_ring.next_to_use != ring_end) {
1729 tpd = atl1e_get_tpd(adapter);
1730 tx_buffer = atl1e_get_tx_buffer(adapter, tpd);
1731 pci_unmap_single(adapter->pdev, tx_buffer->dma,
1732 tx_buffer->length, PCI_DMA_TODEVICE);
1733 }
1724 /* Reset the tx rings next pointer */ 1734 /* Reset the tx rings next pointer */
1725 adapter->tx_ring.next_to_use = ring_start; 1735 adapter->tx_ring.next_to_use = ring_start;
1726 return -ENOSPC; 1736 return -ENOSPC;
@@ -1763,6 +1773,16 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
1763 DMA_TO_DEVICE); 1773 DMA_TO_DEVICE);
1764 1774
1765 if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { 1775 if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) {
1776 /* We need to unwind the mappings we've done */
1777 ring_end = adapter->tx_ring.next_to_use;
1778 adapter->tx_ring.next_to_use = ring_start;
1779 while (adapter->tx_ring.next_to_use != ring_end) {
1780 tpd = atl1e_get_tpd(adapter);
1781 tx_buffer = atl1e_get_tx_buffer(adapter, tpd);
1782 dma_unmap_page(&adapter->pdev->dev, tx_buffer->dma,
1783 tx_buffer->length, DMA_TO_DEVICE);
1784 }
1785
1766 /* Reset the ring next to use pointer */ 1786 /* Reset the ring next to use pointer */
1767 adapter->tx_ring.next_to_use = ring_start; 1787 adapter->tx_ring.next_to_use = ring_start;
1768 return -ENOSPC; 1788 return -ENOSPC;
@@ -1853,8 +1873,10 @@ static netdev_tx_t atl1e_xmit_frame(struct sk_buff *skb,
1853 return NETDEV_TX_OK; 1873 return NETDEV_TX_OK;
1854 } 1874 }
1855 1875
1856 if (atl1e_tx_map(adapter, skb, tpd)) 1876 if (atl1e_tx_map(adapter, skb, tpd)) {
1877 dev_kfree_skb_any(skb);
1857 goto out; 1878 goto out;
1879 }
1858 1880
1859 atl1e_tx_queue(adapter, tpd_req, tpd); 1881 atl1e_tx_queue(adapter, tpd_req, tpd);
1860 1882
diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig
index 1d680baf43d6..52c96036dcc4 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -131,6 +131,7 @@ config BNX2X_SRIOV
131config BGMAC 131config BGMAC
132 tristate "BCMA bus GBit core support" 132 tristate "BCMA bus GBit core support"
133 depends on BCMA_HOST_SOC && HAS_DMA 133 depends on BCMA_HOST_SOC && HAS_DMA
134 select PHYLIB
134 ---help--- 135 ---help---
135 This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. 136 This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus.
136 They can be found on BCM47xx SoCs and provide gigabit ethernet. 137 They can be found on BCM47xx SoCs and provide gigabit ethernet.
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 2df48bb0f1ca..181edb522450 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -782,16 +782,22 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
782 782
783 if (vlan_tx_tag_present(skb)) 783 if (vlan_tx_tag_present(skb))
784 vlan_tag = be_get_tx_vlan_tag(adapter, skb); 784 vlan_tag = be_get_tx_vlan_tag(adapter, skb);
785 else if (qnq_async_evt_rcvd(adapter) && adapter->pvid) 785
786 vlan_tag = adapter->pvid; 786 if (qnq_async_evt_rcvd(adapter) && adapter->pvid) {
787 if (!vlan_tag)
788 vlan_tag = adapter->pvid;
789 /* f/w workaround to set skip_hw_vlan = 1, informs the F/W to
790 * skip VLAN insertion
791 */
792 if (skip_hw_vlan)
793 *skip_hw_vlan = true;
794 }
787 795
788 if (vlan_tag) { 796 if (vlan_tag) {
789 skb = __vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_tag); 797 skb = __vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
790 if (unlikely(!skb)) 798 if (unlikely(!skb))
791 return skb; 799 return skb;
792 skb->vlan_tci = 0; 800 skb->vlan_tci = 0;
793 if (skip_hw_vlan)
794 *skip_hw_vlan = true;
795 } 801 }
796 802
797 /* Insert the outer VLAN, if any */ 803 /* Insert the outer VLAN, if any */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
index 4273c06e2e96..9c7194b26ee2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
@@ -156,7 +156,7 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count,
156 stats = filp->private_data; 156 stats = filp->private_data;
157 spin_lock(&stats->lock); 157 spin_lock(&stats->lock);
158 if (stats->n) 158 if (stats->n)
159 field = stats->sum / stats->n; 159 field = div64_u64(stats->sum, stats->n);
160 spin_unlock(&stats->lock); 160 spin_unlock(&stats->lock);
161 ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field); 161 ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field);
162 if (ret > 0) { 162 if (ret > 0) {
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 4dccead586be..23a0fff0df52 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -431,8 +431,8 @@ static int netvsc_probe(struct hv_device *dev,
431 net->netdev_ops = &device_ops; 431 net->netdev_ops = &device_ops;
432 432
433 /* TODO: Add GSO and Checksum offload */ 433 /* TODO: Add GSO and Checksum offload */
434 net->hw_features = NETIF_F_SG; 434 net->hw_features = 0;
435 net->features = NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_TX; 435 net->features = NETIF_F_HW_VLAN_CTAG_TX;
436 436
437 SET_ETHTOOL_OPS(net, &ethtool_ops); 437 SET_ETHTOOL_OPS(net, &ethtool_ops);
438 SET_NETDEV_DEV(net, &dev->device); 438 SET_NETDEV_DEV(net, &dev->device);
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 876c72246ae9..a98fb0ed6aef 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -698,6 +698,28 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
698 return 0; 698 return 0;
699} 699}
700 700
701static unsigned long iov_pages(const struct iovec *iv, int offset,
702 unsigned long nr_segs)
703{
704 unsigned long seg, base;
705 int pages = 0, len, size;
706
707 while (nr_segs && (offset >= iv->iov_len)) {
708 offset -= iv->iov_len;
709 ++iv;
710 --nr_segs;
711 }
712
713 for (seg = 0; seg < nr_segs; seg++) {
714 base = (unsigned long)iv[seg].iov_base + offset;
715 len = iv[seg].iov_len - offset;
716 size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
717 pages += size;
718 offset = 0;
719 }
720
721 return pages;
722}
701 723
702/* Get packet from user space buffer */ 724/* Get packet from user space buffer */
703static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, 725static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
@@ -744,31 +766,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
744 if (unlikely(count > UIO_MAXIOV)) 766 if (unlikely(count > UIO_MAXIOV))
745 goto err; 767 goto err;
746 768
747 if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) 769 if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) {
748 zerocopy = true; 770 copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN;
749
750 if (zerocopy) {
751 /* Userspace may produce vectors with count greater than
752 * MAX_SKB_FRAGS, so we need to linearize parts of the skb
753 * to let the rest of data to be fit in the frags.
754 */
755 if (count > MAX_SKB_FRAGS) {
756 copylen = iov_length(iv, count - MAX_SKB_FRAGS);
757 if (copylen < vnet_hdr_len)
758 copylen = 0;
759 else
760 copylen -= vnet_hdr_len;
761 }
762 /* There are 256 bytes to be copied in skb, so there is enough
763 * room for skb expand head in case it is used.
764 * The rest buffer is mapped from userspace.
765 */
766 if (copylen < vnet_hdr.hdr_len)
767 copylen = vnet_hdr.hdr_len;
768 if (!copylen)
769 copylen = GOODCOPY_LEN;
770 linear = copylen; 771 linear = copylen;
771 } else { 772 if (iov_pages(iv, vnet_hdr_len + copylen, count)
773 <= MAX_SKB_FRAGS)
774 zerocopy = true;
775 }
776
777 if (!zerocopy) {
772 copylen = len; 778 copylen = len;
773 linear = vnet_hdr.hdr_len; 779 linear = vnet_hdr.hdr_len;
774 } 780 }
@@ -780,9 +786,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
780 786
781 if (zerocopy) 787 if (zerocopy)
782 err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count); 788 err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count);
783 else 789 else {
784 err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len, 790 err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len,
785 len); 791 len);
792 if (!err && m && m->msg_control) {
793 struct ubuf_info *uarg = m->msg_control;
794 uarg->callback(uarg, false);
795 }
796 }
797
786 if (err) 798 if (err)
787 goto err_kfree; 799 goto err_kfree;
788 800
@@ -873,7 +885,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
873 __be16 h_vlan_proto; 885 __be16 h_vlan_proto;
874 __be16 h_vlan_TCI; 886 __be16 h_vlan_TCI;
875 } veth; 887 } veth;
876 veth.h_vlan_proto = htons(ETH_P_8021Q); 888 veth.h_vlan_proto = skb->vlan_proto;
877 veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb)); 889 veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb));
878 890
879 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); 891 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
@@ -1107,6 +1119,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
1107 rtnl_lock(); 1119 rtnl_lock();
1108 ret = macvtap_ioctl_set_queue(file, u); 1120 ret = macvtap_ioctl_set_queue(file, u);
1109 rtnl_unlock(); 1121 rtnl_unlock();
1122 return ret;
1110 1123
1111 case TUNGETFEATURES: 1124 case TUNGETFEATURES:
1112 if (put_user(IFF_TAP | IFF_NO_PI | IFF_VNET_HDR | 1125 if (put_user(IFF_TAP | IFF_NO_PI | IFF_VNET_HDR |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 5cdcf92eb310..db690a372260 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1035,6 +1035,29 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
1035 return 0; 1035 return 0;
1036} 1036}
1037 1037
1038static unsigned long iov_pages(const struct iovec *iv, int offset,
1039 unsigned long nr_segs)
1040{
1041 unsigned long seg, base;
1042 int pages = 0, len, size;
1043
1044 while (nr_segs && (offset >= iv->iov_len)) {
1045 offset -= iv->iov_len;
1046 ++iv;
1047 --nr_segs;
1048 }
1049
1050 for (seg = 0; seg < nr_segs; seg++) {
1051 base = (unsigned long)iv[seg].iov_base + offset;
1052 len = iv[seg].iov_len - offset;
1053 size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
1054 pages += size;
1055 offset = 0;
1056 }
1057
1058 return pages;
1059}
1060
1038/* Get packet from user space buffer */ 1061/* Get packet from user space buffer */
1039static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, 1062static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1040 void *msg_control, const struct iovec *iv, 1063 void *msg_control, const struct iovec *iv,
@@ -1082,32 +1105,18 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1082 return -EINVAL; 1105 return -EINVAL;
1083 } 1106 }
1084 1107
1085 if (msg_control) 1108 if (msg_control) {
1086 zerocopy = true; 1109 /* There are 256 bytes to be copied in skb, so there is
1087 1110 * enough room for skb expand head in case it is used.
1088 if (zerocopy) {
1089 /* Userspace may produce vectors with count greater than
1090 * MAX_SKB_FRAGS, so we need to linearize parts of the skb
1091 * to let the rest of data to be fit in the frags.
1092 */
1093 if (count > MAX_SKB_FRAGS) {
1094 copylen = iov_length(iv, count - MAX_SKB_FRAGS);
1095 if (copylen < offset)
1096 copylen = 0;
1097 else
1098 copylen -= offset;
1099 } else
1100 copylen = 0;
1101 /* There are 256 bytes to be copied in skb, so there is enough
1102 * room for skb expand head in case it is used.
1103 * The rest of the buffer is mapped from userspace. 1111 * The rest of the buffer is mapped from userspace.
1104 */ 1112 */
1105 if (copylen < gso.hdr_len) 1113 copylen = gso.hdr_len ? gso.hdr_len : GOODCOPY_LEN;
1106 copylen = gso.hdr_len;
1107 if (!copylen)
1108 copylen = GOODCOPY_LEN;
1109 linear = copylen; 1114 linear = copylen;
1110 } else { 1115 if (iov_pages(iv, offset + copylen, count) <= MAX_SKB_FRAGS)
1116 zerocopy = true;
1117 }
1118
1119 if (!zerocopy) {
1111 copylen = len; 1120 copylen = len;
1112 linear = gso.hdr_len; 1121 linear = gso.hdr_len;
1113 } 1122 }
@@ -1121,8 +1130,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1121 1130
1122 if (zerocopy) 1131 if (zerocopy)
1123 err = zerocopy_sg_from_iovec(skb, iv, offset, count); 1132 err = zerocopy_sg_from_iovec(skb, iv, offset, count);
1124 else 1133 else {
1125 err = skb_copy_datagram_from_iovec(skb, 0, iv, offset, len); 1134 err = skb_copy_datagram_from_iovec(skb, 0, iv, offset, len);
1135 if (!err && msg_control) {
1136 struct ubuf_info *uarg = msg_control;
1137 uarg->callback(uarg, false);
1138 }
1139 }
1126 1140
1127 if (err) { 1141 if (err) {
1128 tun->dev->stats.rx_dropped++; 1142 tun->dev->stats.rx_dropped++;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 0ba1e7edbb1b..a5ba8dd7e6be 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1767,9 +1767,15 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
1767 1767
1768static void vxlan_dellink(struct net_device *dev, struct list_head *head) 1768static void vxlan_dellink(struct net_device *dev, struct list_head *head)
1769{ 1769{
1770 struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
1770 struct vxlan_dev *vxlan = netdev_priv(dev); 1771 struct vxlan_dev *vxlan = netdev_priv(dev);
1771 1772
1773 flush_workqueue(vxlan_wq);
1774
1775 spin_lock(&vn->sock_lock);
1772 hlist_del_rcu(&vxlan->hlist); 1776 hlist_del_rcu(&vxlan->hlist);
1777 spin_unlock(&vn->sock_lock);
1778
1773 list_del(&vxlan->next); 1779 list_del(&vxlan->next);
1774 unregister_netdevice_queue(dev, head); 1780 unregister_netdevice_queue(dev, head);
1775} 1781}
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index ff7f111fffee..36808bf25677 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -286,8 +286,7 @@ no_skb:
286 break; 286 break;
287 } 287 }
288 288
289 __skb_fill_page_desc(skb, 0, page, 0, 0); 289 skb_add_rx_frag(skb, 0, page, 0, 0, PAGE_SIZE);
290 skb_shinfo(skb)->nr_frags = 1;
291 __skb_queue_tail(&np->rx_batch, skb); 290 __skb_queue_tail(&np->rx_batch, skb);
292 } 291 }
293 292
@@ -831,7 +830,6 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,
831 struct sk_buff_head *list) 830 struct sk_buff_head *list)
832{ 831{
833 struct skb_shared_info *shinfo = skb_shinfo(skb); 832 struct skb_shared_info *shinfo = skb_shinfo(skb);
834 int nr_frags = shinfo->nr_frags;
835 RING_IDX cons = np->rx.rsp_cons; 833 RING_IDX cons = np->rx.rsp_cons;
836 struct sk_buff *nskb; 834 struct sk_buff *nskb;
837 835
@@ -840,19 +838,21 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,
840 RING_GET_RESPONSE(&np->rx, ++cons); 838 RING_GET_RESPONSE(&np->rx, ++cons);
841 skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0]; 839 skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0];
842 840
843 __skb_fill_page_desc(skb, nr_frags, 841 if (shinfo->nr_frags == MAX_SKB_FRAGS) {
844 skb_frag_page(nfrag), 842 unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
845 rx->offset, rx->status);
846 843
847 skb->data_len += rx->status; 844 BUG_ON(pull_to <= skb_headlen(skb));
845 __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
846 }
847 BUG_ON(shinfo->nr_frags >= MAX_SKB_FRAGS);
848
849 skb_add_rx_frag(skb, shinfo->nr_frags, skb_frag_page(nfrag),
850 rx->offset, rx->status, PAGE_SIZE);
848 851
849 skb_shinfo(nskb)->nr_frags = 0; 852 skb_shinfo(nskb)->nr_frags = 0;
850 kfree_skb(nskb); 853 kfree_skb(nskb);
851
852 nr_frags++;
853 } 854 }
854 855
855 shinfo->nr_frags = nr_frags;
856 return cons; 856 return cons;
857} 857}
858 858
@@ -933,7 +933,8 @@ static int handle_incoming_queue(struct net_device *dev,
933 while ((skb = __skb_dequeue(rxq)) != NULL) { 933 while ((skb = __skb_dequeue(rxq)) != NULL) {
934 int pull_to = NETFRONT_SKB_CB(skb)->pull_to; 934 int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
935 935
936 __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); 936 if (pull_to > skb_headlen(skb))
937 __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
937 938
938 /* Ethernet work: Delayed to here as it peeks the header. */ 939 /* Ethernet work: Delayed to here as it peeks the header. */
939 skb->protocol = eth_type_trans(skb, dev); 940 skb->protocol = eth_type_trans(skb, dev);
@@ -1019,16 +1020,10 @@ err:
1019 skb_shinfo(skb)->frags[0].page_offset = rx->offset; 1020 skb_shinfo(skb)->frags[0].page_offset = rx->offset;
1020 skb_frag_size_set(&skb_shinfo(skb)->frags[0], rx->status); 1021 skb_frag_size_set(&skb_shinfo(skb)->frags[0], rx->status);
1021 skb->data_len = rx->status; 1022 skb->data_len = rx->status;
1023 skb->len += rx->status;
1022 1024
1023 i = xennet_fill_frags(np, skb, &tmpq); 1025 i = xennet_fill_frags(np, skb, &tmpq);
1024 1026
1025 /*
1026 * Truesize is the actual allocation size, even if the
1027 * allocation is only partially used.
1028 */
1029 skb->truesize += PAGE_SIZE * skb_shinfo(skb)->nr_frags;
1030 skb->len += skb->data_len;
1031
1032 if (rx->flags & XEN_NETRXF_csum_blank) 1027 if (rx->flags & XEN_NETRXF_csum_blank)
1033 skb->ip_summed = CHECKSUM_PARTIAL; 1028 skb->ip_summed = CHECKSUM_PARTIAL;
1034 else if (rx->flags & XEN_NETRXF_data_validated) 1029 else if (rx->flags & XEN_NETRXF_data_validated)
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index a3c1c5aae6a9..1264923ade0f 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -345,6 +345,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
345 if (r && irq) { 345 if (r && irq) {
346 const char *name = NULL; 346 const char *name = NULL;
347 347
348 memset(r, 0, sizeof(*r));
348 /* 349 /*
349 * Get optional "interrupts-names" property to add a name 350 * Get optional "interrupts-names" property to add a name
350 * to the resource. 351 * to the resource.
@@ -482,8 +483,9 @@ void __init of_irq_init(const struct of_device_id *matches)
482 } 483 }
483 484
484 /* Get the next pending parent that might have children */ 485 /* Get the next pending parent that might have children */
485 desc = list_first_entry(&intc_parent_list, typeof(*desc), list); 486 desc = list_first_entry_or_null(&intc_parent_list,
486 if (list_empty(&intc_parent_list) || !desc) { 487 typeof(*desc), list);
488 if (!desc) {
487 pr_err("of_irq_init: children remain, but no parents\n"); 489 pr_err("of_irq_init: children remain, but no parents\n");
488 break; 490 break;
489 } 491 }
diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
index 93404f72dfa8..61be1d9c16c8 100644
--- a/drivers/oprofile/timer_int.c
+++ b/drivers/oprofile/timer_int.c
@@ -74,8 +74,8 @@ static void oprofile_hrtimer_stop(void)
74 put_online_cpus(); 74 put_online_cpus();
75} 75}
76 76
77static int __cpuinit oprofile_cpu_notify(struct notifier_block *self, 77static int oprofile_cpu_notify(struct notifier_block *self,
78 unsigned long action, void *hcpu) 78 unsigned long action, void *hcpu)
79{ 79{
80 long cpu = (long) hcpu; 80 long cpu = (long) hcpu;
81 81
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index b29e20b7862f..bb7af78e4eed 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -388,7 +388,6 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
388 /* Remove the EADS bridge device itself */ 388 /* Remove the EADS bridge device itself */
389 BUG_ON(!bus->self); 389 BUG_ON(!bus->self);
390 pr_debug("PCI: Now removing bridge device %s\n", pci_name(bus->self)); 390 pr_debug("PCI: Now removing bridge device %s\n", pci_name(bus->self));
391 eeh_remove_bus_device(bus->self, true);
392 pci_stop_and_remove_bus_device(bus->self); 391 pci_stop_and_remove_bus_device(bus->self);
393 392
394 return 0; 393 return 0;
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 5b272bfd261d..2a00239661b3 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1193,6 +1193,7 @@ void pinctrl_unregister_map(struct pinctrl_map const *map)
1193 list_for_each_entry(maps_node, &pinctrl_maps, node) { 1193 list_for_each_entry(maps_node, &pinctrl_maps, node) {
1194 if (maps_node->maps == map) { 1194 if (maps_node->maps == map) {
1195 list_del(&maps_node->node); 1195 list_del(&maps_node->node);
1196 kfree(maps_node);
1196 mutex_unlock(&pinctrl_maps_mutex); 1197 mutex_unlock(&pinctrl_maps_mutex);
1197 return; 1198 return;
1198 } 1199 }
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 6866548fab31..7323cca440b5 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1483,6 +1483,7 @@ static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs)
1483 return ret; 1483 return ret;
1484} 1484}
1485 1485
1486#ifdef CONFIG_PM
1486static int pinctrl_single_suspend(struct platform_device *pdev, 1487static int pinctrl_single_suspend(struct platform_device *pdev,
1487 pm_message_t state) 1488 pm_message_t state)
1488{ 1489{
@@ -1505,6 +1506,7 @@ static int pinctrl_single_resume(struct platform_device *pdev)
1505 1506
1506 return pinctrl_force_default(pcs->pctl); 1507 return pinctrl_force_default(pcs->pctl);
1507} 1508}
1509#endif
1508 1510
1509static int pcs_probe(struct platform_device *pdev) 1511static int pcs_probe(struct platform_device *pdev)
1510{ 1512{
diff --git a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c
index 7956df58d751..31f7d0e04aaa 100644
--- a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c
+++ b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c
@@ -3785,6 +3785,7 @@ static const struct regulator_desc sh73a0_vccq_mc0_desc = {
3785 3785
3786static struct regulator_consumer_supply sh73a0_vccq_mc0_consumers[] = { 3786static struct regulator_consumer_supply sh73a0_vccq_mc0_consumers[] = {
3787 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), 3787 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
3788 REGULATOR_SUPPLY("vqmmc", "ee100000.sdhi"),
3788}; 3789};
3789 3790
3790static const struct regulator_init_data sh73a0_vccq_mc0_init_data = { 3791static const struct regulator_init_data sh73a0_vccq_mc0_init_data = {
diff --git a/drivers/pinctrl/sirf/pinctrl-atlas6.c b/drivers/pinctrl/sirf/pinctrl-atlas6.c
index 1fa39a444171..867c9681763c 100644
--- a/drivers/pinctrl/sirf/pinctrl-atlas6.c
+++ b/drivers/pinctrl/sirf/pinctrl-atlas6.c
@@ -496,7 +496,7 @@ static const unsigned sdmmc5_pins[] = { 24, 25, 26 };
496static const struct sirfsoc_muxmask usp0_muxmask[] = { 496static const struct sirfsoc_muxmask usp0_muxmask[] = {
497 { 497 {
498 .group = 1, 498 .group = 1,
499 .mask = BIT(19) | BIT(20) | BIT(21) | BIT(22), 499 .mask = BIT(19) | BIT(20) | BIT(21) | BIT(22) | BIT(23),
500 }, 500 },
501}; 501};
502 502
@@ -507,8 +507,21 @@ static const struct sirfsoc_padmux usp0_padmux = {
507 .funcval = 0, 507 .funcval = 0,
508}; 508};
509 509
510static const unsigned usp0_pins[] = { 51, 52, 53, 54 }; 510static const unsigned usp0_pins[] = { 51, 52, 53, 54, 55 };
511 511
512static const struct sirfsoc_muxmask usp0_uart_nostreamctrl_muxmask[] = {
513 {
514 .group = 1,
515 .mask = BIT(20) | BIT(21),
516 },
517};
518
519static const struct sirfsoc_padmux usp0_uart_nostreamctrl_padmux = {
520 .muxmask_counts = ARRAY_SIZE(usp0_uart_nostreamctrl_muxmask),
521 .muxmask = usp0_uart_nostreamctrl_muxmask,
522};
523
524static const unsigned usp0_uart_nostreamctrl_pins[] = { 52, 53 };
512static const struct sirfsoc_muxmask usp1_muxmask[] = { 525static const struct sirfsoc_muxmask usp1_muxmask[] = {
513 { 526 {
514 .group = 0, 527 .group = 0,
@@ -822,6 +835,8 @@ static const struct sirfsoc_pin_group sirfsoc_pin_groups[] = {
822 SIRFSOC_PIN_GROUP("uart2grp", uart2_pins), 835 SIRFSOC_PIN_GROUP("uart2grp", uart2_pins),
823 SIRFSOC_PIN_GROUP("uart2_nostreamctrlgrp", uart2_nostreamctrl_pins), 836 SIRFSOC_PIN_GROUP("uart2_nostreamctrlgrp", uart2_nostreamctrl_pins),
824 SIRFSOC_PIN_GROUP("usp0grp", usp0_pins), 837 SIRFSOC_PIN_GROUP("usp0grp", usp0_pins),
838 SIRFSOC_PIN_GROUP("usp0_uart_nostreamctrl_grp",
839 usp0_uart_nostreamctrl_pins),
825 SIRFSOC_PIN_GROUP("usp1grp", usp1_pins), 840 SIRFSOC_PIN_GROUP("usp1grp", usp1_pins),
826 SIRFSOC_PIN_GROUP("i2c0grp", i2c0_pins), 841 SIRFSOC_PIN_GROUP("i2c0grp", i2c0_pins),
827 SIRFSOC_PIN_GROUP("i2c1grp", i2c1_pins), 842 SIRFSOC_PIN_GROUP("i2c1grp", i2c1_pins),
@@ -862,6 +877,8 @@ static const char * const uart0grp[] = { "uart0grp" };
862static const char * const uart1grp[] = { "uart1grp" }; 877static const char * const uart1grp[] = { "uart1grp" };
863static const char * const uart2grp[] = { "uart2grp" }; 878static const char * const uart2grp[] = { "uart2grp" };
864static const char * const uart2_nostreamctrlgrp[] = { "uart2_nostreamctrlgrp" }; 879static const char * const uart2_nostreamctrlgrp[] = { "uart2_nostreamctrlgrp" };
880static const char * const usp0_uart_nostreamctrl_grp[] = {
881 "usp0_uart_nostreamctrl_grp" };
865static const char * const usp0grp[] = { "usp0grp" }; 882static const char * const usp0grp[] = { "usp0grp" };
866static const char * const usp1grp[] = { "usp1grp" }; 883static const char * const usp1grp[] = { "usp1grp" };
867static const char * const i2c0grp[] = { "i2c0grp" }; 884static const char * const i2c0grp[] = { "i2c0grp" };
@@ -904,6 +921,9 @@ static const struct sirfsoc_pmx_func sirfsoc_pmx_functions[] = {
904 SIRFSOC_PMX_FUNCTION("uart2", uart2grp, uart2_padmux), 921 SIRFSOC_PMX_FUNCTION("uart2", uart2grp, uart2_padmux),
905 SIRFSOC_PMX_FUNCTION("uart2_nostreamctrl", uart2_nostreamctrlgrp, uart2_nostreamctrl_padmux), 922 SIRFSOC_PMX_FUNCTION("uart2_nostreamctrl", uart2_nostreamctrlgrp, uart2_nostreamctrl_padmux),
906 SIRFSOC_PMX_FUNCTION("usp0", usp0grp, usp0_padmux), 923 SIRFSOC_PMX_FUNCTION("usp0", usp0grp, usp0_padmux),
924 SIRFSOC_PMX_FUNCTION("usp0_uart_nostreamctrl",
925 usp0_uart_nostreamctrl_grp,
926 usp0_uart_nostreamctrl_padmux),
907 SIRFSOC_PMX_FUNCTION("usp1", usp1grp, usp1_padmux), 927 SIRFSOC_PMX_FUNCTION("usp1", usp1grp, usp1_padmux),
908 SIRFSOC_PMX_FUNCTION("i2c0", i2c0grp, i2c0_padmux), 928 SIRFSOC_PMX_FUNCTION("i2c0", i2c0grp, i2c0_padmux),
909 SIRFSOC_PMX_FUNCTION("i2c1", i2c1grp, i2c1_padmux), 929 SIRFSOC_PMX_FUNCTION("i2c1", i2c1grp, i2c1_padmux),
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 9847ab163829..167f3d00c916 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -180,7 +180,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
180 struct pnp_dev *dev = data; 180 struct pnp_dev *dev = data;
181 struct acpi_resource_dma *dma; 181 struct acpi_resource_dma *dma;
182 struct acpi_resource_vendor_typed *vendor_typed; 182 struct acpi_resource_vendor_typed *vendor_typed;
183 struct resource r; 183 struct resource r = {0};
184 int i, flags; 184 int i, flags;
185 185
186 if (acpi_dev_resource_memory(res, &r) 186 if (acpi_dev_resource_memory(res, &r)
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 3e6db1c1dc29..d95e101ffb43 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -515,6 +515,7 @@ struct pnp_resource *pnp_add_resource(struct pnp_dev *dev,
515 } 515 }
516 516
517 pnp_res->res = *res; 517 pnp_res->res = *res;
518 pnp_res->res.name = dev->name;
518 dev_dbg(&dev->dev, "%pR\n", res); 519 dev_dbg(&dev->dev, "%pR\n", res);
519 return pnp_res; 520 return pnp_res;
520} 521}
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index fb1c1e0483ed..8ed52aa49122 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -1497,7 +1497,7 @@ static inline int buf_in_between(int bufnr, int start, int count)
1497static int handle_inbound(struct qdio_q *q, unsigned int callflags, 1497static int handle_inbound(struct qdio_q *q, unsigned int callflags,
1498 int bufnr, int count) 1498 int bufnr, int count)
1499{ 1499{
1500 int used, diff; 1500 int diff;
1501 1501
1502 qperf_inc(q, inbound_call); 1502 qperf_inc(q, inbound_call);
1503 1503
@@ -1530,7 +1530,7 @@ static int handle_inbound(struct qdio_q *q, unsigned int callflags,
1530 1530
1531set: 1531set:
1532 count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); 1532 count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count);
1533 used = atomic_add_return(count, &q->nr_buf_used) - count; 1533 atomic_add(count, &q->nr_buf_used);
1534 1534
1535 if (need_siga_in(q)) 1535 if (need_siga_in(q))
1536 return qdio_siga_input(q); 1536 return qdio_siga_input(q);
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index f446a7705c3b..d4174b82a1a9 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -71,6 +71,7 @@ MODULE_AUTHOR("IBM Corporation");
71MODULE_DESCRIPTION("Adjunct Processor Bus driver, " \ 71MODULE_DESCRIPTION("Adjunct Processor Bus driver, " \
72 "Copyright IBM Corp. 2006, 2012"); 72 "Copyright IBM Corp. 2006, 2012");
73MODULE_LICENSE("GPL"); 73MODULE_LICENSE("GPL");
74MODULE_ALIAS("z90crypt");
74 75
75/* 76/*
76 * Module parameter 77 * Module parameter
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 7b082157eb79..99d2930b18c8 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -185,7 +185,7 @@ static void sci_io_request_build_ssp_command_iu(struct isci_request *ireq)
185 cmd_iu->_r_c = 0; 185 cmd_iu->_r_c = 0;
186 186
187 sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cmd->cmnd, 187 sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cmd->cmnd,
188 task->ssp_task.cmd->cmd_len / sizeof(u32)); 188 (task->ssp_task.cmd->cmd_len+3) / sizeof(u32));
189} 189}
190 190
191static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq) 191static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq)
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 9bb020ac089c..0d30ca849e8f 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -491,6 +491,7 @@ int isci_task_abort_task(struct sas_task *task)
491 struct isci_tmf tmf; 491 struct isci_tmf tmf;
492 int ret = TMF_RESP_FUNC_FAILED; 492 int ret = TMF_RESP_FUNC_FAILED;
493 unsigned long flags; 493 unsigned long flags;
494 int target_done_already = 0;
494 495
495 /* Get the isci_request reference from the task. Note that 496 /* Get the isci_request reference from the task. Note that
496 * this check does not depend on the pending request list 497 * this check does not depend on the pending request list
@@ -505,9 +506,11 @@ int isci_task_abort_task(struct sas_task *task)
505 /* If task is already done, the request isn't valid */ 506 /* If task is already done, the request isn't valid */
506 if (!(task->task_state_flags & SAS_TASK_STATE_DONE) && 507 if (!(task->task_state_flags & SAS_TASK_STATE_DONE) &&
507 (task->task_state_flags & SAS_TASK_AT_INITIATOR) && 508 (task->task_state_flags & SAS_TASK_AT_INITIATOR) &&
508 old_request) 509 old_request) {
509 idev = isci_get_device(task->dev->lldd_dev); 510 idev = isci_get_device(task->dev->lldd_dev);
510 511 target_done_already = test_bit(IREQ_COMPLETE_IN_TARGET,
512 &old_request->flags);
513 }
511 spin_unlock(&task->task_state_lock); 514 spin_unlock(&task->task_state_lock);
512 spin_unlock_irqrestore(&ihost->scic_lock, flags); 515 spin_unlock_irqrestore(&ihost->scic_lock, flags);
513 516
@@ -561,7 +564,7 @@ int isci_task_abort_task(struct sas_task *task)
561 564
562 if (task->task_proto == SAS_PROTOCOL_SMP || 565 if (task->task_proto == SAS_PROTOCOL_SMP ||
563 sas_protocol_ata(task->task_proto) || 566 sas_protocol_ata(task->task_proto) ||
564 test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags) || 567 target_done_already ||
565 test_bit(IDEV_GONE, &idev->flags)) { 568 test_bit(IDEV_GONE, &idev->flags)) {
566 569
567 spin_unlock_irqrestore(&ihost->scic_lock, flags); 570 spin_unlock_irqrestore(&ihost->scic_lock, flags);
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index f14665a6293d..6b1b4e91e53f 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -1857,11 +1857,16 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
1857 goto out; 1857 goto out;
1858 } 1858 }
1859 1859
1860 /* error info record present */ 1860 /*
1861 if (unlikely((rx_desc & RXQ_ERR) && (*(u64 *) slot->response))) { 1861 * error info record present; slot->response is 32 bit aligned but may
1862 * not be 64 bit aligned, so check for zero in two 32 bit reads
1863 */
1864 if (unlikely((rx_desc & RXQ_ERR)
1865 && (*((u32 *)slot->response)
1866 || *(((u32 *)slot->response) + 1)))) {
1862 mv_dprintk("port %d slot %d rx_desc %X has error info" 1867 mv_dprintk("port %d slot %d rx_desc %X has error info"
1863 "%016llX.\n", slot->port->sas_port.id, slot_idx, 1868 "%016llX.\n", slot->port->sas_port.id, slot_idx,
1864 rx_desc, (u64)(*(u64 *)slot->response)); 1869 rx_desc, get_unaligned_le64(slot->response));
1865 tstat->stat = mvs_slot_err(mvi, task, slot_idx); 1870 tstat->stat = mvs_slot_err(mvi, task, slot_idx);
1866 tstat->resp = SAS_TASK_COMPLETE; 1871 tstat->resp = SAS_TASK_COMPLETE;
1867 goto out; 1872 goto out;
diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
index 60e2fb7f2dca..d6b19dc80bee 100644
--- a/drivers/scsi/mvsas/mv_sas.h
+++ b/drivers/scsi/mvsas/mv_sas.h
@@ -39,6 +39,7 @@
39#include <linux/irq.h> 39#include <linux/irq.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/vmalloc.h> 41#include <linux/vmalloc.h>
42#include <asm/unaligned.h>
42#include <scsi/libsas.h> 43#include <scsi/libsas.h>
43#include <scsi/scsi.h> 44#include <scsi/scsi.h>
44#include <scsi/scsi_tcq.h> 45#include <scsi/scsi_tcq.h>
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 42ef481db942..ef0a5481b9dd 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -419,6 +419,8 @@ qla2x00_start_scsi(srb_t *sp)
419 __constant_cpu_to_le16(CF_SIMPLE_TAG); 419 __constant_cpu_to_le16(CF_SIMPLE_TAG);
420 break; 420 break;
421 } 421 }
422 } else {
423 cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
422 } 424 }
423 425
424 /* Load SCSI command packet. */ 426 /* Load SCSI command packet. */
@@ -1307,11 +1309,11 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
1307 fcp_cmnd->task_attribute = TSK_ORDERED; 1309 fcp_cmnd->task_attribute = TSK_ORDERED;
1308 break; 1310 break;
1309 default: 1311 default:
1310 fcp_cmnd->task_attribute = 0; 1312 fcp_cmnd->task_attribute = TSK_SIMPLE;
1311 break; 1313 break;
1312 } 1314 }
1313 } else { 1315 } else {
1314 fcp_cmnd->task_attribute = 0; 1316 fcp_cmnd->task_attribute = TSK_SIMPLE;
1315 } 1317 }
1316 1318
1317 cmd_pkt->fcp_rsp_dseg_len = 0; /* Let response come in status iocb */ 1319 cmd_pkt->fcp_rsp_dseg_len = 0; /* Let response come in status iocb */
@@ -1525,7 +1527,12 @@ qla24xx_start_scsi(srb_t *sp)
1525 case ORDERED_QUEUE_TAG: 1527 case ORDERED_QUEUE_TAG:
1526 cmd_pkt->task = TSK_ORDERED; 1528 cmd_pkt->task = TSK_ORDERED;
1527 break; 1529 break;
1530 default:
1531 cmd_pkt->task = TSK_SIMPLE;
1532 break;
1528 } 1533 }
1534 } else {
1535 cmd_pkt->task = TSK_SIMPLE;
1529 } 1536 }
1530 1537
1531 /* Load SCSI command packet. */ 1538 /* Load SCSI command packet. */
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 80f39b8b0223..86fcf2c313ad 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -838,10 +838,17 @@ static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq)
838 838
839static void sd_unprep_fn(struct request_queue *q, struct request *rq) 839static void sd_unprep_fn(struct request_queue *q, struct request *rq)
840{ 840{
841 struct scsi_cmnd *SCpnt = rq->special;
842
841 if (rq->cmd_flags & REQ_DISCARD) { 843 if (rq->cmd_flags & REQ_DISCARD) {
842 free_page((unsigned long)rq->buffer); 844 free_page((unsigned long)rq->buffer);
843 rq->buffer = NULL; 845 rq->buffer = NULL;
844 } 846 }
847 if (SCpnt->cmnd != rq->cmd) {
848 mempool_free(SCpnt->cmnd, sd_cdb_pool);
849 SCpnt->cmnd = NULL;
850 SCpnt->cmd_len = 0;
851 }
845} 852}
846 853
847/** 854/**
@@ -1720,21 +1727,6 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1720 if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt)) 1727 if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt))
1721 sd_dif_complete(SCpnt, good_bytes); 1728 sd_dif_complete(SCpnt, good_bytes);
1722 1729
1723 if (scsi_host_dif_capable(sdkp->device->host, sdkp->protection_type)
1724 == SD_DIF_TYPE2_PROTECTION && SCpnt->cmnd != SCpnt->request->cmd) {
1725
1726 /* We have to print a failed command here as the
1727 * extended CDB gets freed before scsi_io_completion()
1728 * is called.
1729 */
1730 if (result)
1731 scsi_print_command(SCpnt);
1732
1733 mempool_free(SCpnt->cmnd, sd_cdb_pool);
1734 SCpnt->cmnd = NULL;
1735 SCpnt->cmd_len = 0;
1736 }
1737
1738 return good_bytes; 1730 return good_bytes;
1739} 1731}
1740 1732
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c
index 5f84e0f3f4a4..e53caac13aec 100644
--- a/drivers/spi/spi-altera.c
+++ b/drivers/spi/spi-altera.c
@@ -103,6 +103,16 @@ static void altera_spi_chipsel(struct spi_device *spi, int value)
103 } 103 }
104} 104}
105 105
106static int altera_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
107{
108 return 0;
109}
110
111static int altera_spi_setup(struct spi_device *spi)
112{
113 return 0;
114}
115
106static inline unsigned int hw_txbyte(struct altera_spi *hw, int count) 116static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
107{ 117{
108 if (hw->tx) { 118 if (hw->tx) {
@@ -221,6 +231,7 @@ static int altera_spi_probe(struct platform_device *pdev)
221 master->bus_num = pdev->id; 231 master->bus_num = pdev->id;
222 master->num_chipselect = 16; 232 master->num_chipselect = 16;
223 master->mode_bits = SPI_CS_HIGH; 233 master->mode_bits = SPI_CS_HIGH;
234 master->setup = altera_spi_setup;
224 235
225 hw = spi_master_get_devdata(master); 236 hw = spi_master_get_devdata(master);
226 platform_set_drvdata(pdev, hw); 237 platform_set_drvdata(pdev, hw);
@@ -229,6 +240,7 @@ static int altera_spi_probe(struct platform_device *pdev)
229 hw->bitbang.master = spi_master_get(master); 240 hw->bitbang.master = spi_master_get(master);
230 if (!hw->bitbang.master) 241 if (!hw->bitbang.master)
231 return err; 242 return err;
243 hw->bitbang.setup_transfer = altera_spi_setupxfer;
232 hw->bitbang.chipselect = altera_spi_chipsel; 244 hw->bitbang.chipselect = altera_spi_chipsel;
233 hw->bitbang.txrx_bufs = altera_spi_txrx; 245 hw->bitbang.txrx_bufs = altera_spi_txrx;
234 246
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c
index d98244bb4c6c..e19a3074ac53 100644
--- a/drivers/spi/spi-nuc900.c
+++ b/drivers/spi/spi-nuc900.c
@@ -174,6 +174,17 @@ static void nuc900_spi_gobusy(struct nuc900_spi *hw)
174 spin_unlock_irqrestore(&hw->lock, flags); 174 spin_unlock_irqrestore(&hw->lock, flags);
175} 175}
176 176
177static int nuc900_spi_setupxfer(struct spi_device *spi,
178 struct spi_transfer *t)
179{
180 return 0;
181}
182
183static int nuc900_spi_setup(struct spi_device *spi)
184{
185 return 0;
186}
187
177static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count) 188static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count)
178{ 189{
179 return hw->tx ? hw->tx[count] : 0; 190 return hw->tx ? hw->tx[count] : 0;
@@ -366,8 +377,10 @@ static int nuc900_spi_probe(struct platform_device *pdev)
366 master->num_chipselect = hw->pdata->num_cs; 377 master->num_chipselect = hw->pdata->num_cs;
367 master->bus_num = hw->pdata->bus_num; 378 master->bus_num = hw->pdata->bus_num;
368 hw->bitbang.master = hw->master; 379 hw->bitbang.master = hw->master;
380 hw->bitbang.setup_transfer = nuc900_spi_setupxfer;
369 hw->bitbang.chipselect = nuc900_spi_chipsel; 381 hw->bitbang.chipselect = nuc900_spi_chipsel;
370 hw->bitbang.txrx_bufs = nuc900_spi_txrx; 382 hw->bitbang.txrx_bufs = nuc900_spi_txrx;
383 hw->bitbang.master->setup = nuc900_spi_setup;
371 384
372 hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 385 hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
373 if (hw->res == NULL) { 386 if (hw->res == NULL) {
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index aa5fc52abd04..57de139f76dc 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -564,8 +564,12 @@ static void rspi_work(struct work_struct *work)
564 unsigned long flags; 564 unsigned long flags;
565 int ret; 565 int ret;
566 566
567 spin_lock_irqsave(&rspi->lock, flags); 567 while (1) {
568 while (!list_empty(&rspi->queue)) { 568 spin_lock_irqsave(&rspi->lock, flags);
569 if (list_empty(&rspi->queue)) {
570 spin_unlock_irqrestore(&rspi->lock, flags);
571 break;
572 }
569 mesg = list_entry(rspi->queue.next, struct spi_message, queue); 573 mesg = list_entry(rspi->queue.next, struct spi_message, queue);
570 list_del_init(&mesg->queue); 574 list_del_init(&mesg->queue);
571 spin_unlock_irqrestore(&rspi->lock, flags); 575 spin_unlock_irqrestore(&rspi->lock, flags);
@@ -595,8 +599,6 @@ static void rspi_work(struct work_struct *work)
595 599
596 mesg->status = 0; 600 mesg->status = 0;
597 mesg->complete(mesg->context); 601 mesg->complete(mesg->context);
598
599 spin_lock_irqsave(&rspi->lock, flags);
600 } 602 }
601 603
602 return; 604 return;
@@ -665,11 +667,12 @@ static int rspi_request_dma(struct rspi_data *rspi,
665 struct platform_device *pdev) 667 struct platform_device *pdev)
666{ 668{
667 struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev); 669 struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
670 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
668 dma_cap_mask_t mask; 671 dma_cap_mask_t mask;
669 struct dma_slave_config cfg; 672 struct dma_slave_config cfg;
670 int ret; 673 int ret;
671 674
672 if (!rspi_pd) 675 if (!res || !rspi_pd)
673 return 0; /* The driver assumes no error. */ 676 return 0; /* The driver assumes no error. */
674 677
675 rspi->dma_width_16bit = rspi_pd->dma_width_16bit; 678 rspi->dma_width_16bit = rspi_pd->dma_width_16bit;
@@ -683,6 +686,8 @@ static int rspi_request_dma(struct rspi_data *rspi,
683 if (rspi->chan_rx) { 686 if (rspi->chan_rx) {
684 cfg.slave_id = rspi_pd->dma_rx_id; 687 cfg.slave_id = rspi_pd->dma_rx_id;
685 cfg.direction = DMA_DEV_TO_MEM; 688 cfg.direction = DMA_DEV_TO_MEM;
689 cfg.dst_addr = 0;
690 cfg.src_addr = res->start + RSPI_SPDR;
686 ret = dmaengine_slave_config(rspi->chan_rx, &cfg); 691 ret = dmaengine_slave_config(rspi->chan_rx, &cfg);
687 if (!ret) 692 if (!ret)
688 dev_info(&pdev->dev, "Use DMA when rx.\n"); 693 dev_info(&pdev->dev, "Use DMA when rx.\n");
@@ -698,6 +703,8 @@ static int rspi_request_dma(struct rspi_data *rspi,
698 if (rspi->chan_tx) { 703 if (rspi->chan_tx) {
699 cfg.slave_id = rspi_pd->dma_tx_id; 704 cfg.slave_id = rspi_pd->dma_tx_id;
700 cfg.direction = DMA_MEM_TO_DEV; 705 cfg.direction = DMA_MEM_TO_DEV;
706 cfg.dst_addr = res->start + RSPI_SPDR;
707 cfg.src_addr = 0;
701 ret = dmaengine_slave_config(rspi->chan_tx, &cfg); 708 ret = dmaengine_slave_config(rspi->chan_tx, &cfg);
702 if (!ret) 709 if (!ret)
703 dev_info(&pdev->dev, "Use DMA when tx\n"); 710 dev_info(&pdev->dev, "Use DMA when tx\n");
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 25cf6716c8ed..2465d6d35b06 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -434,6 +434,9 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi)
434 dma_cap_mask_t mask; 434 dma_cap_mask_t mask;
435 int ret; 435 int ret;
436 436
437 if (is_polling(sdd))
438 return 0;
439
437 dma_cap_zero(mask); 440 dma_cap_zero(mask);
438 dma_cap_set(DMA_SLAVE, mask); 441 dma_cap_set(DMA_SLAVE, mask);
439 442
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 0bf1b2c457a1..08ea84a6eb32 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -232,6 +232,21 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
232 return 0; 232 return 0;
233} 233}
234 234
235static int xilinx_spi_setup(struct spi_device *spi)
236{
237 /* always return 0, we can not check the number of bits.
238 * There are cases when SPI setup is called before any driver is
239 * there, in that case the SPI core defaults to 8 bits, which we
240 * do not support in some cases. But if we return an error, the
241 * SPI device would not be registered and no driver can get hold of it
242 * When the driver is there, it will call SPI setup again with the
243 * correct number of bits per transfer.
244 * If a driver setups with the wrong bit number, it will fail when
245 * it tries to do a transfer
246 */
247 return 0;
248}
249
235static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi) 250static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
236{ 251{
237 u8 sr; 252 u8 sr;
@@ -376,6 +391,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
376 xspi->bitbang.chipselect = xilinx_spi_chipselect; 391 xspi->bitbang.chipselect = xilinx_spi_chipselect;
377 xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer; 392 xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer;
378 xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; 393 xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs;
394 xspi->bitbang.master->setup = xilinx_spi_setup;
379 init_completion(&xspi->done); 395 init_completion(&xspi->done);
380 396
381 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 397 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 3227ebeae3f1..57d8b3444600 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -118,8 +118,6 @@ source "drivers/staging/ozwpan/Kconfig"
118 118
119source "drivers/staging/gdm72xx/Kconfig" 119source "drivers/staging/gdm72xx/Kconfig"
120 120
121source "drivers/staging/csr/Kconfig"
122
123source "drivers/staging/silicom/Kconfig" 121source "drivers/staging/silicom/Kconfig"
124 122
125source "drivers/staging/ced1401/Kconfig" 123source "drivers/staging/ced1401/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 4d79ebe2de06..429321f15105 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -52,7 +52,6 @@ obj-$(CONFIG_MFD_NVEC) += nvec/
52obj-$(CONFIG_ANDROID) += android/ 52obj-$(CONFIG_ANDROID) += android/
53obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ 53obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
54obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/ 54obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
55obj-$(CONFIG_CSR_WIFI) += csr/
56obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/ 55obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/
57obj-$(CONFIG_CED1401) += ced1401/ 56obj-$(CONFIG_CED1401) += ced1401/
58obj-$(CONFIG_DRM_IMX) += imx-drm/ 57obj-$(CONFIG_DRM_IMX) += imx-drm/
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index 080abf2faf97..a8c344422a77 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -469,7 +469,7 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
469 unsigned long nr_segs, loff_t ppos) 469 unsigned long nr_segs, loff_t ppos)
470{ 470{
471 struct logger_log *log = file_get_log(iocb->ki_filp); 471 struct logger_log *log = file_get_log(iocb->ki_filp);
472 size_t orig = log->w_off; 472 size_t orig;
473 struct logger_entry header; 473 struct logger_entry header;
474 struct timespec now; 474 struct timespec now;
475 ssize_t ret = 0; 475 ssize_t ret = 0;
@@ -490,6 +490,8 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
490 490
491 mutex_lock(&log->mutex); 491 mutex_lock(&log->mutex);
492 492
493 orig = log->w_off;
494
493 /* 495 /*
494 * Fix up any readers, pulling them forward to the first readable 496 * Fix up any readers, pulling them forward to the first readable
495 * entry after (what will be) the new write offset. We do this now 497 * entry after (what will be) the new write offset. We do this now
diff --git a/drivers/staging/comedi/TODO b/drivers/staging/comedi/TODO
index b10f739b7e3e..fa8da9aada30 100644
--- a/drivers/staging/comedi/TODO
+++ b/drivers/staging/comedi/TODO
@@ -9,4 +9,4 @@ TODO:
9Please send patches to Greg Kroah-Hartman <greg@kroah.com> and 9Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
10copy: 10copy:
11 Ian Abbott <abbotti@mev.co.uk> 11 Ian Abbott <abbotti@mev.co.uk>
12 Frank Mori Hess <fmhess@users.sourceforge.net> 12 H Hartley Sweeten <hsweeten@visionengravers.com>
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 8647518259f6..f4a197b2d1fd 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1413,22 +1413,19 @@ static int do_cmd_ioctl(struct comedi_device *dev,
1413 DPRINTK("subdevice busy\n"); 1413 DPRINTK("subdevice busy\n");
1414 return -EBUSY; 1414 return -EBUSY;
1415 } 1415 }
1416 s->busy = file;
1417 1416
1418 /* make sure channel/gain list isn't too long */ 1417 /* make sure channel/gain list isn't too long */
1419 if (cmd.chanlist_len > s->len_chanlist) { 1418 if (cmd.chanlist_len > s->len_chanlist) {
1420 DPRINTK("channel/gain list too long %u > %d\n", 1419 DPRINTK("channel/gain list too long %u > %d\n",
1421 cmd.chanlist_len, s->len_chanlist); 1420 cmd.chanlist_len, s->len_chanlist);
1422 ret = -EINVAL; 1421 return -EINVAL;
1423 goto cleanup;
1424 } 1422 }
1425 1423
1426 /* make sure channel/gain list isn't too short */ 1424 /* make sure channel/gain list isn't too short */
1427 if (cmd.chanlist_len < 1) { 1425 if (cmd.chanlist_len < 1) {
1428 DPRINTK("channel/gain list too short %u < 1\n", 1426 DPRINTK("channel/gain list too short %u < 1\n",
1429 cmd.chanlist_len); 1427 cmd.chanlist_len);
1430 ret = -EINVAL; 1428 return -EINVAL;
1431 goto cleanup;
1432 } 1429 }
1433 1430
1434 async->cmd = cmd; 1431 async->cmd = cmd;
@@ -1438,8 +1435,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
1438 kmalloc(async->cmd.chanlist_len * sizeof(int), GFP_KERNEL); 1435 kmalloc(async->cmd.chanlist_len * sizeof(int), GFP_KERNEL);
1439 if (!async->cmd.chanlist) { 1436 if (!async->cmd.chanlist) {
1440 DPRINTK("allocation failed\n"); 1437 DPRINTK("allocation failed\n");
1441 ret = -ENOMEM; 1438 return -ENOMEM;
1442 goto cleanup;
1443 } 1439 }
1444 1440
1445 if (copy_from_user(async->cmd.chanlist, user_chanlist, 1441 if (copy_from_user(async->cmd.chanlist, user_chanlist,
@@ -1491,6 +1487,9 @@ static int do_cmd_ioctl(struct comedi_device *dev,
1491 1487
1492 comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING); 1488 comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING);
1493 1489
1490 /* set s->busy _after_ setting SRF_RUNNING flag to avoid race with
1491 * comedi_read() or comedi_write() */
1492 s->busy = file;
1494 ret = s->do_cmd(dev, s); 1493 ret = s->do_cmd(dev, s);
1495 if (ret == 0) 1494 if (ret == 0)
1496 return 0; 1495 return 0;
@@ -1705,6 +1704,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
1705 void *file) 1704 void *file)
1706{ 1705{
1707 struct comedi_subdevice *s; 1706 struct comedi_subdevice *s;
1707 int ret;
1708 1708
1709 if (arg >= dev->n_subdevices) 1709 if (arg >= dev->n_subdevices)
1710 return -EINVAL; 1710 return -EINVAL;
@@ -1721,7 +1721,11 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
1721 if (s->busy != file) 1721 if (s->busy != file)
1722 return -EBUSY; 1722 return -EBUSY;
1723 1723
1724 return do_cancel(dev, s); 1724 ret = do_cancel(dev, s);
1725 if (comedi_get_subdevice_runflags(s) & SRF_USER)
1726 wake_up_interruptible(&s->async->wait_head);
1727
1728 return ret;
1725} 1729}
1726 1730
1727/* 1731/*
@@ -2053,11 +2057,13 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
2053 2057
2054 if (!comedi_is_subdevice_running(s)) { 2058 if (!comedi_is_subdevice_running(s)) {
2055 if (count == 0) { 2059 if (count == 0) {
2060 mutex_lock(&dev->mutex);
2056 if (comedi_is_subdevice_in_error(s)) 2061 if (comedi_is_subdevice_in_error(s))
2057 retval = -EPIPE; 2062 retval = -EPIPE;
2058 else 2063 else
2059 retval = 0; 2064 retval = 0;
2060 do_become_nonbusy(dev, s); 2065 do_become_nonbusy(dev, s);
2066 mutex_unlock(&dev->mutex);
2061 } 2067 }
2062 break; 2068 break;
2063 } 2069 }
@@ -2156,11 +2162,13 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
2156 2162
2157 if (n == 0) { 2163 if (n == 0) {
2158 if (!comedi_is_subdevice_running(s)) { 2164 if (!comedi_is_subdevice_running(s)) {
2165 mutex_lock(&dev->mutex);
2159 do_become_nonbusy(dev, s); 2166 do_become_nonbusy(dev, s);
2160 if (comedi_is_subdevice_in_error(s)) 2167 if (comedi_is_subdevice_in_error(s))
2161 retval = -EPIPE; 2168 retval = -EPIPE;
2162 else 2169 else
2163 retval = 0; 2170 retval = 0;
2171 mutex_unlock(&dev->mutex);
2164 break; 2172 break;
2165 } 2173 }
2166 if (file->f_flags & O_NONBLOCK) { 2174 if (file->f_flags & O_NONBLOCK) {
@@ -2198,9 +2206,11 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
2198 buf += n; 2206 buf += n;
2199 break; /* makes device work like a pipe */ 2207 break; /* makes device work like a pipe */
2200 } 2208 }
2201 if (comedi_is_subdevice_idle(s) && 2209 if (comedi_is_subdevice_idle(s)) {
2202 async->buf_read_count - async->buf_write_count == 0) { 2210 mutex_lock(&dev->mutex);
2203 do_become_nonbusy(dev, s); 2211 if (async->buf_read_count - async->buf_write_count == 0)
2212 do_become_nonbusy(dev, s);
2213 mutex_unlock(&dev->mutex);
2204 } 2214 }
2205 set_current_state(TASK_RUNNING); 2215 set_current_state(TASK_RUNNING);
2206 remove_wait_queue(&async->wait_head, &wait); 2216 remove_wait_queue(&async->wait_head, &wait);
diff --git a/drivers/staging/csr/Kconfig b/drivers/staging/csr/Kconfig
deleted file mode 100644
index ad2a1096e920..000000000000
--- a/drivers/staging/csr/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
1config CSR_WIFI
2 tristate "CSR wireless driver"
3 depends on MMC && CFG80211_WEXT && INET
4 select WIRELESS_EXT
5 select WEXT_PRIV
6 help
7 Driver for the CSR wireless SDIO device.
8
9 If unsure, select N.
diff --git a/drivers/staging/csr/LICENSE.txt b/drivers/staging/csr/LICENSE.txt
deleted file mode 100644
index 364853e5fedc..000000000000
--- a/drivers/staging/csr/LICENSE.txt
+++ /dev/null
@@ -1,39 +0,0 @@
1Permission is hereby granted, free of charge, to any person obtaining
2a copy of this software and associated documentation files (the
3"Software"), to deal in the Software without restriction, including
4without limitation the rights to use, copy, modify, merge, publish,
5distribute, sublicense, and/or sell copies of the Software, and to
6permit persons to whom the Software is furnished to do so, subject to
7the following conditions:
8
9The above copyright notice and this permission notice shall be
10included in all copies or substantial portions of the Software.
11
12Except as contained in this notice, the names of above-listed
13copyright holders and the names of any contributors shall not be used
14in advertising or otherwise to promote the sale, use or other dealings
15in this Software without prior written authorization.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
23OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25
26Alternatively, this software may be distributed under the terms of the
27GNU General Public License ("GPL") version 2 as published
28by the Free Software Foundation.
29
30As a special exception, if other files instantiate templates or use
31macros or inline functions from this file, or you compile this file
32and link it with other works to produce a work based on this file,
33this file does not by itself cause the resulting work to be covered by
34the GNU General Public License. However the source code for this file
35must still be made available in accordance with section (3) of the GNU
36General Public License.
37
38This exception does not invalidate any other reasons why a work based
39on 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
index dbd135a8b177..000000000000
--- a/drivers/staging/csr/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
1ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG
2ccflags-y += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH
3ccflags-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
4
5obj-$(CONFIG_CSR_WIFI) += csr_wifi.o
6obj-$(CONFIG_CSR_WIFI) += csr_helper.o
7
8csr_wifi-y := bh.o \
9 data_tx.o \
10 drv.o \
11 firmware.o \
12 inet.o \
13 init_hw.o \
14 io.o \
15 monitor.o \
16 netdev.o \
17 os.o \
18 putest.o \
19 sdio_events.o \
20 sdio_mmc.o \
21 sdio_stubs.o \
22 sme_blocking.o \
23 ul_int.o \
24 unifi_dbg.o \
25 unifi_event.o \
26 unifi_pdu_processing.o \
27 unifi_sme.o \
28 csr_wifi_hip_card_sdio.o \
29 csr_wifi_hip_card_sdio_intr.o \
30 csr_wifi_hip_card_sdio_mem.o \
31 csr_wifi_hip_chiphelper.o \
32 csr_wifi_hip_download.o \
33 csr_wifi_hip_dump.o \
34 csr_wifi_hip_packing.o \
35 csr_wifi_hip_send.o \
36 csr_wifi_hip_signals.o \
37 csr_wifi_hip_ta_sampling.o \
38 csr_wifi_hip_udi.o \
39 csr_wifi_hip_unifi_signal_names.o \
40 csr_wifi_hip_xbv.o \
41 csr_wifi_nme_ap_converter_init.o \
42 csr_wifi_nme_ap_free_downstream_contents.o \
43 csr_wifi_nme_ap_free_upstream_contents.o \
44 csr_wifi_nme_ap_serialize.o \
45 csr_wifi_nme_ap_sef.o \
46 csr_wifi_router_ctrl_sef.o \
47 csr_wifi_router_sef.o \
48 csr_wifi_router_transport.o \
49 csr_wifi_sme_sef.o \
50 csr_wifi_sme_converter_init.o \
51 csr_wifi_sme_free_downstream_contents.o \
52 csr_wifi_sme_free_upstream_contents.o \
53 csr_wifi_sme_serialize.o \
54 csr_wifi_router_ctrl_converter_init.o \
55 csr_wifi_router_ctrl_free_downstream_contents.o \
56 csr_wifi_router_ctrl_free_upstream_contents.o \
57 csr_wifi_router_ctrl_serialize.o \
58 csr_wifi_router_converter_init.o \
59 csr_wifi_router_free_downstream_contents.o \
60 csr_wifi_router_free_upstream_contents.o \
61 csr_wifi_router_serialize.o \
62 sme_mgt.o \
63 sme_sys.o \
64 sme_userspace.o \
65 sme_wext.o \
66 wext_events.o
67
68csr_helper-y := csr_time.o \
69 csr_util.o \
70 csr_framework_ext.o \
71 csr_wifi_serialize_primitive_types.o \
72 csr_serialize_primitive_types.o \
73 csr_msgconv.o
diff --git a/drivers/staging/csr/bh.c b/drivers/staging/csr/bh.c
deleted file mode 100644
index d795852ccb1c..000000000000
--- a/drivers/staging/csr/bh.c
+++ /dev/null
@@ -1,404 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: bh.c
4 *
5 * PURPOSE:
6 * Provides an implementation for the driver bottom-half.
7 * It is part of the porting exercise in Linux.
8 *
9 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16#include "csr_wifi_hip_unifi.h"
17#include "unifi_priv.h"
18#include <linux/sched/rt.h>
19
20/*
21 * ---------------------------------------------------------------------------
22 * uf_start_thread
23 *
24 * Helper function to start a new thread.
25 *
26 * Arguments:
27 * priv Pointer to OS driver structure for the device.
28 * thread Pointer to the thread object
29 * func The thread function
30 *
31 * Returns:
32 * 0 on success or else a Linux error code.
33 * ---------------------------------------------------------------------------
34 */
35int uf_start_thread(unifi_priv_t *priv,
36 struct uf_thread *thread, int (*func)(void *))
37{
38 if (thread->thread_task != NULL) {
39 unifi_error(priv, "%s thread already started\n", thread->name);
40 return 0;
41 }
42
43 /* Start the kernel thread that handles all h/w accesses. */
44 thread->thread_task = kthread_run(func, priv, "%s", thread->name);
45 if (IS_ERR(thread->thread_task))
46 return PTR_ERR(thread->thread_task);
47
48 /* Module parameter overides the thread priority */
49 if (bh_priority != -1) {
50 if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) {
51 struct sched_param param;
52 priv->bh_thread.prio = bh_priority;
53 unifi_trace(priv, UDBG1,
54 "%s thread (RT) priority = %d\n",
55 thread->name, bh_priority);
56 param.sched_priority = bh_priority;
57 sched_setscheduler(thread->thread_task,
58 SCHED_FIFO, &param);
59 } else if (bh_priority > MAX_RT_PRIO &&
60 bh_priority <= MAX_PRIO) {
61 priv->bh_thread.prio = bh_priority;
62 unifi_trace(priv, UDBG1, "%s thread priority = %d\n",
63 thread->name,
64 PRIO_TO_NICE(bh_priority));
65 set_user_nice(thread->thread_task,
66 PRIO_TO_NICE(bh_priority));
67 } else {
68 priv->bh_thread.prio = DEFAULT_PRIO;
69 unifi_warning(priv,
70 "%s thread unsupported (%d) priority\n",
71 thread->name, bh_priority);
72 }
73 } else
74 priv->bh_thread.prio = DEFAULT_PRIO;
75 unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name);
76
77 return 0;
78} /* uf_start_thread() */
79
80
81/*
82 * ---------------------------------------------------------------------------
83 * uf_stop_thread
84 *
85 * Helper function to stop a thread.
86 *
87 * Arguments:
88 * priv Pointer to OS driver structure for the device.
89 * thread Pointer to the thread object
90 *
91 * Returns:
92 *
93 * ---------------------------------------------------------------------------
94 */
95void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread)
96{
97 if (!thread->thread_task) {
98 unifi_notice(priv, "%s thread is already stopped\n",
99 thread->name);
100 return;
101 }
102
103 unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name);
104
105 kthread_stop(thread->thread_task);
106 thread->thread_task = NULL;
107
108} /* uf_stop_thread() */
109
110
111
112/*
113 * ---------------------------------------------------------------------------
114 * uf_wait_for_thread_to_stop
115 *
116 * Helper function to wait until a thread is stopped.
117 *
118 * Arguments:
119 * priv Pointer to OS driver structure for the device.
120 *
121 * Returns:
122 *
123 * ---------------------------------------------------------------------------
124 */
125void
126uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread)
127{
128 /*
129 * kthread_stop() cannot handle the thread exiting while
130 * kthread_should_stop() is false, so sleep until kthread_stop()
131 * wakes us up
132 */
133 unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n",
134 thread->name);
135 set_current_state(TASK_INTERRUPTIBLE);
136 if (!kthread_should_stop()) {
137 unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name);
138 schedule();
139 }
140
141 thread->thread_task = NULL;
142 unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name);
143} /* uf_wait_for_thread_to_stop() */
144
145
146/*
147 * ---------------------------------------------------------------------------
148 * handle_bh_error
149 *
150 * This function reports an error returned from the HIP core bottom-half.
151 * Normally, implemented during the porting exercise, passing the error
152 * to the SME using unifi_sys_wifi_off_ind().
153 * The SME will try to reset the device and go through
154 * the initialisation of the UniFi.
155 *
156 * Arguments:
157 * priv Pointer to OS driver structure for the device.
158 *
159 * Returns:
160 * None.
161 * ---------------------------------------------------------------------------
162 */
163static void
164handle_bh_error(unifi_priv_t *priv)
165{
166 netInterface_priv_t *interfacePriv;
167 u8 conf_param = CONFIG_IND_ERROR;
168 u8 interfaceTag;
169
170
171 /* Block unifi_run_bh() until the error has been handled. */
172 priv->bh_thread.block_thread = 1;
173
174 /* Consider UniFi to be uninitialised */
175 priv->init_progress = UNIFI_INIT_NONE;
176
177 /* Stop the network traffic */
178 for (interfaceTag = 0;
179 interfaceTag < CSR_WIFI_NUM_INTERFACES; interfaceTag++) {
180 interfacePriv = priv->interfacePriv[interfaceTag];
181 if (interfacePriv->netdev_registered)
182 netif_carrier_off(priv->netdev[interfaceTag]);
183 }
184
185#ifdef CSR_NATIVE_LINUX
186 /* Force any client waiting on an mlme_wait_for_reply() to abort. */
187 uf_abort_mlme(priv);
188
189 /* Cancel any pending workqueue tasks */
190 flush_workqueue(priv->unifi_workqueue);
191
192#endif /* CSR_NATIVE_LINUX */
193
194 unifi_error(priv,
195 "handle_bh_error: fatal error is reported to the SME.\n");
196 /* Notify the clients (SME or unifi_manager) for the error. */
197 ul_log_config_ind(priv, &conf_param, sizeof(u8));
198
199} /* handle_bh_error() */
200
201
202
203/*
204 * ---------------------------------------------------------------------------
205 * bh_thread_function
206 *
207 * All hardware access happens in this thread.
208 * This means there is no need for locks on the hardware and we don't need
209 * to worry about reentrancy with the SDIO library.
210 * Provides and example implementation on how to call unifi_bh(), which
211 * is part of the HIP core API.
212 *
213 * It processes the events generated by unifi_run_bh() to serialise calls
214 * to unifi_bh(). It also demonstrates how the timeout parameter passed in
215 * and returned from unifi_bh() needs to be handled.
216 *
217 * Arguments:
218 * arg Pointer to OS driver structure for the device.
219 *
220 * Returns:
221 * None.
222 *
223 * Notes:
224 * When the bottom half of the driver needs to process signals, events,
225 * or simply the host status (i.e sleep mode), it invokes unifi_run_bh().
226 * Since we need all SDIO transaction to be in a single thread, the
227 * unifi_run_bh() will wake up this thread to process it.
228 *
229 * ---------------------------------------------------------------------------
230 */
231static int bh_thread_function(void *arg)
232{
233 unifi_priv_t *priv = (unifi_priv_t *)arg;
234 CsrResult csrResult;
235 long ret;
236 u32 timeout, t;
237 struct uf_thread *this_thread;
238
239 unifi_trace(priv, UDBG2, "bh_thread_function starting\n");
240
241 this_thread = &priv->bh_thread;
242
243 t = timeout = 0;
244 while (!kthread_should_stop()) {
245 /*
246 * wait until an error occurs,
247 * or we need to process something.
248 */
249 unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n");
250
251 if (timeout > 0) {
252 /* Convert t in ms to jiffies */
253 t = msecs_to_jiffies(timeout);
254 ret = wait_event_interruptible_timeout(
255 this_thread->wakeup_q,
256 (this_thread->wakeup_flag && !this_thread->block_thread) ||
257 kthread_should_stop(),
258 t);
259 timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0;
260 } else {
261 ret = wait_event_interruptible(this_thread->wakeup_q,
262 (this_thread->wakeup_flag && !this_thread->block_thread) ||
263 kthread_should_stop());
264 }
265
266 if (kthread_should_stop()) {
267 unifi_trace(priv, UDBG2,
268 "bh_thread: signalled to exit\n");
269 break;
270 }
271
272 if (ret < 0) {
273 unifi_notice(priv,
274 "bh_thread: wait_event returned %d, thread will exit\n",
275 ret);
276 uf_wait_for_thread_to_stop(priv, this_thread);
277 break;
278 }
279
280 this_thread->wakeup_flag = 0;
281
282 unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n");
283
284 CsrSdioClaim(priv->sdio);
285 csrResult = unifi_bh(priv->card, &timeout);
286 if (csrResult != CSR_RESULT_SUCCESS) {
287 if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
288 CsrSdioRelease(priv->sdio);
289 uf_wait_for_thread_to_stop(priv, this_thread);
290 break;
291 }
292 /* Errors must be delivered to the error task */
293 handle_bh_error(priv);
294 }
295 CsrSdioRelease(priv->sdio);
296 }
297
298 /*
299 * I would normally try to call csr_sdio_remove_irq() here to make sure
300 * that we do not get any interrupts while this thread is not running.
301 * However, the MMC/SDIO driver tries to kill its' interrupt thread.
302 * The kernel threads implementation does not allow to kill threads
303 * from a signalled to stop thread.
304 * So, instead call csr_sdio_linux_remove_irq() always after calling
305 * uf_stop_thread() to kill this thread.
306 */
307
308 unifi_trace(priv, UDBG2, "bh_thread exiting....\n");
309 return 0;
310} /* bh_thread_function() */
311
312
313/*
314 * ---------------------------------------------------------------------------
315 * uf_init_bh
316 *
317 * Helper function to start the bottom half of the driver.
318 * All we need to do here is start the I/O bh thread.
319 *
320 * Arguments:
321 * priv Pointer to OS driver structure for the device.
322 *
323 * Returns:
324 * 0 on success or else a Linux error code.
325 * ---------------------------------------------------------------------------
326 */
327int
328uf_init_bh(unifi_priv_t *priv)
329{
330 int r;
331
332 /* Enable mlme interface. */
333 priv->io_aborted = 0;
334
335
336 /* Start the BH thread */
337 r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function);
338 if (r) {
339 unifi_error(priv,
340 "uf_init_bh: failed to start the BH thread.\n");
341 return r;
342 }
343
344 /* Allow interrupts */
345 r = csr_sdio_linux_install_irq(priv->sdio);
346 if (r) {
347 unifi_error(priv,
348 "uf_init_bh: failed to install the IRQ.\n");
349
350 uf_stop_thread(priv, &priv->bh_thread);
351 }
352
353 return r;
354} /* uf_init_bh() */
355
356
357/*
358 * ---------------------------------------------------------------------------
359 * unifi_run_bh
360 *
361 * Part of the HIP core lib API, implemented in the porting exercise.
362 * The bottom half of the driver calls this function when
363 * it wants to process anything that requires access to unifi.
364 * We need to call unifi_bh() which in this implementation is done
365 * by waking up the I/O thread.
366 *
367 * Arguments:
368 * ospriv Pointer to OS driver structure for the device.
369 *
370 * Returns:
371 * 0 on success or else a Linux error code.
372 *
373 * Notes:
374 * ---------------------------------------------------------------------------
375 */
376CsrResult unifi_run_bh(void *ospriv)
377{
378 unifi_priv_t *priv = ospriv;
379
380 /*
381 * If an error has occurred, we discard silently all messages from the bh
382 * until the error has been processed and the unifi has been
383 * reinitialised.
384 */
385 if (priv->bh_thread.block_thread == 1) {
386 unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n");
387 /*
388 * Do not try to acknowledge a pending interrupt here.
389 * This function is called by unifi_send_signal()
390 * which in turn can be running in an atomic or 'disabled irq'
391 * level if a signal is sent from a workqueue task
392 * (i.e multicass addresses set). We can not hold the SDIO lock
393 * because it might sleep.
394 */
395 return CSR_RESULT_FAILURE;
396 }
397
398 priv->bh_thread.wakeup_flag = 1;
399 /* wake up I/O thread */
400 wake_up_interruptible(&priv->bh_thread.wakeup_q);
401
402 return CSR_RESULT_SUCCESS;
403} /* unifi_run_bh() */
404
diff --git a/drivers/staging/csr/csr_framework_ext.c b/drivers/staging/csr/csr_framework_ext.c
deleted file mode 100644
index 98122bce1427..000000000000
--- a/drivers/staging/csr/csr_framework_ext.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include <linux/kernel.h>
12#include <linux/kthread.h>
13#include <linux/module.h>
14#include <linux/freezer.h>
15#include <linux/semaphore.h>
16#include <linux/slab.h>
17#include <linux/bitops.h>
18
19#include "csr_framework_ext.h"
20
21/*----------------------------------------------------------------------------*
22 * NAME
23 * CsrThreadSleep
24 *
25 * DESCRIPTION
26 * Sleep for a given period.
27 *
28 * RETURNS
29 * void
30 *
31 *----------------------------------------------------------------------------*/
32void CsrThreadSleep(u16 sleepTimeInMs)
33{
34 unsigned long t;
35
36 /* Convert t in ms to jiffies and round up */
37 t = ((sleepTimeInMs * HZ) + 999) / 1000;
38 schedule_timeout_uninterruptible(t);
39}
40EXPORT_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
index 6d26ac6173b0..000000000000
--- a/drivers/staging/csr/csr_framework_ext.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef CSR_FRAMEWORK_EXT_H__
2#define CSR_FRAMEWORK_EXT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_result.h"
14#include "csr_framework_ext_types.h"
15
16/* Result codes */
17#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
18#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
19#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
20#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
21#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
22#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
23
24/* Thread priorities */
25#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
26#define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
27#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
28#define CSR_THREAD_PRIORITY_LOW ((u16) 3)
29#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
30
31#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
32
33void CsrThreadSleep(u16 sleepTimeInMs);
34
35#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
index 575598cf69b2..000000000000
--- a/drivers/staging/csr/csr_framework_ext_types.h
+++ /dev/null
@@ -1,30 +0,0 @@
1#ifndef CSR_FRAMEWORK_EXT_TYPES_H__
2#define CSR_FRAMEWORK_EXT_TYPES_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#ifdef __KERNEL__
14#include <linux/kthread.h>
15#include <linux/semaphore.h>
16#else
17#include <pthread.h>
18#endif
19
20#ifdef __KERNEL__
21
22typedef struct semaphore CsrMutexHandle;
23
24#else /* __KERNEL __ */
25
26typedef pthread_mutex_t CsrMutexHandle;
27
28#endif /* __KERNEL__ */
29
30#endif
diff --git a/drivers/staging/csr/csr_log.h b/drivers/staging/csr/csr_log.h
deleted file mode 100644
index 982941043ddc..000000000000
--- a/drivers/staging/csr/csr_log.h
+++ /dev/null
@@ -1,223 +0,0 @@
1#ifndef CSR_LOG_H__
2#define CSR_LOG_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_sched.h"
14#include "csr_prim_defs.h"
15#include "csr_msgconv.h"
16
17/*
18 * Log filtering
19 */
20
21/*----------------------------------------------------*/
22/* Filtering on environment specific log levels */
23/*----------------------------------------------------*/
24typedef u32 CsrLogLevelEnvironment;
25#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
26#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
27#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
28#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
29#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
30#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
31#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
32#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
33#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
34#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
35#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
36#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
37#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 */
38/* The bit masks between here are reserved for future usage */
39#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 */
40
41/*----------------------------------------------------*/
42/* Filtering on task specific log levels */
43/*----------------------------------------------------*/
44typedef u32 CsrLogLevelTask;
45#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
46#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 */
47#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 */
48#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
49#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 */
50#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 */
51#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
52#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
53#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 */
54#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
55#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
56#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
57#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 */
58#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 */
59#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
60#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 */
61#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
62#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 */
63#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
64#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
65/* The bit masks between here are reserved for future usage */
66#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 */
67
68u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
69CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
70u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
71
72/*
73 * Logging stuff
74 */
75#define CSR_LOG_STRINGIFY_REAL(a) (#a)
76#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
77
78typedef struct {
79 u16 primitiveType;
80 const char *primitiveName;
81 CsrMsgConvMsgEntry *messageConv; /* Private - do not use */
82} CsrLogPrimitiveInformation;
83
84typedef struct {
85 const char *techVer;
86 u32 primitiveInfoCount;
87 CsrLogPrimitiveInformation *primitiveInfo;
88} CsrLogTechInformation;
89
90/*---------------------------------*/
91/* Tech logging */
92/*---------------------------------*/
93typedef u8 bitmask8_t;
94typedef u16 bitmask16_t;
95typedef u32 bitmask32_t;
96
97#ifdef CSR_LOG_ENABLE
98#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
99/* DEPRECATED - replaced by csr_log_text.h */
100#define CSR_LOG_TEXT(text) \
101 do { \
102 if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
103 CsrLogTaskText(text, __LINE__, __FILE__); \
104 } \
105 } while (0)
106#else
107/* DEPRECATED - replaced by csr_log_text.h */
108#define CSR_LOG_TEXT(text) \
109 do { \
110 if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
111 CsrLogTaskText(text, 0, NULL); \
112 } \
113 } while (0)
114#endif
115#else
116#define CSR_LOG_TEXT(text)
117#endif
118
119/* DEPRECATED - replaced by csr_log_text.h */
120void CsrLogTaskText(const char *text,
121 u32 line,
122 const char *file);
123
124#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001)
125#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002)
126#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004)
127#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008)
128#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010)
129#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020)
130#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040)
131
132/* DEPRECATED - replaced by csr_log_text.h */
133void CsrLogStateTransition(bitmask16_t mask,
134 u32 identifier,
135 const char *fsm_name,
136 u32 prev_state,
137 const char *prev_state_str,
138 u32 in_event,
139 const char *in_event_str,
140 u32 next_state,
141 const char *next_state_str,
142 u32 line,
143 const char *file);
144
145/*---------------------------------*/
146/* BSP logging */
147/*---------------------------------*/
148void CsrLogSchedInit(u8 thread_id);
149void CsrLogSchedDeinit(u8 thread_id);
150
151void CsrLogSchedStart(u8 thread_id);
152void CsrLogSchedStop(u8 thread_id);
153
154void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
155void CsrLogDeinitTask(u16 task_id);
156
157void CsrLogActivate(CsrSchedQid tskid);
158void CsrLogDeactivate(CsrSchedQid tskid);
159
160#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000)
161#define SYNERGY_SERIALIZER_TYPE_SER (0x001)
162
163void CsrLogMessagePut(u32 line,
164 const char *file,
165 CsrSchedQid src_task_id,
166 CsrSchedQid dst_taskid,
167 CsrSchedMsgId msg_id,
168 u16 prim_type,
169 const void *msg);
170
171void CsrLogMessageGet(CsrSchedQid src_task_id,
172 CsrSchedQid dst_taskid,
173 u8 get_res,
174 CsrSchedMsgId msg_id,
175 u16 prim_type,
176 const void *msg);
177
178void CsrLogTimedEventIn(u32 line,
179 const char *file,
180 CsrSchedQid task_id,
181 CsrSchedTid tid,
182 u32 requested_delay,
183 u16 fniarg,
184 const void *fnvarg);
185
186void CsrLogTimedEventFire(CsrSchedQid task_id,
187 CsrSchedTid tid);
188
189void CsrLogTimedEventDone(CsrSchedQid task_id,
190 CsrSchedTid tid);
191
192void CsrLogTimedEventCancel(u32 line,
193 const char *file,
194 CsrSchedQid task_id,
195 CsrSchedTid tid,
196 u8 cancel_res);
197
198void CsrLogBgintRegister(u8 thread_id,
199 CsrSchedBgint irq,
200 const char *callback,
201 const void *ptr);
202void CsrLogBgintUnregister(CsrSchedBgint irq);
203void CsrLogBgintSet(CsrSchedBgint irq);
204void CsrLogBgintServiceStart(CsrSchedBgint irq);
205void CsrLogBgintServiceDone(CsrSchedBgint irq);
206
207void CsrLogExceptionStateEvent(u16 prim_type,
208 CsrPrim msg_type,
209 u16 state,
210 u32 line,
211 const char *file);
212void CsrLogExceptionGeneral(u16 prim_type,
213 u16 state,
214 const char *text,
215 u32 line,
216 const char *file);
217void CsrLogExceptionWarning(u16 prim_type,
218 u16 state,
219 const char *text,
220 u32 line,
221 const char *file);
222
223#endif
diff --git a/drivers/staging/csr/csr_log_configure.h b/drivers/staging/csr/csr_log_configure.h
deleted file mode 100644
index 283647cf9702..000000000000
--- a/drivers/staging/csr/csr_log_configure.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef CSR_LOG_CONFIGURE_H__
2#define CSR_LOG_CONFIGURE_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11 *****************************************************************************/
12
13#include "csr_log.h"
14
15/*--------------------------------------------*/
16/* Filtering on log text warning levels */
17/*--------------------------------------------*/
18typedef u32 CsrLogLevelText;
19#define CSR_LOG_LEVEL_TEXT_OFF ((CsrLogLevelText) 0x0000)
20
21#define CSR_LOG_LEVEL_TEXT_CRITICAL ((CsrLogLevelText) 0x0001)
22#define CSR_LOG_LEVEL_TEXT_ERROR ((CsrLogLevelText) 0x0002)
23#define CSR_LOG_LEVEL_TEXT_WARNING ((CsrLogLevelText) 0x0004)
24#define CSR_LOG_LEVEL_TEXT_INFO ((CsrLogLevelText) 0x0008)
25#define CSR_LOG_LEVEL_TEXT_DEBUG ((CsrLogLevelText) 0x0010)
26
27#define CSR_LOG_LEVEL_TEXT_ALL ((CsrLogLevelText) 0xFFFF)
28
29/* The log text interface is used by both scheduler tasks and components outside the scheduler context.
30 * Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two u16's. The lower
31 * 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used
32 * by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the
33 * scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid
34 * clashes the technologies are only allowed to assign values within the same restrictive range as allies to
35 * primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign
36 * taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */
37typedef u32 CsrLogTextTaskId;
38
39#endif
diff --git a/drivers/staging/csr/csr_log_text.h b/drivers/staging/csr/csr_log_text.h
deleted file mode 100644
index cfcf64aa6225..000000000000
--- a/drivers/staging/csr/csr_log_text.h
+++ /dev/null
@@ -1,124 +0,0 @@
1#ifndef CSR_LOG_TEXT_H__
2#define CSR_LOG_TEXT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_log_configure.h"
14
15typedef struct CsrLogSubOrigin
16{
17 u16 subOriginNumber; /* Id of the given SubOrigin */
18 const char *subOriginName; /* Prefix Text for this SubOrigin */
19} CsrLogSubOrigin;
20
21/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
22#ifdef CSR_LOG_ENABLE
23void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
24#else
25#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins)
26#endif
27
28/* CRITICAL: Conditions that are threatening to the integrity/stability of the
29 system as a whole. */
30#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE)
31void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
32void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
33#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs
34#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}}
35#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs
36#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}}
37#else
38#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs)
39#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs)
40#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs)
41#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs)
42#endif
43
44/* ERROR: Malfunction of a component rendering it unable to operate correctly,
45 causing lack of functionality but not loss of system integrity/stability. */
46#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE)
47void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
48void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
49#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs
50#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}}
51#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs
52#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}}
53#else
54#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs)
55#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs)
56#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs)
57#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs)
58#endif
59
60/* WARNING: Conditions that are unexpected and indicative of possible problems
61 or violations of specifications, where the result of such deviations does not
62 lead to malfunction of the component. */
63#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE)
64void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
65void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
66#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs
67#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}}
68#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs
69#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}}
70#else
71#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs)
72#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs)
73#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs)
74#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs)
75#endif
76
77/* INFO: Important events that may aid in determining the conditions under which
78 the more severe conditions are encountered. */
79#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE)
80void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
81void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
82#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs
83#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}}
84#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs
85#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}}
86#else
87#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs)
88#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs)
89#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs)
90#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs)
91#endif
92
93/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */
94#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE)
95void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
96void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
97#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs
98#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}}
99#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs
100#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}}
101#else
102#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs)
103#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs)
104#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs)
105#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs)
106#endif
107
108/* CSR_LOG_TEXT_ASSERT (CRITICAL) */
109#ifdef CSR_LOG_ENABLE
110#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \
111 {if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}}
112#else
113#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition)
114#endif
115
116/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */
117#ifdef CSR_LOG_ENABLE
118#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \
119 CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__))
120#else
121#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType)
122#endif
123
124#endif
diff --git a/drivers/staging/csr/csr_macro.h b/drivers/staging/csr/csr_macro.h
deleted file mode 100644
index c47f1d91b6fa..000000000000
--- a/drivers/staging/csr/csr_macro.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef CSR_MACRO_H__
2#define CSR_MACRO_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include <linux/types.h>
14
15#define FALSE (0)
16#define TRUE (1)
17
18/*------------------------------------------------------------------*/
19/* Endian conversion */
20/*------------------------------------------------------------------*/
21#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8)
22#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \
23 ((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24)
24#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \
25 ((u8 *) (ptr))[1] = ((u8) ((uint) >> 8))
26#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \
27 ((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
28 ((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \
29 ((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF))
30
31/*------------------------------------------------------------------*/
32/* Misc */
33/*------------------------------------------------------------------*/
34/* Use this macro on unused local variables that cannot be removed (such as
35 unused function parameters). This will quell warnings from certain compilers
36 and static code analysis tools like Lint and Valgrind. */
37#define CSR_UNUSED(x) ((void) (x))
38
39#endif
diff --git a/drivers/staging/csr/csr_msg_transport.h b/drivers/staging/csr/csr_msg_transport.h
deleted file mode 100644
index 8d88e7836567..000000000000
--- a/drivers/staging/csr/csr_msg_transport.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef CSR_MSG_TRANSPORT_H__
2#define CSR_MSG_TRANSPORT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#ifndef CsrMsgTransport
14#define CsrMsgTransport CsrSchedMessagePut
15#endif
16
17#endif /* CSR_MSG_TRANSPORT */
diff --git a/drivers/staging/csr/csr_msgconv.c b/drivers/staging/csr/csr_msgconv.c
deleted file mode 100644
index db5e845e60f5..000000000000
--- a/drivers/staging/csr/csr_msgconv.c
+++ /dev/null
@@ -1,291 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/slab.h>
14#include "csr_sched.h"
15#include "csr_msgconv.h"
16#include "csr_macro.h"
17
18static CsrMsgConvEntry *converter;
19
20CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType)
21{
22 CsrMsgConvPrimEntry *ptr = NULL;
23
24 if (converter)
25 {
26 ptr = converter->profile_converters;
27 while (ptr)
28 {
29 if (ptr->primType == primType)
30 {
31 break;
32 }
33 else
34 {
35 ptr = ptr->next;
36 }
37 }
38 }
39
40 return ptr;
41}
42
43static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, u16 msgType)
44{
45 const CsrMsgConvMsgEntry *cv = ptr->conv;
46 if (ptr->lookupFunc)
47 {
48 return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType);
49 }
50
51 while (cv)
52 {
53 if (cv->serFunc == NULL)
54 {
55 /* We've reached the end of the chain */
56 cv = NULL;
57 break;
58 }
59
60 if (cv->msgType == msgType)
61 {
62 break;
63 }
64 else
65 {
66 cv++;
67 }
68 }
69
70 return cv;
71}
72
73static void *deserialize_data(u16 primType,
74 size_t length,
75 u8 *data)
76{
77 CsrMsgConvPrimEntry *ptr;
78 u8 *ret;
79
80 ptr = CsrMsgConvFind(primType);
81
82 if (ptr)
83 {
84 const CsrMsgConvMsgEntry *cv;
85 u16 msgId = 0;
86 size_t offset = 0;
87 CsrUint16Des(&msgId, data, &offset);
88
89 cv = find_msg_converter(ptr, msgId);
90 if (cv)
91 {
92 ret = cv->deserFunc(data, length);
93 }
94 else
95 {
96 ret = NULL;
97 }
98 }
99 else
100 {
101 ret = NULL;
102 }
103
104 return ret;
105}
106
107static size_t sizeof_message(u16 primType, void *msg)
108{
109 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
110 size_t ret;
111
112 if (ptr)
113 {
114 const CsrMsgConvMsgEntry *cv;
115 u16 msgId = *(u16 *) msg;
116
117 cv = find_msg_converter(ptr, msgId);
118 if (cv)
119 {
120 ret = cv->sizeofFunc(msg);
121 }
122 else
123 {
124 ret = 0;
125 }
126 }
127 else
128 {
129 ret = 0;
130 }
131
132 return ret;
133}
134
135static u8 free_message(u16 primType, u8 *data)
136{
137 CsrMsgConvPrimEntry *ptr;
138 u8 ret;
139
140 ptr = CsrMsgConvFind(primType);
141
142 if (ptr)
143 {
144 const CsrMsgConvMsgEntry *cv;
145 u16 msgId = *(u16 *) data;
146
147 cv = find_msg_converter(ptr, msgId);
148 if (cv)
149 {
150 cv->freeFunc(data);
151 ret = TRUE;
152 }
153 else
154 {
155 ret = FALSE;
156 }
157 }
158 else
159 {
160 ret = FALSE;
161 }
162
163 return ret;
164}
165
166static u8 *serialize_message(u16 primType,
167 void *msg,
168 size_t *length,
169 u8 *buffer)
170{
171 CsrMsgConvPrimEntry *ptr;
172 u8 *ret;
173
174 ptr = CsrMsgConvFind(primType);
175
176 *length = 0;
177
178 if (ptr)
179 {
180 const CsrMsgConvMsgEntry *cv;
181
182 cv = find_msg_converter(ptr, *(u16 *) msg);
183 if (cv)
184 {
185 ret = cv->serFunc(buffer, length, msg);
186 }
187 else
188 {
189 ret = NULL;
190 }
191 }
192 else
193 {
194 ret = NULL;
195 }
196
197 return ret;
198}
199
200size_t CsrMsgConvSizeof(u16 primType, void *msg)
201{
202 return sizeof_message(primType, msg);
203}
204
205u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg)
206{
207 if (converter)
208 {
209 size_t serializedLength;
210 u8 *bufSerialized;
211 u8 *bufOffset = &buffer[*offset];
212 bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset);
213 *offset += serializedLength;
214 return bufSerialized;
215 }
216 else
217 {
218 return NULL;
219 }
220}
221
222/* Insert profile converter at head of converter list. */
223void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce)
224{
225 CsrMsgConvPrimEntry *pc;
226 pc = CsrMsgConvFind(primType);
227
228 if (pc)
229 {
230 /* Already registered. Do nothing */
231 }
232 else
233 {
234 pc = kmalloc(sizeof(*pc), GFP_KERNEL);
235 pc->primType = primType;
236 pc->conv = ce;
237 pc->lookupFunc = NULL;
238 pc->next = converter->profile_converters;
239 converter->profile_converters = pc;
240 }
241}
242EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
243
244CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType)
245{
246 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
247 if (ptr)
248 {
249 return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
250 }
251 return NULL;
252}
253EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
254
255CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg)
256{
257 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
258 if (ptr && msg)
259 {
260 u16 msgType = *((u16 *) msg);
261 return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
262 }
263 return NULL;
264}
265
266void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc)
267{
268 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
269 if (ptr)
270 {
271 ptr->lookupFunc = lookupFunc;
272 }
273}
274EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
275
276CsrMsgConvEntry *CsrMsgConvInit(void)
277{
278 if (!converter)
279 {
280 converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);
281
282 converter->profile_converters = NULL;
283 converter->free_message = free_message;
284 converter->sizeof_message = sizeof_message;
285 converter->serialize_message = serialize_message;
286 converter->deserialize_data = deserialize_data;
287 }
288
289 return converter;
290}
291EXPORT_SYMBOL_GPL(CsrMsgConvInit);
diff --git a/drivers/staging/csr/csr_msgconv.h b/drivers/staging/csr/csr_msgconv.h
deleted file mode 100644
index 7e4dd388ae37..000000000000
--- a/drivers/staging/csr/csr_msgconv.h
+++ /dev/null
@@ -1,78 +0,0 @@
1#ifndef CSR_MSGCONV_H__
2#define CSR_MSGCONV_H__
3
4/*****************************************************************************
5
6 (c) Cambridge Silicon Radio Limited 2010
7 All rights reserved and confidential information of CSR
8
9 Refer to LICENSE.txt included with this source for details
10 on the license terms.
11
12*****************************************************************************/
13
14#include <linux/types.h>
15#include "csr_prim_defs.h"
16#include "csr_sched.h"
17
18typedef size_t (CsrMsgSizeofFunc)(void *msg);
19typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
20typedef void (CsrMsgFreeFunc)(void *msg);
21typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
22
23/* Converter entry for one message type */
24typedef struct CsrMsgConvMsgEntry
25{
26 u16 msgType;
27 CsrMsgSizeofFunc *sizeofFunc;
28 CsrMsgSerializeFunc *serFunc;
29 CsrMsgDeserializeFunc *deserFunc;
30 CsrMsgFreeFunc *freeFunc;
31} CsrMsgConvMsgEntry;
32
33/* Optional lookup function */
34typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
35
36/* All converter entries for one specific primitive */
37typedef struct CsrMsgConvPrimEntry
38{
39 u16 primType;
40 const CsrMsgConvMsgEntry *conv;
41 CsrMsgCustomLookupFunc *lookupFunc;
42 struct CsrMsgConvPrimEntry *next;
43} CsrMsgConvPrimEntry;
44
45typedef struct
46{
47 CsrMsgConvPrimEntry *profile_converters;
48 void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
49 u8 (*free_message)(u16 primType, u8 *data);
50 size_t (*sizeof_message)(u16 primType, void *msg);
51 u8 *(*serialize_message)(u16 primType, void *msg,
52 size_t * length,
53 u8 * buffer);
54} CsrMsgConvEntry;
55
56size_t CsrMsgConvSizeof(u16 primType, void *msg);
57u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
58void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
59void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
60CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
61CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
62CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
63CsrMsgConvEntry *CsrMsgConvInit(void);
64
65/* Prototypes for primitive type serializers */
66void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
67void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
68void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
69void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
70void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
71
72void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
73void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
74void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
75void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
76void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
77
78#endif
diff --git a/drivers/staging/csr/csr_prim_defs.h b/drivers/staging/csr/csr_prim_defs.h
deleted file mode 100644
index 81a1eaac30d9..000000000000
--- a/drivers/staging/csr/csr_prim_defs.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef CSR_PRIM_DEFS_H__
2#define CSR_PRIM_DEFS_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13/************************************************************************************
14 * Segmentation of primitives in upstream and downstream segment
15 ************************************************************************************/
16typedef u16 CsrPrim;
17#define CSR_PRIM_UPSTREAM ((CsrPrim) (0x8000))
18
19/************************************************************************************
20 * Primitive definitions for Synergy framework
21 ************************************************************************************/
22#define CSR_SYNERGY_EVENT_CLASS_BASE ((u16) (0x0600))
23
24#define CSR_HCI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE))
25#define CSR_BCCMD_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE))
26#define CSR_HQ_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE))
27#define CSR_VM_PRIM ((u16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE))
28#define CSR_TM_BLUECORE_PRIM ((u16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE))
29#define CSR_FP_PRIM ((u16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE))
30#define CSR_IP_SOCKET_PRIM ((u16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE))
31#define CSR_IP_ETHER_PRIM ((u16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE))
32#define CSR_IP_IFCONFIG_PRIM ((u16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE))
33#define CSR_IP_INTERNAL_PRIM ((u16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE))
34#define CSR_FSAL_PRIM ((u16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE))
35#define CSR_DATA_STORE_PRIM ((u16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE))
36#define CSR_AM_PRIM ((u16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE))
37#define CSR_TLS_PRIM ((u16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE))
38#define CSR_DHCP_SERVER_PRIM ((u16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE))
39#define CSR_TFTP_PRIM ((u16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE))
40#define CSR_DSPM_PRIM ((u16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE))
41#define CSR_TLS_INTERNAL_PRIM ((u16) (0x0011 | CSR_SYNERGY_EVENT_CLASS_BASE))
42
43#define NUMBER_OF_CSR_FW_EVENTS (CSR_DSPM_PRIM - CSR_SYNERGY_EVENT_CLASS_BASE + 1)
44
45#define CSR_SYNERGY_EVENT_CLASS_MISC_BASE ((u16) (0x06A0))
46
47#define CSR_UI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
48#define CSR_APP_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
49#define CSR_SDIO_PROBE_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
50
51#define NUMBER_OF_CSR_FW_MISC_EVENTS (CSR_SDIO_PROBE_PRIM - CSR_SYNERGY_EVENT_CLASS_MISC_BASE + 1)
52
53#define CSR_ENV_PRIM ((u16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
54
55#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
index cbb607d943c7..000000000000
--- a/drivers/staging/csr/csr_result.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef CSR_RESULT_H__
2#define CSR_RESULT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13typedef u16 CsrResult;
14#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000)
15#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF)
16
17#endif
diff --git a/drivers/staging/csr/csr_sched.h b/drivers/staging/csr/csr_sched.h
deleted file mode 100644
index c7d672c59f5b..000000000000
--- a/drivers/staging/csr/csr_sched.h
+++ /dev/null
@@ -1,85 +0,0 @@
1#ifndef CSR_SCHED_H__
2#define CSR_SCHED_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12#include <linux/types.h>
13#include "csr_time.h"
14
15/* An identifier issued by the scheduler. */
16typedef u32 CsrSchedIdentifier;
17
18/* A task identifier */
19typedef u16 CsrSchedTaskId;
20
21/* A queue identifier */
22typedef u16 CsrSchedQid;
23
24/* A message identifier */
25typedef CsrSchedIdentifier CsrSchedMsgId;
26
27/* A timer event identifier */
28typedef CsrSchedIdentifier CsrSchedTid;
29#define CSR_SCHED_TID_INVALID ((CsrSchedTid) 0)
30
31/* Time constants. */
32#define CSR_SCHED_TIME_MAX (0xFFFFFFFF)
33#define CSR_SCHED_MILLISECOND (1000)
34#define CSR_SCHED_SECOND (1000 * CSR_SCHED_MILLISECOND)
35#define CSR_SCHED_MINUTE (60 * CSR_SCHED_SECOND)
36
37/* Queue and primitive that identifies the environment */
38#define CSR_SCHED_TASK_ID 0xFFFF
39#define CSR_SCHED_PRIM (CSR_SCHED_TASK_ID)
40#define CSR_SCHED_EXCLUDED_MODULE_QUEUE 0xFFFF
41
42/*
43 * Background interrupt definitions
44 */
45typedef u16 CsrSchedBgint;
46#define CSR_SCHED_BGINT_INVALID ((CsrSchedBgint) 0xFFFF)
47
48/*----------------------------------------------------------------------------*
49 * NAME
50 * CsrSchedMessagePut
51 *
52 * DESCRIPTION
53 * Sends a message consisting of the integer "mi" and the void * pointer
54 * "mv" to the message queue "q".
55 *
56 * "mi" and "mv" are neither inspected nor changed by the scheduler - the
57 * task that owns "q" is expected to make sense of the values. "mv" may
58 * be null.
59 *
60 * NOTE
61 * If "mv" is not null then it will typically be a chunk of kmalloc()ed
62 * memory, though there is no need for it to be so. Tasks should normally
63 * obey the convention that when a message built with kmalloc()ed memory
64 * is given to CsrSchedMessagePut() then ownership of the memory is ceded to the
65 * scheduler - and eventually to the recipient task. I.e., the receiver of
66 * the message will be expected to kfree() the message storage.
67 *
68 * RETURNS
69 * void.
70 *
71 *----------------------------------------------------------------------------*/
72#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
73void CsrSchedMessagePutStringLog(CsrSchedQid q,
74 u16 mi,
75 void *mv,
76 u32 line,
77 const char *file);
78#define CsrSchedMessagePut(q, mi, mv) CsrSchedMessagePutStringLog((q), (mi), (mv), __LINE__, __FILE__)
79#else
80void CsrSchedMessagePut(CsrSchedQid q,
81 u16 mi,
82 void *mv);
83#endif
84
85#endif
diff --git a/drivers/staging/csr/csr_sdio.h b/drivers/staging/csr/csr_sdio.h
deleted file mode 100644
index 0971d135abf6..000000000000
--- a/drivers/staging/csr/csr_sdio.h
+++ /dev/null
@@ -1,723 +0,0 @@
1#ifndef CSR_SDIO_H__
2#define CSR_SDIO_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_result.h"
14
15/* Result Codes */
16#define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
17#define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
18#define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
19#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 */
20#define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */
21
22/* Features (for use in features member of CsrSdioFunction) */
23#define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */
24#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */
25
26/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
27#define CSR_SDIO_ANY_MANF_ID 0xFFFF
28#define CSR_SDIO_ANY_CARD_ID 0xFFFF
29#define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF
30#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
31
32/*----------------------------------------------------------------------------*
33 * NAME
34 * CsrSdioFunctionId
35 *
36 * DESCRIPTION
37 * This structure describes one or more functions of a device, based on
38 * four qualitative measures. The CsrSdioFunctionId wildcard defines can be
39 * used for making the CsrSdioFunctionId match more than one function.
40 *
41 * MEMBERS
42 * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
43 * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
44 * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
45 * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
46 *
47 *----------------------------------------------------------------------------*/
48typedef struct
49{
50 u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
51 u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
52 u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
53 u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
54} CsrSdioFunctionId;
55
56/*----------------------------------------------------------------------------*
57 * NAME
58 * CsrSdioFunction
59 *
60 * DESCRIPTION
61 * This structure represents a single function on a device.
62 *
63 * MEMBERS
64 * sdioId - A CsrSdioFunctionId describing this particular function. The
65 * subfield shall not contain any CsrSdioFunctionId wildcards. The
66 * subfields shall describe the specific single function
67 * represented by this structure.
68 * blockSize - Actual configured block size, or 0 if unconfigured.
69 * features - Bit mask with any of CSR_SDIO_FEATURE_* set.
70 * device - Handle of device containing the function. If two functions have
71 * the same device handle, they reside on the same device.
72 * driverData - For use by the Function Driver. The SDIO Driver shall not
73 * attempt to dereference the pointer.
74 * priv - For use by the SDIO Driver. The Function Driver shall not attempt
75 * to dereference the pointer.
76 *
77 *
78 *----------------------------------------------------------------------------*/
79typedef struct
80{
81 CsrSdioFunctionId sdioId;
82 u16 blockSize; /* Actual configured block size, or 0 if unconfigured */
83 u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
84 void *device; /* Handle of device containing the function */
85 void *driverData; /* For use by the Function Driver */
86 void *priv; /* For use by the SDIO Driver */
87} CsrSdioFunction;
88
89/*----------------------------------------------------------------------------*
90 * NAME
91 * CsrSdioInsertedCallback, CsrSdioRemovedCallback
92 *
93 * DESCRIPTION
94 * CsrSdioInsertedCallback is called when a function becomes available to
95 * a registered Function Driver that supports the function.
96 * CsrSdioRemovedCallback is called when a function is no longer available
97 * to a Function Driver, either because the device has been removed, or the
98 * Function Driver has been unregistered.
99 *
100 * NOTE: These functions are implemented by the Function Driver, and are
101 * passed as function pointers in the CsrSdioFunctionDriver struct.
102 *
103 * PARAMETERS
104 * function - Pointer to struct representing the function.
105 *
106 *----------------------------------------------------------------------------*/
107typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
108typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
109
110/*----------------------------------------------------------------------------*
111 * NAME
112 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
113 *
114 * DESCRIPTION
115 * CsrSdioInterruptCallback is called when an interrupt occurs on the
116 * the device associated with the specified function.
117 *
118 * NOTE: These functions are implemented by the Function Driver, and are
119 * passed as function pointers in the CsrSdioFunctionDriver struct.
120 *
121 * PARAMETERS
122 * function - Pointer to struct representing the function.
123 *
124 * RETURNS (only CsrSdioInterruptCallback)
125 * A pointer to a CsrSdioInterruptDsrCallback function.
126 *
127 *----------------------------------------------------------------------------*/
128typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
129typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
130
131/*----------------------------------------------------------------------------*
132 * NAME
133 * CsrSdioSuspendCallback, CsrSdioResumeCallback
134 *
135 * DESCRIPTION
136 * CsrSdioSuspendCallback is called when the system is preparing to go
137 * into a suspended state. CsrSdioResumeCallback is called when the system
138 * has entered an active state again.
139 *
140 * NOTE: These functions are implemented by the Function Driver, and are
141 * passed as function pointers in the CsrSdioFunctionDriver struct.
142 *
143 * PARAMETERS
144 * function - Pointer to struct representing the function.
145 *
146 *----------------------------------------------------------------------------*/
147typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
148typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
149
150/*----------------------------------------------------------------------------*
151 * NAME
152 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
153 *
154 * DESCRIPTION
155 * CsrSdioAsyncCallback is called when an asynchronous operation completes.
156 *
157 * NOTE: These functions are implemented by the Function Driver, and are
158 * passed as function pointers in the function calls that initiate
159 * the operation.
160 *
161 * PARAMETERS
162 * function - Pointer to struct representing the function.
163 * result - The result of the operation that completed. See the description
164 * of the initiating function for possible result values.
165 *
166 * RETURNS (only CsrSdioAsyncCallback)
167 * A pointer to a CsrSdioAsyncDsrCallback function.
168 *
169 *----------------------------------------------------------------------------*/
170typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
171typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
172
173/*----------------------------------------------------------------------------*
174 * NAME
175 * CsrSdioFunctionDriver
176 *
177 * DESCRIPTION
178 * Structure representing a Function Driver.
179 *
180 * MEMBERS
181 * inserted - Callback, see description of CsrSdioInsertedCallback.
182 * removed - Callback, see description of CsrSdioRemovedCallback.
183 * intr - Callback, see description of CsrSdioInterruptCallback.
184 * suspend - Callback, see description of CsrSdioSuspendCallback.
185 * resume - Callback, see description of CsrSdioResumeCallback.
186 * ids - Array of CsrSdioFunctionId describing one or more functions that
187 * are supported by the Function Driver.
188 * idsCount - Length of the ids array.
189 * priv - For use by the SDIO Driver. The Function Driver may initialise
190 * it to NULL, but shall otherwise not access the pointer or attempt
191 * to dereference it.
192 *
193 *----------------------------------------------------------------------------*/
194typedef struct
195{
196 CsrSdioInsertedCallback inserted;
197 CsrSdioRemovedCallback removed;
198 CsrSdioInterruptCallback intr;
199 CsrSdioSuspendCallback suspend;
200 CsrSdioResumeCallback resume;
201 CsrSdioFunctionId *ids;
202 u8 idsCount;
203 void *priv; /* For use by the SDIO Driver */
204} CsrSdioFunctionDriver;
205
206/*----------------------------------------------------------------------------*
207 * NAME
208 * CsrSdioFunctionDriverRegister
209 *
210 * DESCRIPTION
211 * Register a Function Driver.
212 *
213 * PARAMETERS
214 * functionDriver - Pointer to struct describing the Function Driver.
215 *
216 * RETURNS
217 * CSR_RESULT_SUCCESS - The Function Driver was successfully
218 * registered.
219 * CSR_RESULT_FAILURE - Unable to register the function driver,
220 * because of an unspecified/unknown error. The
221 * Function Driver has not been registered.
222 * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
223 * does not point at a valid Function
224 * Driver structure, or some of the members
225 * contain invalid entries.
226 *
227 *----------------------------------------------------------------------------*/
228CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
229
230/*----------------------------------------------------------------------------*
231 * NAME
232 * CsrSdioFunctionDriverUnregister
233 *
234 * DESCRIPTION
235 * Unregister a previously registered Function Driver.
236 *
237 * PARAMETERS
238 * functionDriver - pointer to struct describing the Function Driver.
239 *
240 *----------------------------------------------------------------------------*/
241void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
242
243/*----------------------------------------------------------------------------*
244 * NAME
245 * CsrSdioFunctionEnable, CsrSdioFunctionDisable
246 *
247 * DESCRIPTION
248 * Enable/disable the specified function by setting/clearing the
249 * corresponding bit in the I/O Enable register in function 0, and then
250 * periodically reading the related bit in the I/O Ready register until it
251 * is set/clear, limited by an implementation defined timeout.
252 *
253 * PARAMETERS
254 * function - Pointer to struct representing the function.
255 *
256 * RETURNS
257 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
258 * CSR_RESULT_FAILURE - Unspecified/unknown error.
259 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
260 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
261 * related bit in the I/O Enable register is
262 * undefined.
263 * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
264 * bit in the I/O ready register was not
265 * set/cleared within the timeout period.
266 *
267 * NOTE: If the SDIO R5 response is available, and either of the
268 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
269 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
270 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
271 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
272 * COM_CRC_ERROR bits shall be ignored.
273 *
274 * If the CSPI response is available, and any of the
275 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
276 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
277 *
278 *----------------------------------------------------------------------------*/
279CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
280CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
281
282/*----------------------------------------------------------------------------*
283 * NAME
284 * CsrSdioInterruptEnable, CsrSdioInterruptDisable
285 *
286 * DESCRIPTION
287 * Enable/disable the interrupt for the specified function by
288 * setting/clearing the corresponding bit in the INT Enable register in
289 * function 0.
290 *
291 * PARAMETERS
292 * function - Pointer to struct representing the function.
293 *
294 * RETURNS
295 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
296 * CSR_RESULT_FAILURE - Unspecified/unknown error.
297 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
298 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
299 * related bit in the INT Enable register is
300 * unchanged.
301 * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
302 * enabled/disabled, because it either
303 * does not exist or it is not possible to
304 * individually enable/disable functions.
305 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
306 *
307 * NOTE: If the SDIO R5 response is available, and either of the
308 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
309 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
310 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
311 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
312 * COM_CRC_ERROR bits shall be ignored.
313 *
314 * If the CSPI response is available, and any of the
315 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
316 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
317 *
318 *----------------------------------------------------------------------------*/
319CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
320CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
321
322/*----------------------------------------------------------------------------*
323 * NAME
324 * CsrSdioInterruptAcknowledge
325 *
326 * DESCRIPTION
327 * Acknowledge that a signalled interrupt has been handled. Shall only
328 * be called once, and exactly once for each signalled interrupt to the
329 * corresponding function.
330 *
331 * PARAMETERS
332 * function - Pointer to struct representing the function to which the
333 * event was signalled.
334 *
335 *----------------------------------------------------------------------------*/
336void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
337
338/*----------------------------------------------------------------------------*
339 * NAME
340 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
341 *
342 * DESCRIPTION
343 * Acknowledge that a signalled inserted/removed event has been handled.
344 * Shall only be called once, and exactly once for each signalled event to
345 * the corresponding function.
346 *
347 * PARAMETERS
348 * function - Pointer to struct representing the function to which the
349 * inserted was signalled.
350 * result (CsrSdioInsertedAcknowledge only)
351 * CSR_RESULT_SUCCESS - The Function Driver has accepted the
352 * function, and the function is attached to
353 * the Function Driver until the
354 * CsrSdioRemovedCallback is called and
355 * acknowledged.
356 * CSR_RESULT_FAILURE - Unable to accept the function. The
357 * function is not attached to the Function
358 * Driver, and it may be passed to another
359 * Function Driver which supports the
360 * function.
361 *
362 *----------------------------------------------------------------------------*/
363void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
364void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
365
366/*----------------------------------------------------------------------------*
367 * NAME
368 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
369 *
370 * DESCRIPTION
371 * Acknowledge that a signalled suspend event has been handled. Shall only
372 * be called once, and exactly once for each signalled event to the
373 * corresponding function.
374 *
375 * PARAMETERS
376 * function - Pointer to struct representing the function to which the
377 * event was signalled.
378 * result
379 * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
380 * CSR_RESULT_FAILURE - Unspecified/unknown error.
381 *
382 *----------------------------------------------------------------------------*/
383void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
384void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
385
386/*----------------------------------------------------------------------------*
387 * NAME
388 * CsrSdioBlockSizeSet
389 *
390 * DESCRIPTION
391 * Set the block size to use for the function. The actual configured block
392 * size shall be the minimum of:
393 * 1) Maximum block size supported by the function.
394 * 2) Maximum block size supported by the host controller.
395 * 3) The block size specified by the blockSize argument.
396 *
397 * When this function returns, the actual configured block size is
398 * available in the blockSize member of the function struct.
399 *
400 * PARAMETERS
401 * function - Pointer to struct representing the function.
402 * blockSize - Block size to use for the function. Valid range is 1 to
403 * 2048.
404 *
405 * RETURNS
406 * CSR_RESULT_SUCCESS - The block size register on the chip
407 * was updated.
408 * CSR_RESULT_FAILURE - Unspecified/unknown error.
409 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
410 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
411 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The configured block
412 * size is undefined.
413 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
414 *
415 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
416 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
417 * If the ERROR bit is set (but not FUNCTION_NUMBER),
418 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
419 * COM_CRC_ERROR bits shall be ignored.
420 *
421 * If the CSPI response is available, and any of the
422 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
423 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
424 *
425 * NOTE: Setting the block size requires two individual operations. The
426 * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
427 * response for the first operation, as the partially configured
428 * block size may be out of range, even if the final block size
429 * (after the second operation) is in the valid range.
430 *
431 *----------------------------------------------------------------------------*/
432CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
433
434/*----------------------------------------------------------------------------*
435 * NAME
436 * CsrSdioMaxBusClockFrequencySet
437 *
438 * DESCRIPTION
439 * Set the maximum clock frequency to use for the device associated with
440 * the specified function. The actual configured clock frequency for the
441 * device shall be the minimum of:
442 * 1) Maximum clock frequency supported by the device.
443 * 2) Maximum clock frequency supported by the host controller.
444 * 3) Maximum clock frequency specified for any function on the same
445 * device.
446 *
447 * If the clock frequency exceeds 25MHz, it is the responsibility of the
448 * SDIO driver to enable high speed mode on the device, using the standard
449 * defined procedure, before increasing the frequency beyond the limit.
450 *
451 * Note that the clock frequency configured affects all functions on the
452 * same device.
453 *
454 * PARAMETERS
455 * function - Pointer to struct representing the function.
456 * maxFrequency - The maximum clock frequency for the function in Hertz.
457 *
458 * RETURNS
459 * CSR_RESULT_SUCCESS - The maximum clock frequency was successfully
460 * set for the function.
461 * CSR_RESULT_FAILURE - Unspecified/unknown error.
462 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
463 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
464 *
465 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
466 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
467 * If the ERROR bit is set (but not FUNCTION_NUMBER),
468 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
469 * COM_CRC_ERROR bits shall be ignored.
470 *
471 * If the CSPI response is available, and any of the
472 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
473 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
474 *
475 *
476 *----------------------------------------------------------------------------*/
477CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
478
479/*----------------------------------------------------------------------------*
480 * NAME
481 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
482 *
483 * DESCRIPTION
484 * Read/write an 8bit value from/to the specified register address.
485 *
486 * PARAMETERS
487 * function - Pointer to struct representing the function.
488 * address - Register address within the function.
489 * data - The data to read/write.
490 * callback - The function to call on operation completion.
491 *
492 * RETURNS
493 * CSR_RESULT_SUCCESS - The data was successfully read/written.
494 * CSR_RESULT_FAILURE - Unspecified/unknown error.
495 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
496 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
497 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
498 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
499 *
500 * NOTE: If the SDIO R5 response is available, and either of the
501 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
502 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
503 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
504 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
505 * COM_CRC_ERROR bits shall be ignored.
506 *
507 * If the CSPI response is available, and any of the
508 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
509 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
510 *
511 * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
512 * immediately, and the supplied callback function is called when the
513 * operation is complete. The result value is given as an argument to
514 * the callback function.
515 *
516 *----------------------------------------------------------------------------*/
517CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
518CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
519void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
520void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
521
522/*----------------------------------------------------------------------------*
523 * NAME
524 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
525 *
526 * DESCRIPTION
527 * Read/write a 16bit value from/to the specified register address.
528 *
529 * PARAMETERS
530 * function - Pointer to struct representing the function.
531 * address - Register address within the function.
532 * data - The data to read/write.
533 * callback - The function to call on operation completion.
534 *
535 * RETURNS
536 * CSR_RESULT_SUCCESS - The data was successfully read/written.
537 * CSR_RESULT_FAILURE - Unspecified/unknown error.
538 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
539 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
540 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
541 * partially read/written.
542 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
543 *
544 * NOTE: If the SDIO R5 response is available, and either of the
545 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
546 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
547 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
548 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
549 * COM_CRC_ERROR bits shall be ignored.
550 *
551 * If the CSPI response is available, and any of the
552 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
553 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
554 *
555 * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
556 * immediately, and the supplied callback function is called when the
557 * operation is complete. The result value is given as an argument to
558 * the callback function.
559 *
560 *----------------------------------------------------------------------------*/
561CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
562CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
563void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
564void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
565
566/*----------------------------------------------------------------------------*
567 * NAME
568 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
569 * CsrSdioF0Write8Async
570 *
571 * DESCRIPTION
572 * Read/write an 8bit value from/to the specified register address in
573 * function 0.
574 *
575 * PARAMETERS
576 * function - Pointer to struct representing the function.
577 * address - Register address within the function.
578 * data - The data to read/write.
579 * callback - The function to call on operation completion.
580 *
581 * RETURNS
582 * CSR_RESULT_SUCCESS - The data was successfully read/written.
583 * CSR_RESULT_FAILURE - Unspecified/unknown error.
584 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
585 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
586 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
587 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
588 *
589 * NOTE: If the SDIO R5 response is available, and either of the
590 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
591 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
592 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
593 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
594 * COM_CRC_ERROR bits shall be ignored.
595 *
596 * If the CSPI response is available, and any of the
597 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
598 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
599 *
600 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
601 * immediately, and the supplied callback function is called when the
602 * operation is complete. The result value is given as an argument to
603 * the callback function.
604 *
605 *----------------------------------------------------------------------------*/
606CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
607CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
608void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
609void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
610
611/*----------------------------------------------------------------------------*
612 * NAME
613 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
614 *
615 * DESCRIPTION
616 * Read/write a specified number of bytes from/to the specified register
617 * address.
618 *
619 * PARAMETERS
620 * function - Pointer to struct representing the function.
621 * address - Register address within the function.
622 * data - The data to read/write.
623 * length - Number of byte to read/write.
624 * callback - The function to call on operation completion.
625 *
626 * RETURNS
627 * CSR_RESULT_SUCCESS - The data was successfully read/written.
628 * CSR_RESULT_FAILURE - Unspecified/unknown error.
629 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
630 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
631 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
632 * partially read/written.
633 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
634 *
635 * NOTE: If the SDIO R5 response is available, and either of the
636 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
637 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
638 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
639 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
640 * COM_CRC_ERROR bits shall be ignored.
641 *
642 * If the CSPI response is available, and any of the
643 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
644 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
645 *
646 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
647 * immediately, and the supplied callback function is called when the
648 * operation is complete. The result value is given as an argument to
649 * the callback function.
650 *
651 *----------------------------------------------------------------------------*/
652CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
653CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
654void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
655void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
656
657/*----------------------------------------------------------------------------*
658 * NAME
659 * CsrSdioPowerOn, CsrSdioPowerOff
660 *
661 * DESCRIPTION
662 * Power on/off the device.
663 *
664 * PARAMETERS
665 * function - Pointer to struct representing the function that resides on
666 * the device to power on/off.
667 *
668 * RETURNS (only CsrSdioPowerOn)
669 * CSR_RESULT_SUCCESS - Power was successfully reapplied and the device
670 * has been reinitialised.
671 * CSR_RESULT_FAILURE - Unspecified/unknown error.
672 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
673 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
674 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
675 * reinitialisation.
676 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
677 * CsrSdioPowerOff call. The state of the
678 * device is unchanged.
679 *
680 *----------------------------------------------------------------------------*/
681CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
682void CsrSdioPowerOff(CsrSdioFunction *function);
683
684/*----------------------------------------------------------------------------*
685 * NAME
686 * CsrSdioHardReset
687 *
688 * DESCRIPTION
689 * Perform a hardware reset of the device.
690 *
691 * PARAMETERS
692 * function - Pointer to struct representing the function that resides on
693 * the device to hard reset.
694 *
695 * RETURNS
696 * CSR_RESULT_SUCCESS - Reset was successfully performed and the device
697 * has been reinitialised.
698 * CSR_RESULT_FAILURE - Unspecified/unknown error.
699 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
700 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
701 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
702 * reinitialisation.
703 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
704 * supported. The state of the device is
705 * unchanged.
706 *
707 *----------------------------------------------------------------------------*/
708CsrResult CsrSdioHardReset(CsrSdioFunction *function);
709
710/*----------------------------------------------------------------------------*
711 * NAME
712 * CsrSdioFunctionActive, CsrSdioFunctionIdle
713 *
714 * DESCRIPTION
715 *
716 * PARAMETERS
717 * function - Pointer to struct representing the function.
718 *
719 *----------------------------------------------------------------------------*/
720void CsrSdioFunctionActive(CsrSdioFunction *function);
721void CsrSdioFunctionIdle(CsrSdioFunction *function);
722
723#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
index 9713b9afef64..000000000000
--- a/drivers/staging/csr/csr_serialize_primitive_types.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include <linux/module.h>
12#include <linux/slab.h>
13#include "csr_prim_defs.h"
14#include "csr_msgconv.h"
15#include "csr_macro.h"
16
17void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset)
18{
19 *value = buffer[*offset];
20 *offset += sizeof(*value);
21}
22EXPORT_SYMBOL_GPL(CsrUint8Des);
23
24void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset)
25{
26 *value = (buffer[*offset + 0] << 0) |
27 (buffer[*offset + 1] << 8);
28 *offset += sizeof(*value);
29}
30EXPORT_SYMBOL_GPL(CsrUint16Des);
31
32void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset)
33{
34 *value = (buffer[*offset + 0] << 0) |
35 (buffer[*offset + 1] << 8) |
36 (buffer[*offset + 2] << 16) |
37 (buffer[*offset + 3] << 24);
38 *offset += sizeof(*value);
39}
40EXPORT_SYMBOL_GPL(CsrUint32Des);
41
42void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length)
43{
44 memcpy(value, &buffer[*offset], length);
45 *offset += length;
46}
47EXPORT_SYMBOL_GPL(CsrMemCpyDes);
48
49void CsrCharStringDes(char **value, u8 *buffer, size_t *offset)
50{
51 *value = kstrdup((char *) &buffer[*offset], GFP_KERNEL);
52 *offset += strlen(*value) + 1;
53}
54EXPORT_SYMBOL_GPL(CsrCharStringDes);
55
56void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value)
57{
58 buffer[*offset] = value;
59 *offset += sizeof(value);
60}
61EXPORT_SYMBOL_GPL(CsrUint8Ser);
62
63void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value)
64{
65 buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
66 buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
67 *offset += sizeof(value);
68}
69EXPORT_SYMBOL_GPL(CsrUint16Ser);
70
71void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value)
72{
73 buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
74 buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
75 buffer[*offset + 2] = (u8) ((value >> 16) & 0xFF);
76 buffer[*offset + 3] = (u8) ((value >> 24) & 0xFF);
77 *offset += sizeof(value);
78}
79EXPORT_SYMBOL_GPL(CsrUint32Ser);
80
81void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length)
82{
83 memcpy(&buffer[*offset], value, length);
84 *offset += length;
85}
86EXPORT_SYMBOL_GPL(CsrMemCpySer);
87
88void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value)
89{
90 if (value)
91 {
92 strcpy(((char *) &buffer[*offset]), value);
93 *offset += strlen(value) + 1;
94 }
95 else
96 {
97 CsrUint8Ser(buffer, offset, 0);
98 }
99}
100EXPORT_SYMBOL_GPL(CsrCharStringSer);
diff --git a/drivers/staging/csr/csr_time.c b/drivers/staging/csr/csr_time.c
deleted file mode 100644
index 01179e46f47d..000000000000
--- a/drivers/staging/csr/csr_time.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include <linux/kernel.h>
12#include <linux/time.h>
13#include <linux/module.h>
14
15#include "csr_time.h"
16
17u32 CsrTimeGet(u32 *high)
18{
19 struct timespec ts;
20 u64 time;
21 u32 low;
22
23 ts = current_kernel_time();
24 time = (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
25
26 if (high != NULL)
27 *high = (u32) ((time >> 32) & 0xFFFFFFFF);
28
29 low = (u32) (time & 0xFFFFFFFF);
30
31 return low;
32}
33EXPORT_SYMBOL_GPL(CsrTimeGet);
diff --git a/drivers/staging/csr/csr_time.h b/drivers/staging/csr/csr_time.h
deleted file mode 100644
index fc29e8e5e478..000000000000
--- a/drivers/staging/csr/csr_time.h
+++ /dev/null
@@ -1,76 +0,0 @@
1#ifndef CSR_TIME_H__
2#define CSR_TIME_H__
3/*****************************************************************************
4
5(c) Cambridge Silicon Radio Limited 2010
6All rights reserved and confidential information of CSR
7
8Refer to LICENSE.txt included with this source for details
9on the license terms.
10
11*****************************************************************************/
12
13#include <linux/types.h>
14
15/*******************************************************************************
16
17NAME
18 CsrTimeGet
19
20DESCRIPTION
21 Returns the current system time in a low and a high part. The low part
22 is expressed in microseconds. The high part is incremented when the low
23 part wraps to provide an extended range.
24
25 The caller may provide a NULL pointer as the high parameter.
26 In this case the function just returns the low part and ignores the
27 high parameter.
28
29 Although the time is expressed in microseconds the actual resolution is
30 platform dependent and can be less. It is recommended that the
31 resolution is at least 10 milliseconds.
32
33PARAMETERS
34 high - Pointer to variable that will receive the high part of the
35 current system time. Passing NULL is valid.
36
37RETURNS
38 Low part of current system time in microseconds.
39
40*******************************************************************************/
41u32 CsrTimeGet(u32 *high);
42
43
44/*------------------------------------------------------------------*/
45/* CsrTime Macros */
46/*------------------------------------------------------------------*/
47
48/*----------------------------------------------------------------------------*
49 * NAME
50 * CsrTimeAdd
51 *
52 * DESCRIPTION
53 * Add two time values. Adding the numbers can overflow the range of a
54 * CsrTime, so the user must be cautious.
55 *
56 * RETURNS
57 * CsrTime - the sum of "t1" and "t2".
58 *
59 *----------------------------------------------------------------------------*/
60#define CsrTimeAdd(t1, t2) ((t1) + (t2))
61
62/*----------------------------------------------------------------------------*
63 * NAME
64 * CsrTimeSub
65 *
66 * DESCRIPTION
67 * Subtract two time values. Subtracting the numbers can provoke an
68 * underflow, so the user must be cautious.
69 *
70 * RETURNS
71 * CsrTime - "t1" - "t2".
72 *
73 *----------------------------------------------------------------------------*/
74#define CsrTimeSub(t1, t2) ((s32) (t1) - (s32) (t2))
75
76#endif
diff --git a/drivers/staging/csr/csr_util.c b/drivers/staging/csr/csr_util.c
deleted file mode 100644
index c3aa9d509e5c..000000000000
--- a/drivers/staging/csr/csr_util.c
+++ /dev/null
@@ -1,15 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include <linux/module.h>
12
13MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction");
14MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
15MODULE_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
index efc43a525a3d..000000000000
--- a/drivers/staging/csr/csr_wifi_common.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_COMMON_H__
12#define CSR_WIFI_COMMON_H__
13
14#include <linux/types.h>
15#include "csr_result.h"
16
17/* MAC address */
18typedef struct
19{
20 u8 a[6];
21} CsrWifiMacAddress;
22
23/* IPv4 address */
24typedef struct
25{
26 u8 a[4];
27} CsrWifiIp4Address;
28
29/* IPv6 address */
30typedef struct
31{
32 u8 a[16];
33} CsrWifiIp6Address;
34
35typedef struct
36{
37 u8 ssid[32];
38 u8 length;
39} CsrWifiSsid;
40
41/*******************************************************************************
42
43 DESCRIPTION
44 Result values used on the Wifi Interfaces
45
46 VALUES
47 CSR_RESULT_SUCCESS
48 - The request/procedure succeeded
49 CSR_RESULT_FAILURE
50 - The request/procedure did not succeed because of an error
51 CSR_WIFI_RESULT_NOT_FOUND
52 - The request did not succeed because some resource was not
53 found.
54 CSR_WIFI_RESULT_TIMED_OUT
55 - The request/procedure did not succeed because of a time out
56 CSR_WIFI_RESULT_CANCELLED
57 - The request was canceled due to another conflicting
58 request that was issued before this one was completed
59 CSR_WIFI_RESULT_INVALID_PARAMETER
60 - The request/procedure did not succeed because it had an
61 invalid parameter
62 CSR_WIFI_RESULT_NO_ROOM
63 - The request did not succeed due to a lack of resources,
64 e.g. out of memory problem.
65 CSR_WIFI_RESULT_UNSUPPORTED
66 - The request/procedure did not succeed because the feature
67 is not supported yet
68 CSR_WIFI_RESULT_UNAVAILABLE
69 - The request cannot be processed at this time
70 CSR_WIFI_RESULT_WIFI_OFF
71 - The requested action is not available because Wi-Fi is
72 currently off
73 CSR_WIFI_RESULT_SECURITY_ERROR
74 - The request/procedure did not succeed because of a security
75 error
76 CSR_WIFI_RESULT_MIB_SET_FAILURE
77 - MIB Set Failure: either the MIB OID to be written to does
78 not exist or the MIB Value is invalid.
79 CSR_WIFI_RESULT_INVALID_INTERFACE_TAG
80 - The supplied Interface Tag is not valid.
81 CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT
82 - The new NOA configuration conflicts with the existing NOA configuration
83 hence not accepted"
84*******************************************************************************/
85#define CSR_WIFI_RESULT_NOT_FOUND ((CsrResult) 0x0001)
86#define CSR_WIFI_RESULT_TIMED_OUT ((CsrResult) 0x0002)
87#define CSR_WIFI_RESULT_CANCELLED ((CsrResult) 0x0003)
88#define CSR_WIFI_RESULT_INVALID_PARAMETER ((CsrResult) 0x0004)
89#define CSR_WIFI_RESULT_NO_ROOM ((CsrResult) 0x0005)
90#define CSR_WIFI_RESULT_UNSUPPORTED ((CsrResult) 0x0006)
91#define CSR_WIFI_RESULT_UNAVAILABLE ((CsrResult) 0x0007)
92#define CSR_WIFI_RESULT_WIFI_OFF ((CsrResult) 0x0008)
93#define CSR_WIFI_RESULT_SECURITY_ERROR ((CsrResult) 0x0009)
94#define CSR_WIFI_RESULT_MIB_SET_FAILURE ((CsrResult) 0x000A)
95#define CSR_WIFI_RESULT_INVALID_INTERFACE_TAG ((CsrResult) 0x000B)
96#define CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT ((CsrResult) 0x000C)
97
98#define CSR_WIFI_VERSION "5.1.0.0"
99
100#endif
101
diff --git a/drivers/staging/csr/csr_wifi_fsm.h b/drivers/staging/csr/csr_wifi_fsm.h
deleted file mode 100644
index fc5c5aa6a3c4..000000000000
--- a/drivers/staging/csr/csr_wifi_fsm.h
+++ /dev/null
@@ -1,240 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_FSM_H
12#define CSR_WIFI_FSM_H
13
14#include "csr_prim_defs.h"
15#include "csr_log_text.h"
16#include "csr_wifi_fsm_event.h"
17
18/* including this file for CsrWifiInterfaceMode*/
19#include "csr_wifi_common.h"
20
21#define CSR_WIFI_FSM_ENV (0xFFFF)
22
23/**
24 * @brief
25 * Toplevel FSM context data
26 *
27 * @par Description
28 * Holds ALL FSM static and dynamic data for a FSM
29 */
30typedef struct CsrWifiFsmContext CsrWifiFsmContext;
31
32/**
33 * @brief
34 * FSM External Wakeup CallbackFunction Pointer
35 *
36 * @par Description
37 * Defines the external wakeup function for the FSM
38 * to call when an external event is injected into the systen
39 *
40 * @param[in] context : External context
41 *
42 * @return
43 * void
44 */
45typedef void (*CsrWifiFsmExternalWakupCallbackPtr)(void *context);
46
47/**
48 * @brief
49 * Initialises a top level FSM context
50 *
51 * @par Description
52 * Initialises the FSM Context to an initial state and allocates
53 * space for "maxProcesses" number of instances
54 *
55 * @param[in] osaContext : OSA context
56 * @param[in] applicationContext : Internal fsm application context
57 * @param[in] externalContext : External context
58 * @param[in] maxProcesses : Max processes to allocate room for
59 *
60 * @return
61 * CsrWifiFsmContext* fsm context
62 */
63extern CsrWifiFsmContext* CsrWifiFsmInit(void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId);
64
65/**
66 * @brief
67 * Resets the FSM's back to first conditions
68 *
69 * @par Description
70 * This function is used to free any dynamic resources allocated for the
71 * given context by CsrWifiFsmInit().
72 * The FSM's reset function is called to cleanup any fsm specific memory
73 * The reset function does NOT need to free the fsm data pointer as
74 * CsrWifiFsmShutdown() will do it.
75 * the FSM's init function is call again to reinitialise the FSM context.
76 * CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running.
77 *
78 * @param[in] context : FSM context
79 *
80 * @return
81 * void
82 */
83extern void CsrWifiFsmReset(CsrWifiFsmContext *context);
84
85/**
86 * @brief
87 * Frees resources allocated by CsrWifiFsmInit
88 *
89 * @par Description
90 * This function is used to free any dynamic resources allocated for the
91 * given context by CsrWifiFsmInit(), prior to complete termination of
92 * the program.
93 * The FSM's reset function is called to cleanup any fsm specific memory.
94 * The reset function does NOT need to free the fsm data pointer as
95 * CsrWifiFsmShutdown() will do it.
96 * CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running.
97 *
98 * @param[in] context : FSM context
99 *
100 * @return
101 * void
102 */
103extern void CsrWifiFsmShutdown(CsrWifiFsmContext *context);
104
105/**
106 * @brief
107 * Executes the fsm context
108 *
109 * @par Description
110 * Executes the FSM context and runs until ALL events in the context are processed.
111 * When no more events are left to process then CsrWifiFsmExecute() returns to a time
112 * specifying when to next call the CsrWifiFsmExecute()
113 * Scheduling, threading, blocking and external event notification are outside
114 * the scope of the FSM and CsrWifiFsmExecute().
115 *
116 * @param[in] context : FSM context
117 *
118 * @return
119 * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
120 */
121extern u32 CsrWifiFsmExecute(CsrWifiFsmContext *context);
122
123/**
124 * @brief
125 * Adds an event to the FSM context's external event queue for processing
126 *
127 * @par Description
128 * Adds an event to the contexts external queue
129 * This is thread safe and adds an event to the fsm's external event queue.
130 *
131 * @param[in] context : FSM context
132 * @param[in] event : event to add to the event queue
133 * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
134 * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
135 * @param[in] id : event id
136 *
137 * @return
138 * void
139 */
140extern void CsrWifiFsmSendEventExternal(CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id);
141
142/**
143 * @brief
144 * Adds an Alien event to the FSM context's external event queue for processing
145 *
146 * @par Description
147 * Adds an event to the contexts external queue
148 * This is thread safe and adds an event to the fsm's external event queue.
149 *
150 * @param[in] context : FSM context
151 * @param[in] event : event to add to the event queue
152 * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
153 * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
154 * @param[in] id : event id
155 */
156#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id) \
157 { \
158 CsrWifiFsmAlienEvent *_evt = kmalloc(sizeof(CsrWifiFsmAlienEvent), GFP_KERNEL); \
159 _evt->alienEvent = _alienEvent; \
160 CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \
161 }
162
163
164/**
165 * @brief
166 * Current time of day in ms
167 *
168 * @param[in] context : FSM context
169 *
170 * @return
171 * u32 32 bit ms tick
172 */
173extern u32 CsrWifiFsmGetTimeOfDayMs(CsrWifiFsmContext *context);
174
175/**
176 * @brief
177 * Gets the time until the next FSM timer expiry
178 *
179 * @par Description
180 * Returns the next timeout time or 0 if no timers are set.
181 *
182 * @param[in] context : FSM context
183 *
184 * @return
185 * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
186 */
187extern u32 CsrWifiFsmGetNextTimeout(CsrWifiFsmContext *context);
188
189/**
190 * @brief
191 * Fast forwards the fsm timers by ms Milliseconds
192 *
193 * @param[in] context : FSM context
194 * @param[in] ms : Milliseconds to fast forward by
195 *
196 * @return
197 * void
198 */
199extern void CsrWifiFsmFastForward(CsrWifiFsmContext *context, u16 ms);
200
201/**
202 * @brief
203 * shift the current time of day by ms amount
204 *
205 * @par Description
206 * useful to speed up tests where time needs to pass
207 *
208 * @param[in] context : FSM context
209 * @param[in] ms : ms to adjust time by
210 *
211 * @return
212 * void
213 */
214extern void CsrWifiFsmTestAdvanceTime(CsrWifiFsmContext *context, u32 ms);
215
216/**
217 * @brief
218 * Check if the fsm has events to process
219 *
220 * @param[in] context : FSM context
221 *
222 * @return
223 * u8 returns TRUE if there are events for the FSM to process
224 */
225extern u8 CsrWifiFsmHasEvents(CsrWifiFsmContext *context);
226
227/**
228 * @brief
229 * function that installs the contexts wakeup function
230 *
231 * @param[in] context : FSM context
232 * @param[in] callback : Callback function pointer
233 *
234 * @return
235 * void
236 */
237extern void CsrWifiFsmInstallWakeupCallback(CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback);
238
239#endif /* CSR_WIFI_FSM_H */
240
diff --git a/drivers/staging/csr/csr_wifi_fsm_event.h b/drivers/staging/csr/csr_wifi_fsm_event.h
deleted file mode 100644
index 0690ca955ef5..000000000000
--- a/drivers/staging/csr/csr_wifi_fsm_event.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_FSM_EVENT_H
12#define CSR_WIFI_FSM_EVENT_H
13
14#include "csr_prim_defs.h"
15#include "csr_sched.h"
16
17/**
18 * @brief
19 * FSM event header.
20 *
21 * @par Description
22 * All events MUST have this struct as the FIRST member.
23 * The next member is used internally for linked lists
24 */
25typedef struct CsrWifiFsmEvent
26{
27 CsrPrim type;
28 u16 primtype;
29 CsrSchedQid destination;
30 CsrSchedQid source;
31
32 /* Private pointer to allow an optimal Event list */
33 /* NOTE: Ignore this pointer.
34 * Do not waste code initializing OR freeing it.
35 * The pointer is used internally in the CsrWifiFsm code
36 * to avoid a second malloc when queuing events.
37 */
38 struct CsrWifiFsmEvent *next;
39} CsrWifiFsmEvent;
40
41#endif /* CSR_WIFI_FSM_EVENT_H */
42
diff --git a/drivers/staging/csr/csr_wifi_fsm_types.h b/drivers/staging/csr/csr_wifi_fsm_types.h
deleted file mode 100644
index d21c60a81fcf..000000000000
--- a/drivers/staging/csr/csr_wifi_fsm_types.h
+++ /dev/null
@@ -1,430 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_FSM_TYPES_H
12#define CSR_WIFI_FSM_TYPES_H
13
14#include <linux/types.h>
15#include "csr_macro.h"
16#include "csr_sched.h"
17
18#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
19#include "csr_framework_ext.h"
20#endif
21
22#include "csr_wifi_fsm.h"
23
24#define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10
25
26/**
27 * @brief
28 * FSM event list header.
29 *
30 * @par Description
31 * Singly linked list of events.
32 */
33typedef struct CsrWifiFsmEventList
34{
35 CsrWifiFsmEvent *first;
36 CsrWifiFsmEvent *last;
37} CsrWifiFsmEventList;
38
39
40/**
41 * @brief
42 * FSM timer id.
43 *
44 * @par Description
45 * Composite Id made up of the type, dest and a unique id so
46 * CsrWifiFsmRemoveTimer knows where to look when removing the timer
47 */
48typedef struct CsrWifiFsmTimerId
49{
50 CsrPrim type;
51 u16 primtype;
52 CsrSchedQid destination;
53 u16 uniqueid;
54} CsrWifiFsmTimerId;
55
56/**
57 * @brief
58 * FSM timer header.
59 *
60 * @par Description
61 * All timer MUST have this struct as the FIRST member.
62 * The first members of the structure MUST remain compatable
63 * with the CsrWifiFsmEvent so that timers are just specialised events
64 */
65typedef struct CsrWifiFsmTimer
66{
67 CsrPrim type;
68 u16 primtype;
69 CsrSchedQid destination;
70 CsrSchedQid source;
71
72 /* Private pointer to allow an optimal Event list */
73 struct CsrWifiFsmTimer *next;
74
75 CsrWifiFsmTimerId timerid;
76 u32 timeoutTimeMs;
77} CsrWifiFsmTimer;
78
79
80/**
81 * @brief
82 * Fsm Alien Event
83 *
84 * @par Description
85 * Allows the wrapping of alien events that do not use CsrWifiFsmEvent
86 * as the first member of the Event struct
87 */
88typedef struct
89{
90 CsrWifiFsmEvent event;
91 void *alienEvent;
92} CsrWifiFsmAlienEvent;
93
94
95/**
96 * @brief
97 * FSM timer list header.
98 *
99 * @par Description
100 * Singly linked list of timers.
101 */
102typedef struct CsrWifiFsmTimerList
103{
104 CsrWifiFsmTimer *first;
105 CsrWifiFsmTimer *last;
106 u16 nexttimerid;
107} CsrWifiFsmTimerList;
108
109/**
110 * @brief
111 * Process Entry Function Pointer
112 *
113 * @par Description
114 * Defines the entry function for a processes.
115 * Called at process initialisation.
116 *
117 * @param[in] context : FSM context
118 *
119 * @return
120 * void
121 */
122typedef void (*CsrWifiFsmProcEntryFnPtr)(CsrWifiFsmContext *context);
123
124/**
125 * @brief
126 * Process Transition Function Pointer
127 *
128 * @par Description
129 * Defines a transition function for a processes.
130 * Called when an event causes a transition on a process
131 *
132 * @param[in] CsrWifiFsmContext* : FSM context
133 * @param[in] void* : FSM data (can be NULL)
134 * @param[in] const CsrWifiFsmEvent* : event to process
135 *
136 * @return
137 * void
138 */
139typedef void (*CsrWifiFsmTransitionFnPtr)(CsrWifiFsmContext *context, void *fsmData, const CsrWifiFsmEvent *event);
140
141/**
142 * @brief
143 * Process reset/shutdown Function Pointer
144 *
145 * @par Description
146 * Defines the reset/shutdown function for a processes.
147 * Called to reset or shutdown an fsm.
148 *
149 * @param[in] context : FSM context
150 *
151 * @return
152 * void
153 */
154typedef void (*CsrWifiFsmProcResetFnPtr)(CsrWifiFsmContext *context);
155
156/**
157 * @brief
158 * FSM Default Destination CallbackFunction Pointer
159 *
160 * @par Description
161 * Defines the default destination function for the FSM
162 * to call when an event does not have a valid destination.
163 * This
164 *
165 * @param[in] context : External context
166 *
167 * @return
168 * u16 a valid destination OR CSR_WIFI_FSM_ENV
169 */
170typedef u16 (*CsrWifiFsmDestLookupCallbackPtr)(void *context, const CsrWifiFsmEvent *event);
171
172
173#ifdef CSR_WIFI_FSM_DUMP_ENABLE
174/**
175 * @brief
176 * Trace Dump Function Pointer
177 *
178 * @par Description
179 * Called when we want to trace the FSM
180 *
181 * @param[in] context : FSM context
182 * @param[in] id : fsm id
183 *
184 * @return
185 * void
186 */
187typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData);
188#endif
189
190/**
191 * @brief
192 * Event ID to transition function entry
193 *
194 * @par Description
195 * Event ID to Transition Entry in a state table.
196 */
197typedef struct
198{
199 u32 eventid;
200 CsrWifiFsmTransitionFnPtr transition;
201#ifdef CSR_LOG_ENABLE
202 const char *transitionName;
203#endif
204} CsrWifiFsmEventEntry;
205
206/**
207 * @brief
208 * Single State's Transition Table
209 *
210 * @par Description
211 * Stores Data for a single State's event to
212 * transition functions mapping
213 */
214typedef struct
215{
216 const u8 numEntries;
217 const u8 saveAll;
218 const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */
219#ifdef CSR_LOG_ENABLE
220 u16 stateNumber;
221 const char *stateName;
222#endif
223} CsrWifiFsmTableEntry;
224
225/**
226 * @brief
227 * Process State Transtion table
228 *
229 * @par Description
230 * Stores Data for a processes State to transition table
231 */
232typedef struct
233{
234 u16 numStates; /* number of states */
235 const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix */
236} CsrWifiFsmTransitionFunctionTable;
237
238/**
239 * @brief
240 * Const Process definition
241 *
242 * @par Description
243 * Constant process specification.
244 * This is ALL the non dynamic data that defines
245 * a process.
246 */
247typedef struct
248{
249 const char *processName;
250 const u32 processId;
251 const CsrWifiFsmTransitionFunctionTable transitionTable;
252 const CsrWifiFsmTableEntry unhandledTransitions;
253 const CsrWifiFsmTableEntry ignoreFunctions;
254 const CsrWifiFsmProcEntryFnPtr entryFn;
255 const CsrWifiFsmProcResetFnPtr resetFn;
256#ifdef CSR_WIFI_FSM_DUMP_ENABLE
257 const CsrWifiFsmDumpFnPtr dumpFn; /* Called to dump fsm specific trace if not NULL */
258#endif
259} CsrWifiFsmProcessStateMachine;
260
261#ifdef CSR_WIFI_FSM_DUMP_ENABLE
262/**
263 * @brief
264 * Storage for state transition info
265 */
266typedef struct
267{
268 u16 transitionNumber;
269 CsrWifiFsmEvent event;
270 u16 fromState;
271 u16 toState;
272 CsrWifiFsmTransitionFnPtr transitionFn;
273 u16 transitionCount; /* number consecutive of times this transition was seen */
274#ifdef CSR_LOG_ENABLE
275 const char *transitionName;
276#endif
277} CsrWifiFsmTransitionRecord;
278
279/**
280 * @brief
281 * Storage for the last state X transitions
282 */
283typedef struct
284{
285 u16 numTransitions;
286 CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY];
287} CsrWifiFsmTransitionRecords;
288#endif
289
290/**
291 * @brief
292 * Dynamic Process data
293 *
294 * @par Description
295 * Dynamic process data that is used to keep track of the
296 * state and data for a process instance
297 */
298typedef struct
299{
300 const CsrWifiFsmProcessStateMachine *fsmInfo; /* state machine info that is constant regardless of context */
301 u16 instanceId; /* Runtime process id */
302 u16 state; /* Current state */
303 void *params; /* Instance user data */
304 CsrWifiFsmEventList savedEventQueue; /* The saved event queue */
305 struct CsrWifiFsmInstanceEntry *subFsm; /* Sub Fsm instance data */
306 struct CsrWifiFsmInstanceEntry *subFsmCaller; /* The Fsm instance that created the SubFsm and should be used for callbacks*/
307#ifdef CSR_WIFI_FSM_DUMP_ENABLE
308 CsrWifiFsmTransitionRecords transitionRecords; /* Last X transitions in the FSM */
309#endif
310} CsrWifiFsmInstanceEntry;
311
312/**
313 * @brief
314 * OnCreate Callback Function Pointer
315 *
316 * @par Description
317 * Called when an fsm is created.
318 *
319 * @param[in] extContext : External context
320 * @param[in] instance : FSM instance
321 *
322 * @return
323 * void
324 */
325typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance);
326
327/**
328 * @brief
329 * OnTransition Callback Function Pointer
330 *
331 * @par Description
332 * Called when an event is processed by a fsm
333 *
334 * @param[in] extContext : External context
335 * @param[in] eventEntryArray : Entry data
336 * @param[in] event : Event
337 *
338 * @return
339 * void
340 */
341typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event);
342
343/**
344 * @brief
345 * OnStateChange Callback Function Pointer
346 *
347 * @par Description
348 * Called when CsrWifiFsmNextState is called
349 *
350 * @param[in] extContext : External context
351 *
352 * @return
353 * void
354 */
355typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate);
356
357/**
358 * @brief
359 * OnIgnore,OnError or OnInvalid Callback Function Pointer
360 *
361 * @par Description
362 * Called when an event is processed by a fsm
363 *
364 * @param[in] extContext : External context
365 * @param[in] event : Event
366 *
367 * @return
368 * void
369 */
370typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event);
371
372/**
373 * @brief
374 * Toplevel FSM context data
375 *
376 * @par Description
377 * Holds ALL FSM static and dynamic data for a FSM
378 */
379struct CsrWifiFsmContext
380{
381 CsrWifiFsmEventList eventQueue; /* The internal event queue */
382 CsrWifiFsmEventList externalEventQueue; /* The external event queue */
383#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
384 CsrMutexHandle externalEventQueueLock; /* The external event queue mutex */
385#endif
386 u32 timeOffset; /* Amount to adjust the TimeOfDayMs by */
387 CsrWifiFsmTimerList timerQueue; /* The internal timer queue */
388 u8 useTempSaveList; /* Should the temp save list be used */
389 CsrWifiFsmEventList tempSaveList; /* The temp save event queue */
390 CsrWifiFsmEvent *eventForwardedOrSaved; /* The event that was forwarded or Saved */
391 u16 maxProcesses; /* Size of instanceArray */
392 u16 numProcesses; /* Current number allocated in instanceArray */
393 CsrWifiFsmInstanceEntry *instanceArray; /* Array of processes for this component */
394 CsrWifiFsmInstanceEntry *ownerInstance; /* The Process that owns currentInstance (SubFsm support) */
395 CsrWifiFsmInstanceEntry *currentInstance; /* Current Process that is executing */
396 CsrWifiFsmExternalWakupCallbackPtr externalEventFn; /* External event Callback */
397 CsrWifiFsmOnEventFnPtr appIgnoreCallback; /* Application Ignore event Callback */
398 CsrWifiFsmDestLookupCallbackPtr appEvtDstCallback; /* Application Lookup event Destination Function*/
399
400 void *applicationContext; /* Internal fsm application context */
401 void *externalContext; /* External context (set by the user of the fsm)*/
402 CsrLogTextTaskId loggingTaskId; /* Task Id to use in any logging output */
403
404#ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED
405 CsrSchedTid schedTimerId; /* Scheduler TimerId for use in Scheduler Tasks */
406 u32 schedTimerNexttimeoutMs; /* Next timeout time for the current timer */
407#endif
408
409#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
410#ifdef CSR_WIFI_FSM_TRANSITION_LOCK
411 CsrMutexHandle transitionLock; /* Lock when calling transition functions */
412#endif
413#endif
414
415#ifdef CSR_LOG_ENABLE
416 CsrWifiFsmOnCreateFnPtr onCreate; /* Debug Transition Callback */
417 CsrWifiFsmOnTransitionFnPtr onTransition; /* Debug Transition Callback */
418 CsrWifiFsmOnTransitionFnPtr onUnhandedCallback; /* Unhanded event Callback */
419 CsrWifiFsmOnStateChangeFnPtr onStateChange; /* Debug State Change Callback */
420 CsrWifiFsmOnEventFnPtr onIgnoreCallback; /* Ignore event Callback */
421 CsrWifiFsmOnEventFnPtr onSaveCallback; /* Save event Callback */
422 CsrWifiFsmOnEventFnPtr onErrorCallback; /* Error event Callback */
423 CsrWifiFsmOnEventFnPtr onInvalidCallback; /* Invalid event Callback */
424#endif
425#ifdef CSR_WIFI_FSM_DUMP_ENABLE
426 u16 masterTransitionNumber; /* Increments on every transition */
427#endif
428};
429
430#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
index bd47f606e0de..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_card.h
+++ /dev/null
@@ -1,114 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 ******************************************************************************
13 * FILE : csr_wifi_hip_card.h
14 *
15 * PURPOSE : Defines abstract interface for hardware specific functions.
16 * Note, this is a different file from one of the same name in the
17 * Windows driver.
18 *
19 *****************************************************************************
20 */
21#ifndef __CARD_H__
22#define __CARD_H__
23
24#include "csr_wifi_hip_card_sdio.h"
25#include "csr_wifi_hip_signals.h"
26#include "csr_wifi_hip_unifi_udi.h"
27
28
29/*****************************************************************************
30 * CardEnableInt -
31 */
32CsrResult CardEnableInt(card_t *card);
33
34/*****************************************************************************
35 * CardGenInt -
36 */
37CsrResult CardGenInt(card_t *card);
38
39/*****************************************************************************
40 * CardPendingInt -
41 */
42CsrResult CardPendingInt(card_t *card, u8 *pintr);
43
44/*****************************************************************************
45 * CardDisableInt -
46 */
47CsrResult CardDisableInt(card_t *card);
48
49/*****************************************************************************
50 * CardClearInt -
51 */
52CsrResult CardClearInt(card_t *card);
53
54/*****************************************************************************
55 * CardDisable -
56 */
57void CardDisable(card_t *card);
58
59/*****************************************************************************
60 * CardIntEnabled -
61 */
62CsrResult CardIntEnabled(card_t *card, u8 *enabled);
63
64/*****************************************************************************
65 * CardGetDataSlotSize
66 */
67u16 CardGetDataSlotSize(card_t *card);
68
69/*****************************************************************************
70 * CardWriteBulkData -
71 */
72CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue);
73
74
75/*****************************************************************************
76 * CardClearFromHostDataSlot -
77 */
78void CardClearFromHostDataSlot(card_t *card, const s16 aSlotNum);
79
80#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
81/*****************************************************************************
82 * CardClearFromHostDataSlotWithoutFreeingBulkData - Clear the data stot
83 * without freeing the bulk data
84 */
85
86void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 aSlotNum);
87#endif
88
89/*****************************************************************************
90 * CardGetFreeFromHostDataSlots -
91 */
92u16 CardGetFreeFromHostDataSlots(card_t *card);
93
94u16 CardAreAllFromHostDataSlotsEmpty(card_t *card);
95
96CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which);
97
98CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr);
99
100CsrResult unifi_dl_firmware(card_t *card, void *arg);
101CsrResult unifi_dl_patch(card_t *card, void *arg, u32 boot_ctrl);
102CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode);
103void* unifi_dl_fw_read_start(card_t *card, s8 is_fw);
104
105CsrResult unifi_coredump_handle_request(card_t *card);
106
107CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult);
108#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
109void unifi_debug_log_to_buf(const char *fmt, ...);
110void unifi_debug_string_to_buf(const char *str);
111void unifi_debug_hex_to_buf(const char *buff, u16 length);
112#endif
113
114#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
index d5425325894c..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_card_sdio.c
+++ /dev/null
@@ -1,4001 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_card_sdio.c
14 *
15 * PURPOSE: Implementation of the Card API for SDIO.
16 *
17 * NOTES:
18 * CardInit() is called from the SDIO probe callback when a card is
19 * inserted. This performs the basic SDIO initialisation, enabling i/o
20 * etc.
21 *
22 * ---------------------------------------------------------------------------
23 */
24#include <linux/slab.h>
25#include "csr_wifi_hip_unifi.h"
26#include "csr_wifi_hip_conversions.h"
27#include "csr_wifi_hip_unifiversion.h"
28#include "csr_wifi_hip_card.h"
29#include "csr_wifi_hip_card_sdio.h"
30#include "csr_wifi_hip_chiphelper.h"
31
32
33/* Time to wait between attempts to read MAILBOX0 */
34#define MAILBOX1_TIMEOUT 10 /* in millisecs */
35#define MAILBOX1_ATTEMPTS 200 /* 2 seconds */
36
37#define MAILBOX2_TIMEOUT 5 /* in millisecs */
38#define MAILBOX2_ATTEMPTS 10 /* 50ms */
39
40#define RESET_SETTLE_DELAY 25 /* in millisecs */
41
42static CsrResult card_init_slots(card_t *card);
43static CsrResult card_hw_init(card_t *card);
44static CsrResult firmware_present_in_flash(card_t *card);
45static void bootstrap_chip_hw(card_t *card);
46static CsrResult unifi_reset_hardware(card_t *card);
47static CsrResult unifi_hip_init(card_t *card);
48static CsrResult card_access_panic(card_t *card);
49static CsrResult unifi_read_chip_version(card_t *card);
50
51/*
52 * ---------------------------------------------------------------------------
53 * unifi_alloc_card
54 *
55 * Allocate and initialise the card context structure.
56 *
57 * Arguments:
58 * sdio Pointer to SDIO context pointer to pass to low
59 * level i/o functions.
60 * ospriv Pointer to O/S private struct to pass when calling
61 * callbacks to the higher level system.
62 *
63 * Returns:
64 * Pointer to card struct, which represents the driver context or
65 * NULL if the allocation failed.
66 * ---------------------------------------------------------------------------
67 */
68card_t* unifi_alloc_card(CsrSdioFunction *sdio, void *ospriv)
69{
70 card_t *card;
71 u32 i;
72
73
74 card = kzalloc(sizeof(card_t), GFP_KERNEL);
75 if (card == NULL)
76 {
77 return NULL;
78 }
79
80 card->sdio_if = sdio;
81 card->ospriv = ospriv;
82
83 card->unifi_interrupt_seq = 1;
84
85 /* Make these invalid. */
86 card->proc_select = (u32)(-1);
87 card->dmem_page = (u32)(-1);
88 card->pmem_page = (u32)(-1);
89
90 card->bh_reason_host = 0;
91 card->bh_reason_unifi = 0;
92
93 for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
94 {
95 card->tx_q_paused_flag[i] = 0;
96 }
97 card->memory_resources_allocated = 0;
98
99 card->low_power_mode = UNIFI_LOW_POWER_DISABLED;
100 card->periodic_wake_mode = UNIFI_PERIODIC_WAKE_HOST_DISABLED;
101
102 card->host_state = UNIFI_HOST_STATE_AWAKE;
103 card->intmode = CSR_WIFI_INTMODE_DEFAULT;
104
105 /*
106 * Memory resources for buffers are allocated when the chip is initialised
107 * because we need configuration information from the firmware.
108 */
109
110 /*
111 * Initialise wait queues and lists
112 */
113 card->fh_command_queue.q_body = card->fh_command_q_body;
114 card->fh_command_queue.q_length = UNIFI_SOFT_COMMAND_Q_LENGTH;
115
116 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
117 {
118 card->fh_traffic_queue[i].q_body = card->fh_traffic_q_body[i];
119 card->fh_traffic_queue[i].q_length = UNIFI_SOFT_TRAFFIC_Q_LENGTH;
120 }
121
122
123 /* Initialise mini-coredump pointers in case no coredump buffers
124 * are requested by the OS layer.
125 */
126 card->request_coredump_on_reset = 0;
127 card->dump_next_write = NULL;
128 card->dump_cur_read = NULL;
129 card->dump_buf = NULL;
130
131#ifdef UNIFI_DEBUG
132 /* Determine offset of LSB in pointer for later alignment sanity check.
133 * Synergy integer types have specific widths, which cause compiler
134 * warnings when casting pointer types, e.g. on 64-bit systems.
135 */
136 {
137 u32 val = 0x01234567;
138
139 if (*((u8 *)&val) == 0x01)
140 {
141 card->lsb = sizeof(void *) - 1; /* BE */
142 }
143 else
144 {
145 card->lsb = 0; /* LE */
146 }
147 }
148#endif
149 return card;
150} /* unifi_alloc_card() */
151
152
153/*
154 * ---------------------------------------------------------------------------
155 * unifi_init_card
156 *
157 * Reset the hardware and perform HIP initialization
158 *
159 * Arguments:
160 * card Pointer to card struct
161 *
162 * Returns:
163 * CsrResult code
164 * CSR_RESULT_SUCCESS if successful
165 * ---------------------------------------------------------------------------
166 */
167CsrResult unifi_init_card(card_t *card, s32 led_mask)
168{
169 CsrResult r;
170
171
172 if (card == NULL)
173 {
174 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
175 }
176
177 r = unifi_init(card);
178 if (r != CSR_RESULT_SUCCESS)
179 {
180 return r;
181 }
182
183 r = unifi_hip_init(card);
184 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
185 {
186 return r;
187 }
188 if (r != CSR_RESULT_SUCCESS)
189 {
190 unifi_error(card->ospriv, "Failed to start host protocol.\n");
191 return r;
192 }
193
194 return CSR_RESULT_SUCCESS;
195}
196
197
198/*
199 * ---------------------------------------------------------------------------
200 * unifi_init
201 *
202 * Init the hardware.
203 *
204 * Arguments:
205 * card Pointer to card struct
206 *
207 * Returns:
208 * CsrResult code
209 * CSR_RESULT_SUCCESS if successful
210 * ---------------------------------------------------------------------------
211 */
212CsrResult unifi_init(card_t *card)
213{
214 CsrResult r;
215 CsrResult csrResult;
216
217 if (card == NULL)
218 {
219 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
220 }
221
222 /*
223 * Disable the SDIO interrupts while initialising UniFi.
224 * Re-enable them when f/w is running.
225 */
226 csrResult = CsrSdioInterruptDisable(card->sdio_if);
227 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
228 {
229 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
230 }
231
232 /*
233 * UniFi's PLL may start with a slow clock (~ 1 MHz) so initially
234 * set the SDIO bus clock to a similar value or SDIO accesses may
235 * fail.
236 */
237 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
238 if (csrResult != CSR_RESULT_SUCCESS)
239 {
240 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
241 return r;
242 }
243 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
244
245 /*
246 * Reset UniFi. Note, this only resets the WLAN function part of the chip,
247 * the SDIO interface is not reset.
248 */
249 unifi_trace(card->ospriv, UDBG1, "Resetting UniFi\n");
250 r = unifi_reset_hardware(card);
251 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
252 {
253 return r;
254 }
255 if (r != CSR_RESULT_SUCCESS)
256 {
257 unifi_error(card->ospriv, "Failed to reset UniFi\n");
258 return r;
259 }
260
261 /* Reset the power save mode, to be active until the MLME-reset is complete */
262 r = unifi_configure_low_power_mode(card,
263 UNIFI_LOW_POWER_DISABLED, UNIFI_PERIODIC_WAKE_HOST_DISABLED);
264 if (r != CSR_RESULT_SUCCESS)
265 {
266 unifi_error(card->ospriv, "Failed to set power save mode\n");
267 return r;
268 }
269
270 /*
271 * Set initial value of page registers.
272 * The page registers will be maintained by unifi_read...() and
273 * unifi_write...().
274 */
275 card->proc_select = (u32)(-1);
276 card->dmem_page = (u32)(-1);
277 card->pmem_page = (u32)(-1);
278 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, 0);
279 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
280 {
281 return r;
282 }
283 if (r != CSR_RESULT_SUCCESS)
284 {
285 unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
286 return r;
287 }
288 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, 0);
289 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
290 {
291 return r;
292 }
293 if (r != CSR_RESULT_SUCCESS)
294 {
295 unifi_error(card->ospriv, "Failed to write PROG_MEM2_PAGE\n");
296 return r;
297 }
298
299 /*
300 * If the driver has reset UniFi due to previous SDIO failure, this may
301 * have been due to a chip watchdog reset. In this case, the driver may
302 * have requested a mini-coredump which needs to be captured now the
303 * SDIO interface is alive.
304 */
305 (void)unifi_coredump_handle_request(card);
306
307 /*
308 * Probe to see if the UniFi has ROM/flash to boot from. CSR6xxx should do.
309 */
310 r = firmware_present_in_flash(card);
311 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
312 {
313 return r;
314 }
315 if (r == CSR_WIFI_HIP_RESULT_NOT_FOUND)
316 {
317 unifi_error(card->ospriv, "No firmware found\n");
318 }
319 else if (r != CSR_RESULT_SUCCESS)
320 {
321 unifi_error(card->ospriv, "Probe for Flash failed\n");
322 }
323
324 return r;
325} /* unifi_init() */
326
327
328/*
329 * ---------------------------------------------------------------------------
330 * unifi_download
331 *
332 * Load the firmware.
333 *
334 * Arguments:
335 * card Pointer to card struct
336 * led_mask Loader LED mask
337 *
338 * Returns:
339 * CSR_RESULT_SUCCESS on success
340 * CsrResult error code on failure.
341 * ---------------------------------------------------------------------------
342 */
343CsrResult unifi_download(card_t *card, s32 led_mask)
344{
345 CsrResult r;
346 void *dlpriv;
347
348 if (card == NULL)
349 {
350 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
351 }
352
353 /* Set the loader led mask */
354 card->loader_led_mask = led_mask;
355
356 /* Get the firmware file information */
357 unifi_trace(card->ospriv, UDBG1, "downloading firmware...\n");
358
359 dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
360 if (dlpriv == NULL)
361 {
362 return CSR_WIFI_HIP_RESULT_NOT_FOUND;
363 }
364
365 /* Download the firmware. */
366 r = unifi_dl_firmware(card, dlpriv);
367 if (r != CSR_RESULT_SUCCESS)
368 {
369 unifi_error(card->ospriv, "Failed to download firmware\n");
370 return r;
371 }
372
373 /* Free the firmware file information. */
374 unifi_fw_read_stop(card->ospriv, dlpriv);
375
376 return CSR_RESULT_SUCCESS;
377} /* unifi_download() */
378
379
380/*
381 * ---------------------------------------------------------------------------
382 * unifi_hip_init
383 *
384 * This function performs the f/w initialisation sequence as described
385 * in the Unifi Host Interface Protocol Specification.
386 * It allocates memory for host-side slot data and signal queues.
387 *
388 * Arguments:
389 * card Pointer to card struct
390 *
391 * Returns:
392 * CSR_RESULT_SUCCESS on success or else a CSR error code
393 *
394 * Notes:
395 * The firmware must have been downloaded.
396 * ---------------------------------------------------------------------------
397 */
398static CsrResult unifi_hip_init(card_t *card)
399{
400 CsrResult r;
401 CsrResult csrResult;
402
403 r = card_hw_init(card);
404 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
405 {
406 return r;
407 }
408 if (r != CSR_RESULT_SUCCESS)
409 {
410 unifi_error(card->ospriv, "Failed to establish communication with UniFi\n");
411 return r;
412 }
413#ifdef CSR_PRE_ALLOC_NET_DATA
414 /* if there is any preallocated netdata left from the prev session free it now */
415 prealloc_netdata_free(card);
416#endif
417 /*
418 * Allocate memory for host-side slot data and signal queues.
419 * We need the config info read from the firmware to know how much
420 * memory to allocate.
421 */
422 r = card_init_slots(card);
423 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
424 {
425 return r;
426 }
427 if (r != CSR_RESULT_SUCCESS)
428 {
429 unifi_error(card->ospriv, "Init slots failed: %d\n", r);
430 return r;
431 }
432
433 unifi_trace(card->ospriv, UDBG2, "Sending first UniFi interrupt\n");
434
435 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
436 if (r != CSR_RESULT_SUCCESS)
437 {
438 return r;
439 }
440
441 /* Enable the SDIO interrupts now that the f/w is running. */
442 csrResult = CsrSdioInterruptEnable(card->sdio_if);
443 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
444 {
445 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
446 }
447
448 /* Signal the UniFi to start handling messages */
449 r = CardGenInt(card);
450 if (r != CSR_RESULT_SUCCESS)
451 {
452 return r;
453 }
454
455 return CSR_RESULT_SUCCESS;
456} /* unifi_hip_init() */
457
458
459/*
460 * ---------------------------------------------------------------------------
461 * _build_sdio_config_data
462 *
463 * Unpack the SDIO configuration information from a buffer read from
464 * UniFi into a host structure.
465 * The data is byte-swapped for a big-endian host if necessary by the
466 * UNPACK... macros.
467 *
468 * Arguments:
469 * card Pointer to card struct
470 * cfg_data Destination structure to unpack into.
471 * cfg_data_buf Source buffer to read from. This should be the raw
472 * data read from UniFi.
473 *
474 * Returns:
475 * None.
476 * ---------------------------------------------------------------------------
477 */
478static void _build_sdio_config_data(sdio_config_data_t *cfg_data,
479 const u8 *cfg_data_buf)
480{
481 s16 offset = 0;
482
483 cfg_data->version = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
484 offset += SIZEOF_UINT16;
485
486 cfg_data->sdio_ctrl_offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
487 offset += SIZEOF_UINT16;
488
489 cfg_data->fromhost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
490 offset += SIZEOF_UINT16;
491
492 cfg_data->tohost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
493 offset += SIZEOF_UINT16;
494
495 cfg_data->num_fromhost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
496 offset += SIZEOF_UINT16;
497
498 cfg_data->num_tohost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
499 offset += SIZEOF_UINT16;
500
501 cfg_data->num_fromhost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
502 offset += SIZEOF_UINT16;
503
504 cfg_data->num_tohost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
505 offset += SIZEOF_UINT16;
506
507 cfg_data->data_slot_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
508 offset += SIZEOF_UINT16;
509
510 cfg_data->initialised = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
511 offset += SIZEOF_UINT16;
512
513 cfg_data->overlay_size = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
514 offset += SIZEOF_UINT32;
515
516 cfg_data->data_slot_round = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
517 offset += SIZEOF_UINT16;
518
519 cfg_data->sig_frag_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
520 offset += SIZEOF_UINT16;
521
522 cfg_data->tohost_signal_padding = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
523} /* _build_sdio_config_data() */
524
525
526/*
527 * - Function ----------------------------------------------------------------
528 * card_hw_init()
529 *
530 * Perform the initialisation procedure described in the UniFi Host
531 * Interface Protocol document (section 3.3.8) and read the run-time
532 * configuration information from the UniFi. This is stuff like number
533 * of bulk data slots etc.
534 *
535 * The card enumeration and SD initialisation has already been done by
536 * the SDIO library, see card_sdio_init().
537 *
538 * The initialisation is done when firmware is ready, i.e. this may need
539 * to be called after a f/w download operation.
540 *
541 * The initialisation procedure goes like this:
542 * - Wait for UniFi to start-up by polling SHARED_MAILBOX1
543 * - Find the symbol table and look up SLT_SDIO_SLOT_CONFIG
544 * - Read the config structure
545 * - Check the "SDIO initialised" flag, if not zero do a h/w reset and
546 * start again
547 * - Decide the number of bulk data slots to allocate, allocate them and
548 * set "SDIO initialised" flag (and generate an interrupt) to say so.
549 *
550 * Arguments:
551 * card Pointer to card struct
552 *
553 * Returns:
554 * CSR_RESULT_SUCEESS on success,
555 * a CSR error code on failure
556 *
557 * Notes:
558 * All data in the f/w is stored in a little endian format, without any
559 * padding bytes. Every read from this memory has to be transformed in
560 * host (cpu specific) format, before it is stored in driver's parameters
561 * or/and structures. Athough unifi_card_read16() and unifi_read32() do perform
562 * the conversion internally, unifi_readn() does not.
563 * ---------------------------------------------------------------------------
564 */
565static CsrResult card_hw_init(card_t *card)
566{
567 u32 slut_address;
568 u16 initialised;
569 u16 finger_print;
570 symbol_t slut;
571 sdio_config_data_t *cfg_data;
572 u8 cfg_data_buf[SDIO_CONFIG_DATA_SIZE];
573 CsrResult r;
574 void *dlpriv;
575 s16 major, minor;
576 s16 search_4slut_again;
577 CsrResult csrResult;
578
579 /*
580 * The device revision from the TPLMID_MANF and TPLMID_CARD fields
581 * of the CIS are available as
582 * card->sdio_if->pDevice->ManfID
583 * card->sdio_if->pDevice->AppID
584 */
585
586 /*
587 * Run in a loop so we can patch.
588 */
589 do
590 {
591 /* Reset these each time around the loop. */
592 search_4slut_again = 0;
593 cfg_data = NULL;
594
595 r = card_wait_for_firmware_to_start(card, &slut_address);
596 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
597 {
598 return r;
599 }
600 if (r != CSR_RESULT_SUCCESS)
601 {
602 unifi_error(card->ospriv, "Firmware hasn't started\n");
603 return r;
604 }
605 unifi_trace(card->ospriv, UDBG4, "SLUT addr 0x%lX\n", slut_address);
606
607 /*
608 * Firmware has started, but doesn't know full clock configuration yet
609 * as some of the information may be in the MIB. Therefore we set an
610 * initial SDIO clock speed, faster than UNIFI_SDIO_CLOCK_SAFE_HZ, for
611 * the patch download and subsequent firmware initialisation, and
612 * full speed UNIFI_SDIO_CLOCK_MAX_HZ will be set once the f/w tells us
613 * that it is ready.
614 */
615 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
616 if (csrResult != CSR_RESULT_SUCCESS)
617 {
618 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
619 return r;
620 }
621 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
622
623 /*
624 * Check the SLUT fingerprint.
625 * The slut_address is a generic pointer so we must use unifi_card_read16().
626 */
627 unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
628 finger_print = 0;
629 r = unifi_card_read16(card, slut_address, &finger_print);
630 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
631 {
632 return r;
633 }
634 if (r != CSR_RESULT_SUCCESS)
635 {
636 unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
637 return r;
638 }
639
640 if (finger_print != SLUT_FINGERPRINT)
641 {
642 unifi_error(card->ospriv, "Failed to find Symbol lookup table fingerprint\n");
643 return CSR_RESULT_FAILURE;
644 }
645
646 /* Symbol table starts imedately after the fingerprint */
647 slut_address += 2;
648
649 /* Search the table until either the end marker is found, or the
650 * loading of patch firmware invalidates the current table.
651 */
652 while (!search_4slut_again)
653 {
654 u16 s;
655 u32 l;
656
657 r = unifi_card_read16(card, slut_address, &s);
658 if (r != CSR_RESULT_SUCCESS)
659 {
660 return r;
661 }
662 slut_address += 2;
663
664 if (s == CSR_SLT_END)
665 {
666 unifi_trace(card->ospriv, UDBG3, " found CSR_SLT_END\n");
667 break;
668 }
669
670 r = unifi_read32(card, slut_address, &l);
671 if (r != CSR_RESULT_SUCCESS)
672 {
673 return r;
674 }
675 slut_address += 4;
676
677 slut.id = s;
678 slut.obj = l;
679
680 unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", slut.id, slut.obj);
681 switch (slut.id)
682 {
683 case CSR_SLT_SDIO_SLOT_CONFIG:
684 cfg_data = &card->config_data;
685 /*
686 * unifi_card_readn reads n bytes from the card, where data is stored
687 * in a little endian format, without any padding bytes. So, we
688 * can not just pass the cfg_data pointer or use the
689 * sizeof(sdio_config_data_t) since the structure in the host can
690 * be big endian formatted or have padding bytes for alignment.
691 * We use a char buffer to read the data from the card.
692 */
693 r = unifi_card_readn(card, slut.obj, cfg_data_buf, SDIO_CONFIG_DATA_SIZE);
694 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
695 {
696 return r;
697 }
698 if (r != CSR_RESULT_SUCCESS)
699 {
700 unifi_error(card->ospriv, "Failed to read config data\n");
701 return r;
702 }
703 /* .. and then we copy the data to the host structure */
704 _build_sdio_config_data(cfg_data, cfg_data_buf);
705
706 /* Make sure the from host data slots are what we expect
707 we reserve 2 for commands and there should be at least
708 1 left for each access category */
709 if ((cfg_data->num_fromhost_data_slots < UNIFI_RESERVED_COMMAND_SLOTS)
710 || (cfg_data->num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS) / UNIFI_NO_OF_TX_QS == 0)
711 {
712 unifi_error(card->ospriv, "From host data slots %d\n", cfg_data->num_fromhost_data_slots);
713 unifi_error(card->ospriv, "need to be (queues * x + 2) (UNIFI_RESERVED_COMMAND_SLOTS for commands)\n");
714 return CSR_RESULT_FAILURE;
715 }
716
717 /* Configure SDIO to-block-size padding */
718 if (card->sdio_io_block_pad)
719 {
720 /*
721 * Firmware limits the maximum padding size via data_slot_round.
722 * Therefore when padding to whole block sizes, the block size
723 * must be configured correctly by adjusting CSR_WIFI_HIP_SDIO_BLOCK_SIZE.
724 */
725 if (cfg_data->data_slot_round < card->sdio_io_block_size)
726 {
727 unifi_error(card->ospriv,
728 "Configuration error: Block size of %d exceeds f/w data_slot_round of %d\n",
729 card->sdio_io_block_size, cfg_data->data_slot_round);
730 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
731 }
732
733 /*
734 * To force the To-Host signals to be rounded up to the SDIO block
735 * size, we need to write the To-Host Signal Padding Fragments
736 * field of the SDIO configuration in UniFi.
737 */
738 if ((card->sdio_io_block_size % cfg_data->sig_frag_size) != 0)
739 {
740 unifi_error(card->ospriv, "Configuration error: Can not pad to-host signals.\n");
741 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
742 }
743 cfg_data->tohost_signal_padding = (u16) (card->sdio_io_block_size / cfg_data->sig_frag_size);
744 unifi_info(card->ospriv, "SDIO block size %d requires %d padding chunks\n",
745 card->sdio_io_block_size, cfg_data->tohost_signal_padding);
746 r = unifi_card_write16(card, slut.obj + SDIO_TO_HOST_SIG_PADDING_OFFSET, cfg_data->tohost_signal_padding);
747 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
748 {
749 return r;
750 }
751 if (r != CSR_RESULT_SUCCESS)
752 {
753 unifi_error(card->ospriv, "Failed to write To-Host Signal Padding Fragments\n");
754 return r;
755 }
756 }
757
758 /* Reconstruct the Generic Pointer address of the
759 * SDIO Control Data Struct.
760 */
761 card->sdio_ctrl_addr = cfg_data->sdio_ctrl_offset | (UNIFI_SH_DMEM << 24);
762 card->init_flag_addr = slut.obj + SDIO_INIT_FLAG_OFFSET;
763 break;
764
765 case CSR_SLT_BUILD_ID_NUMBER:
766 {
767 u32 n;
768 r = unifi_read32(card, slut.obj, &n);
769 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
770 {
771 return r;
772 }
773 if (r != CSR_RESULT_SUCCESS)
774 {
775 unifi_error(card->ospriv, "Failed to read build id\n");
776 return r;
777 }
778 card->build_id = n;
779 }
780 break;
781
782 case CSR_SLT_BUILD_ID_STRING:
783 r = unifi_readnz(card, slut.obj, card->build_id_string,
784 sizeof(card->build_id_string));
785 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
786 {
787 return r;
788 }
789 if (r != CSR_RESULT_SUCCESS)
790 {
791 unifi_error(card->ospriv, "Failed to read build string\n");
792 return r;
793 }
794 break;
795
796 case CSR_SLT_PERSISTENT_STORE_DB:
797 break;
798
799 case CSR_SLT_BOOT_LOADER_CONTROL:
800
801 /* This command copies most of the station firmware
802 * image from ROM into program RAM. It also clears
803 * out the zerod data and sets up the initialised
804 * data. */
805 r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_LOAD_STA);
806 if (r != CSR_RESULT_SUCCESS)
807 {
808 unifi_error(card->ospriv, "Failed to write loader load image command\n");
809 return r;
810 }
811
812 dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
813
814 /* dlpriv might be NULL, we still need to do the do_loader_op step. */
815 if (dlpriv != NULL)
816 {
817 /* Download the firmware. */
818 r = unifi_dl_patch(card, dlpriv, slut.obj);
819
820 /* Free the firmware file information. */
821 unifi_fw_read_stop(card->ospriv, dlpriv);
822
823 if (r != CSR_RESULT_SUCCESS)
824 {
825 unifi_error(card->ospriv, "Failed to patch firmware\n");
826 return r;
827 }
828 }
829
830 /* This command starts the firmware image that we want (the
831 * station by default) with any patches required applied. */
832 r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_RESTART);
833 if (r != CSR_RESULT_SUCCESS)
834 {
835 unifi_error(card->ospriv, "Failed to write loader restart command\n");
836 return r;
837 }
838
839 /* The now running patch f/w defines a new SLUT data structure -
840 * the current one is no longer valid. We must drop out of the
841 * processing loop and enumerate the new SLUT (which may appear
842 * at a different offset).
843 */
844 search_4slut_again = 1;
845 break;
846
847 case CSR_SLT_PANIC_DATA_PHY:
848 card->panic_data_phy_addr = slut.obj;
849 break;
850
851 case CSR_SLT_PANIC_DATA_MAC:
852 card->panic_data_mac_addr = slut.obj;
853 break;
854
855 default:
856 /* do nothing */
857 break;
858 }
859 } /* while */
860 } while (search_4slut_again);
861
862 /* Did we find the Config Data ? */
863 if (cfg_data == NULL)
864 {
865 unifi_error(card->ospriv, "Failed to find SDIO_SLOT_CONFIG Symbol\n");
866 return CSR_RESULT_FAILURE;
867 }
868
869 /*
870 * Has ths card already been initialised?
871 * If so, return an error so we do a h/w reset and start again.
872 */
873 r = unifi_card_read16(card, card->init_flag_addr, &initialised);
874 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
875 {
876 return r;
877 }
878 if (r != CSR_RESULT_SUCCESS)
879 {
880 unifi_error(card->ospriv, "Failed to read init flag at %08lx\n",
881 card->init_flag_addr);
882 return r;
883 }
884 if (initialised != 0)
885 {
886 return CSR_RESULT_FAILURE;
887 }
888
889
890 /*
891 * Now check the UniFi firmware version
892 */
893 major = (cfg_data->version >> 8) & 0xFF;
894 minor = cfg_data->version & 0xFF;
895 unifi_info(card->ospriv, "UniFi f/w protocol version %d.%d (driver %d.%d)\n",
896 major, minor,
897 UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
898
899 unifi_info(card->ospriv, "Firmware build %u: %s\n",
900 card->build_id, card->build_id_string);
901
902 if (major != UNIFI_HIP_MAJOR_VERSION)
903 {
904 unifi_error(card->ospriv, "UniFi f/w protocol major version (%d) is different from driver (v%d.%d)\n",
905 major, UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
906#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
907 return CSR_RESULT_FAILURE;
908#endif
909 }
910 if (minor < UNIFI_HIP_MINOR_VERSION)
911 {
912 unifi_error(card->ospriv, "UniFi f/w protocol version (v%d.%d) is older than minimum required by driver (v%d.%d).\n",
913 major, minor,
914 UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
915#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
916 return CSR_RESULT_FAILURE;
917#endif
918 }
919
920 /* Read panic codes from a previous firmware panic. If the firmware has
921 * not panicked since power was applied (e.g. power-off hard reset)
922 * the stored panic codes will not be updated.
923 */
924 unifi_read_panic(card);
925
926 return CSR_RESULT_SUCCESS;
927} /* card_hw_init() */
928
929
930/*
931 * ---------------------------------------------------------------------------
932 * card_wait_for_unifi_to_reset
933 *
934 * Waits for a reset to complete by polling the WLAN function enable
935 * bit (which is cleared on reset).
936 *
937 * Arguments:
938 * card Pointer to card struct
939 *
940 * Returns:
941 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
942 * ---------------------------------------------------------------------------
943 */
944static CsrResult card_wait_for_unifi_to_reset(card_t *card)
945{
946 s16 i;
947 CsrResult r;
948 u8 io_enable;
949 CsrResult csrResult;
950
951 r = CSR_RESULT_SUCCESS;
952 for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
953 {
954 unifi_trace(card->ospriv, UDBG1, "waiting for reset to complete, attempt %d\n", i);
955 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
956 {
957 /* It's quite likely that this read will timeout for the
958 * first few tries - especially if we have reset via
959 * DBG_RESET.
960 */
961#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
962 unifi_debug_log_to_buf("m0@%02X=", SDIO_IO_READY);
963#endif
964 csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
965#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
966 if (csrResult != CSR_RESULT_SUCCESS)
967 {
968 unifi_debug_log_to_buf("error=%X\n", csrResult);
969 }
970 else
971 {
972 unifi_debug_log_to_buf("%X\n", io_enable);
973 }
974#endif
975 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
976 {
977 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
978 }
979 r = CSR_RESULT_SUCCESS;
980 if (csrResult != CSR_RESULT_SUCCESS)
981 {
982 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
983 }
984 }
985 else
986 {
987 r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_enable);
988 }
989 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
990 {
991 return r;
992 }
993 if (r == CSR_RESULT_SUCCESS)
994 {
995 u16 mbox2;
996 s16 enabled = io_enable & (1 << card->function);
997
998 if (!enabled)
999 {
1000 unifi_trace(card->ospriv, UDBG1,
1001 "Reset complete (function %d is disabled) in ~ %u msecs\n",
1002 card->function, i * MAILBOX2_TIMEOUT);
1003
1004 /* Enable WLAN function and verify MAILBOX2 is zero'd */
1005 csrResult = CsrSdioFunctionEnable(card->sdio_if);
1006 if (csrResult != CSR_RESULT_SUCCESS)
1007 {
1008 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
1009 unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d\n", r);
1010 break;
1011 }
1012 }
1013
1014 r = unifi_read_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, &mbox2);
1015 if (r != CSR_RESULT_SUCCESS)
1016 {
1017 unifi_error(card->ospriv, "read HIP_HANDSHAKE failed %d\n", r);
1018 break;
1019 }
1020 if (mbox2 != 0)
1021 {
1022 unifi_error(card->ospriv, "MAILBOX2 non-zero after reset (mbox2 = %04x)\n", mbox2);
1023 r = CSR_RESULT_FAILURE;
1024 }
1025 break;
1026 }
1027 else
1028 {
1029 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
1030 {
1031 /* We ignore read failures for the first few reads,
1032 * they are probably benign. */
1033 if (i > MAILBOX2_ATTEMPTS / 4)
1034 {
1035 unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Ready register while polling for reset\n");
1036 }
1037 }
1038 else
1039 {
1040 unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Enable register while polling for reset\n");
1041 }
1042 }
1043 CsrThreadSleep(MAILBOX2_TIMEOUT);
1044 }
1045
1046 if (r == CSR_RESULT_SUCCESS && i == MAILBOX2_ATTEMPTS)
1047 {
1048 unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete reset\n");
1049 r = CSR_RESULT_FAILURE;
1050 }
1051
1052 return r;
1053} /* card_wait_for_unifi_to_reset() */
1054
1055
1056/*
1057 * ---------------------------------------------------------------------------
1058 * card_wait_for_unifi_to_disable
1059 *
1060 * Waits for the function to become disabled by polling the
1061 * IO_READY bit.
1062 *
1063 * Arguments:
1064 * card Pointer to card struct
1065 *
1066 * Returns:
1067 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
1068 *
1069 * Notes: This function can only be used with
1070 * card->chip_id > SDIO_CARD_ID_UNIFI_2
1071 * ---------------------------------------------------------------------------
1072 */
1073static CsrResult card_wait_for_unifi_to_disable(card_t *card)
1074{
1075 s16 i;
1076 CsrResult r;
1077 u8 io_enable;
1078 CsrResult csrResult;
1079
1080 if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
1081 {
1082 unifi_error(card->ospriv,
1083 "Function reset method not supported for chip_id=%d\n",
1084 card->chip_id);
1085 return CSR_RESULT_FAILURE;
1086 }
1087
1088 r = CSR_RESULT_SUCCESS;
1089 for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
1090 {
1091 unifi_trace(card->ospriv, UDBG1, "waiting for disable to complete, attempt %d\n", i);
1092
1093 /*
1094 * It's quite likely that this read will timeout for the
1095 * first few tries - especially if we have reset via
1096 * DBG_RESET.
1097 */
1098#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1099 unifi_debug_log_to_buf("r0@%02X=", SDIO_IO_READY);
1100#endif
1101 csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
1102#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1103 if (csrResult != CSR_RESULT_SUCCESS)
1104 {
1105 unifi_debug_log_to_buf("error=%X\n", csrResult);
1106 }
1107 else
1108 {
1109 unifi_debug_log_to_buf("%X\n", io_enable);
1110 }
1111#endif
1112 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
1113 {
1114 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
1115 }
1116 if (csrResult == CSR_RESULT_SUCCESS)
1117 {
1118 s16 enabled = io_enable & (1 << card->function);
1119 r = CSR_RESULT_SUCCESS;
1120 if (!enabled)
1121 {
1122 unifi_trace(card->ospriv, UDBG1,
1123 "Disable complete (function %d is disabled) in ~ %u msecs\n",
1124 card->function, i * MAILBOX2_TIMEOUT);
1125
1126 break;
1127 }
1128 }
1129 else
1130 {
1131 /*
1132 * We ignore read failures for the first few reads,
1133 * they are probably benign.
1134 */
1135 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
1136 if (i > (MAILBOX2_ATTEMPTS / 4))
1137 {
1138 unifi_trace(card->ospriv, UDBG1,
1139 "Failed to read CCCR IO Ready register while polling for disable\n");
1140 }
1141 }
1142 CsrThreadSleep(MAILBOX2_TIMEOUT);
1143 }
1144
1145 if ((r == CSR_RESULT_SUCCESS) && (i == MAILBOX2_ATTEMPTS))
1146 {
1147 unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete disable\n");
1148 r = CSR_RESULT_FAILURE;
1149 }
1150
1151 return r;
1152} /* card_wait_for_unifi_to_reset() */
1153
1154
1155/*
1156 * ---------------------------------------------------------------------------
1157 * card_wait_for_firmware_to_start
1158 *
1159 * Polls the MAILBOX1 register for a non-zero value.
1160 * Then reads MAILBOX0 and forms the two values into a 32-bit address
1161 * which is returned to the caller.
1162 *
1163 * Arguments:
1164 * card Pointer to card struct
1165 * paddr Pointer to receive the UniFi address formed
1166 * by concatenating MAILBOX1 and MAILBOX0.
1167 *
1168 * Returns:
1169 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
1170 * ---------------------------------------------------------------------------
1171 */
1172CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr)
1173{
1174 s32 i;
1175 u16 mbox0, mbox1;
1176 CsrResult r;
1177
1178 /*
1179 * Wait for UniFi to initialise its data structures by polling
1180 * the SHARED_MAILBOX1 register.
1181 * Experience shows this is typically 120ms.
1182 */
1183 CsrThreadSleep(MAILBOX1_TIMEOUT);
1184
1185 mbox1 = 0;
1186 unifi_trace(card->ospriv, UDBG1, "waiting for MAILBOX1 to be non-zero...\n");
1187 for (i = 0; i < MAILBOX1_ATTEMPTS; i++)
1188 {
1189 r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
1190 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1191 {
1192 return r;
1193 }
1194 if (r != CSR_RESULT_SUCCESS)
1195 {
1196 /* These reads can fail if UniFi isn't up yet, so try again */
1197 unifi_warning(card->ospriv, "Failed to read UniFi Mailbox1 register\n");
1198 }
1199
1200 if ((r == CSR_RESULT_SUCCESS) && (mbox1 != 0))
1201 {
1202 unifi_trace(card->ospriv, UDBG1, "MAILBOX1 ready (0x%04X) in %u millisecs\n",
1203 mbox1, i * MAILBOX1_TIMEOUT);
1204
1205 /* Read the MAILBOX1 again in case we caught the value as it
1206 * changed. */
1207 r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
1208 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1209 {
1210 return r;
1211 }
1212 if (r != CSR_RESULT_SUCCESS)
1213 {
1214 unifi_error(card->ospriv, "Failed to read UniFi Mailbox1 register for second time\n");
1215 return r;
1216 }
1217 unifi_trace(card->ospriv, UDBG1, "MAILBOX1 value=0x%04X\n", mbox1);
1218
1219 break;
1220 }
1221
1222 CsrThreadSleep(MAILBOX1_TIMEOUT);
1223 if ((i % 100) == 99)
1224 {
1225 unifi_trace(card->ospriv, UDBG2, "MAILBOX1 not ready (0x%X), still trying...\n", mbox1);
1226 }
1227 }
1228
1229 if ((r == CSR_RESULT_SUCCESS) && (mbox1 == 0))
1230 {
1231 unifi_trace(card->ospriv, UDBG1, "Timeout waiting for firmware to start, Mailbox1 still 0 after %d ms\n",
1232 MAILBOX1_ATTEMPTS * MAILBOX1_TIMEOUT);
1233 return CSR_RESULT_FAILURE;
1234 }
1235
1236
1237 /*
1238 * Complete the reset handshake by setting MAILBOX2 to 0xFFFF
1239 */
1240 r = unifi_write_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, 0xFFFF);
1241 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1242 {
1243 return r;
1244 }
1245 if (r != CSR_RESULT_SUCCESS)
1246 {
1247 unifi_error(card->ospriv, "Failed to write f/w startup handshake to MAILBOX2\n");
1248 return r;
1249 }
1250
1251
1252 /*
1253 * Read the Symbol Look Up Table (SLUT) offset.
1254 * Top 16 bits are in mbox1, read the lower 16 bits from mbox0.
1255 */
1256 mbox0 = 0;
1257 r = unifi_read_direct16(card, ChipHelper_MAILBOX0(card->helper) * 2, &mbox0);
1258 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1259 {
1260 return r;
1261 }
1262 if (r != CSR_RESULT_SUCCESS)
1263 {
1264 unifi_error(card->ospriv, "Failed to read UniFi Mailbox0 register\n");
1265 return r;
1266 }
1267
1268 *paddr = (((u32)mbox1 << 16) | mbox0);
1269
1270 return CSR_RESULT_SUCCESS;
1271} /* card_wait_for_firmware_to_start() */
1272
1273
1274/*
1275 * ---------------------------------------------------------------------------
1276 * unifi_capture_panic
1277 *
1278 * Attempt to capture panic codes from the firmware. This may involve
1279 * warm reset of the chip to regain access following a watchdog reset.
1280 *
1281 * Arguments:
1282 * card Pointer to card struct
1283 *
1284 * Returns:
1285 * CSR_RESULT_SUCCESS if panic codes were captured, or none available
1286 * CSR_RESULT_FAILURE if the driver could not access function 1
1287 * ---------------------------------------------------------------------------
1288 */
1289CsrResult unifi_capture_panic(card_t *card)
1290{
1291
1292 /* The firmware must have previously initialised to read the panic addresses
1293 * from the SLUT
1294 */
1295 if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
1296 {
1297 return CSR_RESULT_SUCCESS;
1298 }
1299
1300 /* Ensure we can access function 1 following a panic/watchdog reset */
1301 if (card_access_panic(card) == CSR_RESULT_SUCCESS)
1302 {
1303 /* Read the panic codes */
1304 unifi_read_panic(card);
1305 }
1306 else
1307 {
1308 unifi_info(card->ospriv, "Unable to read panic codes");
1309 }
1310
1311 return CSR_RESULT_SUCCESS;
1312}
1313
1314
1315/*
1316 * ---------------------------------------------------------------------------
1317 * card_access_panic
1318 * Attempt to read the WLAN SDIO function in order to read panic codes
1319 * and perform various reset steps to regain access if the read fails.
1320 *
1321 * Arguments:
1322 * card Pointer to card struct
1323 *
1324 * Returns:
1325 * CSR_RESULT_SUCCESS if panic codes can be read
1326 * CSR error code if panic codes can not be read
1327 * ---------------------------------------------------------------------------
1328 */
1329static CsrResult card_access_panic(card_t *card)
1330{
1331 u16 data_u16 = 0;
1332 s32 i;
1333 CsrResult r, sr;
1334
1335 /* A chip version of zero means that the version never got successfully read
1336 * during reset. In this case give up because it will not be possible to
1337 * verify the chip version.
1338 */
1339 if (!card->chip_version)
1340 {
1341 unifi_info(card->ospriv, "Unknown chip version\n");
1342 return CSR_RESULT_FAILURE;
1343 }
1344
1345 /* Ensure chip is awake or access to function 1 will fail */
1346 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
1347 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1348 {
1349 return r;
1350 }
1351 if (r != CSR_RESULT_SUCCESS)
1352 {
1353 unifi_error(card->ospriv, "unifi_set_host_state() failed %d\n", r);
1354 return CSR_RESULT_FAILURE; /* Card is probably unpowered */
1355 }
1356 CsrThreadSleep(20);
1357
1358 for (i = 0; i < 3; i++)
1359 {
1360 sr = CsrSdioRead16(card->sdio_if, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION * 2, &data_u16);
1361 if (sr != CSR_RESULT_SUCCESS || data_u16 != card->chip_version)
1362 {
1363 unifi_info(card->ospriv, "Failed to read valid chip version sr=%d (0x%04x want 0x%04x) try %d\n",
1364 sr, data_u16, card->chip_version, i);
1365
1366 /* Set clock speed low */
1367 sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
1368 if (sr != CSR_RESULT_SUCCESS)
1369 {
1370 unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed1 %d\n", sr);
1371 r = ConvertCsrSdioToCsrHipResult(card, sr);
1372 }
1373 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
1374
1375 /* First try re-enabling function in case a f/w watchdog reset disabled it */
1376 if (i == 0)
1377 {
1378 unifi_info(card->ospriv, "Try function enable\n");
1379 sr = CsrSdioFunctionEnable(card->sdio_if);
1380 if (sr != CSR_RESULT_SUCCESS)
1381 {
1382 r = ConvertCsrSdioToCsrHipResult(card, sr);
1383 unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d (HIP %d)\n", sr, r);
1384 }
1385 continue;
1386 }
1387
1388 /* Second try, set awake */
1389 unifi_info(card->ospriv, "Try set awake\n");
1390
1391 /* Ensure chip is awake */
1392 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
1393 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1394 {
1395 return r;
1396 }
1397 if (r != CSR_RESULT_SUCCESS)
1398 {
1399 unifi_error(card->ospriv, "unifi_set_host_state() failed2 %d\n", r);
1400 }
1401
1402 /* Set clock speed low in case setting the host state raised it, which
1403 * would only happen if host state was previously TORPID
1404 */
1405 sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
1406 if (sr != CSR_RESULT_SUCCESS)
1407 {
1408 unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed2 %d\n", sr);
1409 }
1410 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
1411
1412 if (i == 1)
1413 {
1414 continue;
1415 }
1416
1417 /* Perform a s/w reset to preserve as much as the card state as possible,
1418 * (mainly the preserve RAM). The context will be lost for coredump - but as we
1419 * were unable to access the WLAN function for panic, the coredump would have
1420 * also failed without a reset.
1421 */
1422 unifi_info(card->ospriv, "Try s/w reset\n");
1423
1424 r = unifi_card_hard_reset(card);
1425 if (r != CSR_RESULT_SUCCESS)
1426 {
1427 unifi_error(card->ospriv, "unifi_card_hard_reset() failed %d\n", r);
1428 }
1429 }
1430 else
1431 {
1432 if (i > 0)
1433 {
1434 unifi_info(card->ospriv, "Read chip version 0x%x after %d retries\n", data_u16, i);
1435 }
1436 break;
1437 }
1438 }
1439
1440 r = ConvertCsrSdioToCsrHipResult(card, sr);
1441 return r;
1442}
1443
1444
1445/*
1446 * ---------------------------------------------------------------------------
1447 * unifi_read_panic
1448 * Reads, saves and prints panic codes stored by the firmware in UniFi's
1449 * preserve RAM by the last panic that occurred since chip was powered.
1450 * Nothing is saved if the panic codes are read as zero.
1451 *
1452 * Arguments:
1453 * card Pointer to card struct
1454 *
1455 * Returns:
1456 * ---------------------------------------------------------------------------
1457 */
1458void unifi_read_panic(card_t *card)
1459{
1460 CsrResult r;
1461 u16 p_code, p_arg;
1462
1463 /* The firmware must have previously initialised to read the panic addresses
1464 * from the SLUT
1465 */
1466 if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
1467 {
1468 return;
1469 }
1470
1471 /* Get the panic data from PHY */
1472 r = unifi_card_read16(card, card->panic_data_phy_addr, &p_code);
1473 if (r != CSR_RESULT_SUCCESS)
1474 {
1475 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr, r);
1476 p_code = 0;
1477 }
1478 if (p_code)
1479 {
1480 r = unifi_card_read16(card, card->panic_data_phy_addr + 2, &p_arg);
1481 if (r != CSR_RESULT_SUCCESS)
1482 {
1483 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr + 2, r);
1484 }
1485 unifi_error(card->ospriv, "Last UniFi PHY PANIC %04x arg %04x\n", p_code, p_arg);
1486 card->last_phy_panic_code = p_code;
1487 card->last_phy_panic_arg = p_arg;
1488 }
1489
1490 /* Get the panic data from MAC */
1491 r = unifi_card_read16(card, card->panic_data_mac_addr, &p_code);
1492 if (r != CSR_RESULT_SUCCESS)
1493 {
1494 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr, r);
1495 p_code = 0;
1496 }
1497 if (p_code)
1498 {
1499 r = unifi_card_read16(card, card->panic_data_mac_addr + 2, &p_arg);
1500 if (r != CSR_RESULT_SUCCESS)
1501 {
1502 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr + 2, r);
1503 }
1504 unifi_error(card->ospriv, "Last UniFi MAC PANIC %04x arg %04x\n", p_code, p_arg);
1505 card->last_mac_panic_code = p_code;
1506 card->last_mac_panic_arg = p_arg;
1507 }
1508
1509}
1510
1511
1512/*
1513 * ---------------------------------------------------------------------------
1514 * card_allocate_memory_resources
1515 *
1516 * Allocates memory for the from-host, to-host bulk data slots,
1517 * soft queue buffers and bulk data buffers.
1518 *
1519 * Arguments:
1520 * card Pointer to card struct
1521 *
1522 * Returns:
1523 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
1524 * ---------------------------------------------------------------------------
1525 */
1526static CsrResult card_allocate_memory_resources(card_t *card)
1527{
1528 s16 n, i, k, r;
1529 sdio_config_data_t *cfg_data;
1530
1531 /* Reset any state carried forward from a previous life */
1532 card->fh_command_queue.q_rd_ptr = 0;
1533 card->fh_command_queue.q_wr_ptr = 0;
1534 (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
1535 "fh_cmd_q");
1536 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1537 {
1538 card->fh_traffic_queue[i].q_rd_ptr = 0;
1539 card->fh_traffic_queue[i].q_wr_ptr = 0;
1540 (void)scnprintf(card->fh_traffic_queue[i].name,
1541 UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
1542 }
1543#ifndef CSR_WIFI_HIP_TA_DISABLE
1544 unifi_ta_sampling_init(card);
1545#endif
1546 /* Convenience short-cut */
1547 cfg_data = &card->config_data;
1548
1549 /*
1550 * Allocate memory for the from-host and to-host signal buffers.
1551 */
1552 card->fh_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
1553 if (card->fh_buffer.buf == NULL)
1554 {
1555 unifi_error(card->ospriv, "Failed to allocate memory for F-H signals\n");
1556 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1557 }
1558 card->fh_buffer.bufsize = UNIFI_FH_BUF_SIZE;
1559 card->fh_buffer.ptr = card->fh_buffer.buf;
1560 card->fh_buffer.count = 0;
1561
1562 card->th_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
1563 if (card->th_buffer.buf == NULL)
1564 {
1565 unifi_error(card->ospriv, "Failed to allocate memory for T-H signals\n");
1566 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1567 }
1568 card->th_buffer.bufsize = UNIFI_FH_BUF_SIZE;
1569 card->th_buffer.ptr = card->th_buffer.buf;
1570 card->th_buffer.count = 0;
1571
1572
1573 /*
1574 * Allocate memory for the from-host and to-host bulk data slots.
1575 * This is done as separate kmallocs because lots of smaller
1576 * allocations are more likely to succeed than one huge one.
1577 */
1578
1579 /* Allocate memory for the array of pointers */
1580 n = cfg_data->num_fromhost_data_slots;
1581
1582 unifi_trace(card->ospriv, UDBG3, "Alloc from-host resources, %d slots.\n", n);
1583 card->from_host_data = kmalloc(n * sizeof(slot_desc_t), GFP_KERNEL);
1584 if (card->from_host_data == NULL)
1585 {
1586 unifi_error(card->ospriv, "Failed to allocate memory for F-H bulk data array\n");
1587 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1588 }
1589
1590 /* Initialise from-host bulk data slots */
1591 for (i = 0; i < n; i++)
1592 {
1593 UNIFI_INIT_BULK_DATA(&card->from_host_data[i].bd);
1594 }
1595
1596 /* Allocate memory for the array used for slot host tag mapping */
1597 card->fh_slot_host_tag_record = kmalloc(n * sizeof(u32), GFP_KERNEL);
1598
1599 if (card->fh_slot_host_tag_record == NULL)
1600 {
1601 unifi_error(card->ospriv, "Failed to allocate memory for F-H slot host tag mapping array\n");
1602 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1603 }
1604
1605 /* Initialise host tag entries for from-host bulk data slots */
1606 for (i = 0; i < n; i++)
1607 {
1608 card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1609 }
1610
1611
1612 /* Allocate memory for the array of pointers */
1613 n = cfg_data->num_tohost_data_slots;
1614
1615 unifi_trace(card->ospriv, UDBG3, "Alloc to-host resources, %d slots.\n", n);
1616 card->to_host_data = kmalloc(n * sizeof(bulk_data_desc_t), GFP_KERNEL);
1617 if (card->to_host_data == NULL)
1618 {
1619 unifi_error(card->ospriv, "Failed to allocate memory for T-H bulk data array\n");
1620 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1621 }
1622
1623 /* Initialise to-host bulk data slots */
1624 for (i = 0; i < n; i++)
1625 {
1626 UNIFI_INIT_BULK_DATA(&card->to_host_data[i]);
1627 }
1628
1629 /*
1630 * Initialise buffers for soft Q
1631 */
1632 for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
1633 {
1634 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1635 {
1636 UNIFI_INIT_BULK_DATA(&card->fh_command_q_body[i].bulkdata[r]);
1637 }
1638 }
1639
1640 for (k = 0; k < UNIFI_NO_OF_TX_QS; k++)
1641 {
1642 for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
1643 {
1644 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1645 {
1646 UNIFI_INIT_BULK_DATA(&card->fh_traffic_q_body[k][i].bulkdata[r]);
1647 }
1648 }
1649 }
1650
1651 card->memory_resources_allocated = 1;
1652
1653 return CSR_RESULT_SUCCESS;
1654} /* card_allocate_memory_resources() */
1655
1656
1657/*
1658 * ---------------------------------------------------------------------------
1659 * unifi_free_bulk_data
1660 *
1661 * Free the data associated to a bulk data structure.
1662 *
1663 * Arguments:
1664 * card Pointer to card struct
1665 * bulk_data_slot Pointer to bulk data structure
1666 *
1667 * Returns:
1668 * None.
1669 *
1670 * ---------------------------------------------------------------------------
1671 */
1672static void unifi_free_bulk_data(card_t *card, bulk_data_desc_t *bulk_data_slot)
1673{
1674 if (bulk_data_slot->data_length != 0)
1675 {
1676 unifi_net_data_free(card->ospriv, bulk_data_slot);
1677 }
1678} /* unifi_free_bulk_data() */
1679
1680
1681/*
1682 * ---------------------------------------------------------------------------
1683 * card_free_memory_resources
1684 *
1685 * Frees memory allocated for the from-host, to-host bulk data slots,
1686 * soft queue buffers and bulk data buffers.
1687 *
1688 * Arguments:
1689 * card Pointer to card struct
1690 *
1691 * Returns:
1692 * None.
1693 * ---------------------------------------------------------------------------
1694 */
1695static void card_free_memory_resources(card_t *card)
1696{
1697
1698 unifi_trace(card->ospriv, UDBG1, "Freeing card memory resources.\n");
1699
1700 /* Clear our internal queues */
1701 unifi_cancel_pending_signals(card);
1702
1703
1704 kfree(card->to_host_data);
1705 card->to_host_data = NULL;
1706
1707 kfree(card->from_host_data);
1708 card->from_host_data = NULL;
1709
1710 /* free the memory for slot host tag mapping array */
1711 kfree(card->fh_slot_host_tag_record);
1712 card->fh_slot_host_tag_record = NULL;
1713
1714 kfree(card->fh_buffer.buf);
1715 card->fh_buffer.ptr = card->fh_buffer.buf = NULL;
1716 card->fh_buffer.bufsize = 0;
1717 card->fh_buffer.count = 0;
1718
1719 kfree(card->th_buffer.buf);
1720 card->th_buffer.ptr = card->th_buffer.buf = NULL;
1721 card->th_buffer.bufsize = 0;
1722 card->th_buffer.count = 0;
1723
1724
1725 card->memory_resources_allocated = 0;
1726
1727} /* card_free_memory_resources() */
1728
1729
1730static void card_init_soft_queues(card_t *card)
1731{
1732 s16 i;
1733
1734 unifi_trace(card->ospriv, UDBG1, "Initialising internal signal queues.\n");
1735 /* Reset any state carried forward from a previous life */
1736 card->fh_command_queue.q_rd_ptr = 0;
1737 card->fh_command_queue.q_wr_ptr = 0;
1738 (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
1739 "fh_cmd_q");
1740 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1741 {
1742 card->fh_traffic_queue[i].q_rd_ptr = 0;
1743 card->fh_traffic_queue[i].q_wr_ptr = 0;
1744 (void)scnprintf(card->fh_traffic_queue[i].name,
1745 UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
1746 }
1747#ifndef CSR_WIFI_HIP_TA_DISABLE
1748 unifi_ta_sampling_init(card);
1749#endif
1750}
1751
1752
1753/*
1754 * ---------------------------------------------------------------------------
1755 * unifi_cancel_pending_signals
1756 *
1757 * Free the signals and associated bulk data, pending in the core.
1758 *
1759 * Arguments:
1760 * card Pointer to card struct
1761 *
1762 * Returns:
1763 * None.
1764 * ---------------------------------------------------------------------------
1765 */
1766void unifi_cancel_pending_signals(card_t *card)
1767{
1768 s16 i, n, r;
1769
1770 unifi_trace(card->ospriv, UDBG1, "Canceling pending signals.\n");
1771
1772 if (card->to_host_data)
1773 {
1774 /*
1775 * Free any bulk data buffers allocated for the t-h slots
1776 * This will clear all buffers that did not make it to
1777 * unifi_receive_event() before cancel was request.
1778 */
1779 n = card->config_data.num_tohost_data_slots;
1780 unifi_trace(card->ospriv, UDBG3, "Freeing to-host resources, %d slots.\n", n);
1781 for (i = 0; i < n; i++)
1782 {
1783 unifi_free_bulk_data(card, &card->to_host_data[i]);
1784 }
1785 }
1786
1787 /*
1788 * If any of the from-host bulk data has reached the card->from_host_data
1789 * but not UniFi, we need to free the buffers here.
1790 */
1791 if (card->from_host_data)
1792 {
1793 /* Free any bulk data buffers allocated for the f-h slots */
1794 n = card->config_data.num_fromhost_data_slots;
1795 unifi_trace(card->ospriv, UDBG3, "Freeing from-host resources, %d slots.\n", n);
1796 for (i = 0; i < n; i++)
1797 {
1798 unifi_free_bulk_data(card, &card->from_host_data[i].bd);
1799 }
1800
1801 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1802 {
1803 card->dynamic_slot_data.from_host_used_slots[i] = 0;
1804 card->dynamic_slot_data.from_host_max_slots[i] = 0;
1805 card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
1806 }
1807 }
1808
1809 /*
1810 * Free any bulk data buffers allocated in the soft queues.
1811 * This covers the case where a bulk data pointer has reached the soft queue
1812 * but not the card->from_host_data.
1813 */
1814 unifi_trace(card->ospriv, UDBG3, "Freeing cmd q resources.\n");
1815 for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
1816 {
1817 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1818 {
1819 unifi_free_bulk_data(card, &card->fh_command_q_body[i].bulkdata[r]);
1820 }
1821 }
1822
1823 unifi_trace(card->ospriv, UDBG3, "Freeing traffic q resources.\n");
1824 for (n = 0; n < UNIFI_NO_OF_TX_QS; n++)
1825 {
1826 for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
1827 {
1828 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1829 {
1830 unifi_free_bulk_data(card, &card->fh_traffic_q_body[n][i].bulkdata[r]);
1831 }
1832 }
1833 }
1834
1835 card_init_soft_queues(card);
1836
1837} /* unifi_cancel_pending_signals() */
1838
1839
1840/*
1841 * ---------------------------------------------------------------------------
1842 * unifi_free_card
1843 *
1844 * Free the memory allocated for the card structure and buffers.
1845 *
1846 * Notes:
1847 * The porting layer is responsible for freeing any mini-coredump buffers
1848 * allocated when it called unifi_coredump_init(), by calling
1849 * unifi_coredump_free() before calling this function.
1850 *
1851 * Arguments:
1852 * card Pointer to card struct
1853 *
1854 * Returns:
1855 * None.
1856 * ---------------------------------------------------------------------------
1857 */
1858void unifi_free_card(card_t *card)
1859{
1860#ifdef CSR_PRE_ALLOC_NET_DATA
1861 prealloc_netdata_free(card);
1862#endif
1863 /* Free any memory allocated. */
1864 card_free_memory_resources(card);
1865
1866 /* Warn if caller didn't free coredump buffers */
1867 if (card->dump_buf)
1868 {
1869 unifi_error(card->ospriv, "Caller should call unifi_coredump_free()\n");
1870 unifi_coredump_free(card); /* free anyway to prevent memory leak */
1871 }
1872
1873 kfree(card);
1874
1875} /* unifi_free_card() */
1876
1877
1878/*
1879 * ---------------------------------------------------------------------------
1880 * card_init_slots
1881 *
1882 * Allocate memory for host-side slot data and signal queues.
1883 *
1884 * Arguments:
1885 * card Pointer to card object
1886 *
1887 * Returns:
1888 * CSR error code.
1889 * ---------------------------------------------------------------------------
1890 */
1891static CsrResult card_init_slots(card_t *card)
1892{
1893 CsrResult r;
1894 u8 i;
1895
1896 /* Allocate the buffers we need, only once. */
1897 if (card->memory_resources_allocated == 1)
1898 {
1899 card_free_memory_resources(card);
1900 }
1901 else
1902 {
1903 /* Initialise our internal command and traffic queues */
1904 card_init_soft_queues(card);
1905 }
1906
1907 r = card_allocate_memory_resources(card);
1908 if (r != CSR_RESULT_SUCCESS)
1909 {
1910 unifi_error(card->ospriv, "Failed to allocate card memory resources.\n");
1911 card_free_memory_resources(card);
1912 return r;
1913 }
1914
1915 if (card->sdio_ctrl_addr == 0)
1916 {
1917 unifi_error(card->ospriv, "Failed to find config struct!\n");
1918 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1919 }
1920
1921 /*
1922 * Set initial counts.
1923 */
1924
1925 card->from_host_data_head = 0;
1926
1927 /* Get initial signal counts from UniFi, in case it has not been reset. */
1928 {
1929 u16 s;
1930
1931 /* Get the from-host-signals-written count */
1932 r = unifi_card_read16(card, card->sdio_ctrl_addr + 0, &s);
1933 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1934 {
1935 return r;
1936 }
1937 if (r != CSR_RESULT_SUCCESS)
1938 {
1939 unifi_error(card->ospriv, "Failed to read from-host sig written count\n");
1940 return r;
1941 }
1942 card->from_host_signals_w = (s16)s;
1943
1944 /* Get the to-host-signals-written count */
1945 r = unifi_card_read16(card, card->sdio_ctrl_addr + 6, &s);
1946 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1947 {
1948 return r;
1949 }
1950 if (r != CSR_RESULT_SUCCESS)
1951 {
1952 unifi_error(card->ospriv, "Failed to read to-host sig read count\n");
1953 return r;
1954 }
1955 card->to_host_signals_r = (s16)s;
1956 }
1957
1958 /* Set Initialised flag. */
1959 r = unifi_card_write16(card, card->init_flag_addr, 0x0001);
1960 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1961 {
1962 return r;
1963 }
1964 if (r != CSR_RESULT_SUCCESS)
1965 {
1966 unifi_error(card->ospriv, "Failed to write initialised flag\n");
1967 return r;
1968 }
1969
1970 /* Dynamic queue reservation */
1971 memset(&card->dynamic_slot_data, 0, sizeof(card_dynamic_slot_t));
1972
1973 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1974 {
1975 card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
1976 UNIFI_RESERVED_COMMAND_SLOTS;
1977 card->dynamic_slot_data.queue_stable[i] = FALSE;
1978 }
1979
1980 card->dynamic_slot_data.packets_interval = UNIFI_PACKETS_INTERVAL;
1981
1982 return CSR_RESULT_SUCCESS;
1983} /* card_init_slots() */
1984
1985
1986/*
1987 * ---------------------------------------------------------------------------
1988 * unifi_set_udi_hook
1989 *
1990 * Registers the udi hook that reports the sent signals to the core.
1991 *
1992 * Arguments:
1993 * card Pointer to the card context struct
1994 * udi_fn Pointer to the callback function.
1995 *
1996 * Returns:
1997 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
1998 * CSR_RESULT_SUCCESS on success.
1999 * ---------------------------------------------------------------------------
2000 */
2001CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn)
2002{
2003 if (card == NULL)
2004 {
2005 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2006 }
2007
2008 if (card->udi_hook == NULL)
2009 {
2010 card->udi_hook = udi_fn;
2011 }
2012
2013 return CSR_RESULT_SUCCESS;
2014} /* unifi_set_udi_hook() */
2015
2016
2017/*
2018 * ---------------------------------------------------------------------------
2019 * unifi_remove_udi_hook
2020 *
2021 * Removes the udi hook that reports the sent signals from the core.
2022 *
2023 * Arguments:
2024 * card Pointer to the card context struct
2025 * udi_fn Pointer to the callback function.
2026 *
2027 * Returns:
2028 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
2029 * CSR_RESULT_SUCCESS on success.
2030 * ---------------------------------------------------------------------------
2031 */
2032CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn)
2033{
2034 if (card == NULL)
2035 {
2036 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2037 }
2038
2039 if (card->udi_hook == udi_fn)
2040 {
2041 card->udi_hook = NULL;
2042 }
2043
2044 return CSR_RESULT_SUCCESS;
2045} /* unifi_remove_udi_hook() */
2046
2047
2048static void CardReassignDynamicReservation(card_t *card)
2049{
2050 u8 i;
2051
2052 unifi_trace(card->ospriv, UDBG5, "Packets Txed %d %d %d %d\n",
2053 card->dynamic_slot_data.packets_txed[0],
2054 card->dynamic_slot_data.packets_txed[1],
2055 card->dynamic_slot_data.packets_txed[2],
2056 card->dynamic_slot_data.packets_txed[3]);
2057
2058 /* Clear reservation and recalculate max slots */
2059 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2060 {
2061 card->dynamic_slot_data.queue_stable[i] = FALSE;
2062 card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
2063 card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
2064 UNIFI_RESERVED_COMMAND_SLOTS;
2065 card->dynamic_slot_data.packets_txed[i] = 0;
2066
2067 unifi_trace(card->ospriv, UDBG5, "CardReassignDynamicReservation: queue %d reserved %d Max %d\n", i,
2068 card->dynamic_slot_data.from_host_reserved_slots[i],
2069 card->dynamic_slot_data.from_host_max_slots[i]);
2070 }
2071
2072 card->dynamic_slot_data.total_packets_txed = 0;
2073}
2074
2075
2076/* Algorithm to dynamically reserve slots. The logic is based mainly on the outstanding queue
2077 * length. Slots are reserved for particular queues during an interval and cleared after the interval.
2078 * Each queue has three associated variables.. a) used slots - the number of slots currently occupied
2079 * by the queue b) reserved slots - number of slots reserved specifically for the queue c) max slots - total
2080 * slots that this queue can actually use (may be higher than reserved slots and is dependent on reserved slots
2081 * for other queues).
2082 * This function is called when there are no slots available for a queue. It checks to see if there are enough
2083 * unreserved slots sufficient for this request. If available these slots are reserved for the queue.
2084 * If there are not enough unreserved slots, a fair share for each queue is calculated based on the total slots
2085 * and the number of active queues (any queue with existing reservation is considered active). Queues needing
2086 * less than their fair share are allowed to have the previously reserved slots. The remaining slots are
2087 * distributed evenly among queues that need more than the fair share
2088 *
2089 * A better scheme would take current bandwidth per AC into consideration when reserving slots. An
2090 * implementation scheme could consider the relative time/service period for slots in an AC. If the firmware
2091 * services other ACs faster than a particular AC (packets wait in the slots longer) then it is fair to reserve
2092 * less slots for the AC
2093 */
2094static void CardCheckDynamicReservation(card_t *card, unifi_TrafficQueue queue)
2095{
2096 u16 q_len, active_queues = 0, excess_queue_slots, div_extra_slots,
2097 queue_fair_share, reserved_slots = 0, q, excess_need_queues = 0, unmovable_slots = 0;
2098 s32 i;
2099 q_t *sigq;
2100 u16 num_data_slots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
2101
2102 /* Calculate the pending queue length */
2103 sigq = &card->fh_traffic_queue[queue];
2104 q_len = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
2105
2106 if (q_len <= card->dynamic_slot_data.from_host_reserved_slots[queue])
2107 {
2108 unifi_trace(card->ospriv, UDBG5, "queue %d q_len %d already has that many reserved slots, exiting\n", queue, q_len);
2109 return;
2110 }
2111
2112 /* Upper limit */
2113 if (q_len > num_data_slots)
2114 {
2115 q_len = num_data_slots;
2116 }
2117
2118 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2119 {
2120 if (i != (s32)queue)
2121 {
2122 reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
2123 }
2124 if ((i == (s32)queue) || (card->dynamic_slot_data.from_host_reserved_slots[i] > 0))
2125 {
2126 active_queues++;
2127 }
2128 }
2129
2130 unifi_trace(card->ospriv, UDBG5, "CardCheckDynamicReservation: queue %d q_len %d\n", queue, q_len);
2131 unifi_trace(card->ospriv, UDBG5, "Active queues %d reserved slots on other queues %d\n",
2132 active_queues, reserved_slots);
2133
2134 if (reserved_slots + q_len <= num_data_slots)
2135 {
2136 card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
2137 if (q_len == num_data_slots)
2138 {
2139 /* This is the common case when just 1 stream is going */
2140 card->dynamic_slot_data.queue_stable[queue] = TRUE;
2141 }
2142 }
2143 else
2144 {
2145 queue_fair_share = num_data_slots / active_queues;
2146 unifi_trace(card->ospriv, UDBG5, "queue fair share %d\n", queue_fair_share);
2147
2148 /* Evenly distribute slots among active queues */
2149 /* Find out the queues that need excess of fair share. Also find slots allocated
2150 * to queues less than their fair share, these slots cannot be reallocated (unmovable slots) */
2151
2152 card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
2153
2154 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2155 {
2156 if (card->dynamic_slot_data.from_host_reserved_slots[i] > queue_fair_share)
2157 {
2158 excess_need_queues++;
2159 }
2160 else
2161 {
2162 unmovable_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
2163 }
2164 }
2165
2166 unifi_trace(card->ospriv, UDBG5, "Excess need queues %d\n", excess_need_queues);
2167
2168 /* Now find the slots per excess demand queue */
2169 excess_queue_slots = (num_data_slots - unmovable_slots) / excess_need_queues;
2170 div_extra_slots = (num_data_slots - unmovable_slots) - excess_queue_slots * excess_need_queues;
2171 for (i = UNIFI_NO_OF_TX_QS - 1; i >= 0; i--)
2172 {
2173 if (card->dynamic_slot_data.from_host_reserved_slots[i] > excess_queue_slots)
2174 {
2175 card->dynamic_slot_data.from_host_reserved_slots[i] = excess_queue_slots;
2176 if (div_extra_slots > 0)
2177 {
2178 card->dynamic_slot_data.from_host_reserved_slots[i]++;
2179 div_extra_slots--;
2180 }
2181 /* No more slots will be allocated to this queue during the current interval */
2182 card->dynamic_slot_data.queue_stable[i] = TRUE;
2183 unifi_trace(card->ospriv, UDBG5, "queue stable %d\n", i);
2184 }
2185 }
2186 }
2187
2188 /* Redistribute max slots */
2189 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2190 {
2191 reserved_slots = 0;
2192 for (q = 0; q < UNIFI_NO_OF_TX_QS; q++)
2193 {
2194 if (i != q)
2195 {
2196 reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[q];
2197 }
2198 }
2199
2200 card->dynamic_slot_data.from_host_max_slots[i] = num_data_slots - reserved_slots;
2201 unifi_trace(card->ospriv, UDBG5, "queue %d reserved %d Max %d\n", i,
2202 card->dynamic_slot_data.from_host_reserved_slots[i],
2203 card->dynamic_slot_data.from_host_max_slots[i]);
2204 }
2205
2206}
2207
2208
2209/*
2210 * ---------------------------------------------------------------------------
2211 * CardClearFromHostDataSlot
2212 *
2213 * Clear a the given data slot, making it available again.
2214 *
2215 * Arguments:
2216 * card Pointer to Card object
2217 * slot Index of the signal slot to clear.
2218 *
2219 * Returns:
2220 * None.
2221 * ---------------------------------------------------------------------------
2222 */
2223void CardClearFromHostDataSlot(card_t *card, const s16 slot)
2224{
2225 u8 queue = card->from_host_data[slot].queue;
2226 const void *os_data_ptr = card->from_host_data[slot].bd.os_data_ptr;
2227
2228 if (card->from_host_data[slot].bd.data_length == 0)
2229 {
2230 unifi_warning(card->ospriv,
2231 "Surprise: request to clear an already free FH data slot: %d\n",
2232 slot);
2233 return;
2234 }
2235
2236 if (os_data_ptr == NULL)
2237 {
2238 unifi_warning(card->ospriv,
2239 "Clearing FH data slot %d: has null payload, len=%d\n",
2240 slot, card->from_host_data[slot].bd.data_length);
2241 }
2242
2243 /* Free card->from_host_data[slot].bd.os_net_ptr here. */
2244 /* Mark slot as free by setting length to 0. */
2245 unifi_free_bulk_data(card, &card->from_host_data[slot].bd);
2246 if (queue < UNIFI_NO_OF_TX_QS)
2247 {
2248 if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
2249 {
2250 unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
2251 queue,
2252 card->dynamic_slot_data.from_host_used_slots[queue]);
2253 }
2254 else
2255 {
2256 card->dynamic_slot_data.from_host_used_slots[queue]--;
2257 }
2258 card->dynamic_slot_data.packets_txed[queue]++;
2259 card->dynamic_slot_data.total_packets_txed++;
2260 if (card->dynamic_slot_data.total_packets_txed >= card->dynamic_slot_data.packets_interval)
2261 {
2262 CardReassignDynamicReservation(card);
2263 }
2264 }
2265
2266 unifi_trace(card->ospriv, UDBG4, "CardClearFromHostDataSlot: slot %d recycled %p\n", slot, os_data_ptr);
2267
2268} /* CardClearFromHostDataSlot() */
2269
2270
2271#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
2272/*
2273 * ---------------------------------------------------------------------------
2274 * CardClearFromHostDataSlotWithoutFreeingBulkData
2275 *
2276 * Clear the given data slot with out freeing the bulk data.
2277 *
2278 * Arguments:
2279 * card Pointer to Card object
2280 * slot Index of the signal slot to clear.
2281 *
2282 * Returns:
2283 * None.
2284 * ---------------------------------------------------------------------------
2285 */
2286void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 slot)
2287{
2288 u8 queue = card->from_host_data[slot].queue;
2289
2290 /* Initialise the from_host data slot so it can be re-used,
2291 * Set length field in from_host_data array to 0.
2292 */
2293 UNIFI_INIT_BULK_DATA(&card->from_host_data[slot].bd);
2294
2295 queue = card->from_host_data[slot].queue;
2296
2297 if (queue < UNIFI_NO_OF_TX_QS)
2298 {
2299 if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
2300 {
2301 unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
2302 queue,
2303 card->dynamic_slot_data.from_host_used_slots[queue]);
2304 }
2305 else
2306 {
2307 card->dynamic_slot_data.from_host_used_slots[queue]--;
2308 }
2309 card->dynamic_slot_data.packets_txed[queue]++;
2310 card->dynamic_slot_data.total_packets_txed++;
2311 if (card->dynamic_slot_data.total_packets_txed >=
2312 card->dynamic_slot_data.packets_interval)
2313 {
2314 CardReassignDynamicReservation(card);
2315 }
2316 }
2317} /* CardClearFromHostDataSlotWithoutFreeingBulkData() */
2318
2319
2320#endif
2321
2322u16 CardGetDataSlotSize(card_t *card)
2323{
2324 return card->config_data.data_slot_size;
2325} /* CardGetDataSlotSize() */
2326
2327
2328/*
2329 * ---------------------------------------------------------------------------
2330 * CardGetFreeFromHostDataSlots
2331 *
2332 * Retrieve the number of from-host bulk data slots available.
2333 *
2334 * Arguments:
2335 * card Pointer to the card context struct
2336 *
2337 * Returns:
2338 * Number of free from-host bulk data slots.
2339 * ---------------------------------------------------------------------------
2340 */
2341u16 CardGetFreeFromHostDataSlots(card_t *card)
2342{
2343 u16 i, n = 0;
2344
2345 /* First two slots reserved for MLME */
2346 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
2347 {
2348 if (card->from_host_data[i].bd.data_length == 0)
2349 {
2350 /* Free slot */
2351 n++;
2352 }
2353 }
2354
2355 return n;
2356} /* CardGetFreeFromHostDataSlots() */
2357
2358
2359/*
2360 * ---------------------------------------------------------------------------
2361 * CardAreAllFromHostDataSlotsEmpty
2362 *
2363 * Returns the state of from-host bulk data slots.
2364 *
2365 * Arguments:
2366 * card Pointer to the card context struct
2367 *
2368 * Returns:
2369 * 1 The from-host bulk data slots are all empty (available).
2370 * 0 Some or all the from-host bulk data slots are in use.
2371 * ---------------------------------------------------------------------------
2372 */
2373u16 CardAreAllFromHostDataSlotsEmpty(card_t *card)
2374{
2375 u16 i;
2376
2377 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
2378 {
2379 if (card->from_host_data[i].bd.data_length != 0)
2380 {
2381 return 0;
2382 }
2383 }
2384
2385 return 1;
2386} /* CardGetFreeFromHostDataSlots() */
2387
2388
2389static CsrResult unifi_identify_hw(card_t *card)
2390{
2391
2392 card->chip_id = card->sdio_if->sdioId.cardId;
2393 card->function = card->sdio_if->sdioId.sdioFunction;
2394 card->sdio_io_block_size = card->sdio_if->blockSize;
2395
2396 /* If SDIO controller doesn't support byte mode CMD53, pad transfers to block sizes */
2397 card->sdio_io_block_pad = (card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE)?FALSE : TRUE;
2398
2399 /*
2400 * Setup the chip helper so that we can access the registers (and
2401 * also tell what sub-type of HIP we should use).
2402 */
2403 card->helper = ChipHelper_GetVersionSdio((u8)card->chip_id);
2404 if (!card->helper)
2405 {
2406 unifi_error(card->ospriv, "Null ChipHelper\n");
2407 }
2408
2409 unifi_info(card->ospriv, "Chip ID 0x%02X Function %u Block Size %u Name %s(%s)\n",
2410 card->chip_id, card->function, card->sdio_io_block_size,
2411 ChipHelper_MarketingName(card->helper),
2412 ChipHelper_FriendlyName(card->helper));
2413
2414 return CSR_RESULT_SUCCESS;
2415} /* unifi_identify_hw() */
2416
2417
2418static CsrResult unifi_prepare_hw(card_t *card)
2419{
2420 CsrResult r;
2421 CsrResult csrResult;
2422 enum unifi_host_state old_state = card->host_state;
2423
2424 r = unifi_identify_hw(card);
2425 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2426 {
2427 return r;
2428 }
2429 if (r != CSR_RESULT_SUCCESS)
2430 {
2431 unifi_error(card->ospriv, "Failed to identify hw\n");
2432 return r;
2433 }
2434
2435 unifi_trace(card->ospriv, UDBG1,
2436 "%s mode SDIO\n", card->sdio_io_block_pad?"Block" : "Byte");
2437 /*
2438 * Chip must be a awake or blocks that are asleep may not get
2439 * reset. We can only do this after we have read the chip_id.
2440 */
2441 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
2442 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2443 {
2444 return r;
2445 }
2446
2447 if (old_state == UNIFI_HOST_STATE_TORPID)
2448 {
2449 /* Ensure the initial clock rate is set; if a reset occurred when the chip was
2450 * TORPID, unifi_set_host_state() may have raised it to MAX.
2451 */
2452 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
2453 if (csrResult != CSR_RESULT_SUCCESS)
2454 {
2455 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2456 return r;
2457 }
2458 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
2459 }
2460
2461 /*
2462 * The WLAN function must be enabled to access MAILBOX2 and DEBUG_RST
2463 * registers.
2464 */
2465 csrResult = CsrSdioFunctionEnable(card->sdio_if);
2466 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
2467 {
2468 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
2469 }
2470 if (csrResult != CSR_RESULT_SUCCESS)
2471 {
2472 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2473 /* Can't enable WLAN function. Try resetting the SDIO block. */
2474 unifi_error(card->ospriv, "Failed to re-enable function %d.\n", card->function);
2475 return r;
2476 }
2477
2478 /*
2479 * Poke some registers to make sure the PLL has started,
2480 * otherwise memory accesses are likely to fail.
2481 */
2482 bootstrap_chip_hw(card);
2483
2484 /* Try to read the chip version from register. */
2485 r = unifi_read_chip_version(card);
2486 if (r != CSR_RESULT_SUCCESS)
2487 {
2488 return r;
2489 }
2490
2491 return CSR_RESULT_SUCCESS;
2492} /* unifi_prepare_hw() */
2493
2494
2495static CsrResult unifi_read_chip_version(card_t *card)
2496{
2497 u32 gbl_chip_version;
2498 CsrResult r;
2499 u16 ver;
2500
2501 gbl_chip_version = ChipHelper_GBL_CHIP_VERSION(card->helper);
2502
2503 /* Try to read the chip version from register. */
2504 if (gbl_chip_version != 0)
2505 {
2506 r = unifi_read_direct16(card, gbl_chip_version * 2, &ver);
2507 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2508 {
2509 return r;
2510 }
2511 if (r != CSR_RESULT_SUCCESS)
2512 {
2513 unifi_error(card->ospriv, "Failed to read GBL_CHIP_VERSION\n");
2514 return r;
2515 }
2516 card->chip_version = ver;
2517 }
2518 else
2519 {
2520 unifi_info(card->ospriv, "Unknown Chip ID, cannot locate GBL_CHIP_VERSION\n");
2521 r = CSR_RESULT_FAILURE;
2522 }
2523
2524 unifi_info(card->ospriv, "Chip Version 0x%04X\n", card->chip_version);
2525
2526 return r;
2527} /* unifi_read_chip_version() */
2528
2529
2530/*
2531 * ---------------------------------------------------------------------------
2532 * unifi_reset_hardware
2533 *
2534 * Execute the UniFi reset sequence.
2535 *
2536 * Note: This may fail if the chip is going TORPID so retry at
2537 * least once.
2538 *
2539 * Arguments:
2540 * card - pointer to card context structure
2541 *
2542 * Returns:
2543 * CSR_RESULT_SUCCESS on success, CSR error otherwise.
2544 *
2545 * Notes:
2546 * Some platforms (e.g. Windows Vista) do not allow access to registers
2547 * that are necessary for a software soft reset.
2548 * ---------------------------------------------------------------------------
2549 */
2550static CsrResult unifi_reset_hardware(card_t *card)
2551{
2552 CsrResult r;
2553 u16 new_block_size = UNIFI_IO_BLOCK_SIZE;
2554 CsrResult csrResult;
2555
2556 /* Errors returned by unifi_prepare_hw() are not critical at this point */
2557 r = unifi_prepare_hw(card);
2558 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2559 {
2560 return r;
2561 }
2562
2563 /* First try SDIO controller reset, which may power cycle the UniFi, assert
2564 * its reset line, or not be implemented depending on the platform.
2565 */
2566 unifi_info(card->ospriv, "Calling CsrSdioHardReset\n");
2567 csrResult = CsrSdioHardReset(card->sdio_if);
2568 if (csrResult == CSR_RESULT_SUCCESS)
2569 {
2570 unifi_info(card->ospriv, "CsrSdioHardReset succeeded on resetting UniFi\n");
2571 r = unifi_prepare_hw(card);
2572 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2573 {
2574 return r;
2575 }
2576 if (r != CSR_RESULT_SUCCESS)
2577 {
2578 unifi_error(card->ospriv, "unifi_prepare_hw failed after hard reset\n");
2579 return r;
2580 }
2581 }
2582 else if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
2583 {
2584 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
2585 }
2586 else
2587 {
2588 /* Falling back to software hard reset methods */
2589 unifi_info(card->ospriv, "Falling back to software hard reset\n");
2590 r = unifi_card_hard_reset(card);
2591 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2592 {
2593 return r;
2594 }
2595 if (r != CSR_RESULT_SUCCESS)
2596 {
2597 unifi_error(card->ospriv, "software hard reset failed\n");
2598 return r;
2599 }
2600
2601 /* If we fell back to unifi_card_hard_reset() methods, chip version may
2602 * not have been read. (Note in the unlikely event that it is zero,
2603 * it will be harmlessly read again)
2604 */
2605 if (card->chip_version == 0)
2606 {
2607 r = unifi_read_chip_version(card);
2608 if (r != CSR_RESULT_SUCCESS)
2609 {
2610 return r;
2611 }
2612 }
2613 }
2614
2615#ifdef CSR_WIFI_HIP_SDIO_BLOCK_SIZE
2616 new_block_size = CSR_WIFI_HIP_SDIO_BLOCK_SIZE;
2617#endif
2618
2619 /* After hard reset, we need to restore the SDIO block size */
2620 csrResult = CsrSdioBlockSizeSet(card->sdio_if, new_block_size);
2621 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2622
2623 /* Warn if a different block size was achieved by the transport */
2624 if (card->sdio_if->blockSize != new_block_size)
2625 {
2626 unifi_info(card->ospriv,
2627 "Actually got block size %d\n", card->sdio_if->blockSize);
2628 }
2629
2630 /* sdio_io_block_size always needs be updated from the achieved block size,
2631 * as it is used by the OS layer to allocate memory in unifi_net_malloc().
2632 * Controllers which don't support block mode (e.g. CSPI) will report a
2633 * block size of zero.
2634 */
2635 if (card->sdio_if->blockSize == 0)
2636 {
2637 unifi_info(card->ospriv, "Block size 0, block mode not available\n");
2638
2639 /* Set sdio_io_block_size to 1 so that unifi_net_data_malloc() has a
2640 * sensible rounding value. Elsewhere padding will already be
2641 * disabled because the controller supports byte mode.
2642 */
2643 card->sdio_io_block_size = 1;
2644
2645 /* Controller features must declare support for byte mode */
2646 if (!(card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE))
2647 {
2648 unifi_error(card->ospriv, "Requires byte mode\n");
2649 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2650 }
2651 }
2652 else
2653 {
2654 /* Padding will be enabled if CSR_SDIO_FEATURE_BYTE_MODE isn't set */
2655 card->sdio_io_block_size = card->sdio_if->blockSize;
2656 }
2657
2658
2659 return r;
2660} /* unifi_reset_hardware() */
2661
2662
2663/*
2664 * ---------------------------------------------------------------------------
2665 * card_reset_method_io_enable
2666 *
2667 * Issue a hard reset to the hw writing the IO_ENABLE.
2668 *
2669 * Arguments:
2670 * card Pointer to Card object
2671 *
2672 * Returns:
2673 * 0 on success,
2674 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2675 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2676 * was not seen in the expected time
2677 * ---------------------------------------------------------------------------
2678 */
2679static CsrResult card_reset_method_io_enable(card_t *card)
2680{
2681 CsrResult r;
2682 CsrResult csrResult;
2683
2684 /*
2685 * This resets only function 1, so should be used in
2686 * preference to the method below (CSR_FUNC_EN)
2687 */
2688 unifi_trace(card->ospriv, UDBG1, "Hard reset (IO_ENABLE)\n");
2689
2690 csrResult = CsrSdioFunctionDisable(card->sdio_if);
2691 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
2692 {
2693 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
2694 }
2695 if (csrResult != CSR_RESULT_SUCCESS)
2696 {
2697 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2698 unifi_warning(card->ospriv, "SDIO error writing IO_ENABLE: %d\n", r);
2699 }
2700 else
2701 {
2702 /* Delay here to let the reset take affect. */
2703 CsrThreadSleep(RESET_SETTLE_DELAY);
2704
2705 r = card_wait_for_unifi_to_disable(card);
2706 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2707 {
2708 return r;
2709 }
2710
2711 if (r == CSR_RESULT_SUCCESS)
2712 {
2713 r = card_wait_for_unifi_to_reset(card);
2714 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2715 {
2716 return r;
2717 }
2718 }
2719 }
2720
2721 if (r != CSR_RESULT_SUCCESS)
2722 {
2723 unifi_trace(card->ospriv, UDBG1, "Hard reset (CSR_FUNC_EN)\n");
2724
2725 r = sdio_write_f0(card, SDIO_CSR_FUNC_EN, 0);
2726 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2727 {
2728 return r;
2729 }
2730 if (r != CSR_RESULT_SUCCESS)
2731 {
2732 unifi_warning(card->ospriv, "SDIO error writing SDIO_CSR_FUNC_EN: %d\n", r);
2733 return r;
2734 }
2735 else
2736 {
2737 /* Delay here to let the reset take affect. */
2738 CsrThreadSleep(RESET_SETTLE_DELAY);
2739
2740 r = card_wait_for_unifi_to_reset(card);
2741 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2742 {
2743 return r;
2744 }
2745 }
2746 }
2747
2748 if (r != CSR_RESULT_SUCCESS)
2749 {
2750 unifi_warning(card->ospriv, "card_reset_method_io_enable failed to reset UniFi\n");
2751 }
2752
2753 return r;
2754} /* card_reset_method_io_enable() */
2755
2756
2757/*
2758 * ---------------------------------------------------------------------------
2759 * card_reset_method_dbg_reset
2760 *
2761 * Issue a hard reset to the hw writing the DBG_RESET.
2762 *
2763 * Arguments:
2764 * card Pointer to Card object
2765 *
2766 * Returns:
2767 * CSR_RESULT_SUCCESS on success,
2768 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2769 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2770 * was not seen in the expected time
2771 * ---------------------------------------------------------------------------
2772 */
2773static CsrResult card_reset_method_dbg_reset(card_t *card)
2774{
2775 CsrResult r;
2776
2777 /*
2778 * Prepare UniFi for h/w reset
2779 */
2780 if (card->host_state == UNIFI_HOST_STATE_TORPID)
2781 {
2782 r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
2783 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2784 {
2785 return r;
2786 }
2787 if (r != CSR_RESULT_SUCCESS)
2788 {
2789 unifi_error(card->ospriv, "Failed to set UNIFI_HOST_STATE_DROWSY\n");
2790 return r;
2791 }
2792 CsrThreadSleep(5);
2793 }
2794
2795 r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
2796 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2797 {
2798 return r;
2799 }
2800 if (r != CSR_RESULT_SUCCESS)
2801 {
2802 unifi_error(card->ospriv, "Can't stop processors\n");
2803 return r;
2804 }
2805
2806 unifi_trace(card->ospriv, UDBG1, "Hard reset (DBG_RESET)\n");
2807
2808 /*
2809 * This register write may fail. The debug reset resets
2810 * parts of the Function 0 sections of the chip, and
2811 * therefore the response cannot be sent back to the host.
2812 */
2813 r = unifi_write_direct_8_or_16(card, ChipHelper_DBG_RESET(card->helper) * 2, 1);
2814 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2815 {
2816 return r;
2817 }
2818 if (r != CSR_RESULT_SUCCESS)
2819 {
2820 unifi_warning(card->ospriv, "SDIO error writing DBG_RESET: %d\n", r);
2821 return r;
2822 }
2823
2824 /* Delay here to let the reset take affect. */
2825 CsrThreadSleep(RESET_SETTLE_DELAY);
2826
2827 r = card_wait_for_unifi_to_reset(card);
2828 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2829 {
2830 return r;
2831 }
2832 if (r != CSR_RESULT_SUCCESS)
2833 {
2834 unifi_warning(card->ospriv, "card_reset_method_dbg_reset failed to reset UniFi\n");
2835 }
2836
2837 return r;
2838} /* card_reset_method_dbg_reset() */
2839
2840
2841/*
2842 * ---------------------------------------------------------------------------
2843 * unifi_card_hard_reset
2844 *
2845 * Issue reset to hardware, by writing to registers on the card.
2846 * Power to the card is preserved.
2847 *
2848 * Arguments:
2849 * card Pointer to Card object
2850 *
2851 * Returns:
2852 * CSR_RESULT_SUCCESS on success,
2853 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2854 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2855 * was not seen in the expected time
2856 * ---------------------------------------------------------------------------
2857 */
2858CsrResult unifi_card_hard_reset(card_t *card)
2859{
2860 CsrResult r;
2861 const struct chip_helper_reset_values *init_data;
2862 u32 chunks;
2863
2864 /* Clear cache of page registers */
2865 card->proc_select = (u32)(-1);
2866 card->dmem_page = (u32)(-1);
2867 card->pmem_page = (u32)(-1);
2868
2869 /*
2870 * We need to have a valid card->helper before we use software hard reset.
2871 * If unifi_identify_hw() fails to get the card ID, it probably means
2872 * that there is no way to talk to the h/w.
2873 */
2874 r = unifi_identify_hw(card);
2875 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2876 {
2877 return r;
2878 }
2879 if (r != CSR_RESULT_SUCCESS)
2880 {
2881 unifi_error(card->ospriv, "unifi_card_hard_reset failed to identify h/w\n");
2882 return r;
2883 }
2884
2885 /* Search for some reset code. */
2886 chunks = ChipHelper_HostResetSequence(card->helper, &init_data);
2887 if (chunks != 0)
2888 {
2889 unifi_error(card->ospriv,
2890 "Hard reset (Code download) is unsupported\n");
2891
2892 return CSR_RESULT_FAILURE;
2893 }
2894
2895 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
2896 {
2897 /* The HIP spec considers this a bus-specific reset.
2898 * This resets only function 1, so should be used in
2899 * preference to the method below (CSR_FUNC_EN)
2900 * If this method fails, it means that the f/w is probably
2901 * not running. In this case, try the DBG_RESET method.
2902 */
2903 r = card_reset_method_io_enable(card);
2904 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2905 {
2906 return r;
2907 }
2908 if (r == CSR_RESULT_SUCCESS)
2909 {
2910 return r;
2911 }
2912 }
2913
2914 /* Software hard reset */
2915 r = card_reset_method_dbg_reset(card);
2916
2917 return r;
2918} /* unifi_card_hard_reset() */
2919
2920
2921/*
2922 * ---------------------------------------------------------------------------
2923 *
2924 * CardGenInt
2925 *
2926 * Prod the card.
2927 * This function causes an internal interrupt to be raised in the
2928 * UniFi chip. It is used to signal the firmware that some action has
2929 * been completed.
2930 * The UniFi Host Interface asks that the value used increments for
2931 * debugging purposes.
2932 *
2933 * Arguments:
2934 * card Pointer to Card object
2935 *
2936 * Returns:
2937 * CSR_RESULT_SUCCESS on success,
2938 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2939 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2940 * was not seen in the expected time
2941 * ---------------------------------------------------------------------------
2942 */
2943CsrResult CardGenInt(card_t *card)
2944{
2945 CsrResult r;
2946
2947 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
2948 {
2949 r = sdio_write_f0(card, SDIO_CSR_FROM_HOST_SCRATCH0,
2950 (u8)card->unifi_interrupt_seq);
2951 }
2952 else
2953 {
2954 r = unifi_write_direct_8_or_16(card,
2955 ChipHelper_SHARED_IO_INTERRUPT(card->helper) * 2,
2956 (u8)card->unifi_interrupt_seq);
2957 }
2958 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2959 {
2960 return r;
2961 }
2962 if (r != CSR_RESULT_SUCCESS)
2963 {
2964 unifi_error(card->ospriv, "SDIO error writing UNIFI_SHARED_IO_INTERRUPT: %d\n", r);
2965 return r;
2966 }
2967
2968 card->unifi_interrupt_seq++;
2969
2970 return CSR_RESULT_SUCCESS;
2971} /* CardGenInt() */
2972
2973
2974/*
2975 * ---------------------------------------------------------------------------
2976 * CardEnableInt
2977 *
2978 * Enable the outgoing SDIO interrupt from UniFi to the host.
2979 *
2980 * Arguments:
2981 * card Pointer to Card object
2982 *
2983 * Returns:
2984 * CSR_RESULT_SUCCESS on success,
2985 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2986 * CSR_RESULT_FAILURE if an SDIO error occurred,
2987 * ---------------------------------------------------------------------------
2988 */
2989CsrResult CardEnableInt(card_t *card)
2990{
2991 CsrResult r;
2992 u8 int_enable;
2993
2994 r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
2995 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2996 {
2997 return r;
2998 }
2999 if (r != CSR_RESULT_SUCCESS)
3000 {
3001 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
3002 return r;
3003 }
3004
3005 int_enable |= (1 << card->function) | UNIFI_SD_INT_ENABLE_IENM;
3006
3007 r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
3008 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3009 {
3010 return r;
3011 }
3012 if (r != CSR_RESULT_SUCCESS)
3013 {
3014 unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
3015 return r;
3016 }
3017
3018 return CSR_RESULT_SUCCESS;
3019} /* CardEnableInt() */
3020
3021
3022/*
3023 * ---------------------------------------------------------------------------
3024 * CardDisableInt
3025 *
3026 * Disable the outgoing SDIO interrupt from UniFi to the host.
3027 *
3028 * Arguments:
3029 * card Pointer to Card object
3030 *
3031 * Returns:
3032 * CSR_RESULT_SUCCESS on success,
3033 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3034 * CSR_RESULT_FAILURE if an SDIO error occurred,
3035 * ---------------------------------------------------------------------------
3036 */
3037CsrResult CardDisableInt(card_t *card)
3038{
3039 CsrResult r;
3040 u8 int_enable;
3041
3042 r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
3043 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3044 {
3045 return r;
3046 }
3047 if (r != CSR_RESULT_SUCCESS)
3048 {
3049 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
3050 return r;
3051 }
3052
3053 int_enable &= ~(1 << card->function);
3054
3055 r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
3056 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3057 {
3058 return r;
3059 }
3060 if (r != CSR_RESULT_SUCCESS)
3061 {
3062 unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
3063 return r;
3064 }
3065
3066 return CSR_RESULT_SUCCESS;
3067} /* CardDisableInt() */
3068
3069
3070/*
3071 * ---------------------------------------------------------------------------
3072 * CardPendingInt
3073 *
3074 * Determine whether UniFi is currently asserting the SDIO interrupt
3075 * request.
3076 *
3077 * Arguments:
3078 * card Pointer to Card object
3079 * pintr Pointer to location to write interrupt status,
3080 * TRUE if interrupt pending,
3081 * FALSE if no interrupt pending.
3082 * Returns:
3083 * CSR_RESULT_SUCCESS interrupt status read successfully
3084 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3085 * CSR_RESULT_FAILURE if an SDIO error occurred,
3086 * ---------------------------------------------------------------------------
3087 */
3088CsrResult CardPendingInt(card_t *card, u8 *pintr)
3089{
3090 CsrResult r;
3091 u8 pending;
3092
3093 *pintr = FALSE;
3094
3095 r = sdio_read_f0(card, SDIO_INT_PENDING, &pending);
3096 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3097 {
3098 return r;
3099 }
3100 if (r != CSR_RESULT_SUCCESS)
3101 {
3102 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_PENDING\n");
3103 return r;
3104 }
3105
3106 *pintr = (pending & (1 << card->function))?TRUE : FALSE;
3107
3108 return CSR_RESULT_SUCCESS;
3109} /* CardPendingInt() */
3110
3111
3112/*
3113 * ---------------------------------------------------------------------------
3114 * CardClearInt
3115 *
3116 * Clear the UniFi SDIO interrupt request.
3117 *
3118 * Arguments:
3119 * card Pointer to Card object
3120 *
3121 * Returns:
3122 * CSR_RESULT_SUCCESS if pending interrupt was cleared, or no pending interrupt.
3123 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3124 * CSR_RESULT_FAILURE if an SDIO error occurred,
3125 * ---------------------------------------------------------------------------
3126 */
3127CsrResult CardClearInt(card_t *card)
3128{
3129 CsrResult r;
3130 u8 intr;
3131
3132 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
3133 {
3134 /* CardPendingInt() sets intr, if there is a pending interrupt */
3135 r = CardPendingInt(card, &intr);
3136 if (intr == FALSE)
3137 {
3138 return r;
3139 }
3140
3141 r = sdio_write_f0(card, SDIO_CSR_HOST_INT_CLEAR, 1);
3142 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3143 {
3144 return r;
3145 }
3146 if (r != CSR_RESULT_SUCCESS)
3147 {
3148 unifi_error(card->ospriv, "SDIO error writing SDIO_CSR_HOST_INT_CLEAR\n");
3149 }
3150 }
3151 else
3152 {
3153 r = unifi_write_direct_8_or_16(card,
3154 ChipHelper_SDIO_HOST_INT(card->helper) * 2,
3155 0);
3156 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3157 {
3158 return r;
3159 }
3160 if (r != CSR_RESULT_SUCCESS)
3161 {
3162 unifi_error(card->ospriv, "SDIO error writing UNIFI_SDIO_HOST_INT\n");
3163 }
3164 }
3165
3166 return r;
3167} /* CardClearInt() */
3168
3169
3170/*
3171 * ---------------------------------------------------------------------------
3172 * CardIntEnabled
3173 *
3174 * Determine whether UniFi is currently asserting the SDIO interrupt
3175 * request.
3176 *
3177 * Arguments:
3178 * card Pointer to Card object
3179 * enabled Pointer to location to write interrupt enable status,
3180 * TRUE if interrupts enabled,
3181 * FALSE if interupts disabled.
3182 *
3183 * Returns:
3184 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3185 * CSR_RESULT_FAILURE if an SDIO error occurred,
3186 * ---------------------------------------------------------------------------
3187 */
3188CsrResult CardIntEnabled(card_t *card, u8 *enabled)
3189{
3190 CsrResult r;
3191 u8 int_enable;
3192
3193 r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
3194 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3195 {
3196 return r;
3197 }
3198 if (r != CSR_RESULT_SUCCESS)
3199 {
3200 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
3201 return r;
3202 }
3203
3204 *enabled = (int_enable & (1 << card->function))?TRUE : FALSE;
3205
3206 return CSR_RESULT_SUCCESS;
3207} /* CardIntEnabled() */
3208
3209
3210/*
3211 * ---------------------------------------------------------------------------
3212 * CardWriteBulkData
3213 * Allocate slot in the pending bulkdata arrays and assign it to a signal's
3214 * bulkdata reference. The slot is then ready for UniFi's bulkdata commands
3215 * to transfer the data to/from the host.
3216 *
3217 * Arguments:
3218 * card Pointer to Card object
3219 * csptr Pending signal pointer, including bulkdata ref
3220 * queue Traffic queue that this signal is using
3221 *
3222 * Returns:
3223 * CSR_RESULT_SUCCESS if a free slot was assigned
3224 * CSR_RESULT_FAILURE if no slot was available
3225 * ---------------------------------------------------------------------------
3226 */
3227CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue)
3228{
3229 u16 i, slots[UNIFI_MAX_DATA_REFERENCES], j = 0;
3230 u8 *packed_sigptr, num_slots_required = 0;
3231 bulk_data_desc_t *bulkdata = csptr->bulkdata;
3232 s16 h, nslots;
3233
3234 /* Count the number of slots required */
3235 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
3236 {
3237 if (bulkdata[i].data_length != 0)
3238 {
3239 num_slots_required++;
3240 }
3241 }
3242
3243 /* Get the slot numbers */
3244 if (num_slots_required != 0)
3245 {
3246 /* Last 2 slots for MLME */
3247 if (queue == UNIFI_TRAFFIC_Q_MLME)
3248 {
3249 h = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
3250 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
3251 {
3252 if (card->from_host_data[h].bd.data_length == 0)
3253 {
3254 /* Free data slot, claim it */
3255 slots[j++] = h;
3256 if (j == num_slots_required)
3257 {
3258 break;
3259 }
3260 }
3261
3262 if (++h >= card->config_data.num_fromhost_data_slots)
3263 {
3264 h = 0;
3265 }
3266 }
3267 }
3268 else
3269 {
3270 if (card->dynamic_slot_data.from_host_used_slots[queue]
3271 < card->dynamic_slot_data.from_host_max_slots[queue])
3272 {
3273 /* Data commands get a free slot only after a few checks */
3274 nslots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
3275
3276 h = card->from_host_data_head;
3277
3278 for (i = 0; i < nslots; i++)
3279 {
3280 if (card->from_host_data[h].bd.data_length == 0)
3281 {
3282 /* Free data slot, claim it */
3283 slots[j++] = h;
3284 if (j == num_slots_required)
3285 {
3286 break;
3287 }
3288 }
3289
3290 if (++h >= nslots)
3291 {
3292 h = 0;
3293 }
3294 }
3295 card->from_host_data_head = h;
3296 }
3297 }
3298
3299 /* Required number of slots are not available, bail out */
3300 if (j != num_slots_required)
3301 {
3302 unifi_trace(card->ospriv, UDBG5, "CardWriteBulkData: didn't find free slot/s\n");
3303
3304 /* If we haven't already reached the stable state we can ask for reservation */
3305 if ((queue != UNIFI_TRAFFIC_Q_MLME) && (card->dynamic_slot_data.queue_stable[queue] == FALSE))
3306 {
3307 CardCheckDynamicReservation(card, queue);
3308 }
3309
3310 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
3311 {
3312 unifi_trace(card->ospriv, UDBG5, "fh data slot %d: %d\n", i, card->from_host_data[i].bd.data_length);
3313 }
3314 return CSR_RESULT_FAILURE;
3315 }
3316 }
3317
3318 packed_sigptr = csptr->sigbuf;
3319
3320 /* Fill in the slots with data */
3321 j = 0;
3322 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
3323 {
3324 if (bulkdata[i].data_length == 0)
3325 {
3326 /* Zero-out the DATAREF in the signal */
3327 SET_PACKED_DATAREF_SLOT(packed_sigptr, i, 0);
3328 SET_PACKED_DATAREF_LEN(packed_sigptr, i, 0);
3329 }
3330 else
3331 {
3332 /*
3333 * Fill in the slot number in the SIGNAL structure but
3334 * preserve the offset already in there
3335 */
3336 SET_PACKED_DATAREF_SLOT(packed_sigptr, i, slots[j] | (((u16)packed_sigptr[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1]) << 8));
3337 SET_PACKED_DATAREF_LEN(packed_sigptr, i, bulkdata[i].data_length);
3338
3339 /* Do not copy the data, just store the information to them */
3340 card->from_host_data[slots[j]].bd.os_data_ptr = bulkdata[i].os_data_ptr;
3341 card->from_host_data[slots[j]].bd.os_net_buf_ptr = bulkdata[i].os_net_buf_ptr;
3342 card->from_host_data[slots[j]].bd.data_length = bulkdata[i].data_length;
3343 card->from_host_data[slots[j]].bd.net_buf_length = bulkdata[i].net_buf_length;
3344 card->from_host_data[slots[j]].queue = queue;
3345
3346 unifi_trace(card->ospriv, UDBG4, "CardWriteBulkData sig=0x%x, fh slot %d = %p\n",
3347 GET_SIGNAL_ID(packed_sigptr), i, bulkdata[i].os_data_ptr);
3348
3349 /* Sanity-check that the bulk data desc being assigned to the slot
3350 * actually has a payload.
3351 */
3352 if (!bulkdata[i].os_data_ptr)
3353 {
3354 unifi_error(card->ospriv, "Assign null os_data_ptr (len=%d) fh slot %d, i=%d, q=%d, sig=0x%x",
3355 bulkdata[i].data_length, slots[j], i, queue, GET_SIGNAL_ID(packed_sigptr));
3356 }
3357
3358 j++;
3359 if (queue < UNIFI_NO_OF_TX_QS)
3360 {
3361 card->dynamic_slot_data.from_host_used_slots[queue]++;
3362 }
3363 }
3364 }
3365
3366 return CSR_RESULT_SUCCESS;
3367} /* CardWriteBulkData() */
3368
3369
3370/*
3371 * ---------------------------------------------------------------------------
3372 * card_find_data_slot
3373 *
3374 * Dereference references to bulk data slots into pointers to real data.
3375 *
3376 * Arguments:
3377 * card Pointer to the card struct.
3378 * slot Slot number from a signal structure
3379 *
3380 * Returns:
3381 * Pointer to entry in bulk_data_slot array.
3382 * ---------------------------------------------------------------------------
3383 */
3384bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot)
3385{
3386 s16 sn;
3387 bulk_data_desc_t *bd;
3388
3389 sn = slot & 0x7FFF;
3390
3391 /* ?? check sanity of slot number ?? */
3392
3393 if (slot & SLOT_DIR_TO_HOST)
3394 {
3395 bd = &card->to_host_data[sn];
3396 }
3397 else
3398 {
3399 bd = &card->from_host_data[sn].bd;
3400 }
3401
3402 return bd;
3403} /* card_find_data_slot() */
3404
3405
3406/*
3407 * ---------------------------------------------------------------------------
3408 * firmware_present_in_flash
3409 *
3410 * Probe for external Flash that looks like it might contain firmware.
3411 *
3412 * If Flash is not present, reads always return 0x0008.
3413 * If Flash is present, but empty, reads return 0xFFFF.
3414 * Anything else is considered to be firmware.
3415 *
3416 * Arguments:
3417 * card Pointer to card struct
3418 *
3419 * Returns:
3420 * CSR_RESULT_SUCCESS firmware is present in ROM or flash
3421 * CSR_WIFI_HIP_RESULT_NOT_FOUND firmware is not present in ROM or flash
3422 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3423 * CSR_RESULT_FAILURE if an SDIO error occurred
3424 * ---------------------------------------------------------------------------
3425 */
3426static CsrResult firmware_present_in_flash(card_t *card)
3427{
3428 CsrResult r;
3429 u16 m1, m5;
3430
3431 if (ChipHelper_HasRom(card->helper))
3432 {
3433 return CSR_RESULT_SUCCESS;
3434 }
3435 if (!ChipHelper_HasFlash(card->helper))
3436 {
3437 return CSR_WIFI_HIP_RESULT_NOT_FOUND;
3438 }
3439
3440 /*
3441 * Examine the Flash locations that are the power-on default reset
3442 * vectors of the XAP processors.
3443 * These are words 1 and 5 in Flash.
3444 */
3445 r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 2), &m1);
3446 if (r != CSR_RESULT_SUCCESS)
3447 {
3448 return r;
3449 }
3450
3451 r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 10), &m5);
3452 if (r != CSR_RESULT_SUCCESS)
3453 {
3454 return r;
3455 }
3456
3457 /* Check for uninitialised/missing flash */
3458 if ((m1 == 0x0008) || (m1 == 0xFFFF) ||
3459 (m1 == 0x0004) || (m5 == 0x0004) ||
3460 (m5 == 0x0008) || (m5 == 0xFFFF))
3461 {
3462 return CSR_WIFI_HIP_RESULT_NOT_FOUND;
3463 }
3464
3465 return CSR_RESULT_SUCCESS;
3466} /* firmware_present_in_flash() */
3467
3468
3469/*
3470 * ---------------------------------------------------------------------------
3471 * bootstrap_chip_hw
3472 *
3473 * Perform chip specific magic to "Get It Working" TM. This will
3474 * increase speed of PLLs in analogue and maybe enable some
3475 * on-chip regulators.
3476 *
3477 * Arguments:
3478 * card Pointer to card struct
3479 *
3480 * Returns:
3481 * None.
3482 * ---------------------------------------------------------------------------
3483 */
3484static void bootstrap_chip_hw(card_t *card)
3485{
3486 const struct chip_helper_init_values *vals;
3487 u32 i, len;
3488 void *sdio = card->sdio_if;
3489 CsrResult csrResult;
3490
3491 len = ChipHelper_ClockStartupSequence(card->helper, &vals);
3492 if (len != 0)
3493 {
3494 for (i = 0; i < len; i++)
3495 {
3496 csrResult = CsrSdioWrite16(sdio, vals[i].addr * 2, vals[i].value);
3497 if (csrResult != CSR_RESULT_SUCCESS)
3498 {
3499 unifi_warning(card->ospriv, "Failed to write bootstrap value %d\n", i);
3500 /* Might not be fatal */
3501 }
3502
3503 CsrThreadSleep(1);
3504 }
3505 }
3506} /* bootstrap_chip_hw() */
3507
3508
3509/*
3510 * ---------------------------------------------------------------------------
3511 * unifi_card_stop_processor
3512 *
3513 * Stop the UniFi XAP processors.
3514 *
3515 * Arguments:
3516 * card Pointer to card struct
3517 * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
3518 *
3519 * Returns:
3520 * CSR_RESULT_SUCCESS if successful, or CSR error code
3521 * ---------------------------------------------------------------------------
3522 */
3523CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which)
3524{
3525 CsrResult r = CSR_RESULT_SUCCESS;
3526 u8 status;
3527 s16 retry = 100;
3528
3529 while (retry--)
3530 {
3531 /* Select both XAPs */
3532 r = unifi_set_proc_select(card, which);
3533 if (r != CSR_RESULT_SUCCESS)
3534 {
3535 break;
3536 }
3537
3538 /* Stop processors */
3539 r = unifi_write_direct16(card, ChipHelper_DBG_EMU_CMD(card->helper) * 2, 2);
3540 if (r != CSR_RESULT_SUCCESS)
3541 {
3542 break;
3543 }
3544
3545 /* Read status */
3546 r = unifi_read_direct_8_or_16(card,
3547 ChipHelper_DBG_HOST_STOP_STATUS(card->helper) * 2,
3548 &status);
3549 if (r != CSR_RESULT_SUCCESS)
3550 {
3551 break;
3552 }
3553
3554 if ((status & 1) == 1)
3555 {
3556 /* Success! */
3557 return CSR_RESULT_SUCCESS;
3558 }
3559
3560 /* Processors didn't stop, try again */
3561 }
3562
3563 if (r != CSR_RESULT_SUCCESS)
3564 {
3565 /* An SDIO error occurred */
3566 unifi_error(card->ospriv, "Failed to stop processors: SDIO error\n");
3567 }
3568 else
3569 {
3570 /* If we reach here, we didn't the status in time. */
3571 unifi_error(card->ospriv, "Failed to stop processors: timeout waiting for stopped status\n");
3572 r = CSR_RESULT_FAILURE;
3573 }
3574
3575 return r;
3576} /* unifi_card_stop_processor() */
3577
3578
3579/*
3580 * ---------------------------------------------------------------------------
3581 * card_start_processor
3582 *
3583 * Start the UniFi XAP processors.
3584 *
3585 * Arguments:
3586 * card Pointer to card struct
3587 * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
3588 *
3589 * Returns:
3590 * CSR_RESULT_SUCCESS or CSR error code
3591 * ---------------------------------------------------------------------------
3592 */
3593CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which)
3594{
3595 CsrResult r;
3596
3597 /* Select both XAPs */
3598 r = unifi_set_proc_select(card, which);
3599 if (r != CSR_RESULT_SUCCESS)
3600 {
3601 unifi_error(card->ospriv, "unifi_set_proc_select failed: %d.\n", r);
3602 return r;
3603 }
3604
3605
3606 r = unifi_write_direct_8_or_16(card,
3607 ChipHelper_DBG_EMU_CMD(card->helper) * 2, 8);
3608 if (r != CSR_RESULT_SUCCESS)
3609 {
3610 return r;
3611 }
3612
3613 r = unifi_write_direct_8_or_16(card,
3614 ChipHelper_DBG_EMU_CMD(card->helper) * 2, 0);
3615 if (r != CSR_RESULT_SUCCESS)
3616 {
3617 return r;
3618 }
3619
3620 return CSR_RESULT_SUCCESS;
3621} /* card_start_processor() */
3622
3623
3624/*
3625 * ---------------------------------------------------------------------------
3626 * unifi_set_interrupt_mode
3627 *
3628 * Configure the interrupt processing mode used by the HIP
3629 *
3630 * Arguments:
3631 * card Pointer to card struct
3632 * mode Interrupt mode to apply
3633 *
3634 * Returns:
3635 * None
3636 * ---------------------------------------------------------------------------
3637 */
3638void unifi_set_interrupt_mode(card_t *card, u32 mode)
3639{
3640 if (mode == CSR_WIFI_INTMODE_RUN_BH_ONCE)
3641 {
3642 unifi_info(card->ospriv, "Scheduled interrupt mode");
3643 }
3644 card->intmode = mode;
3645} /* unifi_set_interrupt_mode() */
3646
3647
3648/*
3649 * ---------------------------------------------------------------------------
3650 * unifi_start_processors
3651 *
3652 * Start all UniFi XAP processors.
3653 *
3654 * Arguments:
3655 * card Pointer to card struct
3656 *
3657 * Returns:
3658 * CSR_RESULT_SUCCESS on success, CSR error code on error
3659 * ---------------------------------------------------------------------------
3660 */
3661CsrResult unifi_start_processors(card_t *card)
3662{
3663 return card_start_processor(card, UNIFI_PROC_BOTH);
3664} /* unifi_start_processors() */
3665
3666
3667/*
3668 * ---------------------------------------------------------------------------
3669 * unifi_request_max_sdio_clock
3670 *
3671 * Requests that the maximum SDIO clock rate is set at the next suitable
3672 * opportunity (e.g. when the BH next runs, so as not to interfere with
3673 * any current operation).
3674 *
3675 * Arguments:
3676 * card Pointer to card struct
3677 *
3678 * Returns:
3679 * None
3680 * ---------------------------------------------------------------------------
3681 */
3682void unifi_request_max_sdio_clock(card_t *card)
3683{
3684 card->request_max_clock = 1;
3685} /* unifi_request_max_sdio_clock() */
3686
3687
3688/*
3689 * ---------------------------------------------------------------------------
3690 * unifi_set_host_state
3691 *
3692 * Set the host deep-sleep state.
3693 *
3694 * If transitioning to TORPID, the SDIO driver will be notified
3695 * that the SD bus will be unused (idle) and conversely, when
3696 * transitioning from TORPID that the bus will be used (active).
3697 *
3698 * Arguments:
3699 * card Pointer to card struct
3700 * state New deep-sleep state.
3701 *
3702 * Returns:
3703 * CSR_RESULT_SUCCESS on success
3704 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3705 * CSR_RESULT_FAILURE if an SDIO error occurred
3706 *
3707 * Notes:
3708 * We need to reduce the SDIO clock speed before trying to wake up the
3709 * chip. Actually, in the implementation below we reduce the clock speed
3710 * not just before we try to wake up the chip, but when we put the chip to
3711 * deep sleep. This means that if the f/w wakes up on its' own, we waste
3712 * a reduce/increace cycle. However, trying to eliminate this overhead is
3713 * proved difficult, as the current state machine in the HIP lib does at
3714 * least a CMD52 to disable the interrupts before we configure the host
3715 * state.
3716 * ---------------------------------------------------------------------------
3717 */
3718CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state)
3719{
3720 CsrResult r = CSR_RESULT_SUCCESS;
3721 CsrResult csrResult;
3722 static const char *const states[] = {
3723 "AWAKE", "DROWSY", "TORPID"
3724 };
3725 static const u8 state_csr_host_wakeup[] = {
3726 1, 3, 0
3727 };
3728 static const u8 state_io_abort[] = {
3729 0, 2, 3
3730 };
3731
3732 unifi_trace(card->ospriv, UDBG4, "State %s to %s\n",
3733 states[card->host_state], states[state]);
3734
3735 if (card->host_state == UNIFI_HOST_STATE_TORPID)
3736 {
3737 CsrSdioFunctionActive(card->sdio_if);
3738 }
3739
3740 /* Write the new state to UniFi. */
3741 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
3742 {
3743 r = sdio_write_f0(card, SDIO_CSR_HOST_WAKEUP,
3744 (u8)((card->function << 4) | state_csr_host_wakeup[state]));
3745 }
3746 else
3747 {
3748 r = sdio_write_f0(card, SDIO_IO_ABORT, state_io_abort[state]);
3749 }
3750
3751 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3752 {
3753 return r;
3754 }
3755 if (r != CSR_RESULT_SUCCESS)
3756 {
3757 unifi_error(card->ospriv, "Failed to write UniFi deep sleep state\n");
3758 }
3759 else
3760 {
3761 /*
3762 * If the chip was in state TORPID then we can now increase
3763 * the maximum bus clock speed.
3764 */
3765 if (card->host_state == UNIFI_HOST_STATE_TORPID)
3766 {
3767 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
3768 UNIFI_SDIO_CLOCK_MAX_HZ);
3769 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
3770 /* Non-fatal error */
3771 if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
3772 {
3773 unifi_warning(card->ospriv,
3774 "Failed to increase the SDIO clock speed\n");
3775 }
3776 else
3777 {
3778 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ;
3779 }
3780 }
3781
3782 /*
3783 * Cache the current state in the card structure to avoid
3784 * unnecessary SDIO reads.
3785 */
3786 card->host_state = state;
3787
3788 if (state == UNIFI_HOST_STATE_TORPID)
3789 {
3790 /*
3791 * If the chip is now in state TORPID then we must now decrease
3792 * the maximum bus clock speed.
3793 */
3794 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
3795 UNIFI_SDIO_CLOCK_SAFE_HZ);
3796 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
3797 if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
3798 {
3799 unifi_warning(card->ospriv,
3800 "Failed to decrease the SDIO clock speed\n");
3801 }
3802 else
3803 {
3804 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
3805 }
3806 CsrSdioFunctionIdle(card->sdio_if);
3807 }
3808 }
3809
3810 return r;
3811} /* unifi_set_host_state() */
3812
3813
3814/*
3815 * ---------------------------------------------------------------------------
3816 * unifi_card_info
3817 *
3818 * Update the card information data structure
3819 *
3820 * Arguments:
3821 * card Pointer to card struct
3822 * card_info Pointer to info structure to update
3823 *
3824 * Returns:
3825 * None
3826 * ---------------------------------------------------------------------------
3827 */
3828void unifi_card_info(card_t *card, card_info_t *card_info)
3829{
3830 card_info->chip_id = card->chip_id;
3831 card_info->chip_version = card->chip_version;
3832 card_info->fw_build = card->build_id;
3833 card_info->fw_hip_version = card->config_data.version;
3834 card_info->sdio_block_size = card->sdio_io_block_size;
3835} /* unifi_card_info() */
3836
3837
3838/*
3839 * ---------------------------------------------------------------------------
3840 * unifi_check_io_status
3841 *
3842 * Check UniFi for spontaneous reset and pending interrupt.
3843 *
3844 * Arguments:
3845 * card Pointer to card struct
3846 * status Pointer to location to write chip status:
3847 * 0 if UniFi is running, and no interrupt pending
3848 * 1 if UniFi has spontaneously reset
3849 * 2 if there is a pending interrupt
3850 * Returns:
3851 * CSR_RESULT_SUCCESS if OK, or CSR error
3852 * ---------------------------------------------------------------------------
3853 */
3854CsrResult unifi_check_io_status(card_t *card, s32 *status)
3855{
3856 u8 io_en;
3857 CsrResult r;
3858 u8 pending;
3859
3860 *status = 0;
3861
3862 r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_en);
3863 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3864 {
3865 return r;
3866 }
3867 if (r != CSR_RESULT_SUCCESS)
3868 {
3869 unifi_error(card->ospriv, "Failed to read SDIO_IO_ENABLE to check for spontaneous reset\n");
3870 return r;
3871 }
3872
3873 if ((io_en & (1 << card->function)) == 0)
3874 {
3875 s32 fw_count;
3876 *status = 1;
3877 unifi_error(card->ospriv, "UniFi has spontaneously reset.\n");
3878
3879 /*
3880 * These reads are very likely to fail. We want to know if the function is really
3881 * disabled or the SDIO driver just returns rubbish.
3882 */
3883 fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
3884 if (fw_count < 0)
3885 {
3886 unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
3887 }
3888 else
3889 {
3890 unifi_error(card->ospriv, "thsw: %u (driver thinks is %u)\n",
3891 fw_count, card->to_host_signals_w);
3892 }
3893 fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
3894 if (fw_count < 0)
3895 {
3896 unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
3897 }
3898 else
3899 {
3900 unifi_error(card->ospriv, "fhsr: %u (driver thinks is %u)\n",
3901 fw_count, card->from_host_signals_r);
3902 }
3903
3904 return r;
3905 }
3906
3907 unifi_info(card->ospriv, "UniFi function %d is enabled.\n", card->function);
3908
3909 /* See if we missed an SDIO interrupt */
3910 r = CardPendingInt(card, &pending);
3911 if (pending)
3912 {
3913 unifi_error(card->ospriv, "There is an unhandled pending interrupt.\n");
3914 *status = 2;
3915 return r;
3916 }
3917
3918 return r;
3919} /* unifi_check_io_status() */
3920
3921
3922void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo)
3923{
3924 s32 count_fhr;
3925 s16 t;
3926 u32 occupied_fh;
3927
3928 q_t *sigq;
3929 u16 nslots, i;
3930
3931 memset(hipqosinfo, 0, sizeof(unifi_HipQosInfo));
3932
3933 nslots = card->config_data.num_fromhost_data_slots;
3934
3935 for (i = 0; i < nslots; i++)
3936 {
3937 if (card->from_host_data[i].bd.data_length == 0)
3938 {
3939 hipqosinfo->free_fh_bulkdata_slots++;
3940 }
3941 }
3942
3943 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
3944 {
3945 sigq = &card->fh_traffic_queue[i];
3946 t = sigq->q_wr_ptr - sigq->q_rd_ptr;
3947 if (t < 0)
3948 {
3949 t += sigq->q_length;
3950 }
3951 hipqosinfo->free_fh_sig_queue_slots[i] = (sigq->q_length - t) - 1;
3952 }
3953
3954 count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
3955 if (count_fhr < 0)
3956 {
3957 unifi_error(card->ospriv, "Failed to read from-host sig read count - %d\n", count_fhr);
3958 hipqosinfo->free_fh_fw_slots = 0xfa;
3959 return;
3960 }
3961
3962 occupied_fh = (card->from_host_signals_w - count_fhr) % 128;
3963
3964 hipqosinfo->free_fh_fw_slots = (u16)(card->config_data.num_fromhost_sig_frags - occupied_fh);
3965}
3966
3967
3968
3969CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult)
3970{
3971 CsrResult r = CSR_RESULT_FAILURE;
3972
3973 switch (csrResult)
3974 {
3975 case CSR_RESULT_SUCCESS:
3976 r = CSR_RESULT_SUCCESS;
3977 break;
3978 /* Timeout errors */
3979 case CSR_SDIO_RESULT_TIMEOUT:
3980 /* Integrity errors */
3981 case CSR_SDIO_RESULT_CRC_ERROR:
3982 r = CSR_RESULT_FAILURE;
3983 break;
3984 case CSR_SDIO_RESULT_NO_DEVICE:
3985 r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
3986 break;
3987 case CSR_SDIO_RESULT_INVALID_VALUE:
3988 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
3989 break;
3990 case CSR_RESULT_FAILURE:
3991 r = CSR_RESULT_FAILURE;
3992 break;
3993 default:
3994 unifi_warning(card->ospriv, "Unrecognised csrResult error code: %d\n", csrResult);
3995 break;
3996 }
3997
3998 return r;
3999} /* ConvertCsrSdioToCsrHipResult() */
4000
4001
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
index a9b9ec427320..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_card_sdio.h
+++ /dev/null
@@ -1,694 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 *
14 * FILE: csr_wifi_hip_card_sdio.h
15 *
16 * PURPOSE:
17 * Internal header for Card API for SDIO.
18 * ---------------------------------------------------------------------------
19 */
20#ifndef __CARD_SDIO_H__
21#define __CARD_SDIO_H__
22
23#include "csr_wifi_hip_unifi.h"
24#include "csr_wifi_hip_unifi_udi.h"
25#include "csr_wifi_hip_unifihw.h"
26#include "csr_wifi_hip_unifiversion.h"
27#ifndef CSR_WIFI_HIP_TA_DISABLE
28#include "csr_wifi_hip_ta_sampling.h"
29#endif
30#include "csr_wifi_hip_xbv.h"
31#include "csr_wifi_hip_chiphelper.h"
32
33
34/*
35 *
36 * Configuration items.
37 * Which of these should go in a platform unifi_config.h file?
38 *
39 */
40
41/*
42 * When the traffic queues contain more signals than there is space for on
43 * UniFi, a limiting algorithm comes into play.
44 * If a traffic queue has enough slots free to buffer more traffic from the
45 * network stack, then the following check is applied. The number of free
46 * slots is RESUME_XMIT_THRESHOLD.
47 */
48#define RESUME_XMIT_THRESHOLD 4
49
50
51/*
52 * When reading signals from UniFi, the host processes pending all signals
53 * and then acknowledges them together in a single write to update the
54 * to-host-chunks-read location.
55 * When there is more than one bulk data transfer (e.g. one received data
56 * packet and a request for the payload data of a transmitted packet), the
57 * update can be delayed significantly. This ties up resources on chip.
58 *
59 * To remedy this problem, to-host-chunks-read is updated after processing
60 * a signal if TO_HOST_FLUSH_THRESHOLD bytes of bulk data have been
61 * transferred since the last update.
62 */
63#define TO_HOST_FLUSH_THRESHOLD (500 * 5)
64
65
66/* SDIO Card Common Control Registers */
67#define SDIO_CCCR_SDIO_REVISION (0x00)
68#define SDIO_SD_SPEC_REVISION (0x01)
69#define SDIO_IO_ENABLE (0x02)
70#define SDIO_IO_READY (0x03)
71#define SDIO_INT_ENABLE (0x04)
72#define SDIO_INT_PENDING (0x05)
73#define SDIO_IO_ABORT (0x06)
74#define SDIO_BUS_IFACE_CONTROL (0x07)
75#define SDIO_CARD_CAPABILOTY (0x08)
76#define SDIO_COMMON_CIS_POINTER (0x09)
77#define SDIO_BUS_SUSPEND (0x0C)
78#define SDIO_FUNCTION_SELECT (0x0D)
79#define SDIO_EXEC_FLAGS (0x0E)
80#define SDIO_READY_FLAGS (0x0F)
81#define SDIO_FN0_BLOCK_SIZE (0x10)
82#define SDIO_POWER_CONTROL (0x12)
83#define SDIO_VENDOR_START (0xF0)
84
85#define SDIO_CSR_HOST_WAKEUP (0xf0)
86#define SDIO_CSR_HOST_INT_CLEAR (0xf1)
87#define SDIO_CSR_FROM_HOST_SCRATCH0 (0xf2)
88#define SDIO_CSR_FROM_HOST_SCRATCH1 (0xf3)
89#define SDIO_CSR_TO_HOST_SCRATCH0 (0xf4)
90#define SDIO_CSR_TO_HOST_SCRATCH1 (0xf5)
91#define SDIO_CSR_FUNC_EN (0xf6)
92#define SDIO_CSR_CSPI_MODE (0xf7)
93#define SDIO_CSR_CSPI_STATUS (0xf8)
94#define SDIO_CSR_CSPI_PADDING (0xf9)
95
96
97#define UNIFI_SD_INT_ENABLE_IENM 0x0001 /* Master INT Enable */
98
99#ifdef CSR_PRE_ALLOC_NET_DATA
100#define BULK_DATA_PRE_ALLOC_NUM 16
101#endif
102
103/*
104 * Structure to hold configuration information read from UniFi.
105 */
106typedef struct
107{
108 /*
109 * The version of the SDIO signal queues and bulk data pools
110 * configuration structure. The MSB is the major version number, used to
111 * indicate incompatible changes. The LSB gives the minor revision number,
112 * used to indicate changes that maintain backwards compatibility.
113 */
114 u16 version;
115
116 /*
117 * offset from the start of the shared data memory to the SD IO
118 * control structure.
119 */
120 u16 sdio_ctrl_offset;
121
122 /* Buffer handle of the from-host signal queue */
123 u16 fromhost_sigbuf_handle;
124
125 /* Buffer handle of the to-host signal queue */
126 u16 tohost_sigbuf_handle;
127
128 /*
129 * Maximum number of signal primitive or bulk data command fragments that may be
130 * pending in the to-hw signal queue.
131 */
132 u16 num_fromhost_sig_frags;
133
134 /*
135 * Number of signal primitive or bulk data command fragments that must be pending
136 * in the to-host signal queue before the host will generate an interrupt
137 * to indicate that it has read a signal. This will usually be the total
138 * capacity of the to-host signal buffer less the size of the largest signal
139 * primitive divided by the signal primitive fragment size, but may be set
140 * to 1 to request interrupts every time that the host read a signal.
141 * Note that the hw may place more signals in the to-host signal queue
142 * than indicated by this field.
143 */
144 u16 num_tohost_sig_frags;
145
146 /*
147 * Number of to-hw bulk data slots. Slots are numbered from 0 (zero) to
148 * one less than the value in this field
149 */
150 u16 num_fromhost_data_slots;
151
152 /*
153 * Number of frm-hw bulk data slots. Slots are numbered from 0 (zero) to
154 * one less than the value in this field
155 */
156 u16 num_tohost_data_slots;
157
158 /*
159 * Size of the bulk data slots (2 octets)
160 * The size of the bulk data slots in octets. This will usually be
161 * the size of the largest MSDU. The value should always be even.
162 */
163 u16 data_slot_size;
164
165 /*
166 * Indicates that the host has finished the initialisation sequence.
167 * Initialised to 0x0000 by the firmware, and set to 0x0001 by us.
168 */
169 u16 initialised;
170
171 /* Added by protocol version 0x0001 */
172 u32 overlay_size;
173
174 /* Added by protocol version 0x0300 */
175 u16 data_slot_round;
176 u16 sig_frag_size;
177
178 /* Added by protocol version 0x0500 */
179 u16 tohost_signal_padding;
180} sdio_config_data_t;
181
182/*
183 * These values may change with versions of the Host Interface Protocol.
184 */
185/*
186 * Size of config info block pointed to by the CSR_SLT_SDIO_SLOT_CONFIG
187 * entry in the f/w symbol table
188 */
189#define SDIO_CONFIG_DATA_SIZE 30
190
191/* Offset of the INIT flag in the config info block. */
192#define SDIO_INIT_FLAG_OFFSET 0x12
193#define SDIO_TO_HOST_SIG_PADDING_OFFSET 0x1C
194
195
196/* Structure for a bulk data transfer command */
197typedef struct
198{
199 u16 cmd_and_len; /* bits 12-15 cmd, bits 0-11 len */
200 u16 data_slot; /* slot number, perhaps OR'd with SLOT_DIR_TO_HOST */
201 u16 offset;
202 u16 buffer_handle;
203} bulk_data_cmd_t;
204
205
206/* Bulk Data signal command values */
207#define SDIO_CMD_SIGNAL 0x00
208#define SDIO_CMD_TO_HOST_TRANSFER 0x01
209#define SDIO_CMD_TO_HOST_TRANSFER_ACK 0x02 /*deprecated*/
210#define SDIO_CMD_FROM_HOST_TRANSFER 0x03
211#define SDIO_CMD_FROM_HOST_TRANSFER_ACK 0x04 /*deprecated*/
212#define SDIO_CMD_CLEAR_SLOT 0x05
213#define SDIO_CMD_OVERLAY_TRANSFER 0x06
214#define SDIO_CMD_OVERLAY_TRANSFER_ACK 0x07 /*deprecated*/
215#define SDIO_CMD_FROM_HOST_AND_CLEAR 0x08
216#define SDIO_CMD_PADDING 0x0f
217
218#define SLOT_DIR_TO_HOST 0x8000
219
220
221/* Initialise bulkdata slot
222 * params:
223 * bulk_data_desc_t *bulk_data_slot
224 */
225#define UNIFI_INIT_BULK_DATA(bulk_data_slot) \
226 { \
227 (bulk_data_slot)->os_data_ptr = NULL; \
228 (bulk_data_slot)->data_length = 0; \
229 (bulk_data_slot)->os_net_buf_ptr = NULL; \
230 (bulk_data_slot)->net_buf_length = 0; \
231 }
232
233/*
234 * Structure to contain a SIGNAL datagram.
235 * This is used to build signal queues between the main driver and the
236 * i/o thread.
237 * The fields are:
238 * sigbuf Contains the HIP signal is wire-format (i.e. packed,
239 * little-endian)
240 * bulkdata Contains a copy of any associated bulk data
241 * signal_length The size of the signal in the sigbuf
242 */
243typedef struct card_signal
244{
245 u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
246
247 /* Length of the SIGNAL inside sigbuf */
248 u16 signal_length;
249
250 bulk_data_desc_t bulkdata[UNIFI_MAX_DATA_REFERENCES];
251} card_signal_t;
252
253
254/*
255 * Control structure for a generic ring buffer.
256 */
257#define UNIFI_QUEUE_NAME_MAX_LENGTH 16
258typedef struct
259{
260 card_signal_t *q_body;
261
262 /* Num elements in queue (capacity is one less than this!) */
263 u16 q_length;
264
265 u16 q_wr_ptr;
266 u16 q_rd_ptr;
267
268 char name[UNIFI_QUEUE_NAME_MAX_LENGTH];
269} q_t;
270
271
272#define UNIFI_RESERVED_COMMAND_SLOTS 2
273
274/* Considering approx 500 us per packet giving 0.5 secs */
275#define UNIFI_PACKETS_INTERVAL 1000
276
277/*
278 * Dynamic slot reservation for QoS
279 */
280typedef struct
281{
282 u16 from_host_used_slots[UNIFI_NO_OF_TX_QS];
283 u16 from_host_max_slots[UNIFI_NO_OF_TX_QS];
284 u16 from_host_reserved_slots[UNIFI_NO_OF_TX_QS];
285
286 /* Parameters to determine if a queue was active.
287 If number of packets sent is greater than the threshold
288 for the queue, the queue is considered active and no
289 re reservation is done, it is important not to keep this
290 value too low */
291 /* Packets sent during this interval */
292 u16 packets_txed[UNIFI_NO_OF_TX_QS];
293 u16 total_packets_txed;
294
295 /* Number of packets to see if slots need to be reassigned */
296 u16 packets_interval;
297
298 /* Once a queue reaches a stable state, avoid processing */
299 u8 queue_stable[UNIFI_NO_OF_TX_QS];
300} card_dynamic_slot_t;
301
302
303/* These are type-safe and don't write incorrect values to the
304 * structure. */
305
306/* Return queue slots used count
307 * params:
308 * const q_t *q
309 * returns:
310 * u16
311 */
312#define CSR_WIFI_HIP_Q_SLOTS_USED(q) \
313 (((q)->q_wr_ptr - (q)->q_rd_ptr < 0)? \
314 ((q)->q_wr_ptr - (q)->q_rd_ptr + (q)->q_length) : ((q)->q_wr_ptr - (q)->q_rd_ptr))
315
316/* Return queue slots free count
317 * params:
318 * const q_t *q
319 * returns:
320 * u16
321 */
322#define CSR_WIFI_HIP_Q_SLOTS_FREE(q) \
323 ((q)->q_length - CSR_WIFI_HIP_Q_SLOTS_USED((q)) - 1)
324
325/* Return slot signal data pointer
326 * params:
327 * const q_t *q
328 * u16 slot
329 * returns:
330 * card_signal_t *
331 */
332#define CSR_WIFI_HIP_Q_SLOT_DATA(q, slot) \
333 ((q)->q_body + slot)
334
335/* Return queue next read slot
336 * params:
337 * const q_t *q
338 * returns:
339 * u16 slot offset
340 */
341#define CSR_WIFI_HIP_Q_NEXT_R_SLOT(q) \
342 ((q)->q_rd_ptr)
343
344/* Return queue next write slot
345 * params:
346 * const q_t *q
347 * returns:
348 * u16 slot offset
349 */
350#define CSR_WIFI_HIP_Q_NEXT_W_SLOT(q) \
351 ((q)->q_wr_ptr)
352
353/* Return updated queue pointer wrapped around its length
354 * params:
355 * const q_t *q
356 * u16 x amount to add to queue pointer
357 * returns:
358 * u16 wrapped queue pointer
359 */
360#define CSR_WIFI_HIP_Q_WRAP(q, x) \
361 ((((x) >= (q)->q_length)?((x) % (q)->q_length) : (x)))
362
363/* Advance queue read pointer
364 * params:
365 * const q_t *q
366 */
367#define CSR_WIFI_HIP_Q_INC_R(q) \
368 ((q)->q_rd_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_rd_ptr + 1))
369
370/* Advance queue write pointer
371 * params:
372 * const q_t *q
373 */
374#define CSR_WIFI_HIP_Q_INC_W(q) \
375 ((q)->q_wr_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_wr_ptr + 1))
376
377enum unifi_host_state
378{
379 UNIFI_HOST_STATE_AWAKE = 0,
380 UNIFI_HOST_STATE_DROWSY = 1,
381 UNIFI_HOST_STATE_TORPID = 2
382};
383
384typedef struct
385{
386 bulk_data_desc_t bd;
387 unifi_TrafficQueue queue; /* Used for dynamic slot reservation */
388} slot_desc_t;
389
390/*
391 * Structure describing a UniFi SDIO card.
392 */
393struct card
394{
395 /*
396 * Back pointer for the higher level OS code. This is passed as
397 * an argument to callbacks (e.g. for received data and indications).
398 */
399 void *ospriv;
400
401 /*
402 * mapping of HIP slot to MA-PACKET.req host tag, the
403 * array is indexed by slot numbers and each index stores
404 * information of the last host tag it was used for
405 */
406 u32 *fh_slot_host_tag_record;
407
408
409 /* Info read from Symbol Table during probe */
410 u32 build_id;
411 char build_id_string[128];
412
413 /* Retrieve from SDIO driver. */
414 u16 chip_id;
415
416 /* Read from GBL_CHIP_VERSION. */
417 u16 chip_version;
418
419 /* From the SDIO driver (probably 1) */
420 u8 function;
421
422 /* This is sused to get the register addresses and things. */
423 ChipDescript *helper;
424
425 /*
426 * Bit mask of PIOs for the loader to waggle during download.
427 * We assume these are connected to LEDs. The main firmware gets
428 * the mask from a MIB entry.
429 */
430 s32 loader_led_mask;
431
432 /*
433 * Support for flow control. When the from-host queue of signals
434 * is full, we ask the host upper layer to stop sending packets. When
435 * the queue drains we tell it that it can send packets again.
436 * We use this flag to remember the current state.
437 */
438#define card_is_tx_q_paused(card, q) (card->tx_q_paused_flag[q])
439#define card_tx_q_unpause(card, q) (card->tx_q_paused_flag[q] = 0)
440#define card_tx_q_pause(card, q) (card->tx_q_paused_flag[q] = 1)
441
442 u16 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX + 1 + UNIFI_NO_OF_TX_QS]; /* defensive more than big enough */
443
444 /* UDI callback for logging UniFi interactions */
445 udi_func_t udi_hook;
446
447 u8 bh_reason_host;
448 u8 bh_reason_unifi;
449
450 /* SDIO clock speed request from OS layer */
451 u8 request_max_clock;
452
453 /* Last SDIO clock frequency set */
454 u32 sdio_clock_speed;
455
456 /*
457 * Current host state (copy of value in IOABORT register and
458 * spinlock to protect it.
459 */
460 enum unifi_host_state host_state;
461
462 enum unifi_low_power_mode low_power_mode;
463 enum unifi_periodic_wake_mode periodic_wake_mode;
464
465 /*
466 * Ring buffer of signal structs for a queue of data packets from
467 * the host.
468 * The queue is empty when fh_data_q_num_rd == fh_data_q_num_wr.
469 * To add a packet to the queue, copy it to index given by
470 * (fh_data_q_num_wr%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_wr.
471 * To take a packet from the queue, copy data from index given by
472 * (fh_data_q_num_rd%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_rd.
473 * fh_data_q_num_rd and fh_data_q_num_rd are both modulo 256.
474 */
475 card_signal_t fh_command_q_body[UNIFI_SOFT_COMMAND_Q_LENGTH];
476 q_t fh_command_queue;
477
478 card_signal_t fh_traffic_q_body[UNIFI_NO_OF_TX_QS][UNIFI_SOFT_TRAFFIC_Q_LENGTH];
479 q_t fh_traffic_queue[UNIFI_NO_OF_TX_QS];
480
481 /*
482 * Signal counts from UniFi SDIO Control Data Structure.
483 * These are cached and synchronised with the UniFi before and after
484 * a batch of operations.
485 *
486 * These are the modulo-256 count of signals written to or read from UniFi
487 * The value is incremented for every signal.
488 */
489 s32 from_host_signals_w;
490 s32 from_host_signals_r;
491 s32 to_host_signals_r;
492 s32 to_host_signals_w;
493
494
495 /* Should specify buffer size as a number of signals */
496 /*
497 * Enough for 10 th and 10 fh data slots:
498 * 1 * 10 * 8 = 80
499 * 2 * 10 * 8 = 160
500 */
501#define UNIFI_FH_BUF_SIZE 1024
502 struct sigbuf
503 {
504 u8 *buf; /* buffer area */
505 u8 *ptr; /* current pos */
506 u16 count; /* signal count */
507 u16 bufsize;
508 } fh_buffer;
509 struct sigbuf th_buffer;
510
511
512 /*
513 * Field to use for the incrementing value to write to the UniFi
514 * SHARED_IO_INTERRUPT register.
515 * Flag to say we need to generate an interrupt at end of processing.
516 */
517 u32 unifi_interrupt_seq;
518 u8 generate_interrupt;
519
520
521 /* Pointers to the bulk data slots */
522 slot_desc_t *from_host_data;
523 bulk_data_desc_t *to_host_data;
524
525
526 /*
527 * Index of the next (hopefully) free data slot.
528 * This is an optimisation that starts searching at a more likely point
529 * than the beginning.
530 */
531 s16 from_host_data_head;
532
533 /* Dynamic slot allocation for queues */
534 card_dynamic_slot_t dynamic_slot_data;
535
536 /*
537 * SDIO specific fields
538 */
539
540 /* Interface pointer for the SDIO library */
541 CsrSdioFunction *sdio_if;
542
543 /* Copy of config_data struct from the card */
544 sdio_config_data_t config_data;
545
546 /* SDIO address of the Initialised flag and Control Data struct */
547 u32 init_flag_addr;
548 u32 sdio_ctrl_addr;
549
550 /* The last value written to the Shared Data Memory Page register */
551 u32 proc_select;
552 u32 dmem_page;
553 u32 pmem_page;
554
555 /* SDIO traffic counters limited to 32 bits for Synergy compatibility */
556 u32 sdio_bytes_read;
557 u32 sdio_bytes_written;
558
559 u8 memory_resources_allocated;
560
561 /* UniFi SDIO I/O Block size. */
562 u16 sdio_io_block_size;
563
564 /* Pad transfer sizes to SDIO block boundaries */
565 u8 sdio_io_block_pad;
566
567 /* Read from the XBV */
568 struct FWOV fwov;
569
570#ifndef CSR_WIFI_HIP_TA_DISABLE
571 /* TA sampling */
572 ta_data_t ta_sampling;
573#endif
574
575 /* Auto-coredump */
576 s16 request_coredump_on_reset; /* request coredump on next reset */
577 struct coredump_buf *dump_buf; /* root node */
578 struct coredump_buf *dump_next_write; /* node to fill at next dump */
579 struct coredump_buf *dump_cur_read; /* valid node to read, or NULL */
580
581#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
582 struct cmd_profile
583 {
584 u32 cmd52_count;
585 u32 cmd53_count;
586 u32 tx_count;
587 u32 tx_cfm_count;
588 u32 rx_count;
589 u32 bh_count;
590 u32 process_count;
591 u32 protocol_count;
592
593 u32 cmd52_f0_r_count;
594 u32 cmd52_f0_w_count;
595 u32 cmd52_r8or16_count;
596 u32 cmd52_w8or16_count;
597 u32 cmd52_r16_count;
598 u32 cmd52_w16_count;
599 u32 cmd52_r32_count;
600
601 u32 sdio_cmd_signal;
602 u32 sdio_cmd_clear_slot;
603 u32 sdio_cmd_to_host;
604 u32 sdio_cmd_from_host;
605 u32 sdio_cmd_from_host_and_clear;
606 } hip_prof;
607 struct cmd_profile cmd_prof;
608#endif
609
610 /* Interrupt processing mode flags */
611 u32 intmode;
612
613#ifdef UNIFI_DEBUG
614 u8 lsb;
615#endif
616
617 /* Historic firmware panic codes */
618 u32 panic_data_phy_addr;
619 u32 panic_data_mac_addr;
620 u16 last_phy_panic_code;
621 u16 last_phy_panic_arg;
622 u16 last_mac_panic_code;
623 u16 last_mac_panic_arg;
624#ifdef CSR_PRE_ALLOC_NET_DATA
625 bulk_data_desc_t bulk_data_desc_list[BULK_DATA_PRE_ALLOC_NUM];
626 u16 prealloc_netdata_r;
627 u16 prealloc_netdata_w;
628#endif
629}; /* struct card */
630
631
632/* Reset types */
633enum unifi_reset_type
634{
635 UNIFI_COLD_RESET = 1,
636 UNIFI_WARM_RESET = 2
637};
638
639/*
640 * unifi_set_host_state() implements signalling for waking UniFi from
641 * deep sleep. The host indicates to UniFi that it is in one of three states:
642 * Torpid - host has nothing to send, UniFi can go to sleep.
643 * Drowsy - host has data to send to UniFi. UniFi will respond with an
644 * SDIO interrupt. When hosts responds it moves to Awake.
645 * Awake - host has data to transfer, UniFi must stay awake.
646 * When host has finished, it moves to Torpid.
647 */
648CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state);
649
650
651CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select);
652s32 card_read_signal_counts(card_t *card);
653bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot);
654
655
656CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata);
657CsrResult unifi_readnz(card_t *card, u32 unifi_addr,
658 void *pdata, u16 len);
659s32 unifi_read_shared_count(card_t *card, u32 addr);
660
661CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len);
662
663CsrResult unifi_bulk_rw(card_t *card, u32 handle,
664 void *pdata, u32 len, s16 direction);
665CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle,
666 void *pdata, u32 len, s16 direction);
667#define UNIFI_SDIO_READ 0
668#define UNIFI_SDIO_WRITE 1
669
670CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata);
671CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data);
672CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata);
673CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data);
674
675CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata);
676CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata);
677CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len);
678
679CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data);
680CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len);
681
682CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata);
683CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data);
684
685void unifi_read_panic(card_t *card);
686#ifdef CSR_PRE_ALLOC_NET_DATA
687void prealloc_netdata_free(card_t *card);
688CsrResult prealloc_netdata_alloc(card_t *card);
689#endif
690/* For diagnostic use */
691void dump(void *mem, u16 len);
692void dump16(void *mem, u16 len);
693
694#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
index cfe186e07071..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c
+++ /dev/null
@@ -1,2595 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_card_sdio_intr.c
14 *
15 * PURPOSE:
16 * Interrupt processing for the UniFi SDIO driver.
17 *
18 * We may need another signal queue of responses to UniFi to hold
19 * bulk data commands generated by read_to_host_signals().
20 *
21 * ---------------------------------------------------------------------------
22 */
23#undef CSR_WIFI_HIP_NOISY
24
25#include "csr_wifi_hip_unifi.h"
26#include "csr_wifi_hip_conversions.h"
27#include "csr_wifi_hip_card.h"
28#include "csr_wifi_hip_xbv.h"
29
30
31/*
32 * If the SDIO link is idle for this time (in milliseconds),
33 * signal UniFi to go into Deep Sleep.
34 * Valid return value of unifi_bh().
35 */
36#define UNIFI_DEFAULT_HOST_IDLE_TIMEOUT 5
37/*
38 * If the UniFi has not woken up for this time (in milliseconds),
39 * signal the bottom half to take action.
40 * Valid return value of unifi_bh().
41 */
42#define UNIFI_DEFAULT_WAKE_TIMEOUT 1000
43
44
45static CsrResult process_bh(card_t *card);
46static CsrResult handle_host_protocol(card_t *card, u8 *processed_something);
47
48static CsrResult flush_fh_buffer(card_t *card);
49
50static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space);
51
52static CsrResult read_to_host_signals(card_t *card, s32 *processed);
53static CsrResult process_to_host_signals(card_t *card, s32 *processed);
54
55static CsrResult process_bulk_data_command(card_t *card,
56 const u8 *cmdptr,
57 s16 cmd, u16 len);
58static CsrResult process_clear_slot_command(card_t *card,
59 const u8 *cmdptr);
60static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed);
61static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed);
62static void restart_packet_flow(card_t *card);
63static CsrResult process_clock_request(card_t *card);
64
65#ifdef CSR_WIFI_HIP_NOISY
66s16 dump_fh_buf = 0;
67#endif /* CSR_WIFI_HIP_NOISY */
68
69#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
70
71/*
72 * The unifi_debug_output buffer can be used to debug the HIP behaviour offline
73 * i.e. without using the tracing functions that change the timing.
74 *
75 * Call unifi_debug_log_to_buf() with printf arguments to store a string into
76 * unifi_debug_output. When unifi_debug_buf_dump() is called, the contents of the
77 * buffer are dumped with dump_str() which has to be implemented in the
78 * OS layer, during the porting exercise. The offset printed, holds the
79 * offset where the last character is (always a zero).
80 *
81 */
82
83#define UNIFI_DEBUG_GBUFFER_SIZE 8192
84static char unifi_debug_output[UNIFI_DEBUG_GBUFFER_SIZE];
85static char *unifi_dbgbuf_ptr = unifi_debug_output;
86static char *unifi_dbgbuf_start = unifi_debug_output;
87
88static void append_char(char c)
89{
90 /* write char and advance pointer */
91 *unifi_dbgbuf_ptr++ = c;
92 /* wrap pointer at end of buffer */
93 if ((unifi_dbgbuf_ptr - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
94 {
95 unifi_dbgbuf_ptr = unifi_debug_output;
96 }
97} /* append_char() */
98
99
100void unifi_debug_string_to_buf(const char *str)
101{
102 const char *p = str;
103 while (*p)
104 {
105 append_char(*p);
106 p++;
107 }
108 /* Update start-of-buffer pointer */
109 unifi_dbgbuf_start = unifi_dbgbuf_ptr + 1;
110 if ((unifi_dbgbuf_start - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
111 {
112 unifi_dbgbuf_start = unifi_debug_output;
113 }
114}
115
116
117void unifi_debug_log_to_buf(const char *fmt, ...)
118{
119#define DEBUG_BUFFER_SIZE 80
120 static char s[DEBUG_BUFFER_SIZE];
121 va_list args;
122
123 va_start(args, fmt);
124 vsnprintf(s, DEBUG_BUFFER_SIZE, fmt, args);
125 va_end(args);
126
127 unifi_debug_string_to_buf(s);
128} /* unifi_debug_log_to_buf() */
129
130
131/* Convert signed 32 bit (or less) integer to string */
132static void CsrUInt16ToHex(u16 number, char *str)
133{
134 u16 index;
135 u16 currentValue;
136
137 for (index = 0; index < 4; index++)
138 {
139 currentValue = (u16) (number & 0x000F);
140 number >>= 4;
141 str[3 - index] = (char) (currentValue > 9 ? currentValue + 55 : currentValue + '0');
142 }
143 str[4] = '\0';
144}
145
146
147/*
148 * ---------------------------------------------------------------------------
149 * unifi_debug_hex_to_buf
150 *
151 * puts the contents of the passed buffer into the debug buffer as a hex string
152 *
153 * Arguments:
154 * buff buffer to print as hex
155 * length number of chars to print
156 *
157 * Returns:
158 * None.
159 *
160 * ---------------------------------------------------------------------------
161 */
162void unifi_debug_hex_to_buf(const char *buff, u16 length)
163{
164 char s[5];
165 u16 i;
166
167 for (i = 0; i < length; i = i + 2)
168 {
169 CsrUInt16ToHex(*((u16 *)(buff + i)), s);
170 unifi_debug_string_to_buf(s);
171 }
172}
173
174
175void unifi_debug_buf_dump(void)
176{
177 s32 offset = unifi_dbgbuf_ptr - unifi_debug_output;
178
179 unifi_error(NULL, "HIP debug buffer offset=%d\n", offset);
180 dump_str(unifi_debug_output + offset, UNIFI_DEBUG_GBUFFER_SIZE - offset);
181 dump_str(unifi_debug_output, offset);
182} /* unifi_debug_buf_dump() */
183
184
185#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
186
187#ifdef CSR_PRE_ALLOC_NET_DATA
188#define NETDATA_PRE_ALLOC_BUF_SIZE 8000
189
190void prealloc_netdata_free(card_t *card)
191{
192 unifi_warning(card->ospriv, "prealloc_netdata_free: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
193
194 while (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length != 0)
195 {
196 unifi_warning(card->ospriv, "prealloc_netdata_free: r=%d\n", card->prealloc_netdata_r);
197
198 unifi_net_data_free(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_r]);
199 card->prealloc_netdata_r++;
200 card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
201 }
202 card->prealloc_netdata_r = card->prealloc_netdata_w = 0;
203
204 unifi_warning(card->ospriv, "prealloc_netdata_free: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
205}
206
207
208CsrResult prealloc_netdata_alloc(card_t *card)
209{
210 CsrResult r;
211
212 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
213
214 while (card->bulk_data_desc_list[card->prealloc_netdata_w].data_length == 0)
215 {
216 r = unifi_net_data_malloc(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_w], NETDATA_PRE_ALLOC_BUF_SIZE);
217 if (r != CSR_RESULT_SUCCESS)
218 {
219 unifi_error(card->ospriv, "prealloc_netdata_alloc: Failed to allocate t-h bulk data\n");
220 return CSR_RESULT_FAILURE;
221 }
222 card->prealloc_netdata_w++;
223 card->prealloc_netdata_w %= BULK_DATA_PRE_ALLOC_NUM;
224 }
225 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
226
227 return CSR_RESULT_SUCCESS;
228}
229
230
231static CsrResult prealloc_netdata_get(card_t *card, bulk_data_desc_t *bulk_data_slot, u32 size)
232{
233 CsrResult r;
234
235 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
236
237 if (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0)
238 {
239 unifi_error(card->ospriv, "prealloc_netdata_get: data_length = 0\n");
240 }
241
242 if ((size > NETDATA_PRE_ALLOC_BUF_SIZE) || (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0))
243 {
244 unifi_warning(card->ospriv, "prealloc_netdata_get: Calling net_data_malloc\n");
245
246 r = unifi_net_data_malloc(card->ospriv, bulk_data_slot, size);
247 if (r != CSR_RESULT_SUCCESS)
248 {
249 unifi_error(card->ospriv, "prealloc_netdata_get: Failed to allocate t-h bulk data\n");
250 return CSR_RESULT_FAILURE;
251 }
252 return CSR_RESULT_SUCCESS;
253 }
254
255 *bulk_data_slot = card->bulk_data_desc_list[card->prealloc_netdata_r];
256 card->bulk_data_desc_list[card->prealloc_netdata_r].os_data_ptr = NULL;
257 card->bulk_data_desc_list[card->prealloc_netdata_r].os_net_buf_ptr = NULL;
258 card->bulk_data_desc_list[card->prealloc_netdata_r].net_buf_length = 0;
259 card->bulk_data_desc_list[card->prealloc_netdata_r].data_length = 0;
260
261 card->prealloc_netdata_r++;
262 card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
263
264 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
265
266 return CSR_RESULT_SUCCESS;
267}
268
269
270#endif
271
272/*
273 * ---------------------------------------------------------------------------
274 * unifi_sdio_interrupt_handler
275 *
276 * This function should be called by the OS-dependent code to handle
277 * an SDIO interrupt from the UniFi.
278 *
279 * Arguments:
280 * card Pointer to card context structure.
281 *
282 * Returns:
283 * None.
284 *
285 * Notes: This function may be called in DRS context. In this case,
286 * tracing with the unifi_trace(), etc, is not allowed.
287 * ---------------------------------------------------------------------------
288 */
289void unifi_sdio_interrupt_handler(card_t *card)
290{
291 /*
292 * Set the flag to say reason for waking was SDIO interrupt.
293 * Then ask the OS layer to run the unifi_bh to give attention to the UniFi.
294 */
295 card->bh_reason_unifi = 1;
296 (void)unifi_run_bh(card->ospriv);
297} /* sdio_interrupt_handler() */
298
299
300/*
301 * ---------------------------------------------------------------------------
302 * unifi_configure_low_power_mode
303 *
304 * This function should be called by the OS-dependent when
305 * the deep sleep signaling needs to be enabled or disabled.
306 *
307 * Arguments:
308 * card Pointer to card context structure.
309 * low_power_mode Disable/Enable the deep sleep signaling
310 * periodic_wake_mode UniFi wakes host periodically.
311 *
312 * Returns:
313 * CSR_RESULT_SUCCESS on success or a CSR error code.
314 * ---------------------------------------------------------------------------
315 */
316CsrResult unifi_configure_low_power_mode(card_t *card,
317 enum unifi_low_power_mode low_power_mode,
318 enum unifi_periodic_wake_mode periodic_wake_mode)
319{
320 card->low_power_mode = low_power_mode;
321 card->periodic_wake_mode = periodic_wake_mode;
322
323 unifi_trace(card->ospriv, UDBG1,
324 "unifi_configure_low_power_mode: new mode = %s, wake_host = %s\n",
325 (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled",
326 (periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_DISABLED)?"FALSE" : "TRUE");
327
328 (void)unifi_run_bh(card->ospriv);
329 return CSR_RESULT_SUCCESS;
330} /* unifi_configure_low_power_mode() */
331
332
333/*
334 * ---------------------------------------------------------------------------
335 * unifi_force_low_power_mode
336 *
337 * This function should be called by the OS-dependent when
338 * UniFi needs to be set to the low power mode (e.g. on suspend)
339 *
340 * Arguments:
341 * card Pointer to card context structure.
342 *
343 * Returns:
344 * CSR_RESULT_SUCCESS on success or a CSR error code.
345 * ---------------------------------------------------------------------------
346 */
347CsrResult unifi_force_low_power_mode(card_t *card)
348{
349 if (card->low_power_mode == UNIFI_LOW_POWER_DISABLED)
350 {
351 unifi_error(card->ospriv, "Attempt to set mode to TORPID when lower power mode is disabled\n");
352 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
353 }
354
355 return unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
356} /* unifi_force_low_power_mode() */
357
358
359/*
360 * ---------------------------------------------------------------------------
361 * unifi_bh
362 *
363 * This function should be called by the OS-dependent code when
364 * host and/or UniFi has requested an exchange of messages.
365 *
366 * Arguments:
367 * card Pointer to card context structure.
368 *
369 * Returns:
370 * CSR_RESULT_SUCCESS on success or a CSR error code.
371 * ---------------------------------------------------------------------------
372 */
373CsrResult unifi_bh(card_t *card, u32 *remaining)
374{
375 CsrResult r;
376 CsrResult csrResult;
377 u8 pending;
378 s32 iostate, j;
379 const enum unifi_low_power_mode low_power_mode = card->low_power_mode;
380 u16 data_slots_used = 0;
381
382
383 /* Process request to raise the maximum SDIO clock */
384 r = process_clock_request(card);
385 if (r != CSR_RESULT_SUCCESS)
386 {
387 unifi_error(card->ospriv, "Error setting maximum SDIO clock\n");
388 goto exit;
389 }
390
391 /*
392 * Why was the BH thread woken?
393 * If it was an SDIO interrupt, UniFi is awake and we need to process it.
394 * If it was a host process queueing data, then we need to awaken UniFi.
395 *
396 * Priority of flags is top down.
397 *
398 * ----------------------------------------------------------+
399 * \state| AWAKE | DROWSY | TORPID |
400 * flag\ | | | |
401 * ---------+--------------+----------------+----------------|
402 * | do the host | go to AWAKE and| go to AWAKE and|
403 * unifi | protocol | do the host | do the host |
404 * | | protocol | protocol |
405 * ---------+--------------+----------------+----------------|
406 * | do the host | | |
407 * host | protocol | do nothing | go to DROWSY |
408 * | | | |
409 * ---------+--------------+----------------+----------------|
410 * | | | should not |
411 * timeout | go to TORPID | error, unifi | occur |
412 * | | didn't wake up | do nothing |
413 * ----------------------------------------------------------+
414 *
415 * Note that if we end up in the AWAKE state we always do the host protocol.
416 */
417
418 do
419 {
420 /*
421 * When the host state is set to DROWSY, then we can not disable the
422 * interrupts as UniFi can generate an interrupt even when the INT_ENABLE
423 * register has the interrupts disabled. This interrupt will be lost.
424 */
425 if (card->host_state == UNIFI_HOST_STATE_DROWSY || card->host_state == UNIFI_HOST_STATE_TORPID)
426 {
427 u8 reason_unifi;
428
429 /*
430 * An interrupt may occur while or after we cache the reason.
431 * This interrupt will cause the unifi_bh() to be scheduled again.
432 * Any interrupt that has happened before the register is read
433 * and is considered spurious has to acknowledged.
434 */
435 reason_unifi = card->bh_reason_unifi;
436
437 /*
438 * If an interrupt is received, check if it was a real one,
439 * set the host state to AWAKE and run the BH.
440 */
441 r = CardPendingInt(card, &pending);
442 if (r != CSR_RESULT_SUCCESS)
443 {
444 goto exit;
445 }
446
447 if (pending)
448 {
449 unifi_trace(card->ospriv, UDBG5,
450 "UNIFI_HOST_STATE_%s: Set state to AWAKE.\n",
451 (card->host_state == UNIFI_HOST_STATE_TORPID)?"TORPID" : "DROWSY");
452
453 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
454 if (r == CSR_RESULT_SUCCESS)
455 {
456 (*remaining) = 0;
457 break;
458 }
459 }
460 else if (reason_unifi)
461 {
462 CsrSdioInterruptAcknowledge(card->sdio_if);
463 }
464
465 /*
466 * If an chip is in TORPID, and the host wants to wake it up,
467 * set the host state to DROWSY and wait for the wake-up interrupt.
468 */
469 if ((card->host_state == UNIFI_HOST_STATE_TORPID) && card->bh_reason_host)
470 {
471 r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
472 if (r == CSR_RESULT_SUCCESS)
473 {
474 /*
475 * set the timeout value to UNIFI_DEFAULT_WAKE_TIMEOUT
476 * to capture a wake error.
477 */
478 card->bh_reason_host = 0;
479 (*remaining) = UNIFI_DEFAULT_WAKE_TIMEOUT;
480 return CSR_RESULT_SUCCESS;
481 }
482
483 goto exit;
484 }
485
486 /*
487 * If the chip is in DROWSY, and the timeout expires,
488 * we need to reset the chip. This should never occur.
489 * (If it does, check that the calling thread set "remaining"
490 * according to the time remaining when unifi_bh() was called).
491 */
492 if ((card->host_state == UNIFI_HOST_STATE_DROWSY) && ((*remaining) == 0))
493 {
494 unifi_error(card->ospriv, "UniFi did not wake up on time...\n");
495
496 /*
497 * Check if Function1 has gone away or
498 * if we missed an SDIO interrupt.
499 */
500 r = unifi_check_io_status(card, &iostate);
501 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
502 {
503 goto exit;
504 }
505 /* Need to reset and reboot */
506 return CSR_RESULT_FAILURE;
507 }
508 }
509 else
510 {
511 if (card->bh_reason_unifi || card->bh_reason_host)
512 {
513 break;
514 }
515
516 if (((*remaining) == 0) && (low_power_mode == UNIFI_LOW_POWER_ENABLED))
517 {
518 r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
519 if (r == CSR_RESULT_SUCCESS)
520 {
521 (*remaining) = 0;
522 return CSR_RESULT_SUCCESS;
523 }
524
525 goto exit;
526 }
527 }
528
529 /* No need to run the host protocol */
530 return CSR_RESULT_SUCCESS;
531 } while (0);
532
533
534 /* Disable the SDIO interrupts while doing SDIO ops */
535 csrResult = CsrSdioInterruptDisable(card->sdio_if);
536 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
537 {
538 r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
539 goto exit;
540 }
541 if (csrResult != CSR_RESULT_SUCCESS)
542 {
543 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
544 unifi_error(card->ospriv, "Failed to disable SDIO interrupts. unifi_bh queues error.\n");
545 goto exit;
546 }
547
548 /* Now that the interrupts are disabled, ack the interrupt */
549 CsrSdioInterruptAcknowledge(card->sdio_if);
550
551 /* Run the HIP */
552 r = process_bh(card);
553 if (r != CSR_RESULT_SUCCESS)
554 {
555 goto exit;
556 }
557
558 /*
559 * If host is now idle, schedule a timer for the delay before we
560 * let UniFi go into deep sleep.
561 * If the timer goes off, we will move to TORPID state.
562 * If UniFi raises an interrupt in the meantime, we will cancel
563 * the timer and start a new one when we become idle.
564 */
565 for (j = 0; j < UNIFI_NO_OF_TX_QS; j++)
566 {
567 data_slots_used += CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[j]);
568 }
569
570 if ((low_power_mode == UNIFI_LOW_POWER_ENABLED) && (data_slots_used == 0))
571 {
572#ifndef CSR_WIFI_HIP_TA_DISABLE
573 if (card->ta_sampling.traffic_type != CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC)
574 {
575#endif
576 /* return the UNIFI_DEFAULT_HOST_IDLE_TIMEOUT, so we can go to sleep. */
577 unifi_trace(card->ospriv, UDBG5,
578 "Traffic is not periodic, set timer for TORPID.\n");
579 (*remaining) = UNIFI_DEFAULT_HOST_IDLE_TIMEOUT;
580#ifndef CSR_WIFI_HIP_TA_DISABLE
581 }
582 else
583 {
584 unifi_trace(card->ospriv, UDBG5,
585 "Traffic is periodic, set unifi to TORPID immediately.\n");
586 if (CardAreAllFromHostDataSlotsEmpty(card) == 1)
587 {
588 r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
589 if (r != CSR_RESULT_SUCCESS)
590 {
591 goto exit;
592 }
593 }
594 }
595#endif
596 }
597
598 csrResult = CsrSdioInterruptEnable(card->sdio_if);
599 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
600 {
601 r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
602 }
603 if (csrResult != CSR_RESULT_SUCCESS)
604 {
605 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
606 unifi_error(card->ospriv, "Failed to enable SDIO interrupt\n");
607 }
608
609exit:
610
611 unifi_trace(card->ospriv, UDBG4, "New state=%d\n", card->host_state);
612
613 if (r != CSR_RESULT_SUCCESS)
614 {
615#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
616 unifi_debug_buf_dump();
617#endif
618 /* If an interrupt has been raised, ack it here */
619 if (card->bh_reason_unifi)
620 {
621 CsrSdioInterruptAcknowledge(card->sdio_if);
622 }
623
624 unifi_error(card->ospriv,
625 "unifi_bh: state=%d %c, clock=%dkHz, interrupt=%d host=%d, power_save=%s\n",
626 card->host_state,
627 (card->host_state == UNIFI_HOST_STATE_AWAKE)?'A' : (card->host_state == UNIFI_HOST_STATE_DROWSY)?'D' : 'T',
628 card->sdio_clock_speed / 1000,
629 card->bh_reason_unifi, card->bh_reason_host,
630 (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled");
631
632 /* Try to capture firmware panic codes */
633 (void)unifi_capture_panic(card);
634
635 /* Ask for a mini-coredump when the driver has reset UniFi */
636 (void)unifi_coredump_request_at_next_reset(card, 1);
637 }
638
639 return r;
640} /* unifi_bh() */
641
642
643/*
644 * ---------------------------------------------------------------------------
645 * process_clock_request
646 *
647 * Handle request from the OS layer to increase the SDIO clock speed.
648 * The fast clock is limited until the firmware has indicated that it has
649 * completed initialisation to the OS layer.
650 *
651 * Arguments:
652 * card Pointer to card context structure.
653 *
654 * Returns:
655 * CSR_RESULT_SUCCESS on success or CSR error code.
656 * ---------------------------------------------------------------------------
657 */
658static CsrResult process_clock_request(card_t *card)
659{
660 CsrResult r = CSR_RESULT_SUCCESS;
661 CsrResult csrResult;
662
663 if (!card->request_max_clock)
664 {
665 return CSR_RESULT_SUCCESS; /* No pending request */
666 }
667
668 /*
669 * The SDIO clock speed request from the OS layer is only acted upon if
670 * the UniFi is awake. If it was in any other state, the clock speed will
671 * transition through SAFE to MAX while the host wakes it up, and the
672 * final speed reached will be UNIFI_SDIO_CLOCK_MAX_HZ.
673 * This assumes that the SME never requests low power mode while the f/w
674 * initialisation takes place.
675 */
676 if (card->host_state == UNIFI_HOST_STATE_AWAKE)
677 {
678 unifi_trace(card->ospriv, UDBG1, "Set SDIO max clock\n");
679 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_MAX_HZ);
680 if (csrResult != CSR_RESULT_SUCCESS)
681 {
682 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
683 }
684 else
685 {
686 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ; /* log the new freq */
687 }
688 }
689 else
690 {
691 unifi_trace(card->ospriv, UDBG1, "Will set SDIO max clock after wakeup\n");
692 }
693
694 /* Cancel the request now that it has been acted upon, or is about to be
695 * by the wakeup mechanism
696 */
697 card->request_max_clock = 0;
698
699 return r;
700}
701
702
703/*
704 * ---------------------------------------------------------------------------
705 * process_bh
706 *
707 * Exchange messages with UniFi
708 *
709 * Arguments:
710 * card Pointer to card context structure.
711 *
712 * Returns:
713 * CSR_RESULT_SUCCESS on success or CSR error code.
714 * ---------------------------------------------------------------------------
715 */
716static CsrResult process_bh(card_t *card)
717{
718 CsrResult r;
719 u8 more;
720 more = FALSE;
721
722 /* Process the reasons (interrupt, signals) */
723 do
724 {
725 /*
726 * Run in a while loop, to save clearing the interrupts
727 * every time around the outside loop.
728 */
729 do
730 {
731 /* If configured to run the HIP just once, skip first loop */
732 if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
733 {
734 break;
735 }
736
737 r = handle_host_protocol(card, &more);
738 if (r != CSR_RESULT_SUCCESS)
739 {
740 return r;
741 }
742
743#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
744 unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
745 card->cmd_prof.cmd52_count,
746 card->cmd_prof.cmd53_count,
747 card->cmd_prof.tx_count,
748 card->cmd_prof.tx_cfm_count,
749 card->cmd_prof.rx_count,
750 card->cmd_prof.sdio_cmd_signal,
751 card->cmd_prof.sdio_cmd_to_host,
752 card->cmd_prof.sdio_cmd_from_host_and_clear
753 );
754
755 card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
756 card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
757
758 card->cmd_prof.cmd52_f0_r_count = 0;
759 card->cmd_prof.cmd52_f0_w_count = 0;
760 card->cmd_prof.cmd52_r8or16_count = 0;
761 card->cmd_prof.cmd52_w8or16_count = 0;
762 card->cmd_prof.cmd52_r16_count = 0;
763 card->cmd_prof.cmd52_w16_count = 0;
764 card->cmd_prof.cmd52_r32_count = 0;
765
766 card->cmd_prof.sdio_cmd_signal = 0;
767 card->cmd_prof.sdio_cmd_clear_slot = 0;
768 card->cmd_prof.sdio_cmd_to_host = 0;
769 card->cmd_prof.sdio_cmd_from_host = 0;
770 card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
771#endif
772
773
774 } while (more || card->bh_reason_unifi || card->bh_reason_host);
775
776 /* Acknowledge the h/w interrupt */
777 r = CardClearInt(card);
778 if (r != CSR_RESULT_SUCCESS)
779 {
780 unifi_error(card->ospriv, "Failed to acknowledge interrupt.\n");
781 return r;
782 }
783
784 /*
785 * UniFi may have tried to generate an interrupt during the
786 * CardClearInt() was running. So, we need to run the host
787 * protocol again, to check if there are any pending requests.
788 */
789 r = handle_host_protocol(card, &more);
790 if (r != CSR_RESULT_SUCCESS)
791 {
792 return r;
793 }
794
795#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
796 unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
797 card->cmd_prof.cmd52_count,
798 card->cmd_prof.cmd53_count,
799 card->cmd_prof.tx_count,
800 card->cmd_prof.tx_cfm_count,
801 card->cmd_prof.rx_count,
802 card->cmd_prof.sdio_cmd_signal,
803 card->cmd_prof.sdio_cmd_to_host,
804 card->cmd_prof.sdio_cmd_from_host_and_clear
805 );
806
807 card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
808 card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
809
810 card->cmd_prof.cmd52_f0_r_count = 0;
811 card->cmd_prof.cmd52_f0_w_count = 0;
812 card->cmd_prof.cmd52_r8or16_count = 0;
813 card->cmd_prof.cmd52_w8or16_count = 0;
814 card->cmd_prof.cmd52_r16_count = 0;
815 card->cmd_prof.cmd52_w16_count = 0;
816 card->cmd_prof.cmd52_r32_count = 0;
817
818 card->cmd_prof.sdio_cmd_signal = 0;
819 card->cmd_prof.sdio_cmd_clear_slot = 0;
820 card->cmd_prof.sdio_cmd_to_host = 0;
821 card->cmd_prof.sdio_cmd_from_host = 0;
822 card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
823#endif
824 /* If configured to run the HIP just once, work is now done */
825 if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
826 {
827 break;
828 }
829
830 } while (more || card->bh_reason_unifi || card->bh_reason_host);
831
832#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
833 if ((card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) == 0)
834 {
835 unifi_debug_log_to_buf("proc=%d\n",
836 card->cmd_prof.process_count);
837 }
838#endif
839
840 return CSR_RESULT_SUCCESS;
841} /* process_bh() */
842
843
844/*
845 * ---------------------------------------------------------------------------
846 * handle_host_protocol
847 *
848 * This function implements the Host Interface Protocol (HIP) as
849 * described in the Host Interface Protocol Specification.
850 *
851 * Arguments:
852 * card Pointer to card context structure.
853 * processed_something Pointer to location to update processing status:
854 * TRUE when data was transferred
855 * FALSE when no data was transferred (queues empty)
856 *
857 * Returns:
858 * CSR_RESULT_SUCCESS on success or CSR error code.
859 * ---------------------------------------------------------------------------
860 */
861static CsrResult handle_host_protocol(card_t *card, u8 *processed_something)
862{
863 CsrResult r;
864 s32 done;
865
866 *processed_something = FALSE;
867
868#ifdef CSR_WIFI_HIP_NOISY
869 unifi_error(card->ospriv, " ======================== \n");
870#endif /* CSR_WIFI_HIP_NOISY */
871
872#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
873 card->cmd_prof.process_count++;
874#endif
875
876 card->bh_reason_unifi = card->bh_reason_host = 0;
877 card->generate_interrupt = 0;
878
879
880 /*
881 * (Re)fill the T-H signal buffer
882 */
883 r = read_to_host_signals(card, &done);
884 if (r != CSR_RESULT_SUCCESS)
885 {
886 unifi_error(card->ospriv, "Error occurred reading to-host signals\n");
887 return r;
888 }
889 if (done > 0)
890 {
891 *processed_something = TRUE;
892 }
893
894 /*
895 * Process any to-host signals.
896 * Perform any requested CMD53 transfers here, but just queue any
897 * bulk data command responses.
898 */
899 r = process_to_host_signals(card, &done);
900 if (r != CSR_RESULT_SUCCESS)
901 {
902 unifi_error(card->ospriv, "Error occurred processing to-host signals\n");
903 return r;
904 }
905
906 /* Now send any signals in the F-H queues */
907 /* Give precedence to the command queue */
908 r = process_fh_cmd_queue(card, &done);
909 if (r != CSR_RESULT_SUCCESS)
910 {
911 unifi_error(card->ospriv, "Error occurred processing from-host signals\n");
912 return r;
913 }
914 if (done > 0)
915 {
916 *processed_something = TRUE;
917 }
918
919 r = process_fh_traffic_queue(card, &done);
920 if (r != CSR_RESULT_SUCCESS)
921 {
922 unifi_error(card->ospriv, "Error occurred processing from-host data signals\n");
923 return r;
924 }
925 if (done > 0)
926 {
927 *processed_something = TRUE;
928 }
929
930 /* Flush out the batch of signals to the UniFi. */
931 r = flush_fh_buffer(card);
932 if (r != CSR_RESULT_SUCCESS)
933 {
934 unifi_error(card->ospriv, "Failed to copy from-host signals to UniFi\n");
935 return r;
936 }
937
938
939 /*
940 * Send the host interrupt to say the queues have been modified.
941 */
942 if (card->generate_interrupt)
943 {
944 r = CardGenInt(card);
945 if (r != CSR_RESULT_SUCCESS)
946 {
947 unifi_error(card->ospriv, "Failed to notify UniFi that queues have been modified.\n");
948 return r;
949 }
950 }
951
952#ifdef CSR_WIFI_RX_PATH_SPLIT
953#ifdef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
954 unifi_rx_queue_flush(card->ospriv);
955#endif
956#endif
957
958 /* See if we can re-enable transmission now */
959 restart_packet_flow(card);
960
961#ifdef CSR_PRE_ALLOC_NET_DATA
962 r = prealloc_netdata_alloc(card);
963 if (r != CSR_RESULT_SUCCESS)
964 {
965 unifi_error(card->ospriv, "prealloc_netdata failed\n");
966 return r;
967 }
968#endif
969
970 /*
971 * Don't put the thread sleep if we just interacted with the chip,
972 * there might be more to do if we look again.
973 */
974 return r;
975} /* handle_host_protocol() */
976
977
978/*
979 * Rounds the given signal length in bytes to a whole number
980 * of sig_frag_size.
981 */
982#define GET_CHUNKS_FOR(SIG_FRAG_SIZE, LENGTH) (((LENGTH) + ((SIG_FRAG_SIZE)-1)) / (SIG_FRAG_SIZE))
983
984
985/*
986 * ---------------------------------------------------------------------------
987 * read_to_host_signals
988 *
989 * Read everything pending in the UniFi TH signal buffer.
990 * Only do it if the local buffer is empty.
991 *
992 * Arguments:
993 * card Pointer to card context struct
994 * processed Number of signals read:
995 * 0 if there were no signals pending,
996 * 1 if we read at least one signal
997 * Returns:
998 * CSR error code if an error occurred.
999 * ---------------------------------------------------------------------------
1000 */
1001static CsrResult read_to_host_signals(card_t *card, s32 *processed)
1002{
1003 s32 count_thw, count_thr;
1004 s32 unread_chunks, unread_bytes;
1005 CsrResult r;
1006
1007 *processed = 0;
1008
1009 /* Read any pending signals or bulk data commands */
1010 count_thw = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
1011 if (count_thw < 0)
1012 {
1013 unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
1014 return CSR_RESULT_FAILURE;
1015 }
1016 card->to_host_signals_w = count_thw; /* diag */
1017
1018 count_thr = card->to_host_signals_r;
1019
1020 if (count_thw == count_thr)
1021 {
1022 return CSR_RESULT_SUCCESS;
1023 }
1024
1025 unread_chunks =
1026 (((count_thw - count_thr) + 128) % 128) - card->th_buffer.count;
1027
1028 if (unread_chunks == 0)
1029 {
1030 return CSR_RESULT_SUCCESS;
1031 }
1032
1033 unread_bytes = card->config_data.sig_frag_size * unread_chunks;
1034
1035
1036 r = unifi_bulk_rw(card,
1037 card->config_data.tohost_sigbuf_handle,
1038 card->th_buffer.ptr,
1039 unread_bytes,
1040 UNIFI_SDIO_READ);
1041 if (r != CSR_RESULT_SUCCESS)
1042 {
1043 unifi_error(card->ospriv, "Failed to read ToHost signal\n");
1044 return r;
1045 }
1046
1047 card->th_buffer.ptr += unread_bytes;
1048 card->th_buffer.count += (u16)unread_chunks;
1049
1050 *processed = 1;
1051
1052 return CSR_RESULT_SUCCESS;
1053} /* read_to_host_signals() */
1054
1055
1056/*
1057 * ---------------------------------------------------------------------------
1058 * update_to_host_signals_r
1059 *
1060 * Advance the shared-memory count of chunks read from the to-host
1061 * signal buffer.
1062 * Raise a UniFi internal interrupt to tell the firmware that the
1063 * count has changed.
1064 *
1065 * Arguments:
1066 * card Pointer to card context struct
1067 * pending Number of chunks remaining
1068 *
1069 * Returns:
1070 * CSR_RESULT_SUCCESS on success or CSR error code
1071 * ---------------------------------------------------------------------------
1072 */
1073static CsrResult update_to_host_signals_r(card_t *card, s16 pending)
1074{
1075 CsrResult r;
1076
1077 card->to_host_signals_r =
1078 (card->to_host_signals_r + (card->th_buffer.count - pending)) % 128;
1079 card->th_buffer.count = pending;
1080
1081 /* Update the count of signals read */
1082 r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 6,
1083 (u8)card->to_host_signals_r);
1084 if (r != CSR_RESULT_SUCCESS)
1085 {
1086 unifi_error(card->ospriv, "Failed to update to-host signals read\n");
1087 return r;
1088 }
1089
1090 r = CardGenInt(card);
1091 if (r != CSR_RESULT_SUCCESS)
1092 {
1093 unifi_error(card->ospriv, "Failed to notify UniFi that we processed to-host signals.\n");
1094 return r;
1095 }
1096
1097 card->generate_interrupt = 0;
1098
1099 return CSR_RESULT_SUCCESS;
1100} /* update_to_host_signals_r() */
1101
1102
1103/*
1104 * ---------------------------------------------------------------------------
1105 * read_unpack_cmd
1106 *
1107 * Converts a wire-formatted command to the host bulk_data_cmd_t structure.
1108 *
1109 * Arguments:
1110 * ptr Pointer to the command
1111 * bulk_data_cmd Pointer to the host structure
1112 *
1113 * Returns:
1114 * None.
1115 * ---------------------------------------------------------------------------
1116 */
1117static void read_unpack_cmd(const u8 *ptr, bulk_data_cmd_t *bulk_data_cmd)
1118{
1119 s16 index = 0;
1120 bulk_data_cmd->cmd_and_len = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1121 index += SIZEOF_UINT16;
1122 bulk_data_cmd->data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1123 index += SIZEOF_UINT16;
1124 bulk_data_cmd->offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1125 index += SIZEOF_UINT16;
1126 bulk_data_cmd->buffer_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1127 index += SIZEOF_UINT16;
1128} /* read_unpack_cmd */
1129
1130
1131/*
1132 * ---------------------------------------------------------------------------
1133 * process_to_host_signals
1134 *
1135 * Read and dispatch signals from the UniFi
1136 *
1137 * Arguments:
1138 * card Pointer to card context struct
1139 * processed Pointer to location to write processing result:
1140 * 0 if there were no signals pending,
1141 * 1 if we read at least one signal
1142 *
1143 * Returns:
1144 * CSR error code if there was an error
1145 *
1146 * Notes:
1147 * Since bulk data transfers can take a long time, if we wait until
1148 * all are done before we acknowledge the signals, the UniFi runs out
1149 * of buffer space. Therefore we keep a count of the bytes transferred
1150 * in bulk data commands, and update the to-host-signals-read count
1151 * if we've done a large transfer.
1152 *
1153 * All data in the f/w is stored in a little endian format, without any
1154 * padding bytes. Every read from the memory has to be transformed in
1155 * host (cpu specific) format, before we can process it. Therefore we
1156 * use read_unpack_cmd() and read_unpack_signal() to convert the raw data
1157 * contained in the card->th_buffer.buf to host structures.
1158 * Important: UDI clients use wire-formatted structures, so we need to
1159 * indicate all data, as we have read it from the device.
1160 * ---------------------------------------------------------------------------
1161 */
1162static CsrResult process_to_host_signals(card_t *card, s32 *processed)
1163{
1164 s16 pending;
1165 s16 remaining;
1166 u8 *bufptr;
1167 bulk_data_param_t data_ptrs;
1168 s16 cmd;
1169 u16 sig_len;
1170 s16 i;
1171 u16 chunks_in_buf;
1172 u16 bytes_transferred = 0;
1173 CsrResult r = CSR_RESULT_SUCCESS;
1174
1175 *processed = 0;
1176
1177 pending = card->th_buffer.count;
1178
1179 /* Are there new to-host signals? */
1180 unifi_trace(card->ospriv, UDBG4, "handling %d to-host chunks\n", pending);
1181
1182 if (!pending)
1183 {
1184 return CSR_RESULT_SUCCESS;
1185 }
1186
1187 /*
1188 * This is a pointer to the raw data we have read from the f/w.
1189 * Can be a signal or a command. Note that we need to convert
1190 * it to a host structure before we process it.
1191 */
1192 bufptr = card->th_buffer.buf;
1193
1194 while (pending > 0)
1195 {
1196 s16 f_flush_count = 0;
1197
1198 /*
1199 * Command and length are common to signal and bulk data msgs.
1200 * If command == 0 (i.e. a signal), len is number of bytes
1201 * *following* the 2-byte header.
1202 */
1203 cmd = bufptr[1] >> 4;
1204 sig_len = bufptr[0] + ((bufptr[1] & 0x0F) << 8);
1205
1206#ifdef CSR_WIFI_HIP_NOISY
1207 unifi_error(card->ospriv, "Received UniFi msg cmd=%d, len=%d\n",
1208 cmd, sig_len);
1209#endif /* CSR_WIFI_HIP_NOISY */
1210
1211 if ((sig_len == 0) &&
1212 ((cmd != SDIO_CMD_CLEAR_SLOT) && (cmd != SDIO_CMD_PADDING)))
1213 {
1214 unifi_error(card->ospriv, "incomplete signal or command: has size zero\n");
1215 return CSR_RESULT_FAILURE;
1216 }
1217 /*
1218 * Make sure the buffer contains a complete message.
1219 * Signals may occupy multiple chunks, bulk-data commands occupy
1220 * one chunk.
1221 */
1222 if (cmd == SDIO_CMD_SIGNAL)
1223 {
1224 chunks_in_buf = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(sig_len + 2));
1225 }
1226 else
1227 {
1228 chunks_in_buf = 1;
1229 }
1230
1231 if (chunks_in_buf > (u16)pending)
1232 {
1233 unifi_error(card->ospriv, "incomplete signal (0x%x?): need %d chunks, got %d\n",
1234 GET_SIGNAL_ID(bufptr + 2),
1235 chunks_in_buf, pending);
1236 unifi_error(card->ospriv, " thsw=%d, thsr=%d\n",
1237 card->to_host_signals_w,
1238 card->to_host_signals_r);
1239 return CSR_RESULT_FAILURE;
1240 }
1241
1242
1243 switch (cmd)
1244 {
1245 case SDIO_CMD_SIGNAL:
1246 /* This is a signal. Read the rest of it and then handle it. */
1247#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1248 card->cmd_prof.sdio_cmd_signal++;
1249#endif
1250
1251 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
1252 {
1253 /* Retrieve dataRefs[i].DataLength */
1254 u16 data_len = GET_PACKED_DATAREF_LEN(bufptr + 2, i);
1255
1256 /*
1257 * The bulk data length in the signal can not be greater than
1258 * the maximun length allowed by the SDIO config structure.
1259 */
1260 if (data_len > card->config_data.data_slot_size)
1261 {
1262 unifi_error(card->ospriv,
1263 "Bulk Data length (%d) exceeds Maximum Bulk Data length (%d)\n",
1264 data_len, card->config_data.data_slot_size);
1265 return CSR_RESULT_FAILURE;
1266 }
1267
1268 /*
1269 * Len here might not be the same as the length in the
1270 * bulk data slot. The slot length will always be even,
1271 * but len could be odd.
1272 */
1273 if (data_len != 0)
1274 {
1275 /* Retrieve dataRefs[i].SlotNumber */
1276 s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
1277
1278 if (slot >= card->config_data.num_tohost_data_slots)
1279 {
1280 unifi_error(card->ospriv, "!!!bad slot number in to-host signal: %d, sig 0x%X\n",
1281 slot, cmd);
1282 return CSR_RESULT_FAILURE;
1283 }
1284
1285 data_ptrs.d[i].os_data_ptr = card->to_host_data[slot].os_data_ptr;
1286 data_ptrs.d[i].os_net_buf_ptr = card->to_host_data[slot].os_net_buf_ptr;
1287 data_ptrs.d[i].net_buf_length = card->to_host_data[slot].net_buf_length;
1288 data_ptrs.d[i].data_length = data_len;
1289 }
1290 else
1291 {
1292 UNIFI_INIT_BULK_DATA(&data_ptrs.d[i]);
1293 }
1294 }
1295
1296 /*
1297 * Log the signal to the UDI, before call unifi_receive_event() as
1298 * it can modify the bulk data.
1299 */
1300 if (card->udi_hook)
1301 {
1302 (*card->udi_hook)(card->ospriv, bufptr + 2, sig_len,
1303 &data_ptrs, UDI_LOG_TO_HOST);
1304 }
1305
1306#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
1307 if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
1308 {
1309 card->cmd_prof.tx_cfm_count++;
1310 }
1311 else if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_INDICATION_ID)
1312 {
1313 if (data_ptrs.d[0].os_data_ptr)
1314 {
1315 if ((*data_ptrs.d[0].os_data_ptr) & 0x08)
1316 {
1317 card->cmd_prof.rx_count++;
1318 }
1319 }
1320 }
1321#endif
1322 /*
1323 * Check if the signal is MA-PACKET.cfm and if so check the status.
1324 * If the status is failure, search through the slot records to find
1325 * if any slots are occupied for this host tag. This can happen if
1326 * f/w has not downloaded the bulkdata and before that itself it has
1327 * signalled the confirm with failure. If it finds a slot with that
1328 * host tag then, it clears the corresponding slot
1329 */
1330
1331 if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
1332 {
1333 /* Get host tag and transmission status */
1334 u32 host_tag = GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(bufptr + 2);
1335 u16 status = GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(bufptr + 2);
1336
1337 unifi_trace(card->ospriv, UDBG4, "process_to_host_signals signal ID=%x host Tag=%x status=%x\n",
1338 GET_SIGNAL_ID(bufptr + 2), host_tag, status);
1339
1340 /* If transmission status is failure then search through the slot records
1341 * and if for any slot records the clear slot is not done then do it now
1342 */
1343
1344 if (status && (card->fh_slot_host_tag_record))
1345 {
1346 u16 num_fh_slots = card->config_data.num_fromhost_data_slots;
1347
1348 /* search through the list of slot records and match with host tag
1349 * If a slot is not yet cleared then clear the slot from here
1350 */
1351 for (i = 0; i < num_fh_slots; i++)
1352 {
1353 if (card->fh_slot_host_tag_record[i] == host_tag)
1354 {
1355#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
1356 /* Invoke the HAL module function to requeue it back to HAL Queues */
1357 r = unifi_reque_ma_packet_request(card->ospriv, host_tag, status, &card->from_host_data[i].bd);
1358 card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1359 if (CSR_RESULT_SUCCESS != r)
1360 {
1361 unifi_trace(card->ospriv, UDBG5, "process_to_host_signals: Failed to requeue Packet(hTag:%x) back to HAL \n", host_tag);
1362 CardClearFromHostDataSlot(card, i);
1363 }
1364 else
1365 {
1366 CardClearFromHostDataSlotWithoutFreeingBulkData(card, i);
1367 }
1368
1369#else
1370 unifi_trace(card->ospriv, UDBG4, "process_to_host_signals Clear slot=%x host tag=%x\n", i, host_tag);
1371 card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1372
1373 /* Set length field in from_host_data array to 0 */
1374 CardClearFromHostDataSlot(card, i);
1375#endif
1376 break;
1377 }
1378 }
1379 }
1380 }
1381
1382 /* Pass event to OS layer */
1383 unifi_receive_event(card->ospriv, bufptr + 2, sig_len, &data_ptrs);
1384
1385 /* Initialise the to_host data, so it can be re-used. */
1386 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
1387 {
1388 /* The slot is only valid if the length is non-zero. */
1389 if (GET_PACKED_DATAREF_LEN(bufptr + 2, i) != 0)
1390 {
1391 s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
1392 if (slot < card->config_data.num_tohost_data_slots)
1393 {
1394 UNIFI_INIT_BULK_DATA(&card->to_host_data[slot]);
1395 }
1396 }
1397 }
1398
1399#ifndef CSR_WIFI_DEFER_TH_FLUSH
1400 /*
1401 * If we have previously transferred a lot of data, ack
1402 * the signals read so far, so f/w can reclaim the buffer
1403 * memory sooner.
1404 */
1405 if (bytes_transferred >= TO_HOST_FLUSH_THRESHOLD)
1406 {
1407 f_flush_count = 1;
1408 }
1409#endif
1410 break;
1411
1412
1413 case SDIO_CMD_CLEAR_SLOT:
1414#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1415 card->cmd_prof.sdio_cmd_clear_slot++;
1416#endif
1417 /* This is a clear slot command. */
1418 if (sig_len != 0)
1419 {
1420 unifi_error(card->ospriv, "process_to_host_signals: clear slot, bad data len: 0x%X at offset %d\n",
1421 sig_len, bufptr - card->th_buffer.buf);
1422 return CSR_RESULT_FAILURE;
1423 }
1424
1425 r = process_clear_slot_command(card, bufptr);
1426 if (r != CSR_RESULT_SUCCESS)
1427 {
1428 unifi_error(card->ospriv, "Failed to process clear slot\n");
1429 return r;
1430 }
1431 break;
1432
1433 case SDIO_CMD_TO_HOST_TRANSFER:
1434 case SDIO_CMD_FROM_HOST_TRANSFER:
1435 case SDIO_CMD_FROM_HOST_AND_CLEAR:
1436 case SDIO_CMD_OVERLAY_TRANSFER:
1437 /* This is a bulk data command. */
1438 if (sig_len & 1)
1439 {
1440 unifi_error(card->ospriv, "process_to_host_signals: bulk data, bad data len: 0x%X at offset %d\n",
1441 sig_len, bufptr - card->th_buffer.buf);
1442 return CSR_RESULT_FAILURE;
1443 }
1444
1445 r = process_bulk_data_command(card, bufptr, cmd, sig_len);
1446 if (r != CSR_RESULT_SUCCESS)
1447 {
1448 unifi_error(card->ospriv, "Failed to process bulk cmd\n");
1449 return r;
1450 }
1451 /* Count the bytes transferred */
1452 bytes_transferred += sig_len;
1453
1454 if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
1455 {
1456#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1457 card->cmd_prof.sdio_cmd_from_host_and_clear++;
1458#endif
1459#ifndef CSR_WIFI_DEFER_TH_FLUSH
1460 f_flush_count = 1;
1461#endif
1462 }
1463#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1464 else if (cmd == SDIO_CMD_FROM_HOST_TRANSFER)
1465 {
1466 card->cmd_prof.sdio_cmd_from_host++;
1467 }
1468 else if (cmd == SDIO_CMD_TO_HOST_TRANSFER)
1469 {
1470 card->cmd_prof.sdio_cmd_to_host++;
1471 }
1472#endif
1473 break;
1474
1475 case SDIO_CMD_PADDING:
1476 break;
1477
1478 default:
1479 unifi_error(card->ospriv, "Unrecognised to-host command: %d\n", cmd);
1480 break;
1481 }
1482
1483 bufptr += chunks_in_buf * card->config_data.sig_frag_size;
1484 pending -= chunks_in_buf;
1485
1486 /*
1487 * Write out the host signal count when a significant
1488 * number of bytes of bulk data have been transferred or
1489 * when we have performed a CopyFromHostAndClear.
1490 */
1491 if (f_flush_count)
1492 {
1493 r = update_to_host_signals_r(card, pending);
1494 if (r != CSR_RESULT_SUCCESS)
1495 {
1496 return r;
1497 }
1498 bytes_transferred = 0;
1499 }
1500 }
1501
1502 if (pending)
1503 {
1504 unifi_warning(card->ospriv, "proc_th_sigs: %d unprocessed\n", pending);
1505 }
1506
1507 /* If we processed any signals, write the updated count to UniFi */
1508 if (card->th_buffer.count != pending)
1509 {
1510 r = update_to_host_signals_r(card, pending);
1511 if (r != CSR_RESULT_SUCCESS)
1512 {
1513 return r;
1514 }
1515 }
1516
1517 /*
1518 * Reset the buffer pointer, copying down any un-processed signals.
1519 * This can happen if we enable the optimisation in read_to_host_signals()
1520 * that limits the length to whole blocks.
1521 */
1522 remaining = card->th_buffer.ptr - bufptr;
1523 if (remaining < 0)
1524 {
1525 unifi_error(card->ospriv, "Processing TH signals overran the buffer\n");
1526 return CSR_RESULT_FAILURE;
1527 }
1528 if (remaining > 0)
1529 {
1530 /* Use a safe copy because source and destination may overlap */
1531 u8 *d = card->th_buffer.buf;
1532 u8 *s = bufptr;
1533 s32 n = remaining;
1534 while (n--)
1535 {
1536 *d++ = *s++;
1537 }
1538 }
1539 card->th_buffer.ptr = card->th_buffer.buf + remaining;
1540
1541
1542 /* If we reach here then we processed something */
1543 *processed = 1;
1544 return CSR_RESULT_SUCCESS;
1545} /* process_to_host_signals() */
1546
1547
1548/*
1549 * ---------------------------------------------------------------------------
1550 * process_clear_slot_command
1551 *
1552 * Process a clear slot command fom the UniFi.
1553 *
1554 * Arguments:
1555 * card Pointer to card context struct
1556 * bdcmd Pointer to bulk-data command msg from UniFi
1557 *
1558 * Returns:
1559 * 0 on success, CSR error code on error
1560 * ---------------------------------------------------------------------------
1561 */
1562static CsrResult process_clear_slot_command(card_t *card, const u8 *cmdptr)
1563{
1564 u16 data_slot;
1565 s16 slot;
1566
1567 data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cmdptr + SIZEOF_UINT16);
1568
1569 unifi_trace(card->ospriv, UDBG4, "Processing clear slot cmd, slot=0x%X\n",
1570 data_slot);
1571
1572 slot = data_slot & 0x7FFF;
1573
1574#ifdef CSR_WIFI_HIP_NOISY
1575 unifi_error(card->ospriv, "CMD clear data slot 0x%04x\n", data_slot);
1576#endif /* CSR_WIFI_HIP_NOISY */
1577
1578 if (data_slot & SLOT_DIR_TO_HOST)
1579 {
1580 if (slot >= card->config_data.num_tohost_data_slots)
1581 {
1582 unifi_error(card->ospriv,
1583 "Invalid to-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
1584 slot);
1585 return CSR_RESULT_FAILURE;
1586 }
1587 /* clear to-host data slot */
1588 unifi_warning(card->ospriv, "Unexpected clear to-host data slot cmd: 0x%04x\n",
1589 data_slot);
1590 }
1591 else
1592 {
1593 if (slot >= card->config_data.num_fromhost_data_slots)
1594 {
1595 unifi_error(card->ospriv,
1596 "Invalid from-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
1597 slot);
1598 return CSR_RESULT_FAILURE;
1599 }
1600
1601 /*
1602 * The driver is the owner to clear all slots now
1603 * Ref - comment in process_fh_traffic_queue
1604 * so it will just ignore the clear slot command from firmware
1605 * and return success
1606 */
1607 return CSR_RESULT_SUCCESS;
1608
1609 /* Set length field in from_host_data array to 0 */
1610 /* CardClearFromHostDataSlot(card, slot); */
1611 }
1612
1613 return CSR_RESULT_SUCCESS;
1614} /* process_clear_slot_command() */
1615
1616
1617/*
1618 * ---------------------------------------------------------------------------
1619 * process_bulk_data_command
1620 *
1621 * Process a bulk data request from the UniFi.
1622 *
1623 * Arguments:
1624 * card Pointer to card context struct
1625 * bdcmd Pointer to bulk-data command msg from UniFi
1626 * cmd, len Decoded values of command and length from the msg header
1627 * Cmd will only be one of:
1628 * SDIO_CMD_TO_HOST_TRANSFER
1629 * SDIO_CMD_FROM_HOST_TRANSFER
1630 * SDIO_CMD_FROM_HOST_AND_CLEAR
1631 * SDIO_CMD_OVERLAY_TRANSFER
1632 *
1633 * Returns:
1634 * CSR_RESULT_SUCCESS on success, CSR error code on error
1635 * ---------------------------------------------------------------------------
1636 */
1637static CsrResult process_bulk_data_command(card_t *card, const u8 *cmdptr,
1638 s16 cmd, u16 len)
1639{
1640 bulk_data_desc_t *bdslot;
1641#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
1642 u8 *host_bulk_data_slot;
1643#endif
1644 bulk_data_cmd_t bdcmd;
1645 s16 offset;
1646 s16 slot;
1647 s16 dir;
1648 CsrResult r;
1649
1650 read_unpack_cmd(cmdptr, &bdcmd);
1651
1652 unifi_trace(card->ospriv, UDBG4, "Processing bulk data cmd %d %s, len=%d, slot=0x%X\n",
1653 cmd, lookup_bulkcmd_name(cmd), len, bdcmd.data_slot);
1654
1655 /*
1656 * Round up the transfer length if required.
1657 * This is useful to force all transfers to be a multiple of the SDIO block
1658 * size, so the SDIO driver won't try to use a byte-mode CMD53. These are
1659 * broken on some hardware platforms.
1660 */
1661 if (card->sdio_io_block_pad)
1662 {
1663 len = (len + card->sdio_io_block_size - 1) & ~(card->sdio_io_block_size - 1);
1664 unifi_trace(card->ospriv, UDBG4, "Rounded bulk data length up to %d\n", len);
1665 }
1666
1667 slot = bdcmd.data_slot & 0x7FFF;
1668
1669 if (cmd == SDIO_CMD_OVERLAY_TRANSFER)
1670 {
1671 return CSR_WIFI_HIP_RESULT_INVALID_VALUE; /* Not used on CSR6xxx */
1672 }
1673 else
1674 {
1675 if (bdcmd.data_slot & SLOT_DIR_TO_HOST)
1676 {
1677 /* Request is for to-host bulk data */
1678
1679 /* Check sanity of slot number */
1680 if (slot >= card->config_data.num_tohost_data_slots)
1681 {
1682 unifi_error(card->ospriv,
1683 "Invalid to-host data slot in SDIO bulk xfr req: %d\n",
1684 slot);
1685 return CSR_RESULT_FAILURE;
1686 }
1687
1688 /* Allocate memory for card->to_host_data[slot] bulk data here. */
1689#ifdef CSR_PRE_ALLOC_NET_DATA
1690 r = prealloc_netdata_get(card, &card->to_host_data[slot], len);
1691#else
1692 r = unifi_net_data_malloc(card->ospriv, &card->to_host_data[slot], len);
1693#endif
1694 if (r != CSR_RESULT_SUCCESS)
1695 {
1696 unifi_error(card->ospriv, "Failed to allocate t-h bulk data\n");
1697 return CSR_RESULT_FAILURE;
1698 }
1699
1700 bdslot = &card->to_host_data[slot];
1701
1702 /* Make sure that the buffer is 4-bytes aligned */
1703 r = unifi_net_dma_align(card->ospriv, bdslot);
1704 if (r != CSR_RESULT_SUCCESS)
1705 {
1706 unifi_error(card->ospriv, "Failed to align t-h bulk data buffer for DMA\n");
1707 return CSR_RESULT_FAILURE;
1708 }
1709 }
1710 else
1711 {
1712 /* Request is for from-host bulk data */
1713
1714 if (slot >= card->config_data.num_fromhost_data_slots)
1715 {
1716 unifi_error(card->ospriv,
1717 "Invalid from-host data slot in SDIO bulk xfr req: %d\n",
1718 slot);
1719 return CSR_RESULT_FAILURE;
1720 }
1721 bdslot = &card->from_host_data[slot].bd;
1722 }
1723 offset = bdcmd.offset;
1724 }
1725 /* Do the transfer */
1726 dir = (cmd == SDIO_CMD_TO_HOST_TRANSFER)?
1727 UNIFI_SDIO_READ : UNIFI_SDIO_WRITE;
1728
1729 unifi_trace(card->ospriv, UDBG4,
1730 "Bulk %c %s len=%d, handle %d - slot=%d %p+(%d)\n",
1731 (dir == UNIFI_SDIO_READ)?'R' : 'W',
1732 lookup_bulkcmd_name(cmd),
1733 len,
1734 bdcmd.buffer_handle,
1735 slot, bdslot->os_data_ptr, offset);
1736#ifdef CSR_WIFI_HIP_NOISY
1737 unifi_error(card->ospriv, "Bulk %s len=%d, handle %d - slot=%d %p+(%d)\n",
1738 lookup_bulkcmd_name(cmd),
1739 len,
1740 bdcmd.buffer_handle,
1741 slot, bdslot->os_data_ptr, offset);
1742#endif /* CSR_WIFI_HIP_NOISY */
1743
1744
1745 if (bdslot->os_data_ptr == NULL)
1746 {
1747 unifi_error(card->ospriv, "Null os_data_ptr - Bulk %s handle %d - slot=%d o=(%d)\n",
1748 lookup_bulkcmd_name(cmd),
1749 bdcmd.buffer_handle,
1750 slot,
1751 offset);
1752 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1753 }
1754
1755#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
1756 /* if os_data_ptr is not 4-byte aligned, then allocate a new buffer and copy data
1757 to new buffer to ensure the address passed to unifi_bulk_rw is 4-byte aligned */
1758
1759 if (len != 0 && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
1760 {
1761 host_bulk_data_slot = kmalloc(len, GFP_KERNEL);
1762
1763 if (!host_bulk_data_slot)
1764 {
1765 unifi_error(card->ospriv, " failed to allocate request_data before unifi_bulk_rw\n");
1766 return -1;
1767 }
1768
1769 memcpy((void *)host_bulk_data_slot,
1770 (void *)(bdslot->os_data_ptr + offset), len);
1771
1772 r = unifi_bulk_rw(card,
1773 bdcmd.buffer_handle,
1774 (void *)host_bulk_data_slot,
1775 len,
1776 dir);
1777 }
1778 else
1779#endif
1780 {
1781 r = unifi_bulk_rw(card,
1782 bdcmd.buffer_handle,
1783 (void *)(bdslot->os_data_ptr + offset),
1784 len,
1785 dir);
1786 }
1787
1788 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1789 {
1790 return r;
1791 }
1792 if (r != CSR_RESULT_SUCCESS)
1793 {
1794 unifi_error(card->ospriv,
1795 "Failed: %s hlen=%d, slen=%d, handle %d - slot=%d %p+0x%X\n",
1796 lookup_bulkcmd_name(cmd),
1797 len, /* Header length */
1798 bdslot->data_length, /* Length stored in slot */
1799 bdcmd.buffer_handle,
1800 slot, bdslot->os_data_ptr, offset);
1801 return r;
1802 }
1803
1804 bdslot->data_length = len;
1805
1806 if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
1807 {
1808 if (slot >= card->config_data.num_fromhost_data_slots)
1809 {
1810 unifi_error(card->ospriv,
1811 "Invalid from-host data slot in SDIO_CMD_FROM_HOST_AND_CLEAR: %d\n",
1812 slot);
1813 return CSR_RESULT_FAILURE;
1814 }
1815
1816#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
1817 /* moving this check before we clear host data slot */
1818 if ((len != 0) && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
1819 {
1820 kfree(host_bulk_data_slot);
1821 }
1822#endif
1823
1824 if (card->fh_slot_host_tag_record)
1825 {
1826 unifi_trace(card->ospriv, UDBG5, "CopyFromHostAndClearSlot Reset entry for slot=%d\n", slot);
1827
1828 /* reset the host tag entry for the corresponding slot */
1829 card->fh_slot_host_tag_record[slot] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1830 }
1831
1832
1833 /* Set length field in from_host_data array to 0 */
1834 CardClearFromHostDataSlot(card, slot);
1835 }
1836
1837 return CSR_RESULT_SUCCESS;
1838} /* process_bulk_data_command() */
1839
1840
1841/*
1842 * ---------------------------------------------------------------------------
1843 * check_fh_sig_slots
1844 *
1845 * Check whether there are <n> free signal slots available on UniFi.
1846 * This takes into account the signals already batched since the
1847 * from_host_signal counts were last read.
1848 * If the from_host_signal counts indicate not enough space, we read
1849 * the latest count from UniFi to see if some more have been freed.
1850 *
1851 * Arguments:
1852 * None.
1853 *
1854 * Returns:
1855 * CSR_RESULT_SUCCESS, otherwise CSR error code on error.
1856 * ---------------------------------------------------------------------------
1857 */
1858static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space_fh)
1859{
1860 u32 count_fhw;
1861 u32 occupied_fh, slots_fh;
1862 s32 count_fhr;
1863
1864 count_fhw = card->from_host_signals_w;
1865 count_fhr = card->from_host_signals_r;
1866 slots_fh = card->config_data.num_fromhost_sig_frags;
1867
1868 /* Only read the space in from-host queue if necessary */
1869 occupied_fh = (count_fhw - count_fhr) % 128;
1870
1871 if (slots_fh < occupied_fh)
1872 {
1873 *space_fh = 0;
1874 }
1875 else
1876 {
1877 *space_fh = slots_fh - occupied_fh;
1878 }
1879
1880 if ((occupied_fh != 0) && (*space_fh < needed))
1881 {
1882 count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
1883 if (count_fhr < 0)
1884 {
1885 unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
1886 return CSR_RESULT_FAILURE;
1887 }
1888 card->from_host_signals_r = count_fhr; /* diag */
1889
1890 occupied_fh = (count_fhw - count_fhr) % 128;
1891 *space_fh = slots_fh - occupied_fh;
1892 }
1893
1894 return CSR_RESULT_SUCCESS;
1895} /* check_fh_sig_slots() */
1896
1897
1898/*
1899* If we are padding the From-Host signals to the SDIO block size,
1900* we need to round up the needed_chunks to the SDIO block size.
1901*/
1902#define ROUND_UP_NEEDED_CHUNKS(_card, _needed_chunks) \
1903 { \
1904 u16 _chunks_per_block; \
1905 u16 _chunks_in_last_block; \
1906 \
1907 if (_card->sdio_io_block_pad) \
1908 { \
1909 _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
1910 _chunks_in_last_block = _needed_chunks % _chunks_per_block; \
1911 if (_chunks_in_last_block != 0) \
1912 { \
1913 _needed_chunks = _needed_chunks + (_chunks_per_block - _chunks_in_last_block); \
1914 } \
1915 } \
1916 }
1917
1918
1919#define ROUND_UP_SPACE_CHUNKS(_card, _space_chunks) \
1920 { \
1921 u16 _chunks_per_block; \
1922 \
1923 if (_card->sdio_io_block_pad) \
1924 { \
1925 _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
1926 _space_chunks = ((_space_chunks / _chunks_per_block) * _chunks_per_block); \
1927 } \
1928 }
1929
1930
1931
1932
1933
1934/*
1935 * ---------------------------------------------------------------------------
1936 * process_fh_cmd_queue
1937 *
1938 * Take one signal off the from-host queue and copy it to the UniFi.
1939 * Does nothing if the UniFi has no slots free.
1940 *
1941 * Arguments:
1942 * card Pointer to card context struct
1943 * processed Location to write:
1944 * 0 if there is nothing on the queue to process
1945 * 1 if a signal was successfully processed
1946 *
1947 * Returns:
1948 * CSR error code if an error occurred.
1949 *
1950 * Notes:
1951 * The from-host queue contains signal requests from the network driver
1952 * and any UDI clients interspersed. UDI clients' requests have been stored
1953 * in the from-host queue using the wire-format structures, as they arrive.
1954 * All other requests are stored in the from-host queue using the host
1955 * (cpu specific) structures. We use the is_packed member of the card_signal_t
1956 * structure that describes the queue to make the distinction.
1957 * ---------------------------------------------------------------------------
1958 */
1959static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed)
1960{
1961 q_t *sigq = &card->fh_command_queue;
1962
1963 CsrResult r;
1964 u16 pending_sigs;
1965 u16 pending_chunks;
1966 u16 needed_chunks;
1967 s32 space_chunks;
1968 u16 q_index;
1969
1970 *processed = 0;
1971
1972 /* Get the number of pending signals. */
1973 pending_sigs = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
1974 unifi_trace(card->ospriv, UDBG5, "proc_fh: %d pending\n", pending_sigs);
1975 if (pending_sigs == 0)
1976 {
1977 /* Nothing to do */
1978 return CSR_RESULT_SUCCESS;
1979 }
1980
1981 /* Work out how many chunks we have waiting to send */
1982 for (pending_chunks = 0, q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
1983 q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
1984 q_index = CSR_WIFI_HIP_Q_WRAP(sigq, q_index + 1))
1985 {
1986 card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
1987
1988 /*
1989 * Note that GET_CHUNKS_FOR() needs the size of the packed
1990 * (wire-formatted) structure
1991 */
1992 pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
1993 }
1994
1995 /*
1996 * Check whether UniFi has space for all the buffered bulk-data
1997 * commands and signals as well.
1998 */
1999 needed_chunks = pending_chunks + card->fh_buffer.count;
2000
2001 /* Round up to the block size if necessary */
2002 ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
2003
2004 r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
2005 if (r != CSR_RESULT_SUCCESS)
2006 {
2007 /* Error */
2008 unifi_error(card->ospriv, "Failed to read fh sig count\n");
2009 return r;
2010 }
2011
2012#ifdef CSR_WIFI_HIP_NOISY
2013 unifi_error(card->ospriv, "proc_fh: %d chunks free, need %d\n",
2014 space_chunks, needed_chunks);
2015#endif /* CSR_WIFI_HIP_NOISY */
2016
2017
2018 /*
2019 * Coalesce as many from-host signals as possible
2020 * into a single block and write using a single CMD53
2021 */
2022 if (needed_chunks > (u16)space_chunks)
2023 {
2024 /* Round up to the block size if necessary */
2025 ROUND_UP_SPACE_CHUNKS(card, space_chunks);
2026
2027 /*
2028 * If the f/w has less free chunks than those already pending
2029 * return immediately.
2030 */
2031 if ((u16)space_chunks <= card->fh_buffer.count)
2032 {
2033 /*
2034 * No room in UniFi for any signals after the buffered bulk
2035 * data commands have been sent.
2036 */
2037 unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
2038 card->fh_buffer.count, space_chunks);
2039 card->generate_interrupt = 1;
2040 return CSR_RESULT_SUCCESS;
2041 }
2042 pending_chunks = (u16)(space_chunks - card->fh_buffer.count);
2043 }
2044
2045 while (pending_sigs-- && pending_chunks > 0)
2046 {
2047 card_signal_t *csptr;
2048 s16 i;
2049 u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
2050 bulk_data_param_t bulkdata;
2051 u8 *packed_sigptr;
2052 u16 signal_length = 0;
2053
2054 /* Retrieve the entry at the head of the queue */
2055 q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
2056
2057 /* Get a pointer to the containing card_signal_t struct */
2058 csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
2059
2060 /* Get the new length of the packed signal */
2061 signal_length = csptr->signal_length;
2062
2063 if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
2064 {
2065 unifi_error(card->ospriv, "process_fh_queue: Bad len: %d\n", signal_length);
2066 return CSR_RESULT_FAILURE;
2067 }
2068
2069 /* Need space for 2-byte SDIO protocol header + signal */
2070 sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
2071
2072 free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
2073 (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
2074 if (free_chunks_in_fh_buffer < sig_chunks)
2075 {
2076 /* No more room */
2077 unifi_notice(card->ospriv, "proc_fh_cmd_q: no room in fh buffer for 0x%.4X, deferring\n",
2078 (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
2079 break;
2080 }
2081
2082 packed_sigptr = csptr->sigbuf;
2083
2084 /* Claim and set up a from-host data slot */
2085 if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, UNIFI_TRAFFIC_Q_MLME))
2086 {
2087 unifi_notice(card->ospriv, "proc_fh_cmd_q: no fh data slots for 0x%.4X, deferring\n",
2088 (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
2089 break;
2090 }
2091
2092 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
2093 {
2094 if (csptr->bulkdata[i].data_length == 0)
2095 {
2096 UNIFI_INIT_BULK_DATA(&bulkdata.d[i]);
2097 }
2098 else
2099 {
2100 bulkdata.d[i].os_data_ptr = csptr->bulkdata[i].os_data_ptr;
2101 bulkdata.d[i].data_length = csptr->bulkdata[i].data_length;
2102 }
2103
2104 /* Pass the free responsibility to the lower layer. */
2105 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
2106 }
2107
2108 unifi_trace(card->ospriv, UDBG2, "Sending signal 0x%.4X\n",
2109 GET_SIGNAL_ID(packed_sigptr));
2110#ifdef CSR_WIFI_HIP_NOISY
2111 unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
2112 GET_SIGNAL_ID(packed_sigptr));
2113#endif /* CSR_WIFI_HIP_NOISY */
2114
2115
2116 /* Append packed signal to F-H buffer */
2117 total_length = sig_chunks * card->config_data.sig_frag_size;
2118
2119 card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
2120 card->fh_buffer.ptr[1] =
2121 (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
2122
2123 memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
2124 memset(card->fh_buffer.ptr + 2 + signal_length, 0,
2125 total_length - (2 + signal_length));
2126
2127#ifdef CSR_WIFI_HIP_NOISY
2128 unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
2129 signal_length + 2);
2130 dump(card->fh_buffer.ptr, signal_length + 2);
2131 unifi_trace(card->ospriv, UDBG1, " \n");
2132#endif /* CSR_WIFI_HIP_NOISY */
2133
2134 card->fh_buffer.ptr += total_length;
2135 card->fh_buffer.count += sig_chunks;
2136
2137#ifdef CSR_WIFI_HIP_NOISY
2138 unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
2139 signal_length,
2140 card->fh_buffer.ptr - card->fh_buffer.buf,
2141 card->fh_buffer.count);
2142#endif /* CSR_WIFI_HIP_NOISY */
2143
2144 (*processed)++;
2145 pending_chunks -= sig_chunks;
2146
2147 /* Log the signal to the UDI. */
2148 /* UDI will get the packed structure */
2149 /* Can not log the unpacked signal, unless we reconstruct it! */
2150 if (card->udi_hook)
2151 {
2152 (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
2153 &bulkdata, UDI_LOG_FROM_HOST);
2154 }
2155
2156 /* Remove entry from q */
2157 csptr->signal_length = 0;
2158 CSR_WIFI_HIP_Q_INC_R(sigq);
2159 }
2160
2161 return CSR_RESULT_SUCCESS;
2162} /* process_fh_cmd_queue() */
2163
2164
2165/*
2166 * ---------------------------------------------------------------------------
2167 * process_fh_traffic_queue
2168 *
2169 * Take signals off the from-host queue and copy them to the UniFi.
2170 * Does nothing if the UniFi has no slots free.
2171 *
2172 * Arguments:
2173 * card Pointer to card context struct
2174 * sigq Pointer to the traffic queue
2175 * processed Pointer to location to write:
2176 * 0 if there is nothing on the queue to process
2177 * 1 if a signal was successfully processed
2178 *
2179 * Returns:
2180 * CSR error code if an error occurred.
2181 *
2182 * Notes:
2183 * The from-host queue contains signal requests from the network driver
2184 * and any UDI clients interspersed.
2185 * ---------------------------------------------------------------------------
2186 */
2187static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed)
2188{
2189 q_t *sigq = card->fh_traffic_queue;
2190
2191 CsrResult r;
2192 s16 n = 0;
2193 s32 q_no;
2194 u16 pending_sigs = 0;
2195 u16 pending_chunks = 0;
2196 u16 needed_chunks;
2197 s32 space_chunks;
2198 u16 q_index;
2199 u32 host_tag = 0;
2200 u16 slot_num = 0;
2201
2202 *processed = 0;
2203
2204 /* calculate how many signals are in queues and how many chunks are needed. */
2205 for (n = UNIFI_NO_OF_TX_QS - 1; n >= 0; n--)
2206 {
2207 /* Get the number of pending signals. */
2208 pending_sigs += CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[n]);
2209 unifi_trace(card->ospriv, UDBG5, "proc_fh%d: %d pending\n", n, pending_sigs);
2210
2211 /* Work out how many chunks we have waiting to send */
2212 for (q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[n]);
2213 q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(&sigq[n]);
2214 q_index = CSR_WIFI_HIP_Q_WRAP(&sigq[n], q_index + 1))
2215 {
2216 card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[n], q_index);
2217
2218 /*
2219 * Note that GET_CHUNKS_FOR() needs the size of the packed
2220 * (wire-formatted) structure
2221 */
2222 pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
2223 }
2224 }
2225
2226 /* If there are no pending signals, just return */
2227 if (pending_sigs == 0)
2228 {
2229 /* Nothing to do */
2230 return CSR_RESULT_SUCCESS;
2231 }
2232
2233 /*
2234 * Check whether UniFi has space for all the buffered bulk-data
2235 * commands and signals as well.
2236 */
2237 needed_chunks = pending_chunks + card->fh_buffer.count;
2238
2239 /* Round up to the block size if necessary */
2240 ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
2241
2242 r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
2243 if (r != CSR_RESULT_SUCCESS)
2244 {
2245 /* Error */
2246 unifi_error(card->ospriv, "Failed to read fh sig count\n");
2247 return r;
2248 }
2249
2250#ifdef CSR_WIFI_HIP_NOISY
2251 unifi_error(card->ospriv,
2252 "process_fh_traffic_queue: %d chunks free, need %d\n",
2253 space_chunks, needed_chunks);
2254 read_fhsr(card); /* debugging only */
2255#endif /* CSR_WIFI_HIP_NOISY */
2256
2257 /* Coalesce as many from-host signals as possible
2258 into a single block and write using a single CMD53 */
2259 if (needed_chunks > (u16)space_chunks)
2260 {
2261 /* Round up to the block size if necessary */
2262 ROUND_UP_SPACE_CHUNKS(card, space_chunks);
2263
2264 if ((u16)space_chunks <= card->fh_buffer.count)
2265 {
2266 /*
2267 * No room in UniFi for any signals after the buffered bulk
2268 * data commands have been sent.
2269 */
2270 unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
2271 card->fh_buffer.count, space_chunks);
2272 card->generate_interrupt = 1;
2273 return 0;
2274 }
2275
2276 pending_chunks = (u16)space_chunks - card->fh_buffer.count;
2277 }
2278
2279 q_no = UNIFI_NO_OF_TX_QS - 1;
2280
2281 /*
2282 * pending_sigs will be exhausted if there are is no restriction to the pending
2283 * signals per queue. pending_chunks may be exhausted if there is a restriction.
2284 * q_no check will be exhausted if there is a restriction and our round-robin
2285 * algorith fails to fill all chunks.
2286 */
2287 do
2288 {
2289 card_signal_t *csptr;
2290 u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
2291 bulk_data_param_t bulkdata;
2292 u8 *packed_sigptr;
2293 u16 signal_length = 0;
2294
2295 /* if this queue is empty go to next one. */
2296 if (CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[q_no]) == 0)
2297 {
2298 q_no--;
2299 continue;
2300 }
2301
2302 /* Retrieve the entry at the head of the queue */
2303 q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[q_no]);
2304
2305 /* Get a pointer to the containing card_signal_t struct */
2306 csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[q_no], q_index);
2307
2308 /* Get the new length of the packed signal */
2309 signal_length = csptr->signal_length;
2310
2311 if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
2312 {
2313 unifi_error(card->ospriv, "process_fh_traffic_queue: Bad len: %d\n", signal_length);
2314 return CSR_RESULT_FAILURE;
2315 }
2316
2317 /* Need space for 2-byte SDIO protocol header + signal */
2318 sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
2319 free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
2320 (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
2321 if (free_chunks_in_fh_buffer < sig_chunks)
2322 {
2323 /* No more room */
2324 unifi_notice(card->ospriv, "process_fh_traffic_queue: no more chunks.\n");
2325 break;
2326 }
2327
2328 packed_sigptr = csptr->sigbuf;
2329 /* Claim and set up a from-host data slot */
2330 if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, (unifi_TrafficQueue)q_no))
2331 {
2332 q_no--;
2333 continue;
2334 }
2335
2336 /* Sanity check: MA-PACKET.req must have a valid bulk data */
2337 if ((csptr->bulkdata[0].data_length == 0) || (csptr->bulkdata[0].os_data_ptr == NULL))
2338 {
2339 unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
2340 csptr->bulkdata[0].data_length, csptr->bulkdata[0].os_data_ptr);
2341 dump(packed_sigptr, signal_length);
2342 return CSR_RESULT_FAILURE;
2343 }
2344
2345 bulkdata.d[0].os_data_ptr = csptr->bulkdata[0].os_data_ptr;
2346 bulkdata.d[0].data_length = csptr->bulkdata[0].data_length;
2347 bulkdata.d[0].os_net_buf_ptr = csptr->bulkdata[0].os_net_buf_ptr;
2348 bulkdata.d[0].net_buf_length = csptr->bulkdata[0].net_buf_length;
2349
2350 /* The driver owns clearing of HIP slots for following scenario
2351 * - driver has requested a MA-PACKET.req signal
2352 * - The f/w after receiving the signal decides it can't send it out due to various reasons
2353 * - So the f/w without downloading the bulk data decides to just send a confirmation with fail
2354 * - and then sends a clear slot signal to HIP
2355 *
2356 * But in some cases the clear slot signal never comes and the slot remains --NOT-- freed for ever
2357 *
2358 * To handle this, HIP will keep the record of host tag for each occupied slot
2359 * and then based on status of that Host tag and slot the driver will decide if the slot is
2360 * cleared by f/w signal or the slot has to be freed by driver
2361 */
2362
2363 if (card->fh_slot_host_tag_record)
2364 {
2365 /* Update the f-h slot record for the corresponding host tag */
2366 host_tag = GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(packed_sigptr);
2367 slot_num = GET_PACKED_DATAREF_SLOT(packed_sigptr, 0) & 0x00FF;
2368
2369 unifi_trace(card->ospriv, UDBG5,
2370 "process_fh_traffic_queue signal ID =%x fh slot=%x Host tag =%x\n",
2371 GET_SIGNAL_ID(packed_sigptr), slot_num, host_tag);
2372 card->fh_slot_host_tag_record[slot_num] = host_tag;
2373 }
2374 UNIFI_INIT_BULK_DATA(&bulkdata.d[1]);
2375 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[0]);
2376 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[1]);
2377
2378#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
2379 if (bulkdata.d[0].os_data_ptr)
2380 {
2381 if ((*bulkdata.d[0].os_data_ptr) & 0x08)
2382 {
2383 card->cmd_prof.tx_count++;
2384 }
2385 }
2386#endif
2387 unifi_trace(card->ospriv, UDBG3, "Sending signal 0x%.4X\n",
2388 GET_SIGNAL_ID(packed_sigptr));
2389#ifdef CSR_WIFI_HIP_NOISY
2390 unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
2391 GET_SIGNAL_ID(packed_sigptr));
2392#endif /* CSR_WIFI_HIP_NOISY */
2393
2394 /* Append packed signal to F-H buffer */
2395 total_length = sig_chunks * card->config_data.sig_frag_size;
2396
2397 card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
2398 card->fh_buffer.ptr[1] =
2399 (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
2400
2401 memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
2402 memset(card->fh_buffer.ptr + 2 + signal_length, 0,
2403 total_length - (2 + signal_length));
2404
2405#ifdef CSR_WIFI_HIP_NOISY
2406 unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
2407 signal_length + 2);
2408 dump(card->fh_buffer.ptr, signal_length + 2);
2409 unifi_trace(card->ospriv, UDBG1, " \n");
2410#endif /* CSR_WIFI_HIP_NOISY */
2411
2412 card->fh_buffer.ptr += total_length;
2413 card->fh_buffer.count += sig_chunks;
2414
2415#ifdef CSR_WIFI_HIP_NOISY
2416 unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
2417 signal_length,
2418 card->fh_buffer.ptr - card->fh_buffer.buf,
2419 card->fh_buffer.count);
2420#endif /* CSR_WIFI_HIP_NOISY */
2421
2422 (*processed)++;
2423 pending_sigs--;
2424 pending_chunks -= sig_chunks;
2425
2426 /* Log the signal to the UDI. */
2427 /* UDI will get the packed structure */
2428 /* Can not log the unpacked signal, unless we reconstruct it! */
2429 if (card->udi_hook)
2430 {
2431 (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
2432 &bulkdata, UDI_LOG_FROM_HOST);
2433 }
2434
2435 /* Remove entry from q */
2436 csptr->signal_length = 0;
2437 /* Note that the traffic queue has only one valid bulk data buffer. */
2438 csptr->bulkdata[0].data_length = 0;
2439
2440 CSR_WIFI_HIP_Q_INC_R(&sigq[q_no]);
2441 } while ((pending_sigs > 0) && (pending_chunks > 0) && (q_no >= 0));
2442
2443 return CSR_RESULT_SUCCESS;
2444} /* process_fh_traffic_queue() */
2445
2446
2447/*
2448 * ---------------------------------------------------------------------------
2449 * flush_fh_buffer
2450 *
2451 * Write out the cache from-hosts signals to the UniFi.
2452 *
2453 * Arguments:
2454 * card Pointer to card context struct
2455 *
2456 * Returns:
2457 * CSR error code if an SDIO error occurred.
2458 * ---------------------------------------------------------------------------
2459 */
2460static CsrResult flush_fh_buffer(card_t *card)
2461{
2462 CsrResult r;
2463 u16 len;
2464 u16 sig_units;
2465 u16 data_round;
2466 u16 chunks_in_last_block;
2467 u16 padding_chunks;
2468 u16 i;
2469
2470 len = card->fh_buffer.ptr - card->fh_buffer.buf;
2471
2472#ifdef CSR_WIFI_HIP_NOISY
2473 unifi_error(card->ospriv, "fh_buffer is at %p, ptr= %p\n",
2474 card->fh_buffer.buf, card->fh_buffer.ptr);
2475#endif /* CSR_WIFI_HIP_NOISY */
2476
2477 if (len == 0)
2478 {
2479 return CSR_RESULT_SUCCESS;
2480 }
2481
2482#ifdef CSR_WIFI_HIP_NOISY
2483 if (dump_fh_buf)
2484 {
2485 dump(card->fh_buffer.buf, len);
2486 dump_fh_buf = 0;
2487 }
2488#endif /* CSR_WIFI_HIP_NOISY */
2489
2490 if (card->sdio_io_block_pad)
2491 {
2492 /* Both of these are powers of 2 */
2493 sig_units = card->config_data.sig_frag_size;
2494 data_round = card->sdio_io_block_size;
2495
2496 if (data_round > sig_units)
2497 {
2498 chunks_in_last_block = (len % data_round) / sig_units;
2499
2500 if (chunks_in_last_block != 0)
2501 {
2502 padding_chunks = (data_round / sig_units) - chunks_in_last_block;
2503
2504 memset(card->fh_buffer.ptr, 0, padding_chunks * sig_units);
2505 for (i = 0; i < padding_chunks; i++)
2506 {
2507 card->fh_buffer.ptr[1] = SDIO_CMD_PADDING << 4;
2508 card->fh_buffer.ptr += sig_units;
2509 }
2510
2511 card->fh_buffer.count += padding_chunks;
2512 len += padding_chunks * sig_units;
2513 }
2514 }
2515 }
2516
2517 r = unifi_bulk_rw(card,
2518 card->config_data.fromhost_sigbuf_handle,
2519 card->fh_buffer.buf,
2520 len, UNIFI_SDIO_WRITE);
2521 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2522 {
2523 return r;
2524 }
2525 if (r != CSR_RESULT_SUCCESS)
2526 {
2527 unifi_error(card->ospriv, "Failed to write fh signals: %u bytes, error %d\n", len, r);
2528 return r;
2529 }
2530
2531 /* Update from-host-signals-written signal count */
2532 card->from_host_signals_w =
2533 (card->from_host_signals_w + card->fh_buffer.count) % 128u;
2534 r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 0,
2535 (u8)card->from_host_signals_w);
2536 if (r != CSR_RESULT_SUCCESS)
2537 {
2538 unifi_error(card->ospriv, "Failed to write fh signal count %u with error %d\n",
2539 card->from_host_signals_w, r);
2540 return r;
2541 }
2542 card->generate_interrupt = 1;
2543
2544 /* Reset the fh buffer pointer */
2545 card->fh_buffer.ptr = card->fh_buffer.buf;
2546 card->fh_buffer.count = 0;
2547
2548#ifdef CSR_WIFI_HIP_NOISY
2549 unifi_error(card->ospriv, "END flush: fh len %d, count %d\n",
2550 card->fh_buffer.ptr - card->fh_buffer.buf,
2551 card->fh_buffer.count);
2552#endif /* CSR_WIFI_HIP_NOISY */
2553
2554 return CSR_RESULT_SUCCESS;
2555} /* flush_fh_buffer() */
2556
2557
2558/*
2559 * ---------------------------------------------------------------------------
2560 * restart_packet_flow
2561 *
2562 * This function is called before the bottom-half thread sleeps.
2563 * It checks whether both data and signal resources are available and
2564 * then calls the OS-layer function to re-enable packet transmission.
2565 *
2566 * Arguments:
2567 * card Pointer to card context struct
2568 *
2569 * Returns:
2570 * None.
2571 * ---------------------------------------------------------------------------
2572 */
2573static void restart_packet_flow(card_t *card)
2574{
2575 u8 q;
2576
2577 /*
2578 * We only look at the fh_traffic_queue, because that is where packets from
2579 * the network stack are placed.
2580 */
2581 for (q = 0; q <= UNIFI_TRAFFIC_Q_VO; q++)
2582 {
2583 if (card_is_tx_q_paused(card, q) &&
2584 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[q]) >= RESUME_XMIT_THRESHOLD)
2585 {
2586#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
2587 unifi_debug_log_to_buf("U");
2588#endif
2589 card_tx_q_unpause(card, q);
2590 unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue)q);
2591 }
2592 }
2593} /* restart_packet_flow() */
2594
2595
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
index 17867f60df16..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c
+++ /dev/null
@@ -1,1713 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_card_sdio_mem.c
14 *
15 * PURPOSE: Implementation of the Card API for SDIO.
16 *
17 * ---------------------------------------------------------------------------
18 */
19#include "csr_wifi_hip_unifi.h"
20#include "csr_wifi_hip_card.h"
21
22#define SDIO_RETRIES 3
23#define CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH 16
24
25
26#define retryable_sdio_error(_csrResult) (((_csrResult) == CSR_SDIO_RESULT_CRC_ERROR) || ((_csrResult) == CSR_SDIO_RESULT_TIMEOUT))
27
28
29/*
30 * ---------------------------------------------------------------------------
31 * retrying_read8
32 * retrying_write8
33 *
34 * These functions provide the first level of retry for SDIO operations.
35 * If an SDIO command fails for reason of a response timeout or CRC
36 * error, it is retried immediately. If three attempts fail we report a
37 * failure.
38 * If the command failed for any other reason, the failure is reported
39 * immediately.
40 *
41 * Arguments:
42 * card Pointer to card structure.
43 * funcnum The SDIO function to access.
44 * Function 0 is the Card Configuration Register space,
45 * function 1/2 is the UniFi register space.
46 * addr Address to access
47 * pdata Pointer in which to return the value read.
48 * data Value to write.
49 *
50 * Returns:
51 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
52 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
53 * CSR_RESULT_FAILURE an SDIO error occurred
54 * ---------------------------------------------------------------------------
55 */
56static CsrResult retrying_read8(card_t *card, s16 funcnum, u32 addr, u8 *pdata)
57{
58 CsrSdioFunction *sdio = card->sdio_if;
59 CsrResult r = CSR_RESULT_SUCCESS;
60 s16 retries;
61 CsrResult csrResult = CSR_RESULT_SUCCESS;
62
63 retries = 0;
64 while (retries++ < SDIO_RETRIES)
65 {
66 if (funcnum == 0)
67 {
68#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
69 unifi_debug_log_to_buf("r0@%02X", addr);
70#endif
71 csrResult = CsrSdioF0Read8(sdio, addr, pdata);
72 }
73 else
74 {
75#ifdef CSR_WIFI_TRANSPORT_CSPI
76 unifi_error(card->ospriv,
77 "retrying_read_f0_8: F1 8-bit reads are not allowed.\n");
78 return CSR_RESULT_FAILURE;
79#else
80#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
81 unifi_debug_log_to_buf("r@%02X", addr);
82#endif
83 csrResult = CsrSdioRead8(sdio, addr, pdata);
84#endif
85 }
86#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
87 if (csrResult != CSR_RESULT_SUCCESS)
88 {
89 unifi_debug_log_to_buf("error=%X\n", csrResult);
90 }
91 else
92 {
93 unifi_debug_log_to_buf("=%X\n", *pdata);
94 }
95#endif
96 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
97 {
98 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
99 }
100 /*
101 * Try again for retryable (CRC or TIMEOUT) errors,
102 * break on success or fatal error
103 */
104 if (!retryable_sdio_error(csrResult))
105 {
106#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
107 card->cmd_prof.cmd52_count++;
108#endif
109 break;
110 }
111 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
112 }
113
114 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
115 {
116 unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
117 }
118
119 if (csrResult != CSR_RESULT_SUCCESS)
120 {
121 unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
122 addr, retries - 1);
123 /* Report any SDIO error as a general i/o error */
124 r = CSR_RESULT_FAILURE;
125 }
126
127 return r;
128} /* retrying_read8() */
129
130
131static CsrResult retrying_write8(card_t *card, s16 funcnum, u32 addr, u8 data)
132{
133 CsrSdioFunction *sdio = card->sdio_if;
134 CsrResult r = CSR_RESULT_SUCCESS;
135 s16 retries;
136 CsrResult csrResult = CSR_RESULT_SUCCESS;
137
138 retries = 0;
139 while (retries++ < SDIO_RETRIES)
140 {
141 if (funcnum == 0)
142 {
143#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
144 unifi_debug_log_to_buf("w0@%02X=%X", addr, data);
145#endif
146 csrResult = CsrSdioF0Write8(sdio, addr, data);
147 }
148 else
149 {
150#ifdef CSR_WIFI_TRANSPORT_CSPI
151 unifi_error(card->ospriv,
152 "retrying_write_f0_8: F1 8-bit writes are not allowed.\n");
153 return CSR_RESULT_FAILURE;
154#else
155#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
156 unifi_debug_log_to_buf("w@%02X=%X", addr, data);
157#endif
158 csrResult = CsrSdioWrite8(sdio, addr, data);
159#endif
160 }
161#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
162 if (csrResult != CSR_RESULT_SUCCESS)
163 {
164 unifi_debug_log_to_buf(",error=%X", csrResult);
165 }
166 unifi_debug_string_to_buf("\n");
167#endif
168 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
169 {
170 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
171 }
172 /*
173 * Try again for retryable (CRC or TIMEOUT) errors,
174 * break on success or fatal error
175 */
176 if (!retryable_sdio_error(csrResult))
177 {
178#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
179 card->cmd_prof.cmd52_count++;
180#endif
181 break;
182 }
183 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
184 data, funcnum, addr);
185 }
186
187 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
188 {
189 unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
190 }
191
192 if (csrResult != CSR_RESULT_SUCCESS)
193 {
194 unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
195 addr, retries - 1);
196 /* Report any SDIO error as a general i/o error */
197 r = CSR_RESULT_FAILURE;
198 }
199
200 return r;
201} /* retrying_write8() */
202
203
204static CsrResult retrying_read16(card_t *card, s16 funcnum,
205 u32 addr, u16 *pdata)
206{
207 CsrSdioFunction *sdio = card->sdio_if;
208 CsrResult r = CSR_RESULT_SUCCESS;
209 s16 retries;
210 CsrResult csrResult = CSR_RESULT_SUCCESS;
211
212 retries = 0;
213 while (retries++ < SDIO_RETRIES)
214 {
215#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
216 unifi_debug_log_to_buf("r@%02X", addr);
217#endif
218 csrResult = CsrSdioRead16(sdio, addr, pdata);
219#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
220 if (csrResult != CSR_RESULT_SUCCESS)
221 {
222 unifi_debug_log_to_buf("error=%X\n", csrResult);
223 }
224 else
225 {
226 unifi_debug_log_to_buf("=%X\n", *pdata);
227 }
228#endif
229 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
230 {
231 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
232 }
233
234 /*
235 * Try again for retryable (CRC or TIMEOUT) errors,
236 * break on success or fatal error
237 */
238 if (!retryable_sdio_error(csrResult))
239 {
240#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
241 card->cmd_prof.cmd52_count++;
242#endif
243 break;
244 }
245 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
246 }
247
248 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
249 {
250 unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
251 }
252
253 if (csrResult != CSR_RESULT_SUCCESS)
254 {
255 unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
256 addr, retries - 1);
257 /* Report any SDIO error as a general i/o error */
258 r = CSR_RESULT_FAILURE;
259 }
260
261 return r;
262} /* retrying_read16() */
263
264
265static CsrResult retrying_write16(card_t *card, s16 funcnum,
266 u32 addr, u16 data)
267{
268 CsrSdioFunction *sdio = card->sdio_if;
269 CsrResult r = CSR_RESULT_SUCCESS;
270 s16 retries;
271 CsrResult csrResult = CSR_RESULT_SUCCESS;
272
273 retries = 0;
274 while (retries++ < SDIO_RETRIES)
275 {
276#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
277 unifi_debug_log_to_buf("w@%02X=%X", addr, data);
278#endif
279 csrResult = CsrSdioWrite16(sdio, addr, data);
280#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
281 if (csrResult != CSR_RESULT_SUCCESS)
282 {
283 unifi_debug_log_to_buf(",error=%X", csrResult);
284 }
285 unifi_debug_string_to_buf("\n");
286#endif
287 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
288 {
289 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
290 }
291
292 /*
293 * Try again for retryable (CRC or TIMEOUT) errors,
294 * break on success or fatal error
295 */
296 if (!retryable_sdio_error(csrResult))
297 {
298#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
299 card->cmd_prof.cmd52_count++;
300#endif
301 break;
302 }
303 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
304 data, funcnum, addr);
305 }
306
307 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
308 {
309 unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
310 }
311
312 if (csrResult != CSR_RESULT_SUCCESS)
313 {
314 unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
315 addr, retries - 1);
316 /* Report any SDIO error as a general i/o error */
317 r = CSR_RESULT_FAILURE;
318 }
319
320 return r;
321} /* retrying_write16() */
322
323
324/*
325 * ---------------------------------------------------------------------------
326 * sdio_read_f0
327 *
328 * Reads a byte value from the CCCR (func 0) area of UniFi.
329 *
330 * Arguments:
331 * card Pointer to card structure.
332 * addr Address to read from
333 * pdata Pointer in which to store the read value.
334 *
335 * Returns:
336 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
337 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
338 * CSR_RESULT_FAILURE an SDIO error occurred
339 * ---------------------------------------------------------------------------
340 */
341CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata)
342{
343#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
344 card->cmd_prof.cmd52_f0_r_count++;
345#endif
346 return retrying_read8(card, 0, addr, pdata);
347} /* sdio_read_f0() */
348
349
350/*
351 * ---------------------------------------------------------------------------
352 * sdio_write_f0
353 *
354 * Writes a byte value to the CCCR (func 0) area of UniFi.
355 *
356 * Arguments:
357 * card Pointer to card structure.
358 * addr Address to read from
359 * data Data value to write.
360 *
361 * Returns:
362 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
363 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
364 * CSR_RESULT_FAILURE an SDIO error occurred
365 * ---------------------------------------------------------------------------
366 */
367CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data)
368{
369#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
370 card->cmd_prof.cmd52_f0_w_count++;
371#endif
372 return retrying_write8(card, 0, addr, data);
373} /* sdio_write_f0() */
374
375
376/*
377 * ---------------------------------------------------------------------------
378 * unifi_read_direct_8_or_16
379 *
380 * Read a 8-bit value from the UniFi SDIO interface.
381 *
382 * Arguments:
383 * card Pointer to card structure.
384 * addr Address to read from
385 * pdata Pointer in which to return data.
386 *
387 * Returns:
388 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
389 * ---------------------------------------------------------------------------
390 */
391CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata)
392{
393#ifdef CSR_WIFI_TRANSPORT_CSPI
394 u16 w;
395 CsrResult r;
396
397 r = retrying_read16(card, card->function, addr, &w);
398 *pdata = (u8)(w & 0xFF);
399 return r;
400#else
401 return retrying_read8(card, card->function, addr, pdata);
402#endif
403} /* unifi_read_direct_8_or_16() */
404
405
406/*
407 * ---------------------------------------------------------------------------
408 * unifi_write_direct_8_or_16
409 *
410 * Write a byte value to the UniFi SDIO interface.
411 *
412 * Arguments:
413 * card Pointer to card structure.
414 * addr Address to write to
415 * data Value to write.
416 *
417 * Returns:
418 * CSR_RESULT_SUCCESS on success, non-zero error code on error
419 *
420 * Notes:
421 * If 8-bit write is used, the even address *must* be written second.
422 * This is because writes to odd bytes are cached and not committed
423 * to memory until the preceding even address is written.
424 * ---------------------------------------------------------------------------
425 */
426CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data)
427{
428 if (addr & 1)
429 {
430 unifi_warning(card->ospriv,
431 "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
432 addr);
433 }
434
435#ifdef CSR_WIFI_TRANSPORT_CSPI
436 return retrying_write16(card, card->function, addr, (u16)data);
437#else
438 return retrying_write8(card, card->function, addr, data);
439#endif
440} /* unifi_write_direct_8_or_16() */
441
442
443/*
444 * ---------------------------------------------------------------------------
445 * unifi_read_direct16
446 *
447 * Read a 16-bit value from the UniFi SDIO interface.
448 *
449 * Arguments:
450 * card Pointer to card structure.
451 * addr Address to read from
452 * pdata Pointer in which to return data.
453 *
454 * Returns:
455 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
456 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
457 * CSR_RESULT_FAILURE an SDIO error occurred
458 *
459 * Notes:
460 * The even address *must* be read first. This is because reads from
461 * odd bytes are cached and read from memory when the preceding
462 * even address is read.
463 * ---------------------------------------------------------------------------
464 */
465CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata)
466{
467 return retrying_read16(card, card->function, addr, pdata);
468} /* unifi_read_direct16() */
469
470
471/*
472 * ---------------------------------------------------------------------------
473 * unifi_write_direct16
474 *
475 * Write a 16-bit value to the UniFi SDIO interface.
476 *
477 * Arguments:
478 * card Pointer to card structure.
479 * addr Address to write to
480 * data Value to write.
481 *
482 * Returns:
483 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
484 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
485 * CSR_RESULT_FAILURE an SDIO error occurred
486 *
487 * Notes:
488 * The even address *must* be written second. This is because writes to
489 * odd bytes are cached and not committed to memory until the preceding
490 * even address is written.
491 * ---------------------------------------------------------------------------
492 */
493CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data)
494{
495 return retrying_write16(card, card->function, addr, data);
496} /* unifi_write_direct16() */
497
498
499/*
500 * ---------------------------------------------------------------------------
501 * unifi_read_direct32
502 *
503 * Read a 32-bit value from the UniFi SDIO interface.
504 *
505 * Arguments:
506 * card Pointer to card structure.
507 * addr Address to read from
508 * pdata Pointer in which to return data.
509 *
510 * Returns:
511 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
512 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
513 * CSR_RESULT_FAILURE an SDIO error occurred
514 * ---------------------------------------------------------------------------
515 */
516CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata)
517{
518 CsrResult r;
519 u16 w0, w1;
520
521 r = retrying_read16(card, card->function, addr, &w0);
522 if (r != CSR_RESULT_SUCCESS)
523 {
524 return r;
525 }
526
527 r = retrying_read16(card, card->function, addr + 2, &w1);
528 if (r != CSR_RESULT_SUCCESS)
529 {
530 return r;
531 }
532
533 *pdata = ((u32)w1 << 16) | (u32)w0;
534
535 return CSR_RESULT_SUCCESS;
536} /* unifi_read_direct32() */
537
538
539/*
540 * ---------------------------------------------------------------------------
541 * unifi_read_directn_match
542 *
543 * Read multiple 8-bit values from the UniFi SDIO interface,
544 * stopping when either we have read 'len' bytes or we have read
545 * a octet equal to 'match'. If 'match' is not a valid octet
546 * then this function is the same as 'unifi_read_directn'.
547 *
548 * Arguments:
549 * card Pointer to card structure.
550 * addr Start address to read from.
551 * pdata Pointer to which to write data.
552 * len Maximum umber of bytes to read
553 * match The value to stop reading at.
554 * num Pointer to buffer to write number of bytes read
555 *
556 * Returns:
557 * number of octets read on success, negative error code on error:
558 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
559 * CSR_RESULT_FAILURE an SDIO error occurred
560 *
561 * Notes:
562 * The even address *must* be read first. This is because reads from
563 * odd bytes are cached and read from memory when the preceding
564 * even address is read.
565 * ---------------------------------------------------------------------------
566 */
567static CsrResult unifi_read_directn_match(card_t *card, u32 addr, void *pdata, u16 len, s8 m, u32 *num)
568{
569 CsrResult r;
570 u32 i;
571 u8 *cptr;
572 u16 w;
573
574 *num = 0;
575
576 cptr = (u8 *)pdata;
577 for (i = 0; i < len; i += 2)
578 {
579 r = retrying_read16(card, card->function, addr, &w);
580 if (r != CSR_RESULT_SUCCESS)
581 {
582 return r;
583 }
584
585 *cptr++ = ((u8)w & 0xFF);
586 if ((m >= 0) && (((s8)w & 0xFF) == m))
587 {
588 break;
589 }
590
591 if (i + 1 == len)
592 {
593 /* The len is odd. Ignore the last high byte */
594 break;
595 }
596
597 *cptr++ = ((u8)(w >> 8) & 0xFF);
598 if ((m >= 0) && (((s8)(w >> 8) & 0xFF) == m))
599 {
600 break;
601 }
602
603 addr += 2;
604 }
605
606 *num = (s32)(cptr - (u8 *)pdata);
607 return CSR_RESULT_SUCCESS;
608}
609
610
611/*
612 * ---------------------------------------------------------------------------
613 * unifi_read_directn
614 *
615 * Read multiple 8-bit values from the UniFi SDIO interface.
616 *
617 * Arguments:
618 * card Pointer to card structure.
619 * addr Start address to read from.
620 * pdata Pointer to which to write data.
621 * len Number of bytes to read
622 *
623 * Returns:
624 * 0 on success, non-zero error code on error:
625 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
626 * CSR_RESULT_FAILURE an SDIO error occurred
627 *
628 * Notes:
629 * The even address *must* be read first. This is because reads from
630 * odd bytes are cached and read from memory when the preceding
631 * even address is read.
632 * ---------------------------------------------------------------------------
633 */
634CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len)
635{
636 u32 num;
637
638 return unifi_read_directn_match(card, addr, pdata, len, -1, &num);
639} /* unifi_read_directn() */
640
641
642/*
643 * ---------------------------------------------------------------------------
644 * unifi_write_directn
645 *
646 * Write multiple 8-bit values to the UniFi SDIO interface.
647 *
648 * Arguments:
649 * card Pointer to card structure.
650 * addr Start address to write to.
651 * pdata Source data pointer.
652 * len Number of bytes to write, must be even.
653 *
654 * Returns:
655 * 0 on success, non-zero error code on error:
656 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
657 * CSR_RESULT_FAILURE an SDIO error occurred
658 *
659 * Notes:
660 * The UniFi has a peculiar 16-bit bus architecture. Writes are only
661 * committed to memory when an even address is accessed. Writes to
662 * odd addresses are cached and only committed if the next write is
663 * to the preceding address.
664 * This means we must write data as pairs of bytes in reverse order.
665 * ---------------------------------------------------------------------------
666 */
667CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len)
668{
669 CsrResult r;
670 u8 *cptr;
671 s16 signed_len;
672
673 cptr = (u8 *)pdata;
674 signed_len = (s16)len;
675 while (signed_len > 0)
676 {
677 /* This is UniFi-1 specific code. CSPI not supported so 8-bit write allowed */
678 r = retrying_write16(card, card->function, addr, *cptr);
679 if (r != CSR_RESULT_SUCCESS)
680 {
681 return r;
682 }
683
684 cptr += 2;
685 addr += 2;
686 signed_len -= 2;
687 }
688
689 return CSR_RESULT_SUCCESS;
690} /* unifi_write_directn() */
691
692
693/*
694 * ---------------------------------------------------------------------------
695 * set_dmem_page
696 * set_pmem_page
697 *
698 * Set up the page register for the shared data memory window or program
699 * memory window.
700 *
701 * Arguments:
702 * card Pointer to card structure.
703 * dmem_addr UniFi shared-data-memory address to access.
704 * pmem_addr UniFi program memory address to access. This includes
705 * External FLASH memory at 0x000000
706 * Processor program memory at 0x200000
707 * External SRAM at memory 0x400000
708 * paddr Location to write an SDIO address (24-bit) for
709 * use in a unifi_read_direct or unifi_write_direct call.
710 *
711 * Returns:
712 * CSR_RESULT_SUCCESS on success
713 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
714 * CSR_RESULT_FAILURE an SDIO error occurred
715 * ---------------------------------------------------------------------------
716 */
717static CsrResult set_dmem_page(card_t *card, u32 dmem_addr, u32 *paddr)
718{
719 u16 page, addr;
720 u32 len;
721 CsrResult r;
722
723 *paddr = 0;
724
725 if (!ChipHelper_DecodeWindow(card->helper,
726 CHIP_HELPER_WINDOW_3,
727 CHIP_HELPER_WT_SHARED,
728 dmem_addr / 2,
729 &page, &addr, &len))
730 {
731 unifi_error(card->ospriv, "Failed to decode SHARED_DMEM_PAGE %08lx\n", dmem_addr);
732 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
733 }
734
735 if (page != card->dmem_page)
736 {
737 unifi_trace(card->ospriv, UDBG6, "setting dmem page=0x%X, addr=0x%lX\n", page, addr);
738
739 /* change page register */
740 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, page);
741 if (r != CSR_RESULT_SUCCESS)
742 {
743 unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
744 return r;
745 }
746
747 card->dmem_page = page;
748 }
749
750 *paddr = ((s32)addr * 2) + (dmem_addr & 1);
751
752 return CSR_RESULT_SUCCESS;
753} /* set_dmem_page() */
754
755
756static CsrResult set_pmem_page(card_t *card, u32 pmem_addr,
757 enum chip_helper_window_type mem_type, u32 *paddr)
758{
759 u16 page, addr;
760 u32 len;
761 CsrResult r;
762
763 *paddr = 0;
764
765 if (!ChipHelper_DecodeWindow(card->helper,
766 CHIP_HELPER_WINDOW_2,
767 mem_type,
768 pmem_addr / 2,
769 &page, &addr, &len))
770 {
771 unifi_error(card->ospriv, "Failed to decode PROG MEM PAGE %08lx %d\n", pmem_addr, mem_type);
772 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
773 }
774
775 if (page != card->pmem_page)
776 {
777 unifi_trace(card->ospriv, UDBG6, "setting pmem page=0x%X, addr=0x%lX\n", page, addr);
778
779 /* change page register */
780 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, page);
781 if (r != CSR_RESULT_SUCCESS)
782 {
783 unifi_error(card->ospriv, "Failed to write PROG MEM PAGE\n");
784 return r;
785 }
786
787 card->pmem_page = page;
788 }
789
790 *paddr = ((s32)addr * 2) + (pmem_addr & 1);
791
792 return CSR_RESULT_SUCCESS;
793} /* set_pmem_page() */
794
795
796/*
797 * ---------------------------------------------------------------------------
798 * set_page
799 *
800 * Sets up the appropriate page register to access the given address.
801 * Returns the sdio address at which the unifi address can be accessed.
802 *
803 * Arguments:
804 * card Pointer to card structure.
805 * generic_addr UniFi internal address to access, in Generic Pointer
806 * format, i.e. top byte is space indicator.
807 * paddr Location to write page address
808 * SDIO address (24-bit) for use in a unifi_read_direct or
809 * unifi_write_direct call
810 *
811 * Returns:
812 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
813 * CSR_RESULT_FAILURE an SDIO error occurred
814 * CSR_WIFI_HIP_RESULT_INVALID_VALUE the address is invalid
815 * ---------------------------------------------------------------------------
816 */
817static CsrResult set_page(card_t *card, u32 generic_addr, u32 *paddr)
818{
819 s32 space;
820 u32 addr;
821 CsrResult r = CSR_RESULT_SUCCESS;
822
823 if (!paddr)
824 {
825 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
826 }
827 *paddr = 0;
828 space = UNIFI_GP_SPACE(generic_addr);
829 addr = UNIFI_GP_OFFSET(generic_addr);
830 switch (space)
831 {
832 case UNIFI_SH_DMEM:
833 /* Shared Data Memory is accessed via the Shared Data Memory window */
834 r = set_dmem_page(card, addr, paddr);
835 if (r != CSR_RESULT_SUCCESS)
836 {
837 return r;
838 }
839 break;
840
841 case UNIFI_EXT_FLASH:
842 if (!ChipHelper_HasFlash(card->helper))
843 {
844 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
845 generic_addr, card->helper);
846 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
847 }
848 /* External FLASH is accessed via the Program Memory window */
849 r = set_pmem_page(card, addr, CHIP_HELPER_WT_FLASH, paddr);
850 break;
851
852 case UNIFI_EXT_SRAM:
853 if (!ChipHelper_HasExtSram(card->helper))
854 {
855 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08l (helper=0x%x)\n",
856 generic_addr, card->helper);
857 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
858 }
859 /* External SRAM is accessed via the Program Memory window */
860 r = set_pmem_page(card, addr, CHIP_HELPER_WT_EXT_SRAM, paddr);
861 break;
862
863 case UNIFI_REGISTERS:
864 /* Registers are accessed directly */
865 *paddr = addr;
866 break;
867
868 case UNIFI_PHY_DMEM:
869 r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
870 if (r != CSR_RESULT_SUCCESS)
871 {
872 return r;
873 }
874 *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
875 break;
876
877 case UNIFI_MAC_DMEM:
878 r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
879 if (r != CSR_RESULT_SUCCESS)
880 {
881 return r;
882 }
883 *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
884 break;
885
886 case UNIFI_BT_DMEM:
887 if (!ChipHelper_HasBt(card->helper))
888 {
889 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
890 generic_addr, card->helper);
891 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
892 }
893 r = unifi_set_proc_select(card, UNIFI_PROC_BT);
894 if (r != CSR_RESULT_SUCCESS)
895 {
896 return r;
897 }
898 *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
899 break;
900
901 case UNIFI_PHY_PMEM:
902 r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
903 if (r != CSR_RESULT_SUCCESS)
904 {
905 return r;
906 }
907 r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
908 break;
909
910 case UNIFI_MAC_PMEM:
911 r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
912 if (r != CSR_RESULT_SUCCESS)
913 {
914 return r;
915 }
916 r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
917 break;
918
919 case UNIFI_BT_PMEM:
920 if (!ChipHelper_HasBt(card->helper))
921 {
922 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
923 generic_addr, card->helper);
924 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
925 }
926 r = unifi_set_proc_select(card, UNIFI_PROC_BT);
927 if (r != CSR_RESULT_SUCCESS)
928 {
929 return r;
930 }
931 r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
932 break;
933
934 case UNIFI_PHY_ROM:
935 if (!ChipHelper_HasRom(card->helper))
936 {
937 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
938 generic_addr, card->helper);
939 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
940 }
941 r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
942 if (r != CSR_RESULT_SUCCESS)
943 {
944 return r;
945 }
946 r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
947 break;
948
949 case UNIFI_MAC_ROM:
950 if (!ChipHelper_HasRom(card->helper))
951 {
952 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
953 generic_addr, card->helper);
954 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
955 }
956 r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
957 if (r != CSR_RESULT_SUCCESS)
958 {
959 return r;
960 }
961 r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
962 break;
963
964 case UNIFI_BT_ROM:
965 if (!ChipHelper_HasRom(card->helper) || !ChipHelper_HasBt(card->helper))
966 {
967 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
968 generic_addr, card->helper);
969 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
970 }
971 r = unifi_set_proc_select(card, UNIFI_PROC_BT);
972 if (r != CSR_RESULT_SUCCESS)
973 {
974 return r;
975 }
976 r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
977 break;
978
979 default:
980 unifi_error(card->ospriv, "Bad address space %d in generic pointer 0x%08lX (helper=0x%x)\n",
981 space, generic_addr, card->helper);
982 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
983 }
984
985 return r;
986} /* set_page() */
987
988
989/*
990 * ---------------------------------------------------------------------------
991 * unifi_set_proc_select
992 *
993 *
994 * Arguments:
995 * card Pointer to card structure.
996 * select Which XAP core to select
997 *
998 * Returns:
999 * 0 on success, non-zero error code on error:
1000 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1001 * CSR_RESULT_FAILURE an SDIO error occurred
1002 * ---------------------------------------------------------------------------
1003 */
1004CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select)
1005{
1006 CsrResult r;
1007
1008 /* Verify the the select value is allowed. */
1009 switch (select)
1010 {
1011 case UNIFI_PROC_MAC:
1012 case UNIFI_PROC_PHY:
1013 case UNIFI_PROC_BOTH:
1014 break;
1015
1016
1017 default:
1018 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1019 }
1020
1021 if (card->proc_select != (u32)select)
1022 {
1023 r = unifi_write_direct16(card,
1024 ChipHelper_DBG_HOST_PROC_SELECT(card->helper) * 2,
1025 (u8)select);
1026 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1027 {
1028 return r;
1029 }
1030 if (r != CSR_RESULT_SUCCESS)
1031 {
1032 unifi_error(card->ospriv, "Failed to write to Proc Select register\n");
1033 return r;
1034 }
1035
1036 card->proc_select = (u32)select;
1037 }
1038
1039 return CSR_RESULT_SUCCESS;
1040}
1041
1042
1043/*
1044 * ---------------------------------------------------------------------------
1045 * unifi_read_8_or_16
1046 *
1047 * Performs a byte read of the given address in shared data memory.
1048 * Set up the shared data memory page register as required.
1049 *
1050 * Arguments:
1051 * card Pointer to card structure.
1052 * unifi_addr UniFi shared-data-memory address to access.
1053 * pdata Pointer to a byte variable for the value read.
1054 *
1055 * Returns:
1056 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1057 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1058 * CSR_RESULT_FAILURE an SDIO error occurred
1059 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1060 * ---------------------------------------------------------------------------
1061 */
1062CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata)
1063{
1064 u32 sdio_addr;
1065 CsrResult r;
1066#ifdef CSR_WIFI_TRANSPORT_CSPI
1067 u16 w;
1068#endif
1069
1070 r = set_page(card, unifi_addr, &sdio_addr);
1071 if (r != CSR_RESULT_SUCCESS)
1072 {
1073 return r;
1074 }
1075
1076#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1077 card->cmd_prof.cmd52_r8or16_count++;
1078#endif
1079#ifdef CSR_WIFI_TRANSPORT_CSPI
1080 r = retrying_read16(card, card->function, sdio_addr, &w);
1081 *pdata = (u8)(w & 0xFF);
1082 return r;
1083#else
1084 return retrying_read8(card, card->function, sdio_addr, pdata);
1085#endif
1086} /* unifi_read_8_or_16() */
1087
1088
1089/*
1090 * ---------------------------------------------------------------------------
1091 * unifi_write_8_or_16
1092 *
1093 * Performs a byte write of the given address in shared data memory.
1094 * Set up the shared data memory page register as required.
1095 *
1096 * Arguments:
1097 * card Pointer to card context struct.
1098 * unifi_addr UniFi shared-data-memory address to access.
1099 * data Value to write.
1100 *
1101 * Returns:
1102 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1103 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1104 * CSR_RESULT_FAILURE an SDIO error occurred
1105 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1106 *
1107 * Notes:
1108 * Beware using unifi_write8() because byte writes are not safe on UniFi.
1109 * Writes to odd bytes are cached, writes to even bytes perform a 16-bit
1110 * write with the previously cached odd byte.
1111 * ---------------------------------------------------------------------------
1112 */
1113CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data)
1114{
1115 u32 sdio_addr;
1116 CsrResult r;
1117#ifdef CSR_WIFI_TRANSPORT_CSPI
1118 u16 w;
1119#endif
1120
1121 r = set_page(card, unifi_addr, &sdio_addr);
1122 if (r != CSR_RESULT_SUCCESS)
1123 {
1124 return r;
1125 }
1126
1127 if (sdio_addr & 1)
1128 {
1129 unifi_warning(card->ospriv,
1130 "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
1131 sdio_addr);
1132 }
1133
1134#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1135 card->cmd_prof.cmd52_w8or16_count++;
1136#endif
1137#ifdef CSR_WIFI_TRANSPORT_CSPI
1138 w = data;
1139 return retrying_write16(card, card->function, sdio_addr, w);
1140#else
1141 return retrying_write8(card, card->function, sdio_addr, data);
1142#endif
1143} /* unifi_write_8_or_16() */
1144
1145
1146/*
1147 * ---------------------------------------------------------------------------
1148 * unifi_card_read16
1149 *
1150 * Performs a 16-bit read of the given address in shared data memory.
1151 * Set up the shared data memory page register as required.
1152 *
1153 * Arguments:
1154 * card Pointer to card structure.
1155 * unifi_addr UniFi shared-data-memory address to access.
1156 * pdata Pointer to a 16-bit int variable for the value read.
1157 *
1158 * Returns:
1159 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1160 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1161 * CSR_RESULT_FAILURE an SDIO error occurred
1162 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1163 * ---------------------------------------------------------------------------
1164 */
1165CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata)
1166{
1167 u32 sdio_addr;
1168 CsrResult r;
1169
1170 r = set_page(card, unifi_addr, &sdio_addr);
1171 if (r != CSR_RESULT_SUCCESS)
1172 {
1173 return r;
1174 }
1175
1176#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1177 card->cmd_prof.cmd52_r16_count++;
1178#endif
1179 return unifi_read_direct16(card, sdio_addr, pdata);
1180} /* unifi_card_read16() */
1181
1182
1183/*
1184 * ---------------------------------------------------------------------------
1185 * unifi_card_write16
1186 *
1187 * Performs a 16-bit write of the given address in shared data memory.
1188 * Set up the shared data memory page register as required.
1189 *
1190 * Arguments:
1191 * card Pointer to card structure.
1192 * unifi_addr UniFi shared-data-memory address to access.
1193 * pdata Pointer to a byte variable for the value write.
1194 *
1195 * Returns:
1196 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1197 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1198 * CSR_RESULT_FAILURE an SDIO error occurred
1199 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1200 * ---------------------------------------------------------------------------
1201 */
1202CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data)
1203{
1204 u32 sdio_addr;
1205 CsrResult r;
1206
1207 r = set_page(card, unifi_addr, &sdio_addr);
1208 if (r != CSR_RESULT_SUCCESS)
1209 {
1210 return r;
1211 }
1212
1213#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1214 card->cmd_prof.cmd52_w16_count++;
1215#endif
1216 return unifi_write_direct16(card, sdio_addr, data);
1217} /* unifi_card_write16() */
1218
1219
1220/*
1221 * ---------------------------------------------------------------------------
1222 * unifi_read32
1223 *
1224 * Performs a 32-bit read of the given address in shared data memory.
1225 * Set up the shared data memory page register as required.
1226 *
1227 * Arguments:
1228 * card Pointer to card structure.
1229 * unifi_addr UniFi shared-data-memory address to access.
1230 * pdata Pointer to a int variable for the value read.
1231 *
1232 * Returns:
1233 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1234 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1235 * CSR_RESULT_FAILURE an SDIO error occurred
1236 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1237 * ---------------------------------------------------------------------------
1238 */
1239CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata)
1240{
1241 u32 sdio_addr;
1242 CsrResult r;
1243
1244 r = set_page(card, unifi_addr, &sdio_addr);
1245 if (r != CSR_RESULT_SUCCESS)
1246 {
1247 return r;
1248 }
1249
1250#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1251 card->cmd_prof.cmd52_r32_count++;
1252#endif
1253 return unifi_read_direct32(card, sdio_addr, pdata);
1254} /* unifi_read32() */
1255
1256
1257/*
1258 * ---------------------------------------------------------------------------
1259 * unifi_card_readn
1260 * unifi_readnz
1261 *
1262 * Read multiple 8-bit values from the UniFi SDIO interface.
1263 * This function interprets the address as a GenericPointer as
1264 * defined in the UniFi Host Interface Protocol Specification.
1265 * The readnz version of this function will stop when it reads a
1266 * zero octet.
1267 *
1268 * Arguments:
1269 * card Pointer to card structure.
1270 * unifi_addr UniFi shared-data-memory address to access.
1271 * pdata Pointer to which to write data.
1272 * len Number of bytes to read
1273 *
1274 * Returns:
1275 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1276 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1277 * CSR_RESULT_FAILURE an SDIO error occurred
1278 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1279 * ---------------------------------------------------------------------------
1280 */
1281CsrResult unifi_readn_match(card_t *card, u32 unifi_addr, void *pdata, u16 len, s8 match)
1282{
1283 u32 sdio_addr;
1284 CsrResult r;
1285 u32 num;
1286
1287 r = set_page(card, unifi_addr, &sdio_addr);
1288 if (r != CSR_RESULT_SUCCESS)
1289 {
1290 return r;
1291 }
1292
1293 r = unifi_read_directn_match(card, sdio_addr, pdata, len, match, &num);
1294 return r;
1295} /* unifi_readn_match() */
1296
1297
1298CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len)
1299{
1300 return unifi_readn_match(card, unifi_addr, pdata, len, -1);
1301} /* unifi_card_readn() */
1302
1303
1304CsrResult unifi_readnz(card_t *card, u32 unifi_addr, void *pdata, u16 len)
1305{
1306 return unifi_readn_match(card, unifi_addr, pdata, len, 0);
1307} /* unifi_readnz() */
1308
1309
1310/*
1311 * ---------------------------------------------------------------------------
1312 * unifi_read_shared_count
1313 *
1314 * Read signal count locations, checking for an SDIO error. The
1315 * signal count locations only contain a valid number if the
1316 * highest bit isn't set.
1317 *
1318 * Arguments:
1319 * card Pointer to card context structure.
1320 * addr Shared-memory address to read.
1321 *
1322 * Returns:
1323 * Value read from memory (0-127) or -1 on error
1324 * ---------------------------------------------------------------------------
1325 */
1326s32 unifi_read_shared_count(card_t *card, u32 addr)
1327{
1328 u8 b;
1329 /* I've increased this count, because I have seen cases where
1330 * there were three reads in a row with the top bit set. I'm not
1331 * sure why this might have happened, but I can't see a problem
1332 * with increasing this limit. It's better to take a while to
1333 * recover than to fail. */
1334#define SHARED_READ_RETRY_LIMIT 10
1335 s32 i;
1336
1337 /*
1338 * Get the to-host-signals-written count.
1339 * The top-bit will be set if the firmware was in the process of
1340 * changing the value, in which case we read again.
1341 */
1342 /* Limit the number of repeats so we don't freeze */
1343 for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
1344 {
1345 CsrResult r;
1346 r = unifi_read_8_or_16(card, addr, &b);
1347 if (r != CSR_RESULT_SUCCESS)
1348 {
1349 return -1;
1350 }
1351 if (!(b & 0x80))
1352 {
1353 /* There is a chance that the MSB may have contained invalid data
1354 * (overflow) at the time it was read. Therefore mask off the MSB.
1355 * This avoids a race between driver read and firmware write of the
1356 * word, the value we need is in the lower 8 bits anway.
1357 */
1358 return (s32)(b & 0xff);
1359 }
1360 }
1361
1362 return -1; /* this function has changed in WMM mods */
1363} /* unifi_read_shared_count() */
1364
1365
1366/*
1367 * ---------------------------------------------------------------------------
1368 * unifi_writen
1369 *
1370 * Write multiple 8-bit values to the UniFi SDIO interface using CMD52
1371 * This function interprets the address as a GenericPointer as
1372 * defined in the UniFi Host Interface Protocol Specification.
1373 *
1374 * Arguments:
1375 * card Pointer to card structure.
1376 * unifi_addr UniFi shared-data-memory address to access.
1377 * pdata Pointer to which to write data.
1378 * len Number of bytes to write
1379 *
1380 * Returns:
1381 * 0 on success, non-zero error code on error:
1382 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1383 * CSR_RESULT_FAILURE an SDIO error occurred
1384 * CSR_WIFI_HIP_RESULT_INVALID_VALUE an odd length or length too big.
1385 * ---------------------------------------------------------------------------
1386 */
1387CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len)
1388{
1389 u32 sdio_addr;
1390 CsrResult r;
1391
1392 r = set_page(card, unifi_addr, &sdio_addr);
1393 if (r != CSR_RESULT_SUCCESS)
1394 {
1395 return r;
1396 }
1397
1398 return unifi_write_directn(card, sdio_addr, pdata, len);
1399} /* unifi_writen() */
1400
1401
1402static CsrResult csr_sdio_block_rw(card_t *card, s16 funcnum,
1403 u32 addr, u8 *pdata,
1404 u16 count, s16 dir_is_write)
1405{
1406 CsrResult csrResult;
1407
1408 if (dir_is_write == UNIFI_SDIO_READ)
1409 {
1410#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1411 unifi_debug_log_to_buf("r@%02X#%X=", addr, count);
1412#endif
1413#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1414 unifi_debug_log_to_buf("R");
1415#endif
1416 csrResult = CsrSdioRead(card->sdio_if, addr, pdata, count);
1417#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1418 unifi_debug_log_to_buf("<");
1419#endif
1420 }
1421 else
1422 {
1423#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1424 unifi_debug_log_to_buf("w@%02X#%X=", addr, count);
1425 unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
1426#endif
1427#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1428 unifi_debug_log_to_buf("W");
1429#endif
1430 csrResult = CsrSdioWrite(card->sdio_if, addr, pdata, count);
1431#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1432 unifi_debug_log_to_buf(">");
1433#endif
1434 }
1435#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
1436 card->cmd_prof.cmd53_count++;
1437#endif
1438#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1439 if (csrResult != CSR_RESULT_SUCCESS)
1440 {
1441 unifi_debug_log_to_buf("error=%X", csrResult);
1442 }
1443 else if (dir_is_write == UNIFI_SDIO_READ)
1444 {
1445 unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
1446 }
1447 unifi_debug_string_to_buf("\n");
1448#endif
1449 return csrResult; /* CSR SDIO (not HIP) error code */
1450}
1451
1452
1453/*
1454 * ---------------------------------------------------------------------------
1455 * unifi_bulk_rw
1456 *
1457 * Transfer bulk data to or from the UniFi SDIO interface.
1458 * This function is used to read or write signals and bulk data.
1459 *
1460 * Arguments:
1461 * card Pointer to card structure.
1462 * handle Value to put in the Register Address field of the CMD53 req.
1463 * data Pointer to data to write.
1464 * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
1465 *
1466 * Returns:
1467 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1468 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1469 * CSR_RESULT_FAILURE an SDIO error occurred
1470 *
1471 * Notes:
1472 * This function uses SDIO CMD53, which is the block transfer mode.
1473 * ---------------------------------------------------------------------------
1474 */
1475CsrResult unifi_bulk_rw(card_t *card, u32 handle, void *pdata,
1476 u32 len, s16 direction)
1477{
1478#define CMD53_RETRIES 3
1479 /*
1480 * Ideally instead of sleeping, we want to busy wait.
1481 * Currently there is no framework API to do this. When it becomes available,
1482 * we can use it to busy wait using usecs
1483 */
1484#define REWIND_RETRIES 15 /* when REWIND_DELAY==1msec, or 250 when REWIND_DELAY==50usecs */
1485#define REWIND_POLLING_RETRIES 5
1486#define REWIND_DELAY 1 /* msec or 50usecs */
1487 CsrResult csrResult; /* SDIO error code */
1488 CsrResult r = CSR_RESULT_SUCCESS; /* HIP error code */
1489 s16 retries = CMD53_RETRIES;
1490 s16 stat_retries;
1491 u8 stat;
1492 s16 dump_read;
1493#ifdef UNIFI_DEBUG
1494 u8 *pdata_lsb = ((u8 *)&pdata) + card->lsb;
1495#endif
1496#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
1497 static s16 fake_error;
1498#endif
1499
1500 dump_read = 0;
1501#ifdef UNIFI_DEBUG
1502 if (*pdata_lsb & 1)
1503 {
1504 unifi_notice(card->ospriv, "CD53 request on a unaligned buffer (addr: 0x%X) dir %s-Host\n",
1505 pdata, (direction == UNIFI_SDIO_READ)?"To" : "From");
1506 if (direction == UNIFI_SDIO_WRITE)
1507 {
1508 dump(pdata, (u16)len);
1509 }
1510 else
1511 {
1512 dump_read = 1;
1513 }
1514 }
1515#endif
1516
1517 /* Defensive checks */
1518 if (!pdata)
1519 {
1520 unifi_error(card->ospriv, "Null pdata for unifi_bulk_rw() len: %d\n", len);
1521 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1522 }
1523 if ((len & 1) || (len > 0xffff))
1524 {
1525 unifi_error(card->ospriv, "Impossible CMD53 length requested: %d\n", len);
1526 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1527 }
1528
1529 while (1)
1530 {
1531 csrResult = csr_sdio_block_rw(card, card->function, handle,
1532 (u8 *)pdata, (u16)len,
1533 direction);
1534 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
1535 {
1536 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
1537 }
1538#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
1539 if (++fake_error > 100)
1540 {
1541 fake_error = 90;
1542 unifi_warning(card->ospriv, "Faking a CMD53 error,\n");
1543 if (csrResult == CSR_RESULT_SUCCESS)
1544 {
1545 csrResult = CSR_RESULT_FAILURE;
1546 }
1547 }
1548#endif
1549 if (csrResult == CSR_RESULT_SUCCESS)
1550 {
1551 if (dump_read)
1552 {
1553 dump(pdata, (u16)len);
1554 }
1555 break;
1556 }
1557
1558 /*
1559 * At this point the SDIO driver should have written the I/O Abort
1560 * register to notify UniFi that the command has failed.
1561 * UniFi-1 and UniFi-2 (not UF6xxx) use the same register to store the
1562 * Deep Sleep State. This means we have to restore the Deep Sleep
1563 * State (AWAKE in any case since we can not perform a CD53 in any other
1564 * state) by rewriting the I/O Abort register to its previous value.
1565 */
1566 if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
1567 {
1568 (void)unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
1569 }
1570
1571 /* If csr_sdio_block_rw() failed in a non-retryable way, or retries exhausted
1572 * then stop retrying
1573 */
1574 if (!retryable_sdio_error(csrResult))
1575 {
1576 unifi_error(card->ospriv, "Fatal error in a CMD53 transfer\n");
1577 break;
1578 }
1579
1580 /*
1581 * These happen from time to time, try again
1582 */
1583 if (--retries == 0)
1584 {
1585 break;
1586 }
1587
1588 unifi_trace(card->ospriv, UDBG4,
1589 "Error in a CMD53 transfer, retrying (h:%d,l:%u)...\n",
1590 (s16)handle & 0xff, len);
1591
1592 /* The transfer failed, rewind and try again */
1593 r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 8,
1594 (u8)(handle & 0xff));
1595 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1596 {
1597 return r;
1598 }
1599 if (r != CSR_RESULT_SUCCESS)
1600 {
1601 /*
1602 * If we can't even do CMD52 (register read/write) then
1603 * stop here.
1604 */
1605 unifi_error(card->ospriv, "Failed to write REWIND cmd\n");
1606 return r;
1607 }
1608
1609 /* Signal the UniFi to look for the rewind request. */
1610 r = CardGenInt(card);
1611 if (r != CSR_RESULT_SUCCESS)
1612 {
1613 return r;
1614 }
1615
1616 /* Wait for UniFi to acknowledge the rewind */
1617 stat_retries = REWIND_RETRIES;
1618 while (1)
1619 {
1620 r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 8, &stat);
1621 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1622 {
1623 return r;
1624 }
1625 if (r != CSR_RESULT_SUCCESS)
1626 {
1627 unifi_error(card->ospriv, "Failed to read REWIND status\n");
1628 return CSR_RESULT_FAILURE;
1629 }
1630
1631 if (stat == 0)
1632 {
1633 break;
1634 }
1635 if (--stat_retries == 0)
1636 {
1637 unifi_error(card->ospriv, "Timeout waiting for REWIND ready\n");
1638 return CSR_RESULT_FAILURE;
1639 }
1640
1641 /* Poll for the ack a few times */
1642 if (stat_retries < REWIND_RETRIES - REWIND_POLLING_RETRIES)
1643 {
1644 CsrThreadSleep(REWIND_DELAY);
1645 }
1646 }
1647 }
1648
1649 /* The call to csr_sdio_block_rw() still failed after retrying */
1650 if (csrResult != CSR_RESULT_SUCCESS)
1651 {
1652 unifi_error(card->ospriv, "Block %s failed after %d retries\n",
1653 (direction == UNIFI_SDIO_READ)?"read" : "write",
1654 CMD53_RETRIES - retries);
1655 /* Report any SDIO error as a general i/o error */
1656 return CSR_RESULT_FAILURE;
1657 }
1658
1659 /* Collect some stats */
1660 if (direction == UNIFI_SDIO_READ)
1661 {
1662 card->sdio_bytes_read += len;
1663 }
1664 else
1665 {
1666 card->sdio_bytes_written += len;
1667 }
1668
1669 return CSR_RESULT_SUCCESS;
1670} /* unifi_bulk_rw() */
1671
1672
1673/*
1674 * ---------------------------------------------------------------------------
1675 * unifi_bulk_rw_noretry
1676 *
1677 * Transfer bulk data to or from the UniFi SDIO interface.
1678 * This function is used to read or write signals and bulk data.
1679 *
1680 * Arguments:
1681 * card Pointer to card structure.
1682 * handle Value to put in the Register Address field of
1683 * the CMD53 req.
1684 * data Pointer to data to write.
1685 * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
1686 *
1687 * Returns:
1688 * 0 on success, non-zero error code on error:
1689 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1690 * CSR_RESULT_FAILURE an SDIO error occurred
1691 *
1692 * Notes:
1693 * This function uses SDIO CMD53, which is the block transfer mode.
1694 * ---------------------------------------------------------------------------
1695 */
1696CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle, void *pdata,
1697 u32 len, s16 direction)
1698{
1699 CsrResult csrResult;
1700
1701 csrResult = csr_sdio_block_rw(card, card->function, handle,
1702 (u8 *)pdata, (u16)len, direction);
1703 if (csrResult != CSR_RESULT_SUCCESS)
1704 {
1705 unifi_error(card->ospriv, "Block %s failed\n",
1706 (direction == UNIFI_SDIO_READ)?"read" : "write");
1707 return csrResult;
1708 }
1709
1710 return CSR_RESULT_SUCCESS;
1711} /* unifi_bulk_rw_noretry() */
1712
1713
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.c b/drivers/staging/csr/csr_wifi_hip_chiphelper.c
deleted file mode 100644
index 5cf5b8a5a1e1..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_chiphelper.c
+++ /dev/null
@@ -1,793 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include "csr_macro.h"
12#include "csr_wifi_hip_chiphelper_private.h"
13
14#ifndef nelem
15#define nelem(a) (sizeof(a) / sizeof(a[0]))
16#endif
17
18#define counted(foo) { nelem(foo), foo }
19#define null_counted() { 0, NULL }
20
21/* The init values are a set of register writes that we must
22 perform when we first connect to the chip to get it working.
23 They swicth on the correct clocks and possibly set the host
24 interface as a wkaeup source. They should not be used if
25 proper HIP opperation is required, but are useful before we
26 do a code download. */
27static const struct chip_helper_init_values init_vals_v1[] = {
28 { 0xFDBB, 0xFFFF },
29 { 0xFDB6, 0x03FF },
30 { 0xFDB1, 0x01E3 },
31 { 0xFDB3, 0x0FFF },
32 { 0xFEE3, 0x08F0 },
33 { 0xFEE7, 0x3C3F },
34 { 0xFEE6, 0x0050 },
35 { 0xFDBA, 0x0000 }
36};
37
38static const struct chip_helper_init_values init_vals_v2[] = {
39 { 0xFDB6, 0x0FFF },
40 { 0xF023, 0x3F3F },
41 { 0xFDB1, 0x01E3 },
42 { 0xFDB3, 0x0FFF },
43 { 0xF003, 0x08F0 },
44 { 0xF007, 0x3C3F },
45 { 0xF006, 0x0050 }
46};
47
48
49static const struct chip_helper_init_values init_vals_v22_v23[] = {
50 { 0xF81C, 0x00FF },
51 /*{ 0x????, 0x???? }, */
52 { 0xF80C, 0x1FFF },
53 { 0xFA25, 0x001F },
54 { 0xF804, 0x00FF },
55 { 0xF802, 0x0FFF },
56 /*{ 0x????, 0x???? },
57 { 0x????, 0x???? },
58 { 0x????, 0x???? }*/
59};
60
61static const u16 reset_program_a_v1_or_v2[] = {
62 0x0000
63};
64static const u16 reset_program_b_v1_or_v2[] = {
65 0x0010, 0xFE00, 0xA021, 0xFF00, 0x8111, 0x0009, 0x0CA4, 0x0114,
66 0x0280, 0x04F8, 0xFE00, 0x6F25, 0x06E0, 0x0010, 0xFC00, 0x0121,
67 0xFC00, 0x0225, 0xFE00, 0x7125, 0xFE00, 0x6D11, 0x03F0, 0xFE00,
68 0x6E25, 0x0008, 0x00E0
69};
70
71static const struct chip_helper_reset_values reset_program_v1_or_v2[] =
72{
73 {
74 MAKE_GP(REGISTERS, 0x000C),
75 nelem(reset_program_a_v1_or_v2),
76 reset_program_a_v1_or_v2
77 },
78 {
79 MAKE_GP(MAC_PMEM, 0x000000),
80 nelem(reset_program_b_v1_or_v2),
81 reset_program_b_v1_or_v2
82 }
83};
84
85static const struct chip_map_address_t unifi_map_address_v1_v2[] =
86{
87 { 0xFE9F, 0xFE7B }, /* PM1_BANK_SELECT */
88 { 0xFE9E, 0xFE78 }, /* PM2_BANK_SELECT */
89 { 0xFE9D, 0xFE7E }, /* SHARED_DMEM_PAGE */
90 { 0xFE91, 0xFE90 }, /* PROC_SELECT */
91 { 0xFE8D, 0xFE8C }, /* STOP_STATUS */
92};
93
94static const struct chip_map_address_t unifi_map_address_v22_v23[] =
95{
96 { 0xF8F9, 0xF8AC }, /* GW1_CONFIG */
97 { 0xF8FA, 0xF8AD }, /* GW2_CONFIG */
98 { 0xF8FB, 0xF8AE }, /* GW3_CONFIG */
99 { 0xF830, 0xF81E }, /* PROC_SELECT */
100 { 0xF831, 0xF81F }, /* STOP_STATUS */
101 { 0xF8FC, 0xF8AF }, /* IO_LOG_ADDRESS */
102};
103
104static const struct chip_device_regs_t unifi_device_regs_null =
105{
106 0xFE81, /* GBL_CHIP_VERSION */
107 0x0000, /* GBL_MISC_ENABLES */
108 0x0000, /* DBG_EMU_CMD */
109 {
110 0x0000, /* HOST.DBG_PROC_SELECT */
111 0x0000, /* HOST.DBG_STOP_STATUS */
112 0x0000, /* HOST.WINDOW1_PAGE */
113 0x0000, /* HOST.WINDOW2_PAGE */
114 0x0000, /* HOST.WINDOW3_PAGE */
115 0x0000 /* HOST.IO_LOG_ADDR */
116 },
117 {
118 0x0000, /* SPI.DBG_PROC_SELECT */
119 0x0000, /* SPI.DBG_STOP_STATUS */
120 0x0000, /* SPI.WINDOW1_PAGE */
121 0x0000, /* SPI.WINDOW2_PAGE */
122 0x0000, /* SPI.WINDOW3_PAGE */
123 0x0000 /* SPI.IO_LOG_ADDR */
124 },
125 0x0000, /* DBG_RESET */
126 0x0000, /* > DBG_RESET_VALUE */
127 0x0000, /* DBG_RESET_WARN */
128 0x0000, /* DBG_RESET_WARN_VALUE */
129 0x0000, /* DBG_RESET_RESULT */
130 0xFFE9, /* XAP_PCH */
131 0xFFEA, /* XAP_PCL */
132 0x0000, /* PROC_PC_SNOOP */
133 0x0000, /* WATCHDOG_DISABLE */
134 0x0000, /* MAILBOX0 */
135 0x0000, /* MAILBOX1 */
136 0x0000, /* MAILBOX2 */
137 0x0000, /* MAILBOX3 */
138 0x0000, /* SDIO_HOST_INT */
139 0x0000, /* SHARED_IO_INTERRUPT */
140 0x0000, /* SDIO HIP HANDSHAKE */
141 0x0000 /* COEX_STATUS */
142};
143
144/* UF105x */
145static const struct chip_device_regs_t unifi_device_regs_v1 =
146{
147 0xFE81, /* GBL_CHIP_VERSION */
148 0xFE87, /* GBL_MISC_ENABLES */
149 0xFE9C, /* DBG_EMU_CMD */
150 {
151 0xFE90, /* HOST.DBG_PROC_SELECT */
152 0xFE8C, /* HOST.DBG_STOP_STATUS */
153 0xFE7B, /* HOST.WINDOW1_PAGE */
154 0xFE78, /* HOST.WINDOW2_PAGE */
155 0xFE7E, /* HOST.WINDOW3_PAGE */
156 0x0000 /* HOST.IO_LOG_ADDR */
157 },
158 {
159 0xFE91, /* SPI.DBG_PROC_SELECT */
160 0xFE8D, /* SPI.DBG_STOP_STATUS */
161 0xFE9F, /* SPI.WINDOW1_PAGE */
162 0xFE9E, /* SPI.WINDOW2_PAGE */
163 0xFE9D, /* SPI.WINDOW3_PAGE */
164 0x0000 /* SPI.IO_LOG_ADDR */
165 },
166 0xFE92, /* DBG_RESET */
167 0x0001, /* > DBG_RESET_VALUE */
168 0xFDA0, /* DBG_RESET_WARN (HOST_SELECT) */
169 0x0000, /* DBG_RESET_WARN_VALUE */
170 0xFE92, /* DBG_RESET_RESULT */
171 0xFFE9, /* XAP_PCH */
172 0xFFEA, /* XAP_PCL */
173 0x0051, /* PROC_PC_SNOOP */
174 0xFE70, /* WATCHDOG_DISABLE */
175 0xFE6B, /* MAILBOX0 */
176 0xFE6A, /* MAILBOX1 */
177 0xFE69, /* MAILBOX2 */
178 0xFE68, /* MAILBOX3 */
179 0xFE67, /* SDIO_HOST_INT */
180 0xFE65, /* SHARED_IO_INTERRUPT */
181 0xFDE9, /* SDIO HIP HANDSHAKE */
182 0x0000 /* COEX_STATUS */
183};
184
185/* UF2... */
186static const struct chip_device_regs_t unifi_device_regs_v2 =
187{
188 0xFE81, /* GBL_CHIP_VERSION */
189 0xFE87, /* GBL_MISC_ENABLES */
190 0xFE9C, /* DBG_EMU_CMD */
191 {
192 0xFE90, /* HOST.DBG_PROC_SELECT */
193 0xFE8C, /* HOST.DBG_STOP_STATUS */
194 0xFE7B, /* HOST.WINDOW1_PAGE */
195 0xFE78, /* HOST.WINDOW2_PAGE */
196 0xFE7E, /* HOST.WINDOW3_PAGE */
197 0x0000 /* HOST.IO_LOG_ADDR */
198 },
199 {
200 0xFE91, /* SPI.DBG_PROC_SELECT */
201 0xFE8D, /* SPI.DBG_STOP_STATUS */
202 0xFE9F, /* SPI.WINDOW1_PAGE */
203 0xFE9E, /* SPI.WINDOW2_PAGE */
204 0xFE9D, /* SPI.WINDOW3_PAGE */
205 0x0000 /* SPI.IO_LOG_ADDR */
206 },
207 0xFE92, /* DBG_RESET */
208 0x0000, /* > DBG_RESET_VALUE */
209 0xFDE9, /* DBG_RESET_WARN (TEST_FLASH_DATA - SHARED_MAILBOX2B) */
210 0xFFFF, /* DBG_RESET_WARN_VALUE */
211 0xFDE9, /* DBG_RESET_RESULT (TEST_FLASH_DATA) */
212 0xFFE9, /* XAP_PCH */
213 0xFFEA, /* XAP_PCL */
214 0x0051, /* PROC_PC_SNOOP */
215 0xFE70, /* WATCHDOG_DISABLE */
216 0xFE6B, /* MAILBOX0 */
217 0xFE6A, /* MAILBOX1 */
218 0xFE69, /* MAILBOX2 */
219 0xFE68, /* MAILBOX3 */
220 0xFE67, /* SDIO_HOST_INT */
221 0xFE65, /* SHARED_IO_INTERRUPT */
222 0xFE69, /* SDIO HIP HANDSHAKE */
223 0x0000 /* COEX_STATUS */
224};
225
226/* UF60xx */
227static const struct chip_device_regs_t unifi_device_regs_v22_v23 =
228{
229 0xFE81, /* GBL_CHIP_VERSION */
230 0xF84F, /* GBL_MISC_ENABLES */
231 0xF81D, /* DBG_EMU_CMD */
232 {
233 0xF81E, /* HOST.DBG_PROC_SELECT */
234 0xF81F, /* HOST.DBG_STOP_STATUS */
235 0xF8AC, /* HOST.WINDOW1_PAGE */
236 0xF8AD, /* HOST.WINDOW2_PAGE */
237 0xF8AE, /* HOST.WINDOW3_PAGE */
238 0xF8AF /* HOST.IO_LOG_ADDR */
239 },
240 {
241 0xF830, /* SPI.DBG_PROC_SELECT */
242 0xF831, /* SPI.DBG_STOP_STATUS */
243 0xF8F9, /* SPI.WINDOW1_PAGE */
244 0xF8FA, /* SPI.WINDOW2_PAGE */
245 0xF8FB, /* SPI.WINDOW3_PAGE */
246 0xF8FC /* SPI.IO_LOG_ADDR */
247 },
248 0xF82F, /* DBG_RESET */
249 0x0001, /* > DBG_RESET_VALUE */
250 0x0000, /* DBG_RESET_WARN */
251 0x0000, /* DBG_RESET_WARN_VALUE */
252 0xF82F, /* DBG_RESET_RESULT */
253 0xFFE9, /* XAP_PCH */
254 0xFFEA, /* XAP_PCL */
255 0x001B, /* PROC_PC_SNOOP */
256 0x0055, /* WATCHDOG_DISABLE */
257 0xF84B, /* MAILBOX0 */
258 0xF84C, /* MAILBOX1 */
259 0xF84D, /* MAILBOX2 */
260 0xF84E, /* MAILBOX3 */
261 0xF92F, /* SDIO_HOST_INT */
262 0xF92B, /* SDIO_FROMHOST_SCRTACH0 / SHARED_IO_INTERRUPT */
263 0xF84D, /* SDIO HIP HANDSHAKE (MAILBOX2) */
264 0xF9FB /* COEX_STATUS */
265};
266
267/* Program memory window on UF105x. */
268static const struct window_shift_info_t prog_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
269{
270 { TRUE, 11, 0x0200 }, /* CODE RAM */
271 { TRUE, 11, 0x0000 }, /* FLASH */
272 { TRUE, 11, 0x0400 }, /* External SRAM */
273 { FALSE, 0, 0 }, /* ROM */
274 { FALSE, 0, 0 } /* SHARED */
275};
276
277/* Shared memory window on UF105x. */
278static const struct window_shift_info_t shared_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
279{
280 { FALSE, 0, 0 }, /* CODE RAM */
281 { FALSE, 0, 0 }, /* FLASH */
282 { FALSE, 0, 0 }, /* External SRAM */
283 { FALSE, 0, 0 }, /* ROM */
284 { TRUE, 11, 0x0000 } /* SHARED */
285};
286
287/* One of the Generic Windows on UF60xx and later. */
288static const struct window_shift_info_t generic_window_array_unifi_v22_v23[CHIP_HELPER_WT_COUNT] =
289{
290 { TRUE, 11, 0x3800 }, /* CODE RAM */
291 { FALSE, 0, 0 }, /* FLASH */
292 { FALSE, 0, 0 }, /* External SRAM */
293 { TRUE, 11, 0x2000 }, /* ROM */
294 { TRUE, 11, 0x0000 } /* SHARED */
295};
296
297/* The three windows on UF105x. */
298static const struct window_info_t prog1_window_unifi_v1_v2 = { 0x0000, 0x2000, 0x0080, prog_window_array_unifi_v1_v2 };
299static const struct window_info_t prog2_window_unifi_v1_v2 = { 0x2000, 0x2000, 0x0000, prog_window_array_unifi_v1_v2 };
300static const struct window_info_t shared_window_unifi_v1_v2 = { 0x4000, 0x2000, 0x0000, shared_window_array_unifi_v1_v2 };
301
302/* The three windows on UF60xx and later. */
303static const struct window_info_t generic1_window_unifi_v22_v23 = { 0x0000, 0x2000, 0x0080, generic_window_array_unifi_v22_v23 };
304static const struct window_info_t generic2_window_unifi_v22_v23 = { 0x2000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
305static const struct window_info_t generic3_window_unifi_v22_v23 = { 0x4000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
306
307static const struct chip_device_desc_t chip_device_desc_null =
308{
309 { FALSE, 0x0000, 0x0000, 0x00 },
310 "",
311 "",
312 null_counted(), /* init */
313 null_counted(), /* reset_prog */
314 &unifi_device_regs_null, /* regs */
315 {
316 FALSE, /* has_flash */
317 FALSE, /* has_ext_sram */
318 FALSE, /* has_rom */
319 FALSE, /* has_bt */
320 FALSE, /* has_wlan */
321 },
322 null_counted(),
323 /* prog_offset */
324 {
325 0x00000000,
326 0x00000000,
327 0x00000000,
328 0x00000000
329 },
330 /* data_offset */
331 {
332 0x0000 /* ram */
333 },
334 /* windows */
335 {
336 NULL,
337 NULL,
338 NULL
339 }
340};
341
342static const struct chip_device_desc_t unifi_device_desc_v1 =
343{
344 { FALSE, 0xf0ff, 0x1001, 0x01 }, /* UF105x R01 */
345 "UF105x",
346 "UniFi-1",
347 counted(init_vals_v1), /* init */
348 counted(reset_program_v1_or_v2), /* reset_prog */
349 &unifi_device_regs_v1, /* regs */
350 {
351 TRUE, /* has_flash */
352 TRUE, /* has_ext_sram */
353 FALSE, /* has_rom */
354 FALSE, /* has_bt */
355 TRUE, /* has_wlan */
356 },
357 counted(unifi_map_address_v1_v2), /* map */
358 /* prog_offset */
359 {
360 0x00100000, /* ram */
361 0x00000000, /* rom (invalid) */
362 0x00000000, /* flash */
363 0x00200000, /* ext_ram */
364 },
365 /* data_offset */
366 {
367 0x8000 /* ram */
368 },
369 /* windows */
370 {
371 &prog1_window_unifi_v1_v2,
372 &prog2_window_unifi_v1_v2,
373 &shared_window_unifi_v1_v2
374 }
375};
376
377static const struct chip_device_desc_t unifi_device_desc_v2 =
378{
379 { FALSE, 0xf0ff, 0x2001, 0x02 }, /* UF2... R02 */
380 "UF2...",
381 "UniFi-2",
382 counted(init_vals_v2), /* init */
383 counted(reset_program_v1_or_v2), /* reset_prog */
384 &unifi_device_regs_v2, /* regs */
385 {
386 TRUE, /* has_flash */
387 TRUE, /* has_ext_sram */
388 FALSE, /* has_rom */
389 FALSE, /* has_bt */
390 TRUE, /* has_wlan */
391 },
392 counted(unifi_map_address_v1_v2), /* map */
393 /* prog_offset */
394 {
395 0x00100000, /* ram */
396 0x00000000, /* rom (invalid) */
397 0x00000000, /* flash */
398 0x00200000, /* ext_ram */
399 },
400 /* data_offset */
401 {
402 0x8000 /* ram */
403 },
404 /* windows */
405 {
406 &prog1_window_unifi_v1_v2,
407 &prog2_window_unifi_v1_v2,
408 &shared_window_unifi_v1_v2
409 }
410};
411
412static const struct chip_device_desc_t unifi_device_desc_v3 =
413{
414 { FALSE, 0xf0ff, 0x3001, 0x02 }, /* UF2... R03 */
415 "UF2...",
416 "UniFi-3",
417 counted(init_vals_v2), /* init */
418 counted(reset_program_v1_or_v2), /* reset_prog */
419 &unifi_device_regs_v2, /* regs */
420 {
421 TRUE, /* has_flash */
422 TRUE, /* has_ext_sram */
423 FALSE, /* has_rom */
424 FALSE, /* has_bt */
425 TRUE, /* has_wlan */
426 },
427 counted(unifi_map_address_v1_v2), /* map */
428 /* prog_offset */
429 {
430 0x00100000, /* ram */
431 0x00000000, /* rom (invalid) */
432 0x00000000, /* flash */
433 0x00200000, /* ext_ram */
434 },
435 /* data_offset */
436 {
437 0x8000 /* ram */
438 },
439 /* windows */
440 {
441 &prog1_window_unifi_v1_v2,
442 &prog2_window_unifi_v1_v2,
443 &shared_window_unifi_v1_v2
444 }
445};
446
447static const struct chip_device_desc_t unifi_device_desc_v22 =
448{
449 { FALSE, 0x00ff, 0x0022, 0x07 }, /* UF60xx */
450 "UF60xx",
451 "UniFi-4",
452 counted(init_vals_v22_v23), /* init */
453 null_counted(), /* reset_prog */
454 &unifi_device_regs_v22_v23, /* regs */
455 {
456 FALSE, /* has_flash */
457 FALSE, /* has_ext_sram */
458 TRUE, /* has_rom */
459 FALSE, /* has_bt */
460 TRUE, /* has_wlan */
461 },
462 counted(unifi_map_address_v22_v23), /* map */
463 /* prog_offset */
464 {
465 0x00C00000, /* ram */
466 0x00000000, /* rom */
467 0x00000000, /* flash (invalid) */
468 0x00000000, /* ext_ram (invalid) */
469 },
470 /* data_offset */
471 {
472 0x8000 /* ram */
473 },
474 /* windows */
475 {
476 &generic1_window_unifi_v22_v23,
477 &generic2_window_unifi_v22_v23,
478 &generic3_window_unifi_v22_v23
479 }
480};
481
482static const struct chip_device_desc_t unifi_device_desc_v23 =
483{
484 { FALSE, 0x00ff, 0x0023, 0x08 }, /* UF.... */
485 "UF....",
486 "UF.... (5)",
487 counted(init_vals_v22_v23), /* init */
488 null_counted(), /* reset_prog */
489 &unifi_device_regs_v22_v23, /* regs */
490 {
491 FALSE, /* has_flash */
492 FALSE, /* has_ext_sram */
493 TRUE, /* has_rom */
494 TRUE, /* has_bt */
495 TRUE, /* has_wlan */
496 },
497 counted(unifi_map_address_v22_v23),
498 /* prog_offset */
499 {
500 0x00C00000, /* ram */
501 0x00000000, /* rom */
502 0x00000000, /* flash (invalid) */
503 0x00000000, /* ext_sram (invalid) */
504 },
505 /* data_offset */
506 {
507 0x8000 /* ram */
508 },
509 /* windows */
510 {
511 &generic1_window_unifi_v22_v23,
512 &generic2_window_unifi_v22_v23,
513 &generic3_window_unifi_v22_v23
514 }
515};
516
517static const struct chip_device_desc_t hyd_wlan_subsys_desc_v1 =
518{
519 { FALSE, 0x00ff, 0x0044, 0x00 }, /* UF.... */
520 "HYD...",
521 "HYD... ",
522 counted(init_vals_v22_v23), /* init */
523 null_counted(), /* reset_prog */
524 &unifi_device_regs_v22_v23, /* regs */
525 {
526 FALSE, /* has_flash */
527 FALSE, /* has_ext_sram */
528 TRUE, /* has_rom */
529 FALSE, /* has_bt */
530 TRUE, /* has_wlan */
531 },
532 counted(unifi_map_address_v22_v23),
533 /* prog_offset */
534 {
535 0x00C00000, /* ram */
536 0x00000000, /* rom */
537 0x00000000, /* flash (invalid) */
538 0x00000000, /* ext_sram (invalid) */
539 },
540 /* data_offset */
541 {
542 0x8000 /* ram */
543 },
544 /* windows */
545 {
546 &generic1_window_unifi_v22_v23,
547 &generic2_window_unifi_v22_v23,
548 &generic3_window_unifi_v22_v23
549 }
550};
551
552
553/* This is the list of all chips that we know about. I'm
554 assuming that the order here will be important - we
555 might have multiple entries witrh the same SDIO id for
556 instance. The first one in this list will be the one
557 that is returned if a search is done on only that id.
558 The client will then have to call GetVersionXXX again
559 but with more detailed info.
560
561 I don't know if we need to signal this up to the client
562 in some way?
563
564 (We get the SDIO id before we know anything else about
565 the chip. We might not be able to read any of the other
566 registers at first, but we still need to know about the
567 chip). */
568static const struct chip_device_desc_t *chip_ver_to_desc[] =
569{
570 &unifi_device_desc_v1, /* UF105x R01 */
571 &unifi_device_desc_v2, /* UF2... R02 */
572 &unifi_device_desc_v3, /* UF2... R03 */
573 &unifi_device_desc_v22, /* UF60xx */
574 &unifi_device_desc_v23, /* UF.... */
575 &hyd_wlan_subsys_desc_v1
576};
577
578ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_ver)
579{
580 u32 i;
581
582 for (i = 0; i < nelem(chip_ver_to_desc); i++)
583 {
584 if (chip_ver_to_desc[i]->chip_version.sdio == sdio_ver)
585 {
586 return chip_ver_to_desc[i];
587 }
588 }
589
590 return &chip_device_desc_null;
591}
592
593
594ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81)
595{
596 u32 i;
597
598 if ((from_FF9A & 0xFF00) != 0)
599 {
600 for (i = 0; i < nelem(chip_ver_to_desc); i++)
601 {
602 if (chip_ver_to_desc[i]->chip_version.pre_bc7 &&
603 ((from_FF9A & chip_ver_to_desc[i]->chip_version.mask) ==
604 chip_ver_to_desc[i]->chip_version.result))
605 {
606 return chip_ver_to_desc[i];
607 }
608 }
609 }
610 else
611 {
612 for (i = 0; i < nelem(chip_ver_to_desc); i++)
613 {
614 if (!chip_ver_to_desc[i]->chip_version.pre_bc7 &&
615 ((from_FE81 & chip_ver_to_desc[i]->chip_version.mask) ==
616 chip_ver_to_desc[i]->chip_version.result))
617 {
618 return chip_ver_to_desc[i];
619 }
620 }
621 }
622
623 return &chip_device_desc_null;
624}
625
626
627ChipDescript* ChipHelper_GetVersionUniFi(u16 ver)
628{
629 return ChipHelper_GetVersionAny(0x0000, ver);
630}
631
632
633ChipDescript *ChipHelper_Null(void)
634{
635 return &chip_device_desc_null;
636}
637
638
639ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age bc_age, u16 version)
640{
641 if (bc_age == chip_helper_bluecore_pre_bc7)
642 {
643 return ChipHelper_GetVersionAny(version, 0x0000);
644 }
645 else
646 {
647 return ChipHelper_GetVersionAny(0x0000, version);
648 }
649}
650
651
652/* Expand the DEF0 functions into simple code to return the
653 correct thing. The DEF1 functions expand to nothing in
654 this X macro expansion. */
655#define CHIP_HELPER_DEF0_C_DEF(ret_type, name, info) \
656 ret_type ChipHelper_ ## name(ChipDescript * chip_help) \
657 { \
658 return chip_help->info; \
659 }
660#define CHIP_HELPER_DEF1_C_DEF(ret_type, name, type1, name1)
661
662CHIP_HELPER_LIST(C_DEF)
663
664/*
665 * Map register addresses between HOST and SPI access.
666 */
667u16 ChipHelper_MapAddress_SPI2HOST(ChipDescript *chip_help, u16 addr)
668{
669 u32 i;
670 for (i = 0; i < chip_help->map.len; i++)
671 {
672 if (chip_help->map.vals[i].spi == addr)
673 {
674 return chip_help->map.vals[i].host;
675 }
676 }
677 return addr;
678}
679
680
681u16 ChipHelper_MapAddress_HOST2SPI(ChipDescript *chip_help, u16 addr)
682{
683 u32 i;
684 for (i = 0; i < chip_help->map.len; i++)
685 {
686 if (chip_help->map.vals[i].host == addr)
687 {
688 return chip_help->map.vals[i].spi;
689 }
690 }
691 return addr;
692}
693
694
695/* The address returned by this function is the start of the
696 window in the address space, that is where we can start
697 accessing data from. If a section of the window at the
698 start is unusable because something else is cluttering up
699 the address map then that is taken into account and this
700 function returns that address justt past that. */
701u16 ChipHelper_WINDOW_ADDRESS(ChipDescript *chip_help,
702 enum chip_helper_window_index window)
703{
704 if (window < CHIP_HELPER_WINDOW_COUNT &&
705 chip_help->windows[window] != NULL)
706 {
707 return chip_help->windows[window]->address + chip_help->windows[window]->blocked;
708 }
709 return 0;
710}
711
712
713/* This returns the size of the window minus any blocked section */
714u16 ChipHelper_WINDOW_SIZE(ChipDescript *chip_help,
715 enum chip_helper_window_index window)
716{
717 if (window < CHIP_HELPER_WINDOW_COUNT &&
718 chip_help->windows[window] != NULL)
719 {
720 return chip_help->windows[window]->size - chip_help->windows[window]->blocked;
721 }
722 return 0;
723}
724
725
726/* Get the register writes we should do to make sure that
727 the chip is running with most clocks on. */
728u32 ChipHelper_ClockStartupSequence(ChipDescript *chip_help,
729 const struct chip_helper_init_values **val)
730{
731 *val = chip_help->init.vals;
732 return chip_help->init.len;
733}
734
735
736/* Get the set of values tat we should write to the chip to perform a reset. */
737u32 ChipHelper_HostResetSequence(ChipDescript *chip_help,
738 const struct chip_helper_reset_values **val)
739{
740 *val = chip_help->reset_prog.vals;
741 return chip_help->reset_prog.len;
742}
743
744
745/* Decode a windowed access to the chip. */
746s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
747 enum chip_helper_window_index window,
748 enum chip_helper_window_type type,
749 u32 offset,
750 u16 *page, u16 *addr, u32 *len)
751{
752 const struct window_info_t *win;
753 const struct window_shift_info_t *mode;
754 u16 of, pg;
755
756 if (window >= CHIP_HELPER_WINDOW_COUNT)
757 {
758 return FALSE;
759 }
760 if ((win = chip_help->windows[window]) == NULL)
761 {
762 return FALSE;
763 }
764 if (type >= CHIP_HELPER_WT_COUNT)
765 {
766 return FALSE;
767 }
768 if ((mode = &win->mode[type]) == NULL)
769 {
770 return FALSE;
771 }
772 if (!mode->allowed)
773 {
774 return FALSE;
775 }
776
777 pg = (u16)(offset >> mode->page_shift) + mode->page_offset;
778 of = (u16)(offset & ((1 << mode->page_shift) - 1));
779 /* If 'blocked' is zero this does nothing, else decrease
780 the page register and increase the offset until we aren't
781 in the blocked region of the window. */
782 while (of < win->blocked)
783 {
784 of += 1 << mode->page_shift;
785 pg--;
786 }
787 *page = pg;
788 *addr = win->address + of;
789 *len = win->size - of;
790 return TRUE;
791}
792
793
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.h b/drivers/staging/csr/csr_wifi_hip_chiphelper.h
deleted file mode 100644
index 09b3aefcbced..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_chiphelper.h
+++ /dev/null
@@ -1,407 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_HIP_CHIPHELPER_H__
12#define CSR_WIFI_HIP_CHIPHELPER_H__
13
14
15#include <linux/types.h>
16
17/* The age of the BlueCore chip. This is probably not useful, if
18 you know the age then you can probably work out the version directly. */
19enum chip_helper_bluecore_age
20{
21 chip_helper_bluecore_pre_bc7,
22 chip_helper_bluecore_bc7_or_later
23};
24
25/* We support up to three windowed regions at the moment.
26 Don't reorder these - they're used to index into an array. */
27enum chip_helper_window_index
28{
29 CHIP_HELPER_WINDOW_1 = 0,
30 CHIP_HELPER_WINDOW_2 = 1,
31 CHIP_HELPER_WINDOW_3 = 2,
32 CHIP_HELPER_WINDOW_COUNT = 3
33};
34
35/* These are the things that we can access through a window.
36 Don't reorder these - they're used to index into an array. */
37enum chip_helper_window_type
38{
39 CHIP_HELPER_WT_CODE_RAM = 0,
40 CHIP_HELPER_WT_FLASH = 1,
41 CHIP_HELPER_WT_EXT_SRAM = 2,
42 CHIP_HELPER_WT_ROM = 3,
43 CHIP_HELPER_WT_SHARED = 4,
44 CHIP_HELPER_WT_COUNT = 5
45};
46
47/* Commands to stop and start the XAP */
48enum chip_helper_dbg_emu_cmd_enum
49{
50 CHIP_HELPER_DBG_EMU_CMD_XAP_STEP_MASK = 0x0001,
51 CHIP_HELPER_DBG_EMU_CMD_XAP_RUN_B_MASK = 0x0002,
52 CHIP_HELPER_DBG_EMU_CMD_XAP_BRK_MASK = 0x0004,
53 CHIP_HELPER_DBG_EMU_CMD_XAP_WAKEUP_MASK = 0x0008
54};
55
56/* Bitmasks for Stop and sleep status: DBG_SPI_STOP_STATUS & DBG_HOST_STOP_STATUS */
57enum chip_helper_dbg_stop_status_enum
58{
59 CHIP_HELPER_DBG_STOP_STATUS_NONE_MASK = 0x0000,
60 CHIP_HELPER_DBG_STOP_STATUS_P0_MASK = 0x0001,
61 CHIP_HELPER_DBG_STOP_STATUS_P1_MASK = 0x0002,
62 CHIP_HELPER_DBG_STOP_STATUS_P2_MASK = 0x0004,
63 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P0_MASK = 0x0008,
64 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P1_MASK = 0x0010,
65 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P2_MASK = 0x0020,
66 /* Legacy names/alias */
67 CHIP_HELPER_DBG_STOP_STATUS_MAC_MASK = 0x0001,
68 CHIP_HELPER_DBG_STOP_STATUS_PHY_MASK = 0x0002,
69 CHIP_HELPER_DBG_STOP_STATUS_BT_MASK = 0x0004,
70 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_MAC_MASK = 0x0008,
71 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_PHY_MASK = 0x0010,
72 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_BT_MASK = 0x0020
73};
74
75/* Codes to disable the watchdog */
76enum chip_helper_watchdog_disable_enum
77{
78 CHIP_HELPER_WATCHDOG_DISABLE_CODE1 = 0x6734,
79 CHIP_HELPER_WATCHDOG_DISABLE_CODE2 = 0xD6BF,
80 CHIP_HELPER_WATCHDOG_DISABLE_CODE3 = 0xC31E
81};
82
83/* Other bits have changed between versions */
84enum chip_helper_gbl_misc_enum
85{
86 CHIP_HELPER_GBL_MISC_SPI_STOP_OUT_EN_MASK = 0x0001,
87 CHIP_HELPER_GBL_MISC_MMU_INIT_DONE_MASK = 0x0004
88};
89
90/* Coex status register, contains interrupt status and reset pullup status.
91 * CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK can be used to check
92 * for WAPI on R03 chips and later. */
93enum chip_helper_coex_status_mask_enum
94{
95 CHIP_HELPER_COEX_STATUS_RST_PULLS_LSB_MASK = 0x0001,
96 CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK = 0x0008,
97 CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_LSB_MASK = 0x0010,
98 CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_MSB_MASK = 0x0080,
99 CHIP_HELPER_COEX_STATUS_INT_UART_MASK = 0x0100,
100 CHIP_HELPER_COEX_STATUS_INT_BT_LEG_MASK = 0x0200
101};
102
103/* How to select the different CPUs */
104enum chip_helper_dbg_proc_sel_enum
105{
106 CHIP_HELPER_DBG_PROC_SEL_MAC = 0,
107 CHIP_HELPER_DBG_PROC_SEL_PHY = 1,
108 CHIP_HELPER_DBG_PROC_SEL_BT = 2,
109 CHIP_HELPER_DBG_PROC_SEL_NONE = 2,
110 CHIP_HELPER_DBG_PROC_SEL_BOTH = 3
111};
112
113/* These are the only registers that we have to know the
114 address of before we know the chip version. */
115enum chip_helper_fixed_registers
116{
117 /* This is the address of GBL_CHIP_VERISON on BC7,
118 UF105x, UF60xx and
119 anything later than that. */
120 CHIP_HELPER_UNIFI_GBL_CHIP_VERSION = 0xFE81,
121
122 CHIP_HELPER_OLD_BLUECORE_GBL_CHIP_VERSION = 0xFF9A
123
124 /* This isn't used at the moment (but might be needed
125 to distinguish the BlueCore sub version?) */
126 /* CHIP_HELPER_OLD_BLUECORE_ANA_VERSION_ID = 0xFF7D */
127};
128
129/* Address-value pairs for defining initialisation values */
130struct chip_helper_init_values
131{
132 u16 addr;
133 u16 value;
134};
135
136/* A block of data that should be written to the device */
137struct chip_helper_reset_values
138{
139 u32 gp_address;
140 u32 len;
141 const u16 *data;
142};
143
144/*
145 * This is the C API.
146 */
147
148/* opaque type */
149typedef const struct chip_device_desc_t ChipDescript;
150
151/* Return a NULL descriptor */
152ChipDescript* ChipHelper_Null(void);
153
154/* This should get the correct version for any CSR chip.
155 The two parameters are what is read from addresses
156 0xFF9A and 0xFE81 (OLD_BLUECORE_GBL_CHIP_VERSION and
157 UNIFI_GBL_CHIP_VERSION). These should give a unique identity
158 for most (all?) chips.
159
160 FF9A is the old GBL_CHIP_VERSION register. If the high
161 eight bits are zero then the chip is a new (BC7 +) one
162 and FE81 is the _new_ GBL_CHIP_VERSION register. */
163ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81);
164
165/* The chip is a UniFi, but we don't know which type
166 The parameter is the value of UNIFI_GBL_CHIP_VERSION (0xFE81) */
167ChipDescript* ChipHelper_GetVersionUniFi(u16 version);
168
169/* This gets the version from the SDIO device id. This only
170 gives quite a coarse grained version, so we should update once
171 we hav access to the function N registers. */
172ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_version);
173
174/* The chip is some sort of BlueCore. If "age" is "pre_bc7" then
175 "version" is what was read from FF9A. If "age" is bc7_or_later
176 then "version" is read from FE81. If we don't know if we're pre
177 or post BC7 then we should use "GetVersionAny". */
178ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age age,
179 u16 version);
180
181/* The main functions of this class are built with an X macro. This
182 means we can generate the C and C++ versions from the same source
183 without the two diverging.
184
185 The DEF0 functions are simple and take no parameters. The first
186 parameter to the macro is the return type. The second parameter
187 is the function name and the third parameter is where to get the
188 info from (this is hidden from the user).
189
190 The DEF1 functions take one parameter. This time the third macro
191 parameter is the type of this parameter, and the fourth macro
192 parameter is the name of the parameter. The bodies of these
193 functions are hand written. */
194#define CHIP_HELPER_LIST(m) \
195 CHIP_HELPER_DEF0(m, (const char *, FriendlyName, friendly_name)) \
196 CHIP_HELPER_DEF0(m, (const char *, MarketingName, marketing_name)) \
197 CHIP_HELPER_DEF0(m, (u16, DBG_EMU_CMD, regs->dbg_emu_cmd)) \
198 CHIP_HELPER_DEF0(m, (u16, DBG_HOST_PROC_SELECT, regs->host.dbg_proc_select)) \
199 CHIP_HELPER_DEF0(m, (u16, DBG_HOST_STOP_STATUS, regs->host.dbg_stop_status)) \
200 CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW1_PAGE, regs->host.window1_page)) \
201 CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW2_PAGE, regs->host.window2_page)) \
202 CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW3_PAGE, regs->host.window3_page)) \
203 CHIP_HELPER_DEF0(m, (u16, HOST_IO_LOG_ADDR, regs->host.io_log_addr)) \
204 CHIP_HELPER_DEF0(m, (u16, DBG_SPI_PROC_SELECT, regs->spi.dbg_proc_select)) \
205 CHIP_HELPER_DEF0(m, (u16, DBG_SPI_STOP_STATUS, regs->spi.dbg_stop_status)) \
206 CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW1_PAGE, regs->spi.window1_page)) \
207 CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW2_PAGE, regs->spi.window2_page)) \
208 CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW3_PAGE, regs->spi.window3_page)) \
209 CHIP_HELPER_DEF0(m, (u16, SPI_IO_LOG_ADDR, regs->spi.io_log_addr)) \
210 CHIP_HELPER_DEF0(m, (u16, DBG_RESET, regs->dbg_reset)) \
211 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_VALUE, regs->dbg_reset_value)) \
212 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN, regs->dbg_reset_warn)) \
213 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN_VALUE, regs->dbg_reset_warn_value)) \
214 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_RESULT, regs->dbg_reset_result)) \
215 CHIP_HELPER_DEF0(m, (u16, WATCHDOG_DISABLE, regs->watchdog_disable)) \
216 CHIP_HELPER_DEF0(m, (u16, PROC_PC_SNOOP, regs->proc_pc_snoop)) \
217 CHIP_HELPER_DEF0(m, (u16, GBL_CHIP_VERSION, regs->gbl_chip_version)) \
218 CHIP_HELPER_DEF0(m, (u16, GBL_MISC_ENABLES, regs->gbl_misc_enables)) \
219 CHIP_HELPER_DEF0(m, (u16, XAP_PCH, regs->xap_pch)) \
220 CHIP_HELPER_DEF0(m, (u16, XAP_PCL, regs->xap_pcl)) \
221 CHIP_HELPER_DEF0(m, (u16, MAILBOX0, regs->mailbox0)) \
222 CHIP_HELPER_DEF0(m, (u16, MAILBOX1, regs->mailbox1)) \
223 CHIP_HELPER_DEF0(m, (u16, MAILBOX2, regs->mailbox2)) \
224 CHIP_HELPER_DEF0(m, (u16, MAILBOX3, regs->mailbox3)) \
225 CHIP_HELPER_DEF0(m, (u16, SDIO_HIP_HANDSHAKE, regs->sdio_hip_handshake)) \
226 CHIP_HELPER_DEF0(m, (u16, SDIO_HOST_INT, regs->sdio_host_int)) \
227 CHIP_HELPER_DEF0(m, (u16, COEX_STATUS, regs->coex_status)) \
228 CHIP_HELPER_DEF0(m, (u16, SHARED_IO_INTERRUPT, regs->shared_io_interrupt)) \
229 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_RAM_OFFSET, prog_offset.ram)) \
230 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_ROM_OFFSET, prog_offset.rom)) \
231 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_FLASH_OFFSET, prog_offset.flash)) \
232 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_EXT_SRAM_OFFSET, prog_offset.ext_sram)) \
233 CHIP_HELPER_DEF0(m, (u16, DATA_MEMORY_RAM_OFFSET, data_offset.ram)) \
234 CHIP_HELPER_DEF0(m, (s32, HasFlash, bools.has_flash)) \
235 CHIP_HELPER_DEF0(m, (s32, HasExtSram, bools.has_ext_sram)) \
236 CHIP_HELPER_DEF0(m, (s32, HasRom, bools.has_rom)) \
237 CHIP_HELPER_DEF0(m, (s32, HasBt, bools.has_bt)) \
238 CHIP_HELPER_DEF0(m, (s32, HasWLan, bools.has_wlan)) \
239 CHIP_HELPER_DEF1(m, (u16, WINDOW_ADDRESS, enum chip_helper_window_index, window)) \
240 CHIP_HELPER_DEF1(m, (u16, WINDOW_SIZE, enum chip_helper_window_index, window)) \
241 CHIP_HELPER_DEF1(m, (u16, MapAddress_SPI2HOST, u16, addr)) \
242 CHIP_HELPER_DEF1(m, (u16, MapAddress_HOST2SPI, u16, addr)) \
243 CHIP_HELPER_DEF1(m, (u32, ClockStartupSequence, const struct chip_helper_init_values **, val)) \
244 CHIP_HELPER_DEF1(m, (u32, HostResetSequence, const struct chip_helper_reset_values **, val))
245
246/* Some magic to help the expansion */
247#define CHIP_HELPER_DEF0(a, b) \
248 CHIP_HELPER_DEF0_ ## a b
249#define CHIP_HELPER_DEF1(a, b) \
250 CHIP_HELPER_DEF1_ ## a b
251
252/* Macros so that when we expand the list we get "C" function prototypes. */
253#define CHIP_HELPER_DEF0_C_DEC(ret_type, name, info) \
254 ret_type ChipHelper_ ## name(ChipDescript * chip_help);
255#define CHIP_HELPER_DEF1_C_DEC(ret_type, name, type1, name1) \
256 ret_type ChipHelper_ ## name(ChipDescript * chip_help, type1 name1);
257
258CHIP_HELPER_LIST(C_DEC)
259
260/* FriendlyName
261 MarketingName
262
263 These two functions return human readable strings that describe
264 the chip. FriendlyName returns something that a software engineer
265 at CSR might understand. MarketingName returns something more like
266 an external name for a CSR chip.
267*/
268/* DBG_EMU_CMD
269 WATCHDOG_DISABLE
270 PROC_PC_SNOOP
271 GBL_CHIP_VERSION
272 XAP_PCH
273 XAP_PCL
274
275 These registers are used to control the XAPs.
276*/
277/* DBG_HOST_PROC_SELECT DBG_HOST_STOP_STATUS
278 HOST_WINDOW1_PAGE HOST_WINDOW2_PAGE HOST_WINDOW3_PAGE
279 HOST_IO_LOG_ADDR
280 DBG_SPI_PROC_SELECT DBG_SPI_STOP_STATUS
281 SPI_WINDOW1_PAGE SPI_WINDOW2_PAGE SPI_WINDOW3_PAGE
282 SPI_IO_LOG_ADDR
283
284 These register are used to control the XAPs and the memory
285 windows, normally while debugging the code on chip. There
286 are two versons of these registers, one for access via SPI
287 and another for access via the host interface.
288*/
289/* DBG_RESET
290 DBG_RESET_VALUE
291 DBG_RESET_WARN
292 DBG_RESET_WARN_VALUE
293 DBG_RESET_RESULT
294
295 These registers are used to reset the XAP. This can be
296 quite complex for some chips. If DBG_RESET_WARN is non
297 zero the DBG_RESET_WARN_VALUE should be written to address
298 DBG_RESET_WARN before the reset is perfeormed. DBG_RESET_VALUE
299 should then be written to DBG_RESET to make the reset happen.
300 The DBG_RESET_RESULT register should contain 0 if the reset
301 was successful.
302*/
303/* GBL_MISC_ENABLES
304
305 This register controls some special chip features. It
306 should be used with care is it changes quite a lot between
307 chip versions.
308*/
309/* MAILBOX0
310 MAILBOX1
311 MAILBOX2
312 MAILBOX3
313
314 The mailbox registers are for communication between the host
315 and the firmware. There use is described in part by the host
316 interface protcol specifcation.
317*/
318/* SDIO_HIP_HANDSHAKE
319
320 This is one of the more important SDIO HIP registers. On some
321 chips it has the same value as one of the mailbox registers
322 and on other chips it is different.
323*/
324/* SDIO_HOST_INT
325 SHARED_IO_INTERRUPT
326
327 These registers are used by some versions of the host interface
328 protocol specification. Their names should probably be changed
329 to hide the registers and to expose the functions more.
330*/
331/* COEX_STATUS
332
333 Coex status register, contains interrupt status and reset
334 pullup status. The latter is used to detect WAPI.
335*/
336/* PROGRAM_MEMORY_RAM_OFFSET
337 PROGRAM_MEMORY_ROM_OFFSET
338 PROGRAM_MEMORY_FLASH_OFFSET
339 PROGRAM_MEMORY_EXT_SRAM_OFFSET
340 DATA_MEMORY_RAM_OFFSET
341
342 These are constants that describe the offset of the different
343 memory types in the two different address spaces.
344*/
345/* HasFlash HasExtSram HasRom
346 HasBt HasWLan
347
348 These are a set of bools describing the chip.
349*/
350/* WINDOW_ADDRESS WINDOW_SIZE
351
352 These two functions return the size and address of the windows.
353 The address is the address of the lowest value in the address
354 map that is part of the window and the size is the number of
355 visible words.
356
357 Some of the windows have their lowest portion covered by
358 registers. For these windows address is the first address
359 after the registers and size is the siave excluding the part
360 covered by registers.
361*/
362/* MapAddress_SPI2HOST
363 MapAddress_HOST2SPI
364
365 The debugging interface is duplicated on UniFi and later chips
366 so that there are two versions - one over the SPI interaface and
367 the other over the SDIO interface. These functions map the
368 registers between these two interfaces.
369*/
370/* ClockStartupSequence
371
372 This function returns the list of register value pairs that
373 should be forced into UniFi to enable SPI communication. This
374 set of registers is not needed if the firmware is running, but
375 will be needed if the device is being booted from cold. These
376 register writes enable the clocks and setup the PLL to a basic
377 working state. SPI access might be unreliable until these writes
378 have occurred (And they may take mulitple goes).
379*/
380/* HostResetSequence
381
382 This returns a number of chunks of data and generic pointers.
383 All of the XAPs should be stopped. The data should be written
384 to the generic pointers. The instruction pointer for the MAC
385 should then be set to the start of program memory and then the
386 MAC should be "go"d. This will reset the chip in a reliable
387 and orderly manner without resetting the SDIO interface. It
388 is therefore not needed if the chip is being accessed by the
389 SPI interface (the DBG_RESET_ mechanism can be used instead).
390*/
391
392/* The Decode Window function is more complex. For the window
393 'window' it tries to return the address and page register
394 value needed to see offset 'offset' of memory type 'type'.
395
396 It return 1 on success and 0 on failure. 'page' is what
397 should be written to the page register. 'addr' is the
398 address in the XAPs 16 address map to read from. 'len'
399 is the length that we can read without having to change
400 the page registers. */
401s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
402 enum chip_helper_window_index window,
403 enum chip_helper_window_type type,
404 u32 offset,
405 u16 *page, u16 *addr, u32 *len);
406
407#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
index e5e579912550..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h
+++ /dev/null
@@ -1,200 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
12#define CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
13
14
15#include "csr_wifi_hip_chiphelper.h"
16
17/* This GP stuff should be somewhere else? */
18
19/* Memory spaces encoded in top byte of Generic Pointer type */
20#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */
21#define UNIFI_EXT_FLASH 0x02 /* External FLASH */
22#define UNIFI_EXT_SRAM 0x03 /* External SRAM */
23#define UNIFI_REGISTERS 0x04 /* Registers */
24#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */
25#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */
26#define UNIFI_PHY_ROM 0x12 /* PHY ROM */
27#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */
28#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */
29#define UNIFI_MAC_ROM 0x22 /* MAC ROM */
30#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */
31#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */
32#define UNIFI_BT_ROM 0x32 /* BT ROM */
33
34#define MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O))
35#define GP_OFFSET(GP) ((GP) & 0xFFFFFF)
36#define GP_SPACE(GP) (((GP) >> 24) & 0xFF)
37
38
39/* Address value pairs */
40struct val_array_t
41{
42 u32 len;
43 const struct chip_helper_init_values *vals;
44};
45
46/* Just a (counted) u16 array */
47struct data_array_t
48{
49 u32 len;
50 const u16 *vals;
51};
52
53struct reset_prog_t
54{
55 u32 len;
56 const struct chip_helper_reset_values *vals;
57};
58
59/* The addresses of registers that are equivalent but on
60 different host transports. */
61struct chip_map_address_t
62{
63 u16 spi, host;
64};
65
66struct map_array_t
67{
68 u32 len;
69 const struct chip_map_address_t *vals;
70};
71
72struct chip_device_regs_per_transport_t
73{
74 u16 dbg_proc_select;
75 u16 dbg_stop_status;
76 u16 window1_page; /* PROG_PMEM1 or GW1 */
77 u16 window2_page; /* PROG_PMEM2 or GW2 */
78 u16 window3_page; /* SHARED or GW3 */
79 u16 io_log_addr;
80};
81
82struct chip_device_regs_t
83{
84 u16 gbl_chip_version;
85 u16 gbl_misc_enables;
86 u16 dbg_emu_cmd;
87 struct chip_device_regs_per_transport_t host;
88 struct chip_device_regs_per_transport_t spi;
89 u16 dbg_reset;
90 u16 dbg_reset_value;
91 u16 dbg_reset_warn;
92 u16 dbg_reset_warn_value;
93 u16 dbg_reset_result;
94 u16 xap_pch;
95 u16 xap_pcl;
96 u16 proc_pc_snoop;
97 u16 watchdog_disable;
98 u16 mailbox0;
99 u16 mailbox1;
100 u16 mailbox2;
101 u16 mailbox3;
102 u16 sdio_host_int;
103 u16 shared_io_interrupt;
104 u16 sdio_hip_handshake;
105 u16 coex_status; /* Allows WAPI detection */
106};
107
108/* If allowed is false then this window does not provide this
109 type of access.
110 This describes how addresses should be shifted to make the
111 "page" address. The address is shifted left by 'page_shift'
112 and then has 'page_offset' added. This value should then be
113 written to the page register. */
114struct window_shift_info_t
115{
116 s32 allowed;
117 u32 page_shift;
118 u16 page_offset;
119};
120
121/* Each window has an address and size. These are obvious. It then
122 has a description for each type of memory that might be accessed
123 through it. There might also be a start to the offset of the window.
124 This means that that number of addresses at the start of the window
125 are unusable. */
126struct window_info_t
127{
128 u16 address;
129 u16 size;
130 u16 blocked;
131 const struct window_shift_info_t *mode;
132};
133
134/* If GBL_CHIP_VERSION and'ed with 'mask' and is equal to 'result'
135 then this is the correct set of info. If pre_bc7 is true then the
136 address of GBL_CHIP_VERSION is FF9A, else its FE81. */
137struct chip_version_t
138{
139 s32 pre_bc7;
140 u16 mask;
141 u16 result;
142 u8 sdio;
143};
144
145struct chip_device_desc_t
146{
147 struct chip_version_t chip_version;
148
149 /* This is a text string that a human might find useful (BC02, UF105x) */
150 const char *friendly_name;
151 /* This is what we show to customers */
152 const char *marketing_name;
153
154 /* Initialisation values to write following a reset */
155 struct val_array_t init;
156
157 /* Binary sequence for hard reset */
158 struct reset_prog_t reset_prog;
159
160 /* The register map */
161 const struct chip_device_regs_t *regs;
162
163 /* Some misc. info on the chip */
164 struct
165 {
166 u32 has_flash : 1;
167 u32 has_ext_sram : 1;
168 u32 has_rom : 1;
169 u32 has_bt : 1;
170 u32 has_wlan : 1;
171 } bools;
172
173 /* This table is used to remap register addresses depending on what
174 host interface is used. On the BC7 and later chips there are
175 multiple sets of memory window registers, on for each host
176 interafce (SDIO / SPI). The correct one is needed. */
177 struct map_array_t map;
178
179 /* The offsets into the program address space of the different types of memory.
180 The RAM offset is probably the most useful. */
181 struct
182 {
183 u32 ram;
184 u32 rom;
185 u32 flash;
186 u32 ext_sram;
187 } prog_offset;
188
189 /* The offsets into the data address space of interesting things. */
190 struct
191 {
192 u16 ram;
193 /* maybe add shared / page tables? */
194 } data_offset;
195
196 /* Information on the different windows */
197 const struct window_info_t *windows[CHIP_HELPER_WINDOW_COUNT];
198};
199
200#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
index bf7a52e82995..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_conversions.h
+++ /dev/null
@@ -1,73 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 *
14 * FILE: csr_wifi_hip_conversions.h
15 *
16 * PURPOSE:
17 * This header file provides the macros for converting to and from
18 * wire format.
19 * These macros *MUST* work for little-endian AND big-endian hosts.
20 *
21 * ---------------------------------------------------------------------------
22 */
23#ifndef __CSR_WIFI_HIP_CONVERSIONS_H__
24#define __CSR_WIFI_HIP_CONVERSIONS_H__
25
26#define SIZEOF_UINT16 2
27#define SIZEOF_UINT32 4
28#define SIZEOF_UINT64 8
29
30#define SIZEOF_SIGNAL_HEADER 6
31#define SIZEOF_DATAREF 4
32
33
34/*
35 * Macro to retrieve the signal ID from a wire-format signal.
36 */
37#define GET_SIGNAL_ID(_buf) CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf))
38
39/*
40 * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format)
41 * HIP signal.
42 */
43#define GET_PACKED_DATAREF_SLOT(_buf, _ref) \
44 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
45
46#define GET_PACKED_DATAREF_LEN(_buf, _ref) \
47 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
48
49#define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot) \
50 CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
51
52#define SET_PACKED_DATAREF_LEN(_buf, _ref, _len) \
53 CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
54
55#define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf) \
56 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
57
58#define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf) \
59 CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4))
60
61#define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf) \
62 CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
63
64#define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf) \
65 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2))
66
67
68s32 get_packed_struct_size(const u8 *buf);
69CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig);
70CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len);
71
72#endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */
73
diff --git a/drivers/staging/csr/csr_wifi_hip_download.c b/drivers/staging/csr/csr_wifi_hip_download.c
deleted file mode 100644
index 2f44a383d2cf..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_download.c
+++ /dev/null
@@ -1,819 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_download.c
14 *
15 * PURPOSE:
16 * Routines for downloading firmware to UniFi.
17 *
18 * ---------------------------------------------------------------------------
19 */
20#include <linux/slab.h>
21#include "csr_wifi_hip_unifi.h"
22#include "csr_wifi_hip_unifiversion.h"
23#include "csr_wifi_hip_card.h"
24#include "csr_wifi_hip_xbv.h"
25
26#undef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
27
28static CsrResult do_patch_download(card_t *card, void *dlpriv,
29 xbv1_t *pfwinfo, u32 boot_ctrl_addr);
30
31static CsrResult do_patch_convert_download(card_t *card,
32 void *dlpriv, xbv1_t *pfwinfo);
33
34/*
35 * ---------------------------------------------------------------------------
36 * _find_in_slut
37 *
38 * Find the offset of the appropriate object in the SLUT of a card
39 *
40 * Arguments:
41 * card Pointer to card struct
42 * psym Pointer to symbol object.
43 * id set up by caller
44 * obj will be set up by this function
45 * pslut Pointer to SLUT address, if 0xffffffff then it must be
46 * read from the chip.
47 * Returns:
48 * CSR_RESULT_SUCCESS on success
49 * Non-zero on error,
50 * CSR_WIFI_HIP_RESULT_NOT_FOUND if not found
51 * ---------------------------------------------------------------------------
52 */
53static CsrResult _find_in_slut(card_t *card, symbol_t *psym, u32 *pslut)
54{
55 u32 slut_address;
56 u16 finger_print;
57 CsrResult r;
58 CsrResult csrResult;
59
60 /* Get SLUT address */
61 if (*pslut == 0xffffffff)
62 {
63 r = card_wait_for_firmware_to_start(card, &slut_address);
64 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
65 {
66 return r;
67 }
68 if (r != CSR_RESULT_SUCCESS)
69 {
70 unifi_error(card->ospriv, "Firmware hasn't started\n");
71 return r;
72 }
73 *pslut = slut_address;
74
75 /*
76 * Firmware has started so set the SDIO bus clock to the initial speed,
77 * faster than UNIFI_SDIO_CLOCK_SAFE_HZ, to speed up the f/w download.
78 */
79 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
80 if (csrResult != CSR_RESULT_SUCCESS)
81 {
82 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
83 return r;
84 }
85 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
86 }
87 else
88 {
89 slut_address = *pslut; /* Use previously discovered address */
90 }
91 unifi_trace(card->ospriv, UDBG4, "SLUT addr: 0x%lX\n", slut_address);
92
93 /*
94 * Check the SLUT fingerprint.
95 * The slut_address is a generic pointer so we must use unifi_card_read16().
96 */
97 unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
98 finger_print = 0;
99 r = unifi_card_read16(card, slut_address, &finger_print);
100 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
101 {
102 return r;
103 }
104 if (r != CSR_RESULT_SUCCESS)
105 {
106 unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
107 return r;
108 }
109
110 if (finger_print != SLUT_FINGERPRINT)
111 {
112 unifi_error(card->ospriv, "Failed to find SLUT fingerprint\n");
113 return CSR_RESULT_FAILURE;
114 }
115
116 /* Symbol table starts imedately after the fingerprint */
117 slut_address += 2;
118
119 while (1)
120 {
121 u16 id;
122 u32 obj;
123
124 r = unifi_card_read16(card, slut_address, &id);
125 if (r != CSR_RESULT_SUCCESS)
126 {
127 return r;
128 }
129 slut_address += 2;
130
131 if (id == CSR_SLT_END)
132 {
133 /* End of table reached: not found */
134 r = CSR_WIFI_HIP_RESULT_RANGE;
135 break;
136 }
137
138 r = unifi_read32(card, slut_address, &obj);
139 if (r != CSR_RESULT_SUCCESS)
140 {
141 return r;
142 }
143 slut_address += 4;
144
145 unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", id, obj);
146
147 r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
148 /* Found search term? */
149 if (id == psym->id)
150 {
151 unifi_trace(card->ospriv, UDBG1, " matched SLUT id %02d.%08lx\n", id, obj);
152 psym->obj = obj;
153 r = CSR_RESULT_SUCCESS;
154 break;
155 }
156 }
157
158 return r;
159}
160
161
162/*
163 * ---------------------------------------------------------------------------
164 * do_patch_convert_download
165 *
166 * Download the given firmware image to the UniFi, converting from FWDL
167 * to PTDL XBV format.
168 *
169 * Arguments:
170 * card Pointer to card struct
171 * dlpriv Pointer to source firmware image
172 * fwinfo Pointer to source firmware info struct
173 *
174 * Returns:
175 * CSR_RESULT_SUCCESS on success, CSR error code on error
176 *
177 * Notes:
178 * ---------------------------------------------------------------------------
179 */
180static CsrResult do_patch_convert_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo)
181{
182 CsrResult r;
183 u32 slut_base = 0xffffffff;
184 void *pfw;
185 u32 psize;
186 symbol_t sym;
187
188 /* Reset the chip to guarantee that the ROM loader is running */
189 r = unifi_init(card);
190 if (r != CSR_RESULT_SUCCESS)
191 {
192 unifi_error(card->ospriv,
193 "do_patch_convert_download: failed to re-init UniFi\n");
194 return r;
195 }
196
197 /* If no unifi_helper is running, the firmware version must be read */
198 if (card->build_id == 0)
199 {
200 u32 ver = 0;
201 sym.id = CSR_SLT_BUILD_ID_NUMBER;
202 sym.obj = 0; /* To be updated by _find_in_slut() */
203
204 unifi_trace(card->ospriv, UDBG1, "Need f/w version\n");
205
206 /* Find chip build id entry in SLUT */
207 r = _find_in_slut(card, &sym, &slut_base);
208 if (r != CSR_RESULT_SUCCESS)
209 {
210 unifi_error(card->ospriv, "Failed to find CSR_SLT_BUILD_ID_NUMBER\n");
211 return CSR_RESULT_FAILURE;
212 }
213
214 /* Read running f/w version */
215 r = unifi_read32(card, sym.obj, &ver);
216 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
217 {
218 return r;
219 }
220 if (r != CSR_RESULT_SUCCESS)
221 {
222 unifi_error(card->ospriv, "Failed to read f/w id\n");
223 return CSR_RESULT_FAILURE;
224 }
225 card->build_id = ver;
226 }
227
228 /* Convert the ptest firmware to a patch against the running firmware */
229 pfw = xbv_to_patch(card, unifi_fw_read, dlpriv, pfwinfo, &psize);
230 if (!pfw)
231 {
232 unifi_error(card->ospriv, "Failed to convert f/w to patch");
233 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
234 }
235 else
236 {
237 void *desc;
238 sym.id = CSR_SLT_BOOT_LOADER_CONTROL;
239 sym.obj = 0; /* To be updated by _find_in_slut() */
240
241 /* Find boot loader control entry in SLUT */
242 r = _find_in_slut(card, &sym, &slut_base);
243 if (r != CSR_RESULT_SUCCESS)
244 {
245 unifi_error(card->ospriv, "Failed to find BOOT_LOADER_CONTROL\n");
246 kfree(pfw);
247 return CSR_RESULT_FAILURE;
248 }
249
250 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
251 if (r != CSR_RESULT_SUCCESS)
252 {
253 unifi_error(card->ospriv, "Failed to wake UniFi\n");
254 }
255
256 /* Get a dlpriv for the patch buffer so that unifi_fw_read() can
257 * access it.
258 */
259 desc = unifi_fw_open_buffer(card->ospriv, pfw, psize);
260 if (!desc)
261 {
262 kfree(pfw);
263 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
264 }
265
266 /* Download the patch */
267 unifi_info(card->ospriv, "Downloading converted f/w as patch\n");
268 r = unifi_dl_patch(card, desc, sym.obj);
269 kfree(pfw);
270 unifi_fw_close_buffer(card->ospriv, desc);
271
272 if (r != CSR_RESULT_SUCCESS)
273 {
274 unifi_error(card->ospriv, "Converted patch download failed\n");
275 return r;
276 }
277 else
278 {
279 unifi_trace(card->ospriv, UDBG1, "Converted patch downloaded\n");
280 }
281
282 /* This command starts the firmware */
283 r = unifi_do_loader_op(card, sym.obj + 6, UNIFI_BOOT_LOADER_RESTART);
284 if (r != CSR_RESULT_SUCCESS)
285 {
286 unifi_error(card->ospriv, "Failed to write loader restart cmd\n");
287 }
288
289 return r;
290 }
291}
292
293
294/*
295 * ---------------------------------------------------------------------------
296 * unifi_dl_firmware
297 *
298 * Download the given firmware image to the UniFi.
299 *
300 * Arguments:
301 * card Pointer to card struct
302 * dlpriv A context pointer from the calling function to be
303 * passed when calling unifi_fw_read().
304 *
305 * Returns:
306 * CSR_RESULT_SUCCESS on success,
307 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
308 * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
309 * CSR_RESULT_FAILURE SDIO error
310 *
311 * Notes:
312 * Stops and resets the chip, does the download and runs the new
313 * firmware.
314 * ---------------------------------------------------------------------------
315 */
316CsrResult unifi_dl_firmware(card_t *card, void *dlpriv)
317{
318 xbv1_t *fwinfo;
319 CsrResult r;
320
321 fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
322 if (fwinfo == NULL)
323 {
324 unifi_error(card->ospriv, "Failed to allocate memory for firmware\n");
325 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
326 }
327
328 /*
329 * Scan the firmware file to find the TLVs we are interested in.
330 * These are:
331 * - check we support the file format version in VERF
332 * - SLTP Symbol Lookup Table Pointer
333 * - FWDL firmware download segments
334 * - FWOV firmware overlay segment
335 * - VMEQ Register probe tests to verify matching h/w
336 */
337 r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
338 if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_firmware)
339 {
340 unifi_error(card->ospriv, "File type is %s, expected firmware.\n",
341 fwinfo->mode == xbv_patch?"patch" : "unknown");
342 kfree(fwinfo);
343 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
344 }
345
346 /* UF6xxx doesn't accept firmware, only patches. Therefore we convert
347 * the file to patch format with version numbers matching the current
348 * running firmware, and then download via the patch mechanism.
349 * The sole purpose of this is to support production test firmware across
350 * different ROM releases, the test firmware being provided in non-patch
351 * format.
352 */
353 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
354 {
355 unifi_info(card->ospriv, "Must convert f/w to patch format\n");
356 r = do_patch_convert_download(card, dlpriv, fwinfo);
357 }
358 else
359 {
360 /* Older UniFi chips allowed firmware to be directly loaded onto the
361 * chip, which is no longer supported.
362 */
363 unifi_error(card->ospriv, "Only patch downloading supported\n");
364 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
365 }
366
367 kfree(fwinfo);
368 return r;
369} /* unifi_dl_firmware() */
370
371
372/*
373 * ---------------------------------------------------------------------------
374 * unifi_dl_patch
375 *
376 * Load the given patch set into UniFi.
377 *
378 * Arguments:
379 * card Pointer to card struct
380 * dlpriv The os specific handle to the firmware file.
381 * boot_ctrl The address of the boot loader control structure.
382 *
383 * Returns:
384 * CSR_RESULT_SUCCESS on success,
385 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
386 * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
387 * CSR_RESULT_FAILURE SDIO error
388 *
389 * Notes:
390 * This ends up telling UniFi to restart.
391 * ---------------------------------------------------------------------------
392 */
393CsrResult unifi_dl_patch(card_t *card, void *dlpriv, u32 boot_ctrl)
394{
395 xbv1_t *fwinfo;
396 CsrResult r;
397
398 unifi_info(card->ospriv, "unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl);
399
400 fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
401 if (fwinfo == NULL)
402 {
403 unifi_error(card->ospriv, "Failed to allocate memory for patches\n");
404 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
405 }
406
407 /*
408 * Scan the firmware file to find the TLVs we are interested in.
409 * These are:
410 * - check we support the file format version in VERF
411 * - FWID The build ID of the ROM that we can patch
412 * - PTDL patch download segments
413 */
414 r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
415 if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_patch)
416 {
417 kfree(fwinfo);
418 unifi_error(card->ospriv, "Failed to read in patch file\n");
419 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
420 }
421
422 /*
423 * We have to check the build id read from the SLUT against that
424 * for the patch file. They have to match exactly.
425 * "card->build_id" == XBV1.PTCH.FWID
426 */
427 if (card->build_id != fwinfo->build_id)
428 {
429 unifi_error(card->ospriv, "Wrong patch file for chip (chip = %lu, file = %lu)\n",
430 card->build_id, fwinfo->build_id);
431 kfree(fwinfo);
432#ifndef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
433 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
434#else
435 fwinfo = NULL;
436 dlpriv = NULL;
437 return CSR_RESULT_SUCCESS;
438#endif
439 }
440
441 r = do_patch_download(card, dlpriv, fwinfo, boot_ctrl);
442 if (r != CSR_RESULT_SUCCESS)
443 {
444 unifi_error(card->ospriv, "Failed to patch image\n");
445 }
446
447 kfree(fwinfo);
448
449 return r;
450} /* unifi_dl_patch() */
451
452
453void* unifi_dl_fw_read_start(card_t *card, s8 is_fw)
454{
455 card_info_t card_info;
456
457 unifi_card_info(card, &card_info);
458 unifi_trace(card->ospriv, UDBG5,
459 "id=%d, ver=0x%x, fw_build=%u, fw_hip=0x%x, block_size=%d\n",
460 card_info.chip_id, card_info.chip_version,
461 card_info.fw_build, card_info.fw_hip_version,
462 card_info.sdio_block_size);
463
464 return unifi_fw_read_start(card->ospriv, is_fw, &card_info);
465}
466
467
468/*
469 * ---------------------------------------------------------------------------
470 * safe_read_shared_location
471 *
472 * Read a shared memory location repeatedly until we get two readings
473 * the same.
474 *
475 * Arguments:
476 * card Pointer to card context struct.
477 * unifi_addr UniFi shared-data-memory address to access.
478 * pdata Pointer to a byte variable for the value read.
479 *
480 *
481 * Returns:
482 * CSR_RESULT_SUCCESS on success, CSR error code on failure
483 * ---------------------------------------------------------------------------
484 */
485static CsrResult safe_read_shared_location(card_t *card, u32 address, u8 *pdata)
486{
487 CsrResult r;
488 u16 limit = 1000;
489 u8 b, b2;
490
491 *pdata = 0;
492
493 r = unifi_read_8_or_16(card, address, &b);
494 if (r != CSR_RESULT_SUCCESS)
495 {
496 return r;
497 }
498
499 while (limit--)
500 {
501 r = unifi_read_8_or_16(card, address, &b2);
502 if (r != CSR_RESULT_SUCCESS)
503 {
504 return r;
505 }
506
507 /* When we have a stable value, return it */
508 if (b == b2)
509 {
510 *pdata = b;
511 return CSR_RESULT_SUCCESS;
512 }
513
514 b = b2;
515 }
516
517 return CSR_RESULT_FAILURE;
518} /* safe_read_shared_location() */
519
520
521/*
522 * ---------------------------------------------------------------------------
523 * unifi_do_loader_op
524 *
525 * Send a loader / boot_loader command to the UniFi and wait for
526 * it to complete.
527 *
528 * Arguments:
529 * card Pointer to card context struct.
530 * op_addr The address of the loader operation control word.
531 * opcode The operation to perform.
532 *
533 * Returns:
534 * CSR_RESULT_SUCCESS on success
535 * CSR_RESULT_FAILURE SDIO error or SDIO/XAP timeout
536 * ---------------------------------------------------------------------------
537 */
538
539/*
540 * Ideally instead of sleeping, we want to busy wait.
541 * Currently there is no framework API to do this. When it becomes available,
542 * we can use it to busy wait using usecs
543 */
544#define OPERATION_TIMEOUT_LOOPS (100) /* when OPERATION_TIMEOUT_DELAY==1, (500) otherwise */
545#define OPERATION_TIMEOUT_DELAY 1 /* msec, or 200usecs */
546
547CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode)
548{
549 CsrResult r;
550 s16 op_retries;
551
552 unifi_trace(card->ospriv, UDBG4, "Loader cmd 0x%0x -> 0x%08x\n", opcode, op_addr);
553
554 /* Set the Operation command byte to the opcode */
555 r = unifi_write_8_or_16(card, op_addr, opcode);
556 if (r != CSR_RESULT_SUCCESS)
557 {
558 unifi_error(card->ospriv, "Failed to write loader copy command\n");
559 return r;
560 }
561
562 /* Wait for Operation command byte to be Idle */
563 /* Typically takes ~100us */
564 op_retries = 0;
565 r = CSR_RESULT_SUCCESS;
566 while (1)
567 {
568 u8 op;
569
570 /*
571 * Read the memory location until two successive reads give
572 * the same value.
573 * Then handle it.
574 */
575 r = safe_read_shared_location(card, op_addr, &op);
576 if (r != CSR_RESULT_SUCCESS)
577 {
578 unifi_error(card->ospriv, "Failed to read loader status\n");
579 break;
580 }
581
582 if (op == UNIFI_LOADER_IDLE)
583 {
584 /* Success */
585 break;
586 }
587
588 if (op != opcode)
589 {
590 unifi_error(card->ospriv, "Error reported by loader: 0x%X\n", op);
591 r = CSR_RESULT_FAILURE;
592 break;
593 }
594
595 /* Allow 500us timeout */
596 if (++op_retries >= OPERATION_TIMEOUT_LOOPS)
597 {
598 unifi_error(card->ospriv, "Timeout waiting for loader to ack transfer\n");
599 /* Stop XAPs to aid post-mortem */
600 r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
601 if (r != CSR_RESULT_SUCCESS)
602 {
603 unifi_error(card->ospriv, "Failed to stop UniFi processors\n");
604 }
605 else
606 {
607 r = CSR_RESULT_FAILURE;
608 }
609 break;
610 }
611 CsrThreadSleep(OPERATION_TIMEOUT_DELAY);
612 } /* Loop exits with r != CSR_RESULT_SUCCESS on error */
613
614 return r;
615} /* unifi_do_loader_op() */
616
617
618/*
619 * ---------------------------------------------------------------------------
620 * send_ptdl_to_unifi
621 *
622 * Copy a patch block from userland to the UniFi.
623 * This function reads data, 2K at a time, from userland and writes
624 * it to the UniFi.
625 *
626 * Arguments:
627 * card A pointer to the card structure
628 * dlpriv The os specific handle for the firmware file
629 * ptdl A pointer ot the PTDL block
630 * handle The buffer handle to use for the xfer
631 * op_addr The address of the loader operation control word
632 *
633 * Returns:
634 * Number of bytes sent (Positive) or negative value indicating
635 * error code:
636 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
637 * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
638 * CSR_RESULT_FAILURE SDIO error
639 * ---------------------------------------------------------------------------
640 */
641static CsrResult send_ptdl_to_unifi(card_t *card, void *dlpriv,
642 const struct PTDL *ptdl, u32 handle,
643 u32 op_addr)
644{
645 u32 offset;
646 u8 *buf;
647 s32 data_len;
648 u32 write_len;
649 CsrResult r;
650 const u16 buf_size = 2 * 1024;
651
652 offset = ptdl->dl_offset;
653 data_len = ptdl->dl_size;
654
655 if (data_len > buf_size)
656 {
657 unifi_error(card->ospriv, "PTDL block is too large (%u)\n",
658 ptdl->dl_size);
659 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
660 }
661
662 buf = kmalloc(buf_size, GFP_KERNEL);
663 if (buf == NULL)
664 {
665 unifi_error(card->ospriv, "Failed to allocate transfer buffer for firmware download\n");
666 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
667 }
668
669 r = CSR_RESULT_SUCCESS;
670
671 if (unifi_fw_read(card->ospriv, dlpriv, offset, buf, data_len) != data_len)
672 {
673 unifi_error(card->ospriv, "Failed to read from file\n");
674 }
675 else
676 {
677 /* We can always round these if the host wants to */
678 if (card->sdio_io_block_pad)
679 {
680 write_len = (data_len + (card->sdio_io_block_size - 1)) &
681 ~(card->sdio_io_block_size - 1);
682
683 /* Zero out the rest of the buffer (This isn't needed, but it
684 * makes debugging things later much easier). */
685 memset(buf + data_len, 0, write_len - data_len);
686 }
687 else
688 {
689 write_len = data_len;
690 }
691
692 r = unifi_bulk_rw_noretry(card, handle, buf, write_len, UNIFI_SDIO_WRITE);
693 if (r != CSR_RESULT_SUCCESS)
694 {
695 unifi_error(card->ospriv, "CMD53 failed writing %d bytes to handle %ld\n",
696 data_len, handle);
697 }
698 else
699 {
700 /*
701 * Can change the order of things to overlap read from file
702 * with copy to unifi
703 */
704 r = unifi_do_loader_op(card, op_addr, UNIFI_BOOT_LOADER_PATCH);
705 }
706 }
707
708 kfree(buf);
709
710 if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
711 {
712 unifi_error(card->ospriv, "Failed to copy block of %u bytes to UniFi\n",
713 ptdl->dl_size);
714 }
715
716 return r;
717} /* send_ptdl_to_unifi() */
718
719
720/*
721 * ---------------------------------------------------------------------------
722 * do_patch_download
723 *
724 * This function downloads a set of patches to UniFi and then
725 * causes it to restart.
726 *
727 * Arguments:
728 * card Pointer to card struct.
729 * dlpriv A context pointer from the calling function to be
730 * used when reading the XBV file. This can be NULL
731 * in which case not patches are applied.
732 * pfwinfo Pointer to a fwinfo struct describing the f/w
733 * XBV file.
734 * boot_ctrl_addr The address of the boot loader control structure.
735 *
736 * Returns:
737 * 0 on success, or an error code
738 * CSR_WIFI_HIP_RESULT_INVALID_VALUE for a bad laoader version number
739 * ---------------------------------------------------------------------------
740 */
741static CsrResult do_patch_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo, u32 boot_ctrl_addr)
742{
743 CsrResult r;
744 s32 i;
745 u16 loader_version;
746 u16 handle;
747 u32 total_bytes;
748
749 /*
750 * Read info from the SDIO Loader Control Data Structure
751 */
752 /* Check the loader version */
753 r = unifi_card_read16(card, boot_ctrl_addr, &loader_version);
754 if (r != CSR_RESULT_SUCCESS)
755 {
756 unifi_error(card->ospriv, "Patch download: Failed to read loader version\n");
757 return r;
758 }
759 unifi_trace(card->ospriv, UDBG2, "Patch download: boot loader version 0x%04X\n", loader_version);
760 switch (loader_version)
761 {
762 case 0x0000:
763 break;
764
765 default:
766 unifi_error(card->ospriv, "Patch loader version (0x%04X) is not supported by this driver\n",
767 loader_version);
768 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
769 }
770
771 /* Retrieve the handle to use with CMD53 */
772 r = unifi_card_read16(card, boot_ctrl_addr + 4, &handle);
773 if (r != CSR_RESULT_SUCCESS)
774 {
775 unifi_error(card->ospriv, "Patch download: Failed to read loader handle\n");
776 return r;
777 }
778
779 /* Set the mask of LEDs to flash */
780 if (card->loader_led_mask)
781 {
782 r = unifi_card_write16(card, boot_ctrl_addr + 2,
783 (u16)card->loader_led_mask);
784 if (r != CSR_RESULT_SUCCESS)
785 {
786 unifi_error(card->ospriv, "Patch download: Failed to write LED mask\n");
787 return r;
788 }
789 }
790
791 total_bytes = 0;
792
793 /* Copy download data to UniFi memory */
794 for (i = 0; i < pfwinfo->num_ptdl; i++)
795 {
796 unifi_trace(card->ospriv, UDBG3, "Patch download: %d Downloading for %d from offset %d\n",
797 i,
798 pfwinfo->ptdl[i].dl_size,
799 pfwinfo->ptdl[i].dl_offset);
800
801 r = send_ptdl_to_unifi(card, dlpriv, &pfwinfo->ptdl[i],
802 handle, boot_ctrl_addr + 6);
803 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
804 {
805 return r;
806 }
807 if (r != CSR_RESULT_SUCCESS)
808 {
809 unifi_error(card->ospriv, "Patch failed after %u bytes\n",
810 total_bytes);
811 return r;
812 }
813 total_bytes += pfwinfo->ptdl[i].dl_size;
814 }
815
816 return CSR_RESULT_SUCCESS;
817} /* do_patch_download() */
818
819
diff --git a/drivers/staging/csr/csr_wifi_hip_dump.c b/drivers/staging/csr/csr_wifi_hip_dump.c
deleted file mode 100644
index 7b7eec49d028..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_dump.c
+++ /dev/null
@@ -1,837 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_dump.c
14 *
15 * PURPOSE:
16 * Routines for retrieving and buffering core status from the UniFi
17 *
18 * ---------------------------------------------------------------------------
19 */
20#include <linux/slab.h>
21#include "csr_wifi_hip_unifi.h"
22#include "csr_wifi_hip_unifiversion.h"
23#include "csr_wifi_hip_card.h"
24
25/* Locations to capture in dump (XAP words) */
26#define HIP_CDUMP_FIRST_CPUREG (0xFFE0) /* First CPU register */
27#define HIP_CDUMP_FIRST_LO (0) /* Start of low address range */
28#define HIP_CDUMP_FIRST_HI_MAC (0x3C00) /* Start of MAC high area */
29#define HIP_CDUMP_FIRST_HI_PHY (0x1C00) /* Start of PHY high area */
30#define HIP_CDUMP_FIRST_SH (0) /* Start of shared memory area */
31
32#define HIP_CDUMP_NCPUREGS (10) /* No. of 16-bit XAP registers */
33#define HIP_CDUMP_NWORDS_LO (0x0100) /* Low area size in 16-bit words */
34#define HIP_CDUMP_NWORDS_HI (0x0400) /* High area size in 16-bit words */
35#define HIP_CDUMP_NWORDS_SH (0x0500) /* Shared memory area size, 16-bit words */
36
37#define HIP_CDUMP_NUM_ZONES 7 /* Number of UniFi memory areas to capture */
38
39/* Mini-coredump state */
40typedef struct coredump_buf
41{
42 u16 count; /* serial number of dump */
43 u32 timestamp; /* host's system time at capture */
44 s16 requestor; /* request: 0=auto dump, 1=manual */
45 u16 chip_ver;
46 u32 fw_ver;
47 u16 *zone[HIP_CDUMP_NUM_ZONES];
48
49 struct coredump_buf *next; /* circular list */
50 struct coredump_buf *prev; /* circular list */
51} coredump_buffer;
52
53/* Structure used to describe a zone of chip memory captured by mini-coredump */
54struct coredump_zone
55{
56 unifi_coredump_space_t space; /* XAP memory space this zone covers */
57 enum unifi_dbg_processors_select cpu; /* XAP CPU core selector */
58 u32 gp; /* Generic Pointer to memory zone on XAP */
59 u16 offset; /* 16-bit XAP word offset of zone in memory space */
60 u16 length; /* Length of zone in XAP words */
61};
62
63static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf);
64static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf);
65static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zone,
66 const struct coredump_zone *def);
67static s32 get_value_from_coredump(const coredump_buffer *dump,
68 const unifi_coredump_space_t space, const u16 offset);
69
70/* Table of chip memory zones we capture on mini-coredump */
71static const struct coredump_zone zonedef_table[HIP_CDUMP_NUM_ZONES] = {
72 { UNIFI_COREDUMP_MAC_REG, UNIFI_PROC_MAC, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
73 { UNIFI_COREDUMP_PHY_REG, UNIFI_PROC_PHY, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
74 { 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 },
75 { 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 },
76 { 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 },
77 { 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 },
78 { 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 },
79};
80
81/*
82 * ---------------------------------------------------------------------------
83 * unifi_coredump_request_at_next_reset
84 *
85 * Request that a mini-coredump is performed when the driver has
86 * completed resetting the UniFi device.
87 *
88 * Arguments:
89 * card Pointer to card struct
90 * enable If non-zero, sets the request.
91 * If zero, cancels any pending request.
92 *
93 * Returns:
94 * CSR_RESULT_SUCCESS or CSR HIP error code
95 *
96 * Notes:
97 * This function is typically called once the driver has detected that
98 * the UniFi device has become unresponsive due to crash, or internal
99 * watchdog reset. The driver must reset it to regain communication and,
100 * immediately after that, the mini-coredump can be captured.
101 * ---------------------------------------------------------------------------
102 */
103CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable)
104{
105 CsrResult r;
106
107 if (enable)
108 {
109 unifi_trace(card->ospriv, UDBG2, "Mini-coredump requested after reset\n");
110 }
111
112 if (card == NULL)
113 {
114 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
115 }
116 else
117 {
118 card->request_coredump_on_reset = enable?1 : 0;
119 r = CSR_RESULT_SUCCESS;
120 }
121
122 return r;
123}
124
125
126/*
127 * ---------------------------------------------------------------------------
128 * unifi_coredump_handle_request
129 *
130 * Performs a coredump now, if one was requested, and clears the request.
131 *
132 * Arguments:
133 * card Pointer to card struct
134 *
135 * Returns:
136 * CSR_RESULT_SUCCESS or CSR HIP error code
137 *
138 * Notes:
139 * ---------------------------------------------------------------------------
140 */
141CsrResult unifi_coredump_handle_request(card_t *card)
142{
143 CsrResult r = CSR_RESULT_SUCCESS;
144
145 if (card == NULL)
146 {
147 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
148 }
149 else
150 {
151 if (card->request_coredump_on_reset == 1)
152 {
153 card->request_coredump_on_reset = 0;
154 r = unifi_coredump_capture(card, NULL);
155 }
156 }
157
158 return r;
159}
160
161
162/*
163 * ---------------------------------------------------------------------------
164 * unifi_coredump_capture
165 *
166 * Capture the current status of the UniFi device.
167 * Various registers are buffered for future offline inspection.
168 *
169 * Arguments:
170 * card Pointer to card struct
171 * req Pointer to request struct, or NULL:
172 * A coredump requested manually by the user app
173 * will have a request struct pointer, an automatic
174 * coredump will have a NULL pointer.
175 * Returns:
176 * CSR_RESULT_SUCCESS on success,
177 * CSR_RESULT_FAILURE SDIO error
178 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Initialisation not complete
179 *
180 * Notes:
181 * The result is a filled entry in the circular buffer of core dumps,
182 * values from which can be extracted to userland via an ioctl.
183 * ---------------------------------------------------------------------------
184 */
185CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req)
186{
187 CsrResult r = CSR_RESULT_SUCCESS;
188 static u16 dump_seq_no = 1;
189 u32 time_of_capture;
190
191 if (card->dump_next_write == NULL)
192 {
193 r = CSR_RESULT_SUCCESS;
194 goto done;
195 }
196
197 /* Reject forced capture before initialisation has happened */
198 if (card->helper == NULL)
199 {
200 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
201 goto done;
202 }
203
204
205 /*
206 * Force a mini-coredump capture right now
207 */
208 time_of_capture = CsrTimeGet(NULL);
209 unifi_info(card->ospriv, "Mini-coredump capture at t=%u\n", time_of_capture);
210
211 /* Wake up the processors so we can talk to them */
212 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
213 if (r != CSR_RESULT_SUCCESS)
214 {
215 unifi_error(card->ospriv, "Failed to wake UniFi\n");
216 goto done;
217 }
218 CsrThreadSleep(20);
219
220 /* Stop both XAPs */
221 unifi_trace(card->ospriv, UDBG4, "Stopping XAPs for coredump capture\n");
222 r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
223 if (r != CSR_RESULT_SUCCESS)
224 {
225 unifi_error(card->ospriv, "Failed to stop UniFi XAPs\n");
226 goto done;
227 }
228
229 /* Dump core into the next available slot in the circular list */
230 r = unifi_coredump_from_sdio(card, card->dump_next_write);
231 if (r == CSR_RESULT_SUCCESS)
232 {
233 /* Record whether the dump was manual or automatic */
234 card->dump_next_write->requestor = (req?1 : 0);
235 card->dump_next_write->timestamp = time_of_capture;
236 /* Advance to the next buffer */
237 card->dump_next_write->count = dump_seq_no++;
238 card->dump_cur_read = card->dump_next_write;
239 card->dump_next_write = card->dump_next_write->next;
240
241 /* Sequence no. of zero indicates slot not in use, so handle wrap */
242 if (dump_seq_no == 0)
243 {
244 dump_seq_no = 1;
245 }
246
247 unifi_trace(card->ospriv, UDBG3,
248 "Coredump (%p), SeqNo=%d, cur_read=%p, next_write=%p\n",
249 req,
250 card->dump_cur_read->count,
251 card->dump_cur_read, card->dump_next_write);
252 }
253
254 /* Start both XAPs */
255 unifi_trace(card->ospriv, UDBG4, "Restart XAPs after coredump\n");
256 r = card_start_processor(card, UNIFI_PROC_BOTH);
257 if (r != CSR_RESULT_SUCCESS)
258 {
259 unifi_error(card->ospriv, "Failed to start UniFi XAPs\n");
260 goto done;
261 }
262
263done:
264 return r;
265} /* unifi_coredump_capture() */
266
267
268/*
269 * ---------------------------------------------------------------------------
270 * get_value_from_coredump
271 *
272 *
273 *
274 * Arguments:
275 * dump Pointer to buffered coredump data
276 * offset_in_space XAP memory space to retrieve from the buffer (there
277 * may be more than one zone covering the same memory
278 * space, but starting from different offsets).
279 * offset Offset within the XAP memory space to be retrieved
280 *
281 * Returns:
282 * >=0 Register value on success
283 * <0 Register out of range of any captured zones
284 *
285 * Notes:
286 * ---------------------------------------------------------------------------
287 */
288static s32 get_value_from_coredump(const coredump_buffer *coreDump,
289 const unifi_coredump_space_t space,
290 const u16 offset_in_space)
291{
292 s32 r = -1;
293 u16 offset_in_zone;
294 u32 zone_end_offset;
295 s32 i;
296 const struct coredump_zone *def = &zonedef_table[0];
297
298 /* Search zone def table for a match with the requested memory space */
299 for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++, def++)
300 {
301 if (space == def->space)
302 {
303 zone_end_offset = def->offset + def->length;
304
305 /* Is the space offset contained in this zone? */
306 if (offset_in_space < zone_end_offset &&
307 offset_in_space >= def->offset)
308 {
309 /* Calculate the offset of data within the zone buffer */
310 offset_in_zone = offset_in_space - def->offset;
311 r = (s32) * (coreDump->zone[i] + offset_in_zone);
312
313 unifi_trace(NULL, UDBG6,
314 "sp %d, offs 0x%04x = 0x%04x (in z%d 0x%04x->0x%04x)\n",
315 space, offset_in_space, r,
316 i, def->offset, zone_end_offset - 1);
317 break;
318 }
319 }
320 }
321 return r;
322}
323
324
325/*
326 * ---------------------------------------------------------------------------
327 * unifi_coredump_get_value
328 *
329 * Retrieve the value of a register buffered from a previous core dump,
330 * so that it may be reported back to application code.
331 *
332 * Arguments:
333 * card Pointer to card struct
334 * req_reg Pointer to request parameter partially filled. This
335 * function puts in the values retrieved from the dump.
336 *
337 * Returns:
338 * CSR_RESULT_SUCCESS on success, or:
339 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Null parameter error
340 * CSR_WIFI_HIP_RESULT_RANGE Register out of range
341 * CSR_WIFI_HIP_RESULT_NOT_FOUND Dump index not (yet) captured
342 *
343 * Notes:
344 * ---------------------------------------------------------------------------
345 */
346CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req)
347{
348 CsrResult r;
349 s32 i = 0;
350 coredump_buffer *find_dump = NULL;
351
352 if (req == NULL || card == NULL)
353 {
354 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
355 goto done;
356 }
357 req->value = -1;
358 if (card->dump_buf == NULL)
359 {
360 unifi_trace(card->ospriv, UDBG2, "No coredump buffers\n");
361 r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* Coredumping disabled */
362 goto done;
363 }
364 if (card->dump_cur_read == NULL)
365 {
366 unifi_trace(card->ospriv, UDBG4, "No coredumps captured\n");
367 r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* No coredump yet captured */
368 goto done;
369 }
370
371 /* Find the requested dump buffer */
372 switch (req->index)
373 {
374 case 0: /* Newest */
375 find_dump = card->dump_cur_read;
376 break;
377 case -1: /* Oldest: The next used slot forward */
378 for (find_dump = card->dump_cur_read->next;
379 (find_dump->count == 0) && (find_dump != card->dump_cur_read);
380 find_dump = card->dump_cur_read->next)
381 {
382 }
383 break;
384 default: /* Number of steps back from current read position */
385 for (i = 0, find_dump = card->dump_cur_read;
386 i < req->index;
387 i++, find_dump = find_dump->prev)
388 {
389 /* Walk the list for the index'th entry, but
390 * stop when about to wrap. */
391 unifi_trace(card->ospriv, UDBG6,
392 "%d: %d, @%p, p=%p, n=%p, cr=%p, h=%p\n",
393 i, find_dump->count, find_dump, find_dump->prev,
394 find_dump->next, card->dump_cur_read, card->dump_buf);
395 if (find_dump->prev == card->dump_cur_read)
396 {
397 /* Wrapped but still not found, index out of range */
398 if (i != req->index)
399 {
400 unifi_trace(card->ospriv, UDBG6,
401 "Dump index %d not found %d\n", req->index, i);
402 r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
403 goto done;
404 }
405 break;
406 }
407 }
408 break;
409 }
410
411 /* Check if the slot is actually filled with a core dump */
412 if (find_dump->count == 0)
413 {
414 unifi_trace(card->ospriv, UDBG4, "Not captured %d\n", req->index);
415 r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
416 goto done;
417 }
418
419 unifi_trace(card->ospriv, UDBG6, "Req index %d, found seq %d at step %d\n",
420 req->index, find_dump->count, i);
421
422 /* Find the appropriate entry in the buffer */
423 req->value = get_value_from_coredump(find_dump, req->space, (u16)req->offset);
424 if (req->value < 0)
425 {
426 r = CSR_WIFI_HIP_RESULT_RANGE; /* Un-captured register */
427 unifi_trace(card->ospriv, UDBG4,
428 "Can't read space %d, reg 0x%x from coredump buffer %d\n",
429 req->space, req->offset, req->index);
430 }
431 else
432 {
433 r = CSR_RESULT_SUCCESS;
434 }
435
436 /* Update the private request structure with the found values */
437 req->chip_ver = find_dump->chip_ver;
438 req->fw_ver = find_dump->fw_ver;
439 req->timestamp = find_dump->timestamp;
440 req->requestor = find_dump->requestor;
441 req->serial = find_dump->count;
442
443done:
444 return r;
445} /* unifi_coredump_get_value() */
446
447
448/*
449 * ---------------------------------------------------------------------------
450 * unifi_coredump_read_zone
451 *
452 * Captures a UniFi memory zone into a buffer on the host
453 *
454 * Arguments:
455 * card Pointer to card struct
456 * zonebuf Pointer to on-host buffer to dump the memory zone into
457 * def Pointer to description of the memory zone to read from UniFi.
458 *
459 * Returns:
460 * CSR_RESULT_SUCCESS on success, or:
461 * CSR_RESULT_FAILURE SDIO error
462 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
463 *
464 * Notes:
465 * It is assumed that the caller has already stopped the XAPs
466 * ---------------------------------------------------------------------------
467 */
468static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zonebuf, const struct coredump_zone *def)
469{
470 CsrResult r;
471
472 if (zonebuf == NULL || def == NULL)
473 {
474 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
475 goto done;
476 }
477
478 /* Select XAP CPU if necessary */
479 if (def->cpu != UNIFI_PROC_INVALID)
480 {
481 if (def->cpu != UNIFI_PROC_MAC && def->cpu != UNIFI_PROC_PHY)
482 {
483 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
484 goto done;
485 }
486 r = unifi_set_proc_select(card, def->cpu);
487 if (r != CSR_RESULT_SUCCESS)
488 {
489 goto done;
490 }
491 }
492
493 unifi_trace(card->ospriv, UDBG4,
494 "Dump sp %d, offs 0x%04x, 0x%04x words @GP=%08x CPU %d\n",
495 def->space, def->offset, def->length, def->gp, def->cpu);
496
497 /* Read on-chip RAM (byte-wise) */
498 r = unifi_card_readn(card, def->gp, zonebuf, (u16)(def->length * 2));
499 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
500 {
501 goto done;
502 }
503 if (r != CSR_RESULT_SUCCESS)
504 {
505 unifi_error(card->ospriv, "Can't read UniFi shared data area\n");
506 goto done;
507 }
508
509done:
510 return r;
511}
512
513
514/*
515 * ---------------------------------------------------------------------------
516 * unifi_coredump_read_zones
517 *
518 * Walks through the table of on-chip memory zones defined in zonedef_table,
519 * and reads each of them from the UniFi chip
520 *
521 * Arguments:
522 * card Pointer to card struct
523 * dump_buf Buffer into which register values will be dumped
524 *
525 * Returns:
526 * CSR_RESULT_SUCCESS on success, or:
527 * CSR_RESULT_FAILURE SDIO error
528 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
529 *
530 * Notes:
531 * It is assumed that the caller has already stopped the XAPs
532 * ---------------------------------------------------------------------------
533 */
534static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf)
535{
536 CsrResult r = CSR_RESULT_SUCCESS;
537 s32 i;
538
539 /* Walk the table of coredump zone definitions and read them from the chip */
540 for (i = 0;
541 (i < HIP_CDUMP_NUM_ZONES) && (r == 0);
542 i++)
543 {
544 r = unifi_coredump_read_zone(card, dump_buf->zone[i], &zonedef_table[i]);
545 }
546
547 return r;
548}
549
550
551/*
552 * ---------------------------------------------------------------------------
553 * unifi_coredump_from_sdio
554 *
555 * Capture the status of the UniFi processors, over SDIO
556 *
557 * Arguments:
558 * card Pointer to card struct
559 * reg_buffer Buffer into which register values will be dumped
560 *
561 * Returns:
562 * CSR_RESULT_SUCCESS on success, or:
563 * CSR_RESULT_FAILURE SDIO error
564 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
565 *
566 * Notes:
567 * ---------------------------------------------------------------------------
568 */
569static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf)
570{
571 u16 val;
572 CsrResult r;
573 u32 sdio_addr;
574
575 if (dump_buf == NULL)
576 {
577 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
578 goto done;
579 }
580
581
582 /* Chip and firmware version */
583 unifi_trace(card->ospriv, UDBG4, "Get chip version\n");
584 sdio_addr = 2 * ChipHelper_GBL_CHIP_VERSION(card->helper);
585 if (sdio_addr != 0)
586 {
587 r = unifi_read_direct16(card, sdio_addr, &val);
588 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
589 {
590 goto done;
591 }
592 if (r != CSR_RESULT_SUCCESS)
593 {
594 unifi_error(card->ospriv, "Can't read GBL_CHIP_VERSION\n");
595 goto done;
596 }
597 }
598 dump_buf->chip_ver = val;
599 dump_buf->fw_ver = card->build_id;
600
601 unifi_trace(card->ospriv, UDBG4, "chip_ver 0x%04x, fw_ver %u\n",
602 dump_buf->chip_ver, dump_buf->fw_ver);
603
604 /* Capture the memory zones required from UniFi */
605 r = unifi_coredump_read_zones(card, dump_buf);
606 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
607 {
608 goto done;
609 }
610 if (r != CSR_RESULT_SUCCESS)
611 {
612 unifi_error(card->ospriv, "Can't read UniFi memory areas\n");
613 goto done;
614 }
615
616done:
617 return r;
618} /* unifi_coredump_from_sdio() */
619
620
621#ifndef UNIFI_DISABLE_COREDUMP
622/*
623 * ---------------------------------------------------------------------------
624 * new_coredump_node
625 *
626 * Allocates a coredump linked-list node, and links it to the previous.
627 *
628 * Arguments:
629 * ospriv OS context
630 * prevnode Previous node to link into
631 *
632 * Returns:
633 * Pointer to valid coredump_buffer on success
634 * NULL on memory allocation failure
635 *
636 * Notes:
637 * Allocates "all or nothing"
638 * ---------------------------------------------------------------------------
639 */
640static
641coredump_buffer* new_coredump_node(void *ospriv, coredump_buffer *prevnode)
642{
643 coredump_buffer *newnode = NULL;
644 u16 *newzone = NULL;
645 s32 i;
646 u32 zone_size;
647
648 /* Allocate node header */
649 newnode = kzalloc(sizeof(coredump_buffer), GFP_KERNEL);
650 if (newnode == NULL)
651 {
652 return NULL;
653 }
654
655 /* Allocate chip memory zone capture buffers */
656 for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++)
657 {
658 zone_size = sizeof(u16) * zonedef_table[i].length;
659 newzone = kzalloc(zone_size, GFP_KERNEL);
660 newnode->zone[i] = newzone;
661 if (newzone == NULL)
662 {
663 unifi_error(ospriv, "Out of memory on coredump zone %d (%d words)\n",
664 i, zonedef_table[i].length);
665 break;
666 }
667 }
668
669 /* Clean up if any zone alloc failed */
670 if (newzone == NULL)
671 {
672 for (i = 0; newnode->zone[i] != NULL; i++)
673 {
674 kfree(newnode->zone[i]);
675 newnode->zone[i] = NULL;
676 }
677 }
678
679 /* Link to previous node */
680 newnode->prev = prevnode;
681 if (prevnode)
682 {
683 prevnode->next = newnode;
684 }
685 newnode->next = NULL;
686
687 return newnode;
688}
689
690
691#endif /* UNIFI_DISABLE_COREDUMP */
692
693/*
694 * ---------------------------------------------------------------------------
695 * unifi_coredump_init
696 *
697 * Allocates buffers for the automatic SDIO core dump
698 *
699 * Arguments:
700 * card Pointer to card struct
701 * num_dump_buffers Number of buffers to reserve for coredumps
702 *
703 * Returns:
704 * CSR_RESULT_SUCCESS on success, or:
705 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
706 *
707 * Notes:
708 * Allocates space in advance, to be used for the last n coredump buffers
709 * the intention being that the size is sufficient for at least one dump,
710 * probably several.
711 * It's probably advisable to have at least 2 coredump buffers to allow
712 * one to be enquired with the unifi_coredump tool, while leaving another
713 * free for capturing.
714 * ---------------------------------------------------------------------------
715 */
716CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers)
717{
718#ifndef UNIFI_DISABLE_COREDUMP
719 void *ospriv = card->ospriv;
720 coredump_buffer *prev = NULL;
721 coredump_buffer *newnode = NULL;
722 u32 i = 0;
723#endif
724
725 card->request_coredump_on_reset = 0;
726 card->dump_next_write = NULL;
727 card->dump_cur_read = NULL;
728 card->dump_buf = NULL;
729
730#ifndef UNIFI_DISABLE_COREDUMP
731 unifi_trace(ospriv, UDBG1,
732 "Allocate buffers for %d core dumps\n", num_dump_buffers);
733 if (num_dump_buffers == 0)
734 {
735 goto done;
736 }
737
738 /* Root node */
739 card->dump_buf = new_coredump_node(ospriv, NULL);
740 if (card->dump_buf == NULL)
741 {
742 goto fail;
743 }
744 prev = card->dump_buf;
745 newnode = card->dump_buf;
746
747 /* Add each subsequent node at tail */
748 for (i = 1; i < num_dump_buffers; i++)
749 {
750 newnode = new_coredump_node(ospriv, prev);
751 if (newnode == NULL)
752 {
753 goto fail;
754 }
755 prev = newnode;
756 }
757
758 /* Link the first and last nodes to make the list circular */
759 card->dump_buf->prev = newnode;
760 newnode->next = card->dump_buf;
761
762 /* Set initial r/w access pointers */
763 card->dump_next_write = card->dump_buf;
764 card->dump_cur_read = NULL;
765
766 unifi_trace(ospriv, UDBG2, "Core dump configured (%d dumps max)\n", i);
767
768done:
769#endif
770 return CSR_RESULT_SUCCESS;
771
772#ifndef UNIFI_DISABLE_COREDUMP
773fail:
774 /* Unwind what we allocated so far */
775 unifi_error(ospriv, "Out of memory allocating core dump node %d\n", i);
776 unifi_coredump_free(card);
777 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
778#endif
779} /* unifi_coreump_init() */
780
781
782/*
783 * ---------------------------------------------------------------------------
784 * unifi_coredump_free
785 *
786 * Free all memory dynamically allocated for core dump
787 *
788 * Arguments:
789 * card Pointer to card struct
790 *
791 * Returns:
792 * None
793 *
794 * Notes:
795 * ---------------------------------------------------------------------------
796 */
797void unifi_coredump_free(card_t *card)
798{
799 void *ospriv = card->ospriv;
800 coredump_buffer *node, *del_node;
801 s16 i = 0;
802 s16 j;
803
804 unifi_trace(ospriv, UDBG2, "Core dump de-configured\n");
805
806 if (card->dump_buf == NULL)
807 {
808 return;
809 }
810
811 node = card->dump_buf;
812 do
813 {
814 /* Free payload zones */
815 for (j = 0; j < HIP_CDUMP_NUM_ZONES; j++)
816 {
817 kfree(node->zone[j]);
818 node->zone[j] = NULL;
819 }
820
821 /* Detach */
822 del_node = node;
823 node = node->next;
824
825 /* Free header */
826 kfree(del_node);
827 i++;
828 } while ((node != NULL) && (node != card->dump_buf));
829
830 unifi_trace(ospriv, UDBG3, "Freed %d coredump buffers\n", i);
831
832 card->dump_buf = NULL;
833 card->dump_next_write = NULL;
834 card->dump_cur_read = NULL;
835} /* unifi_coredump_free() */
836
837
diff --git a/drivers/staging/csr/csr_wifi_hip_packing.c b/drivers/staging/csr/csr_wifi_hip_packing.c
deleted file mode 100644
index 0768aefc6d1f..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_packing.c
+++ /dev/null
@@ -1,4804 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#include "csr_wifi_hip_signals.h"
14#include "csr_wifi_hip_unifi.h"
15#include "csr_wifi_hip_conversions.h"
16
17
18/*
19 * ---------------------------------------------------------------------------
20 * get_packed_struct_size
21 *
22 * Examine a buffer containing a UniFi signal in wire-format.
23 * The first two bytes contain the signal ID, decode the signal ID and
24 * return the size, in bytes, of the signal, not including any bulk
25 * data.
26 *
27 * WARNING: This function is auto-generated, DO NOT EDIT!
28 *
29 * Arguments:
30 * buf Pointer to buffer to decode.
31 *
32 * Returns:
33 * 0 if the signal ID is not recognised (i.e. zero length),
34 * otherwise the number of bytes occupied by the signal in the buffer.
35 * This is useful for stepping past the signal to the object in the buffer.
36 * ---------------------------------------------------------------------------
37 */
38s32 get_packed_struct_size(const u8 *buf)
39{
40 s32 size = 0;
41 u16 sig_id;
42
43 sig_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(buf);
44
45 size += SIZEOF_UINT16;
46 size += SIZEOF_UINT16;
47 size += SIZEOF_UINT16;
48 switch (sig_id)
49 {
50#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
51 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
52 size += SIZEOF_UINT16;
53 size += SIZEOF_UINT16;
54 size += SIZEOF_UINT16;
55 size += SIZEOF_UINT16;
56 size += SIZEOF_UINT16;
57 size += SIZEOF_UINT16;
58 break;
59#endif
60#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
61 case CSR_MLME_SETKEYS_CONFIRM_ID:
62 size += SIZEOF_UINT16;
63 size += SIZEOF_UINT16;
64 size += SIZEOF_UINT16;
65 size += SIZEOF_UINT16;
66 size += SIZEOF_UINT16;
67 size += SIZEOF_UINT16;
68 break;
69#endif
70#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
71 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
72 size += SIZEOF_UINT16;
73 size += SIZEOF_UINT16;
74 size += SIZEOF_UINT16;
75 size += SIZEOF_UINT16;
76 size += SIZEOF_UINT16;
77 break;
78#endif
79#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
80 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
81 size += SIZEOF_UINT16;
82 size += SIZEOF_UINT16;
83 size += SIZEOF_UINT16;
84 size += SIZEOF_UINT16;
85 size += SIZEOF_UINT16;
86 size += SIZEOF_UINT16;
87 size += SIZEOF_UINT16;
88 break;
89#endif
90#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
91 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
92 size += SIZEOF_UINT16;
93 size += SIZEOF_UINT16;
94 size += SIZEOF_UINT16;
95 size += SIZEOF_UINT16;
96 size += SIZEOF_UINT16;
97 size += SIZEOF_UINT16;
98 size += SIZEOF_UINT16;
99 break;
100#endif
101#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
102 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
103 size += SIZEOF_UINT16;
104 size += SIZEOF_UINT16;
105 size += SIZEOF_UINT16;
106 size += SIZEOF_UINT16;
107 size += SIZEOF_UINT16;
108 size += SIZEOF_UINT16;
109 break;
110#endif
111#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
112 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
113 size += SIZEOF_UINT16;
114 size += SIZEOF_UINT16;
115 size += SIZEOF_UINT16;
116 size += SIZEOF_UINT16;
117 size += SIZEOF_UINT16;
118 size += SIZEOF_UINT16;
119 size += SIZEOF_UINT16;
120 size += SIZEOF_UINT16;
121 size += SIZEOF_UINT16;
122 size += SIZEOF_UINT16;
123 size += SIZEOF_UINT16;
124 size += SIZEOF_UINT16;
125 size += SIZEOF_UINT16;
126 size += SIZEOF_UINT16;
127 break;
128#endif
129#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
130 case CSR_MLME_SM_START_CONFIRM_ID:
131 size += SIZEOF_UINT16;
132 size += SIZEOF_UINT16;
133 size += SIZEOF_UINT16;
134 size += SIZEOF_UINT16;
135 size += SIZEOF_UINT16;
136 size += SIZEOF_UINT16;
137 break;
138#endif
139#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
140 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
141 size += SIZEOF_UINT16;
142 size += SIZEOF_UINT16;
143 size += SIZEOF_UINT16;
144 size += SIZEOF_UINT16;
145 size += SIZEOF_UINT16;
146 size += 48 / 8;
147 size += SIZEOF_UINT16;
148 size += SIZEOF_UINT16;
149 size += SIZEOF_UINT16;
150 break;
151#endif
152#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
153 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
154 size += SIZEOF_UINT16;
155 size += SIZEOF_UINT16;
156 size += SIZEOF_UINT16;
157 size += SIZEOF_UINT16;
158 size += SIZEOF_UINT16;
159 size += SIZEOF_UINT16;
160 size += SIZEOF_UINT16;
161 break;
162#endif
163 case CSR_DEBUG_WORD16_INDICATION_ID:
164 size += SIZEOF_UINT16;
165 size += SIZEOF_UINT16;
166 size += SIZEOF_UINT16;
167 size += SIZEOF_UINT16;
168 size += SIZEOF_UINT16;
169 size += SIZEOF_UINT16;
170 size += SIZEOF_UINT16;
171 size += SIZEOF_UINT16;
172 size += SIZEOF_UINT16;
173 size += SIZEOF_UINT16;
174 size += SIZEOF_UINT16;
175 size += SIZEOF_UINT16;
176 size += SIZEOF_UINT16;
177 size += SIZEOF_UINT16;
178 size += SIZEOF_UINT16;
179 size += SIZEOF_UINT16;
180 size += SIZEOF_UINT16;
181 size += SIZEOF_UINT16;
182 size += SIZEOF_UINT16;
183 size += SIZEOF_UINT16;
184 break;
185 case CSR_DEBUG_GENERIC_CONFIRM_ID:
186 size += SIZEOF_UINT16;
187 size += SIZEOF_UINT16;
188 size += SIZEOF_UINT16;
189 size += SIZEOF_UINT16;
190 size += SIZEOF_UINT16;
191 size += SIZEOF_UINT16;
192 size += SIZEOF_UINT16;
193 size += SIZEOF_UINT16;
194 size += SIZEOF_UINT16;
195 size += SIZEOF_UINT16;
196 size += SIZEOF_UINT16;
197 size += SIZEOF_UINT16;
198 break;
199 case CSR_MA_PACKET_INDICATION_ID:
200 size += SIZEOF_UINT16;
201 size += SIZEOF_UINT16;
202 size += SIZEOF_UINT16;
203 size += SIZEOF_UINT16;
204 size += SIZEOF_UINT16;
205 size += SIZEOF_UINT64;
206 size += SIZEOF_UINT16;
207 size += SIZEOF_UINT16;
208 size += SIZEOF_UINT16;
209 size += SIZEOF_UINT16;
210 size += SIZEOF_UINT16;
211 size += SIZEOF_UINT16;
212 break;
213 case CSR_MLME_SET_TIM_REQUEST_ID:
214 size += SIZEOF_UINT16;
215 size += SIZEOF_UINT16;
216 size += SIZEOF_UINT16;
217 size += SIZEOF_UINT16;
218 size += SIZEOF_UINT16;
219 size += SIZEOF_UINT16;
220 size += SIZEOF_UINT16;
221 break;
222#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
223 case CSR_MLME_CONNECTED_INDICATION_ID:
224 size += SIZEOF_UINT16;
225 size += SIZEOF_UINT16;
226 size += SIZEOF_UINT16;
227 size += SIZEOF_UINT16;
228 size += SIZEOF_UINT16;
229 size += SIZEOF_UINT16;
230 size += 48 / 8;
231 break;
232#endif
233#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
234 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
235 size += SIZEOF_UINT16;
236 size += SIZEOF_UINT16;
237 size += SIZEOF_UINT16;
238 size += SIZEOF_UINT16;
239 size += SIZEOF_UINT16;
240 size += SIZEOF_UINT16;
241 break;
242#endif
243#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
244 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
245 size += SIZEOF_UINT16;
246 size += SIZEOF_UINT16;
247 size += SIZEOF_UINT16;
248 size += SIZEOF_UINT16;
249 size += SIZEOF_UINT16;
250 size += SIZEOF_UINT16;
251 size += SIZEOF_UINT16;
252 size += SIZEOF_UINT16;
253 break;
254#endif
255#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
256 case CSR_MLME_SCAN_REQUEST_ID:
257 size += SIZEOF_UINT16;
258 size += SIZEOF_UINT16;
259 size += SIZEOF_UINT16;
260 size += SIZEOF_UINT16;
261 size += SIZEOF_UINT16;
262 size += SIZEOF_UINT16;
263 size += SIZEOF_UINT16;
264 size += SIZEOF_UINT32;
265 size += SIZEOF_UINT16;
266 size += SIZEOF_UINT16;
267 break;
268#endif
269#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
270 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
271 size += SIZEOF_UINT16;
272 size += SIZEOF_UINT16;
273 size += SIZEOF_UINT16;
274 size += SIZEOF_UINT16;
275 size += SIZEOF_UINT16;
276 size += SIZEOF_UINT16;
277 break;
278#endif
279#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
280 case CSR_MLME_GET_NEXT_REQUEST_ID:
281 size += SIZEOF_UINT16;
282 size += SIZEOF_UINT16;
283 size += SIZEOF_UINT16;
284 size += SIZEOF_UINT16;
285 break;
286#endif
287#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
288 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
289 size += SIZEOF_UINT16;
290 size += SIZEOF_UINT16;
291 size += SIZEOF_UINT16;
292 size += SIZEOF_UINT16;
293 size += SIZEOF_UINT16;
294 size += SIZEOF_UINT16;
295 break;
296#endif
297#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
298 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
299 size += SIZEOF_UINT16;
300 size += SIZEOF_UINT16;
301 size += SIZEOF_UINT16;
302 size += SIZEOF_UINT16;
303 size += SIZEOF_UINT16;
304 size += 48 / 8;
305 size += SIZEOF_UINT16;
306 size += SIZEOF_UINT16;
307 size += SIZEOF_UINT16;
308 size += SIZEOF_UINT16;
309 size += SIZEOF_UINT16;
310 break;
311#endif
312#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
313 case CSR_MLME_HL_SYNC_REQUEST_ID:
314 size += SIZEOF_UINT16;
315 size += SIZEOF_UINT16;
316 size += SIZEOF_UINT16;
317 size += SIZEOF_UINT16;
318 size += 48 / 8;
319 break;
320#endif
321 case CSR_DEBUG_GENERIC_REQUEST_ID:
322 size += SIZEOF_UINT16;
323 size += SIZEOF_UINT16;
324 size += SIZEOF_UINT16;
325 size += SIZEOF_UINT16;
326 size += SIZEOF_UINT16;
327 size += SIZEOF_UINT16;
328 size += SIZEOF_UINT16;
329 size += SIZEOF_UINT16;
330 size += SIZEOF_UINT16;
331 size += SIZEOF_UINT16;
332 size += SIZEOF_UINT16;
333 size += SIZEOF_UINT16;
334 break;
335#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
336 case CSR_MLME_LEAVE_CONFIRM_ID:
337 size += SIZEOF_UINT16;
338 size += SIZEOF_UINT16;
339 size += SIZEOF_UINT16;
340 size += SIZEOF_UINT16;
341 size += SIZEOF_UINT16;
342 size += SIZEOF_UINT16;
343 break;
344#endif
345#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
346 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
347 size += SIZEOF_UINT16;
348 size += SIZEOF_UINT16;
349 size += SIZEOF_UINT16;
350 size += SIZEOF_UINT16;
351 size += SIZEOF_UINT16;
352 size += SIZEOF_UINT16;
353 break;
354#endif
355#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
356 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
357 size += SIZEOF_UINT16;
358 size += SIZEOF_UINT16;
359 size += SIZEOF_UINT16;
360 size += SIZEOF_UINT16;
361 size += SIZEOF_UINT16;
362 size += SIZEOF_UINT16;
363 break;
364#endif
365#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
366 case CSR_MLME_RESET_REQUEST_ID:
367 size += SIZEOF_UINT16;
368 size += SIZEOF_UINT16;
369 size += SIZEOF_UINT16;
370 size += SIZEOF_UINT16;
371 size += 48 / 8;
372 size += SIZEOF_UINT16;
373 break;
374#endif
375#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
376 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
377 size += SIZEOF_UINT16;
378 size += SIZEOF_UINT16;
379 size += SIZEOF_UINT16;
380 size += SIZEOF_UINT16;
381 size += SIZEOF_UINT16;
382 break;
383#endif
384#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
385 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
386 size += SIZEOF_UINT16;
387 size += SIZEOF_UINT16;
388 size += SIZEOF_UINT16;
389 size += SIZEOF_UINT16;
390 size += SIZEOF_UINT16;
391 size += SIZEOF_UINT16;
392 size += SIZEOF_UINT16;
393 break;
394#endif
395#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
396 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
397 size += SIZEOF_UINT16;
398 size += SIZEOF_UINT16;
399 size += SIZEOF_UINT16;
400 size += SIZEOF_UINT16;
401 size += SIZEOF_UINT16;
402 size += SIZEOF_UINT16;
403 size += SIZEOF_UINT32;
404 break;
405#endif
406#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
407 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
408 size += SIZEOF_UINT16;
409 size += SIZEOF_UINT16;
410 size += SIZEOF_UINT16;
411 size += SIZEOF_UINT16;
412 size += SIZEOF_UINT16;
413 size += SIZEOF_UINT16;
414 size += SIZEOF_UINT16;
415 break;
416#endif
417#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
418 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
419 size += SIZEOF_UINT16;
420 size += SIZEOF_UINT16;
421 size += SIZEOF_UINT16;
422 size += SIZEOF_UINT16;
423 size += SIZEOF_UINT16;
424 size += SIZEOF_UINT16;
425 size += 48 / 8;
426 size += SIZEOF_UINT16;
427 size += SIZEOF_UINT16;
428 break;
429#endif
430#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
431 case CSR_MLME_LEAVE_REQUEST_ID:
432 size += SIZEOF_UINT16;
433 size += SIZEOF_UINT16;
434 size += SIZEOF_UINT16;
435 size += SIZEOF_UINT16;
436 size += SIZEOF_UINT16;
437 break;
438#endif
439#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
440 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
441 size += SIZEOF_UINT16;
442 size += SIZEOF_UINT16;
443 size += SIZEOF_UINT16;
444 size += SIZEOF_UINT16;
445 size += SIZEOF_UINT16;
446 size += SIZEOF_UINT16;
447 size += SIZEOF_UINT16;
448 size += SIZEOF_UINT16;
449 size += SIZEOF_UINT16;
450 break;
451#endif
452#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
453 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
454 size += SIZEOF_UINT16;
455 size += SIZEOF_UINT16;
456 size += SIZEOF_UINT16;
457 size += SIZEOF_UINT16;
458 size += SIZEOF_UINT16;
459 size += SIZEOF_UINT16;
460 size += SIZEOF_UINT16;
461 break;
462#endif
463 case CSR_MLME_SET_TIM_CONFIRM_ID:
464 size += SIZEOF_UINT16;
465 size += SIZEOF_UINT16;
466 size += SIZEOF_UINT16;
467 size += SIZEOF_UINT16;
468 size += SIZEOF_UINT16;
469 size += SIZEOF_UINT16;
470 break;
471#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
472 case CSR_MLME_MEASURE_INDICATION_ID:
473 size += SIZEOF_UINT16;
474 size += SIZEOF_UINT16;
475 size += SIZEOF_UINT16;
476 size += SIZEOF_UINT16;
477 size += SIZEOF_UINT16;
478 break;
479#endif
480#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
481 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
482 size += SIZEOF_UINT16;
483 size += SIZEOF_UINT16;
484 size += SIZEOF_UINT16;
485 size += SIZEOF_UINT16;
486 size += SIZEOF_UINT16;
487 size += SIZEOF_UINT16;
488 size += SIZEOF_UINT16;
489 break;
490#endif
491#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
492 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
493 size += SIZEOF_UINT16;
494 size += SIZEOF_UINT16;
495 size += SIZEOF_UINT16;
496 size += SIZEOF_UINT16;
497 size += SIZEOF_UINT16;
498 size += SIZEOF_UINT16;
499 size += SIZEOF_UINT16;
500 break;
501#endif
502 case CSR_DEBUG_GENERIC_INDICATION_ID:
503 size += SIZEOF_UINT16;
504 size += SIZEOF_UINT16;
505 size += SIZEOF_UINT16;
506 size += SIZEOF_UINT16;
507 size += SIZEOF_UINT16;
508 size += SIZEOF_UINT16;
509 size += SIZEOF_UINT16;
510 size += SIZEOF_UINT16;
511 size += SIZEOF_UINT16;
512 size += SIZEOF_UINT16;
513 size += SIZEOF_UINT16;
514 size += SIZEOF_UINT16;
515 break;
516 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
517 size += SIZEOF_UINT16;
518 size += SIZEOF_UINT16;
519 size += SIZEOF_UINT16;
520 size += SIZEOF_UINT16;
521 size += SIZEOF_UINT16;
522 size += SIZEOF_UINT32;
523 break;
524#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
525 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
526 size += SIZEOF_UINT16;
527 size += SIZEOF_UINT16;
528 size += SIZEOF_UINT16;
529 size += SIZEOF_UINT16;
530 size += SIZEOF_UINT16;
531 size += SIZEOF_UINT16;
532 break;
533#endif
534#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
535 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
536 size += SIZEOF_UINT16;
537 size += SIZEOF_UINT16;
538 size += SIZEOF_UINT16;
539 size += SIZEOF_UINT16;
540 size += SIZEOF_UINT16;
541 size += SIZEOF_UINT16;
542 size += SIZEOF_UINT16;
543 break;
544#endif
545 case CSR_MA_PACKET_REQUEST_ID:
546 size += SIZEOF_UINT16;
547 size += SIZEOF_UINT16;
548 size += SIZEOF_UINT16;
549 size += SIZEOF_UINT16;
550 size += SIZEOF_UINT16;
551 size += SIZEOF_UINT16;
552 size += SIZEOF_UINT32;
553 size += SIZEOF_UINT16;
554 size += 48 / 8;
555 size += SIZEOF_UINT16;
556 break;
557#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
558 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
559 size += SIZEOF_UINT16;
560 size += SIZEOF_UINT16;
561 size += SIZEOF_UINT16;
562 size += SIZEOF_UINT16;
563 size += SIZEOF_UINT16;
564 size += SIZEOF_UINT16;
565 size += SIZEOF_UINT16;
566 size += SIZEOF_UINT16;
567 size += 48 / 8;
568 size += SIZEOF_UINT16;
569 break;
570#endif
571#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
572 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
573 size += SIZEOF_UINT16;
574 size += SIZEOF_UINT16;
575 size += SIZEOF_UINT16;
576 size += SIZEOF_UINT16;
577 size += SIZEOF_UINT16;
578 size += SIZEOF_UINT16;
579 size += SIZEOF_UINT16;
580 break;
581#endif
582 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
583 size += SIZEOF_UINT16;
584 size += SIZEOF_UINT16;
585 size += SIZEOF_UINT16;
586 size += SIZEOF_UINT16;
587 size += SIZEOF_UINT16;
588 size += SIZEOF_UINT16;
589 break;
590#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
591 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
592 size += SIZEOF_UINT16;
593 size += SIZEOF_UINT16;
594 size += SIZEOF_UINT16;
595 size += SIZEOF_UINT16;
596 size += 48 / 8;
597 break;
598#endif
599#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
600 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
601 size += SIZEOF_UINT16;
602 size += SIZEOF_UINT16;
603 size += SIZEOF_UINT16;
604 size += SIZEOF_UINT16;
605 size += SIZEOF_UINT16;
606 size += SIZEOF_UINT16;
607 break;
608#endif
609#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
610 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
611 size += SIZEOF_UINT16;
612 size += SIZEOF_UINT16;
613 size += SIZEOF_UINT16;
614 size += SIZEOF_UINT16;
615 size += SIZEOF_UINT16;
616 size += SIZEOF_UINT16;
617 break;
618#endif
619#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
620 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
621 size += SIZEOF_UINT16;
622 size += SIZEOF_UINT16;
623 size += SIZEOF_UINT16;
624 size += SIZEOF_UINT16;
625 size += SIZEOF_UINT16;
626 size += SIZEOF_UINT16;
627 size += SIZEOF_UINT16;
628 break;
629#endif
630#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
631 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
632 size += SIZEOF_UINT16;
633 size += SIZEOF_UINT16;
634 size += SIZEOF_UINT16;
635 size += SIZEOF_UINT16;
636 size += SIZEOF_UINT16;
637 size += SIZEOF_UINT16;
638 size += SIZEOF_UINT16;
639 size += 48 / 8;
640 break;
641#endif
642#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
643 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
644 size += SIZEOF_UINT16;
645 size += SIZEOF_UINT16;
646 size += SIZEOF_UINT16;
647 size += SIZEOF_UINT16;
648 size += SIZEOF_UINT16;
649 size += SIZEOF_UINT16;
650 size += SIZEOF_UINT16;
651 size += 48 / 8;
652 size += SIZEOF_UINT16;
653 size += SIZEOF_UINT16;
654 break;
655#endif
656#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
657 case CSR_MLME_MEASURE_CONFIRM_ID:
658 size += SIZEOF_UINT16;
659 size += SIZEOF_UINT16;
660 size += SIZEOF_UINT16;
661 size += SIZEOF_UINT16;
662 size += SIZEOF_UINT16;
663 size += SIZEOF_UINT16;
664 break;
665#endif
666#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
667 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
668 size += SIZEOF_UINT16;
669 size += SIZEOF_UINT16;
670 size += SIZEOF_UINT16;
671 size += SIZEOF_UINT16;
672 size += SIZEOF_UINT16;
673 size += SIZEOF_UINT16;
674 break;
675#endif
676#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
677 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
678 size += SIZEOF_UINT16;
679 size += SIZEOF_UINT16;
680 size += SIZEOF_UINT16;
681 size += SIZEOF_UINT16;
682 size += SIZEOF_UINT16;
683 size += 48 / 8;
684 break;
685#endif
686 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
687 size += SIZEOF_UINT16;
688 size += SIZEOF_UINT16;
689 size += SIZEOF_UINT16;
690 size += SIZEOF_UINT16;
691 size += SIZEOF_UINT16;
692 size += SIZEOF_UINT16;
693 break;
694#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
695 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
696 size += SIZEOF_UINT16;
697 size += SIZEOF_UINT16;
698 size += SIZEOF_UINT16;
699 size += SIZEOF_UINT16;
700 size += SIZEOF_UINT16;
701 size += SIZEOF_UINT16;
702 size += SIZEOF_UINT16;
703 break;
704#endif
705#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
706 case CSR_MLME_POWERMGT_CONFIRM_ID:
707 size += SIZEOF_UINT16;
708 size += SIZEOF_UINT16;
709 size += SIZEOF_UINT16;
710 size += SIZEOF_UINT16;
711 size += SIZEOF_UINT16;
712 size += SIZEOF_UINT16;
713 break;
714#endif
715#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
716 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
717 size += SIZEOF_UINT16;
718 size += SIZEOF_UINT16;
719 size += SIZEOF_UINT16;
720 size += SIZEOF_UINT16;
721 size += SIZEOF_UINT16;
722 size += SIZEOF_UINT16;
723 size += SIZEOF_UINT16;
724 break;
725#endif
726#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
727 case CSR_MLME_GET_CONFIRM_ID:
728 size += SIZEOF_UINT16;
729 size += SIZEOF_UINT16;
730 size += SIZEOF_UINT16;
731 size += SIZEOF_UINT16;
732 size += SIZEOF_UINT16;
733 size += SIZEOF_UINT16;
734 break;
735#endif
736#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
737 case CSR_MLME_GET_NEXT_CONFIRM_ID:
738 size += SIZEOF_UINT16;
739 size += SIZEOF_UINT16;
740 size += SIZEOF_UINT16;
741 size += SIZEOF_UINT16;
742 size += SIZEOF_UINT16;
743 size += SIZEOF_UINT16;
744 break;
745#endif
746#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
747 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
748 size += SIZEOF_UINT16;
749 size += SIZEOF_UINT16;
750 size += SIZEOF_UINT16;
751 size += SIZEOF_UINT16;
752 size += SIZEOF_UINT16;
753 size += 48 / 8;
754 size += SIZEOF_UINT16;
755 size += SIZEOF_UINT16;
756 break;
757#endif
758#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
759 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
760 size += SIZEOF_UINT16;
761 size += SIZEOF_UINT16;
762 size += SIZEOF_UINT16;
763 size += SIZEOF_UINT16;
764 size += SIZEOF_UINT16;
765 size += SIZEOF_UINT16;
766 size += SIZEOF_UINT16;
767 break;
768#endif
769#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
770 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
771 size += SIZEOF_UINT16;
772 size += SIZEOF_UINT16;
773 size += SIZEOF_UINT16;
774 size += SIZEOF_UINT16;
775 size += SIZEOF_UINT16;
776 size += SIZEOF_UINT16;
777 size += SIZEOF_UINT16;
778 size += SIZEOF_UINT16;
779 size += SIZEOF_UINT32;
780 size += SIZEOF_UINT32;
781 size += SIZEOF_UINT32;
782 size += 48 / 8;
783 size += SIZEOF_UINT16;
784 break;
785#endif
786#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
787 case CSR_MLME_DELETEKEYS_REQUEST_ID:
788 size += SIZEOF_UINT16;
789 size += SIZEOF_UINT16;
790 size += SIZEOF_UINT16;
791 size += SIZEOF_UINT16;
792 size += SIZEOF_UINT16;
793 size += SIZEOF_UINT16;
794 size += SIZEOF_UINT16;
795 size += 48 / 8;
796 break;
797#endif
798#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
799 case CSR_MLME_RESET_CONFIRM_ID:
800 size += SIZEOF_UINT16;
801 size += SIZEOF_UINT16;
802 size += SIZEOF_UINT16;
803 size += SIZEOF_UINT16;
804 size += SIZEOF_UINT16;
805 break;
806#endif
807#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
808 case CSR_MLME_HL_SYNC_CONFIRM_ID:
809 size += SIZEOF_UINT16;
810 size += SIZEOF_UINT16;
811 size += SIZEOF_UINT16;
812 size += SIZEOF_UINT16;
813 size += 48 / 8;
814 size += SIZEOF_UINT16;
815 break;
816#endif
817#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
818 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
819 size += SIZEOF_UINT16;
820 size += SIZEOF_UINT16;
821 size += SIZEOF_UINT16;
822 size += SIZEOF_UINT16;
823 size += SIZEOF_UINT16;
824 size += SIZEOF_UINT16;
825 size += SIZEOF_UINT16;
826 size += SIZEOF_UINT16;
827 size += SIZEOF_UINT16;
828 size += SIZEOF_UINT32;
829 size += SIZEOF_UINT16;
830 size += SIZEOF_UINT16;
831 break;
832#endif
833#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
834 case CSR_MLME_SET_REQUEST_ID:
835 size += SIZEOF_UINT16;
836 size += SIZEOF_UINT16;
837 size += SIZEOF_UINT16;
838 size += SIZEOF_UINT16;
839 break;
840#endif
841#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
842 case CSR_MLME_SM_START_REQUEST_ID:
843 size += SIZEOF_UINT16;
844 size += SIZEOF_UINT16;
845 size += SIZEOF_UINT16;
846 size += SIZEOF_UINT16;
847 size += SIZEOF_UINT16;
848 size += SIZEOF_UINT16;
849 size += SIZEOF_UINT16;
850 size += 48 / 8;
851 size += 48 / 8;
852 size += SIZEOF_UINT16;
853 size += SIZEOF_UINT16;
854 size += SIZEOF_UINT16;
855 break;
856#endif
857#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
858 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
859 size += SIZEOF_UINT16;
860 size += SIZEOF_UINT16;
861 size += SIZEOF_UINT16;
862 size += SIZEOF_UINT16;
863 size += SIZEOF_UINT16;
864 size += SIZEOF_UINT16;
865 break;
866#endif
867#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
868 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
869 size += SIZEOF_UINT16;
870 size += SIZEOF_UINT16;
871 size += SIZEOF_UINT16;
872 size += SIZEOF_UINT16;
873 size += SIZEOF_UINT16;
874 size += SIZEOF_UINT16;
875 size += SIZEOF_UINT16;
876 break;
877#endif
878#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
879 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
880 size += SIZEOF_UINT16;
881 size += SIZEOF_UINT16;
882 size += SIZEOF_UINT16;
883 size += SIZEOF_UINT16;
884 size += SIZEOF_UINT16;
885 size += SIZEOF_UINT16;
886 break;
887#endif
888#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
889 case CSR_MLME_SETKEYS_REQUEST_ID:
890 size += SIZEOF_UINT16;
891 size += SIZEOF_UINT16;
892 size += SIZEOF_UINT16;
893 size += SIZEOF_UINT16;
894 size += SIZEOF_UINT16;
895 size += SIZEOF_UINT16;
896 size += SIZEOF_UINT16;
897 size += SIZEOF_UINT16;
898 size += 48 / 8;
899 size += SIZEOF_UINT16;
900 size += SIZEOF_UINT16;
901 size += SIZEOF_UINT16;
902 size += SIZEOF_UINT16;
903 size += SIZEOF_UINT16;
904 size += SIZEOF_UINT16;
905 size += SIZEOF_UINT16;
906 size += SIZEOF_UINT16;
907 size += 32 / 8;
908 break;
909#endif
910#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
911 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
912 size += SIZEOF_UINT16;
913 size += SIZEOF_UINT16;
914 size += SIZEOF_UINT16;
915 size += SIZEOF_UINT16;
916 size += SIZEOF_UINT16;
917 size += SIZEOF_UINT16;
918 size += SIZEOF_UINT16;
919 break;
920#endif
921#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
922 case CSR_MLME_GET_REQUEST_ID:
923 size += SIZEOF_UINT16;
924 size += SIZEOF_UINT16;
925 size += SIZEOF_UINT16;
926 size += SIZEOF_UINT16;
927 break;
928#endif
929#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
930 case CSR_MLME_POWERMGT_REQUEST_ID:
931 size += SIZEOF_UINT16;
932 size += SIZEOF_UINT16;
933 size += SIZEOF_UINT16;
934 size += SIZEOF_UINT16;
935 size += SIZEOF_UINT16;
936 size += SIZEOF_UINT16;
937 size += SIZEOF_UINT16;
938 size += SIZEOF_UINT16;
939 size += SIZEOF_UINT16;
940 break;
941#endif
942 case CSR_MA_PACKET_ERROR_INDICATION_ID:
943 size += SIZEOF_UINT16;
944 size += SIZEOF_UINT16;
945 size += SIZEOF_UINT16;
946 size += SIZEOF_UINT16;
947 size += SIZEOF_UINT16;
948 size += 48 / 8;
949 size += SIZEOF_UINT16;
950 size += SIZEOF_UINT16;
951 break;
952#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
953 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
954 size += SIZEOF_UINT16;
955 size += SIZEOF_UINT16;
956 size += SIZEOF_UINT16;
957 size += SIZEOF_UINT16;
958 size += SIZEOF_UINT16;
959 size += SIZEOF_UINT16;
960 size += SIZEOF_UINT32;
961 size += SIZEOF_UINT16;
962 size += SIZEOF_UINT16;
963 size += SIZEOF_UINT16;
964 break;
965#endif
966#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
967 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
968 size += SIZEOF_UINT16;
969 size += SIZEOF_UINT16;
970 size += SIZEOF_UINT16;
971 size += SIZEOF_UINT16;
972 size += SIZEOF_UINT16;
973 size += SIZEOF_UINT16;
974 size += SIZEOF_UINT16;
975 size += SIZEOF_UINT16;
976 size += SIZEOF_UINT16;
977 size += SIZEOF_UINT32;
978 size += SIZEOF_UINT32;
979 size += SIZEOF_UINT16;
980 break;
981#endif
982#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
983 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
984 size += SIZEOF_UINT16;
985 size += SIZEOF_UINT16;
986 size += SIZEOF_UINT16;
987 size += SIZEOF_UINT16;
988 size += SIZEOF_UINT16;
989 size += SIZEOF_UINT16;
990 break;
991#endif
992#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
993 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
994 size += SIZEOF_UINT16;
995 size += SIZEOF_UINT16;
996 size += SIZEOF_UINT16;
997 size += SIZEOF_UINT16;
998 size += SIZEOF_UINT16;
999 size += SIZEOF_UINT16;
1000 size += SIZEOF_UINT16;
1001 break;
1002#endif
1003#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1004 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
1005 size += SIZEOF_UINT16;
1006 size += SIZEOF_UINT16;
1007 size += SIZEOF_UINT16;
1008 size += SIZEOF_UINT16;
1009 size += SIZEOF_UINT16;
1010 break;
1011#endif
1012#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1013 case CSR_MLME_SCAN_CONFIRM_ID:
1014 size += SIZEOF_UINT16;
1015 size += SIZEOF_UINT16;
1016 size += SIZEOF_UINT16;
1017 size += SIZEOF_UINT16;
1018 size += SIZEOF_UINT16;
1019 size += SIZEOF_UINT16;
1020 break;
1021#endif
1022 case CSR_DEBUG_STRING_INDICATION_ID:
1023 size += SIZEOF_UINT16;
1024 size += SIZEOF_UINT16;
1025 size += SIZEOF_UINT16;
1026 size += SIZEOF_UINT16;
1027 break;
1028#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1029 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
1030 size += SIZEOF_UINT16;
1031 size += SIZEOF_UINT16;
1032 size += SIZEOF_UINT16;
1033 size += SIZEOF_UINT16;
1034 size += SIZEOF_UINT16;
1035 size += SIZEOF_UINT16;
1036 size += SIZEOF_UINT16;
1037 break;
1038#endif
1039#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1040 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
1041 size += SIZEOF_UINT16;
1042 size += SIZEOF_UINT16;
1043 size += SIZEOF_UINT16;
1044 size += SIZEOF_UINT16;
1045 size += SIZEOF_UINT16;
1046 size += SIZEOF_UINT16;
1047 size += 48 / 8;
1048 break;
1049#endif
1050#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1051 case CSR_MLME_SET_CONFIRM_ID:
1052 size += SIZEOF_UINT16;
1053 size += SIZEOF_UINT16;
1054 size += SIZEOF_UINT16;
1055 size += SIZEOF_UINT16;
1056 size += SIZEOF_UINT16;
1057 size += SIZEOF_UINT16;
1058 break;
1059#endif
1060#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1061 case CSR_MLME_MEASURE_REQUEST_ID:
1062 size += SIZEOF_UINT16;
1063 size += SIZEOF_UINT16;
1064 size += SIZEOF_UINT16;
1065 size += SIZEOF_UINT16;
1066 size += SIZEOF_UINT16;
1067 break;
1068#endif
1069#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1070 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
1071 size += SIZEOF_UINT16;
1072 size += SIZEOF_UINT16;
1073 size += SIZEOF_UINT16;
1074 size += SIZEOF_UINT16;
1075 size += SIZEOF_UINT16;
1076 size += 48 / 8;
1077 size += SIZEOF_UINT16;
1078 size += SIZEOF_UINT16;
1079 size += SIZEOF_UINT16;
1080 size += SIZEOF_UINT16;
1081 break;
1082#endif
1083#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1084 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
1085 size += SIZEOF_UINT16;
1086 size += SIZEOF_UINT16;
1087 size += SIZEOF_UINT16;
1088 size += SIZEOF_UINT16;
1089 size += SIZEOF_UINT16;
1090 size += SIZEOF_UINT16;
1091 break;
1092#endif
1093 case CSR_MA_PACKET_CONFIRM_ID:
1094 size += SIZEOF_UINT16;
1095 size += SIZEOF_UINT16;
1096 size += SIZEOF_UINT16;
1097 size += SIZEOF_UINT16;
1098 size += SIZEOF_UINT16;
1099 size += SIZEOF_UINT16;
1100 size += SIZEOF_UINT16;
1101 size += SIZEOF_UINT16;
1102 size += SIZEOF_UINT32;
1103 break;
1104#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1105 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
1106 size += SIZEOF_UINT16;
1107 size += SIZEOF_UINT16;
1108 size += SIZEOF_UINT16;
1109 size += SIZEOF_UINT16;
1110 size += SIZEOF_UINT16;
1111 size += SIZEOF_UINT16;
1112 size += SIZEOF_UINT16;
1113 break;
1114#endif
1115#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1116 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
1117 size += SIZEOF_UINT16;
1118 size += SIZEOF_UINT16;
1119 size += SIZEOF_UINT16;
1120 size += SIZEOF_UINT16;
1121 size += SIZEOF_UINT16;
1122 break;
1123#endif
1124 default:
1125 size = 0;
1126 }
1127 return size;
1128} /* get_packed_struct_size() */
1129
1130
1131/*
1132 * ---------------------------------------------------------------------------
1133 * read_unpack_signal
1134 *
1135 * Unpack a wire-format signal into a host-native structure.
1136 * This function handles any necessary conversions for endianness and
1137 * places no restrictions on packing or alignment for the structure
1138 * definition.
1139 *
1140 * WARNING: This function is auto-generated, DO NOT EDIT!
1141 *
1142 * Arguments:
1143 * ptr Signal buffer to unpack.
1144 * sig Pointer to destination structure to populate.
1145 *
1146 * Returns:
1147 * CSR_RESULT_SUCCESS on success,
1148 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
1149 * ---------------------------------------------------------------------------
1150 */
1151CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig)
1152{
1153 s32 index = 0;
1154
1155 sig->SignalPrimitiveHeader.SignalId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1156 index += SIZEOF_UINT16;
1157
1158 sig->SignalPrimitiveHeader.ReceiverProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1159 index += SIZEOF_UINT16;
1160
1161 sig->SignalPrimitiveHeader.SenderProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1162 index += SIZEOF_UINT16;
1163
1164 switch (sig->SignalPrimitiveHeader.SignalId)
1165 {
1166#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1167 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
1168 sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1169 index += SIZEOF_UINT16;
1170 sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1171 index += SIZEOF_UINT16;
1172 sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1173 index += SIZEOF_UINT16;
1174 sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1175 index += SIZEOF_UINT16;
1176 sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1177 index += SIZEOF_UINT16;
1178 sig->u.MlmeSetPacketFilterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1179 index += SIZEOF_UINT16;
1180 break;
1181#endif
1182#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1183 case CSR_MLME_SETKEYS_CONFIRM_ID:
1184 sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1185 index += SIZEOF_UINT16;
1186 sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1187 index += SIZEOF_UINT16;
1188 sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1189 index += SIZEOF_UINT16;
1190 sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1191 index += SIZEOF_UINT16;
1192 sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1193 index += SIZEOF_UINT16;
1194 sig->u.MlmeSetkeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1195 index += SIZEOF_UINT16;
1196 break;
1197#endif
1198#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1199 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
1200 sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1201 index += SIZEOF_UINT16;
1202 sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1203 index += SIZEOF_UINT16;
1204 sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1205 index += SIZEOF_UINT16;
1206 sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1207 index += SIZEOF_UINT16;
1208 sig->u.MlmeConfigQueueConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1209 index += SIZEOF_UINT16;
1210 break;
1211#endif
1212#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1213 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
1214 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1215 index += SIZEOF_UINT16;
1216 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1217 index += SIZEOF_UINT16;
1218 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1219 index += SIZEOF_UINT16;
1220 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1221 index += SIZEOF_UINT16;
1222 sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1223 index += SIZEOF_UINT16;
1224 sig->u.MlmeAddAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1225 index += SIZEOF_UINT16;
1226 sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1227 index += SIZEOF_UINT16;
1228 break;
1229#endif
1230#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1231 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
1232 sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1233 index += SIZEOF_UINT16;
1234 sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1235 index += SIZEOF_UINT16;
1236 sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1237 index += SIZEOF_UINT16;
1238 sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1239 index += SIZEOF_UINT16;
1240 sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1241 index += SIZEOF_UINT16;
1242 sig->u.MlmeAddBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1243 index += SIZEOF_UINT16;
1244 sig->u.MlmeAddBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1245 index += SIZEOF_UINT16;
1246 break;
1247#endif
1248#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1249 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
1250 sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1251 index += SIZEOF_UINT16;
1252 sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1253 index += SIZEOF_UINT16;
1254 sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1255 index += SIZEOF_UINT16;
1256 sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1257 index += SIZEOF_UINT16;
1258 sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1259 index += SIZEOF_UINT16;
1260 sig->u.MlmeDelBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1261 index += SIZEOF_UINT16;
1262 break;
1263#endif
1264#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1265 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
1266 sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1267 index += SIZEOF_UINT16;
1268 sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1269 index += SIZEOF_UINT16;
1270 sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1271 index += SIZEOF_UINT16;
1272 sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1273 index += SIZEOF_UINT16;
1274 sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1275 index += SIZEOF_UINT16;
1276 sig->u.MlmeGetKeySequenceConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1277 index += SIZEOF_UINT16;
1278 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1279 index += SIZEOF_UINT16;
1280 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1281 index += SIZEOF_UINT16;
1282 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1283 index += SIZEOF_UINT16;
1284 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1285 index += SIZEOF_UINT16;
1286 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1287 index += SIZEOF_UINT16;
1288 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1289 index += SIZEOF_UINT16;
1290 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1291 index += SIZEOF_UINT16;
1292 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1293 index += SIZEOF_UINT16;
1294 break;
1295#endif
1296#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1297 case CSR_MLME_SM_START_CONFIRM_ID:
1298 sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1299 index += SIZEOF_UINT16;
1300 sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1301 index += SIZEOF_UINT16;
1302 sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1303 index += SIZEOF_UINT16;
1304 sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1305 index += SIZEOF_UINT16;
1306 sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1307 index += SIZEOF_UINT16;
1308 sig->u.MlmeSmStartConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1309 index += SIZEOF_UINT16;
1310 break;
1311#endif
1312#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1313 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
1314 sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1315 index += SIZEOF_UINT16;
1316 sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1317 index += SIZEOF_UINT16;
1318 sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1319 index += SIZEOF_UINT16;
1320 sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1321 index += SIZEOF_UINT16;
1322 sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1323 index += SIZEOF_UINT16;
1324 memcpy(sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
1325 index += 48 / 8;
1326 sig->u.MlmeStopAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1327 index += SIZEOF_UINT16;
1328 sig->u.MlmeStopAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1329 index += SIZEOF_UINT16;
1330 sig->u.MlmeStopAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1331 index += SIZEOF_UINT16;
1332 break;
1333#endif
1334#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1335 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
1336 sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1337 index += SIZEOF_UINT16;
1338 sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1339 index += SIZEOF_UINT16;
1340 sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1341 index += SIZEOF_UINT16;
1342 sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1343 index += SIZEOF_UINT16;
1344 sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1345 index += SIZEOF_UINT16;
1346 sig->u.MlmeDelTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1347 index += SIZEOF_UINT16;
1348 sig->u.MlmeDelTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1349 index += SIZEOF_UINT16;
1350 break;
1351#endif
1352 case CSR_DEBUG_WORD16_INDICATION_ID:
1353 sig->u.DebugWord16Indication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1354 index += SIZEOF_UINT16;
1355 sig->u.DebugWord16Indication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1356 index += SIZEOF_UINT16;
1357 sig->u.DebugWord16Indication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1358 index += SIZEOF_UINT16;
1359 sig->u.DebugWord16Indication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1360 index += SIZEOF_UINT16;
1361 sig->u.DebugWord16Indication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1362 index += SIZEOF_UINT16;
1363 sig->u.DebugWord16Indication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1364 index += SIZEOF_UINT16;
1365 sig->u.DebugWord16Indication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1366 index += SIZEOF_UINT16;
1367 sig->u.DebugWord16Indication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1368 index += SIZEOF_UINT16;
1369 sig->u.DebugWord16Indication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1370 index += SIZEOF_UINT16;
1371 sig->u.DebugWord16Indication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1372 index += SIZEOF_UINT16;
1373 sig->u.DebugWord16Indication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1374 index += SIZEOF_UINT16;
1375 sig->u.DebugWord16Indication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1376 index += SIZEOF_UINT16;
1377 sig->u.DebugWord16Indication.DebugWords[8] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1378 index += SIZEOF_UINT16;
1379 sig->u.DebugWord16Indication.DebugWords[9] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1380 index += SIZEOF_UINT16;
1381 sig->u.DebugWord16Indication.DebugWords[10] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1382 index += SIZEOF_UINT16;
1383 sig->u.DebugWord16Indication.DebugWords[11] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1384 index += SIZEOF_UINT16;
1385 sig->u.DebugWord16Indication.DebugWords[12] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1386 index += SIZEOF_UINT16;
1387 sig->u.DebugWord16Indication.DebugWords[13] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1388 index += SIZEOF_UINT16;
1389 sig->u.DebugWord16Indication.DebugWords[14] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1390 index += SIZEOF_UINT16;
1391 sig->u.DebugWord16Indication.DebugWords[15] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1392 index += SIZEOF_UINT16;
1393 break;
1394 case CSR_DEBUG_GENERIC_CONFIRM_ID:
1395 sig->u.DebugGenericConfirm.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1396 index += SIZEOF_UINT16;
1397 sig->u.DebugGenericConfirm.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1398 index += SIZEOF_UINT16;
1399 sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1400 index += SIZEOF_UINT16;
1401 sig->u.DebugGenericConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1402 index += SIZEOF_UINT16;
1403 sig->u.DebugGenericConfirm.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1404 index += SIZEOF_UINT16;
1405 sig->u.DebugGenericConfirm.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1406 index += SIZEOF_UINT16;
1407 sig->u.DebugGenericConfirm.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1408 index += SIZEOF_UINT16;
1409 sig->u.DebugGenericConfirm.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1410 index += SIZEOF_UINT16;
1411 sig->u.DebugGenericConfirm.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1412 index += SIZEOF_UINT16;
1413 sig->u.DebugGenericConfirm.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1414 index += SIZEOF_UINT16;
1415 sig->u.DebugGenericConfirm.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1416 index += SIZEOF_UINT16;
1417 sig->u.DebugGenericConfirm.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1418 index += SIZEOF_UINT16;
1419 break;
1420 case CSR_MA_PACKET_INDICATION_ID:
1421 sig->u.MaPacketIndication.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1422 index += SIZEOF_UINT16;
1423 sig->u.MaPacketIndication.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1424 index += SIZEOF_UINT16;
1425 sig->u.MaPacketIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1426 index += SIZEOF_UINT16;
1427 sig->u.MaPacketIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1428 index += SIZEOF_UINT16;
1429 sig->u.MaPacketIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1430 index += SIZEOF_UINT16;
1431 memcpy(sig->u.MaPacketIndication.LocalTime.x, &ptr[index], 64 / 8);
1432 index += 64 / 8;
1433 sig->u.MaPacketIndication.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1434 index += SIZEOF_UINT16;
1435 sig->u.MaPacketIndication.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1436 index += SIZEOF_UINT16;
1437 sig->u.MaPacketIndication.ReceptionStatus = (CSR_RECEPTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1438 index += SIZEOF_UINT16;
1439 sig->u.MaPacketIndication.Rssi = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1440 index += SIZEOF_UINT16;
1441 sig->u.MaPacketIndication.Snr = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1442 index += SIZEOF_UINT16;
1443 sig->u.MaPacketIndication.ReceivedRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1444 index += SIZEOF_UINT16;
1445 break;
1446 case CSR_MLME_SET_TIM_REQUEST_ID:
1447 sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1448 index += SIZEOF_UINT16;
1449 sig->u.MlmeSetTimRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1450 index += SIZEOF_UINT16;
1451 sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1452 index += SIZEOF_UINT16;
1453 sig->u.MlmeSetTimRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1454 index += SIZEOF_UINT16;
1455 sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1456 index += SIZEOF_UINT16;
1457 sig->u.MlmeSetTimRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1458 index += SIZEOF_UINT16;
1459 sig->u.MlmeSetTimRequest.TimValue = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1460 index += SIZEOF_UINT16;
1461 break;
1462#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1463 case CSR_MLME_CONNECTED_INDICATION_ID:
1464 sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1465 index += SIZEOF_UINT16;
1466 sig->u.MlmeConnectedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1467 index += SIZEOF_UINT16;
1468 sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1469 index += SIZEOF_UINT16;
1470 sig->u.MlmeConnectedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1471 index += SIZEOF_UINT16;
1472 sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1473 index += SIZEOF_UINT16;
1474 sig->u.MlmeConnectedIndication.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1475 index += SIZEOF_UINT16;
1476 memcpy(sig->u.MlmeConnectedIndication.PeerMacAddress.x, &ptr[index], 48 / 8);
1477 index += 48 / 8;
1478 break;
1479#endif
1480#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1481 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
1482 sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1483 index += SIZEOF_UINT16;
1484 sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1485 index += SIZEOF_UINT16;
1486 sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1487 index += SIZEOF_UINT16;
1488 sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1489 index += SIZEOF_UINT16;
1490 sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1491 index += SIZEOF_UINT16;
1492 sig->u.MlmeDelRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1493 index += SIZEOF_UINT16;
1494 break;
1495#endif
1496#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1497 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
1498 sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1499 index += SIZEOF_UINT16;
1500 sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1501 index += SIZEOF_UINT16;
1502 sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1503 index += SIZEOF_UINT16;
1504 sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1505 index += SIZEOF_UINT16;
1506 sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1507 index += SIZEOF_UINT16;
1508 sig->u.MlmeTriggeredGetIndication.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1509 index += SIZEOF_UINT16;
1510 sig->u.MlmeTriggeredGetIndication.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1511 index += SIZEOF_UINT16;
1512 sig->u.MlmeTriggeredGetIndication.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1513 index += SIZEOF_UINT16;
1514 break;
1515#endif
1516#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1517 case CSR_MLME_SCAN_REQUEST_ID:
1518 sig->u.MlmeScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1519 index += SIZEOF_UINT16;
1520 sig->u.MlmeScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1521 index += SIZEOF_UINT16;
1522 sig->u.MlmeScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1523 index += SIZEOF_UINT16;
1524 sig->u.MlmeScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1525 index += SIZEOF_UINT16;
1526 sig->u.MlmeScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1527 index += SIZEOF_UINT16;
1528 sig->u.MlmeScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1529 index += SIZEOF_UINT16;
1530 sig->u.MlmeScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1531 index += SIZEOF_UINT16;
1532 sig->u.MlmeScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
1533 index += SIZEOF_UINT32;
1534 sig->u.MlmeScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1535 index += SIZEOF_UINT16;
1536 sig->u.MlmeScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1537 index += SIZEOF_UINT16;
1538 break;
1539#endif
1540#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1541 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
1542 sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1543 index += SIZEOF_UINT16;
1544 sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1545 index += SIZEOF_UINT16;
1546 sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1547 index += SIZEOF_UINT16;
1548 sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1549 index += SIZEOF_UINT16;
1550 sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1551 index += SIZEOF_UINT16;
1552 sig->u.MlmeDeletekeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1553 index += SIZEOF_UINT16;
1554 break;
1555#endif
1556#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1557 case CSR_MLME_GET_NEXT_REQUEST_ID:
1558 sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1559 index += SIZEOF_UINT16;
1560 sig->u.MlmeGetNextRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1561 index += SIZEOF_UINT16;
1562 sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1563 index += SIZEOF_UINT16;
1564 sig->u.MlmeGetNextRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1565 index += SIZEOF_UINT16;
1566 break;
1567#endif
1568#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1569 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
1570 sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1571 index += SIZEOF_UINT16;
1572 sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1573 index += SIZEOF_UINT16;
1574 sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1575 index += SIZEOF_UINT16;
1576 sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1577 index += SIZEOF_UINT16;
1578 sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1579 index += SIZEOF_UINT16;
1580 sig->u.MlmeSetChannelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1581 index += SIZEOF_UINT16;
1582 break;
1583#endif
1584#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1585 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
1586 sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1587 index += SIZEOF_UINT16;
1588 sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1589 index += SIZEOF_UINT16;
1590 sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1591 index += SIZEOF_UINT16;
1592 sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1593 index += SIZEOF_UINT16;
1594 sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1595 index += SIZEOF_UINT16;
1596 memcpy(sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
1597 index += 48 / 8;
1598 sig->u.MlmeStartAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1599 index += SIZEOF_UINT16;
1600 sig->u.MlmeStartAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1601 index += SIZEOF_UINT16;
1602 sig->u.MlmeStartAggregationRequest.StartingSequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1603 index += SIZEOF_UINT16;
1604 sig->u.MlmeStartAggregationRequest.BufferSize = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1605 index += SIZEOF_UINT16;
1606 sig->u.MlmeStartAggregationRequest.BlockAckTimeout = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1607 index += SIZEOF_UINT16;
1608 break;
1609#endif
1610#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1611 case CSR_MLME_HL_SYNC_REQUEST_ID:
1612 sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1613 index += SIZEOF_UINT16;
1614 sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1615 index += SIZEOF_UINT16;
1616 sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1617 index += SIZEOF_UINT16;
1618 sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1619 index += SIZEOF_UINT16;
1620 memcpy(sig->u.MlmeHlSyncRequest.GroupAddress.x, &ptr[index], 48 / 8);
1621 index += 48 / 8;
1622 break;
1623#endif
1624 case CSR_DEBUG_GENERIC_REQUEST_ID:
1625 sig->u.DebugGenericRequest.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1626 index += SIZEOF_UINT16;
1627 sig->u.DebugGenericRequest.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1628 index += SIZEOF_UINT16;
1629 sig->u.DebugGenericRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1630 index += SIZEOF_UINT16;
1631 sig->u.DebugGenericRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1632 index += SIZEOF_UINT16;
1633 sig->u.DebugGenericRequest.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1634 index += SIZEOF_UINT16;
1635 sig->u.DebugGenericRequest.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1636 index += SIZEOF_UINT16;
1637 sig->u.DebugGenericRequest.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1638 index += SIZEOF_UINT16;
1639 sig->u.DebugGenericRequest.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1640 index += SIZEOF_UINT16;
1641 sig->u.DebugGenericRequest.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1642 index += SIZEOF_UINT16;
1643 sig->u.DebugGenericRequest.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1644 index += SIZEOF_UINT16;
1645 sig->u.DebugGenericRequest.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1646 index += SIZEOF_UINT16;
1647 sig->u.DebugGenericRequest.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1648 index += SIZEOF_UINT16;
1649 break;
1650#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1651 case CSR_MLME_LEAVE_CONFIRM_ID:
1652 sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1653 index += SIZEOF_UINT16;
1654 sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1655 index += SIZEOF_UINT16;
1656 sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1657 index += SIZEOF_UINT16;
1658 sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1659 index += SIZEOF_UINT16;
1660 sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1661 index += SIZEOF_UINT16;
1662 sig->u.MlmeLeaveConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1663 index += SIZEOF_UINT16;
1664 break;
1665#endif
1666#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1667 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
1668 sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1669 index += SIZEOF_UINT16;
1670 sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1671 index += SIZEOF_UINT16;
1672 sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1673 index += SIZEOF_UINT16;
1674 sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1675 index += SIZEOF_UINT16;
1676 sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1677 index += SIZEOF_UINT16;
1678 sig->u.MlmeDelTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1679 index += SIZEOF_UINT16;
1680 break;
1681#endif
1682#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1683 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
1684 sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1685 index += SIZEOF_UINT16;
1686 sig->u.MlmeAddMulticastAddressRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1687 index += SIZEOF_UINT16;
1688 sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1689 index += SIZEOF_UINT16;
1690 sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1691 index += SIZEOF_UINT16;
1692 sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1693 index += SIZEOF_UINT16;
1694 sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1695 index += SIZEOF_UINT16;
1696 break;
1697#endif
1698#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1699 case CSR_MLME_RESET_REQUEST_ID:
1700 sig->u.MlmeResetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1701 index += SIZEOF_UINT16;
1702 sig->u.MlmeResetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1703 index += SIZEOF_UINT16;
1704 sig->u.MlmeResetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1705 index += SIZEOF_UINT16;
1706 sig->u.MlmeResetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1707 index += SIZEOF_UINT16;
1708 memcpy(sig->u.MlmeResetRequest.StaAddress.x, &ptr[index], 48 / 8);
1709 index += 48 / 8;
1710 sig->u.MlmeResetRequest.SetDefaultMib = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1711 index += SIZEOF_UINT16;
1712 break;
1713#endif
1714#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1715 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
1716 sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1717 index += SIZEOF_UINT16;
1718 sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1719 index += SIZEOF_UINT16;
1720 sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1721 index += SIZEOF_UINT16;
1722 sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1723 index += SIZEOF_UINT16;
1724 sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1725 index += SIZEOF_UINT16;
1726 break;
1727#endif
1728#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1729 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
1730 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1731 index += SIZEOF_UINT16;
1732 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1733 index += SIZEOF_UINT16;
1734 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1735 index += SIZEOF_UINT16;
1736 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1737 index += SIZEOF_UINT16;
1738 sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1739 index += SIZEOF_UINT16;
1740 sig->u.MlmeAddTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1741 index += SIZEOF_UINT16;
1742 sig->u.MlmeAddTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1743 index += SIZEOF_UINT16;
1744 break;
1745#endif
1746#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1747 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
1748 sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1749 index += SIZEOF_UINT16;
1750 sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1751 index += SIZEOF_UINT16;
1752 sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1753 index += SIZEOF_UINT16;
1754 sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1755 index += SIZEOF_UINT16;
1756 sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1757 index += SIZEOF_UINT16;
1758 sig->u.MlmeSetPacketFilterRequest.PacketFilterMode = (CSR_PACKET_FILTER_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1759 index += SIZEOF_UINT16;
1760 sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
1761 index += SIZEOF_UINT32;
1762 break;
1763#endif
1764#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1765 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
1766 sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1767 index += SIZEOF_UINT16;
1768 sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1769 index += SIZEOF_UINT16;
1770 sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1771 index += SIZEOF_UINT16;
1772 sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1773 index += SIZEOF_UINT16;
1774 sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1775 index += SIZEOF_UINT16;
1776 sig->u.MlmeDelRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1777 index += SIZEOF_UINT16;
1778 sig->u.MlmeDelRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1779 index += SIZEOF_UINT16;
1780 break;
1781#endif
1782#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1783 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
1784 sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1785 index += SIZEOF_UINT16;
1786 sig->u.MlmeConnectStatusRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1787 index += SIZEOF_UINT16;
1788 sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1789 index += SIZEOF_UINT16;
1790 sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1791 index += SIZEOF_UINT16;
1792 sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1793 index += SIZEOF_UINT16;
1794 sig->u.MlmeConnectStatusRequest.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1795 index += SIZEOF_UINT16;
1796 memcpy(sig->u.MlmeConnectStatusRequest.StaAddress.x, &ptr[index], 48 / 8);
1797 index += 48 / 8;
1798 sig->u.MlmeConnectStatusRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1799 index += SIZEOF_UINT16;
1800 sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1801 index += SIZEOF_UINT16;
1802 break;
1803#endif
1804#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1805 case CSR_MLME_LEAVE_REQUEST_ID:
1806 sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1807 index += SIZEOF_UINT16;
1808 sig->u.MlmeLeaveRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1809 index += SIZEOF_UINT16;
1810 sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1811 index += SIZEOF_UINT16;
1812 sig->u.MlmeLeaveRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1813 index += SIZEOF_UINT16;
1814 sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1815 index += SIZEOF_UINT16;
1816 break;
1817#endif
1818#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1819 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
1820 sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1821 index += SIZEOF_UINT16;
1822 sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1823 index += SIZEOF_UINT16;
1824 sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1825 index += SIZEOF_UINT16;
1826 sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1827 index += SIZEOF_UINT16;
1828 sig->u.MlmeConfigQueueRequest.QueueIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1829 index += SIZEOF_UINT16;
1830 sig->u.MlmeConfigQueueRequest.Aifs = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1831 index += SIZEOF_UINT16;
1832 sig->u.MlmeConfigQueueRequest.Cwmin = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1833 index += SIZEOF_UINT16;
1834 sig->u.MlmeConfigQueueRequest.Cwmax = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1835 index += SIZEOF_UINT16;
1836 sig->u.MlmeConfigQueueRequest.TxopLimit = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1837 index += SIZEOF_UINT16;
1838 break;
1839#endif
1840#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1841 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
1842 sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1843 index += SIZEOF_UINT16;
1844 sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1845 index += SIZEOF_UINT16;
1846 sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1847 index += SIZEOF_UINT16;
1848 sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1849 index += SIZEOF_UINT16;
1850 sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1851 index += SIZEOF_UINT16;
1852 sig->u.MlmeDelTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1853 index += SIZEOF_UINT16;
1854 sig->u.MlmeDelTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1855 index += SIZEOF_UINT16;
1856 break;
1857#endif
1858 case CSR_MLME_SET_TIM_CONFIRM_ID:
1859 sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1860 index += SIZEOF_UINT16;
1861 sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1862 index += SIZEOF_UINT16;
1863 sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1864 index += SIZEOF_UINT16;
1865 sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1866 index += SIZEOF_UINT16;
1867 sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1868 index += SIZEOF_UINT16;
1869 sig->u.MlmeSetTimConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1870 index += SIZEOF_UINT16;
1871 break;
1872#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1873 case CSR_MLME_MEASURE_INDICATION_ID:
1874 sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1875 index += SIZEOF_UINT16;
1876 sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1877 index += SIZEOF_UINT16;
1878 sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1879 index += SIZEOF_UINT16;
1880 sig->u.MlmeMeasureIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1881 index += SIZEOF_UINT16;
1882 sig->u.MlmeMeasureIndication.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1883 index += SIZEOF_UINT16;
1884 break;
1885#endif
1886#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1887 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
1888 sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1889 index += SIZEOF_UINT16;
1890 sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1891 index += SIZEOF_UINT16;
1892 sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1893 index += SIZEOF_UINT16;
1894 sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1895 index += SIZEOF_UINT16;
1896 sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1897 index += SIZEOF_UINT16;
1898 sig->u.MlmeDelBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1899 index += SIZEOF_UINT16;
1900 sig->u.MlmeDelBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1901 index += SIZEOF_UINT16;
1902 break;
1903#endif
1904#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1905 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
1906 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1907 index += SIZEOF_UINT16;
1908 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1909 index += SIZEOF_UINT16;
1910 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1911 index += SIZEOF_UINT16;
1912 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1913 index += SIZEOF_UINT16;
1914 sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1915 index += SIZEOF_UINT16;
1916 sig->u.MlmeDelTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1917 index += SIZEOF_UINT16;
1918 sig->u.MlmeDelTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1919 index += SIZEOF_UINT16;
1920 break;
1921#endif
1922 case CSR_DEBUG_GENERIC_INDICATION_ID:
1923 sig->u.DebugGenericIndication.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1924 index += SIZEOF_UINT16;
1925 sig->u.DebugGenericIndication.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1926 index += SIZEOF_UINT16;
1927 sig->u.DebugGenericIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1928 index += SIZEOF_UINT16;
1929 sig->u.DebugGenericIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1930 index += SIZEOF_UINT16;
1931 sig->u.DebugGenericIndication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1932 index += SIZEOF_UINT16;
1933 sig->u.DebugGenericIndication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1934 index += SIZEOF_UINT16;
1935 sig->u.DebugGenericIndication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1936 index += SIZEOF_UINT16;
1937 sig->u.DebugGenericIndication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1938 index += SIZEOF_UINT16;
1939 sig->u.DebugGenericIndication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1940 index += SIZEOF_UINT16;
1941 sig->u.DebugGenericIndication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1942 index += SIZEOF_UINT16;
1943 sig->u.DebugGenericIndication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1944 index += SIZEOF_UINT16;
1945 sig->u.DebugGenericIndication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1946 index += SIZEOF_UINT16;
1947 break;
1948 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
1949 sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1950 index += SIZEOF_UINT16;
1951 sig->u.MaPacketCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1952 index += SIZEOF_UINT16;
1953 sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1954 index += SIZEOF_UINT16;
1955 sig->u.MaPacketCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1956 index += SIZEOF_UINT16;
1957 sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1958 index += SIZEOF_UINT16;
1959 sig->u.MaPacketCancelRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
1960 index += SIZEOF_UINT32;
1961 break;
1962#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1963 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
1964 sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1965 index += SIZEOF_UINT16;
1966 sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1967 index += SIZEOF_UINT16;
1968 sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1969 index += SIZEOF_UINT16;
1970 sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1971 index += SIZEOF_UINT16;
1972 sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1973 index += SIZEOF_UINT16;
1974 sig->u.MlmeModifyBssParameterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1975 index += SIZEOF_UINT16;
1976 break;
1977#endif
1978#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1979 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
1980 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1981 index += SIZEOF_UINT16;
1982 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1983 index += SIZEOF_UINT16;
1984 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1985 index += SIZEOF_UINT16;
1986 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1987 index += SIZEOF_UINT16;
1988 sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1989 index += SIZEOF_UINT16;
1990 sig->u.MlmePauseAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1991 index += SIZEOF_UINT16;
1992 sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1993 index += SIZEOF_UINT16;
1994 break;
1995#endif
1996 case CSR_MA_PACKET_REQUEST_ID:
1997 sig->u.MaPacketRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1998 index += SIZEOF_UINT16;
1999 sig->u.MaPacketRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2000 index += SIZEOF_UINT16;
2001 sig->u.MaPacketRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2002 index += SIZEOF_UINT16;
2003 sig->u.MaPacketRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2004 index += SIZEOF_UINT16;
2005 sig->u.MaPacketRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2006 index += SIZEOF_UINT16;
2007 sig->u.MaPacketRequest.TransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2008 index += SIZEOF_UINT16;
2009 sig->u.MaPacketRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2010 index += SIZEOF_UINT32;
2011 sig->u.MaPacketRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2012 index += SIZEOF_UINT16;
2013 memcpy(sig->u.MaPacketRequest.Ra.x, &ptr[index], 48 / 8);
2014 index += 48 / 8;
2015 sig->u.MaPacketRequest.TransmissionControl = (CSR_TRANSMISSION_CONTROL) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2016 index += SIZEOF_UINT16;
2017 break;
2018#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2019 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
2020 sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2021 index += SIZEOF_UINT16;
2022 sig->u.MlmeModifyBssParameterRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2023 index += SIZEOF_UINT16;
2024 sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2025 index += SIZEOF_UINT16;
2026 sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2027 index += SIZEOF_UINT16;
2028 sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2029 index += SIZEOF_UINT16;
2030 sig->u.MlmeModifyBssParameterRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2031 index += SIZEOF_UINT16;
2032 sig->u.MlmeModifyBssParameterRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2033 index += SIZEOF_UINT16;
2034 sig->u.MlmeModifyBssParameterRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2035 index += SIZEOF_UINT16;
2036 memcpy(sig->u.MlmeModifyBssParameterRequest.Bssid.x, &ptr[index], 48 / 8);
2037 index += 48 / 8;
2038 sig->u.MlmeModifyBssParameterRequest.RtsThreshold = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2039 index += SIZEOF_UINT16;
2040 break;
2041#endif
2042#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2043 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
2044 sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2045 index += SIZEOF_UINT16;
2046 sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2047 index += SIZEOF_UINT16;
2048 sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2049 index += SIZEOF_UINT16;
2050 sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2051 index += SIZEOF_UINT16;
2052 sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2053 index += SIZEOF_UINT16;
2054 sig->u.MlmeAddRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2055 index += SIZEOF_UINT16;
2056 sig->u.MlmeAddRxTriggerRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2057 index += SIZEOF_UINT16;
2058 break;
2059#endif
2060 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
2061 sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2062 index += SIZEOF_UINT16;
2063 sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2064 index += SIZEOF_UINT16;
2065 sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2066 index += SIZEOF_UINT16;
2067 sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2068 index += SIZEOF_UINT16;
2069 sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2070 index += SIZEOF_UINT16;
2071 sig->u.MaVifAvailabilityIndication.Multicast = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2072 index += SIZEOF_UINT16;
2073 break;
2074#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2075 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
2076 sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2077 index += SIZEOF_UINT16;
2078 sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2079 index += SIZEOF_UINT16;
2080 sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2081 index += SIZEOF_UINT16;
2082 sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2083 index += SIZEOF_UINT16;
2084 memcpy(sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, &ptr[index], 48 / 8);
2085 index += 48 / 8;
2086 break;
2087#endif
2088#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2089 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
2090 sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2091 index += SIZEOF_UINT16;
2092 sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2093 index += SIZEOF_UINT16;
2094 sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2095 index += SIZEOF_UINT16;
2096 sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2097 index += SIZEOF_UINT16;
2098 sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2099 index += SIZEOF_UINT16;
2100 sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2101 index += SIZEOF_UINT16;
2102 break;
2103#endif
2104#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2105 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
2106 sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2107 index += SIZEOF_UINT16;
2108 sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2109 index += SIZEOF_UINT16;
2110 sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2111 index += SIZEOF_UINT16;
2112 sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2113 index += SIZEOF_UINT16;
2114 sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2115 index += SIZEOF_UINT16;
2116 sig->u.MlmeBlackoutEndedIndication.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2117 index += SIZEOF_UINT16;
2118 break;
2119#endif
2120#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2121 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
2122 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2123 index += SIZEOF_UINT16;
2124 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2125 index += SIZEOF_UINT16;
2126 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2127 index += SIZEOF_UINT16;
2128 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2129 index += SIZEOF_UINT16;
2130 sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2131 index += SIZEOF_UINT16;
2132 sig->u.MlmeAutonomousScanDoneIndication.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2133 index += SIZEOF_UINT16;
2134 sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2135 index += SIZEOF_UINT16;
2136 break;
2137#endif
2138#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2139 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
2140 sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2141 index += SIZEOF_UINT16;
2142 sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2143 index += SIZEOF_UINT16;
2144 sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2145 index += SIZEOF_UINT16;
2146 sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2147 index += SIZEOF_UINT16;
2148 sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2149 index += SIZEOF_UINT16;
2150 sig->u.MlmeGetKeySequenceRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2151 index += SIZEOF_UINT16;
2152 sig->u.MlmeGetKeySequenceRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2153 index += SIZEOF_UINT16;
2154 memcpy(sig->u.MlmeGetKeySequenceRequest.Address.x, &ptr[index], 48 / 8);
2155 index += 48 / 8;
2156 break;
2157#endif
2158#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2159 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
2160 sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2161 index += SIZEOF_UINT16;
2162 sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2163 index += SIZEOF_UINT16;
2164 sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2165 index += SIZEOF_UINT16;
2166 sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2167 index += SIZEOF_UINT16;
2168 sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2169 index += SIZEOF_UINT16;
2170 sig->u.MlmeSetChannelRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2171 index += SIZEOF_UINT16;
2172 sig->u.MlmeSetChannelRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2173 index += SIZEOF_UINT16;
2174 memcpy(sig->u.MlmeSetChannelRequest.Address.x, &ptr[index], 48 / 8);
2175 index += 48 / 8;
2176 sig->u.MlmeSetChannelRequest.AvailabilityDuration = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2177 index += SIZEOF_UINT16;
2178 sig->u.MlmeSetChannelRequest.AvailabilityInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2179 index += SIZEOF_UINT16;
2180 break;
2181#endif
2182#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2183 case CSR_MLME_MEASURE_CONFIRM_ID:
2184 sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2185 index += SIZEOF_UINT16;
2186 sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2187 index += SIZEOF_UINT16;
2188 sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2189 index += SIZEOF_UINT16;
2190 sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2191 index += SIZEOF_UINT16;
2192 sig->u.MlmeMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2193 index += SIZEOF_UINT16;
2194 sig->u.MlmeMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2195 index += SIZEOF_UINT16;
2196 break;
2197#endif
2198#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2199 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
2200 sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2201 index += SIZEOF_UINT16;
2202 sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2203 index += SIZEOF_UINT16;
2204 sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2205 index += SIZEOF_UINT16;
2206 sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2207 index += SIZEOF_UINT16;
2208 sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2209 index += SIZEOF_UINT16;
2210 sig->u.MlmeAddTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2211 index += SIZEOF_UINT16;
2212 break;
2213#endif
2214#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2215 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
2216 sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2217 index += SIZEOF_UINT16;
2218 sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2219 index += SIZEOF_UINT16;
2220 sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2221 index += SIZEOF_UINT16;
2222 sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2223 index += SIZEOF_UINT16;
2224 sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2225 index += SIZEOF_UINT16;
2226 memcpy(sig->u.MlmeAutonomousScanLossIndication.Bssid.x, &ptr[index], 48 / 8);
2227 index += 48 / 8;
2228 break;
2229#endif
2230 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
2231 sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2232 index += SIZEOF_UINT16;
2233 sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2234 index += SIZEOF_UINT16;
2235 sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2236 index += SIZEOF_UINT16;
2237 sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2238 index += SIZEOF_UINT16;
2239 sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2240 index += SIZEOF_UINT16;
2241 sig->u.MaVifAvailabilityResponse.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2242 index += SIZEOF_UINT16;
2243 break;
2244#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2245 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
2246 sig->u.MlmeAddTemplateRequest.Data1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2247 index += SIZEOF_UINT16;
2248 sig->u.MlmeAddTemplateRequest.Data1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2249 index += SIZEOF_UINT16;
2250 sig->u.MlmeAddTemplateRequest.Data2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2251 index += SIZEOF_UINT16;
2252 sig->u.MlmeAddTemplateRequest.Data2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2253 index += SIZEOF_UINT16;
2254 sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2255 index += SIZEOF_UINT16;
2256 sig->u.MlmeAddTemplateRequest.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2257 index += SIZEOF_UINT16;
2258 sig->u.MlmeAddTemplateRequest.MinTransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2259 index += SIZEOF_UINT16;
2260 break;
2261#endif
2262#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2263 case CSR_MLME_POWERMGT_CONFIRM_ID:
2264 sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2265 index += SIZEOF_UINT16;
2266 sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2267 index += SIZEOF_UINT16;
2268 sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2269 index += SIZEOF_UINT16;
2270 sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2271 index += SIZEOF_UINT16;
2272 sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2273 index += SIZEOF_UINT16;
2274 sig->u.MlmePowermgtConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2275 index += SIZEOF_UINT16;
2276 break;
2277#endif
2278#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2279 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
2280 sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2281 index += SIZEOF_UINT16;
2282 sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2283 index += SIZEOF_UINT16;
2284 sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2285 index += SIZEOF_UINT16;
2286 sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2287 index += SIZEOF_UINT16;
2288 sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2289 index += SIZEOF_UINT16;
2290 sig->u.MlmeAddPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2291 index += SIZEOF_UINT16;
2292 sig->u.MlmeAddPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2293 index += SIZEOF_UINT16;
2294 break;
2295#endif
2296#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2297 case CSR_MLME_GET_CONFIRM_ID:
2298 sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2299 index += SIZEOF_UINT16;
2300 sig->u.MlmeGetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2301 index += SIZEOF_UINT16;
2302 sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2303 index += SIZEOF_UINT16;
2304 sig->u.MlmeGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2305 index += SIZEOF_UINT16;
2306 sig->u.MlmeGetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2307 index += SIZEOF_UINT16;
2308 sig->u.MlmeGetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2309 index += SIZEOF_UINT16;
2310 break;
2311#endif
2312#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2313 case CSR_MLME_GET_NEXT_CONFIRM_ID:
2314 sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2315 index += SIZEOF_UINT16;
2316 sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2317 index += SIZEOF_UINT16;
2318 sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2319 index += SIZEOF_UINT16;
2320 sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2321 index += SIZEOF_UINT16;
2322 sig->u.MlmeGetNextConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2323 index += SIZEOF_UINT16;
2324 sig->u.MlmeGetNextConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2325 index += SIZEOF_UINT16;
2326 break;
2327#endif
2328#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2329 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
2330 sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2331 index += SIZEOF_UINT16;
2332 sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2333 index += SIZEOF_UINT16;
2334 sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2335 index += SIZEOF_UINT16;
2336 sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2337 index += SIZEOF_UINT16;
2338 sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2339 index += SIZEOF_UINT16;
2340 memcpy(sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
2341 index += 48 / 8;
2342 sig->u.MlmeStopAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2343 index += SIZEOF_UINT16;
2344 sig->u.MlmeStopAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2345 index += SIZEOF_UINT16;
2346 break;
2347#endif
2348#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2349 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
2350 sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2351 index += SIZEOF_UINT16;
2352 sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2353 index += SIZEOF_UINT16;
2354 sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2355 index += SIZEOF_UINT16;
2356 sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2357 index += SIZEOF_UINT16;
2358 sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2359 index += SIZEOF_UINT16;
2360 sig->u.MlmeAddRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2361 index += SIZEOF_UINT16;
2362 sig->u.MlmeAddRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2363 index += SIZEOF_UINT16;
2364 break;
2365#endif
2366#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2367 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
2368 sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2369 index += SIZEOF_UINT16;
2370 sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2371 index += SIZEOF_UINT16;
2372 sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2373 index += SIZEOF_UINT16;
2374 sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2375 index += SIZEOF_UINT16;
2376 sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2377 index += SIZEOF_UINT16;
2378 sig->u.MlmeAddBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2379 index += SIZEOF_UINT16;
2380 sig->u.MlmeAddBlackoutRequest.BlackoutType = (CSR_BLACKOUT_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2381 index += SIZEOF_UINT16;
2382 sig->u.MlmeAddBlackoutRequest.BlackoutSource = (CSR_BLACKOUT_SOURCE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2383 index += SIZEOF_UINT16;
2384 sig->u.MlmeAddBlackoutRequest.BlackoutStartReference = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2385 index += SIZEOF_UINT32;
2386 sig->u.MlmeAddBlackoutRequest.BlackoutPeriod = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2387 index += SIZEOF_UINT32;
2388 sig->u.MlmeAddBlackoutRequest.BlackoutDuration = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2389 index += SIZEOF_UINT32;
2390 memcpy(sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, &ptr[index], 48 / 8);
2391 index += 48 / 8;
2392 sig->u.MlmeAddBlackoutRequest.BlackoutCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2393 index += SIZEOF_UINT16;
2394 break;
2395#endif
2396#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2397 case CSR_MLME_DELETEKEYS_REQUEST_ID:
2398 sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2399 index += SIZEOF_UINT16;
2400 sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2401 index += SIZEOF_UINT16;
2402 sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2403 index += SIZEOF_UINT16;
2404 sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2405 index += SIZEOF_UINT16;
2406 sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2407 index += SIZEOF_UINT16;
2408 sig->u.MlmeDeletekeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2409 index += SIZEOF_UINT16;
2410 sig->u.MlmeDeletekeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2411 index += SIZEOF_UINT16;
2412 memcpy(sig->u.MlmeDeletekeysRequest.Address.x, &ptr[index], 48 / 8);
2413 index += 48 / 8;
2414 break;
2415#endif
2416#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2417 case CSR_MLME_RESET_CONFIRM_ID:
2418 sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2419 index += SIZEOF_UINT16;
2420 sig->u.MlmeResetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2421 index += SIZEOF_UINT16;
2422 sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2423 index += SIZEOF_UINT16;
2424 sig->u.MlmeResetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2425 index += SIZEOF_UINT16;
2426 sig->u.MlmeResetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2427 index += SIZEOF_UINT16;
2428 break;
2429#endif
2430#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2431 case CSR_MLME_HL_SYNC_CONFIRM_ID:
2432 sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2433 index += SIZEOF_UINT16;
2434 sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2435 index += SIZEOF_UINT16;
2436 sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2437 index += SIZEOF_UINT16;
2438 sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2439 index += SIZEOF_UINT16;
2440 memcpy(sig->u.MlmeHlSyncConfirm.GroupAddress.x, &ptr[index], 48 / 8);
2441 index += 48 / 8;
2442 sig->u.MlmeHlSyncConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2443 index += SIZEOF_UINT16;
2444 break;
2445#endif
2446#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2447 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
2448 sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2449 index += SIZEOF_UINT16;
2450 sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2451 index += SIZEOF_UINT16;
2452 sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2453 index += SIZEOF_UINT16;
2454 sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2455 index += SIZEOF_UINT16;
2456 sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2457 index += SIZEOF_UINT16;
2458 sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2459 index += SIZEOF_UINT16;
2460 sig->u.MlmeAddAutonomousScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2461 index += SIZEOF_UINT16;
2462 sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2463 index += SIZEOF_UINT16;
2464 sig->u.MlmeAddAutonomousScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2465 index += SIZEOF_UINT16;
2466 sig->u.MlmeAddAutonomousScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2467 index += SIZEOF_UINT32;
2468 sig->u.MlmeAddAutonomousScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2469 index += SIZEOF_UINT16;
2470 sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2471 index += SIZEOF_UINT16;
2472 break;
2473#endif
2474#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2475 case CSR_MLME_SET_REQUEST_ID:
2476 sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2477 index += SIZEOF_UINT16;
2478 sig->u.MlmeSetRequest.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2479 index += SIZEOF_UINT16;
2480 sig->u.MlmeSetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2481 index += SIZEOF_UINT16;
2482 sig->u.MlmeSetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2483 index += SIZEOF_UINT16;
2484 break;
2485#endif
2486#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2487 case CSR_MLME_SM_START_REQUEST_ID:
2488 sig->u.MlmeSmStartRequest.Beacon.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2489 index += SIZEOF_UINT16;
2490 sig->u.MlmeSmStartRequest.Beacon.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2491 index += SIZEOF_UINT16;
2492 sig->u.MlmeSmStartRequest.BssParameters.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2493 index += SIZEOF_UINT16;
2494 sig->u.MlmeSmStartRequest.BssParameters.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2495 index += SIZEOF_UINT16;
2496 sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2497 index += SIZEOF_UINT16;
2498 sig->u.MlmeSmStartRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2499 index += SIZEOF_UINT16;
2500 sig->u.MlmeSmStartRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2501 index += SIZEOF_UINT16;
2502 memcpy(sig->u.MlmeSmStartRequest.InterfaceAddress.x, &ptr[index], 48 / 8);
2503 index += 48 / 8;
2504 memcpy(sig->u.MlmeSmStartRequest.Bssid.x, &ptr[index], 48 / 8);
2505 index += 48 / 8;
2506 sig->u.MlmeSmStartRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2507 index += SIZEOF_UINT16;
2508 sig->u.MlmeSmStartRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2509 index += SIZEOF_UINT16;
2510 sig->u.MlmeSmStartRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2511 index += SIZEOF_UINT16;
2512 break;
2513#endif
2514#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2515 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
2516 sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2517 index += SIZEOF_UINT16;
2518 sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2519 index += SIZEOF_UINT16;
2520 sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2521 index += SIZEOF_UINT16;
2522 sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2523 index += SIZEOF_UINT16;
2524 sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2525 index += SIZEOF_UINT16;
2526 sig->u.MlmeConnectStatusConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2527 index += SIZEOF_UINT16;
2528 break;
2529#endif
2530#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2531 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
2532 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2533 index += SIZEOF_UINT16;
2534 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2535 index += SIZEOF_UINT16;
2536 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2537 index += SIZEOF_UINT16;
2538 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2539 index += SIZEOF_UINT16;
2540 sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2541 index += SIZEOF_UINT16;
2542 sig->u.MlmeDelAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2543 index += SIZEOF_UINT16;
2544 sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2545 index += SIZEOF_UINT16;
2546 break;
2547#endif
2548#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2549 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
2550 sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2551 index += SIZEOF_UINT16;
2552 sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2553 index += SIZEOF_UINT16;
2554 sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2555 index += SIZEOF_UINT16;
2556 sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2557 index += SIZEOF_UINT16;
2558 sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2559 index += SIZEOF_UINT16;
2560 sig->u.MlmeDelPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2561 index += SIZEOF_UINT16;
2562 break;
2563#endif
2564#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2565 case CSR_MLME_SETKEYS_REQUEST_ID:
2566 sig->u.MlmeSetkeysRequest.Key.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2567 index += SIZEOF_UINT16;
2568 sig->u.MlmeSetkeysRequest.Key.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2569 index += SIZEOF_UINT16;
2570 sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2571 index += SIZEOF_UINT16;
2572 sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2573 index += SIZEOF_UINT16;
2574 sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2575 index += SIZEOF_UINT16;
2576 sig->u.MlmeSetkeysRequest.Length = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2577 index += SIZEOF_UINT16;
2578 sig->u.MlmeSetkeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2579 index += SIZEOF_UINT16;
2580 sig->u.MlmeSetkeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2581 index += SIZEOF_UINT16;
2582 memcpy(sig->u.MlmeSetkeysRequest.Address.x, &ptr[index], 48 / 8);
2583 index += 48 / 8;
2584 sig->u.MlmeSetkeysRequest.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2585 index += SIZEOF_UINT16;
2586 sig->u.MlmeSetkeysRequest.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2587 index += SIZEOF_UINT16;
2588 sig->u.MlmeSetkeysRequest.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2589 index += SIZEOF_UINT16;
2590 sig->u.MlmeSetkeysRequest.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2591 index += SIZEOF_UINT16;
2592 sig->u.MlmeSetkeysRequest.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2593 index += SIZEOF_UINT16;
2594 sig->u.MlmeSetkeysRequest.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2595 index += SIZEOF_UINT16;
2596 sig->u.MlmeSetkeysRequest.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2597 index += SIZEOF_UINT16;
2598 sig->u.MlmeSetkeysRequest.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2599 index += SIZEOF_UINT16;
2600 memcpy(&sig->u.MlmeSetkeysRequest.CipherSuiteSelector, &ptr[index], 32 / 8);
2601 index += 32 / 8;
2602 break;
2603#endif
2604#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2605 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
2606 sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2607 index += SIZEOF_UINT16;
2608 sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2609 index += SIZEOF_UINT16;
2610 sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2611 index += SIZEOF_UINT16;
2612 sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2613 index += SIZEOF_UINT16;
2614 sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2615 index += SIZEOF_UINT16;
2616 sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2617 index += SIZEOF_UINT16;
2618 sig->u.MlmePauseAutonomousScanRequest.Pause = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2619 index += SIZEOF_UINT16;
2620 break;
2621#endif
2622#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2623 case CSR_MLME_GET_REQUEST_ID:
2624 sig->u.MlmeGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2625 index += SIZEOF_UINT16;
2626 sig->u.MlmeGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2627 index += SIZEOF_UINT16;
2628 sig->u.MlmeGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2629 index += SIZEOF_UINT16;
2630 sig->u.MlmeGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2631 index += SIZEOF_UINT16;
2632 break;
2633#endif
2634#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2635 case CSR_MLME_POWERMGT_REQUEST_ID:
2636 sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2637 index += SIZEOF_UINT16;
2638 sig->u.MlmePowermgtRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2639 index += SIZEOF_UINT16;
2640 sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2641 index += SIZEOF_UINT16;
2642 sig->u.MlmePowermgtRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2643 index += SIZEOF_UINT16;
2644 sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2645 index += SIZEOF_UINT16;
2646 sig->u.MlmePowermgtRequest.PowerManagementMode = (CSR_POWER_MANAGEMENT_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2647 index += SIZEOF_UINT16;
2648 sig->u.MlmePowermgtRequest.ReceiveDtims = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2649 index += SIZEOF_UINT16;
2650 sig->u.MlmePowermgtRequest.ListenInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2651 index += SIZEOF_UINT16;
2652 sig->u.MlmePowermgtRequest.TrafficWindow = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2653 index += SIZEOF_UINT16;
2654 break;
2655#endif
2656 case CSR_MA_PACKET_ERROR_INDICATION_ID:
2657 sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2658 index += SIZEOF_UINT16;
2659 sig->u.MaPacketErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2660 index += SIZEOF_UINT16;
2661 sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2662 index += SIZEOF_UINT16;
2663 sig->u.MaPacketErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2664 index += SIZEOF_UINT16;
2665 sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2666 index += SIZEOF_UINT16;
2667 memcpy(sig->u.MaPacketErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
2668 index += 48 / 8;
2669 sig->u.MaPacketErrorIndication.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2670 index += SIZEOF_UINT16;
2671 sig->u.MaPacketErrorIndication.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2672 index += SIZEOF_UINT16;
2673 break;
2674#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2675 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
2676 sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2677 index += SIZEOF_UINT16;
2678 sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2679 index += SIZEOF_UINT16;
2680 sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2681 index += SIZEOF_UINT16;
2682 sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2683 index += SIZEOF_UINT16;
2684 sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2685 index += SIZEOF_UINT16;
2686 sig->u.MlmeAddPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2687 index += SIZEOF_UINT16;
2688 sig->u.MlmeAddPeriodicRequest.MaximumLatency = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2689 index += SIZEOF_UINT32;
2690 sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode = (CSR_PERIODIC_SCHEDULING_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2691 index += SIZEOF_UINT16;
2692 sig->u.MlmeAddPeriodicRequest.WakeHost = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2693 index += SIZEOF_UINT16;
2694 sig->u.MlmeAddPeriodicRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2695 index += SIZEOF_UINT16;
2696 break;
2697#endif
2698#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2699 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
2700 sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2701 index += SIZEOF_UINT16;
2702 sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2703 index += SIZEOF_UINT16;
2704 sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2705 index += SIZEOF_UINT16;
2706 sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2707 index += SIZEOF_UINT16;
2708 sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2709 index += SIZEOF_UINT16;
2710 sig->u.MlmeAddTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2711 index += SIZEOF_UINT16;
2712 sig->u.MlmeAddTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2713 index += SIZEOF_UINT16;
2714 sig->u.MlmeAddTspecRequest.PsScheme = (CSR_PS_SCHEME) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2715 index += SIZEOF_UINT16;
2716 sig->u.MlmeAddTspecRequest.MediumTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2717 index += SIZEOF_UINT16;
2718 sig->u.MlmeAddTspecRequest.ServiceStartTime = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2719 index += SIZEOF_UINT32;
2720 sig->u.MlmeAddTspecRequest.ServiceInterval = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2721 index += SIZEOF_UINT32;
2722 sig->u.MlmeAddTspecRequest.MinimumDataRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2723 index += SIZEOF_UINT16;
2724 break;
2725#endif
2726#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2727 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
2728 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2729 index += SIZEOF_UINT16;
2730 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2731 index += SIZEOF_UINT16;
2732 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2733 index += SIZEOF_UINT16;
2734 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2735 index += SIZEOF_UINT16;
2736 sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2737 index += SIZEOF_UINT16;
2738 sig->u.MlmeAddMulticastAddressConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2739 index += SIZEOF_UINT16;
2740 break;
2741#endif
2742#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2743 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
2744 sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2745 index += SIZEOF_UINT16;
2746 sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2747 index += SIZEOF_UINT16;
2748 sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2749 index += SIZEOF_UINT16;
2750 sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2751 index += SIZEOF_UINT16;
2752 sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2753 index += SIZEOF_UINT16;
2754 sig->u.MlmeAddTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2755 index += SIZEOF_UINT16;
2756 sig->u.MlmeAddTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2757 index += SIZEOF_UINT16;
2758 break;
2759#endif
2760#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2761 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
2762 sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2763 index += SIZEOF_UINT16;
2764 sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2765 index += SIZEOF_UINT16;
2766 sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2767 index += SIZEOF_UINT16;
2768 sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2769 index += SIZEOF_UINT16;
2770 sig->u.MlmeHlSyncCancelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2771 index += SIZEOF_UINT16;
2772 break;
2773#endif
2774#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2775 case CSR_MLME_SCAN_CONFIRM_ID:
2776 sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2777 index += SIZEOF_UINT16;
2778 sig->u.MlmeScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2779 index += SIZEOF_UINT16;
2780 sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2781 index += SIZEOF_UINT16;
2782 sig->u.MlmeScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2783 index += SIZEOF_UINT16;
2784 sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2785 index += SIZEOF_UINT16;
2786 sig->u.MlmeScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2787 index += SIZEOF_UINT16;
2788 break;
2789#endif
2790 case CSR_DEBUG_STRING_INDICATION_ID:
2791 sig->u.DebugStringIndication.DebugMessage.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2792 index += SIZEOF_UINT16;
2793 sig->u.DebugStringIndication.DebugMessage.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2794 index += SIZEOF_UINT16;
2795 sig->u.DebugStringIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2796 index += SIZEOF_UINT16;
2797 sig->u.DebugStringIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2798 index += SIZEOF_UINT16;
2799 break;
2800#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2801 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
2802 sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2803 index += SIZEOF_UINT16;
2804 sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2805 index += SIZEOF_UINT16;
2806 sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2807 index += SIZEOF_UINT16;
2808 sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2809 index += SIZEOF_UINT16;
2810 sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2811 index += SIZEOF_UINT16;
2812 sig->u.MlmeAddTemplateConfirm.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2813 index += SIZEOF_UINT16;
2814 sig->u.MlmeAddTemplateConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2815 index += SIZEOF_UINT16;
2816 break;
2817#endif
2818#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2819 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
2820 sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2821 index += SIZEOF_UINT16;
2822 sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2823 index += SIZEOF_UINT16;
2824 sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2825 index += SIZEOF_UINT16;
2826 sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2827 index += SIZEOF_UINT16;
2828 sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2829 index += SIZEOF_UINT16;
2830 sig->u.MlmeBlockackErrorIndication.ResultCode = (CSR_REASON_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2831 index += SIZEOF_UINT16;
2832 memcpy(sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
2833 index += 48 / 8;
2834 break;
2835#endif
2836#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2837 case CSR_MLME_SET_CONFIRM_ID:
2838 sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2839 index += SIZEOF_UINT16;
2840 sig->u.MlmeSetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2841 index += SIZEOF_UINT16;
2842 sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2843 index += SIZEOF_UINT16;
2844 sig->u.MlmeSetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2845 index += SIZEOF_UINT16;
2846 sig->u.MlmeSetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2847 index += SIZEOF_UINT16;
2848 sig->u.MlmeSetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2849 index += SIZEOF_UINT16;
2850 break;
2851#endif
2852#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2853 case CSR_MLME_MEASURE_REQUEST_ID:
2854 sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2855 index += SIZEOF_UINT16;
2856 sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2857 index += SIZEOF_UINT16;
2858 sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2859 index += SIZEOF_UINT16;
2860 sig->u.MlmeMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2861 index += SIZEOF_UINT16;
2862 sig->u.MlmeMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2863 index += SIZEOF_UINT16;
2864 break;
2865#endif
2866#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2867 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
2868 sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2869 index += SIZEOF_UINT16;
2870 sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2871 index += SIZEOF_UINT16;
2872 sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2873 index += SIZEOF_UINT16;
2874 sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2875 index += SIZEOF_UINT16;
2876 sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2877 index += SIZEOF_UINT16;
2878 memcpy(sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
2879 index += 48 / 8;
2880 sig->u.MlmeStartAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2881 index += SIZEOF_UINT16;
2882 sig->u.MlmeStartAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2883 index += SIZEOF_UINT16;
2884 sig->u.MlmeStartAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2885 index += SIZEOF_UINT16;
2886 sig->u.MlmeStartAggregationConfirm.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2887 index += SIZEOF_UINT16;
2888 break;
2889#endif
2890#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2891 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
2892 sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2893 index += SIZEOF_UINT16;
2894 sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2895 index += SIZEOF_UINT16;
2896 sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2897 index += SIZEOF_UINT16;
2898 sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2899 index += SIZEOF_UINT16;
2900 sig->u.MlmeStopMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2901 index += SIZEOF_UINT16;
2902 sig->u.MlmeStopMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2903 index += SIZEOF_UINT16;
2904 break;
2905#endif
2906 case CSR_MA_PACKET_CONFIRM_ID:
2907 sig->u.MaPacketConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2908 index += SIZEOF_UINT16;
2909 sig->u.MaPacketConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2910 index += SIZEOF_UINT16;
2911 sig->u.MaPacketConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2912 index += SIZEOF_UINT16;
2913 sig->u.MaPacketConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2914 index += SIZEOF_UINT16;
2915 sig->u.MaPacketConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2916 index += SIZEOF_UINT16;
2917 sig->u.MaPacketConfirm.TransmissionStatus = (CSR_TRANSMISSION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2918 index += SIZEOF_UINT16;
2919 sig->u.MaPacketConfirm.RetryCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2920 index += SIZEOF_UINT16;
2921 sig->u.MaPacketConfirm.Rate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2922 index += SIZEOF_UINT16;
2923 sig->u.MaPacketConfirm.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2924 index += SIZEOF_UINT32;
2925 break;
2926#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2927 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
2928 sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2929 index += SIZEOF_UINT16;
2930 sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2931 index += SIZEOF_UINT16;
2932 sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2933 index += SIZEOF_UINT16;
2934 sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2935 index += SIZEOF_UINT16;
2936 sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2937 index += SIZEOF_UINT16;
2938 sig->u.MlmeDelPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2939 index += SIZEOF_UINT16;
2940 sig->u.MlmeDelPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2941 index += SIZEOF_UINT16;
2942 break;
2943#endif
2944#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2945 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
2946 sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2947 index += SIZEOF_UINT16;
2948 sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2949 index += SIZEOF_UINT16;
2950 sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2951 index += SIZEOF_UINT16;
2952 sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2953 index += SIZEOF_UINT16;
2954 sig->u.MlmeStopMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2955 index += SIZEOF_UINT16;
2956 break;
2957#endif
2958
2959 default:
2960 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2961 }
2962 return CSR_RESULT_SUCCESS;
2963} /* read_unpack_signal() */
2964
2965
2966/*
2967 * ---------------------------------------------------------------------------
2968 * write_pack
2969 *
2970 * Convert a signal structure, in host-native format, to the
2971 * little-endian wire format specified in the UniFi Host Interface
2972 * Protocol Specification.
2973 *
2974 * WARNING: This function is auto-generated, DO NOT EDIT!
2975 *
2976 * Arguments:
2977 * sig Pointer to signal structure to pack.
2978 * ptr Destination buffer to pack into.
2979 * sig_len Returns the length of the packed signal, i.e. the
2980 * number of bytes written to ptr.
2981 *
2982 * Returns:
2983 * CSR_RESULT_SUCCESS on success,
2984 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
2985 * ---------------------------------------------------------------------------
2986 */
2987CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len)
2988{
2989 s16 index = 0;
2990
2991 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SignalId, ptr + index);
2992 index += SIZEOF_UINT16;
2993
2994 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.ReceiverProcessId, ptr + index);
2995 index += SIZEOF_UINT16;
2996
2997 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SenderProcessId, ptr + index);
2998 index += SIZEOF_UINT16;
2999
3000 switch (sig->SignalPrimitiveHeader.SignalId)
3001 {
3002#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3003 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
3004 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber, ptr + index);
3005 index += SIZEOF_UINT16;
3006 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength, ptr + index);
3007 index += SIZEOF_UINT16;
3008 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber, ptr + index);
3009 index += SIZEOF_UINT16;
3010 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength, ptr + index);
3011 index += SIZEOF_UINT16;
3012 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier, ptr + index);
3013 index += SIZEOF_UINT16;
3014 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.ResultCode, ptr + index);
3015 index += SIZEOF_UINT16;
3016 break;
3017#endif
3018#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3019 case CSR_MLME_SETKEYS_CONFIRM_ID:
3020 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber, ptr + index);
3021 index += SIZEOF_UINT16;
3022 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength, ptr + index);
3023 index += SIZEOF_UINT16;
3024 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber, ptr + index);
3025 index += SIZEOF_UINT16;
3026 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength, ptr + index);
3027 index += SIZEOF_UINT16;
3028 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier, ptr + index);
3029 index += SIZEOF_UINT16;
3030 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.ResultCode, ptr + index);
3031 index += SIZEOF_UINT16;
3032 break;
3033#endif
3034#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3035 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
3036 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber, ptr + index);
3037 index += SIZEOF_UINT16;
3038 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength, ptr + index);
3039 index += SIZEOF_UINT16;
3040 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber, ptr + index);
3041 index += SIZEOF_UINT16;
3042 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength, ptr + index);
3043 index += SIZEOF_UINT16;
3044 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.ResultCode, ptr + index);
3045 index += SIZEOF_UINT16;
3046 break;
3047#endif
3048#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3049 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
3050 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
3051 index += SIZEOF_UINT16;
3052 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
3053 index += SIZEOF_UINT16;
3054 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
3055 index += SIZEOF_UINT16;
3056 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
3057 index += SIZEOF_UINT16;
3058 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
3059 index += SIZEOF_UINT16;
3060 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.ResultCode, ptr + index);
3061 index += SIZEOF_UINT16;
3062 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId, ptr + index);
3063 index += SIZEOF_UINT16;
3064 break;
3065#endif
3066#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3067 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
3068 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
3069 index += SIZEOF_UINT16;
3070 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
3071 index += SIZEOF_UINT16;
3072 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
3073 index += SIZEOF_UINT16;
3074 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
3075 index += SIZEOF_UINT16;
3076 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
3077 index += SIZEOF_UINT16;
3078 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.BlackoutId, ptr + index);
3079 index += SIZEOF_UINT16;
3080 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.ResultCode, ptr + index);
3081 index += SIZEOF_UINT16;
3082 break;
3083#endif
3084#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3085 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
3086 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
3087 index += SIZEOF_UINT16;
3088 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength, ptr + index);
3089 index += SIZEOF_UINT16;
3090 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
3091 index += SIZEOF_UINT16;
3092 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength, ptr + index);
3093 index += SIZEOF_UINT16;
3094 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
3095 index += SIZEOF_UINT16;
3096 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.BlackoutId, ptr + index);
3097 index += SIZEOF_UINT16;
3098 break;
3099#endif
3100#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3101 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
3102 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber, ptr + index);
3103 index += SIZEOF_UINT16;
3104 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength, ptr + index);
3105 index += SIZEOF_UINT16;
3106 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber, ptr + index);
3107 index += SIZEOF_UINT16;
3108 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength, ptr + index);
3109 index += SIZEOF_UINT16;
3110 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier, ptr + index);
3111 index += SIZEOF_UINT16;
3112 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.ResultCode, ptr + index);
3113 index += SIZEOF_UINT16;
3114 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0], ptr + index);
3115 index += SIZEOF_UINT16;
3116 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1], ptr + index);
3117 index += SIZEOF_UINT16;
3118 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2], ptr + index);
3119 index += SIZEOF_UINT16;
3120 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3], ptr + index);
3121 index += SIZEOF_UINT16;
3122 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4], ptr + index);
3123 index += SIZEOF_UINT16;
3124 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5], ptr + index);
3125 index += SIZEOF_UINT16;
3126 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6], ptr + index);
3127 index += SIZEOF_UINT16;
3128 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7], ptr + index);
3129 index += SIZEOF_UINT16;
3130 break;
3131#endif
3132#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3133 case CSR_MLME_SM_START_CONFIRM_ID:
3134 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber, ptr + index);
3135 index += SIZEOF_UINT16;
3136 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength, ptr + index);
3137 index += SIZEOF_UINT16;
3138 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber, ptr + index);
3139 index += SIZEOF_UINT16;
3140 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength, ptr + index);
3141 index += SIZEOF_UINT16;
3142 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier, ptr + index);
3143 index += SIZEOF_UINT16;
3144 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.ResultCode, ptr + index);
3145 index += SIZEOF_UINT16;
3146 break;
3147#endif
3148#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3149 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
3150 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
3151 index += SIZEOF_UINT16;
3152 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength, ptr + index);
3153 index += SIZEOF_UINT16;
3154 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
3155 index += SIZEOF_UINT16;
3156 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength, ptr + index);
3157 index += SIZEOF_UINT16;
3158 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
3159 index += SIZEOF_UINT16;
3160 memcpy(ptr + index, sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, 48 / 8);
3161 index += 48 / 8;
3162 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.UserPriority, ptr + index);
3163 index += SIZEOF_UINT16;
3164 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Direction, ptr + index);
3165 index += SIZEOF_UINT16;
3166 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.ResultCode, ptr + index);
3167 index += SIZEOF_UINT16;
3168 break;
3169#endif
3170#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3171 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
3172 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber, ptr + index);
3173 index += SIZEOF_UINT16;
3174 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength, ptr + index);
3175 index += SIZEOF_UINT16;
3176 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber, ptr + index);
3177 index += SIZEOF_UINT16;
3178 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength, ptr + index);
3179 index += SIZEOF_UINT16;
3180 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier, ptr + index);
3181 index += SIZEOF_UINT16;
3182 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.UserPriority, ptr + index);
3183 index += SIZEOF_UINT16;
3184 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Direction, ptr + index);
3185 index += SIZEOF_UINT16;
3186 break;
3187#endif
3188 case CSR_DEBUG_WORD16_INDICATION_ID:
3189 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.SlotNumber, ptr + index);
3190 index += SIZEOF_UINT16;
3191 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.DataLength, ptr + index);
3192 index += SIZEOF_UINT16;
3193 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.SlotNumber, ptr + index);
3194 index += SIZEOF_UINT16;
3195 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.DataLength, ptr + index);
3196 index += SIZEOF_UINT16;
3197 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[0], ptr + index);
3198 index += SIZEOF_UINT16;
3199 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[1], ptr + index);
3200 index += SIZEOF_UINT16;
3201 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[2], ptr + index);
3202 index += SIZEOF_UINT16;
3203 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[3], ptr + index);
3204 index += SIZEOF_UINT16;
3205 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[4], ptr + index);
3206 index += SIZEOF_UINT16;
3207 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[5], ptr + index);
3208 index += SIZEOF_UINT16;
3209 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[6], ptr + index);
3210 index += SIZEOF_UINT16;
3211 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[7], ptr + index);
3212 index += SIZEOF_UINT16;
3213 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[8], ptr + index);
3214 index += SIZEOF_UINT16;
3215 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[9], ptr + index);
3216 index += SIZEOF_UINT16;
3217 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[10], ptr + index);
3218 index += SIZEOF_UINT16;
3219 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[11], ptr + index);
3220 index += SIZEOF_UINT16;
3221 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[12], ptr + index);
3222 index += SIZEOF_UINT16;
3223 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[13], ptr + index);
3224 index += SIZEOF_UINT16;
3225 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[14], ptr + index);
3226 index += SIZEOF_UINT16;
3227 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[15], ptr + index);
3228 index += SIZEOF_UINT16;
3229 break;
3230 case CSR_DEBUG_GENERIC_CONFIRM_ID:
3231 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.SlotNumber, ptr + index);
3232 index += SIZEOF_UINT16;
3233 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.DataLength, ptr + index);
3234 index += SIZEOF_UINT16;
3235 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber, ptr + index);
3236 index += SIZEOF_UINT16;
3237 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.DataLength, ptr + index);
3238 index += SIZEOF_UINT16;
3239 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[0], ptr + index);
3240 index += SIZEOF_UINT16;
3241 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[1], ptr + index);
3242 index += SIZEOF_UINT16;
3243 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[2], ptr + index);
3244 index += SIZEOF_UINT16;
3245 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[3], ptr + index);
3246 index += SIZEOF_UINT16;
3247 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[4], ptr + index);
3248 index += SIZEOF_UINT16;
3249 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[5], ptr + index);
3250 index += SIZEOF_UINT16;
3251 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[6], ptr + index);
3252 index += SIZEOF_UINT16;
3253 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[7], ptr + index);
3254 index += SIZEOF_UINT16;
3255 break;
3256 case CSR_MA_PACKET_INDICATION_ID:
3257 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.SlotNumber, ptr + index);
3258 index += SIZEOF_UINT16;
3259 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.DataLength, ptr + index);
3260 index += SIZEOF_UINT16;
3261 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.SlotNumber, ptr + index);
3262 index += SIZEOF_UINT16;
3263 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.DataLength, ptr + index);
3264 index += SIZEOF_UINT16;
3265 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.VirtualInterfaceIdentifier, ptr + index);
3266 index += SIZEOF_UINT16;
3267 memcpy(ptr + index, sig->u.MaPacketIndication.LocalTime.x, 64 / 8);
3268 index += 64 / 8;
3269 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Ifindex, ptr + index);
3270 index += SIZEOF_UINT16;
3271 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Channel, ptr + index);
3272 index += SIZEOF_UINT16;
3273 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceptionStatus, ptr + index);
3274 index += SIZEOF_UINT16;
3275 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Rssi, ptr + index);
3276 index += SIZEOF_UINT16;
3277 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Snr, ptr + index);
3278 index += SIZEOF_UINT16;
3279 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceivedRate, ptr + index);
3280 index += SIZEOF_UINT16;
3281 break;
3282 case CSR_MLME_SET_TIM_REQUEST_ID:
3283 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber, ptr + index);
3284 index += SIZEOF_UINT16;
3285 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.DataLength, ptr + index);
3286 index += SIZEOF_UINT16;
3287 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber, ptr + index);
3288 index += SIZEOF_UINT16;
3289 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.DataLength, ptr + index);
3290 index += SIZEOF_UINT16;
3291 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier, ptr + index);
3292 index += SIZEOF_UINT16;
3293 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.AssociationId, ptr + index);
3294 index += SIZEOF_UINT16;
3295 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.TimValue, ptr + index);
3296 index += SIZEOF_UINT16;
3297 break;
3298#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3299 case CSR_MLME_CONNECTED_INDICATION_ID:
3300 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber, ptr + index);
3301 index += SIZEOF_UINT16;
3302 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.DataLength, ptr + index);
3303 index += SIZEOF_UINT16;
3304 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber, ptr + index);
3305 index += SIZEOF_UINT16;
3306 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.DataLength, ptr + index);
3307 index += SIZEOF_UINT16;
3308 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier, ptr + index);
3309 index += SIZEOF_UINT16;
3310 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.ConnectionStatus, ptr + index);
3311 index += SIZEOF_UINT16;
3312 memcpy(ptr + index, sig->u.MlmeConnectedIndication.PeerMacAddress.x, 48 / 8);
3313 index += 48 / 8;
3314 break;
3315#endif
3316#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3317 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
3318 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber, ptr + index);
3319 index += SIZEOF_UINT16;
3320 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength, ptr + index);
3321 index += SIZEOF_UINT16;
3322 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
3323 index += SIZEOF_UINT16;
3324 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
3325 index += SIZEOF_UINT16;
3326 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
3327 index += SIZEOF_UINT16;
3328 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.TriggerId, ptr + index);
3329 index += SIZEOF_UINT16;
3330 break;
3331#endif
3332#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3333 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
3334 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber, ptr + index);
3335 index += SIZEOF_UINT16;
3336 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength, ptr + index);
3337 index += SIZEOF_UINT16;
3338 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber, ptr + index);
3339 index += SIZEOF_UINT16;
3340 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength, ptr + index);
3341 index += SIZEOF_UINT16;
3342 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier, ptr + index);
3343 index += SIZEOF_UINT16;
3344 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Status, ptr + index);
3345 index += SIZEOF_UINT16;
3346 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.ErrorIndex, ptr + index);
3347 index += SIZEOF_UINT16;
3348 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.TriggeredId, ptr + index);
3349 index += SIZEOF_UINT16;
3350 break;
3351#endif
3352#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3353 case CSR_MLME_SCAN_REQUEST_ID:
3354 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.SlotNumber, ptr + index);
3355 index += SIZEOF_UINT16;
3356 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.DataLength, ptr + index);
3357 index += SIZEOF_UINT16;
3358 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.SlotNumber, ptr + index);
3359 index += SIZEOF_UINT16;
3360 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.DataLength, ptr + index);
3361 index += SIZEOF_UINT16;
3362 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.VirtualInterfaceIdentifier, ptr + index);
3363 index += SIZEOF_UINT16;
3364 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.Ifindex, ptr + index);
3365 index += SIZEOF_UINT16;
3366 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ScanType, ptr + index);
3367 index += SIZEOF_UINT16;
3368 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ProbeDelay, ptr + index);
3369 index += SIZEOF_UINT32;
3370 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MinChannelTime, ptr + index);
3371 index += SIZEOF_UINT16;
3372 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MaxChannelTime, ptr + index);
3373 index += SIZEOF_UINT16;
3374 break;
3375#endif
3376#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3377 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
3378 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber, ptr + index);
3379 index += SIZEOF_UINT16;
3380 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength, ptr + index);
3381 index += SIZEOF_UINT16;
3382 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber, ptr + index);
3383 index += SIZEOF_UINT16;
3384 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength, ptr + index);
3385 index += SIZEOF_UINT16;
3386 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier, ptr + index);
3387 index += SIZEOF_UINT16;
3388 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.ResultCode, ptr + index);
3389 index += SIZEOF_UINT16;
3390 break;
3391#endif
3392#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3393 case CSR_MLME_GET_NEXT_REQUEST_ID:
3394 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber, ptr + index);
3395 index += SIZEOF_UINT16;
3396 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.DataLength, ptr + index);
3397 index += SIZEOF_UINT16;
3398 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber, ptr + index);
3399 index += SIZEOF_UINT16;
3400 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.DataLength, ptr + index);
3401 index += SIZEOF_UINT16;
3402 break;
3403#endif
3404#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3405 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
3406 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber, ptr + index);
3407 index += SIZEOF_UINT16;
3408 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength, ptr + index);
3409 index += SIZEOF_UINT16;
3410 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber, ptr + index);
3411 index += SIZEOF_UINT16;
3412 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength, ptr + index);
3413 index += SIZEOF_UINT16;
3414 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier, ptr + index);
3415 index += SIZEOF_UINT16;
3416 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.ResultCode, ptr + index);
3417 index += SIZEOF_UINT16;
3418 break;
3419#endif
3420#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3421 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
3422 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
3423 index += SIZEOF_UINT16;
3424 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength, ptr + index);
3425 index += SIZEOF_UINT16;
3426 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
3427 index += SIZEOF_UINT16;
3428 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength, ptr + index);
3429 index += SIZEOF_UINT16;
3430 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
3431 index += SIZEOF_UINT16;
3432 memcpy(ptr + index, sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, 48 / 8);
3433 index += 48 / 8;
3434 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.UserPriority, ptr + index);
3435 index += SIZEOF_UINT16;
3436 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Direction, ptr + index);
3437 index += SIZEOF_UINT16;
3438 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.StartingSequenceNumber, ptr + index);
3439 index += SIZEOF_UINT16;
3440 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BufferSize, ptr + index);
3441 index += SIZEOF_UINT16;
3442 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BlockAckTimeout, ptr + index);
3443 index += SIZEOF_UINT16;
3444 break;
3445#endif
3446#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3447 case CSR_MLME_HL_SYNC_REQUEST_ID:
3448 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber, ptr + index);
3449 index += SIZEOF_UINT16;
3450 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength, ptr + index);
3451 index += SIZEOF_UINT16;
3452 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber, ptr + index);
3453 index += SIZEOF_UINT16;
3454 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength, ptr + index);
3455 index += SIZEOF_UINT16;
3456 memcpy(ptr + index, sig->u.MlmeHlSyncRequest.GroupAddress.x, 48 / 8);
3457 index += 48 / 8;
3458 break;
3459#endif
3460 case CSR_DEBUG_GENERIC_REQUEST_ID:
3461 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.SlotNumber, ptr + index);
3462 index += SIZEOF_UINT16;
3463 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.DataLength, ptr + index);
3464 index += SIZEOF_UINT16;
3465 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.SlotNumber, ptr + index);
3466 index += SIZEOF_UINT16;
3467 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.DataLength, ptr + index);
3468 index += SIZEOF_UINT16;
3469 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[0], ptr + index);
3470 index += SIZEOF_UINT16;
3471 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[1], ptr + index);
3472 index += SIZEOF_UINT16;
3473 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[2], ptr + index);
3474 index += SIZEOF_UINT16;
3475 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[3], ptr + index);
3476 index += SIZEOF_UINT16;
3477 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[4], ptr + index);
3478 index += SIZEOF_UINT16;
3479 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[5], ptr + index);
3480 index += SIZEOF_UINT16;
3481 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[6], ptr + index);
3482 index += SIZEOF_UINT16;
3483 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[7], ptr + index);
3484 index += SIZEOF_UINT16;
3485 break;
3486#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3487 case CSR_MLME_LEAVE_CONFIRM_ID:
3488 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber, ptr + index);
3489 index += SIZEOF_UINT16;
3490 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength, ptr + index);
3491 index += SIZEOF_UINT16;
3492 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber, ptr + index);
3493 index += SIZEOF_UINT16;
3494 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength, ptr + index);
3495 index += SIZEOF_UINT16;
3496 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier, ptr + index);
3497 index += SIZEOF_UINT16;
3498 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.ResultCode, ptr + index);
3499 index += SIZEOF_UINT16;
3500 break;
3501#endif
3502#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3503 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
3504 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber, ptr + index);
3505 index += SIZEOF_UINT16;
3506 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength, ptr + index);
3507 index += SIZEOF_UINT16;
3508 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
3509 index += SIZEOF_UINT16;
3510 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
3511 index += SIZEOF_UINT16;
3512 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
3513 index += SIZEOF_UINT16;
3514 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.TriggeredId, ptr + index);
3515 index += SIZEOF_UINT16;
3516 break;
3517#endif
3518#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3519 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
3520 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber, ptr + index);
3521 index += SIZEOF_UINT16;
3522 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.DataLength, ptr + index);
3523 index += SIZEOF_UINT16;
3524 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber, ptr + index);
3525 index += SIZEOF_UINT16;
3526 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength, ptr + index);
3527 index += SIZEOF_UINT16;
3528 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier, ptr + index);
3529 index += SIZEOF_UINT16;
3530 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses, ptr + index);
3531 index += SIZEOF_UINT16;
3532 break;
3533#endif
3534#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3535 case CSR_MLME_RESET_REQUEST_ID:
3536 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.SlotNumber, ptr + index);
3537 index += SIZEOF_UINT16;
3538 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.DataLength, ptr + index);
3539 index += SIZEOF_UINT16;
3540 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.SlotNumber, ptr + index);
3541 index += SIZEOF_UINT16;
3542 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.DataLength, ptr + index);
3543 index += SIZEOF_UINT16;
3544 memcpy(ptr + index, sig->u.MlmeResetRequest.StaAddress.x, 48 / 8);
3545 index += 48 / 8;
3546 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.SetDefaultMib, ptr + index);
3547 index += SIZEOF_UINT16;
3548 break;
3549#endif
3550#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3551 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
3552 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber, ptr + index);
3553 index += SIZEOF_UINT16;
3554 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength, ptr + index);
3555 index += SIZEOF_UINT16;
3556 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber, ptr + index);
3557 index += SIZEOF_UINT16;
3558 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength, ptr + index);
3559 index += SIZEOF_UINT16;
3560 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier, ptr + index);
3561 index += SIZEOF_UINT16;
3562 break;
3563#endif
3564#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3565 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
3566 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
3567 index += SIZEOF_UINT16;
3568 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
3569 index += SIZEOF_UINT16;
3570 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
3571 index += SIZEOF_UINT16;
3572 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
3573 index += SIZEOF_UINT16;
3574 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
3575 index += SIZEOF_UINT16;
3576 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.ResultCode, ptr + index);
3577 index += SIZEOF_UINT16;
3578 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.TriggeredId, ptr + index);
3579 index += SIZEOF_UINT16;
3580 break;
3581#endif
3582#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3583 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
3584 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber, ptr + index);
3585 index += SIZEOF_UINT16;
3586 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength, ptr + index);
3587 index += SIZEOF_UINT16;
3588 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber, ptr + index);
3589 index += SIZEOF_UINT16;
3590 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength, ptr + index);
3591 index += SIZEOF_UINT16;
3592 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier, ptr + index);
3593 index += SIZEOF_UINT16;
3594 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.PacketFilterMode, ptr + index);
3595 index += SIZEOF_UINT16;
3596 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress, ptr + index);
3597 index += SIZEOF_UINT32;
3598 break;
3599#endif
3600#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3601 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
3602 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
3603 index += SIZEOF_UINT16;
3604 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
3605 index += SIZEOF_UINT16;
3606 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
3607 index += SIZEOF_UINT16;
3608 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
3609 index += SIZEOF_UINT16;
3610 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
3611 index += SIZEOF_UINT16;
3612 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.TriggerId, ptr + index);
3613 index += SIZEOF_UINT16;
3614 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.ResultCode, ptr + index);
3615 index += SIZEOF_UINT16;
3616 break;
3617#endif
3618#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3619 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
3620 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber, ptr + index);
3621 index += SIZEOF_UINT16;
3622 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.DataLength, ptr + index);
3623 index += SIZEOF_UINT16;
3624 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber, ptr + index);
3625 index += SIZEOF_UINT16;
3626 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength, ptr + index);
3627 index += SIZEOF_UINT16;
3628 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier, ptr + index);
3629 index += SIZEOF_UINT16;
3630 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.ConnectionStatus, ptr + index);
3631 index += SIZEOF_UINT16;
3632 memcpy(ptr + index, sig->u.MlmeConnectStatusRequest.StaAddress.x, 48 / 8);
3633 index += 48 / 8;
3634 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationId, ptr + index);
3635 index += SIZEOF_UINT16;
3636 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation, ptr + index);
3637 index += SIZEOF_UINT16;
3638 break;
3639#endif
3640#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3641 case CSR_MLME_LEAVE_REQUEST_ID:
3642 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber, ptr + index);
3643 index += SIZEOF_UINT16;
3644 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.DataLength, ptr + index);
3645 index += SIZEOF_UINT16;
3646 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber, ptr + index);
3647 index += SIZEOF_UINT16;
3648 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.DataLength, ptr + index);
3649 index += SIZEOF_UINT16;
3650 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier, ptr + index);
3651 index += SIZEOF_UINT16;
3652 break;
3653#endif
3654#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3655 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
3656 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber, ptr + index);
3657 index += SIZEOF_UINT16;
3658 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength, ptr + index);
3659 index += SIZEOF_UINT16;
3660 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber, ptr + index);
3661 index += SIZEOF_UINT16;
3662 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength, ptr + index);
3663 index += SIZEOF_UINT16;
3664 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.QueueIndex, ptr + index);
3665 index += SIZEOF_UINT16;
3666 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Aifs, ptr + index);
3667 index += SIZEOF_UINT16;
3668 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmin, ptr + index);
3669 index += SIZEOF_UINT16;
3670 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmax, ptr + index);
3671 index += SIZEOF_UINT16;
3672 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.TxopLimit, ptr + index);
3673 index += SIZEOF_UINT16;
3674 break;
3675#endif
3676#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3677 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
3678 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
3679 index += SIZEOF_UINT16;
3680 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength, ptr + index);
3681 index += SIZEOF_UINT16;
3682 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
3683 index += SIZEOF_UINT16;
3684 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength, ptr + index);
3685 index += SIZEOF_UINT16;
3686 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
3687 index += SIZEOF_UINT16;
3688 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.UserPriority, ptr + index);
3689 index += SIZEOF_UINT16;
3690 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.ResultCode, ptr + index);
3691 index += SIZEOF_UINT16;
3692 break;
3693#endif
3694 case CSR_MLME_SET_TIM_CONFIRM_ID:
3695 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber, ptr + index);
3696 index += SIZEOF_UINT16;
3697 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength, ptr + index);
3698 index += SIZEOF_UINT16;
3699 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber, ptr + index);
3700 index += SIZEOF_UINT16;
3701 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength, ptr + index);
3702 index += SIZEOF_UINT16;
3703 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier, ptr + index);
3704 index += SIZEOF_UINT16;
3705 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.ResultCode, ptr + index);
3706 index += SIZEOF_UINT16;
3707 break;
3708#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3709 case CSR_MLME_MEASURE_INDICATION_ID:
3710 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber, ptr + index);
3711 index += SIZEOF_UINT16;
3712 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength, ptr + index);
3713 index += SIZEOF_UINT16;
3714 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber, ptr + index);
3715 index += SIZEOF_UINT16;
3716 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.DataLength, ptr + index);
3717 index += SIZEOF_UINT16;
3718 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.DialogToken, ptr + index);
3719 index += SIZEOF_UINT16;
3720 break;
3721#endif
3722#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3723 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
3724 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
3725 index += SIZEOF_UINT16;
3726 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
3727 index += SIZEOF_UINT16;
3728 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
3729 index += SIZEOF_UINT16;
3730 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
3731 index += SIZEOF_UINT16;
3732 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
3733 index += SIZEOF_UINT16;
3734 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.BlackoutId, ptr + index);
3735 index += SIZEOF_UINT16;
3736 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.ResultCode, ptr + index);
3737 index += SIZEOF_UINT16;
3738 break;
3739#endif
3740#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3741 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
3742 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
3743 index += SIZEOF_UINT16;
3744 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
3745 index += SIZEOF_UINT16;
3746 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
3747 index += SIZEOF_UINT16;
3748 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
3749 index += SIZEOF_UINT16;
3750 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
3751 index += SIZEOF_UINT16;
3752 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.ResultCode, ptr + index);
3753 index += SIZEOF_UINT16;
3754 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.TriggeredId, ptr + index);
3755 index += SIZEOF_UINT16;
3756 break;
3757#endif
3758 case CSR_DEBUG_GENERIC_INDICATION_ID:
3759 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.SlotNumber, ptr + index);
3760 index += SIZEOF_UINT16;
3761 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.DataLength, ptr + index);
3762 index += SIZEOF_UINT16;
3763 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.SlotNumber, ptr + index);
3764 index += SIZEOF_UINT16;
3765 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.DataLength, ptr + index);
3766 index += SIZEOF_UINT16;
3767 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[0], ptr + index);
3768 index += SIZEOF_UINT16;
3769 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[1], ptr + index);
3770 index += SIZEOF_UINT16;
3771 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[2], ptr + index);
3772 index += SIZEOF_UINT16;
3773 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[3], ptr + index);
3774 index += SIZEOF_UINT16;
3775 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[4], ptr + index);
3776 index += SIZEOF_UINT16;
3777 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[5], ptr + index);
3778 index += SIZEOF_UINT16;
3779 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[6], ptr + index);
3780 index += SIZEOF_UINT16;
3781 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[7], ptr + index);
3782 index += SIZEOF_UINT16;
3783 break;
3784 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
3785 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber, ptr + index);
3786 index += SIZEOF_UINT16;
3787 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.DataLength, ptr + index);
3788 index += SIZEOF_UINT16;
3789 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber, ptr + index);
3790 index += SIZEOF_UINT16;
3791 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.DataLength, ptr + index);
3792 index += SIZEOF_UINT16;
3793 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier, ptr + index);
3794 index += SIZEOF_UINT16;
3795 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.HostTag, ptr + index);
3796 index += SIZEOF_UINT32;
3797 break;
3798#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3799 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
3800 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber, ptr + index);
3801 index += SIZEOF_UINT16;
3802 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength, ptr + index);
3803 index += SIZEOF_UINT16;
3804 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber, ptr + index);
3805 index += SIZEOF_UINT16;
3806 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength, ptr + index);
3807 index += SIZEOF_UINT16;
3808 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier, ptr + index);
3809 index += SIZEOF_UINT16;
3810 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.ResultCode, ptr + index);
3811 index += SIZEOF_UINT16;
3812 break;
3813#endif
3814#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3815 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
3816 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
3817 index += SIZEOF_UINT16;
3818 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
3819 index += SIZEOF_UINT16;
3820 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
3821 index += SIZEOF_UINT16;
3822 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
3823 index += SIZEOF_UINT16;
3824 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
3825 index += SIZEOF_UINT16;
3826 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.ResultCode, ptr + index);
3827 index += SIZEOF_UINT16;
3828 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId, ptr + index);
3829 index += SIZEOF_UINT16;
3830 break;
3831#endif
3832 case CSR_MA_PACKET_REQUEST_ID:
3833 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.SlotNumber, ptr + index);
3834 index += SIZEOF_UINT16;
3835 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.DataLength, ptr + index);
3836 index += SIZEOF_UINT16;
3837 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.SlotNumber, ptr + index);
3838 index += SIZEOF_UINT16;
3839 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.DataLength, ptr + index);
3840 index += SIZEOF_UINT16;
3841 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.VirtualInterfaceIdentifier, ptr + index);
3842 index += SIZEOF_UINT16;
3843 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmitRate, ptr + index);
3844 index += SIZEOF_UINT16;
3845 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.HostTag, ptr + index);
3846 index += SIZEOF_UINT32;
3847 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Priority, ptr + index);
3848 index += SIZEOF_UINT16;
3849 memcpy(ptr + index, sig->u.MaPacketRequest.Ra.x, 48 / 8);
3850 index += 48 / 8;
3851 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmissionControl, ptr + index);
3852 index += SIZEOF_UINT16;
3853 break;
3854#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3855 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
3856 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber, ptr + index);
3857 index += SIZEOF_UINT16;
3858 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.DataLength, ptr + index);
3859 index += SIZEOF_UINT16;
3860 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber, ptr + index);
3861 index += SIZEOF_UINT16;
3862 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength, ptr + index);
3863 index += SIZEOF_UINT16;
3864 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier, ptr + index);
3865 index += SIZEOF_UINT16;
3866 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.BeaconPeriod, ptr + index);
3867 index += SIZEOF_UINT16;
3868 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.DtimPeriod, ptr + index);
3869 index += SIZEOF_UINT16;
3870 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.CapabilityInformation, ptr + index);
3871 index += SIZEOF_UINT16;
3872 memcpy(ptr + index, sig->u.MlmeModifyBssParameterRequest.Bssid.x, 48 / 8);
3873 index += 48 / 8;
3874 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.RtsThreshold, ptr + index);
3875 index += SIZEOF_UINT16;
3876 break;
3877#endif
3878#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3879 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
3880 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber, ptr + index);
3881 index += SIZEOF_UINT16;
3882 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength, ptr + index);
3883 index += SIZEOF_UINT16;
3884 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
3885 index += SIZEOF_UINT16;
3886 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
3887 index += SIZEOF_UINT16;
3888 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
3889 index += SIZEOF_UINT16;
3890 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.TriggerId, ptr + index);
3891 index += SIZEOF_UINT16;
3892 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Priority, ptr + index);
3893 index += SIZEOF_UINT16;
3894 break;
3895#endif
3896 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
3897 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber, ptr + index);
3898 index += SIZEOF_UINT16;
3899 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength, ptr + index);
3900 index += SIZEOF_UINT16;
3901 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber, ptr + index);
3902 index += SIZEOF_UINT16;
3903 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength, ptr + index);
3904 index += SIZEOF_UINT16;
3905 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier, ptr + index);
3906 index += SIZEOF_UINT16;
3907 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Multicast, ptr + index);
3908 index += SIZEOF_UINT16;
3909 break;
3910#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3911 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
3912 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber, ptr + index);
3913 index += SIZEOF_UINT16;
3914 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength, ptr + index);
3915 index += SIZEOF_UINT16;
3916 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber, ptr + index);
3917 index += SIZEOF_UINT16;
3918 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength, ptr + index);
3919 index += SIZEOF_UINT16;
3920 memcpy(ptr + index, sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, 48 / 8);
3921 index += 48 / 8;
3922 break;
3923#endif
3924#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3925 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
3926 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
3927 index += SIZEOF_UINT16;
3928 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
3929 index += SIZEOF_UINT16;
3930 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
3931 index += SIZEOF_UINT16;
3932 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
3933 index += SIZEOF_UINT16;
3934 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
3935 index += SIZEOF_UINT16;
3936 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId, ptr + index);
3937 index += SIZEOF_UINT16;
3938 break;
3939#endif
3940#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3941 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
3942 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber, ptr + index);
3943 index += SIZEOF_UINT16;
3944 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength, ptr + index);
3945 index += SIZEOF_UINT16;
3946 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber, ptr + index);
3947 index += SIZEOF_UINT16;
3948 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength, ptr + index);
3949 index += SIZEOF_UINT16;
3950 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier, ptr + index);
3951 index += SIZEOF_UINT16;
3952 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.BlackoutId, ptr + index);
3953 index += SIZEOF_UINT16;
3954 break;
3955#endif
3956#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3957 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
3958 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber, ptr + index);
3959 index += SIZEOF_UINT16;
3960 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength, ptr + index);
3961 index += SIZEOF_UINT16;
3962 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber, ptr + index);
3963 index += SIZEOF_UINT16;
3964 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength, ptr + index);
3965 index += SIZEOF_UINT16;
3966 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier, ptr + index);
3967 index += SIZEOF_UINT16;
3968 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.ResultCode, ptr + index);
3969 index += SIZEOF_UINT16;
3970 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId, ptr + index);
3971 index += SIZEOF_UINT16;
3972 break;
3973#endif
3974#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3975 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
3976 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber, ptr + index);
3977 index += SIZEOF_UINT16;
3978 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength, ptr + index);
3979 index += SIZEOF_UINT16;
3980 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber, ptr + index);
3981 index += SIZEOF_UINT16;
3982 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength, ptr + index);
3983 index += SIZEOF_UINT16;
3984 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier, ptr + index);
3985 index += SIZEOF_UINT16;
3986 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyId, ptr + index);
3987 index += SIZEOF_UINT16;
3988 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyType, ptr + index);
3989 index += SIZEOF_UINT16;
3990 memcpy(ptr + index, sig->u.MlmeGetKeySequenceRequest.Address.x, 48 / 8);
3991 index += 48 / 8;
3992 break;
3993#endif
3994#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3995 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
3996 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber, ptr + index);
3997 index += SIZEOF_UINT16;
3998 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength, ptr + index);
3999 index += SIZEOF_UINT16;
4000 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber, ptr + index);
4001 index += SIZEOF_UINT16;
4002 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength, ptr + index);
4003 index += SIZEOF_UINT16;
4004 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier, ptr + index);
4005 index += SIZEOF_UINT16;
4006 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Ifindex, ptr + index);
4007 index += SIZEOF_UINT16;
4008 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Channel, ptr + index);
4009 index += SIZEOF_UINT16;
4010 memcpy(ptr + index, sig->u.MlmeSetChannelRequest.Address.x, 48 / 8);
4011 index += 48 / 8;
4012 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityDuration, ptr + index);
4013 index += SIZEOF_UINT16;
4014 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityInterval, ptr + index);
4015 index += SIZEOF_UINT16;
4016 break;
4017#endif
4018#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4019 case CSR_MLME_MEASURE_CONFIRM_ID:
4020 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
4021 index += SIZEOF_UINT16;
4022 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength, ptr + index);
4023 index += SIZEOF_UINT16;
4024 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
4025 index += SIZEOF_UINT16;
4026 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength, ptr + index);
4027 index += SIZEOF_UINT16;
4028 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.ResultCode, ptr + index);
4029 index += SIZEOF_UINT16;
4030 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.DialogToken, ptr + index);
4031 index += SIZEOF_UINT16;
4032 break;
4033#endif
4034#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4035 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
4036 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber, ptr + index);
4037 index += SIZEOF_UINT16;
4038 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength, ptr + index);
4039 index += SIZEOF_UINT16;
4040 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
4041 index += SIZEOF_UINT16;
4042 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
4043 index += SIZEOF_UINT16;
4044 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
4045 index += SIZEOF_UINT16;
4046 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.TriggeredId, ptr + index);
4047 index += SIZEOF_UINT16;
4048 break;
4049#endif
4050#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4051 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
4052 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber, ptr + index);
4053 index += SIZEOF_UINT16;
4054 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength, ptr + index);
4055 index += SIZEOF_UINT16;
4056 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber, ptr + index);
4057 index += SIZEOF_UINT16;
4058 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength, ptr + index);
4059 index += SIZEOF_UINT16;
4060 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier, ptr + index);
4061 index += SIZEOF_UINT16;
4062 memcpy(ptr + index, sig->u.MlmeAutonomousScanLossIndication.Bssid.x, 48 / 8);
4063 index += 48 / 8;
4064 break;
4065#endif
4066 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
4067 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber, ptr + index);
4068 index += SIZEOF_UINT16;
4069 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength, ptr + index);
4070 index += SIZEOF_UINT16;
4071 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber, ptr + index);
4072 index += SIZEOF_UINT16;
4073 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength, ptr + index);
4074 index += SIZEOF_UINT16;
4075 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier, ptr + index);
4076 index += SIZEOF_UINT16;
4077 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.ResultCode, ptr + index);
4078 index += SIZEOF_UINT16;
4079 break;
4080#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4081 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
4082 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.SlotNumber, ptr + index);
4083 index += SIZEOF_UINT16;
4084 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.DataLength, ptr + index);
4085 index += SIZEOF_UINT16;
4086 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.SlotNumber, ptr + index);
4087 index += SIZEOF_UINT16;
4088 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.DataLength, ptr + index);
4089 index += SIZEOF_UINT16;
4090 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier, ptr + index);
4091 index += SIZEOF_UINT16;
4092 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.FrameType, ptr + index);
4093 index += SIZEOF_UINT16;
4094 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.MinTransmitRate, ptr + index);
4095 index += SIZEOF_UINT16;
4096 break;
4097#endif
4098#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4099 case CSR_MLME_POWERMGT_CONFIRM_ID:
4100 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber, ptr + index);
4101 index += SIZEOF_UINT16;
4102 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength, ptr + index);
4103 index += SIZEOF_UINT16;
4104 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber, ptr + index);
4105 index += SIZEOF_UINT16;
4106 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength, ptr + index);
4107 index += SIZEOF_UINT16;
4108 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier, ptr + index);
4109 index += SIZEOF_UINT16;
4110 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.ResultCode, ptr + index);
4111 index += SIZEOF_UINT16;
4112 break;
4113#endif
4114#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4115 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
4116 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
4117 index += SIZEOF_UINT16;
4118 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
4119 index += SIZEOF_UINT16;
4120 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
4121 index += SIZEOF_UINT16;
4122 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
4123 index += SIZEOF_UINT16;
4124 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
4125 index += SIZEOF_UINT16;
4126 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.PeriodicId, ptr + index);
4127 index += SIZEOF_UINT16;
4128 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.ResultCode, ptr + index);
4129 index += SIZEOF_UINT16;
4130 break;
4131#endif
4132#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4133 case CSR_MLME_GET_CONFIRM_ID:
4134 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber, ptr + index);
4135 index += SIZEOF_UINT16;
4136 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.DataLength, ptr + index);
4137 index += SIZEOF_UINT16;
4138 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber, ptr + index);
4139 index += SIZEOF_UINT16;
4140 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.DataLength, ptr + index);
4141 index += SIZEOF_UINT16;
4142 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Status, ptr + index);
4143 index += SIZEOF_UINT16;
4144 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.ErrorIndex, ptr + index);
4145 index += SIZEOF_UINT16;
4146 break;
4147#endif
4148#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4149 case CSR_MLME_GET_NEXT_CONFIRM_ID:
4150 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber, ptr + index);
4151 index += SIZEOF_UINT16;
4152 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength, ptr + index);
4153 index += SIZEOF_UINT16;
4154 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber, ptr + index);
4155 index += SIZEOF_UINT16;
4156 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength, ptr + index);
4157 index += SIZEOF_UINT16;
4158 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Status, ptr + index);
4159 index += SIZEOF_UINT16;
4160 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.ErrorIndex, ptr + index);
4161 index += SIZEOF_UINT16;
4162 break;
4163#endif
4164#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4165 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
4166 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
4167 index += SIZEOF_UINT16;
4168 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength, ptr + index);
4169 index += SIZEOF_UINT16;
4170 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
4171 index += SIZEOF_UINT16;
4172 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength, ptr + index);
4173 index += SIZEOF_UINT16;
4174 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
4175 index += SIZEOF_UINT16;
4176 memcpy(ptr + index, sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, 48 / 8);
4177 index += 48 / 8;
4178 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.UserPriority, ptr + index);
4179 index += SIZEOF_UINT16;
4180 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Direction, ptr + index);
4181 index += SIZEOF_UINT16;
4182 break;
4183#endif
4184#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4185 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
4186 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
4187 index += SIZEOF_UINT16;
4188 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
4189 index += SIZEOF_UINT16;
4190 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
4191 index += SIZEOF_UINT16;
4192 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
4193 index += SIZEOF_UINT16;
4194 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
4195 index += SIZEOF_UINT16;
4196 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.TriggerId, ptr + index);
4197 index += SIZEOF_UINT16;
4198 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.ResultCode, ptr + index);
4199 index += SIZEOF_UINT16;
4200 break;
4201#endif
4202#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4203 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
4204 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
4205 index += SIZEOF_UINT16;
4206 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength, ptr + index);
4207 index += SIZEOF_UINT16;
4208 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
4209 index += SIZEOF_UINT16;
4210 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength, ptr + index);
4211 index += SIZEOF_UINT16;
4212 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
4213 index += SIZEOF_UINT16;
4214 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutId, ptr + index);
4215 index += SIZEOF_UINT16;
4216 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutType, ptr + index);
4217 index += SIZEOF_UINT16;
4218 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutSource, ptr + index);
4219 index += SIZEOF_UINT16;
4220 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutStartReference, ptr + index);
4221 index += SIZEOF_UINT32;
4222 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutPeriod, ptr + index);
4223 index += SIZEOF_UINT32;
4224 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutDuration, ptr + index);
4225 index += SIZEOF_UINT32;
4226 memcpy(ptr + index, sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, 48 / 8);
4227 index += 48 / 8;
4228 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutCount, ptr + index);
4229 index += SIZEOF_UINT16;
4230 break;
4231#endif
4232#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4233 case CSR_MLME_DELETEKEYS_REQUEST_ID:
4234 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber, ptr + index);
4235 index += SIZEOF_UINT16;
4236 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength, ptr + index);
4237 index += SIZEOF_UINT16;
4238 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber, ptr + index);
4239 index += SIZEOF_UINT16;
4240 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength, ptr + index);
4241 index += SIZEOF_UINT16;
4242 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier, ptr + index);
4243 index += SIZEOF_UINT16;
4244 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyId, ptr + index);
4245 index += SIZEOF_UINT16;
4246 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyType, ptr + index);
4247 index += SIZEOF_UINT16;
4248 memcpy(ptr + index, sig->u.MlmeDeletekeysRequest.Address.x, 48 / 8);
4249 index += 48 / 8;
4250 break;
4251#endif
4252#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4253 case CSR_MLME_RESET_CONFIRM_ID:
4254 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber, ptr + index);
4255 index += SIZEOF_UINT16;
4256 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.DataLength, ptr + index);
4257 index += SIZEOF_UINT16;
4258 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber, ptr + index);
4259 index += SIZEOF_UINT16;
4260 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.DataLength, ptr + index);
4261 index += SIZEOF_UINT16;
4262 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.ResultCode, ptr + index);
4263 index += SIZEOF_UINT16;
4264 break;
4265#endif
4266#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4267 case CSR_MLME_HL_SYNC_CONFIRM_ID:
4268 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber, ptr + index);
4269 index += SIZEOF_UINT16;
4270 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength, ptr + index);
4271 index += SIZEOF_UINT16;
4272 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber, ptr + index);
4273 index += SIZEOF_UINT16;
4274 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength, ptr + index);
4275 index += SIZEOF_UINT16;
4276 memcpy(ptr + index, sig->u.MlmeHlSyncConfirm.GroupAddress.x, 48 / 8);
4277 index += 48 / 8;
4278 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.ResultCode, ptr + index);
4279 index += SIZEOF_UINT16;
4280 break;
4281#endif
4282#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4283 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
4284 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber, ptr + index);
4285 index += SIZEOF_UINT16;
4286 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength, ptr + index);
4287 index += SIZEOF_UINT16;
4288 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber, ptr + index);
4289 index += SIZEOF_UINT16;
4290 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength, ptr + index);
4291 index += SIZEOF_UINT16;
4292 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
4293 index += SIZEOF_UINT16;
4294 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId, ptr + index);
4295 index += SIZEOF_UINT16;
4296 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.Ifindex, ptr + index);
4297 index += SIZEOF_UINT16;
4298 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor, ptr + index);
4299 index += SIZEOF_UINT16;
4300 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ScanType, ptr + index);
4301 index += SIZEOF_UINT16;
4302 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ProbeDelay, ptr + index);
4303 index += SIZEOF_UINT32;
4304 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MinChannelTime, ptr + index);
4305 index += SIZEOF_UINT16;
4306 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime, ptr + index);
4307 index += SIZEOF_UINT16;
4308 break;
4309#endif
4310#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4311 case CSR_MLME_SET_REQUEST_ID:
4312 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber, ptr + index);
4313 index += SIZEOF_UINT16;
4314 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.DataLength, ptr + index);
4315 index += SIZEOF_UINT16;
4316 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.SlotNumber, ptr + index);
4317 index += SIZEOF_UINT16;
4318 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.DataLength, ptr + index);
4319 index += SIZEOF_UINT16;
4320 break;
4321#endif
4322#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4323 case CSR_MLME_SM_START_REQUEST_ID:
4324 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.SlotNumber, ptr + index);
4325 index += SIZEOF_UINT16;
4326 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.DataLength, ptr + index);
4327 index += SIZEOF_UINT16;
4328 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.SlotNumber, ptr + index);
4329 index += SIZEOF_UINT16;
4330 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.DataLength, ptr + index);
4331 index += SIZEOF_UINT16;
4332 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier, ptr + index);
4333 index += SIZEOF_UINT16;
4334 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Ifindex, ptr + index);
4335 index += SIZEOF_UINT16;
4336 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Channel, ptr + index);
4337 index += SIZEOF_UINT16;
4338 memcpy(ptr + index, sig->u.MlmeSmStartRequest.InterfaceAddress.x, 48 / 8);
4339 index += 48 / 8;
4340 memcpy(ptr + index, sig->u.MlmeSmStartRequest.Bssid.x, 48 / 8);
4341 index += 48 / 8;
4342 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BeaconPeriod, ptr + index);
4343 index += SIZEOF_UINT16;
4344 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.DtimPeriod, ptr + index);
4345 index += SIZEOF_UINT16;
4346 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.CapabilityInformation, ptr + index);
4347 index += SIZEOF_UINT16;
4348 break;
4349#endif
4350#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4351 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
4352 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber, ptr + index);
4353 index += SIZEOF_UINT16;
4354 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength, ptr + index);
4355 index += SIZEOF_UINT16;
4356 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber, ptr + index);
4357 index += SIZEOF_UINT16;
4358 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength, ptr + index);
4359 index += SIZEOF_UINT16;
4360 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier, ptr + index);
4361 index += SIZEOF_UINT16;
4362 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.ResultCode, ptr + index);
4363 index += SIZEOF_UINT16;
4364 break;
4365#endif
4366#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4367 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
4368 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
4369 index += SIZEOF_UINT16;
4370 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
4371 index += SIZEOF_UINT16;
4372 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
4373 index += SIZEOF_UINT16;
4374 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
4375 index += SIZEOF_UINT16;
4376 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
4377 index += SIZEOF_UINT16;
4378 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.ResultCode, ptr + index);
4379 index += SIZEOF_UINT16;
4380 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId, ptr + index);
4381 index += SIZEOF_UINT16;
4382 break;
4383#endif
4384#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4385 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
4386 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber, ptr + index);
4387 index += SIZEOF_UINT16;
4388 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength, ptr + index);
4389 index += SIZEOF_UINT16;
4390 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber, ptr + index);
4391 index += SIZEOF_UINT16;
4392 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength, ptr + index);
4393 index += SIZEOF_UINT16;
4394 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier, ptr + index);
4395 index += SIZEOF_UINT16;
4396 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.PeriodicId, ptr + index);
4397 index += SIZEOF_UINT16;
4398 break;
4399#endif
4400#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4401 case CSR_MLME_SETKEYS_REQUEST_ID:
4402 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.SlotNumber, ptr + index);
4403 index += SIZEOF_UINT16;
4404 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.DataLength, ptr + index);
4405 index += SIZEOF_UINT16;
4406 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber, ptr + index);
4407 index += SIZEOF_UINT16;
4408 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength, ptr + index);
4409 index += SIZEOF_UINT16;
4410 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier, ptr + index);
4411 index += SIZEOF_UINT16;
4412 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Length, ptr + index);
4413 index += SIZEOF_UINT16;
4414 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyId, ptr + index);
4415 index += SIZEOF_UINT16;
4416 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyType, ptr + index);
4417 index += SIZEOF_UINT16;
4418 memcpy(ptr + index, sig->u.MlmeSetkeysRequest.Address.x, 48 / 8);
4419 index += 48 / 8;
4420 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[0], ptr + index);
4421 index += SIZEOF_UINT16;
4422 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[1], ptr + index);
4423 index += SIZEOF_UINT16;
4424 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[2], ptr + index);
4425 index += SIZEOF_UINT16;
4426 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[3], ptr + index);
4427 index += SIZEOF_UINT16;
4428 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[4], ptr + index);
4429 index += SIZEOF_UINT16;
4430 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[5], ptr + index);
4431 index += SIZEOF_UINT16;
4432 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[6], ptr + index);
4433 index += SIZEOF_UINT16;
4434 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[7], ptr + index);
4435 index += SIZEOF_UINT16;
4436 memcpy(ptr + index, &sig->u.MlmeSetkeysRequest.CipherSuiteSelector, 32 / 8);
4437 index += 32 / 8;
4438 break;
4439#endif
4440#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4441 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
4442 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
4443 index += SIZEOF_UINT16;
4444 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
4445 index += SIZEOF_UINT16;
4446 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
4447 index += SIZEOF_UINT16;
4448 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
4449 index += SIZEOF_UINT16;
4450 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
4451 index += SIZEOF_UINT16;
4452 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId, ptr + index);
4453 index += SIZEOF_UINT16;
4454 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Pause, ptr + index);
4455 index += SIZEOF_UINT16;
4456 break;
4457#endif
4458#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4459 case CSR_MLME_GET_REQUEST_ID:
4460 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.SlotNumber, ptr + index);
4461 index += SIZEOF_UINT16;
4462 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.DataLength, ptr + index);
4463 index += SIZEOF_UINT16;
4464 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.SlotNumber, ptr + index);
4465 index += SIZEOF_UINT16;
4466 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.DataLength, ptr + index);
4467 index += SIZEOF_UINT16;
4468 break;
4469#endif
4470#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4471 case CSR_MLME_POWERMGT_REQUEST_ID:
4472 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber, ptr + index);
4473 index += SIZEOF_UINT16;
4474 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.DataLength, ptr + index);
4475 index += SIZEOF_UINT16;
4476 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber, ptr + index);
4477 index += SIZEOF_UINT16;
4478 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.DataLength, ptr + index);
4479 index += SIZEOF_UINT16;
4480 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier, ptr + index);
4481 index += SIZEOF_UINT16;
4482 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.PowerManagementMode, ptr + index);
4483 index += SIZEOF_UINT16;
4484 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ReceiveDtims, ptr + index);
4485 index += SIZEOF_UINT16;
4486 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ListenInterval, ptr + index);
4487 index += SIZEOF_UINT16;
4488 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.TrafficWindow, ptr + index);
4489 index += SIZEOF_UINT16;
4490 break;
4491#endif
4492 case CSR_MA_PACKET_ERROR_INDICATION_ID:
4493 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber, ptr + index);
4494 index += SIZEOF_UINT16;
4495 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.DataLength, ptr + index);
4496 index += SIZEOF_UINT16;
4497 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber, ptr + index);
4498 index += SIZEOF_UINT16;
4499 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.DataLength, ptr + index);
4500 index += SIZEOF_UINT16;
4501 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier, ptr + index);
4502 index += SIZEOF_UINT16;
4503 memcpy(ptr + index, sig->u.MaPacketErrorIndication.PeerQstaAddress.x, 48 / 8);
4504 index += 48 / 8;
4505 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.UserPriority, ptr + index);
4506 index += SIZEOF_UINT16;
4507 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.SequenceNumber, ptr + index);
4508 index += SIZEOF_UINT16;
4509 break;
4510#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4511 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
4512 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber, ptr + index);
4513 index += SIZEOF_UINT16;
4514 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength, ptr + index);
4515 index += SIZEOF_UINT16;
4516 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber, ptr + index);
4517 index += SIZEOF_UINT16;
4518 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength, ptr + index);
4519 index += SIZEOF_UINT16;
4520 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier, ptr + index);
4521 index += SIZEOF_UINT16;
4522 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicId, ptr + index);
4523 index += SIZEOF_UINT16;
4524 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.MaximumLatency, ptr + index);
4525 index += SIZEOF_UINT32;
4526 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode, ptr + index);
4527 index += SIZEOF_UINT16;
4528 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.WakeHost, ptr + index);
4529 index += SIZEOF_UINT16;
4530 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.UserPriority, ptr + index);
4531 index += SIZEOF_UINT16;
4532 break;
4533#endif
4534#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4535 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
4536 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber, ptr + index);
4537 index += SIZEOF_UINT16;
4538 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength, ptr + index);
4539 index += SIZEOF_UINT16;
4540 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber, ptr + index);
4541 index += SIZEOF_UINT16;
4542 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength, ptr + index);
4543 index += SIZEOF_UINT16;
4544 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier, ptr + index);
4545 index += SIZEOF_UINT16;
4546 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.UserPriority, ptr + index);
4547 index += SIZEOF_UINT16;
4548 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Direction, ptr + index);
4549 index += SIZEOF_UINT16;
4550 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.PsScheme, ptr + index);
4551 index += SIZEOF_UINT16;
4552 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MediumTime, ptr + index);
4553 index += SIZEOF_UINT16;
4554 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceStartTime, ptr + index);
4555 index += SIZEOF_UINT32;
4556 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceInterval, ptr + index);
4557 index += SIZEOF_UINT32;
4558 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MinimumDataRate, ptr + index);
4559 index += SIZEOF_UINT16;
4560 break;
4561#endif
4562#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4563 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
4564 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber, ptr + index);
4565 index += SIZEOF_UINT16;
4566 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength, ptr + index);
4567 index += SIZEOF_UINT16;
4568 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber, ptr + index);
4569 index += SIZEOF_UINT16;
4570 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength, ptr + index);
4571 index += SIZEOF_UINT16;
4572 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier, ptr + index);
4573 index += SIZEOF_UINT16;
4574 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.ResultCode, ptr + index);
4575 index += SIZEOF_UINT16;
4576 break;
4577#endif
4578#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4579 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
4580 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
4581 index += SIZEOF_UINT16;
4582 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength, ptr + index);
4583 index += SIZEOF_UINT16;
4584 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
4585 index += SIZEOF_UINT16;
4586 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength, ptr + index);
4587 index += SIZEOF_UINT16;
4588 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
4589 index += SIZEOF_UINT16;
4590 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.UserPriority, ptr + index);
4591 index += SIZEOF_UINT16;
4592 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.ResultCode, ptr + index);
4593 index += SIZEOF_UINT16;
4594 break;
4595#endif
4596#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4597 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
4598 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber, ptr + index);
4599 index += SIZEOF_UINT16;
4600 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength, ptr + index);
4601 index += SIZEOF_UINT16;
4602 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber, ptr + index);
4603 index += SIZEOF_UINT16;
4604 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength, ptr + index);
4605 index += SIZEOF_UINT16;
4606 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.ResultCode, ptr + index);
4607 index += SIZEOF_UINT16;
4608 break;
4609#endif
4610#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4611 case CSR_MLME_SCAN_CONFIRM_ID:
4612 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber, ptr + index);
4613 index += SIZEOF_UINT16;
4614 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.DataLength, ptr + index);
4615 index += SIZEOF_UINT16;
4616 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber, ptr + index);
4617 index += SIZEOF_UINT16;
4618 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.DataLength, ptr + index);
4619 index += SIZEOF_UINT16;
4620 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier, ptr + index);
4621 index += SIZEOF_UINT16;
4622 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.ResultCode, ptr + index);
4623 index += SIZEOF_UINT16;
4624 break;
4625#endif
4626 case CSR_DEBUG_STRING_INDICATION_ID:
4627 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.SlotNumber, ptr + index);
4628 index += SIZEOF_UINT16;
4629 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.DataLength, ptr + index);
4630 index += SIZEOF_UINT16;
4631 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.SlotNumber, ptr + index);
4632 index += SIZEOF_UINT16;
4633 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.DataLength, ptr + index);
4634 index += SIZEOF_UINT16;
4635 break;
4636#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4637 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
4638 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber, ptr + index);
4639 index += SIZEOF_UINT16;
4640 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength, ptr + index);
4641 index += SIZEOF_UINT16;
4642 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber, ptr + index);
4643 index += SIZEOF_UINT16;
4644 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength, ptr + index);
4645 index += SIZEOF_UINT16;
4646 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier, ptr + index);
4647 index += SIZEOF_UINT16;
4648 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.FrameType, ptr + index);
4649 index += SIZEOF_UINT16;
4650 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.ResultCode, ptr + index);
4651 index += SIZEOF_UINT16;
4652 break;
4653#endif
4654#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4655 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
4656 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber, ptr + index);
4657 index += SIZEOF_UINT16;
4658 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength, ptr + index);
4659 index += SIZEOF_UINT16;
4660 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber, ptr + index);
4661 index += SIZEOF_UINT16;
4662 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength, ptr + index);
4663 index += SIZEOF_UINT16;
4664 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier, ptr + index);
4665 index += SIZEOF_UINT16;
4666 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.ResultCode, ptr + index);
4667 index += SIZEOF_UINT16;
4668 memcpy(ptr + index, sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, 48 / 8);
4669 index += 48 / 8;
4670 break;
4671#endif
4672#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4673 case CSR_MLME_SET_CONFIRM_ID:
4674 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber, ptr + index);
4675 index += SIZEOF_UINT16;
4676 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.DataLength, ptr + index);
4677 index += SIZEOF_UINT16;
4678 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber, ptr + index);
4679 index += SIZEOF_UINT16;
4680 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.DataLength, ptr + index);
4681 index += SIZEOF_UINT16;
4682 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Status, ptr + index);
4683 index += SIZEOF_UINT16;
4684 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.ErrorIndex, ptr + index);
4685 index += SIZEOF_UINT16;
4686 break;
4687#endif
4688#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4689 case CSR_MLME_MEASURE_REQUEST_ID:
4690 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber, ptr + index);
4691 index += SIZEOF_UINT16;
4692 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength, ptr + index);
4693 index += SIZEOF_UINT16;
4694 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber, ptr + index);
4695 index += SIZEOF_UINT16;
4696 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.DataLength, ptr + index);
4697 index += SIZEOF_UINT16;
4698 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.DialogToken, ptr + index);
4699 index += SIZEOF_UINT16;
4700 break;
4701#endif
4702#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4703 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
4704 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
4705 index += SIZEOF_UINT16;
4706 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength, ptr + index);
4707 index += SIZEOF_UINT16;
4708 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
4709 index += SIZEOF_UINT16;
4710 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength, ptr + index);
4711 index += SIZEOF_UINT16;
4712 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
4713 index += SIZEOF_UINT16;
4714 memcpy(ptr + index, sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, 48 / 8);
4715 index += 48 / 8;
4716 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.UserPriority, ptr + index);
4717 index += SIZEOF_UINT16;
4718 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Direction, ptr + index);
4719 index += SIZEOF_UINT16;
4720 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.ResultCode, ptr + index);
4721 index += SIZEOF_UINT16;
4722 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.SequenceNumber, ptr + index);
4723 index += SIZEOF_UINT16;
4724 break;
4725#endif
4726#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4727 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
4728 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
4729 index += SIZEOF_UINT16;
4730 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength, ptr + index);
4731 index += SIZEOF_UINT16;
4732 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
4733 index += SIZEOF_UINT16;
4734 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength, ptr + index);
4735 index += SIZEOF_UINT16;
4736 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.ResultCode, ptr + index);
4737 index += SIZEOF_UINT16;
4738 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.DialogToken, ptr + index);
4739 index += SIZEOF_UINT16;
4740 break;
4741#endif
4742 case CSR_MA_PACKET_CONFIRM_ID:
4743 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.SlotNumber, ptr + index);
4744 index += SIZEOF_UINT16;
4745 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.DataLength, ptr + index);
4746 index += SIZEOF_UINT16;
4747 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.SlotNumber, ptr + index);
4748 index += SIZEOF_UINT16;
4749 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.DataLength, ptr + index);
4750 index += SIZEOF_UINT16;
4751 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.VirtualInterfaceIdentifier, ptr + index);
4752 index += SIZEOF_UINT16;
4753 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.TransmissionStatus, ptr + index);
4754 index += SIZEOF_UINT16;
4755 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.RetryCount, ptr + index);
4756 index += SIZEOF_UINT16;
4757 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Rate, ptr + index);
4758 index += SIZEOF_UINT16;
4759 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.HostTag, ptr + index);
4760 index += SIZEOF_UINT32;
4761 break;
4762#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4763 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
4764 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
4765 index += SIZEOF_UINT16;
4766 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
4767 index += SIZEOF_UINT16;
4768 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
4769 index += SIZEOF_UINT16;
4770 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
4771 index += SIZEOF_UINT16;
4772 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
4773 index += SIZEOF_UINT16;
4774 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.PeriodicId, ptr + index);
4775 index += SIZEOF_UINT16;
4776 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.ResultCode, ptr + index);
4777 index += SIZEOF_UINT16;
4778 break;
4779#endif
4780#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4781 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
4782 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber, ptr + index);
4783 index += SIZEOF_UINT16;
4784 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength, ptr + index);
4785 index += SIZEOF_UINT16;
4786 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber, ptr + index);
4787 index += SIZEOF_UINT16;
4788 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength, ptr + index);
4789 index += SIZEOF_UINT16;
4790 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.DialogToken, ptr + index);
4791 index += SIZEOF_UINT16;
4792 break;
4793#endif
4794
4795 default:
4796 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
4797 }
4798
4799 *sig_len = index;
4800
4801 return CSR_RESULT_SUCCESS;
4802} /* write_pack() */
4803
4804
diff --git a/drivers/staging/csr/csr_wifi_hip_send.c b/drivers/staging/csr/csr_wifi_hip_send.c
deleted file mode 100644
index 76429e5e77cf..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_send.c
+++ /dev/null
@@ -1,415 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ***************************************************************************
13 *
14 * FILE: csr_wifi_hip_send.c
15 *
16 * PURPOSE:
17 * Code for adding a signal request to the from-host queue.
18 * When the driver bottom-half is run, it will take requests from the
19 * queue and pass them to the UniFi.
20 *
21 * ***************************************************************************
22 */
23#include "csr_wifi_hip_unifi.h"
24#include "csr_wifi_hip_conversions.h"
25#include "csr_wifi_hip_sigs.h"
26#include "csr_wifi_hip_card.h"
27
28unifi_TrafficQueue unifi_frame_priority_to_queue(CSR_PRIORITY priority)
29{
30 switch (priority)
31 {
32 case CSR_QOS_UP0:
33 case CSR_QOS_UP3:
34 return UNIFI_TRAFFIC_Q_BE;
35 case CSR_QOS_UP1:
36 case CSR_QOS_UP2:
37 return UNIFI_TRAFFIC_Q_BK;
38 case CSR_QOS_UP4:
39 case CSR_QOS_UP5:
40 return UNIFI_TRAFFIC_Q_VI;
41 case CSR_QOS_UP6:
42 case CSR_QOS_UP7:
43 case CSR_MANAGEMENT:
44 return UNIFI_TRAFFIC_Q_VO;
45 default:
46 return UNIFI_TRAFFIC_Q_BE;
47 }
48}
49
50
51CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue)
52{
53 switch (queue)
54 {
55 case UNIFI_TRAFFIC_Q_BE:
56 return CSR_QOS_UP0;
57 case UNIFI_TRAFFIC_Q_BK:
58 return CSR_QOS_UP1;
59 case UNIFI_TRAFFIC_Q_VI:
60 return CSR_QOS_UP5;
61 case UNIFI_TRAFFIC_Q_VO:
62 return CSR_QOS_UP6;
63 default:
64 return CSR_QOS_UP0;
65 }
66}
67
68
69/*
70 * ---------------------------------------------------------------------------
71 * send_signal
72 *
73 * This function queues a signal for sending to UniFi. It first checks
74 * that there is space on the fh_signal_queue for another entry, then
75 * claims any bulk data slots required and copies data into them. Then
76 * increments the fh_signal_queue write count.
77 *
78 * The fh_signal_queue is later processed by the driver bottom half
79 * (in unifi_bh()).
80 *
81 * This function call unifi_pause_xmit() to pause the flow of data plane
82 * packets when:
83 * - the fh_signal_queue ring buffer is full
84 * - there are less than UNIFI_MAX_DATA_REFERENCES (2) bulk data
85 * slots available.
86 *
87 * Arguments:
88 * card Pointer to card context structure
89 * sigptr Pointer to the signal to write to UniFi.
90 * siglen Number of bytes pointer to by sigptr.
91 * bulkdata Array of pointers to an associated bulk data.
92 * sigq To which from-host queue to add the signal.
93 *
94 * Returns:
95 * CSR_RESULT_SUCCESS on success
96 * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or
97 * no free signal queue entry
98 *
99 * Notes:
100 * Calls unifi_pause_xmit() when the last slots are used.
101 * ---------------------------------------------------------------------------
102 */
103static CsrResult send_signal(card_t *card, const u8 *sigptr, u32 siglen,
104 const bulk_data_param_t *bulkdata,
105 q_t *sigq, u32 priority_q, u32 run_bh)
106{
107 u16 i, data_slot_size;
108 card_signal_t *csptr;
109 s16 qe;
110 CsrResult r;
111 s16 debug_print = 0;
112
113 data_slot_size = CardGetDataSlotSize(card);
114
115 /* Check that the fh_data_queue has a free slot */
116 if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sigq))
117 {
118 unifi_trace(card->ospriv, UDBG3, "send_signal: %s full\n", sigq->name);
119
120 return CSR_WIFI_HIP_RESULT_NO_SPACE;
121 }
122
123 /*
124 * Now add the signal to the From Host signal queue
125 */
126 /* Get next slot on queue */
127 qe = CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
128 csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, qe);
129
130 /* Make up the card_signal struct */
131 csptr->signal_length = (u16)siglen;
132 memcpy((void *)csptr->sigbuf, (void *)sigptr, siglen);
133
134 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
135 {
136 if ((bulkdata != NULL) && (bulkdata->d[i].data_length != 0))
137 {
138 u32 datalen = bulkdata->d[i].data_length;
139
140 /* Make sure data will fit in a bulk data slot */
141 if (bulkdata->d[i].os_data_ptr == NULL)
142 {
143 unifi_error(card->ospriv, "send_signal - NULL bulkdata[%d]\n", i);
144 debug_print++;
145 csptr->bulkdata[i].data_length = 0;
146 }
147 else
148 {
149 if (datalen > data_slot_size)
150 {
151 unifi_error(card->ospriv,
152 "send_signal - Invalid data length %u (@%p), "
153 "truncating\n",
154 datalen, bulkdata->d[i].os_data_ptr);
155 datalen = data_slot_size;
156 debug_print++;
157 }
158 /* Store the bulk data info in the soft queue. */
159 csptr->bulkdata[i].os_data_ptr = (u8 *)bulkdata->d[i].os_data_ptr;
160 csptr->bulkdata[i].os_net_buf_ptr = (u8 *)bulkdata->d[i].os_net_buf_ptr;
161 csptr->bulkdata[i].net_buf_length = bulkdata->d[i].net_buf_length;
162 csptr->bulkdata[i].data_length = datalen;
163 }
164 }
165 else
166 {
167 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
168 }
169 }
170
171 if (debug_print)
172 {
173 const u8 *sig = sigptr;
174
175 unifi_error(card->ospriv, "Signal(%d): %*ph\n", siglen,
176 16, sig);
177 unifi_error(card->ospriv, "Bulkdata pointer %p(%d), %p(%d)\n",
178 bulkdata != NULL?bulkdata->d[0].os_data_ptr : NULL,
179 bulkdata != NULL?bulkdata->d[0].data_length : 0,
180 bulkdata != NULL?bulkdata->d[1].os_data_ptr : NULL,
181 bulkdata != NULL?bulkdata->d[1].data_length : 0);
182 }
183
184 /* Advance the written count to say there is a new entry */
185 CSR_WIFI_HIP_Q_INC_W(sigq);
186
187 /*
188 * Set the flag to say reason for waking was a host request.
189 * Then ask the OS layer to run the unifi_bh.
190 */
191 if (run_bh == 1)
192 {
193 card->bh_reason_host = 1;
194 r = unifi_run_bh(card->ospriv);
195 if (r != CSR_RESULT_SUCCESS)
196 {
197 unifi_error(card->ospriv, "failed to run bh.\n");
198 card->bh_reason_host = 0;
199
200 /*
201 * The bulk data buffer will be freed by the caller.
202 * We need to invalidate the description of the bulk data in our
203 * soft queue, to prevent the core freeing the bulk data again later.
204 */
205 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
206 {
207 if (csptr->bulkdata[i].data_length != 0)
208 {
209 csptr->bulkdata[i].os_data_ptr = csptr->bulkdata[i].os_net_buf_ptr = NULL;
210 csptr->bulkdata[i].net_buf_length = csptr->bulkdata[i].data_length = 0;
211 }
212 }
213 return r;
214 }
215 }
216 else
217 {
218 unifi_error(card->ospriv, "run_bh=%d, bh not called.\n", run_bh);
219 }
220
221 /*
222 * Have we used up all the fh signal list entries?
223 */
224 if (CSR_WIFI_HIP_Q_SLOTS_FREE(sigq) == 0)
225 {
226 /* We have filled the queue, so stop the upper layer. The command queue
227 * is an exception, as suspending due to that being full could delay
228 * resume/retry until new commands or data are received.
229 */
230 if (sigq != &card->fh_command_queue)
231 {
232 /*
233 * Must call unifi_pause_xmit() *before* setting the paused flag.
234 * (the unifi_pause_xmit call should not be after setting the flag because of the possibility of being interrupted
235 * by the bh thread between our setting the flag and the call to unifi_pause_xmit()
236 * If bh thread then cleared the flag, we would end up paused, but without the flag set)
237 * Instead, setting it afterwards means that if this thread is interrupted by the bh thread
238 * the pause flag is still guaranteed to end up set
239 * However the potential deadlock now is that if bh thread emptied the queue and cleared the flag before this thread's
240 * call to unifi_pause_xmit(), then bh thread may not run again because it will be waiting for
241 * a packet to appear in the queue but nothing ever will because xmit is paused.
242 * 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.
243 * (Note even this bad situation would not persist long in practice, because something else (eg rx, or tx in different queue)
244 * is likely to wake bh thread quite soon)
245 * But to avoid this deadlock completely, after setting the flag we check that there is something left in the queue.
246 * If there is, we know that bh thread has not emptied the queue yet.
247 * Since bh thread checks to unpause the queue *after* taking packets from the queue, we know that it is still going to make at
248 * least one more check to see whether it needs to unpause the queue. So all is well.
249 * If there are no packets in the queue, then the deadlock described above might happen. To make sure it does not, we
250 * unpause the queue here. A possible side effect is that unifi_restart_xmit() may (rarely) be called for second time
251 * unnecessarily, which is harmless
252 */
253
254#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
255 unifi_debug_log_to_buf("P");
256#endif
257 unifi_pause_xmit(card->ospriv, (unifi_TrafficQueue)priority_q);
258 card_tx_q_pause(card, priority_q);
259 if (CSR_WIFI_HIP_Q_SLOTS_USED(sigq) == 0)
260 {
261 card_tx_q_unpause(card, priority_q);
262 unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue) priority_q);
263 }
264 }
265 else
266 {
267 unifi_warning(card->ospriv,
268 "send_signal: fh_cmd_q full, not pausing (run_bh=%d)\n",
269 run_bh);
270 }
271 }
272
273 return CSR_RESULT_SUCCESS;
274} /* send_signal() */
275
276
277/*
278 * ---------------------------------------------------------------------------
279 * unifi_send_signal
280 *
281 * Invokes send_signal() to queue a signal in the command or traffic queue
282 * If sigptr pointer is NULL, it pokes the bh to check if UniFi is responsive.
283 *
284 * Arguments:
285 * card Pointer to card context struct
286 * sigptr Pointer to signal from card.
287 * siglen Size of the signal
288 * bulkdata Pointer to the bulk data of the signal
289 *
290 * Returns:
291 * CSR_RESULT_SUCCESS on success
292 * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or no free signal queue entry
293 *
294 * Notes:
295 * unifi_send_signal() is used to queue signals, created by the driver,
296 * to the device. Signals are constructed using the UniFi packed structures.
297 * ---------------------------------------------------------------------------
298 */
299CsrResult unifi_send_signal(card_t *card, const u8 *sigptr, u32 siglen,
300 const bulk_data_param_t *bulkdata)
301{
302 q_t *sig_soft_q;
303 u16 signal_id;
304 CsrResult r;
305 u32 run_bh;
306 u32 priority_q;
307
308 /* A NULL signal pointer is a request to check if UniFi is responsive */
309 if (sigptr == NULL)
310 {
311 card->bh_reason_host = 1;
312 return unifi_run_bh(card->ospriv);
313 }
314
315 priority_q = 0;
316 run_bh = 1;
317 signal_id = GET_SIGNAL_ID(sigptr);
318 /*
319 * If the signal is a CSR_MA_PACKET_REQUEST ,
320 * we send it using the traffic soft queue. Else we use the command soft queue.
321 */
322 if (signal_id == CSR_MA_PACKET_REQUEST_ID)
323 {
324 u16 frame_priority;
325
326 if (card->periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_ENABLED)
327 {
328 run_bh = 0;
329 }
330
331#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
332 unifi_debug_log_to_buf("D");
333#endif
334 /* Sanity check: MA-PACKET.req must have a valid bulk data */
335 if ((bulkdata->d[0].data_length == 0) || (bulkdata->d[0].os_data_ptr == NULL))
336 {
337 unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
338 bulkdata->d[0].data_length, bulkdata->d[0].os_data_ptr);
339 dump((void *)sigptr, siglen);
340 return CSR_RESULT_FAILURE;
341 }
342
343 /* Map the frame priority to a traffic queue index. */
344 frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr);
345 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority);
346
347 sig_soft_q = &card->fh_traffic_queue[priority_q];
348 }
349 else
350 {
351 sig_soft_q = &card->fh_command_queue;
352 }
353
354 r = send_signal(card, sigptr, siglen, bulkdata, sig_soft_q, priority_q, run_bh);
355 /* On error, the caller must free or requeue bulkdata buffers */
356
357 return r;
358} /* unifi_send_signal() */
359
360
361/*
362 * ---------------------------------------------------------------------------
363 * unifi_send_resources_available
364 *
365 * Examines whether there is available space to queue
366 * a signal in the command or traffic queue
367 *
368 * Arguments:
369 * card Pointer to card context struct
370 * sigptr Pointer to signal.
371 *
372 * Returns:
373 * CSR_RESULT_SUCCESS if resources available
374 * CSR_WIFI_HIP_RESULT_NO_SPACE if there was no free signal queue entry
375 *
376 * Notes:
377 * ---------------------------------------------------------------------------
378 */
379CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr)
380{
381 q_t *sig_soft_q;
382 u16 signal_id = GET_SIGNAL_ID(sigptr);
383
384 /*
385 * If the signal is a CSR_MA_PACKET_REQUEST ,
386 * we send it using the traffic soft queue. Else we use the command soft queue.
387 */
388 if (signal_id == CSR_MA_PACKET_REQUEST_ID)
389 {
390 u16 frame_priority;
391 u32 priority_q;
392
393 /* Map the frame priority to a traffic queue index. */
394 frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr);
395 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority);
396
397 sig_soft_q = &card->fh_traffic_queue[priority_q];
398 }
399 else
400 {
401 sig_soft_q = &card->fh_command_queue;
402 }
403
404 /* Check that the fh_data_queue has a free slot */
405 if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sig_soft_q))
406 {
407 unifi_notice(card->ospriv, "unifi_send_resources_available: %s full\n",
408 sig_soft_q->name);
409 return CSR_WIFI_HIP_RESULT_NO_SPACE;
410 }
411
412 return CSR_RESULT_SUCCESS;
413} /* unifi_send_resources_available() */
414
415
diff --git a/drivers/staging/csr/csr_wifi_hip_signals.c b/drivers/staging/csr/csr_wifi_hip_signals.c
deleted file mode 100644
index 3c821320df00..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_signals.c
+++ /dev/null
@@ -1,1313 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13
14/* Generated by hip_dd_l_c_gen.pl */
15
16#include "csr_wifi_hip_signals.h"
17
18#include "csr_wifi_hip_unifi.h"
19
20s32 SigGetSize(const CSR_SIGNAL *aSignal)
21{
22 switch (aSignal->SignalPrimitiveHeader.SignalId)
23 {
24 case CSR_MA_PACKET_REQUEST_ID:
25 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_REQUEST);
26 case CSR_MA_PACKET_CONFIRM_ID:
27 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CONFIRM);
28 case CSR_MA_PACKET_INDICATION_ID:
29 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_INDICATION);
30 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
31 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CANCEL_REQUEST);
32 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
33 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_RESPONSE);
34 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
35 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_INDICATION);
36 case CSR_MA_PACKET_ERROR_INDICATION_ID:
37 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_ERROR_INDICATION);
38#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
39 case CSR_MLME_RESET_REQUEST_ID:
40 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_REQUEST);
41#endif
42#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
43 case CSR_MLME_RESET_CONFIRM_ID:
44 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_CONFIRM);
45#endif
46#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
47 case CSR_MLME_GET_REQUEST_ID:
48 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_REQUEST);
49#endif
50#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
51 case CSR_MLME_GET_CONFIRM_ID:
52 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_CONFIRM);
53#endif
54#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
55 case CSR_MLME_SET_REQUEST_ID:
56 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_REQUEST);
57#endif
58#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
59 case CSR_MLME_SET_CONFIRM_ID:
60 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CONFIRM);
61#endif
62#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
63 case CSR_MLME_GET_NEXT_REQUEST_ID:
64 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_REQUEST);
65#endif
66#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
67 case CSR_MLME_GET_NEXT_CONFIRM_ID:
68 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_CONFIRM);
69#endif
70#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
71 case CSR_MLME_POWERMGT_REQUEST_ID:
72 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_REQUEST);
73#endif
74#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
75 case CSR_MLME_POWERMGT_CONFIRM_ID:
76 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_CONFIRM);
77#endif
78#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
79 case CSR_MLME_SCAN_REQUEST_ID:
80 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_REQUEST);
81#endif
82#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
83 case CSR_MLME_SCAN_CONFIRM_ID:
84 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CONFIRM);
85#endif
86#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
87 case CSR_MLME_HL_SYNC_REQUEST_ID:
88 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_REQUEST);
89#endif
90#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
91 case CSR_MLME_HL_SYNC_CONFIRM_ID:
92 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CONFIRM);
93#endif
94#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
95 case CSR_MLME_MEASURE_REQUEST_ID:
96 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_REQUEST);
97#endif
98#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
99 case CSR_MLME_MEASURE_CONFIRM_ID:
100 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_CONFIRM);
101#endif
102#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
103 case CSR_MLME_MEASURE_INDICATION_ID:
104 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_INDICATION);
105#endif
106#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
107 case CSR_MLME_SETKEYS_REQUEST_ID:
108 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_REQUEST);
109#endif
110#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
111 case CSR_MLME_SETKEYS_CONFIRM_ID:
112 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_CONFIRM);
113#endif
114#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
115 case CSR_MLME_DELETEKEYS_REQUEST_ID:
116 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_REQUEST);
117#endif
118#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
119 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
120 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_CONFIRM);
121#endif
122#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
123 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
124 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION);
125#endif
126#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
127 case CSR_MLME_CONNECTED_INDICATION_ID:
128 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECTED_INDICATION);
129#endif
130#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
131 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
132 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CANCEL_REQUEST);
133#endif
134#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
135 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
136 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_REQUEST);
137#endif
138#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
139 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
140 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_CONFIRM);
141#endif
142#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
143 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
144 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_REQUEST);
145#endif
146#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
147 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
148 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_CONFIRM);
149#endif
150#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
151 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
152 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_REQUEST);
153#endif
154#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
155 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
156 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_CONFIRM);
157#endif
158#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
159 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
160 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST);
161#endif
162#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
163 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
164 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM);
165#endif
166#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
167 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
168 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST);
169#endif
170#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
171 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
172 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM);
173#endif
174#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
175 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
176 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_REQUEST);
177#endif
178#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
179 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
180 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_CONFIRM);
181#endif
182#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
183 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
184 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_REQUEST);
185#endif
186#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
187 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
188 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_CONFIRM);
189#endif
190#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
191 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
192 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST);
193#endif
194#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
195 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
196 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM);
197#endif
198#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
199 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
200 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION);
201#endif
202#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
203 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
204 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_REQUEST);
205#endif
206#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
207 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
208 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_CONFIRM);
209#endif
210#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
211 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
212 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_REQUEST);
213#endif
214#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
215 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
216 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_CONFIRM);
217#endif
218#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
219 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
220 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_TRIGGERED_GET_INDICATION);
221#endif
222#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
223 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
224 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_REQUEST);
225#endif
226#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
227 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
228 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_CONFIRM);
229#endif
230#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
231 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
232 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLACKOUT_ENDED_INDICATION);
233#endif
234#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
235 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
236 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_REQUEST);
237#endif
238#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
239 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
240 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_CONFIRM);
241#endif
242#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
243 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
244 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_REQUEST);
245#endif
246#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
247 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
248 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_CONFIRM);
249#endif
250#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
251 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
252 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_REQUEST);
253#endif
254#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
255 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
256 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_CONFIRM);
257#endif
258#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
259 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
260 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_REQUEST);
261#endif
262#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
263 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
264 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_CONFIRM);
265#endif
266#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
267 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
268 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST);
269#endif
270#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
271 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
272 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM);
273#endif
274#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
275 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
276 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_REQUEST);
277#endif
278#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
279 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
280 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_CONFIRM);
281#endif
282#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
283 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
284 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_REQUEST);
285#endif
286#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
287 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
288 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_CONFIRM);
289#endif
290#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
291 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
292 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_REQUEST);
293#endif
294#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
295 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
296 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_CONFIRM);
297#endif
298#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
299 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
300 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_REQUEST);
301#endif
302#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
303 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
304 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_CONFIRM);
305#endif
306#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
307 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
308 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_REQUEST);
309#endif
310#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
311 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
312 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_CONFIRM);
313#endif
314#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
315 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
316 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLOCKACK_ERROR_INDICATION);
317#endif
318#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
319 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
320 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_REQUEST);
321#endif
322#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
323 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
324 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_CONFIRM);
325#endif
326#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
327 case CSR_MLME_SM_START_REQUEST_ID:
328 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_REQUEST);
329#endif
330#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
331 case CSR_MLME_SM_START_CONFIRM_ID:
332 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_CONFIRM);
333#endif
334#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
335 case CSR_MLME_LEAVE_REQUEST_ID:
336 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_REQUEST);
337#endif
338#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
339 case CSR_MLME_LEAVE_CONFIRM_ID:
340 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_CONFIRM);
341#endif
342 case CSR_MLME_SET_TIM_REQUEST_ID:
343 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_REQUEST);
344 case CSR_MLME_SET_TIM_CONFIRM_ID:
345 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_CONFIRM);
346#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
347 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
348 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_REQUEST);
349#endif
350#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
351 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
352 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_CONFIRM);
353#endif
354#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
355 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
356 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_REQUEST);
357#endif
358#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
359 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
360 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_CONFIRM);
361#endif
362#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
363 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
364 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST);
365#endif
366#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
367 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
368 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM);
369#endif
370 case CSR_DEBUG_STRING_INDICATION_ID:
371 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_STRING_INDICATION);
372 case CSR_DEBUG_WORD16_INDICATION_ID:
373 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_WORD16_INDICATION);
374 case CSR_DEBUG_GENERIC_REQUEST_ID:
375 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_REQUEST);
376 case CSR_DEBUG_GENERIC_CONFIRM_ID:
377 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_CONFIRM);
378 case CSR_DEBUG_GENERIC_INDICATION_ID:
379 return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_INDICATION);
380 default:
381 return 0;
382 }
383}
384
385
386s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef)
387{
388 s32 numRefs = 0;
389
390 switch (aSignal->SignalPrimitiveHeader.SignalId)
391 {
392 case CSR_MA_PACKET_REQUEST_ID:
393 aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Data;
394 aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Dummydataref2;
395 break;
396 case CSR_MA_PACKET_CONFIRM_ID:
397 aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref1;
398 aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref2;
399 break;
400 case CSR_MA_PACKET_INDICATION_ID:
401 aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Data;
402 aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Dummydataref2;
403 break;
404 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
405 aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref1;
406 aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref2;
407 break;
408 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
409 aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref1;
410 aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref2;
411 break;
412 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
413 aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref1;
414 aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref2;
415 break;
416 case CSR_MA_PACKET_ERROR_INDICATION_ID:
417 aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref1;
418 aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref2;
419 break;
420#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
421 case CSR_MLME_RESET_REQUEST_ID:
422 aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref1;
423 aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref2;
424 break;
425#endif
426#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
427 case CSR_MLME_RESET_CONFIRM_ID:
428 aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref1;
429 aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref2;
430 break;
431#endif
432#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
433 case CSR_MLME_GET_REQUEST_ID:
434 aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.MibAttribute;
435 aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.Dummydataref2;
436 break;
437#endif
438#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
439 case CSR_MLME_GET_CONFIRM_ID:
440 aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.MibAttributeValue;
441 aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.Dummydataref2;
442 break;
443#endif
444#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
445 case CSR_MLME_SET_REQUEST_ID:
446 aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.MibAttributeValue;
447 aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.Dummydataref2;
448 break;
449#endif
450#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
451 case CSR_MLME_SET_CONFIRM_ID:
452 aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.MibAttributeValue;
453 aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.Dummydataref2;
454 break;
455#endif
456#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
457 case CSR_MLME_GET_NEXT_REQUEST_ID:
458 aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.MibAttribute;
459 aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.Dummydataref2;
460 break;
461#endif
462#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
463 case CSR_MLME_GET_NEXT_CONFIRM_ID:
464 aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.MibAttributeValue;
465 aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.Dummydataref2;
466 break;
467#endif
468#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
469 case CSR_MLME_POWERMGT_REQUEST_ID:
470 aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref1;
471 aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref2;
472 break;
473#endif
474#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
475 case CSR_MLME_POWERMGT_CONFIRM_ID:
476 aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref1;
477 aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref2;
478 break;
479#endif
480#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
481 case CSR_MLME_SCAN_REQUEST_ID:
482 aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.ChannelList;
483 aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.InformationElements;
484 break;
485#endif
486#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
487 case CSR_MLME_SCAN_CONFIRM_ID:
488 aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref1;
489 aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref2;
490 break;
491#endif
492#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
493 case CSR_MLME_HL_SYNC_REQUEST_ID:
494 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref1;
495 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref2;
496 break;
497#endif
498#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
499 case CSR_MLME_HL_SYNC_CONFIRM_ID:
500 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref1;
501 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref2;
502 break;
503#endif
504#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
505 case CSR_MLME_MEASURE_REQUEST_ID:
506 aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.MeasurementRequestSet;
507 aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.Dummydataref2;
508 break;
509#endif
510#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
511 case CSR_MLME_MEASURE_CONFIRM_ID:
512 aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref1;
513 aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref2;
514 break;
515#endif
516#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
517 case CSR_MLME_MEASURE_INDICATION_ID:
518 aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.MeasurementReportSet;
519 aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.Dummydataref2;
520 break;
521#endif
522#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
523 case CSR_MLME_SETKEYS_REQUEST_ID:
524 aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Key;
525 aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Dummydataref2;
526 break;
527#endif
528#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
529 case CSR_MLME_SETKEYS_CONFIRM_ID:
530 aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref1;
531 aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref2;
532 break;
533#endif
534#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
535 case CSR_MLME_DELETEKEYS_REQUEST_ID:
536 aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref1;
537 aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref2;
538 break;
539#endif
540#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
541 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
542 aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref1;
543 aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref2;
544 break;
545#endif
546#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
547 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
548 aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref1;
549 aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref2;
550 break;
551#endif
552#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
553 case CSR_MLME_CONNECTED_INDICATION_ID:
554 aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref1;
555 aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref2;
556 break;
557#endif
558#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
559 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
560 aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref1;
561 aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref2;
562 break;
563#endif
564#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
565 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
566 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref1;
567 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref2;
568 break;
569#endif
570#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
571 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
572 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref1;
573 aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref2;
574 break;
575#endif
576#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
577 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
578 aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref1;
579 aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref2;
580 break;
581#endif
582#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
583 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
584 aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref1;
585 aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref2;
586 break;
587#endif
588#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
589 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
590 aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref1;
591 aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref2;
592 break;
593#endif
594#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
595 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
596 aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref1;
597 aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref2;
598 break;
599#endif
600#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
601 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
602 aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.ChannelList;
603 aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.InformationElements;
604 break;
605#endif
606#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
607 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
608 aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref1;
609 aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref2;
610 break;
611#endif
612#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
613 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
614 aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref1;
615 aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref2;
616 break;
617#endif
618#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
619 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
620 aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref1;
621 aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref2;
622 break;
623#endif
624#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
625 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
626 aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.InformationElements;
627 aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.Dummydataref2;
628 break;
629#endif
630#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
631 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
632 aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref1;
633 aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref2;
634 break;
635#endif
636#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
637 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
638 aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref1;
639 aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref2;
640 break;
641#endif
642#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
643 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
644 aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref1;
645 aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref2;
646 break;
647#endif
648#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
649 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
650 aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref1;
651 aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref2;
652 break;
653#endif
654#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
655 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
656 aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref1;
657 aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref2;
658 break;
659#endif
660#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
661 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
662 aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref1;
663 aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref2;
664 break;
665#endif
666#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
667 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
668 aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.MibAttribute;
669 aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.Dummydataref2;
670 break;
671#endif
672#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
673 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
674 aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref1;
675 aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref2;
676 break;
677#endif
678#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
679 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
680 aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref1;
681 aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref2;
682 break;
683#endif
684#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
685 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
686 aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref1;
687 aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref2;
688 break;
689#endif
690#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
691 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
692 aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.MibAttributeValue;
693 aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.Dummydataref2;
694 break;
695#endif
696#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
697 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
698 aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref1;
699 aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref2;
700 break;
701#endif
702#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
703 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
704 aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref1;
705 aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref2;
706 break;
707#endif
708#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
709 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
710 aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref1;
711 aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref2;
712 break;
713#endif
714#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
715 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
716 aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref1;
717 aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref2;
718 break;
719#endif
720#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
721 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
722 aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref1;
723 aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref2;
724 break;
725#endif
726#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
727 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
728 aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.InformationElements;
729 aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.Dummydataref2;
730 break;
731#endif
732#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
733 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
734 aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref1;
735 aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref2;
736 break;
737#endif
738#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
739 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
740 aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref1;
741 aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref2;
742 break;
743#endif
744#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
745 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
746 aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref1;
747 aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref2;
748 break;
749#endif
750#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
751 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
752 aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.InformationElements;
753 aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.Dummydataref2;
754 break;
755#endif
756#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
757 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
758 aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref1;
759 aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref2;
760 break;
761#endif
762#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
763 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
764 aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Data;
765 aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Dummydataref2;
766 break;
767#endif
768#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
769 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
770 aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref1;
771 aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref2;
772 break;
773#endif
774#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
775 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
776 aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data1;
777 aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data2;
778 break;
779#endif
780#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
781 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
782 aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref1;
783 aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref2;
784 break;
785#endif
786#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
787 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
788 aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref1;
789 aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref2;
790 break;
791#endif
792#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
793 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
794 aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref1;
795 aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref2;
796 break;
797#endif
798#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
799 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
800 aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref1;
801 aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref2;
802 break;
803#endif
804#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
805 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
806 aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref1;
807 aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref2;
808 break;
809#endif
810#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
811 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
812 aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref1;
813 aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref2;
814 break;
815#endif
816#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
817 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
818 aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref1;
819 aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref2;
820 break;
821#endif
822#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
823 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
824 aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref1;
825 aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref2;
826 break;
827#endif
828#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
829 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
830 aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref1;
831 aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref2;
832 break;
833#endif
834#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
835 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
836 aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref1;
837 aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref2;
838 break;
839#endif
840#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
841 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
842 aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref1;
843 aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref2;
844 break;
845#endif
846#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
847 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
848 aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref1;
849 aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref2;
850 break;
851#endif
852#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
853 case CSR_MLME_SM_START_REQUEST_ID:
854 aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.Beacon;
855 aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.BssParameters;
856 break;
857#endif
858#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
859 case CSR_MLME_SM_START_CONFIRM_ID:
860 aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref1;
861 aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref2;
862 break;
863#endif
864#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
865 case CSR_MLME_LEAVE_REQUEST_ID:
866 aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref1;
867 aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref2;
868 break;
869#endif
870#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
871 case CSR_MLME_LEAVE_CONFIRM_ID:
872 aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref1;
873 aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref2;
874 break;
875#endif
876 case CSR_MLME_SET_TIM_REQUEST_ID:
877 aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref1;
878 aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref2;
879 break;
880 case CSR_MLME_SET_TIM_CONFIRM_ID:
881 aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref1;
882 aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref2;
883 break;
884#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
885 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
886 aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref1;
887 aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref2;
888 break;
889#endif
890#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
891 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
892 aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref1;
893 aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref2;
894 break;
895#endif
896#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
897 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
898 aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref1;
899 aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref2;
900 break;
901#endif
902#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
903 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
904 aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref1;
905 aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref2;
906 break;
907#endif
908#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
909 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
910 aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Data;
911 aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Dummydataref2;
912 break;
913#endif
914#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
915 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
916 aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref1;
917 aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref2;
918 break;
919#endif
920 case CSR_DEBUG_STRING_INDICATION_ID:
921 aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.DebugMessage;
922 aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.Dummydataref2;
923 break;
924 case CSR_DEBUG_WORD16_INDICATION_ID:
925 aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref1;
926 aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref2;
927 break;
928 case CSR_DEBUG_GENERIC_REQUEST_ID:
929 aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.DebugVariable;
930 aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.Dummydataref2;
931 break;
932 case CSR_DEBUG_GENERIC_CONFIRM_ID:
933 aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.DebugVariable;
934 aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.Dummydataref2;
935 break;
936 case CSR_DEBUG_GENERIC_INDICATION_ID:
937 aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.DebugVariable;
938 aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.Dummydataref2;
939 break;
940 default:
941 return 0;
942 }
943 return numRefs;
944}
945
946
947u32 SigGetFilterPos(u16 aSigID)
948{
949 switch (aSigID)
950 {
951 case CSR_MA_PACKET_REQUEST_ID:
952 return 0x00000001;
953 case CSR_MA_PACKET_CONFIRM_ID:
954 return 0x00000002;
955 case CSR_MA_PACKET_INDICATION_ID:
956 return 0x00000004;
957 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
958 return 0x00000008;
959 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
960 return 0x00000010;
961 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
962 return 0x00000020;
963 case CSR_MA_PACKET_ERROR_INDICATION_ID:
964 return 0x00000040;
965#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
966 case CSR_MLME_RESET_REQUEST_ID:
967 return 0x00000080;
968#endif
969#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
970 case CSR_MLME_RESET_CONFIRM_ID:
971 return 0x00000100;
972#endif
973#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
974 case CSR_MLME_GET_REQUEST_ID:
975 return 0x00000200;
976#endif
977#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
978 case CSR_MLME_GET_CONFIRM_ID:
979 return 0x00000400;
980#endif
981#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
982 case CSR_MLME_SET_REQUEST_ID:
983 return 0x00000800;
984#endif
985#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
986 case CSR_MLME_SET_CONFIRM_ID:
987 return 0x00001000;
988#endif
989#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
990 case CSR_MLME_GET_NEXT_REQUEST_ID:
991 return 0x00002000;
992#endif
993#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
994 case CSR_MLME_GET_NEXT_CONFIRM_ID:
995 return 0x00004000;
996#endif
997#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
998 case CSR_MLME_POWERMGT_REQUEST_ID:
999 return 0x00008000;
1000#endif
1001#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1002 case CSR_MLME_POWERMGT_CONFIRM_ID:
1003 return 0x00010001;
1004#endif
1005#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1006 case CSR_MLME_SCAN_REQUEST_ID:
1007 return 0x00010002;
1008#endif
1009#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1010 case CSR_MLME_SCAN_CONFIRM_ID:
1011 return 0x00010004;
1012#endif
1013#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1014 case CSR_MLME_HL_SYNC_REQUEST_ID:
1015 return 0x00010008;
1016#endif
1017#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1018 case CSR_MLME_HL_SYNC_CONFIRM_ID:
1019 return 0x00010010;
1020#endif
1021#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1022 case CSR_MLME_MEASURE_REQUEST_ID:
1023 return 0x00010020;
1024#endif
1025#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1026 case CSR_MLME_MEASURE_CONFIRM_ID:
1027 return 0x00010040;
1028#endif
1029#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1030 case CSR_MLME_MEASURE_INDICATION_ID:
1031 return 0x00010080;
1032#endif
1033#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1034 case CSR_MLME_SETKEYS_REQUEST_ID:
1035 return 0x00010100;
1036#endif
1037#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1038 case CSR_MLME_SETKEYS_CONFIRM_ID:
1039 return 0x00010200;
1040#endif
1041#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1042 case CSR_MLME_DELETEKEYS_REQUEST_ID:
1043 return 0x00010400;
1044#endif
1045#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1046 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
1047 return 0x00010800;
1048#endif
1049#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1050 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
1051 return 0x00011000;
1052#endif
1053#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1054 case CSR_MLME_CONNECTED_INDICATION_ID:
1055 return 0x00012000;
1056#endif
1057#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1058 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
1059 return 0x00014000;
1060#endif
1061#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1062 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
1063 return 0x00018000;
1064#endif
1065#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1066 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
1067 return 0x00020001;
1068#endif
1069#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1070 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
1071 return 0x00020002;
1072#endif
1073#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1074 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
1075 return 0x00020004;
1076#endif
1077#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1078 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
1079 return 0x00020008;
1080#endif
1081#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1082 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
1083 return 0x00020010;
1084#endif
1085#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1086 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
1087 return 0x00020020;
1088#endif
1089#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1090 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
1091 return 0x00020040;
1092#endif
1093#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1094 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
1095 return 0x00020080;
1096#endif
1097#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1098 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
1099 return 0x00020100;
1100#endif
1101#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1102 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
1103 return 0x00020200;
1104#endif
1105#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1106 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
1107 return 0x00020400;
1108#endif
1109#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1110 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
1111 return 0x00020800;
1112#endif
1113#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1114 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
1115 return 0x00021000;
1116#endif
1117#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1118 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
1119 return 0x00022000;
1120#endif
1121#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1122 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
1123 return 0x00024000;
1124#endif
1125#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1126 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
1127 return 0x00028000;
1128#endif
1129#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1130 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
1131 return 0x00030001;
1132#endif
1133#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1134 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
1135 return 0x00030002;
1136#endif
1137#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1138 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
1139 return 0x00030004;
1140#endif
1141#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1142 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
1143 return 0x00030008;
1144#endif
1145#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1146 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
1147 return 0x00030010;
1148#endif
1149#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1150 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
1151 return 0x00030020;
1152#endif
1153#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1154 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
1155 return 0x00030040;
1156#endif
1157#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1158 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
1159 return 0x00030080;
1160#endif
1161#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1162 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
1163 return 0x00030100;
1164#endif
1165#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1166 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
1167 return 0x00030200;
1168#endif
1169#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1170 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
1171 return 0x00030400;
1172#endif
1173#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1174 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
1175 return 0x00030800;
1176#endif
1177#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1178 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
1179 return 0x00031000;
1180#endif
1181#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1182 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
1183 return 0x00032000;
1184#endif
1185#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1186 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
1187 return 0x00034000;
1188#endif
1189#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1190 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
1191 return 0x00038000;
1192#endif
1193#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1194 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
1195 return 0x00040001;
1196#endif
1197#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1198 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
1199 return 0x00040002;
1200#endif
1201#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1202 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
1203 return 0x00040004;
1204#endif
1205#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1206 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
1207 return 0x00040008;
1208#endif
1209#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1210 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
1211 return 0x00040010;
1212#endif
1213#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1214 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
1215 return 0x00040020;
1216#endif
1217#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1218 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
1219 return 0x00040040;
1220#endif
1221#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1222 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
1223 return 0x00040080;
1224#endif
1225#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1226 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
1227 return 0x00040100;
1228#endif
1229#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1230 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
1231 return 0x00040200;
1232#endif
1233#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1234 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
1235 return 0x00040400;
1236#endif
1237#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1238 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
1239 return 0x00040800;
1240#endif
1241#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1242 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
1243 return 0x00041000;
1244#endif
1245#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1246 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
1247 return 0x00042000;
1248#endif
1249#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1250 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
1251 return 0x00044000;
1252#endif
1253#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1254 case CSR_MLME_SM_START_REQUEST_ID:
1255 return 0x00048000;
1256#endif
1257#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1258 case CSR_MLME_SM_START_CONFIRM_ID:
1259 return 0x00050001;
1260#endif
1261#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1262 case CSR_MLME_LEAVE_REQUEST_ID:
1263 return 0x00050002;
1264#endif
1265#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1266 case CSR_MLME_LEAVE_CONFIRM_ID:
1267 return 0x00050004;
1268#endif
1269 case CSR_MLME_SET_TIM_REQUEST_ID:
1270 return 0x00050008;
1271 case CSR_MLME_SET_TIM_CONFIRM_ID:
1272 return 0x00050010;
1273#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1274 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
1275 return 0x00050020;
1276#endif
1277#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1278 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
1279 return 0x00050040;
1280#endif
1281#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1282 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
1283 return 0x00050080;
1284#endif
1285#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1286 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
1287 return 0x00050100;
1288#endif
1289#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1290 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
1291 return 0x00050200;
1292#endif
1293#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1294 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
1295 return 0x00050400;
1296#endif
1297 case CSR_DEBUG_STRING_INDICATION_ID:
1298 return 0x00050800;
1299 case CSR_DEBUG_WORD16_INDICATION_ID:
1300 return 0x00051000;
1301 case CSR_DEBUG_GENERIC_REQUEST_ID:
1302 return 0x00052000;
1303 case CSR_DEBUG_GENERIC_CONFIRM_ID:
1304 return 0x00054000;
1305 case CSR_DEBUG_GENERIC_INDICATION_ID:
1306 return 0x00058000;
1307 default:
1308 break;
1309 }
1310 return 0xffffffff;
1311}
1312
1313
diff --git a/drivers/staging/csr/csr_wifi_hip_signals.h b/drivers/staging/csr/csr_wifi_hip_signals.h
deleted file mode 100644
index ca4d0774195c..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_signals.h
+++ /dev/null
@@ -1,128 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 *****************************************************************************
13 *
14 * FILE: csr_wifi_hip_signals.h
15 *
16 * PURPOSE:
17 * Header file wrapping the auto-generated code in csr_wifi_hip_sigs.h
18 * and csr_wifi_hip_signals.c -
19 * csr_wifi_hip_sigs.h provides structures defining UniFi signals and
20 * csr_wifi_hip_signals.c provides SigGetSize() and SigGetDataRefs().
21 *
22 *****************************************************************************
23 */
24#ifndef __CSR_WIFI_HIP_SIGNALS_H__
25#define __CSR_WIFI_HIP_SIGNALS_H__
26
27#include <linux/types.h>
28#include "csr_wifi_hip_sigs.h"
29
30
31/****************************************************************************/
32/* INFORMATION ELEMENTS */
33/****************************************************************************/
34
35/* Information Element ID's - shouldn't be in here, but nowhere better yet */
36#define IE_SSID_ID 0
37#define IE_SUPPORTED_RATES_ID 1
38#define IE_FH_PARAM_SET_ID 2
39#define IE_DS_PARAM_SET_ID 3
40#define IE_CF_PARAM_SET_ID 4
41#define IE_TIM_ID 5
42#define IE_IBSS_PARAM_SET_ID 6
43#define IE_COUNTRY_ID 7
44#define IE_HOPPING_PATTERN_PARAMS_ID 8
45#define IE_HOPPING_PATTERN_TABLE_ID 9
46#define IE_REQUEST_ID 10
47#define IE_QBSS_LOAD_ID 11
48#define IE_EDCA_PARAM_SET_ID 12
49#define IE_TRAFFIC_SPEC_ID 13
50#define IE_TRAFFIC_CLASS_ID 14
51#define IE_SCHEDULE_ID 15
52#define IE_CHALLENGE_TEXT_ID 16
53#define IE_POWER_CONSTRAINT_ID 32
54#define IE_POWER_CAPABILITY_ID 33
55#define IE_TPC_REQUEST_ID 34
56#define IE_TPC_REPORT_ID 35
57#define IE_SUPPORTED_CHANNELS_ID 36
58#define IE_CHANNEL_SWITCH_ANNOUNCE_ID 37
59#define IE_MEASUREMENT_REQUEST_ID 38
60#define IE_MEASUREMENT_REPORT_ID 39
61#define IE_QUIET_ID 40
62#define IE_IBSS_DFS_ID 41
63#define IE_ERP_INFO_ID 42
64#define IE_TS_DELAY_ID 43
65#define IE_TCLAS_PROCESSING_ID 44
66#define IE_QOS_CAPABILITY_ID 46
67#define IE_RSN_ID 48
68#define IE_EXTENDED_SUPPORTED_RATES_ID 50
69#define IE_AP_CHANNEL_REPORT_ID 52
70#define IE_RCPI_ID 53
71#define IE_WPA_ID 221
72
73
74/* The maximum number of data references in a signal structure */
75#define UNIFI_MAX_DATA_REFERENCES 2
76
77/* The space to allow for a wire-format signal structure */
78#define UNIFI_PACKED_SIGBUF_SIZE 64
79
80
81/******************************************************************************/
82/* SIGNAL PARAMETER VALUES */
83/******************************************************************************/
84
85/* ifIndex */
86#define UNIFI_IF_2G4 1
87#define UNIFI_IF_5G 2
88
89/* SendProcessId */
90#define HOST_PROC_ID 0xc000
91
92#define SIG_CAP_ESS 0x0001
93#define SIG_CAP_IBSS 0x0002
94#define SIG_CAP_CF_POLLABLE 0x0004
95#define SIG_CAP_CF_POLL_REQUEST 0x0008
96#define SIG_CAP_PRIVACY 0x0010
97#define SIG_CAP_SHORT_PREAMBLE 0x0020
98#define SIG_CAP_DSSSOFDM 0x2000
99
100/******************************************************************************/
101/* FUNCTION DECLARATIONS */
102/******************************************************************************/
103
104/******************************************************************************
105 * SigGetNumDataRefs - Retrieve pointers to data-refs from a signal.
106 *
107 * PARAMETERS:
108 * aSignal - Pointer to signal to retrieve the data refs of.
109 * aDataRef - Address of a pointer to the structure that the data refs
110 * pointers will be stored.
111 *
112 * RETURNS:
113 * The number of data-refs in the signal.
114 */
115s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef);
116
117/******************************************************************************
118 * SigGetSize - Retrieve the size (in bytes) of a given signal.
119 *
120 * PARAMETERS:
121 * aSignal - Pointer to signal to retrieve size of.
122 *
123 * RETURNS:
124 * The size (in bytes) of the given signal.
125 */
126s32 SigGetSize(const CSR_SIGNAL *aSignal);
127
128#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
index 6112cc3e87fa..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_sigs.h
+++ /dev/null
@@ -1,1417 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13
14/* Generated by hip_dd_l_h_gen.pl */
15
16#ifndef CSR_WIFI_HIP_SIGS_H
17#define CSR_WIFI_HIP_SIGS_H
18
19typedef s16 csr_place_holding_type;
20
21typedef u16 CSR_ASSOCIATION_ID;
22
23typedef u16 CSR_AUTONOMOUS_SCAN_ID;
24
25typedef u16 CSR_BEACON_PERIODS;
26
27typedef u16 CSR_BLACKOUT_ID;
28
29typedef enum CSR_BLACKOUT_SOURCE
30{
31 CSR_DOT11_LOCAL = 0x0000,
32 CSR_DOT11_REMOTE = 0x0001,
33 CSR_OTHER_RADIO = 0x0002,
34 CSR_NOT_LINKED = 0x0004
35} CSR_BLACKOUT_SOURCE;
36
37typedef enum CSR_BLACKOUT_TYPE
38{
39 CSR_LOCAL_DEVICE_ONLY = 0x0001,
40 CSR_SPECIFIED_PEER = 0x0002,
41 CSR_CURRENT_CHANNEL = 0x0004,
42 CSR_P2P = 0x0008
43} CSR_BLACKOUT_TYPE;
44
45typedef enum CSR_BOOT_LOADER_OPERATION
46{
47 CSR_BOOT_LOADER_IDLE = 0x00,
48 CSR_BOOT_LOADER_RESTART = 0x01,
49 CSR_BOOT_LOADER_PATCH = 0x02,
50 CSR_BOOT_LOADER_IMAGE_0 = 0x10,
51 CSR_BOOT_LOADER_IMAGE_1 = 0x11,
52 CSR_BOOT_LOADER_IMAGE_2 = 0x12,
53 CSR_BOOT_LOADER_IMAGE_3 = 0x13
54} CSR_BOOT_LOADER_OPERATION;
55
56typedef u16 CSR_CAPABILITY_INFORMATION;
57
58typedef u16 CSR_CHANNEL_STARTING_FACTOR;
59
60typedef u32 CSR_CIPHER_SUITE_SELECTOR;
61
62typedef u32 CSR_CLIENT_TAG;
63
64typedef enum CSR_CONNECTION_STATUS
65{
66 CSR_DISCONNECTED = 0x0000,
67 CSR_CONNECTED_AWAKE = 0x0001
68} CSR_CONNECTION_STATUS;
69
70typedef s16 CSR_DECIBELS;
71
72typedef enum CSR_DIRECTION
73{
74 CSR_TRANSMIT = 0x0000,
75 CSR_RECEIVE = 0x0001,
76 CSR_BIDIRECTIONAL = 0x0003
77} CSR_DIRECTION;
78
79typedef enum CSR_FRAME_TYPE
80{
81 CSR_RESERVED = 0x0000,
82 CSR_BEACON = 0x0001,
83 CSR_PROBE_RESPONSE = 0x0002,
84 CSR_BEACON_AND_PROBE_RESPONSE = 0x0003,
85 CSR_PROBE_REQUEST = 0x0004
86} CSR_FRAME_TYPE;
87
88typedef u32 CSR_IPV4_ADDRESS;
89
90typedef enum CSR_IFINTERFACE
91{
92 CSR_INDEX_2G4 = 0x0001,
93 CSR_INDEX_5G = 0x0002
94} CSR_IFINTERFACE;
95
96typedef enum CSR_KEY_TYPE
97{
98 CSR_GROUP = 0x0000,
99 CSR_PAIRWISE = 0x0001,
100 CSR_PEER_KEY = 0x0002,
101 CSR_IGTK = 0x0003
102} CSR_KEY_TYPE;
103
104typedef enum CSR_LOADER_OPERATION
105{
106 CSR_LOADER_IDLE = 0x0000,
107 CSR_LOADER_COPY = 0x0001
108} CSR_LOADER_OPERATION;
109
110typedef struct CSR_MAC_ADDRESS
111{
112 u8 x[6];
113} CSR_MACADDRESS;
114
115typedef enum CSR_MIB_STATUS
116{
117 CSR_MIB_SUCCESSFUL = 0x0000,
118 CSR_MIB_INVALID_PARAMETERS = 0x0001,
119 CSR_MIB_WRITE_ONLY = 0x0002,
120 CSR_MIB_READ_ONLY = 0x0003
121} CSR_MIB_STATUS;
122
123typedef enum CSR_MEMORY_SPACE
124{
125 CSR_NONE = 0x00,
126 CSR_SHARED_DATA_MEMORY = 0x01,
127 CSR_EXTERNAL_FLASH_MEMORY = 0x02,
128 CSR_EXTERNAL_SRAM = 0x03,
129 CSR_REGISTERS = 0x04,
130 CSR_PHY_PROCESSOR_DATA_MEMORY = 0x10,
131 CSR_PHY_PROCESSOR_PROGRAM_MEMORY = 0x11,
132 CSR_PHY_PROCESSOR_ROM = 0x12,
133 CSR_MAC_PROCESSOR_DATA_MEMORY = 0x20,
134 CSR_MAC_PROCESSOR_PROGRAM_MEMORY = 0x21,
135 CSR_MAC_PROCESSOR_ROM = 0x22,
136 CSR_BT_PROCESSOR_DATA_MEMORY = 0x30,
137 CSR_BT_PROCESSOR_PROGRAM_MEMORY = 0x31,
138 CSR_BT_PROCESSOR_ROM = 0x32
139} CSR_MEMORY_SPACE;
140
141typedef u16 CSR_MICROSECONDS16;
142
143typedef u32 CSR_MICROSECONDS32;
144
145typedef u16 CSR_NATURAL16;
146
147typedef enum CSR_PS_SCHEME
148{
149 CSR_LEGACY_PS = 0x0001,
150 CSR_U_APSD = 0x0002,
151 CSR_S_APSD = 0x0004
152} CSR_PS_SCHEME;
153
154typedef enum CSR_PACKET_FILTER_MODE
155{
156 CSR_PFM_OPT_OUT = 0x0000,
157 CSR_PFM_OPT_IN = 0x0003
158} CSR_PACKET_FILTER_MODE;
159
160typedef u16 CSR_PERIODIC_ID;
161
162typedef enum CSR_PERIODIC_SCHEDULING_MODE
163{
164 CSR_PSM_PERIODIC_SCHEDULE_PS_POLL = 0x0001,
165 CSR_PSM_PERIODIC_SCHEDULE_PM_BIT = 0x0002,
166 CSR_PSM_PERIODIC_SCHEDULE_UAPSD = 0x0004,
167 CSR_PSM_PERIODIC_SCHEDULE_SAPSD = 0x0008
168} CSR_PERIODIC_SCHEDULING_MODE;
169
170typedef enum CSR_POWER_MANAGEMENT_MODE
171{
172 CSR_PMM_ACTIVE_MODE = 0x0000,
173 CSR_PMM_POWER_SAVE = 0x0001,
174 CSR_PMM_FAST_POWER_SAVE = 0x0002
175} CSR_POWER_MANAGEMENT_MODE;
176
177typedef enum CSR_PRIORITY
178{
179 CSR_QOS_UP0 = 0x0000,
180 CSR_QOS_UP1 = 0x0001,
181 CSR_QOS_UP2 = 0x0002,
182 CSR_QOS_UP3 = 0x0003,
183 CSR_QOS_UP4 = 0x0004,
184 CSR_QOS_UP5 = 0x0005,
185 CSR_QOS_UP6 = 0x0006,
186 CSR_QOS_UP7 = 0x0007,
187 CSR_CONTENTION = 0x8000,
188 CSR_MANAGEMENT = 0x8010
189} CSR_PRIORITY;
190
191typedef enum CSR_REASON_CODE
192{
193 CSR_UNSPECIFIED_REASON = 0x0001,
194 CSR_INVALID_INFORMATION_ELEMENT = 0x000d,
195 CSR_QOS_UNSPECIFIED_REASON = 0x0020,
196 CSR_QOS_EXCESSIVE_NOT_ACK = 0x0022,
197 CSR_QOS_TXOP_LIMIT_EXCEEDED = 0x0023,
198 CSR_QSTA_LEAVING = 0x0024,
199 CSR_UNKNOWN_BA = 0x0026,
200 CSR_UNKNOWN_TS = 0x0026,
201 CSR_TIMEOUT = 0x0027
202} CSR_REASON_CODE;
203
204typedef enum CSR_RECEPTION_STATUS
205{
206 CSR_RX_SUCCESS = 0x0000,
207 CSR_RX_FAILURE_UNSPECIFIED = 0x0001,
208 CSR_MICHAEL_MIC_ERROR = 0x0002,
209 CSR_DECRYPTION_ERROR = 0x0003,
210 CSR_NO_TEMPORAL_KEY_AVAILABLE = 0x0004,
211 CSR_UNSUPPORTED_MODULATION = 0x0011,
212 CSR_BAD_FCS = 0x0012,
213 CSR_BAD_SIGNAL = 0x0013
214} CSR_RECEPTION_STATUS;
215
216typedef enum CSR_RESULT_CODE
217{
218 CSR_RC_SUCCESS = 0x0000,
219 CSR_RC_UNSPECIFIED_FAILURE = 0x0001,
220 CSR_RC_REFUSED = 0x0003,
221 CSR_RC_INVALID_PARAMETERS = 0x0026,
222 CSR_RC_REJECTED_INVALID_IE = 0x0028,
223 CSR_RC_REJECTED_INVALID_GROUP_CIPHER = 0x0029,
224 CSR_RC_REJECTED_INVALID_PAIRWISE_CIPHER = 0x002a,
225 CSR_RC_TIMEOUT = 0x8000,
226 CSR_RC_TOO_MANY_SIMULTANEOUS_REQUESTS = 0x8001,
227 CSR_RC_BSS_ALREADY_STARTED_OR_JOINED = 0x8002,
228 CSR_RC_NOT_SUPPORTED = 0x8003,
229 CSR_RC_TRANSMISSION_FAILURE = 0x8004,
230 CSR_RC_RESET_REQUIRED_BEFORE_START = 0x8006,
231 CSR_RC_INSUFFICIENT_RESOURCE = 0x8007,
232 CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES = 0x8008,
233 CSR_RC_INVALID_UNICAST_CIPHER = 0xf02f,
234 CSR_RC_INVALID_MULTICAST_CIPHER = 0xf030
235} CSR_RESULT_CODE;
236
237typedef enum CSR_SCAN_TYPE
238{
239 CSR_SC_ACTIVE_SCAN = 0x0000,
240 CSR_SC_PASSIVE_SCAN = 0x0001
241} CSR_SCAN_TYPE;
242
243typedef enum CSR_SIGNAL_ID
244{
245 CSR_MA_PACKET_REQUEST_ID = 0x0110,
246 CSR_MA_PACKET_CONFIRM_ID = 0x0111,
247 CSR_MA_PACKET_INDICATION_ID = 0x0113,
248 CSR_MA_PACKET_CANCEL_REQUEST_ID = 0x0114,
249 CSR_MA_VIF_AVAILABILITY_RESPONSE_ID = 0x0116,
250 CSR_MA_VIF_AVAILABILITY_INDICATION_ID = 0x0117,
251 CSR_MA_PACKET_ERROR_INDICATION_ID = 0x011b,
252 CSR_MLME_RESET_REQUEST_ID = 0x0200,
253 CSR_MLME_RESET_CONFIRM_ID = 0x0201,
254 CSR_MLME_GET_REQUEST_ID = 0x0204,
255 CSR_MLME_GET_CONFIRM_ID = 0x0205,
256 CSR_MLME_SET_REQUEST_ID = 0x0208,
257 CSR_MLME_SET_CONFIRM_ID = 0x0209,
258 CSR_MLME_GET_NEXT_REQUEST_ID = 0x020c,
259 CSR_MLME_GET_NEXT_CONFIRM_ID = 0x020d,
260 CSR_MLME_POWERMGT_REQUEST_ID = 0x0210,
261 CSR_MLME_POWERMGT_CONFIRM_ID = 0x0211,
262 CSR_MLME_SCAN_REQUEST_ID = 0x0214,
263 CSR_MLME_SCAN_CONFIRM_ID = 0x0215,
264 CSR_MLME_HL_SYNC_REQUEST_ID = 0x0244,
265 CSR_MLME_HL_SYNC_CONFIRM_ID = 0x0245,
266 CSR_MLME_MEASURE_REQUEST_ID = 0x0258,
267 CSR_MLME_MEASURE_CONFIRM_ID = 0x0259,
268 CSR_MLME_MEASURE_INDICATION_ID = 0x025b,
269 CSR_MLME_SETKEYS_REQUEST_ID = 0x0268,
270 CSR_MLME_SETKEYS_CONFIRM_ID = 0x0269,
271 CSR_MLME_DELETEKEYS_REQUEST_ID = 0x026c,
272 CSR_MLME_DELETEKEYS_CONFIRM_ID = 0x026d,
273 CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID = 0x0287,
274 CSR_MLME_CONNECTED_INDICATION_ID = 0x028b,
275 CSR_MLME_SCAN_CANCEL_REQUEST_ID = 0x028c,
276 CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID = 0x0298,
277 CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID = 0x0299,
278 CSR_MLME_ADD_PERIODIC_REQUEST_ID = 0x02a0,
279 CSR_MLME_ADD_PERIODIC_CONFIRM_ID = 0x02a1,
280 CSR_MLME_DEL_PERIODIC_REQUEST_ID = 0x02a4,
281 CSR_MLME_DEL_PERIODIC_CONFIRM_ID = 0x02a5,
282 CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID = 0x02a8,
283 CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02a9,
284 CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID = 0x02ac,
285 CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02ad,
286 CSR_MLME_SET_PACKET_FILTER_REQUEST_ID = 0x02b8,
287 CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID = 0x02b9,
288 CSR_MLME_STOP_MEASURE_REQUEST_ID = 0x02bc,
289 CSR_MLME_STOP_MEASURE_CONFIRM_ID = 0x02bd,
290 CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID = 0x02cc,
291 CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02cd,
292 CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID = 0x02db,
293 CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID = 0x02dc,
294 CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID = 0x02dd,
295 CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID = 0x02e0,
296 CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID = 0x02e1,
297 CSR_MLME_TRIGGERED_GET_INDICATION_ID = 0x02e7,
298 CSR_MLME_ADD_BLACKOUT_REQUEST_ID = 0x02f8,
299 CSR_MLME_ADD_BLACKOUT_CONFIRM_ID = 0x02f9,
300 CSR_MLME_BLACKOUT_ENDED_INDICATION_ID = 0x02fb,
301 CSR_MLME_DEL_BLACKOUT_REQUEST_ID = 0x02fc,
302 CSR_MLME_DEL_BLACKOUT_CONFIRM_ID = 0x02fd,
303 CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID = 0x0304,
304 CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID = 0x0305,
305 CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID = 0x0308,
306 CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID = 0x0309,
307 CSR_MLME_CONNECT_STATUS_REQUEST_ID = 0x0310,
308 CSR_MLME_CONNECT_STATUS_CONFIRM_ID = 0x0311,
309 CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID = 0x0314,
310 CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID = 0x0315,
311 CSR_MLME_ADD_TEMPLATE_REQUEST_ID = 0x0318,
312 CSR_MLME_ADD_TEMPLATE_CONFIRM_ID = 0x0319,
313 CSR_MLME_CONFIG_QUEUE_REQUEST_ID = 0x031c,
314 CSR_MLME_CONFIG_QUEUE_CONFIRM_ID = 0x031d,
315 CSR_MLME_ADD_TSPEC_REQUEST_ID = 0x0320,
316 CSR_MLME_ADD_TSPEC_CONFIRM_ID = 0x0321,
317 CSR_MLME_DEL_TSPEC_REQUEST_ID = 0x0324,
318 CSR_MLME_DEL_TSPEC_CONFIRM_ID = 0x0325,
319 CSR_MLME_START_AGGREGATION_REQUEST_ID = 0x0328,
320 CSR_MLME_START_AGGREGATION_CONFIRM_ID = 0x0329,
321 CSR_MLME_BLOCKACK_ERROR_INDICATION_ID = 0x032b,
322 CSR_MLME_STOP_AGGREGATION_REQUEST_ID = 0x032c,
323 CSR_MLME_STOP_AGGREGATION_CONFIRM_ID = 0x032d,
324 CSR_MLME_SM_START_REQUEST_ID = 0x0334,
325 CSR_MLME_SM_START_CONFIRM_ID = 0x0335,
326 CSR_MLME_LEAVE_REQUEST_ID = 0x0338,
327 CSR_MLME_LEAVE_CONFIRM_ID = 0x0339,
328 CSR_MLME_SET_TIM_REQUEST_ID = 0x033c,
329 CSR_MLME_SET_TIM_CONFIRM_ID = 0x033d,
330 CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID = 0x0340,
331 CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID = 0x0341,
332 CSR_MLME_SET_CHANNEL_REQUEST_ID = 0x034c,
333 CSR_MLME_SET_CHANNEL_CONFIRM_ID = 0x034d,
334 CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID = 0x040c,
335 CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID = 0x040d,
336 CSR_DEBUG_STRING_INDICATION_ID = 0x0803,
337 CSR_DEBUG_WORD16_INDICATION_ID = 0x0807,
338 CSR_DEBUG_GENERIC_REQUEST_ID = 0x0808,
339 CSR_DEBUG_GENERIC_CONFIRM_ID = 0x0809,
340 CSR_DEBUG_GENERIC_INDICATION_ID = 0x080b
341} CSR_SIGNAL_ID;
342
343typedef u16 CSR_SIMPLE_POINTER;
344
345typedef u16 CSR_STARTING_SEQUENCE_NUMBER;
346
347typedef enum CSR_SYMBOL_ID
348{
349 CSR_SLT_END = 0x0000,
350 CSR_SLT_PCI_SLOT_CONFIG = 0x0001,
351 CSR_SLT_SDIO_SLOT_CONFIG = 0x0002,
352 CSR_SLT_BUILD_ID_NUMBER = 0x0003,
353 CSR_SLT_BUILD_ID_STRING = 0x0004,
354 CSR_SLT_PERSISTENT_STORE_DB = 0x0005,
355 CSR_SLT_RESET_VECTOR_PHY = 0x0006,
356 CSR_SLT_RESET_VECTOR_MAC = 0x0007,
357 CSR_SLT_SDIO_LOADER_CONTROL = 0x0008,
358 CSR_SLT_TEST_CMD = 0x0009,
359 CSR_SLT_TEST_ALIVE_COUNTER = 0x000a,
360 CSR_SLT_TEST_PARAMETERS = 0x000b,
361 CSR_SLT_TEST_RESULTS = 0x000c,
362 CSR_SLT_TEST_VERSION = 0x000d,
363 CSR_SLT_MIB_PSID_RANGES = 0x000e,
364 CSR_SLT_KIP_TABLE = 0x000f,
365 CSR_SLT_PANIC_DATA_PHY = 0x0010,
366 CSR_SLT_PANIC_DATA_MAC = 0x0011,
367 CSR_SLT_BOOT_LOADER_CONTROL = 0x0012,
368 CSR_SLT_SOFT_MAC = 0x0013
369} CSR_SYMBOL_ID;
370
371typedef struct CSR_TSF_TIME
372{
373 u8 x[8];
374} CSR_TSF_TIME;
375
376typedef u16 CSR_TIME_UNITS;
377
378typedef enum CSR_TRANSMISSION_CONTROL
379{
380 CSR_TRIGGERED = 0x0001,
381 CSR_END_OF_SERVICE = 0x0002,
382 CSR_NO_CONFIRM_REQUIRED = 0x0004,
383 CSR_ALLOW_BA = 0x0008
384} CSR_TRANSMISSION_CONTROL;
385
386typedef enum CSR_TRANSMISSION_STATUS
387{
388 CSR_TX_SUCCESSFUL = 0x0000,
389 CSR_TX_RETRY_LIMIT = 0x0001,
390 CSR_TX_LIFETIME = 0x0002,
391 CSR_TX_NO_BSS = 0x0003,
392 CSR_TX_EXCESSIVE_DATA_LENGTH = 0x0004,
393 CSR_TX_UNSUPPORTED_PRIORITY = 0x0006,
394 CSR_TX_UNAVAILABLE_PRIORITY = 0x0007,
395 CSR_TX_UNAVAILABLE_KEY_MAPPING = 0x000a,
396 CSR_TX_EDCA_TIMEOUT = 0x000b,
397 CSR_TX_BLOCK_ACK_TIMEOUT = 0x000c,
398 CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED = 0x000d,
399 CSR_TX_REJECTED_PEER_STATION_SLEEPING = 0x000e,
400 CSR_TX_REJECTED_DTIM_ENDED = 0x000f,
401 CSR_TX_REJECTED_DTIM_STARTED = 0x0010
402} CSR_TRANSMISSION_STATUS;
403
404typedef u16 CSR_TRIGGER_ID;
405
406typedef u16 CSR_TRIGGERED_ID;
407
408typedef enum CSR_HIP_VERSIONS
409{
410 CSR_HIP_ENG_VERSION = 0x0001,
411 CSR_HIP_VERSION = 0x0900
412} CSR_HIP_VERSIONS;
413
414typedef u16 CSR_BUFFER_HANDLE;
415
416typedef u16 CSR_CHANNEL_NUMBER;
417
418typedef struct CSR_DATA_REFERENCE
419{
420 u16 SlotNumber;
421 u16 DataLength;
422} CSR_DATAREF;
423
424typedef u16 CSR_DIALOG_TOKEN;
425
426typedef struct CSR_GENERIC_POINTER
427{
428 u32 MemoryOffset;
429 CSR_MEMORY_SPACE MemorySpace;
430} CSR_GENERIC_POINTER;
431
432typedef struct CSR_MLME_CONFIG_QUEUE_CONFIRM
433{
434 CSR_DATAREF Dummydataref1;
435 CSR_DATAREF Dummydataref2;
436 CSR_RESULT_CODE ResultCode;
437} CSR_MLME_CONFIG_QUEUE_CONFIRM;
438
439typedef struct CSR_MLME_CONFIG_QUEUE_REQUEST
440{
441 CSR_DATAREF Dummydataref1;
442 CSR_DATAREF Dummydataref2;
443 CSR_NATURAL16 QueueIndex;
444 CSR_NATURAL16 Aifs;
445 CSR_NATURAL16 Cwmin;
446 CSR_NATURAL16 Cwmax;
447 CSR_NATURAL16 TxopLimit;
448} CSR_MLME_CONFIG_QUEUE_REQUEST;
449
450typedef struct CSR_MLME_GET_CONFIRM
451{
452 CSR_DATAREF MibAttributeValue;
453 CSR_DATAREF Dummydataref2;
454 CSR_MIB_STATUS Status;
455 CSR_NATURAL16 ErrorIndex;
456} CSR_MLME_GET_CONFIRM;
457
458typedef struct CSR_MLME_GET_REQUEST
459{
460 CSR_DATAREF MibAttribute;
461 CSR_DATAREF Dummydataref2;
462} CSR_MLME_GET_REQUEST;
463
464typedef struct CSR_MLME_GET_NEXT_CONFIRM
465{
466 CSR_DATAREF MibAttributeValue;
467 CSR_DATAREF Dummydataref2;
468 CSR_MIB_STATUS Status;
469 CSR_NATURAL16 ErrorIndex;
470} CSR_MLME_GET_NEXT_CONFIRM;
471
472typedef struct CSR_MLME_GET_NEXT_REQUEST
473{
474 CSR_DATAREF MibAttribute;
475 CSR_DATAREF Dummydataref2;
476} CSR_MLME_GET_NEXT_REQUEST;
477
478typedef struct CSR_MLME_HL_SYNC_CONFIRM
479{
480 CSR_DATAREF Dummydataref1;
481 CSR_DATAREF Dummydataref2;
482 CSR_MACADDRESS GroupAddress;
483 CSR_RESULT_CODE ResultCode;
484} CSR_MLME_HL_SYNC_CONFIRM;
485
486typedef struct CSR_MLME_HL_SYNC_REQUEST
487{
488 CSR_DATAREF Dummydataref1;
489 CSR_DATAREF Dummydataref2;
490 CSR_MACADDRESS GroupAddress;
491} CSR_MLME_HL_SYNC_REQUEST;
492
493typedef struct CSR_MLME_HL_SYNC_CANCEL_CONFIRM
494{
495 CSR_DATAREF Dummydataref1;
496 CSR_DATAREF Dummydataref2;
497 CSR_RESULT_CODE ResultCode;
498} CSR_MLME_HL_SYNC_CANCEL_CONFIRM;
499
500typedef struct CSR_MLME_HL_SYNC_CANCEL_REQUEST
501{
502 CSR_DATAREF Dummydataref1;
503 CSR_DATAREF Dummydataref2;
504 CSR_MACADDRESS GroupAddress;
505} CSR_MLME_HL_SYNC_CANCEL_REQUEST;
506
507typedef struct CSR_MLME_MEASURE_CONFIRM
508{
509 CSR_DATAREF Dummydataref1;
510 CSR_DATAREF Dummydataref2;
511 CSR_RESULT_CODE ResultCode;
512 CSR_DIALOG_TOKEN DialogToken;
513} CSR_MLME_MEASURE_CONFIRM;
514
515typedef struct CSR_MLME_MEASURE_INDICATION
516{
517 CSR_DATAREF MeasurementReportSet;
518 CSR_DATAREF Dummydataref2;
519 CSR_DIALOG_TOKEN DialogToken;
520} CSR_MLME_MEASURE_INDICATION;
521
522typedef struct CSR_MLME_MEASURE_REQUEST
523{
524 CSR_DATAREF MeasurementRequestSet;
525 CSR_DATAREF Dummydataref2;
526 CSR_DIALOG_TOKEN DialogToken;
527} CSR_MLME_MEASURE_REQUEST;
528
529typedef struct CSR_MLME_RESET_CONFIRM
530{
531 CSR_DATAREF Dummydataref1;
532 CSR_DATAREF Dummydataref2;
533 CSR_RESULT_CODE ResultCode;
534} CSR_MLME_RESET_CONFIRM;
535
536typedef struct CSR_MLME_RESET_REQUEST
537{
538 CSR_DATAREF Dummydataref1;
539 CSR_DATAREF Dummydataref2;
540 CSR_MACADDRESS StaAddress;
541 s16 SetDefaultMib;
542} CSR_MLME_RESET_REQUEST;
543
544typedef struct CSR_MLME_SET_CONFIRM
545{
546 CSR_DATAREF MibAttributeValue;
547 CSR_DATAREF Dummydataref2;
548 CSR_MIB_STATUS Status;
549 CSR_NATURAL16 ErrorIndex;
550} CSR_MLME_SET_CONFIRM;
551
552typedef struct CSR_MLME_SET_REQUEST
553{
554 CSR_DATAREF MibAttributeValue;
555 CSR_DATAREF Dummydataref2;
556} CSR_MLME_SET_REQUEST;
557
558typedef struct CSR_MLME_STOP_MEASURE_CONFIRM
559{
560 CSR_DATAREF Dummydataref1;
561 CSR_DATAREF Dummydataref2;
562 CSR_RESULT_CODE ResultCode;
563 CSR_DIALOG_TOKEN DialogToken;
564} CSR_MLME_STOP_MEASURE_CONFIRM;
565
566typedef struct CSR_MLME_STOP_MEASURE_REQUEST
567{
568 CSR_DATAREF Dummydataref1;
569 CSR_DATAREF Dummydataref2;
570 CSR_DIALOG_TOKEN DialogToken;
571} CSR_MLME_STOP_MEASURE_REQUEST;
572
573typedef u16 CSR_PROCESS_ID;
574
575typedef u16 CSR_RATE;
576
577typedef u16 CSR_SEQUENCE_NUMBER;
578
579typedef struct CSR_SIGNAL_PRIMITIVE_HEADER
580{
581 s16 SignalId;
582 CSR_PROCESS_ID ReceiverProcessId;
583 CSR_PROCESS_ID SenderProcessId;
584} CSR_SIGNAL_PRIMITIVE_HEADER;
585
586typedef u16 CSR_TRAFFIC_WINDOW;
587
588typedef u16 CSR_VIF_IDENTIFIER;
589
590typedef struct CSR_DEBUG_GENERIC_CONFIRM
591{
592 CSR_DATAREF DebugVariable;
593 CSR_DATAREF Dummydataref2;
594 CSR_NATURAL16 DebugWords[8];
595} CSR_DEBUG_GENERIC_CONFIRM;
596
597typedef struct CSR_DEBUG_GENERIC_INDICATION
598{
599 CSR_DATAREF DebugVariable;
600 CSR_DATAREF Dummydataref2;
601 CSR_NATURAL16 DebugWords[8];
602} CSR_DEBUG_GENERIC_INDICATION;
603
604typedef struct CSR_DEBUG_GENERIC_REQUEST
605{
606 CSR_DATAREF DebugVariable;
607 CSR_DATAREF Dummydataref2;
608 CSR_NATURAL16 DebugWords[8];
609} CSR_DEBUG_GENERIC_REQUEST;
610
611typedef struct CSR_DEBUG_STRING_INDICATION
612{
613 CSR_DATAREF DebugMessage;
614 CSR_DATAREF Dummydataref2;
615} CSR_DEBUG_STRING_INDICATION;
616
617typedef struct CSR_DEBUG_WORD16_INDICATION
618{
619 CSR_DATAREF Dummydataref1;
620 CSR_DATAREF Dummydataref2;
621 CSR_NATURAL16 DebugWords[16];
622} CSR_DEBUG_WORD16_INDICATION;
623
624typedef struct CSR_MA_PACKET_CONFIRM
625{
626 CSR_DATAREF Dummydataref1;
627 CSR_DATAREF Dummydataref2;
628 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
629 CSR_TRANSMISSION_STATUS TransmissionStatus;
630 CSR_NATURAL16 RetryCount;
631 CSR_RATE Rate;
632 CSR_CLIENT_TAG HostTag;
633} CSR_MA_PACKET_CONFIRM;
634
635typedef struct CSR_MA_PACKET_INDICATION
636{
637 CSR_DATAREF Data;
638 CSR_DATAREF Dummydataref2;
639 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
640 CSR_TSF_TIME LocalTime;
641 CSR_IFINTERFACE Ifindex;
642 CSR_CHANNEL_NUMBER Channel;
643 CSR_RECEPTION_STATUS ReceptionStatus;
644 CSR_DECIBELS Rssi;
645 CSR_DECIBELS Snr;
646 CSR_RATE ReceivedRate;
647} CSR_MA_PACKET_INDICATION;
648
649typedef struct CSR_MA_PACKET_REQUEST
650{
651 CSR_DATAREF Data;
652 CSR_DATAREF Dummydataref2;
653 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
654 CSR_RATE TransmitRate;
655 CSR_CLIENT_TAG HostTag;
656 CSR_PRIORITY Priority;
657 CSR_MACADDRESS Ra;
658 CSR_TRANSMISSION_CONTROL TransmissionControl;
659} CSR_MA_PACKET_REQUEST;
660
661typedef struct CSR_MA_PACKET_CANCEL_REQUEST
662{
663 CSR_DATAREF Dummydataref1;
664 CSR_DATAREF Dummydataref2;
665 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
666 CSR_CLIENT_TAG HostTag;
667} CSR_MA_PACKET_CANCEL_REQUEST;
668
669typedef struct CSR_MA_PACKET_ERROR_INDICATION
670{
671 CSR_DATAREF Dummydataref1;
672 CSR_DATAREF Dummydataref2;
673 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
674 CSR_MACADDRESS PeerQstaAddress;
675 CSR_PRIORITY UserPriority;
676 CSR_SEQUENCE_NUMBER SequenceNumber;
677} CSR_MA_PACKET_ERROR_INDICATION;
678
679typedef struct CSR_MA_VIF_AVAILABILITY_INDICATION
680{
681 CSR_DATAREF Dummydataref1;
682 CSR_DATAREF Dummydataref2;
683 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
684 s16 Multicast;
685} CSR_MA_VIF_AVAILABILITY_INDICATION;
686
687typedef struct CSR_MA_VIF_AVAILABILITY_RESPONSE
688{
689 CSR_DATAREF Dummydataref1;
690 CSR_DATAREF Dummydataref2;
691 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
692 CSR_RESULT_CODE ResultCode;
693} CSR_MA_VIF_AVAILABILITY_RESPONSE;
694
695typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM
696{
697 CSR_DATAREF Dummydataref1;
698 CSR_DATAREF Dummydataref2;
699 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
700 CSR_RESULT_CODE ResultCode;
701 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
702} CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM;
703
704typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST
705{
706 CSR_DATAREF ChannelList;
707 CSR_DATAREF InformationElements;
708 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
709 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
710 CSR_IFINTERFACE Ifindex;
711 CSR_CHANNEL_STARTING_FACTOR ChannelStartingFactor;
712 CSR_SCAN_TYPE ScanType;
713 CSR_MICROSECONDS32 ProbeDelay;
714 CSR_TIME_UNITS MinChannelTime;
715 CSR_TIME_UNITS MaxChannelTime;
716} CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST;
717
718typedef struct CSR_MLME_ADD_BLACKOUT_CONFIRM
719{
720 CSR_DATAREF Dummydataref1;
721 CSR_DATAREF Dummydataref2;
722 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
723 CSR_BLACKOUT_ID BlackoutId;
724 CSR_RESULT_CODE ResultCode;
725} CSR_MLME_ADD_BLACKOUT_CONFIRM;
726
727typedef struct CSR_MLME_ADD_BLACKOUT_REQUEST
728{
729 CSR_DATAREF Dummydataref1;
730 CSR_DATAREF Dummydataref2;
731 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
732 CSR_BLACKOUT_ID BlackoutId;
733 CSR_BLACKOUT_TYPE BlackoutType;
734 CSR_BLACKOUT_SOURCE BlackoutSource;
735 CSR_MICROSECONDS32 BlackoutStartReference;
736 CSR_MICROSECONDS32 BlackoutPeriod;
737 CSR_MICROSECONDS32 BlackoutDuration;
738 CSR_MACADDRESS PeerStaAddress;
739 CSR_NATURAL16 BlackoutCount;
740} CSR_MLME_ADD_BLACKOUT_REQUEST;
741
742typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM
743{
744 CSR_DATAREF Dummydataref1;
745 CSR_DATAREF Dummydataref2;
746 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
747 CSR_RESULT_CODE ResultCode;
748} CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM;
749
750typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST
751{
752 CSR_DATAREF Data;
753 CSR_DATAREF Dummydataref2;
754 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
755 CSR_NATURAL16 NumberOfMulticastGroupAddresses;
756} CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST;
757
758typedef struct CSR_MLME_ADD_PERIODIC_CONFIRM
759{
760 CSR_DATAREF Dummydataref1;
761 CSR_DATAREF Dummydataref2;
762 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
763 CSR_PERIODIC_ID PeriodicId;
764 CSR_RESULT_CODE ResultCode;
765} CSR_MLME_ADD_PERIODIC_CONFIRM;
766
767typedef struct CSR_MLME_ADD_PERIODIC_REQUEST
768{
769 CSR_DATAREF Dummydataref1;
770 CSR_DATAREF Dummydataref2;
771 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
772 CSR_PERIODIC_ID PeriodicId;
773 CSR_MICROSECONDS32 MaximumLatency;
774 CSR_PERIODIC_SCHEDULING_MODE PeriodicSchedulingMode;
775 s16 WakeHost;
776 CSR_PRIORITY UserPriority;
777} CSR_MLME_ADD_PERIODIC_REQUEST;
778
779typedef struct CSR_MLME_ADD_RX_TRIGGER_CONFIRM
780{
781 CSR_DATAREF Dummydataref1;
782 CSR_DATAREF Dummydataref2;
783 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
784 CSR_TRIGGER_ID TriggerId;
785 CSR_RESULT_CODE ResultCode;
786} CSR_MLME_ADD_RX_TRIGGER_CONFIRM;
787
788typedef struct CSR_MLME_ADD_RX_TRIGGER_REQUEST
789{
790 CSR_DATAREF InformationElements;
791 CSR_DATAREF Dummydataref2;
792 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
793 CSR_TRIGGER_ID TriggerId;
794 CSR_PRIORITY Priority;
795} CSR_MLME_ADD_RX_TRIGGER_REQUEST;
796
797typedef struct CSR_MLME_ADD_TEMPLATE_CONFIRM
798{
799 CSR_DATAREF Dummydataref1;
800 CSR_DATAREF Dummydataref2;
801 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
802 CSR_FRAME_TYPE FrameType;
803 CSR_RESULT_CODE ResultCode;
804} CSR_MLME_ADD_TEMPLATE_CONFIRM;
805
806typedef struct CSR_MLME_ADD_TEMPLATE_REQUEST
807{
808 CSR_DATAREF Data1;
809 CSR_DATAREF Data2;
810 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
811 CSR_FRAME_TYPE FrameType;
812 CSR_RATE MinTransmitRate;
813} CSR_MLME_ADD_TEMPLATE_REQUEST;
814
815typedef struct CSR_MLME_ADD_TRIGGERED_GET_CONFIRM
816{
817 CSR_DATAREF Dummydataref1;
818 CSR_DATAREF Dummydataref2;
819 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
820 CSR_RESULT_CODE ResultCode;
821 CSR_TRIGGERED_ID TriggeredId;
822} CSR_MLME_ADD_TRIGGERED_GET_CONFIRM;
823
824typedef struct CSR_MLME_ADD_TRIGGERED_GET_REQUEST
825{
826 CSR_DATAREF MibAttribute;
827 CSR_DATAREF Dummydataref2;
828 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
829 CSR_TRIGGERED_ID TriggeredId;
830} CSR_MLME_ADD_TRIGGERED_GET_REQUEST;
831
832typedef struct CSR_MLME_ADD_TSPEC_CONFIRM
833{
834 CSR_DATAREF Dummydataref1;
835 CSR_DATAREF Dummydataref2;
836 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
837 CSR_PRIORITY UserPriority;
838 CSR_RESULT_CODE ResultCode;
839} CSR_MLME_ADD_TSPEC_CONFIRM;
840
841typedef struct CSR_MLME_ADD_TSPEC_REQUEST
842{
843 CSR_DATAREF Dummydataref1;
844 CSR_DATAREF Dummydataref2;
845 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
846 CSR_PRIORITY UserPriority;
847 CSR_DIRECTION Direction;
848 CSR_PS_SCHEME PsScheme;
849 CSR_NATURAL16 MediumTime;
850 CSR_MICROSECONDS32 ServiceStartTime;
851 CSR_MICROSECONDS32 ServiceInterval;
852 CSR_RATE MinimumDataRate;
853} CSR_MLME_ADD_TSPEC_REQUEST;
854
855typedef struct CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION
856{
857 CSR_DATAREF Dummydataref1;
858 CSR_DATAREF Dummydataref2;
859 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
860 CSR_RESULT_CODE ResultCode;
861 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
862} CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION;
863
864typedef struct CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION
865{
866 CSR_DATAREF Dummydataref1;
867 CSR_DATAREF Dummydataref2;
868 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
869 CSR_MACADDRESS Bssid;
870} CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION;
871
872typedef struct CSR_MLME_BLACKOUT_ENDED_INDICATION
873{
874 CSR_DATAREF Dummydataref1;
875 CSR_DATAREF Dummydataref2;
876 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
877 CSR_BLACKOUT_ID BlackoutId;
878} CSR_MLME_BLACKOUT_ENDED_INDICATION;
879
880typedef struct CSR_MLME_BLOCKACK_ERROR_INDICATION
881{
882 CSR_DATAREF Dummydataref1;
883 CSR_DATAREF Dummydataref2;
884 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
885 CSR_REASON_CODE ResultCode;
886 CSR_MACADDRESS PeerQstaAddress;
887} CSR_MLME_BLOCKACK_ERROR_INDICATION;
888
889typedef struct CSR_MLME_CONNECTED_INDICATION
890{
891 CSR_DATAREF Dummydataref1;
892 CSR_DATAREF Dummydataref2;
893 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
894 CSR_CONNECTION_STATUS ConnectionStatus;
895 CSR_MACADDRESS PeerMacAddress;
896} CSR_MLME_CONNECTED_INDICATION;
897
898typedef struct CSR_MLME_CONNECT_STATUS_CONFIRM
899{
900 CSR_DATAREF Dummydataref1;
901 CSR_DATAREF Dummydataref2;
902 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
903 CSR_RESULT_CODE ResultCode;
904} CSR_MLME_CONNECT_STATUS_CONFIRM;
905
906typedef struct CSR_MLME_CONNECT_STATUS_REQUEST
907{
908 CSR_DATAREF InformationElements;
909 CSR_DATAREF Dummydataref2;
910 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
911 CSR_CONNECTION_STATUS ConnectionStatus;
912 CSR_MACADDRESS StaAddress;
913 CSR_ASSOCIATION_ID AssociationId;
914 CSR_CAPABILITY_INFORMATION AssociationCapabilityInformation;
915} CSR_MLME_CONNECT_STATUS_REQUEST;
916
917typedef struct CSR_MLME_DELETEKEYS_CONFIRM
918{
919 CSR_DATAREF Dummydataref1;
920 CSR_DATAREF Dummydataref2;
921 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
922 CSR_RESULT_CODE ResultCode;
923} CSR_MLME_DELETEKEYS_CONFIRM;
924
925typedef struct CSR_MLME_DELETEKEYS_REQUEST
926{
927 CSR_DATAREF Dummydataref1;
928 CSR_DATAREF Dummydataref2;
929 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
930 CSR_NATURAL16 KeyId;
931 CSR_KEY_TYPE KeyType;
932 CSR_MACADDRESS Address;
933} CSR_MLME_DELETEKEYS_REQUEST;
934
935typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM
936{
937 CSR_DATAREF Dummydataref1;
938 CSR_DATAREF Dummydataref2;
939 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
940 CSR_RESULT_CODE ResultCode;
941 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
942} CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM;
943
944typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST
945{
946 CSR_DATAREF Dummydataref1;
947 CSR_DATAREF Dummydataref2;
948 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
949 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
950} CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST;
951
952typedef struct CSR_MLME_DEL_BLACKOUT_CONFIRM
953{
954 CSR_DATAREF Dummydataref1;
955 CSR_DATAREF Dummydataref2;
956 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
957 CSR_BLACKOUT_ID BlackoutId;
958 CSR_RESULT_CODE ResultCode;
959} CSR_MLME_DEL_BLACKOUT_CONFIRM;
960
961typedef struct CSR_MLME_DEL_BLACKOUT_REQUEST
962{
963 CSR_DATAREF Dummydataref1;
964 CSR_DATAREF Dummydataref2;
965 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
966 CSR_BLACKOUT_ID BlackoutId;
967} CSR_MLME_DEL_BLACKOUT_REQUEST;
968
969typedef struct CSR_MLME_DEL_PERIODIC_CONFIRM
970{
971 CSR_DATAREF Dummydataref1;
972 CSR_DATAREF Dummydataref2;
973 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
974 CSR_PERIODIC_ID PeriodicId;
975 CSR_RESULT_CODE ResultCode;
976} CSR_MLME_DEL_PERIODIC_CONFIRM;
977
978typedef struct CSR_MLME_DEL_PERIODIC_REQUEST
979{
980 CSR_DATAREF Dummydataref1;
981 CSR_DATAREF Dummydataref2;
982 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
983 CSR_PERIODIC_ID PeriodicId;
984} CSR_MLME_DEL_PERIODIC_REQUEST;
985
986typedef struct CSR_MLME_DEL_RX_TRIGGER_CONFIRM
987{
988 CSR_DATAREF Dummydataref1;
989 CSR_DATAREF Dummydataref2;
990 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
991 CSR_TRIGGER_ID TriggerId;
992 CSR_RESULT_CODE ResultCode;
993} CSR_MLME_DEL_RX_TRIGGER_CONFIRM;
994
995typedef struct CSR_MLME_DEL_RX_TRIGGER_REQUEST
996{
997 CSR_DATAREF Dummydataref1;
998 CSR_DATAREF Dummydataref2;
999 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1000 CSR_TRIGGER_ID TriggerId;
1001} CSR_MLME_DEL_RX_TRIGGER_REQUEST;
1002
1003typedef struct CSR_MLME_DEL_TRIGGERED_GET_CONFIRM
1004{
1005 CSR_DATAREF Dummydataref1;
1006 CSR_DATAREF Dummydataref2;
1007 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1008 CSR_RESULT_CODE ResultCode;
1009 CSR_TRIGGERED_ID TriggeredId;
1010} CSR_MLME_DEL_TRIGGERED_GET_CONFIRM;
1011
1012typedef struct CSR_MLME_DEL_TRIGGERED_GET_REQUEST
1013{
1014 CSR_DATAREF Dummydataref1;
1015 CSR_DATAREF Dummydataref2;
1016 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1017 CSR_TRIGGERED_ID TriggeredId;
1018} CSR_MLME_DEL_TRIGGERED_GET_REQUEST;
1019
1020typedef struct CSR_MLME_DEL_TSPEC_CONFIRM
1021{
1022 CSR_DATAREF Dummydataref1;
1023 CSR_DATAREF Dummydataref2;
1024 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1025 CSR_PRIORITY UserPriority;
1026 CSR_RESULT_CODE ResultCode;
1027} CSR_MLME_DEL_TSPEC_CONFIRM;
1028
1029typedef struct CSR_MLME_DEL_TSPEC_REQUEST
1030{
1031 CSR_DATAREF Dummydataref1;
1032 CSR_DATAREF Dummydataref2;
1033 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1034 CSR_PRIORITY UserPriority;
1035 CSR_DIRECTION Direction;
1036} CSR_MLME_DEL_TSPEC_REQUEST;
1037
1038typedef struct CSR_MLME_GET_KEY_SEQUENCE_CONFIRM
1039{
1040 CSR_DATAREF Dummydataref1;
1041 CSR_DATAREF Dummydataref2;
1042 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1043 CSR_RESULT_CODE ResultCode;
1044 CSR_NATURAL16 SequenceNumber[8];
1045} CSR_MLME_GET_KEY_SEQUENCE_CONFIRM;
1046
1047typedef struct CSR_MLME_GET_KEY_SEQUENCE_REQUEST
1048{
1049 CSR_DATAREF Dummydataref1;
1050 CSR_DATAREF Dummydataref2;
1051 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1052 CSR_NATURAL16 KeyId;
1053 CSR_KEY_TYPE KeyType;
1054 CSR_MACADDRESS Address;
1055} CSR_MLME_GET_KEY_SEQUENCE_REQUEST;
1056
1057typedef struct CSR_MLME_LEAVE_CONFIRM
1058{
1059 CSR_DATAREF Dummydataref1;
1060 CSR_DATAREF Dummydataref2;
1061 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1062 CSR_RESULT_CODE ResultCode;
1063} CSR_MLME_LEAVE_CONFIRM;
1064
1065typedef struct CSR_MLME_LEAVE_REQUEST
1066{
1067 CSR_DATAREF Dummydataref1;
1068 CSR_DATAREF Dummydataref2;
1069 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1070} CSR_MLME_LEAVE_REQUEST;
1071
1072typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM
1073{
1074 CSR_DATAREF Dummydataref1;
1075 CSR_DATAREF Dummydataref2;
1076 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1077 CSR_RESULT_CODE ResultCode;
1078} CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM;
1079
1080typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST
1081{
1082 CSR_DATAREF Data;
1083 CSR_DATAREF Dummydataref2;
1084 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1085 CSR_TIME_UNITS BeaconPeriod;
1086 CSR_BEACON_PERIODS DtimPeriod;
1087 CSR_CAPABILITY_INFORMATION CapabilityInformation;
1088 CSR_MACADDRESS Bssid;
1089 CSR_NATURAL16 RtsThreshold;
1090} CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST;
1091
1092typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM
1093{
1094 CSR_DATAREF Dummydataref1;
1095 CSR_DATAREF Dummydataref2;
1096 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1097 CSR_RESULT_CODE ResultCode;
1098 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
1099} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM;
1100
1101typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST
1102{
1103 CSR_DATAREF Dummydataref1;
1104 CSR_DATAREF Dummydataref2;
1105 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1106 CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
1107 s16 Pause;
1108} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST;
1109
1110typedef struct CSR_MLME_POWERMGT_CONFIRM
1111{
1112 CSR_DATAREF Dummydataref1;
1113 CSR_DATAREF Dummydataref2;
1114 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1115 CSR_RESULT_CODE ResultCode;
1116} CSR_MLME_POWERMGT_CONFIRM;
1117
1118typedef struct CSR_MLME_POWERMGT_REQUEST
1119{
1120 CSR_DATAREF Dummydataref1;
1121 CSR_DATAREF Dummydataref2;
1122 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1123 CSR_POWER_MANAGEMENT_MODE PowerManagementMode;
1124 s16 ReceiveDtims;
1125 CSR_BEACON_PERIODS ListenInterval;
1126 CSR_TRAFFIC_WINDOW TrafficWindow;
1127} CSR_MLME_POWERMGT_REQUEST;
1128
1129typedef struct CSR_MLME_SCAN_CONFIRM
1130{
1131 CSR_DATAREF Dummydataref1;
1132 CSR_DATAREF Dummydataref2;
1133 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1134 CSR_RESULT_CODE ResultCode;
1135} CSR_MLME_SCAN_CONFIRM;
1136
1137typedef struct CSR_MLME_SCAN_REQUEST
1138{
1139 CSR_DATAREF ChannelList;
1140 CSR_DATAREF InformationElements;
1141 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1142 CSR_IFINTERFACE Ifindex;
1143 CSR_SCAN_TYPE ScanType;
1144 CSR_MICROSECONDS32 ProbeDelay;
1145 CSR_TIME_UNITS MinChannelTime;
1146 CSR_TIME_UNITS MaxChannelTime;
1147} CSR_MLME_SCAN_REQUEST;
1148
1149typedef struct CSR_MLME_SCAN_CANCEL_REQUEST
1150{
1151 CSR_DATAREF Dummydataref1;
1152 CSR_DATAREF Dummydataref2;
1153 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1154} CSR_MLME_SCAN_CANCEL_REQUEST;
1155
1156typedef struct CSR_MLME_SETKEYS_CONFIRM
1157{
1158 CSR_DATAREF Dummydataref1;
1159 CSR_DATAREF Dummydataref2;
1160 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1161 CSR_RESULT_CODE ResultCode;
1162} CSR_MLME_SETKEYS_CONFIRM;
1163
1164typedef struct CSR_MLME_SETKEYS_REQUEST
1165{
1166 CSR_DATAREF Key;
1167 CSR_DATAREF Dummydataref2;
1168 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1169 CSR_NATURAL16 Length;
1170 CSR_NATURAL16 KeyId;
1171 CSR_KEY_TYPE KeyType;
1172 CSR_MACADDRESS Address;
1173 CSR_NATURAL16 SequenceNumber[8];
1174 CSR_CIPHER_SUITE_SELECTOR CipherSuiteSelector;
1175} CSR_MLME_SETKEYS_REQUEST;
1176
1177typedef struct CSR_MLME_SET_CHANNEL_CONFIRM
1178{
1179 CSR_DATAREF Dummydataref1;
1180 CSR_DATAREF Dummydataref2;
1181 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1182 CSR_RESULT_CODE ResultCode;
1183} CSR_MLME_SET_CHANNEL_CONFIRM;
1184
1185typedef struct CSR_MLME_SET_CHANNEL_REQUEST
1186{
1187 CSR_DATAREF Dummydataref1;
1188 CSR_DATAREF Dummydataref2;
1189 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1190 CSR_IFINTERFACE Ifindex;
1191 CSR_CHANNEL_NUMBER Channel;
1192 CSR_MACADDRESS Address;
1193 CSR_TIME_UNITS AvailabilityDuration;
1194 CSR_TIME_UNITS AvailabilityInterval;
1195} CSR_MLME_SET_CHANNEL_REQUEST;
1196
1197typedef struct CSR_MLME_SET_PACKET_FILTER_CONFIRM
1198{
1199 CSR_DATAREF Dummydataref1;
1200 CSR_DATAREF Dummydataref2;
1201 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1202 CSR_RESULT_CODE ResultCode;
1203} CSR_MLME_SET_PACKET_FILTER_CONFIRM;
1204
1205typedef struct CSR_MLME_SET_PACKET_FILTER_REQUEST
1206{
1207 CSR_DATAREF InformationElements;
1208 CSR_DATAREF Dummydataref2;
1209 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1210 CSR_PACKET_FILTER_MODE PacketFilterMode;
1211 CSR_IPV4_ADDRESS ArpFilterAddress;
1212} CSR_MLME_SET_PACKET_FILTER_REQUEST;
1213
1214typedef struct CSR_MLME_SET_TIM_CONFIRM
1215{
1216 CSR_DATAREF Dummydataref1;
1217 CSR_DATAREF Dummydataref2;
1218 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1219 CSR_RESULT_CODE ResultCode;
1220} CSR_MLME_SET_TIM_CONFIRM;
1221
1222typedef struct CSR_MLME_SET_TIM_REQUEST
1223{
1224 CSR_DATAREF Dummydataref1;
1225 CSR_DATAREF Dummydataref2;
1226 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1227 CSR_ASSOCIATION_ID AssociationId;
1228 s16 TimValue;
1229} CSR_MLME_SET_TIM_REQUEST;
1230
1231typedef struct CSR_MLME_SM_START_CONFIRM
1232{
1233 CSR_DATAREF Dummydataref1;
1234 CSR_DATAREF Dummydataref2;
1235 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1236 CSR_RESULT_CODE ResultCode;
1237} CSR_MLME_SM_START_CONFIRM;
1238
1239typedef struct CSR_MLME_SM_START_REQUEST
1240{
1241 CSR_DATAREF Beacon;
1242 CSR_DATAREF BssParameters;
1243 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1244 CSR_IFINTERFACE Ifindex;
1245 CSR_CHANNEL_NUMBER Channel;
1246 CSR_MACADDRESS InterfaceAddress;
1247 CSR_MACADDRESS Bssid;
1248 CSR_TIME_UNITS BeaconPeriod;
1249 CSR_BEACON_PERIODS DtimPeriod;
1250 CSR_CAPABILITY_INFORMATION CapabilityInformation;
1251} CSR_MLME_SM_START_REQUEST;
1252
1253typedef struct CSR_MLME_START_AGGREGATION_CONFIRM
1254{
1255 CSR_DATAREF Dummydataref1;
1256 CSR_DATAREF Dummydataref2;
1257 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1258 CSR_MACADDRESS PeerQstaAddress;
1259 CSR_PRIORITY UserPriority;
1260 CSR_DIRECTION Direction;
1261 CSR_RESULT_CODE ResultCode;
1262 CSR_SEQUENCE_NUMBER SequenceNumber;
1263} CSR_MLME_START_AGGREGATION_CONFIRM;
1264
1265typedef struct CSR_MLME_START_AGGREGATION_REQUEST
1266{
1267 CSR_DATAREF Dummydataref1;
1268 CSR_DATAREF Dummydataref2;
1269 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1270 CSR_MACADDRESS PeerQstaAddress;
1271 CSR_PRIORITY UserPriority;
1272 CSR_DIRECTION Direction;
1273 CSR_STARTING_SEQUENCE_NUMBER StartingSequenceNumber;
1274 CSR_NATURAL16 BufferSize;
1275 CSR_TIME_UNITS BlockAckTimeout;
1276} CSR_MLME_START_AGGREGATION_REQUEST;
1277
1278typedef struct CSR_MLME_STOP_AGGREGATION_CONFIRM
1279{
1280 CSR_DATAREF Dummydataref1;
1281 CSR_DATAREF Dummydataref2;
1282 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1283 CSR_MACADDRESS PeerQstaAddress;
1284 CSR_PRIORITY UserPriority;
1285 CSR_DIRECTION Direction;
1286 CSR_RESULT_CODE ResultCode;
1287} CSR_MLME_STOP_AGGREGATION_CONFIRM;
1288
1289typedef struct CSR_MLME_STOP_AGGREGATION_REQUEST
1290{
1291 CSR_DATAREF Dummydataref1;
1292 CSR_DATAREF Dummydataref2;
1293 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1294 CSR_MACADDRESS PeerQstaAddress;
1295 CSR_PRIORITY UserPriority;
1296 CSR_DIRECTION Direction;
1297} CSR_MLME_STOP_AGGREGATION_REQUEST;
1298
1299typedef struct CSR_MLME_TRIGGERED_GET_INDICATION
1300{
1301 CSR_DATAREF MibAttributeValue;
1302 CSR_DATAREF Dummydataref2;
1303 CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
1304 CSR_MIB_STATUS Status;
1305 CSR_NATURAL16 ErrorIndex;
1306 CSR_TRIGGERED_ID TriggeredId;
1307} CSR_MLME_TRIGGERED_GET_INDICATION;
1308
1309typedef struct CSR_SIGNAL_PRIMITIVE
1310{
1311 CSR_SIGNAL_PRIMITIVE_HEADER SignalPrimitiveHeader;
1312 union
1313 {
1314 CSR_MA_PACKET_REQUEST MaPacketRequest;
1315 CSR_MA_PACKET_CONFIRM MaPacketConfirm;
1316 CSR_MA_PACKET_INDICATION MaPacketIndication;
1317 CSR_MA_PACKET_CANCEL_REQUEST MaPacketCancelRequest;
1318 CSR_MA_VIF_AVAILABILITY_RESPONSE MaVifAvailabilityResponse;
1319 CSR_MA_VIF_AVAILABILITY_INDICATION MaVifAvailabilityIndication;
1320 CSR_MA_PACKET_ERROR_INDICATION MaPacketErrorIndication;
1321 CSR_MLME_RESET_REQUEST MlmeResetRequest;
1322 CSR_MLME_RESET_CONFIRM MlmeResetConfirm;
1323 CSR_MLME_GET_REQUEST MlmeGetRequest;
1324 CSR_MLME_GET_CONFIRM MlmeGetConfirm;
1325 CSR_MLME_SET_REQUEST MlmeSetRequest;
1326 CSR_MLME_SET_CONFIRM MlmeSetConfirm;
1327 CSR_MLME_GET_NEXT_REQUEST MlmeGetNextRequest;
1328 CSR_MLME_GET_NEXT_CONFIRM MlmeGetNextConfirm;
1329 CSR_MLME_POWERMGT_REQUEST MlmePowermgtRequest;
1330 CSR_MLME_POWERMGT_CONFIRM MlmePowermgtConfirm;
1331 CSR_MLME_SCAN_REQUEST MlmeScanRequest;
1332 CSR_MLME_SCAN_CONFIRM MlmeScanConfirm;
1333 CSR_MLME_HL_SYNC_REQUEST MlmeHlSyncRequest;
1334 CSR_MLME_HL_SYNC_CONFIRM MlmeHlSyncConfirm;
1335 CSR_MLME_MEASURE_REQUEST MlmeMeasureRequest;
1336 CSR_MLME_MEASURE_CONFIRM MlmeMeasureConfirm;
1337 CSR_MLME_MEASURE_INDICATION MlmeMeasureIndication;
1338 CSR_MLME_SETKEYS_REQUEST MlmeSetkeysRequest;
1339 CSR_MLME_SETKEYS_CONFIRM MlmeSetkeysConfirm;
1340 CSR_MLME_DELETEKEYS_REQUEST MlmeDeletekeysRequest;
1341 CSR_MLME_DELETEKEYS_CONFIRM MlmeDeletekeysConfirm;
1342 CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION MlmeAutonomousScanLossIndication;
1343 CSR_MLME_CONNECTED_INDICATION MlmeConnectedIndication;
1344 CSR_MLME_SCAN_CANCEL_REQUEST MlmeScanCancelRequest;
1345 CSR_MLME_HL_SYNC_CANCEL_REQUEST MlmeHlSyncCancelRequest;
1346 CSR_MLME_HL_SYNC_CANCEL_CONFIRM MlmeHlSyncCancelConfirm;
1347 CSR_MLME_ADD_PERIODIC_REQUEST MlmeAddPeriodicRequest;
1348 CSR_MLME_ADD_PERIODIC_CONFIRM MlmeAddPeriodicConfirm;
1349 CSR_MLME_DEL_PERIODIC_REQUEST MlmeDelPeriodicRequest;
1350 CSR_MLME_DEL_PERIODIC_CONFIRM MlmeDelPeriodicConfirm;
1351 CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST MlmeAddAutonomousScanRequest;
1352 CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM MlmeAddAutonomousScanConfirm;
1353 CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST MlmeDelAutonomousScanRequest;
1354 CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM MlmeDelAutonomousScanConfirm;
1355 CSR_MLME_SET_PACKET_FILTER_REQUEST MlmeSetPacketFilterRequest;
1356 CSR_MLME_SET_PACKET_FILTER_CONFIRM MlmeSetPacketFilterConfirm;
1357 CSR_MLME_STOP_MEASURE_REQUEST MlmeStopMeasureRequest;
1358 CSR_MLME_STOP_MEASURE_CONFIRM MlmeStopMeasureConfirm;
1359 CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST MlmePauseAutonomousScanRequest;
1360 CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM MlmePauseAutonomousScanConfirm;
1361 CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION MlmeAutonomousScanDoneIndication;
1362 CSR_MLME_ADD_TRIGGERED_GET_REQUEST MlmeAddTriggeredGetRequest;
1363 CSR_MLME_ADD_TRIGGERED_GET_CONFIRM MlmeAddTriggeredGetConfirm;
1364 CSR_MLME_DEL_TRIGGERED_GET_REQUEST MlmeDelTriggeredGetRequest;
1365 CSR_MLME_DEL_TRIGGERED_GET_CONFIRM MlmeDelTriggeredGetConfirm;
1366 CSR_MLME_TRIGGERED_GET_INDICATION MlmeTriggeredGetIndication;
1367 CSR_MLME_ADD_BLACKOUT_REQUEST MlmeAddBlackoutRequest;
1368 CSR_MLME_ADD_BLACKOUT_CONFIRM MlmeAddBlackoutConfirm;
1369 CSR_MLME_BLACKOUT_ENDED_INDICATION MlmeBlackoutEndedIndication;
1370 CSR_MLME_DEL_BLACKOUT_REQUEST MlmeDelBlackoutRequest;
1371 CSR_MLME_DEL_BLACKOUT_CONFIRM MlmeDelBlackoutConfirm;
1372 CSR_MLME_ADD_RX_TRIGGER_REQUEST MlmeAddRxTriggerRequest;
1373 CSR_MLME_ADD_RX_TRIGGER_CONFIRM MlmeAddRxTriggerConfirm;
1374 CSR_MLME_DEL_RX_TRIGGER_REQUEST MlmeDelRxTriggerRequest;
1375 CSR_MLME_DEL_RX_TRIGGER_CONFIRM MlmeDelRxTriggerConfirm;
1376 CSR_MLME_CONNECT_STATUS_REQUEST MlmeConnectStatusRequest;
1377 CSR_MLME_CONNECT_STATUS_CONFIRM MlmeConnectStatusConfirm;
1378 CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST MlmeModifyBssParameterRequest;
1379 CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM MlmeModifyBssParameterConfirm;
1380 CSR_MLME_ADD_TEMPLATE_REQUEST MlmeAddTemplateRequest;
1381 CSR_MLME_ADD_TEMPLATE_CONFIRM MlmeAddTemplateConfirm;
1382 CSR_MLME_CONFIG_QUEUE_REQUEST MlmeConfigQueueRequest;
1383 CSR_MLME_CONFIG_QUEUE_CONFIRM MlmeConfigQueueConfirm;
1384 CSR_MLME_ADD_TSPEC_REQUEST MlmeAddTspecRequest;
1385 CSR_MLME_ADD_TSPEC_CONFIRM MlmeAddTspecConfirm;
1386 CSR_MLME_DEL_TSPEC_REQUEST MlmeDelTspecRequest;
1387 CSR_MLME_DEL_TSPEC_CONFIRM MlmeDelTspecConfirm;
1388 CSR_MLME_START_AGGREGATION_REQUEST MlmeStartAggregationRequest;
1389 CSR_MLME_START_AGGREGATION_CONFIRM MlmeStartAggregationConfirm;
1390 CSR_MLME_BLOCKACK_ERROR_INDICATION MlmeBlockackErrorIndication;
1391 CSR_MLME_STOP_AGGREGATION_REQUEST MlmeStopAggregationRequest;
1392 CSR_MLME_STOP_AGGREGATION_CONFIRM MlmeStopAggregationConfirm;
1393 CSR_MLME_SM_START_REQUEST MlmeSmStartRequest;
1394 CSR_MLME_SM_START_CONFIRM MlmeSmStartConfirm;
1395 CSR_MLME_LEAVE_REQUEST MlmeLeaveRequest;
1396 CSR_MLME_LEAVE_CONFIRM MlmeLeaveConfirm;
1397 CSR_MLME_SET_TIM_REQUEST MlmeSetTimRequest;
1398 CSR_MLME_SET_TIM_CONFIRM MlmeSetTimConfirm;
1399 CSR_MLME_GET_KEY_SEQUENCE_REQUEST MlmeGetKeySequenceRequest;
1400 CSR_MLME_GET_KEY_SEQUENCE_CONFIRM MlmeGetKeySequenceConfirm;
1401 CSR_MLME_SET_CHANNEL_REQUEST MlmeSetChannelRequest;
1402 CSR_MLME_SET_CHANNEL_CONFIRM MlmeSetChannelConfirm;
1403 CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST MlmeAddMulticastAddressRequest;
1404 CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM MlmeAddMulticastAddressConfirm;
1405 CSR_DEBUG_STRING_INDICATION DebugStringIndication;
1406 CSR_DEBUG_WORD16_INDICATION DebugWord16Indication;
1407 CSR_DEBUG_GENERIC_REQUEST DebugGenericRequest;
1408 CSR_DEBUG_GENERIC_CONFIRM DebugGenericConfirm;
1409 CSR_DEBUG_GENERIC_INDICATION DebugGenericIndication;
1410 } u;
1411} CSR_SIGNAL;
1412
1413#define SIG_FILTER_SIZE 6
1414
1415u32 SigGetFilterPos(u16 aSigID);
1416
1417#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
index f1df36aa87e7..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_ta_sampling.c
+++ /dev/null
@@ -1,541 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_ta_sampling.c
14 *
15 * PURPOSE:
16 * The traffic analysis sampling module.
17 * This gathers data which is sent to the SME and used to analyse
18 * the traffic behaviour.
19 *
20 * Provides:
21 * unifi_ta_sampling_init - Initialise the internal state
22 * unifi_ta_sample - Sampling function, call this for every data packet
23 *
24 * Calls these external functions which must be provided:
25 * unifi_ta_indicate_sampling - Pass sample data to the SME.
26 * unifi_ta_indicate_protocol - Report certain data packet types to the SME.
27 * ---------------------------------------------------------------------------
28 */
29
30#include "csr_wifi_hip_card_sdio.h"
31
32/* Maximum number of Tx frames we store each CYCLE_1, for detecting period */
33#define TA_MAX_INTERVALS_IN_C1 100
34
35/* Number of intervals in CYCLE_1 (one second), for detecting periodic */
36/* Must match size of unifi_TrafficStats.intervals - 1 */
37#define TA_INTERVALS_NUM 10
38
39/* Step (in msecs) between intervals, for detecting periodic */
40/* We are only interested in periods up to 100ms, i.e. between beacons */
41/* This is correct for TA_INTERVALS_NUM=10 */
42#define TA_INTERVALS_STEP 10
43
44
45enum ta_frame_identity
46{
47 TA_FRAME_UNKNOWN,
48 TA_FRAME_ETHERNET_UNINTERESTING,
49 TA_FRAME_ETHERNET_INTERESTING
50};
51
52
53#define TA_ETHERNET_TYPE_OFFSET 6
54#define TA_LLC_HEADER_SIZE 8
55#define TA_IP_TYPE_OFFSET 17
56#define TA_UDP_SOURCE_PORT_OFFSET 28
57#define TA_UDP_DEST_PORT_OFFSET (TA_UDP_SOURCE_PORT_OFFSET + 2)
58#define TA_BOOTP_CLIENT_MAC_ADDR_OFFSET 64
59#define TA_DHCP_MESSAGE_TYPE_OFFSET 278
60#define TA_DHCP_MESSAGE_TYPE_ACK 0x05
61#define TA_PROTO_TYPE_IP 0x0800
62#define TA_PROTO_TYPE_EAP 0x888E
63#define TA_PROTO_TYPE_WAI 0x8864
64#define TA_PROTO_TYPE_ARP 0x0806
65#define TA_IP_TYPE_TCP 0x06
66#define TA_IP_TYPE_UDP 0x11
67#define TA_UDP_PORT_BOOTPC 0x0044
68#define TA_UDP_PORT_BOOTPS 0x0043
69#define TA_EAPOL_TYPE_OFFSET 9
70#define TA_EAPOL_TYPE_START 0x01
71
72#define snap_802_2 0xAAAA0300
73#define oui_rfc1042 0x00000000
74#define oui_8021h 0x0000f800
75static const u8 aironet_snap[5] = { 0x00, 0x40, 0x96, 0x00, 0x00 };
76
77
78/*
79 * ---------------------------------------------------------------------------
80 * ta_detect_protocol
81 *
82 * Internal only.
83 * Detects a specific protocol in a frame and indicates a TA event.
84 *
85 * Arguments:
86 * ta The pointer to the TA module.
87 * direction The direction of the frame (tx or rx).
88 * data Pointer to the structure that contains the data.
89 *
90 * Returns:
91 * None
92 * ---------------------------------------------------------------------------
93 */
94static enum ta_frame_identity ta_detect_protocol(card_t *card, CsrWifiRouterCtrlProtocolDirection direction,
95 const bulk_data_desc_t *data,
96 const u8 *saddr,
97 const u8 *sta_macaddr)
98{
99 ta_data_t *tad = &card->ta_sampling;
100 u16 proto;
101 u16 source_port, dest_port;
102 CsrWifiMacAddress srcAddress;
103 u32 snap_hdr, oui_hdr;
104
105 if (data->data_length < TA_LLC_HEADER_SIZE)
106 {
107 return TA_FRAME_UNKNOWN;
108 }
109
110 snap_hdr = (((u32)data->os_data_ptr[0]) << 24) |
111 (((u32)data->os_data_ptr[1]) << 16) |
112 (((u32)data->os_data_ptr[2]) << 8);
113 if (snap_hdr != snap_802_2)
114 {
115 return TA_FRAME_UNKNOWN;
116 }
117
118 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
119 {
120 /*
121 * Here we would use the custom filter to detect interesting frames.
122 */
123 }
124
125 oui_hdr = (((u32)data->os_data_ptr[3]) << 24) |
126 (((u32)data->os_data_ptr[4]) << 16) |
127 (((u32)data->os_data_ptr[5]) << 8);
128 if ((oui_hdr == oui_rfc1042) || (oui_hdr == oui_8021h))
129 {
130 proto = (data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET] * 256) +
131 data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET + 1];
132
133 /* The only interesting IP frames are the DHCP */
134 if (proto == TA_PROTO_TYPE_IP)
135 {
136 if (data->data_length > TA_IP_TYPE_OFFSET)
137 {
138 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
139 {
140 ta_l4stats_t *ta_l4stats = &tad->ta_l4stats;
141 u8 l4proto = data->os_data_ptr[TA_IP_TYPE_OFFSET];
142
143 if (l4proto == TA_IP_TYPE_TCP)
144 {
145 if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
146 {
147 ta_l4stats->txTcpBytesCount += data->data_length;
148 }
149 else
150 {
151 ta_l4stats->rxTcpBytesCount += data->data_length;
152 }
153 }
154 else if (l4proto == TA_IP_TYPE_UDP)
155 {
156 if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
157 {
158 ta_l4stats->txUdpBytesCount += data->data_length;
159 }
160 else
161 {
162 ta_l4stats->rxUdpBytesCount += data->data_length;
163 }
164 }
165 }
166
167 /* detect DHCP frames */
168 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP)
169 {
170 /* DHCP frames are UDP frames with BOOTP ports */
171 if (data->os_data_ptr[TA_IP_TYPE_OFFSET] == TA_IP_TYPE_UDP)
172 {
173 if (data->data_length > TA_UDP_DEST_PORT_OFFSET)
174 {
175 source_port = (data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET] * 256) +
176 data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET + 1];
177 dest_port = (data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET] * 256) +
178 data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET + 1];
179
180 if (((source_port == TA_UDP_PORT_BOOTPC) && (dest_port == TA_UDP_PORT_BOOTPS)) ||
181 ((source_port == TA_UDP_PORT_BOOTPS) && (dest_port == TA_UDP_PORT_BOOTPC)))
182 {
183 /* The DHCP should have at least a message type (request, ack, nack, etc) */
184 if (data->data_length > TA_DHCP_MESSAGE_TYPE_OFFSET + 6)
185 {
186 UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
187
188 if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
189 {
190 unifi_ta_indicate_protocol(card->ospriv,
191 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP,
192 direction,
193 &srcAddress);
194 return TA_FRAME_ETHERNET_UNINTERESTING;
195 }
196
197 /* DHCPACK is a special indication */
198 if (UNIFI_MAC_ADDRESS_CMP(data->os_data_ptr + TA_BOOTP_CLIENT_MAC_ADDR_OFFSET, sta_macaddr) == TRUE)
199 {
200 if (data->os_data_ptr[TA_DHCP_MESSAGE_TYPE_OFFSET] == TA_DHCP_MESSAGE_TYPE_ACK)
201 {
202 unifi_ta_indicate_protocol(card->ospriv,
203 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK,
204 direction,
205 &srcAddress);
206 }
207 else
208 {
209 unifi_ta_indicate_protocol(card->ospriv,
210 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP,
211 direction,
212 &srcAddress);
213 }
214 }
215 }
216 }
217 }
218 }
219 }
220 }
221
222 return TA_FRAME_ETHERNET_INTERESTING;
223 }
224
225 /* detect protocol type EAPOL or WAI (treated as equivalent here) */
226 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL)
227 {
228 if (TA_PROTO_TYPE_EAP == proto || TA_PROTO_TYPE_WAI == proto)
229 {
230 if ((TA_PROTO_TYPE_WAI == proto) || (direction != CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) ||
231 (data->os_data_ptr[TA_EAPOL_TYPE_OFFSET] == TA_EAPOL_TYPE_START))
232 {
233 UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
234 unifi_ta_indicate_protocol(card->ospriv,
235 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL,
236 direction, &srcAddress);
237 }
238 return TA_FRAME_ETHERNET_UNINTERESTING;
239 }
240 }
241
242 /* detect protocol type 0x0806 (ARP) */
243 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP)
244 {
245 if (proto == TA_PROTO_TYPE_ARP)
246 {
247 UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
248 unifi_ta_indicate_protocol(card->ospriv,
249 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP,
250 direction, &srcAddress);
251 return TA_FRAME_ETHERNET_UNINTERESTING;
252 }
253 }
254
255 return TA_FRAME_ETHERNET_INTERESTING;
256 }
257 else if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET)
258 {
259 /* detect Aironet frames */
260 if (!memcmp(data->os_data_ptr + 3, aironet_snap, 5))
261 {
262 UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
263 unifi_ta_indicate_protocol(card->ospriv, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET,
264 direction, &srcAddress);
265 }
266 }
267
268 return TA_FRAME_ETHERNET_UNINTERESTING;
269} /* ta_detect_protocol() */
270
271
272static void tas_reset_data(ta_data_t *tad)
273{
274 s16 i;
275
276 for (i = 0; i < (TA_INTERVALS_NUM + 1); i++)
277 {
278 tad->stats.intervals[i] = 0;
279 }
280
281 tad->stats.rxFramesNum = 0;
282 tad->stats.txFramesNum = 0;
283 tad->stats.rxBytesCount = 0;
284 tad->stats.txBytesCount = 0;
285 tad->stats.rxMeanRate = 0;
286
287 tad->rx_sum_rate = 0;
288
289 tad->ta_l4stats.rxTcpBytesCount = 0;
290 tad->ta_l4stats.txTcpBytesCount = 0;
291 tad->ta_l4stats.rxUdpBytesCount = 0;
292 tad->ta_l4stats.txUdpBytesCount = 0;
293} /* tas_reset_data() */
294
295
296/*
297 * ---------------------------------------------------------------------------
298 * API.
299 * unifi_ta_sampling_init
300 *
301 * (Re)Initialise the Traffic Analysis sampling module.
302 * Resets the counters and timestamps.
303 *
304 * Arguments:
305 * tad Pointer to a ta_data_t structure containing the
306 * context for this device instance.
307 * drv_priv An opaque pointer that the TA sampling module will
308 * pass in call-outs.
309 *
310 * Returns:
311 * None.
312 * ---------------------------------------------------------------------------
313 */
314void unifi_ta_sampling_init(card_t *card)
315{
316 (void)unifi_ta_configure(card, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET, NULL);
317
318 card->ta_sampling.packet_filter = CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE;
319 card->ta_sampling.traffic_type = CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL;
320} /* unifi_ta_sampling_init() */
321
322
323/*
324 * ---------------------------------------------------------------------------
325 * API.
326 * unifi_ta_sample
327 *
328 * Sample a data frame for the TA module.
329 * This function stores all the useful information it can extract from
330 * the frame and detects any specific protocols.
331 *
332 * Arguments:
333 * tad The pointer to the TA sampling context struct.
334 * direction The direction of the frame (rx, tx)
335 * data Pointer to the frame data
336 * saddr Source MAC address of frame.
337 * timestamp Time (in msecs) that the frame was received.
338 * rate Reported data rate for the rx frame (0 for tx frames)
339 *
340 * Returns:
341 * None
342 * ---------------------------------------------------------------------------
343 */
344void unifi_ta_sample(card_t *card,
345 CsrWifiRouterCtrlProtocolDirection direction,
346 const bulk_data_desc_t *data,
347 const u8 *saddr,
348 const u8 *sta_macaddr,
349 u32 timestamp,
350 u16 rate)
351{
352 ta_data_t *tad = &card->ta_sampling;
353 enum ta_frame_identity identity;
354 u32 time_delta;
355
356
357
358 /* Step1: Check for specific frames */
359 if (tad->packet_filter != CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE)
360 {
361 identity = ta_detect_protocol(card, direction, data, saddr, sta_macaddr);
362 }
363 else
364 {
365 identity = TA_FRAME_ETHERNET_INTERESTING;
366 }
367
368
369 /* Step2: Update the information in the current record */
370 if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX)
371 {
372 /* Update the Rx packet count and the throughput count */
373 tad->stats.rxFramesNum++;
374 tad->stats.rxBytesCount += data->data_length;
375
376 /* Accumulate packet Rx rates for later averaging */
377 tad->rx_sum_rate += rate;
378 }
379 else
380 {
381 if (identity == TA_FRAME_ETHERNET_INTERESTING)
382 {
383 /*
384 * Store the period between the last and the current frame.
385 * There is not point storing more than TA_MAX_INTERVALS_IN_C1 periods,
386 * the traffic will be bursty or continuous.
387 */
388 if (tad->stats.txFramesNum < TA_MAX_INTERVALS_IN_C1)
389 {
390 u32 interval;
391 u32 index_in_intervals;
392
393 interval = timestamp - tad->tx_last_ts;
394 tad->tx_last_ts = timestamp;
395 index_in_intervals = (interval + TA_INTERVALS_STEP / 2 - 1) / TA_INTERVALS_STEP;
396
397 /* If the interval is interesting, update the t1_intervals count */
398 if (index_in_intervals <= TA_INTERVALS_NUM)
399 {
400 unifi_trace(card->ospriv, UDBG5,
401 "unifi_ta_sample: TX interval=%d index=%d\n",
402 interval, index_in_intervals);
403 tad->stats.intervals[index_in_intervals]++;
404 }
405 }
406 }
407
408 /* Update the Tx packet count... */
409 tad->stats.txFramesNum++;
410 /* ... and the number of bytes for throughput. */
411 tad->stats.txBytesCount += data->data_length;
412 }
413
414 /*
415 * If more than one second has elapsed since the last report, send
416 * another one.
417 */
418 /* Unsigned subtraction handles wrap-around from 0xFFFFFFFF to 0 */
419 time_delta = timestamp - tad->last_indication_time;
420 if (time_delta >= 1000)
421 {
422 /*
423 * rxFramesNum can be flashed in tas_reset_data() by another thread.
424 * Use a temp to avoid division by zero.
425 */
426 u32 temp_rxFramesNum;
427 temp_rxFramesNum = tad->stats.rxFramesNum;
428
429 /* Calculate this interval's mean frame Rx rate from the sum */
430 if (temp_rxFramesNum)
431 {
432 tad->stats.rxMeanRate = tad->rx_sum_rate / temp_rxFramesNum;
433 }
434 unifi_trace(card->ospriv, UDBG5,
435 "unifi_ta_sample: RX fr=%lu, r=%u, sum=%lu, av=%lu\n",
436 tad->stats.rxFramesNum, rate,
437 tad->rx_sum_rate, tad->stats.rxMeanRate);
438
439 /*
440 * Send the information collected in the stats struct
441 * to the SME and reset the counters.
442 */
443 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
444 {
445 u32 rxTcpThroughput = tad->ta_l4stats.rxTcpBytesCount / time_delta;
446 u32 txTcpThroughput = tad->ta_l4stats.txTcpBytesCount / time_delta;
447 u32 rxUdpThroughput = tad->ta_l4stats.rxUdpBytesCount / time_delta;
448 u32 txUdpThroughput = tad->ta_l4stats.txUdpBytesCount / time_delta;
449
450 unifi_ta_indicate_l4stats(card->ospriv,
451 rxTcpThroughput,
452 txTcpThroughput,
453 rxUdpThroughput,
454 txUdpThroughput
455 );
456 }
457 unifi_ta_indicate_sampling(card->ospriv, &tad->stats);
458 tas_reset_data(tad);
459 tad->last_indication_time = timestamp;
460 }
461} /* unifi_ta_sample() */
462
463
464/*
465 * ---------------------------------------------------------------------------
466 * External API.
467 * unifi_ta_configure
468 *
469 * Configures the TA module parameters.
470 *
471 * Arguments:
472 * ta The pointer to the TA module.
473 * config_type The type of the configuration request
474 * config Pointer to the configuration parameters.
475 *
476 * Returns:
477 * CSR_RESULT_SUCCESS on success, CSR error code otherwise
478 * ---------------------------------------------------------------------------
479 */
480CsrResult unifi_ta_configure(card_t *card,
481 CsrWifiRouterCtrlTrafficConfigType config_type,
482 const CsrWifiRouterCtrlTrafficConfig *config)
483{
484 ta_data_t *tad = &card->ta_sampling;
485
486 /* Reinitialise our data when we are reset */
487 if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET)
488 {
489 /* Reset the stats to zero */
490 tas_reset_data(tad);
491
492 /* Reset the timer variables */
493 tad->tx_last_ts = 0;
494 tad->last_indication_time = 0;
495
496 return CSR_RESULT_SUCCESS;
497 }
498
499 if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER)
500 {
501 tad->packet_filter = config->packetFilter;
502
503 if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
504 {
505 tad->custom_filter = config->customFilter;
506 }
507
508 return CSR_RESULT_SUCCESS;
509 }
510
511 return CSR_RESULT_SUCCESS;
512} /* unifi_ta_configure() */
513
514
515/*
516 * ---------------------------------------------------------------------------
517 * External API.
518 * unifi_ta_classification
519 *
520 * Configures the current TA classification.
521 *
522 * Arguments:
523 * ta The pointer to the TA module.
524 * traffic_type The classification type
525 * period The traffic period if the type is periodic
526 *
527 * Returns:
528 * None
529 * ---------------------------------------------------------------------------
530 */
531void unifi_ta_classification(card_t *card,
532 CsrWifiRouterCtrlTrafficType traffic_type,
533 u16 period)
534{
535 unifi_trace(card->ospriv, UDBG3,
536 "Changed current ta classification to: %d\n", traffic_type);
537
538 card->ta_sampling.traffic_type = traffic_type;
539}
540
541
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
index aa684c654d06..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_ta_sampling.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_ta_sampling.h
14 *
15 * PURPOSE:
16 * This file contains Traffic Analysis definitions common to the
17 * sampling and analysis modules.
18 *
19 * ---------------------------------------------------------------------------
20 */
21#ifndef __TA_SAMPLING_H__
22#define __TA_SAMPLING_H__
23
24#include "csr_wifi_hip_unifi.h"
25
26typedef struct ta_l4stats
27{
28 u32 rxTcpBytesCount;
29 u32 txTcpBytesCount;
30 u32 rxUdpBytesCount;
31 u32 txUdpBytesCount;
32} ta_l4stats_t;
33
34/*
35 * Context structure to preserve state between calls.
36 */
37
38typedef struct ta_data
39{
40 /* Current packet filter configuration */
41 u16 packet_filter;
42
43 /* Current packet custom filter configuration */
44 CsrWifiRouterCtrlTrafficFilter custom_filter;
45
46 /* The timestamp of the last tx packet processed. */
47 u32 tx_last_ts;
48
49 /* The timestamp of the last packet processed. */
50 u32 last_indication_time;
51
52 /* Statistics */
53 CsrWifiRouterCtrlTrafficStats stats;
54
55 /* Current traffic classification */
56 CsrWifiRouterCtrlTrafficType traffic_type;
57
58 /* Sum of packet rx rates for this interval used to calculate mean */
59 u32 rx_sum_rate;
60 ta_l4stats_t ta_l4stats;
61} ta_data_t;
62
63
64void unifi_ta_sampling_init(card_t *card);
65
66#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
index a6b006b0e983..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_udi.c
+++ /dev/null
@@ -1,173 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_card_udi.c
14 *
15 * PURPOSE:
16 * Maintain a list of callbacks to log UniFi exchanges to one or more
17 * debug/monitoring client applications.
18 *
19 * NOTES:
20 * Just call the UDI driver log fn directly for now.
21 * When done properly, each open() on the UDI device will install
22 * a log function. We will call all log fns whenever a signal is written
23 * to or read form the UniFi.
24 *
25 * ---------------------------------------------------------------------------
26 */
27#include <linux/seq_file.h>
28#include "csr_wifi_hip_unifi.h"
29#include "csr_wifi_hip_card.h"
30
31
32static void unifi_print_unsafe_sdio_status(card_t *card, struct seq_file *m)
33{
34#ifdef CSR_UNSAFE_SDIO_ACCESS
35 s32 iostate;
36 CsrResult r;
37 static const char *const states[] = {
38 "AWAKE", "DROWSY", "TORPID"
39 };
40#define SHARED_READ_RETRY_LIMIT 10
41 u8 b;
42
43 seq_printf(m, "Host State: %s\n", states[card->host_state]);
44
45 r = unifi_check_io_status(card, &iostate);
46 if (iostate == 1) {
47 seq_puts(m, remaining, "I/O Check: F1 disabled\n");
48 } else {
49 if (iostate == 1) {
50 seq_puts(m, "I/O Check: pending interrupt\n");
51
52 seq_printf(m, "BH reason interrupt = %d\n", card->bh_reason_unifi);
53 seq_printf(m, "BH reason host = %d\n", card->bh_reason_host);
54
55 for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) {
56 r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b);
57 if (r == CSR_RESULT_SUCCESS && !(b & 0x80)) {
58 seq_printf(m, "fhsr: %u (driver thinks is %u)\n",
59 b, card->from_host_signals_r);
60 break;
61 }
62 }
63
64 iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
65 seq_printf(m, "thsw: %u (driver thinks is %u)\n",
66 iostate, card->to_host_signals_w);
67 }
68#endif
69}
70
71/*
72 * ---------------------------------------------------------------------------
73 * unifi_print_status
74 *
75 * Print status info to given character buffer.
76 *
77 * Arguments:
78 * None.
79 *
80 * Returns:
81 * None.
82 * ---------------------------------------------------------------------------
83 */
84s32 unifi_print_status(card_t *card, struct seq_file *m)
85{
86 sdio_config_data_t *cfg;
87 u16 i, n;
88
89 i = n = 0;
90 seq_printf(m, "Chip ID %u\n", card->chip_id);
91 seq_printf(m, "Chip Version %04X\n", card->chip_version);
92 seq_printf(m, "HIP v%u.%u\n",
93 (card->config_data.version >> 8) & 0xFF,
94 card->config_data.version & 0xFF);
95 seq_printf(m, "Build %u: %s\n", card->build_id, card->build_id_string);
96
97 cfg = &card->config_data;
98
99 seq_printf(m, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset);
100 seq_printf(m, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle);
101 seq_printf(m, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle);
102 seq_printf(m, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags);
103 seq_printf(m, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags);
104 seq_printf(m, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots);
105 seq_printf(m, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots);
106 seq_printf(m, "data_slot_size %u\n", cfg->data_slot_size);
107
108 /* Added by protocol version 0x0001 */
109 seq_printf(m, "overlay_size %u\n", cfg->overlay_size);
110
111 /* Added by protocol version 0x0300 */
112 seq_printf(m, "data_slot_round %u\n", cfg->data_slot_round);
113 seq_printf(m, "sig_frag_size %u\n", cfg->sig_frag_size);
114
115 /* Added by protocol version 0x0300 */
116 seq_printf(m, "tohost_sig_pad %u\n", cfg->tohost_signal_padding);
117
118 seq_puts(m, "\nInternal state:\n");
119
120 seq_printf(m, "Last PHY PANIC: %04x:%04x\n",
121 card->last_phy_panic_code, card->last_phy_panic_arg);
122 seq_printf(m, "Last MAC PANIC: %04x:%04x\n",
123 card->last_mac_panic_code, card->last_mac_panic_arg);
124
125 seq_printf(m, "fhsr: %hu\n", (u16)card->from_host_signals_r);
126 seq_printf(m, "fhsw: %hu\n", (u16)card->from_host_signals_w);
127 seq_printf(m, "thsr: %hu\n", (u16)card->to_host_signals_r);
128 seq_printf(m, "thsw: %hu\n", (u16)card->to_host_signals_w);
129 seq_printf(m, "fh buffer contains: %d signals, %td bytes\n",
130 card->fh_buffer.count,
131 card->fh_buffer.ptr - card->fh_buffer.buf);
132
133 seq_puts(m, "paused: ");
134 for (i = 0; i < ARRAY_SIZE(card->tx_q_paused_flag); i++)
135 seq_printf(m, card->tx_q_paused_flag[i] ? "1" : "0");
136 seq_putc(m, '\n');
137
138 seq_printf(m, "fh command q: %u waiting, %u free of %u:\n",
139 CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue),
140 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue),
141 UNIFI_SOFT_COMMAND_Q_LENGTH);
142
143 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
144 seq_printf(m, "fh traffic q[%u]: %u waiting, %u free of %u:\n",
145 i,
146 CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]),
147 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]),
148 UNIFI_SOFT_TRAFFIC_Q_LENGTH);
149
150 seq_printf(m, "fh data slots free: %u\n",
151 card->from_host_data ? CardGetFreeFromHostDataSlots(card) : 0);
152
153 seq_puts(m, "From host data slots:");
154 n = card->config_data.num_fromhost_data_slots;
155 for (i = 0; i < n && card->from_host_data; i++)
156 seq_printf(m, " %hu", (u16)card->from_host_data[i].bd.data_length);
157 seq_putc(m, '\n');
158
159 seq_puts(m, "To host data slots:");
160 n = card->config_data.num_tohost_data_slots;
161 for (i = 0; i < n && card->to_host_data; i++)
162 seq_printf(m, " %hu", (u16)card->to_host_data[i].data_length);
163 seq_putc(m, '\n');
164
165 unifi_print_unsafe_sdio_status(card, m);
166
167 seq_puts(m, "\nStats:\n");
168 seq_printf(m, "Total SDIO bytes: R=%u W=%u\n",
169 card->sdio_bytes_read, card->sdio_bytes_written);
170
171 seq_printf(m, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq);
172 return 0;
173}
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi.h b/drivers/staging/csr/csr_wifi_hip_unifi.h
deleted file mode 100644
index 1160a0e25c7d..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_unifi.h
+++ /dev/null
@@ -1,871 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 *
14 * FILE : csr_wifi_hip_unifi.h
15 *
16 * PURPOSE : Public API for the UniFi HIP core library.
17 *
18 * ---------------------------------------------------------------------------
19 */
20#ifndef __CSR_WIFI_HIP_UNIFI_H__
21#define __CSR_WIFI_HIP_UNIFI_H__ 1
22
23#ifndef CSR_WIFI_HIP_TA_DISABLE
24#include "csr_wifi_router_ctrl_prim.h"
25#include "csr_wifi_router_prim.h"
26#else
27#include "csr_time.h"
28#endif
29
30/* SDIO chip ID numbers */
31
32/* Manufacturer id */
33#define SDIO_MANF_ID_CSR 0x032a
34
35/* Device id */
36#define SDIO_CARD_ID_UNIFI_1 0x0001
37#define SDIO_CARD_ID_UNIFI_2 0x0002
38#define SDIO_CARD_ID_UNIFI_3 0x0007
39#define SDIO_CARD_ID_UNIFI_4 0x0008
40
41/* Function number for WLAN */
42#define SDIO_WLAN_FUNC_ID_UNIFI_1 0x0001
43#define SDIO_WLAN_FUNC_ID_UNIFI_2 0x0001
44#define SDIO_WLAN_FUNC_ID_UNIFI_3 0x0001
45#define SDIO_WLAN_FUNC_ID_UNIFI_4 0x0002
46
47/* Maximum SDIO bus clock supported. */
48#define UNIFI_SDIO_CLOCK_MAX_HZ 50000000 /* Hz */
49
50/*
51 * Initialisation SDIO bus clock.
52 *
53 * The initialisation clock speed should be used from when the chip has been
54 * reset until the first MLME-reset has been received (i.e. during firmware
55 * initialisation), unless UNIFI_SDIO_CLOCK_SAFE_HZ applies.
56 */
57#define UNIFI_SDIO_CLOCK_INIT_HZ 12500000 /* Hz */
58
59/*
60 * Safe SDIO bus clock.
61 *
62 * The safe speed should be used when the chip is in deep sleep or
63 * it's state is unknown (just after reset / power on).
64 */
65#define UNIFI_SDIO_CLOCK_SAFE_HZ 1000000 /* Hz */
66
67/* I/O default block size to use for UniFi. */
68#define UNIFI_IO_BLOCK_SIZE 64
69
70#define UNIFI_WOL_OFF 0
71#define UNIFI_WOL_SDIO 1
72#define UNIFI_WOL_PIO 2
73
74/* The number of Tx traffic queues */
75#define UNIFI_NO_OF_TX_QS 4
76
77#define CSR_WIFI_HIP_RESERVED_HOST_TAG 0xFFFFFFFF
78
79/*
80 * The number of slots in the from-host queues.
81 *
82 * UNIFI_SOFT_TRAFFIC_Q_LENGTH is the number of slots in the traffic queues
83 * and there will be UNIFI_NO_OF_TX_QS of them.
84 * Traffic queues are used for data packets.
85 *
86 * UNIFI_SOFT_COMMAND_Q_LENGTH is the number of slots in the command queue.
87 * The command queue is used for MLME management requests.
88 *
89 * Queues are ring buffers and so must always have 1 unused slot.
90 */
91#define UNIFI_SOFT_TRAFFIC_Q_LENGTH (20 + 1)
92#define UNIFI_SOFT_COMMAND_Q_LENGTH (16 + 1)
93
94#include "csr_framework_ext.h" /* from the synergy porting folder */
95#include "csr_sdio.h" /* from the synergy porting folder */
96#include "csr_macro.h" /* from the synergy porting folder */
97#include "csr_wifi_result.h"
98
99/* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */
100#define UNIFI_MAC_ADDRESS_COPY(dst, src) \
101 do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; \
102 (dst)[2] = (src)[2]; (dst)[3] = (src)[3]; \
103 (dst)[4] = (src)[4]; (dst)[5] = (src)[5]; \
104 } while (0)
105
106#define UNIFI_MAC_ADDRESS_CMP(addr1, addr2) \
107 (((addr1)[0] == (addr2)[0]) && ((addr1)[1] == (addr2)[1]) && \
108 ((addr1)[2] == (addr2)[2]) && ((addr1)[3] == (addr2)[3]) && \
109 ((addr1)[4] == (addr2)[4]) && ((addr1)[5] == (addr2)[5]))
110
111/* Traffic queue ordered according to priority
112 * EAPOL/Uncontrolled port Queue should be the last
113 */
114typedef enum
115{
116 UNIFI_TRAFFIC_Q_BK = 0,
117 UNIFI_TRAFFIC_Q_BE,
118 UNIFI_TRAFFIC_Q_VI,
119 UNIFI_TRAFFIC_Q_VO,
120 UNIFI_TRAFFIC_Q_EAPOL, /* Non existent in HIP */
121 UNIFI_TRAFFIC_Q_MAX, /* Non existent */
122 UNIFI_TRAFFIC_Q_MLME /* Non existent */
123} unifi_TrafficQueue;
124
125/*
126 * Structure describing a bulk data slot.
127 * This structure is shared between the HIP core library and the OS
128 * layer. See the definition of unifi_net_data_malloc() for more details.
129 *
130 * The data_length field is used to indicate empty/occupied state.
131 * Needs to be defined before #include "unifi_os.h".
132 */
133typedef struct _bulk_data_desc
134{
135 const u8 *os_data_ptr;
136 u32 data_length;
137 const void *os_net_buf_ptr;
138 u32 net_buf_length;
139} bulk_data_desc_t;
140
141/* Structure of an entry in the Symbol Look Up Table (SLUT). */
142typedef struct _symbol
143{
144 u16 id;
145 u32 obj;
146} symbol_t;
147
148/*
149 * Header files need to be included from the current directory,
150 * the SME library, the synergy framework and the OS layer.
151 * A thin OS layer needs to be implemented in the porting exercise.
152 *
153 * Note that unifi_os.h should be included only in unifi.h
154 */
155
156#include "unifi_os.h"
157
158/*
159 * Contains the HIP core definitions selected in the porting exercise, such as
160 * UNIFI_PAD_BULK_DATA_TO_BLOCK_SIZE and UNIFI_PAD_SIGNALS_TO_BLOCK_SIZE.
161 * Implemented in the OS layer, as part of the porting exersice.
162 */
163#include "unifi_config.h"
164
165#include "csr_wifi_hip_signals.h" /* from this dir */
166
167/*
168 * The card structure is an opaque pointer that is used to pass context
169 * to the upper-edge API functions.
170 */
171typedef struct card card_t;
172
173
174/*
175 * This structure describes all of the bulk data that 'might' be
176 * associated with a signal.
177 */
178typedef struct _bulk_data_param
179{
180 bulk_data_desc_t d[UNIFI_MAX_DATA_REFERENCES];
181} bulk_data_param_t;
182
183
184/*
185 * This structure describes the chip and HIP core lib
186 * information that exposed to the OS layer.
187 */
188typedef struct _card_info
189{
190 u16 chip_id;
191 u16 chip_version;
192 u32 fw_build;
193 u16 fw_hip_version;
194 u32 sdio_block_size;
195} card_info_t;
196
197
198/*
199 * Mini-coredump definitions
200 */
201/* Definition of XAP memory ranges used by the mini-coredump system.
202 * Note that, these values are NOT the same as UNIFI_REGISTERS, etc
203 * in unifihw.h which don't allow selection of register areas for each XAP.
204 */
205typedef enum unifi_coredump_space
206{
207 UNIFI_COREDUMP_MAC_REG,
208 UNIFI_COREDUMP_PHY_REG,
209 UNIFI_COREDUMP_SH_DMEM,
210 UNIFI_COREDUMP_MAC_DMEM,
211 UNIFI_COREDUMP_PHY_DMEM,
212 UNIFI_COREDUMP_TRIGGER_MAGIC = 0xFEED
213} unifi_coredump_space_t;
214
215/* Structure used to request a register value from a mini-coredump buffer */
216typedef struct unifi_coredump_req
217{
218 /* From user */
219 s32 index; /* 0=newest, -1=oldest */
220 unifi_coredump_space_t space; /* memory space */
221 u32 offset; /* register offset in space */
222 /* From driver */
223 u32 drv_build; /* Driver build id */
224 u32 chip_ver; /* Chip version */
225 u32 fw_ver; /* Firmware version */
226 s32 requestor; /* Requestor: 0=auto dump, 1=manual */
227 u32 timestamp; /* time of capture by driver */
228 u32 serial; /* capture serial number */
229 s32 value; /* register value */
230} unifi_coredump_req_t; /* mini-coredumped reg value request */
231
232
233/**
234 * @defgroup upperedge Upper edge API
235 *
236 * The following functions are implemented in the HIP core lib.
237 */
238
239/**
240 *
241 * Initialise the HIP core lib.
242 * Note that the OS layer must initialise the SDIO glue layer and obtain
243 * an SDIO function context, prior to this call.
244 *
245 * @param sdiopriv the SDIO function context.
246 *
247 * @param ospriv the OS layer context.
248 *
249 * @return \p card_t the HIP core lib API context.
250 *
251 * @ingroup upperedge
252 */
253card_t* unifi_alloc_card(CsrSdioFunction *sdiopriv, void *ospriv);
254
255
256/**
257 *
258 * Initialise the UniFi chip.
259 *
260 * @param card the HIP core lib API context.
261 *
262 * @param led_mask the led mask to apply to UniFi.
263 *
264 * @return \b 0 if UniFi is initialized.
265 *
266 * @return \b -CSR_EIO if an I/O error occurred while initializing UniFi
267 *
268 * @return \b -CSR_ENODEV if the card is no longer present.
269 *
270 * @ingroup upperedge
271 */
272CsrResult unifi_init_card(card_t *card, s32 led_mask);
273
274/**
275 *
276 * De-Initialise the HIP core lib.
277 *
278 * @param card the HIP core lib API context.
279 *
280 * @ingroup upperedge
281 */
282void unifi_free_card(card_t *card);
283
284/**
285 *
286 * Cancel all the signals pending in the HIP core lib.
287 * Normally used during a system suspend when the power is retained on UniFi.
288 *
289 * @param card the HIP core lib API context.
290 *
291 * @ingroup upperedge
292 */
293void unifi_cancel_pending_signals(card_t *card);
294
295/**
296 *
297 * Send a signal to UniFi.
298 * Normally it is called from unifi_sys_hip_req() and the OS layer
299 * Tx data plane.
300 *
301 * Note that the bulkdata buffers ownership is passed to the HIP core lib.
302 * These buffers must be allocated using unifi_net_data_malloc().
303 *
304 * @param card the HIP core lib API context.
305 *
306 * @param sigptr pointer to the signal.
307 *
308 * @param siglen size of the signal.
309 *
310 * @param bulkdata pointer to the bulk data associated with the signal.
311 *
312 * @return \b 0 signal is sent.
313 *
314 * @return \b -CSR_EIO if an error occurred while sending the signal
315 *
316 * @return \b -CSR_ENODEV if the card is no longer present.
317 *
318 * @ingroup upperedge
319 */
320CsrResult unifi_send_signal(card_t *card, const u8 *sigptr,
321 u32 siglen,
322 const bulk_data_param_t *bulkdata);
323
324/**
325 *
326 * Check if the HIP core lib has resources to send a signal.
327 * Normally there no need to use this function.
328 *
329 * @param card the HIP core lib API context.
330 *
331 * @param sigptr pointer to the signal.
332 *
333 * @return \b 0 if there are resources for the signal.
334 *
335 * @return \b -CSR_ENOSPC if there are not enough resources
336 *
337 * @ingroup upperedge
338 */
339CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr);
340
341/**
342 *
343 * Read the UniFi chip and the HIP core lib information.
344 *
345 * @param card the HIP core lib API context.
346 *
347 * @param card_info pointer to save the information.
348 *
349 * @ingroup upperedge
350 */
351void unifi_card_info(card_t *card, card_info_t *card_info);
352
353/**
354 *
355 * Print the UniFi I/O and Interrupt status.
356 * Normally it is used for debug purposes only.
357 *
358 * @param card the HIP core lib API context.
359
360 * @param status buffer for the chip status
361 *
362 * @return \b 0 if the check was performed.
363 *
364 * @return \b -CSR_EIO if an error occurred while checking the status.
365 *
366 * @return \b -CSR_ENODEV if the card is no longer present.
367 *
368 * @ingroup upperedge
369 */
370CsrResult unifi_check_io_status(card_t *card, s32 *status);
371
372
373/**
374 *
375 * Run the HIP core lib Botton-Half.
376 * Whenever the HIP core lib want this function to be called
377 * by the OS layer, it calls unifi_run_bh().
378 *
379 * @param card the HIP core lib API context.
380 *
381 * @param remaining pointer to return the time (in msecs) that this function
382 * should be re-scheduled. A return value of 0 means that no re-scheduling
383 * is required. If unifi_bh() is called before the timeout expires,
384 * the caller must pass in the remaining time.
385 *
386 * @return \b 0 if no error occurred.
387 *
388 * @return \b -CSR_ENODEV if the card is no longer present.
389 *
390 * @return \b -CSR_E* if an error occurred while running the bottom half.
391 *
392 * @ingroup upperedge
393 */
394CsrResult unifi_bh(card_t *card, u32 *remaining);
395
396
397/**
398 * UniFi Low Power Mode (Deep Sleep Signaling)
399 *
400 * unifi_low_power_mode defines the UniFi Deep Sleep Signaling status.
401 * Use with unifi_configure_low_power_mode() to enable/disable
402 * the Deep Sleep Signaling.
403 */
404enum unifi_low_power_mode
405{
406 UNIFI_LOW_POWER_DISABLED,
407 UNIFI_LOW_POWER_ENABLED
408};
409
410/**
411 * Periodic Wake Host Mode
412 *
413 * unifi_periodic_wake_mode defines the Periodic Wake Host Mode.
414 * It can only be set to UNIFI_PERIODIC_WAKE_HOST_ENABLED if
415 * low_power_mode == UNIFI_LOW_POWER_ENABLED.
416 */
417enum unifi_periodic_wake_mode
418{
419 UNIFI_PERIODIC_WAKE_HOST_DISABLED,
420 UNIFI_PERIODIC_WAKE_HOST_ENABLED
421};
422
423/**
424 *
425 * Run the HIP core lib Botton-Half.
426 * Whenever the HIP core lib want this function to be called
427 * by the OS layer, it calls unifi_run_bh().
428 *
429 * Typically, the SME is responsible for configuring these parameters,
430 * so unifi_sys_configure_power_mode_req() is usually implemented
431 * as a direct call to unifi_configure_low_power_mode().
432 *
433 * Note: When polling mode is used instead of interrupts,
434 * low_power_mode must never be set to UNIFI_LOW_POWER_ENABLED.
435 *
436 * @param card the HIP core lib API context.
437 *
438 * @param low_power_mode the Low Power Mode.
439 *
440 * @param periodic_wake_mode the Periodic Wake Mode.
441 *
442 * @return \b 0 if no error occurred.
443 *
444 * @return \b -CSR_E* if the request failed.
445 *
446 * @ingroup upperedge
447 */
448CsrResult unifi_configure_low_power_mode(card_t *card,
449 enum unifi_low_power_mode low_power_mode,
450 enum unifi_periodic_wake_mode periodic_wake_mode);
451
452/**
453 *
454 * Forces the UniFi chip to enter a Deep Sleep state.
455 * This is normally called by the OS layer when the platform suspends.
456 *
457 * Note that if the UniFi Low Power Mode is disabled this call fails.
458 *
459 * @param card the HIP core lib API context.
460 *
461 * @return \b 0 if no error occurred.
462 *
463 * @return \b -CSR_ENODEV if the card is no longer present.
464 *
465 * @return \b -CSR_E* if the request failed.
466 *
467 * @ingroup upperedge
468 */
469CsrResult unifi_force_low_power_mode(card_t *card);
470
471#ifndef CSR_WIFI_HIP_TA_DISABLE
472/**
473 * Configure the Traffic Analysis sampling
474 *
475 * Enable or disable statistics gathering.
476 * Enable or disable particular packet detection.
477 *
478 * @param card the HIP core context
479 * @param config_type the item to configure
480 * @param config pointer to struct containing config info
481 *
482 * @return \b 0 if configuration was successful
483 *
484 * @return \b -CSR_EINVAL if a parameter had an invalid value
485 *
486 * @ingroup upperedge
487 */
488CsrResult unifi_ta_configure(card_t *card,
489 CsrWifiRouterCtrlTrafficConfigType config_type,
490 const CsrWifiRouterCtrlTrafficConfig *config);
491
492/**
493 * Pass a packet for Traffic Analysis sampling
494 *
495 * @param card the HIP core context
496 * @param direction the direction (Rx or Tx) of the frame.
497 * @param data pointer to bulkdata struct containing the packet
498 * @param saddr the source address of the packet
499 * @param sta_macaddr the MAC address of the UniFi chip
500 * @param timestamp the current time in msecs
501 *
502 * @ingroup upperedge
503 */
504void unifi_ta_sample(card_t *card,
505 CsrWifiRouterCtrlProtocolDirection direction,
506 const bulk_data_desc_t *data,
507 const u8 *saddr,
508 const u8 *sta_macaddr,
509 u32 timestamp,
510 u16 rate);
511
512/**
513 * Notify the HIP core lib for a detected Traffic Classification.
514 * Typically, the SME is responsible for configuring these parameters,
515 * so unifi_sys_traffic_classification_req() is usually implemented
516 * as a direct call to unifi_ta_classification().
517 *
518 * @param card the HIP core context.
519 * @param traffic_type the detected traffic type.
520 * @param period The detected period of the traffic.
521 *
522 * @ingroup upperedge
523 */
524void unifi_ta_classification(card_t *card,
525 CsrWifiRouterCtrlTrafficType traffic_type,
526 u16 period);
527
528#endif
529/**
530 * Use software to hard reset the chip.
531 * This is a subset of the unifi_init_card() functionality and should
532 * only be used only to reset a paniced chip before a coredump is taken.
533 *
534 * @param card the HIP core context.
535 *
536 * @ingroup upperedge
537 */
538CsrResult unifi_card_hard_reset(card_t *card);
539
540
541CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len);
542CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata);
543CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data);
544
545
546enum unifi_dbg_processors_select
547{
548 UNIFI_PROC_MAC,
549 UNIFI_PROC_PHY,
550 UNIFI_PROC_BT,
551 UNIFI_PROC_BOTH,
552 UNIFI_PROC_INVALID
553};
554
555CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which);
556
557/**
558 * Call-outs from the HIP core lib to the OS layer.
559 * The following functions need to be implemented during the porting exercise.
560 */
561
562/**
563 * Selects appropriate queue according to priority
564 * Helps maintain uniformity in queue selection between the HIP
565 * and the OS layers.
566 *
567 * @param priority priority of the packet
568 *
569 * @return \b Traffic queue to which a packet of this priority belongs
570 *
571 * @ingroup upperedge
572 */
573unifi_TrafficQueue
574unifi_frame_priority_to_queue(CSR_PRIORITY priority);
575
576/**
577 * Returns the priority corresponding to a particular Queue when that is used
578 * when downgrading a packet to a lower AC.
579 * Helps maintain uniformity in queue - priority mapping between the HIP
580 * and the OS layers.
581 *
582 * @param queue
583 *
584 * @return \b Highest priority corresponding to this queue
585 *
586 * @ingroup upperedge
587 */
588CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue);
589
590/**
591 *
592 * Flow control callbacks.
593 * unifi_pause_xmit() is called when the HIP core lib does not have any
594 * resources to store data packets. The OS layer needs to pause
595 * the Tx data plane until unifi_restart_xmit() is called.
596 *
597 * @param ospriv the OS layer context.
598 *
599 * @ingroup upperedge
600 */
601void unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue);
602void unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue);
603
604/**
605 *
606 * Request to run the Bottom-Half.
607 * The HIP core lib calls this function to request that unifi_bh()
608 * needs to be run by the OS layer. It can be called anytime, i.e.
609 * when the unifi_bh() is running.
610 * Since unifi_bh() is not re-entrant, usually unifi_run_bh() sets
611 * an event to a thread that schedules a call to unifi_bh().
612 *
613 * @param ospriv the OS layer context.
614 *
615 * @ingroup upperedge
616 */
617CsrResult unifi_run_bh(void *ospriv);
618
619/**
620 *
621 * Delivers a signal received from UniFi to the OS layer.
622 * Normally, the data signals should be delivered to the data plane
623 * and all the rest to the SME (unifi_sys_hip_ind()).
624 *
625 * Note that the OS layer is responsible for freeing the bulkdata
626 * buffers, using unifi_net_data_free().
627 *
628 * @param ospriv the OS layer context.
629 *
630 * @param sigptr pointer to the signal.
631 *
632 * @param siglen size of the signal.
633 *
634 * @param bulkdata pointer to the bulk data associated with the signal.
635 *
636 * @ingroup upperedge
637 */
638void unifi_receive_event(void *ospriv,
639 u8 *sigdata, u32 siglen,
640 const bulk_data_param_t *bulkdata);
641
642#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
643/**
644 *
645 * Used to reque the failed ma packet request back to hal queues
646 *
647 * @param ospriv the OS layer context.
648 *
649 * @param host_tag host tag for the packet to requeue.
650 *
651 * @param bulkDataDesc pointer to the bulk data.
652 *
653 * @ingroup upperedge
654 */
655CsrResult unifi_reque_ma_packet_request(void *ospriv, u32 host_tag,
656 u16 status,
657 bulk_data_desc_t *bulkDataDesc);
658
659#endif
660typedef struct
661{
662 u16 free_fh_sig_queue_slots[UNIFI_NO_OF_TX_QS];
663 u16 free_fh_bulkdata_slots;
664 u16 free_fh_fw_slots;
665} unifi_HipQosInfo;
666
667void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo);
668
669
670/**
671 * Functions that read a portion of a firmware file.
672 *
673 * Note: If the UniFi chip runs the f/w from ROM, the HIP core may never
674 * call these functions. Also, the HIP core may call these functions even if
675 * a f/w file is not available. In this case, it is safe to fail the request.
676 */
677#define UNIFI_FW_STA 1 /* Identify STA firmware file */
678
679/**
680 *
681 * Ask the OS layer to initialise a read from a f/w file.
682 *
683 * @param ospriv the OS layer context.
684 *
685 * @param is_fw if 0 the request if for the loader file, if 1 the request
686 * is for a f/w file.
687 *
688 * @param info a card_info_t structure containing versions information.
689 * Note that some members of the structure may not be initialised.
690 *
691 * @return \p NULL if the file is not available, or a pointer which contains
692 * OS specific information for the file (typically the contents of the file)
693 * that the HIP core uses when calling unifi_fw_read() and unifi_fw_read_stop()
694 *
695 * @ingroup upperedge
696 */
697void* unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info);
698
699/**
700 *
701 * Ask the OS layer to return a portion from a f/w file.
702 *
703 * @param ospriv the OS layer context.
704 *
705 * @param arg the OS pointer returned by unifi_fw_read_start().
706 *
707 * @param offset the offset in the f/w file to read the read from.
708 *
709 * @param buf the buffer to store the returned data.
710 *
711 * @param len the size in bytes of the requested read.
712 *
713 * @ingroup upperedge
714 */
715s32 unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len);
716
717/**
718 *
719 * Ask the OS layer to finish reading from a f/w file.
720 *
721 * @param ospriv the OS layer context.
722 *
723 * @param dlpriv the OS pointer returned by unifi_fw_read_start().
724 *
725 * @ingroup upperedge
726 */
727void unifi_fw_read_stop(void *ospriv, void *dlpriv);
728
729/**
730 *
731 * Ask OS layer for a handle to a dynamically allocated firmware buffer
732 * (primarily intended for production test images which may need conversion)
733 *
734 * @param ospriv the OS layer context.
735 *
736 * @param fwbuf pointer to dynamically allocated buffer
737 *
738 * @param len length of provided buffer in bytes
739 *
740 * @ingroup upperedge
741 */
742void* unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len);
743
744/**
745 *
746 * Release a handle to a dynamically allocated firmware buffer
747 * (primarily intended for production test images which may need conversion)
748 *
749 * @param ospriv the OS layer context.
750 *
751 * @param fwbuf pointer to dynamically allocated buffer
752 *
753 * @ingroup upperedge
754 */
755void unifi_fw_close_buffer(void *ospriv, void *fwbuf);
756
757#ifndef CSR_WIFI_HIP_TA_DISABLE
758/*
759 * Driver must provide these.
760 *
761 * A simple implementation will just call
762 * unifi_sys_traffic_protocol_ind() or unifi_sys_traffic_classification_ind()
763 * respectively. See sme_csr_userspace/sme_userspace.c.
764 */
765/**
766 *
767 * Indicates a detected packet of type packet_type.
768 * Typically, this information is processed by the SME so
769 * unifi_ta_indicate_protocol() needs to schedule a call to
770 * unifi_sys_traffic_protocol_ind().
771 *
772 * @param ospriv the OS layer context.
773 *
774 * @param packet_type the detected packet type.
775 *
776 * @param direction the direction of the packet (Rx, Tx).
777 *
778 * @param src_addr the source address of the packet.
779 *
780 * @ingroup upperedge
781 */
782void unifi_ta_indicate_protocol(void *ospriv,
783 CsrWifiRouterCtrlTrafficPacketType packet_type,
784 CsrWifiRouterCtrlProtocolDirection direction,
785 const CsrWifiMacAddress *src_addr);
786
787/**
788 *
789 * Indicates statistics for the sample data over a period.
790 * Typically, this information is processed by the SME so
791 * unifi_ta_indicate_sampling() needs to schedule a call to
792 * unifi_sys_traffic_sample_ind().
793 *
794 * @param ospriv the OS layer context.
795 *
796 * @param stats the pointer to the structure that contains the statistics.
797 *
798 * @ingroup upperedge
799 */
800void unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats);
801void unifi_ta_indicate_l4stats(void *ospriv,
802 u32 rxTcpThroughput,
803 u32 txTcpThroughput,
804 u32 rxUdpThroughput,
805 u32 txUdpThroughput);
806#endif
807
808void unifi_rx_queue_flush(void *ospriv);
809
810/**
811 * Call-out from the SDIO glue layer.
812 *
813 * The glue layer needs to call unifi_sdio_interrupt_handler() every time
814 * an interrupts occurs.
815 *
816 * @param card the HIP core context.
817 *
818 * @ingroup bottomedge
819 */
820void unifi_sdio_interrupt_handler(card_t *card);
821
822
823/* HELPER FUNCTIONS */
824
825/*
826 * unifi_init() and unifi_download() implement a subset of unifi_init_card functionality
827 * that excludes HIP initialization.
828 */
829CsrResult unifi_init(card_t *card);
830CsrResult unifi_download(card_t *card, s32 led_mask);
831
832/*
833 * unifi_start_processors() ensures both on-chip processors are running
834 */
835CsrResult unifi_start_processors(card_t *card);
836
837CsrResult unifi_capture_panic(card_t *card);
838
839/*
840 * Configure HIP interrupt processing mode
841 */
842#define CSR_WIFI_INTMODE_DEFAULT 0
843#define CSR_WIFI_INTMODE_RUN_BH_ONCE 1 /* Run BH once per interrupt */
844
845void unifi_set_interrupt_mode(card_t *card, u32 mode);
846
847/*
848 * unifi_request_max_clock() requests that max SDIO clock speed is set at the
849 * next suitable opportunity.
850 */
851void unifi_request_max_sdio_clock(card_t *card);
852
853
854/* Functions to lookup bulk data command names. */
855const char* lookup_bulkcmd_name(u16 id);
856
857/* Function to log HIP's global debug buffer */
858#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
859void unifi_debug_buf_dump(void);
860void unifi_debug_log_to_buf(const char *fmt, ...);
861void unifi_debug_hex_to_buf(const char *buff, u16 length);
862#endif
863
864/* Mini-coredump utility functions */
865CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req);
866CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req);
867CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable);
868CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers);
869void unifi_coredump_free(card_t *card);
870
871#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
index 9a3528599f3c..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c
+++ /dev/null
@@ -1,41 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include "csr_wifi_hip_unifi.h"
12
13struct sig_name {
14 s16 id;
15 const char *name;
16};
17
18static const struct sig_name Unifi_bulkcmd_names[] = {
19 { 0, "SignalCmd" },
20 { 1, "CopyToHost" },
21 { 2, "CopyToHostAck" },
22 { 3, "CopyFromHost" },
23 { 4, "CopyFromHostAck" },
24 { 5, "ClearSlot" },
25 { 6, "CopyOverlay" },
26 { 7, "CopyOverlayAck" },
27 { 8, "CopyFromHostAndClearSlot" },
28 { 15, "Padding" }
29};
30
31const char *lookup_bulkcmd_name(u16 id)
32{
33 if (id < 9)
34 return Unifi_bulkcmd_names[id].name;
35 if (id == 15)
36 return "Padding";
37
38 return "UNKNOWN";
39}
40
41
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
index 4126e85bfe9b..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_unifi_udi.h
14 *
15 * PURPOSE:
16 * Declarations and definitions for the UniFi Debug Interface.
17 *
18 * ---------------------------------------------------------------------------
19 */
20#ifndef __CSR_WIFI_HIP_UNIFI_UDI_H__
21#define __CSR_WIFI_HIP_UNIFI_UDI_H__
22
23#include "csr_wifi_hip_unifi.h"
24#include "csr_wifi_hip_signals.h"
25
26
27/*
28 * Support for tracing the wire protocol.
29 */
30enum udi_log_direction
31{
32 UDI_LOG_FROM_HOST = 0x0000,
33 UDI_LOG_TO_HOST = 0x0001
34};
35
36typedef void (*udi_func_t)(void *ospriv, u8 *sigdata,
37 u32 signal_len,
38 const bulk_data_param_t *bulkdata,
39 enum udi_log_direction dir);
40
41CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn);
42CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn);
43
44
45/*
46 * Function to print current status info to a string.
47 * This is used in the linux /proc interface and might be useful
48 * in other systems.
49 */
50s32 unifi_print_status(card_t *card, struct seq_file *m);
51
52#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
index 3f9fcbd55b55..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_unifihw.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 *
14 * File: csr_wifi_hip_unifihw.h
15 *
16 * Definitions of various chip registers, addresses, values etc.
17 *
18 * ---------------------------------------------------------------------------
19 */
20#ifndef __UNIFIHW_H__
21#define __UNIFIHW_H__ 1
22
23/* Symbol Look Up Table fingerprint. IDs are in sigs.h */
24#define SLUT_FINGERPRINT 0xD397
25
26
27/* Values of LoaderOperation */
28#define UNIFI_LOADER_IDLE 0x00
29#define UNIFI_LOADER_COPY 0x01
30#define UNIFI_LOADER_ERROR_MASK 0xF0
31
32/* Values of BootLoaderOperation */
33#define UNIFI_BOOT_LOADER_IDLE 0x00
34#define UNIFI_BOOT_LOADER_RESTART 0x01
35#define UNIFI_BOOT_LOADER_PATCH 0x02
36#define UNIFI_BOOT_LOADER_LOAD_STA 0x10
37#define UNIFI_BOOT_LOADER_LOAD_PTEST 0x11
38
39
40/* Memory spaces encoded in top byte of Generic Pointer type */
41#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */
42#define UNIFI_EXT_FLASH 0x02 /* External FLASH */
43#define UNIFI_EXT_SRAM 0x03 /* External SRAM */
44#define UNIFI_REGISTERS 0x04 /* Registers */
45#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */
46#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */
47#define UNIFI_PHY_ROM 0x12 /* PHY ROM */
48#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */
49#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */
50#define UNIFI_MAC_ROM 0x22 /* MAC ROM */
51#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */
52#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */
53#define UNIFI_BT_ROM 0x32 /* BT ROM */
54
55#define UNIFI_MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O))
56#define UNIFI_GP_OFFSET(GP) ((GP) & 0xFFFFFF)
57#define UNIFI_GP_SPACE(GP) (((GP) >> 24) & 0xFF)
58
59#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
index d1c66783f32c..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_unifiversion.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: unifiversion.h
14 *
15 * PURPOSE:
16 * Version information for the portable UniFi driver.
17 *
18 * ---------------------------------------------------------------------------
19 */
20
21#ifndef __UNIFIVERSION_H__
22#define __UNIFIVERSION_H__
23
24/*
25 * The minimum version of Host Interface Protocol required by the driver.
26 */
27#define UNIFI_HIP_MAJOR_VERSION 9
28#define UNIFI_HIP_MINOR_VERSION 1
29
30#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
index 050a15fbadf9..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_xbv.c
+++ /dev/null
@@ -1,1076 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_xbv.c
14 *
15 * PURPOSE:
16 * Routines for downloading firmware to UniFi.
17 *
18 * UniFi firmware files use a nested TLV (Tag-Length-Value) format.
19 *
20 * ---------------------------------------------------------------------------
21 */
22#include <linux/slab.h>
23
24#ifdef CSR_WIFI_XBV_TEST
25/* Standalone test harness */
26#include "unifi_xbv.h"
27#include "csr_wifi_hip_unifihw.h"
28#else
29/* Normal driver build */
30#include "csr_wifi_hip_unifiversion.h"
31#include "csr_wifi_hip_card.h"
32#define DBG_TAG(t)
33#endif
34
35#include "csr_wifi_hip_xbv.h"
36
37#define STREAM_CHECKSUM 0x6d34 /* Sum of uint16s in each patch stream */
38
39/* XBV sizes used in patch conversion
40 */
41#define PTDL_MAX_SIZE 2048 /* Max bytes allowed per PTDL */
42#define PTDL_HDR_SIZE (4 + 2 + 6 + 2) /* sizeof(fw_id, sec_len, patch_cmd, csum) */
43
44/* Struct to represent a buffer for reading firmware file */
45
46typedef struct
47{
48 void *dlpriv;
49 s32 ioffset;
50 fwreadfn_t iread;
51} ct_t;
52
53/* Struct to represent a TLV field */
54typedef struct
55{
56 char t_name[4];
57 u32 t_len;
58} tag_t;
59
60
61#define TAG_EQ(i, v) (((i)[0] == (v)[0]) && \
62 ((i)[1] == (v)[1]) && \
63 ((i)[2] == (v)[2]) && \
64 ((i)[3] == (v)[3]))
65
66/* We create a small stack on the stack that contains an enum
67 * indicating the containing list segments, and the offset at which
68 * those lists end. This enables a lot more error checking. */
69typedef enum
70{
71 xbv_xbv1,
72 /*xbv_info,*/
73 xbv_fw,
74 xbv_vers,
75 xbv_vand,
76 xbv_ptch,
77 xbv_other
78} xbv_container;
79
80#define XBV_STACK_SIZE 6
81#define XBV_MAX_OFFS 0x7fffffff
82
83typedef struct
84{
85 struct
86 {
87 xbv_container container;
88 s32 ioffset_end;
89 } s[XBV_STACK_SIZE];
90 u32 ptr;
91} xbv_stack_t;
92
93static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag);
94static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len);
95static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len);
96static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
97 xbv_mode new_mode, xbv_container old_cont);
98static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack,
99 xbv_mode new_mode, xbv_container old_cont,
100 xbv_container new_cont, u32 ioff);
101
102static u32 write_uint16(void *buf, const u32 offset,
103 const u16 val);
104static u32 write_uint32(void *buf, const u32 offset,
105 const u32 val);
106static u32 write_bytes(void *buf, const u32 offset,
107 const u8 *data, const u32 len);
108static u32 write_tag(void *buf, const u32 offset,
109 const char *tag_str);
110static u32 write_chunk(void *buf, const u32 offset,
111 const char *tag_str,
112 const u32 payload_len);
113static u16 calc_checksum(void *buf, const u32 offset,
114 const u32 bytes_len);
115static u32 calc_patch_size(const xbv1_t *fwinfo);
116
117static u32 write_xbv_header(void *buf, const u32 offset,
118 const u32 file_payload_length);
119static u32 write_ptch_header(void *buf, const u32 offset,
120 const u32 fw_id);
121static u32 write_patchcmd(void *buf, const u32 offset,
122 const u32 dst_genaddr, const u16 len);
123static u32 write_reset_ptdl(void *buf, const u32 offset,
124 const xbv1_t *fwinfo, u32 fw_id);
125static u32 write_fwdl_to_ptdl(void *buf, const u32 offset,
126 fwreadfn_t readfn, const struct FWDL *fwdl,
127 const void *fw_buf, const u32 fw_id,
128 void *rdbuf);
129
130/*
131 * ---------------------------------------------------------------------------
132 * parse_xbv1
133 *
134 * Scan the firmware file to find the TLVs we are interested in.
135 * Actions performed:
136 * - check we support the file format version in VERF
137 * Store these TLVs if we have a firmware image:
138 * - SLTP Symbol Lookup Table Pointer
139 * - FWDL firmware download segments
140 * - FWOL firmware overlay segment
141 * - VMEQ Register probe tests to verify matching h/w
142 * Store these TLVs if we have a patch file:
143 * - FWID the firmware build ID that this file patches
144 * - PTDL The actual patches
145 *
146 * The structure pointed to by fwinfo is cleared and
147 * 'fwinfo->mode' is set to 'unknown'. The 'fwinfo->mode'
148 * variable is set to 'firmware' or 'patch' once we know which
149 * sort of XBV file we have.
150 *
151 * Arguments:
152 * readfn Pointer to function to call to read from the file.
153 * dlpriv Opaque pointer arg to pass to readfn.
154 * fwinfo Pointer to fwinfo struct to fill in.
155 *
156 * Returns:
157 * CSR_RESULT_SUCCESS on success, CSR error code on failure
158 * ---------------------------------------------------------------------------
159 */
160CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo)
161{
162 ct_t ct;
163 tag_t tag;
164 xbv_stack_t stack;
165
166 ct.dlpriv = dlpriv;
167 ct.ioffset = 0;
168 ct.iread = readfn;
169
170 memset(fwinfo, 0, sizeof(xbv1_t));
171 fwinfo->mode = xbv_unknown;
172
173 /* File must start with XBV1 triplet */
174 if (read_tag(card, &ct, &tag) <= 0)
175 {
176 unifi_error(NULL, "File is not UniFi firmware\n");
177 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
178 }
179
180 DBG_TAG(tag.t_name);
181
182 if (!TAG_EQ(tag.t_name, "XBV1"))
183 {
184 unifi_error(NULL, "File is not UniFi firmware (%s)\n", tag.t_name);
185 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
186 }
187
188 stack.ptr = 0;
189 stack.s[stack.ptr].container = xbv_xbv1;
190 stack.s[stack.ptr].ioffset_end = XBV_MAX_OFFS;
191
192 /* Now scan the file */
193 while (1)
194 {
195 s32 n;
196
197 n = read_tag(card, &ct, &tag);
198 if (n < 0)
199 {
200 unifi_error(NULL, "No tag\n");
201 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
202 }
203 if (n == 0)
204 {
205 /* End of file */
206 break;
207 }
208
209 DBG_TAG(tag.t_name);
210
211 /* File format version */
212 if (TAG_EQ(tag.t_name, "VERF"))
213 {
214 u32 version;
215
216 if (xbv_check(fwinfo, &stack, xbv_unknown, xbv_xbv1) ||
217 (tag.t_len != 2) ||
218 read_uint(card, &ct, &version, 2))
219 {
220 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
221 }
222 if (version != 0)
223 {
224 unifi_error(NULL, "Unsupported firmware file version: %d.%d\n",
225 version >> 8, version & 0xFF);
226 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
227 }
228 }
229 else if (TAG_EQ(tag.t_name, "LIST"))
230 {
231 char name[4];
232 u32 list_end;
233
234 list_end = ct.ioffset + tag.t_len;
235
236 if (read_bytes(card, &ct, name, 4))
237 {
238 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
239 }
240
241 DBG_TAG(name);
242 if (TAG_EQ(name, "FW "))
243 {
244 if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_xbv1, xbv_fw, list_end))
245 {
246 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
247 }
248 }
249 else if (TAG_EQ(name, "VERS"))
250 {
251 if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_fw, xbv_vers, list_end) ||
252 (fwinfo->vers.num_vand != 0))
253 {
254 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
255 }
256 }
257 else if (TAG_EQ(name, "VAND"))
258 {
259 struct VAND *vand;
260
261 if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_vers, xbv_vand, list_end) ||
262 (fwinfo->vers.num_vand >= MAX_VAND))
263 {
264 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
265 }
266
267 /* Get a new VAND */
268 vand = fwinfo->vand + fwinfo->vers.num_vand++;
269
270 /* Fill it in */
271 vand->first = fwinfo->num_vmeq;
272 vand->count = 0;
273 }
274 else if (TAG_EQ(name, "PTCH"))
275 {
276 if (xbv_push(fwinfo, &stack, xbv_patch, xbv_xbv1, xbv_ptch, list_end))
277 {
278 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
279 }
280 }
281 else
282 {
283 /* Skip over any other lists. We dont bother to push
284 * the new list type now as we would only pop it at
285 * the end of the outer loop. */
286 ct.ioffset += tag.t_len - 4;
287 }
288 }
289 else if (TAG_EQ(tag.t_name, "SLTP"))
290 {
291 u32 addr;
292
293 if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
294 (tag.t_len != 4) ||
295 (fwinfo->slut_addr != 0) ||
296 read_uint(card, &ct, &addr, 4))
297 {
298 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
299 }
300
301 fwinfo->slut_addr = addr;
302 }
303 else if (TAG_EQ(tag.t_name, "FWDL"))
304 {
305 u32 addr;
306 struct FWDL *fwdl;
307
308 if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
309 (fwinfo->num_fwdl >= MAX_FWDL) ||
310 (read_uint(card, &ct, &addr, 4)))
311 {
312 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
313 }
314
315 fwdl = fwinfo->fwdl + fwinfo->num_fwdl++;
316
317 fwdl->dl_size = tag.t_len - 4;
318 fwdl->dl_addr = addr;
319 fwdl->dl_offset = ct.ioffset;
320
321 ct.ioffset += tag.t_len - 4;
322 }
323 else if (TAG_EQ(tag.t_name, "FWOV"))
324 {
325 if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
326 (fwinfo->fwov.dl_size != 0) ||
327 (fwinfo->fwov.dl_offset != 0))
328 {
329 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
330 }
331
332 fwinfo->fwov.dl_size = tag.t_len;
333 fwinfo->fwov.dl_offset = ct.ioffset;
334
335 ct.ioffset += tag.t_len;
336 }
337 else if (TAG_EQ(tag.t_name, "VMEQ"))
338 {
339 u32 temp[3];
340 struct VAND *vand;
341 struct VMEQ *vmeq;
342
343 if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_vand) ||
344 (fwinfo->num_vmeq >= MAX_VMEQ) ||
345 (fwinfo->vers.num_vand == 0) ||
346 (tag.t_len != 8) ||
347 read_uint(card, &ct, &temp[0], 4) ||
348 read_uint(card, &ct, &temp[1], 2) ||
349 read_uint(card, &ct, &temp[2], 2))
350 {
351 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
352 }
353
354 /* Get the last VAND */
355 vand = fwinfo->vand + (fwinfo->vers.num_vand - 1);
356
357 /* Get a new VMEQ */
358 vmeq = fwinfo->vmeq + fwinfo->num_vmeq++;
359
360 /* Note that this VAND contains another VMEQ */
361 vand->count++;
362
363 /* Fill in the VMEQ */
364 vmeq->addr = temp[0];
365 vmeq->mask = (u16)temp[1];
366 vmeq->value = (u16)temp[2];
367 }
368 else if (TAG_EQ(tag.t_name, "FWID"))
369 {
370 u32 build_id;
371
372 if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) ||
373 (tag.t_len != 4) ||
374 (fwinfo->build_id != 0) ||
375 read_uint(card, &ct, &build_id, 4))
376 {
377 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
378 }
379
380 fwinfo->build_id = build_id;
381 }
382 else if (TAG_EQ(tag.t_name, "PTDL"))
383 {
384 struct PTDL *ptdl;
385
386 if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) ||
387 (fwinfo->num_ptdl >= MAX_PTDL))
388 {
389 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
390 }
391
392 /* Allocate a new PTDL */
393 ptdl = fwinfo->ptdl + fwinfo->num_ptdl++;
394
395 ptdl->dl_size = tag.t_len;
396 ptdl->dl_offset = ct.ioffset;
397
398 ct.ioffset += tag.t_len;
399 }
400 else
401 {
402 /*
403 * If we get here it is a tag we are not interested in,
404 * just skip over it.
405 */
406 ct.ioffset += tag.t_len;
407 }
408
409 /* Check to see if we are at the end of the currently stacked
410 * segment. We could finish more than one list at a time. */
411 while (ct.ioffset >= stack.s[stack.ptr].ioffset_end)
412 {
413 if (ct.ioffset > stack.s[stack.ptr].ioffset_end)
414 {
415 unifi_error(NULL,
416 "XBV file has overrun stack'd segment %d (%d > %d)\n",
417 stack.ptr, ct.ioffset, stack.s[stack.ptr].ioffset_end);
418 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
419 }
420 if (stack.ptr <= 0)
421 {
422 unifi_error(NULL, "XBV file has underrun stack pointer\n");
423 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
424 }
425 stack.ptr--;
426 }
427 }
428
429 if (stack.ptr != 0)
430 {
431 unifi_error(NULL, "Last list of XBV is not complete.\n");
432 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
433 }
434
435 return CSR_RESULT_SUCCESS;
436} /* xbv1_parse() */
437
438
439/* Check the the XBV file is of a consistant sort (either firmware or
440 * patch) and that we are in the correct containing list type. */
441static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
442 xbv_mode new_mode, xbv_container old_cont)
443{
444 /* If the new file mode is unknown the current packet could be in
445 * either (any) type of XBV file, and we cant make a decission at
446 * this time. */
447 if (new_mode != xbv_unknown)
448 {
449 if (fwinfo->mode == xbv_unknown)
450 {
451 fwinfo->mode = new_mode;
452 }
453 else if (fwinfo->mode != new_mode)
454 {
455 return -1;
456 }
457 }
458 /* If the current stack top doesn't match what we expect then the
459 * file is corrupt. */
460 if (stack->s[stack->ptr].container != old_cont)
461 {
462 return -1;
463 }
464 return 0;
465}
466
467
468/* Make checks as above and then enter a new list */
469static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack,
470 xbv_mode new_mode, xbv_container old_cont,
471 xbv_container new_cont, u32 new_ioff)
472{
473 if (xbv_check(fwinfo, stack, new_mode, old_cont))
474 {
475 return -1;
476 }
477
478 /* Check that our stack won't overflow. */
479 if (stack->ptr >= (XBV_STACK_SIZE - 1))
480 {
481 return -1;
482 }
483
484 /* Add the new list element to the top of the stack. */
485 stack->ptr++;
486 stack->s[stack->ptr].container = new_cont;
487 stack->s[stack->ptr].ioffset_end = new_ioff;
488
489 return 0;
490}
491
492
493static u32 xbv2uint(u8 *ptr, s32 len)
494{
495 u32 u = 0;
496 s16 i;
497
498 for (i = 0; i < len; i++)
499 {
500 u32 b;
501 b = ptr[i];
502 u += b << (i * 8);
503 }
504 return u;
505}
506
507
508static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag)
509{
510 u8 buf[8];
511 s32 n;
512
513 n = (*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, 8);
514 if (n <= 0)
515 {
516 return n;
517 }
518
519 /* read the tag and length */
520 if (n != 8)
521 {
522 return -1;
523 }
524
525 /* get section tag */
526 memcpy(tag->t_name, buf, 4);
527
528 /* get section length */
529 tag->t_len = xbv2uint(buf + 4, 4);
530
531 ct->ioffset += 8;
532
533 return 8;
534} /* read_tag() */
535
536
537static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len)
538{
539 /* read the tag value */
540 if ((*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, len) != (s32)len)
541 {
542 return -1;
543 }
544
545 ct->ioffset += len;
546
547 return 0;
548} /* read_bytes() */
549
550
551static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len)
552{
553 u8 buf[4];
554
555 /* Integer cannot be more than 4 bytes */
556 if (len > 4)
557 {
558 return -1;
559 }
560
561 if (read_bytes(card, ct, buf, len))
562 {
563 return -1;
564 }
565
566 *u = xbv2uint(buf, len);
567
568 return 0;
569} /* read_uint() */
570
571
572static u32 write_uint16(void *buf, const u32 offset, const u16 val)
573{
574 u8 *dst = (u8 *)buf + offset;
575 *dst++ = (u8)(val & 0xff); /* LSB first */
576 *dst = (u8)(val >> 8);
577 return sizeof(u16);
578}
579
580
581static u32 write_uint32(void *buf, const u32 offset, const u32 val)
582{
583 (void)write_uint16(buf, offset + 0, (u16)(val & 0xffff));
584 (void)write_uint16(buf, offset + 2, (u16)(val >> 16));
585 return sizeof(u32);
586}
587
588
589static u32 write_bytes(void *buf, const u32 offset, const u8 *data, const u32 len)
590{
591 u32 i;
592 u8 *dst = (u8 *)buf + offset;
593
594 for (i = 0; i < len; i++)
595 {
596 *dst++ = *((u8 *)data + i);
597 }
598 return len;
599}
600
601
602static u32 write_tag(void *buf, const u32 offset, const char *tag_str)
603{
604 u8 *dst = (u8 *)buf + offset;
605 memcpy(dst, tag_str, 4);
606 return 4;
607}
608
609
610static u32 write_chunk(void *buf, const u32 offset, const char *tag_str, const u32 payload_len)
611{
612 u32 written = 0;
613 written += write_tag(buf, offset, tag_str);
614 written += write_uint32(buf, written + offset, (u32)payload_len);
615
616 return written;
617}
618
619
620static u16 calc_checksum(void *buf, const u32 offset, const u32 bytes_len)
621{
622 u32 i;
623 u8 *src = (u8 *)buf + offset;
624 u16 sum = 0;
625 u16 val;
626
627 for (i = 0; i < bytes_len / 2; i++)
628 {
629 /* Contents copied to file is LE, host might not be */
630 val = (u16) * src++; /* LSB */
631 val += (u16)(*src++) << 8; /* MSB */
632 sum += val;
633 }
634
635 /* Total of uint16s in the stream plus the stored check value
636 * should equal STREAM_CHECKSUM when decoded.
637 */
638 return (STREAM_CHECKSUM - sum);
639}
640
641
642#define PTDL_RESET_DATA_SIZE 20 /* Size of reset vectors PTDL */
643
644static u32 calc_patch_size(const xbv1_t *fwinfo)
645{
646 s16 i;
647 u32 size = 0;
648
649 /*
650 * Work out how big an equivalent patch format file must be for this image.
651 * This only needs to be approximate, so long as it's large enough.
652 */
653 if (fwinfo->mode != xbv_firmware)
654 {
655 return 0;
656 }
657
658 /* Payload (which will get put into a series of PTDLs) */
659 for (i = 0; i < fwinfo->num_fwdl; i++)
660 {
661 size += fwinfo->fwdl[i].dl_size;
662 }
663
664 /* Another PTDL at the end containing reset vectors */
665 size += PTDL_RESET_DATA_SIZE;
666
667 /* PTDL headers. Add one for remainder, one for reset vectors */
668 size += ((fwinfo->num_fwdl / PTDL_MAX_SIZE) + 2) * PTDL_HDR_SIZE;
669
670 /* Another 1K sufficient to cover miscellaneous headers */
671 size += 1024;
672
673 return size;
674}
675
676
677static u32 write_xbv_header(void *buf, const u32 offset, const u32 file_payload_length)
678{
679 u32 written = 0;
680
681 /* The length value given to the XBV chunk is the length of all subsequent
682 * contents of the file, excluding the 8 byte size of the XBV1 header itself
683 * (The added 6 bytes thus accounts for the size of the VERF)
684 */
685 written += write_chunk(buf, offset + written, (char *)"XBV1", file_payload_length + 6);
686
687 written += write_chunk(buf, offset + written, (char *)"VERF", 2);
688 written += write_uint16(buf, offset + written, 0); /* File version */
689
690 return written;
691}
692
693
694static u32 write_ptch_header(void *buf, const u32 offset, const u32 fw_id)
695{
696 u32 written = 0;
697
698 /* LIST is written with a zero length, to be updated later */
699 written += write_chunk(buf, offset + written, (char *)"LIST", 0);
700 written += write_tag(buf, offset + written, (char *)"PTCH"); /* List type */
701
702 written += write_chunk(buf, offset + written, (char *)"FWID", 4);
703 written += write_uint32(buf, offset + written, fw_id);
704
705
706 return written;
707}
708
709
710#define UF_REGION_PHY 1
711#define UF_REGION_MAC 2
712#define UF_MEMPUT_MAC 0x0000
713#define UF_MEMPUT_PHY 0x1000
714
715static u32 write_patchcmd(void *buf, const u32 offset, const u32 dst_genaddr, const u16 len)
716{
717 u32 written = 0;
718 u32 region = (dst_genaddr >> 28);
719 u16 cmd_and_len = UF_MEMPUT_MAC;
720
721 if (region == UF_REGION_PHY)
722 {
723 cmd_and_len = UF_MEMPUT_PHY;
724 }
725 else if (region != UF_REGION_MAC)
726 {
727 return 0; /* invalid */
728 }
729
730 /* Write the command and data length */
731 cmd_and_len |= len;
732 written += write_uint16(buf, offset + written, cmd_and_len);
733
734 /* Write the destination generic address */
735 written += write_uint16(buf, offset + written, (u16)(dst_genaddr >> 16));
736 written += write_uint16(buf, offset + written, (u16)(dst_genaddr & 0xffff));
737
738 /* The data payload should be appended to the command */
739 return written;
740}
741
742
743static u32 write_fwdl_to_ptdl(void *buf, const u32 offset, fwreadfn_t readfn,
744 const struct FWDL *fwdl, const void *dlpriv,
745 const u32 fw_id, void *fw_buf)
746{
747 u32 written = 0;
748 s16 chunks = 0;
749 u32 left = fwdl->dl_size; /* Bytes left in this fwdl */
750 u32 dl_addr = fwdl->dl_addr; /* Target address of fwdl image on XAP */
751 u32 dl_offs = fwdl->dl_offset; /* Offset of fwdl image data in source */
752 u16 csum;
753 u32 csum_start_offs; /* first offset to include in checksum */
754 u32 sec_data_len; /* section data byte count */
755 u32 sec_len; /* section data + header byte count */
756
757 /* FWDL maps to one or more PTDLs, as max size for a PTDL is 1K words */
758 while (left)
759 {
760 /* Calculate amount to be transferred */
761 sec_data_len = min_t(u32, left, PTDL_MAX_SIZE - PTDL_HDR_SIZE);
762 sec_len = sec_data_len + PTDL_HDR_SIZE;
763
764 /* Write PTDL header + entire PTDL size */
765 written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len);
766 /* bug digest implies 4 bytes of padding here, but that seems wrong */
767
768 /* Checksum starts here */
769 csum_start_offs = offset + written;
770
771 /* Patch-chunk header: fw_id. Note that this is in XAP word order */
772 written += write_uint16(buf, offset + written, (u16)(fw_id >> 16));
773 written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff));
774
775 /* Patch-chunk header: section length in uint16s */
776 written += write_uint16(buf, offset + written, (u16)(sec_len / 2));
777
778
779 /* Write the appropriate patch command for the data's destination ptr */
780 written += write_patchcmd(buf, offset + written, dl_addr, (u16)(sec_data_len / 2));
781
782 /* Write the data itself (limited to the max chunk length) */
783 if (readfn(NULL, (void *)dlpriv, dl_offs, fw_buf, sec_data_len) < 0)
784 {
785 return 0;
786 }
787
788 written += write_bytes(buf,
789 offset + written,
790 fw_buf,
791 sec_data_len);
792
793 /* u16 checksum calculated over data written */
794 csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset));
795 written += write_uint16(buf, offset + written, csum);
796
797 left -= sec_data_len;
798 dl_addr += sec_data_len;
799 dl_offs += sec_data_len;
800 chunks++;
801 }
802
803 return written;
804}
805
806
807#define SEC_CMD_LEN ((4 + 2) * 2) /* sizeof(cmd, vector) per XAP */
808#define PTDL_VEC_HDR_SIZE (4 + 2 + 2) /* sizeof(fw_id, sec_len, csum) */
809#define UF_MAC_START_VEC 0x00c00000 /* Start address of image on MAC */
810#define UF_PHY_START_VEC 0x00c00000 /* Start address of image on PHY */
811#define UF_MAC_START_CMD 0x6000 /* MAC "Set start address" command */
812#define UF_PHY_START_CMD 0x7000 /* PHY "Set start address" command */
813
814static u32 write_reset_ptdl(void *buf, const u32 offset, const xbv1_t *fwinfo, u32 fw_id)
815{
816 u32 written = 0;
817 u16 csum;
818 u32 csum_start_offs; /* first offset to include in checksum */
819 u32 sec_len; /* section data + header byte count */
820
821 sec_len = SEC_CMD_LEN + PTDL_VEC_HDR_SIZE; /* Total section byte length */
822
823 /* Write PTDL header + entire PTDL size */
824 written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len);
825
826 /* Checksum starts here */
827 csum_start_offs = offset + written;
828
829 /* Patch-chunk header: fw_id. Note that this is in XAP word order */
830 written += write_uint16(buf, offset + written, (u16)(fw_id >> 16));
831 written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff));
832
833 /* Patch-chunk header: section length in uint16s */
834 written += write_uint16(buf, offset + written, (u16)(sec_len / 2));
835
836 /*
837 * Restart addresses to be executed on subsequent loader restart command.
838 */
839
840 /* Setup the MAC start address, note word ordering */
841 written += write_uint16(buf, offset + written, UF_MAC_START_CMD);
842 written += write_uint16(buf, offset + written, (UF_MAC_START_VEC >> 16));
843 written += write_uint16(buf, offset + written, (UF_MAC_START_VEC & 0xffff));
844
845 /* Setup the PHY start address, note word ordering */
846 written += write_uint16(buf, offset + written, UF_PHY_START_CMD);
847 written += write_uint16(buf, offset + written, (UF_PHY_START_VEC >> 16));
848 written += write_uint16(buf, offset + written, (UF_PHY_START_VEC & 0xffff));
849
850 /* u16 checksum calculated over data written */
851 csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset));
852 written += write_uint16(buf, offset + written, csum);
853
854 return written;
855}
856
857
858/*
859 * ---------------------------------------------------------------------------
860 * read_slut
861 *
862 * desc
863 *
864 * Arguments:
865 * readfn Pointer to function to call to read from the file.
866 * dlpriv Opaque pointer arg to pass to readfn.
867 * addr Offset into firmware image of SLUT.
868 * fwinfo Pointer to fwinfo struct to fill in.
869 *
870 * Returns:
871 * Number of SLUT entries in the f/w, or -1 if the image was corrupt.
872 * ---------------------------------------------------------------------------
873 */
874s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
875 symbol_t *slut, u32 slut_len)
876{
877 s16 i;
878 s32 offset;
879 u32 magic;
880 u32 count = 0;
881 ct_t ct;
882
883 if (fwinfo->mode != xbv_firmware)
884 {
885 return -1;
886 }
887
888 /* Find the d/l segment containing the SLUT */
889 /* This relies on the SLUT being entirely contained in one segment */
890 offset = -1;
891 for (i = 0; i < fwinfo->num_fwdl; i++)
892 {
893 if ((fwinfo->slut_addr >= fwinfo->fwdl[i].dl_addr) &&
894 (fwinfo->slut_addr < (fwinfo->fwdl[i].dl_addr + fwinfo->fwdl[i].dl_size)))
895 {
896 offset = fwinfo->fwdl[i].dl_offset +
897 (fwinfo->slut_addr - fwinfo->fwdl[i].dl_addr);
898 }
899 }
900 if (offset < 0)
901 {
902 return -1;
903 }
904
905 ct.dlpriv = dlpriv;
906 ct.ioffset = offset;
907 ct.iread = readfn;
908
909 if (read_uint(card, &ct, &magic, 2))
910 {
911 return -1;
912 }
913 if (magic != SLUT_FINGERPRINT)
914 {
915 return -1;
916 }
917
918 while (count < slut_len)
919 {
920 u32 id, obj;
921
922 /* Read Symbol Id */
923 if (read_uint(card, &ct, &id, 2))
924 {
925 return -1;
926 }
927
928 /* Check for end of table marker */
929 if (id == CSR_SLT_END)
930 {
931 break;
932 }
933
934 /* Read Symbol Value */
935 if (read_uint(card, &ct, &obj, 4))
936 {
937 return -1;
938 }
939
940 slut[count].id = (u16)id;
941 slut[count].obj = obj;
942 count++;
943 }
944
945 return count;
946} /* read_slut() */
947
948
949/*
950 * ---------------------------------------------------------------------------
951 * xbv_to_patch
952 *
953 * Convert (the relevant parts of) a firmware xbv file into a patch xbv
954 *
955 * Arguments:
956 * card
957 * fw_buf - pointer to xbv firmware image
958 * fwinfo - structure describing the firmware image
959 * size - pointer to location into which size of f/w is written.
960 *
961 * Returns:
962 * Pointer to firmware image, or NULL on error. Caller must free this
963 * buffer via kfree() once it's finished with.
964 *
965 * Notes:
966 * The input fw_buf should have been checked via xbv1_parse prior to
967 * calling this function, so the input image is assumed valid.
968 * ---------------------------------------------------------------------------
969 */
970#define PTCH_LIST_SIZE 16 /* sizeof PTCH+FWID chunk in LIST header */
971
972void* xbv_to_patch(card_t *card, fwreadfn_t readfn,
973 const void *fw_buf, const xbv1_t *fwinfo, u32 *size)
974{
975 void *patch_buf = NULL;
976 u32 patch_buf_size;
977 u32 payload_offs = 0; /* Start of XBV payload */
978 s16 i;
979 u32 patch_offs = 0;
980 u32 list_len_offs = 0; /* Offset of PTDL LIST length parameter */
981 u32 ptdl_start_offs = 0; /* Offset of first PTDL chunk */
982 u32 fw_id;
983 void *rdbuf;
984
985 if (!fw_buf || !fwinfo || !card)
986 {
987 return NULL;
988 }
989
990 if (fwinfo->mode != xbv_firmware)
991 {
992 unifi_error(NULL, "Not a firmware file\n");
993 return NULL;
994 }
995
996 /* Pre-allocate read buffer for chunk conversion */
997 rdbuf = kmalloc(PTDL_MAX_SIZE, GFP_KERNEL);
998 if (!rdbuf)
999 {
1000 unifi_error(card, "Couldn't alloc conversion buffer\n");
1001 return NULL;
1002 }
1003
1004 /* Loader requires patch file's build ID to match the running firmware's */
1005 fw_id = card->build_id;
1006
1007 /* Firmware XBV1 contains VERF, optional INFO, SLUT(s), FWDL(s) */
1008 /* Other chunks should get skipped. */
1009 /* VERF should be sanity-checked against chip version */
1010
1011 /* Patch XBV1 contains VERF, optional INFO, PTCH */
1012 /* PTCH contains FWID, optional INFO, PTDL(s), PTDL(start_vec) */
1013 /* Each FWDL is split into PTDLs (each is 1024 XAP words max) */
1014 /* Each PTDL contains running ROM f/w version, and checksum */
1015 /* MAC/PHY reset addresses (known) are added into a final PTDL */
1016
1017 /* The input image has already been parsed, and loaded into fwinfo, so we
1018 * can use that to build the output image
1019 */
1020 patch_buf_size = calc_patch_size(fwinfo);
1021
1022 patch_buf = kmalloc(patch_buf_size, GFP_KERNEL);
1023 if (!patch_buf)
1024 {
1025 kfree(rdbuf);
1026 unifi_error(NULL, "Can't malloc buffer for patch conversion\n");
1027 return NULL;
1028 }
1029
1030 memset(patch_buf, 0xdd, patch_buf_size);
1031
1032 /* Write XBV + VERF headers */
1033 patch_offs += write_xbv_header(patch_buf, patch_offs, 0);
1034 payload_offs = patch_offs;
1035
1036 /* Write patch (LIST) header */
1037 list_len_offs = patch_offs + 4; /* Save LIST.length offset for later update */
1038 patch_offs += write_ptch_header(patch_buf, patch_offs, fw_id);
1039
1040 /* Save start offset of the PTDL chunks */
1041 ptdl_start_offs = patch_offs;
1042
1043 /* Write LIST of firmware PTDL blocks */
1044 for (i = 0; i < fwinfo->num_fwdl; i++)
1045 {
1046 patch_offs += write_fwdl_to_ptdl(patch_buf,
1047 patch_offs,
1048 readfn,
1049 &fwinfo->fwdl[i],
1050 fw_buf,
1051 fw_id,
1052 rdbuf);
1053 }
1054
1055 /* Write restart-vector PTDL last */
1056 patch_offs += write_reset_ptdl(patch_buf, patch_offs, fwinfo, fw_id);
1057
1058 /* Now the length is known, update the LIST.length */
1059 (void)write_uint32(patch_buf, list_len_offs,
1060 (patch_offs - ptdl_start_offs) + PTCH_LIST_SIZE);
1061
1062 /* Re write XBV headers just to fill in the correct file size */
1063 (void)write_xbv_header(patch_buf, 0, (patch_offs - payload_offs));
1064
1065 unifi_trace(card->ospriv, UDBG1, "XBV:PTCH size %u, fw_id %u\n",
1066 patch_offs, fw_id);
1067 if (size)
1068 {
1069 *size = patch_offs;
1070 }
1071 kfree(rdbuf);
1072
1073 return patch_buf;
1074}
1075
1076
diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.h b/drivers/staging/csr/csr_wifi_hip_xbv.h
deleted file mode 100644
index 3c507235323d..000000000000
--- a/drivers/staging/csr/csr_wifi_hip_xbv.h
+++ /dev/null
@@ -1,119 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/*
12 * ---------------------------------------------------------------------------
13 * FILE: csr_wifi_hip_xbv.h
14 *
15 * PURPOSE:
16 * Definitions and declarations for code to read XBV files - the UniFi
17 * firmware download file format.
18 *
19 * ---------------------------------------------------------------------------
20 */
21#ifndef __XBV_H__
22#define __XBV_H__
23
24#ifndef CSR_WIFI_XBV_TEST
25/* Driver includes */
26#include "csr_wifi_hip_unifi.h"
27#endif
28
29
30struct VMEQ
31{
32 u32 addr;
33 u16 mask;
34 u16 value;
35};
36
37struct VAND
38{
39 u32 first;
40 u32 count;
41};
42
43struct VERS
44{
45 u32 num_vand;
46};
47
48struct FWDL
49{
50 u32 dl_addr;
51 u32 dl_size;
52 u32 dl_offset;
53};
54
55struct FWOV
56{
57 u32 dl_size;
58 u32 dl_offset;
59};
60
61struct PTDL
62{
63 u32 dl_size;
64 u32 dl_offset;
65};
66
67#define MAX_VMEQ 64
68#define MAX_VAND 64
69#define MAX_FWDL 256
70#define MAX_PTDL 256
71
72/* An XBV1 file can either contain firmware or patches (at the
73 * moment). The 'mode' member of the xbv1_t structure tells us which
74 * one is the case. */
75typedef enum
76{
77 xbv_unknown,
78 xbv_firmware,
79 xbv_patch
80} xbv_mode;
81
82typedef struct
83{
84 xbv_mode mode;
85
86 /* Parts of a Firmware XBV1 */
87
88 struct VMEQ vmeq[MAX_VMEQ];
89 u32 num_vmeq;
90 struct VAND vand[MAX_VAND];
91 struct VERS vers;
92
93 u32 slut_addr;
94
95 /* F/W download image, possibly more than one part */
96 struct FWDL fwdl[MAX_FWDL];
97 s16 num_fwdl;
98
99 /* F/W overlay image, add r not used */
100 struct FWOV fwov;
101
102 /* Parts of a Patch XBV1 */
103
104 u32 build_id;
105
106 struct PTDL ptdl[MAX_PTDL];
107 s16 num_ptdl;
108} xbv1_t;
109
110
111typedef s32 (*fwreadfn_t)(void *ospriv, void *dlpriv, u32 offset, void *buf, u32 len);
112
113CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo);
114s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
115 symbol_t *slut, u32 slut_len);
116void* xbv_to_patch(card_t *card, fwreadfn_t readfn, const void *fw_buf, const xbv1_t *fwinfo,
117 u32 *size);
118
119#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
index cfb3e272e359..000000000000
--- a/drivers/staging/csr/csr_wifi_hostio_prim.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11
12#ifndef CSR_WIFI_HOSTIO_H
13#define CSR_WIFI_HOSTIO_H
14
15#define CSR_WIFI_HOSTIO_PRIM 0x0453
16
17#endif /* CSR_WIFI_HOSTIO_H */
18
diff --git a/drivers/staging/csr/csr_wifi_lib.h b/drivers/staging/csr/csr_wifi_lib.h
deleted file mode 100644
index 5fde0efb5dca..000000000000
--- a/drivers/staging/csr/csr_wifi_lib.h
+++ /dev/null
@@ -1,103 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10#ifndef CSR_WIFI_LIB_H__
11#define CSR_WIFI_LIB_H__
12
13#include "csr_wifi_fsm_event.h"
14
15/*----------------------------------------------------------------------------*
16 * CsrWifiFsmEventInit
17 *
18 * DESCRIPTION
19 * Macro to initialise the members of a CsrWifiFsmEvent.
20 *----------------------------------------------------------------------------*/
21#define CsrWifiFsmEventInit(evt, p_primtype, p_msgtype, p_dst, p_src) \
22 (evt)->primtype = p_primtype; \
23 (evt)->type = p_msgtype; \
24 (evt)->destination = p_dst; \
25 (evt)->source = p_src
26
27
28/*----------------------------------------------------------------------------*
29 * CsrWifiEvent_struct
30 *
31 * DESCRIPTION
32 * Generic message creator.
33 * Allocates and fills in a message with the signature CsrWifiEvent
34 *
35 *----------------------------------------------------------------------------*/
36CsrWifiFsmEvent* CsrWifiEvent_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src);
37
38typedef struct
39{
40 CsrWifiFsmEvent common;
41 u8 value;
42} CsrWifiEventCsrUint8;
43
44/*----------------------------------------------------------------------------*
45 * CsrWifiEventCsrUint8_struct
46 *
47 * DESCRIPTION
48 * Generic message creator.
49 * Allocates and fills in a message with the signature CsrWifiEventCsrUint8
50 *
51 *----------------------------------------------------------------------------*/
52CsrWifiEventCsrUint8* CsrWifiEventCsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u8 value);
53
54typedef struct
55{
56 CsrWifiFsmEvent common;
57 u16 value;
58} CsrWifiEventCsrUint16;
59
60/*----------------------------------------------------------------------------*
61 * CsrWifiEventCsrUint16_struct
62 *
63 * DESCRIPTION
64 * Generic message creator.
65 * Allocates and fills in a message with the signature CsrWifiEventCsrUint16
66 *
67 *----------------------------------------------------------------------------*/
68CsrWifiEventCsrUint16* CsrWifiEventCsrUint16_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value);
69
70typedef struct
71{
72 CsrWifiFsmEvent common;
73 u32 value;
74} CsrWifiEventCsrUint32;
75
76/*----------------------------------------------------------------------------*
77 * CsrWifiEventCsrUint32_struct
78 *
79 * DESCRIPTION
80 * Generic message creator.
81 * Allocates and fills in a message with the signature CsrWifiEventCsrUint32
82 *
83 *----------------------------------------------------------------------------*/
84CsrWifiEventCsrUint32* CsrWifiEventCsrUint32_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u32 value);
85
86typedef struct
87{
88 CsrWifiFsmEvent common;
89 u16 value16;
90 u8 value8;
91} CsrWifiEventCsrUint16CsrUint8;
92
93/*----------------------------------------------------------------------------*
94 * CsrWifiEventCsrUint16CsrUint8_struct
95 *
96 * DESCRIPTION
97 * Generic message creator.
98 * Allocates and fills in a message with the signature CsrWifiEventCsrUint16CsrUint8
99 *
100 *----------------------------------------------------------------------------*/
101CsrWifiEventCsrUint16CsrUint8* CsrWifiEventCsrUint16CsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value16, u8 value8);
102
103#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
index f8b402947a09..000000000000
--- a/drivers/staging/csr/csr_wifi_msgconv.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_MSGCONV_H__
12#define CSR_WIFI_MSGCONV_H__
13
14#include "csr_prim_defs.h"
15#include "csr_sched.h"
16
17void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v);
18void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v);
19void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v);
20
21void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset);
22void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset);
23void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset);
24
25void CsrUint24Ser(u8 *ptr, size_t *len, u32 v);
26void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset);
27
28
29size_t CsrWifiEventSizeof(void *msg);
30u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg);
31void* CsrWifiEventDes(u8 *buffer, size_t length);
32
33size_t CsrWifiEventCsrUint8Sizeof(void *msg);
34u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg);
35void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length);
36
37size_t CsrWifiEventCsrUint16Sizeof(void *msg);
38u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg);
39void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length);
40
41size_t CsrWifiEventCsrUint32Sizeof(void *msg);
42u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg);
43void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length);
44
45size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg);
46u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg);
47void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length);
48
49#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
index 0689d6f1cab1..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c
+++ /dev/null
@@ -1,90 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#include "csr_msgconv.h"
14#include "csr_macro.h"
15
16#ifdef CSR_WIFI_NME_ENABLE
17#ifdef CSR_WIFI_AP_ENABLE
18
19#ifdef CSR_LOG_ENABLE
20#include "csr_log.h"
21#endif
22
23#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE
24#include "csr_wifi_nme_ap_serialize.h"
25#include "csr_wifi_nme_ap_prim.h"
26
27static CsrMsgConvMsgEntry csrwifinmeap_conv_lut[] = {
28 { CSR_WIFI_NME_AP_CONFIG_SET_REQ, CsrWifiNmeApConfigSetReqSizeof, CsrWifiNmeApConfigSetReqSer, CsrWifiNmeApConfigSetReqDes, CsrWifiNmeApConfigSetReqSerFree },
29 { CSR_WIFI_NME_AP_WPS_REGISTER_REQ, CsrWifiNmeApWpsRegisterReqSizeof, CsrWifiNmeApWpsRegisterReqSer, CsrWifiNmeApWpsRegisterReqDes, CsrWifiNmeApWpsRegisterReqSerFree },
30 { CSR_WIFI_NME_AP_START_REQ, CsrWifiNmeApStartReqSizeof, CsrWifiNmeApStartReqSer, CsrWifiNmeApStartReqDes, CsrWifiNmeApStartReqSerFree },
31 { CSR_WIFI_NME_AP_STOP_REQ, CsrWifiNmeApStopReqSizeof, CsrWifiNmeApStopReqSer, CsrWifiNmeApStopReqDes, CsrWifiNmeApStopReqSerFree },
32 { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, CsrWifiNmeApWmmParamUpdateReqSizeof, CsrWifiNmeApWmmParamUpdateReqSer, CsrWifiNmeApWmmParamUpdateReqDes, CsrWifiNmeApWmmParamUpdateReqSerFree },
33 { CSR_WIFI_NME_AP_STA_REMOVE_REQ, CsrWifiNmeApStaRemoveReqSizeof, CsrWifiNmeApStaRemoveReqSer, CsrWifiNmeApStaRemoveReqDes, CsrWifiNmeApStaRemoveReqSerFree },
34 { CSR_WIFI_NME_AP_CONFIG_SET_CFM, CsrWifiNmeApConfigSetCfmSizeof, CsrWifiNmeApConfigSetCfmSer, CsrWifiNmeApConfigSetCfmDes, CsrWifiNmeApConfigSetCfmSerFree },
35 { CSR_WIFI_NME_AP_WPS_REGISTER_CFM, CsrWifiNmeApWpsRegisterCfmSizeof, CsrWifiNmeApWpsRegisterCfmSer, CsrWifiNmeApWpsRegisterCfmDes, CsrWifiNmeApWpsRegisterCfmSerFree },
36 { CSR_WIFI_NME_AP_START_CFM, CsrWifiNmeApStartCfmSizeof, CsrWifiNmeApStartCfmSer, CsrWifiNmeApStartCfmDes, CsrWifiNmeApStartCfmSerFree },
37 { CSR_WIFI_NME_AP_STOP_CFM, CsrWifiNmeApStopCfmSizeof, CsrWifiNmeApStopCfmSer, CsrWifiNmeApStopCfmDes, CsrWifiNmeApStopCfmSerFree },
38 { CSR_WIFI_NME_AP_STOP_IND, CsrWifiNmeApStopIndSizeof, CsrWifiNmeApStopIndSer, CsrWifiNmeApStopIndDes, CsrWifiNmeApStopIndSerFree },
39 { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, CsrWifiNmeApWmmParamUpdateCfmSizeof, CsrWifiNmeApWmmParamUpdateCfmSer, CsrWifiNmeApWmmParamUpdateCfmDes, CsrWifiNmeApWmmParamUpdateCfmSerFree },
40 { CSR_WIFI_NME_AP_STATION_IND, CsrWifiNmeApStationIndSizeof, CsrWifiNmeApStationIndSer, CsrWifiNmeApStationIndDes, CsrWifiNmeApStationIndSerFree },
41
42 { 0, NULL, NULL, NULL, NULL },
43};
44
45CsrMsgConvMsgEntry* CsrWifiNmeApConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
46{
47 if (msgType & CSR_PRIM_UPSTREAM)
48 {
49 u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT;
50 if (idx < (CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT) &&
51 csrwifinmeap_conv_lut[idx].msgType == msgType)
52 {
53 return &csrwifinmeap_conv_lut[idx];
54 }
55 }
56 else
57 {
58 if (msgType < CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT &&
59 csrwifinmeap_conv_lut[msgType].msgType == msgType)
60 {
61 return &csrwifinmeap_conv_lut[msgType];
62 }
63 }
64 return NULL;
65}
66
67
68void CsrWifiNmeApConverterInit(void)
69{
70 CsrMsgConvInsert(CSR_WIFI_NME_AP_PRIM, csrwifinmeap_conv_lut);
71 CsrMsgConvCustomLookupRegister(CSR_WIFI_NME_AP_PRIM, CsrWifiNmeApConverterLookup);
72}
73
74
75#ifdef CSR_LOG_ENABLE
76static const CsrLogPrimitiveInformation csrwifinmeap_conv_info = {
77 CSR_WIFI_NME_AP_PRIM,
78 (char *)"CSR_WIFI_NME_AP_PRIM",
79 csrwifinmeap_conv_lut
80};
81const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void)
82{
83 return &csrwifinmeap_conv_info;
84}
85
86
87#endif /* CSR_LOG_ENABLE */
88#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
89#endif /* CSR_WIFI_NME_ENABLE */
90#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
index b89d7c7f8e21..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_AP_CONVERTER_INIT_H__
14#define CSR_WIFI_NME_AP_CONVERTER_INIT_H__
15
16#ifndef CSR_WIFI_NME_ENABLE
17#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h
18#endif
19#ifndef CSR_WIFI_AP_ENABLE
20#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h
21#endif
22
23#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE
24
25#include "csr_msgconv.h"
26
27#ifdef CSR_LOG_ENABLE
28#include "csr_log.h"
29
30extern const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void);
31#endif /* CSR_LOG_ENABLE */
32
33extern void CsrWifiNmeApConverterInit(void);
34
35#else /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
36
37#define CsrWifiNmeApConverterInit()
38
39#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
40
41#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
index ab9358873ec3..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_nme_ap_prim.h"
14#include "csr_wifi_nme_ap_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiNmeApFreeDownstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_NME_AP_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37
38 switch (*((CsrWifiNmeApPrim *) message))
39 {
40 case CSR_WIFI_NME_AP_CONFIG_SET_REQ:
41 {
42 CsrWifiNmeApConfigSetReq *p = (CsrWifiNmeApConfigSetReq *)message;
43 kfree(p->apMacConfig.macAddressList);
44 p->apMacConfig.macAddressList = NULL;
45 break;
46 }
47 case CSR_WIFI_NME_AP_START_REQ:
48 {
49 CsrWifiNmeApStartReq *p = (CsrWifiNmeApStartReq *)message;
50 switch (p->apCredentials.authType)
51 {
52 case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
53 switch (p->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
54 {
55 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
56 kfree(p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
57 p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase = NULL;
58 break;
59 default:
60 break;
61 }
62 break;
63 default:
64 break;
65 }
66 {
67 u16 i3;
68 for (i3 = 0; i3 < p->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
69 {
70 kfree(p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel);
71 p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL;
72 }
73 }
74 kfree(p->p2pGoParam.operatingChanList.channelEntryList);
75 p->p2pGoParam.operatingChanList.channelEntryList = NULL;
76 break;
77 }
78
79 default:
80 break;
81 }
82}
83
84
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
index 2786a6bbff97..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#include "csr_wifi_nme_ap_prim.h"
14#include "csr_wifi_nme_ap_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiNmeApFreeUpstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_NME_AP_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37}
38
39
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
index 6d8df8366817..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_lib.h
+++ /dev/null
@@ -1,495 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_AP_LIB_H__
14#define CSR_WIFI_NME_AP_LIB_H__
15
16#include "csr_sched.h"
17#include "csr_macro.h"
18#include "csr_msg_transport.h"
19
20#include "csr_wifi_lib.h"
21
22#include "csr_wifi_nme_ap_prim.h"
23#include "csr_wifi_nme_task.h"
24
25#ifndef CSR_WIFI_NME_ENABLE
26#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h
27#endif
28#ifndef CSR_WIFI_AP_ENABLE
29#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h
30#endif
31
32/*----------------------------------------------------------------------------*
33 * CsrWifiNmeApFreeUpstreamMessageContents
34 *
35 * DESCRIPTION
36 * Free the allocated memory in a CSR_WIFI_NME_AP upstream message. Does not
37 * free the message itself, and can only be used for upstream messages.
38 *
39 * PARAMETERS
40 * Deallocates the resources in a CSR_WIFI_NME_AP upstream message
41 *----------------------------------------------------------------------------*/
42void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
43
44/*----------------------------------------------------------------------------*
45 * CsrWifiNmeApFreeDownstreamMessageContents
46 *
47 * DESCRIPTION
48 * Free the allocated memory in a CSR_WIFI_NME_AP downstream message. Does not
49 * free the message itself, and can only be used for downstream messages.
50 *
51 * PARAMETERS
52 * Deallocates the resources in a CSR_WIFI_NME_AP downstream message
53 *----------------------------------------------------------------------------*/
54void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
55
56/*******************************************************************************
57
58 NAME
59 CsrWifiNmeApConfigSetReqSend
60
61 DESCRIPTION
62 This primitive passes AP configuration info for NME. This can be sent at
63 any time but will be acted upon when the AP is started again. This
64 information is common to both P2P GO and AP
65
66 PARAMETERS
67 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
68 apConfig - AP configuration for the NME.
69 apMacConfig - MAC configuration to be acted on when
70 CSR_WIFI_NME_AP_START.request is sent.
71
72*******************************************************************************/
73#define CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__) \
74 msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL); \
75 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_REQ, dst__, src__); \
76 msg__->apConfig = (apConfig__); \
77 msg__->apMacConfig = (apMacConfig__);
78
79#define CsrWifiNmeApConfigSetReqSendTo(dst__, src__, apConfig__, apMacConfig__) \
80 { \
81 CsrWifiNmeApConfigSetReq *msg__; \
82 CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__); \
83 CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
84 }
85
86#define CsrWifiNmeApConfigSetReqSend(src__, apConfig__, apMacConfig__) \
87 CsrWifiNmeApConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, apConfig__, apMacConfig__)
88
89/*******************************************************************************
90
91 NAME
92 CsrWifiNmeApConfigSetCfmSend
93
94 DESCRIPTION
95 This primitive reports the result of the request.
96
97 PARAMETERS
98 queue - Destination Task Queue
99 status - Status of the request.
100
101*******************************************************************************/
102#define CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__) \
103 msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetCfm), GFP_KERNEL); \
104 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_CFM, dst__, src__); \
105 msg__->status = (status__);
106
107#define CsrWifiNmeApConfigSetCfmSendTo(dst__, src__, status__) \
108 { \
109 CsrWifiNmeApConfigSetCfm *msg__; \
110 CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__); \
111 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
112 }
113
114#define CsrWifiNmeApConfigSetCfmSend(dst__, status__) \
115 CsrWifiNmeApConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
116
117/*******************************************************************************
118
119 NAME
120 CsrWifiNmeApStaRemoveReqSend
121
122 DESCRIPTION
123 This primitive disconnects a connected station. If keepBlocking is set to
124 TRUE, the station with the specified MAC address is not allowed to
125 connect. If the requested station is not already connected,it may be
126 blocked based on keepBlocking parameter.
127
128 PARAMETERS
129 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
130 interfaceTag - Interface Identifier; unique identifier of an interface
131 staMacAddress - Mac Address of the station to be disconnected or blocked
132 keepBlocking - If TRUE, the station is blocked. If FALSE and the station is
133 connected, disconnect the station. If FALSE and the station
134 is not connected, no action is taken.
135
136*******************************************************************************/
137#define CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \
138 msg__ = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL); \
139 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STA_REMOVE_REQ, dst__, src__); \
140 msg__->interfaceTag = (interfaceTag__); \
141 msg__->staMacAddress = (staMacAddress__); \
142 msg__->keepBlocking = (keepBlocking__);
143
144#define CsrWifiNmeApStaRemoveReqSendTo(dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \
145 { \
146 CsrWifiNmeApStaRemoveReq *msg__; \
147 CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__); \
148 CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
149 }
150
151#define CsrWifiNmeApStaRemoveReqSend(src__, interfaceTag__, staMacAddress__, keepBlocking__) \
152 CsrWifiNmeApStaRemoveReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, staMacAddress__, keepBlocking__)
153
154/*******************************************************************************
155
156 NAME
157 CsrWifiNmeApStartReqSend
158
159 DESCRIPTION
160 This primitive requests NME to started the AP operation.
161
162 PARAMETERS
163 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
164 interfaceTag - Interface identifier; unique identifier of an interface
165 apType - AP Type specifies the Legacy AP or P2P GO operation
166 cloakSsid - Indicates whether the SSID should be cloaked (hidden and
167 not broadcast in beacon) or not
168 ssid - Service Set Identifier
169 ifIndex - Radio interface
170 channel - Channel number of the channel to use
171 apCredentials - Security credential configuration.
172 maxConnections - Maximum number of stations/P2P clients allowed
173 p2pGoParam - P2P specific GO parameters.
174 wpsEnabled - Indicates whether WPS should be enabled or not
175
176*******************************************************************************/
177#define CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
178 msg__ = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL); \
179 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_REQ, dst__, src__); \
180 msg__->interfaceTag = (interfaceTag__); \
181 msg__->apType = (apType__); \
182 msg__->cloakSsid = (cloakSsid__); \
183 msg__->ssid = (ssid__); \
184 msg__->ifIndex = (ifIndex__); \
185 msg__->channel = (channel__); \
186 msg__->apCredentials = (apCredentials__); \
187 msg__->maxConnections = (maxConnections__); \
188 msg__->p2pGoParam = (p2pGoParam__); \
189 msg__->wpsEnabled = (wpsEnabled__);
190
191#define CsrWifiNmeApStartReqSendTo(dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
192 { \
193 CsrWifiNmeApStartReq *msg__; \
194 CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__); \
195 CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
196 }
197
198#define CsrWifiNmeApStartReqSend(src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
199 CsrWifiNmeApStartReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__)
200
201/*******************************************************************************
202
203 NAME
204 CsrWifiNmeApStartCfmSend
205
206 DESCRIPTION
207 This primitive reports the result of CSR_WIFI_NME_AP_START.request.
208
209 PARAMETERS
210 queue - Destination Task Queue
211 interfaceTag - Interface identifier; unique identifier of an interface
212 status - Status of the request.
213 ssid - Service Set Identifier
214
215*******************************************************************************/
216#define CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__) \
217 msg__ = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL); \
218 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_CFM, dst__, src__); \
219 msg__->interfaceTag = (interfaceTag__); \
220 msg__->status = (status__); \
221 msg__->ssid = (ssid__);
222
223#define CsrWifiNmeApStartCfmSendTo(dst__, src__, interfaceTag__, status__, ssid__) \
224 { \
225 CsrWifiNmeApStartCfm *msg__; \
226 CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__); \
227 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
228 }
229
230#define CsrWifiNmeApStartCfmSend(dst__, interfaceTag__, status__, ssid__) \
231 CsrWifiNmeApStartCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, ssid__)
232
233/*******************************************************************************
234
235 NAME
236 CsrWifiNmeApStationIndSend
237
238 DESCRIPTION
239 This primitive indicates that a station has joined or a previously joined
240 station has left the BSS/group
241
242 PARAMETERS
243 queue - Destination Task Queue
244 interfaceTag - Interface Identifier; unique identifier of an interface
245 mediaStatus - Indicates whether the station is connected or
246 disconnected
247 peerMacAddress - MAC address of the station
248 peerDeviceAddress - P2P Device Address
249
250*******************************************************************************/
251#define CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
252 msg__ = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL); \
253 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STATION_IND, dst__, src__); \
254 msg__->interfaceTag = (interfaceTag__); \
255 msg__->mediaStatus = (mediaStatus__); \
256 msg__->peerMacAddress = (peerMacAddress__); \
257 msg__->peerDeviceAddress = (peerDeviceAddress__);
258
259#define CsrWifiNmeApStationIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
260 { \
261 CsrWifiNmeApStationInd *msg__; \
262 CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__); \
263 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
264 }
265
266#define CsrWifiNmeApStationIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
267 CsrWifiNmeApStationIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__)
268
269/*******************************************************************************
270
271 NAME
272 CsrWifiNmeApStopReqSend
273
274 DESCRIPTION
275 This primitive requests NME to stop the AP operation.
276
277 PARAMETERS
278 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
279 interfaceTag - Interface identifier; unique identifier of an interface
280
281*******************************************************************************/
282#define CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__) \
283 msg__ = kmalloc(sizeof(CsrWifiNmeApStopReq), GFP_KERNEL); \
284 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_REQ, dst__, src__); \
285 msg__->interfaceTag = (interfaceTag__);
286
287#define CsrWifiNmeApStopReqSendTo(dst__, src__, interfaceTag__) \
288 { \
289 CsrWifiNmeApStopReq *msg__; \
290 CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__); \
291 CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
292 }
293
294#define CsrWifiNmeApStopReqSend(src__, interfaceTag__) \
295 CsrWifiNmeApStopReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
296
297/*******************************************************************************
298
299 NAME
300 CsrWifiNmeApStopIndSend
301
302 DESCRIPTION
303 Indicates that AP operation had stopped because of some unrecoverable
304 error after AP operation was started successfully. NME sends this signal
305 after failing to restart the AP operation internally following an error
306
307 PARAMETERS
308 queue - Destination Task Queue
309 interfaceTag - Interface Identifier; unique identifier of an interface
310 apType - Reports AP Type (P2PGO or AP)
311 status - Error Status
312
313*******************************************************************************/
314#define CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \
315 msg__ = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL); \
316 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_IND, dst__, src__); \
317 msg__->interfaceTag = (interfaceTag__); \
318 msg__->apType = (apType__); \
319 msg__->status = (status__);
320
321#define CsrWifiNmeApStopIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \
322 { \
323 CsrWifiNmeApStopInd *msg__; \
324 CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \
325 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
326 }
327
328#define CsrWifiNmeApStopIndSend(dst__, interfaceTag__, apType__, status__) \
329 CsrWifiNmeApStopIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, apType__, status__)
330
331/*******************************************************************************
332
333 NAME
334 CsrWifiNmeApStopCfmSend
335
336 DESCRIPTION
337 This primitive confirms that the AP operation is stopped. NME shall send
338 this primitive in response to the request even if AP operation has
339 already been stopped
340
341 PARAMETERS
342 queue - Destination Task Queue
343 interfaceTag - Interface identifier; unique identifier of an interface
344 status - Status of the request.
345
346*******************************************************************************/
347#define CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
348 msg__ = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL); \
349 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_CFM, dst__, src__); \
350 msg__->interfaceTag = (interfaceTag__); \
351 msg__->status = (status__);
352
353#define CsrWifiNmeApStopCfmSendTo(dst__, src__, interfaceTag__, status__) \
354 { \
355 CsrWifiNmeApStopCfm *msg__; \
356 CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
357 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
358 }
359
360#define CsrWifiNmeApStopCfmSend(dst__, interfaceTag__, status__) \
361 CsrWifiNmeApStopCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
362
363/*******************************************************************************
364
365 NAME
366 CsrWifiNmeApWmmParamUpdateReqSend
367
368 DESCRIPTION
369 Application uses this primitive to update the WMM parameters
370
371 PARAMETERS
372 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
373 wmmApParams - WMM Access point parameters per access category. The array
374 index corresponds to the ACI
375 wmmApBcParams - WMM station parameters per access category to be advertised
376 in the beacons and probe response The array index
377 corresponds to the ACI
378
379*******************************************************************************/
380#define CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__) \
381 msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL); \
382 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \
383 memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \
384 memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4);
385
386#define CsrWifiNmeApWmmParamUpdateReqSendTo(dst__, src__, wmmApParams__, wmmApBcParams__) \
387 { \
388 CsrWifiNmeApWmmParamUpdateReq *msg__; \
389 CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__); \
390 CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
391 }
392
393#define CsrWifiNmeApWmmParamUpdateReqSend(src__, wmmApParams__, wmmApBcParams__) \
394 CsrWifiNmeApWmmParamUpdateReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wmmApParams__, wmmApBcParams__)
395
396/*******************************************************************************
397
398 NAME
399 CsrWifiNmeApWmmParamUpdateCfmSend
400
401 DESCRIPTION
402 A confirm for for the WMM parameters update
403
404 PARAMETERS
405 queue - Destination Task Queue
406 status - Status of the request.
407
408*******************************************************************************/
409#define CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__) \
410 msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateCfm), GFP_KERNEL); \
411 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \
412 msg__->status = (status__);
413
414#define CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, src__, status__) \
415 { \
416 CsrWifiNmeApWmmParamUpdateCfm *msg__; \
417 CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__); \
418 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
419 }
420
421#define CsrWifiNmeApWmmParamUpdateCfmSend(dst__, status__) \
422 CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
423
424/*******************************************************************************
425
426 NAME
427 CsrWifiNmeApWpsRegisterReqSend
428
429 DESCRIPTION
430 This primitive allows the NME to accept the WPS registration from an
431 enrollee. Such registration procedure can be cancelled by sending
432 CSR_WIFI_NME_WPS_CANCEL.request.
433
434 PARAMETERS
435 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
436 interfaceTag - Interface Identifier; unique identifier of an
437 interface
438 selectedDevicePasswordId - Selected password type
439 selectedConfigMethod - Selected WPS configuration method type
440 pin - PIN value.
441 Relevant if selected device password ID is PIN.4
442 digit pin is passed by sending the pin digits in
443 pin[0]..pin[3] and rest of the contents filled
444 with '-'.
445
446*******************************************************************************/
447#define CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
448 msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL); \
449 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_REQ, dst__, src__); \
450 msg__->interfaceTag = (interfaceTag__); \
451 msg__->selectedDevicePasswordId = (selectedDevicePasswordId__); \
452 msg__->selectedConfigMethod = (selectedConfigMethod__); \
453 memcpy(msg__->pin, (pin__), sizeof(u8) * 8);
454
455#define CsrWifiNmeApWpsRegisterReqSendTo(dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
456 { \
457 CsrWifiNmeApWpsRegisterReq *msg__; \
458 CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__); \
459 CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
460 }
461
462#define CsrWifiNmeApWpsRegisterReqSend(src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
463 CsrWifiNmeApWpsRegisterReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__)
464
465/*******************************************************************************
466
467 NAME
468 CsrWifiNmeApWpsRegisterCfmSend
469
470 DESCRIPTION
471 This primitive reports the result of WPS procedure.
472
473 PARAMETERS
474 queue - Destination Task Queue
475 interfaceTag - Interface identifier; unique identifier of an interface
476 status - Status of the request.
477
478*******************************************************************************/
479#define CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
480 msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL); \
481 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_CFM, dst__, src__); \
482 msg__->interfaceTag = (interfaceTag__); \
483 msg__->status = (status__);
484
485#define CsrWifiNmeApWpsRegisterCfmSendTo(dst__, src__, interfaceTag__, status__) \
486 { \
487 CsrWifiNmeApWpsRegisterCfm *msg__; \
488 CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
489 CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
490 }
491
492#define CsrWifiNmeApWpsRegisterCfmSend(dst__, interfaceTag__, status__) \
493 CsrWifiNmeApWpsRegisterCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
494
495#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
index b32bdbc7e22f..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_prim.h
+++ /dev/null
@@ -1,494 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_AP_PRIM_H__
14#define CSR_WIFI_NME_AP_PRIM_H__
15
16#include <linux/types.h>
17#include "csr_prim_defs.h"
18#include "csr_sched.h"
19#include "csr_wifi_common.h"
20#include "csr_result.h"
21#include "csr_wifi_fsm_event.h"
22#include "csr_wifi_sme_ap_prim.h"
23#include "csr_wifi_nme_prim.h"
24
25#ifndef CSR_WIFI_NME_ENABLE
26#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h
27#endif
28#ifndef CSR_WIFI_AP_ENABLE
29#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h
30#endif
31
32#define CSR_WIFI_NME_AP_PRIM (0x0426)
33
34typedef CsrPrim CsrWifiNmeApPrim;
35
36
37/*******************************************************************************
38
39 NAME
40 CsrWifiNmeApPersCredentialType
41
42 DESCRIPTION
43 NME Credential Types
44
45 VALUES
46 CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK
47 - Use PSK as credential.
48 CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE
49 - Use the specified passphrase as credential
50
51*******************************************************************************/
52typedef u8 CsrWifiNmeApPersCredentialType;
53#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK ((CsrWifiNmeApPersCredentialType) 0x00)
54#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE ((CsrWifiNmeApPersCredentialType) 0x01)
55
56
57/*******************************************************************************
58
59 NAME
60 CsrWifiNmeApConfig
61
62 DESCRIPTION
63 Structure holding AP config data.
64
65 MEMBERS
66 apGroupkeyTimeout - Access point group key timeout.
67 apStrictGtkRekey - Access point strict GTK rekey flag. If set TRUE, the AP
68 shall rekey GTK every time a connected STA leaves BSS.
69 apGmkTimeout - Access point GMK timeout
70 apResponseTimeout - Response timeout
71 apRetransLimit - Max allowed retransmissions
72
73*******************************************************************************/
74typedef struct
75{
76 u16 apGroupkeyTimeout;
77 u8 apStrictGtkRekey;
78 u16 apGmkTimeout;
79 u16 apResponseTimeout;
80 u8 apRetransLimit;
81} CsrWifiNmeApConfig;
82
83/*******************************************************************************
84
85 NAME
86 CsrWifiNmeApAuthPers
87
88 DESCRIPTION
89
90 MEMBERS
91 authSupport - Credential type value (as defined in the
92 enumeration type).
93 rsnCapabilities - RSN capabilities mask
94 wapiCapabilities - WAPI capabilities mask
95 pskOrPassphrase - Credential type value (as defined in the
96 enumeration type).
97 authPers_credentials - Union containing credentials which depends
98 on credentialType parameter.
99 authPers_credentialspsk -
100 authPers_credentialspassphrase -
101
102*******************************************************************************/
103typedef struct
104{
105 CsrWifiSmeApAuthSupportMask authSupport;
106 CsrWifiSmeApRsnCapabilitiesMask rsnCapabilities;
107 CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities;
108 CsrWifiNmeApPersCredentialType pskOrPassphrase;
109 union {
110 CsrWifiNmePsk psk;
111 CsrWifiNmePassphrase passphrase;
112 } authPers_credentials;
113} CsrWifiNmeApAuthPers;
114
115/*******************************************************************************
116
117 NAME
118 CsrWifiNmeApCredentials
119
120 DESCRIPTION
121 Structure containing the Credentials data.
122
123 MEMBERS
124 authType - Authentication type
125 nmeAuthType - Authentication parameters
126 nmeAuthTypeopenSystemEmpty -
127 nmeAuthTypeauthwep -
128 nmeAuthTypeauthTypePersonal -
129
130*******************************************************************************/
131typedef struct
132{
133 CsrWifiSmeApAuthType authType;
134 union {
135 CsrWifiSmeEmpty openSystemEmpty;
136 CsrWifiSmeWepAuth authwep;
137 CsrWifiNmeApAuthPers authTypePersonal;
138 } nmeAuthType;
139} CsrWifiNmeApCredentials;
140
141
142/* Downstream */
143#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST (0x0000)
144
145#define CSR_WIFI_NME_AP_CONFIG_SET_REQ ((CsrWifiNmeApPrim) (0x0000 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
146#define CSR_WIFI_NME_AP_WPS_REGISTER_REQ ((CsrWifiNmeApPrim) (0x0001 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
147#define CSR_WIFI_NME_AP_START_REQ ((CsrWifiNmeApPrim) (0x0002 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
148#define CSR_WIFI_NME_AP_STOP_REQ ((CsrWifiNmeApPrim) (0x0003 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
149#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ ((CsrWifiNmeApPrim) (0x0004 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
150#define CSR_WIFI_NME_AP_STA_REMOVE_REQ ((CsrWifiNmeApPrim) (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
151
152
153#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)
154
155/* Upstream */
156#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
157
158#define CSR_WIFI_NME_AP_CONFIG_SET_CFM ((CsrWifiNmeApPrim)(0x0000 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
159#define CSR_WIFI_NME_AP_WPS_REGISTER_CFM ((CsrWifiNmeApPrim)(0x0001 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
160#define CSR_WIFI_NME_AP_START_CFM ((CsrWifiNmeApPrim)(0x0002 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
161#define CSR_WIFI_NME_AP_STOP_CFM ((CsrWifiNmeApPrim)(0x0003 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
162#define CSR_WIFI_NME_AP_STOP_IND ((CsrWifiNmeApPrim)(0x0004 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
163#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM ((CsrWifiNmeApPrim)(0x0005 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
164#define CSR_WIFI_NME_AP_STATION_IND ((CsrWifiNmeApPrim)(0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
165
166#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST (0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)
167
168#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)
169#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT (CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)
170
171/*******************************************************************************
172
173 NAME
174 CsrWifiNmeApConfigSetReq
175
176 DESCRIPTION
177 This primitive passes AP configuration info for NME. This can be sent at
178 any time but will be acted upon when the AP is started again. This
179 information is common to both P2P GO and AP
180
181 MEMBERS
182 common - Common header for use with the CsrWifiFsm Module
183 apConfig - AP configuration for the NME.
184 apMacConfig - MAC configuration to be acted on when
185 CSR_WIFI_NME_AP_START.request is sent.
186
187*******************************************************************************/
188typedef struct
189{
190 CsrWifiFsmEvent common;
191 CsrWifiNmeApConfig apConfig;
192 CsrWifiSmeApMacConfig apMacConfig;
193} CsrWifiNmeApConfigSetReq;
194
195/*******************************************************************************
196
197 NAME
198 CsrWifiNmeApWpsRegisterReq
199
200 DESCRIPTION
201 This primitive allows the NME to accept the WPS registration from an
202 enrollee. Such registration procedure can be cancelled by sending
203 CSR_WIFI_NME_WPS_CANCEL.request.
204
205 MEMBERS
206 common - Common header for use with the CsrWifiFsm Module
207 interfaceTag - Interface Identifier; unique identifier of an
208 interface
209 selectedDevicePasswordId - Selected password type
210 selectedConfigMethod - Selected WPS configuration method type
211 pin - PIN value.
212 Relevant if selected device password ID is PIN.4
213 digit pin is passed by sending the pin digits in
214 pin[0]..pin[3] and rest of the contents filled
215 with '-'.
216
217*******************************************************************************/
218typedef struct
219{
220 CsrWifiFsmEvent common;
221 u16 interfaceTag;
222 CsrWifiSmeWpsDpid selectedDevicePasswordId;
223 CsrWifiSmeWpsConfigType selectedConfigMethod;
224 u8 pin[8];
225} CsrWifiNmeApWpsRegisterReq;
226
227/*******************************************************************************
228
229 NAME
230 CsrWifiNmeApStartReq
231
232 DESCRIPTION
233 This primitive requests NME to started the AP operation.
234
235 MEMBERS
236 common - Common header for use with the CsrWifiFsm Module
237 interfaceTag - Interface identifier; unique identifier of an interface
238 apType - AP Type specifies the Legacy AP or P2P GO operation
239 cloakSsid - Indicates whether the SSID should be cloaked (hidden and
240 not broadcast in beacon) or not
241 ssid - Service Set Identifier
242 ifIndex - Radio interface
243 channel - Channel number of the channel to use
244 apCredentials - Security credential configuration.
245 maxConnections - Maximum number of stations/P2P clients allowed
246 p2pGoParam - P2P specific GO parameters.
247 wpsEnabled - Indicates whether WPS should be enabled or not
248
249*******************************************************************************/
250typedef struct
251{
252 CsrWifiFsmEvent common;
253 u16 interfaceTag;
254 CsrWifiSmeApType apType;
255 u8 cloakSsid;
256 CsrWifiSsid ssid;
257 CsrWifiSmeRadioIF ifIndex;
258 u8 channel;
259 CsrWifiNmeApCredentials apCredentials;
260 u8 maxConnections;
261 CsrWifiSmeApP2pGoConfig p2pGoParam;
262 u8 wpsEnabled;
263} CsrWifiNmeApStartReq;
264
265/*******************************************************************************
266
267 NAME
268 CsrWifiNmeApStopReq
269
270 DESCRIPTION
271 This primitive requests NME to stop the AP operation.
272
273 MEMBERS
274 common - Common header for use with the CsrWifiFsm Module
275 interfaceTag - Interface identifier; unique identifier of an interface
276
277*******************************************************************************/
278typedef struct
279{
280 CsrWifiFsmEvent common;
281 u16 interfaceTag;
282} CsrWifiNmeApStopReq;
283
284/*******************************************************************************
285
286 NAME
287 CsrWifiNmeApWmmParamUpdateReq
288
289 DESCRIPTION
290 Application uses this primitive to update the WMM parameters
291
292 MEMBERS
293 common - Common header for use with the CsrWifiFsm Module
294 wmmApParams - WMM Access point parameters per access category. The array
295 index corresponds to the ACI
296 wmmApBcParams - WMM station parameters per access category to be advertised
297 in the beacons and probe response The array index
298 corresponds to the ACI
299
300*******************************************************************************/
301typedef struct
302{
303 CsrWifiFsmEvent common;
304 CsrWifiSmeWmmAcParams wmmApParams[4];
305 CsrWifiSmeWmmAcParams wmmApBcParams[4];
306} CsrWifiNmeApWmmParamUpdateReq;
307
308/*******************************************************************************
309
310 NAME
311 CsrWifiNmeApStaRemoveReq
312
313 DESCRIPTION
314 This primitive disconnects a connected station. If keepBlocking is set to
315 TRUE, the station with the specified MAC address is not allowed to
316 connect. If the requested station is not already connected,it may be
317 blocked based on keepBlocking parameter.
318
319 MEMBERS
320 common - Common header for use with the CsrWifiFsm Module
321 interfaceTag - Interface Identifier; unique identifier of an interface
322 staMacAddress - Mac Address of the station to be disconnected or blocked
323 keepBlocking - If TRUE, the station is blocked. If FALSE and the station is
324 connected, disconnect the station. If FALSE and the station
325 is not connected, no action is taken.
326
327*******************************************************************************/
328typedef struct
329{
330 CsrWifiFsmEvent common;
331 u16 interfaceTag;
332 CsrWifiMacAddress staMacAddress;
333 u8 keepBlocking;
334} CsrWifiNmeApStaRemoveReq;
335
336/*******************************************************************************
337
338 NAME
339 CsrWifiNmeApConfigSetCfm
340
341 DESCRIPTION
342 This primitive reports the result of the request.
343
344 MEMBERS
345 common - Common header for use with the CsrWifiFsm Module
346 status - Status of the request.
347
348*******************************************************************************/
349typedef struct
350{
351 CsrWifiFsmEvent common;
352 CsrResult status;
353} CsrWifiNmeApConfigSetCfm;
354
355/*******************************************************************************
356
357 NAME
358 CsrWifiNmeApWpsRegisterCfm
359
360 DESCRIPTION
361 This primitive reports the result of WPS procedure.
362
363 MEMBERS
364 common - Common header for use with the CsrWifiFsm Module
365 interfaceTag - Interface identifier; unique identifier of an interface
366 status - Status of the request.
367
368*******************************************************************************/
369typedef struct
370{
371 CsrWifiFsmEvent common;
372 u16 interfaceTag;
373 CsrResult status;
374} CsrWifiNmeApWpsRegisterCfm;
375
376/*******************************************************************************
377
378 NAME
379 CsrWifiNmeApStartCfm
380
381 DESCRIPTION
382 This primitive reports the result of CSR_WIFI_NME_AP_START.request.
383
384 MEMBERS
385 common - Common header for use with the CsrWifiFsm Module
386 interfaceTag - Interface identifier; unique identifier of an interface
387 status - Status of the request.
388 ssid - Service Set Identifier
389
390*******************************************************************************/
391typedef struct
392{
393 CsrWifiFsmEvent common;
394 u16 interfaceTag;
395 CsrResult status;
396 CsrWifiSsid ssid;
397} CsrWifiNmeApStartCfm;
398
399/*******************************************************************************
400
401 NAME
402 CsrWifiNmeApStopCfm
403
404 DESCRIPTION
405 This primitive confirms that the AP operation is stopped. NME shall send
406 this primitive in response to the request even if AP operation has
407 already been stopped
408
409 MEMBERS
410 common - Common header for use with the CsrWifiFsm Module
411 interfaceTag - Interface identifier; unique identifier of an interface
412 status - Status of the request.
413
414*******************************************************************************/
415typedef struct
416{
417 CsrWifiFsmEvent common;
418 u16 interfaceTag;
419 CsrResult status;
420} CsrWifiNmeApStopCfm;
421
422/*******************************************************************************
423
424 NAME
425 CsrWifiNmeApStopInd
426
427 DESCRIPTION
428 Indicates that AP operation had stopped because of some unrecoverable
429 error after AP operation was started successfully. NME sends this signal
430 after failing to restart the AP operation internally following an error
431
432 MEMBERS
433 common - Common header for use with the CsrWifiFsm Module
434 interfaceTag - Interface Identifier; unique identifier of an interface
435 apType - Reports AP Type (P2PGO or AP)
436 status - Error Status
437
438*******************************************************************************/
439typedef struct
440{
441 CsrWifiFsmEvent common;
442 u16 interfaceTag;
443 CsrWifiSmeApType apType;
444 CsrResult status;
445} CsrWifiNmeApStopInd;
446
447/*******************************************************************************
448
449 NAME
450 CsrWifiNmeApWmmParamUpdateCfm
451
452 DESCRIPTION
453 A confirm for for the WMM parameters update
454
455 MEMBERS
456 common - Common header for use with the CsrWifiFsm Module
457 status - Status of the request.
458
459*******************************************************************************/
460typedef struct
461{
462 CsrWifiFsmEvent common;
463 CsrResult status;
464} CsrWifiNmeApWmmParamUpdateCfm;
465
466/*******************************************************************************
467
468 NAME
469 CsrWifiNmeApStationInd
470
471 DESCRIPTION
472 This primitive indicates that a station has joined or a previously joined
473 station has left the BSS/group
474
475 MEMBERS
476 common - Common header for use with the CsrWifiFsm Module
477 interfaceTag - Interface Identifier; unique identifier of an interface
478 mediaStatus - Indicates whether the station is connected or
479 disconnected
480 peerMacAddress - MAC address of the station
481 peerDeviceAddress - P2P Device Address
482
483*******************************************************************************/
484typedef struct
485{
486 CsrWifiFsmEvent common;
487 u16 interfaceTag;
488 CsrWifiSmeMediaStatus mediaStatus;
489 CsrWifiMacAddress peerMacAddress;
490 CsrWifiMacAddress peerDeviceAddress;
491} CsrWifiNmeApStationInd;
492
493#endif /* CSR_WIFI_NME_AP_PRIM_H__ */
494
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
index bfebb1529779..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_sef.c
+++ /dev/null
@@ -1,30 +0,0 @@
1/*****************************************************************************
2
3 FILE: csr_wifi_nme_sef.c
4
5 (c) Cambridge Silicon Radio Limited 2010
6
7 Refer to LICENSE.txt included with this source for details
8 on the license terms.
9
10 *****************************************************************************/
11#include "csr_wifi_nme_ap_sef.h"
12#include "unifi_priv.h"
13
14void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg)
15{
16 switch(msg->type) {
17 case CSR_WIFI_NME_AP_START_CFM:
18 CsrWifiNmeApStartCfmHandler(drvpriv, msg);
19 break;
20 case CSR_WIFI_NME_AP_STOP_CFM:
21 CsrWifiNmeApStopCfmHandler(drvpriv, msg);
22 break;
23 case CSR_WIFI_NME_AP_CONFIG_SET_CFM:
24 CsrWifiNmeApConfigSetCfmHandler(drvpriv, msg);
25 break;
26 default:
27 unifi_error(drvpriv, "CsrWifiNmeApUpstreamStateHandlers: unhandled NME_AP message type 0x%.4X\n", msg->type);
28 break;
29 }
30}
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
index 3daaa0944dba..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_sef.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/*****************************************************************************
2 FILE: csr_wifi_nme_sef.h
3 (c) Cambridge Silicon Radio Limited 2010
4
5 Refer to LICENSE.txt included with this source for details
6 on the license terms.
7
8*****************************************************************************/
9#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__
10#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__
11
12#include "csr_wifi_nme_prim.h"
13
14void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg);
15
16
17extern void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
18extern void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
19extern void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
20
21#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
index 1a901a70d195..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
+++ /dev/null
@@ -1,909 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/string.h>
13#include <linux/slab.h>
14#include "csr_msgconv.h"
15
16#ifdef CSR_WIFI_NME_ENABLE
17#ifdef CSR_WIFI_AP_ENABLE
18
19#include "csr_wifi_nme_ap_prim.h"
20#include "csr_wifi_nme_ap_serialize.h"
21
22void CsrWifiNmeApPfree(void *ptr)
23{
24 kfree(ptr);
25}
26
27
28size_t CsrWifiNmeApConfigSetReqSizeof(void *msg)
29{
30 CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) msg;
31 size_t bufferSize = 2;
32
33 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 104) */
34 bufferSize += 2; /* u16 primitive->apConfig.apGroupkeyTimeout */
35 bufferSize += 1; /* u8 primitive->apConfig.apStrictGtkRekey */
36 bufferSize += 2; /* u16 primitive->apConfig.apGmkTimeout */
37 bufferSize += 2; /* u16 primitive->apConfig.apResponseTimeout */
38 bufferSize += 1; /* u8 primitive->apConfig.apRetransLimit */
39 bufferSize += 1; /* CsrWifiSmeApPhySupportMask primitive->apMacConfig.phySupportedBitmap */
40 bufferSize += 2; /* u16 primitive->apMacConfig.beaconInterval */
41 bufferSize += 1; /* u8 primitive->apMacConfig.dtimPeriod */
42 bufferSize += 2; /* u16 primitive->apMacConfig.maxListenInterval */
43 bufferSize += 1; /* u8 primitive->apMacConfig.supportedRatesCount */
44 bufferSize += 20; /* u8 primitive->apMacConfig.supportedRates[20] */
45 bufferSize += 1; /* CsrWifiSmePreambleType primitive->apMacConfig.preamble */
46 bufferSize += 1; /* u8 primitive->apMacConfig.shortSlotTimeEnabled */
47 bufferSize += 1; /* CsrWifiSmeCtsProtectionType primitive->apMacConfig.ctsProtectionType */
48 bufferSize += 1; /* u8 primitive->apMacConfig.wmmEnabled */
49 {
50 u16 i2;
51 for (i2 = 0; i2 < 4; i2++)
52 {
53 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMin */
54 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMax */
55 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].aifs */
56 bufferSize += 2; /* u16 primitive->apMacConfig.wmmApParams[i2].txopLimit */
57 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory */
58 }
59 }
60 {
61 u16 i2;
62 for (i2 = 0; i2 < 4; i2++)
63 {
64 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMin */
65 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMax */
66 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].aifs */
67 bufferSize += 2; /* u16 primitive->apMacConfig.wmmApBcParams[i2].txopLimit */
68 bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory */
69 }
70 }
71 bufferSize += 1; /* CsrWifiSmeApAccessType primitive->apMacConfig.accessType */
72 bufferSize += 1; /* u8 primitive->apMacConfig.macAddressListCount */
73 {
74 u16 i2;
75 for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
76 {
77 bufferSize += 6; /* u8 primitive->apMacConfig.macAddressList[i2].a[6] */
78 }
79 }
80 bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.greenfieldSupported */
81 bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.shortGi20MHz */
82 bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.rxStbc */
83 bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.rifsModeAllowed */
84 bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.htProtection */
85 bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.dualCtsProtection */
86 return bufferSize;
87}
88
89
90u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
91{
92 CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *)msg;
93 *len = 0;
94 CsrUint16Ser(ptr, len, primitive->common.type);
95 CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGroupkeyTimeout);
96 CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apStrictGtkRekey);
97 CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGmkTimeout);
98 CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apResponseTimeout);
99 CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apRetransLimit);
100 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.phySupportedBitmap);
101 CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.beaconInterval);
102 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.dtimPeriod);
103 CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.maxListenInterval);
104 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.supportedRatesCount);
105 CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.supportedRates, ((u16) (20)));
106 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.preamble);
107 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.shortSlotTimeEnabled);
108 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.ctsProtectionType);
109 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmEnabled);
110 {
111 u16 i2;
112 for (i2 = 0; i2 < 4; i2++)
113 {
114 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMin);
115 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMax);
116 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].aifs);
117 CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApParams[i2].txopLimit);
118 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory);
119 }
120 }
121 {
122 u16 i2;
123 for (i2 = 0; i2 < 4; i2++)
124 {
125 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMin);
126 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMax);
127 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].aifs);
128 CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApBcParams[i2].txopLimit);
129 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory);
130 }
131 }
132 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.accessType);
133 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.macAddressListCount);
134 {
135 u16 i2;
136 for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
137 {
138 CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.macAddressList[i2].a, ((u16) (6)));
139 }
140 }
141 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.greenfieldSupported);
142 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.shortGi20MHz);
143 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rxStbc);
144 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rifsModeAllowed);
145 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.htProtection);
146 CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.dualCtsProtection);
147 return(ptr);
148}
149
150
151void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t length)
152{
153 CsrWifiNmeApConfigSetReq *primitive = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL);
154 size_t offset;
155 offset = 0;
156
157 CsrUint16Des(&primitive->common.type, buffer, &offset);
158 CsrUint16Des((u16 *) &primitive->apConfig.apGroupkeyTimeout, buffer, &offset);
159 CsrUint8Des((u8 *) &primitive->apConfig.apStrictGtkRekey, buffer, &offset);
160 CsrUint16Des((u16 *) &primitive->apConfig.apGmkTimeout, buffer, &offset);
161 CsrUint16Des((u16 *) &primitive->apConfig.apResponseTimeout, buffer, &offset);
162 CsrUint8Des((u8 *) &primitive->apConfig.apRetransLimit, buffer, &offset);
163 CsrUint8Des((u8 *) &primitive->apMacConfig.phySupportedBitmap, buffer, &offset);
164 CsrUint16Des((u16 *) &primitive->apMacConfig.beaconInterval, buffer, &offset);
165 CsrUint8Des((u8 *) &primitive->apMacConfig.dtimPeriod, buffer, &offset);
166 CsrUint16Des((u16 *) &primitive->apMacConfig.maxListenInterval, buffer, &offset);
167 CsrUint8Des((u8 *) &primitive->apMacConfig.supportedRatesCount, buffer, &offset);
168 CsrMemCpyDes(primitive->apMacConfig.supportedRates, buffer, &offset, ((u16) (20)));
169 CsrUint8Des((u8 *) &primitive->apMacConfig.preamble, buffer, &offset);
170 CsrUint8Des((u8 *) &primitive->apMacConfig.shortSlotTimeEnabled, buffer, &offset);
171 CsrUint8Des((u8 *) &primitive->apMacConfig.ctsProtectionType, buffer, &offset);
172 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmEnabled, buffer, &offset);
173 {
174 u16 i2;
175 for (i2 = 0; i2 < 4; i2++)
176 {
177 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMin, buffer, &offset);
178 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMax, buffer, &offset);
179 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].aifs, buffer, &offset);
180 CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApParams[i2].txopLimit, buffer, &offset);
181 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory, buffer, &offset);
182 }
183 }
184 {
185 u16 i2;
186 for (i2 = 0; i2 < 4; i2++)
187 {
188 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMin, buffer, &offset);
189 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMax, buffer, &offset);
190 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].aifs, buffer, &offset);
191 CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApBcParams[i2].txopLimit, buffer, &offset);
192 CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory, buffer, &offset);
193 }
194 }
195 CsrUint8Des((u8 *) &primitive->apMacConfig.accessType, buffer, &offset);
196 CsrUint8Des((u8 *) &primitive->apMacConfig.macAddressListCount, buffer, &offset);
197 primitive->apMacConfig.macAddressList = NULL;
198 if (primitive->apMacConfig.macAddressListCount)
199 {
200 primitive->apMacConfig.macAddressList = kmalloc(sizeof(CsrWifiMacAddress) * primitive->apMacConfig.macAddressListCount, GFP_KERNEL);
201 }
202 {
203 u16 i2;
204 for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
205 {
206 CsrMemCpyDes(primitive->apMacConfig.macAddressList[i2].a, buffer, &offset, ((u16) (6)));
207 }
208 }
209 CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.greenfieldSupported, buffer, &offset);
210 CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.shortGi20MHz, buffer, &offset);
211 CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rxStbc, buffer, &offset);
212 CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rifsModeAllowed, buffer, &offset);
213 CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.htProtection, buffer, &offset);
214 CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.dualCtsProtection, buffer, &offset);
215
216 return primitive;
217}
218
219
220void CsrWifiNmeApConfigSetReqSerFree(void *voidPrimitivePointer)
221{
222 CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) voidPrimitivePointer;
223 kfree(primitive->apMacConfig.macAddressList);
224 kfree(primitive);
225}
226
227
228size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg)
229{
230 size_t bufferSize = 2;
231
232 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
233 bufferSize += 2; /* u16 primitive->interfaceTag */
234 bufferSize += 2; /* CsrWifiSmeWpsDpid primitive->selectedDevicePasswordId */
235 bufferSize += 2; /* CsrWifiSmeWpsConfigType primitive->selectedConfigMethod */
236 bufferSize += 8; /* u8 primitive->pin[8] */
237 return bufferSize;
238}
239
240
241u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg)
242{
243 CsrWifiNmeApWpsRegisterReq *primitive = (CsrWifiNmeApWpsRegisterReq *)msg;
244 *len = 0;
245 CsrUint16Ser(ptr, len, primitive->common.type);
246 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
247 CsrUint16Ser(ptr, len, (u16) primitive->selectedDevicePasswordId);
248 CsrUint16Ser(ptr, len, (u16) primitive->selectedConfigMethod);
249 CsrMemCpySer(ptr, len, (const void *) primitive->pin, ((u16) (8)));
250 return(ptr);
251}
252
253
254void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t length)
255{
256 CsrWifiNmeApWpsRegisterReq *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL);
257 size_t offset;
258 offset = 0;
259
260 CsrUint16Des(&primitive->common.type, buffer, &offset);
261 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
262 CsrUint16Des((u16 *) &primitive->selectedDevicePasswordId, buffer, &offset);
263 CsrUint16Des((u16 *) &primitive->selectedConfigMethod, buffer, &offset);
264 CsrMemCpyDes(primitive->pin, buffer, &offset, ((u16) (8)));
265
266 return primitive;
267}
268
269
270size_t CsrWifiNmeApStartReqSizeof(void *msg)
271{
272 CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) msg;
273 size_t bufferSize = 2;
274
275 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 112) */
276 bufferSize += 2; /* u16 primitive->interfaceTag */
277 bufferSize += 1; /* CsrWifiSmeApType primitive->apType */
278 bufferSize += 1; /* u8 primitive->cloakSsid */
279 bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
280 bufferSize += 1; /* u8 primitive->ssid.length */
281 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->ifIndex */
282 bufferSize += 1; /* u8 primitive->channel */
283 bufferSize += 1; /* CsrWifiSmeApAuthType primitive->apCredentials.authType */
284 switch (primitive->apCredentials.authType)
285 {
286 case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
287 bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.openSystemEmpty.empty */
288 break;
289 case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
290 bufferSize += 1; /* CsrWifiSmeWepCredentialType primitive->apCredentials.nmeAuthType.authwep.wepKeyType */
291 switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
292 {
293 case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
294 bufferSize += 1; /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType */
295 bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey */
296 bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1[13] */
297 bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2[13] */
298 bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3[13] */
299 bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4[13] */
300 break;
301 case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
302 bufferSize += 1; /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType */
303 bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey */
304 bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1[5] */
305 bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2[5] */
306 bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3[5] */
307 bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4[5] */
308 break;
309 default:
310 break;
311 }
312 break;
313 case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
314 bufferSize += 1; /* CsrWifiSmeApAuthSupportMask primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport */
315 bufferSize += 2; /* CsrWifiSmeApRsnCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities */
316 bufferSize += 2; /* CsrWifiSmeApWapiCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities */
317 bufferSize += 1; /* CsrWifiNmeApPersCredentialType primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase */
318 switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
319 {
320 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
321 bufferSize += 2; /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode */
322 bufferSize += 32; /* u8 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk[32] */
323 break;
324 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
325 bufferSize += 2; /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode */
326 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) */
327 break;
328 default:
329 break;
330 }
331 break;
332 default:
333 break;
334 }
335 bufferSize += 1; /* u8 primitive->maxConnections */
336 bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->p2pGoParam.groupCapability */
337 bufferSize += 3; /* u8 primitive->p2pGoParam.operatingChanList.country[3] */
338 bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryListCount */
339 {
340 u16 i3;
341 for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
342 {
343 bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass */
344 bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount */
345 bufferSize += primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel */
346 }
347 }
348 bufferSize += 1; /* u8 primitive->p2pGoParam.opPsEnabled */
349 bufferSize += 1; /* u8 primitive->p2pGoParam.ctWindow */
350 bufferSize += 1; /* CsrWifiSmeP2pNoaConfigMethod primitive->p2pGoParam.noaConfigMethod */
351 bufferSize += 1; /* u8 primitive->p2pGoParam.allowNoaWithNonP2pDevices */
352 bufferSize += 1; /* u8 primitive->wpsEnabled */
353 return bufferSize;
354}
355
356
357u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg)
358{
359 CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *)msg;
360 *len = 0;
361 CsrUint16Ser(ptr, len, primitive->common.type);
362 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
363 CsrUint8Ser(ptr, len, (u8) primitive->apType);
364 CsrUint8Ser(ptr, len, (u8) primitive->cloakSsid);
365 CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
366 CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
367 CsrUint8Ser(ptr, len, (u8) primitive->ifIndex);
368 CsrUint8Ser(ptr, len, (u8) primitive->channel);
369 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.authType);
370 switch (primitive->apCredentials.authType)
371 {
372 case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
373 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.openSystemEmpty.empty);
374 break;
375 case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
376 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepKeyType);
377 switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
378 {
379 case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
380 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType);
381 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey);
382 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, ((u16) (13)));
383 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, ((u16) (13)));
384 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, ((u16) (13)));
385 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, ((u16) (13)));
386 break;
387 case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
388 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType);
389 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey);
390 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, ((u16) (5)));
391 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, ((u16) (5)));
392 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, ((u16) (5)));
393 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, ((u16) (5)));
394 break;
395 default:
396 break;
397 }
398 break;
399 case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
400 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport);
401 CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities);
402 CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities);
403 CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase);
404 switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
405 {
406 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
407 CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode);
408 CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, ((u16) (32)));
409 break;
410 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
411 CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode);
412 CsrCharStringSer(ptr, len, primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
413 break;
414 default:
415 break;
416 }
417 break;
418 default:
419 break;
420 }
421 CsrUint8Ser(ptr, len, (u8) primitive->maxConnections);
422 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.groupCapability);
423 CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.country, ((u16) (3)));
424 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryListCount);
425 {
426 u16 i3;
427 for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
428 {
429 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass);
430 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount);
431 if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)
432 {
433 CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)));
434 }
435 }
436 }
437 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.opPsEnabled);
438 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.ctWindow);
439 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.noaConfigMethod);
440 CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.allowNoaWithNonP2pDevices);
441 CsrUint8Ser(ptr, len, (u8) primitive->wpsEnabled);
442 return(ptr);
443}
444
445
446void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t length)
447{
448 CsrWifiNmeApStartReq *primitive = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL);
449 size_t offset;
450 offset = 0;
451
452 CsrUint16Des(&primitive->common.type, buffer, &offset);
453 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
454 CsrUint8Des((u8 *) &primitive->apType, buffer, &offset);
455 CsrUint8Des((u8 *) &primitive->cloakSsid, buffer, &offset);
456 CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
457 CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
458 CsrUint8Des((u8 *) &primitive->ifIndex, buffer, &offset);
459 CsrUint8Des((u8 *) &primitive->channel, buffer, &offset);
460 CsrUint8Des((u8 *) &primitive->apCredentials.authType, buffer, &offset);
461 switch (primitive->apCredentials.authType)
462 {
463 case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
464 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.openSystemEmpty.empty, buffer, &offset);
465 break;
466 case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
467 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepKeyType, buffer, &offset);
468 switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
469 {
470 case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
471 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType, buffer, &offset);
472 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey, buffer, &offset);
473 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, buffer, &offset, ((u16) (13)));
474 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, buffer, &offset, ((u16) (13)));
475 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, buffer, &offset, ((u16) (13)));
476 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, buffer, &offset, ((u16) (13)));
477 break;
478 case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
479 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType, buffer, &offset);
480 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey, buffer, &offset);
481 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, buffer, &offset, ((u16) (5)));
482 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, buffer, &offset, ((u16) (5)));
483 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, buffer, &offset, ((u16) (5)));
484 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, buffer, &offset, ((u16) (5)));
485 break;
486 default:
487 break;
488 }
489 break;
490 case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
491 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport, buffer, &offset);
492 CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities, buffer, &offset);
493 CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities, buffer, &offset);
494 CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase, buffer, &offset);
495 switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
496 {
497 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
498 CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode, buffer, &offset);
499 CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, buffer, &offset, ((u16) (32)));
500 break;
501 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
502 CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode, buffer, &offset);
503 CsrCharStringDes(&primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase, buffer, &offset);
504 break;
505 default:
506 break;
507 }
508 break;
509 default:
510 break;
511 }
512 CsrUint8Des((u8 *) &primitive->maxConnections, buffer, &offset);
513 CsrUint8Des((u8 *) &primitive->p2pGoParam.groupCapability, buffer, &offset);
514 CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.country, buffer, &offset, ((u16) (3)));
515 CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryListCount, buffer, &offset);
516 primitive->p2pGoParam.operatingChanList.channelEntryList = NULL;
517 if (primitive->p2pGoParam.operatingChanList.channelEntryListCount)
518 {
519 primitive->p2pGoParam.operatingChanList.channelEntryList = kmalloc(sizeof(CsrWifiSmeApP2pOperatingChanEntry) * primitive->p2pGoParam.operatingChanList.channelEntryListCount, GFP_KERNEL);
520 }
521 {
522 u16 i3;
523 for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
524 {
525 CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass, buffer, &offset);
526 CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, buffer, &offset);
527 if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)
528 {
529 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = kmalloc(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, GFP_KERNEL);
530 CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, buffer, &offset, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)));
531 }
532 else
533 {
534 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL;
535 }
536 }
537 }
538 CsrUint8Des((u8 *) &primitive->p2pGoParam.opPsEnabled, buffer, &offset);
539 CsrUint8Des((u8 *) &primitive->p2pGoParam.ctWindow, buffer, &offset);
540 CsrUint8Des((u8 *) &primitive->p2pGoParam.noaConfigMethod, buffer, &offset);
541 CsrUint8Des((u8 *) &primitive->p2pGoParam.allowNoaWithNonP2pDevices, buffer, &offset);
542 CsrUint8Des((u8 *) &primitive->wpsEnabled, buffer, &offset);
543
544 return primitive;
545}
546
547
548void CsrWifiNmeApStartReqSerFree(void *voidPrimitivePointer)
549{
550 CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) voidPrimitivePointer;
551 switch (primitive->apCredentials.authType)
552 {
553 case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
554 switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
555 {
556 case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
557 kfree(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
558 break;
559 default:
560 break;
561 }
562 break;
563 default:
564 break;
565 }
566 {
567 u16 i3;
568 for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
569 {
570 kfree(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel);
571 }
572 }
573 kfree(primitive->p2pGoParam.operatingChanList.channelEntryList);
574 kfree(primitive);
575}
576
577
578size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg)
579{
580 size_t bufferSize = 2;
581
582 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 51) */
583 {
584 u16 i1;
585 for (i1 = 0; i1 < 4; i1++)
586 {
587 bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMin */
588 bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMax */
589 bufferSize += 1; /* u8 primitive->wmmApParams[i1].aifs */
590 bufferSize += 2; /* u16 primitive->wmmApParams[i1].txopLimit */
591 bufferSize += 1; /* u8 primitive->wmmApParams[i1].admissionControlMandatory */
592 }
593 }
594 {
595 u16 i1;
596 for (i1 = 0; i1 < 4; i1++)
597 {
598 bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMin */
599 bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMax */
600 bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].aifs */
601 bufferSize += 2; /* u16 primitive->wmmApBcParams[i1].txopLimit */
602 bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].admissionControlMandatory */
603 }
604 }
605 return bufferSize;
606}
607
608
609u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg)
610{
611 CsrWifiNmeApWmmParamUpdateReq *primitive = (CsrWifiNmeApWmmParamUpdateReq *)msg;
612 *len = 0;
613 CsrUint16Ser(ptr, len, primitive->common.type);
614 {
615 u16 i1;
616 for (i1 = 0; i1 < 4; i1++)
617 {
618 CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMin);
619 CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMax);
620 CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].aifs);
621 CsrUint16Ser(ptr, len, (u16) primitive->wmmApParams[i1].txopLimit);
622 CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].admissionControlMandatory);
623 }
624 }
625 {
626 u16 i1;
627 for (i1 = 0; i1 < 4; i1++)
628 {
629 CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMin);
630 CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMax);
631 CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].aifs);
632 CsrUint16Ser(ptr, len, (u16) primitive->wmmApBcParams[i1].txopLimit);
633 CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].admissionControlMandatory);
634 }
635 }
636 return(ptr);
637}
638
639
640void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t length)
641{
642 CsrWifiNmeApWmmParamUpdateReq *primitive = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL);
643 size_t offset;
644 offset = 0;
645
646 CsrUint16Des(&primitive->common.type, buffer, &offset);
647 {
648 u16 i1;
649 for (i1 = 0; i1 < 4; i1++)
650 {
651 CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMin, buffer, &offset);
652 CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMax, buffer, &offset);
653 CsrUint8Des((u8 *) &primitive->wmmApParams[i1].aifs, buffer, &offset);
654 CsrUint16Des((u16 *) &primitive->wmmApParams[i1].txopLimit, buffer, &offset);
655 CsrUint8Des((u8 *) &primitive->wmmApParams[i1].admissionControlMandatory, buffer, &offset);
656 }
657 }
658 {
659 u16 i1;
660 for (i1 = 0; i1 < 4; i1++)
661 {
662 CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMin, buffer, &offset);
663 CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMax, buffer, &offset);
664 CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].aifs, buffer, &offset);
665 CsrUint16Des((u16 *) &primitive->wmmApBcParams[i1].txopLimit, buffer, &offset);
666 CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].admissionControlMandatory, buffer, &offset);
667 }
668 }
669
670 return primitive;
671}
672
673
674size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg)
675{
676 size_t bufferSize = 2;
677
678 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
679 bufferSize += 2; /* u16 primitive->interfaceTag */
680 bufferSize += 6; /* u8 primitive->staMacAddress.a[6] */
681 bufferSize += 1; /* u8 primitive->keepBlocking */
682 return bufferSize;
683}
684
685
686u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg)
687{
688 CsrWifiNmeApStaRemoveReq *primitive = (CsrWifiNmeApStaRemoveReq *)msg;
689 *len = 0;
690 CsrUint16Ser(ptr, len, primitive->common.type);
691 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
692 CsrMemCpySer(ptr, len, (const void *) primitive->staMacAddress.a, ((u16) (6)));
693 CsrUint8Ser(ptr, len, (u8) primitive->keepBlocking);
694 return(ptr);
695}
696
697
698void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t length)
699{
700 CsrWifiNmeApStaRemoveReq *primitive = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL);
701 size_t offset;
702 offset = 0;
703
704 CsrUint16Des(&primitive->common.type, buffer, &offset);
705 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
706 CsrMemCpyDes(primitive->staMacAddress.a, buffer, &offset, ((u16) (6)));
707 CsrUint8Des((u8 *) &primitive->keepBlocking, buffer, &offset);
708
709 return primitive;
710}
711
712
713size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg)
714{
715 size_t bufferSize = 2;
716
717 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
718 bufferSize += 2; /* u16 primitive->interfaceTag */
719 bufferSize += 2; /* CsrResult primitive->status */
720 return bufferSize;
721}
722
723
724u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg)
725{
726 CsrWifiNmeApWpsRegisterCfm *primitive = (CsrWifiNmeApWpsRegisterCfm *)msg;
727 *len = 0;
728 CsrUint16Ser(ptr, len, primitive->common.type);
729 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
730 CsrUint16Ser(ptr, len, (u16) primitive->status);
731 return(ptr);
732}
733
734
735void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t length)
736{
737 CsrWifiNmeApWpsRegisterCfm *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL);
738 size_t offset;
739 offset = 0;
740
741 CsrUint16Des(&primitive->common.type, buffer, &offset);
742 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
743 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
744
745 return primitive;
746}
747
748
749size_t CsrWifiNmeApStartCfmSizeof(void *msg)
750{
751 size_t bufferSize = 2;
752
753 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 40) */
754 bufferSize += 2; /* u16 primitive->interfaceTag */
755 bufferSize += 2; /* CsrResult primitive->status */
756 bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
757 bufferSize += 1; /* u8 primitive->ssid.length */
758 return bufferSize;
759}
760
761
762u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg)
763{
764 CsrWifiNmeApStartCfm *primitive = (CsrWifiNmeApStartCfm *)msg;
765 *len = 0;
766 CsrUint16Ser(ptr, len, primitive->common.type);
767 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
768 CsrUint16Ser(ptr, len, (u16) primitive->status);
769 CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
770 CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
771 return(ptr);
772}
773
774
775void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t length)
776{
777 CsrWifiNmeApStartCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL);
778 size_t offset;
779 offset = 0;
780
781 CsrUint16Des(&primitive->common.type, buffer, &offset);
782 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
783 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
784 CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
785 CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
786
787 return primitive;
788}
789
790
791size_t CsrWifiNmeApStopCfmSizeof(void *msg)
792{
793 size_t bufferSize = 2;
794
795 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
796 bufferSize += 2; /* u16 primitive->interfaceTag */
797 bufferSize += 2; /* CsrResult primitive->status */
798 return bufferSize;
799}
800
801
802u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg)
803{
804 CsrWifiNmeApStopCfm *primitive = (CsrWifiNmeApStopCfm *)msg;
805 *len = 0;
806 CsrUint16Ser(ptr, len, primitive->common.type);
807 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
808 CsrUint16Ser(ptr, len, (u16) primitive->status);
809 return(ptr);
810}
811
812
813void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t length)
814{
815 CsrWifiNmeApStopCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL);
816 size_t offset;
817 offset = 0;
818
819 CsrUint16Des(&primitive->common.type, buffer, &offset);
820 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
821 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
822
823 return primitive;
824}
825
826
827size_t CsrWifiNmeApStopIndSizeof(void *msg)
828{
829 size_t bufferSize = 2;
830
831 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
832 bufferSize += 2; /* u16 primitive->interfaceTag */
833 bufferSize += 1; /* CsrWifiSmeApType primitive->apType */
834 bufferSize += 2; /* CsrResult primitive->status */
835 return bufferSize;
836}
837
838
839u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg)
840{
841 CsrWifiNmeApStopInd *primitive = (CsrWifiNmeApStopInd *)msg;
842 *len = 0;
843 CsrUint16Ser(ptr, len, primitive->common.type);
844 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
845 CsrUint8Ser(ptr, len, (u8) primitive->apType);
846 CsrUint16Ser(ptr, len, (u16) primitive->status);
847 return(ptr);
848}
849
850
851void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t length)
852{
853 CsrWifiNmeApStopInd *primitive = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL);
854 size_t offset;
855 offset = 0;
856
857 CsrUint16Des(&primitive->common.type, buffer, &offset);
858 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
859 CsrUint8Des((u8 *) &primitive->apType, buffer, &offset);
860 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
861
862 return primitive;
863}
864
865
866size_t CsrWifiNmeApStationIndSizeof(void *msg)
867{
868 size_t bufferSize = 2;
869
870 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
871 bufferSize += 2; /* u16 primitive->interfaceTag */
872 bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */
873 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
874 bufferSize += 6; /* u8 primitive->peerDeviceAddress.a[6] */
875 return bufferSize;
876}
877
878
879u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg)
880{
881 CsrWifiNmeApStationInd *primitive = (CsrWifiNmeApStationInd *)msg;
882 *len = 0;
883 CsrUint16Ser(ptr, len, primitive->common.type);
884 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
885 CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
886 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
887 CsrMemCpySer(ptr, len, (const void *) primitive->peerDeviceAddress.a, ((u16) (6)));
888 return(ptr);
889}
890
891
892void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t length)
893{
894 CsrWifiNmeApStationInd *primitive = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL);
895 size_t offset;
896 offset = 0;
897
898 CsrUint16Des(&primitive->common.type, buffer, &offset);
899 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
900 CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
901 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
902 CsrMemCpyDes(primitive->peerDeviceAddress.a, buffer, &offset, ((u16) (6)));
903
904 return primitive;
905}
906
907
908#endif /* CSR_WIFI_NME_ENABLE */
909#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
index c04585e72460..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_ap_serialize.h
+++ /dev/null
@@ -1,94 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_AP_SERIALIZE_H__
14#define CSR_WIFI_NME_AP_SERIALIZE_H__
15
16#include "csr_wifi_msgconv.h"
17
18#include "csr_wifi_nme_ap_prim.h"
19
20#ifndef CSR_WIFI_NME_ENABLE
21#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h
22#endif
23#ifndef CSR_WIFI_AP_ENABLE
24#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h
25#endif
26
27extern void CsrWifiNmeApPfree(void *ptr);
28
29extern u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
30extern void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t len);
31extern size_t CsrWifiNmeApConfigSetReqSizeof(void *msg);
32extern void CsrWifiNmeApConfigSetReqSerFree(void *msg);
33
34extern u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg);
35extern void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t len);
36extern size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg);
37#define CsrWifiNmeApWpsRegisterReqSerFree CsrWifiNmeApPfree
38
39extern u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg);
40extern void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t len);
41extern size_t CsrWifiNmeApStartReqSizeof(void *msg);
42extern void CsrWifiNmeApStartReqSerFree(void *msg);
43
44#define CsrWifiNmeApStopReqSer CsrWifiEventCsrUint16Ser
45#define CsrWifiNmeApStopReqDes CsrWifiEventCsrUint16Des
46#define CsrWifiNmeApStopReqSizeof CsrWifiEventCsrUint16Sizeof
47#define CsrWifiNmeApStopReqSerFree CsrWifiNmeApPfree
48
49extern u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg);
50extern void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t len);
51extern size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg);
52#define CsrWifiNmeApWmmParamUpdateReqSerFree CsrWifiNmeApPfree
53
54extern u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg);
55extern void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t len);
56extern size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg);
57#define CsrWifiNmeApStaRemoveReqSerFree CsrWifiNmeApPfree
58
59#define CsrWifiNmeApConfigSetCfmSer CsrWifiEventCsrUint16Ser
60#define CsrWifiNmeApConfigSetCfmDes CsrWifiEventCsrUint16Des
61#define CsrWifiNmeApConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
62#define CsrWifiNmeApConfigSetCfmSerFree CsrWifiNmeApPfree
63
64extern u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg);
65extern void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t len);
66extern size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg);
67#define CsrWifiNmeApWpsRegisterCfmSerFree CsrWifiNmeApPfree
68
69extern u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg);
70extern void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t len);
71extern size_t CsrWifiNmeApStartCfmSizeof(void *msg);
72#define CsrWifiNmeApStartCfmSerFree CsrWifiNmeApPfree
73
74extern u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg);
75extern void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t len);
76extern size_t CsrWifiNmeApStopCfmSizeof(void *msg);
77#define CsrWifiNmeApStopCfmSerFree CsrWifiNmeApPfree
78
79extern u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg);
80extern void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t len);
81extern size_t CsrWifiNmeApStopIndSizeof(void *msg);
82#define CsrWifiNmeApStopIndSerFree CsrWifiNmeApPfree
83
84#define CsrWifiNmeApWmmParamUpdateCfmSer CsrWifiEventCsrUint16Ser
85#define CsrWifiNmeApWmmParamUpdateCfmDes CsrWifiEventCsrUint16Des
86#define CsrWifiNmeApWmmParamUpdateCfmSizeof CsrWifiEventCsrUint16Sizeof
87#define CsrWifiNmeApWmmParamUpdateCfmSerFree CsrWifiNmeApPfree
88
89extern u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg);
90extern void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t len);
91extern size_t CsrWifiNmeApStationIndSizeof(void *msg);
92#define CsrWifiNmeApStationIndSerFree CsrWifiNmeApPfree
93
94#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
index 85e6f5f57130..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_converter_init.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_CONVERTER_INIT_H__
14#define CSR_WIFI_NME_CONVERTER_INIT_H__
15
16#ifndef CSR_WIFI_NME_ENABLE
17#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_converter_init.h
18#endif
19
20#ifndef EXCLUDE_CSR_WIFI_NME_MODULE
21
22#include "csr_msgconv.h"
23
24#ifdef CSR_LOG_ENABLE
25#include "csr_log.h"
26
27extern const CsrLogPrimitiveInformation* CsrWifiNmeTechInfoGet(void);
28#endif /* CSR_LOG_ENABLE */
29
30extern void CsrWifiNmeConverterInit(void);
31
32#else /* EXCLUDE_CSR_WIFI_NME_MODULE */
33
34#define CsrWifiNmeConverterInit()
35
36#endif /* EXCLUDE_CSR_WIFI_NME_MODULE */
37
38#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
index 5a1f132009bf..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_lib.h
+++ /dev/null
@@ -1,991 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_LIB_H__
14#define CSR_WIFI_NME_LIB_H__
15
16#include "csr_sched.h"
17#include "csr_macro.h"
18#include "csr_msg_transport.h"
19
20#include "csr_wifi_lib.h"
21
22#include "csr_wifi_nme_prim.h"
23#include "csr_wifi_nme_task.h"
24
25
26#ifndef CSR_WIFI_NME_ENABLE
27#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_lib.h
28#endif
29
30/*******************************************************************************
31
32 NAME
33 CsrWifiNmeConnectionStatusGetReqSend
34
35 DESCRIPTION
36 Requests the current connection status of the NME.
37
38 PARAMETERS
39 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
40 interfaceTag - Interface Identifier; unique identifier of an interface
41
42*******************************************************************************/
43#define CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__) \
44 msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetReq), GFP_KERNEL); \
45 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ, dst__, src__); \
46 msg__->interfaceTag = (interfaceTag__);
47
48#define CsrWifiNmeConnectionStatusGetReqSendTo(dst__, src__, interfaceTag__) \
49 { \
50 CsrWifiNmeConnectionStatusGetReq *msg__; \
51 CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__); \
52 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
53 }
54
55#define CsrWifiNmeConnectionStatusGetReqSend(src__, interfaceTag__) \
56 CsrWifiNmeConnectionStatusGetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
57
58/*******************************************************************************
59
60 NAME
61 CsrWifiNmeConnectionStatusGetCfmSend
62
63 DESCRIPTION
64 Reports the connection status of the NME.
65
66 PARAMETERS
67 queue - Destination Task Queue
68 interfaceTag - Interface Identifier; unique identifier of an interface
69 status - Indicates the success or otherwise of the requested
70 operation.
71 connectionStatus - NME current connection status
72
73*******************************************************************************/
74#define CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__) \
75 msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetCfm), GFP_KERNEL); \
76 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM, dst__, src__); \
77 msg__->interfaceTag = (interfaceTag__); \
78 msg__->status = (status__); \
79 msg__->connectionStatus = (connectionStatus__);
80
81#define CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStatus__) \
82 { \
83 CsrWifiNmeConnectionStatusGetCfm *msg__; \
84 CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__); \
85 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
86 }
87
88#define CsrWifiNmeConnectionStatusGetCfmSend(dst__, interfaceTag__, status__, connectionStatus__) \
89 CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectionStatus__)
90
91/*******************************************************************************
92
93 NAME
94 CsrWifiNmeEventMaskSetReqSend
95
96 DESCRIPTION
97 The wireless manager application may register with the NME to receive
98 notification of interesting events. Indications will be sent only if the
99 wireless manager explicitly registers to be notified of that event.
100 indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask.
101
102 PARAMETERS
103 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
104 indMask - Set mask with values from CsrWifiNmeIndications
105
106*******************************************************************************/
107#define CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \
108 msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetReq), GFP_KERNEL); \
109 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_REQ, dst__, src__); \
110 msg__->indMask = (indMask__);
111
112#define CsrWifiNmeEventMaskSetReqSendTo(dst__, src__, indMask__) \
113 { \
114 CsrWifiNmeEventMaskSetReq *msg__; \
115 CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \
116 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
117 }
118
119#define CsrWifiNmeEventMaskSetReqSend(src__, indMask__) \
120 CsrWifiNmeEventMaskSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, indMask__)
121
122/*******************************************************************************
123
124 NAME
125 CsrWifiNmeEventMaskSetCfmSend
126
127 DESCRIPTION
128 The NME calls the primitive to report the result of the request
129 primitive.
130
131 PARAMETERS
132 queue - Destination Task Queue
133 status - Reports the result of the request
134
135*******************************************************************************/
136#define CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \
137 msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetCfm), GFP_KERNEL); \
138 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_CFM, dst__, src__); \
139 msg__->status = (status__);
140
141#define CsrWifiNmeEventMaskSetCfmSendTo(dst__, src__, status__) \
142 { \
143 CsrWifiNmeEventMaskSetCfm *msg__; \
144 CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \
145 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
146 }
147
148#define CsrWifiNmeEventMaskSetCfmSend(dst__, status__) \
149 CsrWifiNmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
150
151/*******************************************************************************
152
153 NAME
154 CsrWifiNmeProfileConnectReqSend
155
156 DESCRIPTION
157 Requests the NME to attempt to connect to the specified profile.
158 Overrides any current connection attempt.
159
160 PARAMETERS
161 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
162 interfaceTag - Interface Identifier; unique identifier of an interface
163 profileIdentity - Identity (BSSID, SSID) of profile to be connected to.
164 It must match an existing profile in the NME.
165
166*******************************************************************************/
167#define CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__) \
168 msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectReq), GFP_KERNEL); \
169 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_REQ, dst__, src__); \
170 msg__->interfaceTag = (interfaceTag__); \
171 msg__->profileIdentity = (profileIdentity__);
172
173#define CsrWifiNmeProfileConnectReqSendTo(dst__, src__, interfaceTag__, profileIdentity__) \
174 { \
175 CsrWifiNmeProfileConnectReq *msg__; \
176 CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__); \
177 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
178 }
179
180#define CsrWifiNmeProfileConnectReqSend(src__, interfaceTag__, profileIdentity__) \
181 CsrWifiNmeProfileConnectReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentity__)
182
183/*******************************************************************************
184
185 NAME
186 CsrWifiNmeProfileConnectCfmSend
187
188 DESCRIPTION
189 Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the
190 connectAttempt parameters contain details of the APs that the NME
191 attempted to connect to before reporting the failure of the request.
192
193 PARAMETERS
194 queue - Destination Task Queue
195 interfaceTag - Interface Identifier; unique identifier of an
196 interface
197 status - Indicates the success or otherwise of the requested
198 operation.
199 connectAttemptsCount - This parameter is relevant only if
200 status!=CSR_WIFI_NME_STATUS_SUCCESS.
201 Number of connection attempt elements provided with
202 this primitive
203 connectAttempts - This parameter is relevant only if
204 status!=CSR_WIFI_NME_STATUS_SUCCESS.
205 Points to the list of connection attempt elements
206 provided with this primitive
207 Each element of the list provides information about
208 an AP on which the connection attempt was made and
209 the error that occurred during the attempt.
210
211*******************************************************************************/
212#define CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
213 msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectCfm), GFP_KERNEL); \
214 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_CFM, dst__, src__); \
215 msg__->interfaceTag = (interfaceTag__); \
216 msg__->status = (status__); \
217 msg__->connectAttemptsCount = (connectAttemptsCount__); \
218 msg__->connectAttempts = (connectAttempts__);
219
220#define CsrWifiNmeProfileConnectCfmSendTo(dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
221 { \
222 CsrWifiNmeProfileConnectCfm *msg__; \
223 CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__); \
224 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
225 }
226
227#define CsrWifiNmeProfileConnectCfmSend(dst__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
228 CsrWifiNmeProfileConnectCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__)
229
230/*******************************************************************************
231
232 NAME
233 CsrWifiNmeProfileDeleteAllReqSend
234
235 DESCRIPTION
236 Deletes all profiles present in the NME, but does NOT modify the
237 preferred profile list.
238
239 PARAMETERS
240 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
241
242*******************************************************************************/
243#define CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__) \
244 msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllReq), GFP_KERNEL); \
245 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ, dst__, src__);
246
247#define CsrWifiNmeProfileDeleteAllReqSendTo(dst__, src__) \
248 { \
249 CsrWifiNmeProfileDeleteAllReq *msg__; \
250 CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__); \
251 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
252 }
253
254#define CsrWifiNmeProfileDeleteAllReqSend(src__) \
255 CsrWifiNmeProfileDeleteAllReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__)
256
257/*******************************************************************************
258
259 NAME
260 CsrWifiNmeProfileDeleteAllCfmSend
261
262 DESCRIPTION
263 Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ.
264 Returns always CSR_WIFI_NME_STATUS_SUCCESS.
265
266 PARAMETERS
267 queue - Destination Task Queue
268 status - Indicates the success or otherwise of the requested operation, but
269 in this case it always set to success.
270
271*******************************************************************************/
272#define CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__) \
273 msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllCfm), GFP_KERNEL); \
274 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM, dst__, src__); \
275 msg__->status = (status__);
276
277#define CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, src__, status__) \
278 { \
279 CsrWifiNmeProfileDeleteAllCfm *msg__; \
280 CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__); \
281 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
282 }
283
284#define CsrWifiNmeProfileDeleteAllCfmSend(dst__, status__) \
285 CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
286
287/*******************************************************************************
288
289 NAME
290 CsrWifiNmeProfileDeleteReqSend
291
292 DESCRIPTION
293 Will delete the profile with a matching identity, but does NOT modify the
294 preferred profile list.
295
296 PARAMETERS
297 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
298 profileIdentity - Identity (BSSID, SSID) of profile to be deleted.
299
300*******************************************************************************/
301#define CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__) \
302 msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteReq), GFP_KERNEL); \
303 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_REQ, dst__, src__); \
304 msg__->profileIdentity = (profileIdentity__);
305
306#define CsrWifiNmeProfileDeleteReqSendTo(dst__, src__, profileIdentity__) \
307 { \
308 CsrWifiNmeProfileDeleteReq *msg__; \
309 CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__); \
310 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
311 }
312
313#define CsrWifiNmeProfileDeleteReqSend(src__, profileIdentity__) \
314 CsrWifiNmeProfileDeleteReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profileIdentity__)
315
316/*******************************************************************************
317
318 NAME
319 CsrWifiNmeProfileDeleteCfmSend
320
321 DESCRIPTION
322 Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ.
323 Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile.
324
325 PARAMETERS
326 queue - Destination Task Queue
327 status - Indicates the success or otherwise of the requested operation.
328
329*******************************************************************************/
330#define CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__) \
331 msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteCfm), GFP_KERNEL); \
332 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_CFM, dst__, src__); \
333 msg__->status = (status__);
334
335#define CsrWifiNmeProfileDeleteCfmSendTo(dst__, src__, status__) \
336 { \
337 CsrWifiNmeProfileDeleteCfm *msg__; \
338 CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__); \
339 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
340 }
341
342#define CsrWifiNmeProfileDeleteCfmSend(dst__, status__) \
343 CsrWifiNmeProfileDeleteCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
344
345/*******************************************************************************
346
347 NAME
348 CsrWifiNmeProfileDisconnectIndSend
349
350 DESCRIPTION
351 Indication generated from the NME (if an application subscribes to
352 receive it) that informs that application that the current profile
353 connection has disconnected. The indication will contain information
354 about APs that it attempted to maintain the connection via i.e. in the
355 case of failed roaming.
356
357 PARAMETERS
358 queue - Destination Task Queue
359 interfaceTag - Interface Identifier; unique identifier of an
360 interface
361 connectAttemptsCount - Number of connection attempt elements provided with
362 this primitive
363 connectAttempts - Points to the list of connection attempt elements
364 provided with this primitive
365 Each element of the list provides information about
366 an AP on which the connection attempt was made and
367 the error occurred during the attempt.
368
369*******************************************************************************/
370#define CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
371 msg__ = kmalloc(sizeof(CsrWifiNmeProfileDisconnectInd), GFP_KERNEL); \
372 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DISCONNECT_IND, dst__, src__); \
373 msg__->interfaceTag = (interfaceTag__); \
374 msg__->connectAttemptsCount = (connectAttemptsCount__); \
375 msg__->connectAttempts = (connectAttempts__);
376
377#define CsrWifiNmeProfileDisconnectIndSendTo(dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
378 { \
379 CsrWifiNmeProfileDisconnectInd *msg__; \
380 CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__); \
381 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
382 }
383
384#define CsrWifiNmeProfileDisconnectIndSend(dst__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
385 CsrWifiNmeProfileDisconnectIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, connectAttemptsCount__, connectAttempts__)
386
387/*******************************************************************************
388
389 NAME
390 CsrWifiNmeProfileOrderSetReqSend
391
392 DESCRIPTION
393 Defines the preferred order that profiles present in the NME should be
394 used during the NME auto-connect behaviour.
395 If profileIdentitysCount == 0, it removes any existing preferred profile
396 list already present in the NME, effectively disabling the auto-connect
397 behaviour.
398 NOTE: Profile identities that do not match any profile stored in the NME
399 are ignored during the auto-connect procedure.
400 NOTE: during auto-connect the NME will only attempt to join an existing
401 adhoc network and it will never attempt to host an adhoc network; for
402 hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ
403
404 PARAMETERS
405 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
406 interfaceTag - Interface Identifier; unique identifier of an
407 interface
408 profileIdentitysCount - The number of profiles identities in the list.
409 profileIdentitys - Points to the list of profile identities.
410
411*******************************************************************************/
412#define CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
413 msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetReq), GFP_KERNEL); \
414 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_REQ, dst__, src__); \
415 msg__->interfaceTag = (interfaceTag__); \
416 msg__->profileIdentitysCount = (profileIdentitysCount__); \
417 msg__->profileIdentitys = (profileIdentitys__);
418
419#define CsrWifiNmeProfileOrderSetReqSendTo(dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
420 { \
421 CsrWifiNmeProfileOrderSetReq *msg__; \
422 CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__); \
423 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
424 }
425
426#define CsrWifiNmeProfileOrderSetReqSend(src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
427 CsrWifiNmeProfileOrderSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__)
428
429/*******************************************************************************
430
431 NAME
432 CsrWifiNmeProfileOrderSetCfmSend
433
434 DESCRIPTION
435 Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request.
436
437 PARAMETERS
438 queue - Destination Task Queue
439 interfaceTag - Interface Identifier; unique identifier of an interface
440 status - Indicates the success or otherwise of the requested
441 operation.
442
443*******************************************************************************/
444#define CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
445 msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetCfm), GFP_KERNEL); \
446 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_CFM, dst__, src__); \
447 msg__->interfaceTag = (interfaceTag__); \
448 msg__->status = (status__);
449
450#define CsrWifiNmeProfileOrderSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
451 { \
452 CsrWifiNmeProfileOrderSetCfm *msg__; \
453 CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
454 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
455 }
456
457#define CsrWifiNmeProfileOrderSetCfmSend(dst__, interfaceTag__, status__) \
458 CsrWifiNmeProfileOrderSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
459
460/*******************************************************************************
461
462 NAME
463 CsrWifiNmeProfileSetReqSend
464
465 DESCRIPTION
466 Creates or updates an existing profile in the NME that matches the unique
467 identity of the profile. Each profile is identified by the combination of
468 BSSID and SSID. The profile contains all the required credentials for
469 attempting to connect to the network. Creating or updating a profile via
470 the NME PROFILE SET REQ does NOT add the profile to the preferred profile
471 list within the NME used for the NME auto-connect behaviour.
472
473 PARAMETERS
474 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
475 profile - Specifies the identity and credentials of the network.
476
477*******************************************************************************/
478#define CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__) \
479 msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetReq), GFP_KERNEL); \
480 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_REQ, dst__, src__); \
481 msg__->profile = (profile__);
482
483#define CsrWifiNmeProfileSetReqSendTo(dst__, src__, profile__) \
484 { \
485 CsrWifiNmeProfileSetReq *msg__; \
486 CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__); \
487 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
488 }
489
490#define CsrWifiNmeProfileSetReqSend(src__, profile__) \
491 CsrWifiNmeProfileSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profile__)
492
493/*******************************************************************************
494
495 NAME
496 CsrWifiNmeProfileSetCfmSend
497
498 DESCRIPTION
499 Reports the status of the NME PROFILE SET REQ; the request will only fail
500 if the details specified in the profile contains an invalid combination
501 of parameters for example specifying the profile as cloaked but not
502 specifying the SSID. The NME doesn't limit the number of profiles that
503 may be created. The NME assumes that the entity configuring it is aware
504 of the appropriate limits.
505
506 PARAMETERS
507 queue - Destination Task Queue
508 status - Indicates the success or otherwise of the requested operation.
509
510*******************************************************************************/
511#define CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__) \
512 msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetCfm), GFP_KERNEL); \
513 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_CFM, dst__, src__); \
514 msg__->status = (status__);
515
516#define CsrWifiNmeProfileSetCfmSendTo(dst__, src__, status__) \
517 { \
518 CsrWifiNmeProfileSetCfm *msg__; \
519 CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__); \
520 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
521 }
522
523#define CsrWifiNmeProfileSetCfmSend(dst__, status__) \
524 CsrWifiNmeProfileSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
525
526/*******************************************************************************
527
528 NAME
529 CsrWifiNmeProfileUpdateIndSend
530
531 DESCRIPTION
532 Indication generated from the NME (if an application subscribes to
533 receive it) that informs that application that the contained profile has
534 changed.
535 For example, either the credentials EAP-FAST PAC file or the session data
536 within the profile has changed.
537 It is up to the application whether it stores this updated profile or
538 not.
539
540 PARAMETERS
541 queue - Destination Task Queue
542 interfaceTag - Interface Identifier; unique identifier of an interface
543 profile - The identity and credentials of the network.
544
545*******************************************************************************/
546#define CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__) \
547 msg__ = kmalloc(sizeof(CsrWifiNmeProfileUpdateInd), GFP_KERNEL); \
548 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_UPDATE_IND, dst__, src__); \
549 msg__->interfaceTag = (interfaceTag__); \
550 msg__->profile = (profile__);
551
552#define CsrWifiNmeProfileUpdateIndSendTo(dst__, src__, interfaceTag__, profile__) \
553 { \
554 CsrWifiNmeProfileUpdateInd *msg__; \
555 CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__); \
556 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
557 }
558
559#define CsrWifiNmeProfileUpdateIndSend(dst__, interfaceTag__, profile__) \
560 CsrWifiNmeProfileUpdateIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, profile__)
561
562/*******************************************************************************
563
564 NAME
565 CsrWifiNmeSimGsmAuthIndSend
566
567 DESCRIPTION
568 Indication generated from the NME (if an application subscribes to
569 receive it) that requests the UICC Manager to perform a GSM
570 authentication on behalf of the NME. This indication is generated when
571 the NME is attempting to connect to a profile configured for EAP-SIM. An
572 application MUST register to receive this indication for the NME to
573 support the EAP-SIM credential types. Otherwise the NME has no route to
574 obtain the information from the UICC. EAP-SIM authentication requires 2
575 or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random
576 Challenges) are included.
577
578 PARAMETERS
579 queue - Destination Task Queue
580 randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS)
581 or 48 (3 RANDs).
582 rands - 2 or 3 RANDs values.
583
584*******************************************************************************/
585#define CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__) \
586 msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthInd), GFP_KERNEL); \
587 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_IND, dst__, src__); \
588 msg__->randsLength = (randsLength__); \
589 msg__->rands = (rands__);
590
591#define CsrWifiNmeSimGsmAuthIndSendTo(dst__, src__, randsLength__, rands__) \
592 { \
593 CsrWifiNmeSimGsmAuthInd *msg__; \
594 CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__); \
595 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
596 }
597
598#define CsrWifiNmeSimGsmAuthIndSend(dst__, randsLength__, rands__) \
599 CsrWifiNmeSimGsmAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, randsLength__, rands__)
600
601/*******************************************************************************
602
603 NAME
604 CsrWifiNmeSimGsmAuthResSend
605
606 DESCRIPTION
607 Response from the application that received the NME SIM GSM AUTH IND. For
608 each GSM authentication round a GSM Ciphering key (Kc) and a signed
609 response (SRES) are produced. Since 2 or 3 GSM authentication rounds are
610 used the 2 or 3 Kc's obtained respectively are combined into one buffer
611 and similarly the 2 or 3 SRES's obtained are combined into another
612 buffer. The order of Kc values (SRES values respectively) in their buffer
613 is the same as that of their corresponding RAND values in the incoming
614 indication.
615
616 PARAMETERS
617 status - Indicates the outcome of the requested operation:
618 STATUS_SUCCESS or STATUS_ERROR
619 kcsLength - Length in Bytes of Kc buffer. Legal values are: 16 or 24.
620 kcs - Kc buffer holding 2 or 3 Kc values.
621 sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12.
622 sres - SRES buffer holding 2 or 3 SRES values.
623
624*******************************************************************************/
625#define CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
626 msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthRes), GFP_KERNEL); \
627 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_RES, dst__, src__); \
628 msg__->status = (status__); \
629 msg__->kcsLength = (kcsLength__); \
630 msg__->kcs = (kcs__); \
631 msg__->sresLength = (sresLength__); \
632 msg__->sres = (sres__);
633
634#define CsrWifiNmeSimGsmAuthResSendTo(dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
635 { \
636 CsrWifiNmeSimGsmAuthRes *msg__; \
637 CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__); \
638 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
639 }
640
641#define CsrWifiNmeSimGsmAuthResSend(src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
642 CsrWifiNmeSimGsmAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, kcsLength__, kcs__, sresLength__, sres__)
643
644/*******************************************************************************
645
646 NAME
647 CsrWifiNmeSimImsiGetIndSend
648
649 DESCRIPTION
650 Indication generated from the NME (if an application subscribes to
651 receive it) that requests the IMSI and UICC type from the UICC Manager.
652 This indication is generated when the NME is attempting to connect to a
653 profile configured for EAP-SIM/AKA. An application MUST register to
654 receive this indication for the NME to support the EAP-SIM/AKA credential
655 types. Otherwise the NME has no route to obtain the information from the
656 UICC.
657
658 PARAMETERS
659 queue - Destination Task Queue
660
661*******************************************************************************/
662#define CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__) \
663 msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetInd), GFP_KERNEL); \
664 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_IND, dst__, src__);
665
666#define CsrWifiNmeSimImsiGetIndSendTo(dst__, src__) \
667 { \
668 CsrWifiNmeSimImsiGetInd *msg__; \
669 CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__); \
670 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
671 }
672
673#define CsrWifiNmeSimImsiGetIndSend(dst__) \
674 CsrWifiNmeSimImsiGetIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE)
675
676/*******************************************************************************
677
678 NAME
679 CsrWifiNmeSimImsiGetResSend
680
681 DESCRIPTION
682 Response from the application that received the NME SIM IMSI GET IND.
683
684 PARAMETERS
685 status - Indicates the outcome of the requested operation: STATUS_SUCCESS
686 or STATUS_ERROR.
687 imsi - The value of the IMSI obtained from the UICC.
688 cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both).
689
690*******************************************************************************/
691#define CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__) \
692 msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetRes), GFP_KERNEL); \
693 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_RES, dst__, src__); \
694 msg__->status = (status__); \
695 msg__->imsi = (imsi__); \
696 msg__->cardType = (cardType__);
697
698#define CsrWifiNmeSimImsiGetResSendTo(dst__, src__, status__, imsi__, cardType__) \
699 { \
700 CsrWifiNmeSimImsiGetRes *msg__; \
701 CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__); \
702 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
703 }
704
705#define CsrWifiNmeSimImsiGetResSend(src__, status__, imsi__, cardType__) \
706 CsrWifiNmeSimImsiGetResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, imsi__, cardType__)
707
708/*******************************************************************************
709
710 NAME
711 CsrWifiNmeSimUmtsAuthIndSend
712
713 DESCRIPTION
714 Indication generated from the NME (if an application subscribes to
715 receive it) that requests the UICC Manager to perform a UMTS
716 authentication on behalf of the NME. This indication is generated when
717 the NME is attempting to connect to a profile configured for EAP-AKA. An
718 application MUST register to receive this indication for the NME to
719 support the EAP-AKA credential types. Otherwise the NME has no route to
720 obtain the information from the USIM. EAP-AKA requires one UMTS
721 authentication round and therefore only one RAND and one AUTN values are
722 included.
723
724 PARAMETERS
725 queue - Destination Task Queue
726 rand - UMTS RAND value.
727 autn - UMTS AUTN value.
728
729*******************************************************************************/
730#define CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__) \
731 msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthInd), GFP_KERNEL); \
732 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_IND, dst__, src__); \
733 memcpy(msg__->rand, (rand__), sizeof(u8) * 16); \
734 memcpy(msg__->autn, (autn__), sizeof(u8) * 16);
735
736#define CsrWifiNmeSimUmtsAuthIndSendTo(dst__, src__, rand__, autn__) \
737 { \
738 CsrWifiNmeSimUmtsAuthInd *msg__; \
739 CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__); \
740 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
741 }
742
743#define CsrWifiNmeSimUmtsAuthIndSend(dst__, rand__, autn__) \
744 CsrWifiNmeSimUmtsAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, rand__, autn__)
745
746/*******************************************************************************
747
748 NAME
749 CsrWifiNmeSimUmtsAuthResSend
750
751 DESCRIPTION
752 Response from the application that received the NME SIM UMTS AUTH IND.
753 The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and
754 resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS.
755 The value of auts is only meaningful when
756 result=UMTS_AUTH_RESULT_SYNC_FAIL.
757
758 PARAMETERS
759 status - Indicates the outcome of the requested operation:
760 STATUS_SUCCESS or STATUS_ERROR.
761 result - The result of UMTS authentication as performed by the
762 UICC which could be: Success, Authentication Reject or
763 Synchronisation Failure. For all these 3 outcomes the
764 value of status is success.
765 umtsCipherKey - The UMTS Cipher Key as calculated and returned by the
766 UICC.
767 umtsIntegrityKey - The UMTS Integrity Key as calculated and returned by
768 the UICC.
769 resParameterLength - The length (in bytes) of the RES parameter (min=4; max
770 = 16).
771 resParameter - The RES parameter as calculated and returned by the
772 UICC.
773 auts - The AUTS parameter as calculated and returned by the
774 UICC.
775
776*******************************************************************************/
777#define CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
778 msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthRes), GFP_KERNEL); \
779 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_RES, dst__, src__); \
780 msg__->status = (status__); \
781 msg__->result = (result__); \
782 memcpy(msg__->umtsCipherKey, (umtsCipherKey__), sizeof(u8) * 16); \
783 memcpy(msg__->umtsIntegrityKey, (umtsIntegrityKey__), sizeof(u8) * 16); \
784 msg__->resParameterLength = (resParameterLength__); \
785 msg__->resParameter = (resParameter__); \
786 memcpy(msg__->auts, (auts__), sizeof(u8) * 14);
787
788#define CsrWifiNmeSimUmtsAuthResSendTo(dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
789 { \
790 CsrWifiNmeSimUmtsAuthRes *msg__; \
791 CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__); \
792 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
793 }
794
795#define CsrWifiNmeSimUmtsAuthResSend(src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
796 CsrWifiNmeSimUmtsAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__)
797
798/*******************************************************************************
799
800 NAME
801 CsrWifiNmeWpsCancelReqSend
802
803 DESCRIPTION
804 Requests the NME to cancel any WPS procedure that it is currently
805 performing. This includes WPS registrar activities started because of
806 CSR_WIFI_NME_AP_REGISTER.request
807
808 PARAMETERS
809 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
810 interfaceTag - Interface Identifier; unique identifier of an interface
811
812*******************************************************************************/
813#define CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__) \
814 msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelReq), GFP_KERNEL); \
815 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_REQ, dst__, src__); \
816 msg__->interfaceTag = (interfaceTag__);
817
818#define CsrWifiNmeWpsCancelReqSendTo(dst__, src__, interfaceTag__) \
819 { \
820 CsrWifiNmeWpsCancelReq *msg__; \
821 CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__); \
822 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
823 }
824
825#define CsrWifiNmeWpsCancelReqSend(src__, interfaceTag__) \
826 CsrWifiNmeWpsCancelReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
827
828/*******************************************************************************
829
830 NAME
831 CsrWifiNmeWpsCancelCfmSend
832
833 DESCRIPTION
834 Reports the status of the NME WPS REQ, the request is always SUCCESSFUL.
835
836 PARAMETERS
837 queue - Destination Task Queue
838 interfaceTag - Interface Identifier; unique identifier of an interface
839 status - Only returns CSR_WIFI_NME_STATUS_SUCCESS
840
841*******************************************************************************/
842#define CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
843 msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelCfm), GFP_KERNEL); \
844 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_CFM, dst__, src__); \
845 msg__->interfaceTag = (interfaceTag__); \
846 msg__->status = (status__);
847
848#define CsrWifiNmeWpsCancelCfmSendTo(dst__, src__, interfaceTag__, status__) \
849 { \
850 CsrWifiNmeWpsCancelCfm *msg__; \
851 CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
852 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
853 }
854
855#define CsrWifiNmeWpsCancelCfmSend(dst__, interfaceTag__, status__) \
856 CsrWifiNmeWpsCancelCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
857
858/*******************************************************************************
859
860 NAME
861 CsrWifiNmeWpsCfmSend
862
863 DESCRIPTION
864 Reports the status of the NME WPS REQ.
865 If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the
866 identity and credentials of the AP.
867
868 PARAMETERS
869 queue - Destination Task Queue
870 interfaceTag - Interface Identifier; unique identifier of an interface
871 status - Indicates the success or otherwise of the requested
872 operation.
873 profile - This parameter is relevant only if
874 status==CSR_WIFI_NME_STATUS_SUCCESS.
875 The identity and credentials of the network.
876
877*******************************************************************************/
878#define CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__) \
879 msg__ = kmalloc(sizeof(CsrWifiNmeWpsCfm), GFP_KERNEL); \
880 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CFM, dst__, src__); \
881 msg__->interfaceTag = (interfaceTag__); \
882 msg__->status = (status__); \
883 msg__->profile = (profile__);
884
885#define CsrWifiNmeWpsCfmSendTo(dst__, src__, interfaceTag__, status__, profile__) \
886 { \
887 CsrWifiNmeWpsCfm *msg__; \
888 CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__); \
889 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
890 }
891
892#define CsrWifiNmeWpsCfmSend(dst__, interfaceTag__, status__, profile__) \
893 CsrWifiNmeWpsCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, profile__)
894
895/*******************************************************************************
896
897 NAME
898 CsrWifiNmeWpsConfigSetReqSend
899
900 DESCRIPTION
901 This primitive passes the WPS information for the device to NME. This may
902 be accepted only if no interface is active.
903
904 PARAMETERS
905 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
906 wpsConfig - WPS config.
907
908*******************************************************************************/
909#define CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__) \
910 msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetReq), GFP_KERNEL); \
911 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_REQ, dst__, src__); \
912 msg__->wpsConfig = (wpsConfig__);
913
914#define CsrWifiNmeWpsConfigSetReqSendTo(dst__, src__, wpsConfig__) \
915 { \
916 CsrWifiNmeWpsConfigSetReq *msg__; \
917 CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__); \
918 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
919 }
920
921#define CsrWifiNmeWpsConfigSetReqSend(src__, wpsConfig__) \
922 CsrWifiNmeWpsConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wpsConfig__)
923
924/*******************************************************************************
925
926 NAME
927 CsrWifiNmeWpsConfigSetCfmSend
928
929 DESCRIPTION
930 Confirm.
931
932 PARAMETERS
933 queue - Destination Task Queue
934 status - Status of the request.
935
936*******************************************************************************/
937#define CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__) \
938 msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetCfm), GFP_KERNEL); \
939 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_CFM, dst__, src__); \
940 msg__->status = (status__);
941
942#define CsrWifiNmeWpsConfigSetCfmSendTo(dst__, src__, status__) \
943 { \
944 CsrWifiNmeWpsConfigSetCfm *msg__; \
945 CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__); \
946 CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
947 }
948
949#define CsrWifiNmeWpsConfigSetCfmSend(dst__, status__) \
950 CsrWifiNmeWpsConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
951
952/*******************************************************************************
953
954 NAME
955 CsrWifiNmeWpsReqSend
956
957 DESCRIPTION
958 Requests the NME to look for WPS enabled APs and attempt to perform WPS
959 to determine the appropriate security credentials to connect to the AP.
960 If the PIN == '00000000' then 'push button mode' is indicated, otherwise
961 the PIN has to match that of the AP. 4 digit pin is passed by sending the
962 pin digits in pin[0]..pin[3] and rest of the contents filled with '-'.
963
964 PARAMETERS
965 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
966 interfaceTag - Interface Identifier; unique identifier of an interface
967 pin - PIN value.
968 ssid - Service Set identifier
969 bssid - ID of Basic Service Set for which a WPS connection attempt is
970 being made.
971
972*******************************************************************************/
973#define CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \
974 msg__ = kmalloc(sizeof(CsrWifiNmeWpsReq), GFP_KERNEL); \
975 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_REQ, dst__, src__); \
976 msg__->interfaceTag = (interfaceTag__); \
977 memcpy(msg__->pin, (pin__), sizeof(u8) * 8); \
978 msg__->ssid = (ssid__); \
979 msg__->bssid = (bssid__);
980
981#define CsrWifiNmeWpsReqSendTo(dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \
982 { \
983 CsrWifiNmeWpsReq *msg__; \
984 CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__); \
985 CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
986 }
987
988#define CsrWifiNmeWpsReqSend(src__, interfaceTag__, pin__, ssid__, bssid__) \
989 CsrWifiNmeWpsReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, pin__, ssid__, bssid__)
990
991#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
index 9a7927a117ea..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_prim.h
+++ /dev/null
@@ -1,1657 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_PRIM_H__
14#define CSR_WIFI_NME_PRIM_H__
15
16#include <linux/types.h>
17#include "csr_prim_defs.h"
18#include "csr_sched.h"
19#include "csr_wifi_common.h"
20#include "csr_result.h"
21#include "csr_wifi_fsm_event.h"
22#include "csr_wifi_sme_prim.h"
23
24#ifndef CSR_WIFI_NME_ENABLE
25#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_prim.h
26#endif
27
28#define CSR_WIFI_NME_PRIM (0x0424)
29
30typedef CsrPrim CsrWifiNmePrim;
31
32typedef void (*CsrWifiNmeFrameFreeFunction)(void *frame);
33
34/*******************************************************************************
35
36 NAME
37 CsrWifiNmeAuthMode
38
39 DESCRIPTION
40 WiFi Authentication Mode
41
42 VALUES
43 CSR_WIFI_NME_AUTH_MODE_80211_OPEN
44 - Connects to an open system network (i.e. no authentication,
45 no encryption) or to a WEP enabled network.
46 CSR_WIFI_NME_AUTH_MODE_80211_SHARED
47 - Connect to a WEP enabled network.
48 CSR_WIFI_NME_AUTH_MODE_8021X_WPA
49 - Connects to a WPA Enterprise enabled network.
50 CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK
51 - Connects to a WPA with Pre-Shared Key enabled network.
52 CSR_WIFI_NME_AUTH_MODE_8021X_WPA2
53 - Connects to a WPA2 Enterprise enabled network.
54 CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK
55 - Connects to a WPA2 with Pre-Shared Key enabled network.
56 CSR_WIFI_NME_AUTH_MODE_8021X_CCKM
57 - Connects to a CCKM enabled network.
58 CSR_WIFI_NME_AUTH_MODE_WAPI_WAI
59 - Connects to a WAPI Enterprise enabled network.
60 CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK
61 - Connects to a WAPI with Pre-Shared Key enabled network.
62 CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X
63 - For future use.
64
65*******************************************************************************/
66typedef u16 CsrWifiNmeAuthMode;
67#define CSR_WIFI_NME_AUTH_MODE_80211_OPEN ((CsrWifiNmeAuthMode) 0x0001)
68#define CSR_WIFI_NME_AUTH_MODE_80211_SHARED ((CsrWifiNmeAuthMode) 0x0002)
69#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA ((CsrWifiNmeAuthMode) 0x0004)
70#define CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK ((CsrWifiNmeAuthMode) 0x0008)
71#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2 ((CsrWifiNmeAuthMode) 0x0010)
72#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK ((CsrWifiNmeAuthMode) 0x0020)
73#define CSR_WIFI_NME_AUTH_MODE_8021X_CCKM ((CsrWifiNmeAuthMode) 0x0040)
74#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAI ((CsrWifiNmeAuthMode) 0x0080)
75#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK ((CsrWifiNmeAuthMode) 0x0100)
76#define CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X ((CsrWifiNmeAuthMode) 0x0200)
77
78/*******************************************************************************
79
80 NAME
81 CsrWifiNmeBssType
82
83 DESCRIPTION
84 Type of BSS
85
86 VALUES
87 CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE
88 - Infrastructure BSS type where access to the network is via
89 one or several Access Points.
90 CSR_WIFI_NME_BSS_TYPE_ADHOC
91 - Adhoc or Independent BSS Type where one Station acts as a
92 host and future stations can join the adhoc network without
93 needing an access point.
94 CSR_WIFI_NME_BSS_TYPE_RESERVED
95 - To be in sync with SME.This is not used.
96 CSR_WIFI_NME_BSS_TYPE_P2P
97 - P2P mode of operation.
98
99*******************************************************************************/
100typedef u8 CsrWifiNmeBssType;
101#define CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE ((CsrWifiNmeBssType) 0x00)
102#define CSR_WIFI_NME_BSS_TYPE_ADHOC ((CsrWifiNmeBssType) 0x01)
103#define CSR_WIFI_NME_BSS_TYPE_RESERVED ((CsrWifiNmeBssType) 0x02)
104#define CSR_WIFI_NME_BSS_TYPE_P2P ((CsrWifiNmeBssType) 0x03)
105
106/*******************************************************************************
107
108 NAME
109 CsrWifiNmeCcxOptionsMask
110
111 DESCRIPTION
112 Enumeration type defining possible mask values for setting CCX options.
113
114 VALUES
115 CSR_WIFI_NME_CCX_OPTION_NONE - No CCX option is set.
116 CSR_WIFI_NME_CCX_OPTION_CCKM - CCX option cckm is set.
117
118*******************************************************************************/
119typedef u8 CsrWifiNmeCcxOptionsMask;
120#define CSR_WIFI_NME_CCX_OPTION_NONE ((CsrWifiNmeCcxOptionsMask) 0x00)
121#define CSR_WIFI_NME_CCX_OPTION_CCKM ((CsrWifiNmeCcxOptionsMask) 0x01)
122
123/*******************************************************************************
124
125 NAME
126 CsrWifiNmeConfigAction
127
128 DESCRIPTION
129
130 VALUES
131 CSR_WIFI_PIN_ENTRY_PUSH_BUTTON -
132 CSR_WIFI_PIN_ENTRY_DISPLAY_PIN -
133 CSR_WIFI_PIN_ENTRY_ENTER_PIN -
134
135*******************************************************************************/
136typedef u8 CsrWifiNmeConfigAction;
137#define CSR_WIFI_PIN_ENTRY_PUSH_BUTTON ((CsrWifiNmeConfigAction) 0x00)
138#define CSR_WIFI_PIN_ENTRY_DISPLAY_PIN ((CsrWifiNmeConfigAction) 0x01)
139#define CSR_WIFI_PIN_ENTRY_ENTER_PIN ((CsrWifiNmeConfigAction) 0x02)
140
141/*******************************************************************************
142
143 NAME
144 CsrWifiNmeConnectionStatus
145
146 DESCRIPTION
147 Indicate the NME Connection Status when connecting or when disconnecting
148
149 VALUES
150 CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED
151 - NME is disconnected.
152 CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING
153 - NME is in the process of connecting.
154 CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING
155 - NME is in the authentication stage of a connection attempt.
156 CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED
157 - NME is connected.
158 CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING
159 - NME is in the process of disconnecting.
160
161*******************************************************************************/
162typedef u8 CsrWifiNmeConnectionStatus;
163#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED ((CsrWifiNmeConnectionStatus) 0x00)
164#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING ((CsrWifiNmeConnectionStatus) 0x01)
165#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING ((CsrWifiNmeConnectionStatus) 0x02)
166#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED ((CsrWifiNmeConnectionStatus) 0x03)
167#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING ((CsrWifiNmeConnectionStatus) 0x04)
168
169/*******************************************************************************
170
171 NAME
172 CsrWifiNmeCredentialType
173
174 DESCRIPTION
175 NME Credential Types
176
177 VALUES
178 CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM
179 - Credential Type Open System.
180 CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64
181 - Credential Type WEP-64
182 CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128
183 - Credential Type WEP-128
184 CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK
185 - Credential Type WPA Pre-Shared Key
186 CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE
187 - Credential Type WPA pass phrase
188 CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK
189 - Credential Type WPA2 Pre-Shared Key.
190 CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE
191 - Credential Type WPA2 pass phrase
192 CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK
193 - Credential Type WAPI Pre-Shared Key.
194 CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE
195 - Credential Type WAPI pass phrase
196 CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI
197 - Credential Type WAPI certificates
198 CSR_WIFI_NME_CREDENTIAL_TYPE_8021X
199 - Credential Type 802.1X: the associated type supports
200 FAST/LEAP/TLS/TTLS/PEAP/etc.
201
202*******************************************************************************/
203typedef u16 CsrWifiNmeCredentialType;
204#define CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM ((CsrWifiNmeCredentialType) 0x0000)
205#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64 ((CsrWifiNmeCredentialType) 0x0001)
206#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128 ((CsrWifiNmeCredentialType) 0x0002)
207#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK ((CsrWifiNmeCredentialType) 0x0003)
208#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0004)
209#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK ((CsrWifiNmeCredentialType) 0x0005)
210#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0006)
211#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK ((CsrWifiNmeCredentialType) 0x0007)
212#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0008)
213#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI ((CsrWifiNmeCredentialType) 0x0009)
214#define CSR_WIFI_NME_CREDENTIAL_TYPE_8021X ((CsrWifiNmeCredentialType) 0x000A)
215
216/*******************************************************************************
217
218 NAME
219 CsrWifiNmeEapMethod
220
221 DESCRIPTION
222 Outer EAP method with possibly inner method.
223
224 VALUES
225 CSR_WIFI_NME_EAP_METHOD_TLS
226 - EAP-TLS Method.
227 CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2
228 - EAP-TTLS Method with MSCHAPV2.
229 CSR_WIFI_NME_EAP_METHOD_PEAP_GTC
230 - EAP-PEAP Method with GTC.
231 CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2
232 - EAP-PEAP Method with MSCHAPV2.
233 CSR_WIFI_NME_EAP_METHOD_SIM
234 - EAP-SIM Method.
235 CSR_WIFI_NME_EAP_METHOD_AKA
236 - EAP-AKA Method.
237 CSR_WIFI_NME_EAP_METHOD_FAST_GTC
238 - EAP-FAST Method with GTC.
239 CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2
240 - EAP-FAST Method with MSCHAPV2.
241 CSR_WIFI_NME_EAP_METHOD_LEAP
242 - EAP-LEAP Method.
243
244*******************************************************************************/
245typedef u16 CsrWifiNmeEapMethod;
246#define CSR_WIFI_NME_EAP_METHOD_TLS ((CsrWifiNmeEapMethod) 0x0001)
247#define CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0002)
248#define CSR_WIFI_NME_EAP_METHOD_PEAP_GTC ((CsrWifiNmeEapMethod) 0x0004)
249#define CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0008)
250#define CSR_WIFI_NME_EAP_METHOD_SIM ((CsrWifiNmeEapMethod) 0x0010)
251#define CSR_WIFI_NME_EAP_METHOD_AKA ((CsrWifiNmeEapMethod) 0x0020)
252#define CSR_WIFI_NME_EAP_METHOD_FAST_GTC ((CsrWifiNmeEapMethod) 0x0040)
253#define CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0080)
254#define CSR_WIFI_NME_EAP_METHOD_LEAP ((CsrWifiNmeEapMethod) 0x0100)
255
256/*******************************************************************************
257
258 NAME
259 CsrWifiNmeEncryption
260
261 DESCRIPTION
262 WiFi Encryption method
263
264 VALUES
265 CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE
266 - No encryprion set.
267 CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
268 - 40 bytes WEP key for peer to peer communication.
269 CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
270 - 104 bytes WEP key for peer to peer communication.
271 CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
272 - TKIP key for peer to peer communication.
273 CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
274 - CCMP key for peer to peer communication.
275 CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
276 - SMS4 key for peer to peer communication.
277 CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40
278 - 40 bytes WEP key for broadcast messages.
279 CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104
280 - 104 bytes WEP key for broadcast messages.
281 CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP
282 - TKIP key for broadcast messages.
283 CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP
284 - CCMP key for broadcast messages
285 CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4
286 - SMS4 key for broadcast messages.
287
288*******************************************************************************/
289typedef u16 CsrWifiNmeEncryption;
290#define CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE ((CsrWifiNmeEncryption) 0x0000)
291#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 ((CsrWifiNmeEncryption) 0x0001)
292#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 ((CsrWifiNmeEncryption) 0x0002)
293#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP ((CsrWifiNmeEncryption) 0x0004)
294#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP ((CsrWifiNmeEncryption) 0x0008)
295#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 ((CsrWifiNmeEncryption) 0x0010)
296#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40 ((CsrWifiNmeEncryption) 0x0020)
297#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104 ((CsrWifiNmeEncryption) 0x0040)
298#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP ((CsrWifiNmeEncryption) 0x0080)
299#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP ((CsrWifiNmeEncryption) 0x0100)
300#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4 ((CsrWifiNmeEncryption) 0x0200)
301
302/*******************************************************************************
303
304 NAME
305 CsrWifiNmeIndications
306
307 DESCRIPTION
308 NME indications
309
310 VALUES
311 CSR_WIFI_NME_INDICATIONS_IND_AP_STATION
312 - NME AP Station Indication.
313 CSR_WIFI_NME_INDICATIONS_IND_AP_STOP
314 - NME AP Stop Indication.
315 CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH
316 - NME UMTS Authentication Indication.
317 CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START
318 - NME P2P Group Start Indication.
319 CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS
320 - NME P2P Group Status Indication.
321 CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE
322 - NME P2P Group Role Indication.
323 CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT
324 - NME Profile Disconnect Indication.
325 CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE
326 - NME Profile Update Indication.
327 CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET
328 - NME GET IMSI Indication.
329 CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH
330 - NME GSM Authentication Indication.
331 CSR_WIFI_NME_INDICATIONS_ALL
332 - Used to register for all available indications
333
334*******************************************************************************/
335typedef u32 CsrWifiNmeIndications;
336#define CSR_WIFI_NME_INDICATIONS_IND_AP_STATION ((CsrWifiNmeIndications) 0x00100000)
337#define CSR_WIFI_NME_INDICATIONS_IND_AP_STOP ((CsrWifiNmeIndications) 0x00200000)
338#define CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH ((CsrWifiNmeIndications) 0x01000000)
339#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START ((CsrWifiNmeIndications) 0x02000000)
340#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS ((CsrWifiNmeIndications) 0x04000000)
341#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE ((CsrWifiNmeIndications) 0x08000000)
342#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT ((CsrWifiNmeIndications) 0x10000000)
343#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE ((CsrWifiNmeIndications) 0x20000000)
344#define CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET ((CsrWifiNmeIndications) 0x40000000)
345#define CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH ((CsrWifiNmeIndications) 0x80000000)
346#define CSR_WIFI_NME_INDICATIONS_ALL ((CsrWifiNmeIndications) 0xFFFFFFFF)
347
348/*******************************************************************************
349
350 NAME
351 CsrWifiNmeSecError
352
353 DESCRIPTION
354 NME Security Errors
355 place holder for the security library abort reason
356
357 VALUES
358 CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN
359 - Unknown Security Error.
360
361*******************************************************************************/
362typedef u8 CsrWifiNmeSecError;
363#define CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN ((CsrWifiNmeSecError) 0x00)
364
365/*******************************************************************************
366
367 NAME
368 CsrWifiNmeSimCardType
369
370 DESCRIPTION
371 (U)SIM Card (or UICC) types
372
373 VALUES
374 CSR_WIFI_NME_SIM_CARD_TYPE_2G - 2G SIM card, capable of performing GSM
375 authentication only.
376 CSR_WIFI_NME_SIM_CARD_TYPE_3G - UICC supporting USIM application, capable
377 of performing UMTS authentication only.
378 CSR_WIFI_NME_SIM_CARD_TYPE_2G3G - UICC supporting both USIM and SIM
379 applications, capable of performing both
380 UMTS and GSM authentications.
381
382*******************************************************************************/
383typedef u8 CsrWifiNmeSimCardType;
384#define CSR_WIFI_NME_SIM_CARD_TYPE_2G ((CsrWifiNmeSimCardType) 0x01)
385#define CSR_WIFI_NME_SIM_CARD_TYPE_3G ((CsrWifiNmeSimCardType) 0x02)
386#define CSR_WIFI_NME_SIM_CARD_TYPE_2G3G ((CsrWifiNmeSimCardType) 0x03)
387
388/*******************************************************************************
389
390 NAME
391 CsrWifiNmeUmtsAuthResult
392
393 DESCRIPTION
394 Only relevant for UMTS Authentication. It indicates if the UICC has
395 successfully authenticated the network or otherwise.
396
397 VALUES
398 CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS
399 - Successful outcome from USIM indicating that the card has
400 successfully authenticated the network.
401 CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL
402 - Unsuccessful outcome from USIM indicating that the card is
403 requesting the network to synchronise and re-try again. If
404 no further request is received an NME timer will expire and
405 the authentication is aborted.
406 CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT
407 - Unsuccessful outcome from USIM indicating that the card has
408 rejected the network and that the authentication is
409 aborted.
410
411*******************************************************************************/
412typedef u8 CsrWifiNmeUmtsAuthResult;
413#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS ((CsrWifiNmeUmtsAuthResult) 0x00)
414#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL ((CsrWifiNmeUmtsAuthResult) 0x01)
415#define CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT ((CsrWifiNmeUmtsAuthResult) 0x02)
416
417/*******************************************************************************
418
419 NAME
420 CsrWifiNmeWmmQosInfo
421
422 DESCRIPTION
423 Defines bits for the QoS Info octect as defined in the WMM specification.
424 The values of this type are used across the NME/SME/Router API's and they
425 must be kept consistent with the corresponding types in the .xml of the
426 other interfaces
427
428 VALUES
429 CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL
430 - WMM AP may deliver all buffered frames.
431 CSR_WIFI_NME_WMM_QOS_INFO_AC_VO
432 - To enable the triggering and delivery of QoS Voice.
433 CSR_WIFI_NME_WMM_QOS_INFO_AC_VI
434 - To enable the triggering and delivery of QoS Video.
435 CSR_WIFI_NME_WMM_QOS_INFO_AC_BK
436 - To enable the triggering and delivery of QoS Background.
437 CSR_WIFI_NME_WMM_QOS_INFO_AC_BE
438 - To enable the triggering and delivery of QoS Best Effort.
439 CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO
440 - WMM AP may deliver a maximum of 2 buffered frames per
441 Unscheduled Service Period (USP).
442 CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR
443 - WMM AP may deliver a maximum of 4 buffered frames per USP.
444 CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX
445 - WMM AP may deliver a maximum of 6 buffered frames per USP.
446
447*******************************************************************************/
448typedef u8 CsrWifiNmeWmmQosInfo;
449#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL ((CsrWifiNmeWmmQosInfo) 0x00)
450#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VO ((CsrWifiNmeWmmQosInfo) 0x01)
451#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VI ((CsrWifiNmeWmmQosInfo) 0x02)
452#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BK ((CsrWifiNmeWmmQosInfo) 0x04)
453#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BE ((CsrWifiNmeWmmQosInfo) 0x08)
454#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO ((CsrWifiNmeWmmQosInfo) 0x20)
455#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR ((CsrWifiNmeWmmQosInfo) 0x40)
456#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX ((CsrWifiNmeWmmQosInfo) 0x60)
457
458
459/*******************************************************************************
460
461 NAME
462 CsrWifiNmeEapMethodMask
463
464 DESCRIPTION
465 Mask type for use with the values defined by CsrWifiNmeEapMethod.
466
467*******************************************************************************/
468typedef u16 CsrWifiNmeEapMethodMask;
469/*******************************************************************************
470
471 NAME
472 CsrWifiNmeEncryptionMask
473
474 DESCRIPTION
475 Mask type for use with the values defined by CsrWifiNmeEncryption
476
477*******************************************************************************/
478typedef u16 CsrWifiNmeEncryptionMask;
479/*******************************************************************************
480
481 NAME
482 CsrWifiNmeIndicationsMask
483
484 DESCRIPTION
485 Mask type for use with the values defined by CsrWifiNmeIndications
486
487*******************************************************************************/
488typedef u32 CsrWifiNmeIndicationsMask;
489/*******************************************************************************
490
491 NAME
492 CsrWifiNmeNmeIndicationsMask
493
494 DESCRIPTION
495 Mask type for use with the values defined by CsrWifiNmeNmeIndications.
496 Used to overlap the unused portion of the unifi_IndicationsMask For NME
497 specific indications
498
499*******************************************************************************/
500typedef u32 CsrWifiNmeNmeIndicationsMask;
501/*******************************************************************************
502
503 NAME
504 CsrWifiNmeWmmQosInfoMask
505
506 DESCRIPTION
507 Mask type for use with the values defined by CsrWifiNmeWmmQosInfo
508
509*******************************************************************************/
510typedef u8 CsrWifiNmeWmmQosInfoMask;
511
512
513/*******************************************************************************
514
515 NAME
516 CsrWifiNmeEmpty
517
518 DESCRIPTION
519 Empty Structure to indicate that no credentials are available.
520
521 MEMBERS
522 empty - Only element of the empty structure (always set to 0).
523
524*******************************************************************************/
525typedef struct
526{
527 u8 empty;
528} CsrWifiNmeEmpty;
529
530/*******************************************************************************
531
532 NAME
533 CsrWifiNmePassphrase
534
535 DESCRIPTION
536 Structure holding the ASCII Pass Phrase data.
537
538 MEMBERS
539 encryptionMode - Encryption type as defined in CsrWifiSmeEncryption.
540 passphrase - Pass phrase ASCII value.
541
542*******************************************************************************/
543typedef struct
544{
545 u16 encryptionMode;
546 char *passphrase;
547} CsrWifiNmePassphrase;
548
549/*******************************************************************************
550
551 NAME
552 CsrWifiNmePsk
553
554 DESCRIPTION
555 Structure holding the Pre-Shared Key data.
556
557 MEMBERS
558 encryptionMode - Encryption type as defined in CsrWifiSmeEncryption.
559 psk - Pre-Shared Key value.
560
561*******************************************************************************/
562typedef struct
563{
564 u16 encryptionMode;
565 u8 psk[32];
566} CsrWifiNmePsk;
567
568/*******************************************************************************
569
570 NAME
571 CsrWifiNmeWapiCredentials
572
573 DESCRIPTION
574 Structure holding WAPI credentials data.
575
576 MEMBERS
577 certificateLength - Length in bytes of the following client certificate.
578 certificate - The actual client certificate data (if present).
579 DER/PEM format supported.
580 privateKeyLength - Length in bytes of the following private key.
581 privateKey - The actual private key. DER/PEM format.
582 caCertificateLength - Length in bytes of the following certificate authority
583 certificate.
584 caCertificate - The actual certificate authority certificate data. If
585 not supplied the received certificate authority
586 certificate is assumed to be validate, if present the
587 received certificate is validated against it. DER/PEM
588 format supported.
589
590*******************************************************************************/
591typedef struct
592{
593 u32 certificateLength;
594 u8 *certificate;
595 u16 privateKeyLength;
596 u8 *privateKey;
597 u32 caCertificateLength;
598 u8 *caCertificate;
599} CsrWifiNmeWapiCredentials;
600
601/*******************************************************************************
602
603 NAME
604 CsrWifiNmeConnectAttempt
605
606 DESCRIPTION
607 Structure holding Connection attempt data.
608
609 MEMBERS
610 bssid - Id of Basic Service Set connections attempt have been made
611 to.
612 status - Status returned to indicate the success or otherwise of the
613 connection attempt.
614 securityError - Security error status indicating the nature of the failure
615 to connect.
616
617*******************************************************************************/
618typedef struct
619{
620 CsrWifiMacAddress bssid;
621 CsrResult status;
622 CsrWifiNmeSecError securityError;
623} CsrWifiNmeConnectAttempt;
624
625/*******************************************************************************
626
627 NAME
628 CsrWifiNmeEapCredentials
629
630 DESCRIPTION
631 Supports the use of multiple EAP methods via a single structure. The
632 methods required are indicated by the value set in the eapMethodMask
633
634 MEMBERS
635 eapMethodMask
636 - Bit mask of supported EAP methods
637 Currently only supports the setting of one bit.
638 Required for all the EAP methods.
639 authMode
640 - Bit mask representing the authentication types that may be
641 supported by a suitable AP. An AP must support at least one
642 of the authentication types specified to be considered for
643 connection. Required for all EAP methods.
644 encryptionMode
645 - Bit mask representing the encryption types that may be
646 supported by a suitable AP. An AP must support a suitable
647 mix of the pairwise and group encryption types requested to
648 be considered for connection. Required for all EAP methods.
649 userName
650 - User name. Required for all EAP methods except: SIM or AKA.
651 userPassword
652 - User Password. Required for all EAP methods except: TLS,
653 SIM or AKA.
654 authServerUserIdentity
655 - Authentication server user Identity. Required for all EAP
656 methods except: TLS, SIM, AKA or FAST.
657 clientCertificateLength
658 - Length in bytes of the following client certificate (if
659 present). Only required for TLS.
660 clientCertificate
661 - The actual client certificate data (if present). Only
662 required for TLS. DER/PEM format supported.
663 certificateAuthorityCertificateLength
664 - Length in bytes of the following certificate authority
665 certificate (if present). Optional for TLS, TTLS, PEAP.
666 certificateAuthorityCertificate
667 - The actual certificate authority certificate data (if
668 present). If not supplied the received certificate
669 authority certificate is assumed to be valid, if present
670 the received certificate is validated against it. Optional
671 for TLS, TTLS, PEAP. DER/PEM format supported.
672 privateKeyLength
673 - Length in bytes of the following private key (if present).
674 Only required for TLS.
675 privateKey
676 - The actual private key (if present). Only required for TLS.
677 DER/PEM format, maybe password protected.
678 privateKeyPassword
679 - Optional password to protect the private key.
680 sessionLength
681 - Length in bytes of the following session field Supported
682 for all EAP methods except: SIM or AKA.
683 session
684 - Session information to support faster re-authentication.
685 Supported for all EAP methods except: SIM or AKA.
686 allowPacProvisioning
687 - If TRUE: PAC provisioning is allowed 'over-the_air';
688 If FALSE: a PAC must be supplied.
689 Only required for FAST.
690 pacLength
691 - Length the following PAC field. If allowPacProvisioning is
692 FALSE then the PAC MUST be supplied (i.e. non-zero). Only
693 required for FAST.
694 pac
695 - The actual PAC data. If allowPacProvisioning is FALSE then
696 the PAC MUST be supplied. Only required for FAST.
697 pacPassword
698 - Optional password to protect the PAC. Only required for
699 FAST.
700
701*******************************************************************************/
702typedef struct
703{
704 CsrWifiNmeEapMethodMask eapMethodMask;
705 CsrWifiSmeAuthModeMask authMode;
706 CsrWifiNmeEncryptionMask encryptionMode;
707 char *userName;
708 char *userPassword;
709 char *authServerUserIdentity;
710 u32 clientCertificateLength;
711 u8 *clientCertificate;
712 u32 certificateAuthorityCertificateLength;
713 u8 *certificateAuthorityCertificate;
714 u16 privateKeyLength;
715 u8 *privateKey;
716 char *privateKeyPassword;
717 u32 sessionLength;
718 u8 *session;
719 u8 allowPacProvisioning;
720 u32 pacLength;
721 u8 *pac;
722 char *pacPassword;
723} CsrWifiNmeEapCredentials;
724
725/*******************************************************************************
726
727 NAME
728 CsrWifiNmePeerConfig
729
730 DESCRIPTION
731 Structure holding Peer Config data.
732
733 MEMBERS
734 p2pDeviceId -
735 groupCapabilityMask -
736 groupOwnerIntent -
737
738*******************************************************************************/
739typedef struct
740{
741 CsrWifiMacAddress p2pDeviceId;
742 CsrWifiSmeP2pGroupCapabilityMask groupCapabilityMask;
743 u8 groupOwnerIntent;
744} CsrWifiNmePeerConfig;
745
746/*******************************************************************************
747
748 NAME
749 CsrWifiNmeProfileIdentity
750
751 DESCRIPTION
752 The identity of a profile is defined as the unique combination the BSSID
753 and SSID.
754
755 MEMBERS
756 bssid - ID of Basic Service Set for or the P2pDevice address of the GO for
757 which a connection attempt was made.
758 ssid - Service Set Id.
759
760*******************************************************************************/
761typedef struct
762{
763 CsrWifiMacAddress bssid;
764 CsrWifiSsid ssid;
765} CsrWifiNmeProfileIdentity;
766
767/*******************************************************************************
768
769 NAME
770 CsrWifiNmeWep128Keys
771
772 DESCRIPTION
773 Structure holding WEP Authentication Type and WEP keys that can be used
774 when using WEP128.
775
776 MEMBERS
777 wepAuthType - Mask to select the WEP authentication type (Open or Shared)
778 selectedWepKey - Index to one of the four keys below indicating the
779 currently used WEP key.
780 key1 - Value for key number 1.
781 key2 - Value for key number 2.
782 key3 - Value for key number 3.
783 key4 - Value for key number 4.
784
785*******************************************************************************/
786typedef struct
787{
788 CsrWifiSmeAuthModeMask wepAuthType;
789 u8 selectedWepKey;
790 u8 key1[13];
791 u8 key2[13];
792 u8 key3[13];
793 u8 key4[13];
794} CsrWifiNmeWep128Keys;
795
796/*******************************************************************************
797
798 NAME
799 CsrWifiNmeWep64Keys
800
801 DESCRIPTION
802 Structure for holding WEP Authentication Type and WEP keys that can be
803 used when using WEP64.
804
805 MEMBERS
806 wepAuthType - Mask to select the WEP authentication type (Open or Shared)
807 selectedWepKey - Index to one of the four keys below indicating the
808 currently used WEP key.
809 key1 - Value for key number 1.
810 key2 - Value for key number 2.
811 key3 - Value for key number 3.
812 key4 - Value for key number 4.
813
814*******************************************************************************/
815typedef struct
816{
817 CsrWifiSmeAuthModeMask wepAuthType;
818 u8 selectedWepKey;
819 u8 key1[5];
820 u8 key2[5];
821 u8 key3[5];
822 u8 key4[5];
823} CsrWifiNmeWep64Keys;
824
825/*******************************************************************************
826
827 NAME
828 CsrWifiNmeCredentials
829
830 DESCRIPTION
831 Structure containing the Credentials data.
832
833 MEMBERS
834 credentialType - Credential type value (as defined in the
835 enumeration type).
836 credential - Union containing credentials which depends on
837 credentialType parameter.
838 credentialeap -
839 credentialwapiPassphrase -
840 credentialwpa2Passphrase -
841 credentialwpa2Psk -
842 credentialwapiPsk -
843 credentialwpaPassphrase -
844 credentialwapi -
845 credentialwep128Key -
846 credentialwpaPsk -
847 credentialopenSystem -
848 credentialwep64Key -
849
850*******************************************************************************/
851typedef struct
852{
853 CsrWifiNmeCredentialType credentialType;
854 union {
855 CsrWifiNmeEapCredentials eap;
856 CsrWifiNmePassphrase wapiPassphrase;
857 CsrWifiNmePassphrase wpa2Passphrase;
858 CsrWifiNmePsk wpa2Psk;
859 CsrWifiNmePsk wapiPsk;
860 CsrWifiNmePassphrase wpaPassphrase;
861 CsrWifiNmeWapiCredentials wapi;
862 CsrWifiNmeWep128Keys wep128Key;
863 CsrWifiNmePsk wpaPsk;
864 CsrWifiNmeEmpty openSystem;
865 CsrWifiNmeWep64Keys wep64Key;
866 } credential;
867} CsrWifiNmeCredentials;
868
869/*******************************************************************************
870
871 NAME
872 CsrWifiNmeProfile
873
874 DESCRIPTION
875 Structure containing the Profile data.
876
877 MEMBERS
878 profileIdentity - Profile Identity.
879 wmmQosInfoMask - Mask for WMM QoS information.
880 bssType - Type of BSS (Infrastructure or Adhoc).
881 channelNo - Channel Number.
882 ccxOptionsMask - Options mask for Cisco Compatible Extentions.
883 cloakedSsid - Flag to decide whether the SSID is cloaked (not
884 transmitted) or not.
885 credentials - Credentials data.
886
887*******************************************************************************/
888typedef struct
889{
890 CsrWifiNmeProfileIdentity profileIdentity;
891 CsrWifiNmeWmmQosInfoMask wmmQosInfoMask;
892 CsrWifiNmeBssType bssType;
893 u8 channelNo;
894 u8 ccxOptionsMask;
895 u8 cloakedSsid;
896 CsrWifiNmeCredentials credentials;
897} CsrWifiNmeProfile;
898
899
900/* Downstream */
901#define CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST (0x0000)
902
903#define CSR_WIFI_NME_PROFILE_SET_REQ ((CsrWifiNmePrim) (0x0000 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
904#define CSR_WIFI_NME_PROFILE_DELETE_REQ ((CsrWifiNmePrim) (0x0001 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
905#define CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ ((CsrWifiNmePrim) (0x0002 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
906#define CSR_WIFI_NME_PROFILE_ORDER_SET_REQ ((CsrWifiNmePrim) (0x0003 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
907#define CSR_WIFI_NME_PROFILE_CONNECT_REQ ((CsrWifiNmePrim) (0x0004 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
908#define CSR_WIFI_NME_WPS_REQ ((CsrWifiNmePrim) (0x0005 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
909#define CSR_WIFI_NME_WPS_CANCEL_REQ ((CsrWifiNmePrim) (0x0006 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
910#define CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ ((CsrWifiNmePrim) (0x0007 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
911#define CSR_WIFI_NME_SIM_IMSI_GET_RES ((CsrWifiNmePrim) (0x0008 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
912#define CSR_WIFI_NME_SIM_GSM_AUTH_RES ((CsrWifiNmePrim) (0x0009 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
913#define CSR_WIFI_NME_SIM_UMTS_AUTH_RES ((CsrWifiNmePrim) (0x000A + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
914#define CSR_WIFI_NME_WPS_CONFIG_SET_REQ ((CsrWifiNmePrim) (0x000B + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
915#define CSR_WIFI_NME_EVENT_MASK_SET_REQ ((CsrWifiNmePrim) (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
916
917
918#define CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)
919
920/* Upstream */
921#define CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
922
923#define CSR_WIFI_NME_PROFILE_SET_CFM ((CsrWifiNmePrim)(0x0000 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
924#define CSR_WIFI_NME_PROFILE_DELETE_CFM ((CsrWifiNmePrim)(0x0001 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
925#define CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM ((CsrWifiNmePrim)(0x0002 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
926#define CSR_WIFI_NME_PROFILE_ORDER_SET_CFM ((CsrWifiNmePrim)(0x0003 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
927#define CSR_WIFI_NME_PROFILE_CONNECT_CFM ((CsrWifiNmePrim)(0x0004 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
928#define CSR_WIFI_NME_WPS_CFM ((CsrWifiNmePrim)(0x0005 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
929#define CSR_WIFI_NME_WPS_CANCEL_CFM ((CsrWifiNmePrim)(0x0006 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
930#define CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM ((CsrWifiNmePrim)(0x0007 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
931#define CSR_WIFI_NME_PROFILE_UPDATE_IND ((CsrWifiNmePrim)(0x0008 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
932#define CSR_WIFI_NME_PROFILE_DISCONNECT_IND ((CsrWifiNmePrim)(0x0009 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
933#define CSR_WIFI_NME_SIM_IMSI_GET_IND ((CsrWifiNmePrim)(0x000A + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
934#define CSR_WIFI_NME_SIM_GSM_AUTH_IND ((CsrWifiNmePrim)(0x000B + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
935#define CSR_WIFI_NME_SIM_UMTS_AUTH_IND ((CsrWifiNmePrim)(0x000C + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
936#define CSR_WIFI_NME_WPS_CONFIG_SET_CFM ((CsrWifiNmePrim)(0x000D + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
937#define CSR_WIFI_NME_EVENT_MASK_SET_CFM ((CsrWifiNmePrim)(0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
938
939#define CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST (0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)
940
941#define CSR_WIFI_NME_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)
942#define CSR_WIFI_NME_PRIM_UPSTREAM_COUNT (CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)
943
944/*******************************************************************************
945
946 NAME
947 CsrWifiNmeProfileSetReq
948
949 DESCRIPTION
950 Creates or updates an existing profile in the NME that matches the unique
951 identity of the profile. Each profile is identified by the combination of
952 BSSID and SSID. The profile contains all the required credentials for
953 attempting to connect to the network. Creating or updating a profile via
954 the NME PROFILE SET REQ does NOT add the profile to the preferred profile
955 list within the NME used for the NME auto-connect behaviour.
956
957 MEMBERS
958 common - Common header for use with the CsrWifiFsm Module
959 profile - Specifies the identity and credentials of the network.
960
961*******************************************************************************/
962typedef struct
963{
964 CsrWifiFsmEvent common;
965 CsrWifiNmeProfile profile;
966} CsrWifiNmeProfileSetReq;
967
968/*******************************************************************************
969
970 NAME
971 CsrWifiNmeProfileDeleteReq
972
973 DESCRIPTION
974 Will delete the profile with a matching identity, but does NOT modify the
975 preferred profile list.
976
977 MEMBERS
978 common - Common header for use with the CsrWifiFsm Module
979 profileIdentity - Identity (BSSID, SSID) of profile to be deleted.
980
981*******************************************************************************/
982typedef struct
983{
984 CsrWifiFsmEvent common;
985 CsrWifiNmeProfileIdentity profileIdentity;
986} CsrWifiNmeProfileDeleteReq;
987
988/*******************************************************************************
989
990 NAME
991 CsrWifiNmeProfileDeleteAllReq
992
993 DESCRIPTION
994 Deletes all profiles present in the NME, but does NOT modify the
995 preferred profile list.
996
997 MEMBERS
998 common - Common header for use with the CsrWifiFsm Module
999
1000*******************************************************************************/
1001typedef struct
1002{
1003 CsrWifiFsmEvent common;
1004} CsrWifiNmeProfileDeleteAllReq;
1005
1006/*******************************************************************************
1007
1008 NAME
1009 CsrWifiNmeProfileOrderSetReq
1010
1011 DESCRIPTION
1012 Defines the preferred order that profiles present in the NME should be
1013 used during the NME auto-connect behaviour.
1014 If profileIdentitysCount == 0, it removes any existing preferred profile
1015 list already present in the NME, effectively disabling the auto-connect
1016 behaviour.
1017 NOTE: Profile identities that do not match any profile stored in the NME
1018 are ignored during the auto-connect procedure.
1019 NOTE: during auto-connect the NME will only attempt to join an existing
1020 adhoc network and it will never attempt to host an adhoc network; for
1021 hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ
1022
1023 MEMBERS
1024 common - Common header for use with the CsrWifiFsm Module
1025 interfaceTag - Interface Identifier; unique identifier of an
1026 interface
1027 profileIdentitysCount - The number of profiles identities in the list.
1028 profileIdentitys - Points to the list of profile identities.
1029
1030*******************************************************************************/
1031typedef struct
1032{
1033 CsrWifiFsmEvent common;
1034 u16 interfaceTag;
1035 u8 profileIdentitysCount;
1036 CsrWifiNmeProfileIdentity *profileIdentitys;
1037} CsrWifiNmeProfileOrderSetReq;
1038
1039/*******************************************************************************
1040
1041 NAME
1042 CsrWifiNmeProfileConnectReq
1043
1044 DESCRIPTION
1045 Requests the NME to attempt to connect to the specified profile.
1046 Overrides any current connection attempt.
1047
1048 MEMBERS
1049 common - Common header for use with the CsrWifiFsm Module
1050 interfaceTag - Interface Identifier; unique identifier of an interface
1051 profileIdentity - Identity (BSSID, SSID) of profile to be connected to.
1052 It must match an existing profile in the NME.
1053
1054*******************************************************************************/
1055typedef struct
1056{
1057 CsrWifiFsmEvent common;
1058 u16 interfaceTag;
1059 CsrWifiNmeProfileIdentity profileIdentity;
1060} CsrWifiNmeProfileConnectReq;
1061
1062/*******************************************************************************
1063
1064 NAME
1065 CsrWifiNmeWpsReq
1066
1067 DESCRIPTION
1068 Requests the NME to look for WPS enabled APs and attempt to perform WPS
1069 to determine the appropriate security credentials to connect to the AP.
1070 If the PIN == '00000000' then 'push button mode' is indicated, otherwise
1071 the PIN has to match that of the AP. 4 digit pin is passed by sending the
1072 pin digits in pin[0]..pin[3] and rest of the contents filled with '-'.
1073
1074 MEMBERS
1075 common - Common header for use with the CsrWifiFsm Module
1076 interfaceTag - Interface Identifier; unique identifier of an interface
1077 pin - PIN value.
1078 ssid - Service Set identifier
1079 bssid - ID of Basic Service Set for which a WPS connection attempt is
1080 being made.
1081
1082*******************************************************************************/
1083typedef struct
1084{
1085 CsrWifiFsmEvent common;
1086 u16 interfaceTag;
1087 u8 pin[8];
1088 CsrWifiSsid ssid;
1089 CsrWifiMacAddress bssid;
1090} CsrWifiNmeWpsReq;
1091
1092/*******************************************************************************
1093
1094 NAME
1095 CsrWifiNmeWpsCancelReq
1096
1097 DESCRIPTION
1098 Requests the NME to cancel any WPS procedure that it is currently
1099 performing. This includes WPS registrar activities started because of
1100 CSR_WIFI_NME_AP_REGISTER.request
1101
1102 MEMBERS
1103 common - Common header for use with the CsrWifiFsm Module
1104 interfaceTag - Interface Identifier; unique identifier of an interface
1105
1106*******************************************************************************/
1107typedef struct
1108{
1109 CsrWifiFsmEvent common;
1110 u16 interfaceTag;
1111} CsrWifiNmeWpsCancelReq;
1112
1113/*******************************************************************************
1114
1115 NAME
1116 CsrWifiNmeConnectionStatusGetReq
1117
1118 DESCRIPTION
1119 Requests the current connection status of the NME.
1120
1121 MEMBERS
1122 common - Common header for use with the CsrWifiFsm Module
1123 interfaceTag - Interface Identifier; unique identifier of an interface
1124
1125*******************************************************************************/
1126typedef struct
1127{
1128 CsrWifiFsmEvent common;
1129 u16 interfaceTag;
1130} CsrWifiNmeConnectionStatusGetReq;
1131
1132/*******************************************************************************
1133
1134 NAME
1135 CsrWifiNmeSimImsiGetRes
1136
1137 DESCRIPTION
1138 Response from the application that received the NME SIM IMSI GET IND.
1139
1140 MEMBERS
1141 common - Common header for use with the CsrWifiFsm Module
1142 status - Indicates the outcome of the requested operation: STATUS_SUCCESS
1143 or STATUS_ERROR.
1144 imsi - The value of the IMSI obtained from the UICC.
1145 cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both).
1146
1147*******************************************************************************/
1148typedef struct
1149{
1150 CsrWifiFsmEvent common;
1151 CsrResult status;
1152 char *imsi;
1153 CsrWifiNmeSimCardType cardType;
1154} CsrWifiNmeSimImsiGetRes;
1155
1156/*******************************************************************************
1157
1158 NAME
1159 CsrWifiNmeSimGsmAuthRes
1160
1161 DESCRIPTION
1162 Response from the application that received the NME SIM GSM AUTH IND. For
1163 each GSM authentication round a GSM Ciphering key (Kc) and a signed
1164 response (SRES) are produced. Since 2 or 3 GSM authentication rounds are
1165 used the 2 or 3 Kc's obtained respectively are combined into one buffer
1166 and similarly the 2 or 3 SRES's obtained are combined into another
1167 buffer. The order of Kc values (SRES values respectively) in their buffer
1168 is the same as that of their corresponding RAND values in the incoming
1169 indication.
1170
1171 MEMBERS
1172 common - Common header for use with the CsrWifiFsm Module
1173 status - Indicates the outcome of the requested operation:
1174 STATUS_SUCCESS or STATUS_ERROR
1175 kcsLength - Length in Bytes of Kc buffer. Legal values are: 16 or 24.
1176 kcs - Kc buffer holding 2 or 3 Kc values.
1177 sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12.
1178 sres - SRES buffer holding 2 or 3 SRES values.
1179
1180*******************************************************************************/
1181typedef struct
1182{
1183 CsrWifiFsmEvent common;
1184 CsrResult status;
1185 u8 kcsLength;
1186 u8 *kcs;
1187 u8 sresLength;
1188 u8 *sres;
1189} CsrWifiNmeSimGsmAuthRes;
1190
1191/*******************************************************************************
1192
1193 NAME
1194 CsrWifiNmeSimUmtsAuthRes
1195
1196 DESCRIPTION
1197 Response from the application that received the NME SIM UMTS AUTH IND.
1198 The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and
1199 resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS.
1200 The value of auts is only meaningful when
1201 result=UMTS_AUTH_RESULT_SYNC_FAIL.
1202
1203 MEMBERS
1204 common - Common header for use with the CsrWifiFsm Module
1205 status - Indicates the outcome of the requested operation:
1206 STATUS_SUCCESS or STATUS_ERROR.
1207 result - The result of UMTS authentication as performed by the
1208 UICC which could be: Success, Authentication Reject or
1209 Synchronisation Failure. For all these 3 outcomes the
1210 value of status is success.
1211 umtsCipherKey - The UMTS Cipher Key as calculated and returned by the
1212 UICC.
1213 umtsIntegrityKey - The UMTS Integrity Key as calculated and returned by
1214 the UICC.
1215 resParameterLength - The length (in bytes) of the RES parameter (min=4; max
1216 = 16).
1217 resParameter - The RES parameter as calculated and returned by the
1218 UICC.
1219 auts - The AUTS parameter as calculated and returned by the
1220 UICC.
1221
1222*******************************************************************************/
1223typedef struct
1224{
1225 CsrWifiFsmEvent common;
1226 CsrResult status;
1227 CsrWifiNmeUmtsAuthResult result;
1228 u8 umtsCipherKey[16];
1229 u8 umtsIntegrityKey[16];
1230 u8 resParameterLength;
1231 u8 *resParameter;
1232 u8 auts[14];
1233} CsrWifiNmeSimUmtsAuthRes;
1234
1235/*******************************************************************************
1236
1237 NAME
1238 CsrWifiNmeWpsConfigSetReq
1239
1240 DESCRIPTION
1241 This primitive passes the WPS information for the device to NME. This may
1242 be accepted only if no interface is active.
1243
1244 MEMBERS
1245 common - Common header for use with the CsrWifiFsm Module
1246 wpsConfig - WPS config.
1247
1248*******************************************************************************/
1249typedef struct
1250{
1251 CsrWifiFsmEvent common;
1252 CsrWifiSmeWpsConfig wpsConfig;
1253} CsrWifiNmeWpsConfigSetReq;
1254
1255/*******************************************************************************
1256
1257 NAME
1258 CsrWifiNmeEventMaskSetReq
1259
1260 DESCRIPTION
1261 The wireless manager application may register with the NME to receive
1262 notification of interesting events. Indications will be sent only if the
1263 wireless manager explicitly registers to be notified of that event.
1264 indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask.
1265
1266 MEMBERS
1267 common - Common header for use with the CsrWifiFsm Module
1268 indMask - Set mask with values from CsrWifiNmeIndications
1269
1270*******************************************************************************/
1271typedef struct
1272{
1273 CsrWifiFsmEvent common;
1274 CsrWifiNmeIndicationsMask indMask;
1275} CsrWifiNmeEventMaskSetReq;
1276
1277/*******************************************************************************
1278
1279 NAME
1280 CsrWifiNmeProfileSetCfm
1281
1282 DESCRIPTION
1283 Reports the status of the NME PROFILE SET REQ; the request will only fail
1284 if the details specified in the profile contains an invalid combination
1285 of parameters for example specifying the profile as cloaked but not
1286 specifying the SSID. The NME doesn't limit the number of profiles that
1287 may be created. The NME assumes that the entity configuring it is aware
1288 of the appropriate limits.
1289
1290 MEMBERS
1291 common - Common header for use with the CsrWifiFsm Module
1292 status - Indicates the success or otherwise of the requested operation.
1293
1294*******************************************************************************/
1295typedef struct
1296{
1297 CsrWifiFsmEvent common;
1298 CsrResult status;
1299} CsrWifiNmeProfileSetCfm;
1300
1301/*******************************************************************************
1302
1303 NAME
1304 CsrWifiNmeProfileDeleteCfm
1305
1306 DESCRIPTION
1307 Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ.
1308 Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile.
1309
1310 MEMBERS
1311 common - Common header for use with the CsrWifiFsm Module
1312 status - Indicates the success or otherwise of the requested operation.
1313
1314*******************************************************************************/
1315typedef struct
1316{
1317 CsrWifiFsmEvent common;
1318 CsrResult status;
1319} CsrWifiNmeProfileDeleteCfm;
1320
1321/*******************************************************************************
1322
1323 NAME
1324 CsrWifiNmeProfileDeleteAllCfm
1325
1326 DESCRIPTION
1327 Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ.
1328 Returns always CSR_WIFI_NME_STATUS_SUCCESS.
1329
1330 MEMBERS
1331 common - Common header for use with the CsrWifiFsm Module
1332 status - Indicates the success or otherwise of the requested operation, but
1333 in this case it always set to success.
1334
1335*******************************************************************************/
1336typedef struct
1337{
1338 CsrWifiFsmEvent common;
1339 CsrResult status;
1340} CsrWifiNmeProfileDeleteAllCfm;
1341
1342/*******************************************************************************
1343
1344 NAME
1345 CsrWifiNmeProfileOrderSetCfm
1346
1347 DESCRIPTION
1348 Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request.
1349
1350 MEMBERS
1351 common - Common header for use with the CsrWifiFsm Module
1352 interfaceTag - Interface Identifier; unique identifier of an interface
1353 status - Indicates the success or otherwise of the requested
1354 operation.
1355
1356*******************************************************************************/
1357typedef struct
1358{
1359 CsrWifiFsmEvent common;
1360 u16 interfaceTag;
1361 CsrResult status;
1362} CsrWifiNmeProfileOrderSetCfm;
1363
1364/*******************************************************************************
1365
1366 NAME
1367 CsrWifiNmeProfileConnectCfm
1368
1369 DESCRIPTION
1370 Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the
1371 connectAttempt parameters contain details of the APs that the NME
1372 attempted to connect to before reporting the failure of the request.
1373
1374 MEMBERS
1375 common - Common header for use with the CsrWifiFsm Module
1376 interfaceTag - Interface Identifier; unique identifier of an
1377 interface
1378 status - Indicates the success or otherwise of the requested
1379 operation.
1380 connectAttemptsCount - This parameter is relevant only if
1381 status!=CSR_WIFI_NME_STATUS_SUCCESS.
1382 Number of connection attempt elements provided with
1383 this primitive
1384 connectAttempts - This parameter is relevant only if
1385 status!=CSR_WIFI_NME_STATUS_SUCCESS.
1386 Points to the list of connection attempt elements
1387 provided with this primitive
1388 Each element of the list provides information about
1389 an AP on which the connection attempt was made and
1390 the error that occurred during the attempt.
1391
1392*******************************************************************************/
1393typedef struct
1394{
1395 CsrWifiFsmEvent common;
1396 u16 interfaceTag;
1397 CsrResult status;
1398 u8 connectAttemptsCount;
1399 CsrWifiNmeConnectAttempt *connectAttempts;
1400} CsrWifiNmeProfileConnectCfm;
1401
1402/*******************************************************************************
1403
1404 NAME
1405 CsrWifiNmeWpsCfm
1406
1407 DESCRIPTION
1408 Reports the status of the NME WPS REQ.
1409 If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the
1410 identity and credentials of the AP.
1411
1412 MEMBERS
1413 common - Common header for use with the CsrWifiFsm Module
1414 interfaceTag - Interface Identifier; unique identifier of an interface
1415 status - Indicates the success or otherwise of the requested
1416 operation.
1417 profile - This parameter is relevant only if
1418 status==CSR_WIFI_NME_STATUS_SUCCESS.
1419 The identity and credentials of the network.
1420
1421*******************************************************************************/
1422typedef struct
1423{
1424 CsrWifiFsmEvent common;
1425 u16 interfaceTag;
1426 CsrResult status;
1427 CsrWifiNmeProfile profile;
1428} CsrWifiNmeWpsCfm;
1429
1430/*******************************************************************************
1431
1432 NAME
1433 CsrWifiNmeWpsCancelCfm
1434
1435 DESCRIPTION
1436 Reports the status of the NME WPS REQ, the request is always SUCCESSFUL.
1437
1438 MEMBERS
1439 common - Common header for use with the CsrWifiFsm Module
1440 interfaceTag - Interface Identifier; unique identifier of an interface
1441 status - Only returns CSR_WIFI_NME_STATUS_SUCCESS
1442
1443*******************************************************************************/
1444typedef struct
1445{
1446 CsrWifiFsmEvent common;
1447 u16 interfaceTag;
1448 CsrResult status;
1449} CsrWifiNmeWpsCancelCfm;
1450
1451/*******************************************************************************
1452
1453 NAME
1454 CsrWifiNmeConnectionStatusGetCfm
1455
1456 DESCRIPTION
1457 Reports the connection status of the NME.
1458
1459 MEMBERS
1460 common - Common header for use with the CsrWifiFsm Module
1461 interfaceTag - Interface Identifier; unique identifier of an interface
1462 status - Indicates the success or otherwise of the requested
1463 operation.
1464 connectionStatus - NME current connection status
1465
1466*******************************************************************************/
1467typedef struct
1468{
1469 CsrWifiFsmEvent common;
1470 u16 interfaceTag;
1471 CsrResult status;
1472 CsrWifiNmeConnectionStatus connectionStatus;
1473} CsrWifiNmeConnectionStatusGetCfm;
1474
1475/*******************************************************************************
1476
1477 NAME
1478 CsrWifiNmeProfileUpdateInd
1479
1480 DESCRIPTION
1481 Indication generated from the NME (if an application subscribes to
1482 receive it) that informs that application that the contained profile has
1483 changed.
1484 For example, either the credentials EAP-FAST PAC file or the session data
1485 within the profile has changed.
1486 It is up to the application whether it stores this updated profile or
1487 not.
1488
1489 MEMBERS
1490 common - Common header for use with the CsrWifiFsm Module
1491 interfaceTag - Interface Identifier; unique identifier of an interface
1492 profile - The identity and credentials of the network.
1493
1494*******************************************************************************/
1495typedef struct
1496{
1497 CsrWifiFsmEvent common;
1498 u16 interfaceTag;
1499 CsrWifiNmeProfile profile;
1500} CsrWifiNmeProfileUpdateInd;
1501
1502/*******************************************************************************
1503
1504 NAME
1505 CsrWifiNmeProfileDisconnectInd
1506
1507 DESCRIPTION
1508 Indication generated from the NME (if an application subscribes to
1509 receive it) that informs that application that the current profile
1510 connection has disconnected. The indication will contain information
1511 about APs that it attempted to maintain the connection via i.e. in the
1512 case of failed roaming.
1513
1514 MEMBERS
1515 common - Common header for use with the CsrWifiFsm Module
1516 interfaceTag - Interface Identifier; unique identifier of an
1517 interface
1518 connectAttemptsCount - Number of connection attempt elements provided with
1519 this primitive
1520 connectAttempts - Points to the list of connection attempt elements
1521 provided with this primitive
1522 Each element of the list provides information about
1523 an AP on which the connection attempt was made and
1524 the error occurred during the attempt.
1525
1526*******************************************************************************/
1527typedef struct
1528{
1529 CsrWifiFsmEvent common;
1530 u16 interfaceTag;
1531 u8 connectAttemptsCount;
1532 CsrWifiNmeConnectAttempt *connectAttempts;
1533} CsrWifiNmeProfileDisconnectInd;
1534
1535/*******************************************************************************
1536
1537 NAME
1538 CsrWifiNmeSimImsiGetInd
1539
1540 DESCRIPTION
1541 Indication generated from the NME (if an application subscribes to
1542 receive it) that requests the IMSI and UICC type from the UICC Manager.
1543 This indication is generated when the NME is attempting to connect to a
1544 profile configured for EAP-SIM/AKA. An application MUST register to
1545 receive this indication for the NME to support the EAP-SIM/AKA credential
1546 types. Otherwise the NME has no route to obtain the information from the
1547 UICC.
1548
1549 MEMBERS
1550 common - Common header for use with the CsrWifiFsm Module
1551
1552*******************************************************************************/
1553typedef struct
1554{
1555 CsrWifiFsmEvent common;
1556} CsrWifiNmeSimImsiGetInd;
1557
1558/*******************************************************************************
1559
1560 NAME
1561 CsrWifiNmeSimGsmAuthInd
1562
1563 DESCRIPTION
1564 Indication generated from the NME (if an application subscribes to
1565 receive it) that requests the UICC Manager to perform a GSM
1566 authentication on behalf of the NME. This indication is generated when
1567 the NME is attempting to connect to a profile configured for EAP-SIM. An
1568 application MUST register to receive this indication for the NME to
1569 support the EAP-SIM credential types. Otherwise the NME has no route to
1570 obtain the information from the UICC. EAP-SIM authentication requires 2
1571 or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random
1572 Challenges) are included.
1573
1574 MEMBERS
1575 common - Common header for use with the CsrWifiFsm Module
1576 randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS)
1577 or 48 (3 RANDs).
1578 rands - 2 or 3 RANDs values.
1579
1580*******************************************************************************/
1581typedef struct
1582{
1583 CsrWifiFsmEvent common;
1584 u8 randsLength;
1585 u8 *rands;
1586} CsrWifiNmeSimGsmAuthInd;
1587
1588/*******************************************************************************
1589
1590 NAME
1591 CsrWifiNmeSimUmtsAuthInd
1592
1593 DESCRIPTION
1594 Indication generated from the NME (if an application subscribes to
1595 receive it) that requests the UICC Manager to perform a UMTS
1596 authentication on behalf of the NME. This indication is generated when
1597 the NME is attempting to connect to a profile configured for EAP-AKA. An
1598 application MUST register to receive this indication for the NME to
1599 support the EAP-AKA credential types. Otherwise the NME has no route to
1600 obtain the information from the USIM. EAP-AKA requires one UMTS
1601 authentication round and therefore only one RAND and one AUTN values are
1602 included.
1603
1604 MEMBERS
1605 common - Common header for use with the CsrWifiFsm Module
1606 rand - UMTS RAND value.
1607 autn - UMTS AUTN value.
1608
1609*******************************************************************************/
1610typedef struct
1611{
1612 CsrWifiFsmEvent common;
1613 u8 rand[16];
1614 u8 autn[16];
1615} CsrWifiNmeSimUmtsAuthInd;
1616
1617/*******************************************************************************
1618
1619 NAME
1620 CsrWifiNmeWpsConfigSetCfm
1621
1622 DESCRIPTION
1623 Confirm.
1624
1625 MEMBERS
1626 common - Common header for use with the CsrWifiFsm Module
1627 status - Status of the request.
1628
1629*******************************************************************************/
1630typedef struct
1631{
1632 CsrWifiFsmEvent common;
1633 CsrResult status;
1634} CsrWifiNmeWpsConfigSetCfm;
1635
1636/*******************************************************************************
1637
1638 NAME
1639 CsrWifiNmeEventMaskSetCfm
1640
1641 DESCRIPTION
1642 The NME calls the primitive to report the result of the request
1643 primitive.
1644
1645 MEMBERS
1646 common - Common header for use with the CsrWifiFsm Module
1647 status - Reports the result of the request
1648
1649*******************************************************************************/
1650typedef struct
1651{
1652 CsrWifiFsmEvent common;
1653 CsrResult status;
1654} CsrWifiNmeEventMaskSetCfm;
1655
1656#endif /* CSR_WIFI_NME_PRIM_H__ */
1657
diff --git a/drivers/staging/csr/csr_wifi_nme_serialize.h b/drivers/staging/csr/csr_wifi_nme_serialize.h
deleted file mode 100644
index ebac484419cf..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_serialize.h
+++ /dev/null
@@ -1,166 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_SERIALIZE_H__
14#define CSR_WIFI_NME_SERIALIZE_H__
15
16#include "csr_wifi_msgconv.h"
17#include "csr_wifi_nme_prim.h"
18
19#ifndef CSR_WIFI_NME_ENABLE
20#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_serialize.h
21#endif
22
23extern void CsrWifiNmePfree(void *ptr);
24
25extern u8* CsrWifiNmeProfileSetReqSer(u8 *ptr, size_t *len, void *msg);
26extern void* CsrWifiNmeProfileSetReqDes(u8 *buffer, size_t len);
27extern size_t CsrWifiNmeProfileSetReqSizeof(void *msg);
28extern void CsrWifiNmeProfileSetReqSerFree(void *msg);
29
30extern u8* CsrWifiNmeProfileDeleteReqSer(u8 *ptr, size_t *len, void *msg);
31extern void* CsrWifiNmeProfileDeleteReqDes(u8 *buffer, size_t len);
32extern size_t CsrWifiNmeProfileDeleteReqSizeof(void *msg);
33#define CsrWifiNmeProfileDeleteReqSerFree CsrWifiNmePfree
34
35#define CsrWifiNmeProfileDeleteAllReqSer CsrWifiEventSer
36#define CsrWifiNmeProfileDeleteAllReqDes CsrWifiEventDes
37#define CsrWifiNmeProfileDeleteAllReqSizeof CsrWifiEventSizeof
38#define CsrWifiNmeProfileDeleteAllReqSerFree CsrWifiNmePfree
39
40extern u8* CsrWifiNmeProfileOrderSetReqSer(u8 *ptr, size_t *len, void *msg);
41extern void* CsrWifiNmeProfileOrderSetReqDes(u8 *buffer, size_t len);
42extern size_t CsrWifiNmeProfileOrderSetReqSizeof(void *msg);
43extern void CsrWifiNmeProfileOrderSetReqSerFree(void *msg);
44
45extern u8* CsrWifiNmeProfileConnectReqSer(u8 *ptr, size_t *len, void *msg);
46extern void* CsrWifiNmeProfileConnectReqDes(u8 *buffer, size_t len);
47extern size_t CsrWifiNmeProfileConnectReqSizeof(void *msg);
48#define CsrWifiNmeProfileConnectReqSerFree CsrWifiNmePfree
49
50extern u8* CsrWifiNmeWpsReqSer(u8 *ptr, size_t *len, void *msg);
51extern void* CsrWifiNmeWpsReqDes(u8 *buffer, size_t len);
52extern size_t CsrWifiNmeWpsReqSizeof(void *msg);
53#define CsrWifiNmeWpsReqSerFree CsrWifiNmePfree
54
55#define CsrWifiNmeWpsCancelReqSer CsrWifiEventCsrUint16Ser
56#define CsrWifiNmeWpsCancelReqDes CsrWifiEventCsrUint16Des
57#define CsrWifiNmeWpsCancelReqSizeof CsrWifiEventCsrUint16Sizeof
58#define CsrWifiNmeWpsCancelReqSerFree CsrWifiNmePfree
59
60#define CsrWifiNmeConnectionStatusGetReqSer CsrWifiEventCsrUint16Ser
61#define CsrWifiNmeConnectionStatusGetReqDes CsrWifiEventCsrUint16Des
62#define CsrWifiNmeConnectionStatusGetReqSizeof CsrWifiEventCsrUint16Sizeof
63#define CsrWifiNmeConnectionStatusGetReqSerFree CsrWifiNmePfree
64
65extern u8* CsrWifiNmeSimImsiGetResSer(u8 *ptr, size_t *len, void *msg);
66extern void* CsrWifiNmeSimImsiGetResDes(u8 *buffer, size_t len);
67extern size_t CsrWifiNmeSimImsiGetResSizeof(void *msg);
68extern void CsrWifiNmeSimImsiGetResSerFree(void *msg);
69
70extern u8* CsrWifiNmeSimGsmAuthResSer(u8 *ptr, size_t *len, void *msg);
71extern void* CsrWifiNmeSimGsmAuthResDes(u8 *buffer, size_t len);
72extern size_t CsrWifiNmeSimGsmAuthResSizeof(void *msg);
73extern void CsrWifiNmeSimGsmAuthResSerFree(void *msg);
74
75extern u8* CsrWifiNmeSimUmtsAuthResSer(u8 *ptr, size_t *len, void *msg);
76extern void* CsrWifiNmeSimUmtsAuthResDes(u8 *buffer, size_t len);
77extern size_t CsrWifiNmeSimUmtsAuthResSizeof(void *msg);
78extern void CsrWifiNmeSimUmtsAuthResSerFree(void *msg);
79
80extern u8* CsrWifiNmeWpsConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
81extern void* CsrWifiNmeWpsConfigSetReqDes(u8 *buffer, size_t len);
82extern size_t CsrWifiNmeWpsConfigSetReqSizeof(void *msg);
83extern void CsrWifiNmeWpsConfigSetReqSerFree(void *msg);
84
85#define CsrWifiNmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser
86#define CsrWifiNmeEventMaskSetReqDes CsrWifiEventCsrUint32Des
87#define CsrWifiNmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof
88#define CsrWifiNmeEventMaskSetReqSerFree CsrWifiNmePfree
89
90#define CsrWifiNmeProfileSetCfmSer CsrWifiEventCsrUint16Ser
91#define CsrWifiNmeProfileSetCfmDes CsrWifiEventCsrUint16Des
92#define CsrWifiNmeProfileSetCfmSizeof CsrWifiEventCsrUint16Sizeof
93#define CsrWifiNmeProfileSetCfmSerFree CsrWifiNmePfree
94
95#define CsrWifiNmeProfileDeleteCfmSer CsrWifiEventCsrUint16Ser
96#define CsrWifiNmeProfileDeleteCfmDes CsrWifiEventCsrUint16Des
97#define CsrWifiNmeProfileDeleteCfmSizeof CsrWifiEventCsrUint16Sizeof
98#define CsrWifiNmeProfileDeleteCfmSerFree CsrWifiNmePfree
99
100#define CsrWifiNmeProfileDeleteAllCfmSer CsrWifiEventCsrUint16Ser
101#define CsrWifiNmeProfileDeleteAllCfmDes CsrWifiEventCsrUint16Des
102#define CsrWifiNmeProfileDeleteAllCfmSizeof CsrWifiEventCsrUint16Sizeof
103#define CsrWifiNmeProfileDeleteAllCfmSerFree CsrWifiNmePfree
104
105extern u8* CsrWifiNmeProfileOrderSetCfmSer(u8 *ptr, size_t *len, void *msg);
106extern void* CsrWifiNmeProfileOrderSetCfmDes(u8 *buffer, size_t len);
107extern size_t CsrWifiNmeProfileOrderSetCfmSizeof(void *msg);
108#define CsrWifiNmeProfileOrderSetCfmSerFree CsrWifiNmePfree
109
110extern u8* CsrWifiNmeProfileConnectCfmSer(u8 *ptr, size_t *len, void *msg);
111extern void* CsrWifiNmeProfileConnectCfmDes(u8 *buffer, size_t len);
112extern size_t CsrWifiNmeProfileConnectCfmSizeof(void *msg);
113extern void CsrWifiNmeProfileConnectCfmSerFree(void *msg);
114
115extern u8* CsrWifiNmeWpsCfmSer(u8 *ptr, size_t *len, void *msg);
116extern void* CsrWifiNmeWpsCfmDes(u8 *buffer, size_t len);
117extern size_t CsrWifiNmeWpsCfmSizeof(void *msg);
118extern void CsrWifiNmeWpsCfmSerFree(void *msg);
119
120extern u8* CsrWifiNmeWpsCancelCfmSer(u8 *ptr, size_t *len, void *msg);
121extern void* CsrWifiNmeWpsCancelCfmDes(u8 *buffer, size_t len);
122extern size_t CsrWifiNmeWpsCancelCfmSizeof(void *msg);
123#define CsrWifiNmeWpsCancelCfmSerFree CsrWifiNmePfree
124
125extern u8* CsrWifiNmeConnectionStatusGetCfmSer(u8 *ptr, size_t *len, void *msg);
126extern void* CsrWifiNmeConnectionStatusGetCfmDes(u8 *buffer, size_t len);
127extern size_t CsrWifiNmeConnectionStatusGetCfmSizeof(void *msg);
128#define CsrWifiNmeConnectionStatusGetCfmSerFree CsrWifiNmePfree
129
130extern u8* CsrWifiNmeProfileUpdateIndSer(u8 *ptr, size_t *len, void *msg);
131extern void* CsrWifiNmeProfileUpdateIndDes(u8 *buffer, size_t len);
132extern size_t CsrWifiNmeProfileUpdateIndSizeof(void *msg);
133extern void CsrWifiNmeProfileUpdateIndSerFree(void *msg);
134
135extern u8* CsrWifiNmeProfileDisconnectIndSer(u8 *ptr, size_t *len, void *msg);
136extern void* CsrWifiNmeProfileDisconnectIndDes(u8 *buffer, size_t len);
137extern size_t CsrWifiNmeProfileDisconnectIndSizeof(void *msg);
138extern void CsrWifiNmeProfileDisconnectIndSerFree(void *msg);
139
140#define CsrWifiNmeSimImsiGetIndSer CsrWifiEventSer
141#define CsrWifiNmeSimImsiGetIndDes CsrWifiEventDes
142#define CsrWifiNmeSimImsiGetIndSizeof CsrWifiEventSizeof
143#define CsrWifiNmeSimImsiGetIndSerFree CsrWifiNmePfree
144
145extern u8* CsrWifiNmeSimGsmAuthIndSer(u8 *ptr, size_t *len, void *msg);
146extern void* CsrWifiNmeSimGsmAuthIndDes(u8 *buffer, size_t len);
147extern size_t CsrWifiNmeSimGsmAuthIndSizeof(void *msg);
148extern void CsrWifiNmeSimGsmAuthIndSerFree(void *msg);
149
150extern u8* CsrWifiNmeSimUmtsAuthIndSer(u8 *ptr, size_t *len, void *msg);
151extern void* CsrWifiNmeSimUmtsAuthIndDes(u8 *buffer, size_t len);
152extern size_t CsrWifiNmeSimUmtsAuthIndSizeof(void *msg);
153#define CsrWifiNmeSimUmtsAuthIndSerFree CsrWifiNmePfree
154
155#define CsrWifiNmeWpsConfigSetCfmSer CsrWifiEventCsrUint16Ser
156#define CsrWifiNmeWpsConfigSetCfmDes CsrWifiEventCsrUint16Des
157#define CsrWifiNmeWpsConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
158#define CsrWifiNmeWpsConfigSetCfmSerFree CsrWifiNmePfree
159
160#define CsrWifiNmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser
161#define CsrWifiNmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des
162#define CsrWifiNmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof
163#define CsrWifiNmeEventMaskSetCfmSerFree CsrWifiNmePfree
164
165#endif /* CSR_WIFI_NME_SERIALIZE_H__ */
166
diff --git a/drivers/staging/csr/csr_wifi_nme_task.h b/drivers/staging/csr/csr_wifi_nme_task.h
deleted file mode 100644
index 84e973a59bb2..000000000000
--- a/drivers/staging/csr/csr_wifi_nme_task.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_NME_TASK_H__
14#define CSR_WIFI_NME_TASK_H__
15
16#include <linux/types.h>
17#include "csr_sched.h"
18
19#ifndef CSR_WIFI_NME_ENABLE
20#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_task.h
21#endif
22
23#define CSR_WIFI_NME_LOG_ID 0x1203FFFF
24extern CsrSchedQid CSR_WIFI_NME_IFACEQUEUE;
25
26#endif /* CSR_WIFI_NME_TASK_H__ */
27
diff --git a/drivers/staging/csr/csr_wifi_private_common.h b/drivers/staging/csr/csr_wifi_private_common.h
deleted file mode 100644
index ee3bd51b934a..000000000000
--- a/drivers/staging/csr/csr_wifi_private_common.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_PRIVATE_COMMON_H__
12#define CSR_WIFI_PRIVATE_COMMON_H__
13
14/**
15 * @brief maximum number of STAs allowed to be connected
16 *
17 * @par Description
18 * min & max Beacon Interval
19 */
20#define CSR_WIFI_AP_MAX_ASSOC_STA 8
21
22/** Number of only b rates */
23#define CSR_WIFI_SME_AP_MAX_ONLY_B_RATES 4
24
25
26/** Number of mandatory b rates */
27#define CSR_WIFI_SME_AP_MAX_MANDATORY_B_RATES 2
28
29
30/** Number of mandatory bg rates */
31#define CSR_WIFI_SME_AP_MAX_MANDATORY_BG_RATES 4
32
33
34/** Number of bg rates */
35#define CSR_WIFI_SME_AP_MAX_BG_RATES 12
36
37
38/** Number of no b only g rates */
39#define CSR_WIFI_SME_AP_MAX_NO_B_ONLY_G_RATES 8
40
41
42/** Number of mandatory g rates */
43#define CSR_WIFI_SME_AP_MAX_MANDATORY_G_RATES 7
44
45
46/* Number of g mandatory rates */
47#define CSR_WIFI_SME_AP_G_MANDATORY_RATES_NUM 7
48
49
50/* Number of b mandatory rates */
51#define CSR_WIFI_SME_AP_B_MANDATORY_RATES_NUM 2
52
53
54/* Number of b/g mandatory rates */
55#define CSR_WIFI_SME_AP_BG_MANDATORY_RATES_NUM 4
56
57
58/* The maximum allowed length of SSID */
59#define CSR_WIFI_SME_AP_SSID_MAX_LENGTH 32
60
61/* Refer 8.4.2.27 RSN element - we support TKIP, WPA2, WAPI and PSK only, no pmkid, group cipher suite */
62#define CSR_WIFI_SME_RSN_PACKED_SIZE (1 + 1 + 2 + 4 + 2 + 4 * 2 + 2 + 4 * 1 + 2 + 24)
63
64/* Refer 7.3.2.9 (ISO/IEC 8802-11:2006) WAPI element - we support WAPI PSK only, no bkid, group cipher suite */
65#define CSR_WIFI_SME_WAPI_PACKED_SIZE (1 + 1 + 2 + 2 + 4 * 1 + 2 + 4 * 1 + 4 + 2 + 24)
66
67
68/* Common structure for NME and SME to maintain Interface mode*/
69typedef u8 CsrWifiInterfaceMode;
70#define CSR_WIFI_MODE_NONE ((CsrWifiInterfaceMode) 0xFF)
71#define CSR_WIFI_MODE_STA ((CsrWifiInterfaceMode) 0x00)
72#define CSR_WIFI_MODE_AP ((CsrWifiInterfaceMode) 0x01)
73#define CSR_WIFI_MODE_P2P_DEVICE ((CsrWifiInterfaceMode) 0x02)
74#define CSR_WIFI_MODE_P2P_CLI ((CsrWifiInterfaceMode) 0x03)
75#define CSR_WIFI_MODE_P2P_GO ((CsrWifiInterfaceMode) 0x04)
76#define CSR_WIFI_MODE_AMP ((CsrWifiInterfaceMode) 0x05)
77#define CSR_WIFI_MODE_WPS_ENROLLEE ((CsrWifiInterfaceMode) 0x06)
78#define CSR_WIFI_MODE_IBSS ((CsrWifiInterfaceMode) 0x07)
79
80#endif
81
diff --git a/drivers/staging/csr/csr_wifi_result.h b/drivers/staging/csr/csr_wifi_result.h
deleted file mode 100644
index 3c394c7e5fa9..000000000000
--- a/drivers/staging/csr/csr_wifi_result.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_RESULT_H__
12#define CSR_WIFI_RESULT_H__
13
14#include "csr_result.h"
15
16/* THIS FILE SHOULD CONTAIN ONLY RESULT CODES */
17
18/* Result Codes */
19#define CSR_WIFI_HIP_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
20#define CSR_WIFI_HIP_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
21#define CSR_WIFI_HIP_RESULT_NO_SPACE ((CsrResult) 3) /* A queue or buffer is full */
22#define CSR_WIFI_HIP_RESULT_NO_MEMORY ((CsrResult) 4) /* Fatal error, no memory */
23#define CSR_WIFI_HIP_RESULT_RANGE ((CsrResult) 5) /* Request exceeds the range of a file or a buffer */
24#define CSR_WIFI_HIP_RESULT_NOT_FOUND ((CsrResult) 6) /* A file (typically a f/w patch) is not found */
25
26#endif /* CSR_WIFI_RESULT_H__ */
27
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
index 775c013d0514..000000000000
--- a/drivers/staging/csr/csr_wifi_router_converter_init.c
+++ /dev/null
@@ -1,82 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#include "csr_msgconv.h"
14#include "csr_macro.h"
15
16
17#ifdef CSR_LOG_ENABLE
18#include "csr_log.h"
19#endif
20
21#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE
22#include "csr_wifi_router_serialize.h"
23#include "csr_wifi_router_prim.h"
24
25static CsrMsgConvMsgEntry csrwifirouter_conv_lut[] = {
26 { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, CsrWifiRouterMaPacketSubscribeReqSizeof, CsrWifiRouterMaPacketSubscribeReqSer, CsrWifiRouterMaPacketSubscribeReqDes, CsrWifiRouterMaPacketSubscribeReqSerFree },
27 { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, CsrWifiRouterMaPacketUnsubscribeReqSizeof, CsrWifiRouterMaPacketUnsubscribeReqSer, CsrWifiRouterMaPacketUnsubscribeReqDes, CsrWifiRouterMaPacketUnsubscribeReqSerFree },
28 { CSR_WIFI_ROUTER_MA_PACKET_REQ, CsrWifiRouterMaPacketReqSizeof, CsrWifiRouterMaPacketReqSer, CsrWifiRouterMaPacketReqDes, CsrWifiRouterMaPacketReqSerFree },
29 { CSR_WIFI_ROUTER_MA_PACKET_RES, CsrWifiRouterMaPacketResSizeof, CsrWifiRouterMaPacketResSer, CsrWifiRouterMaPacketResDes, CsrWifiRouterMaPacketResSerFree },
30 { CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, CsrWifiRouterMaPacketCancelReqSizeof, CsrWifiRouterMaPacketCancelReqSer, CsrWifiRouterMaPacketCancelReqDes, CsrWifiRouterMaPacketCancelReqSerFree },
31 { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, CsrWifiRouterMaPacketSubscribeCfmSizeof, CsrWifiRouterMaPacketSubscribeCfmSer, CsrWifiRouterMaPacketSubscribeCfmDes, CsrWifiRouterMaPacketSubscribeCfmSerFree },
32 { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, CsrWifiRouterMaPacketUnsubscribeCfmSizeof, CsrWifiRouterMaPacketUnsubscribeCfmSer, CsrWifiRouterMaPacketUnsubscribeCfmDes, CsrWifiRouterMaPacketUnsubscribeCfmSerFree },
33 { CSR_WIFI_ROUTER_MA_PACKET_CFM, CsrWifiRouterMaPacketCfmSizeof, CsrWifiRouterMaPacketCfmSer, CsrWifiRouterMaPacketCfmDes, CsrWifiRouterMaPacketCfmSerFree },
34 { CSR_WIFI_ROUTER_MA_PACKET_IND, CsrWifiRouterMaPacketIndSizeof, CsrWifiRouterMaPacketIndSer, CsrWifiRouterMaPacketIndDes, CsrWifiRouterMaPacketIndSerFree },
35
36 { 0, NULL, NULL, NULL, NULL },
37};
38
39CsrMsgConvMsgEntry* CsrWifiRouterConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
40{
41 if (msgType & CSR_PRIM_UPSTREAM)
42 {
43 u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT;
44 if (idx < (CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT) &&
45 csrwifirouter_conv_lut[idx].msgType == msgType)
46 {
47 return &csrwifirouter_conv_lut[idx];
48 }
49 }
50 else
51 {
52 if (msgType < CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT &&
53 csrwifirouter_conv_lut[msgType].msgType == msgType)
54 {
55 return &csrwifirouter_conv_lut[msgType];
56 }
57 }
58 return NULL;
59}
60
61
62void CsrWifiRouterConverterInit(void)
63{
64 CsrMsgConvInsert(CSR_WIFI_ROUTER_PRIM, csrwifirouter_conv_lut);
65 CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_PRIM, CsrWifiRouterConverterLookup);
66}
67
68
69#ifdef CSR_LOG_ENABLE
70static const CsrLogPrimitiveInformation csrwifirouter_conv_info = {
71 CSR_WIFI_ROUTER_PRIM,
72 (char *)"CSR_WIFI_ROUTER_PRIM",
73 csrwifirouter_conv_lut
74};
75const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void)
76{
77 return &csrwifirouter_conv_info;
78}
79
80
81#endif /* CSR_LOG_ENABLE */
82#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
index 478327b75c18..000000000000
--- a/drivers/staging/csr/csr_wifi_router_converter_init.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_CONVERTER_INIT_H__
14#define CSR_WIFI_ROUTER_CONVERTER_INIT_H__
15
16#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE
17
18#include "csr_msgconv.h"
19
20#ifdef CSR_LOG_ENABLE
21#include "csr_log.h"
22
23extern const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void);
24#endif /* CSR_LOG_ENABLE */
25
26extern void CsrWifiRouterConverterInit(void);
27
28#else /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
29
30#define CsrWifiRouterConverterInit()
31
32#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
33
34#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
index a02e307e5a88..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c
+++ /dev/null
@@ -1,134 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#include "csr_msgconv.h"
14#include "csr_macro.h"
15
16#ifdef CSR_LOG_ENABLE
17#include "csr_log.h"
18#endif
19
20#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE
21#include "csr_wifi_router_ctrl_serialize.h"
22#include "csr_wifi_router_ctrl_prim.h"
23
24static CsrMsgConvMsgEntry csrwifirouterctrl_conv_lut[] = {
25 { CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, CsrWifiRouterCtrlConfigurePowerModeReqSizeof, CsrWifiRouterCtrlConfigurePowerModeReqSer, CsrWifiRouterCtrlConfigurePowerModeReqDes, CsrWifiRouterCtrlConfigurePowerModeReqSerFree },
26 { CSR_WIFI_ROUTER_CTRL_HIP_REQ, CsrWifiRouterCtrlHipReqSizeof, CsrWifiRouterCtrlHipReqSer, CsrWifiRouterCtrlHipReqDes, CsrWifiRouterCtrlHipReqSerFree },
27 { CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, CsrWifiRouterCtrlMediaStatusReqSizeof, CsrWifiRouterCtrlMediaStatusReqSer, CsrWifiRouterCtrlMediaStatusReqDes, CsrWifiRouterCtrlMediaStatusReqSerFree },
28 { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, CsrWifiRouterCtrlMulticastAddressResSizeof, CsrWifiRouterCtrlMulticastAddressResSer, CsrWifiRouterCtrlMulticastAddressResDes, CsrWifiRouterCtrlMulticastAddressResSerFree },
29 { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, CsrWifiRouterCtrlPortConfigureReqSizeof, CsrWifiRouterCtrlPortConfigureReqSer, CsrWifiRouterCtrlPortConfigureReqDes, CsrWifiRouterCtrlPortConfigureReqSerFree },
30 { CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, CsrWifiRouterCtrlQosControlReqSizeof, CsrWifiRouterCtrlQosControlReqSer, CsrWifiRouterCtrlQosControlReqDes, CsrWifiRouterCtrlQosControlReqSerFree },
31 { CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, CsrWifiRouterCtrlSuspendResSizeof, CsrWifiRouterCtrlSuspendResSer, CsrWifiRouterCtrlSuspendResDes, CsrWifiRouterCtrlSuspendResSerFree },
32 { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, CsrWifiRouterCtrlTclasAddReqSizeof, CsrWifiRouterCtrlTclasAddReqSer, CsrWifiRouterCtrlTclasAddReqDes, CsrWifiRouterCtrlTclasAddReqSerFree },
33 { CSR_WIFI_ROUTER_CTRL_RESUME_RES, CsrWifiRouterCtrlResumeResSizeof, CsrWifiRouterCtrlResumeResSer, CsrWifiRouterCtrlResumeResDes, CsrWifiRouterCtrlResumeResSerFree },
34 { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseReqSer, CsrWifiRouterCtrlRawSdioDeinitialiseReqDes, CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree },
35 { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, CsrWifiRouterCtrlRawSdioInitialiseReqSizeof, CsrWifiRouterCtrlRawSdioInitialiseReqSer, CsrWifiRouterCtrlRawSdioInitialiseReqDes, CsrWifiRouterCtrlRawSdioInitialiseReqSerFree },
36 { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, CsrWifiRouterCtrlTclasDelReqSizeof, CsrWifiRouterCtrlTclasDelReqSer, CsrWifiRouterCtrlTclasDelReqDes, CsrWifiRouterCtrlTclasDelReqSerFree },
37 { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, CsrWifiRouterCtrlTrafficClassificationReqSizeof, CsrWifiRouterCtrlTrafficClassificationReqSer, CsrWifiRouterCtrlTrafficClassificationReqDes, CsrWifiRouterCtrlTrafficClassificationReqSerFree },
38 { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, CsrWifiRouterCtrlTrafficConfigReqSizeof, CsrWifiRouterCtrlTrafficConfigReqSer, CsrWifiRouterCtrlTrafficConfigReqDes, CsrWifiRouterCtrlTrafficConfigReqSerFree },
39 { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, CsrWifiRouterCtrlWifiOffReqSizeof, CsrWifiRouterCtrlWifiOffReqSer, CsrWifiRouterCtrlWifiOffReqDes, CsrWifiRouterCtrlWifiOffReqSerFree },
40 { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, CsrWifiRouterCtrlWifiOffResSizeof, CsrWifiRouterCtrlWifiOffResSer, CsrWifiRouterCtrlWifiOffResDes, CsrWifiRouterCtrlWifiOffResSerFree },
41 { CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, CsrWifiRouterCtrlWifiOnReqSizeof, CsrWifiRouterCtrlWifiOnReqSer, CsrWifiRouterCtrlWifiOnReqDes, CsrWifiRouterCtrlWifiOnReqSerFree },
42 { CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, CsrWifiRouterCtrlWifiOnResSizeof, CsrWifiRouterCtrlWifiOnResSer, CsrWifiRouterCtrlWifiOnResDes, CsrWifiRouterCtrlWifiOnResSerFree },
43 { CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, CsrWifiRouterCtrlM4TransmitReqSizeof, CsrWifiRouterCtrlM4TransmitReqSer, CsrWifiRouterCtrlM4TransmitReqDes, CsrWifiRouterCtrlM4TransmitReqSerFree },
44 { CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, CsrWifiRouterCtrlModeSetReqSizeof, CsrWifiRouterCtrlModeSetReqSer, CsrWifiRouterCtrlModeSetReqDes, CsrWifiRouterCtrlModeSetReqSerFree },
45 { CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, CsrWifiRouterCtrlPeerAddReqSizeof, CsrWifiRouterCtrlPeerAddReqSer, CsrWifiRouterCtrlPeerAddReqDes, CsrWifiRouterCtrlPeerAddReqSerFree },
46 { CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, CsrWifiRouterCtrlPeerDelReqSizeof, CsrWifiRouterCtrlPeerDelReqSer, CsrWifiRouterCtrlPeerDelReqDes, CsrWifiRouterCtrlPeerDelReqSerFree },
47 { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, CsrWifiRouterCtrlPeerUpdateReqSizeof, CsrWifiRouterCtrlPeerUpdateReqSer, CsrWifiRouterCtrlPeerUpdateReqDes, CsrWifiRouterCtrlPeerUpdateReqSerFree },
48 { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, CsrWifiRouterCtrlCapabilitiesReqSizeof, CsrWifiRouterCtrlCapabilitiesReqSer, CsrWifiRouterCtrlCapabilitiesReqDes, CsrWifiRouterCtrlCapabilitiesReqSerFree },
49 { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, CsrWifiRouterCtrlBlockAckEnableReqSizeof, CsrWifiRouterCtrlBlockAckEnableReqSer, CsrWifiRouterCtrlBlockAckEnableReqDes, CsrWifiRouterCtrlBlockAckEnableReqSerFree },
50 { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, CsrWifiRouterCtrlBlockAckDisableReqSizeof, CsrWifiRouterCtrlBlockAckDisableReqSer, CsrWifiRouterCtrlBlockAckDisableReqDes, CsrWifiRouterCtrlBlockAckDisableReqSerFree },
51 { CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, CsrWifiRouterCtrlWapiRxPktReqSizeof, CsrWifiRouterCtrlWapiRxPktReqSer, CsrWifiRouterCtrlWapiRxPktReqDes, CsrWifiRouterCtrlWapiRxPktReqSerFree },
52 { CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, CsrWifiRouterCtrlWapiMulticastFilterReqSizeof, CsrWifiRouterCtrlWapiMulticastFilterReqSer, CsrWifiRouterCtrlWapiMulticastFilterReqDes, CsrWifiRouterCtrlWapiMulticastFilterReqSerFree },
53 { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, CsrWifiRouterCtrlWapiUnicastFilterReqSizeof, CsrWifiRouterCtrlWapiUnicastFilterReqSer, CsrWifiRouterCtrlWapiUnicastFilterReqDes, CsrWifiRouterCtrlWapiUnicastFilterReqSerFree },
54 { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof, CsrWifiRouterCtrlWapiUnicastTxPktReqSer, CsrWifiRouterCtrlWapiUnicastTxPktReqDes, CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree },
55 { CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, CsrWifiRouterCtrlWapiFilterReqSizeof, CsrWifiRouterCtrlWapiFilterReqSer, CsrWifiRouterCtrlWapiFilterReqDes, CsrWifiRouterCtrlWapiFilterReqSerFree },
56 { CSR_WIFI_ROUTER_CTRL_HIP_IND, CsrWifiRouterCtrlHipIndSizeof, CsrWifiRouterCtrlHipIndSer, CsrWifiRouterCtrlHipIndDes, CsrWifiRouterCtrlHipIndSerFree },
57 { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, CsrWifiRouterCtrlMulticastAddressIndSizeof, CsrWifiRouterCtrlMulticastAddressIndSer, CsrWifiRouterCtrlMulticastAddressIndDes, CsrWifiRouterCtrlMulticastAddressIndSerFree },
58 { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, CsrWifiRouterCtrlPortConfigureCfmSizeof, CsrWifiRouterCtrlPortConfigureCfmSer, CsrWifiRouterCtrlPortConfigureCfmDes, CsrWifiRouterCtrlPortConfigureCfmSerFree },
59 { CSR_WIFI_ROUTER_CTRL_RESUME_IND, CsrWifiRouterCtrlResumeIndSizeof, CsrWifiRouterCtrlResumeIndSer, CsrWifiRouterCtrlResumeIndDes, CsrWifiRouterCtrlResumeIndSerFree },
60 { CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, CsrWifiRouterCtrlSuspendIndSizeof, CsrWifiRouterCtrlSuspendIndSer, CsrWifiRouterCtrlSuspendIndDes, CsrWifiRouterCtrlSuspendIndSerFree },
61 { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, CsrWifiRouterCtrlTclasAddCfmSizeof, CsrWifiRouterCtrlTclasAddCfmSer, CsrWifiRouterCtrlTclasAddCfmDes, CsrWifiRouterCtrlTclasAddCfmSerFree },
62 { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer, CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree },
63 { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioInitialiseCfmSer, CsrWifiRouterCtrlRawSdioInitialiseCfmDes, CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree },
64 { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, CsrWifiRouterCtrlTclasDelCfmSizeof, CsrWifiRouterCtrlTclasDelCfmSer, CsrWifiRouterCtrlTclasDelCfmDes, CsrWifiRouterCtrlTclasDelCfmSerFree },
65 { CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, CsrWifiRouterCtrlTrafficProtocolIndSizeof, CsrWifiRouterCtrlTrafficProtocolIndSer, CsrWifiRouterCtrlTrafficProtocolIndDes, CsrWifiRouterCtrlTrafficProtocolIndSerFree },
66 { CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, CsrWifiRouterCtrlTrafficSampleIndSizeof, CsrWifiRouterCtrlTrafficSampleIndSer, CsrWifiRouterCtrlTrafficSampleIndDes, CsrWifiRouterCtrlTrafficSampleIndSerFree },
67 { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, CsrWifiRouterCtrlWifiOffIndSizeof, CsrWifiRouterCtrlWifiOffIndSer, CsrWifiRouterCtrlWifiOffIndDes, CsrWifiRouterCtrlWifiOffIndSerFree },
68 { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, CsrWifiRouterCtrlWifiOffCfmSizeof, CsrWifiRouterCtrlWifiOffCfmSer, CsrWifiRouterCtrlWifiOffCfmDes, CsrWifiRouterCtrlWifiOffCfmSerFree },
69 { CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, CsrWifiRouterCtrlWifiOnIndSizeof, CsrWifiRouterCtrlWifiOnIndSer, CsrWifiRouterCtrlWifiOnIndDes, CsrWifiRouterCtrlWifiOnIndSerFree },
70 { CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, CsrWifiRouterCtrlWifiOnCfmSizeof, CsrWifiRouterCtrlWifiOnCfmSer, CsrWifiRouterCtrlWifiOnCfmDes, CsrWifiRouterCtrlWifiOnCfmSerFree },
71 { CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, CsrWifiRouterCtrlM4ReadyToSendIndSizeof, CsrWifiRouterCtrlM4ReadyToSendIndSer, CsrWifiRouterCtrlM4ReadyToSendIndDes, CsrWifiRouterCtrlM4ReadyToSendIndSerFree },
72 { CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, CsrWifiRouterCtrlM4TransmittedIndSizeof, CsrWifiRouterCtrlM4TransmittedIndSer, CsrWifiRouterCtrlM4TransmittedIndDes, CsrWifiRouterCtrlM4TransmittedIndSerFree },
73 { CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, CsrWifiRouterCtrlMicFailureIndSizeof, CsrWifiRouterCtrlMicFailureIndSer, CsrWifiRouterCtrlMicFailureIndDes, CsrWifiRouterCtrlMicFailureIndSerFree },
74 { CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, CsrWifiRouterCtrlConnectedIndSizeof, CsrWifiRouterCtrlConnectedIndSer, CsrWifiRouterCtrlConnectedIndDes, CsrWifiRouterCtrlConnectedIndSerFree },
75 { CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, CsrWifiRouterCtrlPeerAddCfmSizeof, CsrWifiRouterCtrlPeerAddCfmSer, CsrWifiRouterCtrlPeerAddCfmDes, CsrWifiRouterCtrlPeerAddCfmSerFree },
76 { CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, CsrWifiRouterCtrlPeerDelCfmSizeof, CsrWifiRouterCtrlPeerDelCfmSer, CsrWifiRouterCtrlPeerDelCfmDes, CsrWifiRouterCtrlPeerDelCfmSerFree },
77 { CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, CsrWifiRouterCtrlUnexpectedFrameIndSizeof, CsrWifiRouterCtrlUnexpectedFrameIndSer, CsrWifiRouterCtrlUnexpectedFrameIndDes, CsrWifiRouterCtrlUnexpectedFrameIndSerFree },
78 { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, CsrWifiRouterCtrlPeerUpdateCfmSizeof, CsrWifiRouterCtrlPeerUpdateCfmSer, CsrWifiRouterCtrlPeerUpdateCfmDes, CsrWifiRouterCtrlPeerUpdateCfmSerFree },
79 { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, CsrWifiRouterCtrlCapabilitiesCfmSizeof, CsrWifiRouterCtrlCapabilitiesCfmSer, CsrWifiRouterCtrlCapabilitiesCfmDes, CsrWifiRouterCtrlCapabilitiesCfmSerFree },
80 { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, CsrWifiRouterCtrlBlockAckEnableCfmSizeof, CsrWifiRouterCtrlBlockAckEnableCfmSer, CsrWifiRouterCtrlBlockAckEnableCfmDes, CsrWifiRouterCtrlBlockAckEnableCfmSerFree },
81 { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, CsrWifiRouterCtrlBlockAckDisableCfmSizeof, CsrWifiRouterCtrlBlockAckDisableCfmSer, CsrWifiRouterCtrlBlockAckDisableCfmDes, CsrWifiRouterCtrlBlockAckDisableCfmSerFree },
82 { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, CsrWifiRouterCtrlBlockAckErrorIndSizeof, CsrWifiRouterCtrlBlockAckErrorIndSer, CsrWifiRouterCtrlBlockAckErrorIndDes, CsrWifiRouterCtrlBlockAckErrorIndSerFree },
83 { CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, CsrWifiRouterCtrlStaInactiveIndSizeof, CsrWifiRouterCtrlStaInactiveIndSer, CsrWifiRouterCtrlStaInactiveIndDes, CsrWifiRouterCtrlStaInactiveIndSerFree },
84 { CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, CsrWifiRouterCtrlWapiRxMicCheckIndSizeof, CsrWifiRouterCtrlWapiRxMicCheckIndSer, CsrWifiRouterCtrlWapiRxMicCheckIndDes, CsrWifiRouterCtrlWapiRxMicCheckIndSerFree },
85 { CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, CsrWifiRouterCtrlModeSetCfmSizeof, CsrWifiRouterCtrlModeSetCfmSer, CsrWifiRouterCtrlModeSetCfmDes, CsrWifiRouterCtrlModeSetCfmSerFree },
86 { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer, CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree },
87
88 { 0, NULL, NULL, NULL, NULL },
89};
90
91CsrMsgConvMsgEntry* CsrWifiRouterCtrlConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
92{
93 if (msgType & CSR_PRIM_UPSTREAM)
94 {
95 u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT;
96 if (idx < (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT) &&
97 csrwifirouterctrl_conv_lut[idx].msgType == msgType)
98 {
99 return &csrwifirouterctrl_conv_lut[idx];
100 }
101 }
102 else
103 {
104 if (msgType < CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT &&
105 csrwifirouterctrl_conv_lut[msgType].msgType == msgType)
106 {
107 return &csrwifirouterctrl_conv_lut[msgType];
108 }
109 }
110 return NULL;
111}
112
113
114void CsrWifiRouterCtrlConverterInit(void)
115{
116 CsrMsgConvInsert(CSR_WIFI_ROUTER_CTRL_PRIM, csrwifirouterctrl_conv_lut);
117 CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_CTRL_PRIM, CsrWifiRouterCtrlConverterLookup);
118}
119
120
121#ifdef CSR_LOG_ENABLE
122static const CsrLogPrimitiveInformation csrwifirouterctrl_conv_info = {
123 CSR_WIFI_ROUTER_CTRL_PRIM,
124 (char *)"CSR_WIFI_ROUTER_CTRL_PRIM",
125 csrwifirouterctrl_conv_lut
126};
127const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void)
128{
129 return &csrwifirouterctrl_conv_info;
130}
131
132
133#endif /* CSR_LOG_ENABLE */
134#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
index c98458912825..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__
14#define CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__
15
16#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE
17
18#include "csr_msgconv.h"
19
20#ifdef CSR_LOG_ENABLE
21#include "csr_log.h"
22
23extern const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void);
24#endif /* CSR_LOG_ENABLE */
25
26extern void CsrWifiRouterCtrlConverterInit(void);
27
28#else /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
29
30#define CsrWifiRouterCtrlConverterInit()
31
32#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
33
34#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
index 7fa85fb4d6c0..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c
+++ /dev/null
@@ -1,108 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_router_ctrl_prim.h"
14#include "csr_wifi_router_ctrl_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiRouterCtrlFreeDownstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37
38 switch (*((CsrWifiRouterCtrlPrim *) message))
39 {
40 case CSR_WIFI_ROUTER_CTRL_HIP_REQ:
41 {
42 CsrWifiRouterCtrlHipReq *p = (CsrWifiRouterCtrlHipReq *)message;
43 kfree(p->mlmeCommand);
44 p->mlmeCommand = NULL;
45 kfree(p->dataRef1);
46 p->dataRef1 = NULL;
47 kfree(p->dataRef2);
48 p->dataRef2 = NULL;
49 break;
50 }
51 case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES:
52 {
53 CsrWifiRouterCtrlMulticastAddressRes *p = (CsrWifiRouterCtrlMulticastAddressRes *)message;
54 kfree(p->getAddresses);
55 p->getAddresses = NULL;
56 break;
57 }
58 case CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ:
59 {
60 CsrWifiRouterCtrlTclasAddReq *p = (CsrWifiRouterCtrlTclasAddReq *)message;
61 kfree(p->tclas);
62 p->tclas = NULL;
63 break;
64 }
65 case CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ:
66 {
67 CsrWifiRouterCtrlTclasDelReq *p = (CsrWifiRouterCtrlTclasDelReq *)message;
68 kfree(p->tclas);
69 p->tclas = NULL;
70 break;
71 }
72 case CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ:
73 {
74 CsrWifiRouterCtrlWifiOnReq *p = (CsrWifiRouterCtrlWifiOnReq *)message;
75 kfree(p->data);
76 p->data = NULL;
77 break;
78 }
79 case CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES:
80 {
81 CsrWifiRouterCtrlWifiOnRes *p = (CsrWifiRouterCtrlWifiOnRes *)message;
82 kfree(p->smeVersions.smeBuild);
83 p->smeVersions.smeBuild = NULL;
84 break;
85 }
86 case CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ:
87 {
88 CsrWifiRouterCtrlWapiRxPktReq *p = (CsrWifiRouterCtrlWapiRxPktReq *)message;
89 kfree(p->signal);
90 p->signal = NULL;
91 kfree(p->data);
92 p->data = NULL;
93 break;
94 }
95 case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ:
96 {
97 CsrWifiRouterCtrlWapiUnicastTxPktReq *p = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)message;
98 kfree(p->data);
99 p->data = NULL;
100 break;
101 }
102
103 default:
104 break;
105 }
106}
107
108
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
index 954b3defc49c..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_router_ctrl_prim.h"
14#include "csr_wifi_router_ctrl_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiRouterCtrlFreeUpstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37
38 switch (*((CsrWifiRouterCtrlPrim *) message))
39 {
40 case CSR_WIFI_ROUTER_CTRL_HIP_IND:
41 {
42 CsrWifiRouterCtrlHipInd *p = (CsrWifiRouterCtrlHipInd *)message;
43 kfree(p->mlmeCommand);
44 p->mlmeCommand = NULL;
45 kfree(p->dataRef1);
46 p->dataRef1 = NULL;
47 kfree(p->dataRef2);
48 p->dataRef2 = NULL;
49 break;
50 }
51 case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND:
52 {
53 CsrWifiRouterCtrlMulticastAddressInd *p = (CsrWifiRouterCtrlMulticastAddressInd *)message;
54 kfree(p->setAddresses);
55 p->setAddresses = NULL;
56 break;
57 }
58 case CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND:
59 {
60 CsrWifiRouterCtrlWifiOnInd *p = (CsrWifiRouterCtrlWifiOnInd *)message;
61 kfree(p->versions.routerBuild);
62 p->versions.routerBuild = NULL;
63 break;
64 }
65 case CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND:
66 {
67 CsrWifiRouterCtrlWapiRxMicCheckInd *p = (CsrWifiRouterCtrlWapiRxMicCheckInd *)message;
68 kfree(p->signal);
69 p->signal = NULL;
70 kfree(p->data);
71 p->data = NULL;
72 break;
73 }
74 case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND:
75 {
76 CsrWifiRouterCtrlWapiUnicastTxEncryptInd *p = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)message;
77 kfree(p->data);
78 p->data = NULL;
79 break;
80 }
81
82 default:
83 break;
84 }
85}
86
87
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
index f235153c42af..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_lib.h
+++ /dev/null
@@ -1,2082 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_CTRL_LIB_H__
14#define CSR_WIFI_ROUTER_CTRL_LIB_H__
15
16#include "csr_sched.h"
17#include "csr_macro.h"
18#include "csr_msg_transport.h"
19
20#include "csr_wifi_lib.h"
21
22#include "csr_wifi_router_ctrl_prim.h"
23#include "csr_wifi_router_task.h"
24
25/*----------------------------------------------------------------------------*
26 * CsrWifiRouterCtrlFreeUpstreamMessageContents
27 *
28 * DESCRIPTION
29 * Free the allocated memory in a CSR_WIFI_ROUTER_CTRL upstream message. Does not
30 * free the message itself, and can only be used for upstream messages.
31 *
32 * PARAMETERS
33 * Deallocates the resources in a CSR_WIFI_ROUTER_CTRL upstream message
34 *----------------------------------------------------------------------------*/
35void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message);
36
37/*----------------------------------------------------------------------------*
38 * CsrWifiRouterCtrlFreeDownstreamMessageContents
39 *
40 * DESCRIPTION
41 * Free the allocated memory in a CSR_WIFI_ROUTER_CTRL downstream message. Does not
42 * free the message itself, and can only be used for downstream messages.
43 *
44 * PARAMETERS
45 * Deallocates the resources in a CSR_WIFI_ROUTER_CTRL downstream message
46 *----------------------------------------------------------------------------*/
47void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message);
48
49/*----------------------------------------------------------------------------*
50 * Enum to string functions
51 *----------------------------------------------------------------------------*/
52const char* CsrWifiRouterCtrlBlockAckRoleToString(CsrWifiRouterCtrlBlockAckRole value);
53const char* CsrWifiRouterCtrlControlIndicationToString(CsrWifiRouterCtrlControlIndication value);
54const char* CsrWifiRouterCtrlListActionToString(CsrWifiRouterCtrlListAction value);
55const char* CsrWifiRouterCtrlLowPowerModeToString(CsrWifiRouterCtrlLowPowerMode value);
56const char* CsrWifiRouterCtrlMediaStatusToString(CsrWifiRouterCtrlMediaStatus value);
57const char* CsrWifiRouterCtrlModeToString(CsrWifiRouterCtrlMode value);
58const char* CsrWifiRouterCtrlPeerStatusToString(CsrWifiRouterCtrlPeerStatus value);
59const char* CsrWifiRouterCtrlPortActionToString(CsrWifiRouterCtrlPortAction value);
60const char* CsrWifiRouterCtrlPowersaveTypeToString(CsrWifiRouterCtrlPowersaveType value);
61const char* CsrWifiRouterCtrlProtocolDirectionToString(CsrWifiRouterCtrlProtocolDirection value);
62const char* CsrWifiRouterCtrlQoSControlToString(CsrWifiRouterCtrlQoSControl value);
63const char* CsrWifiRouterCtrlQueueConfigToString(CsrWifiRouterCtrlQueueConfig value);
64const char* CsrWifiRouterCtrlTrafficConfigTypeToString(CsrWifiRouterCtrlTrafficConfigType value);
65const char* CsrWifiRouterCtrlTrafficPacketTypeToString(CsrWifiRouterCtrlTrafficPacketType value);
66const char* CsrWifiRouterCtrlTrafficTypeToString(CsrWifiRouterCtrlTrafficType value);
67
68
69/*----------------------------------------------------------------------------*
70 * CsrPrim Type toString function.
71 * Converts a message type to the String name of the Message
72 *----------------------------------------------------------------------------*/
73const char* CsrWifiRouterCtrlPrimTypeToString(CsrPrim msgType);
74
75/*----------------------------------------------------------------------------*
76 * Lookup arrays for PrimType name Strings
77 *----------------------------------------------------------------------------*/
78extern const char *CsrWifiRouterCtrlUpstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT];
79extern const char *CsrWifiRouterCtrlDownstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT];
80
81/*******************************************************************************
82
83 NAME
84 CsrWifiRouterCtrlBlockAckDisableReqSend
85
86 DESCRIPTION
87
88 PARAMETERS
89 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
90 interfaceTag -
91 clientData -
92 macAddress -
93 trafficStreamID -
94 role -
95
96*******************************************************************************/
97#define CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
98 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL); \
99 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, dst__, src__); \
100 msg__->interfaceTag = (interfaceTag__); \
101 msg__->clientData = (clientData__); \
102 msg__->macAddress = (macAddress__); \
103 msg__->trafficStreamID = (trafficStreamID__); \
104 msg__->role = (role__);
105
106#define CsrWifiRouterCtrlBlockAckDisableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
107 { \
108 CsrWifiRouterCtrlBlockAckDisableReq *msg__; \
109 CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__); \
110 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
111 }
112
113#define CsrWifiRouterCtrlBlockAckDisableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
114 CsrWifiRouterCtrlBlockAckDisableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__)
115
116/*******************************************************************************
117
118 NAME
119 CsrWifiRouterCtrlBlockAckDisableCfmSend
120
121 DESCRIPTION
122
123 PARAMETERS
124 queue - Destination Task Queue
125 clientData -
126 interfaceTag -
127 status -
128
129*******************************************************************************/
130#define CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
131 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL); \
132 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, dst__, src__); \
133 msg__->clientData = (clientData__); \
134 msg__->interfaceTag = (interfaceTag__); \
135 msg__->status = (status__);
136
137#define CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
138 { \
139 CsrWifiRouterCtrlBlockAckDisableCfm *msg__; \
140 CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
141 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
142 }
143
144#define CsrWifiRouterCtrlBlockAckDisableCfmSend(dst__, clientData__, interfaceTag__, status__) \
145 CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
146
147/*******************************************************************************
148
149 NAME
150 CsrWifiRouterCtrlBlockAckEnableReqSend
151
152 DESCRIPTION
153
154 PARAMETERS
155 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
156 interfaceTag -
157 clientData -
158 macAddress -
159 trafficStreamID -
160 role -
161 bufferSize -
162 timeout -
163 ssn -
164
165*******************************************************************************/
166#define CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
167 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL); \
168 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, dst__, src__); \
169 msg__->interfaceTag = (interfaceTag__); \
170 msg__->clientData = (clientData__); \
171 msg__->macAddress = (macAddress__); \
172 msg__->trafficStreamID = (trafficStreamID__); \
173 msg__->role = (role__); \
174 msg__->bufferSize = (bufferSize__); \
175 msg__->timeout = (timeout__); \
176 msg__->ssn = (ssn__);
177
178#define CsrWifiRouterCtrlBlockAckEnableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
179 { \
180 CsrWifiRouterCtrlBlockAckEnableReq *msg__; \
181 CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__); \
182 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
183 }
184
185#define CsrWifiRouterCtrlBlockAckEnableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
186 CsrWifiRouterCtrlBlockAckEnableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__)
187
188/*******************************************************************************
189
190 NAME
191 CsrWifiRouterCtrlBlockAckEnableCfmSend
192
193 DESCRIPTION
194
195 PARAMETERS
196 queue - Destination Task Queue
197 clientData -
198 interfaceTag -
199 status -
200
201*******************************************************************************/
202#define CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
203 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL); \
204 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, dst__, src__); \
205 msg__->clientData = (clientData__); \
206 msg__->interfaceTag = (interfaceTag__); \
207 msg__->status = (status__);
208
209#define CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
210 { \
211 CsrWifiRouterCtrlBlockAckEnableCfm *msg__; \
212 CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
213 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
214 }
215
216#define CsrWifiRouterCtrlBlockAckEnableCfmSend(dst__, clientData__, interfaceTag__, status__) \
217 CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
218
219/*******************************************************************************
220
221 NAME
222 CsrWifiRouterCtrlBlockAckErrorIndSend
223
224 DESCRIPTION
225
226 PARAMETERS
227 queue - Destination Task Queue
228 clientData -
229 interfaceTag -
230 trafficStreamID -
231 peerMacAddress -
232 status -
233
234*******************************************************************************/
235#define CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
236 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL); \
237 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, dst__, src__); \
238 msg__->clientData = (clientData__); \
239 msg__->interfaceTag = (interfaceTag__); \
240 msg__->trafficStreamID = (trafficStreamID__); \
241 msg__->peerMacAddress = (peerMacAddress__); \
242 msg__->status = (status__);
243
244#define CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
245 { \
246 CsrWifiRouterCtrlBlockAckErrorInd *msg__; \
247 CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__); \
248 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
249 }
250
251#define CsrWifiRouterCtrlBlockAckErrorIndSend(dst__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
252 CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__)
253
254/*******************************************************************************
255
256 NAME
257 CsrWifiRouterCtrlCapabilitiesReqSend
258
259 DESCRIPTION
260
261 PARAMETERS
262 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
263 clientData -
264
265*******************************************************************************/
266#define CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__) \
267 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesReq), GFP_KERNEL); \
268 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, dst__, src__); \
269 msg__->clientData = (clientData__);
270
271#define CsrWifiRouterCtrlCapabilitiesReqSendTo(dst__, src__, clientData__) \
272 { \
273 CsrWifiRouterCtrlCapabilitiesReq *msg__; \
274 CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__); \
275 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
276 }
277
278#define CsrWifiRouterCtrlCapabilitiesReqSend(src__, clientData__) \
279 CsrWifiRouterCtrlCapabilitiesReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
280
281/*******************************************************************************
282
283 NAME
284 CsrWifiRouterCtrlCapabilitiesCfmSend
285
286 DESCRIPTION
287 The router sends this primitive to confirm the size of the queues of the
288 HIP.
289
290 PARAMETERS
291 queue - Destination Task Queue
292 clientData -
293 commandQueueSize - Size of command queue
294 trafficQueueSize - Size of traffic queue (per AC)
295
296*******************************************************************************/
297#define CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \
298 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL); \
299 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, dst__, src__); \
300 msg__->clientData = (clientData__); \
301 msg__->commandQueueSize = (commandQueueSize__); \
302 msg__->trafficQueueSize = (trafficQueueSize__);
303
304#define CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \
305 { \
306 CsrWifiRouterCtrlCapabilitiesCfm *msg__; \
307 CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__); \
308 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
309 }
310
311#define CsrWifiRouterCtrlCapabilitiesCfmSend(dst__, clientData__, commandQueueSize__, trafficQueueSize__) \
312 CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, commandQueueSize__, trafficQueueSize__)
313
314/*******************************************************************************
315
316 NAME
317 CsrWifiRouterCtrlConfigurePowerModeReqSend
318
319 DESCRIPTION
320
321 PARAMETERS
322 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
323 clientData -
324 mode -
325 wakeHost -
326
327*******************************************************************************/
328#define CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__) \
329 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL); \
330 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, dst__, src__); \
331 msg__->clientData = (clientData__); \
332 msg__->mode = (mode__); \
333 msg__->wakeHost = (wakeHost__);
334
335#define CsrWifiRouterCtrlConfigurePowerModeReqSendTo(dst__, src__, clientData__, mode__, wakeHost__) \
336 { \
337 CsrWifiRouterCtrlConfigurePowerModeReq *msg__; \
338 CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__); \
339 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
340 }
341
342#define CsrWifiRouterCtrlConfigurePowerModeReqSend(src__, clientData__, mode__, wakeHost__) \
343 CsrWifiRouterCtrlConfigurePowerModeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, mode__, wakeHost__)
344
345/*******************************************************************************
346
347 NAME
348 CsrWifiRouterCtrlConnectedIndSend
349
350 DESCRIPTION
351
352 PARAMETERS
353 queue - Destination Task Queue
354 clientData -
355 interfaceTag -
356 peerMacAddress -
357 peerStatus -
358
359*******************************************************************************/
360#define CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
361 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL); \
362 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, dst__, src__); \
363 msg__->clientData = (clientData__); \
364 msg__->interfaceTag = (interfaceTag__); \
365 msg__->peerMacAddress = (peerMacAddress__); \
366 msg__->peerStatus = (peerStatus__);
367
368#define CsrWifiRouterCtrlConnectedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
369 { \
370 CsrWifiRouterCtrlConnectedInd *msg__; \
371 CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__); \
372 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
373 }
374
375#define CsrWifiRouterCtrlConnectedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
376 CsrWifiRouterCtrlConnectedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerStatus__)
377
378/*******************************************************************************
379
380 NAME
381 CsrWifiRouterCtrlHipReqSend
382
383 DESCRIPTION
384 This primitive is used for transferring MLME messages to the HIP.
385
386 PARAMETERS
387 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
388 mlmeCommandLength - Length of the MLME signal
389 mlmeCommand - Pointer to the MLME signal
390 dataRef1Length - Length of the dataRef1 bulk data
391 dataRef1 - Pointer to the bulk data 1
392 dataRef2Length - Length of the dataRef2 bulk data
393 dataRef2 - Pointer to the bulk data 2
394
395*******************************************************************************/
396#define CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
397 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL); \
398 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_REQ, dst__, src__); \
399 msg__->mlmeCommandLength = (mlmeCommandLength__); \
400 msg__->mlmeCommand = (mlmeCommand__); \
401 msg__->dataRef1Length = (dataRef1Length__); \
402 msg__->dataRef1 = (dataRef1__); \
403 msg__->dataRef2Length = (dataRef2Length__); \
404 msg__->dataRef2 = (dataRef2__);
405
406#define CsrWifiRouterCtrlHipReqSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
407 { \
408 CsrWifiRouterCtrlHipReq *msg__; \
409 CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \
410 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
411 }
412
413#define CsrWifiRouterCtrlHipReqSend(src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
414 CsrWifiRouterCtrlHipReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__)
415
416/*******************************************************************************
417
418 NAME
419 CsrWifiRouterCtrlHipIndSend
420
421 DESCRIPTION
422 This primitive is used for transferring MLME messages from the HIP.
423
424 PARAMETERS
425 queue - Destination Task Queue
426 mlmeCommandLength - Length of the MLME signal
427 mlmeCommand - Pointer to the MLME signal
428 dataRef1Length - Length of the dataRef1 bulk data
429 dataRef1 - Pointer to the bulk data 1
430 dataRef2Length - Length of the dataRef2 bulk data
431 dataRef2 - Pointer to the bulk data 2
432
433*******************************************************************************/
434#define CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
435 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL); \
436 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_IND, dst__, src__); \
437 msg__->mlmeCommandLength = (mlmeCommandLength__); \
438 msg__->mlmeCommand = (mlmeCommand__); \
439 msg__->dataRef1Length = (dataRef1Length__); \
440 msg__->dataRef1 = (dataRef1__); \
441 msg__->dataRef2Length = (dataRef2Length__); \
442 msg__->dataRef2 = (dataRef2__);
443
444#define CsrWifiRouterCtrlHipIndSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
445 { \
446 CsrWifiRouterCtrlHipInd *msg__; \
447 CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \
448 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
449 }
450
451#define CsrWifiRouterCtrlHipIndSend(dst__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
452 CsrWifiRouterCtrlHipIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__)
453
454/*******************************************************************************
455
456 NAME
457 CsrWifiRouterCtrlM4ReadyToSendIndSend
458
459 DESCRIPTION
460
461 PARAMETERS
462 queue - Destination Task Queue
463 clientData -
464 interfaceTag -
465 peerMacAddress -
466
467*******************************************************************************/
468#define CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
469 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL); \
470 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, dst__, src__); \
471 msg__->clientData = (clientData__); \
472 msg__->interfaceTag = (interfaceTag__); \
473 msg__->peerMacAddress = (peerMacAddress__);
474
475#define CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
476 { \
477 CsrWifiRouterCtrlM4ReadyToSendInd *msg__; \
478 CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \
479 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
480 }
481
482#define CsrWifiRouterCtrlM4ReadyToSendIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \
483 CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__)
484
485/*******************************************************************************
486
487 NAME
488 CsrWifiRouterCtrlM4TransmitReqSend
489
490 DESCRIPTION
491
492 PARAMETERS
493 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
494 interfaceTag -
495 clientData -
496
497*******************************************************************************/
498#define CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__) \
499 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL); \
500 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, dst__, src__); \
501 msg__->interfaceTag = (interfaceTag__); \
502 msg__->clientData = (clientData__);
503
504#define CsrWifiRouterCtrlM4TransmitReqSendTo(dst__, src__, interfaceTag__, clientData__) \
505 { \
506 CsrWifiRouterCtrlM4TransmitReq *msg__; \
507 CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__); \
508 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
509 }
510
511#define CsrWifiRouterCtrlM4TransmitReqSend(src__, interfaceTag__, clientData__) \
512 CsrWifiRouterCtrlM4TransmitReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__)
513
514/*******************************************************************************
515
516 NAME
517 CsrWifiRouterCtrlM4TransmittedIndSend
518
519 DESCRIPTION
520
521 PARAMETERS
522 queue - Destination Task Queue
523 clientData -
524 interfaceTag -
525 peerMacAddress -
526 status -
527
528*******************************************************************************/
529#define CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \
530 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL); \
531 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, dst__, src__); \
532 msg__->clientData = (clientData__); \
533 msg__->interfaceTag = (interfaceTag__); \
534 msg__->peerMacAddress = (peerMacAddress__); \
535 msg__->status = (status__);
536
537#define CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \
538 { \
539 CsrWifiRouterCtrlM4TransmittedInd *msg__; \
540 CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__); \
541 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
542 }
543
544#define CsrWifiRouterCtrlM4TransmittedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, status__) \
545 CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, status__)
546
547/*******************************************************************************
548
549 NAME
550 CsrWifiRouterCtrlMediaStatusReqSend
551
552 DESCRIPTION
553
554 PARAMETERS
555 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
556 interfaceTag -
557 clientData -
558 mediaStatus -
559
560*******************************************************************************/
561#define CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__) \
562 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL); \
563 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, dst__, src__); \
564 msg__->interfaceTag = (interfaceTag__); \
565 msg__->clientData = (clientData__); \
566 msg__->mediaStatus = (mediaStatus__);
567
568#define CsrWifiRouterCtrlMediaStatusReqSendTo(dst__, src__, interfaceTag__, clientData__, mediaStatus__) \
569 { \
570 CsrWifiRouterCtrlMediaStatusReq *msg__; \
571 CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__); \
572 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
573 }
574
575#define CsrWifiRouterCtrlMediaStatusReqSend(src__, interfaceTag__, clientData__, mediaStatus__) \
576 CsrWifiRouterCtrlMediaStatusReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mediaStatus__)
577
578/*******************************************************************************
579
580 NAME
581 CsrWifiRouterCtrlMicFailureIndSend
582
583 DESCRIPTION
584
585 PARAMETERS
586 queue - Destination Task Queue
587 clientData -
588 interfaceTag -
589 peerMacAddress -
590 unicastPdu -
591
592*******************************************************************************/
593#define CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
594 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL); \
595 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, dst__, src__); \
596 msg__->clientData = (clientData__); \
597 msg__->interfaceTag = (interfaceTag__); \
598 msg__->peerMacAddress = (peerMacAddress__); \
599 msg__->unicastPdu = (unicastPdu__);
600
601#define CsrWifiRouterCtrlMicFailureIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
602 { \
603 CsrWifiRouterCtrlMicFailureInd *msg__; \
604 CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__); \
605 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
606 }
607
608#define CsrWifiRouterCtrlMicFailureIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
609 CsrWifiRouterCtrlMicFailureIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__)
610
611/*******************************************************************************
612
613 NAME
614 CsrWifiRouterCtrlModeSetReqSend
615
616 DESCRIPTION
617
618 PARAMETERS
619 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
620 interfaceTag -
621 clientData -
622 mode -
623 bssid - BSSID of the network the device is going to be a part
624 of
625 protection - Set to TRUE if encryption is enabled for the
626 connection/broadcast frames
627 intraBssDistEnabled - If set to TRUE, intra BSS destribution will be
628 enabled. If set to FALSE, any unicast PDU which does
629 not have the RA as the the local MAC address, shall be
630 ignored. This field is interpreted by the receive if
631 mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
632
633*******************************************************************************/
634#define CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
635 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL); \
636 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, dst__, src__); \
637 msg__->interfaceTag = (interfaceTag__); \
638 msg__->clientData = (clientData__); \
639 msg__->mode = (mode__); \
640 msg__->bssid = (bssid__); \
641 msg__->protection = (protection__); \
642 msg__->intraBssDistEnabled = (intraBssDistEnabled__);
643
644#define CsrWifiRouterCtrlModeSetReqSendTo(dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
645 { \
646 CsrWifiRouterCtrlModeSetReq *msg__; \
647 CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__); \
648 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
649 }
650
651#define CsrWifiRouterCtrlModeSetReqSend(src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
652 CsrWifiRouterCtrlModeSetReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__)
653
654/*******************************************************************************
655
656 NAME
657 CsrWifiRouterCtrlModeSetCfmSend
658
659 DESCRIPTION
660
661 PARAMETERS
662 queue - Destination Task Queue
663 clientData -
664 interfaceTag -
665 mode -
666 status -
667
668*******************************************************************************/
669#define CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__) \
670 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL); \
671 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, dst__, src__); \
672 msg__->clientData = (clientData__); \
673 msg__->interfaceTag = (interfaceTag__); \
674 msg__->mode = (mode__); \
675 msg__->status = (status__);
676
677#define CsrWifiRouterCtrlModeSetCfmSendTo(dst__, src__, clientData__, interfaceTag__, mode__, status__) \
678 { \
679 CsrWifiRouterCtrlModeSetCfm *msg__; \
680 CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__); \
681 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
682 }
683
684#define CsrWifiRouterCtrlModeSetCfmSend(dst__, clientData__, interfaceTag__, mode__, status__) \
685 CsrWifiRouterCtrlModeSetCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, mode__, status__)
686
687/*******************************************************************************
688
689 NAME
690 CsrWifiRouterCtrlMulticastAddressIndSend
691
692 DESCRIPTION
693
694 PARAMETERS
695 queue - Destination Task Queue
696 clientData -
697 interfaceTag -
698 action -
699 setAddressesCount -
700 setAddresses -
701
702*******************************************************************************/
703#define CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
704 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL); \
705 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, dst__, src__); \
706 msg__->clientData = (clientData__); \
707 msg__->interfaceTag = (interfaceTag__); \
708 msg__->action = (action__); \
709 msg__->setAddressesCount = (setAddressesCount__); \
710 msg__->setAddresses = (setAddresses__);
711
712#define CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
713 { \
714 CsrWifiRouterCtrlMulticastAddressInd *msg__; \
715 CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \
716 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
717 }
718
719#define CsrWifiRouterCtrlMulticastAddressIndSend(dst__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
720 CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__)
721
722/*******************************************************************************
723
724 NAME
725 CsrWifiRouterCtrlMulticastAddressResSend
726
727 DESCRIPTION
728
729 PARAMETERS
730 interfaceTag -
731 clientData -
732 status -
733 action -
734 getAddressesCount -
735 getAddresses -
736
737*******************************************************************************/
738#define CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
739 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL); \
740 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, dst__, src__); \
741 msg__->interfaceTag = (interfaceTag__); \
742 msg__->clientData = (clientData__); \
743 msg__->status = (status__); \
744 msg__->action = (action__); \
745 msg__->getAddressesCount = (getAddressesCount__); \
746 msg__->getAddresses = (getAddresses__);
747
748#define CsrWifiRouterCtrlMulticastAddressResSendTo(dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
749 { \
750 CsrWifiRouterCtrlMulticastAddressRes *msg__; \
751 CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__); \
752 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
753 }
754
755#define CsrWifiRouterCtrlMulticastAddressResSend(src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
756 CsrWifiRouterCtrlMulticastAddressResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__)
757
758/*******************************************************************************
759
760 NAME
761 CsrWifiRouterCtrlPeerAddReqSend
762
763 DESCRIPTION
764
765 PARAMETERS
766 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
767 interfaceTag -
768 clientData -
769 peerMacAddress -
770 associationId -
771 staInfo -
772
773*******************************************************************************/
774#define CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
775 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL); \
776 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, dst__, src__); \
777 msg__->interfaceTag = (interfaceTag__); \
778 msg__->clientData = (clientData__); \
779 msg__->peerMacAddress = (peerMacAddress__); \
780 msg__->associationId = (associationId__); \
781 msg__->staInfo = (staInfo__);
782
783#define CsrWifiRouterCtrlPeerAddReqSendTo(dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
784 { \
785 CsrWifiRouterCtrlPeerAddReq *msg__; \
786 CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__); \
787 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
788 }
789
790#define CsrWifiRouterCtrlPeerAddReqSend(src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
791 CsrWifiRouterCtrlPeerAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__)
792
793/*******************************************************************************
794
795 NAME
796 CsrWifiRouterCtrlPeerAddCfmSend
797
798 DESCRIPTION
799
800 PARAMETERS
801 queue - Destination Task Queue
802 clientData -
803 interfaceTag -
804 peerMacAddress -
805 peerRecordHandle -
806 status -
807
808*******************************************************************************/
809#define CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
810 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL); \
811 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, dst__, src__); \
812 msg__->clientData = (clientData__); \
813 msg__->interfaceTag = (interfaceTag__); \
814 msg__->peerMacAddress = (peerMacAddress__); \
815 msg__->peerRecordHandle = (peerRecordHandle__); \
816 msg__->status = (status__);
817
818#define CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
819 { \
820 CsrWifiRouterCtrlPeerAddCfm *msg__; \
821 CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__); \
822 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
823 }
824
825#define CsrWifiRouterCtrlPeerAddCfmSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
826 CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__)
827
828/*******************************************************************************
829
830 NAME
831 CsrWifiRouterCtrlPeerDelReqSend
832
833 DESCRIPTION
834
835 PARAMETERS
836 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
837 interfaceTag -
838 clientData -
839 peerRecordHandle -
840
841*******************************************************************************/
842#define CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \
843 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL); \
844 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, dst__, src__); \
845 msg__->interfaceTag = (interfaceTag__); \
846 msg__->clientData = (clientData__); \
847 msg__->peerRecordHandle = (peerRecordHandle__);
848
849#define CsrWifiRouterCtrlPeerDelReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \
850 { \
851 CsrWifiRouterCtrlPeerDelReq *msg__; \
852 CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__); \
853 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
854 }
855
856#define CsrWifiRouterCtrlPeerDelReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__) \
857 CsrWifiRouterCtrlPeerDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__)
858
859/*******************************************************************************
860
861 NAME
862 CsrWifiRouterCtrlPeerDelCfmSend
863
864 DESCRIPTION
865
866 PARAMETERS
867 queue - Destination Task Queue
868 clientData -
869 interfaceTag -
870 status -
871
872*******************************************************************************/
873#define CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
874 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL); \
875 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, dst__, src__); \
876 msg__->clientData = (clientData__); \
877 msg__->interfaceTag = (interfaceTag__); \
878 msg__->status = (status__);
879
880#define CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
881 { \
882 CsrWifiRouterCtrlPeerDelCfm *msg__; \
883 CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
884 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
885 }
886
887#define CsrWifiRouterCtrlPeerDelCfmSend(dst__, clientData__, interfaceTag__, status__) \
888 CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
889
890/*******************************************************************************
891
892 NAME
893 CsrWifiRouterCtrlPeerUpdateReqSend
894
895 DESCRIPTION
896
897 PARAMETERS
898 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
899 interfaceTag -
900 clientData -
901 peerRecordHandle -
902 powersaveMode -
903
904*******************************************************************************/
905#define CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
906 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL); \
907 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, dst__, src__); \
908 msg__->interfaceTag = (interfaceTag__); \
909 msg__->clientData = (clientData__); \
910 msg__->peerRecordHandle = (peerRecordHandle__); \
911 msg__->powersaveMode = (powersaveMode__);
912
913#define CsrWifiRouterCtrlPeerUpdateReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
914 { \
915 CsrWifiRouterCtrlPeerUpdateReq *msg__; \
916 CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__); \
917 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
918 }
919
920#define CsrWifiRouterCtrlPeerUpdateReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
921 CsrWifiRouterCtrlPeerUpdateReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__)
922
923/*******************************************************************************
924
925 NAME
926 CsrWifiRouterCtrlPeerUpdateCfmSend
927
928 DESCRIPTION
929
930 PARAMETERS
931 queue - Destination Task Queue
932 clientData -
933 interfaceTag -
934 status -
935
936*******************************************************************************/
937#define CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
938 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL); \
939 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, dst__, src__); \
940 msg__->clientData = (clientData__); \
941 msg__->interfaceTag = (interfaceTag__); \
942 msg__->status = (status__);
943
944#define CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
945 { \
946 CsrWifiRouterCtrlPeerUpdateCfm *msg__; \
947 CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
948 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
949 }
950
951#define CsrWifiRouterCtrlPeerUpdateCfmSend(dst__, clientData__, interfaceTag__, status__) \
952 CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
953
954/*******************************************************************************
955
956 NAME
957 CsrWifiRouterCtrlPortConfigureReqSend
958
959 DESCRIPTION
960
961 PARAMETERS
962 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
963 interfaceTag -
964 clientData -
965 uncontrolledPortAction -
966 controlledPortAction -
967 macAddress -
968 setProtection -
969
970*******************************************************************************/
971#define CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
972 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL); \
973 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, dst__, src__); \
974 msg__->interfaceTag = (interfaceTag__); \
975 msg__->clientData = (clientData__); \
976 msg__->uncontrolledPortAction = (uncontrolledPortAction__); \
977 msg__->controlledPortAction = (controlledPortAction__); \
978 msg__->macAddress = (macAddress__); \
979 msg__->setProtection = (setProtection__);
980
981#define CsrWifiRouterCtrlPortConfigureReqSendTo(dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
982 { \
983 CsrWifiRouterCtrlPortConfigureReq *msg__; \
984 CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__); \
985 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
986 }
987
988#define CsrWifiRouterCtrlPortConfigureReqSend(src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
989 CsrWifiRouterCtrlPortConfigureReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__)
990
991/*******************************************************************************
992
993 NAME
994 CsrWifiRouterCtrlPortConfigureCfmSend
995
996 DESCRIPTION
997
998 PARAMETERS
999 queue - Destination Task Queue
1000 clientData -
1001 interfaceTag -
1002 status -
1003 macAddress -
1004
1005*******************************************************************************/
1006#define CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \
1007 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL); \
1008 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, dst__, src__); \
1009 msg__->clientData = (clientData__); \
1010 msg__->interfaceTag = (interfaceTag__); \
1011 msg__->status = (status__); \
1012 msg__->macAddress = (macAddress__);
1013
1014#define CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \
1015 { \
1016 CsrWifiRouterCtrlPortConfigureCfm *msg__; \
1017 CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__); \
1018 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1019 }
1020
1021#define CsrWifiRouterCtrlPortConfigureCfmSend(dst__, clientData__, interfaceTag__, status__, macAddress__) \
1022 CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__, macAddress__)
1023
1024/*******************************************************************************
1025
1026 NAME
1027 CsrWifiRouterCtrlQosControlReqSend
1028
1029 DESCRIPTION
1030
1031 PARAMETERS
1032 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1033 interfaceTag -
1034 clientData -
1035 control -
1036 queueConfig -
1037
1038*******************************************************************************/
1039#define CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \
1040 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL); \
1041 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, dst__, src__); \
1042 msg__->interfaceTag = (interfaceTag__); \
1043 msg__->clientData = (clientData__); \
1044 msg__->control = (control__); \
1045 msg__->queueConfig = (queueConfig__);
1046
1047#define CsrWifiRouterCtrlQosControlReqSendTo(dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \
1048 { \
1049 CsrWifiRouterCtrlQosControlReq *msg__; \
1050 CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__); \
1051 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1052 }
1053
1054#define CsrWifiRouterCtrlQosControlReqSend(src__, interfaceTag__, clientData__, control__, queueConfig__) \
1055 CsrWifiRouterCtrlQosControlReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, control__, queueConfig__)
1056
1057/*******************************************************************************
1058
1059 NAME
1060 CsrWifiRouterCtrlRawSdioDeinitialiseReqSend
1061
1062 DESCRIPTION
1063
1064 PARAMETERS
1065 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1066 clientData -
1067
1068*******************************************************************************/
1069#define CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__) \
1070 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseReq), GFP_KERNEL); \
1071 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, dst__, src__); \
1072 msg__->clientData = (clientData__);
1073
1074#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(dst__, src__, clientData__) \
1075 { \
1076 CsrWifiRouterCtrlRawSdioDeinitialiseReq *msg__; \
1077 CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__); \
1078 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1079 }
1080
1081#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSend(src__, clientData__) \
1082 CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
1083
1084/*******************************************************************************
1085
1086 NAME
1087 CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend
1088
1089 DESCRIPTION
1090
1091 PARAMETERS
1092 queue - Destination Task Queue
1093 clientData -
1094 result -
1095
1096*******************************************************************************/
1097#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__) \
1098 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL); \
1099 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, dst__, src__); \
1100 msg__->clientData = (clientData__); \
1101 msg__->result = (result__);
1102
1103#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, src__, clientData__, result__) \
1104 { \
1105 CsrWifiRouterCtrlRawSdioDeinitialiseCfm *msg__; \
1106 CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__); \
1107 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1108 }
1109
1110#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend(dst__, clientData__, result__) \
1111 CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__)
1112
1113/*******************************************************************************
1114
1115 NAME
1116 CsrWifiRouterCtrlRawSdioInitialiseReqSend
1117
1118 DESCRIPTION
1119
1120 PARAMETERS
1121 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1122 clientData -
1123
1124*******************************************************************************/
1125#define CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__) \
1126 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseReq), GFP_KERNEL); \
1127 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, dst__, src__); \
1128 msg__->clientData = (clientData__);
1129
1130#define CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(dst__, src__, clientData__) \
1131 { \
1132 CsrWifiRouterCtrlRawSdioInitialiseReq *msg__; \
1133 CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__); \
1134 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1135 }
1136
1137#define CsrWifiRouterCtrlRawSdioInitialiseReqSend(src__, clientData__) \
1138 CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
1139
1140/*******************************************************************************
1141
1142 NAME
1143 CsrWifiRouterCtrlRawSdioInitialiseCfmSend
1144
1145 DESCRIPTION
1146
1147 PARAMETERS
1148 queue - Destination Task Queue
1149 clientData -
1150 result -
1151 byteRead -
1152 byteWrite -
1153 firmwareDownload -
1154 reset -
1155 coreDumpPrepare -
1156 byteBlockRead -
1157 gpRead16 -
1158 gpWrite16 -
1159
1160*******************************************************************************/
1161#define CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
1162 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL); \
1163 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, dst__, src__); \
1164 msg__->clientData = (clientData__); \
1165 msg__->result = (result__); \
1166 msg__->byteRead = (byteRead__); \
1167 msg__->byteWrite = (byteWrite__); \
1168 msg__->firmwareDownload = (firmwareDownload__); \
1169 msg__->reset = (reset__); \
1170 msg__->coreDumpPrepare = (coreDumpPrepare__); \
1171 msg__->byteBlockRead = (byteBlockRead__); \
1172 msg__->gpRead16 = (gpRead16__); \
1173 msg__->gpWrite16 = (gpWrite16__);
1174
1175#define CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
1176 { \
1177 CsrWifiRouterCtrlRawSdioInitialiseCfm *msg__; \
1178 CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__); \
1179 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1180 }
1181
1182#define CsrWifiRouterCtrlRawSdioInitialiseCfmSend(dst__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
1183 CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__)
1184
1185/*******************************************************************************
1186
1187 NAME
1188 CsrWifiRouterCtrlResumeIndSend
1189
1190 DESCRIPTION
1191
1192 PARAMETERS
1193 queue - Destination Task Queue
1194 clientData -
1195 powerMaintained -
1196
1197*******************************************************************************/
1198#define CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__) \
1199 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeInd), GFP_KERNEL); \
1200 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_IND, dst__, src__); \
1201 msg__->clientData = (clientData__); \
1202 msg__->powerMaintained = (powerMaintained__);
1203
1204#define CsrWifiRouterCtrlResumeIndSendTo(dst__, src__, clientData__, powerMaintained__) \
1205 { \
1206 CsrWifiRouterCtrlResumeInd *msg__; \
1207 CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__); \
1208 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1209 }
1210
1211#define CsrWifiRouterCtrlResumeIndSend(dst__, clientData__, powerMaintained__) \
1212 CsrWifiRouterCtrlResumeIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, powerMaintained__)
1213
1214/*******************************************************************************
1215
1216 NAME
1217 CsrWifiRouterCtrlResumeResSend
1218
1219 DESCRIPTION
1220
1221 PARAMETERS
1222 clientData -
1223 status -
1224
1225*******************************************************************************/
1226#define CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__) \
1227 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL); \
1228 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_RES, dst__, src__); \
1229 msg__->clientData = (clientData__); \
1230 msg__->status = (status__);
1231
1232#define CsrWifiRouterCtrlResumeResSendTo(dst__, src__, clientData__, status__) \
1233 { \
1234 CsrWifiRouterCtrlResumeRes *msg__; \
1235 CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__); \
1236 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1237 }
1238
1239#define CsrWifiRouterCtrlResumeResSend(src__, clientData__, status__) \
1240 CsrWifiRouterCtrlResumeResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__)
1241
1242/*******************************************************************************
1243
1244 NAME
1245 CsrWifiRouterCtrlStaInactiveIndSend
1246
1247 DESCRIPTION
1248
1249 PARAMETERS
1250 queue - Destination Task Queue
1251 clientData -
1252 interfaceTag -
1253 staAddress -
1254
1255*******************************************************************************/
1256#define CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__) \
1257 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL); \
1258 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, dst__, src__); \
1259 msg__->clientData = (clientData__); \
1260 msg__->interfaceTag = (interfaceTag__); \
1261 msg__->staAddress = (staAddress__);
1262
1263#define CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, src__, clientData__, interfaceTag__, staAddress__) \
1264 { \
1265 CsrWifiRouterCtrlStaInactiveInd *msg__; \
1266 CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__); \
1267 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1268 }
1269
1270#define CsrWifiRouterCtrlStaInactiveIndSend(dst__, clientData__, interfaceTag__, staAddress__) \
1271 CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, staAddress__)
1272
1273/*******************************************************************************
1274
1275 NAME
1276 CsrWifiRouterCtrlSuspendIndSend
1277
1278 DESCRIPTION
1279
1280 PARAMETERS
1281 queue - Destination Task Queue
1282 clientData -
1283 hardSuspend -
1284 d3Suspend -
1285
1286*******************************************************************************/
1287#define CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__) \
1288 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL); \
1289 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, dst__, src__); \
1290 msg__->clientData = (clientData__); \
1291 msg__->hardSuspend = (hardSuspend__); \
1292 msg__->d3Suspend = (d3Suspend__);
1293
1294#define CsrWifiRouterCtrlSuspendIndSendTo(dst__, src__, clientData__, hardSuspend__, d3Suspend__) \
1295 { \
1296 CsrWifiRouterCtrlSuspendInd *msg__; \
1297 CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__); \
1298 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1299 }
1300
1301#define CsrWifiRouterCtrlSuspendIndSend(dst__, clientData__, hardSuspend__, d3Suspend__) \
1302 CsrWifiRouterCtrlSuspendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, hardSuspend__, d3Suspend__)
1303
1304/*******************************************************************************
1305
1306 NAME
1307 CsrWifiRouterCtrlSuspendResSend
1308
1309 DESCRIPTION
1310
1311 PARAMETERS
1312 clientData -
1313 status -
1314
1315*******************************************************************************/
1316#define CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__) \
1317 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL); \
1318 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, dst__, src__); \
1319 msg__->clientData = (clientData__); \
1320 msg__->status = (status__);
1321
1322#define CsrWifiRouterCtrlSuspendResSendTo(dst__, src__, clientData__, status__) \
1323 { \
1324 CsrWifiRouterCtrlSuspendRes *msg__; \
1325 CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__); \
1326 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1327 }
1328
1329#define CsrWifiRouterCtrlSuspendResSend(src__, clientData__, status__) \
1330 CsrWifiRouterCtrlSuspendResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__)
1331
1332/*******************************************************************************
1333
1334 NAME
1335 CsrWifiRouterCtrlTclasAddReqSend
1336
1337 DESCRIPTION
1338
1339 PARAMETERS
1340 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1341 interfaceTag -
1342 clientData -
1343 tclasLength -
1344 tclas -
1345
1346*******************************************************************************/
1347#define CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
1348 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL); \
1349 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, dst__, src__); \
1350 msg__->interfaceTag = (interfaceTag__); \
1351 msg__->clientData = (clientData__); \
1352 msg__->tclasLength = (tclasLength__); \
1353 msg__->tclas = (tclas__);
1354
1355#define CsrWifiRouterCtrlTclasAddReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
1356 { \
1357 CsrWifiRouterCtrlTclasAddReq *msg__; \
1358 CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \
1359 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1360 }
1361
1362#define CsrWifiRouterCtrlTclasAddReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
1363 CsrWifiRouterCtrlTclasAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__)
1364
1365/*******************************************************************************
1366
1367 NAME
1368 CsrWifiRouterCtrlTclasAddCfmSend
1369
1370 DESCRIPTION
1371
1372 PARAMETERS
1373 queue - Destination Task Queue
1374 clientData -
1375 interfaceTag -
1376 status -
1377
1378*******************************************************************************/
1379#define CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
1380 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL); \
1381 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, dst__, src__); \
1382 msg__->clientData = (clientData__); \
1383 msg__->interfaceTag = (interfaceTag__); \
1384 msg__->status = (status__);
1385
1386#define CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
1387 { \
1388 CsrWifiRouterCtrlTclasAddCfm *msg__; \
1389 CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
1390 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1391 }
1392
1393#define CsrWifiRouterCtrlTclasAddCfmSend(dst__, clientData__, interfaceTag__, status__) \
1394 CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
1395
1396/*******************************************************************************
1397
1398 NAME
1399 CsrWifiRouterCtrlTclasDelReqSend
1400
1401 DESCRIPTION
1402
1403 PARAMETERS
1404 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1405 interfaceTag -
1406 clientData -
1407 tclasLength -
1408 tclas -
1409
1410*******************************************************************************/
1411#define CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
1412 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL); \
1413 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, dst__, src__); \
1414 msg__->interfaceTag = (interfaceTag__); \
1415 msg__->clientData = (clientData__); \
1416 msg__->tclasLength = (tclasLength__); \
1417 msg__->tclas = (tclas__);
1418
1419#define CsrWifiRouterCtrlTclasDelReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
1420 { \
1421 CsrWifiRouterCtrlTclasDelReq *msg__; \
1422 CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \
1423 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1424 }
1425
1426#define CsrWifiRouterCtrlTclasDelReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
1427 CsrWifiRouterCtrlTclasDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__)
1428
1429/*******************************************************************************
1430
1431 NAME
1432 CsrWifiRouterCtrlTclasDelCfmSend
1433
1434 DESCRIPTION
1435
1436 PARAMETERS
1437 queue - Destination Task Queue
1438 clientData -
1439 interfaceTag -
1440 status -
1441
1442*******************************************************************************/
1443#define CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
1444 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL); \
1445 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, dst__, src__); \
1446 msg__->clientData = (clientData__); \
1447 msg__->interfaceTag = (interfaceTag__); \
1448 msg__->status = (status__);
1449
1450#define CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
1451 { \
1452 CsrWifiRouterCtrlTclasDelCfm *msg__; \
1453 CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
1454 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1455 }
1456
1457#define CsrWifiRouterCtrlTclasDelCfmSend(dst__, clientData__, interfaceTag__, status__) \
1458 CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
1459
1460/*******************************************************************************
1461
1462 NAME
1463 CsrWifiRouterCtrlTrafficClassificationReqSend
1464
1465 DESCRIPTION
1466
1467 PARAMETERS
1468 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1469 interfaceTag -
1470 clientData -
1471 trafficType -
1472 period -
1473
1474*******************************************************************************/
1475#define CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \
1476 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL); \
1477 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, dst__, src__); \
1478 msg__->interfaceTag = (interfaceTag__); \
1479 msg__->clientData = (clientData__); \
1480 msg__->trafficType = (trafficType__); \
1481 msg__->period = (period__);
1482
1483#define CsrWifiRouterCtrlTrafficClassificationReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \
1484 { \
1485 CsrWifiRouterCtrlTrafficClassificationReq *msg__; \
1486 CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__); \
1487 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1488 }
1489
1490#define CsrWifiRouterCtrlTrafficClassificationReqSend(src__, interfaceTag__, clientData__, trafficType__, period__) \
1491 CsrWifiRouterCtrlTrafficClassificationReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficType__, period__)
1492
1493/*******************************************************************************
1494
1495 NAME
1496 CsrWifiRouterCtrlTrafficConfigReqSend
1497
1498 DESCRIPTION
1499
1500 PARAMETERS
1501 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1502 interfaceTag -
1503 clientData -
1504 trafficConfigType -
1505 config -
1506
1507*******************************************************************************/
1508#define CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
1509 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL); \
1510 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, dst__, src__); \
1511 msg__->interfaceTag = (interfaceTag__); \
1512 msg__->clientData = (clientData__); \
1513 msg__->trafficConfigType = (trafficConfigType__); \
1514 msg__->config = (config__);
1515
1516#define CsrWifiRouterCtrlTrafficConfigReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
1517 { \
1518 CsrWifiRouterCtrlTrafficConfigReq *msg__; \
1519 CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__); \
1520 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1521 }
1522
1523#define CsrWifiRouterCtrlTrafficConfigReqSend(src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
1524 CsrWifiRouterCtrlTrafficConfigReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficConfigType__, config__)
1525
1526/*******************************************************************************
1527
1528 NAME
1529 CsrWifiRouterCtrlTrafficProtocolIndSend
1530
1531 DESCRIPTION
1532
1533 PARAMETERS
1534 queue - Destination Task Queue
1535 clientData -
1536 interfaceTag -
1537 packetType -
1538 direction -
1539 srcAddress -
1540
1541*******************************************************************************/
1542#define CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
1543 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL); \
1544 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, dst__, src__); \
1545 msg__->clientData = (clientData__); \
1546 msg__->interfaceTag = (interfaceTag__); \
1547 msg__->packetType = (packetType__); \
1548 msg__->direction = (direction__); \
1549 msg__->srcAddress = (srcAddress__);
1550
1551#define CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
1552 { \
1553 CsrWifiRouterCtrlTrafficProtocolInd *msg__; \
1554 CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__); \
1555 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1556 }
1557
1558#define CsrWifiRouterCtrlTrafficProtocolIndSend(dst__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
1559 CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, packetType__, direction__, srcAddress__)
1560
1561/*******************************************************************************
1562
1563 NAME
1564 CsrWifiRouterCtrlTrafficSampleIndSend
1565
1566 DESCRIPTION
1567
1568 PARAMETERS
1569 queue - Destination Task Queue
1570 clientData -
1571 interfaceTag -
1572 stats -
1573
1574*******************************************************************************/
1575#define CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__) \
1576 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL); \
1577 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, dst__, src__); \
1578 msg__->clientData = (clientData__); \
1579 msg__->interfaceTag = (interfaceTag__); \
1580 msg__->stats = (stats__);
1581
1582#define CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, src__, clientData__, interfaceTag__, stats__) \
1583 { \
1584 CsrWifiRouterCtrlTrafficSampleInd *msg__; \
1585 CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__); \
1586 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1587 }
1588
1589#define CsrWifiRouterCtrlTrafficSampleIndSend(dst__, clientData__, interfaceTag__, stats__) \
1590 CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, stats__)
1591
1592/*******************************************************************************
1593
1594 NAME
1595 CsrWifiRouterCtrlUnexpectedFrameIndSend
1596
1597 DESCRIPTION
1598
1599 PARAMETERS
1600 queue - Destination Task Queue
1601 clientData -
1602 interfaceTag -
1603 peerMacAddress -
1604
1605*******************************************************************************/
1606#define CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
1607 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL); \
1608 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, dst__, src__); \
1609 msg__->clientData = (clientData__); \
1610 msg__->interfaceTag = (interfaceTag__); \
1611 msg__->peerMacAddress = (peerMacAddress__);
1612
1613#define CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
1614 { \
1615 CsrWifiRouterCtrlUnexpectedFrameInd *msg__; \
1616 CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \
1617 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1618 }
1619
1620#define CsrWifiRouterCtrlUnexpectedFrameIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \
1621 CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__)
1622
1623/*******************************************************************************
1624
1625 NAME
1626 CsrWifiRouterCtrlWapiFilterReqSend
1627
1628 DESCRIPTION
1629
1630 PARAMETERS
1631 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1632 interfaceTag -
1633 isWapiConnected -
1634
1635*******************************************************************************/
1636#define CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__) \
1637 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiFilterReq), GFP_KERNEL); \
1638 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, dst__, src__); \
1639 msg__->interfaceTag = (interfaceTag__); \
1640 msg__->isWapiConnected = (isWapiConnected__);
1641
1642#define CsrWifiRouterCtrlWapiFilterReqSendTo(dst__, src__, interfaceTag__, isWapiConnected__) \
1643 { \
1644 CsrWifiRouterCtrlWapiFilterReq *msg__; \
1645 CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__); \
1646 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1647 }
1648
1649#define CsrWifiRouterCtrlWapiFilterReqSend(src__, interfaceTag__, isWapiConnected__) \
1650 CsrWifiRouterCtrlWapiFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, isWapiConnected__)
1651
1652/*******************************************************************************
1653
1654 NAME
1655 CsrWifiRouterCtrlWapiMulticastFilterReqSend
1656
1657 DESCRIPTION
1658
1659 PARAMETERS
1660 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1661 interfaceTag -
1662 status -
1663
1664*******************************************************************************/
1665#define CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \
1666 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiMulticastFilterReq), GFP_KERNEL); \
1667 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, dst__, src__); \
1668 msg__->interfaceTag = (interfaceTag__); \
1669 msg__->status = (status__);
1670
1671#define CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \
1672 { \
1673 CsrWifiRouterCtrlWapiMulticastFilterReq *msg__; \
1674 CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \
1675 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1676 }
1677
1678#define CsrWifiRouterCtrlWapiMulticastFilterReqSend(src__, interfaceTag__, status__) \
1679 CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__)
1680
1681/*******************************************************************************
1682
1683 NAME
1684 CsrWifiRouterCtrlWapiRxMicCheckIndSend
1685
1686 DESCRIPTION
1687
1688 PARAMETERS
1689 queue - Destination Task Queue
1690 clientData -
1691 interfaceTag -
1692 signalLength -
1693 signal -
1694 dataLength -
1695 data -
1696
1697*******************************************************************************/
1698#define CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
1699 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL); \
1700 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, dst__, src__); \
1701 msg__->clientData = (clientData__); \
1702 msg__->interfaceTag = (interfaceTag__); \
1703 msg__->signalLength = (signalLength__); \
1704 msg__->signal = (signal__); \
1705 msg__->dataLength = (dataLength__); \
1706 msg__->data = (data__);
1707
1708#define CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
1709 { \
1710 CsrWifiRouterCtrlWapiRxMicCheckInd *msg__; \
1711 CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \
1712 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1713 }
1714
1715#define CsrWifiRouterCtrlWapiRxMicCheckIndSend(dst__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
1716 CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__)
1717
1718/*******************************************************************************
1719
1720 NAME
1721 CsrWifiRouterCtrlWapiRxPktReqSend
1722
1723 DESCRIPTION
1724
1725 PARAMETERS
1726 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1727 interfaceTag -
1728 signalLength -
1729 signal -
1730 dataLength -
1731 data -
1732
1733*******************************************************************************/
1734#define CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
1735 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL); \
1736 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, dst__, src__); \
1737 msg__->interfaceTag = (interfaceTag__); \
1738 msg__->signalLength = (signalLength__); \
1739 msg__->signal = (signal__); \
1740 msg__->dataLength = (dataLength__); \
1741 msg__->data = (data__);
1742
1743#define CsrWifiRouterCtrlWapiRxPktReqSendTo(dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
1744 { \
1745 CsrWifiRouterCtrlWapiRxPktReq *msg__; \
1746 CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \
1747 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1748 }
1749
1750#define CsrWifiRouterCtrlWapiRxPktReqSend(src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
1751 CsrWifiRouterCtrlWapiRxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__)
1752
1753/*******************************************************************************
1754
1755 NAME
1756 CsrWifiRouterCtrlWapiUnicastFilterReqSend
1757
1758 DESCRIPTION
1759
1760 PARAMETERS
1761 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1762 interfaceTag -
1763 status -
1764
1765*******************************************************************************/
1766#define CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \
1767 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastFilterReq), GFP_KERNEL); \
1768 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, dst__, src__); \
1769 msg__->interfaceTag = (interfaceTag__); \
1770 msg__->status = (status__);
1771
1772#define CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \
1773 { \
1774 CsrWifiRouterCtrlWapiUnicastFilterReq *msg__; \
1775 CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \
1776 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1777 }
1778
1779#define CsrWifiRouterCtrlWapiUnicastFilterReqSend(src__, interfaceTag__, status__) \
1780 CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__)
1781
1782/*******************************************************************************
1783
1784 NAME
1785 CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend
1786
1787 DESCRIPTION
1788
1789 PARAMETERS
1790 queue - Destination Task Queue
1791 clientData -
1792 interfaceTag -
1793 dataLength -
1794 data -
1795
1796*******************************************************************************/
1797#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \
1798 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL); \
1799 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, dst__, src__); \
1800 msg__->clientData = (clientData__); \
1801 msg__->interfaceTag = (interfaceTag__); \
1802 msg__->dataLength = (dataLength__); \
1803 msg__->data = (data__);
1804
1805#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \
1806 { \
1807 CsrWifiRouterCtrlWapiUnicastTxEncryptInd *msg__; \
1808 CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__); \
1809 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1810 }
1811
1812#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(dst__, clientData__, interfaceTag__, dataLength__, data__) \
1813 CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, dataLength__, data__)
1814
1815/*******************************************************************************
1816
1817 NAME
1818 CsrWifiRouterCtrlWapiUnicastTxPktReqSend
1819
1820 DESCRIPTION
1821
1822 PARAMETERS
1823 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1824 interfaceTag -
1825 dataLength -
1826 data -
1827
1828*******************************************************************************/
1829#define CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__) \
1830 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL); \
1831 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, dst__, src__); \
1832 msg__->interfaceTag = (interfaceTag__); \
1833 msg__->dataLength = (dataLength__); \
1834 msg__->data = (data__);
1835
1836#define CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(dst__, src__, interfaceTag__, dataLength__, data__) \
1837 { \
1838 CsrWifiRouterCtrlWapiUnicastTxPktReq *msg__; \
1839 CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__); \
1840 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1841 }
1842
1843#define CsrWifiRouterCtrlWapiUnicastTxPktReqSend(src__, interfaceTag__, dataLength__, data__) \
1844 CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, dataLength__, data__)
1845
1846/*******************************************************************************
1847
1848 NAME
1849 CsrWifiRouterCtrlWifiOffReqSend
1850
1851 DESCRIPTION
1852
1853 PARAMETERS
1854 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1855 clientData -
1856
1857*******************************************************************************/
1858#define CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__) \
1859 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffReq), GFP_KERNEL); \
1860 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, dst__, src__); \
1861 msg__->clientData = (clientData__);
1862
1863#define CsrWifiRouterCtrlWifiOffReqSendTo(dst__, src__, clientData__) \
1864 { \
1865 CsrWifiRouterCtrlWifiOffReq *msg__; \
1866 CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__); \
1867 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1868 }
1869
1870#define CsrWifiRouterCtrlWifiOffReqSend(src__, clientData__) \
1871 CsrWifiRouterCtrlWifiOffReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
1872
1873/*******************************************************************************
1874
1875 NAME
1876 CsrWifiRouterCtrlWifiOffIndSend
1877
1878 DESCRIPTION
1879
1880 PARAMETERS
1881 queue - Destination Task Queue
1882 clientData -
1883 controlIndication -
1884
1885*******************************************************************************/
1886#define CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__) \
1887 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffInd), GFP_KERNEL); \
1888 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, dst__, src__); \
1889 msg__->clientData = (clientData__); \
1890 msg__->controlIndication = (controlIndication__);
1891
1892#define CsrWifiRouterCtrlWifiOffIndSendTo(dst__, src__, clientData__, controlIndication__) \
1893 { \
1894 CsrWifiRouterCtrlWifiOffInd *msg__; \
1895 CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__); \
1896 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1897 }
1898
1899#define CsrWifiRouterCtrlWifiOffIndSend(dst__, clientData__, controlIndication__) \
1900 CsrWifiRouterCtrlWifiOffIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, controlIndication__)
1901
1902/*******************************************************************************
1903
1904 NAME
1905 CsrWifiRouterCtrlWifiOffResSend
1906
1907 DESCRIPTION
1908
1909 PARAMETERS
1910 clientData -
1911
1912*******************************************************************************/
1913#define CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__) \
1914 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffRes), GFP_KERNEL); \
1915 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, dst__, src__); \
1916 msg__->clientData = (clientData__);
1917
1918#define CsrWifiRouterCtrlWifiOffResSendTo(dst__, src__, clientData__) \
1919 { \
1920 CsrWifiRouterCtrlWifiOffRes *msg__; \
1921 CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__); \
1922 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1923 }
1924
1925#define CsrWifiRouterCtrlWifiOffResSend(src__, clientData__) \
1926 CsrWifiRouterCtrlWifiOffResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
1927
1928/*******************************************************************************
1929
1930 NAME
1931 CsrWifiRouterCtrlWifiOffCfmSend
1932
1933 DESCRIPTION
1934
1935 PARAMETERS
1936 queue - Destination Task Queue
1937 clientData -
1938
1939*******************************************************************************/
1940#define CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__) \
1941 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffCfm), GFP_KERNEL); \
1942 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, dst__, src__); \
1943 msg__->clientData = (clientData__);
1944
1945#define CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, src__, clientData__) \
1946 { \
1947 CsrWifiRouterCtrlWifiOffCfm *msg__; \
1948 CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__); \
1949 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1950 }
1951
1952#define CsrWifiRouterCtrlWifiOffCfmSend(dst__, clientData__) \
1953 CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__)
1954
1955/*******************************************************************************
1956
1957 NAME
1958 CsrWifiRouterCtrlWifiOnReqSend
1959
1960 DESCRIPTION
1961
1962 PARAMETERS
1963 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1964 clientData -
1965 dataLength - Number of bytes in the buffer pointed to by 'data'
1966 data - Pointer to the buffer containing 'dataLength' bytes
1967
1968*******************************************************************************/
1969#define CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__) \
1970 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL); \
1971 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, dst__, src__); \
1972 msg__->clientData = (clientData__); \
1973 msg__->dataLength = (dataLength__); \
1974 msg__->data = (data__);
1975
1976#define CsrWifiRouterCtrlWifiOnReqSendTo(dst__, src__, clientData__, dataLength__, data__) \
1977 { \
1978 CsrWifiRouterCtrlWifiOnReq *msg__; \
1979 CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__); \
1980 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
1981 }
1982
1983#define CsrWifiRouterCtrlWifiOnReqSend(src__, clientData__, dataLength__, data__) \
1984 CsrWifiRouterCtrlWifiOnReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, dataLength__, data__)
1985
1986/*******************************************************************************
1987
1988 NAME
1989 CsrWifiRouterCtrlWifiOnIndSend
1990
1991 DESCRIPTION
1992
1993 PARAMETERS
1994 queue - Destination Task Queue
1995 clientData -
1996 status -
1997 versions -
1998
1999*******************************************************************************/
2000#define CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__) \
2001 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL); \
2002 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, dst__, src__); \
2003 msg__->clientData = (clientData__); \
2004 msg__->status = (status__); \
2005 msg__->versions = (versions__);
2006
2007#define CsrWifiRouterCtrlWifiOnIndSendTo(dst__, src__, clientData__, status__, versions__) \
2008 { \
2009 CsrWifiRouterCtrlWifiOnInd *msg__; \
2010 CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__); \
2011 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
2012 }
2013
2014#define CsrWifiRouterCtrlWifiOnIndSend(dst__, clientData__, status__, versions__) \
2015 CsrWifiRouterCtrlWifiOnIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__, versions__)
2016
2017/*******************************************************************************
2018
2019 NAME
2020 CsrWifiRouterCtrlWifiOnResSend
2021
2022 DESCRIPTION
2023
2024 PARAMETERS
2025 clientData -
2026 status -
2027 numInterfaceAddress -
2028 stationMacAddress - array size 1 MUST match CSR_WIFI_NUM_INTERFACES
2029 smeVersions -
2030 scheduledInterrupt -
2031
2032*******************************************************************************/
2033#define CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
2034 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL); \
2035 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, dst__, src__); \
2036 msg__->clientData = (clientData__); \
2037 msg__->status = (status__); \
2038 msg__->numInterfaceAddress = (numInterfaceAddress__); \
2039 memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2); \
2040 msg__->smeVersions = (smeVersions__); \
2041 msg__->scheduledInterrupt = (scheduledInterrupt__);
2042
2043#define CsrWifiRouterCtrlWifiOnResSendTo(dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
2044 { \
2045 CsrWifiRouterCtrlWifiOnRes *msg__; \
2046 CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__); \
2047 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
2048 }
2049
2050#define CsrWifiRouterCtrlWifiOnResSend(src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
2051 CsrWifiRouterCtrlWifiOnResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__)
2052
2053/*******************************************************************************
2054
2055 NAME
2056 CsrWifiRouterCtrlWifiOnCfmSend
2057
2058 DESCRIPTION
2059
2060 PARAMETERS
2061 queue - Destination Task Queue
2062 clientData -
2063 status -
2064
2065*******************************************************************************/
2066#define CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__) \
2067 msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL); \
2068 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, dst__, src__); \
2069 msg__->clientData = (clientData__); \
2070 msg__->status = (status__);
2071
2072#define CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, src__, clientData__, status__) \
2073 { \
2074 CsrWifiRouterCtrlWifiOnCfm *msg__; \
2075 CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__); \
2076 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
2077 }
2078
2079#define CsrWifiRouterCtrlWifiOnCfmSend(dst__, clientData__, status__) \
2080 CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__)
2081
2082#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
index 1312a335dd76..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_prim.h
+++ /dev/null
@@ -1,2113 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_CTRL_PRIM_H__
14#define CSR_WIFI_ROUTER_CTRL_PRIM_H__
15
16#include <linux/types.h>
17#include "csr_prim_defs.h"
18#include "csr_sched.h"
19#include "csr_wifi_common.h"
20#include "csr_result.h"
21#include "csr_wifi_fsm_event.h"
22
23#define CSR_WIFI_ROUTER_CTRL_PRIM (0x0401)
24
25typedef CsrPrim CsrWifiRouterCtrlPrim;
26
27typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteWrite)(u8 func, u32 address, u8 data);
28typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteRead)(u8 func, u32 address, u8 *pdata);
29typedef CsrResult (*CsrWifiRouterCtrlRawSdioFirmwareDownload)(u32 length, const u8 *pdata);
30typedef CsrResult (*CsrWifiRouterCtrlRawSdioReset)(void);
31typedef CsrResult (*CsrWifiRouterCtrlRawSdioCoreDumpPrepare)(u8 suspendSme);
32typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteBlockRead)(u8 func, u32 address, u8 *pdata, u32 length);
33typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpRead16)(u8 func, u32 address, u16 *pdata);
34typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpWrite16)(u8 func, u32 address, u16 data);
35
36/*******************************************************************************
37
38 NAME
39 CsrWifiRouterCtrlBlockAckRole
40
41 DESCRIPTION
42
43 VALUES
44 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
45 -
46 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
47 -
48
49*******************************************************************************/
50typedef u8 CsrWifiRouterCtrlBlockAckRole;
51#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR ((CsrWifiRouterCtrlBlockAckRole) 0x00)
52#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT ((CsrWifiRouterCtrlBlockAckRole) 0x01)
53
54/*******************************************************************************
55
56 NAME
57 CsrWifiRouterCtrlControlIndication
58
59 DESCRIPTION
60
61 VALUES
62 CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR
63 -
64 CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT
65 -
66 CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED
67 -
68
69*******************************************************************************/
70typedef u8 CsrWifiRouterCtrlControlIndication;
71#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR ((CsrWifiRouterCtrlControlIndication) 0x01)
72#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT ((CsrWifiRouterCtrlControlIndication) 0x02)
73#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED ((CsrWifiRouterCtrlControlIndication) 0x03)
74
75/*******************************************************************************
76
77 NAME
78 CsrWifiRouterCtrlListAction
79
80 DESCRIPTION
81
82 VALUES
83 CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET
84 -
85 CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD
86 -
87 CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE
88 -
89 CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH
90 -
91
92*******************************************************************************/
93typedef u8 CsrWifiRouterCtrlListAction;
94#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET ((CsrWifiRouterCtrlListAction) 0x00)
95#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD ((CsrWifiRouterCtrlListAction) 0x01)
96#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE ((CsrWifiRouterCtrlListAction) 0x02)
97#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH ((CsrWifiRouterCtrlListAction) 0x03)
98
99/*******************************************************************************
100
101 NAME
102 CsrWifiRouterCtrlLowPowerMode
103
104 DESCRIPTION
105
106 VALUES
107 CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED
108 -
109 CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED
110 -
111
112*******************************************************************************/
113typedef u16 CsrWifiRouterCtrlLowPowerMode;
114#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED ((CsrWifiRouterCtrlLowPowerMode) 0x0000)
115#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED ((CsrWifiRouterCtrlLowPowerMode) 0x0001)
116
117/*******************************************************************************
118
119 NAME
120 CsrWifiRouterCtrlMediaStatus
121
122 DESCRIPTION
123
124 VALUES
125 CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED
126 -
127 CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED
128 -
129
130*******************************************************************************/
131typedef u8 CsrWifiRouterCtrlMediaStatus;
132#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED ((CsrWifiRouterCtrlMediaStatus) 0x00)
133#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED ((CsrWifiRouterCtrlMediaStatus) 0x01)
134
135/*******************************************************************************
136
137 NAME
138 CsrWifiRouterCtrlMode
139
140 DESCRIPTION
141
142 VALUES
143 CSR_WIFI_ROUTER_CTRL_MODE_NONE -
144 CSR_WIFI_ROUTER_CTRL_MODE_IBSS -
145 CSR_WIFI_ROUTER_CTRL_MODE_STA -
146 CSR_WIFI_ROUTER_CTRL_MODE_AP -
147 CSR_WIFI_ROUTER_CTRL_MODE_MONITOR -
148 CSR_WIFI_ROUTER_CTRL_MODE_AMP -
149 CSR_WIFI_ROUTER_CTRL_MODE_P2P -
150 CSR_WIFI_ROUTER_CTRL_MODE_P2PGO -
151 CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI -
152
153*******************************************************************************/
154typedef u8 CsrWifiRouterCtrlMode;
155#define CSR_WIFI_ROUTER_CTRL_MODE_NONE ((CsrWifiRouterCtrlMode) 0x00)
156#define CSR_WIFI_ROUTER_CTRL_MODE_IBSS ((CsrWifiRouterCtrlMode) 0x01)
157#define CSR_WIFI_ROUTER_CTRL_MODE_STA ((CsrWifiRouterCtrlMode) 0x02)
158#define CSR_WIFI_ROUTER_CTRL_MODE_AP ((CsrWifiRouterCtrlMode) 0x03)
159#define CSR_WIFI_ROUTER_CTRL_MODE_MONITOR ((CsrWifiRouterCtrlMode) 0x04)
160#define CSR_WIFI_ROUTER_CTRL_MODE_AMP ((CsrWifiRouterCtrlMode) 0x05)
161#define CSR_WIFI_ROUTER_CTRL_MODE_P2P ((CsrWifiRouterCtrlMode) 0x06)
162#define CSR_WIFI_ROUTER_CTRL_MODE_P2PGO ((CsrWifiRouterCtrlMode) 0x07)
163#define CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI ((CsrWifiRouterCtrlMode) 0x08)
164
165/*******************************************************************************
166
167 NAME
168 CsrWifiRouterCtrlPeerStatus
169
170 DESCRIPTION
171
172 VALUES
173 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE
174 -
175 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE
176 -
177 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED
178 -
179
180*******************************************************************************/
181typedef u8 CsrWifiRouterCtrlPeerStatus;
182#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE ((CsrWifiRouterCtrlPeerStatus) 0x00)
183#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE ((CsrWifiRouterCtrlPeerStatus) 0x01)
184#define CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED ((CsrWifiRouterCtrlPeerStatus) 0x02)
185
186/*******************************************************************************
187
188 NAME
189 CsrWifiRouterCtrlPortAction
190
191 DESCRIPTION
192
193 VALUES
194 CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
195 -
196 CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
197 -
198 CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK
199 -
200
201*******************************************************************************/
202typedef u16 CsrWifiRouterCtrlPortAction;
203#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN ((CsrWifiRouterCtrlPortAction) 0x0000)
204#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD ((CsrWifiRouterCtrlPortAction) 0x0001)
205#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ((CsrWifiRouterCtrlPortAction) 0x0002)
206
207/*******************************************************************************
208
209 NAME
210 CsrWifiRouterCtrlPowersaveType
211
212 DESCRIPTION
213
214 VALUES
215 CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT
216 - If set, AC BK PS info is present in b4 and b5
217 CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT
218 - If set, AC BE PS info is present in b6 and b7
219 CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT
220 - If set, AC VI PS info is present in b8 and b9
221 CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT
222 - If set, AC VO PS info is present in b10 and b11
223 CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED
224 -
225 CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED
226 -
227 CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED
228 -
229 CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED
230 -
231 CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED
232 -
233 CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED
234 -
235 CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED
236 -
237 CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED
238 -
239
240*******************************************************************************/
241typedef u16 CsrWifiRouterCtrlPowersaveType;
242#define CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0001)
243#define CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0002)
244#define CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0004)
245#define CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0008)
246#define CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0010)
247#define CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0020)
248#define CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0040)
249#define CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0080)
250#define CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0100)
251#define CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0200)
252#define CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0400)
253#define CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0800)
254
255/*******************************************************************************
256
257 NAME
258 CsrWifiRouterCtrlProtocolDirection
259
260 DESCRIPTION
261
262 VALUES
263 CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX
264 -
265 CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX
266 -
267
268*******************************************************************************/
269typedef u16 CsrWifiRouterCtrlProtocolDirection;
270#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX ((CsrWifiRouterCtrlProtocolDirection) 0x0000)
271#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX ((CsrWifiRouterCtrlProtocolDirection) 0x0001)
272
273/*******************************************************************************
274
275 NAME
276 CsrWifiRouterCtrlQoSControl
277
278 DESCRIPTION
279
280 VALUES
281 CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF
282 -
283 CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON
284 -
285 CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON
286 -
287
288*******************************************************************************/
289typedef u16 CsrWifiRouterCtrlQoSControl;
290#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF ((CsrWifiRouterCtrlQoSControl) 0x0000)
291#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON ((CsrWifiRouterCtrlQoSControl) 0x0001)
292#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON ((CsrWifiRouterCtrlQoSControl) 0x0002)
293
294/*******************************************************************************
295
296 NAME
297 CsrWifiRouterCtrlQueueConfig
298
299 DESCRIPTION
300 Defines which Queues are enabled for use.
301
302 VALUES
303 CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE
304 -
305 CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE
306 -
307 CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE
308 -
309 CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE
310 -
311
312*******************************************************************************/
313typedef u8 CsrWifiRouterCtrlQueueConfig;
314#define CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x01)
315#define CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x02)
316#define CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x04)
317#define CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x08)
318
319/*******************************************************************************
320
321 NAME
322 CsrWifiRouterCtrlTrafficConfigType
323
324 DESCRIPTION
325
326 VALUES
327 CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET
328 -
329 CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER
330 -
331 CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS
332 -
333
334*******************************************************************************/
335typedef u16 CsrWifiRouterCtrlTrafficConfigType;
336#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET ((CsrWifiRouterCtrlTrafficConfigType) 0x0000)
337#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER ((CsrWifiRouterCtrlTrafficConfigType) 0x0001)
338#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS ((CsrWifiRouterCtrlTrafficConfigType) 0x0002)
339
340/*******************************************************************************
341
342 NAME
343 CsrWifiRouterCtrlTrafficPacketType
344
345 DESCRIPTION
346
347 VALUES
348 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE
349 -
350 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL
351 -
352 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP
353 -
354 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK
355 -
356 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP
357 -
358 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET
359 -
360 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM
361 -
362 CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL
363 -
364
365*******************************************************************************/
366typedef u16 CsrWifiRouterCtrlTrafficPacketType;
367#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE ((CsrWifiRouterCtrlTrafficPacketType) 0x0000)
368#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL ((CsrWifiRouterCtrlTrafficPacketType) 0x0001)
369#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP ((CsrWifiRouterCtrlTrafficPacketType) 0x0002)
370#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK ((CsrWifiRouterCtrlTrafficPacketType) 0x0004)
371#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP ((CsrWifiRouterCtrlTrafficPacketType) 0x0008)
372#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET ((CsrWifiRouterCtrlTrafficPacketType) 0x0010)
373#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM ((CsrWifiRouterCtrlTrafficPacketType) 0x0020)
374#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL ((CsrWifiRouterCtrlTrafficPacketType) 0x00FF)
375
376/*******************************************************************************
377
378 NAME
379 CsrWifiRouterCtrlTrafficType
380
381 DESCRIPTION
382
383 VALUES
384 CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL
385 -
386 CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY
387 -
388 CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC
389 -
390 CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS
391 -
392
393*******************************************************************************/
394typedef u8 CsrWifiRouterCtrlTrafficType;
395#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL ((CsrWifiRouterCtrlTrafficType) 0x00)
396#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY ((CsrWifiRouterCtrlTrafficType) 0x01)
397#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC ((CsrWifiRouterCtrlTrafficType) 0x02)
398#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS ((CsrWifiRouterCtrlTrafficType) 0x03)
399
400
401/*******************************************************************************
402
403 NAME
404 CsrWifiRouterCtrlPeerRecordHandle
405
406 DESCRIPTION
407
408*******************************************************************************/
409typedef u32 CsrWifiRouterCtrlPeerRecordHandle;
410/*******************************************************************************
411
412 NAME
413 CsrWifiRouterCtrlPowersaveTypeMask
414
415 DESCRIPTION
416 Mask type for use with the values defined by
417 CsrWifiRouterCtrlPowersaveType
418
419*******************************************************************************/
420typedef u16 CsrWifiRouterCtrlPowersaveTypeMask;
421/*******************************************************************************
422
423 NAME
424 CsrWifiRouterCtrlQueueConfigMask
425
426 DESCRIPTION
427 Mask type for use with the values defined by CsrWifiRouterCtrlQueueConfig
428
429*******************************************************************************/
430typedef u8 CsrWifiRouterCtrlQueueConfigMask;
431/*******************************************************************************
432
433 NAME
434 CsrWifiRouterCtrlRequestorInfo
435
436 DESCRIPTION
437
438*******************************************************************************/
439typedef u16 CsrWifiRouterCtrlRequestorInfo;
440/*******************************************************************************
441
442 NAME
443 CsrWifiRouterCtrlTrafficStreamId
444
445 DESCRIPTION
446
447*******************************************************************************/
448typedef u8 CsrWifiRouterCtrlTrafficStreamId;
449
450
451/*******************************************************************************
452
453 NAME
454 CsrWifiRouterCtrlSmeVersions
455
456 DESCRIPTION
457
458 MEMBERS
459 firmwarePatch -
460 smeBuild -
461 smeHip -
462
463*******************************************************************************/
464typedef struct
465{
466 u32 firmwarePatch;
467 char *smeBuild;
468 u32 smeHip;
469} CsrWifiRouterCtrlSmeVersions;
470
471/*******************************************************************************
472
473 NAME
474 CsrWifiRouterCtrlStaInfo
475
476 DESCRIPTION
477
478 MEMBERS
479 wmmOrQosEnabled -
480 powersaveMode -
481 maxSpLength -
482 listenIntervalInTus -
483
484*******************************************************************************/
485typedef struct
486{
487 u8 wmmOrQosEnabled;
488 CsrWifiRouterCtrlPowersaveTypeMask powersaveMode;
489 u8 maxSpLength;
490 u16 listenIntervalInTus;
491} CsrWifiRouterCtrlStaInfo;
492
493/*******************************************************************************
494
495 NAME
496 CsrWifiRouterCtrlTrafficFilter
497
498 DESCRIPTION
499
500 MEMBERS
501 etherType -
502 ipType -
503 udpSourcePort -
504 udpDestPort -
505
506*******************************************************************************/
507typedef struct
508{
509 u32 etherType;
510 u8 ipType;
511 u32 udpSourcePort;
512 u32 udpDestPort;
513} CsrWifiRouterCtrlTrafficFilter;
514
515/*******************************************************************************
516
517 NAME
518 CsrWifiRouterCtrlTrafficStats
519
520 DESCRIPTION
521
522 MEMBERS
523 rxMeanRate - Mean rx data rate over the interval
524 rxFramesNum - Keep number of Rx frames per second, for CYCLE_3.
525 txFramesNum - Keep number of Tx frames per second, for CYCLE_3.
526 rxBytesCount - Keep calculated Rx throughput per second, for CYCLE_2.
527 txBytesCount - Keep calculated Tx throughput per second, for CYCLE_2.
528 intervals - array size 11 MUST match TA_INTERVALS_NUM
529
530*******************************************************************************/
531typedef struct
532{
533 u32 rxMeanRate;
534 u32 rxFramesNum;
535 u32 txFramesNum;
536 u32 rxBytesCount;
537 u32 txBytesCount;
538 u8 intervals[11];
539} CsrWifiRouterCtrlTrafficStats;
540
541/*******************************************************************************
542
543 NAME
544 CsrWifiRouterCtrlVersions
545
546 DESCRIPTION
547
548 MEMBERS
549 chipId -
550 chipVersion -
551 firmwareBuild -
552 firmwareHip -
553 routerBuild -
554 routerHip -
555
556*******************************************************************************/
557typedef struct
558{
559 u32 chipId;
560 u32 chipVersion;
561 u32 firmwareBuild;
562 u32 firmwareHip;
563 char *routerBuild;
564 u32 routerHip;
565} CsrWifiRouterCtrlVersions;
566
567/*******************************************************************************
568
569 NAME
570 CsrWifiRouterCtrlTrafficConfig
571
572 DESCRIPTION
573
574 MEMBERS
575 packetFilter -
576 customFilter -
577
578*******************************************************************************/
579typedef struct
580{
581 u16 packetFilter;
582 CsrWifiRouterCtrlTrafficFilter customFilter;
583} CsrWifiRouterCtrlTrafficConfig;
584
585
586/* Downstream */
587#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST (0x0000)
588
589#define CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ ((CsrWifiRouterCtrlPrim) (0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
590#define CSR_WIFI_ROUTER_CTRL_HIP_REQ ((CsrWifiRouterCtrlPrim) (0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
591#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ ((CsrWifiRouterCtrlPrim) (0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
592#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES ((CsrWifiRouterCtrlPrim) (0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
593#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ ((CsrWifiRouterCtrlPrim) (0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
594#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ ((CsrWifiRouterCtrlPrim) (0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
595#define CSR_WIFI_ROUTER_CTRL_SUSPEND_RES ((CsrWifiRouterCtrlPrim) (0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
596#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ ((CsrWifiRouterCtrlPrim) (0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
597#define CSR_WIFI_ROUTER_CTRL_RESUME_RES ((CsrWifiRouterCtrlPrim) (0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
598#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ ((CsrWifiRouterCtrlPrim) (0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
599#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ ((CsrWifiRouterCtrlPrim) (0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
600#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ ((CsrWifiRouterCtrlPrim) (0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
601#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ ((CsrWifiRouterCtrlPrim) (0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
602#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ ((CsrWifiRouterCtrlPrim) (0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
603#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ ((CsrWifiRouterCtrlPrim) (0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
604#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES ((CsrWifiRouterCtrlPrim) (0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
605#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ ((CsrWifiRouterCtrlPrim) (0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
606#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES ((CsrWifiRouterCtrlPrim) (0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
607#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ ((CsrWifiRouterCtrlPrim) (0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
608#define CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ ((CsrWifiRouterCtrlPrim) (0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
609#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ ((CsrWifiRouterCtrlPrim) (0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
610#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ ((CsrWifiRouterCtrlPrim) (0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
611#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ ((CsrWifiRouterCtrlPrim) (0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
612#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ ((CsrWifiRouterCtrlPrim) (0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
613#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ ((CsrWifiRouterCtrlPrim) (0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
614#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ ((CsrWifiRouterCtrlPrim) (0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
615#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ ((CsrWifiRouterCtrlPrim) (0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
616#define CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
617#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
618#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ ((CsrWifiRouterCtrlPrim) (0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
619#define CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
620
621
622#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)
623
624/* Upstream */
625#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
626
627#define CSR_WIFI_ROUTER_CTRL_HIP_IND ((CsrWifiRouterCtrlPrim)(0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
628#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND ((CsrWifiRouterCtrlPrim)(0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
629#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM ((CsrWifiRouterCtrlPrim)(0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
630#define CSR_WIFI_ROUTER_CTRL_RESUME_IND ((CsrWifiRouterCtrlPrim)(0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
631#define CSR_WIFI_ROUTER_CTRL_SUSPEND_IND ((CsrWifiRouterCtrlPrim)(0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
632#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM ((CsrWifiRouterCtrlPrim)(0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
633#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM ((CsrWifiRouterCtrlPrim)(0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
634#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM ((CsrWifiRouterCtrlPrim)(0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
635#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM ((CsrWifiRouterCtrlPrim)(0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
636#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND ((CsrWifiRouterCtrlPrim)(0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
637#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND ((CsrWifiRouterCtrlPrim)(0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
638#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND ((CsrWifiRouterCtrlPrim)(0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
639#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM ((CsrWifiRouterCtrlPrim)(0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
640#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND ((CsrWifiRouterCtrlPrim)(0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
641#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM ((CsrWifiRouterCtrlPrim)(0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
642#define CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND ((CsrWifiRouterCtrlPrim)(0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
643#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND ((CsrWifiRouterCtrlPrim)(0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
644#define CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND ((CsrWifiRouterCtrlPrim)(0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
645#define CSR_WIFI_ROUTER_CTRL_CONNECTED_IND ((CsrWifiRouterCtrlPrim)(0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
646#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM ((CsrWifiRouterCtrlPrim)(0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
647#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM ((CsrWifiRouterCtrlPrim)(0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
648#define CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND ((CsrWifiRouterCtrlPrim)(0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
649#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM ((CsrWifiRouterCtrlPrim)(0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
650#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM ((CsrWifiRouterCtrlPrim)(0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
651#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM ((CsrWifiRouterCtrlPrim)(0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
652#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM ((CsrWifiRouterCtrlPrim)(0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
653#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND ((CsrWifiRouterCtrlPrim)(0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
654#define CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND ((CsrWifiRouterCtrlPrim)(0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
655#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND ((CsrWifiRouterCtrlPrim)(0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
656#define CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM ((CsrWifiRouterCtrlPrim)(0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
657#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND ((CsrWifiRouterCtrlPrim)(0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
658
659#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)
660
661#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)
662#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)
663
664/*******************************************************************************
665
666 NAME
667 CsrWifiRouterCtrlConfigurePowerModeReq
668
669 DESCRIPTION
670
671 MEMBERS
672 common - Common header for use with the CsrWifiFsm Module
673 clientData -
674 mode -
675 wakeHost -
676
677*******************************************************************************/
678typedef struct
679{
680 CsrWifiFsmEvent common;
681 CsrWifiRouterCtrlRequestorInfo clientData;
682 CsrWifiRouterCtrlLowPowerMode mode;
683 u8 wakeHost;
684} CsrWifiRouterCtrlConfigurePowerModeReq;
685
686/*******************************************************************************
687
688 NAME
689 CsrWifiRouterCtrlHipReq
690
691 DESCRIPTION
692 This primitive is used for transferring MLME messages to the HIP.
693
694 MEMBERS
695 common - Common header for use with the CsrWifiFsm Module
696 mlmeCommandLength - Length of the MLME signal
697 mlmeCommand - Pointer to the MLME signal
698 dataRef1Length - Length of the dataRef1 bulk data
699 dataRef1 - Pointer to the bulk data 1
700 dataRef2Length - Length of the dataRef2 bulk data
701 dataRef2 - Pointer to the bulk data 2
702
703*******************************************************************************/
704typedef struct
705{
706 CsrWifiFsmEvent common;
707 u16 mlmeCommandLength;
708 u8 *mlmeCommand;
709 u16 dataRef1Length;
710 u8 *dataRef1;
711 u16 dataRef2Length;
712 u8 *dataRef2;
713} CsrWifiRouterCtrlHipReq;
714
715/*******************************************************************************
716
717 NAME
718 CsrWifiRouterCtrlMediaStatusReq
719
720 DESCRIPTION
721
722 MEMBERS
723 common - Common header for use with the CsrWifiFsm Module
724 interfaceTag -
725 clientData -
726 mediaStatus -
727
728*******************************************************************************/
729typedef struct
730{
731 CsrWifiFsmEvent common;
732 u16 interfaceTag;
733 CsrWifiRouterCtrlRequestorInfo clientData;
734 CsrWifiRouterCtrlMediaStatus mediaStatus;
735} CsrWifiRouterCtrlMediaStatusReq;
736
737/*******************************************************************************
738
739 NAME
740 CsrWifiRouterCtrlMulticastAddressRes
741
742 DESCRIPTION
743
744 MEMBERS
745 common - Common header for use with the CsrWifiFsm Module
746 interfaceTag -
747 clientData -
748 status -
749 action -
750 getAddressesCount -
751 getAddresses -
752
753*******************************************************************************/
754typedef struct
755{
756 CsrWifiFsmEvent common;
757 u16 interfaceTag;
758 CsrWifiRouterCtrlRequestorInfo clientData;
759 CsrResult status;
760 CsrWifiRouterCtrlListAction action;
761 u8 getAddressesCount;
762 CsrWifiMacAddress *getAddresses;
763} CsrWifiRouterCtrlMulticastAddressRes;
764
765/*******************************************************************************
766
767 NAME
768 CsrWifiRouterCtrlPortConfigureReq
769
770 DESCRIPTION
771
772 MEMBERS
773 common - Common header for use with the CsrWifiFsm Module
774 interfaceTag -
775 clientData -
776 uncontrolledPortAction -
777 controlledPortAction -
778 macAddress -
779 setProtection -
780
781*******************************************************************************/
782typedef struct
783{
784 CsrWifiFsmEvent common;
785 u16 interfaceTag;
786 CsrWifiRouterCtrlRequestorInfo clientData;
787 CsrWifiRouterCtrlPortAction uncontrolledPortAction;
788 CsrWifiRouterCtrlPortAction controlledPortAction;
789 CsrWifiMacAddress macAddress;
790 u8 setProtection;
791} CsrWifiRouterCtrlPortConfigureReq;
792
793/*******************************************************************************
794
795 NAME
796 CsrWifiRouterCtrlQosControlReq
797
798 DESCRIPTION
799
800 MEMBERS
801 common - Common header for use with the CsrWifiFsm Module
802 interfaceTag -
803 clientData -
804 control -
805 queueConfig -
806
807*******************************************************************************/
808typedef struct
809{
810 CsrWifiFsmEvent common;
811 u16 interfaceTag;
812 CsrWifiRouterCtrlRequestorInfo clientData;
813 CsrWifiRouterCtrlQoSControl control;
814 CsrWifiRouterCtrlQueueConfigMask queueConfig;
815} CsrWifiRouterCtrlQosControlReq;
816
817/*******************************************************************************
818
819 NAME
820 CsrWifiRouterCtrlSuspendRes
821
822 DESCRIPTION
823
824 MEMBERS
825 common - Common header for use with the CsrWifiFsm Module
826 clientData -
827 status -
828
829*******************************************************************************/
830typedef struct
831{
832 CsrWifiFsmEvent common;
833 CsrWifiRouterCtrlRequestorInfo clientData;
834 CsrResult status;
835} CsrWifiRouterCtrlSuspendRes;
836
837/*******************************************************************************
838
839 NAME
840 CsrWifiRouterCtrlTclasAddReq
841
842 DESCRIPTION
843
844 MEMBERS
845 common - Common header for use with the CsrWifiFsm Module
846 interfaceTag -
847 clientData -
848 tclasLength -
849 tclas -
850
851*******************************************************************************/
852typedef struct
853{
854 CsrWifiFsmEvent common;
855 u16 interfaceTag;
856 CsrWifiRouterCtrlRequestorInfo clientData;
857 u16 tclasLength;
858 u8 *tclas;
859} CsrWifiRouterCtrlTclasAddReq;
860
861/*******************************************************************************
862
863 NAME
864 CsrWifiRouterCtrlResumeRes
865
866 DESCRIPTION
867
868 MEMBERS
869 common - Common header for use with the CsrWifiFsm Module
870 clientData -
871 status -
872
873*******************************************************************************/
874typedef struct
875{
876 CsrWifiFsmEvent common;
877 CsrWifiRouterCtrlRequestorInfo clientData;
878 CsrResult status;
879} CsrWifiRouterCtrlResumeRes;
880
881/*******************************************************************************
882
883 NAME
884 CsrWifiRouterCtrlRawSdioDeinitialiseReq
885
886 DESCRIPTION
887
888 MEMBERS
889 common - Common header for use with the CsrWifiFsm Module
890 clientData -
891
892*******************************************************************************/
893typedef struct
894{
895 CsrWifiFsmEvent common;
896 CsrWifiRouterCtrlRequestorInfo clientData;
897} CsrWifiRouterCtrlRawSdioDeinitialiseReq;
898
899/*******************************************************************************
900
901 NAME
902 CsrWifiRouterCtrlRawSdioInitialiseReq
903
904 DESCRIPTION
905
906 MEMBERS
907 common - Common header for use with the CsrWifiFsm Module
908 clientData -
909
910*******************************************************************************/
911typedef struct
912{
913 CsrWifiFsmEvent common;
914 CsrWifiRouterCtrlRequestorInfo clientData;
915} CsrWifiRouterCtrlRawSdioInitialiseReq;
916
917/*******************************************************************************
918
919 NAME
920 CsrWifiRouterCtrlTclasDelReq
921
922 DESCRIPTION
923
924 MEMBERS
925 common - Common header for use with the CsrWifiFsm Module
926 interfaceTag -
927 clientData -
928 tclasLength -
929 tclas -
930
931*******************************************************************************/
932typedef struct
933{
934 CsrWifiFsmEvent common;
935 u16 interfaceTag;
936 CsrWifiRouterCtrlRequestorInfo clientData;
937 u16 tclasLength;
938 u8 *tclas;
939} CsrWifiRouterCtrlTclasDelReq;
940
941/*******************************************************************************
942
943 NAME
944 CsrWifiRouterCtrlTrafficClassificationReq
945
946 DESCRIPTION
947
948 MEMBERS
949 common - Common header for use with the CsrWifiFsm Module
950 interfaceTag -
951 clientData -
952 trafficType -
953 period -
954
955*******************************************************************************/
956typedef struct
957{
958 CsrWifiFsmEvent common;
959 u16 interfaceTag;
960 CsrWifiRouterCtrlRequestorInfo clientData;
961 CsrWifiRouterCtrlTrafficType trafficType;
962 u16 period;
963} CsrWifiRouterCtrlTrafficClassificationReq;
964
965/*******************************************************************************
966
967 NAME
968 CsrWifiRouterCtrlTrafficConfigReq
969
970 DESCRIPTION
971
972 MEMBERS
973 common - Common header for use with the CsrWifiFsm Module
974 interfaceTag -
975 clientData -
976 trafficConfigType -
977 config -
978
979*******************************************************************************/
980typedef struct
981{
982 CsrWifiFsmEvent common;
983 u16 interfaceTag;
984 CsrWifiRouterCtrlRequestorInfo clientData;
985 CsrWifiRouterCtrlTrafficConfigType trafficConfigType;
986 CsrWifiRouterCtrlTrafficConfig config;
987} CsrWifiRouterCtrlTrafficConfigReq;
988
989/*******************************************************************************
990
991 NAME
992 CsrWifiRouterCtrlWifiOffReq
993
994 DESCRIPTION
995
996 MEMBERS
997 common - Common header for use with the CsrWifiFsm Module
998 clientData -
999
1000*******************************************************************************/
1001typedef struct
1002{
1003 CsrWifiFsmEvent common;
1004 CsrWifiRouterCtrlRequestorInfo clientData;
1005} CsrWifiRouterCtrlWifiOffReq;
1006
1007/*******************************************************************************
1008
1009 NAME
1010 CsrWifiRouterCtrlWifiOffRes
1011
1012 DESCRIPTION
1013
1014 MEMBERS
1015 common - Common header for use with the CsrWifiFsm Module
1016 clientData -
1017
1018*******************************************************************************/
1019typedef struct
1020{
1021 CsrWifiFsmEvent common;
1022 CsrWifiRouterCtrlRequestorInfo clientData;
1023} CsrWifiRouterCtrlWifiOffRes;
1024
1025/*******************************************************************************
1026
1027 NAME
1028 CsrWifiRouterCtrlWifiOnReq
1029
1030 DESCRIPTION
1031
1032 MEMBERS
1033 common - Common header for use with the CsrWifiFsm Module
1034 clientData -
1035 dataLength - Number of bytes in the buffer pointed to by 'data'
1036 data - Pointer to the buffer containing 'dataLength' bytes
1037
1038*******************************************************************************/
1039typedef struct
1040{
1041 CsrWifiFsmEvent common;
1042 CsrWifiRouterCtrlRequestorInfo clientData;
1043 u32 dataLength;
1044 u8 *data;
1045} CsrWifiRouterCtrlWifiOnReq;
1046
1047/*******************************************************************************
1048
1049 NAME
1050 CsrWifiRouterCtrlWifiOnRes
1051
1052 DESCRIPTION
1053
1054 MEMBERS
1055 common - Common header for use with the CsrWifiFsm Module
1056 clientData -
1057 status -
1058 numInterfaceAddress -
1059 stationMacAddress - array size 1 MUST match CSR_WIFI_NUM_INTERFACES
1060 smeVersions -
1061 scheduledInterrupt -
1062
1063*******************************************************************************/
1064typedef struct
1065{
1066 CsrWifiFsmEvent common;
1067 CsrWifiRouterCtrlRequestorInfo clientData;
1068 CsrResult status;
1069 u16 numInterfaceAddress;
1070 CsrWifiMacAddress stationMacAddress[2];
1071 CsrWifiRouterCtrlSmeVersions smeVersions;
1072 u8 scheduledInterrupt;
1073} CsrWifiRouterCtrlWifiOnRes;
1074
1075/*******************************************************************************
1076
1077 NAME
1078 CsrWifiRouterCtrlM4TransmitReq
1079
1080 DESCRIPTION
1081
1082 MEMBERS
1083 common - Common header for use with the CsrWifiFsm Module
1084 interfaceTag -
1085 clientData -
1086
1087*******************************************************************************/
1088typedef struct
1089{
1090 CsrWifiFsmEvent common;
1091 u16 interfaceTag;
1092 CsrWifiRouterCtrlRequestorInfo clientData;
1093} CsrWifiRouterCtrlM4TransmitReq;
1094
1095/*******************************************************************************
1096
1097 NAME
1098 CsrWifiRouterCtrlModeSetReq
1099
1100 DESCRIPTION
1101
1102 MEMBERS
1103 common - Common header for use with the CsrWifiFsm Module
1104 interfaceTag -
1105 clientData -
1106 mode -
1107 bssid - BSSID of the network the device is going to be a part
1108 of
1109 protection - Set to TRUE if encryption is enabled for the
1110 connection/broadcast frames
1111 intraBssDistEnabled - If set to TRUE, intra BSS destribution will be
1112 enabled. If set to FALSE, any unicast PDU which does
1113 not have the RA as the the local MAC address, shall be
1114 ignored. This field is interpreted by the receive if
1115 mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
1116
1117*******************************************************************************/
1118typedef struct
1119{
1120 CsrWifiFsmEvent common;
1121 u16 interfaceTag;
1122 CsrWifiRouterCtrlRequestorInfo clientData;
1123 CsrWifiRouterCtrlMode mode;
1124 CsrWifiMacAddress bssid;
1125 u8 protection;
1126 u8 intraBssDistEnabled;
1127} CsrWifiRouterCtrlModeSetReq;
1128
1129/*******************************************************************************
1130
1131 NAME
1132 CsrWifiRouterCtrlPeerAddReq
1133
1134 DESCRIPTION
1135
1136 MEMBERS
1137 common - Common header for use with the CsrWifiFsm Module
1138 interfaceTag -
1139 clientData -
1140 peerMacAddress -
1141 associationId -
1142 staInfo -
1143
1144*******************************************************************************/
1145typedef struct
1146{
1147 CsrWifiFsmEvent common;
1148 u16 interfaceTag;
1149 CsrWifiRouterCtrlRequestorInfo clientData;
1150 CsrWifiMacAddress peerMacAddress;
1151 u16 associationId;
1152 CsrWifiRouterCtrlStaInfo staInfo;
1153} CsrWifiRouterCtrlPeerAddReq;
1154
1155/*******************************************************************************
1156
1157 NAME
1158 CsrWifiRouterCtrlPeerDelReq
1159
1160 DESCRIPTION
1161
1162 MEMBERS
1163 common - Common header for use with the CsrWifiFsm Module
1164 interfaceTag -
1165 clientData -
1166 peerRecordHandle -
1167
1168*******************************************************************************/
1169typedef struct
1170{
1171 CsrWifiFsmEvent common;
1172 u16 interfaceTag;
1173 CsrWifiRouterCtrlRequestorInfo clientData;
1174 CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
1175} CsrWifiRouterCtrlPeerDelReq;
1176
1177/*******************************************************************************
1178
1179 NAME
1180 CsrWifiRouterCtrlPeerUpdateReq
1181
1182 DESCRIPTION
1183
1184 MEMBERS
1185 common - Common header for use with the CsrWifiFsm Module
1186 interfaceTag -
1187 clientData -
1188 peerRecordHandle -
1189 powersaveMode -
1190
1191*******************************************************************************/
1192typedef struct
1193{
1194 CsrWifiFsmEvent common;
1195 u16 interfaceTag;
1196 CsrWifiRouterCtrlRequestorInfo clientData;
1197 CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
1198 CsrWifiRouterCtrlPowersaveTypeMask powersaveMode;
1199} CsrWifiRouterCtrlPeerUpdateReq;
1200
1201/*******************************************************************************
1202
1203 NAME
1204 CsrWifiRouterCtrlCapabilitiesReq
1205
1206 DESCRIPTION
1207
1208 MEMBERS
1209 common - Common header for use with the CsrWifiFsm Module
1210 clientData -
1211
1212*******************************************************************************/
1213typedef struct
1214{
1215 CsrWifiFsmEvent common;
1216 CsrWifiRouterCtrlRequestorInfo clientData;
1217} CsrWifiRouterCtrlCapabilitiesReq;
1218
1219/*******************************************************************************
1220
1221 NAME
1222 CsrWifiRouterCtrlBlockAckEnableReq
1223
1224 DESCRIPTION
1225
1226 MEMBERS
1227 common - Common header for use with the CsrWifiFsm Module
1228 interfaceTag -
1229 clientData -
1230 macAddress -
1231 trafficStreamID -
1232 role -
1233 bufferSize -
1234 timeout -
1235 ssn -
1236
1237*******************************************************************************/
1238typedef struct
1239{
1240 CsrWifiFsmEvent common;
1241 u16 interfaceTag;
1242 CsrWifiRouterCtrlRequestorInfo clientData;
1243 CsrWifiMacAddress macAddress;
1244 CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
1245 CsrWifiRouterCtrlBlockAckRole role;
1246 u16 bufferSize;
1247 u16 timeout;
1248 u16 ssn;
1249} CsrWifiRouterCtrlBlockAckEnableReq;
1250
1251/*******************************************************************************
1252
1253 NAME
1254 CsrWifiRouterCtrlBlockAckDisableReq
1255
1256 DESCRIPTION
1257
1258 MEMBERS
1259 common - Common header for use with the CsrWifiFsm Module
1260 interfaceTag -
1261 clientData -
1262 macAddress -
1263 trafficStreamID -
1264 role -
1265
1266*******************************************************************************/
1267typedef struct
1268{
1269 CsrWifiFsmEvent common;
1270 u16 interfaceTag;
1271 CsrWifiRouterCtrlRequestorInfo clientData;
1272 CsrWifiMacAddress macAddress;
1273 CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
1274 CsrWifiRouterCtrlBlockAckRole role;
1275} CsrWifiRouterCtrlBlockAckDisableReq;
1276
1277/*******************************************************************************
1278
1279 NAME
1280 CsrWifiRouterCtrlWapiRxPktReq
1281
1282 DESCRIPTION
1283
1284 MEMBERS
1285 common - Common header for use with the CsrWifiFsm Module
1286 interfaceTag -
1287 signalLength -
1288 signal -
1289 dataLength -
1290 data -
1291
1292*******************************************************************************/
1293typedef struct
1294{
1295 CsrWifiFsmEvent common;
1296 u16 interfaceTag;
1297 u16 signalLength;
1298 u8 *signal;
1299 u16 dataLength;
1300 u8 *data;
1301} CsrWifiRouterCtrlWapiRxPktReq;
1302
1303/*******************************************************************************
1304
1305 NAME
1306 CsrWifiRouterCtrlWapiMulticastFilterReq
1307
1308 DESCRIPTION
1309
1310 MEMBERS
1311 common - Common header for use with the CsrWifiFsm Module
1312 interfaceTag -
1313 status -
1314
1315*******************************************************************************/
1316typedef struct
1317{
1318 CsrWifiFsmEvent common;
1319 u16 interfaceTag;
1320 u8 status;
1321} CsrWifiRouterCtrlWapiMulticastFilterReq;
1322
1323/*******************************************************************************
1324
1325 NAME
1326 CsrWifiRouterCtrlWapiUnicastFilterReq
1327
1328 DESCRIPTION
1329
1330 MEMBERS
1331 common - Common header for use with the CsrWifiFsm Module
1332 interfaceTag -
1333 status -
1334
1335*******************************************************************************/
1336typedef struct
1337{
1338 CsrWifiFsmEvent common;
1339 u16 interfaceTag;
1340 u8 status;
1341} CsrWifiRouterCtrlWapiUnicastFilterReq;
1342
1343/*******************************************************************************
1344
1345 NAME
1346 CsrWifiRouterCtrlWapiUnicastTxPktReq
1347
1348 DESCRIPTION
1349
1350 MEMBERS
1351 common - Common header for use with the CsrWifiFsm Module
1352 interfaceTag -
1353 dataLength -
1354 data -
1355
1356*******************************************************************************/
1357typedef struct
1358{
1359 CsrWifiFsmEvent common;
1360 u16 interfaceTag;
1361 u16 dataLength;
1362 u8 *data;
1363} CsrWifiRouterCtrlWapiUnicastTxPktReq;
1364
1365/*******************************************************************************
1366
1367 NAME
1368 CsrWifiRouterCtrlWapiFilterReq
1369
1370 DESCRIPTION
1371
1372 MEMBERS
1373 common - Common header for use with the CsrWifiFsm Module
1374 interfaceTag -
1375 isWapiConnected -
1376
1377*******************************************************************************/
1378typedef struct
1379{
1380 CsrWifiFsmEvent common;
1381 u16 interfaceTag;
1382 u8 isWapiConnected;
1383} CsrWifiRouterCtrlWapiFilterReq;
1384
1385/*******************************************************************************
1386
1387 NAME
1388 CsrWifiRouterCtrlHipInd
1389
1390 DESCRIPTION
1391 This primitive is used for transferring MLME messages from the HIP.
1392
1393 MEMBERS
1394 common - Common header for use with the CsrWifiFsm Module
1395 mlmeCommandLength - Length of the MLME signal
1396 mlmeCommand - Pointer to the MLME signal
1397 dataRef1Length - Length of the dataRef1 bulk data
1398 dataRef1 - Pointer to the bulk data 1
1399 dataRef2Length - Length of the dataRef2 bulk data
1400 dataRef2 - Pointer to the bulk data 2
1401
1402*******************************************************************************/
1403typedef struct
1404{
1405 CsrWifiFsmEvent common;
1406 u16 mlmeCommandLength;
1407 u8 *mlmeCommand;
1408 u16 dataRef1Length;
1409 u8 *dataRef1;
1410 u16 dataRef2Length;
1411 u8 *dataRef2;
1412} CsrWifiRouterCtrlHipInd;
1413
1414/*******************************************************************************
1415
1416 NAME
1417 CsrWifiRouterCtrlMulticastAddressInd
1418
1419 DESCRIPTION
1420
1421 MEMBERS
1422 common - Common header for use with the CsrWifiFsm Module
1423 clientData -
1424 interfaceTag -
1425 action -
1426 setAddressesCount -
1427 setAddresses -
1428
1429*******************************************************************************/
1430typedef struct
1431{
1432 CsrWifiFsmEvent common;
1433 CsrWifiRouterCtrlRequestorInfo clientData;
1434 u16 interfaceTag;
1435 CsrWifiRouterCtrlListAction action;
1436 u8 setAddressesCount;
1437 CsrWifiMacAddress *setAddresses;
1438} CsrWifiRouterCtrlMulticastAddressInd;
1439
1440/*******************************************************************************
1441
1442 NAME
1443 CsrWifiRouterCtrlPortConfigureCfm
1444
1445 DESCRIPTION
1446
1447 MEMBERS
1448 common - Common header for use with the CsrWifiFsm Module
1449 clientData -
1450 interfaceTag -
1451 status -
1452 macAddress -
1453
1454*******************************************************************************/
1455typedef struct
1456{
1457 CsrWifiFsmEvent common;
1458 CsrWifiRouterCtrlRequestorInfo clientData;
1459 u16 interfaceTag;
1460 CsrResult status;
1461 CsrWifiMacAddress macAddress;
1462} CsrWifiRouterCtrlPortConfigureCfm;
1463
1464/*******************************************************************************
1465
1466 NAME
1467 CsrWifiRouterCtrlResumeInd
1468
1469 DESCRIPTION
1470
1471 MEMBERS
1472 common - Common header for use with the CsrWifiFsm Module
1473 clientData -
1474 powerMaintained -
1475
1476*******************************************************************************/
1477typedef struct
1478{
1479 CsrWifiFsmEvent common;
1480 CsrWifiRouterCtrlRequestorInfo clientData;
1481 u8 powerMaintained;
1482} CsrWifiRouterCtrlResumeInd;
1483
1484/*******************************************************************************
1485
1486 NAME
1487 CsrWifiRouterCtrlSuspendInd
1488
1489 DESCRIPTION
1490
1491 MEMBERS
1492 common - Common header for use with the CsrWifiFsm Module
1493 clientData -
1494 hardSuspend -
1495 d3Suspend -
1496
1497*******************************************************************************/
1498typedef struct
1499{
1500 CsrWifiFsmEvent common;
1501 CsrWifiRouterCtrlRequestorInfo clientData;
1502 u8 hardSuspend;
1503 u8 d3Suspend;
1504} CsrWifiRouterCtrlSuspendInd;
1505
1506/*******************************************************************************
1507
1508 NAME
1509 CsrWifiRouterCtrlTclasAddCfm
1510
1511 DESCRIPTION
1512
1513 MEMBERS
1514 common - Common header for use with the CsrWifiFsm Module
1515 clientData -
1516 interfaceTag -
1517 status -
1518
1519*******************************************************************************/
1520typedef struct
1521{
1522 CsrWifiFsmEvent common;
1523 CsrWifiRouterCtrlRequestorInfo clientData;
1524 u16 interfaceTag;
1525 CsrResult status;
1526} CsrWifiRouterCtrlTclasAddCfm;
1527
1528/*******************************************************************************
1529
1530 NAME
1531 CsrWifiRouterCtrlRawSdioDeinitialiseCfm
1532
1533 DESCRIPTION
1534
1535 MEMBERS
1536 common - Common header for use with the CsrWifiFsm Module
1537 clientData -
1538 result -
1539
1540*******************************************************************************/
1541typedef struct
1542{
1543 CsrWifiFsmEvent common;
1544 CsrWifiRouterCtrlRequestorInfo clientData;
1545 CsrResult result;
1546} CsrWifiRouterCtrlRawSdioDeinitialiseCfm;
1547
1548/*******************************************************************************
1549
1550 NAME
1551 CsrWifiRouterCtrlRawSdioInitialiseCfm
1552
1553 DESCRIPTION
1554
1555 MEMBERS
1556 common - Common header for use with the CsrWifiFsm Module
1557 clientData -
1558 result -
1559 byteRead -
1560 byteWrite -
1561 firmwareDownload -
1562 reset -
1563 coreDumpPrepare -
1564 byteBlockRead -
1565 gpRead16 -
1566 gpWrite16 -
1567
1568*******************************************************************************/
1569typedef struct
1570{
1571 CsrWifiFsmEvent common;
1572 CsrWifiRouterCtrlRequestorInfo clientData;
1573 CsrResult result;
1574 CsrWifiRouterCtrlRawSdioByteRead byteRead;
1575 CsrWifiRouterCtrlRawSdioByteWrite byteWrite;
1576 CsrWifiRouterCtrlRawSdioFirmwareDownload firmwareDownload;
1577 CsrWifiRouterCtrlRawSdioReset reset;
1578 CsrWifiRouterCtrlRawSdioCoreDumpPrepare coreDumpPrepare;
1579 CsrWifiRouterCtrlRawSdioByteBlockRead byteBlockRead;
1580 CsrWifiRouterCtrlRawSdioGpRead16 gpRead16;
1581 CsrWifiRouterCtrlRawSdioGpWrite16 gpWrite16;
1582} CsrWifiRouterCtrlRawSdioInitialiseCfm;
1583
1584/*******************************************************************************
1585
1586 NAME
1587 CsrWifiRouterCtrlTclasDelCfm
1588
1589 DESCRIPTION
1590
1591 MEMBERS
1592 common - Common header for use with the CsrWifiFsm Module
1593 clientData -
1594 interfaceTag -
1595 status -
1596
1597*******************************************************************************/
1598typedef struct
1599{
1600 CsrWifiFsmEvent common;
1601 CsrWifiRouterCtrlRequestorInfo clientData;
1602 u16 interfaceTag;
1603 CsrResult status;
1604} CsrWifiRouterCtrlTclasDelCfm;
1605
1606/*******************************************************************************
1607
1608 NAME
1609 CsrWifiRouterCtrlTrafficProtocolInd
1610
1611 DESCRIPTION
1612
1613 MEMBERS
1614 common - Common header for use with the CsrWifiFsm Module
1615 clientData -
1616 interfaceTag -
1617 packetType -
1618 direction -
1619 srcAddress -
1620
1621*******************************************************************************/
1622typedef struct
1623{
1624 CsrWifiFsmEvent common;
1625 CsrWifiRouterCtrlRequestorInfo clientData;
1626 u16 interfaceTag;
1627 CsrWifiRouterCtrlTrafficPacketType packetType;
1628 CsrWifiRouterCtrlProtocolDirection direction;
1629 CsrWifiMacAddress srcAddress;
1630} CsrWifiRouterCtrlTrafficProtocolInd;
1631
1632/*******************************************************************************
1633
1634 NAME
1635 CsrWifiRouterCtrlTrafficSampleInd
1636
1637 DESCRIPTION
1638
1639 MEMBERS
1640 common - Common header for use with the CsrWifiFsm Module
1641 clientData -
1642 interfaceTag -
1643 stats -
1644
1645*******************************************************************************/
1646typedef struct
1647{
1648 CsrWifiFsmEvent common;
1649 CsrWifiRouterCtrlRequestorInfo clientData;
1650 u16 interfaceTag;
1651 CsrWifiRouterCtrlTrafficStats stats;
1652} CsrWifiRouterCtrlTrafficSampleInd;
1653
1654/*******************************************************************************
1655
1656 NAME
1657 CsrWifiRouterCtrlWifiOffInd
1658
1659 DESCRIPTION
1660
1661 MEMBERS
1662 common - Common header for use with the CsrWifiFsm Module
1663 clientData -
1664 controlIndication -
1665
1666*******************************************************************************/
1667typedef struct
1668{
1669 CsrWifiFsmEvent common;
1670 CsrWifiRouterCtrlRequestorInfo clientData;
1671 CsrWifiRouterCtrlControlIndication controlIndication;
1672} CsrWifiRouterCtrlWifiOffInd;
1673
1674/*******************************************************************************
1675
1676 NAME
1677 CsrWifiRouterCtrlWifiOffCfm
1678
1679 DESCRIPTION
1680
1681 MEMBERS
1682 common - Common header for use with the CsrWifiFsm Module
1683 clientData -
1684
1685*******************************************************************************/
1686typedef struct
1687{
1688 CsrWifiFsmEvent common;
1689 CsrWifiRouterCtrlRequestorInfo clientData;
1690} CsrWifiRouterCtrlWifiOffCfm;
1691
1692/*******************************************************************************
1693
1694 NAME
1695 CsrWifiRouterCtrlWifiOnInd
1696
1697 DESCRIPTION
1698
1699 MEMBERS
1700 common - Common header for use with the CsrWifiFsm Module
1701 clientData -
1702 status -
1703 versions -
1704
1705*******************************************************************************/
1706typedef struct
1707{
1708 CsrWifiFsmEvent common;
1709 CsrWifiRouterCtrlRequestorInfo clientData;
1710 CsrResult status;
1711 CsrWifiRouterCtrlVersions versions;
1712} CsrWifiRouterCtrlWifiOnInd;
1713
1714/*******************************************************************************
1715
1716 NAME
1717 CsrWifiRouterCtrlWifiOnCfm
1718
1719 DESCRIPTION
1720
1721 MEMBERS
1722 common - Common header for use with the CsrWifiFsm Module
1723 clientData -
1724 status -
1725
1726*******************************************************************************/
1727typedef struct
1728{
1729 CsrWifiFsmEvent common;
1730 CsrWifiRouterCtrlRequestorInfo clientData;
1731 CsrResult status;
1732} CsrWifiRouterCtrlWifiOnCfm;
1733
1734/*******************************************************************************
1735
1736 NAME
1737 CsrWifiRouterCtrlM4ReadyToSendInd
1738
1739 DESCRIPTION
1740
1741 MEMBERS
1742 common - Common header for use with the CsrWifiFsm Module
1743 clientData -
1744 interfaceTag -
1745 peerMacAddress -
1746
1747*******************************************************************************/
1748typedef struct
1749{
1750 CsrWifiFsmEvent common;
1751 CsrWifiRouterCtrlRequestorInfo clientData;
1752 u16 interfaceTag;
1753 CsrWifiMacAddress peerMacAddress;
1754} CsrWifiRouterCtrlM4ReadyToSendInd;
1755
1756/*******************************************************************************
1757
1758 NAME
1759 CsrWifiRouterCtrlM4TransmittedInd
1760
1761 DESCRIPTION
1762
1763 MEMBERS
1764 common - Common header for use with the CsrWifiFsm Module
1765 clientData -
1766 interfaceTag -
1767 peerMacAddress -
1768 status -
1769
1770*******************************************************************************/
1771typedef struct
1772{
1773 CsrWifiFsmEvent common;
1774 CsrWifiRouterCtrlRequestorInfo clientData;
1775 u16 interfaceTag;
1776 CsrWifiMacAddress peerMacAddress;
1777 CsrResult status;
1778} CsrWifiRouterCtrlM4TransmittedInd;
1779
1780/*******************************************************************************
1781
1782 NAME
1783 CsrWifiRouterCtrlMicFailureInd
1784
1785 DESCRIPTION
1786
1787 MEMBERS
1788 common - Common header for use with the CsrWifiFsm Module
1789 clientData -
1790 interfaceTag -
1791 peerMacAddress -
1792 unicastPdu -
1793
1794*******************************************************************************/
1795typedef struct
1796{
1797 CsrWifiFsmEvent common;
1798 CsrWifiRouterCtrlRequestorInfo clientData;
1799 u16 interfaceTag;
1800 CsrWifiMacAddress peerMacAddress;
1801 u8 unicastPdu;
1802} CsrWifiRouterCtrlMicFailureInd;
1803
1804/*******************************************************************************
1805
1806 NAME
1807 CsrWifiRouterCtrlConnectedInd
1808
1809 DESCRIPTION
1810
1811 MEMBERS
1812 common - Common header for use with the CsrWifiFsm Module
1813 clientData -
1814 interfaceTag -
1815 peerMacAddress -
1816 peerStatus -
1817
1818*******************************************************************************/
1819typedef struct
1820{
1821 CsrWifiFsmEvent common;
1822 CsrWifiRouterCtrlRequestorInfo clientData;
1823 u16 interfaceTag;
1824 CsrWifiMacAddress peerMacAddress;
1825 CsrWifiRouterCtrlPeerStatus peerStatus;
1826} CsrWifiRouterCtrlConnectedInd;
1827
1828/*******************************************************************************
1829
1830 NAME
1831 CsrWifiRouterCtrlPeerAddCfm
1832
1833 DESCRIPTION
1834
1835 MEMBERS
1836 common - Common header for use with the CsrWifiFsm Module
1837 clientData -
1838 interfaceTag -
1839 peerMacAddress -
1840 peerRecordHandle -
1841 status -
1842
1843*******************************************************************************/
1844typedef struct
1845{
1846 CsrWifiFsmEvent common;
1847 CsrWifiRouterCtrlRequestorInfo clientData;
1848 u16 interfaceTag;
1849 CsrWifiMacAddress peerMacAddress;
1850 CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
1851 CsrResult status;
1852} CsrWifiRouterCtrlPeerAddCfm;
1853
1854/*******************************************************************************
1855
1856 NAME
1857 CsrWifiRouterCtrlPeerDelCfm
1858
1859 DESCRIPTION
1860
1861 MEMBERS
1862 common - Common header for use with the CsrWifiFsm Module
1863 clientData -
1864 interfaceTag -
1865 status -
1866
1867*******************************************************************************/
1868typedef struct
1869{
1870 CsrWifiFsmEvent common;
1871 CsrWifiRouterCtrlRequestorInfo clientData;
1872 u16 interfaceTag;
1873 CsrResult status;
1874} CsrWifiRouterCtrlPeerDelCfm;
1875
1876/*******************************************************************************
1877
1878 NAME
1879 CsrWifiRouterCtrlUnexpectedFrameInd
1880
1881 DESCRIPTION
1882
1883 MEMBERS
1884 common - Common header for use with the CsrWifiFsm Module
1885 clientData -
1886 interfaceTag -
1887 peerMacAddress -
1888
1889*******************************************************************************/
1890typedef struct
1891{
1892 CsrWifiFsmEvent common;
1893 CsrWifiRouterCtrlRequestorInfo clientData;
1894 u16 interfaceTag;
1895 CsrWifiMacAddress peerMacAddress;
1896} CsrWifiRouterCtrlUnexpectedFrameInd;
1897
1898/*******************************************************************************
1899
1900 NAME
1901 CsrWifiRouterCtrlPeerUpdateCfm
1902
1903 DESCRIPTION
1904
1905 MEMBERS
1906 common - Common header for use with the CsrWifiFsm Module
1907 clientData -
1908 interfaceTag -
1909 status -
1910
1911*******************************************************************************/
1912typedef struct
1913{
1914 CsrWifiFsmEvent common;
1915 CsrWifiRouterCtrlRequestorInfo clientData;
1916 u16 interfaceTag;
1917 CsrResult status;
1918} CsrWifiRouterCtrlPeerUpdateCfm;
1919
1920/*******************************************************************************
1921
1922 NAME
1923 CsrWifiRouterCtrlCapabilitiesCfm
1924
1925 DESCRIPTION
1926 The router sends this primitive to confirm the size of the queues of the
1927 HIP.
1928
1929 MEMBERS
1930 common - Common header for use with the CsrWifiFsm Module
1931 clientData -
1932 commandQueueSize - Size of command queue
1933 trafficQueueSize - Size of traffic queue (per AC)
1934
1935*******************************************************************************/
1936typedef struct
1937{
1938 CsrWifiFsmEvent common;
1939 CsrWifiRouterCtrlRequestorInfo clientData;
1940 u16 commandQueueSize;
1941 u16 trafficQueueSize;
1942} CsrWifiRouterCtrlCapabilitiesCfm;
1943
1944/*******************************************************************************
1945
1946 NAME
1947 CsrWifiRouterCtrlBlockAckEnableCfm
1948
1949 DESCRIPTION
1950
1951 MEMBERS
1952 common - Common header for use with the CsrWifiFsm Module
1953 clientData -
1954 interfaceTag -
1955 status -
1956
1957*******************************************************************************/
1958typedef struct
1959{
1960 CsrWifiFsmEvent common;
1961 CsrWifiRouterCtrlRequestorInfo clientData;
1962 u16 interfaceTag;
1963 CsrResult status;
1964} CsrWifiRouterCtrlBlockAckEnableCfm;
1965
1966/*******************************************************************************
1967
1968 NAME
1969 CsrWifiRouterCtrlBlockAckDisableCfm
1970
1971 DESCRIPTION
1972
1973 MEMBERS
1974 common - Common header for use with the CsrWifiFsm Module
1975 clientData -
1976 interfaceTag -
1977 status -
1978
1979*******************************************************************************/
1980typedef struct
1981{
1982 CsrWifiFsmEvent common;
1983 CsrWifiRouterCtrlRequestorInfo clientData;
1984 u16 interfaceTag;
1985 CsrResult status;
1986} CsrWifiRouterCtrlBlockAckDisableCfm;
1987
1988/*******************************************************************************
1989
1990 NAME
1991 CsrWifiRouterCtrlBlockAckErrorInd
1992
1993 DESCRIPTION
1994
1995 MEMBERS
1996 common - Common header for use with the CsrWifiFsm Module
1997 clientData -
1998 interfaceTag -
1999 trafficStreamID -
2000 peerMacAddress -
2001 status -
2002
2003*******************************************************************************/
2004typedef struct
2005{
2006 CsrWifiFsmEvent common;
2007 CsrWifiRouterCtrlRequestorInfo clientData;
2008 u16 interfaceTag;
2009 CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
2010 CsrWifiMacAddress peerMacAddress;
2011 CsrResult status;
2012} CsrWifiRouterCtrlBlockAckErrorInd;
2013
2014/*******************************************************************************
2015
2016 NAME
2017 CsrWifiRouterCtrlStaInactiveInd
2018
2019 DESCRIPTION
2020
2021 MEMBERS
2022 common - Common header for use with the CsrWifiFsm Module
2023 clientData -
2024 interfaceTag -
2025 staAddress -
2026
2027*******************************************************************************/
2028typedef struct
2029{
2030 CsrWifiFsmEvent common;
2031 CsrWifiRouterCtrlRequestorInfo clientData;
2032 u16 interfaceTag;
2033 CsrWifiMacAddress staAddress;
2034} CsrWifiRouterCtrlStaInactiveInd;
2035
2036/*******************************************************************************
2037
2038 NAME
2039 CsrWifiRouterCtrlWapiRxMicCheckInd
2040
2041 DESCRIPTION
2042
2043 MEMBERS
2044 common - Common header for use with the CsrWifiFsm Module
2045 clientData -
2046 interfaceTag -
2047 signalLength -
2048 signal -
2049 dataLength -
2050 data -
2051
2052*******************************************************************************/
2053typedef struct
2054{
2055 CsrWifiFsmEvent common;
2056 CsrWifiRouterCtrlRequestorInfo clientData;
2057 u16 interfaceTag;
2058 u16 signalLength;
2059 u8 *signal;
2060 u16 dataLength;
2061 u8 *data;
2062} CsrWifiRouterCtrlWapiRxMicCheckInd;
2063
2064/*******************************************************************************
2065
2066 NAME
2067 CsrWifiRouterCtrlModeSetCfm
2068
2069 DESCRIPTION
2070
2071 MEMBERS
2072 common - Common header for use with the CsrWifiFsm Module
2073 clientData -
2074 interfaceTag -
2075 mode -
2076 status -
2077
2078*******************************************************************************/
2079typedef struct
2080{
2081 CsrWifiFsmEvent common;
2082 CsrWifiRouterCtrlRequestorInfo clientData;
2083 u16 interfaceTag;
2084 CsrWifiRouterCtrlMode mode;
2085 CsrResult status;
2086} CsrWifiRouterCtrlModeSetCfm;
2087
2088/*******************************************************************************
2089
2090 NAME
2091 CsrWifiRouterCtrlWapiUnicastTxEncryptInd
2092
2093 DESCRIPTION
2094
2095 MEMBERS
2096 common - Common header for use with the CsrWifiFsm Module
2097 clientData -
2098 interfaceTag -
2099 dataLength -
2100 data -
2101
2102*******************************************************************************/
2103typedef struct
2104{
2105 CsrWifiFsmEvent common;
2106 CsrWifiRouterCtrlRequestorInfo clientData;
2107 u16 interfaceTag;
2108 u16 dataLength;
2109 u8 *data;
2110} CsrWifiRouterCtrlWapiUnicastTxEncryptInd;
2111
2112#endif /* CSR_WIFI_ROUTER_CTRL_PRIM_H__ */
2113
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
index 99cf93061d1b..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_sef.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 Confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9 *****************************************************************************/
10#include "csr_wifi_router_ctrl_sef.h"
11
12const CsrWifiRouterCtrlStateHandlerType
13 CsrWifiRouterCtrlDownstreamStateHandlers
14 [CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT] = {
15 /* 0x0000 */ CsrWifiRouterCtrlConfigurePowerModeReqHandler,
16 /* 0x0001 */ CsrWifiRouterCtrlHipReqHandler,
17 /* 0x0002 */ CsrWifiRouterCtrlMediaStatusReqHandler,
18 /* 0x0003 */ CsrWifiRouterCtrlMulticastAddressResHandler,
19 /* 0x0004 */ CsrWifiRouterCtrlPortConfigureReqHandler,
20 /* 0x0005 */ CsrWifiRouterCtrlQosControlReqHandler,
21 /* 0x0006 */ CsrWifiRouterCtrlSuspendResHandler,
22 /* 0x0007 */ CsrWifiRouterCtrlTclasAddReqHandler,
23 /* 0x0008 */ CsrWifiRouterCtrlResumeResHandler,
24 /* 0x0009 */ CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler,
25 /* 0x000A */ CsrWifiRouterCtrlRawSdioInitialiseReqHandler,
26 /* 0x000B */ CsrWifiRouterCtrlTclasDelReqHandler,
27 /* 0x000C */ CsrWifiRouterCtrlTrafficClassificationReqHandler,
28 /* 0x000D */ CsrWifiRouterCtrlTrafficConfigReqHandler,
29 /* 0x000E */ CsrWifiRouterCtrlWifiOffReqHandler,
30 /* 0x000F */ CsrWifiRouterCtrlWifiOffResHandler,
31 /* 0x0010 */ CsrWifiRouterCtrlWifiOnReqHandler,
32 /* 0x0011 */ CsrWifiRouterCtrlWifiOnResHandler,
33 /* 0x0012 */ CsrWifiRouterCtrlM4TransmitReqHandler,
34 /* 0x0013 */ CsrWifiRouterCtrlModeSetReqHandler,
35 /* 0x0014 */ CsrWifiRouterCtrlPeerAddReqHandler,
36 /* 0x0015 */ CsrWifiRouterCtrlPeerDelReqHandler,
37 /* 0x0016 */ CsrWifiRouterCtrlPeerUpdateReqHandler,
38 /* 0x0017 */ CsrWifiRouterCtrlCapabilitiesReqHandler,
39 /* 0x0018 */ CsrWifiRouterCtrlBlockAckEnableReqHandler,
40 /* 0x0019 */ CsrWifiRouterCtrlBlockAckDisableReqHandler,
41 /* 0x001A */ CsrWifiRouterCtrlWapiRxPktReqHandler,
42 /* 0x001B */ CsrWifiRouterCtrlWapiMulticastFilterReqHandler,
43 /* 0x001C */ CsrWifiRouterCtrlWapiUnicastFilterReqHandler,
44 /* 0x001D */ CsrWifiRouterCtrlWapiUnicastTxPktReqHandler,
45 /* 0x001E */ CsrWifiRouterCtrlWapiFilterReqHandler,
46};
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
index 2fb4937bc909..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_sef.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 Confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9 *****************************************************************************/
10#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__
11#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__
12
13#include "csr_wifi_router_ctrl_prim.h"
14
15 typedef void (*CsrWifiRouterCtrlStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
16
17 extern const CsrWifiRouterCtrlStateHandlerType CsrWifiRouterCtrlDownstreamStateHandlers[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT];
18
19 extern void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
20 extern void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
21 extern void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
22 extern void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
23 extern void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
24 extern void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
25 extern void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
26 extern void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
27 extern void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
28 extern void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
29 extern void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
30 extern void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
31 extern void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
32 extern void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
33 extern void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
34 extern void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
35 extern void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
36 extern void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
37 extern void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
38 extern void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
39 extern void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
40 extern void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
41 extern void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
42 extern void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
43 extern void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
44 extern void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
45 extern void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
46 extern void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
47 extern void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
48 extern void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
49 extern void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
50
51#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
index 3eda1b66b336..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
+++ /dev/null
@@ -1,2591 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/string.h>
13#include <linux/slab.h>
14#include "csr_msgconv.h"
15#include "csr_wifi_router_ctrl_prim.h"
16#include "csr_wifi_router_ctrl_serialize.h"
17
18void CsrWifiRouterCtrlPfree(void *ptr)
19{
20 kfree(ptr);
21}
22
23
24size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg)
25{
26 size_t bufferSize = 2;
27
28 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
29 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
30 bufferSize += 2; /* CsrWifiRouterCtrlLowPowerMode primitive->mode */
31 bufferSize += 1; /* u8 primitive->wakeHost */
32 return bufferSize;
33}
34
35
36u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg)
37{
38 CsrWifiRouterCtrlConfigurePowerModeReq *primitive = (CsrWifiRouterCtrlConfigurePowerModeReq *)msg;
39 *len = 0;
40 CsrUint16Ser(ptr, len, primitive->common.type);
41 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
42 CsrUint16Ser(ptr, len, (u16) primitive->mode);
43 CsrUint8Ser(ptr, len, (u8) primitive->wakeHost);
44 return(ptr);
45}
46
47
48void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t length)
49{
50 CsrWifiRouterCtrlConfigurePowerModeReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL);
51 size_t offset;
52 offset = 0;
53
54 CsrUint16Des(&primitive->common.type, buffer, &offset);
55 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
56 CsrUint16Des((u16 *) &primitive->mode, buffer, &offset);
57 CsrUint8Des((u8 *) &primitive->wakeHost, buffer, &offset);
58
59 return primitive;
60}
61
62
63size_t CsrWifiRouterCtrlHipReqSizeof(void *msg)
64{
65 CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) msg;
66 size_t bufferSize = 2;
67
68 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
69 bufferSize += 2; /* u16 primitive->mlmeCommandLength */
70 bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */
71 bufferSize += 2; /* u16 primitive->dataRef1Length */
72 bufferSize += primitive->dataRef1Length; /* u8 primitive->dataRef1 */
73 bufferSize += 2; /* u16 primitive->dataRef2Length */
74 bufferSize += primitive->dataRef2Length; /* u8 primitive->dataRef2 */
75 return bufferSize;
76}
77
78
79u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg)
80{
81 CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *)msg;
82 *len = 0;
83 CsrUint16Ser(ptr, len, primitive->common.type);
84 CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength);
85 if (primitive->mlmeCommandLength)
86 {
87 CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength)));
88 }
89 CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length);
90 if (primitive->dataRef1Length)
91 {
92 CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length)));
93 }
94 CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length);
95 if (primitive->dataRef2Length)
96 {
97 CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length)));
98 }
99 return(ptr);
100}
101
102
103void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t length)
104{
105 CsrWifiRouterCtrlHipReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL);
106 size_t offset;
107 offset = 0;
108
109 CsrUint16Des(&primitive->common.type, buffer, &offset);
110 CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset);
111 if (primitive->mlmeCommandLength)
112 {
113 primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL);
114 CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength)));
115 }
116 else
117 {
118 primitive->mlmeCommand = NULL;
119 }
120 CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset);
121 if (primitive->dataRef1Length)
122 {
123 primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL);
124 CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length)));
125 }
126 else
127 {
128 primitive->dataRef1 = NULL;
129 }
130 CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset);
131 if (primitive->dataRef2Length)
132 {
133 primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL);
134 CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length)));
135 }
136 else
137 {
138 primitive->dataRef2 = NULL;
139 }
140
141 return primitive;
142}
143
144
145void CsrWifiRouterCtrlHipReqSerFree(void *voidPrimitivePointer)
146{
147 CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) voidPrimitivePointer;
148 kfree(primitive->mlmeCommand);
149 kfree(primitive->dataRef1);
150 kfree(primitive->dataRef2);
151 kfree(primitive);
152}
153
154
155size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg)
156{
157 size_t bufferSize = 2;
158
159 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
160 bufferSize += 2; /* u16 primitive->interfaceTag */
161 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
162 bufferSize += 1; /* CsrWifiRouterCtrlMediaStatus primitive->mediaStatus */
163 return bufferSize;
164}
165
166
167u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg)
168{
169 CsrWifiRouterCtrlMediaStatusReq *primitive = (CsrWifiRouterCtrlMediaStatusReq *)msg;
170 *len = 0;
171 CsrUint16Ser(ptr, len, primitive->common.type);
172 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
173 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
174 CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
175 return(ptr);
176}
177
178
179void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t length)
180{
181 CsrWifiRouterCtrlMediaStatusReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL);
182 size_t offset;
183 offset = 0;
184
185 CsrUint16Des(&primitive->common.type, buffer, &offset);
186 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
187 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
188 CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
189
190 return primitive;
191}
192
193
194size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg)
195{
196 CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) msg;
197 size_t bufferSize = 2;
198
199 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
200 bufferSize += 2; /* u16 primitive->interfaceTag */
201 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
202 bufferSize += 2; /* CsrResult primitive->status */
203 bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */
204 bufferSize += 1; /* u8 primitive->getAddressesCount */
205 {
206 u16 i1;
207 for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
208 {
209 bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
210 }
211 }
212 return bufferSize;
213}
214
215
216u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg)
217{
218 CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *)msg;
219 *len = 0;
220 CsrUint16Ser(ptr, len, primitive->common.type);
221 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
222 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
223 CsrUint16Ser(ptr, len, (u16) primitive->status);
224 CsrUint8Ser(ptr, len, (u8) primitive->action);
225 CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount);
226 {
227 u16 i1;
228 for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
229 {
230 CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
231 }
232 }
233 return(ptr);
234}
235
236
237void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t length)
238{
239 CsrWifiRouterCtrlMulticastAddressRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL);
240 size_t offset;
241 offset = 0;
242
243 CsrUint16Des(&primitive->common.type, buffer, &offset);
244 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
245 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
246 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
247 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
248 CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset);
249 primitive->getAddresses = NULL;
250 if (primitive->getAddressesCount)
251 {
252 primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL);
253 }
254 {
255 u16 i1;
256 for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
257 {
258 CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
259 }
260 }
261
262 return primitive;
263}
264
265
266void CsrWifiRouterCtrlMulticastAddressResSerFree(void *voidPrimitivePointer)
267{
268 CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) voidPrimitivePointer;
269 kfree(primitive->getAddresses);
270 kfree(primitive);
271}
272
273
274size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg)
275{
276 size_t bufferSize = 2;
277
278 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
279 bufferSize += 2; /* u16 primitive->interfaceTag */
280 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
281 bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->uncontrolledPortAction */
282 bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->controlledPortAction */
283 bufferSize += 6; /* u8 primitive->macAddress.a[6] */
284 bufferSize += 1; /* u8 primitive->setProtection */
285 return bufferSize;
286}
287
288
289u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg)
290{
291 CsrWifiRouterCtrlPortConfigureReq *primitive = (CsrWifiRouterCtrlPortConfigureReq *)msg;
292 *len = 0;
293 CsrUint16Ser(ptr, len, primitive->common.type);
294 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
295 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
296 CsrUint16Ser(ptr, len, (u16) primitive->uncontrolledPortAction);
297 CsrUint16Ser(ptr, len, (u16) primitive->controlledPortAction);
298 CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
299 CsrUint8Ser(ptr, len, (u8) primitive->setProtection);
300 return(ptr);
301}
302
303
304void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t length)
305{
306 CsrWifiRouterCtrlPortConfigureReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL);
307 size_t offset;
308 offset = 0;
309
310 CsrUint16Des(&primitive->common.type, buffer, &offset);
311 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
312 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
313 CsrUint16Des((u16 *) &primitive->uncontrolledPortAction, buffer, &offset);
314 CsrUint16Des((u16 *) &primitive->controlledPortAction, buffer, &offset);
315 CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
316 CsrUint8Des((u8 *) &primitive->setProtection, buffer, &offset);
317
318 return primitive;
319}
320
321
322size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg)
323{
324 size_t bufferSize = 2;
325
326 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
327 bufferSize += 2; /* u16 primitive->interfaceTag */
328 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
329 bufferSize += 2; /* CsrWifiRouterCtrlQoSControl primitive->control */
330 bufferSize += 1; /* CsrWifiRouterCtrlQueueConfigMask primitive->queueConfig */
331 return bufferSize;
332}
333
334
335u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg)
336{
337 CsrWifiRouterCtrlQosControlReq *primitive = (CsrWifiRouterCtrlQosControlReq *)msg;
338 *len = 0;
339 CsrUint16Ser(ptr, len, primitive->common.type);
340 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
341 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
342 CsrUint16Ser(ptr, len, (u16) primitive->control);
343 CsrUint8Ser(ptr, len, (u8) primitive->queueConfig);
344 return(ptr);
345}
346
347
348void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t length)
349{
350 CsrWifiRouterCtrlQosControlReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL);
351 size_t offset;
352 offset = 0;
353
354 CsrUint16Des(&primitive->common.type, buffer, &offset);
355 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
356 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
357 CsrUint16Des((u16 *) &primitive->control, buffer, &offset);
358 CsrUint8Des((u8 *) &primitive->queueConfig, buffer, &offset);
359
360 return primitive;
361}
362
363
364size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg)
365{
366 size_t bufferSize = 2;
367
368 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
369 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
370 bufferSize += 2; /* CsrResult primitive->status */
371 return bufferSize;
372}
373
374
375u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg)
376{
377 CsrWifiRouterCtrlSuspendRes *primitive = (CsrWifiRouterCtrlSuspendRes *)msg;
378 *len = 0;
379 CsrUint16Ser(ptr, len, primitive->common.type);
380 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
381 CsrUint16Ser(ptr, len, (u16) primitive->status);
382 return(ptr);
383}
384
385
386void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t length)
387{
388 CsrWifiRouterCtrlSuspendRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL);
389 size_t offset;
390 offset = 0;
391
392 CsrUint16Des(&primitive->common.type, buffer, &offset);
393 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
394 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
395
396 return primitive;
397}
398
399
400size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg)
401{
402 CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) msg;
403 size_t bufferSize = 2;
404
405 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
406 bufferSize += 2; /* u16 primitive->interfaceTag */
407 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
408 bufferSize += 2; /* u16 primitive->tclasLength */
409 bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
410 return bufferSize;
411}
412
413
414u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg)
415{
416 CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *)msg;
417 *len = 0;
418 CsrUint16Ser(ptr, len, primitive->common.type);
419 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
420 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
421 CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
422 if (primitive->tclasLength)
423 {
424 CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
425 }
426 return(ptr);
427}
428
429
430void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t length)
431{
432 CsrWifiRouterCtrlTclasAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL);
433 size_t offset;
434 offset = 0;
435
436 CsrUint16Des(&primitive->common.type, buffer, &offset);
437 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
438 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
439 CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
440 if (primitive->tclasLength)
441 {
442 primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
443 CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
444 }
445 else
446 {
447 primitive->tclas = NULL;
448 }
449
450 return primitive;
451}
452
453
454void CsrWifiRouterCtrlTclasAddReqSerFree(void *voidPrimitivePointer)
455{
456 CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) voidPrimitivePointer;
457 kfree(primitive->tclas);
458 kfree(primitive);
459}
460
461
462size_t CsrWifiRouterCtrlResumeResSizeof(void *msg)
463{
464 size_t bufferSize = 2;
465
466 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
467 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
468 bufferSize += 2; /* CsrResult primitive->status */
469 return bufferSize;
470}
471
472
473u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg)
474{
475 CsrWifiRouterCtrlResumeRes *primitive = (CsrWifiRouterCtrlResumeRes *)msg;
476 *len = 0;
477 CsrUint16Ser(ptr, len, primitive->common.type);
478 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
479 CsrUint16Ser(ptr, len, (u16) primitive->status);
480 return(ptr);
481}
482
483
484void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t length)
485{
486 CsrWifiRouterCtrlResumeRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL);
487 size_t offset;
488 offset = 0;
489
490 CsrUint16Des(&primitive->common.type, buffer, &offset);
491 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
492 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
493
494 return primitive;
495}
496
497
498size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg)
499{
500 CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) msg;
501 size_t bufferSize = 2;
502
503 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
504 bufferSize += 2; /* u16 primitive->interfaceTag */
505 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
506 bufferSize += 2; /* u16 primitive->tclasLength */
507 bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
508 return bufferSize;
509}
510
511
512u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg)
513{
514 CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *)msg;
515 *len = 0;
516 CsrUint16Ser(ptr, len, primitive->common.type);
517 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
518 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
519 CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
520 if (primitive->tclasLength)
521 {
522 CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
523 }
524 return(ptr);
525}
526
527
528void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t length)
529{
530 CsrWifiRouterCtrlTclasDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL);
531 size_t offset;
532 offset = 0;
533
534 CsrUint16Des(&primitive->common.type, buffer, &offset);
535 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
536 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
537 CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
538 if (primitive->tclasLength)
539 {
540 primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
541 CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
542 }
543 else
544 {
545 primitive->tclas = NULL;
546 }
547
548 return primitive;
549}
550
551
552void CsrWifiRouterCtrlTclasDelReqSerFree(void *voidPrimitivePointer)
553{
554 CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) voidPrimitivePointer;
555 kfree(primitive->tclas);
556 kfree(primitive);
557}
558
559
560size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg)
561{
562 size_t bufferSize = 2;
563
564 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
565 bufferSize += 2; /* u16 primitive->interfaceTag */
566 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
567 bufferSize += 1; /* CsrWifiRouterCtrlTrafficType primitive->trafficType */
568 bufferSize += 2; /* u16 primitive->period */
569 return bufferSize;
570}
571
572
573u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg)
574{
575 CsrWifiRouterCtrlTrafficClassificationReq *primitive = (CsrWifiRouterCtrlTrafficClassificationReq *)msg;
576 *len = 0;
577 CsrUint16Ser(ptr, len, primitive->common.type);
578 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
579 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
580 CsrUint8Ser(ptr, len, (u8) primitive->trafficType);
581 CsrUint16Ser(ptr, len, (u16) primitive->period);
582 return(ptr);
583}
584
585
586void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t length)
587{
588 CsrWifiRouterCtrlTrafficClassificationReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL);
589 size_t offset;
590 offset = 0;
591
592 CsrUint16Des(&primitive->common.type, buffer, &offset);
593 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
594 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
595 CsrUint8Des((u8 *) &primitive->trafficType, buffer, &offset);
596 CsrUint16Des((u16 *) &primitive->period, buffer, &offset);
597
598 return primitive;
599}
600
601
602size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg)
603{
604 size_t bufferSize = 2;
605
606 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */
607 bufferSize += 2; /* u16 primitive->interfaceTag */
608 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
609 bufferSize += 2; /* CsrWifiRouterCtrlTrafficConfigType primitive->trafficConfigType */
610 bufferSize += 2; /* u16 primitive->config.packetFilter */
611 bufferSize += 4; /* u32 primitive->config.customFilter.etherType */
612 bufferSize += 1; /* u8 primitive->config.customFilter.ipType */
613 bufferSize += 4; /* u32 primitive->config.customFilter.udpSourcePort */
614 bufferSize += 4; /* u32 primitive->config.customFilter.udpDestPort */
615 return bufferSize;
616}
617
618
619u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg)
620{
621 CsrWifiRouterCtrlTrafficConfigReq *primitive = (CsrWifiRouterCtrlTrafficConfigReq *)msg;
622 *len = 0;
623 CsrUint16Ser(ptr, len, primitive->common.type);
624 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
625 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
626 CsrUint16Ser(ptr, len, (u16) primitive->trafficConfigType);
627 CsrUint16Ser(ptr, len, (u16) primitive->config.packetFilter);
628 CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.etherType);
629 CsrUint8Ser(ptr, len, (u8) primitive->config.customFilter.ipType);
630 CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpSourcePort);
631 CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpDestPort);
632 return(ptr);
633}
634
635
636void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t length)
637{
638 CsrWifiRouterCtrlTrafficConfigReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL);
639 size_t offset;
640 offset = 0;
641
642 CsrUint16Des(&primitive->common.type, buffer, &offset);
643 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
644 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
645 CsrUint16Des((u16 *) &primitive->trafficConfigType, buffer, &offset);
646 CsrUint16Des((u16 *) &primitive->config.packetFilter, buffer, &offset);
647 CsrUint32Des((u32 *) &primitive->config.customFilter.etherType, buffer, &offset);
648 CsrUint8Des((u8 *) &primitive->config.customFilter.ipType, buffer, &offset);
649 CsrUint32Des((u32 *) &primitive->config.customFilter.udpSourcePort, buffer, &offset);
650 CsrUint32Des((u32 *) &primitive->config.customFilter.udpDestPort, buffer, &offset);
651
652 return primitive;
653}
654
655
656size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg)
657{
658 CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) msg;
659 size_t bufferSize = 2;
660
661 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
662 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
663 bufferSize += 4; /* u32 primitive->dataLength */
664 bufferSize += primitive->dataLength; /* u8 primitive->data */
665 return bufferSize;
666}
667
668
669u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg)
670{
671 CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *)msg;
672 *len = 0;
673 CsrUint16Ser(ptr, len, primitive->common.type);
674 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
675 CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
676 if (primitive->dataLength)
677 {
678 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
679 }
680 return(ptr);
681}
682
683
684void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t length)
685{
686 CsrWifiRouterCtrlWifiOnReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL);
687 size_t offset;
688 offset = 0;
689
690 CsrUint16Des(&primitive->common.type, buffer, &offset);
691 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
692 CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
693 if (primitive->dataLength)
694 {
695 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
696 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
697 }
698 else
699 {
700 primitive->data = NULL;
701 }
702
703 return primitive;
704}
705
706
707void CsrWifiRouterCtrlWifiOnReqSerFree(void *voidPrimitivePointer)
708{
709 CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) voidPrimitivePointer;
710 kfree(primitive->data);
711 kfree(primitive);
712}
713
714
715size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg)
716{
717 CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) msg;
718 size_t bufferSize = 2;
719
720 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 30) */
721 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
722 bufferSize += 2; /* CsrResult primitive->status */
723 bufferSize += 2; /* u16 primitive->numInterfaceAddress */
724 {
725 u16 i1;
726 for (i1 = 0; i1 < 2; i1++)
727 {
728 bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */
729 }
730 }
731 bufferSize += 4; /* u32 primitive->smeVersions.firmwarePatch */
732 bufferSize += (primitive->smeVersions.smeBuild ? strlen(primitive->smeVersions.smeBuild) : 0) + 1; /* char* primitive->smeVersions.smeBuild (0 byte len + 1 for NULL Term) */
733 bufferSize += 4; /* u32 primitive->smeVersions.smeHip */
734 bufferSize += 1; /* u8 primitive->scheduledInterrupt */
735 return bufferSize;
736}
737
738
739u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg)
740{
741 CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *)msg;
742 *len = 0;
743 CsrUint16Ser(ptr, len, primitive->common.type);
744 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
745 CsrUint16Ser(ptr, len, (u16) primitive->status);
746 CsrUint16Ser(ptr, len, (u16) primitive->numInterfaceAddress);
747 {
748 u16 i1;
749 for (i1 = 0; i1 < 2; i1++)
750 {
751 CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6)));
752 }
753 }
754 CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.firmwarePatch);
755 CsrCharStringSer(ptr, len, primitive->smeVersions.smeBuild);
756 CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.smeHip);
757 CsrUint8Ser(ptr, len, (u8) primitive->scheduledInterrupt);
758 return(ptr);
759}
760
761
762void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t length)
763{
764 CsrWifiRouterCtrlWifiOnRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL);
765 size_t offset;
766 offset = 0;
767
768 CsrUint16Des(&primitive->common.type, buffer, &offset);
769 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
770 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
771 CsrUint16Des((u16 *) &primitive->numInterfaceAddress, buffer, &offset);
772 {
773 u16 i1;
774 for (i1 = 0; i1 < 2; i1++)
775 {
776 CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6)));
777 }
778 }
779 CsrUint32Des((u32 *) &primitive->smeVersions.firmwarePatch, buffer, &offset);
780 CsrCharStringDes(&primitive->smeVersions.smeBuild, buffer, &offset);
781 CsrUint32Des((u32 *) &primitive->smeVersions.smeHip, buffer, &offset);
782 CsrUint8Des((u8 *) &primitive->scheduledInterrupt, buffer, &offset);
783
784 return primitive;
785}
786
787
788void CsrWifiRouterCtrlWifiOnResSerFree(void *voidPrimitivePointer)
789{
790 CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) voidPrimitivePointer;
791 kfree(primitive->smeVersions.smeBuild);
792 kfree(primitive);
793}
794
795
796size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg)
797{
798 size_t bufferSize = 2;
799
800 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
801 bufferSize += 2; /* u16 primitive->interfaceTag */
802 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
803 return bufferSize;
804}
805
806
807u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg)
808{
809 CsrWifiRouterCtrlM4TransmitReq *primitive = (CsrWifiRouterCtrlM4TransmitReq *)msg;
810 *len = 0;
811 CsrUint16Ser(ptr, len, primitive->common.type);
812 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
813 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
814 return(ptr);
815}
816
817
818void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t length)
819{
820 CsrWifiRouterCtrlM4TransmitReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL);
821 size_t offset;
822 offset = 0;
823
824 CsrUint16Des(&primitive->common.type, buffer, &offset);
825 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
826 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
827
828 return primitive;
829}
830
831
832size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg)
833{
834 size_t bufferSize = 2;
835
836 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */
837 bufferSize += 2; /* u16 primitive->interfaceTag */
838 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
839 bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */
840 bufferSize += 6; /* u8 primitive->bssid.a[6] */
841 bufferSize += 1; /* u8 primitive->protection */
842 bufferSize += 1; /* u8 primitive->intraBssDistEnabled */
843 return bufferSize;
844}
845
846
847u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg)
848{
849 CsrWifiRouterCtrlModeSetReq *primitive = (CsrWifiRouterCtrlModeSetReq *)msg;
850 *len = 0;
851 CsrUint16Ser(ptr, len, primitive->common.type);
852 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
853 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
854 CsrUint8Ser(ptr, len, (u8) primitive->mode);
855 CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6)));
856 CsrUint8Ser(ptr, len, (u8) primitive->protection);
857 CsrUint8Ser(ptr, len, (u8) primitive->intraBssDistEnabled);
858 return(ptr);
859}
860
861
862void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t length)
863{
864 CsrWifiRouterCtrlModeSetReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL);
865 size_t offset;
866 offset = 0;
867
868 CsrUint16Des(&primitive->common.type, buffer, &offset);
869 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
870 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
871 CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
872 CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6)));
873 CsrUint8Des((u8 *) &primitive->protection, buffer, &offset);
874 CsrUint8Des((u8 *) &primitive->intraBssDistEnabled, buffer, &offset);
875
876 return primitive;
877}
878
879
880size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg)
881{
882 size_t bufferSize = 2;
883
884 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
885 bufferSize += 2; /* u16 primitive->interfaceTag */
886 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
887 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
888 bufferSize += 2; /* u16 primitive->associationId */
889 bufferSize += 1; /* u8 primitive->staInfo.wmmOrQosEnabled */
890 bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->staInfo.powersaveMode */
891 bufferSize += 1; /* u8 primitive->staInfo.maxSpLength */
892 bufferSize += 2; /* u16 primitive->staInfo.listenIntervalInTus */
893 return bufferSize;
894}
895
896
897u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg)
898{
899 CsrWifiRouterCtrlPeerAddReq *primitive = (CsrWifiRouterCtrlPeerAddReq *)msg;
900 *len = 0;
901 CsrUint16Ser(ptr, len, primitive->common.type);
902 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
903 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
904 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
905 CsrUint16Ser(ptr, len, (u16) primitive->associationId);
906 CsrUint8Ser(ptr, len, (u8) primitive->staInfo.wmmOrQosEnabled);
907 CsrUint16Ser(ptr, len, (u16) primitive->staInfo.powersaveMode);
908 CsrUint8Ser(ptr, len, (u8) primitive->staInfo.maxSpLength);
909 CsrUint16Ser(ptr, len, (u16) primitive->staInfo.listenIntervalInTus);
910 return(ptr);
911}
912
913
914void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t length)
915{
916 CsrWifiRouterCtrlPeerAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL);
917 size_t offset;
918 offset = 0;
919
920 CsrUint16Des(&primitive->common.type, buffer, &offset);
921 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
922 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
923 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
924 CsrUint16Des((u16 *) &primitive->associationId, buffer, &offset);
925 CsrUint8Des((u8 *) &primitive->staInfo.wmmOrQosEnabled, buffer, &offset);
926 CsrUint16Des((u16 *) &primitive->staInfo.powersaveMode, buffer, &offset);
927 CsrUint8Des((u8 *) &primitive->staInfo.maxSpLength, buffer, &offset);
928 CsrUint16Des((u16 *) &primitive->staInfo.listenIntervalInTus, buffer, &offset);
929
930 return primitive;
931}
932
933
934size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg)
935{
936 size_t bufferSize = 2;
937
938 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
939 bufferSize += 2; /* u16 primitive->interfaceTag */
940 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
941 bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
942 return bufferSize;
943}
944
945
946u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg)
947{
948 CsrWifiRouterCtrlPeerDelReq *primitive = (CsrWifiRouterCtrlPeerDelReq *)msg;
949 *len = 0;
950 CsrUint16Ser(ptr, len, primitive->common.type);
951 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
952 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
953 CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
954 return(ptr);
955}
956
957
958void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t length)
959{
960 CsrWifiRouterCtrlPeerDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL);
961 size_t offset;
962 offset = 0;
963
964 CsrUint16Des(&primitive->common.type, buffer, &offset);
965 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
966 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
967 CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
968
969 return primitive;
970}
971
972
973size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg)
974{
975 size_t bufferSize = 2;
976
977 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
978 bufferSize += 2; /* u16 primitive->interfaceTag */
979 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
980 bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
981 bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->powersaveMode */
982 return bufferSize;
983}
984
985
986u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg)
987{
988 CsrWifiRouterCtrlPeerUpdateReq *primitive = (CsrWifiRouterCtrlPeerUpdateReq *)msg;
989 *len = 0;
990 CsrUint16Ser(ptr, len, primitive->common.type);
991 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
992 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
993 CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
994 CsrUint16Ser(ptr, len, (u16) primitive->powersaveMode);
995 return(ptr);
996}
997
998
999void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t length)
1000{
1001 CsrWifiRouterCtrlPeerUpdateReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL);
1002 size_t offset;
1003 offset = 0;
1004
1005 CsrUint16Des(&primitive->common.type, buffer, &offset);
1006 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1007 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1008 CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
1009 CsrUint16Des((u16 *) &primitive->powersaveMode, buffer, &offset);
1010
1011 return primitive;
1012}
1013
1014
1015size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg)
1016{
1017 size_t bufferSize = 2;
1018
1019 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
1020 bufferSize += 2; /* u16 primitive->interfaceTag */
1021 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1022 bufferSize += 6; /* u8 primitive->macAddress.a[6] */
1023 bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
1024 bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */
1025 bufferSize += 2; /* u16 primitive->bufferSize */
1026 bufferSize += 2; /* u16 primitive->timeout */
1027 bufferSize += 2; /* u16 primitive->ssn */
1028 return bufferSize;
1029}
1030
1031
1032u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg)
1033{
1034 CsrWifiRouterCtrlBlockAckEnableReq *primitive = (CsrWifiRouterCtrlBlockAckEnableReq *)msg;
1035 *len = 0;
1036 CsrUint16Ser(ptr, len, primitive->common.type);
1037 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1038 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1039 CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
1040 CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
1041 CsrUint8Ser(ptr, len, (u8) primitive->role);
1042 CsrUint16Ser(ptr, len, (u16) primitive->bufferSize);
1043 CsrUint16Ser(ptr, len, (u16) primitive->timeout);
1044 CsrUint16Ser(ptr, len, (u16) primitive->ssn);
1045 return(ptr);
1046}
1047
1048
1049void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t length)
1050{
1051 CsrWifiRouterCtrlBlockAckEnableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL);
1052 size_t offset;
1053 offset = 0;
1054
1055 CsrUint16Des(&primitive->common.type, buffer, &offset);
1056 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1057 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1058 CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
1059 CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
1060 CsrUint8Des((u8 *) &primitive->role, buffer, &offset);
1061 CsrUint16Des((u16 *) &primitive->bufferSize, buffer, &offset);
1062 CsrUint16Des((u16 *) &primitive->timeout, buffer, &offset);
1063 CsrUint16Des((u16 *) &primitive->ssn, buffer, &offset);
1064
1065 return primitive;
1066}
1067
1068
1069size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg)
1070{
1071 size_t bufferSize = 2;
1072
1073 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
1074 bufferSize += 2; /* u16 primitive->interfaceTag */
1075 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1076 bufferSize += 6; /* u8 primitive->macAddress.a[6] */
1077 bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
1078 bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */
1079 return bufferSize;
1080}
1081
1082
1083u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg)
1084{
1085 CsrWifiRouterCtrlBlockAckDisableReq *primitive = (CsrWifiRouterCtrlBlockAckDisableReq *)msg;
1086 *len = 0;
1087 CsrUint16Ser(ptr, len, primitive->common.type);
1088 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1089 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1090 CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
1091 CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
1092 CsrUint8Ser(ptr, len, (u8) primitive->role);
1093 return(ptr);
1094}
1095
1096
1097void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t length)
1098{
1099 CsrWifiRouterCtrlBlockAckDisableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL);
1100 size_t offset;
1101 offset = 0;
1102
1103 CsrUint16Des(&primitive->common.type, buffer, &offset);
1104 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1105 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1106 CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
1107 CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
1108 CsrUint8Des((u8 *) &primitive->role, buffer, &offset);
1109
1110 return primitive;
1111}
1112
1113
1114size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg)
1115{
1116 CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) msg;
1117 size_t bufferSize = 2;
1118
1119 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
1120 bufferSize += 2; /* u16 primitive->interfaceTag */
1121 bufferSize += 2; /* u16 primitive->signalLength */
1122 bufferSize += primitive->signalLength; /* u8 primitive->signal */
1123 bufferSize += 2; /* u16 primitive->dataLength */
1124 bufferSize += primitive->dataLength; /* u8 primitive->data */
1125 return bufferSize;
1126}
1127
1128
1129u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg)
1130{
1131 CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *)msg;
1132 *len = 0;
1133 CsrUint16Ser(ptr, len, primitive->common.type);
1134 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1135 CsrUint16Ser(ptr, len, (u16) primitive->signalLength);
1136 if (primitive->signalLength)
1137 {
1138 CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength)));
1139 }
1140 CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
1141 if (primitive->dataLength)
1142 {
1143 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
1144 }
1145 return(ptr);
1146}
1147
1148
1149void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t length)
1150{
1151 CsrWifiRouterCtrlWapiRxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL);
1152 size_t offset;
1153 offset = 0;
1154
1155 CsrUint16Des(&primitive->common.type, buffer, &offset);
1156 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1157 CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset);
1158 if (primitive->signalLength)
1159 {
1160 primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL);
1161 CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength)));
1162 }
1163 else
1164 {
1165 primitive->signal = NULL;
1166 }
1167 CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
1168 if (primitive->dataLength)
1169 {
1170 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
1171 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
1172 }
1173 else
1174 {
1175 primitive->data = NULL;
1176 }
1177
1178 return primitive;
1179}
1180
1181
1182void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *voidPrimitivePointer)
1183{
1184 CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) voidPrimitivePointer;
1185 kfree(primitive->signal);
1186 kfree(primitive->data);
1187 kfree(primitive);
1188}
1189
1190
1191size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg)
1192{
1193 CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) msg;
1194 size_t bufferSize = 2;
1195
1196 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
1197 bufferSize += 2; /* u16 primitive->interfaceTag */
1198 bufferSize += 2; /* u16 primitive->dataLength */
1199 bufferSize += primitive->dataLength; /* u8 primitive->data */
1200 return bufferSize;
1201}
1202
1203
1204u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg)
1205{
1206 CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)msg;
1207 *len = 0;
1208 CsrUint16Ser(ptr, len, primitive->common.type);
1209 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1210 CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
1211 if (primitive->dataLength)
1212 {
1213 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
1214 }
1215 return(ptr);
1216}
1217
1218
1219void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t length)
1220{
1221 CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL);
1222 size_t offset;
1223 offset = 0;
1224
1225 CsrUint16Des(&primitive->common.type, buffer, &offset);
1226 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1227 CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
1228 if (primitive->dataLength)
1229 {
1230 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
1231 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
1232 }
1233 else
1234 {
1235 primitive->data = NULL;
1236 }
1237
1238 return primitive;
1239}
1240
1241
1242void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *voidPrimitivePointer)
1243{
1244 CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) voidPrimitivePointer;
1245 kfree(primitive->data);
1246 kfree(primitive);
1247}
1248
1249
1250size_t CsrWifiRouterCtrlHipIndSizeof(void *msg)
1251{
1252 CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) msg;
1253 size_t bufferSize = 2;
1254
1255 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
1256 bufferSize += 2; /* u16 primitive->mlmeCommandLength */
1257 bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */
1258 bufferSize += 2; /* u16 primitive->dataRef1Length */
1259 bufferSize += primitive->dataRef1Length; /* u8 primitive->dataRef1 */
1260 bufferSize += 2; /* u16 primitive->dataRef2Length */
1261 bufferSize += primitive->dataRef2Length; /* u8 primitive->dataRef2 */
1262 return bufferSize;
1263}
1264
1265
1266u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg)
1267{
1268 CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *)msg;
1269 *len = 0;
1270 CsrUint16Ser(ptr, len, primitive->common.type);
1271 CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength);
1272 if (primitive->mlmeCommandLength)
1273 {
1274 CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength)));
1275 }
1276 CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length);
1277 if (primitive->dataRef1Length)
1278 {
1279 CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length)));
1280 }
1281 CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length);
1282 if (primitive->dataRef2Length)
1283 {
1284 CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length)));
1285 }
1286 return(ptr);
1287}
1288
1289
1290void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t length)
1291{
1292 CsrWifiRouterCtrlHipInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL);
1293 size_t offset;
1294 offset = 0;
1295
1296 CsrUint16Des(&primitive->common.type, buffer, &offset);
1297 CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset);
1298 if (primitive->mlmeCommandLength)
1299 {
1300 primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL);
1301 CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength)));
1302 }
1303 else
1304 {
1305 primitive->mlmeCommand = NULL;
1306 }
1307 CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset);
1308 if (primitive->dataRef1Length)
1309 {
1310 primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL);
1311 CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length)));
1312 }
1313 else
1314 {
1315 primitive->dataRef1 = NULL;
1316 }
1317 CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset);
1318 if (primitive->dataRef2Length)
1319 {
1320 primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL);
1321 CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length)));
1322 }
1323 else
1324 {
1325 primitive->dataRef2 = NULL;
1326 }
1327
1328 return primitive;
1329}
1330
1331
1332void CsrWifiRouterCtrlHipIndSerFree(void *voidPrimitivePointer)
1333{
1334 CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) voidPrimitivePointer;
1335 kfree(primitive->mlmeCommand);
1336 kfree(primitive->dataRef1);
1337 kfree(primitive->dataRef2);
1338 kfree(primitive);
1339}
1340
1341
1342size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg)
1343{
1344 CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) msg;
1345 size_t bufferSize = 2;
1346
1347 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
1348 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1349 bufferSize += 2; /* u16 primitive->interfaceTag */
1350 bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */
1351 bufferSize += 1; /* u8 primitive->setAddressesCount */
1352 {
1353 u16 i1;
1354 for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
1355 {
1356 bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
1357 }
1358 }
1359 return bufferSize;
1360}
1361
1362
1363u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg)
1364{
1365 CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *)msg;
1366 *len = 0;
1367 CsrUint16Ser(ptr, len, primitive->common.type);
1368 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1369 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1370 CsrUint8Ser(ptr, len, (u8) primitive->action);
1371 CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount);
1372 {
1373 u16 i1;
1374 for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
1375 {
1376 CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
1377 }
1378 }
1379 return(ptr);
1380}
1381
1382
1383void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t length)
1384{
1385 CsrWifiRouterCtrlMulticastAddressInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL);
1386 size_t offset;
1387 offset = 0;
1388
1389 CsrUint16Des(&primitive->common.type, buffer, &offset);
1390 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1391 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1392 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
1393 CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset);
1394 primitive->setAddresses = NULL;
1395 if (primitive->setAddressesCount)
1396 {
1397 primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL);
1398 }
1399 {
1400 u16 i1;
1401 for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
1402 {
1403 CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
1404 }
1405 }
1406
1407 return primitive;
1408}
1409
1410
1411void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *voidPrimitivePointer)
1412{
1413 CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) voidPrimitivePointer;
1414 kfree(primitive->setAddresses);
1415 kfree(primitive);
1416}
1417
1418
1419size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg)
1420{
1421 size_t bufferSize = 2;
1422
1423 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
1424 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1425 bufferSize += 2; /* u16 primitive->interfaceTag */
1426 bufferSize += 2; /* CsrResult primitive->status */
1427 bufferSize += 6; /* u8 primitive->macAddress.a[6] */
1428 return bufferSize;
1429}
1430
1431
1432u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg)
1433{
1434 CsrWifiRouterCtrlPortConfigureCfm *primitive = (CsrWifiRouterCtrlPortConfigureCfm *)msg;
1435 *len = 0;
1436 CsrUint16Ser(ptr, len, primitive->common.type);
1437 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1438 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1439 CsrUint16Ser(ptr, len, (u16) primitive->status);
1440 CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
1441 return(ptr);
1442}
1443
1444
1445void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t length)
1446{
1447 CsrWifiRouterCtrlPortConfigureCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL);
1448 size_t offset;
1449 offset = 0;
1450
1451 CsrUint16Des(&primitive->common.type, buffer, &offset);
1452 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1453 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1454 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1455 CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
1456
1457 return primitive;
1458}
1459
1460
1461size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg)
1462{
1463 size_t bufferSize = 2;
1464
1465 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
1466 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1467 bufferSize += 1; /* u8 primitive->hardSuspend */
1468 bufferSize += 1; /* u8 primitive->d3Suspend */
1469 return bufferSize;
1470}
1471
1472
1473u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg)
1474{
1475 CsrWifiRouterCtrlSuspendInd *primitive = (CsrWifiRouterCtrlSuspendInd *)msg;
1476 *len = 0;
1477 CsrUint16Ser(ptr, len, primitive->common.type);
1478 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1479 CsrUint8Ser(ptr, len, (u8) primitive->hardSuspend);
1480 CsrUint8Ser(ptr, len, (u8) primitive->d3Suspend);
1481 return(ptr);
1482}
1483
1484
1485void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t length)
1486{
1487 CsrWifiRouterCtrlSuspendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL);
1488 size_t offset;
1489 offset = 0;
1490
1491 CsrUint16Des(&primitive->common.type, buffer, &offset);
1492 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1493 CsrUint8Des((u8 *) &primitive->hardSuspend, buffer, &offset);
1494 CsrUint8Des((u8 *) &primitive->d3Suspend, buffer, &offset);
1495
1496 return primitive;
1497}
1498
1499
1500size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg)
1501{
1502 size_t bufferSize = 2;
1503
1504 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
1505 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1506 bufferSize += 2; /* u16 primitive->interfaceTag */
1507 bufferSize += 2; /* CsrResult primitive->status */
1508 return bufferSize;
1509}
1510
1511
1512u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg)
1513{
1514 CsrWifiRouterCtrlTclasAddCfm *primitive = (CsrWifiRouterCtrlTclasAddCfm *)msg;
1515 *len = 0;
1516 CsrUint16Ser(ptr, len, primitive->common.type);
1517 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1518 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1519 CsrUint16Ser(ptr, len, (u16) primitive->status);
1520 return(ptr);
1521}
1522
1523
1524void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t length)
1525{
1526 CsrWifiRouterCtrlTclasAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL);
1527 size_t offset;
1528 offset = 0;
1529
1530 CsrUint16Des(&primitive->common.type, buffer, &offset);
1531 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1532 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1533 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1534
1535 return primitive;
1536}
1537
1538
1539size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg)
1540{
1541 size_t bufferSize = 2;
1542
1543 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
1544 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1545 bufferSize += 2; /* CsrResult primitive->result */
1546 return bufferSize;
1547}
1548
1549
1550u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg)
1551{
1552 CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioDeinitialiseCfm *)msg;
1553 *len = 0;
1554 CsrUint16Ser(ptr, len, primitive->common.type);
1555 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1556 CsrUint16Ser(ptr, len, (u16) primitive->result);
1557 return(ptr);
1558}
1559
1560
1561void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t length)
1562{
1563 CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL);
1564 size_t offset;
1565 offset = 0;
1566
1567 CsrUint16Des(&primitive->common.type, buffer, &offset);
1568 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1569 CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
1570
1571 return primitive;
1572}
1573
1574
1575size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg)
1576{
1577 size_t bufferSize = 2;
1578
1579 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */
1580 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1581 bufferSize += 2; /* CsrResult primitive->result */
1582 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteRead primitive->byteRead */
1583 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteWrite primitive->byteWrite */
1584 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioFirmwareDownload primitive->firmwareDownload */
1585 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioReset primitive->reset */
1586 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioCoreDumpPrepare primitive->coreDumpPrepare */
1587 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteBlockRead primitive->byteBlockRead */
1588 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpRead16 primitive->gpRead16 */
1589 bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpWrite16 primitive->gpWrite16 */
1590 return bufferSize;
1591}
1592
1593
1594u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg)
1595{
1596 CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioInitialiseCfm *)msg;
1597 *len = 0;
1598 CsrUint16Ser(ptr, len, primitive->common.type);
1599 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1600 CsrUint16Ser(ptr, len, (u16) primitive->result);
1601 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteRead */
1602 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteWrite */
1603 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->firmwareDownload */
1604 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->reset */
1605 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->coreDumpPrepare */
1606 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteBlockRead */
1607 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpRead16 */
1608 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpWrite16 */
1609 return(ptr);
1610}
1611
1612
1613void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t length)
1614{
1615 CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL);
1616 size_t offset;
1617 offset = 0;
1618
1619 CsrUint16Des(&primitive->common.type, buffer, &offset);
1620 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1621 CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
1622 primitive->byteRead = NULL; /* Special for Function Pointers... */
1623 offset += 4;
1624 primitive->byteWrite = NULL; /* Special for Function Pointers... */
1625 offset += 4;
1626 primitive->firmwareDownload = NULL; /* Special for Function Pointers... */
1627 offset += 4;
1628 primitive->reset = NULL; /* Special for Function Pointers... */
1629 offset += 4;
1630 primitive->coreDumpPrepare = NULL; /* Special for Function Pointers... */
1631 offset += 4;
1632 primitive->byteBlockRead = NULL; /* Special for Function Pointers... */
1633 offset += 4;
1634 primitive->gpRead16 = NULL; /* Special for Function Pointers... */
1635 offset += 4;
1636 primitive->gpWrite16 = NULL; /* Special for Function Pointers... */
1637 offset += 4;
1638
1639 return primitive;
1640}
1641
1642
1643size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg)
1644{
1645 size_t bufferSize = 2;
1646
1647 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
1648 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1649 bufferSize += 2; /* u16 primitive->interfaceTag */
1650 bufferSize += 2; /* CsrResult primitive->status */
1651 return bufferSize;
1652}
1653
1654
1655u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg)
1656{
1657 CsrWifiRouterCtrlTclasDelCfm *primitive = (CsrWifiRouterCtrlTclasDelCfm *)msg;
1658 *len = 0;
1659 CsrUint16Ser(ptr, len, primitive->common.type);
1660 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1661 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1662 CsrUint16Ser(ptr, len, (u16) primitive->status);
1663 return(ptr);
1664}
1665
1666
1667void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t length)
1668{
1669 CsrWifiRouterCtrlTclasDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL);
1670 size_t offset;
1671 offset = 0;
1672
1673 CsrUint16Des(&primitive->common.type, buffer, &offset);
1674 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1675 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1676 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1677
1678 return primitive;
1679}
1680
1681
1682size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg)
1683{
1684 size_t bufferSize = 2;
1685
1686 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
1687 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1688 bufferSize += 2; /* u16 primitive->interfaceTag */
1689 bufferSize += 2; /* CsrWifiRouterCtrlTrafficPacketType primitive->packetType */
1690 bufferSize += 2; /* CsrWifiRouterCtrlProtocolDirection primitive->direction */
1691 bufferSize += 6; /* u8 primitive->srcAddress.a[6] */
1692 return bufferSize;
1693}
1694
1695
1696u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg)
1697{
1698 CsrWifiRouterCtrlTrafficProtocolInd *primitive = (CsrWifiRouterCtrlTrafficProtocolInd *)msg;
1699 *len = 0;
1700 CsrUint16Ser(ptr, len, primitive->common.type);
1701 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1702 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1703 CsrUint16Ser(ptr, len, (u16) primitive->packetType);
1704 CsrUint16Ser(ptr, len, (u16) primitive->direction);
1705 CsrMemCpySer(ptr, len, (const void *) primitive->srcAddress.a, ((u16) (6)));
1706 return(ptr);
1707}
1708
1709
1710void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t length)
1711{
1712 CsrWifiRouterCtrlTrafficProtocolInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL);
1713 size_t offset;
1714 offset = 0;
1715
1716 CsrUint16Des(&primitive->common.type, buffer, &offset);
1717 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1718 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1719 CsrUint16Des((u16 *) &primitive->packetType, buffer, &offset);
1720 CsrUint16Des((u16 *) &primitive->direction, buffer, &offset);
1721 CsrMemCpyDes(primitive->srcAddress.a, buffer, &offset, ((u16) (6)));
1722
1723 return primitive;
1724}
1725
1726
1727size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg)
1728{
1729 size_t bufferSize = 2;
1730
1731 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 38) */
1732 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1733 bufferSize += 2; /* u16 primitive->interfaceTag */
1734 bufferSize += 4; /* u32 primitive->stats.rxMeanRate */
1735 bufferSize += 4; /* u32 primitive->stats.rxFramesNum */
1736 bufferSize += 4; /* u32 primitive->stats.txFramesNum */
1737 bufferSize += 4; /* u32 primitive->stats.rxBytesCount */
1738 bufferSize += 4; /* u32 primitive->stats.txBytesCount */
1739 bufferSize += 11; /* u8 primitive->stats.intervals[11] */
1740 return bufferSize;
1741}
1742
1743
1744u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg)
1745{
1746 CsrWifiRouterCtrlTrafficSampleInd *primitive = (CsrWifiRouterCtrlTrafficSampleInd *)msg;
1747 *len = 0;
1748 CsrUint16Ser(ptr, len, primitive->common.type);
1749 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1750 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1751 CsrUint32Ser(ptr, len, (u32) primitive->stats.rxMeanRate);
1752 CsrUint32Ser(ptr, len, (u32) primitive->stats.rxFramesNum);
1753 CsrUint32Ser(ptr, len, (u32) primitive->stats.txFramesNum);
1754 CsrUint32Ser(ptr, len, (u32) primitive->stats.rxBytesCount);
1755 CsrUint32Ser(ptr, len, (u32) primitive->stats.txBytesCount);
1756 CsrMemCpySer(ptr, len, (const void *) primitive->stats.intervals, ((u16) (11)));
1757 return(ptr);
1758}
1759
1760
1761void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t length)
1762{
1763 CsrWifiRouterCtrlTrafficSampleInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL);
1764 size_t offset;
1765 offset = 0;
1766
1767 CsrUint16Des(&primitive->common.type, buffer, &offset);
1768 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1769 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1770 CsrUint32Des((u32 *) &primitive->stats.rxMeanRate, buffer, &offset);
1771 CsrUint32Des((u32 *) &primitive->stats.rxFramesNum, buffer, &offset);
1772 CsrUint32Des((u32 *) &primitive->stats.txFramesNum, buffer, &offset);
1773 CsrUint32Des((u32 *) &primitive->stats.rxBytesCount, buffer, &offset);
1774 CsrUint32Des((u32 *) &primitive->stats.txBytesCount, buffer, &offset);
1775 CsrMemCpyDes(primitive->stats.intervals, buffer, &offset, ((u16) (11)));
1776
1777 return primitive;
1778}
1779
1780
1781size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg)
1782{
1783 CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) msg;
1784 size_t bufferSize = 2;
1785
1786 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 27) */
1787 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1788 bufferSize += 2; /* CsrResult primitive->status */
1789 bufferSize += 4; /* u32 primitive->versions.chipId */
1790 bufferSize += 4; /* u32 primitive->versions.chipVersion */
1791 bufferSize += 4; /* u32 primitive->versions.firmwareBuild */
1792 bufferSize += 4; /* u32 primitive->versions.firmwareHip */
1793 bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1; /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */
1794 bufferSize += 4; /* u32 primitive->versions.routerHip */
1795 return bufferSize;
1796}
1797
1798
1799u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg)
1800{
1801 CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *)msg;
1802 *len = 0;
1803 CsrUint16Ser(ptr, len, primitive->common.type);
1804 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1805 CsrUint16Ser(ptr, len, (u16) primitive->status);
1806 CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId);
1807 CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion);
1808 CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild);
1809 CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip);
1810 CsrCharStringSer(ptr, len, primitive->versions.routerBuild);
1811 CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip);
1812 return(ptr);
1813}
1814
1815
1816void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t length)
1817{
1818 CsrWifiRouterCtrlWifiOnInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL);
1819 size_t offset;
1820 offset = 0;
1821
1822 CsrUint16Des(&primitive->common.type, buffer, &offset);
1823 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1824 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1825 CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset);
1826 CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset);
1827 CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset);
1828 CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset);
1829 CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset);
1830 CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset);
1831
1832 return primitive;
1833}
1834
1835
1836void CsrWifiRouterCtrlWifiOnIndSerFree(void *voidPrimitivePointer)
1837{
1838 CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) voidPrimitivePointer;
1839 kfree(primitive->versions.routerBuild);
1840 kfree(primitive);
1841}
1842
1843
1844size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg)
1845{
1846 size_t bufferSize = 2;
1847
1848 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
1849 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1850 bufferSize += 2; /* CsrResult primitive->status */
1851 return bufferSize;
1852}
1853
1854
1855u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg)
1856{
1857 CsrWifiRouterCtrlWifiOnCfm *primitive = (CsrWifiRouterCtrlWifiOnCfm *)msg;
1858 *len = 0;
1859 CsrUint16Ser(ptr, len, primitive->common.type);
1860 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1861 CsrUint16Ser(ptr, len, (u16) primitive->status);
1862 return(ptr);
1863}
1864
1865
1866void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t length)
1867{
1868 CsrWifiRouterCtrlWifiOnCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL);
1869 size_t offset;
1870 offset = 0;
1871
1872 CsrUint16Des(&primitive->common.type, buffer, &offset);
1873 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1874 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1875
1876 return primitive;
1877}
1878
1879
1880size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg)
1881{
1882 size_t bufferSize = 2;
1883
1884 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
1885 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1886 bufferSize += 2; /* u16 primitive->interfaceTag */
1887 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
1888 return bufferSize;
1889}
1890
1891
1892u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg)
1893{
1894 CsrWifiRouterCtrlM4ReadyToSendInd *primitive = (CsrWifiRouterCtrlM4ReadyToSendInd *)msg;
1895 *len = 0;
1896 CsrUint16Ser(ptr, len, primitive->common.type);
1897 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1898 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1899 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
1900 return(ptr);
1901}
1902
1903
1904void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t length)
1905{
1906 CsrWifiRouterCtrlM4ReadyToSendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL);
1907 size_t offset;
1908 offset = 0;
1909
1910 CsrUint16Des(&primitive->common.type, buffer, &offset);
1911 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1912 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1913 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
1914
1915 return primitive;
1916}
1917
1918
1919size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg)
1920{
1921 size_t bufferSize = 2;
1922
1923 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
1924 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1925 bufferSize += 2; /* u16 primitive->interfaceTag */
1926 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
1927 bufferSize += 2; /* CsrResult primitive->status */
1928 return bufferSize;
1929}
1930
1931
1932u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg)
1933{
1934 CsrWifiRouterCtrlM4TransmittedInd *primitive = (CsrWifiRouterCtrlM4TransmittedInd *)msg;
1935 *len = 0;
1936 CsrUint16Ser(ptr, len, primitive->common.type);
1937 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1938 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1939 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
1940 CsrUint16Ser(ptr, len, (u16) primitive->status);
1941 return(ptr);
1942}
1943
1944
1945void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t length)
1946{
1947 CsrWifiRouterCtrlM4TransmittedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL);
1948 size_t offset;
1949 offset = 0;
1950
1951 CsrUint16Des(&primitive->common.type, buffer, &offset);
1952 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1953 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1954 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
1955 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1956
1957 return primitive;
1958}
1959
1960
1961size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg)
1962{
1963 size_t bufferSize = 2;
1964
1965 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
1966 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
1967 bufferSize += 2; /* u16 primitive->interfaceTag */
1968 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
1969 bufferSize += 1; /* u8 primitive->unicastPdu */
1970 return bufferSize;
1971}
1972
1973
1974u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg)
1975{
1976 CsrWifiRouterCtrlMicFailureInd *primitive = (CsrWifiRouterCtrlMicFailureInd *)msg;
1977 *len = 0;
1978 CsrUint16Ser(ptr, len, primitive->common.type);
1979 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
1980 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1981 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
1982 CsrUint8Ser(ptr, len, (u8) primitive->unicastPdu);
1983 return(ptr);
1984}
1985
1986
1987void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t length)
1988{
1989 CsrWifiRouterCtrlMicFailureInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL);
1990 size_t offset;
1991 offset = 0;
1992
1993 CsrUint16Des(&primitive->common.type, buffer, &offset);
1994 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
1995 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1996 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
1997 CsrUint8Des((u8 *) &primitive->unicastPdu, buffer, &offset);
1998
1999 return primitive;
2000}
2001
2002
2003size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg)
2004{
2005 size_t bufferSize = 2;
2006
2007 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
2008 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2009 bufferSize += 2; /* u16 primitive->interfaceTag */
2010 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
2011 bufferSize += 1; /* CsrWifiRouterCtrlPeerStatus primitive->peerStatus */
2012 return bufferSize;
2013}
2014
2015
2016u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg)
2017{
2018 CsrWifiRouterCtrlConnectedInd *primitive = (CsrWifiRouterCtrlConnectedInd *)msg;
2019 *len = 0;
2020 CsrUint16Ser(ptr, len, primitive->common.type);
2021 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2022 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2023 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
2024 CsrUint8Ser(ptr, len, (u8) primitive->peerStatus);
2025 return(ptr);
2026}
2027
2028
2029void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t length)
2030{
2031 CsrWifiRouterCtrlConnectedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL);
2032 size_t offset;
2033 offset = 0;
2034
2035 CsrUint16Des(&primitive->common.type, buffer, &offset);
2036 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2037 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2038 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
2039 CsrUint8Des((u8 *) &primitive->peerStatus, buffer, &offset);
2040
2041 return primitive;
2042}
2043
2044
2045size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg)
2046{
2047 size_t bufferSize = 2;
2048
2049 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 19) */
2050 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2051 bufferSize += 2; /* u16 primitive->interfaceTag */
2052 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
2053 bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
2054 bufferSize += 2; /* CsrResult primitive->status */
2055 return bufferSize;
2056}
2057
2058
2059u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg)
2060{
2061 CsrWifiRouterCtrlPeerAddCfm *primitive = (CsrWifiRouterCtrlPeerAddCfm *)msg;
2062 *len = 0;
2063 CsrUint16Ser(ptr, len, primitive->common.type);
2064 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2065 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2066 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
2067 CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
2068 CsrUint16Ser(ptr, len, (u16) primitive->status);
2069 return(ptr);
2070}
2071
2072
2073void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t length)
2074{
2075 CsrWifiRouterCtrlPeerAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL);
2076 size_t offset;
2077 offset = 0;
2078
2079 CsrUint16Des(&primitive->common.type, buffer, &offset);
2080 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2081 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2082 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
2083 CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
2084 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2085
2086 return primitive;
2087}
2088
2089
2090size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg)
2091{
2092 size_t bufferSize = 2;
2093
2094 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
2095 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2096 bufferSize += 2; /* u16 primitive->interfaceTag */
2097 bufferSize += 2; /* CsrResult primitive->status */
2098 return bufferSize;
2099}
2100
2101
2102u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg)
2103{
2104 CsrWifiRouterCtrlPeerDelCfm *primitive = (CsrWifiRouterCtrlPeerDelCfm *)msg;
2105 *len = 0;
2106 CsrUint16Ser(ptr, len, primitive->common.type);
2107 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2108 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2109 CsrUint16Ser(ptr, len, (u16) primitive->status);
2110 return(ptr);
2111}
2112
2113
2114void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t length)
2115{
2116 CsrWifiRouterCtrlPeerDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL);
2117 size_t offset;
2118 offset = 0;
2119
2120 CsrUint16Des(&primitive->common.type, buffer, &offset);
2121 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2122 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2123 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2124
2125 return primitive;
2126}
2127
2128
2129size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg)
2130{
2131 size_t bufferSize = 2;
2132
2133 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
2134 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2135 bufferSize += 2; /* u16 primitive->interfaceTag */
2136 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
2137 return bufferSize;
2138}
2139
2140
2141u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg)
2142{
2143 CsrWifiRouterCtrlUnexpectedFrameInd *primitive = (CsrWifiRouterCtrlUnexpectedFrameInd *)msg;
2144 *len = 0;
2145 CsrUint16Ser(ptr, len, primitive->common.type);
2146 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2147 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2148 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
2149 return(ptr);
2150}
2151
2152
2153void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t length)
2154{
2155 CsrWifiRouterCtrlUnexpectedFrameInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL);
2156 size_t offset;
2157 offset = 0;
2158
2159 CsrUint16Des(&primitive->common.type, buffer, &offset);
2160 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2161 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2162 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
2163
2164 return primitive;
2165}
2166
2167
2168size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg)
2169{
2170 size_t bufferSize = 2;
2171
2172 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
2173 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2174 bufferSize += 2; /* u16 primitive->interfaceTag */
2175 bufferSize += 2; /* CsrResult primitive->status */
2176 return bufferSize;
2177}
2178
2179
2180u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg)
2181{
2182 CsrWifiRouterCtrlPeerUpdateCfm *primitive = (CsrWifiRouterCtrlPeerUpdateCfm *)msg;
2183 *len = 0;
2184 CsrUint16Ser(ptr, len, primitive->common.type);
2185 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2186 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2187 CsrUint16Ser(ptr, len, (u16) primitive->status);
2188 return(ptr);
2189}
2190
2191
2192void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t length)
2193{
2194 CsrWifiRouterCtrlPeerUpdateCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL);
2195 size_t offset;
2196 offset = 0;
2197
2198 CsrUint16Des(&primitive->common.type, buffer, &offset);
2199 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2200 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2201 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2202
2203 return primitive;
2204}
2205
2206
2207size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg)
2208{
2209 size_t bufferSize = 2;
2210
2211 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
2212 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2213 bufferSize += 2; /* u16 primitive->commandQueueSize */
2214 bufferSize += 2; /* u16 primitive->trafficQueueSize */
2215 return bufferSize;
2216}
2217
2218
2219u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg)
2220{
2221 CsrWifiRouterCtrlCapabilitiesCfm *primitive = (CsrWifiRouterCtrlCapabilitiesCfm *)msg;
2222 *len = 0;
2223 CsrUint16Ser(ptr, len, primitive->common.type);
2224 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2225 CsrUint16Ser(ptr, len, (u16) primitive->commandQueueSize);
2226 CsrUint16Ser(ptr, len, (u16) primitive->trafficQueueSize);
2227 return(ptr);
2228}
2229
2230
2231void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t length)
2232{
2233 CsrWifiRouterCtrlCapabilitiesCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL);
2234 size_t offset;
2235 offset = 0;
2236
2237 CsrUint16Des(&primitive->common.type, buffer, &offset);
2238 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2239 CsrUint16Des((u16 *) &primitive->commandQueueSize, buffer, &offset);
2240 CsrUint16Des((u16 *) &primitive->trafficQueueSize, buffer, &offset);
2241
2242 return primitive;
2243}
2244
2245
2246size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg)
2247{
2248 size_t bufferSize = 2;
2249
2250 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
2251 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2252 bufferSize += 2; /* u16 primitive->interfaceTag */
2253 bufferSize += 2; /* CsrResult primitive->status */
2254 return bufferSize;
2255}
2256
2257
2258u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg)
2259{
2260 CsrWifiRouterCtrlBlockAckEnableCfm *primitive = (CsrWifiRouterCtrlBlockAckEnableCfm *)msg;
2261 *len = 0;
2262 CsrUint16Ser(ptr, len, primitive->common.type);
2263 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2264 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2265 CsrUint16Ser(ptr, len, (u16) primitive->status);
2266 return(ptr);
2267}
2268
2269
2270void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t length)
2271{
2272 CsrWifiRouterCtrlBlockAckEnableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL);
2273 size_t offset;
2274 offset = 0;
2275
2276 CsrUint16Des(&primitive->common.type, buffer, &offset);
2277 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2278 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2279 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2280
2281 return primitive;
2282}
2283
2284
2285size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg)
2286{
2287 size_t bufferSize = 2;
2288
2289 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
2290 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2291 bufferSize += 2; /* u16 primitive->interfaceTag */
2292 bufferSize += 2; /* CsrResult primitive->status */
2293 return bufferSize;
2294}
2295
2296
2297u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg)
2298{
2299 CsrWifiRouterCtrlBlockAckDisableCfm *primitive = (CsrWifiRouterCtrlBlockAckDisableCfm *)msg;
2300 *len = 0;
2301 CsrUint16Ser(ptr, len, primitive->common.type);
2302 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2303 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2304 CsrUint16Ser(ptr, len, (u16) primitive->status);
2305 return(ptr);
2306}
2307
2308
2309void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t length)
2310{
2311 CsrWifiRouterCtrlBlockAckDisableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL);
2312 size_t offset;
2313 offset = 0;
2314
2315 CsrUint16Des(&primitive->common.type, buffer, &offset);
2316 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2317 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2318 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2319
2320 return primitive;
2321}
2322
2323
2324size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg)
2325{
2326 size_t bufferSize = 2;
2327
2328 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */
2329 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2330 bufferSize += 2; /* u16 primitive->interfaceTag */
2331 bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
2332 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
2333 bufferSize += 2; /* CsrResult primitive->status */
2334 return bufferSize;
2335}
2336
2337
2338u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg)
2339{
2340 CsrWifiRouterCtrlBlockAckErrorInd *primitive = (CsrWifiRouterCtrlBlockAckErrorInd *)msg;
2341 *len = 0;
2342 CsrUint16Ser(ptr, len, primitive->common.type);
2343 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2344 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2345 CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
2346 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
2347 CsrUint16Ser(ptr, len, (u16) primitive->status);
2348 return(ptr);
2349}
2350
2351
2352void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t length)
2353{
2354 CsrWifiRouterCtrlBlockAckErrorInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL);
2355 size_t offset;
2356 offset = 0;
2357
2358 CsrUint16Des(&primitive->common.type, buffer, &offset);
2359 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2360 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2361 CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
2362 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
2363 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2364
2365 return primitive;
2366}
2367
2368
2369size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg)
2370{
2371 size_t bufferSize = 2;
2372
2373 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
2374 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2375 bufferSize += 2; /* u16 primitive->interfaceTag */
2376 bufferSize += 6; /* u8 primitive->staAddress.a[6] */
2377 return bufferSize;
2378}
2379
2380
2381u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg)
2382{
2383 CsrWifiRouterCtrlStaInactiveInd *primitive = (CsrWifiRouterCtrlStaInactiveInd *)msg;
2384 *len = 0;
2385 CsrUint16Ser(ptr, len, primitive->common.type);
2386 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2387 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2388 CsrMemCpySer(ptr, len, (const void *) primitive->staAddress.a, ((u16) (6)));
2389 return(ptr);
2390}
2391
2392
2393void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t length)
2394{
2395 CsrWifiRouterCtrlStaInactiveInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL);
2396 size_t offset;
2397 offset = 0;
2398
2399 CsrUint16Des(&primitive->common.type, buffer, &offset);
2400 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2401 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2402 CsrMemCpyDes(primitive->staAddress.a, buffer, &offset, ((u16) (6)));
2403
2404 return primitive;
2405}
2406
2407
2408size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg)
2409{
2410 CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) msg;
2411 size_t bufferSize = 2;
2412
2413 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
2414 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2415 bufferSize += 2; /* u16 primitive->interfaceTag */
2416 bufferSize += 2; /* u16 primitive->signalLength */
2417 bufferSize += primitive->signalLength; /* u8 primitive->signal */
2418 bufferSize += 2; /* u16 primitive->dataLength */
2419 bufferSize += primitive->dataLength; /* u8 primitive->data */
2420 return bufferSize;
2421}
2422
2423
2424u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg)
2425{
2426 CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *)msg;
2427 *len = 0;
2428 CsrUint16Ser(ptr, len, primitive->common.type);
2429 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2430 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2431 CsrUint16Ser(ptr, len, (u16) primitive->signalLength);
2432 if (primitive->signalLength)
2433 {
2434 CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength)));
2435 }
2436 CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
2437 if (primitive->dataLength)
2438 {
2439 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
2440 }
2441 return(ptr);
2442}
2443
2444
2445void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t length)
2446{
2447 CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL);
2448 size_t offset;
2449 offset = 0;
2450
2451 CsrUint16Des(&primitive->common.type, buffer, &offset);
2452 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2453 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2454 CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset);
2455 if (primitive->signalLength)
2456 {
2457 primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL);
2458 CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength)));
2459 }
2460 else
2461 {
2462 primitive->signal = NULL;
2463 }
2464 CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
2465 if (primitive->dataLength)
2466 {
2467 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
2468 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
2469 }
2470 else
2471 {
2472 primitive->data = NULL;
2473 }
2474
2475 return primitive;
2476}
2477
2478
2479void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *voidPrimitivePointer)
2480{
2481 CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) voidPrimitivePointer;
2482 kfree(primitive->signal);
2483 kfree(primitive->data);
2484 kfree(primitive);
2485}
2486
2487
2488size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg)
2489{
2490 size_t bufferSize = 2;
2491
2492 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
2493 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2494 bufferSize += 2; /* u16 primitive->interfaceTag */
2495 bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */
2496 bufferSize += 2; /* CsrResult primitive->status */
2497 return bufferSize;
2498}
2499
2500
2501u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg)
2502{
2503 CsrWifiRouterCtrlModeSetCfm *primitive = (CsrWifiRouterCtrlModeSetCfm *)msg;
2504 *len = 0;
2505 CsrUint16Ser(ptr, len, primitive->common.type);
2506 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2507 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2508 CsrUint8Ser(ptr, len, (u8) primitive->mode);
2509 CsrUint16Ser(ptr, len, (u16) primitive->status);
2510 return(ptr);
2511}
2512
2513
2514void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t length)
2515{
2516 CsrWifiRouterCtrlModeSetCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL);
2517 size_t offset;
2518 offset = 0;
2519
2520 CsrUint16Des(&primitive->common.type, buffer, &offset);
2521 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2522 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2523 CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
2524 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2525
2526 return primitive;
2527}
2528
2529
2530size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg)
2531{
2532 CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) msg;
2533 size_t bufferSize = 2;
2534
2535 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
2536 bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
2537 bufferSize += 2; /* u16 primitive->interfaceTag */
2538 bufferSize += 2; /* u16 primitive->dataLength */
2539 bufferSize += primitive->dataLength; /* u8 primitive->data */
2540 return bufferSize;
2541}
2542
2543
2544u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg)
2545{
2546 CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)msg;
2547 *len = 0;
2548 CsrUint16Ser(ptr, len, primitive->common.type);
2549 CsrUint16Ser(ptr, len, (u16) primitive->clientData);
2550 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2551 CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
2552 if (primitive->dataLength)
2553 {
2554 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
2555 }
2556 return(ptr);
2557}
2558
2559
2560void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t length)
2561{
2562 CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL);
2563 size_t offset;
2564 offset = 0;
2565
2566 CsrUint16Des(&primitive->common.type, buffer, &offset);
2567 CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
2568 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2569 CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
2570 if (primitive->dataLength)
2571 {
2572 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
2573 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
2574 }
2575 else
2576 {
2577 primitive->data = NULL;
2578 }
2579
2580 return primitive;
2581}
2582
2583
2584void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *voidPrimitivePointer)
2585{
2586 CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) voidPrimitivePointer;
2587 kfree(primitive->data);
2588 kfree(primitive);
2589}
2590
2591
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
index c9048386cfcb..000000000000
--- a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h
+++ /dev/null
@@ -1,333 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__
14#define CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__
15
16#include "csr_wifi_msgconv.h"
17
18#include "csr_wifi_router_ctrl_prim.h"
19
20extern void CsrWifiRouterCtrlPfree(void *ptr);
21
22extern u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg);
23extern void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t len);
24extern size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg);
25#define CsrWifiRouterCtrlConfigurePowerModeReqSerFree CsrWifiRouterCtrlPfree
26
27extern u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg);
28extern void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t len);
29extern size_t CsrWifiRouterCtrlHipReqSizeof(void *msg);
30extern void CsrWifiRouterCtrlHipReqSerFree(void *msg);
31
32extern u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg);
33extern void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t len);
34extern size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg);
35#define CsrWifiRouterCtrlMediaStatusReqSerFree CsrWifiRouterCtrlPfree
36
37extern u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg);
38extern void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t len);
39extern size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg);
40extern void CsrWifiRouterCtrlMulticastAddressResSerFree(void *msg);
41
42extern u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg);
43extern void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t len);
44extern size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg);
45#define CsrWifiRouterCtrlPortConfigureReqSerFree CsrWifiRouterCtrlPfree
46
47extern u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg);
48extern void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t len);
49extern size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg);
50#define CsrWifiRouterCtrlQosControlReqSerFree CsrWifiRouterCtrlPfree
51
52extern u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg);
53extern void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t len);
54extern size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg);
55#define CsrWifiRouterCtrlSuspendResSerFree CsrWifiRouterCtrlPfree
56
57extern u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg);
58extern void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t len);
59extern size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg);
60extern void CsrWifiRouterCtrlTclasAddReqSerFree(void *msg);
61
62extern u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg);
63extern void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t len);
64extern size_t CsrWifiRouterCtrlResumeResSizeof(void *msg);
65#define CsrWifiRouterCtrlResumeResSerFree CsrWifiRouterCtrlPfree
66
67#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSer CsrWifiEventCsrUint16Ser
68#define CsrWifiRouterCtrlRawSdioDeinitialiseReqDes CsrWifiEventCsrUint16Des
69#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof CsrWifiEventCsrUint16Sizeof
70#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree CsrWifiRouterCtrlPfree
71
72#define CsrWifiRouterCtrlRawSdioInitialiseReqSer CsrWifiEventCsrUint16Ser
73#define CsrWifiRouterCtrlRawSdioInitialiseReqDes CsrWifiEventCsrUint16Des
74#define CsrWifiRouterCtrlRawSdioInitialiseReqSizeof CsrWifiEventCsrUint16Sizeof
75#define CsrWifiRouterCtrlRawSdioInitialiseReqSerFree CsrWifiRouterCtrlPfree
76
77extern u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg);
78extern void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t len);
79extern size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg);
80extern void CsrWifiRouterCtrlTclasDelReqSerFree(void *msg);
81
82extern u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg);
83extern void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t len);
84extern size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg);
85#define CsrWifiRouterCtrlTrafficClassificationReqSerFree CsrWifiRouterCtrlPfree
86
87extern u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg);
88extern void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t len);
89extern size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg);
90#define CsrWifiRouterCtrlTrafficConfigReqSerFree CsrWifiRouterCtrlPfree
91
92#define CsrWifiRouterCtrlWifiOffReqSer CsrWifiEventCsrUint16Ser
93#define CsrWifiRouterCtrlWifiOffReqDes CsrWifiEventCsrUint16Des
94#define CsrWifiRouterCtrlWifiOffReqSizeof CsrWifiEventCsrUint16Sizeof
95#define CsrWifiRouterCtrlWifiOffReqSerFree CsrWifiRouterCtrlPfree
96
97#define CsrWifiRouterCtrlWifiOffResSer CsrWifiEventCsrUint16Ser
98#define CsrWifiRouterCtrlWifiOffResDes CsrWifiEventCsrUint16Des
99#define CsrWifiRouterCtrlWifiOffResSizeof CsrWifiEventCsrUint16Sizeof
100#define CsrWifiRouterCtrlWifiOffResSerFree CsrWifiRouterCtrlPfree
101
102extern u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg);
103extern void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t len);
104extern size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg);
105extern void CsrWifiRouterCtrlWifiOnReqSerFree(void *msg);
106
107extern u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg);
108extern void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t len);
109extern size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg);
110extern void CsrWifiRouterCtrlWifiOnResSerFree(void *msg);
111
112extern u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg);
113extern void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t len);
114extern size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg);
115#define CsrWifiRouterCtrlM4TransmitReqSerFree CsrWifiRouterCtrlPfree
116
117extern u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg);
118extern void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t len);
119extern size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg);
120#define CsrWifiRouterCtrlModeSetReqSerFree CsrWifiRouterCtrlPfree
121
122extern u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg);
123extern void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t len);
124extern size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg);
125#define CsrWifiRouterCtrlPeerAddReqSerFree CsrWifiRouterCtrlPfree
126
127extern u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg);
128extern void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t len);
129extern size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg);
130#define CsrWifiRouterCtrlPeerDelReqSerFree CsrWifiRouterCtrlPfree
131
132extern u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg);
133extern void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t len);
134extern size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg);
135#define CsrWifiRouterCtrlPeerUpdateReqSerFree CsrWifiRouterCtrlPfree
136
137#define CsrWifiRouterCtrlCapabilitiesReqSer CsrWifiEventCsrUint16Ser
138#define CsrWifiRouterCtrlCapabilitiesReqDes CsrWifiEventCsrUint16Des
139#define CsrWifiRouterCtrlCapabilitiesReqSizeof CsrWifiEventCsrUint16Sizeof
140#define CsrWifiRouterCtrlCapabilitiesReqSerFree CsrWifiRouterCtrlPfree
141
142extern u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg);
143extern void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t len);
144extern size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg);
145#define CsrWifiRouterCtrlBlockAckEnableReqSerFree CsrWifiRouterCtrlPfree
146
147extern u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg);
148extern void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t len);
149extern size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg);
150#define CsrWifiRouterCtrlBlockAckDisableReqSerFree CsrWifiRouterCtrlPfree
151
152extern u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg);
153extern void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t len);
154extern size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg);
155extern void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *msg);
156
157#define CsrWifiRouterCtrlWapiMulticastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
158#define CsrWifiRouterCtrlWapiMulticastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
159#define CsrWifiRouterCtrlWapiMulticastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
160#define CsrWifiRouterCtrlWapiMulticastFilterReqSerFree CsrWifiRouterCtrlPfree
161
162#define CsrWifiRouterCtrlWapiUnicastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
163#define CsrWifiRouterCtrlWapiUnicastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
164#define CsrWifiRouterCtrlWapiUnicastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
165#define CsrWifiRouterCtrlWapiUnicastFilterReqSerFree CsrWifiRouterCtrlPfree
166
167extern u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg);
168extern void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t len);
169extern size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg);
170extern void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *msg);
171
172#define CsrWifiRouterCtrlWapiFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
173#define CsrWifiRouterCtrlWapiFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
174#define CsrWifiRouterCtrlWapiFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
175#define CsrWifiRouterCtrlWapiFilterReqSerFree CsrWifiRouterCtrlPfree
176
177extern u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg);
178extern void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t len);
179extern size_t CsrWifiRouterCtrlHipIndSizeof(void *msg);
180extern void CsrWifiRouterCtrlHipIndSerFree(void *msg);
181
182extern u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg);
183extern void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t len);
184extern size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg);
185extern void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *msg);
186
187extern u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg);
188extern void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t len);
189extern size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg);
190#define CsrWifiRouterCtrlPortConfigureCfmSerFree CsrWifiRouterCtrlPfree
191
192#define CsrWifiRouterCtrlResumeIndSer CsrWifiEventCsrUint16CsrUint8Ser
193#define CsrWifiRouterCtrlResumeIndDes CsrWifiEventCsrUint16CsrUint8Des
194#define CsrWifiRouterCtrlResumeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
195#define CsrWifiRouterCtrlResumeIndSerFree CsrWifiRouterCtrlPfree
196
197extern u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg);
198extern void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t len);
199extern size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg);
200#define CsrWifiRouterCtrlSuspendIndSerFree CsrWifiRouterCtrlPfree
201
202extern u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg);
203extern void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t len);
204extern size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg);
205#define CsrWifiRouterCtrlTclasAddCfmSerFree CsrWifiRouterCtrlPfree
206
207extern u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg);
208extern void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t len);
209extern size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg);
210#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree CsrWifiRouterCtrlPfree
211
212extern u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg);
213extern void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t len);
214extern size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg);
215#define CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree CsrWifiRouterCtrlPfree
216
217extern u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg);
218extern void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t len);
219extern size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg);
220#define CsrWifiRouterCtrlTclasDelCfmSerFree CsrWifiRouterCtrlPfree
221
222extern u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg);
223extern void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t len);
224extern size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg);
225#define CsrWifiRouterCtrlTrafficProtocolIndSerFree CsrWifiRouterCtrlPfree
226
227extern u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg);
228extern void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t len);
229extern size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg);
230#define CsrWifiRouterCtrlTrafficSampleIndSerFree CsrWifiRouterCtrlPfree
231
232#define CsrWifiRouterCtrlWifiOffIndSer CsrWifiEventCsrUint16CsrUint8Ser
233#define CsrWifiRouterCtrlWifiOffIndDes CsrWifiEventCsrUint16CsrUint8Des
234#define CsrWifiRouterCtrlWifiOffIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
235#define CsrWifiRouterCtrlWifiOffIndSerFree CsrWifiRouterCtrlPfree
236
237#define CsrWifiRouterCtrlWifiOffCfmSer CsrWifiEventCsrUint16Ser
238#define CsrWifiRouterCtrlWifiOffCfmDes CsrWifiEventCsrUint16Des
239#define CsrWifiRouterCtrlWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof
240#define CsrWifiRouterCtrlWifiOffCfmSerFree CsrWifiRouterCtrlPfree
241
242extern u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg);
243extern void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t len);
244extern size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg);
245extern void CsrWifiRouterCtrlWifiOnIndSerFree(void *msg);
246
247extern u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg);
248extern void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t len);
249extern size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg);
250#define CsrWifiRouterCtrlWifiOnCfmSerFree CsrWifiRouterCtrlPfree
251
252extern u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg);
253extern void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t len);
254extern size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg);
255#define CsrWifiRouterCtrlM4ReadyToSendIndSerFree CsrWifiRouterCtrlPfree
256
257extern u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg);
258extern void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t len);
259extern size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg);
260#define CsrWifiRouterCtrlM4TransmittedIndSerFree CsrWifiRouterCtrlPfree
261
262extern u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg);
263extern void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t len);
264extern size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg);
265#define CsrWifiRouterCtrlMicFailureIndSerFree CsrWifiRouterCtrlPfree
266
267extern u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg);
268extern void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t len);
269extern size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg);
270#define CsrWifiRouterCtrlConnectedIndSerFree CsrWifiRouterCtrlPfree
271
272extern u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg);
273extern void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t len);
274extern size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg);
275#define CsrWifiRouterCtrlPeerAddCfmSerFree CsrWifiRouterCtrlPfree
276
277extern u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg);
278extern void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t len);
279extern size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg);
280#define CsrWifiRouterCtrlPeerDelCfmSerFree CsrWifiRouterCtrlPfree
281
282extern u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg);
283extern void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t len);
284extern size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg);
285#define CsrWifiRouterCtrlUnexpectedFrameIndSerFree CsrWifiRouterCtrlPfree
286
287extern u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg);
288extern void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t len);
289extern size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg);
290#define CsrWifiRouterCtrlPeerUpdateCfmSerFree CsrWifiRouterCtrlPfree
291
292extern u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg);
293extern void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t len);
294extern size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg);
295#define CsrWifiRouterCtrlCapabilitiesCfmSerFree CsrWifiRouterCtrlPfree
296
297extern u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg);
298extern void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t len);
299extern size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg);
300#define CsrWifiRouterCtrlBlockAckEnableCfmSerFree CsrWifiRouterCtrlPfree
301
302extern u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg);
303extern void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t len);
304extern size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg);
305#define CsrWifiRouterCtrlBlockAckDisableCfmSerFree CsrWifiRouterCtrlPfree
306
307extern u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg);
308extern void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t len);
309extern size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg);
310#define CsrWifiRouterCtrlBlockAckErrorIndSerFree CsrWifiRouterCtrlPfree
311
312extern u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg);
313extern void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t len);
314extern size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg);
315#define CsrWifiRouterCtrlStaInactiveIndSerFree CsrWifiRouterCtrlPfree
316
317extern u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg);
318extern void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t len);
319extern size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg);
320extern void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *msg);
321
322extern u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg);
323extern void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t len);
324extern size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg);
325#define CsrWifiRouterCtrlModeSetCfmSerFree CsrWifiRouterCtrlPfree
326
327extern u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg);
328extern void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t len);
329extern size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg);
330extern void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *msg);
331
332#endif /* CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__ */
333
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
index c4badc565a91..000000000000
--- a/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_router_prim.h"
14#include "csr_wifi_router_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiRouterFreeDownstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_ROUTER_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37
38 switch (*((CsrWifiRouterPrim *) message))
39 {
40 case CSR_WIFI_ROUTER_MA_PACKET_REQ:
41 {
42 CsrWifiRouterMaPacketReq *p = (CsrWifiRouterMaPacketReq *)message;
43 kfree(p->frame);
44 p->frame = NULL;
45 break;
46 }
47
48 default:
49 break;
50 }
51}
52
53
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
index 4cd126338e27..000000000000
--- a/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_router_prim.h"
14#include "csr_wifi_router_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiRouterFreeUpstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_ROUTER_PRIM)
30 return;
31 if (NULL == message)
32 return;
33 switch (*((CsrWifiRouterPrim *) message)) {
34 case CSR_WIFI_ROUTER_MA_PACKET_IND:
35 {
36 CsrWifiRouterMaPacketInd *p =
37 (CsrWifiRouterMaPacketInd *) message;
38 kfree(p->frame);
39 p->frame = NULL;
40 break;
41 }
42 default:
43 break;
44 }
45}
46
47
diff --git a/drivers/staging/csr/csr_wifi_router_lib.h b/drivers/staging/csr/csr_wifi_router_lib.h
deleted file mode 100644
index b0477c413aae..000000000000
--- a/drivers/staging/csr/csr_wifi_router_lib.h
+++ /dev/null
@@ -1,417 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_LIB_H__
14#define CSR_WIFI_ROUTER_LIB_H__
15
16#include "csr_sched.h"
17#include "csr_macro.h"
18#include "csr_msg_transport.h"
19
20#include "csr_wifi_lib.h"
21
22#include "csr_wifi_router_prim.h"
23#include "csr_wifi_router_task.h"
24
25/*----------------------------------------------------------------------------*
26 * CsrWifiRouterFreeUpstreamMessageContents
27 *
28 * DESCRIPTION
29 * Free the allocated memory in a CSR_WIFI_ROUTER upstream message. Does not
30 * free the message itself, and can only be used for upstream messages.
31 *
32 * PARAMETERS
33 * Deallocates the resources in a CSR_WIFI_ROUTER upstream message
34 *----------------------------------------------------------------------------*/
35void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message);
36
37/*----------------------------------------------------------------------------*
38 * CsrWifiRouterFreeDownstreamMessageContents
39 *
40 * DESCRIPTION
41 * Free the allocated memory in a CSR_WIFI_ROUTER downstream message. Does not
42 * free the message itself, and can only be used for downstream messages.
43 *
44 * PARAMETERS
45 * Deallocates the resources in a CSR_WIFI_ROUTER downstream message
46 *----------------------------------------------------------------------------*/
47void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message);
48
49/*----------------------------------------------------------------------------*
50 * Enum to string functions
51 *----------------------------------------------------------------------------*/
52const char* CsrWifiRouterAppTypeToString(CsrWifiRouterAppType value);
53const char* CsrWifiRouterEncapsulationToString(CsrWifiRouterEncapsulation value);
54const char* CsrWifiRouterOuiToString(CsrWifiRouterOui value);
55const char* CsrWifiRouterPriorityToString(CsrWifiRouterPriority value);
56
57
58/*----------------------------------------------------------------------------*
59 * CsrPrim Type toString function.
60 * Converts a message type to the String name of the Message
61 *----------------------------------------------------------------------------*/
62const char* CsrWifiRouterPrimTypeToString(CsrPrim msgType);
63
64/*----------------------------------------------------------------------------*
65 * Lookup arrays for PrimType name Strings
66 *----------------------------------------------------------------------------*/
67extern const char *CsrWifiRouterUpstreamPrimNames[CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT];
68extern const char *CsrWifiRouterDownstreamPrimNames[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
69
70/*******************************************************************************
71
72 NAME
73 CsrWifiRouterMaPacketCancelReqSend
74
75 DESCRIPTION
76 This primitive is used to request cancellation of a previously send
77 CsrWifiRouterMaPacketReq.
78 The frame may already have been transmitted so there is no guarantees
79 that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
80 of the frame in question.
81 If the cancellation fails, the Router will send, if required,
82 CsrWifiRouterMaPacketCfm.
83 If the cancellation succeeds, the Router will not send
84 CsrWifiRouterMaPacketCfm.
85
86 PARAMETERS
87 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
88 interfaceTag - Interface Identifier; unique identifier of an interface
89 hostTag - The hostTag for the frame, which should be cancelled.
90 priority - Priority of the frame, which should be cancelled
91 peerMacAddress - Destination MAC address of the frame, which should be
92 cancelled
93
94*******************************************************************************/
95#define CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
96 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL); \
97 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, dst__, src__); \
98 msg__->interfaceTag = (interfaceTag__); \
99 msg__->hostTag = (hostTag__); \
100 msg__->priority = (priority__); \
101 msg__->peerMacAddress = (peerMacAddress__);
102
103#define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
104 { \
105 CsrWifiRouterMaPacketCancelReq *msg__; \
106 CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \
107 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
108 }
109
110#define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
111 CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__)
112
113/*******************************************************************************
114
115 NAME
116 CsrWifiRouterMaPacketReqSend
117
118 DESCRIPTION
119 A task sends this primitive to transmit a frame.
120
121 PARAMETERS
122 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
123 interfaceTag - Interface Identifier; unique identifier of an interface
124 subscriptionHandle - The handle of the subscription
125 frameLength - Length of the frame to be sent in bytes
126 frame - Pointer to the frame to be sent
127 freeFunction - Pointer to function to be used to free the frame
128 priority - Priority of the frame, which should be sent
129 hostTag - An application shall set the bits b31..b28 using one of
130 the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
131 be used by the requestor without any restrictions, but
132 the hostTag shall be unique so the hostTag for
133 CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
134 in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
135 (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
136 (20 bits) ]. If the hostTag is not unique, the
137 behaviour of the system is unpredicatable with respect
138 to data/management frame transfer.
139 cfmRequested - Indicates if the requestor needs a confirm for packet
140 requests sent under this subscription. If set to TRUE,
141 the router will send a confirm, else it will not send
142 any confirm
143
144*******************************************************************************/
145#define CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
146 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL); \
147 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_REQ, dst__, src__); \
148 msg__->interfaceTag = (interfaceTag__); \
149 msg__->subscriptionHandle = (subscriptionHandle__); \
150 msg__->frameLength = (frameLength__); \
151 msg__->frame = (frame__); \
152 msg__->freeFunction = (freeFunction__); \
153 msg__->priority = (priority__); \
154 msg__->hostTag = (hostTag__); \
155 msg__->cfmRequested = (cfmRequested__);
156
157#define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
158 { \
159 CsrWifiRouterMaPacketReq *msg__; \
160 CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \
161 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
162 }
163
164#define CsrWifiRouterMaPacketReqSend(src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
165 CsrWifiRouterMaPacketReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__)
166
167/*******************************************************************************
168
169 NAME
170 CsrWifiRouterMaPacketIndSend
171
172 DESCRIPTION
173 The router sends the primitive to a subscribed task when it receives a
174 frame matching the subscription.
175
176 PARAMETERS
177 queue - Destination Task Queue
178 interfaceTag - Interface Identifier; unique identifier of an interface
179 subscriptionHandle - The handle of the subscription
180 result - Status of the operation
181 frameLength - Length of the received frame in bytes
182 frame - Pointer to the received frame
183 freeFunction - Pointer to function to be used to free the frame
184 rssi - Received signal strength indication in dBm
185 snr - Signal to Noise Ratio
186 rate - Transmission/Reception rate
187
188*******************************************************************************/
189#define CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
190 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL); \
191 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_IND, dst__, src__); \
192 msg__->interfaceTag = (interfaceTag__); \
193 msg__->subscriptionHandle = (subscriptionHandle__); \
194 msg__->result = (result__); \
195 msg__->frameLength = (frameLength__); \
196 msg__->frame = (frame__); \
197 msg__->freeFunction = (freeFunction__); \
198 msg__->rssi = (rssi__); \
199 msg__->snr = (snr__); \
200 msg__->rate = (rate__);
201
202#define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
203 { \
204 CsrWifiRouterMaPacketInd *msg__; \
205 CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__); \
206 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
207 }
208
209#define CsrWifiRouterMaPacketIndSend(dst__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
210 CsrWifiRouterMaPacketIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__)
211
212/*******************************************************************************
213
214 NAME
215 CsrWifiRouterMaPacketResSend
216
217 DESCRIPTION
218 A task send this primitive to confirm the reception of the received
219 frame.
220
221 PARAMETERS
222 interfaceTag - Interface Identifier; unique identifier of an interface
223 subscriptionHandle - The handle of the subscription
224 result - Status of the operation
225
226*******************************************************************************/
227#define CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
228 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL); \
229 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_RES, dst__, src__); \
230 msg__->interfaceTag = (interfaceTag__); \
231 msg__->subscriptionHandle = (subscriptionHandle__); \
232 msg__->result = (result__);
233
234#define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
235 { \
236 CsrWifiRouterMaPacketRes *msg__; \
237 CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \
238 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
239 }
240
241#define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \
242 CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__)
243
244/*******************************************************************************
245
246 NAME
247 CsrWifiRouterMaPacketCfmSend
248
249 DESCRIPTION
250 The router sends the primitive to confirm the result of the transmission
251 of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
252
253 PARAMETERS
254 queue - Destination Task Queue
255 interfaceTag - Interface Identifier; unique identifier of an interface
256 result - Status of the operation
257 hostTag - The hostTrag will match the hostTag sent in the request.
258 rate - Transmission/Reception rate
259
260*******************************************************************************/
261#define CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
262 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL); \
263 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CFM, dst__, src__); \
264 msg__->interfaceTag = (interfaceTag__); \
265 msg__->result = (result__); \
266 msg__->hostTag = (hostTag__); \
267 msg__->rate = (rate__);
268
269#define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
270 { \
271 CsrWifiRouterMaPacketCfm *msg__; \
272 CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \
273 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
274 }
275
276#define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \
277 CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__)
278
279/*******************************************************************************
280
281 NAME
282 CsrWifiRouterMaPacketSubscribeReqSend
283
284 DESCRIPTION
285 A task can use this primitive to subscribe for a particular OUI/protocol
286 and transmit and receive frames matching the subscription.
287 NOTE: Multiple subscriptions for a given protocol and OUI will result in
288 the first subscription receiving the data and not the subsequent
289 subscriptions.
290
291 PARAMETERS
292 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
293 interfaceTag - Interface Identifier; unique identifier of an interface
294 encapsulation - Specifies the encapsulation type, which will be used for the
295 subscription
296 protocol - Together with the OUI, specifies the protocol, which a task
297 wants to subscribe to
298 oui - Specifies the OUI for the protocol, which a task wants to
299 subscribe to
300
301*******************************************************************************/
302#define CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
303 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL); \
304 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, dst__, src__); \
305 msg__->interfaceTag = (interfaceTag__); \
306 msg__->encapsulation = (encapsulation__); \
307 msg__->protocol = (protocol__); \
308 msg__->oui = (oui__);
309
310#define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
311 { \
312 CsrWifiRouterMaPacketSubscribeReq *msg__; \
313 CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \
314 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
315 }
316
317#define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \
318 CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__)
319
320/*******************************************************************************
321
322 NAME
323 CsrWifiRouterMaPacketSubscribeCfmSend
324
325 DESCRIPTION
326 The router sends this primitive to confirm the result of the
327 subscription.
328
329 PARAMETERS
330 queue - Destination Task Queue
331 interfaceTag - Interface Identifier; unique identifier of an interface
332 subscriptionHandle - Handle to the subscription
333 This handle must be used in all subsequent requests
334 status - Status of the operation
335 allocOffset - Size of the offset for the frames of the subscription
336
337*******************************************************************************/
338#define CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
339 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL); \
340 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, dst__, src__); \
341 msg__->interfaceTag = (interfaceTag__); \
342 msg__->subscriptionHandle = (subscriptionHandle__); \
343 msg__->status = (status__); \
344 msg__->allocOffset = (allocOffset__);
345
346#define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
347 { \
348 CsrWifiRouterMaPacketSubscribeCfm *msg__; \
349 CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \
350 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
351 }
352
353#define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
354 CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__)
355
356/*******************************************************************************
357
358 NAME
359 CsrWifiRouterMaPacketUnsubscribeReqSend
360
361 DESCRIPTION
362 A task sends this primitive to unsubscribe a subscription
363
364 PARAMETERS
365 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
366 interfaceTag - Interface Identifier; unique identifier of an interface
367 subscriptionHandle - The handle of the subscription
368
369*******************************************************************************/
370#define CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__) \
371 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeReq), GFP_KERNEL); \
372 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, dst__, src__); \
373 msg__->interfaceTag = (interfaceTag__); \
374 msg__->subscriptionHandle = (subscriptionHandle__);
375
376#define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \
377 { \
378 CsrWifiRouterMaPacketUnsubscribeReq *msg__; \
379 CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \
380 CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
381 }
382
383#define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \
384 CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__)
385
386/*******************************************************************************
387
388 NAME
389 CsrWifiRouterMaPacketUnsubscribeCfmSend
390
391 DESCRIPTION
392 The router sends this primitive to confirm the result of the
393 unsubscription.
394
395 PARAMETERS
396 queue - Destination Task Queue
397 interfaceTag - Interface Identifier; unique identifier of an interface
398 status - Status of the operation
399
400*******************************************************************************/
401#define CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
402 msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL); \
403 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, dst__, src__); \
404 msg__->interfaceTag = (interfaceTag__); \
405 msg__->status = (status__);
406
407#define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \
408 { \
409 CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \
410 CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
411 CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
412 }
413
414#define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \
415 CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__)
416
417#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
index c52344b51f2f..000000000000
--- a/drivers/staging/csr/csr_wifi_router_prim.h
+++ /dev/null
@@ -1,421 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_PRIM_H__
14#define CSR_WIFI_ROUTER_PRIM_H__
15
16#include <linux/types.h>
17#include "csr_prim_defs.h"
18#include "csr_sched.h"
19#include "csr_wifi_common.h"
20#include "csr_result.h"
21#include "csr_wifi_fsm_event.h"
22
23#define CSR_WIFI_ROUTER_PRIM (0x0400)
24
25typedef CsrPrim CsrWifiRouterPrim;
26
27typedef void (*CsrWifiRouterFrameFreeFunction)(void *frame);
28
29/*******************************************************************************
30
31 NAME
32 CsrWifiRouterAppType
33
34 DESCRIPTION
35
36 VALUES
37 CSR_WIFI_ROUTER_APP_TYPE_SME -
38 CSR_WIFI_ROUTER_APP_TYPE_PAL -
39 CSR_WIFI_ROUTER_APP_TYPE_NME -
40 CSR_WIFI_ROUTER_APP_TYPE_OTHER -
41
42*******************************************************************************/
43typedef u8 CsrWifiRouterAppType;
44#define CSR_WIFI_ROUTER_APP_TYPE_SME ((CsrWifiRouterAppType) 0x0)
45#define CSR_WIFI_ROUTER_APP_TYPE_PAL ((CsrWifiRouterAppType) 0x1)
46#define CSR_WIFI_ROUTER_APP_TYPE_NME ((CsrWifiRouterAppType) 0x2)
47#define CSR_WIFI_ROUTER_APP_TYPE_OTHER ((CsrWifiRouterAppType) 0x3)
48
49/*******************************************************************************
50
51 NAME
52 CsrWifiRouterEncapsulation
53
54 DESCRIPTION
55 Indicates the type of encapsulation used for the subscription
56
57 VALUES
58 CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET
59 - Ethernet encapsulation
60 CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP
61 - LLC/SNAP encapsulation
62
63*******************************************************************************/
64typedef u8 CsrWifiRouterEncapsulation;
65#define CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET ((CsrWifiRouterEncapsulation) 0x00)
66#define CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP ((CsrWifiRouterEncapsulation) 0x01)
67
68/*******************************************************************************
69
70 NAME
71 CsrWifiRouterOui
72
73 DESCRIPTION
74
75 VALUES
76 CSR_WIFI_ROUTER_OUI_RFC_1042 -
77 CSR_WIFI_ROUTER_OUI_BT -
78
79*******************************************************************************/
80typedef u32 CsrWifiRouterOui;
81#define CSR_WIFI_ROUTER_OUI_RFC_1042 ((CsrWifiRouterOui) 0x000000)
82#define CSR_WIFI_ROUTER_OUI_BT ((CsrWifiRouterOui) 0x001958)
83
84/*******************************************************************************
85
86 NAME
87 CsrWifiRouterPriority
88
89 DESCRIPTION
90 As defined in the IEEE 802.11 standards
91
92 VALUES
93 CSR_WIFI_ROUTER_PRIORITY_QOS_UP0
94 - See IEEE 802.11 Standard
95 CSR_WIFI_ROUTER_PRIORITY_QOS_UP1
96 - See IEEE 802.11 Standard
97 CSR_WIFI_ROUTER_PRIORITY_QOS_UP2
98 - See IEEE 802.11 Standard
99 CSR_WIFI_ROUTER_PRIORITY_QOS_UP3
100 - See IEEE 802.11 Standard
101 CSR_WIFI_ROUTER_PRIORITY_QOS_UP4
102 - See IEEE 802.11 Standard
103 CSR_WIFI_ROUTER_PRIORITY_QOS_UP5
104 - See IEEE 802.11 Standard
105 CSR_WIFI_ROUTER_PRIORITY_QOS_UP6
106 - See IEEE 802.11 Standard
107 CSR_WIFI_ROUTER_PRIORITY_QOS_UP7
108 - See IEEE 802.11 Standard
109 CSR_WIFI_ROUTER_PRIORITY_CONTENTION
110 - See IEEE 802.11 Standard
111 CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT
112 - See IEEE 802.11 Standard
113
114*******************************************************************************/
115typedef u16 CsrWifiRouterPriority;
116#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP0 ((CsrWifiRouterPriority) 0x0000)
117#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP1 ((CsrWifiRouterPriority) 0x0001)
118#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP2 ((CsrWifiRouterPriority) 0x0002)
119#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP3 ((CsrWifiRouterPriority) 0x0003)
120#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP4 ((CsrWifiRouterPriority) 0x0004)
121#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP5 ((CsrWifiRouterPriority) 0x0005)
122#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP6 ((CsrWifiRouterPriority) 0x0006)
123#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP7 ((CsrWifiRouterPriority) 0x0007)
124#define CSR_WIFI_ROUTER_PRIORITY_CONTENTION ((CsrWifiRouterPriority) 0x8000)
125#define CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT ((CsrWifiRouterPriority) 0x8010)
126
127
128/* Downstream */
129#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST (0x0000)
130
131#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ ((CsrWifiRouterPrim) (0x0000 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
132#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ ((CsrWifiRouterPrim) (0x0001 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
133#define CSR_WIFI_ROUTER_MA_PACKET_REQ ((CsrWifiRouterPrim) (0x0002 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
134#define CSR_WIFI_ROUTER_MA_PACKET_RES ((CsrWifiRouterPrim) (0x0003 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
135#define CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ ((CsrWifiRouterPrim) (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
136
137
138#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)
139
140/* Upstream */
141#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
142
143#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM ((CsrWifiRouterPrim)(0x0000 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
144#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM ((CsrWifiRouterPrim)(0x0001 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
145#define CSR_WIFI_ROUTER_MA_PACKET_CFM ((CsrWifiRouterPrim)(0x0002 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
146#define CSR_WIFI_ROUTER_MA_PACKET_IND ((CsrWifiRouterPrim)(0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
147
148#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST (0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)
149
150#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)
151#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT (CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)
152
153/*******************************************************************************
154
155 NAME
156 CsrWifiRouterMaPacketSubscribeReq
157
158 DESCRIPTION
159 A task can use this primitive to subscribe for a particular OUI/protocol
160 and transmit and receive frames matching the subscription.
161 NOTE: Multiple subscriptions for a given protocol and OUI will result in
162 the first subscription receiving the data and not the subsequent
163 subscriptions.
164
165 MEMBERS
166 common - Common header for use with the CsrWifiFsm Module
167 interfaceTag - Interface Identifier; unique identifier of an interface
168 encapsulation - Specifies the encapsulation type, which will be used for the
169 subscription
170 protocol - Together with the OUI, specifies the protocol, which a task
171 wants to subscribe to
172 oui - Specifies the OUI for the protocol, which a task wants to
173 subscribe to
174
175*******************************************************************************/
176typedef struct
177{
178 CsrWifiFsmEvent common;
179 u16 interfaceTag;
180 CsrWifiRouterEncapsulation encapsulation;
181 u16 protocol;
182 u32 oui;
183} CsrWifiRouterMaPacketSubscribeReq;
184
185/*******************************************************************************
186
187 NAME
188 CsrWifiRouterMaPacketUnsubscribeReq
189
190 DESCRIPTION
191 A task sends this primitive to unsubscribe a subscription
192
193 MEMBERS
194 common - Common header for use with the CsrWifiFsm Module
195 interfaceTag - Interface Identifier; unique identifier of an interface
196 subscriptionHandle - The handle of the subscription
197
198*******************************************************************************/
199typedef struct
200{
201 CsrWifiFsmEvent common;
202 u16 interfaceTag;
203 u8 subscriptionHandle;
204} CsrWifiRouterMaPacketUnsubscribeReq;
205
206/*******************************************************************************
207
208 NAME
209 CsrWifiRouterMaPacketReq
210
211 DESCRIPTION
212 A task sends this primitive to transmit a frame.
213
214 MEMBERS
215 common - Common header for use with the CsrWifiFsm Module
216 interfaceTag - Interface Identifier; unique identifier of an interface
217 subscriptionHandle - The handle of the subscription
218 frameLength - Length of the frame to be sent in bytes
219 frame - Pointer to the frame to be sent
220 freeFunction - Pointer to function to be used to free the frame
221 priority - Priority of the frame, which should be sent
222 hostTag - An application shall set the bits b31..b28 using one of
223 the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
224 be used by the requestor without any restrictions, but
225 the hostTag shall be unique so the hostTag for
226 CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
227 in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
228 (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
229 (20 bits) ]. If the hostTag is not unique, the
230 behaviour of the system is unpredicatable with respect
231 to data/management frame transfer.
232 cfmRequested - Indicates if the requestor needs a confirm for packet
233 requests sent under this subscription. If set to TRUE,
234 the router will send a confirm, else it will not send
235 any confirm
236
237*******************************************************************************/
238typedef struct
239{
240 CsrWifiFsmEvent common;
241 u16 interfaceTag;
242 u8 subscriptionHandle;
243 u16 frameLength;
244 u8 *frame;
245 CsrWifiRouterFrameFreeFunction freeFunction;
246 CsrWifiRouterPriority priority;
247 u32 hostTag;
248 u8 cfmRequested;
249} CsrWifiRouterMaPacketReq;
250
251/*******************************************************************************
252
253 NAME
254 CsrWifiRouterMaPacketRes
255
256 DESCRIPTION
257 A task send this primitive to confirm the reception of the received
258 frame.
259
260 MEMBERS
261 common - Common header for use with the CsrWifiFsm Module
262 interfaceTag - Interface Identifier; unique identifier of an interface
263 subscriptionHandle - The handle of the subscription
264 result - Status of the operation
265
266*******************************************************************************/
267typedef struct
268{
269 CsrWifiFsmEvent common;
270 u16 interfaceTag;
271 u8 subscriptionHandle;
272 CsrResult result;
273} CsrWifiRouterMaPacketRes;
274
275/*******************************************************************************
276
277 NAME
278 CsrWifiRouterMaPacketCancelReq
279
280 DESCRIPTION
281 This primitive is used to request cancellation of a previously send
282 CsrWifiRouterMaPacketReq.
283 The frame may already have been transmitted so there is no guarantees
284 that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
285 of the frame in question.
286 If the cancellation fails, the Router will send, if required,
287 CsrWifiRouterMaPacketCfm.
288 If the cancellation succeeds, the Router will not send
289 CsrWifiRouterMaPacketCfm.
290
291 MEMBERS
292 common - Common header for use with the CsrWifiFsm Module
293 interfaceTag - Interface Identifier; unique identifier of an interface
294 hostTag - The hostTag for the frame, which should be cancelled.
295 priority - Priority of the frame, which should be cancelled
296 peerMacAddress - Destination MAC address of the frame, which should be
297 cancelled
298
299*******************************************************************************/
300typedef struct
301{
302 CsrWifiFsmEvent common;
303 u16 interfaceTag;
304 u32 hostTag;
305 CsrWifiRouterPriority priority;
306 CsrWifiMacAddress peerMacAddress;
307} CsrWifiRouterMaPacketCancelReq;
308
309/*******************************************************************************
310
311 NAME
312 CsrWifiRouterMaPacketSubscribeCfm
313
314 DESCRIPTION
315 The router sends this primitive to confirm the result of the
316 subscription.
317
318 MEMBERS
319 common - Common header for use with the CsrWifiFsm Module
320 interfaceTag - Interface Identifier; unique identifier of an interface
321 subscriptionHandle - Handle to the subscription
322 This handle must be used in all subsequent requests
323 status - Status of the operation
324 allocOffset - Size of the offset for the frames of the subscription
325
326*******************************************************************************/
327typedef struct
328{
329 CsrWifiFsmEvent common;
330 u16 interfaceTag;
331 u8 subscriptionHandle;
332 CsrResult status;
333 u16 allocOffset;
334} CsrWifiRouterMaPacketSubscribeCfm;
335
336/*******************************************************************************
337
338 NAME
339 CsrWifiRouterMaPacketUnsubscribeCfm
340
341 DESCRIPTION
342 The router sends this primitive to confirm the result of the
343 unsubscription.
344
345 MEMBERS
346 common - Common header for use with the CsrWifiFsm Module
347 interfaceTag - Interface Identifier; unique identifier of an interface
348 status - Status of the operation
349
350*******************************************************************************/
351typedef struct
352{
353 CsrWifiFsmEvent common;
354 u16 interfaceTag;
355 CsrResult status;
356} CsrWifiRouterMaPacketUnsubscribeCfm;
357
358/*******************************************************************************
359
360 NAME
361 CsrWifiRouterMaPacketCfm
362
363 DESCRIPTION
364 The router sends the primitive to confirm the result of the transmission
365 of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
366
367 MEMBERS
368 common - Common header for use with the CsrWifiFsm Module
369 interfaceTag - Interface Identifier; unique identifier of an interface
370 result - Status of the operation
371 hostTag - The hostTrag will match the hostTag sent in the request.
372 rate - Transmission/Reception rate
373
374*******************************************************************************/
375typedef struct
376{
377 CsrWifiFsmEvent common;
378 u16 interfaceTag;
379 CsrResult result;
380 u32 hostTag;
381 u16 rate;
382} CsrWifiRouterMaPacketCfm;
383
384/*******************************************************************************
385
386 NAME
387 CsrWifiRouterMaPacketInd
388
389 DESCRIPTION
390 The router sends the primitive to a subscribed task when it receives a
391 frame matching the subscription.
392
393 MEMBERS
394 common - Common header for use with the CsrWifiFsm Module
395 interfaceTag - Interface Identifier; unique identifier of an interface
396 subscriptionHandle - The handle of the subscription
397 result - Status of the operation
398 frameLength - Length of the received frame in bytes
399 frame - Pointer to the received frame
400 freeFunction - Pointer to function to be used to free the frame
401 rssi - Received signal strength indication in dBm
402 snr - Signal to Noise Ratio
403 rate - Transmission/Reception rate
404
405*******************************************************************************/
406typedef struct
407{
408 CsrWifiFsmEvent common;
409 u16 interfaceTag;
410 u8 subscriptionHandle;
411 CsrResult result;
412 u16 frameLength;
413 u8 *frame;
414 CsrWifiRouterFrameFreeFunction freeFunction;
415 s16 rssi;
416 s16 snr;
417 u16 rate;
418} CsrWifiRouterMaPacketInd;
419
420#endif /* CSR_WIFI_ROUTER_PRIM_H__ */
421
diff --git a/drivers/staging/csr/csr_wifi_router_sef.c b/drivers/staging/csr/csr_wifi_router_sef.c
deleted file mode 100644
index 45a10fb77296..000000000000
--- a/drivers/staging/csr/csr_wifi_router_sef.c
+++ /dev/null
@@ -1,19 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 Confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9 *****************************************************************************/
10#include "csr_wifi_router_sef.h"
11
12const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT] =
13{
14 /* 0x0000 */ CsrWifiRouterMaPacketSubscribeReqHandler,
15 /* 0x0001 */ CsrWifiRouterMaPacketUnsubscribeReqHandler,
16 /* 0x0002 */ CsrWifiRouterMaPacketReqHandler,
17 /* 0x0003 */ CsrWifiRouterMaPacketResHandler,
18 /* 0x0004 */ CsrWifiRouterMaPacketCancelReqHandler,
19};
diff --git a/drivers/staging/csr/csr_wifi_router_sef.h b/drivers/staging/csr/csr_wifi_router_sef.h
deleted file mode 100644
index 86692c7780c9..000000000000
--- a/drivers/staging/csr/csr_wifi_router_sef.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 Confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9 *****************************************************************************/
10#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__
11#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__
12
13#include "csr_wifi_router_prim.h"
14
15 typedef void (*CsrWifiRouterStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
16
17 extern const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
18
19 extern void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
20 extern void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
21 extern void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
22 extern void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
23 extern void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
24
25#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
index 4eccf5d6c289..000000000000
--- a/drivers/staging/csr/csr_wifi_router_serialize.c
+++ /dev/null
@@ -1,418 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_msgconv.h"
14#include "csr_wifi_router_prim.h"
15#include "csr_wifi_router_serialize.h"
16
17void CsrWifiRouterPfree(void *ptr)
18{
19 kfree(ptr);
20}
21
22
23size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg)
24{
25 size_t bufferSize = 2;
26
27 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
28 bufferSize += 2; /* u16 primitive->interfaceTag */
29 bufferSize += 1; /* CsrWifiRouterEncapsulation primitive->encapsulation */
30 bufferSize += 2; /* u16 primitive->protocol */
31 bufferSize += 4; /* u32 primitive->oui */
32 return bufferSize;
33}
34
35
36u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg)
37{
38 CsrWifiRouterMaPacketSubscribeReq *primitive = (CsrWifiRouterMaPacketSubscribeReq *)msg;
39 *len = 0;
40 CsrUint16Ser(ptr, len, primitive->common.type);
41 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
42 CsrUint8Ser(ptr, len, (u8) primitive->encapsulation);
43 CsrUint16Ser(ptr, len, (u16) primitive->protocol);
44 CsrUint32Ser(ptr, len, (u32) primitive->oui);
45 return(ptr);
46}
47
48
49void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t length)
50{
51 CsrWifiRouterMaPacketSubscribeReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL);
52 size_t offset;
53 offset = 0;
54
55 CsrUint16Des(&primitive->common.type, buffer, &offset);
56 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
57 CsrUint8Des((u8 *) &primitive->encapsulation, buffer, &offset);
58 CsrUint16Des((u16 *) &primitive->protocol, buffer, &offset);
59 CsrUint32Des((u32 *) &primitive->oui, buffer, &offset);
60
61 return primitive;
62}
63
64
65size_t CsrWifiRouterMaPacketReqSizeof(void *msg)
66{
67 CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) msg;
68 size_t bufferSize = 2;
69
70 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 20) */
71 bufferSize += 2; /* u16 primitive->interfaceTag */
72 bufferSize += 1; /* u8 primitive->subscriptionHandle */
73 bufferSize += 2; /* u16 primitive->frameLength */
74 bufferSize += primitive->frameLength; /* u8 primitive->frame */
75 bufferSize += 4; /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */
76 bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */
77 bufferSize += 4; /* u32 primitive->hostTag */
78 bufferSize += 1; /* u8 primitive->cfmRequested */
79 return bufferSize;
80}
81
82
83u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg)
84{
85 CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *)msg;
86 *len = 0;
87 CsrUint16Ser(ptr, len, primitive->common.type);
88 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
89 CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
90 CsrUint16Ser(ptr, len, (u16) primitive->frameLength);
91 if (primitive->frameLength)
92 {
93 CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength)));
94 }
95 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */
96 CsrUint16Ser(ptr, len, (u16) primitive->priority);
97 CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
98 CsrUint8Ser(ptr, len, (u8) primitive->cfmRequested);
99 return(ptr);
100}
101
102
103void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t length)
104{
105 CsrWifiRouterMaPacketReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL);
106 size_t offset;
107 offset = 0;
108
109 CsrUint16Des(&primitive->common.type, buffer, &offset);
110 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
111 CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
112 CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset);
113 if (primitive->frameLength)
114 {
115 primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL);
116 CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength)));
117 }
118 else
119 {
120 primitive->frame = NULL;
121 }
122 primitive->freeFunction = NULL; /* Special for Function Pointers... */
123 offset += 4;
124 CsrUint16Des((u16 *) &primitive->priority, buffer, &offset);
125 CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
126 CsrUint8Des((u8 *) &primitive->cfmRequested, buffer, &offset);
127
128 return primitive;
129}
130
131
132void CsrWifiRouterMaPacketReqSerFree(void *voidPrimitivePointer)
133{
134 CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) voidPrimitivePointer;
135 kfree(primitive->frame);
136 kfree(primitive);
137}
138
139
140size_t CsrWifiRouterMaPacketResSizeof(void *msg)
141{
142 size_t bufferSize = 2;
143
144 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
145 bufferSize += 2; /* u16 primitive->interfaceTag */
146 bufferSize += 1; /* u8 primitive->subscriptionHandle */
147 bufferSize += 2; /* CsrResult primitive->result */
148 return bufferSize;
149}
150
151
152u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg)
153{
154 CsrWifiRouterMaPacketRes *primitive = (CsrWifiRouterMaPacketRes *)msg;
155 *len = 0;
156 CsrUint16Ser(ptr, len, primitive->common.type);
157 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
158 CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
159 CsrUint16Ser(ptr, len, (u16) primitive->result);
160 return(ptr);
161}
162
163
164void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t length)
165{
166 CsrWifiRouterMaPacketRes *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL);
167 size_t offset;
168 offset = 0;
169
170 CsrUint16Des(&primitive->common.type, buffer, &offset);
171 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
172 CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
173 CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
174
175 return primitive;
176}
177
178
179size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg)
180{
181 size_t bufferSize = 2;
182
183 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
184 bufferSize += 2; /* u16 primitive->interfaceTag */
185 bufferSize += 4; /* u32 primitive->hostTag */
186 bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */
187 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
188 return bufferSize;
189}
190
191
192u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg)
193{
194 CsrWifiRouterMaPacketCancelReq *primitive = (CsrWifiRouterMaPacketCancelReq *)msg;
195 *len = 0;
196 CsrUint16Ser(ptr, len, primitive->common.type);
197 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
198 CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
199 CsrUint16Ser(ptr, len, (u16) primitive->priority);
200 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
201 return(ptr);
202}
203
204
205void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t length)
206{
207 CsrWifiRouterMaPacketCancelReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL);
208 size_t offset;
209 offset = 0;
210
211 CsrUint16Des(&primitive->common.type, buffer, &offset);
212 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
213 CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
214 CsrUint16Des((u16 *) &primitive->priority, buffer, &offset);
215 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
216
217 return primitive;
218}
219
220
221size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg)
222{
223 size_t bufferSize = 2;
224
225 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
226 bufferSize += 2; /* u16 primitive->interfaceTag */
227 bufferSize += 1; /* u8 primitive->subscriptionHandle */
228 bufferSize += 2; /* CsrResult primitive->status */
229 bufferSize += 2; /* u16 primitive->allocOffset */
230 return bufferSize;
231}
232
233
234u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg)
235{
236 CsrWifiRouterMaPacketSubscribeCfm *primitive = (CsrWifiRouterMaPacketSubscribeCfm *)msg;
237 *len = 0;
238 CsrUint16Ser(ptr, len, primitive->common.type);
239 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
240 CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
241 CsrUint16Ser(ptr, len, (u16) primitive->status);
242 CsrUint16Ser(ptr, len, (u16) primitive->allocOffset);
243 return(ptr);
244}
245
246
247void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t length)
248{
249 CsrWifiRouterMaPacketSubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL);
250 size_t offset;
251 offset = 0;
252
253 CsrUint16Des(&primitive->common.type, buffer, &offset);
254 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
255 CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
256 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
257 CsrUint16Des((u16 *) &primitive->allocOffset, buffer, &offset);
258
259 return primitive;
260}
261
262
263size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg)
264{
265 size_t bufferSize = 2;
266
267 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
268 bufferSize += 2; /* u16 primitive->interfaceTag */
269 bufferSize += 2; /* CsrResult primitive->status */
270 return bufferSize;
271}
272
273
274u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg)
275{
276 CsrWifiRouterMaPacketUnsubscribeCfm *primitive = (CsrWifiRouterMaPacketUnsubscribeCfm *)msg;
277 *len = 0;
278 CsrUint16Ser(ptr, len, primitive->common.type);
279 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
280 CsrUint16Ser(ptr, len, (u16) primitive->status);
281 return(ptr);
282}
283
284
285void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t length)
286{
287 CsrWifiRouterMaPacketUnsubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL);
288 size_t offset;
289 offset = 0;
290
291 CsrUint16Des(&primitive->common.type, buffer, &offset);
292 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
293 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
294
295 return primitive;
296}
297
298
299size_t CsrWifiRouterMaPacketCfmSizeof(void *msg)
300{
301 size_t bufferSize = 2;
302
303 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
304 bufferSize += 2; /* u16 primitive->interfaceTag */
305 bufferSize += 2; /* CsrResult primitive->result */
306 bufferSize += 4; /* u32 primitive->hostTag */
307 bufferSize += 2; /* u16 primitive->rate */
308 return bufferSize;
309}
310
311
312u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg)
313{
314 CsrWifiRouterMaPacketCfm *primitive = (CsrWifiRouterMaPacketCfm *)msg;
315 *len = 0;
316 CsrUint16Ser(ptr, len, primitive->common.type);
317 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
318 CsrUint16Ser(ptr, len, (u16) primitive->result);
319 CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
320 CsrUint16Ser(ptr, len, (u16) primitive->rate);
321 return(ptr);
322}
323
324
325void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t length)
326{
327 CsrWifiRouterMaPacketCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL);
328 size_t offset;
329 offset = 0;
330
331 CsrUint16Des(&primitive->common.type, buffer, &offset);
332 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
333 CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
334 CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
335 CsrUint16Des((u16 *) &primitive->rate, buffer, &offset);
336
337 return primitive;
338}
339
340
341size_t CsrWifiRouterMaPacketIndSizeof(void *msg)
342{
343 CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) msg;
344 size_t bufferSize = 2;
345
346 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
347 bufferSize += 2; /* u16 primitive->interfaceTag */
348 bufferSize += 1; /* u8 primitive->subscriptionHandle */
349 bufferSize += 2; /* CsrResult primitive->result */
350 bufferSize += 2; /* u16 primitive->frameLength */
351 bufferSize += primitive->frameLength; /* u8 primitive->frame */
352 bufferSize += 4; /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */
353 bufferSize += 2; /* s16 primitive->rssi */
354 bufferSize += 2; /* s16 primitive->snr */
355 bufferSize += 2; /* u16 primitive->rate */
356 return bufferSize;
357}
358
359
360u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg)
361{
362 CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *)msg;
363 *len = 0;
364 CsrUint16Ser(ptr, len, primitive->common.type);
365 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
366 CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
367 CsrUint16Ser(ptr, len, (u16) primitive->result);
368 CsrUint16Ser(ptr, len, (u16) primitive->frameLength);
369 if (primitive->frameLength)
370 {
371 CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength)));
372 }
373 CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */
374 CsrUint16Ser(ptr, len, (u16) primitive->rssi);
375 CsrUint16Ser(ptr, len, (u16) primitive->snr);
376 CsrUint16Ser(ptr, len, (u16) primitive->rate);
377 return(ptr);
378}
379
380
381void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t length)
382{
383 CsrWifiRouterMaPacketInd *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL);
384 size_t offset;
385 offset = 0;
386
387 CsrUint16Des(&primitive->common.type, buffer, &offset);
388 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
389 CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
390 CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
391 CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset);
392 if (primitive->frameLength)
393 {
394 primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL);
395 CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength)));
396 }
397 else
398 {
399 primitive->frame = NULL;
400 }
401 primitive->freeFunction = NULL; /* Special for Function Pointers... */
402 offset += 4;
403 CsrUint16Des((u16 *) &primitive->rssi, buffer, &offset);
404 CsrUint16Des((u16 *) &primitive->snr, buffer, &offset);
405 CsrUint16Des((u16 *) &primitive->rate, buffer, &offset);
406
407 return primitive;
408}
409
410
411void CsrWifiRouterMaPacketIndSerFree(void *voidPrimitivePointer)
412{
413 CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) voidPrimitivePointer;
414 kfree(primitive->frame);
415 kfree(primitive);
416}
417
418
diff --git a/drivers/staging/csr/csr_wifi_router_serialize.h b/drivers/staging/csr/csr_wifi_router_serialize.h
deleted file mode 100644
index 94ccdac5606f..000000000000
--- a/drivers/staging/csr/csr_wifi_router_serialize.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_SERIALIZE_H__
14#define CSR_WIFI_ROUTER_SERIALIZE_H__
15
16#include "csr_wifi_msgconv.h"
17#include "csr_wifi_router_prim.h"
18
19extern void CsrWifiRouterPfree(void *ptr);
20
21extern u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg);
22extern void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t len);
23extern size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg);
24#define CsrWifiRouterMaPacketSubscribeReqSerFree CsrWifiRouterPfree
25
26#define CsrWifiRouterMaPacketUnsubscribeReqSer CsrWifiEventCsrUint16CsrUint8Ser
27#define CsrWifiRouterMaPacketUnsubscribeReqDes CsrWifiEventCsrUint16CsrUint8Des
28#define CsrWifiRouterMaPacketUnsubscribeReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
29#define CsrWifiRouterMaPacketUnsubscribeReqSerFree CsrWifiRouterPfree
30
31extern u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg);
32extern void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t len);
33extern size_t CsrWifiRouterMaPacketReqSizeof(void *msg);
34extern void CsrWifiRouterMaPacketReqSerFree(void *msg);
35
36extern u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg);
37extern void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t len);
38extern size_t CsrWifiRouterMaPacketResSizeof(void *msg);
39#define CsrWifiRouterMaPacketResSerFree CsrWifiRouterPfree
40
41extern u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg);
42extern void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t len);
43extern size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg);
44#define CsrWifiRouterMaPacketCancelReqSerFree CsrWifiRouterPfree
45
46extern u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg);
47extern void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t len);
48extern size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg);
49#define CsrWifiRouterMaPacketSubscribeCfmSerFree CsrWifiRouterPfree
50
51extern u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg);
52extern void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t len);
53extern size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg);
54#define CsrWifiRouterMaPacketUnsubscribeCfmSerFree CsrWifiRouterPfree
55
56extern u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg);
57extern void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t len);
58extern size_t CsrWifiRouterMaPacketCfmSizeof(void *msg);
59#define CsrWifiRouterMaPacketCfmSerFree CsrWifiRouterPfree
60
61extern u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg);
62extern void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t len);
63extern size_t CsrWifiRouterMaPacketIndSizeof(void *msg);
64extern void CsrWifiRouterMaPacketIndSerFree(void *msg);
65
66#endif /* CSR_WIFI_ROUTER_SERIALIZE_H__ */
67
diff --git a/drivers/staging/csr/csr_wifi_router_task.h b/drivers/staging/csr/csr_wifi_router_task.h
deleted file mode 100644
index 9ba892f34e6d..000000000000
--- a/drivers/staging/csr/csr_wifi_router_task.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_ROUTER_TASK_H__
14#define CSR_WIFI_ROUTER_TASK_H__
15
16#include "csr_sched.h"
17
18#define CSR_WIFI_ROUTER_LOG_ID 0x1201FFFF
19extern CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE;
20void CsrWifiRouterInit(void **gash);
21void CsrWifiRouterDeinit(void **gash);
22void CsrWifiRouterHandler(void **gash);
23
24#endif /* CSR_WIFI_ROUTER_TASK_H__ */
25
diff --git a/drivers/staging/csr/csr_wifi_router_transport.c b/drivers/staging/csr/csr_wifi_router_transport.c
deleted file mode 100644
index e905ead9389b..000000000000
--- a/drivers/staging/csr/csr_wifi_router_transport.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/** @file router_transport.c
2 *
3 *
4 * Copyright (C) Cambridge Silicon Radio Ltd 2006-2010. All rights reserved.
5 *
6 * Refer to LICENSE.txt included with this source code for details on
7 * the license terms.
8 *
9 ****************************************************************************/
10
11#include "unifi_priv.h"
12
13#include "csr_sched.h"
14#include "csr_msgconv.h"
15
16#include "sme_userspace.h"
17
18#include "csr_wifi_hostio_prim.h"
19#include "csr_wifi_router_lib.h"
20#include "csr_wifi_router_sef.h"
21#include "csr_wifi_router_converter_init.h"
22#include "csr_wifi_router_ctrl_lib.h"
23#include "csr_wifi_router_ctrl_sef.h"
24#include "csr_wifi_router_ctrl_converter_init.h"
25#include "csr_wifi_sme_prim.h"
26#include "csr_wifi_sme_sef.h"
27#include "csr_wifi_sme_converter_init.h"
28#ifdef CSR_SUPPORT_WEXT
29#ifdef CSR_SUPPORT_WEXT_AP
30#include "csr_wifi_nme_ap_prim.h"
31#include "csr_wifi_nme_ap_sef.h"
32#include "csr_wifi_nme_ap_converter_init.h"
33#endif
34#endif
35
36static unifi_priv_t *drvpriv = NULL;
37void CsrWifiRouterTransportInit(unifi_priv_t *priv)
38{
39 unifi_trace(priv, UDBG1, "CsrWifiRouterTransportInit: \n");
40
41 drvpriv = priv;
42 (void)CsrMsgConvInit();
43 CsrWifiRouterConverterInit();
44 CsrWifiRouterCtrlConverterInit();
45 CsrWifiSmeConverterInit();
46#ifdef CSR_SUPPORT_WEXT
47#ifdef CSR_SUPPORT_WEXT_AP
48 CsrWifiNmeApConverterInit();
49#endif
50#endif
51}
52
53void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8* buffer, size_t bufferLength)
54{
55 CsrMsgConvMsgEntry* msgEntry;
56 u16 primType;
57 CsrSchedQid src;
58 CsrSchedQid dest;
59 u16 msgType;
60 size_t offset = 0;
61 CsrWifiFsmEvent* msg;
62
63 /* Decode the prim and message type */
64 CsrUint16Des(&primType, buffer, &offset);
65 CsrUint16Des(&src, buffer, &offset);
66 CsrUint16Des(&dest, buffer, &offset);
67 CsrUint16Des(&msgType, buffer, &offset);
68 offset -= 2; /* Adjust as the Deserialise Function will read this as well */
69
70 unifi_trace(priv, UDBG4, "CsrWifiRouterTransportRecv: primType=0x%.4X, msgType=0x%.4X, bufferLength=%d\n",
71 primType, msgType, bufferLength);
72
73 /* Special handling for HOSTIO messages.... */
74 if (primType == CSR_WIFI_HOSTIO_PRIM)
75 {
76 CsrWifiRouterCtrlHipReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, CSR_WIFI_ROUTER_CTRL_PRIM, dest, src, NULL}, 0, NULL, 0, NULL, 0, NULL};
77
78 req.mlmeCommandLength = bufferLength;
79 req.mlmeCommand = buffer;
80
81 offset += 8;/* Skip the id, src, dest and slot number */
82 CsrUint16Des(&req.dataRef1Length, buffer, &offset);
83 offset += 2; /* Skip the slot number */
84 CsrUint16Des(&req.dataRef2Length, buffer, &offset);
85
86 if (req.dataRef1Length)
87 {
88 u16 dr1Offset = (bufferLength - req.dataRef2Length) - req.dataRef1Length;
89 req.dataRef1 = &buffer[dr1Offset];
90 }
91
92 if (req.dataRef2Length)
93 {
94 u16 dr2Offset = bufferLength - req.dataRef2Length;
95 req.dataRef2 = &buffer[dr2Offset];
96 }
97
98 /* Copy the hip data but strip off the prim type */
99 req.mlmeCommandLength -= (req.dataRef1Length + req.dataRef2Length + 6);
100 req.mlmeCommand = &buffer[6];
101
102 CsrWifiRouterCtrlHipReqHandler(priv, &req.common);
103 return;
104 }
105
106 msgEntry = CsrMsgConvFindEntry(primType, msgType);
107 if (!msgEntry)
108 {
109 unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n",
110 primType, msgType);
111 dump(buffer, bufferLength);
112 return;
113 }
114
115 msg = (CsrWifiFsmEvent*)(msgEntry->deserFunc)(&buffer[offset], bufferLength - offset);
116
117 msg->primtype = primType;
118 msg->type = msgType;
119 msg->source = src;
120 msg->destination = dest;
121
122 switch(primType)
123 {
124 case CSR_WIFI_ROUTER_CTRL_PRIM:
125 CsrWifiRouterCtrlDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST](priv, msg);
126 CsrWifiRouterCtrlFreeDownstreamMessageContents(CSR_WIFI_ROUTER_CTRL_PRIM, msg);
127 break;
128 case CSR_WIFI_ROUTER_PRIM:
129 CsrWifiRouterDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST](priv, msg);
130 CsrWifiRouterFreeDownstreamMessageContents(CSR_WIFI_ROUTER_PRIM, msg);
131 break;
132 case CSR_WIFI_SME_PRIM:
133 CsrWifiSmeUpstreamStateHandlers[msg->type - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST](priv, msg);
134 CsrWifiSmeFreeUpstreamMessageContents(CSR_WIFI_SME_PRIM, msg);
135 break;
136#ifdef CSR_SUPPORT_WEXT
137#ifdef CSR_SUPPORT_WEXT_AP
138 case CSR_WIFI_NME_AP_PRIM:
139 CsrWifiNmeApUpstreamStateHandlers(priv, msg);
140 CsrWifiNmeApFreeUpstreamMessageContents(CSR_WIFI_NME_AP_PRIM, msg);
141 break;
142#endif
143#endif
144 default:
145 unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend unhandled prim type 0x%.4X\n", primType);
146 break;
147 }
148 kfree(msg);
149}
150
151static void CsrWifiRouterTransportSerialiseAndSend(u16 primType, void* msg)
152{
153 CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)msg;
154 CsrMsgConvMsgEntry* msgEntry;
155 size_t msgSize;
156 size_t encodeBufferLen = 0;
157 size_t offset = 0;
158 u8* encodeBuffer;
159
160 unifi_trace(drvpriv, UDBG4, "CsrWifiRouterTransportSerialiseAndSend: primType=0x%.4X, msgType=0x%.4X\n",
161 primType, evt->type);
162
163 msgEntry = CsrMsgConvFindEntry(primType, evt->type);
164 if (!msgEntry)
165 {
166 unifi_error(drvpriv, "CsrWifiRouterTransportSerialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n",
167 primType, evt->type);
168 return;
169 }
170
171 msgSize = 6 + (msgEntry->sizeofFunc)((void*)msg);
172
173 encodeBuffer = kmalloc(msgSize, GFP_KERNEL);
174
175 /* Encode PrimType */
176 CsrUint16Ser(encodeBuffer, &encodeBufferLen, primType);
177 CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->source);
178 CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->destination);
179
180 (void)(msgEntry->serFunc)(&encodeBuffer[encodeBufferLen], &offset, msg);
181 encodeBufferLen += offset;
182
183 uf_sme_queue_message(drvpriv, encodeBuffer, encodeBufferLen);
184
185 /* Do not use msgEntry->freeFunc because the memory is owned by the driver */
186 kfree(msg);
187}
188
189#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
190void CsrSchedMessagePutStringLog(CsrSchedQid q, u16 mi, void *mv, u32 line, char *file)
191#else
192void CsrSchedMessagePut(CsrSchedQid q, u16 mi, void *mv)
193#endif
194{
195 CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)mv;
196 evt->destination = q;
197 CsrWifiRouterTransportSerialiseAndSend(mi, mv);
198}
199
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
index dd93d0061190..000000000000
--- a/drivers/staging/csr/csr_wifi_serialize_primitive_types.c
+++ /dev/null
@@ -1,256 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#include <linux/module.h>
12#include <linux/slab.h>
13#include "csr_macro.h"
14#include "csr_msgconv.h"
15#include "csr_wifi_msgconv.h"
16#include "csr_wifi_lib.h"
17
18void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset)
19{
20 u32 val;
21
22 val = ((buffer[(*offset) + 2] << 16) |
23 (buffer[(*offset) + 1] << 8) |
24 (buffer[(*offset)]));
25
26 *offset += 3;
27 *v = val;
28}
29
30
31/* Big endian :e.g WSC, TCLAS */
32void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset)
33{
34 u16 val;
35
36 val = (buffer[(*offset)] << 8) | (buffer[(*offset) + 1]);
37 *offset += 2;
38
39 *v = val;
40}
41
42
43void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
44{
45 u32 val;
46
47 val = ((buffer[(*offset)] << 16) |
48 (buffer[(*offset) + 1] << 8) |
49 (buffer[(*offset) + 2]));
50
51 *offset += 3;
52 *v = val;
53}
54
55
56void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
57{
58 u32 val;
59
60 val = ((buffer[(*offset)] << 24) |
61 (buffer[(*offset) + 1] << 16) |
62 (buffer[(*offset) + 2] << 8) |
63 (buffer[(*offset) + 3]));
64
65 *offset += 4;
66 *v = val;
67}
68
69
70void CsrUint24Ser(u8 *ptr, size_t *len, u32 v)
71{
72 ptr[(*len) + 2] = (u8)((v & 0x00ff0000) >> 16);
73 ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
74 ptr[(*len)] = (u8)((v & 0x000000ff));
75
76 *len += 3;
77}
78
79
80/* Big endian :e.g WSC, TCLAS */
81void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v)
82{
83 ptr[(*len)] = (u8)((v & 0xff00) >> 8);
84 ptr[(*len) + 1] = (u8)((v & 0x00ff));
85
86 *len += 2;
87}
88
89
90void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v)
91{
92 ptr[(*len)] = (u8)((v & 0xff000000) >> 24);
93 ptr[(*len) + 1] = (u8)((v & 0x00ff0000) >> 16);
94 ptr[(*len) + 2] = (u8)((v & 0x0000ff00) >> 8);
95 ptr[(*len) + 3] = (u8)((v & 0x000000ff));
96
97 *len += 4;
98}
99
100
101void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v)
102{
103 ptr[(*len)] = (u8)((v & 0x00ff0000) >> 16);
104 ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
105 ptr[(*len) + 2] = (u8)((v & 0x000000ff));
106
107 *len += 3;
108}
109
110
111size_t CsrWifiEventSizeof(void *msg)
112{
113 return 2;
114}
115EXPORT_SYMBOL_GPL(CsrWifiEventSizeof);
116
117u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg)
118{
119 CsrWifiFsmEvent *primitive = (CsrWifiFsmEvent *)msg;
120 *len = 0;
121 CsrUint16Ser(ptr, len, primitive->type);
122 return(ptr);
123}
124EXPORT_SYMBOL_GPL(CsrWifiEventSer);
125
126void* CsrWifiEventDes(u8 *buffer, size_t length)
127{
128 CsrWifiFsmEvent *primitive = kmalloc(sizeof(CsrWifiFsmEvent), GFP_KERNEL);
129 size_t offset = 0;
130 CsrUint16Des(&primitive->type, buffer, &offset);
131
132 return primitive;
133}
134EXPORT_SYMBOL_GPL(CsrWifiEventDes);
135
136size_t CsrWifiEventCsrUint8Sizeof(void *msg)
137{
138 return 3;
139}
140EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Sizeof);
141
142u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg)
143{
144 CsrWifiEventCsrUint8 *primitive = (CsrWifiEventCsrUint8 *)msg;
145 *len = 0;
146 CsrUint16Ser(ptr, len, primitive->common.type);
147 CsrUint8Ser(ptr, len, primitive->value);
148 return(ptr);
149}
150EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Ser);
151
152
153void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length)
154{
155 CsrWifiEventCsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint8), GFP_KERNEL);
156
157 size_t offset = 0;
158 CsrUint16Des(&primitive->common.type, buffer, &offset);
159 CsrUint8Des(&primitive->value, buffer, &offset);
160
161 return primitive;
162}
163EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Des);
164
165
166size_t CsrWifiEventCsrUint16Sizeof(void *msg)
167{
168 return 4;
169}
170EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Sizeof);
171
172
173u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg)
174{
175 CsrWifiEventCsrUint16 *primitive = (CsrWifiEventCsrUint16 *)msg;
176 *len = 0;
177 CsrUint16Ser(ptr, len, primitive->common.type);
178 CsrUint16Ser(ptr, len, primitive->value);
179 return(ptr);
180}
181EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Ser);
182
183void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length)
184{
185 CsrWifiEventCsrUint16 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16), GFP_KERNEL);
186
187 size_t offset = 0;
188 CsrUint16Des(&primitive->common.type, buffer, &offset);
189 CsrUint16Des(&primitive->value, buffer, &offset);
190
191 return primitive;
192}
193EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Des);
194
195
196size_t CsrWifiEventCsrUint32Sizeof(void *msg)
197{
198 return 6;
199}
200EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Sizeof);
201
202u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg)
203{
204 CsrWifiEventCsrUint32 *primitive = (CsrWifiEventCsrUint32 *)msg;
205 *len = 0;
206 CsrUint16Ser(ptr, len, primitive->common.type);
207 CsrUint32Ser(ptr, len, primitive->value);
208 return(ptr);
209}
210EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Ser);
211
212
213void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length)
214{
215 CsrWifiEventCsrUint32 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint32), GFP_KERNEL);
216
217 size_t offset = 0;
218 CsrUint16Des(&primitive->common.type, buffer, &offset);
219 CsrUint32Des(&primitive->value, buffer, &offset);
220
221 return primitive;
222}
223EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Des);
224
225size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg)
226{
227 return 5;
228}
229EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Sizeof);
230
231u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg)
232{
233 CsrWifiEventCsrUint16CsrUint8 *primitive = (CsrWifiEventCsrUint16CsrUint8 *)msg;
234 *len = 0;
235 CsrUint16Ser(ptr, len, primitive->common.type);
236 CsrUint16Ser(ptr, len, primitive->value16);
237 CsrUint8Ser(ptr, len, primitive->value8);
238 return(ptr);
239}
240EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Ser);
241
242
243void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length)
244{
245 CsrWifiEventCsrUint16CsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16CsrUint8), GFP_KERNEL);
246
247 size_t offset = 0;
248 CsrUint16Des(&primitive->common.type, buffer, &offset);
249 CsrUint16Des(&primitive->value16, buffer, &offset);
250 CsrUint8Des(&primitive->value8, buffer, &offset);
251
252 return primitive;
253}
254EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Des);
255
256
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
index 48ea9143f591..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_ap_lib.h
+++ /dev/null
@@ -1,774 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_AP_LIB_H__
14#define CSR_WIFI_SME_AP_LIB_H__
15
16#include "csr_sched.h"
17#include "csr_macro.h"
18#include "csr_msg_transport.h"
19
20#include "csr_wifi_lib.h"
21
22#include "csr_wifi_sme_ap_prim.h"
23#include "csr_wifi_sme_task.h"
24
25#ifndef CSR_WIFI_AP_ENABLE
26#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_lib.h
27#endif
28
29/*----------------------------------------------------------------------------*
30 * CsrWifiSmeApFreeUpstreamMessageContents
31 *
32 * DESCRIPTION
33 * Free the allocated memory in a CSR_WIFI_SME_AP upstream message. Does not
34 * free the message itself, and can only be used for upstream messages.
35 *
36 * PARAMETERS
37 * Deallocates the resources in a CSR_WIFI_SME_AP upstream message
38 *----------------------------------------------------------------------------*/
39void CsrWifiSmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
40
41/*----------------------------------------------------------------------------*
42 * CsrWifiSmeApFreeDownstreamMessageContents
43 *
44 * DESCRIPTION
45 * Free the allocated memory in a CSR_WIFI_SME_AP downstream message. Does not
46 * free the message itself, and can only be used for downstream messages.
47 *
48 * PARAMETERS
49 * Deallocates the resources in a CSR_WIFI_SME_AP downstream message
50 *----------------------------------------------------------------------------*/
51void CsrWifiSmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
52
53/*----------------------------------------------------------------------------*
54 * Enum to string functions
55 *----------------------------------------------------------------------------*/
56const char* CsrWifiSmeApAccessTypeToString(CsrWifiSmeApAccessType value);
57const char* CsrWifiSmeApAuthSupportToString(CsrWifiSmeApAuthSupport value);
58const char* CsrWifiSmeApAuthTypeToString(CsrWifiSmeApAuthType value);
59const char* CsrWifiSmeApDirectionToString(CsrWifiSmeApDirection value);
60const char* CsrWifiSmeApPhySupportToString(CsrWifiSmeApPhySupport value);
61const char* CsrWifiSmeApTypeToString(CsrWifiSmeApType value);
62
63
64/*----------------------------------------------------------------------------*
65 * CsrPrim Type toString function.
66 * Converts a message type to the String name of the Message
67 *----------------------------------------------------------------------------*/
68const char* CsrWifiSmeApPrimTypeToString(CsrPrim msgType);
69
70/*----------------------------------------------------------------------------*
71 * Lookup arrays for PrimType name Strings
72 *----------------------------------------------------------------------------*/
73extern const char *CsrWifiSmeApUpstreamPrimNames[CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT];
74extern const char *CsrWifiSmeApDownstreamPrimNames[CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT];
75
76/*******************************************************************************
77
78 NAME
79 CsrWifiSmeApActiveBaGetReqSend
80
81 DESCRIPTION
82 This primitive used to retrieve information related to the active block
83 ack sessions
84
85 PARAMETERS
86 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
87 interfaceTag -
88
89*******************************************************************************/
90#define CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__) \
91 msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetReq), GFP_KERNEL); \
92 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ, dst__, src__); \
93 msg__->interfaceTag = (interfaceTag__);
94
95#define CsrWifiSmeApActiveBaGetReqSendTo(dst__, src__, interfaceTag__) \
96 { \
97 CsrWifiSmeApActiveBaGetReq *msg__; \
98 CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__); \
99 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
100 }
101
102#define CsrWifiSmeApActiveBaGetReqSend(src__, interfaceTag__) \
103 CsrWifiSmeApActiveBaGetReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
104
105/*******************************************************************************
106
107 NAME
108 CsrWifiSmeApActiveBaGetCfmSend
109
110 DESCRIPTION
111 This primitive carries the information related to the active ba sessions
112
113 PARAMETERS
114 queue - Destination Task Queue
115 interfaceTag -
116 status - Reports the result of the request
117 activeBaCount - Number of active block ack session
118 activeBaSessions - Points to a buffer containing an array of
119 CsrWifiSmeApBaSession structures.
120
121*******************************************************************************/
122#define CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
123 msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetCfm), GFP_KERNEL); \
124 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM, dst__, src__); \
125 msg__->interfaceTag = (interfaceTag__); \
126 msg__->status = (status__); \
127 msg__->activeBaCount = (activeBaCount__); \
128 msg__->activeBaSessions = (activeBaSessions__);
129
130#define CsrWifiSmeApActiveBaGetCfmSendTo(dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
131 { \
132 CsrWifiSmeApActiveBaGetCfm *msg__; \
133 CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__); \
134 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
135 }
136
137#define CsrWifiSmeApActiveBaGetCfmSend(dst__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
138 CsrWifiSmeApActiveBaGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, activeBaCount__, activeBaSessions__)
139
140/*******************************************************************************
141
142 NAME
143 CsrWifiSmeApBaDeleteReqSend
144
145 DESCRIPTION
146 This primitive is used to delete an active block ack session
147
148 PARAMETERS
149 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
150 interfaceTag -
151 reason -
152 baSession - BA session to be deleted
153
154*******************************************************************************/
155#define CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__) \
156 msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteReq), GFP_KERNEL); \
157 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_REQ, dst__, src__); \
158 msg__->interfaceTag = (interfaceTag__); \
159 msg__->reason = (reason__); \
160 msg__->baSession = (baSession__);
161
162#define CsrWifiSmeApBaDeleteReqSendTo(dst__, src__, interfaceTag__, reason__, baSession__) \
163 { \
164 CsrWifiSmeApBaDeleteReq *msg__; \
165 CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__); \
166 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
167 }
168
169#define CsrWifiSmeApBaDeleteReqSend(src__, interfaceTag__, reason__, baSession__) \
170 CsrWifiSmeApBaDeleteReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, reason__, baSession__)
171
172/*******************************************************************************
173
174 NAME
175 CsrWifiSmeApBaDeleteCfmSend
176
177 DESCRIPTION
178 This primitive confirms the BA is deleted
179
180 PARAMETERS
181 queue - Destination Task Queue
182 interfaceTag -
183 status - Reports the result of the request
184 baSession - deleted BA session
185
186*******************************************************************************/
187#define CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__) \
188 msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteCfm), GFP_KERNEL); \
189 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_CFM, dst__, src__); \
190 msg__->interfaceTag = (interfaceTag__); \
191 msg__->status = (status__); \
192 msg__->baSession = (baSession__);
193
194#define CsrWifiSmeApBaDeleteCfmSendTo(dst__, src__, interfaceTag__, status__, baSession__) \
195 { \
196 CsrWifiSmeApBaDeleteCfm *msg__; \
197 CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__); \
198 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
199 }
200
201#define CsrWifiSmeApBaDeleteCfmSend(dst__, interfaceTag__, status__, baSession__) \
202 CsrWifiSmeApBaDeleteCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, baSession__)
203
204/*******************************************************************************
205
206 NAME
207 CsrWifiSmeApBeaconingStartReqSend
208
209 DESCRIPTION
210 This primitive requests the SME to start AP or GO functionality
211
212 PARAMETERS
213 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
214 interfaceTag -
215 initialPresence - Set to 0, if Not in a group fomration phase, set to 1 ,
216 during group formation phase
217 apType - apType : Legacy AP or P2PGO
218 cloakSsid - cloakSsid flag.
219 ssid - ssid.
220 ifIndex - Radio Interface
221 channel - channel.
222 maxConnections - Maximum Stations + P2PClients allowed
223 apCredentials - AP security credeitals used to advertise in beacon /probe
224 response
225 smeApConfig - AP configuration
226 p2pGoParam - P2P specific GO parameters. Ignored if it is a leagacy AP
227
228*******************************************************************************/
229#define CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
230 msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartReq), GFP_KERNEL); \
231 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_REQ, dst__, src__); \
232 msg__->interfaceTag = (interfaceTag__); \
233 msg__->initialPresence = (initialPresence__); \
234 msg__->apType = (apType__); \
235 msg__->cloakSsid = (cloakSsid__); \
236 msg__->ssid = (ssid__); \
237 msg__->ifIndex = (ifIndex__); \
238 msg__->channel = (channel__); \
239 msg__->maxConnections = (maxConnections__); \
240 msg__->apCredentials = (apCredentials__); \
241 msg__->smeApConfig = (smeApConfig__); \
242 msg__->p2pGoParam = (p2pGoParam__);
243
244#define CsrWifiSmeApBeaconingStartReqSendTo(dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
245 { \
246 CsrWifiSmeApBeaconingStartReq *msg__; \
247 CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__); \
248 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
249 }
250
251#define CsrWifiSmeApBeaconingStartReqSend(src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
252 CsrWifiSmeApBeaconingStartReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__)
253
254/*******************************************************************************
255
256 NAME
257 CsrWifiSmeApBeaconingStartCfmSend
258
259 DESCRIPTION
260 This primitive confirms the completion of the request along with the
261 status
262
263 PARAMETERS
264 queue - Destination Task Queue
265 interfaceTag -
266 status -
267 secIeLength -
268 secIe -
269
270*******************************************************************************/
271#define CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \
272 msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartCfm), GFP_KERNEL); \
273 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_CFM, dst__, src__); \
274 msg__->interfaceTag = (interfaceTag__); \
275 msg__->status = (status__); \
276 msg__->secIeLength = (secIeLength__); \
277 msg__->secIe = (secIe__);
278
279#define CsrWifiSmeApBeaconingStartCfmSendTo(dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \
280 { \
281 CsrWifiSmeApBeaconingStartCfm *msg__; \
282 CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__); \
283 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
284 }
285
286#define CsrWifiSmeApBeaconingStartCfmSend(dst__, interfaceTag__, status__, secIeLength__, secIe__) \
287 CsrWifiSmeApBeaconingStartCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, secIeLength__, secIe__)
288
289/*******************************************************************************
290
291 NAME
292 CsrWifiSmeApBeaconingStopReqSend
293
294 DESCRIPTION
295 This primitive requests the SME to STOP AP or P2PGO operation
296
297 PARAMETERS
298 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
299 interfaceTag -
300
301*******************************************************************************/
302#define CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__) \
303 msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopReq), GFP_KERNEL); \
304 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_REQ, dst__, src__); \
305 msg__->interfaceTag = (interfaceTag__);
306
307#define CsrWifiSmeApBeaconingStopReqSendTo(dst__, src__, interfaceTag__) \
308 { \
309 CsrWifiSmeApBeaconingStopReq *msg__; \
310 CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__); \
311 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
312 }
313
314#define CsrWifiSmeApBeaconingStopReqSend(src__, interfaceTag__) \
315 CsrWifiSmeApBeaconingStopReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
316
317/*******************************************************************************
318
319 NAME
320 CsrWifiSmeApBeaconingStopCfmSend
321
322 DESCRIPTION
323 This primitive confirms AP or P2PGO operation is terminated
324
325 PARAMETERS
326 queue - Destination Task Queue
327 interfaceTag -
328 status -
329
330*******************************************************************************/
331#define CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
332 msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopCfm), GFP_KERNEL); \
333 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_CFM, dst__, src__); \
334 msg__->interfaceTag = (interfaceTag__); \
335 msg__->status = (status__);
336
337#define CsrWifiSmeApBeaconingStopCfmSendTo(dst__, src__, interfaceTag__, status__) \
338 { \
339 CsrWifiSmeApBeaconingStopCfm *msg__; \
340 CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
341 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
342 }
343
344#define CsrWifiSmeApBeaconingStopCfmSend(dst__, interfaceTag__, status__) \
345 CsrWifiSmeApBeaconingStopCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
346
347/*******************************************************************************
348
349 NAME
350 CsrWifiSmeApErrorIndSend
351
352 DESCRIPTION
353 This primitve is sent by SME to indicate some error in AP operationi
354 after AP operations were started successfully and continuing the AP
355 operation may lead to undesired behaviour. It is the responsibility of
356 the upper layers to stop AP operation if needed
357
358 PARAMETERS
359 queue - Destination Task Queue
360 interfaceTag - Range 0-1
361 apType -
362 status - Contains the error status
363
364*******************************************************************************/
365#define CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \
366 msg__ = kmalloc(sizeof(CsrWifiSmeApErrorInd), GFP_KERNEL); \
367 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ERROR_IND, dst__, src__); \
368 msg__->interfaceTag = (interfaceTag__); \
369 msg__->apType = (apType__); \
370 msg__->status = (status__);
371
372#define CsrWifiSmeApErrorIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \
373 { \
374 CsrWifiSmeApErrorInd *msg__; \
375 CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \
376 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
377 }
378
379#define CsrWifiSmeApErrorIndSend(dst__, interfaceTag__, apType__, status__) \
380 CsrWifiSmeApErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, apType__, status__)
381
382/*******************************************************************************
383
384 NAME
385 CsrWifiSmeApStaConnectStartIndSend
386
387 DESCRIPTION
388 This primitive indicates that a stations request to join the group/BSS is
389 accepted
390
391 PARAMETERS
392 queue - Destination Task Queue
393 interfaceTag -
394 peerMacAddress -
395
396*******************************************************************************/
397#define CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__) \
398 msg__ = kmalloc(sizeof(CsrWifiSmeApStaConnectStartInd), GFP_KERNEL); \
399 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_CONNECT_START_IND, dst__, src__); \
400 msg__->interfaceTag = (interfaceTag__); \
401 msg__->peerMacAddress = (peerMacAddress__);
402
403#define CsrWifiSmeApStaConnectStartIndSendTo(dst__, src__, interfaceTag__, peerMacAddress__) \
404 { \
405 CsrWifiSmeApStaConnectStartInd *msg__; \
406 CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__); \
407 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
408 }
409
410#define CsrWifiSmeApStaConnectStartIndSend(dst__, interfaceTag__, peerMacAddress__) \
411 CsrWifiSmeApStaConnectStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, peerMacAddress__)
412
413/*******************************************************************************
414
415 NAME
416 CsrWifiSmeApStaDisconnectReqSend
417
418 DESCRIPTION
419 This primitive tells SME to deauth ot disassociate a particular station
420 within BSS
421
422 PARAMETERS
423 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
424 interfaceTag -
425 deauthReason -
426 disassocReason -
427 peerMacaddress -
428 keepBlocking - If TRUE, the station is blocked. If FALSE and the station
429 is connected, disconnect the station. If FALSE and the
430 station is not connected, no action is taken.
431
432*******************************************************************************/
433#define CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
434 msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectReq), GFP_KERNEL); \
435 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_REQ, dst__, src__); \
436 msg__->interfaceTag = (interfaceTag__); \
437 msg__->deauthReason = (deauthReason__); \
438 msg__->disassocReason = (disassocReason__); \
439 msg__->peerMacaddress = (peerMacaddress__); \
440 msg__->keepBlocking = (keepBlocking__);
441
442#define CsrWifiSmeApStaDisconnectReqSendTo(dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
443 { \
444 CsrWifiSmeApStaDisconnectReq *msg__; \
445 CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__); \
446 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
447 }
448
449#define CsrWifiSmeApStaDisconnectReqSend(src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
450 CsrWifiSmeApStaDisconnectReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__)
451
452/*******************************************************************************
453
454 NAME
455 CsrWifiSmeApStaDisconnectCfmSend
456
457 DESCRIPTION
458 This primitive confirms the station is disconnected
459
460 PARAMETERS
461 queue - Destination Task Queue
462 interfaceTag -
463 status -
464 peerMacaddress -
465
466*******************************************************************************/
467#define CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__) \
468 msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectCfm), GFP_KERNEL); \
469 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_CFM, dst__, src__); \
470 msg__->interfaceTag = (interfaceTag__); \
471 msg__->status = (status__); \
472 msg__->peerMacaddress = (peerMacaddress__);
473
474#define CsrWifiSmeApStaDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__, peerMacaddress__) \
475 { \
476 CsrWifiSmeApStaDisconnectCfm *msg__; \
477 CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__); \
478 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
479 }
480
481#define CsrWifiSmeApStaDisconnectCfmSend(dst__, interfaceTag__, status__, peerMacaddress__) \
482 CsrWifiSmeApStaDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, peerMacaddress__)
483
484/*******************************************************************************
485
486 NAME
487 CsrWifiSmeApStaNotifyIndSend
488
489 DESCRIPTION
490 This primitive indicates that a station has joined or a previously joined
491 station has left the BSS/group
492
493 PARAMETERS
494 queue - Destination Task Queue
495 interfaceTag -
496 mediaStatus -
497 peerMacAddress -
498 peerDeviceAddress -
499 disassocReason -
500 deauthReason -
501 WpsRegistration -
502 secIeLength -
503 secIe -
504 groupKeyId -
505 seqNumber -
506
507*******************************************************************************/
508#define CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
509 msg__ = kmalloc(sizeof(CsrWifiSmeApStaNotifyInd), GFP_KERNEL); \
510 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_NOTIFY_IND, dst__, src__); \
511 msg__->interfaceTag = (interfaceTag__); \
512 msg__->mediaStatus = (mediaStatus__); \
513 msg__->peerMacAddress = (peerMacAddress__); \
514 msg__->peerDeviceAddress = (peerDeviceAddress__); \
515 msg__->disassocReason = (disassocReason__); \
516 msg__->deauthReason = (deauthReason__); \
517 msg__->WpsRegistration = (WpsRegistration__); \
518 msg__->secIeLength = (secIeLength__); \
519 msg__->secIe = (secIe__); \
520 msg__->groupKeyId = (groupKeyId__); \
521 memcpy(msg__->seqNumber, (seqNumber__), sizeof(u16) * 8);
522
523#define CsrWifiSmeApStaNotifyIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
524 { \
525 CsrWifiSmeApStaNotifyInd *msg__; \
526 CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__); \
527 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
528 }
529
530#define CsrWifiSmeApStaNotifyIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
531 CsrWifiSmeApStaNotifyIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__)
532
533/*******************************************************************************
534
535 NAME
536 CsrWifiSmeApWmmParamUpdateReqSend
537
538 DESCRIPTION
539 Application uses this primitive to update the WMM parameters on the fly
540
541 PARAMETERS
542 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
543 interfaceTag -
544 wmmApParams - WMM parameters to be used for local firmware queue
545 configuration
546 wmmApBcParams - WMM parameters to be advertised in beacon/probe response
547
548*******************************************************************************/
549#define CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
550 msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateReq), GFP_KERNEL); \
551 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \
552 msg__->interfaceTag = (interfaceTag__); \
553 memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \
554 memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4);
555
556#define CsrWifiSmeApWmmParamUpdateReqSendTo(dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
557 { \
558 CsrWifiSmeApWmmParamUpdateReq *msg__; \
559 CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__); \
560 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
561 }
562
563#define CsrWifiSmeApWmmParamUpdateReqSend(src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
564 CsrWifiSmeApWmmParamUpdateReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, wmmApParams__, wmmApBcParams__)
565
566/*******************************************************************************
567
568 NAME
569 CsrWifiSmeApWmmParamUpdateCfmSend
570
571 DESCRIPTION
572 A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request
573
574 PARAMETERS
575 queue - Destination Task Queue
576 interfaceTag -
577 status -
578
579*******************************************************************************/
580#define CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
581 msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateCfm), GFP_KERNEL); \
582 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \
583 msg__->interfaceTag = (interfaceTag__); \
584 msg__->status = (status__);
585
586#define CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, src__, interfaceTag__, status__) \
587 { \
588 CsrWifiSmeApWmmParamUpdateCfm *msg__; \
589 CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
590 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
591 }
592
593#define CsrWifiSmeApWmmParamUpdateCfmSend(dst__, interfaceTag__, status__) \
594 CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
595
596/*******************************************************************************
597
598 NAME
599 CsrWifiSmeApWpsConfigurationReqSend
600
601 DESCRIPTION
602 This primitive passes the WPS information for the device to SME. This may
603 be accepted only if no interface is active.
604
605 PARAMETERS
606 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
607 wpsConfig - WPS config.
608
609*******************************************************************************/
610#define CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \
611 msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationReq), GFP_KERNEL); \
612 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ, dst__, src__); \
613 msg__->wpsConfig = (wpsConfig__);
614
615#define CsrWifiSmeApWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \
616 { \
617 CsrWifiSmeApWpsConfigurationReq *msg__; \
618 CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \
619 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
620 }
621
622#define CsrWifiSmeApWpsConfigurationReqSend(src__, wpsConfig__) \
623 CsrWifiSmeApWpsConfigurationReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, wpsConfig__)
624
625/*******************************************************************************
626
627 NAME
628 CsrWifiSmeApWpsConfigurationCfmSend
629
630 DESCRIPTION
631 Confirm.
632
633 PARAMETERS
634 queue - Destination Task Queue
635 status - Status of the request.
636
637*******************************************************************************/
638#define CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \
639 msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationCfm), GFP_KERNEL); \
640 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM, dst__, src__); \
641 msg__->status = (status__);
642
643#define CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, src__, status__) \
644 { \
645 CsrWifiSmeApWpsConfigurationCfm *msg__; \
646 CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \
647 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
648 }
649
650#define CsrWifiSmeApWpsConfigurationCfmSend(dst__, status__) \
651 CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
652
653/*******************************************************************************
654
655 NAME
656 CsrWifiSmeApWpsRegistrationFinishedReqSend
657
658 DESCRIPTION
659 This primitive tells SME that WPS registration procedure has finished
660
661 PARAMETERS
662 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
663 interfaceTag -
664
665*******************************************************************************/
666#define CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__) \
667 msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedReq), GFP_KERNEL); \
668 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ, dst__, src__); \
669 msg__->interfaceTag = (interfaceTag__);
670
671#define CsrWifiSmeApWpsRegistrationFinishedReqSendTo(dst__, src__, interfaceTag__) \
672 { \
673 CsrWifiSmeApWpsRegistrationFinishedReq *msg__; \
674 CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__); \
675 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
676 }
677
678#define CsrWifiSmeApWpsRegistrationFinishedReqSend(src__, interfaceTag__) \
679 CsrWifiSmeApWpsRegistrationFinishedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
680
681/*******************************************************************************
682
683 NAME
684 CsrWifiSmeApWpsRegistrationFinishedCfmSend
685
686 DESCRIPTION
687 A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request
688
689 PARAMETERS
690 queue - Destination Task Queue
691 interfaceTag -
692 status -
693
694*******************************************************************************/
695#define CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
696 msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedCfm), GFP_KERNEL); \
697 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM, dst__, src__); \
698 msg__->interfaceTag = (interfaceTag__); \
699 msg__->status = (status__);
700
701#define CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, src__, interfaceTag__, status__) \
702 { \
703 CsrWifiSmeApWpsRegistrationFinishedCfm *msg__; \
704 CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
705 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
706 }
707
708#define CsrWifiSmeApWpsRegistrationFinishedCfmSend(dst__, interfaceTag__, status__) \
709 CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
710
711/*******************************************************************************
712
713 NAME
714 CsrWifiSmeApWpsRegistrationStartedReqSend
715
716 DESCRIPTION
717 This primitive tells SME that WPS registration procedure has started
718
719 PARAMETERS
720 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
721 interfaceTag -
722 SelectedDevicePasswordId -
723 SelectedconfigMethod -
724
725*******************************************************************************/
726#define CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
727 msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedReq), GFP_KERNEL); \
728 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ, dst__, src__); \
729 msg__->interfaceTag = (interfaceTag__); \
730 msg__->SelectedDevicePasswordId = (SelectedDevicePasswordId__); \
731 msg__->SelectedconfigMethod = (SelectedconfigMethod__);
732
733#define CsrWifiSmeApWpsRegistrationStartedReqSendTo(dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
734 { \
735 CsrWifiSmeApWpsRegistrationStartedReq *msg__; \
736 CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__); \
737 CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
738 }
739
740#define CsrWifiSmeApWpsRegistrationStartedReqSend(src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
741 CsrWifiSmeApWpsRegistrationStartedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__)
742
743/*******************************************************************************
744
745 NAME
746 CsrWifiSmeApWpsRegistrationStartedCfmSend
747
748 DESCRIPTION
749 A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request
750
751 PARAMETERS
752 queue - Destination Task Queue
753 interfaceTag -
754 status -
755
756*******************************************************************************/
757#define CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
758 msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedCfm), GFP_KERNEL); \
759 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM, dst__, src__); \
760 msg__->interfaceTag = (interfaceTag__); \
761 msg__->status = (status__);
762
763#define CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, src__, interfaceTag__, status__) \
764 { \
765 CsrWifiSmeApWpsRegistrationStartedCfm *msg__; \
766 CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
767 CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
768 }
769
770#define CsrWifiSmeApWpsRegistrationStartedCfmSend(dst__, interfaceTag__, status__) \
771 CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
772
773
774#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
index 3c4bcbc16126..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_ap_prim.h
+++ /dev/null
@@ -1,1030 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_AP_PRIM_H__
14#define CSR_WIFI_SME_AP_PRIM_H__
15
16#include "csr_prim_defs.h"
17#include "csr_sched.h"
18#include "csr_wifi_common.h"
19#include "csr_result.h"
20#include "csr_wifi_fsm_event.h"
21#include "csr_wifi_sme_prim.h"
22
23#ifndef CSR_WIFI_AP_ENABLE
24#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_prim.h
25#endif
26
27#define CSR_WIFI_SME_AP_PRIM (0x0407)
28
29typedef CsrPrim CsrWifiSmeApPrim;
30
31
32/*******************************************************************************
33
34 NAME
35 CsrWifiSmeApAccessType
36
37 DESCRIPTION
38 Allow or deny STAs based on MAC address
39
40 VALUES
41 CSR_WIFI_AP_ACCESS_TYPE_NONE - None
42 CSR_WIFI_AP_ACCESS_TYPE_ALLOW - Allow only if MAC address is from the list
43 CSR_WIFI_AP_ACCESS_TYPE_DENY - Disallow if MAC address is from the list
44
45*******************************************************************************/
46typedef u8 CsrWifiSmeApAccessType;
47#define CSR_WIFI_AP_ACCESS_TYPE_NONE ((CsrWifiSmeApAccessType) 0x00)
48#define CSR_WIFI_AP_ACCESS_TYPE_ALLOW ((CsrWifiSmeApAccessType) 0x01)
49#define CSR_WIFI_AP_ACCESS_TYPE_DENY ((CsrWifiSmeApAccessType) 0x02)
50
51/*******************************************************************************
52
53 NAME
54 CsrWifiSmeApAuthSupport
55
56 DESCRIPTION
57 Define bits for AP authentication support
58
59 VALUES
60 CSR_WIFI_SME_RSN_AUTH_WPAPSK - RSN WPA-PSK Support
61 CSR_WIFI_SME_RSN_AUTH_WPA2PSK - RSN WPA2-PSK Support
62 CSR_WIFI_SME_AUTH_WAPIPSK - WAPI-PSK Support
63
64*******************************************************************************/
65typedef u8 CsrWifiSmeApAuthSupport;
66#define CSR_WIFI_SME_RSN_AUTH_WPAPSK ((CsrWifiSmeApAuthSupport) 0x01)
67#define CSR_WIFI_SME_RSN_AUTH_WPA2PSK ((CsrWifiSmeApAuthSupport) 0x02)
68#define CSR_WIFI_SME_AUTH_WAPIPSK ((CsrWifiSmeApAuthSupport) 0x04)
69
70/*******************************************************************************
71
72 NAME
73 CsrWifiSmeApAuthType
74
75 DESCRIPTION
76 Definition of the SME AP Authentication Options
77
78 VALUES
79 CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM
80 - Open authentication
81 CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL
82 - Personal authentication using a passphrase or a pre-shared
83 key.
84 CSR_WIFI_SME_AP_AUTH_TYPE_WEP
85 - WEP authentication. This can be either open or shared key
86
87*******************************************************************************/
88typedef u8 CsrWifiSmeApAuthType;
89#define CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM ((CsrWifiSmeApAuthType) 0x00)
90#define CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL ((CsrWifiSmeApAuthType) 0x01)
91#define CSR_WIFI_SME_AP_AUTH_TYPE_WEP ((CsrWifiSmeApAuthType) 0x02)
92
93/*******************************************************************************
94
95 NAME
96 CsrWifiSmeApDirection
97
98 DESCRIPTION
99 Definition of Direction
100
101 VALUES
102 CSR_WIFI_AP_DIRECTION_RECEIPIENT - Receipient
103 CSR_WIFI_AP_DIRECTION_ORIGINATOR - Originator
104
105*******************************************************************************/
106typedef u8 CsrWifiSmeApDirection;
107#define CSR_WIFI_AP_DIRECTION_RECEIPIENT ((CsrWifiSmeApDirection) 0x00)
108#define CSR_WIFI_AP_DIRECTION_ORIGINATOR ((CsrWifiSmeApDirection) 0x01)
109
110/*******************************************************************************
111
112 NAME
113 CsrWifiSmeApPhySupport
114
115 DESCRIPTION
116 Define bits for CsrWifiSmeApPhySupportMask
117
118 VALUES
119 CSR_WIFI_SME_AP_PHY_SUPPORT_A - 802.11a. It is not supported in the current
120 release.
121 CSR_WIFI_SME_AP_PHY_SUPPORT_B - 802.11b
122 CSR_WIFI_SME_AP_PHY_SUPPORT_G - 802.11g
123 CSR_WIFI_SME_AP_PHY_SUPPORT_N - 802.11n
124
125*******************************************************************************/
126typedef u8 CsrWifiSmeApPhySupport;
127#define CSR_WIFI_SME_AP_PHY_SUPPORT_A ((CsrWifiSmeApPhySupport) 0x01)
128#define CSR_WIFI_SME_AP_PHY_SUPPORT_B ((CsrWifiSmeApPhySupport) 0x02)
129#define CSR_WIFI_SME_AP_PHY_SUPPORT_G ((CsrWifiSmeApPhySupport) 0x04)
130#define CSR_WIFI_SME_AP_PHY_SUPPORT_N ((CsrWifiSmeApPhySupport) 0x08)
131
132/*******************************************************************************
133
134 NAME
135 CsrWifiSmeApType
136
137 DESCRIPTION
138 Definition of AP types
139
140 VALUES
141 CSR_WIFI_AP_TYPE_LEGACY - Legacy AP
142 CSR_WIFI_AP_TYPE_P2P - P2P Group Owner(GO)
143
144*******************************************************************************/
145typedef u8 CsrWifiSmeApType;
146#define CSR_WIFI_AP_TYPE_LEGACY ((CsrWifiSmeApType) 0x00)
147#define CSR_WIFI_AP_TYPE_P2P ((CsrWifiSmeApType) 0x01)
148
149
150/*******************************************************************************
151
152 NAME
153 CsrWifiSmeApAuthSupportMask
154
155 DESCRIPTION
156 See CsrWifiSmeApAuthSupport for bit definitions
157
158*******************************************************************************/
159typedef u8 CsrWifiSmeApAuthSupportMask;
160/*******************************************************************************
161
162 NAME
163 CsrWifiSmeApPhySupportMask
164
165 DESCRIPTION
166 Mask type for use with the values defined by CsrWifiSmeApPhySupport
167
168*******************************************************************************/
169typedef u8 CsrWifiSmeApPhySupportMask;
170/*******************************************************************************
171
172 NAME
173 CsrWifiSmeApRsnCapabilities
174
175 DESCRIPTION
176 Set to 0 for the current release
177
178*******************************************************************************/
179typedef u16 CsrWifiSmeApRsnCapabilities;
180/*******************************************************************************
181
182 NAME
183 CsrWifiSmeApRsnCapabilitiesMask
184
185 DESCRIPTION
186 Mask type for use with the values defined by CsrWifiSmeApRsnCapabilities
187
188*******************************************************************************/
189typedef u16 CsrWifiSmeApRsnCapabilitiesMask;
190/*******************************************************************************
191
192 NAME
193 CsrWifiSmeApWapiCapabilities
194
195 DESCRIPTION
196 Ignored by the stack as WAPI is not supported for AP operations in the
197 current release
198
199*******************************************************************************/
200typedef u16 CsrWifiSmeApWapiCapabilities;
201/*******************************************************************************
202
203 NAME
204 CsrWifiSmeApWapiCapabilitiesMask
205
206 DESCRIPTION
207 Mask type for use with the values defined by CsrWifiSmeApWapiCapabilities
208
209*******************************************************************************/
210typedef u16 CsrWifiSmeApWapiCapabilitiesMask;
211
212
213/*******************************************************************************
214
215 NAME
216 CsrWifiSmeApHtParams
217
218 DESCRIPTION
219 Structure holding HT parameters
220
221 MEMBERS
222 greenfieldSupported - Indicates if the AP supports Htgreenfield operation
223 subject to the chip capability. If the chip does not
224 support Htgreenfield operation, this parameter will be
225 ignored.
226 NOTE: if shortGi20MHz is set to TRUE and the chip
227 supports short GI operation for 20MHz this field will
228 be be ignored and the AP will not support Htgreenfield
229 operation.
230 NOTE: This field is ignored by the Wi-Fi stack for the
231 current release. It implies that AP does not support
232 greenfield operation.
233 shortGi20MHz - Indicates if the AP support short GI operation for
234 20MHz subject to the chip capability.If the chip does
235 not support short GI for 20MHz, this parameter is
236 ignored
237 rxStbc - Support for STBC for receive. 0 => No support for STBC
238 , 1=> Use STBC for Rx
239 rifsModeAllowed - RIFS Mode is allowed to protect overlapping non-HT BSS
240 htProtection - Deprecated
241 dualCtsProtection - Dual CTS Protection enabled
242
243*******************************************************************************/
244typedef struct
245{
246 u8 greenfieldSupported;
247 u8 shortGi20MHz;
248 u8 rxStbc;
249 u8 rifsModeAllowed;
250 u8 htProtection;
251 u8 dualCtsProtection;
252} CsrWifiSmeApHtParams;
253
254/*******************************************************************************
255
256 NAME
257 CsrWifiSmeApP2pOperatingChanEntry
258
259 DESCRIPTION
260
261 MEMBERS
262 operatingClass - Channel operating class
263 operatingChannelCount - Number of channels in this entry
264 operatingChannel - List of channels
265
266*******************************************************************************/
267typedef struct
268{
269 u8 operatingClass;
270 u8 operatingChannelCount;
271 u8 *operatingChannel;
272} CsrWifiSmeApP2pOperatingChanEntry;
273
274/*******************************************************************************
275
276 NAME
277 CsrWifiSmeApP2pOperatingChanList
278
279 DESCRIPTION
280 This structure contains the lists of P2P operating channels
281
282 MEMBERS
283 country - Country
284 channelEntryListCount - Number of entries
285 channelEntryList - List of entries
286
287*******************************************************************************/
288typedef struct
289{
290 u8 country[3];
291 u8 channelEntryListCount;
292 CsrWifiSmeApP2pOperatingChanEntry *channelEntryList;
293} CsrWifiSmeApP2pOperatingChanList;
294
295/*******************************************************************************
296
297 NAME
298 CsrWifiSmeApAuthPers
299
300 DESCRIPTION
301
302 MEMBERS
303 authSupport -
304 encryptionModeMask -
305 rsnCapabilities -
306 wapiCapabilities -
307
308*******************************************************************************/
309typedef struct
310{
311 CsrWifiSmeApAuthSupportMask authSupport;
312 CsrWifiSmeEncryptionMask encryptionModeMask;
313 CsrWifiSmeApRsnCapabilitiesMask rsnCapabilities;
314 CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities;
315} CsrWifiSmeApAuthPers;
316
317/*******************************************************************************
318
319 NAME
320 CsrWifiSmeApBaSession
321
322 DESCRIPTION
323
324 MEMBERS
325 peerMacAddress - Indicates MAC address of the peer station
326 tid - Specifies the TID of the MSDUs for which this Block Ack has
327 been set up. Range: 0-15
328 direction - Specifies if the AP is the originator or the recipient of
329 the data stream that uses the Block Ack.
330
331*******************************************************************************/
332typedef struct
333{
334 CsrWifiMacAddress peerMacAddress;
335 u8 tid;
336 CsrWifiSmeApDirection direction;
337} CsrWifiSmeApBaSession;
338
339/*******************************************************************************
340
341 NAME
342 CsrWifiSmeApMacConfig
343
344 DESCRIPTION
345 Structure holding AP MAC configuration.
346
347 MEMBERS
348 phySupportedBitmap - Indicates supported physical layers
349 beaconInterval - Beacon interval in terms of TUs
350 dtimPeriod - DTIM period in terms of number of beacon intervals
351 maxListenInterval - Maximum allowed listen interval as number of beacon
352 intervals
353 supportedRatesCount - Number of supported rates. Range : 0 to 20
354 supportedRates - List of supportedRates. A rate is specied in the
355 units of 500kbps. An entry for a basic rate shall
356 have the MSB set to 1.
357 preamble - Preamble to be advertised in beacons and probe
358 responses
359 shortSlotTimeEnabled - TRUE indicates the AP shall use short slot time if
360 all the stations use short slot operation.
361 ctsProtectionType - CTS protection to be used
362 wmmEnabled - Indicate whether WMM is enabled or not. If set to
363 FALSE,the WMM parameters shall be ignored by the
364 receiver.
365 wmmApParams - WMM parameters to be used for local firmware queue
366 configuration. Array index corresponds to the ACI.
367 wmmApBcParams - WMM parameters to be advertised in beacon/probe
368 response. Array index corresponds to the ACI
369 accessType - Specifies whether the MAC addresses from the list
370 should be allowed or denied
371 macAddressListCount - Number of MAC addresses
372 macAddressList - List of MAC addresses
373 apHtParams - AP HT parameters. The stack shall use these
374 parameters only if phySupportedBitmap indicates
375 support for IEEE 802.11n
376
377*******************************************************************************/
378typedef struct
379{
380 CsrWifiSmeApPhySupportMask phySupportedBitmap;
381 u16 beaconInterval;
382 u8 dtimPeriod;
383 u16 maxListenInterval;
384 u8 supportedRatesCount;
385 u8 supportedRates[20];
386 CsrWifiSmePreambleType preamble;
387 u8 shortSlotTimeEnabled;
388 CsrWifiSmeCtsProtectionType ctsProtectionType;
389 u8 wmmEnabled;
390 CsrWifiSmeWmmAcParams wmmApParams[4];
391 CsrWifiSmeWmmAcParams wmmApBcParams[4];
392 CsrWifiSmeApAccessType accessType;
393 u8 macAddressListCount;
394 CsrWifiMacAddress *macAddressList;
395 CsrWifiSmeApHtParams apHtParams;
396} CsrWifiSmeApMacConfig;
397
398/*******************************************************************************
399
400 NAME
401 CsrWifiSmeApP2pGoConfig
402
403 DESCRIPTION
404
405 MEMBERS
406 groupCapability - Indicates the P2P group capabilities
407 operatingChanList - List of operating channels in the order of
408 decreasing priority. It may contain channel
409 entry/entries not supported by the wifi stack.
410 These shall be filtered out by the wifi stack
411 opPsEnabled - Indicates whether opportunistic power save can
412 be used.
413 Note: This parameter is ignored by the WiFi
414 stack for the current release
415 ctWindow - Define Client Traffic window to be used in terms
416 of number of TUs. Range: 0 to 127.
417 Note: This parameter is ignored by the WiFi
418 stack for the current release.
419 noaConfigMethod - Notice of Absence configuration method.
420 Note: This parameter is ignored by the WiFi
421 stack for the current release.
422 allowNoaWithNonP2pDevices - Indicates if NOA should be allowed if non P2P
423 devices are connected. If allowed the non P2P
424 devices may suffer in throughput.
425 Note: This parameter is ignored by the WiFi
426 stack for the current release.
427
428*******************************************************************************/
429typedef struct
430{
431 CsrWifiSmeP2pGroupCapabilityMask groupCapability;
432 CsrWifiSmeApP2pOperatingChanList operatingChanList;
433 u8 opPsEnabled;
434 u8 ctWindow;
435 CsrWifiSmeP2pNoaConfigMethod noaConfigMethod;
436 u8 allowNoaWithNonP2pDevices;
437} CsrWifiSmeApP2pGoConfig;
438
439/*******************************************************************************
440
441 NAME
442 CsrWifiSmeApCredentials
443
444 DESCRIPTION
445
446 MEMBERS
447 authType -
448 smeAuthType -
449 smeAuthTypeopenSystemEmpty -
450 smeAuthTypeauthwep -
451 smeAuthTypeauthPers -
452
453*******************************************************************************/
454typedef struct
455{
456 CsrWifiSmeApAuthType authType;
457 union {
458 CsrWifiSmeEmpty openSystemEmpty;
459 CsrWifiSmeWepAuth authwep;
460 CsrWifiSmeApAuthPers authPers;
461 } smeAuthType;
462} CsrWifiSmeApCredentials;
463
464/*******************************************************************************
465
466 NAME
467 CsrWifiSmeApSecConfig
468
469 DESCRIPTION
470
471 MEMBERS
472 apCredentials -
473 wpsEnabled -
474
475*******************************************************************************/
476typedef struct
477{
478 CsrWifiSmeApCredentials apCredentials;
479 u8 wpsEnabled;
480} CsrWifiSmeApSecConfig;
481
482
483/* Downstream */
484#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST (0x0000)
485
486#define CSR_WIFI_SME_AP_BEACONING_START_REQ ((CsrWifiSmeApPrim) (0x0000 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
487#define CSR_WIFI_SME_AP_BEACONING_STOP_REQ ((CsrWifiSmeApPrim) (0x0001 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
488#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ ((CsrWifiSmeApPrim) (0x0002 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
489#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ ((CsrWifiSmeApPrim) (0x0003 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
490#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ ((CsrWifiSmeApPrim) (0x0004 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
491#define CSR_WIFI_SME_AP_STA_DISCONNECT_REQ ((CsrWifiSmeApPrim) (0x0005 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
492#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ ((CsrWifiSmeApPrim) (0x0006 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
493#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ ((CsrWifiSmeApPrim) (0x0007 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
494#define CSR_WIFI_SME_AP_BA_DELETE_REQ ((CsrWifiSmeApPrim) (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
495
496
497#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)
498
499/* Upstream */
500#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
501
502#define CSR_WIFI_SME_AP_BEACONING_START_CFM ((CsrWifiSmeApPrim)(0x0000 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
503#define CSR_WIFI_SME_AP_BEACONING_STOP_CFM ((CsrWifiSmeApPrim)(0x0001 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
504#define CSR_WIFI_SME_AP_STA_NOTIFY_IND ((CsrWifiSmeApPrim)(0x0002 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
505#define CSR_WIFI_SME_AP_STA_CONNECT_START_IND ((CsrWifiSmeApPrim)(0x0003 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
506#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM ((CsrWifiSmeApPrim)(0x0004 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
507#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM ((CsrWifiSmeApPrim)(0x0005 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
508#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM ((CsrWifiSmeApPrim)(0x0006 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
509#define CSR_WIFI_SME_AP_STA_DISCONNECT_CFM ((CsrWifiSmeApPrim)(0x0007 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
510#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM ((CsrWifiSmeApPrim)(0x0008 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
511#define CSR_WIFI_SME_AP_ERROR_IND ((CsrWifiSmeApPrim)(0x0009 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
512#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM ((CsrWifiSmeApPrim)(0x000A + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
513#define CSR_WIFI_SME_AP_BA_DELETE_CFM ((CsrWifiSmeApPrim)(0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
514
515#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST (0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)
516
517#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)
518#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT (CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)
519
520/*******************************************************************************
521
522 NAME
523 CsrWifiSmeApBeaconingStartReq
524
525 DESCRIPTION
526 This primitive requests the SME to start AP or GO functionality
527
528 MEMBERS
529 common - Common header for use with the CsrWifiFsm Module
530 interfaceTag -
531 initialPresence - Set to 0, if Not in a group fomration phase, set to 1 ,
532 during group formation phase
533 apType - apType : Legacy AP or P2PGO
534 cloakSsid - cloakSsid flag.
535 ssid - ssid.
536 ifIndex - Radio Interface
537 channel - channel.
538 maxConnections - Maximum Stations + P2PClients allowed
539 apCredentials - AP security credeitals used to advertise in beacon /probe
540 response
541 smeApConfig - AP configuration
542 p2pGoParam - P2P specific GO parameters. Ignored if it is a leagacy AP
543
544*******************************************************************************/
545typedef struct
546{
547 CsrWifiFsmEvent common;
548 u16 interfaceTag;
549 u8 initialPresence;
550 CsrWifiSmeApType apType;
551 u8 cloakSsid;
552 CsrWifiSsid ssid;
553 CsrWifiSmeRadioIF ifIndex;
554 u8 channel;
555 u8 maxConnections;
556 CsrWifiSmeApSecConfig apCredentials;
557 CsrWifiSmeApMacConfig smeApConfig;
558 CsrWifiSmeApP2pGoConfig p2pGoParam;
559} CsrWifiSmeApBeaconingStartReq;
560
561/*******************************************************************************
562
563 NAME
564 CsrWifiSmeApBeaconingStopReq
565
566 DESCRIPTION
567 This primitive requests the SME to STOP AP or P2PGO operation
568
569 MEMBERS
570 common - Common header for use with the CsrWifiFsm Module
571 interfaceTag -
572
573*******************************************************************************/
574typedef struct
575{
576 CsrWifiFsmEvent common;
577 u16 interfaceTag;
578} CsrWifiSmeApBeaconingStopReq;
579
580/*******************************************************************************
581
582 NAME
583 CsrWifiSmeApWpsRegistrationStartedReq
584
585 DESCRIPTION
586 This primitive tells SME that WPS registration procedure has started
587
588 MEMBERS
589 common - Common header for use with the CsrWifiFsm Module
590 interfaceTag -
591 SelectedDevicePasswordId -
592 SelectedconfigMethod -
593
594*******************************************************************************/
595typedef struct
596{
597 CsrWifiFsmEvent common;
598 u16 interfaceTag;
599 CsrWifiSmeWpsDpid SelectedDevicePasswordId;
600 CsrWifiSmeWpsConfigType SelectedconfigMethod;
601} CsrWifiSmeApWpsRegistrationStartedReq;
602
603/*******************************************************************************
604
605 NAME
606 CsrWifiSmeApWpsRegistrationFinishedReq
607
608 DESCRIPTION
609 This primitive tells SME that WPS registration procedure has finished
610
611 MEMBERS
612 common - Common header for use with the CsrWifiFsm Module
613 interfaceTag -
614
615*******************************************************************************/
616typedef struct
617{
618 CsrWifiFsmEvent common;
619 u16 interfaceTag;
620} CsrWifiSmeApWpsRegistrationFinishedReq;
621
622/*******************************************************************************
623
624 NAME
625 CsrWifiSmeApWmmParamUpdateReq
626
627 DESCRIPTION
628 Application uses this primitive to update the WMM parameters on the fly
629
630 MEMBERS
631 common - Common header for use with the CsrWifiFsm Module
632 interfaceTag -
633 wmmApParams - WMM parameters to be used for local firmware queue
634 configuration
635 wmmApBcParams - WMM parameters to be advertised in beacon/probe response
636
637*******************************************************************************/
638typedef struct
639{
640 CsrWifiFsmEvent common;
641 u16 interfaceTag;
642 CsrWifiSmeWmmAcParams wmmApParams[4];
643 CsrWifiSmeWmmAcParams wmmApBcParams[4];
644} CsrWifiSmeApWmmParamUpdateReq;
645
646/*******************************************************************************
647
648 NAME
649 CsrWifiSmeApStaDisconnectReq
650
651 DESCRIPTION
652 This primitive tells SME to deauth ot disassociate a particular station
653 within BSS
654
655 MEMBERS
656 common - Common header for use with the CsrWifiFsm Module
657 interfaceTag -
658 deauthReason -
659 disassocReason -
660 peerMacaddress -
661 keepBlocking - If TRUE, the station is blocked. If FALSE and the station
662 is connected, disconnect the station. If FALSE and the
663 station is not connected, no action is taken.
664
665*******************************************************************************/
666typedef struct
667{
668 CsrWifiFsmEvent common;
669 u16 interfaceTag;
670 CsrWifiSmeIEEE80211Reason deauthReason;
671 CsrWifiSmeIEEE80211Reason disassocReason;
672 CsrWifiMacAddress peerMacaddress;
673 u8 keepBlocking;
674} CsrWifiSmeApStaDisconnectReq;
675
676/*******************************************************************************
677
678 NAME
679 CsrWifiSmeApWpsConfigurationReq
680
681 DESCRIPTION
682 This primitive passes the WPS information for the device to SME. This may
683 be accepted only if no interface is active.
684
685 MEMBERS
686 common - Common header for use with the CsrWifiFsm Module
687 wpsConfig - WPS config.
688
689*******************************************************************************/
690typedef struct
691{
692 CsrWifiFsmEvent common;
693 CsrWifiSmeWpsConfig wpsConfig;
694} CsrWifiSmeApWpsConfigurationReq;
695
696/*******************************************************************************
697
698 NAME
699 CsrWifiSmeApActiveBaGetReq
700
701 DESCRIPTION
702 This primitive used to retrieve information related to the active block
703 ack sessions
704
705 MEMBERS
706 common - Common header for use with the CsrWifiFsm Module
707 interfaceTag -
708
709*******************************************************************************/
710typedef struct
711{
712 CsrWifiFsmEvent common;
713 u16 interfaceTag;
714} CsrWifiSmeApActiveBaGetReq;
715
716/*******************************************************************************
717
718 NAME
719 CsrWifiSmeApBaDeleteReq
720
721 DESCRIPTION
722 This primitive is used to delete an active block ack session
723
724 MEMBERS
725 common - Common header for use with the CsrWifiFsm Module
726 interfaceTag -
727 reason -
728 baSession - BA session to be deleted
729
730*******************************************************************************/
731typedef struct
732{
733 CsrWifiFsmEvent common;
734 u16 interfaceTag;
735 CsrWifiSmeIEEE80211Reason reason;
736 CsrWifiSmeApBaSession baSession;
737} CsrWifiSmeApBaDeleteReq;
738
739/*******************************************************************************
740
741 NAME
742 CsrWifiSmeApBeaconingStartCfm
743
744 DESCRIPTION
745 This primitive confirms the completion of the request along with the
746 status
747
748 MEMBERS
749 common - Common header for use with the CsrWifiFsm Module
750 interfaceTag -
751 status -
752 secIeLength -
753 secIe -
754
755*******************************************************************************/
756typedef struct
757{
758 CsrWifiFsmEvent common;
759 u16 interfaceTag;
760 CsrResult status;
761 u16 secIeLength;
762 u8 *secIe;
763} CsrWifiSmeApBeaconingStartCfm;
764
765/*******************************************************************************
766
767 NAME
768 CsrWifiSmeApBeaconingStopCfm
769
770 DESCRIPTION
771 This primitive confirms AP or P2PGO operation is terminated
772
773 MEMBERS
774 common - Common header for use with the CsrWifiFsm Module
775 interfaceTag -
776 status -
777
778*******************************************************************************/
779typedef struct
780{
781 CsrWifiFsmEvent common;
782 u16 interfaceTag;
783 CsrResult status;
784} CsrWifiSmeApBeaconingStopCfm;
785
786/*******************************************************************************
787
788 NAME
789 CsrWifiSmeApStaNotifyInd
790
791 DESCRIPTION
792 This primitive indicates that a station has joined or a previously joined
793 station has left the BSS/group
794
795 MEMBERS
796 common - Common header for use with the CsrWifiFsm Module
797 interfaceTag -
798 mediaStatus -
799 peerMacAddress -
800 peerDeviceAddress -
801 disassocReason -
802 deauthReason -
803 WpsRegistration -
804 secIeLength -
805 secIe -
806 groupKeyId -
807 seqNumber -
808
809*******************************************************************************/
810typedef struct
811{
812 CsrWifiFsmEvent common;
813 u16 interfaceTag;
814 CsrWifiSmeMediaStatus mediaStatus;
815 CsrWifiMacAddress peerMacAddress;
816 CsrWifiMacAddress peerDeviceAddress;
817 CsrWifiSmeIEEE80211Reason disassocReason;
818 CsrWifiSmeIEEE80211Reason deauthReason;
819 CsrWifiSmeWpsRegistration WpsRegistration;
820 u8 secIeLength;
821 u8 *secIe;
822 u8 groupKeyId;
823 u16 seqNumber[8];
824} CsrWifiSmeApStaNotifyInd;
825
826/*******************************************************************************
827
828 NAME
829 CsrWifiSmeApStaConnectStartInd
830
831 DESCRIPTION
832 This primitive indicates that a stations request to join the group/BSS is
833 accepted
834
835 MEMBERS
836 common - Common header for use with the CsrWifiFsm Module
837 interfaceTag -
838 peerMacAddress -
839
840*******************************************************************************/
841typedef struct
842{
843 CsrWifiFsmEvent common;
844 u16 interfaceTag;
845 CsrWifiMacAddress peerMacAddress;
846} CsrWifiSmeApStaConnectStartInd;
847
848/*******************************************************************************
849
850 NAME
851 CsrWifiSmeApWpsRegistrationStartedCfm
852
853 DESCRIPTION
854 A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request
855
856 MEMBERS
857 common - Common header for use with the CsrWifiFsm Module
858 interfaceTag -
859 status -
860
861*******************************************************************************/
862typedef struct
863{
864 CsrWifiFsmEvent common;
865 u16 interfaceTag;
866 CsrResult status;
867} CsrWifiSmeApWpsRegistrationStartedCfm;
868
869/*******************************************************************************
870
871 NAME
872 CsrWifiSmeApWpsRegistrationFinishedCfm
873
874 DESCRIPTION
875 A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request
876
877 MEMBERS
878 common - Common header for use with the CsrWifiFsm Module
879 interfaceTag -
880 status -
881
882*******************************************************************************/
883typedef struct
884{
885 CsrWifiFsmEvent common;
886 u16 interfaceTag;
887 CsrResult status;
888} CsrWifiSmeApWpsRegistrationFinishedCfm;
889
890/*******************************************************************************
891
892 NAME
893 CsrWifiSmeApWmmParamUpdateCfm
894
895 DESCRIPTION
896 A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request
897
898 MEMBERS
899 common - Common header for use with the CsrWifiFsm Module
900 interfaceTag -
901 status -
902
903*******************************************************************************/
904typedef struct
905{
906 CsrWifiFsmEvent common;
907 u16 interfaceTag;
908 CsrResult status;
909} CsrWifiSmeApWmmParamUpdateCfm;
910
911/*******************************************************************************
912
913 NAME
914 CsrWifiSmeApStaDisconnectCfm
915
916 DESCRIPTION
917 This primitive confirms the station is disconnected
918
919 MEMBERS
920 common - Common header for use with the CsrWifiFsm Module
921 interfaceTag -
922 status -
923 peerMacaddress -
924
925*******************************************************************************/
926typedef struct
927{
928 CsrWifiFsmEvent common;
929 u16 interfaceTag;
930 CsrResult status;
931 CsrWifiMacAddress peerMacaddress;
932} CsrWifiSmeApStaDisconnectCfm;
933
934/*******************************************************************************
935
936 NAME
937 CsrWifiSmeApWpsConfigurationCfm
938
939 DESCRIPTION
940 Confirm.
941
942 MEMBERS
943 common - Common header for use with the CsrWifiFsm Module
944 status - Status of the request.
945
946*******************************************************************************/
947typedef struct
948{
949 CsrWifiFsmEvent common;
950 CsrResult status;
951} CsrWifiSmeApWpsConfigurationCfm;
952
953/*******************************************************************************
954
955 NAME
956 CsrWifiSmeApErrorInd
957
958 DESCRIPTION
959 This primitve is sent by SME to indicate some error in AP operationi
960 after AP operations were started successfully and continuing the AP
961 operation may lead to undesired behaviour. It is the responsibility of
962 the upper layers to stop AP operation if needed
963
964 MEMBERS
965 common - Common header for use with the CsrWifiFsm Module
966 interfaceTag - Range 0-1
967 apType -
968 status - Contains the error status
969
970*******************************************************************************/
971typedef struct
972{
973 CsrWifiFsmEvent common;
974 u16 interfaceTag;
975 CsrWifiSmeApType apType;
976 CsrResult status;
977} CsrWifiSmeApErrorInd;
978
979/*******************************************************************************
980
981 NAME
982 CsrWifiSmeApActiveBaGetCfm
983
984 DESCRIPTION
985 This primitive carries the information related to the active ba sessions
986
987 MEMBERS
988 common - Common header for use with the CsrWifiFsm Module
989 interfaceTag -
990 status - Reports the result of the request
991 activeBaCount - Number of active block ack session
992 activeBaSessions - Points to a buffer containing an array of
993 CsrWifiSmeApBaSession structures.
994
995*******************************************************************************/
996typedef struct
997{
998 CsrWifiFsmEvent common;
999 u16 interfaceTag;
1000 CsrResult status;
1001 u16 activeBaCount;
1002 CsrWifiSmeApBaSession *activeBaSessions;
1003} CsrWifiSmeApActiveBaGetCfm;
1004
1005/*******************************************************************************
1006
1007 NAME
1008 CsrWifiSmeApBaDeleteCfm
1009
1010 DESCRIPTION
1011 This primitive confirms the BA is deleted
1012
1013 MEMBERS
1014 common - Common header for use with the CsrWifiFsm Module
1015 interfaceTag -
1016 status - Reports the result of the request
1017 baSession - deleted BA session
1018
1019*******************************************************************************/
1020typedef struct
1021{
1022 CsrWifiFsmEvent common;
1023 u16 interfaceTag;
1024 CsrResult status;
1025 CsrWifiSmeApBaSession baSession;
1026} CsrWifiSmeApBaDeleteCfm;
1027
1028
1029#endif /* CSR_WIFI_SME_AP_PRIM_H__ */
1030
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
index 31835f06bbc2..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_converter_init.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#include "csr_msgconv.h"
14#include "csr_macro.h"
15
16
17#ifdef CSR_LOG_ENABLE
18#include "csr_log.h"
19#endif
20
21#ifndef EXCLUDE_CSR_WIFI_SME_MODULE
22#include "csr_wifi_sme_serialize.h"
23#include "csr_wifi_sme_prim.h"
24
25static CsrMsgConvMsgEntry csrwifisme_conv_lut[] = {
26 { CSR_WIFI_SME_ACTIVATE_REQ, CsrWifiSmeActivateReqSizeof, CsrWifiSmeActivateReqSer, CsrWifiSmeActivateReqDes, CsrWifiSmeActivateReqSerFree },
27 { CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, CsrWifiSmeAdhocConfigGetReqSizeof, CsrWifiSmeAdhocConfigGetReqSer, CsrWifiSmeAdhocConfigGetReqDes, CsrWifiSmeAdhocConfigGetReqSerFree },
28 { CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, CsrWifiSmeAdhocConfigSetReqSizeof, CsrWifiSmeAdhocConfigSetReqSer, CsrWifiSmeAdhocConfigSetReqDes, CsrWifiSmeAdhocConfigSetReqSerFree },
29 { CSR_WIFI_SME_BLACKLIST_REQ, CsrWifiSmeBlacklistReqSizeof, CsrWifiSmeBlacklistReqSer, CsrWifiSmeBlacklistReqDes, CsrWifiSmeBlacklistReqSerFree },
30 { CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, CsrWifiSmeCalibrationDataGetReqSizeof, CsrWifiSmeCalibrationDataGetReqSer, CsrWifiSmeCalibrationDataGetReqDes, CsrWifiSmeCalibrationDataGetReqSerFree },
31 { CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, CsrWifiSmeCalibrationDataSetReqSizeof, CsrWifiSmeCalibrationDataSetReqSer, CsrWifiSmeCalibrationDataSetReqDes, CsrWifiSmeCalibrationDataSetReqSerFree },
32 { CSR_WIFI_SME_CCX_CONFIG_GET_REQ, CsrWifiSmeCcxConfigGetReqSizeof, CsrWifiSmeCcxConfigGetReqSer, CsrWifiSmeCcxConfigGetReqDes, CsrWifiSmeCcxConfigGetReqSerFree },
33 { CSR_WIFI_SME_CCX_CONFIG_SET_REQ, CsrWifiSmeCcxConfigSetReqSizeof, CsrWifiSmeCcxConfigSetReqSer, CsrWifiSmeCcxConfigSetReqDes, CsrWifiSmeCcxConfigSetReqSerFree },
34 { CSR_WIFI_SME_COEX_CONFIG_GET_REQ, CsrWifiSmeCoexConfigGetReqSizeof, CsrWifiSmeCoexConfigGetReqSer, CsrWifiSmeCoexConfigGetReqDes, CsrWifiSmeCoexConfigGetReqSerFree },
35 { CSR_WIFI_SME_COEX_CONFIG_SET_REQ, CsrWifiSmeCoexConfigSetReqSizeof, CsrWifiSmeCoexConfigSetReqSer, CsrWifiSmeCoexConfigSetReqDes, CsrWifiSmeCoexConfigSetReqSerFree },
36 { CSR_WIFI_SME_COEX_INFO_GET_REQ, CsrWifiSmeCoexInfoGetReqSizeof, CsrWifiSmeCoexInfoGetReqSer, CsrWifiSmeCoexInfoGetReqDes, CsrWifiSmeCoexInfoGetReqSerFree },
37 { CSR_WIFI_SME_CONNECT_REQ, CsrWifiSmeConnectReqSizeof, CsrWifiSmeConnectReqSer, CsrWifiSmeConnectReqDes, CsrWifiSmeConnectReqSerFree },
38 { CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, CsrWifiSmeConnectionConfigGetReqSizeof, CsrWifiSmeConnectionConfigGetReqSer, CsrWifiSmeConnectionConfigGetReqDes, CsrWifiSmeConnectionConfigGetReqSerFree },
39 { CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, CsrWifiSmeConnectionInfoGetReqSizeof, CsrWifiSmeConnectionInfoGetReqSer, CsrWifiSmeConnectionInfoGetReqDes, CsrWifiSmeConnectionInfoGetReqSerFree },
40 { CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, CsrWifiSmeConnectionStatsGetReqSizeof, CsrWifiSmeConnectionStatsGetReqSer, CsrWifiSmeConnectionStatsGetReqDes, CsrWifiSmeConnectionStatsGetReqSerFree },
41 { CSR_WIFI_SME_DEACTIVATE_REQ, CsrWifiSmeDeactivateReqSizeof, CsrWifiSmeDeactivateReqSer, CsrWifiSmeDeactivateReqDes, CsrWifiSmeDeactivateReqSerFree },
42 { CSR_WIFI_SME_DISCONNECT_REQ, CsrWifiSmeDisconnectReqSizeof, CsrWifiSmeDisconnectReqSer, CsrWifiSmeDisconnectReqDes, CsrWifiSmeDisconnectReqSerFree },
43 { CSR_WIFI_SME_EVENT_MASK_SET_REQ, CsrWifiSmeEventMaskSetReqSizeof, CsrWifiSmeEventMaskSetReqSer, CsrWifiSmeEventMaskSetReqDes, CsrWifiSmeEventMaskSetReqSerFree },
44 { CSR_WIFI_SME_HOST_CONFIG_GET_REQ, CsrWifiSmeHostConfigGetReqSizeof, CsrWifiSmeHostConfigGetReqSer, CsrWifiSmeHostConfigGetReqDes, CsrWifiSmeHostConfigGetReqSerFree },
45 { CSR_WIFI_SME_HOST_CONFIG_SET_REQ, CsrWifiSmeHostConfigSetReqSizeof, CsrWifiSmeHostConfigSetReqSer, CsrWifiSmeHostConfigSetReqDes, CsrWifiSmeHostConfigSetReqSerFree },
46 { CSR_WIFI_SME_KEY_REQ, CsrWifiSmeKeyReqSizeof, CsrWifiSmeKeyReqSer, CsrWifiSmeKeyReqDes, CsrWifiSmeKeyReqSerFree },
47 { CSR_WIFI_SME_LINK_QUALITY_GET_REQ, CsrWifiSmeLinkQualityGetReqSizeof, CsrWifiSmeLinkQualityGetReqSer, CsrWifiSmeLinkQualityGetReqDes, CsrWifiSmeLinkQualityGetReqSerFree },
48 { CSR_WIFI_SME_MIB_CONFIG_GET_REQ, CsrWifiSmeMibConfigGetReqSizeof, CsrWifiSmeMibConfigGetReqSer, CsrWifiSmeMibConfigGetReqDes, CsrWifiSmeMibConfigGetReqSerFree },
49 { CSR_WIFI_SME_MIB_CONFIG_SET_REQ, CsrWifiSmeMibConfigSetReqSizeof, CsrWifiSmeMibConfigSetReqSer, CsrWifiSmeMibConfigSetReqDes, CsrWifiSmeMibConfigSetReqSerFree },
50 { CSR_WIFI_SME_MIB_GET_NEXT_REQ, CsrWifiSmeMibGetNextReqSizeof, CsrWifiSmeMibGetNextReqSer, CsrWifiSmeMibGetNextReqDes, CsrWifiSmeMibGetNextReqSerFree },
51 { CSR_WIFI_SME_MIB_GET_REQ, CsrWifiSmeMibGetReqSizeof, CsrWifiSmeMibGetReqSer, CsrWifiSmeMibGetReqDes, CsrWifiSmeMibGetReqSerFree },
52 { CSR_WIFI_SME_MIB_SET_REQ, CsrWifiSmeMibSetReqSizeof, CsrWifiSmeMibSetReqSer, CsrWifiSmeMibSetReqDes, CsrWifiSmeMibSetReqSerFree },
53 { CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, CsrWifiSmeMulticastAddressReqSizeof, CsrWifiSmeMulticastAddressReqSer, CsrWifiSmeMulticastAddressReqDes, CsrWifiSmeMulticastAddressReqSerFree },
54 { CSR_WIFI_SME_PACKET_FILTER_SET_REQ, CsrWifiSmePacketFilterSetReqSizeof, CsrWifiSmePacketFilterSetReqSer, CsrWifiSmePacketFilterSetReqDes, CsrWifiSmePacketFilterSetReqSerFree },
55 { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, CsrWifiSmePermanentMacAddressGetReqSizeof, CsrWifiSmePermanentMacAddressGetReqSer, CsrWifiSmePermanentMacAddressGetReqDes, CsrWifiSmePermanentMacAddressGetReqSerFree },
56 { CSR_WIFI_SME_PMKID_REQ, CsrWifiSmePmkidReqSizeof, CsrWifiSmePmkidReqSer, CsrWifiSmePmkidReqDes, CsrWifiSmePmkidReqSerFree },
57 { CSR_WIFI_SME_POWER_CONFIG_GET_REQ, CsrWifiSmePowerConfigGetReqSizeof, CsrWifiSmePowerConfigGetReqSer, CsrWifiSmePowerConfigGetReqDes, CsrWifiSmePowerConfigGetReqSerFree },
58 { CSR_WIFI_SME_POWER_CONFIG_SET_REQ, CsrWifiSmePowerConfigSetReqSizeof, CsrWifiSmePowerConfigSetReqSer, CsrWifiSmePowerConfigSetReqDes, CsrWifiSmePowerConfigSetReqSerFree },
59 { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, CsrWifiSmeRegulatoryDomainInfoGetReqSizeof, CsrWifiSmeRegulatoryDomainInfoGetReqSer, CsrWifiSmeRegulatoryDomainInfoGetReqDes, CsrWifiSmeRegulatoryDomainInfoGetReqSerFree },
60 { CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, CsrWifiSmeRoamingConfigGetReqSizeof, CsrWifiSmeRoamingConfigGetReqSer, CsrWifiSmeRoamingConfigGetReqDes, CsrWifiSmeRoamingConfigGetReqSerFree },
61 { CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, CsrWifiSmeRoamingConfigSetReqSizeof, CsrWifiSmeRoamingConfigSetReqSer, CsrWifiSmeRoamingConfigSetReqDes, CsrWifiSmeRoamingConfigSetReqSerFree },
62 { CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, CsrWifiSmeScanConfigGetReqSizeof, CsrWifiSmeScanConfigGetReqSer, CsrWifiSmeScanConfigGetReqDes, CsrWifiSmeScanConfigGetReqSerFree },
63 { CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, CsrWifiSmeScanConfigSetReqSizeof, CsrWifiSmeScanConfigSetReqSer, CsrWifiSmeScanConfigSetReqDes, CsrWifiSmeScanConfigSetReqSerFree },
64 { CSR_WIFI_SME_SCAN_FULL_REQ, CsrWifiSmeScanFullReqSizeof, CsrWifiSmeScanFullReqSer, CsrWifiSmeScanFullReqDes, CsrWifiSmeScanFullReqSerFree },
65 { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, CsrWifiSmeScanResultsFlushReqSizeof, CsrWifiSmeScanResultsFlushReqSer, CsrWifiSmeScanResultsFlushReqDes, CsrWifiSmeScanResultsFlushReqSerFree },
66 { CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, CsrWifiSmeScanResultsGetReqSizeof, CsrWifiSmeScanResultsGetReqSer, CsrWifiSmeScanResultsGetReqDes, CsrWifiSmeScanResultsGetReqSerFree },
67 { CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, CsrWifiSmeSmeStaConfigGetReqSizeof, CsrWifiSmeSmeStaConfigGetReqSer, CsrWifiSmeSmeStaConfigGetReqDes, CsrWifiSmeSmeStaConfigGetReqSerFree },
68 { CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, CsrWifiSmeSmeStaConfigSetReqSizeof, CsrWifiSmeSmeStaConfigSetReqSer, CsrWifiSmeSmeStaConfigSetReqDes, CsrWifiSmeSmeStaConfigSetReqSerFree },
69 { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, CsrWifiSmeStationMacAddressGetReqSizeof, CsrWifiSmeStationMacAddressGetReqSer, CsrWifiSmeStationMacAddressGetReqDes, CsrWifiSmeStationMacAddressGetReqSerFree },
70 { CSR_WIFI_SME_TSPEC_REQ, CsrWifiSmeTspecReqSizeof, CsrWifiSmeTspecReqSer, CsrWifiSmeTspecReqDes, CsrWifiSmeTspecReqSerFree },
71 { CSR_WIFI_SME_VERSIONS_GET_REQ, CsrWifiSmeVersionsGetReqSizeof, CsrWifiSmeVersionsGetReqSer, CsrWifiSmeVersionsGetReqDes, CsrWifiSmeVersionsGetReqSerFree },
72 { CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, CsrWifiSmeWifiFlightmodeReqSizeof, CsrWifiSmeWifiFlightmodeReqSer, CsrWifiSmeWifiFlightmodeReqDes, CsrWifiSmeWifiFlightmodeReqSerFree },
73 { CSR_WIFI_SME_WIFI_OFF_REQ, CsrWifiSmeWifiOffReqSizeof, CsrWifiSmeWifiOffReqSer, CsrWifiSmeWifiOffReqDes, CsrWifiSmeWifiOffReqSerFree },
74 { CSR_WIFI_SME_WIFI_ON_REQ, CsrWifiSmeWifiOnReqSizeof, CsrWifiSmeWifiOnReqSer, CsrWifiSmeWifiOnReqDes, CsrWifiSmeWifiOnReqSerFree },
75 { CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, CsrWifiSmeCloakedSsidsSetReqSizeof, CsrWifiSmeCloakedSsidsSetReqSer, CsrWifiSmeCloakedSsidsSetReqDes, CsrWifiSmeCloakedSsidsSetReqSerFree },
76 { CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, CsrWifiSmeCloakedSsidsGetReqSizeof, CsrWifiSmeCloakedSsidsGetReqSer, CsrWifiSmeCloakedSsidsGetReqDes, CsrWifiSmeCloakedSsidsGetReqSerFree },
77 { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, CsrWifiSmeSmeCommonConfigGetReqSizeof, CsrWifiSmeSmeCommonConfigGetReqSer, CsrWifiSmeSmeCommonConfigGetReqDes, CsrWifiSmeSmeCommonConfigGetReqSerFree },
78 { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, CsrWifiSmeSmeCommonConfigSetReqSizeof, CsrWifiSmeSmeCommonConfigSetReqSer, CsrWifiSmeSmeCommonConfigSetReqDes, CsrWifiSmeSmeCommonConfigSetReqSerFree },
79 { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, CsrWifiSmeInterfaceCapabilityGetReqSizeof, CsrWifiSmeInterfaceCapabilityGetReqSer, CsrWifiSmeInterfaceCapabilityGetReqDes, CsrWifiSmeInterfaceCapabilityGetReqSerFree },
80 { CSR_WIFI_SME_WPS_CONFIGURATION_REQ, CsrWifiSmeWpsConfigurationReqSizeof, CsrWifiSmeWpsConfigurationReqSer, CsrWifiSmeWpsConfigurationReqDes, CsrWifiSmeWpsConfigurationReqSerFree },
81 { CSR_WIFI_SME_SET_REQ, CsrWifiSmeSetReqSizeof, CsrWifiSmeSetReqSer, CsrWifiSmeSetReqDes, CsrWifiSmeSetReqSerFree },
82 { CSR_WIFI_SME_ACTIVATE_CFM, CsrWifiSmeActivateCfmSizeof, CsrWifiSmeActivateCfmSer, CsrWifiSmeActivateCfmDes, CsrWifiSmeActivateCfmSerFree },
83 { CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, CsrWifiSmeAdhocConfigGetCfmSizeof, CsrWifiSmeAdhocConfigGetCfmSer, CsrWifiSmeAdhocConfigGetCfmDes, CsrWifiSmeAdhocConfigGetCfmSerFree },
84 { CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, CsrWifiSmeAdhocConfigSetCfmSizeof, CsrWifiSmeAdhocConfigSetCfmSer, CsrWifiSmeAdhocConfigSetCfmDes, CsrWifiSmeAdhocConfigSetCfmSerFree },
85 { CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, CsrWifiSmeAssociationCompleteIndSizeof, CsrWifiSmeAssociationCompleteIndSer, CsrWifiSmeAssociationCompleteIndDes, CsrWifiSmeAssociationCompleteIndSerFree },
86 { CSR_WIFI_SME_ASSOCIATION_START_IND, CsrWifiSmeAssociationStartIndSizeof, CsrWifiSmeAssociationStartIndSer, CsrWifiSmeAssociationStartIndDes, CsrWifiSmeAssociationStartIndSerFree },
87 { CSR_WIFI_SME_BLACKLIST_CFM, CsrWifiSmeBlacklistCfmSizeof, CsrWifiSmeBlacklistCfmSer, CsrWifiSmeBlacklistCfmDes, CsrWifiSmeBlacklistCfmSerFree },
88 { CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, CsrWifiSmeCalibrationDataGetCfmSizeof, CsrWifiSmeCalibrationDataGetCfmSer, CsrWifiSmeCalibrationDataGetCfmDes, CsrWifiSmeCalibrationDataGetCfmSerFree },
89 { CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, CsrWifiSmeCalibrationDataSetCfmSizeof, CsrWifiSmeCalibrationDataSetCfmSer, CsrWifiSmeCalibrationDataSetCfmDes, CsrWifiSmeCalibrationDataSetCfmSerFree },
90 { CSR_WIFI_SME_CCX_CONFIG_GET_CFM, CsrWifiSmeCcxConfigGetCfmSizeof, CsrWifiSmeCcxConfigGetCfmSer, CsrWifiSmeCcxConfigGetCfmDes, CsrWifiSmeCcxConfigGetCfmSerFree },
91 { CSR_WIFI_SME_CCX_CONFIG_SET_CFM, CsrWifiSmeCcxConfigSetCfmSizeof, CsrWifiSmeCcxConfigSetCfmSer, CsrWifiSmeCcxConfigSetCfmDes, CsrWifiSmeCcxConfigSetCfmSerFree },
92 { CSR_WIFI_SME_COEX_CONFIG_GET_CFM, CsrWifiSmeCoexConfigGetCfmSizeof, CsrWifiSmeCoexConfigGetCfmSer, CsrWifiSmeCoexConfigGetCfmDes, CsrWifiSmeCoexConfigGetCfmSerFree },
93 { CSR_WIFI_SME_COEX_CONFIG_SET_CFM, CsrWifiSmeCoexConfigSetCfmSizeof, CsrWifiSmeCoexConfigSetCfmSer, CsrWifiSmeCoexConfigSetCfmDes, CsrWifiSmeCoexConfigSetCfmSerFree },
94 { CSR_WIFI_SME_COEX_INFO_GET_CFM, CsrWifiSmeCoexInfoGetCfmSizeof, CsrWifiSmeCoexInfoGetCfmSer, CsrWifiSmeCoexInfoGetCfmDes, CsrWifiSmeCoexInfoGetCfmSerFree },
95 { CSR_WIFI_SME_CONNECT_CFM, CsrWifiSmeConnectCfmSizeof, CsrWifiSmeConnectCfmSer, CsrWifiSmeConnectCfmDes, CsrWifiSmeConnectCfmSerFree },
96 { CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, CsrWifiSmeConnectionConfigGetCfmSizeof, CsrWifiSmeConnectionConfigGetCfmSer, CsrWifiSmeConnectionConfigGetCfmDes, CsrWifiSmeConnectionConfigGetCfmSerFree },
97 { CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, CsrWifiSmeConnectionInfoGetCfmSizeof, CsrWifiSmeConnectionInfoGetCfmSer, CsrWifiSmeConnectionInfoGetCfmDes, CsrWifiSmeConnectionInfoGetCfmSerFree },
98 { CSR_WIFI_SME_CONNECTION_QUALITY_IND, CsrWifiSmeConnectionQualityIndSizeof, CsrWifiSmeConnectionQualityIndSer, CsrWifiSmeConnectionQualityIndDes, CsrWifiSmeConnectionQualityIndSerFree },
99 { CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, CsrWifiSmeConnectionStatsGetCfmSizeof, CsrWifiSmeConnectionStatsGetCfmSer, CsrWifiSmeConnectionStatsGetCfmDes, CsrWifiSmeConnectionStatsGetCfmSerFree },
100 { CSR_WIFI_SME_DEACTIVATE_CFM, CsrWifiSmeDeactivateCfmSizeof, CsrWifiSmeDeactivateCfmSer, CsrWifiSmeDeactivateCfmDes, CsrWifiSmeDeactivateCfmSerFree },
101 { CSR_WIFI_SME_DISCONNECT_CFM, CsrWifiSmeDisconnectCfmSizeof, CsrWifiSmeDisconnectCfmSer, CsrWifiSmeDisconnectCfmDes, CsrWifiSmeDisconnectCfmSerFree },
102 { CSR_WIFI_SME_EVENT_MASK_SET_CFM, CsrWifiSmeEventMaskSetCfmSizeof, CsrWifiSmeEventMaskSetCfmSer, CsrWifiSmeEventMaskSetCfmDes, CsrWifiSmeEventMaskSetCfmSerFree },
103 { CSR_WIFI_SME_HOST_CONFIG_GET_CFM, CsrWifiSmeHostConfigGetCfmSizeof, CsrWifiSmeHostConfigGetCfmSer, CsrWifiSmeHostConfigGetCfmDes, CsrWifiSmeHostConfigGetCfmSerFree },
104 { CSR_WIFI_SME_HOST_CONFIG_SET_CFM, CsrWifiSmeHostConfigSetCfmSizeof, CsrWifiSmeHostConfigSetCfmSer, CsrWifiSmeHostConfigSetCfmDes, CsrWifiSmeHostConfigSetCfmSerFree },
105 { CSR_WIFI_SME_IBSS_STATION_IND, CsrWifiSmeIbssStationIndSizeof, CsrWifiSmeIbssStationIndSer, CsrWifiSmeIbssStationIndDes, CsrWifiSmeIbssStationIndSerFree },
106 { CSR_WIFI_SME_KEY_CFM, CsrWifiSmeKeyCfmSizeof, CsrWifiSmeKeyCfmSer, CsrWifiSmeKeyCfmDes, CsrWifiSmeKeyCfmSerFree },
107 { CSR_WIFI_SME_LINK_QUALITY_GET_CFM, CsrWifiSmeLinkQualityGetCfmSizeof, CsrWifiSmeLinkQualityGetCfmSer, CsrWifiSmeLinkQualityGetCfmDes, CsrWifiSmeLinkQualityGetCfmSerFree },
108 { CSR_WIFI_SME_MEDIA_STATUS_IND, CsrWifiSmeMediaStatusIndSizeof, CsrWifiSmeMediaStatusIndSer, CsrWifiSmeMediaStatusIndDes, CsrWifiSmeMediaStatusIndSerFree },
109 { CSR_WIFI_SME_MIB_CONFIG_GET_CFM, CsrWifiSmeMibConfigGetCfmSizeof, CsrWifiSmeMibConfigGetCfmSer, CsrWifiSmeMibConfigGetCfmDes, CsrWifiSmeMibConfigGetCfmSerFree },
110 { CSR_WIFI_SME_MIB_CONFIG_SET_CFM, CsrWifiSmeMibConfigSetCfmSizeof, CsrWifiSmeMibConfigSetCfmSer, CsrWifiSmeMibConfigSetCfmDes, CsrWifiSmeMibConfigSetCfmSerFree },
111 { CSR_WIFI_SME_MIB_GET_CFM, CsrWifiSmeMibGetCfmSizeof, CsrWifiSmeMibGetCfmSer, CsrWifiSmeMibGetCfmDes, CsrWifiSmeMibGetCfmSerFree },
112 { CSR_WIFI_SME_MIB_GET_NEXT_CFM, CsrWifiSmeMibGetNextCfmSizeof, CsrWifiSmeMibGetNextCfmSer, CsrWifiSmeMibGetNextCfmDes, CsrWifiSmeMibGetNextCfmSerFree },
113 { CSR_WIFI_SME_MIB_SET_CFM, CsrWifiSmeMibSetCfmSizeof, CsrWifiSmeMibSetCfmSer, CsrWifiSmeMibSetCfmDes, CsrWifiSmeMibSetCfmSerFree },
114 { CSR_WIFI_SME_MIC_FAILURE_IND, CsrWifiSmeMicFailureIndSizeof, CsrWifiSmeMicFailureIndSer, CsrWifiSmeMicFailureIndDes, CsrWifiSmeMicFailureIndSerFree },
115 { CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, CsrWifiSmeMulticastAddressCfmSizeof, CsrWifiSmeMulticastAddressCfmSer, CsrWifiSmeMulticastAddressCfmDes, CsrWifiSmeMulticastAddressCfmSerFree },
116 { CSR_WIFI_SME_PACKET_FILTER_SET_CFM, CsrWifiSmePacketFilterSetCfmSizeof, CsrWifiSmePacketFilterSetCfmSer, CsrWifiSmePacketFilterSetCfmDes, CsrWifiSmePacketFilterSetCfmSerFree },
117 { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, CsrWifiSmePermanentMacAddressGetCfmSizeof, CsrWifiSmePermanentMacAddressGetCfmSer, CsrWifiSmePermanentMacAddressGetCfmDes, CsrWifiSmePermanentMacAddressGetCfmSerFree },
118 { CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, CsrWifiSmePmkidCandidateListIndSizeof, CsrWifiSmePmkidCandidateListIndSer, CsrWifiSmePmkidCandidateListIndDes, CsrWifiSmePmkidCandidateListIndSerFree },
119 { CSR_WIFI_SME_PMKID_CFM, CsrWifiSmePmkidCfmSizeof, CsrWifiSmePmkidCfmSer, CsrWifiSmePmkidCfmDes, CsrWifiSmePmkidCfmSerFree },
120 { CSR_WIFI_SME_POWER_CONFIG_GET_CFM, CsrWifiSmePowerConfigGetCfmSizeof, CsrWifiSmePowerConfigGetCfmSer, CsrWifiSmePowerConfigGetCfmDes, CsrWifiSmePowerConfigGetCfmSerFree },
121 { CSR_WIFI_SME_POWER_CONFIG_SET_CFM, CsrWifiSmePowerConfigSetCfmSizeof, CsrWifiSmePowerConfigSetCfmSer, CsrWifiSmePowerConfigSetCfmDes, CsrWifiSmePowerConfigSetCfmSerFree },
122 { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof, CsrWifiSmeRegulatoryDomainInfoGetCfmSer, CsrWifiSmeRegulatoryDomainInfoGetCfmDes, CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree },
123 { CSR_WIFI_SME_ROAM_COMPLETE_IND, CsrWifiSmeRoamCompleteIndSizeof, CsrWifiSmeRoamCompleteIndSer, CsrWifiSmeRoamCompleteIndDes, CsrWifiSmeRoamCompleteIndSerFree },
124 { CSR_WIFI_SME_ROAM_START_IND, CsrWifiSmeRoamStartIndSizeof, CsrWifiSmeRoamStartIndSer, CsrWifiSmeRoamStartIndDes, CsrWifiSmeRoamStartIndSerFree },
125 { CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, CsrWifiSmeRoamingConfigGetCfmSizeof, CsrWifiSmeRoamingConfigGetCfmSer, CsrWifiSmeRoamingConfigGetCfmDes, CsrWifiSmeRoamingConfigGetCfmSerFree },
126 { CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, CsrWifiSmeRoamingConfigSetCfmSizeof, CsrWifiSmeRoamingConfigSetCfmSer, CsrWifiSmeRoamingConfigSetCfmDes, CsrWifiSmeRoamingConfigSetCfmSerFree },
127 { CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, CsrWifiSmeScanConfigGetCfmSizeof, CsrWifiSmeScanConfigGetCfmSer, CsrWifiSmeScanConfigGetCfmDes, CsrWifiSmeScanConfigGetCfmSerFree },
128 { CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, CsrWifiSmeScanConfigSetCfmSizeof, CsrWifiSmeScanConfigSetCfmSer, CsrWifiSmeScanConfigSetCfmDes, CsrWifiSmeScanConfigSetCfmSerFree },
129 { CSR_WIFI_SME_SCAN_FULL_CFM, CsrWifiSmeScanFullCfmSizeof, CsrWifiSmeScanFullCfmSer, CsrWifiSmeScanFullCfmDes, CsrWifiSmeScanFullCfmSerFree },
130 { CSR_WIFI_SME_SCAN_RESULT_IND, CsrWifiSmeScanResultIndSizeof, CsrWifiSmeScanResultIndSer, CsrWifiSmeScanResultIndDes, CsrWifiSmeScanResultIndSerFree },
131 { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, CsrWifiSmeScanResultsFlushCfmSizeof, CsrWifiSmeScanResultsFlushCfmSer, CsrWifiSmeScanResultsFlushCfmDes, CsrWifiSmeScanResultsFlushCfmSerFree },
132 { CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, CsrWifiSmeScanResultsGetCfmSizeof, CsrWifiSmeScanResultsGetCfmSer, CsrWifiSmeScanResultsGetCfmDes, CsrWifiSmeScanResultsGetCfmSerFree },
133 { CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, CsrWifiSmeSmeStaConfigGetCfmSizeof, CsrWifiSmeSmeStaConfigGetCfmSer, CsrWifiSmeSmeStaConfigGetCfmDes, CsrWifiSmeSmeStaConfigGetCfmSerFree },
134 { CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, CsrWifiSmeSmeStaConfigSetCfmSizeof, CsrWifiSmeSmeStaConfigSetCfmSer, CsrWifiSmeSmeStaConfigSetCfmDes, CsrWifiSmeSmeStaConfigSetCfmSerFree },
135 { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, CsrWifiSmeStationMacAddressGetCfmSizeof, CsrWifiSmeStationMacAddressGetCfmSer, CsrWifiSmeStationMacAddressGetCfmDes, CsrWifiSmeStationMacAddressGetCfmSerFree },
136 { CSR_WIFI_SME_TSPEC_IND, CsrWifiSmeTspecIndSizeof, CsrWifiSmeTspecIndSer, CsrWifiSmeTspecIndDes, CsrWifiSmeTspecIndSerFree },
137 { CSR_WIFI_SME_TSPEC_CFM, CsrWifiSmeTspecCfmSizeof, CsrWifiSmeTspecCfmSer, CsrWifiSmeTspecCfmDes, CsrWifiSmeTspecCfmSerFree },
138 { CSR_WIFI_SME_VERSIONS_GET_CFM, CsrWifiSmeVersionsGetCfmSizeof, CsrWifiSmeVersionsGetCfmSer, CsrWifiSmeVersionsGetCfmDes, CsrWifiSmeVersionsGetCfmSerFree },
139 { CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, CsrWifiSmeWifiFlightmodeCfmSizeof, CsrWifiSmeWifiFlightmodeCfmSer, CsrWifiSmeWifiFlightmodeCfmDes, CsrWifiSmeWifiFlightmodeCfmSerFree },
140 { CSR_WIFI_SME_WIFI_OFF_IND, CsrWifiSmeWifiOffIndSizeof, CsrWifiSmeWifiOffIndSer, CsrWifiSmeWifiOffIndDes, CsrWifiSmeWifiOffIndSerFree },
141 { CSR_WIFI_SME_WIFI_OFF_CFM, CsrWifiSmeWifiOffCfmSizeof, CsrWifiSmeWifiOffCfmSer, CsrWifiSmeWifiOffCfmDes, CsrWifiSmeWifiOffCfmSerFree },
142 { CSR_WIFI_SME_WIFI_ON_CFM, CsrWifiSmeWifiOnCfmSizeof, CsrWifiSmeWifiOnCfmSer, CsrWifiSmeWifiOnCfmDes, CsrWifiSmeWifiOnCfmSerFree },
143 { CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, CsrWifiSmeCloakedSsidsSetCfmSizeof, CsrWifiSmeCloakedSsidsSetCfmSer, CsrWifiSmeCloakedSsidsSetCfmDes, CsrWifiSmeCloakedSsidsSetCfmSerFree },
144 { CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, CsrWifiSmeCloakedSsidsGetCfmSizeof, CsrWifiSmeCloakedSsidsGetCfmSer, CsrWifiSmeCloakedSsidsGetCfmDes, CsrWifiSmeCloakedSsidsGetCfmSerFree },
145 { CSR_WIFI_SME_WIFI_ON_IND, CsrWifiSmeWifiOnIndSizeof, CsrWifiSmeWifiOnIndSer, CsrWifiSmeWifiOnIndDes, CsrWifiSmeWifiOnIndSerFree },
146 { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, CsrWifiSmeSmeCommonConfigGetCfmSizeof, CsrWifiSmeSmeCommonConfigGetCfmSer, CsrWifiSmeSmeCommonConfigGetCfmDes, CsrWifiSmeSmeCommonConfigGetCfmSerFree },
147 { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, CsrWifiSmeSmeCommonConfigSetCfmSizeof, CsrWifiSmeSmeCommonConfigSetCfmSer, CsrWifiSmeSmeCommonConfigSetCfmDes, CsrWifiSmeSmeCommonConfigSetCfmSerFree },
148 { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, CsrWifiSmeInterfaceCapabilityGetCfmSizeof, CsrWifiSmeInterfaceCapabilityGetCfmSer, CsrWifiSmeInterfaceCapabilityGetCfmDes, CsrWifiSmeInterfaceCapabilityGetCfmSerFree },
149 { CSR_WIFI_SME_ERROR_IND, CsrWifiSmeErrorIndSizeof, CsrWifiSmeErrorIndSer, CsrWifiSmeErrorIndDes, CsrWifiSmeErrorIndSerFree },
150 { CSR_WIFI_SME_INFO_IND, CsrWifiSmeInfoIndSizeof, CsrWifiSmeInfoIndSer, CsrWifiSmeInfoIndDes, CsrWifiSmeInfoIndSerFree },
151 { CSR_WIFI_SME_CORE_DUMP_IND, CsrWifiSmeCoreDumpIndSizeof, CsrWifiSmeCoreDumpIndSer, CsrWifiSmeCoreDumpIndDes, CsrWifiSmeCoreDumpIndSerFree },
152 { CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, CsrWifiSmeAmpStatusChangeIndSizeof, CsrWifiSmeAmpStatusChangeIndSer, CsrWifiSmeAmpStatusChangeIndDes, CsrWifiSmeAmpStatusChangeIndSerFree },
153 { CSR_WIFI_SME_WPS_CONFIGURATION_CFM, CsrWifiSmeWpsConfigurationCfmSizeof, CsrWifiSmeWpsConfigurationCfmSer, CsrWifiSmeWpsConfigurationCfmDes, CsrWifiSmeWpsConfigurationCfmSerFree },
154
155 { 0, NULL, NULL, NULL, NULL },
156};
157
158CsrMsgConvMsgEntry* CsrWifiSmeConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
159{
160 if (msgType & CSR_PRIM_UPSTREAM)
161 {
162 u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT;
163 if (idx < (CSR_WIFI_SME_PRIM_UPSTREAM_COUNT + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT) &&
164 csrwifisme_conv_lut[idx].msgType == msgType)
165 {
166 return &csrwifisme_conv_lut[idx];
167 }
168 }
169 else
170 {
171 if (msgType < CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT &&
172 csrwifisme_conv_lut[msgType].msgType == msgType)
173 {
174 return &csrwifisme_conv_lut[msgType];
175 }
176 }
177 return NULL;
178}
179
180
181void CsrWifiSmeConverterInit(void)
182{
183 CsrMsgConvInsert(CSR_WIFI_SME_PRIM, csrwifisme_conv_lut);
184 CsrMsgConvCustomLookupRegister(CSR_WIFI_SME_PRIM, CsrWifiSmeConverterLookup);
185}
186
187
188#ifdef CSR_LOG_ENABLE
189static const CsrLogPrimitiveInformation csrwifisme_conv_info = {
190 CSR_WIFI_SME_PRIM,
191 (char *)"CSR_WIFI_SME_PRIM",
192 csrwifisme_conv_lut
193};
194const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void)
195{
196 return &csrwifisme_conv_info;
197}
198
199
200#endif /* CSR_LOG_ENABLE */
201#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
index ba5e4b44bb6b..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_converter_init.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_CONVERTER_INIT_H__
14#define CSR_WIFI_SME_CONVERTER_INIT_H__
15
16#ifndef EXCLUDE_CSR_WIFI_SME_MODULE
17
18#include "csr_msgconv.h"
19
20#ifdef CSR_LOG_ENABLE
21#include "csr_log.h"
22
23extern const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void);
24#endif /* CSR_LOG_ENABLE */
25
26extern void CsrWifiSmeConverterInit(void);
27
28#else /* EXCLUDE_CSR_WIFI_SME_MODULE */
29
30#define CsrWifiSmeConverterInit()
31
32#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */
33
34#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
index 03b5ddb22cd7..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c
+++ /dev/null
@@ -1,187 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_sme_prim.h"
14#include "csr_wifi_sme_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiSmeFreeDownstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_SME_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_SME_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37
38 switch (*((CsrWifiSmePrim *) message))
39 {
40 case CSR_WIFI_SME_BLACKLIST_REQ:
41 {
42 CsrWifiSmeBlacklistReq *p = (CsrWifiSmeBlacklistReq *)message;
43 kfree(p->setAddresses);
44 p->setAddresses = NULL;
45 break;
46 }
47 case CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ:
48 {
49 CsrWifiSmeCalibrationDataSetReq *p = (CsrWifiSmeCalibrationDataSetReq *)message;
50 kfree(p->calibrationData);
51 p->calibrationData = NULL;
52 break;
53 }
54 case CSR_WIFI_SME_CONNECT_REQ:
55 {
56 CsrWifiSmeConnectReq *p = (CsrWifiSmeConnectReq *)message;
57 kfree(p->connectionConfig.mlmeAssociateReqInformationElements);
58 p->connectionConfig.mlmeAssociateReqInformationElements = NULL;
59 break;
60 }
61 case CSR_WIFI_SME_MIB_GET_NEXT_REQ:
62 {
63 CsrWifiSmeMibGetNextReq *p = (CsrWifiSmeMibGetNextReq *)message;
64 kfree(p->mibAttribute);
65 p->mibAttribute = NULL;
66 break;
67 }
68 case CSR_WIFI_SME_MIB_GET_REQ:
69 {
70 CsrWifiSmeMibGetReq *p = (CsrWifiSmeMibGetReq *)message;
71 kfree(p->mibAttribute);
72 p->mibAttribute = NULL;
73 break;
74 }
75 case CSR_WIFI_SME_MIB_SET_REQ:
76 {
77 CsrWifiSmeMibSetReq *p = (CsrWifiSmeMibSetReq *)message;
78 kfree(p->mibAttribute);
79 p->mibAttribute = NULL;
80 break;
81 }
82 case CSR_WIFI_SME_MULTICAST_ADDRESS_REQ:
83 {
84 CsrWifiSmeMulticastAddressReq *p = (CsrWifiSmeMulticastAddressReq *)message;
85 kfree(p->setAddresses);
86 p->setAddresses = NULL;
87 break;
88 }
89 case CSR_WIFI_SME_PACKET_FILTER_SET_REQ:
90 {
91 CsrWifiSmePacketFilterSetReq *p = (CsrWifiSmePacketFilterSetReq *)message;
92 kfree(p->filter);
93 p->filter = NULL;
94 break;
95 }
96 case CSR_WIFI_SME_PMKID_REQ:
97 {
98 CsrWifiSmePmkidReq *p = (CsrWifiSmePmkidReq *)message;
99 kfree(p->setPmkids);
100 p->setPmkids = NULL;
101 break;
102 }
103 case CSR_WIFI_SME_SCAN_CONFIG_SET_REQ:
104 {
105 CsrWifiSmeScanConfigSetReq *p = (CsrWifiSmeScanConfigSetReq *)message;
106 kfree(p->scanConfig.passiveChannelList);
107 p->scanConfig.passiveChannelList = NULL;
108 break;
109 }
110 case CSR_WIFI_SME_SCAN_FULL_REQ:
111 {
112 CsrWifiSmeScanFullReq *p = (CsrWifiSmeScanFullReq *)message;
113 kfree(p->ssid);
114 p->ssid = NULL;
115 kfree(p->channelList);
116 p->channelList = NULL;
117 kfree(p->probeIe);
118 p->probeIe = NULL;
119 break;
120 }
121 case CSR_WIFI_SME_TSPEC_REQ:
122 {
123 CsrWifiSmeTspecReq *p = (CsrWifiSmeTspecReq *)message;
124 kfree(p->tspec);
125 p->tspec = NULL;
126 kfree(p->tclas);
127 p->tclas = NULL;
128 break;
129 }
130 case CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ:
131 {
132 CsrWifiSmeWifiFlightmodeReq *p = (CsrWifiSmeWifiFlightmodeReq *)message;
133 {
134 u16 i1;
135 for (i1 = 0; i1 < p->mibFilesCount; i1++)
136 {
137 kfree(p->mibFiles[i1].data);
138 p->mibFiles[i1].data = NULL;
139 }
140 }
141 kfree(p->mibFiles);
142 p->mibFiles = NULL;
143 break;
144 }
145 case CSR_WIFI_SME_WIFI_ON_REQ:
146 {
147 CsrWifiSmeWifiOnReq *p = (CsrWifiSmeWifiOnReq *)message;
148 {
149 u16 i1;
150 for (i1 = 0; i1 < p->mibFilesCount; i1++)
151 {
152 kfree(p->mibFiles[i1].data);
153 p->mibFiles[i1].data = NULL;
154 }
155 }
156 kfree(p->mibFiles);
157 p->mibFiles = NULL;
158 break;
159 }
160 case CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ:
161 {
162 CsrWifiSmeCloakedSsidsSetReq *p = (CsrWifiSmeCloakedSsidsSetReq *)message;
163 kfree(p->cloakedSsids.cloakedSsids);
164 p->cloakedSsids.cloakedSsids = NULL;
165 break;
166 }
167 case CSR_WIFI_SME_WPS_CONFIGURATION_REQ:
168 {
169 CsrWifiSmeWpsConfigurationReq *p = (CsrWifiSmeWpsConfigurationReq *)message;
170 kfree(p->wpsConfig.secondaryDeviceType);
171 p->wpsConfig.secondaryDeviceType = NULL;
172 break;
173 }
174 case CSR_WIFI_SME_SET_REQ:
175 {
176 CsrWifiSmeSetReq *p = (CsrWifiSmeSetReq *)message;
177 kfree(p->data);
178 p->data = NULL;
179 break;
180 }
181
182 default:
183 break;
184 }
185}
186
187
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
index c04767baaa5b..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c
+++ /dev/null
@@ -1,275 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/slab.h>
13#include "csr_wifi_sme_prim.h"
14#include "csr_wifi_sme_lib.h"
15
16/*----------------------------------------------------------------------------*
17 * NAME
18 * CsrWifiSmeFreeUpstreamMessageContents
19 *
20 * DESCRIPTION
21 *
22 *
23 * PARAMETERS
24 * eventClass: only the value CSR_WIFI_SME_PRIM will be handled
25 * message: the message to free
26 *----------------------------------------------------------------------------*/
27void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message)
28{
29 if (eventClass != CSR_WIFI_SME_PRIM)
30 {
31 return;
32 }
33 if (NULL == message)
34 {
35 return;
36 }
37
38 switch (*((CsrWifiSmePrim *) message))
39 {
40 case CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND:
41 {
42 CsrWifiSmeAssociationCompleteInd *p = (CsrWifiSmeAssociationCompleteInd *)message;
43 kfree(p->connectionInfo.beaconFrame);
44 p->connectionInfo.beaconFrame = NULL;
45 kfree(p->connectionInfo.associationReqFrame);
46 p->connectionInfo.associationReqFrame = NULL;
47 kfree(p->connectionInfo.associationRspFrame);
48 p->connectionInfo.associationRspFrame = NULL;
49 kfree(p->connectionInfo.assocScanInfoElements);
50 p->connectionInfo.assocScanInfoElements = NULL;
51 kfree(p->connectionInfo.assocReqInfoElements);
52 p->connectionInfo.assocReqInfoElements = NULL;
53 kfree(p->connectionInfo.assocRspInfoElements);
54 p->connectionInfo.assocRspInfoElements = NULL;
55 break;
56 }
57 case CSR_WIFI_SME_BLACKLIST_CFM:
58 {
59 CsrWifiSmeBlacklistCfm *p = (CsrWifiSmeBlacklistCfm *)message;
60 kfree(p->getAddresses);
61 p->getAddresses = NULL;
62 break;
63 }
64 case CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM:
65 {
66 CsrWifiSmeCalibrationDataGetCfm *p = (CsrWifiSmeCalibrationDataGetCfm *)message;
67 kfree(p->calibrationData);
68 p->calibrationData = NULL;
69 break;
70 }
71 case CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM:
72 {
73 CsrWifiSmeConnectionConfigGetCfm *p = (CsrWifiSmeConnectionConfigGetCfm *)message;
74 kfree(p->connectionConfig.mlmeAssociateReqInformationElements);
75 p->connectionConfig.mlmeAssociateReqInformationElements = NULL;
76 break;
77 }
78 case CSR_WIFI_SME_CONNECTION_INFO_GET_CFM:
79 {
80 CsrWifiSmeConnectionInfoGetCfm *p = (CsrWifiSmeConnectionInfoGetCfm *)message;
81 kfree(p->connectionInfo.beaconFrame);
82 p->connectionInfo.beaconFrame = NULL;
83 kfree(p->connectionInfo.associationReqFrame);
84 p->connectionInfo.associationReqFrame = NULL;
85 kfree(p->connectionInfo.associationRspFrame);
86 p->connectionInfo.associationRspFrame = NULL;
87 kfree(p->connectionInfo.assocScanInfoElements);
88 p->connectionInfo.assocScanInfoElements = NULL;
89 kfree(p->connectionInfo.assocReqInfoElements);
90 p->connectionInfo.assocReqInfoElements = NULL;
91 kfree(p->connectionInfo.assocRspInfoElements);
92 p->connectionInfo.assocRspInfoElements = NULL;
93 break;
94 }
95 case CSR_WIFI_SME_MEDIA_STATUS_IND:
96 {
97 CsrWifiSmeMediaStatusInd *p = (CsrWifiSmeMediaStatusInd *)message;
98 kfree(p->connectionInfo.beaconFrame);
99 p->connectionInfo.beaconFrame = NULL;
100 kfree(p->connectionInfo.associationReqFrame);
101 p->connectionInfo.associationReqFrame = NULL;
102 kfree(p->connectionInfo.associationRspFrame);
103 p->connectionInfo.associationRspFrame = NULL;
104 kfree(p->connectionInfo.assocScanInfoElements);
105 p->connectionInfo.assocScanInfoElements = NULL;
106 kfree(p->connectionInfo.assocReqInfoElements);
107 p->connectionInfo.assocReqInfoElements = NULL;
108 kfree(p->connectionInfo.assocRspInfoElements);
109 p->connectionInfo.assocRspInfoElements = NULL;
110 break;
111 }
112 case CSR_WIFI_SME_MIB_GET_CFM:
113 {
114 CsrWifiSmeMibGetCfm *p = (CsrWifiSmeMibGetCfm *)message;
115 kfree(p->mibAttribute);
116 p->mibAttribute = NULL;
117 break;
118 }
119 case CSR_WIFI_SME_MIB_GET_NEXT_CFM:
120 {
121 CsrWifiSmeMibGetNextCfm *p = (CsrWifiSmeMibGetNextCfm *)message;
122 kfree(p->mibAttribute);
123 p->mibAttribute = NULL;
124 break;
125 }
126 case CSR_WIFI_SME_MULTICAST_ADDRESS_CFM:
127 {
128 CsrWifiSmeMulticastAddressCfm *p = (CsrWifiSmeMulticastAddressCfm *)message;
129 kfree(p->getAddresses);
130 p->getAddresses = NULL;
131 break;
132 }
133 case CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND:
134 {
135 CsrWifiSmePmkidCandidateListInd *p = (CsrWifiSmePmkidCandidateListInd *)message;
136 kfree(p->pmkidCandidates);
137 p->pmkidCandidates = NULL;
138 break;
139 }
140 case CSR_WIFI_SME_PMKID_CFM:
141 {
142 CsrWifiSmePmkidCfm *p = (CsrWifiSmePmkidCfm *)message;
143 kfree(p->getPmkids);
144 p->getPmkids = NULL;
145 break;
146 }
147 case CSR_WIFI_SME_SCAN_CONFIG_GET_CFM:
148 {
149 CsrWifiSmeScanConfigGetCfm *p = (CsrWifiSmeScanConfigGetCfm *)message;
150 kfree(p->scanConfig.passiveChannelList);
151 p->scanConfig.passiveChannelList = NULL;
152 break;
153 }
154 case CSR_WIFI_SME_SCAN_RESULT_IND:
155 {
156 CsrWifiSmeScanResultInd *p = (CsrWifiSmeScanResultInd *)message;
157 kfree(p->result.informationElements);
158 p->result.informationElements = NULL;
159 switch (p->result.p2pDeviceRole)
160 {
161 case CSR_WIFI_SME_P2P_ROLE_GO:
162 {
163 u16 i4;
164 for (i4 = 0; i4 < p->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
165 {
166 kfree(p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
167 p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
168 }
169 }
170 kfree(p->result.deviceInfo.groupInfo.p2PClientInfo);
171 p->result.deviceInfo.groupInfo.p2PClientInfo = NULL;
172 break;
173 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
174 kfree(p->result.deviceInfo.standalonedevInfo.secDeviceType);
175 p->result.deviceInfo.standalonedevInfo.secDeviceType = NULL;
176 break;
177 default:
178 break;
179 }
180 break;
181 }
182 case CSR_WIFI_SME_SCAN_RESULTS_GET_CFM:
183 {
184 CsrWifiSmeScanResultsGetCfm *p = (CsrWifiSmeScanResultsGetCfm *)message;
185 {
186 u16 i1;
187 for (i1 = 0; i1 < p->scanResultsCount; i1++)
188 {
189 kfree(p->scanResults[i1].informationElements);
190 p->scanResults[i1].informationElements = NULL;
191 switch (p->scanResults[i1].p2pDeviceRole)
192 {
193 case CSR_WIFI_SME_P2P_ROLE_GO:
194 {
195 u16 i4;
196 for (i4 = 0; i4 < p->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
197 {
198 kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
199 p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
200 }
201 }
202 kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo);
203 p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL;
204 break;
205 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
206 kfree(p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType);
207 p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL;
208 break;
209 default:
210 break;
211 }
212 }
213 }
214 kfree(p->scanResults);
215 p->scanResults = NULL;
216 break;
217 }
218 case CSR_WIFI_SME_TSPEC_IND:
219 {
220 CsrWifiSmeTspecInd *p = (CsrWifiSmeTspecInd *)message;
221 kfree(p->tspec);
222 p->tspec = NULL;
223 break;
224 }
225 case CSR_WIFI_SME_TSPEC_CFM:
226 {
227 CsrWifiSmeTspecCfm *p = (CsrWifiSmeTspecCfm *)message;
228 kfree(p->tspec);
229 p->tspec = NULL;
230 break;
231 }
232 case CSR_WIFI_SME_VERSIONS_GET_CFM:
233 {
234 CsrWifiSmeVersionsGetCfm *p = (CsrWifiSmeVersionsGetCfm *)message;
235 kfree(p->versions.routerBuild);
236 p->versions.routerBuild = NULL;
237 kfree(p->versions.smeBuild);
238 p->versions.smeBuild = NULL;
239 break;
240 }
241 case CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM:
242 {
243 CsrWifiSmeCloakedSsidsGetCfm *p = (CsrWifiSmeCloakedSsidsGetCfm *)message;
244 kfree(p->cloakedSsids.cloakedSsids);
245 p->cloakedSsids.cloakedSsids = NULL;
246 break;
247 }
248 case CSR_WIFI_SME_ERROR_IND:
249 {
250 CsrWifiSmeErrorInd *p = (CsrWifiSmeErrorInd *)message;
251 kfree(p->errorMessage);
252 p->errorMessage = NULL;
253 break;
254 }
255 case CSR_WIFI_SME_INFO_IND:
256 {
257 CsrWifiSmeInfoInd *p = (CsrWifiSmeInfoInd *)message;
258 kfree(p->infoMessage);
259 p->infoMessage = NULL;
260 break;
261 }
262 case CSR_WIFI_SME_CORE_DUMP_IND:
263 {
264 CsrWifiSmeCoreDumpInd *p = (CsrWifiSmeCoreDumpInd *)message;
265 kfree(p->data);
266 p->data = NULL;
267 break;
268 }
269
270 default:
271 break;
272 }
273}
274
275
diff --git a/drivers/staging/csr/csr_wifi_sme_lib.h b/drivers/staging/csr/csr_wifi_sme_lib.h
deleted file mode 100644
index 53cf1268286e..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_lib.h
+++ /dev/null
@@ -1,4303 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_LIB_H__
14#define CSR_WIFI_SME_LIB_H__
15
16#include "csr_sched.h"
17#include "csr_macro.h"
18#include "csr_msg_transport.h"
19
20#include "csr_wifi_lib.h"
21
22#include "csr_wifi_sme_prim.h"
23#include "csr_wifi_sme_task.h"
24
25
26#ifndef CSR_WIFI_SME_LIB_DESTINATION_QUEUE
27# ifdef CSR_WIFI_NME_ENABLE
28# include "csr_wifi_nme_task.h"
29# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_NME_IFACEQUEUE
30# else
31# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_SME_IFACEQUEUE
32# endif
33#endif
34
35/*----------------------------------------------------------------------------*
36 * CsrWifiSmeFreeUpstreamMessageContents
37 *
38 * DESCRIPTION
39 * Free the allocated memory in a CSR_WIFI_SME upstream message. Does not
40 * free the message itself, and can only be used for upstream messages.
41 *
42 * PARAMETERS
43 * Deallocates the resources in a CSR_WIFI_SME upstream message
44 *----------------------------------------------------------------------------*/
45void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message);
46
47/*----------------------------------------------------------------------------*
48 * CsrWifiSmeFreeDownstreamMessageContents
49 *
50 * DESCRIPTION
51 * Free the allocated memory in a CSR_WIFI_SME downstream message. Does not
52 * free the message itself, and can only be used for downstream messages.
53 *
54 * PARAMETERS
55 * Deallocates the resources in a CSR_WIFI_SME downstream message
56 *----------------------------------------------------------------------------*/
57void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message);
58
59/*----------------------------------------------------------------------------*
60 * Enum to string functions
61 *----------------------------------------------------------------------------*/
62const char* CsrWifiSme80211NetworkTypeToString(CsrWifiSme80211NetworkType value);
63const char* CsrWifiSme80211PrivacyModeToString(CsrWifiSme80211PrivacyMode value);
64const char* CsrWifiSme80211dTrustLevelToString(CsrWifiSme80211dTrustLevel value);
65const char* CsrWifiSmeAmpStatusToString(CsrWifiSmeAmpStatus value);
66const char* CsrWifiSmeAuthModeToString(CsrWifiSmeAuthMode value);
67const char* CsrWifiSmeBasicUsabilityToString(CsrWifiSmeBasicUsability value);
68const char* CsrWifiSmeBssTypeToString(CsrWifiSmeBssType value);
69const char* CsrWifiSmeCoexSchemeToString(CsrWifiSmeCoexScheme value);
70const char* CsrWifiSmeControlIndicationToString(CsrWifiSmeControlIndication value);
71const char* CsrWifiSmeCtsProtectionTypeToString(CsrWifiSmeCtsProtectionType value);
72const char* CsrWifiSmeD3AutoScanModeToString(CsrWifiSmeD3AutoScanMode value);
73const char* CsrWifiSmeEncryptionToString(CsrWifiSmeEncryption value);
74const char* CsrWifiSmeFirmwareDriverInterfaceToString(CsrWifiSmeFirmwareDriverInterface value);
75const char* CsrWifiSmeHostPowerModeToString(CsrWifiSmeHostPowerMode value);
76const char* CsrWifiSmeIEEE80211ReasonToString(CsrWifiSmeIEEE80211Reason value);
77const char* CsrWifiSmeIEEE80211ResultToString(CsrWifiSmeIEEE80211Result value);
78const char* CsrWifiSmeIndicationsToString(CsrWifiSmeIndications value);
79const char* CsrWifiSmeKeyTypeToString(CsrWifiSmeKeyType value);
80const char* CsrWifiSmeListActionToString(CsrWifiSmeListAction value);
81const char* CsrWifiSmeMediaStatusToString(CsrWifiSmeMediaStatus value);
82const char* CsrWifiSmeP2pCapabilityToString(CsrWifiSmeP2pCapability value);
83const char* CsrWifiSmeP2pGroupCapabilityToString(CsrWifiSmeP2pGroupCapability value);
84const char* CsrWifiSmeP2pNoaConfigMethodToString(CsrWifiSmeP2pNoaConfigMethod value);
85const char* CsrWifiSmeP2pRoleToString(CsrWifiSmeP2pRole value);
86const char* CsrWifiSmeP2pStatusToString(CsrWifiSmeP2pStatus value);
87const char* CsrWifiSmePacketFilterModeToString(CsrWifiSmePacketFilterMode value);
88const char* CsrWifiSmePowerSaveLevelToString(CsrWifiSmePowerSaveLevel value);
89const char* CsrWifiSmePreambleTypeToString(CsrWifiSmePreambleType value);
90const char* CsrWifiSmeRadioIFToString(CsrWifiSmeRadioIF value);
91const char* CsrWifiSmeRegulatoryDomainToString(CsrWifiSmeRegulatoryDomain value);
92const char* CsrWifiSmeRoamReasonToString(CsrWifiSmeRoamReason value);
93const char* CsrWifiSmeScanTypeToString(CsrWifiSmeScanType value);
94const char* CsrWifiSmeTrafficTypeToString(CsrWifiSmeTrafficType value);
95const char* CsrWifiSmeTspecCtrlToString(CsrWifiSmeTspecCtrl value);
96const char* CsrWifiSmeTspecResultCodeToString(CsrWifiSmeTspecResultCode value);
97const char* CsrWifiSmeWepAuthModeToString(CsrWifiSmeWepAuthMode value);
98const char* CsrWifiSmeWepCredentialTypeToString(CsrWifiSmeWepCredentialType value);
99const char* CsrWifiSmeWmmModeToString(CsrWifiSmeWmmMode value);
100const char* CsrWifiSmeWmmQosInfoToString(CsrWifiSmeWmmQosInfo value);
101const char* CsrWifiSmeWpsConfigTypeToString(CsrWifiSmeWpsConfigType value);
102const char* CsrWifiSmeWpsDeviceCategoryToString(CsrWifiSmeWpsDeviceCategory value);
103const char* CsrWifiSmeWpsDeviceSubCategoryToString(CsrWifiSmeWpsDeviceSubCategory value);
104const char* CsrWifiSmeWpsDpidToString(CsrWifiSmeWpsDpid value);
105const char* CsrWifiSmeWpsRegistrationToString(CsrWifiSmeWpsRegistration value);
106
107
108/*----------------------------------------------------------------------------*
109 * CsrPrim Type toString function.
110 * Converts a message type to the String name of the Message
111 *----------------------------------------------------------------------------*/
112const char* CsrWifiSmePrimTypeToString(CsrPrim msgType);
113
114/*----------------------------------------------------------------------------*
115 * Lookup arrays for PrimType name Strings
116 *----------------------------------------------------------------------------*/
117extern const char *CsrWifiSmeUpstreamPrimNames[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT];
118extern const char *CsrWifiSmeDownstreamPrimNames[CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT];
119
120/*******************************************************************************
121
122 NAME
123 CsrWifiSmeActivateReqSend
124
125 DESCRIPTION
126 The WMA sends this primitive to activate the SME.
127 The WMA must activate the SME before it can send any other primitive.
128
129 PARAMETERS
130 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
131
132*******************************************************************************/
133#define CsrWifiSmeActivateReqCreate(msg__, dst__, src__) \
134 msg__ = kmalloc(sizeof(CsrWifiSmeActivateReq), GFP_KERNEL); \
135 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_REQ, dst__, src__);
136
137#define CsrWifiSmeActivateReqSendTo(dst__, src__) \
138 { \
139 CsrWifiSmeActivateReq *msg__; \
140 CsrWifiSmeActivateReqCreate(msg__, dst__, src__); \
141 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
142 }
143
144#define CsrWifiSmeActivateReqSend(src__) \
145 CsrWifiSmeActivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
146
147/*******************************************************************************
148
149 NAME
150 CsrWifiSmeActivateCfmSend
151
152 DESCRIPTION
153 The SME sends this primitive when the activation is complete.
154
155 PARAMETERS
156 queue - Destination Task Queue
157 status - Reports the result of the request
158
159*******************************************************************************/
160#define CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__) \
161 msg__ = kmalloc(sizeof(CsrWifiSmeActivateCfm), GFP_KERNEL); \
162 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_CFM, dst__, src__); \
163 msg__->status = (status__);
164
165#define CsrWifiSmeActivateCfmSendTo(dst__, src__, status__) \
166 { \
167 CsrWifiSmeActivateCfm *msg__; \
168 CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__); \
169 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
170 }
171
172#define CsrWifiSmeActivateCfmSend(dst__, status__) \
173 CsrWifiSmeActivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
174
175/*******************************************************************************
176
177 NAME
178 CsrWifiSmeAdhocConfigGetReqSend
179
180 DESCRIPTION
181 This primitive gets the value of the adHocConfig parameter.
182
183 PARAMETERS
184 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
185
186*******************************************************************************/
187#define CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__) \
188 msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetReq), GFP_KERNEL); \
189 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, dst__, src__);
190
191#define CsrWifiSmeAdhocConfigGetReqSendTo(dst__, src__) \
192 { \
193 CsrWifiSmeAdhocConfigGetReq *msg__; \
194 CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__); \
195 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
196 }
197
198#define CsrWifiSmeAdhocConfigGetReqSend(src__) \
199 CsrWifiSmeAdhocConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
200
201/*******************************************************************************
202
203 NAME
204 CsrWifiSmeAdhocConfigGetCfmSend
205
206 DESCRIPTION
207 This primitive reports the result of the request.
208
209 PARAMETERS
210 queue - Destination Task Queue
211 status - Reports the result of the request
212 adHocConfig - Contains the values used when starting an Ad-hoc (IBSS)
213 connection.
214
215*******************************************************************************/
216#define CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__) \
217 msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL); \
218 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, dst__, src__); \
219 msg__->status = (status__); \
220 msg__->adHocConfig = (adHocConfig__);
221
222#define CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, src__, status__, adHocConfig__) \
223 { \
224 CsrWifiSmeAdhocConfigGetCfm *msg__; \
225 CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__); \
226 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
227 }
228
229#define CsrWifiSmeAdhocConfigGetCfmSend(dst__, status__, adHocConfig__) \
230 CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, adHocConfig__)
231
232/*******************************************************************************
233
234 NAME
235 CsrWifiSmeAdhocConfigSetReqSend
236
237 DESCRIPTION
238 This primitive sets the value of the adHocConfig parameter.
239
240 PARAMETERS
241 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
242 adHocConfig - Sets the values to use when starting an ad hoc network.
243
244*******************************************************************************/
245#define CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__) \
246 msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL); \
247 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, dst__, src__); \
248 msg__->adHocConfig = (adHocConfig__);
249
250#define CsrWifiSmeAdhocConfigSetReqSendTo(dst__, src__, adHocConfig__) \
251 { \
252 CsrWifiSmeAdhocConfigSetReq *msg__; \
253 CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__); \
254 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
255 }
256
257#define CsrWifiSmeAdhocConfigSetReqSend(src__, adHocConfig__) \
258 CsrWifiSmeAdhocConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, adHocConfig__)
259
260/*******************************************************************************
261
262 NAME
263 CsrWifiSmeAdhocConfigSetCfmSend
264
265 DESCRIPTION
266 This primitive reports the result of the request.
267
268 PARAMETERS
269 queue - Destination Task Queue
270 status - Reports the result of the request
271
272*******************************************************************************/
273#define CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__) \
274 msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetCfm), GFP_KERNEL); \
275 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, dst__, src__); \
276 msg__->status = (status__);
277
278#define CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, src__, status__) \
279 { \
280 CsrWifiSmeAdhocConfigSetCfm *msg__; \
281 CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__); \
282 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
283 }
284
285#define CsrWifiSmeAdhocConfigSetCfmSend(dst__, status__) \
286 CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
287
288/*******************************************************************************
289
290 NAME
291 CsrWifiSmeAmpStatusChangeIndSend
292
293 DESCRIPTION
294 Indication of change to AMP activity.
295
296 PARAMETERS
297 queue - Destination Task Queue
298 interfaceTag - Interface on which the AMP activity changed.
299 ampStatus - The new status of AMP activity.Range: {AMP_ACTIVE,
300 AMP_INACTIVE}.
301
302*******************************************************************************/
303#define CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__) \
304 msg__ = kmalloc(sizeof(CsrWifiSmeAmpStatusChangeInd), GFP_KERNEL); \
305 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, dst__, src__); \
306 msg__->interfaceTag = (interfaceTag__); \
307 msg__->ampStatus = (ampStatus__);
308
309#define CsrWifiSmeAmpStatusChangeIndSendTo(dst__, src__, interfaceTag__, ampStatus__) \
310 { \
311 CsrWifiSmeAmpStatusChangeInd *msg__; \
312 CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__); \
313 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
314 }
315
316#define CsrWifiSmeAmpStatusChangeIndSend(dst__, interfaceTag__, ampStatus__) \
317 CsrWifiSmeAmpStatusChangeIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, ampStatus__)
318
319/*******************************************************************************
320
321 NAME
322 CsrWifiSmeAssociationCompleteIndSend
323
324 DESCRIPTION
325 The SME will send this primitive to all the tasks that have registered to
326 receive it whenever it completes an attempt to associate with an AP. If
327 the association was successful, status will be set to
328 CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be
329 set to appropriate error codes.
330
331 PARAMETERS
332 queue - Destination Task Queue
333 interfaceTag - Interface Identifier; unique identifier of an interface
334 status - Reports the result of the association procedure
335 connectionInfo - This parameter is relevant only if result is
336 CSR_WIFI_SME_STATUS_SUCCESS:
337 it points to the connection information for the new network
338 deauthReason - This parameter is relevant only if result is not
339 CSR_WIFI_SME_STATUS_SUCCESS:
340 if the AP deauthorised the station, it gives the reason of
341 the deauthorization
342
343*******************************************************************************/
344#define CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
345 msg__ = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL); \
346 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, dst__, src__); \
347 msg__->interfaceTag = (interfaceTag__); \
348 msg__->status = (status__); \
349 msg__->connectionInfo = (connectionInfo__); \
350 msg__->deauthReason = (deauthReason__);
351
352#define CsrWifiSmeAssociationCompleteIndSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
353 { \
354 CsrWifiSmeAssociationCompleteInd *msg__; \
355 CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__); \
356 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
357 }
358
359#define CsrWifiSmeAssociationCompleteIndSend(dst__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
360 CsrWifiSmeAssociationCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__, deauthReason__)
361
362/*******************************************************************************
363
364 NAME
365 CsrWifiSmeAssociationStartIndSend
366
367 DESCRIPTION
368 The SME will send this primitive to all the tasks that have registered to
369 receive it whenever it begins an attempt to associate with an AP.
370
371 PARAMETERS
372 queue - Destination Task Queue
373 interfaceTag - Interface Identifier; unique identifier of an interface
374 address - BSSID of the associating network
375 ssid - Service Set identifier of the associating network
376
377*******************************************************************************/
378#define CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__) \
379 msg__ = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL); \
380 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_START_IND, dst__, src__); \
381 msg__->interfaceTag = (interfaceTag__); \
382 msg__->address = (address__); \
383 msg__->ssid = (ssid__);
384
385#define CsrWifiSmeAssociationStartIndSendTo(dst__, src__, interfaceTag__, address__, ssid__) \
386 { \
387 CsrWifiSmeAssociationStartInd *msg__; \
388 CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__); \
389 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
390 }
391
392#define CsrWifiSmeAssociationStartIndSend(dst__, interfaceTag__, address__, ssid__) \
393 CsrWifiSmeAssociationStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, address__, ssid__)
394
395/*******************************************************************************
396
397 NAME
398 CsrWifiSmeBlacklistReqSend
399
400 DESCRIPTION
401 The wireless manager application should call this primitive to notify the
402 driver of any networks that should not be connected to. The interface
403 allows the wireless manager application to query, add, remove, and flush
404 the BSSIDs that the driver may not connect or roam to.
405 When this primitive adds to the black list the BSSID to which the SME is
406 currently connected, the SME will try to roam, if applicable, to another
407 BSSID in the same ESS; if the roaming procedure fails, the SME will
408 disconnect.
409
410 PARAMETERS
411 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
412 interfaceTag - Interface Identifier; unique identifier of an interface
413 action - The value of the CsrWifiSmeListAction parameter instructs
414 the driver to modify or provide the list of blacklisted
415 networks.
416 setAddressCount - Number of BSSIDs sent with this primitive
417 setAddresses - Pointer to the list of BBSIDs sent with the primitive, set
418 to NULL if none is sent.
419
420*******************************************************************************/
421#define CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
422 msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL); \
423 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_REQ, dst__, src__); \
424 msg__->interfaceTag = (interfaceTag__); \
425 msg__->action = (action__); \
426 msg__->setAddressCount = (setAddressCount__); \
427 msg__->setAddresses = (setAddresses__);
428
429#define CsrWifiSmeBlacklistReqSendTo(dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
430 { \
431 CsrWifiSmeBlacklistReq *msg__; \
432 CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__); \
433 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
434 }
435
436#define CsrWifiSmeBlacklistReqSend(src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
437 CsrWifiSmeBlacklistReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressCount__, setAddresses__)
438
439/*******************************************************************************
440
441 NAME
442 CsrWifiSmeBlacklistCfmSend
443
444 DESCRIPTION
445 The SME will call this primitive when the action on the blacklist has
446 completed. For a GET action, this primitive also reports the list of
447 BBSIDs in the blacklist.
448
449 PARAMETERS
450 queue - Destination Task Queue
451 interfaceTag - Interface Identifier; unique identifier of an interface
452 status - Reports the result of the request
453 action - Action in the request
454 getAddressCount - This parameter is only relevant if action is
455 CSR_WIFI_SME_LIST_ACTION_GET:
456 number of BSSIDs sent with this primitive
457 getAddresses - Pointer to the list of BBSIDs sent with the primitive, set
458 to NULL if none is sent.
459
460*******************************************************************************/
461#define CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
462 msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL); \
463 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_CFM, dst__, src__); \
464 msg__->interfaceTag = (interfaceTag__); \
465 msg__->status = (status__); \
466 msg__->action = (action__); \
467 msg__->getAddressCount = (getAddressCount__); \
468 msg__->getAddresses = (getAddresses__);
469
470#define CsrWifiSmeBlacklistCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
471 { \
472 CsrWifiSmeBlacklistCfm *msg__; \
473 CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__); \
474 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
475 }
476
477#define CsrWifiSmeBlacklistCfmSend(dst__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
478 CsrWifiSmeBlacklistCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressCount__, getAddresses__)
479
480/*******************************************************************************
481
482 NAME
483 CsrWifiSmeCalibrationDataGetReqSend
484
485 DESCRIPTION
486 This primitive retrieves the Wi-Fi radio calibration data.
487
488 PARAMETERS
489 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
490
491*******************************************************************************/
492#define CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__) \
493 msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetReq), GFP_KERNEL); \
494 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, dst__, src__);
495
496#define CsrWifiSmeCalibrationDataGetReqSendTo(dst__, src__) \
497 { \
498 CsrWifiSmeCalibrationDataGetReq *msg__; \
499 CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__); \
500 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
501 }
502
503#define CsrWifiSmeCalibrationDataGetReqSend(src__) \
504 CsrWifiSmeCalibrationDataGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
505
506/*******************************************************************************
507
508 NAME
509 CsrWifiSmeCalibrationDataGetCfmSend
510
511 DESCRIPTION
512 This primitive reports the result of the request.
513
514 PARAMETERS
515 queue - Destination Task Queue
516 status - Reports the result of the request
517 calibrationDataLength - Number of bytes in the buffer pointed by
518 calibrationData
519 calibrationData - Pointer to a buffer of length calibrationDataLength
520 containing the calibration data
521
522*******************************************************************************/
523#define CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__) \
524 msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL); \
525 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, dst__, src__); \
526 msg__->status = (status__); \
527 msg__->calibrationDataLength = (calibrationDataLength__); \
528 msg__->calibrationData = (calibrationData__);
529
530#define CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, src__, status__, calibrationDataLength__, calibrationData__) \
531 { \
532 CsrWifiSmeCalibrationDataGetCfm *msg__; \
533 CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__); \
534 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
535 }
536
537#define CsrWifiSmeCalibrationDataGetCfmSend(dst__, status__, calibrationDataLength__, calibrationData__) \
538 CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, calibrationDataLength__, calibrationData__)
539
540/*******************************************************************************
541
542 NAME
543 CsrWifiSmeCalibrationDataSetReqSend
544
545 DESCRIPTION
546 This primitive sets the Wi-Fi radio calibration data.
547 The usage of the primitive with proper calibration data will avoid
548 time-consuming configuration after power-up.
549
550 PARAMETERS
551 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
552 calibrationDataLength - Number of bytes in the buffer pointed by
553 calibrationData
554 calibrationData - Pointer to a buffer of length calibrationDataLength
555 containing the calibration data
556
557*******************************************************************************/
558#define CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__) \
559 msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL); \
560 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, dst__, src__); \
561 msg__->calibrationDataLength = (calibrationDataLength__); \
562 msg__->calibrationData = (calibrationData__);
563
564#define CsrWifiSmeCalibrationDataSetReqSendTo(dst__, src__, calibrationDataLength__, calibrationData__) \
565 { \
566 CsrWifiSmeCalibrationDataSetReq *msg__; \
567 CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__); \
568 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
569 }
570
571#define CsrWifiSmeCalibrationDataSetReqSend(src__, calibrationDataLength__, calibrationData__) \
572 CsrWifiSmeCalibrationDataSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, calibrationDataLength__, calibrationData__)
573
574/*******************************************************************************
575
576 NAME
577 CsrWifiSmeCalibrationDataSetCfmSend
578
579 DESCRIPTION
580 This primitive reports the result of the request.
581
582 PARAMETERS
583 queue - Destination Task Queue
584 status - Reports the result of the request
585
586*******************************************************************************/
587#define CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__) \
588 msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetCfm), GFP_KERNEL); \
589 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, dst__, src__); \
590 msg__->status = (status__);
591
592#define CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, src__, status__) \
593 { \
594 CsrWifiSmeCalibrationDataSetCfm *msg__; \
595 CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__); \
596 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
597 }
598
599#define CsrWifiSmeCalibrationDataSetCfmSend(dst__, status__) \
600 CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
601
602/*******************************************************************************
603
604 NAME
605 CsrWifiSmeCcxConfigGetReqSend
606
607 DESCRIPTION
608 This primitive gets the value of the CcxConfig parameter.
609 CURRENTLY NOT SUPPORTED.
610
611 PARAMETERS
612 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
613 interfaceTag - Interface Identifier; unique identifier of an interface
614
615*******************************************************************************/
616#define CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
617 msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetReq), GFP_KERNEL); \
618 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_REQ, dst__, src__); \
619 msg__->interfaceTag = (interfaceTag__);
620
621#define CsrWifiSmeCcxConfigGetReqSendTo(dst__, src__, interfaceTag__) \
622 { \
623 CsrWifiSmeCcxConfigGetReq *msg__; \
624 CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
625 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
626 }
627
628#define CsrWifiSmeCcxConfigGetReqSend(src__, interfaceTag__) \
629 CsrWifiSmeCcxConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
630
631/*******************************************************************************
632
633 NAME
634 CsrWifiSmeCcxConfigGetCfmSend
635
636 DESCRIPTION
637 This primitive reports the result of the request.
638
639 PARAMETERS
640 queue - Destination Task Queue
641 interfaceTag - Interface Identifier; unique identifier of an interface
642 status - Reports the result of the request
643 ccxConfig - Currently not supported
644
645*******************************************************************************/
646#define CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__) \
647 msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL); \
648 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_CFM, dst__, src__); \
649 msg__->interfaceTag = (interfaceTag__); \
650 msg__->status = (status__); \
651 msg__->ccxConfig = (ccxConfig__);
652
653#define CsrWifiSmeCcxConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, ccxConfig__) \
654 { \
655 CsrWifiSmeCcxConfigGetCfm *msg__; \
656 CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__); \
657 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
658 }
659
660#define CsrWifiSmeCcxConfigGetCfmSend(dst__, interfaceTag__, status__, ccxConfig__) \
661 CsrWifiSmeCcxConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, ccxConfig__)
662
663/*******************************************************************************
664
665 NAME
666 CsrWifiSmeCcxConfigSetReqSend
667
668 DESCRIPTION
669 This primitive sets the value of the CcxConfig parameter.
670 CURRENTLY NOT SUPPORTED.
671
672 PARAMETERS
673 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
674 interfaceTag - Interface Identifier; unique identifier of an interface
675 ccxConfig - Currently not supported
676
677*******************************************************************************/
678#define CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__) \
679 msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL); \
680 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_REQ, dst__, src__); \
681 msg__->interfaceTag = (interfaceTag__); \
682 msg__->ccxConfig = (ccxConfig__);
683
684#define CsrWifiSmeCcxConfigSetReqSendTo(dst__, src__, interfaceTag__, ccxConfig__) \
685 { \
686 CsrWifiSmeCcxConfigSetReq *msg__; \
687 CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__); \
688 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
689 }
690
691#define CsrWifiSmeCcxConfigSetReqSend(src__, interfaceTag__, ccxConfig__) \
692 CsrWifiSmeCcxConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, ccxConfig__)
693
694/*******************************************************************************
695
696 NAME
697 CsrWifiSmeCcxConfigSetCfmSend
698
699 DESCRIPTION
700 This primitive reports the result of the request.
701
702 PARAMETERS
703 queue - Destination Task Queue
704 interfaceTag - Interface Identifier; unique identifier of an interface
705 status - Reports the result of the request
706
707*******************************************************************************/
708#define CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
709 msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL); \
710 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_CFM, dst__, src__); \
711 msg__->interfaceTag = (interfaceTag__); \
712 msg__->status = (status__);
713
714#define CsrWifiSmeCcxConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
715 { \
716 CsrWifiSmeCcxConfigSetCfm *msg__; \
717 CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
718 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
719 }
720
721#define CsrWifiSmeCcxConfigSetCfmSend(dst__, interfaceTag__, status__) \
722 CsrWifiSmeCcxConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
723
724/*******************************************************************************
725
726 NAME
727 CsrWifiSmeCloakedSsidsGetReqSend
728
729 DESCRIPTION
730 This primitive gets the value of the CloakedSsids parameter.
731
732 PARAMETERS
733 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
734
735*******************************************************************************/
736#define CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__) \
737 msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetReq), GFP_KERNEL); \
738 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, dst__, src__);
739
740#define CsrWifiSmeCloakedSsidsGetReqSendTo(dst__, src__) \
741 { \
742 CsrWifiSmeCloakedSsidsGetReq *msg__; \
743 CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__); \
744 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
745 }
746
747#define CsrWifiSmeCloakedSsidsGetReqSend(src__) \
748 CsrWifiSmeCloakedSsidsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
749
750/*******************************************************************************
751
752 NAME
753 CsrWifiSmeCloakedSsidsGetCfmSend
754
755 DESCRIPTION
756 This primitive reports the result of the request.
757
758 PARAMETERS
759 queue - Destination Task Queue
760 status - Reports the result of the request
761 cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for
762 by the driver
763
764*******************************************************************************/
765#define CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__) \
766 msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL); \
767 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, dst__, src__); \
768 msg__->status = (status__); \
769 msg__->cloakedSsids = (cloakedSsids__);
770
771#define CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, src__, status__, cloakedSsids__) \
772 { \
773 CsrWifiSmeCloakedSsidsGetCfm *msg__; \
774 CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__); \
775 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
776 }
777
778#define CsrWifiSmeCloakedSsidsGetCfmSend(dst__, status__, cloakedSsids__) \
779 CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, cloakedSsids__)
780
781/*******************************************************************************
782
783 NAME
784 CsrWifiSmeCloakedSsidsSetReqSend
785
786 DESCRIPTION
787 This primitive sets the list of cloaked SSIDs for which the WMA possesses
788 profiles.
789 When the driver detects a cloaked AP, the SME will explicitly scan for it
790 using the list of cloaked SSIDs provided it, and, if the scan succeeds,
791 it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND
792 (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM.
793
794 PARAMETERS
795 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
796 cloakedSsids - Sets the list of cloaked SSIDs
797
798*******************************************************************************/
799#define CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__) \
800 msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL); \
801 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, dst__, src__); \
802 msg__->cloakedSsids = (cloakedSsids__);
803
804#define CsrWifiSmeCloakedSsidsSetReqSendTo(dst__, src__, cloakedSsids__) \
805 { \
806 CsrWifiSmeCloakedSsidsSetReq *msg__; \
807 CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__); \
808 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
809 }
810
811#define CsrWifiSmeCloakedSsidsSetReqSend(src__, cloakedSsids__) \
812 CsrWifiSmeCloakedSsidsSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, cloakedSsids__)
813
814/*******************************************************************************
815
816 NAME
817 CsrWifiSmeCloakedSsidsSetCfmSend
818
819 DESCRIPTION
820 This primitive reports the result of the request.
821
822 PARAMETERS
823 queue - Destination Task Queue
824 status - Reports the result of the request
825
826*******************************************************************************/
827#define CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__) \
828 msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetCfm), GFP_KERNEL); \
829 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, dst__, src__); \
830 msg__->status = (status__);
831
832#define CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, src__, status__) \
833 { \
834 CsrWifiSmeCloakedSsidsSetCfm *msg__; \
835 CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__); \
836 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
837 }
838
839#define CsrWifiSmeCloakedSsidsSetCfmSend(dst__, status__) \
840 CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
841
842/*******************************************************************************
843
844 NAME
845 CsrWifiSmeCoexConfigGetReqSend
846
847 DESCRIPTION
848 This primitive gets the value of the CoexConfig parameter.
849
850 PARAMETERS
851 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
852
853*******************************************************************************/
854#define CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__) \
855 msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetReq), GFP_KERNEL); \
856 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_REQ, dst__, src__);
857
858#define CsrWifiSmeCoexConfigGetReqSendTo(dst__, src__) \
859 { \
860 CsrWifiSmeCoexConfigGetReq *msg__; \
861 CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__); \
862 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
863 }
864
865#define CsrWifiSmeCoexConfigGetReqSend(src__) \
866 CsrWifiSmeCoexConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
867
868/*******************************************************************************
869
870 NAME
871 CsrWifiSmeCoexConfigGetCfmSend
872
873 DESCRIPTION
874 This primitive reports the result of the request.
875
876 PARAMETERS
877 queue - Destination Task Queue
878 status - Reports the result of the request
879 coexConfig - Reports the parameters used to configure the coexistence
880 behaviour
881
882*******************************************************************************/
883#define CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__) \
884 msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL); \
885 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_CFM, dst__, src__); \
886 msg__->status = (status__); \
887 msg__->coexConfig = (coexConfig__);
888
889#define CsrWifiSmeCoexConfigGetCfmSendTo(dst__, src__, status__, coexConfig__) \
890 { \
891 CsrWifiSmeCoexConfigGetCfm *msg__; \
892 CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__); \
893 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
894 }
895
896#define CsrWifiSmeCoexConfigGetCfmSend(dst__, status__, coexConfig__) \
897 CsrWifiSmeCoexConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexConfig__)
898
899/*******************************************************************************
900
901 NAME
902 CsrWifiSmeCoexConfigSetReqSend
903
904 DESCRIPTION
905 This primitive sets the value of the CoexConfig parameter.
906
907 PARAMETERS
908 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
909 coexConfig - Configures the coexistence behaviour
910
911*******************************************************************************/
912#define CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__) \
913 msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL); \
914 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_REQ, dst__, src__); \
915 msg__->coexConfig = (coexConfig__);
916
917#define CsrWifiSmeCoexConfigSetReqSendTo(dst__, src__, coexConfig__) \
918 { \
919 CsrWifiSmeCoexConfigSetReq *msg__; \
920 CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__); \
921 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
922 }
923
924#define CsrWifiSmeCoexConfigSetReqSend(src__, coexConfig__) \
925 CsrWifiSmeCoexConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, coexConfig__)
926
927/*******************************************************************************
928
929 NAME
930 CsrWifiSmeCoexConfigSetCfmSend
931
932 DESCRIPTION
933 This primitive reports the result of the request.
934
935 PARAMETERS
936 queue - Destination Task Queue
937 status - Reports the result of the request
938
939*******************************************************************************/
940#define CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__) \
941 msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetCfm), GFP_KERNEL); \
942 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_CFM, dst__, src__); \
943 msg__->status = (status__);
944
945#define CsrWifiSmeCoexConfigSetCfmSendTo(dst__, src__, status__) \
946 { \
947 CsrWifiSmeCoexConfigSetCfm *msg__; \
948 CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__); \
949 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
950 }
951
952#define CsrWifiSmeCoexConfigSetCfmSend(dst__, status__) \
953 CsrWifiSmeCoexConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
954
955/*******************************************************************************
956
957 NAME
958 CsrWifiSmeCoexInfoGetReqSend
959
960 DESCRIPTION
961 This primitive gets the value of the CoexInfo parameter.
962
963 PARAMETERS
964 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
965
966*******************************************************************************/
967#define CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__) \
968 msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetReq), GFP_KERNEL); \
969 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_REQ, dst__, src__);
970
971#define CsrWifiSmeCoexInfoGetReqSendTo(dst__, src__) \
972 { \
973 CsrWifiSmeCoexInfoGetReq *msg__; \
974 CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__); \
975 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
976 }
977
978#define CsrWifiSmeCoexInfoGetReqSend(src__) \
979 CsrWifiSmeCoexInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
980
981/*******************************************************************************
982
983 NAME
984 CsrWifiSmeCoexInfoGetCfmSend
985
986 DESCRIPTION
987 This primitive reports the result of the request.
988
989 PARAMETERS
990 queue - Destination Task Queue
991 status - Reports the result of the request
992 coexInfo - Reports information and state related to coexistence.
993
994*******************************************************************************/
995#define CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__) \
996 msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL); \
997 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_CFM, dst__, src__); \
998 msg__->status = (status__); \
999 msg__->coexInfo = (coexInfo__);
1000
1001#define CsrWifiSmeCoexInfoGetCfmSendTo(dst__, src__, status__, coexInfo__) \
1002 { \
1003 CsrWifiSmeCoexInfoGetCfm *msg__; \
1004 CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__); \
1005 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1006 }
1007
1008#define CsrWifiSmeCoexInfoGetCfmSend(dst__, status__, coexInfo__) \
1009 CsrWifiSmeCoexInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexInfo__)
1010
1011/*******************************************************************************
1012
1013 NAME
1014 CsrWifiSmeConnectReqSend
1015
1016 DESCRIPTION
1017 The wireless manager application calls this primitive to start the
1018 process of joining an 802.11 wireless network or to start an ad hoc
1019 network.
1020 The structure pointed by connectionConfig contains parameters describing
1021 the network to join or, in case of an ad hoc network, to host or join.
1022 The SME will select a network, perform the IEEE 802.11 Join, Authenticate
1023 and Associate exchanges.
1024 The SME selects the networks from the current scan list that match both
1025 the SSID and BSSID, however either or both of these may be the wildcard
1026 value. Using this rule, the following operations are possible:
1027 * To connect to a network by name, specify the SSID and set the BSSID to
1028 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible,
1029 the SME will select the one with the strongest signal.
1030 * To connect to a specific network, specify the BSSID. The SSID is
1031 optional, but if given it must match the SSID of the network. An empty
1032 SSID may be specified by setting the SSID length to zero. Please note
1033 that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF
1034 0xFF 0xFF), the SME will not attempt to roam if signal conditions become
1035 poor, even if there is an alternative AP with an SSID that matches the
1036 current network SSID.
1037 * To connect to any network matching the other parameters (i.e. security,
1038 etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF
1039 0xFF 0xFF 0xFF. In this case, the SME will order all available networks
1040 by their signal strengths and will iterate through this list until it
1041 successfully connects.
1042 NOTE: Specifying the BSSID will restrict the selection to one specific
1043 network. If SSID and BSSID are given, they must both match the network
1044 for it to be selected. To select a network based on the SSID only, the
1045 wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF
1046 0xFF 0xFF.
1047 The SME will try to connect to each network that matches the provided
1048 parameters, one by one, until it succeeds or has tried unsuccessfully
1049 with all the matching networks.
1050 If there is no network that matches the parameters and the request allows
1051 to host an ad hoc network, the SME will advertise a new ad hoc network
1052 instead.
1053 If the SME cannot connect, it will notify the failure in the confirm.
1054
1055 PARAMETERS
1056 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1057 interfaceTag - Interface Identifier; unique identifier of an interface
1058 connectionConfig - Describes the candidate network to join or to host.
1059
1060*******************************************************************************/
1061#define CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__) \
1062 msg__ = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL); \
1063 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_REQ, dst__, src__); \
1064 msg__->interfaceTag = (interfaceTag__); \
1065 msg__->connectionConfig = (connectionConfig__);
1066
1067#define CsrWifiSmeConnectReqSendTo(dst__, src__, interfaceTag__, connectionConfig__) \
1068 { \
1069 CsrWifiSmeConnectReq *msg__; \
1070 CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__); \
1071 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1072 }
1073
1074#define CsrWifiSmeConnectReqSend(src__, interfaceTag__, connectionConfig__) \
1075 CsrWifiSmeConnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, connectionConfig__)
1076
1077/*******************************************************************************
1078
1079 NAME
1080 CsrWifiSmeConnectCfmSend
1081
1082 DESCRIPTION
1083 The SME calls this primitive when the connection exchange is complete or
1084 all connection attempts fail.
1085
1086 PARAMETERS
1087 queue - Destination Task Queue
1088 interfaceTag - Interface Identifier; unique identifier of an interface
1089 status - Reports the result of the request.
1090 CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to
1091 locate the requested AP failed
1092
1093*******************************************************************************/
1094#define CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
1095 msg__ = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL); \
1096 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_CFM, dst__, src__); \
1097 msg__->interfaceTag = (interfaceTag__); \
1098 msg__->status = (status__);
1099
1100#define CsrWifiSmeConnectCfmSendTo(dst__, src__, interfaceTag__, status__) \
1101 { \
1102 CsrWifiSmeConnectCfm *msg__; \
1103 CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
1104 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1105 }
1106
1107#define CsrWifiSmeConnectCfmSend(dst__, interfaceTag__, status__) \
1108 CsrWifiSmeConnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
1109
1110/*******************************************************************************
1111
1112 NAME
1113 CsrWifiSmeConnectionConfigGetReqSend
1114
1115 DESCRIPTION
1116 This primitive gets the value of the ConnectionConfig parameter.
1117
1118 PARAMETERS
1119 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1120 interfaceTag - Interface Identifier; unique identifier of an interface
1121
1122*******************************************************************************/
1123#define CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
1124 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetReq), GFP_KERNEL); \
1125 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, dst__, src__); \
1126 msg__->interfaceTag = (interfaceTag__);
1127
1128#define CsrWifiSmeConnectionConfigGetReqSendTo(dst__, src__, interfaceTag__) \
1129 { \
1130 CsrWifiSmeConnectionConfigGetReq *msg__; \
1131 CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
1132 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1133 }
1134
1135#define CsrWifiSmeConnectionConfigGetReqSend(src__, interfaceTag__) \
1136 CsrWifiSmeConnectionConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
1137
1138/*******************************************************************************
1139
1140 NAME
1141 CsrWifiSmeConnectionConfigGetCfmSend
1142
1143 DESCRIPTION
1144 This primitive reports the result of the request.
1145
1146 PARAMETERS
1147 queue - Destination Task Queue
1148 interfaceTag - Interface Identifier; unique identifier of an interface
1149 status - Reports the result of the request
1150 connectionConfig - Parameters used by the SME for selecting a network
1151
1152*******************************************************************************/
1153#define CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__) \
1154 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL); \
1155 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, dst__, src__); \
1156 msg__->interfaceTag = (interfaceTag__); \
1157 msg__->status = (status__); \
1158 msg__->connectionConfig = (connectionConfig__);
1159
1160#define CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionConfig__) \
1161 { \
1162 CsrWifiSmeConnectionConfigGetCfm *msg__; \
1163 CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__); \
1164 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1165 }
1166
1167#define CsrWifiSmeConnectionConfigGetCfmSend(dst__, interfaceTag__, status__, connectionConfig__) \
1168 CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionConfig__)
1169
1170/*******************************************************************************
1171
1172 NAME
1173 CsrWifiSmeConnectionInfoGetReqSend
1174
1175 DESCRIPTION
1176 This primitive gets the value of the ConnectionInfo parameter.
1177
1178 PARAMETERS
1179 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1180 interfaceTag - Interface Identifier; unique identifier of an interface
1181
1182*******************************************************************************/
1183#define CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__) \
1184 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetReq), GFP_KERNEL); \
1185 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, dst__, src__); \
1186 msg__->interfaceTag = (interfaceTag__);
1187
1188#define CsrWifiSmeConnectionInfoGetReqSendTo(dst__, src__, interfaceTag__) \
1189 { \
1190 CsrWifiSmeConnectionInfoGetReq *msg__; \
1191 CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__); \
1192 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1193 }
1194
1195#define CsrWifiSmeConnectionInfoGetReqSend(src__, interfaceTag__) \
1196 CsrWifiSmeConnectionInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
1197
1198/*******************************************************************************
1199
1200 NAME
1201 CsrWifiSmeConnectionInfoGetCfmSend
1202
1203 DESCRIPTION
1204 This primitive reports the result of the request.
1205
1206 PARAMETERS
1207 queue - Destination Task Queue
1208 interfaceTag - Interface Identifier; unique identifier of an interface
1209 status - Reports the result of the request
1210 connectionInfo - Information about the current connection
1211
1212*******************************************************************************/
1213#define CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__) \
1214 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL); \
1215 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, dst__, src__); \
1216 msg__->interfaceTag = (interfaceTag__); \
1217 msg__->status = (status__); \
1218 msg__->connectionInfo = (connectionInfo__);
1219
1220#define CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__) \
1221 { \
1222 CsrWifiSmeConnectionInfoGetCfm *msg__; \
1223 CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__); \
1224 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1225 }
1226
1227#define CsrWifiSmeConnectionInfoGetCfmSend(dst__, interfaceTag__, status__, connectionInfo__) \
1228 CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__)
1229
1230/*******************************************************************************
1231
1232 NAME
1233 CsrWifiSmeConnectionQualityIndSend
1234
1235 DESCRIPTION
1236 The SME sends this primitive to all the tasks that have registered to
1237 receive it whenever the value of the current connection quality
1238 parameters change by more than a certain configurable amount.
1239 The wireless manager application may configure the trigger thresholds for
1240 this indication using the field in smeConfig parameter of
1241 CSR_WIFI_SME_SME_CONFIG_SET_REQ.
1242 Connection quality messages can be suppressed by setting both thresholds
1243 to zero.
1244
1245 PARAMETERS
1246 queue - Destination Task Queue
1247 interfaceTag - Interface Identifier; unique identifier of an interface
1248 linkQuality - Indicates the quality of the link
1249
1250*******************************************************************************/
1251#define CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__) \
1252 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL); \
1253 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_QUALITY_IND, dst__, src__); \
1254 msg__->interfaceTag = (interfaceTag__); \
1255 msg__->linkQuality = (linkQuality__);
1256
1257#define CsrWifiSmeConnectionQualityIndSendTo(dst__, src__, interfaceTag__, linkQuality__) \
1258 { \
1259 CsrWifiSmeConnectionQualityInd *msg__; \
1260 CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__); \
1261 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1262 }
1263
1264#define CsrWifiSmeConnectionQualityIndSend(dst__, interfaceTag__, linkQuality__) \
1265 CsrWifiSmeConnectionQualityIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, linkQuality__)
1266
1267/*******************************************************************************
1268
1269 NAME
1270 CsrWifiSmeConnectionStatsGetReqSend
1271
1272 DESCRIPTION
1273 This primitive gets the value of the ConnectionStats parameter.
1274
1275 PARAMETERS
1276 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1277 interfaceTag - Interface Identifier; unique identifier of an interface
1278
1279*******************************************************************************/
1280#define CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__) \
1281 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetReq), GFP_KERNEL); \
1282 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, dst__, src__); \
1283 msg__->interfaceTag = (interfaceTag__);
1284
1285#define CsrWifiSmeConnectionStatsGetReqSendTo(dst__, src__, interfaceTag__) \
1286 { \
1287 CsrWifiSmeConnectionStatsGetReq *msg__; \
1288 CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__); \
1289 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1290 }
1291
1292#define CsrWifiSmeConnectionStatsGetReqSend(src__, interfaceTag__) \
1293 CsrWifiSmeConnectionStatsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
1294
1295/*******************************************************************************
1296
1297 NAME
1298 CsrWifiSmeConnectionStatsGetCfmSend
1299
1300 DESCRIPTION
1301 This primitive reports the result of the request.
1302
1303 PARAMETERS
1304 queue - Destination Task Queue
1305 interfaceTag - Interface Identifier; unique identifier of an interface
1306 status - Reports the result of the request
1307 connectionStats - Statistics for current connection.
1308
1309*******************************************************************************/
1310#define CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__) \
1311 msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL); \
1312 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, dst__, src__); \
1313 msg__->interfaceTag = (interfaceTag__); \
1314 msg__->status = (status__); \
1315 msg__->connectionStats = (connectionStats__);
1316
1317#define CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStats__) \
1318 { \
1319 CsrWifiSmeConnectionStatsGetCfm *msg__; \
1320 CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__); \
1321 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1322 }
1323
1324#define CsrWifiSmeConnectionStatsGetCfmSend(dst__, interfaceTag__, status__, connectionStats__) \
1325 CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionStats__)
1326
1327/*******************************************************************************
1328
1329 NAME
1330 CsrWifiSmeCoreDumpIndSend
1331
1332 DESCRIPTION
1333 The SME will send this primitive to all the tasks that have registered to
1334 receive Wi-Fi Chip core dump data.
1335 The core dump data may be fragmented and sent using more than one
1336 indication.
1337 To indicate that all the data has been sent, the last indication contains
1338 a 'length' of 0 and 'data' of NULL.
1339
1340 PARAMETERS
1341 queue - Destination Task Queue
1342 dataLength - Number of bytes in the buffer pointed to by 'data'
1343 data - Pointer to the buffer containing 'dataLength' bytes of core
1344 dump data
1345
1346*******************************************************************************/
1347#define CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__) \
1348 msg__ = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL); \
1349 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CORE_DUMP_IND, dst__, src__); \
1350 msg__->dataLength = (dataLength__); \
1351 msg__->data = (data__);
1352
1353#define CsrWifiSmeCoreDumpIndSendTo(dst__, src__, dataLength__, data__) \
1354 { \
1355 CsrWifiSmeCoreDumpInd *msg__; \
1356 CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__); \
1357 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1358 }
1359
1360#define CsrWifiSmeCoreDumpIndSend(dst__, dataLength__, data__) \
1361 CsrWifiSmeCoreDumpIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, dataLength__, data__)
1362
1363/*******************************************************************************
1364
1365 NAME
1366 CsrWifiSmeDeactivateReqSend
1367
1368 DESCRIPTION
1369 The WMA sends this primitive to deactivate the SME.
1370
1371 PARAMETERS
1372 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1373
1374*******************************************************************************/
1375#define CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__) \
1376 msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateReq), GFP_KERNEL); \
1377 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_REQ, dst__, src__);
1378
1379#define CsrWifiSmeDeactivateReqSendTo(dst__, src__) \
1380 { \
1381 CsrWifiSmeDeactivateReq *msg__; \
1382 CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__); \
1383 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1384 }
1385
1386#define CsrWifiSmeDeactivateReqSend(src__) \
1387 CsrWifiSmeDeactivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
1388
1389/*******************************************************************************
1390
1391 NAME
1392 CsrWifiSmeDeactivateCfmSend
1393
1394 DESCRIPTION
1395 The SME sends this primitive when the deactivation is complete.
1396 The WMA cannot send any more primitives until it actives the SME again
1397 sending another CSR_WIFI_SME_ACTIVATE_REQ.
1398
1399 PARAMETERS
1400 queue - Destination Task Queue
1401 status - Reports the result of the request
1402
1403*******************************************************************************/
1404#define CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__) \
1405 msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateCfm), GFP_KERNEL); \
1406 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_CFM, dst__, src__); \
1407 msg__->status = (status__);
1408
1409#define CsrWifiSmeDeactivateCfmSendTo(dst__, src__, status__) \
1410 { \
1411 CsrWifiSmeDeactivateCfm *msg__; \
1412 CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__); \
1413 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1414 }
1415
1416#define CsrWifiSmeDeactivateCfmSend(dst__, status__) \
1417 CsrWifiSmeDeactivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
1418
1419/*******************************************************************************
1420
1421 NAME
1422 CsrWifiSmeDisconnectReqSend
1423
1424 DESCRIPTION
1425 The wireless manager application may disconnect from the current network
1426 by calling this primitive
1427
1428 PARAMETERS
1429 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1430 interfaceTag - Interface Identifier; unique identifier of an interface
1431
1432*******************************************************************************/
1433#define CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__) \
1434 msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectReq), GFP_KERNEL); \
1435 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_REQ, dst__, src__); \
1436 msg__->interfaceTag = (interfaceTag__);
1437
1438#define CsrWifiSmeDisconnectReqSendTo(dst__, src__, interfaceTag__) \
1439 { \
1440 CsrWifiSmeDisconnectReq *msg__; \
1441 CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__); \
1442 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1443 }
1444
1445#define CsrWifiSmeDisconnectReqSend(src__, interfaceTag__) \
1446 CsrWifiSmeDisconnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
1447
1448/*******************************************************************************
1449
1450 NAME
1451 CsrWifiSmeDisconnectCfmSend
1452
1453 DESCRIPTION
1454 On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a
1455 disconnect operation, sending a CsrWifiSmeMediaStatusInd with
1456 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when
1457 disconnection is complete.
1458
1459 PARAMETERS
1460 queue - Destination Task Queue
1461 interfaceTag - Interface Identifier; unique identifier of an interface
1462 status - Reports the result of the request
1463
1464*******************************************************************************/
1465#define CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
1466 msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL); \
1467 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_CFM, dst__, src__); \
1468 msg__->interfaceTag = (interfaceTag__); \
1469 msg__->status = (status__);
1470
1471#define CsrWifiSmeDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__) \
1472 { \
1473 CsrWifiSmeDisconnectCfm *msg__; \
1474 CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
1475 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1476 }
1477
1478#define CsrWifiSmeDisconnectCfmSend(dst__, interfaceTag__, status__) \
1479 CsrWifiSmeDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
1480
1481/*******************************************************************************
1482
1483 NAME
1484 CsrWifiSmeErrorIndSend
1485
1486 DESCRIPTION
1487 Important error message indicating a error of some importance
1488
1489 PARAMETERS
1490 queue - Destination Task Queue
1491 errorMessage - Contains the error message.
1492
1493*******************************************************************************/
1494#define CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__) \
1495 msg__ = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL); \
1496 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ERROR_IND, dst__, src__); \
1497 msg__->errorMessage = (errorMessage__);
1498
1499#define CsrWifiSmeErrorIndSendTo(dst__, src__, errorMessage__) \
1500 { \
1501 CsrWifiSmeErrorInd *msg__; \
1502 CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__); \
1503 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1504 }
1505
1506#define CsrWifiSmeErrorIndSend(dst__, errorMessage__) \
1507 CsrWifiSmeErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, errorMessage__)
1508
1509/*******************************************************************************
1510
1511 NAME
1512 CsrWifiSmeEventMaskSetReqSend
1513
1514 DESCRIPTION
1515 The wireless manager application may register with the SME to receive
1516 notification of interesting events. Indications will be sent only if the
1517 wireless manager explicitly registers to be notified of that event.
1518 indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask.
1519
1520 PARAMETERS
1521 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1522 indMask - Set mask with values from CsrWifiSmeIndications
1523
1524*******************************************************************************/
1525#define CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \
1526 msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetReq), GFP_KERNEL); \
1527 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_REQ, dst__, src__); \
1528 msg__->indMask = (indMask__);
1529
1530#define CsrWifiSmeEventMaskSetReqSendTo(dst__, src__, indMask__) \
1531 { \
1532 CsrWifiSmeEventMaskSetReq *msg__; \
1533 CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \
1534 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1535 }
1536
1537#define CsrWifiSmeEventMaskSetReqSend(src__, indMask__) \
1538 CsrWifiSmeEventMaskSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, indMask__)
1539
1540/*******************************************************************************
1541
1542 NAME
1543 CsrWifiSmeEventMaskSetCfmSend
1544
1545 DESCRIPTION
1546 The SME calls the primitive to report the result of the request
1547 primitive.
1548
1549 PARAMETERS
1550 queue - Destination Task Queue
1551 status - Reports the result of the request
1552
1553*******************************************************************************/
1554#define CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \
1555 msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetCfm), GFP_KERNEL); \
1556 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_CFM, dst__, src__); \
1557 msg__->status = (status__);
1558
1559#define CsrWifiSmeEventMaskSetCfmSendTo(dst__, src__, status__) \
1560 { \
1561 CsrWifiSmeEventMaskSetCfm *msg__; \
1562 CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \
1563 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1564 }
1565
1566#define CsrWifiSmeEventMaskSetCfmSend(dst__, status__) \
1567 CsrWifiSmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
1568
1569/*******************************************************************************
1570
1571 NAME
1572 CsrWifiSmeHostConfigGetReqSend
1573
1574 DESCRIPTION
1575 This primitive gets the value of the hostConfig parameter.
1576
1577 PARAMETERS
1578 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1579 interfaceTag - Interface Identifier; unique identifier of an interface
1580
1581*******************************************************************************/
1582#define CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
1583 msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetReq), GFP_KERNEL); \
1584 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_REQ, dst__, src__); \
1585 msg__->interfaceTag = (interfaceTag__);
1586
1587#define CsrWifiSmeHostConfigGetReqSendTo(dst__, src__, interfaceTag__) \
1588 { \
1589 CsrWifiSmeHostConfigGetReq *msg__; \
1590 CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
1591 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1592 }
1593
1594#define CsrWifiSmeHostConfigGetReqSend(src__, interfaceTag__) \
1595 CsrWifiSmeHostConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
1596
1597/*******************************************************************************
1598
1599 NAME
1600 CsrWifiSmeHostConfigGetCfmSend
1601
1602 DESCRIPTION
1603 This primitive reports the result of the request.
1604
1605 PARAMETERS
1606 queue - Destination Task Queue
1607 interfaceTag - Interface Identifier; unique identifier of an interface
1608 status - Reports the result of the request
1609 hostConfig - Current host power state.
1610
1611*******************************************************************************/
1612#define CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__) \
1613 msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL); \
1614 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_CFM, dst__, src__); \
1615 msg__->interfaceTag = (interfaceTag__); \
1616 msg__->status = (status__); \
1617 msg__->hostConfig = (hostConfig__);
1618
1619#define CsrWifiSmeHostConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, hostConfig__) \
1620 { \
1621 CsrWifiSmeHostConfigGetCfm *msg__; \
1622 CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__); \
1623 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1624 }
1625
1626#define CsrWifiSmeHostConfigGetCfmSend(dst__, interfaceTag__, status__, hostConfig__) \
1627 CsrWifiSmeHostConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, hostConfig__)
1628
1629/*******************************************************************************
1630
1631 NAME
1632 CsrWifiSmeHostConfigSetReqSend
1633
1634 DESCRIPTION
1635 This primitive sets the value of the hostConfig parameter.
1636
1637 PARAMETERS
1638 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1639 interfaceTag - Interface Identifier; unique identifier of an interface
1640 hostConfig - Communicates a change of host power state (for example, on
1641 mains power, on battery power etc) and of the periodicity of
1642 traffic data
1643
1644*******************************************************************************/
1645#define CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__) \
1646 msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL); \
1647 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_REQ, dst__, src__); \
1648 msg__->interfaceTag = (interfaceTag__); \
1649 msg__->hostConfig = (hostConfig__);
1650
1651#define CsrWifiSmeHostConfigSetReqSendTo(dst__, src__, interfaceTag__, hostConfig__) \
1652 { \
1653 CsrWifiSmeHostConfigSetReq *msg__; \
1654 CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__); \
1655 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1656 }
1657
1658#define CsrWifiSmeHostConfigSetReqSend(src__, interfaceTag__, hostConfig__) \
1659 CsrWifiSmeHostConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, hostConfig__)
1660
1661/*******************************************************************************
1662
1663 NAME
1664 CsrWifiSmeHostConfigSetCfmSend
1665
1666 DESCRIPTION
1667 This primitive reports the result of the request.
1668
1669 PARAMETERS
1670 queue - Destination Task Queue
1671 interfaceTag - Interface Identifier; unique identifier of an interface
1672 status - Reports the result of the request
1673
1674*******************************************************************************/
1675#define CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
1676 msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL); \
1677 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_CFM, dst__, src__); \
1678 msg__->interfaceTag = (interfaceTag__); \
1679 msg__->status = (status__);
1680
1681#define CsrWifiSmeHostConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
1682 { \
1683 CsrWifiSmeHostConfigSetCfm *msg__; \
1684 CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
1685 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1686 }
1687
1688#define CsrWifiSmeHostConfigSetCfmSend(dst__, interfaceTag__, status__) \
1689 CsrWifiSmeHostConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
1690
1691/*******************************************************************************
1692
1693 NAME
1694 CsrWifiSmeIbssStationIndSend
1695
1696 DESCRIPTION
1697 The SME will send this primitive to indicate that a station has joined or
1698 left the ad-hoc network.
1699
1700 PARAMETERS
1701 queue - Destination Task Queue
1702 address - MAC address of the station that has joined or left
1703 isconnected - TRUE if the station joined, FALSE if the station left
1704
1705*******************************************************************************/
1706#define CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__) \
1707 msg__ = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL); \
1708 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_IBSS_STATION_IND, dst__, src__); \
1709 msg__->address = (address__); \
1710 msg__->isconnected = (isconnected__);
1711
1712#define CsrWifiSmeIbssStationIndSendTo(dst__, src__, address__, isconnected__) \
1713 { \
1714 CsrWifiSmeIbssStationInd *msg__; \
1715 CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__); \
1716 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1717 }
1718
1719#define CsrWifiSmeIbssStationIndSend(dst__, address__, isconnected__) \
1720 CsrWifiSmeIbssStationIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__, isconnected__)
1721
1722/*******************************************************************************
1723
1724 NAME
1725 CsrWifiSmeInfoIndSend
1726
1727 DESCRIPTION
1728 Message indicating a some info about current activity. Mostly of interest
1729 in testing but may be useful in the field.
1730
1731 PARAMETERS
1732 queue - Destination Task Queue
1733 infoMessage - Contains the message.
1734
1735*******************************************************************************/
1736#define CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__) \
1737 msg__ = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL); \
1738 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INFO_IND, dst__, src__); \
1739 msg__->infoMessage = (infoMessage__);
1740
1741#define CsrWifiSmeInfoIndSendTo(dst__, src__, infoMessage__) \
1742 { \
1743 CsrWifiSmeInfoInd *msg__; \
1744 CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__); \
1745 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1746 }
1747
1748#define CsrWifiSmeInfoIndSend(dst__, infoMessage__) \
1749 CsrWifiSmeInfoIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, infoMessage__)
1750
1751/*******************************************************************************
1752
1753 NAME
1754 CsrWifiSmeInterfaceCapabilityGetReqSend
1755
1756 DESCRIPTION
1757 The Wireless Manager calls this primitive to ask the SME for the
1758 capabilities of the supported interfaces
1759
1760 PARAMETERS
1761 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1762
1763*******************************************************************************/
1764#define CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__) \
1765 msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetReq), GFP_KERNEL); \
1766 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, dst__, src__);
1767
1768#define CsrWifiSmeInterfaceCapabilityGetReqSendTo(dst__, src__) \
1769 { \
1770 CsrWifiSmeInterfaceCapabilityGetReq *msg__; \
1771 CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__); \
1772 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1773 }
1774
1775#define CsrWifiSmeInterfaceCapabilityGetReqSend(src__) \
1776 CsrWifiSmeInterfaceCapabilityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
1777
1778/*******************************************************************************
1779
1780 NAME
1781 CsrWifiSmeInterfaceCapabilityGetCfmSend
1782
1783 DESCRIPTION
1784 This primitive reports the result of the request.
1785
1786 PARAMETERS
1787 queue - Destination Task Queue
1788 status - Result of the request
1789 numInterfaces - Number of the interfaces supported
1790 capBitmap - Points to the list of capabilities bitmaps provided for each
1791 interface.
1792 The bits represent the following capabilities:
1793 -bits 7 to 4-Reserved
1794 -bit 3-AMP
1795 -bit 2-P2P
1796 -bit 1-AP
1797 -bit 0-STA
1798
1799*******************************************************************************/
1800#define CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__) \
1801 msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL); \
1802 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, dst__, src__); \
1803 msg__->status = (status__); \
1804 msg__->numInterfaces = (numInterfaces__); \
1805 memcpy(msg__->capBitmap, (capBitmap__), sizeof(u8) * 2);
1806
1807#define CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, src__, status__, numInterfaces__, capBitmap__) \
1808 { \
1809 CsrWifiSmeInterfaceCapabilityGetCfm *msg__; \
1810 CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__); \
1811 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1812 }
1813
1814#define CsrWifiSmeInterfaceCapabilityGetCfmSend(dst__, status__, numInterfaces__, capBitmap__) \
1815 CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, numInterfaces__, capBitmap__)
1816
1817/*******************************************************************************
1818
1819 NAME
1820 CsrWifiSmeKeyReqSend
1821
1822 DESCRIPTION
1823 The wireless manager application calls this primitive to add or remove
1824 keys that the chip should use for encryption of data.
1825 The interface allows the wireless manager application to add and remove
1826 keys according to the specified action.
1827
1828 PARAMETERS
1829 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1830 interfaceTag - Interface Identifier; unique identifier of an interface
1831 action - The value of the CsrWifiSmeListAction parameter instructs the
1832 driver to modify or provide the list of keys.
1833 CSR_WIFI_SME_LIST_ACTION_GET is not supported here.
1834 key - Key to be added or removed
1835
1836*******************************************************************************/
1837#define CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__) \
1838 msg__ = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL); \
1839 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_REQ, dst__, src__); \
1840 msg__->interfaceTag = (interfaceTag__); \
1841 msg__->action = (action__); \
1842 msg__->key = (key__);
1843
1844#define CsrWifiSmeKeyReqSendTo(dst__, src__, interfaceTag__, action__, key__) \
1845 { \
1846 CsrWifiSmeKeyReq *msg__; \
1847 CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__); \
1848 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1849 }
1850
1851#define CsrWifiSmeKeyReqSend(src__, interfaceTag__, action__, key__) \
1852 CsrWifiSmeKeyReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, key__)
1853
1854/*******************************************************************************
1855
1856 NAME
1857 CsrWifiSmeKeyCfmSend
1858
1859 DESCRIPTION
1860 The SME calls the primitive to report the result of the request
1861 primitive.
1862
1863 PARAMETERS
1864 queue - Destination Task Queue
1865 interfaceTag - Interface Identifier; unique identifier of an interface
1866 status - Reports the result of the request
1867 action - Action in the request
1868 keyType - Type of the key added/deleted
1869 peerMacAddress - Peer MAC Address of the key added/deleted
1870
1871*******************************************************************************/
1872#define CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
1873 msg__ = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL); \
1874 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_CFM, dst__, src__); \
1875 msg__->interfaceTag = (interfaceTag__); \
1876 msg__->status = (status__); \
1877 msg__->action = (action__); \
1878 msg__->keyType = (keyType__); \
1879 msg__->peerMacAddress = (peerMacAddress__);
1880
1881#define CsrWifiSmeKeyCfmSendTo(dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
1882 { \
1883 CsrWifiSmeKeyCfm *msg__; \
1884 CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__); \
1885 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1886 }
1887
1888#define CsrWifiSmeKeyCfmSend(dst__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
1889 CsrWifiSmeKeyCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, keyType__, peerMacAddress__)
1890
1891/*******************************************************************************
1892
1893 NAME
1894 CsrWifiSmeLinkQualityGetReqSend
1895
1896 DESCRIPTION
1897 This primitive gets the value of the LinkQuality parameter.
1898
1899 PARAMETERS
1900 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
1901 interfaceTag - Interface Identifier; unique identifier of an interface
1902
1903*******************************************************************************/
1904#define CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__) \
1905 msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetReq), GFP_KERNEL); \
1906 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_REQ, dst__, src__); \
1907 msg__->interfaceTag = (interfaceTag__);
1908
1909#define CsrWifiSmeLinkQualityGetReqSendTo(dst__, src__, interfaceTag__) \
1910 { \
1911 CsrWifiSmeLinkQualityGetReq *msg__; \
1912 CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__); \
1913 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
1914 }
1915
1916#define CsrWifiSmeLinkQualityGetReqSend(src__, interfaceTag__) \
1917 CsrWifiSmeLinkQualityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
1918
1919/*******************************************************************************
1920
1921 NAME
1922 CsrWifiSmeLinkQualityGetCfmSend
1923
1924 DESCRIPTION
1925 This primitive reports the result of the request.
1926
1927 PARAMETERS
1928 queue - Destination Task Queue
1929 interfaceTag - Interface Identifier; unique identifier of an interface
1930 status - Reports the result of the request
1931 linkQuality - Indicates the quality of the link
1932
1933*******************************************************************************/
1934#define CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__) \
1935 msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL); \
1936 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_CFM, dst__, src__); \
1937 msg__->interfaceTag = (interfaceTag__); \
1938 msg__->status = (status__); \
1939 msg__->linkQuality = (linkQuality__);
1940
1941#define CsrWifiSmeLinkQualityGetCfmSendTo(dst__, src__, interfaceTag__, status__, linkQuality__) \
1942 { \
1943 CsrWifiSmeLinkQualityGetCfm *msg__; \
1944 CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__); \
1945 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1946 }
1947
1948#define CsrWifiSmeLinkQualityGetCfmSend(dst__, interfaceTag__, status__, linkQuality__) \
1949 CsrWifiSmeLinkQualityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, linkQuality__)
1950
1951/*******************************************************************************
1952
1953 NAME
1954 CsrWifiSmeMediaStatusIndSend
1955
1956 DESCRIPTION
1957 The SME sends this primitive to all the tasks that have registered to
1958 receive it when a network connection is established, lost or has moved to
1959 another AP.
1960
1961 PARAMETERS
1962 queue - Destination Task Queue
1963 interfaceTag - Interface Identifier; unique identifier of an interface
1964 mediaStatus - Indicates the media status
1965 connectionInfo - This parameter is relevant only if the mediaStatus is
1966 CSR_WIFI_SME_MEDIA_STATUS_CONNECTED:
1967 it points to the connection information for the new network
1968 disassocReason - This parameter is relevant only if the mediaStatus is
1969 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
1970 if a disassociation has occurred it gives the reason of the
1971 disassociation
1972 deauthReason - This parameter is relevant only if the mediaStatus is
1973 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
1974 if a deauthentication has occurred it gives the reason of
1975 the deauthentication
1976
1977*******************************************************************************/
1978#define CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
1979 msg__ = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL); \
1980 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MEDIA_STATUS_IND, dst__, src__); \
1981 msg__->interfaceTag = (interfaceTag__); \
1982 msg__->mediaStatus = (mediaStatus__); \
1983 msg__->connectionInfo = (connectionInfo__); \
1984 msg__->disassocReason = (disassocReason__); \
1985 msg__->deauthReason = (deauthReason__);
1986
1987#define CsrWifiSmeMediaStatusIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
1988 { \
1989 CsrWifiSmeMediaStatusInd *msg__; \
1990 CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__); \
1991 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
1992 }
1993
1994#define CsrWifiSmeMediaStatusIndSend(dst__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
1995 CsrWifiSmeMediaStatusIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__)
1996
1997/*******************************************************************************
1998
1999 NAME
2000 CsrWifiSmeMibConfigGetReqSend
2001
2002 DESCRIPTION
2003 This primitive gets the value of the MibConfig parameter.
2004
2005 PARAMETERS
2006 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2007
2008*******************************************************************************/
2009#define CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__) \
2010 msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetReq), GFP_KERNEL); \
2011 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_REQ, dst__, src__);
2012
2013#define CsrWifiSmeMibConfigGetReqSendTo(dst__, src__) \
2014 { \
2015 CsrWifiSmeMibConfigGetReq *msg__; \
2016 CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__); \
2017 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2018 }
2019
2020#define CsrWifiSmeMibConfigGetReqSend(src__) \
2021 CsrWifiSmeMibConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
2022
2023/*******************************************************************************
2024
2025 NAME
2026 CsrWifiSmeMibConfigGetCfmSend
2027
2028 DESCRIPTION
2029 This primitive reports the result of the request.
2030
2031 PARAMETERS
2032 queue - Destination Task Queue
2033 status - Reports the result of the request
2034 mibConfig - Reports various IEEE 802.11 attributes as currently configured
2035
2036*******************************************************************************/
2037#define CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__) \
2038 msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL); \
2039 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_CFM, dst__, src__); \
2040 msg__->status = (status__); \
2041 msg__->mibConfig = (mibConfig__);
2042
2043#define CsrWifiSmeMibConfigGetCfmSendTo(dst__, src__, status__, mibConfig__) \
2044 { \
2045 CsrWifiSmeMibConfigGetCfm *msg__; \
2046 CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__); \
2047 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2048 }
2049
2050#define CsrWifiSmeMibConfigGetCfmSend(dst__, status__, mibConfig__) \
2051 CsrWifiSmeMibConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibConfig__)
2052
2053/*******************************************************************************
2054
2055 NAME
2056 CsrWifiSmeMibConfigSetReqSend
2057
2058 DESCRIPTION
2059 This primitive sets the value of the MibConfig parameter.
2060
2061 PARAMETERS
2062 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2063 mibConfig - Conveys the desired value of various IEEE 802.11 attributes as
2064 currently configured
2065
2066*******************************************************************************/
2067#define CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__) \
2068 msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL); \
2069 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_REQ, dst__, src__); \
2070 msg__->mibConfig = (mibConfig__);
2071
2072#define CsrWifiSmeMibConfigSetReqSendTo(dst__, src__, mibConfig__) \
2073 { \
2074 CsrWifiSmeMibConfigSetReq *msg__; \
2075 CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__); \
2076 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2077 }
2078
2079#define CsrWifiSmeMibConfigSetReqSend(src__, mibConfig__) \
2080 CsrWifiSmeMibConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibConfig__)
2081
2082/*******************************************************************************
2083
2084 NAME
2085 CsrWifiSmeMibConfigSetCfmSend
2086
2087 DESCRIPTION
2088 This primitive reports the result of the request.
2089
2090 PARAMETERS
2091 queue - Destination Task Queue
2092 status - Reports the result of the request
2093
2094*******************************************************************************/
2095#define CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__) \
2096 msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetCfm), GFP_KERNEL); \
2097 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_CFM, dst__, src__); \
2098 msg__->status = (status__);
2099
2100#define CsrWifiSmeMibConfigSetCfmSendTo(dst__, src__, status__) \
2101 { \
2102 CsrWifiSmeMibConfigSetCfm *msg__; \
2103 CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__); \
2104 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2105 }
2106
2107#define CsrWifiSmeMibConfigSetCfmSend(dst__, status__) \
2108 CsrWifiSmeMibConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
2109
2110/*******************************************************************************
2111
2112 NAME
2113 CsrWifiSmeMibGetCfmSend
2114
2115 DESCRIPTION
2116 The SME calls this primitive to return the requested MIB variable values.
2117
2118 PARAMETERS
2119 queue - Destination Task Queue
2120 status - Reports the result of the request
2121 mibAttributeLength - Length of mibAttribute
2122 mibAttribute - Points to the VarBind or VarBindList containing the
2123 names and values of the MIB variables requested
2124
2125*******************************************************************************/
2126#define CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
2127 msg__ = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL); \
2128 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_CFM, dst__, src__); \
2129 msg__->status = (status__); \
2130 msg__->mibAttributeLength = (mibAttributeLength__); \
2131 msg__->mibAttribute = (mibAttribute__);
2132
2133#define CsrWifiSmeMibGetCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
2134 { \
2135 CsrWifiSmeMibGetCfm *msg__; \
2136 CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \
2137 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2138 }
2139
2140#define CsrWifiSmeMibGetCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \
2141 CsrWifiSmeMibGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__)
2142
2143/*******************************************************************************
2144
2145 NAME
2146 CsrWifiSmeMibGetNextReqSend
2147
2148 DESCRIPTION
2149 To read a sequence of MIB parameters, for example a table, call this
2150 primitive to find the name of the next MIB variable
2151
2152 PARAMETERS
2153 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2154 mibAttributeLength - Length of mibAttribute
2155 mibAttribute - Points to a VarBind or VarBindList containing the
2156 name(s) of the MIB variable(s) to search from.
2157
2158*******************************************************************************/
2159#define CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
2160 msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL); \
2161 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_REQ, dst__, src__); \
2162 msg__->mibAttributeLength = (mibAttributeLength__); \
2163 msg__->mibAttribute = (mibAttribute__);
2164
2165#define CsrWifiSmeMibGetNextReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
2166 { \
2167 CsrWifiSmeMibGetNextReq *msg__; \
2168 CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
2169 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2170 }
2171
2172#define CsrWifiSmeMibGetNextReqSend(src__, mibAttributeLength__, mibAttribute__) \
2173 CsrWifiSmeMibGetNextReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
2174
2175/*******************************************************************************
2176
2177 NAME
2178 CsrWifiSmeMibGetNextCfmSend
2179
2180 DESCRIPTION
2181 The SME calls this primitive to return the requested MIB name(s).
2182 The wireless manager application can then read the value of the MIB
2183 variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided.
2184
2185 PARAMETERS
2186 queue - Destination Task Queue
2187 status - Reports the result of the request
2188 mibAttributeLength - Length of mibAttribute
2189 mibAttribute - Points to a VarBind or VarBindList containing the
2190 name(s) of the MIB variable(s) lexicographically
2191 following the name(s) given in the request
2192
2193*******************************************************************************/
2194#define CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
2195 msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL); \
2196 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_CFM, dst__, src__); \
2197 msg__->status = (status__); \
2198 msg__->mibAttributeLength = (mibAttributeLength__); \
2199 msg__->mibAttribute = (mibAttribute__);
2200
2201#define CsrWifiSmeMibGetNextCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
2202 { \
2203 CsrWifiSmeMibGetNextCfm *msg__; \
2204 CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \
2205 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2206 }
2207
2208#define CsrWifiSmeMibGetNextCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \
2209 CsrWifiSmeMibGetNextCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__)
2210
2211/*******************************************************************************
2212
2213 NAME
2214 CsrWifiSmeMibGetReqSend
2215
2216 DESCRIPTION
2217 The wireless manager application calls this primitive to retrieve one or
2218 more MIB variables.
2219
2220 PARAMETERS
2221 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2222 mibAttributeLength - Length of mibAttribute
2223 mibAttribute - Points to the VarBind or VarBindList containing the
2224 names of the MIB variables to be retrieved
2225
2226*******************************************************************************/
2227#define CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
2228 msg__ = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL); \
2229 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_REQ, dst__, src__); \
2230 msg__->mibAttributeLength = (mibAttributeLength__); \
2231 msg__->mibAttribute = (mibAttribute__);
2232
2233#define CsrWifiSmeMibGetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
2234 { \
2235 CsrWifiSmeMibGetReq *msg__; \
2236 CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
2237 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2238 }
2239
2240#define CsrWifiSmeMibGetReqSend(src__, mibAttributeLength__, mibAttribute__) \
2241 CsrWifiSmeMibGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
2242
2243/*******************************************************************************
2244
2245 NAME
2246 CsrWifiSmeMibSetReqSend
2247
2248 DESCRIPTION
2249 The SME provides raw access to the MIB on the chip, which may be used by
2250 some configuration or diagnostic utilities, but is not normally needed by
2251 the wireless manager application.
2252 The MIB access functions use BER encoded names (OID) of the MIB
2253 parameters and BER encoded values, as described in the chip Host
2254 Interface Protocol Specification.
2255 The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information
2256 Base Reference Guide'.
2257 The wireless manager application calls this primitive to set one or more
2258 MIB variables
2259
2260 PARAMETERS
2261 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2262 mibAttributeLength - Length of mibAttribute
2263 mibAttribute - Points to the VarBind or VarBindList containing the
2264 names and values of the MIB variables to set
2265
2266*******************************************************************************/
2267#define CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
2268 msg__ = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL); \
2269 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_REQ, dst__, src__); \
2270 msg__->mibAttributeLength = (mibAttributeLength__); \
2271 msg__->mibAttribute = (mibAttribute__);
2272
2273#define CsrWifiSmeMibSetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
2274 { \
2275 CsrWifiSmeMibSetReq *msg__; \
2276 CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
2277 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2278 }
2279
2280#define CsrWifiSmeMibSetReqSend(src__, mibAttributeLength__, mibAttribute__) \
2281 CsrWifiSmeMibSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
2282
2283/*******************************************************************************
2284
2285 NAME
2286 CsrWifiSmeMibSetCfmSend
2287
2288 DESCRIPTION
2289 The SME calls the primitive to report the result of the set primitive.
2290
2291 PARAMETERS
2292 queue - Destination Task Queue
2293 status - Reports the result of the request
2294
2295*******************************************************************************/
2296#define CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__) \
2297 msg__ = kmalloc(sizeof(CsrWifiSmeMibSetCfm), GFP_KERNEL); \
2298 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_CFM, dst__, src__); \
2299 msg__->status = (status__);
2300
2301#define CsrWifiSmeMibSetCfmSendTo(dst__, src__, status__) \
2302 { \
2303 CsrWifiSmeMibSetCfm *msg__; \
2304 CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__); \
2305 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2306 }
2307
2308#define CsrWifiSmeMibSetCfmSend(dst__, status__) \
2309 CsrWifiSmeMibSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
2310
2311/*******************************************************************************
2312
2313 NAME
2314 CsrWifiSmeMicFailureIndSend
2315
2316 DESCRIPTION
2317 The SME sends this primitive to all the tasks that have registered to
2318 receive it whenever the chip firmware reports a MIC failure.
2319
2320 PARAMETERS
2321 queue - Destination Task Queue
2322 interfaceTag - Interface Identifier; unique identifier of an interface
2323 secondFailure - TRUE if this indication is for a second failure in 60
2324 seconds
2325 count - The number of MIC failure events since the connection was
2326 established
2327 address - MAC address of the transmitter that caused the MIC failure
2328 keyType - Type of key for which the failure occurred
2329
2330*******************************************************************************/
2331#define CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
2332 msg__ = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL); \
2333 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIC_FAILURE_IND, dst__, src__); \
2334 msg__->interfaceTag = (interfaceTag__); \
2335 msg__->secondFailure = (secondFailure__); \
2336 msg__->count = (count__); \
2337 msg__->address = (address__); \
2338 msg__->keyType = (keyType__);
2339
2340#define CsrWifiSmeMicFailureIndSendTo(dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
2341 { \
2342 CsrWifiSmeMicFailureInd *msg__; \
2343 CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__); \
2344 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2345 }
2346
2347#define CsrWifiSmeMicFailureIndSend(dst__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
2348 CsrWifiSmeMicFailureIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, secondFailure__, count__, address__, keyType__)
2349
2350/*******************************************************************************
2351
2352 NAME
2353 CsrWifiSmeMulticastAddressReqSend
2354
2355 DESCRIPTION
2356 The wireless manager application calls this primitive to specify the
2357 multicast addresses which the chip should recognise. The interface allows
2358 the wireless manager application to query, add, remove and flush the
2359 multicast addresses for the network interface according to the specified
2360 action.
2361
2362 PARAMETERS
2363 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2364 interfaceTag - Interface Identifier; unique identifier of an interface
2365 action - The value of the CsrWifiSmeListAction parameter
2366 instructs the driver to modify or provide the list of
2367 MAC addresses.
2368 setAddressesCount - Number of MAC addresses sent with the primitive
2369 setAddresses - Pointer to the list of MAC Addresses sent with the
2370 primitive, set to NULL if none is sent.
2371
2372*******************************************************************************/
2373#define CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
2374 msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL); \
2375 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, dst__, src__); \
2376 msg__->interfaceTag = (interfaceTag__); \
2377 msg__->action = (action__); \
2378 msg__->setAddressesCount = (setAddressesCount__); \
2379 msg__->setAddresses = (setAddresses__);
2380
2381#define CsrWifiSmeMulticastAddressReqSendTo(dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
2382 { \
2383 CsrWifiSmeMulticastAddressReq *msg__; \
2384 CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \
2385 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2386 }
2387
2388#define CsrWifiSmeMulticastAddressReqSend(src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
2389 CsrWifiSmeMulticastAddressReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__)
2390
2391/*******************************************************************************
2392
2393 NAME
2394 CsrWifiSmeMulticastAddressCfmSend
2395
2396 DESCRIPTION
2397 The SME will call this primitive when the operation is complete. For a
2398 GET action, this primitive reports the current list of MAC addresses.
2399
2400 PARAMETERS
2401 queue - Destination Task Queue
2402 interfaceTag - Interface Identifier; unique identifier of an interface
2403 status - Reports the result of the request
2404 action - Action in the request
2405 getAddressesCount - This parameter is only relevant if action is
2406 CSR_WIFI_SME_LIST_ACTION_GET:
2407 number of MAC addresses sent with the primitive
2408 getAddresses - Pointer to the list of MAC Addresses sent with the
2409 primitive, set to NULL if none is sent.
2410
2411*******************************************************************************/
2412#define CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
2413 msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL); \
2414 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, dst__, src__); \
2415 msg__->interfaceTag = (interfaceTag__); \
2416 msg__->status = (status__); \
2417 msg__->action = (action__); \
2418 msg__->getAddressesCount = (getAddressesCount__); \
2419 msg__->getAddresses = (getAddresses__);
2420
2421#define CsrWifiSmeMulticastAddressCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
2422 { \
2423 CsrWifiSmeMulticastAddressCfm *msg__; \
2424 CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__); \
2425 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2426 }
2427
2428#define CsrWifiSmeMulticastAddressCfmSend(dst__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
2429 CsrWifiSmeMulticastAddressCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__)
2430
2431/*******************************************************************************
2432
2433 NAME
2434 CsrWifiSmePacketFilterSetReqSend
2435
2436 DESCRIPTION
2437 The wireless manager application should call this primitive to enable or
2438 disable filtering of broadcast packets: uninteresting broadcast packets
2439 will be dropped by the Wi-Fi chip, instead of passing them up to the
2440 host.
2441 This has the advantage of saving power in the host application processor
2442 as it removes the need to process unwanted packets.
2443 All broadcast packets are filtered according to the filter and the filter
2444 mode provided, except ARP packets, which are filtered using
2445 arpFilterAddress.
2446 Filters are not cumulative: only the parameters specified in the most
2447 recent successful request are significant.
2448 For more information, see 'UniFi Firmware API Specification'.
2449
2450 PARAMETERS
2451 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2452 interfaceTag - Interface Identifier; unique identifier of an interface
2453 filterLength - Length of the filter in bytes.
2454 filterLength=0 disables the filter previously set
2455 filter - Points to the first byte of the filter provided, if any.
2456 This shall include zero or more instance of the
2457 information elements of one of these types
2458 * Traffic Classification (TCLAS) elements
2459 * WMM-SA TCLAS elements
2460 mode - Specifies whether the filter selects or excludes packets
2461 matching the filter
2462 arpFilterAddress - IPv4 address to be used for filtering the ARP packets.
2463 * If the specified address is the IPv4 broadcast address
2464 (255.255.255.255), all ARP packets are reported to the
2465 host,
2466 * If the specified address is NOT the IPv4 broadcast
2467 address, only ARP packets with the specified address in
2468 the Source or Target Protocol Address fields are reported
2469 to the host
2470
2471*******************************************************************************/
2472#define CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
2473 msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL); \
2474 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_REQ, dst__, src__); \
2475 msg__->interfaceTag = (interfaceTag__); \
2476 msg__->filterLength = (filterLength__); \
2477 msg__->filter = (filter__); \
2478 msg__->mode = (mode__); \
2479 msg__->arpFilterAddress = (arpFilterAddress__);
2480
2481#define CsrWifiSmePacketFilterSetReqSendTo(dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
2482 { \
2483 CsrWifiSmePacketFilterSetReq *msg__; \
2484 CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__); \
2485 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2486 }
2487
2488#define CsrWifiSmePacketFilterSetReqSend(src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
2489 CsrWifiSmePacketFilterSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__)
2490
2491/*******************************************************************************
2492
2493 NAME
2494 CsrWifiSmePacketFilterSetCfmSend
2495
2496 DESCRIPTION
2497 The SME calls the primitive to report the result of the set primitive.
2498
2499 PARAMETERS
2500 queue - Destination Task Queue
2501 interfaceTag - Interface Identifier; unique identifier of an interface
2502 status - Reports the result of the request
2503
2504*******************************************************************************/
2505#define CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
2506 msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL); \
2507 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_CFM, dst__, src__); \
2508 msg__->interfaceTag = (interfaceTag__); \
2509 msg__->status = (status__);
2510
2511#define CsrWifiSmePacketFilterSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
2512 { \
2513 CsrWifiSmePacketFilterSetCfm *msg__; \
2514 CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
2515 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2516 }
2517
2518#define CsrWifiSmePacketFilterSetCfmSend(dst__, interfaceTag__, status__) \
2519 CsrWifiSmePacketFilterSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
2520
2521/*******************************************************************************
2522
2523 NAME
2524 CsrWifiSmePermanentMacAddressGetReqSend
2525
2526 DESCRIPTION
2527 This primitive retrieves the MAC address stored in EEPROM
2528
2529 PARAMETERS
2530 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2531
2532*******************************************************************************/
2533#define CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__) \
2534 msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetReq), GFP_KERNEL); \
2535 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, dst__, src__);
2536
2537#define CsrWifiSmePermanentMacAddressGetReqSendTo(dst__, src__) \
2538 { \
2539 CsrWifiSmePermanentMacAddressGetReq *msg__; \
2540 CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__); \
2541 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2542 }
2543
2544#define CsrWifiSmePermanentMacAddressGetReqSend(src__) \
2545 CsrWifiSmePermanentMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
2546
2547/*******************************************************************************
2548
2549 NAME
2550 CsrWifiSmePermanentMacAddressGetCfmSend
2551
2552 DESCRIPTION
2553 This primitive reports the result of the request.
2554
2555 PARAMETERS
2556 queue - Destination Task Queue
2557 status - Reports the result of the request
2558 permanentMacAddress - MAC address stored in the EEPROM
2559
2560*******************************************************************************/
2561#define CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__) \
2562 msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL); \
2563 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, dst__, src__); \
2564 msg__->status = (status__); \
2565 msg__->permanentMacAddress = (permanentMacAddress__);
2566
2567#define CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, src__, status__, permanentMacAddress__) \
2568 { \
2569 CsrWifiSmePermanentMacAddressGetCfm *msg__; \
2570 CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__); \
2571 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2572 }
2573
2574#define CsrWifiSmePermanentMacAddressGetCfmSend(dst__, status__, permanentMacAddress__) \
2575 CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, permanentMacAddress__)
2576
2577/*******************************************************************************
2578
2579 NAME
2580 CsrWifiSmePmkidCandidateListIndSend
2581
2582 DESCRIPTION
2583 The SME will send this primitive to all the tasks that have registered to
2584 receive it when a new network supporting preauthentication and/or PMK
2585 caching is seen.
2586
2587 PARAMETERS
2588 queue - Destination Task Queue
2589 interfaceTag - Interface Identifier; unique identifier of an
2590 interface
2591 pmkidCandidatesCount - Number of PMKID candidates provided
2592 pmkidCandidates - Points to the first PMKID candidate
2593
2594*******************************************************************************/
2595#define CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
2596 msg__ = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL); \
2597 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, dst__, src__); \
2598 msg__->interfaceTag = (interfaceTag__); \
2599 msg__->pmkidCandidatesCount = (pmkidCandidatesCount__); \
2600 msg__->pmkidCandidates = (pmkidCandidates__);
2601
2602#define CsrWifiSmePmkidCandidateListIndSendTo(dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
2603 { \
2604 CsrWifiSmePmkidCandidateListInd *msg__; \
2605 CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__); \
2606 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2607 }
2608
2609#define CsrWifiSmePmkidCandidateListIndSend(dst__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
2610 CsrWifiSmePmkidCandidateListIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__)
2611
2612/*******************************************************************************
2613
2614 NAME
2615 CsrWifiSmePmkidReqSend
2616
2617 DESCRIPTION
2618 The wireless manager application calls this primitive to request an
2619 operation on the SME PMKID list.
2620 The action argument specifies the operation to perform.
2621 When the connection is complete, the wireless manager application may
2622 then send and receive EAPOL packets to complete WPA or WPA2
2623 authentication if appropriate.
2624 The wireless manager application can then pass the resulting encryption
2625 keys using this primitive.
2626
2627 PARAMETERS
2628 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2629 interfaceTag - Interface Identifier; unique identifier of an interface
2630 action - The value of the CsrWifiSmeListAction parameter instructs
2631 the driver to modify or provide the list of PMKIDs.
2632 setPmkidsCount - Number of PMKIDs sent with the primitive
2633 setPmkids - Pointer to the list of PMKIDs sent with the primitive, set
2634 to NULL if none is sent.
2635
2636*******************************************************************************/
2637#define CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
2638 msg__ = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL); \
2639 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_REQ, dst__, src__); \
2640 msg__->interfaceTag = (interfaceTag__); \
2641 msg__->action = (action__); \
2642 msg__->setPmkidsCount = (setPmkidsCount__); \
2643 msg__->setPmkids = (setPmkids__);
2644
2645#define CsrWifiSmePmkidReqSendTo(dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
2646 { \
2647 CsrWifiSmePmkidReq *msg__; \
2648 CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__); \
2649 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2650 }
2651
2652#define CsrWifiSmePmkidReqSend(src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
2653 CsrWifiSmePmkidReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__)
2654
2655/*******************************************************************************
2656
2657 NAME
2658 CsrWifiSmePmkidCfmSend
2659
2660 DESCRIPTION
2661 The SME will call this primitive when the operation is complete. For a
2662 GET action, this primitive reports the current list of PMKIDs
2663
2664 PARAMETERS
2665 queue - Destination Task Queue
2666 interfaceTag - Interface Identifier; unique identifier of an interface
2667 status - Reports the result of the request
2668 action - Action in the request
2669 getPmkidsCount - This parameter is only relevant if action is
2670 CSR_WIFI_SME_LIST_ACTION_GET:
2671 number of PMKIDs sent with the primitive
2672 getPmkids - Pointer to the list of PMKIDs sent with the primitive, set
2673 to NULL if none is sent.
2674
2675*******************************************************************************/
2676#define CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
2677 msg__ = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL); \
2678 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CFM, dst__, src__); \
2679 msg__->interfaceTag = (interfaceTag__); \
2680 msg__->status = (status__); \
2681 msg__->action = (action__); \
2682 msg__->getPmkidsCount = (getPmkidsCount__); \
2683 msg__->getPmkids = (getPmkids__);
2684
2685#define CsrWifiSmePmkidCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
2686 { \
2687 CsrWifiSmePmkidCfm *msg__; \
2688 CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__); \
2689 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2690 }
2691
2692#define CsrWifiSmePmkidCfmSend(dst__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
2693 CsrWifiSmePmkidCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__)
2694
2695/*******************************************************************************
2696
2697 NAME
2698 CsrWifiSmePowerConfigGetReqSend
2699
2700 DESCRIPTION
2701 This primitive gets the value of the PowerConfig parameter.
2702
2703 PARAMETERS
2704 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2705
2706*******************************************************************************/
2707#define CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__) \
2708 msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetReq), GFP_KERNEL); \
2709 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_REQ, dst__, src__);
2710
2711#define CsrWifiSmePowerConfigGetReqSendTo(dst__, src__) \
2712 { \
2713 CsrWifiSmePowerConfigGetReq *msg__; \
2714 CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__); \
2715 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2716 }
2717
2718#define CsrWifiSmePowerConfigGetReqSend(src__) \
2719 CsrWifiSmePowerConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
2720
2721/*******************************************************************************
2722
2723 NAME
2724 CsrWifiSmePowerConfigGetCfmSend
2725
2726 DESCRIPTION
2727 This primitive reports the result of the request.
2728
2729 PARAMETERS
2730 queue - Destination Task Queue
2731 status - Reports the result of the request
2732 powerConfig - Returns the current parameters for the power configuration of
2733 the firmware
2734
2735*******************************************************************************/
2736#define CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__) \
2737 msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL); \
2738 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_CFM, dst__, src__); \
2739 msg__->status = (status__); \
2740 msg__->powerConfig = (powerConfig__);
2741
2742#define CsrWifiSmePowerConfigGetCfmSendTo(dst__, src__, status__, powerConfig__) \
2743 { \
2744 CsrWifiSmePowerConfigGetCfm *msg__; \
2745 CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__); \
2746 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2747 }
2748
2749#define CsrWifiSmePowerConfigGetCfmSend(dst__, status__, powerConfig__) \
2750 CsrWifiSmePowerConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, powerConfig__)
2751
2752/*******************************************************************************
2753
2754 NAME
2755 CsrWifiSmePowerConfigSetReqSend
2756
2757 DESCRIPTION
2758 This primitive sets the value of the PowerConfig parameter.
2759
2760 PARAMETERS
2761 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2762 powerConfig - Power saving configuration
2763
2764*******************************************************************************/
2765#define CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__) \
2766 msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL); \
2767 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_REQ, dst__, src__); \
2768 msg__->powerConfig = (powerConfig__);
2769
2770#define CsrWifiSmePowerConfigSetReqSendTo(dst__, src__, powerConfig__) \
2771 { \
2772 CsrWifiSmePowerConfigSetReq *msg__; \
2773 CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__); \
2774 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2775 }
2776
2777#define CsrWifiSmePowerConfigSetReqSend(src__, powerConfig__) \
2778 CsrWifiSmePowerConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, powerConfig__)
2779
2780/*******************************************************************************
2781
2782 NAME
2783 CsrWifiSmePowerConfigSetCfmSend
2784
2785 DESCRIPTION
2786 This primitive reports the result of the request.
2787
2788 PARAMETERS
2789 queue - Destination Task Queue
2790 status - Reports the result of the request
2791
2792*******************************************************************************/
2793#define CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__) \
2794 msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetCfm), GFP_KERNEL); \
2795 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_CFM, dst__, src__); \
2796 msg__->status = (status__);
2797
2798#define CsrWifiSmePowerConfigSetCfmSendTo(dst__, src__, status__) \
2799 { \
2800 CsrWifiSmePowerConfigSetCfm *msg__; \
2801 CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__); \
2802 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2803 }
2804
2805#define CsrWifiSmePowerConfigSetCfmSend(dst__, status__) \
2806 CsrWifiSmePowerConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
2807
2808/*******************************************************************************
2809
2810 NAME
2811 CsrWifiSmeRegulatoryDomainInfoGetReqSend
2812
2813 DESCRIPTION
2814 This primitive gets the value of the RegulatoryDomainInfo parameter.
2815
2816 PARAMETERS
2817 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2818
2819*******************************************************************************/
2820#define CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__) \
2821 msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetReq), GFP_KERNEL); \
2822 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, dst__, src__);
2823
2824#define CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(dst__, src__) \
2825 { \
2826 CsrWifiSmeRegulatoryDomainInfoGetReq *msg__; \
2827 CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__); \
2828 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2829 }
2830
2831#define CsrWifiSmeRegulatoryDomainInfoGetReqSend(src__) \
2832 CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
2833
2834/*******************************************************************************
2835
2836 NAME
2837 CsrWifiSmeRegulatoryDomainInfoGetCfmSend
2838
2839 DESCRIPTION
2840 This primitive reports the result of the request.
2841
2842 PARAMETERS
2843 queue - Destination Task Queue
2844 status - Reports the result of the request
2845 regDomInfo - Reports information and state related to regulatory domain
2846 operation.
2847
2848*******************************************************************************/
2849#define CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__) \
2850 msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL); \
2851 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, dst__, src__); \
2852 msg__->status = (status__); \
2853 msg__->regDomInfo = (regDomInfo__);
2854
2855#define CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, src__, status__, regDomInfo__) \
2856 { \
2857 CsrWifiSmeRegulatoryDomainInfoGetCfm *msg__; \
2858 CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__); \
2859 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2860 }
2861
2862#define CsrWifiSmeRegulatoryDomainInfoGetCfmSend(dst__, status__, regDomInfo__) \
2863 CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, regDomInfo__)
2864
2865/*******************************************************************************
2866
2867 NAME
2868 CsrWifiSmeRoamCompleteIndSend
2869
2870 DESCRIPTION
2871 The SME will send this primitive to all the tasks that have registered to
2872 receive it whenever it completes an attempt to roam to an AP. If the roam
2873 attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS,
2874 otherwise it shall be set to the appropriate error code.
2875
2876 PARAMETERS
2877 queue - Destination Task Queue
2878 interfaceTag - Interface Identifier; unique identifier of an interface
2879 status - Reports the result of the roaming procedure
2880
2881*******************************************************************************/
2882#define CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__) \
2883 msg__ = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL); \
2884 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_COMPLETE_IND, dst__, src__); \
2885 msg__->interfaceTag = (interfaceTag__); \
2886 msg__->status = (status__);
2887
2888#define CsrWifiSmeRoamCompleteIndSendTo(dst__, src__, interfaceTag__, status__) \
2889 { \
2890 CsrWifiSmeRoamCompleteInd *msg__; \
2891 CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__); \
2892 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2893 }
2894
2895#define CsrWifiSmeRoamCompleteIndSend(dst__, interfaceTag__, status__) \
2896 CsrWifiSmeRoamCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
2897
2898/*******************************************************************************
2899
2900 NAME
2901 CsrWifiSmeRoamStartIndSend
2902
2903 DESCRIPTION
2904 The SME will send this primitive to all the tasks that have registered to
2905 receive it whenever it begins an attempt to roam to an AP.
2906 If the wireless manager application connect request specified the SSID
2907 and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF
2908 0xFF), the SME monitors the signal quality and maintains a list of
2909 candidates to roam to. When the signal quality of the current connection
2910 falls below a threshold, and there is a candidate with better quality,
2911 the SME will attempt to the candidate AP.
2912 If the roaming procedure succeeds, the SME will also issue a Media
2913 Connect indication to inform the wireless manager application of the
2914 change.
2915 NOTE: to prevent the SME from initiating roaming the WMA must specify the
2916 BSSID in the connection request; this forces the SME to connect only to
2917 that AP.
2918 The wireless manager application can obtain statistics for roaming
2919 purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and
2920 CSR_WIFI_SME_CONNECTION_STATS_GET_REQ.
2921 When the wireless manager application wishes to roam to another AP, it
2922 must issue a connection request specifying the BSSID of the desired AP.
2923
2924 PARAMETERS
2925 queue - Destination Task Queue
2926 interfaceTag - Interface Identifier; unique identifier of an interface
2927 roamReason - Indicates the reason for starting the roaming procedure
2928 reason80211 - Indicates the reason for deauthentication or disassociation
2929
2930*******************************************************************************/
2931#define CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__) \
2932 msg__ = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL); \
2933 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_START_IND, dst__, src__); \
2934 msg__->interfaceTag = (interfaceTag__); \
2935 msg__->roamReason = (roamReason__); \
2936 msg__->reason80211 = (reason80211__);
2937
2938#define CsrWifiSmeRoamStartIndSendTo(dst__, src__, interfaceTag__, roamReason__, reason80211__) \
2939 { \
2940 CsrWifiSmeRoamStartInd *msg__; \
2941 CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__); \
2942 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
2943 }
2944
2945#define CsrWifiSmeRoamStartIndSend(dst__, interfaceTag__, roamReason__, reason80211__) \
2946 CsrWifiSmeRoamStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, roamReason__, reason80211__)
2947
2948/*******************************************************************************
2949
2950 NAME
2951 CsrWifiSmeRoamingConfigGetReqSend
2952
2953 DESCRIPTION
2954 This primitive gets the value of the RoamingConfig parameter.
2955
2956 PARAMETERS
2957 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
2958 interfaceTag - Interface Identifier; unique identifier of an interface
2959
2960*******************************************************************************/
2961#define CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
2962 msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetReq), GFP_KERNEL); \
2963 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, dst__, src__); \
2964 msg__->interfaceTag = (interfaceTag__);
2965
2966#define CsrWifiSmeRoamingConfigGetReqSendTo(dst__, src__, interfaceTag__) \
2967 { \
2968 CsrWifiSmeRoamingConfigGetReq *msg__; \
2969 CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
2970 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
2971 }
2972
2973#define CsrWifiSmeRoamingConfigGetReqSend(src__, interfaceTag__) \
2974 CsrWifiSmeRoamingConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
2975
2976/*******************************************************************************
2977
2978 NAME
2979 CsrWifiSmeRoamingConfigGetCfmSend
2980
2981 DESCRIPTION
2982 This primitive reports the result of the request.
2983
2984 PARAMETERS
2985 queue - Destination Task Queue
2986 interfaceTag - Interface Identifier; unique identifier of an interface
2987 status - Reports the result of the request
2988 roamingConfig - Reports the roaming behaviour of the driver and firmware
2989
2990*******************************************************************************/
2991#define CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__) \
2992 msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL); \
2993 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, dst__, src__); \
2994 msg__->interfaceTag = (interfaceTag__); \
2995 msg__->status = (status__); \
2996 msg__->roamingConfig = (roamingConfig__);
2997
2998#define CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, roamingConfig__) \
2999 { \
3000 CsrWifiSmeRoamingConfigGetCfm *msg__; \
3001 CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__); \
3002 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3003 }
3004
3005#define CsrWifiSmeRoamingConfigGetCfmSend(dst__, interfaceTag__, status__, roamingConfig__) \
3006 CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, roamingConfig__)
3007
3008/*******************************************************************************
3009
3010 NAME
3011 CsrWifiSmeRoamingConfigSetReqSend
3012
3013 DESCRIPTION
3014 This primitive sets the value of the RoamingConfig parameter.
3015
3016 PARAMETERS
3017 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3018 interfaceTag - Interface Identifier; unique identifier of an interface
3019 roamingConfig - Desired roaming behaviour values
3020
3021*******************************************************************************/
3022#define CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__) \
3023 msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL); \
3024 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, dst__, src__); \
3025 msg__->interfaceTag = (interfaceTag__); \
3026 msg__->roamingConfig = (roamingConfig__);
3027
3028#define CsrWifiSmeRoamingConfigSetReqSendTo(dst__, src__, interfaceTag__, roamingConfig__) \
3029 { \
3030 CsrWifiSmeRoamingConfigSetReq *msg__; \
3031 CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__); \
3032 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3033 }
3034
3035#define CsrWifiSmeRoamingConfigSetReqSend(src__, interfaceTag__, roamingConfig__) \
3036 CsrWifiSmeRoamingConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, roamingConfig__)
3037
3038/*******************************************************************************
3039
3040 NAME
3041 CsrWifiSmeRoamingConfigSetCfmSend
3042
3043 DESCRIPTION
3044 This primitive sets the value of the RoamingConfig parameter.
3045
3046 PARAMETERS
3047 queue - Destination Task Queue
3048 interfaceTag - Interface Identifier; unique identifier of an interface
3049 status - Reports the result of the request
3050
3051*******************************************************************************/
3052#define CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
3053 msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL); \
3054 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, dst__, src__); \
3055 msg__->interfaceTag = (interfaceTag__); \
3056 msg__->status = (status__);
3057
3058#define CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
3059 { \
3060 CsrWifiSmeRoamingConfigSetCfm *msg__; \
3061 CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
3062 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3063 }
3064
3065#define CsrWifiSmeRoamingConfigSetCfmSend(dst__, interfaceTag__, status__) \
3066 CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
3067
3068/*******************************************************************************
3069
3070 NAME
3071 CsrWifiSmeScanConfigGetReqSend
3072
3073 DESCRIPTION
3074 This primitive gets the value of the ScanConfig parameter.
3075
3076 PARAMETERS
3077 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3078
3079*******************************************************************************/
3080#define CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__) \
3081 msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetReq), GFP_KERNEL); \
3082 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, dst__, src__);
3083
3084#define CsrWifiSmeScanConfigGetReqSendTo(dst__, src__) \
3085 { \
3086 CsrWifiSmeScanConfigGetReq *msg__; \
3087 CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__); \
3088 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3089 }
3090
3091#define CsrWifiSmeScanConfigGetReqSend(src__) \
3092 CsrWifiSmeScanConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
3093
3094/*******************************************************************************
3095
3096 NAME
3097 CsrWifiSmeScanConfigGetCfmSend
3098
3099 DESCRIPTION
3100 This primitive reports the result of the request.
3101
3102 PARAMETERS
3103 queue - Destination Task Queue
3104 status - Reports the result of the request
3105 scanConfig - Returns the current parameters for the autonomous scanning
3106 behaviour of the firmware
3107
3108*******************************************************************************/
3109#define CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__) \
3110 msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL); \
3111 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, dst__, src__); \
3112 msg__->status = (status__); \
3113 msg__->scanConfig = (scanConfig__);
3114
3115#define CsrWifiSmeScanConfigGetCfmSendTo(dst__, src__, status__, scanConfig__) \
3116 { \
3117 CsrWifiSmeScanConfigGetCfm *msg__; \
3118 CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__); \
3119 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3120 }
3121
3122#define CsrWifiSmeScanConfigGetCfmSend(dst__, status__, scanConfig__) \
3123 CsrWifiSmeScanConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanConfig__)
3124
3125/*******************************************************************************
3126
3127 NAME
3128 CsrWifiSmeScanConfigSetReqSend
3129
3130 DESCRIPTION
3131 This primitive sets the value of the ScanConfig parameter.
3132 The SME normally configures the firmware to perform autonomous scanning
3133 without involving the host.
3134 The firmware passes beacon / probe response or indicates loss of beacon
3135 on certain changes of state, for example:
3136 * A new AP is seen for the first time
3137 * An AP is no longer visible
3138 * The signal strength of an AP changes by more than a certain amount, as
3139 configured by the thresholds in the scanConfig parameter
3140 In addition to the autonomous scan, the wireless manager application may
3141 request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ.
3142
3143 PARAMETERS
3144 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3145 scanConfig - Reports the configuration for the autonomous scanning behaviour
3146 of the firmware
3147
3148*******************************************************************************/
3149#define CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__) \
3150 msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL); \
3151 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, dst__, src__); \
3152 msg__->scanConfig = (scanConfig__);
3153
3154#define CsrWifiSmeScanConfigSetReqSendTo(dst__, src__, scanConfig__) \
3155 { \
3156 CsrWifiSmeScanConfigSetReq *msg__; \
3157 CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__); \
3158 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3159 }
3160
3161#define CsrWifiSmeScanConfigSetReqSend(src__, scanConfig__) \
3162 CsrWifiSmeScanConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, scanConfig__)
3163
3164/*******************************************************************************
3165
3166 NAME
3167 CsrWifiSmeScanConfigSetCfmSend
3168
3169 DESCRIPTION
3170 This primitive reports the result of the request.
3171
3172 PARAMETERS
3173 queue - Destination Task Queue
3174 status - Reports the result of the request
3175
3176*******************************************************************************/
3177#define CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__) \
3178 msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetCfm), GFP_KERNEL); \
3179 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, dst__, src__); \
3180 msg__->status = (status__);
3181
3182#define CsrWifiSmeScanConfigSetCfmSendTo(dst__, src__, status__) \
3183 { \
3184 CsrWifiSmeScanConfigSetCfm *msg__; \
3185 CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__); \
3186 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3187 }
3188
3189#define CsrWifiSmeScanConfigSetCfmSend(dst__, status__) \
3190 CsrWifiSmeScanConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
3191
3192/*******************************************************************************
3193
3194 NAME
3195 CsrWifiSmeScanFullReqSend
3196
3197 DESCRIPTION
3198 The wireless manager application should call this primitive to request a
3199 full scan.
3200 Channels are scanned actively or passively according to the requirement
3201 set by regulatory domain.
3202 If the SME receives this primitive while a full scan is going on, the new
3203 request is buffered and it will be served after the current full scan is
3204 completed.
3205
3206 PARAMETERS
3207 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3208 ssidCount - Number of SSIDs provided.
3209 If it is 0, the SME will attempt to detect any network
3210 ssid - Points to the first SSID provided, if any.
3211 bssid - BSS identifier.
3212 If it is equal to FF-FF-FF-FF-FF, the SME will listen for
3213 messages from any BSS.
3214 If it is different from FF-FF-FF-FF-FF and any SSID is
3215 provided, one SSID must match the network of the BSS.
3216 forceScan - Forces the scan even if the SME is in a state which would
3217 normally prevent it (e.g. autonomous scan is running).
3218 bssType - Type of BSS to scan for
3219 scanType - Type of scan to perform
3220 channelListCount - Number of channels provided.
3221 If it is 0, the SME will initiate a scan of all the
3222 supported channels that are permitted by the current
3223 regulatory domain.
3224 channelList - Points to the first channel , or NULL if channelListCount
3225 is zero.
3226 probeIeLength - Length of the information element in bytes to be sent
3227 with the probe message.
3228 probeIe - Points to the first byte of the information element to be
3229 sent with the probe message.
3230
3231*******************************************************************************/
3232#define CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
3233 msg__ = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL); \
3234 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_REQ, dst__, src__); \
3235 msg__->ssidCount = (ssidCount__); \
3236 msg__->ssid = (ssid__); \
3237 msg__->bssid = (bssid__); \
3238 msg__->forceScan = (forceScan__); \
3239 msg__->bssType = (bssType__); \
3240 msg__->scanType = (scanType__); \
3241 msg__->channelListCount = (channelListCount__); \
3242 msg__->channelList = (channelList__); \
3243 msg__->probeIeLength = (probeIeLength__); \
3244 msg__->probeIe = (probeIe__);
3245
3246#define CsrWifiSmeScanFullReqSendTo(dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
3247 { \
3248 CsrWifiSmeScanFullReq *msg__; \
3249 CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__); \
3250 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3251 }
3252
3253#define CsrWifiSmeScanFullReqSend(src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
3254 CsrWifiSmeScanFullReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__)
3255
3256/*******************************************************************************
3257
3258 NAME
3259 CsrWifiSmeScanFullCfmSend
3260
3261 DESCRIPTION
3262 The SME calls this primitive when the results from the scan are
3263 available.
3264
3265 PARAMETERS
3266 queue - Destination Task Queue
3267 status - Reports the result of the request
3268
3269*******************************************************************************/
3270#define CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__) \
3271 msg__ = kmalloc(sizeof(CsrWifiSmeScanFullCfm), GFP_KERNEL); \
3272 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_CFM, dst__, src__); \
3273 msg__->status = (status__);
3274
3275#define CsrWifiSmeScanFullCfmSendTo(dst__, src__, status__) \
3276 { \
3277 CsrWifiSmeScanFullCfm *msg__; \
3278 CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__); \
3279 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3280 }
3281
3282#define CsrWifiSmeScanFullCfmSend(dst__, status__) \
3283 CsrWifiSmeScanFullCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
3284
3285/*******************************************************************************
3286
3287 NAME
3288 CsrWifiSmeScanResultIndSend
3289
3290 DESCRIPTION
3291 The SME sends this primitive to all the tasks that have registered to
3292 receive it whenever a scan indication is received from the firmware.
3293
3294 PARAMETERS
3295 queue - Destination Task Queue
3296 result - Points to a buffer containing a scan result.
3297
3298*******************************************************************************/
3299#define CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__) \
3300 msg__ = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL); \
3301 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULT_IND, dst__, src__); \
3302 msg__->result = (result__);
3303
3304#define CsrWifiSmeScanResultIndSendTo(dst__, src__, result__) \
3305 { \
3306 CsrWifiSmeScanResultInd *msg__; \
3307 CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__); \
3308 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3309 }
3310
3311#define CsrWifiSmeScanResultIndSend(dst__, result__) \
3312 CsrWifiSmeScanResultIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, result__)
3313
3314/*******************************************************************************
3315
3316 NAME
3317 CsrWifiSmeScanResultsFlushReqSend
3318
3319 DESCRIPTION
3320 The Wireless Manager calls this primitive to ask the SME to delete all
3321 scan results from its cache, except for the scan result of any currently
3322 connected network.
3323 As scan results are received by the SME from the firmware, they are
3324 cached in the SME memory.
3325 Any time the Wireless Manager requests scan results, they are returned
3326 from the SME internal cache.
3327 For some applications it may be desirable to clear this cache prior to
3328 requesting that a scan be performed; this will ensure that the cache then
3329 only contains the networks detected in the most recent scan.
3330
3331 PARAMETERS
3332 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3333
3334*******************************************************************************/
3335#define CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__) \
3336 msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushReq), GFP_KERNEL); \
3337 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, dst__, src__);
3338
3339#define CsrWifiSmeScanResultsFlushReqSendTo(dst__, src__) \
3340 { \
3341 CsrWifiSmeScanResultsFlushReq *msg__; \
3342 CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__); \
3343 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3344 }
3345
3346#define CsrWifiSmeScanResultsFlushReqSend(src__) \
3347 CsrWifiSmeScanResultsFlushReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
3348
3349/*******************************************************************************
3350
3351 NAME
3352 CsrWifiSmeScanResultsFlushCfmSend
3353
3354 DESCRIPTION
3355 The SME will call this primitive when the cache has been cleared.
3356
3357 PARAMETERS
3358 queue - Destination Task Queue
3359 status - Reports the result of the request
3360
3361*******************************************************************************/
3362#define CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__) \
3363 msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushCfm), GFP_KERNEL); \
3364 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, dst__, src__); \
3365 msg__->status = (status__);
3366
3367#define CsrWifiSmeScanResultsFlushCfmSendTo(dst__, src__, status__) \
3368 { \
3369 CsrWifiSmeScanResultsFlushCfm *msg__; \
3370 CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__); \
3371 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3372 }
3373
3374#define CsrWifiSmeScanResultsFlushCfmSend(dst__, status__) \
3375 CsrWifiSmeScanResultsFlushCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
3376
3377/*******************************************************************************
3378
3379 NAME
3380 CsrWifiSmeScanResultsGetReqSend
3381
3382 DESCRIPTION
3383 The wireless manager application calls this primitive to retrieve the
3384 current set of scan results, either after receiving a successful
3385 CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results.
3386
3387 PARAMETERS
3388 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3389
3390*******************************************************************************/
3391#define CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__) \
3392 msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetReq), GFP_KERNEL); \
3393 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, dst__, src__);
3394
3395#define CsrWifiSmeScanResultsGetReqSendTo(dst__, src__) \
3396 { \
3397 CsrWifiSmeScanResultsGetReq *msg__; \
3398 CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__); \
3399 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3400 }
3401
3402#define CsrWifiSmeScanResultsGetReqSend(src__) \
3403 CsrWifiSmeScanResultsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
3404
3405/*******************************************************************************
3406
3407 NAME
3408 CsrWifiSmeScanResultsGetCfmSend
3409
3410 DESCRIPTION
3411 The SME sends this primitive to provide the current set of scan results.
3412
3413 PARAMETERS
3414 queue - Destination Task Queue
3415 status - Reports the result of the request
3416 scanResultsCount - Number of scan results
3417 scanResults - Points to a buffer containing an array of
3418 CsrWifiSmeScanResult structures.
3419
3420*******************************************************************************/
3421#define CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__) \
3422 msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL); \
3423 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, dst__, src__); \
3424 msg__->status = (status__); \
3425 msg__->scanResultsCount = (scanResultsCount__); \
3426 msg__->scanResults = (scanResults__);
3427
3428#define CsrWifiSmeScanResultsGetCfmSendTo(dst__, src__, status__, scanResultsCount__, scanResults__) \
3429 { \
3430 CsrWifiSmeScanResultsGetCfm *msg__; \
3431 CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__); \
3432 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3433 }
3434
3435#define CsrWifiSmeScanResultsGetCfmSend(dst__, status__, scanResultsCount__, scanResults__) \
3436 CsrWifiSmeScanResultsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanResultsCount__, scanResults__)
3437
3438/*******************************************************************************
3439
3440 NAME
3441 CsrWifiSmeSetReqSend
3442
3443 DESCRIPTION
3444 Used to pass custom data to the SME. Format is the same as 802.11 Info
3445 Elements => | Id | Length | Data
3446 1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01
3447 (0x00|0x01)"
3448
3449 PARAMETERS
3450 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3451 dataLength - Number of bytes in the buffer pointed to by 'data'
3452 data - Pointer to the buffer containing 'dataLength' bytes
3453
3454*******************************************************************************/
3455#define CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__) \
3456 msg__ = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL); \
3457 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SET_REQ, dst__, src__); \
3458 msg__->dataLength = (dataLength__); \
3459 msg__->data = (data__);
3460
3461#define CsrWifiSmeSetReqSendTo(dst__, src__, dataLength__, data__) \
3462 { \
3463 CsrWifiSmeSetReq *msg__; \
3464 CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__); \
3465 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3466 }
3467
3468#define CsrWifiSmeSetReqSend(src__, dataLength__, data__) \
3469 CsrWifiSmeSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, dataLength__, data__)
3470
3471/*******************************************************************************
3472
3473 NAME
3474 CsrWifiSmeSmeCommonConfigGetReqSend
3475
3476 DESCRIPTION
3477 This primitive gets the value of the Sme common parameter.
3478
3479 PARAMETERS
3480 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3481
3482*******************************************************************************/
3483#define CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__) \
3484 msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetReq), GFP_KERNEL); \
3485 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, dst__, src__);
3486
3487#define CsrWifiSmeSmeCommonConfigGetReqSendTo(dst__, src__) \
3488 { \
3489 CsrWifiSmeSmeCommonConfigGetReq *msg__; \
3490 CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__); \
3491 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3492 }
3493
3494#define CsrWifiSmeSmeCommonConfigGetReqSend(src__) \
3495 CsrWifiSmeSmeCommonConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
3496
3497/*******************************************************************************
3498
3499 NAME
3500 CsrWifiSmeSmeCommonConfigGetCfmSend
3501
3502 DESCRIPTION
3503 This primitive reports the result of the request.
3504
3505 PARAMETERS
3506 queue - Destination Task Queue
3507 status - Reports the result of the request
3508 deviceConfig - Configuration options in the SME
3509
3510*******************************************************************************/
3511#define CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__) \
3512 msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL); \
3513 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, dst__, src__); \
3514 msg__->status = (status__); \
3515 msg__->deviceConfig = (deviceConfig__);
3516
3517#define CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, src__, status__, deviceConfig__) \
3518 { \
3519 CsrWifiSmeSmeCommonConfigGetCfm *msg__; \
3520 CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__); \
3521 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3522 }
3523
3524#define CsrWifiSmeSmeCommonConfigGetCfmSend(dst__, status__, deviceConfig__) \
3525 CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, deviceConfig__)
3526
3527/*******************************************************************************
3528
3529 NAME
3530 CsrWifiSmeSmeCommonConfigSetReqSend
3531
3532 DESCRIPTION
3533 This primitive sets the value of the Sme common.
3534
3535 PARAMETERS
3536 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3537 deviceConfig - Configuration options in the SME
3538
3539*******************************************************************************/
3540#define CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__) \
3541 msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL); \
3542 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, dst__, src__); \
3543 msg__->deviceConfig = (deviceConfig__);
3544
3545#define CsrWifiSmeSmeCommonConfigSetReqSendTo(dst__, src__, deviceConfig__) \
3546 { \
3547 CsrWifiSmeSmeCommonConfigSetReq *msg__; \
3548 CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__); \
3549 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3550 }
3551
3552#define CsrWifiSmeSmeCommonConfigSetReqSend(src__, deviceConfig__) \
3553 CsrWifiSmeSmeCommonConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, deviceConfig__)
3554
3555/*******************************************************************************
3556
3557 NAME
3558 CsrWifiSmeSmeCommonConfigSetCfmSend
3559
3560 DESCRIPTION
3561 Reports the result of the request
3562
3563 PARAMETERS
3564 queue - Destination Task Queue
3565 status - Reports the result of the request
3566
3567*******************************************************************************/
3568#define CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__) \
3569 msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetCfm), GFP_KERNEL); \
3570 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, dst__, src__); \
3571 msg__->status = (status__);
3572
3573#define CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, src__, status__) \
3574 { \
3575 CsrWifiSmeSmeCommonConfigSetCfm *msg__; \
3576 CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__); \
3577 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3578 }
3579
3580#define CsrWifiSmeSmeCommonConfigSetCfmSend(dst__, status__) \
3581 CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
3582
3583/*******************************************************************************
3584
3585 NAME
3586 CsrWifiSmeSmeStaConfigGetReqSend
3587
3588 DESCRIPTION
3589 This primitive gets the value of the SmeStaConfig parameter.
3590
3591 PARAMETERS
3592 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3593 interfaceTag - Interface Identifier; unique identifier of an interface
3594
3595*******************************************************************************/
3596#define CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
3597 msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetReq), GFP_KERNEL); \
3598 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, dst__, src__); \
3599 msg__->interfaceTag = (interfaceTag__);
3600
3601#define CsrWifiSmeSmeStaConfigGetReqSendTo(dst__, src__, interfaceTag__) \
3602 { \
3603 CsrWifiSmeSmeStaConfigGetReq *msg__; \
3604 CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
3605 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3606 }
3607
3608#define CsrWifiSmeSmeStaConfigGetReqSend(src__, interfaceTag__) \
3609 CsrWifiSmeSmeStaConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
3610
3611/*******************************************************************************
3612
3613 NAME
3614 CsrWifiSmeSmeStaConfigGetCfmSend
3615
3616 DESCRIPTION
3617 This primitive reports the result of the request.
3618
3619 PARAMETERS
3620 queue - Destination Task Queue
3621 interfaceTag - Interface Identifier; unique identifier of an interface
3622 status - Reports the result of the request
3623 smeConfig - Current SME Station Parameters
3624
3625*******************************************************************************/
3626#define CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__) \
3627 msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL); \
3628 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, dst__, src__); \
3629 msg__->interfaceTag = (interfaceTag__); \
3630 msg__->status = (status__); \
3631 msg__->smeConfig = (smeConfig__);
3632
3633#define CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, smeConfig__) \
3634 { \
3635 CsrWifiSmeSmeStaConfigGetCfm *msg__; \
3636 CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__); \
3637 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3638 }
3639
3640#define CsrWifiSmeSmeStaConfigGetCfmSend(dst__, interfaceTag__, status__, smeConfig__) \
3641 CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, smeConfig__)
3642
3643/*******************************************************************************
3644
3645 NAME
3646 CsrWifiSmeSmeStaConfigSetReqSend
3647
3648 DESCRIPTION
3649 This primitive sets the value of the SmeConfig parameter.
3650
3651 PARAMETERS
3652 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3653 interfaceTag - Interface Identifier; unique identifier of an interface
3654 smeConfig - SME Station Parameters to be set
3655
3656*******************************************************************************/
3657#define CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__) \
3658 msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL); \
3659 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, dst__, src__); \
3660 msg__->interfaceTag = (interfaceTag__); \
3661 msg__->smeConfig = (smeConfig__);
3662
3663#define CsrWifiSmeSmeStaConfigSetReqSendTo(dst__, src__, interfaceTag__, smeConfig__) \
3664 { \
3665 CsrWifiSmeSmeStaConfigSetReq *msg__; \
3666 CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__); \
3667 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3668 }
3669
3670#define CsrWifiSmeSmeStaConfigSetReqSend(src__, interfaceTag__, smeConfig__) \
3671 CsrWifiSmeSmeStaConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, smeConfig__)
3672
3673/*******************************************************************************
3674
3675 NAME
3676 CsrWifiSmeSmeStaConfigSetCfmSend
3677
3678 DESCRIPTION
3679 This primitive reports the result of the request.
3680
3681 PARAMETERS
3682 queue - Destination Task Queue
3683 interfaceTag - Interface Identifier; unique identifier of an interface
3684 status - Reports the result of the request
3685
3686*******************************************************************************/
3687#define CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
3688 msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL); \
3689 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, dst__, src__); \
3690 msg__->interfaceTag = (interfaceTag__); \
3691 msg__->status = (status__);
3692
3693#define CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
3694 { \
3695 CsrWifiSmeSmeStaConfigSetCfm *msg__; \
3696 CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
3697 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3698 }
3699
3700#define CsrWifiSmeSmeStaConfigSetCfmSend(dst__, interfaceTag__, status__) \
3701 CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
3702
3703/*******************************************************************************
3704
3705 NAME
3706 CsrWifiSmeStationMacAddressGetReqSend
3707
3708 DESCRIPTION
3709 This primitives is used to retrieve the current MAC address used by the
3710 station.
3711
3712 PARAMETERS
3713 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3714
3715*******************************************************************************/
3716#define CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__) \
3717 msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetReq), GFP_KERNEL); \
3718 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, dst__, src__);
3719
3720#define CsrWifiSmeStationMacAddressGetReqSendTo(dst__, src__) \
3721 { \
3722 CsrWifiSmeStationMacAddressGetReq *msg__; \
3723 CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__); \
3724 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3725 }
3726
3727#define CsrWifiSmeStationMacAddressGetReqSend(src__) \
3728 CsrWifiSmeStationMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
3729
3730/*******************************************************************************
3731
3732 NAME
3733 CsrWifiSmeStationMacAddressGetCfmSend
3734
3735 DESCRIPTION
3736 This primitive reports the result of the request.
3737
3738 PARAMETERS
3739 queue - Destination Task Queue
3740 status - Reports the result of the request
3741 stationMacAddress - Current MAC address of the station.
3742
3743*******************************************************************************/
3744#define CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__) \
3745 msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL); \
3746 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, dst__, src__); \
3747 msg__->status = (status__); \
3748 memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2);
3749
3750#define CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, src__, status__, stationMacAddress__) \
3751 { \
3752 CsrWifiSmeStationMacAddressGetCfm *msg__; \
3753 CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__); \
3754 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3755 }
3756
3757#define CsrWifiSmeStationMacAddressGetCfmSend(dst__, status__, stationMacAddress__) \
3758 CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, stationMacAddress__)
3759
3760/*******************************************************************************
3761
3762 NAME
3763 CsrWifiSmeTspecReqSend
3764
3765 DESCRIPTION
3766 The wireless manager application should call this primitive to use the
3767 TSPEC feature.
3768 The chip supports the use of TSPECs and TCLAS for the use of IEEE
3769 802.11/WMM Quality of Service features.
3770 The API allows the wireless manager application to supply a correctly
3771 formatted TSPEC and TCLAS pair to the driver.
3772 After performing basic validation, the driver negotiates the installation
3773 of the TSPEC with the AP as defined by the 802.11 specification.
3774 The driver retains all TSPEC and TCLAS pairs until they are specifically
3775 removed.
3776 It is not compulsory for a TSPEC to have a TCLAS (NULL is used to
3777 indicate that no TCLAS is supplied), while a TCLASS always require a
3778 TSPEC.
3779 The format of the TSPEC element is specified in 'WMM (including WMM Power
3780 Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'.
3781 For more information, see 'UniFi Configuring WMM and WMM-PS'.
3782
3783 PARAMETERS
3784 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3785 interfaceTag - Interface Identifier; unique identifier of an interface
3786 action - Specifies the action to be carried out on the list of TSPECs.
3787 CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here.
3788 transactionId - Unique Transaction ID for the TSPEC, as assigned by the
3789 driver
3790 strict - If it set to false, allows the SME to perform automatic
3791 TSPEC negotiation
3792 ctrlMask - Additional TSPEC configuration for CCX.
3793 Set mask with values from CsrWifiSmeTspecCtrl.
3794 CURRENTLY NOT SUPPORTED
3795 tspecLength - Length of the TSPEC.
3796 tspec - Points to the first byte of the TSPEC
3797 tclasLength - Length of the TCLAS.
3798 If it is equal to 0, no TCLASS is provided for the TSPEC
3799 tclas - Points to the first byte of the TCLAS, if any.
3800
3801*******************************************************************************/
3802#define CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
3803 msg__ = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL); \
3804 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_REQ, dst__, src__); \
3805 msg__->interfaceTag = (interfaceTag__); \
3806 msg__->action = (action__); \
3807 msg__->transactionId = (transactionId__); \
3808 msg__->strict = (strict__); \
3809 msg__->ctrlMask = (ctrlMask__); \
3810 msg__->tspecLength = (tspecLength__); \
3811 msg__->tspec = (tspec__); \
3812 msg__->tclasLength = (tclasLength__); \
3813 msg__->tclas = (tclas__);
3814
3815#define CsrWifiSmeTspecReqSendTo(dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
3816 { \
3817 CsrWifiSmeTspecReq *msg__; \
3818 CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__); \
3819 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3820 }
3821
3822#define CsrWifiSmeTspecReqSend(src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
3823 CsrWifiSmeTspecReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__)
3824
3825/*******************************************************************************
3826
3827 NAME
3828 CsrWifiSmeTspecIndSend
3829
3830 DESCRIPTION
3831 The SME will send this primitive to all the task that have registered to
3832 receive it when a status change in the TSPEC occurs.
3833
3834 PARAMETERS
3835 queue - Destination Task Queue
3836 interfaceTag - Interface Identifier; unique identifier of an interface
3837 transactionId - Unique Transaction ID for the TSPEC, as assigned by the
3838 driver
3839 tspecResultCode - Specifies the TSPEC operation requested by the peer
3840 station
3841 tspecLength - Length of the TSPEC.
3842 tspec - Points to the first byte of the TSPEC
3843
3844*******************************************************************************/
3845#define CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
3846 msg__ = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL); \
3847 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_IND, dst__, src__); \
3848 msg__->interfaceTag = (interfaceTag__); \
3849 msg__->transactionId = (transactionId__); \
3850 msg__->tspecResultCode = (tspecResultCode__); \
3851 msg__->tspecLength = (tspecLength__); \
3852 msg__->tspec = (tspec__);
3853
3854#define CsrWifiSmeTspecIndSendTo(dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
3855 { \
3856 CsrWifiSmeTspecInd *msg__; \
3857 CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \
3858 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3859 }
3860
3861#define CsrWifiSmeTspecIndSend(dst__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
3862 CsrWifiSmeTspecIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__)
3863
3864/*******************************************************************************
3865
3866 NAME
3867 CsrWifiSmeTspecCfmSend
3868
3869 DESCRIPTION
3870 The SME calls the primitive to report the result of the TSpec primitive
3871 request.
3872
3873 PARAMETERS
3874 queue - Destination Task Queue
3875 interfaceTag - Interface Identifier; unique identifier of an interface
3876 status - Reports the result of the request
3877 transactionId - Unique Transaction ID for the TSPEC, as assigned by the
3878 driver
3879 tspecResultCode - Specifies the result of the negotiated TSPEC operation
3880 tspecLength - Length of the TSPEC.
3881 tspec - Points to the first byte of the TSPEC
3882
3883*******************************************************************************/
3884#define CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
3885 msg__ = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL); \
3886 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_CFM, dst__, src__); \
3887 msg__->interfaceTag = (interfaceTag__); \
3888 msg__->status = (status__); \
3889 msg__->transactionId = (transactionId__); \
3890 msg__->tspecResultCode = (tspecResultCode__); \
3891 msg__->tspecLength = (tspecLength__); \
3892 msg__->tspec = (tspec__);
3893
3894#define CsrWifiSmeTspecCfmSendTo(dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
3895 { \
3896 CsrWifiSmeTspecCfm *msg__; \
3897 CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \
3898 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3899 }
3900
3901#define CsrWifiSmeTspecCfmSend(dst__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
3902 CsrWifiSmeTspecCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__)
3903
3904/*******************************************************************************
3905
3906 NAME
3907 CsrWifiSmeVersionsGetReqSend
3908
3909 DESCRIPTION
3910 This primitive gets the value of the Versions parameter.
3911
3912 PARAMETERS
3913 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3914
3915*******************************************************************************/
3916#define CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__) \
3917 msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetReq), GFP_KERNEL); \
3918 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_REQ, dst__, src__);
3919
3920#define CsrWifiSmeVersionsGetReqSendTo(dst__, src__) \
3921 { \
3922 CsrWifiSmeVersionsGetReq *msg__; \
3923 CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__); \
3924 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
3925 }
3926
3927#define CsrWifiSmeVersionsGetReqSend(src__) \
3928 CsrWifiSmeVersionsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
3929
3930/*******************************************************************************
3931
3932 NAME
3933 CsrWifiSmeVersionsGetCfmSend
3934
3935 DESCRIPTION
3936 This primitive reports the result of the request.
3937
3938 PARAMETERS
3939 queue - Destination Task Queue
3940 status - Reports the result of the request
3941 versions - Version IDs of the product
3942
3943*******************************************************************************/
3944#define CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__) \
3945 msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL); \
3946 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_CFM, dst__, src__); \
3947 msg__->status = (status__); \
3948 msg__->versions = (versions__);
3949
3950#define CsrWifiSmeVersionsGetCfmSendTo(dst__, src__, status__, versions__) \
3951 { \
3952 CsrWifiSmeVersionsGetCfm *msg__; \
3953 CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__); \
3954 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
3955 }
3956
3957#define CsrWifiSmeVersionsGetCfmSend(dst__, status__, versions__) \
3958 CsrWifiSmeVersionsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, versions__)
3959
3960/*******************************************************************************
3961
3962 NAME
3963 CsrWifiSmeWifiFlightmodeReqSend
3964
3965 DESCRIPTION
3966 The wireless manager application may call this primitive on boot-up of
3967 the platform to ensure that the chip is placed in a mode that prevents
3968 any emission of RF energy.
3969 This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ.
3970 As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file
3971 (if any) and the programming of the initial MIB settings (if supplied by
3972 the WMA), but it also ensures that the chip is left in its lowest
3973 possible power-mode with the radio subsystems disabled.
3974 This feature is useful on platforms where power cannot be removed from
3975 the chip (leaving the chip not initialised will cause it to consume more
3976 power so calling this function ensures that the chip is initialised into
3977 a low power mode but without entering a state where it could emit any RF
3978 energy).
3979 NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi
3980 stays conceptually off. Configuration primitives can be sent after
3981 CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained.
3982 Requests that require the state of the Wi-Fi to be ON will return
3983 CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms.
3984
3985 PARAMETERS
3986 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
3987 address - Optionally specifies a station MAC address.
3988 In normal use, the manager should set the address to 0xFF
3989 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
3990 the MAC address in the MIB.
3991 mibFilesCount - Number of provided data blocks with initial MIB values
3992 mibFiles - Points to the first data block with initial MIB values.
3993 These data blocks are typically the contents of the provided
3994 files ufmib.dat and localmib.dat, available from the host
3995 file system, if they exist.
3996 These files typically contain radio tuning and calibration
3997 values.
3998 More values can be created using the Host Tools.
3999
4000*******************************************************************************/
4001#define CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \
4002 msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL); \
4003 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, dst__, src__); \
4004 msg__->address = (address__); \
4005 msg__->mibFilesCount = (mibFilesCount__); \
4006 msg__->mibFiles = (mibFiles__);
4007
4008#define CsrWifiSmeWifiFlightmodeReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \
4009 { \
4010 CsrWifiSmeWifiFlightmodeReq *msg__; \
4011 CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \
4012 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
4013 }
4014
4015#define CsrWifiSmeWifiFlightmodeReqSend(src__, address__, mibFilesCount__, mibFiles__) \
4016 CsrWifiSmeWifiFlightmodeReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__)
4017
4018/*******************************************************************************
4019
4020 NAME
4021 CsrWifiSmeWifiFlightmodeCfmSend
4022
4023 DESCRIPTION
4024 The SME calls this primitive when the chip is initialised for low power
4025 mode and with the radio subsystem disabled. To leave flight mode, and
4026 enable Wi-Fi, the wireless manager application should call
4027 CSR_WIFI_SME_WIFI_ON_REQ.
4028
4029 PARAMETERS
4030 queue - Destination Task Queue
4031 status - Reports the result of the request
4032
4033*******************************************************************************/
4034#define CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__) \
4035 msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeCfm), GFP_KERNEL); \
4036 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, dst__, src__); \
4037 msg__->status = (status__);
4038
4039#define CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, src__, status__) \
4040 { \
4041 CsrWifiSmeWifiFlightmodeCfm *msg__; \
4042 CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__); \
4043 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
4044 }
4045
4046#define CsrWifiSmeWifiFlightmodeCfmSend(dst__, status__) \
4047 CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
4048
4049/*******************************************************************************
4050
4051 NAME
4052 CsrWifiSmeWifiOffReqSend
4053
4054 DESCRIPTION
4055 The wireless manager application calls this primitive to turn off the
4056 chip, thus saving power when Wi-Fi is not in use.
4057
4058 PARAMETERS
4059 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
4060
4061*******************************************************************************/
4062#define CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__) \
4063 msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffReq), GFP_KERNEL); \
4064 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_REQ, dst__, src__);
4065
4066#define CsrWifiSmeWifiOffReqSendTo(dst__, src__) \
4067 { \
4068 CsrWifiSmeWifiOffReq *msg__; \
4069 CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__); \
4070 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
4071 }
4072
4073#define CsrWifiSmeWifiOffReqSend(src__) \
4074 CsrWifiSmeWifiOffReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
4075
4076/*******************************************************************************
4077
4078 NAME
4079 CsrWifiSmeWifiOffIndSend
4080
4081 DESCRIPTION
4082 The SME sends this primitive to all the tasks that have registered to
4083 receive it to report that the chip has been turned off.
4084
4085 PARAMETERS
4086 queue - Destination Task Queue
4087 reason - Indicates the reason why the Wi-Fi has been switched off.
4088
4089*******************************************************************************/
4090#define CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__) \
4091 msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffInd), GFP_KERNEL); \
4092 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_IND, dst__, src__); \
4093 msg__->reason = (reason__);
4094
4095#define CsrWifiSmeWifiOffIndSendTo(dst__, src__, reason__) \
4096 { \
4097 CsrWifiSmeWifiOffInd *msg__; \
4098 CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__); \
4099 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
4100 }
4101
4102#define CsrWifiSmeWifiOffIndSend(dst__, reason__) \
4103 CsrWifiSmeWifiOffIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, reason__)
4104
4105/*******************************************************************************
4106
4107 NAME
4108 CsrWifiSmeWifiOffCfmSend
4109
4110 DESCRIPTION
4111 After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a
4112 network, the SME will perform a disconnect operation, will send a
4113 CSR_WIFI_SME_MEDIA_STATUS_IND with
4114 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call
4115 CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off.
4116
4117 PARAMETERS
4118 queue - Destination Task Queue
4119 status - Reports the result of the request
4120
4121*******************************************************************************/
4122#define CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__) \
4123 msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffCfm), GFP_KERNEL); \
4124 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_CFM, dst__, src__); \
4125 msg__->status = (status__);
4126
4127#define CsrWifiSmeWifiOffCfmSendTo(dst__, src__, status__) \
4128 { \
4129 CsrWifiSmeWifiOffCfm *msg__; \
4130 CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__); \
4131 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
4132 }
4133
4134#define CsrWifiSmeWifiOffCfmSend(dst__, status__) \
4135 CsrWifiSmeWifiOffCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
4136
4137/*******************************************************************************
4138
4139 NAME
4140 CsrWifiSmeWifiOnReqSend
4141
4142 DESCRIPTION
4143 The wireless manager application calls this primitive to turn on the
4144 Wi-Fi chip.
4145 If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on,
4146 downloads the patch file (if any), and programs the initial MIB settings
4147 (if supplied by the WMA).
4148 The patch file is not provided with the SME API; its downloading is
4149 automatic and handled internally by the system.
4150 The MIB settings, when provided, override the default values that the
4151 firmware loads from EEPROM.
4152 If the Wi-Fi chip is already on, the SME takes no action and returns a
4153 successful status in the confirm.
4154
4155 PARAMETERS
4156 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
4157 address - Optionally specifies a station MAC address.
4158 In normal use, the manager should set the address to 0xFF
4159 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
4160 the MAC address in the MIB
4161 mibFilesCount - Number of provided data blocks with initial MIB values
4162 mibFiles - Points to the first data block with initial MIB values.
4163 These data blocks are typically the contents of the provided
4164 files ufmib.dat and localmib.dat, available from the host
4165 file system, if they exist.
4166 These files typically contain radio tuning and calibration
4167 values.
4168 More values can be created using the Host Tools.
4169
4170*******************************************************************************/
4171#define CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \
4172 msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL); \
4173 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_REQ, dst__, src__); \
4174 msg__->address = (address__); \
4175 msg__->mibFilesCount = (mibFilesCount__); \
4176 msg__->mibFiles = (mibFiles__);
4177
4178#define CsrWifiSmeWifiOnReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \
4179 { \
4180 CsrWifiSmeWifiOnReq *msg__; \
4181 CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \
4182 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
4183 }
4184
4185#define CsrWifiSmeWifiOnReqSend(src__, address__, mibFilesCount__, mibFiles__) \
4186 CsrWifiSmeWifiOnReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__)
4187
4188/*******************************************************************************
4189
4190 NAME
4191 CsrWifiSmeWifiOnIndSend
4192
4193 DESCRIPTION
4194 The SME sends this primitive to all tasks that have registered to receive
4195 it once the chip becomes available and ready to use.
4196
4197 PARAMETERS
4198 queue - Destination Task Queue
4199 address - Current MAC address
4200
4201*******************************************************************************/
4202#define CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__) \
4203 msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL); \
4204 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_IND, dst__, src__); \
4205 msg__->address = (address__);
4206
4207#define CsrWifiSmeWifiOnIndSendTo(dst__, src__, address__) \
4208 { \
4209 CsrWifiSmeWifiOnInd *msg__; \
4210 CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__); \
4211 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
4212 }
4213
4214#define CsrWifiSmeWifiOnIndSend(dst__, address__) \
4215 CsrWifiSmeWifiOnIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__)
4216
4217/*******************************************************************************
4218
4219 NAME
4220 CsrWifiSmeWifiOnCfmSend
4221
4222 DESCRIPTION
4223 The SME sends this primitive to the task that has sent the request once
4224 the chip has been initialised and is available for use.
4225
4226 PARAMETERS
4227 queue - Destination Task Queue
4228 status - Reports the result of the request
4229
4230*******************************************************************************/
4231#define CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__) \
4232 msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnCfm), GFP_KERNEL); \
4233 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_CFM, dst__, src__); \
4234 msg__->status = (status__);
4235
4236#define CsrWifiSmeWifiOnCfmSendTo(dst__, src__, status__) \
4237 { \
4238 CsrWifiSmeWifiOnCfm *msg__; \
4239 CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__); \
4240 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
4241 }
4242
4243#define CsrWifiSmeWifiOnCfmSend(dst__, status__) \
4244 CsrWifiSmeWifiOnCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
4245
4246/*******************************************************************************
4247
4248 NAME
4249 CsrWifiSmeWpsConfigurationReqSend
4250
4251 DESCRIPTION
4252 This primitive passes the WPS information for the device to SME. This may
4253 be accepted only if no interface is active.
4254
4255 PARAMETERS
4256 queue - Message Source Task Queue (Cfm's will be sent to this Queue)
4257 wpsConfig - WPS config.
4258
4259*******************************************************************************/
4260#define CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \
4261 msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL); \
4262 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_REQ, dst__, src__); \
4263 msg__->wpsConfig = (wpsConfig__);
4264
4265#define CsrWifiSmeWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \
4266 { \
4267 CsrWifiSmeWpsConfigurationReq *msg__; \
4268 CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \
4269 CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
4270 }
4271
4272#define CsrWifiSmeWpsConfigurationReqSend(src__, wpsConfig__) \
4273 CsrWifiSmeWpsConfigurationReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, wpsConfig__)
4274
4275/*******************************************************************************
4276
4277 NAME
4278 CsrWifiSmeWpsConfigurationCfmSend
4279
4280 DESCRIPTION
4281 Confirm.
4282
4283 PARAMETERS
4284 queue - Destination Task Queue
4285 status - Status of the request.
4286
4287*******************************************************************************/
4288#define CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \
4289 msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationCfm), GFP_KERNEL); \
4290 CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_CFM, dst__, src__); \
4291 msg__->status = (status__);
4292
4293#define CsrWifiSmeWpsConfigurationCfmSendTo(dst__, src__, status__) \
4294 { \
4295 CsrWifiSmeWpsConfigurationCfm *msg__; \
4296 CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \
4297 CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
4298 }
4299
4300#define CsrWifiSmeWpsConfigurationCfmSend(dst__, status__) \
4301 CsrWifiSmeWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
4302
4303#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
index 17ec79c77e54..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_prim.h
+++ /dev/null
@@ -1,6510 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_PRIM_H__
14#define CSR_WIFI_SME_PRIM_H__
15
16#include <linux/types.h>
17#include "csr_prim_defs.h"
18#include "csr_sched.h"
19#include "csr_wifi_common.h"
20#include "csr_result.h"
21#include "csr_wifi_fsm_event.h"
22
23#define CSR_WIFI_SME_PRIM (0x0404)
24
25typedef CsrPrim CsrWifiSmePrim;
26
27
28/*******************************************************************************
29
30 NAME
31 CsrWifiSme80211NetworkType
32
33 DESCRIPTION
34 Indicates the physical layer of the network
35
36 VALUES
37 CSR_WIFI_SME_80211_NETWORK_TYPE_DS
38 - Direct-sequence spread spectrum
39 CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24
40 - Orthogonal Frequency Division Multiplexing at 2.4 GHz
41 CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5
42 - Orthogonal Frequency Division Multiplexing at 5 GHz
43 CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO
44 - Automatic
45
46*******************************************************************************/
47typedef u8 CsrWifiSme80211NetworkType;
48#define CSR_WIFI_SME_80211_NETWORK_TYPE_DS ((CsrWifiSme80211NetworkType) 0x00)
49#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24 ((CsrWifiSme80211NetworkType) 0x01)
50#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5 ((CsrWifiSme80211NetworkType) 0x02)
51#define CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO ((CsrWifiSme80211NetworkType) 0x03)
52
53/*******************************************************************************
54
55 NAME
56 CsrWifiSme80211PrivacyMode
57
58 DESCRIPTION
59 Bits to enable or disable the privacy mode
60
61 VALUES
62 CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
63 - Privacy mode is enabled: use of WEP for confidentiality is
64 required.
65 CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED
66 - Privacy mode is disabled
67
68*******************************************************************************/
69typedef u8 CsrWifiSme80211PrivacyMode;
70#define CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED ((CsrWifiSme80211PrivacyMode) 0x00)
71#define CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED ((CsrWifiSme80211PrivacyMode) 0x01)
72
73/*******************************************************************************
74
75 NAME
76 CsrWifiSme80211dTrustLevel
77
78 DESCRIPTION
79 Level of trust for the information coming from the network
80
81 VALUES
82 CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT
83 - Start with passive scanning and only accept country IE for
84 updating channel lists
85 CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT
86 - As above plus accept adjunct technology location
87 information
88 CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS
89 - As above accept plus receiving channel from infrastructure
90 networks
91 CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS
92 - As above accept plus receiving channel from the ad hoc
93 networks
94 CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB
95 - Start with active scanning with list of active channels
96 from the MIB and accept as above
97 CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED
98 - Start with active scanning with list of active channels
99 from the MIB and ignore any channel information from the
100 network
101
102*******************************************************************************/
103typedef u8 CsrWifiSme80211dTrustLevel;
104#define CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT ((CsrWifiSme80211dTrustLevel) 0x01)
105#define CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT ((CsrWifiSme80211dTrustLevel) 0x02)
106#define CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS ((CsrWifiSme80211dTrustLevel) 0x03)
107#define CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS ((CsrWifiSme80211dTrustLevel) 0x04)
108#define CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB ((CsrWifiSme80211dTrustLevel) 0x05)
109#define CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED ((CsrWifiSme80211dTrustLevel) 0x06)
110
111/*******************************************************************************
112
113 NAME
114 CsrWifiSmeAmpStatus
115
116 DESCRIPTION
117 AMP Current Status
118
119 VALUES
120 CSR_WIFI_SME_AMP_ACTIVE - AMP ACTIVE.
121 CSR_WIFI_SME_AMP_INACTIVE - AMP INACTIVE
122
123*******************************************************************************/
124typedef u8 CsrWifiSmeAmpStatus;
125#define CSR_WIFI_SME_AMP_ACTIVE ((CsrWifiSmeAmpStatus) 0x00)
126#define CSR_WIFI_SME_AMP_INACTIVE ((CsrWifiSmeAmpStatus) 0x01)
127
128/*******************************************************************************
129
130 NAME
131 CsrWifiSmeAuthMode
132
133 DESCRIPTION
134 Define bits for CsrWifiSmeAuthMode
135
136 VALUES
137 CSR_WIFI_SME_AUTH_MODE_80211_OPEN
138 - Connects to an open system network (i.e. no authentication,
139 no encryption) or to a WEP enabled network.
140 CSR_WIFI_SME_AUTH_MODE_80211_SHARED
141 - Connect to a WEP enabled network.
142 CSR_WIFI_SME_AUTH_MODE_8021X_WPA
143 - Connects to a WPA Enterprise enabled network.
144 CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK
145 - Connects to a WPA with Pre-Shared Key enabled network.
146 CSR_WIFI_SME_AUTH_MODE_8021X_WPA2
147 - Connects to a WPA2 Enterprise enabled network.
148 CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK
149 - Connects to a WPA2 with Pre-Shared Key enabled network.
150 CSR_WIFI_SME_AUTH_MODE_8021X_CCKM
151 - Connects to a CCKM enabled network.
152 CSR_WIFI_SME_AUTH_MODE_WAPI_WAI
153 - Connects to a WAPI Enterprise enabled network.
154 CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK
155 - Connects to a WAPI with Pre-Shared Key enabled network.
156 CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X
157 - For future use.
158
159*******************************************************************************/
160typedef u16 CsrWifiSmeAuthMode;
161#define CSR_WIFI_SME_AUTH_MODE_80211_OPEN ((CsrWifiSmeAuthMode) 0x0001)
162#define CSR_WIFI_SME_AUTH_MODE_80211_SHARED ((CsrWifiSmeAuthMode) 0x0002)
163#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA ((CsrWifiSmeAuthMode) 0x0004)
164#define CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK ((CsrWifiSmeAuthMode) 0x0008)
165#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 ((CsrWifiSmeAuthMode) 0x0010)
166#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK ((CsrWifiSmeAuthMode) 0x0020)
167#define CSR_WIFI_SME_AUTH_MODE_8021X_CCKM ((CsrWifiSmeAuthMode) 0x0040)
168#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAI ((CsrWifiSmeAuthMode) 0x0080)
169#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK ((CsrWifiSmeAuthMode) 0x0100)
170#define CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X ((CsrWifiSmeAuthMode) 0x0200)
171
172/*******************************************************************************
173
174 NAME
175 CsrWifiSmeBasicUsability
176
177 DESCRIPTION
178 Indicates the usability level of a channel
179
180 VALUES
181 CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE
182 - Not usable; connection not recommended
183 CSR_WIFI_SME_BASIC_USABILITY_POOR
184 - Poor quality; connect only if nothing better is available
185 CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY
186 - Quality is satisfactory
187 CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED
188 - Not connected
189
190*******************************************************************************/
191typedef u8 CsrWifiSmeBasicUsability;
192#define CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE ((CsrWifiSmeBasicUsability) 0x00)
193#define CSR_WIFI_SME_BASIC_USABILITY_POOR ((CsrWifiSmeBasicUsability) 0x01)
194#define CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY ((CsrWifiSmeBasicUsability) 0x02)
195#define CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED ((CsrWifiSmeBasicUsability) 0x03)
196
197/*******************************************************************************
198
199 NAME
200 CsrWifiSmeBssType
201
202 DESCRIPTION
203 Indicates the BSS type
204
205 VALUES
206 CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
207 - Infrastructure BSS.
208 CSR_WIFI_SME_BSS_TYPE_ADHOC
209 - Ad hoc or Independent BSS.
210 CSR_WIFI_SME_BSS_TYPE_ANY_BSS
211 - Specifies any type of BSS
212 CSR_WIFI_SME_BSS_TYPE_P2P
213 - Specifies P2P
214
215*******************************************************************************/
216typedef u8 CsrWifiSmeBssType;
217#define CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE ((CsrWifiSmeBssType) 0x00)
218#define CSR_WIFI_SME_BSS_TYPE_ADHOC ((CsrWifiSmeBssType) 0x01)
219#define CSR_WIFI_SME_BSS_TYPE_ANY_BSS ((CsrWifiSmeBssType) 0x02)
220#define CSR_WIFI_SME_BSS_TYPE_P2P ((CsrWifiSmeBssType) 0x03)
221
222/*******************************************************************************
223
224 NAME
225 CsrWifiSmeCoexScheme
226
227 DESCRIPTION
228 Options for the coexistence signalling
229 Same as MibValues
230
231 VALUES
232 CSR_WIFI_SME_COEX_SCHEME_DISABLED
233 - The coexistence signalling is disabled
234 CSR_WIFI_SME_COEX_SCHEME_CSR
235 - Basic CSR coexistence signalling
236 CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL
237 - Full CSR coexistence signalling
238 CSR_WIFI_SME_COEX_SCHEME_PTA
239 - Packet Traffic Arbitrator coexistence signalling
240
241*******************************************************************************/
242typedef u8 CsrWifiSmeCoexScheme;
243#define CSR_WIFI_SME_COEX_SCHEME_DISABLED ((CsrWifiSmeCoexScheme) 0x00)
244#define CSR_WIFI_SME_COEX_SCHEME_CSR ((CsrWifiSmeCoexScheme) 0x01)
245#define CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL ((CsrWifiSmeCoexScheme) 0x02)
246#define CSR_WIFI_SME_COEX_SCHEME_PTA ((CsrWifiSmeCoexScheme) 0x03)
247
248/*******************************************************************************
249
250 NAME
251 CsrWifiSmeControlIndication
252
253 DESCRIPTION
254 Indicates the reason why the Wi-Fi has been switched off.
255 The values of this type are used across the NME/SME/Router API's and they
256 must be kept consistent with the corresponding types in the .xml of the
257 ottherinterfaces
258
259 VALUES
260 CSR_WIFI_SME_CONTROL_INDICATION_ERROR
261 - An unrecoverable error (for example, an unrecoverable SDIO
262 error) has occurred.
263 The wireless manager application should reinitialise the
264 chip by calling CSR_WIFI_SME_WIFI_ON_REQ.
265 CSR_WIFI_SME_CONTROL_INDICATION_EXIT
266 - The chip became unavailable due to an external action, for
267 example, when a plug-in card is ejected or the driver is
268 unloaded.
269 CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED
270 - The Wi-Fi has been switched off as the wireless manager
271 application has sent CSR_WIFI_SME_WIFI_OFF_REQ
272
273*******************************************************************************/
274typedef u8 CsrWifiSmeControlIndication;
275#define CSR_WIFI_SME_CONTROL_INDICATION_ERROR ((CsrWifiSmeControlIndication) 0x01)
276#define CSR_WIFI_SME_CONTROL_INDICATION_EXIT ((CsrWifiSmeControlIndication) 0x02)
277#define CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED ((CsrWifiSmeControlIndication) 0x03)
278
279/*******************************************************************************
280
281 NAME
282 CsrWifiSmeCtsProtectionType
283
284 DESCRIPTION
285 SME CTS Protection Types
286
287 VALUES
288 CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC
289 - AP CTS Protection automatic based on non-ERP station in own
290 BSS or neighbouring BSS on the same channel based on OLBC.
291 This requires monitoring of beacons from other APs.
292 CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED
293 - AP CTS Protection Force enabled
294 CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED
295 - AP CTS Protection Force disabled.
296 CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC
297 - AP CTS Protection automatic without considering OLBC but
298 considering non-ERP station in the own BSS Valid only if AP
299 is configured to work in 802.11bg or 802.11g mode otherwise
300 this option specifies the same behaviour as AUTOMATIC
301
302*******************************************************************************/
303typedef u8 CsrWifiSmeCtsProtectionType;
304#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC ((CsrWifiSmeCtsProtectionType) 0x00)
305#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED ((CsrWifiSmeCtsProtectionType) 0x01)
306#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED ((CsrWifiSmeCtsProtectionType) 0x02)
307#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC ((CsrWifiSmeCtsProtectionType) 0x03)
308
309/*******************************************************************************
310
311 NAME
312 CsrWifiSmeD3AutoScanMode
313
314 DESCRIPTION
315 Autonomous scan status while in D3 suspended period
316
317 VALUES
318 CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON
319 - Autonomous scan stays on
320 CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF
321 - Autonomous scan is switched off
322 CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO
323 - Automatically select autoscanning behaviour.
324 CURRENTLY NOT SUPPORTED
325
326*******************************************************************************/
327typedef u8 CsrWifiSmeD3AutoScanMode;
328#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON ((CsrWifiSmeD3AutoScanMode) 0x00)
329#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF ((CsrWifiSmeD3AutoScanMode) 0x01)
330#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO ((CsrWifiSmeD3AutoScanMode) 0x02)
331
332/*******************************************************************************
333
334 NAME
335 CsrWifiSmeEncryption
336
337 DESCRIPTION
338 Defines bits for CsrWifiSmeEncryption
339 For a WEP enabled network, the caller must specify the correct
340 combination of flags in the encryptionModeMask.
341
342 VALUES
343 CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
344 - No encryption set
345 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
346 - Selects 40 byte key WEP for unicast communication
347 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
348 - Selects 104 byte key WEP for unicast communication
349 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
350 - Selects TKIP for unicast communication
351 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
352 - Selects CCMP for unicast communication
353 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
354 - Selects SMS4 for unicast communication
355 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
356 - Selects 40 byte key WEP for broadcast messages
357 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
358 - Selects 104 byte key WEP for broadcast messages
359 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP
360 - Selects a TKIP for broadcast messages
361 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP
362 - Selects CCMP for broadcast messages
363 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4
364 - Selects SMS4 for broadcast messages
365
366*******************************************************************************/
367typedef u16 CsrWifiSmeEncryption;
368#define CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE ((CsrWifiSmeEncryption) 0x0000)
369#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 ((CsrWifiSmeEncryption) 0x0001)
370#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 ((CsrWifiSmeEncryption) 0x0002)
371#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP ((CsrWifiSmeEncryption) 0x0004)
372#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP ((CsrWifiSmeEncryption) 0x0008)
373#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 ((CsrWifiSmeEncryption) 0x0010)
374#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 ((CsrWifiSmeEncryption) 0x0020)
375#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 ((CsrWifiSmeEncryption) 0x0040)
376#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP ((CsrWifiSmeEncryption) 0x0080)
377#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP ((CsrWifiSmeEncryption) 0x0100)
378#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4 ((CsrWifiSmeEncryption) 0x0200)
379
380/*******************************************************************************
381
382 NAME
383 CsrWifiSmeFirmwareDriverInterface
384
385 DESCRIPTION
386 Type of communication between Host and Firmware
387
388 VALUES
389 CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE
390 - No preformated header. NOT SUPPORTED in the current release
391 CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE
392 - Preformated IEEE 802.11 header for user plane
393
394*******************************************************************************/
395typedef u8 CsrWifiSmeFirmwareDriverInterface;
396#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE ((CsrWifiSmeFirmwareDriverInterface) 0x00)
397#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE ((CsrWifiSmeFirmwareDriverInterface) 0x01)
398
399/*******************************************************************************
400
401 NAME
402 CsrWifiSmeHostPowerMode
403
404 DESCRIPTION
405 Defines the power mode
406
407 VALUES
408 CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE
409 - Host device is running on external power.
410 CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE
411 - Host device is running on (internal) battery power.
412 CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE
413 - For future use.
414
415*******************************************************************************/
416typedef u8 CsrWifiSmeHostPowerMode;
417#define CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE ((CsrWifiSmeHostPowerMode) 0x00)
418#define CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE ((CsrWifiSmeHostPowerMode) 0x01)
419#define CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE ((CsrWifiSmeHostPowerMode) 0x02)
420
421/*******************************************************************************
422
423 NAME
424 CsrWifiSmeIEEE80211Reason
425
426 DESCRIPTION
427 As definined in the IEEE 802.11 standards
428
429 VALUES
430 CSR_WIFI_SME_IEEE80211_REASON_SUCCESS
431 - See IEEE 802.11 Standard
432 CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON
433 - See IEEE 802.11 Standard
434 CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID
435 - See IEEE 802.11 Standard
436 CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS
437 - See IEEE 802.11 Standard
438 CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY
439 - See IEEE 802.11 Standard
440 CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD
441 - See IEEE 802.11 Standard
442 CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR
443 - See IEEE 802.11 Standard
444 CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR
445 - See IEEE 802.11 Standard
446 CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS
447 - See IEEE 802.11 Standard
448 CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED
449 - See IEEE 802.11 Standard
450 CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY
451 - See IEEE 802.11 Standard
452 CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS
453 - See IEEE 802.11 Standard
454 CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT
455 - See IEEE 802.11 Standard
456 CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE
457 - See IEEE 802.11 Standard
458 CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT
459 - See IEEE 802.11 Standard
460 CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT
461 - See IEEE 802.11 Standard
462 CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT
463 - See IEEE 802.11 Standard
464 CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER
465 - See IEEE 802.11 Standard
466 CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER
467 - See IEEE 802.11 Standard
468 CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP
469 - See IEEE 802.11 Standard
470 CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION
471 - See IEEE 802.11 Standard
472 CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES
473 - See IEEE 802.11 Standard
474 CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED
475 - See IEEE 802.11 Standard
476 CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY
477 - See IEEE 802.11 Standard
478 CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS
479 - See IEEE 802.11 Standard
480 CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON
481 - See IEEE 802.11 Standard
482 CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH
483 - See IEEE 802.11 Standard
484 CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK
485 - See IEEE 802.11 Standard
486 CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED
487 - See IEEE 802.11 Standard
488 CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING
489 - See IEEE 802.11 Standard
490 CSR_WIFI_SME_IEEE80211_REASON_END_TS
491 - See IEEE 802.11 Standard
492 CSR_WIFI_SME_IEEE80211_REASON_END_DLS
493 - See IEEE 802.11 Standard
494 CSR_WIFI_SME_IEEE80211_REASON_END_BA
495 - See IEEE 802.11 Standard
496 CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS
497 - See IEEE 802.11 Standard
498 CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA
499 - See IEEE 802.11 Standard
500 CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS
501 - See IEEE 802.11 Standard
502 CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT
503 - See IEEE 802.11 Standard
504 CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH
505 - See IEEE 802.11 Standard
506 CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT
507 - See IEEE 802.11 Standard
508 CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT
509 - See IEEE 802.11 Standard
510 CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE
511 - See IEEE 802.11 Standard
512 CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER
513 - See IEEE 802.11 Standard
514 CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER
515 - See IEEE 802.11 Standard
516 CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION
517 - See IEEE 802.11 Standard
518 CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE
519 - See IEEE 802.11 Standard
520 CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED
521 - See IEEE 802.11 Standard
522
523*******************************************************************************/
524typedef u16 CsrWifiSmeIEEE80211Reason;
525#define CSR_WIFI_SME_IEEE80211_REASON_SUCCESS ((CsrWifiSmeIEEE80211Reason) 0x0000)
526#define CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON ((CsrWifiSmeIEEE80211Reason) 0x0001)
527#define CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID ((CsrWifiSmeIEEE80211Reason) 0x0002)
528#define CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS ((CsrWifiSmeIEEE80211Reason) 0x0003)
529#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY ((CsrWifiSmeIEEE80211Reason) 0x0004)
530#define CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD ((CsrWifiSmeIEEE80211Reason) 0x0005)
531#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR ((CsrWifiSmeIEEE80211Reason) 0x0006)
532#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR ((CsrWifiSmeIEEE80211Reason) 0x0007)
533#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS ((CsrWifiSmeIEEE80211Reason) 0x0008)
534#define CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED ((CsrWifiSmeIEEE80211Reason) 0x0009)
535#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY ((CsrWifiSmeIEEE80211Reason) 0x000a)
536#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS ((CsrWifiSmeIEEE80211Reason) 0x000b)
537#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT ((CsrWifiSmeIEEE80211Reason) 0x000d)
538#define CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE ((CsrWifiSmeIEEE80211Reason) 0x000e)
539#define CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x000f)
540#define CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x0010)
541#define CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT ((CsrWifiSmeIEEE80211Reason) 0x0011)
542#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER ((CsrWifiSmeIEEE80211Reason) 0x0012)
543#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER ((CsrWifiSmeIEEE80211Reason) 0x0013)
544#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP ((CsrWifiSmeIEEE80211Reason) 0x0014)
545#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION ((CsrWifiSmeIEEE80211Reason) 0x0015)
546#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES ((CsrWifiSmeIEEE80211Reason) 0x0016)
547#define CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED ((CsrWifiSmeIEEE80211Reason) 0x0017)
548#define CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY ((CsrWifiSmeIEEE80211Reason) 0x0018)
549#define CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS ((CsrWifiSmeIEEE80211Reason) 0x001F)
550#define CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON ((CsrWifiSmeIEEE80211Reason) 0x0020)
551#define CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeIEEE80211Reason) 0x0021)
552#define CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK ((CsrWifiSmeIEEE80211Reason) 0x0022)
553#define CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED ((CsrWifiSmeIEEE80211Reason) 0x0023)
554#define CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING ((CsrWifiSmeIEEE80211Reason) 0x0024)
555#define CSR_WIFI_SME_IEEE80211_REASON_END_TS ((CsrWifiSmeIEEE80211Reason) 0x0025)
556#define CSR_WIFI_SME_IEEE80211_REASON_END_DLS ((CsrWifiSmeIEEE80211Reason) 0x0025)
557#define CSR_WIFI_SME_IEEE80211_REASON_END_BA ((CsrWifiSmeIEEE80211Reason) 0x0025)
558#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS ((CsrWifiSmeIEEE80211Reason) 0x0026)
559#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA ((CsrWifiSmeIEEE80211Reason) 0x0026)
560#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS ((CsrWifiSmeIEEE80211Reason) 0x0026)
561#define CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x0027)
562#define CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH ((CsrWifiSmeIEEE80211Reason) 0x002d)
563#define CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0xf019)
564#define CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0xf01a)
565#define CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE ((CsrWifiSmeIEEE80211Reason) 0xf01b)
566#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER ((CsrWifiSmeIEEE80211Reason) 0xf01c)
567#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER ((CsrWifiSmeIEEE80211Reason) 0xf01d)
568#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION ((CsrWifiSmeIEEE80211Reason) 0xf01e)
569#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE ((CsrWifiSmeIEEE80211Reason) 0xf01f)
570#define CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED ((CsrWifiSmeIEEE80211Reason) 0xf020)
571
572/*******************************************************************************
573
574 NAME
575 CsrWifiSmeIEEE80211Result
576
577 DESCRIPTION
578 As definined in the IEEE 802.11 standards
579
580 VALUES
581 CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS
582 - See IEEE 802.11 Standard
583 CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE
584 - See IEEE 802.11 Standard
585 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH
586 - See IEEE 802.11 Standard
587 CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION
588 - See IEEE 802.11 Standard
589 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON
590 - See IEEE 802.11 Standard
591 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH
592 - See IEEE 802.11 Standard
593 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER
594 - See IEEE 802.11 Standard
595 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE
596 - See IEEE 802.11 Standard
597 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT
598 - See IEEE 802.11 Standard
599 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY
600 - See IEEE 802.11 Standard
601 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH
602 - See IEEE 802.11 Standard
603 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED
604 - See IEEE 802.11 Standard
605 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED
606 - See IEEE 802.11 Standard
607 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED
608 - See IEEE 802.11 Standard
609 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED
610 - See IEEE 802.11 Standard
611 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE
612 - See IEEE 802.11 Standard
613 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE
614 - See IEEE 802.11 Standard
615 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED
616 - See IEEE 802.11 Standard
617 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED
618 - See IEEE 802.11 Standard
619 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT
620 - See IEEE 802.11 Standard
621 CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE
622 - See IEEE 802.11 Standard
623 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT
624 - See IEEE 802.11 Standard
625 CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY
626 - See IEEE 802.11 Standard
627 CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION
628 - See IEEE 802.11 Standard
629 CSR_WIFI_SME_IEEE80211_RESULT_FAILURE
630 - See IEEE 802.11 Standard
631 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT
632 - See IEEE 802.11 Standard
633 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL
634 - See IEEE 802.11 Standard
635 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED
636 - See IEEE 802.11 Standard
637 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED
638 - See IEEE 802.11 Standard
639 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED
640 - See IEEE 802.11 Standard
641 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS
642 - See IEEE 802.11 Standard
643 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES
644 - See IEEE 802.11 Standard
645 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE
646 - See IEEE 802.11 Standard
647 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER
648 - See IEEE 802.11 Standard
649 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER
650 - See IEEE 802.11 Standard
651 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP
652 - See IEEE 802.11 Standard
653 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION
654 - See IEEE 802.11 Standard
655 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY
656 - See IEEE 802.11 Standard
657 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY
658 - See IEEE 802.11 Standard
659 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD
660 - See IEEE 802.11 Standard
661 CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED
662 - See IEEE 802.11 Standard
663 CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT
664 - See IEEE 802.11 Standard
665 CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA
666 - See IEEE 802.11 Standard
667 CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE
668 - See IEEE 802.11 Standard
669 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT
670 - See IEEE 802.11 Standard
671 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID
672 - See IEEE 802.11 Standard
673 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE
674 - See IEEE 802.11 Standard
675 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE
676 - See IEEE 802.11 Standard
677 CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE
678 - See IEEE 802.11 Standard
679 CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY
680 - See IEEE 802.11 Standard
681 CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH
682 - See IEEE 802.11 Standard
683 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS
684 - See IEEE 802.11 Standard
685 CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT
686 - See IEEE 802.11 Standard
687 CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS
688 - See IEEE 802.11 Standard
689 CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED
690 - See IEEE 802.11 Standard
691 CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED
692 - See IEEE 802.11 Standard
693 CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE
694 - See IEEE 802.11 Standard
695 CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED
696 - See IEEE 802.11 Standard
697 CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START
698 - See IEEE 802.11 Standard
699 CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE
700 - See IEEE 802.11 Standard
701 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER
702 - See IEEE 802.11 Standard
703 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER
704 - See IEEE 802.11 Standard
705 CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION
706 - See IEEE 802.11 Standard
707 CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE
708 - See IEEE 802.11 Standard
709
710*******************************************************************************/
711typedef u16 CsrWifiSmeIEEE80211Result;
712#define CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS ((CsrWifiSmeIEEE80211Result) 0x0000)
713#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE ((CsrWifiSmeIEEE80211Result) 0x0001)
714#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x000a)
715#define CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION ((CsrWifiSmeIEEE80211Result) 0x000b)
716#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON ((CsrWifiSmeIEEE80211Result) 0x000c)
717#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x000d)
718#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER ((CsrWifiSmeIEEE80211Result) 0x000e)
719#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE ((CsrWifiSmeIEEE80211Result) 0x000f)
720#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT ((CsrWifiSmeIEEE80211Result) 0x0010)
721#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY ((CsrWifiSmeIEEE80211Result) 0x0011)
722#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x0012)
723#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0013)
724#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0014)
725#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0015)
726#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0016)
727#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE ((CsrWifiSmeIEEE80211Result) 0x0017)
728#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE ((CsrWifiSmeIEEE80211Result) 0x0018)
729#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0019)
730#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED ((CsrWifiSmeIEEE80211Result) 0x001a)
731#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT ((CsrWifiSmeIEEE80211Result) 0x001b)
732#define CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE ((CsrWifiSmeIEEE80211Result) 0x001c)
733#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT ((CsrWifiSmeIEEE80211Result) 0x001d)
734#define CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY ((CsrWifiSmeIEEE80211Result) 0x001e)
735#define CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION ((CsrWifiSmeIEEE80211Result) 0x001f)
736#define CSR_WIFI_SME_IEEE80211_RESULT_FAILURE ((CsrWifiSmeIEEE80211Result) 0x0020)
737#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT ((CsrWifiSmeIEEE80211Result) 0x0021)
738#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL ((CsrWifiSmeIEEE80211Result) 0x0022)
739#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0023)
740#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED ((CsrWifiSmeIEEE80211Result) 0x0025)
741#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED ((CsrWifiSmeIEEE80211Result) 0x0025)
742#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS ((CsrWifiSmeIEEE80211Result) 0x0026)
743#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES ((CsrWifiSmeIEEE80211Result) 0x0027)
744#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE ((CsrWifiSmeIEEE80211Result) 0x0028)
745#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER ((CsrWifiSmeIEEE80211Result) 0x0029)
746#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER ((CsrWifiSmeIEEE80211Result) 0x002a)
747#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP ((CsrWifiSmeIEEE80211Result) 0x002b)
748#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION ((CsrWifiSmeIEEE80211Result) 0x002c)
749#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY ((CsrWifiSmeIEEE80211Result) 0x002d)
750#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY ((CsrWifiSmeIEEE80211Result) 0x002e)
751#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD ((CsrWifiSmeIEEE80211Result) 0x002f)
752#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED ((CsrWifiSmeIEEE80211Result) 0x0030)
753#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT ((CsrWifiSmeIEEE80211Result) 0x0031)
754#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA ((CsrWifiSmeIEEE80211Result) 0x0032)
755#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE ((CsrWifiSmeIEEE80211Result) 0x0033)
756#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT ((CsrWifiSmeIEEE80211Result) 0x0034)
757#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID ((CsrWifiSmeIEEE80211Result) 0x0035)
758#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE ((CsrWifiSmeIEEE80211Result) 0x0036)
759#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE ((CsrWifiSmeIEEE80211Result) 0x0037)
760#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE ((CsrWifiSmeIEEE80211Result) 0x00c8)
761#define CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY ((CsrWifiSmeIEEE80211Result) 0x00c9)
762#define CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeIEEE80211Result) 0x00ca)
763#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS ((CsrWifiSmeIEEE80211Result) 0x00cb)
764#define CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT ((CsrWifiSmeIEEE80211Result) 0x8000)
765#define CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS ((CsrWifiSmeIEEE80211Result) 0x8001)
766#define CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED ((CsrWifiSmeIEEE80211Result) 0x8002)
767#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED ((CsrWifiSmeIEEE80211Result) 0x8003)
768#define CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE ((CsrWifiSmeIEEE80211Result) 0x8004)
769#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED ((CsrWifiSmeIEEE80211Result) 0x8005)
770#define CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START ((CsrWifiSmeIEEE80211Result) 0x8006)
771#define CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE ((CsrWifiSmeIEEE80211Result) 0x8007)
772#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER ((CsrWifiSmeIEEE80211Result) 0xf02f)
773#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER ((CsrWifiSmeIEEE80211Result) 0xf030)
774#define CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION ((CsrWifiSmeIEEE80211Result) 0xf031)
775#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE ((CsrWifiSmeIEEE80211Result) 0xf032)
776
777/*******************************************************************************
778
779 NAME
780 CsrWifiSmeIndications
781
782 DESCRIPTION
783 Defines bits for CsrWifiSmeIndicationsMask
784
785 VALUES
786 CSR_WIFI_SME_INDICATIONS_NONE
787 - Used to cancel the registrations for receiving indications
788 CSR_WIFI_SME_INDICATIONS_WIFIOFF
789 - Used to register for CSR_WIFI_SME_WIFI_OFF_IND events
790 CSR_WIFI_SME_INDICATIONS_SCANRESULT
791 - Used to register for CSR_WIFI_SME_SCAN_RESULT_IND events
792 CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY
793 - Used to register for CSR_WIFI_SME_CONNECTION_QUALITY_IND
794 events
795 CSR_WIFI_SME_INDICATIONS_MEDIASTATUS
796 - Used to register for CSR_WIFI_SME_MEDIA_STATUS_IND events
797 CSR_WIFI_SME_INDICATIONS_MICFAILURE
798 - Used to register for CSR_WIFI_SME_MICFAILURE_IND events
799 CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST
800 - Used to register for CSR_WIFI_SME_PMKIDCANDIDATE_LIST_IND
801 events
802 CSR_WIFI_SME_INDICATIONS_TSPEC
803 - Used to register for CSR_WIFI_SME_TSPEC_IND events
804 CSR_WIFI_SME_INDICATIONS_ROAMSTART
805 - Used to register for CSR_WIFI_SME_ROAM_START_IND events
806 CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE
807 - Used to register for CSR_WIFI_SME_ROAM_COMPLETE_IND events
808 CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART
809 - Used to register for CSR_WIFI_SME_ASSOCIATION_START_IND
810 events
811 CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE
812 - Used to register for CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND
813 events
814 CSR_WIFI_SME_INDICATIONS_IBSSSTATION
815 - Used to register for CSR_WIFI_SME_IBSS_STATION_IND events
816 CSR_WIFI_SME_INDICATIONS_WIFION
817 - Used to register for CSR_WIFI_SME_WIFI_ON_IND events
818 CSR_WIFI_SME_INDICATIONS_ERROR
819 - Used to register for CSR_WIFI_SME_ERROR_IND events
820 CSR_WIFI_SME_INDICATIONS_INFO
821 - Used to register for CSR_WIFI_SME_INFO_IND events
822 CSR_WIFI_SME_INDICATIONS_COREDUMP
823 - Used to register for CSR_WIFI_SME_CORE_DUMP_IND events
824 CSR_WIFI_SME_INDICATIONS_ALL
825 - Used to register for all available indications
826
827*******************************************************************************/
828typedef u32 CsrWifiSmeIndications;
829#define CSR_WIFI_SME_INDICATIONS_NONE ((CsrWifiSmeIndications) 0x00000000)
830#define CSR_WIFI_SME_INDICATIONS_WIFIOFF ((CsrWifiSmeIndications) 0x00000001)
831#define CSR_WIFI_SME_INDICATIONS_SCANRESULT ((CsrWifiSmeIndications) 0x00000002)
832#define CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY ((CsrWifiSmeIndications) 0x00000004)
833#define CSR_WIFI_SME_INDICATIONS_MEDIASTATUS ((CsrWifiSmeIndications) 0x00000008)
834#define CSR_WIFI_SME_INDICATIONS_MICFAILURE ((CsrWifiSmeIndications) 0x00000010)
835#define CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST ((CsrWifiSmeIndications) 0x00000020)
836#define CSR_WIFI_SME_INDICATIONS_TSPEC ((CsrWifiSmeIndications) 0x00000040)
837#define CSR_WIFI_SME_INDICATIONS_ROAMSTART ((CsrWifiSmeIndications) 0x00000080)
838#define CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE ((CsrWifiSmeIndications) 0x00000100)
839#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART ((CsrWifiSmeIndications) 0x00000200)
840#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE ((CsrWifiSmeIndications) 0x00000400)
841#define CSR_WIFI_SME_INDICATIONS_IBSSSTATION ((CsrWifiSmeIndications) 0x00000800)
842#define CSR_WIFI_SME_INDICATIONS_WIFION ((CsrWifiSmeIndications) 0x00001000)
843#define CSR_WIFI_SME_INDICATIONS_ERROR ((CsrWifiSmeIndications) 0x00002000)
844#define CSR_WIFI_SME_INDICATIONS_INFO ((CsrWifiSmeIndications) 0x00004000)
845#define CSR_WIFI_SME_INDICATIONS_COREDUMP ((CsrWifiSmeIndications) 0x00008000)
846#define CSR_WIFI_SME_INDICATIONS_ALL ((CsrWifiSmeIndications) 0xFFFFFFFF)
847
848/*******************************************************************************
849
850 NAME
851 CsrWifiSmeKeyType
852
853 DESCRIPTION
854 Indicates the type of the key
855
856 VALUES
857 CSR_WIFI_SME_KEY_TYPE_GROUP - Key for broadcast communication
858 CSR_WIFI_SME_KEY_TYPE_PAIRWISE - Key for unicast communication
859 CSR_WIFI_SME_KEY_TYPE_STAKEY - Key for direct link communication to
860 another station in infrastructure networks
861 CSR_WIFI_SME_KEY_TYPE_IGTK - Integrity Group Temporal Key
862 CSR_WIFI_SME_KEY_TYPE_CCKM - Key for Cisco Centralized Key Management
863
864*******************************************************************************/
865typedef u8 CsrWifiSmeKeyType;
866#define CSR_WIFI_SME_KEY_TYPE_GROUP ((CsrWifiSmeKeyType) 0x00)
867#define CSR_WIFI_SME_KEY_TYPE_PAIRWISE ((CsrWifiSmeKeyType) 0x01)
868#define CSR_WIFI_SME_KEY_TYPE_STAKEY ((CsrWifiSmeKeyType) 0x02)
869#define CSR_WIFI_SME_KEY_TYPE_IGTK ((CsrWifiSmeKeyType) 0x03)
870#define CSR_WIFI_SME_KEY_TYPE_CCKM ((CsrWifiSmeKeyType) 0x04)
871
872/*******************************************************************************
873
874 NAME
875 CsrWifiSmeListAction
876
877 DESCRIPTION
878 Identifies the type of action to be performed on a list of items
879 The values of this type are used across the NME/SME/Router API's and they
880 must be kept consistent with the corresponding types in the .xml of the
881 ottherinterfaces
882
883 VALUES
884 CSR_WIFI_SME_LIST_ACTION_GET - Retrieve the current list of items
885 CSR_WIFI_SME_LIST_ACTION_ADD - Add one or more items
886 CSR_WIFI_SME_LIST_ACTION_REMOVE - Remove one or more items
887 CSR_WIFI_SME_LIST_ACTION_FLUSH - Remove all items
888
889*******************************************************************************/
890typedef u8 CsrWifiSmeListAction;
891#define CSR_WIFI_SME_LIST_ACTION_GET ((CsrWifiSmeListAction) 0x00)
892#define CSR_WIFI_SME_LIST_ACTION_ADD ((CsrWifiSmeListAction) 0x01)
893#define CSR_WIFI_SME_LIST_ACTION_REMOVE ((CsrWifiSmeListAction) 0x02)
894#define CSR_WIFI_SME_LIST_ACTION_FLUSH ((CsrWifiSmeListAction) 0x03)
895
896/*******************************************************************************
897
898 NAME
899 CsrWifiSmeMediaStatus
900
901 DESCRIPTION
902 Indicates the connection status
903 The values of this type are used across the NME/SME/Router API's and they
904 must be kept consistent with the corresponding types in the .xml of the
905 ottherinterfaces
906
907 VALUES
908 CSR_WIFI_SME_MEDIA_STATUS_CONNECTED
909 - Value CSR_WIFI_SME_MEDIA_STATUS_CONNECTED can happen in two
910 situations:
911 * A network connection is established. Specifically, this is
912 when the MLME_ASSOCIATION completes or the first peer
913 relationship is established in an IBSS. In a WPA/WPA2
914 network, this indicates that the stack is ready to perform
915 the 4-way handshake or 802.1x authentication if CSR NME
916 security library is not used. If CSR NME security library
917 is used this indicates, completion of 4way handshake or
918 802.1x authentication
919 * The SME roams to another AP on the same ESS
920 During the AP operation, it indicates that the peer station
921 is connected to the AP and is ready for data transfer.
922 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED
923 - Value CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED can happen in
924 two situations:
925 * when the connection to a network is lost and there is no
926 alternative on the same ESS to roam to
927 * when a CSR_WIFI_SME_DISCONNECT_REQ request is issued
928 During AP or P2PGO operation, it indicates that the peer
929 station has disconnected from the AP
930
931*******************************************************************************/
932typedef u8 CsrWifiSmeMediaStatus;
933#define CSR_WIFI_SME_MEDIA_STATUS_CONNECTED ((CsrWifiSmeMediaStatus) 0x00)
934#define CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED ((CsrWifiSmeMediaStatus) 0x01)
935
936/*******************************************************************************
937
938 NAME
939 CsrWifiSmeP2pCapability
940
941 DESCRIPTION
942 Defines P2P Device Capabilities
943
944 VALUES
945 CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY
946 - This field is set to 1 if the P2P Device supports Service
947 Discovery, and to 0 otherwise
948 CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY
949 - This field is set to 1 when the P2P Device supports P2P
950 Client Discoverability, and to 0 otherwise.
951 CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY
952 - This field is set to 1 when the P2P Device supports
953 Concurrent Operation with WLAN, and to 0 otherwise.
954 CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY
955 - This field is set to 1 when the P2P interface of the P2P
956 Device is capable of being managed by the WLAN
957 (infrastructure network) based on P2P coexistence
958 parameters, and to 0 otherwise
959 CSR_WIFI_SME_P2P_INVITAION_CAPABILITY
960 - This field is set to 1 if the P2P Device is capable of
961 processing P2P Invitation Procedure signaling, and to 0
962 otherwise.
963
964*******************************************************************************/
965typedef u8 CsrWifiSmeP2pCapability;
966#define CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY ((CsrWifiSmeP2pCapability) 0x01)
967#define CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY ((CsrWifiSmeP2pCapability) 0x02)
968#define CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY ((CsrWifiSmeP2pCapability) 0x04)
969#define CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY ((CsrWifiSmeP2pCapability) 0x08)
970#define CSR_WIFI_SME_P2P_INVITAION_CAPABILITY ((CsrWifiSmeP2pCapability) 0x20)
971
972/*******************************************************************************
973
974 NAME
975 CsrWifiSmeP2pGroupCapability
976
977 DESCRIPTION
978 Define bits for P2P Group Capability
979
980 VALUES
981 CSR_WIFI_P2P_GRP_CAP_GO
982 - Indicates if the local device has become a GO after GO
983 negotiation
984 CSR_WIFI_P2P_GRP_CAP_PERSISTENT
985 - Persistent group
986 CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST
987 - Intra-BSS data distribution support
988 CSR_WIFI_P2P_GRP_CAP_CROSS_CONN
989 - Support of cross connection
990 CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT
991 - Support of persistent reconnect
992
993*******************************************************************************/
994typedef u8 CsrWifiSmeP2pGroupCapability;
995#define CSR_WIFI_P2P_GRP_CAP_GO ((CsrWifiSmeP2pGroupCapability) 0x01)
996#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT ((CsrWifiSmeP2pGroupCapability) 0x02)
997#define CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST ((CsrWifiSmeP2pGroupCapability) 0x08)
998#define CSR_WIFI_P2P_GRP_CAP_CROSS_CONN ((CsrWifiSmeP2pGroupCapability) 0x10)
999#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT ((CsrWifiSmeP2pGroupCapability) 0x20)
1000
1001/*******************************************************************************
1002
1003 NAME
1004 CsrWifiSmeP2pNoaConfigMethod
1005
1006 DESCRIPTION
1007 Notice of Absece Configuration
1008
1009 VALUES
1010 CSR_WIFI_P2P_NOA_NONE - Do not use NOA
1011 CSR_WIFI_P2P_NOA_AUTONOMOUS - NOA based on the traffic analysis
1012 CSR_WIFI_P2P_NOA_USER_DEFINED - NOA as specified by the user
1013
1014*******************************************************************************/
1015typedef u8 CsrWifiSmeP2pNoaConfigMethod;
1016#define CSR_WIFI_P2P_NOA_NONE ((CsrWifiSmeP2pNoaConfigMethod) 0x00)
1017#define CSR_WIFI_P2P_NOA_AUTONOMOUS ((CsrWifiSmeP2pNoaConfigMethod) 0x01)
1018#define CSR_WIFI_P2P_NOA_USER_DEFINED ((CsrWifiSmeP2pNoaConfigMethod) 0x02)
1019
1020/*******************************************************************************
1021
1022 NAME
1023 CsrWifiSmeP2pRole
1024
1025 DESCRIPTION
1026 Definition of roles for a P2P Device
1027
1028 VALUES
1029 CSR_WIFI_SME_P2P_ROLE_NONE - A non-P2PDevice device
1030 CSR_WIFI_SME_P2P_ROLE_STANDALONE - A Standalone P2P device
1031 CSR_WIFI_SME_P2P_ROLE_GO - Role Assumed is that of a Group Owner
1032 within a P2P Group
1033 CSR_WIFI_SME_P2P_ROLE_CLI - Role Assumed is that of a P2P Client
1034 within a P2P Group
1035
1036*******************************************************************************/
1037typedef u8 CsrWifiSmeP2pRole;
1038#define CSR_WIFI_SME_P2P_ROLE_NONE ((CsrWifiSmeP2pRole) 0x00)
1039#define CSR_WIFI_SME_P2P_ROLE_STANDALONE ((CsrWifiSmeP2pRole) 0x01)
1040#define CSR_WIFI_SME_P2P_ROLE_GO ((CsrWifiSmeP2pRole) 0x02)
1041#define CSR_WIFI_SME_P2P_ROLE_CLI ((CsrWifiSmeP2pRole) 0x03)
1042
1043/*******************************************************************************
1044
1045 NAME
1046 CsrWifiSmeP2pStatus
1047
1048 DESCRIPTION
1049 This data type enumerates the outcome of P2P procedure
1050
1051 VALUES
1052 CSR_WIFI_SME_P2P_STATUS_SUCCESS
1053 - Success
1054 CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE
1055 - Fail; information is currently unavailable
1056 CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM
1057 - Fail; incompatible parameters
1058 CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED
1059 - Fail; limit reached
1060 CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM
1061 - Fail; invalid parameters
1062 CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE
1063 - Fail; unable to accommodate request
1064 CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR
1065 - Fail; previous protocol error, or disruptive behavior
1066 CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS
1067 - Fail; no common channels
1068 CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP
1069 - Fail; unknown P2P Group
1070 CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT
1071 - Fail: both P2P Devices indicated an Intent of 15 in Group
1072 Owner Negotiation
1073 CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE
1074 - Fail; incompatible provisioning method
1075 CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT
1076 - Fail: rejected by user
1077 CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED
1078 - Fail; Status Reserved
1079
1080*******************************************************************************/
1081typedef u8 CsrWifiSmeP2pStatus;
1082#define CSR_WIFI_SME_P2P_STATUS_SUCCESS ((CsrWifiSmeP2pStatus) 0x00)
1083#define CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE ((CsrWifiSmeP2pStatus) 0x01)
1084#define CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM ((CsrWifiSmeP2pStatus) 0x02)
1085#define CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED ((CsrWifiSmeP2pStatus) 0x03)
1086#define CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM ((CsrWifiSmeP2pStatus) 0x04)
1087#define CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE ((CsrWifiSmeP2pStatus) 0x05)
1088#define CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR ((CsrWifiSmeP2pStatus) 0x06)
1089#define CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS ((CsrWifiSmeP2pStatus) 0x07)
1090#define CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP ((CsrWifiSmeP2pStatus) 0x08)
1091#define CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT ((CsrWifiSmeP2pStatus) 0x09)
1092#define CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE ((CsrWifiSmeP2pStatus) 0x0A)
1093#define CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT ((CsrWifiSmeP2pStatus) 0x0B)
1094#define CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED ((CsrWifiSmeP2pStatus) 0xFF)
1095
1096/*******************************************************************************
1097
1098 NAME
1099 CsrWifiSmePacketFilterMode
1100
1101 DESCRIPTION
1102 Options for the filter mode parameter.
1103 The Values here match the HIP interface
1104
1105 VALUES
1106 CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT
1107 - Broadcast packets are always reported to the host unless
1108 they match at least one of the specified TCLAS IEs.
1109 CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN
1110 - Broadcast packets are reported to the host only if they
1111 match at least one of the specified TCLAS IEs.
1112
1113*******************************************************************************/
1114typedef u8 CsrWifiSmePacketFilterMode;
1115#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT ((CsrWifiSmePacketFilterMode) 0x00)
1116#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN ((CsrWifiSmePacketFilterMode) 0x03)
1117
1118/*******************************************************************************
1119
1120 NAME
1121 CsrWifiSmePowerSaveLevel
1122
1123 DESCRIPTION
1124 Power Save Level options as defined in the IEEE 802.11 standards
1125 First 3 values are set to match the mlme PowerManagementMode
1126
1127 VALUES
1128 CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW - No power save: the driver will remain
1129 active at all times
1130 CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH - Enter power save after all packets in
1131 the queues are transmitted and received
1132 CSR_WIFI_SME_POWER_SAVE_LEVEL_MED - Enter power save after all packets in
1133 the queues are transmitted and received
1134 and a further configurable delay
1135 (default 1s) has elapsed
1136 CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO - The SME will decide when to enter power
1137 save mode according to the traffic
1138 analysis
1139
1140*******************************************************************************/
1141typedef u8 CsrWifiSmePowerSaveLevel;
1142#define CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW ((CsrWifiSmePowerSaveLevel) 0x00)
1143#define CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH ((CsrWifiSmePowerSaveLevel) 0x01)
1144#define CSR_WIFI_SME_POWER_SAVE_LEVEL_MED ((CsrWifiSmePowerSaveLevel) 0x02)
1145#define CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO ((CsrWifiSmePowerSaveLevel) 0x03)
1146
1147/*******************************************************************************
1148
1149 NAME
1150 CsrWifiSmePreambleType
1151
1152 DESCRIPTION
1153 SME Preamble Types
1154
1155 VALUES
1156 CSR_WIFI_SME_USE_LONG_PREAMBLE - Use legacy (long) preamble
1157 CSR_WIFI_SME_USE_SHORT_PREAMBLE - Use short PPDU format
1158
1159*******************************************************************************/
1160typedef u8 CsrWifiSmePreambleType;
1161#define CSR_WIFI_SME_USE_LONG_PREAMBLE ((CsrWifiSmePreambleType) 0x00)
1162#define CSR_WIFI_SME_USE_SHORT_PREAMBLE ((CsrWifiSmePreambleType) 0x01)
1163
1164/*******************************************************************************
1165
1166 NAME
1167 CsrWifiSmeRadioIF
1168
1169 DESCRIPTION
1170 Indicates the frequency
1171
1172 VALUES
1173 CSR_WIFI_SME_RADIO_IF_GHZ_2_4 - Indicates the 2.4 GHZ frequency
1174 CSR_WIFI_SME_RADIO_IF_GHZ_5_0 - Future use: currently not supported
1175 CSR_WIFI_SME_RADIO_IF_BOTH - Future use: currently not supported
1176
1177*******************************************************************************/
1178typedef u8 CsrWifiSmeRadioIF;
1179#define CSR_WIFI_SME_RADIO_IF_GHZ_2_4 ((CsrWifiSmeRadioIF) 0x01)
1180#define CSR_WIFI_SME_RADIO_IF_GHZ_5_0 ((CsrWifiSmeRadioIF) 0x02)
1181#define CSR_WIFI_SME_RADIO_IF_BOTH ((CsrWifiSmeRadioIF) 0x03)
1182
1183/*******************************************************************************
1184
1185 NAME
1186 CsrWifiSmeRegulatoryDomain
1187
1188 DESCRIPTION
1189 Indicates the regulatory domain as defined in IEEE 802.11 standards
1190
1191 VALUES
1192 CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER
1193 - See IEEE 802.11 Standard
1194 CSR_WIFI_SME_REGULATORY_DOMAIN_FCC
1195 - See IEEE 802.11 Standard
1196 CSR_WIFI_SME_REGULATORY_DOMAIN_IC
1197 - See IEEE 802.11 Standard
1198 CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI
1199 - See IEEE 802.11 Standard
1200 CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN
1201 - See IEEE 802.11 Standard
1202 CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE
1203 - See IEEE 802.11 Standard
1204 CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN
1205 - See IEEE 802.11 Standard
1206 CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS
1207 - See IEEE 802.11 Standard
1208 CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA
1209 - See IEEE 802.11 Standard
1210 CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS
1211 - See IEEE 802.11 Standard
1212 CSR_WIFI_SME_REGULATORY_DOMAIN_NONE
1213 - See IEEE 802.11 Standard
1214
1215*******************************************************************************/
1216typedef u8 CsrWifiSmeRegulatoryDomain;
1217#define CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER ((CsrWifiSmeRegulatoryDomain) 0x00)
1218#define CSR_WIFI_SME_REGULATORY_DOMAIN_FCC ((CsrWifiSmeRegulatoryDomain) 0x10)
1219#define CSR_WIFI_SME_REGULATORY_DOMAIN_IC ((CsrWifiSmeRegulatoryDomain) 0x20)
1220#define CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI ((CsrWifiSmeRegulatoryDomain) 0x30)
1221#define CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN ((CsrWifiSmeRegulatoryDomain) 0x31)
1222#define CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE ((CsrWifiSmeRegulatoryDomain) 0x32)
1223#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN ((CsrWifiSmeRegulatoryDomain) 0x40)
1224#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS ((CsrWifiSmeRegulatoryDomain) 0x41)
1225#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA ((CsrWifiSmeRegulatoryDomain) 0x50)
1226#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS ((CsrWifiSmeRegulatoryDomain) 0x51)
1227#define CSR_WIFI_SME_REGULATORY_DOMAIN_NONE ((CsrWifiSmeRegulatoryDomain) 0xFF)
1228
1229/*******************************************************************************
1230
1231 NAME
1232 CsrWifiSmeRoamReason
1233
1234 DESCRIPTION
1235 Indicates the reason for roaming
1236
1237 VALUES
1238 CSR_WIFI_SME_ROAM_REASON_BEACONLOST
1239 - The station cannot receive the beacon signal any more
1240 CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED
1241 - The station has been disassociated
1242 CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED
1243 - The station has been deauthenticated
1244 CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND
1245 - A better AP has been found
1246
1247*******************************************************************************/
1248typedef u8 CsrWifiSmeRoamReason;
1249#define CSR_WIFI_SME_ROAM_REASON_BEACONLOST ((CsrWifiSmeRoamReason) 0x00)
1250#define CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED ((CsrWifiSmeRoamReason) 0x01)
1251#define CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED ((CsrWifiSmeRoamReason) 0x02)
1252#define CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND ((CsrWifiSmeRoamReason) 0x03)
1253
1254/*******************************************************************************
1255
1256 NAME
1257 CsrWifiSmeScanType
1258
1259 DESCRIPTION
1260 Identifies the type of scan to be performed
1261
1262 VALUES
1263 CSR_WIFI_SME_SCAN_TYPE_ALL - Scan actively or passively according to the
1264 regulatory domain restrictions
1265 CSR_WIFI_SME_SCAN_TYPE_ACTIVE - Scan actively only: send probes and listen
1266 for answers
1267 CSR_WIFI_SME_SCAN_TYPE_PASSIVE - Scan passively only: listen for beacon
1268 messages
1269
1270*******************************************************************************/
1271typedef u8 CsrWifiSmeScanType;
1272#define CSR_WIFI_SME_SCAN_TYPE_ALL ((CsrWifiSmeScanType) 0x00)
1273#define CSR_WIFI_SME_SCAN_TYPE_ACTIVE ((CsrWifiSmeScanType) 0x01)
1274#define CSR_WIFI_SME_SCAN_TYPE_PASSIVE ((CsrWifiSmeScanType) 0x02)
1275
1276/*******************************************************************************
1277
1278 NAME
1279 CsrWifiSmeTrafficType
1280
1281 DESCRIPTION
1282 Identifies the type of traffic going on on the connection.
1283 The values of this type are used across the NME/SME/Router API's and they
1284 must be kept consistent with the corresponding types in the .xml of the
1285 ottherinterfaces
1286
1287 VALUES
1288 CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL
1289 - During the last 30 seconds there were fewer than 20 packets
1290 per seconds in each second in both directions
1291 CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY
1292 - During the last 30 seconds there was at least one second
1293 during which more than 20 packets were received in either
1294 direction
1295 CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC
1296 - During the last 5 seconds there were at least 10 packets
1297 received each second and a defined period for the traffic
1298 can be recognized
1299 CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS
1300 - During the last 5 seconds there were at least 20 packets
1301 received each second in either direction
1302
1303*******************************************************************************/
1304typedef u8 CsrWifiSmeTrafficType;
1305#define CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL ((CsrWifiSmeTrafficType) 0x00)
1306#define CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY ((CsrWifiSmeTrafficType) 0x01)
1307#define CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC ((CsrWifiSmeTrafficType) 0x02)
1308#define CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS ((CsrWifiSmeTrafficType) 0x03)
1309
1310/*******************************************************************************
1311
1312 NAME
1313 CsrWifiSmeTspecCtrl
1314
1315 DESCRIPTION
1316 Defines bits for CsrWifiSmeTspecCtrlMask for additional CCX configuration.
1317 CURRENTLY NOT SUPPORTED.
1318
1319 VALUES
1320 CSR_WIFI_SME_TSPEC_CTRL_STRICT
1321 - No automatic negotiation
1322 CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING
1323 - Signalling TSPEC
1324 CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE
1325 - Voice traffic TSPEC
1326
1327*******************************************************************************/
1328typedef u8 CsrWifiSmeTspecCtrl;
1329#define CSR_WIFI_SME_TSPEC_CTRL_STRICT ((CsrWifiSmeTspecCtrl) 0x01)
1330#define CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING ((CsrWifiSmeTspecCtrl) 0x02)
1331#define CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE ((CsrWifiSmeTspecCtrl) 0x04)
1332
1333/*******************************************************************************
1334
1335 NAME
1336 CsrWifiSmeTspecResultCode
1337
1338 DESCRIPTION
1339 Defines the result of the TSPEC exchanges with the AP
1340
1341 VALUES
1342 CSR_WIFI_SME_TSPEC_RESULT_SUCCESS
1343 - TSPEC command has been processed correctly
1344 CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE
1345 - The Access Point reported a failure
1346 CSR_WIFI_SME_TSPEC_RESULT_FAILURE
1347 - Internal failure in the SME
1348 CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS
1349 - The TSPEC parameters are invalid
1350 CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS
1351 - The TCLASS parameters are invalid
1352 CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH
1353 - As specified by the WMM Spec
1354 CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY
1355 - As specified by the WMM Spec
1356 CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES
1357 - As specified by the WMM Spec
1358 CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT
1359 - The TSPEC negotiation timed out
1360 CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED
1361 - The Access Point does not support the TSPEC
1362 CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT
1363 - The length of the TSPEC is not correct
1364 CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID
1365 - The TSPEC transaction id is not in the list
1366 CSR_WIFI_SME_TSPEC_RESULT_INSTALLED
1367 - The TSPEC has been installed and it is now active.
1368 CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED
1369 - The Traffic ID has already been installed
1370 CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED
1371 - The AP has deleted the TSPEC
1372
1373*******************************************************************************/
1374typedef u8 CsrWifiSmeTspecResultCode;
1375#define CSR_WIFI_SME_TSPEC_RESULT_SUCCESS ((CsrWifiSmeTspecResultCode) 0x00)
1376#define CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE ((CsrWifiSmeTspecResultCode) 0x01)
1377#define CSR_WIFI_SME_TSPEC_RESULT_FAILURE ((CsrWifiSmeTspecResultCode) 0x02)
1378#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS ((CsrWifiSmeTspecResultCode) 0x05)
1379#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS ((CsrWifiSmeTspecResultCode) 0x06)
1380#define CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeTspecResultCode) 0x07)
1381#define CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY ((CsrWifiSmeTspecResultCode) 0x08)
1382#define CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES ((CsrWifiSmeTspecResultCode) 0x09)
1383#define CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT ((CsrWifiSmeTspecResultCode) 0x0D)
1384#define CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED ((CsrWifiSmeTspecResultCode) 0x0E)
1385#define CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT ((CsrWifiSmeTspecResultCode) 0x10)
1386#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID ((CsrWifiSmeTspecResultCode) 0x11)
1387#define CSR_WIFI_SME_TSPEC_RESULT_INSTALLED ((CsrWifiSmeTspecResultCode) 0x12)
1388#define CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED ((CsrWifiSmeTspecResultCode) 0x13)
1389#define CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED ((CsrWifiSmeTspecResultCode) 0x14)
1390
1391/*******************************************************************************
1392
1393 NAME
1394 CsrWifiSmeWepAuthMode
1395
1396 DESCRIPTION
1397 Define bits for CsrWifiSmeWepAuthMode
1398
1399 VALUES
1400 CSR_WIFI_SME_WEP_AUTH_MODE_OPEN - Open-WEP enabled network
1401 CSR_WIFI_SME_WEP_AUTH_MODE_SHARED - Shared-key WEP enabled network.
1402
1403*******************************************************************************/
1404typedef u8 CsrWifiSmeWepAuthMode;
1405#define CSR_WIFI_SME_WEP_AUTH_MODE_OPEN ((CsrWifiSmeWepAuthMode) 0x00)
1406#define CSR_WIFI_SME_WEP_AUTH_MODE_SHARED ((CsrWifiSmeWepAuthMode) 0x01)
1407
1408/*******************************************************************************
1409
1410 NAME
1411 CsrWifiSmeWepCredentialType
1412
1413 DESCRIPTION
1414 Definition of types of WEP Credentials
1415
1416 VALUES
1417 CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64
1418 - WEP 64 credential
1419 CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128
1420 - WEP 128 credential
1421
1422*******************************************************************************/
1423typedef u8 CsrWifiSmeWepCredentialType;
1424#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64 ((CsrWifiSmeWepCredentialType) 0x00)
1425#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128 ((CsrWifiSmeWepCredentialType) 0x01)
1426
1427/*******************************************************************************
1428
1429 NAME
1430 CsrWifiSmeWmmMode
1431
1432 DESCRIPTION
1433 Defines bits for CsrWifiSmeWmmModeMask: enable/disable WMM features.
1434
1435 VALUES
1436 CSR_WIFI_SME_WMM_MODE_DISABLED - Disables the WMM features.
1437 CSR_WIFI_SME_WMM_MODE_AC_ENABLED - Enables support for WMM-AC.
1438 CSR_WIFI_SME_WMM_MODE_PS_ENABLED - Enables support for WMM Power Save.
1439 CSR_WIFI_SME_WMM_MODE_SA_ENABLED - Currently not supported
1440 CSR_WIFI_SME_WMM_MODE_ENABLED - Enables support for all currently
1441 available WMM features.
1442
1443*******************************************************************************/
1444typedef u8 CsrWifiSmeWmmMode;
1445#define CSR_WIFI_SME_WMM_MODE_DISABLED ((CsrWifiSmeWmmMode) 0x00)
1446#define CSR_WIFI_SME_WMM_MODE_AC_ENABLED ((CsrWifiSmeWmmMode) 0x01)
1447#define CSR_WIFI_SME_WMM_MODE_PS_ENABLED ((CsrWifiSmeWmmMode) 0x02)
1448#define CSR_WIFI_SME_WMM_MODE_SA_ENABLED ((CsrWifiSmeWmmMode) 0x04)
1449#define CSR_WIFI_SME_WMM_MODE_ENABLED ((CsrWifiSmeWmmMode) 0xFF)
1450
1451/*******************************************************************************
1452
1453 NAME
1454 CsrWifiSmeWmmQosInfo
1455
1456 DESCRIPTION
1457 Defines bits for the QoS Info Octect as defined in the WMM specification.
1458 The first four values define one bit each that can be set or cleared.
1459 Each of the last four values define all the remaining 4 bits and only one
1460 of them at the time shall be used.
1461 For more information, see 'WMM (including WMM Power Save) Specification -
1462 Version 1.1' and 'UniFi Configuring WMM and WMM-PS, Application Note'.
1463
1464 VALUES
1465 CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL
1466 - WMM AP may deliver all buffered frames
1467 CSR_WIFI_SME_WMM_QOS_INFO_AC_VO
1468 - Enable UAPSD(both trigger and delivery) for Voice Access
1469 Category
1470 CSR_WIFI_SME_WMM_QOS_INFO_AC_VI
1471 - Enable UAPSD(both trigger and delivery) for Video Access
1472 Category
1473 CSR_WIFI_SME_WMM_QOS_INFO_AC_BK
1474 - Enable UAPSD(both trigger and delivery) for Background
1475 Access Category
1476 CSR_WIFI_SME_WMM_QOS_INFO_AC_BE
1477 - Enable UAPSD(both trigger and delivery) for Best Effort
1478 Access Category
1479 CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO
1480 - WMM AP may deliver a maximum of 2 buffered frames (MSDUs
1481 and MMPDUs) per USP
1482 CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR
1483 - WMM AP may deliver a maximum of 4 buffered frames (MSDUs
1484 and MMPDUs) per USP
1485 CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX
1486 - WMM AP may deliver a maximum of 6 buffered frames (MSDUs
1487 and MMPDUs) per USP
1488
1489*******************************************************************************/
1490typedef u8 CsrWifiSmeWmmQosInfo;
1491#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL ((CsrWifiSmeWmmQosInfo) 0x00)
1492#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VO ((CsrWifiSmeWmmQosInfo) 0x01)
1493#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VI ((CsrWifiSmeWmmQosInfo) 0x02)
1494#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BK ((CsrWifiSmeWmmQosInfo) 0x04)
1495#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BE ((CsrWifiSmeWmmQosInfo) 0x08)
1496#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO ((CsrWifiSmeWmmQosInfo) 0x20)
1497#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR ((CsrWifiSmeWmmQosInfo) 0x40)
1498#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX ((CsrWifiSmeWmmQosInfo) 0x60)
1499
1500/*******************************************************************************
1501
1502 NAME
1503 CsrWifiSmeWpsConfigType
1504
1505 DESCRIPTION
1506 WPS config methods supported/used by a device
1507
1508 VALUES
1509 CSR_WIFI_WPS_CONFIG_LABEL
1510 - Label
1511 CSR_WIFI_WPS_CONFIG_DISPLAY
1512 - Display
1513 CSR_WIFI_WPS_CONFIG_EXT_NFC
1514 - External NFC : Not supported in this release
1515 CSR_WIFI_WPS_CONFIG_INT_NFC
1516 - Internal NFC : Not supported in this release
1517 CSR_WIFI_WPS_CONFIG_NFC_IFACE
1518 - NFC interface : Not supported in this release
1519 CSR_WIFI_WPS_CONFIG_PBC
1520 - PBC
1521 CSR_WIFI_WPS_CONFIG_KEYPAD
1522 - KeyPad
1523 CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC
1524 - PBC through software user interface
1525 CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC
1526 - Physical PBC
1527 CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY
1528 - Virtual Display : via html config page etc
1529 CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY
1530 - Physical Display : Attached to the device
1531
1532*******************************************************************************/
1533typedef u16 CsrWifiSmeWpsConfigType;
1534#define CSR_WIFI_WPS_CONFIG_LABEL ((CsrWifiSmeWpsConfigType) 0x0004)
1535#define CSR_WIFI_WPS_CONFIG_DISPLAY ((CsrWifiSmeWpsConfigType) 0x0008)
1536#define CSR_WIFI_WPS_CONFIG_EXT_NFC ((CsrWifiSmeWpsConfigType) 0x0010)
1537#define CSR_WIFI_WPS_CONFIG_INT_NFC ((CsrWifiSmeWpsConfigType) 0x0020)
1538#define CSR_WIFI_WPS_CONFIG_NFC_IFACE ((CsrWifiSmeWpsConfigType) 0x0040)
1539#define CSR_WIFI_WPS_CONFIG_PBC ((CsrWifiSmeWpsConfigType) 0x0080)
1540#define CSR_WIFI_WPS_CONFIG_KEYPAD ((CsrWifiSmeWpsConfigType) 0x0100)
1541#define CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC ((CsrWifiSmeWpsConfigType) 0x0280)
1542#define CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC ((CsrWifiSmeWpsConfigType) 0x0480)
1543#define CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY ((CsrWifiSmeWpsConfigType) 0x2008)
1544#define CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY ((CsrWifiSmeWpsConfigType) 0x4008)
1545
1546/*******************************************************************************
1547
1548 NAME
1549 CsrWifiSmeWpsDeviceCategory
1550
1551 DESCRIPTION
1552 Wps Primary Device Types
1553
1554 VALUES
1555 CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED
1556 - Unspecified.
1557 CSR_WIFI_SME_WPS_CATEGORY_COMPUTER
1558 - Computer.
1559 CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV
1560 - Input device
1561 CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP
1562 - Printer Scanner Fax Copier etc
1563 CSR_WIFI_SME_WPS_CATEGORY_CAMERA
1564 - Camera
1565 CSR_WIFI_SME_WPS_CATEGORY_STORAGE
1566 - Storage
1567 CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA
1568 - Net Infra
1569 CSR_WIFI_SME_WPS_CATEGORY_DISPLAY
1570 - Display
1571 CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA
1572 - Multimedia
1573 CSR_WIFI_SME_WPS_CATEGORY_GAMING
1574 - Gaming.
1575 CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE
1576 - Telephone.
1577 CSR_WIFI_SME_WPS_CATEGORY_AUDIO
1578 - Audio
1579 CSR_WIFI_SME_WPS_CATEOARY_OTHERS
1580 - Others.
1581
1582*******************************************************************************/
1583typedef u8 CsrWifiSmeWpsDeviceCategory;
1584#define CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED ((CsrWifiSmeWpsDeviceCategory) 0x00)
1585#define CSR_WIFI_SME_WPS_CATEGORY_COMPUTER ((CsrWifiSmeWpsDeviceCategory) 0x01)
1586#define CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV ((CsrWifiSmeWpsDeviceCategory) 0x02)
1587#define CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP ((CsrWifiSmeWpsDeviceCategory) 0x03)
1588#define CSR_WIFI_SME_WPS_CATEGORY_CAMERA ((CsrWifiSmeWpsDeviceCategory) 0x04)
1589#define CSR_WIFI_SME_WPS_CATEGORY_STORAGE ((CsrWifiSmeWpsDeviceCategory) 0x05)
1590#define CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA ((CsrWifiSmeWpsDeviceCategory) 0x06)
1591#define CSR_WIFI_SME_WPS_CATEGORY_DISPLAY ((CsrWifiSmeWpsDeviceCategory) 0x07)
1592#define CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA ((CsrWifiSmeWpsDeviceCategory) 0x08)
1593#define CSR_WIFI_SME_WPS_CATEGORY_GAMING ((CsrWifiSmeWpsDeviceCategory) 0x09)
1594#define CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE ((CsrWifiSmeWpsDeviceCategory) 0x0A)
1595#define CSR_WIFI_SME_WPS_CATEGORY_AUDIO ((CsrWifiSmeWpsDeviceCategory) 0x0B)
1596#define CSR_WIFI_SME_WPS_CATEOARY_OTHERS ((CsrWifiSmeWpsDeviceCategory) 0xFF)
1597
1598/*******************************************************************************
1599
1600 NAME
1601 CsrWifiSmeWpsDeviceSubCategory
1602
1603 DESCRIPTION
1604 Wps Secondary Device Types
1605
1606 VALUES
1607 CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED
1608 - Unspecied
1609 CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS
1610 - Network Associated Storage
1611 CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR
1612 - Printer or print server
1613 CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM
1614 - Windows mobile
1615 CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER
1616 - Audio tuner/receiver
1617 CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL
1618 - Digital still camera
1619 CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP
1620 - Access Point
1621 CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV
1622 - TV.
1623 CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR
1624 - DAR.
1625 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD
1626 - Keyboard.
1627 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC
1628 - PC.
1629 CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX
1630 - Xbox.
1631 CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR
1632 - Scanner
1633 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER
1634 - Server
1635 CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER
1636 - Router
1637 CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR
1638 - PVR
1639 CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER
1640 - Speaker
1641 CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM
1642 - Feature phone - Single mode
1643 CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO
1644 - Video camera
1645 CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM
1646 - Picture frame
1647 CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360
1648 - Xbox360
1649 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE
1650 - Mouse
1651 CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH
1652 - Switch
1653 CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP
1654 - Portable music player
1655 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK
1656 - Joy stick
1657 CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN
1658 - Play-station
1659 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT
1660 - Media Center
1661 CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX
1662 - MCX
1663 CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM
1664 - Feature phone - Dual mode
1665 CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB
1666 - Web camera
1667 CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX
1668 - Fax
1669 CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR
1670 - Projector
1671 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL
1672 - Track Ball
1673 CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX
1674 - Set-Top-Box
1675 CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY
1676 - GateWay.
1677 CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY
1678 - Security camera
1679 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC
1680 - Ultra mobile PC.
1681 CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE
1682 - Game console/Game console adapter
1683 CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR
1684 - Copier
1685 CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET
1686 - Headset(headphones + microphone)
1687 CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM
1688 - Smart phone - Single mode
1689 CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR
1690 - Monitor.
1691 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL
1692 - Game control.
1693 CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL
1694 - All-in-One
1695 CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA
1696 - Media Server/Media Adapter/Media Extender
1697 CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM
1698 - Smart phone - Dual mode
1699 CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV
1700 - Portable gaming device
1701 CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE
1702 - Headphone.
1703 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK
1704 - Notebook.
1705 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE
1706 - Remote control
1707 CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC
1708 - Microphone
1709 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP
1710 - Desktop.
1711 CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP
1712 - Portable video player
1713 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID
1714 - Mobile internet device
1715 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN
1716 - Touch screen
1717 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR
1718 - Biometric reader
1719 CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK
1720 - Netbook
1721 CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR
1722 - Bar code reader.
1723
1724*******************************************************************************/
1725typedef u8 CsrWifiSmeWpsDeviceSubCategory;
1726#define CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED ((CsrWifiSmeWpsDeviceSubCategory) 0x00)
1727#define CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1728#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1729#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1730#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1731#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1732#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1733#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1734#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1735#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1736#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1737#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
1738#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1739#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1740#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1741#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1742#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1743#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1744#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1745#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1746#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360 ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1747#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
1748#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1749#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1750#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1751#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1752#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1753#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1754#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1755#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1756#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1757#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
1758#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1759#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1760#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1761#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1762#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1763#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1764#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1765#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1766#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1767#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
1768#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1769#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1770#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1771#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1772#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1773#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1774#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
1775#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
1776#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
1777#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
1778#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
1779#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID ((CsrWifiSmeWpsDeviceSubCategory) 0x07)
1780#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN ((CsrWifiSmeWpsDeviceSubCategory) 0x07)
1781#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR ((CsrWifiSmeWpsDeviceSubCategory) 0x08)
1782#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK ((CsrWifiSmeWpsDeviceSubCategory) 0x08)
1783#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR ((CsrWifiSmeWpsDeviceSubCategory) 0x09)
1784
1785/*******************************************************************************
1786
1787 NAME
1788 CsrWifiSmeWpsDpid
1789
1790 DESCRIPTION
1791 Device Password ID for the chosen config method
1792
1793 VALUES
1794 CSR_WIFI_SME_WPS_DPID_PIN - PIN
1795 CSR_WIFI_SME_WPS_DPID_USER - User specified : Used only during P2P GO
1796 negotiation procedure
1797 CSR_WIFI_SME_WPS_DPID_MACHINE - Machine specified i: Not used in this
1798 release
1799 CSR_WIFI_SME_WPS_DPID_REKEY - Rekey : Not used in this release
1800 CSR_WIFI_SME_WPS_DPID_PBC - PBC
1801 CSR_WIFI_SME_WPS_DPID_REGISTRAR - Registrar specified : Used only in P2P Go
1802 negotiation procedure
1803
1804*******************************************************************************/
1805typedef u16 CsrWifiSmeWpsDpid;
1806#define CSR_WIFI_SME_WPS_DPID_PIN ((CsrWifiSmeWpsDpid) 0x0000)
1807#define CSR_WIFI_SME_WPS_DPID_USER ((CsrWifiSmeWpsDpid) 0x0001)
1808#define CSR_WIFI_SME_WPS_DPID_MACHINE ((CsrWifiSmeWpsDpid) 0x0002)
1809#define CSR_WIFI_SME_WPS_DPID_REKEY ((CsrWifiSmeWpsDpid) 0x0003)
1810#define CSR_WIFI_SME_WPS_DPID_PBC ((CsrWifiSmeWpsDpid) 0x0004)
1811#define CSR_WIFI_SME_WPS_DPID_REGISTRAR ((CsrWifiSmeWpsDpid) 0x0005)
1812
1813/*******************************************************************************
1814
1815 NAME
1816 CsrWifiSmeWpsRegistration
1817
1818 DESCRIPTION
1819
1820 VALUES
1821 CSR_WIFI_SME_WPS_REG_NOT_REQUIRED - No encryption set
1822 CSR_WIFI_SME_WPS_REG_REQUIRED - No encryption set
1823 CSR_WIFI_SME_WPS_REG_UNKNOWN - No encryption set
1824
1825*******************************************************************************/
1826typedef u8 CsrWifiSmeWpsRegistration;
1827#define CSR_WIFI_SME_WPS_REG_NOT_REQUIRED ((CsrWifiSmeWpsRegistration) 0x00)
1828#define CSR_WIFI_SME_WPS_REG_REQUIRED ((CsrWifiSmeWpsRegistration) 0x01)
1829#define CSR_WIFI_SME_WPS_REG_UNKNOWN ((CsrWifiSmeWpsRegistration) 0x02)
1830
1831
1832/*******************************************************************************
1833
1834 NAME
1835 CsrWifiSmeAuthModeMask
1836
1837 DESCRIPTION
1838 Mask type for use with the values defined by CsrWifiSmeAuthMode
1839
1840*******************************************************************************/
1841typedef u16 CsrWifiSmeAuthModeMask;
1842/*******************************************************************************
1843
1844 NAME
1845 CsrWifiSmeEncryptionMask
1846
1847 DESCRIPTION
1848 Mask type for use with the values defined by CsrWifiSmeEncryption
1849
1850*******************************************************************************/
1851typedef u16 CsrWifiSmeEncryptionMask;
1852/*******************************************************************************
1853
1854 NAME
1855 CsrWifiSmeIndicationsMask
1856
1857 DESCRIPTION
1858 Mask type for use with the values defined by CsrWifiSmeIndications
1859
1860*******************************************************************************/
1861typedef u32 CsrWifiSmeIndicationsMask;
1862/*******************************************************************************
1863
1864 NAME
1865 CsrWifiSmeP2pCapabilityMask
1866
1867 DESCRIPTION
1868 Mask type for use with the values defined by CsrWifiSmeP2pCapability
1869
1870*******************************************************************************/
1871typedef u8 CsrWifiSmeP2pCapabilityMask;
1872/*******************************************************************************
1873
1874 NAME
1875 CsrWifiSmeP2pGroupCapabilityMask
1876
1877 DESCRIPTION
1878 Mask type for use with the values defined by CsrWifiSmeP2pGroupCapability
1879
1880*******************************************************************************/
1881typedef u8 CsrWifiSmeP2pGroupCapabilityMask;
1882/*******************************************************************************
1883
1884 NAME
1885 CsrWifiSmeTspecCtrlMask
1886
1887 DESCRIPTION
1888 Mask type for use with the values defined by CsrWifiSmeTspecCtrl
1889
1890*******************************************************************************/
1891typedef u8 CsrWifiSmeTspecCtrlMask;
1892/*******************************************************************************
1893
1894 NAME
1895 CsrWifiSmeWmmModeMask
1896
1897 DESCRIPTION
1898 Mask type for use with the values defined by CsrWifiSmeWmmMode
1899
1900*******************************************************************************/
1901typedef u8 CsrWifiSmeWmmModeMask;
1902/*******************************************************************************
1903
1904 NAME
1905 CsrWifiSmeWmmQosInfoMask
1906
1907 DESCRIPTION
1908 Mask type for use with the values defined by CsrWifiSmeWmmQosInfo
1909
1910*******************************************************************************/
1911typedef u8 CsrWifiSmeWmmQosInfoMask;
1912/*******************************************************************************
1913
1914 NAME
1915 CsrWifiSmeWpsConfigTypeMask
1916
1917 DESCRIPTION
1918 Mask type for use with the values defined by CsrWifiSmeWpsConfigType
1919
1920*******************************************************************************/
1921typedef u16 CsrWifiSmeWpsConfigTypeMask;
1922
1923
1924/*******************************************************************************
1925
1926 NAME
1927 CsrWifiSmeAdHocConfig
1928
1929 DESCRIPTION
1930 Defines values to use when starting an Ad-hoc (IBSS) network.
1931
1932 MEMBERS
1933 atimWindowTu - ATIM window specified for IBSS
1934 beaconPeriodTu - Interval between beacon packets
1935 joinOnlyAttempts - Maximum number of attempts to join an ad-hoc network.
1936 The default value is 1.
1937 Set to 0 for infinite attempts.
1938 joinAttemptIntervalMs - Time between scans for joining the requested IBSS.
1939
1940*******************************************************************************/
1941typedef struct
1942{
1943 u16 atimWindowTu;
1944 u16 beaconPeriodTu;
1945 u16 joinOnlyAttempts;
1946 u16 joinAttemptIntervalMs;
1947} CsrWifiSmeAdHocConfig;
1948
1949/*******************************************************************************
1950
1951 NAME
1952 CsrWifiSmeAvailabilityConfig
1953
1954 DESCRIPTION
1955
1956 MEMBERS
1957 listenChannel -
1958 availabilityDuration -
1959 avalabilityPeriod -
1960
1961*******************************************************************************/
1962typedef struct
1963{
1964 u8 listenChannel;
1965 u16 availabilityDuration;
1966 u16 avalabilityPeriod;
1967} CsrWifiSmeAvailabilityConfig;
1968
1969/*******************************************************************************
1970
1971 NAME
1972 CsrWifiSmeCcxConfig
1973
1974 DESCRIPTION
1975 This type is reserved for future use and should not be used.
1976
1977 MEMBERS
1978 keepAliveTimeMs - NOT USED
1979 apRoamingEnabled - NOT USED
1980 measurementsMask - NOT USED
1981 ccxRadioMgtEnabled - NOT USED
1982
1983*******************************************************************************/
1984typedef struct
1985{
1986 u8 keepAliveTimeMs;
1987 u8 apRoamingEnabled;
1988 u8 measurementsMask;
1989 u8 ccxRadioMgtEnabled;
1990} CsrWifiSmeCcxConfig;
1991
1992/*******************************************************************************
1993
1994 NAME
1995 CsrWifiSmeCoexConfig
1996
1997 DESCRIPTION
1998 Parameters for the coexistence behaviour.
1999
2000 MEMBERS
2001 coexEnableSchemeManagement - Enables the Coexistence Management Scheme
2002 coexPeriodicWakeHost - If TRUE the firmware wakes up the host
2003 periodically according to the traffic
2004 period and latency parameters; the host
2005 will then send the data to transmit only
2006 when woken up.
2007 If FALSE, the firmware does not wake up the
2008 host and the host will send the data to
2009 transmit to the firmware whenever there is
2010 data to transmit
2011 coexTrafficBurstyLatencyMs - Period of awakening for the firmware used
2012 when bursty traffic is detected
2013 coexTrafficContinuousLatencyMs - Period of awakening for the firmware used
2014 when continuous traffic is detected
2015 coexObexBlackoutDurationMs - Blackout Duration when a Obex Connection is
2016 used
2017 coexObexBlackoutPeriodMs - Blackout Period when a Obex Connection is
2018 used
2019 coexA2dpBrBlackoutDurationMs - Blackout Duration when a Basic Rate A2DP
2020 Connection streaming data
2021 coexA2dpBrBlackoutPeriodMs - Blackout Period when a Basic Rate A2DP
2022 Connection streaming data
2023 coexA2dpEdrBlackoutDurationMs - Blackout Duration when an Enhanced Data
2024 Rate A2DP Connection streaming data
2025 coexA2dpEdrBlackoutPeriodMs - Blackout Period when an Enhanced Data Rate
2026 A2DP Connection streaming data
2027 coexPagingBlackoutDurationMs - Blackout Duration when a BT page is active
2028 coexPagingBlackoutPeriodMs - Blackout Period when a BT page is active
2029 coexInquiryBlackoutDurationMs - Blackout Duration when a BT inquiry is
2030 active
2031 coexInquiryBlackoutPeriodMs - Blackout Period when a BT inquiry is active
2032
2033*******************************************************************************/
2034typedef struct
2035{
2036 u8 coexEnableSchemeManagement;
2037 u8 coexPeriodicWakeHost;
2038 u16 coexTrafficBurstyLatencyMs;
2039 u16 coexTrafficContinuousLatencyMs;
2040 u16 coexObexBlackoutDurationMs;
2041 u16 coexObexBlackoutPeriodMs;
2042 u16 coexA2dpBrBlackoutDurationMs;
2043 u16 coexA2dpBrBlackoutPeriodMs;
2044 u16 coexA2dpEdrBlackoutDurationMs;
2045 u16 coexA2dpEdrBlackoutPeriodMs;
2046 u16 coexPagingBlackoutDurationMs;
2047 u16 coexPagingBlackoutPeriodMs;
2048 u16 coexInquiryBlackoutDurationMs;
2049 u16 coexInquiryBlackoutPeriodMs;
2050} CsrWifiSmeCoexConfig;
2051
2052/*******************************************************************************
2053
2054 NAME
2055 CsrWifiSmeConnectionStats
2056
2057 DESCRIPTION
2058 Indicates the statistics of the connection.
2059 The dot11 fields are defined in the Annex D of the IEEE 802.11 standard.
2060
2061 MEMBERS
2062 unifiTxDataRate
2063 - The bit rate currently in use for transmissions of unicast
2064 data frames; a data rate in units of 500kbit/s.
2065 On an infrastructure BSS, this is the data rate used in
2066 communicating with the associated access point; if there is
2067 none, an error is returned.
2068 On an IBSS, this is the data rate used for the last
2069 transmission of a unicast data frame to any station in the
2070 IBSS. If no such transmission has been made, an error is
2071 returned.
2072 unifiRxDataRate
2073 - As above for receiving data
2074 dot11RetryCount
2075 - See IEEE 802.11 Standard
2076 dot11MultipleRetryCount
2077 - See IEEE 802.11 Standard
2078 dot11AckFailureCount
2079 - See IEEE 802.11 Standard
2080 dot11FrameDuplicateCount
2081 - See IEEE 802.11 Standard
2082 dot11FcsErrorCount
2083 - See IEEE 802.11 Standard
2084 dot11RtsSuccessCount
2085 - See IEEE 802.11 Standard
2086 dot11RtsFailureCount
2087 - See IEEE 802.11 Standard
2088 dot11FailedCount
2089 - See IEEE 802.11 Standard
2090 dot11TransmittedFragmentCount
2091 - See IEEE 802.11 Standard
2092 dot11TransmittedFrameCount
2093 - See IEEE 802.11 Standard
2094 dot11WepExcludedCount
2095 - See IEEE 802.11 Standard
2096 dot11WepIcvErrorCount
2097 - See IEEE 802.11 Standard
2098 dot11WepUndecryptableCount
2099 - See IEEE 802.11 Standard
2100 dot11MulticastReceivedFrameCount
2101 - See IEEE 802.11 Standard
2102 dot11MulticastTransmittedFrameCount
2103 - See IEEE 802.11 Standard
2104 dot11ReceivedFragmentCount
2105 - See IEEE 802.11 Standard
2106 dot11Rsna4WayHandshakeFailures
2107 - See IEEE 802.11 Standard
2108 dot11RsnaTkipCounterMeasuresInvoked
2109 - See IEEE 802.11 Standard
2110 dot11RsnaStatsTkipLocalMicFailures
2111 - See IEEE 802.11 Standard
2112 dot11RsnaStatsTkipReplays
2113 - See IEEE 802.11 Standard
2114 dot11RsnaStatsTkipIcvErrors
2115 - See IEEE 802.11 Standard
2116 dot11RsnaStatsCcmpReplays
2117 - See IEEE 802.11 Standard
2118 dot11RsnaStatsCcmpDecryptErrors
2119 - See IEEE 802.11 Standard
2120
2121*******************************************************************************/
2122typedef struct
2123{
2124 u8 unifiTxDataRate;
2125 u8 unifiRxDataRate;
2126 u32 dot11RetryCount;
2127 u32 dot11MultipleRetryCount;
2128 u32 dot11AckFailureCount;
2129 u32 dot11FrameDuplicateCount;
2130 u32 dot11FcsErrorCount;
2131 u32 dot11RtsSuccessCount;
2132 u32 dot11RtsFailureCount;
2133 u32 dot11FailedCount;
2134 u32 dot11TransmittedFragmentCount;
2135 u32 dot11TransmittedFrameCount;
2136 u32 dot11WepExcludedCount;
2137 u32 dot11WepIcvErrorCount;
2138 u32 dot11WepUndecryptableCount;
2139 u32 dot11MulticastReceivedFrameCount;
2140 u32 dot11MulticastTransmittedFrameCount;
2141 u32 dot11ReceivedFragmentCount;
2142 u32 dot11Rsna4WayHandshakeFailures;
2143 u32 dot11RsnaTkipCounterMeasuresInvoked;
2144 u32 dot11RsnaStatsTkipLocalMicFailures;
2145 u32 dot11RsnaStatsTkipReplays;
2146 u32 dot11RsnaStatsTkipIcvErrors;
2147 u32 dot11RsnaStatsCcmpReplays;
2148 u32 dot11RsnaStatsCcmpDecryptErrors;
2149} CsrWifiSmeConnectionStats;
2150
2151/*******************************************************************************
2152
2153 NAME
2154 CsrWifiSmeDataBlock
2155
2156 DESCRIPTION
2157 Holds a generic data block to be passed through the interface
2158
2159 MEMBERS
2160 length - Length of the data block
2161 data - Points to the first byte of the data block
2162
2163*******************************************************************************/
2164typedef struct
2165{
2166 u16 length;
2167 u8 *data;
2168} CsrWifiSmeDataBlock;
2169
2170/*******************************************************************************
2171
2172 NAME
2173 CsrWifiSmeEmpty
2174
2175 DESCRIPTION
2176 Empty Structure to indicate that no parameters are available.
2177
2178 MEMBERS
2179 empty - Only element of the empty structure (always set to 0).
2180
2181*******************************************************************************/
2182typedef struct
2183{
2184 u8 empty;
2185} CsrWifiSmeEmpty;
2186
2187/*******************************************************************************
2188
2189 NAME
2190 CsrWifiSmeLinkQuality
2191
2192 DESCRIPTION
2193 Indicates the quality of the link
2194
2195 MEMBERS
2196 unifiRssi - Indicates the received signal strength indication of the link in
2197 dBm
2198 unifiSnr - Indicates the signal to noise ratio of the link in dB
2199
2200*******************************************************************************/
2201typedef struct
2202{
2203 s16 unifiRssi;
2204 s16 unifiSnr;
2205} CsrWifiSmeLinkQuality;
2206
2207/*******************************************************************************
2208
2209 NAME
2210 CsrWifiSmeMibConfig
2211
2212 DESCRIPTION
2213 Allows low level configuration in the chip.
2214
2215 MEMBERS
2216 unifiFixMaxTxDataRate - This attribute is used in combination with
2217 unifiFixTxDataRate. If it is FALSE, then
2218 unifiFixTxDataRate specifies a specific data
2219 rate to use. If it is TRUE, unifiFixTxDataRate
2220 instead specifies a maximum data rate.
2221 unifiFixTxDataRate - Transmit rate for unicast data.
2222 See MIB description for more details
2223 dot11RtsThreshold - See IEEE 802.11 Standard
2224 dot11FragmentationThreshold - See IEEE 802.11 Standard
2225 dot11CurrentTxPowerLevel - See IEEE 802.11 Standard
2226
2227*******************************************************************************/
2228typedef struct
2229{
2230 u8 unifiFixMaxTxDataRate;
2231 u8 unifiFixTxDataRate;
2232 u16 dot11RtsThreshold;
2233 u16 dot11FragmentationThreshold;
2234 u16 dot11CurrentTxPowerLevel;
2235} CsrWifiSmeMibConfig;
2236
2237/*******************************************************************************
2238
2239 NAME
2240 CsrWifiSmeP2pProfileIdentity
2241
2242 DESCRIPTION
2243 Details to be filled in
2244
2245 MEMBERS
2246 listenChannel -
2247 availabilityDuration -
2248 avalabilityPeriod -
2249
2250*******************************************************************************/
2251typedef struct
2252{
2253 u8 listenChannel;
2254 u16 availabilityDuration;
2255 u16 avalabilityPeriod;
2256} CsrWifiSmeP2pProfileIdentity;
2257
2258/*******************************************************************************
2259
2260 NAME
2261 CsrWifiSmePmkid
2262
2263 DESCRIPTION
2264 Defines a PMKID association with BSS
2265
2266 MEMBERS
2267 bssid - BSS identifier
2268 pmkid - PMKID
2269
2270*******************************************************************************/
2271typedef struct
2272{
2273 CsrWifiMacAddress bssid;
2274 u8 pmkid[16];
2275} CsrWifiSmePmkid;
2276
2277/*******************************************************************************
2278
2279 NAME
2280 CsrWifiSmePmkidCandidate
2281
2282 DESCRIPTION
2283 Information for a PMKID candidate
2284
2285 MEMBERS
2286 bssid - BSS identifier
2287 preAuthAllowed - Indicates whether preauthentication is allowed
2288
2289*******************************************************************************/
2290typedef struct
2291{
2292 CsrWifiMacAddress bssid;
2293 u8 preAuthAllowed;
2294} CsrWifiSmePmkidCandidate;
2295
2296/*******************************************************************************
2297
2298 NAME
2299 CsrWifiSmePmkidList
2300
2301 DESCRIPTION
2302 NOT USED
2303 Used in the Sync access API
2304
2305 MEMBERS
2306 pmkidsCount - Number of PMKIDs in the list
2307 pmkids - Points to the first PMKID in the list
2308
2309*******************************************************************************/
2310typedef struct
2311{
2312 u8 pmkidsCount;
2313 CsrWifiSmePmkid *pmkids;
2314} CsrWifiSmePmkidList;
2315
2316/*******************************************************************************
2317
2318 NAME
2319 CsrWifiSmeRegulatoryDomainInfo
2320
2321 DESCRIPTION
2322 Regulatory domain options.
2323
2324 MEMBERS
2325 dot11MultiDomainCapabilityImplemented
2326 - TRUE is the multi domain capability is implemented
2327 dot11MultiDomainCapabilityEnabled
2328 - TRUE is the multi domain capability is enabled
2329 currentRegulatoryDomain
2330 - Current regulatory domain
2331 currentCountryCode
2332 - Current country code as defined by the IEEE 802.11
2333 standards
2334
2335*******************************************************************************/
2336typedef struct
2337{
2338 u8 dot11MultiDomainCapabilityImplemented;
2339 u8 dot11MultiDomainCapabilityEnabled;
2340 CsrWifiSmeRegulatoryDomain currentRegulatoryDomain;
2341 u8 currentCountryCode[2];
2342} CsrWifiSmeRegulatoryDomainInfo;
2343
2344/*******************************************************************************
2345
2346 NAME
2347 CsrWifiSmeRoamingBandData
2348
2349 DESCRIPTION
2350 Thresholds to define one usability level category for the received signal
2351
2352 MEMBERS
2353 rssiHighThreshold - Received Signal Strength Indication upper bound in dBm
2354 for the usability level
2355 rssiLowThreshold - Received Signal Strength Indication lower bound in dBm
2356 for the usability level
2357 snrHighThreshold - Signal to Noise Ratio upper bound in dB for the
2358 usability level
2359 snrLowThreshold - Signal to Noise Ratio lower bound in dB for the
2360 usability level
2361
2362*******************************************************************************/
2363typedef struct
2364{
2365 s16 rssiHighThreshold;
2366 s16 rssiLowThreshold;
2367 s16 snrHighThreshold;
2368 s16 snrLowThreshold;
2369} CsrWifiSmeRoamingBandData;
2370
2371/*******************************************************************************
2372
2373 NAME
2374 CsrWifiSmeScanConfigData
2375
2376 DESCRIPTION
2377 Configures the scanning behaviour of the driver and firmware
2378
2379 MEMBERS
2380 intervalSeconds - All the channels will be scanned once in this time
2381 interval.
2382 If connected, the channel scans are spread across
2383 the interval.
2384 If disconnected, all the channels will be scanned
2385 together
2386 validitySeconds - How long the scan result are cached
2387 minActiveChannelTimeTu - Minimum time of listening on a channel being
2388 actively scanned before leaving if no probe
2389 responses or beacon frames have been received
2390 maxActiveChannelTimeTu - Maximum time of listening on a channel being
2391 actively scanned
2392 minPassiveChannelTimeTu - Minimum time of listening on a channel being
2393 passive scanned before leaving if no beacon frames
2394 have been received
2395 maxPassiveChannelTimeTu - Maximum time of listening on a channel being
2396 passively scanned
2397
2398*******************************************************************************/
2399typedef struct
2400{
2401 u16 intervalSeconds;
2402 u16 validitySeconds;
2403 u16 minActiveChannelTimeTu;
2404 u16 maxActiveChannelTimeTu;
2405 u16 minPassiveChannelTimeTu;
2406 u16 maxPassiveChannelTimeTu;
2407} CsrWifiSmeScanConfigData;
2408
2409/*******************************************************************************
2410
2411 NAME
2412 CsrWifiSmeTsfTime
2413
2414 DESCRIPTION
2415 Time stamp representation
2416
2417 MEMBERS
2418 data - TSF Bytes
2419
2420*******************************************************************************/
2421typedef struct
2422{
2423 u8 data[8];
2424} CsrWifiSmeTsfTime;
2425
2426/*******************************************************************************
2427
2428 NAME
2429 CsrWifiSmeVersions
2430
2431 DESCRIPTION
2432 Reports version information for the chip, the firmware and the driver and
2433 the SME.
2434
2435 MEMBERS
2436 chipId - Chip ID
2437 chipVersion - Chip version ID
2438 firmwareBuild - Firmware Rom build number
2439 firmwarePatch - Firmware Patch build number (if applicable)
2440 firmwareHip - Firmware HIP protocol version number
2441 routerBuild - Router build number
2442 routerHip - Router HIP protocol version number
2443 smeBuild - SME build number
2444 smeHip - SME HIP protocol version number
2445
2446*******************************************************************************/
2447typedef struct
2448{
2449 u32 chipId;
2450 u32 chipVersion;
2451 u32 firmwareBuild;
2452 u32 firmwarePatch;
2453 u32 firmwareHip;
2454 char *routerBuild;
2455 u32 routerHip;
2456 char *smeBuild;
2457 u32 smeHip;
2458} CsrWifiSmeVersions;
2459
2460/*******************************************************************************
2461
2462 NAME
2463 CsrWifiSmeWmmAcParams
2464
2465 DESCRIPTION
2466 Structure holding WMM AC params data.
2467
2468 MEMBERS
2469 cwMin - Exponent for the calculation of CWmin. Range: 0
2470 to 15
2471 cwMax - Exponent for the calculation of CWmax. Range: 0
2472 to15
2473 aifs - Arbitration Inter Frame Spacing in terms of
2474 number of timeslots. Range 2 to 15
2475 txopLimit - TXOP Limit in the units of 32 microseconds
2476 admissionControlMandatory - Indicates whether the admission control is
2477 mandatory or not. Current release does not
2478 support admission control , hence shall be set
2479 to FALSE.
2480
2481*******************************************************************************/
2482typedef struct
2483{
2484 u8 cwMin;
2485 u8 cwMax;
2486 u8 aifs;
2487 u16 txopLimit;
2488 u8 admissionControlMandatory;
2489} CsrWifiSmeWmmAcParams;
2490
2491/*******************************************************************************
2492
2493 NAME
2494 CsrWifiSmeWpsDeviceType
2495
2496 DESCRIPTION
2497 Structure holding AP WPS device type data.
2498
2499 MEMBERS
2500 deviceDetails - category , sub category etc
2501
2502*******************************************************************************/
2503typedef struct
2504{
2505 u8 deviceDetails[8];
2506} CsrWifiSmeWpsDeviceType;
2507
2508/*******************************************************************************
2509
2510 NAME
2511 CsrWifiSmeWpsDeviceTypeCommon
2512
2513 DESCRIPTION
2514
2515 MEMBERS
2516 spportWps -
2517 deviceType -
2518
2519*******************************************************************************/
2520typedef struct
2521{
2522 u8 spportWps;
2523 u8 deviceType;
2524} CsrWifiSmeWpsDeviceTypeCommon;
2525
2526/*******************************************************************************
2527
2528 NAME
2529 CsrWifiSmeWpsInfo
2530
2531 DESCRIPTION
2532
2533 MEMBERS
2534 version -
2535 configMethods -
2536 devicePassworId -
2537
2538*******************************************************************************/
2539typedef struct
2540{
2541 u16 version;
2542 u16 configMethods;
2543 u16 devicePassworId;
2544} CsrWifiSmeWpsInfo;
2545
2546/*******************************************************************************
2547
2548 NAME
2549 CsrWifiSmeCloakedSsidConfig
2550
2551 DESCRIPTION
2552 List of cloaked SSIDs .
2553
2554 MEMBERS
2555 cloakedSsidsCount - Number of cloaked SSID
2556 cloakedSsids - Points to the first byte of the first SSID provided
2557
2558*******************************************************************************/
2559typedef struct
2560{
2561 u8 cloakedSsidsCount;
2562 CsrWifiSsid *cloakedSsids;
2563} CsrWifiSmeCloakedSsidConfig;
2564
2565/*******************************************************************************
2566
2567 NAME
2568 CsrWifiSmeCoexInfo
2569
2570 DESCRIPTION
2571 Information and state related to coexistence.
2572
2573 MEMBERS
2574 hasTrafficData - TRUE if any Wi-Fi traffic is detected
2575 currentTrafficType - Current type of traffic
2576 currentPeriodMs - Period of the traffic as detected by the traffic
2577 analysis.
2578 If the traffic is not periodic, it is set to 0.
2579 currentPowerSave - Current power save level
2580 currentCoexPeriodMs - Period of awakening for the firmware used when
2581 periodic traffic is detected.
2582 If the traffic is not periodic, it is set to 0.
2583 currentCoexLatencyMs - Period of awakening for the firmware used when
2584 non-periodic traffic is detected
2585 hasBtDevice - TRUE if there is a Bluetooth device connected
2586 currentBlackoutDurationUs - Current blackout duration for protecting
2587 Bluetooth
2588 currentBlackoutPeriodUs - Current blackout period
2589 currentCoexScheme - Defines the scheme for the coexistence
2590 signalling
2591
2592*******************************************************************************/
2593typedef struct
2594{
2595 u8 hasTrafficData;
2596 CsrWifiSmeTrafficType currentTrafficType;
2597 u16 currentPeriodMs;
2598 CsrWifiSmePowerSaveLevel currentPowerSave;
2599 u16 currentCoexPeriodMs;
2600 u16 currentCoexLatencyMs;
2601 u8 hasBtDevice;
2602 u32 currentBlackoutDurationUs;
2603 u32 currentBlackoutPeriodUs;
2604 CsrWifiSmeCoexScheme currentCoexScheme;
2605} CsrWifiSmeCoexInfo;
2606
2607/*******************************************************************************
2608
2609 NAME
2610 CsrWifiSmeConnectionConfig
2611
2612 DESCRIPTION
2613 Specifies the parameters that the SME should use in selecting a network.
2614
2615 MEMBERS
2616 ssid
2617 - Service Set identifier
2618 bssid
2619 - BSS identifier
2620 bssType
2621 - Indicates the type of BSS
2622 ifIndex
2623 - Indicates the radio interface
2624 privacyMode
2625 - Specifies whether the privacy mode is enabled or disabled.
2626 authModeMask
2627 - Sets the authentication options that the SME can use while
2628 associating to the AP
2629 Set mask with values from CsrWifiSmeAuthMode
2630 encryptionModeMask
2631 - Sets the encryption options that the SME can use while
2632 associating to the AP
2633 Set mask with values from CsrWifiSmeEncryption
2634 mlmeAssociateReqInformationElementsLength
2635 - Length in bytes of information elements to be sent in the
2636 Association Request.
2637 mlmeAssociateReqInformationElements
2638 - Points to the first byte of the information elements, if
2639 any.
2640 wmmQosInfo
2641 - This parameter allows the driver's WMM behaviour to be
2642 configured.
2643 To enable support for WMM, use
2644 CSR_WIFI_SME_SME_CONFIG_SET_REQ with the
2645 CSR_WIFI_SME_WMM_MODE_AC_ENABLED bit set in wmmModeMask
2646 field in smeConfig parameter.
2647 Set mask with values from CsrWifiSmeWmmQosInfo
2648 adhocJoinOnly
2649 - This parameter is relevant only if bssType is NOT set to
2650 CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
2651 if TRUE the SME will only try to join an ad-hoc network if
2652 there is one already established;
2653 if FALSE the SME will try to join an ad-hoc network if
2654 there is one already established or it will try to
2655 establish a new one
2656 adhocChannel
2657 - This parameter is relevant only if bssType is NOT set to
2658 CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
2659 it indicates the channel to use joining an ad hoc network.
2660 Setting this to 0 causes the SME to select a channel from
2661 those permitted in the regulatory domain.
2662
2663*******************************************************************************/
2664typedef struct
2665{
2666 CsrWifiSsid ssid;
2667 CsrWifiMacAddress bssid;
2668 CsrWifiSmeBssType bssType;
2669 CsrWifiSmeRadioIF ifIndex;
2670 CsrWifiSme80211PrivacyMode privacyMode;
2671 CsrWifiSmeAuthModeMask authModeMask;
2672 CsrWifiSmeEncryptionMask encryptionModeMask;
2673 u16 mlmeAssociateReqInformationElementsLength;
2674 u8 *mlmeAssociateReqInformationElements;
2675 CsrWifiSmeWmmQosInfoMask wmmQosInfo;
2676 u8 adhocJoinOnly;
2677 u8 adhocChannel;
2678} CsrWifiSmeConnectionConfig;
2679
2680/*******************************************************************************
2681
2682 NAME
2683 CsrWifiSmeConnectionInfo
2684
2685 DESCRIPTION
2686 Parameters that the SME should use in selecting a network
2687
2688 MEMBERS
2689 ssid - Service set identifier
2690 bssid - BSS identifier
2691 networkType80211 - Physical layer used for the connection
2692 channelNumber - Channel number
2693 channelFrequency - Channel frequency
2694 authMode - Authentication mode used for the connection
2695 pairwiseCipher - Encryption type for peer to peer communication
2696 groupCipher - Encryption type for broadcast and multicast
2697 communication
2698 ifIndex - Indicates the radio interface
2699 atimWindowTu - ATIM window specified for IBSS
2700 beaconPeriodTu - Interval between beacon packets
2701 reassociation - Indicates whether a reassociation occurred
2702 beaconFrameLength - Indicates the number of bytes of the beacon
2703 frame
2704 beaconFrame - Points at the first byte of the beacon frame
2705 associationReqFrameLength - Indicates the number of bytes of the
2706 association request frame
2707 associationReqFrame - Points at the first byte of the association
2708 request frame
2709 associationRspFrameLength - Indicates the number of bytes of the
2710 association response frame
2711 associationRspFrame - Points at the first byte of the association
2712 response frame
2713 assocScanInfoElementsLength - Indicates the number of bytes in the buffer
2714 pointed by assocScanInfoElements
2715 assocScanInfoElements - Pointer to the buffer containing the
2716 information elements of the probe response
2717 received after the probe requests sent before
2718 attempting to authenticate to the network
2719 assocReqCapabilities - Reports the content of the Capability
2720 information element as specified in the
2721 association request.
2722 assocReqListenIntervalTu - Listen Interval specified in the association
2723 request
2724 assocReqApAddress - AP address to which the association requests
2725 has been sent
2726 assocReqInfoElementsLength - Indicates the number of bytes of the
2727 association request information elements
2728 assocReqInfoElements - Points at the first byte of the association
2729 request information elements
2730 assocRspResult - Result reported in the association response
2731 assocRspCapabilityInfo - Reports the content of the Capability
2732 information element as received in the
2733 association response.
2734 assocRspAssociationId - Reports the association ID received in the
2735 association response.
2736 assocRspInfoElementsLength - Indicates the number of bytes of the
2737 association response information elements
2738 assocRspInfoElements - Points at the first byte of the association
2739 response information elements
2740
2741*******************************************************************************/
2742typedef struct
2743{
2744 CsrWifiSsid ssid;
2745 CsrWifiMacAddress bssid;
2746 CsrWifiSme80211NetworkType networkType80211;
2747 u8 channelNumber;
2748 u16 channelFrequency;
2749 CsrWifiSmeAuthMode authMode;
2750 CsrWifiSmeEncryption pairwiseCipher;
2751 CsrWifiSmeEncryption groupCipher;
2752 CsrWifiSmeRadioIF ifIndex;
2753 u16 atimWindowTu;
2754 u16 beaconPeriodTu;
2755 u8 reassociation;
2756 u16 beaconFrameLength;
2757 u8 *beaconFrame;
2758 u16 associationReqFrameLength;
2759 u8 *associationReqFrame;
2760 u16 associationRspFrameLength;
2761 u8 *associationRspFrame;
2762 u16 assocScanInfoElementsLength;
2763 u8 *assocScanInfoElements;
2764 u16 assocReqCapabilities;
2765 u16 assocReqListenIntervalTu;
2766 CsrWifiMacAddress assocReqApAddress;
2767 u16 assocReqInfoElementsLength;
2768 u8 *assocReqInfoElements;
2769 CsrWifiSmeIEEE80211Result assocRspResult;
2770 u16 assocRspCapabilityInfo;
2771 u16 assocRspAssociationId;
2772 u16 assocRspInfoElementsLength;
2773 u8 *assocRspInfoElements;
2774} CsrWifiSmeConnectionInfo;
2775
2776/*******************************************************************************
2777
2778 NAME
2779 CsrWifiSmeDeviceConfig
2780
2781 DESCRIPTION
2782 General configuration options in the SME
2783
2784 MEMBERS
2785 trustLevel - Level of trust of the information coming from the
2786 network
2787 countryCode - Country code as specified by IEEE 802.11 standard
2788 firmwareDriverInterface - Specifies the type of communication between Host
2789 and Firmware
2790 enableStrictDraftN - If TRUE TKIP is disallowed when connecting to
2791 802.11n enabled access points
2792
2793*******************************************************************************/
2794typedef struct
2795{
2796 CsrWifiSme80211dTrustLevel trustLevel;
2797 u8 countryCode[2];
2798 CsrWifiSmeFirmwareDriverInterface firmwareDriverInterface;
2799 u8 enableStrictDraftN;
2800} CsrWifiSmeDeviceConfig;
2801
2802/*******************************************************************************
2803
2804 NAME
2805 CsrWifiSmeDeviceInfo
2806
2807 DESCRIPTION
2808 P2P Information for a P2P Device
2809
2810 MEMBERS
2811 deviceAddress - Device Address of the P2P device
2812 configMethods - Supported WPS configuration methods.
2813 p2PDeviceCap - P2P device capabilities
2814 primDeviceType - Primary WPS device type
2815 secondaryDeviceTypeCount - Number of secondary device types
2816 secDeviceType - list of secondary WPS device types
2817 deviceName - Device name without up to 32 characters'\0'.
2818 deviceNameLength - Number of characters of the device name
2819
2820*******************************************************************************/
2821typedef struct
2822{
2823 CsrWifiMacAddress deviceAddress;
2824 CsrWifiSmeWpsConfigTypeMask configMethods;
2825 CsrWifiSmeP2pCapabilityMask p2PDeviceCap;
2826 CsrWifiSmeWpsDeviceType primDeviceType;
2827 u8 secondaryDeviceTypeCount;
2828 CsrWifiSmeWpsDeviceType *secDeviceType;
2829 u8 deviceName[32];
2830 u8 deviceNameLength;
2831} CsrWifiSmeDeviceInfo;
2832
2833/*******************************************************************************
2834
2835 NAME
2836 CsrWifiSmeDeviceInfoCommon
2837
2838 DESCRIPTION
2839 Structure holding device information.
2840
2841 MEMBERS
2842 p2pDeviceAddress -
2843 primaryDeviceType -
2844 secondaryDeviceTypesCount -
2845 secondaryDeviceTypes -
2846 deviceNameLength -
2847 deviceName -
2848
2849*******************************************************************************/
2850typedef struct
2851{
2852 CsrWifiMacAddress p2pDeviceAddress;
2853 CsrWifiSmeWpsDeviceTypeCommon primaryDeviceType;
2854 u8 secondaryDeviceTypesCount;
2855 u8 secondaryDeviceTypes[10];
2856 u8 deviceNameLength;
2857 u8 deviceName[32];
2858} CsrWifiSmeDeviceInfoCommon;
2859
2860/*******************************************************************************
2861
2862 NAME
2863 CsrWifiSmeHostConfig
2864
2865 DESCRIPTION
2866 Defines the host power state (for example, on mains power, on battery
2867 power etc) and the periodicity of the traffic data.
2868
2869 MEMBERS
2870 powerMode - The wireless manager application should use the
2871 powerMode parameter to inform the SME of the host
2872 power state.
2873 applicationDataPeriodMs - The applicationDataPeriodMs parameter allows a
2874 wireless manager application to inform the SME
2875 that an application is running that generates
2876 periodic network traffic and the period of the
2877 traffic.
2878 An example of such an application is a VoIP client.
2879 The wireless manager application should set
2880 applicationDataPeriodMs to the period in
2881 milliseconds between data packets or zero if no
2882 periodic application is running.
2883 Voip etc 0 = No Periodic Data
2884
2885*******************************************************************************/
2886typedef struct
2887{
2888 CsrWifiSmeHostPowerMode powerMode;
2889 u16 applicationDataPeriodMs;
2890} CsrWifiSmeHostConfig;
2891
2892/*******************************************************************************
2893
2894 NAME
2895 CsrWifiSmeKey
2896
2897 DESCRIPTION
2898 Information for a key to be used for encryption
2899
2900 MEMBERS
2901 keyType - Specifies whether the key is a pairwise or group key; it
2902 should be set to CSR_WIFI_SME_GROUP_KEY or
2903 CSR_WIFI_SME_PAIRWISE_KEY, as required.
2904 keyIndex - Specifies which WEP key (0-3) to set; it should be set to 0
2905 for a WPA/WPA2 pairwise key and non-zero for a WPA/WPA2
2906 group key.
2907 wepTxKey - If wepTxKey is TRUE, and the key is a WEP key, the key will
2908 be selected for encrypting transmitted packets.
2909 To select a previously defined key as the transmit
2910 encryption key, set keyIndex to the required key, wepTxKey
2911 to TRUE and the keyLength to 0.
2912 keyRsc - Key Receive Sequence Counter
2913 authenticator - If TRUE the WMA will act as authenticator.
2914 CURRENTLY NOT SUPPORTED
2915 address - BSS identifier of the AP
2916 keyLength - Length of the key in bytes
2917 key - Points to the first byte of the key
2918
2919*******************************************************************************/
2920typedef struct
2921{
2922 CsrWifiSmeKeyType keyType;
2923 u8 keyIndex;
2924 u8 wepTxKey;
2925 u16 keyRsc[8];
2926 u8 authenticator;
2927 CsrWifiMacAddress address;
2928 u8 keyLength;
2929 u8 key[32];
2930} CsrWifiSmeKey;
2931
2932/*******************************************************************************
2933
2934 NAME
2935 CsrWifiSmeP2pClientInfoType
2936
2937 DESCRIPTION
2938 P2P Information for a P2P Client
2939
2940 MEMBERS
2941 p2PClientInterfaceAddress - MAC address of the P2P Client
2942 clientDeviceInfo - Device Information
2943
2944*******************************************************************************/
2945typedef struct
2946{
2947 CsrWifiMacAddress p2PClientInterfaceAddress;
2948 CsrWifiSmeDeviceInfo clientDeviceInfo;
2949} CsrWifiSmeP2pClientInfoType;
2950
2951/*******************************************************************************
2952
2953 NAME
2954 CsrWifiSmeP2pGroupInfo
2955
2956 DESCRIPTION
2957 P2P Information for a P2P Group
2958
2959 MEMBERS
2960 groupCapability - P2P group capabilities
2961 p2pDeviceAddress - Device Address of the GO
2962 p2pClientInfoCount - Number of P2P Clients that belong to the group.
2963 p2PClientInfo - Pointer to the list containing client information for
2964 each client in the group
2965
2966*******************************************************************************/
2967typedef struct
2968{
2969 CsrWifiSmeP2pGroupCapabilityMask groupCapability;
2970 CsrWifiMacAddress p2pDeviceAddress;
2971 u8 p2pClientInfoCount;
2972 CsrWifiSmeP2pClientInfoType *p2PClientInfo;
2973} CsrWifiSmeP2pGroupInfo;
2974
2975/*******************************************************************************
2976
2977 NAME
2978 CsrWifiSmePowerConfig
2979
2980 DESCRIPTION
2981 Configures the power-save behaviour of the driver and firmware.
2982
2983 MEMBERS
2984 powerSaveLevel - Power Save Level option
2985 listenIntervalTu - Interval for waking to receive beacon frames
2986 rxDtims - If TRUE, wake for DTIM every beacon period, to
2987 allow the reception broadcast packets
2988 d3AutoScanMode - Defines whether the autonomous scanning will be
2989 turned off or will stay on during a D3 suspended
2990 period
2991 clientTrafficWindow - Deprecated
2992 opportunisticPowerSave - Deprecated
2993 noticeOfAbsence - Deprecated
2994
2995*******************************************************************************/
2996typedef struct
2997{
2998 CsrWifiSmePowerSaveLevel powerSaveLevel;
2999 u16 listenIntervalTu;
3000 u8 rxDtims;
3001 CsrWifiSmeD3AutoScanMode d3AutoScanMode;
3002 u8 clientTrafficWindow;
3003 u8 opportunisticPowerSave;
3004 u8 noticeOfAbsence;
3005} CsrWifiSmePowerConfig;
3006
3007/*******************************************************************************
3008
3009 NAME
3010 CsrWifiSmeRoamingConfig
3011
3012 DESCRIPTION
3013 Configures the roaming behaviour of the driver and firmware
3014
3015 MEMBERS
3016 roamingBands - Defines the thresholds to determine the usability
3017 level of the current connection.
3018 roamingBands is indexed by the first 3 entries of
3019 the CsrWifiSmeBasicUsability enum
3020 disableSmoothRoaming - Disable the RSSI/SNR triggers from the Firmware
3021 that the SME uses to detect the quality of the
3022 connection.
3023 This implicitly disables disableRoamScans
3024 disableRoamScans - Disables the scanning for the roaming operation
3025 reconnectLimit - Maximum number of times SME may reconnect in the
3026 given interval
3027 reconnectLimitIntervalMs - Interval for maximum number of times SME may
3028 reconnect to the same Access Point
3029 roamScanCfg - Scanning behaviour for the specifically aimed at
3030 improving roaming performance.
3031 roamScanCfg is indexed by the first 3 entries of
3032 the CsrWifiSmeBasicUsability enum
3033
3034*******************************************************************************/
3035typedef struct
3036{
3037 CsrWifiSmeRoamingBandData roamingBands[3];
3038 u8 disableSmoothRoaming;
3039 u8 disableRoamScans;
3040 u8 reconnectLimit;
3041 u16 reconnectLimitIntervalMs;
3042 CsrWifiSmeScanConfigData roamScanCfg[3];
3043} CsrWifiSmeRoamingConfig;
3044
3045/*******************************************************************************
3046
3047 NAME
3048 CsrWifiSmeScanConfig
3049
3050 DESCRIPTION
3051 Parameters for the autonomous scanning behaviour of the system
3052
3053 MEMBERS
3054 scanCfg - Scan configuration data.
3055 Indexed by the CsrWifiSmeBasicUsability enum
3056 disableAutonomousScans - Enables or disables the autonomous scan
3057 maxResults - Maximum number of results to be cached in the SME
3058 highRssiThreshold - High received signal strength indication threshold
3059 in dBm for an AP above which the system will
3060 report scan indications
3061 lowRssiThreshold - Low received signal strength indication threshold
3062 in dBm for an AP below which the system will
3063 report scan indications
3064 deltaRssiThreshold - Minimum difference for received signal strength
3065 indication in dBm for an AP which trigger a scan
3066 indication to be sent.
3067 highSnrThreshold - High Signal to Noise Ratio threshold in dB for an
3068 AP above which the system will report scan
3069 indications
3070 lowSnrThreshold - Low Signal to Noise Ratio threshold in dB for an
3071 AP below which the system will report scan
3072 indications
3073 deltaSnrThreshold - Minimum difference for Signal to Noise Ratio in dB
3074 for an AP which trigger a scan indication to be
3075 sent.
3076 passiveChannelListCount - Number of channels to be scanned passively.
3077 passiveChannelList - Points to the first channel to be scanned
3078 passively , if any.
3079
3080*******************************************************************************/
3081typedef struct
3082{
3083 CsrWifiSmeScanConfigData scanCfg[4];
3084 u8 disableAutonomousScans;
3085 u16 maxResults;
3086 s8 highRssiThreshold;
3087 s8 lowRssiThreshold;
3088 s8 deltaRssiThreshold;
3089 s8 highSnrThreshold;
3090 s8 lowSnrThreshold;
3091 s8 deltaSnrThreshold;
3092 u16 passiveChannelListCount;
3093 u8 *passiveChannelList;
3094} CsrWifiSmeScanConfig;
3095
3096/*******************************************************************************
3097
3098 NAME
3099 CsrWifiSmeScanResult
3100
3101 DESCRIPTION
3102 This structure defines the scan result for each BSS found
3103
3104 MEMBERS
3105 ssid - Service set identifier
3106 bssid - BSS identifier
3107 rssi - Received signal strength indication in dBm
3108 snr - Signal to noise ratio in dB
3109 ifIndex - Indicates the radio interface
3110 beaconPeriodTu - Interval between beacon frames
3111 timeStamp - Timestamp in the BSS
3112 localTime - Timestamp in the Access Point
3113 channelFrequency - Channel frequency
3114 capabilityInformation - Capabilities of the BSS.
3115 channelNumber - Channel number
3116 usability - Indicates the usability level.
3117 bssType - Type of BSS.
3118 informationElementsLength - Number of bytes of the information elements
3119 received as part of the beacon or probe
3120 response.
3121 informationElements - Points to the first byte of the IEs received
3122 as part of the beacon or probe response.
3123 The format of the IEs is as specified in the
3124 IEEE 802.11 specification.
3125 p2pDeviceRole - Role of the P2P device.
3126 Relevant only if bssType is
3127 CSR_WIFI_SME_BSS_TYPE_P2P
3128 deviceInfo - Union containing P2P device info which
3129 depends on p2pDeviceRole parameter.
3130 deviceInforeservedCli -
3131 deviceInfogroupInfo -
3132 deviceInforeservedNone -
3133 deviceInfostandalonedevInfo -
3134
3135*******************************************************************************/
3136typedef struct
3137{
3138 CsrWifiSsid ssid;
3139 CsrWifiMacAddress bssid;
3140 s16 rssi;
3141 s16 snr;
3142 CsrWifiSmeRadioIF ifIndex;
3143 u16 beaconPeriodTu;
3144 CsrWifiSmeTsfTime timeStamp;
3145 CsrWifiSmeTsfTime localTime;
3146 u16 channelFrequency;
3147 u16 capabilityInformation;
3148 u8 channelNumber;
3149 CsrWifiSmeBasicUsability usability;
3150 CsrWifiSmeBssType bssType;
3151 u16 informationElementsLength;
3152 u8 *informationElements;
3153 CsrWifiSmeP2pRole p2pDeviceRole;
3154 union {
3155 CsrWifiSmeEmpty reservedCli;
3156 CsrWifiSmeP2pGroupInfo groupInfo;
3157 CsrWifiSmeEmpty reservedNone;
3158 CsrWifiSmeDeviceInfo standalonedevInfo;
3159 } deviceInfo;
3160} CsrWifiSmeScanResult;
3161
3162/*******************************************************************************
3163
3164 NAME
3165 CsrWifiSmeStaConfig
3166
3167 DESCRIPTION
3168 Station configuration options in the SME
3169
3170 MEMBERS
3171 connectionQualityRssiChangeTrigger - Sets the difference of RSSI
3172 measurements which triggers reports
3173 from the Firmware
3174 connectionQualitySnrChangeTrigger - Sets the difference of SNR measurements
3175 which triggers reports from the
3176 Firmware
3177 wmmModeMask - Mask containing one or more values from
3178 CsrWifiSmeWmmMode
3179 ifIndex - Indicates the band of frequencies used
3180 allowUnicastUseGroupCipher - If TRUE, it allows to use groupwise
3181 keys if no pairwise key is specified
3182 enableOpportunisticKeyCaching - If TRUE, enables the Opportunistic Key
3183 Caching feature
3184
3185*******************************************************************************/
3186typedef struct
3187{
3188 u8 connectionQualityRssiChangeTrigger;
3189 u8 connectionQualitySnrChangeTrigger;
3190 CsrWifiSmeWmmModeMask wmmModeMask;
3191 CsrWifiSmeRadioIF ifIndex;
3192 u8 allowUnicastUseGroupCipher;
3193 u8 enableOpportunisticKeyCaching;
3194} CsrWifiSmeStaConfig;
3195
3196/*******************************************************************************
3197
3198 NAME
3199 CsrWifiSmeWep128Keys
3200
3201 DESCRIPTION
3202 Structure holding WEP Authentication Type and WEP keys that can be used
3203 when using WEP128.
3204
3205 MEMBERS
3206 wepAuthType - Mask to select the WEP authentication type (Open or Shared)
3207 selectedWepKey - Index to one of the four keys below indicating the
3208 currently used WEP key. Mapping From SME/User -> firmware.
3209 Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key
3210 4-> Index 3.
3211 key1 - Value for key number 1.
3212 key2 - Value for key number 2.
3213 key3 - Value for key number 3.
3214 key4 - Value for key number 4.
3215
3216*******************************************************************************/
3217typedef struct
3218{
3219 CsrWifiSmeWepAuthMode wepAuthType;
3220 u8 selectedWepKey;
3221 u8 key1[13];
3222 u8 key2[13];
3223 u8 key3[13];
3224 u8 key4[13];
3225} CsrWifiSmeWep128Keys;
3226
3227/*******************************************************************************
3228
3229 NAME
3230 CsrWifiSmeWep64Keys
3231
3232 DESCRIPTION
3233 Structure holding WEP Authentication Type and WEP keys that can be used
3234 when using WEP64.
3235
3236 MEMBERS
3237 wepAuthType - Mask to select the WEP authentication type (Open or Shared)
3238 selectedWepKey - Index to one of the four keys below indicating the
3239 currently used WEP key. Mapping From SME/User -> firmware.
3240 Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key
3241 4-> Index 3.
3242 key1 - Value for key number 1.
3243 key2 - Value for key number 2.
3244 key3 - Value for key number 3.
3245 key4 - Value for key number 4.
3246
3247*******************************************************************************/
3248typedef struct
3249{
3250 CsrWifiSmeWepAuthMode wepAuthType;
3251 u8 selectedWepKey;
3252 u8 key1[5];
3253 u8 key2[5];
3254 u8 key3[5];
3255 u8 key4[5];
3256} CsrWifiSmeWep64Keys;
3257
3258/*******************************************************************************
3259
3260 NAME
3261 CsrWifiSmeWepAuth
3262
3263 DESCRIPTION
3264 WEP authentication parameter structure
3265
3266 MEMBERS
3267 wepKeyType - WEP key try (128 bit or 64 bit)
3268 wepCredentials - Union containing credentials which depends on
3269 wepKeyType parameter.
3270 wepCredentialswep128Key -
3271 wepCredentialswep64Key -
3272
3273*******************************************************************************/
3274typedef struct
3275{
3276 CsrWifiSmeWepCredentialType wepKeyType;
3277 union {
3278 CsrWifiSmeWep128Keys wep128Key;
3279 CsrWifiSmeWep64Keys wep64Key;
3280 } wepCredentials;
3281} CsrWifiSmeWepAuth;
3282
3283/*******************************************************************************
3284
3285 NAME
3286 CsrWifiSmeWpsConfig
3287
3288 DESCRIPTION
3289 Structure holding AP WPS Config data.
3290
3291 MEMBERS
3292 wpsVersion - wpsVersion should be 0x10 for WPS1.0h or 0x20 for
3293 WSC2.0
3294 uuid - uuid.
3295 deviceName - Device name upto 32 characters without '\0'.
3296 deviceNameLength - deviceNameLen.
3297 manufacturer - manufacturer: CSR
3298 manufacturerLength - manufacturerLen.
3299 modelName - modelName Unifi
3300 modelNameLength - modelNameLen.
3301 modelNumber - modelNumber
3302 modelNumberLength - modelNumberLen.
3303 serialNumber - serialNumber
3304 primDeviceType - Primary WPS device type
3305 secondaryDeviceTypeCount - Number of secondary device types
3306 secondaryDeviceType - list of secondary WPS device types
3307 configMethods - Supported WPS config methods
3308 rfBands - RfBands.
3309 osVersion - Os version on which the device is running
3310
3311*******************************************************************************/
3312typedef struct
3313{
3314 u8 wpsVersion;
3315 u8 uuid[16];
3316 u8 deviceName[32];
3317 u8 deviceNameLength;
3318 u8 manufacturer[64];
3319 u8 manufacturerLength;
3320 u8 modelName[32];
3321 u8 modelNameLength;
3322 u8 modelNumber[32];
3323 u8 modelNumberLength;
3324 u8 serialNumber[32];
3325 CsrWifiSmeWpsDeviceType primDeviceType;
3326 u8 secondaryDeviceTypeCount;
3327 CsrWifiSmeWpsDeviceType *secondaryDeviceType;
3328 CsrWifiSmeWpsConfigTypeMask configMethods;
3329 u8 rfBands;
3330 u8 osVersion[4];
3331} CsrWifiSmeWpsConfig;
3332
3333
3334/* Downstream */
3335#define CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST (0x0000)
3336
3337#define CSR_WIFI_SME_ACTIVATE_REQ ((CsrWifiSmePrim) (0x0000 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3338#define CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0001 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3339#define CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0002 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3340#define CSR_WIFI_SME_BLACKLIST_REQ ((CsrWifiSmePrim) (0x0003 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3341#define CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ ((CsrWifiSmePrim) (0x0004 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3342#define CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ ((CsrWifiSmePrim) (0x0005 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3343#define CSR_WIFI_SME_CCX_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0006 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3344#define CSR_WIFI_SME_CCX_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0007 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3345#define CSR_WIFI_SME_COEX_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0008 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3346#define CSR_WIFI_SME_COEX_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0009 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3347#define CSR_WIFI_SME_COEX_INFO_GET_REQ ((CsrWifiSmePrim) (0x000A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3348#define CSR_WIFI_SME_CONNECT_REQ ((CsrWifiSmePrim) (0x000B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3349#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x000C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3350#define CSR_WIFI_SME_CONNECTION_INFO_GET_REQ ((CsrWifiSmePrim) (0x000D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3351#define CSR_WIFI_SME_CONNECTION_STATS_GET_REQ ((CsrWifiSmePrim) (0x000E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3352#define CSR_WIFI_SME_DEACTIVATE_REQ ((CsrWifiSmePrim) (0x000F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3353#define CSR_WIFI_SME_DISCONNECT_REQ ((CsrWifiSmePrim) (0x0010 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3354#define CSR_WIFI_SME_EVENT_MASK_SET_REQ ((CsrWifiSmePrim) (0x0011 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3355#define CSR_WIFI_SME_HOST_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0012 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3356#define CSR_WIFI_SME_HOST_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0013 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3357#define CSR_WIFI_SME_KEY_REQ ((CsrWifiSmePrim) (0x0014 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3358#define CSR_WIFI_SME_LINK_QUALITY_GET_REQ ((CsrWifiSmePrim) (0x0015 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3359#define CSR_WIFI_SME_MIB_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0016 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3360#define CSR_WIFI_SME_MIB_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0017 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3361#define CSR_WIFI_SME_MIB_GET_NEXT_REQ ((CsrWifiSmePrim) (0x0018 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3362#define CSR_WIFI_SME_MIB_GET_REQ ((CsrWifiSmePrim) (0x0019 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3363#define CSR_WIFI_SME_MIB_SET_REQ ((CsrWifiSmePrim) (0x001A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3364#define CSR_WIFI_SME_MULTICAST_ADDRESS_REQ ((CsrWifiSmePrim) (0x001B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3365#define CSR_WIFI_SME_PACKET_FILTER_SET_REQ ((CsrWifiSmePrim) (0x001C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3366#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ ((CsrWifiSmePrim) (0x001D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3367#define CSR_WIFI_SME_PMKID_REQ ((CsrWifiSmePrim) (0x001E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3368#define CSR_WIFI_SME_POWER_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x001F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3369#define CSR_WIFI_SME_POWER_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0020 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3370#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ ((CsrWifiSmePrim) (0x0021 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3371#define CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0022 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3372#define CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0023 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3373#define CSR_WIFI_SME_SCAN_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0024 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3374#define CSR_WIFI_SME_SCAN_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0025 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3375#define CSR_WIFI_SME_SCAN_FULL_REQ ((CsrWifiSmePrim) (0x0026 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3376#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ ((CsrWifiSmePrim) (0x0027 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3377#define CSR_WIFI_SME_SCAN_RESULTS_GET_REQ ((CsrWifiSmePrim) (0x0028 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3378#define CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0029 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3379#define CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x002A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3380#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ ((CsrWifiSmePrim) (0x002B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3381#define CSR_WIFI_SME_TSPEC_REQ ((CsrWifiSmePrim) (0x002C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3382#define CSR_WIFI_SME_VERSIONS_GET_REQ ((CsrWifiSmePrim) (0x002D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3383#define CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ ((CsrWifiSmePrim) (0x002E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3384#define CSR_WIFI_SME_WIFI_OFF_REQ ((CsrWifiSmePrim) (0x002F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3385#define CSR_WIFI_SME_WIFI_ON_REQ ((CsrWifiSmePrim) (0x0030 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3386#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ ((CsrWifiSmePrim) (0x0031 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3387#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ ((CsrWifiSmePrim) (0x0032 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3388#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0033 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3389#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0034 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3390#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ ((CsrWifiSmePrim) (0x0035 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3391#define CSR_WIFI_SME_WPS_CONFIGURATION_REQ ((CsrWifiSmePrim) (0x0036 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3392#define CSR_WIFI_SME_SET_REQ ((CsrWifiSmePrim) (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
3393
3394
3395#define CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)
3396
3397/* Upstream */
3398#define CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
3399
3400#define CSR_WIFI_SME_ACTIVATE_CFM ((CsrWifiSmePrim)(0x0000 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3401#define CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0001 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3402#define CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0002 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3403#define CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND ((CsrWifiSmePrim)(0x0003 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3404#define CSR_WIFI_SME_ASSOCIATION_START_IND ((CsrWifiSmePrim)(0x0004 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3405#define CSR_WIFI_SME_BLACKLIST_CFM ((CsrWifiSmePrim)(0x0005 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3406#define CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM ((CsrWifiSmePrim)(0x0006 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3407#define CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM ((CsrWifiSmePrim)(0x0007 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3408#define CSR_WIFI_SME_CCX_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0008 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3409#define CSR_WIFI_SME_CCX_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0009 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3410#define CSR_WIFI_SME_COEX_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x000A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3411#define CSR_WIFI_SME_COEX_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x000B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3412#define CSR_WIFI_SME_COEX_INFO_GET_CFM ((CsrWifiSmePrim)(0x000C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3413#define CSR_WIFI_SME_CONNECT_CFM ((CsrWifiSmePrim)(0x000D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3414#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x000E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3415#define CSR_WIFI_SME_CONNECTION_INFO_GET_CFM ((CsrWifiSmePrim)(0x000F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3416#define CSR_WIFI_SME_CONNECTION_QUALITY_IND ((CsrWifiSmePrim)(0x0010 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3417#define CSR_WIFI_SME_CONNECTION_STATS_GET_CFM ((CsrWifiSmePrim)(0x0011 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3418#define CSR_WIFI_SME_DEACTIVATE_CFM ((CsrWifiSmePrim)(0x0012 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3419#define CSR_WIFI_SME_DISCONNECT_CFM ((CsrWifiSmePrim)(0x0013 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3420#define CSR_WIFI_SME_EVENT_MASK_SET_CFM ((CsrWifiSmePrim)(0x0014 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3421#define CSR_WIFI_SME_HOST_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0015 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3422#define CSR_WIFI_SME_HOST_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0016 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3423#define CSR_WIFI_SME_IBSS_STATION_IND ((CsrWifiSmePrim)(0x0017 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3424#define CSR_WIFI_SME_KEY_CFM ((CsrWifiSmePrim)(0x0018 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3425#define CSR_WIFI_SME_LINK_QUALITY_GET_CFM ((CsrWifiSmePrim)(0x0019 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3426#define CSR_WIFI_SME_MEDIA_STATUS_IND ((CsrWifiSmePrim)(0x001A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3427#define CSR_WIFI_SME_MIB_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x001B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3428#define CSR_WIFI_SME_MIB_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x001C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3429#define CSR_WIFI_SME_MIB_GET_CFM ((CsrWifiSmePrim)(0x001D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3430#define CSR_WIFI_SME_MIB_GET_NEXT_CFM ((CsrWifiSmePrim)(0x001E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3431#define CSR_WIFI_SME_MIB_SET_CFM ((CsrWifiSmePrim)(0x001F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3432#define CSR_WIFI_SME_MIC_FAILURE_IND ((CsrWifiSmePrim)(0x0020 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3433#define CSR_WIFI_SME_MULTICAST_ADDRESS_CFM ((CsrWifiSmePrim)(0x0021 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3434#define CSR_WIFI_SME_PACKET_FILTER_SET_CFM ((CsrWifiSmePrim)(0x0022 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3435#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM ((CsrWifiSmePrim)(0x0023 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3436#define CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND ((CsrWifiSmePrim)(0x0024 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3437#define CSR_WIFI_SME_PMKID_CFM ((CsrWifiSmePrim)(0x0025 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3438#define CSR_WIFI_SME_POWER_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0026 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3439#define CSR_WIFI_SME_POWER_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0027 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3440#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM ((CsrWifiSmePrim)(0x0028 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3441#define CSR_WIFI_SME_ROAM_COMPLETE_IND ((CsrWifiSmePrim)(0x0029 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3442#define CSR_WIFI_SME_ROAM_START_IND ((CsrWifiSmePrim)(0x002A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3443#define CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x002B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3444#define CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x002C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3445#define CSR_WIFI_SME_SCAN_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x002D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3446#define CSR_WIFI_SME_SCAN_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x002E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3447#define CSR_WIFI_SME_SCAN_FULL_CFM ((CsrWifiSmePrim)(0x002F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3448#define CSR_WIFI_SME_SCAN_RESULT_IND ((CsrWifiSmePrim)(0x0030 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3449#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM ((CsrWifiSmePrim)(0x0031 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3450#define CSR_WIFI_SME_SCAN_RESULTS_GET_CFM ((CsrWifiSmePrim)(0x0032 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3451#define CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0033 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3452#define CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0034 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3453#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM ((CsrWifiSmePrim)(0x0035 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3454#define CSR_WIFI_SME_TSPEC_IND ((CsrWifiSmePrim)(0x0036 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3455#define CSR_WIFI_SME_TSPEC_CFM ((CsrWifiSmePrim)(0x0037 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3456#define CSR_WIFI_SME_VERSIONS_GET_CFM ((CsrWifiSmePrim)(0x0038 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3457#define CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM ((CsrWifiSmePrim)(0x0039 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3458#define CSR_WIFI_SME_WIFI_OFF_IND ((CsrWifiSmePrim)(0x003A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3459#define CSR_WIFI_SME_WIFI_OFF_CFM ((CsrWifiSmePrim)(0x003B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3460#define CSR_WIFI_SME_WIFI_ON_CFM ((CsrWifiSmePrim)(0x003C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3461#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM ((CsrWifiSmePrim)(0x003D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3462#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM ((CsrWifiSmePrim)(0x003E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3463#define CSR_WIFI_SME_WIFI_ON_IND ((CsrWifiSmePrim)(0x003F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3464#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0040 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3465#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0041 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3466#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM ((CsrWifiSmePrim)(0x0042 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3467#define CSR_WIFI_SME_ERROR_IND ((CsrWifiSmePrim)(0x0043 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3468#define CSR_WIFI_SME_INFO_IND ((CsrWifiSmePrim)(0x0044 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3469#define CSR_WIFI_SME_CORE_DUMP_IND ((CsrWifiSmePrim)(0x0045 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3470#define CSR_WIFI_SME_AMP_STATUS_CHANGE_IND ((CsrWifiSmePrim)(0x0046 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3471#define CSR_WIFI_SME_WPS_CONFIGURATION_CFM ((CsrWifiSmePrim)(0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
3472
3473#define CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST (0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)
3474
3475#define CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)
3476#define CSR_WIFI_SME_PRIM_UPSTREAM_COUNT (CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)
3477
3478/*******************************************************************************
3479
3480 NAME
3481 CsrWifiSmeActivateReq
3482
3483 DESCRIPTION
3484 The WMA sends this primitive to activate the SME.
3485 The WMA must activate the SME before it can send any other primitive.
3486
3487 MEMBERS
3488 common - Common header for use with the CsrWifiFsm Module
3489
3490*******************************************************************************/
3491typedef struct
3492{
3493 CsrWifiFsmEvent common;
3494} CsrWifiSmeActivateReq;
3495
3496/*******************************************************************************
3497
3498 NAME
3499 CsrWifiSmeAdhocConfigGetReq
3500
3501 DESCRIPTION
3502 This primitive gets the value of the adHocConfig parameter.
3503
3504 MEMBERS
3505 common - Common header for use with the CsrWifiFsm Module
3506
3507*******************************************************************************/
3508typedef struct
3509{
3510 CsrWifiFsmEvent common;
3511} CsrWifiSmeAdhocConfigGetReq;
3512
3513/*******************************************************************************
3514
3515 NAME
3516 CsrWifiSmeAdhocConfigSetReq
3517
3518 DESCRIPTION
3519 This primitive sets the value of the adHocConfig parameter.
3520
3521 MEMBERS
3522 common - Common header for use with the CsrWifiFsm Module
3523 adHocConfig - Sets the values to use when starting an ad hoc network.
3524
3525*******************************************************************************/
3526typedef struct
3527{
3528 CsrWifiFsmEvent common;
3529 CsrWifiSmeAdHocConfig adHocConfig;
3530} CsrWifiSmeAdhocConfigSetReq;
3531
3532/*******************************************************************************
3533
3534 NAME
3535 CsrWifiSmeBlacklistReq
3536
3537 DESCRIPTION
3538 The wireless manager application should call this primitive to notify the
3539 driver of any networks that should not be connected to. The interface
3540 allows the wireless manager application to query, add, remove, and flush
3541 the BSSIDs that the driver may not connect or roam to.
3542 When this primitive adds to the black list the BSSID to which the SME is
3543 currently connected, the SME will try to roam, if applicable, to another
3544 BSSID in the same ESS; if the roaming procedure fails, the SME will
3545 disconnect.
3546
3547 MEMBERS
3548 common - Common header for use with the CsrWifiFsm Module
3549 interfaceTag - Interface Identifier; unique identifier of an interface
3550 action - The value of the CsrWifiSmeListAction parameter instructs
3551 the driver to modify or provide the list of blacklisted
3552 networks.
3553 setAddressCount - Number of BSSIDs sent with this primitive
3554 setAddresses - Pointer to the list of BBSIDs sent with the primitive, set
3555 to NULL if none is sent.
3556
3557*******************************************************************************/
3558typedef struct
3559{
3560 CsrWifiFsmEvent common;
3561 u16 interfaceTag;
3562 CsrWifiSmeListAction action;
3563 u8 setAddressCount;
3564 CsrWifiMacAddress *setAddresses;
3565} CsrWifiSmeBlacklistReq;
3566
3567/*******************************************************************************
3568
3569 NAME
3570 CsrWifiSmeCalibrationDataGetReq
3571
3572 DESCRIPTION
3573 This primitive retrieves the Wi-Fi radio calibration data.
3574
3575 MEMBERS
3576 common - Common header for use with the CsrWifiFsm Module
3577
3578*******************************************************************************/
3579typedef struct
3580{
3581 CsrWifiFsmEvent common;
3582} CsrWifiSmeCalibrationDataGetReq;
3583
3584/*******************************************************************************
3585
3586 NAME
3587 CsrWifiSmeCalibrationDataSetReq
3588
3589 DESCRIPTION
3590 This primitive sets the Wi-Fi radio calibration data.
3591 The usage of the primitive with proper calibration data will avoid
3592 time-consuming configuration after power-up.
3593
3594 MEMBERS
3595 common - Common header for use with the CsrWifiFsm Module
3596 calibrationDataLength - Number of bytes in the buffer pointed by
3597 calibrationData
3598 calibrationData - Pointer to a buffer of length calibrationDataLength
3599 containing the calibration data
3600
3601*******************************************************************************/
3602typedef struct
3603{
3604 CsrWifiFsmEvent common;
3605 u16 calibrationDataLength;
3606 u8 *calibrationData;
3607} CsrWifiSmeCalibrationDataSetReq;
3608
3609/*******************************************************************************
3610
3611 NAME
3612 CsrWifiSmeCcxConfigGetReq
3613
3614 DESCRIPTION
3615 This primitive gets the value of the CcxConfig parameter.
3616 CURRENTLY NOT SUPPORTED.
3617
3618 MEMBERS
3619 common - Common header for use with the CsrWifiFsm Module
3620 interfaceTag - Interface Identifier; unique identifier of an interface
3621
3622*******************************************************************************/
3623typedef struct
3624{
3625 CsrWifiFsmEvent common;
3626 u16 interfaceTag;
3627} CsrWifiSmeCcxConfigGetReq;
3628
3629/*******************************************************************************
3630
3631 NAME
3632 CsrWifiSmeCcxConfigSetReq
3633
3634 DESCRIPTION
3635 This primitive sets the value of the CcxConfig parameter.
3636 CURRENTLY NOT SUPPORTED.
3637
3638 MEMBERS
3639 common - Common header for use with the CsrWifiFsm Module
3640 interfaceTag - Interface Identifier; unique identifier of an interface
3641 ccxConfig - Currently not supported
3642
3643*******************************************************************************/
3644typedef struct
3645{
3646 CsrWifiFsmEvent common;
3647 u16 interfaceTag;
3648 CsrWifiSmeCcxConfig ccxConfig;
3649} CsrWifiSmeCcxConfigSetReq;
3650
3651/*******************************************************************************
3652
3653 NAME
3654 CsrWifiSmeCoexConfigGetReq
3655
3656 DESCRIPTION
3657 This primitive gets the value of the CoexConfig parameter.
3658
3659 MEMBERS
3660 common - Common header for use with the CsrWifiFsm Module
3661
3662*******************************************************************************/
3663typedef struct
3664{
3665 CsrWifiFsmEvent common;
3666} CsrWifiSmeCoexConfigGetReq;
3667
3668/*******************************************************************************
3669
3670 NAME
3671 CsrWifiSmeCoexConfigSetReq
3672
3673 DESCRIPTION
3674 This primitive sets the value of the CoexConfig parameter.
3675
3676 MEMBERS
3677 common - Common header for use with the CsrWifiFsm Module
3678 coexConfig - Configures the coexistence behaviour
3679
3680*******************************************************************************/
3681typedef struct
3682{
3683 CsrWifiFsmEvent common;
3684 CsrWifiSmeCoexConfig coexConfig;
3685} CsrWifiSmeCoexConfigSetReq;
3686
3687/*******************************************************************************
3688
3689 NAME
3690 CsrWifiSmeCoexInfoGetReq
3691
3692 DESCRIPTION
3693 This primitive gets the value of the CoexInfo parameter.
3694
3695 MEMBERS
3696 common - Common header for use with the CsrWifiFsm Module
3697
3698*******************************************************************************/
3699typedef struct
3700{
3701 CsrWifiFsmEvent common;
3702} CsrWifiSmeCoexInfoGetReq;
3703
3704/*******************************************************************************
3705
3706 NAME
3707 CsrWifiSmeConnectReq
3708
3709 DESCRIPTION
3710 The wireless manager application calls this primitive to start the
3711 process of joining an 802.11 wireless network or to start an ad hoc
3712 network.
3713 The structure pointed by connectionConfig contains parameters describing
3714 the network to join or, in case of an ad hoc network, to host or join.
3715 The SME will select a network, perform the IEEE 802.11 Join, Authenticate
3716 and Associate exchanges.
3717 The SME selects the networks from the current scan list that match both
3718 the SSID and BSSID, however either or both of these may be the wildcard
3719 value. Using this rule, the following operations are possible:
3720 * To connect to a network by name, specify the SSID and set the BSSID to
3721 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible,
3722 the SME will select the one with the strongest signal.
3723 * To connect to a specific network, specify the BSSID. The SSID is
3724 optional, but if given it must match the SSID of the network. An empty
3725 SSID may be specified by setting the SSID length to zero. Please note
3726 that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF
3727 0xFF 0xFF), the SME will not attempt to roam if signal conditions become
3728 poor, even if there is an alternative AP with an SSID that matches the
3729 current network SSID.
3730 * To connect to any network matching the other parameters (i.e. security,
3731 etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF
3732 0xFF 0xFF 0xFF. In this case, the SME will order all available networks
3733 by their signal strengths and will iterate through this list until it
3734 successfully connects.
3735 NOTE: Specifying the BSSID will restrict the selection to one specific
3736 network. If SSID and BSSID are given, they must both match the network
3737 for it to be selected. To select a network based on the SSID only, the
3738 wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF
3739 0xFF 0xFF.
3740 The SME will try to connect to each network that matches the provided
3741 parameters, one by one, until it succeeds or has tried unsuccessfully
3742 with all the matching networks.
3743 If there is no network that matches the parameters and the request allows
3744 to host an ad hoc network, the SME will advertise a new ad hoc network
3745 instead.
3746 If the SME cannot connect, it will notify the failure in the confirm.
3747
3748 MEMBERS
3749 common - Common header for use with the CsrWifiFsm Module
3750 interfaceTag - Interface Identifier; unique identifier of an interface
3751 connectionConfig - Describes the candidate network to join or to host.
3752
3753*******************************************************************************/
3754typedef struct
3755{
3756 CsrWifiFsmEvent common;
3757 u16 interfaceTag;
3758 CsrWifiSmeConnectionConfig connectionConfig;
3759} CsrWifiSmeConnectReq;
3760
3761/*******************************************************************************
3762
3763 NAME
3764 CsrWifiSmeConnectionConfigGetReq
3765
3766 DESCRIPTION
3767 This primitive gets the value of the ConnectionConfig parameter.
3768
3769 MEMBERS
3770 common - Common header for use with the CsrWifiFsm Module
3771 interfaceTag - Interface Identifier; unique identifier of an interface
3772
3773*******************************************************************************/
3774typedef struct
3775{
3776 CsrWifiFsmEvent common;
3777 u16 interfaceTag;
3778} CsrWifiSmeConnectionConfigGetReq;
3779
3780/*******************************************************************************
3781
3782 NAME
3783 CsrWifiSmeConnectionInfoGetReq
3784
3785 DESCRIPTION
3786 This primitive gets the value of the ConnectionInfo parameter.
3787
3788 MEMBERS
3789 common - Common header for use with the CsrWifiFsm Module
3790 interfaceTag - Interface Identifier; unique identifier of an interface
3791
3792*******************************************************************************/
3793typedef struct
3794{
3795 CsrWifiFsmEvent common;
3796 u16 interfaceTag;
3797} CsrWifiSmeConnectionInfoGetReq;
3798
3799/*******************************************************************************
3800
3801 NAME
3802 CsrWifiSmeConnectionStatsGetReq
3803
3804 DESCRIPTION
3805 This primitive gets the value of the ConnectionStats parameter.
3806
3807 MEMBERS
3808 common - Common header for use with the CsrWifiFsm Module
3809 interfaceTag - Interface Identifier; unique identifier of an interface
3810
3811*******************************************************************************/
3812typedef struct
3813{
3814 CsrWifiFsmEvent common;
3815 u16 interfaceTag;
3816} CsrWifiSmeConnectionStatsGetReq;
3817
3818/*******************************************************************************
3819
3820 NAME
3821 CsrWifiSmeDeactivateReq
3822
3823 DESCRIPTION
3824 The WMA sends this primitive to deactivate the SME.
3825
3826 MEMBERS
3827 common - Common header for use with the CsrWifiFsm Module
3828
3829*******************************************************************************/
3830typedef struct
3831{
3832 CsrWifiFsmEvent common;
3833} CsrWifiSmeDeactivateReq;
3834
3835/*******************************************************************************
3836
3837 NAME
3838 CsrWifiSmeDisconnectReq
3839
3840 DESCRIPTION
3841 The wireless manager application may disconnect from the current network
3842 by calling this primitive
3843
3844 MEMBERS
3845 common - Common header for use with the CsrWifiFsm Module
3846 interfaceTag - Interface Identifier; unique identifier of an interface
3847
3848*******************************************************************************/
3849typedef struct
3850{
3851 CsrWifiFsmEvent common;
3852 u16 interfaceTag;
3853} CsrWifiSmeDisconnectReq;
3854
3855/*******************************************************************************
3856
3857 NAME
3858 CsrWifiSmeEventMaskSetReq
3859
3860 DESCRIPTION
3861 The wireless manager application may register with the SME to receive
3862 notification of interesting events. Indications will be sent only if the
3863 wireless manager explicitly registers to be notified of that event.
3864 indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask.
3865
3866 MEMBERS
3867 common - Common header for use with the CsrWifiFsm Module
3868 indMask - Set mask with values from CsrWifiSmeIndications
3869
3870*******************************************************************************/
3871typedef struct
3872{
3873 CsrWifiFsmEvent common;
3874 CsrWifiSmeIndicationsMask indMask;
3875} CsrWifiSmeEventMaskSetReq;
3876
3877/*******************************************************************************
3878
3879 NAME
3880 CsrWifiSmeHostConfigGetReq
3881
3882 DESCRIPTION
3883 This primitive gets the value of the hostConfig parameter.
3884
3885 MEMBERS
3886 common - Common header for use with the CsrWifiFsm Module
3887 interfaceTag - Interface Identifier; unique identifier of an interface
3888
3889*******************************************************************************/
3890typedef struct
3891{
3892 CsrWifiFsmEvent common;
3893 u16 interfaceTag;
3894} CsrWifiSmeHostConfigGetReq;
3895
3896/*******************************************************************************
3897
3898 NAME
3899 CsrWifiSmeHostConfigSetReq
3900
3901 DESCRIPTION
3902 This primitive sets the value of the hostConfig parameter.
3903
3904 MEMBERS
3905 common - Common header for use with the CsrWifiFsm Module
3906 interfaceTag - Interface Identifier; unique identifier of an interface
3907 hostConfig - Communicates a change of host power state (for example, on
3908 mains power, on battery power etc) and of the periodicity of
3909 traffic data
3910
3911*******************************************************************************/
3912typedef struct
3913{
3914 CsrWifiFsmEvent common;
3915 u16 interfaceTag;
3916 CsrWifiSmeHostConfig hostConfig;
3917} CsrWifiSmeHostConfigSetReq;
3918
3919/*******************************************************************************
3920
3921 NAME
3922 CsrWifiSmeKeyReq
3923
3924 DESCRIPTION
3925 The wireless manager application calls this primitive to add or remove
3926 keys that the chip should use for encryption of data.
3927 The interface allows the wireless manager application to add and remove
3928 keys according to the specified action.
3929
3930 MEMBERS
3931 common - Common header for use with the CsrWifiFsm Module
3932 interfaceTag - Interface Identifier; unique identifier of an interface
3933 action - The value of the CsrWifiSmeListAction parameter instructs the
3934 driver to modify or provide the list of keys.
3935 CSR_WIFI_SME_LIST_ACTION_GET is not supported here.
3936 key - Key to be added or removed
3937
3938*******************************************************************************/
3939typedef struct
3940{
3941 CsrWifiFsmEvent common;
3942 u16 interfaceTag;
3943 CsrWifiSmeListAction action;
3944 CsrWifiSmeKey key;
3945} CsrWifiSmeKeyReq;
3946
3947/*******************************************************************************
3948
3949 NAME
3950 CsrWifiSmeLinkQualityGetReq
3951
3952 DESCRIPTION
3953 This primitive gets the value of the LinkQuality parameter.
3954
3955 MEMBERS
3956 common - Common header for use with the CsrWifiFsm Module
3957 interfaceTag - Interface Identifier; unique identifier of an interface
3958
3959*******************************************************************************/
3960typedef struct
3961{
3962 CsrWifiFsmEvent common;
3963 u16 interfaceTag;
3964} CsrWifiSmeLinkQualityGetReq;
3965
3966/*******************************************************************************
3967
3968 NAME
3969 CsrWifiSmeMibConfigGetReq
3970
3971 DESCRIPTION
3972 This primitive gets the value of the MibConfig parameter.
3973
3974 MEMBERS
3975 common - Common header for use with the CsrWifiFsm Module
3976
3977*******************************************************************************/
3978typedef struct
3979{
3980 CsrWifiFsmEvent common;
3981} CsrWifiSmeMibConfigGetReq;
3982
3983/*******************************************************************************
3984
3985 NAME
3986 CsrWifiSmeMibConfigSetReq
3987
3988 DESCRIPTION
3989 This primitive sets the value of the MibConfig parameter.
3990
3991 MEMBERS
3992 common - Common header for use with the CsrWifiFsm Module
3993 mibConfig - Conveys the desired value of various IEEE 802.11 attributes as
3994 currently configured
3995
3996*******************************************************************************/
3997typedef struct
3998{
3999 CsrWifiFsmEvent common;
4000 CsrWifiSmeMibConfig mibConfig;
4001} CsrWifiSmeMibConfigSetReq;
4002
4003/*******************************************************************************
4004
4005 NAME
4006 CsrWifiSmeMibGetNextReq
4007
4008 DESCRIPTION
4009 To read a sequence of MIB parameters, for example a table, call this
4010 primitive to find the name of the next MIB variable
4011
4012 MEMBERS
4013 common - Common header for use with the CsrWifiFsm Module
4014 mibAttributeLength - Length of mibAttribute
4015 mibAttribute - Points to a VarBind or VarBindList containing the
4016 name(s) of the MIB variable(s) to search from.
4017
4018*******************************************************************************/
4019typedef struct
4020{
4021 CsrWifiFsmEvent common;
4022 u16 mibAttributeLength;
4023 u8 *mibAttribute;
4024} CsrWifiSmeMibGetNextReq;
4025
4026/*******************************************************************************
4027
4028 NAME
4029 CsrWifiSmeMibGetReq
4030
4031 DESCRIPTION
4032 The wireless manager application calls this primitive to retrieve one or
4033 more MIB variables.
4034
4035 MEMBERS
4036 common - Common header for use with the CsrWifiFsm Module
4037 mibAttributeLength - Length of mibAttribute
4038 mibAttribute - Points to the VarBind or VarBindList containing the
4039 names of the MIB variables to be retrieved
4040
4041*******************************************************************************/
4042typedef struct
4043{
4044 CsrWifiFsmEvent common;
4045 u16 mibAttributeLength;
4046 u8 *mibAttribute;
4047} CsrWifiSmeMibGetReq;
4048
4049/*******************************************************************************
4050
4051 NAME
4052 CsrWifiSmeMibSetReq
4053
4054 DESCRIPTION
4055 The SME provides raw access to the MIB on the chip, which may be used by
4056 some configuration or diagnostic utilities, but is not normally needed by
4057 the wireless manager application.
4058 The MIB access functions use BER encoded names (OID) of the MIB
4059 parameters and BER encoded values, as described in the chip Host
4060 Interface Protocol Specification.
4061 The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information
4062 Base Reference Guide'.
4063 The wireless manager application calls this primitive to set one or more
4064 MIB variables
4065
4066 MEMBERS
4067 common - Common header for use with the CsrWifiFsm Module
4068 mibAttributeLength - Length of mibAttribute
4069 mibAttribute - Points to the VarBind or VarBindList containing the
4070 names and values of the MIB variables to set
4071
4072*******************************************************************************/
4073typedef struct
4074{
4075 CsrWifiFsmEvent common;
4076 u16 mibAttributeLength;
4077 u8 *mibAttribute;
4078} CsrWifiSmeMibSetReq;
4079
4080/*******************************************************************************
4081
4082 NAME
4083 CsrWifiSmeMulticastAddressReq
4084
4085 DESCRIPTION
4086 The wireless manager application calls this primitive to specify the
4087 multicast addresses which the chip should recognise. The interface allows
4088 the wireless manager application to query, add, remove and flush the
4089 multicast addresses for the network interface according to the specified
4090 action.
4091
4092 MEMBERS
4093 common - Common header for use with the CsrWifiFsm Module
4094 interfaceTag - Interface Identifier; unique identifier of an interface
4095 action - The value of the CsrWifiSmeListAction parameter
4096 instructs the driver to modify or provide the list of
4097 MAC addresses.
4098 setAddressesCount - Number of MAC addresses sent with the primitive
4099 setAddresses - Pointer to the list of MAC Addresses sent with the
4100 primitive, set to NULL if none is sent.
4101
4102*******************************************************************************/
4103typedef struct
4104{
4105 CsrWifiFsmEvent common;
4106 u16 interfaceTag;
4107 CsrWifiSmeListAction action;
4108 u8 setAddressesCount;
4109 CsrWifiMacAddress *setAddresses;
4110} CsrWifiSmeMulticastAddressReq;
4111
4112/*******************************************************************************
4113
4114 NAME
4115 CsrWifiSmePacketFilterSetReq
4116
4117 DESCRIPTION
4118 The wireless manager application should call this primitive to enable or
4119 disable filtering of broadcast packets: uninteresting broadcast packets
4120 will be dropped by the Wi-Fi chip, instead of passing them up to the
4121 host.
4122 This has the advantage of saving power in the host application processor
4123 as it removes the need to process unwanted packets.
4124 All broadcast packets are filtered according to the filter and the filter
4125 mode provided, except ARP packets, which are filtered using
4126 arpFilterAddress.
4127 Filters are not cumulative: only the parameters specified in the most
4128 recent successful request are significant.
4129 For more information, see 'UniFi Firmware API Specification'.
4130
4131 MEMBERS
4132 common - Common header for use with the CsrWifiFsm Module
4133 interfaceTag - Interface Identifier; unique identifier of an interface
4134 filterLength - Length of the filter in bytes.
4135 filterLength=0 disables the filter previously set
4136 filter - Points to the first byte of the filter provided, if any.
4137 This shall include zero or more instance of the
4138 information elements of one of these types
4139 * Traffic Classification (TCLAS) elements
4140 * WMM-SA TCLAS elements
4141 mode - Specifies whether the filter selects or excludes packets
4142 matching the filter
4143 arpFilterAddress - IPv4 address to be used for filtering the ARP packets.
4144 * If the specified address is the IPv4 broadcast address
4145 (255.255.255.255), all ARP packets are reported to the
4146 host,
4147 * If the specified address is NOT the IPv4 broadcast
4148 address, only ARP packets with the specified address in
4149 the Source or Target Protocol Address fields are reported
4150 to the host
4151
4152*******************************************************************************/
4153typedef struct
4154{
4155 CsrWifiFsmEvent common;
4156 u16 interfaceTag;
4157 u16 filterLength;
4158 u8 *filter;
4159 CsrWifiSmePacketFilterMode mode;
4160 CsrWifiIp4Address arpFilterAddress;
4161} CsrWifiSmePacketFilterSetReq;
4162
4163/*******************************************************************************
4164
4165 NAME
4166 CsrWifiSmePermanentMacAddressGetReq
4167
4168 DESCRIPTION
4169 This primitive retrieves the MAC address stored in EEPROM
4170
4171 MEMBERS
4172 common - Common header for use with the CsrWifiFsm Module
4173
4174*******************************************************************************/
4175typedef struct
4176{
4177 CsrWifiFsmEvent common;
4178} CsrWifiSmePermanentMacAddressGetReq;
4179
4180/*******************************************************************************
4181
4182 NAME
4183 CsrWifiSmePmkidReq
4184
4185 DESCRIPTION
4186 The wireless manager application calls this primitive to request an
4187 operation on the SME PMKID list.
4188 The action argument specifies the operation to perform.
4189 When the connection is complete, the wireless manager application may
4190 then send and receive EAPOL packets to complete WPA or WPA2
4191 authentication if appropriate.
4192 The wireless manager application can then pass the resulting encryption
4193 keys using this primitive.
4194
4195 MEMBERS
4196 common - Common header for use with the CsrWifiFsm Module
4197 interfaceTag - Interface Identifier; unique identifier of an interface
4198 action - The value of the CsrWifiSmeListAction parameter instructs
4199 the driver to modify or provide the list of PMKIDs.
4200 setPmkidsCount - Number of PMKIDs sent with the primitive
4201 setPmkids - Pointer to the list of PMKIDs sent with the primitive, set
4202 to NULL if none is sent.
4203
4204*******************************************************************************/
4205typedef struct
4206{
4207 CsrWifiFsmEvent common;
4208 u16 interfaceTag;
4209 CsrWifiSmeListAction action;
4210 u8 setPmkidsCount;
4211 CsrWifiSmePmkid *setPmkids;
4212} CsrWifiSmePmkidReq;
4213
4214/*******************************************************************************
4215
4216 NAME
4217 CsrWifiSmePowerConfigGetReq
4218
4219 DESCRIPTION
4220 This primitive gets the value of the PowerConfig parameter.
4221
4222 MEMBERS
4223 common - Common header for use with the CsrWifiFsm Module
4224
4225*******************************************************************************/
4226typedef struct
4227{
4228 CsrWifiFsmEvent common;
4229} CsrWifiSmePowerConfigGetReq;
4230
4231/*******************************************************************************
4232
4233 NAME
4234 CsrWifiSmePowerConfigSetReq
4235
4236 DESCRIPTION
4237 This primitive sets the value of the PowerConfig parameter.
4238
4239 MEMBERS
4240 common - Common header for use with the CsrWifiFsm Module
4241 powerConfig - Power saving configuration
4242
4243*******************************************************************************/
4244typedef struct
4245{
4246 CsrWifiFsmEvent common;
4247 CsrWifiSmePowerConfig powerConfig;
4248} CsrWifiSmePowerConfigSetReq;
4249
4250/*******************************************************************************
4251
4252 NAME
4253 CsrWifiSmeRegulatoryDomainInfoGetReq
4254
4255 DESCRIPTION
4256 This primitive gets the value of the RegulatoryDomainInfo parameter.
4257
4258 MEMBERS
4259 common - Common header for use with the CsrWifiFsm Module
4260
4261*******************************************************************************/
4262typedef struct
4263{
4264 CsrWifiFsmEvent common;
4265} CsrWifiSmeRegulatoryDomainInfoGetReq;
4266
4267/*******************************************************************************
4268
4269 NAME
4270 CsrWifiSmeRoamingConfigGetReq
4271
4272 DESCRIPTION
4273 This primitive gets the value of the RoamingConfig parameter.
4274
4275 MEMBERS
4276 common - Common header for use with the CsrWifiFsm Module
4277 interfaceTag - Interface Identifier; unique identifier of an interface
4278
4279*******************************************************************************/
4280typedef struct
4281{
4282 CsrWifiFsmEvent common;
4283 u16 interfaceTag;
4284} CsrWifiSmeRoamingConfigGetReq;
4285
4286/*******************************************************************************
4287
4288 NAME
4289 CsrWifiSmeRoamingConfigSetReq
4290
4291 DESCRIPTION
4292 This primitive sets the value of the RoamingConfig parameter.
4293
4294 MEMBERS
4295 common - Common header for use with the CsrWifiFsm Module
4296 interfaceTag - Interface Identifier; unique identifier of an interface
4297 roamingConfig - Desired roaming behaviour values
4298
4299*******************************************************************************/
4300typedef struct
4301{
4302 CsrWifiFsmEvent common;
4303 u16 interfaceTag;
4304 CsrWifiSmeRoamingConfig roamingConfig;
4305} CsrWifiSmeRoamingConfigSetReq;
4306
4307/*******************************************************************************
4308
4309 NAME
4310 CsrWifiSmeScanConfigGetReq
4311
4312 DESCRIPTION
4313 This primitive gets the value of the ScanConfig parameter.
4314
4315 MEMBERS
4316 common - Common header for use with the CsrWifiFsm Module
4317
4318*******************************************************************************/
4319typedef struct
4320{
4321 CsrWifiFsmEvent common;
4322} CsrWifiSmeScanConfigGetReq;
4323
4324/*******************************************************************************
4325
4326 NAME
4327 CsrWifiSmeScanConfigSetReq
4328
4329 DESCRIPTION
4330 This primitive sets the value of the ScanConfig parameter.
4331 The SME normally configures the firmware to perform autonomous scanning
4332 without involving the host.
4333 The firmware passes beacon / probe response or indicates loss of beacon
4334 on certain changes of state, for example:
4335 * A new AP is seen for the first time
4336 * An AP is no longer visible
4337 * The signal strength of an AP changes by more than a certain amount, as
4338 configured by the thresholds in the scanConfig parameter
4339 In addition to the autonomous scan, the wireless manager application may
4340 request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ.
4341
4342 MEMBERS
4343 common - Common header for use with the CsrWifiFsm Module
4344 scanConfig - Reports the configuration for the autonomous scanning behaviour
4345 of the firmware
4346
4347*******************************************************************************/
4348typedef struct
4349{
4350 CsrWifiFsmEvent common;
4351 CsrWifiSmeScanConfig scanConfig;
4352} CsrWifiSmeScanConfigSetReq;
4353
4354/*******************************************************************************
4355
4356 NAME
4357 CsrWifiSmeScanFullReq
4358
4359 DESCRIPTION
4360 The wireless manager application should call this primitive to request a
4361 full scan.
4362 Channels are scanned actively or passively according to the requirement
4363 set by regulatory domain.
4364 If the SME receives this primitive while a full scan is going on, the new
4365 request is buffered and it will be served after the current full scan is
4366 completed.
4367
4368 MEMBERS
4369 common - Common header for use with the CsrWifiFsm Module
4370 ssidCount - Number of SSIDs provided.
4371 If it is 0, the SME will attempt to detect any network
4372 ssid - Points to the first SSID provided, if any.
4373 bssid - BSS identifier.
4374 If it is equal to FF-FF-FF-FF-FF, the SME will listen for
4375 messages from any BSS.
4376 If it is different from FF-FF-FF-FF-FF and any SSID is
4377 provided, one SSID must match the network of the BSS.
4378 forceScan - Forces the scan even if the SME is in a state which would
4379 normally prevent it (e.g. autonomous scan is running).
4380 bssType - Type of BSS to scan for
4381 scanType - Type of scan to perform
4382 channelListCount - Number of channels provided.
4383 If it is 0, the SME will initiate a scan of all the
4384 supported channels that are permitted by the current
4385 regulatory domain.
4386 channelList - Points to the first channel , or NULL if channelListCount
4387 is zero.
4388 probeIeLength - Length of the information element in bytes to be sent
4389 with the probe message.
4390 probeIe - Points to the first byte of the information element to be
4391 sent with the probe message.
4392
4393*******************************************************************************/
4394typedef struct
4395{
4396 CsrWifiFsmEvent common;
4397 u8 ssidCount;
4398 CsrWifiSsid *ssid;
4399 CsrWifiMacAddress bssid;
4400 u8 forceScan;
4401 CsrWifiSmeBssType bssType;
4402 CsrWifiSmeScanType scanType;
4403 u16 channelListCount;
4404 u8 *channelList;
4405 u16 probeIeLength;
4406 u8 *probeIe;
4407} CsrWifiSmeScanFullReq;
4408
4409/*******************************************************************************
4410
4411 NAME
4412 CsrWifiSmeScanResultsFlushReq
4413
4414 DESCRIPTION
4415 The Wireless Manager calls this primitive to ask the SME to delete all
4416 scan results from its cache, except for the scan result of any currently
4417 connected network.
4418 As scan results are received by the SME from the firmware, they are
4419 cached in the SME memory.
4420 Any time the Wireless Manager requests scan results, they are returned
4421 from the SME internal cache.
4422 For some applications it may be desirable to clear this cache prior to
4423 requesting that a scan be performed; this will ensure that the cache then
4424 only contains the networks detected in the most recent scan.
4425
4426 MEMBERS
4427 common - Common header for use with the CsrWifiFsm Module
4428
4429*******************************************************************************/
4430typedef struct
4431{
4432 CsrWifiFsmEvent common;
4433} CsrWifiSmeScanResultsFlushReq;
4434
4435/*******************************************************************************
4436
4437 NAME
4438 CsrWifiSmeScanResultsGetReq
4439
4440 DESCRIPTION
4441 The wireless manager application calls this primitive to retrieve the
4442 current set of scan results, either after receiving a successful
4443 CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results.
4444
4445 MEMBERS
4446 common - Common header for use with the CsrWifiFsm Module
4447
4448*******************************************************************************/
4449typedef struct
4450{
4451 CsrWifiFsmEvent common;
4452} CsrWifiSmeScanResultsGetReq;
4453
4454/*******************************************************************************
4455
4456 NAME
4457 CsrWifiSmeSmeStaConfigGetReq
4458
4459 DESCRIPTION
4460 This primitive gets the value of the SmeStaConfig parameter.
4461
4462 MEMBERS
4463 common - Common header for use with the CsrWifiFsm Module
4464 interfaceTag - Interface Identifier; unique identifier of an interface
4465
4466*******************************************************************************/
4467typedef struct
4468{
4469 CsrWifiFsmEvent common;
4470 u16 interfaceTag;
4471} CsrWifiSmeSmeStaConfigGetReq;
4472
4473/*******************************************************************************
4474
4475 NAME
4476 CsrWifiSmeSmeStaConfigSetReq
4477
4478 DESCRIPTION
4479 This primitive sets the value of the SmeConfig parameter.
4480
4481 MEMBERS
4482 common - Common header for use with the CsrWifiFsm Module
4483 interfaceTag - Interface Identifier; unique identifier of an interface
4484 smeConfig - SME Station Parameters to be set
4485
4486*******************************************************************************/
4487typedef struct
4488{
4489 CsrWifiFsmEvent common;
4490 u16 interfaceTag;
4491 CsrWifiSmeStaConfig smeConfig;
4492} CsrWifiSmeSmeStaConfigSetReq;
4493
4494/*******************************************************************************
4495
4496 NAME
4497 CsrWifiSmeStationMacAddressGetReq
4498
4499 DESCRIPTION
4500 This primitives is used to retrieve the current MAC address used by the
4501 station.
4502
4503 MEMBERS
4504 common - Common header for use with the CsrWifiFsm Module
4505
4506*******************************************************************************/
4507typedef struct
4508{
4509 CsrWifiFsmEvent common;
4510} CsrWifiSmeStationMacAddressGetReq;
4511
4512/*******************************************************************************
4513
4514 NAME
4515 CsrWifiSmeTspecReq
4516
4517 DESCRIPTION
4518 The wireless manager application should call this primitive to use the
4519 TSPEC feature.
4520 The chip supports the use of TSPECs and TCLAS for the use of IEEE
4521 802.11/WMM Quality of Service features.
4522 The API allows the wireless manager application to supply a correctly
4523 formatted TSPEC and TCLAS pair to the driver.
4524 After performing basic validation, the driver negotiates the installation
4525 of the TSPEC with the AP as defined by the 802.11 specification.
4526 The driver retains all TSPEC and TCLAS pairs until they are specifically
4527 removed.
4528 It is not compulsory for a TSPEC to have a TCLAS (NULL is used to
4529 indicate that no TCLAS is supplied), while a TCLASS always require a
4530 TSPEC.
4531 The format of the TSPEC element is specified in 'WMM (including WMM Power
4532 Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'.
4533 For more information, see 'UniFi Configuring WMM and WMM-PS'.
4534
4535 MEMBERS
4536 common - Common header for use with the CsrWifiFsm Module
4537 interfaceTag - Interface Identifier; unique identifier of an interface
4538 action - Specifies the action to be carried out on the list of TSPECs.
4539 CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here.
4540 transactionId - Unique Transaction ID for the TSPEC, as assigned by the
4541 driver
4542 strict - If it set to false, allows the SME to perform automatic
4543 TSPEC negotiation
4544 ctrlMask - Additional TSPEC configuration for CCX.
4545 Set mask with values from CsrWifiSmeTspecCtrl.
4546 CURRENTLY NOT SUPPORTED
4547 tspecLength - Length of the TSPEC.
4548 tspec - Points to the first byte of the TSPEC
4549 tclasLength - Length of the TCLAS.
4550 If it is equal to 0, no TCLASS is provided for the TSPEC
4551 tclas - Points to the first byte of the TCLAS, if any.
4552
4553*******************************************************************************/
4554typedef struct
4555{
4556 CsrWifiFsmEvent common;
4557 u16 interfaceTag;
4558 CsrWifiSmeListAction action;
4559 u32 transactionId;
4560 u8 strict;
4561 CsrWifiSmeTspecCtrlMask ctrlMask;
4562 u16 tspecLength;
4563 u8 *tspec;
4564 u16 tclasLength;
4565 u8 *tclas;
4566} CsrWifiSmeTspecReq;
4567
4568/*******************************************************************************
4569
4570 NAME
4571 CsrWifiSmeVersionsGetReq
4572
4573 DESCRIPTION
4574 This primitive gets the value of the Versions parameter.
4575
4576 MEMBERS
4577 common - Common header for use with the CsrWifiFsm Module
4578
4579*******************************************************************************/
4580typedef struct
4581{
4582 CsrWifiFsmEvent common;
4583} CsrWifiSmeVersionsGetReq;
4584
4585/*******************************************************************************
4586
4587 NAME
4588 CsrWifiSmeWifiFlightmodeReq
4589
4590 DESCRIPTION
4591 The wireless manager application may call this primitive on boot-up of
4592 the platform to ensure that the chip is placed in a mode that prevents
4593 any emission of RF energy.
4594 This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ.
4595 As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file
4596 (if any) and the programming of the initial MIB settings (if supplied by
4597 the WMA), but it also ensures that the chip is left in its lowest
4598 possible power-mode with the radio subsystems disabled.
4599 This feature is useful on platforms where power cannot be removed from
4600 the chip (leaving the chip not initialised will cause it to consume more
4601 power so calling this function ensures that the chip is initialised into
4602 a low power mode but without entering a state where it could emit any RF
4603 energy).
4604 NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi
4605 stays conceptually off. Configuration primitives can be sent after
4606 CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained.
4607 Requests that require the state of the Wi-Fi to be ON will return
4608 CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms.
4609
4610 MEMBERS
4611 common - Common header for use with the CsrWifiFsm Module
4612 address - Optionally specifies a station MAC address.
4613 In normal use, the manager should set the address to 0xFF
4614 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
4615 the MAC address in the MIB.
4616 mibFilesCount - Number of provided data blocks with initial MIB values
4617 mibFiles - Points to the first data block with initial MIB values.
4618 These data blocks are typically the contents of the provided
4619 files ufmib.dat and localmib.dat, available from the host
4620 file system, if they exist.
4621 These files typically contain radio tuning and calibration
4622 values.
4623 More values can be created using the Host Tools.
4624
4625*******************************************************************************/
4626typedef struct
4627{
4628 CsrWifiFsmEvent common;
4629 CsrWifiMacAddress address;
4630 u16 mibFilesCount;
4631 CsrWifiSmeDataBlock *mibFiles;
4632} CsrWifiSmeWifiFlightmodeReq;
4633
4634/*******************************************************************************
4635
4636 NAME
4637 CsrWifiSmeWifiOffReq
4638
4639 DESCRIPTION
4640 The wireless manager application calls this primitive to turn off the
4641 chip, thus saving power when Wi-Fi is not in use.
4642
4643 MEMBERS
4644 common - Common header for use with the CsrWifiFsm Module
4645
4646*******************************************************************************/
4647typedef struct
4648{
4649 CsrWifiFsmEvent common;
4650} CsrWifiSmeWifiOffReq;
4651
4652/*******************************************************************************
4653
4654 NAME
4655 CsrWifiSmeWifiOnReq
4656
4657 DESCRIPTION
4658 The wireless manager application calls this primitive to turn on the
4659 Wi-Fi chip.
4660 If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on,
4661 downloads the patch file (if any), and programs the initial MIB settings
4662 (if supplied by the WMA).
4663 The patch file is not provided with the SME API; its downloading is
4664 automatic and handled internally by the system.
4665 The MIB settings, when provided, override the default values that the
4666 firmware loads from EEPROM.
4667 If the Wi-Fi chip is already on, the SME takes no action and returns a
4668 successful status in the confirm.
4669
4670 MEMBERS
4671 common - Common header for use with the CsrWifiFsm Module
4672 address - Optionally specifies a station MAC address.
4673 In normal use, the manager should set the address to 0xFF
4674 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
4675 the MAC address in the MIB
4676 mibFilesCount - Number of provided data blocks with initial MIB values
4677 mibFiles - Points to the first data block with initial MIB values.
4678 These data blocks are typically the contents of the provided
4679 files ufmib.dat and localmib.dat, available from the host
4680 file system, if they exist.
4681 These files typically contain radio tuning and calibration
4682 values.
4683 More values can be created using the Host Tools.
4684
4685*******************************************************************************/
4686typedef struct
4687{
4688 CsrWifiFsmEvent common;
4689 CsrWifiMacAddress address;
4690 u16 mibFilesCount;
4691 CsrWifiSmeDataBlock *mibFiles;
4692} CsrWifiSmeWifiOnReq;
4693
4694/*******************************************************************************
4695
4696 NAME
4697 CsrWifiSmeCloakedSsidsSetReq
4698
4699 DESCRIPTION
4700 This primitive sets the list of cloaked SSIDs for which the WMA possesses
4701 profiles.
4702 When the driver detects a cloaked AP, the SME will explicitly scan for it
4703 using the list of cloaked SSIDs provided it, and, if the scan succeeds,
4704 it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND
4705 (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM.
4706
4707 MEMBERS
4708 common - Common header for use with the CsrWifiFsm Module
4709 cloakedSsids - Sets the list of cloaked SSIDs
4710
4711*******************************************************************************/
4712typedef struct
4713{
4714 CsrWifiFsmEvent common;
4715 CsrWifiSmeCloakedSsidConfig cloakedSsids;
4716} CsrWifiSmeCloakedSsidsSetReq;
4717
4718/*******************************************************************************
4719
4720 NAME
4721 CsrWifiSmeCloakedSsidsGetReq
4722
4723 DESCRIPTION
4724 This primitive gets the value of the CloakedSsids parameter.
4725
4726 MEMBERS
4727 common - Common header for use with the CsrWifiFsm Module
4728
4729*******************************************************************************/
4730typedef struct
4731{
4732 CsrWifiFsmEvent common;
4733} CsrWifiSmeCloakedSsidsGetReq;
4734
4735/*******************************************************************************
4736
4737 NAME
4738 CsrWifiSmeSmeCommonConfigGetReq
4739
4740 DESCRIPTION
4741 This primitive gets the value of the Sme common parameter.
4742
4743 MEMBERS
4744 common - Common header for use with the CsrWifiFsm Module
4745
4746*******************************************************************************/
4747typedef struct
4748{
4749 CsrWifiFsmEvent common;
4750} CsrWifiSmeSmeCommonConfigGetReq;
4751
4752/*******************************************************************************
4753
4754 NAME
4755 CsrWifiSmeSmeCommonConfigSetReq
4756
4757 DESCRIPTION
4758 This primitive sets the value of the Sme common.
4759
4760 MEMBERS
4761 common - Common header for use with the CsrWifiFsm Module
4762 deviceConfig - Configuration options in the SME
4763
4764*******************************************************************************/
4765typedef struct
4766{
4767 CsrWifiFsmEvent common;
4768 CsrWifiSmeDeviceConfig deviceConfig;
4769} CsrWifiSmeSmeCommonConfigSetReq;
4770
4771/*******************************************************************************
4772
4773 NAME
4774 CsrWifiSmeInterfaceCapabilityGetReq
4775
4776 DESCRIPTION
4777 The Wireless Manager calls this primitive to ask the SME for the
4778 capabilities of the supported interfaces
4779
4780 MEMBERS
4781 common - Common header for use with the CsrWifiFsm Module
4782
4783*******************************************************************************/
4784typedef struct
4785{
4786 CsrWifiFsmEvent common;
4787} CsrWifiSmeInterfaceCapabilityGetReq;
4788
4789/*******************************************************************************
4790
4791 NAME
4792 CsrWifiSmeWpsConfigurationReq
4793
4794 DESCRIPTION
4795 This primitive passes the WPS information for the device to SME. This may
4796 be accepted only if no interface is active.
4797
4798 MEMBERS
4799 common - Common header for use with the CsrWifiFsm Module
4800 wpsConfig - WPS config.
4801
4802*******************************************************************************/
4803typedef struct
4804{
4805 CsrWifiFsmEvent common;
4806 CsrWifiSmeWpsConfig wpsConfig;
4807} CsrWifiSmeWpsConfigurationReq;
4808
4809/*******************************************************************************
4810
4811 NAME
4812 CsrWifiSmeSetReq
4813
4814 DESCRIPTION
4815 Used to pass custom data to the SME. Format is the same as 802.11 Info
4816 Elements => | Id | Length | Data
4817 1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01
4818 (0x00|0x01)"
4819
4820 MEMBERS
4821 common - Common header for use with the CsrWifiFsm Module
4822 dataLength - Number of bytes in the buffer pointed to by 'data'
4823 data - Pointer to the buffer containing 'dataLength' bytes
4824
4825*******************************************************************************/
4826typedef struct
4827{
4828 CsrWifiFsmEvent common;
4829 u32 dataLength;
4830 u8 *data;
4831} CsrWifiSmeSetReq;
4832
4833/*******************************************************************************
4834
4835 NAME
4836 CsrWifiSmeActivateCfm
4837
4838 DESCRIPTION
4839 The SME sends this primitive when the activation is complete.
4840
4841 MEMBERS
4842 common - Common header for use with the CsrWifiFsm Module
4843 status - Reports the result of the request
4844
4845*******************************************************************************/
4846typedef struct
4847{
4848 CsrWifiFsmEvent common;
4849 CsrResult status;
4850} CsrWifiSmeActivateCfm;
4851
4852/*******************************************************************************
4853
4854 NAME
4855 CsrWifiSmeAdhocConfigGetCfm
4856
4857 DESCRIPTION
4858 This primitive reports the result of the request.
4859
4860 MEMBERS
4861 common - Common header for use with the CsrWifiFsm Module
4862 status - Reports the result of the request
4863 adHocConfig - Contains the values used when starting an Ad-hoc (IBSS)
4864 connection.
4865
4866*******************************************************************************/
4867typedef struct
4868{
4869 CsrWifiFsmEvent common;
4870 CsrResult status;
4871 CsrWifiSmeAdHocConfig adHocConfig;
4872} CsrWifiSmeAdhocConfigGetCfm;
4873
4874/*******************************************************************************
4875
4876 NAME
4877 CsrWifiSmeAdhocConfigSetCfm
4878
4879 DESCRIPTION
4880 This primitive reports the result of the request.
4881
4882 MEMBERS
4883 common - Common header for use with the CsrWifiFsm Module
4884 status - Reports the result of the request
4885
4886*******************************************************************************/
4887typedef struct
4888{
4889 CsrWifiFsmEvent common;
4890 CsrResult status;
4891} CsrWifiSmeAdhocConfigSetCfm;
4892
4893/*******************************************************************************
4894
4895 NAME
4896 CsrWifiSmeAssociationCompleteInd
4897
4898 DESCRIPTION
4899 The SME will send this primitive to all the tasks that have registered to
4900 receive it whenever it completes an attempt to associate with an AP. If
4901 the association was successful, status will be set to
4902 CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be
4903 set to appropriate error codes.
4904
4905 MEMBERS
4906 common - Common header for use with the CsrWifiFsm Module
4907 interfaceTag - Interface Identifier; unique identifier of an interface
4908 status - Reports the result of the association procedure
4909 connectionInfo - This parameter is relevant only if result is
4910 CSR_WIFI_SME_STATUS_SUCCESS:
4911 it points to the connection information for the new network
4912 deauthReason - This parameter is relevant only if result is not
4913 CSR_WIFI_SME_STATUS_SUCCESS:
4914 if the AP deauthorised the station, it gives the reason of
4915 the deauthorization
4916
4917*******************************************************************************/
4918typedef struct
4919{
4920 CsrWifiFsmEvent common;
4921 u16 interfaceTag;
4922 CsrResult status;
4923 CsrWifiSmeConnectionInfo connectionInfo;
4924 CsrWifiSmeIEEE80211Reason deauthReason;
4925} CsrWifiSmeAssociationCompleteInd;
4926
4927/*******************************************************************************
4928
4929 NAME
4930 CsrWifiSmeAssociationStartInd
4931
4932 DESCRIPTION
4933 The SME will send this primitive to all the tasks that have registered to
4934 receive it whenever it begins an attempt to associate with an AP.
4935
4936 MEMBERS
4937 common - Common header for use with the CsrWifiFsm Module
4938 interfaceTag - Interface Identifier; unique identifier of an interface
4939 address - BSSID of the associating network
4940 ssid - Service Set identifier of the associating network
4941
4942*******************************************************************************/
4943typedef struct
4944{
4945 CsrWifiFsmEvent common;
4946 u16 interfaceTag;
4947 CsrWifiMacAddress address;
4948 CsrWifiSsid ssid;
4949} CsrWifiSmeAssociationStartInd;
4950
4951/*******************************************************************************
4952
4953 NAME
4954 CsrWifiSmeBlacklistCfm
4955
4956 DESCRIPTION
4957 The SME will call this primitive when the action on the blacklist has
4958 completed. For a GET action, this primitive also reports the list of
4959 BBSIDs in the blacklist.
4960
4961 MEMBERS
4962 common - Common header for use with the CsrWifiFsm Module
4963 interfaceTag - Interface Identifier; unique identifier of an interface
4964 status - Reports the result of the request
4965 action - Action in the request
4966 getAddressCount - This parameter is only relevant if action is
4967 CSR_WIFI_SME_LIST_ACTION_GET:
4968 number of BSSIDs sent with this primitive
4969 getAddresses - Pointer to the list of BBSIDs sent with the primitive, set
4970 to NULL if none is sent.
4971
4972*******************************************************************************/
4973typedef struct
4974{
4975 CsrWifiFsmEvent common;
4976 u16 interfaceTag;
4977 CsrResult status;
4978 CsrWifiSmeListAction action;
4979 u8 getAddressCount;
4980 CsrWifiMacAddress *getAddresses;
4981} CsrWifiSmeBlacklistCfm;
4982
4983/*******************************************************************************
4984
4985 NAME
4986 CsrWifiSmeCalibrationDataGetCfm
4987
4988 DESCRIPTION
4989 This primitive reports the result of the request.
4990
4991 MEMBERS
4992 common - Common header for use with the CsrWifiFsm Module
4993 status - Reports the result of the request
4994 calibrationDataLength - Number of bytes in the buffer pointed by
4995 calibrationData
4996 calibrationData - Pointer to a buffer of length calibrationDataLength
4997 containing the calibration data
4998
4999*******************************************************************************/
5000typedef struct
5001{
5002 CsrWifiFsmEvent common;
5003 CsrResult status;
5004 u16 calibrationDataLength;
5005 u8 *calibrationData;
5006} CsrWifiSmeCalibrationDataGetCfm;
5007
5008/*******************************************************************************
5009
5010 NAME
5011 CsrWifiSmeCalibrationDataSetCfm
5012
5013 DESCRIPTION
5014 This primitive reports the result of the request.
5015
5016 MEMBERS
5017 common - Common header for use with the CsrWifiFsm Module
5018 status - Reports the result of the request
5019
5020*******************************************************************************/
5021typedef struct
5022{
5023 CsrWifiFsmEvent common;
5024 CsrResult status;
5025} CsrWifiSmeCalibrationDataSetCfm;
5026
5027/*******************************************************************************
5028
5029 NAME
5030 CsrWifiSmeCcxConfigGetCfm
5031
5032 DESCRIPTION
5033 This primitive reports the result of the request.
5034
5035 MEMBERS
5036 common - Common header for use with the CsrWifiFsm Module
5037 interfaceTag - Interface Identifier; unique identifier of an interface
5038 status - Reports the result of the request
5039 ccxConfig - Currently not supported
5040
5041*******************************************************************************/
5042typedef struct
5043{
5044 CsrWifiFsmEvent common;
5045 u16 interfaceTag;
5046 CsrResult status;
5047 CsrWifiSmeCcxConfig ccxConfig;
5048} CsrWifiSmeCcxConfigGetCfm;
5049
5050/*******************************************************************************
5051
5052 NAME
5053 CsrWifiSmeCcxConfigSetCfm
5054
5055 DESCRIPTION
5056 This primitive reports the result of the request.
5057
5058 MEMBERS
5059 common - Common header for use with the CsrWifiFsm Module
5060 interfaceTag - Interface Identifier; unique identifier of an interface
5061 status - Reports the result of the request
5062
5063*******************************************************************************/
5064typedef struct
5065{
5066 CsrWifiFsmEvent common;
5067 u16 interfaceTag;
5068 CsrResult status;
5069} CsrWifiSmeCcxConfigSetCfm;
5070
5071/*******************************************************************************
5072
5073 NAME
5074 CsrWifiSmeCoexConfigGetCfm
5075
5076 DESCRIPTION
5077 This primitive reports the result of the request.
5078
5079 MEMBERS
5080 common - Common header for use with the CsrWifiFsm Module
5081 status - Reports the result of the request
5082 coexConfig - Reports the parameters used to configure the coexistence
5083 behaviour
5084
5085*******************************************************************************/
5086typedef struct
5087{
5088 CsrWifiFsmEvent common;
5089 CsrResult status;
5090 CsrWifiSmeCoexConfig coexConfig;
5091} CsrWifiSmeCoexConfigGetCfm;
5092
5093/*******************************************************************************
5094
5095 NAME
5096 CsrWifiSmeCoexConfigSetCfm
5097
5098 DESCRIPTION
5099 This primitive reports the result of the request.
5100
5101 MEMBERS
5102 common - Common header for use with the CsrWifiFsm Module
5103 status - Reports the result of the request
5104
5105*******************************************************************************/
5106typedef struct
5107{
5108 CsrWifiFsmEvent common;
5109 CsrResult status;
5110} CsrWifiSmeCoexConfigSetCfm;
5111
5112/*******************************************************************************
5113
5114 NAME
5115 CsrWifiSmeCoexInfoGetCfm
5116
5117 DESCRIPTION
5118 This primitive reports the result of the request.
5119
5120 MEMBERS
5121 common - Common header for use with the CsrWifiFsm Module
5122 status - Reports the result of the request
5123 coexInfo - Reports information and state related to coexistence.
5124
5125*******************************************************************************/
5126typedef struct
5127{
5128 CsrWifiFsmEvent common;
5129 CsrResult status;
5130 CsrWifiSmeCoexInfo coexInfo;
5131} CsrWifiSmeCoexInfoGetCfm;
5132
5133/*******************************************************************************
5134
5135 NAME
5136 CsrWifiSmeConnectCfm
5137
5138 DESCRIPTION
5139 The SME calls this primitive when the connection exchange is complete or
5140 all connection attempts fail.
5141
5142 MEMBERS
5143 common - Common header for use with the CsrWifiFsm Module
5144 interfaceTag - Interface Identifier; unique identifier of an interface
5145 status - Reports the result of the request.
5146 CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to
5147 locate the requested AP failed
5148
5149*******************************************************************************/
5150typedef struct
5151{
5152 CsrWifiFsmEvent common;
5153 u16 interfaceTag;
5154 CsrResult status;
5155} CsrWifiSmeConnectCfm;
5156
5157/*******************************************************************************
5158
5159 NAME
5160 CsrWifiSmeConnectionConfigGetCfm
5161
5162 DESCRIPTION
5163 This primitive reports the result of the request.
5164
5165 MEMBERS
5166 common - Common header for use with the CsrWifiFsm Module
5167 interfaceTag - Interface Identifier; unique identifier of an interface
5168 status - Reports the result of the request
5169 connectionConfig - Parameters used by the SME for selecting a network
5170
5171*******************************************************************************/
5172typedef struct
5173{
5174 CsrWifiFsmEvent common;
5175 u16 interfaceTag;
5176 CsrResult status;
5177 CsrWifiSmeConnectionConfig connectionConfig;
5178} CsrWifiSmeConnectionConfigGetCfm;
5179
5180/*******************************************************************************
5181
5182 NAME
5183 CsrWifiSmeConnectionInfoGetCfm
5184
5185 DESCRIPTION
5186 This primitive reports the result of the request.
5187
5188 MEMBERS
5189 common - Common header for use with the CsrWifiFsm Module
5190 interfaceTag - Interface Identifier; unique identifier of an interface
5191 status - Reports the result of the request
5192 connectionInfo - Information about the current connection
5193
5194*******************************************************************************/
5195typedef struct
5196{
5197 CsrWifiFsmEvent common;
5198 u16 interfaceTag;
5199 CsrResult status;
5200 CsrWifiSmeConnectionInfo connectionInfo;
5201} CsrWifiSmeConnectionInfoGetCfm;
5202
5203/*******************************************************************************
5204
5205 NAME
5206 CsrWifiSmeConnectionQualityInd
5207
5208 DESCRIPTION
5209 The SME sends this primitive to all the tasks that have registered to
5210 receive it whenever the value of the current connection quality
5211 parameters change by more than a certain configurable amount.
5212 The wireless manager application may configure the trigger thresholds for
5213 this indication using the field in smeConfig parameter of
5214 CSR_WIFI_SME_SME_CONFIG_SET_REQ.
5215 Connection quality messages can be suppressed by setting both thresholds
5216 to zero.
5217
5218 MEMBERS
5219 common - Common header for use with the CsrWifiFsm Module
5220 interfaceTag - Interface Identifier; unique identifier of an interface
5221 linkQuality - Indicates the quality of the link
5222
5223*******************************************************************************/
5224typedef struct
5225{
5226 CsrWifiFsmEvent common;
5227 u16 interfaceTag;
5228 CsrWifiSmeLinkQuality linkQuality;
5229} CsrWifiSmeConnectionQualityInd;
5230
5231/*******************************************************************************
5232
5233 NAME
5234 CsrWifiSmeConnectionStatsGetCfm
5235
5236 DESCRIPTION
5237 This primitive reports the result of the request.
5238
5239 MEMBERS
5240 common - Common header for use with the CsrWifiFsm Module
5241 interfaceTag - Interface Identifier; unique identifier of an interface
5242 status - Reports the result of the request
5243 connectionStats - Statistics for current connection.
5244
5245*******************************************************************************/
5246typedef struct
5247{
5248 CsrWifiFsmEvent common;
5249 u16 interfaceTag;
5250 CsrResult status;
5251 CsrWifiSmeConnectionStats connectionStats;
5252} CsrWifiSmeConnectionStatsGetCfm;
5253
5254/*******************************************************************************
5255
5256 NAME
5257 CsrWifiSmeDeactivateCfm
5258
5259 DESCRIPTION
5260 The SME sends this primitive when the deactivation is complete.
5261 The WMA cannot send any more primitives until it actives the SME again
5262 sending another CSR_WIFI_SME_ACTIVATE_REQ.
5263
5264 MEMBERS
5265 common - Common header for use with the CsrWifiFsm Module
5266 status - Reports the result of the request
5267
5268*******************************************************************************/
5269typedef struct
5270{
5271 CsrWifiFsmEvent common;
5272 CsrResult status;
5273} CsrWifiSmeDeactivateCfm;
5274
5275/*******************************************************************************
5276
5277 NAME
5278 CsrWifiSmeDisconnectCfm
5279
5280 DESCRIPTION
5281 On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a
5282 disconnect operation, sending a CsrWifiSmeMediaStatusInd with
5283 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when
5284 disconnection is complete.
5285
5286 MEMBERS
5287 common - Common header for use with the CsrWifiFsm Module
5288 interfaceTag - Interface Identifier; unique identifier of an interface
5289 status - Reports the result of the request
5290
5291*******************************************************************************/
5292typedef struct
5293{
5294 CsrWifiFsmEvent common;
5295 u16 interfaceTag;
5296 CsrResult status;
5297} CsrWifiSmeDisconnectCfm;
5298
5299/*******************************************************************************
5300
5301 NAME
5302 CsrWifiSmeEventMaskSetCfm
5303
5304 DESCRIPTION
5305 The SME calls the primitive to report the result of the request
5306 primitive.
5307
5308 MEMBERS
5309 common - Common header for use with the CsrWifiFsm Module
5310 status - Reports the result of the request
5311
5312*******************************************************************************/
5313typedef struct
5314{
5315 CsrWifiFsmEvent common;
5316 CsrResult status;
5317} CsrWifiSmeEventMaskSetCfm;
5318
5319/*******************************************************************************
5320
5321 NAME
5322 CsrWifiSmeHostConfigGetCfm
5323
5324 DESCRIPTION
5325 This primitive reports the result of the request.
5326
5327 MEMBERS
5328 common - Common header for use with the CsrWifiFsm Module
5329 interfaceTag - Interface Identifier; unique identifier of an interface
5330 status - Reports the result of the request
5331 hostConfig - Current host power state.
5332
5333*******************************************************************************/
5334typedef struct
5335{
5336 CsrWifiFsmEvent common;
5337 u16 interfaceTag;
5338 CsrResult status;
5339 CsrWifiSmeHostConfig hostConfig;
5340} CsrWifiSmeHostConfigGetCfm;
5341
5342/*******************************************************************************
5343
5344 NAME
5345 CsrWifiSmeHostConfigSetCfm
5346
5347 DESCRIPTION
5348 This primitive reports the result of the request.
5349
5350 MEMBERS
5351 common - Common header for use with the CsrWifiFsm Module
5352 interfaceTag - Interface Identifier; unique identifier of an interface
5353 status - Reports the result of the request
5354
5355*******************************************************************************/
5356typedef struct
5357{
5358 CsrWifiFsmEvent common;
5359 u16 interfaceTag;
5360 CsrResult status;
5361} CsrWifiSmeHostConfigSetCfm;
5362
5363/*******************************************************************************
5364
5365 NAME
5366 CsrWifiSmeIbssStationInd
5367
5368 DESCRIPTION
5369 The SME will send this primitive to indicate that a station has joined or
5370 left the ad-hoc network.
5371
5372 MEMBERS
5373 common - Common header for use with the CsrWifiFsm Module
5374 address - MAC address of the station that has joined or left
5375 isconnected - TRUE if the station joined, FALSE if the station left
5376
5377*******************************************************************************/
5378typedef struct
5379{
5380 CsrWifiFsmEvent common;
5381 CsrWifiMacAddress address;
5382 u8 isconnected;
5383} CsrWifiSmeIbssStationInd;
5384
5385/*******************************************************************************
5386
5387 NAME
5388 CsrWifiSmeKeyCfm
5389
5390 DESCRIPTION
5391 The SME calls the primitive to report the result of the request
5392 primitive.
5393
5394 MEMBERS
5395 common - Common header for use with the CsrWifiFsm Module
5396 interfaceTag - Interface Identifier; unique identifier of an interface
5397 status - Reports the result of the request
5398 action - Action in the request
5399 keyType - Type of the key added/deleted
5400 peerMacAddress - Peer MAC Address of the key added/deleted
5401
5402*******************************************************************************/
5403typedef struct
5404{
5405 CsrWifiFsmEvent common;
5406 u16 interfaceTag;
5407 CsrResult status;
5408 CsrWifiSmeListAction action;
5409 CsrWifiSmeKeyType keyType;
5410 CsrWifiMacAddress peerMacAddress;
5411} CsrWifiSmeKeyCfm;
5412
5413/*******************************************************************************
5414
5415 NAME
5416 CsrWifiSmeLinkQualityGetCfm
5417
5418 DESCRIPTION
5419 This primitive reports the result of the request.
5420
5421 MEMBERS
5422 common - Common header for use with the CsrWifiFsm Module
5423 interfaceTag - Interface Identifier; unique identifier of an interface
5424 status - Reports the result of the request
5425 linkQuality - Indicates the quality of the link
5426
5427*******************************************************************************/
5428typedef struct
5429{
5430 CsrWifiFsmEvent common;
5431 u16 interfaceTag;
5432 CsrResult status;
5433 CsrWifiSmeLinkQuality linkQuality;
5434} CsrWifiSmeLinkQualityGetCfm;
5435
5436/*******************************************************************************
5437
5438 NAME
5439 CsrWifiSmeMediaStatusInd
5440
5441 DESCRIPTION
5442 The SME sends this primitive to all the tasks that have registered to
5443 receive it when a network connection is established, lost or has moved to
5444 another AP.
5445
5446 MEMBERS
5447 common - Common header for use with the CsrWifiFsm Module
5448 interfaceTag - Interface Identifier; unique identifier of an interface
5449 mediaStatus - Indicates the media status
5450 connectionInfo - This parameter is relevant only if the mediaStatus is
5451 CSR_WIFI_SME_MEDIA_STATUS_CONNECTED:
5452 it points to the connection information for the new network
5453 disassocReason - This parameter is relevant only if the mediaStatus is
5454 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
5455 if a disassociation has occurred it gives the reason of the
5456 disassociation
5457 deauthReason - This parameter is relevant only if the mediaStatus is
5458 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
5459 if a deauthentication has occurred it gives the reason of
5460 the deauthentication
5461
5462*******************************************************************************/
5463typedef struct
5464{
5465 CsrWifiFsmEvent common;
5466 u16 interfaceTag;
5467 CsrWifiSmeMediaStatus mediaStatus;
5468 CsrWifiSmeConnectionInfo connectionInfo;
5469 CsrWifiSmeIEEE80211Reason disassocReason;
5470 CsrWifiSmeIEEE80211Reason deauthReason;
5471} CsrWifiSmeMediaStatusInd;
5472
5473/*******************************************************************************
5474
5475 NAME
5476 CsrWifiSmeMibConfigGetCfm
5477
5478 DESCRIPTION
5479 This primitive reports the result of the request.
5480
5481 MEMBERS
5482 common - Common header for use with the CsrWifiFsm Module
5483 status - Reports the result of the request
5484 mibConfig - Reports various IEEE 802.11 attributes as currently configured
5485
5486*******************************************************************************/
5487typedef struct
5488{
5489 CsrWifiFsmEvent common;
5490 CsrResult status;
5491 CsrWifiSmeMibConfig mibConfig;
5492} CsrWifiSmeMibConfigGetCfm;
5493
5494/*******************************************************************************
5495
5496 NAME
5497 CsrWifiSmeMibConfigSetCfm
5498
5499 DESCRIPTION
5500 This primitive reports the result of the request.
5501
5502 MEMBERS
5503 common - Common header for use with the CsrWifiFsm Module
5504 status - Reports the result of the request
5505
5506*******************************************************************************/
5507typedef struct
5508{
5509 CsrWifiFsmEvent common;
5510 CsrResult status;
5511} CsrWifiSmeMibConfigSetCfm;
5512
5513/*******************************************************************************
5514
5515 NAME
5516 CsrWifiSmeMibGetCfm
5517
5518 DESCRIPTION
5519 The SME calls this primitive to return the requested MIB variable values.
5520
5521 MEMBERS
5522 common - Common header for use with the CsrWifiFsm Module
5523 status - Reports the result of the request
5524 mibAttributeLength - Length of mibAttribute
5525 mibAttribute - Points to the VarBind or VarBindList containing the
5526 names and values of the MIB variables requested
5527
5528*******************************************************************************/
5529typedef struct
5530{
5531 CsrWifiFsmEvent common;
5532 CsrResult status;
5533 u16 mibAttributeLength;
5534 u8 *mibAttribute;
5535} CsrWifiSmeMibGetCfm;
5536
5537/*******************************************************************************
5538
5539 NAME
5540 CsrWifiSmeMibGetNextCfm
5541
5542 DESCRIPTION
5543 The SME calls this primitive to return the requested MIB name(s).
5544 The wireless manager application can then read the value of the MIB
5545 variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided.
5546
5547 MEMBERS
5548 common - Common header for use with the CsrWifiFsm Module
5549 status - Reports the result of the request
5550 mibAttributeLength - Length of mibAttribute
5551 mibAttribute - Points to a VarBind or VarBindList containing the
5552 name(s) of the MIB variable(s) lexicographically
5553 following the name(s) given in the request
5554
5555*******************************************************************************/
5556typedef struct
5557{
5558 CsrWifiFsmEvent common;
5559 CsrResult status;
5560 u16 mibAttributeLength;
5561 u8 *mibAttribute;
5562} CsrWifiSmeMibGetNextCfm;
5563
5564/*******************************************************************************
5565
5566 NAME
5567 CsrWifiSmeMibSetCfm
5568
5569 DESCRIPTION
5570 The SME calls the primitive to report the result of the set primitive.
5571
5572 MEMBERS
5573 common - Common header for use with the CsrWifiFsm Module
5574 status - Reports the result of the request
5575
5576*******************************************************************************/
5577typedef struct
5578{
5579 CsrWifiFsmEvent common;
5580 CsrResult status;
5581} CsrWifiSmeMibSetCfm;
5582
5583/*******************************************************************************
5584
5585 NAME
5586 CsrWifiSmeMicFailureInd
5587
5588 DESCRIPTION
5589 The SME sends this primitive to all the tasks that have registered to
5590 receive it whenever the chip firmware reports a MIC failure.
5591
5592 MEMBERS
5593 common - Common header for use with the CsrWifiFsm Module
5594 interfaceTag - Interface Identifier; unique identifier of an interface
5595 secondFailure - TRUE if this indication is for a second failure in 60
5596 seconds
5597 count - The number of MIC failure events since the connection was
5598 established
5599 address - MAC address of the transmitter that caused the MIC failure
5600 keyType - Type of key for which the failure occurred
5601
5602*******************************************************************************/
5603typedef struct
5604{
5605 CsrWifiFsmEvent common;
5606 u16 interfaceTag;
5607 u8 secondFailure;
5608 u16 count;
5609 CsrWifiMacAddress address;
5610 CsrWifiSmeKeyType keyType;
5611} CsrWifiSmeMicFailureInd;
5612
5613/*******************************************************************************
5614
5615 NAME
5616 CsrWifiSmeMulticastAddressCfm
5617
5618 DESCRIPTION
5619 The SME will call this primitive when the operation is complete. For a
5620 GET action, this primitive reports the current list of MAC addresses.
5621
5622 MEMBERS
5623 common - Common header for use with the CsrWifiFsm Module
5624 interfaceTag - Interface Identifier; unique identifier of an interface
5625 status - Reports the result of the request
5626 action - Action in the request
5627 getAddressesCount - This parameter is only relevant if action is
5628 CSR_WIFI_SME_LIST_ACTION_GET:
5629 number of MAC addresses sent with the primitive
5630 getAddresses - Pointer to the list of MAC Addresses sent with the
5631 primitive, set to NULL if none is sent.
5632
5633*******************************************************************************/
5634typedef struct
5635{
5636 CsrWifiFsmEvent common;
5637 u16 interfaceTag;
5638 CsrResult status;
5639 CsrWifiSmeListAction action;
5640 u8 getAddressesCount;
5641 CsrWifiMacAddress *getAddresses;
5642} CsrWifiSmeMulticastAddressCfm;
5643
5644/*******************************************************************************
5645
5646 NAME
5647 CsrWifiSmePacketFilterSetCfm
5648
5649 DESCRIPTION
5650 The SME calls the primitive to report the result of the set primitive.
5651
5652 MEMBERS
5653 common - Common header for use with the CsrWifiFsm Module
5654 interfaceTag - Interface Identifier; unique identifier of an interface
5655 status - Reports the result of the request
5656
5657*******************************************************************************/
5658typedef struct
5659{
5660 CsrWifiFsmEvent common;
5661 u16 interfaceTag;
5662 CsrResult status;
5663} CsrWifiSmePacketFilterSetCfm;
5664
5665/*******************************************************************************
5666
5667 NAME
5668 CsrWifiSmePermanentMacAddressGetCfm
5669
5670 DESCRIPTION
5671 This primitive reports the result of the request.
5672
5673 MEMBERS
5674 common - Common header for use with the CsrWifiFsm Module
5675 status - Reports the result of the request
5676 permanentMacAddress - MAC address stored in the EEPROM
5677
5678*******************************************************************************/
5679typedef struct
5680{
5681 CsrWifiFsmEvent common;
5682 CsrResult status;
5683 CsrWifiMacAddress permanentMacAddress;
5684} CsrWifiSmePermanentMacAddressGetCfm;
5685
5686/*******************************************************************************
5687
5688 NAME
5689 CsrWifiSmePmkidCandidateListInd
5690
5691 DESCRIPTION
5692 The SME will send this primitive to all the tasks that have registered to
5693 receive it when a new network supporting preauthentication and/or PMK
5694 caching is seen.
5695
5696 MEMBERS
5697 common - Common header for use with the CsrWifiFsm Module
5698 interfaceTag - Interface Identifier; unique identifier of an
5699 interface
5700 pmkidCandidatesCount - Number of PMKID candidates provided
5701 pmkidCandidates - Points to the first PMKID candidate
5702
5703*******************************************************************************/
5704typedef struct
5705{
5706 CsrWifiFsmEvent common;
5707 u16 interfaceTag;
5708 u8 pmkidCandidatesCount;
5709 CsrWifiSmePmkidCandidate *pmkidCandidates;
5710} CsrWifiSmePmkidCandidateListInd;
5711
5712/*******************************************************************************
5713
5714 NAME
5715 CsrWifiSmePmkidCfm
5716
5717 DESCRIPTION
5718 The SME will call this primitive when the operation is complete. For a
5719 GET action, this primitive reports the current list of PMKIDs
5720
5721 MEMBERS
5722 common - Common header for use with the CsrWifiFsm Module
5723 interfaceTag - Interface Identifier; unique identifier of an interface
5724 status - Reports the result of the request
5725 action - Action in the request
5726 getPmkidsCount - This parameter is only relevant if action is
5727 CSR_WIFI_SME_LIST_ACTION_GET:
5728 number of PMKIDs sent with the primitive
5729 getPmkids - Pointer to the list of PMKIDs sent with the primitive, set
5730 to NULL if none is sent.
5731
5732*******************************************************************************/
5733typedef struct
5734{
5735 CsrWifiFsmEvent common;
5736 u16 interfaceTag;
5737 CsrResult status;
5738 CsrWifiSmeListAction action;
5739 u8 getPmkidsCount;
5740 CsrWifiSmePmkid *getPmkids;
5741} CsrWifiSmePmkidCfm;
5742
5743/*******************************************************************************
5744
5745 NAME
5746 CsrWifiSmePowerConfigGetCfm
5747
5748 DESCRIPTION
5749 This primitive reports the result of the request.
5750
5751 MEMBERS
5752 common - Common header for use with the CsrWifiFsm Module
5753 status - Reports the result of the request
5754 powerConfig - Returns the current parameters for the power configuration of
5755 the firmware
5756
5757*******************************************************************************/
5758typedef struct
5759{
5760 CsrWifiFsmEvent common;
5761 CsrResult status;
5762 CsrWifiSmePowerConfig powerConfig;
5763} CsrWifiSmePowerConfigGetCfm;
5764
5765/*******************************************************************************
5766
5767 NAME
5768 CsrWifiSmePowerConfigSetCfm
5769
5770 DESCRIPTION
5771 This primitive reports the result of the request.
5772
5773 MEMBERS
5774 common - Common header for use with the CsrWifiFsm Module
5775 status - Reports the result of the request
5776
5777*******************************************************************************/
5778typedef struct
5779{
5780 CsrWifiFsmEvent common;
5781 CsrResult status;
5782} CsrWifiSmePowerConfigSetCfm;
5783
5784/*******************************************************************************
5785
5786 NAME
5787 CsrWifiSmeRegulatoryDomainInfoGetCfm
5788
5789 DESCRIPTION
5790 This primitive reports the result of the request.
5791
5792 MEMBERS
5793 common - Common header for use with the CsrWifiFsm Module
5794 status - Reports the result of the request
5795 regDomInfo - Reports information and state related to regulatory domain
5796 operation.
5797
5798*******************************************************************************/
5799typedef struct
5800{
5801 CsrWifiFsmEvent common;
5802 CsrResult status;
5803 CsrWifiSmeRegulatoryDomainInfo regDomInfo;
5804} CsrWifiSmeRegulatoryDomainInfoGetCfm;
5805
5806/*******************************************************************************
5807
5808 NAME
5809 CsrWifiSmeRoamCompleteInd
5810
5811 DESCRIPTION
5812 The SME will send this primitive to all the tasks that have registered to
5813 receive it whenever it completes an attempt to roam to an AP. If the roam
5814 attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS,
5815 otherwise it shall be set to the appropriate error code.
5816
5817 MEMBERS
5818 common - Common header for use with the CsrWifiFsm Module
5819 interfaceTag - Interface Identifier; unique identifier of an interface
5820 status - Reports the result of the roaming procedure
5821
5822*******************************************************************************/
5823typedef struct
5824{
5825 CsrWifiFsmEvent common;
5826 u16 interfaceTag;
5827 CsrResult status;
5828} CsrWifiSmeRoamCompleteInd;
5829
5830/*******************************************************************************
5831
5832 NAME
5833 CsrWifiSmeRoamStartInd
5834
5835 DESCRIPTION
5836 The SME will send this primitive to all the tasks that have registered to
5837 receive it whenever it begins an attempt to roam to an AP.
5838 If the wireless manager application connect request specified the SSID
5839 and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF
5840 0xFF), the SME monitors the signal quality and maintains a list of
5841 candidates to roam to. When the signal quality of the current connection
5842 falls below a threshold, and there is a candidate with better quality,
5843 the SME will attempt to the candidate AP.
5844 If the roaming procedure succeeds, the SME will also issue a Media
5845 Connect indication to inform the wireless manager application of the
5846 change.
5847 NOTE: to prevent the SME from initiating roaming the WMA must specify the
5848 BSSID in the connection request; this forces the SME to connect only to
5849 that AP.
5850 The wireless manager application can obtain statistics for roaming
5851 purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and
5852 CSR_WIFI_SME_CONNECTION_STATS_GET_REQ.
5853 When the wireless manager application wishes to roam to another AP, it
5854 must issue a connection request specifying the BSSID of the desired AP.
5855
5856 MEMBERS
5857 common - Common header for use with the CsrWifiFsm Module
5858 interfaceTag - Interface Identifier; unique identifier of an interface
5859 roamReason - Indicates the reason for starting the roaming procedure
5860 reason80211 - Indicates the reason for deauthentication or disassociation
5861
5862*******************************************************************************/
5863typedef struct
5864{
5865 CsrWifiFsmEvent common;
5866 u16 interfaceTag;
5867 CsrWifiSmeRoamReason roamReason;
5868 CsrWifiSmeIEEE80211Reason reason80211;
5869} CsrWifiSmeRoamStartInd;
5870
5871/*******************************************************************************
5872
5873 NAME
5874 CsrWifiSmeRoamingConfigGetCfm
5875
5876 DESCRIPTION
5877 This primitive reports the result of the request.
5878
5879 MEMBERS
5880 common - Common header for use with the CsrWifiFsm Module
5881 interfaceTag - Interface Identifier; unique identifier of an interface
5882 status - Reports the result of the request
5883 roamingConfig - Reports the roaming behaviour of the driver and firmware
5884
5885*******************************************************************************/
5886typedef struct
5887{
5888 CsrWifiFsmEvent common;
5889 u16 interfaceTag;
5890 CsrResult status;
5891 CsrWifiSmeRoamingConfig roamingConfig;
5892} CsrWifiSmeRoamingConfigGetCfm;
5893
5894/*******************************************************************************
5895
5896 NAME
5897 CsrWifiSmeRoamingConfigSetCfm
5898
5899 DESCRIPTION
5900 This primitive sets the value of the RoamingConfig parameter.
5901
5902 MEMBERS
5903 common - Common header for use with the CsrWifiFsm Module
5904 interfaceTag - Interface Identifier; unique identifier of an interface
5905 status - Reports the result of the request
5906
5907*******************************************************************************/
5908typedef struct
5909{
5910 CsrWifiFsmEvent common;
5911 u16 interfaceTag;
5912 CsrResult status;
5913} CsrWifiSmeRoamingConfigSetCfm;
5914
5915/*******************************************************************************
5916
5917 NAME
5918 CsrWifiSmeScanConfigGetCfm
5919
5920 DESCRIPTION
5921 This primitive reports the result of the request.
5922
5923 MEMBERS
5924 common - Common header for use with the CsrWifiFsm Module
5925 status - Reports the result of the request
5926 scanConfig - Returns the current parameters for the autonomous scanning
5927 behaviour of the firmware
5928
5929*******************************************************************************/
5930typedef struct
5931{
5932 CsrWifiFsmEvent common;
5933 CsrResult status;
5934 CsrWifiSmeScanConfig scanConfig;
5935} CsrWifiSmeScanConfigGetCfm;
5936
5937/*******************************************************************************
5938
5939 NAME
5940 CsrWifiSmeScanConfigSetCfm
5941
5942 DESCRIPTION
5943 This primitive reports the result of the request.
5944
5945 MEMBERS
5946 common - Common header for use with the CsrWifiFsm Module
5947 status - Reports the result of the request
5948
5949*******************************************************************************/
5950typedef struct
5951{
5952 CsrWifiFsmEvent common;
5953 CsrResult status;
5954} CsrWifiSmeScanConfigSetCfm;
5955
5956/*******************************************************************************
5957
5958 NAME
5959 CsrWifiSmeScanFullCfm
5960
5961 DESCRIPTION
5962 The SME calls this primitive when the results from the scan are
5963 available.
5964
5965 MEMBERS
5966 common - Common header for use with the CsrWifiFsm Module
5967 status - Reports the result of the request
5968
5969*******************************************************************************/
5970typedef struct
5971{
5972 CsrWifiFsmEvent common;
5973 CsrResult status;
5974} CsrWifiSmeScanFullCfm;
5975
5976/*******************************************************************************
5977
5978 NAME
5979 CsrWifiSmeScanResultInd
5980
5981 DESCRIPTION
5982 The SME sends this primitive to all the tasks that have registered to
5983 receive it whenever a scan indication is received from the firmware.
5984
5985 MEMBERS
5986 common - Common header for use with the CsrWifiFsm Module
5987 result - Points to a buffer containing a scan result.
5988
5989*******************************************************************************/
5990typedef struct
5991{
5992 CsrWifiFsmEvent common;
5993 CsrWifiSmeScanResult result;
5994} CsrWifiSmeScanResultInd;
5995
5996/*******************************************************************************
5997
5998 NAME
5999 CsrWifiSmeScanResultsFlushCfm
6000
6001 DESCRIPTION
6002 The SME will call this primitive when the cache has been cleared.
6003
6004 MEMBERS
6005 common - Common header for use with the CsrWifiFsm Module
6006 status - Reports the result of the request
6007
6008*******************************************************************************/
6009typedef struct
6010{
6011 CsrWifiFsmEvent common;
6012 CsrResult status;
6013} CsrWifiSmeScanResultsFlushCfm;
6014
6015/*******************************************************************************
6016
6017 NAME
6018 CsrWifiSmeScanResultsGetCfm
6019
6020 DESCRIPTION
6021 The SME sends this primitive to provide the current set of scan results.
6022
6023 MEMBERS
6024 common - Common header for use with the CsrWifiFsm Module
6025 status - Reports the result of the request
6026 scanResultsCount - Number of scan results
6027 scanResults - Points to a buffer containing an array of
6028 CsrWifiSmeScanResult structures.
6029
6030*******************************************************************************/
6031typedef struct
6032{
6033 CsrWifiFsmEvent common;
6034 CsrResult status;
6035 u16 scanResultsCount;
6036 CsrWifiSmeScanResult *scanResults;
6037} CsrWifiSmeScanResultsGetCfm;
6038
6039/*******************************************************************************
6040
6041 NAME
6042 CsrWifiSmeSmeStaConfigGetCfm
6043
6044 DESCRIPTION
6045 This primitive reports the result of the request.
6046
6047 MEMBERS
6048 common - Common header for use with the CsrWifiFsm Module
6049 interfaceTag - Interface Identifier; unique identifier of an interface
6050 status - Reports the result of the request
6051 smeConfig - Current SME Station Parameters
6052
6053*******************************************************************************/
6054typedef struct
6055{
6056 CsrWifiFsmEvent common;
6057 u16 interfaceTag;
6058 CsrResult status;
6059 CsrWifiSmeStaConfig smeConfig;
6060} CsrWifiSmeSmeStaConfigGetCfm;
6061
6062/*******************************************************************************
6063
6064 NAME
6065 CsrWifiSmeSmeStaConfigSetCfm
6066
6067 DESCRIPTION
6068 This primitive reports the result of the request.
6069
6070 MEMBERS
6071 common - Common header for use with the CsrWifiFsm Module
6072 interfaceTag - Interface Identifier; unique identifier of an interface
6073 status - Reports the result of the request
6074
6075*******************************************************************************/
6076typedef struct
6077{
6078 CsrWifiFsmEvent common;
6079 u16 interfaceTag;
6080 CsrResult status;
6081} CsrWifiSmeSmeStaConfigSetCfm;
6082
6083/*******************************************************************************
6084
6085 NAME
6086 CsrWifiSmeStationMacAddressGetCfm
6087
6088 DESCRIPTION
6089 This primitive reports the result of the request.
6090
6091 MEMBERS
6092 common - Common header for use with the CsrWifiFsm Module
6093 status - Reports the result of the request
6094 stationMacAddress - Current MAC address of the station.
6095
6096*******************************************************************************/
6097typedef struct
6098{
6099 CsrWifiFsmEvent common;
6100 CsrResult status;
6101 CsrWifiMacAddress stationMacAddress[2];
6102} CsrWifiSmeStationMacAddressGetCfm;
6103
6104/*******************************************************************************
6105
6106 NAME
6107 CsrWifiSmeTspecInd
6108
6109 DESCRIPTION
6110 The SME will send this primitive to all the task that have registered to
6111 receive it when a status change in the TSPEC occurs.
6112
6113 MEMBERS
6114 common - Common header for use with the CsrWifiFsm Module
6115 interfaceTag - Interface Identifier; unique identifier of an interface
6116 transactionId - Unique Transaction ID for the TSPEC, as assigned by the
6117 driver
6118 tspecResultCode - Specifies the TSPEC operation requested by the peer
6119 station
6120 tspecLength - Length of the TSPEC.
6121 tspec - Points to the first byte of the TSPEC
6122
6123*******************************************************************************/
6124typedef struct
6125{
6126 CsrWifiFsmEvent common;
6127 u16 interfaceTag;
6128 u32 transactionId;
6129 CsrWifiSmeTspecResultCode tspecResultCode;
6130 u16 tspecLength;
6131 u8 *tspec;
6132} CsrWifiSmeTspecInd;
6133
6134/*******************************************************************************
6135
6136 NAME
6137 CsrWifiSmeTspecCfm
6138
6139 DESCRIPTION
6140 The SME calls the primitive to report the result of the TSpec primitive
6141 request.
6142
6143 MEMBERS
6144 common - Common header for use with the CsrWifiFsm Module
6145 interfaceTag - Interface Identifier; unique identifier of an interface
6146 status - Reports the result of the request
6147 transactionId - Unique Transaction ID for the TSPEC, as assigned by the
6148 driver
6149 tspecResultCode - Specifies the result of the negotiated TSPEC operation
6150 tspecLength - Length of the TSPEC.
6151 tspec - Points to the first byte of the TSPEC
6152
6153*******************************************************************************/
6154typedef struct
6155{
6156 CsrWifiFsmEvent common;
6157 u16 interfaceTag;
6158 CsrResult status;
6159 u32 transactionId;
6160 CsrWifiSmeTspecResultCode tspecResultCode;
6161 u16 tspecLength;
6162 u8 *tspec;
6163} CsrWifiSmeTspecCfm;
6164
6165/*******************************************************************************
6166
6167 NAME
6168 CsrWifiSmeVersionsGetCfm
6169
6170 DESCRIPTION
6171 This primitive reports the result of the request.
6172
6173 MEMBERS
6174 common - Common header for use with the CsrWifiFsm Module
6175 status - Reports the result of the request
6176 versions - Version IDs of the product
6177
6178*******************************************************************************/
6179typedef struct
6180{
6181 CsrWifiFsmEvent common;
6182 CsrResult status;
6183 CsrWifiSmeVersions versions;
6184} CsrWifiSmeVersionsGetCfm;
6185
6186/*******************************************************************************
6187
6188 NAME
6189 CsrWifiSmeWifiFlightmodeCfm
6190
6191 DESCRIPTION
6192 The SME calls this primitive when the chip is initialised for low power
6193 mode and with the radio subsystem disabled. To leave flight mode, and
6194 enable Wi-Fi, the wireless manager application should call
6195 CSR_WIFI_SME_WIFI_ON_REQ.
6196
6197 MEMBERS
6198 common - Common header for use with the CsrWifiFsm Module
6199 status - Reports the result of the request
6200
6201*******************************************************************************/
6202typedef struct
6203{
6204 CsrWifiFsmEvent common;
6205 CsrResult status;
6206} CsrWifiSmeWifiFlightmodeCfm;
6207
6208/*******************************************************************************
6209
6210 NAME
6211 CsrWifiSmeWifiOffInd
6212
6213 DESCRIPTION
6214 The SME sends this primitive to all the tasks that have registered to
6215 receive it to report that the chip has been turned off.
6216
6217 MEMBERS
6218 common - Common header for use with the CsrWifiFsm Module
6219 reason - Indicates the reason why the Wi-Fi has been switched off.
6220
6221*******************************************************************************/
6222typedef struct
6223{
6224 CsrWifiFsmEvent common;
6225 CsrWifiSmeControlIndication reason;
6226} CsrWifiSmeWifiOffInd;
6227
6228/*******************************************************************************
6229
6230 NAME
6231 CsrWifiSmeWifiOffCfm
6232
6233 DESCRIPTION
6234 After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a
6235 network, the SME will perform a disconnect operation, will send a
6236 CSR_WIFI_SME_MEDIA_STATUS_IND with
6237 CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call
6238 CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off.
6239
6240 MEMBERS
6241 common - Common header for use with the CsrWifiFsm Module
6242 status - Reports the result of the request
6243
6244*******************************************************************************/
6245typedef struct
6246{
6247 CsrWifiFsmEvent common;
6248 CsrResult status;
6249} CsrWifiSmeWifiOffCfm;
6250
6251/*******************************************************************************
6252
6253 NAME
6254 CsrWifiSmeWifiOnCfm
6255
6256 DESCRIPTION
6257 The SME sends this primitive to the task that has sent the request once
6258 the chip has been initialised and is available for use.
6259
6260 MEMBERS
6261 common - Common header for use with the CsrWifiFsm Module
6262 status - Reports the result of the request
6263
6264*******************************************************************************/
6265typedef struct
6266{
6267 CsrWifiFsmEvent common;
6268 CsrResult status;
6269} CsrWifiSmeWifiOnCfm;
6270
6271/*******************************************************************************
6272
6273 NAME
6274 CsrWifiSmeCloakedSsidsSetCfm
6275
6276 DESCRIPTION
6277 This primitive reports the result of the request.
6278
6279 MEMBERS
6280 common - Common header for use with the CsrWifiFsm Module
6281 status - Reports the result of the request
6282
6283*******************************************************************************/
6284typedef struct
6285{
6286 CsrWifiFsmEvent common;
6287 CsrResult status;
6288} CsrWifiSmeCloakedSsidsSetCfm;
6289
6290/*******************************************************************************
6291
6292 NAME
6293 CsrWifiSmeCloakedSsidsGetCfm
6294
6295 DESCRIPTION
6296 This primitive reports the result of the request.
6297
6298 MEMBERS
6299 common - Common header for use with the CsrWifiFsm Module
6300 status - Reports the result of the request
6301 cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for
6302 by the driver
6303
6304*******************************************************************************/
6305typedef struct
6306{
6307 CsrWifiFsmEvent common;
6308 CsrResult status;
6309 CsrWifiSmeCloakedSsidConfig cloakedSsids;
6310} CsrWifiSmeCloakedSsidsGetCfm;
6311
6312/*******************************************************************************
6313
6314 NAME
6315 CsrWifiSmeWifiOnInd
6316
6317 DESCRIPTION
6318 The SME sends this primitive to all tasks that have registered to receive
6319 it once the chip becomes available and ready to use.
6320
6321 MEMBERS
6322 common - Common header for use with the CsrWifiFsm Module
6323 address - Current MAC address
6324
6325*******************************************************************************/
6326typedef struct
6327{
6328 CsrWifiFsmEvent common;
6329 CsrWifiMacAddress address;
6330} CsrWifiSmeWifiOnInd;
6331
6332/*******************************************************************************
6333
6334 NAME
6335 CsrWifiSmeSmeCommonConfigGetCfm
6336
6337 DESCRIPTION
6338 This primitive reports the result of the request.
6339
6340 MEMBERS
6341 common - Common header for use with the CsrWifiFsm Module
6342 status - Reports the result of the request
6343 deviceConfig - Configuration options in the SME
6344
6345*******************************************************************************/
6346typedef struct
6347{
6348 CsrWifiFsmEvent common;
6349 CsrResult status;
6350 CsrWifiSmeDeviceConfig deviceConfig;
6351} CsrWifiSmeSmeCommonConfigGetCfm;
6352
6353/*******************************************************************************
6354
6355 NAME
6356 CsrWifiSmeSmeCommonConfigSetCfm
6357
6358 DESCRIPTION
6359 Reports the result of the request
6360
6361 MEMBERS
6362 common - Common header for use with the CsrWifiFsm Module
6363 status - Reports the result of the request
6364
6365*******************************************************************************/
6366typedef struct
6367{
6368 CsrWifiFsmEvent common;
6369 CsrResult status;
6370} CsrWifiSmeSmeCommonConfigSetCfm;
6371
6372/*******************************************************************************
6373
6374 NAME
6375 CsrWifiSmeInterfaceCapabilityGetCfm
6376
6377 DESCRIPTION
6378 This primitive reports the result of the request.
6379
6380 MEMBERS
6381 common - Common header for use with the CsrWifiFsm Module
6382 status - Result of the request
6383 numInterfaces - Number of the interfaces supported
6384 capBitmap - Points to the list of capabilities bitmaps provided for each
6385 interface.
6386 The bits represent the following capabilities:
6387 -bits 7 to 4-Reserved
6388 -bit 3-AMP
6389 -bit 2-P2P
6390 -bit 1-AP
6391 -bit 0-STA
6392
6393*******************************************************************************/
6394typedef struct
6395{
6396 CsrWifiFsmEvent common;
6397 CsrResult status;
6398 u16 numInterfaces;
6399 u8 capBitmap[2];
6400} CsrWifiSmeInterfaceCapabilityGetCfm;
6401
6402/*******************************************************************************
6403
6404 NAME
6405 CsrWifiSmeErrorInd
6406
6407 DESCRIPTION
6408 Important error message indicating a error of some importance
6409
6410 MEMBERS
6411 common - Common header for use with the CsrWifiFsm Module
6412 errorMessage - Contains the error message.
6413
6414*******************************************************************************/
6415typedef struct
6416{
6417 CsrWifiFsmEvent common;
6418 char *errorMessage;
6419} CsrWifiSmeErrorInd;
6420
6421/*******************************************************************************
6422
6423 NAME
6424 CsrWifiSmeInfoInd
6425
6426 DESCRIPTION
6427 Message indicating a some info about current activity. Mostly of interest
6428 in testing but may be useful in the field.
6429
6430 MEMBERS
6431 common - Common header for use with the CsrWifiFsm Module
6432 infoMessage - Contains the message.
6433
6434*******************************************************************************/
6435typedef struct
6436{
6437 CsrWifiFsmEvent common;
6438 char *infoMessage;
6439} CsrWifiSmeInfoInd;
6440
6441/*******************************************************************************
6442
6443 NAME
6444 CsrWifiSmeCoreDumpInd
6445
6446 DESCRIPTION
6447 The SME will send this primitive to all the tasks that have registered to
6448 receive Wi-Fi Chip core dump data.
6449 The core dump data may be fragmented and sent using more than one
6450 indication.
6451 To indicate that all the data has been sent, the last indication contains
6452 a 'length' of 0 and 'data' of NULL.
6453
6454 MEMBERS
6455 common - Common header for use with the CsrWifiFsm Module
6456 dataLength - Number of bytes in the buffer pointed to by 'data'
6457 data - Pointer to the buffer containing 'dataLength' bytes of core
6458 dump data
6459
6460*******************************************************************************/
6461typedef struct
6462{
6463 CsrWifiFsmEvent common;
6464 u32 dataLength;
6465 u8 *data;
6466} CsrWifiSmeCoreDumpInd;
6467
6468/*******************************************************************************
6469
6470 NAME
6471 CsrWifiSmeAmpStatusChangeInd
6472
6473 DESCRIPTION
6474 Indication of change to AMP activity.
6475
6476 MEMBERS
6477 common - Common header for use with the CsrWifiFsm Module
6478 interfaceTag - Interface on which the AMP activity changed.
6479 ampStatus - The new status of AMP activity.Range: {AMP_ACTIVE,
6480 AMP_INACTIVE}.
6481
6482*******************************************************************************/
6483typedef struct
6484{
6485 CsrWifiFsmEvent common;
6486 u16 interfaceTag;
6487 CsrWifiSmeAmpStatus ampStatus;
6488} CsrWifiSmeAmpStatusChangeInd;
6489
6490/*******************************************************************************
6491
6492 NAME
6493 CsrWifiSmeWpsConfigurationCfm
6494
6495 DESCRIPTION
6496 Confirm.
6497
6498 MEMBERS
6499 common - Common header for use with the CsrWifiFsm Module
6500 status - Status of the request.
6501
6502*******************************************************************************/
6503typedef struct
6504{
6505 CsrWifiFsmEvent common;
6506 CsrResult status;
6507} CsrWifiSmeWpsConfigurationCfm;
6508
6509#endif /* CSR_WIFI_SME_PRIM_H__ */
6510
diff --git a/drivers/staging/csr/csr_wifi_sme_sef.c b/drivers/staging/csr/csr_wifi_sme_sef.c
deleted file mode 100644
index cf32254335c4..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_sef.c
+++ /dev/null
@@ -1,85 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 Confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9 *****************************************************************************/
10#include "csr_wifi_sme_sef.h"
11
12const CsrWifiSmeStateHandlerType CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT] =
13{
14 /* 0x8000 */ CsrWifiSmeActivateCfmHandler,
15 /* 0x8001 */ CsrWifiSmeAdhocConfigGetCfmHandler,
16 /* 0x8002 */ CsrWifiSmeAdhocConfigSetCfmHandler,
17 /* 0x8003 */ CsrWifiSmeAssociationCompleteIndHandler,
18 /* 0x8004 */ CsrWifiSmeAssociationStartIndHandler,
19 /* 0x8005 */ CsrWifiSmeBlacklistCfmHandler,
20 /* 0x8006 */ CsrWifiSmeCalibrationDataGetCfmHandler,
21 /* 0x8007 */ CsrWifiSmeCalibrationDataSetCfmHandler,
22 /* 0x8008 */ CsrWifiSmeCcxConfigGetCfmHandler,
23 /* 0x8009 */ CsrWifiSmeCcxConfigSetCfmHandler,
24 /* 0x800A */ CsrWifiSmeCoexConfigGetCfmHandler,
25 /* 0x800B */ CsrWifiSmeCoexConfigSetCfmHandler,
26 /* 0x800C */ CsrWifiSmeCoexInfoGetCfmHandler,
27 /* 0x800D */ CsrWifiSmeConnectCfmHandler,
28 /* 0x800E */ CsrWifiSmeConnectionConfigGetCfmHandler,
29 /* 0x800F */ CsrWifiSmeConnectionInfoGetCfmHandler,
30 /* 0x8010 */ CsrWifiSmeConnectionQualityIndHandler,
31 /* 0x8011 */ CsrWifiSmeConnectionStatsGetCfmHandler,
32 /* 0x8012 */ CsrWifiSmeDeactivateCfmHandler,
33 /* 0x8013 */ CsrWifiSmeDisconnectCfmHandler,
34 /* 0x8014 */ CsrWifiSmeEventMaskSetCfmHandler,
35 /* 0x8015 */ CsrWifiSmeHostConfigGetCfmHandler,
36 /* 0x8016 */ CsrWifiSmeHostConfigSetCfmHandler,
37 /* 0x8017 */ CsrWifiSmeIbssStationIndHandler,
38 /* 0x8018 */ CsrWifiSmeKeyCfmHandler,
39 /* 0x8019 */ CsrWifiSmeLinkQualityGetCfmHandler,
40 /* 0x801A */ CsrWifiSmeMediaStatusIndHandler,
41 /* 0x801B */ CsrWifiSmeMibConfigGetCfmHandler,
42 /* 0x801C */ CsrWifiSmeMibConfigSetCfmHandler,
43 /* 0x801D */ CsrWifiSmeMibGetCfmHandler,
44 /* 0x801E */ CsrWifiSmeMibGetNextCfmHandler,
45 /* 0x801F */ CsrWifiSmeMibSetCfmHandler,
46 /* 0x8020 */ CsrWifiSmeMicFailureIndHandler,
47 /* 0x8021 */ CsrWifiSmeMulticastAddressCfmHandler,
48 /* 0x8022 */ CsrWifiSmePacketFilterSetCfmHandler,
49 /* 0x8023 */ CsrWifiSmePermanentMacAddressGetCfmHandler,
50 /* 0x8024 */ CsrWifiSmePmkidCandidateListIndHandler,
51 /* 0x8025 */ CsrWifiSmePmkidCfmHandler,
52 /* 0x8026 */ CsrWifiSmePowerConfigGetCfmHandler,
53 /* 0x8027 */ CsrWifiSmePowerConfigSetCfmHandler,
54 /* 0x8028 */ CsrWifiSmeRegulatoryDomainInfoGetCfmHandler,
55 /* 0x8029 */ CsrWifiSmeRoamCompleteIndHandler,
56 /* 0x802A */ CsrWifiSmeRoamStartIndHandler,
57 /* 0x802B */ CsrWifiSmeRoamingConfigGetCfmHandler,
58 /* 0x802C */ CsrWifiSmeRoamingConfigSetCfmHandler,
59 /* 0x802D */ CsrWifiSmeScanConfigGetCfmHandler,
60 /* 0x802E */ CsrWifiSmeScanConfigSetCfmHandler,
61 /* 0x802F */ CsrWifiSmeScanFullCfmHandler,
62 /* 0x8030 */ CsrWifiSmeScanResultIndHandler,
63 /* 0x8031 */ CsrWifiSmeScanResultsFlushCfmHandler,
64 /* 0x8032 */ CsrWifiSmeScanResultsGetCfmHandler,
65 /* 0x8033 */ CsrWifiSmeSmeStaConfigGetCfmHandler,
66 /* 0x8034 */ CsrWifiSmeSmeStaConfigSetCfmHandler,
67 /* 0x8035 */ CsrWifiSmeStationMacAddressGetCfmHandler,
68 /* 0x8036 */ CsrWifiSmeTspecIndHandler,
69 /* 0x8037 */ CsrWifiSmeTspecCfmHandler,
70 /* 0x8038 */ CsrWifiSmeVersionsGetCfmHandler,
71 /* 0x8039 */ CsrWifiSmeWifiFlightmodeCfmHandler,
72 /* 0x803A */ CsrWifiSmeWifiOffIndHandler,
73 /* 0x803B */ CsrWifiSmeWifiOffCfmHandler,
74 /* 0x803C */ CsrWifiSmeWifiOnCfmHandler,
75 /* 0x803D */ CsrWifiSmeCloakedSsidsSetCfmHandler,
76 /* 0x803E */ CsrWifiSmeCloakedSsidsGetCfmHandler,
77 /* 0x803F */ CsrWifiSmeWifiOnIndHandler,
78 /* 0x8040 */ CsrWifiSmeSmeCommonConfigGetCfmHandler,
79 /* 0x8041 */ CsrWifiSmeSmeCommonConfigSetCfmHandler,
80 /* 0x8042 */ CsrWifiSmeGetInterfaceCapabilityCfmHandler,
81 /* 0x8043 */ CsrWifiSmeErrorIndHandler,
82 /* 0x8044 */ CsrWifiSmeInfoIndHandler,
83 /* 0x8045 */ CsrWifiSmeCoreDumpIndHandler,
84 /* 0x8046 */ CsrWifiSmeAmpStatusChangeIndHandler,
85};
diff --git a/drivers/staging/csr/csr_wifi_sme_sef.h b/drivers/staging/csr/csr_wifi_sme_sef.h
deleted file mode 100644
index 78b88c067236..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_sef.h
+++ /dev/null
@@ -1,142 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 Confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__
11#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__
12
13#include "csr_wifi_sme_prim.h"
14
15typedef void (*CsrWifiSmeStateHandlerType)(void *drvpriv, CsrWifiFsmEvent *msg);
16
17extern const CsrWifiSmeStateHandlerType
18 CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT];
19
20
21extern void CsrWifiSmeActivateCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
22extern void CsrWifiSmeAdhocConfigGetCfmHandler(void *drvpriv,
23 CsrWifiFsmEvent *msg);
24extern void CsrWifiSmeAdhocConfigSetCfmHandler(void *drvpriv,
25 CsrWifiFsmEvent *msg);
26extern void CsrWifiSmeAssociationCompleteIndHandler(void *drvpriv,
27 CsrWifiFsmEvent *msg);
28extern void CsrWifiSmeAssociationStartIndHandler(void *drvpriv,
29 CsrWifiFsmEvent *msg);
30extern void CsrWifiSmeBlacklistCfmHandler(void *drvpriv,
31 CsrWifiFsmEvent *msg);
32extern void CsrWifiSmeCalibrationDataGetCfmHandler(void *drvpriv,
33 CsrWifiFsmEvent *msg);
34extern void CsrWifiSmeCalibrationDataSetCfmHandler(void *drvpriv,
35 CsrWifiFsmEvent *msg);
36extern void CsrWifiSmeCcxConfigGetCfmHandler(void *drvpriv,
37 CsrWifiFsmEvent *msg);
38extern void CsrWifiSmeCcxConfigSetCfmHandler(void *drvpriv,
39 CsrWifiFsmEvent *msg);
40extern void CsrWifiSmeCoexConfigGetCfmHandler(void *drvpriv,
41 CsrWifiFsmEvent *msg);
42extern void CsrWifiSmeCoexConfigSetCfmHandler(void *drvpriv,
43 CsrWifiFsmEvent *msg);
44extern void CsrWifiSmeCoexInfoGetCfmHandler(void *drvpriv,
45 CsrWifiFsmEvent *msg);
46extern void CsrWifiSmeConnectCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
47extern void CsrWifiSmeConnectionConfigGetCfmHandler(void *drvpriv,
48 CsrWifiFsmEvent *msg);
49extern void CsrWifiSmeConnectionInfoGetCfmHandler(void *drvpriv,
50 CsrWifiFsmEvent *msg);
51extern void CsrWifiSmeConnectionQualityIndHandler(void *drvpriv,
52 CsrWifiFsmEvent *msg);
53extern void CsrWifiSmeConnectionStatsGetCfmHandler(void *drvpriv,
54 CsrWifiFsmEvent *msg);
55extern void CsrWifiSmeDeactivateCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
56extern void CsrWifiSmeDisconnectCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
57extern void CsrWifiSmeEventMaskSetCfmHandler(void *drvpriv,
58 CsrWifiFsmEvent *msg);
59extern void CsrWifiSmeHostConfigGetCfmHandler(void *drvpriv,
60 CsrWifiFsmEvent *msg);
61extern void CsrWifiSmeHostConfigSetCfmHandler(void *drvpriv,
62 CsrWifiFsmEvent *msg);
63extern void CsrWifiSmeIbssStationIndHandler(void *drvpriv,
64 CsrWifiFsmEvent *msg);
65extern void CsrWifiSmeKeyCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
66extern void CsrWifiSmeLinkQualityGetCfmHandler(void *drvpriv,
67 CsrWifiFsmEvent *msg);
68extern void CsrWifiSmeMediaStatusIndHandler(void *drvpriv,
69 CsrWifiFsmEvent *msg);
70extern void CsrWifiSmeMibConfigGetCfmHandler(void *drvpriv,
71 CsrWifiFsmEvent *msg);
72extern void CsrWifiSmeMibConfigSetCfmHandler(void *drvpriv,
73 CsrWifiFsmEvent *msg);
74extern void CsrWifiSmeMibGetCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
75extern void CsrWifiSmeMibGetNextCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
76extern void CsrWifiSmeMibSetCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
77extern void CsrWifiSmeMicFailureIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
78extern void CsrWifiSmeMulticastAddressCfmHandler(void *drvpriv,
79 CsrWifiFsmEvent *msg);
80extern void CsrWifiSmePacketFilterSetCfmHandler(void *drvpriv,
81 CsrWifiFsmEvent *msg);
82extern void CsrWifiSmePermanentMacAddressGetCfmHandler(void *drvpriv,
83 CsrWifiFsmEvent *msg);
84extern void CsrWifiSmePmkidCandidateListIndHandler(void *drvpriv,
85 CsrWifiFsmEvent *msg);
86extern void CsrWifiSmePmkidCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
87extern void CsrWifiSmePowerConfigGetCfmHandler(void *drvpriv,
88 CsrWifiFsmEvent *msg);
89extern void CsrWifiSmePowerConfigSetCfmHandler(void *drvpriv,
90 CsrWifiFsmEvent *msg);
91extern void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void *drvpriv,
92 CsrWifiFsmEvent *msg);
93extern void CsrWifiSmeRoamCompleteIndHandler(void *drvpriv,
94 CsrWifiFsmEvent *msg);
95extern void CsrWifiSmeRoamStartIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
96extern void CsrWifiSmeRoamingConfigGetCfmHandler(void *drvpriv,
97 CsrWifiFsmEvent *msg);
98extern void CsrWifiSmeRoamingConfigSetCfmHandler(void *drvpriv,
99 CsrWifiFsmEvent *msg);
100extern void CsrWifiSmeScanConfigGetCfmHandler(void *drvpriv,
101 CsrWifiFsmEvent *msg);
102extern void CsrWifiSmeScanConfigSetCfmHandler(void *drvpriv,
103 CsrWifiFsmEvent *msg);
104extern void CsrWifiSmeScanFullCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
105extern void CsrWifiSmeScanResultIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
106extern void CsrWifiSmeScanResultsFlushCfmHandler(void *drvpriv,
107 CsrWifiFsmEvent *msg);
108extern void CsrWifiSmeScanResultsGetCfmHandler(void *drvpriv,
109 CsrWifiFsmEvent *msg);
110extern void CsrWifiSmeSmeStaConfigGetCfmHandler(void *drvpriv,
111 CsrWifiFsmEvent *msg);
112extern void CsrWifiSmeSmeStaConfigSetCfmHandler(void *drvpriv,
113 CsrWifiFsmEvent *msg);
114extern void CsrWifiSmeStationMacAddressGetCfmHandler(void *drvpriv,
115 CsrWifiFsmEvent *msg);
116extern void CsrWifiSmeTspecIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
117extern void CsrWifiSmeTspecCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
118extern void CsrWifiSmeVersionsGetCfmHandler(void *drvpriv,
119 CsrWifiFsmEvent *msg);
120extern void CsrWifiSmeWifiFlightmodeCfmHandler(void *drvpriv,
121 CsrWifiFsmEvent *msg);
122extern void CsrWifiSmeWifiOffIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
123extern void CsrWifiSmeWifiOffCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
124extern void CsrWifiSmeWifiOnCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
125extern void CsrWifiSmeCloakedSsidsSetCfmHandler(void *drvpriv,
126 CsrWifiFsmEvent *msg);
127extern void CsrWifiSmeCloakedSsidsGetCfmHandler(void *drvpriv,
128 CsrWifiFsmEvent *msg);
129extern void CsrWifiSmeWifiOnIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
130extern void CsrWifiSmeSmeCommonConfigGetCfmHandler(void *drvpriv,
131 CsrWifiFsmEvent *msg);
132extern void CsrWifiSmeSmeCommonConfigSetCfmHandler(void *drvpriv,
133 CsrWifiFsmEvent *msg);
134extern void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void *drvpriv,
135 CsrWifiFsmEvent *msg);
136extern void CsrWifiSmeErrorIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
137extern void CsrWifiSmeInfoIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
138extern void CsrWifiSmeCoreDumpIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
139extern void CsrWifiSmeAmpStatusChangeIndHandler(void *drvpriv,
140 CsrWifiFsmEvent *msg);
141
142#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
index 7d7e1d8b5ed3..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_serialize.c
+++ /dev/null
@@ -1,5809 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12#include <linux/string.h>
13#include <linux/slab.h>
14#include "csr_msgconv.h"
15#include "csr_wifi_sme_prim.h"
16#include "csr_wifi_sme_serialize.h"
17
18void CsrWifiSmePfree(void *ptr)
19{
20 kfree(ptr);
21}
22
23
24size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg)
25{
26 size_t bufferSize = 2;
27
28 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
29 bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */
30 bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */
31 bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */
32 bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */
33 return bufferSize;
34}
35
36
37u8* CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
38{
39 CsrWifiSmeAdhocConfigSetReq *primitive = (CsrWifiSmeAdhocConfigSetReq *)msg;
40 *len = 0;
41 CsrUint16Ser(ptr, len, primitive->common.type);
42 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu);
43 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu);
44 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts);
45 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs);
46 return(ptr);
47}
48
49
50void* CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t length)
51{
52 CsrWifiSmeAdhocConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL);
53 size_t offset;
54 offset = 0;
55
56 CsrUint16Des(&primitive->common.type, buffer, &offset);
57 CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset);
58 CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset);
59 CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset);
60 CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset);
61
62 return primitive;
63}
64
65
66size_t CsrWifiSmeBlacklistReqSizeof(void *msg)
67{
68 CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) msg;
69 size_t bufferSize = 2;
70
71 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
72 bufferSize += 2; /* u16 primitive->interfaceTag */
73 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
74 bufferSize += 1; /* u8 primitive->setAddressCount */
75 {
76 u16 i1;
77 for (i1 = 0; i1 < primitive->setAddressCount; i1++)
78 {
79 bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
80 }
81 }
82 return bufferSize;
83}
84
85
86u8* CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg)
87{
88 CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *)msg;
89 *len = 0;
90 CsrUint16Ser(ptr, len, primitive->common.type);
91 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
92 CsrUint8Ser(ptr, len, (u8) primitive->action);
93 CsrUint8Ser(ptr, len, (u8) primitive->setAddressCount);
94 {
95 u16 i1;
96 for (i1 = 0; i1 < primitive->setAddressCount; i1++)
97 {
98 CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
99 }
100 }
101 return(ptr);
102}
103
104
105void* CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t length)
106{
107 CsrWifiSmeBlacklistReq *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL);
108 size_t offset;
109 offset = 0;
110
111 CsrUint16Des(&primitive->common.type, buffer, &offset);
112 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
113 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
114 CsrUint8Des((u8 *) &primitive->setAddressCount, buffer, &offset);
115 primitive->setAddresses = NULL;
116 if (primitive->setAddressCount)
117 {
118 primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressCount, GFP_KERNEL);
119 }
120 {
121 u16 i1;
122 for (i1 = 0; i1 < primitive->setAddressCount; i1++)
123 {
124 CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
125 }
126 }
127
128 return primitive;
129}
130
131
132void CsrWifiSmeBlacklistReqSerFree(void *voidPrimitivePointer)
133{
134 CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) voidPrimitivePointer;
135 kfree(primitive->setAddresses);
136 kfree(primitive);
137}
138
139
140size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg)
141{
142 CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) msg;
143 size_t bufferSize = 2;
144
145 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
146 bufferSize += 2; /* u16 primitive->calibrationDataLength */
147 bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */
148 return bufferSize;
149}
150
151
152u8* CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg)
153{
154 CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *)msg;
155 *len = 0;
156 CsrUint16Ser(ptr, len, primitive->common.type);
157 CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength);
158 if (primitive->calibrationDataLength)
159 {
160 CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength)));
161 }
162 return(ptr);
163}
164
165
166void* CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t length)
167{
168 CsrWifiSmeCalibrationDataSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL);
169 size_t offset;
170 offset = 0;
171
172 CsrUint16Des(&primitive->common.type, buffer, &offset);
173 CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset);
174 if (primitive->calibrationDataLength)
175 {
176 primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL);
177 CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength)));
178 }
179 else
180 {
181 primitive->calibrationData = NULL;
182 }
183
184 return primitive;
185}
186
187
188void CsrWifiSmeCalibrationDataSetReqSerFree(void *voidPrimitivePointer)
189{
190 CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) voidPrimitivePointer;
191 kfree(primitive->calibrationData);
192 kfree(primitive);
193}
194
195
196size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg)
197{
198 size_t bufferSize = 2;
199
200 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
201 bufferSize += 2; /* u16 primitive->interfaceTag */
202 bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */
203 bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */
204 bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */
205 bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */
206 return bufferSize;
207}
208
209
210u8* CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
211{
212 CsrWifiSmeCcxConfigSetReq *primitive = (CsrWifiSmeCcxConfigSetReq *)msg;
213 *len = 0;
214 CsrUint16Ser(ptr, len, primitive->common.type);
215 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
216 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs);
217 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled);
218 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask);
219 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled);
220 return(ptr);
221}
222
223
224void* CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t length)
225{
226 CsrWifiSmeCcxConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL);
227 size_t offset;
228 offset = 0;
229
230 CsrUint16Des(&primitive->common.type, buffer, &offset);
231 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
232 CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset);
233 CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset);
234 CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset);
235 CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset);
236
237 return primitive;
238}
239
240
241size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg)
242{
243 size_t bufferSize = 2;
244
245 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */
246 bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */
247 bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */
248 bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */
249 bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */
250 bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */
251 bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */
252 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */
253 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */
254 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */
255 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */
256 bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */
257 bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */
258 bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */
259 bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */
260 return bufferSize;
261}
262
263
264u8* CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
265{
266 CsrWifiSmeCoexConfigSetReq *primitive = (CsrWifiSmeCoexConfigSetReq *)msg;
267 *len = 0;
268 CsrUint16Ser(ptr, len, primitive->common.type);
269 CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement);
270 CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost);
271 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs);
272 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs);
273 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs);
274 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs);
275 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs);
276 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs);
277 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs);
278 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs);
279 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs);
280 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs);
281 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs);
282 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs);
283 return(ptr);
284}
285
286
287void* CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t length)
288{
289 CsrWifiSmeCoexConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL);
290 size_t offset;
291 offset = 0;
292
293 CsrUint16Des(&primitive->common.type, buffer, &offset);
294 CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset);
295 CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset);
296 CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset);
297 CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset);
298 CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset);
299 CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset);
300 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset);
301 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset);
302 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset);
303 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset);
304 CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset);
305 CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset);
306 CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset);
307 CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset);
308
309 return primitive;
310}
311
312
313size_t CsrWifiSmeConnectReqSizeof(void *msg)
314{
315 CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) msg;
316 size_t bufferSize = 2;
317
318 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 57) */
319 bufferSize += 2; /* u16 primitive->interfaceTag */
320 bufferSize += 32; /* u8 primitive->connectionConfig.ssid.ssid[32] */
321 bufferSize += 1; /* u8 primitive->connectionConfig.ssid.length */
322 bufferSize += 6; /* u8 primitive->connectionConfig.bssid.a[6] */
323 bufferSize += 1; /* CsrWifiSmeBssType primitive->connectionConfig.bssType */
324 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */
325 bufferSize += 1; /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */
326 bufferSize += 2; /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */
327 bufferSize += 2; /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */
328 bufferSize += 2; /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */
329 bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */
330 bufferSize += 1; /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */
331 bufferSize += 1; /* u8 primitive->connectionConfig.adhocJoinOnly */
332 bufferSize += 1; /* u8 primitive->connectionConfig.adhocChannel */
333 return bufferSize;
334}
335
336
337u8* CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg)
338{
339 CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *)msg;
340 *len = 0;
341 CsrUint16Ser(ptr, len, primitive->common.type);
342 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
343 CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32)));
344 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length);
345 CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6)));
346 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType);
347 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex);
348 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode);
349 CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask);
350 CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask);
351 CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength);
352 if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
353 {
354 CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
355 }
356 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo);
357 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly);
358 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel);
359 return(ptr);
360}
361
362
363void* CsrWifiSmeConnectReqDes(u8 *buffer, size_t length)
364{
365 CsrWifiSmeConnectReq *primitive = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL);
366 size_t offset;
367 offset = 0;
368
369 CsrUint16Des(&primitive->common.type, buffer, &offset);
370 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
371 CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32)));
372 CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset);
373 CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6)));
374 CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset);
375 CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset);
376 CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset);
377 CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset);
378 CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset);
379 CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset);
380 if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
381 {
382 primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL);
383 CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
384 }
385 else
386 {
387 primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL;
388 }
389 CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset);
390 CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset);
391 CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset);
392
393 return primitive;
394}
395
396
397void CsrWifiSmeConnectReqSerFree(void *voidPrimitivePointer)
398{
399 CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) voidPrimitivePointer;
400 kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements);
401 kfree(primitive);
402}
403
404
405size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg)
406{
407 size_t bufferSize = 2;
408
409 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
410 bufferSize += 2; /* u16 primitive->interfaceTag */
411 bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */
412 bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */
413 return bufferSize;
414}
415
416
417u8* CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
418{
419 CsrWifiSmeHostConfigSetReq *primitive = (CsrWifiSmeHostConfigSetReq *)msg;
420 *len = 0;
421 CsrUint16Ser(ptr, len, primitive->common.type);
422 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
423 CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode);
424 CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs);
425 return(ptr);
426}
427
428
429void* CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t length)
430{
431 CsrWifiSmeHostConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL);
432 size_t offset;
433 offset = 0;
434
435 CsrUint16Des(&primitive->common.type, buffer, &offset);
436 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
437 CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset);
438 CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset);
439
440 return primitive;
441}
442
443
444size_t CsrWifiSmeKeyReqSizeof(void *msg)
445{
446 size_t bufferSize = 2;
447
448 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */
449 bufferSize += 2; /* u16 primitive->interfaceTag */
450 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
451 bufferSize += 1; /* CsrWifiSmeKeyType primitive->key.keyType */
452 bufferSize += 1; /* u8 primitive->key.keyIndex */
453 bufferSize += 1; /* u8 primitive->key.wepTxKey */
454 {
455 u16 i2;
456 for (i2 = 0; i2 < 8; i2++)
457 {
458 bufferSize += 2; /* u16 primitive->key.keyRsc[8] */
459 }
460 }
461 bufferSize += 1; /* u8 primitive->key.authenticator */
462 bufferSize += 6; /* u8 primitive->key.address.a[6] */
463 bufferSize += 1; /* u8 primitive->key.keyLength */
464 bufferSize += 32; /* u8 primitive->key.key[32] */
465 return bufferSize;
466}
467
468
469u8* CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg)
470{
471 CsrWifiSmeKeyReq *primitive = (CsrWifiSmeKeyReq *)msg;
472 *len = 0;
473 CsrUint16Ser(ptr, len, primitive->common.type);
474 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
475 CsrUint8Ser(ptr, len, (u8) primitive->action);
476 CsrUint8Ser(ptr, len, (u8) primitive->key.keyType);
477 CsrUint8Ser(ptr, len, (u8) primitive->key.keyIndex);
478 CsrUint8Ser(ptr, len, (u8) primitive->key.wepTxKey);
479 {
480 u16 i2;
481 for (i2 = 0; i2 < 8; i2++)
482 {
483 CsrUint16Ser(ptr, len, (u16) primitive->key.keyRsc[i2]);
484 }
485 }
486 CsrUint8Ser(ptr, len, (u8) primitive->key.authenticator);
487 CsrMemCpySer(ptr, len, (const void *) primitive->key.address.a, ((u16) (6)));
488 CsrUint8Ser(ptr, len, (u8) primitive->key.keyLength);
489 CsrMemCpySer(ptr, len, (const void *) primitive->key.key, ((u16) (32)));
490 return(ptr);
491}
492
493
494void* CsrWifiSmeKeyReqDes(u8 *buffer, size_t length)
495{
496 CsrWifiSmeKeyReq *primitive = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL);
497 size_t offset;
498 offset = 0;
499
500 CsrUint16Des(&primitive->common.type, buffer, &offset);
501 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
502 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
503 CsrUint8Des((u8 *) &primitive->key.keyType, buffer, &offset);
504 CsrUint8Des((u8 *) &primitive->key.keyIndex, buffer, &offset);
505 CsrUint8Des((u8 *) &primitive->key.wepTxKey, buffer, &offset);
506 {
507 u16 i2;
508 for (i2 = 0; i2 < 8; i2++)
509 {
510 CsrUint16Des((u16 *) &primitive->key.keyRsc[i2], buffer, &offset);
511 }
512 }
513 CsrUint8Des((u8 *) &primitive->key.authenticator, buffer, &offset);
514 CsrMemCpyDes(primitive->key.address.a, buffer, &offset, ((u16) (6)));
515 CsrUint8Des((u8 *) &primitive->key.keyLength, buffer, &offset);
516 CsrMemCpyDes(primitive->key.key, buffer, &offset, ((u16) (32)));
517
518 return primitive;
519}
520
521
522size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg)
523{
524 size_t bufferSize = 2;
525
526 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
527 bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */
528 bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */
529 bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */
530 bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */
531 bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */
532 return bufferSize;
533}
534
535
536u8* CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
537{
538 CsrWifiSmeMibConfigSetReq *primitive = (CsrWifiSmeMibConfigSetReq *)msg;
539 *len = 0;
540 CsrUint16Ser(ptr, len, primitive->common.type);
541 CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate);
542 CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate);
543 CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold);
544 CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold);
545 CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel);
546 return(ptr);
547}
548
549
550void* CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t length)
551{
552 CsrWifiSmeMibConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL);
553 size_t offset;
554 offset = 0;
555
556 CsrUint16Des(&primitive->common.type, buffer, &offset);
557 CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset);
558 CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset);
559 CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset);
560 CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset);
561 CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset);
562
563 return primitive;
564}
565
566
567size_t CsrWifiSmeMibGetNextReqSizeof(void *msg)
568{
569 CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) msg;
570 size_t bufferSize = 2;
571
572 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
573 bufferSize += 2; /* u16 primitive->mibAttributeLength */
574 bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
575 return bufferSize;
576}
577
578
579u8* CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg)
580{
581 CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *)msg;
582 *len = 0;
583 CsrUint16Ser(ptr, len, primitive->common.type);
584 CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
585 if (primitive->mibAttributeLength)
586 {
587 CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
588 }
589 return(ptr);
590}
591
592
593void* CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t length)
594{
595 CsrWifiSmeMibGetNextReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL);
596 size_t offset;
597 offset = 0;
598
599 CsrUint16Des(&primitive->common.type, buffer, &offset);
600 CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
601 if (primitive->mibAttributeLength)
602 {
603 primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
604 CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
605 }
606 else
607 {
608 primitive->mibAttribute = NULL;
609 }
610
611 return primitive;
612}
613
614
615void CsrWifiSmeMibGetNextReqSerFree(void *voidPrimitivePointer)
616{
617 CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) voidPrimitivePointer;
618 kfree(primitive->mibAttribute);
619 kfree(primitive);
620}
621
622
623size_t CsrWifiSmeMibGetReqSizeof(void *msg)
624{
625 CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) msg;
626 size_t bufferSize = 2;
627
628 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
629 bufferSize += 2; /* u16 primitive->mibAttributeLength */
630 bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
631 return bufferSize;
632}
633
634
635u8* CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg)
636{
637 CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *)msg;
638 *len = 0;
639 CsrUint16Ser(ptr, len, primitive->common.type);
640 CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
641 if (primitive->mibAttributeLength)
642 {
643 CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
644 }
645 return(ptr);
646}
647
648
649void* CsrWifiSmeMibGetReqDes(u8 *buffer, size_t length)
650{
651 CsrWifiSmeMibGetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL);
652 size_t offset;
653 offset = 0;
654
655 CsrUint16Des(&primitive->common.type, buffer, &offset);
656 CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
657 if (primitive->mibAttributeLength)
658 {
659 primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
660 CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
661 }
662 else
663 {
664 primitive->mibAttribute = NULL;
665 }
666
667 return primitive;
668}
669
670
671void CsrWifiSmeMibGetReqSerFree(void *voidPrimitivePointer)
672{
673 CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) voidPrimitivePointer;
674 kfree(primitive->mibAttribute);
675 kfree(primitive);
676}
677
678
679size_t CsrWifiSmeMibSetReqSizeof(void *msg)
680{
681 CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) msg;
682 size_t bufferSize = 2;
683
684 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
685 bufferSize += 2; /* u16 primitive->mibAttributeLength */
686 bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
687 return bufferSize;
688}
689
690
691u8* CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg)
692{
693 CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *)msg;
694 *len = 0;
695 CsrUint16Ser(ptr, len, primitive->common.type);
696 CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
697 if (primitive->mibAttributeLength)
698 {
699 CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
700 }
701 return(ptr);
702}
703
704
705void* CsrWifiSmeMibSetReqDes(u8 *buffer, size_t length)
706{
707 CsrWifiSmeMibSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL);
708 size_t offset;
709 offset = 0;
710
711 CsrUint16Des(&primitive->common.type, buffer, &offset);
712 CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
713 if (primitive->mibAttributeLength)
714 {
715 primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
716 CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
717 }
718 else
719 {
720 primitive->mibAttribute = NULL;
721 }
722
723 return primitive;
724}
725
726
727void CsrWifiSmeMibSetReqSerFree(void *voidPrimitivePointer)
728{
729 CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) voidPrimitivePointer;
730 kfree(primitive->mibAttribute);
731 kfree(primitive);
732}
733
734
735size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg)
736{
737 CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) msg;
738 size_t bufferSize = 2;
739
740 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
741 bufferSize += 2; /* u16 primitive->interfaceTag */
742 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
743 bufferSize += 1; /* u8 primitive->setAddressesCount */
744 {
745 u16 i1;
746 for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
747 {
748 bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
749 }
750 }
751 return bufferSize;
752}
753
754
755u8* CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg)
756{
757 CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *)msg;
758 *len = 0;
759 CsrUint16Ser(ptr, len, primitive->common.type);
760 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
761 CsrUint8Ser(ptr, len, (u8) primitive->action);
762 CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount);
763 {
764 u16 i1;
765 for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
766 {
767 CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
768 }
769 }
770 return(ptr);
771}
772
773
774void* CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t length)
775{
776 CsrWifiSmeMulticastAddressReq *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL);
777 size_t offset;
778 offset = 0;
779
780 CsrUint16Des(&primitive->common.type, buffer, &offset);
781 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
782 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
783 CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset);
784 primitive->setAddresses = NULL;
785 if (primitive->setAddressesCount)
786 {
787 primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL);
788 }
789 {
790 u16 i1;
791 for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
792 {
793 CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
794 }
795 }
796
797 return primitive;
798}
799
800
801void CsrWifiSmeMulticastAddressReqSerFree(void *voidPrimitivePointer)
802{
803 CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) voidPrimitivePointer;
804 kfree(primitive->setAddresses);
805 kfree(primitive);
806}
807
808
809size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg)
810{
811 CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) msg;
812 size_t bufferSize = 2;
813
814 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
815 bufferSize += 2; /* u16 primitive->interfaceTag */
816 bufferSize += 2; /* u16 primitive->filterLength */
817 bufferSize += primitive->filterLength; /* u8 primitive->filter */
818 bufferSize += 1; /* CsrWifiSmePacketFilterMode primitive->mode */
819 bufferSize += 4; /* u8 primitive->arpFilterAddress.a[4] */
820 return bufferSize;
821}
822
823
824u8* CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg)
825{
826 CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *)msg;
827 *len = 0;
828 CsrUint16Ser(ptr, len, primitive->common.type);
829 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
830 CsrUint16Ser(ptr, len, (u16) primitive->filterLength);
831 if (primitive->filterLength)
832 {
833 CsrMemCpySer(ptr, len, (const void *) primitive->filter, ((u16) (primitive->filterLength)));
834 }
835 CsrUint8Ser(ptr, len, (u8) primitive->mode);
836 CsrMemCpySer(ptr, len, (const void *) primitive->arpFilterAddress.a, ((u16) (4)));
837 return(ptr);
838}
839
840
841void* CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t length)
842{
843 CsrWifiSmePacketFilterSetReq *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL);
844 size_t offset;
845 offset = 0;
846
847 CsrUint16Des(&primitive->common.type, buffer, &offset);
848 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
849 CsrUint16Des((u16 *) &primitive->filterLength, buffer, &offset);
850 if (primitive->filterLength)
851 {
852 primitive->filter = kmalloc(primitive->filterLength, GFP_KERNEL);
853 CsrMemCpyDes(primitive->filter, buffer, &offset, ((u16) (primitive->filterLength)));
854 }
855 else
856 {
857 primitive->filter = NULL;
858 }
859 CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
860 CsrMemCpyDes(primitive->arpFilterAddress.a, buffer, &offset, ((u16) (4)));
861
862 return primitive;
863}
864
865
866void CsrWifiSmePacketFilterSetReqSerFree(void *voidPrimitivePointer)
867{
868 CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) voidPrimitivePointer;
869 kfree(primitive->filter);
870 kfree(primitive);
871}
872
873
874size_t CsrWifiSmePmkidReqSizeof(void *msg)
875{
876 CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) msg;
877 size_t bufferSize = 2;
878
879 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */
880 bufferSize += 2; /* u16 primitive->interfaceTag */
881 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
882 bufferSize += 1; /* u8 primitive->setPmkidsCount */
883 {
884 u16 i1;
885 for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
886 {
887 bufferSize += 6; /* u8 primitive->setPmkids[i1].bssid.a[6] */
888 bufferSize += 16; /* u8 primitive->setPmkids[i1].pmkid[16] */
889 }
890 }
891 return bufferSize;
892}
893
894
895u8* CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg)
896{
897 CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *)msg;
898 *len = 0;
899 CsrUint16Ser(ptr, len, primitive->common.type);
900 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
901 CsrUint8Ser(ptr, len, (u8) primitive->action);
902 CsrUint8Ser(ptr, len, (u8) primitive->setPmkidsCount);
903 {
904 u16 i1;
905 for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
906 {
907 CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].bssid.a, ((u16) (6)));
908 CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].pmkid, ((u16) (16)));
909 }
910 }
911 return(ptr);
912}
913
914
915void* CsrWifiSmePmkidReqDes(u8 *buffer, size_t length)
916{
917 CsrWifiSmePmkidReq *primitive = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL);
918 size_t offset;
919 offset = 0;
920
921 CsrUint16Des(&primitive->common.type, buffer, &offset);
922 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
923 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
924 CsrUint8Des((u8 *) &primitive->setPmkidsCount, buffer, &offset);
925 primitive->setPmkids = NULL;
926 if (primitive->setPmkidsCount)
927 {
928 primitive->setPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->setPmkidsCount, GFP_KERNEL);
929 }
930 {
931 u16 i1;
932 for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
933 {
934 CsrMemCpyDes(primitive->setPmkids[i1].bssid.a, buffer, &offset, ((u16) (6)));
935 CsrMemCpyDes(primitive->setPmkids[i1].pmkid, buffer, &offset, ((u16) (16)));
936 }
937 }
938
939 return primitive;
940}
941
942
943void CsrWifiSmePmkidReqSerFree(void *voidPrimitivePointer)
944{
945 CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) voidPrimitivePointer;
946 kfree(primitive->setPmkids);
947 kfree(primitive);
948}
949
950
951size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg)
952{
953 size_t bufferSize = 2;
954
955 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
956 bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */
957 bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */
958 bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */
959 bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */
960 bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */
961 bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */
962 bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */
963 return bufferSize;
964}
965
966
967u8* CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
968{
969 CsrWifiSmePowerConfigSetReq *primitive = (CsrWifiSmePowerConfigSetReq *)msg;
970 *len = 0;
971 CsrUint16Ser(ptr, len, primitive->common.type);
972 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel);
973 CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu);
974 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims);
975 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode);
976 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow);
977 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave);
978 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence);
979 return(ptr);
980}
981
982
983void* CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t length)
984{
985 CsrWifiSmePowerConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL);
986 size_t offset;
987 offset = 0;
988
989 CsrUint16Des(&primitive->common.type, buffer, &offset);
990 CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset);
991 CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset);
992 CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset);
993 CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset);
994 CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset);
995 CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset);
996 CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset);
997
998 return primitive;
999}
1000
1001
1002size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg)
1003{
1004 size_t bufferSize = 2;
1005
1006 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 70) */
1007 bufferSize += 2; /* u16 primitive->interfaceTag */
1008 {
1009 u16 i2;
1010 for (i2 = 0; i2 < 3; i2++)
1011 {
1012 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */
1013 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */
1014 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */
1015 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */
1016 }
1017 }
1018 bufferSize += 1; /* u8 primitive->roamingConfig.disableSmoothRoaming */
1019 bufferSize += 1; /* u8 primitive->roamingConfig.disableRoamScans */
1020 bufferSize += 1; /* u8 primitive->roamingConfig.reconnectLimit */
1021 bufferSize += 2; /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */
1022 {
1023 u16 i2;
1024 for (i2 = 0; i2 < 3; i2++)
1025 {
1026 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */
1027 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */
1028 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */
1029 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */
1030 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */
1031 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */
1032 }
1033 }
1034 return bufferSize;
1035}
1036
1037
1038u8* CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
1039{
1040 CsrWifiSmeRoamingConfigSetReq *primitive = (CsrWifiSmeRoamingConfigSetReq *)msg;
1041 *len = 0;
1042 CsrUint16Ser(ptr, len, primitive->common.type);
1043 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1044 {
1045 u16 i2;
1046 for (i2 = 0; i2 < 3; i2++)
1047 {
1048 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold);
1049 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold);
1050 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold);
1051 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold);
1052 }
1053 }
1054 CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming);
1055 CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans);
1056 CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit);
1057 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs);
1058 {
1059 u16 i2;
1060 for (i2 = 0; i2 < 3; i2++)
1061 {
1062 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds);
1063 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds);
1064 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu);
1065 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu);
1066 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu);
1067 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu);
1068 }
1069 }
1070 return(ptr);
1071}
1072
1073
1074void* CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t length)
1075{
1076 CsrWifiSmeRoamingConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL);
1077 size_t offset;
1078 offset = 0;
1079
1080 CsrUint16Des(&primitive->common.type, buffer, &offset);
1081 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1082 {
1083 u16 i2;
1084 for (i2 = 0; i2 < 3; i2++)
1085 {
1086 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset);
1087 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset);
1088 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset);
1089 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset);
1090 }
1091 }
1092 CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset);
1093 CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset);
1094 CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset);
1095 CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset);
1096 {
1097 u16 i2;
1098 for (i2 = 0; i2 < 3; i2++)
1099 {
1100 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset);
1101 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset);
1102 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
1103 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
1104 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
1105 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
1106 }
1107 }
1108
1109 return primitive;
1110}
1111
1112
1113size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg)
1114{
1115 CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) msg;
1116 size_t bufferSize = 2;
1117
1118 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 63) */
1119 {
1120 u16 i2;
1121 for (i2 = 0; i2 < 4; i2++)
1122 {
1123 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */
1124 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */
1125 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */
1126 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */
1127 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */
1128 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */
1129 }
1130 }
1131 bufferSize += 1; /* u8 primitive->scanConfig.disableAutonomousScans */
1132 bufferSize += 2; /* u16 primitive->scanConfig.maxResults */
1133 bufferSize += 1; /* s8 primitive->scanConfig.highRssiThreshold */
1134 bufferSize += 1; /* s8 primitive->scanConfig.lowRssiThreshold */
1135 bufferSize += 1; /* s8 primitive->scanConfig.deltaRssiThreshold */
1136 bufferSize += 1; /* s8 primitive->scanConfig.highSnrThreshold */
1137 bufferSize += 1; /* s8 primitive->scanConfig.lowSnrThreshold */
1138 bufferSize += 1; /* s8 primitive->scanConfig.deltaSnrThreshold */
1139 bufferSize += 2; /* u16 primitive->scanConfig.passiveChannelListCount */
1140 bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */
1141 return bufferSize;
1142}
1143
1144
1145u8* CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
1146{
1147 CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *)msg;
1148 *len = 0;
1149 CsrUint16Ser(ptr, len, primitive->common.type);
1150 {
1151 u16 i2;
1152 for (i2 = 0; i2 < 4; i2++)
1153 {
1154 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds);
1155 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds);
1156 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu);
1157 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu);
1158 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu);
1159 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu);
1160 }
1161 }
1162 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans);
1163 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults);
1164 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold);
1165 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold);
1166 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold);
1167 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold);
1168 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold);
1169 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold);
1170 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount);
1171 if (primitive->scanConfig.passiveChannelListCount)
1172 {
1173 CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount)));
1174 }
1175 return(ptr);
1176}
1177
1178
1179void* CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t length)
1180{
1181 CsrWifiSmeScanConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL);
1182 size_t offset;
1183 offset = 0;
1184
1185 CsrUint16Des(&primitive->common.type, buffer, &offset);
1186 {
1187 u16 i2;
1188 for (i2 = 0; i2 < 4; i2++)
1189 {
1190 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset);
1191 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset);
1192 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
1193 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
1194 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
1195 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
1196 }
1197 }
1198 CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset);
1199 CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset);
1200 CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset);
1201 CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset);
1202 CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset);
1203 CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset);
1204 CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset);
1205 CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset);
1206 CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset);
1207 if (primitive->scanConfig.passiveChannelListCount)
1208 {
1209 primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL);
1210 CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount)));
1211 }
1212 else
1213 {
1214 primitive->scanConfig.passiveChannelList = NULL;
1215 }
1216
1217 return primitive;
1218}
1219
1220
1221void CsrWifiSmeScanConfigSetReqSerFree(void *voidPrimitivePointer)
1222{
1223 CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) voidPrimitivePointer;
1224 kfree(primitive->scanConfig.passiveChannelList);
1225 kfree(primitive);
1226}
1227
1228
1229size_t CsrWifiSmeScanFullReqSizeof(void *msg)
1230{
1231 CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) msg;
1232 size_t bufferSize = 2;
1233
1234 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 52) */
1235 bufferSize += 1; /* u8 primitive->ssidCount */
1236 {
1237 u16 i1;
1238 for (i1 = 0; i1 < primitive->ssidCount; i1++)
1239 {
1240 bufferSize += 32; /* u8 primitive->ssid[i1].ssid[32] */
1241 bufferSize += 1; /* u8 primitive->ssid[i1].length */
1242 }
1243 }
1244 bufferSize += 6; /* u8 primitive->bssid.a[6] */
1245 bufferSize += 1; /* u8 primitive->forceScan */
1246 bufferSize += 1; /* CsrWifiSmeBssType primitive->bssType */
1247 bufferSize += 1; /* CsrWifiSmeScanType primitive->scanType */
1248 bufferSize += 2; /* u16 primitive->channelListCount */
1249 bufferSize += primitive->channelListCount; /* u8 primitive->channelList */
1250 bufferSize += 2; /* u16 primitive->probeIeLength */
1251 bufferSize += primitive->probeIeLength; /* u8 primitive->probeIe */
1252 return bufferSize;
1253}
1254
1255
1256u8* CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg)
1257{
1258 CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *)msg;
1259 *len = 0;
1260 CsrUint16Ser(ptr, len, primitive->common.type);
1261 CsrUint8Ser(ptr, len, (u8) primitive->ssidCount);
1262 {
1263 u16 i1;
1264 for (i1 = 0; i1 < primitive->ssidCount; i1++)
1265 {
1266 CsrMemCpySer(ptr, len, (const void *) primitive->ssid[i1].ssid, ((u16) (32)));
1267 CsrUint8Ser(ptr, len, (u8) primitive->ssid[i1].length);
1268 }
1269 }
1270 CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6)));
1271 CsrUint8Ser(ptr, len, (u8) primitive->forceScan);
1272 CsrUint8Ser(ptr, len, (u8) primitive->bssType);
1273 CsrUint8Ser(ptr, len, (u8) primitive->scanType);
1274 CsrUint16Ser(ptr, len, (u16) primitive->channelListCount);
1275 if (primitive->channelListCount)
1276 {
1277 CsrMemCpySer(ptr, len, (const void *) primitive->channelList, ((u16) (primitive->channelListCount)));
1278 }
1279 CsrUint16Ser(ptr, len, (u16) primitive->probeIeLength);
1280 if (primitive->probeIeLength)
1281 {
1282 CsrMemCpySer(ptr, len, (const void *) primitive->probeIe, ((u16) (primitive->probeIeLength)));
1283 }
1284 return(ptr);
1285}
1286
1287
1288void* CsrWifiSmeScanFullReqDes(u8 *buffer, size_t length)
1289{
1290 CsrWifiSmeScanFullReq *primitive = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL);
1291 size_t offset;
1292 offset = 0;
1293
1294 CsrUint16Des(&primitive->common.type, buffer, &offset);
1295 CsrUint8Des((u8 *) &primitive->ssidCount, buffer, &offset);
1296 primitive->ssid = NULL;
1297 if (primitive->ssidCount)
1298 {
1299 primitive->ssid = kmalloc(sizeof(CsrWifiSsid) * primitive->ssidCount, GFP_KERNEL);
1300 }
1301 {
1302 u16 i1;
1303 for (i1 = 0; i1 < primitive->ssidCount; i1++)
1304 {
1305 CsrMemCpyDes(primitive->ssid[i1].ssid, buffer, &offset, ((u16) (32)));
1306 CsrUint8Des((u8 *) &primitive->ssid[i1].length, buffer, &offset);
1307 }
1308 }
1309 CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6)));
1310 CsrUint8Des((u8 *) &primitive->forceScan, buffer, &offset);
1311 CsrUint8Des((u8 *) &primitive->bssType, buffer, &offset);
1312 CsrUint8Des((u8 *) &primitive->scanType, buffer, &offset);
1313 CsrUint16Des((u16 *) &primitive->channelListCount, buffer, &offset);
1314 if (primitive->channelListCount)
1315 {
1316 primitive->channelList = kmalloc(primitive->channelListCount, GFP_KERNEL);
1317 CsrMemCpyDes(primitive->channelList, buffer, &offset, ((u16) (primitive->channelListCount)));
1318 }
1319 else
1320 {
1321 primitive->channelList = NULL;
1322 }
1323 CsrUint16Des((u16 *) &primitive->probeIeLength, buffer, &offset);
1324 if (primitive->probeIeLength)
1325 {
1326 primitive->probeIe = kmalloc(primitive->probeIeLength, GFP_KERNEL);
1327 CsrMemCpyDes(primitive->probeIe, buffer, &offset, ((u16) (primitive->probeIeLength)));
1328 }
1329 else
1330 {
1331 primitive->probeIe = NULL;
1332 }
1333
1334 return primitive;
1335}
1336
1337
1338void CsrWifiSmeScanFullReqSerFree(void *voidPrimitivePointer)
1339{
1340 CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) voidPrimitivePointer;
1341 kfree(primitive->ssid);
1342 kfree(primitive->channelList);
1343 kfree(primitive->probeIe);
1344 kfree(primitive);
1345}
1346
1347
1348size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg)
1349{
1350 size_t bufferSize = 2;
1351
1352 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
1353 bufferSize += 2; /* u16 primitive->interfaceTag */
1354 bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */
1355 bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */
1356 bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */
1357 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */
1358 bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */
1359 bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */
1360 return bufferSize;
1361}
1362
1363
1364u8* CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
1365{
1366 CsrWifiSmeSmeStaConfigSetReq *primitive = (CsrWifiSmeSmeStaConfigSetReq *)msg;
1367 *len = 0;
1368 CsrUint16Ser(ptr, len, primitive->common.type);
1369 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1370 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger);
1371 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger);
1372 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask);
1373 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex);
1374 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher);
1375 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching);
1376 return(ptr);
1377}
1378
1379
1380void* CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t length)
1381{
1382 CsrWifiSmeSmeStaConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL);
1383 size_t offset;
1384 offset = 0;
1385
1386 CsrUint16Des(&primitive->common.type, buffer, &offset);
1387 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1388 CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset);
1389 CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset);
1390 CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset);
1391 CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset);
1392 CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset);
1393 CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset);
1394
1395 return primitive;
1396}
1397
1398
1399size_t CsrWifiSmeTspecReqSizeof(void *msg)
1400{
1401 CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) msg;
1402 size_t bufferSize = 2;
1403
1404 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
1405 bufferSize += 2; /* u16 primitive->interfaceTag */
1406 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
1407 bufferSize += 4; /* u32 primitive->transactionId */
1408 bufferSize += 1; /* u8 primitive->strict */
1409 bufferSize += 1; /* CsrWifiSmeTspecCtrlMask primitive->ctrlMask */
1410 bufferSize += 2; /* u16 primitive->tspecLength */
1411 bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
1412 bufferSize += 2; /* u16 primitive->tclasLength */
1413 bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
1414 return bufferSize;
1415}
1416
1417
1418u8* CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg)
1419{
1420 CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *)msg;
1421 *len = 0;
1422 CsrUint16Ser(ptr, len, primitive->common.type);
1423 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
1424 CsrUint8Ser(ptr, len, (u8) primitive->action);
1425 CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
1426 CsrUint8Ser(ptr, len, (u8) primitive->strict);
1427 CsrUint8Ser(ptr, len, (u8) primitive->ctrlMask);
1428 CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
1429 if (primitive->tspecLength)
1430 {
1431 CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
1432 }
1433 CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
1434 if (primitive->tclasLength)
1435 {
1436 CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
1437 }
1438 return(ptr);
1439}
1440
1441
1442void* CsrWifiSmeTspecReqDes(u8 *buffer, size_t length)
1443{
1444 CsrWifiSmeTspecReq *primitive = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL);
1445 size_t offset;
1446 offset = 0;
1447
1448 CsrUint16Des(&primitive->common.type, buffer, &offset);
1449 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
1450 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
1451 CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
1452 CsrUint8Des((u8 *) &primitive->strict, buffer, &offset);
1453 CsrUint8Des((u8 *) &primitive->ctrlMask, buffer, &offset);
1454 CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
1455 if (primitive->tspecLength)
1456 {
1457 primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
1458 CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
1459 }
1460 else
1461 {
1462 primitive->tspec = NULL;
1463 }
1464 CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
1465 if (primitive->tclasLength)
1466 {
1467 primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
1468 CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
1469 }
1470 else
1471 {
1472 primitive->tclas = NULL;
1473 }
1474
1475 return primitive;
1476}
1477
1478
1479void CsrWifiSmeTspecReqSerFree(void *voidPrimitivePointer)
1480{
1481 CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) voidPrimitivePointer;
1482 kfree(primitive->tspec);
1483 kfree(primitive->tclas);
1484 kfree(primitive);
1485}
1486
1487
1488size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg)
1489{
1490 CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) msg;
1491 size_t bufferSize = 2;
1492
1493 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
1494 bufferSize += 6; /* u8 primitive->address.a[6] */
1495 bufferSize += 2; /* u16 primitive->mibFilesCount */
1496 {
1497 u16 i1;
1498 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1499 {
1500 bufferSize += 2; /* u16 primitive->mibFiles[i1].length */
1501 bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */
1502 }
1503 }
1504 return bufferSize;
1505}
1506
1507
1508u8* CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg)
1509{
1510 CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *)msg;
1511 *len = 0;
1512 CsrUint16Ser(ptr, len, primitive->common.type);
1513 CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
1514 CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount);
1515 {
1516 u16 i1;
1517 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1518 {
1519 CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length);
1520 if (primitive->mibFiles[i1].length)
1521 {
1522 CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length)));
1523 }
1524 }
1525 }
1526 return(ptr);
1527}
1528
1529
1530void* CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t length)
1531{
1532 CsrWifiSmeWifiFlightmodeReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL);
1533 size_t offset;
1534 offset = 0;
1535
1536 CsrUint16Des(&primitive->common.type, buffer, &offset);
1537 CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
1538 CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset);
1539 primitive->mibFiles = NULL;
1540 if (primitive->mibFilesCount)
1541 {
1542 primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL);
1543 }
1544 {
1545 u16 i1;
1546 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1547 {
1548 CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset);
1549 if (primitive->mibFiles[i1].length)
1550 {
1551 primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL);
1552 CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length)));
1553 }
1554 else
1555 {
1556 primitive->mibFiles[i1].data = NULL;
1557 }
1558 }
1559 }
1560
1561 return primitive;
1562}
1563
1564
1565void CsrWifiSmeWifiFlightmodeReqSerFree(void *voidPrimitivePointer)
1566{
1567 CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) voidPrimitivePointer;
1568 {
1569 u16 i1;
1570 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1571 {
1572 kfree(primitive->mibFiles[i1].data);
1573 }
1574 }
1575 kfree(primitive->mibFiles);
1576 kfree(primitive);
1577}
1578
1579
1580size_t CsrWifiSmeWifiOnReqSizeof(void *msg)
1581{
1582 CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) msg;
1583 size_t bufferSize = 2;
1584
1585 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
1586 bufferSize += 6; /* u8 primitive->address.a[6] */
1587 bufferSize += 2; /* u16 primitive->mibFilesCount */
1588 {
1589 u16 i1;
1590 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1591 {
1592 bufferSize += 2; /* u16 primitive->mibFiles[i1].length */
1593 bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */
1594 }
1595 }
1596 return bufferSize;
1597}
1598
1599
1600u8* CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg)
1601{
1602 CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *)msg;
1603 *len = 0;
1604 CsrUint16Ser(ptr, len, primitive->common.type);
1605 CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
1606 CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount);
1607 {
1608 u16 i1;
1609 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1610 {
1611 CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length);
1612 if (primitive->mibFiles[i1].length)
1613 {
1614 CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length)));
1615 }
1616 }
1617 }
1618 return(ptr);
1619}
1620
1621
1622void* CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t length)
1623{
1624 CsrWifiSmeWifiOnReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL);
1625 size_t offset;
1626 offset = 0;
1627
1628 CsrUint16Des(&primitive->common.type, buffer, &offset);
1629 CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
1630 CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset);
1631 primitive->mibFiles = NULL;
1632 if (primitive->mibFilesCount)
1633 {
1634 primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL);
1635 }
1636 {
1637 u16 i1;
1638 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1639 {
1640 CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset);
1641 if (primitive->mibFiles[i1].length)
1642 {
1643 primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL);
1644 CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length)));
1645 }
1646 else
1647 {
1648 primitive->mibFiles[i1].data = NULL;
1649 }
1650 }
1651 }
1652
1653 return primitive;
1654}
1655
1656
1657void CsrWifiSmeWifiOnReqSerFree(void *voidPrimitivePointer)
1658{
1659 CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) voidPrimitivePointer;
1660 {
1661 u16 i1;
1662 for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
1663 {
1664 kfree(primitive->mibFiles[i1].data);
1665 }
1666 }
1667 kfree(primitive->mibFiles);
1668 kfree(primitive);
1669}
1670
1671
1672size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg)
1673{
1674 CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) msg;
1675 size_t bufferSize = 2;
1676
1677 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 37) */
1678 bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */
1679 {
1680 u16 i2;
1681 for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
1682 {
1683 bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */
1684 bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */
1685 }
1686 }
1687 return bufferSize;
1688}
1689
1690
1691u8* CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg)
1692{
1693 CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *)msg;
1694 *len = 0;
1695 CsrUint16Ser(ptr, len, primitive->common.type);
1696 CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount);
1697 {
1698 u16 i2;
1699 for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
1700 {
1701 CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32)));
1702 CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length);
1703 }
1704 }
1705 return(ptr);
1706}
1707
1708
1709void* CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t length)
1710{
1711 CsrWifiSmeCloakedSsidsSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL);
1712 size_t offset;
1713 offset = 0;
1714
1715 CsrUint16Des(&primitive->common.type, buffer, &offset);
1716 CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset);
1717 primitive->cloakedSsids.cloakedSsids = NULL;
1718 if (primitive->cloakedSsids.cloakedSsidsCount)
1719 {
1720 primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL);
1721 }
1722 {
1723 u16 i2;
1724 for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
1725 {
1726 CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32)));
1727 CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset);
1728 }
1729 }
1730
1731 return primitive;
1732}
1733
1734
1735void CsrWifiSmeCloakedSsidsSetReqSerFree(void *voidPrimitivePointer)
1736{
1737 CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) voidPrimitivePointer;
1738 kfree(primitive->cloakedSsids.cloakedSsids);
1739 kfree(primitive);
1740}
1741
1742
1743size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg)
1744{
1745 size_t bufferSize = 2;
1746
1747 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
1748 bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */
1749 bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */
1750 bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */
1751 bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */
1752 return bufferSize;
1753}
1754
1755
1756u8* CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
1757{
1758 CsrWifiSmeSmeCommonConfigSetReq *primitive = (CsrWifiSmeSmeCommonConfigSetReq *)msg;
1759 *len = 0;
1760 CsrUint16Ser(ptr, len, primitive->common.type);
1761 CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel);
1762 CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2)));
1763 CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface);
1764 CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN);
1765 return(ptr);
1766}
1767
1768
1769void* CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t length)
1770{
1771 CsrWifiSmeSmeCommonConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL);
1772 size_t offset;
1773 offset = 0;
1774
1775 CsrUint16Des(&primitive->common.type, buffer, &offset);
1776 CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset);
1777 CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2)));
1778 CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset);
1779 CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset);
1780
1781 return primitive;
1782}
1783
1784
1785size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg)
1786{
1787 CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) msg;
1788 size_t bufferSize = 2;
1789
1790 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 240) */
1791 bufferSize += 1; /* u8 primitive->wpsConfig.wpsVersion */
1792 bufferSize += 16; /* u8 primitive->wpsConfig.uuid[16] */
1793 bufferSize += 32; /* u8 primitive->wpsConfig.deviceName[32] */
1794 bufferSize += 1; /* u8 primitive->wpsConfig.deviceNameLength */
1795 bufferSize += 64; /* u8 primitive->wpsConfig.manufacturer[64] */
1796 bufferSize += 1; /* u8 primitive->wpsConfig.manufacturerLength */
1797 bufferSize += 32; /* u8 primitive->wpsConfig.modelName[32] */
1798 bufferSize += 1; /* u8 primitive->wpsConfig.modelNameLength */
1799 bufferSize += 32; /* u8 primitive->wpsConfig.modelNumber[32] */
1800 bufferSize += 1; /* u8 primitive->wpsConfig.modelNumberLength */
1801 bufferSize += 32; /* u8 primitive->wpsConfig.serialNumber[32] */
1802 bufferSize += 8; /* u8 primitive->wpsConfig.primDeviceType.deviceDetails[8] */
1803 bufferSize += 1; /* u8 primitive->wpsConfig.secondaryDeviceTypeCount */
1804 {
1805 u16 i2;
1806 for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
1807 {
1808 bufferSize += 8; /* u8 primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails[8] */
1809 }
1810 }
1811 bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->wpsConfig.configMethods */
1812 bufferSize += 1; /* u8 primitive->wpsConfig.rfBands */
1813 bufferSize += 4; /* u8 primitive->wpsConfig.osVersion[4] */
1814 return bufferSize;
1815}
1816
1817
1818u8* CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg)
1819{
1820 CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *)msg;
1821 *len = 0;
1822 CsrUint16Ser(ptr, len, primitive->common.type);
1823 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.wpsVersion);
1824 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.uuid, ((u16) (16)));
1825 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.deviceName, ((u16) (32)));
1826 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.deviceNameLength);
1827 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.manufacturer, ((u16) (64)));
1828 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.manufacturerLength);
1829 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelName, ((u16) (32)));
1830 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNameLength);
1831 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelNumber, ((u16) (32)));
1832 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNumberLength);
1833 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.serialNumber, ((u16) (32)));
1834 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.primDeviceType.deviceDetails, ((u16) (8)));
1835 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.secondaryDeviceTypeCount);
1836 {
1837 u16 i2;
1838 for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
1839 {
1840 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, ((u16) (8)));
1841 }
1842 }
1843 CsrUint16Ser(ptr, len, (u16) primitive->wpsConfig.configMethods);
1844 CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.rfBands);
1845 CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.osVersion, ((u16) (4)));
1846 return(ptr);
1847}
1848
1849
1850void* CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t length)
1851{
1852 CsrWifiSmeWpsConfigurationReq *primitive = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL);
1853 size_t offset;
1854 offset = 0;
1855
1856 CsrUint16Des(&primitive->common.type, buffer, &offset);
1857 CsrUint8Des((u8 *) &primitive->wpsConfig.wpsVersion, buffer, &offset);
1858 CsrMemCpyDes(primitive->wpsConfig.uuid, buffer, &offset, ((u16) (16)));
1859 CsrMemCpyDes(primitive->wpsConfig.deviceName, buffer, &offset, ((u16) (32)));
1860 CsrUint8Des((u8 *) &primitive->wpsConfig.deviceNameLength, buffer, &offset);
1861 CsrMemCpyDes(primitive->wpsConfig.manufacturer, buffer, &offset, ((u16) (64)));
1862 CsrUint8Des((u8 *) &primitive->wpsConfig.manufacturerLength, buffer, &offset);
1863 CsrMemCpyDes(primitive->wpsConfig.modelName, buffer, &offset, ((u16) (32)));
1864 CsrUint8Des((u8 *) &primitive->wpsConfig.modelNameLength, buffer, &offset);
1865 CsrMemCpyDes(primitive->wpsConfig.modelNumber, buffer, &offset, ((u16) (32)));
1866 CsrUint8Des((u8 *) &primitive->wpsConfig.modelNumberLength, buffer, &offset);
1867 CsrMemCpyDes(primitive->wpsConfig.serialNumber, buffer, &offset, ((u16) (32)));
1868 CsrMemCpyDes(primitive->wpsConfig.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
1869 CsrUint8Des((u8 *) &primitive->wpsConfig.secondaryDeviceTypeCount, buffer, &offset);
1870 primitive->wpsConfig.secondaryDeviceType = NULL;
1871 if (primitive->wpsConfig.secondaryDeviceTypeCount)
1872 {
1873 primitive->wpsConfig.secondaryDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->wpsConfig.secondaryDeviceTypeCount, GFP_KERNEL);
1874 }
1875 {
1876 u16 i2;
1877 for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
1878 {
1879 CsrMemCpyDes(primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, buffer, &offset, ((u16) (8)));
1880 }
1881 }
1882 CsrUint16Des((u16 *) &primitive->wpsConfig.configMethods, buffer, &offset);
1883 CsrUint8Des((u8 *) &primitive->wpsConfig.rfBands, buffer, &offset);
1884 CsrMemCpyDes(primitive->wpsConfig.osVersion, buffer, &offset, ((u16) (4)));
1885
1886 return primitive;
1887}
1888
1889
1890void CsrWifiSmeWpsConfigurationReqSerFree(void *voidPrimitivePointer)
1891{
1892 CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) voidPrimitivePointer;
1893 kfree(primitive->wpsConfig.secondaryDeviceType);
1894 kfree(primitive);
1895}
1896
1897
1898size_t CsrWifiSmeSetReqSizeof(void *msg)
1899{
1900 CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) msg;
1901 size_t bufferSize = 2;
1902
1903 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
1904 bufferSize += 4; /* u32 primitive->dataLength */
1905 bufferSize += primitive->dataLength; /* u8 primitive->data */
1906 return bufferSize;
1907}
1908
1909
1910u8* CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg)
1911{
1912 CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *)msg;
1913 *len = 0;
1914 CsrUint16Ser(ptr, len, primitive->common.type);
1915 CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
1916 if (primitive->dataLength)
1917 {
1918 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
1919 }
1920 return(ptr);
1921}
1922
1923
1924void* CsrWifiSmeSetReqDes(u8 *buffer, size_t length)
1925{
1926 CsrWifiSmeSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL);
1927 size_t offset;
1928 offset = 0;
1929
1930 CsrUint16Des(&primitive->common.type, buffer, &offset);
1931 CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
1932 if (primitive->dataLength)
1933 {
1934 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
1935 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
1936 }
1937 else
1938 {
1939 primitive->data = NULL;
1940 }
1941
1942 return primitive;
1943}
1944
1945
1946void CsrWifiSmeSetReqSerFree(void *voidPrimitivePointer)
1947{
1948 CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) voidPrimitivePointer;
1949 kfree(primitive->data);
1950 kfree(primitive);
1951}
1952
1953
1954size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg)
1955{
1956 size_t bufferSize = 2;
1957
1958 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
1959 bufferSize += 2; /* CsrResult primitive->status */
1960 bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */
1961 bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */
1962 bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */
1963 bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */
1964 return bufferSize;
1965}
1966
1967
1968u8* CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
1969{
1970 CsrWifiSmeAdhocConfigGetCfm *primitive = (CsrWifiSmeAdhocConfigGetCfm *)msg;
1971 *len = 0;
1972 CsrUint16Ser(ptr, len, primitive->common.type);
1973 CsrUint16Ser(ptr, len, (u16) primitive->status);
1974 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu);
1975 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu);
1976 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts);
1977 CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs);
1978 return(ptr);
1979}
1980
1981
1982void* CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t length)
1983{
1984 CsrWifiSmeAdhocConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL);
1985 size_t offset;
1986 offset = 0;
1987
1988 CsrUint16Des(&primitive->common.type, buffer, &offset);
1989 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
1990 CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset);
1991 CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset);
1992 CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset);
1993 CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset);
1994
1995 return primitive;
1996}
1997
1998
1999size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg)
2000{
2001 CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) msg;
2002 size_t bufferSize = 2;
2003
2004 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 98) */
2005 bufferSize += 2; /* u16 primitive->interfaceTag */
2006 bufferSize += 2; /* CsrResult primitive->status */
2007 bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */
2008 bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */
2009 bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */
2010 bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
2011 bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */
2012 bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */
2013 bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
2014 bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
2015 bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
2016 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
2017 bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */
2018 bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */
2019 bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */
2020 bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */
2021 bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */
2022 bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */
2023 bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */
2024 bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */
2025 bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */
2026 bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
2027 bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
2028 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */
2029 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
2030 bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
2031 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
2032 bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */
2033 bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
2034 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
2035 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */
2036 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
2037 bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */
2038 bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */
2039 return bufferSize;
2040}
2041
2042
2043u8* CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg)
2044{
2045 CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *)msg;
2046 *len = 0;
2047 CsrUint16Ser(ptr, len, primitive->common.type);
2048 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2049 CsrUint16Ser(ptr, len, (u16) primitive->status);
2050 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
2051 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
2052 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
2053 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
2054 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
2055 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
2056 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
2057 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
2058 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
2059 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
2060 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
2061 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
2062 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
2063 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
2064 if (primitive->connectionInfo.beaconFrameLength)
2065 {
2066 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
2067 }
2068 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
2069 if (primitive->connectionInfo.associationReqFrameLength)
2070 {
2071 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
2072 }
2073 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
2074 if (primitive->connectionInfo.associationRspFrameLength)
2075 {
2076 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
2077 }
2078 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
2079 if (primitive->connectionInfo.assocScanInfoElementsLength)
2080 {
2081 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
2082 }
2083 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
2084 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
2085 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
2086 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
2087 if (primitive->connectionInfo.assocReqInfoElementsLength)
2088 {
2089 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
2090 }
2091 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
2092 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
2093 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
2094 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
2095 if (primitive->connectionInfo.assocRspInfoElementsLength)
2096 {
2097 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
2098 }
2099 CsrUint16Ser(ptr, len, (u16) primitive->deauthReason);
2100 return(ptr);
2101}
2102
2103
2104void* CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t length)
2105{
2106 CsrWifiSmeAssociationCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL);
2107 size_t offset;
2108 offset = 0;
2109
2110 CsrUint16Des(&primitive->common.type, buffer, &offset);
2111 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2112 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2113 CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
2114 CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
2115 CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
2116 CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
2117 CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
2118 CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
2119 CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
2120 CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
2121 CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
2122 CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
2123 CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
2124 CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
2125 CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
2126 CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
2127 if (primitive->connectionInfo.beaconFrameLength)
2128 {
2129 primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
2130 CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
2131 }
2132 else
2133 {
2134 primitive->connectionInfo.beaconFrame = NULL;
2135 }
2136 CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
2137 if (primitive->connectionInfo.associationReqFrameLength)
2138 {
2139 primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
2140 CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
2141 }
2142 else
2143 {
2144 primitive->connectionInfo.associationReqFrame = NULL;
2145 }
2146 CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
2147 if (primitive->connectionInfo.associationRspFrameLength)
2148 {
2149 primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
2150 CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
2151 }
2152 else
2153 {
2154 primitive->connectionInfo.associationRspFrame = NULL;
2155 }
2156 CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
2157 if (primitive->connectionInfo.assocScanInfoElementsLength)
2158 {
2159 primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
2160 CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
2161 }
2162 else
2163 {
2164 primitive->connectionInfo.assocScanInfoElements = NULL;
2165 }
2166 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
2167 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
2168 CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
2169 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
2170 if (primitive->connectionInfo.assocReqInfoElementsLength)
2171 {
2172 primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
2173 CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
2174 }
2175 else
2176 {
2177 primitive->connectionInfo.assocReqInfoElements = NULL;
2178 }
2179 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
2180 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
2181 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
2182 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
2183 if (primitive->connectionInfo.assocRspInfoElementsLength)
2184 {
2185 primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
2186 CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
2187 }
2188 else
2189 {
2190 primitive->connectionInfo.assocRspInfoElements = NULL;
2191 }
2192 CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset);
2193
2194 return primitive;
2195}
2196
2197
2198void CsrWifiSmeAssociationCompleteIndSerFree(void *voidPrimitivePointer)
2199{
2200 CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) voidPrimitivePointer;
2201 kfree(primitive->connectionInfo.beaconFrame);
2202 kfree(primitive->connectionInfo.associationReqFrame);
2203 kfree(primitive->connectionInfo.associationRspFrame);
2204 kfree(primitive->connectionInfo.assocScanInfoElements);
2205 kfree(primitive->connectionInfo.assocReqInfoElements);
2206 kfree(primitive->connectionInfo.assocRspInfoElements);
2207 kfree(primitive);
2208}
2209
2210
2211size_t CsrWifiSmeAssociationStartIndSizeof(void *msg)
2212{
2213 size_t bufferSize = 2;
2214
2215 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 44) */
2216 bufferSize += 2; /* u16 primitive->interfaceTag */
2217 bufferSize += 6; /* u8 primitive->address.a[6] */
2218 bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
2219 bufferSize += 1; /* u8 primitive->ssid.length */
2220 return bufferSize;
2221}
2222
2223
2224u8* CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg)
2225{
2226 CsrWifiSmeAssociationStartInd *primitive = (CsrWifiSmeAssociationStartInd *)msg;
2227 *len = 0;
2228 CsrUint16Ser(ptr, len, primitive->common.type);
2229 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2230 CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
2231 CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
2232 CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
2233 return(ptr);
2234}
2235
2236
2237void* CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t length)
2238{
2239 CsrWifiSmeAssociationStartInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL);
2240 size_t offset;
2241 offset = 0;
2242
2243 CsrUint16Des(&primitive->common.type, buffer, &offset);
2244 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2245 CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
2246 CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
2247 CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
2248
2249 return primitive;
2250}
2251
2252
2253size_t CsrWifiSmeBlacklistCfmSizeof(void *msg)
2254{
2255 CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) msg;
2256 size_t bufferSize = 2;
2257
2258 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
2259 bufferSize += 2; /* u16 primitive->interfaceTag */
2260 bufferSize += 2; /* CsrResult primitive->status */
2261 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
2262 bufferSize += 1; /* u8 primitive->getAddressCount */
2263 {
2264 u16 i1;
2265 for (i1 = 0; i1 < primitive->getAddressCount; i1++)
2266 {
2267 bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
2268 }
2269 }
2270 return bufferSize;
2271}
2272
2273
2274u8* CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg)
2275{
2276 CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *)msg;
2277 *len = 0;
2278 CsrUint16Ser(ptr, len, primitive->common.type);
2279 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2280 CsrUint16Ser(ptr, len, (u16) primitive->status);
2281 CsrUint8Ser(ptr, len, (u8) primitive->action);
2282 CsrUint8Ser(ptr, len, (u8) primitive->getAddressCount);
2283 {
2284 u16 i1;
2285 for (i1 = 0; i1 < primitive->getAddressCount; i1++)
2286 {
2287 CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
2288 }
2289 }
2290 return(ptr);
2291}
2292
2293
2294void* CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t length)
2295{
2296 CsrWifiSmeBlacklistCfm *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL);
2297 size_t offset;
2298 offset = 0;
2299
2300 CsrUint16Des(&primitive->common.type, buffer, &offset);
2301 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2302 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2303 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
2304 CsrUint8Des((u8 *) &primitive->getAddressCount, buffer, &offset);
2305 primitive->getAddresses = NULL;
2306 if (primitive->getAddressCount)
2307 {
2308 primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressCount, GFP_KERNEL);
2309 }
2310 {
2311 u16 i1;
2312 for (i1 = 0; i1 < primitive->getAddressCount; i1++)
2313 {
2314 CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
2315 }
2316 }
2317
2318 return primitive;
2319}
2320
2321
2322void CsrWifiSmeBlacklistCfmSerFree(void *voidPrimitivePointer)
2323{
2324 CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) voidPrimitivePointer;
2325 kfree(primitive->getAddresses);
2326 kfree(primitive);
2327}
2328
2329
2330size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg)
2331{
2332 CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) msg;
2333 size_t bufferSize = 2;
2334
2335 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
2336 bufferSize += 2; /* CsrResult primitive->status */
2337 bufferSize += 2; /* u16 primitive->calibrationDataLength */
2338 bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */
2339 return bufferSize;
2340}
2341
2342
2343u8* CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg)
2344{
2345 CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *)msg;
2346 *len = 0;
2347 CsrUint16Ser(ptr, len, primitive->common.type);
2348 CsrUint16Ser(ptr, len, (u16) primitive->status);
2349 CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength);
2350 if (primitive->calibrationDataLength)
2351 {
2352 CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength)));
2353 }
2354 return(ptr);
2355}
2356
2357
2358void* CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t length)
2359{
2360 CsrWifiSmeCalibrationDataGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL);
2361 size_t offset;
2362 offset = 0;
2363
2364 CsrUint16Des(&primitive->common.type, buffer, &offset);
2365 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2366 CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset);
2367 if (primitive->calibrationDataLength)
2368 {
2369 primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL);
2370 CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength)));
2371 }
2372 else
2373 {
2374 primitive->calibrationData = NULL;
2375 }
2376
2377 return primitive;
2378}
2379
2380
2381void CsrWifiSmeCalibrationDataGetCfmSerFree(void *voidPrimitivePointer)
2382{
2383 CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) voidPrimitivePointer;
2384 kfree(primitive->calibrationData);
2385 kfree(primitive);
2386}
2387
2388
2389size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg)
2390{
2391 size_t bufferSize = 2;
2392
2393 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
2394 bufferSize += 2; /* u16 primitive->interfaceTag */
2395 bufferSize += 2; /* CsrResult primitive->status */
2396 bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */
2397 bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */
2398 bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */
2399 bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */
2400 return bufferSize;
2401}
2402
2403
2404u8* CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
2405{
2406 CsrWifiSmeCcxConfigGetCfm *primitive = (CsrWifiSmeCcxConfigGetCfm *)msg;
2407 *len = 0;
2408 CsrUint16Ser(ptr, len, primitive->common.type);
2409 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2410 CsrUint16Ser(ptr, len, (u16) primitive->status);
2411 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs);
2412 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled);
2413 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask);
2414 CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled);
2415 return(ptr);
2416}
2417
2418
2419void* CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t length)
2420{
2421 CsrWifiSmeCcxConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL);
2422 size_t offset;
2423 offset = 0;
2424
2425 CsrUint16Des(&primitive->common.type, buffer, &offset);
2426 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2427 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2428 CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset);
2429 CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset);
2430 CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset);
2431 CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset);
2432
2433 return primitive;
2434}
2435
2436
2437size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg)
2438{
2439 size_t bufferSize = 2;
2440
2441 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
2442 bufferSize += 2; /* u16 primitive->interfaceTag */
2443 bufferSize += 2; /* CsrResult primitive->status */
2444 return bufferSize;
2445}
2446
2447
2448u8* CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
2449{
2450 CsrWifiSmeCcxConfigSetCfm *primitive = (CsrWifiSmeCcxConfigSetCfm *)msg;
2451 *len = 0;
2452 CsrUint16Ser(ptr, len, primitive->common.type);
2453 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2454 CsrUint16Ser(ptr, len, (u16) primitive->status);
2455 return(ptr);
2456}
2457
2458
2459void* CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t length)
2460{
2461 CsrWifiSmeCcxConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL);
2462 size_t offset;
2463 offset = 0;
2464
2465 CsrUint16Des(&primitive->common.type, buffer, &offset);
2466 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2467 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2468
2469 return primitive;
2470}
2471
2472
2473size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg)
2474{
2475 size_t bufferSize = 2;
2476
2477 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */
2478 bufferSize += 2; /* CsrResult primitive->status */
2479 bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */
2480 bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */
2481 bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */
2482 bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */
2483 bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */
2484 bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */
2485 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */
2486 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */
2487 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */
2488 bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */
2489 bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */
2490 bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */
2491 bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */
2492 bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */
2493 return bufferSize;
2494}
2495
2496
2497u8* CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
2498{
2499 CsrWifiSmeCoexConfigGetCfm *primitive = (CsrWifiSmeCoexConfigGetCfm *)msg;
2500 *len = 0;
2501 CsrUint16Ser(ptr, len, primitive->common.type);
2502 CsrUint16Ser(ptr, len, (u16) primitive->status);
2503 CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement);
2504 CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost);
2505 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs);
2506 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs);
2507 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs);
2508 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs);
2509 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs);
2510 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs);
2511 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs);
2512 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs);
2513 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs);
2514 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs);
2515 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs);
2516 CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs);
2517 return(ptr);
2518}
2519
2520
2521void* CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t length)
2522{
2523 CsrWifiSmeCoexConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL);
2524 size_t offset;
2525 offset = 0;
2526
2527 CsrUint16Des(&primitive->common.type, buffer, &offset);
2528 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2529 CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset);
2530 CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset);
2531 CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset);
2532 CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset);
2533 CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset);
2534 CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset);
2535 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset);
2536 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset);
2537 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset);
2538 CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset);
2539 CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset);
2540 CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset);
2541 CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset);
2542 CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset);
2543
2544 return primitive;
2545}
2546
2547
2548size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg)
2549{
2550 size_t bufferSize = 2;
2551
2552 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */
2553 bufferSize += 2; /* CsrResult primitive->status */
2554 bufferSize += 1; /* u8 primitive->coexInfo.hasTrafficData */
2555 bufferSize += 1; /* CsrWifiSmeTrafficType primitive->coexInfo.currentTrafficType */
2556 bufferSize += 2; /* u16 primitive->coexInfo.currentPeriodMs */
2557 bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->coexInfo.currentPowerSave */
2558 bufferSize += 2; /* u16 primitive->coexInfo.currentCoexPeriodMs */
2559 bufferSize += 2; /* u16 primitive->coexInfo.currentCoexLatencyMs */
2560 bufferSize += 1; /* u8 primitive->coexInfo.hasBtDevice */
2561 bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutDurationUs */
2562 bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutPeriodUs */
2563 bufferSize += 1; /* CsrWifiSmeCoexScheme primitive->coexInfo.currentCoexScheme */
2564 return bufferSize;
2565}
2566
2567
2568u8* CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
2569{
2570 CsrWifiSmeCoexInfoGetCfm *primitive = (CsrWifiSmeCoexInfoGetCfm *)msg;
2571 *len = 0;
2572 CsrUint16Ser(ptr, len, primitive->common.type);
2573 CsrUint16Ser(ptr, len, (u16) primitive->status);
2574 CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasTrafficData);
2575 CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentTrafficType);
2576 CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentPeriodMs);
2577 CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentPowerSave);
2578 CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexPeriodMs);
2579 CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexLatencyMs);
2580 CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasBtDevice);
2581 CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutDurationUs);
2582 CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutPeriodUs);
2583 CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentCoexScheme);
2584 return(ptr);
2585}
2586
2587
2588void* CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t length)
2589{
2590 CsrWifiSmeCoexInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL);
2591 size_t offset;
2592 offset = 0;
2593
2594 CsrUint16Des(&primitive->common.type, buffer, &offset);
2595 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2596 CsrUint8Des((u8 *) &primitive->coexInfo.hasTrafficData, buffer, &offset);
2597 CsrUint8Des((u8 *) &primitive->coexInfo.currentTrafficType, buffer, &offset);
2598 CsrUint16Des((u16 *) &primitive->coexInfo.currentPeriodMs, buffer, &offset);
2599 CsrUint8Des((u8 *) &primitive->coexInfo.currentPowerSave, buffer, &offset);
2600 CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexPeriodMs, buffer, &offset);
2601 CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexLatencyMs, buffer, &offset);
2602 CsrUint8Des((u8 *) &primitive->coexInfo.hasBtDevice, buffer, &offset);
2603 CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutDurationUs, buffer, &offset);
2604 CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutPeriodUs, buffer, &offset);
2605 CsrUint8Des((u8 *) &primitive->coexInfo.currentCoexScheme, buffer, &offset);
2606
2607 return primitive;
2608}
2609
2610
2611size_t CsrWifiSmeConnectCfmSizeof(void *msg)
2612{
2613 size_t bufferSize = 2;
2614
2615 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
2616 bufferSize += 2; /* u16 primitive->interfaceTag */
2617 bufferSize += 2; /* CsrResult primitive->status */
2618 return bufferSize;
2619}
2620
2621
2622u8* CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg)
2623{
2624 CsrWifiSmeConnectCfm *primitive = (CsrWifiSmeConnectCfm *)msg;
2625 *len = 0;
2626 CsrUint16Ser(ptr, len, primitive->common.type);
2627 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2628 CsrUint16Ser(ptr, len, (u16) primitive->status);
2629 return(ptr);
2630}
2631
2632
2633void* CsrWifiSmeConnectCfmDes(u8 *buffer, size_t length)
2634{
2635 CsrWifiSmeConnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL);
2636 size_t offset;
2637 offset = 0;
2638
2639 CsrUint16Des(&primitive->common.type, buffer, &offset);
2640 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2641 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2642
2643 return primitive;
2644}
2645
2646
2647size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg)
2648{
2649 CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) msg;
2650 size_t bufferSize = 2;
2651
2652 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 59) */
2653 bufferSize += 2; /* u16 primitive->interfaceTag */
2654 bufferSize += 2; /* CsrResult primitive->status */
2655 bufferSize += 32; /* u8 primitive->connectionConfig.ssid.ssid[32] */
2656 bufferSize += 1; /* u8 primitive->connectionConfig.ssid.length */
2657 bufferSize += 6; /* u8 primitive->connectionConfig.bssid.a[6] */
2658 bufferSize += 1; /* CsrWifiSmeBssType primitive->connectionConfig.bssType */
2659 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */
2660 bufferSize += 1; /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */
2661 bufferSize += 2; /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */
2662 bufferSize += 2; /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */
2663 bufferSize += 2; /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */
2664 bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */
2665 bufferSize += 1; /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */
2666 bufferSize += 1; /* u8 primitive->connectionConfig.adhocJoinOnly */
2667 bufferSize += 1; /* u8 primitive->connectionConfig.adhocChannel */
2668 return bufferSize;
2669}
2670
2671
2672u8* CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
2673{
2674 CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *)msg;
2675 *len = 0;
2676 CsrUint16Ser(ptr, len, primitive->common.type);
2677 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2678 CsrUint16Ser(ptr, len, (u16) primitive->status);
2679 CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32)));
2680 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length);
2681 CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6)));
2682 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType);
2683 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex);
2684 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode);
2685 CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask);
2686 CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask);
2687 CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength);
2688 if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
2689 {
2690 CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
2691 }
2692 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo);
2693 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly);
2694 CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel);
2695 return(ptr);
2696}
2697
2698
2699void* CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t length)
2700{
2701 CsrWifiSmeConnectionConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL);
2702 size_t offset;
2703 offset = 0;
2704
2705 CsrUint16Des(&primitive->common.type, buffer, &offset);
2706 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2707 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2708 CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32)));
2709 CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset);
2710 CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6)));
2711 CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset);
2712 CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset);
2713 CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset);
2714 CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset);
2715 CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset);
2716 CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset);
2717 if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
2718 {
2719 primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL);
2720 CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
2721 }
2722 else
2723 {
2724 primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL;
2725 }
2726 CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset);
2727 CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset);
2728 CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset);
2729
2730 return primitive;
2731}
2732
2733
2734void CsrWifiSmeConnectionConfigGetCfmSerFree(void *voidPrimitivePointer)
2735{
2736 CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) voidPrimitivePointer;
2737 kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements);
2738 kfree(primitive);
2739}
2740
2741
2742size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg)
2743{
2744 CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) msg;
2745 size_t bufferSize = 2;
2746
2747 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 96) */
2748 bufferSize += 2; /* u16 primitive->interfaceTag */
2749 bufferSize += 2; /* CsrResult primitive->status */
2750 bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */
2751 bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */
2752 bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */
2753 bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
2754 bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */
2755 bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */
2756 bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
2757 bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
2758 bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
2759 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
2760 bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */
2761 bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */
2762 bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */
2763 bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */
2764 bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */
2765 bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */
2766 bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */
2767 bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */
2768 bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */
2769 bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
2770 bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
2771 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */
2772 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
2773 bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
2774 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
2775 bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */
2776 bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
2777 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
2778 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */
2779 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
2780 bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */
2781 return bufferSize;
2782}
2783
2784
2785u8* CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
2786{
2787 CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *)msg;
2788 *len = 0;
2789 CsrUint16Ser(ptr, len, primitive->common.type);
2790 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2791 CsrUint16Ser(ptr, len, (u16) primitive->status);
2792 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
2793 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
2794 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
2795 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
2796 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
2797 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
2798 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
2799 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
2800 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
2801 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
2802 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
2803 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
2804 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
2805 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
2806 if (primitive->connectionInfo.beaconFrameLength)
2807 {
2808 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
2809 }
2810 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
2811 if (primitive->connectionInfo.associationReqFrameLength)
2812 {
2813 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
2814 }
2815 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
2816 if (primitive->connectionInfo.associationRspFrameLength)
2817 {
2818 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
2819 }
2820 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
2821 if (primitive->connectionInfo.assocScanInfoElementsLength)
2822 {
2823 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
2824 }
2825 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
2826 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
2827 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
2828 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
2829 if (primitive->connectionInfo.assocReqInfoElementsLength)
2830 {
2831 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
2832 }
2833 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
2834 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
2835 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
2836 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
2837 if (primitive->connectionInfo.assocRspInfoElementsLength)
2838 {
2839 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
2840 }
2841 return(ptr);
2842}
2843
2844
2845void* CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t length)
2846{
2847 CsrWifiSmeConnectionInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL);
2848 size_t offset;
2849 offset = 0;
2850
2851 CsrUint16Des(&primitive->common.type, buffer, &offset);
2852 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2853 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
2854 CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
2855 CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
2856 CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
2857 CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
2858 CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
2859 CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
2860 CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
2861 CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
2862 CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
2863 CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
2864 CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
2865 CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
2866 CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
2867 CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
2868 if (primitive->connectionInfo.beaconFrameLength)
2869 {
2870 primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
2871 CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
2872 }
2873 else
2874 {
2875 primitive->connectionInfo.beaconFrame = NULL;
2876 }
2877 CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
2878 if (primitive->connectionInfo.associationReqFrameLength)
2879 {
2880 primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
2881 CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
2882 }
2883 else
2884 {
2885 primitive->connectionInfo.associationReqFrame = NULL;
2886 }
2887 CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
2888 if (primitive->connectionInfo.associationRspFrameLength)
2889 {
2890 primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
2891 CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
2892 }
2893 else
2894 {
2895 primitive->connectionInfo.associationRspFrame = NULL;
2896 }
2897 CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
2898 if (primitive->connectionInfo.assocScanInfoElementsLength)
2899 {
2900 primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
2901 CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
2902 }
2903 else
2904 {
2905 primitive->connectionInfo.assocScanInfoElements = NULL;
2906 }
2907 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
2908 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
2909 CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
2910 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
2911 if (primitive->connectionInfo.assocReqInfoElementsLength)
2912 {
2913 primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
2914 CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
2915 }
2916 else
2917 {
2918 primitive->connectionInfo.assocReqInfoElements = NULL;
2919 }
2920 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
2921 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
2922 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
2923 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
2924 if (primitive->connectionInfo.assocRspInfoElementsLength)
2925 {
2926 primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
2927 CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
2928 }
2929 else
2930 {
2931 primitive->connectionInfo.assocRspInfoElements = NULL;
2932 }
2933
2934 return primitive;
2935}
2936
2937
2938void CsrWifiSmeConnectionInfoGetCfmSerFree(void *voidPrimitivePointer)
2939{
2940 CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) voidPrimitivePointer;
2941 kfree(primitive->connectionInfo.beaconFrame);
2942 kfree(primitive->connectionInfo.associationReqFrame);
2943 kfree(primitive->connectionInfo.associationRspFrame);
2944 kfree(primitive->connectionInfo.assocScanInfoElements);
2945 kfree(primitive->connectionInfo.assocReqInfoElements);
2946 kfree(primitive->connectionInfo.assocRspInfoElements);
2947 kfree(primitive);
2948}
2949
2950
2951size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg)
2952{
2953 size_t bufferSize = 2;
2954
2955 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
2956 bufferSize += 2; /* u16 primitive->interfaceTag */
2957 bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */
2958 bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */
2959 return bufferSize;
2960}
2961
2962
2963u8* CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg)
2964{
2965 CsrWifiSmeConnectionQualityInd *primitive = (CsrWifiSmeConnectionQualityInd *)msg;
2966 *len = 0;
2967 CsrUint16Ser(ptr, len, primitive->common.type);
2968 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
2969 CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi);
2970 CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr);
2971 return(ptr);
2972}
2973
2974
2975void* CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t length)
2976{
2977 CsrWifiSmeConnectionQualityInd *primitive = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL);
2978 size_t offset;
2979 offset = 0;
2980
2981 CsrUint16Des(&primitive->common.type, buffer, &offset);
2982 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
2983 CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset);
2984 CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset);
2985
2986 return primitive;
2987}
2988
2989
2990size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg)
2991{
2992 size_t bufferSize = 2;
2993
2994 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 101) */
2995 bufferSize += 2; /* u16 primitive->interfaceTag */
2996 bufferSize += 2; /* CsrResult primitive->status */
2997 bufferSize += 1; /* u8 primitive->connectionStats.unifiTxDataRate */
2998 bufferSize += 1; /* u8 primitive->connectionStats.unifiRxDataRate */
2999 bufferSize += 4; /* u32 primitive->connectionStats.dot11RetryCount */
3000 bufferSize += 4; /* u32 primitive->connectionStats.dot11MultipleRetryCount */
3001 bufferSize += 4; /* u32 primitive->connectionStats.dot11AckFailureCount */
3002 bufferSize += 4; /* u32 primitive->connectionStats.dot11FrameDuplicateCount */
3003 bufferSize += 4; /* u32 primitive->connectionStats.dot11FcsErrorCount */
3004 bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsSuccessCount */
3005 bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsFailureCount */
3006 bufferSize += 4; /* u32 primitive->connectionStats.dot11FailedCount */
3007 bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFragmentCount */
3008 bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFrameCount */
3009 bufferSize += 4; /* u32 primitive->connectionStats.dot11WepExcludedCount */
3010 bufferSize += 4; /* u32 primitive->connectionStats.dot11WepIcvErrorCount */
3011 bufferSize += 4; /* u32 primitive->connectionStats.dot11WepUndecryptableCount */
3012 bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastReceivedFrameCount */
3013 bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastTransmittedFrameCount */
3014 bufferSize += 4; /* u32 primitive->connectionStats.dot11ReceivedFragmentCount */
3015 bufferSize += 4; /* u32 primitive->connectionStats.dot11Rsna4WayHandshakeFailures */
3016 bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked */
3017 bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures */
3018 bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipReplays */
3019 bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipIcvErrors */
3020 bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpReplays */
3021 bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors */
3022 return bufferSize;
3023}
3024
3025
3026u8* CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg)
3027{
3028 CsrWifiSmeConnectionStatsGetCfm *primitive = (CsrWifiSmeConnectionStatsGetCfm *)msg;
3029 *len = 0;
3030 CsrUint16Ser(ptr, len, primitive->common.type);
3031 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3032 CsrUint16Ser(ptr, len, (u16) primitive->status);
3033 CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiTxDataRate);
3034 CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiRxDataRate);
3035 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RetryCount);
3036 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MultipleRetryCount);
3037 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11AckFailureCount);
3038 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FrameDuplicateCount);
3039 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FcsErrorCount);
3040 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsSuccessCount);
3041 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsFailureCount);
3042 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FailedCount);
3043 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFragmentCount);
3044 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFrameCount);
3045 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepExcludedCount);
3046 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepIcvErrorCount);
3047 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepUndecryptableCount);
3048 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastReceivedFrameCount);
3049 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastTransmittedFrameCount);
3050 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11ReceivedFragmentCount);
3051 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11Rsna4WayHandshakeFailures);
3052 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked);
3053 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures);
3054 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipReplays);
3055 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipIcvErrors);
3056 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpReplays);
3057 CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors);
3058 return(ptr);
3059}
3060
3061
3062void* CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t length)
3063{
3064 CsrWifiSmeConnectionStatsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL);
3065 size_t offset;
3066 offset = 0;
3067
3068 CsrUint16Des(&primitive->common.type, buffer, &offset);
3069 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3070 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3071 CsrUint8Des((u8 *) &primitive->connectionStats.unifiTxDataRate, buffer, &offset);
3072 CsrUint8Des((u8 *) &primitive->connectionStats.unifiRxDataRate, buffer, &offset);
3073 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RetryCount, buffer, &offset);
3074 CsrUint32Des((u32 *) &primitive->connectionStats.dot11MultipleRetryCount, buffer, &offset);
3075 CsrUint32Des((u32 *) &primitive->connectionStats.dot11AckFailureCount, buffer, &offset);
3076 CsrUint32Des((u32 *) &primitive->connectionStats.dot11FrameDuplicateCount, buffer, &offset);
3077 CsrUint32Des((u32 *) &primitive->connectionStats.dot11FcsErrorCount, buffer, &offset);
3078 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsSuccessCount, buffer, &offset);
3079 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsFailureCount, buffer, &offset);
3080 CsrUint32Des((u32 *) &primitive->connectionStats.dot11FailedCount, buffer, &offset);
3081 CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFragmentCount, buffer, &offset);
3082 CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFrameCount, buffer, &offset);
3083 CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepExcludedCount, buffer, &offset);
3084 CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepIcvErrorCount, buffer, &offset);
3085 CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepUndecryptableCount, buffer, &offset);
3086 CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastReceivedFrameCount, buffer, &offset);
3087 CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastTransmittedFrameCount, buffer, &offset);
3088 CsrUint32Des((u32 *) &primitive->connectionStats.dot11ReceivedFragmentCount, buffer, &offset);
3089 CsrUint32Des((u32 *) &primitive->connectionStats.dot11Rsna4WayHandshakeFailures, buffer, &offset);
3090 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked, buffer, &offset);
3091 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures, buffer, &offset);
3092 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipReplays, buffer, &offset);
3093 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipIcvErrors, buffer, &offset);
3094 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpReplays, buffer, &offset);
3095 CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors, buffer, &offset);
3096
3097 return primitive;
3098}
3099
3100
3101size_t CsrWifiSmeDisconnectCfmSizeof(void *msg)
3102{
3103 size_t bufferSize = 2;
3104
3105 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
3106 bufferSize += 2; /* u16 primitive->interfaceTag */
3107 bufferSize += 2; /* CsrResult primitive->status */
3108 return bufferSize;
3109}
3110
3111
3112u8* CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg)
3113{
3114 CsrWifiSmeDisconnectCfm *primitive = (CsrWifiSmeDisconnectCfm *)msg;
3115 *len = 0;
3116 CsrUint16Ser(ptr, len, primitive->common.type);
3117 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3118 CsrUint16Ser(ptr, len, (u16) primitive->status);
3119 return(ptr);
3120}
3121
3122
3123void* CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t length)
3124{
3125 CsrWifiSmeDisconnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL);
3126 size_t offset;
3127 offset = 0;
3128
3129 CsrUint16Des(&primitive->common.type, buffer, &offset);
3130 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3131 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3132
3133 return primitive;
3134}
3135
3136
3137size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg)
3138{
3139 size_t bufferSize = 2;
3140
3141 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
3142 bufferSize += 2; /* u16 primitive->interfaceTag */
3143 bufferSize += 2; /* CsrResult primitive->status */
3144 bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */
3145 bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */
3146 return bufferSize;
3147}
3148
3149
3150u8* CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
3151{
3152 CsrWifiSmeHostConfigGetCfm *primitive = (CsrWifiSmeHostConfigGetCfm *)msg;
3153 *len = 0;
3154 CsrUint16Ser(ptr, len, primitive->common.type);
3155 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3156 CsrUint16Ser(ptr, len, (u16) primitive->status);
3157 CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode);
3158 CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs);
3159 return(ptr);
3160}
3161
3162
3163void* CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t length)
3164{
3165 CsrWifiSmeHostConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL);
3166 size_t offset;
3167 offset = 0;
3168
3169 CsrUint16Des(&primitive->common.type, buffer, &offset);
3170 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3171 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3172 CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset);
3173 CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset);
3174
3175 return primitive;
3176}
3177
3178
3179size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg)
3180{
3181 size_t bufferSize = 2;
3182
3183 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
3184 bufferSize += 2; /* u16 primitive->interfaceTag */
3185 bufferSize += 2; /* CsrResult primitive->status */
3186 return bufferSize;
3187}
3188
3189
3190u8* CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
3191{
3192 CsrWifiSmeHostConfigSetCfm *primitive = (CsrWifiSmeHostConfigSetCfm *)msg;
3193 *len = 0;
3194 CsrUint16Ser(ptr, len, primitive->common.type);
3195 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3196 CsrUint16Ser(ptr, len, (u16) primitive->status);
3197 return(ptr);
3198}
3199
3200
3201void* CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t length)
3202{
3203 CsrWifiSmeHostConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL);
3204 size_t offset;
3205 offset = 0;
3206
3207 CsrUint16Des(&primitive->common.type, buffer, &offset);
3208 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3209 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3210
3211 return primitive;
3212}
3213
3214
3215size_t CsrWifiSmeIbssStationIndSizeof(void *msg)
3216{
3217 size_t bufferSize = 2;
3218
3219 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
3220 bufferSize += 6; /* u8 primitive->address.a[6] */
3221 bufferSize += 1; /* u8 primitive->isconnected */
3222 return bufferSize;
3223}
3224
3225
3226u8* CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg)
3227{
3228 CsrWifiSmeIbssStationInd *primitive = (CsrWifiSmeIbssStationInd *)msg;
3229 *len = 0;
3230 CsrUint16Ser(ptr, len, primitive->common.type);
3231 CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
3232 CsrUint8Ser(ptr, len, (u8) primitive->isconnected);
3233 return(ptr);
3234}
3235
3236
3237void* CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t length)
3238{
3239 CsrWifiSmeIbssStationInd *primitive = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL);
3240 size_t offset;
3241 offset = 0;
3242
3243 CsrUint16Des(&primitive->common.type, buffer, &offset);
3244 CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
3245 CsrUint8Des((u8 *) &primitive->isconnected, buffer, &offset);
3246
3247 return primitive;
3248}
3249
3250
3251size_t CsrWifiSmeKeyCfmSizeof(void *msg)
3252{
3253 size_t bufferSize = 2;
3254
3255 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
3256 bufferSize += 2; /* u16 primitive->interfaceTag */
3257 bufferSize += 2; /* CsrResult primitive->status */
3258 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
3259 bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */
3260 bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
3261 return bufferSize;
3262}
3263
3264
3265u8* CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg)
3266{
3267 CsrWifiSmeKeyCfm *primitive = (CsrWifiSmeKeyCfm *)msg;
3268 *len = 0;
3269 CsrUint16Ser(ptr, len, primitive->common.type);
3270 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3271 CsrUint16Ser(ptr, len, (u16) primitive->status);
3272 CsrUint8Ser(ptr, len, (u8) primitive->action);
3273 CsrUint8Ser(ptr, len, (u8) primitive->keyType);
3274 CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
3275 return(ptr);
3276}
3277
3278
3279void* CsrWifiSmeKeyCfmDes(u8 *buffer, size_t length)
3280{
3281 CsrWifiSmeKeyCfm *primitive = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL);
3282 size_t offset;
3283 offset = 0;
3284
3285 CsrUint16Des(&primitive->common.type, buffer, &offset);
3286 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3287 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3288 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
3289 CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset);
3290 CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
3291
3292 return primitive;
3293}
3294
3295
3296size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg)
3297{
3298 size_t bufferSize = 2;
3299
3300 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
3301 bufferSize += 2; /* u16 primitive->interfaceTag */
3302 bufferSize += 2; /* CsrResult primitive->status */
3303 bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */
3304 bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */
3305 return bufferSize;
3306}
3307
3308
3309u8* CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg)
3310{
3311 CsrWifiSmeLinkQualityGetCfm *primitive = (CsrWifiSmeLinkQualityGetCfm *)msg;
3312 *len = 0;
3313 CsrUint16Ser(ptr, len, primitive->common.type);
3314 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3315 CsrUint16Ser(ptr, len, (u16) primitive->status);
3316 CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi);
3317 CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr);
3318 return(ptr);
3319}
3320
3321
3322void* CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t length)
3323{
3324 CsrWifiSmeLinkQualityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL);
3325 size_t offset;
3326 offset = 0;
3327
3328 CsrUint16Des(&primitive->common.type, buffer, &offset);
3329 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3330 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3331 CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset);
3332 CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset);
3333
3334 return primitive;
3335}
3336
3337
3338size_t CsrWifiSmeMediaStatusIndSizeof(void *msg)
3339{
3340 CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) msg;
3341 size_t bufferSize = 2;
3342
3343 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 99) */
3344 bufferSize += 2; /* u16 primitive->interfaceTag */
3345 bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */
3346 bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */
3347 bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */
3348 bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */
3349 bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
3350 bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */
3351 bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */
3352 bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
3353 bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
3354 bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
3355 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
3356 bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */
3357 bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */
3358 bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */
3359 bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */
3360 bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */
3361 bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */
3362 bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */
3363 bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */
3364 bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */
3365 bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
3366 bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
3367 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */
3368 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
3369 bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
3370 bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
3371 bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */
3372 bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
3373 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
3374 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */
3375 bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
3376 bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */
3377 bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->disassocReason */
3378 bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */
3379 return bufferSize;
3380}
3381
3382
3383u8* CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg)
3384{
3385 CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *)msg;
3386 *len = 0;
3387 CsrUint16Ser(ptr, len, primitive->common.type);
3388 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3389 CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
3390 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
3391 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
3392 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
3393 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
3394 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
3395 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
3396 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
3397 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
3398 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
3399 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
3400 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
3401 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
3402 CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
3403 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
3404 if (primitive->connectionInfo.beaconFrameLength)
3405 {
3406 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
3407 }
3408 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
3409 if (primitive->connectionInfo.associationReqFrameLength)
3410 {
3411 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
3412 }
3413 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
3414 if (primitive->connectionInfo.associationRspFrameLength)
3415 {
3416 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
3417 }
3418 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
3419 if (primitive->connectionInfo.assocScanInfoElementsLength)
3420 {
3421 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
3422 }
3423 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
3424 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
3425 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
3426 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
3427 if (primitive->connectionInfo.assocReqInfoElementsLength)
3428 {
3429 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
3430 }
3431 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
3432 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
3433 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
3434 CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
3435 if (primitive->connectionInfo.assocRspInfoElementsLength)
3436 {
3437 CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
3438 }
3439 CsrUint16Ser(ptr, len, (u16) primitive->disassocReason);
3440 CsrUint16Ser(ptr, len, (u16) primitive->deauthReason);
3441 return(ptr);
3442}
3443
3444
3445void* CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t length)
3446{
3447 CsrWifiSmeMediaStatusInd *primitive = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL);
3448 size_t offset;
3449 offset = 0;
3450
3451 CsrUint16Des(&primitive->common.type, buffer, &offset);
3452 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3453 CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
3454 CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
3455 CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
3456 CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
3457 CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
3458 CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
3459 CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
3460 CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
3461 CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
3462 CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
3463 CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
3464 CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
3465 CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
3466 CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
3467 CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
3468 if (primitive->connectionInfo.beaconFrameLength)
3469 {
3470 primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
3471 CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
3472 }
3473 else
3474 {
3475 primitive->connectionInfo.beaconFrame = NULL;
3476 }
3477 CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
3478 if (primitive->connectionInfo.associationReqFrameLength)
3479 {
3480 primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
3481 CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
3482 }
3483 else
3484 {
3485 primitive->connectionInfo.associationReqFrame = NULL;
3486 }
3487 CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
3488 if (primitive->connectionInfo.associationRspFrameLength)
3489 {
3490 primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
3491 CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
3492 }
3493 else
3494 {
3495 primitive->connectionInfo.associationRspFrame = NULL;
3496 }
3497 CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
3498 if (primitive->connectionInfo.assocScanInfoElementsLength)
3499 {
3500 primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
3501 CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
3502 }
3503 else
3504 {
3505 primitive->connectionInfo.assocScanInfoElements = NULL;
3506 }
3507 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
3508 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
3509 CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
3510 CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
3511 if (primitive->connectionInfo.assocReqInfoElementsLength)
3512 {
3513 primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
3514 CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
3515 }
3516 else
3517 {
3518 primitive->connectionInfo.assocReqInfoElements = NULL;
3519 }
3520 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
3521 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
3522 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
3523 CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
3524 if (primitive->connectionInfo.assocRspInfoElementsLength)
3525 {
3526 primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
3527 CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
3528 }
3529 else
3530 {
3531 primitive->connectionInfo.assocRspInfoElements = NULL;
3532 }
3533 CsrUint16Des((u16 *) &primitive->disassocReason, buffer, &offset);
3534 CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset);
3535
3536 return primitive;
3537}
3538
3539
3540void CsrWifiSmeMediaStatusIndSerFree(void *voidPrimitivePointer)
3541{
3542 CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) voidPrimitivePointer;
3543 kfree(primitive->connectionInfo.beaconFrame);
3544 kfree(primitive->connectionInfo.associationReqFrame);
3545 kfree(primitive->connectionInfo.associationRspFrame);
3546 kfree(primitive->connectionInfo.assocScanInfoElements);
3547 kfree(primitive->connectionInfo.assocReqInfoElements);
3548 kfree(primitive->connectionInfo.assocRspInfoElements);
3549 kfree(primitive);
3550}
3551
3552
3553size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg)
3554{
3555 size_t bufferSize = 2;
3556
3557 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
3558 bufferSize += 2; /* CsrResult primitive->status */
3559 bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */
3560 bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */
3561 bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */
3562 bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */
3563 bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */
3564 return bufferSize;
3565}
3566
3567
3568u8* CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
3569{
3570 CsrWifiSmeMibConfigGetCfm *primitive = (CsrWifiSmeMibConfigGetCfm *)msg;
3571 *len = 0;
3572 CsrUint16Ser(ptr, len, primitive->common.type);
3573 CsrUint16Ser(ptr, len, (u16) primitive->status);
3574 CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate);
3575 CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate);
3576 CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold);
3577 CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold);
3578 CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel);
3579 return(ptr);
3580}
3581
3582
3583void* CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t length)
3584{
3585 CsrWifiSmeMibConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL);
3586 size_t offset;
3587 offset = 0;
3588
3589 CsrUint16Des(&primitive->common.type, buffer, &offset);
3590 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3591 CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset);
3592 CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset);
3593 CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset);
3594 CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset);
3595 CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset);
3596
3597 return primitive;
3598}
3599
3600
3601size_t CsrWifiSmeMibGetCfmSizeof(void *msg)
3602{
3603 CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) msg;
3604 size_t bufferSize = 2;
3605
3606 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
3607 bufferSize += 2; /* CsrResult primitive->status */
3608 bufferSize += 2; /* u16 primitive->mibAttributeLength */
3609 bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
3610 return bufferSize;
3611}
3612
3613
3614u8* CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg)
3615{
3616 CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *)msg;
3617 *len = 0;
3618 CsrUint16Ser(ptr, len, primitive->common.type);
3619 CsrUint16Ser(ptr, len, (u16) primitive->status);
3620 CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
3621 if (primitive->mibAttributeLength)
3622 {
3623 CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
3624 }
3625 return(ptr);
3626}
3627
3628
3629void* CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t length)
3630{
3631 CsrWifiSmeMibGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL);
3632 size_t offset;
3633 offset = 0;
3634
3635 CsrUint16Des(&primitive->common.type, buffer, &offset);
3636 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3637 CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
3638 if (primitive->mibAttributeLength)
3639 {
3640 primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
3641 CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
3642 }
3643 else
3644 {
3645 primitive->mibAttribute = NULL;
3646 }
3647
3648 return primitive;
3649}
3650
3651
3652void CsrWifiSmeMibGetCfmSerFree(void *voidPrimitivePointer)
3653{
3654 CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) voidPrimitivePointer;
3655 kfree(primitive->mibAttribute);
3656 kfree(primitive);
3657}
3658
3659
3660size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg)
3661{
3662 CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) msg;
3663 size_t bufferSize = 2;
3664
3665 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
3666 bufferSize += 2; /* CsrResult primitive->status */
3667 bufferSize += 2; /* u16 primitive->mibAttributeLength */
3668 bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
3669 return bufferSize;
3670}
3671
3672
3673u8* CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg)
3674{
3675 CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *)msg;
3676 *len = 0;
3677 CsrUint16Ser(ptr, len, primitive->common.type);
3678 CsrUint16Ser(ptr, len, (u16) primitive->status);
3679 CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
3680 if (primitive->mibAttributeLength)
3681 {
3682 CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
3683 }
3684 return(ptr);
3685}
3686
3687
3688void* CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t length)
3689{
3690 CsrWifiSmeMibGetNextCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL);
3691 size_t offset;
3692 offset = 0;
3693
3694 CsrUint16Des(&primitive->common.type, buffer, &offset);
3695 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3696 CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
3697 if (primitive->mibAttributeLength)
3698 {
3699 primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
3700 CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
3701 }
3702 else
3703 {
3704 primitive->mibAttribute = NULL;
3705 }
3706
3707 return primitive;
3708}
3709
3710
3711void CsrWifiSmeMibGetNextCfmSerFree(void *voidPrimitivePointer)
3712{
3713 CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) voidPrimitivePointer;
3714 kfree(primitive->mibAttribute);
3715 kfree(primitive);
3716}
3717
3718
3719size_t CsrWifiSmeMicFailureIndSizeof(void *msg)
3720{
3721 size_t bufferSize = 2;
3722
3723 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
3724 bufferSize += 2; /* u16 primitive->interfaceTag */
3725 bufferSize += 1; /* u8 primitive->secondFailure */
3726 bufferSize += 2; /* u16 primitive->count */
3727 bufferSize += 6; /* u8 primitive->address.a[6] */
3728 bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */
3729 return bufferSize;
3730}
3731
3732
3733u8* CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg)
3734{
3735 CsrWifiSmeMicFailureInd *primitive = (CsrWifiSmeMicFailureInd *)msg;
3736 *len = 0;
3737 CsrUint16Ser(ptr, len, primitive->common.type);
3738 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3739 CsrUint8Ser(ptr, len, (u8) primitive->secondFailure);
3740 CsrUint16Ser(ptr, len, (u16) primitive->count);
3741 CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
3742 CsrUint8Ser(ptr, len, (u8) primitive->keyType);
3743 return(ptr);
3744}
3745
3746
3747void* CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t length)
3748{
3749 CsrWifiSmeMicFailureInd *primitive = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL);
3750 size_t offset;
3751 offset = 0;
3752
3753 CsrUint16Des(&primitive->common.type, buffer, &offset);
3754 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3755 CsrUint8Des((u8 *) &primitive->secondFailure, buffer, &offset);
3756 CsrUint16Des((u16 *) &primitive->count, buffer, &offset);
3757 CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
3758 CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset);
3759
3760 return primitive;
3761}
3762
3763
3764size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg)
3765{
3766 CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) msg;
3767 size_t bufferSize = 2;
3768
3769 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
3770 bufferSize += 2; /* u16 primitive->interfaceTag */
3771 bufferSize += 2; /* CsrResult primitive->status */
3772 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
3773 bufferSize += 1; /* u8 primitive->getAddressesCount */
3774 {
3775 u16 i1;
3776 for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
3777 {
3778 bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
3779 }
3780 }
3781 return bufferSize;
3782}
3783
3784
3785u8* CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg)
3786{
3787 CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *)msg;
3788 *len = 0;
3789 CsrUint16Ser(ptr, len, primitive->common.type);
3790 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3791 CsrUint16Ser(ptr, len, (u16) primitive->status);
3792 CsrUint8Ser(ptr, len, (u8) primitive->action);
3793 CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount);
3794 {
3795 u16 i1;
3796 for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
3797 {
3798 CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
3799 }
3800 }
3801 return(ptr);
3802}
3803
3804
3805void* CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t length)
3806{
3807 CsrWifiSmeMulticastAddressCfm *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL);
3808 size_t offset;
3809 offset = 0;
3810
3811 CsrUint16Des(&primitive->common.type, buffer, &offset);
3812 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3813 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3814 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
3815 CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset);
3816 primitive->getAddresses = NULL;
3817 if (primitive->getAddressesCount)
3818 {
3819 primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL);
3820 }
3821 {
3822 u16 i1;
3823 for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
3824 {
3825 CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
3826 }
3827 }
3828
3829 return primitive;
3830}
3831
3832
3833void CsrWifiSmeMulticastAddressCfmSerFree(void *voidPrimitivePointer)
3834{
3835 CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) voidPrimitivePointer;
3836 kfree(primitive->getAddresses);
3837 kfree(primitive);
3838}
3839
3840
3841size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg)
3842{
3843 size_t bufferSize = 2;
3844
3845 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
3846 bufferSize += 2; /* u16 primitive->interfaceTag */
3847 bufferSize += 2; /* CsrResult primitive->status */
3848 return bufferSize;
3849}
3850
3851
3852u8* CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg)
3853{
3854 CsrWifiSmePacketFilterSetCfm *primitive = (CsrWifiSmePacketFilterSetCfm *)msg;
3855 *len = 0;
3856 CsrUint16Ser(ptr, len, primitive->common.type);
3857 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3858 CsrUint16Ser(ptr, len, (u16) primitive->status);
3859 return(ptr);
3860}
3861
3862
3863void* CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t length)
3864{
3865 CsrWifiSmePacketFilterSetCfm *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL);
3866 size_t offset;
3867 offset = 0;
3868
3869 CsrUint16Des(&primitive->common.type, buffer, &offset);
3870 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3871 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3872
3873 return primitive;
3874}
3875
3876
3877size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg)
3878{
3879 size_t bufferSize = 2;
3880
3881 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
3882 bufferSize += 2; /* CsrResult primitive->status */
3883 bufferSize += 6; /* u8 primitive->permanentMacAddress.a[6] */
3884 return bufferSize;
3885}
3886
3887
3888u8* CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg)
3889{
3890 CsrWifiSmePermanentMacAddressGetCfm *primitive = (CsrWifiSmePermanentMacAddressGetCfm *)msg;
3891 *len = 0;
3892 CsrUint16Ser(ptr, len, primitive->common.type);
3893 CsrUint16Ser(ptr, len, (u16) primitive->status);
3894 CsrMemCpySer(ptr, len, (const void *) primitive->permanentMacAddress.a, ((u16) (6)));
3895 return(ptr);
3896}
3897
3898
3899void* CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t length)
3900{
3901 CsrWifiSmePermanentMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL);
3902 size_t offset;
3903 offset = 0;
3904
3905 CsrUint16Des(&primitive->common.type, buffer, &offset);
3906 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
3907 CsrMemCpyDes(primitive->permanentMacAddress.a, buffer, &offset, ((u16) (6)));
3908
3909 return primitive;
3910}
3911
3912
3913size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg)
3914{
3915 CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) msg;
3916 size_t bufferSize = 2;
3917
3918 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
3919 bufferSize += 2; /* u16 primitive->interfaceTag */
3920 bufferSize += 1; /* u8 primitive->pmkidCandidatesCount */
3921 {
3922 u16 i1;
3923 for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
3924 {
3925 bufferSize += 6; /* u8 primitive->pmkidCandidates[i1].bssid.a[6] */
3926 bufferSize += 1; /* u8 primitive->pmkidCandidates[i1].preAuthAllowed */
3927 }
3928 }
3929 return bufferSize;
3930}
3931
3932
3933u8* CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg)
3934{
3935 CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *)msg;
3936 *len = 0;
3937 CsrUint16Ser(ptr, len, primitive->common.type);
3938 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
3939 CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidatesCount);
3940 {
3941 u16 i1;
3942 for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
3943 {
3944 CsrMemCpySer(ptr, len, (const void *) primitive->pmkidCandidates[i1].bssid.a, ((u16) (6)));
3945 CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidates[i1].preAuthAllowed);
3946 }
3947 }
3948 return(ptr);
3949}
3950
3951
3952void* CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t length)
3953{
3954 CsrWifiSmePmkidCandidateListInd *primitive = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL);
3955 size_t offset;
3956 offset = 0;
3957
3958 CsrUint16Des(&primitive->common.type, buffer, &offset);
3959 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
3960 CsrUint8Des((u8 *) &primitive->pmkidCandidatesCount, buffer, &offset);
3961 primitive->pmkidCandidates = NULL;
3962 if (primitive->pmkidCandidatesCount)
3963 {
3964 primitive->pmkidCandidates = kmalloc(sizeof(CsrWifiSmePmkidCandidate) * primitive->pmkidCandidatesCount, GFP_KERNEL);
3965 }
3966 {
3967 u16 i1;
3968 for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
3969 {
3970 CsrMemCpyDes(primitive->pmkidCandidates[i1].bssid.a, buffer, &offset, ((u16) (6)));
3971 CsrUint8Des((u8 *) &primitive->pmkidCandidates[i1].preAuthAllowed, buffer, &offset);
3972 }
3973 }
3974
3975 return primitive;
3976}
3977
3978
3979void CsrWifiSmePmkidCandidateListIndSerFree(void *voidPrimitivePointer)
3980{
3981 CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) voidPrimitivePointer;
3982 kfree(primitive->pmkidCandidates);
3983 kfree(primitive);
3984}
3985
3986
3987size_t CsrWifiSmePmkidCfmSizeof(void *msg)
3988{
3989 CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) msg;
3990 size_t bufferSize = 2;
3991
3992 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */
3993 bufferSize += 2; /* u16 primitive->interfaceTag */
3994 bufferSize += 2; /* CsrResult primitive->status */
3995 bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
3996 bufferSize += 1; /* u8 primitive->getPmkidsCount */
3997 {
3998 u16 i1;
3999 for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
4000 {
4001 bufferSize += 6; /* u8 primitive->getPmkids[i1].bssid.a[6] */
4002 bufferSize += 16; /* u8 primitive->getPmkids[i1].pmkid[16] */
4003 }
4004 }
4005 return bufferSize;
4006}
4007
4008
4009u8* CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg)
4010{
4011 CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *)msg;
4012 *len = 0;
4013 CsrUint16Ser(ptr, len, primitive->common.type);
4014 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
4015 CsrUint16Ser(ptr, len, (u16) primitive->status);
4016 CsrUint8Ser(ptr, len, (u8) primitive->action);
4017 CsrUint8Ser(ptr, len, (u8) primitive->getPmkidsCount);
4018 {
4019 u16 i1;
4020 for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
4021 {
4022 CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].bssid.a, ((u16) (6)));
4023 CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].pmkid, ((u16) (16)));
4024 }
4025 }
4026 return(ptr);
4027}
4028
4029
4030void* CsrWifiSmePmkidCfmDes(u8 *buffer, size_t length)
4031{
4032 CsrWifiSmePmkidCfm *primitive = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL);
4033 size_t offset;
4034 offset = 0;
4035
4036 CsrUint16Des(&primitive->common.type, buffer, &offset);
4037 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
4038 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4039 CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
4040 CsrUint8Des((u8 *) &primitive->getPmkidsCount, buffer, &offset);
4041 primitive->getPmkids = NULL;
4042 if (primitive->getPmkidsCount)
4043 {
4044 primitive->getPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->getPmkidsCount, GFP_KERNEL);
4045 }
4046 {
4047 u16 i1;
4048 for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
4049 {
4050 CsrMemCpyDes(primitive->getPmkids[i1].bssid.a, buffer, &offset, ((u16) (6)));
4051 CsrMemCpyDes(primitive->getPmkids[i1].pmkid, buffer, &offset, ((u16) (16)));
4052 }
4053 }
4054
4055 return primitive;
4056}
4057
4058
4059void CsrWifiSmePmkidCfmSerFree(void *voidPrimitivePointer)
4060{
4061 CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) voidPrimitivePointer;
4062 kfree(primitive->getPmkids);
4063 kfree(primitive);
4064}
4065
4066
4067size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg)
4068{
4069 size_t bufferSize = 2;
4070
4071 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
4072 bufferSize += 2; /* CsrResult primitive->status */
4073 bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */
4074 bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */
4075 bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */
4076 bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */
4077 bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */
4078 bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */
4079 bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */
4080 return bufferSize;
4081}
4082
4083
4084u8* CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
4085{
4086 CsrWifiSmePowerConfigGetCfm *primitive = (CsrWifiSmePowerConfigGetCfm *)msg;
4087 *len = 0;
4088 CsrUint16Ser(ptr, len, primitive->common.type);
4089 CsrUint16Ser(ptr, len, (u16) primitive->status);
4090 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel);
4091 CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu);
4092 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims);
4093 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode);
4094 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow);
4095 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave);
4096 CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence);
4097 return(ptr);
4098}
4099
4100
4101void* CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t length)
4102{
4103 CsrWifiSmePowerConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL);
4104 size_t offset;
4105 offset = 0;
4106
4107 CsrUint16Des(&primitive->common.type, buffer, &offset);
4108 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4109 CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset);
4110 CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset);
4111 CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset);
4112 CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset);
4113 CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset);
4114 CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset);
4115 CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset);
4116
4117 return primitive;
4118}
4119
4120
4121size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg)
4122{
4123 size_t bufferSize = 2;
4124
4125 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
4126 bufferSize += 2; /* CsrResult primitive->status */
4127 bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityImplemented */
4128 bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityEnabled */
4129 bufferSize += 1; /* CsrWifiSmeRegulatoryDomain primitive->regDomInfo.currentRegulatoryDomain */
4130 bufferSize += 2; /* u8 primitive->regDomInfo.currentCountryCode[2] */
4131 return bufferSize;
4132}
4133
4134
4135u8* CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
4136{
4137 CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = (CsrWifiSmeRegulatoryDomainInfoGetCfm *)msg;
4138 *len = 0;
4139 CsrUint16Ser(ptr, len, primitive->common.type);
4140 CsrUint16Ser(ptr, len, (u16) primitive->status);
4141 CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityImplemented);
4142 CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityEnabled);
4143 CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.currentRegulatoryDomain);
4144 CsrMemCpySer(ptr, len, (const void *) primitive->regDomInfo.currentCountryCode, ((u16) (2)));
4145 return(ptr);
4146}
4147
4148
4149void* CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t length)
4150{
4151 CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL);
4152 size_t offset;
4153 offset = 0;
4154
4155 CsrUint16Des(&primitive->common.type, buffer, &offset);
4156 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4157 CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityImplemented, buffer, &offset);
4158 CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityEnabled, buffer, &offset);
4159 CsrUint8Des((u8 *) &primitive->regDomInfo.currentRegulatoryDomain, buffer, &offset);
4160 CsrMemCpyDes(primitive->regDomInfo.currentCountryCode, buffer, &offset, ((u16) (2)));
4161
4162 return primitive;
4163}
4164
4165
4166size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg)
4167{
4168 size_t bufferSize = 2;
4169
4170 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
4171 bufferSize += 2; /* u16 primitive->interfaceTag */
4172 bufferSize += 2; /* CsrResult primitive->status */
4173 return bufferSize;
4174}
4175
4176
4177u8* CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg)
4178{
4179 CsrWifiSmeRoamCompleteInd *primitive = (CsrWifiSmeRoamCompleteInd *)msg;
4180 *len = 0;
4181 CsrUint16Ser(ptr, len, primitive->common.type);
4182 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
4183 CsrUint16Ser(ptr, len, (u16) primitive->status);
4184 return(ptr);
4185}
4186
4187
4188void* CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t length)
4189{
4190 CsrWifiSmeRoamCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL);
4191 size_t offset;
4192 offset = 0;
4193
4194 CsrUint16Des(&primitive->common.type, buffer, &offset);
4195 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
4196 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4197
4198 return primitive;
4199}
4200
4201
4202size_t CsrWifiSmeRoamStartIndSizeof(void *msg)
4203{
4204 size_t bufferSize = 2;
4205
4206 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
4207 bufferSize += 2; /* u16 primitive->interfaceTag */
4208 bufferSize += 1; /* CsrWifiSmeRoamReason primitive->roamReason */
4209 bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->reason80211 */
4210 return bufferSize;
4211}
4212
4213
4214u8* CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg)
4215{
4216 CsrWifiSmeRoamStartInd *primitive = (CsrWifiSmeRoamStartInd *)msg;
4217 *len = 0;
4218 CsrUint16Ser(ptr, len, primitive->common.type);
4219 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
4220 CsrUint8Ser(ptr, len, (u8) primitive->roamReason);
4221 CsrUint16Ser(ptr, len, (u16) primitive->reason80211);
4222 return(ptr);
4223}
4224
4225
4226void* CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t length)
4227{
4228 CsrWifiSmeRoamStartInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL);
4229 size_t offset;
4230 offset = 0;
4231
4232 CsrUint16Des(&primitive->common.type, buffer, &offset);
4233 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
4234 CsrUint8Des((u8 *) &primitive->roamReason, buffer, &offset);
4235 CsrUint16Des((u16 *) &primitive->reason80211, buffer, &offset);
4236
4237 return primitive;
4238}
4239
4240
4241size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg)
4242{
4243 size_t bufferSize = 2;
4244
4245 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 72) */
4246 bufferSize += 2; /* u16 primitive->interfaceTag */
4247 bufferSize += 2; /* CsrResult primitive->status */
4248 {
4249 u16 i2;
4250 for (i2 = 0; i2 < 3; i2++)
4251 {
4252 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */
4253 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */
4254 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */
4255 bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */
4256 }
4257 }
4258 bufferSize += 1; /* u8 primitive->roamingConfig.disableSmoothRoaming */
4259 bufferSize += 1; /* u8 primitive->roamingConfig.disableRoamScans */
4260 bufferSize += 1; /* u8 primitive->roamingConfig.reconnectLimit */
4261 bufferSize += 2; /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */
4262 {
4263 u16 i2;
4264 for (i2 = 0; i2 < 3; i2++)
4265 {
4266 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */
4267 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */
4268 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */
4269 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */
4270 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */
4271 bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */
4272 }
4273 }
4274 return bufferSize;
4275}
4276
4277
4278u8* CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
4279{
4280 CsrWifiSmeRoamingConfigGetCfm *primitive = (CsrWifiSmeRoamingConfigGetCfm *)msg;
4281 *len = 0;
4282 CsrUint16Ser(ptr, len, primitive->common.type);
4283 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
4284 CsrUint16Ser(ptr, len, (u16) primitive->status);
4285 {
4286 u16 i2;
4287 for (i2 = 0; i2 < 3; i2++)
4288 {
4289 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold);
4290 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold);
4291 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold);
4292 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold);
4293 }
4294 }
4295 CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming);
4296 CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans);
4297 CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit);
4298 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs);
4299 {
4300 u16 i2;
4301 for (i2 = 0; i2 < 3; i2++)
4302 {
4303 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds);
4304 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds);
4305 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu);
4306 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu);
4307 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu);
4308 CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu);
4309 }
4310 }
4311 return(ptr);
4312}
4313
4314
4315void* CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t length)
4316{
4317 CsrWifiSmeRoamingConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL);
4318 size_t offset;
4319 offset = 0;
4320
4321 CsrUint16Des(&primitive->common.type, buffer, &offset);
4322 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
4323 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4324 {
4325 u16 i2;
4326 for (i2 = 0; i2 < 3; i2++)
4327 {
4328 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset);
4329 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset);
4330 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset);
4331 CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset);
4332 }
4333 }
4334 CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset);
4335 CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset);
4336 CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset);
4337 CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset);
4338 {
4339 u16 i2;
4340 for (i2 = 0; i2 < 3; i2++)
4341 {
4342 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset);
4343 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset);
4344 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
4345 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
4346 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
4347 CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
4348 }
4349 }
4350
4351 return primitive;
4352}
4353
4354
4355size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg)
4356{
4357 size_t bufferSize = 2;
4358
4359 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
4360 bufferSize += 2; /* u16 primitive->interfaceTag */
4361 bufferSize += 2; /* CsrResult primitive->status */
4362 return bufferSize;
4363}
4364
4365
4366u8* CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
4367{
4368 CsrWifiSmeRoamingConfigSetCfm *primitive = (CsrWifiSmeRoamingConfigSetCfm *)msg;
4369 *len = 0;
4370 CsrUint16Ser(ptr, len, primitive->common.type);
4371 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
4372 CsrUint16Ser(ptr, len, (u16) primitive->status);
4373 return(ptr);
4374}
4375
4376
4377void* CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t length)
4378{
4379 CsrWifiSmeRoamingConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL);
4380 size_t offset;
4381 offset = 0;
4382
4383 CsrUint16Des(&primitive->common.type, buffer, &offset);
4384 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
4385 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4386
4387 return primitive;
4388}
4389
4390
4391size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg)
4392{
4393 CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) msg;
4394 size_t bufferSize = 2;
4395
4396 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */
4397 bufferSize += 2; /* CsrResult primitive->status */
4398 {
4399 u16 i2;
4400 for (i2 = 0; i2 < 4; i2++)
4401 {
4402 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */
4403 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */
4404 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */
4405 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */
4406 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */
4407 bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */
4408 }
4409 }
4410 bufferSize += 1; /* u8 primitive->scanConfig.disableAutonomousScans */
4411 bufferSize += 2; /* u16 primitive->scanConfig.maxResults */
4412 bufferSize += 1; /* s8 primitive->scanConfig.highRssiThreshold */
4413 bufferSize += 1; /* s8 primitive->scanConfig.lowRssiThreshold */
4414 bufferSize += 1; /* s8 primitive->scanConfig.deltaRssiThreshold */
4415 bufferSize += 1; /* s8 primitive->scanConfig.highSnrThreshold */
4416 bufferSize += 1; /* s8 primitive->scanConfig.lowSnrThreshold */
4417 bufferSize += 1; /* s8 primitive->scanConfig.deltaSnrThreshold */
4418 bufferSize += 2; /* u16 primitive->scanConfig.passiveChannelListCount */
4419 bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */
4420 return bufferSize;
4421}
4422
4423
4424u8* CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
4425{
4426 CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *)msg;
4427 *len = 0;
4428 CsrUint16Ser(ptr, len, primitive->common.type);
4429 CsrUint16Ser(ptr, len, (u16) primitive->status);
4430 {
4431 u16 i2;
4432 for (i2 = 0; i2 < 4; i2++)
4433 {
4434 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds);
4435 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds);
4436 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu);
4437 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu);
4438 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu);
4439 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu);
4440 }
4441 }
4442 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans);
4443 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults);
4444 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold);
4445 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold);
4446 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold);
4447 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold);
4448 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold);
4449 CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold);
4450 CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount);
4451 if (primitive->scanConfig.passiveChannelListCount)
4452 {
4453 CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount)));
4454 }
4455 return(ptr);
4456}
4457
4458
4459void* CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t length)
4460{
4461 CsrWifiSmeScanConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL);
4462 size_t offset;
4463 offset = 0;
4464
4465 CsrUint16Des(&primitive->common.type, buffer, &offset);
4466 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4467 {
4468 u16 i2;
4469 for (i2 = 0; i2 < 4; i2++)
4470 {
4471 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset);
4472 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset);
4473 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
4474 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
4475 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
4476 CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
4477 }
4478 }
4479 CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset);
4480 CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset);
4481 CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset);
4482 CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset);
4483 CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset);
4484 CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset);
4485 CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset);
4486 CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset);
4487 CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset);
4488 if (primitive->scanConfig.passiveChannelListCount)
4489 {
4490 primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL);
4491 CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount)));
4492 }
4493 else
4494 {
4495 primitive->scanConfig.passiveChannelList = NULL;
4496 }
4497
4498 return primitive;
4499}
4500
4501
4502void CsrWifiSmeScanConfigGetCfmSerFree(void *voidPrimitivePointer)
4503{
4504 CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) voidPrimitivePointer;
4505 kfree(primitive->scanConfig.passiveChannelList);
4506 kfree(primitive);
4507}
4508
4509
4510size_t CsrWifiSmeScanResultIndSizeof(void *msg)
4511{
4512 CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) msg;
4513 size_t bufferSize = 2;
4514
4515 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 149) */
4516 bufferSize += 32; /* u8 primitive->result.ssid.ssid[32] */
4517 bufferSize += 1; /* u8 primitive->result.ssid.length */
4518 bufferSize += 6; /* u8 primitive->result.bssid.a[6] */
4519 bufferSize += 2; /* s16 primitive->result.rssi */
4520 bufferSize += 2; /* s16 primitive->result.snr */
4521 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->result.ifIndex */
4522 bufferSize += 2; /* u16 primitive->result.beaconPeriodTu */
4523 bufferSize += 8; /* u8 primitive->result.timeStamp.data[8] */
4524 bufferSize += 8; /* u8 primitive->result.localTime.data[8] */
4525 bufferSize += 2; /* u16 primitive->result.channelFrequency */
4526 bufferSize += 2; /* u16 primitive->result.capabilityInformation */
4527 bufferSize += 1; /* u8 primitive->result.channelNumber */
4528 bufferSize += 1; /* CsrWifiSmeBasicUsability primitive->result.usability */
4529 bufferSize += 1; /* CsrWifiSmeBssType primitive->result.bssType */
4530 bufferSize += 2; /* u16 primitive->result.informationElementsLength */
4531 bufferSize += primitive->result.informationElementsLength; /* u8 primitive->result.informationElements */
4532 bufferSize += 1; /* CsrWifiSmeP2pRole primitive->result.p2pDeviceRole */
4533 switch (primitive->result.p2pDeviceRole)
4534 {
4535 case CSR_WIFI_SME_P2P_ROLE_CLI:
4536 bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedCli.empty */
4537 break;
4538 case CSR_WIFI_SME_P2P_ROLE_GO:
4539 bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->result.deviceInfo.groupInfo.groupCapability */
4540 bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a[6] */
4541 bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2pClientInfoCount */
4542 {
4543 u16 i4;
4544 for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
4545 {
4546 bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */
4547 bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */
4548 bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */
4549 bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */
4550 bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */
4551 bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */
4552 {
4553 u16 i6;
4554 for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
4555 {
4556 bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */
4557 }
4558 }
4559 bufferSize += 32; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */
4560 bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */
4561 }
4562 }
4563 break;
4564 case CSR_WIFI_SME_P2P_ROLE_NONE:
4565 bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedNone.empty */
4566 break;
4567 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
4568 bufferSize += 6; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a[6] */
4569 bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.standalonedevInfo.configMethods */
4570 bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap */
4571 bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */
4572 bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */
4573 {
4574 u16 i4;
4575 for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
4576 {
4577 bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */
4578 }
4579 }
4580 bufferSize += 32; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceName[32] */
4581 bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceNameLength */
4582 break;
4583 default:
4584 break;
4585 }
4586 return bufferSize;
4587}
4588
4589
4590u8* CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg)
4591{
4592 CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *)msg;
4593 *len = 0;
4594 CsrUint16Ser(ptr, len, primitive->common.type);
4595 CsrMemCpySer(ptr, len, (const void *) primitive->result.ssid.ssid, ((u16) (32)));
4596 CsrUint8Ser(ptr, len, (u8) primitive->result.ssid.length);
4597 CsrMemCpySer(ptr, len, (const void *) primitive->result.bssid.a, ((u16) (6)));
4598 CsrUint16Ser(ptr, len, (u16) primitive->result.rssi);
4599 CsrUint16Ser(ptr, len, (u16) primitive->result.snr);
4600 CsrUint8Ser(ptr, len, (u8) primitive->result.ifIndex);
4601 CsrUint16Ser(ptr, len, (u16) primitive->result.beaconPeriodTu);
4602 CsrMemCpySer(ptr, len, (const void *) primitive->result.timeStamp.data, ((u16) (8)));
4603 CsrMemCpySer(ptr, len, (const void *) primitive->result.localTime.data, ((u16) (8)));
4604 CsrUint16Ser(ptr, len, (u16) primitive->result.channelFrequency);
4605 CsrUint16Ser(ptr, len, (u16) primitive->result.capabilityInformation);
4606 CsrUint8Ser(ptr, len, (u8) primitive->result.channelNumber);
4607 CsrUint8Ser(ptr, len, (u8) primitive->result.usability);
4608 CsrUint8Ser(ptr, len, (u8) primitive->result.bssType);
4609 CsrUint16Ser(ptr, len, (u16) primitive->result.informationElementsLength);
4610 if (primitive->result.informationElementsLength)
4611 {
4612 CsrMemCpySer(ptr, len, (const void *) primitive->result.informationElements, ((u16) (primitive->result.informationElementsLength)));
4613 }
4614 CsrUint8Ser(ptr, len, (u8) primitive->result.p2pDeviceRole);
4615 switch (primitive->result.p2pDeviceRole)
4616 {
4617 case CSR_WIFI_SME_P2P_ROLE_CLI:
4618 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedCli.empty);
4619 break;
4620 case CSR_WIFI_SME_P2P_ROLE_GO:
4621 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.groupCapability);
4622 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6)));
4623 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2pClientInfoCount);
4624 {
4625 u16 i4;
4626 for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
4627 {
4628 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6)));
4629 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6)));
4630 CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods);
4631 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap);
4632 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8)));
4633 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount);
4634 {
4635 u16 i6;
4636 for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
4637 {
4638 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8)));
4639 }
4640 }
4641 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32)));
4642 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength);
4643 }
4644 }
4645 break;
4646 case CSR_WIFI_SME_P2P_ROLE_NONE:
4647 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedNone.empty);
4648 break;
4649 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
4650 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6)));
4651 CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.standalonedevInfo.configMethods);
4652 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap);
4653 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8)));
4654 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount);
4655 {
4656 u16 i4;
4657 for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
4658 {
4659 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8)));
4660 }
4661 }
4662 CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceName, ((u16) (32)));
4663 CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.deviceNameLength);
4664 break;
4665 default:
4666 break;
4667 }
4668 return(ptr);
4669}
4670
4671
4672void* CsrWifiSmeScanResultIndDes(u8 *buffer, size_t length)
4673{
4674 CsrWifiSmeScanResultInd *primitive = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL);
4675 size_t offset;
4676 offset = 0;
4677
4678 CsrUint16Des(&primitive->common.type, buffer, &offset);
4679 CsrMemCpyDes(primitive->result.ssid.ssid, buffer, &offset, ((u16) (32)));
4680 CsrUint8Des((u8 *) &primitive->result.ssid.length, buffer, &offset);
4681 CsrMemCpyDes(primitive->result.bssid.a, buffer, &offset, ((u16) (6)));
4682 CsrUint16Des((u16 *) &primitive->result.rssi, buffer, &offset);
4683 CsrUint16Des((u16 *) &primitive->result.snr, buffer, &offset);
4684 CsrUint8Des((u8 *) &primitive->result.ifIndex, buffer, &offset);
4685 CsrUint16Des((u16 *) &primitive->result.beaconPeriodTu, buffer, &offset);
4686 CsrMemCpyDes(primitive->result.timeStamp.data, buffer, &offset, ((u16) (8)));
4687 CsrMemCpyDes(primitive->result.localTime.data, buffer, &offset, ((u16) (8)));
4688 CsrUint16Des((u16 *) &primitive->result.channelFrequency, buffer, &offset);
4689 CsrUint16Des((u16 *) &primitive->result.capabilityInformation, buffer, &offset);
4690 CsrUint8Des((u8 *) &primitive->result.channelNumber, buffer, &offset);
4691 CsrUint8Des((u8 *) &primitive->result.usability, buffer, &offset);
4692 CsrUint8Des((u8 *) &primitive->result.bssType, buffer, &offset);
4693 CsrUint16Des((u16 *) &primitive->result.informationElementsLength, buffer, &offset);
4694 if (primitive->result.informationElementsLength)
4695 {
4696 primitive->result.informationElements = kmalloc(primitive->result.informationElementsLength, GFP_KERNEL);
4697 CsrMemCpyDes(primitive->result.informationElements, buffer, &offset, ((u16) (primitive->result.informationElementsLength)));
4698 }
4699 else
4700 {
4701 primitive->result.informationElements = NULL;
4702 }
4703 CsrUint8Des((u8 *) &primitive->result.p2pDeviceRole, buffer, &offset);
4704 switch (primitive->result.p2pDeviceRole)
4705 {
4706 case CSR_WIFI_SME_P2P_ROLE_CLI:
4707 CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedCli.empty, buffer, &offset);
4708 break;
4709 case CSR_WIFI_SME_P2P_ROLE_GO:
4710 CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.groupCapability, buffer, &offset);
4711 CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6)));
4712 CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset);
4713 primitive->result.deviceInfo.groupInfo.p2PClientInfo = NULL;
4714 if (primitive->result.deviceInfo.groupInfo.p2pClientInfoCount)
4715 {
4716 primitive->result.deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL);
4717 }
4718 {
4719 u16 i4;
4720 for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
4721 {
4722 CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6)));
4723 CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
4724 CsrUint16Des((u16 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset);
4725 CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset);
4726 CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
4727 CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset);
4728 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
4729 if (primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount)
4730 {
4731 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL);
4732 }
4733 {
4734 u16 i6;
4735 for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
4736 {
4737 CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8)));
4738 }
4739 }
4740 CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32)));
4741 CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset);
4742 }
4743 }
4744 break;
4745 case CSR_WIFI_SME_P2P_ROLE_NONE:
4746 CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedNone.empty, buffer, &offset);
4747 break;
4748 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
4749 CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
4750 CsrUint16Des((u16 *) &primitive->result.deviceInfo.standalonedevInfo.configMethods, buffer, &offset);
4751 CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset);
4752 CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
4753 CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset);
4754 primitive->result.deviceInfo.standalonedevInfo.secDeviceType = NULL;
4755 if (primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount)
4756 {
4757 primitive->result.deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL);
4758 }
4759 {
4760 u16 i4;
4761 for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
4762 {
4763 CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8)));
4764 }
4765 }
4766 CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32)));
4767 CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset);
4768 break;
4769 default:
4770 break;
4771 }
4772
4773 return primitive;
4774}
4775
4776
4777void CsrWifiSmeScanResultIndSerFree(void *voidPrimitivePointer)
4778{
4779 CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) voidPrimitivePointer;
4780 kfree(primitive->result.informationElements);
4781 switch (primitive->result.p2pDeviceRole)
4782 {
4783 case CSR_WIFI_SME_P2P_ROLE_GO:
4784 {
4785 u16 i4;
4786 for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
4787 {
4788 kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
4789 }
4790 }
4791 kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo);
4792 break;
4793 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
4794 kfree(primitive->result.deviceInfo.standalonedevInfo.secDeviceType);
4795 break;
4796 default:
4797 break;
4798 }
4799 kfree(primitive);
4800}
4801
4802
4803size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg)
4804{
4805 CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) msg;
4806 size_t bufferSize = 2;
4807
4808 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 153) */
4809 bufferSize += 2; /* CsrResult primitive->status */
4810 bufferSize += 2; /* u16 primitive->scanResultsCount */
4811 {
4812 u16 i1;
4813 for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
4814 {
4815 bufferSize += 32; /* u8 primitive->scanResults[i1].ssid.ssid[32] */
4816 bufferSize += 1; /* u8 primitive->scanResults[i1].ssid.length */
4817 bufferSize += 6; /* u8 primitive->scanResults[i1].bssid.a[6] */
4818 bufferSize += 2; /* s16 primitive->scanResults[i1].rssi */
4819 bufferSize += 2; /* s16 primitive->scanResults[i1].snr */
4820 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->scanResults[i1].ifIndex */
4821 bufferSize += 2; /* u16 primitive->scanResults[i1].beaconPeriodTu */
4822 bufferSize += 8; /* u8 primitive->scanResults[i1].timeStamp.data[8] */
4823 bufferSize += 8; /* u8 primitive->scanResults[i1].localTime.data[8] */
4824 bufferSize += 2; /* u16 primitive->scanResults[i1].channelFrequency */
4825 bufferSize += 2; /* u16 primitive->scanResults[i1].capabilityInformation */
4826 bufferSize += 1; /* u8 primitive->scanResults[i1].channelNumber */
4827 bufferSize += 1; /* CsrWifiSmeBasicUsability primitive->scanResults[i1].usability */
4828 bufferSize += 1; /* CsrWifiSmeBssType primitive->scanResults[i1].bssType */
4829 bufferSize += 2; /* u16 primitive->scanResults[i1].informationElementsLength */
4830 bufferSize += primitive->scanResults[i1].informationElementsLength; /* u8 primitive->scanResults[i1].informationElements */
4831 bufferSize += 1; /* CsrWifiSmeP2pRole primitive->scanResults[i1].p2pDeviceRole */
4832 switch (primitive->scanResults[i1].p2pDeviceRole)
4833 {
4834 case CSR_WIFI_SME_P2P_ROLE_CLI:
4835 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedCli.empty */
4836 break;
4837 case CSR_WIFI_SME_P2P_ROLE_GO:
4838 bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability */
4839 bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a[6] */
4840 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount */
4841 {
4842 u16 i4;
4843 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
4844 {
4845 bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */
4846 bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */
4847 bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */
4848 bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */
4849 bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */
4850 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */
4851 {
4852 u16 i6;
4853 for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
4854 {
4855 bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */
4856 }
4857 }
4858 bufferSize += 32; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */
4859 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */
4860 }
4861 }
4862 break;
4863 case CSR_WIFI_SME_P2P_ROLE_NONE:
4864 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedNone.empty */
4865 break;
4866 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
4867 bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a[6] */
4868 bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods */
4869 bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap */
4870 bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */
4871 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */
4872 {
4873 u16 i4;
4874 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
4875 {
4876 bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */
4877 }
4878 }
4879 bufferSize += 32; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName[32] */
4880 bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength */
4881 break;
4882 default:
4883 break;
4884 }
4885 }
4886 }
4887 return bufferSize;
4888}
4889
4890
4891u8* CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg)
4892{
4893 CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *)msg;
4894 *len = 0;
4895 CsrUint16Ser(ptr, len, primitive->common.type);
4896 CsrUint16Ser(ptr, len, (u16) primitive->status);
4897 CsrUint16Ser(ptr, len, (u16) primitive->scanResultsCount);
4898 {
4899 u16 i1;
4900 for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
4901 {
4902 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].ssid.ssid, ((u16) (32)));
4903 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ssid.length);
4904 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].bssid.a, ((u16) (6)));
4905 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].rssi);
4906 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].snr);
4907 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ifIndex);
4908 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].beaconPeriodTu);
4909 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].timeStamp.data, ((u16) (8)));
4910 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].localTime.data, ((u16) (8)));
4911 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].channelFrequency);
4912 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].capabilityInformation);
4913 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].channelNumber);
4914 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].usability);
4915 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].bssType);
4916 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].informationElementsLength);
4917 if (primitive->scanResults[i1].informationElementsLength)
4918 {
4919 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].informationElements, ((u16) (primitive->scanResults[i1].informationElementsLength)));
4920 }
4921 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].p2pDeviceRole);
4922 switch (primitive->scanResults[i1].p2pDeviceRole)
4923 {
4924 case CSR_WIFI_SME_P2P_ROLE_CLI:
4925 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedCli.empty);
4926 break;
4927 case CSR_WIFI_SME_P2P_ROLE_GO:
4928 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability);
4929 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6)));
4930 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount);
4931 {
4932 u16 i4;
4933 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
4934 {
4935 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6)));
4936 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6)));
4937 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods);
4938 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap);
4939 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8)));
4940 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount);
4941 {
4942 u16 i6;
4943 for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
4944 {
4945 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8)));
4946 }
4947 }
4948 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32)));
4949 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength);
4950 }
4951 }
4952 break;
4953 case CSR_WIFI_SME_P2P_ROLE_NONE:
4954 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedNone.empty);
4955 break;
4956 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
4957 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6)));
4958 CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods);
4959 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap);
4960 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8)));
4961 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount);
4962 {
4963 u16 i4;
4964 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
4965 {
4966 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8)));
4967 }
4968 }
4969 CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, ((u16) (32)));
4970 CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength);
4971 break;
4972 default:
4973 break;
4974 }
4975 }
4976 }
4977 return(ptr);
4978}
4979
4980
4981void* CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t length)
4982{
4983 CsrWifiSmeScanResultsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL);
4984 size_t offset;
4985 offset = 0;
4986
4987 CsrUint16Des(&primitive->common.type, buffer, &offset);
4988 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
4989 CsrUint16Des((u16 *) &primitive->scanResultsCount, buffer, &offset);
4990 primitive->scanResults = NULL;
4991 if (primitive->scanResultsCount)
4992 {
4993 primitive->scanResults = kmalloc(sizeof(CsrWifiSmeScanResult) * primitive->scanResultsCount, GFP_KERNEL);
4994 }
4995 {
4996 u16 i1;
4997 for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
4998 {
4999 CsrMemCpyDes(primitive->scanResults[i1].ssid.ssid, buffer, &offset, ((u16) (32)));
5000 CsrUint8Des((u8 *) &primitive->scanResults[i1].ssid.length, buffer, &offset);
5001 CsrMemCpyDes(primitive->scanResults[i1].bssid.a, buffer, &offset, ((u16) (6)));
5002 CsrUint16Des((u16 *) &primitive->scanResults[i1].rssi, buffer, &offset);
5003 CsrUint16Des((u16 *) &primitive->scanResults[i1].snr, buffer, &offset);
5004 CsrUint8Des((u8 *) &primitive->scanResults[i1].ifIndex, buffer, &offset);
5005 CsrUint16Des((u16 *) &primitive->scanResults[i1].beaconPeriodTu, buffer, &offset);
5006 CsrMemCpyDes(primitive->scanResults[i1].timeStamp.data, buffer, &offset, ((u16) (8)));
5007 CsrMemCpyDes(primitive->scanResults[i1].localTime.data, buffer, &offset, ((u16) (8)));
5008 CsrUint16Des((u16 *) &primitive->scanResults[i1].channelFrequency, buffer, &offset);
5009 CsrUint16Des((u16 *) &primitive->scanResults[i1].capabilityInformation, buffer, &offset);
5010 CsrUint8Des((u8 *) &primitive->scanResults[i1].channelNumber, buffer, &offset);
5011 CsrUint8Des((u8 *) &primitive->scanResults[i1].usability, buffer, &offset);
5012 CsrUint8Des((u8 *) &primitive->scanResults[i1].bssType, buffer, &offset);
5013 CsrUint16Des((u16 *) &primitive->scanResults[i1].informationElementsLength, buffer, &offset);
5014 if (primitive->scanResults[i1].informationElementsLength)
5015 {
5016 primitive->scanResults[i1].informationElements = kmalloc(primitive->scanResults[i1].informationElementsLength, GFP_KERNEL);
5017 CsrMemCpyDes(primitive->scanResults[i1].informationElements, buffer, &offset, ((u16) (primitive->scanResults[i1].informationElementsLength)));
5018 }
5019 else
5020 {
5021 primitive->scanResults[i1].informationElements = NULL;
5022 }
5023 CsrUint8Des((u8 *) &primitive->scanResults[i1].p2pDeviceRole, buffer, &offset);
5024 switch (primitive->scanResults[i1].p2pDeviceRole)
5025 {
5026 case CSR_WIFI_SME_P2P_ROLE_CLI:
5027 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedCli.empty, buffer, &offset);
5028 break;
5029 case CSR_WIFI_SME_P2P_ROLE_GO:
5030 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability, buffer, &offset);
5031 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6)));
5032 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset);
5033 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL;
5034 if (primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount)
5035 {
5036 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL);
5037 }
5038 {
5039 u16 i4;
5040 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
5041 {
5042 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6)));
5043 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
5044 CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset);
5045 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset);
5046 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
5047 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset);
5048 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
5049 if (primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount)
5050 {
5051 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL);
5052 }
5053 {
5054 u16 i6;
5055 for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
5056 {
5057 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8)));
5058 }
5059 }
5060 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32)));
5061 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset);
5062 }
5063 }
5064 break;
5065 case CSR_WIFI_SME_P2P_ROLE_NONE:
5066 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedNone.empty, buffer, &offset);
5067 break;
5068 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
5069 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
5070 CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods, buffer, &offset);
5071 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset);
5072 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
5073 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset);
5074 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL;
5075 if (primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount)
5076 {
5077 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL);
5078 }
5079 {
5080 u16 i4;
5081 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
5082 {
5083 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8)));
5084 }
5085 }
5086 CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32)));
5087 CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset);
5088 break;
5089 default:
5090 break;
5091 }
5092 }
5093 }
5094
5095 return primitive;
5096}
5097
5098
5099void CsrWifiSmeScanResultsGetCfmSerFree(void *voidPrimitivePointer)
5100{
5101 CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) voidPrimitivePointer;
5102 {
5103 u16 i1;
5104 for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
5105 {
5106 kfree(primitive->scanResults[i1].informationElements);
5107 switch (primitive->scanResults[i1].p2pDeviceRole)
5108 {
5109 case CSR_WIFI_SME_P2P_ROLE_GO:
5110 {
5111 u16 i4;
5112 for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
5113 {
5114 kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
5115 }
5116 }
5117 kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo);
5118 break;
5119 case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
5120 kfree(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType);
5121 break;
5122 default:
5123 break;
5124 }
5125 }
5126 }
5127 kfree(primitive->scanResults);
5128 kfree(primitive);
5129}
5130
5131
5132size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg)
5133{
5134 size_t bufferSize = 2;
5135
5136 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
5137 bufferSize += 2; /* u16 primitive->interfaceTag */
5138 bufferSize += 2; /* CsrResult primitive->status */
5139 bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */
5140 bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */
5141 bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */
5142 bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */
5143 bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */
5144 bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */
5145 return bufferSize;
5146}
5147
5148
5149u8* CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
5150{
5151 CsrWifiSmeSmeStaConfigGetCfm *primitive = (CsrWifiSmeSmeStaConfigGetCfm *)msg;
5152 *len = 0;
5153 CsrUint16Ser(ptr, len, primitive->common.type);
5154 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
5155 CsrUint16Ser(ptr, len, (u16) primitive->status);
5156 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger);
5157 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger);
5158 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask);
5159 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex);
5160 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher);
5161 CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching);
5162 return(ptr);
5163}
5164
5165
5166void* CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t length)
5167{
5168 CsrWifiSmeSmeStaConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL);
5169 size_t offset;
5170 offset = 0;
5171
5172 CsrUint16Des(&primitive->common.type, buffer, &offset);
5173 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
5174 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5175 CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset);
5176 CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset);
5177 CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset);
5178 CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset);
5179 CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset);
5180 CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset);
5181
5182 return primitive;
5183}
5184
5185
5186size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg)
5187{
5188 size_t bufferSize = 2;
5189
5190 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
5191 bufferSize += 2; /* u16 primitive->interfaceTag */
5192 bufferSize += 2; /* CsrResult primitive->status */
5193 return bufferSize;
5194}
5195
5196
5197u8* CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
5198{
5199 CsrWifiSmeSmeStaConfigSetCfm *primitive = (CsrWifiSmeSmeStaConfigSetCfm *)msg;
5200 *len = 0;
5201 CsrUint16Ser(ptr, len, primitive->common.type);
5202 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
5203 CsrUint16Ser(ptr, len, (u16) primitive->status);
5204 return(ptr);
5205}
5206
5207
5208void* CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t length)
5209{
5210 CsrWifiSmeSmeStaConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL);
5211 size_t offset;
5212 offset = 0;
5213
5214 CsrUint16Des(&primitive->common.type, buffer, &offset);
5215 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
5216 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5217
5218 return primitive;
5219}
5220
5221
5222size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg)
5223{
5224 size_t bufferSize = 2;
5225
5226 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
5227 bufferSize += 2; /* CsrResult primitive->status */
5228 {
5229 u16 i1;
5230 for (i1 = 0; i1 < 2; i1++)
5231 {
5232 bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */
5233 }
5234 }
5235 return bufferSize;
5236}
5237
5238
5239u8* CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg)
5240{
5241 CsrWifiSmeStationMacAddressGetCfm *primitive = (CsrWifiSmeStationMacAddressGetCfm *)msg;
5242 *len = 0;
5243 CsrUint16Ser(ptr, len, primitive->common.type);
5244 CsrUint16Ser(ptr, len, (u16) primitive->status);
5245 {
5246 u16 i1;
5247 for (i1 = 0; i1 < 2; i1++)
5248 {
5249 CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6)));
5250 }
5251 }
5252 return(ptr);
5253}
5254
5255
5256void* CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t length)
5257{
5258 CsrWifiSmeStationMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL);
5259 size_t offset;
5260 offset = 0;
5261
5262 CsrUint16Des(&primitive->common.type, buffer, &offset);
5263 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5264 {
5265 u16 i1;
5266 for (i1 = 0; i1 < 2; i1++)
5267 {
5268 CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6)));
5269 }
5270 }
5271
5272 return primitive;
5273}
5274
5275
5276size_t CsrWifiSmeTspecIndSizeof(void *msg)
5277{
5278 CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) msg;
5279 size_t bufferSize = 2;
5280
5281 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
5282 bufferSize += 2; /* u16 primitive->interfaceTag */
5283 bufferSize += 4; /* u32 primitive->transactionId */
5284 bufferSize += 1; /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */
5285 bufferSize += 2; /* u16 primitive->tspecLength */
5286 bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
5287 return bufferSize;
5288}
5289
5290
5291u8* CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg)
5292{
5293 CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *)msg;
5294 *len = 0;
5295 CsrUint16Ser(ptr, len, primitive->common.type);
5296 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
5297 CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
5298 CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode);
5299 CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
5300 if (primitive->tspecLength)
5301 {
5302 CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
5303 }
5304 return(ptr);
5305}
5306
5307
5308void* CsrWifiSmeTspecIndDes(u8 *buffer, size_t length)
5309{
5310 CsrWifiSmeTspecInd *primitive = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL);
5311 size_t offset;
5312 offset = 0;
5313
5314 CsrUint16Des(&primitive->common.type, buffer, &offset);
5315 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
5316 CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
5317 CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset);
5318 CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
5319 if (primitive->tspecLength)
5320 {
5321 primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
5322 CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
5323 }
5324 else
5325 {
5326 primitive->tspec = NULL;
5327 }
5328
5329 return primitive;
5330}
5331
5332
5333void CsrWifiSmeTspecIndSerFree(void *voidPrimitivePointer)
5334{
5335 CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) voidPrimitivePointer;
5336 kfree(primitive->tspec);
5337 kfree(primitive);
5338}
5339
5340
5341size_t CsrWifiSmeTspecCfmSizeof(void *msg)
5342{
5343 CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) msg;
5344 size_t bufferSize = 2;
5345
5346 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
5347 bufferSize += 2; /* u16 primitive->interfaceTag */
5348 bufferSize += 2; /* CsrResult primitive->status */
5349 bufferSize += 4; /* u32 primitive->transactionId */
5350 bufferSize += 1; /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */
5351 bufferSize += 2; /* u16 primitive->tspecLength */
5352 bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
5353 return bufferSize;
5354}
5355
5356
5357u8* CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg)
5358{
5359 CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *)msg;
5360 *len = 0;
5361 CsrUint16Ser(ptr, len, primitive->common.type);
5362 CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
5363 CsrUint16Ser(ptr, len, (u16) primitive->status);
5364 CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
5365 CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode);
5366 CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
5367 if (primitive->tspecLength)
5368 {
5369 CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
5370 }
5371 return(ptr);
5372}
5373
5374
5375void* CsrWifiSmeTspecCfmDes(u8 *buffer, size_t length)
5376{
5377 CsrWifiSmeTspecCfm *primitive = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL);
5378 size_t offset;
5379 offset = 0;
5380
5381 CsrUint16Des(&primitive->common.type, buffer, &offset);
5382 CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
5383 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5384 CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
5385 CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset);
5386 CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
5387 if (primitive->tspecLength)
5388 {
5389 primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
5390 CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
5391 }
5392 else
5393 {
5394 primitive->tspec = NULL;
5395 }
5396
5397 return primitive;
5398}
5399
5400
5401void CsrWifiSmeTspecCfmSerFree(void *voidPrimitivePointer)
5402{
5403 CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) voidPrimitivePointer;
5404 kfree(primitive->tspec);
5405 kfree(primitive);
5406}
5407
5408
5409size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg)
5410{
5411 CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) msg;
5412 size_t bufferSize = 2;
5413
5414 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 33) */
5415 bufferSize += 2; /* CsrResult primitive->status */
5416 bufferSize += 4; /* u32 primitive->versions.chipId */
5417 bufferSize += 4; /* u32 primitive->versions.chipVersion */
5418 bufferSize += 4; /* u32 primitive->versions.firmwareBuild */
5419 bufferSize += 4; /* u32 primitive->versions.firmwarePatch */
5420 bufferSize += 4; /* u32 primitive->versions.firmwareHip */
5421 bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1; /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */
5422 bufferSize += 4; /* u32 primitive->versions.routerHip */
5423 bufferSize += (primitive->versions.smeBuild ? strlen(primitive->versions.smeBuild) : 0) + 1; /* char* primitive->versions.smeBuild (0 byte len + 1 for NULL Term) */
5424 bufferSize += 4; /* u32 primitive->versions.smeHip */
5425 return bufferSize;
5426}
5427
5428
5429u8* CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg)
5430{
5431 CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *)msg;
5432 *len = 0;
5433 CsrUint16Ser(ptr, len, primitive->common.type);
5434 CsrUint16Ser(ptr, len, (u16) primitive->status);
5435 CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId);
5436 CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion);
5437 CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild);
5438 CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwarePatch);
5439 CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip);
5440 CsrCharStringSer(ptr, len, primitive->versions.routerBuild);
5441 CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip);
5442 CsrCharStringSer(ptr, len, primitive->versions.smeBuild);
5443 CsrUint32Ser(ptr, len, (u32) primitive->versions.smeHip);
5444 return(ptr);
5445}
5446
5447
5448void* CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t length)
5449{
5450 CsrWifiSmeVersionsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL);
5451 size_t offset;
5452 offset = 0;
5453
5454 CsrUint16Des(&primitive->common.type, buffer, &offset);
5455 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5456 CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset);
5457 CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset);
5458 CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset);
5459 CsrUint32Des((u32 *) &primitive->versions.firmwarePatch, buffer, &offset);
5460 CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset);
5461 CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset);
5462 CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset);
5463 CsrCharStringDes(&primitive->versions.smeBuild, buffer, &offset);
5464 CsrUint32Des((u32 *) &primitive->versions.smeHip, buffer, &offset);
5465
5466 return primitive;
5467}
5468
5469
5470void CsrWifiSmeVersionsGetCfmSerFree(void *voidPrimitivePointer)
5471{
5472 CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) voidPrimitivePointer;
5473 kfree(primitive->versions.routerBuild);
5474 kfree(primitive->versions.smeBuild);
5475 kfree(primitive);
5476}
5477
5478
5479size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg)
5480{
5481 CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) msg;
5482 size_t bufferSize = 2;
5483
5484 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */
5485 bufferSize += 2; /* CsrResult primitive->status */
5486 bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */
5487 {
5488 u16 i2;
5489 for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
5490 {
5491 bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */
5492 bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */
5493 }
5494 }
5495 return bufferSize;
5496}
5497
5498
5499u8* CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg)
5500{
5501 CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *)msg;
5502 *len = 0;
5503 CsrUint16Ser(ptr, len, primitive->common.type);
5504 CsrUint16Ser(ptr, len, (u16) primitive->status);
5505 CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount);
5506 {
5507 u16 i2;
5508 for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
5509 {
5510 CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32)));
5511 CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length);
5512 }
5513 }
5514 return(ptr);
5515}
5516
5517
5518void* CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t length)
5519{
5520 CsrWifiSmeCloakedSsidsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL);
5521 size_t offset;
5522 offset = 0;
5523
5524 CsrUint16Des(&primitive->common.type, buffer, &offset);
5525 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5526 CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset);
5527 primitive->cloakedSsids.cloakedSsids = NULL;
5528 if (primitive->cloakedSsids.cloakedSsidsCount)
5529 {
5530 primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL);
5531 }
5532 {
5533 u16 i2;
5534 for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
5535 {
5536 CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32)));
5537 CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset);
5538 }
5539 }
5540
5541 return primitive;
5542}
5543
5544
5545void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *voidPrimitivePointer)
5546{
5547 CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) voidPrimitivePointer;
5548 kfree(primitive->cloakedSsids.cloakedSsids);
5549 kfree(primitive);
5550}
5551
5552
5553size_t CsrWifiSmeWifiOnIndSizeof(void *msg)
5554{
5555 size_t bufferSize = 2;
5556
5557 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
5558 bufferSize += 6; /* u8 primitive->address.a[6] */
5559 return bufferSize;
5560}
5561
5562
5563u8* CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg)
5564{
5565 CsrWifiSmeWifiOnInd *primitive = (CsrWifiSmeWifiOnInd *)msg;
5566 *len = 0;
5567 CsrUint16Ser(ptr, len, primitive->common.type);
5568 CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
5569 return(ptr);
5570}
5571
5572
5573void* CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t length)
5574{
5575 CsrWifiSmeWifiOnInd *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL);
5576 size_t offset;
5577 offset = 0;
5578
5579 CsrUint16Des(&primitive->common.type, buffer, &offset);
5580 CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
5581
5582 return primitive;
5583}
5584
5585
5586size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg)
5587{
5588 size_t bufferSize = 2;
5589
5590 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
5591 bufferSize += 2; /* CsrResult primitive->status */
5592 bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */
5593 bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */
5594 bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */
5595 bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */
5596 return bufferSize;
5597}
5598
5599
5600u8* CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
5601{
5602 CsrWifiSmeSmeCommonConfigGetCfm *primitive = (CsrWifiSmeSmeCommonConfigGetCfm *)msg;
5603 *len = 0;
5604 CsrUint16Ser(ptr, len, primitive->common.type);
5605 CsrUint16Ser(ptr, len, (u16) primitive->status);
5606 CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel);
5607 CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2)));
5608 CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface);
5609 CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN);
5610 return(ptr);
5611}
5612
5613
5614void* CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t length)
5615{
5616 CsrWifiSmeSmeCommonConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL);
5617 size_t offset;
5618 offset = 0;
5619
5620 CsrUint16Des(&primitive->common.type, buffer, &offset);
5621 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5622 CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset);
5623 CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2)));
5624 CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset);
5625 CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset);
5626
5627 return primitive;
5628}
5629
5630
5631size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg)
5632{
5633 size_t bufferSize = 2;
5634
5635 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
5636 bufferSize += 2; /* CsrResult primitive->status */
5637 bufferSize += 2; /* u16 primitive->numInterfaces */
5638 bufferSize += 2; /* u8 primitive->capBitmap[2] */
5639 return bufferSize;
5640}
5641
5642
5643u8* CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len, void *msg)
5644{
5645 CsrWifiSmeInterfaceCapabilityGetCfm *primitive = (CsrWifiSmeInterfaceCapabilityGetCfm *)msg;
5646 *len = 0;
5647 CsrUint16Ser(ptr, len, primitive->common.type);
5648 CsrUint16Ser(ptr, len, (u16) primitive->status);
5649 CsrUint16Ser(ptr, len, (u16) primitive->numInterfaces);
5650 CsrMemCpySer(ptr, len, (const void *) primitive->capBitmap, ((u16) (2)));
5651 return(ptr);
5652}
5653
5654
5655void* CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t length)
5656{
5657 CsrWifiSmeInterfaceCapabilityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL);
5658 size_t offset;
5659 offset = 0;
5660
5661 CsrUint16Des(&primitive->common.type, buffer, &offset);
5662 CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
5663 CsrUint16Des((u16 *) &primitive->numInterfaces, buffer, &offset);
5664 CsrMemCpyDes(primitive->capBitmap, buffer, &offset, ((u16) (2)));
5665
5666 return primitive;
5667}
5668
5669
5670size_t CsrWifiSmeErrorIndSizeof(void *msg)
5671{
5672 CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) msg;
5673 size_t bufferSize = 2;
5674
5675 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */
5676 bufferSize += (primitive->errorMessage ? strlen(primitive->errorMessage) : 0) + 1; /* char* primitive->errorMessage (0 byte len + 1 for NULL Term) */
5677 return bufferSize;
5678}
5679
5680
5681u8* CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg)
5682{
5683 CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *)msg;
5684 *len = 0;
5685 CsrUint16Ser(ptr, len, primitive->common.type);
5686 CsrCharStringSer(ptr, len, primitive->errorMessage);
5687 return(ptr);
5688}
5689
5690
5691void* CsrWifiSmeErrorIndDes(u8 *buffer, size_t length)
5692{
5693 CsrWifiSmeErrorInd *primitive = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL);
5694 size_t offset;
5695 offset = 0;
5696
5697 CsrUint16Des(&primitive->common.type, buffer, &offset);
5698 CsrCharStringDes(&primitive->errorMessage, buffer, &offset);
5699
5700 return primitive;
5701}
5702
5703
5704void CsrWifiSmeErrorIndSerFree(void *voidPrimitivePointer)
5705{
5706 CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) voidPrimitivePointer;
5707 kfree(primitive->errorMessage);
5708 kfree(primitive);
5709}
5710
5711
5712size_t CsrWifiSmeInfoIndSizeof(void *msg)
5713{
5714 CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) msg;
5715 size_t bufferSize = 2;
5716
5717 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */
5718 bufferSize += (primitive->infoMessage ? strlen(primitive->infoMessage) : 0) + 1; /* char* primitive->infoMessage (0 byte len + 1 for NULL Term) */
5719 return bufferSize;
5720}
5721
5722
5723u8* CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg)
5724{
5725 CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *)msg;
5726 *len = 0;
5727 CsrUint16Ser(ptr, len, primitive->common.type);
5728 CsrCharStringSer(ptr, len, primitive->infoMessage);
5729 return(ptr);
5730}
5731
5732
5733void* CsrWifiSmeInfoIndDes(u8 *buffer, size_t length)
5734{
5735 CsrWifiSmeInfoInd *primitive = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL);
5736 size_t offset;
5737 offset = 0;
5738
5739 CsrUint16Des(&primitive->common.type, buffer, &offset);
5740 CsrCharStringDes(&primitive->infoMessage, buffer, &offset);
5741
5742 return primitive;
5743}
5744
5745
5746void CsrWifiSmeInfoIndSerFree(void *voidPrimitivePointer)
5747{
5748 CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) voidPrimitivePointer;
5749 kfree(primitive->infoMessage);
5750 kfree(primitive);
5751}
5752
5753
5754size_t CsrWifiSmeCoreDumpIndSizeof(void *msg)
5755{
5756 CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) msg;
5757 size_t bufferSize = 2;
5758
5759 /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
5760 bufferSize += 4; /* u32 primitive->dataLength */
5761 bufferSize += primitive->dataLength; /* u8 primitive->data */
5762 return bufferSize;
5763}
5764
5765
5766u8* CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg)
5767{
5768 CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *)msg;
5769 *len = 0;
5770 CsrUint16Ser(ptr, len, primitive->common.type);
5771 CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
5772 if (primitive->dataLength)
5773 {
5774 CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
5775 }
5776 return(ptr);
5777}
5778
5779
5780void* CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t length)
5781{
5782 CsrWifiSmeCoreDumpInd *primitive = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL);
5783 size_t offset;
5784 offset = 0;
5785
5786 CsrUint16Des(&primitive->common.type, buffer, &offset);
5787 CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
5788 if (primitive->dataLength)
5789 {
5790 primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
5791 CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
5792 }
5793 else
5794 {
5795 primitive->data = NULL;
5796 }
5797
5798 return primitive;
5799}
5800
5801
5802void CsrWifiSmeCoreDumpIndSerFree(void *voidPrimitivePointer)
5803{
5804 CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) voidPrimitivePointer;
5805 kfree(primitive->data);
5806 kfree(primitive);
5807}
5808
5809
diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.h b/drivers/staging/csr/csr_wifi_sme_serialize.h
deleted file mode 100644
index f8526269b203..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_serialize.h
+++ /dev/null
@@ -1,666 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2012
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_SERIALIZE_H__
14#define CSR_WIFI_SME_SERIALIZE_H__
15
16#include "csr_wifi_msgconv.h"
17#include "csr_wifi_sme_prim.h"
18
19extern void CsrWifiSmePfree(void *ptr);
20
21#define CsrWifiSmeActivateReqSer CsrWifiEventSer
22#define CsrWifiSmeActivateReqDes CsrWifiEventDes
23#define CsrWifiSmeActivateReqSizeof CsrWifiEventSizeof
24#define CsrWifiSmeActivateReqSerFree CsrWifiSmePfree
25
26#define CsrWifiSmeAdhocConfigGetReqSer CsrWifiEventSer
27#define CsrWifiSmeAdhocConfigGetReqDes CsrWifiEventDes
28#define CsrWifiSmeAdhocConfigGetReqSizeof CsrWifiEventSizeof
29#define CsrWifiSmeAdhocConfigGetReqSerFree CsrWifiSmePfree
30
31extern u8 *CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
32extern void *CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t len);
33extern size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg);
34#define CsrWifiSmeAdhocConfigSetReqSerFree CsrWifiSmePfree
35
36extern u8 *CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg);
37extern void *CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t len);
38extern size_t CsrWifiSmeBlacklistReqSizeof(void *msg);
39extern void CsrWifiSmeBlacklistReqSerFree(void *msg);
40
41#define CsrWifiSmeCalibrationDataGetReqSer CsrWifiEventSer
42#define CsrWifiSmeCalibrationDataGetReqDes CsrWifiEventDes
43#define CsrWifiSmeCalibrationDataGetReqSizeof CsrWifiEventSizeof
44#define CsrWifiSmeCalibrationDataGetReqSerFree CsrWifiSmePfree
45
46extern u8 *CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg);
47extern void *CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t len);
48extern size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg);
49extern void CsrWifiSmeCalibrationDataSetReqSerFree(void *msg);
50
51#define CsrWifiSmeCcxConfigGetReqSer CsrWifiEventCsrUint16Ser
52#define CsrWifiSmeCcxConfigGetReqDes CsrWifiEventCsrUint16Des
53#define CsrWifiSmeCcxConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
54#define CsrWifiSmeCcxConfigGetReqSerFree CsrWifiSmePfree
55
56extern u8 *CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
57extern void *CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t len);
58extern size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg);
59#define CsrWifiSmeCcxConfigSetReqSerFree CsrWifiSmePfree
60
61#define CsrWifiSmeCoexConfigGetReqSer CsrWifiEventSer
62#define CsrWifiSmeCoexConfigGetReqDes CsrWifiEventDes
63#define CsrWifiSmeCoexConfigGetReqSizeof CsrWifiEventSizeof
64#define CsrWifiSmeCoexConfigGetReqSerFree CsrWifiSmePfree
65
66extern u8 *CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
67extern void *CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t len);
68extern size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg);
69#define CsrWifiSmeCoexConfigSetReqSerFree CsrWifiSmePfree
70
71#define CsrWifiSmeCoexInfoGetReqSer CsrWifiEventSer
72#define CsrWifiSmeCoexInfoGetReqDes CsrWifiEventDes
73#define CsrWifiSmeCoexInfoGetReqSizeof CsrWifiEventSizeof
74#define CsrWifiSmeCoexInfoGetReqSerFree CsrWifiSmePfree
75
76extern u8 *CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg);
77extern void *CsrWifiSmeConnectReqDes(u8 *buffer, size_t len);
78extern size_t CsrWifiSmeConnectReqSizeof(void *msg);
79extern void CsrWifiSmeConnectReqSerFree(void *msg);
80
81#define CsrWifiSmeConnectionConfigGetReqSer CsrWifiEventCsrUint16Ser
82#define CsrWifiSmeConnectionConfigGetReqDes CsrWifiEventCsrUint16Des
83#define CsrWifiSmeConnectionConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
84#define CsrWifiSmeConnectionConfigGetReqSerFree CsrWifiSmePfree
85
86#define CsrWifiSmeConnectionInfoGetReqSer CsrWifiEventCsrUint16Ser
87#define CsrWifiSmeConnectionInfoGetReqDes CsrWifiEventCsrUint16Des
88#define CsrWifiSmeConnectionInfoGetReqSizeof CsrWifiEventCsrUint16Sizeof
89#define CsrWifiSmeConnectionInfoGetReqSerFree CsrWifiSmePfree
90
91#define CsrWifiSmeConnectionStatsGetReqSer CsrWifiEventCsrUint16Ser
92#define CsrWifiSmeConnectionStatsGetReqDes CsrWifiEventCsrUint16Des
93#define CsrWifiSmeConnectionStatsGetReqSizeof CsrWifiEventCsrUint16Sizeof
94#define CsrWifiSmeConnectionStatsGetReqSerFree CsrWifiSmePfree
95
96#define CsrWifiSmeDeactivateReqSer CsrWifiEventSer
97#define CsrWifiSmeDeactivateReqDes CsrWifiEventDes
98#define CsrWifiSmeDeactivateReqSizeof CsrWifiEventSizeof
99#define CsrWifiSmeDeactivateReqSerFree CsrWifiSmePfree
100
101#define CsrWifiSmeDisconnectReqSer CsrWifiEventCsrUint16Ser
102#define CsrWifiSmeDisconnectReqDes CsrWifiEventCsrUint16Des
103#define CsrWifiSmeDisconnectReqSizeof CsrWifiEventCsrUint16Sizeof
104#define CsrWifiSmeDisconnectReqSerFree CsrWifiSmePfree
105
106#define CsrWifiSmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser
107#define CsrWifiSmeEventMaskSetReqDes CsrWifiEventCsrUint32Des
108#define CsrWifiSmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof
109#define CsrWifiSmeEventMaskSetReqSerFree CsrWifiSmePfree
110
111#define CsrWifiSmeHostConfigGetReqSer CsrWifiEventCsrUint16Ser
112#define CsrWifiSmeHostConfigGetReqDes CsrWifiEventCsrUint16Des
113#define CsrWifiSmeHostConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
114#define CsrWifiSmeHostConfigGetReqSerFree CsrWifiSmePfree
115
116extern u8 *CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
117extern void *CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t len);
118extern size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg);
119#define CsrWifiSmeHostConfigSetReqSerFree CsrWifiSmePfree
120
121extern u8 *CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg);
122extern void *CsrWifiSmeKeyReqDes(u8 *buffer, size_t len);
123extern size_t CsrWifiSmeKeyReqSizeof(void *msg);
124#define CsrWifiSmeKeyReqSerFree CsrWifiSmePfree
125
126#define CsrWifiSmeLinkQualityGetReqSer CsrWifiEventCsrUint16Ser
127#define CsrWifiSmeLinkQualityGetReqDes CsrWifiEventCsrUint16Des
128#define CsrWifiSmeLinkQualityGetReqSizeof CsrWifiEventCsrUint16Sizeof
129#define CsrWifiSmeLinkQualityGetReqSerFree CsrWifiSmePfree
130
131#define CsrWifiSmeMibConfigGetReqSer CsrWifiEventSer
132#define CsrWifiSmeMibConfigGetReqDes CsrWifiEventDes
133#define CsrWifiSmeMibConfigGetReqSizeof CsrWifiEventSizeof
134#define CsrWifiSmeMibConfigGetReqSerFree CsrWifiSmePfree
135
136extern u8 *CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
137extern void *CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t len);
138extern size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg);
139#define CsrWifiSmeMibConfigSetReqSerFree CsrWifiSmePfree
140
141extern u8 *CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg);
142extern void *CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t len);
143extern size_t CsrWifiSmeMibGetNextReqSizeof(void *msg);
144extern void CsrWifiSmeMibGetNextReqSerFree(void *msg);
145
146extern u8 *CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg);
147extern void *CsrWifiSmeMibGetReqDes(u8 *buffer, size_t len);
148extern size_t CsrWifiSmeMibGetReqSizeof(void *msg);
149extern void CsrWifiSmeMibGetReqSerFree(void *msg);
150
151extern u8 *CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg);
152extern void *CsrWifiSmeMibSetReqDes(u8 *buffer, size_t len);
153extern size_t CsrWifiSmeMibSetReqSizeof(void *msg);
154extern void CsrWifiSmeMibSetReqSerFree(void *msg);
155
156extern u8 *CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg);
157extern void *CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t len);
158extern size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg);
159extern void CsrWifiSmeMulticastAddressReqSerFree(void *msg);
160
161extern u8 *CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg);
162extern void *CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t len);
163extern size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg);
164extern void CsrWifiSmePacketFilterSetReqSerFree(void *msg);
165
166#define CsrWifiSmePermanentMacAddressGetReqSer CsrWifiEventSer
167#define CsrWifiSmePermanentMacAddressGetReqDes CsrWifiEventDes
168#define CsrWifiSmePermanentMacAddressGetReqSizeof CsrWifiEventSizeof
169#define CsrWifiSmePermanentMacAddressGetReqSerFree CsrWifiSmePfree
170
171extern u8 *CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg);
172extern void *CsrWifiSmePmkidReqDes(u8 *buffer, size_t len);
173extern size_t CsrWifiSmePmkidReqSizeof(void *msg);
174extern void CsrWifiSmePmkidReqSerFree(void *msg);
175
176#define CsrWifiSmePowerConfigGetReqSer CsrWifiEventSer
177#define CsrWifiSmePowerConfigGetReqDes CsrWifiEventDes
178#define CsrWifiSmePowerConfigGetReqSizeof CsrWifiEventSizeof
179#define CsrWifiSmePowerConfigGetReqSerFree CsrWifiSmePfree
180
181extern u8 *CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
182extern void *CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t len);
183extern size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg);
184#define CsrWifiSmePowerConfigSetReqSerFree CsrWifiSmePfree
185
186#define CsrWifiSmeRegulatoryDomainInfoGetReqSer CsrWifiEventSer
187#define CsrWifiSmeRegulatoryDomainInfoGetReqDes CsrWifiEventDes
188#define CsrWifiSmeRegulatoryDomainInfoGetReqSizeof CsrWifiEventSizeof
189#define CsrWifiSmeRegulatoryDomainInfoGetReqSerFree CsrWifiSmePfree
190
191#define CsrWifiSmeRoamingConfigGetReqSer CsrWifiEventCsrUint16Ser
192#define CsrWifiSmeRoamingConfigGetReqDes CsrWifiEventCsrUint16Des
193#define CsrWifiSmeRoamingConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
194#define CsrWifiSmeRoamingConfigGetReqSerFree CsrWifiSmePfree
195
196extern u8 *CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
197extern void *CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t len);
198extern size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg);
199#define CsrWifiSmeRoamingConfigSetReqSerFree CsrWifiSmePfree
200
201#define CsrWifiSmeScanConfigGetReqSer CsrWifiEventSer
202#define CsrWifiSmeScanConfigGetReqDes CsrWifiEventDes
203#define CsrWifiSmeScanConfigGetReqSizeof CsrWifiEventSizeof
204#define CsrWifiSmeScanConfigGetReqSerFree CsrWifiSmePfree
205
206extern u8 *CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
207extern void *CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t len);
208extern size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg);
209extern void CsrWifiSmeScanConfigSetReqSerFree(void *msg);
210
211extern u8 *CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg);
212extern void *CsrWifiSmeScanFullReqDes(u8 *buffer, size_t len);
213extern size_t CsrWifiSmeScanFullReqSizeof(void *msg);
214extern void CsrWifiSmeScanFullReqSerFree(void *msg);
215
216#define CsrWifiSmeScanResultsFlushReqSer CsrWifiEventSer
217#define CsrWifiSmeScanResultsFlushReqDes CsrWifiEventDes
218#define CsrWifiSmeScanResultsFlushReqSizeof CsrWifiEventSizeof
219#define CsrWifiSmeScanResultsFlushReqSerFree CsrWifiSmePfree
220
221#define CsrWifiSmeScanResultsGetReqSer CsrWifiEventSer
222#define CsrWifiSmeScanResultsGetReqDes CsrWifiEventDes
223#define CsrWifiSmeScanResultsGetReqSizeof CsrWifiEventSizeof
224#define CsrWifiSmeScanResultsGetReqSerFree CsrWifiSmePfree
225
226#define CsrWifiSmeSmeStaConfigGetReqSer CsrWifiEventCsrUint16Ser
227#define CsrWifiSmeSmeStaConfigGetReqDes CsrWifiEventCsrUint16Des
228#define CsrWifiSmeSmeStaConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
229#define CsrWifiSmeSmeStaConfigGetReqSerFree CsrWifiSmePfree
230
231extern u8 *CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
232extern void *CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t len);
233extern size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg);
234#define CsrWifiSmeSmeStaConfigSetReqSerFree CsrWifiSmePfree
235
236#define CsrWifiSmeStationMacAddressGetReqSer CsrWifiEventSer
237#define CsrWifiSmeStationMacAddressGetReqDes CsrWifiEventDes
238#define CsrWifiSmeStationMacAddressGetReqSizeof CsrWifiEventSizeof
239#define CsrWifiSmeStationMacAddressGetReqSerFree CsrWifiSmePfree
240
241extern u8 *CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg);
242extern void *CsrWifiSmeTspecReqDes(u8 *buffer, size_t len);
243extern size_t CsrWifiSmeTspecReqSizeof(void *msg);
244extern void CsrWifiSmeTspecReqSerFree(void *msg);
245
246#define CsrWifiSmeVersionsGetReqSer CsrWifiEventSer
247#define CsrWifiSmeVersionsGetReqDes CsrWifiEventDes
248#define CsrWifiSmeVersionsGetReqSizeof CsrWifiEventSizeof
249#define CsrWifiSmeVersionsGetReqSerFree CsrWifiSmePfree
250
251extern u8 *CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg);
252extern void *CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t len);
253extern size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg);
254extern void CsrWifiSmeWifiFlightmodeReqSerFree(void *msg);
255
256#define CsrWifiSmeWifiOffReqSer CsrWifiEventSer
257#define CsrWifiSmeWifiOffReqDes CsrWifiEventDes
258#define CsrWifiSmeWifiOffReqSizeof CsrWifiEventSizeof
259#define CsrWifiSmeWifiOffReqSerFree CsrWifiSmePfree
260
261extern u8 *CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg);
262extern void *CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t len);
263extern size_t CsrWifiSmeWifiOnReqSizeof(void *msg);
264extern void CsrWifiSmeWifiOnReqSerFree(void *msg);
265
266extern u8 *CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg);
267extern void *CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t len);
268extern size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg);
269extern void CsrWifiSmeCloakedSsidsSetReqSerFree(void *msg);
270
271#define CsrWifiSmeCloakedSsidsGetReqSer CsrWifiEventSer
272#define CsrWifiSmeCloakedSsidsGetReqDes CsrWifiEventDes
273#define CsrWifiSmeCloakedSsidsGetReqSizeof CsrWifiEventSizeof
274#define CsrWifiSmeCloakedSsidsGetReqSerFree CsrWifiSmePfree
275
276#define CsrWifiSmeSmeCommonConfigGetReqSer CsrWifiEventSer
277#define CsrWifiSmeSmeCommonConfigGetReqDes CsrWifiEventDes
278#define CsrWifiSmeSmeCommonConfigGetReqSizeof CsrWifiEventSizeof
279#define CsrWifiSmeSmeCommonConfigGetReqSerFree CsrWifiSmePfree
280
281extern u8 *CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
282extern void *CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t len);
283extern size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg);
284#define CsrWifiSmeSmeCommonConfigSetReqSerFree CsrWifiSmePfree
285
286#define CsrWifiSmeInterfaceCapabilityGetReqSer CsrWifiEventSer
287#define CsrWifiSmeInterfaceCapabilityGetReqDes CsrWifiEventDes
288#define CsrWifiSmeInterfaceCapabilityGetReqSizeof CsrWifiEventSizeof
289#define CsrWifiSmeInterfaceCapabilityGetReqSerFree CsrWifiSmePfree
290
291extern u8 *CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg);
292extern void *CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t len);
293extern size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg);
294extern void CsrWifiSmeWpsConfigurationReqSerFree(void *msg);
295
296extern u8 *CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg);
297extern void *CsrWifiSmeSetReqDes(u8 *buffer, size_t len);
298extern size_t CsrWifiSmeSetReqSizeof(void *msg);
299extern void CsrWifiSmeSetReqSerFree(void *msg);
300
301#define CsrWifiSmeActivateCfmSer CsrWifiEventCsrUint16Ser
302#define CsrWifiSmeActivateCfmDes CsrWifiEventCsrUint16Des
303#define CsrWifiSmeActivateCfmSizeof CsrWifiEventCsrUint16Sizeof
304#define CsrWifiSmeActivateCfmSerFree CsrWifiSmePfree
305
306extern u8 *CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
307extern void *CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t len);
308extern size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg);
309#define CsrWifiSmeAdhocConfigGetCfmSerFree CsrWifiSmePfree
310
311#define CsrWifiSmeAdhocConfigSetCfmSer CsrWifiEventCsrUint16Ser
312#define CsrWifiSmeAdhocConfigSetCfmDes CsrWifiEventCsrUint16Des
313#define CsrWifiSmeAdhocConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
314#define CsrWifiSmeAdhocConfigSetCfmSerFree CsrWifiSmePfree
315
316extern u8 *CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg);
317extern void *CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t len);
318extern size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg);
319extern void CsrWifiSmeAssociationCompleteIndSerFree(void *msg);
320
321extern u8 *CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg);
322extern void *CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t len);
323extern size_t CsrWifiSmeAssociationStartIndSizeof(void *msg);
324#define CsrWifiSmeAssociationStartIndSerFree CsrWifiSmePfree
325
326extern u8 *CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg);
327extern void *CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t len);
328extern size_t CsrWifiSmeBlacklistCfmSizeof(void *msg);
329extern void CsrWifiSmeBlacklistCfmSerFree(void *msg);
330
331extern u8 *CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg);
332extern void *CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t len);
333extern size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg);
334extern void CsrWifiSmeCalibrationDataGetCfmSerFree(void *msg);
335
336#define CsrWifiSmeCalibrationDataSetCfmSer CsrWifiEventCsrUint16Ser
337#define CsrWifiSmeCalibrationDataSetCfmDes CsrWifiEventCsrUint16Des
338#define CsrWifiSmeCalibrationDataSetCfmSizeof CsrWifiEventCsrUint16Sizeof
339#define CsrWifiSmeCalibrationDataSetCfmSerFree CsrWifiSmePfree
340
341extern u8 *CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
342extern void *CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t len);
343extern size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg);
344#define CsrWifiSmeCcxConfigGetCfmSerFree CsrWifiSmePfree
345
346extern u8 *CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
347extern void *CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t len);
348extern size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg);
349#define CsrWifiSmeCcxConfigSetCfmSerFree CsrWifiSmePfree
350
351extern u8 *CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
352extern void *CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t len);
353extern size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg);
354#define CsrWifiSmeCoexConfigGetCfmSerFree CsrWifiSmePfree
355
356#define CsrWifiSmeCoexConfigSetCfmSer CsrWifiEventCsrUint16Ser
357#define CsrWifiSmeCoexConfigSetCfmDes CsrWifiEventCsrUint16Des
358#define CsrWifiSmeCoexConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
359#define CsrWifiSmeCoexConfigSetCfmSerFree CsrWifiSmePfree
360
361extern u8 *CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
362extern void *CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t len);
363extern size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg);
364#define CsrWifiSmeCoexInfoGetCfmSerFree CsrWifiSmePfree
365
366extern u8 *CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg);
367extern void *CsrWifiSmeConnectCfmDes(u8 *buffer, size_t len);
368extern size_t CsrWifiSmeConnectCfmSizeof(void *msg);
369#define CsrWifiSmeConnectCfmSerFree CsrWifiSmePfree
370
371extern u8 *CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
372extern void *CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t len);
373extern size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg);
374extern void CsrWifiSmeConnectionConfigGetCfmSerFree(void *msg);
375
376extern u8 *CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
377extern void *CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t len);
378extern size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg);
379extern void CsrWifiSmeConnectionInfoGetCfmSerFree(void *msg);
380
381extern u8 *CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg);
382extern void *CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t len);
383extern size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg);
384#define CsrWifiSmeConnectionQualityIndSerFree CsrWifiSmePfree
385
386extern u8 *CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg);
387extern void *CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t len);
388extern size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg);
389#define CsrWifiSmeConnectionStatsGetCfmSerFree CsrWifiSmePfree
390
391#define CsrWifiSmeDeactivateCfmSer CsrWifiEventCsrUint16Ser
392#define CsrWifiSmeDeactivateCfmDes CsrWifiEventCsrUint16Des
393#define CsrWifiSmeDeactivateCfmSizeof CsrWifiEventCsrUint16Sizeof
394#define CsrWifiSmeDeactivateCfmSerFree CsrWifiSmePfree
395
396extern u8 *CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg);
397extern void *CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t len);
398extern size_t CsrWifiSmeDisconnectCfmSizeof(void *msg);
399#define CsrWifiSmeDisconnectCfmSerFree CsrWifiSmePfree
400
401#define CsrWifiSmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser
402#define CsrWifiSmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des
403#define CsrWifiSmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof
404#define CsrWifiSmeEventMaskSetCfmSerFree CsrWifiSmePfree
405
406extern u8 *CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
407extern void *CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t len);
408extern size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg);
409#define CsrWifiSmeHostConfigGetCfmSerFree CsrWifiSmePfree
410
411extern u8 *CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
412extern void *CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t len);
413extern size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg);
414#define CsrWifiSmeHostConfigSetCfmSerFree CsrWifiSmePfree
415
416extern u8 *CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg);
417extern void *CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t len);
418extern size_t CsrWifiSmeIbssStationIndSizeof(void *msg);
419#define CsrWifiSmeIbssStationIndSerFree CsrWifiSmePfree
420
421extern u8 *CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg);
422extern void *CsrWifiSmeKeyCfmDes(u8 *buffer, size_t len);
423extern size_t CsrWifiSmeKeyCfmSizeof(void *msg);
424#define CsrWifiSmeKeyCfmSerFree CsrWifiSmePfree
425
426extern u8 *CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg);
427extern void *CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t len);
428extern size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg);
429#define CsrWifiSmeLinkQualityGetCfmSerFree CsrWifiSmePfree
430
431extern u8 *CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg);
432extern void *CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t len);
433extern size_t CsrWifiSmeMediaStatusIndSizeof(void *msg);
434extern void CsrWifiSmeMediaStatusIndSerFree(void *msg);
435
436extern u8 *CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
437extern void *CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t len);
438extern size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg);
439#define CsrWifiSmeMibConfigGetCfmSerFree CsrWifiSmePfree
440
441#define CsrWifiSmeMibConfigSetCfmSer CsrWifiEventCsrUint16Ser
442#define CsrWifiSmeMibConfigSetCfmDes CsrWifiEventCsrUint16Des
443#define CsrWifiSmeMibConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
444#define CsrWifiSmeMibConfigSetCfmSerFree CsrWifiSmePfree
445
446extern u8 *CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg);
447extern void *CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t len);
448extern size_t CsrWifiSmeMibGetCfmSizeof(void *msg);
449extern void CsrWifiSmeMibGetCfmSerFree(void *msg);
450
451extern u8 *CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg);
452extern void *CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t len);
453extern size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg);
454extern void CsrWifiSmeMibGetNextCfmSerFree(void *msg);
455
456#define CsrWifiSmeMibSetCfmSer CsrWifiEventCsrUint16Ser
457#define CsrWifiSmeMibSetCfmDes CsrWifiEventCsrUint16Des
458#define CsrWifiSmeMibSetCfmSizeof CsrWifiEventCsrUint16Sizeof
459#define CsrWifiSmeMibSetCfmSerFree CsrWifiSmePfree
460
461extern u8 *CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg);
462extern void *CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t len);
463extern size_t CsrWifiSmeMicFailureIndSizeof(void *msg);
464#define CsrWifiSmeMicFailureIndSerFree CsrWifiSmePfree
465
466extern u8 *CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg);
467extern void *CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t len);
468extern size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg);
469extern void CsrWifiSmeMulticastAddressCfmSerFree(void *msg);
470
471extern u8 *CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg);
472extern void *CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t len);
473extern size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg);
474#define CsrWifiSmePacketFilterSetCfmSerFree CsrWifiSmePfree
475
476extern u8 *CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len,
477 void *msg);
478extern void *CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t len);
479extern size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg);
480#define CsrWifiSmePermanentMacAddressGetCfmSerFree CsrWifiSmePfree
481
482extern u8 *CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg);
483extern void *CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t len);
484extern size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg);
485extern void CsrWifiSmePmkidCandidateListIndSerFree(void *msg);
486
487extern u8 *CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg);
488extern void *CsrWifiSmePmkidCfmDes(u8 *buffer, size_t len);
489extern size_t CsrWifiSmePmkidCfmSizeof(void *msg);
490extern void CsrWifiSmePmkidCfmSerFree(void *msg);
491
492extern u8 *CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
493extern void *CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t len);
494extern size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg);
495#define CsrWifiSmePowerConfigGetCfmSerFree CsrWifiSmePfree
496
497#define CsrWifiSmePowerConfigSetCfmSer CsrWifiEventCsrUint16Ser
498#define CsrWifiSmePowerConfigSetCfmDes CsrWifiEventCsrUint16Des
499#define CsrWifiSmePowerConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
500#define CsrWifiSmePowerConfigSetCfmSerFree CsrWifiSmePfree
501
502extern u8 *CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len,
503 void *msg);
504extern void *CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t len);
505extern size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg);
506#define CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree CsrWifiSmePfree
507
508extern u8 *CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg);
509extern void *CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t len);
510extern size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg);
511#define CsrWifiSmeRoamCompleteIndSerFree CsrWifiSmePfree
512
513extern u8 *CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg);
514extern void *CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t len);
515extern size_t CsrWifiSmeRoamStartIndSizeof(void *msg);
516#define CsrWifiSmeRoamStartIndSerFree CsrWifiSmePfree
517
518extern u8 *CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
519extern void *CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t len);
520extern size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg);
521#define CsrWifiSmeRoamingConfigGetCfmSerFree CsrWifiSmePfree
522
523extern u8 *CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
524extern void *CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t len);
525extern size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg);
526#define CsrWifiSmeRoamingConfigSetCfmSerFree CsrWifiSmePfree
527
528extern u8 *CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
529extern void *CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t len);
530extern size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg);
531extern void CsrWifiSmeScanConfigGetCfmSerFree(void *msg);
532
533#define CsrWifiSmeScanConfigSetCfmSer CsrWifiEventCsrUint16Ser
534#define CsrWifiSmeScanConfigSetCfmDes CsrWifiEventCsrUint16Des
535#define CsrWifiSmeScanConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
536#define CsrWifiSmeScanConfigSetCfmSerFree CsrWifiSmePfree
537
538#define CsrWifiSmeScanFullCfmSer CsrWifiEventCsrUint16Ser
539#define CsrWifiSmeScanFullCfmDes CsrWifiEventCsrUint16Des
540#define CsrWifiSmeScanFullCfmSizeof CsrWifiEventCsrUint16Sizeof
541#define CsrWifiSmeScanFullCfmSerFree CsrWifiSmePfree
542
543extern u8 *CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg);
544extern void *CsrWifiSmeScanResultIndDes(u8 *buffer, size_t len);
545extern size_t CsrWifiSmeScanResultIndSizeof(void *msg);
546extern void CsrWifiSmeScanResultIndSerFree(void *msg);
547
548#define CsrWifiSmeScanResultsFlushCfmSer CsrWifiEventCsrUint16Ser
549#define CsrWifiSmeScanResultsFlushCfmDes CsrWifiEventCsrUint16Des
550#define CsrWifiSmeScanResultsFlushCfmSizeof CsrWifiEventCsrUint16Sizeof
551#define CsrWifiSmeScanResultsFlushCfmSerFree CsrWifiSmePfree
552
553extern u8 *CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg);
554extern void *CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t len);
555extern size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg);
556extern void CsrWifiSmeScanResultsGetCfmSerFree(void *msg);
557
558extern u8 *CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
559extern void *CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t len);
560extern size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg);
561#define CsrWifiSmeSmeStaConfigGetCfmSerFree CsrWifiSmePfree
562
563extern u8 *CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
564extern void *CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t len);
565extern size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg);
566#define CsrWifiSmeSmeStaConfigSetCfmSerFree CsrWifiSmePfree
567
568extern u8 *CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len,
569 void *msg);
570extern void *CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t len);
571extern size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg);
572#define CsrWifiSmeStationMacAddressGetCfmSerFree CsrWifiSmePfree
573
574extern u8 *CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg);
575extern void *CsrWifiSmeTspecIndDes(u8 *buffer, size_t len);
576extern size_t CsrWifiSmeTspecIndSizeof(void *msg);
577extern void CsrWifiSmeTspecIndSerFree(void *msg);
578
579extern u8 *CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg);
580extern void *CsrWifiSmeTspecCfmDes(u8 *buffer, size_t len);
581extern size_t CsrWifiSmeTspecCfmSizeof(void *msg);
582extern void CsrWifiSmeTspecCfmSerFree(void *msg);
583
584extern u8 *CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg);
585extern void *CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t len);
586extern size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg);
587extern void CsrWifiSmeVersionsGetCfmSerFree(void *msg);
588
589#define CsrWifiSmeWifiFlightmodeCfmSer CsrWifiEventCsrUint16Ser
590#define CsrWifiSmeWifiFlightmodeCfmDes CsrWifiEventCsrUint16Des
591#define CsrWifiSmeWifiFlightmodeCfmSizeof CsrWifiEventCsrUint16Sizeof
592#define CsrWifiSmeWifiFlightmodeCfmSerFree CsrWifiSmePfree
593
594#define CsrWifiSmeWifiOffIndSer CsrWifiEventCsrUint8Ser
595#define CsrWifiSmeWifiOffIndDes CsrWifiEventCsrUint8Des
596#define CsrWifiSmeWifiOffIndSizeof CsrWifiEventCsrUint8Sizeof
597#define CsrWifiSmeWifiOffIndSerFree CsrWifiSmePfree
598
599#define CsrWifiSmeWifiOffCfmSer CsrWifiEventCsrUint16Ser
600#define CsrWifiSmeWifiOffCfmDes CsrWifiEventCsrUint16Des
601#define CsrWifiSmeWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof
602#define CsrWifiSmeWifiOffCfmSerFree CsrWifiSmePfree
603
604#define CsrWifiSmeWifiOnCfmSer CsrWifiEventCsrUint16Ser
605#define CsrWifiSmeWifiOnCfmDes CsrWifiEventCsrUint16Des
606#define CsrWifiSmeWifiOnCfmSizeof CsrWifiEventCsrUint16Sizeof
607#define CsrWifiSmeWifiOnCfmSerFree CsrWifiSmePfree
608
609#define CsrWifiSmeCloakedSsidsSetCfmSer CsrWifiEventCsrUint16Ser
610#define CsrWifiSmeCloakedSsidsSetCfmDes CsrWifiEventCsrUint16Des
611#define CsrWifiSmeCloakedSsidsSetCfmSizeof CsrWifiEventCsrUint16Sizeof
612#define CsrWifiSmeCloakedSsidsSetCfmSerFree CsrWifiSmePfree
613
614extern u8 *CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg);
615extern void *CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t len);
616extern size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg);
617extern void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *msg);
618
619extern u8 *CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg);
620extern void *CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t len);
621extern size_t CsrWifiSmeWifiOnIndSizeof(void *msg);
622#define CsrWifiSmeWifiOnIndSerFree CsrWifiSmePfree
623
624extern u8 *CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
625extern void *CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t len);
626extern size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg);
627#define CsrWifiSmeSmeCommonConfigGetCfmSerFree CsrWifiSmePfree
628
629#define CsrWifiSmeSmeCommonConfigSetCfmSer CsrWifiEventCsrUint16Ser
630#define CsrWifiSmeSmeCommonConfigSetCfmDes CsrWifiEventCsrUint16Des
631#define CsrWifiSmeSmeCommonConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
632#define CsrWifiSmeSmeCommonConfigSetCfmSerFree CsrWifiSmePfree
633
634extern u8 *CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len,
635 void *msg);
636extern void *CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t len);
637extern size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg);
638#define CsrWifiSmeInterfaceCapabilityGetCfmSerFree CsrWifiSmePfree
639
640extern u8 *CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg);
641extern void *CsrWifiSmeErrorIndDes(u8 *buffer, size_t len);
642extern size_t CsrWifiSmeErrorIndSizeof(void *msg);
643extern void CsrWifiSmeErrorIndSerFree(void *msg);
644
645extern u8 *CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg);
646extern void *CsrWifiSmeInfoIndDes(u8 *buffer, size_t len);
647extern size_t CsrWifiSmeInfoIndSizeof(void *msg);
648extern void CsrWifiSmeInfoIndSerFree(void *msg);
649
650extern u8 *CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg);
651extern void *CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t len);
652extern size_t CsrWifiSmeCoreDumpIndSizeof(void *msg);
653extern void CsrWifiSmeCoreDumpIndSerFree(void *msg);
654
655#define CsrWifiSmeAmpStatusChangeIndSer CsrWifiEventCsrUint16CsrUint8Ser
656#define CsrWifiSmeAmpStatusChangeIndDes CsrWifiEventCsrUint16CsrUint8Des
657#define CsrWifiSmeAmpStatusChangeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
658#define CsrWifiSmeAmpStatusChangeIndSerFree CsrWifiSmePfree
659
660#define CsrWifiSmeWpsConfigurationCfmSer CsrWifiEventCsrUint16Ser
661#define CsrWifiSmeWpsConfigurationCfmDes CsrWifiEventCsrUint16Des
662#define CsrWifiSmeWpsConfigurationCfmSizeof CsrWifiEventCsrUint16Sizeof
663#define CsrWifiSmeWpsConfigurationCfmSerFree CsrWifiSmePfree
664
665#endif /* CSR_WIFI_SME_SERIALIZE_H__ */
666
diff --git a/drivers/staging/csr/csr_wifi_sme_task.h b/drivers/staging/csr/csr_wifi_sme_task.h
deleted file mode 100644
index 1e938c1fa964..000000000000
--- a/drivers/staging/csr/csr_wifi_sme_task.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11/* Note: this is an auto-generated file. */
12
13#ifndef CSR_WIFI_SME_TASK_H__
14#define CSR_WIFI_SME_TASK_H__
15
16#include "csr_sched.h"
17
18#define CSR_WIFI_SME_LOG_ID 0x1202FFFF
19extern CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
20void CsrWifiSmeInit(void **gash);
21void CsrWifiSmeDeinit(void **gash);
22void CsrWifiSmeHandler(void **gash);
23
24#endif /* CSR_WIFI_SME_TASK_H__ */
25
diff --git a/drivers/staging/csr/csr_wifi_vif_utils.h b/drivers/staging/csr/csr_wifi_vif_utils.h
deleted file mode 100644
index 8ff97888996d..000000000000
--- a/drivers/staging/csr/csr_wifi_vif_utils.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9*****************************************************************************/
10
11#ifndef CSR_WIFI_VIF_UTILS_H
12#define CSR_WIFI_VIF_UTILS_H
13
14/* STANDARD INCLUDES ********************************************************/
15
16/* PROJECT INCLUDES *********************************************************/
17/* including this file for CsrWifiInterfaceMode*/
18#include "csr_wifi_private_common.h"
19
20/* MACROS *******************************************************************/
21
22/* Common macros for NME and SME to be used temporarily until SoftMAC changes are made */
23#define CSR_WIFI_NUM_INTERFACES (u8)0x1
24#define CSR_WIFI_INTERFACE_IN_USE (u16)0x0
25
26#endif /* CSR_WIFI_VIF_UTILS_H */
27
diff --git a/drivers/staging/csr/data_tx.c b/drivers/staging/csr/data_tx.c
deleted file mode 100644
index 9e3d8b8ab02c..000000000000
--- a/drivers/staging/csr/data_tx.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: data_tx.c
4 *
5 * PURPOSE:
6 * This file provides functions to send data requests to the UniFi.
7 *
8 * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
9 *
10 * Refer to LICENSE.txt included with this source code for details on
11 * the license terms.
12 *
13 * ---------------------------------------------------------------------------
14 */
15#include "csr_wifi_hip_unifi.h"
16#include "unifi_priv.h"
17
18int
19uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet, unsigned int length)
20{
21 const unsigned char *p = packet;
22 u16 keyinfo;
23
24
25 if (length < (4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1 + 8))
26 return 1;
27
28 p += 8;
29 keyinfo = p[5] << 8 | p[6]; /* big-endian */
30 if (
31 (p[0] == 1 || p[0] == 2) /* protocol version 802.1X-2001 (WPA) or -2004 (WPA2) */ &&
32 p[1] == 3 /* EAPOL-Key */ &&
33 /* don't bother checking p[2] p[3] (hh ll, packet body length) */
34 (p[4] == 254 || p[4] == 2) /* descriptor type P802.1i-D3.0 (WPA) or 802.11i-2004 (WPA2) */ &&
35 ((keyinfo & 0x0007) == 1 || (keyinfo & 0x0007) == 2) /* key descriptor version */ &&
36 (keyinfo & ~0x0207U) == 0x0108 && /* key info for 4/4 or 4/2 -- ignore key desc version and sec bit (since varies in WPA 4/4) */
37 (p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 0] == 0 && /* key data length (2 octets) 0 for 4/4 only */
38 p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1] == 0)
39 ) {
40 unifi_trace(priv, UDBG1, "uf_verify_m4: M4 detected\n");
41 return 0;
42 } else {
43 return 1;
44 }
45}
46
47/*
48 * ---------------------------------------------------------------------------
49 *
50 * Data transport signals.
51 *
52 * ---------------------------------------------------------------------------
53 */
54
diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c
deleted file mode 100644
index 92898de921f5..000000000000
--- a/drivers/staging/csr/drv.c
+++ /dev/null
@@ -1,2193 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: drv.c
4 *
5 * PURPOSE:
6 * Conventional device interface for debugging/monitoring of the
7 * driver and h/w using unicli. This interface is also being used
8 * by the SME linux implementation and the helper apps.
9 *
10 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 * ---------------------------------------------------------------------------
16 */
17
18/*
19 * Porting Notes:
20 * Part of this file contains an example for how to glue the OS layer
21 * with the HIP core lib, the SDIO glue layer, and the SME.
22 *
23 * When the unifi_sdio.ko modules loads, the linux kernel calls unifi_load().
24 * unifi_load() calls uf_sdio_load() which is exported by the SDIO glue
25 * layer. uf_sdio_load() registers this driver with the underlying SDIO driver.
26 * When a card is detected, the SDIO glue layer calls register_unifi_sdio()
27 * to pass the SDIO function context and ask the OS layer to initialise
28 * the card. register_unifi_sdio() allocates all the private data of the OS
29 * layer and calls uf_run_unifihelper() to start the SME. The SME calls
30 * unifi_sys_wifi_on_req() which uses the HIP core lib to initialise the card.
31 */
32
33#include <linux/init.h>
34#include <linux/slab.h>
35#include <linux/poll.h>
36#include <asm/uaccess.h>
37#include <linux/jiffies.h>
38#include <linux/version.h>
39
40#include "csr_wifi_hip_unifiversion.h"
41#include "unifi_priv.h"
42#include "csr_wifi_hip_conversions.h"
43#include "unifi_native.h"
44
45/* Module parameter variables */
46int buswidth = 0; /* 0 means use default, values 1,4 */
47int sdio_clock = 50000; /* kHz */
48int unifi_debug = 0;
49/* fw_init prevents f/w initialisation on error. */
50int fw_init[MAX_UNIFI_DEVS] = {-1, -1};
51int use_5g = 0;
52int led_mask = 0; /* 0x0c00 for dev-pc-1503c, dev-pc-1528a */
53int disable_hw_reset = 0;
54int disable_power_control = 0;
55int enable_wol = UNIFI_WOL_OFF; /* 0 for none, 1 for SDIO IRQ, 2 for PIO */
56#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
57int tl_80211d = (int)CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB;
58#endif
59int sdio_block_size = -1; /* Override SDIO block size */
60int sdio_byte_mode = 0; /* 0 for block mode + padding, 1 for byte mode */
61int coredump_max = CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS;
62int run_bh_once = -1; /* Set for scheduled interrupt mode, -1 = default */
63int bh_priority = -1;
64#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
65#define UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA (1 << 1)
66#define UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP (1 << 2)
67int log_hip_signals = 0;
68#endif
69
70MODULE_DESCRIPTION("CSR UniFi (SDIO)");
71
72module_param(buswidth, int, S_IRUGO|S_IWUSR);
73module_param(sdio_clock, int, S_IRUGO|S_IWUSR);
74module_param(unifi_debug, int, S_IRUGO|S_IWUSR);
75module_param_array(fw_init, int, NULL, S_IRUGO|S_IWUSR);
76module_param(use_5g, int, S_IRUGO|S_IWUSR);
77module_param(led_mask, int, S_IRUGO|S_IWUSR);
78module_param(disable_hw_reset, int, S_IRUGO|S_IWUSR);
79module_param(disable_power_control, int, S_IRUGO|S_IWUSR);
80module_param(enable_wol, int, S_IRUGO|S_IWUSR);
81#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
82module_param(tl_80211d, int, S_IRUGO|S_IWUSR);
83#endif
84module_param(sdio_block_size, int, S_IRUGO|S_IWUSR);
85module_param(sdio_byte_mode, int, S_IRUGO|S_IWUSR);
86module_param(coredump_max, int, S_IRUGO|S_IWUSR);
87module_param(run_bh_once, int, S_IRUGO|S_IWUSR);
88module_param(bh_priority, int, S_IRUGO|S_IWUSR);
89#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
90module_param(log_hip_signals, int, S_IRUGO|S_IWUSR);
91#endif
92
93MODULE_PARM_DESC(buswidth, "SDIO bus width (0=default), set 1 for 1-bit or 4 for 4-bit mode");
94MODULE_PARM_DESC(sdio_clock, "SDIO bus frequency in kHz, (default = 50 MHz)");
95MODULE_PARM_DESC(unifi_debug, "Diagnostic reporting level");
96MODULE_PARM_DESC(fw_init, "Set to 0 to prevent f/w initialization on error");
97MODULE_PARM_DESC(use_5g, "Use the 5G (802.11a) radio band");
98MODULE_PARM_DESC(led_mask, "LED mask flags");
99MODULE_PARM_DESC(disable_hw_reset, "Set to 1 to disable hardware reset");
100MODULE_PARM_DESC(disable_power_control, "Set to 1 to disable SDIO power control");
101MODULE_PARM_DESC(enable_wol, "Enable wake-on-wlan function 0=off, 1=SDIO, 2=PIO");
102#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
103MODULE_PARM_DESC(tl_80211d, "802.11d Trust Level (1-6, default = 5)");
104#endif
105MODULE_PARM_DESC(sdio_block_size, "Set to override SDIO block size");
106MODULE_PARM_DESC(sdio_byte_mode, "Set to 1 for byte mode SDIO");
107MODULE_PARM_DESC(coredump_max, "Number of chip mini-coredump buffers to allocate");
108MODULE_PARM_DESC(run_bh_once, "Run BH only when firmware interrupts");
109MODULE_PARM_DESC(bh_priority, "Modify the BH thread priority");
110#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
111MODULE_PARM_DESC(log_hip_signals, "Set to 1 to enable HIP signal offline logging");
112#endif
113
114
115/* Callback for event logging to UDI clients */
116static void udi_log_event(ul_client_t *client,
117 const u8 *signal, int signal_len,
118 const bulk_data_param_t *bulkdata,
119 int dir);
120
121static void udi_set_log_filter(ul_client_t *pcli,
122 unifiio_filter_t *udi_filter);
123
124
125/* Mutex to protect access to priv->sme_cli */
126DEFINE_SEMAPHORE(udi_mutex);
127
128s32 CsrHipResultToStatus(CsrResult csrResult)
129{
130 s32 r = -EIO;
131
132 switch (csrResult)
133 {
134 case CSR_RESULT_SUCCESS:
135 r = 0;
136 break;
137 case CSR_WIFI_HIP_RESULT_RANGE:
138 r = -ERANGE;
139 break;
140 case CSR_WIFI_HIP_RESULT_NO_DEVICE:
141 r = -ENODEV;
142 break;
143 case CSR_WIFI_HIP_RESULT_INVALID_VALUE:
144 r = -EINVAL;
145 break;
146 case CSR_WIFI_HIP_RESULT_NOT_FOUND:
147 r = -ENOENT;
148 break;
149 case CSR_WIFI_HIP_RESULT_NO_SPACE:
150 r = -ENOSPC;
151 break;
152 case CSR_WIFI_HIP_RESULT_NO_MEMORY:
153 r = -ENOMEM;
154 break;
155 case CSR_RESULT_FAILURE:
156 r = -EIO;
157 break;
158 default:
159 /*unifi_warning(card->ospriv, "CsrHipResultToStatus: Unrecognised csrResult error code: %d\n", csrResult);*/
160 r = -EIO;
161 }
162 return r;
163}
164
165
166static const char*
167trace_putest_cmdid(unifi_putest_command_t putest_cmd)
168{
169 switch (putest_cmd) {
170 case UNIFI_PUTEST_START:
171 return "START";
172 case UNIFI_PUTEST_STOP:
173 return "STOP";
174 case UNIFI_PUTEST_SET_SDIO_CLOCK:
175 return "SET CLOCK";
176 case UNIFI_PUTEST_CMD52_READ:
177 return "CMD52R";
178 case UNIFI_PUTEST_CMD52_BLOCK_READ:
179 return "CMD52BR";
180 case UNIFI_PUTEST_CMD52_WRITE:
181 return "CMD52W";
182 case UNIFI_PUTEST_DL_FW:
183 return "D/L FW";
184 case UNIFI_PUTEST_DL_FW_BUFF:
185 return "D/L FW BUFFER";
186 case UNIFI_PUTEST_COREDUMP_PREPARE:
187 return "PREPARE COREDUMP";
188 case UNIFI_PUTEST_GP_READ16:
189 return "GP16R";
190 case UNIFI_PUTEST_GP_WRITE16:
191 return "GP16W";
192 default:
193 return "ERROR: unrecognised command";
194 }
195 }
196
197#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
198int uf_register_hip_offline_debug(unifi_priv_t *priv)
199{
200 ul_client_t *udi_cli;
201 int i;
202
203 udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event);
204 if (udi_cli == NULL) {
205 /* Too many clients already using this device */
206 unifi_error(priv, "Too many UDI clients already open\n");
207 return -ENOSPC;
208 }
209 unifi_trace(priv, UDBG1, "Offline HIP client is registered\n");
210
211 down(&priv->udi_logging_mutex);
212 udi_cli->event_hook = udi_log_event;
213 unifi_set_udi_hook(priv->card, logging_handler);
214 /* Log all signals by default */
215 for (i = 0; i < SIG_FILTER_SIZE; i++) {
216 udi_cli->signal_filter[i] = 0xFFFF;
217 }
218 priv->logging_client = udi_cli;
219 up(&priv->udi_logging_mutex);
220
221 return 0;
222}
223
224int uf_unregister_hip_offline_debug(unifi_priv_t *priv)
225{
226 ul_client_t *udi_cli = priv->logging_client;
227 if (udi_cli == NULL)
228 {
229 unifi_error(priv, "Unknown HIP client unregister request\n");
230 return -ERANGE;
231 }
232
233 unifi_trace(priv, UDBG1, "Offline HIP client is unregistered\n");
234
235 down(&priv->udi_logging_mutex);
236 priv->logging_client = NULL;
237 udi_cli->event_hook = NULL;
238 up(&priv->udi_logging_mutex);
239
240 ul_deregister_client(udi_cli);
241
242 return 0;
243}
244#endif
245
246
247/*
248 * ---------------------------------------------------------------------------
249 * unifi_open
250 * unifi_release
251 *
252 * Open and release entry points for the UniFi debug driver.
253 *
254 * Arguments:
255 * Normal linux driver args.
256 *
257 * Returns:
258 * Linux error code.
259 * ---------------------------------------------------------------------------
260 */
261static int
262unifi_open(struct inode *inode, struct file *file)
263{
264 int devno;
265 unifi_priv_t *priv;
266 ul_client_t *udi_cli;
267
268 devno = MINOR(inode->i_rdev) >> 1;
269
270 /*
271 * Increase the ref_count for the char device clients.
272 * Make sure you call uf_put_instance() to decreace it if
273 * unifi_open returns an error.
274 */
275 priv = uf_get_instance(devno);
276 if (priv == NULL) {
277 unifi_error(NULL, "unifi_open: No device present\n");
278 return -ENODEV;
279 }
280
281 /* Register this instance in the client's list. */
282 /* The minor number determines the nature of the client (Unicli or SME). */
283 if (MINOR(inode->i_rdev) & 0x1) {
284 udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event);
285 if (udi_cli == NULL) {
286 /* Too many clients already using this device */
287 unifi_error(priv, "Too many clients already open\n");
288 uf_put_instance(devno);
289 return -ENOSPC;
290 }
291 unifi_trace(priv, UDBG1, "Client is registered to /dev/unifiudi%d\n", devno);
292 } else {
293 /*
294 * Even-numbered device nodes are the control application.
295 * This is the userspace helper containing SME or
296 * unifi_manager.
297 */
298
299 down(&udi_mutex);
300
301#ifdef CSR_SME_USERSPACE
302 /* Check if a config client is already attached */
303 if (priv->sme_cli) {
304 up(&udi_mutex);
305 uf_put_instance(devno);
306
307 unifi_info(priv, "There is already a configuration client using the character device\n");
308 return -EBUSY;
309 }
310#endif /* CSR_SME_USERSPACE */
311
312#ifdef CSR_SUPPORT_SME
313 udi_cli = ul_register_client(priv,
314 CLI_USING_WIRE_FORMAT | CLI_SME_USERSPACE,
315 sme_log_event);
316#else
317 /* Config client for native driver */
318 udi_cli = ul_register_client(priv,
319 0,
320 sme_native_log_event);
321#endif
322 if (udi_cli == NULL) {
323 /* Too many clients already using this device */
324 up(&udi_mutex);
325 uf_put_instance(devno);
326
327 unifi_error(priv, "Too many clients already open\n");
328 return -ENOSPC;
329 }
330
331 /*
332 * Fill-in the pointer to the configuration client.
333 * This is the SME userspace helper or unifi_manager.
334 * Not used in the SME embedded version.
335 */
336 unifi_trace(priv, UDBG1, "SME client (id:%d s:0x%X) is registered\n",
337 udi_cli->client_id, udi_cli->sender_id);
338 /* Store the SME UniFi Linux Client */
339 if (priv->sme_cli == NULL) {
340 priv->sme_cli = udi_cli;
341 }
342
343 up(&udi_mutex);
344 }
345
346
347 /*
348 * Store the pointer to the client.
349 * All char driver's entry points will pass this pointer.
350 */
351 file->private_data = udi_cli;
352
353 return 0;
354} /* unifi_open() */
355
356
357static int
358unifi_release(struct inode *inode, struct file *filp)
359{
360 ul_client_t *udi_cli = (void*)filp->private_data;
361 int devno;
362 unifi_priv_t *priv;
363
364 priv = uf_find_instance(udi_cli->instance);
365 if (!priv) {
366 unifi_error(priv, "unifi_close: instance for device not found\n");
367 return -ENODEV;
368 }
369
370 devno = MINOR(inode->i_rdev) >> 1;
371
372 /* Even device nodes are the config client (i.e. SME or unifi_manager) */
373 if ((MINOR(inode->i_rdev) & 0x1) == 0) {
374
375 if (priv->sme_cli != udi_cli) {
376 unifi_notice(priv, "Surprise closing config device: not the sme client\n");
377 }
378 unifi_notice(priv, "SME client close (unifi%d)\n", devno);
379
380 /*
381 * Clear sme_cli before calling unifi_sys_... so it doesn't try to
382 * queue a reply to the (now gone) SME.
383 */
384 down(&udi_mutex);
385 priv->sme_cli = NULL;
386 up(&udi_mutex);
387
388#ifdef CSR_SME_USERSPACE
389 /* Power-down when config client closes */
390 {
391 CsrWifiRouterCtrlWifiOffReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, 0, 0, 0, NULL}};
392 CsrWifiRouterCtrlWifiOffReqHandler(priv, &req.common);
393 }
394
395 uf_sme_deinit(priv);
396
397 /* It is possible that a blocking SME request was made from another process
398 * which did not get read by the SME before the WifiOffReq.
399 * So check for a pending request which will go unanswered and cancel
400 * the wait for event. As only one blocking request can be in progress at
401 * a time, up to one event should be completed.
402 */
403 uf_sme_cancel_request(priv, 0);
404
405#endif /* CSR_SME_USERSPACE */
406 } else {
407
408 unifi_trace(priv, UDBG2, "UDI client close (unifiudi%d)\n", devno);
409
410 /* If the pointer matches the logging client, stop logging. */
411 down(&priv->udi_logging_mutex);
412 if (udi_cli == priv->logging_client) {
413 priv->logging_client = NULL;
414 }
415 up(&priv->udi_logging_mutex);
416
417 if (udi_cli == priv->amp_client) {
418 priv->amp_client = NULL;
419 }
420 }
421
422 /* Deregister this instance from the client's list. */
423 ul_deregister_client(udi_cli);
424
425 uf_put_instance(devno);
426
427 return 0;
428} /* unifi_release() */
429
430
431
432/*
433 * ---------------------------------------------------------------------------
434 * unifi_read
435 *
436 * The read() driver entry point.
437 *
438 * Arguments:
439 * filp The file descriptor returned by unifi_open()
440 * p The user space buffer to copy the read data
441 * len The size of the p buffer
442 * poff
443 *
444 * Returns:
445 * number of bytes read or an error code on failure
446 * ---------------------------------------------------------------------------
447 */
448static ssize_t
449unifi_read(struct file *filp, char *p, size_t len, loff_t *poff)
450{
451 ul_client_t *pcli = (void*)filp->private_data;
452 unifi_priv_t *priv;
453 udi_log_t *logptr = NULL;
454 udi_msg_t *msgptr;
455 struct list_head *l;
456 int msglen;
457
458 priv = uf_find_instance(pcli->instance);
459 if (!priv) {
460 unifi_error(priv, "invalid priv\n");
461 return -ENODEV;
462 }
463
464 if (!pcli->udi_enabled) {
465 unifi_error(priv, "unifi_read: unknown client.");
466 return -EINVAL;
467 }
468
469 if (list_empty(&pcli->udi_log)) {
470 if (filp->f_flags & O_NONBLOCK) {
471 /* Non-blocking - just return if the udi_log is empty */
472 return 0;
473 } else {
474 /* Blocking - wait on the UDI wait queue */
475 if (wait_event_interruptible(pcli->udi_wq,
476 !list_empty(&pcli->udi_log)))
477 {
478 unifi_error(priv, "unifi_read: wait_event_interruptible failed.");
479 return -ERESTARTSYS;
480 }
481 }
482 }
483
484 /* Read entry from list head and remove it from the list */
485 if (down_interruptible(&pcli->udi_sem)) {
486 return -ERESTARTSYS;
487 }
488 l = pcli->udi_log.next;
489 list_del(l);
490 up(&pcli->udi_sem);
491
492 /* Get a pointer to whole struct */
493 logptr = list_entry(l, udi_log_t, q);
494 if (logptr == NULL) {
495 unifi_error(priv, "unifi_read: failed to get event.\n");
496 return -EINVAL;
497 }
498
499 /* Get the real message */
500 msgptr = &logptr->msg;
501 msglen = msgptr->length;
502 if (msglen > len) {
503 printk(KERN_WARNING "truncated read to %d actual msg len is %lu\n", msglen, (long unsigned int)len);
504 msglen = len;
505 }
506
507 /* and pass it to the client (SME or Unicli). */
508 if (copy_to_user(p, msgptr, msglen))
509 {
510 printk(KERN_ERR "Failed to copy UDI log to user\n");
511 kfree(logptr);
512 return -EFAULT;
513 }
514
515 /* It is our resposibility to free the message buffer. */
516 kfree(logptr);
517
518 return msglen;
519
520} /* unifi_read() */
521
522
523
524/*
525 * ---------------------------------------------------------------------------
526 * udi_send_signal_unpacked
527 *
528 * Sends an unpacked signal to UniFi.
529 *
530 * Arguments:
531 * priv Pointer to private context struct
532 * data Pointer to request structure and data to send
533 * data_len Length of data in data pointer.
534 *
535 * Returns:
536 * Number of bytes written, error otherwise.
537 *
538 * Notes:
539 * All clients that use this function to send a signal to the unifi
540 * must use the host formatted structures.
541 * ---------------------------------------------------------------------------
542 */
543static int
544udi_send_signal_unpacked(unifi_priv_t *priv, unsigned char* data, uint data_len)
545{
546 CSR_SIGNAL *sigptr = (CSR_SIGNAL*)data;
547 CSR_DATAREF *datarefptr;
548 bulk_data_param_t bulk_data;
549 uint signal_size, i;
550 uint bulk_data_offset = 0;
551 int bytecount, r;
552 CsrResult csrResult;
553
554 /* Number of bytes in the signal */
555 signal_size = SigGetSize(sigptr);
556 if (!signal_size || (signal_size > data_len)) {
557 unifi_error(priv, "unifi_sme_mlme_req - Invalid signal 0x%x size should be %d bytes\n",
558 sigptr->SignalPrimitiveHeader.SignalId,
559 signal_size);
560 return -EINVAL;
561 }
562 bytecount = signal_size;
563
564 /* Get a pointer to the information of the first data reference */
565 datarefptr = (CSR_DATAREF*)&sigptr->u;
566
567 /* Initialize the offset in the data buffer, bulk data is right after the signal. */
568 bulk_data_offset = signal_size;
569
570 /* store the references and the size of the bulk data to the bulkdata structure */
571 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
572 /* the length of the bulk data is in the signal */
573 if ((datarefptr+i)->DataLength) {
574 void *dest;
575
576 csrResult = unifi_net_data_malloc(priv, &bulk_data.d[i], (datarefptr+i)->DataLength);
577 if (csrResult != CSR_RESULT_SUCCESS) {
578 unifi_error(priv, "udi_send_signal_unpacked: failed to allocate request_data.\n");
579 return -EIO;
580 }
581
582 dest = (void*)bulk_data.d[i].os_data_ptr;
583 memcpy(dest, data + bulk_data_offset, bulk_data.d[i].data_length);
584 } else {
585 bulk_data.d[i].data_length = 0;
586 }
587
588 bytecount += bulk_data.d[i].data_length;
589 /* advance the offset, to point the next bulk data */
590 bulk_data_offset += bulk_data.d[i].data_length;
591 }
592
593
594 unifi_trace(priv, UDBG3, "SME Send: signal 0x%.4X\n", sigptr->SignalPrimitiveHeader.SignalId);
595
596 /* Send the signal. */
597 r = ul_send_signal_unpacked(priv, sigptr, &bulk_data);
598 if (r < 0) {
599 unifi_error(priv, "udi_send_signal_unpacked: send failed (%d)\n", r);
600 for(i=0;i<UNIFI_MAX_DATA_REFERENCES;i++) {
601 if(bulk_data.d[i].data_length != 0) {
602 unifi_net_data_free(priv, &bulk_data.d[i]);
603 }
604 }
605 return -EIO;
606 }
607
608 return bytecount;
609} /* udi_send_signal_unpacked() */
610
611
612
613/*
614 * ---------------------------------------------------------------------------
615 * udi_send_signal_raw
616 *
617 * Sends a packed signal to UniFi.
618 *
619 * Arguments:
620 * priv Pointer to private context struct
621 * buf Pointer to request structure and data to send
622 * buflen Length of data in data pointer.
623 *
624 * Returns:
625 * Number of bytes written, error otherwise.
626 *
627 * Notes:
628 * All clients that use this function to send a signal to the unifi
629 * must use the wire formatted structures.
630 * ---------------------------------------------------------------------------
631 */
632static int
633udi_send_signal_raw(unifi_priv_t *priv, unsigned char *buf, int buflen)
634{
635 int signal_size;
636 int sig_id;
637 bulk_data_param_t data_ptrs;
638 int i, r;
639 unsigned int num_data_refs;
640 int bytecount;
641 CsrResult csrResult;
642
643 /*
644 * The signal is the first thing in buf, the signal id is the
645 * first 16 bits of the signal.
646 */
647 /* Number of bytes in the signal */
648 sig_id = GET_SIGNAL_ID(buf);
649 signal_size = buflen;
650 signal_size -= GET_PACKED_DATAREF_LEN(buf, 0);
651 signal_size -= GET_PACKED_DATAREF_LEN(buf, 1);
652 if ((signal_size <= 0) || (signal_size > buflen)) {
653 unifi_error(priv, "udi_send_signal_raw - Couldn't find length of signal 0x%x\n",
654 sig_id);
655 return -EINVAL;
656 }
657 unifi_trace(priv, UDBG2, "udi_send_signal_raw: signal 0x%.4X len:%d\n",
658 sig_id, signal_size);
659 /* Zero the data ref arrays */
660 memset(&data_ptrs, 0, sizeof(data_ptrs));
661
662 /*
663 * Find the number of associated bulk data packets. Scan through
664 * the data refs to check that we have enough data and pick out
665 * pointers to appended bulk data.
666 */
667 num_data_refs = 0;
668 bytecount = signal_size;
669
670 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
671 {
672 unsigned int len = GET_PACKED_DATAREF_LEN(buf, i);
673 unifi_trace(priv, UDBG3, "udi_send_signal_raw: data_ref length = %d\n", len);
674
675 if (len != 0) {
676 void *dest;
677
678 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[i], len);
679 if (csrResult != CSR_RESULT_SUCCESS) {
680 unifi_error(priv, "udi_send_signal_raw: failed to allocate request_data.\n");
681 return -EIO;
682 }
683
684 dest = (void*)data_ptrs.d[i].os_data_ptr;
685 memcpy(dest, buf + bytecount, len);
686
687 bytecount += len;
688 num_data_refs++;
689 }
690 data_ptrs.d[i].data_length = len;
691 }
692
693 unifi_trace(priv, UDBG3, "Queueing signal 0x%.4X from UDI with %u data refs\n",
694 sig_id,
695 num_data_refs);
696
697 if (bytecount > buflen) {
698 unifi_error(priv, "udi_send_signal_raw: Not enough data (%d instead of %d)\n", buflen, bytecount);
699 return -EINVAL;
700 }
701
702 /* Send the signal calling the function that uses the wire-formatted signals. */
703 r = ul_send_signal_raw(priv, buf, signal_size, &data_ptrs);
704 if (r < 0) {
705 unifi_error(priv, "udi_send_signal_raw: send failed (%d)\n", r);
706 return -EIO;
707 }
708
709#ifdef CSR_NATIVE_LINUX
710 if (sig_id == CSR_MLME_POWERMGT_REQUEST_ID) {
711 int power_mode = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((buf +
712 SIZEOF_SIGNAL_HEADER + (UNIFI_MAX_DATA_REFERENCES*SIZEOF_DATAREF)));
713#ifdef CSR_SUPPORT_WEXT
714 /* Overide the wext power mode to the new value */
715 priv->wext_conf.power_mode = power_mode;
716#endif
717 /* Configure deep sleep signaling */
718 if (power_mode || (priv->interfacePriv[0]->connected == UnifiNotConnected)) {
719 csrResult = unifi_configure_low_power_mode(priv->card,
720 UNIFI_LOW_POWER_ENABLED,
721 UNIFI_PERIODIC_WAKE_HOST_DISABLED);
722 } else {
723 csrResult = unifi_configure_low_power_mode(priv->card,
724 UNIFI_LOW_POWER_DISABLED,
725 UNIFI_PERIODIC_WAKE_HOST_DISABLED);
726 }
727 }
728#endif
729
730 return bytecount;
731} /* udi_send_signal_raw */
732
733/*
734 * ---------------------------------------------------------------------------
735 * unifi_write
736 *
737 * The write() driver entry point.
738 * A UniFi Debug Interface client such as unicli can write a signal
739 * plus bulk data to the driver for sending to the UniFi chip.
740 *
741 * Only one signal may be sent per write operation.
742 *
743 * Arguments:
744 * filp The file descriptor returned by unifi_open()
745 * p The user space buffer to get the data from
746 * len The size of the p buffer
747 * poff
748 *
749 * Returns:
750 * number of bytes written or an error code on failure
751 * ---------------------------------------------------------------------------
752 */
753static ssize_t
754unifi_write(struct file *filp, const char *p, size_t len, loff_t *poff)
755{
756 ul_client_t *pcli = (ul_client_t*)filp->private_data;
757 unifi_priv_t *priv;
758 unsigned char *buf;
759 unsigned char *bufptr;
760 int remaining;
761 int bytes_written;
762 int r;
763 bulk_data_param_t bulkdata;
764 CsrResult csrResult;
765
766 priv = uf_find_instance(pcli->instance);
767 if (!priv) {
768 unifi_error(priv, "invalid priv\n");
769 return -ENODEV;
770 }
771
772 unifi_trace(priv, UDBG5, "unifi_write: len = %d\n", len);
773
774 if (!pcli->udi_enabled) {
775 unifi_error(priv, "udi disabled\n");
776 return -EINVAL;
777 }
778
779 /*
780 * AMP client sends only one signal at a time, so we can use
781 * unifi_net_data_malloc to save the extra copy.
782 */
783 if (pcli == priv->amp_client) {
784 int signal_size;
785 int sig_id;
786 unsigned char *signal_buf;
787 char *user_data_buf;
788
789 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], len);
790 if (csrResult != CSR_RESULT_SUCCESS) {
791 unifi_error(priv, "unifi_write: failed to allocate request_data.\n");
792 return -ENOMEM;
793 }
794
795 user_data_buf = (char*)bulkdata.d[0].os_data_ptr;
796
797 /* Get the data from the AMP client. */
798 if (copy_from_user((void*)user_data_buf, p, len)) {
799 unifi_error(priv, "unifi_write: copy from user failed\n");
800 unifi_net_data_free(priv, &bulkdata.d[0]);
801 return -EFAULT;
802 }
803
804 bulkdata.d[1].os_data_ptr = NULL;
805 bulkdata.d[1].data_length = 0;
806
807 /* Number of bytes in the signal */
808 sig_id = GET_SIGNAL_ID(bulkdata.d[0].os_data_ptr);
809 signal_size = len;
810 signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 0);
811 signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 1);
812 if ((signal_size <= 0) || (signal_size > len)) {
813 unifi_error(priv, "unifi_write - Couldn't find length of signal 0x%x\n",
814 sig_id);
815 unifi_net_data_free(priv, &bulkdata.d[0]);
816 return -EINVAL;
817 }
818
819 unifi_trace(priv, UDBG2, "unifi_write: signal 0x%.4X len:%d\n",
820 sig_id, signal_size);
821
822 /* Allocate a buffer for the signal */
823 signal_buf = kmemdup(bulkdata.d[0].os_data_ptr, signal_size,
824 GFP_KERNEL);
825 if (!signal_buf) {
826 unifi_net_data_free(priv, &bulkdata.d[0]);
827 return -ENOMEM;
828 }
829
830 /* Get the signal from the os_data_ptr */
831 signal_buf[5] = (pcli->sender_id >> 8) & 0xff;
832
833 if (signal_size < len) {
834 /* Remove the signal from the os_data_ptr */
835 bulkdata.d[0].data_length -= signal_size;
836 bulkdata.d[0].os_data_ptr += signal_size;
837 } else {
838 bulkdata.d[0].data_length = 0;
839 bulkdata.d[0].os_data_ptr = NULL;
840 }
841
842 /* Send the signal calling the function that uses the wire-formatted signals. */
843 r = ul_send_signal_raw(priv, signal_buf, signal_size, &bulkdata);
844 if (r < 0) {
845 unifi_error(priv, "unifi_write: send failed (%d)\n", r);
846 if (bulkdata.d[0].os_data_ptr != NULL) {
847 unifi_net_data_free(priv, &bulkdata.d[0]);
848 }
849 }
850
851 /* Free the signal buffer and return */
852 kfree(signal_buf);
853 return len;
854 }
855
856 buf = kmalloc(len, GFP_KERNEL);
857 if (!buf) {
858 return -ENOMEM;
859 }
860
861 /* Get the data from the client (SME or Unicli). */
862 if (copy_from_user((void*)buf, p, len)) {
863 unifi_error(priv, "copy from user failed\n");
864 kfree(buf);
865 return -EFAULT;
866 }
867
868 /*
869 * In SME userspace build read() contains a SYS or MGT message.
870 * Note that even though the SME sends one signal at a time, we can not
871 * use unifi_net_data_malloc because in the early stages, before having
872 * initialised the core, it will fail since the I/O block size is unknown.
873 */
874#ifdef CSR_SME_USERSPACE
875 if (pcli->configuration & CLI_SME_USERSPACE) {
876 CsrWifiRouterTransportRecv(priv, buf, len);
877 kfree(buf);
878 return len;
879 }
880#endif
881
882 /* ul_send_signal_raw will do a sanity check of len against signal content */
883
884 /*
885 * udi_send_signal_raw() and udi_send_signal_unpacked() return the number of bytes consumed.
886 * A write call can pass multiple signal concatenated together.
887 */
888 bytes_written = 0;
889 remaining = len;
890 bufptr = buf;
891 while (remaining > 0)
892 {
893 int r;
894
895 /*
896 * Set the SenderProcessId.
897 * The SignalPrimitiveHeader is the first 3 16-bit words of the signal,
898 * the SenderProcessId is bytes 4,5.
899 * The MSB of the sender ID needs to be set to the client ID.
900 * The LSB is controlled by the SME.
901 */
902 bufptr[5] = (pcli->sender_id >> 8) & 0xff;
903
904 /* use the appropriate interface, depending on the clients' configuration */
905 if (pcli->configuration & CLI_USING_WIRE_FORMAT) {
906 unifi_trace(priv, UDBG1, "unifi_write: call udi_send_signal().\n");
907 r = udi_send_signal_raw(priv, bufptr, remaining);
908 } else {
909 r = udi_send_signal_unpacked(priv, bufptr, remaining);
910 }
911 if (r < 0) {
912 /* Set the return value to the error code */
913 unifi_error(priv, "unifi_write: (udi or sme)_send_signal() returns %d\n", r);
914 bytes_written = r;
915 break;
916 }
917 bufptr += r;
918 remaining -= r;
919 bytes_written += r;
920 }
921
922 kfree(buf);
923
924 return bytes_written;
925} /* unifi_write() */
926
927
928static const char* build_type_to_string(unsigned char build_type)
929{
930 switch (build_type)
931 {
932 case UNIFI_BUILD_NME: return "NME";
933 case UNIFI_BUILD_WEXT: return "WEXT";
934 case UNIFI_BUILD_AP: return "AP";
935 }
936 return "unknown";
937}
938
939
940/*
941 * ----------------------------------------------------------------
942 * unifi_ioctl
943 *
944 * Ioctl handler for unifi driver.
945 *
946 * Arguments:
947 * inodep Pointer to inode structure.
948 * filp Pointer to file structure.
949 * cmd Ioctl cmd passed by user.
950 * arg Ioctl arg passed by user.
951 *
952 * Returns:
953 * 0 on success, -ve error code on error.
954 * ----------------------------------------------------------------
955 */
956static long
957unifi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
958{
959 ul_client_t *pcli = (ul_client_t*)filp->private_data;
960 unifi_priv_t *priv;
961 struct net_device *dev;
962 int r = 0;
963 int int_param, i;
964 u8* buf;
965 CsrResult csrResult;
966#if (defined CSR_SUPPORT_SME)
967 unifi_cfg_command_t cfg_cmd;
968#if (defined CSR_SUPPORT_WEXT)
969 CsrWifiSmeCoexConfig coex_config;
970 unsigned char uchar_param;
971 unsigned char varbind[MAX_VARBIND_LENGTH];
972 int vblen;
973#endif
974#endif
975 unifi_putest_command_t putest_cmd;
976
977 priv = uf_find_instance(pcli->instance);
978 if (!priv) {
979 unifi_error(priv, "ioctl error: unknown instance=%d\n", pcli->instance);
980 r = -ENODEV;
981 goto out;
982 }
983 unifi_trace(priv, UDBG5, "unifi_ioctl: cmd=0x%X, arg=0x%lX\n", cmd, arg);
984
985 switch (cmd) {
986
987 case UNIFI_GET_UDI_ENABLE:
988 unifi_trace(priv, UDBG4, "UniFi Get UDI Enable\n");
989
990 down(&priv->udi_logging_mutex);
991 int_param = (priv->logging_client == NULL) ? 0 : 1;
992 up(&priv->udi_logging_mutex);
993
994 if (put_user(int_param, (int*)arg))
995 {
996 unifi_error(priv, "UNIFI_GET_UDI_ENABLE: Failed to copy to user\n");
997 r = -EFAULT;
998 goto out;
999 }
1000 break;
1001
1002 case UNIFI_SET_UDI_ENABLE:
1003 unifi_trace(priv, UDBG4, "UniFi Set UDI Enable\n");
1004 if (get_user(int_param, (int*)arg))
1005 {
1006 unifi_error(priv, "UNIFI_SET_UDI_ENABLE: Failed to copy from user\n");
1007 r = -EFAULT;
1008 goto out;
1009 }
1010
1011#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1012 if (log_hip_signals) {
1013 unifi_error(priv, "omnicli cannot be used when log_hip_signals is used\n");
1014 r = -EFAULT;
1015 goto out;
1016 }
1017#endif
1018
1019 down(&priv->udi_logging_mutex);
1020 if (int_param) {
1021 pcli->event_hook = udi_log_event;
1022 unifi_set_udi_hook(priv->card, logging_handler);
1023 /* Log all signals by default */
1024 for (i = 0; i < SIG_FILTER_SIZE; i++) {
1025 pcli->signal_filter[i] = 0xFFFF;
1026 }
1027 priv->logging_client = pcli;
1028
1029 } else {
1030 priv->logging_client = NULL;
1031 pcli->event_hook = NULL;
1032 }
1033 up(&priv->udi_logging_mutex);
1034
1035 break;
1036
1037 case UNIFI_SET_MIB:
1038 unifi_trace(priv, UDBG4, "UniFi Set MIB\n");
1039#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
1040 /* Read first 2 bytes and check length */
1041 if (copy_from_user((void*)varbind, (void*)arg, 2)) {
1042 unifi_error(priv,
1043 "UNIFI_SET_MIB: Failed to copy in varbind header\n");
1044 r = -EFAULT;
1045 goto out;
1046 }
1047 vblen = varbind[1];
1048 if ((vblen + 2) > MAX_VARBIND_LENGTH) {
1049 unifi_error(priv,
1050 "UNIFI_SET_MIB: Varbind too long (%d, limit %d)\n",
1051 (vblen+2), MAX_VARBIND_LENGTH);
1052 r = -EINVAL;
1053 goto out;
1054 }
1055 /* Read rest of varbind */
1056 if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) {
1057 unifi_error(priv, "UNIFI_SET_MIB: Failed to copy in varbind\n");
1058 r = -EFAULT;
1059 goto out;
1060 }
1061
1062 /* send to SME */
1063 vblen += 2;
1064 r = sme_mgt_mib_set(priv, varbind, vblen);
1065 if (r) {
1066 goto out;
1067 }
1068#else
1069 unifi_notice(priv, "UNIFI_SET_MIB: Unsupported.\n");
1070#endif /* CSR_SUPPORT_WEXT */
1071 break;
1072
1073 case UNIFI_GET_MIB:
1074 unifi_trace(priv, UDBG4, "UniFi Get MIB\n");
1075#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
1076 /* Read first 2 bytes and check length */
1077 if (copy_from_user((void*)varbind, (void*)arg, 2)) {
1078 unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind header\n");
1079 r = -EFAULT;
1080 goto out;
1081 }
1082 vblen = varbind[1];
1083 if ((vblen+2) > MAX_VARBIND_LENGTH) {
1084 unifi_error(priv, "UNIFI_GET_MIB: Varbind too long (%d, limit %d)\n",
1085 (vblen+2), MAX_VARBIND_LENGTH);
1086 r = -EINVAL;
1087 goto out;
1088 }
1089 /* Read rest of varbind */
1090 if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) {
1091 unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind\n");
1092 r = -EFAULT;
1093 goto out;
1094 }
1095
1096 vblen += 2;
1097 r = sme_mgt_mib_get(priv, varbind, &vblen);
1098 if (r) {
1099 goto out;
1100 }
1101 /* copy out varbind */
1102 if (vblen > MAX_VARBIND_LENGTH) {
1103 unifi_error(priv,
1104 "UNIFI_GET_MIB: Varbind result too long (%d, limit %d)\n",
1105 vblen, MAX_VARBIND_LENGTH);
1106 r = -EINVAL;
1107 goto out;
1108 }
1109 if (copy_to_user((void*)arg, varbind, vblen)) {
1110 r = -EFAULT;
1111 goto out;
1112 }
1113#else
1114 unifi_notice(priv, "UNIFI_GET_MIB: Unsupported.\n");
1115#endif /* CSR_SUPPORT_WEXT */
1116 break;
1117
1118 case UNIFI_CFG:
1119#if (defined CSR_SUPPORT_SME)
1120 if (get_user(cfg_cmd, (unifi_cfg_command_t*)arg))
1121 {
1122 unifi_error(priv, "UNIFI_CFG: Failed to get the command\n");
1123 r = -EFAULT;
1124 goto out;
1125 }
1126
1127 unifi_trace(priv, UDBG1, "UNIFI_CFG: Command is %d (t=%u) sz=%d\n",
1128 cfg_cmd, jiffies_to_msecs(jiffies), sizeof(unifi_cfg_command_t));
1129 switch (cfg_cmd) {
1130 case UNIFI_CFG_POWER:
1131 r = unifi_cfg_power(priv, (unsigned char*)arg);
1132 break;
1133 case UNIFI_CFG_POWERSAVE:
1134 r = unifi_cfg_power_save(priv, (unsigned char*)arg);
1135 break;
1136 case UNIFI_CFG_POWERSUPPLY:
1137 r = unifi_cfg_power_supply(priv, (unsigned char*)arg);
1138 break;
1139 case UNIFI_CFG_FILTER:
1140 r = unifi_cfg_packet_filters(priv, (unsigned char*)arg);
1141 break;
1142 case UNIFI_CFG_GET:
1143 r = unifi_cfg_get_info(priv, (unsigned char*)arg);
1144 break;
1145 case UNIFI_CFG_WMM_QOSINFO:
1146 r = unifi_cfg_wmm_qos_info(priv, (unsigned char*)arg);
1147 break;
1148 case UNIFI_CFG_WMM_ADDTS:
1149 r = unifi_cfg_wmm_addts(priv, (unsigned char*)arg);
1150 break;
1151 case UNIFI_CFG_WMM_DELTS:
1152 r = unifi_cfg_wmm_delts(priv, (unsigned char*)arg);
1153 break;
1154 case UNIFI_CFG_STRICT_DRAFT_N:
1155 r = unifi_cfg_strict_draft_n(priv, (unsigned char*)arg);
1156 break;
1157 case UNIFI_CFG_ENABLE_OKC:
1158 r = unifi_cfg_enable_okc(priv, (unsigned char*)arg);
1159 break;
1160#ifdef CSR_SUPPORT_SME
1161 case UNIFI_CFG_CORE_DUMP:
1162 CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, CSR_WIFI_SME_CONTROL_INDICATION_ERROR);
1163 unifi_trace(priv, UDBG2, "UNIFI_CFG_CORE_DUMP: sent wifi off indication\n");
1164 break;
1165#endif
1166#ifdef CSR_SUPPORT_WEXT_AP
1167 case UNIFI_CFG_SET_AP_CONFIG:
1168 r= unifi_cfg_set_ap_config(priv, (unsigned char*)arg);
1169 break;
1170#endif
1171 default:
1172 unifi_error(priv, "UNIFI_CFG: Unknown Command (%d)\n", cfg_cmd);
1173 r = -EINVAL;
1174 goto out;
1175 }
1176#endif
1177
1178 break;
1179
1180 case UNIFI_PUTEST:
1181 if (get_user(putest_cmd, (unifi_putest_command_t*)arg))
1182 {
1183 unifi_error(priv, "UNIFI_PUTEST: Failed to get the command\n");
1184 r = -EFAULT;
1185 goto out;
1186 }
1187
1188 unifi_trace(priv, UDBG1, "UNIFI_PUTEST: Command is %s\n",
1189 trace_putest_cmdid(putest_cmd));
1190 switch (putest_cmd) {
1191 case UNIFI_PUTEST_START:
1192 r = unifi_putest_start(priv, (unsigned char*)arg);
1193 break;
1194 case UNIFI_PUTEST_STOP:
1195 r = unifi_putest_stop(priv, (unsigned char*)arg);
1196 break;
1197 case UNIFI_PUTEST_SET_SDIO_CLOCK:
1198 r = unifi_putest_set_sdio_clock(priv, (unsigned char*)arg);
1199 break;
1200 case UNIFI_PUTEST_CMD52_READ:
1201 r = unifi_putest_cmd52_read(priv, (unsigned char*)arg);
1202 break;
1203 case UNIFI_PUTEST_CMD52_BLOCK_READ:
1204 r = unifi_putest_cmd52_block_read(priv, (unsigned char*)arg);
1205 break;
1206 case UNIFI_PUTEST_CMD52_WRITE:
1207 r = unifi_putest_cmd52_write(priv, (unsigned char*)arg);
1208 break;
1209 case UNIFI_PUTEST_DL_FW:
1210 r = unifi_putest_dl_fw(priv, (unsigned char*)arg);
1211 break;
1212 case UNIFI_PUTEST_DL_FW_BUFF:
1213 r = unifi_putest_dl_fw_buff(priv, (unsigned char*)arg);
1214 break;
1215 case UNIFI_PUTEST_COREDUMP_PREPARE:
1216 r = unifi_putest_coredump_prepare(priv, (unsigned char*)arg);
1217 break;
1218 case UNIFI_PUTEST_GP_READ16:
1219 r = unifi_putest_gp_read16(priv, (unsigned char*)arg);
1220 break;
1221 case UNIFI_PUTEST_GP_WRITE16:
1222 r = unifi_putest_gp_write16(priv, (unsigned char*)arg);
1223 break;
1224 default:
1225 unifi_error(priv, "UNIFI_PUTEST: Unknown Command (%d)\n", putest_cmd);
1226 r = -EINVAL;
1227 goto out;
1228 }
1229
1230 break;
1231 case UNIFI_BUILD_TYPE:
1232 unifi_trace(priv, UDBG2, "UNIFI_BUILD_TYPE userspace=%s\n", build_type_to_string(*(unsigned char*)arg));
1233#ifndef CSR_SUPPORT_WEXT_AP
1234 if (UNIFI_BUILD_AP == *(unsigned char*)arg)
1235 {
1236 unifi_error(priv, "Userspace has AP support, which is incompatible\n");
1237 }
1238#endif
1239
1240#ifndef CSR_SUPPORT_WEXT
1241 if (UNIFI_BUILD_WEXT == *(unsigned char*)arg)
1242 {
1243 unifi_error(priv, "Userspace has WEXT support, which is incompatible\n");
1244 }
1245#endif
1246 break;
1247 case UNIFI_INIT_HW:
1248 unifi_trace(priv, UDBG2, "UNIFI_INIT_HW.\n");
1249 priv->init_progress = UNIFI_INIT_NONE;
1250
1251#if defined(CSR_SUPPORT_WEXT) || defined (CSR_NATIVE_LINUX)
1252 /* At this point we are ready to start the SME. */
1253 r = sme_mgt_wifi_on(priv);
1254 if (r) {
1255 goto out;
1256 }
1257#endif
1258
1259 break;
1260
1261 case UNIFI_INIT_NETDEV:
1262 {
1263 /* get the proper interfaceTagId */
1264 u16 interfaceTag=0;
1265 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1266
1267 dev = priv->netdev[interfaceTag];
1268 unifi_trace(priv, UDBG2, "UNIFI_INIT_NETDEV.\n");
1269
1270 if (copy_from_user((void*)dev->dev_addr, (void*)arg, 6)) {
1271 r = -EFAULT;
1272 goto out;
1273 }
1274
1275 /* Attach the network device to the stack */
1276 if (!interfacePriv->netdev_registered)
1277 {
1278 r = uf_register_netdev(priv, interfaceTag);
1279 if (r) {
1280 unifi_error(priv, "Failed to register the network device.\n");
1281 goto out;
1282 }
1283 }
1284
1285 /* Apply scheduled interrupt mode, if requested by module param */
1286 if (run_bh_once != -1) {
1287 unifi_set_interrupt_mode(priv->card, (u32)run_bh_once);
1288 }
1289
1290 priv->init_progress = UNIFI_INIT_COMPLETED;
1291
1292 /* Firmware initialisation is complete, so let the SDIO bus
1293 * clock be raised when convienent to the core.
1294 */
1295 unifi_request_max_sdio_clock(priv->card);
1296
1297#ifdef CSR_SUPPORT_WEXT
1298 /* Notify the Android wpa_supplicant that we are ready */
1299 wext_send_started_event(priv);
1300#endif
1301
1302 unifi_info(priv, "UniFi ready\n");
1303
1304#ifdef ANDROID_BUILD
1305 /* Release the wakelock */
1306 unifi_trace(priv, UDBG1, "netdev_init: release wake lock\n");
1307 wake_unlock(&unifi_sdio_wake_lock);
1308#endif
1309#ifdef CSR_NATIVE_SOFTMAC /* For softmac dev, force-enable the network interface rather than wait for a connected-ind */
1310 {
1311 struct net_device *dev = priv->netdev[interfaceTag];
1312#ifdef CSR_SUPPORT_WEXT
1313 interfacePriv->wait_netdev_change = TRUE;
1314#endif
1315 netif_carrier_on(dev);
1316 }
1317#endif
1318 }
1319 break;
1320 case UNIFI_GET_INIT_STATUS:
1321 unifi_trace(priv, UDBG2, "UNIFI_GET_INIT_STATUS.\n");
1322 if (put_user(priv->init_progress, (int*)arg))
1323 {
1324 printk(KERN_ERR "UNIFI_GET_INIT_STATUS: Failed to copy to user\n");
1325 r = -EFAULT;
1326 goto out;
1327 }
1328 break;
1329
1330 case UNIFI_KICK:
1331 unifi_trace(priv, UDBG4, "Kick UniFi\n");
1332 unifi_sdio_interrupt_handler(priv->card);
1333 break;
1334
1335 case UNIFI_SET_DEBUG:
1336 unifi_debug = arg;
1337 unifi_trace(priv, UDBG4, "unifi_debug set to %d\n", unifi_debug);
1338 break;
1339
1340 case UNIFI_SET_TRACE:
1341 /* no longer supported */
1342 r = -EINVAL;
1343 break;
1344
1345
1346 case UNIFI_SET_UDI_LOG_MASK:
1347 {
1348 unifiio_filter_t udi_filter;
1349 uint16_t *sig_ids_addr;
1350#define UF_MAX_SIG_IDS 128 /* Impose a sensible limit */
1351
1352 if (copy_from_user((void*)(&udi_filter), (void*)arg, sizeof(udi_filter))) {
1353 r = -EFAULT;
1354 goto out;
1355 }
1356 if ((udi_filter.action < UfSigFil_AllOn) ||
1357 (udi_filter.action > UfSigFil_SelectOff))
1358 {
1359 printk(KERN_WARNING
1360 "UNIFI_SET_UDI_LOG_MASK: Bad action value: %d\n",
1361 udi_filter.action);
1362 r = -EINVAL;
1363 goto out;
1364 }
1365 /* No signal list for "All" actions */
1366 if ((udi_filter.action == UfSigFil_AllOn) ||
1367 (udi_filter.action == UfSigFil_AllOff))
1368 {
1369 udi_filter.num_sig_ids = 0;
1370 }
1371
1372 if (udi_filter.num_sig_ids > UF_MAX_SIG_IDS) {
1373 printk(KERN_WARNING
1374 "UNIFI_SET_UDI_LOG_MASK: too many signal ids (%d, max %d)\n",
1375 udi_filter.num_sig_ids, UF_MAX_SIG_IDS);
1376 r = -EINVAL;
1377 goto out;
1378 }
1379
1380 /* Copy in signal id list if given */
1381 if (udi_filter.num_sig_ids > 0) {
1382 /* Preserve userspace address of sig_ids array */
1383 sig_ids_addr = udi_filter.sig_ids;
1384 /* Allocate kernel memory for sig_ids and copy to it */
1385 udi_filter.sig_ids =
1386 kmalloc(udi_filter.num_sig_ids * sizeof(uint16_t), GFP_KERNEL);
1387 if (!udi_filter.sig_ids) {
1388 r = -ENOMEM;
1389 goto out;
1390 }
1391 if (copy_from_user((void*)udi_filter.sig_ids,
1392 (void*)sig_ids_addr,
1393 udi_filter.num_sig_ids * sizeof(uint16_t)))
1394 {
1395 kfree(udi_filter.sig_ids);
1396 r = -EFAULT;
1397 goto out;
1398 }
1399 }
1400
1401 udi_set_log_filter(pcli, &udi_filter);
1402
1403 if (udi_filter.num_sig_ids > 0) {
1404 kfree(udi_filter.sig_ids);
1405 }
1406 }
1407 break;
1408
1409 case UNIFI_SET_AMP_ENABLE:
1410 unifi_trace(priv, UDBG4, "UniFi Set AMP Enable\n");
1411 if (get_user(int_param, (int*)arg))
1412 {
1413 unifi_error(priv, "UNIFI_SET_AMP_ENABLE: Failed to copy from user\n");
1414 r = -EFAULT;
1415 goto out;
1416 }
1417
1418 if (int_param) {
1419 priv->amp_client = pcli;
1420 } else {
1421 priv->amp_client = NULL;
1422 }
1423
1424 int_param = 0;
1425 buf = (u8*)&int_param;
1426 buf[0] = UNIFI_SOFT_COMMAND_Q_LENGTH - 1;
1427 buf[1] = UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1;
1428 if (copy_to_user((void*)arg, &int_param, sizeof(int))) {
1429 r = -EFAULT;
1430 goto out;
1431 }
1432 break;
1433
1434 case UNIFI_SET_UDI_SNAP_MASK:
1435 {
1436 unifiio_snap_filter_t snap_filter;
1437
1438 if (copy_from_user((void*)(&snap_filter), (void*)arg, sizeof(snap_filter))) {
1439 r = -EFAULT;
1440 goto out;
1441 }
1442
1443 if (pcli->snap_filter.count) {
1444 pcli->snap_filter.count = 0;
1445 kfree(pcli->snap_filter.protocols);
1446 }
1447
1448 if (snap_filter.count == 0) {
1449 break;
1450 }
1451
1452 pcli->snap_filter.protocols = kmalloc(snap_filter.count * sizeof(u16), GFP_KERNEL);
1453 if (!pcli->snap_filter.protocols) {
1454 r = -ENOMEM;
1455 goto out;
1456 }
1457 if (copy_from_user((void*)pcli->snap_filter.protocols,
1458 (void*)snap_filter.protocols,
1459 snap_filter.count * sizeof(u16)))
1460 {
1461 kfree(pcli->snap_filter.protocols);
1462 r = -EFAULT;
1463 goto out;
1464 }
1465
1466 pcli->snap_filter.count = snap_filter.count;
1467
1468 }
1469 break;
1470
1471 case UNIFI_SME_PRESENT:
1472 {
1473 u8 ind;
1474 unifi_trace(priv, UDBG4, "UniFi SME Present IOCTL.\n");
1475 if (copy_from_user((void*)(&int_param), (void*)arg, sizeof(int)))
1476 {
1477 printk(KERN_ERR "UNIFI_SME_PRESENT: Failed to copy from user\n");
1478 r = -EFAULT;
1479 goto out;
1480 }
1481
1482 priv->sme_is_present = int_param;
1483 if (priv->sme_is_present == 1) {
1484 ind = CONFIG_SME_PRESENT;
1485 } else {
1486 ind = CONFIG_SME_NOT_PRESENT;
1487 }
1488 /* Send an indication to the helper app. */
1489 ul_log_config_ind(priv, &ind, sizeof(u8));
1490 }
1491 break;
1492
1493 case UNIFI_CFG_PERIOD_TRAFFIC:
1494 {
1495#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
1496 CsrWifiSmeCoexConfig coexConfig;
1497#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
1498 unifi_trace(priv, UDBG4, "UniFi Configure Periodic Traffic.\n");
1499#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
1500 if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) {
1501 unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n");
1502 r = -EFAULT;
1503 goto out;
1504 }
1505
1506 if (uchar_param == 0) {
1507 r = sme_mgt_coex_config_get(priv, &coexConfig);
1508 if (r) {
1509 unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Get unifi_CoexInfoValue failed.\n");
1510 goto out;
1511 }
1512 if (copy_to_user((void*)(arg + 1),
1513 (void*)&coexConfig,
1514 sizeof(CsrWifiSmeCoexConfig))) {
1515 r = -EFAULT;
1516 goto out;
1517 }
1518 goto out;
1519 }
1520
1521 if (copy_from_user((void*)(&coex_config), (void*)(arg + 1), sizeof(CsrWifiSmeCoexConfig)))
1522 {
1523 unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n");
1524 r = -EFAULT;
1525 goto out;
1526 }
1527
1528 coexConfig = coex_config;
1529 r = sme_mgt_coex_config_set(priv, &coexConfig);
1530 if (r) {
1531 unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Set unifi_CoexInfoValue failed.\n");
1532 goto out;
1533 }
1534
1535#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
1536 break;
1537 }
1538 case UNIFI_CFG_UAPSD_TRAFFIC:
1539 unifi_trace(priv, UDBG4, "UniFi Configure U-APSD Mask.\n");
1540#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
1541 if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) {
1542 unifi_error(priv, "UNIFI_CFG_UAPSD_TRAFFIC: Failed to copy from user\n");
1543 r = -EFAULT;
1544 goto out;
1545 }
1546 unifi_trace(priv, UDBG4, "New U-APSD Mask: 0x%x\n", uchar_param);
1547#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
1548 break;
1549
1550#ifndef UNIFI_DISABLE_COREDUMP
1551 case UNIFI_COREDUMP_GET_REG:
1552 unifi_trace(priv, UDBG4, "Mini-coredump data request\n");
1553 {
1554 unifiio_coredump_req_t dump_req; /* Public OS layer structure */
1555 unifi_coredump_req_t priv_req; /* Private HIP structure */
1556
1557 if (copy_from_user((void*)(&dump_req), (void*)arg, sizeof(dump_req))) {
1558 r = -EFAULT;
1559 goto out;
1560 }
1561 memset(&priv_req, 0, sizeof(priv_req));
1562 priv_req.index = dump_req.index;
1563 priv_req.offset = dump_req.offset;
1564
1565 /* Convert OS-layer's XAP memory space ID to HIP's ID in case they differ */
1566 switch (dump_req.space) {
1567 case UNIFIIO_COREDUMP_MAC_REG: priv_req.space = UNIFI_COREDUMP_MAC_REG; break;
1568 case UNIFIIO_COREDUMP_PHY_REG: priv_req.space = UNIFI_COREDUMP_PHY_REG; break;
1569 case UNIFIIO_COREDUMP_SH_DMEM: priv_req.space = UNIFI_COREDUMP_SH_DMEM; break;
1570 case UNIFIIO_COREDUMP_MAC_DMEM: priv_req.space = UNIFI_COREDUMP_MAC_DMEM; break;
1571 case UNIFIIO_COREDUMP_PHY_DMEM: priv_req.space = UNIFI_COREDUMP_PHY_DMEM; break;
1572 case UNIFIIO_COREDUMP_TRIGGER_MAGIC: priv_req.space = UNIFI_COREDUMP_TRIGGER_MAGIC; break;
1573 default:
1574 r = -EINVAL;
1575 goto out;
1576 }
1577
1578 if (priv_req.space == UNIFI_COREDUMP_TRIGGER_MAGIC) {
1579 /* Force a coredump grab now */
1580 unifi_trace(priv, UDBG2, "UNIFI_COREDUMP_GET_REG: Force capture\n");
1581 csrResult = unifi_coredump_capture(priv->card, &priv_req);
1582 r = CsrHipResultToStatus(csrResult);
1583 unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: status %d\n", r);
1584 } else {
1585 /* Retrieve the appropriate register entry */
1586 csrResult = unifi_coredump_get_value(priv->card, &priv_req);
1587 r = CsrHipResultToStatus(csrResult);
1588 if (r) {
1589 unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: Status %d\n", r);
1590 goto out;
1591 }
1592 /* Update the OS-layer structure with values returned in the private */
1593 dump_req.value = priv_req.value;
1594 dump_req.timestamp = priv_req.timestamp;
1595 dump_req.requestor = priv_req.requestor;
1596 dump_req.serial = priv_req.serial;
1597 dump_req.chip_ver = priv_req.chip_ver;
1598 dump_req.fw_ver = priv_req.fw_ver;
1599 dump_req.drv_build = 0;
1600
1601 unifi_trace(priv, UDBG6,
1602 "Dump: %d (seq %d): V:0x%04x (%d) @0x%02x:%04x = 0x%04x\n",
1603 dump_req.index, dump_req.serial,
1604 dump_req.chip_ver, dump_req.drv_build,
1605 dump_req.space, dump_req.offset, dump_req.value);
1606 }
1607 if (copy_to_user((void*)arg, (void*)&dump_req, sizeof(dump_req))) {
1608 r = -EFAULT;
1609 goto out;
1610 }
1611 }
1612 break;
1613#endif
1614 default:
1615 r = -EINVAL;
1616 }
1617
1618out:
1619 return (long)r;
1620} /* unifi_ioctl() */
1621
1622
1623
1624static unsigned int
1625unifi_poll(struct file *filp, poll_table *wait)
1626{
1627 ul_client_t *pcli = (ul_client_t*)filp->private_data;
1628 unsigned int mask = 0;
1629 int ready;
1630
1631 ready = !list_empty(&pcli->udi_log);
1632
1633 poll_wait(filp, &pcli->udi_wq, wait);
1634
1635 if (ready) {
1636 mask |= POLLIN | POLLRDNORM; /* readable */
1637 }
1638
1639 return mask;
1640} /* unifi_poll() */
1641
1642
1643
1644/*
1645 * ---------------------------------------------------------------------------
1646 * udi_set_log_filter
1647 *
1648 * Configure the bit mask that determines which signal primitives are
1649 * passed to the logging process.
1650 *
1651 * Arguments:
1652 * pcli Pointer to the client to configure.
1653 * udi_filter Pointer to a unifiio_filter_t containing instructions.
1654 *
1655 * Returns:
1656 * None.
1657 *
1658 * Notes:
1659 * SigGetFilterPos() returns a 32-bit value that contains an index and a
1660 * mask for accessing a signal_filter array. The top 16 bits specify an
1661 * index into a signal_filter, the bottom 16 bits specify a mask to
1662 * apply.
1663 * ---------------------------------------------------------------------------
1664 */
1665static void
1666udi_set_log_filter(ul_client_t *pcli, unifiio_filter_t *udi_filter)
1667{
1668 u32 filter_pos;
1669 int i;
1670
1671 if (udi_filter->action == UfSigFil_AllOn)
1672 {
1673 for (i = 0; i < SIG_FILTER_SIZE; i++) {
1674 pcli->signal_filter[i] = 0xFFFF;
1675 }
1676 }
1677 else if (udi_filter->action == UfSigFil_AllOff)
1678 {
1679 for (i = 0; i < SIG_FILTER_SIZE; i++) {
1680 pcli->signal_filter[i] = 0;
1681 }
1682 }
1683 else if (udi_filter->action == UfSigFil_SelectOn)
1684 {
1685 for (i = 0; i < udi_filter->num_sig_ids; i++) {
1686 filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]);
1687 if (filter_pos == 0xFFFFFFFF)
1688 {
1689 printk(KERN_WARNING
1690 "Unrecognised signal id (0x%X) specifed in logging filter\n",
1691 udi_filter->sig_ids[i]);
1692 } else {
1693 pcli->signal_filter[filter_pos >> 16] |= (filter_pos & 0xFFFF);
1694 }
1695 }
1696 }
1697 else if (udi_filter->action == UfSigFil_SelectOff)
1698 {
1699 for (i = 0; i < udi_filter->num_sig_ids; i++) {
1700 filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]);
1701 if (filter_pos == 0xFFFFFFFF)
1702 {
1703 printk(KERN_WARNING
1704 "Unrecognised signal id (0x%X) specifed in logging filter\n",
1705 udi_filter->sig_ids[i]);
1706 } else {
1707 pcli->signal_filter[filter_pos >> 16] &= ~(filter_pos & 0xFFFF);
1708 }
1709 }
1710 }
1711
1712} /* udi_set_log_filter() */
1713
1714
1715/*
1716 * ---------------------------------------------------------------------------
1717 * udi_log_event
1718 *
1719 * Callback function to be registered as the UDI hook callback.
1720 * Copies the signal content into a new udi_log_t struct and adds
1721 * it to the read queue for this UDI client.
1722 *
1723 * Arguments:
1724 * pcli A pointer to the client instance.
1725 * signal Pointer to the received signal.
1726 * signal_len Size of the signal structure in bytes.
1727 * bulkdata Pointers to any associated bulk data.
1728 * dir Direction of the signal. Zero means from host,
1729 * non-zero means to host.
1730 *
1731 * Returns:
1732 * None.
1733 * ---------------------------------------------------------------------------
1734 */
1735void
1736udi_log_event(ul_client_t *pcli,
1737 const u8 *signal, int signal_len,
1738 const bulk_data_param_t *bulkdata,
1739 int dir)
1740{
1741 udi_log_t *logptr;
1742 u8 *p;
1743 int i;
1744 int total_len;
1745 udi_msg_t *msgptr;
1746 u32 filter_pos;
1747#ifdef OMNICLI_LINUX_EXTRA_LOG
1748 static volatile unsigned int printk_cpu = UINT_MAX;
1749 unsigned long long t;
1750 unsigned long nanosec_rem;
1751 unsigned long n_1000;
1752#endif
1753
1754 /* Just a sanity check */
1755 if ((signal == NULL) || (signal_len <= 0)) {
1756 return;
1757 }
1758
1759#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1760 /* When HIP offline signal logging is enabled, omnicli cannot run */
1761 if (log_hip_signals)
1762 {
1763 /* Add timestamp */
1764 if (log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP)
1765 {
1766 int timestamp = jiffies_to_msecs(jiffies);
1767 unifi_debug_log_to_buf("T:");
1768 unifi_debug_log_to_buf("%04X%04X ", *(((u16*)&timestamp) + 1),
1769 *(u16*)&timestamp);
1770 }
1771
1772 /* Add signal */
1773 unifi_debug_log_to_buf("S%s:%04X R:%04X D:%04X ",
1774 dir ? "T" : "F",
1775 *(u16*)signal,
1776 *(u16*)(signal + 2),
1777 *(u16*)(signal + 4));
1778 unifi_debug_hex_to_buf(signal + 6, signal_len - 6);
1779
1780 /* Add bulk data (assume 1 bulk data per signal) */
1781 if ((log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA) &&
1782 (bulkdata->d[0].data_length > 0))
1783 {
1784 unifi_debug_log_to_buf("\nD:");
1785 unifi_debug_hex_to_buf(bulkdata->d[0].os_data_ptr, bulkdata->d[0].data_length);
1786 }
1787 unifi_debug_log_to_buf("\n");
1788
1789 return;
1790 }
1791#endif
1792
1793#ifdef CSR_NATIVE_LINUX
1794 uf_native_process_udi_signal(pcli, signal, signal_len, bulkdata, dir);
1795#endif
1796
1797 /*
1798 * Apply the logging filter - only report signals that have their
1799 * bit set in the filter mask.
1800 */
1801 filter_pos = SigGetFilterPos(GET_SIGNAL_ID(signal));
1802
1803 if ((filter_pos != 0xFFFFFFFF) &&
1804 ((pcli->signal_filter[filter_pos >> 16] & (filter_pos & 0xFFFF)) == 0))
1805 {
1806 /* Signal is not wanted by client */
1807 return;
1808 }
1809
1810
1811 /* Calculate the buffer we need to store signal plus bulk data */
1812 total_len = signal_len;
1813 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
1814 total_len += bulkdata->d[i].data_length;
1815 }
1816
1817 /* Allocate log structure plus actual signal. */
1818 logptr = kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL);
1819
1820 if (logptr == NULL) {
1821 printk(KERN_ERR
1822 "Failed to allocate %lu bytes for a UDI log record\n",
1823 (long unsigned int)(sizeof(udi_log_t) + total_len));
1824 return;
1825 }
1826
1827 /* Fill in udi_log struct */
1828 INIT_LIST_HEAD(&logptr->q);
1829 msgptr = &logptr->msg;
1830 msgptr->length = sizeof(udi_msg_t) + total_len;
1831#ifdef OMNICLI_LINUX_EXTRA_LOG
1832 t = cpu_clock(printk_cpu);
1833 nanosec_rem = do_div(t, 1000000000);
1834 n_1000 = nanosec_rem/1000;
1835 msgptr->timestamp = (t <<10 ) | ((unsigned long)(n_1000 >> 10) & 0x3ff);
1836#else
1837 msgptr->timestamp = jiffies_to_msecs(jiffies);
1838#endif
1839 msgptr->direction = dir;
1840 msgptr->signal_length = signal_len;
1841
1842 /* Copy signal and bulk data to the log */
1843 p = (u8 *)(msgptr + 1);
1844 memcpy(p, signal, signal_len);
1845 p += signal_len;
1846
1847 /* Append any bulk data */
1848 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
1849 int len = bulkdata->d[i].data_length;
1850
1851 /*
1852 * Len here might not be the same as the length in the bulk data slot.
1853 * The slot length will always be even, but len could be odd.
1854 */
1855 if (len > 0) {
1856 if (bulkdata->d[i].os_data_ptr) {
1857 memcpy(p, bulkdata->d[i].os_data_ptr, len);
1858 } else {
1859 memset(p, 0, len);
1860 }
1861 p += len;
1862 }
1863 }
1864
1865 /* Add to tail of log queue */
1866 if (down_interruptible(&pcli->udi_sem)) {
1867 printk(KERN_WARNING "udi_log_event_q: Failed to get udi sem\n");
1868 kfree(logptr);
1869 return;
1870 }
1871 list_add_tail(&logptr->q, &pcli->udi_log);
1872 up(&pcli->udi_sem);
1873
1874 /* Wake any waiting user process */
1875 wake_up_interruptible(&pcli->udi_wq);
1876
1877} /* udi_log_event() */
1878
1879#ifdef CSR_SME_USERSPACE
1880int
1881uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length)
1882{
1883 udi_log_t *logptr;
1884 udi_msg_t *msgptr;
1885 u8 *p;
1886
1887 /* Just a sanity check */
1888 if ((buffer == NULL) || (length <= 0)) {
1889 return -EINVAL;
1890 }
1891
1892 /* Allocate log structure plus actual signal. */
1893 logptr = kmalloc(sizeof(udi_log_t) + length, GFP_ATOMIC);
1894 if (logptr == NULL) {
1895 unifi_error(priv, "Failed to allocate %d bytes for an SME message\n",
1896 sizeof(udi_log_t) + length);
1897 kfree(buffer);
1898 return -ENOMEM;
1899 }
1900
1901 /* Fill in udi_log struct */
1902 INIT_LIST_HEAD(&logptr->q);
1903 msgptr = &logptr->msg;
1904 msgptr->length = sizeof(udi_msg_t) + length;
1905 msgptr->signal_length = length;
1906
1907 /* Copy signal and bulk data to the log */
1908 p = (u8 *)(msgptr + 1);
1909 memcpy(p, buffer, length);
1910
1911 /* Add to tail of log queue */
1912 down(&udi_mutex);
1913 if (priv->sme_cli == NULL) {
1914 kfree(logptr);
1915 kfree(buffer);
1916 up(&udi_mutex);
1917 unifi_info(priv, "Message for the SME dropped, SME has gone away\n");
1918 return 0;
1919 }
1920
1921 down(&priv->sme_cli->udi_sem);
1922 list_add_tail(&logptr->q, &priv->sme_cli->udi_log);
1923 up(&priv->sme_cli->udi_sem);
1924
1925 /* Wake any waiting user process */
1926 wake_up_interruptible(&priv->sme_cli->udi_wq);
1927 up(&udi_mutex);
1928
1929 /* It is our responsibility to free the buffer allocated in build_packed_*() */
1930 kfree(buffer);
1931
1932 return 0;
1933
1934} /* uf_sme_queue_message() */
1935#endif
1936
1937/*
1938 ****************************************************************************
1939 *
1940 * Driver instantiation
1941 *
1942 ****************************************************************************
1943 */
1944static const struct file_operations unifi_fops = {
1945 .owner = THIS_MODULE,
1946 .open = unifi_open,
1947 .release = unifi_release,
1948 .read = unifi_read,
1949 .write = unifi_write,
1950 .unlocked_ioctl = unifi_ioctl,
1951 .poll = unifi_poll,
1952};
1953
1954static dev_t unifi_first_devno;
1955static struct class *unifi_class;
1956
1957
1958int uf_create_device_nodes(unifi_priv_t *priv, int bus_id)
1959{
1960 dev_t devno;
1961 int r;
1962
1963 cdev_init(&priv->unifi_cdev, &unifi_fops);
1964
1965 /* cdev_init() should set the cdev owner, but it does not */
1966 priv->unifi_cdev.owner = THIS_MODULE;
1967
1968 devno = MKDEV(MAJOR(unifi_first_devno),
1969 MINOR(unifi_first_devno) + (bus_id * 2));
1970 r = cdev_add(&priv->unifi_cdev, devno, 1);
1971 if (r) {
1972 return r;
1973 }
1974
1975#ifdef SDIO_EXPORTS_STRUCT_DEVICE
1976 if (!device_create(unifi_class, priv->unifi_device,
1977 devno, priv, "unifi%d", bus_id)) {
1978#else
1979 priv->unifi_device = device_create(unifi_class, NULL,
1980 devno, priv, "unifi%d", bus_id);
1981 if (priv->unifi_device == NULL) {
1982#endif /* SDIO_EXPORTS_STRUCT_DEVICE */
1983
1984 cdev_del(&priv->unifi_cdev);
1985 return -EINVAL;
1986 }
1987
1988 cdev_init(&priv->unifiudi_cdev, &unifi_fops);
1989
1990 /* cdev_init() should set the cdev owner, but it does not */
1991 priv->unifiudi_cdev.owner = THIS_MODULE;
1992
1993 devno = MKDEV(MAJOR(unifi_first_devno),
1994 MINOR(unifi_first_devno) + (bus_id * 2) + 1);
1995 r = cdev_add(&priv->unifiudi_cdev, devno, 1);
1996 if (r) {
1997 device_destroy(unifi_class, priv->unifi_cdev.dev);
1998 cdev_del(&priv->unifi_cdev);
1999 return r;
2000 }
2001
2002 if (!device_create(unifi_class,
2003#ifdef SDIO_EXPORTS_STRUCT_DEVICE
2004 priv->unifi_device,
2005#else
2006 NULL,
2007#endif /* SDIO_EXPORTS_STRUCT_DEVICE */
2008 devno, priv, "unifiudi%d", bus_id)) {
2009 device_destroy(unifi_class, priv->unifi_cdev.dev);
2010 cdev_del(&priv->unifiudi_cdev);
2011 cdev_del(&priv->unifi_cdev);
2012 return -EINVAL;
2013 }
2014
2015 return 0;
2016}
2017
2018
2019void uf_destroy_device_nodes(unifi_priv_t *priv)
2020{
2021 device_destroy(unifi_class, priv->unifiudi_cdev.dev);
2022 device_destroy(unifi_class, priv->unifi_cdev.dev);
2023 cdev_del(&priv->unifiudi_cdev);
2024 cdev_del(&priv->unifi_cdev);
2025}
2026
2027
2028
2029/*
2030 * ----------------------------------------------------------------
2031 * uf_create_debug_device
2032 *
2033 * Allocates device numbers for unifi character device nodes
2034 * and creates a unifi class in sysfs
2035 *
2036 * Arguments:
2037 * fops Pointer to the char device operations structure.
2038 *
2039 * Returns:
2040 * 0 on success, -ve error code on error.
2041 * ----------------------------------------------------------------
2042 */
2043static int
2044uf_create_debug_device(const struct file_operations *fops)
2045{
2046 int ret;
2047
2048 /* Allocate two device numbers for each device. */
2049 ret = alloc_chrdev_region(&unifi_first_devno, 0, MAX_UNIFI_DEVS*2, UNIFI_NAME);
2050 if (ret) {
2051 unifi_error(NULL, "Failed to add alloc dev numbers: %d\n", ret);
2052 return ret;
2053 }
2054
2055 /* Create a UniFi class */
2056 unifi_class = class_create(THIS_MODULE, UNIFI_NAME);
2057 if (IS_ERR(unifi_class)) {
2058 unifi_error(NULL, "Failed to create UniFi class\n");
2059
2060 /* Release device numbers */
2061 unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2);
2062 unifi_first_devno = 0;
2063 return -EINVAL;
2064 }
2065
2066 return 0;
2067} /* uf_create_debug_device() */
2068
2069
2070/*
2071 * ----------------------------------------------------------------
2072 * uf_remove_debug_device
2073 *
2074 * Destroys the unifi class and releases the allocated
2075 * device numbers for unifi character device nodes.
2076 *
2077 * Arguments:
2078 *
2079 * Returns:
2080 * ----------------------------------------------------------------
2081 */
2082static void
2083uf_remove_debug_device(void)
2084{
2085 /* Destroy the UniFi class */
2086 class_destroy(unifi_class);
2087
2088 /* Release device numbers */
2089 unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2);
2090 unifi_first_devno = 0;
2091
2092} /* uf_remove_debug_device() */
2093
2094
2095/*
2096 * ---------------------------------------------------------------------------
2097 *
2098 * Module loading.
2099 *
2100 * ---------------------------------------------------------------------------
2101 */
2102int __init
2103unifi_load(void)
2104{
2105 int r;
2106
2107 printk("UniFi SDIO Driver: %s %s %s\n",
2108 CSR_WIFI_VERSION,
2109 __DATE__, __TIME__);
2110
2111#ifdef CSR_SME_USERSPACE
2112#ifdef CSR_SUPPORT_WEXT
2113 printk("CSR SME with WEXT support\n");
2114#else
2115 printk("CSR SME no WEXT support\n");
2116#endif /* CSR_SUPPORT_WEXT */
2117#endif /* CSR_SME_USERSPACE */
2118
2119#ifdef CSR_NATIVE_LINUX
2120#ifdef CSR_SUPPORT_WEXT
2121#error WEXT unsupported in the native driver
2122#endif
2123 printk("CSR native no WEXT support\n");
2124#endif
2125#ifdef CSR_WIFI_SPLIT_PATCH
2126 printk("Split patch support\n");
2127#endif
2128 printk("Kernel %d.%d.%d\n",
2129 ((LINUX_VERSION_CODE) >> 16) & 0xff,
2130 ((LINUX_VERSION_CODE) >> 8) & 0xff,
2131 (LINUX_VERSION_CODE) & 0xff);
2132 /*
2133 * Instantiate the /dev/unifi* device nodes.
2134 * We must do this before registering with the SDIO driver because it
2135 * will immediately call the "insert" callback if the card is
2136 * already present.
2137 */
2138 r = uf_create_debug_device(&unifi_fops);
2139 if (r) {
2140 return r;
2141 }
2142
2143 /* Now register with the SDIO driver */
2144 r = uf_sdio_load();
2145 if (r) {
2146 uf_remove_debug_device();
2147 return r;
2148 }
2149
2150 if (sdio_block_size > -1) {
2151 unifi_info(NULL, "sdio_block_size %d\n", sdio_block_size);
2152 }
2153
2154 if (sdio_byte_mode) {
2155 unifi_info(NULL, "sdio_byte_mode\n");
2156 }
2157
2158 if (disable_power_control) {
2159 unifi_info(NULL, "disable_power_control\n");
2160 }
2161
2162 if (disable_hw_reset) {
2163 unifi_info(NULL, "disable_hw_reset\n");
2164 }
2165
2166 if (enable_wol) {
2167 unifi_info(NULL, "enable_wol %d\n", enable_wol);
2168 }
2169
2170 if (run_bh_once != -1) {
2171 unifi_info(NULL, "run_bh_once %d\n", run_bh_once);
2172 }
2173
2174 return 0;
2175} /* unifi_load() */
2176
2177
2178void __exit
2179unifi_unload(void)
2180{
2181 /* The SDIO remove hook will call unifi_disconnect(). */
2182 uf_sdio_unload();
2183
2184 uf_remove_debug_device();
2185
2186} /* unifi_unload() */
2187
2188module_init(unifi_load);
2189module_exit(unifi_unload);
2190
2191MODULE_DESCRIPTION("UniFi Device driver");
2192MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
2193MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/staging/csr/firmware.c b/drivers/staging/csr/firmware.c
deleted file mode 100644
index b42a4d6a0c36..000000000000
--- a/drivers/staging/csr/firmware.c
+++ /dev/null
@@ -1,396 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: firmware.c
4 *
5 * PURPOSE:
6 * Implements the f/w related HIP core lib API.
7 * It is part of the porting exercise in Linux.
8 *
9 * Also, it contains example code for reading the loader and f/w files
10 * from the userspace and starting the SME in Linux.
11 *
12 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
13 *
14 * Refer to LICENSE.txt included with this source code for details on
15 * the license terms.
16 *
17 * ---------------------------------------------------------------------------
18 */
19#include <linux/kmod.h>
20#include <linux/vmalloc.h>
21#include <linux/firmware.h>
22#include <asm/uaccess.h>
23#include "csr_wifi_hip_unifi.h"
24#include "csr_wifi_hip_unifi_udi.h"
25#include "unifiio.h"
26#include "unifi_priv.h"
27
28/*
29 * ---------------------------------------------------------------------------
30 *
31 * F/W download. Part of the HIP core API
32 *
33 * ---------------------------------------------------------------------------
34 */
35
36
37/*
38 * ---------------------------------------------------------------------------
39 * unifi_fw_read_start
40 *
41 * Returns a structure to be passed in unifi_fw_read().
42 * This structure is an OS specific description of the f/w file.
43 * In the linux implementation it is a buffer with the f/w and its' length.
44 * The HIP driver calls this functions to request for the loader or
45 * the firmware file.
46 * The structure pointer can be freed when unifi_fw_read_stop() is called.
47 *
48 * Arguments:
49 * ospriv Pointer to driver context.
50 * is_fw Type of firmware to retrieve
51 * info Versions information. Can be used to determine
52 * the appropriate f/w file to load.
53 *
54 * Returns:
55 * O on success, non-zero otherwise.
56 *
57 * ---------------------------------------------------------------------------
58 */
59void*
60unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info)
61{
62 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
63 CSR_UNUSED(info);
64
65 if (is_fw == UNIFI_FW_STA) {
66 /* F/w may have been released after a previous successful download. */
67 if (priv->fw_sta.dl_data == NULL) {
68 unifi_trace(priv, UDBG2, "Attempt reload of sta f/w\n");
69 uf_request_firmware_files(priv, UNIFI_FW_STA);
70 }
71 /* Set up callback struct for readfunc() */
72 if (priv->fw_sta.dl_data != NULL) {
73 return &priv->fw_sta;
74 }
75
76 } else {
77 unifi_error(priv, "downloading firmware... unknown request: %d\n", is_fw);
78 }
79
80 return NULL;
81} /* unifi_fw_read_start() */
82
83
84
85/*
86 * ---------------------------------------------------------------------------
87 * unifi_fw_read_stop
88 *
89 * Called when the HIP driver has finished using the loader or
90 * the firmware file.
91 * The firmware buffer may be released now.
92 *
93 * Arguments:
94 * ospriv Pointer to driver context.
95 * dlpriv The pointer returned by unifi_fw_read_start()
96 *
97 * ---------------------------------------------------------------------------
98 */
99void
100unifi_fw_read_stop(void *ospriv, void *dlpriv)
101{
102 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
103 struct dlpriv *dl_struct = (struct dlpriv *)dlpriv;
104
105 if (dl_struct != NULL) {
106 if (dl_struct->dl_data != NULL) {
107 unifi_trace(priv, UDBG2, "Release f/w buffer %p, %d bytes\n",
108 dl_struct->dl_data, dl_struct->dl_len);
109 }
110 uf_release_firmware(priv, dl_struct);
111 }
112
113} /* unifi_fw_read_stop() */
114
115
116/*
117 * ---------------------------------------------------------------------------
118 * unifi_fw_open_buffer
119 *
120 * Returns a handle for a buffer dynamically allocated by the driver,
121 * e.g. into which a firmware file may have been converted from another format
122 * which is the case with some production test images.
123 *
124 * The handle may then be used by unifi_fw_read() to access the contents of
125 * the buffer.
126 *
127 * Arguments:
128 * ospriv Pointer to driver context.
129 * fwbuf Buffer containing firmware image
130 * len Length of buffer in bytes
131 *
132 * Returns
133 * Handle for buffer, or NULL on error
134 * ---------------------------------------------------------------------------
135 */
136void *
137unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len)
138{
139 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
140
141 if (fwbuf == NULL) {
142 return NULL;
143 }
144 priv->fw_conv.dl_data = fwbuf;
145 priv->fw_conv.dl_len = len;
146 priv->fw_conv.fw_desc = NULL; /* No OS f/w resource is associated */
147
148 return &priv->fw_conv;
149}
150
151/*
152 * ---------------------------------------------------------------------------
153 * unifi_fw_close_buffer
154 *
155 * Releases any handle for a buffer dynamically allocated by the driver,
156 * e.g. into which a firmware file may have been converted from another format
157 * which is the case with some production test images.
158 *
159 *
160 * Arguments:
161 * ospriv Pointer to driver context.
162 * fwbuf Buffer containing firmware image
163 *
164 * Returns
165 * Handle for buffer, or NULL on error
166 * ---------------------------------------------------------------------------
167 */
168void unifi_fw_close_buffer(void *ospriv, void *fwbuf)
169{
170}
171
172/*
173 * ---------------------------------------------------------------------------
174 * unifi_fw_read
175 *
176 * The HIP driver calls this function to ask for a part of the loader or
177 * the firmware file.
178 *
179 * Arguments:
180 * ospriv Pointer to driver context.
181 * arg The pointer returned by unifi_fw_read_start().
182 * offset The offset in the file to return from.
183 * buf A buffer to store the requested data.
184 * len The size of the buf and the size of the requested data.
185 *
186 * Returns
187 * The number of bytes read from the firmware image, or -ve on error
188 * ---------------------------------------------------------------------------
189 */
190s32
191unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len)
192{
193 const struct dlpriv *dlpriv = arg;
194
195 if (offset >= dlpriv->dl_len) {
196 /* at end of file */
197 return 0;
198 }
199
200 if ((offset + len) > dlpriv->dl_len) {
201 /* attempt to read past end of file */
202 return -1;
203 }
204
205 memcpy(buf, dlpriv->dl_data+offset, len);
206
207 return len;
208
209} /* unifi_fw_read() */
210
211
212
213
214#define UNIFIHELPER_INIT_MODE_SMEUSER 2
215#define UNIFIHELPER_INIT_MODE_NATIVE 1
216
217/*
218 * ---------------------------------------------------------------------------
219 * uf_run_unifihelper
220 *
221 * Ask userspace to send us firmware for download by running
222 * '/usr/sbin/unififw'.
223 * The same script starts the SME userspace application.
224 * Derived from net_run_sbin_hotplug().
225 *
226 * Arguments:
227 * priv Pointer to OS private struct.
228 *
229 * Returns:
230 * None.
231 * ---------------------------------------------------------------------------
232 */
233int
234uf_run_unifihelper(unifi_priv_t *priv)
235{
236#ifdef ANDROID_BUILD
237 char *prog = "/system/bin/unififw";
238#else
239 char *prog = "/usr/sbin/unififw";
240#endif /* ANDROID_BUILD */
241
242 char *argv[6], *envp[4];
243 char inst_str[8];
244 char init_mode[8];
245 int i, r;
246
247#if (defined CSR_SME_USERSPACE) && (!defined CSR_SUPPORT_WEXT)
248 unifi_trace(priv, UDBG1, "SME userspace build: run unifi_helper manually\n");
249 return 0;
250#endif
251
252 unifi_trace(priv, UDBG1, "starting %s\n", prog);
253
254 snprintf(inst_str, 8, "%d", priv->instance);
255#if (defined CSR_SME_USERSPACE)
256 snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_SMEUSER);
257#else
258 snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_NATIVE);
259#endif /* CSR_SME_USERSPACE */
260
261 i = 0;
262 argv[i++] = prog;
263 argv[i++] = inst_str;
264 argv[i++] = init_mode;
265 argv[i++] = 0;
266 argv[i] = 0;
267 /* Don't add more args without making argv bigger */
268
269 /* minimal command environment */
270 i = 0;
271 envp[i++] = "HOME=/";
272 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
273 envp[i] = 0;
274 /* Don't add more without making envp bigger */
275
276 unifi_trace(priv, UDBG2, "running %s %s %s\n", argv[0], argv[1], argv[2]);
277
278 r = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
279
280 return r;
281} /* uf_run_unifihelper() */
282
283#ifdef CSR_WIFI_SPLIT_PATCH
284static u8 is_ap_mode(unifi_priv_t *priv)
285{
286 if (priv == NULL || priv->interfacePriv[0] == NULL)
287 {
288 return FALSE;
289 }
290
291 /* Test for mode requiring AP patch */
292 return(CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode));
293}
294#endif
295
296/*
297 * ---------------------------------------------------------------------------
298 * uf_request_firmware_files
299 *
300 * Get the firmware files from userspace.
301 *
302 * Arguments:
303 * priv Pointer to OS private struct.
304 * is_fw type of firmware to load (UNIFI_FW_STA/LOADER)
305 *
306 * Returns:
307 * None.
308 * ---------------------------------------------------------------------------
309 */
310int uf_request_firmware_files(unifi_priv_t *priv, int is_fw)
311{
312 /* uses the default method to get the firmware */
313 const struct firmware *fw_entry;
314 int postfix;
315#define UNIFI_MAX_FW_PATH_LEN 32
316 char fw_name[UNIFI_MAX_FW_PATH_LEN];
317 int r;
318
319#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
320 if (priv->mib_data.length) {
321 vfree(priv->mib_data.data);
322 priv->mib_data.data = NULL;
323 priv->mib_data.length = 0;
324 }
325#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/
326
327 postfix = priv->instance;
328
329 if (is_fw == UNIFI_FW_STA) {
330 /* Free kernel buffer and reload */
331 uf_release_firmware(priv, &priv->fw_sta);
332#ifdef CSR_WIFI_SPLIT_PATCH
333 scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
334 postfix, (is_ap_mode(priv) ? "ap.xbv" : "staonly.xbv") );
335#else
336 scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
337 postfix, "sta.xbv" );
338#endif
339 r = request_firmware(&fw_entry, fw_name, priv->unifi_device);
340 if (r == 0) {
341 priv->fw_sta.dl_data = fw_entry->data;
342 priv->fw_sta.dl_len = fw_entry->size;
343 priv->fw_sta.fw_desc = (void *)fw_entry;
344 } else {
345 unifi_trace(priv, UDBG2, "Firmware file not available\n");
346 }
347 }
348
349 return 0;
350
351} /* uf_request_firmware_files() */
352
353/*
354 * ---------------------------------------------------------------------------
355 * uf_release_firmware_files
356 *
357 * Release all buffers used to store firmware files
358 *
359 * Arguments:
360 * priv Pointer to OS private struct.
361 *
362 * Returns:
363 * None.
364 * ---------------------------------------------------------------------------
365 */
366int uf_release_firmware_files(unifi_priv_t *priv)
367{
368 uf_release_firmware(priv, &priv->fw_sta);
369
370 return 0;
371}
372
373/*
374 * ---------------------------------------------------------------------------
375 * uf_release_firmware
376 *
377 * Release specific buffer used to store firmware
378 *
379 * Arguments:
380 * priv Pointer to OS private struct.
381 * to_free Pointer to specific buffer to release
382 *
383 * Returns:
384 * None.
385 * ---------------------------------------------------------------------------
386 */
387int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free)
388{
389 if (to_free != NULL) {
390 release_firmware((const struct firmware *)to_free->fw_desc);
391 to_free->fw_desc = NULL;
392 to_free->dl_data = NULL;
393 to_free->dl_len = 0;
394 }
395 return 0;
396}
diff --git a/drivers/staging/csr/inet.c b/drivers/staging/csr/inet.c
deleted file mode 100644
index b3ef818fef35..000000000000
--- a/drivers/staging/csr/inet.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: inet.c
4 *
5 * PURPOSE:
6 * Routines related to IP address changes.
7 * Optional part of the porting exercise. It uses system network
8 * handlers to obtain the UniFi IP address and pass it to the SME
9 * using the unifi_sys_ip_configured_ind().
10 *
11 * Copyright (C) 2008-2009 Cambridge Silicon Radio Ltd.
12 *
13 * Refer to LICENSE.txt included with this source code for details on
14 * the license terms.
15 *
16 * ---------------------------------------------------------------------------
17 */
18#include <linux/inetdevice.h>
19#include <linux/notifier.h>
20
21#include "unifi_priv.h"
22#include "csr_wifi_hip_conversions.h"
23
24/*
25 * The inet notifier is global and not per-netdev. To avoid having a
26 * notifier registered when there are no unifi devices present, it's
27 * registered after the first unifi network device is registered, and
28 * unregistered when the last unifi network device is unregistered.
29 */
30
31static atomic_t inet_notif_refs = ATOMIC_INIT(0);
32
33static int uf_inetaddr_event(struct notifier_block *notif, unsigned long event, void *ifa)
34{
35 struct net_device *ndev;
36 unifi_priv_t *priv;
37 struct in_ifaddr *if_addr;
38 netInterface_priv_t *InterfacePriv = (netInterface_priv_t *)NULL;
39
40 if (!ifa || !((struct in_ifaddr *)ifa)->ifa_dev) {
41 unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ifa=%p\n", event, ifa);
42 return NOTIFY_DONE;
43 }
44
45 ndev = ((struct in_ifaddr *)ifa)->ifa_dev->dev;
46 InterfacePriv = (netInterface_priv_t*) netdev_priv(ndev);
47
48 /* As the notifier is global, the call may be for a non-UniFi netdev.
49 * Therefore check the netdev_priv to make sure it's a known UniFi one.
50 */
51 if (uf_find_netdev_priv(InterfacePriv) == -1) {
52 unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ndev=%p, other netdev_priv=%p\n",
53 event, ndev, InterfacePriv);
54 return NOTIFY_DONE;
55 }
56
57 if (!InterfacePriv->privPtr) {
58 unifi_error(NULL, "uf_inetaddr_event null priv (%lu) ndev=%p, InterfacePriv=%p\n",
59 event, ndev, InterfacePriv);
60 return NOTIFY_DONE;
61 }
62
63 priv = InterfacePriv->privPtr;
64 if_addr = (struct in_ifaddr *)ifa;
65
66 /* If this event is for a UniFi device, notify the SME that an IP
67 * address has been added or removed. */
68 if (uf_find_priv(priv) != -1) {
69 switch (event) {
70 case NETDEV_UP:
71 unifi_info(priv, "IP address assigned for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name);
72 priv->sta_ip_address = if_addr->ifa_address;
73#ifdef CSR_SUPPORT_WEXT
74 sme_mgt_packet_filter_set(priv);
75#endif
76 break;
77 case NETDEV_DOWN:
78 unifi_info(priv, "IP address removed for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name);
79 priv->sta_ip_address = 0xFFFFFFFF;
80#ifdef CSR_SUPPORT_WEXT
81 sme_mgt_packet_filter_set(priv);
82#endif
83 break;
84 }
85 }
86
87 return NOTIFY_DONE;
88}
89
90static struct notifier_block uf_inetaddr_notifier = {
91 .notifier_call = uf_inetaddr_event,
92};
93
94void uf_register_inet_notifier(void)
95{
96 if (atomic_inc_return(&inet_notif_refs) == 1)
97 register_inetaddr_notifier(&uf_inetaddr_notifier);
98}
99
100void uf_unregister_inet_notifier(void)
101{
102 if (atomic_dec_return(&inet_notif_refs) == 0)
103 unregister_inetaddr_notifier(&uf_inetaddr_notifier);
104}
diff --git a/drivers/staging/csr/init_hw.c b/drivers/staging/csr/init_hw.c
deleted file mode 100644
index 3b8a4babf9a6..000000000000
--- a/drivers/staging/csr/init_hw.c
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: init_hw.c
4 *
5 * PURPOSE:
6 * Use the HIP core lib to initialise the UniFi chip.
7 * It is part of the porting exercise in Linux.
8 *
9 * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16#include "csr_wifi_hip_unifi.h"
17#include "unifi_priv.h"
18
19
20#define MAX_INIT_ATTEMPTS 4
21
22extern int led_mask;
23
24
25/*
26 * ---------------------------------------------------------------------------
27 * uf_init_hw
28 *
29 * Resets hardware, downloads and initialises f/w.
30 * This function demonstrates how to use the HIP core lib API
31 * to implement the SME unifi_sys_wifi_on_req() part of the SYS API.
32 *
33 * In a simple implementation, all this function needs to do is call
34 * unifi_init_card() and then unifi_card_info().
35 * In the Linux implementation, it will retry to initialise UniFi or
36 * try to debug the reasons if unifi_init_card() returns an error.
37 *
38 * Arguments:
39 * ospriv Pointer to OS driver structure for the device.
40 *
41 * Returns:
42 * O on success, non-zero otherwise.
43 *
44 * ---------------------------------------------------------------------------
45 */
46int
47uf_init_hw(unifi_priv_t *priv)
48{
49 int attempts = 0;
50 int priv_instance;
51 CsrResult csrResult = CSR_RESULT_FAILURE;
52
53 priv_instance = uf_find_priv(priv);
54 if (priv_instance == -1) {
55 unifi_warning(priv, "uf_init_hw: Unknown priv instance, will use fw_init[0]\n");
56 priv_instance = 0;
57 }
58
59 while (1) {
60 if (attempts > MAX_INIT_ATTEMPTS) {
61 unifi_error(priv, "Failed to initialise UniFi after %d attempts, "
62 "giving up.\n",
63 attempts);
64 break;
65 }
66 attempts++;
67
68 unifi_info(priv, "Initialising UniFi, attempt %d\n", attempts);
69
70 if (fw_init[priv_instance] > 0) {
71 unifi_notice(priv, "f/w init prevented by module parameter\n");
72 break;
73 } else if (fw_init[priv_instance] == 0) {
74 fw_init[priv_instance] ++;
75 }
76
77 /*
78 * Initialise driver core. This will perform a reset of UniFi
79 * internals, but not the SDIO CCCR.
80 */
81 CsrSdioClaim(priv->sdio);
82 csrResult = unifi_init_card(priv->card, led_mask);
83 CsrSdioRelease(priv->sdio);
84
85 if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
86 return CsrHipResultToStatus(csrResult);
87 }
88 if (csrResult == CSR_WIFI_HIP_RESULT_NOT_FOUND) {
89 unifi_error(priv, "Firmware file required, but not found.\n");
90 return CsrHipResultToStatus(csrResult);
91 }
92 if (csrResult != CSR_RESULT_SUCCESS) {
93 /* failed. Reset h/w and try again */
94 unifi_error(priv, "Failed to initialise UniFi chip.\n");
95 continue;
96 }
97
98 /* Get the version information from the lib_hip */
99 unifi_card_info(priv->card, &priv->card_info);
100
101 return CsrHipResultToStatus(csrResult);
102 }
103
104 return CsrHipResultToStatus(csrResult);
105
106} /* uf_init_hw */
107
108
diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c
deleted file mode 100644
index f903022b4079..000000000000
--- a/drivers/staging/csr/io.c
+++ /dev/null
@@ -1,1098 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: io.c
4 *
5 * PURPOSE:
6 * This file contains routines that the SDIO driver can call when a
7 * UniFi card is first inserted (or detected) and removed.
8 *
9 * When used with sdioemb, the udev scripts (at least on Ubuntu) don't
10 * recognise a UniFi being added to the system. This is because sdioemb
11 * does not register itself as a device_driver, it uses it's own code
12 * to handle insert and remove.
13 * To have Ubuntu recognise UniFi, edit /etc/udev/rules.d/85-ifupdown.rules
14 * to change this line:
15 * SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"
16 * to these:
17 * #SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"
18 * SUBSYSTEM=="net", GOTO="net_start"
19 *
20 * Then you can add a stanza to /etc/network/interfaces like this:
21 * auto eth1
22 * iface eth1 inet dhcp
23 * wpa-conf /etc/wpa_supplicant.conf
24 * This will then automatically associate when a car dis inserted.
25 *
26 * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd.
27 *
28 * Refer to LICENSE.txt included with this source code for details on
29 * the license terms.
30 *
31 * ---------------------------------------------------------------------------
32 */
33#include <linux/proc_fs.h>
34#include <linux/seq_file.h>
35
36#include "csr_wifi_hip_unifi.h"
37#include "csr_wifi_hip_unifiversion.h"
38#include "csr_wifi_hip_unifi_udi.h" /* for unifi_print_status() */
39#include "unifiio.h"
40#include "unifi_priv.h"
41
42/*
43 * Array of pointers to context structs for unifi devices that are present.
44 * The index in the array corresponds to the wlan interface number
45 * (if "wlan*" is used). If "eth*" is used, the eth* numbers are allocated
46 * after any Ethernet cards.
47 *
48 * The Arasan PCI-SDIO controller card supported by this driver has 2 slots,
49 * hence a max of 2 devices.
50 */
51static unifi_priv_t *Unifi_instances[MAX_UNIFI_DEVS];
52
53/* Array of pointers to netdev objects used by the UniFi driver, as there
54 * are now many per instance. This is used to determine which netdev events
55 * are for UniFi as opposed to other net interfaces.
56 */
57static netInterface_priv_t *Unifi_netdev_instances[MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES];
58
59/*
60 * Array to hold the status of each unifi device in each slot.
61 * We only process an insert event when In_use[] for the slot is
62 * UNIFI_DEV_NOT_IN_USE. Otherwise, it means that the slot is in use or
63 * we are in the middle of a cleanup (the action on unplug).
64 */
65#define UNIFI_DEV_NOT_IN_USE 0
66#define UNIFI_DEV_IN_USE 1
67#define UNIFI_DEV_CLEANUP 2
68static int In_use[MAX_UNIFI_DEVS];
69/*
70 * Mutex to prevent UDI clients to open the character device before the priv
71 * is created and initialised.
72 */
73DEFINE_SEMAPHORE(Unifi_instance_mutex);
74/*
75 * When the device is removed, unregister waits on Unifi_cleanup_wq
76 * until all the UDI clients release the character device.
77 */
78DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq);
79
80#ifdef CONFIG_PROC_FS
81/*
82 * seq_file wrappers for procfile show routines.
83 */
84static int uf_proc_show(struct seq_file *m, void *v);
85
86#define UNIFI_DEBUG_TXT_BUFFER (8 * 1024)
87
88static int uf_proc_open(struct inode *inode, struct file *file)
89{
90 return single_open_size(file, uf_proc_show, PDE_DATA(inode),
91 UNIFI_DEBUG_TXT_BUFFER);
92}
93
94static const struct file_operations uf_proc_fops = {
95 .open = uf_proc_open,
96 .read = seq_read,
97 .llseek = seq_lseek,
98 .release = single_release,
99};
100
101#endif /* CONFIG_PROC_FS */
102
103#ifdef CSR_WIFI_RX_PATH_SPLIT
104
105static CsrResult signal_buffer_init(unifi_priv_t * priv, int size)
106{
107 int i;
108
109 priv->rxSignalBuffer.writePointer =
110 priv->rxSignalBuffer.readPointer = 0;
111 priv->rxSignalBuffer.size = size;
112 /* Allocating Memory for Signal primitive pointer */
113 for(i=0; i<size; i++)
114 {
115 priv->rxSignalBuffer.rx_buff[i].sig_len=0;
116 priv->rxSignalBuffer.rx_buff[i].bufptr = kmalloc(UNIFI_PACKED_SIGBUF_SIZE, GFP_KERNEL);
117 if (priv->rxSignalBuffer.rx_buff[i].bufptr == NULL)
118 {
119 int j;
120 unifi_error(priv, "signal_buffer_init:Failed to Allocate shared memory for T-H signals \n");
121 for(j=0;j<i;j++)
122 {
123 priv->rxSignalBuffer.rx_buff[j].sig_len=0;
124 kfree(priv->rxSignalBuffer.rx_buff[j].bufptr);
125 priv->rxSignalBuffer.rx_buff[j].bufptr = NULL;
126 }
127 return -1;
128 }
129 }
130 return 0;
131}
132
133
134static void signal_buffer_free(unifi_priv_t * priv, int size)
135{
136 int i;
137
138 for(i=0; i<size; i++)
139 {
140 priv->rxSignalBuffer.rx_buff[i].sig_len=0;
141 kfree(priv->rxSignalBuffer.rx_buff[i].bufptr);
142 priv->rxSignalBuffer.rx_buff[i].bufptr = NULL;
143 }
144}
145#endif
146/*
147 * ---------------------------------------------------------------------------
148 * uf_register_netdev
149 *
150 * Registers the network interface, installes the qdisc,
151 * and registers the inet handler.
152 * In the porting exercise, register the driver to the network
153 * stack if necessary.
154 *
155 * Arguments:
156 * priv Pointer to driver context.
157 *
158 * Returns:
159 * O on success, non-zero otherwise.
160 *
161 * Notes:
162 * We will only unregister when the card is ejected, so we must
163 * only do it once.
164 * ---------------------------------------------------------------------------
165 */
166int
167uf_register_netdev(unifi_priv_t *priv, int interfaceTag)
168{
169 int r;
170 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
171
172 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
173 unifi_error(priv, "uf_register_netdev bad interfaceTag\n");
174 return -EINVAL;
175 }
176
177 /*
178 * Allocates a device number and registers device with the network
179 * stack.
180 */
181 unifi_trace(priv, UDBG5, "uf_register_netdev: netdev %d - 0x%p\n",
182 interfaceTag, priv->netdev[interfaceTag]);
183 r = register_netdev(priv->netdev[interfaceTag]);
184 if (r) {
185 unifi_error(priv, "Failed to register net device\n");
186 return -EINVAL;
187 }
188
189 /* The device is registed */
190 interfacePriv->netdev_registered = 1;
191
192#ifdef CSR_SUPPORT_SME
193 /*
194 * Register the inet handler; it notifies us for changes in the IP address.
195 */
196 uf_register_inet_notifier();
197#endif /* CSR_SUPPORT_SME */
198
199 unifi_notice(priv, "unifi%d is %s\n",
200 priv->instance, priv->netdev[interfaceTag]->name);
201
202 return 0;
203} /* uf_register_netdev */
204
205
206/*
207 * ---------------------------------------------------------------------------
208 * uf_unregister_netdev
209 *
210 * Unregisters the network interface and the inet handler.
211 *
212 * Arguments:
213 * priv Pointer to driver context.
214 *
215 * Returns:
216 * None.
217 *
218 * ---------------------------------------------------------------------------
219 */
220void
221uf_unregister_netdev(unifi_priv_t *priv)
222{
223 int i=0;
224
225#ifdef CSR_SUPPORT_SME
226 /* Unregister the inet handler... */
227 uf_unregister_inet_notifier();
228#endif /* CSR_SUPPORT_SME */
229
230 for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
231 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
232 if (interfacePriv->netdev_registered) {
233 unifi_trace(priv, UDBG5,
234 "uf_unregister_netdev: netdev %d - 0x%p\n",
235 i, priv->netdev[i]);
236
237 /* ... and the netdev */
238 unregister_netdev(priv->netdev[i]);
239 interfacePriv->netdev_registered = 0;
240 }
241
242 interfacePriv->interfaceMode = 0;
243
244 /* Enable all queues by default */
245 interfacePriv->queueEnabled[0] = 1;
246 interfacePriv->queueEnabled[1] = 1;
247 interfacePriv->queueEnabled[2] = 1;
248 interfacePriv->queueEnabled[3] = 1;
249 }
250
251 priv->totalInterfaceCount = 0;
252} /* uf_unregister_netdev() */
253
254
255/*
256 * ---------------------------------------------------------------------------
257 * register_unifi_sdio
258 *
259 * This function is called from the Probe (or equivalent) method of
260 * the SDIO driver when a UniFi card is detected.
261 * We allocate the Linux net_device struct, initialise the HIP core
262 * lib, create the char device nodes and start the userspace helper
263 * to initialise the device.
264 *
265 * Arguments:
266 * sdio_dev Pointer to SDIO context handle to use for all
267 * SDIO ops.
268 * bus_id A small number indicating the SDIO card position on the
269 * bus. Typically this is the slot number, e.g. 0, 1 etc.
270 * Valid values are 0 to MAX_UNIFI_DEVS-1.
271 * dev Pointer to kernel device manager struct.
272 *
273 * Returns:
274 * Pointer to the unifi instance, or NULL on error.
275 * ---------------------------------------------------------------------------
276 */
277static unifi_priv_t *
278register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev)
279{
280 unifi_priv_t *priv = NULL;
281 int r = -1;
282 CsrResult csrResult;
283
284 if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
285 unifi_error(priv, "register_unifi_sdio: invalid device %d\n",
286 bus_id);
287 return NULL;
288 }
289
290 down(&Unifi_instance_mutex);
291
292 if (In_use[bus_id] != UNIFI_DEV_NOT_IN_USE) {
293 unifi_error(priv, "register_unifi_sdio: device %d is already in use\n",
294 bus_id);
295 goto failed0;
296 }
297
298
299 /* Allocate device private and net_device structs */
300 priv = uf_alloc_netdevice(sdio_dev, bus_id);
301 if (priv == NULL) {
302 unifi_error(priv, "Failed to allocate driver private\n");
303 goto failed0;
304 }
305
306 priv->unifi_device = dev;
307
308 SET_NETDEV_DEV(priv->netdev[0], dev);
309
310 /* We are not ready to send data yet. */
311 netif_carrier_off(priv->netdev[0]);
312
313 /* Allocate driver context. */
314 priv->card = unifi_alloc_card(priv->sdio, priv);
315 if (priv->card == NULL) {
316 unifi_error(priv, "Failed to allocate UniFi driver card struct.\n");
317 goto failed1;
318 }
319
320 if (Unifi_instances[bus_id]) {
321 unifi_error(priv, "Internal error: instance for slot %d is already taken\n",
322 bus_id);
323 }
324 Unifi_instances[bus_id] = priv;
325 In_use[bus_id] = UNIFI_DEV_IN_USE;
326
327 /* Save the netdev_priv for use by the netdev event callback mechanism */
328 Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES] = netdev_priv(priv->netdev[0]);
329
330 /* Initialise the mini-coredump capture buffers */
331 csrResult = unifi_coredump_init(priv->card, (u16)coredump_max);
332 if (csrResult != CSR_RESULT_SUCCESS) {
333 unifi_error(priv, "Couldn't allocate mini-coredump buffers\n");
334 }
335
336 /* Create the character device nodes */
337 r = uf_create_device_nodes(priv, bus_id);
338 if (r) {
339 goto failed1;
340 }
341
342 /*
343 * We use the slot number as unifi device index.
344 */
345 scnprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance);
346 /*
347 * The following complex casting is in place in order to eliminate 64-bit compilation warning
348 * "cast to/from pointer from/to integer of different size"
349 */
350 if (!proc_create_data(priv->proc_entry_name, 0, NULL,
351 &uf_proc_fops, (void *)(long)priv->instance))
352 {
353 unifi_error(priv, "unifi: can't create /proc/driver/unifi\n");
354 }
355
356 /* Allocate the net_device for interfaces other than 0. */
357 {
358 int i;
359 priv->totalInterfaceCount =0;
360
361 for(i=1;i<CSR_WIFI_NUM_INTERFACES;i++)
362 {
363 if( !uf_alloc_netdevice_for_other_interfaces(priv, i) )
364 {
365 /* error occured while allocating the net_device for interface[i]. The net_device are
366 * allocated for the interfaces with id<i. Dont worry, all the allocated net_device will
367 * be releasing chen the control goes to the label failed0.
368 */
369 unifi_error(priv, "Failed to allocate driver private for interface[%d]\n", i);
370 goto failed0;
371 }
372 else
373 {
374 SET_NETDEV_DEV(priv->netdev[i], dev);
375
376 /* We are not ready to send data yet. */
377 netif_carrier_off(priv->netdev[i]);
378
379 /* Save the netdev_priv for use by the netdev event callback mechanism */
380 Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES + i] = netdev_priv(priv->netdev[i]);
381 }
382 }
383
384 for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
385 {
386 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
387 interfacePriv->netdev_registered=0;
388 }
389 }
390
391#ifdef CSR_WIFI_RX_PATH_SPLIT
392 if (signal_buffer_init(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE))
393 {
394 unifi_error(priv, "Failed to allocate shared memory for T-H signals\n");
395 goto failed2;
396 }
397 priv->rx_workqueue = create_singlethread_workqueue("rx_workq");
398 if (priv->rx_workqueue == NULL) {
399 unifi_error(priv, "create_singlethread_workqueue failed \n");
400 goto failed3;
401 }
402 INIT_WORK(&priv->rx_work_struct, rx_wq_handler);
403#endif
404
405#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
406 if (log_hip_signals)
407 {
408 uf_register_hip_offline_debug(priv);
409 }
410#endif
411
412 /* Initialise the SME related threads and parameters */
413 r = uf_sme_init(priv);
414 if (r) {
415 unifi_error(priv, "SME initialisation failed.\n");
416 goto failed4;
417 }
418
419 /*
420 * Run the userspace helper program (unififw) to perform
421 * the device initialisation.
422 */
423 unifi_trace(priv, UDBG1, "run UniFi helper app...\n");
424 r = uf_run_unifihelper(priv);
425 if (r) {
426 unifi_notice(priv, "unable to run UniFi helper app\n");
427 /* Not a fatal error. */
428 }
429
430 up(&Unifi_instance_mutex);
431
432 return priv;
433
434failed4:
435#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
436if (log_hip_signals)
437{
438 uf_unregister_hip_offline_debug(priv);
439}
440#endif
441#ifdef CSR_WIFI_RX_PATH_SPLIT
442 flush_workqueue(priv->rx_workqueue);
443 destroy_workqueue(priv->rx_workqueue);
444failed3:
445 signal_buffer_free(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
446failed2:
447#endif
448 /* Remove the device nodes */
449 uf_destroy_device_nodes(priv);
450failed1:
451 /* Deregister priv->netdev_client */
452 ul_deregister_client(priv->netdev_client);
453
454failed0:
455 if (priv && priv->card) {
456 unifi_coredump_free(priv->card);
457 unifi_free_card(priv->card);
458 }
459 if (priv) {
460 uf_free_netdevice(priv);
461 }
462
463 up(&Unifi_instance_mutex);
464
465 return NULL;
466} /* register_unifi_sdio() */
467
468
469/*
470 * ---------------------------------------------------------------------------
471 * ask_unifi_sdio_cleanup
472 *
473 * We can not free our private context, until all the char device
474 * clients have closed the file handles. unregister_unifi_sdio() which
475 * is called when a card is removed, waits on Unifi_cleanup_wq until
476 * the reference count becomes zero. It is time to wake it up now.
477 *
478 * Arguments:
479 * priv Pointer to driver context.
480 *
481 * Returns:
482 * None.
483 * ---------------------------------------------------------------------------
484 */
485static void
486ask_unifi_sdio_cleanup(unifi_priv_t *priv)
487{
488
489 /*
490 * Now clear the flag that says the old instance is in use.
491 * This is used to prevent a new instance being started before old
492 * one has finshed closing down, for example if bounce makes the card
493 * appear to be ejected and re-inserted quickly.
494 */
495 In_use[priv->instance] = UNIFI_DEV_CLEANUP;
496
497 unifi_trace(NULL, UDBG5, "ask_unifi_sdio_cleanup: wake up cleanup workqueue.\n");
498 wake_up(&Unifi_cleanup_wq);
499
500} /* ask_unifi_sdio_cleanup() */
501
502
503/*
504 * ---------------------------------------------------------------------------
505 * cleanup_unifi_sdio
506 *
507 * Release any resources owned by a unifi instance.
508 *
509 * Arguments:
510 * priv Pointer to the instance to free.
511 *
512 * Returns:
513 * None.
514 * ---------------------------------------------------------------------------
515 */
516static void
517cleanup_unifi_sdio(unifi_priv_t *priv)
518{
519 int priv_instance;
520 int i;
521 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
522
523 /* Remove the device nodes */
524 uf_destroy_device_nodes(priv);
525
526 /* Mark this device as gone away by NULLing the entry in Unifi_instances */
527 Unifi_instances[priv->instance] = NULL;
528
529 unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: remove_proc_entry\n");
530 /*
531 * Free the children of priv before unifi_free_netdevice() frees
532 * the priv struct
533 */
534 remove_proc_entry(priv->proc_entry_name, 0);
535
536
537 /* Unregister netdev as a client. */
538 if (priv->netdev_client) {
539 unifi_trace(priv, UDBG2, "Netdev client (id:%d s:0x%X) is unregistered\n",
540 priv->netdev_client->client_id, priv->netdev_client->sender_id);
541 ul_deregister_client(priv->netdev_client);
542 }
543
544 /* Destroy the SME related threads and parameters */
545 uf_sme_deinit(priv);
546
547#ifdef CSR_SME_USERSPACE
548 priv->smepriv = NULL;
549#endif
550
551#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
552 if (log_hip_signals)
553 {
554 uf_unregister_hip_offline_debug(priv);
555 }
556#endif
557
558 /* Free any packets left in the Rx queues */
559 for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
560 {
561 uf_free_pending_rx_packets(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, i);
562 uf_free_pending_rx_packets(priv, UF_CONTROLLED_PORT_Q, broadcast_address, i);
563 }
564 /*
565 * We need to free the resources held by the core, which include tx skbs,
566 * otherwise we can not call unregister_netdev().
567 */
568 if (priv->card) {
569 unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: free card\n");
570 unifi_coredump_free(priv->card);
571 unifi_free_card(priv->card);
572 priv->card = NULL;
573 }
574
575 /*
576 * Unregister the network device.
577 * We can not unregister the netdev before we release
578 * all pending packets in the core.
579 */
580 uf_unregister_netdev(priv);
581 priv->totalInterfaceCount = 0;
582
583 /* Clear the table of registered netdev_priv's */
584 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
585 Unifi_netdev_instances[priv->instance * CSR_WIFI_NUM_INTERFACES + i] = NULL;
586 }
587
588 unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: uf_free_netdevice\n");
589 /*
590 * When uf_free_netdevice() returns, the priv is invalid
591 * so we need to remember the instance to clear the global flag later.
592 */
593 priv_instance = priv->instance;
594
595#ifdef CSR_WIFI_RX_PATH_SPLIT
596 flush_workqueue(priv->rx_workqueue);
597 destroy_workqueue(priv->rx_workqueue);
598 signal_buffer_free(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
599#endif
600
601 /* Priv is freed as part of the net_device */
602 uf_free_netdevice(priv);
603
604 /*
605 * Now clear the flag that says the old instance is in use.
606 * This is used to prevent a new instance being started before old
607 * one has finshed closing down, for example if bounce makes the card
608 * appear to be ejected and re-inserted quickly.
609 */
610 In_use[priv_instance] = UNIFI_DEV_NOT_IN_USE;
611
612 unifi_trace(NULL, UDBG5, "cleanup_unifi_sdio: DONE.\n");
613
614} /* cleanup_unifi_sdio() */
615
616
617/*
618 * ---------------------------------------------------------------------------
619 * unregister_unifi_sdio
620 *
621 * Call from SDIO driver when it detects that UniFi has been removed.
622 *
623 * Arguments:
624 * bus_id Number of the card that was ejected.
625 *
626 * Returns:
627 * None.
628 * ---------------------------------------------------------------------------
629 */
630static void
631unregister_unifi_sdio(int bus_id)
632{
633 unifi_priv_t *priv;
634 int interfaceTag=0;
635 u8 reason = CONFIG_IND_EXIT;
636
637 if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
638 unifi_error(NULL, "unregister_unifi_sdio: invalid device %d\n",
639 bus_id);
640 return;
641 }
642
643 priv = Unifi_instances[bus_id];
644 if (priv == NULL) {
645 unifi_error(priv, "unregister_unifi_sdio: device %d is not registered\n",
646 bus_id);
647 return;
648 }
649
650 /* Stop the network traffic before freeing the core. */
651 for(interfaceTag=0;interfaceTag<priv->totalInterfaceCount;interfaceTag++)
652 {
653 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
654 if(interfacePriv->netdev_registered)
655 {
656 netif_carrier_off(priv->netdev[interfaceTag]);
657 netif_tx_stop_all_queues(priv->netdev[interfaceTag]);
658 }
659 }
660
661#ifdef CSR_NATIVE_LINUX
662 /*
663 * If the unifi thread was started, signal it to stop. This
664 * should cause any userspace processes with open unifi device to
665 * close them.
666 */
667 uf_stop_thread(priv, &priv->bh_thread);
668
669 /* Unregister the interrupt handler */
670 if (csr_sdio_linux_remove_irq(priv->sdio)) {
671 unifi_notice(priv,
672 "csr_sdio_linux_remove_irq failed to talk to card.\n");
673 }
674
675 /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
676 uf_abort_mlme(priv);
677#endif /* CSR_NATIVE_LINUX */
678
679 ul_log_config_ind(priv, &reason, sizeof(u8));
680
681 /* Deregister the UDI hook from the core. */
682 unifi_remove_udi_hook(priv->card, logging_handler);
683
684 uf_put_instance(bus_id);
685
686 /*
687 * Wait until the device is cleaned up. i.e., when all userspace
688 * processes have closed any open unifi devices.
689 */
690 wait_event(Unifi_cleanup_wq, In_use[bus_id] == UNIFI_DEV_CLEANUP);
691 unifi_trace(NULL, UDBG5, "Received clean up event\n");
692
693 /* Now we can free the private context and the char device nodes */
694 cleanup_unifi_sdio(priv);
695
696} /* unregister_unifi_sdio() */
697
698
699/*
700 * ---------------------------------------------------------------------------
701 * uf_find_instance
702 *
703 * Find the context structure for a given UniFi device instance.
704 *
705 * Arguments:
706 * inst The instance number to look for.
707 *
708 * Returns:
709 * None.
710 * ---------------------------------------------------------------------------
711 */
712unifi_priv_t *
713uf_find_instance(int inst)
714{
715 if ((inst < 0) || (inst >= MAX_UNIFI_DEVS)) {
716 return NULL;
717 }
718 return Unifi_instances[inst];
719} /* uf_find_instance() */
720
721
722/*
723 * ---------------------------------------------------------------------------
724 * uf_find_priv
725 *
726 * Find the device instance for a given context structure.
727 *
728 * Arguments:
729 * priv The context structure pointer to look for.
730 *
731 * Returns:
732 * index of instance, -1 otherwise.
733 * ---------------------------------------------------------------------------
734 */
735int
736uf_find_priv(unifi_priv_t *priv)
737{
738 int inst;
739
740 if (!priv) {
741 return -1;
742 }
743
744 for (inst = 0; inst < MAX_UNIFI_DEVS; inst++) {
745 if (Unifi_instances[inst] == priv) {
746 return inst;
747 }
748 }
749
750 return -1;
751} /* uf_find_priv() */
752
753/*
754 * ---------------------------------------------------------------------------
755 * uf_find_netdev_priv
756 *
757 * Find the device instance for a given netdev context structure.
758 *
759 * Arguments:
760 * priv The context structure pointer to look for.
761 *
762 * Returns:
763 * index of instance, -1 otherwise.
764 * ---------------------------------------------------------------------------
765 */
766int
767uf_find_netdev_priv(netInterface_priv_t *priv)
768{
769 int inst;
770
771 if (!priv) {
772 return -1;
773 }
774
775 for (inst = 0; inst < MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES; inst++) {
776 if (Unifi_netdev_instances[inst] == priv) {
777 return inst;
778 }
779 }
780
781 return -1;
782} /* uf_find_netdev_priv() */
783
784/*
785 * ---------------------------------------------------------------------------
786 * uf_get_instance
787 *
788 * Find the context structure for a given UniFi device instance
789 * and increment the reference count.
790 *
791 * Arguments:
792 * inst The instance number to look for.
793 *
794 * Returns:
795 * Pointer to the instance or NULL if no instance exists.
796 * ---------------------------------------------------------------------------
797 */
798unifi_priv_t *
799uf_get_instance(int inst)
800{
801 unifi_priv_t *priv;
802
803 down(&Unifi_instance_mutex);
804
805 priv = uf_find_instance(inst);
806 if (priv) {
807 priv->ref_count++;
808 }
809
810 up(&Unifi_instance_mutex);
811
812 return priv;
813}
814
815/*
816 * ---------------------------------------------------------------------------
817 * uf_put_instance
818 *
819 * Decrement the context reference count, freeing resources and
820 * shutting down the driver when the count reaches zero.
821 *
822 * Arguments:
823 * inst The instance number to look for.
824 *
825 * Returns:
826 * Pointer to the instance or NULL if no instance exists.
827 * ---------------------------------------------------------------------------
828 */
829void
830uf_put_instance(int inst)
831{
832 unifi_priv_t *priv;
833
834 down(&Unifi_instance_mutex);
835
836 priv = uf_find_instance(inst);
837 if (priv) {
838 priv->ref_count--;
839 if (priv->ref_count == 0) {
840 ask_unifi_sdio_cleanup(priv);
841 }
842 }
843
844 up(&Unifi_instance_mutex);
845}
846
847
848/*
849 * ---------------------------------------------------------------------------
850 * uf_proc_show
851 *
852 * Read method for driver node in /proc/driver/unifi0
853 *
854 * Arguments:
855 * page
856 * start
857 * offset
858 * count
859 * eof
860 * data
861 *
862 * Returns:
863 * None.
864 * ---------------------------------------------------------------------------
865 */
866#ifdef CONFIG_PROC_FS
867static int uf_proc_show(struct seq_file *m, void *v)
868{
869 unifi_priv_t *priv;
870 int i;
871
872 /*
873 * The following complex casting is in place in order to eliminate
874 * 64-bit compilation warning "cast to/from pointer from/to integer of
875 * different size"
876 */
877 priv = uf_find_instance((long)m->private);
878 if (!priv)
879 return 0;
880
881 seq_printf(m, "UniFi SDIO Driver: %s %s %s\n",
882 CSR_WIFI_VERSION, __DATE__, __TIME__);
883#ifdef CSR_SME_USERSPACE
884 seq_puts(m, "SME: CSR userspace ");
885#ifdef CSR_SUPPORT_WEXT
886 seq_puts(m, "with WEXT support\n");
887#else
888 seq_putc(m, '\n');
889#endif /* CSR_SUPPORT_WEXT */
890#endif /* CSR_SME_USERSPACE */
891#ifdef CSR_NATIVE_LINUX
892 seq_puts(m, "SME: native\n");
893#endif
894
895#ifdef CSR_SUPPORT_SME
896 seq_printf(m, "Firmware (ROM) build:%u, Patch:%u\n",
897 priv->card_info.fw_build,
898 priv->sme_versions.firmwarePatch);
899#endif
900
901 unifi_print_status(priv->card, m);
902
903 seq_printf(m, "Last dbg str: %s\n", priv->last_debug_string);
904
905 seq_puts(m, "Last dbg16:");
906 for (i = 0; i < 8; i++)
907 seq_printf(m, " %04X", priv->last_debug_word16[i]);
908 seq_putc(m, '\n');
909 seq_puts(m, " ");
910 for (; i < 16; i++)
911 seq_printf(m, " %04X", priv->last_debug_word16[i]);
912 seq_putc(m, '\n');
913 return 0;
914}
915#endif
916
917
918
919
920static void
921uf_lx_suspend(CsrSdioFunction *sdio_ctx)
922{
923 unifi_priv_t *priv = sdio_ctx->driverData;
924 unifi_suspend(priv);
925
926 CsrSdioSuspendAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
927}
928
929static void
930uf_lx_resume(CsrSdioFunction *sdio_ctx)
931{
932 unifi_priv_t *priv = sdio_ctx->driverData;
933 unifi_resume(priv);
934
935 CsrSdioResumeAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
936}
937
938static int active_slot = MAX_UNIFI_DEVS;
939static struct device *os_devices[MAX_UNIFI_DEVS];
940
941void
942uf_add_os_device(int bus_id, struct device *os_device)
943{
944 if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
945 unifi_error(NULL, "uf_add_os_device: invalid device %d\n",
946 bus_id);
947 return;
948 }
949
950 active_slot = bus_id;
951 os_devices[bus_id] = os_device;
952} /* uf_add_os_device() */
953
954void
955uf_remove_os_device(int bus_id)
956{
957 if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
958 unifi_error(NULL, "uf_remove_os_device: invalid device %d\n",
959 bus_id);
960 return;
961 }
962
963 active_slot = bus_id;
964 os_devices[bus_id] = NULL;
965} /* uf_remove_os_device() */
966
967static void
968uf_sdio_inserted(CsrSdioFunction *sdio_ctx)
969{
970 unifi_priv_t *priv;
971
972 unifi_trace(NULL, UDBG5, "uf_sdio_inserted(0x%p), slot_id=%d, dev=%p\n",
973 sdio_ctx, active_slot, os_devices[active_slot]);
974
975 priv = register_unifi_sdio(sdio_ctx, active_slot, os_devices[active_slot]);
976 if (priv == NULL) {
977 CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_FAILURE);
978 return;
979 }
980
981 sdio_ctx->driverData = priv;
982
983 CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
984} /* uf_sdio_inserted() */
985
986
987static void
988uf_sdio_removed(CsrSdioFunction *sdio_ctx)
989{
990 unregister_unifi_sdio(active_slot);
991 CsrSdioRemovedAcknowledge(sdio_ctx);
992} /* uf_sdio_removed() */
993
994
995static void
996uf_sdio_dsr_handler(CsrSdioFunction *sdio_ctx)
997{
998 unifi_priv_t *priv = sdio_ctx->driverData;
999
1000 unifi_sdio_interrupt_handler(priv->card);
1001} /* uf_sdio_dsr_handler() */
1002
1003/*
1004 * ---------------------------------------------------------------------------
1005 * uf_sdio_int_handler
1006 *
1007 * Interrupt callback function for SDIO interrupts.
1008 * This is called in kernel context (i.e. not interrupt context).
1009 * We retrieve the unifi context pointer and call the main UniFi
1010 * interrupt handler.
1011 *
1012 * Arguments:
1013 * fdev SDIO context pointer
1014 *
1015 * Returns:
1016 * None.
1017 * ---------------------------------------------------------------------------
1018 */
1019static CsrSdioInterruptDsrCallback
1020uf_sdio_int_handler(CsrSdioFunction *sdio_ctx)
1021{
1022 return uf_sdio_dsr_handler;
1023} /* uf_sdio_int_handler() */
1024
1025
1026
1027
1028static CsrSdioFunctionId unifi_ids[] =
1029{
1030 {
1031 .manfId = SDIO_MANF_ID_CSR,
1032 .cardId = SDIO_CARD_ID_UNIFI_3,
1033 .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_3,
1034 .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE,
1035 },
1036 {
1037 .manfId = SDIO_MANF_ID_CSR,
1038 .cardId = SDIO_CARD_ID_UNIFI_4,
1039 .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_4,
1040 .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE,
1041 }
1042};
1043
1044
1045/*
1046 * Structure to register with the glue layer.
1047 */
1048static CsrSdioFunctionDriver unifi_sdioFunction_drv =
1049{
1050 .inserted = uf_sdio_inserted,
1051 .removed = uf_sdio_removed,
1052 .intr = uf_sdio_int_handler,
1053 .suspend = uf_lx_suspend,
1054 .resume = uf_lx_resume,
1055
1056 .ids = unifi_ids,
1057 .idsCount = sizeof(unifi_ids) / sizeof(unifi_ids[0])
1058};
1059
1060
1061/*
1062 * ---------------------------------------------------------------------------
1063 * uf_sdio_load
1064 * uf_sdio_unload
1065 *
1066 * These functions are called from the main module load and unload
1067 * functions. They perform the appropriate operations for the monolithic
1068 * driver.
1069 *
1070 * Arguments:
1071 * None.
1072 *
1073 * Returns:
1074 * None.
1075 * ---------------------------------------------------------------------------
1076 */
1077int __init
1078uf_sdio_load(void)
1079{
1080 CsrResult csrResult;
1081
1082 csrResult = CsrSdioFunctionDriverRegister(&unifi_sdioFunction_drv);
1083 if (csrResult != CSR_RESULT_SUCCESS) {
1084 unifi_error(NULL, "Failed to register UniFi SDIO driver: csrResult=%d\n", csrResult);
1085 return -EIO;
1086 }
1087
1088 return 0;
1089} /* uf_sdio_load() */
1090
1091
1092
1093void __exit
1094uf_sdio_unload(void)
1095{
1096 CsrSdioFunctionDriverUnregister(&unifi_sdioFunction_drv);
1097} /* uf_sdio_unload() */
1098
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
deleted file mode 100644
index 861d6b7687c7..000000000000
--- a/drivers/staging/csr/mlme.c
+++ /dev/null
@@ -1,433 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: mlme.c
4 *
5 * PURPOSE:
6 * This file provides functions to send MLME requests to the UniFi.
7 *
8 * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
9 *
10 * Refer to LICENSE.txt included with this source code for details on
11 * the license terms.
12 *
13 * ---------------------------------------------------------------------------
14 */
15#include "csr_wifi_hip_unifi.h"
16#include "unifi_priv.h"
17
18/*
19 * ---------------------------------------------------------------------------
20 * unifi_mlme_wait_for_reply
21 *
22 * Wait for a reply after sending a signal.
23 *
24 * Arguments:
25 * priv Pointer to device private context struct
26 * ul_client Pointer to linux client
27 * sig_reply_id ID of the expected reply (defined in sigs.h).
28 * timeout timeout in ms
29 *
30 * Returns:
31 * 0 on success, -ve POSIX code on error.
32 *
33 * Notes:
34 * This function waits for a specific (sig_reply_id) signal from UniFi.
35 * It also match the sequence number of the received (cfm) signal, with
36 * the latest sequence number of the signal (req) we have sent.
37 * These two number match be equal.
38 * Should only be used for waiting xxx.cfm signals and only after
39 * we have sent the matching xxx.req signal to UniFi.
40 * If no response is received within the expected time (timeout), we assume
41 * that the UniFi is busy and return an error.
42 * If the wait is aborted by a kernel signal arriving, we stop waiting.
43 * If a response from UniFi is not what we expected, we discard it and
44 * wait again. This could be a response from an aborted request. If we
45 * see several bad responses we assume we have lost synchronisation with
46 * UniFi.
47 * ---------------------------------------------------------------------------
48 */
49static int
50unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout)
51{
52 int retries = 0;
53 long r;
54 long t = timeout;
55 unsigned int sent_seq_no;
56
57 /* Convert t in ms to jiffies */
58 t = msecs_to_jiffies(t);
59
60 do {
61 /* Wait for the confirm or timeout. */
62 r = wait_event_interruptible_timeout(pcli->udi_wq,
63 (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
64 t);
65 /* Check for general i/o error */
66 if (priv->io_aborted) {
67 unifi_error(priv, "MLME operation aborted\n");
68 return -EIO;
69 }
70
71 /*
72 * If r=0 the request has timed-out.
73 * If r>0 the request has completed successfully.
74 * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
75 */
76 if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
77 unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
78 sig_reply_id, jiffies_to_msecs(t));
79 pcli->wake_up_wq_id = 0;
80 return -ETIMEDOUT;
81 } else if (r == -ERESTARTSYS) {
82 unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
83 pcli->wake_up_wq_id = 0;
84 return -EINTR;
85 } else {
86 /* Get the sequence number of the signal that we previously set. */
87 if (pcli->seq_no != 0) {
88 sent_seq_no = pcli->seq_no - 1;
89 } else {
90 sent_seq_no = 0x0F;
91 }
92
93 unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
94 pcli->wake_up_wq_id,
95 pcli->wake_seq_no, sent_seq_no);
96
97 /* The two sequence ids must match. */
98 if (pcli->wake_seq_no == sent_seq_no) {
99 /* and the signal ids must match. */
100 if (sig_reply_id == pcli->wake_up_wq_id) {
101 /* Found the expected signal */
102 break;
103 } else {
104 /* This should never happen ... */
105 unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
106 pcli->wake_up_wq_id,
107 sig_reply_id,
108 pcli->wake_seq_no);
109 pcli->wake_up_wq_id = 0;
110 return -EIO;
111 }
112 }
113 /* Wait for the next signal. */
114 pcli->wake_up_wq_id = 0;
115
116 retries ++;
117 if (retries >= 3) {
118 unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
119 pcli->wake_up_wq_id,
120 sig_reply_id);
121 pcli->wake_up_wq_id = 0;
122 return -EIO;
123 }
124 }
125 } while (1);
126
127 pcli->wake_up_wq_id = 0;
128
129 return 0;
130} /* unifi_mlme_wait_for_reply() */
131
132
133/*
134 * ---------------------------------------------------------------------------
135 * unifi_mlme_blocking_request
136 *
137 * Send a MLME request signal to UniFi.
138 *
139 * Arguments:
140 * priv Pointer to device private context struct
141 * pcli Pointer to context of calling process
142 * sig Pointer to the signal to send
143 * data_ptrs Pointer to the bulk data of the signal
144 * timeout The request's timeout.
145 *
146 * Returns:
147 * 0 on success, 802.11 result code on error.
148 * ---------------------------------------------------------------------------
149 */
150int
151unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
152 CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
153 int timeout)
154{
155 int r;
156
157 if (sig->SignalPrimitiveHeader.SignalId == 0) {
158 unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
159 sig->SignalPrimitiveHeader.SignalId);
160 return -EINVAL;
161 }
162
163 down(&priv->mlme_blocking_mutex);
164
165 sig->SignalPrimitiveHeader.ReceiverProcessId = 0;
166 sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no;
167
168 unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n",
169 pcli->client_id,
170 sig->SignalPrimitiveHeader.SenderProcessId,
171 sig->SignalPrimitiveHeader.SignalId);
172 /* Send the signal to UniFi */
173 r = ul_send_signal_unpacked(priv, sig, data_ptrs);
174 if (r) {
175 up(&priv->mlme_blocking_mutex);
176 unifi_error(priv, "Error queueing MLME REQUEST signal\n");
177 return r;
178 }
179
180 unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n",
181 sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
182
183 /*
184 * Advance the sequence number of the last sent signal, only
185 * if the signal has been successfully set.
186 */
187 pcli->seq_no++;
188 if (pcli->seq_no > 0x0F) {
189 pcli->seq_no = 0;
190 }
191
192 r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
193 up(&priv->mlme_blocking_mutex);
194
195 if (r) {
196 unifi_error(priv, "Error waiting for MLME CONFIRM signal\n");
197 return r;
198 }
199
200 return 0;
201} /* unifi_mlme_blocking_request() */
202
203
204/*
205 * ---------------------------------------------------------------------------
206 * unifi_mlme_copy_reply_and_wakeup_client
207 *
208 * Copy the reply signal from UniFi to the client's structure
209 * and wake up the waiting client.
210 *
211 * Arguments:
212 * None.
213 *
214 * Returns:
215 * None.
216 * ---------------------------------------------------------------------------
217 */
218void
219unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
220 CSR_SIGNAL *signal, int signal_len,
221 const bulk_data_param_t *bulkdata)
222{
223 int i;
224
225 /* Copy the signal to the reply */
226 memcpy(pcli->reply_signal, signal, signal_len);
227
228 /* Get the sequence number of the signal that woke us up. */
229 pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F;
230
231 /* Append any bulk data */
232 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
233 if (bulkdata->d[i].data_length > 0) {
234 if (bulkdata->d[i].os_data_ptr) {
235 memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length);
236 pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length;
237 } else {
238 pcli->reply_bulkdata[i]->length = 0;
239 }
240 }
241 }
242
243 /* Wake the requesting MLME function. */
244 pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId;
245 wake_up_interruptible(&pcli->udi_wq);
246
247} /* unifi_mlme_copy_reply_and_wakeup_client() */
248
249
250/*
251 * ---------------------------------------------------------------------------
252 * uf_abort_mlme
253 *
254 * Abort any MLME operation in progress.
255 * This is used in the error recovery mechanism.
256 *
257 * Arguments:
258 * priv Pointer to driver context.
259 *
260 * Returns:
261 * 0 on success.
262 * ---------------------------------------------------------------------------
263 */
264int
265uf_abort_mlme(unifi_priv_t *priv)
266{
267 ul_client_t *ul_cli;
268
269 /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
270 priv->io_aborted = 1;
271
272 ul_cli = priv->netdev_client;
273 if (ul_cli) {
274 wake_up_interruptible(&ul_cli->udi_wq);
275 }
276
277 ul_cli = priv->wext_client;
278 if (ul_cli) {
279 wake_up_interruptible(&ul_cli->udi_wq);
280 }
281
282 return 0;
283} /* uf_abort_mlme() */
284
285
286
287/*
288 * ---------------------------------------------------------------------------
289 *
290 * Human-readable decoding of Reason and Result codes.
291 *
292 * ---------------------------------------------------------------------------
293 */
294
295struct mlme_code {
296 const char *name;
297 int id;
298};
299
300static const struct mlme_code Result_codes[] = {
301 { "Success", 0x0000 },
302 { "Unspecified Failure", 0x0001 },
303 /* (Reserved) 0x0002 - 0x0009 */
304 { "Refused Capabilities Mismatch", 0x000A },
305 /* (Reserved) 0x000B */
306 { "Refused External Reason", 0x000C },
307 /* (Reserved) 0x000D - 0x0010 */
308 { "Refused AP Out Of Memory", 0x0011 },
309 { "Refused Basic Rates Mismatch", 0x0012 },
310 /* (Reserved) 0x0013 - 0x001F */
311 { "Failure", 0x0020 },
312 /* (Reserved) 0x0021 - 0x0024 */
313 { "Refused Reason Unspecified", 0x0025 },
314 { "Invalid Parameters", 0x0026 },
315 { "Rejected With Suggested Changes", 0x0027 },
316 /* (Reserved) 0x0028 - 0x002E */
317 { "Rejected For Delay Period", 0x002F },
318 { "Not Allowed", 0x0030 },
319 { "Not Present", 0x0031 },
320 { "Not QSTA", 0x0032 },
321 /* (Reserved) 0x0033 - 0x7FFF */
322 { "Timeout", 0x8000 },
323 { "Too Many Simultaneous Requests", 0x8001 },
324 { "BSS Already Started Or Joined", 0x8002 },
325 { "Not Supported", 0x8003 },
326 { "Transmission Failure", 0x8004 },
327 { "Refused Not Authenticated", 0x8005 },
328 { "Reset Required Before Start", 0x8006 },
329 { "LM Info Unavailable", 0x8007 },
330 { NULL, -1 }
331};
332
333static const struct mlme_code Reason_codes[] = {
334 /* (Reserved) 0x0000 */
335 { "Unspecified Reason", 0x0001 },
336 { "Authentication Not Valid", 0x0002 },
337 { "Deauthenticated Leave BSS", 0x0003 },
338 { "Disassociated Inactivity", 0x0004 },
339 { "AP Overload", 0x0005 },
340 { "Class2 Frame Error", 0x0006 },
341 { "Class3 Frame Error", 0x0007 },
342 { "Disassociated Leave BSS", 0x0008 },
343 { "Association Not Authenticated", 0x0009 },
344 { "Disassociated Power Capability", 0x000A },
345 { "Disassociated Supported Channels", 0x000B },
346 /* (Reserved) 0x000C */
347 { "Invalid Information Element", 0x000D },
348 { "Michael MIC Failure", 0x000E },
349 { "Fourway Handshake Timeout", 0x000F },
350 { "Group Key Update Timeout", 0x0010 },
351 { "Handshake Element Different", 0x0011 },
352 { "Invalid Group Cipher", 0x0012 },
353 { "Invalid Pairwise Cipher", 0x0013 },
354 { "Invalid AKMP", 0x0014 },
355 { "Unsupported RSN IE Version", 0x0015 },
356 { "Invalid RSN IE Capabilities", 0x0016 },
357 { "Dot1X Auth Failed", 0x0017 },
358 { "Cipher Rejected By Policy", 0x0018 },
359 /* (Reserved) 0x0019 - 0x001F */
360 { "QoS Unspecified Reason", 0x0020 },
361 { "QoS Insufficient Bandwidth", 0x0021 },
362 { "QoS Excessive Not Ack", 0x0022 },
363 { "QoS TXOP Limit Exceeded", 0x0023 },
364 { "QSTA Leaving", 0x0024 },
365 { "End TS, End DLS, End BA", 0x0025 },
366 { "Unknown TS, Unknown DLS, Unknown BA", 0x0026 },
367 { "Timeout", 0x0027 },
368 /* (Reserved) 0x0028 - 0x002C */
369 { "STAKey Mismatch", 0x002D },
370 { NULL, -1 }
371};
372
373
374static const char *
375lookup_something(const struct mlme_code *n, int id)
376{
377 for (; n->name; n++) {
378 if (n->id == id) {
379 return n->name;
380 }
381 }
382
383 /* not found */
384 return NULL;
385} /* lookup_something() */
386
387
388const char *
389lookup_result_code(int result)
390{
391 static char fallback[16];
392 const char *str;
393
394 str = lookup_something(Result_codes, result);
395
396 if (str == NULL) {
397 snprintf(fallback, 16, "%d", result);
398 str = fallback;
399 }
400
401 return str;
402} /* lookup_result_code() */
403
404
405/*
406 * ---------------------------------------------------------------------------
407 * lookup_reason
408 *
409 * Return a description string for a WiFi MLME ReasonCode.
410 *
411 * Arguments:
412 * reason The ReasonCode to interpret.
413 *
414 * Returns:
415 * Pointer to description string.
416 * ---------------------------------------------------------------------------
417 */
418const char *
419lookup_reason_code(int reason)
420{
421 static char fallback[16];
422 const char *str;
423
424 str = lookup_something(Reason_codes, reason);
425
426 if (str == NULL) {
427 snprintf(fallback, 16, "%d", reason);
428 str = fallback;
429 }
430
431 return str;
432} /* lookup_reason_code() */
433
diff --git a/drivers/staging/csr/monitor.c b/drivers/staging/csr/monitor.c
deleted file mode 100644
index e11f6cba8266..000000000000
--- a/drivers/staging/csr/monitor.c
+++ /dev/null
@@ -1,384 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: monitor.c
4 *
5 * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
6 *
7 * Refer to LICENSE.txt included with this source code for details on
8 * the license terms.
9 *
10 * ---------------------------------------------------------------------------
11 */
12
13#include "unifi_priv.h"
14
15#ifdef UNIFI_SNIFF_ARPHRD
16
17
18#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
19#include <net/ieee80211_radiotap.h>
20#endif
21
22#ifndef ETH_P_80211_RAW
23#define ETH_P_80211_RAW ETH_P_ALL
24#endif
25
26/*
27 * ---------------------------------------------------------------------------
28 * uf_start_sniff
29 *
30 * Start UniFi capture in SNIFF mode, i.e capture everything it hears.
31 *
32 * Arguments:
33 * priv Pointer to device private context struct
34 *
35 * Returns:
36 * 0 on success or kernel error code
37 * ---------------------------------------------------------------------------
38 */
39int
40uf_start_sniff(unifi_priv_t *priv)
41{
42 ul_client_t *pcli = priv->wext_client;
43 CSR_SIGNAL signal;
44 CSR_MLME_SNIFFJOIN_REQUEST *req = &signal.u.MlmeSniffjoinRequest;
45 int timeout = 1000;
46 int r;
47
48 req->Ifindex = priv->if_index;
49 req->Channel = priv->wext_conf.channel;
50 req->ChannelStartingFactor = 0;
51
52 signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SNIFFJOIN_REQUEST_ID;
53
54 r = unifi_mlme_blocking_request(priv, pcli, &signal, NULL, timeout);
55 if (r < 0) {
56 unifi_error(priv, "failed to send SNIFFJOIN request, error %d\n", r);
57 return r;
58 }
59
60 r = pcli->reply_signal->u.MlmeSniffjoinConfirm.Resultcode;
61 if (r) {
62 unifi_notice(priv, "SNIFFJOIN request was rejected with result 0x%X (%s)\n",
63 r, lookup_result_code(r));
64 return -EIO;
65 }
66
67 return 0;
68} /* uf_start_sniff() */
69
70
71
72/*
73 * ---------------------------------------------------------------------------
74 * netrx_radiotap
75 *
76 * Reformat a UniFi SNIFFDATA signal into a radiotap packet.
77 *
78 * Arguments:
79 * priv OS private context pointer.
80 * ind Pointer to a MA_UNITDATA_INDICATION or
81 * DS_UNITDATA_INDICATION indication structure.
82 *
83 * Notes:
84 * Radiotap header values are all little-endian, UniFi signals will have
85 * been converted to host-endian.
86 * ---------------------------------------------------------------------------
87 */
88#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
89static void
90netrx_radiotap(unifi_priv_t *priv,
91 const CSR_MA_SNIFFDATA_INDICATION *ind,
92 struct sk_buff *skb_orig)
93{
94 struct net_device *dev = priv->netdev;
95 struct sk_buff *skb = NULL;
96 unsigned char *ptr;
97 unsigned char *base;
98 int ind_data_len = skb_orig->len - 2 - ETH_HLEN;
99 struct unifi_rx_radiotap_header {
100 struct ieee80211_radiotap_header rt_hdr;
101 /* IEEE80211_RADIOTAP_TSFT */
102 u64 rt_tsft;
103 /* IEEE80211_RADIOTAP_FLAGS */
104 u8 rt_flags;
105 /* IEEE80211_RADIOTAP_RATE */
106 u8 rt_rate;
107 /* IEEE80211_RADIOTAP_CHANNEL */
108 u16 rt_chan;
109 u16 rt_chan_flags;
110 /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
111 u8 rt_dbm_antsignal;
112 /* IEEE80211_RADIOTAP_DBM_ANTNOISE */
113 u8 rt_dbm_antnoise;
114 /* IEEE80211_RADIOTAP_ANTENNA */
115 u8 rt_antenna;
116
117 /* pad to 4-byte boundary */
118 u8 pad[3];
119 } __attribute__((__packed__));
120
121 struct unifi_rx_radiotap_header *unifi_rt;
122 int signal, noise, snr;
123
124 if (ind_data_len <= 0) {
125 unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n");
126 return;
127 }
128
129 /*
130 * Allocate a SKB for the received data packet, including radiotap
131 * header.
132 */
133 skb = dev_alloc_skb(ind_data_len + sizeof(struct unifi_rx_radiotap_header) + 4);
134 if (! skb) {
135 unifi_error(priv, "alloc_skb failed.\n");
136 priv->stats.rx_errors++;
137 return;
138 }
139
140 base = skb->data;
141
142 /* Reserve the radiotap header at the front of skb */
143 unifi_rt = (struct unifi_rx_radiotap_header *)
144 skb_put(skb, sizeof(struct unifi_rx_radiotap_header));
145
146 /* Copy in the 802.11 frame */
147 ptr = skb_put(skb, ind_data_len);
148 memcpy(ptr, skb_orig->data, ind_data_len);
149
150 unifi_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
151 unifi_rt->rt_hdr.it_pad = 0; /* always good to zero */
152 unifi_rt->rt_hdr.it_len = sizeof(struct unifi_rx_radiotap_header);
153
154 /* Big bitfield of all the fields we provide in radiotap */
155 unifi_rt->rt_hdr.it_present = 0
156 | (1 << IEEE80211_RADIOTAP_TSFT)
157 | (1 << IEEE80211_RADIOTAP_FLAGS)
158 | (1 << IEEE80211_RADIOTAP_RATE)
159 | (1 << IEEE80211_RADIOTAP_CHANNEL)
160 | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)
161 | (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)
162 | (1 << IEEE80211_RADIOTAP_ANTENNA)
163 ;
164
165
166 /* No flags to set */
167 unifi_rt->rt_tsft = (((u64)ind->Timestamp.x[7]) | (((u64)ind->Timestamp.x[6]) << 8) |
168 (((u64)ind->Timestamp.x[5]) << 16) | (((u64)ind->Timestamp.x[4]) << 24) |
169 (((u64)ind->Timestamp.x[3]) << 32) | (((u64)ind->Timestamp.x[2]) << 40) |
170 (((u64)ind->Timestamp.x[1]) << 48) | (((u64)ind->Timestamp.x[0]) << 56));
171
172 unifi_rt->rt_flags = 0;
173
174 unifi_rt->rt_rate = ind->Rate;
175
176 unifi_rt->rt_chan = cpu_to_le16(ieee80211chan2mhz(priv->wext_conf.channel));
177 unifi_rt->rt_chan_flags = 0;
178
179 /* Convert signal to dBm */
180 signal = (s16)unifi2host_16(ind->Rssi); /* in dBm */
181 snr = (s16)unifi2host_16(ind->Snr); /* in dB */
182 noise = signal - snr;
183
184 unifi_rt->rt_dbm_antsignal = signal;
185 unifi_rt->rt_dbm_antnoise = noise;
186
187 unifi_rt->rt_antenna = ind->AntennaId;
188
189
190 skb->dev = dev;
191 skb_reset_mac_header(skb);
192 skb->pkt_type = PACKET_OTHERHOST;
193 skb->protocol = __constant_htons(ETH_P_80211_RAW);
194 memset(skb->cb, 0, sizeof(skb->cb));
195
196 /* Pass up to Linux network stack */
197 netif_rx_ni(skb);
198
199 dev->last_rx = jiffies;
200
201 /* Bump the rx stats */
202 priv->stats.rx_packets++;
203 priv->stats.rx_bytes += ind_data_len;
204
205} /* netrx_radiotap() */
206#endif /* RADIOTAP */
207
208
209/*
210 * ---------------------------------------------------------------------------
211 * netrx_prism
212 *
213 * Reformat a UniFi SNIFFDATA signal into a Prism format sniff packet.
214 *
215 * Arguments:
216 * priv OS private context pointer.
217 * ind Pointer to a MA_UNITDATA_INDICATION or
218 * DS_UNITDATA_INDICATION indication structure.
219 *
220 * Notes:
221 * Radiotap header values are all little-endian, UniFi signals will have
222 * been converted to host-endian.
223 * ---------------------------------------------------------------------------
224 */
225#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM)
226static void
227netrx_prism(unifi_priv_t *priv,
228 const CSR_MA_SNIFFDATA_INDICATION *ind,
229 struct sk_buff *skb_orig)
230{
231 struct net_device *dev = priv->netdev;
232 struct sk_buff *skb = NULL;
233 unsigned char *ptr;
234 unsigned char *base;
235 int ind_data_len = skb_orig->len - 2 - ETH_HLEN;
236#define WLANCAP_MAGIC_COOKIE_V1 0x80211001
237 struct avs_header_v1 {
238 uint32 version;
239 uint32 length;
240 uint64 mactime;
241 uint64 hosttime;
242 uint32 phytype;
243 uint32 channel;
244 uint32 datarate;
245 uint32 antenna;
246 uint32 priority;
247 uint32 ssi_type;
248 int32 ssi_signal;
249 int32 ssi_noise;
250 uint32 preamble;
251 uint32 encoding;
252 } *avs;
253 int signal, noise, snr;
254
255 if (ind_data_len <= 0) {
256 unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n");
257 return;
258 }
259
260 /*
261 * Allocate a SKB for the received data packet, including radiotap
262 * header.
263 */
264 skb = dev_alloc_skb(ind_data_len + sizeof(struct avs_header_v1) + 4);
265 if (! skb) {
266 unifi_error(priv, "alloc_skb failed.\n");
267 priv->stats.rx_errors++;
268 return;
269 }
270
271 base = skb->data;
272
273 /* Reserve the radiotap header at the front of skb */
274 avs = (struct avs_header_v1 *)skb_put(skb, sizeof(struct avs_header_v1));
275
276 /* Copy in the 802.11 frame */
277 ptr = skb_put(skb, ind_data_len);
278 memcpy(ptr, skb_orig->data, ind_data_len);
279
280 /* Convert signal to dBm */
281 signal = 0x10000 - ((s16)unifi2host_16(ind->Rssi)); /* in dBm */
282 snr = (s16)unifi2host_16(ind->Snr); /* in dB */
283 noise = signal - snr;
284
285 avs->version = htonl(WLANCAP_MAGIC_COOKIE_V1);
286 avs->length = htonl(sizeof(struct avs_header_v1));
287 avs->mactime = __cpu_to_be64(ind->Timestamp);
288 avs->hosttime = __cpu_to_be64(jiffies);
289 avs->phytype = htonl(9); /* dss_ofdm_dot11_g */
290 avs->channel = htonl(priv->wext_conf.channel);
291 avs->datarate = htonl(ind->Rate * 5);
292 avs->antenna = htonl(ind->Antenna);
293 avs->priority = htonl(0); /* unknown */
294 avs->ssi_type = htonl(2); /* dBm */
295 avs->ssi_signal = htonl(signal);
296 avs->ssi_noise = htonl(noise);
297 avs->preamble = htonl(0); /* unknown */
298 avs->encoding = htonl(0); /* unknown */
299
300
301 skb->dev = dev;
302 skb->mac.raw = skb->data;
303 skb->pkt_type = PACKET_OTHERHOST;
304 skb->protocol = __constant_htons(ETH_P_80211_RAW);
305 memset(skb->cb, 0, sizeof(skb->cb));
306
307 /* Pass up to Linux network stack */
308 netif_rx_ni(skb);
309
310 dev->last_rx = jiffies;
311
312 /* Bump the rx stats */
313 priv->stats.rx_packets++;
314 priv->stats.rx_bytes += ind_data_len;
315
316} /* netrx_prism() */
317#endif /* PRISM */
318
319
320/*
321 * ---------------------------------------------------------------------------
322 * ma_sniffdata_ind
323 *
324 * Reformat a UniFi SNIFFDATA signal into a network
325 *
326 * Arguments:
327 * ospriv OS private context pointer.
328 * ind Pointer to a MA_UNITDATA_INDICATION or
329 * DS_UNITDATA_INDICATION indication structure.
330 * bulkdata Pointer to a bulk data structure, describing
331 * the data received.
332 *
333 * Notes:
334 * Radiotap header values are all little-endian, UniFi signals will have
335 * been converted to host-endian.
336 * ---------------------------------------------------------------------------
337 */
338void
339ma_sniffdata_ind(void *ospriv,
340 const CSR_MA_SNIFFDATA_INDICATION *ind,
341 const bulk_data_param_t *bulkdata)
342{
343 unifi_priv_t *priv = ospriv;
344 struct net_device *dev = priv->netdev;
345 struct sk_buff *skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
346
347 if (bulkdata->d[0].data_length == 0) {
348 unifi_warning(priv, "rx: MA-SNIFFDATA indication with zero bulk data\n");
349 return;
350 }
351
352 skb->len = bulkdata->d[0].data_length;
353
354 /* We only process data packets if the interface is open */
355 if (unlikely(!netif_running(dev))) {
356 priv->stats.rx_dropped++;
357 priv->wext_conf.wireless_stats.discard.misc++;
358 dev_kfree_skb(skb);
359 return;
360 }
361
362 if (ind->ReceptionStatus) {
363 priv->stats.rx_dropped++;
364 priv->wext_conf.wireless_stats.discard.misc++;
365 printk(KERN_INFO "unifi: Dropping corrupt sniff packet\n");
366 dev_kfree_skb(skb);
367 return;
368 }
369
370#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM)
371 netrx_prism(priv, ind, skb);
372#endif /* PRISM */
373
374#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
375 netrx_radiotap(priv, ind, skb);
376#endif /* RADIOTAP */
377
378 dev_kfree_skb(skb);
379
380} /* ma_sniffdata_ind() */
381
382
383#endif /* UNIFI_SNIFF_ARPHRD */
384
diff --git a/drivers/staging/csr/netdev.c b/drivers/staging/csr/netdev.c
deleted file mode 100644
index 9c716c162c24..000000000000
--- a/drivers/staging/csr/netdev.c
+++ /dev/null
@@ -1,3307 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: netdev.c
4 *
5 * PURPOSE:
6 * This file provides the upper edge interface to the linux netdevice
7 * and wireless extensions.
8 * It is part of the porting exercise.
9 *
10 * Copyright (C) 2005-2010 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 * ---------------------------------------------------------------------------
16 */
17
18/*
19 * Porting Notes:
20 * This file implements the data plane of the UniFi linux driver.
21 *
22 * All the Tx packets are passed to the HIP core lib, using the
23 * unifi_send_signal() API. For EAPOL packets use the MLME-EAPOL.req
24 * signal, for all other use the MLME-UNITDATA.req. The unifi_send_signal()
25 * expects the wire-formatted (packed) signal. For convenience, in the OS
26 * layer we only use the native (unpacked) signal structures. The HIP core lib
27 * provides the write_pack() helper function to convert to the packed signal.
28 * The packet is stored in the bulk data of the signal. We do not need to
29 * allocate new memory to store the packet, because unifi_net_data_malloc()
30 * is implemented to return a skb, which is the format of packet in Linux.
31 * The HIP core lib frees the bulk data buffers, so we do not need to do
32 * this in the OS layer.
33 *
34 * All the Rx packets are MLME-UNITDATA.ind signals, passed by the HIP core lib
35 * in unifi_receive_event(). We do not need to allocate an skb and copy the
36 * received packet because the HIP core lib has stored in memory allocated by
37 * unifi_net_data_malloc(). Also, we can perform the 802.11 to Ethernet
38 * translation in-place because we allocate the extra memory allocated in
39 * unifi_net_data_malloc().
40 *
41 * If possible, the porting exercise should appropriately implement
42 * unifi_net_data_malloc() and unifi_net_data_free() to save copies between
43 * network and driver buffers.
44 */
45
46#include <linux/types.h>
47#include <linux/etherdevice.h>
48#include <linux/mutex.h>
49#include <linux/semaphore.h>
50#include <linux/vmalloc.h>
51#include "csr_wifi_hip_unifi.h"
52#include "csr_wifi_hip_conversions.h"
53#include "unifi_priv.h"
54#include <net/pkt_sched.h>
55
56
57/* Wext handler is supported only if CSR_SUPPORT_WEXT is defined */
58#ifdef CSR_SUPPORT_WEXT
59extern struct iw_handler_def unifi_iw_handler_def;
60#endif /* CSR_SUPPORT_WEXT */
61static void check_ba_frame_age_timeout( unifi_priv_t *priv,
62 netInterface_priv_t *interfacePriv,
63 ba_session_rx_struct *ba_session);
64static void process_ba_frame(unifi_priv_t *priv,
65 netInterface_priv_t *interfacePriv,
66 ba_session_rx_struct *ba_session,
67 frame_desc_struct *frame_desc);
68static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv);
69static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata);
70static void process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata);
71static int uf_net_open(struct net_device *dev);
72static int uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
73static int uf_net_stop(struct net_device *dev);
74static struct net_device_stats *uf_net_get_stats(struct net_device *dev);
75static u16 uf_net_select_queue(struct net_device *dev, struct sk_buff *skb);
76static netdev_tx_t uf_net_xmit(struct sk_buff *skb, struct net_device *dev);
77static void uf_set_multicast_list(struct net_device *dev);
78
79
80typedef int (*tx_signal_handler)(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority);
81
82#ifdef CONFIG_NET_SCHED
83/*
84 * Queueing Discipline Interface
85 * Only used if kernel is configured with CONFIG_NET_SCHED
86 */
87
88/*
89 * The driver uses the qdisc interface to buffer and control all
90 * outgoing traffic. We create a root qdisc, register our qdisc operations
91 * and later we create two subsidiary pfifo queues for the uncontrolled
92 * and controlled ports.
93 *
94 * The network stack delivers all outgoing packets in our enqueue handler.
95 * There, we classify the packet and decide whether to store it or drop it
96 * (if the controlled port state is set to "discard").
97 * If the packet is enqueued, the network stack call our dequeue handler.
98 * There, we decide whether we can send the packet, delay it or drop it
99 * (the controlled port configuration might have changed meanwhile).
100 * If a packet is dequeued, then the network stack calls our hard_start_xmit
101 * handler where finally we send the packet.
102 *
103 * If the hard_start_xmit handler fails to send the packet, we return
104 * NETDEV_TX_BUSY and the network stack call our requeue handler where
105 * we put the packet back in the same queue in came from.
106 *
107 */
108
109struct uf_sched_data
110{
111 /* Traffic Classifier TBD */
112 struct tcf_proto *filter_list;
113 /* Our two queues */
114 struct Qdisc *queues[UNIFI_TRAFFIC_Q_MAX];
115};
116
117struct uf_tx_packet_data {
118 /* Queue the packet is stored in */
119 unifi_TrafficQueue queue;
120 /* QoS Priority determined when enqueing packet */
121 CSR_PRIORITY priority;
122 /* Debug */
123 unsigned long host_tag;
124};
125
126#endif /* CONFIG_NET_SCHED */
127
128static const struct net_device_ops uf_netdev_ops =
129{
130 .ndo_open = uf_net_open,
131 .ndo_stop = uf_net_stop,
132 .ndo_start_xmit = uf_net_xmit,
133 .ndo_do_ioctl = uf_net_ioctl,
134 .ndo_get_stats = uf_net_get_stats, /* called by /proc/net/dev */
135 .ndo_set_rx_mode = uf_set_multicast_list,
136 .ndo_select_queue = uf_net_select_queue,
137};
138
139static u8 oui_rfc1042[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
140static u8 oui_8021h[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
141
142
143/* Callback for event logging to blocking clients */
144static void netdev_mlme_event_handler(ul_client_t *client,
145 const u8 *sig_packed, int sig_len,
146 const bulk_data_param_t *bulkdata,
147 int dir);
148
149#ifdef CSR_SUPPORT_WEXT
150/* Declare netdev_notifier block which will contain the state change
151 * handler callback function
152 */
153static struct notifier_block uf_netdev_notifier;
154#endif
155
156/*
157 * ---------------------------------------------------------------------------
158 * uf_alloc_netdevice
159 *
160 * Allocate memory for the net_device and device private structs
161 * for this interface.
162 * Fill in the fields, but don't register the interface yet.
163 * We need to configure the UniFi first.
164 *
165 * Arguments:
166 * sdio_dev Pointer to SDIO context handle to use for all
167 * SDIO ops.
168 * bus_id A small number indicating the SDIO card position on the
169 * bus. Typically this is the slot number, e.g. 0, 1 etc.
170 * Valid values are 0 to MAX_UNIFI_DEVS-1.
171 *
172 * Returns:
173 * Pointer to device private struct.
174 *
175 * Notes:
176 * The net_device and device private structs are allocated together
177 * and should be freed by freeing the net_device pointer.
178 * ---------------------------------------------------------------------------
179 */
180unifi_priv_t *
181uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id)
182{
183 struct net_device *dev;
184 unifi_priv_t *priv;
185 netInterface_priv_t *interfacePriv;
186#ifdef CSR_SUPPORT_WEXT
187 int rc;
188#endif
189 unsigned char i; /* loop index */
190
191 /*
192 * Allocate netdevice struct, assign name template and
193 * setup as an ethernet device.
194 * The net_device and private structs are zeroed. Ether_setup() then
195 * sets up ethernet handlers and values.
196 * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices,
197 * so use "eth*" (like other wireless extns drivers).
198 */
199 dev = alloc_etherdev_mq(sizeof(unifi_priv_t) + sizeof(netInterface_priv_t), UNIFI_TRAFFIC_Q_MAX);
200
201 if (dev == NULL) {
202 return NULL;
203 }
204
205 /* Set up back pointer from priv to netdev */
206 interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
207 priv = (unifi_priv_t *)(interfacePriv + 1);
208 interfacePriv->privPtr = priv;
209 interfacePriv->InterfaceTag = 0;
210
211
212 /* Initialize all supported netdev interface to be NULL */
213 for(i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
214 priv->netdev[i] = NULL;
215 priv->interfacePriv[i] = NULL;
216 }
217 priv->netdev[0] = dev;
218 priv->interfacePriv[0] = interfacePriv;
219
220 /* Setup / override net_device fields */
221 dev->netdev_ops = &uf_netdev_ops;
222
223#ifdef CSR_SUPPORT_WEXT
224 dev->wireless_handlers = &unifi_iw_handler_def;
225#if IW_HANDLER_VERSION < 6
226 dev->get_wireless_stats = unifi_get_wireless_stats;
227#endif /* IW_HANDLER_VERSION */
228#endif /* CSR_SUPPORT_WEXT */
229
230 /* This gives us enough headroom to add the 802.11 header */
231 dev->needed_headroom = 32;
232
233 /* Use bus_id as instance number */
234 priv->instance = bus_id;
235 /* Store SDIO pointer to pass in the core */
236 priv->sdio = sdio_dev;
237
238 sdio_dev->driverData = (void*)priv;
239 /* Consider UniFi to be uninitialised */
240 priv->init_progress = UNIFI_INIT_NONE;
241
242 priv->prev_queue = 0;
243
244 /*
245 * Initialise the clients structure array.
246 * We do not need protection around ul_init_clients() because
247 * the character device can not be used until uf_alloc_netdevice()
248 * returns and Unifi_instances[bus_id]=priv is set, since unifi_open()
249 * will return -ENODEV.
250 */
251 ul_init_clients(priv);
252
253 /*
254 * Register a new ul client to send the multicast list signals.
255 * Note: priv->instance must be set before calling this.
256 */
257 priv->netdev_client = ul_register_client(priv,
258 0,
259 netdev_mlme_event_handler);
260 if (priv->netdev_client == NULL) {
261 unifi_error(priv,
262 "Failed to register a unifi client for background netdev processing\n");
263 free_netdev(priv->netdev[0]);
264 return NULL;
265 }
266 unifi_trace(priv, UDBG2, "Netdev %p client (id:%d s:0x%X) is registered\n",
267 dev, priv->netdev_client->client_id, priv->netdev_client->sender_id);
268
269 priv->sta_wmm_capabilities = 0;
270
271#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_SUPPORT_SME))
272 priv->wapi_multicast_filter = 0;
273 priv->wapi_unicast_filter = 0;
274 priv->wapi_unicast_queued_pkt_filter = 0;
275#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
276 priv->isWapiConnection = FALSE;
277#endif
278#endif
279
280 /* Enable all queues by default */
281 interfacePriv->queueEnabled[0] = 1;
282 interfacePriv->queueEnabled[1] = 1;
283 interfacePriv->queueEnabled[2] = 1;
284 interfacePriv->queueEnabled[3] = 1;
285
286#ifdef CSR_SUPPORT_SME
287 priv->allPeerDozing = 0;
288#endif
289 /*
290 * Initialise the OS private struct.
291 */
292 /*
293 * Instead of deciding in advance to use 11bg or 11a, we could do a more
294 * clever scan on both radios.
295 */
296 if (use_5g) {
297 priv->if_index = CSR_INDEX_5G;
298 unifi_info(priv, "Using the 802.11a radio\n");
299 } else {
300 priv->if_index = CSR_INDEX_2G4;
301 }
302
303 /* Initialise bh thread structure */
304 priv->bh_thread.thread_task = NULL;
305 priv->bh_thread.block_thread = 1;
306 init_waitqueue_head(&priv->bh_thread.wakeup_q);
307 priv->bh_thread.wakeup_flag = 0;
308 sprintf(priv->bh_thread.name, "uf_bh_thread");
309
310 /* reset the connected state for the interface */
311 interfacePriv->connected = UnifiConnectedUnknown; /* -1 unknown, 0 no, 1 yes */
312
313#ifdef USE_DRIVER_LOCK
314 sema_init(&priv->lock, 1);
315#endif /* USE_DRIVER_LOCK */
316
317 spin_lock_init(&priv->send_signal_lock);
318
319 spin_lock_init(&priv->m4_lock);
320 sema_init(&priv->ba_mutex, 1);
321
322#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
323 spin_lock_init(&priv->wapi_lock);
324#endif
325
326#ifdef CSR_SUPPORT_SME
327 spin_lock_init(&priv->staRecord_lock);
328 spin_lock_init(&priv->tx_q_lock);
329#endif
330
331 /* Create the Traffic Analysis workqueue */
332 priv->unifi_workqueue = create_singlethread_workqueue("unifi_workq");
333 if (priv->unifi_workqueue == NULL) {
334 /* Deregister priv->netdev_client */
335 ul_deregister_client(priv->netdev_client);
336 free_netdev(priv->netdev[0]);
337 return NULL;
338 }
339
340#ifdef CSR_SUPPORT_SME
341 /* Create the Multicast Addresses list work structure */
342 INIT_WORK(&priv->multicast_list_task, uf_multicast_list_wq);
343
344 /* Create m4 buffering work structure */
345 INIT_WORK(&interfacePriv->send_m4_ready_task, uf_send_m4_ready_wq);
346
347#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
348 /* Create work structure to buffer the WAPI data packets to be sent to SME for encryption */
349 INIT_WORK(&interfacePriv->send_pkt_to_encrypt, uf_send_pkt_to_encrypt);
350#endif
351#endif
352
353 priv->ref_count = 1;
354
355 priv->amp_client = NULL;
356 priv->coredump_mode = 0;
357 priv->ptest_mode = 0;
358 priv->wol_suspend = FALSE;
359 INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list);
360 INIT_LIST_HEAD(&interfacePriv->rx_controlled_list);
361 sema_init(&priv->rx_q_sem, 1);
362
363#ifdef CSR_SUPPORT_WEXT
364 interfacePriv->netdev_callback_registered = FALSE;
365 interfacePriv->wait_netdev_change = FALSE;
366 /* Register callback for netdevice state changes */
367 if ((rc = register_netdevice_notifier(&uf_netdev_notifier)) == 0) {
368 interfacePriv->netdev_callback_registered = TRUE;
369 }
370 else {
371 unifi_warning(priv, "Failed to register netdevice notifier : %d %p\n", rc, dev);
372 }
373#endif /* CSR_SUPPORT_WEXT */
374
375#ifdef CSR_WIFI_SPLIT_PATCH
376 /* set it to some invalid value */
377 priv->pending_mode_set.common.destination = 0xaaaa;
378#endif
379
380 return priv;
381} /* uf_alloc_netdevice() */
382
383/*
384 *---------------------------------------------------------------------------
385 * uf_alloc_netdevice_for_other_interfaces
386 *
387 * Allocate memory for the net_device and device private structs
388 * for this interface.
389 * Fill in the fields, but don't register the interface yet.
390 * We need to configure the UniFi first.
391 *
392 * Arguments:
393 * interfaceTag Interface number.
394 * sdio_dev Pointer to SDIO context handle to use for all
395 * SDIO ops.
396 * bus_id A small number indicating the SDIO card position on the
397 * bus. Typically this is the slot number, e.g. 0, 1 etc.
398 * Valid values are 0 to MAX_UNIFI_DEVS-1.
399 *
400 * Returns:
401 * Pointer to device private struct.
402 *
403 * Notes:
404 * The device private structure contains the interfaceTag and pointer to the unifi_priv
405 * structure created allocated by net_device od interface0.
406 * The net_device and device private structs are allocated together
407 * and should be freed by freeing the net_device pointer.
408 * ---------------------------------------------------------------------------
409 */
410u8
411uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag)
412{
413 struct net_device *dev;
414 netInterface_priv_t *interfacePriv;
415
416 /*
417 * Allocate netdevice struct, assign name template and
418 * setup as an ethernet device.
419 * The net_device and private structs are zeroed. Ether_setup() then
420 * sets up ethernet handlers and values.
421 * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices,
422 * so use "eth*" (like other wireless extns drivers).
423 */
424 dev = alloc_etherdev_mq(sizeof(netInterface_priv_t), 1);
425 if (dev == NULL) {
426 return FALSE;
427 }
428
429 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
430 unifi_error(priv, "uf_alloc_netdevice_for_other_interfaces bad interfaceTag\n");
431 return FALSE;
432 }
433
434 /* Set up back pointer from priv to netdev */
435 interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
436 interfacePriv->privPtr = priv;
437 interfacePriv->InterfaceTag = interfaceTag;
438 priv->netdev[interfaceTag] = dev;
439 priv->interfacePriv[interfacePriv->InterfaceTag] = interfacePriv;
440
441 /* reset the connected state for the interface */
442 interfacePriv->connected = UnifiConnectedUnknown; /* -1 unknown, 0 no, 1 yes */
443 INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list);
444 INIT_LIST_HEAD(&interfacePriv->rx_controlled_list);
445
446 /* Setup / override net_device fields */
447 dev->netdev_ops = &uf_netdev_ops;
448
449#ifdef CSR_SUPPORT_WEXT
450 dev->wireless_handlers = &unifi_iw_handler_def;
451#if IW_HANDLER_VERSION < 6
452 dev->get_wireless_stats = unifi_get_wireless_stats;
453#endif /* IW_HANDLER_VERSION */
454#endif /* CSR_SUPPORT_WEXT */
455 return TRUE;
456} /* uf_alloc_netdevice() */
457
458
459
460/*
461 * ---------------------------------------------------------------------------
462 * uf_free_netdevice
463 *
464 * Unregister the network device and free the memory allocated for it.
465 * NB This includes the memory for the priv struct.
466 *
467 * Arguments:
468 * priv Device private pointer.
469 *
470 * Returns:
471 * None.
472 * ---------------------------------------------------------------------------
473 */
474int
475uf_free_netdevice(unifi_priv_t *priv)
476{
477 int i;
478 unsigned long flags;
479
480 unifi_trace(priv, UDBG1, "uf_free_netdevice\n");
481
482 if (!priv) {
483 return -EINVAL;
484 }
485
486 /*
487 * Free any buffers used for holding firmware
488 */
489 uf_release_firmware_files(priv);
490
491#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
492 if (priv->connection_config.mlmeAssociateReqInformationElements) {
493 kfree(priv->connection_config.mlmeAssociateReqInformationElements);
494 }
495 priv->connection_config.mlmeAssociateReqInformationElements = NULL;
496 priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
497
498 if (priv->mib_data.length) {
499 vfree(priv->mib_data.data);
500 }
501 priv->mib_data.data = NULL;
502 priv->mib_data.length = 0;
503
504#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/
505
506 /* Free any bulkdata buffers allocated for M4 caching */
507 spin_lock_irqsave(&priv->m4_lock, flags);
508 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
509 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
510 if (interfacePriv->m4_bulk_data.data_length > 0) {
511 unifi_trace(priv, UDBG5, "uf_free_netdevice: free M4 bulkdata %d\n", i);
512 unifi_net_data_free(priv, &interfacePriv->m4_bulk_data);
513 }
514 }
515 spin_unlock_irqrestore(&priv->m4_lock, flags);
516
517#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
518 /* Free any bulkdata buffers allocated for M4 caching */
519 spin_lock_irqsave(&priv->wapi_lock, flags);
520 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
521 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
522 if (interfacePriv->wapi_unicast_bulk_data.data_length > 0) {
523 unifi_trace(priv, UDBG5, "uf_free_netdevice: free WAPI PKT bulk data %d\n", i);
524 unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
525 }
526 }
527 spin_unlock_irqrestore(&priv->wapi_lock, flags);
528#endif
529
530#ifdef CSR_SUPPORT_WEXT
531 /* Unregister callback for netdevice state changes */
532 unregister_netdevice_notifier(&uf_netdev_notifier);
533#endif /* CSR_SUPPORT_WEXT */
534
535#ifdef CSR_SUPPORT_SME
536 /* Cancel work items and destroy the workqueue */
537 cancel_work_sync(&priv->multicast_list_task);
538#endif
539/* Destroy the workqueues. */
540 flush_workqueue(priv->unifi_workqueue);
541 destroy_workqueue(priv->unifi_workqueue);
542
543 /* Free up netdev in reverse order: priv is allocated with netdev[0].
544 * So, netdev[0] should be freed after all other netdevs are freed up
545 */
546 for (i=CSR_WIFI_NUM_INTERFACES-1; i>=0; i--) {
547 /*Free the netdev struct and priv, which are all one lump*/
548 if (priv->netdev[i]) {
549 unifi_error(priv, "uf_free_netdevice: netdev %d %p\n", i, priv->netdev[i]);
550 free_netdev(priv->netdev[i]);
551 }
552 }
553
554 return 0;
555} /* uf_free_netdevice() */
556
557
558/*
559 * ---------------------------------------------------------------------------
560 * uf_net_open
561 *
562 * Called when userland does "ifconfig wlan0 up".
563 *
564 * Arguments:
565 * dev Device pointer.
566 *
567 * Returns:
568 * None.
569 * ---------------------------------------------------------------------------
570 */
571static int
572uf_net_open(struct net_device *dev)
573{
574 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
575 unifi_priv_t *priv = interfacePriv->privPtr;
576
577 /* If we haven't finished UniFi initialisation, we can't start */
578 if (priv->init_progress != UNIFI_INIT_COMPLETED) {
579 unifi_warning(priv, "%s: unifi not ready, failing net_open\n", __FUNCTION__);
580 return -EINVAL;
581 }
582
583#if (defined CSR_NATIVE_LINUX) && (defined UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT)
584 /*
585 * To sniff, the user must do "iwconfig mode monitor", which sets
586 * priv->wext_conf.mode to IW_MODE_MONITOR.
587 * Then he/she must do "ifconfig ethn up", which calls this fn.
588 * There is no point in starting the sniff with SNIFFJOIN until
589 * this point.
590 */
591 if (priv->wext_conf.mode == IW_MODE_MONITOR) {
592 int err;
593 err = uf_start_sniff(priv);
594 if (err) {
595 return err;
596 }
597 netif_carrier_on(dev);
598 }
599#endif
600
601#ifdef CSR_SUPPORT_WEXT
602 if (interfacePriv->wait_netdev_change) {
603 unifi_trace(priv, UDBG1, "%s: Waiting for NETDEV_CHANGE, assume connected\n",
604 __FUNCTION__);
605 interfacePriv->connected = UnifiConnected;
606 interfacePriv->wait_netdev_change = FALSE;
607 }
608#endif
609
610 netif_tx_start_all_queues(dev);
611
612 return 0;
613} /* uf_net_open() */
614
615
616static int
617uf_net_stop(struct net_device *dev)
618{
619#if defined(CSR_NATIVE_LINUX) && defined(UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT)
620 netInterface_priv_t *interfacePriv = (netInterface_priv_t*)netdev_priv(dev);
621 unifi_priv_t *priv = interfacePriv->privPtr;
622
623 /* Stop sniffing if in Monitor mode */
624 if (priv->wext_conf.mode == IW_MODE_MONITOR) {
625 if (priv->card) {
626 int err;
627 err = unifi_reset_state(priv, dev->dev_addr, 1);
628 if (err) {
629 return err;
630 }
631 }
632 }
633#endif
634
635 netif_tx_stop_all_queues(dev);
636
637 return 0;
638} /* uf_net_stop() */
639
640
641/* This is called after the WE handlers */
642static int
643uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
644{
645 int rc;
646
647 rc = -EOPNOTSUPP;
648
649 return rc;
650} /* uf_net_ioctl() */
651
652
653
654static struct net_device_stats *
655uf_net_get_stats(struct net_device *dev)
656{
657 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
658
659 return &interfacePriv->stats;
660} /* uf_net_get_stats() */
661
662static CSR_PRIORITY uf_get_packet_priority(unifi_priv_t *priv, netInterface_priv_t *interfacePriv, struct sk_buff *skb, const int proto)
663{
664 CSR_PRIORITY priority = CSR_CONTENTION;
665
666 priority = (CSR_PRIORITY) (skb->priority >> 5);
667
668 if (priority == CSR_QOS_UP0) { /* 0 */
669
670 unifi_trace(priv, UDBG5, "uf_get_packet_priority: proto = 0x%.4X\n", proto);
671
672 switch (proto) {
673 case 0x0800: /* IPv4 */
674 case 0x814C: /* SNMP */
675 case 0x880C: /* GSMP */
676 priority = (CSR_PRIORITY) (skb->data[1 + ETH_HLEN] >> 5);
677 break;
678
679 case 0x8100: /* VLAN */
680 priority = (CSR_PRIORITY) (skb->data[0 + ETH_HLEN] >> 5);
681 break;
682
683 case 0x86DD: /* IPv6 */
684 priority = (CSR_PRIORITY) ((skb->data[0 + ETH_HLEN] & 0x0E) >> 1);
685 break;
686
687 default:
688 priority = CSR_QOS_UP0;
689 break;
690 }
691 }
692
693 /* Check if we are allowed to transmit on this AC. Because of ACM we may have to downgrade to a lower
694 * priority */
695 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA ||
696 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) {
697 unifi_TrafficQueue queue;
698
699 /* Keep trying lower priorities until we find a queue
700 * Priority to queue mapping is 1,2 - BK, 0,3 - BE, 4,5 - VI, 6,7 - VO */
701 queue = unifi_frame_priority_to_queue(priority);
702
703 while (queue > UNIFI_TRAFFIC_Q_BK && !interfacePriv->queueEnabled[queue]) {
704 queue--;
705 priority = unifi_get_default_downgrade_priority(queue);
706 }
707 }
708
709 unifi_trace(priv, UDBG5, "Packet priority = %d\n", priority);
710
711 return priority;
712}
713
714/*
715 */
716/*
717 * ---------------------------------------------------------------------------
718 * get_packet_priority
719 *
720 * Arguments:
721 * priv private data area of functional driver
722 * skb socket buffer
723 * ehdr ethernet header to fetch protocol
724 * interfacePriv For accessing station record database
725 *
726 *
727 * Returns:
728 * CSR_PRIORITY.
729 * ---------------------------------------------------------------------------
730 */
731CSR_PRIORITY
732get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv)
733{
734 CSR_PRIORITY priority = CSR_CONTENTION;
735 const int proto = ntohs(ehdr->h_proto);
736
737 u8 interfaceMode = interfacePriv->interfaceMode;
738
739 /* Priority Mapping for all the Modes */
740 switch(interfaceMode)
741 {
742 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
743 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
744 unifi_trace(priv, UDBG4, "mode is STA \n");
745 if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1) {
746 priority = uf_get_packet_priority(priv, interfacePriv, skb, proto);
747 } else {
748 priority = CSR_CONTENTION;
749 }
750 break;
751#ifdef CSR_SUPPORT_SME
752 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
753 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
754 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
755 {
756 CsrWifiRouterCtrlStaInfo_t * dstStaInfo =
757 CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfacePriv->InterfaceTag);
758 unifi_trace(priv, UDBG4, "mode is AP \n");
759 if (!(ehdr->h_dest[0] & 0x01) && dstStaInfo && dstStaInfo->wmmOrQosEnabled) {
760 /* If packet is not Broadcast/multicast */
761 priority = uf_get_packet_priority(priv, interfacePriv, skb, proto);
762 } else {
763 /* Since packet destination is not QSTA, set priority to CSR_CONTENTION */
764 unifi_trace(priv, UDBG4, "Destination is not QSTA or BroadCast/Multicast\n");
765 priority = CSR_CONTENTION;
766 }
767 }
768 break;
769#endif
770 default:
771 unifi_trace(priv, UDBG3, " mode unknown in %s func, mode=%x\n", __FUNCTION__, interfaceMode);
772 }
773 unifi_trace(priv, UDBG5, "priority = %x\n", priority);
774
775 return priority;
776}
777
778/*
779 * ---------------------------------------------------------------------------
780 * uf_net_select_queue
781 *
782 * Called by the kernel to select which queue to put the packet in
783 *
784 * Arguments:
785 * dev Device pointer
786 * skb Packet
787 *
788 * Returns:
789 * Queue index
790 * ---------------------------------------------------------------------------
791 */
792static u16
793uf_net_select_queue(struct net_device *dev, struct sk_buff *skb)
794{
795 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
796 unifi_priv_t *priv = (unifi_priv_t *)interfacePriv->privPtr;
797 struct ethhdr ehdr;
798 unifi_TrafficQueue queue;
799 int proto;
800 CSR_PRIORITY priority;
801
802 memcpy(&ehdr, skb->data, ETH_HLEN);
803 proto = ntohs(ehdr.h_proto);
804
805 /* 802.1x - apply controlled/uncontrolled port rules */
806 if ((proto != ETH_P_PAE)
807#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
808 && (proto != ETH_P_WAI)
809#endif
810 ) {
811 /* queues 0 - 3 */
812 priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
813 queue = unifi_frame_priority_to_queue(priority);
814 } else {
815 /* queue 4 */
816 queue = UNIFI_TRAFFIC_Q_EAPOL;
817 }
818
819
820 return (u16)queue;
821} /* uf_net_select_queue() */
822
823int
824skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto)
825{
826 llc_snap_hdr_t *snap;
827 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
828 unifi_priv_t *priv = interfacePriv->privPtr;
829 int headroom;
830
831 /* get the headroom available in skb */
832 headroom = skb_headroom(skb);
833 /* step 1: classify ether frame, DIX or 802.3? */
834
835 if (proto < 0x600) {
836 /* codes <= 1500 reserved for 802.3 lengths */
837 /* it's 802.3, pass ether payload unchanged, */
838 unifi_trace(priv, UDBG3, "802.3 len: %d\n", skb->len);
839
840 /* leave off any PAD octets. */
841 skb_trim(skb, proto);
842 } else if (proto == ETH_P_8021Q) {
843
844 /* Store the VLAN SNAP (should be 87-65). */
845 u16 vlan_snap = *(u16*)skb->data;
846 /* check for headroom availability before skb_push 14 = (4 + 10) */
847 if (headroom < 14) {
848 unifi_trace(priv, UDBG3, "cant append vlan snap: debug\n");
849 return -1;
850 }
851 /* Add AA-AA-03-00-00-00 */
852 snap = (llc_snap_hdr_t *)skb_push(skb, 4);
853 snap->dsap = snap->ssap = 0xAA;
854 snap->ctrl = 0x03;
855 memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
856
857 /* Add AA-AA-03-00-00-00 */
858 snap = (llc_snap_hdr_t *)skb_push(skb, 10);
859 snap->dsap = snap->ssap = 0xAA;
860 snap->ctrl = 0x03;
861 memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
862
863 /* Add the VLAN specific information */
864 snap->protocol = htons(proto);
865 *(u16*)(snap + 1) = vlan_snap;
866
867 } else
868 {
869 /* it's DIXII, time for some conversion */
870 unifi_trace(priv, UDBG3, "DIXII len: %d\n", skb->len);
871
872 /* check for headroom availability before skb_push */
873 if (headroom < sizeof(llc_snap_hdr_t)) {
874 unifi_trace(priv, UDBG3, "cant append snap: debug\n");
875 return -1;
876 }
877 /* tack on SNAP */
878 snap = (llc_snap_hdr_t *)skb_push(skb, sizeof(llc_snap_hdr_t));
879 snap->dsap = snap->ssap = 0xAA;
880 snap->ctrl = 0x03;
881 /* Use the appropriate OUI. */
882 if ((proto == ETH_P_AARP) || (proto == ETH_P_IPX)) {
883 memcpy(snap->oui, oui_8021h, P80211_OUI_LEN);
884 } else {
885 memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
886 }
887 snap->protocol = htons(proto);
888 }
889
890 return 0;
891} /* skb_add_llc_snap() */
892
893#ifdef CSR_SUPPORT_SME
894static int
895_identify_sme_ma_pkt_ind(unifi_priv_t *priv,
896 const s8 *oui, u16 protocol,
897 const CSR_SIGNAL *signal,
898 bulk_data_param_t *bulkdata,
899 const unsigned char *daddr,
900 const unsigned char *saddr)
901{
902 CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication;
903 int r;
904 u8 i;
905
906 unifi_trace(priv, UDBG5,
907 "_identify_sme_ma_pkt_ind -->\n");
908 for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
909 if (priv->sme_unidata_ind_filters[i].in_use) {
910 if (!memcmp(oui, priv->sme_unidata_ind_filters[i].oui, 3) &&
911 (protocol == priv->sme_unidata_ind_filters[i].protocol)) {
912
913 /* Send to client */
914 if (priv->sme_cli) {
915 /*
916 * Pass the packet to the SME, using unifi_sys_ma_unitdata_ind().
917 * The frame needs to be converted according to the encapsulation.
918 */
919 unifi_trace(priv, UDBG1,
920 "_identify_sme_ma_pkt_ind: handle=%d, encap=%d, proto=%x\n",
921 i, priv->sme_unidata_ind_filters[i].encapsulation,
922 priv->sme_unidata_ind_filters[i].protocol);
923 if (priv->sme_unidata_ind_filters[i].encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) {
924 struct sk_buff *skb;
925 /* The translation is performed on skb... */
926 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
927 skb->len = bulkdata->d[0].data_length;
928
929 unifi_trace(priv, UDBG1,
930 "_identify_sme_ma_pkt_ind: skb_80211_to_ether -->\n");
931 r = skb_80211_to_ether(priv, skb, daddr, saddr,
932 signal, bulkdata);
933 unifi_trace(priv, UDBG1,
934 "_identify_sme_ma_pkt_ind: skb_80211_to_ether <--\n");
935 if (r) {
936 return -EINVAL;
937 }
938
939 /* ... but we indicate buffer and length */
940 bulkdata->d[0].os_data_ptr = skb->data;
941 bulkdata->d[0].data_length = skb->len;
942 } else {
943 /* Add the MAC addresses before the SNAP */
944 bulkdata->d[0].os_data_ptr -= 2*ETH_ALEN;
945 bulkdata->d[0].data_length += 2*ETH_ALEN;
946 memcpy((void*)bulkdata->d[0].os_data_ptr, daddr, ETH_ALEN);
947 memcpy((void*)bulkdata->d[0].os_data_ptr + ETH_ALEN, saddr, ETH_ALEN);
948 }
949
950 unifi_trace(priv, UDBG1,
951 "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind -->\n");
952 CsrWifiRouterMaPacketIndSend(priv->sme_unidata_ind_filters[i].appHandle,
953 (pkt_ind->VirtualInterfaceIdentifier & 0xff),
954 i,
955 pkt_ind->ReceptionStatus,
956 bulkdata->d[0].data_length,
957 (u8*)bulkdata->d[0].os_data_ptr,
958 NULL,
959 pkt_ind->Rssi,
960 pkt_ind->Snr,
961 pkt_ind->ReceivedRate);
962
963
964 unifi_trace(priv, UDBG1,
965 "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind <--\n");
966 }
967
968 return 1;
969 }
970 }
971 }
972
973 return -1;
974}
975#endif /* CSR_SUPPORT_SME */
976
977/*
978 * ---------------------------------------------------------------------------
979 * skb_80211_to_ether
980 *
981 * Make sure the received frame is in Ethernet (802.3) form.
982 * De-encapsulates SNAP if necessary, adds a ethernet header.
983 * The source buffer should not contain an 802.11 MAC header
984 *
985 * Arguments:
986 * payload Pointer to packet data received from UniFi.
987 * payload_length Number of bytes of data received from UniFi.
988 * daddr Destination MAC address.
989 * saddr Source MAC address.
990 *
991 * Returns:
992 * 0 on success, -1 if the packet is bad and should be dropped,
993 * 1 if the packet was forwarded to the SME or AMP client.
994 * ---------------------------------------------------------------------------
995 */
996int
997skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
998 const unsigned char *daddr, const unsigned char *saddr,
999 const CSR_SIGNAL *signal,
1000 bulk_data_param_t *bulkdata)
1001{
1002 unsigned char *payload;
1003 int payload_length;
1004 struct ethhdr *eth;
1005 llc_snap_hdr_t *snap;
1006 int headroom;
1007#define UF_VLAN_LLC_HEADER_SIZE 18
1008 static const u8 vlan_inner_snap[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
1009#if defined(CSR_NATIVE_SOFTMAC) && defined(CSR_SUPPORT_SME)
1010 const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
1011#endif
1012
1013 if(skb== NULL || daddr == NULL || saddr == NULL){
1014 unifi_error(priv, "skb_80211_to_ether: PBC fail\n");
1015 return 1;
1016 }
1017
1018 payload = skb->data;
1019 payload_length = skb->len;
1020
1021 snap = (llc_snap_hdr_t *)payload;
1022 eth = (struct ethhdr *)payload;
1023
1024 /* get the skb headroom size */
1025 headroom = skb_headroom(skb);
1026
1027 /*
1028 * Test for the various encodings
1029 */
1030 if ((payload_length >= sizeof(llc_snap_hdr_t)) &&
1031 (snap->dsap == 0xAA) &&
1032 (snap->ssap == 0xAA) &&
1033 (snap->ctrl == 0x03) &&
1034 (snap->oui[0] == 0) &&
1035 (snap->oui[1] == 0) &&
1036 ((snap->oui[2] == 0) || (snap->oui[2] == 0xF8)))
1037 {
1038 /* AppleTalk AARP (2) or IPX SNAP */
1039 if ((snap->oui[2] == 0) &&
1040 ((ntohs(snap->protocol) == ETH_P_AARP) || (ntohs(snap->protocol) == ETH_P_IPX)))
1041 {
1042 u16 len;
1043
1044 unifi_trace(priv, UDBG3, "%s len: %d\n",
1045 (ntohs(snap->protocol) == ETH_P_AARP) ? "ETH_P_AARP" : "ETH_P_IPX",
1046 payload_length);
1047
1048 /* check for headroom availability before skb_push */
1049 if (headroom < (2 * ETH_ALEN + 2)) {
1050 unifi_warning(priv, "headroom not available to skb_push ether header\n");
1051 return -1;
1052 }
1053
1054 /* Add 802.3 header and leave full payload */
1055 len = htons(skb->len);
1056 memcpy(skb_push(skb, 2), &len, 2);
1057 memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN);
1058 memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN);
1059
1060 return 0;
1061 }
1062 /* VLAN-tagged IP */
1063 if ((snap->oui[2] == 0) && (ntohs(snap->protocol) == ETH_P_8021Q))
1064 {
1065 /*
1066 * The translation doesn't change the packet length, so is done in-place.
1067 *
1068 * Example header (from Std 802.11-2007 Annex M):
1069 * AA-AA-03-00-00-00-81-00-87-65-AA-AA-03-00-00-00-08-06
1070 * -------SNAP-------p1-p1-ll-ll-------SNAP--------p2-p2
1071 * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-p1-p1-ll-ll-p2-p2
1072 * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-81-00-87-65-08-06
1073 */
1074 u16 vlan_snap;
1075
1076 if (payload_length < UF_VLAN_LLC_HEADER_SIZE) {
1077 unifi_warning(priv, "VLAN SNAP header too short: %d bytes\n", payload_length);
1078 return -1;
1079 }
1080
1081 if (memcmp(payload + 10, vlan_inner_snap, 6)) {
1082 unifi_warning(priv, "VLAN malformatted SNAP header.\n");
1083 return -1;
1084 }
1085
1086 unifi_trace(priv, UDBG3, "VLAN SNAP: %02x-%02x\n", payload[8], payload[9]);
1087 unifi_trace(priv, UDBG3, "VLAN len: %d\n", payload_length);
1088
1089 /* Create the 802.3 header */
1090
1091 vlan_snap = *((u16*)(payload + 8));
1092
1093 /* Create LLC header without byte-swapping */
1094 eth->h_proto = snap->protocol;
1095
1096 memcpy(eth->h_dest, daddr, ETH_ALEN);
1097 memcpy(eth->h_source, saddr, ETH_ALEN);
1098 *(u16*)(eth + 1) = vlan_snap;
1099 return 0;
1100 }
1101
1102 /* it's a SNAP + RFC1042 frame */
1103 unifi_trace(priv, UDBG3, "SNAP+RFC1042 len: %d\n", payload_length);
1104
1105 /* chop SNAP+llc header from skb. */
1106 skb_pull(skb, sizeof(llc_snap_hdr_t));
1107
1108 /* Since skb_pull called above to chop snap+llc, no need to check for headroom
1109 * availability before skb_push
1110 */
1111 /* create 802.3 header at beginning of skb. */
1112 eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
1113 memcpy(eth->h_dest, daddr, ETH_ALEN);
1114 memcpy(eth->h_source, saddr, ETH_ALEN);
1115 /* Copy protocol field without byte-swapping */
1116 eth->h_proto = snap->protocol;
1117 } else {
1118 u16 len;
1119
1120 /* check for headroom availability before skb_push */
1121 if (headroom < (2 * ETH_ALEN + 2)) {
1122 unifi_warning(priv, "headroom not available to skb_push ether header\n");
1123 return -1;
1124 }
1125 /* Add 802.3 header and leave full payload */
1126 len = htons(skb->len);
1127 memcpy(skb_push(skb, 2), &len, 2);
1128 memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN);
1129 memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN);
1130
1131 return 1;
1132 }
1133
1134 return 0;
1135} /* skb_80211_to_ether() */
1136
1137
1138static CsrWifiRouterCtrlPortAction verify_port(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
1139{
1140#ifdef CSR_NATIVE_LINUX
1141#ifdef CSR_SUPPORT_WEXT
1142 if (queue == UF_CONTROLLED_PORT_Q) {
1143 return priv->wext_conf.block_controlled_port;
1144 } else {
1145 return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
1146 }
1147#else
1148 return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN; /* default to open for softmac dev */
1149#endif
1150#else
1151 return uf_sme_port_state(priv, address, queue, interfaceTag);
1152#endif
1153}
1154
1155/*
1156 * ---------------------------------------------------------------------------
1157 * prepare_and_add_macheader
1158 *
1159 *
1160 * These functions adds mac header for packet from netdev
1161 * to UniFi for transmission.
1162 * EAP protocol packets are also appended with Mac header &
1163 * sent using send_ma_pkt_request().
1164 *
1165 * Arguments:
1166 * priv Pointer to device private context struct
1167 * skb Socket buffer containing data packet to transmit
1168 * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb
1169 * serviceClass to append QOS control header in Mac header
1170 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1171 * interfaceTag the interfaceID on which activity going on
1172 * daddr destination address
1173 * saddr source address
1174 * protection protection bit set in framce control of mac header
1175 *
1176 * Returns:
1177 * Zero on success or error code.
1178 * ---------------------------------------------------------------------------
1179 */
1180
1181int prepare_and_add_macheader(unifi_priv_t *priv, struct sk_buff *skb, struct sk_buff *newSkb,
1182 CSR_PRIORITY priority,
1183 bulk_data_param_t *bulkdata,
1184 u16 interfaceTag,
1185 const u8 *daddr,
1186 const u8 *saddr,
1187 u8 protection)
1188{
1189 u16 fc = 0;
1190 u8 qc = 0;
1191 u8 macHeaderLengthInBytes = MAC_HEADER_SIZE, *bufPtr = NULL;
1192 bulk_data_param_t data_ptrs;
1193 CsrResult csrResult;
1194 int headroom =0;
1195 u8 direction = 0;
1196 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1197 u8 *addressOne;
1198 u8 bQosNull = false;
1199
1200 if (skb == NULL) {
1201 unifi_error(priv, "prepare_and_add_macheader: Invalid SKB reference\n");
1202 return -1;
1203 }
1204
1205 /* add a MAC header refer: 7.1.3.1 Frame Control field in P802.11REVmb.book */
1206 if (priority != CSR_CONTENTION) {
1207 /* EAPOL packets don't go as QOS_DATA */
1208 if (priority == CSR_MANAGEMENT) {
1209 fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
1210 } else {
1211 /* Qos Control Field */
1212 macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
1213
1214 if (skb->len) {
1215
1216 fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
1217 } else {
1218 fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_NULL);
1219 bQosNull = true;
1220 }
1221 }
1222 } else {
1223 if(skb->len == 0) {
1224 fc |= cpu_to_le16(IEEE802_11_FC_TYPE_NULL);
1225 } else {
1226 fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
1227 }
1228 }
1229
1230 switch (interfacePriv->interfaceMode)
1231 {
1232 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1233 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1234 direction = 2;
1235 fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK);
1236 break;
1237 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1238 direction = 0;
1239 break;
1240 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1241 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1242 direction = 1;
1243 fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
1244 break;
1245 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1246 if (priority == CSR_MANAGEMENT ) {
1247
1248 direction = 2;
1249 fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK);
1250 } else {
1251 /* Data frames have to use WDS 4 address frames */
1252 direction = 3;
1253 fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK | IEEE802_11_FC_FROM_DS_MASK);
1254 macHeaderLengthInBytes += 6;
1255 }
1256 break;
1257 default:
1258 unifi_warning(priv, "prepare_and_add_macheader: Unknown mode %d\n",
1259 interfacePriv->interfaceMode);
1260 }
1261
1262
1263 /* If Sta is QOS & HTC is supported then need to set 'order' bit */
1264 /* We don't support HT Control for now */
1265
1266 if(protection) {
1267 fc |= cpu_to_le16(IEEE802_11_FC_PROTECTED_MASK);
1268 }
1269
1270 /* check the skb headroom before pushing mac header */
1271 headroom = skb_headroom(skb);
1272
1273 if (headroom < macHeaderLengthInBytes) {
1274 unifi_trace(priv, UDBG5,
1275 "prepare_and_add_macheader: Allocate headroom extra %d bytes\n",
1276 macHeaderLengthInBytes);
1277
1278 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1279
1280 if (csrResult != CSR_RESULT_SUCCESS) {
1281 unifi_error(priv, " failed to allocate request_data. in %s func\n", __FUNCTION__);
1282 return -1;
1283 }
1284 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1285 newSkb->len = skb->len + macHeaderLengthInBytes;
1286
1287 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1288 skb->data, skb->len);
1289
1290 bulkdata->d[0].os_data_ptr = newSkb->data;
1291 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1292 bulkdata->d[0].data_length = newSkb->len;
1293
1294 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1295
1296 /* The old skb will not be used again */
1297 kfree_skb(skb);
1298 } else {
1299
1300 /* headroom has sufficient size, so will get proper pointer */
1301 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1302 bulkdata->d[0].os_data_ptr = skb->data;
1303 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1304 bulkdata->d[0].data_length = skb->len;
1305 }
1306
1307 /* Frame the actual MAC header */
1308
1309 memset(bufPtr, 0, macHeaderLengthInBytes);
1310
1311 /* copy frameControl field */
1312 memcpy(bufPtr, &fc, sizeof(fc));
1313 bufPtr += sizeof(fc);
1314 macHeaderLengthInBytes -= sizeof(fc);
1315
1316 /* Duration/ID field which is 2 bytes */
1317 bufPtr += 2;
1318 macHeaderLengthInBytes -= 2;
1319
1320 switch(direction)
1321 {
1322 case 0:
1323 /* Its an Ad-Hoc no need to route it through AP */
1324 /* Address1: MAC address of the destination from eth header */
1325 memcpy(bufPtr, daddr, ETH_ALEN);
1326 bufPtr += ETH_ALEN;
1327 macHeaderLengthInBytes -= ETH_ALEN;
1328
1329 /* Address2: MAC address of the source */
1330 memcpy(bufPtr, saddr, ETH_ALEN);
1331 bufPtr += ETH_ALEN;
1332 macHeaderLengthInBytes -= ETH_ALEN;
1333
1334 /* Address3: the BSSID (locally generated in AdHoc (creators Bssid)) */
1335 memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
1336 bufPtr += ETH_ALEN;
1337 macHeaderLengthInBytes -= ETH_ALEN;
1338 break;
1339 case 1:
1340 /* Address1: MAC address of the actual destination */
1341 memcpy(bufPtr, daddr, ETH_ALEN);
1342 bufPtr += ETH_ALEN;
1343 macHeaderLengthInBytes -= ETH_ALEN;
1344 /* Address2: The MAC address of the AP */
1345 memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
1346 bufPtr += ETH_ALEN;
1347 macHeaderLengthInBytes -= ETH_ALEN;
1348
1349 /* Address3: MAC address of the source from eth header */
1350 memcpy(bufPtr, saddr, ETH_ALEN);
1351 bufPtr += ETH_ALEN;
1352 macHeaderLengthInBytes -= ETH_ALEN;
1353 break;
1354 case 2:
1355 /* Address1: To AP is the MAC address of the AP to which its associated */
1356 memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
1357 bufPtr += ETH_ALEN;
1358 macHeaderLengthInBytes -= ETH_ALEN;
1359
1360 /* Address2: MAC address of the source from eth header */
1361 memcpy(bufPtr, saddr, ETH_ALEN);
1362 bufPtr += ETH_ALEN;
1363 macHeaderLengthInBytes -= ETH_ALEN;
1364
1365 /* Address3: MAC address of the actual destination on the distribution system */
1366 memcpy(bufPtr, daddr, ETH_ALEN);
1367 bufPtr += ETH_ALEN;
1368 macHeaderLengthInBytes -= ETH_ALEN;
1369 break;
1370 case 3:
1371 memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
1372 bufPtr += ETH_ALEN;
1373 macHeaderLengthInBytes -= ETH_ALEN;
1374
1375 /* Address2: MAC address of the source from eth header */
1376 memcpy(bufPtr, saddr, ETH_ALEN);
1377 bufPtr += ETH_ALEN;
1378 macHeaderLengthInBytes -= ETH_ALEN;
1379
1380 /* Address3: MAC address of the actual destination on the distribution system */
1381 memcpy(bufPtr, daddr, ETH_ALEN);
1382 bufPtr += ETH_ALEN;
1383 macHeaderLengthInBytes -= ETH_ALEN;
1384 break;
1385 default:
1386 unifi_error(priv, "Unknown direction =%d : Not handled now\n", direction);
1387 return -1;
1388 }
1389 /* 2 bytes of frame control field, appended by firmware */
1390 bufPtr += 2;
1391 macHeaderLengthInBytes -= 2;
1392
1393 if (3 == direction) {
1394 /* Address4: MAC address of the source */
1395 memcpy(bufPtr, saddr, ETH_ALEN);
1396 bufPtr += ETH_ALEN;
1397 macHeaderLengthInBytes -= ETH_ALEN;
1398 }
1399
1400 /* IF Qos Data or Qos Null Data then set QosControl field */
1401 if ((priority != CSR_CONTENTION) && (macHeaderLengthInBytes >= QOS_CONTROL_HEADER_SIZE)) {
1402
1403 if (priority > 7) {
1404 unifi_trace(priv, UDBG1, "data packets priority is more than 7, priority = %x\n", priority);
1405 qc |= 7;
1406 } else {
1407 qc |= priority;
1408 }
1409 /*assigning address1
1410 * Address1 offset taken fromm bufPtr(currently bufPtr pointing to Qos contorl) variable in reverse direction
1411 * Address4 don't exit
1412 */
1413
1414 addressOne = bufPtr- ADDRESS_ONE_OFFSET;
1415
1416 if (addressOne[0] & 0x1) {
1417 /* multicast/broadcast frames, no acknowledgement needed */
1418 qc |= 1 << 5;
1419 }
1420 /* non-AP mode only for now */
1421 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA ||
1422 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS ||
1423 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) {
1424 /* In case of STA and IBSS case eosp and txop limit is 0. */
1425 } else {
1426 if(bQosNull) {
1427 qc |= 1 << 4;
1428 }
1429 }
1430
1431 /* append Qos control field to mac header */
1432 bufPtr[0] = qc;
1433 /* txop limit is 0 */
1434 bufPtr[1] = 0;
1435 macHeaderLengthInBytes -= QOS_CONTROL_HEADER_SIZE;
1436 }
1437 if (macHeaderLengthInBytes) {
1438 unifi_warning(priv, " Mac header not appended properly\n");
1439 return -1;
1440 }
1441 return 0;
1442}
1443
1444/*
1445 * ---------------------------------------------------------------------------
1446 * send_ma_pkt_request
1447 *
1448 * These functions send a data packet to UniFi for transmission.
1449 * EAP protocol packets are also sent as send_ma_pkt_request().
1450 *
1451 * Arguments:
1452 * priv Pointer to device private context struct
1453 * skb Socket buffer containing data packet to transmit
1454 * ehdr Pointer to Ethernet header within skb.
1455 *
1456 * Returns:
1457 * Zero on success or error code.
1458 * ---------------------------------------------------------------------------
1459 */
1460
1461static int
1462send_ma_pkt_request(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority)
1463{
1464 int r;
1465 u16 i;
1466 u8 eapolStore = FALSE;
1467 struct sk_buff *newSkb = NULL;
1468 bulk_data_param_t bulkdata;
1469 const int proto = ntohs(ehdr->h_proto);
1470 u16 interfaceTag;
1471 CsrWifiMacAddress peerAddress;
1472 CSR_TRANSMISSION_CONTROL transmissionControl = CSR_NO_CONFIRM_REQUIRED;
1473 s8 protection;
1474 netInterface_priv_t *interfacePriv = NULL;
1475 CSR_RATE TransmitRate = (CSR_RATE)0;
1476
1477 unifi_trace(priv, UDBG5, "entering send_ma_pkt_request\n");
1478
1479 /* Get the interface Tag by means of source Mac address */
1480 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
1481 if (!memcmp(priv->netdev[i]->dev_addr, ehdr->h_source, ETH_ALEN)) {
1482 interfaceTag = i;
1483 interfacePriv = priv->interfacePriv[interfaceTag];
1484 break;
1485 }
1486 }
1487
1488 if (interfacePriv == NULL) {
1489 /* No match found - error */
1490 interfaceTag = 0;
1491 interfacePriv = priv->interfacePriv[interfaceTag];
1492 unifi_warning(priv, "Mac address not matching ... debugging needed\n");
1493 interfacePriv->stats.tx_dropped++;
1494 kfree_skb(skb);
1495 return -1;
1496 }
1497
1498 /* Add a SNAP header if necessary */
1499 if (skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto) != 0) {
1500 /* convert failed */
1501 unifi_error(priv, "skb_add_llc_snap failed.\n");
1502 kfree_skb(skb);
1503 return -1;
1504 }
1505
1506 bulkdata.d[0].os_data_ptr = skb->data;
1507 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
1508 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
1509 bulkdata.d[1].os_data_ptr = NULL;
1510 bulkdata.d[1].os_net_buf_ptr = NULL;
1511 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
1512
1513#ifdef CSR_SUPPORT_SME
1514 /* Notify the TA module for the Tx frame for non AP/P2PGO mode*/
1515 if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) &&
1516 (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) {
1517 unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX,
1518 &bulkdata.d[0], ehdr->h_source,
1519 priv->netdev[interfaceTag]->dev_addr,
1520 jiffies_to_msecs(jiffies),
1521 0); /* rate is unknown on tx */
1522 }
1523#endif /* CSR_SUPPORT_SME */
1524
1525 if ((proto == ETH_P_PAE)
1526#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1527 || (proto == ETH_P_WAI)
1528#endif
1529 )
1530 {
1531 /* check for m4 detection */
1532 if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) {
1533 eapolStore = TRUE;
1534 }
1535 }
1536
1537#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1538 if (proto == ETH_P_WAI)
1539 {
1540 protection = 0; /*WAI packets always sent unencrypted*/
1541 }
1542 else
1543 {
1544#endif
1545#ifdef CSR_SUPPORT_SME
1546 if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, ehdr->h_dest)) < 0) {
1547 unifi_warning(priv, "unicast address, but destination not in station record database\n");
1548 unifi_net_data_free(priv, &bulkdata.d[0]);
1549 return -1;
1550 }
1551#else
1552 protection = 0;
1553#endif
1554#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1555 }
1556#endif
1557
1558 /* append Mac header for Eapol as well as data packet */
1559 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, ehdr->h_dest, ehdr->h_source, protection)) {
1560 unifi_error(priv, "failed to create MAC header\n");
1561 unifi_net_data_free(priv, &bulkdata.d[0]);
1562 return -1;
1563 }
1564
1565 /* RA address must contain the immediate destination MAC address that is similar to
1566 * the Address 1 field of 802.11 Mac header here 4 is: (sizeof(framecontrol) + sizeof (durationID))
1567 * which is address 1 field
1568 */
1569 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
1570
1571 unifi_trace(priv, UDBG5, "RA[0]=%x, RA[1]=%x, RA[2]=%x, RA[3]=%x, RA[4]=%x, RA[5]=%x\n",
1572 peerAddress.a[0], peerAddress.a[1], peerAddress.a[2], peerAddress.a[3],
1573 peerAddress.a[4], peerAddress.a[5]);
1574
1575
1576 if ((proto == ETH_P_PAE)
1577#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1578 || (proto == ETH_P_WAI)
1579#endif
1580 )
1581 {
1582 CSR_SIGNAL signal;
1583 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
1584
1585 /* initialize signal to zero */
1586 memset(&signal, 0, sizeof(CSR_SIGNAL));
1587
1588 /* Frame MA_PACKET request */
1589 signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
1590 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
1591 signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
1592
1593 transmissionControl = req->TransmissionControl = 0;
1594#ifdef CSR_SUPPORT_SME
1595 if (eapolStore)
1596 {
1597 netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]);
1598
1599 /* Fill the MA-PACKET.req */
1600
1601 req->Priority = priority;
1602 unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority);
1603
1604 /* rate selected by firmware */
1605 req->TransmitRate = 0;
1606 req->HostTag = CSR_WIFI_EAPOL_M4_HOST_TAG;
1607 /* RA address matching with address 1 of Mac header */
1608 memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
1609
1610 spin_lock(&priv->m4_lock);
1611 /* Store the M4-PACKET.req for later */
1612 interfacePriv->m4_signal = signal;
1613 interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
1614 interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length;
1615 interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
1616 interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
1617 spin_unlock(&priv->m4_lock);
1618
1619 /* Signal the workqueue to call CsrWifiRouterCtrlM4ReadyToSendIndSend().
1620 * It cannot be called directly from the tx path because it
1621 * does a non-atomic kmalloc via the framework's CsrPmemAlloc().
1622 */
1623 queue_work(priv->unifi_workqueue, &netpriv->send_m4_ready_task);
1624
1625 return 0;
1626 }
1627#endif
1628 }/*EAPOL or WAI packet*/
1629
1630#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
1631 if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) && \
1632 (priv->wapi_unicast_filter) && \
1633 (proto != ETH_P_PAE) && \
1634 (proto != ETH_P_WAI) && \
1635 (skb->len > 0))
1636 {
1637 CSR_SIGNAL signal;
1638 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
1639 netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]);
1640
1641 unifi_trace(priv, UDBG4, "send_ma_pkt_request() - WAPI unicast data packet when USKID = 1 \n");
1642
1643 /* initialize signal to zero */
1644 memset(&signal, 0, sizeof(CSR_SIGNAL));
1645 /* Frame MA_PACKET request */
1646 signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
1647 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
1648 signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
1649
1650 /* Fill the MA-PACKET.req */
1651 req->TransmissionControl = 0;
1652 req->Priority = priority;
1653 unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority);
1654 req->TransmitRate = (CSR_RATE) 0; /* rate selected by firmware */
1655 req->HostTag = 0xffffffff; /* Ask for a new HostTag */
1656 /* RA address matching with address 1 of Mac header */
1657 memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
1658
1659 /* Store the M4-PACKET.req for later */
1660 spin_lock(&priv->wapi_lock);
1661 interfacePriv->wapi_unicast_ma_pkt_sig = signal;
1662 interfacePriv->wapi_unicast_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
1663 interfacePriv->wapi_unicast_bulk_data.data_length = bulkdata.d[0].data_length;
1664 interfacePriv->wapi_unicast_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
1665 interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
1666 spin_unlock(&priv->wapi_lock);
1667
1668 /* Signal the workqueue to call CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend().
1669 * It cannot be called directly from the tx path because it
1670 * does a non-atomic kmalloc via the framework's CsrPmemAlloc().
1671 */
1672 queue_work(priv->unifi_workqueue, &netpriv->send_pkt_to_encrypt);
1673
1674 return 0;
1675 }
1676#endif
1677
1678 if(priv->cmanrTestMode)
1679 {
1680 TransmitRate = priv->cmanrTestModeTransmitRate;
1681 unifi_trace(priv, UDBG2, "send_ma_pkt_request: cmanrTestModeTransmitRate = %d TransmitRate=%d\n",
1682 priv->cmanrTestModeTransmitRate,
1683 TransmitRate
1684 );
1685 }
1686
1687 /* Send UniFi msg */
1688 /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
1689 r = uf_process_ma_packet_req(priv,
1690 peerAddress.a,
1691 0xffffffff, /* Ask for a new HostTag */
1692 interfaceTag,
1693 transmissionControl,
1694 TransmitRate,
1695 priority,
1696 priv->netdev_client->sender_id,
1697 &bulkdata);
1698
1699 if (r) {
1700 unifi_trace(priv, UDBG1, "(HIP validation failure) r = %x\n", r);
1701 unifi_net_data_free(priv, &bulkdata.d[0]);
1702 return -1;
1703 }
1704
1705 unifi_trace(priv, UDBG3, "leaving send_ma_pkt_request, UNITDATA result code = %d\n", r);
1706
1707 return r;
1708} /* send_ma_pkt_request() */
1709
1710/*
1711 * ---------------------------------------------------------------------------
1712 * uf_net_xmit
1713 *
1714 * This function is called by the higher level stack to transmit an
1715 * ethernet packet.
1716 *
1717 * Arguments:
1718 * skb Ethernet packet to send.
1719 * dev Pointer to the linux net device.
1720 *
1721 * Returns:
1722 * 0 on success (packet was consumed, not necessarily transmitted)
1723 * 1 if packet was requeued
1724 * -1 on error
1725 *
1726 *
1727 * Notes:
1728 * The controlled port is handled in the qdisc dequeue handler.
1729 * ---------------------------------------------------------------------------
1730 */
1731static netdev_tx_t
1732uf_net_xmit(struct sk_buff *skb, struct net_device *dev)
1733{
1734 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1735 unifi_priv_t *priv = interfacePriv->privPtr;
1736 struct ethhdr ehdr;
1737 int proto, port;
1738 int result;
1739 static tx_signal_handler tx_handler;
1740 CSR_PRIORITY priority;
1741 CsrWifiRouterCtrlPortAction port_action;
1742
1743 unifi_trace(priv, UDBG5, "unifi_net_xmit: skb = %x\n", skb);
1744
1745 memcpy(&ehdr, skb->data, ETH_HLEN);
1746 proto = ntohs(ehdr.h_proto);
1747 priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
1748
1749 /* All frames are sent as MA-PACKET.req (EAPOL also) */
1750 tx_handler = send_ma_pkt_request;
1751
1752 /* 802.1x - apply controlled/uncontrolled port rules */
1753 if ((proto != ETH_P_PAE)
1754#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1755 && (proto != ETH_P_WAI)
1756#endif
1757 ) {
1758 port = UF_CONTROLLED_PORT_Q;
1759 } else {
1760 /* queue 4 */
1761 port = UF_UNCONTROLLED_PORT_Q;
1762 }
1763
1764 /* Uncontrolled port rules apply */
1765 port_action = verify_port(priv
1766 , (((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode)||(CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI== interfacePriv->interfaceMode))? interfacePriv->bssid.a: ehdr.h_dest)
1767 , port
1768 , interfacePriv->InterfaceTag);
1769
1770 if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
1771 unifi_trace(priv, UDBG5,
1772 "uf_net_xmit: %s controlled port open\n",
1773 port ? "" : "un");
1774 /* Remove the ethernet header */
1775 skb_pull(skb, ETH_HLEN);
1776 result = tx_handler(priv, skb, &ehdr, priority);
1777 } else {
1778
1779 /* Discard the packet if necessary */
1780 unifi_trace(priv, UDBG2,
1781 "uf_net_xmit: %s controlled port %s\n",
1782 port ? "" : "un", port_action==CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ? "blocked" : "closed");
1783 interfacePriv->stats.tx_dropped++;
1784 kfree_skb(skb);
1785
1786 return NETDEV_TX_OK;
1787 }
1788
1789 if (result == NETDEV_TX_OK) {
1790#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
1791 /* Don't update the tx stats when the pkt is to be sent for sw encryption*/
1792 if (!((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) &&
1793 (priv->wapi_unicast_filter == 1)))
1794 {
1795 dev->trans_start = jiffies;
1796 /* Should really count tx stats in the UNITDATA.status signal but
1797 * that doesn't have the length.
1798 */
1799 interfacePriv->stats.tx_packets++;
1800 /* count only the packet payload */
1801 interfacePriv->stats.tx_bytes += skb->len;
1802
1803 }
1804#else
1805 dev->trans_start = jiffies;
1806
1807 /*
1808 * Should really count tx stats in the UNITDATA.status signal but
1809 * that doesn't have the length.
1810 */
1811 interfacePriv->stats.tx_packets++;
1812 /* count only the packet payload */
1813 interfacePriv->stats.tx_bytes += skb->len;
1814#endif
1815 } else if (result < 0) {
1816
1817 /* Failed to send: fh queue was full, and the skb was discarded.
1818 * Return OK to indicate that the buffer was consumed, to stop the
1819 * kernel re-transmitting the freed buffer.
1820 */
1821 interfacePriv->stats.tx_dropped++;
1822 unifi_trace(priv, UDBG1, "unifi_net_xmit: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped);
1823 result = NETDEV_TX_OK;
1824 }
1825
1826 /* The skb will have been freed by send_XXX_request() */
1827
1828 return result;
1829} /* uf_net_xmit() */
1830
1831/*
1832 * ---------------------------------------------------------------------------
1833 * unifi_pause_xmit
1834 * unifi_restart_xmit
1835 *
1836 * These functions are called from the UniFi core to control the flow
1837 * of packets from the upper layers.
1838 * unifi_pause_xmit() is called when the internal queue is full and
1839 * should take action to stop unifi_ma_unitdata() being called.
1840 * When the queue has drained, unifi_restart_xmit() will be called to
1841 * re-enable the flow of packets for transmission.
1842 *
1843 * Arguments:
1844 * ospriv OS private context pointer.
1845 *
1846 * Returns:
1847 * unifi_pause_xmit() is called from interrupt context.
1848 * ---------------------------------------------------------------------------
1849 */
1850void
1851unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue)
1852{
1853 unifi_priv_t *priv = ospriv;
1854 int i; /* used as a loop counter */
1855
1856 unifi_trace(priv, UDBG2, "Stopping queue %d\n", queue);
1857
1858 for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
1859 {
1860 if (netif_running(priv->netdev[i]))
1861 {
1862 netif_stop_subqueue(priv->netdev[i], (u16)queue);
1863 }
1864 }
1865
1866#ifdef CSR_SUPPORT_SME
1867 if(queue<=3) {
1868 routerStartBuffering(priv, queue);
1869 unifi_trace(priv, UDBG2, "Start buffering %d\n", queue);
1870 } else {
1871 routerStartBuffering(priv, 0);
1872 unifi_error(priv, "Start buffering %d defaulting to 0\n", queue);
1873 }
1874#endif
1875
1876} /* unifi_pause_xmit() */
1877
1878void
1879unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue)
1880{
1881 unifi_priv_t *priv = ospriv;
1882 int i=0; /* used as a loop counter */
1883
1884 unifi_trace(priv, UDBG2, "Waking queue %d\n", queue);
1885
1886 for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
1887 {
1888 if (netif_running(priv->netdev[i]))
1889 {
1890 netif_wake_subqueue(priv->netdev[i], (u16)queue);
1891 }
1892 }
1893
1894#ifdef CSR_SUPPORT_SME
1895 if(queue <=3) {
1896 routerStopBuffering(priv, queue);
1897 uf_send_buffered_frames(priv, queue);
1898 } else {
1899 routerStopBuffering(priv, 0);
1900 uf_send_buffered_frames(priv, 0);
1901 }
1902#endif
1903} /* unifi_restart_xmit() */
1904
1905
1906static void
1907indicate_rx_skb(unifi_priv_t *priv, u16 ifTag, u8* dst_a, u8* src_a, struct sk_buff *skb, CSR_SIGNAL *signal,
1908 bulk_data_param_t *bulkdata)
1909{
1910 int r, sr = 0;
1911 struct net_device *dev;
1912
1913#ifdef CSR_SUPPORT_SME
1914 llc_snap_hdr_t *snap;
1915
1916 snap = (llc_snap_hdr_t *)skb->data;
1917
1918 sr = _identify_sme_ma_pkt_ind(priv,
1919 snap->oui, ntohs(snap->protocol),
1920 signal,
1921 bulkdata,
1922 dst_a, src_a );
1923#endif
1924
1925 /*
1926 * Decapsulate any SNAP header and
1927 * prepend an ethernet header so that the skb manipulation and ARP
1928 * stuff works.
1929 */
1930 r = skb_80211_to_ether(priv, skb, dst_a, src_a,
1931 signal, bulkdata);
1932 if (r == -1) {
1933 /* Drop the packet and return */
1934 priv->interfacePriv[ifTag]->stats.rx_errors++;
1935 priv->interfacePriv[ifTag]->stats.rx_frame_errors++;
1936 unifi_net_data_free(priv, &bulkdata->d[0]);
1937 unifi_notice(priv, "indicate_rx_skb: Discard unknown frame.\n");
1938 return;
1939 }
1940
1941 /* Handle the case where packet is sent up through the subscription
1942 * API but should not be given to the network stack (AMP PAL case)
1943 * LLC header is different from WiFi and the packet has been subscribed for
1944 */
1945 if (r == 1 && sr == 1) {
1946 unifi_net_data_free(priv, &bulkdata->d[0]);
1947 unifi_trace(priv, UDBG5, "indicate_rx_skb: Data given to subscription"
1948 "API, not being given to kernel\n");
1949 return;
1950 }
1951
1952 dev = priv->netdev[ifTag];
1953 /* Now we look like a regular ethernet frame */
1954 /* Fill in SKB meta data */
1955 skb->dev = dev;
1956 skb->protocol = eth_type_trans(skb, dev);
1957 skb->ip_summed = CHECKSUM_UNNECESSARY;
1958
1959 /* Test for an overlength frame */
1960 if (skb->len > (dev->mtu + ETH_HLEN)) {
1961 /* A bogus length ethfrm has been encap'd. */
1962 /* Is someone trying an oflow attack? */
1963 unifi_error(priv, "%s: oversize frame (%d > %d)\n",
1964 dev->name,
1965 skb->len, dev->mtu + ETH_HLEN);
1966
1967 /* Drop the packet and return */
1968 priv->interfacePriv[ifTag]->stats.rx_errors++;
1969 priv->interfacePriv[ifTag]->stats.rx_length_errors++;
1970 unifi_net_data_free(priv, &bulkdata->d[0]);
1971 return;
1972 }
1973
1974
1975 if(priv->cmanrTestMode)
1976 {
1977 const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
1978 priv->cmanrTestModeTransmitRate = pkt_ind->ReceivedRate;
1979 unifi_trace(priv, UDBG2, "indicate_rx_skb: cmanrTestModeTransmitRate=%d\n", priv->cmanrTestModeTransmitRate);
1980 }
1981
1982 /* Pass SKB up the stack */
1983#ifdef CSR_WIFI_USE_NETIF_RX
1984 netif_rx(skb);
1985#else
1986 netif_rx_ni(skb);
1987#endif
1988
1989 if (dev != NULL) {
1990 dev->last_rx = jiffies;
1991 }
1992
1993 /* Bump rx stats */
1994 priv->interfacePriv[ifTag]->stats.rx_packets++;
1995 priv->interfacePriv[ifTag]->stats.rx_bytes += bulkdata->d[0].data_length;
1996
1997 return;
1998}
1999
2000void
2001uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
2002 CsrWifiMacAddress source_address,
2003 int indicate, u16 interfaceTag)
2004{
2005 rx_buffered_packets_t *rx_q_item;
2006 struct list_head *rx_list;
2007 struct list_head *n;
2008 struct list_head *l_h;
2009 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
2010 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2011
2012 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2013 unifi_error(priv, "uf_process_rx_pending_queue bad interfaceTag\n");
2014 return;
2015 }
2016
2017 if (queue == UF_CONTROLLED_PORT_Q) {
2018 rx_list = &interfacePriv->rx_controlled_list;
2019 } else {
2020 rx_list = &interfacePriv->rx_uncontrolled_list;
2021 }
2022
2023 down(&priv->rx_q_sem);
2024 list_for_each_safe(l_h, n, rx_list) {
2025 rx_q_item = list_entry(l_h, rx_buffered_packets_t, q);
2026
2027 /* Validate against the source address */
2028 if (memcmp(broadcast_address.a, source_address.a, ETH_ALEN) &&
2029 memcmp(rx_q_item->sa.a, source_address.a, ETH_ALEN)) {
2030
2031 unifi_trace(priv, UDBG2,
2032 "uf_process_rx_pending_queue: Skipping sa=%02X%02X%02X%02X%02X%02X skb=%p, bulkdata=%p\n",
2033 rx_q_item->sa.a[0], rx_q_item->sa.a[1],
2034 rx_q_item->sa.a[2], rx_q_item->sa.a[3],
2035 rx_q_item->sa.a[4], rx_q_item->sa.a[5],
2036 rx_q_item->skb, &rx_q_item->bulkdata.d[0]);
2037 continue;
2038 }
2039
2040 list_del(l_h);
2041
2042
2043 unifi_trace(priv, UDBG2,
2044 "uf_process_rx_pending_queue: Was Blocked skb=%p, bulkdata=%p\n",
2045 rx_q_item->skb, &rx_q_item->bulkdata);
2046
2047 if (indicate) {
2048 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);
2049 } else {
2050 interfacePriv->stats.rx_dropped++;
2051 unifi_net_data_free(priv, &rx_q_item->bulkdata.d[0]);
2052 }
2053
2054 /* It is our resposibility to free the Rx structure object. */
2055 kfree(rx_q_item);
2056 }
2057 up(&priv->rx_q_sem);
2058}
2059
2060/*
2061 * ---------------------------------------------------------------------------
2062 * uf_resume_data_plane
2063 *
2064 * Is called when the (un)controlled port is set to open,
2065 * to notify the network stack to schedule for transmission
2066 * any packets queued in the qdisk while port was closed and
2067 * indicated to the stack any packets buffered in the Rx queues.
2068 *
2069 * Arguments:
2070 * priv Pointer to device private struct
2071 *
2072 * Returns:
2073 * ---------------------------------------------------------------------------
2074 */
2075void
2076uf_resume_data_plane(unifi_priv_t *priv, int queue,
2077 CsrWifiMacAddress peer_address,
2078 u16 interfaceTag)
2079{
2080#ifdef CSR_SUPPORT_WEXT
2081 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2082#endif
2083
2084 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2085 unifi_error(priv, "uf_resume_data_plane bad interfaceTag\n");
2086 return;
2087 }
2088
2089 unifi_trace(priv, UDBG2, "Resuming netif\n");
2090
2091 /*
2092 * If we are waiting for the net device to enter the up state, don't
2093 * process the rx queue yet as it will be done by the callback when
2094 * the device is ready.
2095 */
2096#ifdef CSR_SUPPORT_WEXT
2097 if (!interfacePriv->wait_netdev_change)
2098#endif
2099 {
2100#ifdef CONFIG_NET_SCHED
2101 if (netif_running(priv->netdev[interfaceTag])) {
2102 netif_tx_schedule_all(priv->netdev[interfaceTag]);
2103 }
2104#endif
2105 uf_process_rx_pending_queue(priv, queue, peer_address, 1, interfaceTag);
2106 }
2107} /* uf_resume_data_plane() */
2108
2109
2110void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue, CsrWifiMacAddress peer_address, u16 interfaceTag)
2111{
2112 uf_process_rx_pending_queue(priv, queue, peer_address, 0, interfaceTag);
2113
2114} /* uf_free_pending_rx_packets() */
2115
2116
2117/*
2118 * ---------------------------------------------------------------------------
2119 * unifi_rx
2120 *
2121 * Reformat a UniFi data received packet into a p80211 packet and
2122 * pass it up the protocol stack.
2123 *
2124 * Arguments:
2125 * None.
2126 *
2127 * Returns:
2128 * None.
2129 * ---------------------------------------------------------------------------
2130 */
2131static void
2132unifi_rx(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
2133{
2134 u16 interfaceTag;
2135 bulk_data_desc_t *pData;
2136 const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
2137 struct sk_buff *skb;
2138 CsrWifiRouterCtrlPortAction port_action;
2139 u8 dataFrameType;
2140 int proto;
2141 int queue;
2142
2143 u8 da[ETH_ALEN], sa[ETH_ALEN];
2144 u8 toDs, fromDs, frameType, macHeaderLengthInBytes = MAC_HEADER_SIZE;
2145 u16 frameControl;
2146 netInterface_priv_t *interfacePriv;
2147 struct ethhdr ehdr;
2148
2149 interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff);
2150 interfacePriv = priv->interfacePriv[interfaceTag];
2151
2152 /* Sanity check that the VIF refers to a sensible interface */
2153 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
2154 {
2155 unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
2156 unifi_net_data_free(priv, &bulkdata->d[0]);
2157 return;
2158 }
2159
2160 /* Sanity check that the VIF refers to an allocated netdev */
2161 if (!interfacePriv->netdev_registered)
2162 {
2163 unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag);
2164 unifi_net_data_free(priv, &bulkdata->d[0]);
2165 return;
2166 }
2167
2168 if (bulkdata->d[0].data_length == 0) {
2169 unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__);
2170 unifi_net_data_free(priv, &bulkdata->d[0]);
2171 return;
2172 }
2173
2174
2175 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
2176 skb->len = bulkdata->d[0].data_length;
2177
2178 /* Point to the addresses */
2179 toDs = (skb->data[1] & 0x01) ? 1 : 0;
2180 fromDs = (skb->data[1] & 0x02) ? 1 : 0;
2181
2182 memcpy(da, (skb->data+4+toDs*12), ETH_ALEN);/* Address1 or 3 */
2183 memcpy(sa, (skb->data+10+fromDs*(6+toDs*8)), ETH_ALEN); /* Address2, 3 or 4 */
2184
2185
2186 pData = &bulkdata->d[0];
2187 frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr);
2188 frameType = ((frameControl & 0x000C) >> 2);
2189
2190 dataFrameType =((frameControl & 0x00f0) >> 4);
2191 unifi_trace(priv, UDBG6,
2192 "%s: Receive Data Frame Type %d \n", __FUNCTION__, dataFrameType);
2193
2194 switch(dataFrameType)
2195 {
2196 case QOS_DATA:
2197 case QOS_DATA_NULL:
2198 /* If both are set then the Address4 exists (only for AP) */
2199 if (fromDs && toDs)
2200 {
2201 /* 6 is the size of Address4 field */
2202 macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
2203 }
2204 else
2205 {
2206 macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
2207 }
2208
2209 /* If order bit set then HT control field is the part of MAC header */
2210 if (frameControl & FRAME_CONTROL_ORDER_BIT)
2211 macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
2212 break;
2213 default:
2214 if (fromDs && toDs)
2215 macHeaderLengthInBytes += 6;
2216 }
2217
2218 /* Prepare the ethernet header from snap header of skb data */
2219 switch(dataFrameType)
2220 {
2221 case DATA_NULL:
2222 case QOS_DATA_NULL:
2223 /* This is for only queue info fetching, EAPOL wont come as
2224 * null data so the proto is initialized as zero
2225 */
2226 proto = 0x0;
2227 break;
2228 default:
2229 {
2230 llc_snap_hdr_t *snap;
2231 /* Fetch a snap header to find protocol (for IPV4/IPV6 packets
2232 * the snap header fetching offset is same)
2233 */
2234 snap = (llc_snap_hdr_t *) (skb->data + macHeaderLengthInBytes);
2235
2236 /* prepare the ethernet header from the snap header & addresses */
2237 ehdr.h_proto = snap->protocol;
2238 memcpy(ehdr.h_dest, da, ETH_ALEN);
2239 memcpy(ehdr.h_source, sa, ETH_ALEN);
2240 }
2241 proto = ntohs(ehdr.h_proto);
2242 }
2243 unifi_trace(priv, UDBG3, "in unifi_rx protocol from snap header = 0x%x\n", proto);
2244
2245 if ((proto != ETH_P_PAE)
2246#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
2247 && (proto != ETH_P_WAI)
2248#endif
2249 ) {
2250 queue = UF_CONTROLLED_PORT_Q;
2251 } else {
2252 queue = UF_UNCONTROLLED_PORT_Q;
2253 }
2254
2255 port_action = verify_port(priv, (unsigned char*)sa, queue, interfaceTag);
2256 unifi_trace(priv, UDBG3, "in unifi_rx port action is = 0x%x & queue = %x\n", port_action, queue);
2257
2258#ifdef CSR_SUPPORT_SME
2259 /* Notify the TA module for the Rx frame for non P2PGO and AP cases*/
2260 if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) &&
2261 (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))
2262 {
2263 /* Remove MAC header of length(macHeaderLengthInBytes) before sampling */
2264 skb_pull(skb, macHeaderLengthInBytes);
2265 pData->os_data_ptr = skb->data;
2266 pData->data_length -= macHeaderLengthInBytes;
2267
2268 if (pData->data_length) {
2269 unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX,
2270 &bulkdata->d[0],
2271 sa, priv->netdev[interfaceTag]->dev_addr,
2272 jiffies_to_msecs(jiffies),
2273 pkt_ind->ReceivedRate);
2274 }
2275 } else {
2276
2277 /* AP/P2PGO specific handling here */
2278 CsrWifiRouterCtrlStaInfo_t * srcStaInfo =
2279 CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
2280
2281 /* Defensive check only; Source address is already checked in
2282 process_ma_packet_ind and we should have a valid source address here */
2283
2284 if(srcStaInfo == NULL) {
2285 CsrWifiMacAddress peerMacAddress;
2286 /* Unknown data PDU */
2287 memcpy(peerMacAddress.a, sa, ETH_ALEN);
2288 unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__,
2289 sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
2290 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
2291 unifi_net_data_free(priv, &bulkdata->d[0]);
2292 return;
2293 }
2294
2295 /* For AP GO mode, don't store the PDUs */
2296 if (port_action != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
2297 /* Drop the packet and return */
2298 CsrWifiMacAddress peerMacAddress;
2299 memcpy(peerMacAddress.a, sa, ETH_ALEN);
2300 unifi_trace(priv, UDBG3, "%s: Port is not open: unexpected frame from peer = %x:%x:%x:%x:%x:%x\n",
2301 __FUNCTION__, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
2302
2303 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
2304 interfacePriv->stats.rx_dropped++;
2305 unifi_net_data_free(priv, &bulkdata->d[0]);
2306 unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n", __FUNCTION__,
2307 proto, queue ? "Controlled" : "Un-controlled");
2308 return;
2309 }
2310
2311 /* Qos NULL/Data NULL are freed here and not processed further */
2312 if((dataFrameType == QOS_DATA_NULL) || (dataFrameType == DATA_NULL)){
2313 unifi_trace(priv, UDBG5, "%s: Null Frame Received and Freed\n", __FUNCTION__);
2314 unifi_net_data_free(priv, &bulkdata->d[0]);
2315 return;
2316 }
2317
2318 /* Now we have done with MAC header so proceed with the real data part*/
2319 /* This function takes care of appropriate routing for AP/P2PGO case*/
2320 /* the function hadnles following things
2321 2. Routing the PDU to appropriate location
2322 3. Error case handling
2323 */
2324 if(!(uf_ap_process_data_pdu(priv, skb, &ehdr, srcStaInfo,
2325 signal,
2326 bulkdata,
2327 macHeaderLengthInBytes)))
2328 {
2329 return;
2330 }
2331 unifi_trace(priv, UDBG5, "unifi_rx: no specific AP handling process as normal frame, MAC Header len %d\n", macHeaderLengthInBytes);
2332 /* Remove the MAC header for subsequent conversion */
2333 skb_pull(skb, macHeaderLengthInBytes);
2334 pData->os_data_ptr = skb->data;
2335 pData->data_length -= macHeaderLengthInBytes;
2336 pData->os_net_buf_ptr = (unsigned char*)skb;
2337 pData->net_buf_length = skb->len;
2338 }
2339#endif /* CSR_SUPPORT_SME */
2340
2341
2342 /* Now that the MAC header is removed, null-data frames have zero length
2343 * and can be dropped
2344 */
2345 if (pData->data_length == 0) {
2346 if (((frameControl & 0x00f0) >> 4) != QOS_DATA_NULL &&
2347 ((frameControl & 0x00f0) >> 4) != DATA_NULL) {
2348 unifi_trace(priv, UDBG1, "Zero length frame, but not null-data %04x\n", frameControl);
2349 }
2350 unifi_net_data_free(priv, &bulkdata->d[0]);
2351 return;
2352 }
2353
2354 if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
2355 /* Drop the packet and return */
2356 interfacePriv->stats.rx_dropped++;
2357 unifi_net_data_free(priv, &bulkdata->d[0]);
2358 unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n",
2359 __FUNCTION__, proto, queue ? "controlled" : "uncontrolled");
2360 return;
2361 } else if ( (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK) ||
2362 (interfacePriv->connected != UnifiConnected) ) {
2363
2364 /* Buffer the packet into the Rx queues */
2365 rx_buffered_packets_t *rx_q_item;
2366 struct list_head *rx_list;
2367
2368 rx_q_item = kmalloc(sizeof(rx_buffered_packets_t),
2369 GFP_KERNEL);
2370 if (rx_q_item == NULL) {
2371 unifi_error(priv, "%s: Failed to allocate %d bytes for rx packet record\n",
2372 __FUNCTION__, sizeof(rx_buffered_packets_t));
2373 interfacePriv->stats.rx_dropped++;
2374 unifi_net_data_free(priv, &bulkdata->d[0]);
2375 return;
2376 }
2377
2378 INIT_LIST_HEAD(&rx_q_item->q);
2379 rx_q_item->bulkdata = *bulkdata;
2380 rx_q_item->skb = skb;
2381 rx_q_item->signal = *signal;
2382 memcpy(rx_q_item->sa.a, sa, ETH_ALEN);
2383 memcpy(rx_q_item->da.a, da, ETH_ALEN);
2384 unifi_trace(priv, UDBG2, "%s: Blocked skb=%p, bulkdata=%p\n",
2385 __FUNCTION__, rx_q_item->skb, &rx_q_item->bulkdata);
2386
2387 if (queue == UF_CONTROLLED_PORT_Q) {
2388 rx_list = &interfacePriv->rx_controlled_list;
2389 } else {
2390 rx_list = &interfacePriv->rx_uncontrolled_list;
2391 }
2392
2393 /* Add to tail of packets queue */
2394 down(&priv->rx_q_sem);
2395 list_add_tail(&rx_q_item->q, rx_list);
2396 up(&priv->rx_q_sem);
2397
2398 return;
2399
2400 }
2401
2402 indicate_rx_skb(priv, interfaceTag, da, sa, skb, signal, bulkdata);
2403
2404} /* unifi_rx() */
2405
2406static void process_ma_packet_cfm(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
2407{
2408 u16 interfaceTag;
2409 const CSR_MA_PACKET_CONFIRM *pkt_cfm = &signal->u.MaPacketConfirm;
2410 netInterface_priv_t *interfacePriv;
2411
2412 interfaceTag = (pkt_cfm->VirtualInterfaceIdentifier & 0xff);
2413 interfacePriv = priv->interfacePriv[interfaceTag];
2414
2415 /* Sanity check that the VIF refers to a sensible interface */
2416 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
2417 {
2418 unifi_error(priv, "%s: MA-PACKET confirm with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
2419 return;
2420 }
2421#ifdef CSR_SUPPORT_SME
2422 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2423 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2424
2425 uf_process_ma_pkt_cfm_for_ap(priv, interfaceTag, pkt_cfm);
2426 } else if (interfacePriv->m4_sent && (pkt_cfm->HostTag == interfacePriv->m4_hostTag)) {
2427 /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
2428 CsrResult result = pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE;
2429 CsrWifiMacAddress peerMacAddress;
2430 memcpy(peerMacAddress.a, interfacePriv->m4_signal.u.MaPacketRequest.Ra.x, ETH_ALEN);
2431
2432 unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
2433 CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
2434 interfaceTag,
2435 peerMacAddress,
2436 result);
2437 interfacePriv->m4_sent = FALSE;
2438 interfacePriv->m4_hostTag = 0xffffffff;
2439 }
2440#endif
2441 return;
2442}
2443
2444
2445/*
2446 * ---------------------------------------------------------------------------
2447 * unifi_rx
2448 *
2449 * Reformat a UniFi data received packet into a p80211 packet and
2450 * pass it up the protocol stack.
2451 *
2452 * Arguments:
2453 * None.
2454 *
2455 * Returns:
2456 * None.
2457 * ---------------------------------------------------------------------------
2458 */
2459static void process_ma_packet_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
2460{
2461 u16 interfaceTag;
2462 bulk_data_desc_t *pData;
2463 CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication;
2464 struct sk_buff *skb;
2465 u16 frameControl;
2466 netInterface_priv_t *interfacePriv;
2467 u8 da[ETH_ALEN], sa[ETH_ALEN];
2468 u8 *bssid = NULL, *ba_addr = NULL;
2469 u8 toDs, fromDs, frameType;
2470 u8 i =0;
2471
2472#ifdef CSR_SUPPORT_SME
2473 u8 dataFrameType = 0;
2474 u8 powerSaveChanged = FALSE;
2475 u8 pmBit = 0;
2476 CsrWifiRouterCtrlStaInfo_t *srcStaInfo = NULL;
2477 u16 qosControl;
2478
2479#endif
2480
2481 interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff);
2482 interfacePriv = priv->interfacePriv[interfaceTag];
2483
2484
2485 /* Sanity check that the VIF refers to a sensible interface */
2486 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
2487 {
2488 unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
2489 unifi_net_data_free(priv, &bulkdata->d[0]);
2490 return;
2491 }
2492
2493 /* Sanity check that the VIF refers to an allocated netdev */
2494 if (!interfacePriv->netdev_registered)
2495 {
2496 unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag);
2497 unifi_net_data_free(priv, &bulkdata->d[0]);
2498 return;
2499 }
2500
2501 if (bulkdata->d[0].data_length == 0) {
2502 unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__);
2503 unifi_net_data_free(priv, &bulkdata->d[0]);
2504 return;
2505 }
2506 /* For monitor mode we need to pass this indication to the registered application
2507 handle this separately*/
2508 /* MIC failure is already taken care of so no need to send the PDUs which are not successfully received in non-monitor mode*/
2509 if(pkt_ind->ReceptionStatus != CSR_RX_SUCCESS)
2510 {
2511 unifi_warning(priv, "%s: MA-PACKET indication with status = %d\n", __FUNCTION__, pkt_ind->ReceptionStatus);
2512 unifi_net_data_free(priv, &bulkdata->d[0]);
2513 return;
2514 }
2515
2516
2517 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
2518 skb->len = bulkdata->d[0].data_length;
2519
2520 /* Point to the addresses */
2521 toDs = (skb->data[1] & 0x01) ? 1 : 0;
2522 fromDs = (skb->data[1] & 0x02) ? 1 : 0;
2523
2524 memcpy(da, (skb->data+4+toDs*12), ETH_ALEN);/* Address1 or 3 */
2525 memcpy(sa, (skb->data+10+fromDs*(6+toDs*8)), ETH_ALEN); /* Address2, 3 or 4 */
2526
2527 /* Find the BSSID, which will be used to match the BA session */
2528 if (toDs && fromDs)
2529 {
2530 unifi_trace(priv, UDBG6, "4 address frame - don't try to find BSSID\n");
2531 bssid = NULL;
2532 }
2533 else
2534 {
2535 bssid = (u8 *) (skb->data + 4 + 12 - (fromDs * 6) - (toDs * 12));
2536 }
2537
2538 pData = &bulkdata->d[0];
2539 frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr);
2540 frameType = ((frameControl & 0x000C) >> 2);
2541
2542 unifi_trace(priv, UDBG3, "Rx Frame Type: %d sn: %d\n", frameType,
2543 (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff);
2544 if(frameType == IEEE802_11_FRAMETYPE_CONTROL){
2545#ifdef CSR_SUPPORT_SME
2546 unifi_trace(priv, UDBG6, "%s: Received Control Frame\n", __FUNCTION__);
2547
2548 if((frameControl & 0x00f0) == 0x00A0){
2549 /* This is a PS-POLL request */
2550 u8 pmBit = (frameControl & 0x1000)?0x01:0x00;
2551 unifi_trace(priv, UDBG6, "%s: Received PS-POLL Frame\n", __FUNCTION__);
2552
2553 uf_process_ps_poll(priv, sa, da, pmBit, interfaceTag);
2554 }
2555 else {
2556 unifi_warning(priv, "%s: Non PS-POLL control frame is received\n", __FUNCTION__);
2557 }
2558#endif
2559 unifi_net_data_free(priv, &bulkdata->d[0]);
2560 return;
2561 }
2562 if(frameType != IEEE802_11_FRAMETYPE_DATA) {
2563 unifi_warning(priv, "%s: Non control Non Data frame is received\n", __FUNCTION__);
2564 unifi_net_data_free(priv, &bulkdata->d[0]);
2565 return;
2566 }
2567
2568#ifdef CSR_SUPPORT_SME
2569 if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
2570 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)){
2571
2572 srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
2573
2574 if(srcStaInfo == NULL) {
2575 CsrWifiMacAddress peerMacAddress;
2576 /* Unknown data PDU */
2577 memcpy(peerMacAddress.a, sa, ETH_ALEN);
2578 unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__,
2579 sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
2580 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
2581 unifi_net_data_free(priv, &bulkdata->d[0]);
2582 return;
2583 }
2584
2585 /*
2586 verify power management bit here so as to ensure host and unifi are always
2587 in sync with power management status of peer.
2588
2589 If we do it later, it may so happen we have stored the frame in BA re-ordering
2590 buffer and hence host and unifi are out of sync for power management status
2591 */
2592
2593 pmBit = (frameControl & 0x1000)?0x01:0x00;
2594 powerSaveChanged = uf_process_pm_bit_for_peer(priv, srcStaInfo, pmBit, interfaceTag);
2595
2596 /* Update station last activity time */
2597 srcStaInfo->activity_flag = TRUE;
2598
2599 /* For Qos Frame if PM bit is toggled to indicate the change in power save state then it shall not be
2600 considered as Trigger Frame. Enter only if WMM STA and peer is in Power save */
2601
2602 dataFrameType = ((frameControl & 0x00f0) >> 4);
2603
2604 if((powerSaveChanged == FALSE)&&(srcStaInfo->wmmOrQosEnabled == TRUE)&&
2605 (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)){
2606
2607 if((dataFrameType == QOS_DATA) || (dataFrameType == QOS_DATA_NULL)){
2608
2609 /*
2610 * QoS control field is offset from frame control by 2 (frame control)
2611 * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
2612 */
2613 if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){
2614 qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 30);
2615 }
2616 else{
2617 qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 24);
2618 }
2619 unifi_trace(priv, UDBG5, "%s: Check if U-APSD operations are triggered for qosControl: 0x%x\n", __FUNCTION__, qosControl);
2620 uf_process_wmm_deliver_ac_uapsd(priv, srcStaInfo, qosControl, interfaceTag);
2621 }
2622 }
2623 }
2624
2625#endif
2626
2627 if( ((frameControl & 0x00f0) >> 4) == QOS_DATA) {
2628 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);
2629 int tID = *qos_control_ptr & IEEE802_11_QC_TID_MASK; /* using ls octet of qos control */
2630 ba_session_rx_struct *ba_session;
2631 u8 ba_session_idx = 0;
2632 /* Get the BA originator address */
2633 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2634 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
2635 ba_addr = sa;
2636 }else{
2637 ba_addr = bssid;
2638 }
2639
2640 down(&priv->ba_mutex);
2641 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
2642 ba_session = interfacePriv->ba_session_rx[ba_session_idx];
2643 if (ba_session){
2644 unifi_trace(priv, UDBG6, "found ba_session=0x%x ba_session_idx=%d", ba_session, ba_session_idx);
2645 if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == tID)){
2646 frame_desc_struct frame_desc;
2647 frame_desc.bulkdata = *bulkdata;
2648 frame_desc.signal = *signal;
2649 frame_desc.sn = (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff;
2650 frame_desc.active = TRUE;
2651 unifi_trace(priv, UDBG6, "%s: calling process_ba_frame (session=%d)\n", __FUNCTION__, ba_session_idx);
2652 process_ba_frame(priv, interfacePriv, ba_session, &frame_desc);
2653 up(&priv->ba_mutex);
2654 process_ba_complete(priv, interfacePriv);
2655 break;
2656 }
2657 }
2658 }
2659 if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
2660 up(&priv->ba_mutex);
2661 unifi_trace(priv, UDBG6, "%s: calling process_amsdu()", __FUNCTION__);
2662 process_amsdu(priv, signal, bulkdata);
2663 }
2664 } else {
2665 unifi_trace(priv, UDBG6, "calling unifi_rx()");
2666 unifi_rx(priv, signal, bulkdata);
2667 }
2668
2669 /* check if the frames in reorder buffer has aged, the check
2670 * is done after receive processing so that if the missing frame
2671 * has arrived in this receive process, then it is handled cleanly.
2672 *
2673 * And also this code here takes care that timeout check is made for all
2674 * the receive indications
2675 */
2676 down(&priv->ba_mutex);
2677 for (i=0; i < MAX_SUPPORTED_BA_SESSIONS_RX; i++){
2678 ba_session_rx_struct *ba_session;
2679 ba_session = interfacePriv->ba_session_rx[i];
2680 if (ba_session){
2681 check_ba_frame_age_timeout(priv, interfacePriv, ba_session);
2682 }
2683 }
2684 up(&priv->ba_mutex);
2685 process_ba_complete(priv, interfacePriv);
2686
2687}
2688/*
2689 * ---------------------------------------------------------------------------
2690 * uf_set_multicast_list
2691 *
2692 * This function is called by the higher level stack to set
2693 * a list of multicast rx addresses.
2694 *
2695 * Arguments:
2696 * dev Network Device pointer.
2697 *
2698 * Returns:
2699 * None.
2700 *
2701 * Notes:
2702 * ---------------------------------------------------------------------------
2703 */
2704
2705static void
2706uf_set_multicast_list(struct net_device *dev)
2707{
2708 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2709 unifi_priv_t *priv = interfacePriv->privPtr;
2710
2711#ifdef CSR_NATIVE_LINUX
2712 unifi_trace(priv, UDBG3, "uf_set_multicast_list unsupported\n");
2713 return;
2714#else
2715
2716 u8 *mc_list = interfacePriv->mc_list;
2717 struct netdev_hw_addr *mc_addr;
2718 int mc_addr_count;
2719
2720 if (priv->init_progress != UNIFI_INIT_COMPLETED) {
2721 return;
2722 }
2723
2724 mc_addr_count = netdev_mc_count(dev);
2725
2726 unifi_trace(priv, UDBG3,
2727 "uf_set_multicast_list (count=%d)\n", mc_addr_count);
2728
2729
2730 /* Not enough space? */
2731 if (mc_addr_count > UNIFI_MAX_MULTICAST_ADDRESSES) {
2732 return;
2733 }
2734
2735 /* Store the list to be processed by the work item. */
2736 interfacePriv->mc_list_count = mc_addr_count;
2737 netdev_hw_addr_list_for_each(mc_addr, &dev->mc) {
2738 memcpy(mc_list, mc_addr->addr, ETH_ALEN);
2739 mc_list += ETH_ALEN;
2740 }
2741
2742 /* Send a message to the workqueue */
2743 queue_work(priv->unifi_workqueue, &priv->multicast_list_task);
2744#endif
2745
2746} /* uf_set_multicast_list() */
2747
2748/*
2749 * ---------------------------------------------------------------------------
2750 * netdev_mlme_event_handler
2751 *
2752 * Callback function to be used as the udi_event_callback when registering
2753 * as a netdev client.
2754 * To use it, a client specifies this function as the udi_event_callback
2755 * to ul_register_client(). The signal dispatcher in
2756 * unifi_receive_event() will call this function to deliver a signal.
2757 *
2758 * Arguments:
2759 * pcli Pointer to the client instance.
2760 * signal Pointer to the received signal.
2761 * signal_len Size of the signal structure in bytes.
2762 * bulkdata Pointer to structure containing any associated bulk data.
2763 * dir Direction of the signal. Zero means from host,
2764 * non-zero means to host.
2765 *
2766 * Returns:
2767 * None.
2768 * ---------------------------------------------------------------------------
2769 */
2770static void
2771netdev_mlme_event_handler(ul_client_t *pcli, const u8 *sig_packed, int sig_len,
2772 const bulk_data_param_t *bulkdata_o, int dir)
2773{
2774 CSR_SIGNAL signal;
2775 unifi_priv_t *priv = uf_find_instance(pcli->instance);
2776 int id, r;
2777 bulk_data_param_t bulkdata;
2778
2779 /* Just a sanity check */
2780 if (sig_packed == NULL) {
2781 return;
2782 }
2783
2784 /*
2785 * This copy is to silence a compiler warning about discarding the
2786 * const qualifier.
2787 */
2788 bulkdata = *bulkdata_o;
2789
2790 /* Get the unpacked signal */
2791 r = read_unpack_signal(sig_packed, &signal);
2792 if (r) {
2793 /*
2794 * The CSR_MLME_CONNECTED_INDICATION_ID has a receiverID=0 so will
2795 * fall through this case. It is safe to ignore this signal.
2796 */
2797 unifi_trace(priv, UDBG1,
2798 "Netdev - Received unknown signal 0x%.4X.\n",
2799 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
2800 return;
2801 }
2802
2803 id = signal.SignalPrimitiveHeader.SignalId;
2804 unifi_trace(priv, UDBG3, "Netdev - Process signal 0x%.4X\n", id);
2805
2806 /*
2807 * Take the appropriate action for the signal.
2808 */
2809 switch (id) {
2810 case CSR_MA_PACKET_ERROR_INDICATION_ID:
2811 process_ma_packet_error_ind(priv, &signal, &bulkdata);
2812 break;
2813 case CSR_MA_PACKET_INDICATION_ID:
2814 process_ma_packet_ind(priv, &signal, &bulkdata);
2815 break;
2816 case CSR_MA_PACKET_CONFIRM_ID:
2817 process_ma_packet_cfm(priv, &signal, &bulkdata);
2818 break;
2819#ifdef CSR_SUPPORT_SME
2820 case CSR_MLME_SET_TIM_CONFIRM_ID:
2821 /* Handle TIM confirms from FW & set the station record's TIM state appropriately,
2822 * In case of failures, tries with max_retransmit limit
2823 */
2824 uf_handle_tim_cfm(priv, &signal.u.MlmeSetTimConfirm, signal.SignalPrimitiveHeader.ReceiverProcessId);
2825 break;
2826#endif
2827 case CSR_DEBUG_STRING_INDICATION_ID:
2828 debug_string_indication(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length);
2829 break;
2830
2831 case CSR_DEBUG_WORD16_INDICATION_ID:
2832 debug_word16_indication(priv, &signal);
2833 break;
2834
2835 case CSR_DEBUG_GENERIC_CONFIRM_ID:
2836 case CSR_DEBUG_GENERIC_INDICATION_ID:
2837 debug_generic_indication(priv, &signal);
2838 break;
2839 default:
2840 break;
2841 }
2842
2843} /* netdev_mlme_event_handler() */
2844
2845
2846/*
2847 * ---------------------------------------------------------------------------
2848 * uf_net_get_name
2849 *
2850 * Retrieve the name (e.g. eth1) associated with this network device
2851 *
2852 * Arguments:
2853 * dev Pointer to the network device.
2854 * name Buffer to write name
2855 * len Size of buffer in bytes
2856 *
2857 * Returns:
2858 * None
2859 *
2860 * Notes:
2861 * ---------------------------------------------------------------------------
2862 */
2863void uf_net_get_name(struct net_device *dev, char *name, int len)
2864{
2865 *name = '\0';
2866 if (dev) {
2867 strlcpy(name, dev->name, (len > IFNAMSIZ) ? IFNAMSIZ : len);
2868 }
2869
2870} /* uf_net_get_name */
2871
2872#ifdef CSR_SUPPORT_WEXT
2873
2874/*
2875 * ---------------------------------------------------------------------------
2876 * uf_netdev_event
2877 *
2878 * Callback function to handle netdev state changes
2879 *
2880 * Arguments:
2881 * notif Pointer to a notifier_block.
2882 * event Event prompting notification
2883 * ptr net_device pointer
2884 *
2885 * Returns:
2886 * None
2887 *
2888 * Notes:
2889 * The event handler is global, and may occur on non-UniFi netdevs.
2890 * ---------------------------------------------------------------------------
2891 */
2892static int
2893uf_netdev_event(struct notifier_block *notif, unsigned long event, void* ptr) {
2894 struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
2895 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(netdev);
2896 unifi_priv_t *priv = NULL;
2897 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
2898
2899 /* Check that the event is for a UniFi netdev. If it's not, the netdev_priv
2900 * structure is not safe to use.
2901 */
2902 if (uf_find_netdev_priv(interfacePriv) == -1) {
2903 unifi_trace(NULL, UDBG1, "uf_netdev_event: ignore e=%d, ptr=%p, priv=%p %s\n",
2904 event, ptr, interfacePriv, netdev->name);
2905 return 0;
2906 }
2907
2908 switch(event) {
2909 case NETDEV_CHANGE:
2910 priv = interfacePriv->privPtr;
2911 unifi_trace(priv, UDBG1, "NETDEV_CHANGE: %p %s %s waiting for it\n",
2912 ptr,
2913 netdev->name,
2914 interfacePriv->wait_netdev_change ? "" : "not");
2915
2916 if (interfacePriv->wait_netdev_change) {
2917 netif_tx_wake_all_queues(priv->netdev[interfacePriv->InterfaceTag]);
2918 interfacePriv->connected = UnifiConnected;
2919 interfacePriv->wait_netdev_change = FALSE;
2920 /* Note: passing the broadcast address here will allow anyone to attempt to join our adhoc network */
2921 uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
2922 uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
2923 }
2924 break;
2925
2926 default:
2927 break;
2928 }
2929 return 0;
2930}
2931
2932static struct notifier_block uf_netdev_notifier = {
2933 .notifier_call = uf_netdev_event,
2934};
2935#endif /* CSR_SUPPORT_WEXT */
2936
2937
2938static void
2939 process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
2940{
2941 u32 offset;
2942 u32 length = bulkdata->d[0].data_length;
2943 u32 subframe_length, subframe_body_length, dot11_hdr_size;
2944 u8 *ptr;
2945 bulk_data_param_t subframe_bulkdata;
2946 u8 *dot11_hdr_ptr = (u8*)bulkdata->d[0].os_data_ptr;
2947 CsrResult csrResult;
2948 u16 frameControl;
2949 u8 *qos_control_ptr;
2950
2951 frameControl = le16_to_cpu(*((u16*)dot11_hdr_ptr));
2952 qos_control_ptr = dot11_hdr_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24);
2953 if(!(*qos_control_ptr & IEEE802_11_QC_A_MSDU_PRESENT)) {
2954 unifi_trace(priv, UDBG6, "%s: calling unifi_rx()", __FUNCTION__);
2955 unifi_rx(priv, signal, bulkdata);
2956 return;
2957 }
2958 *qos_control_ptr &= ~(IEEE802_11_QC_A_MSDU_PRESENT);
2959
2960 ptr = qos_control_ptr + 2;
2961 offset = dot11_hdr_size = ptr - dot11_hdr_ptr;
2962
2963 while(length > (offset + sizeof(struct ethhdr) + sizeof(llc_snap_hdr_t))) {
2964 subframe_body_length = ntohs(((struct ethhdr*)ptr)->h_proto);
2965 if(subframe_body_length > IEEE802_11_MAX_DATA_LEN) {
2966 unifi_error(priv, "%s: bad subframe_body_length = %d\n", __FUNCTION__, subframe_body_length);
2967 break;
2968 }
2969 subframe_length = sizeof(struct ethhdr) + subframe_body_length;
2970 memset(&subframe_bulkdata, 0, sizeof(bulk_data_param_t));
2971
2972 csrResult = unifi_net_data_malloc(priv, &subframe_bulkdata.d[0], dot11_hdr_size + subframe_body_length);
2973
2974 if (csrResult != CSR_RESULT_SUCCESS) {
2975 unifi_error(priv, "%s: unifi_net_data_malloc failed\n", __FUNCTION__);
2976 break;
2977 }
2978
2979 memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr, dot11_hdr_ptr, dot11_hdr_size);
2980
2981
2982 /* When to DS=0 and from DS=0, address 3 will already have BSSID so no need to re-program */
2983 if ((frameControl & IEEE802_11_FC_TO_DS_MASK) && !(frameControl & IEEE802_11_FC_FROM_DS_MASK)){
2984 memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET, ((struct ethhdr*)ptr)->h_dest, ETH_ALEN);
2985 }
2986 else if (!(frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){
2987 memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET,
2988 ((struct ethhdr*)ptr)->h_source,
2989 ETH_ALEN);
2990 }
2991
2992 memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + dot11_hdr_size,
2993 ptr + sizeof(struct ethhdr),
2994 subframe_body_length);
2995 unifi_trace(priv, UDBG6, "%s: calling unifi_rx. length = %d subframe_length = %d\n", __FUNCTION__, length, subframe_length);
2996 unifi_rx(priv, signal, &subframe_bulkdata);
2997
2998 subframe_length = (subframe_length + 3)&(~0x3);
2999 ptr += subframe_length;
3000 offset += subframe_length;
3001 }
3002 unifi_net_data_free(priv, &bulkdata->d[0]);
3003}
3004
3005
3006#define SN_TO_INDEX(__ba_session, __sn) (((__sn - __ba_session->start_sn) & 0xFFF) % __ba_session->wind_size)
3007
3008
3009#define ADVANCE_EXPECTED_SN(__ba_session) \
3010{ \
3011 __ba_session->expected_sn++; \
3012 __ba_session->expected_sn &= 0xFFF; \
3013}
3014
3015#define FREE_BUFFER_SLOT(__ba_session, __index) \
3016{ \
3017 __ba_session->occupied_slots--; \
3018 __ba_session->buffer[__index].active = FALSE; \
3019 ADVANCE_EXPECTED_SN(__ba_session); \
3020}
3021
3022static void add_frame_to_ba_complete(unifi_priv_t *priv,
3023 netInterface_priv_t *interfacePriv,
3024 frame_desc_struct *frame_desc)
3025{
3026 interfacePriv->ba_complete[interfacePriv->ba_complete_index] = *frame_desc;
3027 interfacePriv->ba_complete_index++;
3028}
3029
3030
3031static void update_expected_sn(unifi_priv_t *priv,
3032 netInterface_priv_t *interfacePriv,
3033 ba_session_rx_struct *ba_session,
3034 u16 sn)
3035{
3036 int i, j;
3037 u16 gap;
3038
3039 gap = (sn - ba_session->expected_sn) & 0xFFF;
3040 unifi_trace(priv, UDBG6, "%s: process the frames up to new_expected_sn = %d gap = %d\n", __FUNCTION__, sn, gap);
3041 for(j = 0; j < gap && j < ba_session->wind_size; j++) {
3042 i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
3043 unifi_trace(priv, UDBG6, "%s: process the slot index = %d\n", __FUNCTION__, i);
3044 if(ba_session->buffer[i].active) {
3045 add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
3046 unifi_trace(priv, UDBG6, "%s: process the frame at index = %d expected_sn = %d\n", __FUNCTION__, i, ba_session->expected_sn);
3047 FREE_BUFFER_SLOT(ba_session, i);
3048 } else {
3049 unifi_trace(priv, UDBG6, "%s: empty slot at index = %d\n", __FUNCTION__, i);
3050 ADVANCE_EXPECTED_SN(ba_session);
3051 }
3052 }
3053 ba_session->expected_sn = sn;
3054}
3055
3056
3057static void complete_ready_sequence(unifi_priv_t *priv,
3058 netInterface_priv_t *interfacePriv,
3059 ba_session_rx_struct *ba_session)
3060{
3061 int i;
3062
3063 i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
3064 while (ba_session->buffer[i].active) {
3065 add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
3066 unifi_trace(priv, UDBG6, "%s: completed stored frame(expected_sn=%d) at i = %d\n", __FUNCTION__, ba_session->expected_sn, i);
3067 FREE_BUFFER_SLOT(ba_session, i);
3068 i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
3069 }
3070}
3071
3072
3073void scroll_ba_window(unifi_priv_t *priv,
3074 netInterface_priv_t *interfacePriv,
3075 ba_session_rx_struct *ba_session,
3076 u16 sn)
3077{
3078 if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) {
3079 update_expected_sn(priv, interfacePriv, ba_session, sn);
3080 complete_ready_sequence(priv, interfacePriv, ba_session);
3081 }
3082}
3083
3084
3085static int consume_frame_or_get_buffer_index(unifi_priv_t *priv,
3086 netInterface_priv_t *interfacePriv,
3087 ba_session_rx_struct *ba_session,
3088 u16 sn,
3089 frame_desc_struct *frame_desc) {
3090 int i;
3091 u16 sn_temp;
3092
3093 if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) {
3094
3095 /* once we are in BA window, set the flag for BA trigger */
3096 if(!ba_session->trigger_ba_after_ssn){
3097 ba_session->trigger_ba_after_ssn = TRUE;
3098 }
3099
3100 sn_temp = ba_session->expected_sn + ba_session->wind_size;
3101 unifi_trace(priv, UDBG6, "%s: new frame: sn=%d\n", __FUNCTION__, sn);
3102 if(!(((sn - sn_temp) & 0xFFF) > 2048)) {
3103 u16 new_expected_sn;
3104 unifi_trace(priv, UDBG6, "%s: frame is out of window\n", __FUNCTION__);
3105 sn_temp = (sn - ba_session->wind_size) & 0xFFF;
3106 new_expected_sn = (sn_temp + 1) & 0xFFF;
3107 update_expected_sn(priv, interfacePriv, ba_session, new_expected_sn);
3108 }
3109 i = -1;
3110 if (sn == ba_session->expected_sn) {
3111 unifi_trace(priv, UDBG6, "%s: sn = ba_session->expected_sn = %d\n", __FUNCTION__, sn);
3112 ADVANCE_EXPECTED_SN(ba_session);
3113 add_frame_to_ba_complete(priv, interfacePriv, frame_desc);
3114 } else {
3115 i = SN_TO_INDEX(ba_session, sn);
3116 unifi_trace(priv, UDBG6, "%s: sn(%d) != ba_session->expected_sn(%d), i = %d\n", __FUNCTION__, sn, ba_session->expected_sn, i);
3117 if (ba_session->buffer[i].active) {
3118 unifi_trace(priv, UDBG6, "%s: free frame at i = %d\n", __FUNCTION__, i);
3119 i = -1;
3120 unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
3121 }
3122 }
3123 } else {
3124 i = -1;
3125 if(!ba_session->trigger_ba_after_ssn){
3126 unifi_trace(priv, UDBG6, "%s: frame before ssn, pass it up: sn=%d\n", __FUNCTION__, sn);
3127 add_frame_to_ba_complete(priv, interfacePriv, frame_desc);
3128 }else{
3129 unifi_trace(priv, UDBG6, "%s: old frame, drop: sn=%d, expected_sn=%d\n", __FUNCTION__, sn, ba_session->expected_sn);
3130 unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
3131 }
3132 }
3133 return i;
3134}
3135
3136
3137
3138static void process_ba_frame(unifi_priv_t *priv,
3139 netInterface_priv_t *interfacePriv,
3140 ba_session_rx_struct *ba_session,
3141 frame_desc_struct *frame_desc)
3142{
3143 int i;
3144 u16 sn = frame_desc->sn;
3145
3146 if (ba_session->timeout) {
3147 mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024)));
3148 }
3149 unifi_trace(priv, UDBG6, "%s: got frame(sn=%d)\n", __FUNCTION__, sn);
3150
3151 i = consume_frame_or_get_buffer_index(priv, interfacePriv, ba_session, sn, frame_desc);
3152 if(i >= 0) {
3153 unifi_trace(priv, UDBG6, "%s: store frame(sn=%d) at i = %d\n", __FUNCTION__, sn, i);
3154 ba_session->buffer[i] = *frame_desc;
3155 ba_session->buffer[i].recv_time = CsrTimeGet(NULL);
3156 ba_session->occupied_slots++;
3157 } else {
3158 unifi_trace(priv, UDBG6, "%s: frame consumed - sn = %d\n", __FUNCTION__, sn);
3159 }
3160 complete_ready_sequence(priv, interfacePriv, ba_session);
3161}
3162
3163
3164static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv)
3165{
3166 frame_desc_struct *frame_desc;
3167 u8 i;
3168
3169 for(i = 0; i < interfacePriv->ba_complete_index; i++) {
3170 frame_desc = &interfacePriv->ba_complete[i];
3171 unifi_trace(priv, UDBG6, "%s: calling process_amsdu()\n", __FUNCTION__);
3172 process_amsdu(priv, &frame_desc->signal, &frame_desc->bulkdata);
3173 }
3174 interfacePriv->ba_complete_index = 0;
3175
3176}
3177
3178
3179/* Check if the frames in BA reoder buffer has aged and
3180 * if so release the frames to upper processes and move
3181 * the window
3182 */
3183static void check_ba_frame_age_timeout( unifi_priv_t *priv,
3184 netInterface_priv_t *interfacePriv,
3185 ba_session_rx_struct *ba_session)
3186{
3187 u32 now;
3188 u32 age;
3189 u8 i, j;
3190 u16 sn_temp;
3191
3192 /* gap is started at 1 because we have buffered frames and
3193 * hence a minimum gap of 1 exists
3194 */
3195 u8 gap=1;
3196
3197 now = CsrTimeGet(NULL);
3198
3199 if (ba_session->occupied_slots)
3200 {
3201 /* expected sequence has not arrived so start searching from next
3202 * sequence number until a frame is available and determine the gap.
3203 * Check if the frame available has timedout, if so advance the
3204 * expected sequence number and release the frames
3205 */
3206 sn_temp = (ba_session->expected_sn + 1) & 0xFFF;
3207
3208 for(j = 0; j < ba_session->wind_size; j++)
3209 {
3210 i = SN_TO_INDEX(ba_session, sn_temp);
3211
3212 if(ba_session->buffer[i].active)
3213 {
3214 unifi_trace(priv, UDBG6, "check age at slot index = %d sn = %d recv_time = %u now = %u\n",
3215 i,
3216 ba_session->buffer[i].sn,
3217 ba_session->buffer[i].recv_time,
3218 now);
3219
3220 if (ba_session->buffer[i].recv_time > now)
3221 {
3222 /* timer wrap */
3223 age = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, ba_session->buffer[i].recv_time), now);
3224 }
3225 else
3226 {
3227 age = (u32)CsrTimeSub(now, ba_session->buffer[i].recv_time);
3228 }
3229
3230 if (age >= CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT)
3231 {
3232 unifi_trace(priv, UDBG2, "release the frame at index = %d gap = %d expected_sn = %d sn = %d\n",
3233 i,
3234 gap,
3235 ba_session->expected_sn,
3236 ba_session->buffer[i].sn);
3237
3238 /* if it has timedout don't wait for missing frames, move the window */
3239 while (gap--)
3240 {
3241 ADVANCE_EXPECTED_SN(ba_session);
3242 }
3243 add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
3244 FREE_BUFFER_SLOT(ba_session, i);
3245 complete_ready_sequence(priv, interfacePriv, ba_session);
3246 }
3247 break;
3248
3249 }
3250 else
3251 {
3252 /* advance temp sequence number and frame gap */
3253 sn_temp = (sn_temp + 1) & 0xFFF;
3254 gap++;
3255 }
3256 }
3257 }
3258}
3259
3260
3261static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
3262{
3263 u16 interfaceTag;
3264 const CSR_MA_PACKET_ERROR_INDICATION *pkt_err_ind = &signal->u.MaPacketErrorIndication;
3265 netInterface_priv_t *interfacePriv;
3266 ba_session_rx_struct *ba_session;
3267 u8 ba_session_idx = 0;
3268 CSR_PRIORITY UserPriority;
3269 CSR_SEQUENCE_NUMBER sn;
3270
3271 interfaceTag = (pkt_err_ind->VirtualInterfaceIdentifier & 0xff);
3272
3273
3274 /* Sanity check that the VIF refers to a sensible interface */
3275 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
3276 {
3277 unifi_error(priv, "%s: MaPacketErrorIndication indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
3278 return;
3279 }
3280
3281 interfacePriv = priv->interfacePriv[interfaceTag];
3282 UserPriority = pkt_err_ind->UserPriority;
3283 if(UserPriority > 15) {
3284 unifi_error(priv, "%s: MaPacketErrorIndication indication with bad UserPriority=%d\n", __FUNCTION__, UserPriority);
3285 }
3286 sn = pkt_err_ind->SequenceNumber;
3287
3288 down(&priv->ba_mutex);
3289 /* To find the right ba_session loop through the BA sessions, compare MAC address and tID */
3290 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
3291 ba_session = interfacePriv->ba_session_rx[ba_session_idx];
3292 if (ba_session){
3293 if ((!memcmp(ba_session->macAddress.a, pkt_err_ind->PeerQstaAddress.x, ETH_ALEN)) && (ba_session->tID == UserPriority)){
3294 if (ba_session->timeout) {
3295 mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024)));
3296 }
3297 scroll_ba_window(priv, interfacePriv, ba_session, sn);
3298 break;
3299 }
3300 }
3301 }
3302
3303 up(&priv->ba_mutex);
3304 process_ba_complete(priv, interfacePriv);
3305}
3306
3307
diff --git a/drivers/staging/csr/os.c b/drivers/staging/csr/os.c
deleted file mode 100644
index 37ec59df3581..000000000000
--- a/drivers/staging/csr/os.c
+++ /dev/null
@@ -1,477 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: os.c
4 *
5 * PURPOSE:
6 * Routines to fulfil the OS-abstraction for the HIP lib.
7 * It is part of the porting exercise.
8 *
9 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16
17/**
18 * The HIP lib OS abstraction consists of the implementation
19 * of the functions in this file. It is part of the porting exercise.
20 */
21
22#include "unifi_priv.h"
23
24
25/*
26 * ---------------------------------------------------------------------------
27 * unifi_net_data_malloc
28 *
29 * Allocate an OS specific net data buffer of "size" bytes.
30 * The bulk_data_slot.os_data_ptr must be initialised to point
31 * to the buffer allocated. The bulk_data_slot.length must be
32 * initialised to the requested size, zero otherwise.
33 * The bulk_data_slot.os_net_buf_ptr can be initialised to
34 * an OS specific pointer to be used in the unifi_net_data_free().
35 *
36 *
37 * Arguments:
38 * ospriv Pointer to device private context struct.
39 * bulk_data_slot Pointer to the bulk data structure to initialise.
40 * size Size of the buffer to be allocated.
41 *
42 * Returns:
43 * CSR_RESULT_SUCCESS on success, CSR_RESULT_FAILURE otherwise.
44 * ---------------------------------------------------------------------------
45 */
46CsrResult
47unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size)
48{
49 struct sk_buff *skb;
50 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
51 int rounded_length;
52
53 if (priv->card_info.sdio_block_size == 0) {
54 unifi_error(priv, "unifi_net_data_malloc: Invalid SDIO block size\n");
55 return CSR_RESULT_FAILURE;
56 }
57
58 rounded_length = (size + priv->card_info.sdio_block_size - 1) & ~(priv->card_info.sdio_block_size - 1);
59
60 /*
61 * (ETH_HLEN + 2) bytes tailroom for header manipulation
62 * CSR_WIFI_ALIGN_BYTES bytes headroom for alignment manipulation
63 */
64 skb = dev_alloc_skb(rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES);
65 if (! skb) {
66 unifi_error(ospriv, "alloc_skb failed.\n");
67 bulk_data_slot->os_net_buf_ptr = NULL;
68 bulk_data_slot->net_buf_length = 0;
69 bulk_data_slot->os_data_ptr = NULL;
70 bulk_data_slot->data_length = 0;
71 return CSR_RESULT_FAILURE;
72 }
73
74 bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb;
75 bulk_data_slot->net_buf_length = rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES;
76 bulk_data_slot->os_data_ptr = (const void*)skb->data;
77 bulk_data_slot->data_length = size;
78
79 return CSR_RESULT_SUCCESS;
80} /* unifi_net_data_malloc() */
81
82/*
83 * ---------------------------------------------------------------------------
84 * unifi_net_data_free
85 *
86 * Free an OS specific net data buffer.
87 * The bulk_data_slot.length must be initialised to 0.
88 *
89 *
90 * Arguments:
91 * ospriv Pointer to device private context struct.
92 * bulk_data_slot Pointer to the bulk data structure that
93 * holds the data to be freed.
94 *
95 * Returns:
96 * None.
97 * ---------------------------------------------------------------------------
98 */
99void
100unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot)
101{
102 struct sk_buff *skb;
103 CSR_UNUSED(ospriv);
104
105 skb = (struct sk_buff *)bulk_data_slot->os_net_buf_ptr;
106 dev_kfree_skb(skb);
107
108 bulk_data_slot->net_buf_length = 0;
109 bulk_data_slot->data_length = 0;
110 bulk_data_slot->os_data_ptr = bulk_data_slot->os_net_buf_ptr = NULL;
111
112} /* unifi_net_data_free() */
113
114
115/*
116* ---------------------------------------------------------------------------
117* unifi_net_dma_align
118*
119* DMA align an OS specific net data buffer.
120* The buffer must be empty.
121*
122*
123* Arguments:
124* ospriv Pointer to device private context struct.
125* bulk_data_slot Pointer to the bulk data structure that
126* holds the data to be aligned.
127*
128* Returns:
129* None.
130* ---------------------------------------------------------------------------
131*/
132CsrResult
133unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot)
134{
135 struct sk_buff *skb;
136 unsigned long buf_address;
137 int offset;
138 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
139
140 if ((bulk_data_slot == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) {
141 return CSR_RESULT_SUCCESS;
142 }
143
144 if ((bulk_data_slot->os_data_ptr == NULL) || (bulk_data_slot->data_length == 0)) {
145 return CSR_RESULT_SUCCESS;
146 }
147
148 buf_address = (unsigned long)(bulk_data_slot->os_data_ptr) & (CSR_WIFI_ALIGN_BYTES - 1);
149
150 unifi_trace(priv, UDBG5,
151 "unifi_net_dma_align: Allign buffer (0x%p) by %d bytes\n",
152 bulk_data_slot->os_data_ptr, buf_address);
153
154 offset = CSR_WIFI_ALIGN_BYTES - buf_address;
155 if (offset < 0) {
156 unifi_error(priv, "unifi_net_dma_align: Failed (offset=%d)\n", offset);
157 return CSR_RESULT_FAILURE;
158 }
159
160 skb = (struct sk_buff*)(bulk_data_slot->os_net_buf_ptr);
161 skb_reserve(skb, offset);
162 bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb;
163 bulk_data_slot->os_data_ptr = (const void*)(skb->data);
164
165 return CSR_RESULT_SUCCESS;
166
167} /* unifi_net_dma_align() */
168
169#ifdef ANDROID_TIMESTAMP
170static volatile unsigned int printk_cpu = UINT_MAX;
171char tbuf[30];
172
173char* print_time(void )
174{
175 unsigned long long t;
176 unsigned long nanosec_rem;
177
178 t = cpu_clock(printk_cpu);
179 nanosec_rem = do_div(t, 1000000000);
180 sprintf(tbuf, "[%5lu.%06lu] ",
181 (unsigned long) t,
182 nanosec_rem / 1000);
183
184 return tbuf;
185}
186#endif
187
188
189/* Module parameters */
190extern int unifi_debug;
191
192#ifdef UNIFI_DEBUG
193#define DEBUG_BUFFER_SIZE 120
194
195#define FORMAT_TRACE(_s, _len, _args, _fmt) \
196 do { \
197 va_start(_args, _fmt); \
198 _len += vsnprintf(&(_s)[_len], \
199 (DEBUG_BUFFER_SIZE - _len), \
200 _fmt, _args); \
201 va_end(_args); \
202 if (_len >= DEBUG_BUFFER_SIZE) { \
203 (_s)[DEBUG_BUFFER_SIZE - 2] = '\n'; \
204 (_s)[DEBUG_BUFFER_SIZE - 1] = 0; \
205 } \
206 } while (0)
207
208void
209unifi_error(void* ospriv, const char *fmt, ...)
210{
211 unifi_priv_t *priv = (unifi_priv_t*) ospriv;
212 char s[DEBUG_BUFFER_SIZE];
213 va_list args;
214 unsigned int len;
215#ifdef ANDROID_TIMESTAMP
216 if (priv != NULL) {
217 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance);
218 } else {
219 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time());
220 }
221#else
222 if (priv != NULL) {
223 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance);
224 } else {
225 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: ");
226 }
227#endif /* ANDROID_TIMESTAMP */
228 FORMAT_TRACE(s, len, args, fmt);
229
230 printk("%s", s);
231}
232
233void
234unifi_warning(void* ospriv, const char *fmt, ...)
235{
236 unifi_priv_t *priv = (unifi_priv_t*) ospriv;
237 char s[DEBUG_BUFFER_SIZE];
238 va_list args;
239 unsigned int len;
240
241#ifdef ANDROID_TIMESTAMP
242 if (priv != NULL) {
243 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi%d: ", print_time(), priv->instance);
244 } else {
245 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi: ", print_time());
246 }
247#else
248 if (priv != NULL) {
249 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi%d: ", priv->instance);
250 } else {
251 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi: ");
252 }
253#endif /* ANDROID_TIMESTAMP */
254
255 FORMAT_TRACE(s, len, args, fmt);
256
257 printk("%s", s);
258}
259
260
261void
262unifi_notice(void* ospriv, const char *fmt, ...)
263{
264 unifi_priv_t *priv = (unifi_priv_t*) ospriv;
265 char s[DEBUG_BUFFER_SIZE];
266 va_list args;
267 unsigned int len;
268
269#ifdef ANDROID_TIMESTAMP
270 if (priv != NULL) {
271 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi%d: ", print_time(), priv->instance);
272 } else {
273 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi: ", print_time());
274 }
275#else
276 if (priv != NULL) {
277 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi%d: ", priv->instance);
278 } else {
279 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi: ");
280 }
281#endif /* ANDROID_TIMESTAMP */
282
283 FORMAT_TRACE(s, len, args, fmt);
284
285 printk("%s", s);
286}
287
288
289void
290unifi_info(void* ospriv, const char *fmt, ...)
291{
292 unifi_priv_t *priv = (unifi_priv_t*) ospriv;
293 char s[DEBUG_BUFFER_SIZE];
294 va_list args;
295 unsigned int len;
296
297#ifdef ANDROID_TIMESTAMP
298 if (priv != NULL) {
299 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi%d: ", print_time(), priv->instance);
300 } else {
301 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi: ", print_time());
302 }
303#else
304 if (priv != NULL) {
305 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi%d: ", priv->instance);
306 } else {
307 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi: ");
308 }
309#endif /* ANDROID_TIMESTAMP */
310
311 FORMAT_TRACE(s, len, args, fmt);
312
313 printk("%s", s);
314}
315
316/* debugging */
317void
318unifi_trace(void* ospriv, int level, const char *fmt, ...)
319{
320 unifi_priv_t *priv = (unifi_priv_t*) ospriv;
321 char s[DEBUG_BUFFER_SIZE];
322 va_list args;
323 unsigned int len;
324
325 if (unifi_debug >= level) {
326#ifdef ANDROID_TIMESTAMP
327 if (priv != NULL) {
328 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance);
329 } else {
330 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time());
331 }
332#else
333 if (priv != NULL) {
334 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance);
335 } else {
336 len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: ");
337 }
338#endif /* ANDROID_TIMESTAMP */
339
340 FORMAT_TRACE(s, len, args, fmt);
341
342 printk("%s", s);
343 }
344}
345
346#else
347
348void
349unifi_error_nop(void* ospriv, const char *fmt, ...)
350{
351}
352
353void
354unifi_trace_nop(void* ospriv, int level, const char *fmt, ...)
355{
356}
357
358#endif /* UNIFI_DEBUG */
359
360
361/*
362 * ---------------------------------------------------------------------------
363 *
364 * Debugging support.
365 *
366 * ---------------------------------------------------------------------------
367 */
368
369#ifdef UNIFI_DEBUG
370
371/* Memory dump with level filter controlled by unifi_debug */
372void
373unifi_dump(void *ospriv, int level, const char *msg, void *mem, u16 len)
374{
375 unifi_priv_t *priv = (unifi_priv_t*) ospriv;
376
377 if (unifi_debug >= level) {
378#ifdef ANDROID_TIMESTAMP
379 if (priv != NULL) {
380 printk(KERN_ERR "%s unifi%d: --- dump: %s ---\n", print_time(), priv->instance, msg ? msg : "");
381 } else {
382 printk(KERN_ERR "%s unifi: --- dump: %s ---\n", print_time(), msg ? msg : "");
383 }
384#else
385 if (priv != NULL) {
386 printk(KERN_ERR "unifi%d: --- dump: %s ---\n", priv->instance, msg ? msg : "");
387 } else {
388 printk(KERN_ERR "unifi: --- dump: %s ---\n", msg ? msg : "");
389 }
390#endif /* ANDROID_TIMESTAMP */
391 dump(mem, len);
392
393 if (priv != NULL) {
394 printk(KERN_ERR "unifi%d: --- end of dump ---\n", priv->instance);
395 } else {
396 printk(KERN_ERR "unifi: --- end of dump ---\n");
397 }
398 }
399}
400
401/* Memory dump that appears all the time, use sparingly */
402void
403dump(void *mem, u16 len)
404{
405 int i, col = 0;
406 unsigned char *pdata = (unsigned char *)mem;
407#ifdef ANDROID_TIMESTAMP
408 printk("timestamp %s \n", print_time());
409#endif /* ANDROID_TIMESTAMP */
410 if (mem == NULL) {
411 printk("(null dump)\n");
412 return;
413 }
414 for (i = 0; i < len; i++) {
415 if (col == 0)
416 printk("0x%02X: ", i);
417
418 printk(" %02X", pdata[i]);
419
420 if (++col == 16) {
421 printk("\n");
422 col = 0;
423 }
424 }
425 if (col)
426 printk("\n");
427} /* dump() */
428
429
430void
431dump16(void *mem, u16 len)
432{
433 int i, col=0;
434 unsigned short *p = (unsigned short *)mem;
435#ifdef ANDROID_TIMESTAMP
436 printk("timestamp %s \n", print_time());
437#endif /* ANDROID_TIMESTAMP */
438 for (i = 0; i < len; i+=2) {
439 if (col == 0)
440 printk("0x%02X: ", i);
441
442 printk(" %04X", *p++);
443
444 if (++col == 8) {
445 printk("\n");
446 col = 0;
447 }
448 }
449 if (col)
450 printk("\n");
451}
452
453
454#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
455void
456dump_str(void *mem, u16 len)
457{
458 int i;
459 unsigned char *pdata = (unsigned char *)mem;
460#ifdef ANDROID_TIMESTAMP
461 printk("timestamp %s \n", print_time());
462#endif /* ANDROID_TIMESTAMP */
463 for (i = 0; i < len; i++) {
464 printk("%c", pdata[i]);
465 }
466 printk("\n");
467
468} /* dump_str() */
469#endif /* CSR_ONLY_NOTES */
470
471
472#endif /* UNIFI_DEBUG */
473
474
475/* ---------------------------------------------------------------------------
476 * - End -
477 * ------------------------------------------------------------------------- */
diff --git a/drivers/staging/csr/putest.c b/drivers/staging/csr/putest.c
deleted file mode 100644
index 5613cf0e16b0..000000000000
--- a/drivers/staging/csr/putest.c
+++ /dev/null
@@ -1,685 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: putest.c
4 *
5 * PURPOSE: putest related functions.
6 *
7 * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
8 *
9 * Refer to LICENSE.txt included with this source code for details on
10 * the license terms.
11 *
12 * ***************************************************************************
13 */
14
15#include <linux/vmalloc.h>
16#include <linux/firmware.h>
17
18#include "unifi_priv.h"
19#include "csr_wifi_hip_chiphelper.h"
20
21#define UNIFI_PROC_BOTH 3
22
23
24int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg)
25{
26 struct unifi_putest_cmd52 cmd52_params;
27 u8 *arg_pos;
28 unsigned int cmd_param_size;
29 int r;
30 CsrResult csrResult;
31 unsigned char ret_buffer[32];
32 u8 *ret_buffer_pos;
33 u8 retries;
34
35 arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
36 if (get_user(cmd_param_size, (int*)arg_pos)) {
37 unifi_error(priv,
38 "unifi_putest_cmd52_read: Failed to get the argument\n");
39 return -EFAULT;
40 }
41
42 if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) {
43 unifi_error(priv,
44 "unifi_putest_cmd52_read: cmd52 struct mismatch\n");
45 return -EINVAL;
46 }
47
48 arg_pos += sizeof(unsigned int);
49 if (copy_from_user(&cmd52_params,
50 (void*)arg_pos,
51 sizeof(struct unifi_putest_cmd52))) {
52 unifi_error(priv,
53 "unifi_putest_cmd52_read: Failed to get the cmd52 params\n");
54 return -EFAULT;
55 }
56
57 unifi_trace(priv, UDBG2, "cmd52r: func=%d addr=0x%x ",
58 cmd52_params.funcnum, cmd52_params.addr);
59
60 retries = 3;
61 CsrSdioClaim(priv->sdio);
62 do {
63 if (cmd52_params.funcnum == 0) {
64 csrResult = CsrSdioF0Read8(priv->sdio, cmd52_params.addr, &cmd52_params.data);
65 } else {
66 csrResult = CsrSdioRead8(priv->sdio, cmd52_params.addr, &cmd52_params.data);
67 }
68 } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT)));
69 CsrSdioRelease(priv->sdio);
70
71 if (csrResult != CSR_RESULT_SUCCESS) {
72 unifi_error(priv,
73 "\nunifi_putest_cmd52_read: Read8() failed (csrResult=0x%x)\n", csrResult);
74 return -EFAULT;
75 }
76 unifi_trace(priv, UDBG2, "data=%d\n", cmd52_params.data);
77
78 /* Copy the info to the out buffer */
79 *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_CMD52_READ;
80 ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1);
81 *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_cmd52);
82 ret_buffer_pos += sizeof(unsigned int);
83 memcpy(ret_buffer_pos, &cmd52_params, sizeof(struct unifi_putest_cmd52));
84 ret_buffer_pos += sizeof(struct unifi_putest_cmd52);
85
86 r = copy_to_user((void*)arg,
87 ret_buffer,
88 ret_buffer_pos - ret_buffer);
89 if (r) {
90 unifi_error(priv,
91 "unifi_putest_cmd52_read: Failed to return the data\n");
92 return -EFAULT;
93 }
94
95 return 0;
96}
97
98
99int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg)
100{
101 struct unifi_putest_cmd52 cmd52_params;
102 u8 *arg_pos;
103 unsigned int cmd_param_size;
104 CsrResult csrResult;
105 u8 retries;
106
107 arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
108 if (get_user(cmd_param_size, (int*)arg_pos)) {
109 unifi_error(priv,
110 "unifi_putest_cmd52_write: Failed to get the argument\n");
111 return -EFAULT;
112 }
113
114 if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) {
115 unifi_error(priv,
116 "unifi_putest_cmd52_write: cmd52 struct mismatch\n");
117 return -EINVAL;
118 }
119
120 arg_pos += sizeof(unsigned int);
121 if (copy_from_user(&cmd52_params,
122 (void*)(arg_pos),
123 sizeof(struct unifi_putest_cmd52))) {
124 unifi_error(priv,
125 "unifi_putest_cmd52_write: Failed to get the cmd52 params\n");
126 return -EFAULT;
127 }
128
129 unifi_trace(priv, UDBG2, "cmd52w: func=%d addr=0x%x data=%d\n",
130 cmd52_params.funcnum, cmd52_params.addr, cmd52_params.data);
131
132 retries = 3;
133 CsrSdioClaim(priv->sdio);
134 do {
135 if (cmd52_params.funcnum == 0) {
136 csrResult = CsrSdioF0Write8(priv->sdio, cmd52_params.addr, cmd52_params.data);
137 } else {
138 csrResult = CsrSdioWrite8(priv->sdio, cmd52_params.addr, cmd52_params.data);
139 }
140 } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT)));
141 CsrSdioRelease(priv->sdio);
142
143 if (csrResult != CSR_RESULT_SUCCESS) {
144 unifi_error(priv,
145 "unifi_putest_cmd52_write: Write8() failed (csrResult=0x%x)\n", csrResult);
146 return -EFAULT;
147 }
148
149 return 0;
150}
151
152int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg)
153{
154 struct unifi_putest_gp_rw16 gp_r16_params;
155 u8 *arg_pos;
156 unsigned int cmd_param_size;
157 int r;
158 CsrResult csrResult;
159 unsigned char ret_buffer[32];
160 u8 *ret_buffer_pos;
161
162 arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
163 if (get_user(cmd_param_size, (int*)arg_pos)) {
164 unifi_error(priv,
165 "unifi_putest_gp_read16: Failed to get the argument\n");
166 return -EFAULT;
167 }
168
169 if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) {
170 unifi_error(priv,
171 "unifi_putest_gp_read16: struct mismatch\n");
172 return -EINVAL;
173 }
174
175 arg_pos += sizeof(unsigned int);
176 if (copy_from_user(&gp_r16_params,
177 (void*)arg_pos,
178 sizeof(struct unifi_putest_gp_rw16))) {
179 unifi_error(priv,
180 "unifi_putest_gp_read16: Failed to get the params\n");
181 return -EFAULT;
182 }
183 CsrSdioClaim(priv->sdio);
184 csrResult = unifi_card_read16(priv->card, gp_r16_params.addr, &gp_r16_params.data);
185 CsrSdioRelease(priv->sdio);
186 if (csrResult != CSR_RESULT_SUCCESS) {
187 unifi_error(priv,
188 "unifi_putest_gp_read16: unifi_card_read16() GP=0x%x failed (csrResult=0x%x)\n", gp_r16_params.addr, csrResult);
189 return -EFAULT;
190 }
191
192 unifi_trace(priv, UDBG2, "gp_r16: GP=0x%08x, data=0x%04x\n", gp_r16_params.addr, gp_r16_params.data);
193
194 /* Copy the info to the out buffer */
195 *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_GP_READ16;
196 ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1);
197 *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_gp_rw16);
198 ret_buffer_pos += sizeof(unsigned int);
199 memcpy(ret_buffer_pos, &gp_r16_params, sizeof(struct unifi_putest_gp_rw16));
200 ret_buffer_pos += sizeof(struct unifi_putest_gp_rw16);
201
202 r = copy_to_user((void*)arg,
203 ret_buffer,
204 ret_buffer_pos - ret_buffer);
205 if (r) {
206 unifi_error(priv,
207 "unifi_putest_gp_read16: Failed to return the data\n");
208 return -EFAULT;
209 }
210
211 return 0;
212}
213
214int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg)
215{
216 struct unifi_putest_gp_rw16 gp_w16_params;
217 u8 *arg_pos;
218 unsigned int cmd_param_size;
219 CsrResult csrResult;
220
221 arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
222 if (get_user(cmd_param_size, (int*)arg_pos)) {
223 unifi_error(priv,
224 "unifi_putest_gp_write16: Failed to get the argument\n");
225 return -EFAULT;
226 }
227
228 if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) {
229 unifi_error(priv,
230 "unifi_putest_gp_write16: struct mismatch\n");
231 return -EINVAL;
232 }
233
234 arg_pos += sizeof(unsigned int);
235 if (copy_from_user(&gp_w16_params,
236 (void*)(arg_pos),
237 sizeof(struct unifi_putest_gp_rw16))) {
238 unifi_error(priv,
239 "unifi_putest_gp_write16: Failed to get the params\n");
240 return -EFAULT;
241 }
242
243 unifi_trace(priv, UDBG2, "gp_w16: GP=0x%08x, data=0x%04x\n", gp_w16_params.addr, gp_w16_params.data);
244 CsrSdioClaim(priv->sdio);
245 csrResult = unifi_card_write16(priv->card, gp_w16_params.addr, gp_w16_params.data);
246 CsrSdioRelease(priv->sdio);
247 if (csrResult != CSR_RESULT_SUCCESS) {
248 unifi_error(priv,
249 "unifi_putest_gp_write16: unifi_card_write16() GP=%x failed (csrResult=0x%x)\n", gp_w16_params.addr, csrResult);
250 return -EFAULT;
251 }
252
253 return 0;
254}
255
256int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg)
257{
258 int sdio_clock_speed;
259 CsrResult csrResult;
260
261 if (get_user(sdio_clock_speed, (int*)(((unifi_putest_command_t*)arg) + 1))) {
262 unifi_error(priv,
263 "unifi_putest_set_sdio_clock: Failed to get the argument\n");
264 return -EFAULT;
265 }
266
267 unifi_trace(priv, UDBG2, "set sdio clock: %d KHz\n", sdio_clock_speed);
268
269 CsrSdioClaim(priv->sdio);
270 csrResult = CsrSdioMaxBusClockFrequencySet(priv->sdio, sdio_clock_speed * 1000);
271 CsrSdioRelease(priv->sdio);
272 if (csrResult != CSR_RESULT_SUCCESS) {
273 unifi_error(priv,
274 "unifi_putest_set_sdio_clock: Set clock failed (csrResult=0x%x)\n", csrResult);
275 return -EFAULT;
276 }
277
278 return 0;
279}
280
281
282int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg)
283{
284 int r;
285 CsrResult csrResult;
286 int already_in_test = priv->ptest_mode;
287
288 /* Ensure that sme_sys_suspend() doesn't power down the chip because:
289 * 1) Power is needed anyway for ptest.
290 * 2) The app code uses the START ioctl as a reset, so it gets called
291 * multiple times. If the app stops the XAPs, but the power_down/up
292 * sequence doesn't actually power down the chip, there can be problems
293 * resetting, because part of the power_up sequence disables function 1
294 */
295 priv->ptest_mode = 1;
296
297 /* Suspend the SME and UniFi */
298 if (priv->sme_cli) {
299 r = sme_sys_suspend(priv);
300 if (r) {
301 unifi_error(priv,
302 "unifi_putest_start: failed to suspend UniFi\n");
303 return r;
304 }
305 }
306
307 /* Application may have stopped the XAPs, but they are needed for reset */
308 if (already_in_test) {
309 CsrSdioClaim(priv->sdio);
310 csrResult = unifi_start_processors(priv->card);
311 CsrSdioRelease(priv->sdio);
312 if (csrResult != CSR_RESULT_SUCCESS) {
313 unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
314 }
315 } else {
316 /* Ensure chip is powered for the case where there's no unifi_helper */
317 CsrSdioClaim(priv->sdio);
318 csrResult = CsrSdioPowerOn(priv->sdio);
319 CsrSdioRelease(priv->sdio);
320 if (csrResult != CSR_RESULT_SUCCESS) {
321 unifi_error(priv, "CsrSdioPowerOn csrResult = %d\n", csrResult);
322 }
323 }
324 CsrSdioClaim(priv->sdio);
325 csrResult = unifi_init(priv->card);
326 CsrSdioRelease(priv->sdio);
327 if (csrResult != CSR_RESULT_SUCCESS) {
328 unifi_error(priv,
329 "unifi_putest_start: failed to init UniFi\n");
330 return CsrHipResultToStatus(csrResult);
331 }
332
333 return 0;
334}
335
336
337int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg)
338{
339 int r = 0;
340 CsrResult csrResult;
341
342 /* Application may have stopped the XAPs, but they are needed for reset */
343 CsrSdioClaim(priv->sdio);
344 csrResult = unifi_start_processors(priv->card);
345 CsrSdioRelease(priv->sdio);
346 if (csrResult != CSR_RESULT_SUCCESS) {
347 unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
348 }
349
350 /* PUTEST_STOP is also used to resume the XAPs after SME coredump.
351 * Don't power off the chip, leave that to the normal wifi-off which is
352 * about to carry on. No need to resume the SME either, as it wasn't suspended.
353 */
354 if (priv->coredump_mode) {
355 priv->coredump_mode = 0;
356 return 0;
357 }
358
359 /* At this point function 1 is enabled and the XAPs are running, so it is
360 * safe to let the card power down. Power is restored later, asynchronously,
361 * during the wifi_on requested by the SME.
362 */
363 CsrSdioClaim(priv->sdio);
364 CsrSdioPowerOff(priv->sdio);
365 CsrSdioRelease(priv->sdio);
366
367 /* Resume the SME and UniFi */
368 if (priv->sme_cli) {
369 r = sme_sys_resume(priv);
370 if (r) {
371 unifi_error(priv,
372 "unifi_putest_stop: failed to resume SME\n");
373 }
374 }
375 priv->ptest_mode = 0;
376
377 return r;
378}
379
380
381int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg)
382{
383#define UF_PUTEST_MAX_FW_FILE_NAME 16
384#define UNIFI_MAX_FW_PATH_LEN 32
385 unsigned int fw_name_length;
386 unsigned char fw_name[UF_PUTEST_MAX_FW_FILE_NAME+1];
387 unsigned char *name_buffer;
388 int postfix;
389 char fw_path[UNIFI_MAX_FW_PATH_LEN];
390 const struct firmware *fw_entry;
391 struct dlpriv temp_fw_sta;
392 int r;
393 CsrResult csrResult;
394
395 /* Get the f/w file name length */
396 if (get_user(fw_name_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) {
397 unifi_error(priv,
398 "unifi_putest_dl_fw: Failed to get the length argument\n");
399 return -EFAULT;
400 }
401
402 unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file name size = %d\n", fw_name_length);
403
404 /* Sanity check for the f/w file name length */
405 if (fw_name_length > UF_PUTEST_MAX_FW_FILE_NAME) {
406 unifi_error(priv,
407 "unifi_putest_dl_fw: F/W file name is too long\n");
408 return -EINVAL;
409 }
410
411 /* Get the f/w file name */
412 name_buffer = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int);
413 if (copy_from_user(fw_name, (void*)name_buffer, fw_name_length)) {
414 unifi_error(priv, "unifi_putest_dl_fw: Failed to get the file name\n");
415 return -EFAULT;
416 }
417 fw_name[fw_name_length] = '\0';
418 unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file = %s\n", fw_name);
419
420 /* Keep the existing f/w to a temp, we need to restore it later */
421 temp_fw_sta = priv->fw_sta;
422
423 /* Get the putest f/w */
424 postfix = priv->instance;
425 scnprintf(fw_path, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
426 postfix, fw_name);
427 r = request_firmware(&fw_entry, fw_path, priv->unifi_device);
428 if (r == 0) {
429 priv->fw_sta.fw_desc = (void *)fw_entry;
430 priv->fw_sta.dl_data = fw_entry->data;
431 priv->fw_sta.dl_len = fw_entry->size;
432 } else {
433 unifi_error(priv, "Firmware file not available\n");
434 return -EINVAL;
435 }
436
437 /* Application may have stopped the XAPs, but they are needed for reset */
438 CsrSdioClaim(priv->sdio);
439 csrResult = unifi_start_processors(priv->card);
440 CsrSdioRelease(priv->sdio);
441 if (csrResult != CSR_RESULT_SUCCESS) {
442 unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
443 }
444
445 /* Download the f/w. On UF6xxx this will cause the f/w file to convert
446 * into patch format and download via the ROM boot loader
447 */
448 CsrSdioClaim(priv->sdio);
449 csrResult = unifi_download(priv->card, 0x0c00);
450 CsrSdioRelease(priv->sdio);
451 if (csrResult != CSR_RESULT_SUCCESS) {
452 unifi_error(priv,
453 "unifi_putest_dl_fw: failed to download the f/w\n");
454 goto free_fw;
455 }
456
457 /* Free the putest f/w... */
458free_fw:
459 uf_release_firmware(priv, &priv->fw_sta);
460 /* ... and restore the original f/w */
461 priv->fw_sta = temp_fw_sta;
462
463 return CsrHipResultToStatus(csrResult);
464}
465
466
467int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg)
468{
469 unsigned int fw_length;
470 unsigned char *fw_buf = NULL;
471 unsigned char *fw_user_ptr;
472 struct dlpriv temp_fw_sta;
473 CsrResult csrResult;
474
475 /* Get the f/w buffer length */
476 if (get_user(fw_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) {
477 unifi_error(priv,
478 "unifi_putest_dl_fw_buff: Failed to get the length arg\n");
479 return -EFAULT;
480 }
481
482 unifi_trace(priv, UDBG2, "unifi_putest_dl_fw_buff: size = %d\n", fw_length);
483
484 /* Sanity check for the buffer length */
485 if (fw_length == 0 || fw_length > 0xfffffff) {
486 unifi_error(priv,
487 "unifi_putest_dl_fw_buff: buffer length bad %u\n", fw_length);
488 return -EINVAL;
489 }
490
491 /* Buffer for kernel copy of the f/w image */
492 fw_buf = kmalloc(fw_length, GFP_KERNEL);
493 if (!fw_buf) {
494 unifi_error(priv, "unifi_putest_dl_fw_buff: malloc fail\n");
495 return -ENOMEM;
496 }
497
498 /* Get the f/w image */
499 fw_user_ptr = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int);
500 if (copy_from_user(fw_buf, (void*)fw_user_ptr, fw_length)) {
501 unifi_error(priv, "unifi_putest_dl_fw_buff: Failed to get the buffer\n");
502 kfree(fw_buf);
503 return -EFAULT;
504 }
505
506 /* Save the existing f/w to a temp, we need to restore it later */
507 temp_fw_sta = priv->fw_sta;
508
509 /* Setting fw_desc NULL indicates to the core that no f/w file was loaded
510 * via the kernel request_firmware() mechanism. This indicates to the core
511 * that it shouldn't call release_firmware() after the download is done.
512 */
513 priv->fw_sta.fw_desc = NULL; /* No OS f/w resource */
514 priv->fw_sta.dl_data = fw_buf;
515 priv->fw_sta.dl_len = fw_length;
516
517 /* Application may have stopped the XAPs, but they are needed for reset */
518 CsrSdioClaim(priv->sdio);
519 csrResult = unifi_start_processors(priv->card);
520 CsrSdioRelease(priv->sdio);
521 if (csrResult != CSR_RESULT_SUCCESS) {
522 unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
523 }
524
525 /* Download the f/w. On UF6xxx this will cause the f/w file to convert
526 * into patch format and download via the ROM boot loader
527 */
528 CsrSdioClaim(priv->sdio);
529 csrResult = unifi_download(priv->card, 0x0c00);
530 CsrSdioRelease(priv->sdio);
531 if (csrResult != CSR_RESULT_SUCCESS) {
532 unifi_error(priv,
533 "unifi_putest_dl_fw_buff: failed to download the f/w\n");
534 goto free_fw;
535 }
536
537free_fw:
538 /* Finished with the putest f/w, so restore the station f/w */
539 priv->fw_sta = temp_fw_sta;
540 kfree(fw_buf);
541
542 return CsrHipResultToStatus(csrResult);
543}
544
545
546int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg)
547{
548 u16 data_u16;
549 s32 i;
550 CsrResult r;
551
552 unifi_info(priv, "Preparing for SDIO coredump\n");
553#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
554 unifi_debug_buf_dump();
555#endif
556
557 /* Sanity check that userspace hasn't called a PUTEST_START, because that
558 * would have reset UniFi, potentially power cycling it and losing context
559 */
560 if (priv->ptest_mode) {
561 unifi_error(priv, "PUTEST_START shouldn't be used before a coredump\n");
562 }
563
564 /* Flag that the userspace has requested coredump. Even if this preparation
565 * fails, the SME will call PUTEST_STOP to tidy up.
566 */
567 priv->coredump_mode = 1;
568
569 for (i = 0; i < 3; i++) {
570 CsrSdioClaim(priv->sdio);
571 r = CsrSdioRead16(priv->sdio, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION*2, &data_u16);
572 CsrSdioRelease(priv->sdio);
573 if (r != CSR_RESULT_SUCCESS) {
574 unifi_info(priv, "Failed to read chip version! Try %d\n", i);
575
576 /* First try, re-enable function which may have been disabled by f/w panic */
577 if (i == 0) {
578 unifi_info(priv, "Try function enable\n");
579 CsrSdioClaim(priv->sdio);
580 r = CsrSdioFunctionEnable(priv->sdio);
581 CsrSdioRelease(priv->sdio);
582 if (r != CSR_RESULT_SUCCESS) {
583 unifi_error(priv, "CsrSdioFunctionEnable failed %d\n", r);
584 }
585 continue;
586 }
587
588 /* Subsequent tries, reset */
589
590 /* Set clock speed low */
591 CsrSdioClaim(priv->sdio);
592 r = CsrSdioMaxBusClockFrequencySet(priv->sdio, UNIFI_SDIO_CLOCK_SAFE_HZ);
593 CsrSdioRelease(priv->sdio);
594 if (r != CSR_RESULT_SUCCESS) {
595 unifi_error(priv, "CsrSdioMaxBusClockFrequencySet() failed %d\n", r);
596 }
597
598 /* Card software reset */
599 CsrSdioClaim(priv->sdio);
600 r = unifi_card_hard_reset(priv->card);
601 CsrSdioRelease(priv->sdio);
602 if (r != CSR_RESULT_SUCCESS) {
603 unifi_error(priv, "unifi_card_hard_reset() failed %d\n", r);
604 }
605 } else {
606 unifi_info(priv, "Read chip version of 0x%04x\n", data_u16);
607 break;
608 }
609 }
610
611 if (r != CSR_RESULT_SUCCESS) {
612 unifi_error(priv, "Failed to prepare chip\n");
613 return -EIO;
614 }
615
616 /* Stop the XAPs for coredump. The PUTEST_STOP must be called, e.g. at
617 * Raw SDIO deinit, to resume them.
618 */
619 CsrSdioClaim(priv->sdio);
620 r = unifi_card_stop_processor(priv->card, UNIFI_PROC_BOTH);
621 CsrSdioRelease(priv->sdio);
622 if (r != CSR_RESULT_SUCCESS) {
623 unifi_error(priv, "Failed to stop processors\n");
624 }
625
626 return 0;
627}
628
629int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg)
630{
631 struct unifi_putest_block_cmd52_r block_cmd52;
632 u8 *arg_pos;
633 unsigned int cmd_param_size;
634 CsrResult r;
635 u8 *block_local_buffer;
636
637 arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
638 if (get_user(cmd_param_size, (int*)arg_pos)) {
639 unifi_error(priv,
640 "cmd52r_block: Failed to get the argument\n");
641 return -EFAULT;
642 }
643
644 if (cmd_param_size != sizeof(struct unifi_putest_block_cmd52_r)) {
645 unifi_error(priv,
646 "cmd52r_block: cmd52 struct mismatch\n");
647 return -EINVAL;
648 }
649
650 arg_pos += sizeof(unsigned int);
651 if (copy_from_user(&block_cmd52,
652 (void*)arg_pos,
653 sizeof(struct unifi_putest_block_cmd52_r))) {
654 unifi_error(priv,
655 "cmd52r_block: Failed to get the cmd52 params\n");
656 return -EFAULT;
657 }
658
659 unifi_trace(priv, UDBG2, "cmd52r_block: func=%d addr=0x%x len=0x%x ",
660 block_cmd52.funcnum, block_cmd52.addr, block_cmd52.length);
661
662 block_local_buffer = vmalloc(block_cmd52.length);
663 if (block_local_buffer == NULL) {
664 unifi_error(priv, "cmd52r_block: Failed to allocate buffer\n");
665 return -ENOMEM;
666 }
667
668 CsrSdioClaim(priv->sdio);
669 r = unifi_card_readn(priv->card, block_cmd52.addr, block_local_buffer, block_cmd52.length);
670 CsrSdioRelease(priv->sdio);
671 if (r != CSR_RESULT_SUCCESS) {
672 unifi_error(priv, "cmd52r_block: unifi_readn failed\n");
673 return -EIO;
674 }
675
676 if (copy_to_user((void*)block_cmd52.data,
677 block_local_buffer,
678 block_cmd52.length)) {
679 unifi_error(priv,
680 "cmd52r_block: Failed to return the data\n");
681 return -EFAULT;
682 }
683
684 return 0;
685}
diff --git a/drivers/staging/csr/sdio_events.c b/drivers/staging/csr/sdio_events.c
deleted file mode 100644
index 2a80b9eb0200..000000000000
--- a/drivers/staging/csr/sdio_events.c
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: sdio_events.c
4 *
5 * PURPOSE:
6 * Process the events received by the SDIO glue layer.
7 * Optional part of the porting exercise.
8 *
9 * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16#include "unifi_priv.h"
17
18
19/*
20 * Porting Notes:
21 * There are two ways to support the suspend/resume system events in a driver.
22 * In some operating systems these events are delivered to the OS driver
23 * directly from the system. In this case, the OS driver needs to pass these
24 * events to the API described in the CSR SDIO Abstration API document.
25 * In Linux, and other embedded operating systems, the suspend/resume events
26 * come from the SDIO driver. In this case, simply get these events in the
27 * SDIO glue layer and notify the OS layer.
28 *
29 * In either case, typically, the events are processed by the SME.
30 * Use the unifi_sys_suspend_ind() and unifi_sys_resume_ind() to pass
31 * the events to the SME.
32 */
33
34/*
35 * ---------------------------------------------------------------------------
36 * unifi_suspend
37 *
38 * Handles a suspend request from the SDIO driver.
39 *
40 * Arguments:
41 * ospriv Pointer to OS driver context.
42 *
43 * ---------------------------------------------------------------------------
44 */
45void unifi_suspend(void *ospriv)
46{
47 unifi_priv_t *priv = ospriv;
48 int interfaceTag=0;
49
50 /* For powered suspend, tell the resume's wifi_on() not to reinit UniFi */
51 priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
52
53 unifi_trace(priv, UDBG1, "unifi_suspend: wol_suspend %d, enable_wol %d",
54 priv->wol_suspend, enable_wol );
55
56 /* Stop network traffic. */
57 /* need to stop all the netdevices*/
58 for( interfaceTag=0;interfaceTag<CSR_WIFI_NUM_INTERFACES;interfaceTag++)
59 {
60 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
61 if (interfacePriv->netdev_registered == 1)
62 {
63 if( priv->wol_suspend ) {
64 unifi_trace(priv, UDBG1, "unifi_suspend: Don't netif_carrier_off");
65 } else {
66 unifi_trace(priv, UDBG1, "unifi_suspend: netif_carrier_off");
67 netif_carrier_off(priv->netdev[interfaceTag]);
68 }
69 netif_tx_stop_all_queues(priv->netdev[interfaceTag]);
70 }
71 }
72
73 unifi_trace(priv, UDBG1, "unifi_suspend: suspend SME");
74
75 sme_sys_suspend(priv);
76
77} /* unifi_suspend() */
78
79
80/*
81 * ---------------------------------------------------------------------------
82 * unifi_resume
83 *
84 * Handles a resume request from the SDIO driver.
85 *
86 * Arguments:
87 * ospriv Pointer to OS driver context.
88 *
89 * ---------------------------------------------------------------------------
90 */
91void unifi_resume(void *ospriv)
92{
93 unifi_priv_t *priv = ospriv;
94 int interfaceTag=0;
95 int r;
96 int wol = priv->wol_suspend;
97
98 unifi_trace(priv, UDBG1, "unifi_resume: resume SME, enable_wol=%d", enable_wol);
99
100 /* The resume causes wifi-on which will re-enable the BH and reinstall the ISR */
101 r = sme_sys_resume(priv);
102 if (r) {
103 unifi_error(priv, "Failed to resume UniFi\n");
104 }
105
106 /* Resume the network interfaces. For the cold resume case, this will
107 * happen upon reconnection.
108 */
109 if (wol) {
110 unifi_trace(priv, UDBG1, "unifi_resume: try to enable carrier");
111
112 /* need to start all the netdevices*/
113 for( interfaceTag=0;interfaceTag<CSR_WIFI_NUM_INTERFACES;interfaceTag++) {
114 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
115
116 unifi_trace(priv, UDBG1, "unifi_resume: interfaceTag %d netdev_registered %d mode %d\n",
117 interfaceTag, interfacePriv->netdev_registered, interfacePriv->interfaceMode);
118
119 if (interfacePriv->netdev_registered == 1)
120 {
121 netif_carrier_on(priv->netdev[interfaceTag]);
122 netif_tx_start_all_queues(priv->netdev[interfaceTag]);
123 }
124 }
125
126 /* Kick the BH thread (with reason=host) to poll for data that may have
127 * arrived during a powered suspend. This caters for the case where the SME
128 * doesn't interact with the chip (e.g install autonomous scans) during resume.
129 */
130 unifi_send_signal(priv->card, NULL, 0, NULL);
131 }
132
133} /* unifi_resume() */
134
diff --git a/drivers/staging/csr/sdio_mmc.c b/drivers/staging/csr/sdio_mmc.c
deleted file mode 100644
index 2b503c23efae..000000000000
--- a/drivers/staging/csr/sdio_mmc.c
+++ /dev/null
@@ -1,1288 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 *
4 * FILE: sdio_mmc.c
5 *
6 * PURPOSE: SDIO driver interface for generic MMC stack.
7 *
8 * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
9 *
10 * ---------------------------------------------------------------------------
11 */
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/mutex.h>
16#include <linux/gfp.h>
17#include <linux/mmc/core.h>
18#include <linux/mmc/card.h>
19#include <linux/mmc/host.h>
20#include <linux/mmc/sdio_func.h>
21#include <linux/mmc/sdio_ids.h>
22#include <linux/mmc/sdio.h>
23#include <linux/suspend.h>
24
25#include "unifi_priv.h"
26
27#ifdef ANDROID_BUILD
28struct wake_lock unifi_sdio_wake_lock; /* wakelock to prevent suspend while resuming */
29#endif
30
31static CsrSdioFunctionDriver *sdio_func_drv;
32
33#ifdef CONFIG_PM
34static int uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr);
35#endif
36
37/*
38 * We need to keep track of the power on/off because we can not call
39 * mmc_power_restore_host() when the card is already powered.
40 * Even then, we need to patch the MMC driver to add a power_restore handler
41 * in the mmc_sdio_ops structure. If the MMC driver before 2.6.37 is not patched,
42 * mmc_power_save_host() and mmc_power_restore_host() are no-ops in the kernel,
43 * returning immediately (at least on x86).
44 */
45static int card_is_powered = 1;
46
47/* MMC uses ENOMEDIUM to indicate card gone away */
48
49static CsrResult
50ConvertSdioToCsrSdioResult(int r)
51{
52 CsrResult csrResult = CSR_RESULT_FAILURE;
53
54 switch (r) {
55 case 0:
56 csrResult = CSR_RESULT_SUCCESS;
57 break;
58 case -EIO:
59 case -EILSEQ:
60 csrResult = CSR_SDIO_RESULT_CRC_ERROR;
61 break;
62 /* Timeout errors */
63 case -ETIMEDOUT:
64 case -EBUSY:
65 csrResult = CSR_SDIO_RESULT_TIMEOUT;
66 break;
67 case -ENODEV:
68 case -ENOMEDIUM:
69 csrResult = CSR_SDIO_RESULT_NO_DEVICE;
70 break;
71 case -EINVAL:
72 csrResult = CSR_SDIO_RESULT_INVALID_VALUE;
73 break;
74 case -ENOMEM:
75 case -ENOSYS:
76 case -ERANGE:
77 case -ENXIO:
78 csrResult = CSR_RESULT_FAILURE;
79 break;
80 default:
81 unifi_warning(NULL, "Unrecognised SDIO error code: %d\n", r);
82 break;
83 }
84
85 return csrResult;
86}
87
88
89static int
90csr_io_rw_direct(struct mmc_card *card, int write, uint8_t fn,
91 uint32_t addr, uint8_t in, uint8_t* out)
92{
93 struct mmc_command cmd;
94 int err;
95
96 BUG_ON(!card);
97 BUG_ON(fn > 7);
98
99 memset(&cmd, 0, sizeof(struct mmc_command));
100
101 cmd.opcode = SD_IO_RW_DIRECT;
102 cmd.arg = write ? 0x80000000 : 0x00000000;
103 cmd.arg |= fn << 28;
104 cmd.arg |= (write && out) ? 0x08000000 : 0x00000000;
105 cmd.arg |= addr << 9;
106 cmd.arg |= in;
107 cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC;
108
109 err = mmc_wait_for_cmd(card->host, &cmd, 0);
110 if (err)
111 return err;
112
113 /* this function is not exported, so we will need to sort it out here
114 * for now, lets hard code it to sdio */
115 if (0) {
116 /* old arg (mmc_host_is_spi(card->host)) { */
117 /* host driver already reported errors */
118 } else {
119 if (cmd.resp[0] & R5_ERROR) {
120 printk(KERN_ERR "%s: r5 error 0x%02x\n",
121 __FUNCTION__, cmd.resp[0]);
122 return -EIO;
123 }
124 if (cmd.resp[0] & R5_FUNCTION_NUMBER)
125 return -EINVAL;
126 if (cmd.resp[0] & R5_OUT_OF_RANGE)
127 return -ERANGE;
128 }
129
130 if (out) {
131 if (0) { /* old argument (mmc_host_is_spi(card->host)) */
132 *out = (cmd.resp[0] >> 8) & 0xFF;
133 }
134 else {
135 *out = cmd.resp[0] & 0xFF;
136 }
137 }
138
139 return CSR_RESULT_SUCCESS;
140}
141
142
143CsrResult
144CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data)
145{
146 struct sdio_func *func = (struct sdio_func *)function->priv;
147 int err = 0;
148
149 _sdio_claim_host(func);
150 *data = sdio_readb(func, address, &err);
151 _sdio_release_host(func);
152
153 if (err) {
154 return ConvertSdioToCsrSdioResult(err);
155 }
156
157 return CSR_RESULT_SUCCESS;
158} /* CsrSdioRead8() */
159
160CsrResult
161CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data)
162{
163 struct sdio_func *func = (struct sdio_func *)function->priv;
164 int err = 0;
165
166 _sdio_claim_host(func);
167 sdio_writeb(func, data, address, &err);
168 _sdio_release_host(func);
169
170 if (err) {
171 return ConvertSdioToCsrSdioResult(err);
172 }
173
174 return CSR_RESULT_SUCCESS;
175} /* CsrSdioWrite8() */
176
177CsrResult
178CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data)
179{
180 struct sdio_func *func = (struct sdio_func *)function->priv;
181 int err;
182 uint8_t b0, b1;
183
184 _sdio_claim_host(func);
185 b0 = sdio_readb(func, address, &err);
186 if (err) {
187 _sdio_release_host(func);
188 return ConvertSdioToCsrSdioResult(err);
189 }
190
191 b1 = sdio_readb(func, address+1, &err);
192 if (err) {
193 _sdio_release_host(func);
194 return ConvertSdioToCsrSdioResult(err);
195 }
196 _sdio_release_host(func);
197
198 *data = ((uint16_t)b1 << 8) | b0;
199
200 return CSR_RESULT_SUCCESS;
201} /* CsrSdioRead16() */
202
203
204CsrResult
205CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data)
206{
207 struct sdio_func *func = (struct sdio_func *)function->priv;
208 int err;
209 uint8_t b0, b1;
210
211 _sdio_claim_host(func);
212 b1 = (data >> 8) & 0xFF;
213 sdio_writeb(func, b1, address+1, &err);
214 if (err) {
215 _sdio_release_host(func);
216 return ConvertSdioToCsrSdioResult(err);
217 }
218
219 b0 = data & 0xFF;
220 sdio_writeb(func, b0, address, &err);
221 if (err) {
222 _sdio_release_host(func);
223 return ConvertSdioToCsrSdioResult(err);
224 }
225
226 _sdio_release_host(func);
227 return CSR_RESULT_SUCCESS;
228} /* CsrSdioWrite16() */
229
230
231CsrResult
232CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data)
233{
234 struct sdio_func *func = (struct sdio_func *)function->priv;
235 int err = 0;
236
237 _sdio_claim_host(func);
238#ifdef MMC_QUIRK_LENIENT_FN0
239 *data = sdio_f0_readb(func, address, &err);
240#else
241 err = csr_io_rw_direct(func->card, 0, 0, address, 0, data);
242#endif
243 _sdio_release_host(func);
244
245 if (err) {
246 return ConvertSdioToCsrSdioResult(err);
247 }
248
249 return CSR_RESULT_SUCCESS;
250} /* CsrSdioF0Read8() */
251
252CsrResult
253CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data)
254{
255 struct sdio_func *func = (struct sdio_func *)function->priv;
256 int err = 0;
257
258 _sdio_claim_host(func);
259#ifdef MMC_QUIRK_LENIENT_FN0
260 sdio_f0_writeb(func, data, address, &err);
261#else
262 err = csr_io_rw_direct(func->card, 1, 0, address, data, NULL);
263#endif
264 _sdio_release_host(func);
265
266 if (err) {
267 return ConvertSdioToCsrSdioResult(err);
268 }
269
270 return CSR_RESULT_SUCCESS;
271} /* CsrSdioF0Write8() */
272
273
274CsrResult
275CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length)
276{
277 struct sdio_func *func = (struct sdio_func *)function->priv;
278 int err;
279
280 _sdio_claim_host(func);
281 err = sdio_readsb(func, data, address, length);
282 _sdio_release_host(func);
283
284 if (err) {
285 return ConvertSdioToCsrSdioResult(err);
286 }
287
288 return CSR_RESULT_SUCCESS;
289} /* CsrSdioRead() */
290
291CsrResult
292CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length)
293{
294 struct sdio_func *func = (struct sdio_func *)function->priv;
295 int err;
296
297 _sdio_claim_host(func);
298 err = sdio_writesb(func, address, (void*)data, length);
299 _sdio_release_host(func);
300
301 if (err) {
302 return ConvertSdioToCsrSdioResult(err);
303 }
304
305 return CSR_RESULT_SUCCESS;
306} /* CsrSdioWrite() */
307
308
309static int
310csr_sdio_enable_hs(struct mmc_card *card)
311{
312 int ret;
313 u8 speed;
314
315 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) {
316 /* We've asked for HS clock rates, but controller doesn't
317 * claim to support it. We should limit the clock
318 * to 25MHz via module parameter.
319 */
320 printk(KERN_INFO "unifi: request HS but not MMC_CAP_SD_HIGHSPEED");
321 return 0;
322 }
323
324 if (!card->cccr.high_speed)
325 return 0;
326
327#if 1
328 ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);
329 if (ret)
330 return ret;
331
332 speed |= SDIO_SPEED_EHS;
333#else
334 /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */
335 speed = SDIO_SPEED_EHS | SDIO_SPEED_SHS;
336#endif
337
338 ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);
339 if (ret)
340 return ret;
341
342 mmc_card_set_highspeed(card);
343 card->host->ios.timing = MMC_TIMING_SD_HS;
344 card->host->ops->set_ios(card->host, &card->host->ios);
345
346 return 0;
347}
348
349static int
350csr_sdio_disable_hs(struct mmc_card *card)
351{
352 int ret;
353 u8 speed;
354
355 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
356 return 0;
357
358 if (!card->cccr.high_speed)
359 return 0;
360#if 1
361 ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);
362 if (ret)
363 return ret;
364
365 speed &= ~SDIO_SPEED_EHS;
366#else
367 /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */
368 speed = SDIO_SPEED_SHS; /* clear SDIO_SPEED_EHS */
369#endif
370
371 ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);
372 if (ret)
373 return ret;
374
375 card->state &= ~MMC_STATE_HIGHSPEED;
376 card->host->ios.timing = MMC_TIMING_LEGACY;
377 card->host->ops->set_ios(card->host, &card->host->ios);
378
379 return 0;
380}
381
382
383/*
384 * ---------------------------------------------------------------------------
385 * CsrSdioMaxBusClockFrequencySet
386 *
387 * Set the maximum SDIO bus clock speed to use.
388 *
389 * Arguments:
390 * sdio SDIO context pointer
391 * maxFrequency maximum clock speed in Hz
392 *
393 * Returns:
394 * an error code.
395 * ---------------------------------------------------------------------------
396 */
397CsrResult
398CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency)
399{
400 struct sdio_func *func = (struct sdio_func *)function->priv;
401 struct mmc_host *host = func->card->host;
402 struct mmc_ios *ios = &host->ios;
403 unsigned int max_hz;
404 int err;
405 u32 max_khz = maxFrequency/1000;
406
407 if (!max_khz || max_khz > sdio_clock) {
408 max_khz = sdio_clock;
409 }
410
411 _sdio_claim_host(func);
412 max_hz = 1000 * max_khz;
413 if (max_hz > host->f_max) {
414 max_hz = host->f_max;
415 }
416
417 if (max_hz > 25000000) {
418 err = csr_sdio_enable_hs(func->card);
419 } else {
420 err = csr_sdio_disable_hs(func->card);
421 }
422 if (err) {
423 printk(KERN_ERR "SDIO warning: Failed to configure SDIO clock mode\n");
424 _sdio_release_host(func);
425 return CSR_RESULT_SUCCESS;
426 }
427
428 ios->clock = max_hz;
429 host->ops->set_ios(host, ios);
430
431 _sdio_release_host(func);
432
433 return CSR_RESULT_SUCCESS;
434} /* CsrSdioMaxBusClockFrequencySet() */
435
436
437/*
438 * ---------------------------------------------------------------------------
439 * CsrSdioInterruptEnable
440 * CsrSdioInterruptDisable
441 *
442 * Enable or disable the SDIO interrupt.
443 * The driver disables the SDIO interrupt until the i/o thread can
444 * process it.
445 * The SDIO interrupt can be disabled by modifying the SDIO_INT_ENABLE
446 * register in the Card Common Control Register block, but this requires
447 * two CMD52 operations. A better solution is to mask the interrupt at
448 * the host controller.
449 *
450 * Arguments:
451 * sdio SDIO context pointer
452 *
453 * Returns:
454 * Zero on success or a UniFi driver error code.
455 *
456 * ---------------------------------------------------------------------------
457 */
458CsrResult
459CsrSdioInterruptEnable(CsrSdioFunction *function)
460{
461 struct sdio_func *func = (struct sdio_func *)function->priv;
462 int err = 0;
463
464#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
465 sdio_unblock_card_irq(func);
466#else
467 _sdio_claim_host(func);
468 /* Write the Int Enable in CCCR block */
469#ifdef MMC_QUIRK_LENIENT_FN0
470 sdio_f0_writeb(func, 0x3, SDIO_CCCR_IENx, &err);
471#else
472 err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x03, NULL);
473#endif
474 _sdio_release_host(func);
475
476 if (err) {
477 printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err);
478 return ConvertSdioToCsrSdioResult(err);
479 }
480#endif
481 return CSR_RESULT_SUCCESS;
482} /* CsrSdioInterruptEnable() */
483
484CsrResult
485CsrSdioInterruptDisable(CsrSdioFunction *function)
486{
487 struct sdio_func *func = (struct sdio_func *)function->priv;
488 int err = 0;
489
490#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
491 sdio_block_card_irq(func);
492#else
493 _sdio_claim_host(func);
494 /* Write the Int Enable in CCCR block */
495#ifdef MMC_QUIRK_LENIENT_FN0
496 sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &err);
497#else
498 err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL);
499#endif
500 _sdio_release_host(func);
501
502 if (err) {
503 printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err);
504 return ConvertSdioToCsrSdioResult(err);
505 }
506#endif
507 return CSR_RESULT_SUCCESS;
508} /* CsrSdioInterruptDisable() */
509
510
511void CsrSdioInterruptAcknowledge(CsrSdioFunction *function)
512{
513}
514
515
516/*
517 * ---------------------------------------------------------------------------
518 * CsrSdioFunctionEnable
519 *
520 * Enable i/o on function 1.
521 *
522 * Arguments:
523 * sdio SDIO context pointer
524 *
525 * Returns:
526 * UniFi driver error code.
527 * ---------------------------------------------------------------------------
528 */
529CsrResult
530CsrSdioFunctionEnable(CsrSdioFunction *function)
531{
532 struct sdio_func *func = (struct sdio_func *)function->priv;
533 int err;
534
535 /* Enable UniFi function 1 (the 802.11 part). */
536 _sdio_claim_host(func);
537 err = sdio_enable_func(func);
538 _sdio_release_host(func);
539 if (err) {
540 unifi_error(NULL, "Failed to enable SDIO function %d\n", func->num);
541 }
542
543 return ConvertSdioToCsrSdioResult(err);
544} /* CsrSdioFunctionEnable() */
545
546
547/*
548 * ---------------------------------------------------------------------------
549 * CsrSdioFunctionDisable
550 *
551 * Enable i/o on function 1.
552 *
553 * Arguments:
554 * sdio SDIO context pointer
555 *
556 * Returns:
557 * UniFi driver error code.
558 * ---------------------------------------------------------------------------
559 */
560CsrResult
561CsrSdioFunctionDisable(CsrSdioFunction *function)
562{
563 struct sdio_func *func = (struct sdio_func *)function->priv;
564 int err;
565
566 /* Disable UniFi function 1 (the 802.11 part). */
567 _sdio_claim_host(func);
568 err = sdio_disable_func(func);
569 _sdio_release_host(func);
570 if (err) {
571 unifi_error(NULL, "Failed to disable SDIO function %d\n", func->num);
572 }
573
574 return ConvertSdioToCsrSdioResult(err);
575} /* CsrSdioFunctionDisable() */
576
577
578/*
579 * ---------------------------------------------------------------------------
580 * CsrSdioFunctionActive
581 *
582 * No-op as the bus goes to an active state at the start of every
583 * command.
584 *
585 * Arguments:
586 * sdio SDIO context pointer
587 * ---------------------------------------------------------------------------
588 */
589void
590CsrSdioFunctionActive(CsrSdioFunction *function)
591{
592} /* CsrSdioFunctionActive() */
593
594/*
595 * ---------------------------------------------------------------------------
596 * CsrSdioFunctionIdle
597 *
598 * Set the function as idle.
599 *
600 * Arguments:
601 * sdio SDIO context pointer
602 * ---------------------------------------------------------------------------
603 */
604void
605CsrSdioFunctionIdle(CsrSdioFunction *function)
606{
607} /* CsrSdioFunctionIdle() */
608
609
610/*
611 * ---------------------------------------------------------------------------
612 * CsrSdioPowerOn
613 *
614 * Power on UniFi.
615 *
616 * Arguments:
617 * sdio SDIO context pointer
618 * ---------------------------------------------------------------------------
619 */
620CsrResult
621CsrSdioPowerOn(CsrSdioFunction *function)
622{
623 struct sdio_func *func = (struct sdio_func *)function->priv;
624 struct mmc_host *host = func->card->host;
625
626 _sdio_claim_host(func);
627 if (!card_is_powered) {
628 mmc_power_restore_host(host);
629 card_is_powered = 1;
630 } else {
631 printk(KERN_INFO "SDIO: Skip power on; card is already powered.\n");
632 }
633 _sdio_release_host(func);
634
635 return CSR_RESULT_SUCCESS;
636} /* CsrSdioPowerOn() */
637
638/*
639 * ---------------------------------------------------------------------------
640 * CsrSdioPowerOff
641 *
642 * Power off UniFi.
643 *
644 * Arguments:
645 * sdio SDIO context pointer
646 * ---------------------------------------------------------------------------
647 */
648void
649CsrSdioPowerOff(CsrSdioFunction *function)
650{
651 struct sdio_func *func = (struct sdio_func *)function->priv;
652 struct mmc_host *host = func->card->host;
653
654 _sdio_claim_host(func);
655 if (card_is_powered) {
656 mmc_power_save_host(host);
657 card_is_powered = 0;
658 } else {
659 printk(KERN_INFO "SDIO: Skip power off; card is already powered off.\n");
660 }
661 _sdio_release_host(func);
662} /* CsrSdioPowerOff() */
663
664
665static int
666sdio_set_block_size_ignore_first_error(struct sdio_func *func, unsigned blksz)
667{
668 int ret;
669
670 if (blksz > func->card->host->max_blk_size)
671 return -EINVAL;
672
673 if (blksz == 0) {
674 blksz = min(func->max_blksize, func->card->host->max_blk_size);
675 blksz = min(blksz, 512u);
676 }
677
678 /*
679 * Ignore -ERANGE (OUT_OF_RANGE in R5) on the first byte as
680 * the block size may be invalid until both bytes are written.
681 */
682 ret = csr_io_rw_direct(func->card, 1, 0,
683 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE,
684 blksz & 0xff, NULL);
685 if (ret && ret != -ERANGE)
686 return ret;
687 ret = csr_io_rw_direct(func->card, 1, 0,
688 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1,
689 (blksz >> 8) & 0xff, NULL);
690 if (ret)
691 return ret;
692 func->cur_blksize = blksz;
693
694 return 0;
695}
696
697CsrResult
698CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize)
699{
700 struct sdio_func *func = (struct sdio_func *)function->priv;
701 int r = 0;
702
703 /* Module parameter overrides */
704 if (sdio_block_size > -1) {
705 blockSize = sdio_block_size;
706 }
707
708 unifi_trace(NULL, UDBG1, "Set SDIO function block size to %d\n",
709 blockSize);
710
711 _sdio_claim_host(func);
712 r = sdio_set_block_size(func, blockSize);
713 _sdio_release_host(func);
714
715 /*
716 * The MMC driver for kernels prior to 2.6.32 may fail this request
717 * with -ERANGE. In this case use our workaround.
718 */
719 if (r == -ERANGE) {
720 _sdio_claim_host(func);
721 r = sdio_set_block_size_ignore_first_error(func, blockSize);
722 _sdio_release_host(func);
723 }
724 if (r) {
725 unifi_error(NULL, "Error %d setting block size\n", r);
726 }
727
728 /* Determine the achieved block size to pass to the core */
729 function->blockSize = func->cur_blksize;
730
731 return ConvertSdioToCsrSdioResult(r);
732} /* CsrSdioBlockSizeSet() */
733
734
735/*
736 * ---------------------------------------------------------------------------
737 * CsrSdioHardReset
738 *
739 * Hard Resets UniFi is possible.
740 *
741 * Arguments:
742 * sdio SDIO context pointer
743 * ---------------------------------------------------------------------------
744 */
745CsrResult
746CsrSdioHardReset(CsrSdioFunction *function)
747{
748 return CSR_RESULT_FAILURE;
749} /* CsrSdioHardReset() */
750
751
752
753/*
754 * ---------------------------------------------------------------------------
755 * uf_glue_sdio_int_handler
756 *
757 * Interrupt callback function for SDIO interrupts.
758 * This is called in kernel context (i.e. not interrupt context).
759 *
760 * Arguments:
761 * func SDIO context pointer
762 *
763 * Returns:
764 * None.
765 *
766 * Note: Called with host already claimed.
767 * ---------------------------------------------------------------------------
768 */
769static void
770uf_glue_sdio_int_handler(struct sdio_func *func)
771{
772 CsrSdioFunction *sdio_ctx;
773 CsrSdioInterruptDsrCallback func_dsr_callback;
774 int r;
775
776 sdio_ctx = sdio_get_drvdata(func);
777 if (!sdio_ctx) {
778 return;
779 }
780
781#ifndef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
782 /*
783 * Normally, we are not allowed to do any SDIO commands here.
784 * However, this is called in a thread context and with the SDIO lock
785 * so we disable the interrupts here instead of trying to do complicated
786 * things with the SDIO lock.
787 */
788#ifdef MMC_QUIRK_LENIENT_FN0
789 sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &r);
790#else
791 r = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL);
792#endif
793 if (r) {
794 printk(KERN_ERR "UniFi MMC Int handler: Failed to disable interrupts %d\n", r);
795 }
796#endif
797
798 /* If the function driver has registered a handler, call it */
799 if (sdio_func_drv && sdio_func_drv->intr) {
800
801 func_dsr_callback = sdio_func_drv->intr(sdio_ctx);
802
803 /* If interrupt handle returns a DSR handle, call it */
804 if (func_dsr_callback) {
805 func_dsr_callback(sdio_ctx);
806 }
807 }
808
809} /* uf_glue_sdio_int_handler() */
810
811
812
813/*
814 * ---------------------------------------------------------------------------
815 * csr_sdio_linux_remove_irq
816 *
817 * Unregister the interrupt handler.
818 * This means that the linux layer can not process interrupts any more.
819 *
820 * Arguments:
821 * sdio SDIO context pointer
822 *
823 * Returns:
824 * Status of the removal.
825 * ---------------------------------------------------------------------------
826 */
827int csr_sdio_linux_remove_irq(CsrSdioFunction *function)
828{
829 struct sdio_func *func = (struct sdio_func *)function->priv;
830 int r;
831
832 unifi_trace(NULL, UDBG1, "csr_sdio_linux_remove_irq\n");
833
834 sdio_claim_host(func);
835 r = sdio_release_irq(func);
836 sdio_release_host(func);
837
838 return r;
839
840} /* csr_sdio_linux_remove_irq() */
841
842
843/*
844 * ---------------------------------------------------------------------------
845 * csr_sdio_linux_install_irq
846 *
847 * Register the interrupt handler.
848 * This means that the linux layer can process interrupts.
849 *
850 * Arguments:
851 * sdio SDIO context pointer
852 *
853 * Returns:
854 * Status of the removal.
855 * ---------------------------------------------------------------------------
856 */
857int csr_sdio_linux_install_irq(CsrSdioFunction *function)
858{
859 struct sdio_func *func = (struct sdio_func *)function->priv;
860 int r;
861
862 unifi_trace(NULL, UDBG1, "csr_sdio_linux_install_irq\n");
863
864 /* Register our interrupt handle */
865 sdio_claim_host(func);
866 r = sdio_claim_irq(func, uf_glue_sdio_int_handler);
867 sdio_release_host(func);
868
869 /* If the interrupt was installed earlier, is fine */
870 if (r == -EBUSY)
871 r = 0;
872
873 return r;
874} /* csr_sdio_linux_install_irq() */
875
876#ifdef CONFIG_PM
877
878/*
879 * Power Management notifier
880 */
881struct uf_sdio_mmc_pm_notifier
882{
883 struct list_head list;
884
885 CsrSdioFunction *sdio_ctx;
886 struct notifier_block pm_notifier;
887};
888
889/* PM notifier list head */
890static struct uf_sdio_mmc_pm_notifier uf_sdio_mmc_pm_notifiers = {
891 .sdio_ctx = NULL,
892};
893
894/*
895 * ---------------------------------------------------------------------------
896 * uf_sdio_mmc_register_pm_notifier
897 * uf_sdio_mmc_unregister_pm_notifier
898 *
899 * Register/unregister for power management events. A list is used to
900 * allow multiple card instances to be supported.
901 *
902 * Arguments:
903 * sdio_ctx - CSR SDIO context to associate PM notifier to
904 *
905 * Returns:
906 * Register function returns NULL on error
907 * ---------------------------------------------------------------------------
908 */
909static struct uf_sdio_mmc_pm_notifier *
910uf_sdio_mmc_register_pm_notifier(CsrSdioFunction *sdio_ctx)
911{
912 /* Allocate notifier context for this card instance */
913 struct uf_sdio_mmc_pm_notifier *notifier_ctx = kmalloc(sizeof(struct uf_sdio_mmc_pm_notifier), GFP_KERNEL);
914
915 if (notifier_ctx)
916 {
917 notifier_ctx->sdio_ctx = sdio_ctx;
918 notifier_ctx->pm_notifier.notifier_call = uf_sdio_mmc_power_event;
919
920 list_add(&notifier_ctx->list, &uf_sdio_mmc_pm_notifiers.list);
921
922 if (register_pm_notifier(&notifier_ctx->pm_notifier)) {
923 printk(KERN_ERR "unifi: register_pm_notifier failed\n");
924 }
925 }
926
927 return notifier_ctx;
928}
929
930static void
931uf_sdio_mmc_unregister_pm_notifier(CsrSdioFunction *sdio_ctx)
932{
933 struct uf_sdio_mmc_pm_notifier *notifier_ctx;
934 struct list_head *node, *q;
935
936 list_for_each_safe(node, q, &uf_sdio_mmc_pm_notifiers.list) {
937 notifier_ctx = list_entry(node, struct uf_sdio_mmc_pm_notifier, list);
938
939 /* If it matches, unregister and free the notifier context */
940 if (notifier_ctx && notifier_ctx->sdio_ctx == sdio_ctx)
941 {
942 if (unregister_pm_notifier(&notifier_ctx->pm_notifier)) {
943 printk(KERN_ERR "unifi: unregister_pm_notifier failed\n");
944 }
945
946 /* Remove from list */
947 notifier_ctx->sdio_ctx = NULL;
948 list_del(node);
949 kfree(notifier_ctx);
950 }
951 }
952}
953
954/*
955 * ---------------------------------------------------------------------------
956 * uf_sdio_mmc_power_event
957 *
958 * Handler for power management events.
959 *
960 * We need to handle suspend/resume events while the userspace is unsuspended
961 * to allow the SME to run its suspend/resume state machines.
962 *
963 * Arguments:
964 * event event ID
965 *
966 * Returns:
967 * Status of the event handling
968 * ---------------------------------------------------------------------------
969 */
970static int
971uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr)
972{
973 struct uf_sdio_mmc_pm_notifier *notifier_ctx = container_of(this,
974 struct uf_sdio_mmc_pm_notifier,
975 pm_notifier);
976
977 /* Call the CSR SDIO function driver's suspend/resume method
978 * while the userspace is unsuspended.
979 */
980 switch (event) {
981 case PM_POST_HIBERNATION:
982 case PM_POST_SUSPEND:
983 printk(KERN_INFO "%s:%d resume\n", __FUNCTION__, __LINE__ );
984 if (sdio_func_drv && sdio_func_drv->resume) {
985 sdio_func_drv->resume(notifier_ctx->sdio_ctx);
986 }
987 break;
988
989 case PM_HIBERNATION_PREPARE:
990 case PM_SUSPEND_PREPARE:
991 printk(KERN_INFO "%s:%d suspend\n", __FUNCTION__, __LINE__ );
992 if (sdio_func_drv && sdio_func_drv->suspend) {
993 sdio_func_drv->suspend(notifier_ctx->sdio_ctx);
994 }
995 break;
996 }
997 return NOTIFY_DONE;
998}
999
1000#endif /* CONFIG_PM */
1001
1002/*
1003 * ---------------------------------------------------------------------------
1004 * uf_glue_sdio_probe
1005 *
1006 * Card insert callback.
1007 *
1008 * Arguments:
1009 * func Our (glue layer) context pointer.
1010 *
1011 * Returns:
1012 * UniFi driver error code.
1013 * ---------------------------------------------------------------------------
1014 */
1015static int
1016uf_glue_sdio_probe(struct sdio_func *func,
1017 const struct sdio_device_id *id)
1018{
1019 int instance;
1020 CsrSdioFunction *sdio_ctx;
1021
1022 /* First of all claim the SDIO driver */
1023 sdio_claim_host(func);
1024
1025 /* Assume that the card is already powered */
1026 card_is_powered = 1;
1027
1028 /* Assumes one card per host, which is true for SDIO */
1029 instance = func->card->host->index;
1030 printk("sdio bus_id: %16s - UniFi card 0x%X inserted\n",
1031 sdio_func_id(func), instance);
1032
1033 /* Allocate context */
1034 sdio_ctx = kmalloc(sizeof(CsrSdioFunction), GFP_KERNEL);
1035 if (sdio_ctx == NULL) {
1036 sdio_release_host(func);
1037 return -ENOMEM;
1038 }
1039
1040 /* Initialise the context */
1041 sdio_ctx->sdioId.manfId = func->vendor;
1042 sdio_ctx->sdioId.cardId = func->device;
1043 sdio_ctx->sdioId.sdioFunction = func->num;
1044 sdio_ctx->sdioId.sdioInterface = func->class;
1045 sdio_ctx->blockSize = func->cur_blksize;
1046 sdio_ctx->priv = (void *)func;
1047 sdio_ctx->features = 0;
1048
1049 /* Module parameter enables byte mode */
1050 if (sdio_byte_mode) {
1051 sdio_ctx->features |= CSR_SDIO_FEATURE_BYTE_MODE;
1052 }
1053
1054 if (func->card->host->caps & MMC_CAP_SD_HIGHSPEED) {
1055 unifi_trace(NULL, UDBG1, "MMC_CAP_SD_HIGHSPEED is available\n");
1056 }
1057
1058#ifdef MMC_QUIRK_LENIENT_FN0
1059 func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
1060#endif
1061
1062 /* Pass context to the SDIO driver */
1063 sdio_set_drvdata(func, sdio_ctx);
1064
1065#ifdef CONFIG_PM
1066 /* Register to get PM events */
1067 if (uf_sdio_mmc_register_pm_notifier(sdio_ctx) == NULL) {
1068 unifi_error(NULL, "%s: Failed to register for PM events\n", __FUNCTION__);
1069 }
1070#endif
1071
1072 /* Register this device with the SDIO function driver */
1073 /* Call the main UniFi driver inserted handler */
1074 if (sdio_func_drv && sdio_func_drv->inserted) {
1075 uf_add_os_device(instance, &func->dev);
1076 sdio_func_drv->inserted(sdio_ctx);
1077 }
1078
1079 /* We have finished, so release the SDIO driver */
1080 sdio_release_host(func);
1081
1082#ifdef ANDROID_BUILD
1083 /* Take the wakelock */
1084 unifi_trace(NULL, UDBG1, "probe: take wake lock\n");
1085 wake_lock(&unifi_sdio_wake_lock);
1086#endif
1087
1088 return 0;
1089} /* uf_glue_sdio_probe() */
1090
1091
1092/*
1093 * ---------------------------------------------------------------------------
1094 * uf_glue_sdio_remove
1095 *
1096 * Card removal callback.
1097 *
1098 * Arguments:
1099 * func Our (glue layer) context pointer.
1100 *
1101 * Returns:
1102 * UniFi driver error code.
1103 * ---------------------------------------------------------------------------
1104 */
1105static void
1106uf_glue_sdio_remove(struct sdio_func *func)
1107{
1108 CsrSdioFunction *sdio_ctx;
1109
1110 sdio_ctx = sdio_get_drvdata(func);
1111 if (!sdio_ctx) {
1112 return;
1113 }
1114
1115 unifi_info(NULL, "UniFi card removed\n");
1116
1117 /* Clean up the SDIO function driver */
1118 if (sdio_func_drv && sdio_func_drv->removed) {
1119 uf_remove_os_device(func->card->host->index);
1120 sdio_func_drv->removed(sdio_ctx);
1121 }
1122
1123#ifdef CONFIG_PM
1124 /* Unregister for PM events */
1125 uf_sdio_mmc_unregister_pm_notifier(sdio_ctx);
1126#endif
1127
1128 kfree(sdio_ctx);
1129
1130} /* uf_glue_sdio_remove */
1131
1132
1133/*
1134 * SDIO ids *must* be statically declared, so we can't take
1135 * them from the list passed in csr_sdio_register_driver().
1136 */
1137static const struct sdio_device_id unifi_ids[] = {
1138 { SDIO_DEVICE(SDIO_MANF_ID_CSR, SDIO_CARD_ID_UNIFI_3) },
1139 { SDIO_DEVICE(SDIO_MANF_ID_CSR, SDIO_CARD_ID_UNIFI_4) },
1140 { /* end: all zeroes */ },
1141};
1142
1143MODULE_DEVICE_TABLE(sdio, unifi_ids);
1144
1145#ifdef CONFIG_PM
1146
1147/*
1148 * ---------------------------------------------------------------------------
1149 * uf_glue_sdio_suspend
1150 *
1151 * Card suspend callback. The userspace will already be suspended.
1152 *
1153 * Arguments:
1154 * dev The struct device owned by the MMC driver
1155 *
1156 * Returns:
1157 * None
1158 * ---------------------------------------------------------------------------
1159 */
1160static int
1161uf_glue_sdio_suspend(struct device *dev)
1162{
1163 unifi_trace(NULL, UDBG1, "uf_glue_sdio_suspend");
1164
1165 return 0;
1166} /* uf_glue_sdio_suspend */
1167
1168
1169/*
1170 * ---------------------------------------------------------------------------
1171 * uf_glue_sdio_resume
1172 *
1173 * Card resume callback. The userspace will still be suspended.
1174 *
1175 * Arguments:
1176 * dev The struct device owned by the MMC driver
1177 *
1178 * Returns:
1179 * None
1180 * ---------------------------------------------------------------------------
1181 */
1182static int
1183uf_glue_sdio_resume(struct device *dev)
1184{
1185 unifi_trace(NULL, UDBG1, "uf_glue_sdio_resume");
1186
1187#ifdef ANDROID_BUILD
1188 unifi_trace(NULL, UDBG1, "resume: take wakelock\n");
1189 wake_lock(&unifi_sdio_wake_lock);
1190#endif
1191
1192 return 0;
1193
1194} /* uf_glue_sdio_resume */
1195
1196static struct dev_pm_ops unifi_pm_ops = {
1197 .suspend = uf_glue_sdio_suspend,
1198 .resume = uf_glue_sdio_resume,
1199};
1200
1201#define UNIFI_PM_OPS (&unifi_pm_ops)
1202
1203#else
1204
1205#define UNIFI_PM_OPS NULL
1206
1207#endif /* CONFIG_PM */
1208
1209static struct sdio_driver unifi_driver = {
1210 .probe = uf_glue_sdio_probe,
1211 .remove = uf_glue_sdio_remove,
1212 .name = "unifi",
1213 .id_table = unifi_ids,
1214 .drv.pm = UNIFI_PM_OPS,
1215};
1216
1217
1218/*
1219 * ---------------------------------------------------------------------------
1220 * CsrSdioFunctionDriverRegister
1221 * CsrSdioFunctionDriverUnregister
1222 *
1223 * These functions are called from the main module load and unload
1224 * functions. They perform the appropriate operations for the
1225 * linux MMC/SDIO driver.
1226 *
1227 * Arguments:
1228 * sdio_drv Pointer to the function driver's SDIO structure.
1229 *
1230 * Returns:
1231 * None.
1232 * ---------------------------------------------------------------------------
1233 */
1234CsrResult
1235CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *sdio_drv)
1236{
1237 int r;
1238
1239 printk("UniFi: Using native Linux MMC driver for SDIO.\n");
1240
1241 if (sdio_func_drv) {
1242 unifi_error(NULL, "sdio_mmc: UniFi driver already registered\n");
1243 return CSR_SDIO_RESULT_INVALID_VALUE;
1244 }
1245
1246#ifdef ANDROID_BUILD
1247 wake_lock_init(&unifi_sdio_wake_lock, WAKE_LOCK_SUSPEND, "unifi_sdio_work");
1248#endif
1249
1250 /* Save the registered driver description */
1251 /*
1252 * FIXME:
1253 * Need a table here to handle a call to register for just one function.
1254 * mmc only allows us to register for the whole device
1255 */
1256 sdio_func_drv = sdio_drv;
1257
1258#ifdef CONFIG_PM
1259 /* Initialise PM notifier list */
1260 INIT_LIST_HEAD(&uf_sdio_mmc_pm_notifiers.list);
1261#endif
1262
1263 /* Register ourself with mmc_core */
1264 r = sdio_register_driver(&unifi_driver);
1265 if (r) {
1266 printk(KERN_ERR "unifi_sdio: Failed to register UniFi SDIO driver: %d\n", r);
1267 return ConvertSdioToCsrSdioResult(r);
1268 }
1269
1270 return CSR_RESULT_SUCCESS;
1271} /* CsrSdioFunctionDriverRegister() */
1272
1273
1274
1275void
1276CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *sdio_drv)
1277{
1278 printk(KERN_INFO "UniFi: unregister from MMC sdio\n");
1279
1280#ifdef ANDROID_BUILD
1281 wake_lock_destroy(&unifi_sdio_wake_lock);
1282#endif
1283 sdio_unregister_driver(&unifi_driver);
1284
1285 sdio_func_drv = NULL;
1286
1287} /* CsrSdioFunctionDriverUnregister() */
1288
diff --git a/drivers/staging/csr/sdio_stubs.c b/drivers/staging/csr/sdio_stubs.c
deleted file mode 100644
index 839fae01d96c..000000000000
--- a/drivers/staging/csr/sdio_stubs.c
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Stubs for some of the bottom edge functions.
3 *
4 * These stubs are optional functions in the bottom edge (SDIO driver
5 * interface) API that not all platforms or SDIO drivers may support.
6 *
7 * They're declared as weak symbols so they can be overridden by
8 * simply providing a non-weak declaration.
9 *
10 * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 */
16#include "csr_wifi_hip_unifi.h"
17
18void __attribute__((weak)) CsrSdioFunctionIdle(CsrSdioFunction *function)
19{
20}
21
22void __attribute__((weak)) CsrSdioFunctionActive(CsrSdioFunction *function)
23{
24}
25
26CsrResult __attribute__((weak)) CsrSdioPowerOn(CsrSdioFunction *function)
27{
28 return CSR_RESULT_SUCCESS;
29}
30
31void __attribute__((weak)) CsrSdioPowerOff(CsrSdioFunction *function)
32{
33}
34
35CsrResult __attribute__((weak)) CsrSdioHardReset(CsrSdioFunction *function)
36{
37 return CSR_SDIO_RESULT_NOT_RESET;
38}
39
40CsrResult __attribute__((weak)) CsrSdioBlockSizeSet(CsrSdioFunction *function,
41 u16 blockSize)
42{
43 return CSR_RESULT_SUCCESS;
44}
45
46CsrResult __attribute__((weak)) CsrSdioSuspend(CsrSdioFunction *function)
47{
48 return CSR_RESULT_SUCCESS;
49}
50
51CsrResult __attribute__((weak)) CsrSdioResume(CsrSdioFunction *function)
52{
53 return CSR_RESULT_SUCCESS;
54}
55
56int __attribute__((weak)) csr_sdio_linux_install_irq(CsrSdioFunction *function)
57{
58 return 0;
59}
60
61int __attribute__((weak)) csr_sdio_linux_remove_irq(CsrSdioFunction *function)
62{
63 return 0;
64}
65
66void __attribute__((weak)) CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result)
67{
68}
69
70void __attribute__((weak)) CsrSdioRemovedAcknowledge(CsrSdioFunction *function)
71{
72}
73
74void __attribute__((weak)) CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result)
75{
76}
77
78void __attribute__((weak)) CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result)
79{
80}
81
82
diff --git a/drivers/staging/csr/sme_blocking.c b/drivers/staging/csr/sme_blocking.c
deleted file mode 100644
index 0c6e21636e7f..000000000000
--- a/drivers/staging/csr/sme_blocking.c
+++ /dev/null
@@ -1,1466 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: sme_mgt_blocking.c
4 *
5 * PURPOSE:
6 * This file contains the driver specific implementation of
7 * the WEXT <==> SME MGT interface for all SME builds that support WEXT.
8 *
9 * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16
17#include "unifi_priv.h"
18
19
20/*
21 * This file also contains the implementation of the asynchronous
22 * requests to the SME.
23 *
24 * Before calling an asynchronous SME function, we call sme_init_request()
25 * which gets hold of the SME semaphore and updates the request status.
26 * The semaphore makes sure that there is only one pending request to
27 * the SME at a time.
28 *
29 * Now we are ready to call the SME function, but only if
30 * sme_init_request() has returned 0.
31 *
32 * When the SME function returns, we need to wait
33 * for the reply. This is done in sme_wait_for_reply().
34 * If the request times-out, the request status is set to SME_REQUEST_TIMEDOUT
35 * and the sme_wait_for_reply() returns.
36 *
37 * If the SME replies in time, we call sme_complete_request().
38 * There we change the request status to SME_REQUEST_RECEIVED. This will
39 * wake up the process waiting on sme_wait_for_reply().
40 * It is important that we copy the reply data in priv->sme_reply
41 * before calling sme_complete_request().
42 *
43 * Handling the wext requests, we need to block
44 * until the SME sends the response to our request.
45 * We use the sme_init_request() and sme_wait_for_reply()
46 * to implement this behavior in the following functions:
47 * sme_mgt_wifi_on()
48 * sme_mgt_wifi_off()
49 * sme_mgt_scan_full()
50 * sme_mgt_scan_results_get_async()
51 * sme_mgt_connect()
52 * unifi_mgt_media_status_ind()
53 * sme_mgt_disconnect()
54 * sme_mgt_pmkid()
55 * sme_mgt_key()
56 * sme_mgt_mib_get()
57 * sme_mgt_mib_set()
58 * sme_mgt_versions_get()
59 * sme_mgt_set_value()
60 * sme_mgt_get_value()
61 * sme_mgt_set_value_async()
62 * sme_mgt_get_value_async()
63 * sme_mgt_packet_filter_set()
64 * sme_mgt_tspec()
65 */
66
67
68/*
69 * Handling the suspend and resume system events, we need to block
70 * until the SME sends the response to our indication.
71 * We use the sme_init_request() and sme_wait_for_reply()
72 * to implement this behavior in the following functions:
73 * sme_sys_suspend()
74 * sme_sys_resume()
75 */
76
77#define UNIFI_SME_MGT_SHORT_TIMEOUT 10000
78#define UNIFI_SME_MGT_LONG_TIMEOUT 19000
79#define UNIFI_SME_SYS_LONG_TIMEOUT 10000
80
81#ifdef UNIFI_DEBUG
82# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, __func__)
83#else
84# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, NULL)
85#endif
86
87static int
88sme_init_request(unifi_priv_t *priv)
89{
90 if (priv == NULL) {
91 unifi_error(priv, "sme_init_request: Invalid priv\n");
92 return -EIO;
93 }
94
95 unifi_trace(priv, UDBG5, "sme_init_request: wait sem\n");
96
97 /* Grab the SME semaphore until the reply comes, or timeout */
98 if (down_interruptible(&priv->sme_sem)) {
99 unifi_error(priv, "sme_init_request: Failed to get SME semaphore\n");
100 return -EIO;
101 }
102 unifi_trace(priv, UDBG5, "sme_init_request: got sem: pending\n");
103
104 priv->sme_reply.request_status = SME_REQUEST_PENDING;
105
106 return 0;
107
108} /* sme_init_request() */
109
110
111void
112uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func)
113{
114 if (priv == NULL) {
115 unifi_error(priv, "sme_complete_request: Invalid priv\n");
116 return;
117 }
118
119 if (priv->sme_reply.request_status != SME_REQUEST_PENDING) {
120 unifi_notice(priv,
121 "sme_complete_request: request not pending %s (s:%d)\n",
122 (func ? func : ""), priv->sme_reply.request_status);
123 return;
124 }
125 unifi_trace(priv, UDBG5,
126 "sme_complete_request: completed %s (s:%d)\n",
127 (func ? func : ""), priv->sme_reply.request_status);
128
129 priv->sme_reply.request_status = SME_REQUEST_RECEIVED;
130 priv->sme_reply.reply_status = reply_status;
131
132 wake_up_interruptible(&priv->sme_request_wq);
133
134 return;
135}
136
137
138void
139uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status)
140{
141 /* Check for a blocking SME request in progress, and cancel the wait.
142 * This should be used when the character device is closed.
143 */
144
145 if (priv == NULL) {
146 unifi_error(priv, "sme_cancel_request: Invalid priv\n");
147 return;
148 }
149
150 /* If no request is pending, nothing to wake up */
151 if (priv->sme_reply.request_status != SME_REQUEST_PENDING) {
152 unifi_trace(priv, UDBG5,
153 "sme_cancel_request: no request was pending (s:%d)\n",
154 priv->sme_reply.request_status);
155 /* Nothing to do */
156 return;
157 }
158 unifi_trace(priv, UDBG5,
159 "sme_cancel_request: request cancelled (s:%d)\n",
160 priv->sme_reply.request_status);
161
162 /* Wake up the wait with an error status */
163 priv->sme_reply.request_status = SME_REQUEST_CANCELLED;
164 priv->sme_reply.reply_status = reply_status; /* unimportant since the CANCELLED state will fail the ioctl */
165
166 wake_up_interruptible(&priv->sme_request_wq);
167
168 return;
169}
170
171
172static int
173_sme_wait_for_reply(unifi_priv_t *priv,
174 unsigned long timeout, const char *func)
175{
176 long r;
177
178 unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s sleep\n", func ? func : "");
179 r = wait_event_interruptible_timeout(priv->sme_request_wq,
180 (priv->sme_reply.request_status != SME_REQUEST_PENDING),
181 msecs_to_jiffies(timeout));
182 unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s awake (%d)\n", func ? func : "", r);
183
184 if (r == -ERESTARTSYS) {
185 /* The thread was killed */
186 unifi_info(priv, "ERESTARTSYS in _sme_wait_for_reply\n");
187 up(&priv->sme_sem);
188 return r;
189 }
190 if (priv->sme_reply.request_status == SME_REQUEST_CANCELLED) {
191 unifi_trace(priv, UDBG5, "Cancelled waiting for SME to reply (%s s:%d, t:%d, r:%d)\n",
192 (func ? func : ""), priv->sme_reply.request_status, timeout, r);
193
194 /* Release the SME semaphore that was downed in sme_init_request() */
195 up(&priv->sme_sem);
196 return -EIO; /* fail the ioctl */
197 }
198 if ((r == 0) && (priv->sme_reply.request_status != SME_REQUEST_RECEIVED)) {
199 unifi_notice(priv, "Timeout waiting for SME to reply (%s s:%d, t:%d)\n",
200 (func ? func : ""), priv->sme_reply.request_status, timeout);
201
202 priv->sme_reply.request_status = SME_REQUEST_TIMEDOUT;
203
204 /* Release the SME semaphore that was downed in sme_init_request() */
205 up(&priv->sme_sem);
206
207 return -ETIMEDOUT;
208 }
209
210 unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s received (%d)\n",
211 func ? func : "", r);
212
213 /* Release the SME semaphore that was downed in sme_init_request() */
214 up(&priv->sme_sem);
215
216 return 0;
217} /* sme_wait_for_reply() */
218
219
220
221
222#ifdef CSR_SUPPORT_WEXT
223int sme_mgt_wifi_on(unifi_priv_t *priv)
224{
225 u16 numElements;
226 CsrWifiSmeDataBlock* dataList;
227#ifdef CSR_SUPPORT_WEXT_AP
228 int r;
229#endif
230
231 if (priv->smepriv == NULL) {
232 unifi_error(priv, "sme_mgt_wifi_on: invalid smepriv\n");
233 return -EIO;
234 }
235
236 if (priv->mib_data.length) {
237 numElements = 1;
238 dataList = &priv->mib_data;
239 } else {
240 numElements = 0;
241 dataList = NULL;
242 }
243 /* Start the SME */
244#ifdef CSR_SUPPORT_WEXT_AP
245 r = sme_init_request(priv);
246 if (r) {
247 return -EIO;
248 }
249#endif
250 CsrWifiSmeWifiOnReqSend(0, priv->sta_mac_address, numElements, dataList);
251#ifdef CSR_SUPPORT_WEXT_AP
252 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
253 unifi_trace(priv, UDBG4,
254 "sme_mgt_wifi_on: unifi_mgt_wifi_oo_req <-- (r=%d, status=%d)\n",
255 r, priv->sme_reply.reply_status);
256 return convert_sme_error(priv->sme_reply.reply_status);
257#else
258 return 0;
259#endif
260} /* sme_mgt_wifi_on() */
261
262
263int sme_mgt_wifi_off(unifi_priv_t *priv)
264{
265 int r;
266
267 if (priv->smepriv == NULL) {
268 unifi_error(priv, "sme_mgt_wifi_off: invalid smepriv\n");
269 return -EIO;
270 }
271
272 r = sme_init_request(priv);
273 if (r)
274 return -EIO;
275
276 /* Stop the SME */
277 CsrWifiSmeWifiOffReqSend(0);
278
279 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
280 if (r)
281 return r;
282
283 unifi_trace(priv, UDBG4,
284 "sme_mgt_wifi_off: unifi_mgt_wifi_off_req <-- (r=%d, status=%d)\n",
285 r, priv->sme_reply.reply_status);
286 return convert_sme_error(priv->sme_reply.reply_status);
287
288} /* sme_mgt_wifi_off */
289
290int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
291 CsrWifiSmeListAction action)
292{
293 int r;
294
295 if (priv->smepriv == NULL) {
296 unifi_error(priv, "sme_mgt_key: invalid smepriv\n");
297 return -EIO;
298 }
299
300 r = sme_init_request(priv);
301 if (r)
302 return -EIO;
303
304 CsrWifiSmeKeyReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action, *sme_key);
305
306 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
307 if (r)
308 return r;
309
310 return convert_sme_error(priv->sme_reply.reply_status);
311}
312
313
314int sme_mgt_scan_full(unifi_priv_t *priv,
315 CsrWifiSsid *specific_ssid,
316 int num_channels,
317 unsigned char *channel_list)
318{
319 CsrWifiMacAddress bcastAddress = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
320 u8 is_active = (num_channels > 0) ? TRUE : FALSE;
321 int r;
322
323 if (priv->smepriv == NULL) {
324 unifi_error(priv, "sme_mgt_scan_full: invalid smepriv\n");
325 return -EIO;
326 }
327
328 unifi_trace(priv, UDBG4, "sme_mgt_scan_full: -->\n");
329
330 r = sme_init_request(priv);
331 if (r)
332 return -EIO;
333
334 /* If a channel list is provided, do an active scan */
335 if (is_active) {
336 unifi_trace(priv, UDBG1,
337 "channel list - num_channels: %d, active scan\n",
338 num_channels);
339 }
340
341 CsrWifiSmeScanFullReqSend(0,
342 specific_ssid->length?1:0, /* 0 or 1 SSIDS */
343 specific_ssid,
344 bcastAddress,
345 is_active,
346 CSR_WIFI_SME_BSS_TYPE_ANY_BSS,
347 CSR_WIFI_SME_SCAN_TYPE_ALL,
348 (u16)num_channels, channel_list,
349 0, NULL);
350
351 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
352 if (r)
353 return r;
354
355 unifi_trace(priv, UDBG4, "sme_mgt_scan_full: <-- (status=%d)\n", priv->sme_reply.reply_status);
356 if (priv->sme_reply.reply_status == CSR_WIFI_RESULT_UNAVAILABLE)
357 return 0; /* initial scan already underway */
358 else
359 return convert_sme_error(priv->sme_reply.reply_status);
360}
361
362
363int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
364 struct iw_request_info *info,
365 char *scan_results,
366 long scan_results_len)
367{
368 u16 scan_result_list_count;
369 CsrWifiSmeScanResult *scan_result_list;
370 CsrWifiSmeScanResult *scan_result;
371 int r;
372 int i;
373 char *current_ev = scan_results;
374
375 if (priv->smepriv == NULL) {
376 unifi_error(priv, "sme_mgt_scan_results_get_async: invalid smepriv\n");
377 return -EIO;
378 }
379
380 r = sme_init_request(priv);
381 if (r)
382 return -EIO;
383
384 CsrWifiSmeScanResultsGetReqSend(0);
385 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
386 if (r)
387 return r;
388
389 scan_result_list_count = priv->sme_reply.reply_scan_results_count;
390 scan_result_list = priv->sme_reply.reply_scan_results;
391 unifi_trace(priv, UDBG2,
392 "scan_results: Scan returned %d, numElements=%d\n",
393 r, scan_result_list_count);
394
395 /* OK, now we have the scan results */
396 for (i = 0; i < scan_result_list_count; ++i) {
397 scan_result = &scan_result_list[i];
398
399 unifi_trace(priv, UDBG2, "Scan Result: %.*s\n",
400 scan_result->ssid.length,
401 scan_result->ssid.ssid);
402
403 r = unifi_translate_scan(priv->netdev[0], info,
404 current_ev,
405 scan_results + scan_results_len,
406 scan_result, i+1);
407
408 if (r < 0) {
409 kfree(scan_result_list);
410 priv->sme_reply.reply_scan_results_count = 0;
411 priv->sme_reply.reply_scan_results = NULL;
412 return r;
413 }
414
415 current_ev += r;
416 }
417
418 /*
419 * Free the scan results allocated in unifi_mgt_scan_results_get_cfm()
420 * and invalidate the reply_scan_results to avoid re-using
421 * the freed pointers.
422 */
423 kfree(scan_result_list);
424 priv->sme_reply.reply_scan_results_count = 0;
425 priv->sme_reply.reply_scan_results = NULL;
426
427 unifi_trace(priv, UDBG2,
428 "scan_results: Scan translated to %d bytes\n",
429 current_ev - scan_results);
430 return (current_ev - scan_results);
431}
432
433
434int sme_mgt_connect(unifi_priv_t *priv)
435{
436 int r;
437
438 if (priv->smepriv == NULL) {
439 unifi_error(priv, "sme_mgt_connect: invalid smepriv\n");
440 return -EIO;
441 }
442
443 unifi_trace(priv, UDBG2, "sme_mgt_connect: %.*s\n",
444 priv->connection_config.ssid.length,
445 priv->connection_config.ssid.ssid);
446
447 r = sme_init_request(priv);
448 if (r)
449 return -EIO;
450
451 CsrWifiSmeConnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE, priv->connection_config);
452 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
453 if (r)
454 return r;
455
456 if (priv->sme_reply.reply_status)
457 unifi_trace(priv, UDBG1, "sme_mgt_connect: failed with SME status %d\n",
458 priv->sme_reply.reply_status);
459
460 return convert_sme_error(priv->sme_reply.reply_status);
461}
462
463
464int sme_mgt_disconnect(unifi_priv_t *priv)
465{
466 int r;
467
468 if (priv->smepriv == NULL) {
469 unifi_error(priv, "sme_mgt_disconnect: invalid smepriv\n");
470 return -EIO;
471 }
472
473 r = sme_init_request(priv);
474 if (r)
475 return -EIO;
476
477 CsrWifiSmeDisconnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
478 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
479 if (r)
480 return r;
481
482 unifi_trace(priv, UDBG4, "sme_mgt_disconnect: <-- (status=%d)\n", priv->sme_reply.reply_status);
483 return convert_sme_error(priv->sme_reply.reply_status);
484}
485
486
487int sme_mgt_pmkid(unifi_priv_t *priv,
488 CsrWifiSmeListAction action,
489 CsrWifiSmePmkidList *pmkid_list)
490{
491 int r;
492
493 if (priv->smepriv == NULL) {
494 unifi_error(priv, "sme_mgt_pmkid: invalid smepriv\n");
495 return -EIO;
496 }
497
498 r = sme_init_request(priv);
499 if (r)
500 return -EIO;
501
502 CsrWifiSmePmkidReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action,
503 pmkid_list->pmkidsCount, pmkid_list->pmkids);
504 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
505 if (r)
506 return r;
507
508 unifi_trace(priv, UDBG4, "sme_mgt_pmkid: <-- (status=%d)\n", priv->sme_reply.reply_status);
509 return convert_sme_error(priv->sme_reply.reply_status);
510}
511
512
513int sme_mgt_mib_get(unifi_priv_t *priv,
514 unsigned char *varbind, int *length)
515{
516 int r;
517
518 if (priv->smepriv == NULL) {
519 unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n");
520 return -EIO;
521 }
522
523 r = sme_init_request(priv);
524 if (r)
525 return -EIO;
526
527 priv->mib_cfm_buffer = varbind;
528 priv->mib_cfm_buffer_length = MAX_VARBIND_LENGTH;
529
530 CsrWifiSmeMibGetReqSend(0, *length, varbind);
531 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
532 if (r) {
533 priv->mib_cfm_buffer_length = 0;
534 priv->mib_cfm_buffer = NULL;
535 return r;
536 }
537
538 *length = priv->mib_cfm_buffer_length;
539
540 priv->mib_cfm_buffer_length = 0;
541 priv->mib_cfm_buffer = NULL;
542 unifi_trace(priv, UDBG4, "sme_mgt_mib_get: <-- (status=%d)\n", priv->sme_reply.reply_status);
543 return convert_sme_error(priv->sme_reply.reply_status);
544}
545
546int sme_mgt_mib_set(unifi_priv_t *priv,
547 unsigned char *varbind, int length)
548{
549 int r;
550
551 if (priv->smepriv == NULL) {
552 unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n");
553 return -EIO;
554 }
555
556 r = sme_init_request(priv);
557 if (r)
558 return -EIO;
559
560 CsrWifiSmeMibSetReqSend(0, length, varbind);
561 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
562 if (r)
563 return r;
564
565 unifi_trace(priv, UDBG4, "sme_mgt_mib_set: <-- (status=%d)\n", priv->sme_reply.reply_status);
566 return convert_sme_error(priv->sme_reply.reply_status);
567}
568
569#endif /* CSR_SUPPORT_WEXT */
570
571int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig)
572{
573#ifdef CSR_SME_USERSPACE
574 int r;
575
576 if (priv->smepriv == NULL) {
577 unifi_error(priv, "sme_mgt_set_value_async: invalid smepriv\n");
578 return -EIO;
579 }
580
581 r = sme_init_request(priv);
582 if (r)
583 return -EIO;
584
585 CsrWifiSmePowerConfigSetReqSend(0, *powerConfig);
586
587 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
588 if (r)
589 return r;
590
591 unifi_trace(priv, UDBG4,
592 "sme_mgt_set_value_async: unifi_mgt_set_value_req <-- (r=%d status=%d)\n",
593 r, priv->sme_reply.reply_status);
594 return convert_sme_error(priv->sme_reply.reply_status);
595#else
596 CsrResult status;
597 if (priv->smepriv == NULL) {
598 unifi_error(priv, "sme_mgt_set_value: invalid smepriv\n");
599 return -EIO;
600 }
601 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
602 status = CsrWifiSmeMgtPowerConfigSetReq(priv->smepriv, *powerConfig);
603 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
604 return convert_sme_error(status);
605#endif
606}
607
608int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig)
609{
610#ifdef CSR_SME_USERSPACE
611 int r;
612
613 if (priv->smepriv == NULL) {
614 unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n");
615 return -EIO;
616 }
617
618 r = sme_init_request(priv);
619 if (r)
620 return -EIO;
621
622 CsrWifiSmeSmeStaConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *staConfig);
623 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
624 if (r)
625 return r;
626
627 unifi_trace(priv, UDBG4,
628 "sme_mgt_sme_config_set: CsrWifiSmeSmeStaConfigSetReq <-- (r=%d status=%d)\n",
629 r, priv->sme_reply.reply_status);
630
631 r = sme_init_request(priv);
632 if (r)
633 return -EIO;
634
635 CsrWifiSmeSmeCommonConfigSetReqSend(0, *deviceConfig);
636 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
637 if (r)
638 return r;
639
640 unifi_trace(priv, UDBG4,
641 "sme_mgt_sme_config_set: CsrWifiSmeSmeCommonConfigSetReq <-- (r=%d status=%d)\n",
642 r, priv->sme_reply.reply_status);
643
644 return convert_sme_error(priv->sme_reply.reply_status);
645#else
646 CsrResult status;
647 if (priv->smepriv == NULL) {
648 unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n");
649 return -EIO;
650 }
651 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
652 status = CsrWifiSmeMgtSmeConfigSetReq(priv->smepriv, *staConfig);
653 status = CsrWifiSmeMgtDeviceConfigSetReq(priv->smepriv, *deviceConfig);
654 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
655 return convert_sme_error(status);
656#endif
657}
658
659#ifdef CSR_SUPPORT_WEXT
660
661int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
662{
663#ifdef CSR_SME_USERSPACE
664 int r;
665
666 if (priv->smepriv == NULL) {
667 unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n");
668 return -EIO;
669 }
670
671 r = sme_init_request(priv);
672 if (r)
673 return -EIO;
674
675 CsrWifiSmeMibConfigSetReqSend(0, *mibConfig);
676
677 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
678 if (r)
679 return r;
680
681 unifi_trace(priv, UDBG4,
682 "sme_mgt_mib_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
683 r, priv->sme_reply.reply_status);
684 return convert_sme_error(priv->sme_reply.reply_status);
685#else
686 CsrResult status;
687 if (priv->smepriv == NULL) {
688 unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n");
689 return -EIO;
690 }
691 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
692 status = CsrWifiSmeMgtMibConfigSetReq(priv->smepriv, *mibConfig);
693 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
694 return convert_sme_error(status);
695#endif
696}
697
698int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig)
699{
700#ifdef CSR_SME_USERSPACE
701 int r;
702
703 if (priv->smepriv == NULL) {
704 unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n");
705 return -EIO;
706 }
707
708 r = sme_init_request(priv);
709 if (r)
710 return -EIO;
711
712 CsrWifiSmeCoexConfigSetReqSend(0, *coexConfig);
713
714 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
715 if (r)
716 return r;
717
718 unifi_trace(priv, UDBG4,
719 "sme_mgt_coex_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
720 r, priv->sme_reply.reply_status);
721 return convert_sme_error(priv->sme_reply.reply_status);
722#else
723 CsrResult status;
724 if (priv->smepriv == NULL) {
725 unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n");
726 return -EIO;
727 }
728 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
729 status = CsrWifiSmeMgtCoexConfigSetReq(priv->smepriv, *coexConfig);
730 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
731 return convert_sme_error(status);
732#endif
733}
734
735#endif /* CSR_SUPPORT_WEXT */
736
737int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig)
738{
739#ifdef CSR_SME_USERSPACE
740 int r;
741
742 if (priv->smepriv == NULL) {
743 unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n");
744 return -EIO;
745 }
746
747 r = sme_init_request(priv);
748 if (r)
749 return -EIO;
750
751 CsrWifiSmeHostConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *hostConfig);
752
753 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
754 if (r)
755 return r;
756
757 unifi_trace(priv, UDBG4,
758 "sme_mgt_host_config_set: unifi_mgt_set_host_config_req <-- (r=%d status=%d)\n",
759 r, priv->sme_reply.reply_status);
760 return convert_sme_error(priv->sme_reply.reply_status);
761#else
762 CsrResult status;
763 if (priv->smepriv == NULL) {
764 unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n");
765 return -EIO;
766 }
767 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
768 status = CsrWifiSmeMgtHostConfigSetReq(priv->smepriv, *hostConfig);
769 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
770 return convert_sme_error(status);
771#endif
772}
773
774#ifdef CSR_SUPPORT_WEXT
775
776int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions)
777{
778#ifdef CSR_SME_USERSPACE
779 int r;
780
781 if (priv->smepriv == NULL) {
782 unifi_error(priv, "sme_mgt_versions_get: invalid smepriv\n");
783 return -EIO;
784 }
785
786 unifi_trace(priv, UDBG4, "sme_mgt_versions_get: unifi_mgt_versions_get_req -->\n");
787 r = sme_init_request(priv);
788 if (r)
789 return -EIO;
790
791 CsrWifiSmeVersionsGetReqSend(0);
792
793 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
794 if (r)
795 return r;
796
797 /* store the reply */
798 if (versions != NULL) {
799 memcpy((unsigned char*)versions,
800 (unsigned char*)&priv->sme_reply.versions,
801 sizeof(CsrWifiSmeVersions));
802 }
803
804 unifi_trace(priv, UDBG4,
805 "sme_mgt_versions_get: unifi_mgt_versions_get_req <-- (r=%d status=%d)\n",
806 r, priv->sme_reply.reply_status);
807
808 return convert_sme_error(priv->sme_reply.reply_status);
809#else
810 CsrResult status;
811 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
812 status = CsrWifiSmeMgtVersionsGetReq(priv->smepriv, versions);
813 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
814 return convert_sme_error(status);
815#endif
816}
817
818#endif /* CSR_SUPPORT_WEXT */
819
820int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig)
821{
822#ifdef CSR_SME_USERSPACE
823 int r;
824
825 if (priv->smepriv == NULL) {
826 unifi_error(priv, "sme_mgt_power_config_get: invalid smepriv\n");
827 return -EIO;
828 }
829
830 unifi_trace(priv, UDBG4, "sme_mgt_power_config_get: unifi_mgt_power_config_req -->\n");
831 r = sme_init_request(priv);
832 if (r)
833 return -EIO;
834
835 CsrWifiSmePowerConfigGetReqSend(0);
836
837 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
838 if (r)
839 return r;
840
841 /* store the reply */
842 if (powerConfig != NULL) {
843 memcpy((unsigned char*)powerConfig,
844 (unsigned char*)&priv->sme_reply.powerConfig,
845 sizeof(CsrWifiSmePowerConfig));
846 }
847
848 unifi_trace(priv, UDBG4,
849 "sme_mgt_get_versions: unifi_mgt_power_config_req <-- (r=%d status=%d)\n",
850 r, priv->sme_reply.reply_status);
851
852 return convert_sme_error(priv->sme_reply.reply_status);
853#else
854 CsrResult status;
855 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
856 status = CsrWifiSmeMgtPowerConfigGetReq(priv->smepriv, powerConfig);
857 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
858 return convert_sme_error(status);
859#endif
860}
861
862int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig)
863{
864#ifdef CSR_SME_USERSPACE
865 int r;
866
867 if (priv->smepriv == NULL) {
868 unifi_error(priv, "sme_mgt_host_config_get: invalid smepriv\n");
869 return -EIO;
870 }
871
872 unifi_trace(priv, UDBG4, "sme_mgt_host_config_get: unifi_mgt_host_config_get_req -->\n");
873 r = sme_init_request(priv);
874 if (r)
875 return -EIO;
876
877 CsrWifiSmeHostConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
878
879 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
880 if (r)
881 return r;
882
883 /* store the reply */
884 if (hostConfig != NULL)
885 memcpy((unsigned char*)hostConfig,
886 (unsigned char*)&priv->sme_reply.hostConfig,
887 sizeof(CsrWifiSmeHostConfig));
888
889 unifi_trace(priv, UDBG4,
890 "sme_mgt_host_config_get: unifi_mgt_host_config_get_req <-- (r=%d status=%d)\n",
891 r, priv->sme_reply.reply_status);
892
893 return convert_sme_error(priv->sme_reply.reply_status);
894#else
895 CsrResult status;
896 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
897 status = CsrWifiSmeMgtHostConfigGetReq(priv->smepriv, hostConfig);
898 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
899 return convert_sme_error(status);
900#endif
901}
902
903int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig)
904{
905#ifdef CSR_SME_USERSPACE
906 int r;
907
908 if (priv->smepriv == NULL) {
909 unifi_error(priv, "sme_mgt_sme_config_get: invalid smepriv\n");
910 return -EIO;
911 }
912
913 unifi_trace(priv, UDBG4, "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req -->\n");
914
915 /* Common device config */
916 r = sme_init_request(priv);
917 if (r)
918 return -EIO;
919
920 CsrWifiSmeSmeCommonConfigGetReqSend(0);
921 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
922 if (r)
923 return r;
924
925 /* store the reply */
926 if (deviceConfig != NULL)
927 memcpy((unsigned char*)deviceConfig,
928 (unsigned char*)&priv->sme_reply.deviceConfig,
929 sizeof(CsrWifiSmeDeviceConfig));
930
931 /* STA config */
932 r = sme_init_request(priv);
933 if (r)
934 return -EIO;
935
936 CsrWifiSmeSmeStaConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
937 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
938 if (r)
939 return r;
940
941 /* store the reply */
942 if (staConfig != NULL)
943 memcpy((unsigned char*)staConfig,
944 (unsigned char*)&priv->sme_reply.staConfig,
945 sizeof(CsrWifiSmeStaConfig));
946
947 unifi_trace(priv, UDBG4,
948 "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req <-- (r=%d status=%d)\n",
949 r, priv->sme_reply.reply_status);
950
951 return convert_sme_error(priv->sme_reply.reply_status);
952#else
953 CsrResult status;
954 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
955 status = CsrWifiSmeMgtSmeConfigGetReq(priv->smepriv, staConfig);
956 status = CsrWifiSmeMgtDeviceConfigGetReq(priv->smepriv, deviceConfig);
957 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
958 return convert_sme_error(status);
959#endif
960}
961
962int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo)
963{
964#ifdef CSR_SME_USERSPACE
965 int r;
966
967 if (priv->smepriv == NULL) {
968 unifi_error(priv, "sme_mgt_coex_info_get: invalid smepriv\n");
969 return -EIO;
970 }
971
972 unifi_trace(priv, UDBG4, "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req -->\n");
973 r = sme_init_request(priv);
974 if (r)
975 return -EIO;
976
977 CsrWifiSmeCoexInfoGetReqSend(0);
978
979 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
980 if (r)
981 return r;
982
983 /* store the reply */
984 if (coexInfo != NULL)
985 memcpy((unsigned char*)coexInfo,
986 (unsigned char*)&priv->sme_reply.coexInfo,
987 sizeof(CsrWifiSmeCoexInfo));
988
989 unifi_trace(priv, UDBG4,
990 "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req <-- (r=%d status=%d)\n",
991 r, priv->sme_reply.reply_status);
992
993 return convert_sme_error(priv->sme_reply.reply_status);
994#else
995 CsrResult status;
996 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
997 status = CsrWifiSmeMgtCoexInfoGetReq(priv->smepriv, coexInfo);
998 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
999 return convert_sme_error(status);
1000#endif
1001}
1002
1003#ifdef CSR_SUPPORT_WEXT
1004
1005int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig)
1006{
1007#ifdef CSR_SME_USERSPACE
1008 int r;
1009
1010 if (priv->smepriv == NULL) {
1011 unifi_error(priv, "sme_mgt_coex_config_get: invalid smepriv\n");
1012 return -EIO;
1013 }
1014
1015 unifi_trace(priv, UDBG4, "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req -->\n");
1016 r = sme_init_request(priv);
1017 if (r)
1018 return -EIO;
1019
1020 CsrWifiSmeCoexConfigGetReqSend(0);
1021
1022 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1023 if (r)
1024 return r;
1025
1026 /* store the reply */
1027 if (coexConfig != NULL)
1028 memcpy((unsigned char*)coexConfig,
1029 (unsigned char*)&priv->sme_reply.coexConfig,
1030 sizeof(CsrWifiSmeCoexConfig));
1031
1032 unifi_trace(priv, UDBG4,
1033 "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req <-- (r=%d status=%d)\n",
1034 r, priv->sme_reply.reply_status);
1035
1036 return convert_sme_error(priv->sme_reply.reply_status);
1037#else
1038 CsrResult status;
1039 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
1040 status = CsrWifiSmeMgtCoexConfigGetReq(priv->smepriv, coexConfig);
1041 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
1042 return convert_sme_error(status);
1043#endif
1044}
1045
1046int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
1047{
1048#ifdef CSR_SME_USERSPACE
1049 int r;
1050
1051 if (priv->smepriv == NULL) {
1052 unifi_error(priv, "sme_mgt_mib_config_get: invalid smepriv\n");
1053 return -EIO;
1054 }
1055
1056 unifi_trace(priv, UDBG4, "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req -->\n");
1057 r = sme_init_request(priv);
1058 if (r)
1059 return -EIO;
1060
1061 CsrWifiSmeMibConfigGetReqSend(0);
1062
1063 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1064 if (r)
1065 return r;
1066
1067 /* store the reply */
1068 if (mibConfig != NULL)
1069 memcpy((unsigned char*)mibConfig,
1070 (unsigned char*)&priv->sme_reply.mibConfig,
1071 sizeof(CsrWifiSmeMibConfig));
1072
1073 unifi_trace(priv, UDBG4,
1074 "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req <-- (r=%d status=%d)\n",
1075 r, priv->sme_reply.reply_status);
1076
1077 return convert_sme_error(priv->sme_reply.reply_status);
1078#else
1079 CsrResult status;
1080 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
1081 status = CsrWifiSmeMgtMibConfigGetReq(priv->smepriv, mibConfig);
1082 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
1083 return convert_sme_error(status);
1084#endif
1085}
1086
1087int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo)
1088{
1089#ifdef CSR_SME_USERSPACE
1090 int r;
1091
1092 if (priv->smepriv == NULL) {
1093 unifi_error(priv, "sme_mgt_connection_info_get: invalid smepriv\n");
1094 return -EIO;
1095 }
1096
1097 unifi_trace(priv, UDBG4, "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req -->\n");
1098 r = sme_init_request(priv);
1099 if (r)
1100 return -EIO;
1101
1102 CsrWifiSmeConnectionInfoGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
1103
1104 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1105 if (r)
1106 return r;
1107
1108 /* store the reply */
1109 if (connectionInfo != NULL)
1110 memcpy((unsigned char*)connectionInfo,
1111 (unsigned char*)&priv->sme_reply.connectionInfo,
1112 sizeof(CsrWifiSmeConnectionInfo));
1113
1114 unifi_trace(priv, UDBG4,
1115 "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req <-- (r=%d status=%d)\n",
1116 r, priv->sme_reply.reply_status);
1117
1118 return convert_sme_error(priv->sme_reply.reply_status);
1119#else
1120 CsrResult status;
1121 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
1122 status = CsrWifiSmeMgtConnectionInfoGetReq(priv->smepriv, connectionInfo);
1123 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
1124 return convert_sme_error(status);
1125#endif
1126}
1127
1128int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig)
1129{
1130#ifdef CSR_SME_USERSPACE
1131 int r;
1132
1133 if (priv->smepriv == NULL) {
1134 unifi_error(priv, "sme_mgt_connection_config_get: invalid smepriv\n");
1135 return -EIO;
1136 }
1137
1138 unifi_trace(priv, UDBG4, "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req -->\n");
1139 r = sme_init_request(priv);
1140 if (r)
1141 return -EIO;
1142
1143 CsrWifiSmeConnectionConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
1144
1145 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1146 if (r)
1147 return r;
1148
1149 /* store the reply */
1150 if (connectionConfig != NULL)
1151 memcpy((unsigned char*)connectionConfig,
1152 (unsigned char*)&priv->sme_reply.connectionConfig,
1153 sizeof(CsrWifiSmeConnectionConfig));
1154
1155 unifi_trace(priv, UDBG4,
1156 "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req <-- (r=%d status=%d)\n",
1157 r, priv->sme_reply.reply_status);
1158
1159 return convert_sme_error(priv->sme_reply.reply_status);
1160#else
1161 CsrResult status;
1162 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
1163 status = CsrWifiSmeMgtConnectionConfigGetReq(priv->smepriv, connectionConfig);
1164 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
1165 return convert_sme_error(status);
1166#endif
1167}
1168
1169int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats)
1170{
1171#ifdef CSR_SME_USERSPACE
1172 int r;
1173
1174 if (priv->smepriv == NULL) {
1175 unifi_error(priv, "sme_mgt_connection_stats_get: invalid smepriv\n");
1176 return -EIO;
1177 }
1178
1179 unifi_trace(priv, UDBG4, "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req -->\n");
1180 r = sme_init_request(priv);
1181 if (r)
1182 return -EIO;
1183
1184 CsrWifiSmeConnectionStatsGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
1185
1186 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1187 if (r)
1188 return r;
1189
1190 /* store the reply */
1191 if (connectionStats != NULL)
1192 memcpy((unsigned char*)connectionStats,
1193 (unsigned char*)&priv->sme_reply.connectionStats,
1194 sizeof(CsrWifiSmeConnectionStats));
1195
1196 unifi_trace(priv, UDBG4,
1197 "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req <-- (r=%d status=%d)\n",
1198 r, priv->sme_reply.reply_status);
1199
1200 return convert_sme_error(priv->sme_reply.reply_status);
1201#else
1202 CsrResult status;
1203 CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
1204 status = CsrWifiSmeMgtConnectionStatsGetReq(priv->smepriv, connectionStats);
1205 CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
1206 return convert_sme_error(status);
1207#endif
1208}
1209
1210#endif /* CSR_SUPPORT_WEXT */
1211
1212int sme_mgt_packet_filter_set(unifi_priv_t *priv)
1213{
1214 CsrWifiIp4Address ipAddress = {{0xFF, 0xFF, 0xFF, 0xFF }};
1215 if (priv->smepriv == NULL) {
1216 unifi_error(priv, "sme_mgt_packet_filter_set: invalid smepriv\n");
1217 return -EIO;
1218 }
1219 if (priv->packet_filters.arp_filter) {
1220 ipAddress.a[0] = (priv->sta_ip_address ) & 0xFF;
1221 ipAddress.a[1] = (priv->sta_ip_address >> 8) & 0xFF;
1222 ipAddress.a[2] = (priv->sta_ip_address >> 16) & 0xFF;
1223 ipAddress.a[3] = (priv->sta_ip_address >> 24) & 0xFF;
1224 }
1225
1226 unifi_trace(priv, UDBG5,
1227 "sme_mgt_packet_filter_set: IP address %d.%d.%d.%d\n",
1228 ipAddress.a[0], ipAddress.a[1],
1229 ipAddress.a[2], ipAddress.a[3]);
1230
1231 /* Doesn't block for a confirm */
1232 CsrWifiSmePacketFilterSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
1233 priv->packet_filters.tclas_ies_length,
1234 priv->filter_tclas_ies,
1235 priv->packet_filters.filter_mode,
1236 ipAddress);
1237 return 0;
1238}
1239
1240int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
1241 u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas)
1242{
1243 int r;
1244
1245 if (priv->smepriv == NULL) {
1246 unifi_error(priv, "sme_mgt_tspec: invalid smepriv\n");
1247 return -EIO;
1248 }
1249
1250 r = sme_init_request(priv);
1251 if (r)
1252 return -EIO;
1253
1254 CsrWifiSmeTspecReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
1255 action, tid, TRUE, 0,
1256 tspec->length, tspec->data,
1257 tclas->length, tclas->data);
1258 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1259 if (r)
1260 return r;
1261
1262 unifi_trace(priv, UDBG4, "sme_mgt_tspec: <-- (status=%d)\n", priv->sme_reply.reply_status);
1263 return convert_sme_error(priv->sme_reply.reply_status);
1264}
1265
1266
1267
1268int sme_sys_suspend(unifi_priv_t *priv)
1269{
1270 int r;
1271 CsrResult csrResult;
1272
1273 if (priv->smepriv == NULL) {
1274 unifi_error(priv, "sme_sys_suspend: invalid smepriv\n");
1275 return -EIO;
1276 }
1277
1278 r = sme_init_request(priv);
1279 if (r)
1280 return -EIO;
1281
1282 /* Suspend the SME, which MAY cause it to power down UniFi */
1283 CsrWifiRouterCtrlSuspendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, 0, priv->wol_suspend);
1284 r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
1285 if (r) {
1286 /* No reply - forcibly power down in case the request wasn't processed */
1287 unifi_notice(priv,
1288 "suspend: SME did not reply %s, ",
1289 (priv->ptest_mode | priv->wol_suspend) ? "leave powered" : "power off UniFi anyway\n");
1290
1291 /* Leave power on for production test, though */
1292 if (!priv->ptest_mode) {
1293 /* Put UniFi to deep sleep, in case we can not power it off */
1294 CsrSdioClaim(priv->sdio);
1295 unifi_trace(priv, UDBG1, "Force deep sleep");
1296 csrResult = unifi_force_low_power_mode(priv->card);
1297
1298 /* For WOL, the UniFi must stay powered */
1299 if (!priv->wol_suspend) {
1300 unifi_trace(priv, UDBG1, "Power off\n");
1301 CsrSdioPowerOff(priv->sdio);
1302 }
1303 CsrSdioRelease(priv->sdio);
1304 }
1305 }
1306
1307 if (priv->wol_suspend) {
1308 unifi_trace(priv, UDBG1, "UniFi left powered for WOL\n");
1309
1310 /* Remove the IRQ, which also disables the card SDIO interrupt.
1311 * Disabling the card SDIO interrupt enables the PIO WOL source.
1312 * Removal of the of the handler ensures that in both SDIO and PIO cases
1313 * the card interrupt only wakes the host. The card will be polled
1314 * after resume to handle any pending data.
1315 */
1316 if (csr_sdio_linux_remove_irq(priv->sdio)) {
1317 unifi_notice(priv, "WOL csr_sdio_linux_remove_irq failed\n");
1318 }
1319
1320 if (enable_wol == UNIFI_WOL_SDIO) {
1321 /* Because csr_sdio_linux_remove_irq() disabled the card SDIO interrupt,
1322 * it must be left enabled to wake-on-SDIO.
1323 */
1324 unifi_trace(priv, UDBG1, "Enable card SDIO interrupt for SDIO WOL\n");
1325
1326 CsrSdioClaim(priv->sdio);
1327 csrResult = CsrSdioInterruptEnable(priv->sdio);
1328 CsrSdioRelease(priv->sdio);
1329
1330 if (csrResult != CSR_RESULT_SUCCESS) {
1331 unifi_error(priv, "WOL CsrSdioInterruptEnable failed %d\n", csrResult);
1332 }
1333 } else {
1334 unifi_trace(priv, UDBG1, "Disabled card SDIO interrupt for PIO WOL\n");
1335 }
1336
1337 /* Prevent the BH thread from running during the suspend.
1338 * Upon resume, sme_sys_resume() will trigger a wifi-on, this will cause
1339 * the BH thread to be re-enabled and reinstall the ISR.
1340 */
1341 priv->bh_thread.block_thread = 1;
1342
1343 unifi_trace(priv, UDBG1, "unifi_suspend: suspended BH");
1344 }
1345
1346 /* Consider UniFi to be uninitialised */
1347 priv->init_progress = UNIFI_INIT_NONE;
1348
1349 unifi_trace(priv, UDBG1, "sme_sys_suspend: <-- (r=%d status=%d)\n", r, priv->sme_reply.reply_status);
1350 return convert_sme_error(priv->sme_reply.reply_status);
1351}
1352
1353
1354int sme_sys_resume(unifi_priv_t *priv)
1355{
1356 int r;
1357
1358 unifi_trace(priv, UDBG1, "sme_sys_resume %s\n", priv->wol_suspend ? "warm" : "");
1359
1360 if (priv->smepriv == NULL) {
1361 unifi_error(priv, "sme_sys_resume: invalid smepriv\n");
1362 return -EIO;
1363 }
1364
1365 r = sme_init_request(priv);
1366 if (r)
1367 return -EIO;
1368
1369 CsrWifiRouterCtrlResumeIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, priv->wol_suspend);
1370
1371 r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
1372 if (r)
1373 unifi_notice(priv,
1374 "resume: SME did not reply, return success anyway\n");
1375
1376 return 0;
1377}
1378
1379#ifdef CSR_SUPPORT_WEXT_AP
1380int sme_ap_stop(unifi_priv_t *priv, u16 interface_tag)
1381{
1382 int r;
1383
1384 if (priv->smepriv == NULL) {
1385 unifi_error(priv, "sme_ap_stop: invalid smepriv\n");
1386 return -EIO;
1387 }
1388
1389 r = sme_init_request(priv);
1390 if (r)
1391 return -EIO;
1392
1393 CsrWifiNmeApStopReqSend(0, interface_tag);
1394
1395 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1396 if (r)
1397 return r;
1398
1399 unifi_trace(priv, UDBG4,
1400 "sme_ap_stop <-- (r=%d status=%d)\n",
1401 r, priv->sme_reply.reply_status);
1402 return convert_sme_error(priv->sme_reply.reply_status);
1403
1404}
1405
1406int sme_ap_start(unifi_priv_t *priv, u16 interface_tag,
1407 CsrWifiSmeApConfig_t * ap_config)
1408{
1409 int r;
1410 CsrWifiSmeApP2pGoConfig p2p_go_param;
1411 memset(&p2p_go_param, 0, sizeof(CsrWifiSmeApP2pGoConfig));
1412
1413 if (priv->smepriv == NULL) {
1414 unifi_error(priv, "sme_ap_start: invalid smepriv\n");
1415 return -EIO;
1416 }
1417
1418 r = sme_init_request(priv);
1419 if (r)
1420 return -EIO;
1421
1422 CsrWifiNmeApStartReqSend(0, interface_tag, CSR_WIFI_AP_TYPE_LEGACY, FALSE,
1423 ap_config->ssid, 1, ap_config->channel,
1424 ap_config->credentials, ap_config->max_connections,
1425 p2p_go_param, FALSE);
1426
1427 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1428 if (r)
1429 return r;
1430
1431 unifi_trace(priv, UDBG4,
1432 "sme_ap_start <-- (r=%d status=%d)\n",
1433 r, priv->sme_reply.reply_status);
1434 return convert_sme_error(priv->sme_reply.reply_status);
1435}
1436
1437int sme_ap_config(unifi_priv_t *priv,
1438 CsrWifiSmeApMacConfig *ap_mac_config,
1439 CsrWifiNmeApConfig *group_security_config)
1440{
1441 int r;
1442 CsrWifiSmeApP2pGoConfig p2p_go_param;
1443 memset(&p2p_go_param, 0, sizeof(CsrWifiSmeApP2pGoConfig));
1444
1445 if (priv->smepriv == NULL) {
1446 unifi_error(priv, "sme_ap_config: invalid smepriv\n");
1447 return -EIO;
1448 }
1449
1450 r = sme_init_request(priv);
1451 if (r)
1452 return -EIO;
1453
1454 CsrWifiNmeApConfigSetReqSend(0, *group_security_config,
1455 *ap_mac_config);
1456
1457 r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
1458 if (r)
1459 return r;
1460
1461 unifi_trace(priv, UDBG4,
1462 "sme_ap_config <-- (r=%d status=%d)\n",
1463 r, priv->sme_reply.reply_status);
1464 return convert_sme_error(priv->sme_reply.reply_status);
1465}
1466#endif
diff --git a/drivers/staging/csr/sme_mgt.c b/drivers/staging/csr/sme_mgt.c
deleted file mode 100644
index 58d1b3b72932..000000000000
--- a/drivers/staging/csr/sme_mgt.c
+++ /dev/null
@@ -1,1012 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: sme_mgt.c
4 *
5 * PURPOSE:
6 * This file contains the driver specific implementation of
7 * the SME MGT SAP.
8 * It is part of the porting exercise.
9 *
10 * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 * ---------------------------------------------------------------------------
16 */
17
18#include "csr_wifi_hip_unifiversion.h"
19#include "unifi_priv.h"
20#include "csr_wifi_hip_conversions.h"
21/*
22 * This file implements the SME MGT API. It contains the following functions:
23 * CsrWifiSmeWifiFlightmodeCfmSend()
24 * CsrWifiSmeWifiOnCfmSend()
25 * CsrWifiSmeWifiOffCfmSend()
26 * CsrWifiSmeWifiOffIndSend()
27 * CsrWifiSmeScanFullCfmSend()
28 * CsrWifiSmeScanResultsGetCfmSend()
29 * CsrWifiSmeScanResultIndSend()
30 * CsrWifiSmeScanResultsFlushCfmSend()
31 * CsrWifiSmeConnectCfmSend()
32 * CsrWifiSmeMediaStatusIndSend()
33 * CsrWifiSmeDisconnectCfmSend()
34 * CsrWifiSmeKeyCfmSend()
35 * CsrWifiSmeMulticastAddressCfmSend()
36 * CsrWifiSmeSetValueCfmSend()
37 * CsrWifiSmeGetValueCfmSend()
38 * CsrWifiSmeMicFailureIndSend()
39 * CsrWifiSmePmkidCfmSend()
40 * CsrWifiSmePmkidCandidateListIndSend()
41 * CsrWifiSmeMibSetCfmSend()
42 * CsrWifiSmeMibGetCfmSend()
43 * CsrWifiSmeMibGetNextCfmSend()
44 * CsrWifiSmeConnectionQualityIndSend()
45 * CsrWifiSmePacketFilterSetCfmSend()
46 * CsrWifiSmeTspecCfmSend()
47 * CsrWifiSmeTspecIndSend()
48 * CsrWifiSmeBlacklistCfmSend()
49 * CsrWifiSmeEventMaskSetCfmSend()
50 * CsrWifiSmeRoamStartIndSend()
51 * CsrWifiSmeRoamCompleteIndSend()
52 * CsrWifiSmeAssociationStartIndSend()
53 * CsrWifiSmeAssociationCompleteIndSend()
54 * CsrWifiSmeIbssStationIndSend()
55 */
56
57
58void CsrWifiSmeMicFailureIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
59{
60#ifdef CSR_SUPPORT_WEXT
61 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
62 CsrWifiSmeMicFailureInd* ind = (CsrWifiSmeMicFailureInd*)msg;
63
64 if (priv == NULL) {
65 unifi_error(NULL, "CsrWifiSmeMicFailureIndSend: invalid priv\n");
66 return;
67 }
68
69 unifi_trace(priv, UDBG1,
70 "CsrWifiSmeMicFailureIndSend: count=%d, KeyType=%d\n",
71 ind->count, ind->keyType);
72
73 wext_send_michaelmicfailure_event(priv, ind->count, ind->address, ind->keyType, ind->interfaceTag);
74#endif
75}
76
77
78void CsrWifiSmePmkidCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
79{
80#ifdef CSR_SUPPORT_WEXT
81 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
82 CsrWifiSmePmkidCfm* cfm = (CsrWifiSmePmkidCfm*)msg;
83
84 if (priv == NULL) {
85 unifi_error(NULL, "CsrWifiSmePmkidCfmSend: Invalid ospriv.\n");
86 return;
87 }
88
89 /*
90 * WEXT never does a GET operation the PMKIDs, so we don't need
91 * handle data returned in pmkids.
92 */
93
94 sme_complete_request(priv, cfm->status);
95#endif
96}
97
98
99void CsrWifiSmePmkidCandidateListIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
100{
101#ifdef CSR_SUPPORT_WEXT
102 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
103 CsrWifiSmePmkidCandidateListInd* ind = (CsrWifiSmePmkidCandidateListInd*)msg;
104 int i;
105
106 if (priv->smepriv == NULL) {
107 unifi_error(priv, "CsrWifiSmePmkidCandidateListIndSend: invalid smepriv\n");
108 return;
109 }
110
111 for (i = 0; i < ind->pmkidCandidatesCount; i++)
112 {
113 wext_send_pmkid_candidate_event(priv, ind->pmkidCandidates[i].bssid, ind->pmkidCandidates[i].preAuthAllowed, ind->interfaceTag);
114 }
115#endif
116}
117
118void CsrWifiSmeScanResultsFlushCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
119{
120}
121
122void CsrWifiSmeScanResultsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
123{
124#ifdef CSR_SUPPORT_WEXT
125 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
126 CsrWifiSmeScanResultsGetCfm* cfm = (CsrWifiSmeScanResultsGetCfm*)msg;
127 int bytesRequired = cfm->scanResultsCount * sizeof(CsrWifiSmeScanResult);
128 int i;
129 u8* current_buff;
130 CsrWifiSmeScanResult* scanCopy;
131
132 if (priv == NULL) {
133 unifi_error(NULL, "CsrWifiSmeScanResultsGetCfmSend: Invalid ospriv.\n");
134 return;
135 }
136
137 /* Calc the size of the buffer reuired */
138 for (i = 0; i < cfm->scanResultsCount; ++i) {
139 const CsrWifiSmeScanResult *scan_result = &cfm->scanResults[i];
140 bytesRequired += scan_result->informationElementsLength;
141 }
142
143 /* Take a Copy of the scan Results :-) */
144 scanCopy = kmalloc(bytesRequired, GFP_KERNEL);
145 memcpy(scanCopy, cfm->scanResults, sizeof(CsrWifiSmeScanResult) * cfm->scanResultsCount);
146
147 /* Take a Copy of the Info Elements AND update the scan result pointers */
148 current_buff = (u8*)&scanCopy[cfm->scanResultsCount];
149 for (i = 0; i < cfm->scanResultsCount; ++i)
150 {
151 CsrWifiSmeScanResult *scan_result = &scanCopy[i];
152 memcpy(current_buff, scan_result->informationElements, scan_result->informationElementsLength);
153 scan_result->informationElements = current_buff;
154 current_buff += scan_result->informationElementsLength;
155 }
156
157 priv->sme_reply.reply_scan_results_count = cfm->scanResultsCount;
158 priv->sme_reply.reply_scan_results = scanCopy;
159
160 sme_complete_request(priv, cfm->status);
161#endif
162}
163
164
165void CsrWifiSmeScanFullCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
166{
167#ifdef CSR_SUPPORT_WEXT
168 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
169 CsrWifiSmeScanFullCfm* cfm = (CsrWifiSmeScanFullCfm*)msg;
170
171 if (priv == NULL) {
172 unifi_error(NULL, "CsrWifiSmeScanFullCfmSend: Invalid ospriv.\n");
173 return;
174 }
175
176 sme_complete_request(priv, cfm->status);
177#endif
178}
179
180
181void CsrWifiSmeScanResultIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
182{
183
184}
185
186
187void CsrWifiSmeConnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
188{
189#ifdef CSR_SUPPORT_WEXT
190 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
191 CsrWifiSmeConnectCfm* cfm = (CsrWifiSmeConnectCfm*)msg;
192
193 if (priv == NULL) {
194 unifi_error(NULL, "CsrWifiSmeConnectCfmSend: Invalid ospriv.\n");
195 return;
196 }
197
198 sme_complete_request(priv, cfm->status);
199#endif
200}
201
202
203void CsrWifiSmeDisconnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
204{
205#ifdef CSR_SUPPORT_WEXT
206 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
207 CsrWifiSmeDisconnectCfm* cfm = (CsrWifiSmeDisconnectCfm*)msg;
208
209 if (priv == NULL) {
210 unifi_error(NULL, "CsrWifiSmeDisconnectCfmSend: Invalid ospriv.\n");
211 return;
212 }
213
214 sme_complete_request(priv, cfm->status);
215#endif
216}
217
218
219void CsrWifiSmeKeyCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
220{
221#ifdef CSR_SUPPORT_WEXT
222 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
223 CsrWifiSmeKeyCfm* cfm = (CsrWifiSmeKeyCfm*)msg;
224
225 if (priv == NULL) {
226 unifi_error(NULL, "CsrWifiSmeKeyCfmSend: Invalid ospriv.\n");
227 return;
228 }
229
230 sme_complete_request(priv, cfm->status);
231#endif
232}
233
234
235void CsrWifiSmeMulticastAddressCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
236{
237#ifdef CSR_SUPPORT_WEXT
238 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
239 CsrWifiSmeMulticastAddressCfm* cfm = (CsrWifiSmeMulticastAddressCfm*)msg;
240
241 if (priv == NULL) {
242 unifi_error(NULL, "CsrWifiSmeMulticastAddressCfmSend: Invalid ospriv.\n");
243 return;
244 }
245
246 sme_complete_request(priv, cfm->status);
247#endif
248}
249
250void CsrWifiSmeWifiFlightmodeCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
251{
252#ifdef CSR_SUPPORT_WEXT
253 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
254 CsrWifiSmeWifiFlightmodeCfm* cfm = (CsrWifiSmeWifiFlightmodeCfm*)msg;
255
256 if (priv == NULL) {
257 unifi_error(NULL, "CsrWifiSmeWifiFlightmodeCfmSend: Invalid ospriv.\n");
258 return;
259 }
260
261 sme_complete_request(priv, cfm->status);
262#endif
263}
264
265void CsrWifiSmeWifiOnCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
266{
267#ifdef CSR_SUPPORT_WEXT
268 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
269 CsrWifiSmeWifiOnCfm* cfm = (CsrWifiSmeWifiOnCfm*)msg;
270
271 if (priv == NULL) {
272 unifi_error(NULL, "CsrWifiSmeWifiOnCfmSend: Invalid ospriv.\n");
273 return;
274 }
275
276 unifi_trace(priv, UDBG4,
277 "CsrWifiSmeWifiOnCfmSend: wake up status %d\n", cfm->status);
278#ifdef CSR_SUPPORT_WEXT_AP
279 sme_complete_request(priv, cfm->status);
280#endif
281
282#endif
283}
284
285void CsrWifiSmeWifiOffCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
286{
287#ifdef CSR_SUPPORT_WEXT
288 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
289 CsrWifiSmeWifiOffCfm* cfm = (CsrWifiSmeWifiOffCfm*)msg;
290
291 if (priv == NULL) {
292 unifi_error(NULL, "CsrWifiSmeWifiOffCfmSend: Invalid ospriv.\n");
293 return;
294 }
295
296 sme_complete_request(priv, cfm->status);
297#endif
298}
299
300
301void CsrWifiSmeWifiOffIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
302{
303#ifdef CSR_SUPPORT_WEXT
304 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
305 CsrWifiSmeWifiOffInd* ind = (CsrWifiSmeWifiOffInd*)msg;
306
307 if (priv == NULL) {
308 unifi_error(NULL, "CsrWifiRouterCtrlStoppedReqSend: Invalid ospriv.\n");
309 return;
310 }
311
312 if (priv->smepriv == NULL) {
313 unifi_error(priv, "CsrWifiRouterCtrlStoppedReqSend: invalid smepriv\n");
314 return;
315 }
316
317 /*
318 * If the status indicates an error, the SME is in a stopped state.
319 * We need to start it again in order to reinitialise UniFi.
320 */
321 switch (ind->reason) {
322 case CSR_WIFI_SME_CONTROL_INDICATION_ERROR:
323 unifi_trace(priv, UDBG1,
324 "CsrWifiRouterCtrlStoppedReqSend: Restarting SME (ind:%d)\n",
325 ind->reason);
326
327 /* On error, restart the SME */
328 sme_mgt_wifi_on(priv);
329 break;
330 case CSR_WIFI_SME_CONTROL_INDICATION_EXIT:
331#ifdef CSR_SUPPORT_WEXT_AP
332 sme_complete_request(priv, 0);
333#endif
334 break;
335 default:
336 break;
337 }
338
339#endif
340}
341
342void CsrWifiSmeVersionsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
343{
344#ifdef CSR_SUPPORT_WEXT
345 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
346 CsrWifiSmeVersionsGetCfm* cfm = (CsrWifiSmeVersionsGetCfm*)msg;
347
348 if (priv == NULL) {
349 unifi_error(NULL, "CsrWifiSmeVersionsGetCfmSend: Invalid ospriv.\n");
350 return;
351 }
352
353 priv->sme_reply.versions = cfm->versions;
354 sme_complete_request(priv, cfm->status);
355#endif
356}
357
358void CsrWifiSmePowerConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
359{
360 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
361 CsrWifiSmePowerConfigGetCfm* cfm = (CsrWifiSmePowerConfigGetCfm*)msg;
362
363 if (priv == NULL) {
364 unifi_error(NULL, "CsrWifiSmePowerConfigGetCfmSend: Invalid ospriv.\n");
365 return;
366 }
367
368 priv->sme_reply.powerConfig = cfm->powerConfig;
369 sme_complete_request(priv, cfm->status);
370}
371
372void CsrWifiSmeHostConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
373{
374 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
375 CsrWifiSmeHostConfigGetCfm* cfm = (CsrWifiSmeHostConfigGetCfm*)msg;
376
377 if (priv == NULL) {
378 unifi_error(NULL, "CsrWifiSmeHostConfigGetCfmSend: Invalid ospriv.\n");
379 return;
380 }
381
382 priv->sme_reply.hostConfig = cfm->hostConfig;
383 sme_complete_request(priv, cfm->status);
384}
385
386void CsrWifiSmeCoexInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
387{
388 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
389 CsrWifiSmeCoexInfoGetCfm* cfm = (CsrWifiSmeCoexInfoGetCfm*)msg;
390
391 if (priv == NULL) {
392 unifi_error(NULL, "CsrWifiSmeCoexInfoGetCfmSend: Invalid ospriv.\n");
393 return;
394 }
395
396 priv->sme_reply.coexInfo = cfm->coexInfo;
397 sme_complete_request(priv, cfm->status);
398}
399
400void CsrWifiSmeCoexConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
401{
402#ifdef CSR_SUPPORT_WEXT
403 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
404 CsrWifiSmeCoexConfigGetCfm* cfm = (CsrWifiSmeCoexConfigGetCfm*)msg;
405
406 if (priv == NULL) {
407 unifi_error(NULL, "CsrWifiSmeCoexConfigGetCfmSend: Invalid ospriv.\n");
408 return;
409 }
410
411 priv->sme_reply.coexConfig = cfm->coexConfig;
412 sme_complete_request(priv, cfm->status);
413#endif
414}
415
416void CsrWifiSmeMibConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
417{
418#ifdef CSR_SUPPORT_WEXT
419 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
420 CsrWifiSmeMibConfigGetCfm* cfm = (CsrWifiSmeMibConfigGetCfm*)msg;
421
422 if (priv == NULL) {
423 unifi_error(NULL, "CsrWifiSmeMibConfigGetCfmSend: Invalid ospriv.\n");
424 return;
425 }
426
427 priv->sme_reply.mibConfig = cfm->mibConfig;
428 sme_complete_request(priv, cfm->status);
429#endif
430}
431
432void CsrWifiSmeConnectionInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
433{
434#ifdef CSR_SUPPORT_WEXT
435 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
436 CsrWifiSmeConnectionInfoGetCfm* cfm = (CsrWifiSmeConnectionInfoGetCfm*)msg;
437
438 if (priv == NULL) {
439 unifi_error(NULL, "CsrWifiSmeConnectionInfoGetCfmSend: Invalid ospriv.\n");
440 return;
441 }
442
443 priv->sme_reply.connectionInfo = cfm->connectionInfo;
444 sme_complete_request(priv, cfm->status);
445#endif
446}
447
448void CsrWifiSmeConnectionConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
449{
450#ifdef CSR_SUPPORT_WEXT
451 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
452 CsrWifiSmeConnectionConfigGetCfm* cfm = (CsrWifiSmeConnectionConfigGetCfm*)msg;
453
454 if (priv == NULL) {
455 unifi_error(NULL, "CsrWifiSmeConnectionConfigGetCfmSend: Invalid ospriv.\n");
456 return;
457 }
458
459 priv->sme_reply.connectionConfig = cfm->connectionConfig;
460 sme_complete_request(priv, cfm->status);
461#endif
462}
463
464void CsrWifiSmeConnectionStatsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
465{
466#ifdef CSR_SUPPORT_WEXT
467 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
468 CsrWifiSmeConnectionStatsGetCfm* cfm = (CsrWifiSmeConnectionStatsGetCfm*)msg;
469
470 if (priv == NULL) {
471 unifi_error(NULL, "CsrWifiSmeConnectionStatsGetCfmSend: Invalid ospriv.\n");
472 return;
473 }
474
475 priv->sme_reply.connectionStats = cfm->connectionStats;
476 sme_complete_request(priv, cfm->status);
477#endif
478}
479
480void CsrWifiSmeMibSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
481{
482#ifdef CSR_SUPPORT_WEXT
483 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
484 CsrWifiSmeMibSetCfm* cfm = (CsrWifiSmeMibSetCfm*)msg;
485
486 if (priv == NULL) {
487 unifi_error(NULL, "CsrWifiSmeMibSetCfmSend: Invalid ospriv.\n");
488 return;
489 }
490
491 sme_complete_request(priv, cfm->status);
492#endif
493}
494
495void CsrWifiSmeMibGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
496{
497#ifdef CSR_SUPPORT_WEXT
498 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
499 CsrWifiSmeMibGetCfm* cfm = (CsrWifiSmeMibGetCfm*)msg;
500
501 if (priv == NULL) {
502 unifi_error(NULL, "CsrWifiSmeMibGetCfmSend: Invalid ospriv.\n");
503 return;
504 }
505
506 if (cfm->mibAttribute == NULL) {
507 unifi_error(priv, "CsrWifiSmeMibGetCfmSend: Empty reply.\n");
508 sme_complete_request(priv, cfm->status);
509 return;
510 }
511
512 if ((priv->mib_cfm_buffer != NULL) &&
513 (priv->mib_cfm_buffer_length >= cfm->mibAttributeLength)) {
514 memcpy(priv->mib_cfm_buffer, cfm->mibAttribute, cfm->mibAttributeLength);
515 priv->mib_cfm_buffer_length = cfm->mibAttributeLength;
516 } else {
517 unifi_error(priv,
518 "CsrWifiSmeMibGetCfmSend: No room to store MIB data (have=%d need=%d).\n",
519 priv->mib_cfm_buffer_length, cfm->mibAttributeLength);
520 }
521
522 sme_complete_request(priv, cfm->status);
523#endif
524}
525
526void CsrWifiSmeMibGetNextCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
527{
528#ifdef CSR_SUPPORT_WEXT
529 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
530 CsrWifiSmeMibGetNextCfm* cfm = (CsrWifiSmeMibGetNextCfm*)msg;
531
532 if (priv == NULL) {
533 unifi_error(NULL, "CsrWifiSmeMibGetNextCfmSend: Invalid ospriv.\n");
534 return;
535 }
536
537 /* Need to copy MIB data */
538 sme_complete_request(priv, cfm->status);
539#endif
540}
541
542void CsrWifiSmeConnectionQualityIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
543{
544#ifdef CSR_SUPPORT_WEXT
545 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
546 CsrWifiSmeConnectionQualityInd* ind = (CsrWifiSmeConnectionQualityInd*)msg;
547 int signal, noise, snr;
548
549 if (priv == NULL) {
550 unifi_error(NULL, "CsrWifiSmeConnectionQualityIndSend: Invalid ospriv.\n");
551 return;
552 }
553
554 /*
555 * level and noise below are mapped into an unsigned 8 bit number,
556 * ranging from [-192; 63]. The way this is achieved is simply to
557 * add 0x100 onto the number if it is negative,
558 * once clipped to the correct range.
559 */
560 signal = ind->linkQuality.unifiRssi;
561 /* Clip range of snr */
562 snr = (ind->linkQuality.unifiSnr > 0) ? ind->linkQuality.unifiSnr : 0; /* In dB relative, from 0 - 255 */
563 snr = (snr < 255) ? snr : 255;
564 noise = signal - snr;
565
566 /* Clip range of signal */
567 signal = (signal < 63) ? signal : 63;
568 signal = (signal > -192) ? signal : -192;
569
570 /* Clip range of noise */
571 noise = (noise < 63) ? noise : 63;
572 noise = (noise > -192) ? noise : -192;
573
574 /* Make u8 */
575 signal = ( signal < 0 ) ? signal + 0x100 : signal;
576 noise = ( noise < 0 ) ? noise + 0x100 : noise;
577
578 priv->wext_wireless_stats.qual.level = (u8)signal; /* -192 : 63 */
579 priv->wext_wireless_stats.qual.noise = (u8)noise; /* -192 : 63 */
580 priv->wext_wireless_stats.qual.qual = snr; /* 0 : 255 */
581 priv->wext_wireless_stats.qual.updated = 0;
582
583#if WIRELESS_EXT > 16
584 priv->wext_wireless_stats.qual.updated |= IW_QUAL_LEVEL_UPDATED |
585 IW_QUAL_NOISE_UPDATED |
586 IW_QUAL_QUAL_UPDATED;
587#if WIRELESS_EXT > 18
588 priv->wext_wireless_stats.qual.updated |= IW_QUAL_DBM;
589#endif
590#endif
591#endif
592}
593
594void CsrWifiSmePacketFilterSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
595{
596 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
597
598 if (priv == NULL) {
599 unifi_error(NULL, "CsrWifiSmePacketFilterSetCfmSend: Invalid ospriv.\n");
600 return;
601 }
602
603 /* The packet filter set request does not block for a reply */
604}
605
606void CsrWifiSmeTspecCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
607{
608 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
609 CsrWifiSmeTspecCfm* cfm = (CsrWifiSmeTspecCfm*)msg;
610
611 if (priv == NULL) {
612 unifi_error(NULL, "CsrWifiSmeTspecCfmSend: Invalid ospriv.\n");
613 return;
614 }
615
616 sme_complete_request(priv, cfm->status);
617}
618
619void CsrWifiSmeTspecIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
620{
621}
622
623void CsrWifiSmeBlacklistCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
624{
625}
626
627void CsrWifiSmeEventMaskSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
628{
629}
630
631
632void CsrWifiSmeRoamStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
633{
634}
635
636void CsrWifiSmeRoamCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
637{
638 /* This is called when the association completes, before any 802.1x authentication */
639}
640
641void CsrWifiSmeAssociationStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
642{
643}
644
645void CsrWifiSmeAssociationCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
646{
647}
648
649void CsrWifiSmeIbssStationIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
650{
651}
652
653void CsrWifiSmeWifiOnIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
654{
655}
656
657void CsrWifiSmeRestrictedAccessEnableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
658{
659}
660
661void CsrWifiSmeRestrictedAccessDisableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
662{
663}
664
665
666void CsrWifiSmeAdhocConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
667{
668}
669
670void CsrWifiSmeAdhocConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
671{
672#ifdef CSR_SUPPORT_WEXT
673 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
674 CsrWifiSmeAdhocConfigSetCfm* cfm = (CsrWifiSmeAdhocConfigSetCfm*)msg;
675
676 if (priv == NULL) {
677 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
678 return;
679 }
680
681 sme_complete_request(priv, cfm->status);
682#endif
683}
684
685void CsrWifiSmeCalibrationDataGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
686{
687}
688
689void CsrWifiSmeCalibrationDataSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
690{
691#ifdef CSR_SUPPORT_WEXT
692 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
693 CsrWifiSmeCalibrationDataSetCfm* cfm = (CsrWifiSmeCalibrationDataSetCfm*)msg;
694
695 if (priv == NULL) {
696 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
697 return;
698 }
699
700 sme_complete_request(priv, cfm->status);
701#endif
702}
703
704void CsrWifiSmeCcxConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
705{
706}
707
708void CsrWifiSmeCcxConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
709{
710#ifdef CSR_SUPPORT_WEXT
711 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
712 CsrWifiSmeCcxConfigSetCfm* cfm = (CsrWifiSmeCcxConfigSetCfm*)msg;
713
714 if (priv == NULL) {
715 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
716 return;
717 }
718
719 sme_complete_request(priv, cfm->status);
720#endif
721}
722
723void CsrWifiSmeCloakedSsidsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
724{
725}
726
727void CsrWifiSmeCloakedSsidsSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
728{
729#ifdef CSR_SUPPORT_WEXT
730 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
731 CsrWifiSmeCloakedSsidsSetCfm* cfm = (CsrWifiSmeCloakedSsidsSetCfm*)msg;
732
733 if (priv == NULL) {
734 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
735 return;
736 }
737
738 sme_complete_request(priv, cfm->status);
739#endif
740}
741
742
743void CsrWifiSmeCoexConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
744{
745#ifdef CSR_SUPPORT_WEXT
746 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
747 CsrWifiSmeCoexConfigSetCfm* cfm = (CsrWifiSmeCoexConfigSetCfm*)msg;
748
749 if (priv == NULL) {
750 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
751 return;
752 }
753
754 sme_complete_request(priv, cfm->status);
755#endif
756}
757
758void CsrWifiSmeHostConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
759{
760 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
761 CsrWifiSmeHostConfigSetCfm* cfm = (CsrWifiSmeHostConfigSetCfm*)msg;
762
763 if (priv == NULL) {
764 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
765 return;
766 }
767
768 sme_complete_request(priv, cfm->status);
769}
770
771void CsrWifiSmeLinkQualityGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
772{
773}
774
775
776void CsrWifiSmeMibConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
777{
778#ifdef CSR_SUPPORT_WEXT
779 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
780 CsrWifiSmeMibConfigSetCfm* cfm = (CsrWifiSmeMibConfigSetCfm*)msg;
781
782 if (priv == NULL) {
783 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
784 return;
785 }
786
787 sme_complete_request(priv, cfm->status);
788#endif
789}
790
791void CsrWifiSmePermanentMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
792{
793}
794
795void CsrWifiSmePowerConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
796{
797 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
798 CsrWifiSmePowerConfigSetCfm* cfm = (CsrWifiSmePowerConfigSetCfm*)msg;
799
800 if (priv == NULL) {
801 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
802 return;
803 }
804
805 sme_complete_request(priv, cfm->status);
806}
807
808void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
809{
810}
811
812void CsrWifiSmeRoamingConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
813{
814}
815
816void CsrWifiSmeMediaStatusIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
817{
818#ifdef CSR_SUPPORT_WEXT
819 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
820 CsrWifiSmeMediaStatusInd* ind = (CsrWifiSmeMediaStatusInd*)msg;
821
822 if (priv->smepriv == NULL) {
823 unifi_error(priv, "CsrWifiSmeMediaStatusIndSend: invalid smepriv\n");
824 return;
825 }
826
827 if (ind->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) {
828 /*
829 * Send wireless-extension event up to userland to announce
830 * connection.
831 */
832 wext_send_assoc_event(priv,
833 (unsigned char *)ind->connectionInfo.bssid.a,
834 (unsigned char *)ind->connectionInfo.assocReqInfoElements,
835 ind->connectionInfo.assocReqInfoElementsLength,
836 (unsigned char *)ind->connectionInfo.assocRspInfoElements,
837 ind->connectionInfo.assocRspInfoElementsLength,
838 (unsigned char *)ind->connectionInfo.assocScanInfoElements,
839 ind->connectionInfo.assocScanInfoElementsLength);
840
841 unifi_trace(priv, UDBG2, "CsrWifiSmeMediaStatusIndSend: IBSS=%pM\n",
842 ind->connectionInfo.bssid.a);
843
844 sme_mgt_packet_filter_set(priv);
845
846 } else {
847 /*
848 * Send wireless-extension event up to userland to announce
849 * connection lost to a BSS.
850 */
851 wext_send_disassoc_event(priv);
852 }
853#endif
854}
855
856void CsrWifiSmeRoamingConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
857{
858 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
859 CsrWifiSmeRoamingConfigSetCfm* cfm = (CsrWifiSmeRoamingConfigSetCfm*)msg;
860
861 if (priv == NULL) {
862 unifi_error(NULL, "CsrWifiSmeRoamingConfigSetCfmSend: Invalid ospriv.\n");
863 return;
864 }
865
866 sme_complete_request(priv, cfm->status);
867}
868
869void CsrWifiSmeScanConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
870{
871}
872
873void CsrWifiSmeScanConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
874{
875#ifdef CSR_SUPPORT_WEXT
876 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
877 CsrWifiSmeScanConfigSetCfm* cfm = (CsrWifiSmeScanConfigSetCfm*)msg;
878
879 if (priv == NULL) {
880 unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
881 return;
882 }
883
884 sme_complete_request(priv, cfm->status);
885#endif
886}
887
888void CsrWifiSmeStationMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
889{
890}
891
892void CsrWifiSmeSmeCommonConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
893{
894 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
895 CsrWifiSmeSmeCommonConfigGetCfm* cfm = (CsrWifiSmeSmeCommonConfigGetCfm*)msg;
896
897 if (priv == NULL) {
898 unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n");
899 return;
900 }
901
902 priv->sme_reply.deviceConfig = cfm->deviceConfig;
903 sme_complete_request(priv, cfm->status);
904}
905
906void CsrWifiSmeSmeStaConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
907{
908 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
909 CsrWifiSmeSmeStaConfigGetCfm* cfm = (CsrWifiSmeSmeStaConfigGetCfm*)msg;
910
911 if (priv == NULL) {
912 unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n");
913 return;
914 }
915
916 priv->sme_reply.staConfig = cfm->smeConfig;
917 sme_complete_request(priv, cfm->status);
918}
919
920void CsrWifiSmeSmeCommonConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
921{
922 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
923 CsrWifiSmeSmeCommonConfigSetCfm* cfm = (CsrWifiSmeSmeCommonConfigSetCfm*)msg;
924
925 if (priv == NULL) {
926 unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n");
927 return;
928 }
929
930 sme_complete_request(priv, cfm->status);
931}
932
933void CsrWifiSmeSmeStaConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
934{
935 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
936 CsrWifiSmeSmeStaConfigSetCfm* cfm = (CsrWifiSmeSmeStaConfigSetCfm*)msg;
937
938 if (priv == NULL) {
939 unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n");
940 return;
941 }
942
943 sme_complete_request(priv, cfm->status);
944}
945
946void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
947{
948}
949
950void CsrWifiSmeErrorIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
951{
952}
953
954void CsrWifiSmeInfoIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
955{
956}
957
958void CsrWifiSmeCoreDumpIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
959{
960}
961void CsrWifiSmeAmpStatusChangeIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
962{
963}
964
965void CsrWifiSmeActivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
966{
967}
968void CsrWifiSmeDeactivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
969{
970}
971
972#ifdef CSR_SUPPORT_WEXT
973#ifdef CSR_SUPPORT_WEXT_AP
974void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
975{
976 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
977 CsrWifiNmeApStartCfm* cfm = (CsrWifiNmeApStartCfm*)msg;
978
979 if (priv == NULL) {
980 unifi_error(NULL, "CsrWifiNmeApStartCfmSend: Invalid ospriv.\n");
981 return;
982 }
983
984 sme_complete_request(priv, cfm->status);
985}
986
987void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
988{
989 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
990 CsrWifiNmeApStopCfm* cfm = (CsrWifiNmeApStopCfm*)msg;
991
992 if (priv == NULL) {
993 unifi_error(NULL, "CsrWifiNmeApStopCfmSend: Invalid ospriv.\n");
994 return;
995 }
996
997 sme_complete_request(priv, cfm->status);
998}
999
1000void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1001{
1002 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1003 CsrWifiNmeApConfigSetCfm* cfm = (CsrWifiNmeApConfigSetCfm*)msg;
1004
1005 if (priv == NULL) {
1006 unifi_error(NULL, "CsrWifiNmeApConfigSetCfmSend: Invalid ospriv.\n");
1007 return;
1008 }
1009 sme_complete_request(priv, cfm->status);
1010}
1011#endif
1012#endif
diff --git a/drivers/staging/csr/sme_native.c b/drivers/staging/csr/sme_native.c
deleted file mode 100644
index d0b9be31e12c..000000000000
--- a/drivers/staging/csr/sme_native.c
+++ /dev/null
@@ -1,566 +0,0 @@
1/*
2 * ***************************************************************************
3 *
4 * FILE: sme_native.c
5 *
6 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
7 *
8 * Refer to LICENSE.txt included with this source code for details on
9 * the license terms.
10 *
11 * ***************************************************************************
12 */
13
14#include <linux/netdevice.h>
15#include "unifi_priv.h"
16#include "csr_wifi_hip_unifi.h"
17#include "csr_wifi_hip_conversions.h"
18
19static const unsigned char wildcard_address[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
20
21int
22uf_sme_init(unifi_priv_t *priv)
23{
24 sema_init(&priv->mlme_blocking_mutex, 1);
25
26#ifdef CSR_SUPPORT_WEXT
27 {
28 int r = uf_init_wext_interface(priv);
29 if (r != 0) {
30 return r;
31 }
32 }
33#endif
34
35 return 0;
36} /* uf_sme_init() */
37
38
39void
40uf_sme_deinit(unifi_priv_t *priv)
41{
42
43 /* Free memory allocated for the scan table */
44/* unifi_clear_scan_table(priv); */
45
46 /* Cancel any pending workqueue tasks */
47 flush_workqueue(priv->unifi_workqueue);
48
49#ifdef CSR_SUPPORT_WEXT
50 uf_deinit_wext_interface(priv);
51#endif
52
53} /* uf_sme_deinit() */
54
55
56int sme_mgt_wifi_on(unifi_priv_t *priv)
57{
58 int r, i;
59 s32 csrResult;
60
61 if (priv == NULL) {
62 return -EINVAL;
63 }
64 /* Initialize the interface mode to None */
65 for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
66 priv->interfacePriv[i]->interfaceMode = 0;
67 }
68
69 /* Set up interface mode so that get_packet_priority() can
70 * select the right QOS priority when WMM is enabled.
71 */
72 priv->interfacePriv[0]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_STA;
73
74 r = uf_request_firmware_files(priv, UNIFI_FW_STA);
75 if (r) {
76 unifi_error(priv, "sme_mgt_wifi_on: Failed to get f/w\n");
77 return r;
78 }
79
80 /*
81 * The request to initialise UniFi might come while UniFi is running.
82 * We need to block all I/O activity until the reset completes, otherwise
83 * an SDIO error might occur resulting an indication to the SME which
84 * makes it think that the initialisation has failed.
85 */
86 priv->bh_thread.block_thread = 1;
87
88 /* Power on UniFi */
89 CsrSdioClaim(priv->sdio);
90 csrResult = CsrSdioPowerOn(priv->sdio);
91 CsrSdioRelease(priv->sdio);
92 if(csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) {
93 return -EIO;
94 }
95
96 if (csrResult == CSR_RESULT_SUCCESS) {
97 /* Initialise UniFi hardware */
98 r = uf_init_hw(priv);
99 if (r) {
100 return r;
101 }
102 }
103
104 /* Re-enable the I/O thread */
105 priv->bh_thread.block_thread = 0;
106
107 /* Disable deep sleep signalling during the firmware initialisation, to
108 * prevent the wakeup mechanism raising the SDIO clock beyond INIT before
109 * the first MLME-RESET.ind. It gets re-enabled at the CONNECTED.ind,
110 * immediately after the MLME-RESET.ind
111 */
112 csrResult = unifi_configure_low_power_mode(priv->card,
113 UNIFI_LOW_POWER_DISABLED,
114 UNIFI_PERIODIC_WAKE_HOST_DISABLED);
115 if (csrResult != CSR_RESULT_SUCCESS) {
116 unifi_warning(priv,
117 "sme_mgt_wifi_on: unifi_configure_low_power_mode() returned an error\n");
118 }
119
120
121 /* Start the I/O thread */
122 CsrSdioClaim(priv->sdio);
123 r = uf_init_bh(priv);
124 if (r) {
125 CsrSdioPowerOff(priv->sdio);
126 CsrSdioRelease(priv->sdio);
127 return r;
128 }
129 CsrSdioRelease(priv->sdio);
130
131 priv->init_progress = UNIFI_INIT_FW_DOWNLOADED;
132
133 return 0;
134}
135
136int
137sme_sys_suspend(unifi_priv_t *priv)
138{
139 const int interfaceNum = 0; /* FIXME */
140 CsrResult csrResult;
141
142 /* Abort any pending requests. */
143 uf_abort_mlme(priv);
144
145 /* Allow our mlme request to go through. */
146 priv->io_aborted = 0;
147
148 /* Send MLME-RESET.req to UniFi. */
149 unifi_reset_state(priv, priv->netdev[interfaceNum]->dev_addr, 0);
150
151 /* Stop the network traffic */
152 netif_carrier_off(priv->netdev[interfaceNum]);
153
154 /* Put UniFi to deep sleep */
155 CsrSdioClaim(priv->sdio);
156 csrResult = unifi_force_low_power_mode(priv->card);
157 CsrSdioRelease(priv->sdio);
158
159 return 0;
160} /* sme_sys_suspend() */
161
162
163int
164sme_sys_resume(unifi_priv_t *priv)
165{
166#ifdef CSR_SUPPORT_WEXT
167 /* Send disconnect event so clients will re-initialise connection. */
168 memset(priv->wext_conf.current_ssid, 0, UNIFI_MAX_SSID_LEN);
169 memset((void*)priv->wext_conf.current_bssid, 0, ETH_ALEN);
170 priv->wext_conf.capability = 0;
171 wext_send_disassoc_event(priv);
172#endif
173 return 0;
174} /* sme_sys_resume() */
175
176
177/*
178 * ---------------------------------------------------------------------------
179 * sme_native_log_event
180 *
181 * Callback function to be registered as the SME event callback.
182 * Copies the signal content into a new udi_log_t struct and adds
183 * it to the read queue for the SME client.
184 *
185 * Arguments:
186 * arg This is the value given to unifi_add_udi_hook, in
187 * this case a pointer to the client instance.
188 * signal Pointer to the received signal.
189 * signal_len Size of the signal structure in bytes.
190 * bulkdata Pointers to any associated bulk data.
191 * dir Direction of the signal. Zero means from host,
192 * non-zero means to host.
193 *
194 * Returns:
195 * None.
196 * ---------------------------------------------------------------------------
197 */
198void
199sme_native_log_event(ul_client_t *pcli,
200 const u8 *sig_packed, int sig_len,
201 const bulk_data_param_t *bulkdata,
202 int dir)
203{
204 unifi_priv_t *priv;
205 udi_log_t *logptr;
206 u8 *p;
207 int i, r;
208 int signal_len;
209 int total_len;
210 udi_msg_t *msgptr;
211 CSR_SIGNAL signal;
212 ul_client_t *client = pcli;
213
214 if (client == NULL) {
215 unifi_error(NULL, "sme_native_log_event: client has exited\n");
216 return;
217 }
218
219 priv = uf_find_instance(client->instance);
220 if (!priv) {
221 unifi_error(priv, "invalid priv\n");
222 return;
223 }
224
225 /* Just a sanity check */
226 if ((sig_packed == NULL) || (sig_len <= 0)) {
227 return;
228 }
229
230 /* Get the unpacked signal */
231 r = read_unpack_signal(sig_packed, &signal);
232 if (r == 0) {
233 signal_len = SigGetSize(&signal);
234 } else {
235 u16 receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sig_packed) + sizeof(u16)) & 0xFF00;
236
237 /* The control indications are 1 byte, pass them to client. */
238 if (sig_len == 1) {
239 unifi_trace(priv, UDBG5,
240 "Control indication (0x%x) for native SME.\n",
241 *sig_packed);
242
243 *(u8*)&signal = *sig_packed;
244 signal_len = sig_len;
245 } else if (receiver_id == 0) {
246 /*
247 * Also "unknown" signals with a ReceiverId of 0 are passed to the client
248 * without unpacking. (This is a code size optimisation to allow signals
249 * that the driver not interested in to be dropped from the unpack code).
250 */
251 unifi_trace(priv, UDBG5,
252 "Signal 0x%.4X with ReceiverId 0 for native SME.\n",
253 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
254
255 *(u8*)&signal = *sig_packed;
256 signal_len = sig_len;
257 } else {
258 unifi_error(priv,
259 "sme_native_log_event - Received unknown signal 0x%.4X.\n",
260 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
261 return;
262 }
263 }
264
265 unifi_trace(priv, UDBG3, "sme_native_log_event: signal 0x%.4X for %d\n",
266 signal.SignalPrimitiveHeader.SignalId,
267 client->client_id);
268
269 total_len = signal_len;
270 /* Calculate the buffer we need to store signal plus bulk data */
271 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
272 total_len += bulkdata->d[i].data_length;
273 }
274
275 /* Allocate log structure plus actual signal. */
276 logptr = kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL);
277
278 if (logptr == NULL) {
279 unifi_error(priv,
280 "Failed to allocate %d bytes for a UDI log record\n",
281 sizeof(udi_log_t) + total_len);
282 return;
283 }
284
285 /* Fill in udi_log struct */
286 INIT_LIST_HEAD(&logptr->q);
287 msgptr = &logptr->msg;
288 msgptr->length = sizeof(udi_msg_t) + total_len;
289 msgptr->timestamp = jiffies_to_msecs(jiffies);
290 msgptr->direction = dir;
291 msgptr->signal_length = signal_len;
292
293 /* Copy signal and bulk data to the log */
294 p = (u8 *)(msgptr + 1);
295 memcpy(p, &signal, signal_len);
296 p += signal_len;
297
298 /* Append any bulk data */
299 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
300 int len = bulkdata->d[i].data_length;
301
302 /*
303 * Len here might not be the same as the length in the bulk data slot.
304 * The slot length will always be even, but len could be odd.
305 */
306 if (len > 0) {
307 if (bulkdata->d[i].os_data_ptr) {
308 memcpy(p, bulkdata->d[i].os_data_ptr, len);
309 } else {
310 memset(p, 0, len);
311 }
312 p += len;
313 }
314 }
315
316 /* Add to tail of log queue */
317 down(&client->udi_sem);
318 list_add_tail(&logptr->q, &client->udi_log);
319 up(&client->udi_sem);
320
321 /* Wake any waiting user process */
322 wake_up_interruptible(&client->udi_wq);
323
324} /* sme_native_log_event() */
325
326
327/*
328 * ---------------------------------------------------------------------------
329 * unifi_ta_indicate_protocol
330 *
331 * Report that a packet of a particular type has been seen
332 *
333 * Arguments:
334 * drv_priv The device context pointer passed to ta_init.
335 * protocol The protocol type enum value.
336 * direction Whether the packet was a tx or rx.
337 * src_addr The source MAC address from the data packet.
338 *
339 * Returns:
340 * None.
341 *
342 * Notes:
343 * We defer the actual sending to a background workqueue,
344 * see uf_ta_ind_wq().
345 * ---------------------------------------------------------------------------
346 */
347void
348unifi_ta_indicate_protocol(void *ospriv,
349 CsrWifiRouterCtrlTrafficPacketType packet_type,
350 CsrWifiRouterCtrlProtocolDirection direction,
351 const CsrWifiMacAddress *src_addr)
352{
353
354} /* unifi_ta_indicate_protocol */
355
356/*
357 * ---------------------------------------------------------------------------
358 * unifi_ta_indicate_sampling
359 *
360 * Send the TA sampling information to the SME.
361 *
362 * Arguments:
363 * drv_priv The device context pointer passed to ta_init.
364 * stats The TA sampling data to send.
365 *
366 * Returns:
367 * None.
368 * ---------------------------------------------------------------------------
369 */
370void
371unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats)
372{
373
374} /* unifi_ta_indicate_sampling() */
375
376
377void
378unifi_ta_indicate_l4stats(void *ospriv,
379 u32 rxTcpThroughput,
380 u32 txTcpThroughput,
381 u32 rxUdpThroughput,
382 u32 txUdpThroughput)
383{
384
385} /* unifi_ta_indicate_l4stats() */
386
387/*
388 * ---------------------------------------------------------------------------
389 * uf_native_process_udi_signal
390 *
391 * Process interesting signals from the UDI interface.
392 *
393 * Arguments:
394 * pcli A pointer to the client instance.
395 * signal Pointer to the received signal.
396 * signal_len Size of the signal structure in bytes.
397 * bulkdata Pointers to any associated bulk data.
398 * dir Direction of the signal. Zero means from host,
399 * non-zero means to host.
400 *
401 *
402 * Returns:
403 * None.
404 * ---------------------------------------------------------------------------
405 */
406void
407uf_native_process_udi_signal(ul_client_t *pcli,
408 const u8 *packed_signal, int packed_signal_len,
409 const bulk_data_param_t *bulkdata, int dir)
410{
411
412} /* uf_native_process_udi_signal() */
413
414
415/*
416 * ---------------------------------------------------------------------------
417 * sme_native_mlme_event_handler
418 *
419 * Callback function to be used as the udi_event_callback when registering
420 * as a client.
421 * This function implements a blocking request-reply interface for WEXT.
422 * To use it, a client specifies this function as the udi_event_callback
423 * to ul_register_client(). The signal dispatcher in
424 * unifi_receive_event() will call this function to deliver a signal.
425 *
426 * Arguments:
427 * pcli Pointer to the client instance.
428 * signal Pointer to the received signal.
429 * signal_len Size of the signal structure in bytes.
430 * bulkdata Pointer to structure containing any associated bulk data.
431 * dir Direction of the signal. Zero means from host,
432 * non-zero means to host.
433 *
434 * Returns:
435 * None.
436 * ---------------------------------------------------------------------------
437 */
438void
439sme_native_mlme_event_handler(ul_client_t *pcli,
440 const u8 *sig_packed, int sig_len,
441 const bulk_data_param_t *bulkdata,
442 int dir)
443{
444 CSR_SIGNAL signal;
445 int signal_len;
446 unifi_priv_t *priv = uf_find_instance(pcli->instance);
447 int id, r;
448
449 /* Just a sanity check */
450 if ((sig_packed == NULL) || (sig_len <= 0)) {
451 return;
452 }
453
454 /* Get the unpacked signal */
455 r = read_unpack_signal(sig_packed, &signal);
456 if (r == 0) {
457 signal_len = SigGetSize(&signal);
458 } else {
459 unifi_error(priv,
460 "sme_native_mlme_event_handler - Received unknown signal 0x%.4X.\n",
461 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
462 return;
463 }
464
465 id = signal.SignalPrimitiveHeader.SignalId;
466 unifi_trace(priv, UDBG4, "wext - Process signal 0x%.4X\n", id);
467
468 /*
469 * Take the appropriate action for the signal.
470 */
471 switch (id) {
472 /*
473 * Confirm replies from UniFi.
474 * These all have zero or one CSR_DATAREF member. (FIXME: check this is still true for softmac)
475 */
476 case CSR_MA_PACKET_CONFIRM_ID:
477 case CSR_MLME_RESET_CONFIRM_ID:
478 case CSR_MLME_GET_CONFIRM_ID:
479 case CSR_MLME_SET_CONFIRM_ID:
480 case CSR_MLME_GET_NEXT_CONFIRM_ID:
481 case CSR_MLME_POWERMGT_CONFIRM_ID:
482 case CSR_MLME_SCAN_CONFIRM_ID:
483 case CSR_MLME_HL_SYNC_CONFIRM_ID:
484 case CSR_MLME_MEASURE_CONFIRM_ID:
485 case CSR_MLME_SETKEYS_CONFIRM_ID:
486 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
487 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
488 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
489 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
490 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
491 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
492 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
493 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
494 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
495 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
496 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
497 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
498 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
499 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
500 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
501 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
502 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
503 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
504 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
505 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
506 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
507 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
508 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
509 case CSR_MLME_SM_START_CONFIRM_ID:
510 case CSR_MLME_LEAVE_CONFIRM_ID:
511 case CSR_MLME_SET_TIM_CONFIRM_ID:
512 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
513 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
514 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
515 case CSR_DEBUG_GENERIC_CONFIRM_ID:
516 unifi_mlme_copy_reply_and_wakeup_client(pcli, &signal, signal_len, bulkdata);
517 break;
518
519 case CSR_MLME_CONNECTED_INDICATION_ID:
520 /* We currently ignore the connected-ind for softmac f/w development */
521 unifi_info(priv, "CSR_MLME_CONNECTED_INDICATION_ID ignored\n");
522 break;
523
524 default:
525 break;
526 }
527
528} /* sme_native_mlme_event_handler() */
529
530
531
532/*
533 * -------------------------------------------------------------------------
534 * unifi_reset_state
535 *
536 * Ensure that a MAC address has been set.
537 * Send the MLME-RESET signal.
538 * This must be called at least once before starting to do any
539 * network activities (e.g. scan, join etc).
540 *
541 * Arguments:
542 * priv Pointer to device private context struct
543 * macaddr Pointer to chip MAC address.
544 * If this is FF:FF:FF:FF:FF:FF it will be replaced
545 * with the MAC address from the chip.
546 * set_default_mib 1 if the f/w must reset the MIB to the default values
547 * 0 otherwise
548 *
549 * Returns:
550 * 0 on success, an error code otherwise.
551 * -------------------------------------------------------------------------
552 */
553int
554unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr,
555 unsigned char set_default_mib)
556{
557 int r = 0;
558
559#ifdef CSR_SUPPORT_WEXT
560 /* The reset clears any 802.11 association. */
561 priv->wext_conf.flag_associated = 0;
562#endif
563
564 return r;
565} /* unifi_reset_state() */
566
diff --git a/drivers/staging/csr/sme_sys.c b/drivers/staging/csr/sme_sys.c
deleted file mode 100644
index b5258d71d250..000000000000
--- a/drivers/staging/csr/sme_sys.c
+++ /dev/null
@@ -1,3260 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: sme_sys.c
4 *
5 * PURPOSE:
6 * Driver specific implementation of the SME SYS SAP.
7 * It is part of the porting exercise.
8 *
9 * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16
17#include "csr_wifi_hip_unifiversion.h"
18#include "unifi_priv.h"
19#include "csr_wifi_hip_conversions.h"
20#ifdef CSR_SUPPORT_WEXT_AP
21#include "csr_wifi_sme_sef.h"
22#endif
23
24/*
25 * This file implements the SME SYS API and contains the following functions:
26 * CsrWifiRouterCtrlMediaStatusReqHandler()
27 * CsrWifiRouterCtrlHipReqHandler()
28 * CsrWifiRouterCtrlPortConfigureReqHandler()
29 * CsrWifiRouterCtrlWifiOnReqHandler()
30 * CsrWifiRouterCtrlWifiOffReqHandler()
31 * CsrWifiRouterCtrlSuspendResHandler()
32 * CsrWifiRouterCtrlResumeResHandler()
33 * CsrWifiRouterCtrlQosControlReqHandler()
34 * CsrWifiRouterCtrlConfigurePowerModeReqHandler()
35 * CsrWifiRouterCtrlWifiOnResHandler()
36 * CsrWifiRouterCtrlWifiOffRspHandler()
37 * CsrWifiRouterCtrlMulticastAddressResHandler()
38 * CsrWifiRouterCtrlTrafficConfigReqHandler()
39 * CsrWifiRouterCtrlTrafficClassificationReqHandler()
40 * CsrWifiRouterCtrlTclasAddReqHandler()
41 * CsrWifiRouterCtrlTclasDelReqHandler()
42 * CsrWifiRouterCtrlSetModeReqHandler()
43 * CsrWifiRouterCtrlWapiMulticastFilterReqHandler()
44 * CsrWifiRouterCtrlWapiUnicastFilterReqHandler()
45 * CsrWifiRouterCtrlWapiUnicastTxPktReqHandler()
46 * CsrWifiRouterCtrlWapiRxPktReqHandler()
47 * CsrWifiRouterCtrlWapiFilterReqHandler()
48 */
49
50#ifdef CSR_SUPPORT_SME
51static void check_inactivity_timer_expire_func(unsigned long data);
52void uf_send_disconnected_ind_wq(struct work_struct *work);
53#endif
54
55void send_auto_ma_packet_confirm(unifi_priv_t *priv,
56 netInterface_priv_t *interfacePriv,
57 struct list_head *buffered_frames_list)
58{
59 tx_buffered_packets_t *buffered_frame_item = NULL;
60 struct list_head *listHead;
61 struct list_head *placeHolder;
62 int client_id;
63
64 CSR_SIGNAL unpacked_signal;
65 u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
66 u16 packed_siglen;
67
68
69 list_for_each_safe(listHead, placeHolder, buffered_frames_list)
70 {
71 buffered_frame_item = list_entry(listHead, tx_buffered_packets_t, q);
72
73 if(!buffered_frame_item) {
74 unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
75 continue;
76 }
77
78 if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_NONE) &&
79 (priv->wifi_on_state == wifi_on_done))
80 {
81
82 unifi_warning(priv, "Send MA_PACKET_CONFIRM to SenderProcessId = %x for (HostTag = %x TransmissionControl = %x)\n",
83 (buffered_frame_item->leSenderProcessId),
84 buffered_frame_item->hostTag,
85 buffered_frame_item->transmissionControl);
86
87 client_id = buffered_frame_item->leSenderProcessId & 0xFF00;
88
89 if (client_id == priv->sme_cli->sender_id)
90 {
91 /* construct a MA-PACKET.confirm message for SME */
92 memset(&unpacked_signal, 0, sizeof(unpacked_signal));
93 unpacked_signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_CONFIRM_ID;
94 unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId = buffered_frame_item->leSenderProcessId;
95 unpacked_signal.SignalPrimitiveHeader.SenderProcessId = CSR_WIFI_ROUTER_IFACEQUEUE;
96
97 unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,
98 interfacePriv->InterfaceTag);
99 unpacked_signal.u.MaPacketConfirm.TransmissionStatus = CSR_RESULT_FAILURE;
100 unpacked_signal.u.MaPacketConfirm.RetryCount = 0;
101 unpacked_signal.u.MaPacketConfirm.Rate = buffered_frame_item->rate;
102 unpacked_signal.u.MaPacketConfirm.HostTag = buffered_frame_item->hostTag;
103
104 write_pack(&unpacked_signal, sigbuf, &packed_siglen);
105 unifi_warning(priv, "MA_PACKET_CONFIRM for SME (0x%x, 0x%x, 0x%x, 0x%x)\n",
106 unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId,
107 unpacked_signal.SignalPrimitiveHeader.SenderProcessId,
108 unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier,
109 unpacked_signal.u.MaPacketConfirm.HostTag);
110
111 CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
112 packed_siglen,
113 (u8 *)sigbuf,
114 0, NULL,
115 0, NULL);
116 }
117 else if((buffered_frame_item->hostTag & 0x80000000))
118 {
119 /* construct a MA-PACKET.confirm message for NME */
120 unifi_warning(priv, "MA_PACKET_CONFIRM for NME (0x%x, 0x%x, 0x%x, 0x%x)\n",
121 buffered_frame_item->leSenderProcessId,
122 buffered_frame_item->interfaceTag,
123 buffered_frame_item->transmissionControl,
124 (buffered_frame_item->hostTag & 0x3FFFFFFF));
125
126 CsrWifiRouterMaPacketCfmSend((buffered_frame_item->leSenderProcessId & 0xFF),
127 buffered_frame_item->interfaceTag,
128 CSR_RESULT_FAILURE,
129 (buffered_frame_item->hostTag & 0x3FFFFFFF),
130 buffered_frame_item->rate);
131
132 }
133 else
134 {
135 unifi_warning(priv, "Buffered packet dropped without sending a confirm\n");
136 }
137
138 }
139
140 list_del(listHead);
141 kfree(buffered_frame_item);
142 buffered_frame_item = NULL;
143 }
144}
145
146void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
147{
148 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
149 CsrWifiRouterCtrlMediaStatusReq* req = (CsrWifiRouterCtrlMediaStatusReq*)msg;
150 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
151 unsigned long flags;
152
153 if (priv->smepriv == NULL) {
154 unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid smepriv\n");
155 return;
156 }
157 if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
158 unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid interfaceTag\n");
159 return;
160 }
161 unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlMediaStatusReqHandler: Mode = %d req->mediaStatus = %d\n", interfacePriv->interfaceMode, req->mediaStatus);
162 if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AMP) {
163 bulk_data_desc_t bulk_data;
164
165 bulk_data.data_length = 0;
166
167 spin_lock_irqsave(&priv->m4_lock, flags);
168 if (interfacePriv->m4_bulk_data.data_length > 0) {
169 bulk_data = interfacePriv->m4_bulk_data;
170 interfacePriv->m4_bulk_data.net_buf_length = 0;
171 interfacePriv->m4_bulk_data.data_length = 0;
172 interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
173 }
174 spin_unlock_irqrestore(&priv->m4_lock, flags);
175
176 if (bulk_data.data_length != 0) {
177 unifi_trace(priv, UDBG5, "CsrWifiRouterCtrlMediaStatusReqHandler: free M4\n");
178 unifi_net_data_free(priv, &bulk_data);
179 }
180
181 if ((req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) &&
182 (interfacePriv->connected != UnifiConnected)) {
183
184 switch(interfacePriv->interfaceMode){
185 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
186 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
187 interfacePriv->connected = UnifiConnected;
188 netif_carrier_on(priv->netdev[req->interfaceTag]);
189#ifdef CSR_SUPPORT_WEXT
190 wext_send_started_event(priv);
191#endif
192 unifi_trace(priv, UDBG1,
193 "CsrWifiRouterCtrlMediaStatusReqHandler: AP/P2PGO setting netif_carrier_on\n");
194 netif_tx_wake_all_queues(priv->netdev[req->interfaceTag]);
195 break;
196
197 default:
198#ifdef CSR_SUPPORT_WEXT
199 /* In the WEXT builds (sme and native), the userspace is not ready
200 * to process any EAPOL or WAPI packets, until it has been informed
201 * of the NETDEV_CHANGE.
202 */
203 if (interfacePriv->netdev_callback_registered && (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI)) {
204 interfacePriv->wait_netdev_change = TRUE;
205 unifi_trace(priv, UDBG1,
206 "CsrWifiRouterCtrlMediaStatusReqHandler: waiting for NETDEV_CHANGE\n");
207 /*
208 * Carrier can go to on, only after wait_netdev_change is set to TRUE.
209 * Otherwise there can be a race in uf_netdev_event().
210 */
211 netif_carrier_on(priv->netdev[req->interfaceTag]);
212 unifi_trace(priv, UDBG1,
213 "CsrWifiRouterCtrlMediaStatusReqHandler: STA/P2PCLI setting netif_carrier_on\n");
214 }
215 else
216#endif
217 {
218 /* In the NME build, the userspace does not wait for the NETDEV_CHANGE
219 * so it is ready to process all the EAPOL or WAPI packets.
220 * At this point, we enable all the Tx queues, and we indicate any packets
221 * that are queued (and the respective port is opened).
222 */
223 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
224 interfacePriv->connected = UnifiConnected;
225 unifi_trace(priv, UDBG1,
226 "CsrWifiRouterMediaStatusReqHandler: UnifiConnected && netif_carrier_on\n");
227 netif_carrier_on(priv->netdev[req->interfaceTag]);
228 netif_tx_wake_all_queues(priv->netdev[req->interfaceTag]);
229 uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
230 uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
231 }
232 break;
233 }
234 }
235
236 if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED) {
237#ifdef CSR_SUPPORT_WEXT
238 unifi_trace(priv, UDBG1,
239 "CsrWifiRouterMediaStatusReqHandler: cancel waiting for NETDEV_CHANGE\n");
240 interfacePriv->wait_netdev_change = FALSE;
241#endif
242 unifi_trace(priv, UDBG1,
243 "CsrWifiRouterMediaStatusReqHandler: setting netif_carrier_off\n");
244 netif_carrier_off(priv->netdev[req->interfaceTag]);
245#ifdef CSR_SUPPORT_WEXT
246 switch(interfacePriv->interfaceMode){
247 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
248 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
249 wext_send_started_event(priv);
250 break;
251 default:
252 break;
253 }
254#endif
255 interfacePriv->connected = UnifiNotConnected;
256 }
257 } else {
258 /* For AMP, just update the L2 connected flag */
259 if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) {
260 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP connected\n");
261 interfacePriv->connected = UnifiConnected;
262 } else {
263 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP disconnected\n");
264 interfacePriv->connected = UnifiNotConnected;
265 }
266 }
267}
268
269
270void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
271{
272 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
273 CsrWifiRouterCtrlHipReq* hipreq = (CsrWifiRouterCtrlHipReq*)msg;
274 bulk_data_param_t bulkdata;
275 u8 *signal_ptr;
276 int signal_length;
277 int r=0;
278 void *dest;
279 CsrResult csrResult;
280 CSR_SIGNAL *signal;
281 u16 interfaceTag = 0;
282 CSR_MA_PACKET_REQUEST *req;
283 netInterface_priv_t *interfacePriv;
284
285 if (priv == NULL) {
286 return;
287 }
288 if (priv->smepriv == NULL) {
289 unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid smepriv\n");
290 return;
291 }
292 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
293 unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid interfaceTag\n");
294 return;
295 }
296
297 interfacePriv = priv->interfacePriv[interfaceTag];
298
299 /* Initialize bulkdata to avoid os_net_buf is garbage */
300 memset(&bulkdata, 0, sizeof(bulk_data_param_t));
301
302 signal = (CSR_SIGNAL *)hipreq->mlmeCommand;
303
304 unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: 0x04%X ---->\n",
305 *((u16*)hipreq->mlmeCommand));
306
307 /* Construct the signal. */
308 signal_ptr = (u8*)hipreq->mlmeCommand;
309 signal_length = hipreq->mlmeCommandLength;
310
311 /*
312 * The MSB of the sender ID needs to be set to the client ID.
313 * The LSB is controlled by the SME.
314 */
315 signal_ptr[5] = (priv->sme_cli->sender_id >> 8) & 0xff;
316
317 /* Allocate buffers for the bulk data. */
318 if (hipreq->dataRef1Length) {
319 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], hipreq->dataRef1Length);
320 if (csrResult == CSR_RESULT_SUCCESS) {
321 dest = (void*)bulkdata.d[0].os_data_ptr;
322 memcpy(dest, hipreq->dataRef1, hipreq->dataRef1Length);
323 bulkdata.d[0].data_length = hipreq->dataRef1Length;
324 } else {
325 unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
326 return;
327 }
328 } else {
329 bulkdata.d[0].os_data_ptr = NULL;
330 bulkdata.d[0].data_length = 0;
331 }
332 if (hipreq->dataRef2Length) {
333 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[1], hipreq->dataRef2Length);
334 if (csrResult == CSR_RESULT_SUCCESS) {
335 dest = (void*)bulkdata.d[1].os_data_ptr;
336 memcpy(dest, hipreq->dataRef2, hipreq->dataRef2Length);
337 bulkdata.d[1].data_length = hipreq->dataRef2Length;
338 } else {
339 if (bulkdata.d[0].data_length)
340 {
341 unifi_net_data_free(priv, &bulkdata.d[0]);
342 }
343 unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
344 return;
345 }
346 } else {
347 bulkdata.d[1].os_data_ptr = NULL;
348 bulkdata.d[1].data_length = 0;
349 }
350
351 unifi_trace(priv, UDBG3, "SME SEND: Signal 0x%.4X \n",
352 *((u16*)signal_ptr));
353 if (signal->SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_REQUEST_ID)
354 {
355 CSR_SIGNAL unpacked_signal;
356 read_unpack_signal((u8 *) signal, &unpacked_signal);
357 req = &unpacked_signal.u.MaPacketRequest;
358 interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
359 switch(interfacePriv->interfaceMode)
360 {
361 case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
362 unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid mode: NONE \n");
363 break;
364 default:
365 unifi_trace(priv, UDBG5, "mode is %x\n", interfacePriv->interfaceMode);
366 }
367 /* While sending ensure that first 2 bits b31 and b30 are 00. These are used for local routing*/
368 r = uf_process_ma_packet_req(priv, req->Ra.x, (req->HostTag & 0x3FFFFFFF), interfaceTag,
369 req->TransmissionControl, req->TransmitRate,
370 req->Priority, signal->SignalPrimitiveHeader.SenderProcessId,
371 &bulkdata);
372 if (r)
373 {
374 if (bulkdata.d[0].data_length)
375 {
376 unifi_net_data_free(priv, &bulkdata.d[0]);
377 }
378 if (bulkdata.d[1].data_length)
379 {
380 unifi_net_data_free(priv, &bulkdata.d[1]);
381 }
382 }
383 } else {
384 /* ul_send_signal_raw frees the bulk data if it fails */
385 r = ul_send_signal_raw(priv, signal_ptr, signal_length, &bulkdata);
386 }
387
388 if (r) {
389 unifi_error(priv,
390 "CsrWifiRouterCtrlHipReqHandler: Failed to send signal (0x%.4X - %u)\n",
391 *((u16*)signal_ptr), r);
392 CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, CSR_WIFI_SME_CONTROL_INDICATION_ERROR);
393 }
394
395 unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: <----\n");
396}
397
398#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
399static void
400uf_send_gratuitous_arp(unifi_priv_t *priv, u16 interfaceTag)
401{
402 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
403 CSR_PRIORITY priority;
404 CSR_SIGNAL signal;
405 bulk_data_param_t bulkdata;
406 CsrResult csrResult;
407 struct sk_buff *skb, *newSkb = NULL;
408 s8 protection;
409 int r;
410 static const u8 arp_req[36] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,
411 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01,
412 0x00, 0x02, 0x5f, 0x20, 0x2f, 0x02,
413 0xc0, 0xa8, 0x00, 0x02,
414 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
415 0xc0, 0xa8, 0x00, 0x02};
416
417 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], sizeof(arp_req));
418 if (csrResult != CSR_RESULT_SUCCESS)
419 {
420 unifi_error(priv, "Failed to allocate bulk data in CsrWifiSmeRoamCompleteIndHandler()\n");
421 return;
422 }
423 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
424 skb->len = bulkdata.d[0].data_length;
425
426 memcpy(skb->data, arp_req, sizeof(arp_req));
427 /* add MAC and IP address */
428 memcpy(skb->data + 16, priv->netdev[interfaceTag]->dev_addr, ETH_ALEN);
429 skb->data[22] = (priv->sta_ip_address ) & 0xFF;
430 skb->data[23] = (priv->sta_ip_address >> 8) & 0xFF;
431 skb->data[24] = (priv->sta_ip_address >> 16) & 0xFF;
432 skb->data[25] = (priv->sta_ip_address >> 24) & 0xFF;
433 skb->data[32] = (priv->sta_ip_address ) & 0xFF;
434 skb->data[33] = (priv->sta_ip_address >> 8) & 0xFF;
435 skb->data[34] = (priv->sta_ip_address >> 16) & 0xFF;
436 skb->data[35] = (priv->sta_ip_address >> 24) & 0xFF;
437
438 bulkdata.d[1].os_data_ptr = NULL;
439 bulkdata.d[1].os_net_buf_ptr = NULL;
440 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
441
442 if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, &arp_req[26])) < 0)
443 {
444 unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: Failed to determine protection mode\n");
445 unifi_net_data_free(priv, &bulkdata.d[0]);
446 return;
447 }
448
449 if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1)
450 {
451 priority = CSR_QOS_UP0;
452 }
453 else
454 {
455 priority = CSR_CONTENTION;
456 }
457
458 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata,
459 interfaceTag, &arp_req[26],
460 priv->netdev[interfaceTag]->dev_addr, protection))
461 {
462 unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to create MAC header\n");
463 unifi_net_data_free(priv, &bulkdata.d[0]);
464 return;
465 }
466 bulkdata.d[0].os_data_ptr = skb->data;
467 bulkdata.d[0].os_net_buf_ptr = skb;
468 bulkdata.d[0].data_length = skb->len;
469
470 unifi_frame_ma_packet_req(priv, priority, 0, 0xffffffff, interfaceTag,
471 CSR_NO_CONFIRM_REQUIRED, priv->netdev_client->sender_id,
472 interfacePriv->bssid.a, &signal);
473
474 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
475 if (r)
476 {
477 unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to send QOS data null packet result: %d\n", r);
478 unifi_net_data_free(priv, &bulkdata.d[0]);
479 return;
480 }
481
482}
483#endif /* CSR_WIFI_SEND_GRATUITOUS_ARP */
484
485/*
486 * ---------------------------------------------------------------------------
487 * configure_data_port
488 *
489 * Store the new controlled port configuration.
490 *
491 * Arguments:
492 * priv Pointer to device private context struct
493 * port_cfg Pointer to the port configuration
494 *
495 * Returns:
496 * An unifi_ControlledPortAction value.
497 * ---------------------------------------------------------------------------
498 */
499static int
500configure_data_port(unifi_priv_t *priv,
501 CsrWifiRouterCtrlPortAction port_action,
502 const CsrWifiMacAddress *macAddress,
503 const int queue,
504 u16 interfaceTag)
505{
506 const u8 broadcast_mac_address[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
507 unifi_port_config_t *port;
508 netInterface_priv_t *interfacePriv;
509 int i;
510 const char* controlled_string; /* cosmetic "controlled"/"uncontrolled" for trace */
511
512 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
513 unifi_error(priv, "configure_data_port: bad interfaceTag\n");
514 return -EFAULT;
515 }
516
517 interfacePriv = priv->interfacePriv[interfaceTag];
518
519 if (queue == UF_CONTROLLED_PORT_Q) {
520 port = &interfacePriv->controlled_data_port;
521 controlled_string = "controlled";
522 } else {
523 port = &interfacePriv->uncontrolled_data_port;
524 controlled_string = "uncontrolled";
525 }
526
527 unifi_trace(priv, UDBG2,
528 "port config request %pM %s with port_action %d.\n",
529 macAddress->a, controlled_string, port_action);
530
531 /* 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 */
532 if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode ||
533 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) ||
534 !memcmp(macAddress->a, broadcast_mac_address, ETH_ALEN)) {
535
536 port->port_cfg[0].port_action = port_action;
537 port->port_cfg[0].mac_address = *macAddress;
538 port->port_cfg[0].in_use = TRUE;
539 port->entries_in_use = 1;
540 port->overide_action = UF_DATA_PORT_OVERIDE;
541
542 unifi_trace(priv, UDBG2, "%s port override on\n",
543 (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
544
545 /* Discard the remaining entries in the port config table */
546 for (i = 1; i < UNIFI_MAX_CONNECTIONS; i++) {
547 port->port_cfg[i].in_use = FALSE;
548 }
549
550 if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
551 unifi_trace(priv, UDBG1, "%s port broadcast set to open.\n",
552 (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
553
554 /*
555 * Ask stack to schedule for transmission any packets queued
556 * while controlled port was not open.
557 * Use netif_schedule() instead of netif_wake_queue() because
558 * transmission should be already enabled at this point. If it
559 * is not, probably the interface is down and should remain as is.
560 */
561 uf_resume_data_plane(priv, queue, *macAddress, interfaceTag);
562
563#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
564 if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) &&
565 (queue == UF_CONTROLLED_PORT_Q) && (priv->sta_ip_address != 0xFFFFFFFF))
566 {
567 uf_send_gratuitous_arp(priv, interfaceTag);
568 }
569#endif
570 } else {
571 unifi_trace(priv, UDBG1, "%s port broadcast set to %s.\n",
572 (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled",
573 (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) ? "discard": "closed");
574
575 /* If port is closed, discard all the pending Rx packets */
576 if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
577 uf_free_pending_rx_packets(priv, queue, *macAddress, interfaceTag);
578 }
579 }
580 } else {
581 /* store the new configuration, either in the entry with matching mac address (if already present),
582 * otherwise in a new entry
583 */
584
585 int found_entry_flag;
586 int first_free_slot = -1;
587
588 /* If leaving override mode, free the port entry used for override */
589 if (port->overide_action == UF_DATA_PORT_OVERIDE) {
590 port->port_cfg[0].in_use = FALSE;
591 port->entries_in_use = 0;
592 port->overide_action = UF_DATA_PORT_NOT_OVERIDE;
593
594 unifi_trace(priv, UDBG2, "%s port override off\n",
595 (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
596 }
597
598 found_entry_flag = 0;
599 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
600 if (port->port_cfg[i].in_use) {
601 if (!memcmp(&port->port_cfg[i].mac_address.a, macAddress->a, ETH_ALEN)) {
602 /* We've seen this address before, reconfigure it */
603 port->port_cfg[i].port_action = port_action;
604 found_entry_flag = 1;
605 break;
606 }
607 } else if (first_free_slot == -1) {
608 /* Remember the first free slot on the way past so it can be claimed
609 * if this turns out to be a new MAC address (to save walking the list again).
610 */
611 first_free_slot = i;
612 }
613 }
614
615 /* At this point we found an existing entry and have updated it, or need to
616 * add a new entry. If all slots are allocated, give up and return an error.
617 */
618 if (!found_entry_flag) {
619 if (first_free_slot == -1) {
620 unifi_error(priv, "no free slot found in port config array (%d used)\n", port->entries_in_use);
621 return -EFAULT;
622 } else {
623 port->entries_in_use++;
624 }
625
626 unifi_trace(priv, UDBG3, "port config index assigned in config_data_port = %d\n", first_free_slot);
627 port->port_cfg[first_free_slot].in_use = TRUE;
628 port->port_cfg[first_free_slot].port_action = port_action;
629 port->port_cfg[first_free_slot].mac_address = *macAddress;
630 }
631
632 if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
633 /*
634 * Ask stack to schedule for transmission any packets queued
635 * while controlled port was not open.
636 * Use netif_schedule() instead of netif_wake_queue() because
637 * transmission should be already enabled at this point. If it
638 * is not, probably the interface is down and should remain as is.
639 */
640 uf_resume_data_plane(priv, queue, *macAddress, interfaceTag);
641 }
642
643 /*
644 * If port is closed, discard all the pending Rx packets
645 * coming from the peer station.
646 */
647 if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
648 uf_free_pending_rx_packets(priv, queue, *macAddress, interfaceTag);
649 }
650
651 unifi_trace(priv, UDBG2,
652 "port config %pM with port_action %d.\n",
653 macAddress->a, port_action);
654 }
655 return 0;
656} /* configure_data_port() */
657
658
659void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
660{
661 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
662 CsrWifiRouterCtrlPortConfigureReq* req = (CsrWifiRouterCtrlPortConfigureReq*)msg;
663 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
664
665 unifi_trace(priv, UDBG3, "entering CsrWifiRouterCtrlPortConfigureReqHandler\n");
666 if (priv->smepriv == NULL) {
667 unifi_error(priv, "CsrWifiRouterCtrlPortConfigureReqHandler: invalid smepriv\n");
668 return;
669 }
670
671 /* To update the protection status of the peer/station */
672 switch(interfacePriv->interfaceMode)
673 {
674 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
675 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
676 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
677 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
678 /* Since for Unifi as a station, the station record not maintained & interfaceID is
679 * only needed to update the peer protection status
680 */
681 interfacePriv->protect = req->setProtection;
682 break;
683 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
684 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
685 {
686 u8 i;
687 CsrWifiRouterCtrlStaInfo_t *staRecord;
688 /* Ifscontrolled port is open means, The peer has been added to station record
689 * so that the protection corresponding to the peer is valid in this req
690 */
691 if (req->controlledPortAction == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
692 for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
693 staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
694 if (staRecord) {
695 /* Find the matching station record & set the protection type */
696 if (!memcmp(req->macAddress.a, staRecord->peerMacAddress.a, ETH_ALEN)) {
697 staRecord->protection = req->setProtection;
698 break;
699 }
700 }
701 }
702 }
703 }
704 break;
705 default:
706 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlPortConfigureReqHandler(0x%.4X) Uncaught mode %d\n",
707 msg->source, interfacePriv->interfaceMode);
708 }
709
710 configure_data_port(priv, req->uncontrolledPortAction, (const CsrWifiMacAddress *)&req->macAddress,
711 UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
712 configure_data_port(priv, req->controlledPortAction, (const CsrWifiMacAddress *)&req->macAddress,
713 UF_CONTROLLED_PORT_Q, req->interfaceTag);
714
715 CsrWifiRouterCtrlPortConfigureCfmSend(msg->source, req->clientData, req->interfaceTag,
716 CSR_RESULT_SUCCESS, req->macAddress);
717 unifi_trace(priv, UDBG3, "leaving CsrWifiRouterCtrlPortConfigureReqHandler\n");
718}
719
720
721void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
722{
723 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
724 CsrWifiRouterCtrlVersions versions;
725 CsrWifiRouterCtrlWifiOnReq* req = (CsrWifiRouterCtrlWifiOnReq*)msg;
726 int r, i;
727 CsrResult csrResult;
728
729 if (priv == NULL) {
730 return;
731 }
732 if( priv->wol_suspend ) {
733 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n");
734 } else {
735#ifdef ANDROID_BUILD
736 /* Take the wakelock while Wi-Fi On is in progress */
737 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n");
738 wake_lock(&unifi_sdio_wake_lock);
739#endif
740 for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
741 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n", i );
742
743 priv->interfacePriv[i]->interfaceMode = 0;
744 }
745 }
746 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler(0x%.4X) req->dataLength=%d req->data=0x%x\n", msg->source, req->dataLength, req->data);
747
748 if(req->dataLength==3 && req->data && req->data[0]==0 && req->data[1]==1 && req->data[2]==1)
749 {
750 priv->cmanrTestMode = TRUE;
751 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: cmanrTestMode=%d\n", priv->cmanrTestMode);
752 }
753 else
754 {
755 priv->cmanrTestMode = FALSE;
756 }
757
758 /*
759 * The request to initialise UniFi might come while UniFi is running.
760 * We need to block all I/O activity until the reset completes, otherwise
761 * an SDIO error might occur resulting an indication to the SME which
762 * makes it think that the initialisation has failed.
763 */
764 priv->bh_thread.block_thread = 1;
765
766 /* Update the wifi_on state */
767 priv->wifi_on_state = wifi_on_in_progress;
768
769 /* If UniFi was unpowered, acquire the firmware for download to chip */
770 if (!priv->wol_suspend) {
771 r = uf_request_firmware_files(priv, UNIFI_FW_STA);
772 if (r) {
773 unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to get f/w\n");
774 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
775 return;
776 }
777 } else {
778 unifi_trace(priv, UDBG1, "Don't need firmware\n");
779 }
780
781 /* Power on UniFi (which may not necessarily have been off) */
782 CsrSdioClaim(priv->sdio);
783 csrResult = CsrSdioPowerOn(priv->sdio);
784 CsrSdioRelease(priv->sdio);
785 if (csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) {
786 unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to power on UniFi\n");
787 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
788 return;
789 }
790
791 /* If CsrSdioPowerOn() returns CSR_RESULT_SUCCESS, it means that we need to initialise UniFi */
792 if (csrResult == CSR_RESULT_SUCCESS && !priv->wol_suspend) {
793 /* Initialise UniFi hardware */
794 r = uf_init_hw(priv);
795 if (r) {
796 unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
797 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
798 return;
799 }
800 } else {
801 unifi_trace(priv, UDBG1, "UniFi already initialised\n");
802 }
803
804 /* Completed handling of wake up from suspend with UniFi powered */
805 priv->wol_suspend = FALSE;
806
807 /* Re-enable the I/O thread */
808 priv->bh_thread.block_thread = 0;
809
810 /*
811 * Start the I/O thread. The thread might be already running.
812 * This fine, just carry on with the request.
813 */
814 r = uf_init_bh(priv);
815 if (r) {
816 CsrSdioClaim(priv->sdio);
817 CsrSdioPowerOff(priv->sdio);
818 CsrSdioRelease(priv->sdio);
819 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
820 return;
821 }
822
823 /* Get the version information from the core */
824 unifi_card_info(priv->card, &priv->card_info);
825
826 /* Set the sme queue id */
827 priv->CSR_WIFI_SME_IFACEQUEUE = msg->source;
828 CSR_WIFI_SME_IFACEQUEUE = msg->source;
829
830
831 /* Copy to the unifiio_card_info structure. */
832 versions.chipId = priv->card_info.chip_id;
833 versions.chipVersion = priv->card_info.chip_version;
834 versions.firmwareBuild = priv->card_info.fw_build;
835 versions.firmwareHip = priv->card_info.fw_hip_version;
836 versions.routerBuild = (char*)CSR_WIFI_VERSION;
837 versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION;
838
839 CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions);
840
841 /* Update the wifi_on state */
842 priv->wifi_on_state = wifi_on_done;
843}
844
845
846/*
847 * wifi_off:
848 * Common code for CsrWifiRouterCtrlWifiOffReqHandler() and
849 * CsrWifiRouterCtrlWifiOffRspHandler().
850 */
851static void
852wifi_off(unifi_priv_t *priv)
853{
854 int power_off;
855 int priv_instance;
856 int i;
857 CsrResult csrResult;
858
859
860 /* Already off? */
861 if (priv->wifi_on_state == wifi_on_unspecified) {
862 unifi_trace(priv, UDBG1, "wifi_off already\n");
863 return;
864 }
865
866 unifi_trace(priv, UDBG1, "wifi_off\n");
867
868 /* Destroy the Traffic Analysis Module */
869 cancel_work_sync(&priv->ta_ind_work.task);
870 cancel_work_sync(&priv->ta_sample_ind_work.task);
871#ifdef CSR_SUPPORT_WEXT
872 cancel_work_sync(&priv->sme_config_task);
873 wext_send_disassoc_event(priv);
874#endif
875
876 /* Cancel pending M4 stuff */
877 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
878 if (priv->netdev[i]) {
879 netInterface_priv_t *netpriv = (netInterface_priv_t *) netdev_priv(priv->netdev[i]);
880 cancel_work_sync(&netpriv->send_m4_ready_task);
881 }
882 }
883 flush_workqueue(priv->unifi_workqueue);
884
885 /* fw_init parameter can prevent power off UniFi, for debugging */
886 priv_instance = uf_find_priv(priv);
887 if (priv_instance == -1) {
888 unifi_warning(priv,
889 "CsrWifiRouterCtrlStopReqHandler: Unknown priv instance, will power off card.\n");
890 power_off = 1;
891 } else {
892 power_off = (fw_init[priv_instance] > 0) ? 0 : 1;
893 }
894
895 /* Production test mode requires power to the chip, too */
896 if (priv->ptest_mode) {
897 power_off = 0;
898 }
899
900 /* Stop the bh_thread */
901 uf_stop_thread(priv, &priv->bh_thread);
902
903 /* Read the f/w panic codes, if any. Protect against second wifi_off() call,
904 * which may happen if SME requests a wifi_off and closes the char device */
905 if (priv->init_progress != UNIFI_INIT_NONE) {
906 CsrSdioClaim(priv->sdio);
907 unifi_capture_panic(priv->card);
908 CsrSdioRelease(priv->sdio);
909 }
910
911 /* Unregister the interrupt handler */
912 if (csr_sdio_linux_remove_irq(priv->sdio)) {
913 unifi_notice(priv,
914 "csr_sdio_linux_remove_irq failed to talk to card.\n");
915 }
916
917 if (power_off) {
918 unifi_trace(priv, UDBG2,
919 "Force low power and try to power off\n");
920 /* Put UniFi to deep sleep, in case we can not power it off */
921 CsrSdioClaim(priv->sdio);
922 csrResult = unifi_force_low_power_mode(priv->card);
923 CsrSdioRelease(priv->sdio);
924
925 CsrSdioPowerOff(priv->sdio);
926 }
927
928 /* Consider UniFi to be uninitialised */
929 priv->init_progress = UNIFI_INIT_NONE;
930 priv->wifi_on_state = wifi_on_unspecified;
931
932
933} /* wifi_off() */
934
935
936void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
937{
938 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
939 CsrWifiRouterCtrlWifiOffReq* req = (CsrWifiRouterCtrlWifiOffReq*)msg;
940 int i = 0;
941
942 if (priv == NULL) {
943 return;
944 }
945
946 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOffReqHandler(0x%.4X)\n", msg->source);
947
948 /* Stop the network traffic on all interfaces before freeing the core. */
949 for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
950 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
951 if (interfacePriv->netdev_registered == 1) {
952 netif_carrier_off(priv->netdev[i]);
953 netif_tx_stop_all_queues(priv->netdev[i]);
954 interfacePriv->connected = UnifiConnectedUnknown;
955 }
956 interfacePriv->interfaceMode = 0;
957
958 /* Enable all queues by default */
959 interfacePriv->queueEnabled[0] = 1;
960 interfacePriv->queueEnabled[1] = 1;
961 interfacePriv->queueEnabled[2] = 1;
962 interfacePriv->queueEnabled[3] = 1;
963 }
964 wifi_off(priv);
965
966 CsrWifiRouterCtrlWifiOffCfmSend(msg->source, req->clientData);
967
968 /* If this is called in response to closing the character device, the
969 * caller must use uf_sme_cancel_request() to terminate any pending SME
970 * blocking request or there will be a delay while the operation times out.
971 */
972}
973
974
975void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
976{
977 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
978 CsrWifiRouterCtrlQosControlReq* req = (CsrWifiRouterCtrlQosControlReq*)msg;
979 netInterface_priv_t *interfacePriv;
980
981 if (priv->smepriv == NULL) {
982 unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: invalid smepriv\n");
983 return;
984 }
985
986 unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlQosControlReqHandler:scontrol = %d", req->control);
987
988 if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
989 unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
990 return;
991 }
992 interfacePriv = priv->interfacePriv[req->interfaceTag];
993
994 if (req->control == CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON) {
995 priv->sta_wmm_capabilities |= QOS_CAPABILITY_WMM_ENABLED;
996 unifi_trace(priv, UDBG1, "WMM enabled\n");
997
998 unifi_trace(priv, UDBG1, "Queue Config %x\n", req->queueConfig);
999
1000 interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BK] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE)?1:0;
1001 interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BE] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE)?1:0;
1002 interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VI] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE)?1:0;
1003 interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VO] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE)?1:0;
1004
1005 } else {
1006 priv->sta_wmm_capabilities = 0;
1007 unifi_trace(priv, UDBG1, "WMM disabled\n");
1008 }
1009}
1010
1011
1012void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1013{
1014 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1015 CsrWifiRouterCtrlTclasAddReq* req = (CsrWifiRouterCtrlTclasAddReq*)msg;
1016
1017 if (priv == NULL) {
1018 unifi_error(priv, "CsrWifiRouterCtrlTclasAddReqHandler: invalid smepriv\n");
1019 return;
1020 }
1021
1022 CsrWifiRouterCtrlTclasAddCfmSend(msg->source, req->clientData, req->interfaceTag , CSR_RESULT_SUCCESS);
1023}
1024
1025void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1026{
1027 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1028 CsrWifiRouterCtrlTclasDelReq* req = (CsrWifiRouterCtrlTclasDelReq*)msg;
1029
1030 if (priv == NULL) {
1031 unifi_error(priv, "CsrWifiRouterCtrlTclasDelReqHandler: invalid smepriv\n");
1032 return;
1033 }
1034
1035 CsrWifiRouterCtrlTclasDelCfmSend(msg->source, req->clientData, req->interfaceTag, CSR_RESULT_SUCCESS);
1036}
1037
1038
1039void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1040{
1041 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1042 CsrWifiRouterCtrlConfigurePowerModeReq* req = (CsrWifiRouterCtrlConfigurePowerModeReq*)msg;
1043 enum unifi_low_power_mode pm;
1044 CsrResult csrResult;
1045
1046 if (priv->smepriv == NULL) {
1047 unifi_error(priv, "CsrWifiRouterCtrlConfigurePowerModeReqHandler: invalid smepriv\n");
1048 return;
1049 }
1050
1051 if (req->mode == CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED) {
1052 pm = UNIFI_LOW_POWER_DISABLED;
1053 } else {
1054 pm = UNIFI_LOW_POWER_ENABLED;
1055 }
1056
1057 unifi_trace(priv, UDBG2,
1058 "CsrWifiRouterCtrlConfigurePowerModeReqHandler (mode=%d, wake=%d)\n",
1059 req->mode, req->wakeHost);
1060 csrResult = unifi_configure_low_power_mode(priv->card, pm,
1061 (req->wakeHost ? UNIFI_PERIODIC_WAKE_HOST_ENABLED : UNIFI_PERIODIC_WAKE_HOST_DISABLED));
1062}
1063
1064
1065void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1066{
1067 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1068 CsrWifiRouterCtrlWifiOnRes* res = (CsrWifiRouterCtrlWifiOnRes*)msg;
1069
1070 if (priv == NULL) {
1071 unifi_error(NULL, "CsrWifiRouterCtrlWifiOnResHandler: Invalid ospriv.\n");
1072 return;
1073 }
1074
1075 unifi_trace(priv, UDBG1,
1076 "CsrWifiRouterCtrlWifiOnResHandler: status %d (patch %u)\n", res->status, res->smeVersions.firmwarePatch);
1077
1078 if (res->smeVersions.firmwarePatch != 0) {
1079 unifi_info(priv, "Firmware patch %d\n", res->smeVersions.firmwarePatch);
1080 }
1081
1082 if (res->numInterfaceAddress > CSR_WIFI_NUM_INTERFACES) {
1083 unifi_error(priv, "WifiOnResHandler bad numInterfaceAddress %d\n", res->numInterfaceAddress);
1084 return;
1085 }
1086
1087 /* UniFi is now initialised, complete the init. */
1088 if (res->status == CSR_RESULT_SUCCESS)
1089 {
1090 int i; /* used as a loop counter */
1091 u32 intmode = CSR_WIFI_INTMODE_DEFAULT;
1092#ifdef CSR_WIFI_SPLIT_PATCH
1093 u8 switching_ap_fw = FALSE;
1094#endif
1095 /* Register the UniFi device with the OS network manager */
1096 unifi_trace(priv, UDBG3, "Card Init Completed Successfully\n");
1097
1098 /* Store the MAC address in the netdev */
1099 for(i=0;i<res->numInterfaceAddress;i++)
1100 {
1101 memcpy(priv->netdev[i]->dev_addr, res->stationMacAddress[i].a, ETH_ALEN);
1102 }
1103
1104 /* Copy version structure into the private versions field */
1105 priv->sme_versions = res->smeVersions;
1106
1107 unifi_trace(priv, UDBG2, "network interfaces count = %d\n",
1108 res->numInterfaceAddress);
1109
1110 /* Register the netdevs for each interface. */
1111 for(i=0;i<res->numInterfaceAddress;i++)
1112 {
1113 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
1114 if(!interfacePriv->netdev_registered)
1115 {
1116 int r;
1117 unifi_trace(priv, UDBG3, "registering net device %d\n", i);
1118 r = uf_register_netdev(priv, i);
1119 if (r)
1120 {
1121 /* unregister the net_device that are registered in the previous iterations */
1122 uf_unregister_netdev(priv);
1123 unifi_error(priv, "Failed to register the network device.\n");
1124 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE);
1125 return;
1126 }
1127 }
1128#ifdef CSR_WIFI_SPLIT_PATCH
1129 else
1130 {
1131 /* If a netdev is already registered, we have received this WifiOnRes
1132 * in response to switching AP/STA firmware in a ModeSetReq.
1133 * Rememeber this in order to send a ModeSetCfm once
1134 */
1135 switching_ap_fw = TRUE;
1136 }
1137#endif
1138 }
1139 priv->totalInterfaceCount = res->numInterfaceAddress;
1140
1141 /* If the MIB has selected f/w scheduled interrupt mode, apply it now
1142 * but let module param override.
1143 */
1144 if (run_bh_once != -1) {
1145 intmode = (u32)run_bh_once;
1146 } else if (res->scheduledInterrupt) {
1147 intmode = CSR_WIFI_INTMODE_RUN_BH_ONCE;
1148 }
1149 unifi_set_interrupt_mode(priv->card, intmode);
1150
1151 priv->init_progress = UNIFI_INIT_COMPLETED;
1152
1153 /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
1154 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_SUCCESS);
1155
1156#ifdef CSR_WIFI_SPLIT_PATCH
1157 if (switching_ap_fw && (priv->pending_mode_set.common.destination != 0xaaaa)) {
1158 unifi_info(priv, "Completed firmware reload with %s patch\n",
1159 CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode) ? "AP" : "STA");
1160
1161 /* Confirm the ModeSetReq that requested the AP/STA patch switch */
1162 CsrWifiRouterCtrlModeSetCfmSend(priv->pending_mode_set.common.source,
1163 priv->pending_mode_set.clientData,
1164 priv->pending_mode_set.interfaceTag,
1165 priv->pending_mode_set.mode,
1166 CSR_RESULT_SUCCESS);
1167 priv->pending_mode_set.common.destination = 0xaaaa;
1168 }
1169#endif
1170 unifi_info(priv, "UniFi ready\n");
1171
1172#ifdef ANDROID_BUILD
1173 /* Release the wakelock */
1174 unifi_trace(priv, UDBG1, "ready: release wake lock\n");
1175 wake_unlock(&unifi_sdio_wake_lock);
1176#endif
1177 /* Firmware initialisation is complete, so let the SDIO bus
1178 * clock be raised when convienent to the core.
1179 */
1180 unifi_request_max_sdio_clock(priv->card);
1181
1182#ifdef CSR_SUPPORT_WEXT
1183 /* Notify the Android wpa_supplicant that we are ready */
1184 wext_send_started_event(priv);
1185
1186 queue_work(priv->unifi_workqueue, &priv->sme_config_task);
1187#endif
1188
1189 } else {
1190 /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
1191 CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE);
1192 }
1193}
1194
1195
1196void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1197{
1198}
1199
1200
1201void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1202{
1203}
1204
1205
1206void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1207{
1208 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1209 CsrWifiRouterMaPacketSubscribeReq* req = (CsrWifiRouterMaPacketSubscribeReq*)msg;
1210 u8 i;
1211 CsrResult result;
1212
1213 if (priv == NULL) {
1214 unifi_error(priv, "CsrWifiRouterMaPacketSubscribeReqHandler: invalid priv\n");
1215 return;
1216 }
1217
1218 /* Look for an unused filter */
1219
1220 result = CSR_WIFI_RESULT_NO_ROOM;
1221 for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
1222
1223 if (!priv->sme_unidata_ind_filters[i].in_use) {
1224
1225 priv->sme_unidata_ind_filters[i].in_use = 1;
1226 priv->sme_unidata_ind_filters[i].appHandle = msg->source;
1227 priv->sme_unidata_ind_filters[i].encapsulation = req->encapsulation;
1228 priv->sme_unidata_ind_filters[i].protocol = req->protocol;
1229
1230 priv->sme_unidata_ind_filters[i].oui[2] = (u8) (req->oui & 0xFF);
1231 priv->sme_unidata_ind_filters[i].oui[1] = (u8) ((req->oui >> 8) & 0xFF);
1232 priv->sme_unidata_ind_filters[i].oui[0] = (u8) ((req->oui >> 16) & 0xFF);
1233
1234 result = CSR_RESULT_SUCCESS;
1235 break;
1236 }
1237 }
1238
1239 unifi_trace(priv, UDBG1,
1240 "subscribe_req: encap=%d, handle=%d, result=%d\n",
1241 req->encapsulation, i, result);
1242 CsrWifiRouterMaPacketSubscribeCfmSend(msg->source, req->interfaceTag, i, result, 0);
1243}
1244
1245
1246void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1247{
1248 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1249 CsrWifiRouterMaPacketUnsubscribeReq* req = (CsrWifiRouterMaPacketUnsubscribeReq*)msg;
1250 CsrResult result;
1251
1252 if (priv == NULL) {
1253 unifi_error(priv, "CsrWifiRouterMaPacketUnsubscribeReqHandler: invalid priv\n");
1254 return;
1255 }
1256
1257 result = CSR_WIFI_RESULT_NOT_FOUND;
1258
1259 if (req->subscriptionHandle < MAX_MA_UNIDATA_IND_FILTERS) {
1260 if (priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use) {
1261 priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use = 0;
1262 result = CSR_RESULT_SUCCESS;
1263 } else {
1264 result = CSR_WIFI_RESULT_NOT_FOUND;
1265 }
1266 }
1267
1268 unifi_trace(priv, UDBG1,
1269 "unsubscribe_req: handle=%d, result=%d\n",
1270 req->subscriptionHandle, result);
1271 CsrWifiRouterMaPacketUnsubscribeCfmSend(msg->source, req->interfaceTag, result);
1272}
1273
1274
1275void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1276{
1277 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1278 CsrWifiRouterCtrlCapabilitiesReq* req = (CsrWifiRouterCtrlCapabilitiesReq*)msg;
1279
1280 if (priv == NULL) {
1281 unifi_error(priv, "CsrWifiRouterCtrlCapabilitiesReqHandler: invalid priv\n");
1282 return;
1283 }
1284
1285 CsrWifiRouterCtrlCapabilitiesCfmSend(msg->source, req->clientData,
1286 UNIFI_SOFT_COMMAND_Q_LENGTH - 1,
1287 UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1);
1288}
1289
1290
1291void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1292{
1293 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1294 CsrWifiRouterCtrlSuspendRes* res = (CsrWifiRouterCtrlSuspendRes*)msg;
1295
1296 if (priv == NULL) {
1297 unifi_error(priv, "CsrWifiRouterCtrlSuspendResHandler: invalid priv\n");
1298 return;
1299 }
1300
1301 sme_complete_request(priv, res->status);
1302}
1303
1304
1305void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1306{
1307 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1308 CsrWifiRouterCtrlResumeRes* res = (CsrWifiRouterCtrlResumeRes*)msg;
1309
1310 if (priv == NULL) {
1311 unifi_error(priv, "CsrWifiRouterCtrlResumeResHandler: invalid priv\n");
1312 return;
1313 }
1314
1315 sme_complete_request(priv, res->status);
1316}
1317
1318
1319void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1320{
1321 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1322 CsrWifiRouterCtrlTrafficConfigReq* req = (CsrWifiRouterCtrlTrafficConfigReq*)msg;
1323 CsrResult csrResult;
1324
1325 if (priv == NULL) {
1326 unifi_error(priv, "CsrWifiRouterCtrlTrafficConfigReqHandler: invalid smepriv\n");
1327 return;
1328 }
1329 if (req->trafficConfigType == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER)
1330 {
1331 req->config.packetFilter |= CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM;
1332 }
1333 csrResult = unifi_ta_configure(priv->card, req->trafficConfigType, (const CsrWifiRouterCtrlTrafficConfig *)&req->config);
1334}
1335
1336void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1337{
1338 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1339 CsrWifiRouterCtrlTrafficClassificationReq* req = (CsrWifiRouterCtrlTrafficClassificationReq*)msg;
1340
1341 if (priv == NULL) {
1342 unifi_error(priv, "CsrWifiRouterCtrlTrafficClassificationReqHandler: invalid smepriv\n");
1343 return;
1344 }
1345
1346 unifi_ta_classification(priv->card, req->trafficType, req->period);
1347}
1348
1349static int
1350_sys_packet_req(unifi_priv_t *priv, const CSR_SIGNAL *signal,
1351 u8 subscriptionHandle,
1352 u16 frameLength, u8 *frame,
1353 int proto)
1354{
1355 int r;
1356 const sme_ma_unidata_ind_filter_t *subs;
1357 bulk_data_param_t bulkdata;
1358 CSR_MA_PACKET_REQUEST req = signal->u.MaPacketRequest;
1359 struct sk_buff *skb, *newSkb = NULL;
1360 CsrWifiMacAddress peerMacAddress;
1361 CsrResult csrResult;
1362 u16 interfaceTag = req.VirtualInterfaceIdentifier & 0xff;
1363 u8 eapolStore = FALSE;
1364 s8 protection = 0;
1365 netInterface_priv_t *interfacePriv;
1366 unsigned long flags;
1367
1368 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1369 unifi_error(priv, "_sys_packet_req: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1370 return -EINVAL;
1371 }
1372 interfacePriv = priv->interfacePriv[interfaceTag];
1373 if (!priv->sme_unidata_ind_filters[subscriptionHandle].in_use) {
1374 unifi_error(priv, "_sys_packet_req: unknown subscription.\n");
1375 return -EINVAL;
1376 }
1377
1378 subs = &priv->sme_unidata_ind_filters[subscriptionHandle];
1379 unifi_trace(priv, UDBG1,
1380 "_sys_packet_req: handle=%d, subs=%p, encap=%d\n",
1381 subscriptionHandle, subs, subs->encapsulation);
1382
1383 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], frameLength);
1384 if (csrResult != CSR_RESULT_SUCCESS) {
1385 unifi_error(priv, "_sys_packet_req: failed to allocate bulkdata.\n");
1386 return (int)CsrHipResultToStatus(csrResult);
1387 }
1388
1389 /* get the peer Mac address */
1390 memcpy(&peerMacAddress, frame, ETH_ALEN);
1391
1392 /* Determine if we need to add encapsulation header */
1393 if (subs->encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) {
1394 memcpy((void*)bulkdata.d[0].os_data_ptr, frame, frameLength);
1395
1396 /* The translation is performed on the skb */
1397 skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr;
1398
1399 unifi_trace(priv, UDBG1,
1400 "_sys_packet_req: skb_add_llc_snap -->\n");
1401 r = skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto);
1402 unifi_trace(priv, UDBG1,
1403 "_sys_packet_req: skb_add_llc_snap <--\n");
1404 if (r) {
1405 unifi_error(priv,
1406 "_sys_packet_req: failed to translate eth frame.\n");
1407 unifi_net_data_free(priv, &bulkdata.d[0]);
1408 return r;
1409 }
1410
1411 bulkdata.d[0].data_length = skb->len;
1412 } else {
1413 /* Crop the MAC addresses from the packet */
1414 memcpy((void*)bulkdata.d[0].os_data_ptr, frame + 2*ETH_ALEN, frameLength - 2*ETH_ALEN);
1415 bulkdata.d[0].data_length = frameLength - 2*ETH_ALEN;
1416 skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr;
1417 skb->len = bulkdata.d[0].data_length;
1418
1419 }
1420
1421 bulkdata.d[1].os_data_ptr = NULL;
1422 bulkdata.d[1].os_net_buf_ptr = NULL;
1423 bulkdata.d[1].data_length = 0;
1424
1425 /* check for m4 detection */
1426 if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) {
1427 eapolStore = TRUE;
1428 }
1429
1430#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1431 if (proto == ETH_P_WAI)
1432 {
1433 protection = 0; /*WAI packets always sent unencrypted*/
1434 }
1435 else
1436 {
1437#endif
1438
1439#ifdef CSR_SUPPORT_SME
1440 if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, peerMacAddress.a)) < 0) {
1441 unifi_error(priv, "unicast address, but destination not in station record database\n");
1442 unifi_net_data_free(priv, &bulkdata.d[0]);
1443 return -1;
1444 }
1445#else
1446 protection = 0;
1447#endif
1448
1449#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1450 }
1451#endif
1452
1453 /* add Mac header */
1454 if (prepare_and_add_macheader(priv, skb, newSkb, req.Priority, &bulkdata, interfaceTag, frame, frame + ETH_ALEN, protection)) {
1455 unifi_error(priv, "failed to create MAC header\n");
1456 unifi_net_data_free(priv, &bulkdata.d[0]);
1457 return -1;
1458 }
1459
1460 if (eapolStore) {
1461 spin_lock_irqsave(&priv->m4_lock, flags);
1462 /* Store the EAPOL M4 packet for later */
1463 interfacePriv->m4_signal = *signal;
1464 interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
1465 interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length;
1466 interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
1467 interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
1468 spin_unlock_irqrestore(&priv->m4_lock, flags);
1469 /* Send a signal to SME */
1470 unifi_trace(priv, UDBG1, "_sys_packet_req: Sending CsrWifiRouterCtrlM4ReadyToSendInd\n");
1471 CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
1472 return 0;
1473 }
1474
1475 /* Send the signal to UniFi */
1476 /* Set the B31 to 1 for local routing*/
1477 r= uf_process_ma_packet_req(priv, peerMacAddress.a, (req.HostTag | 0x80000000), interfaceTag, 0,
1478 (CSR_RATE)0, req.Priority, signal->SignalPrimitiveHeader.SenderProcessId, &bulkdata);
1479 if (r) {
1480 unifi_error(priv,
1481 "_sys_packet_req: failed to send signal.\n");
1482 unifi_net_data_free(priv, &bulkdata.d[0]);
1483 return r;
1484 }
1485 /* The final CsrWifiRouterMaPacketCfmSend() will called when the actual MA-PACKET.cfm is received from the chip */
1486
1487 return 0;
1488}
1489
1490void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1491{
1492 int r;
1493 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1494 CsrWifiRouterMaPacketReq* mareq = (CsrWifiRouterMaPacketReq*)msg;
1495 llc_snap_hdr_t *snap;
1496 u16 snap_protocol;
1497 CSR_SIGNAL signal;
1498 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
1499 CsrWifiRouterCtrlPortAction controlPortaction;
1500 u8 *daddr, *saddr;
1501 u16 interfaceTag = mareq->interfaceTag & 0x00ff;
1502 int queue;
1503 netInterface_priv_t *interfacePriv;
1504
1505 if (!mareq->frame || !priv || !priv->smepriv)
1506 {
1507 unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: invalid frame/priv/priv->smepriv\n");
1508 return;
1509 }
1510
1511 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1512 unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
1513 return;
1514 }
1515
1516 interfacePriv = priv->interfacePriv[interfaceTag];
1517 /* get a pointer to dest & source Mac address */
1518 daddr = mareq->frame;
1519 saddr = (mareq->frame + ETH_ALEN);
1520 /* point to the proper position of frame, since frame has MAC header */
1521 snap = (llc_snap_hdr_t *) (mareq->frame + 2 * ETH_ALEN);
1522 snap_protocol = ntohs(snap->protocol);
1523 if((snap_protocol == ETH_P_PAE)
1524#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
1525 || (snap_protocol == ETH_P_WAI)
1526#endif
1527 )
1528 {
1529 queue = UF_UNCONTROLLED_PORT_Q;
1530 }
1531 else
1532 {
1533 queue = UF_CONTROLLED_PORT_Q;
1534 }
1535
1536 /* Controlled port restrictions apply to the packets */
1537 controlPortaction = uf_sme_port_state(priv, daddr, queue, interfaceTag);
1538 if (controlPortaction != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)
1539 {
1540 unifi_warning(priv, "CsrWifiRouterMaPacketReqHandler: (%s)controlled port is closed.\n", (queue == UF_CONTROLLED_PORT_Q)?"":"un");
1541 if(mareq->cfmRequested)
1542 {
1543 CsrWifiRouterMaPacketCfmSend(msg->source,
1544 interfaceTag,
1545 CSR_RESULT_FAILURE,
1546 mareq->hostTag, 0);
1547 }
1548 return;
1549 }
1550
1551 signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
1552 /* Store the appHandle in the LSB of the SenderId. */
1553 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->sme_cli->sender_id & 0xff00) | (unsigned int)msg->source),
1554 (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
1555 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
1556
1557 /* Fill in the MA-PACKET.req signal */
1558 memcpy(req->Ra.x, daddr, ETH_ALEN);
1559 req->Priority = mareq->priority;
1560 req->TransmitRate = 0; /* Let firmware select the rate*/
1561 req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag);
1562 req->HostTag = mareq->hostTag;
1563
1564 if(mareq->cfmRequested)
1565 req->TransmissionControl = 0;
1566 else
1567 req->TransmissionControl = CSR_NO_CONFIRM_REQUIRED;
1568
1569 r = _sys_packet_req(priv, &signal, mareq->subscriptionHandle,
1570 mareq->frameLength, mareq->frame, snap_protocol);
1571
1572 if (r && mareq->cfmRequested)
1573 {
1574 CsrWifiRouterMaPacketCfmSend(msg->source, interfaceTag,
1575 CSR_RESULT_FAILURE,
1576 mareq->hostTag, 0);
1577 }
1578 return;
1579}
1580
1581void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1582{
1583}
1584
1585void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1586{
1587 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1588 CsrWifiRouterCtrlM4TransmitReq* req = (CsrWifiRouterCtrlM4TransmitReq*)msg;
1589 int r;
1590 bulk_data_param_t bulkdata;
1591 netInterface_priv_t *interfacePriv;
1592 CSR_SIGNAL m4_signal;
1593 unsigned long flags;
1594
1595 if (priv == NULL) {
1596 unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid smepriv\n");
1597 return;
1598 }
1599 if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1600 unifi_error(priv, "M4TransmitReqHandler: interfaceTag >= CSR_WIFI_NUM_INTERFACES\n");
1601 return;
1602 }
1603
1604 interfacePriv = priv->interfacePriv[req->interfaceTag];
1605 spin_lock_irqsave(&priv->m4_lock, flags);
1606 if (interfacePriv->m4_bulk_data.data_length == 0) {
1607 spin_unlock_irqrestore(&priv->m4_lock, flags);
1608 unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid buffer\n");
1609 return;
1610 }
1611
1612 memcpy(&bulkdata.d[0], &interfacePriv->m4_bulk_data, sizeof(bulk_data_desc_t));
1613
1614 interfacePriv->m4_bulk_data.net_buf_length = 0;
1615 interfacePriv->m4_bulk_data.data_length = 0;
1616 interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
1617 m4_signal = interfacePriv->m4_signal;
1618 spin_unlock_irqrestore(&priv->m4_lock, flags);
1619
1620 bulkdata.d[1].os_data_ptr = NULL;
1621 bulkdata.d[1].data_length = 0;
1622
1623 interfacePriv->m4_sent = TRUE;
1624 m4_signal.u.MaPacketRequest.HostTag |= 0x80000000;
1625 /* Store the hostTag for later varification */
1626 interfacePriv->m4_hostTag = m4_signal.u.MaPacketRequest.HostTag;
1627 r = ul_send_signal_unpacked(priv, &m4_signal, &bulkdata);
1628 unifi_trace(priv, UDBG1,
1629 "CsrWifiRouterCtrlM4TransmitReqHandler: sent\n");
1630 if (r) {
1631 unifi_error(priv,
1632 "CsrWifiRouterCtrlM4TransmitReqHandler: failed to send signal.\n");
1633 unifi_net_data_free(priv, &bulkdata.d[0]);
1634 }
1635}
1636
1637/* reset the station records when the mode is set as CSR_WIFI_ROUTER_CTRL_MODE_NONE */
1638static void CsrWifiRouterCtrlResetStationRecordList(unifi_priv_t *priv, u16 interfaceTag)
1639{
1640 u8 i, j;
1641 CsrWifiRouterCtrlStaInfo_t *staInfo=NULL;
1642 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1643 unsigned long lock_flags;
1644
1645 /* create a list for sending confirms of un-delivered packets */
1646 struct list_head send_cfm_list;
1647
1648 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1649 unifi_error(priv, "CsrWifiRouterCtrlResetStationRecordList: bad interfaceTag\n");
1650 return;
1651 }
1652
1653 INIT_LIST_HEAD(&send_cfm_list);
1654
1655 /* Reset the station record to NULL if mode is NONE */
1656 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
1657 if ((staInfo=interfacePriv->staInfo[i]) != NULL) {
1658 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1659 &send_cfm_list,
1660 &(staInfo->mgtFrames));
1661 uf_flush_list(priv, &(staInfo->mgtFrames));
1662 for(j=0;j<MAX_ACCESS_CATOGORY;j++){
1663 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1664 &send_cfm_list,
1665 &(staInfo->dataPdu[j]));
1666 uf_flush_list(priv, &(staInfo->dataPdu[j]));
1667 }
1668
1669 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
1670 /* Removing station record information from port config array */
1671 memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t));
1672 staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
1673 staInfo->peerControlledPort->in_use = FALSE;
1674 interfacePriv->controlled_data_port.entries_in_use--;
1675
1676 memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t));
1677 staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
1678 staInfo->peerUnControlledPort->in_use = FALSE;
1679 interfacePriv->uncontrolled_data_port.entries_in_use--;
1680
1681 kfree(interfacePriv->staInfo[i]);
1682 interfacePriv->staInfo[i] = NULL;
1683 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
1684 }
1685 }
1686 /* after the critical region process the list of frames that requested cfm
1687 * and send cfm to requestor one by one
1688 */
1689 send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
1690
1691#ifdef CSR_SUPPORT_SME
1692 /* Interface Independent, no of packet queued, incase of mode is None or AP set to 0 */
1693 switch(interfacePriv->interfaceMode)
1694 {
1695 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1696 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1697 case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
1698 if (priv->noOfPktQueuedInDriver) {
1699 unifi_warning(priv, "After reset the noOfPktQueuedInDriver = %x\n", priv->noOfPktQueuedInDriver);
1700 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
1701 priv->noOfPktQueuedInDriver = 0;
1702 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
1703 }
1704 break;
1705 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1706 break;
1707 default:
1708 unifi_error(priv, "interfacemode is not correct in CsrWifiRouterCtrlResetStationRecordList: debug\n");
1709 }
1710#endif
1711
1712 if (((interfacePriv->controlled_data_port.entries_in_use != 0) || (interfacePriv->uncontrolled_data_port.entries_in_use != 0))
1713 && (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE)) {
1714 /* Print in case if the value of entries goes to -ve/+ve (apart from 0)
1715 * we expect the entries should be zero here if mode is set as NONE
1716 */
1717 unifi_trace(priv, UDBG3, "In %s controlled port entries = %d, uncontrolled port entries = %d\n",
1718 __FUNCTION__, interfacePriv->controlled_data_port.entries_in_use,
1719 interfacePriv->uncontrolled_data_port.entries_in_use);
1720 }
1721}
1722
1723void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag)
1724{
1725 netInterface_priv_t *interfacePriv;
1726
1727 /* create a list for sending confirms of un-delivered packets */
1728 struct list_head send_cfm_list;
1729
1730 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1731 unifi_error(priv, "CsrWifiRouterCtrlInterfaceReset: bad interfaceTag\n");
1732 return;
1733 }
1734
1735 interfacePriv = priv->interfacePriv[interfaceTag];
1736
1737 INIT_LIST_HEAD(&send_cfm_list);
1738
1739 /* Enable all queues by default */
1740 interfacePriv->queueEnabled[0] = 1;
1741 interfacePriv->queueEnabled[1] = 1;
1742 interfacePriv->queueEnabled[2] = 1;
1743 interfacePriv->queueEnabled[3] = 1;
1744
1745 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1746 &send_cfm_list,
1747 &(interfacePriv->genericMgtFrames));
1748 uf_flush_list(priv, &(interfacePriv->genericMgtFrames));
1749
1750 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1751 &send_cfm_list,
1752 &(interfacePriv->genericMulticastOrBroadCastMgtFrames));
1753 uf_flush_list(priv, &(interfacePriv->genericMulticastOrBroadCastMgtFrames));
1754
1755 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1756 &send_cfm_list,
1757 &(interfacePriv->genericMulticastOrBroadCastFrames));
1758
1759 uf_flush_list(priv, &(interfacePriv->genericMulticastOrBroadCastFrames));
1760
1761 /* process the list of frames that requested cfm
1762 and send cfm to requestor one by one */
1763 send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
1764
1765 /* Reset the station record to NULL if mode is tried to set as NONE */
1766 switch(interfacePriv->interfaceMode)
1767 {
1768 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1769 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1770 case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
1771 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1772 /* station records not available in these modes */
1773 break;
1774 default:
1775 CsrWifiRouterCtrlResetStationRecordList(priv, interfaceTag);
1776 }
1777
1778 interfacePriv->num_stations_joined = 0;
1779 interfacePriv->sta_activity_check_enabled = FALSE;
1780}
1781
1782
1783void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1784{
1785 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
1786 CsrWifiRouterCtrlModeSetReq* req = (CsrWifiRouterCtrlModeSetReq*)msg;
1787
1788 if (priv == NULL)
1789 {
1790 unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid smepriv\n");
1791 return;
1792 }
1793
1794 if (req->interfaceTag < CSR_WIFI_NUM_INTERFACES)
1795 {
1796 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
1797#ifdef CSR_WIFI_SPLIT_PATCH
1798 u8 old_mode = interfacePriv->interfaceMode;
1799#endif
1800 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlModeSetReqHandler: interfacePriv->interfaceMode = %d\n",
1801 interfacePriv->interfaceMode);
1802
1803 interfacePriv->interfaceMode = req->mode;
1804
1805#ifdef CSR_WIFI_SPLIT_PATCH
1806 /* Detect a change in mode that requires a switch to/from the AP firmware patch.
1807 * This should only happen when transitioning in/out of AP modes.
1808 */
1809 if (CSR_WIFI_HIP_IS_AP_FW(req->mode) != CSR_WIFI_HIP_IS_AP_FW(old_mode))
1810 {
1811 CsrWifiRouterCtrlVersions versions;
1812 int r;
1813
1814#ifdef ANDROID_BUILD
1815 /* Take the wakelock while switching patch */
1816 unifi_trace(priv, UDBG1, "patch switch: take wake lock\n");
1817 wake_lock(&unifi_sdio_wake_lock);
1818#endif
1819 unifi_info(priv, "Resetting UniFi with %s patch\n", CSR_WIFI_HIP_IS_AP_FW(req->mode) ? "AP" : "STA");
1820
1821 r = uf_request_firmware_files(priv, UNIFI_FW_STA);
1822 if (r) {
1823 unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: Failed to get f/w\n");
1824 CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
1825 req->mode, CSR_RESULT_FAILURE);
1826 return;
1827 }
1828
1829 /* Block the I/O thread */
1830 priv->bh_thread.block_thread = 1;
1831
1832 /* Reset and download the new patch */
1833 r = uf_init_hw(priv);
1834 if (r) {
1835 unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
1836 CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
1837 req->mode, CSR_RESULT_FAILURE);
1838 return;
1839 }
1840
1841 /* Re-enable the I/O thread */
1842 priv->bh_thread.block_thread = 0;
1843
1844 /* Get the version information from the core */
1845 unifi_card_info(priv->card, &priv->card_info);
1846
1847 /* Copy to the unifiio_card_info structure. */
1848 versions.chipId = priv->card_info.chip_id;
1849 versions.chipVersion = priv->card_info.chip_version;
1850 versions.firmwareBuild = priv->card_info.fw_build;
1851 versions.firmwareHip = priv->card_info.fw_hip_version;
1852 versions.routerBuild = (char*)CSR_WIFI_VERSION;
1853 versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION;
1854
1855 /* Now that new firmware is running, send a WifiOnInd to the NME. This will
1856 * cause it to retransfer the MIB.
1857 */
1858 CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions);
1859
1860 /* Store the request so we know where to send the ModeSetCfm */
1861 priv->pending_mode_set = *req;
1862 }
1863 else
1864#endif
1865 {
1866 /* No patch switch, confirm straightaway */
1867 CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
1868 req->mode, CSR_RESULT_SUCCESS);
1869 }
1870
1871 interfacePriv->bssid = req->bssid;
1872 /* For modes other than AP/P2PGO, set below member FALSE */
1873 interfacePriv->intraBssEnabled = FALSE;
1874 /* Initialise the variable bcTimSet with a value
1875 * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
1876 */
1877 interfacePriv->bcTimSet = 0xFF;
1878 interfacePriv->bcTimSetReqPendingFlag = FALSE;
1879 /* Initialise the variable bcTimSetReqQueued with a value
1880 * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
1881 */
1882 interfacePriv->bcTimSetReqQueued =0xFF;
1883 CsrWifiRouterCtrlInterfaceReset(priv, req->interfaceTag);
1884
1885 if(req->mode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1886 req->mode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1887 interfacePriv->protect = req->protection;
1888 interfacePriv->dtimActive=FALSE;
1889 interfacePriv->multicastPduHostTag = 0xffffffff;
1890 /* For AP/P2PGO mode SME sending intraBssDistEnabled
1891 * i.e. for AP: intraBssDistEnabled = TRUE, for P2PGO
1892 * intraBssDistEnabled = TRUE/FALSE on requirement
1893 */
1894 interfacePriv->intraBssEnabled = req->intraBssDistEnabled;
1895 unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlModeSetReqHandler: IntraBssDisEnabled = %d\n",
1896 req->intraBssDistEnabled);
1897 } else if (req->mode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
1898 netif_carrier_off(priv->netdev[req->interfaceTag]);
1899 interfacePriv->connected = UnifiConnectedUnknown;
1900 }
1901 }
1902 else {
1903 unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid interfaceTag :%d\n", req->interfaceTag);
1904 }
1905}
1906
1907void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
1908{
1909}
1910
1911/* delete the station record from the station record data base */
1912static int peer_delete_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerDelReq *req)
1913{
1914 u8 j;
1915 CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
1916 unifi_port_config_t *controlledPort;
1917 unifi_port_config_t *unControlledPort;
1918 netInterface_priv_t *interfacePriv;
1919
1920 u8 ba_session_idx = 0;
1921 ba_session_rx_struct *ba_session_rx = NULL;
1922 ba_session_tx_struct *ba_session_tx = NULL;
1923
1924 /* create a list for sending confirms of un-delivered packets */
1925 struct list_head send_cfm_list;
1926
1927 unsigned long lock_flags;
1928
1929 if ((req->peerRecordHandle >= UNIFI_MAX_CONNECTIONS) || (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
1930 unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", req->peerRecordHandle, req->interfaceTag);
1931 return CSR_RESULT_FAILURE;
1932 }
1933
1934 INIT_LIST_HEAD(&send_cfm_list);
1935
1936 interfacePriv = priv->interfacePriv[req->interfaceTag];
1937 /* remove the station record & make it NULL */
1938 if ((staInfo=interfacePriv->staInfo[req->peerRecordHandle])!=NULL) {
1939
1940 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1941 &send_cfm_list,
1942 &(staInfo->mgtFrames));
1943
1944 uf_flush_list(priv, &(staInfo->mgtFrames));
1945 for(j=0;j<MAX_ACCESS_CATOGORY;j++){
1946 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1947 &send_cfm_list,
1948 &(staInfo->dataPdu[j]));
1949 uf_flush_list(priv, &(staInfo->dataPdu[j]));
1950 }
1951
1952 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
1953 /* clear the port configure array info, for the corresponding peer entry */
1954 controlledPort = &interfacePriv->controlled_data_port;
1955 unControlledPort = &interfacePriv->uncontrolled_data_port;
1956
1957 unifi_trace(priv, UDBG1, "peer_delete_record: Peer found handle = %d, port in use: cont(%d), unCont(%d)\n",
1958 req->peerRecordHandle, controlledPort->entries_in_use, unControlledPort->entries_in_use);
1959
1960 memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t));
1961 staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
1962 staInfo->peerControlledPort->in_use = FALSE;
1963 if (controlledPort->entries_in_use) {
1964 controlledPort->entries_in_use--;
1965 } else {
1966 unifi_warning(priv, "number of controlled port entries is zero, trying to decrement: debug\n");
1967 }
1968
1969 memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t));
1970 staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
1971 staInfo->peerUnControlledPort->in_use = FALSE;
1972 if (unControlledPort->entries_in_use) {
1973 unControlledPort->entries_in_use--;
1974 } else {
1975 unifi_warning(priv, "number of uncontrolled port entries is zero, trying to decrement: debug\n");
1976 }
1977
1978 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
1979 /* update the TIM with zero */
1980 if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS &&
1981 staInfo->timSet == CSR_WIFI_TIM_SET) {
1982 unifi_trace(priv, UDBG3, "peer is deleted so TIM updated to 0, in firmware\n");
1983 update_tim(priv, staInfo->aid, 0, req->interfaceTag, req->peerRecordHandle);
1984 }
1985
1986
1987 /* Stop BA session if it is active, for this peer address all BA sessions
1988 (per tID per role) are closed */
1989
1990 down(&priv->ba_mutex);
1991 for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
1992 ba_session_rx = priv->interfacePriv[req->interfaceTag]->ba_session_rx[ba_session_idx];
1993 if(ba_session_rx) {
1994 if(!memcmp(ba_session_rx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){
1995 blockack_session_stop(priv,
1996 req->interfaceTag,
1997 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT,
1998 ba_session_rx->tID,
1999 ba_session_rx->macAddress);
2000 }
2001 }
2002 }
2003
2004 for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
2005 ba_session_tx = priv->interfacePriv[req->interfaceTag]->ba_session_tx[ba_session_idx];
2006 if(ba_session_tx) {
2007 if(!memcmp(ba_session_tx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){
2008 blockack_session_stop(priv,
2009 req->interfaceTag,
2010 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR,
2011 ba_session_tx->tID,
2012 ba_session_tx->macAddress);
2013 }
2014 }
2015 }
2016
2017 up(&priv->ba_mutex);
2018
2019#ifdef CSR_SUPPORT_SME
2020 unifi_trace(priv, UDBG1, "Canceling work queue for STA with AID: %d\n", staInfo->aid);
2021 cancel_work_sync(&staInfo->send_disconnected_ind_task);
2022#endif
2023
2024 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2025#ifdef CSR_SUPPORT_SME
2026 interfacePriv->num_stations_joined--;
2027
2028 staInfo->nullDataHostTag = INVALID_HOST_TAG;
2029
2030 if ((interfacePriv->sta_activity_check_enabled) &&
2031 (interfacePriv->num_stations_joined < STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD))
2032 {
2033 unifi_trace(priv, UDBG1, "STOPPING the Inactivity Timer (num of stations = %d)\n", interfacePriv->num_stations_joined);
2034 interfacePriv->sta_activity_check_enabled = FALSE;
2035 del_timer_sync(&interfacePriv->sta_activity_check_timer);
2036 }
2037#endif
2038
2039 /* Free the station record for corresponding peer */
2040 kfree(interfacePriv->staInfo[req->peerRecordHandle]);
2041 interfacePriv->staInfo[req->peerRecordHandle] = NULL;
2042 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2043
2044 /* after the critical region process the list of frames that requested cfm
2045 and send cfm to requestor one by one */
2046 send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
2047
2048
2049 }
2050 else
2051 {
2052 unifi_trace(priv, UDBG3, " peer not found: Delete request Peer handle[%d]\n", req->peerRecordHandle);
2053 }
2054
2055 return CSR_RESULT_SUCCESS;
2056}
2057
2058void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2059{
2060 CsrWifiRouterCtrlPeerDelReq* req = (CsrWifiRouterCtrlPeerDelReq*)msg;
2061 CsrResult status = CSR_RESULT_SUCCESS;
2062 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2063 netInterface_priv_t *interfacePriv;
2064
2065 unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler\n");
2066 if (priv == NULL)
2067 {
2068 unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n");
2069 return;
2070 }
2071
2072 if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)
2073 {
2074 unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: bad interfaceTag\n");
2075 return;
2076 }
2077
2078 interfacePriv = priv->interfacePriv[req->interfaceTag];
2079
2080 switch(interfacePriv->interfaceMode)
2081 {
2082 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2083 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
2084 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2085 /* remove the station from station record data base */
2086 status = peer_delete_record(priv, req);
2087 break;
2088 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
2089 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
2090 default:
2091 /* No station record to maintain in these modes */
2092 break;
2093 }
2094
2095 CsrWifiRouterCtrlPeerDelCfmSend(msg->source, req->clientData, req->interfaceTag, status);
2096 unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerDelReqHandler \n");
2097}
2098
2099/* Add the new station to the station record data base */
2100static int peer_add_new_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerAddReq *req, u32 *handle)
2101{
2102 u8 i, powerModeTemp = 0;
2103 u8 freeSlotFound = FALSE;
2104 CsrWifiRouterCtrlStaInfo_t *newRecord = NULL;
2105 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
2106 u32 currentTime, currentTimeHi;
2107 unsigned long lock_flags;
2108
2109 if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2110 unifi_error(priv, "peer_add_new_record: bad interfaceTag\n");
2111 return CSR_RESULT_FAILURE;
2112 }
2113
2114 currentTime = CsrTimeGet(&currentTimeHi);
2115
2116 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
2117 if(interfacePriv->staInfo[i] == NULL) {
2118 /* Slot is empty, so can be used for station record */
2119 freeSlotFound = TRUE;
2120 *handle = i;
2121
2122 /* Allocate for the new station record , to avoid race condition would happen between ADD_PEER &
2123 * DEL_PEER the allocation made atomic memory rather than kernel memory
2124 */
2125 newRecord = kmalloc(sizeof(CsrWifiRouterCtrlStaInfo_t), GFP_ATOMIC);
2126 if (!newRecord) {
2127 unifi_error(priv, "failed to allocate the %d bytes of mem for station record\n",
2128 sizeof(CsrWifiRouterCtrlStaInfo_t));
2129 return CSR_RESULT_FAILURE;
2130 }
2131
2132 unifi_trace(priv, UDBG1, "peer_add_new_record: handle = %d AID = %d addr = %x:%x:%x:%x:%x:%x LI=%u\n",
2133 *handle, req->associationId, req->peerMacAddress.a[0], req->peerMacAddress.a[1], req->peerMacAddress.a[2],
2134 req->peerMacAddress.a[3], req->peerMacAddress.a[4], req->peerMacAddress.a[5],
2135 req->staInfo.listenIntervalInTus);
2136
2137 /* disable the preemption until station record updated */
2138 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2139
2140 interfacePriv->staInfo[i] = newRecord;
2141 /* Initialize the record*/
2142 memset(newRecord, 0, sizeof(CsrWifiRouterCtrlStaInfo_t));
2143 /* update the station record */
2144 memcpy(newRecord->peerMacAddress.a, req->peerMacAddress.a, ETH_ALEN);
2145 newRecord->wmmOrQosEnabled = req->staInfo.wmmOrQosEnabled;
2146
2147 /* maxSpLength is bit map in qosInfo field, so converting accordingly */
2148 newRecord->maxSpLength = req->staInfo.maxSpLength * 2;
2149
2150 /*Max SP 0 mean any number of packets. since we buffer only 512
2151 packets we are hard coding this to zero for the moment */
2152
2153 if(newRecord->maxSpLength == 0)
2154 newRecord->maxSpLength=512;
2155
2156 newRecord->assignedHandle = i;
2157
2158 /* copy power save mode of all access catagory (Trigger/Delivery/both enabled/disabled) */
2159 powerModeTemp = (u8) ((req->staInfo.powersaveMode >> 4) & 0xff);
2160
2161 if(!(req->staInfo.powersaveMode & 0x0001))
2162 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
2163 else
2164 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= powerModeTemp & 0x03;
2165
2166 if(!(req->staInfo.powersaveMode & 0x0002))
2167 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
2168 else
2169 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= ((powerModeTemp & 0x0C)>> 2);
2170
2171 if(!(req->staInfo.powersaveMode & 0x0004))
2172 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
2173 else
2174 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= ((powerModeTemp & 0x30)>> 4);
2175
2176 if(!(req->staInfo.powersaveMode & 0x0008))
2177 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
2178 else
2179 newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= ((powerModeTemp & 0xC0)>> 6);
2180
2181 {
2182 u8 k;
2183 for(k=0; k< MAX_ACCESS_CATOGORY ;k++)
2184 unifi_trace(priv, UDBG2, "peer_add_new_record: WMM : %d ,AC %d, powersaveMode %x \n",
2185 req->staInfo.wmmOrQosEnabled, k, newRecord->powersaveMode[k]);
2186 }
2187
2188 unifi_trace(priv, UDBG3, "newRecord->wmmOrQosEnabled : %d , MAX SP : %d\n",
2189 newRecord->wmmOrQosEnabled, newRecord->maxSpLength);
2190
2191 /* Initialize the mgtFrames & data Pdu list */
2192 {
2193 u8 j;
2194 INIT_LIST_HEAD(&newRecord->mgtFrames);
2195 for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
2196 INIT_LIST_HEAD(&newRecord->dataPdu[j]);
2197 }
2198 }
2199
2200 newRecord->lastActivity = currentTime;
2201 newRecord->activity_flag = TRUE;
2202
2203 /* enable the preemption as station record updated */
2204 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2205
2206 /* First time port actions are set for the peer with below information */
2207 configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress,
2208 UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
2209
2210 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS) {
2211 configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress,
2212 UF_CONTROLLED_PORT_Q, req->interfaceTag);
2213 } else {
2214 configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD, &newRecord->peerMacAddress,
2215 UF_CONTROLLED_PORT_Q, req->interfaceTag);
2216 }
2217
2218
2219 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2220 /* Port status must be already set before calling the Add Peer request */
2221 newRecord->peerControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a,
2222 UF_CONTROLLED_PORT_Q, req->interfaceTag);
2223 newRecord->peerUnControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a,
2224 UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
2225
2226 if (!newRecord->peerControlledPort || !newRecord->peerUnControlledPort) {
2227 /* enable the preemption as station record failed to update */
2228 unifi_warning(priv, "Un/ControlledPort record not found in port configuration array index = %d\n", i);
2229 kfree(interfacePriv->staInfo[i]);
2230 interfacePriv->staInfo[i] = NULL;
2231 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2232 return CSR_RESULT_FAILURE;
2233 }
2234
2235 newRecord->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
2236
2237 /* changes done during block ack handling */
2238 newRecord->txSuspend = FALSE;
2239
2240 /*U-APSD related data structure*/
2241 newRecord->timRequestPendingFlag = FALSE;
2242
2243 /* Initialise the variable updateTimReqQueued with a value
2244 * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
2245 */
2246 newRecord->updateTimReqQueued = 0xFF;
2247 newRecord->timSet = CSR_WIFI_TIM_RESET;
2248 newRecord->uapsdActive = FALSE;
2249 newRecord->noOfSpFramesSent =0;
2250 newRecord->triggerFramePriority = CSR_QOS_UP0;
2251
2252 /* The protection bit is updated once the port opens for corresponding peer in
2253 * routerPortConfigure request */
2254
2255 /* update the association ID */
2256 newRecord->aid = req->associationId;
2257
2258#ifdef CSR_SUPPORT_SME
2259 interfacePriv->num_stations_joined++;
2260 newRecord->interfacePriv = interfacePriv;
2261 newRecord->listenIntervalInTus = req->staInfo.listenIntervalInTus;
2262 newRecord->nullDataHostTag = INVALID_HOST_TAG;
2263
2264 INIT_WORK(&newRecord->send_disconnected_ind_task, uf_send_disconnected_ind_wq);
2265
2266 if(!(interfacePriv->sta_activity_check_enabled) &&
2267 (interfacePriv->num_stations_joined >= STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD)){
2268 unifi_trace(priv, UDBG1,
2269 "peer_add_new_record: STARTING the Inactivity Timer (num of stations = %d)",
2270 interfacePriv->num_stations_joined);
2271
2272 interfacePriv->sta_activity_check_enabled = TRUE;
2273 interfacePriv->sta_activity_check_timer.function = check_inactivity_timer_expire_func;
2274 interfacePriv->sta_activity_check_timer.data = (unsigned long)interfacePriv;
2275
2276 init_timer(&interfacePriv->sta_activity_check_timer);
2277 mod_timer(&interfacePriv->sta_activity_check_timer,
2278 (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000)));
2279
2280 }
2281#endif
2282 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2283 break;
2284 }
2285 }
2286
2287 if(!freeSlotFound) {
2288 unifi_error(priv, "Limited connectivity, Free slot not found for station record addition\n");
2289 return CSR_RESULT_FAILURE;
2290 }
2291 return CSR_RESULT_SUCCESS;
2292}
2293
2294#ifdef CSR_SUPPORT_SME
2295static void check_inactivity_timer_expire_func(unsigned long data)
2296{
2297 struct unifi_priv *priv;
2298 CsrWifiRouterCtrlStaInfo_t *sta_record = NULL;
2299 u8 i = 0;
2300 u32 now;
2301 u32 inactive_time;
2302 netInterface_priv_t *interfacePriv = (netInterface_priv_t *) data;
2303
2304 if (!interfacePriv)
2305 {
2306 return;
2307 }
2308
2309 priv = interfacePriv->privPtr;
2310
2311 if (interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES)
2312 {
2313 unifi_error(priv, "check_inactivity_timer_expire_func: Invalid interfaceTag\n");
2314 return;
2315 }
2316
2317 /* RUN Algorithm to check inactivity for each connected station */
2318 now = CsrTimeGet(NULL);
2319
2320 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
2321 if(interfacePriv->staInfo[i] != NULL) {
2322 sta_record = interfacePriv->staInfo[i];
2323
2324 if (sta_record->activity_flag == TRUE){
2325 sta_record->activity_flag = FALSE;
2326 sta_record->lastActivity = now;
2327 continue;
2328 }
2329
2330 if (sta_record->lastActivity > now)
2331 {
2332 /* simple timer wrap (for 1 wrap) */
2333 inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, sta_record->lastActivity), now);
2334 }
2335 else
2336 {
2337 inactive_time = (u32)CsrTimeSub(now, sta_record->lastActivity);
2338 }
2339
2340 if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
2341 {
2342 unifi_trace(priv, UDBG1, "STA is Inactive - AID = %d inactive_time = %d\n",
2343 sta_record->aid,
2344 inactive_time);
2345
2346 /* station is in-active, if it is in active mode send a null frame
2347 * and the station should acknowledge the null frame, if acknowledgement
2348 * is not received throw out the station.
2349 * If the station is in Power Save, update TIM for the station so
2350 * that it wakes up and register some activity through PS-Poll or
2351 * trigger frame.
2352 */
2353 if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2354 {
2355 unifi_trace(priv, UDBG1, "STA power save state - Active, send a NULL frame to check if it is ALIVE\n");
2356 uf_send_nulldata ( priv,
2357 sta_record->interfacePriv->InterfaceTag,
2358 sta_record->peerMacAddress.a,
2359 CSR_CONTENTION,
2360 sta_record);
2361 }
2362 else if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2363 {
2364 if((sta_record->timSet == CSR_WIFI_TIM_SET) ||
2365 (sta_record->timSet == CSR_WIFI_TIM_SETTING))
2366 {
2367 unifi_trace(priv, UDBG1, "STA power save state - PS, TIM is already SET\n");
2368
2369 /* If TIM is set and we do not have any activity for
2370 * more than 3 listen intervals then send a disconnected
2371 * indication to SME, to delete the station from station
2372 * record list.
2373 * The inactivity is already more than STA_INACTIVE_TIMEOUT_VAL
2374 * and this check ensures if the listen interval is a larger
2375 * value than STA_INACTIVE_TIMEOUT_VAL.
2376 */
2377 if (inactive_time > (3 * (sta_record->listenIntervalInTus * 1024)))
2378 {
2379 unifi_trace(priv, UDBG1, "STA is inactive for more than 3 listen intervals\n");
2380 queue_work( priv->unifi_workqueue,
2381 &sta_record->send_disconnected_ind_task);
2382 }
2383
2384 }
2385 else
2386 {
2387 unifi_trace(priv, UDBG1, "STA power save state - PS, update TIM to see if it is ALIVE\n");
2388 update_tim(priv,
2389 sta_record->aid,
2390 CSR_WIFI_TIM_SET,
2391 interfacePriv->InterfaceTag,
2392 sta_record->assignedHandle);
2393 }
2394 }
2395 }
2396 }
2397 }
2398
2399 /* re-run the timer interrupt */
2400 mod_timer(&interfacePriv->sta_activity_check_timer,
2401 (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000)));
2402
2403}
2404
2405
2406void uf_send_disconnected_ind_wq(struct work_struct *work)
2407{
2408
2409 CsrWifiRouterCtrlStaInfo_t *staInfo = container_of(work, CsrWifiRouterCtrlStaInfo_t, send_disconnected_ind_task);
2410 unifi_priv_t *priv;
2411 u16 interfaceTag;
2412 struct list_head send_cfm_list;
2413 u8 j;
2414
2415 if(!staInfo) {
2416 return;
2417 }
2418
2419 if(!staInfo->interfacePriv) {
2420 return;
2421 }
2422
2423 priv = staInfo->interfacePriv->privPtr;
2424 interfaceTag = staInfo->interfacePriv->InterfaceTag;
2425
2426 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2427 unifi_error(priv, "uf_send_disconnected_ind_wq: invalid interfaceTag\n");
2428 return;
2429 }
2430
2431 /* The SME/NME may be waiting for confirmation for requested frames to this station.
2432 * So loop through buffered frames for this station and if confirmation is
2433 * requested, send auto confirmation with failure status. Also flush the frames so
2434 * that these are not processed again in PEER_DEL_REQ handler.
2435 */
2436 INIT_LIST_HEAD(&send_cfm_list);
2437
2438 uf_prepare_send_cfm_list_for_queued_pkts(priv,
2439 &send_cfm_list,
2440 &(staInfo->mgtFrames));
2441
2442 uf_flush_list(priv, &(staInfo->mgtFrames));
2443
2444 for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
2445 uf_prepare_send_cfm_list_for_queued_pkts(priv,
2446 &send_cfm_list,
2447 &(staInfo->dataPdu[j]));
2448
2449 uf_flush_list(priv, &(staInfo->dataPdu[j]));
2450 }
2451
2452 send_auto_ma_packet_confirm(priv, staInfo->interfacePriv, &send_cfm_list);
2453
2454 unifi_warning(priv, "uf_send_disconnected_ind_wq: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
2455 staInfo->peerMacAddress.a[0],
2456 staInfo->peerMacAddress.a[1],
2457 staInfo->peerMacAddress.a[2],
2458 staInfo->peerMacAddress.a[3],
2459 staInfo->peerMacAddress.a[4],
2460 staInfo->peerMacAddress.a[5]);
2461
2462 CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
2463 0,
2464 staInfo->interfacePriv->InterfaceTag,
2465 staInfo->peerMacAddress,
2466 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
2467
2468
2469 return;
2470}
2471
2472
2473#endif
2474void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2475{
2476 CsrWifiRouterCtrlPeerAddReq* req = (CsrWifiRouterCtrlPeerAddReq*)msg;
2477 CsrResult status = CSR_RESULT_SUCCESS;
2478 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2479 u32 handle = 0;
2480 netInterface_priv_t *interfacePriv;
2481
2482 unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerAddReqHandler \n");
2483 if (priv == NULL)
2484 {
2485 unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: invalid smepriv\n");
2486 return;
2487 }
2488
2489 if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)
2490 {
2491 unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: bad interfaceTag\n");
2492 return;
2493 }
2494
2495 interfacePriv = priv->interfacePriv[req->interfaceTag];
2496
2497 switch(interfacePriv->interfaceMode)
2498 {
2499 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2500 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
2501 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2502 /* Add station record */
2503 status = peer_add_new_record(priv, req, &handle);
2504 break;
2505 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
2506 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
2507 default:
2508 /* No station record to maintain in these modes */
2509 break;
2510 }
2511
2512 CsrWifiRouterCtrlPeerAddCfmSend(msg->source, req->clientData, req->interfaceTag, req->peerMacAddress, handle, status);
2513 unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerAddReqHandler \n");
2514}
2515
2516void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2517{
2518 CsrWifiRouterCtrlPeerUpdateReq* req = (CsrWifiRouterCtrlPeerUpdateReq*)msg;
2519 CsrResult status = CSR_RESULT_SUCCESS;
2520 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2521
2522 unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerUpdateReqHandler \n");
2523 if (priv == NULL)
2524 {
2525 unifi_error(priv, "CsrWifiRouterCtrlPeerUpdateReqHandler: invalid smepriv\n");
2526 return;
2527 }
2528
2529 CsrWifiRouterCtrlPeerUpdateCfmSend(msg->source, req->clientData, req->interfaceTag, status);
2530 unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerUpdateReqHandler \n");
2531}
2532
2533
2534 void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2535{
2536 /* This will never be called as it is intercepted in the Userspace */
2537}
2538
2539void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2540{
2541 /* This will never be called as it is intercepted in the Userspace */
2542}
2543
2544void
2545uf_send_ba_err_wq(struct work_struct *work)
2546{
2547 ba_session_rx_struct *ba_session = container_of(work, ba_session_rx_struct, send_ba_err_task);
2548 unifi_priv_t *priv;
2549
2550 if(!ba_session) {
2551 return;
2552 }
2553
2554 if(!ba_session->interfacePriv) {
2555 return;
2556 }
2557
2558 priv = ba_session->interfacePriv->privPtr;
2559
2560 if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2561 unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__);
2562 return;
2563 }
2564
2565 unifi_warning(priv, "%s: Calling CsrWifiRouterCtrlBlockAckErrorIndSend(%d, %d, %d, %d, %x:%x:%x:%x:%x:%x, %d)\n",
2566 __FUNCTION__,
2567 priv->CSR_WIFI_SME_IFACEQUEUE,
2568 0,
2569 ba_session->interfacePriv->InterfaceTag,
2570 ba_session->tID,
2571 ba_session->macAddress.a[0],
2572 ba_session->macAddress.a[1],
2573 ba_session->macAddress.a[2],
2574 ba_session->macAddress.a[3],
2575 ba_session->macAddress.a[4],
2576 ba_session->macAddress.a[5],
2577 CSR_RESULT_SUCCESS
2578 );
2579 CsrWifiRouterCtrlBlockAckErrorIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
2580 0,
2581 ba_session->interfacePriv->InterfaceTag,
2582 ba_session->tID,
2583 ba_session->macAddress,
2584 CSR_RESULT_SUCCESS);
2585}
2586
2587
2588static void ba_session_terminate_timer_func(unsigned long data)
2589{
2590 ba_session_rx_struct *ba_session = (ba_session_rx_struct*)data;
2591 struct unifi_priv *priv;
2592
2593 if(!ba_session) {
2594 return;
2595 }
2596
2597 if(!ba_session->interfacePriv) {
2598 return;
2599 }
2600
2601 priv = ba_session->interfacePriv->privPtr;
2602
2603 if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2604 unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__);
2605 return;
2606 }
2607
2608 queue_work(priv->unifi_workqueue, &ba_session->send_ba_err_task);
2609}
2610
2611
2612u8 blockack_session_stop(unifi_priv_t *priv,
2613 u16 interfaceTag,
2614 CsrWifiRouterCtrlBlockAckRole role,
2615 u16 tID,
2616 CsrWifiMacAddress macAddress)
2617{
2618 netInterface_priv_t *interfacePriv;
2619 ba_session_rx_struct *ba_session_rx = NULL;
2620 ba_session_tx_struct *ba_session_tx = NULL;
2621 u8 ba_session_idx = 0;
2622 int i;
2623
2624 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2625 unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag);
2626 return FALSE;
2627 }
2628
2629 interfacePriv = priv->interfacePriv[interfaceTag];
2630
2631 if(!interfacePriv) {
2632 unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__);
2633 return FALSE;
2634 }
2635
2636 if(tID > 15) {
2637 unifi_error(priv, "%s: bad tID = %d\n", __FUNCTION__, tID);
2638 return FALSE;
2639 }
2640
2641 if((role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR) &&
2642 (role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT)) {
2643 unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role);
2644 return FALSE;
2645 }
2646
2647 unifi_warning(priv,
2648 "%s: stopping ba_session for peer = %pM role = %d tID = %d\n",
2649 __func__, macAddress.a, role, tID);
2650
2651 /* find out the appropriate ba session (/station /tid /role) for which stop is requested */
2652 if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){
2653 for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
2654
2655 ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx];
2656
2657 if(ba_session_rx){
2658 if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){
2659 break;
2660 }
2661 }
2662 }
2663
2664 if (!ba_session_rx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX)) {
2665 unifi_error(priv, "%s: bad ba_session for Rx [tID=%d]\n", __FUNCTION__, tID);
2666 return FALSE;
2667 }
2668
2669
2670 if(ba_session_rx->timeout) {
2671 del_timer_sync(&ba_session_rx->timer);
2672 }
2673 cancel_work_sync(&ba_session_rx->send_ba_err_task);
2674 for (i = 0; i < ba_session_rx->wind_size; i++) {
2675 if(ba_session_rx->buffer[i].active) {
2676 frame_desc_struct *frame_desc = &ba_session_rx->buffer[i];
2677 unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
2678 }
2679 }
2680 kfree(ba_session_rx->buffer);
2681
2682 interfacePriv->ba_session_rx[ba_session_idx] = NULL;
2683 kfree(ba_session_rx);
2684 }else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){
2685 for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
2686 ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx];
2687 if(ba_session_tx){
2688 if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){
2689 break;
2690 }
2691 }
2692 }
2693
2694 if (!ba_session_tx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX)) {
2695 unifi_error(priv, "%s: bad ba_session for Tx [tID=%d]\n", __FUNCTION__, tID);
2696 return FALSE;
2697 }
2698 interfacePriv->ba_session_tx[ba_session_idx] = NULL;
2699 kfree(ba_session_tx);
2700
2701 }
2702
2703 return TRUE;
2704}
2705
2706
2707void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2708{
2709 CsrWifiRouterCtrlBlockAckDisableReq* req = (CsrWifiRouterCtrlBlockAckDisableReq*)msg;
2710 u8 r;
2711 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2712
2713 unifi_trace(priv, UDBG6, "%s: in ok\n", __FUNCTION__);
2714
2715 down(&priv->ba_mutex);
2716 r = blockack_session_stop(priv,
2717 req->interfaceTag,
2718 req->role,
2719 req->trafficStreamID,
2720 req->macAddress);
2721 up(&priv->ba_mutex);
2722
2723 CsrWifiRouterCtrlBlockAckDisableCfmSend(msg->source,
2724 req->clientData,
2725 req->interfaceTag,
2726 r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE);
2727
2728 unifi_trace(priv, UDBG6, "%s: out ok\n", __FUNCTION__);
2729}
2730
2731
2732u8 blockack_session_start(unifi_priv_t *priv,
2733 u16 interfaceTag,
2734 u16 tID,
2735 u16 timeout,
2736 CsrWifiRouterCtrlBlockAckRole role,
2737 u16 wind_size,
2738 u16 start_sn,
2739 CsrWifiMacAddress macAddress
2740 )
2741{
2742 netInterface_priv_t *interfacePriv;
2743 ba_session_rx_struct *ba_session_rx = NULL;
2744 ba_session_tx_struct *ba_session_tx = NULL;
2745 u8 ba_session_idx = 0;
2746
2747
2748 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2749 unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag);
2750 return FALSE;
2751 }
2752
2753 interfacePriv = priv->interfacePriv[interfaceTag];
2754
2755 if(!interfacePriv) {
2756 unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__);
2757 return FALSE;
2758 }
2759
2760 if(tID > 15)
2761 {
2762 unifi_error(priv, "%s: bad tID=%d\n", __FUNCTION__, tID);
2763 return FALSE;
2764 }
2765
2766 if(wind_size > MAX_BA_WIND_SIZE) {
2767 unifi_error(priv, "%s: bad wind_size = %d\n", __FUNCTION__, wind_size);
2768 return FALSE;
2769 }
2770
2771 if(role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR &&
2772 role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT) {
2773 unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role);
2774 return FALSE;
2775 }
2776
2777 unifi_warning(priv,
2778 "%s: ba session with peer= (%pM)\n", __func__,
2779 macAddress.a);
2780
2781 unifi_warning(priv, "%s: ba session for tID=%d timeout=%d role=%d wind_size=%d start_sn=%d\n", __FUNCTION__,
2782 tID,
2783 timeout,
2784 role,
2785 wind_size,
2786 start_sn);
2787
2788 /* Check if BA session exists for per station, per TID, per role or not.
2789 if BA session exists update parameters and if it does not exist
2790 create a new BA session */
2791 if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){
2792 for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
2793 ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx];
2794 if (ba_session_tx) {
2795 if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){
2796 unifi_warning(priv, "%s: ba_session for Tx already exists\n", __FUNCTION__);
2797 return TRUE;
2798 }
2799 }
2800 }
2801
2802 /* we have to create new ba_session_tx struct */
2803 ba_session_tx = NULL;
2804
2805 /* loop through until an empty BA session slot is there and save the session there */
2806 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX ; ba_session_idx++){
2807 if (!(interfacePriv->ba_session_tx[ba_session_idx])){
2808 break;
2809 }
2810 }
2811 if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX){
2812 unifi_error(priv, "%s: All ba_session used for Tx, NO free session available\n", __FUNCTION__);
2813 return FALSE;
2814 }
2815
2816 /* create and populate the new BA session structure */
2817 ba_session_tx = kzalloc(sizeof(ba_session_tx_struct), GFP_KERNEL);
2818 if (!ba_session_tx) {
2819 unifi_error(priv, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__);
2820 return FALSE;
2821 }
2822
2823 ba_session_tx->interfacePriv = interfacePriv;
2824 ba_session_tx->tID = tID;
2825 ba_session_tx->macAddress = macAddress;
2826
2827 interfacePriv->ba_session_tx[ba_session_idx] = ba_session_tx;
2828
2829 } else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){
2830
2831 for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
2832 ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx];
2833 if (ba_session_rx) {
2834 if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){
2835 unifi_warning(priv, "%s: ba_session for Rx[tID = %d] already exists\n", __FUNCTION__, tID);
2836
2837 if(ba_session_rx->wind_size == wind_size &&
2838 ba_session_rx->timeout == timeout &&
2839 ba_session_rx->expected_sn == start_sn) {
2840 return TRUE;
2841 }
2842
2843 if(ba_session_rx->timeout) {
2844 del_timer_sync(&ba_session_rx->timer);
2845 ba_session_rx->timeout = 0;
2846 }
2847
2848 if(ba_session_rx->wind_size != wind_size) {
2849 blockack_session_stop(priv, interfaceTag, role, tID, macAddress);
2850 } else {
2851 if (timeout) {
2852 ba_session_rx->timeout = timeout;
2853 ba_session_rx->timer.function = ba_session_terminate_timer_func;
2854 ba_session_rx->timer.data = (unsigned long)ba_session_rx;
2855 init_timer(&ba_session_rx->timer);
2856 mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024)));
2857 }
2858 /*
2859 * The starting sequence number shall remain same if the BA
2860 * enable request is issued to update BA parameters only. If
2861 * it is not same, then we scroll our window to the new starting
2862 * sequence number. This could happen if the DELBA frame from
2863 * originator is lost and then we receive ADDBA frame with new SSN.
2864 */
2865 if(ba_session_rx->start_sn != start_sn) {
2866 scroll_ba_window(priv, interfacePriv, ba_session_rx, start_sn);
2867 }
2868 return TRUE;
2869 }
2870 }
2871 }
2872 }
2873
2874 /* we could have a valid BA session pointer here or un-initialized
2875 ba session pointer. but in any case we have to create a new session.
2876 so re-initialize the ba_session pointer */
2877 ba_session_rx = NULL;
2878
2879 /* loop through until an empty BA session slot is there and save the session there */
2880 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX ; ba_session_idx++){
2881 if (!(interfacePriv->ba_session_rx[ba_session_idx])){
2882 break;
2883 }
2884 }
2885 if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
2886 unifi_error(priv, "%s: All ba_session used for Rx, NO free session available\n", __FUNCTION__);
2887 return FALSE;
2888 }
2889
2890 /* It is observed that with some devices there is a race between
2891 * EAPOL exchanges and BA session establishment. This results in
2892 * some EAPOL authentication packets getting stuck in BA reorder
2893 * buffer and hence the conection cannot be established. To avoid
2894 * this we check here if the EAPOL authentication is complete and
2895 * if so then only allow the BA session to establish.
2896 *
2897 * It is verified that the peers normally re-establish
2898 * the BA session after the initial rejection.
2899 */
2900 if (CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN != uf_sme_port_state(priv, macAddress.a, UF_CONTROLLED_PORT_Q, interfacePriv->InterfaceTag))
2901 {
2902 unifi_warning(priv, "blockack_session_start: Controlled port not opened, Reject BA request\n");
2903 return FALSE;
2904 }
2905
2906 ba_session_rx = kzalloc(sizeof(ba_session_rx_struct), GFP_KERNEL);
2907 if (!ba_session_rx) {
2908 unifi_error(priv, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__);
2909 return FALSE;
2910 }
2911
2912 ba_session_rx->wind_size = wind_size;
2913 ba_session_rx->start_sn = ba_session_rx->expected_sn = start_sn;
2914 ba_session_rx->trigger_ba_after_ssn = FALSE;
2915
2916 ba_session_rx->buffer = kzalloc(ba_session_rx->wind_size*sizeof(frame_desc_struct), GFP_KERNEL);
2917 if (!ba_session_rx->buffer) {
2918 kfree(ba_session_rx);
2919 unifi_error(priv, "%s: kmalloc failed for buffer\n", __FUNCTION__);
2920 return FALSE;
2921 }
2922
2923 INIT_WORK(&ba_session_rx->send_ba_err_task, uf_send_ba_err_wq);
2924 if (timeout) {
2925 ba_session_rx->timeout = timeout;
2926 ba_session_rx->timer.function = ba_session_terminate_timer_func;
2927 ba_session_rx->timer.data = (unsigned long)ba_session_rx;
2928 init_timer(&ba_session_rx->timer);
2929 mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024)));
2930 }
2931
2932 ba_session_rx->interfacePriv = interfacePriv;
2933 ba_session_rx->tID = tID;
2934 ba_session_rx->macAddress = macAddress;
2935
2936 interfacePriv->ba_session_rx[ba_session_idx] = ba_session_rx;
2937 }
2938 return TRUE;
2939}
2940
2941void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2942{
2943 CsrWifiRouterCtrlBlockAckEnableReq* req = (CsrWifiRouterCtrlBlockAckEnableReq*)msg;
2944 u8 r;
2945 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2946
2947 unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
2948 down(&priv->ba_mutex);
2949 r = blockack_session_start(priv,
2950 req->interfaceTag,
2951 req->trafficStreamID,
2952 req->timeout,
2953 req->role,
2954 req->bufferSize,
2955 req->ssn,
2956 req->macAddress
2957 );
2958 up(&priv->ba_mutex);
2959
2960 CsrWifiRouterCtrlBlockAckEnableCfmSend(msg->source,
2961 req->clientData,
2962 req->interfaceTag,
2963 r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE);
2964 unifi_trace(priv, UDBG6, "<<%s: r=%d\n", __FUNCTION__, r);
2965
2966}
2967
2968void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
2969{
2970#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
2971
2972 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2973 CsrWifiRouterCtrlWapiMulticastFilterReq* req = (CsrWifiRouterCtrlWapiMulticastFilterReq*)msg;
2974 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
2975
2976 if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
2977
2978 unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
2979
2980 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiMulticastFilterReq: req->status = %d\n", req->status);
2981
2982 /* status 1 - Filter on
2983 * status 0 - Filter off */
2984 priv->wapi_multicast_filter = req->status;
2985
2986 unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
2987 } else {
2988
2989 unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
2990
2991 }
2992#elif defined(UNIFI_DEBUG)
2993 /*WAPI Disabled*/
2994 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
2995 unifi_error(priv, "CsrWifiRouterCtrlWapiMulticastFilterReqHandler: called when WAPI isn't enabled\n");
2996#endif
2997}
2998
2999void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
3000{
3001#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3002
3003 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3004 CsrWifiRouterCtrlWapiUnicastFilterReq* req = (CsrWifiRouterCtrlWapiUnicastFilterReq*)msg;
3005 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
3006
3007 if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
3008
3009 unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
3010
3011 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastFilterReq: req->status= %d\n", req->status);
3012
3013 if ((priv->wapi_unicast_filter == 1) && (req->status == 0)) {
3014 /* When we have successfully re-associated and obtained a new unicast key with keyid = 0 */
3015 priv->wapi_unicast_queued_pkt_filter = 1;
3016 }
3017
3018 /* status 1 - Filter ON
3019 * status 0 - Filter OFF */
3020 priv->wapi_unicast_filter = req->status;
3021
3022 unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
3023 } else {
3024
3025 unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
3026
3027 }
3028#elif defined(UNIFI_DEBUG)
3029 /*WAPI Disabled*/
3030 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3031 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastFilterReqHandler: called when WAPI isn't enabled\n");
3032#endif
3033}
3034
3035void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
3036{
3037#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3038
3039 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3040 CsrWifiRouterCtrlWapiRxPktReq* req = (CsrWifiRouterCtrlWapiRxPktReq*)msg;
3041 int client_id, receiver_id;
3042 bulk_data_param_t bulkdata;
3043 CsrResult res;
3044 ul_client_t *client;
3045 CSR_SIGNAL signal;
3046 CSR_MA_PACKET_INDICATION *pkt_ind;
3047 netInterface_priv_t *interfacePriv;
3048
3049 if (priv == NULL) {
3050 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n", __func__);
3051 return;
3052 }
3053
3054 if (priv->smepriv == NULL) {
3055 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n", __func__);
3056 return;
3057 }
3058
3059 interfacePriv = priv->interfacePriv[req->interfaceTag];
3060
3061 if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
3062
3063 unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
3064
3065
3066 if (req->dataLength == 0 || req->data == NULL) {
3067 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n", __FUNCTION__);
3068 return;
3069 }
3070
3071 res = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength);
3072 if (res != CSR_RESULT_SUCCESS) {
3073 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: Could not allocate net data\n", __FUNCTION__);
3074 return;
3075 }
3076
3077 /* This function is expected to be called only when the MIC has been verified by SME to be correct
3078 * So reset the reception status to rx_success */
3079 res = read_unpack_signal(req->signal, &signal);
3080 if (res) {
3081 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: Received unknown or corrupted signal.\n");
3082 return;
3083 }
3084 pkt_ind = (CSR_MA_PACKET_INDICATION*) (&((&signal)->u).MaPacketIndication);
3085 if (pkt_ind->ReceptionStatus != CSR_MICHAEL_MIC_ERROR) {
3086 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: Unknown signal with reception status = %d\n", pkt_ind->ReceptionStatus);
3087 return;
3088 } else {
3089 unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlWapiRxPktReqHandler: MIC verified , RX_SUCCESS \n", __FUNCTION__);
3090 pkt_ind->ReceptionStatus = CSR_RX_SUCCESS;
3091 write_pack(&signal, req->signal, &(req->signalLength));
3092 }
3093
3094 memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength);
3095
3096 receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((req->signal) + sizeof(s16)) & 0xFFF0;
3097 client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT;
3098
3099 client = &priv->ul_clients[client_id];
3100
3101 if (client && client->event_hook) {
3102 unifi_trace(priv, UDBG3,
3103 "CsrWifiRouterCtrlWapiRxPktReq: "
3104 "Sending signal to client %d, (s:0x%X, r:0x%X) - Signal 0x%X \n",
3105 client->client_id, client->sender_id, receiver_id,
3106 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(req->signal));
3107
3108 client->event_hook(client, req->signal, req->signalLength, &bulkdata, UDI_TO_HOST);
3109 } else {
3110 unifi_trace(priv, UDBG4, "No client to give the packet to\n");
3111 unifi_net_data_free(priv, &bulkdata.d[0]);
3112 }
3113
3114 unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
3115 } else {
3116 unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
3117 }
3118#elif defined(UNIFI_DEBUG)
3119 /*WAPI Disabled*/
3120 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3121 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: called when WAPI isn't enabled\n");
3122#endif
3123}
3124
3125void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
3126{
3127#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
3128
3129 unifi_priv_t *priv = (unifi_priv_t*) drvpriv;
3130 CsrWifiRouterCtrlWapiUnicastTxPktReq *req = (CsrWifiRouterCtrlWapiUnicastTxPktReq*) msg;
3131 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
3132 bulk_data_param_t bulkdata;
3133 u8 macHeaderLengthInBytes = MAC_HEADER_SIZE;
3134 /*KeyID, Reserved, PN, MIC*/
3135 u8 appendedCryptoFields = 1 + 1 + 16 + 16;
3136 CsrResult result;
3137 /* Retrieve the MA PACKET REQ fields from the Signal retained from send_ma_pkt_request() */
3138 CSR_MA_PACKET_REQUEST *storedSignalMAPktReq = &interfacePriv->wapi_unicast_ma_pkt_sig.u.MaPacketRequest;
3139
3140 if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
3141
3142 unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
3143
3144 if (priv == NULL) {
3145 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid priv\n", __FUNCTION__);
3146 return;
3147 }
3148 if (priv->smepriv == NULL) {
3149 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid sme priv\n", __FUNCTION__);
3150 return;
3151 }
3152 if (req->data == NULL) {
3153 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid request\n", __FUNCTION__);
3154 return;
3155 } else {
3156 /* If it is QoS data (type = data subtype = QoS), frame header contains QoS control field */
3157 if ((req->data[0] & 0x88) == 0x88) {
3158 macHeaderLengthInBytes = macHeaderLengthInBytes + QOS_CONTROL_HEADER_SIZE;
3159 }
3160 }
3161 if ( !(req->dataLength>(macHeaderLengthInBytes+appendedCryptoFields)) ) {
3162 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid dataLength\n", __FUNCTION__);
3163 return;
3164 }
3165
3166 /* Encrypted DATA Packet contained in (req->data)
3167 * -------------------------------------------------------------------
3168 * |MAC Header| KeyId | Reserved | PN | xxDataxx | xxMICxxx |
3169 * -------------------------------------------------------------------
3170 * (<-----Encrypted----->)
3171 * -------------------------------------------------------------------
3172 * |24/26(QoS)| 1 | 1 | 16 | x | 16 |
3173 * -------------------------------------------------------------------
3174 */
3175 result = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength);
3176 if (result != CSR_RESULT_SUCCESS) {
3177 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: Could not allocate net data\n", __FUNCTION__);
3178 return;
3179 }
3180 memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength);
3181 bulkdata.d[0].data_length = req->dataLength;
3182 bulkdata.d[1].os_data_ptr = NULL;
3183 bulkdata.d[1].data_length = 0;
3184
3185 /* Send UniFi msg */
3186 /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
3187 result = uf_process_ma_packet_req(priv,
3188 storedSignalMAPktReq->Ra.x,
3189 storedSignalMAPktReq->HostTag,/* Ask for a new HostTag */
3190 req->interfaceTag,
3191 storedSignalMAPktReq->TransmissionControl,
3192 storedSignalMAPktReq->TransmitRate,
3193 storedSignalMAPktReq->Priority, /* Retained value */
3194 interfacePriv->wapi_unicast_ma_pkt_sig.SignalPrimitiveHeader.SenderProcessId, /*FIXME AP: VALIDATE ???*/
3195 &bulkdata);
3196
3197 if (result == NETDEV_TX_OK) {
3198 (priv->netdev[req->interfaceTag])->trans_start = jiffies;
3199 /* Should really count tx stats in the UNITDATA.status signal but
3200 * that doesn't have the length.
3201 */
3202 interfacePriv->stats.tx_packets++;
3203
3204 /* count only the packet payload */
3205 interfacePriv->stats.tx_bytes += req->dataLength - macHeaderLengthInBytes - appendedCryptoFields;
3206 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Sent), sent count = %x\n", interfacePriv->stats.tx_packets);
3207 } else {
3208 /* Failed to send: fh queue was full, and the skb was discarded*/
3209 unifi_trace(priv, UDBG1, "(HIP validation failure) Result = %d\n", result);
3210 unifi_net_data_free(priv, &bulkdata.d[0]);
3211
3212 interfacePriv->stats.tx_dropped++;
3213 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped);
3214 }
3215
3216 unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
3217
3218 } else {
3219
3220 unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
3221
3222 }
3223#elif defined(UNIFI_DEBUG)
3224 /*WAPI Disabled*/
3225 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3226 unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: called when WAPI SW ENCRYPTION isn't enabled\n");
3227#endif
3228}
3229
3230void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
3231{
3232#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3233
3234#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
3235 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3236 CsrWifiRouterCtrlWapiFilterReq* req = (CsrWifiRouterCtrlWapiFilterReq*)msg;
3237 netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
3238
3239 if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
3240
3241 unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
3242
3243 unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiFilterReq: req->isWapiConnected [0/1] = %d \n", req->isWapiConnected);
3244
3245 priv->isWapiConnection = req->isWapiConnected;
3246
3247 unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
3248 } else {
3249
3250 unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
3251
3252 }
3253#endif
3254
3255#elif defined(UNIFI_DEBUG)
3256 /*WAPI Disabled*/
3257 unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
3258 unifi_error(priv, "CsrWifiRouterCtrlWapiFilterReq: called when WAPI isn't enabled\n");
3259#endif
3260}
diff --git a/drivers/staging/csr/sme_userspace.c b/drivers/staging/csr/sme_userspace.c
deleted file mode 100644
index b919b001ef7c..000000000000
--- a/drivers/staging/csr/sme_userspace.c
+++ /dev/null
@@ -1,315 +0,0 @@
1/*
2 *****************************************************************************
3 *
4 * FILE : sme_userspace.c
5 *
6 * PURPOSE : Support functions for userspace SME helper application.
7 *
8 *
9 * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 *****************************************************************************
15 */
16
17#include "unifi_priv.h"
18
19/*
20 * Fix Me..... These need to be the correct values...
21 * Dynamic from the user space.
22 */
23CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE = 0xFFFF;
24CsrSchedQid CSR_WIFI_SME_IFACEQUEUE = 0xFFFF;
25#ifdef CSR_SUPPORT_WEXT_AP
26CsrSchedQid CSR_WIFI_NME_IFACEQUEUE = 0xFFFF;
27#endif
28int
29uf_sme_init(unifi_priv_t *priv)
30{
31 int i, j;
32
33 CsrWifiRouterTransportInit(priv);
34
35 priv->smepriv = priv;
36
37 init_waitqueue_head(&priv->sme_request_wq);
38
39 priv->filter_tclas_ies = NULL;
40 memset(&priv->packet_filters, 0, sizeof(uf_cfg_bcast_packet_filter_t));
41
42#ifdef CSR_SUPPORT_WEXT
43 priv->ignore_bssid_join = FALSE;
44 priv->mib_data.length = 0;
45
46 uf_sme_wext_set_defaults(priv);
47#endif /* CSR_SUPPORT_WEXT*/
48
49 priv->sta_ip_address = 0xFFFFFFFF;
50
51 priv->wifi_on_state = wifi_on_unspecified;
52
53 sema_init(&priv->sme_sem, 1);
54 memset(&priv->sme_reply, 0, sizeof(sme_reply_t));
55
56 priv->ta_ind_work.in_use = 0;
57 priv->ta_sample_ind_work.in_use = 0;
58
59 priv->CSR_WIFI_SME_IFACEQUEUE = 0xFFFF;
60
61 for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
62 priv->sme_unidata_ind_filters[i].in_use = 0;
63 }
64
65 /* Create a work queue item for Traffic Analysis indications to SME */
66 INIT_WORK(&priv->ta_ind_work.task, uf_ta_ind_wq);
67 INIT_WORK(&priv->ta_sample_ind_work.task, uf_ta_sample_ind_wq);
68#ifdef CSR_SUPPORT_WEXT
69 INIT_WORK(&priv->sme_config_task, uf_sme_config_wq);
70#endif
71
72 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
73 netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
74 interfacePriv->m4_sent = FALSE;
75 interfacePriv->m4_bulk_data.net_buf_length = 0;
76 interfacePriv->m4_bulk_data.data_length = 0;
77 interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
78
79 memset(&interfacePriv->controlled_data_port, 0, sizeof(unifi_port_config_t));
80 interfacePriv->controlled_data_port.entries_in_use = 1;
81 interfacePriv->controlled_data_port.port_cfg[0].in_use = TRUE;
82 interfacePriv->controlled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
83 interfacePriv->controlled_data_port.overide_action = UF_DATA_PORT_OVERIDE;
84
85 memset(&interfacePriv->uncontrolled_data_port, 0, sizeof(unifi_port_config_t));
86 interfacePriv->uncontrolled_data_port.entries_in_use = 1;
87 interfacePriv->uncontrolled_data_port.port_cfg[0].in_use = TRUE;
88 interfacePriv->uncontrolled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
89 interfacePriv->uncontrolled_data_port.overide_action = UF_DATA_PORT_OVERIDE;
90
91 /* Mark the remainder of the port config table as unallocated */
92 for(j = 1; j < UNIFI_MAX_CONNECTIONS; j++) {
93 interfacePriv->controlled_data_port.port_cfg[j].in_use = FALSE;
94 interfacePriv->controlled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
95
96 interfacePriv->uncontrolled_data_port.port_cfg[j].in_use = FALSE;
97 interfacePriv->uncontrolled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
98 }
99
100 /* intializing the lists */
101 INIT_LIST_HEAD(&interfacePriv->genericMgtFrames);
102 INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastMgtFrames);
103 INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastFrames);
104
105 for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) {
106 interfacePriv->staInfo[j] = NULL;
107 }
108
109 interfacePriv->num_stations_joined = 0;
110 interfacePriv->sta_activity_check_enabled = FALSE;
111 }
112
113
114 return 0;
115} /* uf_sme_init() */
116
117
118void
119uf_sme_deinit(unifi_priv_t *priv)
120{
121 int i, j;
122 u8 ba_session_idx;
123 ba_session_rx_struct *ba_session_rx = NULL;
124 ba_session_tx_struct *ba_session_tx = NULL;
125 CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
126 netInterface_priv_t *interfacePriv = NULL;
127
128 /* Free any TCLASs previously allocated */
129 if (priv->packet_filters.tclas_ies_length) {
130 priv->packet_filters.tclas_ies_length = 0;
131 kfree(priv->filter_tclas_ies);
132 priv->filter_tclas_ies = NULL;
133 }
134
135 for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
136 priv->sme_unidata_ind_filters[i].in_use = 0;
137 }
138
139 /* Remove all the Peer database, before going down */
140 for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
141 down(&priv->ba_mutex);
142 for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
143 ba_session_rx = priv->interfacePriv[i]->ba_session_rx[ba_session_idx];
144 if(ba_session_rx) {
145 blockack_session_stop(priv,
146 i,
147 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT,
148 ba_session_rx->tID,
149 ba_session_rx->macAddress);
150 }
151 }
152 for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
153 ba_session_tx = priv->interfacePriv[i]->ba_session_tx[ba_session_idx];
154 if(ba_session_tx) {
155 blockack_session_stop(priv,
156 i,
157 CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR,
158 ba_session_tx->tID,
159 ba_session_tx->macAddress);
160 }
161 }
162
163 up(&priv->ba_mutex);
164 interfacePriv = priv->interfacePriv[i];
165 if(interfacePriv){
166 for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) {
167 if ((staInfo=interfacePriv->staInfo[j]) != NULL) {
168 /* Clear the STA activity parameters before freeing station Record */
169 unifi_trace(priv, UDBG1, "uf_sme_deinit: Canceling work queue for STA with AID: %d\n", staInfo->aid);
170 cancel_work_sync(&staInfo->send_disconnected_ind_task);
171 staInfo->nullDataHostTag = INVALID_HOST_TAG;
172 }
173 }
174 if (interfacePriv->sta_activity_check_enabled){
175 interfacePriv->sta_activity_check_enabled = FALSE;
176 del_timer_sync(&interfacePriv->sta_activity_check_timer);
177 }
178 }
179 CsrWifiRouterCtrlInterfaceReset(priv, i);
180 priv->interfacePriv[i]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_NONE;
181 }
182
183
184} /* uf_sme_deinit() */
185
186
187
188
189
190/*
191 * ---------------------------------------------------------------------------
192 * unifi_ta_indicate_protocol
193 *
194 * Report that a packet of a particular type has been seen
195 *
196 * Arguments:
197 * drv_priv The device context pointer passed to ta_init.
198 * protocol The protocol type enum value.
199 * direction Whether the packet was a tx or rx.
200 * src_addr The source MAC address from the data packet.
201 *
202 * Returns:
203 * None.
204 *
205 * Notes:
206 * We defer the actual sending to a background workqueue,
207 * see uf_ta_ind_wq().
208 * ---------------------------------------------------------------------------
209 */
210void
211unifi_ta_indicate_protocol(void *ospriv,
212 CsrWifiRouterCtrlTrafficPacketType packet_type,
213 CsrWifiRouterCtrlProtocolDirection direction,
214 const CsrWifiMacAddress *src_addr)
215{
216 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
217
218 if (priv->ta_ind_work.in_use) {
219 unifi_warning(priv,
220 "unifi_ta_indicate_protocol: workqueue item still in use, not sending\n");
221 return;
222 }
223
224 if (CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX == direction)
225 {
226 u16 interfaceTag = 0;
227 CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
228 interfaceTag,
229 packet_type,
230 direction,
231 *src_addr);
232 }
233 else
234 {
235 priv->ta_ind_work.packet_type = packet_type;
236 priv->ta_ind_work.direction = direction;
237 priv->ta_ind_work.src_addr = *src_addr;
238
239 queue_work(priv->unifi_workqueue, &priv->ta_ind_work.task);
240 }
241
242} /* unifi_ta_indicate_protocol() */
243
244
245/*
246 * ---------------------------------------------------------------------------
247 * unifi_ta_indicate_sampling
248 *
249 * Send the TA sampling information to the SME.
250 *
251 * Arguments:
252 * drv_priv The device context pointer passed to ta_init.
253 * stats The TA sampling data to send.
254 *
255 * Returns:
256 * None.
257 * ---------------------------------------------------------------------------
258 */
259void
260unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats)
261{
262 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
263
264 if (!priv) {
265 return;
266 }
267
268 if (priv->ta_sample_ind_work.in_use) {
269 unifi_warning(priv,
270 "unifi_ta_indicate_sampling: workqueue item still in use, not sending\n");
271 return;
272 }
273
274 priv->ta_sample_ind_work.stats = *stats;
275
276 queue_work(priv->unifi_workqueue, &priv->ta_sample_ind_work.task);
277
278} /* unifi_ta_indicate_sampling() */
279
280
281/*
282 * ---------------------------------------------------------------------------
283 * unifi_ta_indicate_l4stats
284 *
285 * Send the TA TCP/UDP throughput information to the driver.
286 *
287 * Arguments:
288 * drv_priv The device context pointer passed to ta_init.
289 * rxTcpThroughput TCP RX throughput in KiloBytes
290 * txTcpThroughput TCP TX throughput in KiloBytes
291 * rxUdpThroughput UDP RX throughput in KiloBytes
292 * txUdpThroughput UDP TX throughput in KiloBytes
293 *
294 * Returns:
295 * None.
296 * ---------------------------------------------------------------------------
297 */
298void
299unifi_ta_indicate_l4stats(void *ospriv,
300 u32 rxTcpThroughput,
301 u32 txTcpThroughput,
302 u32 rxUdpThroughput,
303 u32 txUdpThroughput)
304{
305 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
306
307 if (!priv) {
308 return;
309 }
310 /* Save the info. The actual action will be taken in unifi_ta_indicate_sampling() */
311 priv->rxTcpThroughput = rxTcpThroughput;
312 priv->txTcpThroughput = txTcpThroughput;
313 priv->rxUdpThroughput = rxUdpThroughput;
314 priv->txUdpThroughput = txUdpThroughput;
315} /* unifi_ta_indicate_l4stats() */
diff --git a/drivers/staging/csr/sme_userspace.h b/drivers/staging/csr/sme_userspace.h
deleted file mode 100644
index ebe371c732b2..000000000000
--- a/drivers/staging/csr/sme_userspace.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: sme_userspace.h
4 *
5 * PURPOSE: SME related definitions.
6 *
7 * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
8 *
9 * Refer to LICENSE.txt included with this source code for details on
10 * the license terms.
11 *
12 * ***************************************************************************
13 */
14#ifndef __LINUX_SME_USERSPACE_H__
15#define __LINUX_SME_USERSPACE_H__ 1
16
17#include <linux/kernel.h>
18
19int uf_sme_init(unifi_priv_t *priv);
20void uf_sme_deinit(unifi_priv_t *priv);
21int uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length);
22
23
24#include "csr_wifi_router_lib.h"
25#include "csr_wifi_router_sef.h"
26#include "csr_wifi_router_ctrl_lib.h"
27#include "csr_wifi_router_ctrl_sef.h"
28#include "csr_wifi_sme_task.h"
29#ifdef CSR_SUPPORT_WEXT_AP
30#include "csr_wifi_nme_ap_lib.h"
31#endif
32#include "csr_wifi_sme_lib.h"
33
34void CsrWifiRouterTransportInit(unifi_priv_t *priv);
35void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8 *buffer, size_t bufferLength);
36void CsrWifiRouterTransportDeInit(unifi_priv_t *priv);
37
38#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
index 84f11cb53596..000000000000
--- a/drivers/staging/csr/sme_wext.c
+++ /dev/null
@@ -1,3327 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: sme_wext.c
4 *
5 * PURPOSE:
6 * Handlers for ioctls from iwconfig.
7 * These provide the control plane operations.
8 *
9 * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16#include <linux/types.h>
17#include <linux/etherdevice.h>
18#include <linux/if_arp.h>
19#include <asm/uaccess.h>
20#include <linux/ctype.h>
21#include "unifi_priv.h"
22#include <linux/rtnetlink.h>
23
24#define CHECK_INITED(_priv) \
25 do { \
26 if (_priv->init_progress != UNIFI_INIT_COMPLETED) { \
27 unifi_trace(_priv, UDBG2, "%s unifi not ready, failing wext call\n", __FUNCTION__); \
28 return -ENODEV; \
29 } \
30 } while (0)
31
32/* Workaround for the wpa_supplicant hanging issue - disabled on Android */
33#ifndef ANDROID_BUILD
34#define CSR_WIFI_WEXT_HANG_WORKAROUND
35#endif
36
37#ifdef CSR_WIFI_WEXT_HANG_WORKAROUND
38# define UF_RTNL_LOCK() rtnl_lock()
39# define UF_RTNL_UNLOCK() rtnl_unlock()
40#else
41# define UF_RTNL_LOCK()
42# define UF_RTNL_UNLOCK()
43#endif
44
45
46/*
47 * ---------------------------------------------------------------------------
48 * Helper functions
49 * ---------------------------------------------------------------------------
50 */
51
52/*
53 * ---------------------------------------------------------------------------
54 * wext_freq_to_channel
55 * channel_to_mhz
56 *
57 * These functions convert between channel number and frequency.
58 *
59 * Arguments:
60 * ch Channel number, as defined in 802.11 specs
61 * m, e Mantissa and exponent as provided by wireless extension.
62 *
63 * Returns:
64 * channel or frequency (in MHz) value
65 * ---------------------------------------------------------------------------
66 */
67static int
68wext_freq_to_channel(int m, int e)
69{
70 int mhz;
71
72 mhz = m;
73 while (e < 6) {
74 mhz /= 10;
75 e++;
76 }
77 while (e > 6) {
78 mhz *= 10;
79 e--;
80 }
81
82 if (mhz >= 5000) {
83 return ((mhz - 5000) / 5);
84 }
85
86 if (mhz == 2482) {
87 return 14;
88 }
89
90 if (mhz >= 2407) {
91 return ((mhz - 2407) / 5);
92 }
93
94 return 0;
95} /* wext_freq_to_channel() */
96
97static int
98channel_to_mhz(int ch, int dot11a)
99{
100
101 if (ch == 0) return 0;
102 if (ch > 200) return 0;
103
104 /* 5G */
105 if (dot11a) {
106 return (5000 + (5 * ch));
107 }
108
109 /* 2.4G */
110 if (ch == 14) {
111 return 2484;
112 }
113
114 if ((ch < 14) && (ch > 0)) {
115 return (2407 + (5 * ch));
116 }
117
118 return 0;
119}
120#ifdef CSR_SUPPORT_WEXT_AP
121void uf_sme_wext_ap_set_defaults(unifi_priv_t *priv)
122{
123 memcpy(priv->ap_config.ssid.ssid, "defaultssid", sizeof("defaultssid"));
124
125 priv->ap_config.ssid.length = 8;
126 priv->ap_config.channel = 6;
127 priv->ap_config.if_index = 1;
128 priv->ap_config.credentials.authType = 0;
129 priv->ap_config.max_connections=8;
130
131 priv->group_sec_config.apGroupkeyTimeout = 0;
132 priv->group_sec_config.apStrictGtkRekey = 0;
133 priv->group_sec_config.apGmkTimeout = 0;
134 priv->group_sec_config.apResponseTimeout = 100; /* Default*/
135 priv->group_sec_config.apRetransLimit = 3; /* Default*/
136 /* Set default params even if they may not be used*/
137 /* Until Here*/
138
139 priv->ap_mac_config.preamble = CSR_WIFI_SME_USE_LONG_PREAMBLE;
140 priv->ap_mac_config.shortSlotTimeEnabled = FALSE;
141 priv->ap_mac_config.ctsProtectionType=CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC;
142
143 priv->ap_mac_config.wmmEnabled = TRUE;
144 priv->ap_mac_config.wmmApParams[0].cwMin=4;
145 priv->ap_mac_config.wmmApParams[0].cwMax=10;
146 priv->ap_mac_config.wmmApParams[0].aifs=3;
147 priv->ap_mac_config.wmmApParams[0].txopLimit=0;
148 priv->ap_mac_config.wmmApParams[0].admissionControlMandatory=FALSE;
149 priv->ap_mac_config.wmmApParams[1].cwMin=4;
150 priv->ap_mac_config.wmmApParams[1].cwMax=10;
151 priv->ap_mac_config.wmmApParams[1].aifs=7;
152 priv->ap_mac_config.wmmApParams[1].txopLimit=0;
153 priv->ap_mac_config.wmmApParams[1].admissionControlMandatory=FALSE;
154 priv->ap_mac_config.wmmApParams[2].cwMin=3;
155 priv->ap_mac_config.wmmApParams[2].cwMax=4;
156 priv->ap_mac_config.wmmApParams[2].aifs=1;
157 priv->ap_mac_config.wmmApParams[2].txopLimit=94;
158 priv->ap_mac_config.wmmApParams[2].admissionControlMandatory=FALSE;
159 priv->ap_mac_config.wmmApParams[3].cwMin=2;
160 priv->ap_mac_config.wmmApParams[3].cwMax=3;
161 priv->ap_mac_config.wmmApParams[3].aifs=1;
162 priv->ap_mac_config.wmmApParams[3].txopLimit=47;
163 priv->ap_mac_config.wmmApParams[3].admissionControlMandatory=FALSE;
164
165 priv->ap_mac_config.wmmApBcParams[0].cwMin=4;
166 priv->ap_mac_config.wmmApBcParams[0].cwMax=10;
167 priv->ap_mac_config.wmmApBcParams[0].aifs=3;
168 priv->ap_mac_config.wmmApBcParams[0].txopLimit=0;
169 priv->ap_mac_config.wmmApBcParams[0].admissionControlMandatory=FALSE;
170 priv->ap_mac_config.wmmApBcParams[1].cwMin=4;
171 priv->ap_mac_config.wmmApBcParams[1].cwMax=10;
172 priv->ap_mac_config.wmmApBcParams[1].aifs=7;
173 priv->ap_mac_config.wmmApBcParams[1].txopLimit=0;
174 priv->ap_mac_config.wmmApBcParams[1].admissionControlMandatory=FALSE;
175 priv->ap_mac_config.wmmApBcParams[2].cwMin=3;
176 priv->ap_mac_config.wmmApBcParams[2].cwMax=4;
177 priv->ap_mac_config.wmmApBcParams[2].aifs=2;
178 priv->ap_mac_config.wmmApBcParams[2].txopLimit=94;
179 priv->ap_mac_config.wmmApBcParams[2].admissionControlMandatory=FALSE;
180 priv->ap_mac_config.wmmApBcParams[3].cwMin=2;
181 priv->ap_mac_config.wmmApBcParams[3].cwMax=3;
182 priv->ap_mac_config.wmmApBcParams[3].aifs=2;
183 priv->ap_mac_config.wmmApBcParams[3].txopLimit=47;
184 priv->ap_mac_config.wmmApBcParams[3].admissionControlMandatory=FALSE;
185
186 priv->ap_mac_config.accessType=CSR_WIFI_AP_ACCESS_TYPE_NONE;
187 priv->ap_mac_config.macAddressListCount=0;
188 priv->ap_mac_config.macAddressList=NULL;
189
190 priv->ap_mac_config.apHtParams.rxStbc=1;
191 priv->ap_mac_config.apHtParams.rifsModeAllowed=TRUE;
192 priv->ap_mac_config.apHtParams.greenfieldSupported=FALSE;
193 priv->ap_mac_config.apHtParams.shortGi20MHz=TRUE;
194 priv->ap_mac_config.apHtParams.htProtection=0;
195 priv->ap_mac_config.apHtParams.dualCtsProtection=FALSE;
196
197 priv->ap_mac_config.phySupportedBitmap =
198 (CSR_WIFI_SME_AP_PHY_SUPPORT_B|CSR_WIFI_SME_AP_PHY_SUPPORT_G|CSR_WIFI_SME_AP_PHY_SUPPORT_N);
199 priv->ap_mac_config.beaconInterval= 100;
200 priv->ap_mac_config.dtimPeriod=3;
201 priv->ap_mac_config.maxListenInterval=0x00ff;/* Set it to a large value
202 to enable different types of
203 devices to join us */
204 priv->ap_mac_config.supportedRatesCount =
205 uf_configure_supported_rates(priv->ap_mac_config.supportedRates, priv->ap_mac_config.phySupportedBitmap);
206}
207#endif
208/*
209 * ---------------------------------------------------------------------------
210 * uf_sme_wext_set_defaults
211 *
212 * Set up power-on defaults for driver config.
213 *
214 * Note: The SME Management API *cannot* be used in this function.
215 *
216 * Arguments:
217 * priv Pointer to device private context struct
218 *
219 * Returns:
220 * None.
221 * ---------------------------------------------------------------------------
222 */
223void
224uf_sme_wext_set_defaults(unifi_priv_t *priv)
225{
226 memset(&priv->connection_config, 0, sizeof(CsrWifiSmeConnectionConfig));
227
228 priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE;
229 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
230 priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
231 priv->connection_config.privacyMode = CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
232 priv->connection_config.wmmQosInfo = 0xFF;
233 priv->connection_config.ifIndex = CSR_WIFI_SME_RADIO_IF_BOTH;
234 priv->connection_config.adhocJoinOnly = FALSE;
235 priv->connection_config.adhocChannel = 6;
236
237 priv->wep_tx_key_index = 0;
238
239 priv->wext_wireless_stats.qual.qual = 0;
240 priv->wext_wireless_stats.qual.level = 0;
241 priv->wext_wireless_stats.qual.noise = 0;
242 priv->wext_wireless_stats.qual.updated = 0x70;
243#ifdef CSR_SUPPORT_WEXT_AP
244 /* Initialize the default configuration for AP */
245 uf_sme_wext_ap_set_defaults(priv);
246#endif
247
248
249} /* uf_sme_wext_set_defaults() */
250
251
252/*
253 * ---------------------------------------------------------------------------
254 * WEXT methods
255 * ---------------------------------------------------------------------------
256 */
257
258/*
259 * ---------------------------------------------------------------------------
260 * unifi_giwname - handler for SIOCGIWNAME
261 * unifi_siwfreq - handler for SIOCSIWFREQ
262 * unifi_giwfreq - handler for SIOCGIWFREQ
263 * unifi_siwmode - handler for SIOCSIWMODE
264 * unifi_giwmode - handler for SIOCGIWMODE
265 * unifi_giwrange - handler for SIOCGIWRANGE
266 * unifi_siwap - handler for SIOCSIWAP
267 * unifi_giwap - handler for SIOCGIWAP
268 * unifi_siwscan - handler for SIOCSIWSCAN
269 * unifi_giwscan - handler for SIOCGIWSCAN
270 * unifi_siwessid - handler for SIOCSIWESSID
271 * unifi_giwessid - handler for SIOCGIWESSID
272 * unifi_siwencode - handler for SIOCSIWENCODE
273 * unifi_giwencode - handler for SIOCGIWENCODE
274 *
275 * Handler functions for IW extensions.
276 * These are registered via the unifi_iw_handler_def struct below
277 * and called by the generic IW driver support code.
278 * See include/net/iw_handler.h.
279 *
280 * Arguments:
281 * None.
282 *
283 * Returns:
284 * None.
285 * ---------------------------------------------------------------------------
286 */
287static int
288iwprivsdefs(struct net_device *dev, struct iw_request_info *info,
289 union iwreq_data *wrqu, char *extra)
290{
291 int r;
292 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
293 unifi_priv_t *priv = interfacePriv->privPtr;
294 CsrWifiSmeMibConfig mibConfig;
295 CsrWifiSmePowerConfig powerConfig;
296
297 unifi_trace(priv, UDBG1, "iwprivs80211defaults: reload defaults\n");
298
299 uf_sme_wext_set_defaults(priv);
300
301 /* Get, modify and set the MIB data */
302 r = sme_mgt_mib_config_get(priv, &mibConfig);
303 if (r) {
304 unifi_error(priv, "iwprivs80211defaults: Get CsrWifiSmeMibConfigValue failed.\n");
305 return r;
306 }
307 mibConfig.dot11RtsThreshold = 2347;
308 mibConfig.dot11FragmentationThreshold = 2346;
309 r = sme_mgt_mib_config_set(priv, &mibConfig);
310 if (r) {
311 unifi_error(priv, "iwprivs80211defaults: Set CsrWifiSmeMibConfigValue failed.\n");
312 return r;
313 }
314
315 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
316 powerConfig.listenIntervalTu = 100;
317 powerConfig.rxDtims = 1;
318
319 r = sme_mgt_power_config_set(priv, &powerConfig);
320 if (r) {
321 unifi_error(priv, "iwprivs80211defaults: Set unifi_PowerConfigValue failed.\n");
322 return r;
323 }
324
325 return 0;
326} /* iwprivsdefs() */
327
328static int
329iwprivs80211ps(struct net_device *dev, struct iw_request_info *info,
330 union iwreq_data *wrqu, char *extra)
331{
332 int r = 0;
333 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
334 unifi_priv_t *priv = interfacePriv->privPtr;
335
336 int ps_mode = (int)(*extra);
337 CsrWifiSmePowerConfig powerConfig;
338
339 unifi_trace(priv, UDBG1, "iwprivs80211ps: power save mode = %d\n", ps_mode);
340
341 r = sme_mgt_power_config_get(priv, &powerConfig);
342 if (r) {
343 unifi_error(priv, "iwprivs80211ps: Get unifi_PowerConfigValue failed.\n");
344 return r;
345 }
346
347 switch (ps_mode) {
348 case CSR_PMM_ACTIVE_MODE:
349 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
350 break;
351 case CSR_PMM_POWER_SAVE:
352 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
353 break;
354 case CSR_PMM_FAST_POWER_SAVE:
355 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
356 break;
357 default:
358 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
359 break;
360 }
361
362 r = sme_mgt_power_config_set(priv, &powerConfig);
363 if (r) {
364 unifi_error(priv, "iwprivs80211ps: Set unifi_PowerConfigValue failed.\n");
365 }
366
367 return r;
368}
369
370static int
371iwprivg80211ps(struct net_device *dev, struct iw_request_info *info,
372 union iwreq_data *wrqu, char *extra)
373{
374 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
375 unifi_priv_t *priv = interfacePriv->privPtr;
376
377 CsrWifiSmePowerConfig powerConfig;
378 int r;
379
380 r = sme_mgt_power_config_get(priv, &powerConfig);
381 if (r) {
382 unifi_error(priv, "iwprivg80211ps: Get 802.11 power mode failed.\n");
383 return r;
384 }
385
386 switch (powerConfig.powerSaveLevel) {
387 case CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW:
388 snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
389 "Power save mode: %d (Active)",
390 powerConfig.powerSaveLevel);
391 break;
392 case CSR_WIFI_SME_POWER_SAVE_LEVEL_MED:
393 snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
394 "Power save mode: %d (Fast)",
395 powerConfig.powerSaveLevel);
396 break;
397 case CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH:
398 snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
399 "Power save mode: %d (Full)",
400 powerConfig.powerSaveLevel);
401 break;
402 case CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO:
403 snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
404 "Power save mode: %d (Auto)",
405 powerConfig.powerSaveLevel);
406 break;
407 default:
408 snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
409 "Power save mode: %d (Unknown)",
410 powerConfig.powerSaveLevel);
411 break;
412 }
413
414 wrqu->data.length = strlen(extra) + 1;
415
416 return 0;
417}
418
419static int
420iwprivssmedebug(struct net_device *dev, struct iw_request_info *info,
421 union iwreq_data *wrqu, char *extra)
422{
423 /* No longer supported on the API */
424#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
425 unifi_debug_buf_dump();
426#endif
427
428 return 0;
429}
430
431#ifdef CSR_SUPPORT_WEXT_AP
432#define PARAM_TYPE_INT 0
433#define PARAM_TYPE_STRING 1
434#define CSR_WIFI_MAX_SSID_LEN 32
435#define CSR_WIFI_MAX_SEC_LEN 16
436#define CSR_WIFI_MAX_KEY_LEN 65
437
438static int hex_look_up(char x)
439{
440 if(x>='0' && x<='9')
441 return (x-48);
442 if(x>= 'a' && x <= 'f')
443 return (x-87);
444 return -1;
445}
446
447static int power (int a, int b)
448{
449 int i;
450 int num =1;
451 for(i=0;i<b;i++)
452 num *=a;
453 return num;
454}
455
456static int decode_parameter_from_string(unifi_priv_t* priv, char **str_ptr,
457 const char *token, int param_type,
458 void *dst, int param_max_len)
459{
460 u8 int_str[7] = "0";
461 u32 param_str_len;
462 u8 *param_str_begin, *param_str_end;
463 u8 *orig_str = *str_ptr;
464
465 if (!strncmp(*str_ptr, token, strlen(token))) {
466 strsep(str_ptr, "=,");
467 param_str_begin = *str_ptr;
468 strsep(str_ptr, "=,");
469 if (*str_ptr == NULL) {
470 param_str_len = strlen(param_str_begin);
471 } else {
472 param_str_end = *str_ptr-1;
473 param_str_len = param_str_end - param_str_begin;
474 }
475 unifi_trace(priv, UDBG2, "'token:%s', len:%d, ", token, param_str_len);
476 if (param_str_len > param_max_len) {
477 unifi_notice(priv, "extracted param len:%d is > MAX:%d\n", param_str_len, param_max_len);
478 param_str_len = param_max_len;
479 }
480 switch (param_type) {
481 case PARAM_TYPE_INT:
482 {
483 u32 *pdst_int = dst, num =0;
484 int i, j=0;
485 if (param_str_len > sizeof(int_str)) {
486 param_str_len = sizeof(int_str);
487 }
488 memcpy(int_str, param_str_begin, param_str_len);
489 for(i = param_str_len; i>0;i--) {
490 if(int_str[i-1] >= '0' && int_str[i-1] <='9') {
491 num += ((int_str[i-1]-'0')*power(10, j));
492 j++;
493 } else {
494 unifi_error(priv, "decode_parameter_from_string:not a number %c\n", (int_str[i-1]));
495 return -1;
496 }
497 }
498 *pdst_int = num;
499 unifi_trace(priv, UDBG2, "decode_parameter_from_string:decoded int = %d\n", *pdst_int);
500 }
501 break;
502 default:
503 memcpy(dst, param_str_begin, param_str_len);
504 *((char *)dst + param_str_len) = 0;
505 unifi_trace(priv, UDBG2, "decode_parameter_from_string:decoded string = %s\n", (char *)dst);
506 break;
507 }
508 } else {
509 unifi_error(priv, "decode_parameter_from_string: Token:%s not found in %s \n", token, orig_str);
510 return -1;
511 }
512 return 0;
513}
514static int store_ap_advanced_config_from_string(unifi_priv_t *priv, char *param_str)
515{
516 char * str_ptr=param_str;
517 int ret = 0, tmp_var;
518 char phy_mode[6];
519 CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config;
520
521 /* Check for BI */
522 ret = decode_parameter_from_string(priv, &str_ptr, "BI=",
523 PARAM_TYPE_INT, &tmp_var, 5);
524 if(ret) {
525 unifi_error(priv, "store_ap_advanced_config_from_string: BI not found\n");
526 return -1;
527 }
528 ap_mac_config->beaconInterval = tmp_var;
529 ret = decode_parameter_from_string(priv, &str_ptr, "DTIM_PER=",
530 PARAM_TYPE_INT, &tmp_var, 5);
531 if(ret) {
532 unifi_error(priv, "store_ap_advanced_config_from_string: DTIM_PER not found\n");
533 return -1;
534 }
535 ap_mac_config->dtimPeriod = tmp_var;
536 ret = decode_parameter_from_string(priv, &str_ptr, "WMM=",
537 PARAM_TYPE_INT, &tmp_var, 5);
538 if(ret) {
539 unifi_error(priv, "store_ap_advanced_config_from_string: WMM not found\n");
540 return -1;
541 }
542 ap_mac_config->wmmEnabled = tmp_var;
543 ret = decode_parameter_from_string(priv, &str_ptr, "PHY=",
544 PARAM_TYPE_STRING, phy_mode, 5);
545 if(ret) {
546 unifi_error(priv, "store_ap_advanced_config_from_string: PHY not found\n");
547 } else {
548 if(strstr(phy_mode, "b")){
549 ap_mac_config->phySupportedBitmap = CSR_WIFI_SME_AP_PHY_SUPPORT_B;
550 }
551 if(strstr(phy_mode, "g")) {
552 ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_G;
553 }
554 if(strstr(phy_mode, "n")) {
555 ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_N;
556 }
557 ap_mac_config->supportedRatesCount =
558 uf_configure_supported_rates(ap_mac_config->supportedRates, ap_mac_config->phySupportedBitmap);
559 }
560 return ret;
561}
562
563static int store_ap_config_from_string( unifi_priv_t * priv, char *param_str)
564
565{
566 char *str_ptr = param_str;
567 char sub_cmd[16];
568 char sec[CSR_WIFI_MAX_SEC_LEN];
569 char key[CSR_WIFI_MAX_KEY_LEN];
570 int ret = 0, tmp_var;
571 CsrWifiSmeApConfig_t *ap_config = &priv->ap_config;
572 CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config;
573 memset(sub_cmd, 0, sizeof(sub_cmd));
574 if(!strstr(param_str, "END")) {
575 unifi_error(priv, "store_ap_config_from_string:Invalid config string:%s\n", param_str);
576 return -1;
577 }
578 if (decode_parameter_from_string(priv, &str_ptr, "ASCII_CMD=",
579 PARAM_TYPE_STRING, sub_cmd, 6) != 0) {
580 return -1;
581 }
582 if (strncmp(sub_cmd, "AP_CFG", 6)) {
583
584 if(!strncmp(sub_cmd , "ADVCFG", 6)) {
585 return store_ap_advanced_config_from_string(priv, str_ptr);
586 }
587 unifi_error(priv, "store_ap_config_from_string: sub_cmd:%s != 'AP_CFG or ADVCFG'!\n", sub_cmd);
588 return -1;
589 }
590 memset(ap_config, 0, sizeof(CsrWifiSmeApConfig_t));
591 ret = decode_parameter_from_string(priv, &str_ptr, "SSID=",
592 PARAM_TYPE_STRING, ap_config->ssid.ssid,
593 CSR_WIFI_MAX_SSID_LEN);
594 if(ret) {
595 unifi_error(priv, "store_ap_config_from_string: SSID not found\n");
596 return -1;
597 }
598 ap_config->ssid.length = strlen(ap_config->ssid.ssid);
599
600 ret = decode_parameter_from_string(priv, &str_ptr, "SEC=",
601 PARAM_TYPE_STRING, sec, CSR_WIFI_MAX_SEC_LEN);
602 if(ret) {
603 unifi_error(priv, "store_ap_config_from_string: SEC not found\n");
604 return -1;
605 }
606 ret = decode_parameter_from_string(priv, &str_ptr, "KEY=",
607 PARAM_TYPE_STRING, key, CSR_WIFI_MAX_KEY_LEN);
608 if(!strcasecmp(sec, "open")) {
609 unifi_trace(priv, UDBG2, "store_ap_config_from_string: security open");
610 ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM;
611 if(ret) {
612 unifi_notice(priv, "store_ap_config_from_string: KEY not found:fine with Open\n");
613 }
614 }
615 else if(!strcasecmp(sec, "wpa2-psk")) {
616 int i, j=0;
617 CsrWifiNmeApAuthPers *pers =
618 ((CsrWifiNmeApAuthPers *)&(ap_config->credentials.nmeAuthType.authTypePersonal));
619 u8 *psk = pers->authPers_credentials.psk.psk;
620
621 unifi_trace(priv, UDBG2, "store_ap_config_from_string: security WPA2");
622 if(ret) {
623 unifi_error(priv, "store_ap_config_from_string: KEY not found for WPA2\n");
624 return -1;
625 }
626 ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL;
627 pers->authSupport = CSR_WIFI_SME_RSN_AUTH_WPA2PSK;
628 pers->rsnCapabilities =0;
629 pers->wapiCapabilities =0;
630 pers->pskOrPassphrase=CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK;
631 pers->authPers_credentials.psk.encryptionMode =
632 (CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP |CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP) ;
633 for(i=0;i<32;i++){
634 psk[i] = (16*hex_look_up(key[j]))+hex_look_up(key[j+1]);
635 j+=2;
636 }
637
638 } else {
639 unifi_notice(priv, "store_ap_config_from_string: Unknown security: Assuming Open");
640 ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM;
641 return -1;
642 }
643 /* Get the decoded value in a temp int variable to ensure that other fields within the struct
644 which are of type other than int are not over written */
645 ret = decode_parameter_from_string(priv, &str_ptr, "CHANNEL=", PARAM_TYPE_INT, &tmp_var, 5);
646 if(ret)
647 return -1;
648 ap_config->channel = tmp_var;
649 ret = decode_parameter_from_string(priv, &str_ptr, "PREAMBLE=", PARAM_TYPE_INT, &tmp_var, 5);
650 if(ret)
651 return -1;
652 ap_mac_config->preamble = tmp_var;
653 ret = decode_parameter_from_string(priv, &str_ptr, "MAX_SCB=", PARAM_TYPE_INT, &tmp_var, 5);
654 ap_config->max_connections = tmp_var;
655 return ret;
656}
657
658static int
659iwprivsapstart(struct net_device *dev, struct iw_request_info *info,
660 union iwreq_data *wrqu, char *extra)
661{
662 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
663 unifi_priv_t *priv = interfacePriv->privPtr;
664 int r;
665
666 unifi_trace(priv, UDBG1, "iwprivsapstart\n" );
667 r = sme_ap_start(priv, interfacePriv->InterfaceTag, &priv->ap_config);
668 if(r) {
669 unifi_error(priv, "iwprivsapstart AP START failed : %d\n", -r);
670 }
671 return r;
672}
673
674static int
675iwprivsapconfig(struct net_device *dev, struct iw_request_info *info,
676 union iwreq_data *wrqu, char *extra)
677{
678 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
679 unifi_priv_t *priv = interfacePriv->privPtr;
680 char *cfg_str = NULL;
681 int r;
682
683 unifi_trace(priv, UDBG1, "iwprivsapconfig\n" );
684 if (wrqu->data.length != 0) {
685 char *str;
686 if (!(cfg_str = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
687 {
688 return -ENOMEM;
689 }
690 if (copy_from_user(cfg_str, wrqu->data.pointer, wrqu->data.length)) {
691 kfree(cfg_str);
692 return -EFAULT;
693 }
694 cfg_str[wrqu->data.length] = 0;
695 unifi_trace(priv, UDBG2, "length:%d\n", wrqu->data.length);
696 unifi_trace(priv, UDBG2, "AP configuration string:%s\n", cfg_str);
697 str = cfg_str;
698 if ((r = store_ap_config_from_string(priv, str))) {
699 unifi_error(priv, "iwprivsapconfig:Failed to decode the string %d\n", r);
700 kfree(cfg_str);
701 return -EIO;
702
703 }
704 } else {
705 unifi_error(priv, "iwprivsapconfig argument length = 0 \n");
706 return -EIO;
707 }
708 r = sme_ap_config(priv, &priv->ap_mac_config, &priv->group_sec_config);
709 if(r) {
710 unifi_error(priv, "iwprivsapstop AP Config failed : %d\n", -r);
711 } else if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
712 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
713 unifi_trace(priv, UDBG1, "iwprivsapconfig: Starting the AP");
714 r = sme_ap_start(priv, interfacePriv->InterfaceTag, &priv->ap_config);
715 if(r) {
716 unifi_error(priv, "iwprivsapstart AP START failed : %d\n", -r);
717 }
718 }
719 kfree(cfg_str);
720 return r;
721}
722
723static int
724iwprivsapstop(struct net_device *dev, struct iw_request_info *info,
725 union iwreq_data *wrqu, char *extra)
726{
727 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
728 unifi_priv_t *priv = interfacePriv->privPtr;
729 int r;
730 u16 interface_tag = interfacePriv->InterfaceTag;
731
732 unifi_trace(priv, UDBG1, "iwprivsapstop\n" );
733 r = sme_ap_stop(priv, interface_tag);
734 if(r) {
735 unifi_error(priv, "iwprivsapstop AP STOP failed : %d\n", -r);
736 }
737 return r;
738}
739
740#ifdef ANDROID_BUILD
741static int
742iwprivsapfwreload(struct net_device *dev, struct iw_request_info *info,
743 union iwreq_data *wrqu, char *extra)
744{
745 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
746 unifi_priv_t *priv = interfacePriv->privPtr;
747
748 unifi_trace(priv, UDBG1, "iwprivsapfwreload\n" );
749 return 0;
750}
751
752static int
753iwprivsstackstart(struct net_device *dev, struct iw_request_info *info,
754 union iwreq_data *wrqu, char *extra)
755{
756 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
757 unifi_priv_t *priv = interfacePriv->privPtr;
758 unifi_trace(priv, UDBG1, "iwprivsstackstart\n" );
759 return 0;
760}
761
762static int
763iwprivsstackstop(struct net_device *dev, struct iw_request_info *info,
764 union iwreq_data *wrqu, char *extra)
765{
766 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
767 unifi_priv_t *priv = interfacePriv->privPtr;
768 int r = 0;
769 u16 interface_tag = interfacePriv->InterfaceTag;
770
771 unifi_trace(priv, UDBG1, "iwprivsstackstop\n" );
772
773 switch(interfacePriv->interfaceMode) {
774 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
775 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
776 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
777 r = sme_mgt_disconnect(priv);
778 break;
779 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
780 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
781 r = sme_ap_stop(priv, interface_tag);
782 break;
783 default :
784 break;
785 }
786
787 if(r) {
788 unifi_error(priv, "iwprivsstackstop Stack stop failed : %d\n", -r);
789 }
790 return 0;
791}
792#endif /* ANDROID_BUILD */
793#endif /* CSR_SUPPORT_WEXT_AP */
794
795#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
796static int
797iwprivsconfwapi(struct net_device *dev, struct iw_request_info *info,
798 union iwreq_data *wrqu, char *extra)
799{
800 u8 enable;
801 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
802 unifi_priv_t *priv = interfacePriv->privPtr;
803
804 unifi_trace(priv, UDBG1, "iwprivsconfwapi\n" );
805
806 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
807 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
808 unifi_error(priv, "iwprivsconfwapi: not permitted in Mode %d\n",
809 interfacePriv->interfaceMode);
810 return -EPERM;
811 }
812
813 enable = *(u8*)(extra);
814
815 if (enable) {
816 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
817 priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI);
818 priv->connection_config.encryptionModeMask |=
819 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4;
820 } else {
821 priv->connection_config.authModeMask &= ~(CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI);
822 priv->connection_config.encryptionModeMask &=
823 ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4);
824 }
825
826 return 0;
827}
828
829static int
830iwprivswpikey(struct net_device *dev, struct iw_request_info *info,
831 union iwreq_data *wrqu, char *extra)
832{
833 int r = 0, i;
834 CsrWifiSmeKey key;
835 unifiio_wapi_key_t inKey;
836 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
837 unifi_priv_t *priv = interfacePriv->privPtr;
838
839 unifi_trace(priv, UDBG1, "iwprivswpikey\n" );
840
841 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
842 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
843 unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n",
844 interfacePriv->interfaceMode);
845 return -EPERM;
846 }
847
848 inKey = *(unifiio_wapi_key_t*)(extra);
849
850 if (inKey.unicastKey) {
851 key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
852 } else {
853 key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
854 }
855
856 key.keyIndex = inKey.keyIndex;
857
858 /* memcpy(key.keyRsc, inKey.keyRsc, 16); */
859 for (i = 0; i < 16; i+= 2)
860 {
861 key.keyRsc[i/2] = inKey.keyRsc[i+1] << 8 | inKey.keyRsc[i];
862 }
863
864 memcpy(key.address.a, inKey.address, 6);
865 key.keyLength = 32;
866 memcpy(key.key, inKey.key, 32);
867 key.authenticator = 0;
868 key.wepTxKey = 0;
869
870 unifi_trace(priv, UDBG1, "keyType = %d, keyIndex = %d, wepTxKey = %d, keyRsc = %x:%x, auth = %d, address = %x:%x, "
871 "keylength = %d, key = %x:%x\n", key.keyType, key.keyIndex, key.wepTxKey,
872 key.keyRsc[0], key.keyRsc[7], key.authenticator,
873 key.address.a[0], key.address.a[5], key.keyLength, key.key[0],
874 key.key[15]);
875
876 r = sme_mgt_key(priv, &key, CSR_WIFI_SME_LIST_ACTION_ADD);
877 if (r) {
878 unifi_error(priv, "SETKEYS request was rejected with result %d\n", r);
879 return convert_sme_error(r);
880 }
881
882 return r;
883}
884#endif
885
886
887static int
888unifi_giwname(struct net_device *dev, struct iw_request_info *info,
889 union iwreq_data *wrqu, char *extra)
890{
891 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
892 unifi_priv_t *priv = interfacePriv->privPtr;
893 char *name = wrqu->name;
894 unifi_trace(priv, UDBG2, "unifi_giwname\n");
895
896 if (priv->if_index == CSR_INDEX_5G) {
897 strcpy(name, "IEEE 802.11-a");
898 } else {
899 strcpy(name, "IEEE 802.11-bgn");
900 }
901 return 0;
902} /* unifi_giwname() */
903
904
905static int
906unifi_siwfreq(struct net_device *dev, struct iw_request_info *info,
907 union iwreq_data *wrqu, char *extra)
908{
909 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
910 unifi_priv_t *priv = interfacePriv->privPtr;
911 struct iw_freq *freq = (struct iw_freq *)wrqu;
912
913 unifi_trace(priv, UDBG2, "unifi_siwfreq\n");
914
915 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
916 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
917 unifi_error(priv, "unifi_siwfreq: not permitted in Mode %d\n",
918 interfacePriv->interfaceMode);
919 return -EPERM;
920 }
921
922
923 /*
924 * Channel is stored in the connection configuration,
925 * and set later when ask for a connection.
926 */
927 if ((freq->e == 0) && (freq->m <= 1000)) {
928 priv->connection_config.adhocChannel = freq->m;
929 } else {
930 priv->connection_config.adhocChannel = wext_freq_to_channel(freq->m, freq->e);
931 }
932
933 return 0;
934} /* unifi_siwfreq() */
935
936
937static int
938unifi_giwfreq(struct net_device *dev, struct iw_request_info *info,
939 union iwreq_data *wrqu, char *extra)
940{
941 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
942 unifi_priv_t *priv = interfacePriv->privPtr;
943 struct iw_freq *freq = (struct iw_freq *)wrqu;
944 int err = 0;
945 CsrWifiSmeConnectionInfo connectionInfo;
946
947 unifi_trace(priv, UDBG2, "unifi_giwfreq\n");
948 CHECK_INITED(priv);
949
950 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
951 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
952 unifi_error(priv, "unifi_giwfreq: not permitted in Mode %d\n",
953 interfacePriv->interfaceMode);
954 return -EPERM;
955 }
956
957
958 UF_RTNL_UNLOCK();
959 err = sme_mgt_connection_info_get(priv, &connectionInfo);
960 UF_RTNL_LOCK();
961
962 freq->m = channel_to_mhz(connectionInfo.channelNumber,
963 (connectionInfo.networkType80211 == CSR_WIFI_SME_RADIO_IF_GHZ_5_0));
964 freq->e = 6;
965
966 return convert_sme_error(err);
967} /* unifi_giwfreq() */
968
969
970static int
971unifi_siwmode(struct net_device *dev, struct iw_request_info *info,
972 union iwreq_data *wrqu, char *extra)
973{
974 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
975 unifi_priv_t *priv = interfacePriv->privPtr;
976
977 unifi_trace(priv, UDBG2, "unifi_siwmode\n");
978
979 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
980 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
981 unifi_error(priv, "unifi_siwmode: not permitted in Mode %d\n",
982 interfacePriv->interfaceMode);
983 return -EPERM;
984 }
985
986
987 switch(wrqu->mode) {
988 case IW_MODE_ADHOC:
989 priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ADHOC;
990 break;
991 case IW_MODE_INFRA:
992 priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE;
993 break;
994 case IW_MODE_AUTO:
995 priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ANY_BSS;
996 break;
997 default:
998 unifi_notice(priv, "Unknown IW MODE value.\n");
999 }
1000
1001 /* Clear the SSID and BSSID configuration */
1002 priv->connection_config.ssid.length = 0;
1003 memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN);
1004
1005 return 0;
1006} /* unifi_siwmode() */
1007
1008
1009
1010static int
1011unifi_giwmode(struct net_device *dev, struct iw_request_info *info,
1012 union iwreq_data *wrqu, char *extra)
1013{
1014 int r = 0;
1015 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1016 unifi_priv_t *priv = interfacePriv->privPtr;
1017 CsrWifiSmeConnectionConfig connectionConfig;
1018
1019 unifi_trace(priv, UDBG2, "unifi_giwmode\n");
1020 CHECK_INITED(priv);
1021
1022 unifi_trace(priv, UDBG2, "unifi_giwmode: Exisitng mode = 0x%x\n",
1023 interfacePriv->interfaceMode);
1024 switch(interfacePriv->interfaceMode) {
1025 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1026 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1027 wrqu->mode = IW_MODE_INFRA;
1028 break;
1029 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1030 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1031 wrqu->mode = IW_MODE_MASTER;
1032 break;
1033 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1034 wrqu->mode = IW_MODE_ADHOC;
1035 break;
1036 case CSR_WIFI_ROUTER_CTRL_MODE_P2P:
1037 case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
1038 UF_RTNL_UNLOCK();
1039 r = sme_mgt_connection_config_get(priv, &connectionConfig);
1040 UF_RTNL_LOCK();
1041 if (r == 0) {
1042 switch(connectionConfig.bssType) {
1043 case CSR_WIFI_SME_BSS_TYPE_ADHOC:
1044 wrqu->mode = IW_MODE_ADHOC;
1045 break;
1046 case CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
1047 wrqu->mode = IW_MODE_INFRA;
1048 break;
1049 default:
1050 wrqu->mode = IW_MODE_AUTO;
1051 unifi_notice(priv, "Unknown IW MODE value.\n");
1052 }
1053 }
1054 break;
1055 default:
1056 wrqu->mode = IW_MODE_AUTO;
1057 unifi_notice(priv, "Unknown IW MODE value.\n");
1058
1059 }
1060 unifi_trace(priv, UDBG4, "unifi_giwmode: mode = 0x%x\n", wrqu->mode);
1061 return r;
1062} /* unifi_giwmode() */
1063
1064
1065
1066static int
1067unifi_giwrange(struct net_device *dev, struct iw_request_info *info,
1068 union iwreq_data *wrqu, char *extra)
1069{
1070 struct iw_point *dwrq = &wrqu->data;
1071 struct iw_range *range = (struct iw_range *) extra;
1072 int i;
1073
1074 unifi_trace(NULL, UDBG2, "unifi_giwrange\n");
1075
1076 dwrq->length = sizeof(struct iw_range);
1077 memset(range, 0, sizeof(*range));
1078 range->min_nwid = 0x0000;
1079 range->max_nwid = 0x0000;
1080
1081 /*
1082 * Don't report the frequency/channel table, then the channel
1083 * number returned elsewhere will be printed as a channel number.
1084 */
1085
1086 /* Ranges of values reported in quality structs */
1087 range->max_qual.qual = 40; /* Max expected qual value */
1088 range->max_qual.level = -120; /* Noise floor in dBm */
1089 range->max_qual.noise = -120; /* Noise floor in dBm */
1090
1091
1092 /* space for IW_MAX_BITRATES (8 up to WE15, 32 later) */
1093 i = 0;
1094#if WIRELESS_EXT > 15
1095 range->bitrate[i++] = 2 * 500000;
1096 range->bitrate[i++] = 4 * 500000;
1097 range->bitrate[i++] = 11 * 500000;
1098 range->bitrate[i++] = 22 * 500000;
1099 range->bitrate[i++] = 12 * 500000;
1100 range->bitrate[i++] = 18 * 500000;
1101 range->bitrate[i++] = 24 * 500000;
1102 range->bitrate[i++] = 36 * 500000;
1103 range->bitrate[i++] = 48 * 500000;
1104 range->bitrate[i++] = 72 * 500000;
1105 range->bitrate[i++] = 96 * 500000;
1106 range->bitrate[i++] = 108 * 500000;
1107#else
1108 range->bitrate[i++] = 2 * 500000;
1109 range->bitrate[i++] = 4 * 500000;
1110 range->bitrate[i++] = 11 * 500000;
1111 range->bitrate[i++] = 22 * 500000;
1112 range->bitrate[i++] = 24 * 500000;
1113 range->bitrate[i++] = 48 * 500000;
1114 range->bitrate[i++] = 96 * 500000;
1115 range->bitrate[i++] = 108 * 500000;
1116#endif /* WIRELESS_EXT < 16 */
1117 range->num_bitrates = i;
1118
1119 range->max_encoding_tokens = NUM_WEPKEYS;
1120 range->num_encoding_sizes = 2;
1121 range->encoding_size[0] = 5;
1122 range->encoding_size[1] = 13;
1123
1124 range->we_version_source = 20;
1125 range->we_version_compiled = WIRELESS_EXT;
1126
1127 /* Number of channels available in h/w */
1128 range->num_channels = 14;
1129 /* Number of entries in freq[] array */
1130 range->num_frequency = 14;
1131 for (i = 0; (i < range->num_frequency) && (i < IW_MAX_FREQUENCIES); i++) {
1132 int chan = i + 1;
1133 range->freq[i].i = chan;
1134 range->freq[i].m = channel_to_mhz(chan, 0);
1135 range->freq[i].e = 6;
1136 }
1137 if ((i+3) < IW_MAX_FREQUENCIES) {
1138 range->freq[i].i = 36;
1139 range->freq[i].m = channel_to_mhz(36, 1);
1140 range->freq[i].e = 6;
1141 range->freq[i+1].i = 40;
1142 range->freq[i+1].m = channel_to_mhz(40, 1);
1143 range->freq[i+1].e = 6;
1144 range->freq[i+2].i = 44;
1145 range->freq[i+2].m = channel_to_mhz(44, 1);
1146 range->freq[i+2].e = 6;
1147 range->freq[i+3].i = 48;
1148 range->freq[i+3].m = channel_to_mhz(48, 1);
1149 range->freq[i+3].e = 6;
1150 }
1151
1152#if WIRELESS_EXT > 16
1153 /* Event capability (kernel + driver) */
1154 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
1155 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
1156 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
1157 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
1158 range->event_capa[1] = IW_EVENT_CAPA_K_1;
1159 range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
1160 IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
1161 IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
1162 IW_EVENT_CAPA_MASK(IWEVEXPIRED));
1163#endif /* WIRELESS_EXT > 16 */
1164
1165#if WIRELESS_EXT > 17
1166 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
1167 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
1168#endif /* WIRELESS_EXT > 17 */
1169
1170
1171 return 0;
1172} /* unifi_giwrange() */
1173
1174
1175static int
1176unifi_siwap(struct net_device *dev, struct iw_request_info *info,
1177 union iwreq_data *wrqu, char *extra)
1178{
1179 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1180 unifi_priv_t *priv = interfacePriv->privPtr;
1181 int err = 0;
1182
1183 CHECK_INITED(priv);
1184
1185 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1186 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1187 unifi_error(priv, "unifi_siwap: not permitted in Mode %d\n",
1188 interfacePriv->interfaceMode);
1189 return -EPERM;
1190 }
1191
1192
1193 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) {
1194 return -EINVAL;
1195 }
1196
1197 unifi_trace(priv, UDBG1, "unifi_siwap: asked for %pM\n",
1198 wrqu->ap_addr.sa_data);
1199
1200 if (is_zero_ether_addr(wrqu->ap_addr.sa_data)) {
1201 priv->ignore_bssid_join = FALSE;
1202 err = sme_mgt_disconnect(priv);
1203 if (err) {
1204 unifi_trace(priv, UDBG4, "unifi_siwap: Disconnect failed, status %d\n", err);
1205 }
1206 return 0;
1207 }
1208
1209 if (priv->ignore_bssid_join) {
1210 unifi_trace(priv, UDBG4, "unifi_siwap: ignoring second join\n");
1211 priv->ignore_bssid_join = FALSE;
1212 } else {
1213 memcpy(priv->connection_config.bssid.a, wrqu->ap_addr.sa_data, ETH_ALEN);
1214 unifi_trace(priv, UDBG1, "unifi_siwap: Joining %X:%X:%X:%X:%X:%X\n",
1215 priv->connection_config.bssid.a[0],
1216 priv->connection_config.bssid.a[1],
1217 priv->connection_config.bssid.a[2],
1218 priv->connection_config.bssid.a[3],
1219 priv->connection_config.bssid.a[4],
1220 priv->connection_config.bssid.a[5]);
1221 err = sme_mgt_connect(priv);
1222 if (err) {
1223 unifi_error(priv, "unifi_siwap: Join failed, status %d\n", err);
1224 return convert_sme_error(err);
1225 }
1226 }
1227
1228 return 0;
1229} /* unifi_siwap() */
1230
1231
1232static int
1233unifi_giwap(struct net_device *dev, struct iw_request_info *info,
1234 union iwreq_data *wrqu, char *extra)
1235{
1236 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1237 unifi_priv_t *priv = interfacePriv->privPtr;
1238 CsrWifiSmeConnectionInfo connectionInfo;
1239 int r = 0;
1240 u8 *bssid;
1241
1242 CHECK_INITED(priv);
1243 unifi_trace(priv, UDBG2, "unifi_giwap\n");
1244
1245 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1246 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1247 unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n",
1248 interfacePriv->interfaceMode);
1249 return -EPERM;
1250 }
1251
1252 UF_RTNL_UNLOCK();
1253 r = sme_mgt_connection_info_get(priv, &connectionInfo);
1254 UF_RTNL_LOCK();
1255
1256 if (r == 0) {
1257 bssid = connectionInfo.bssid.a;
1258 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
1259 unifi_trace(priv, UDBG4, "unifi_giwap: BSSID = %pM\n", bssid);
1260
1261 memcpy(wrqu->ap_addr.sa_data, bssid, ETH_ALEN);
1262 } else {
1263 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
1264 }
1265
1266 return 0;
1267} /* unifi_giwap() */
1268
1269
1270static int
1271unifi_siwscan(struct net_device *dev, struct iw_request_info *info,
1272 union iwreq_data *wrqu, char *extra)
1273{
1274 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1275 unifi_priv_t *priv = interfacePriv->privPtr;
1276 int r;
1277 CsrWifiSsid scan_ssid;
1278 unsigned char *channel_list = NULL;
1279 int chans_good = 0;
1280#if WIRELESS_EXT > 17
1281 struct iw_point *data = &wrqu->data;
1282 struct iw_scan_req *req = (struct iw_scan_req *) extra;
1283#endif
1284
1285 CHECK_INITED(priv);
1286
1287 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1288 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1289 unifi_error(priv, "unifi_siwscan: not permitted in Mode %d\n",
1290 interfacePriv->interfaceMode);
1291 return -EPERM;
1292 }
1293
1294
1295#if WIRELESS_EXT > 17
1296 /* Providing a valid channel list will force an active scan */
1297 if (req) {
1298 if ((req->num_channels > 0) && (req->num_channels < IW_MAX_FREQUENCIES)) {
1299 channel_list = kmalloc(req->num_channels, GFP_KERNEL);
1300 if (channel_list) {
1301 int i;
1302 for (i = 0; i < req->num_channels; i++) {
1303 /* Convert frequency to channel number */
1304 int ch = wext_freq_to_channel(req->channel_list[i].m,
1305 req->channel_list[i].e);
1306 if (ch) {
1307 channel_list[chans_good++] = ch;
1308 }
1309 }
1310 unifi_trace(priv, UDBG1,
1311 "SIWSCAN: Scanning %d channels\n", chans_good);
1312 } else {
1313 /* Fall back to scanning all */
1314 unifi_error(priv, "SIWSCAN: Can't alloc channel_list (%d)\n",
1315 req->num_channels);
1316 }
1317 }
1318 }
1319
1320 if (req && (data->flags & IW_SCAN_THIS_ESSID)) {
1321 memcpy(scan_ssid.ssid, req->essid, req->essid_len);
1322 scan_ssid.length = req->essid_len;
1323 unifi_trace(priv, UDBG1,
1324 "SIWSCAN: Scanning for %.*s\n",
1325 scan_ssid.length, scan_ssid.ssid);
1326 } else
1327#endif
1328 {
1329 unifi_trace(priv, UDBG1, "SIWSCAN: Scanning for all APs\n");
1330 scan_ssid.length = 0;
1331 }
1332
1333 r = sme_mgt_scan_full(priv, &scan_ssid, chans_good, channel_list);
1334 if (r) {
1335 unifi_error(priv, "SIWSCAN: Scan returned error %d\n", r);
1336 } else {
1337 unifi_trace(priv, UDBG1, "SIWSCAN: Scan done\n");
1338 wext_send_scan_results_event(priv);
1339 }
1340
1341 if (channel_list) {
1342 kfree(channel_list);
1343 }
1344
1345 return r;
1346
1347} /* unifi_siwscan() */
1348
1349
1350static const unsigned char *
1351unifi_find_info_element(int id, const unsigned char *info, int len)
1352{
1353 const unsigned char *ie = info;
1354
1355 while (len > 1)
1356 {
1357 int e_id, e_len;
1358 e_id = ie[0];
1359 e_len = ie[1];
1360
1361 /* Return if we find a match */
1362 if (e_id == id)
1363 {
1364 return ie;
1365 }
1366
1367 len -= (e_len + 2);
1368 ie += (e_len + 2);
1369 }
1370
1371 return NULL;
1372} /* unifi_find_info_element() */
1373
1374
1375/*
1376 * Translate scan data returned from the card to a card independent
1377 * format that the Wireless Tools will understand - Jean II
1378 */
1379int
1380unifi_translate_scan(struct net_device *dev,
1381 struct iw_request_info *info,
1382 char *current_ev, char *end_buf,
1383 CsrWifiSmeScanResult *scan_data,
1384 int scan_index)
1385{
1386 struct iw_event iwe; /* Temporary buffer */
1387 unsigned char *info_elems;
1388 int info_elem_len;
1389 const unsigned char *elem;
1390 u16 capabilities;
1391 int signal, noise, snr;
1392 char *start_buf = current_ev;
1393 char *current_val; /* For rates */
1394 int i, r;
1395
1396 info_elems = scan_data->informationElements;
1397 info_elem_len = scan_data->informationElementsLength;
1398
1399 if (!scan_data->informationElementsLength || !scan_data->informationElements) {
1400 unifi_error(NULL, "*** NULL SCAN IEs ***\n");
1401 return -EIO;
1402 }
1403
1404 /* get capinfo bits */
1405 capabilities = scan_data->capabilityInformation;
1406
1407 unifi_trace(NULL, UDBG5, "Capabilities: 0x%x\n", capabilities);
1408
1409 /* First entry *MUST* be the AP MAC address */
1410 memset(&iwe, 0, sizeof(iwe));
1411 iwe.cmd = SIOCGIWAP;
1412 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1413 memcpy(iwe.u.ap_addr.sa_data, scan_data->bssid.a, ETH_ALEN);
1414 iwe.len = IW_EV_ADDR_LEN;
1415 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_ADDR_LEN);
1416 if (r < 0) {
1417 return r;
1418 }
1419 start_buf += r;
1420
1421 /* Other entries will be displayed in the order we give them */
1422
1423 /* Add the ESSID */
1424 /* find SSID in Info Elems */
1425 elem = unifi_find_info_element(IE_SSID_ID, info_elems, info_elem_len);
1426 if (elem) {
1427 int e_len = elem[1];
1428 const unsigned char *e_ptr = elem + 2;
1429 unsigned char buf[33];
1430
1431 memset(&iwe, 0, sizeof(iwe));
1432 iwe.cmd = SIOCGIWESSID;
1433 iwe.u.essid.length = e_len;
1434 if (iwe.u.essid.length > 32) {
1435 iwe.u.essid.length = 32;
1436 }
1437 iwe.u.essid.flags = scan_index;
1438 memcpy(buf, e_ptr, iwe.u.essid.length);
1439 buf[iwe.u.essid.length] = '\0';
1440 r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, buf);
1441 if (r < 0) {
1442 return r;
1443 }
1444 start_buf += r;
1445
1446 }
1447
1448 /* Add mode */
1449 memset(&iwe, 0, sizeof(iwe));
1450 iwe.cmd = SIOCGIWMODE;
1451 if (scan_data->bssType == CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE) {
1452 iwe.u.mode = IW_MODE_INFRA;
1453 } else {
1454 iwe.u.mode = IW_MODE_ADHOC;
1455 }
1456 iwe.len = IW_EV_UINT_LEN;
1457 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_UINT_LEN);
1458 if (r < 0) {
1459 return r;
1460 }
1461 start_buf += r;
1462
1463 /* Add frequency. iwlist will convert to channel using table given in giwrange */
1464 memset(&iwe, 0, sizeof(iwe));
1465 iwe.cmd = SIOCGIWFREQ;
1466 iwe.u.freq.m = scan_data->channelFrequency;
1467 iwe.u.freq.e = 6;
1468 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_FREQ_LEN);
1469 if (r < 0) {
1470 return r;
1471 }
1472 start_buf += r;
1473
1474
1475 /* Add quality statistics */
1476 iwe.cmd = IWEVQUAL;
1477 /*
1478 * level and noise below are mapped into an unsigned 8 bit number,
1479 * ranging from [-192; 63]. The way this is achieved is simply to
1480 * add 0x100 onto the number if it is negative,
1481 * once clipped to the correct range.
1482 */
1483 signal = scan_data->rssi; /* This value is in dBm */
1484 /* Clip range of snr */
1485 snr = (scan_data->snr > 0) ? scan_data->snr : 0; /* In dB relative, from 0 - 255 */
1486 snr = (snr < 255) ? snr : 255;
1487 noise = signal - snr;
1488
1489 /* Clip range of signal */
1490 signal = (signal < 63) ? signal : 63;
1491 signal = (signal > -192) ? signal : -192;
1492
1493 /* Clip range of noise */
1494 noise = (noise < 63) ? noise : 63;
1495 noise = (noise > -192) ? noise : -192;
1496
1497 /* Make u8 */
1498 signal = ( signal < 0 ) ? signal + 0x100 : signal;
1499 noise = ( noise < 0 ) ? noise + 0x100 : noise;
1500
1501 iwe.u.qual.level = (u8)signal; /* -192 : 63 */
1502 iwe.u.qual.noise = (u8)noise; /* -192 : 63 */
1503 iwe.u.qual.qual = snr; /* 0 : 255 */
1504 iwe.u.qual.updated = 0;
1505#if WIRELESS_EXT > 16
1506 iwe.u.qual.updated |= IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED |
1507 IW_QUAL_QUAL_UPDATED;
1508#if WIRELESS_EXT > 18
1509 iwe.u.qual.updated |= IW_QUAL_DBM;
1510#endif
1511#endif
1512 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_QUAL_LEN);
1513 if (r < 0) {
1514 return r;
1515 }
1516 start_buf += r;
1517
1518 /* Add encryption capability */
1519 iwe.cmd = SIOCGIWENCODE;
1520 if (capabilities & SIG_CAP_PRIVACY) {
1521 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1522 } else {
1523 iwe.u.data.flags = IW_ENCODE_DISABLED;
1524 }
1525 iwe.u.data.length = 0;
1526 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1527 r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, "");
1528 if (r < 0) {
1529 return r;
1530 }
1531 start_buf += r;
1532
1533
1534 /*
1535 * Rate : stuffing multiple values in a single event require a bit
1536 * more of magic - Jean II
1537 */
1538 current_val = start_buf + IW_EV_LCP_LEN;
1539
1540 iwe.cmd = SIOCGIWRATE;
1541 /* Those two flags are ignored... */
1542 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
1543
1544 elem = unifi_find_info_element(IE_SUPPORTED_RATES_ID,
1545 info_elems, info_elem_len);
1546 if (elem) {
1547 int e_len = elem[1];
1548 const unsigned char *e_ptr = elem + 2;
1549
1550 /*
1551 * Count how many rates we have.
1552 * Zero marks the end of the list, if the list is not truncated.
1553 */
1554 /* Max 8 values */
1555 for (i = 0; i < e_len; i++) {
1556 if (e_ptr[i] == 0) {
1557 break;
1558 }
1559 /* Bit rate given in 500 kb/s units (+ 0x80) */
1560 iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000);
1561 /* Add new value to event */
1562 r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
1563 if (r < 0) {
1564 return r;
1565 }
1566 current_val +=r;
1567
1568 }
1569 }
1570 elem = unifi_find_info_element(IE_EXTENDED_SUPPORTED_RATES_ID,
1571 info_elems, info_elem_len);
1572 if (elem) {
1573 int e_len = elem[1];
1574 const unsigned char *e_ptr = elem + 2;
1575
1576 /*
1577 * Count how many rates we have.
1578 * Zero marks the end of the list, if the list is not truncated.
1579 */
1580 /* Max 8 values */
1581 for (i = 0; i < e_len; i++) {
1582 if (e_ptr[i] == 0) {
1583 break;
1584 }
1585 /* Bit rate given in 500 kb/s units (+ 0x80) */
1586 iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000);
1587 /* Add new value to event */
1588 r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
1589 if (r < 0) {
1590 return r;
1591 }
1592 current_val +=r;
1593 }
1594 }
1595 /* Check if we added any rates event */
1596 if ((current_val - start_buf) > IW_EV_LCP_LEN) {
1597 start_buf = current_val;
1598 }
1599
1600
1601#if WIRELESS_EXT > 17
1602 memset(&iwe, 0, sizeof(iwe));
1603 iwe.cmd = IWEVGENIE;
1604 iwe.u.data.length = info_elem_len;
1605
1606 r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, info_elems);
1607 if (r < 0) {
1608 return r;
1609 }
1610
1611 start_buf += r;
1612#endif /* WE > 17 */
1613
1614 return (start_buf - current_ev);
1615} /* unifi_translate_scan() */
1616
1617
1618
1619static int
1620unifi_giwscan(struct net_device *dev, struct iw_request_info *info,
1621 union iwreq_data *wrqu, char *extra)
1622{
1623 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1624 unifi_priv_t *priv = interfacePriv->privPtr;
1625 struct iw_point *dwrq = &wrqu->data;
1626 int r;
1627
1628 CHECK_INITED(priv);
1629
1630 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1631 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1632 unifi_error(priv, "unifi_giwscan: not permitted in Mode %d\n",
1633 interfacePriv->interfaceMode);
1634 return -EPERM;
1635 }
1636
1637
1638 unifi_trace(priv, UDBG1,
1639 "unifi_giwscan: buffer (%d bytes) \n",
1640 dwrq->length);
1641 UF_RTNL_UNLOCK();
1642 r = sme_mgt_scan_results_get_async(priv, info, extra, dwrq->length);
1643 UF_RTNL_LOCK();
1644 if (r < 0) {
1645 unifi_trace(priv, UDBG1,
1646 "unifi_giwscan: buffer (%d bytes) not big enough.\n",
1647 dwrq->length);
1648 return r;
1649 }
1650
1651 dwrq->length = r;
1652 dwrq->flags = 0;
1653
1654 return 0;
1655} /* unifi_giwscan() */
1656
1657
1658/*
1659 * ---------------------------------------------------------------------------
1660 * unifi_siwessid
1661 *
1662 * Request to join a network or start and AdHoc.
1663 *
1664 * Arguments:
1665 * dev Pointer to network device struct.
1666 * info Pointer to broken-out ioctl request.
1667 * data Pointer to argument data.
1668 * essid Pointer to string giving name of network to join
1669 * or start
1670 *
1671 * Returns:
1672 * 0 on success and everything complete
1673 * -EINPROGRESS to have the higher level call the commit method.
1674 * ---------------------------------------------------------------------------
1675 */
1676static int
1677unifi_siwessid(struct net_device *dev, struct iw_request_info *info,
1678 struct iw_point *data, char *essid)
1679{
1680 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1681 unifi_priv_t *priv = interfacePriv->privPtr;
1682 int len;
1683 int err = 0;
1684
1685 CHECK_INITED(priv);
1686
1687 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1688 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1689 unifi_error(priv, "unifi_siwessid: not permitted in Mode %d\n",
1690 interfacePriv->interfaceMode);
1691 return -EPERM;
1692 }
1693
1694
1695 len = 0;
1696 if (data->flags & 1) {
1697 /* Limit length */
1698 len = data->length;
1699 if (len > UNIFI_MAX_SSID_LEN) {
1700 len = UNIFI_MAX_SSID_LEN;
1701 }
1702 }
1703
1704#ifdef UNIFI_DEBUG
1705 {
1706 char essid_str[UNIFI_MAX_SSID_LEN+1];
1707 int i;
1708
1709 for (i = 0; i < len; i++) {
1710 essid_str[i] = (isprint(essid[i]) ? essid[i] : '?');
1711 }
1712 essid_str[i] = '\0';
1713
1714 unifi_trace(priv, UDBG1, "unifi_siwessid: asked for '%*s' (%d)\n", len, essid_str, len);
1715 unifi_trace(priv, UDBG2, " with authModeMask = %d", priv->connection_config.authModeMask);
1716 }
1717#endif
1718
1719 memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN);
1720 if (len) {
1721 if (essid[len - 1] == 0) {
1722 len --;
1723 }
1724
1725 memcpy(priv->connection_config.ssid.ssid, essid, len);
1726 priv->connection_config.ssid.length = len;
1727
1728 } else {
1729 priv->connection_config.ssid.length = 0;
1730 }
1731
1732 UF_RTNL_UNLOCK();
1733 err = sme_mgt_connect(priv);
1734 UF_RTNL_LOCK();
1735 if (err) {
1736 unifi_error(priv, "unifi_siwessid: Join failed, status %d\n", err);
1737 return convert_sme_error(err);
1738 }
1739
1740 return 0;
1741} /* unifi_siwessid() */
1742
1743
1744static int
1745unifi_giwessid(struct net_device *dev, struct iw_request_info *info,
1746 union iwreq_data *wrqu, char *essid)
1747{
1748 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1749 unifi_priv_t *priv = interfacePriv->privPtr;
1750 struct iw_point *data = &wrqu->essid;
1751 CsrWifiSmeConnectionInfo connectionInfo;
1752 int r = 0;
1753
1754 unifi_trace(priv, UDBG2, "unifi_giwessid\n");
1755 CHECK_INITED(priv);
1756
1757 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
1758 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
1759 unifi_error(priv, "unifi_giwessid: not permitted in Mode %d\n",
1760 interfacePriv->interfaceMode);
1761 return -EPERM;
1762 }
1763
1764 UF_RTNL_UNLOCK();
1765 r = sme_mgt_connection_info_get(priv, &connectionInfo);
1766 UF_RTNL_LOCK();
1767
1768 if (r == 0) {
1769 data->length = connectionInfo.ssid.length;
1770 strncpy(essid,
1771 connectionInfo.ssid.ssid,
1772 data->length);
1773 data->flags = 1; /* active */
1774
1775 unifi_trace(priv, UDBG2, "unifi_giwessid: %.*s\n",
1776 data->length, essid);
1777 }
1778
1779
1780 return 0;
1781} /* unifi_giwessid() */
1782
1783
1784static int
1785unifi_siwrate(struct net_device *dev, struct iw_request_info *info,
1786 union iwreq_data *wrqu, char *extra)
1787{
1788 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1789 unifi_priv_t *priv = interfacePriv->privPtr;
1790 struct iw_param *args = &wrqu->bitrate;
1791 CsrWifiSmeMibConfig mibConfig;
1792 int r;
1793
1794 CHECK_INITED(priv);
1795 unifi_trace(priv, UDBG2, "unifi_siwrate\n");
1796
1797 /*
1798 * If args->fixed == 0, value is max rate or -1 for best
1799 * If args->fixed == 1, value is rate to set or -1 for best
1800 * args->disabled and args->flags are not used in SIOCSIWRATE
1801 */
1802
1803 /* Get, modify and set the MIB data */
1804 UF_RTNL_UNLOCK();
1805 r = sme_mgt_mib_config_get(priv, &mibConfig);
1806 UF_RTNL_LOCK();
1807 if (r) {
1808 unifi_error(priv, "unifi_siwrate: Get CsrWifiSmeMibConfigValue failed.\n");
1809 return r;
1810 }
1811
1812 /* Default to auto rate algorithm */
1813 /* in 500Kbit/s, 0 means auto */
1814 mibConfig.unifiFixTxDataRate = 0;
1815
1816 if (args->value != -1) {
1817 mibConfig.unifiFixTxDataRate = args->value / 500000;
1818 }
1819
1820 /* 1 means rate is a maximum, 2 means rate is a set value */
1821 if (args->fixed == 1) {
1822 mibConfig.unifiFixMaxTxDataRate = 0;
1823 } else {
1824 mibConfig.unifiFixMaxTxDataRate = 1;
1825 }
1826 UF_RTNL_UNLOCK();
1827 r = sme_mgt_mib_config_set(priv, &mibConfig);
1828 UF_RTNL_LOCK();
1829 if (r) {
1830 unifi_error(priv, "unifi_siwrate: Set CsrWifiSmeMibConfigValue failed.\n");
1831 return r;
1832 }
1833
1834
1835 return 0;
1836} /* unifi_siwrate() */
1837
1838
1839
1840static int
1841unifi_giwrate(struct net_device *dev, struct iw_request_info *info,
1842 union iwreq_data *wrqu, char *extra)
1843{
1844 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1845 unifi_priv_t *priv = interfacePriv->privPtr;
1846 struct iw_param *args = &wrqu->bitrate;
1847 int r;
1848 int bitrate, flag;
1849 CsrWifiSmeMibConfig mibConfig;
1850 CsrWifiSmeConnectionStats connectionStats;
1851
1852 unifi_trace(priv, UDBG2, "unifi_giwrate\n");
1853 CHECK_INITED(priv);
1854
1855 flag = 0;
1856 bitrate = 0;
1857 UF_RTNL_UNLOCK();
1858 r = sme_mgt_mib_config_get(priv, &mibConfig);
1859 UF_RTNL_LOCK();
1860 if (r) {
1861 unifi_error(priv, "unifi_giwrate: Get CsrWifiSmeMibConfigValue failed.\n");
1862 return r;
1863 }
1864
1865 bitrate = mibConfig.unifiFixTxDataRate;
1866 flag = mibConfig.unifiFixMaxTxDataRate;
1867
1868 /* Used the value returned by the SME if MIB returns 0 */
1869 if (bitrate == 0) {
1870 UF_RTNL_UNLOCK();
1871 r = sme_mgt_connection_stats_get(priv, &connectionStats);
1872 UF_RTNL_LOCK();
1873 /* Ignore errors, we may be disconnected */
1874 if (r == 0) {
1875 bitrate = connectionStats.unifiTxDataRate;
1876 }
1877 }
1878
1879 args->value = bitrate * 500000;
1880 args->fixed = !flag;
1881
1882 return 0;
1883} /* unifi_giwrate() */
1884
1885
1886static int
1887unifi_siwrts(struct net_device *dev, struct iw_request_info *info,
1888 union iwreq_data *wrqu, char *extra)
1889{
1890 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1891 unifi_priv_t *priv = interfacePriv->privPtr;
1892 int val = wrqu->rts.value;
1893 int r = 0;
1894 CsrWifiSmeMibConfig mibConfig;
1895
1896 unifi_trace(priv, UDBG2, "unifi_siwrts\n");
1897 CHECK_INITED(priv);
1898
1899 if (wrqu->rts.disabled) {
1900 val = 2347;
1901 }
1902
1903 if ( (val < 0) || (val > 2347) )
1904 {
1905 return -EINVAL;
1906 }
1907
1908 /* Get, modify and set the MIB data */
1909 UF_RTNL_UNLOCK();
1910 r = sme_mgt_mib_config_get(priv, &mibConfig);
1911 UF_RTNL_LOCK();
1912 if (r) {
1913 unifi_error(priv, "unifi_siwrts: Get CsrWifiSmeMibConfigValue failed.\n");
1914 return r;
1915 }
1916 mibConfig.dot11RtsThreshold = val;
1917 UF_RTNL_UNLOCK();
1918 r = sme_mgt_mib_config_set(priv, &mibConfig);
1919 UF_RTNL_LOCK();
1920 if (r) {
1921 unifi_error(priv, "unifi_siwrts: Set CsrWifiSmeMibConfigValue failed.\n");
1922 return r;
1923 }
1924
1925 return 0;
1926}
1927
1928
1929static int
1930unifi_giwrts(struct net_device *dev, struct iw_request_info *info,
1931 union iwreq_data *wrqu, char *extra)
1932{
1933 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1934 unifi_priv_t *priv = interfacePriv->privPtr;
1935 int r;
1936 int rts_thresh;
1937 CsrWifiSmeMibConfig mibConfig;
1938
1939 unifi_trace(priv, UDBG2, "unifi_giwrts\n");
1940 CHECK_INITED(priv);
1941
1942 UF_RTNL_UNLOCK();
1943 r = sme_mgt_mib_config_get(priv, &mibConfig);
1944 UF_RTNL_LOCK();
1945 if (r) {
1946 unifi_error(priv, "unifi_giwrts: Get CsrWifiSmeMibConfigValue failed.\n");
1947 return r;
1948 }
1949
1950 rts_thresh = mibConfig.dot11RtsThreshold;
1951 if (rts_thresh > 2347) {
1952 rts_thresh = 2347;
1953 }
1954
1955 wrqu->rts.value = rts_thresh;
1956 wrqu->rts.disabled = (rts_thresh == 2347);
1957 wrqu->rts.fixed = 1;
1958
1959 return 0;
1960}
1961
1962
1963static int
1964unifi_siwfrag(struct net_device *dev, struct iw_request_info *info,
1965 union iwreq_data *wrqu, char *extra)
1966{
1967 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
1968 unifi_priv_t *priv = interfacePriv->privPtr;
1969 int val = wrqu->frag.value;
1970 int r = 0;
1971 CsrWifiSmeMibConfig mibConfig;
1972
1973 unifi_trace(priv, UDBG2, "unifi_siwfrag\n");
1974 CHECK_INITED(priv);
1975
1976 if (wrqu->frag.disabled)
1977 val = 2346;
1978
1979 if ( (val < 256) || (val > 2347) )
1980 return -EINVAL;
1981
1982 /* Get, modify and set the MIB data */
1983 UF_RTNL_UNLOCK();
1984 r = sme_mgt_mib_config_get(priv, &mibConfig);
1985 UF_RTNL_LOCK();
1986 if (r) {
1987 unifi_error(priv, "unifi_siwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
1988 return r;
1989 }
1990 /* Fragmentation Threashold must be even */
1991 mibConfig.dot11FragmentationThreshold = (val & ~0x1);
1992 UF_RTNL_UNLOCK();
1993 r = sme_mgt_mib_config_set(priv, &mibConfig);
1994 UF_RTNL_LOCK();
1995 if (r) {
1996 unifi_error(priv, "unifi_siwfrag: Set CsrWifiSmeMibConfigValue failed.\n");
1997 return r;
1998 }
1999
2000 return 0;
2001}
2002
2003
2004static int
2005unifi_giwfrag(struct net_device *dev, struct iw_request_info *info,
2006 union iwreq_data *wrqu, char *extra)
2007{
2008 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2009 unifi_priv_t *priv = interfacePriv->privPtr;
2010 int r;
2011 int frag_thresh;
2012 CsrWifiSmeMibConfig mibConfig;
2013
2014 unifi_trace(priv, UDBG2, "unifi_giwfrag\n");
2015 CHECK_INITED(priv);
2016
2017 UF_RTNL_UNLOCK();
2018 r = sme_mgt_mib_config_get(priv, &mibConfig);
2019 UF_RTNL_LOCK();
2020 if (r) {
2021 unifi_error(priv, "unifi_giwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
2022 return r;
2023 }
2024
2025 frag_thresh = mibConfig.dot11FragmentationThreshold;
2026
2027 /* Build the return structure */
2028 wrqu->frag.value = frag_thresh;
2029 wrqu->frag.disabled = (frag_thresh >= 2346);
2030 wrqu->frag.fixed = 1;
2031
2032 return 0;
2033}
2034
2035
2036static int
2037unifi_siwencode(struct net_device *dev, struct iw_request_info *info,
2038 union iwreq_data *wrqu, char *extra)
2039{
2040 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2041 unifi_priv_t *priv = interfacePriv->privPtr;
2042 struct iw_point *erq = &wrqu->encoding;
2043 int index;
2044 int rc = 0;
2045 int privacy = -1;
2046 CsrWifiSmeKey sme_key;
2047
2048 unifi_trace(priv, UDBG2, "unifi_siwencode\n");
2049
2050 CHECK_INITED(priv);
2051
2052 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2053 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2054 unifi_error(priv, "unifi_siwencode: not permitted in Mode %d\n",
2055 interfacePriv->interfaceMode);
2056 return -EPERM;
2057 }
2058
2059
2060 /*
2061 * Key index is encoded in the flags.
2062 * 0 - use current default,
2063 * 1-4 - if a key value is given set that key
2064 * if not use that key
2065 */
2066 index = (erq->flags & IW_ENCODE_INDEX); /* key number, 1-4 */
2067 if ((index < 0) || (index > 4)) {
2068 unifi_error(priv, "unifi_siwencode: Request to set an invalid key (index:%d)", index);
2069 return -EINVAL;
2070 }
2071
2072 /*
2073 * Basic checking: do we have a key to set ?
2074 * The IW_ENCODE_NOKEY flag is set when no key is present (only change flags),
2075 * but older versions rely on sending a key id 1-4.
2076 */
2077 if (erq->length > 0) {
2078
2079 /* Check the size of the key */
2080 if ((erq->length > LARGE_KEY_SIZE) || (erq->length < SMALL_KEY_SIZE)) {
2081 unifi_error(priv, "unifi_siwencode: Request to set an invalid key (length:%d)",
2082 erq->length);
2083 return -EINVAL;
2084 }
2085
2086 /* Check the index (none (i.e. 0) means use current) */
2087 if ((index < 1) || (index > 4)) {
2088 /* If we do not have a previous key, use 1 as default */
2089 if (!priv->wep_tx_key_index) {
2090 priv->wep_tx_key_index = 1;
2091 }
2092 index = priv->wep_tx_key_index;
2093 }
2094
2095 /* If we didn't have a key and a valid index is set, we want to remember it*/
2096 if (!priv->wep_tx_key_index) {
2097 priv->wep_tx_key_index = index;
2098 }
2099
2100 unifi_trace(priv, UDBG1, "Tx key Index is %d\n", priv->wep_tx_key_index);
2101
2102 privacy = 1;
2103
2104 /* Check if the key is not marked as invalid */
2105 if ((erq->flags & IW_ENCODE_NOKEY) == 0) {
2106
2107 unifi_trace(priv, UDBG1, "New %s key (len=%d, index=%d)\n",
2108 (priv->wep_tx_key_index == index) ? "tx" : "",
2109 erq->length, index);
2110
2111 sme_key.wepTxKey = (priv->wep_tx_key_index == index);
2112 if (priv->wep_tx_key_index == index) {
2113 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
2114 } else {
2115 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
2116 }
2117 /* Key index is zero based in SME but 1 based in wext */
2118 sme_key.keyIndex = (index - 1);
2119 sme_key.keyLength = erq->length;
2120 sme_key.authenticator = 0;
2121 memset(sme_key.address.a, 0xFF, ETH_ALEN);
2122 memcpy(sme_key.key, extra, erq->length);
2123
2124 UF_RTNL_UNLOCK();
2125 rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
2126 UF_RTNL_LOCK();
2127 if (rc) {
2128 unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc);
2129 return convert_sme_error(rc);
2130 }
2131
2132 /* Store the key to be reported by the SIOCGIWENCODE handler */
2133 priv->wep_keys[index - 1].len = erq->length;
2134 memcpy(priv->wep_keys[index - 1].key, extra, erq->length);
2135 }
2136 } else {
2137 /*
2138 * No additional key data, so it must be a request to change the
2139 * active key.
2140 */
2141 if (index != 0) {
2142 unifi_trace(priv, UDBG1, "Tx key Index is %d\n", index - 1);
2143
2144 /* Store the index to be reported by the SIOCGIWENCODE handler */
2145 priv->wep_tx_key_index = index;
2146
2147 sme_key.wepTxKey = 1;
2148 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
2149
2150 /* Key index is zero based in SME but 1 based in wext */
2151 sme_key.keyIndex = (index - 1);
2152 sme_key.keyLength = 0;
2153 sme_key.authenticator = 0;
2154 UF_RTNL_UNLOCK();
2155 rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
2156 UF_RTNL_LOCK();
2157 if (rc) {
2158 unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc);
2159 return convert_sme_error(rc);
2160 }
2161
2162 /* Turn on encryption */
2163 privacy = 1;
2164 }
2165 }
2166
2167 /* Read the flags */
2168 if (erq->flags & IW_ENCODE_DISABLED) {
2169 /* disable encryption */
2170 unifi_trace(priv, UDBG1, "disable WEP encryption\n");
2171 privacy = 0;
2172
2173 priv->wep_tx_key_index = 0;
2174
2175 unifi_trace(priv, UDBG1, "IW_ENCODE_DISABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2176 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
2177 }
2178
2179 if (erq->flags & IW_ENCODE_RESTRICTED) {
2180 /* Use shared key auth */
2181 unifi_trace(priv, UDBG1, "IW_ENCODE_RESTRICTED: CSR_WIFI_SME_AUTH_MODE_80211_SHARED\n");
2182 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_SHARED;
2183
2184 /* Turn on encryption */
2185 privacy = 1;
2186 }
2187 if (erq->flags & IW_ENCODE_OPEN) {
2188 unifi_trace(priv, UDBG1, "IW_ENCODE_OPEN: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2189 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
2190 }
2191
2192 /* Commit the changes to flags if needed */
2193 if (privacy != -1) {
2194 priv->connection_config.privacyMode = privacy ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
2195 priv->connection_config.encryptionModeMask = privacy ? (CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 |
2196 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 |
2197 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 |
2198 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104) :
2199 CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
2200 }
2201
2202 return convert_sme_error(rc);
2203
2204} /* unifi_siwencode() */
2205
2206
2207
2208static int
2209unifi_giwencode(struct net_device *dev, struct iw_request_info *info,
2210 union iwreq_data *wrqu, char *extra)
2211{
2212 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2213 unifi_priv_t *priv = interfacePriv->privPtr;
2214 struct iw_point *erq = &wrqu->encoding;
2215
2216 unifi_trace(priv, UDBG2, "unifi_giwencode\n");
2217
2218 CHECK_INITED(priv);
2219
2220 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2221 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2222 unifi_error(priv, "unifi_giwencode: not permitted in Mode %d\n",
2223 interfacePriv->interfaceMode);
2224 return -EPERM;
2225 }
2226
2227
2228 if (priv->connection_config.authModeMask == CSR_WIFI_SME_AUTH_MODE_80211_SHARED) {
2229 erq->flags = IW_ENCODE_RESTRICTED;
2230 }
2231 else {
2232 if (priv->connection_config.privacyMode == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED) {
2233 erq->flags = IW_ENCODE_DISABLED;
2234 } else {
2235 erq->flags = IW_ENCODE_OPEN;
2236 }
2237 }
2238
2239 erq->length = 0;
2240
2241 if (erq->flags != IW_ENCODE_DISABLED) {
2242 int index = priv->wep_tx_key_index;
2243
2244 if ((index > 0) && (index <= NUM_WEPKEYS)) {
2245 erq->flags |= (index & IW_ENCODE_INDEX);
2246 erq->length = priv->wep_keys[index - 1].len;
2247 memcpy(extra, priv->wep_keys[index - 1].key, erq->length);
2248 } else {
2249 unifi_notice(priv, "unifi_giwencode: Surprise, do not have a valid key index (%d)\n",
2250 index);
2251 }
2252 }
2253
2254 return 0;
2255} /* unifi_giwencode() */
2256
2257
2258static int
2259unifi_siwpower(struct net_device *dev, struct iw_request_info *info,
2260 union iwreq_data *wrqu, char *extra)
2261{
2262 struct iw_param *args = &wrqu->power;
2263 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2264 unifi_priv_t *priv = interfacePriv->privPtr;
2265 int listen_interval, wake_for_dtim;
2266 int r = 0;
2267 CsrWifiSmePowerConfig powerConfig;
2268
2269 unifi_trace(priv, UDBG2, "unifi_siwpower\n");
2270
2271 CHECK_INITED(priv);
2272
2273 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2274 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2275 unifi_error(priv, "unifi_siwpower: not permitted in Mode %d\n",
2276 interfacePriv->interfaceMode);
2277 return -EPERM;
2278 }
2279
2280 UF_RTNL_UNLOCK();
2281 r = sme_mgt_power_config_get(priv, &powerConfig);
2282 UF_RTNL_LOCK();
2283 if (r) {
2284 unifi_error(priv, "unifi_siwpower: Get unifi_PowerConfigValue failed.\n");
2285 return r;
2286 }
2287
2288 listen_interval = -1;
2289 wake_for_dtim = -1;
2290 if (args->disabled) {
2291 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
2292 }
2293 else
2294 {
2295 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
2296
2297 switch (args->flags & IW_POWER_TYPE) {
2298 case 0:
2299 /* not specified */
2300 break;
2301 case IW_POWER_PERIOD:
2302 listen_interval = args->value / 1000;
2303 break;
2304 default:
2305 return -EINVAL;
2306 }
2307
2308 switch (args->flags & IW_POWER_MODE) {
2309 case 0:
2310 /* not specified */
2311 break;
2312 case IW_POWER_UNICAST_R:
2313 /* not interested in broadcast packets */
2314 wake_for_dtim = 0;
2315 break;
2316 case IW_POWER_ALL_R:
2317 /* yes, we are interested in broadcast packets */
2318 wake_for_dtim = 1;
2319 break;
2320 default:
2321 return -EINVAL;
2322 }
2323 }
2324
2325 if (listen_interval > 0) {
2326 powerConfig.listenIntervalTu = listen_interval;
2327 unifi_trace(priv, UDBG4, "unifi_siwpower: new Listen Interval = %d.\n",
2328 powerConfig.listenIntervalTu);
2329 }
2330
2331 if (wake_for_dtim >= 0) {
2332 powerConfig.rxDtims = wake_for_dtim;
2333 }
2334 UF_RTNL_UNLOCK();
2335 r = sme_mgt_power_config_set(priv, &powerConfig);
2336 UF_RTNL_LOCK();
2337 if (r) {
2338 unifi_error(priv, "unifi_siwpower: Set unifi_PowerConfigValue failed.\n");
2339 return r;
2340 }
2341
2342 return 0;
2343} /* unifi_siwpower() */
2344
2345
2346static int
2347unifi_giwpower(struct net_device *dev, struct iw_request_info *info,
2348 union iwreq_data *wrqu, char *extra)
2349{
2350 struct iw_param *args = &wrqu->power;
2351 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2352 unifi_priv_t *priv = interfacePriv->privPtr;
2353 CsrWifiSmePowerConfig powerConfig;
2354 int r;
2355
2356 unifi_trace(priv, UDBG2, "unifi_giwpower\n");
2357
2358 CHECK_INITED(priv);
2359
2360 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2361 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2362 unifi_error(priv, "unifi_giwpower: not permitted in Mode %d\n",
2363 interfacePriv->interfaceMode);
2364 return -EPERM;
2365 }
2366
2367
2368 args->flags = 0;
2369 UF_RTNL_UNLOCK();
2370 r = sme_mgt_power_config_get(priv, &powerConfig);
2371 UF_RTNL_LOCK();
2372 if (r) {
2373 unifi_error(priv, "unifi_giwpower: Get unifi_PowerConfigValue failed.\n");
2374 return r;
2375 }
2376
2377 unifi_trace(priv, UDBG4, "unifi_giwpower: mode=%d\n",
2378 powerConfig.powerSaveLevel);
2379
2380 args->disabled = (powerConfig.powerSaveLevel == CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW);
2381 if (args->disabled) {
2382 args->flags = 0;
2383 return 0;
2384 }
2385
2386 args->value = powerConfig.listenIntervalTu * 1000;
2387 args->flags |= IW_POWER_PERIOD;
2388
2389 if (powerConfig.rxDtims) {
2390 args->flags |= IW_POWER_ALL_R;
2391 } else {
2392 args->flags |= IW_POWER_UNICAST_R;
2393 }
2394
2395 return 0;
2396} /* unifi_giwpower() */
2397
2398
2399/*
2400 * ---------------------------------------------------------------------------
2401 * unifi_siwcommit - handler for SIOCSIWCOMMIT
2402 *
2403 * Apply all the parameters that have been set.
2404 * In practice this means:
2405 * - do a scan
2406 * - join a network or start an AdHoc
2407 * - authenticate and associate.
2408 *
2409 * Arguments:
2410 * None.
2411 *
2412 * Returns:
2413 * None.
2414 * ---------------------------------------------------------------------------
2415 */
2416static int
2417unifi_siwcommit(struct net_device *dev, struct iw_request_info *info,
2418 union iwreq_data *wrqu, char *extra)
2419{
2420 return 0;
2421} /* unifi_siwcommit() */
2422
2423
2424
2425static int
2426unifi_siwmlme(struct net_device *dev, struct iw_request_info *info,
2427 union iwreq_data *wrqu, char *extra)
2428{
2429 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2430 unifi_priv_t *priv = interfacePriv->privPtr;
2431 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2432
2433 unifi_trace(priv, UDBG2, "unifi_siwmlme\n");
2434 CHECK_INITED(priv);
2435
2436 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2437 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2438 unifi_error(priv, "unifi_siwmlme: not permitted in Mode %d\n",
2439 interfacePriv->interfaceMode);
2440 return -EPERM;
2441 }
2442
2443
2444 switch (mlme->cmd) {
2445 case IW_MLME_DEAUTH:
2446 case IW_MLME_DISASSOC:
2447 UF_RTNL_UNLOCK();
2448 sme_mgt_disconnect(priv);
2449 UF_RTNL_LOCK();
2450 break;
2451 default:
2452 return -EOPNOTSUPP;
2453 }
2454
2455 return 0;
2456} /* unifi_siwmlme() */
2457
2458
2459/*
2460 * ---------------------------------------------------------------------------
2461 * unifi_siwgenie
2462 * unifi_giwgenie
2463 *
2464 * WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM).
2465 * Handlers for SIOCSIWGENIE, SIOCGIWGENIE - set/get generic IE
2466 *
2467 * The host program (e.g. wpa_supplicant) uses this call to set the
2468 * additional IEs to accompany the next (Associate?) request.
2469 *
2470 * Arguments:
2471 * None.
2472 *
2473 * Returns:
2474 * None.
2475 * Notes:
2476 * From wireless.h:
2477 * This ioctl uses struct iw_point and data buffer that includes IE id
2478 * and len fields. More than one IE may be included in the
2479 * request. Setting the generic IE to empty buffer (len=0) removes the
2480 * generic IE from the driver.
2481 * ---------------------------------------------------------------------------
2482 */
2483static int
2484unifi_siwgenie(struct net_device *dev, struct iw_request_info *info,
2485 union iwreq_data *wrqu, char *extra)
2486{
2487 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2488 unifi_priv_t *priv = interfacePriv->privPtr;
2489 int len;
2490
2491 unifi_trace(priv, UDBG2, "unifi_siwgenie\n");
2492
2493 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2494 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2495 unifi_error(priv, "unifi_siwgenie: not permitted in Mode %d\n",
2496 interfacePriv->interfaceMode);
2497 return -EPERM;
2498 }
2499
2500
2501 if ( priv->connection_config.mlmeAssociateReqInformationElements) {
2502 kfree( priv->connection_config.mlmeAssociateReqInformationElements);
2503 }
2504 priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
2505 priv->connection_config.mlmeAssociateReqInformationElements = NULL;
2506
2507 len = wrqu->data.length;
2508 if (len == 0) {
2509 return 0;
2510 }
2511
2512 priv->connection_config.mlmeAssociateReqInformationElements = kmalloc(len, GFP_KERNEL);
2513 if (priv->connection_config.mlmeAssociateReqInformationElements == NULL) {
2514 return -ENOMEM;
2515 }
2516
2517 priv->connection_config.mlmeAssociateReqInformationElementsLength = len;
2518 memcpy( priv->connection_config.mlmeAssociateReqInformationElements, extra, len);
2519
2520 return 0;
2521} /* unifi_siwgenie() */
2522
2523
2524static int
2525unifi_giwgenie(struct net_device *dev, struct iw_request_info *info,
2526 union iwreq_data *wrqu, char *extra)
2527{
2528 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2529 unifi_priv_t *priv = interfacePriv->privPtr;
2530 int len;
2531
2532 unifi_trace(priv, UDBG2, "unifi_giwgenie\n");
2533
2534 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2535 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2536 unifi_error(priv, "unifi_giwgenie: not permitted in Mode %d\n",
2537 interfacePriv->interfaceMode);
2538 return -EPERM;
2539 }
2540
2541
2542 len = priv->connection_config.mlmeAssociateReqInformationElementsLength;
2543
2544 if (len == 0) {
2545 wrqu->data.length = 0;
2546 return 0;
2547 }
2548
2549 if (wrqu->data.length < len) {
2550 return -E2BIG;
2551 }
2552
2553 wrqu->data.length = len;
2554 memcpy(extra, priv->connection_config.mlmeAssociateReqInformationElements, len);
2555
2556 return 0;
2557} /* unifi_giwgenie() */
2558
2559
2560/*
2561 * ---------------------------------------------------------------------------
2562 * unifi_siwauth
2563 * unifi_giwauth
2564 *
2565 * Handlers for SIOCSIWAUTH, SIOCGIWAUTH
2566 * Set/get various authentication parameters.
2567 *
2568 * Arguments:
2569 *
2570 *
2571 * Returns:
2572 * None.
2573 * ---------------------------------------------------------------------------
2574 */
2575static int
2576_unifi_siwauth(struct net_device *dev, struct iw_request_info *info,
2577 union iwreq_data *wrqu, char *extra)
2578{
2579 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2580 unifi_priv_t *priv = interfacePriv->privPtr;
2581 CsrWifiSmeAuthModeMask new_auth;
2582
2583 unifi_trace(priv, UDBG2, "unifi_siwauth\n");
2584
2585 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2586 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2587 unifi_error(priv, "unifi_siwauth: not permitted in Mode %d\n",
2588 interfacePriv->interfaceMode);
2589 return -EPERM;
2590 }
2591
2592
2593 /*
2594 * This ioctl is safe to call even when UniFi is powered off.
2595 * wpa_supplicant calls it to test whether we support WPA.
2596 */
2597
2598 switch (wrqu->param.flags & IW_AUTH_INDEX) {
2599
2600 case IW_AUTH_WPA_ENABLED:
2601 unifi_trace(priv, UDBG1, "IW_AUTH_WPA_ENABLED: %d\n", wrqu->param.value);
2602
2603 if (wrqu->param.value == 0) {
2604 unifi_trace(priv, UDBG5, "IW_AUTH_WPA_ENABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2605 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
2606 }
2607 break;
2608
2609 case IW_AUTH_PRIVACY_INVOKED:
2610 unifi_trace(priv, UDBG1, "IW_AUTH_PRIVACY_INVOKED: %d\n", wrqu->param.value);
2611
2612 priv->connection_config.privacyMode = wrqu->param.value ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
2613 if (wrqu->param.value == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED)
2614 {
2615 priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
2616 }
2617 break;
2618
2619 case IW_AUTH_80211_AUTH_ALG:
2620 /*
2621 IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
2622 IW_AUTH_ALG_SHARED_KEY 0x00000002
2623 IW_AUTH_ALG_LEAP 0x00000004
2624 */
2625 new_auth = 0;
2626 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM) {
2627 unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_OPEN_SYSTEM)\n", wrqu->param.value);
2628 new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
2629 }
2630 if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY) {
2631 unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_SHARED_KEY)\n", wrqu->param.value);
2632 new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_SHARED;
2633 }
2634 if (wrqu->param.value & IW_AUTH_ALG_LEAP) {
2635 /* Initial exchanges using open-system to set EAP */
2636 unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_LEAP)\n", wrqu->param.value);
2637 new_auth |= CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X;
2638 }
2639 if (new_auth == 0) {
2640 unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: invalid value %d\n",
2641 wrqu->param.value);
2642 return -EINVAL;
2643 } else {
2644 priv->connection_config.authModeMask = new_auth;
2645 }
2646 break;
2647
2648 case IW_AUTH_WPA_VERSION:
2649 unifi_trace(priv, UDBG1, "IW_AUTH_WPA_VERSION: %d\n", wrqu->param.value);
2650 priv->ignore_bssid_join = TRUE;
2651 /*
2652 IW_AUTH_WPA_VERSION_DISABLED 0x00000001
2653 IW_AUTH_WPA_VERSION_WPA 0x00000002
2654 IW_AUTH_WPA_VERSION_WPA2 0x00000004
2655 */
2656
2657 if (!(wrqu->param.value & IW_AUTH_WPA_VERSION_DISABLED)) {
2658
2659 priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
2660
2661 if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA) {
2662 unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA, WPA-PSK\n");
2663 priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK);
2664 }
2665 if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA2) {
2666 unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA2, WPA2-PSK\n");
2667 priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK);
2668 }
2669 }
2670 break;
2671
2672 case IW_AUTH_CIPHER_PAIRWISE:
2673 unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_PAIRWISE: %d\n", wrqu->param.value);
2674 /*
2675 * one of:
2676 IW_AUTH_CIPHER_NONE 0x00000001
2677 IW_AUTH_CIPHER_WEP40 0x00000002
2678 IW_AUTH_CIPHER_TKIP 0x00000004
2679 IW_AUTH_CIPHER_CCMP 0x00000008
2680 IW_AUTH_CIPHER_WEP104 0x00000010
2681 */
2682
2683 priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
2684
2685 if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2686 priv->connection_config.encryptionModeMask |=
2687 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40;
2688 }
2689 if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
2690 priv->connection_config.encryptionModeMask |=
2691 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104;
2692 }
2693 if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2694 priv->connection_config.encryptionModeMask |=
2695 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP;
2696 }
2697 if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2698 priv->connection_config.encryptionModeMask |=
2699 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP;
2700 }
2701
2702 break;
2703
2704 case IW_AUTH_CIPHER_GROUP:
2705 unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_GROUP: %d\n", wrqu->param.value);
2706 /*
2707 * Use the WPA version and the group cipher suite to set the permitted
2708 * group key in the MIB. f/w uses this value to validate WPA and RSN IEs
2709 * in the probe responses from the desired BSS(ID)
2710 */
2711
2712 priv->connection_config.encryptionModeMask &= ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 |
2713 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 |
2714 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP |
2715 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP);
2716 if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
2717 priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40;
2718 }
2719 if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
2720 priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104;
2721 }
2722 if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
2723 priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP;
2724 }
2725 if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
2726 priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP;
2727 }
2728
2729 break;
2730
2731 case IW_AUTH_KEY_MGMT:
2732 unifi_trace(priv, UDBG1, "IW_AUTH_KEY_MGMT: %d\n", wrqu->param.value);
2733 /*
2734 IW_AUTH_KEY_MGMT_802_1X 1
2735 IW_AUTH_KEY_MGMT_PSK 2
2736 */
2737 if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK)) {
2738 /* Check for explicitly set mode. */
2739 if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) {
2740 priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK;
2741 }
2742 if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) {
2743 priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA;
2744 }
2745 unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA: %d\n",
2746 priv->connection_config.authModeMask);
2747 }
2748 if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK)) {
2749 /* Check for explicitly set mode. */
2750 if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) {
2751 priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK;
2752 }
2753 if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) {
2754 priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2;
2755 }
2756 unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA2: %d\n",
2757 priv->connection_config.authModeMask);
2758 }
2759
2760 break;
2761 case IW_AUTH_TKIP_COUNTERMEASURES:
2762 /*
2763 * Set to true at the start of the 60 second backup-off period
2764 * following 2 MichaelMIC failures within 60s.
2765 */
2766 unifi_trace(priv, UDBG1, "IW_AUTH_TKIP_COUNTERMEASURES: %d\n", wrqu->param.value);
2767 break;
2768
2769 case IW_AUTH_DROP_UNENCRYPTED:
2770 /*
2771 * Set to true on init.
2772 * Set to false just before associate if encryption will not be
2773 * required.
2774 *
2775 * Note this is not the same as the 802.1X controlled port
2776 */
2777 unifi_trace(priv, UDBG1, "IW_AUTH_DROP_UNENCRYPTED: %d\n", wrqu->param.value);
2778 break;
2779
2780 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2781 /*
2782 * This is set by wpa_supplicant to allow unencrypted EAPOL messages
2783 * even if pairwise keys are set when not using WPA. IEEE 802.1X
2784 * specifies that these frames are not encrypted, but WPA encrypts
2785 * them when pairwise keys are in use.
2786 * I think the UniFi f/w handles this decision for us.
2787 */
2788 unifi_trace(priv, UDBG1, "IW_AUTH_RX_UNENCRYPTED_EAPOL: %d\n", wrqu->param.value);
2789 break;
2790
2791 case IW_AUTH_ROAMING_CONTROL:
2792 unifi_trace(priv, UDBG1, "IW_AUTH_ROAMING_CONTROL: %d\n", wrqu->param.value);
2793 break;
2794
2795 default:
2796 unifi_trace(priv, UDBG1, "Unsupported auth param %d to 0x%X\n",
2797 wrqu->param.flags & IW_AUTH_INDEX,
2798 wrqu->param.value);
2799 return -EOPNOTSUPP;
2800 }
2801
2802 unifi_trace(priv, UDBG2, "authModeMask = %d", priv->connection_config.authModeMask);
2803
2804 return 0;
2805} /* _unifi_siwauth() */
2806
2807
2808static int
2809unifi_siwauth(struct net_device *dev, struct iw_request_info *info,
2810 union iwreq_data *wrqu, char *extra)
2811{
2812 int err = 0;
2813
2814 UF_RTNL_UNLOCK();
2815 err = _unifi_siwauth(dev, info, wrqu, extra);
2816 UF_RTNL_LOCK();
2817
2818 return err;
2819} /* unifi_siwauth() */
2820
2821
2822static int
2823unifi_giwauth(struct net_device *dev, struct iw_request_info *info,
2824 union iwreq_data *wrqu, char *extra)
2825{
2826 unifi_trace(NULL, UDBG2, "unifi_giwauth\n");
2827 return -EOPNOTSUPP;
2828} /* unifi_giwauth() */
2829
2830/*
2831 * ---------------------------------------------------------------------------
2832 * unifi_siwencodeext
2833 * unifi_giwencodeext
2834 *
2835 * Handlers for SIOCSIWENCODEEXT, SIOCGIWENCODEEXT - set/get
2836 * encoding token & mode
2837 *
2838 * Arguments:
2839 * None.
2840 *
2841 * Returns:
2842 * None.
2843 *
2844 * Notes:
2845 * For WPA/WPA2 we don't take note of the IW_ENCODE_EXT_SET_TX_KEY flag.
2846 * This flag means "use this key to encode transmissions"; we just
2847 * assume only one key will be set and that is the one to use.
2848 * ---------------------------------------------------------------------------
2849 */
2850static int
2851_unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info,
2852 union iwreq_data *wrqu, char *extra)
2853{
2854 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
2855 unifi_priv_t *priv = interfacePriv->privPtr;
2856 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2857 int r = 0;
2858 unsigned char *keydata;
2859 unsigned char tkip_key[32];
2860 int keyid;
2861 unsigned char *a = (unsigned char *)ext->addr.sa_data;
2862 CsrWifiSmeKey sme_key;
2863 CsrWifiSmeKeyType key_type;
2864
2865 CHECK_INITED(priv);
2866
2867 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
2868 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
2869 unifi_error(priv, "unifi_siwencodeext: not permitted in Mode %d\n",
2870 interfacePriv->interfaceMode);
2871 return -EPERM;
2872 }
2873
2874
2875 unifi_trace(priv, UDBG1, "siwencodeext: flags=0x%X, alg=%d, ext_flags=0x%X, len=%d, index=%d,\n",
2876 wrqu->encoding.flags, ext->alg, ext->ext_flags,
2877 ext->key_len, (wrqu->encoding.flags & IW_ENCODE_INDEX));
2878 unifi_trace(priv, UDBG3, " addr=%pM\n", a);
2879
2880 if ((ext->key_len == 0) && (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) {
2881 /* This means use a different key (given by key_idx) for Tx. */
2882 /* NYI */
2883 unifi_trace(priv, UDBG1, KERN_ERR "unifi_siwencodeext: NYI should change tx key id here!!\n");
2884 return -ENOTSUPP;
2885 }
2886
2887 memset(&sme_key, 0, sizeof(sme_key));
2888
2889 keydata = (unsigned char *)(ext + 1);
2890 keyid = (wrqu->encoding.flags & IW_ENCODE_INDEX);
2891
2892 /*
2893 * Check for request to delete keys for an address.
2894 */
2895 /* Pick out request for no privacy. */
2896 if (ext->alg == IW_ENCODE_ALG_NONE) {
2897
2898 unifi_trace(priv, UDBG1, "Deleting %s key %d\n",
2899 (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ? "GROUP" : "PAIRWISE",
2900 keyid);
2901
2902 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2903 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
2904 } else {
2905 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
2906 }
2907 sme_key.keyIndex = (keyid - 1);
2908 sme_key.keyLength = 0;
2909 sme_key.authenticator = 0;
2910 memcpy(sme_key.address.a, a, ETH_ALEN);
2911 UF_RTNL_UNLOCK();
2912 r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_REMOVE);
2913 UF_RTNL_LOCK();
2914 if (r) {
2915 unifi_error(priv, "Delete key request was rejected with result %d\n", r);
2916 return convert_sme_error(r);
2917 }
2918
2919 return 0;
2920 }
2921
2922 /*
2923 * Request is to set a key, not delete
2924 */
2925
2926 /* Pick out WEP and use set_wep_key(). */
2927 if (ext->alg == IW_ENCODE_ALG_WEP) {
2928 /* WEP-40, WEP-104 */
2929
2930 /* Check for valid key length */
2931 if (!((ext->key_len == 5) || (ext->key_len == 13))) {
2932 unifi_trace(priv, UDBG1, KERN_ERR "Invalid length for WEP key: %d\n", ext->key_len);
2933 return -EINVAL;
2934 }
2935
2936 unifi_trace(priv, UDBG1, "Setting WEP key %d tx:%d\n",
2937 keyid, ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY);
2938
2939 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
2940 sme_key.wepTxKey = TRUE;
2941 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
2942 } else {
2943 sme_key.wepTxKey = FALSE;
2944 sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
2945 }
2946 sme_key.keyIndex = (keyid - 1);
2947 sme_key.keyLength = ext->key_len;
2948 sme_key.authenticator = 0;
2949 memset(sme_key.address.a, 0xFF, ETH_ALEN);
2950 memcpy(sme_key.key, keydata, ext->key_len);
2951 UF_RTNL_UNLOCK();
2952 r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
2953 UF_RTNL_LOCK();
2954 if (r) {
2955 unifi_error(priv, "siwencodeext: Set key failed (%d)", r);
2956 return convert_sme_error(r);
2957 }
2958
2959 return 0;
2960 }
2961
2962 /*
2963 *
2964 * If we reach here, we are dealing with a WPA/WPA2 key
2965 *
2966 */
2967 if (ext->key_len > 32) {
2968 return -EINVAL;
2969 }
2970
2971 /*
2972 * TKIP keys from wpa_supplicant need swapping.
2973 * What about other supplicants (when they come along)?
2974 */
2975 if ((ext->alg == IW_ENCODE_ALG_TKIP) && (ext->key_len == 32)) {
2976 memcpy(tkip_key, keydata, 16);
2977 memcpy(tkip_key + 16, keydata + 24, 8);
2978 memcpy(tkip_key + 24, keydata + 16, 8);
2979 keydata = tkip_key;
2980 }
2981
2982 key_type = (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ?
2983 CSR_WIFI_SME_KEY_TYPE_GROUP : /* Group Key */
2984 CSR_WIFI_SME_KEY_TYPE_PAIRWISE; /* Pairwise Key */
2985
2986 sme_key.keyType = key_type;
2987 sme_key.keyIndex = (keyid - 1);
2988 sme_key.keyLength = ext->key_len;
2989 sme_key.authenticator = 0;
2990 memcpy(sme_key.address.a, ext->addr.sa_data, ETH_ALEN);
2991 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
2992
2993 unifi_trace(priv, UDBG5, "RSC first 6 bytes = %*phC\n",
2994 6, ext->rx_seq);
2995
2996 /* memcpy((u8*)(&sme_key.keyRsc), ext->rx_seq, 8); */
2997 sme_key.keyRsc[0] = ext->rx_seq[1] << 8 | ext->rx_seq[0];
2998 sme_key.keyRsc[1] = ext->rx_seq[3] << 8 | ext->rx_seq[2];
2999 sme_key.keyRsc[2] = ext->rx_seq[5] << 8 | ext->rx_seq[4];
3000 sme_key.keyRsc[3] = ext->rx_seq[7] << 8 | ext->rx_seq[6];
3001
3002 }
3003
3004 memcpy(sme_key.key, keydata, ext->key_len);
3005 UF_RTNL_UNLOCK();
3006 r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
3007 UF_RTNL_LOCK();
3008 if (r) {
3009 unifi_error(priv, "SETKEYS request was rejected with result %d\n", r);
3010 return convert_sme_error(r);
3011 }
3012
3013 return r;
3014} /* _unifi_siwencodeext() */
3015
3016
3017static int
3018unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info,
3019 union iwreq_data *wrqu, char *extra)
3020{
3021 int err = 0;
3022
3023 err = _unifi_siwencodeext(dev, info, wrqu, extra);
3024
3025 return err;
3026} /* unifi_siwencodeext() */
3027
3028
3029static int
3030unifi_giwencodeext(struct net_device *dev, struct iw_request_info *info,
3031 union iwreq_data *wrqu, char *extra)
3032{
3033 return -EOPNOTSUPP;
3034} /* unifi_giwencodeext() */
3035
3036
3037/*
3038 * ---------------------------------------------------------------------------
3039 * unifi_siwpmksa
3040 *
3041 * SIOCSIWPMKSA - PMKSA cache operation
3042 * The caller passes a pmksa structure:
3043 * - cmd one of ADD, REMOVE, FLUSH
3044 * - bssid MAC address
3045 * - pmkid ID string (16 bytes)
3046 *
3047 * Arguments:
3048 * None.
3049 *
3050 * Returns:
3051 * None.
3052 *
3053 * Notes:
3054 * This is not needed since we provide a siwgenie method.
3055 * ---------------------------------------------------------------------------
3056 */
3057#define UNIFI_PMKID_KEY_SIZE 16
3058static int
3059unifi_siwpmksa(struct net_device *dev, struct iw_request_info *info,
3060 union iwreq_data *wrqu, char *extra)
3061{
3062 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
3063 unifi_priv_t *priv = interfacePriv->privPtr;
3064 struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
3065 CsrResult r = 0;
3066 CsrWifiSmePmkidList pmkid_list;
3067 CsrWifiSmePmkid pmkid;
3068 CsrWifiSmeListAction action;
3069
3070 CHECK_INITED(priv);
3071
3072 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
3073 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
3074 unifi_error(priv, "unifi_siwpmksa: not permitted in Mode %d\n",
3075 interfacePriv->interfaceMode);
3076 return -EPERM;
3077 }
3078
3079
3080 unifi_trace(priv, UDBG1, "SIWPMKSA: cmd %d, %pM\n", pmksa->cmd,
3081 pmksa->bssid.sa_data);
3082
3083 pmkid_list.pmkids = NULL;
3084 switch (pmksa->cmd) {
3085 case IW_PMKSA_ADD:
3086 pmkid_list.pmkids = &pmkid;
3087 action = CSR_WIFI_SME_LIST_ACTION_ADD;
3088 pmkid_list.pmkidsCount = 1;
3089 memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN);
3090 memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE);
3091 break;
3092 case IW_PMKSA_REMOVE:
3093 pmkid_list.pmkids = &pmkid;
3094 action = CSR_WIFI_SME_LIST_ACTION_REMOVE;
3095 pmkid_list.pmkidsCount = 1;
3096 memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN);
3097 memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE);
3098 break;
3099 case IW_PMKSA_FLUSH:
3100 /* Replace current PMKID's with an empty list */
3101 pmkid_list.pmkidsCount = 0;
3102 action = CSR_WIFI_SME_LIST_ACTION_FLUSH;
3103 break;
3104 default:
3105 unifi_notice(priv, "SIWPMKSA: Unknown command (0x%x)\n", pmksa->cmd);
3106 return -EINVAL;
3107 }
3108
3109 /* Set the Value the pmkid's will have 1 added OR 1 removed OR be cleared at this point */
3110 UF_RTNL_UNLOCK();
3111 r = sme_mgt_pmkid(priv, action, &pmkid_list);
3112 UF_RTNL_LOCK();
3113 if (r) {
3114 unifi_error(priv, "SIWPMKSA: Set PMKID's Failed.\n");
3115 }
3116
3117 return r;
3118
3119} /* unifi_siwpmksa() */
3120
3121
3122/*
3123 * ---------------------------------------------------------------------------
3124 * unifi_get_wireless_stats
3125 *
3126 * get_wireless_stats method for Linux wireless extensions.
3127 *
3128 * Arguments:
3129 * dev Pointer to associated netdevice.
3130 *
3131 * Returns:
3132 * Pointer to iw_statistics struct.
3133 * ---------------------------------------------------------------------------
3134 */
3135struct iw_statistics *
3136unifi_get_wireless_stats(struct net_device *dev)
3137{
3138 netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
3139 unifi_priv_t *priv = interfacePriv->privPtr;
3140
3141 if (priv->init_progress != UNIFI_INIT_COMPLETED) {
3142 return NULL;
3143 }
3144
3145 return &priv->wext_wireless_stats;
3146} /* unifi_get_wireless_stats() */
3147
3148
3149/*
3150 * Structures to export the Wireless Handlers
3151 */
3152
3153static const struct iw_priv_args unifi_private_args[] = {
3154 /*{ cmd, set_args, get_args, name } */
3155 { SIOCIWS80211POWERSAVEPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
3156 IW_PRIV_TYPE_NONE, "iwprivs80211ps" },
3157 { SIOCIWG80211POWERSAVEPRIV, IW_PRIV_TYPE_NONE,
3158 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IWPRIV_POWER_SAVE_MAX_STRING, "iwprivg80211ps" },
3159 { SIOCIWS80211RELOADDEFAULTSPRIV, IW_PRIV_TYPE_NONE,
3160 IW_PRIV_TYPE_NONE, "iwprivsdefs" },
3161 { SIOCIWSSMEDEBUGPRIV, IW_PRIV_TYPE_CHAR | IWPRIV_SME_DEBUG_MAX_STRING, IW_PRIV_TYPE_NONE, "iwprivssmedebug" },
3162#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3163 { SIOCIWSCONFWAPIPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
3164 IW_PRIV_TYPE_NONE, "iwprivsconfwapi" },
3165 { SIOCIWSWAPIKEYPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(unifiio_wapi_key_t),
3166 IW_PRIV_TYPE_NONE, "iwprivswpikey" },
3167#endif
3168#ifdef CSR_SUPPORT_WEXT_AP
3169 { SIOCIWSAPCFGPRIV, IW_PRIV_TYPE_CHAR | 256, IW_PRIV_TYPE_NONE, "AP_SET_CFG" },
3170 { SIOCIWSAPSTARTPRIV, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "AP_BSS_START" },
3171 { SIOCIWSAPSTOPPRIV, IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0,
3172 IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "AP_BSS_STOP" },
3173#ifdef ANDROID_BUILD
3174 { SIOCIWSFWRELOADPRIV, IW_PRIV_TYPE_CHAR |256,
3175 IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "WL_FW_RELOAD" },
3176 { SIOCIWSSTACKSTART, 0,
3177 IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "START" },
3178 { SIOCIWSSTACKSTOP, 0,
3179 IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "STOP" },
3180#endif /* ANDROID_BUILD */
3181#endif /* CSR_SUPPORT_WEXT_AP */
3182};
3183
3184static const iw_handler unifi_handler[] =
3185{
3186 (iw_handler) unifi_siwcommit, /* SIOCSIWCOMMIT */
3187 (iw_handler) unifi_giwname, /* SIOCGIWNAME */
3188 (iw_handler) NULL, /* SIOCSIWNWID */
3189 (iw_handler) NULL, /* SIOCGIWNWID */
3190 (iw_handler) unifi_siwfreq, /* SIOCSIWFREQ */
3191 (iw_handler) unifi_giwfreq, /* SIOCGIWFREQ */
3192 (iw_handler) unifi_siwmode, /* SIOCSIWMODE */
3193 (iw_handler) unifi_giwmode, /* SIOCGIWMODE */
3194 (iw_handler) NULL, /* SIOCSIWSENS */
3195 (iw_handler) NULL, /* SIOCGIWSENS */
3196 (iw_handler) NULL, /* SIOCSIWRANGE */
3197 (iw_handler) unifi_giwrange, /* SIOCGIWRANGE */
3198 (iw_handler) NULL, /* SIOCSIWPRIV */
3199 (iw_handler) NULL, /* SIOCGIWPRIV */
3200 (iw_handler) NULL, /* SIOCSIWSTATS */
3201 (iw_handler) NULL, /* SIOCGIWSTATS */
3202 (iw_handler) NULL, /* SIOCSIWSPY */
3203 (iw_handler) NULL, /* SIOCGIWSPY */
3204 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3205 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3206 (iw_handler) unifi_siwap, /* SIOCSIWAP */
3207 (iw_handler) unifi_giwap, /* SIOCGIWAP */
3208#if WIRELESS_EXT > 17
3209 /* WPA : IEEE 802.11 MLME requests */
3210 unifi_siwmlme, /* SIOCSIWMLME, request MLME operation */
3211#else
3212 (iw_handler) NULL, /* -- hole -- */
3213#endif
3214 (iw_handler) NULL, /* SIOCGIWAPLIST */
3215 (iw_handler) unifi_siwscan, /* SIOCSIWSCAN */
3216 (iw_handler) unifi_giwscan, /* SIOCGIWSCAN */
3217 (iw_handler) unifi_siwessid, /* SIOCSIWESSID */
3218 (iw_handler) unifi_giwessid, /* SIOCGIWESSID */
3219 (iw_handler) NULL, /* SIOCSIWNICKN */
3220 (iw_handler) NULL, /* SIOCGIWNICKN */
3221 (iw_handler) NULL, /* -- hole -- */
3222 (iw_handler) NULL, /* -- hole -- */
3223 unifi_siwrate, /* SIOCSIWRATE */
3224 unifi_giwrate, /* SIOCGIWRATE */
3225 unifi_siwrts, /* SIOCSIWRTS */
3226 unifi_giwrts, /* SIOCGIWRTS */
3227 unifi_siwfrag, /* SIOCSIWFRAG */
3228 unifi_giwfrag, /* SIOCGIWFRAG */
3229 (iw_handler) NULL, /* SIOCSIWTXPOW */
3230 (iw_handler) NULL, /* SIOCGIWTXPOW */
3231 (iw_handler) NULL, /* SIOCSIWRETRY */
3232 (iw_handler) NULL, /* SIOCGIWRETRY */
3233 unifi_siwencode, /* SIOCSIWENCODE */
3234 unifi_giwencode, /* SIOCGIWENCODE */
3235 unifi_siwpower, /* SIOCSIWPOWER */
3236 unifi_giwpower, /* SIOCGIWPOWER */
3237#if WIRELESS_EXT > 17
3238 (iw_handler) NULL, /* -- hole -- */
3239 (iw_handler) NULL, /* -- hole -- */
3240
3241 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
3242 unifi_siwgenie, /* SIOCSIWGENIE */ /* set generic IE */
3243 unifi_giwgenie, /* SIOCGIWGENIE */ /* get generic IE */
3244
3245 /* WPA : Authentication mode parameters */
3246 unifi_siwauth, /* SIOCSIWAUTH */ /* set authentication mode params */
3247 unifi_giwauth, /* SIOCGIWAUTH */ /* get authentication mode params */
3248
3249 /* WPA : Extended version of encoding configuration */
3250 unifi_siwencodeext, /* SIOCSIWENCODEEXT */ /* set encoding token & mode */
3251 unifi_giwencodeext, /* SIOCGIWENCODEEXT */ /* get encoding token & mode */
3252
3253 /* WPA2 : PMKSA cache management */
3254 unifi_siwpmksa, /* SIOCSIWPMKSA */ /* PMKSA cache operation */
3255 (iw_handler) NULL, /* -- hole -- */
3256#endif /* WIRELESS_EXT > 17 */
3257};
3258
3259
3260static const iw_handler unifi_private_handler[] =
3261{
3262 iwprivs80211ps, /* SIOCIWFIRSTPRIV */
3263 iwprivg80211ps, /* SIOCIWFIRSTPRIV + 1 */
3264 iwprivsdefs, /* SIOCIWFIRSTPRIV + 2 */
3265 (iw_handler) NULL,
3266#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3267 iwprivsconfwapi, /* SIOCIWFIRSTPRIV + 4 */
3268 (iw_handler) NULL, /* SIOCIWFIRSTPRIV + 5 */
3269 iwprivswpikey, /* SIOCIWFIRSTPRIV + 6 */
3270#else
3271 (iw_handler) NULL,
3272 (iw_handler) NULL,
3273 (iw_handler) NULL,
3274#endif
3275 (iw_handler) NULL,
3276 iwprivssmedebug, /* SIOCIWFIRSTPRIV + 8 */
3277#ifdef CSR_SUPPORT_WEXT_AP
3278 (iw_handler) NULL,
3279 iwprivsapconfig,
3280 (iw_handler) NULL,
3281 iwprivsapstart,
3282 (iw_handler) NULL,
3283 iwprivsapstop,
3284 (iw_handler) NULL,
3285#ifdef ANDROID_BUILD
3286 iwprivsapfwreload,
3287 (iw_handler) NULL,
3288 iwprivsstackstart,
3289 (iw_handler) NULL,
3290 iwprivsstackstop,
3291#else
3292 (iw_handler) NULL,
3293 (iw_handler) NULL,
3294 (iw_handler) NULL,
3295 (iw_handler) NULL,
3296 (iw_handler) NULL,
3297#endif /* ANDROID_BUILD */
3298#else
3299 (iw_handler) NULL,
3300 (iw_handler) NULL,
3301 (iw_handler) NULL,
3302 (iw_handler) NULL,
3303 (iw_handler) NULL,
3304 (iw_handler) NULL,
3305 (iw_handler) NULL,
3306 (iw_handler) NULL,
3307 (iw_handler) NULL,
3308 (iw_handler) NULL,
3309 (iw_handler) NULL,
3310 (iw_handler) NULL,
3311#endif /* CSR_SUPPORT_WEXT_AP */
3312};
3313
3314struct iw_handler_def unifi_iw_handler_def =
3315{
3316 .num_standard = sizeof(unifi_handler) / sizeof(iw_handler),
3317 .num_private = sizeof(unifi_private_handler) / sizeof(iw_handler),
3318 .num_private_args = sizeof(unifi_private_args) / sizeof(struct iw_priv_args),
3319 .standard = (iw_handler *) unifi_handler,
3320 .private = (iw_handler *) unifi_private_handler,
3321 .private_args = (struct iw_priv_args *) unifi_private_args,
3322#if IW_HANDLER_VERSION >= 6
3323 .get_wireless_stats = unifi_get_wireless_stats,
3324#endif
3325};
3326
3327
diff --git a/drivers/staging/csr/ul_int.c b/drivers/staging/csr/ul_int.c
deleted file mode 100644
index eb286e5f7467..000000000000
--- a/drivers/staging/csr/ul_int.c
+++ /dev/null
@@ -1,528 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: ul_int.c
4 *
5 * PURPOSE:
6 * Manage list of client applications using UniFi.
7 *
8 * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd.
9 *
10 * Refer to LICENSE.txt included with this source code for details on
11 * the license terms.
12 *
13 * ***************************************************************************
14 */
15#include "csr_wifi_hip_unifi.h"
16#include "csr_wifi_hip_conversions.h"
17#include "unifi_priv.h"
18#include "unifiio.h"
19#include "unifi_os.h"
20
21static void free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata);
22static void reset_driver_status(unifi_priv_t *priv);
23
24/*
25 * ---------------------------------------------------------------------------
26 * ul_init_clients
27 *
28 * Initialise the clients array to empty.
29 *
30 * Arguments:
31 * priv Pointer to device private context struct
32 *
33 * Returns:
34 * None.
35 *
36 * Notes:
37 * This function needs to be called before priv is stored in
38 * Unifi_instances[].
39 * ---------------------------------------------------------------------------
40 */
41void
42ul_init_clients(unifi_priv_t *priv)
43{
44 int id;
45 ul_client_t *ul_clients;
46
47 sema_init(&priv->udi_logging_mutex, 1);
48 priv->logging_client = NULL;
49
50 ul_clients = priv->ul_clients;
51
52 for (id = 0; id < MAX_UDI_CLIENTS; id++) {
53 memset(&ul_clients[id], 0, sizeof(ul_client_t));
54
55 ul_clients[id].client_id = id;
56 ul_clients[id].sender_id = UDI_SENDER_ID_BASE + (id << UDI_SENDER_ID_SHIFT);
57 ul_clients[id].instance = -1;
58 ul_clients[id].event_hook = NULL;
59
60 INIT_LIST_HEAD(&ul_clients[id].udi_log);
61 init_waitqueue_head(&ul_clients[id].udi_wq);
62 sema_init(&ul_clients[id].udi_sem, 1);
63
64 ul_clients[id].wake_up_wq_id = 0;
65 ul_clients[id].seq_no = 0;
66 ul_clients[id].wake_seq_no = 0;
67 ul_clients[id].snap_filter.count = 0;
68 }
69} /* ul_init_clients() */
70
71
72/*
73 * ---------------------------------------------------------------------------
74 * ul_register_client
75 *
76 * This function registers a new ul client.
77 *
78 * Arguments:
79 * priv Pointer to device private context struct
80 * configuration Special configuration for the client.
81 * udi_event_clbk Callback for receiving event from unifi.
82 *
83 * Returns:
84 * 0 if a new clients is registered, -1 otherwise.
85 * ---------------------------------------------------------------------------
86 */
87ul_client_t *
88ul_register_client(unifi_priv_t *priv, unsigned int configuration,
89 udi_event_t udi_event_clbk)
90{
91 unsigned char id, ref;
92 ul_client_t *ul_clients;
93
94 ul_clients = priv->ul_clients;
95
96 /* check for an unused entry */
97 for (id = 0; id < MAX_UDI_CLIENTS; id++) {
98 if (ul_clients[id].udi_enabled == 0) {
99 ul_clients[id].instance = priv->instance;
100 ul_clients[id].udi_enabled = 1;
101 ul_clients[id].configuration = configuration;
102
103 /* Allocate memory for the reply signal.. */
104 ul_clients[id].reply_signal = kmalloc(sizeof(CSR_SIGNAL), GFP_KERNEL);
105 if (ul_clients[id].reply_signal == NULL) {
106 unifi_error(priv, "Failed to allocate reply signal for client.\n");
107 return NULL;
108 }
109 /* .. and the bulk data of the reply signal. */
110 for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) {
111 ul_clients[id].reply_bulkdata[ref] = kmalloc(sizeof(bulk_data_t), GFP_KERNEL);
112 /* If allocation fails, free allocated memory. */
113 if (ul_clients[id].reply_bulkdata[ref] == NULL) {
114 for (; ref > 0; ref --) {
115 kfree(ul_clients[id].reply_bulkdata[ref - 1]);
116 }
117 kfree(ul_clients[id].reply_signal);
118 unifi_error(priv, "Failed to allocate bulk data buffers for client.\n");
119 return NULL;
120 }
121 }
122
123 /* Set the event callback. */
124 ul_clients[id].event_hook = udi_event_clbk;
125
126 unifi_trace(priv, UDBG2, "UDI %d (0x%x) registered. configuration = 0x%x\n",
127 id, &ul_clients[id], configuration);
128 return &ul_clients[id];
129 }
130 }
131 return NULL;
132} /* ul_register_client() */
133
134
135/*
136 * ---------------------------------------------------------------------------
137 * ul_deregister_client
138 *
139 * This function deregisters a blocking UDI client.
140 *
141 * Arguments:
142 * client Pointer to the client we deregister.
143 *
144 * Returns:
145 * 0 if a new clients is deregistered.
146 * ---------------------------------------------------------------------------
147 */
148int
149ul_deregister_client(ul_client_t *ul_client)
150{
151 struct list_head *pos, *n;
152 udi_log_t *logptr;
153 unifi_priv_t *priv = uf_find_instance(ul_client->instance);
154 int ref;
155
156 ul_client->instance = -1;
157 ul_client->event_hook = NULL;
158 ul_client->udi_enabled = 0;
159 unifi_trace(priv, UDBG5, "UDI (0x%x) deregistered.\n", ul_client);
160
161 /* Free memory allocated for the reply signal and its bulk data. */
162 kfree(ul_client->reply_signal);
163 for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) {
164 kfree(ul_client->reply_bulkdata[ref]);
165 }
166
167 if (ul_client->snap_filter.count) {
168 ul_client->snap_filter.count = 0;
169 kfree(ul_client->snap_filter.protocols);
170 }
171
172 /* Free anything pending on the udi_log list */
173 down(&ul_client->udi_sem);
174 list_for_each_safe(pos, n, &ul_client->udi_log)
175 {
176 logptr = list_entry(pos, udi_log_t, q);
177 list_del(pos);
178 kfree(logptr);
179 }
180 up(&ul_client->udi_sem);
181
182 return 0;
183} /* ul_deregister_client() */
184
185
186
187/*
188 * ---------------------------------------------------------------------------
189 * logging_handler
190 *
191 * This function is registered with the driver core.
192 * It is called every time a UniFi HIP Signal is sent. It iterates over
193 * the list of processes interested in receiving log events and
194 * delivers the events to them.
195 *
196 * Arguments:
197 * ospriv Pointer to driver's private data.
198 * sigdata Pointer to the packed signal buffer.
199 * signal_len Length of the packed signal.
200 * bulkdata Pointer to the signal's bulk data.
201 * dir Direction of the signal
202 * 0 = from-host
203 * 1 = to-host
204 *
205 * Returns:
206 * None.
207 * ---------------------------------------------------------------------------
208 */
209void
210logging_handler(void *ospriv,
211 u8 *sigdata, u32 signal_len,
212 const bulk_data_param_t *bulkdata,
213 enum udi_log_direction direction)
214{
215 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
216 ul_client_t *client;
217 int dir;
218
219 dir = (direction == UDI_LOG_FROM_HOST) ? UDI_FROM_HOST : UDI_TO_HOST;
220
221 down(&priv->udi_logging_mutex);
222 client = priv->logging_client;
223 if (client != NULL) {
224 client->event_hook(client, sigdata, signal_len,
225 bulkdata, dir);
226 }
227 up(&priv->udi_logging_mutex);
228
229} /* logging_handler() */
230
231
232
233/*
234 * ---------------------------------------------------------------------------
235 * ul_log_config_ind
236 *
237 * This function uses the client's register callback
238 * to indicate configuration information e.g core errors.
239 *
240 * Arguments:
241 * priv Pointer to driver's private data.
242 * conf_param Pointer to the configuration data.
243 * len Length of the configuration data.
244 *
245 * Returns:
246 * None.
247 * ---------------------------------------------------------------------------
248 */
249void
250ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len)
251{
252#ifdef CSR_SUPPORT_SME
253 if (priv->smepriv == NULL)
254 {
255 return;
256 }
257 if ((CONFIG_IND_ERROR == (*conf_param)) && (priv->wifi_on_state == wifi_on_in_progress)) {
258 unifi_notice(priv, "ul_log_config_ind: wifi on in progress, suppress error\n");
259 } else {
260 /* wifi_off_ind (error or exit) */
261 CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, (CsrWifiRouterCtrlControlIndication)(*conf_param));
262 }
263#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
264 unifi_debug_buf_dump();
265#endif
266#else
267 bulk_data_param_t bulkdata;
268
269 /*
270 * If someone killed unifi_managed before the driver was unloaded
271 * the g_drvpriv pointer is going to be NULL. In this case it is
272 * safe to assume that there is no client to get the indication.
273 */
274 if (!priv) {
275 unifi_notice(NULL, "uf_sme_event_ind: NULL priv\n");
276 return;
277 }
278
279 /* Create a null bulkdata structure. */
280 bulkdata.d[0].data_length = 0;
281 bulkdata.d[1].data_length = 0;
282
283 sme_native_log_event(priv->sme_cli, conf_param, sizeof(u8),
284 &bulkdata, UDI_CONFIG_IND);
285
286#endif /* CSR_SUPPORT_SME */
287
288} /* ul_log_config_ind */
289
290
291/*
292 * ---------------------------------------------------------------------------
293 * free_bulkdata_buffers
294 *
295 * Free the bulkdata buffers e.g. after a failed unifi_send_signal().
296 *
297 * Arguments:
298 * priv Pointer to device private struct
299 * bulkdata Pointer to bulkdata parameter table
300 *
301 * Returns:
302 * None.
303 * ---------------------------------------------------------------------------
304 */
305static void
306free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata)
307{
308 int i;
309
310 if (bulkdata) {
311 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) {
312 if (bulkdata->d[i].data_length != 0) {
313 unifi_net_data_free(priv, (bulk_data_desc_t *)(&bulkdata->d[i]));
314 /* data_length is now 0 */
315 }
316 }
317 }
318
319} /* free_bulkdata_buffers */
320
321static int
322_align_bulk_data_buffers(unifi_priv_t *priv, u8 *signal,
323 bulk_data_param_t *bulkdata)
324{
325 unsigned int i;
326
327 if ((bulkdata == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) {
328 return 0;
329 }
330
331 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
332 {
333 struct sk_buff *skb;
334 /*
335 * The following complex casting is in place in order to eliminate 64-bit compilation warning
336 * "cast to/from pointer from/to integer of different size"
337 */
338 u32 align_offset = (u32)(long)(bulkdata->d[i].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
339 if (align_offset)
340 {
341 skb = (struct sk_buff*)bulkdata->d[i].os_net_buf_ptr;
342 if (skb == NULL) {
343 unifi_warning(priv,
344 "_align_bulk_data_buffers: Align offset found (%d) but skb is NULL!\n",
345 align_offset);
346 return -EINVAL;
347 }
348 if (bulkdata->d[i].data_length == 0) {
349 unifi_warning(priv,
350 "_align_bulk_data_buffers: Align offset found (%d) but length is zero\n",
351 align_offset);
352 return CSR_RESULT_SUCCESS;
353 }
354 unifi_trace(priv, UDBG5,
355 "Align f-h buffer (0x%p) by %d bytes (skb->data: 0x%p)\n",
356 bulkdata->d[i].os_data_ptr, align_offset, skb->data);
357
358
359 /* Check if there is enough headroom... */
360 if (unlikely(skb_headroom(skb) < align_offset))
361 {
362 struct sk_buff *tmp = skb;
363
364 unifi_trace(priv, UDBG5, "Headroom not enough - realloc it\n");
365 skb = skb_realloc_headroom(skb, align_offset);
366 if (skb == NULL) {
367 unifi_error(priv,
368 "_align_bulk_data_buffers: skb_realloc_headroom failed - signal is dropped\n");
369 return -EFAULT;
370 }
371 /* Free the old bulk data only if allocation succeeds */
372 kfree_skb(tmp);
373 /* Bulkdata needs to point to the new skb */
374 bulkdata->d[i].os_net_buf_ptr = (const unsigned char*)skb;
375 bulkdata->d[i].os_data_ptr = (const void*)skb->data;
376 }
377 /* ... before pushing the data to the right alignment offset */
378 skb_push(skb, align_offset);
379
380 }
381 /* The direction bit is zero for the from-host */
382 signal[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1] = align_offset;
383
384 }
385 return 0;
386} /* _align_bulk_data_buffers() */
387
388
389/*
390 * ---------------------------------------------------------------------------
391 * ul_send_signal_unpacked
392 *
393 * This function sends a host formatted signal to unifi.
394 *
395 * Arguments:
396 * priv Pointer to driver's private data.
397 * sigptr Pointer to the signal.
398 * bulkdata Pointer to the signal's bulk data.
399 *
400 * Returns:
401 * O on success, error code otherwise.
402 *
403 * Notes:
404 * The signals have to be sent in the format described in the host interface
405 * specification, i.e wire formatted. Certain clients use the host formatted
406 * structures. The write_pack() transforms the host formatted signal
407 * into the wired formatted signal. The code is in the core, since the signals
408 * are defined therefore binded to the host interface specification.
409 * ---------------------------------------------------------------------------
410 */
411int
412ul_send_signal_unpacked(unifi_priv_t *priv, CSR_SIGNAL *sigptr,
413 bulk_data_param_t *bulkdata)
414{
415 u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
416 u16 packed_siglen;
417 CsrResult csrResult;
418 unsigned long lock_flags;
419 int r;
420
421
422 csrResult = write_pack(sigptr, sigbuf, &packed_siglen);
423 if (csrResult != CSR_RESULT_SUCCESS) {
424 unifi_error(priv, "Malformed HIP signal in ul_send_signal_unpacked()\n");
425 return CsrHipResultToStatus(csrResult);
426 }
427 r = _align_bulk_data_buffers(priv, sigbuf, (bulk_data_param_t*)bulkdata);
428 if (r) {
429 return r;
430 }
431
432 spin_lock_irqsave(&priv->send_signal_lock, lock_flags);
433 csrResult = unifi_send_signal(priv->card, sigbuf, packed_siglen, bulkdata);
434 if (csrResult != CSR_RESULT_SUCCESS) {
435 /* free_bulkdata_buffers(priv, (bulk_data_param_t *)bulkdata); */
436 spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
437 return CsrHipResultToStatus(csrResult);
438 }
439 spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
440
441 return 0;
442} /* ul_send_signal_unpacked() */
443
444
445/*
446 * ---------------------------------------------------------------------------
447 * reset_driver_status
448 *
449 * This function is called from ul_send_signal_raw() when it detects
450 * that the SME has sent a MLME-RESET request.
451 *
452 * Arguments:
453 * priv Pointer to device private struct
454 *
455 * Returns:
456 * None.
457 * ---------------------------------------------------------------------------
458 */
459static void
460reset_driver_status(unifi_priv_t *priv)
461{
462 priv->sta_wmm_capabilities = 0;
463#ifdef CSR_NATIVE_LINUX
464#ifdef CSR_SUPPORT_WEXT
465 priv->wext_conf.flag_associated = 0;
466 priv->wext_conf.block_controlled_port = CSR_WIFI_ROUTER_PORT_ACTION_8021X_PORT_OPEN;
467 priv->wext_conf.bss_wmm_capabilities = 0;
468 priv->wext_conf.disable_join_on_ssid_set = 0;
469#endif
470#endif
471} /* reset_driver_status() */
472
473
474/*
475 * ---------------------------------------------------------------------------
476 * ul_send_signal_raw
477 *
478 * This function sends a wire formatted data signal to unifi.
479 *
480 * Arguments:
481 * priv Pointer to driver's private data.
482 * sigptr Pointer to the signal.
483 * siglen Length of the signal.
484 * bulkdata Pointer to the signal's bulk data.
485 *
486 * Returns:
487 * O on success, error code otherwise.
488 * ---------------------------------------------------------------------------
489 */
490int
491ul_send_signal_raw(unifi_priv_t *priv, unsigned char *sigptr, int siglen,
492 bulk_data_param_t *bulkdata)
493{
494 CsrResult csrResult;
495 unsigned long lock_flags;
496 int r;
497
498 /*
499 * Make sure that the signal is updated with the bulk data
500 * alignment for DMA.
501 */
502 r = _align_bulk_data_buffers(priv, (u8*)sigptr, bulkdata);
503 if (r) {
504 return r;
505 }
506
507 spin_lock_irqsave(&priv->send_signal_lock, lock_flags);
508 csrResult = unifi_send_signal(priv->card, sigptr, siglen, bulkdata);
509 if (csrResult != CSR_RESULT_SUCCESS) {
510 free_bulkdata_buffers(priv, bulkdata);
511 spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
512 return CsrHipResultToStatus(csrResult);
513 }
514 spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
515
516 /*
517 * Since this is use by unicli, if we get an MLME reset request
518 * we need to initialize a few status parameters
519 * that the driver uses to make decisions.
520 */
521 if (GET_SIGNAL_ID(sigptr) == CSR_MLME_RESET_REQUEST_ID) {
522 reset_driver_status(priv);
523 }
524
525 return 0;
526} /* ul_send_signal_raw() */
527
528
diff --git a/drivers/staging/csr/unifi_clients.h b/drivers/staging/csr/unifi_clients.h
deleted file mode 100644
index df853e160ea5..000000000000
--- a/drivers/staging/csr/unifi_clients.h
+++ /dev/null
@@ -1,129 +0,0 @@
1/*
2 *****************************************************************************
3 *
4 * FILE : unifi_clients.h
5 *
6 * PURPOSE : Private header file for unifi clients.
7 *
8 * UDI = UniFi Debug Interface
9 *
10 * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 *****************************************************************************
16 */
17#ifndef __LINUX_UNIFI_CLIENTS_H__
18#define __LINUX_UNIFI_CLIENTS_H__ 1
19
20#include <linux/kernel.h>
21
22#define MAX_UDI_CLIENTS 8
23
24/* The start of the range of process ids allocated for ul clients */
25#define UDI_SENDER_ID_BASE 0xC000
26#define UDI_SENDER_ID_SHIFT 8
27
28
29/* Structure to hold a UDI logged signal */
30typedef struct {
31
32 /* List link structure */
33 struct list_head q;
34
35 /* The message that will be passed to the user app */
36 udi_msg_t msg;
37
38 /* Signal body and data follow */
39
40} udi_log_t;
41
42
43
44typedef struct ul_client ul_client_t;
45
46typedef void (*udi_event_t)(ul_client_t *client,
47 const u8 *sigdata, int signal_len,
48 const bulk_data_param_t *bulkdata,
49 int dir);
50
51void logging_handler(void *ospriv,
52 u8 *sigdata, u32 signal_len,
53 const bulk_data_param_t *bulkdata,
54 enum udi_log_direction direction);
55
56
57/*
58 * Structure describing a bulk data slot.
59 * The length field is used to indicate empty/occupied state.
60 */
61typedef struct _bulk_data
62{
63 unsigned char ptr[2000];
64 unsigned int length;
65} bulk_data_t;
66
67
68struct ul_client {
69 /* Index of this client in the ul_clients array. */
70 int client_id;
71
72 /* Index of UniFi device to which this client is attached. */
73 int instance;
74
75 /* Flag to say whether this client has been enabled. */
76 int udi_enabled;
77
78 /* Value to use in signal->SenderProcessId */
79 int sender_id;
80
81 /* Configuration flags, e.g blocking, logging, etc. */
82 unsigned int configuration;
83
84 udi_event_t event_hook;
85
86 /* A list to hold signals received from UniFi for reading by read() */
87 struct list_head udi_log;
88
89 /* Semaphore to protect the udi_log list */
90 struct semaphore udi_sem;
91
92 /*
93 * Linux waitqueue to support blocking read and poll.
94 * Logging clients should wait on udi_log. while
95 * blocking clients should wait on wake_up_wq.
96 */
97 wait_queue_head_t udi_wq;
98 CSR_SIGNAL* reply_signal;
99 bulk_data_t* reply_bulkdata[UNIFI_MAX_DATA_REFERENCES];
100
101 u16 signal_filter[SIG_FILTER_SIZE];
102
103
104 /* ------------------------------------------------------------------- */
105 /* Code below here is used by the sme_native configuration only */
106
107 /* Flag to wake up blocking clients waiting on udi_wq. */
108 int wake_up_wq_id;
109
110 /*
111 * A 0x00 - 0x0F mask to apply in signal->SenderProcessId.
112 * Every time we do a blocking mlme request we increase this value.
113 * The mlme_wait_for_reply() will wait for this sequence number.
114 * Only the MLME blocking functions update this field.
115 */
116 unsigned char seq_no;
117
118 /*
119 * A 0x00 - 0x0F counter, containing the sequence number of
120 * the signal that this client has last received.
121 * Only the MLME blocking functions update this field.
122 */
123 unsigned char wake_seq_no;
124
125 unifiio_snap_filter_t snap_filter;
126}; /* struct ul_client */
127
128
129#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
index fe119707844a..000000000000
--- a/drivers/staging/csr/unifi_config.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 *
4 * FILE: unifi_config.h
5 *
6 * PURPOSE:
7 * This header file provides parameters that configure the operation
8 * of the driver.
9 *
10 * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 * ---------------------------------------------------------------------------
16 */
17#ifndef __UNIFI_CONFIG_H__
18#define __UNIFI_CONFIG_H__ 1
19
20/*
21 * Override for the SDIO function block size on this host. When byte mode CMD53s
22 * are not used/supported by the SD host controller, transfers are padded up to
23 * the next block boundary. The 512-byte default on UF6xxx wastes too much space
24 * on the chip, so the block size is reduced to support this configuration.
25 */
26#define CSR_WIFI_HIP_SDIO_BLOCK_SIZE 64
27
28/* Define the number of mini-coredump buffers to allocate at startup. These are
29 * used to record chip status for the last n unexpected resets.
30 */
31#define CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS 5
32
33
34#endif /* __UNIFI_CONFIG_H__ */
diff --git a/drivers/staging/csr/unifi_dbg.c b/drivers/staging/csr/unifi_dbg.c
deleted file mode 100644
index 38d57085a26a..000000000000
--- a/drivers/staging/csr/unifi_dbg.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: unifi_dbg.c
4 *
5 * PURPOSE:
6 * Handle debug signals received from UniFi.
7 *
8 * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
9 *
10 * Refer to LICENSE.txt included with this source code for details on
11 * the license terms.
12 *
13 * ***************************************************************************
14 */
15#include "unifi_priv.h"
16
17/*
18 * ---------------------------------------------------------------------------
19 * debug_string_indication
20 * debug_word16_indication
21 *
22 * Handlers for debug indications.
23 *
24 * Arguments:
25 * priv Pointer to private context structure.
26 *
27 * Returns:
28 * None.
29 * ---------------------------------------------------------------------------
30 */
31void
32debug_string_indication(unifi_priv_t *priv, const unsigned char *extra, unsigned int extralen)
33{
34 const unsigned int maxlen = sizeof(priv->last_debug_string) - 1;
35
36 if (extralen > maxlen) {
37 extralen = maxlen;
38 }
39
40 strncpy(priv->last_debug_string, extra, extralen);
41
42 /* Make sure the string is terminated */
43 priv->last_debug_string[extralen] = '\0';
44
45 unifi_info(priv, "unifi debug: %s\n", priv->last_debug_string);
46
47} /* debug_string_indication() */
48
49
50
51void
52debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
53{
54 int i;
55
56 if (priv == NULL) {
57 unifi_info(priv, "Priv is NULL\n");
58 return;
59 }
60
61 for (i = 0; i < 16; i++) {
62 priv->last_debug_word16[i] =
63 sigptr->u.DebugWord16Indication.DebugWords[i];
64 }
65
66 if (priv->last_debug_word16[0] == 0xFA11) {
67 unsigned long ts;
68 ts = (priv->last_debug_word16[6] << 16) | priv->last_debug_word16[5];
69 unifi_info(priv, " %10lu: %s fault %04x, arg %04x (x%d)\n",
70 ts,
71 priv->last_debug_word16[3] == 0x8000 ? "MAC" :
72 priv->last_debug_word16[3] == 0x4000 ? "PHY" :
73 "???",
74 priv->last_debug_word16[1],
75 priv->last_debug_word16[2],
76 priv->last_debug_word16[4]);
77 }
78 else if (priv->last_debug_word16[0] != 0xDBAC)
79 /* suppress SDL Trace output (note: still available to unicli). */
80 {
81 unifi_info(priv, "unifi debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
82 priv->last_debug_word16[0], priv->last_debug_word16[1],
83 priv->last_debug_word16[2], priv->last_debug_word16[3],
84 priv->last_debug_word16[4], priv->last_debug_word16[5],
85 priv->last_debug_word16[6], priv->last_debug_word16[7]);
86 unifi_info(priv, " %04X %04X %04X %04X %04X %04X %04X %04X\n",
87 priv->last_debug_word16[8], priv->last_debug_word16[9],
88 priv->last_debug_word16[10], priv->last_debug_word16[11],
89 priv->last_debug_word16[12], priv->last_debug_word16[13],
90 priv->last_debug_word16[14], priv->last_debug_word16[15]);
91 }
92
93} /* debug_word16_indication() */
94
95
96void
97debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
98{
99 unifi_info(priv, "debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
100 sigptr->u.DebugGenericIndication.DebugWords[0],
101 sigptr->u.DebugGenericIndication.DebugWords[1],
102 sigptr->u.DebugGenericIndication.DebugWords[2],
103 sigptr->u.DebugGenericIndication.DebugWords[3],
104 sigptr->u.DebugGenericIndication.DebugWords[4],
105 sigptr->u.DebugGenericIndication.DebugWords[5],
106 sigptr->u.DebugGenericIndication.DebugWords[6],
107 sigptr->u.DebugGenericIndication.DebugWords[7]);
108
109} /* debug_generic_indication() */
110
diff --git a/drivers/staging/csr/unifi_event.c b/drivers/staging/csr/unifi_event.c
deleted file mode 100644
index 71fdb2180e3d..000000000000
--- a/drivers/staging/csr/unifi_event.c
+++ /dev/null
@@ -1,692 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: unifi_event.c
4 *
5 * PURPOSE:
6 * Process the signals received by UniFi.
7 * It is part of the porting exercise.
8 *
9 * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ***************************************************************************
15 */
16
17
18/*
19 * Porting notes:
20 * The implementation of unifi_receive_event() in Linux is fairly complicated.
21 * The linux driver support multiple userspace applications and several
22 * build configurations, so the received signals are processed by different
23 * processes and multiple times.
24 * In a simple implementation, this function needs to deliver:
25 * - The MLME-UNITDATA.ind signals to the Rx data plane and to the Traffic
26 * Analysis using unifi_ta_sample().
27 * - The MLME-UNITDATA-STATUS.ind signals to the Tx data plane.
28 * - All the other signals to the SME using unifi_sys_hip_ind().
29 */
30
31#include "csr_wifi_hip_unifi.h"
32#include "csr_wifi_hip_conversions.h"
33#include "unifi_priv.h"
34
35
36/*
37 * ---------------------------------------------------------------------------
38 * send_to_client
39 *
40 * Helper for unifi_receive_event.
41 *
42 * This function forwards a signal to one client.
43 *
44 * Arguments:
45 * priv Pointer to driver's private data.
46 * client Pointer to the client structure.
47 * receiver_id The reciever id of the signal.
48 * sigdata Pointer to the packed signal buffer.
49 * siglen Length of the packed signal.
50 * bulkdata Pointer to the signal's bulk data.
51 *
52 * Returns:
53 * None.
54 *
55 * ---------------------------------------------------------------------------
56 */
57static void send_to_client(unifi_priv_t *priv, ul_client_t *client,
58 int receiver_id,
59 unsigned char *sigdata, int siglen,
60 const bulk_data_param_t *bulkdata)
61{
62 if (client && client->event_hook) {
63 /*unifi_trace(priv, UDBG3,
64 "Receive: client %d, (s:0x%X, r:0x%X) - Signal 0x%.4X \n",
65 client->client_id, client->sender_id, receiver_id,
66 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));*/
67
68 client->event_hook(client, sigdata, siglen, bulkdata, UDI_TO_HOST);
69 }
70}
71
72/*
73 * ---------------------------------------------------------------------------
74 * process_pkt_data_ind
75 *
76 * Dispatcher for received signals.
77 *
78 * This function receives the 'to host' signals and forwards
79 * them to the unifi linux clients.
80 *
81 * Arguments:
82 * priv Context
83 * sigdata Pointer to the packed signal buffer(Its in form of MA-PACKET.ind).
84 * bulkdata Pointer to signal's bulkdata
85 * freeBulkData Pointer to a flag which gets set if the bulkdata needs to
86 * be freed after calling the logging handlers. If it is not
87 * set the bulkdata must be freed by the MLME handler or
88 * passed to the network stack.
89 * Returns:
90 * TRUE if the packet should be routed to the SME etc.
91 * FALSE if the packet is for the driver or network stack
92 * ---------------------------------------------------------------------------
93 */
94static u8 check_routing_pkt_data_ind(unifi_priv_t *priv,
95 u8 *sigdata,
96 const bulk_data_param_t* bulkdata,
97 u8 *freeBulkData,
98 netInterface_priv_t *interfacePriv)
99{
100 u16 frmCtrl, receptionStatus, frmCtrlSubType;
101 u8 *macHdrLocation;
102 u8 interfaceTag;
103 u8 isDataFrame;
104 u8 isProtocolVerInvalid = FALSE;
105 u8 isDataFrameSubTypeNoData = FALSE;
106
107#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
108 static const u8 wapiProtocolIdSNAPHeader[] = {0x88, 0xb4};
109 static const u8 wapiProtocolIdSNAPHeaderOffset = 6;
110 u8 *destAddr;
111 u8 *srcAddr;
112 u8 isWapiUnicastPkt = FALSE;
113
114#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
115 u16 qosControl;
116#endif
117
118 u8 llcSnapHeaderOffset = 0;
119
120 destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET;
121 srcAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET;
122
123 /*Individual/Group bit - Bit 0 of first byte*/
124 isWapiUnicastPkt = (!(destAddr[0] & 0x01)) ? TRUE : FALSE;
125#endif
126
127#define CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22
128
129 *freeBulkData = FALSE;
130
131 /* Fetch the MAC header location from MA_PKT_IND packet */
132 macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
133 /* Fetch the Frame Control value from MAC header */
134 frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
135
136 /* Pull out interface tag from virtual interface identifier */
137 interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + 14)) & 0xff;
138
139 /* check for MIC failure before processing the signal */
140 receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET);
141
142 /* To discard any spurious MIC failures that could be reported by the firmware */
143 isDataFrame = ((frmCtrl & IEEE80211_FC_TYPE_MASK) == (IEEE802_11_FC_TYPE_DATA & IEEE80211_FC_TYPE_MASK)) ? TRUE : FALSE;
144 /* 0x00 is the only valid protocol version*/
145 isProtocolVerInvalid = (frmCtrl & IEEE80211_FC_PROTO_VERSION_MASK) ? TRUE : FALSE;
146 frmCtrlSubType = (frmCtrl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET;
147 /*Exclude the no data & reserved sub-types from MIC failure processing*/
148 isDataFrameSubTypeNoData = (((frmCtrlSubType>0x03)&&(frmCtrlSubType<0x08)) || (frmCtrlSubType>0x0B)) ? TRUE : FALSE;
149 if ((receptionStatus == CSR_MICHAEL_MIC_ERROR) &&
150 ((!isDataFrame) || isProtocolVerInvalid || (isDataFrame && isDataFrameSubTypeNoData))) {
151 /* Currently MIC errors are discarded for frames other than data frames. This might need changing when we start
152 * supporting 802.11w (Protected Management frames)
153 */
154 *freeBulkData = TRUE;
155 unifi_trace(priv, UDBG4, "Discarding this frame and ignoring the MIC failure as this is a garbage/non-data/no data frame\n");
156 return FALSE;
157 }
158
159#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
160
161 if (receptionStatus == CSR_MICHAEL_MIC_ERROR) {
162
163 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
164
165#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
166 if ((isDataFrame) &&
167 ((IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK) == (frmCtrl & IEEE80211_FC_SUBTYPE_MASK)) &&
168 (priv->isWapiConnection))
169 {
170 qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation + (((frmCtrl & IEEE802_11_FC_TO_DS_MASK) && (frmCtrl & IEEE802_11_FC_FROM_DS_MASK)) ? 30 : 24) );
171
172 unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind() :: Value of the QoS control field - 0x%04x \n", qosControl);
173
174 if (qosControl & IEEE802_11_QC_NON_TID_BITS_MASK)
175 {
176 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");
177
178 /*Exclude the MIC [16] and the PN [16] that are appended by the firmware*/
179 ((bulk_data_param_t*)bulkdata)->d[0].data_length = bulkdata->d[0].data_length - 32;
180
181 /*Clear the reception status of the signal (CSR_RX_SUCCESS)*/
182 *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET) = 0x00;
183 *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET+1) = 0x00;
184
185 *freeBulkData = FALSE;
186
187 return FALSE;
188 }
189 }
190#endif
191 /* If this MIC ERROR reported by the firmware is either for
192 * [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
193 * [2] a WAPI Unicast MPDU and either the CONTROL PORT is open or the WAPI Unicast filter or filter(s) is NOT set
194 * then report a MIC FAILURE indication to the SME.
195 */
196#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
197 if ((priv->wapi_multicast_filter == 0) || isWapiUnicastPkt) {
198#else
199 /*When SW encryption is enabled and USKID=1 (wapi_unicast_filter = 1), we are expected
200 *to receive MIC failure INDs for unicast MPDUs*/
201 if ( ((priv->wapi_multicast_filter == 0) && !isWapiUnicastPkt) ||
202 ((priv->wapi_unicast_filter == 0) && isWapiUnicastPkt) ) {
203#endif
204 /*Discard the frame*/
205 *freeBulkData = TRUE;
206 unifi_trace(priv, UDBG4, "Discarding the contents of the frame with MIC failure \n");
207
208 if (isWapiUnicastPkt &&
209 ((uf_sme_port_state(priv, srcAddr, UF_CONTROLLED_PORT_Q, interfaceTag) != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)||
210#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
211 (priv->wapi_unicast_filter) ||
212#endif
213 (priv->wapi_unicast_queued_pkt_filter))) {
214
215 /* Workaround to handle MIC failures reported by the firmware for encrypted packets from the AP
216 * while we are in the process of re-association induced by unsupported WAPI Unicast key index
217 * - Discard the packets with MIC failures "until" we have
218 * a. negotiated a key,
219 * b. opened the CONTROL PORT and
220 * c. the AP has started using the new key
221 */
222 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");
223
224 /*Ignore this MIC failure*/
225 return FALSE;
226
227 }/*WAPI re-key specific workaround*/
228
229 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n",
230 interfaceTag, srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcAddr[4], srcAddr[5]);
231 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Dest Addr %x:%x:%x:%x:%x:%x\n",
232 destAddr[0], destAddr[1], destAddr[2], destAddr[3], destAddr[4], destAddr[5]);
233 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Control Port State - 0x%.4X \n",
234 uf_sme_port_state(priv, srcAddr, UF_CONTROLLED_PORT_Q, interfaceTag));
235
236 unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
237
238 /*Report the MIC failure to the SME*/
239 return TRUE;
240 }
241 }/* STA mode */
242 else {
243 /* Its AP Mode . Just Return */
244 *freeBulkData = TRUE;
245 unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
246 return TRUE;
247 } /* AP mode */
248 }/* MIC error */
249#else
250 if (receptionStatus == CSR_MICHAEL_MIC_ERROR) {
251 *freeBulkData = TRUE;
252 unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
253 return TRUE;
254 }
255#endif /*CSR_WIFI_SECURITY_WAPI_ENABLE*/
256
257 unifi_trace(priv, UDBG4, "frmCtrl = 0x%04x %s\n",
258 frmCtrl,
259 (((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) == IEEE802_11_FRAMETYPE_MANAGEMENT) ?
260 "Mgt" : "Ctrl/Data");
261
262#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
263 /* To ignore MIC failures reported due to the WAPI AP using the old key for queued packets before
264 * starting to use the new key negotiated as part of unicast re-keying
265 */
266 if ((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA)&&
267 isWapiUnicastPkt &&
268 (receptionStatus == CSR_RX_SUCCESS) &&
269 (priv->wapi_unicast_queued_pkt_filter==1)) {
270
271 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI unicast pkt received when the (wapi_unicast_queued_pkt_filter) is set\n");
272
273 if (isDataFrame) {
274 switch(frmCtrl & IEEE80211_FC_SUBTYPE_MASK) {
275 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
276 llcSnapHeaderOffset = MAC_HEADER_SIZE + 2;
277 break;
278 case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
279 case IEEE802_11_FC_TYPE_NULL & IEEE80211_FC_SUBTYPE_MASK:
280 break;
281 default:
282 llcSnapHeaderOffset = MAC_HEADER_SIZE;
283 }
284 }
285
286 if (llcSnapHeaderOffset > 0) {
287 /* QoS data or Data */
288 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): SNAP header found & its offset %d\n", llcSnapHeaderOffset);
289 if (memcmp((u8 *)(bulkdata->d[0].os_data_ptr+llcSnapHeaderOffset+wapiProtocolIdSNAPHeaderOffset),
290 wapiProtocolIdSNAPHeader, sizeof(wapiProtocolIdSNAPHeader))) {
291
292 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): This is a data & NOT a WAI protocol packet\n");
293 /* On the first unicast data pkt that is decrypted successfully after re-keying, reset the filter */
294 priv->wapi_unicast_queued_pkt_filter = 0;
295 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");
296 }
297 else {
298 unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI - This is a WAI protocol packet\n");
299 }
300 }
301 }
302#endif
303
304
305 switch ((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) {
306 case IEEE802_11_FRAMETYPE_MANAGEMENT:
307 *freeBulkData = TRUE; /* Free (after SME handler copies it) */
308
309 /* In P2P device mode, filter the legacy AP beacons here */
310 if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2P)&&\
311 ((CSR_WIFI_80211_GET_FRAME_SUBTYPE(macHdrLocation)) == CSR_WIFI_80211_FRAME_SUBTYPE_BEACON)){
312
313 u8 *pSsid, *pSsidLen;
314 static u8 P2PWildCardSsid[CSR_WIFI_P2P_WILDCARD_SSID_LENGTH] = {'D', 'I', 'R', 'E', 'C', 'T', '-'};
315
316 pSsidLen = macHdrLocation + MAC_HEADER_SIZE + CSR_WIFI_BEACON_FIXED_LENGTH;
317 pSsid = pSsidLen + 2;
318
319 if(*(pSsidLen + 1) >= CSR_WIFI_P2P_WILDCARD_SSID_LENGTH){
320 if(memcmp(pSsid, P2PWildCardSsid, CSR_WIFI_P2P_WILDCARD_SSID_LENGTH) == 0){
321 unifi_trace(priv, UDBG6, "Received a P2P Beacon, pass it to SME\n");
322 return TRUE;
323 }
324 }
325 unifi_trace(priv, UDBG6, "Received a Legacy AP beacon in P2P mode, drop it\n");
326 return FALSE;
327 }
328 return TRUE; /* Route to SME */
329 case IEEE802_11_FRAMETYPE_DATA:
330 case IEEE802_11_FRAMETYPE_CONTROL:
331 *freeBulkData = FALSE; /* Network stack or MLME handler frees */
332 return FALSE;
333 default:
334 unifi_error(priv, "Unhandled frame type %04x\n", frmCtrl);
335 *freeBulkData = TRUE; /* Not interested, but must free it */
336 return FALSE;
337 }
338}
339
340/*
341 * ---------------------------------------------------------------------------
342 * unifi_process_receive_event
343 *
344 * Dispatcher for received signals.
345 *
346 * This function receives the 'to host' signals and forwards
347 * them to the unifi linux clients.
348 *
349 * Arguments:
350 * ospriv Pointer to driver's private data.
351 * sigdata Pointer to the packed signal buffer.
352 * siglen Length of the packed signal.
353 * bulkdata Pointer to the signal's bulk data.
354 *
355 * Returns:
356 * None.
357 *
358 * Notes:
359 * The signals are received in the format described in the host interface
360 * specification, i.e wire formatted. Certain clients use the same format
361 * to interpret them and other clients use the host formatted structures.
362 * Each client has to call read_unpack_signal() to transform the wire
363 * formatted signal into the host formatted signal, if necessary.
364 * The code is in the core, since the signals are defined therefore
365 * binded to the host interface specification.
366 * ---------------------------------------------------------------------------
367 */
368static void
369unifi_process_receive_event(void *ospriv,
370 u8 *sigdata, u32 siglen,
371 const bulk_data_param_t *bulkdata)
372{
373 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
374 int i, receiver_id;
375 int client_id;
376 s16 signal_id;
377 u8 pktIndToSme = FALSE, freeBulkData = FALSE;
378
379 unifi_trace(priv, UDBG5, "unifi_process_receive_event: "
380 "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n",
381 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF,
382 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF,
383 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF,
384 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF,
385 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF,
386 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF,
387 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF,
388 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF,
389 siglen);
390
391 receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)) & 0xFF00;
392 client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT;
393 signal_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata);
394
395
396
397 /* check for the type of frame received (checks for 802.11 management frames) */
398 if (signal_id == CSR_MA_PACKET_INDICATION_ID)
399 {
400#define CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET 14
401 u8 interfaceTag;
402 netInterface_priv_t *interfacePriv;
403
404 /* Pull out interface tag from virtual interface identifier */
405 interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff;
406 interfacePriv = priv->interfacePriv[interfaceTag];
407
408 /* Update activity for this station in case of IBSS */
409#ifdef CSR_SUPPORT_SME
410 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS)
411 {
412 u8 *saddr;
413 /* Fetch the source address from mac header */
414 saddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET;
415 unifi_trace(priv, UDBG5,
416 "Updating sta activity in IBSS interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n",
417 interfaceTag, saddr[0], saddr[1], saddr[2], saddr[3], saddr[4], saddr[5]);
418
419 uf_update_sta_activity(priv, interfaceTag, saddr);
420 }
421#endif
422
423 pktIndToSme = check_routing_pkt_data_ind(priv, sigdata, bulkdata, &freeBulkData, interfacePriv);
424
425 unifi_trace(priv, UDBG6, "RX: packet entry point to driver from HIP,pkt to SME ?(%s) \n", (pktIndToSme)? "YES":"NO");
426
427 }
428
429 if (pktIndToSme)
430 {
431 /* Management MA_PACKET_IND for SME */
432 if(sigdata != NULL && bulkdata != NULL){
433 send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata);
434 }
435 else{
436 unifi_error(priv, "unifi_receive_event2: sigdata or Bulkdata is NULL \n");
437 }
438#ifdef CSR_NATIVE_LINUX
439 send_to_client(priv, priv->wext_client,
440 receiver_id,
441 sigdata, siglen, bulkdata);
442#endif
443 }
444 else
445 {
446 /* Signals with ReceiverId==0 are also reported to SME / WEXT,
447 * unless they are data/control MA_PACKET_INDs or VIF_AVAILABILITY_INDs
448 */
449 if (!receiver_id) {
450 if(signal_id == CSR_MA_VIF_AVAILABILITY_INDICATION_ID) {
451 uf_process_ma_vif_availibility_ind(priv, sigdata, siglen);
452 }
453 else if (signal_id != CSR_MA_PACKET_INDICATION_ID) {
454 send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata);
455#ifdef CSR_NATIVE_LINUX
456 send_to_client(priv, priv->wext_client,
457 receiver_id,
458 sigdata, siglen, bulkdata);
459#endif
460 }
461 else
462 {
463
464#if (defined(CSR_SUPPORT_SME) && defined(CSR_WIFI_SECURITY_WAPI_ENABLE))
465 #define CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22
466 netInterface_priv_t *interfacePriv;
467 u8 interfaceTag;
468 u16 receptionStatus = CSR_RX_SUCCESS;
469
470 /* Pull out interface tag from virtual interface identifier */
471 interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff;
472 interfacePriv = priv->interfacePriv[interfaceTag];
473
474 /* check for MIC failure */
475 receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET);
476
477 /* Send a WAPI MPDU to SME for re-check MIC if the respective filter has been set*/
478 if ((!freeBulkData) &&
479 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) &&
480 (receptionStatus == CSR_MICHAEL_MIC_ERROR) &&
481 ((priv->wapi_multicast_filter == 1)
482#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
483 || (priv->wapi_unicast_filter == 1)
484#endif
485 ))
486 {
487 CSR_SIGNAL signal;
488 u8 *destAddr;
489 CsrResult res;
490 u16 interfaceTag = 0;
491 u8 isMcastPkt = TRUE;
492
493 unifi_trace(priv, UDBG6, "Received a WAPI data packet when the Unicast/Multicast filter is set\n");
494 res = read_unpack_signal(sigdata, &signal);
495 if (res) {
496 unifi_error(priv, "Received unknown or corrupted signal (0x%x).\n",
497 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
498 return;
499 }
500
501 /* Check if the type of MPDU and the respective filter status*/
502 destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET;
503 isMcastPkt = (destAddr[0] & 0x01) ? TRUE : FALSE;
504 unifi_trace(priv, UDBG6,
505 "1.MPDU type: (%s), 2.Multicast filter: (%s), 3. Unicast filter: (%s)\n",
506 ((isMcastPkt) ? "Multiast":"Unicast"),
507 ((priv->wapi_multicast_filter) ? "Enabled":"Disabled"),
508 ((priv->wapi_unicast_filter) ? "Enabled":"Disabled"));
509
510 if (((isMcastPkt) && (priv->wapi_multicast_filter == 1))
511#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
512 || ((!isMcastPkt) && (priv->wapi_unicast_filter == 1))
513#endif
514 )
515 {
516 unifi_trace(priv, UDBG4, "Sending the WAPI MPDU for MIC check\n");
517 CsrWifiRouterCtrlWapiRxMicCheckIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, siglen, sigdata, bulkdata->d[0].data_length, (u8*)bulkdata->d[0].os_data_ptr);
518
519 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
520 if (bulkdata->d[i].data_length != 0) {
521 unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
522 }
523 }
524 return;
525 }
526 } /* CSR_MA_PACKET_INDICATION_ID */
527#endif /*CSR_SUPPORT_SME && CSR_WIFI_SECURITY_WAPI_ENABLE*/
528 }
529 }
530
531 /* calls the registered clients handler callback func.
532 * netdev_mlme_event_handler is one of the registered handler used to route
533 * data packet to network stack or AMP/EAPOL related data to SME
534 *
535 * The freeBulkData check ensures that, it has received a management frame and
536 * the frame needs to be freed here. So not to be passed to netdev handler
537 */
538 if(!freeBulkData){
539 if ((client_id < MAX_UDI_CLIENTS) &&
540 (&priv->ul_clients[client_id] != priv->logging_client)) {
541 unifi_trace(priv, UDBG6, "Call the registered clients handler callback func\n");
542 send_to_client(priv, &priv->ul_clients[client_id],
543 receiver_id,
544 sigdata, siglen, bulkdata);
545 }
546 }
547 }
548
549 /*
550 * Free bulk data buffers here unless it is a CSR_MA_PACKET_INDICATION
551 */
552 switch (signal_id)
553 {
554#ifdef UNIFI_SNIFF_ARPHRD
555 case CSR_MA_SNIFFDATA_INDICATION_ID:
556#endif
557 break;
558
559 case CSR_MA_PACKET_INDICATION_ID:
560 if (!freeBulkData)
561 {
562 break;
563 }
564 /* FALLS THROUGH... */
565 default:
566 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
567 if (bulkdata->d[i].data_length != 0) {
568 unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
569 }
570 }
571 }
572
573} /* unifi_process_receive_event() */
574
575
576#ifdef CSR_WIFI_RX_PATH_SPLIT
577static u8 signal_buffer_is_full(unifi_priv_t* priv)
578{
579 return (((priv->rxSignalBuffer.writePointer + 1)% priv->rxSignalBuffer.size) == (priv->rxSignalBuffer.readPointer));
580}
581
582void unifi_rx_queue_flush(void *ospriv)
583{
584 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
585
586 unifi_trace(priv, UDBG4, "rx_wq_handler: RdPtr = %d WritePtr = %d\n",
587 priv->rxSignalBuffer.readPointer, priv->rxSignalBuffer.writePointer);
588 if(priv != NULL) {
589 u8 readPointer = priv->rxSignalBuffer.readPointer;
590 while (readPointer != priv->rxSignalBuffer.writePointer)
591 {
592 rx_buff_struct_t *buf = &priv->rxSignalBuffer.rx_buff[readPointer];
593 unifi_trace(priv, UDBG6, "rx_wq_handler: RdPtr = %d WritePtr = %d\n",
594 readPointer, priv->rxSignalBuffer.writePointer);
595 unifi_process_receive_event(priv, buf->bufptr, buf->sig_len, &buf->data_ptrs);
596 readPointer ++;
597 if(readPointer >= priv->rxSignalBuffer.size) {
598 readPointer = 0;
599 }
600 }
601 priv->rxSignalBuffer.readPointer = readPointer;
602 }
603}
604
605void rx_wq_handler(struct work_struct *work)
606{
607 unifi_priv_t *priv = container_of(work, unifi_priv_t, rx_work_struct);
608 unifi_rx_queue_flush(priv);
609}
610#endif
611
612
613
614/*
615 * ---------------------------------------------------------------------------
616 * unifi_receive_event
617 *
618 * Dispatcher for received signals.
619 *
620 * This function receives the 'to host' signals and forwards
621 * them to the unifi linux clients.
622 *
623 * Arguments:
624 * ospriv Pointer to driver's private data.
625 * sigdata Pointer to the packed signal buffer.
626 * siglen Length of the packed signal.
627 * bulkdata Pointer to the signal's bulk data.
628 *
629 * Returns:
630 * None.
631 *
632 * Notes:
633 * The signals are received in the format described in the host interface
634 * specification, i.e wire formatted. Certain clients use the same format
635 * to interpret them and other clients use the host formatted structures.
636 * Each client has to call read_unpack_signal() to transform the wire
637 * formatted signal into the host formatted signal, if necessary.
638 * The code is in the core, since the signals are defined therefore
639 * binded to the host interface specification.
640 * ---------------------------------------------------------------------------
641 */
642void
643unifi_receive_event(void *ospriv,
644 u8 *sigdata, u32 siglen,
645 const bulk_data_param_t *bulkdata)
646{
647#ifdef CSR_WIFI_RX_PATH_SPLIT
648 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
649 u8 writePointer;
650 int i;
651 rx_buff_struct_t * rx_buff;
652
653 unifi_trace(priv, UDBG5, "unifi_receive_event: "
654 "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n",
655 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF,
656 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF,
657 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF,
658 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF,
659 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF,
660 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF,
661 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF,
662 CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF, siglen);
663 if(signal_buffer_is_full(priv)) {
664 unifi_error(priv, "TO HOST signal queue FULL dropping the PDU\n");
665 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
666 if (bulkdata->d[i].data_length != 0) {
667 unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
668 }
669 }
670 return;
671 }
672 writePointer = priv->rxSignalBuffer.writePointer;
673 rx_buff = &priv->rxSignalBuffer.rx_buff[writePointer];
674 memcpy(rx_buff->bufptr, sigdata, siglen);
675 rx_buff->sig_len = siglen;
676 rx_buff->data_ptrs = *bulkdata;
677 writePointer++;
678 if(writePointer >= priv->rxSignalBuffer.size) {
679 writePointer =0;
680 }
681 unifi_trace(priv, UDBG4, "unifi_receive_event:writePtr = %d\n", priv->rxSignalBuffer.writePointer);
682 priv->rxSignalBuffer.writePointer = writePointer;
683
684#ifndef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
685 queue_work(priv->rx_workqueue, &priv->rx_work_struct);
686#endif
687
688#else
689 unifi_process_receive_event(ospriv, sigdata, siglen, bulkdata);
690#endif
691} /* unifi_receive_event() */
692
diff --git a/drivers/staging/csr/unifi_native.h b/drivers/staging/csr/unifi_native.h
deleted file mode 100644
index a73b38e5e480..000000000000
--- a/drivers/staging/csr/unifi_native.h
+++ /dev/null
@@ -1,257 +0,0 @@
1/*
2 *****************************************************************************
3 *
4 * FILE : unifi_native.h
5 *
6 * PURPOSE : Private header file for unifi driver support to wireless extensions.
7 *
8 * UDI = UniFi Debug Interface
9 *
10 * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 *****************************************************************************
16 */
17#ifndef __LINUX_UNIFI_NATIVE_H__
18#define __LINUX_UNIFI_NATIVE_H__ 1
19
20#include <linux/kernel.h>
21#include <linux/if_arp.h>
22
23
24/*
25 * scan.c wext.c autojoin.c
26 */
27/* Structure to hold results of a scan */
28typedef struct scan_info {
29
30/* CSR_MLME_SCAN_INDICATION msi; */
31
32 unsigned char *info_elems;
33 int info_elem_length;
34
35} scan_info_t;
36
37
38#define IE_VECTOR_MAXLEN 1024
39
40#ifdef CSR_SUPPORT_WEXT
41/*
42 * Structre to hold the wireless network configuration info.
43 */
44struct wext_config {
45
46 /* Requested channel when setting up an adhoc network */
47 int channel;
48
49 /* wireless extns mode: IW_MODE_AUTO, ADHOC, INFRA, MASTER ... MONITOR */
50 int mode;
51
52 /* The capabilities of the currently joined network */
53 int capability;
54
55 /* The interval between beacons if we create an IBSS */
56 int beacon_period;
57
58 /*
59 * Power-save parameters
60 */
61 /* The listen interval to ask for in Associate req. */
62 int assoc_listen_interval;
63 /* Power-mode to put UniFi into */
64
65 unsigned char desired_ssid[UNIFI_MAX_SSID_LEN]; /* the last ESSID set by SIOCSIWESSID */
66 int power_mode;
67 /* Whether to wake for broadcast packets (using DTIM interval) */
68 int wakeup_for_dtims;
69
70 /* Currently selected WEP Key ID (0..3) */
71 int wep_key_id;
72
73 wep_key_t wep_keys[NUM_WEPKEYS];
74
75/* CSR_AUTHENTICATION_TYPE auth_type; */
76 int privacy;
77
78 u32 join_failure_timeout;
79 u32 auth_failure_timeout;
80 u32 assoc_failure_timeout;
81
82 unsigned char generic_ie[IE_VECTOR_MAXLEN];
83 int generic_ie_len;
84
85 struct iw_statistics wireless_stats;
86
87
88 /* the ESSID we are currently associated to */
89 unsigned char current_ssid[UNIFI_MAX_SSID_LEN];
90 /* the BSSID we are currently associated to */
91 unsigned char current_bssid[6];
92
93 /*
94 * IW_AUTH_WPA_VERSION_DISABLED 0x00000001
95 * IW_AUTH_WPA_VERSION_WPA 0x00000002
96 * IW_AUTH_WPA_VERSION_WPA2 0x00000004
97 */
98 unsigned char wpa_version;
99
100 /*
101 * cipher selection:
102 * IW_AUTH_CIPHER_NONE 0x00000001
103 * IW_AUTH_CIPHER_WEP40 0x00000002
104 * IW_AUTH_CIPHER_TKIP 0x00000004
105 * IW_AUTH_CIPHER_CCMP 0x00000008
106 * IW_AUTH_CIPHER_WEP104 0x00000010
107 */
108 unsigned char pairwise_cipher_used;
109 unsigned char group_cipher_used;
110
111 unsigned int frag_thresh;
112 unsigned int rts_thresh;
113
114 /* U-APSD value, send with Association Request to WMM Enabled APs */
115 unsigned char wmm_bss_uapsd_mask;
116 /* The WMM capabilities of the selected BSS */
117 unsigned int bss_wmm_capabilities;
118
119 /* Flag to prevent a join when the ssid is set */
120 int disable_join_on_ssid_set;
121
122 /* Scan info */
123#define UNIFI_MAX_SCANS 32
124 scan_info_t scan_list[UNIFI_MAX_SCANS];
125 int num_scan_info;
126
127 /* Flag on whether non-802.1x packets are allowed out */
128/* CsrWifiRouterPortAction block_controlled_port;*/
129
130 /* Flag on whether we have completed an authenticate/associate process */
131 unsigned int flag_associated : 1;
132}; /* struct wext_config */
133
134#endif /* CSR_SUPPORT_WEXT */
135
136
137/*
138 * wext.c
139 */
140/*int mlme_set_protection(unifi_priv_t *priv, unsigned char *addr,
141 CSR_PROTECT_TYPE prot, CSR_KEY_TYPE key_type);
142*/
143
144/*
145 * scan.c
146 */
147/*
148void unifi_scan_indication_handler(unifi_priv_t *priv,
149 const CSR_MLME_SCAN_INDICATION *msg,
150 const unsigned char *extra,
151 unsigned int len);
152*/
153void unifi_clear_scan_table(unifi_priv_t *priv);
154scan_info_t *unifi_get_scan_report(unifi_priv_t *priv, int index);
155
156
157/*
158 * Utility functions
159 */
160const unsigned char *unifi_find_info_element(int id,
161 const unsigned char *info,
162 int len);
163int unifi_add_info_element(unsigned char *info,
164 int ie_id,
165 const unsigned char *ie_data,
166 int ie_len);
167
168/*
169 * autojoin.c
170 */
171/* Higher level fns */
172int unifi_autojoin(unifi_priv_t *priv, const char *ssid);
173/*
174int unifi_do_scan(unifi_priv_t *priv, int scantype, CSR_BSS_TYPE bsstype,
175 const char *ssid, int ssid_len);
176*/
177int unifi_set_powermode(unifi_priv_t *priv);
178int unifi_join_ap(unifi_priv_t *priv, scan_info_t *si);
179int unifi_join_bss(unifi_priv_t *priv, unsigned char *macaddr);
180int unifi_leave(unifi_priv_t *priv);
181unsigned int unifi_get_wmm_bss_capabilities(unifi_priv_t *priv,
182 unsigned char *ie_vector,
183 int ie_len, int *ap_capabilities);
184
185/*
186 * Status and management.
187 */
188int uf_init_wext_interface(unifi_priv_t *priv);
189void uf_deinit_wext_interface(unifi_priv_t *priv);
190
191/*
192 * Function to reset UniFi's 802.11 state by sending MLME-RESET.req
193 */
194int unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr, unsigned char set_default_mib);
195
196
197/*
198 * mlme.c
199 */
200/* Abort an MLME operation - useful in error recovery */
201int uf_abort_mlme(unifi_priv_t *priv);
202
203int unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
204 CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
205 int timeout);
206void unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
207 CSR_SIGNAL *signal, int signal_len,
208 const bulk_data_param_t *bulkdata);
209
210/*
211 * Utility functions
212 */
213const char *lookup_reason_code(int reason);
214const char *lookup_result_code(int result);
215
216
217/*
218 * sme_native.c
219 */
220int uf_sme_init(unifi_priv_t *priv);
221void uf_sme_deinit(unifi_priv_t *priv);
222int sme_sys_suspend(unifi_priv_t *priv);
223int sme_sys_resume(unifi_priv_t *priv);
224int sme_mgt_wifi_on(unifi_priv_t *priv);
225
226/* Callback for event logging to SME clients (unifi_manager) */
227void sme_native_log_event(ul_client_t *client,
228 const u8 *sig_packed, int sig_len,
229 const bulk_data_param_t *bulkdata,
230 int dir);
231
232void sme_native_mlme_event_handler(ul_client_t *pcli,
233 const u8 *sig_packed, int sig_len,
234 const bulk_data_param_t *bulkdata,
235 int dir);
236
237/* Task to query statistics from the MIB */
238#define UF_SME_STATS_WQ_TIMEOUT 2000 /* in msecs */
239void uf_sme_stats_wq(struct work_struct *work);
240
241void uf_native_process_udi_signal(ul_client_t *pcli,
242 const u8 *packed_signal,
243 int packed_signal_len,
244 const bulk_data_param_t *bulkdata, int dir);
245#ifdef UNIFI_SNIFF_ARPHRD
246/*
247 * monitor.c
248 */
249int uf_start_sniff(unifi_priv_t *priv);
250/*
251void ma_sniffdata_ind(void *ospriv,
252 const CSR_MA_SNIFFDATA_INDICATION *ind,
253 const bulk_data_param_t *bulkdata);
254*/
255#endif /* ARPHRD_IEEE80211_PRISM */
256
257#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
index 56a26982070e..000000000000
--- a/drivers/staging/csr/unifi_os.h
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 *
4 * FILE: os_linux/unifi_os.h
5 *
6 * PURPOSE:
7 * This header file provides the OS-dependent facilities for a linux
8 * environment.
9 *
10 * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 * ---------------------------------------------------------------------------
16 */
17#ifndef __UNIFI_OS_LINUX_H__
18#define __UNIFI_OS_LINUX_H__ 1
19
20#include <linux/kernel.h>
21#include <linux/time.h>
22#include <linux/list.h>
23#include <linux/delay.h>
24#include <linux/string.h>
25
26/*
27 * Needed for core/signals.c
28 */
29#include <stddef.h>
30
31
32/* Define INLINE directive*/
33#define INLINE inline
34
35/* Malloc and free */
36CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
37void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
38#define CSR_WIFI_ALIGN_BYTES 4
39CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot);
40
41/*
42 * Byte Order
43 * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value!
44 */
45#ifdef __KERNEL__
46#define unifi2host_16(n) (__le16_to_cpu((n)))
47#define unifi2host_32(n) (__le32_to_cpu((n)))
48#define host2unifi_16(n) (__cpu_to_le16((n)))
49#define host2unifi_32(n) (__cpu_to_le32((n)))
50#endif
51
52/* Module parameters */
53extern int unifi_debug;
54
55/* debugging */
56#ifdef UNIFI_DEBUG
57/*
58 * unifi_debug is a verbosity level for debug messages
59 * UDBG0 msgs are always printed if UNIFI_DEBUG is defined
60 * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0
61 * etc.
62 */
63
64#define ASSERT(cond) \
65 do { \
66 if (!(cond)) { \
67 printk("Assertion failed in %s at %s:%d: %s\n", \
68 __FUNCTION__, __FILE__, __LINE__, #cond); \
69 } \
70 } while (0)
71
72
73void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
74void dump(void *mem, u16 len);
75void dump16(void *mem, u16 len);
76#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
77void dump_str(void *mem, u16 len);
78#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
79
80void unifi_error(void* ospriv, const char *fmt, ...);
81void unifi_warning(void* ospriv, const char *fmt, ...);
82void unifi_notice(void* ospriv, const char *fmt, ...);
83void unifi_info(void* ospriv, const char *fmt, ...);
84
85void unifi_trace(void* ospriv, int level, const char *fmt, ...);
86
87#else
88
89/* Stubs */
90
91#define ASSERT(cond)
92
93static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
94static inline void dump(void *mem, u16 len) {}
95static inline void dump16(void *mem, u16 len) {}
96#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
97static inline void dump_str(void *mem, u16 len) {}
98#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
99
100void unifi_error_nop(void* ospriv, const char *fmt, ...);
101void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
102#define unifi_error if(1);else unifi_error_nop
103#define unifi_warning if(1);else unifi_error_nop
104#define unifi_notice if(1);else unifi_error_nop
105#define unifi_info if(1);else unifi_error_nop
106#define unifi_trace if(1);else unifi_trace_nop
107
108#endif /* UNIFI_DEBUG */
109
110
111/* Different levels of diagnostic detail... */
112#define UDBG0 0 /* always prints in debug build */
113#define UDBG1 1
114#define UDBG2 2
115#define UDBG3 3
116#define UDBG4 4
117#define UDBG5 5
118#define UDBG6 6
119#define UDBG7 7
120
121
122#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
index 04fe9e2acf0e..000000000000
--- a/drivers/staging/csr/unifi_pdu_processing.c
+++ /dev/null
@@ -1,3729 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: unifi_pdu_processing.c
4 *
5 * PURPOSE:
6 * This file provides the PDU handling functionality before it gets sent to unfi and after
7 * receiving a PDU from unifi
8 *
9 * Copyright (C) 2010 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16
17#include <linux/types.h>
18#include <linux/etherdevice.h>
19#include <linux/vmalloc.h>
20
21#include "csr_wifi_hip_unifi.h"
22#include "csr_wifi_hip_conversions.h"
23#include "csr_time.h"
24#include "unifi_priv.h"
25#include <net/pkt_sched.h>
26
27#ifdef CSR_SUPPORT_SME
28static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
29 tx_buffered_packets_t* buffered_pkt)
30{
31 struct sk_buff *skb ;
32 u32 align_offset;
33
34 if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){
35 return;
36 }
37
38 skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
39 align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
40 if(align_offset){
41 skb_pull(skb, align_offset);
42 }
43
44 buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
45 buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length;
46 buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
47 buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
48}
49#endif
50
51void
52unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
53 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
54 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
55 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
56 CSR_SIGNAL *signal)
57{
58
59 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
60 netInterface_priv_t *interfacePriv;
61 u8 ba_session_idx = 0;
62 ba_session_tx_struct *ba_session = NULL;
63 u8 *ba_addr = NULL;
64
65 interfacePriv = priv->interfacePriv[interfaceTag];
66
67 unifi_trace(priv, UDBG5,
68 "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n",
69 peerMacAddress);
70 signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
71 signal->SignalPrimitiveHeader.ReceiverProcessId = 0;
72 signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId;
73
74 /* Fill the MA-PACKET.req */
75 req->Priority = priority;
76 unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority);
77
78 /* A value of 0 is used for auto selection of rates. But for P2P GO case
79 * for action frames the rate is governed by SME. Hence instead of 0,
80 * the rate is filled in with the value passed here
81 */
82 req->TransmitRate = TransmitRate;
83
84 /* packets from netdev then no confirm required but packets from
85 * Nme/Sme eapol data frames requires the confirmation
86 */
87 req->TransmissionControl = transmissionControl;
88 req->VirtualInterfaceIdentifier =
89 uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag);
90 memcpy(req->Ra.x, peerMacAddress, ETH_ALEN);
91
92 if (hostTag == 0xffffffff) {
93 req->HostTag = interfacePriv->tag++;
94 req->HostTag |= 0x40000000;
95 unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag);
96 interfacePriv->tag &= 0x0fffffff;
97 } else {
98 req->HostTag = hostTag;
99 unifi_trace(priv, UDBG3, "host tag got from SME = 0x%x\n", req->HostTag);
100 }
101 /* check if BA session exists for the peer MAC address on same tID */
102 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
103 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
104 ba_addr = peerMacAddress;
105 }else{
106 ba_addr = interfacePriv->bssid.a;
107 }
108 for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
109 ba_session = interfacePriv->ba_session_tx[ba_session_idx];
110 if (ba_session){
111 if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){
112 req->TransmissionControl |= CSR_ALLOW_BA;
113 break;
114 }
115 }
116 }
117
118 unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n");
119}
120
121#ifdef CSR_SUPPORT_SME
122
123#define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001
124#define TRANSMISSION_CONTROL_EOSP_MASK 0x0002
125
126static
127int frame_and_send_queued_pdu(unifi_priv_t* priv, tx_buffered_packets_t* buffered_pkt,
128 CsrWifiRouterCtrlStaInfo_t *staRecord, u8 moreData , u8 eosp)
129{
130
131 CSR_SIGNAL signal;
132 bulk_data_param_t bulkdata;
133 int result;
134 u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE;
135 u8 *qc;
136 u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr);
137 unsigned long lock_flags;
138 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n", moreData, eosp);
139 unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag,
140 buffered_pkt->interfaceTag, buffered_pkt->transmissionControl,
141 buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal);
142 bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr;
143 bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length;
144 bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr;
145 bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length;
146 bulkdata.d[1].os_data_ptr = NULL;
147 bulkdata.d[1].data_length = 0;
148 bulkdata.d[1].os_net_buf_ptr =0;
149 bulkdata.d[1].net_buf_length =0;
150
151 if(moreData) {
152 *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK);
153 } else {
154 *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK);
155 }
156
157 if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE))
158 {
159 unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n", staRecord->wmmOrQosEnabled);
160
161 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
162 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
163
164 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
165 {
166 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
167 case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
168 /* If both are set then the Address4 exists (only for AP) */
169 if (fromDs && toDs) {
170 /* 6 is the size of Address4 field */
171 macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
172 } else {
173 macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
174 }
175
176 /* If order bit set then HT control field is the part of MAC header */
177 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
178 macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
179 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6));
180 } else {
181 qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2));
182 }
183 *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4));
184 break;
185 default:
186 if (fromDs && toDs)
187 macHeaderLengthInBytes += 6;
188 }
189
190 }
191 result = ul_send_signal_unpacked(priv, &signal, &bulkdata);
192 if(result){
193 _update_buffered_pkt_params_after_alignment(priv, &bulkdata, buffered_pkt);
194 }
195
196 /* Decrement the packet counts queued in driver */
197 if (result != -ENOSPC) {
198 /* protect entire counter updation by disabling preemption */
199 if (!priv->noOfPktQueuedInDriver) {
200 unifi_error(priv, "packets queued in driver 0 still decrementing\n");
201 } else {
202 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
203 priv->noOfPktQueuedInDriver--;
204 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
205 }
206 /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
207 if (staRecord) {
208 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
209 if (!staRecord->noOfPktQueued) {
210 unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n");
211 } else {
212 staRecord->noOfPktQueued--;
213 }
214 /* if the STA alive probe frame has failed then reset the saved host tag */
215 if (result){
216 if (staRecord->nullDataHostTag == buffered_pkt->hostTag){
217 staRecord->nullDataHostTag = INVALID_HOST_TAG;
218 }
219 }
220 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
221 }
222
223 }
224 return result;
225}
226#ifdef CSR_SUPPORT_SME
227static
228void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList)
229{
230 /* dequeue the tx data packets from the appropriate queue */
231 tx_buffered_packets_t *tx_q_item = NULL;
232 struct list_head *listHead;
233 struct list_head *placeHolder;
234 unsigned long lock_flags;
235
236
237 unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n");
238 /* check for list empty */
239 if (list_empty(txList)) {
240 unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n");
241 return;
242 }
243
244 /* return the last node , and modify it. */
245
246 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
247 list_for_each_prev_safe(listHead, placeHolder, txList) {
248 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
249 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
250 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
251 unifi_trace(priv, UDBG1,
252 "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n", tx_q_item->transmissionControl, tx_q_item->hostTag);
253 unifi_trace(priv, UDBG3, "in set_eosp_transmit_ctrl no.of buffered frames %d\n", priv->noOfPktQueuedInDriver);
254 break;
255 }
256 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
257 unifi_trace(priv, UDBG1, "List Empty %d\n", list_empty(txList));
258 unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n");
259 return;
260}
261
262static
263void send_vif_availibility_rsp(unifi_priv_t *priv, CSR_VIF_IDENTIFIER vif, CSR_RESULT_CODE resultCode)
264{
265 CSR_SIGNAL signal;
266 CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp;
267 bulk_data_param_t *bulkdata = NULL;
268 int r;
269
270 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode);
271
272 memset(&signal, 0, sizeof(CSR_SIGNAL));
273 rsp = &signal.u.MaVifAvailabilityResponse;
274 rsp->VirtualInterfaceIdentifier = vif;
275 rsp->ResultCode = resultCode;
276 signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID;
277 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
278 signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
279
280 /* Send the signal to UniFi */
281 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
282 if(r) {
283 unifi_error(priv, "Availibility response sending failed %x status %d\n", vif, r);
284 }
285 else {
286 unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r);
287 }
288}
289#endif
290
291static
292void verify_and_accomodate_tx_packet(unifi_priv_t *priv)
293{
294 tx_buffered_packets_t *tx_q_item;
295 unsigned long lock_flags;
296 struct list_head *listHead, *list;
297 struct list_head *placeHolder;
298 u8 i, j, eospFramedeleted=0;
299 u8 thresholdExcedeDueToBroadcast = TRUE;
300 /* it will be made it interface Specific in the future when multi interfaces are supported ,
301 right now interface 0 is considered */
302 netInterface_priv_t *interfacePriv = priv->interfacePriv[0];
303 CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
304
305 unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n");
306
307 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
308 staInfo = interfacePriv->staInfo[i];
309 if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) {
310 /* remove the first(oldest) packet from the all the access catogory, since data
311 * packets for station record crossed the threshold limit (64 for AP supporting
312 * 8 peers)
313 */
314 unifi_trace(priv, UDBG3, "number of station pkts queued= %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid);
315 for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
316 list = &staInfo->dataPdu[j];
317 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
318 list_for_each_safe(listHead, placeHolder, list) {
319 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
320 list_del(listHead);
321 thresholdExcedeDueToBroadcast = FALSE;
322 unifi_net_data_free(priv, &tx_q_item->bulkdata);
323 kfree(tx_q_item);
324 tx_q_item = NULL;
325 if (!priv->noOfPktQueuedInDriver) {
326 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
327 } else {
328 /* protection provided by spinlock */
329 priv->noOfPktQueuedInDriver--;
330
331 }
332 /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
333 if (!staInfo->noOfPktQueued) {
334 unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__);
335 } else {
336 spin_lock(&priv->staRecord_lock);
337 staInfo->noOfPktQueued--;
338 spin_unlock(&priv->staRecord_lock);
339 }
340 break;
341 }
342 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
343 }
344 }
345 }
346 if (thresholdExcedeDueToBroadcast && interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) {
347 /* Remove the packets from genericMulticastOrBroadCastFrames queue
348 * (the max packets in driver is reached due to broadcast/multicast frames)
349 */
350 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
351 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
352 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
353 if(eospFramedeleted){
354 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
355 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
356 unifi_trace(priv, UDBG1, "updating eosp for next packet hostTag:= 0x%x ", tx_q_item->hostTag);
357 eospFramedeleted =0;
358 break;
359 }
360
361 if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){
362 eospFramedeleted = 1;
363 }
364 unifi_trace(priv, UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n", tx_q_item->transmissionControl, tx_q_item->hostTag);
365 list_del(listHead);
366 unifi_net_data_free(priv, &tx_q_item->bulkdata);
367 kfree(tx_q_item);
368 priv->noOfPktQueuedInDriver--;
369 spin_lock(&priv->staRecord_lock);
370 interfacePriv->noOfbroadcastPktQueued--;
371 spin_unlock(&priv->staRecord_lock);
372 if(!eospFramedeleted){
373 break;
374 }
375 }
376 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
377 }
378 unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n");
379}
380
381static
382CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
383 struct list_head *list, CSR_SIGNAL *signal,
384 u8 requeueOnSamePos)
385{
386
387 /* queue the tx data packets on to appropriate queue */
388 CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
389 tx_buffered_packets_t *tx_q_item;
390 unsigned long lock_flags;
391
392 unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n");
393 if(!list) {
394 unifi_error(priv, "List is not specified\n");
395 return CSR_RESULT_FAILURE;
396 }
397
398 /* Removes aged packets & adds the incoming packet */
399 if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) {
400 unifi_trace(priv, UDBG3, "number of pkts queued= %d \n", priv->noOfPktQueuedInDriver);
401 verify_and_accomodate_tx_packet(priv);
402 }
403
404
405
406 tx_q_item = kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
407 if (tx_q_item == NULL) {
408 unifi_error(priv,
409 "Failed to allocate %d bytes for tx packet record\n",
410 sizeof(tx_buffered_packets_t));
411 return CSR_RESULT_FAILURE;
412 }
413
414 /* disable the preemption */
415 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
416 INIT_LIST_HEAD(&tx_q_item->q);
417 /* fill the tx_q structure members */
418 tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
419 tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length;
420 tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
421 tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
422 tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
423 tx_q_item->hostTag = req->HostTag;
424 tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId;
425 tx_q_item->transmissionControl = req->TransmissionControl;
426 tx_q_item->priority = req->Priority;
427 tx_q_item->rate = req->TransmitRate;
428 memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN);
429
430
431
432 if (requeueOnSamePos) {
433 list_add(&tx_q_item->q, list);
434 } else {
435 list_add_tail(&tx_q_item->q, list);
436 }
437
438 /* Count of packet queued in driver */
439 priv->noOfPktQueuedInDriver++;
440 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
441 unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n");
442 return CSR_RESULT_SUCCESS;
443}
444
445#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
446CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag,
447 u16 txStatus, bulk_data_desc_t *bulkDataDesc)
448{
449 CsrResult status = CSR_RESULT_SUCCESS;
450 unifi_priv_t *priv = (unifi_priv_t*)ospriv;
451 netInterface_priv_t *interfacePriv;
452 struct list_head *list = NULL;
453 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
454 bulk_data_param_t bulkData;
455 CSR_SIGNAL signal;
456 CSR_PRIORITY priority = 0;
457 u16 interfaceTag = 0;
458 unifi_TrafficQueue priority_q;
459 u16 frameControl = 0, frameType = 0;
460 unsigned long lock_flags;
461
462 interfacePriv = priv->interfacePriv[interfaceTag];
463
464 /* If the current mode is not AP or P2PGO then just return failure
465 * to clear the hip slot
466 */
467 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
468 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) {
469 return CSR_RESULT_FAILURE;
470 }
471
472 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag);
473
474 staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,
475 (((u8 *) bulkDataDesc->os_data_ptr) + 4),
476 interfaceTag);
477 if (NULL == staRecord) {
478 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n");
479 return CSR_RESULT_FAILURE;
480 }
481
482 /* Update TIM if MA-PACKET.cfm fails with status as Tx-retry-limit or No-BSS and then just return failure
483 * to clear the hip slot associated with the Packet
484 */
485 if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) {
486 if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING)
487 {
488 unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n");
489 if (!staRecord->timRequestPendingFlag) {
490 update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle);
491 }
492 else {
493 /* Cache the TimSet value so that it will processed immidiatly after
494 * completing the current setTim Request
495 */
496 staRecord->updateTimReqQueued = 1;
497 unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n",
498 staRecord->updateTimReqQueued, staRecord->aid);
499 }
500 }
501 return CSR_RESULT_FAILURE;
502 }
503 else if ((CSR_TX_LIFETIME == txStatus) || (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) ||
504 (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) ||
505 (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus) ||
506 (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) {
507 /* Extract the Frame control and the frame type */
508 frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr);
509 frameType = ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
510
511 /* Mgmt frames will not be re-queued for Tx
512 * so just return failure to clear the hip slot
513 */
514 if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) {
515 return CSR_RESULT_FAILURE;
516 }
517 else if (IEEE802_11_FRAMETYPE_DATA == frameType) {
518 /* QOS NULL and DATA NULL frames will not be re-queued for Tx
519 * so just return failure to clear the hip slot
520 */
521 if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) ||
522 (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) {
523 return CSR_RESULT_FAILURE;
524 }
525 }
526
527 /* Extract the Packet priority */
528 if (TRUE == staRecord->wmmOrQosEnabled) {
529 u16 qosControl = 0;
530 u8 dataFrameType = 0;
531
532 dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4);
533
534 if (dataFrameType == QOS_DATA) {
535 /* QoS control field is offset from frame control by 2 (frame control)
536 * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
537 */
538 if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) {
539 qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30);
540 }
541 else {
542 qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24);
543 }
544 }
545
546 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
547
548 if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) {
549 unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority);
550 return CSR_RESULT_FAILURE;
551 }
552 }
553 else {
554 priority = CSR_CONTENTION;
555 }
556
557 /* Frame Bulk data to requeue it back to HAL Queues */
558 bulkData.d[0].os_data_ptr = bulkDataDesc->os_data_ptr;
559 bulkData.d[0].data_length = bulkDataDesc->data_length;
560 bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr;
561 bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length;
562
563 bulkData.d[1].os_data_ptr = NULL;
564 bulkData.d[1].os_net_buf_ptr = NULL;
565 bulkData.d[1].data_length = bulkData.d[1].net_buf_length = 0;
566
567 /* Initialize signal to zero */
568 memset(&signal, 0, sizeof(CSR_SIGNAL));
569
570 /* Frame MA Packet Req */
571 unifi_frame_ma_packet_req(priv, priority, 0, host_tag,
572 interfaceTag, CSR_NO_CONFIRM_REQUIRED,
573 priv->netdev_client->sender_id,
574 staRecord->peerMacAddress.a, &signal);
575
576 /* Find the Q-Priority */
577 priority_q = unifi_frame_priority_to_queue(priority);
578 list = &staRecord->dataPdu[priority_q];
579
580 /* Place the Packet on to HAL Queue */
581 status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE);
582
583 /* Update the Per-station queued packet counter */
584 if (!status) {
585 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
586 staRecord->noOfPktQueued++;
587 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
588 }
589 }
590 else {
591 /* Packet will not be re-queued for any of the other MA Packet Tx failure
592 * reasons so just return failure to clear the hip slot
593 */
594 return CSR_RESULT_FAILURE;
595 }
596
597 return status;
598}
599#endif
600
601static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable)
602{
603 u8 i;
604 *allDeliveryEnabled = TRUE;
605 for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) {
606 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
607 /* One is is not Delivery Enabled */
608 *allDeliveryEnabled = FALSE;
609 break;
610 }
611 }
612 if (*allDeliveryEnabled) {
613 *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1])
614 ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3])
615 ||!list_empty(&staRecord->mgtFrames));
616 }
617}
618
619/*
620 * ---------------------------------------------------------------------------
621 * uf_handle_tim_cfm
622 *
623 *
624 * This function updates tim status in host depending confirm status from firmware
625 *
626 * Arguments:
627 * priv Pointer to device private context struct
628 * cfm CSR_MLME_SET_TIM_CONFIRM
629 * receiverProcessId SenderProcessID to fetch handle & timSet status
630 *
631 * ---------------------------------------------------------------------------
632 */
633void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId)
634{
635 u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId);
636 u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId);
637 u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
638 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
639 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
640 /* This variable holds what TIM value we wanted to set in firmware */
641 u16 timSetValue = 0;
642 /* Irrespective of interface the count maintained */
643 static u8 retryCount = 0;
644 unsigned long lock_flags;
645 unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus);
646
647 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
648 unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag);
649 return;
650 }
651
652 if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) {
653 unifi_warning(priv, "bad station Handle = %x\n", handle);
654 return;
655 }
656
657 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
658 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
659 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
660 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
661 unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL handle = %x\n", handle);
662 return;
663 }
664 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
665 }
666 switch(timSetStatus)
667 {
668 case CSR_WIFI_TIM_SETTING:
669 timSetValue = CSR_WIFI_TIM_SET;
670 break;
671 case CSR_WIFI_TIM_RESETTING:
672 timSetValue = CSR_WIFI_TIM_RESET;
673 break;
674 default:
675 unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus);
676 return;
677 }
678
679 /* check TIM confirm for success/failures */
680 switch(cfm->ResultCode)
681 {
682 case CSR_RC_SUCCESS:
683 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
684 /* Unicast frame & station record available */
685 if (timSetStatus == staRecord->timSet) {
686 staRecord->timSet = timSetValue;
687 /* fh_cmd_q can also be full at some point of time!,
688 * resetting count as queue is cleaned by firmware at this point
689 */
690 retryCount = 0;
691 unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET");
692 } else {
693 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",
694 receiverProcessId, timSetStatus, staRecord->timSet, handle);
695 }
696
697 /* Reset TIM pending flag to send next TIM request */
698 staRecord->timRequestPendingFlag = FALSE;
699
700 /* Make sure that one more UpdateTim request is queued, if Queued its value
701 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
702 */
703 if (0xFF != staRecord->updateTimReqQueued)
704 {
705 /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
706 if (staRecord->timSet != staRecord->updateTimReqQueued)
707 {
708 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n");
709
710 update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle);
711
712 staRecord->updateTimReqQueued = 0xFF;
713 }
714 }
715 } else {
716
717 interfacePriv->bcTimSet = timSetValue;
718 /* fh_cmd_q can also be full at some point of time!,
719 * resetting count as queue is cleaned by firmware at this point
720 */
721 retryCount = 0;
722 unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET");
723
724 /* Reset DTIM pending flag to send next DTIM request */
725 interfacePriv->bcTimSetReqPendingFlag = FALSE;
726
727 /* Make sure that one more UpdateDTim request is queued, if Queued its value
728 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
729 */
730 if (0xFF != interfacePriv->bcTimSetReqQueued)
731 {
732 /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
733 if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued)
734 {
735 unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n");
736
737 update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF);
738
739 interfacePriv->bcTimSetReqQueued = 0xFF;
740 }
741 }
742
743 }
744 break;
745 case CSR_RC_INVALID_PARAMETERS:
746 case CSR_RC_INSUFFICIENT_RESOURCE:
747 /* check for max retry limit & send again
748 * MAX_RETRY_LIMIT is not maintained for each set of transactions..Its generic
749 * If failure crosses this Limit, we have to take a call to FIX
750 */
751 if (retryCount > UNIFI_MAX_RETRY_LIMIT) {
752 u8 moreData = FALSE;
753 retryCount = 0;
754 /* Because of continuos traffic in fh_cmd_q the tim set request is failing (exceeding retry limit)
755 * but if we didn't synchronize our timSet varible state with firmware then it can cause below issues
756 * cond 1. We want to SET tim in firmware if its fails & max retry limit reached
757 * -> If host set's the timSet to 1, we wont try to send(as max retry reached) update tim but
758 * firmware is not updated with queue(TIM) status so it wont set TIM in beacon finally host start piling
759 * up data & wont try to set tim in firmware (This can cause worser performance)
760 * cond 2. We want to reset tim in firmware it fails & reaches max retry limit
761 * -> If host sets the timSet to Zero, it wont try to set a TIM request unless we wont have any packets
762 * to be queued, so beacon unnecessarily advertizes the TIM
763 */
764
765 if(staRecord) {
766 if(!staRecord->wmmOrQosEnabled) {
767 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
768 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
769 !list_empty(&staRecord->mgtFrames));
770 } else {
771 /* Peer is QSTA */
772 u8 allDeliveryEnabled = 0, dataAvailable = 0;
773 /* Check if all AC's are Delivery Enabled */
774 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
775 /*check for more data in non-delivery enabled queues*/
776 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
777
778 }
779 /* To avoid cond 1 & 2, check internal Queues status, if we have more Data then set RESET the timSet(0),
780 * so we are trying to be in sync with firmware & next packets before queuing atleast try to
781 * set TIM in firmware otherwise it SET timSet(1)
782 */
783 if (moreData) {
784 staRecord->timSet = CSR_WIFI_TIM_RESET;
785 } else {
786 staRecord->timSet = CSR_WIFI_TIM_SET;
787 }
788 } else {
789 /* Its a broadcast frames */
790 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
791 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
792 if (moreData) {
793 update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF);
794 } else {
795 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
796 }
797 }
798
799 unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n");
800 return;
801 }
802 retryCount++;
803
804 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
805 if (timSetStatus == staRecord->timSet) {
806 unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid);
807 update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle);
808 } else {
809 unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n",
810 timSetStatus, staRecord->timSet);
811 }
812 } else {
813 unifi_warning(priv, "tim request failed, retry for broadcast frames\n");
814 update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF);
815 }
816 break;
817 default:
818 unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode);
819 }
820
821 unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__);
822}
823
824/*
825 * ---------------------------------------------------------------------------
826 * update_tim
827 *
828 *
829 * This function updates tim status in firmware for AID[1 to UNIFI_MAX_CONNECTIONS] or
830 * AID[0] for broadcast/multicast packets.
831 *
832 * NOTE: The LSB (least significant BYTE) of senderId while sending this MLME premitive
833 * has been modified(utilized) as below
834 *
835 * SenderID in signal's SignalPrimitiveHeader is 2 byte the lowe byte bitmap is below
836 *
837 * station handle(6 bits) timSet Status (2 bits)
838 * --------------------- ----------------------
839 * 0 0 0 0 0 0 | 0 0
840 *
841 * timSet Status can be one of below:
842 *
843 * CSR_WIFI_TIM_RESET
844 * CSR_WIFI_TIM_RESETTING
845 * CSR_WIFI_TIM_SET
846 * CSR_WIFI_TIM_SETTING
847 *
848 * Arguments:
849 * priv Pointer to device private context struct
850 * aid can be 1 t0 UNIFI_MAX_CONNECTIONS & 0 means multicast/broadcast
851 * setTim value SET(1) / RESET(0)
852 * interfaceTag the interfaceID on which activity going on
853 * handle from (0 <= handle < UNIFI_MAX_CONNECTIONS)
854 *
855 * ---------------------------------------------------------------------------
856 */
857void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle)
858{
859 CSR_SIGNAL signal;
860 s32 r;
861 CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest;
862 bulk_data_param_t *bulkdata = NULL;
863 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
864 u8 senderIdLsb = 0;
865 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
866 u32 oldTimSetStatus = 0, timSetStatus = 0;
867
868 unifi_trace(priv, UDBG5, "entering the update_tim routine\n");
869
870
871 if (handle == 0xFFFFFFFF) {
872 handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE;
873 if (setTim == interfacePriv->bcTimSet)
874 {
875 unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet);
876 return;
877 }
878 } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) {
879 unifi_warning(priv, "bad station Handle = %x\n", handle);
880 return;
881 }
882
883 if (setTim) {
884 timSetStatus = CSR_WIFI_TIM_SETTING;
885 } else {
886 timSetStatus = CSR_WIFI_TIM_RESETTING;
887 }
888
889 if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
890 if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
891 unifi_warning(priv, "station record is NULL in update_tim: handle = %x :debug\n", handle);
892 return;
893 }
894 /* In case of signal sending failed, revert back to old state */
895 oldTimSetStatus = staRecord->timSet;
896 staRecord->timSet = timSetStatus;
897 }
898
899 /* pack senderID LSB */
900 senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timSetStatus);
901
902 /* initialize signal to zero */
903 memset(&signal, 0, sizeof(CSR_SIGNAL));
904
905 /* Frame the MLME-SET-TIM request */
906 signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID;
907 signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
908 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb),
909 (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
910
911 /* set The virtual interfaceIdentifier, aid, tim value */
912 req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag);
913 req->AssociationId = aid;
914 req->TimValue = setTim;
915
916
917 unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n",
918 aid, senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId);
919
920 /* Send the signal to UniFi */
921 r = ul_send_signal_unpacked(priv, &signal, bulkdata);
922 if (r) {
923 /* No need to free bulk data, as TIM request doesn't carries any data */
924 unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n");
925 if (staRecord) {
926 staRecord->timSet = oldTimSetStatus ;
927 }
928 else
929 {
930 /* MLME_SET_TIM.req sending failed here for AID0, so revert back our bcTimSet status */
931 interfacePriv->bcTimSet = !setTim;
932 }
933 }
934 else {
935 /* Update tim request pending flag and ensure no more TIM set requests are send
936 for the same station until TIM confirm is received */
937 if (staRecord) {
938 staRecord->timRequestPendingFlag = TRUE;
939 }
940 else
941 {
942 /* Update tim request (for AID 0) pending flag and ensure no more DTIM set requests are send
943 * for the same station until TIM confirm is received
944 */
945 interfacePriv->bcTimSetReqPendingFlag = TRUE;
946 }
947 }
948 unifi_trace(priv, UDBG5, "leaving the update_tim routine\n");
949}
950
951static
952void process_peer_active_transition(unifi_priv_t * priv,
953 CsrWifiRouterCtrlStaInfo_t *staRecord,
954 u16 interfaceTag)
955{
956 int r, i;
957 u8 spaceAvail[4] = {TRUE, TRUE, TRUE, TRUE};
958 tx_buffered_packets_t * buffered_pkt = NULL;
959 unsigned long lock_flags;
960 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
961
962 unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n");
963
964 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
965 /* giving more priority to multicast packets so delaying unicast packets*/
966 unifi_trace(priv, UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n");
967
968 /* As station is active now, even though AP is not able to send frames to it
969 * because of DTIM, it needs to reset the TIM here
970 */
971 if (!staRecord->timRequestPendingFlag){
972 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){
973 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
974 }
975 }
976 else
977 {
978 /* Cache the TimSet value so that it will processed immidiatly after
979 * completing the current setTim Request
980 */
981 staRecord->updateTimReqQueued = 0;
982 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
983 staRecord->aid);
984 }
985 return;
986 }
987 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
988 buffered_pkt->transmissionControl &=
989 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
990 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, 0, FALSE)) == -ENOSPC) {
991 unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n");
992 /* Enqueue at the head of the queue */
993 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
994 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
995 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
996 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
997 spaceAvail[3] = FALSE;
998 break;
999 } else {
1000 if(r){
1001 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1002 /* the PDU failed where we can't do any thing so free the storage */
1003 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1004 }
1005 kfree(buffered_pkt);
1006 }
1007 }
1008 if (!staRecord->timRequestPendingFlag) {
1009 if (staRecord->txSuspend) {
1010 if(staRecord->timSet == CSR_WIFI_TIM_SET) {
1011 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
1012 }
1013 return;
1014 }
1015 }
1016 else
1017 {
1018 /* Cache the TimSet value so that it will processed immidiatly after
1019 * completing the current setTim Request
1020 */
1021 staRecord->updateTimReqQueued = 0;
1022 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1023 staRecord->aid);
1024 }
1025 for(i=3;i>=0;i--) {
1026 if(!spaceAvail[i])
1027 continue;
1028 unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n", i);
1029 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
1030 buffered_pkt->transmissionControl &=
1031 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
1032 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, 0, FALSE)) == -ENOSPC) {
1033 /* Clear the trigger bit transmission control*/
1034 /* Enqueue at the head of the queue */
1035 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
1036 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
1037 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
1038 priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle);
1039 break;
1040 } else {
1041 if(r){
1042 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
1043 /* the PDU failed where we can't do any thing so free the storage */
1044 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
1045 }
1046 kfree(buffered_pkt);
1047 }
1048 }
1049 }
1050 if (!staRecord->timRequestPendingFlag){
1051 if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)) {
1052 unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n");
1053 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
1054 }
1055 }
1056 else
1057 {
1058 /* Cache the TimSet value so that it will processed immidiatly after
1059 * completing the current setTim Request
1060 */
1061 staRecord->updateTimReqQueued = 0;
1062 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1063 staRecord->aid);
1064 }
1065 unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n");
1066}
1067
1068
1069
1070void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm)
1071{
1072 netInterface_priv_t *interfacePriv;
1073 u8 i;
1074 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1075 interfacePriv = priv->interfacePriv[interfaceTag];
1076
1077
1078 if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) {
1079 unifi_trace(priv, UDBG2, "CFM for marked Multicast Tag = %x\n", interfacePriv->multicastPduHostTag);
1080 interfacePriv->multicastPduHostTag = 0xffffffff;
1081 resume_suspended_uapsd(priv, interfaceTag);
1082 resume_unicast_buffered_frames(priv, interfaceTag);
1083 if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) &&
1084 list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1085 unifi_trace(priv, UDBG1, "Resetting multicastTIM");
1086 if (!interfacePriv->bcTimSetReqPendingFlag)
1087 {
1088 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
1089 }
1090 else
1091 {
1092 /* Cache the DTimSet value so that it will processed immidiatly after
1093 * completing the current setDTim Request
1094 */
1095 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
1096 unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n",
1097 interfacePriv->bcTimSetReqQueued);
1098 }
1099
1100 }
1101 return;
1102 }
1103
1104 /* Check if it is a Confirm for null data frame used
1105 * for probing station activity
1106 */
1107 for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
1108 staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
1109 if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) {
1110
1111 unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n",
1112 pkt_cfm->HostTag,
1113 pkt_cfm->TransmissionStatus
1114 );
1115 staRecord->nullDataHostTag = INVALID_HOST_TAG;
1116
1117 if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){
1118 u32 now;
1119 u32 inactive_time;
1120
1121 unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n");
1122 /* Recheck if there is some activity after null data is sent.
1123 *
1124 * If still there is no activity then send a disconnected indication
1125 * to SME to delete the station record.
1126 */
1127 if (staRecord->activity_flag){
1128 return;
1129 }
1130 now = CsrTimeGet(NULL);
1131
1132 if (staRecord->lastActivity > now)
1133 {
1134 /* simple timer wrap (for 1 wrap) */
1135 inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity),
1136 now);
1137 }
1138 else
1139 {
1140 inactive_time = (u32)CsrTimeSub(now, staRecord->lastActivity);
1141 }
1142
1143 if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
1144 {
1145 struct list_head send_cfm_list;
1146 u8 j;
1147
1148 /* The SME/NME may be waiting for confirmation for requested frames to this station.
1149 * Though this is --VERY UNLIKELY-- in case of station in active mode. But still as a
1150 * a defensive check, it loops through buffered frames for this station and if confirmation
1151 * is requested, send auto confirmation with failure status. Also flush the frames so
1152 * that these are not processed again in PEER_DEL_REQ handler.
1153 */
1154 INIT_LIST_HEAD(&send_cfm_list);
1155
1156 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1157 &send_cfm_list,
1158 &(staRecord->mgtFrames));
1159
1160 uf_flush_list(priv, &(staRecord->mgtFrames));
1161
1162 for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
1163 uf_prepare_send_cfm_list_for_queued_pkts(priv,
1164 &send_cfm_list,
1165 &(staRecord->dataPdu[j]));
1166
1167 uf_flush_list(priv, &(staRecord->dataPdu[j]));
1168 }
1169
1170 send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list);
1171
1172
1173
1174 unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
1175 staRecord->peerMacAddress.a[0],
1176 staRecord->peerMacAddress.a[1],
1177 staRecord->peerMacAddress.a[2],
1178 staRecord->peerMacAddress.a[3],
1179 staRecord->peerMacAddress.a[4],
1180 staRecord->peerMacAddress.a[5]);
1181
1182 CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
1183 0,
1184 staRecord->interfacePriv->InterfaceTag,
1185 staRecord->peerMacAddress,
1186 CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
1187 }
1188
1189 }
1190 else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL)
1191 {
1192 staRecord->activity_flag = TRUE;
1193 }
1194 }
1195 }
1196}
1197
1198#endif
1199u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag)
1200{
1201 switch(mode)
1202 {
1203 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1204 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1205 return (0x02<<8|tag);
1206
1207 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1208 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1209 return (0x03<<8|tag);
1210
1211 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1212 return (0x01<<8|tag);
1213
1214 case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
1215 return (0x04<<8|tag);
1216 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1217 return (0x05<<8|tag);
1218 default:
1219 return tag;
1220 }
1221}
1222
1223#ifdef CSR_SUPPORT_SME
1224
1225/*
1226 * ---------------------------------------------------------------------------
1227 * update_macheader
1228 *
1229 *
1230 * These functions updates mac header for intra BSS packet
1231 * routing.
1232 * NOTE: This function always has to be called in rx context which
1233 * is in bh thread context since GFP_KERNEL is used. In soft IRQ/ Interrupt
1234 * context shouldn't be used
1235 *
1236 * Arguments:
1237 * priv Pointer to device private context struct
1238 * skb Socket buffer containing data packet to transmit
1239 * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb
1240 * priority to append QOS control header in Mac header
1241 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1242 * interfaceTag the interfaceID on which activity going on
1243 * macHeaderLengthInBytes no. of bytes of mac header in received frame
1244 * qosDestination used to append Qos control field
1245 *
1246 * Returns:
1247 * Zero on success or -1 on error.
1248 * ---------------------------------------------------------------------------
1249 */
1250
1251static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb,
1252 struct sk_buff *newSkb, CSR_PRIORITY *priority,
1253 bulk_data_param_t *bulkdata, u16 interfaceTag,
1254 u8 macHeaderLengthInBytes,
1255 u8 qosDestination)
1256{
1257
1258 u16 *fc = NULL;
1259 u8 direction = 0, toDs, fromDs;
1260 u8 *bufPtr = NULL;
1261 u8 sa[ETH_ALEN], da[ETH_ALEN];
1262 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1263 int headroom;
1264 u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0};
1265
1266 unifi_trace(priv, UDBG5, "entering the update_macheader function\n");
1267
1268 /* temporary buffer for the Mac header storage */
1269 memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes);
1270
1271 /* remove the Macheader from the skb */
1272 skb_pull(skb, macHeaderLengthInBytes);
1273
1274 /* get the skb headroom for skb_push check */
1275 headroom = skb_headroom(skb);
1276
1277 /* pointer to frame control field */
1278 fc = (u16*) macHeaderBuf;
1279
1280 toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
1281 fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
1282 unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs);
1283 direction = ((fromDs | (toDs << 1)) & 0x3);
1284
1285 /* Address1 or 3 from the macheader */
1286 memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN);
1287 /* Address2, 3 or 4 from the mac header */
1288 memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN);
1289
1290 unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction);
1291 /* update the toDs, fromDs & address fields in Mac header */
1292 switch(direction)
1293 {
1294 case 2:
1295 /* toDs = 1 & fromDs = 0 , toAp when frames received from peer
1296 * while sending this packet to Destination the Mac header changed
1297 * as fromDs = 1 & toDs = 0, fromAp
1298 */
1299 *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK);
1300 *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
1301 /* Address1: MAC address of the actual destination (4 = 2+2) */
1302 memcpy(macHeaderBuf + 4, da, ETH_ALEN);
1303 /* Address2: The MAC address of the AP (10 = 2+2+6) */
1304 memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN);
1305 /* Address3: MAC address of the actual source from mac header (16 = 2+2+6+6) */
1306 memcpy(macHeaderBuf + 16, sa, ETH_ALEN);
1307 break;
1308 case 3:
1309 unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n");
1310 break;
1311 default:
1312 unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n");
1313 return -1;
1314 }
1315
1316 /* frameType is Data always, Validation is done before calling this function */
1317
1318 /* check for the souce station type */
1319 switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
1320 {
1321 case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
1322 /* No need to modify the qos control field */
1323 if (!qosDestination) {
1324
1325 /* If source Sta is QOS enabled & if this bit set, then HTC is supported by
1326 * peer station & htc field present in macHeader
1327 */
1328 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1329 /* HT control field present in Mac header
1330 * 6 = sizeof(qosControl) + sizeof(htc)
1331 */
1332 macHeaderLengthInBytes -= 6;
1333 } else {
1334 macHeaderLengthInBytes -= 2;
1335 }
1336 /* Destination STA is non qos so change subtype to DATA */
1337 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1338 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
1339 /* remove the qos control field & HTC(if present). new macHeaderLengthInBytes is less than old
1340 * macHeaderLengthInBytes so no need to verify skb headroom
1341 */
1342 if (headroom < macHeaderLengthInBytes) {
1343 unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n");
1344 return -1;
1345 }
1346 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1347
1348 /* update bulk data os_data_ptr */
1349 bulkdata->d[0].os_data_ptr = skb->data;
1350 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1351 bulkdata->d[0].data_length = skb->len;
1352
1353 } else {
1354 /* pointing to QOS control field */
1355 u8 qc;
1356 if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
1357 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2)));
1358 } else {
1359 qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2)));
1360 }
1361
1362 if ((qc & IEEE802_11_QC_TID_MASK) > 7) {
1363 *priority = 7;
1364 } else {
1365 *priority = qc & IEEE802_11_QC_TID_MASK;
1366 }
1367
1368 unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority);
1369
1370 if (headroom < macHeaderLengthInBytes) {
1371 unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n");
1372 return -1;
1373 }
1374 bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
1375 }
1376 break;
1377 default:
1378 {
1379 bulk_data_param_t data_ptrs;
1380 CsrResult csrResult;
1381 unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n");
1382
1383 if (qosDestination) {
1384 u8 qc = 0;
1385 unifi_trace(priv, UDBG3, "destination is QOS station \n");
1386
1387 /* Set Ma-Packet.req UP to UP0 */
1388 *priority = CSR_QOS_UP0;
1389
1390 /* prepare the qos control field */
1391 qc |= CSR_QOS_UP0;
1392 /* no Amsdu is in ap buffer so eosp is left 0 */
1393 if (da[0] & 0x1) {
1394 /* multicast/broadcast frames, no acknowledgement needed */
1395 qc |= 1 << 5;
1396 }
1397
1398 /* update new Mac header Length with 2 = sizeof(qos control) */
1399 macHeaderLengthInBytes += 2;
1400
1401 /* received DATA frame but destiantion is QOS station so update subtype to QOS*/
1402 *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
1403 *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
1404
1405 /* appendQosControlOffset = macHeaderLengthInBytes - 2, since source sta is not QOS */
1406 macHeaderBuf[macHeaderLengthInBytes - 2] = qc;
1407 /* txopLimit is 0 */
1408 macHeaderBuf[macHeaderLengthInBytes - 1] = 0;
1409 if (headroom < macHeaderLengthInBytes) {
1410 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1411
1412 if (csrResult != CSR_RESULT_SUCCESS) {
1413 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1414 return -1;
1415 }
1416 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1417 newSkb->len = skb->len + macHeaderLengthInBytes;
1418
1419 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1420 skb->data, skb->len);
1421
1422 bulkdata->d[0].os_data_ptr = newSkb->data;
1423 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1424 bulkdata->d[0].data_length = newSkb->len;
1425
1426 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1427
1428 /* The old skb will not be used again */
1429 kfree_skb(skb);
1430 } else {
1431 /* skb headroom is sufficient to append Macheader */
1432 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1433 bulkdata->d[0].os_data_ptr = skb->data;
1434 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1435 bulkdata->d[0].data_length = skb->len;
1436 }
1437 } else {
1438 unifi_trace(priv, UDBG3, "destination is not a QSTA\n");
1439 if (headroom < macHeaderLengthInBytes) {
1440 csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
1441
1442 if (csrResult != CSR_RESULT_SUCCESS) {
1443 unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
1444 return -1;
1445 }
1446 newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
1447 newSkb->len = skb->len + macHeaderLengthInBytes;
1448
1449 memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
1450 skb->data, skb->len);
1451
1452 bulkdata->d[0].os_data_ptr = newSkb->data;
1453 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
1454 bulkdata->d[0].data_length = newSkb->len;
1455
1456 bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
1457
1458 /* The old skb will not be used again */
1459 kfree_skb(skb);
1460 } else {
1461 /* skb headroom is sufficient to append Macheader */
1462 bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
1463 bulkdata->d[0].os_data_ptr = skb->data;
1464 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
1465 bulkdata->d[0].data_length = skb->len;
1466 }
1467 }
1468 }
1469 }
1470
1471 /* prepare the complete skb, by pushing the MAC header to the beginning of the skb->data */
1472 unifi_trace(priv, UDBG5, "updated Mac Header: %d \n", macHeaderLengthInBytes);
1473 memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes);
1474
1475 unifi_trace(priv, UDBG5, "leaving the update_macheader function\n");
1476 return 0;
1477}
1478/*
1479 * ---------------------------------------------------------------------------
1480 * uf_ap_process_data_pdu
1481 *
1482 *
1483 * Takes care of intra BSS admission control & routing packets within BSS
1484 *
1485 * Arguments:
1486 * priv Pointer to device private context struct
1487 * skb Socket buffer containing data packet to transmit
1488 * ehdr ethernet header to fetch priority of packet
1489 * srcStaInfo source stations record for connection verification
1490 * packed_signal
1491 * signal_len
1492 * signal MA-PACKET.indication signal
1493 * bulkdata if newSkb allocated then bulkdata updated to send to unifi
1494 * macHeaderLengthInBytes no. of bytes of mac header in received frame
1495 *
1496 * Returns:
1497 * Zero on success(ap processing complete) or -1 if packet also have to be sent to NETDEV.
1498 * ---------------------------------------------------------------------------
1499 */
1500int
1501uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
1502 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
1503 const CSR_SIGNAL *signal,
1504 bulk_data_param_t *bulkdata,
1505 u8 macHeaderLengthInBytes)
1506{
1507 const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication);
1508 u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff);
1509 struct sk_buff *newSkb = NULL;
1510 /* pointer to skb or private skb created using skb_copy() */
1511 struct sk_buff *skbPtr = skb;
1512 u8 sendToNetdev = FALSE;
1513 u8 qosDestination = FALSE;
1514 CSR_PRIORITY priority = CSR_CONTENTION;
1515 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1516 netInterface_priv_t *interfacePriv;
1517
1518 unifi_trace(priv, UDBG5, "entering uf_ap_process_data_pdu %d\n", macHeaderLengthInBytes);
1519 /* InterfaceTag validation from MA_PACKET.indication */
1520 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1521 unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n");
1522 unifi_net_data_free(priv, &bulkdata->d[0]);
1523 return 0;
1524 }
1525 interfacePriv = priv->interfacePriv[interfaceTag];
1526
1527 if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) &&
1528 (interfacePriv->intraBssEnabled == FALSE)) {
1529 unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled);
1530
1531 /*In P2P GO case, if intraBSS distribution Disabled then don't do IntraBSS routing */
1532 /* If destination in our BSS then drop otherwise give packet to netdev */
1533 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1534 if (dstStaInfo) {
1535 unifi_net_data_free(priv, &bulkdata->d[0]);
1536 return 0;
1537 }
1538 /* May be associated P2PCLI trying to send the packets on backbone (Netdev) */
1539 return -1;
1540 }
1541
1542 if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) {
1543 /* This packet will be given to the TCP/IP stack since this packet is for us(AP)
1544 * No routing needed */
1545 unifi_trace(priv, UDBG4, "destination address is csr_ap\n");
1546 return -1;
1547 }
1548
1549 /* fetch the destination record from station record database */
1550 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
1551
1552 /* AP mode processing, & if packet is unicast */
1553 if(!dstStaInfo) {
1554 if (!(ehdr->h_dest[0] & 0x1)) {
1555 /* destination not in station record & its a unicast packet, so pass the packet to network stack */
1556 unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol));
1557 return -1;
1558 } else {
1559 /* packet is multicast/broadcast */
1560 /* copy the skb to skbPtr, send skb to netdev & skbPtr to multicast/broad cast list */
1561 unifi_trace(priv, UDBG5, "skb_copy, in uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol));
1562 skbPtr = skb_copy(skb, GFP_KERNEL);
1563 if(skbPtr == NULL) {
1564 /* We don't have memory to don't send the frame in BSS*/
1565 unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol));
1566 return -1;
1567 }
1568 sendToNetdev = TRUE;
1569 }
1570 } else {
1571
1572 /* validate the Peer & Destination Station record */
1573 if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) {
1574 unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n");
1575 interfacePriv->stats.rx_errors++;
1576 unifi_net_data_free(priv, &bulkdata->d[0]);
1577 return 0;
1578 }
1579 }
1580
1581 /* BroadCast packet received and it's been sent as non QOS packets.
1582 * Since WMM spec not mandates broadcast/multicast to be sent as QOS data only,
1583 * if all Peers are QSTA
1584 */
1585 if(sendToNetdev) {
1586 /* BroadCast packet and it's been sent as non QOS packets */
1587 qosDestination = FALSE;
1588 } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) {
1589 qosDestination = TRUE;
1590 }
1591
1592 unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination = %s\n", (qosDestination)? "TRUE": "FALSE");
1593
1594 /* packet is allowed to send to unifi, update the Mac header */
1595 if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) {
1596 interfacePriv->stats.rx_errors++;
1597 unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n");
1598 if (sendToNetdev) {
1599 /* Free's the skb_copy(skbPtr) data since packet processing failed */
1600 bulkdata->d[0].os_data_ptr = skbPtr->data;
1601 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1602 bulkdata->d[0].data_length = skbPtr->len;
1603 unifi_net_data_free(priv, &bulkdata->d[0]);
1604 }
1605 return -1;
1606 }
1607
1608 unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n");
1609
1610 /* Packet is ready to send to unifi ,transmissionControl = 0x0004, confirmation is not needed for data packets */
1611 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)) {
1612 if (sendToNetdev) {
1613 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");
1614 /* Free's the skb_copy(skbPtr) data since packet processing failed */
1615 bulkdata->d[0].os_data_ptr = skbPtr->data;
1616 bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
1617 bulkdata->d[0].data_length = skbPtr->len;
1618 unifi_net_data_free(priv, &bulkdata->d[0]);
1619 } else {
1620 /* This free's the skb data */
1621 unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n");
1622 unifi_net_data_free(priv, &bulkdata->d[0]);
1623 }
1624 }
1625 unifi_trace(priv, UDBG5, "leaving uf_ap_process_data_pdu\n");
1626
1627 if (sendToNetdev) {
1628 /* The packet is multicast/broadcast, so after AP processing packet has to
1629 * be sent to netdev, if peer port state is open
1630 */
1631 unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n");
1632 return -1;
1633 }
1634 /* Ap handled the packet & its a unicast packet, no need to send to netdev */
1635 return 0;
1636}
1637
1638#endif
1639
1640CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,
1641 u8 *peerMacAddress,
1642 CSR_CLIENT_TAG hostTag,
1643 u16 interfaceTag,
1644 CSR_TRANSMISSION_CONTROL transmissionControl,
1645 CSR_RATE TransmitRate,
1646 CSR_PRIORITY priority,
1647 CSR_PROCESS_ID leSenderProcessId,
1648 bulk_data_param_t *bulkdata)
1649{
1650 CsrResult status = CSR_RESULT_SUCCESS;
1651 CSR_SIGNAL signal;
1652 int result;
1653#ifdef CSR_SUPPORT_SME
1654 CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
1655 const u8 *macHdrLocation = bulkdata->d[0].os_data_ptr;
1656 CsrWifiPacketType pktType;
1657 int frameType = 0;
1658 u8 queuePacketDozing = FALSE;
1659 u32 priority_q;
1660 u16 frmCtrl;
1661 struct list_head * list = NULL; /* List to which buffered PDUs are to be enqueued*/
1662 u8 setBcTim=FALSE;
1663 netInterface_priv_t *interfacePriv;
1664 u8 requeueOnSamePos = FALSE;
1665 u32 handle = 0xFFFFFFFF;
1666 unsigned long lock_flags;
1667
1668 unifi_trace(priv, UDBG5,
1669 "entering uf_process_ma_packet_req, peer: %pMF\n",
1670 peerMacAddress);
1671
1672 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1673 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1674 return CSR_RESULT_FAILURE;
1675 }
1676 interfacePriv = priv->interfacePriv[interfaceTag];
1677
1678
1679 /* fetch the station record for corresponding peer mac address */
1680 if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) {
1681 handle = staRecord->assignedHandle;
1682 }
1683
1684 /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
1685 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag,
1686 interfaceTag, transmissionControl, leSenderProcessId,
1687 peerMacAddress, &signal);
1688
1689 /* Since it's common path between STA & AP mode, in case of STA packet
1690 * need not to be queued but in AP case we have to queue PDU's in
1691 * different scenarios
1692 */
1693 switch(interfacePriv->interfaceMode)
1694 {
1695 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1696 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1697 /* For this mode processing done below */
1698 break;
1699 default:
1700 /* In case of STA/IBSS/P2PCLI/AMP, no checks needed send the packet down & return */
1701 unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode);
1702 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
1703 unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__);
1704 }
1705 if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) {
1706 status = CSR_RESULT_FAILURE;
1707 }
1708 return status;
1709 }
1710
1711 /* -----Only AP/P2pGO mode handling falls below----- */
1712
1713 /* convert priority to queue */
1714 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
1715
1716 /* check the powersave status of the peer */
1717 if (staRecord && (staRecord->currentPeerState ==
1718 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) {
1719 /* Peer is dozing & packet have to be delivered, so buffer the packet &
1720 * update the TIM
1721 */
1722 queuePacketDozing = TRUE;
1723 }
1724
1725 /* find the type of frame unicast or mulicast/broadcast */
1726 if (*peerMacAddress & 0x1) {
1727 /* Multicast/broadCast data are always triggered by vif_availability.ind
1728 * at the DTIM
1729 */
1730 pktType = CSR_WIFI_MULTICAST_PDU;
1731 } else {
1732 pktType = CSR_WIFI_UNICAST_PDU;
1733 }
1734
1735 /* Fetch the frame control field from mac header & check for frame type */
1736 frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
1737
1738 /* Processing done according to Frame/Packet type */
1739 frameType = ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
1740 switch(frameType)
1741 {
1742 case IEEE802_11_FRAMETYPE_MANAGEMENT:
1743
1744 switch(pktType)
1745 {
1746 case CSR_WIFI_UNICAST_PDU:
1747 unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n");
1748 /* push the packet in to the queue with appropriate mgt list */
1749 if (!staRecord) {
1750 /* push the packet to the unifi if list is empty (if packet lost how to re-enque) */
1751 if (list_empty(&interfacePriv->genericMgtFrames)) {
1752#ifdef CSR_SUPPORT_SME
1753 if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
1754#endif
1755
1756 unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n");
1757 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1758 /* reque only on ENOSPC */
1759 if(result == -ENOSPC) {
1760 /* requeue the failed packet to genericMgtFrame with same position */
1761 unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n");
1762 list = &interfacePriv->genericMgtFrames;
1763 requeueOnSamePos = TRUE;
1764 }
1765#ifdef CSR_SUPPORT_SME
1766 }else{
1767 list = &interfacePriv->genericMgtFrames;
1768 unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n", signal.u.MaPacketRequest.HostTag);
1769 update_eosp_to_head_of_broadcast_list_head(priv, interfaceTag);
1770 }
1771#endif
1772 } else {
1773 /* Queue the packet to genericMgtFrame of unifi_priv_t data structure */
1774 list = &interfacePriv->genericMgtFrames;
1775 unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n");
1776 }
1777 } else {
1778 /* check peer power state */
1779 if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
1780 /* peer is in dozing mode, so queue packet in mgt frame list of station record */
1781 /*if multicast traffic is going on, buffer the unicast packets*/
1782 list = &staRecord->mgtFrames;
1783
1784 unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n",
1785 (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing);
1786 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)){
1787 update_eosp_to_head_of_broadcast_list_head(priv, interfaceTag);
1788 }
1789
1790 } else {
1791 unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n");
1792 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1793 if(result == -ENOSPC) {
1794 /* requeue the failed packet to staRecord->mgtFrames with same position */
1795 list = &staRecord->mgtFrames;
1796 requeueOnSamePos = TRUE;
1797 unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n", staRecord->assignedHandle);
1798 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
1799 } else if (result) {
1800 status = CSR_RESULT_FAILURE;
1801 }
1802 }
1803 }
1804 break;
1805 case CSR_WIFI_MULTICAST_PDU:
1806 unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n");
1807 /* Queue the packet to genericMulticastOrBroadCastMgtFrames of unifi_priv_t data structure
1808 * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
1809 */
1810
1811 list = &interfacePriv->genericMulticastOrBroadCastMgtFrames;
1812 if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) &&
1813 (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
1814 setBcTim=TRUE;
1815 }
1816 break;
1817 default:
1818 unifi_error(priv, "condition never meets: packet type unrecognized\n");
1819 }
1820 break;
1821 case IEEE802_11_FRAMETYPE_DATA:
1822 switch(pktType)
1823 {
1824 case CSR_WIFI_UNICAST_PDU:
1825 unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n");
1826 /* check peer power state, list status & peer port status */
1827 if(!staRecord) {
1828 unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__);
1829 return CSR_RESULT_FAILURE;
1830 } else if (queuePacketDozing || isRouterBufferEnabled(priv, priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
1831 /* peer is in dozing mode, so queue packet in mgt frame list of station record */
1832 /* if multicast traffic is going on, buffet the unicast packets */
1833 unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\
1834 Buffering enabled = %d \n", priority_q, queuePacketDozing, isRouterBufferEnabled(priv, priority_q));
1835 list = &staRecord->dataPdu[priority_q];
1836 } else {
1837 unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q);
1838 /* Pdu allowed to send to unifi */
1839 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1840 if(result == -ENOSPC) {
1841 /* requeue the failed packet to staRecord->dataPdu[priority_q] with same position */
1842 unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n", priority_q);
1843 requeueOnSamePos = TRUE;
1844 list = &staRecord->dataPdu[priority_q];
1845 priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle);
1846 if(!isRouterBufferEnabled(priv, priority_q)) {
1847 unifi_error(priv, "Buffering Not enabled for queue %d \n", priority_q);
1848 }
1849 } else if (result) {
1850 status = CSR_RESULT_FAILURE;
1851 }
1852 }
1853 break;
1854 case CSR_WIFI_MULTICAST_PDU:
1855 unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n");
1856 /* Queue the packet to genericMulticastOrBroadCastFrames list of unifi_priv_t data structure
1857 * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
1858 */
1859 list = &interfacePriv->genericMulticastOrBroadCastFrames;
1860 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
1861 setBcTim = TRUE;
1862 }
1863 break;
1864 default:
1865 unifi_error(priv, "condition never meets: packet type un recognized\n");
1866 }
1867 break;
1868 default:
1869 unifi_error(priv, "unrecognized frame type\n");
1870 }
1871 if(list) {
1872 status = enque_tx_data_pdu(priv, bulkdata, list, &signal, requeueOnSamePos);
1873 /* Record no. of packet queued for each peer */
1874 if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) {
1875 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
1876 staRecord->noOfPktQueued++;
1877 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
1878 }
1879 else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status))
1880 {
1881 /* If broadcast Tim is set && queuing is successful, then only update TIM */
1882 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
1883 interfacePriv->noOfbroadcastPktQueued++;
1884 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
1885 }
1886 }
1887 /* If broadcast Tim is set && queuing is successful, then only update TIM */
1888 if(setBcTim && !status) {
1889 unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n");
1890 if (!interfacePriv->bcTimSetReqPendingFlag)
1891 {
1892 update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, handle);
1893 }
1894 else
1895 {
1896 /* Cache the TimSet value so that it will processed immidiatly after
1897 * completing the current setTim Request
1898 */
1899 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET;
1900 unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n",
1901 interfacePriv->bcTimSetReqQueued);
1902 }
1903 } else if(staRecord && staRecord->currentPeerState ==
1904 CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
1905 if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) {
1906 if(!staRecord->wmmOrQosEnabled) {
1907 if(!list_empty(&staRecord->mgtFrames) ||
1908 !list_empty(&staRecord->dataPdu[3]) ||
1909 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) {
1910 unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n");
1911 if (!staRecord->timRequestPendingFlag){
1912 update_tim(priv, staRecord->aid, 1, interfaceTag, handle);
1913 }
1914 else
1915 {
1916 /* Cache the TimSet value so that it will processed immidiatly after
1917 * completing the current setTim Request
1918 */
1919 staRecord->updateTimReqQueued = 1;
1920 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1921 staRecord->aid);
1922 }
1923 }
1924 } else {
1925 /* Check for non delivery enable(i.e trigger enable), all delivery enable & legacy AC for TIM update in firmware */
1926 u8 allDeliveryEnabled = 0, dataAvailable = 0;
1927 /* Check if all AC's are Delivery Enabled */
1928 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
1929 if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)
1930 || (!list_empty(&staRecord->mgtFrames))) {
1931 if (!staRecord->timRequestPendingFlag) {
1932 update_tim(priv, staRecord->aid, 1, interfaceTag, handle);
1933 }
1934 else
1935 {
1936 /* Cache the TimSet value so that it will processed immidiatly after
1937 * completing the current setTim Request
1938 */
1939 staRecord->updateTimReqQueued = 1;
1940 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
1941 staRecord->aid);
1942 }
1943 }
1944 }
1945 }
1946 }
1947
1948 if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv, priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
1949 unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n", priority_q);
1950 uf_send_buffered_frames(priv, priority_q);
1951 }
1952 unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n");
1953 return status;
1954#else
1955#ifdef CSR_NATIVE_LINUX
1956 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
1957 unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
1958 return CSR_RESULT_FAILURE;
1959 }
1960 /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
1961 unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag,
1962 transmissionControl, leSenderProcessId,
1963 peerMacAddress, &signal);
1964 result = ul_send_signal_unpacked(priv, &signal, bulkdata);
1965 if (result) {
1966 return CSR_RESULT_FAILURE;
1967 }
1968#endif
1969 return status;
1970#endif
1971}
1972
1973#ifdef CSR_SUPPORT_SME
1974s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr)
1975{
1976 s8 protection = 0;
1977 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
1978
1979 switch(interfacePriv->interfaceMode)
1980 {
1981 case CSR_WIFI_ROUTER_CTRL_MODE_STA:
1982 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
1983 case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
1984 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
1985 protection = interfacePriv->protect;
1986 break;
1987 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
1988 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
1989 {
1990 CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
1991 if (daddr[0] & 0x1) {
1992 unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n");
1993 /* In this mode, the protect member of priv structure has an information of how
1994 * AP/P2PGO has started, & the member updated in set mode request for AP/P2PGO
1995 */
1996 protection = interfacePriv->protect;
1997 } else {
1998 /* fetch the destination record from station record database */
1999 dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag);
2000 if (!dstStaInfo) {
2001 unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n");
2002 return -1;
2003 }
2004 protection = dstStaInfo->protection;
2005 }
2006 }
2007 break;
2008 default:
2009 unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n");
2010 }
2011 return protection;
2012}
2013#endif
2014#ifdef CSR_SUPPORT_SME
2015u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag)
2016{
2017 int r;
2018 tx_buffered_packets_t * buffered_pkt = NULL;
2019 u8 moreData = FALSE;
2020 u8 pduSent =0;
2021 unsigned long lock_flags;
2022 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2023 u32 hostTag = 0xffffffff;
2024
2025 if(!isRouterBufferEnabled(priv, UNIFI_TRAFFIC_Q_VO)) {
2026 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
2027 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK);
2028 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2029
2030
2031 unifi_trace(priv, UDBG2, "DTIM Occurred for interface:sending Mgt packet %d\n", interfaceTag);
2032
2033 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, moreData, FALSE)) == -ENOSPC) {
2034 unifi_trace(priv, UDBG1, "frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag);
2035 /* Enqueue at the head of the queue */
2036 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
2037 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
2038 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
2039 break;
2040 } else {
2041 unifi_trace(priv, UDBG1, "send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n",
2042 buffered_pkt->hostTag,
2043 r);
2044 if(r) {
2045 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2046 }
2047 if(!moreData) {
2048
2049 interfacePriv->dtimActive = FALSE;
2050 if(!r) {
2051 hostTag = buffered_pkt->hostTag;
2052 pduSent++;
2053 } else {
2054 send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_UNSPECIFIED_FAILURE);
2055 }
2056 }
2057 /* Buffered frame sent successfully */
2058 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2059 interfacePriv->noOfbroadcastPktQueued--;
2060 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2061 kfree(buffered_pkt);
2062 }
2063
2064 }
2065 }
2066 if(!isRouterBufferEnabled(priv, UNIFI_TRAFFIC_Q_CONTENTION)) {
2067 while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMulticastOrBroadCastFrames))) {
2068 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
2069 moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
2070
2071
2072 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, moreData, FALSE)) == -ENOSPC) {
2073 /* Clear the trigger bit transmission control*/
2074 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK);
2075 /* Enqueue at the head of the queue */
2076 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
2077 list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames);
2078 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
2079 break;
2080 } else {
2081 if(r) {
2082 unifi_trace(priv, UDBG1, "send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n",
2083 buffered_pkt->hostTag,
2084 r);
2085 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2086 }
2087 if(!moreData) {
2088 interfacePriv->dtimActive = FALSE;
2089 if(!r) {
2090 pduSent ++;
2091 hostTag = buffered_pkt->hostTag;
2092 } else {
2093 send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_UNSPECIFIED_FAILURE);
2094 }
2095 }
2096 /* Buffered frame sent successfully */
2097 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2098 interfacePriv->noOfbroadcastPktQueued--;
2099 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2100 kfree(buffered_pkt);
2101 }
2102 }
2103 }
2104 if((interfacePriv->dtimActive == FALSE)) {
2105 /* Record the host Tag*/
2106 unifi_trace(priv, UDBG2, "send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n", hostTag);
2107 interfacePriv->multicastPduHostTag = hostTag;
2108 }
2109 return pduSent;
2110}
2111#endif
2112void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata,
2113 u32 siglen)
2114{
2115#ifdef CSR_SUPPORT_SME
2116 CSR_SIGNAL signal;
2117 CSR_MA_VIF_AVAILABILITY_INDICATION *ind;
2118 int r;
2119 u16 interfaceTag;
2120 u8 pduSent =0;
2121 CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS;
2122 netInterface_priv_t *interfacePriv;
2123
2124 unifi_trace(priv, UDBG3,
2125 "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n",
2126 *((u16*)sigdata));
2127
2128 r = read_unpack_signal(sigdata, &signal);
2129 if (r) {
2130 unifi_error(priv,
2131 "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n",
2132 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
2133 return;
2134 }
2135 ind = &signal.u.MaVifAvailabilityIndication;
2136 interfaceTag=ind->VirtualInterfaceIdentifier & 0xff;
2137
2138 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
2139 unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n");
2140 return;
2141 }
2142
2143 interfacePriv = priv->interfacePriv[interfaceTag];
2144
2145 if(ind->Multicast) {
2146 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) &&
2147 list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) {
2148 /* This condition can occur because of a potential race where the
2149 TIM is not yet reset as host is waiting for confirm but it is sent
2150 by firmware and DTIM occurs*/
2151 unifi_notice(priv, "ma_vif_availibility_ind recevied for multicast but queues are empty%d\n", interfaceTag);
2152 send_vif_availibility_rsp(priv, ind->VirtualInterfaceIdentifier, CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2153 interfacePriv->dtimActive = FALSE;
2154 if(interfacePriv->multicastPduHostTag == 0xffffffff) {
2155 unifi_notice(priv, "ma_vif_availibility_ind recevied for multicast but queues are empty%d\n", interfaceTag);
2156 /* This may be an extra request in very rare race conditions but it is fine as it would atleast remove the potential lock up */
2157 if (!interfacePriv->bcTimSetReqPendingFlag)
2158 {
2159 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
2160 }
2161 else
2162 {
2163 /* Cache the TimSet value so that it will processed immidiatly after
2164 * completing the current setTim Request
2165 */
2166 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2167 unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n",
2168 interfacePriv->bcTimSetReqQueued);
2169 }
2170 }
2171 return;
2172 }
2173 if(interfacePriv->dtimActive) {
2174 unifi_trace(priv, UDBG2, "DTIM Occurred for already active DTIM interface %d\n", interfaceTag);
2175 return;
2176 } else {
2177 unifi_trace(priv, UDBG2, "DTIM Occurred for interface %d\n", interfaceTag);
2178 if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
2179 set_eosp_transmit_ctrl(priv, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
2180 } else {
2181 set_eosp_transmit_ctrl(priv, &interfacePriv->genericMulticastOrBroadCastFrames);
2182 }
2183 }
2184 interfacePriv->dtimActive = TRUE;
2185 pduSent = send_multicast_frames(priv, interfaceTag);
2186 }
2187 else {
2188 unifi_error(priv, "Interface switching is not supported %d\n", interfaceTag);
2189 resultCode = CSR_RC_NOT_SUPPORTED;
2190 send_vif_availibility_rsp(priv, ind->VirtualInterfaceIdentifier, CSR_RC_NOT_SUPPORTED);
2191 }
2192#endif
2193}
2194#ifdef CSR_SUPPORT_SME
2195
2196#define GET_ACTIVE_INTERFACE_TAG(priv) 0
2197
2198static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord)
2199{
2200 s8 i;
2201
2202 for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--)
2203 {
2204 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2205 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2206 &&(!list_empty(&staRecord->dataPdu[i]))) {
2207 unifi_trace(priv, UDBG2, "uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i);
2208 return TRUE;
2209 }
2210 }
2211
2212 unifi_trace(priv, UDBG2, "uf_is_more_data_for_delivery_ac: Data NOT Available \n");
2213 return FALSE;
2214}
2215
2216static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue)
2217{
2218 s8 i;
2219
2220 for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--)
2221 {
2222 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2223 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2224 &&(!list_empty(&staRecord->dataPdu[i]))) {
2225 unifi_trace(priv, UDBG2, "uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i);
2226 return TRUE;
2227 }
2228 }
2229
2230 unifi_trace(priv, UDBG2, "uf_is_more_data_for_usp_delivery: Data NOT Available \n");
2231 return FALSE;
2232}
2233
2234/*
2235 * ---------------------------------------------------------------------------
2236 * uf_send_buffered_data_from_delivery_ac
2237 *
2238 * This function takes care of
2239 * -> Parsing the delivery enabled queue & sending frame down to HIP
2240 * -> Setting EOSP=1 when USP to be terminated
2241 * -> Depending on MAX SP length services the USP
2242 *
2243 * NOTE:This function always called from uf_handle_uspframes_delivery(), Dont
2244 * call this function from any other location in code
2245 *
2246 * Arguments:
2247 * priv Pointer to device private context struct
2248 * vif interface specific HIP vif instance
2249 * staInfo peer for which UAPSD to be scheduled
2250 * queue AC from which Data to be sent in USP
2251 * txList access category for processing list
2252 * ---------------------------------------------------------------------------
2253 */
2254void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv,
2255 CsrWifiRouterCtrlStaInfo_t * staInfo,
2256 u8 queue,
2257 struct list_head *txList)
2258{
2259
2260 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2261 tx_buffered_packets_t * buffered_pkt = NULL;
2262 unsigned long lock_flags;
2263 u8 eosp=FALSE;
2264 s8 r =0;
2265 u8 moreData = FALSE;
2266 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2267
2268 unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2269
2270 if (queue > UNIFI_TRAFFIC_Q_VO)
2271 {
2272 return;
2273 }
2274 while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) {
2275 if((IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
2276 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n",
2277 staInfo->aid);
2278
2279 /* Once resume called, the U-APSD delivery operation will resume */
2280 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2281 staInfo->uspSuspend = TRUE;
2282 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2283 /* re-queueing the packet as DTIM started */
2284 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
2285 list_add(&buffered_pkt->q, txList);
2286 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
2287 break;
2288 }
2289
2290 buffered_pkt->transmissionControl &=
2291 ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2292
2293
2294 if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) {
2295
2296 buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK;
2297
2298 /* Check All delivery enables Ac for more data, because caller of this
2299 * function not aware about last packet
2300 * (First check in moreData fetching helps in draining out Mgt frames Q)
2301 */
2302 moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue));
2303
2304 if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) {
2305 moreData = FALSE;
2306 }
2307
2308 if(moreData == FALSE) {
2309 eosp = TRUE;
2310 buffered_pkt->transmissionControl =
2311 (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
2312 }
2313 } else {
2314 /* Non QoS and non U-APSD */
2315 unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n");
2316 }
2317
2318 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n", moreData, eosp);
2319
2320 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, moreData, eosp)) == -ENOSPC) {
2321
2322 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue);
2323
2324 /* Once resume called, the U-APSD delivery operation will resume */
2325 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2326 staInfo->uspSuspend = TRUE;
2327 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2328
2329 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
2330 list_add(&buffered_pkt->q, txList);
2331 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
2332 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2333 break;
2334 } else {
2335 if(r){
2336 /* the PDU failed where we can't do any thing so free the storage */
2337 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2338 }
2339 kfree(buffered_pkt);
2340 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2341 staInfo->noOfSpFramesSent++;
2342 if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) {
2343 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n");
2344 staInfo->uapsdActive = FALSE;
2345 staInfo->uspSuspend = FALSE;
2346 staInfo->noOfSpFramesSent = 0;
2347 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2348 break;
2349 }
2350 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2351 }
2352 }
2353 unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
2354}
2355
2356void uf_send_buffered_data_from_ac(unifi_priv_t *priv,
2357 CsrWifiRouterCtrlStaInfo_t * staInfo,
2358 u8 queue,
2359 struct list_head *txList)
2360{
2361 tx_buffered_packets_t * buffered_pkt = NULL;
2362 unsigned long lock_flags;
2363 u8 eosp=FALSE;
2364 u8 moreData = FALSE;
2365 s8 r =0;
2366
2367 unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_ac :\n");
2368
2369 while(!isRouterBufferEnabled(priv, queue) &&
2370 ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){
2371
2372 buffered_pkt->transmissionControl &=
2373 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
2374
2375 unifi_trace(priv, UDBG3, "uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n", moreData, eosp);
2376
2377 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, moreData, eosp)) == -ENOSPC) {
2378 /* Enqueue at the head of the queue */
2379 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
2380 list_add(&buffered_pkt->q, txList);
2381 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
2382 if(staInfo != NULL){
2383 priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
2384 }
2385 unifi_trace(priv, UDBG3, " uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n", queue);
2386 } else {
2387 if(r){
2388 /* the PDU failed where we can't do any thing so free the storage */
2389 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
2390 }
2391 kfree(buffered_pkt);
2392 }
2393 }
2394
2395}
2396
2397void uf_send_buffered_frames(unifi_priv_t *priv, unifi_TrafficQueue q)
2398{
2399 u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
2400 u32 startIndex=0, endIndex=0;
2401 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
2402 u8 queue;
2403 u8 moreData = FALSE;
2404
2405 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2406
2407 if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
2408 (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)))
2409 return;
2410
2411 queue = (q<=3)?q:0;
2412
2413 if(interfacePriv->dtimActive) {
2414 /* this function updates dtimActive*/
2415 send_multicast_frames(priv, interfaceTag);
2416 if(!interfacePriv->dtimActive) {
2417 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2418 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2419 if(!moreData) {
2420 if (!interfacePriv->bcTimSetReqPendingFlag)
2421 {
2422 update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0XFFFFFFFF);
2423 }
2424 else
2425 {
2426 /* Cache the TimSet value so that it will processed immidiatly after
2427 * completing the current setTim Request
2428 */
2429 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
2430 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n",
2431 interfacePriv->bcTimSetReqQueued);
2432 }
2433 }
2434 } else {
2435 moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
2436 !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
2437 if(!moreData) {
2438 /* This should never happen but if it happens, we need a way out */
2439 unifi_error(priv, "ERROR: No More Data but DTIM is active sending Response\n");
2440 send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
2441 interfacePriv->dtimActive = FALSE;
2442 }
2443 }
2444 return;
2445 }
2446 if(priv->pausedStaHandle[queue] > 7) {
2447 priv->pausedStaHandle[queue] = 0;
2448 }
2449
2450 if(queue == UNIFI_TRAFFIC_Q_VO) {
2451
2452
2453 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying mgt from queue=%d\n", queue);
2454 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
2455 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag);
2456 if(!staInfo ) {
2457 continue;
2458 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2459 &&(staInfo->uapsdActive == FALSE) ) {
2460 continue;
2461 }
2462
2463 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2464 &&(staInfo->uapsdActive == FALSE)){
2465 /*Non-UAPSD case push the management frames out*/
2466 if(!list_empty(&staInfo->mgtFrames)){
2467 uf_send_buffered_data_from_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2468 }
2469 }
2470
2471 if(isRouterBufferEnabled(priv, queue)) {
2472 unifi_notice(priv, "uf_send_buffered_frames : No space Left for queue = %d\n", queue);
2473 break;
2474 }
2475 }
2476 /*push generic management frames out*/
2477 if(!list_empty(&interfacePriv->genericMgtFrames)) {
2478 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying generic mgt from queue=%d\n", queue);
2479 uf_send_buffered_data_from_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames);
2480 }
2481 }
2482
2483
2484 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : Resume called for Queue=%d\n", queue);
2485 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : start=%d end=%d\n", startIndex, endIndex);
2486
2487 startIndex = priv->pausedStaHandle[queue];
2488 endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS;
2489
2490 while(startIndex != endIndex) {
2491 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag);
2492 if(!staInfo) {
2493 startIndex ++;
2494 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2495 startIndex = 0;
2496 }
2497 continue;
2498 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
2499 &&(staInfo->uapsdActive == FALSE)) {
2500 startIndex ++;
2501 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2502 startIndex = 0;
2503 }
2504 continue;
2505 }
2506 /* Peer is active or U-APSD is active so send PDUs to the peer */
2507 unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying data from queue=%d\n", queue);
2508
2509
2510 if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
2511 &&(staInfo->uapsdActive == FALSE)) {
2512 if(!list_empty(&staInfo->dataPdu[queue])) {
2513
2514 /*Non-UAPSD case push the AC frames out*/
2515 uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue]));
2516 }
2517 }
2518 startIndex ++;
2519 if(startIndex >= UNIFI_MAX_CONNECTIONS) {
2520 startIndex = 0;
2521 }
2522 }
2523 if(isRouterBufferEnabled(priv, queue)) {
2524 priv->pausedStaHandle[queue] = endIndex;
2525 } else {
2526 priv->pausedStaHandle[queue] = 0;
2527 }
2528
2529 /* U-APSD might have stopped because of ENOSPC in lib_hip (pause activity).
2530 * So restart it if U-APSD was active with any of the station
2531 */
2532 unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue);
2533 resume_suspended_uapsd(priv, interfaceTag);
2534}
2535
2536
2537u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord)
2538{
2539 u8 i;
2540
2541 for(i=0;i<=3;i++)
2542 {
2543 if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2544 ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2545 &&(!list_empty(&staRecord->dataPdu[i]))){
2546
2547 return TRUE;
2548 }
2549 }
2550
2551 if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2552 ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
2553 &&(!list_empty(&staRecord->mgtFrames))){
2554
2555 return TRUE;
2556 }
2557
2558
2559
2560 return FALSE;
2561}
2562
2563
2564int uf_process_station_records_for_sending_data(unifi_priv_t *priv, u16 interfaceTag,
2565 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
2566 CsrWifiRouterCtrlStaInfo_t *dstStaInfo)
2567{
2568 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2569
2570 unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n");
2571
2572 if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) {
2573 unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n",
2574 srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action);
2575 return -1;
2576 }
2577 switch (interfacePriv->interfaceMode)
2578 {
2579 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2580 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2581 unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n");
2582 break;
2583 default:
2584 unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n");
2585 return -1;
2586 }
2587
2588 switch(dstStaInfo->peerControlledPort->port_action)
2589 {
2590 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD:
2591 case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK:
2592 unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n");
2593 return -1;
2594 default:
2595 unifi_trace(priv, UDBG5, "destination port state is open\n");
2596 }
2597
2598 /* port state is open, destination station record is valid, Power save state is
2599 * validated in uf_process_ma_packet_req function
2600 */
2601 unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n");
2602 return 0;
2603}
2604
2605
2606/*
2607 * ---------------------------------------------------------------------------
2608 * uf_handle_uspframes_delivery
2609 *
2610 * This function takes care of handling USP session for peer, when
2611 * -> trigger frame from peer
2612 * -> suspended USP to be processed (resumed)
2613 *
2614 * NOTE: uf_send_buffered_data_from_delivery_ac() always called from this function, Dont
2615 * make a direct call to uf_send_buffered_data_from_delivery_ac() from any other part of
2616 * code
2617 *
2618 * Arguments:
2619 * priv Pointer to device private context struct
2620 * staInfo peer for which UAPSD to be scheduled
2621 * interfaceTag virtual interface tag
2622 * ---------------------------------------------------------------------------
2623 */
2624static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag)
2625{
2626
2627 s8 i;
2628 u8 allDeliveryEnabled = 0, dataAvailable = 0;
2629 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2630 unsigned long lock_flags;
2631
2632 unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n",
2633 staInfo->uapsdActive, staInfo->uspSuspend);
2634
2635 /* Check for Buffered frames according to priority order & deliver it
2636 * 1. AC_VO delivery enable & Mgt frames available
2637 * 2. Process remaining Ac's from order AC_VO to AC_BK
2638 */
2639
2640 /* USP initiated by WMMPS enabled peer & SET the status flag to TRUE */
2641 if (!staInfo->uspSuspend && staInfo->uapsdActive)
2642 {
2643 unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n",
2644 staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1],
2645 staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3],
2646 staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]);
2647 return;
2648 }
2649
2650 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2651 staInfo->uapsdActive = TRUE;
2652 staInfo->uspSuspend = FALSE;
2653 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2654
2655 if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)||
2656 (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE))
2657 && (!list_empty(&staInfo->mgtFrames))) {
2658
2659 /* Management queue has data && UNIFI_TRAFFIC_Q_VO is delivery enable */
2660 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n");
2661 uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
2662 }
2663
2664 if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) {
2665 /* All delivery enable AC's are empty, so QNULL to be sent to terminate the USP
2666 * NOTE: If we have sent Mgt frame also, we must send QNULL followed to terminate USP
2667 */
2668 if (!staInfo->uspSuspend) {
2669 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2670 staInfo->uapsdActive = FALSE;
2671 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2672
2673 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n");
2674 uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo);
2675 staInfo->triggerFramePriority = CSR_QOS_UP0;
2676 } else {
2677 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n");
2678 }
2679 } else {
2680 for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) {
2681 if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
2682 ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
2683 && (!list_empty(&staInfo->dataPdu[i]))) {
2684 /* Deliver Data according to AC priority (from VO to BK) as part of USP */
2685 unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i);
2686 uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]);
2687 }
2688
2689 if ((!staInfo->uapsdActive) ||
2690 (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
2691 /* If DTIM active found on one AC, No need to parse the remaining AC's
2692 * as USP suspended. Break out of loop
2693 */
2694 unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x, DTIM=%x, USP terminated=%s\n",
2695 staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag),
2696 staInfo->uapsdActive?"NO":"YES");
2697 break;
2698 }
2699 }
2700 }
2701
2702 /* Depending on the USP status, update the TIM accordingly for delivery enabled AC only
2703 * (since we are not manipulating any Non-delivery list(AC))
2704 */
2705 is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable);
2706 if ((allDeliveryEnabled && !dataAvailable)) {
2707 if ((staInfo->timSet != CSR_WIFI_TIM_RESET) && (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) {
2708 staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET;
2709 unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n");
2710 if (!staInfo->timRequestPendingFlag) {
2711 update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle);
2712 }
2713 }
2714 }
2715 unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n",
2716 staInfo->uapsdActive, staInfo->uspSuspend);
2717}
2718
2719void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv,
2720 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2721 u16 qosControl,
2722 u16 interfaceTag)
2723{
2724 CSR_PRIORITY priority;
2725 unifi_TrafficQueue priority_q;
2726 unsigned long lock_flags;
2727
2728 unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2729 /* If recceived Frames trigger Frame and Devlivery enabled AC has data
2730 * then transmit from High priorty delivery enabled AC
2731 */
2732 priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
2733 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2734
2735 if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
2736 ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) {
2737 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2738 srcStaInfo->triggerFramePriority = priority;
2739 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2740 unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q);
2741 uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag);
2742 }
2743 unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
2744}
2745
2746
2747void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2748{
2749 bulk_data_param_t bulkdata;
2750 CsrResult csrResult;
2751 struct sk_buff *skb, *newSkb = NULL;
2752 CsrWifiMacAddress peerAddress;
2753 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2754 CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK);
2755 int r;
2756 CSR_SIGNAL signal;
2757 u32 priority_q;
2758 CSR_RATE transmitRate = 0;
2759
2760
2761 /* Send a Null Frame to Peer,
2762 * 32= size of mac header */
2763 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE);
2764
2765 if (csrResult != CSR_RESULT_SUCCESS) {
2766 unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n");
2767 return ;
2768 }
2769 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2770 skb->len = 0;
2771 bulkdata.d[0].os_data_ptr = skb->data;
2772 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2773 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2774 bulkdata.d[1].os_data_ptr = NULL;
2775 bulkdata.d[1].os_net_buf_ptr = NULL;
2776 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2777
2778 /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
2779
2780 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2781 unifi_error(priv, "failed to create MAC header\n");
2782 unifi_net_data_free(priv, &bulkdata.d[0]);
2783 return;
2784 }
2785 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2786 /* convert priority to queue */
2787 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2788
2789 /* Frame ma-packet.req, this is saved/transmitted depend on queue state
2790 * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
2791 */
2792 switch (interfacePriv->interfaceMode)
2793 {
2794 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2795 transmitRate = 2;
2796 break;
2797 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2798 transmitRate = 12;
2799 break;
2800 default:
2801 transmitRate = 0;
2802 }
2803 unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag,
2804 transmissionControl, priv->netdev_client->sender_id,
2805 peerAddress.a, &signal);
2806
2807 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2808 if(r) {
2809 unifi_error(priv, "failed to send QOS data null packet result: %d\n", r);
2810 unifi_net_data_free(priv, &bulkdata.d[0]);
2811 }
2812
2813 return;
2814
2815}
2816void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
2817{
2818 bulk_data_param_t bulkdata;
2819 CsrResult csrResult;
2820 struct sk_buff *skb, *newSkb = NULL;
2821 CsrWifiMacAddress peerAddress;
2822 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
2823 CSR_TRANSMISSION_CONTROL transmissionControl = 0;
2824 int r;
2825 CSR_SIGNAL signal;
2826 u32 priority_q;
2827 CSR_RATE transmitRate = 0;
2828 CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
2829 unsigned long lock_flags;
2830
2831 /* Send a Null Frame to Peer, size = 24 for MAC header */
2832 csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE);
2833
2834 if (csrResult != CSR_RESULT_SUCCESS) {
2835 unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n");
2836 return ;
2837 }
2838 skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
2839 skb->len = 0;
2840 bulkdata.d[0].os_data_ptr = skb->data;
2841 bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
2842 bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
2843 bulkdata.d[1].os_data_ptr = NULL;
2844 bulkdata.d[1].os_net_buf_ptr = NULL;
2845 bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
2846
2847 /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
2848 if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
2849 unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n");
2850 unifi_net_data_free(priv, &bulkdata.d[0]);
2851 return;
2852 }
2853 memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
2854 /* convert priority to queue */
2855 priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
2856 transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED);
2857
2858 /* Frame ma-packet.req, this is saved/transmitted depend on queue state
2859 * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
2860 */
2861 switch (interfacePriv->interfaceMode)
2862 {
2863 case CSR_WIFI_ROUTER_CTRL_MODE_AP:
2864 transmitRate = 2;
2865 break;
2866 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
2867 transmitRate = 12;
2868 break;
2869 default:
2870 transmitRate = 0;
2871 }
2872 unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag,
2873 transmissionControl, priv->netdev_client->sender_id,
2874 peerAddress.a, &signal);
2875
2876 /* Save host tag to check the status on reception of MA packet confirm */
2877 srcStaInfo->nullDataHostTag = req->HostTag;
2878 unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag);
2879
2880 r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
2881
2882 if(r == -ENOSPC) {
2883 unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n");
2884 enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1);
2885 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2886 srcStaInfo->noOfPktQueued++;
2887 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2888
2889
2890 }
2891 if(r && r != -ENOSPC){
2892 unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n", r);
2893 unifi_net_data_free(priv, &bulkdata.d[0]);
2894 srcStaInfo->nullDataHostTag = INVALID_HOST_TAG;
2895 }
2896
2897 return;
2898}
2899
2900u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata)
2901{
2902 u8 *bssid = NULL;
2903 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
2904 u8 toDs, fromDs;
2905
2906 toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0;
2907 fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0;
2908
2909 if (toDs && fromDs)
2910 {
2911 unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n");
2912 bssid = NULL;
2913 }
2914 else if((toDs == 0) && (fromDs ==0))
2915 {
2916 /* BSSID is Address 3 */
2917 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN));
2918 }
2919 else if(toDs)
2920 {
2921 /* BSSID is Address 1 */
2922 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4);
2923 }
2924 else if(fromDs)
2925 {
2926 /* BSSID is Address 2 */
2927 bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN);
2928 }
2929
2930 if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0)
2931 {
2932 return TRUE;
2933 }
2934 else
2935 {
2936 return FALSE;
2937 }
2938}
2939
2940
2941u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
2942 u8 pmBit, u16 interfaceTag)
2943{
2944 u8 moreData = FALSE;
2945 u8 powerSaveChanged = FALSE;
2946 unsigned long lock_flags;
2947
2948 unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n");
2949 if (pmBit) {
2950 priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle));
2951 } else {
2952 priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle));
2953 }
2954 if(pmBit) {
2955 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2956
2957 /* disable the preemption */
2958 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2959 srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE;
2960 powerSaveChanged = TRUE;
2961 /* enable the preemption */
2962 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2963 } else {
2964 return powerSaveChanged;
2965 }
2966 } else {
2967 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
2968 /* disable the preemption */
2969 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
2970 srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
2971 powerSaveChanged = TRUE;
2972 /* enable the preemption */
2973 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
2974 }else {
2975 return powerSaveChanged;
2976 }
2977 }
2978
2979
2980 if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
2981 unifi_trace(priv, UDBG3, "Peer with AID = %d is active now\n", srcStaInfo->aid);
2982 process_peer_active_transition(priv, srcStaInfo, interfaceTag);
2983 } else {
2984 unifi_trace(priv, UDBG3, "Peer with AID = %d is in PS Now\n", srcStaInfo->aid);
2985 /* Set TIM if needed */
2986 if(!srcStaInfo->wmmOrQosEnabled) {
2987 moreData = (!list_empty(&srcStaInfo->mgtFrames) ||
2988 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])||
2989 !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]));
2990 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
2991 unifi_trace(priv, UDBG3, "This condition should not occur\n");
2992 if (!srcStaInfo->timRequestPendingFlag){
2993 update_tim(priv, srcStaInfo->aid, 1, interfaceTag, srcStaInfo->assignedHandle);
2994 }
2995 else
2996 {
2997 /* Cache the TimSet value so that it will processed immidiatly after
2998 * completing the current setTim Request
2999 */
3000 srcStaInfo->updateTimReqQueued = 1;
3001 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3002 srcStaInfo->aid);
3003 }
3004
3005 }
3006 } else {
3007 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3008 unifi_trace(priv, UDBG5, "Qos in AP Mode\n");
3009 /* Check if all AC's are Delivery Enabled */
3010 is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable);
3011 /*check for more data in non-delivery enabled queues*/
3012 moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable));
3013
3014 if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
3015 if (!srcStaInfo->timRequestPendingFlag){
3016 update_tim(priv, srcStaInfo->aid, 1, interfaceTag, srcStaInfo->assignedHandle);
3017 }
3018 else
3019 {
3020 /* Cache the TimSet value so that it will processed immidiatly after
3021 * completing the current setTim Request
3022 */
3023 srcStaInfo->updateTimReqQueued = 1;
3024 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
3025 srcStaInfo->aid);
3026 }
3027 }
3028 }
3029 }
3030 unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n");
3031 return powerSaveChanged;
3032}
3033
3034
3035
3036void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag)
3037{
3038 CsrWifiRouterCtrlStaInfo_t *staRecord =
3039 CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
3040 tx_buffered_packets_t * buffered_pkt = NULL;
3041 CsrWifiMacAddress peerMacAddress;
3042 unsigned long lock_flags;
3043 s8 r =0;
3044 u8 moreData = FALSE;
3045 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3046
3047 unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n");
3048 if(!staRecord) {
3049 memcpy(peerMacAddress.a, sa, ETH_ALEN);
3050 unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n",
3051 sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
3052 CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
3053 return;
3054 }
3055
3056 uf_process_pm_bit_for_peer(priv, staRecord, pmBit, interfaceTag);
3057
3058 /* Update station last activity time */
3059 staRecord->activity_flag = TRUE;
3060
3061 /* This should not change the PM bit as PS-POLL has PM bit always set */
3062 if(!pmBit) {
3063 unifi_notice (priv, " PM bit reset in PS-POLL\n");
3064 return;
3065 }
3066
3067 if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
3068 /* giving more priority to multicast packets so dropping ps-poll*/
3069 unifi_notice (priv, " multicast transmission is going on so don't take action on PS-POLL\n");
3070 return;
3071 }
3072
3073 if(!staRecord->wmmOrQosEnabled) {
3074 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3075 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3076 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3077 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3078 !list_empty(&staRecord->mgtFrames));
3079
3080 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3081 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
3082 /* Clear the trigger bit transmission control*/
3083 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3084 /* Enqueue at the head of the queue */
3085 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3086 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3087 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3088 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3089 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3090 } else {
3091 if(r){
3092 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3093 /* the PDU failed where we can't do any thing so free the storage */
3094 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3095 }
3096 kfree(buffered_pkt);
3097 }
3098 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) {
3099 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3100 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3101 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]));
3102
3103 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3104 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
3105 /* Clear the trigger bit transmission control*/
3106 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3107 /* Enqueue at the head of the queue */
3108 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3109 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]);
3110 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3111 priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
3112 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3113 } else {
3114 if(r){
3115 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3116 /* the PDU failed where we can't do any thing so free the storage */
3117 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3118 }
3119 kfree(buffered_pkt);
3120 }
3121 } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) {
3122 buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
3123 moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3124
3125 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3126 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
3127 /* Clear the trigger bit transmission control*/
3128 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3129 /* Enqueue at the head of the queue */
3130 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3131 list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
3132 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3133 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3134 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3135 } else {
3136 if(r){
3137 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3138 /* the PDU failed where we can't do any thing so free the storage */
3139 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3140 }
3141 kfree(buffered_pkt);
3142 }
3143 } else {
3144 /* Actually since we have sent an ACK, there
3145 * there is no need to send a NULL frame*/
3146 }
3147 moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
3148 !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
3149 !list_empty(&staRecord->mgtFrames));
3150 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3151 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3152 if (!staRecord->timRequestPendingFlag){
3153 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
3154 }
3155 else
3156 {
3157 /* Cache the TimSet value so that it will processed immidiatly after
3158 * completing the current setTim Request
3159 */
3160 staRecord->updateTimReqQueued = 0;
3161 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3162 staRecord->aid);
3163 }
3164 }
3165 } else {
3166
3167 u8 allDeliveryEnabled = 0, dataAvailable = 0;
3168 unifi_trace(priv, UDBG3, "Qos Support station.Processing PS-Poll\n");
3169
3170 /*Send Data From Management Frames*/
3171 /* Priority orders for delivering the buffered packets are
3172 * 1. Deliver the Management frames if there
3173 * 2. Other access category frames which are non deliver enable including UNIFI_TRAFFIC_Q_VO
3174 * priority is from VO->BK
3175 */
3176
3177 /* Check if all AC's are Delivery Enabled */
3178 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3179
3180 if (allDeliveryEnabled) {
3181 unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n");
3182 uf_send_qos_null(priv, interfaceTag, sa, CSR_QOS_UP0, staRecord);
3183 return;
3184 }
3185
3186 if (!list_empty(&staRecord->mgtFrames)) {
3187 if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
3188 /* We dont have packets in non delivery enabled UNIFI_TRAFFIC_Q_VO, So we are looking in management
3189 * queue of the station record
3190 */
3191 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3192 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3193
3194 /* Last parameter is EOSP & its false always for PS-POLL processing */
3195 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
3196 /* Clear the trigger bit transmission control*/
3197 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3198 /* Enqueue at the head of the queue */
3199 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3200 list_add(&buffered_pkt->q, &staRecord->mgtFrames);
3201 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3202 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3203 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3204 } else {
3205 if(r){
3206 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3207 /* the PDU failed where we can't do any thing so free the storage */
3208 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3209 }
3210 kfree(buffered_pkt);
3211 }
3212 } else {
3213 unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n");
3214 }
3215
3216 } else {
3217 s8 i;
3218 /* We dont have buffered packet in mangement frame queue (1 failed), So proceed with condition 2
3219 * UNIFI_TRAFFIC_Q_VO -> VI -> BE -> BK
3220 */
3221 for(i= 3; i>=0; i--) {
3222 if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
3223 /* Send One packet, if queue is NULL then continue */
3224 if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
3225 moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
3226
3227 buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3228
3229 /* Last parameter is EOSP & its false always for PS-POLL processing */
3230 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
3231 /* Clear the trigger bit transmission control*/
3232 buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
3233 /* Enqueue at the head of the queue */
3234 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3235 list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
3236 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3237 priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
3238 unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
3239 } else {
3240 if(r) {
3241 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3242 /* the PDU failed where we can't do any thing so free the storage */
3243 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3244 }
3245 kfree(buffered_pkt);
3246 }
3247 break;
3248 }
3249 }
3250 }
3251 }
3252 /* Check if all AC's are Delivery Enabled */
3253 is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
3254 /*check for more data in non-delivery enabled queues*/
3255 moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
3256 if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
3257 unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
3258 if (!staRecord->timRequestPendingFlag){
3259 update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
3260 }
3261 else
3262 {
3263 /* Cache the TimSet value so that it will processed immidiatly after
3264 * completing the current setTim Request
3265 */
3266 staRecord->updateTimReqQueued = 0;
3267 unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
3268 staRecord->aid);
3269 }
3270
3271 }
3272 }
3273
3274 unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n");
3275}
3276
3277
3278
3279void add_to_send_cfm_list(unifi_priv_t * priv,
3280 tx_buffered_packets_t *tx_q_item,
3281 struct list_head *frames_need_cfm_list)
3282{
3283 tx_buffered_packets_t *send_cfm_list_item = NULL;
3284
3285 send_cfm_list_item = kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
3286
3287 if(send_cfm_list_item == NULL){
3288 unifi_warning(priv, "%s: Failed to allocate memory for new list item \n");
3289 return;
3290 }
3291
3292 INIT_LIST_HEAD(&send_cfm_list_item->q);
3293
3294 send_cfm_list_item->hostTag = tx_q_item->hostTag;
3295 send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag;
3296 send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl;
3297 send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId;
3298 send_cfm_list_item->rate = tx_q_item->rate;
3299 memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN);
3300 send_cfm_list_item->priority = tx_q_item->priority;
3301
3302 list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list);
3303}
3304
3305void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
3306 struct list_head *frames_need_cfm_list,
3307 struct list_head * list)
3308{
3309 tx_buffered_packets_t *tx_q_item = NULL;
3310 struct list_head *listHead;
3311 struct list_head *placeHolder;
3312 unsigned long lock_flags;
3313
3314 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3315
3316 /* Search through the list and if confirmation required for any frames,
3317 add it to the send_cfm list */
3318 list_for_each_safe(listHead, placeHolder, list) {
3319 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3320
3321 if(!tx_q_item) {
3322 unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
3323 continue;
3324 }
3325
3326 /* check if confirmation is requested and if the sender ID
3327 is not netdevice client then save the entry in the list for need cfms */
3328 if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) &&
3329 (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){
3330 unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n",
3331 __FUNCTION__,
3332 tx_q_item->leSenderProcessId,
3333 tx_q_item->hostTag,
3334 tx_q_item->transmissionControl);
3335
3336 add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list);
3337 }
3338 }
3339
3340 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3341
3342}
3343
3344
3345
3346void uf_flush_list(unifi_priv_t * priv, struct list_head * list)
3347{
3348 tx_buffered_packets_t *tx_q_item;
3349 struct list_head *listHead;
3350 struct list_head *placeHolder;
3351 unsigned long lock_flags;
3352
3353 unifi_trace(priv, UDBG5, "entering the uf_flush_list \n");
3354
3355 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3356 /* go through list, delete & free memory */
3357 list_for_each_safe(listHead, placeHolder, list) {
3358 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3359
3360 if(!tx_q_item) {
3361 unifi_error(priv, "entry should exists, otherwise crashes (bug)\n");
3362 }
3363 unifi_trace(priv, UDBG5,
3364 "proccess_tx: in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3365 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3366 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3367 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3368 tx_q_item->leSenderProcessId);
3369
3370 list_del(listHead);
3371 /* free the allocated memory */
3372 unifi_net_data_free(priv, &tx_q_item->bulkdata);
3373 kfree(tx_q_item);
3374 tx_q_item = NULL;
3375 if (!priv->noOfPktQueuedInDriver) {
3376 unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
3377 } else {
3378 priv->noOfPktQueuedInDriver--;
3379 }
3380 }
3381 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3382}
3383
3384tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList)
3385{
3386 /* dequeue the tx data packets from the appropriate queue */
3387 tx_buffered_packets_t *tx_q_item = NULL;
3388 struct list_head *listHead;
3389 struct list_head *placeHolder;
3390 unsigned long lock_flags;
3391
3392 unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n");
3393 /* check for list empty */
3394 if (list_empty(txList)) {
3395 unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n");
3396 return NULL;
3397 }
3398
3399 /* Verification, if packet count is negetive */
3400 if (priv->noOfPktQueuedInDriver == 0xFFFF) {
3401 unifi_warning(priv, "no packet available in queue: debug");
3402 return NULL;
3403 }
3404
3405 /* return first node after header, & delete from the list && atleast one item exist */
3406 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3407 list_for_each_safe(listHead, placeHolder, txList) {
3408 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3409 list_del(listHead);
3410 break;
3411 }
3412 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3413
3414 if (tx_q_item) {
3415 unifi_trace(priv, UDBG5,
3416 "proccess_tx: In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
3417 tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
3418 tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
3419 tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
3420 tx_q_item->leSenderProcessId);
3421 }
3422
3423 unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n");
3424 return tx_q_item;
3425}
3426/* generic function to get the station record handler */
3427CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
3428 const u8 *peerMacAddress,
3429 u16 interfaceTag)
3430{
3431 u8 i;
3432 netInterface_priv_t *interfacePriv;
3433 unsigned long lock_flags;
3434
3435 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
3436 unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag);
3437 return NULL;
3438 }
3439
3440 interfacePriv = priv->interfacePriv[interfaceTag];
3441
3442 /* disable the preemption until station record is fetched */
3443 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
3444
3445 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3446 if (interfacePriv->staInfo[i]!= NULL) {
3447 if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) {
3448 /* enable the preemption as station record is fetched */
3449 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
3450 unifi_trace(priv, UDBG5, "peer entry found in station record\n");
3451 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]));
3452 }
3453 }
3454 }
3455 /* enable the preemption as station record is fetched */
3456 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
3457 unifi_trace(priv, UDBG5, "peer entry not found in station record\n");
3458 return NULL;
3459}
3460/* generic function to get the station record handler from the handle */
3461CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
3462 u32 handle,
3463 u16 interfaceTag)
3464{
3465 netInterface_priv_t *interfacePriv;
3466
3467 if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
3468 unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag);
3469 return NULL;
3470 }
3471 interfacePriv = priv->interfacePriv[interfaceTag];
3472 return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]));
3473}
3474
3475/* Function to do inactivity */
3476void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, u32 currentTime)
3477{
3478 u32 i;
3479 CsrWifiRouterCtrlStaInfo_t *staInfo;
3480 u32 elapsedTime; /* Time in microseconds */
3481 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3482 CsrWifiMacAddress peerMacAddress;
3483 unsigned long lock_flags;
3484
3485 if (interfacePriv == NULL) {
3486 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3487 return;
3488 }
3489
3490 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
3491 /* Go through the list of stations to check for inactivity */
3492 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3493 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag);
3494 if(!staInfo ) {
3495 continue;
3496 }
3497
3498 unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n",
3499 currentTime, staInfo->lastActivity);
3500
3501
3502 elapsedTime = (currentTime >= staInfo->lastActivity)?
3503 (currentTime - staInfo->lastActivity):
3504 (~((u32)0) - staInfo->lastActivity + currentTime);
3505 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
3506
3507 if (elapsedTime > MAX_INACTIVITY_INTERVAL) {
3508 memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress));
3509
3510 /* Indicate inactivity for the station */
3511 unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n",
3512 peerMacAddress.a[0], peerMacAddress.a[1],
3513 peerMacAddress.a[2], peerMacAddress.a[3],
3514 peerMacAddress.a[4], peerMacAddress.a[5],
3515 elapsedTime);
3516
3517 CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
3518 }
3519 }
3520
3521 interfacePriv->last_inactivity_check = currentTime;
3522}
3523
3524/* Function to update activity of a station */
3525void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress)
3526{
3527 u32 elapsedTime, currentTime; /* Time in microseconds */
3528 u32 timeHi; /* Not used - Time in microseconds */
3529 CsrWifiRouterCtrlStaInfo_t *staInfo;
3530 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3531 unsigned long lock_flags;
3532
3533 if (interfacePriv == NULL) {
3534 unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
3535 return;
3536 }
3537
3538 currentTime = CsrTimeGet(&timeHi);
3539
3540
3541 staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag);
3542
3543 if (staInfo == NULL) {
3544 unifi_trace(priv, UDBG4, "Sta does not exist yet");
3545 return;
3546 }
3547
3548 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
3549 /* Update activity */
3550 staInfo->lastActivity = currentTime;
3551
3552 /* See if inactivity handler needs to be run
3553 * Here it is theoretically possible that the counter may have wrapped around. But
3554 * since we just want to know when to run the inactivity handler it does not really matter.
3555 * Especially since this is data path it makes sense in keeping it simple and avoiding
3556 * 64 bit handling */
3557 elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)?
3558 (currentTime - interfacePriv->last_inactivity_check):
3559 (~((u32)0) - interfacePriv->last_inactivity_check + currentTime);
3560
3561 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
3562
3563 /* Check if it is time to run the inactivity handler */
3564 if (elapsedTime > INACTIVITY_CHECK_INTERVAL) {
3565 uf_check_inactivity(priv, interfaceTag, currentTime);
3566 }
3567}
3568void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag)
3569{
3570
3571 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3572 u8 i;
3573 int j;
3574 tx_buffered_packets_t * buffered_pkt = NULL;
3575 u8 hipslotFree[4] = {TRUE, TRUE, TRUE, TRUE};
3576 int r;
3577 unsigned long lock_flags;
3578
3579 while(!isRouterBufferEnabled(priv, 3) &&
3580 ((buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMgtFrames))!=NULL)) {
3581 buffered_pkt->transmissionControl &=
3582 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3583 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, 0, FALSE)) == -ENOSPC) {
3584 /* Enqueue at the head of the queue */
3585 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3586 list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames);
3587 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3588 hipslotFree[3]=FALSE;
3589 break;
3590 }else {
3591 if(r){
3592 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3593 /* the PDU failed where we can't do any thing so free the storage */
3594 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3595 }
3596 kfree(buffered_pkt);
3597 }
3598 }
3599 for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
3600 CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i];
3601 if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) {
3602 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n");
3603 break;
3604 }
3605 if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) {
3606 while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) {
3607 buffered_pkt->transmissionControl &=
3608 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3609 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, 0, FALSE)) == -ENOSPC) {
3610 unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n");
3611 /* Enqueue at the head of the queue */
3612 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3613 list_add(&buffered_pkt->q, &staInfo->mgtFrames);
3614 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3615 priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle);
3616 hipslotFree[3] = FALSE;
3617 break;
3618 } else {
3619 if(r){
3620 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3621 /* the PDU failed where we can't do any thing so free the storage */
3622 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3623 }
3624 kfree(buffered_pkt);
3625 }
3626 }
3627
3628 for(j=3;j>=0;j--) {
3629 if(!hipslotFree[j])
3630 continue;
3631
3632 while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) {
3633 buffered_pkt->transmissionControl &=
3634 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
3635 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, 0, FALSE)) == -ENOSPC) {
3636 /* Enqueue at the head of the queue */
3637 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3638 list_add(&buffered_pkt->q, &staInfo->dataPdu[j]);
3639 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3640 priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle);
3641 hipslotFree[j]=FALSE;
3642 break;
3643 } else {
3644 if(r){
3645 unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
3646 /* the PDU failed where we can't do any thing so free the storage */
3647 unifi_net_data_free(priv, &buffered_pkt->bulkdata);
3648 }
3649 kfree(buffered_pkt);
3650 }
3651 }
3652 }
3653 }
3654 }
3655}
3656void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag)
3657{
3658
3659 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
3660 unsigned long lock_flags;
3661 struct list_head *listHead;
3662 struct list_head *placeHolder;
3663 tx_buffered_packets_t *tx_q_item;
3664
3665 if (interfacePriv->noOfbroadcastPktQueued) {
3666
3667 /* Update the EOSP to the HEAD of b/c list
3668 * because we have received any mgmt packet so it should not hold for long time
3669 * peer may time out.
3670 */
3671 spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
3672 list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
3673 tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
3674 tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
3675 tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
3676 unifi_trace(priv, UDBG1, "updating eosp for list Head hostTag:= 0x%x ", tx_q_item->hostTag);
3677 break;
3678 }
3679 spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
3680 }
3681}
3682
3683/*
3684 * ---------------------------------------------------------------------------
3685 * resume_suspended_uapsd
3686 *
3687 * This function takes care processing packets of Unscheduled Service Period,
3688 * which been suspended earlier due to DTIM/HIP ENOSPC scenarios
3689 *
3690 * Arguments:
3691 * priv Pointer to device private context struct
3692 * interfaceTag For which resume should happen
3693 * ---------------------------------------------------------------------------
3694 */
3695void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag)
3696{
3697
3698 u8 startIndex;
3699 CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
3700 unsigned long lock_flags;
3701
3702 unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n");
3703 for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
3704 staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag);
3705
3706 if(!staInfo || !staInfo->wmmOrQosEnabled) {
3707 continue;
3708 } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
3709 &&staInfo->uapsdActive && staInfo->uspSuspend) {
3710 /* U-APSD Still active & previously suspended either ENOSPC of FH queues OR
3711 * due to DTIM activity
3712 */
3713 uf_handle_uspframes_delivery(priv, staInfo, interfaceTag);
3714 } else {
3715 unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n",
3716 staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend);
3717 if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
3718 {
3719 spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
3720 staInfo->uapsdActive = FALSE;
3721 staInfo->uspSuspend = FALSE;
3722 spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
3723 }
3724 }
3725 }
3726 unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n");
3727}
3728
3729#endif
diff --git a/drivers/staging/csr/unifi_priv.h b/drivers/staging/csr/unifi_priv.h
deleted file mode 100644
index 37302f3c2f6c..000000000000
--- a/drivers/staging/csr/unifi_priv.h
+++ /dev/null
@@ -1,1136 +0,0 @@
1/*
2 *****************************************************************************
3 *
4 * FILE : unifi_priv.h
5 *
6 * PURPOSE : Private header file for unifi driver.
7 *
8 * UDI = UniFi Debug Interface
9 *
10 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
11 *
12 * Refer to LICENSE.txt included with this source code for details on
13 * the license terms.
14 *
15 *****************************************************************************
16 */
17#ifndef __LINUX_UNIFI_PRIV_H__
18#define __LINUX_UNIFI_PRIV_H__ 1
19
20#include <linux/module.h>
21#include <linux/string.h>
22#include <linux/errno.h>
23#include <linux/kernel.h>
24#include <linux/wait.h>
25#include <linux/sched.h>
26#include <linux/delay.h>
27#include <linux/netdevice.h>
28#include <linux/wireless.h>
29#include <linux/cdev.h>
30#include <linux/kthread.h>
31#include <linux/freezer.h>
32
33#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
34#include <linux/mmc/core.h>
35#include <linux/mmc/card.h>
36#include <linux/mmc/host.h>
37#include <linux/mmc/sdio_func.h>
38#include <linux/mmc/sdio_ids.h>
39#include <linux/mmc/sdio.h>
40#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
41
42#include <linux/fs.h>
43
44#ifdef ANDROID_BUILD
45#include <linux/wakelock.h>
46#endif
47
48#include "csr_wifi_hip_unifi.h"
49#include "csr_wifi_hip_unifi_udi.h"
50#include "csr_wifi_router_lib.h"
51#include "unifiio.h"
52#ifndef CSR_WIFI_HIP_TA_DISABLE
53#include "csr_wifi_vif_utils.h"
54#endif
55
56/* Define the unifi_priv_t before include the unifi_native.h */
57struct unifi_priv;
58typedef struct unifi_priv unifi_priv_t;
59#ifdef CSR_SUPPORT_WEXT_AP
60struct CsrWifiSmeApConfig;
61typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
62#endif
63#ifdef CSR_SUPPORT_WEXT
64#include "unifi_wext.h"
65#endif
66
67#ifdef ANDROID_BUILD
68extern struct wake_lock unifi_sdio_wake_lock;
69#endif
70
71#include "unifi_clients.h"
72
73#ifdef CSR_NATIVE_LINUX
74#include "sme_native/unifi_native.h"
75#else
76#include "unifi_sme.h"
77#endif
78
79/* The device major number to use when registering the udi driver */
80#define UNIFI_NAME "unifi"
81/*
82 * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present.
83 * This number should be set to the number of SDIO slots supported by the SDIO
84 * host controller on the platform.
85 * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c
86 */
87#define MAX_UNIFI_DEVS 2
88
89/* 802.11 Mac header offsets */
90#define MAC_HEADER_SIZE 24
91#define QOS_CONTROL_HEADER_SIZE 2
92#define HT_CONTROL_HEADER_SIZE 4
93#define QOS_DATA 0x8
94#define QOS_DATA_NULL 0xc
95#define DATA_NULL 0x04
96#define FRAME_CONTROL_ORDER_BIT 0x8000
97#define FRAME_CONTROL_TYPE_FIELD_OFFSET 2
98#define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET 4
99#define IEEE802_11_FRAMETYPE_DATA 0x02
100#define IEEE802_11_FRAMETYPE_CONTROL 0x01
101#define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
102#define IEEE802_11_FRAMETYPE_RESERVED 0x03
103
104/* octet offset from start of mac header for certain fields */
105#define IEEE802_11_ADDR3_OFFSET 16
106#define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
107#define IEEE802_11_MAX_DATA_LEN 2304
108
109/* frame control (FC) masks, for frame control as 16 bit integer */
110#define IEEE802_11_FC_TO_DS_MASK 0x100
111#define IEEE802_11_FC_FROM_DS_MASK 0x200
112#define IEEE802_11_FC_MOREDATA_MASK 0x2000
113#define IEEE802_11_FC_PROTECTED_MASK 0x4000
114#define IEEE80211_FC_ORDER_MASK 0x8000
115#define IEEE80211_FC_SUBTYPE_MASK 0x00f0
116#define IEEE80211_FC_TYPE_MASK 0x000c
117#define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
118
119/* selected type and subtype combinations as in 7.1.3.1 table 1
120 For frame control as 16 bit integer, or for ls octet
121*/
122#define IEEE802_11_FC_TYPE_DATA 0x08
123#define IEEE802_11_FC_TYPE_NULL 0x48
124#define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
125#define IEEE802_11_FC_TYPE_QOS_DATA 0x88
126
127#define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
128
129/* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
130#define IEEE802_11_QC_TID_MASK 0x0f
131#define IEEE802_11_QC_A_MSDU_PRESENT 0x80
132
133#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND))
134#define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0
135#endif
136
137#define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
138#define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
139#define MAX_ACCESS_CATOGORY 4
140
141/* Time in us to check for inactivity of stations 5 mins */
142#define INACTIVITY_CHECK_INTERVAL 300000000
143/* Time in us before a station is flagged as inactive */
144#define MAX_INACTIVITY_INTERVAL 300000000
145
146
147/* Define for maximum BA session */
148#define MAX_SUPPORTED_BA_SESSIONS_TX 1
149#define MAX_SUPPORTED_BA_SESSIONS_RX 4
150
151#define MAX_BA_WIND_SIZE 64
152#define MAC_HEADER_ADDR1_OFFSET 4
153#define MAC_HEADER_ADDR2_OFFSET 10
154
155/* Define for age (in us) value for frames in MPDU reorder buffer */
156#define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000 /* 30 milli seconds */
157
158/* This macro used in prepare_and_add_macheader*/
159#define ADDRESS_ONE_OFFSET 20
160
161/* Defines for STA inactivity detection */
162#define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1 /* in number of stations */
163#define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30 /* in seconds */
164#define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000 /* 120 seconds */
165
166/* Test for modes requiring AP firmware patch */
167#define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \
168 ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE)
169
170/* Defines used in beacon filtering in case of P2P */
171#define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH 0x7
172#define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON 0x8
173#define CSR_WIFI_BEACON_FIXED_LENGTH 12
174#define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET 4
175#define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
176
177#define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
178 ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
179
180/* For M4 request received via netdev*/
181
182typedef u8 CsrWifiPacketType;
183#define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00)
184#define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
185#define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
186
187#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
188
189/* Module parameter variables */
190extern int buswidth;
191extern int sdio_clock;
192extern int use_5g;
193extern int disable_hw_reset;
194extern int disable_power_control;
195extern int enable_wol;
196extern int sme_debug;
197extern int fw_init[MAX_UNIFI_DEVS];
198extern int tl_80211d;
199extern int sdio_byte_mode;
200extern int sdio_block_size;
201extern int coredump_max;
202extern int run_bh_once;
203extern int bh_priority;
204#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
205extern int log_hip_signals;
206#endif
207
208struct dlpriv {
209 const unsigned char *dl_data;
210 int dl_len;
211 void *fw_desc;
212};
213
214
215struct uf_thread {
216
217 struct task_struct *thread_task;
218
219 /* wait_queue for waking the unifi_thread kernel thread */
220 wait_queue_head_t wakeup_q;
221 unsigned int wakeup_flag;
222
223 /*
224 * Use it to block the I/O thread when
225 * an error occurs or UniFi is reinitialised.
226 */
227 int block_thread;
228
229 char name[16];
230 int prio;
231};
232
233/*
234 * Link list to hold the received packets for the period the port
235 * remains closed.
236 */
237typedef struct rx_buffered_packets {
238 /* List link structure */
239 struct list_head q;
240 /* Packet to indicate when the port reopens */
241 struct sk_buff *skb;
242 /* Bulkdata to free in case the port closes and need to discard the packet */
243 bulk_data_param_t bulkdata;
244 /* The source address of the packet */
245 CsrWifiMacAddress sa;
246 /* The destination address of the packet */
247 CsrWifiMacAddress da;
248 /* Corresponding signal */
249 CSR_SIGNAL signal;
250} rx_buffered_packets_t;
251
252
253typedef u8 CsrWifiAcPowersaveMode;
254#define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
255#define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
256#define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
257#define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
258
259
260#define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
261#define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
262#define IS_DTIM_ACTIVE(flag, hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
263#define INVALID_HOST_TAG 0xFFFFFFFF
264#define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
265
266
267
268
269/* Queue to be used for contention priority */
270
271/*
272 * Link list to hold the tx packets for the period the peer
273 * powersave/free slots in unifi
274 */
275typedef struct tx_buffered_packets {
276 /* List link structure */
277 struct list_head q;
278 u16 interfaceTag;
279 CSR_CLIENT_TAG hostTag;
280 CSR_PROCESS_ID leSenderProcessId;
281 CSR_TRANSMISSION_CONTROL transmissionControl;
282 CSR_RATE rate;
283 /* Bulkdata to free in case the port closes and need to discard the packet */
284 bulk_data_desc_t bulkdata;
285 /* The source address of the packet */
286 CsrWifiMacAddress peerMacAddress;
287 CSR_PRIORITY priority;
288} tx_buffered_packets_t;
289
290/* station record has this data structure */
291typedef struct CsrWifiRouterCtrlStaInfo_t {
292
293 /* Sme sends these parameters */
294 CsrWifiMacAddress peerMacAddress;
295 u32 assignedHandle;
296 u8 wmmOrQosEnabled;
297 CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
298 u16 maxSpLength;
299 u8 uapsdActive;
300 u16 noOfSpFramesSent;
301
302 /* Router/Driver database */
303#ifdef CSR_SUPPORT_SME
304 unifi_port_cfg_t *peerControlledPort;
305 unifi_port_cfg_t *peerUnControlledPort;
306
307 /* Inactivity feature parameters */
308 struct netInterface_priv *interfacePriv;
309 struct work_struct send_disconnected_ind_task;
310 u8 activity_flag;
311 u16 listenIntervalInTus;
312 CSR_CLIENT_TAG nullDataHostTag;
313
314 /* Activity timestamps for the station */
315 u32 lastActivity;
316
317 /* during m/c transmission sp suspended */
318 u8 uspSuspend;
319 CSR_PRIORITY triggerFramePriority;
320#endif
321 CsrWifiRouterCtrlPeerStatus currentPeerState;
322 struct list_head dataPdu[MAX_ACCESS_CATOGORY];
323 struct list_head mgtFrames;
324 u8 spStatus;
325 u8 prevFrmType;
326 u8 prevFrmAccessCatogory;
327 u8 protection;
328 u16 aid;
329 u8 txSuspend;
330 u8 timSet;
331 /* Dont change the value of below macro for SET & RESET */
332#define CSR_WIFI_TIM_RESET 0
333#define CSR_WIFI_TIM_SET 1
334#define CSR_WIFI_TIM_RESETTING 2
335#define CSR_WIFI_TIM_SETTING 3
336
337 u8 timRequestPendingFlag;
338 u8 updateTimReqQueued;
339 u16 noOfPktQueued;
340}CsrWifiRouterCtrlStaInfo_t;
341
342#ifdef CSR_SUPPORT_WEXT_AP
343struct CsrWifiSmeApConfig {
344 CsrWifiSsid ssid;
345 u16 channel;
346 CsrWifiNmeApCredentials credentials;
347 u8 max_connections;
348 u8 if_index;
349};
350#endif
351
352#ifdef CSR_WIFI_RX_PATH_SPLIT
353/* This is a test code and may be removed later*/
354#define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
355
356typedef struct
357{
358 u8 *bufptr; /* Signal Primitive */
359 bulk_data_param_t data_ptrs; /* Bulk Data pointers */
360 u16 sig_len;
361}rx_buff_struct_t;
362
363typedef struct
364{
365 u8 writePointer; /**< write pointer */
366 u8 readPointer; /**< read pointer */
367 u8 size; /**< size of circular buffer */
368 rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE]; /**< Element of ciruclar buffer */
369} rxCircularBuffer_t;
370
371void rx_wq_handler(struct work_struct *work);
372#endif
373
374struct unifi_priv {
375
376 card_t *card;
377 CsrSdioFunction *sdio;
378
379 /* Index into Unifi_instances[] for this device. */
380 int instance;
381 /* Reference count for this instance */
382 int ref_count;
383
384 /* Firmware images */
385 struct dlpriv fw_sta;
386 struct dlpriv fw_conv; /* used for conversion of production test image */
387
388 /* Char device related structures */
389 struct cdev unifi_cdev;
390 struct cdev unifiudi_cdev;
391 struct device *unifi_device;
392
393 /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
394 CSR_IFINTERFACE if_index;
395
396 /* For multiple interface support */
397 struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
398 struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
399
400 u8 totalInterfaceCount;
401
402 int prev_queue;
403
404 /* Name of node under /proc */
405 char proc_entry_name[64];
406
407 /*
408 * Flags:
409 * drop_unencrypted
410 * - Not used?
411 * netdev_registered
412 * - whether the netdev has been registered.
413 */
414 unsigned int drop_unencrypted : 1;
415
416 /* Our list of unifi linux clients. */
417 ul_client_t ul_clients[MAX_UDI_CLIENTS];
418
419 /* Mutex to protect using the logging hook after UDI client is gone */
420 struct semaphore udi_logging_mutex;
421 /* Pointer to the ul_clients[] array */
422 ul_client_t *logging_client;
423
424 /* A ul_client_t* used to send the netdev related MIB requests. */
425 ul_client_t *netdev_client;
426
427 /* The SME ul_client_t pointer. */
428 ul_client_t *sme_cli;
429
430 /* The AMP ul_client_t pointer. */
431 ul_client_t *amp_client;
432
433 /*
434 * Semaphore for locking the top-half to one user process.
435 * This is necessary to prevent multiple processes calling driver
436 * operations. This can happen because the network driver entry points
437 * can be called from multiple processes.
438 */
439#ifdef USE_DRIVER_LOCK
440 struct semaphore lock;
441#endif /* USE_DRIVER_LOCK */
442
443 /* Flag to say that an operation was aborted */
444 int io_aborted;
445
446 struct uf_thread bh_thread;
447
448#define UNIFI_INIT_NONE 0x00
449#define UNIFI_INIT_IN_PROGRESS 0x01
450#define UNIFI_INIT_FW_DOWNLOADED 0x02
451#define UNIFI_INIT_COMPLETED 0x04
452 unsigned char init_progress;
453
454 int sme_is_present;
455
456 /* The WMM features that UniFi uses in the current BSS */
457 unsigned int sta_wmm_capabilities;
458
459 /* Debug only */
460 char last_debug_string[256];
461 unsigned short last_debug_word16[16];
462
463#ifdef CSR_SUPPORT_SME
464 /* lock to protect the tx queues list */
465 spinlock_t tx_q_lock;
466 u8 allPeerDozing;
467 u8 pausedStaHandle[MAX_ACCESS_CATOGORY];
468 /* Max packet the driver can queue, irrespective of interface number */
469 u16 noOfPktQueuedInDriver;
470#define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
471#define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
472#define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
473
474 u8 routerBufferEnable[MAX_ACCESS_CATOGORY];
475 /* lock to protect stainfo members and priv members*/
476 spinlock_t staRecord_lock;
477#endif
478#ifdef CSR_NATIVE_LINUX
479#ifdef CSR_SUPPORT_WEXT
480 /* wireless config */
481 struct wext_config wext_conf;
482#endif
483
484 /* Mutex to protect the MLME blocking requests */
485 struct semaphore mlme_blocking_mutex;
486
487 /* The ul_client that provides the blocking API for WEXT calls */
488 ul_client_t *wext_client;
489
490#endif /* CSR_NATIVE_LINUX */
491
492#ifdef CSR_SUPPORT_SME
493 wait_queue_head_t sme_request_wq;
494 /* Semaphore to protect the SME blocking requests */
495 struct semaphore sme_sem;
496 /* Structure to hold the SME blocking requests data*/
497 sme_reply_t sme_reply;
498
499 /* Structure to hold a traffic protocol indication */
500 struct ta_ind {
501 struct work_struct task;
502 CsrWifiRouterCtrlTrafficPacketType packet_type;
503 CsrWifiRouterCtrlProtocolDirection direction;
504 CsrWifiMacAddress src_addr;
505 int in_use;
506 } ta_ind_work;
507
508 struct ta_sample_ind {
509 struct work_struct task;
510 CsrWifiRouterCtrlTrafficStats stats;
511 int in_use;
512 } ta_sample_ind_work;
513
514 __be32 sta_ip_address;
515 CsrWifiRouterCtrlSmeVersions sme_versions;
516
517 /*
518 * Flag to reflect state of unifi_sys_wifi_on_*() progress.
519 * This indicates whether we are in an "wifi on" state when we are
520 * allowed to indication errors with unifi_mgt_wifi_off_ind()
521 */
522 enum {
523 wifi_on_unspecified = -1,
524 wifi_on_in_progress = 0,
525 wifi_on_done = 1,
526 } wifi_on_state;
527
528 /* Userspace TaskId for the SME Set when a wifi on req is received */
529 CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
530
531 struct work_struct multicast_list_task;
532 /*
533 * The SME installs filters to ask for specific MA-UNITDATA.req
534 * to be passed to different SME components.
535 */
536#define MAX_MA_UNIDATA_IND_FILTERS 8
537 sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
538
539/* UNIFI_CFG related parameters */
540 uf_cfg_bcast_packet_filter_t packet_filters;
541 unsigned char *filter_tclas_ies;
542 /* The structure that holds all the connection configuration. */
543 CsrWifiSmeConnectionConfig connection_config;
544#ifdef CSR_SUPPORT_WEXT
545
546 int ignore_bssid_join;
547 struct iw_statistics wext_wireless_stats;
548
549 /* The MIB and MAC address files contents, read from userspace */
550 CsrWifiSmeDataBlock mib_data;
551 CsrWifiMacAddress sta_mac_address;
552
553 int wep_tx_key_index;
554 wep_key_t wep_keys[NUM_WEPKEYS];
555
556
557#ifdef CSR_SUPPORT_WEXT_AP
558 CsrWifiSmeApMacConfig ap_mac_config;
559 CsrWifiNmeApConfig group_sec_config;
560 CsrWifiSmeApConfig_t ap_config;
561#endif
562 struct work_struct sme_config_task;
563
564#endif /* CSR_SUPPORT_WEXT */
565
566#endif /* CSR_SUPPORT_SME */
567
568#ifdef CSR_SME_USERSPACE
569 void *smepriv;
570#endif /* CSR_SME_USERSPACE */
571
572 card_info_t card_info;
573
574 /* Mutex to protect unifi_send_signal() */
575 spinlock_t send_signal_lock;
576
577
578 /*
579 * The workqueue to offload the TA run
580 * and the multicast addresses list set
581 */
582 struct workqueue_struct *unifi_workqueue;
583
584 unsigned char *mib_cfm_buffer;
585 unsigned int mib_cfm_buffer_length;
586
587 int ptest_mode; /* Set when in production test mode */
588 int coredump_mode; /* Set when SME has requested a coredump */
589 u8 wol_suspend; /* Set when suspending with UniFi powered */
590
591#define UF_UNCONTROLLED_PORT_Q 0
592#define UF_CONTROLLED_PORT_Q 1
593
594 /* Semaphore to protect the rx queues list */
595 struct semaphore rx_q_sem;
596
597 /* Spinlock to protect M4 data */
598 spinlock_t m4_lock;
599 /* Mutex to protect BA RX data */
600 struct semaphore ba_mutex;
601
602#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
603 /* Spinlock to protect the WAPI data */
604 spinlock_t wapi_lock;
605#endif
606
607 /* Array to indicate if a particular Tx queue is paused, this may not be
608 * required in a multiqueue implementation since we can directly stop kernel
609 * queues */
610 u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
611
612#ifdef CSR_WIFI_RX_PATH_SPLIT
613 struct workqueue_struct *rx_workqueue;
614 struct work_struct rx_work_struct;
615 rxCircularBuffer_t rxSignalBuffer;
616
617#endif
618
619 u32 rxTcpThroughput;
620 u32 txTcpThroughput;
621 u32 rxUdpThroughput;
622 u32 txUdpThroughput;
623
624#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
625 /*Set if multicast KeyID = 1*/
626 u8 wapi_multicast_filter;
627 /*Set if unicast KeyID = 1*/
628 u8 wapi_unicast_filter;
629 u8 wapi_unicast_queued_pkt_filter;
630#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
631 u8 isWapiConnection;
632#endif
633#endif
634
635#ifdef CSR_WIFI_SPLIT_PATCH
636 CsrWifiRouterCtrlModeSetReq pending_mode_set;
637#endif
638
639 u8 cmanrTestMode;
640 CSR_RATE cmanrTestModeTransmitRate;
641
642};
643
644typedef struct {
645 u16 queue_length[4];
646 u8 os_queue_paused;
647} unifi_OsQosInfo;
648
649
650typedef struct {
651 u8 active;
652 bulk_data_param_t bulkdata;
653 CSR_SIGNAL signal;
654 u16 sn;
655 u32 recv_time;
656} frame_desc_struct;
657
658typedef struct {
659 frame_desc_struct *buffer;
660 u16 wind_size;
661 u16 occupied_slots;
662 struct timer_list timer;
663 u16 timeout;
664 u16 expected_sn;
665 u16 start_sn;
666 u8 trigger_ba_after_ssn;
667 struct netInterface_priv *interfacePriv;
668 u16 tID;
669 CsrWifiMacAddress macAddress;
670 struct work_struct send_ba_err_task;
671} ba_session_rx_struct;
672
673
674typedef struct {
675 struct netInterface_priv *interfacePriv;
676 u16 tID;
677 CsrWifiMacAddress macAddress;
678} ba_session_tx_struct;
679
680typedef struct netInterface_priv
681{
682 u16 InterfaceTag;
683 struct unifi_priv *privPtr;
684 ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
685 ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
686 frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
687 u8 ba_complete_index;
688 u8 queueEnabled[UNIFI_NO_OF_TX_QS];
689 struct work_struct send_m4_ready_task;
690#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
691 struct work_struct send_pkt_to_encrypt;
692#endif
693 struct net_device_stats stats;
694 u8 interfaceMode;
695 u8 protect;
696 CsrWifiMacAddress bssid;
697 /*
698 * Flag to reflect state of CONNECTED indication signal.
699 * This indicates whether we are "joined" an Access Point (i.e. have
700 * nominated an AP and are receiving beacons) but give no indication
701 * of whether we are authenticated and/or associated.
702 */
703 enum {
704 UnifiConnectedUnknown = -1,
705 UnifiNotConnected = 0,
706 UnifiConnected = 1,
707 } connected;
708#ifdef CSR_SUPPORT_WEXT
709 /* Tracks when we are waiting for a netdevice state change callback */
710 u8 wait_netdev_change;
711 /* True if we have successfully registered for netdev callbacks */
712 u8 netdev_callback_registered;
713#endif /* CSR_SUPPORT_WEXT */
714 unsigned int netdev_registered;
715#define UNIFI_MAX_MULTICAST_ADDRESSES 10
716 /* The multicast addresses list that the thread needs to set. */
717 u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
718 /* The multicast addresses count that the thread needs to set. */
719 int mc_list_count;
720 u32 tag;
721#ifdef CSR_SUPPORT_SME
722 /* (un)controlled port configuration */
723 unifi_port_config_t controlled_data_port;
724 unifi_port_config_t uncontrolled_data_port;
725
726 /* station record maintenance related data structures */
727 u8 num_stations_joined;
728 CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
729 struct list_head genericMgtFrames;
730 struct list_head genericMulticastOrBroadCastFrames;
731 struct list_head genericMulticastOrBroadCastMgtFrames;
732
733 /* Timer for detecting station inactivity */
734 struct timer_list sta_activity_check_timer;
735 u8 sta_activity_check_enabled;
736
737 /* Timestamp when the last inactivity check was done */
738 u32 last_inactivity_check;
739
740 /*number of multicast or borad cast packets queued*/
741 u16 noOfbroadcastPktQueued;
742#endif
743 /* A list to hold the buffered uncontrolled port packets */
744 struct list_head rx_uncontrolled_list;
745 /* A list to hold the buffered controlled port packets */
746 struct list_head rx_controlled_list;
747 /* Buffered M4 signal to take care of WPA race condition */
748 CSR_SIGNAL m4_signal;
749 bulk_data_desc_t m4_bulk_data;
750
751#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
752 /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */
753 CSR_SIGNAL wapi_unicast_ma_pkt_sig;
754 bulk_data_desc_t wapi_unicast_bulk_data;
755#endif
756
757 /* This should be removed and m4_hostTag should be used for checking*/
758 u8 m4_sent;
759 CSR_CLIENT_TAG m4_hostTag;
760 u8 dtimActive;
761 u8 intraBssEnabled;
762 u32 multicastPduHostTag; /* Used to set the tim after getting
763 a confirm for it */
764 u8 bcTimSet;
765 u8 bcTimSetReqPendingFlag;
766 u8 bcTimSetReqQueued;
767} netInterface_priv_t;
768
769#ifdef CSR_SUPPORT_SME
770#define routerStartBuffering(priv, queue) priv->routerBufferEnable[(queue)] = TRUE;
771#define routerStopBuffering(priv, queue) priv->routerBufferEnable[(queue)] = FALSE;
772#define isRouterBufferEnabled(priv, queue) priv->routerBufferEnable[(queue)]
773#endif
774
775#ifdef USE_DRIVER_LOCK
776#define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock)
777#define UNLOCK_DRIVER(_p) up(&(_p)->lock)
778#else
779#define LOCK_DRIVER(_p) (void)(_p); /* as nothing */
780#define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */
781#endif /* USE_DRIVER_LOCK */
782
783s32 CsrHipResultToStatus(CsrResult csrResult);
784
785
786/*
787 * SDIO related functions and callbacks
788 */
789int uf_sdio_load(void);
790void uf_sdio_unload(void);
791unifi_priv_t *uf_find_instance(int inst);
792int uf_find_priv(unifi_priv_t *priv);
793int uf_find_netdev_priv(netInterface_priv_t *priv);
794unifi_priv_t *uf_get_instance(int inst);
795void uf_put_instance(int inst);
796int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
797int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
798
799void uf_add_os_device(int bus_id, struct device *os_device);
800void uf_remove_os_device(int bus_id);
801
802
803
804/*
805 * Claim/release SDIO
806 *
807 * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
808 * as this prevents other functions using SDIO.
809 * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
810 * we have followed this scheme:
811 * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
812 * then we call CsrSdioClaim/CsrSdioRelease().
813 * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
814 * then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
815 * to the SDIO glue layer only (e.g. sdio_mmc.c).
816 * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
817 * then we call directly the sdio_claim_host/sdio_release_host().
818 * Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
819 *
820 * Note: The _func and function pointers are _not_ the same.
821 * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
822 * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
823 */
824
825#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
826
827#ifdef CSR_WIFI_SINGLE_FUNCTION
828#define CsrSdioClaim(function) sdio_claim_host((function)->priv);
829#define CsrSdioRelease(function) sdio_release_host((function)->priv);
830
831#define _sdio_claim_host(_func)
832#define _sdio_release_host(_func)
833
834#else
835#define CsrSdioClaim(function)
836#define CsrSdioRelease(function)
837
838#define _sdio_claim_host(_func) sdio_claim_host(_func)
839#define _sdio_release_host(_func) sdio_release_host(_func)
840
841#endif /* CSR_WIFI_SINGLE_FUNCTION */
842
843#else
844#define _sdio_claim_host(_func)
845#define _sdio_release_host(_func)
846
847#define CsrSdioClaim(function)
848#define CsrSdioRelease(function)
849
850#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
851
852
853/*
854 * Functions to allocate and free an ethernet device.
855 */
856unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
857int uf_free_netdevice(unifi_priv_t *priv);
858
859/* Allocating function for other interfaces */
860u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag);
861
862/*
863 * Firmware download related functions.
864 */
865int uf_run_unifihelper(unifi_priv_t *priv);
866int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
867int uf_release_firmware_files(unifi_priv_t *priv);
868int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
869
870/*
871 * Functions to create and delete the device nodes.
872 */
873int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
874void uf_destroy_device_nodes(unifi_priv_t *priv);
875
876/*
877 * Upper Edge Initialisation functions
878 */
879int uf_init_bh(unifi_priv_t *priv);
880int uf_init_hw(unifi_priv_t *priv);
881
882/* Thread related helper functions */
883int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
884void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
885void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
886
887
888/*
889 * Unifi Linux functions
890 */
891void ul_init_clients(unifi_priv_t *priv);
892
893/* Configuration flags */
894#define CLI_USING_WIRE_FORMAT 0x0002
895#define CLI_SME_USERSPACE 0x0020
896ul_client_t *ul_register_client(unifi_priv_t *priv,
897 unsigned int configuration,
898 udi_event_t udi_event_clbk);
899int ul_deregister_client(ul_client_t *pcli);
900
901int ul_send_signal_unpacked(unifi_priv_t *priv,
902 CSR_SIGNAL *sigptr,
903 bulk_data_param_t *bulkdata);
904int ul_send_signal_raw(unifi_priv_t *priv,
905 unsigned char *sigptr, int siglen,
906 bulk_data_param_t *bulkdata);
907
908void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
909
910
911/*
912 * Data plane operations
913 */
914/*
915 * data_tx.c
916 */
917int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
918 unsigned int length);
919
920#ifdef CSR_SUPPORT_SME
921u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
922u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, u8 pmBit, u16 interfaceTag);
923void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag);
924int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
925 struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
926 const CSR_SIGNAL *signal,
927 bulk_data_param_t *bulkdata,
928 u8 macHeaderLengthInBytes);
929u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
930void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t * priv,
931 CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
932 u16 qosControl,
933 u16 interfaceTag);
934
935void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
936void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
937
938void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
939void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
940void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
941
942
943
944#endif
945CsrResult 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);
946void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata, u32 siglen);
947#ifdef CSR_SUPPORT_SME
948void uf_send_buffered_frames(unifi_priv_t *priv, unifi_TrafficQueue queue);
949int uf_process_station_records_for_sending_data(unifi_priv_t *priv, u16 interfaceTag,
950 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
951 CsrWifiRouterCtrlStaInfo_t *dstStaInfo);
952void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
953 struct list_head *frames_need_cfm_list,
954 struct list_head * list);
955void send_auto_ma_packet_confirm(unifi_priv_t *priv,
956 netInterface_priv_t *interfacePriv,
957 struct list_head *buffered_frames_list);
958void uf_flush_list(unifi_priv_t * priv, struct list_head * list);
959tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList);
960void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag);
961void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag);
962void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag);
963#endif
964/*
965 * netdev.c
966 */
967
968#ifndef P80211_OUI_LEN
969#define P80211_OUI_LEN 3
970#endif
971typedef struct {
972 u8 dsap; /* always 0xAA */
973 u8 ssap; /* always 0xAA */
974 u8 ctrl; /* always 0x03 */
975 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
976 u16 protocol;
977} __attribute__ ((packed)) llc_snap_hdr_t;
978int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto);
979int skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
980 const unsigned char *daddr, const unsigned char *saddr,
981 const CSR_SIGNAL *signal,
982 bulk_data_param_t *bulkdata);
983
984const char *result_code_str(int result);
985
986
987/* prepares & appends the Mac header for the payload */
988int prepare_and_add_macheader(unifi_priv_t *priv,
989 struct sk_buff *skb,
990 struct sk_buff *newSkb,
991 CSR_PRIORITY priority,
992 bulk_data_param_t *bulkdata,
993 u16 interfaceTag,
994 const u8 *daddr,
995 const u8 *saddr,
996 u8 protection);
997CSR_PRIORITY
998get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
999
1000void
1001unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
1002 CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
1003 u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
1004 CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
1005 CSR_SIGNAL *signal);
1006
1007
1008/* Pack the LSB to include station handle & status of tim set */
1009#define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
1010/* get the station record handle from the sender ID */
1011#define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
1012/* get the timSet status from the sender ID */
1013#define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
1014
1015/* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */
1016#define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
1017
1018void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle);
1019void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId);
1020
1021/* Clear the Peer station Record, in case of wifioff/unexpected card removal */
1022void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
1023
1024void scroll_ba_window(unifi_priv_t *priv,
1025 netInterface_priv_t *interfacePriv,
1026 ba_session_rx_struct *ba_session,
1027 u16 sn);
1028
1029u8 blockack_session_stop(unifi_priv_t *priv,
1030 u16 interfaceTag,
1031 CsrWifiRouterCtrlBlockAckRole role,
1032 u16 tID,
1033 CsrWifiMacAddress macAddress);
1034#ifdef CSR_SUPPORT_SME
1035/* Fetch the protection information from interface Mode */
1036s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr);
1037#endif
1038
1039/* Fetch the station record handler from data base for matching Mac address */
1040#ifdef CSR_SUPPORT_SME
1041CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
1042 const u8 *peerMacAddress,
1043 u16 interfaceTag);
1044
1045/* Fetch the station record handler from data base for matching handle */
1046CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
1047 u32 handle,
1048 u16 interfaceTag);
1049
1050void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress);
1051void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
1052#endif
1053
1054void uf_resume_data_plane(unifi_priv_t *priv, int queue,
1055 CsrWifiMacAddress peer_address,
1056 u16 interfaceTag);
1057void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
1058 CsrWifiMacAddress peer_address, u16 interfaceTag);
1059
1060int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
1061void uf_unregister_netdev(unifi_priv_t *priv);
1062
1063void uf_net_get_name(struct net_device *dev, char *name, int len);
1064
1065void uf_send_queue_info(unifi_priv_t *priv);
1066u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag);
1067
1068void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
1069 CsrWifiMacAddress source_address,
1070 int indicate, u16 interfaceTag);
1071
1072#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
1073int uf_register_hip_offline_debug(unifi_priv_t *priv);
1074int uf_unregister_hip_offline_debug(unifi_priv_t *priv);
1075#endif
1076
1077/*
1078 * inet.c
1079 */
1080void uf_register_inet_notifier(void);
1081void uf_unregister_inet_notifier(void);
1082
1083
1084/*
1085 * Suspend / Resume handlers
1086 */
1087void unifi_resume(void *ospriv);
1088void unifi_suspend(void *ospriv);
1089
1090
1091#define QOS_CAPABILITY_WMM_ENABLED 0x0001
1092#define QOS_CAPABILITY_WMM_UAPSD 0x0002
1093#define QOS_CAPABILITY_ACM_BE_ENABLED 0x0010
1094#define QOS_CAPABILITY_ACM_BK_ENABLED 0x0020
1095#define QOS_CAPABILITY_ACM_VI_ENABLED 0x0040
1096#define QOS_CAPABILITY_ACM_VO_ENABLED 0x0080
1097#define QOS_CAPABILITY_TS_BE_ENABLED 0x0100
1098#define QOS_CAPABILITY_TS_BK_ENABLED 0x0200
1099#define QOS_CAPABILITY_TS_VI_ENABLED 0x0400
1100#define QOS_CAPABILITY_TS_VO_ENABLED 0x0800
1101
1102
1103/* EAPOL PDUS */
1104#ifndef ETH_P_PAE
1105#define ETH_P_PAE 0x888e
1106#endif
1107#ifndef ETH_P_WAI
1108#define ETH_P_WAI 0x88b4
1109#endif
1110/*
1111 * unifi_dbg.c
1112 */
1113void debug_string_indication(unifi_priv_t *priv,
1114 const unsigned char *extra,
1115 unsigned int extralen);
1116void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1117void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
1118
1119
1120/*
1121 * putest.c
1122 */
1123int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
1124int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
1125int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
1126int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
1127int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
1128int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
1129int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
1130int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
1131int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
1132
1133int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
1134int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
1135
1136#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
index 50908822b3c8..000000000000
--- a/drivers/staging/csr/unifi_sme.c
+++ /dev/null
@@ -1,1225 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: unifi_sme.c
4 *
5 * PURPOSE: SME related functions.
6 *
7 * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
8 *
9 * Refer to LICENSE.txt included with this source code for details on
10 * the license terms.
11 *
12 * ***************************************************************************
13 */
14
15#include "unifi_priv.h"
16#include "csr_wifi_hip_unifi.h"
17#include "csr_wifi_hip_conversions.h"
18#include <linux/sched/rt.h>
19
20
21
22 int
23convert_sme_error(CsrResult error)
24{
25 switch (error) {
26 case CSR_RESULT_SUCCESS:
27 return 0;
28 case CSR_RESULT_FAILURE:
29 case CSR_WIFI_RESULT_NOT_FOUND:
30 case CSR_WIFI_RESULT_TIMED_OUT:
31 case CSR_WIFI_RESULT_CANCELLED:
32 case CSR_WIFI_RESULT_UNAVAILABLE:
33 return -EIO;
34 case CSR_WIFI_RESULT_NO_ROOM:
35 return -EBUSY;
36 case CSR_WIFI_RESULT_INVALID_PARAMETER:
37 return -EINVAL;
38 case CSR_WIFI_RESULT_UNSUPPORTED:
39 return -EOPNOTSUPP;
40 default:
41 return -EIO;
42 }
43}
44
45
46/*
47 * ---------------------------------------------------------------------------
48 * sme_log_event
49 *
50 * Callback function to be registered as the SME event callback.
51 * Copies the signal content into a new udi_log_t struct and adds
52 * it to the read queue for the SME client.
53 *
54 * Arguments:
55 * arg This is the value given to unifi_add_udi_hook, in
56 * this case a pointer to the client instance.
57 * signal Pointer to the received signal.
58 * signal_len Size of the signal structure in bytes.
59 * bulkdata Pointers to any associated bulk data.
60 * dir Direction of the signal. Zero means from host,
61 * non-zero means to host.
62 *
63 * Returns:
64 * None.
65 * ---------------------------------------------------------------------------
66 */
67 void
68sme_log_event(ul_client_t *pcli,
69 const u8 *signal, int signal_len,
70 const bulk_data_param_t *bulkdata,
71 int dir)
72{
73 unifi_priv_t *priv;
74 CSR_SIGNAL unpacked_signal;
75 CsrWifiSmeDataBlock mlmeCommand;
76 CsrWifiSmeDataBlock dataref1;
77 CsrWifiSmeDataBlock dataref2;
78 CsrResult result = CSR_RESULT_SUCCESS;
79 int r;
80
81 /* Just a sanity check */
82 if ((signal == NULL) || (signal_len <= 0)) {
83 return;
84 }
85
86 priv = uf_find_instance(pcli->instance);
87 if (!priv) {
88 unifi_error(priv, "sme_log_event: invalid priv\n");
89 return;
90 }
91
92 if (priv->smepriv == NULL) {
93 unifi_error(priv, "sme_log_event: invalid smepriv\n");
94 return;
95 }
96
97 unifi_trace(priv, UDBG3,
98 "sme_log_event: Process signal 0x%.4X\n",
99 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(signal));
100
101
102 /* If the signal is known, then do any filtering required, otherwise it pass it to the SME. */
103 r = read_unpack_signal(signal, &unpacked_signal);
104 if (r == CSR_RESULT_SUCCESS) {
105 if ((unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_STRING_INDICATION_ID) ||
106 (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_WORD16_INDICATION_ID))
107 {
108 return;
109 }
110 if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_INDICATION_ID)
111 {
112 u16 frmCtrl;
113 u8 unicastPdu = TRUE;
114 u8 *macHdrLocation;
115 u8 *raddr = NULL, *taddr = NULL;
116 CsrWifiMacAddress peerMacAddress;
117 /* Check if we need to send CsrWifiRouterCtrlMicFailureInd*/
118 CSR_MA_PACKET_INDICATION *ind = &unpacked_signal.u.MaPacketIndication;
119
120 macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
121 /* Fetch the frame control value from mac header */
122 frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
123
124 /* Point to the addresses */
125 raddr = macHdrLocation + MAC_HEADER_ADDR1_OFFSET;
126 taddr = macHdrLocation + MAC_HEADER_ADDR2_OFFSET;
127
128 memcpy(peerMacAddress.a, taddr, ETH_ALEN);
129
130 if(ind->ReceptionStatus == CSR_MICHAEL_MIC_ERROR)
131 {
132 if (*raddr & 0x1)
133 unicastPdu = FALSE;
134
135 CsrWifiRouterCtrlMicFailureIndSend (priv->CSR_WIFI_SME_IFACEQUEUE, 0,
136 (ind->VirtualInterfaceIdentifier & 0xff), peerMacAddress,
137 unicastPdu);
138 return;
139 }
140 else
141 {
142 if(ind->ReceptionStatus == CSR_RX_SUCCESS)
143 {
144 u8 pmBit = (frmCtrl & 0x1000)?0x01:0x00;
145 u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff);
146 CsrWifiRouterCtrlStaInfo_t *srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, taddr, interfaceTag);
147 if((srcStaInfo != NULL) && (uf_check_broadcast_bssid(priv, bulkdata)== FALSE))
148 {
149 uf_process_pm_bit_for_peer(priv, srcStaInfo, pmBit, interfaceTag);
150
151 /* Update station last activity flag */
152 srcStaInfo->activity_flag = TRUE;
153 }
154 }
155 }
156 }
157
158 if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_CONFIRM_ID)
159 {
160 CSR_MA_PACKET_CONFIRM *cfm = &unpacked_signal.u.MaPacketConfirm;
161 u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
162 netInterface_priv_t *interfacePriv;
163 CSR_MA_PACKET_REQUEST *req;
164 CsrWifiMacAddress peerMacAddress;
165
166 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
167 {
168 unifi_error(priv, "Bad MA_PACKET_CONFIRM interfaceTag %d\n", interfaceTag);
169 return;
170 }
171
172 unifi_trace(priv, UDBG1, "MA-PACKET Confirm (%x, %x)\n", cfm->HostTag, cfm->TransmissionStatus);
173
174 interfacePriv = priv->interfacePriv[interfaceTag];
175#ifdef CSR_SUPPORT_SME
176 if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
177 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
178
179 if(cfm->HostTag == interfacePriv->multicastPduHostTag){
180 uf_process_ma_pkt_cfm_for_ap(priv, interfaceTag, cfm);
181 }
182 }
183#endif
184
185 req = &interfacePriv->m4_signal.u.MaPacketRequest;
186
187 if(cfm->HostTag & 0x80000000)
188 {
189 if (cfm->TransmissionStatus != CSR_TX_SUCCESSFUL)
190 {
191 result = CSR_RESULT_FAILURE;
192 }
193#ifdef CSR_SUPPORT_SME
194 memcpy(peerMacAddress.a, req->Ra.x, ETH_ALEN);
195 /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
196 if (interfacePriv->m4_sent && (cfm->HostTag == interfacePriv->m4_hostTag))
197 {
198 unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
199 CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
200 interfaceTag,
201 peerMacAddress,
202 result);
203 interfacePriv->m4_sent = FALSE;
204 interfacePriv->m4_hostTag = 0xffffffff;
205 }
206#endif
207 /* If EAPOL was requested via router APIs then send cfm else ignore*/
208 if((cfm->HostTag & 0x80000000) != CSR_WIFI_EAPOL_M4_HOST_TAG) {
209 CsrWifiRouterMaPacketCfmSend((u16)signal[2],
210 cfm->VirtualInterfaceIdentifier,
211 result,
212 (cfm->HostTag & 0x3fffffff), cfm->Rate);
213 } else {
214 unifi_trace(priv, UDBG1, "%s: M4 received from netdevice\n", __FUNCTION__);
215 }
216 return;
217 }
218 }
219 }
220
221 mlmeCommand.length = signal_len;
222 mlmeCommand.data = (u8*)signal;
223
224 dataref1.length = bulkdata->d[0].data_length;
225 if (dataref1.length > 0) {
226 dataref1.data = (u8 *) bulkdata->d[0].os_data_ptr;
227 } else
228 {
229 dataref1.data = NULL;
230 }
231
232 dataref2.length = bulkdata->d[1].data_length;
233 if (dataref2.length > 0) {
234 dataref2.data = (u8 *) bulkdata->d[1].os_data_ptr;
235 } else
236 {
237 dataref2.data = NULL;
238 }
239
240 CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, mlmeCommand.length, mlmeCommand.data,
241 dataref1.length, dataref1.data,
242 dataref2.length, dataref2.data);
243
244} /* sme_log_event() */
245
246
247/*
248 * ---------------------------------------------------------------------------
249 * uf_sme_port_state
250 *
251 * Return the state of the controlled port.
252 *
253 * Arguments:
254 * priv Pointer to device private context struct
255 * address Pointer to the destination for tx or sender for rx address
256 * queue Controlled or uncontrolled queue
257 *
258 * Returns:
259 * An unifi_ControlledPortAction value.
260 * ---------------------------------------------------------------------------
261 */
262CsrWifiRouterCtrlPortAction
263uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
264{
265 int i;
266 unifi_port_config_t *port;
267 netInterface_priv_t *interfacePriv;
268
269 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
270 unifi_error(priv, "uf_sme_port_state: bad interfaceTag\n");
271 return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
272 }
273
274 interfacePriv = priv->interfacePriv[interfaceTag];
275
276 if (queue == UF_CONTROLLED_PORT_Q) {
277 port = &interfacePriv->controlled_data_port;
278 } else {
279 port = &interfacePriv->uncontrolled_data_port;
280 }
281
282 if (!port->entries_in_use) {
283 unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
284 return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
285 }
286
287 /* If the port configuration is common for all destinations, return it. */
288 if (port->overide_action == UF_DATA_PORT_OVERIDE) {
289 unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
290 port->port_cfg[0].port_action);
291 return port->port_cfg[0].port_action;
292 }
293
294 unifi_trace(priv, UDBG5, "Multiple (%d) port configurations.\n", port->entries_in_use);
295
296 /* If multiple configurations exist.. */
297 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
298 /* .. go through the list and match the destination address. */
299 if (port->port_cfg[i].in_use &&
300 memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
301 /* Return the desired action. */
302 return port->port_cfg[i].port_action;
303 }
304 }
305
306 /* Could not find any information, return Open. */
307 unifi_trace(priv, UDBG5, "port configuration not found, return Open.\n");
308 return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
309} /* uf_sme_port_state() */
310
311/*
312 * ---------------------------------------------------------------------------
313 * uf_sme_port_config_handle
314 *
315 * Return the port config handle of the controlled/uncontrolled port.
316 *
317 * Arguments:
318 * priv Pointer to device private context struct
319 * address Pointer to the destination for tx or sender for rx address
320 * queue Controlled or uncontrolled queue
321 *
322 * Returns:
323 * An unifi_port_cfg_t* .
324 * ---------------------------------------------------------------------------
325 */
326unifi_port_cfg_t*
327uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
328{
329 int i;
330 unifi_port_config_t *port;
331 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
332
333 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
334 unifi_error(priv, "uf_sme_port_config_handle: bad interfaceTag\n");
335 return NULL;
336 }
337
338 if (queue == UF_CONTROLLED_PORT_Q) {
339 port = &interfacePriv->controlled_data_port;
340 } else {
341 port = &interfacePriv->uncontrolled_data_port;
342 }
343
344 if (!port->entries_in_use) {
345 unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
346 return NULL;
347 }
348
349 /* If the port configuration is common for all destinations, return it. */
350 if (port->overide_action == UF_DATA_PORT_OVERIDE) {
351 unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
352 port->port_cfg[0].port_action);
353 if (address) {
354 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]);
355 }
356 return &port->port_cfg[0];
357 }
358
359 unifi_trace(priv, UDBG5, "Multiple port configurations.\n");
360
361 /* If multiple configurations exist.. */
362 for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
363 /* .. go through the list and match the destination address. */
364 if (port->port_cfg[i].in_use &&
365 memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
366 /* Return the desired action. */
367 return &port->port_cfg[i];
368 }
369 }
370
371 /* Could not find any information, return Open. */
372 unifi_trace(priv, UDBG5, "port configuration not found, returning NULL (debug).\n");
373 return NULL;
374} /* uf_sme_port_config_handle */
375
376void
377uf_multicast_list_wq(struct work_struct *work)
378{
379 unifi_priv_t *priv = container_of(work, unifi_priv_t,
380 multicast_list_task);
381 int i;
382 u16 interfaceTag = 0;
383 CsrWifiMacAddress* multicast_address_list = NULL;
384 int mc_count;
385 u8 *mc_list;
386 netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
387
388 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
389 unifi_error(priv, "uf_multicast_list_wq: bad interfaceTag\n");
390 return;
391 }
392
393 unifi_trace(priv, UDBG5,
394 "uf_multicast_list_wq: list count = %d\n",
395 interfacePriv->mc_list_count);
396
397 /* Flush the current list */
398 CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, CSR_WIFI_SME_LIST_ACTION_FLUSH, 0, NULL);
399
400 mc_count = interfacePriv->mc_list_count;
401 mc_list = interfacePriv->mc_list;
402 /*
403 * Allocate a new list, need to free it later
404 * in unifi_mgt_multicast_address_cfm().
405 */
406 multicast_address_list = kmalloc(mc_count * sizeof(CsrWifiMacAddress), GFP_KERNEL);
407
408 if (multicast_address_list == NULL) {
409 return;
410 }
411
412 for (i = 0; i < mc_count; i++) {
413 memcpy(multicast_address_list[i].a, mc_list, ETH_ALEN);
414 mc_list += ETH_ALEN;
415 }
416
417 if (priv->smepriv == NULL) {
418 kfree(multicast_address_list);
419 return;
420 }
421
422 CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
423 interfaceTag,
424 CSR_WIFI_SME_LIST_ACTION_ADD,
425 mc_count, multicast_address_list);
426
427 /* The SME will take a copy of the addreses*/
428 kfree(multicast_address_list);
429}
430
431
432int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg)
433{
434 unifi_cfg_power_t cfg_power;
435 int rc;
436 int wol;
437
438 if (get_user(cfg_power, (unifi_cfg_power_t*)(((unifi_cfg_command_t*)arg) + 1))) {
439 unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
440 return -EFAULT;
441 }
442
443 switch (cfg_power) {
444 case UNIFI_CFG_POWER_OFF:
445 priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
446 rc = sme_sys_suspend(priv);
447 if (rc) {
448 return rc;
449 }
450 break;
451 case UNIFI_CFG_POWER_ON:
452 wol = priv->wol_suspend;
453 rc = sme_sys_resume(priv);
454 if (rc) {
455 return rc;
456 }
457 if (wol) {
458 /* Kick the BH to ensure pending transfers are handled when
459 * a suspend happened with card powered.
460 */
461 unifi_send_signal(priv->card, NULL, 0, NULL);
462 }
463 break;
464 default:
465 unifi_error(priv, "WIFI POWER: Unknown value.\n");
466 return -EINVAL;
467 }
468
469 return 0;
470}
471
472
473int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg)
474{
475 unifi_cfg_powersave_t cfg_power_save;
476 CsrWifiSmePowerConfig powerConfig;
477 int rc;
478
479 if (get_user(cfg_power_save, (unifi_cfg_powersave_t*)(((unifi_cfg_command_t*)arg) + 1))) {
480 unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
481 return -EFAULT;
482 }
483
484 /* Get the coex info from the SME */
485 rc = sme_mgt_power_config_get(priv, &powerConfig);
486 if (rc) {
487 unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
488 return rc;
489 }
490
491 switch (cfg_power_save) {
492 case UNIFI_CFG_POWERSAVE_NONE:
493 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
494 break;
495 case UNIFI_CFG_POWERSAVE_FAST:
496 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
497 break;
498 case UNIFI_CFG_POWERSAVE_FULL:
499 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
500 break;
501 case UNIFI_CFG_POWERSAVE_AUTO:
502 powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
503 break;
504 default:
505 unifi_error(priv, "POWERSAVE: Unknown value.\n");
506 return -EINVAL;
507 }
508
509 rc = sme_mgt_power_config_set(priv, &powerConfig);
510
511 if (rc) {
512 unifi_error(priv, "UNIFI_CFG: Set unifi_PowerConfigValue failed.\n");
513 }
514
515 return rc;
516}
517
518
519int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg)
520{
521 unifi_cfg_powersupply_t cfg_power_supply;
522 CsrWifiSmeHostConfig hostConfig;
523 int rc;
524
525 if (get_user(cfg_power_supply, (unifi_cfg_powersupply_t*)(((unifi_cfg_command_t*)arg) + 1))) {
526 unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
527 return -EFAULT;
528 }
529
530 /* Get the coex info from the SME */
531 rc = sme_mgt_host_config_get(priv, &hostConfig);
532 if (rc) {
533 unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
534 return rc;
535 }
536
537 switch (cfg_power_supply) {
538 case UNIFI_CFG_POWERSUPPLY_MAINS:
539 hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE;
540 break;
541 case UNIFI_CFG_POWERSUPPLY_BATTERIES:
542 hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE;
543 break;
544 default:
545 unifi_error(priv, "POWERSUPPLY: Unknown value.\n");
546 return -EINVAL;
547 }
548
549 rc = sme_mgt_host_config_set(priv, &hostConfig);
550 if (rc) {
551 unifi_error(priv, "UNIFI_CFG: Set unifi_HostConfigValue failed.\n");
552 }
553
554 return rc;
555}
556
557
558int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
559{
560 unsigned char *tclas_buffer;
561 unsigned int tclas_buffer_length;
562 tclas_t *dhcp_tclas;
563 int rc;
564
565 /* Free any TCLASs previously allocated */
566 if (priv->packet_filters.tclas_ies_length) {
567 kfree(priv->filter_tclas_ies);
568 priv->filter_tclas_ies = NULL;
569 }
570
571 tclas_buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
572 if (copy_from_user(&priv->packet_filters, (void*)tclas_buffer,
573 sizeof(uf_cfg_bcast_packet_filter_t))) {
574 unifi_error(priv, "UNIFI_CFG: Failed to get the filter struct\n");
575 return -EFAULT;
576 }
577
578 tclas_buffer_length = priv->packet_filters.tclas_ies_length;
579
580 /* Allocate TCLASs if necessary */
581 if (priv->packet_filters.dhcp_filter) {
582 priv->packet_filters.tclas_ies_length += sizeof(tclas_t);
583 }
584 if (priv->packet_filters.tclas_ies_length > 0) {
585 priv->filter_tclas_ies = kmalloc(priv->packet_filters.tclas_ies_length, GFP_KERNEL);
586 if (priv->filter_tclas_ies == NULL) {
587 return -ENOMEM;
588 }
589 if (tclas_buffer_length) {
590 tclas_buffer += sizeof(uf_cfg_bcast_packet_filter_t) - sizeof(unsigned char*);
591 if (copy_from_user(priv->filter_tclas_ies,
592 tclas_buffer,
593 tclas_buffer_length)) {
594 unifi_error(priv, "UNIFI_CFG: Failed to get the TCLAS buffer\n");
595 return -EFAULT;
596 }
597 }
598 }
599
600 if(priv->packet_filters.dhcp_filter)
601 {
602 /* Append the DHCP tclas IE */
603 dhcp_tclas = (tclas_t*)(priv->filter_tclas_ies + tclas_buffer_length);
604 memset(dhcp_tclas, 0, sizeof(tclas_t));
605 dhcp_tclas->element_id = 14;
606 dhcp_tclas->length = sizeof(tcpip_clsfr_t) + 1;
607 dhcp_tclas->user_priority = 0;
608 dhcp_tclas->tcp_ip_cls_fr.cls_fr_type = 1;
609 dhcp_tclas->tcp_ip_cls_fr.version = 4;
610 ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00;
611 ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44;
612 ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00;
613 ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43;
614 dhcp_tclas->tcp_ip_cls_fr.protocol = 0x11;
615 dhcp_tclas->tcp_ip_cls_fr.cls_fr_mask = 0x58; //bits: 3,4,6
616 }
617
618 rc = sme_mgt_packet_filter_set(priv);
619
620 return rc;
621}
622
623
624int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg)
625{
626 u8 wmm_qos_info;
627 int rc = 0;
628
629 if (get_user(wmm_qos_info, (u8*)(((unifi_cfg_command_t*)arg) + 1))) {
630 unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
631 return -EFAULT;
632 }
633
634 /* Store the value in the connection info */
635 priv->connection_config.wmmQosInfo = wmm_qos_info;
636
637 return rc;
638}
639
640
641int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
642{
643 u32 addts_tid;
644 u8 addts_ie_length;
645 u8 *addts_ie;
646 u8 *addts_params;
647 CsrWifiSmeDataBlock tspec;
648 CsrWifiSmeDataBlock tclas;
649 int rc;
650
651 addts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
652 if (get_user(addts_tid, (u32*)addts_params)) {
653 unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
654 return -EFAULT;
655 }
656
657 addts_params += sizeof(u32);
658 if (get_user(addts_ie_length, (u8*)addts_params)) {
659 unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
660 return -EFAULT;
661 }
662
663 unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n",
664 addts_tid, addts_ie_length);
665
666 addts_ie = kmalloc(addts_ie_length, GFP_KERNEL);
667 if (addts_ie == NULL) {
668 unifi_error(priv,
669 "unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n",
670 addts_ie_length);
671 return -ENOMEM;
672 }
673
674 addts_params += sizeof(u8);
675 rc = copy_from_user(addts_ie, addts_params, addts_ie_length);
676 if (rc) {
677 unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n");
678 kfree(addts_ie);
679 return -EFAULT;
680 }
681
682 tspec.data = addts_ie;
683 tspec.length = addts_ie_length;
684 tclas.data = NULL;
685 tclas.length = 0;
686
687 rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_ADD, addts_tid,
688 &tspec, &tclas);
689
690 kfree(addts_ie);
691 return rc;
692}
693
694
695int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg)
696{
697 u32 delts_tid;
698 u8 *delts_params;
699 CsrWifiSmeDataBlock tspec;
700 CsrWifiSmeDataBlock tclas;
701 int rc;
702
703 delts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
704 if (get_user(delts_tid, (u32*)delts_params)) {
705 unifi_error(priv, "unifi_cfg_wmm_delts: Failed to get the argument\n");
706 return -EFAULT;
707 }
708
709 unifi_trace(priv, UDBG4, "delts: tid = 0x%x\n", delts_tid);
710
711 tspec.data = tclas.data = NULL;
712 tspec.length = tclas.length = 0;
713
714 rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_REMOVE, delts_tid,
715 &tspec, &tclas);
716
717 return rc;
718}
719
720int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg)
721{
722 u8 strict_draft_n;
723 u8 *strict_draft_n_params;
724 int rc;
725
726 CsrWifiSmeStaConfig staConfig;
727 CsrWifiSmeDeviceConfig deviceConfig;
728
729 strict_draft_n_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
730 if (get_user(strict_draft_n, (u8*)strict_draft_n_params)) {
731 unifi_error(priv, "unifi_cfg_strict_draft_n: Failed to get the argument\n");
732 return -EFAULT;
733 }
734
735 unifi_trace(priv, UDBG4, "strict_draft_n: = %s\n", ((strict_draft_n) ? "yes":"no"));
736
737 rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
738
739 if (rc) {
740 unifi_warning(priv, "unifi_cfg_strict_draft_n: Get unifi_SMEConfigValue failed.\n");
741 return -EFAULT;
742 }
743
744 deviceConfig.enableStrictDraftN = strict_draft_n;
745
746 rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
747 if (rc) {
748 unifi_warning(priv, "unifi_cfg_strict_draft_n: Set unifi_SMEConfigValue failed.\n");
749 rc = -EFAULT;
750 }
751
752 return rc;
753}
754
755
756int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg)
757{
758 u8 enable_okc;
759 u8 *enable_okc_params;
760 int rc;
761
762 CsrWifiSmeStaConfig staConfig;
763 CsrWifiSmeDeviceConfig deviceConfig;
764
765 enable_okc_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
766 if (get_user(enable_okc, (u8*)enable_okc_params)) {
767 unifi_error(priv, "unifi_cfg_enable_okc: Failed to get the argument\n");
768 return -EFAULT;
769 }
770
771 unifi_trace(priv, UDBG4, "enable_okc: = %s\n", ((enable_okc) ? "yes":"no"));
772
773 rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
774 if (rc) {
775 unifi_warning(priv, "unifi_cfg_enable_okc: Get unifi_SMEConfigValue failed.\n");
776 return -EFAULT;
777 }
778
779 staConfig.enableOpportunisticKeyCaching = enable_okc;
780
781 rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
782 if (rc) {
783 unifi_warning(priv, "unifi_cfg_enable_okc: Set unifi_SMEConfigValue failed.\n");
784 rc = -EFAULT;
785 }
786
787 return rc;
788}
789
790
791int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
792{
793 unifi_cfg_get_t get_cmd;
794 char inst_name[IFNAMSIZ];
795 int rc;
796
797 if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) {
798 unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
799 return -EFAULT;
800 }
801
802 switch (get_cmd) {
803 case UNIFI_CFG_GET_COEX:
804 {
805 CsrWifiSmeCoexInfo coexInfo;
806 /* Get the coex info from the SME */
807 rc = sme_mgt_coex_info_get(priv, &coexInfo);
808 if (rc) {
809 unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n");
810 return rc;
811 }
812
813 /* Copy the info to the out buffer */
814 if (copy_to_user((void*)arg,
815 &coexInfo,
816 sizeof(CsrWifiSmeCoexInfo))) {
817 unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n");
818 return -EFAULT;
819 }
820 break;
821 }
822 case UNIFI_CFG_GET_POWER_MODE:
823 {
824 CsrWifiSmePowerConfig powerConfig;
825 rc = sme_mgt_power_config_get(priv, &powerConfig);
826 if (rc) {
827 unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
828 return rc;
829 }
830
831 /* Copy the info to the out buffer */
832 if (copy_to_user((void*)arg,
833 &powerConfig.powerSaveLevel,
834 sizeof(CsrWifiSmePowerSaveLevel))) {
835 unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n");
836 return -EFAULT;
837 }
838 break;
839 }
840 case UNIFI_CFG_GET_POWER_SUPPLY:
841 {
842 CsrWifiSmeHostConfig hostConfig;
843 rc = sme_mgt_host_config_get(priv, &hostConfig);
844 if (rc) {
845 unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
846 return rc;
847 }
848
849 /* Copy the info to the out buffer */
850 if (copy_to_user((void*)arg,
851 &hostConfig.powerMode,
852 sizeof(CsrWifiSmeHostPowerMode))) {
853 unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n");
854 return -EFAULT;
855 }
856 break;
857 }
858 case UNIFI_CFG_GET_VERSIONS:
859 break;
860 case UNIFI_CFG_GET_INSTANCE:
861 {
862 u16 InterfaceId=0;
863 uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name));
864
865 /* Copy the info to the out buffer */
866 if (copy_to_user((void*)arg,
867 &inst_name[0],
868 sizeof(inst_name))) {
869 unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n");
870 return -EFAULT;
871 }
872 }
873 break;
874
875 case UNIFI_CFG_GET_AP_CONFIG:
876 {
877#ifdef CSR_SUPPORT_WEXT_AP
878 uf_cfg_ap_config_t cfg_ap_config;
879
880 memset(&cfg_ap_config, 0, sizeof(cfg_ap_config));
881 cfg_ap_config.channel = priv->ap_config.channel;
882 cfg_ap_config.beaconInterval = priv->ap_mac_config.beaconInterval;
883 cfg_ap_config.wmmEnabled = priv->ap_mac_config.wmmEnabled;
884 cfg_ap_config.dtimPeriod = priv->ap_mac_config.dtimPeriod;
885 cfg_ap_config.phySupportedBitmap = priv->ap_mac_config.phySupportedBitmap;
886 if (copy_to_user((void*)arg,
887 &cfg_ap_config,
888 sizeof(uf_cfg_ap_config_t))) {
889 unifi_error(priv, "UNIFI_CFG: Failed to copy the AP configuration\n");
890 return -EFAULT;
891 }
892#else
893 return -EPERM;
894#endif
895 }
896 break;
897
898
899 default:
900 unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n");
901 return -EINVAL;
902 }
903
904 return 0;
905}
906#ifdef CSR_SUPPORT_WEXT_AP
907int
908 uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap)
909{
910 int i=0;
911 u8 b=FALSE, g = FALSE, n = FALSE;
912 b = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_B;
913 n = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_N;
914 g = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_G;
915 if(b || g) {
916 supportedRates[i++]=0x82;
917 supportedRates[i++]=0x84;
918 supportedRates[i++]=0x8b;
919 supportedRates[i++]=0x96;
920 } else if(n) {
921 /* For some strange reasons WiFi stack needs both b and g rates*/
922 supportedRates[i++]=0x02;
923 supportedRates[i++]=0x04;
924 supportedRates[i++]=0x0b;
925 supportedRates[i++]=0x16;
926 supportedRates[i++]=0x0c;
927 supportedRates[i++]=0x12;
928 supportedRates[i++]=0x18;
929 supportedRates[i++]=0x24;
930 supportedRates[i++]=0x30;
931 supportedRates[i++]=0x48;
932 supportedRates[i++]=0x60;
933 supportedRates[i++]=0x6c;
934 }
935 if(g) {
936 if(!b) {
937 supportedRates[i++]=0x8c;
938 supportedRates[i++]=0x98;
939 supportedRates[i++]=0xb0;
940 } else {
941 supportedRates[i++]=0x0c;
942 supportedRates[i++]=0x18;
943 supportedRates[i++]=0x30;
944 }
945 supportedRates[i++]=0x48;
946 supportedRates[i++]=0x12;
947 supportedRates[i++]=0x24;
948 supportedRates[i++]=0x60;
949 supportedRates[i++]=0x6c;
950 }
951 return i;
952}
953int unifi_cfg_set_ap_config(unifi_priv_t * priv, unsigned char* arg)
954{
955 uf_cfg_ap_config_t cfg_ap_config;
956 char *buffer;
957
958 buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
959 if (copy_from_user(&cfg_ap_config, (void*)buffer,
960 sizeof(uf_cfg_ap_config_t))) {
961 unifi_error(priv, "UNIFI_CFG: Failed to get the ap config struct\n");
962 return -EFAULT;
963 }
964 priv->ap_config.channel = cfg_ap_config.channel;
965 priv->ap_mac_config.dtimPeriod = cfg_ap_config.dtimPeriod;
966 priv->ap_mac_config.beaconInterval = cfg_ap_config.beaconInterval;
967 priv->group_sec_config.apGroupkeyTimeout = cfg_ap_config.groupkeyTimeout;
968 priv->group_sec_config.apStrictGtkRekey = cfg_ap_config.strictGtkRekeyEnabled;
969 priv->group_sec_config.apGmkTimeout = cfg_ap_config.gmkTimeout;
970 priv->group_sec_config.apResponseTimeout = cfg_ap_config.responseTimeout;
971 priv->group_sec_config.apRetransLimit = cfg_ap_config.retransLimit;
972
973 priv->ap_mac_config.shortSlotTimeEnabled = cfg_ap_config.shortSlotTimeEnabled;
974 priv->ap_mac_config.ctsProtectionType=cfg_ap_config.ctsProtectionType;
975
976 priv->ap_mac_config.wmmEnabled = cfg_ap_config.wmmEnabled;
977
978 priv->ap_mac_config.apHtParams.rxStbc=cfg_ap_config.rxStbc;
979 priv->ap_mac_config.apHtParams.rifsModeAllowed=cfg_ap_config.rifsModeAllowed;
980
981 priv->ap_mac_config.phySupportedBitmap = cfg_ap_config.phySupportedBitmap;
982 priv->ap_mac_config.maxListenInterval=cfg_ap_config.maxListenInterval;
983
984 priv->ap_mac_config.supportedRatesCount= uf_configure_supported_rates(priv->ap_mac_config.supportedRates, priv->ap_mac_config.phySupportedBitmap);
985
986 return 0;
987}
988
989#endif
990#ifdef CSR_SUPPORT_WEXT
991
992 void
993uf_sme_config_wq(struct work_struct *work)
994{
995 CsrWifiSmeStaConfig staConfig;
996 CsrWifiSmeDeviceConfig deviceConfig;
997 unifi_priv_t *priv = container_of(work, unifi_priv_t, sme_config_task);
998
999 /* Register to receive indications from the SME */
1000 CsrWifiSmeEventMaskSetReqSend(0,
1001 CSR_WIFI_SME_INDICATIONS_WIFIOFF | CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY |
1002 CSR_WIFI_SME_INDICATIONS_MEDIASTATUS | CSR_WIFI_SME_INDICATIONS_MICFAILURE);
1003
1004 if (sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig)) {
1005 unifi_warning(priv, "uf_sme_config_wq: Get unifi_SMEConfigValue failed.\n");
1006 return;
1007 }
1008
1009 if (priv->if_index == CSR_INDEX_5G) {
1010 staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_5_0;
1011 } else {
1012 staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_2_4;
1013 }
1014
1015 deviceConfig.trustLevel = (CsrWifiSme80211dTrustLevel)tl_80211d;
1016 if (sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig)) {
1017 unifi_warning(priv,
1018 "SME config for 802.11d Trust Level and Radio Band failed.\n");
1019 return;
1020 }
1021
1022} /* uf_sme_config_wq() */
1023
1024#endif /* CSR_SUPPORT_WEXT */
1025
1026
1027/*
1028 * ---------------------------------------------------------------------------
1029 * uf_ta_ind_wq
1030 *
1031 * Deferred work queue function to send Traffic Analysis protocols
1032 * indications to the SME.
1033 * These are done in a deferred work queue for two reasons:
1034 * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
1035 * - we want to load the main driver data path as lightly as possible
1036 *
1037 * The TA classifications already come from a workqueue.
1038 *
1039 * Arguments:
1040 * work Pointer to work queue item.
1041 *
1042 * Returns:
1043 * None.
1044 * ---------------------------------------------------------------------------
1045 */
1046 void
1047uf_ta_ind_wq(struct work_struct *work)
1048{
1049 struct ta_ind *ind = container_of(work, struct ta_ind, task);
1050 unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_ind_work);
1051 u16 interfaceTag = 0;
1052
1053
1054 CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
1055 interfaceTag,
1056 ind->packet_type,
1057 ind->direction,
1058 ind->src_addr);
1059 ind->in_use = 0;
1060
1061} /* uf_ta_ind_wq() */
1062
1063
1064/*
1065 * ---------------------------------------------------------------------------
1066 * uf_ta_sample_ind_wq
1067 *
1068 * Deferred work queue function to send Traffic Analysis sample
1069 * indications to the SME.
1070 * These are done in a deferred work queue for two reasons:
1071 * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
1072 * - we want to load the main driver data path as lightly as possible
1073 *
1074 * The TA classifications already come from a workqueue.
1075 *
1076 * Arguments:
1077 * work Pointer to work queue item.
1078 *
1079 * Returns:
1080 * None.
1081 * ---------------------------------------------------------------------------
1082 */
1083 void
1084uf_ta_sample_ind_wq(struct work_struct *work)
1085{
1086 struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task);
1087 unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work);
1088 u16 interfaceTag = 0;
1089
1090 unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n",
1091 priv->rxTcpThroughput,
1092 priv->txTcpThroughput,
1093 priv->rxUdpThroughput,
1094 priv->txUdpThroughput,
1095 priv->bh_thread.prio);
1096
1097 if(priv->rxTcpThroughput > 1000)
1098 {
1099 if (bh_priority == -1 && priv->bh_thread.prio != 1)
1100 {
1101 struct sched_param param;
1102 priv->bh_thread.prio = 1;
1103 unifi_trace(priv, UDBG1, "%s new thread (RT) priority = %d\n",
1104 priv->bh_thread.name, priv->bh_thread.prio);
1105 param.sched_priority = priv->bh_thread.prio;
1106 sched_setscheduler(priv->bh_thread.thread_task, SCHED_FIFO, &param);
1107 }
1108 } else
1109 {
1110 if (bh_priority == -1 && priv->bh_thread.prio != DEFAULT_PRIO)
1111 {
1112 struct sched_param param;
1113 param.sched_priority = 0;
1114 sched_setscheduler(priv->bh_thread.thread_task, SCHED_NORMAL, &param);
1115 priv->bh_thread.prio = DEFAULT_PRIO;
1116 unifi_trace(priv, UDBG1, "%s new thread priority = %d\n",
1117 priv->bh_thread.name, priv->bh_thread.prio);
1118 set_user_nice(priv->bh_thread.thread_task, PRIO_TO_NICE(priv->bh_thread.prio));
1119 }
1120 }
1121
1122 CsrWifiRouterCtrlTrafficSampleIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, ind->stats);
1123
1124 ind->in_use = 0;
1125
1126} /* uf_ta_sample_ind_wq() */
1127
1128
1129/*
1130 * ---------------------------------------------------------------------------
1131 * uf_send_m4_ready_wq
1132 *
1133 * Deferred work queue function to send M4 ReadyToSend inds to the SME.
1134 * These are done in a deferred work queue for two reasons:
1135 * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
1136 * - we want to load the main driver data path as lightly as possible
1137 *
1138 * Arguments:
1139 * work Pointer to work queue item.
1140 *
1141 * Returns:
1142 * None.
1143 * ---------------------------------------------------------------------------
1144 */
1145void
1146uf_send_m4_ready_wq(struct work_struct *work)
1147{
1148 netInterface_priv_t *InterfacePriv = container_of(work, netInterface_priv_t, send_m4_ready_task);
1149 u16 iface = InterfacePriv->InterfaceTag;
1150 unifi_priv_t *priv = InterfacePriv->privPtr;
1151 CSR_MA_PACKET_REQUEST *req = &InterfacePriv->m4_signal.u.MaPacketRequest;
1152 CsrWifiMacAddress peer;
1153 unsigned long flags;
1154
1155 /* The peer address was stored in the signal */
1156 spin_lock_irqsave(&priv->m4_lock, flags);
1157 memcpy(peer.a, req->Ra.x, sizeof(peer.a));
1158 spin_unlock_irqrestore(&priv->m4_lock, flags);
1159
1160 /* Send a signal to SME */
1161 CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, iface, peer);
1162
1163 unifi_trace(priv, UDBG1, "M4ReadyToSendInd sent for peer %pMF\n",
1164 peer.a);
1165
1166} /* uf_send_m4_ready_wq() */
1167
1168#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
1169/*
1170 * ---------------------------------------------------------------------------
1171 * uf_send_pkt_to_encrypt
1172 *
1173 * Deferred work queue function to send the WAPI data pkts to SME when unicast KeyId = 1
1174 * These are done in a deferred work queue for two reasons:
1175 * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
1176 * - we want to load the main driver data path as lightly as possible
1177 *
1178 * Arguments:
1179 * work Pointer to work queue item.
1180 *
1181 * Returns:
1182 * None.
1183 * ---------------------------------------------------------------------------
1184 */
1185void uf_send_pkt_to_encrypt(struct work_struct *work)
1186{
1187 netInterface_priv_t *interfacePriv = container_of(work, netInterface_priv_t, send_pkt_to_encrypt);
1188 u16 interfaceTag = interfacePriv->InterfaceTag;
1189 unifi_priv_t *priv = interfacePriv->privPtr;
1190
1191 u32 pktBulkDataLength;
1192 u8 *pktBulkData;
1193 unsigned long flags;
1194
1195 if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
1196
1197 pktBulkDataLength = interfacePriv->wapi_unicast_bulk_data.data_length;
1198
1199 if (pktBulkDataLength > 0) {
1200 pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
1201 } else {
1202 unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n");
1203 return;
1204 }
1205
1206 spin_lock_irqsave(&priv->wapi_lock, flags);
1207 /* Copy over the MA PKT REQ bulk data */
1208 memcpy(pktBulkData, (u8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength);
1209 /* Free any bulk data buffers allocated for the WAPI Data pkt */
1210 unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
1211 interfacePriv->wapi_unicast_bulk_data.net_buf_length = 0;
1212 interfacePriv->wapi_unicast_bulk_data.data_length = 0;
1213 interfacePriv->wapi_unicast_bulk_data.os_data_ptr = interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = NULL;
1214 spin_unlock_irqrestore(&priv->wapi_lock, flags);
1215
1216 CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, pktBulkDataLength, pktBulkData);
1217 unifi_trace(priv, UDBG1, "WapiUnicastTxEncryptInd sent to SME\n");
1218
1219 kfree(pktBulkData); /* Would have been copied over by the SME Handler */
1220
1221 } else {
1222 unifi_warning(priv, "uf_send_pkt_to_encrypt() is NOT applicable for interface mode - %d\n", interfacePriv->interfaceMode);
1223 }
1224}/* uf_send_pkt_to_encrypt() */
1225#endif
diff --git a/drivers/staging/csr/unifi_sme.h b/drivers/staging/csr/unifi_sme.h
deleted file mode 100644
index aff9aa178124..000000000000
--- a/drivers/staging/csr/unifi_sme.h
+++ /dev/null
@@ -1,245 +0,0 @@
1/*
2 * ***************************************************************************
3 * FILE: unifi_sme.h
4 *
5 * PURPOSE: SME related definitions.
6 *
7 * Copyright (C) 2007-2011 by Cambridge Silicon Radio Ltd.
8 *
9 * Refer to LICENSE.txt included with this source code for details on
10 * the license terms.
11 *
12 * ***************************************************************************
13 */
14#ifndef __LINUX_UNIFI_SME_H__
15#define __LINUX_UNIFI_SME_H__ 1
16
17#include <linux/kernel.h>
18
19#ifdef CSR_SME_USERSPACE
20#include "sme_userspace.h"
21#endif
22
23#include "csr_wifi_sme_lib.h"
24
25typedef int unifi_data_port_action;
26
27typedef struct unifi_port_cfg
28{
29 /* TRUE if this port entry is allocated */
30 u8 in_use;
31 CsrWifiRouterCtrlPortAction port_action;
32 CsrWifiMacAddress mac_address;
33} unifi_port_cfg_t;
34
35#define UNIFI_MAX_CONNECTIONS 8
36#define UNIFI_MAX_RETRY_LIMIT 5
37#define UF_DATA_PORT_NOT_OVERIDE 0
38#define UF_DATA_PORT_OVERIDE 1
39
40typedef struct unifi_port_config
41{
42 int entries_in_use;
43 int overide_action;
44 unifi_port_cfg_t port_cfg[UNIFI_MAX_CONNECTIONS];
45} unifi_port_config_t;
46
47
48enum sme_request_status {
49 SME_REQUEST_EMPTY,
50 SME_REQUEST_PENDING,
51 SME_REQUEST_RECEIVED,
52 SME_REQUEST_TIMEDOUT,
53 SME_REQUEST_CANCELLED,
54};
55
56/* Structure to hold a UDI logged signal */
57typedef struct {
58
59 /* The current status of the request */
60 enum sme_request_status request_status;
61
62 /* The status the SME has passed to us */
63 CsrResult reply_status;
64
65 /* SME's reply to a get request */
66 CsrWifiSmeVersions versions;
67 CsrWifiSmePowerConfig powerConfig;
68 CsrWifiSmeHostConfig hostConfig;
69 CsrWifiSmeStaConfig staConfig;
70 CsrWifiSmeDeviceConfig deviceConfig;
71 CsrWifiSmeCoexInfo coexInfo;
72 CsrWifiSmeCoexConfig coexConfig;
73 CsrWifiSmeMibConfig mibConfig;
74 CsrWifiSmeConnectionInfo connectionInfo;
75 CsrWifiSmeConnectionConfig connectionConfig;
76 CsrWifiSmeConnectionStats connectionStats;
77
78
79 /* SME's reply to a scan request */
80 u16 reply_scan_results_count;
81 CsrWifiSmeScanResult* reply_scan_results;
82
83} sme_reply_t;
84
85
86typedef struct {
87 u16 appHandle;
88 CsrWifiRouterEncapsulation encapsulation;
89 u16 protocol;
90 u8 oui[3];
91 u8 in_use;
92} sme_ma_unidata_ind_filter_t;
93
94
95CsrWifiRouterCtrlPortAction uf_sme_port_state(unifi_priv_t *priv,
96 unsigned char *address,
97 int queue,
98 u16 interfaceTag);
99unifi_port_cfg_t *uf_sme_port_config_handle(unifi_priv_t *priv,
100 unsigned char *address,
101 int queue,
102 u16 interfaceTag);
103
104
105
106/* Callback for event logging to SME clients */
107void sme_log_event(ul_client_t *client, const u8 *signal, int signal_len,
108 const bulk_data_param_t *bulkdata, int dir);
109
110/* The workqueue task to the set the multicast addresses list */
111void uf_multicast_list_wq(struct work_struct *work);
112
113/* The workqueue task to execute the TA module */
114void uf_ta_wq(struct work_struct *work);
115
116
117/*
118 * SME blocking helper functions
119 */
120#ifdef UNIFI_DEBUG
121# define sme_complete_request(priv, status) uf_sme_complete_request(priv, status, __func__)
122#else
123# define sme_complete_request(priv, status) uf_sme_complete_request(priv, status, NULL)
124#endif
125
126void uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func);
127void uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status);
128
129
130/*
131 * Blocking functions using the SME SYS API.
132 */
133int sme_sys_suspend(unifi_priv_t *priv);
134int sme_sys_resume(unifi_priv_t *priv);
135
136
137/*
138 * Traffic Analysis workqueue jobs
139 */
140void uf_ta_ind_wq(struct work_struct *work);
141void uf_ta_sample_ind_wq(struct work_struct *work);
142
143/*
144 * SME config workqueue job
145 */
146void uf_sme_config_wq(struct work_struct *work);
147
148/*
149 * To send M4 read to send IND
150 */
151void uf_send_m4_ready_wq(struct work_struct *work);
152
153#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
154/*
155 * To send data pkt to Sme for encryption
156 */
157void uf_send_pkt_to_encrypt(struct work_struct *work);
158#endif
159
160int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig);
161int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig);
162int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig);
163int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig);
164int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig);
165int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig);
166int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo);
167int sme_mgt_packet_filter_set(unifi_priv_t *priv);
168int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
169 u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas);
170
171#ifdef CSR_SUPPORT_WEXT
172/*
173 * Blocking functions using the SME MGT API.
174 */
175int sme_mgt_wifi_on(unifi_priv_t *priv);
176int sme_mgt_wifi_off(unifi_priv_t *priv);
177/*int sme_mgt_set_value_async(unifi_priv_t *priv, unifi_AppValue *app_value);
178int sme_mgt_get_value_async(unifi_priv_t *priv, unifi_AppValue *app_value);
179int sme_mgt_get_value(unifi_priv_t *priv, unifi_AppValue *app_value);
180int sme_mgt_set_value(unifi_priv_t *priv, unifi_AppValue *app_value);
181*/
182int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig);
183int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig);
184int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig);
185int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig);
186
187int sme_mgt_connection_info_set(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo);
188int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo);
189int sme_mgt_connection_config_set(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig);
190int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig);
191int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats);
192
193int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions);
194
195
196int sme_mgt_scan_full(unifi_priv_t *priv, CsrWifiSsid *specific_ssid,
197 int num_channels, unsigned char *channel_list);
198int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
199 struct iw_request_info *info,
200 char *scan_results,
201 long scan_results_len);
202int sme_mgt_disconnect(unifi_priv_t *priv);
203int sme_mgt_connect(unifi_priv_t *priv);
204int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
205 CsrWifiSmeListAction action);
206int sme_mgt_pmkid(unifi_priv_t *priv, CsrWifiSmeListAction action,
207 CsrWifiSmePmkidList *pmkid_list);
208int sme_mgt_mib_get(unifi_priv_t *priv,
209 unsigned char *varbind, int *length);
210int sme_mgt_mib_set(unifi_priv_t *priv,
211 unsigned char *varbind, int length);
212#ifdef CSR_SUPPORT_WEXT_AP
213int sme_ap_start(unifi_priv_t *priv, u16 interface_tag, CsrWifiSmeApConfig_t *ap_config);
214int sme_ap_stop(unifi_priv_t *priv, u16 interface_tag);
215int sme_ap_config(unifi_priv_t *priv, CsrWifiSmeApMacConfig *ap_mac_config, CsrWifiNmeApConfig *group_security_config);
216int uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap);
217#endif
218int unifi_translate_scan(struct net_device *dev,
219 struct iw_request_info *info,
220 char *current_ev, char *end_buf,
221 CsrWifiSmeScanResult *scan_data,
222 int scan_index);
223
224#endif /* CSR_SUPPORT_WEXT */
225
226int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg);
227int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg);
228int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg);
229int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg);
230int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg);
231int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg);
232int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg);
233int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg);
234int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg);
235int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg);
236#ifdef CSR_SUPPORT_WEXT_AP
237int unifi_cfg_set_ap_config(unifi_priv_t * priv, unsigned char* arg);
238#endif
239
240
241
242int convert_sme_error(CsrResult error);
243
244
245#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
index beba089e2e35..000000000000
--- a/drivers/staging/csr/unifi_wext.h
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 *****************************************************************************
3 *
4 * FILE : unifi_wext.h
5 *
6 * PURPOSE : Private header file for unifi driver support to wireless extensions.
7 *
8 * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
9 *
10 * Refer to LICENSE.txt included with this source code for details on
11 * the license terms.
12 *
13*****************************************************************************
14 */
15#ifndef __LINUX_UNIFI_WEXT_H__
16#define __LINUX_UNIFI_WEXT_H__ 1
17
18#include <linux/kernel.h>
19#include <net/iw_handler.h>
20#include "csr_wifi_sme_prim.h"
21
22/*
23 * wext.c
24 */
25/* A few details needed for WEP (Wireless Equivalent Privacy) */
26#define UNIFI_MAX_KEY_SIZE 16
27#define NUM_WEPKEYS 4
28#define SMALL_KEY_SIZE 5
29#define LARGE_KEY_SIZE 13
30typedef struct wep_key_t {
31 int len;
32 unsigned char key[UNIFI_MAX_KEY_SIZE]; /* 40-bit and 104-bit keys */
33} wep_key_t;
34
35#define UNIFI_SCAN_ACTIVE 0
36#define UNIFI_SCAN_PASSIVE 1
37#define UNIFI_MAX_SSID_LEN 32
38
39#define MAX_WPA_IE_LEN 64
40#define MAX_RSN_IE_LEN 255
41
42/*
43 * Function to register in the netdev to report wireless stats.
44 */
45struct iw_statistics *unifi_get_wireless_stats(struct net_device *dev);
46
47void uf_sme_wext_set_defaults(unifi_priv_t *priv);
48
49
50/*
51 * wext_events.c
52 */
53/* Functions to generate Wireless Extension events */
54void wext_send_scan_results_event(unifi_priv_t *priv);
55void wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid,
56 unsigned char *req_ie, int req_ie_len,
57 unsigned char *resp_ie, int resp_ie_len,
58 unsigned char *scan_ie, unsigned int scan_ie_len);
59void wext_send_disassoc_event(unifi_priv_t *priv);
60void wext_send_michaelmicfailure_event(unifi_priv_t *priv,
61 u16 count, CsrWifiMacAddress address,
62 CsrWifiSmeKeyType keyType, u16 interfaceTag);
63void wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag);
64void wext_send_started_event(unifi_priv_t *priv);
65
66
67static inline int
68uf_iwe_stream_add_point(struct iw_request_info *info, char *start, char *stop,
69 struct iw_event *piwe, char *extra)
70{
71 char *new_start;
72
73 new_start = iwe_stream_add_point(info, start, stop, piwe, extra);
74 if (unlikely(new_start == start))
75 return -E2BIG;
76
77 return (new_start - start);
78}
79
80
81static inline int
82uf_iwe_stream_add_event(struct iw_request_info *info, char *start, char *stop,
83 struct iw_event *piwe, int len)
84{
85 char *new_start;
86
87 new_start = iwe_stream_add_event(info, start, stop, piwe, len);
88 if (unlikely(new_start == start))
89 return -E2BIG;
90
91 return (new_start - start);
92}
93
94static inline int
95uf_iwe_stream_add_value(struct iw_request_info *info, char *stream, char *start,
96 char *stop, struct iw_event *piwe, int len)
97{
98 char *new_start;
99
100 new_start = iwe_stream_add_value(info, stream, start, stop, piwe, len);
101 if (unlikely(new_start == start))
102 return -E2BIG;
103
104 return (new_start - start);
105}
106
107
108#endif /* __LINUX_UNIFI_WEXT_H__ */
diff --git a/drivers/staging/csr/unifiio.h b/drivers/staging/csr/unifiio.h
deleted file mode 100644
index b9de0cb94e9a..000000000000
--- a/drivers/staging/csr/unifiio.h
+++ /dev/null
@@ -1,398 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 *
4 * FILE: unifiio.h
5 *
6 * Public definitions for the UniFi linux driver.
7 * This is mostly ioctl command values and structs.
8 *
9 * Include <sys/ioctl.h> or similar before this file
10 *
11 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
12 *
13 * Refer to LICENSE.txt included with this source code for details on
14 * the license terms.
15 *
16 * ---------------------------------------------------------------------------
17 */
18#ifndef __UNIFIIO_H__
19#define __UNIFIIO_H__
20
21#include <linux/types.h>
22
23#define UNIFI_GET_UDI_ENABLE _IOR('u', 1, int)
24#define UNIFI_SET_UDI_ENABLE _IOW('u', 2, int)
25/* Values for UDI_ENABLE */
26#define UDI_ENABLE_DATA 0x1
27#define UDI_ENABLE_CONTROL 0x2
28
29/* MIB set/get. Arg is a pointer to a varbind */
30#define UNIFI_GET_MIB _IOWR('u', 3, unsigned char *)
31#define UNIFI_SET_MIB _IOW ('u', 4, unsigned char *)
32#define MAX_VARBIND_LENGTH 127
33
34/* Private IOCTLs */
35#define SIOCIWS80211POWERSAVEPRIV SIOCIWFIRSTPRIV
36#define SIOCIWG80211POWERSAVEPRIV SIOCIWFIRSTPRIV + 1
37#define SIOCIWS80211RELOADDEFAULTSPRIV SIOCIWFIRSTPRIV + 2
38#define SIOCIWSCONFWAPIPRIV SIOCIWFIRSTPRIV + 4
39#define SIOCIWSWAPIKEYPRIV SIOCIWFIRSTPRIV + 6
40#define SIOCIWSSMEDEBUGPRIV SIOCIWFIRSTPRIV + 8
41#define SIOCIWSAPCFGPRIV SIOCIWFIRSTPRIV + 10
42#define SIOCIWSAPSTARTPRIV SIOCIWFIRSTPRIV + 12
43#define SIOCIWSAPSTOPPRIV SIOCIWFIRSTPRIV + 14
44#define SIOCIWSFWRELOADPRIV SIOCIWFIRSTPRIV + 16
45#define SIOCIWSSTACKSTART SIOCIWFIRSTPRIV + 18
46#define SIOCIWSSTACKSTOP SIOCIWFIRSTPRIV + 20
47
48
49
50#define IWPRIV_POWER_SAVE_MAX_STRING 32
51#define IWPRIV_SME_DEBUG_MAX_STRING 32
52#define IWPRIV_SME_MAX_STRING 120
53
54
55/* Private configuration commands */
56#define UNIFI_CFG _IOWR('u', 5, unsigned char *)
57/*
58 * <------------------ Read/Write Buffer -------------------->
59 * _____________________________________________________________
60 * | Cmd | Arg | ... Buffer (opt) ... |
61 * -------------------------------------------------------------
62 * <-- uint --><-- uint --><----- unsigned char buffer ------>
63 *
64 * Cmd: A unifi_cfg_command_t command.
65 * Arg: Out:Length if Cmd==UNIFI_CFG_GET
66 * In:PowerOnOff if Cmd==UNIFI_CFG_POWER
67 * In:PowerMode if Cmd==UNIFI_CFG_POWERSAVE
68 * In:Length if Cmd==UNIFI_CFG_FILTER
69 * In:WMM Qos Info if Cmd==UNIFI_CFG_WMM_QOS_INFO
70 * Buffer: Out:Data if Cmd==UNIFI_CFG_GET
71 * NULL if Cmd==UNIFI_CFG_POWER
72 * NULL if Cmd==UNIFI_CFG_POWERSAVE
73 * In:Filters if Cmd==UNIFI_CFG_FILTER
74 *
75 * where Filters is a uf_cfg_bcast_packet_filter_t structure
76 * followed by 0 - n tclas_t structures. The length of the tclas_t
77 * structures is obtained by uf_cfg_bcast_packet_filter_t::tclas_ies_length.
78 */
79
80
81#define UNIFI_PUTEST _IOWR('u', 6, unsigned char *)
82/*
83 * <------------------ Read/Write Buffer -------------------->
84 * _____________________________________________________________
85 * | Cmd | Arg | ... Buffer (opt) ... |
86 * -------------------------------------------------------------
87 * <-- uint --><-- uint --><----- unsigned char buffer ------>
88 *
89 * Cmd: A unifi_putest_command_t command.
90 * Arg: N/A if Cmd==UNIFI_PUTEST_START
91 * N/A if Cmd==UNIFI_PUTEST_STOP
92 * In:int (Clock Speed) if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK
93 * In/Out:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_READ
94 * In:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_WRITE
95 * In:uint (f/w file name length) if Cmd==UNIFI_PUTEST_DL_FW
96 * Buffer: NULL if Cmd==UNIFI_PUTEST_START
97 * NULL if Cmd==UNIFI_PUTEST_STOP
98 * NULL if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK
99 * In/Out:unifi_putest_cmd52 if Cmd==UNIFI_PUTEST_CMD52_READ
100 * In:unifi_putest_cmd52 if Cmd==UNIFI_PUTEST_CMD52_WRITE
101 * In:f/w file name if Cmd==UNIFI_PUTEST_DL_FW
102 */
103
104#define UNIFI_BUILD_TYPE _IOWR('u', 7, unsigned char)
105#define UNIFI_BUILD_NME 1
106#define UNIFI_BUILD_WEXT 2
107#define UNIFI_BUILD_AP 3
108
109/* debugging */
110#define UNIFI_KICK _IO ('u', 0x10)
111#define UNIFI_SET_DEBUG _IO ('u', 0x11)
112#define UNIFI_SET_TRACE _IO ('u', 0x12)
113
114#define UNIFI_GET_INIT_STATUS _IOR ('u', 0x15, int)
115#define UNIFI_SET_UDI_LOG_MASK _IOR('u', 0x18, unifiio_filter_t)
116#define UNIFI_SET_UDI_SNAP_MASK _IOW('u', 0x1a, unifiio_snap_filter_t)
117#define UNIFI_SET_AMP_ENABLE _IOWR('u', 0x1b, int)
118
119#define UNIFI_INIT_HW _IOR ('u', 0x13, unsigned char)
120#define UNIFI_INIT_NETDEV _IOW ('u', 0x14, unsigned char[6])
121#define UNIFI_SME_PRESENT _IOW ('u', 0x19, int)
122
123#define UNIFI_CFG_PERIOD_TRAFFIC _IOW ('u', 0x21, unsigned char *)
124#define UNIFI_CFG_UAPSD_TRAFFIC _IOW ('u', 0x22, unsigned char)
125
126#define UNIFI_COREDUMP_GET_REG _IOWR('u', 0x23, unifiio_coredump_req_t)
127
128
129/*
130 * Following reset, f/w may only be downloaded using CMD52.
131 * This is slow, so there is a facility to download a secondary
132 * loader first which supports CMD53.
133 * If loader_len is > 0, then loader_data is assumed to point to
134 * a suitable secondary loader that can be used to download the
135 * main image.
136 *
137 * The driver will run the host protocol initialisation sequence
138 * after downloading the image.
139 *
140 * If both lengths are zero, then the f/w is assumed to have been
141 * booted from Flash and the host protocol initialisation sequence
142 * is run.
143 */
144typedef struct {
145
146 /* Number of bytes in the image */
147 int img_len;
148
149 /* Pointer to image data. */
150 unsigned char *img_data;
151
152
153 /* Number of bytes in the loader image */
154 int loader_len;
155
156 /* Pointer to loader image data. */
157 unsigned char *loader_data;
158
159} unifiio_img_t;
160
161
162/* Structure of data read from the unifi device. */
163typedef struct
164{
165 /* Length (in bytes) of entire structure including appended bulk data */
166 int length;
167
168 /* System time (in milliseconds) that signal was transferred */
169 int timestamp;
170
171 /* Direction in which signal was transferred. */
172 int direction;
173#define UDI_FROM_HOST 0
174#define UDI_TO_HOST 1
175#define UDI_CONFIG_IND 2
176
177 /* The length of the signal (in bytes) not including bulk data */
178 int signal_length;
179
180 /* Signal body follows, then any bulk data */
181
182} udi_msg_t;
183
184
185typedef enum
186{
187 UfSigFil_AllOn = 0, /* Log all signal IDs */
188 UfSigFil_AllOff = 1, /* Don't log any signal IDs */
189 UfSigFil_SelectOn = 2, /* Log these signal IDs */
190 UfSigFil_SelectOff = 3 /* Don't log these signal IDs */
191} uf_sigfilter_action_t;
192
193typedef struct {
194
195 /* Number of 16-bit ints in the sig_ids array */
196 int num_sig_ids;
197 /* The action to perform */
198 uf_sigfilter_action_t action;
199 /* List of signal IDs to pass or block */
200 unsigned short *sig_ids;
201
202} unifiio_filter_t;
203
204
205typedef struct {
206 /* Number of 16-bit ints in the protocols array */
207 u16 count;
208 /* List of protocol ids to pass */
209 u16 *protocols;
210} unifiio_snap_filter_t;
211
212
213
214typedef u8 unifi_putest_command_t;
215
216#define UNIFI_PUTEST_START 0
217#define UNIFI_PUTEST_STOP 1
218#define UNIFI_PUTEST_SET_SDIO_CLOCK 2
219#define UNIFI_PUTEST_CMD52_READ 3
220#define UNIFI_PUTEST_CMD52_WRITE 4
221#define UNIFI_PUTEST_DL_FW 5
222#define UNIFI_PUTEST_DL_FW_BUFF 6
223#define UNIFI_PUTEST_CMD52_BLOCK_READ 7
224#define UNIFI_PUTEST_COREDUMP_PREPARE 8
225#define UNIFI_PUTEST_GP_READ16 9
226#define UNIFI_PUTEST_GP_WRITE16 10
227
228
229struct unifi_putest_cmd52 {
230 int funcnum;
231 unsigned long addr;
232 unsigned char data;
233};
234
235
236struct unifi_putest_block_cmd52_r {
237 int funcnum;
238 unsigned long addr;
239 unsigned int length;
240 unsigned char *data;
241};
242
243struct unifi_putest_gp_rw16 {
244 unsigned long addr; /* generic address */
245 unsigned short data;
246};
247
248typedef enum unifi_cfg_command {
249 UNIFI_CFG_GET,
250 UNIFI_CFG_POWER,
251 UNIFI_CFG_POWERSAVE,
252 UNIFI_CFG_FILTER,
253 UNIFI_CFG_POWERSUPPLY,
254 UNIFI_CFG_WMM_QOSINFO,
255 UNIFI_CFG_WMM_ADDTS,
256 UNIFI_CFG_WMM_DELTS,
257 UNIFI_CFG_STRICT_DRAFT_N,
258 UNIFI_CFG_ENABLE_OKC,
259 UNIFI_CFG_SET_AP_CONFIG,
260 UNIFI_CFG_CORE_DUMP /* request to take a fw core dump */
261} unifi_cfg_command_t;
262
263typedef enum unifi_cfg_power {
264 UNIFI_CFG_POWER_UNSPECIFIED,
265 UNIFI_CFG_POWER_OFF,
266 UNIFI_CFG_POWER_ON
267} unifi_cfg_power_t;
268
269typedef enum unifi_cfg_powersupply {
270 UNIFI_CFG_POWERSUPPLY_UNSPECIFIED,
271 UNIFI_CFG_POWERSUPPLY_MAINS,
272 UNIFI_CFG_POWERSUPPLY_BATTERIES
273} unifi_cfg_powersupply_t;
274
275typedef enum unifi_cfg_powersave {
276 UNIFI_CFG_POWERSAVE_UNSPECIFIED,
277 UNIFI_CFG_POWERSAVE_NONE,
278 UNIFI_CFG_POWERSAVE_FAST,
279 UNIFI_CFG_POWERSAVE_FULL,
280 UNIFI_CFG_POWERSAVE_AUTO
281} unifi_cfg_powersave_t;
282
283typedef enum unifi_cfg_get {
284 UNIFI_CFG_GET_COEX,
285 UNIFI_CFG_GET_POWER_MODE,
286 UNIFI_CFG_GET_VERSIONS,
287 UNIFI_CFG_GET_POWER_SUPPLY,
288 UNIFI_CFG_GET_INSTANCE,
289 UNIFI_CFG_GET_AP_CONFIG
290} unifi_cfg_get_t;
291
292#define UNIFI_CFG_FILTER_NONE 0x0000
293#define UNIFI_CFG_FILTER_DHCP 0x0001
294#define UNIFI_CFG_FILTER_ARP 0x0002
295#define UNIFI_CFG_FILTER_NBNS 0x0004
296#define UNIFI_CFG_FILTER_NBDS 0x0008
297#define UNIFI_CFG_FILTER_CUPS 0x0010
298#define UNIFI_CFG_FILTER_ALL 0xFFFF
299
300
301typedef struct uf_cfg_bcast_packet_filter
302{
303 unsigned long filter_mode; //as defined by HIP protocol
304 unsigned char arp_filter;
305 unsigned char dhcp_filter;
306 unsigned long tclas_ies_length; // length of tclas_ies in bytes
307 unsigned char tclas_ies[1]; // variable length depending on above field
308} uf_cfg_bcast_packet_filter_t;
309
310typedef struct uf_cfg_ap_config
311{
312 u8 phySupportedBitmap;
313 u8 channel;
314 u16 beaconInterval;
315 u8 dtimPeriod;
316 u8 wmmEnabled;
317 u8 shortSlotTimeEnabled;
318 u16 groupkeyTimeout;
319 u8 strictGtkRekeyEnabled;
320 u16 gmkTimeout;
321 u16 responseTimeout;
322 u8 retransLimit;
323 u8 rxStbc;
324 u8 rifsModeAllowed;
325 u8 dualCtsProtection;
326 u8 ctsProtectionType;
327 u16 maxListenInterval;
328}uf_cfg_ap_config_t;
329
330typedef struct tcpic_clsfr
331{
332 __u8 cls_fr_type;
333 __u8 cls_fr_mask;
334 __u8 version;
335 __u8 source_ip_addr[4];
336 __u8 dest_ip_addr[4];
337 __u16 source_port;
338 __u16 dest_port;
339 __u8 dscp;
340 __u8 protocol;
341 __u8 reserved;
342} __attribute__ ((packed)) tcpip_clsfr_t;
343
344typedef struct tclas {
345 __u8 element_id;
346 __u8 length;
347 __u8 user_priority;
348 tcpip_clsfr_t tcp_ip_cls_fr;
349} __attribute__ ((packed)) tclas_t;
350
351
352#define CONFIG_IND_ERROR 0x01
353#define CONFIG_IND_EXIT 0x02
354#define CONFIG_SME_NOT_PRESENT 0x10
355#define CONFIG_SME_PRESENT 0x20
356
357/* WAPI Key */
358typedef struct
359{
360 u8 unicastKey;
361 /* If non zero, then unicast key otherwise group key */
362 u8 keyIndex;
363 u8 keyRsc[16];
364 u8 authenticator;
365 /* If non zero, then authenticator otherwise supplicant */
366 u8 address[6];
367 u8 key[32];
368} unifiio_wapi_key_t;
369
370/* Values describing XAP memory regions captured by the mini-coredump system */
371typedef enum unifiio_coredump_space {
372 UNIFIIO_COREDUMP_MAC_REG,
373 UNIFIIO_COREDUMP_PHY_REG,
374 UNIFIIO_COREDUMP_SH_DMEM,
375 UNIFIIO_COREDUMP_MAC_DMEM,
376 UNIFIIO_COREDUMP_PHY_DMEM,
377 UNIFIIO_COREDUMP_TRIGGER_MAGIC = 0xFEED
378} unifiio_coredump_space_t;
379
380/* Userspace tool uses this structure to retrieve a register value from a
381 * mini-coredump buffer previously saved by the HIP
382 */
383typedef struct unifiio_coredump_req {
384 /* From user */
385 int index; /* 0=newest, -1=oldest */
386 unsigned int offset; /* register offset in space */
387 unifiio_coredump_space_t space; /* memory space */
388 /* Filled by driver */
389 unsigned int drv_build; /* driver build id */
390 unsigned int chip_ver; /* chip version */
391 unsigned int fw_ver; /* firmware version */
392 int requestor; /* requestor: 0=auto dump, 1=manual */
393 unsigned int timestamp; /* time of capture by driver */
394 unsigned int serial; /* capture serial number */
395 int value; /* 16 bit register value, -ve for error */
396} unifiio_coredump_req_t; /* Core-dumped register value request */
397
398#endif /* __UNIFIIO_H__ */
diff --git a/drivers/staging/csr/wext_events.c b/drivers/staging/csr/wext_events.c
deleted file mode 100644
index 9860ea30da25..000000000000
--- a/drivers/staging/csr/wext_events.c
+++ /dev/null
@@ -1,283 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: wext_events.c
4 *
5 * PURPOSE:
6 * Code to generate iwevents.
7 *
8 * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
9 *
10 * Refer to LICENSE.txt included with this source code for details on
11 * the license terms.
12 *
13 * ---------------------------------------------------------------------------
14 */
15#include <linux/types.h>
16#include <linux/etherdevice.h>
17#include <linux/if_arp.h>
18#include "csr_wifi_hip_unifi.h"
19#include "unifi_priv.h"
20
21
22
23/*
24 * ---------------------------------------------------------------------------
25 * wext_send_assoc_event
26 *
27 * Send wireless-extension events up to userland to announce
28 * successful association with an AP.
29 *
30 * Arguments:
31 * priv Pointer to driver context.
32 * bssid MAC address of AP we associated with
33 * req_ie, req_ie_len IEs in the original request
34 * resp_ie, resp_ie_len IEs in the response
35 *
36 * Returns:
37 * None.
38 *
39 * Notes:
40 * This is sent on first successful association, and again if we
41 * roam to another AP.
42 * ---------------------------------------------------------------------------
43 */
44void
45wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid,
46 unsigned char *req_ie, int req_ie_len,
47 unsigned char *resp_ie, int resp_ie_len,
48 unsigned char *scan_ie, unsigned int scan_ie_len)
49{
50#if WIRELESS_EXT > 17
51 union iwreq_data wrqu;
52
53 if (req_ie_len == 0) req_ie = NULL;
54 wrqu.data.length = req_ie_len;
55 wrqu.data.flags = 0;
56 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCREQIE, &wrqu, req_ie);
57
58 if (resp_ie_len == 0) resp_ie = NULL;
59 wrqu.data.length = resp_ie_len;
60 wrqu.data.flags = 0;
61 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCRESPIE, &wrqu, resp_ie);
62
63 if (scan_ie_len > 0) {
64 wrqu.data.length = scan_ie_len;
65 wrqu.data.flags = 0;
66 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVGENIE, &wrqu, scan_ie);
67 }
68
69 memcpy(&wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
70 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL);
71#endif
72} /* wext_send_assoc_event() */
73
74
75
76/*
77 * ---------------------------------------------------------------------------
78 * wext_send_disassoc_event
79 *
80 * Send a wireless-extension event up to userland to announce
81 * that we disassociated from an AP.
82 *
83 * Arguments:
84 * priv Pointer to driver context.
85 *
86 * Returns:
87 * None.
88 *
89 * Notes:
90 * The semantics of wpa_supplicant (the userland SME application) are
91 * that a SIOCGIWAP event with MAC address of all zero means
92 * disassociate.
93 * ---------------------------------------------------------------------------
94 */
95void
96wext_send_disassoc_event(unifi_priv_t *priv)
97{
98#if WIRELESS_EXT > 17
99 union iwreq_data wrqu;
100
101 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
102 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL);
103#endif
104} /* wext_send_disassoc_event() */
105
106
107
108/*
109 * ---------------------------------------------------------------------------
110 * wext_send_scan_results_event
111 *
112 * Send wireless-extension events up to userland to announce
113 * completion of a scan.
114 *
115 * Arguments:
116 * priv Pointer to driver context.
117 *
118 * Returns:
119 * None.
120 *
121 * Notes:
122 * This doesn't actually report the results, they are retrieved
123 * using the SIOCGIWSCAN ioctl command.
124 * ---------------------------------------------------------------------------
125 */
126void
127wext_send_scan_results_event(unifi_priv_t *priv)
128{
129#if WIRELESS_EXT > 17
130 union iwreq_data wrqu;
131
132 wrqu.data.length = 0;
133 wrqu.data.flags = 0;
134 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWSCAN, &wrqu, NULL);
135
136#endif
137} /* wext_send_scan_results_event() */
138
139
140
141/*
142 * ---------------------------------------------------------------------------
143 * wext_send_michaelmicfailure_event
144 *
145 * Send wireless-extension events up to userland to announce
146 * completion of a scan.
147 *
148 * Arguments:
149 * priv Pointer to driver context.
150 * count, macaddr, key_type, key_idx, tsc
151 * Parameters from report from UniFi.
152 *
153 * Returns:
154 * None.
155 * ---------------------------------------------------------------------------
156 */
157#if WIRELESS_EXT >= 18
158static inline void
159_send_michaelmicfailure_event(struct net_device *dev,
160 int count, const unsigned char *macaddr,
161 int key_type, int key_idx,
162 unsigned char *tsc)
163{
164 union iwreq_data wrqu;
165 struct iw_michaelmicfailure mmf;
166
167 memset(&mmf, 0, sizeof(mmf));
168
169 mmf.flags = key_idx & IW_MICFAILURE_KEY_ID;
170 if (key_type == CSR_GROUP) {
171 mmf.flags |= IW_MICFAILURE_GROUP;
172 } else {
173 mmf.flags |= IW_MICFAILURE_PAIRWISE;
174 }
175 mmf.flags |= ((count << 5) & IW_MICFAILURE_COUNT);
176
177 mmf.src_addr.sa_family = ARPHRD_ETHER;
178 memcpy(mmf.src_addr.sa_data, macaddr, ETH_ALEN);
179
180 memcpy(mmf.tsc, tsc, IW_ENCODE_SEQ_MAX_SIZE);
181
182 memset(&wrqu, 0, sizeof(wrqu));
183 wrqu.data.length = sizeof(mmf);
184
185 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&mmf);
186}
187#elif WIRELESS_EXT >= 15
188static inline void
189_send_michaelmicfailure_event(struct net_device *dev,
190 int count, const unsigned char *macaddr,
191 int key_type, int key_idx,
192 unsigned char *tsc)
193{
194 union iwreq_data wrqu;
195 char buf[128];
196
197 sprintf(buf,
198 "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=%pM)",
199 key_idx, (key_type == CSR_GROUP) ? "broad" : "uni", macaddr);
200 memset(&wrqu, 0, sizeof(wrqu));
201 wrqu.data.length = strlen(buf);
202 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
203}
204#else /* WIRELESS_EXT >= 15 */
205static inline void
206_send_michaelmicfailure_event(struct net_device *dev,
207 int count, const unsigned char *macaddr,
208 int key_type, int key_idx,
209 unsigned char *tsc)
210{
211 /* Not supported before WEXT 15 */
212}
213#endif /* WIRELESS_EXT >= 15 */
214
215
216void
217wext_send_michaelmicfailure_event(unifi_priv_t *priv,
218 u16 count,
219 CsrWifiMacAddress address,
220 CsrWifiSmeKeyType keyType,
221 u16 interfaceTag)
222{
223 unsigned char tsc[8] = {0};
224
225 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
226 unifi_error(priv, "wext_send_michaelmicfailure_event bad interfaceTag\n");
227 return;
228 }
229
230 _send_michaelmicfailure_event(priv->netdev[interfaceTag],
231 count,
232 address.a,
233 keyType,
234 0,
235 tsc);
236} /* wext_send_michaelmicfailure_event() */
237
238void
239wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag)
240{
241#if WIRELESS_EXT > 17
242 union iwreq_data wrqu;
243 struct iw_pmkid_cand pmkid_cand;
244
245 if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
246 unifi_error(priv, "wext_send_pmkid_candidate_event bad interfaceTag\n");
247 return;
248 }
249
250 memset(&pmkid_cand, 0, sizeof(pmkid_cand));
251
252 if (preauth_allowed) {
253 pmkid_cand.flags |= IW_PMKID_CAND_PREAUTH;
254 }
255 pmkid_cand.bssid.sa_family = ARPHRD_ETHER;
256 memcpy(pmkid_cand.bssid.sa_data, bssid.a, ETH_ALEN);
257 /* Used as priority, smaller the number higher the priority, not really used in our case */
258 pmkid_cand.index = 1;
259
260 memset(&wrqu, 0, sizeof(wrqu));
261 wrqu.data.length = sizeof(pmkid_cand);
262
263 wireless_send_event(priv->netdev[interfaceTag], IWEVPMKIDCAND, &wrqu, (char *)&pmkid_cand);
264#endif
265} /* wext_send_pmkid_candidate_event() */
266
267/*
268 * Send a custom WEXT event to say we have completed initialisation
269 * and are now ready for WEXT ioctls. Used by Android wpa_supplicant.
270 */
271void
272wext_send_started_event(unifi_priv_t *priv)
273{
274#if WIRELESS_EXT > 17
275 union iwreq_data wrqu;
276 char data[] = "STARTED";
277
278 wrqu.data.length = sizeof(data);
279 wrqu.data.flags = 0;
280 wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVCUSTOM, &wrqu, data);
281#endif
282} /* wext_send_started_event() */
283
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c
index 5590ebf1da15..817f837b240d 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -827,11 +827,11 @@ static void usb_alphatrack_disconnect(struct usb_interface *intf)
827 mutex_unlock(&dev->mtx); 827 mutex_unlock(&dev->mtx);
828 usb_alphatrack_delete(dev); 828 usb_alphatrack_delete(dev);
829 } else { 829 } else {
830 atomic_set(&dev->writes_pending, 0);
830 dev->intf = NULL; 831 dev->intf = NULL;
831 mutex_unlock(&dev->mtx); 832 mutex_unlock(&dev->mtx);
832 } 833 }
833 834
834 atomic_set(&dev->writes_pending, 0);
835 mutex_unlock(&disconnect_mutex); 835 mutex_unlock(&disconnect_mutex);
836 836
837 dev_info(&intf->dev, "Alphatrack Surface #%d now disconnected\n", 837 dev_info(&intf->dev, "Alphatrack Surface #%d now disconnected\n",
diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c
index b795353e8348..cc3692439a5c 100644
--- a/drivers/staging/gdm72xx/gdm_qos.c
+++ b/drivers/staging/gdm72xx/gdm_qos.c
@@ -250,8 +250,8 @@ static void send_qos_list(struct nic *nic, struct list_head *head)
250 250
251 list_for_each_entry_safe(entry, n, head, list) { 251 list_for_each_entry_safe(entry, n, head, list) {
252 list_del(&entry->list); 252 list_del(&entry->list);
253 free_qos_entry(entry);
254 gdm_wimax_send_tx(entry->skb, entry->dev); 253 gdm_wimax_send_tx(entry->skb, entry->dev);
254 free_qos_entry(entry);
255 } 255 }
256} 256}
257 257
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
index 1bfe5d81792b..8ed75a94f465 100644
--- a/drivers/staging/iio/accel/lis3l02dq_core.c
+++ b/drivers/staging/iio/accel/lis3l02dq_core.c
@@ -257,6 +257,8 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
257 ret = lis3l02dq_read_reg_s16(indio_dev, reg, val); 257 ret = lis3l02dq_read_reg_s16(indio_dev, reg, val);
258 } 258 }
259 mutex_unlock(&indio_dev->mlock); 259 mutex_unlock(&indio_dev->mlock);
260 if (ret < 0)
261 goto error_ret;
260 return IIO_VAL_INT; 262 return IIO_VAL_INT;
261 case IIO_CHAN_INFO_SCALE: 263 case IIO_CHAN_INFO_SCALE:
262 *val = 0; 264 *val = 0;
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
index 3fc79e582750..a2e61c2fc8d1 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -517,6 +517,7 @@ static const struct iio_info ad7291_info = {
517 .read_event_value = &ad7291_read_event_value, 517 .read_event_value = &ad7291_read_event_value,
518 .write_event_value = &ad7291_write_event_value, 518 .write_event_value = &ad7291_write_event_value,
519 .event_attrs = &ad7291_event_attribute_group, 519 .event_attrs = &ad7291_event_attribute_group,
520 .driver_module = THIS_MODULE,
520}; 521};
521 522
522static int ad7291_probe(struct i2c_client *client, 523static int ad7291_probe(struct i2c_client *client,
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index d92c97a59d61..9f52a2857929 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
234{ 234{
235 struct mxs_lradc *lradc = iio_priv(iio_dev); 235 struct mxs_lradc *lradc = iio_priv(iio_dev);
236 int ret; 236 int ret;
237 unsigned long mask;
238 237
239 if (m != IIO_CHAN_INFO_RAW) 238 if (m != IIO_CHAN_INFO_RAW)
240 return -EINVAL; 239 return -EINVAL;
@@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
243 if (chan->channel > LRADC_MAX_TOTAL_CHANS) 242 if (chan->channel > LRADC_MAX_TOTAL_CHANS)
244 return -EINVAL; 243 return -EINVAL;
245 244
246 /* Validate the channel if it doesn't intersect with reserved chans. */
247 bitmap_set(&mask, chan->channel, 1);
248 ret = iio_validate_scan_mask_onehot(iio_dev, &mask);
249 if (ret)
250 return -EINVAL;
251
252 /* 245 /*
253 * See if there is no buffered operation in progess. If there is, simply 246 * See if there is no buffered operation in progess. If there is, simply
254 * bail out. This can be improved to support both buffered and raw IO at 247 * 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)
661{ 654{
662 int ret; 655 int ret;
663 struct iio_trigger *trig; 656 struct iio_trigger *trig;
657 struct mxs_lradc *lradc = iio_priv(iio);
664 658
665 trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); 659 trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
666 if (trig == NULL) 660 if (trig == NULL)
667 return -ENOMEM; 661 return -ENOMEM;
668 662
669 trig->dev.parent = iio->dev.parent; 663 trig->dev.parent = lradc->dev;
670 iio_trigger_set_drvdata(trig, iio); 664 iio_trigger_set_drvdata(trig, iio);
671 trig->ops = &mxs_lradc_trigger_ops; 665 trig->ops = &mxs_lradc_trigger_ops;
672 666
@@ -676,15 +670,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
676 return ret; 670 return ret;
677 } 671 }
678 672
679 iio->trig = trig; 673 lradc->trig = trig;
680 674
681 return 0; 675 return 0;
682} 676}
683 677
684static void mxs_lradc_trigger_remove(struct iio_dev *iio) 678static void mxs_lradc_trigger_remove(struct iio_dev *iio)
685{ 679{
686 iio_trigger_unregister(iio->trig); 680 struct mxs_lradc *lradc = iio_priv(iio);
687 iio_trigger_free(iio->trig); 681
682 iio_trigger_unregister(lradc->trig);
683 iio_trigger_free(lradc->trig);
688} 684}
689 685
690static int mxs_lradc_buffer_preenable(struct iio_dev *iio) 686static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig
index 22339059837f..bd0f2fd01db4 100644
--- a/drivers/staging/imx-drm/Kconfig
+++ b/drivers/staging/imx-drm/Kconfig
@@ -33,7 +33,6 @@ config DRM_IMX_TVE
33config DRM_IMX_LDB 33config DRM_IMX_LDB
34 tristate "Support for LVDS displays" 34 tristate "Support for LVDS displays"
35 depends on DRM_IMX 35 depends on DRM_IMX
36 select OF_VIDEOMODE
37 help 36 help
38 Choose this to enable the internal LVDS Display Bridge (LDB) 37 Choose this to enable the internal LVDS Display Bridge (LDB)
39 found on i.MX53 and i.MX6 processors. 38 found on i.MX53 and i.MX6 processors.
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index 4795f1284906..0dd08ef51398 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -392,8 +392,11 @@ static int snd_line6_pcm_free(struct snd_device *device)
392*/ 392*/
393static void pcm_disconnect_substream(struct snd_pcm_substream *substream) 393static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
394{ 394{
395 if (substream->runtime && snd_pcm_running(substream)) 395 if (substream->runtime && snd_pcm_running(substream)) {
396 snd_pcm_stream_lock_irq(substream);
396 snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED); 397 snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
398 snd_pcm_stream_unlock_irq(substream);
399 }
397} 400}
398 401
399/* 402/*
diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
index c191ae203565..41e88abe47af 100644
--- a/drivers/staging/tidspbridge/pmgr/dbll.c
+++ b/drivers/staging/tidspbridge/pmgr/dbll.c
@@ -1120,8 +1120,11 @@ static int dbll_rmm_alloc(struct dynamic_loader_allocate *this,
1120 or DYN_EXTERNAL, then mem granularity information is present 1120 or DYN_EXTERNAL, then mem granularity information is present
1121 within the section name - only process if there are at least three 1121 within the section name - only process if there are at least three
1122 tokens within the section name (just a minor optimization) */ 1122 tokens within the section name (just a minor optimization) */
1123 if (count >= 3) 1123 if (count >= 3) {
1124 strict_strtol(sz_last_token, 10, (long *)&req); 1124 status = kstrtos32(sz_last_token, 10, &req);
1125 if (status)
1126 goto func_cont;
1127 }
1125 1128
1126 if ((req == 0) || (req == 1)) { 1129 if ((req == 0) || (req == 1)) {
1127 if (strcmp(sz_sec_last_token, "DYN_DARAM") == 0) { 1130 if (strcmp(sz_sec_last_token, "DYN_DARAM") == 0) {
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 82c7202fd5cc..e77fb6ea40c9 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -527,8 +527,11 @@ static void zram_reset_device(struct zram *zram)
527 size_t index; 527 size_t index;
528 struct zram_meta *meta; 528 struct zram_meta *meta;
529 529
530 if (!zram->init_done) 530 down_write(&zram->init_lock);
531 if (!zram->init_done) {
532 up_write(&zram->init_lock);
531 return; 533 return;
534 }
532 535
533 meta = zram->meta; 536 meta = zram->meta;
534 zram->init_done = 0; 537 zram->init_done = 0;
@@ -549,6 +552,7 @@ static void zram_reset_device(struct zram *zram)
549 552
550 zram->disksize = 0; 553 zram->disksize = 0;
551 set_capacity(zram->disk, 0); 554 set_capacity(zram->disk, 0);
555 up_write(&zram->init_lock);
552} 556}
553 557
554static void zram_init_device(struct zram *zram, struct zram_meta *meta) 558static void zram_init_device(struct zram *zram, struct zram_meta *meta)
diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
index 5de56f671a9d..f36950e4134f 100644
--- a/drivers/thermal/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/x86_pkg_temp_thermal.c
@@ -54,6 +54,8 @@ MODULE_PARM_DESC(notify_delay_ms,
54* is some wrong values returned by cpuid for number of thresholds. 54* is some wrong values returned by cpuid for number of thresholds.
55*/ 55*/
56#define MAX_NUMBER_OF_TRIPS 2 56#define MAX_NUMBER_OF_TRIPS 2
57/* Limit number of package temp zones */
58#define MAX_PKG_TEMP_ZONE_IDS 256
57 59
58struct phy_dev_entry { 60struct phy_dev_entry {
59 struct list_head list; 61 struct list_head list;
@@ -394,12 +396,16 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
394 char buffer[30]; 396 char buffer[30];
395 int thres_count; 397 int thres_count;
396 u32 eax, ebx, ecx, edx; 398 u32 eax, ebx, ecx, edx;
399 u8 *temp;
397 400
398 cpuid(6, &eax, &ebx, &ecx, &edx); 401 cpuid(6, &eax, &ebx, &ecx, &edx);
399 thres_count = ebx & 0x07; 402 thres_count = ebx & 0x07;
400 if (!thres_count) 403 if (!thres_count)
401 return -ENODEV; 404 return -ENODEV;
402 405
406 if (topology_physical_package_id(cpu) > MAX_PKG_TEMP_ZONE_IDS)
407 return -ENODEV;
408
403 thres_count = clamp_val(thres_count, 0, MAX_NUMBER_OF_TRIPS); 409 thres_count = clamp_val(thres_count, 0, MAX_NUMBER_OF_TRIPS);
404 410
405 err = get_tj_max(cpu, &tj_max); 411 err = get_tj_max(cpu, &tj_max);
@@ -417,13 +423,14 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
417 spin_lock(&pkg_work_lock); 423 spin_lock(&pkg_work_lock);
418 if (topology_physical_package_id(cpu) > max_phy_id) 424 if (topology_physical_package_id(cpu) > max_phy_id)
419 max_phy_id = topology_physical_package_id(cpu); 425 max_phy_id = topology_physical_package_id(cpu);
420 pkg_work_scheduled = krealloc(pkg_work_scheduled, 426 temp = krealloc(pkg_work_scheduled,
421 (max_phy_id+1) * sizeof(u8), GFP_ATOMIC); 427 (max_phy_id+1) * sizeof(u8), GFP_ATOMIC);
422 if (!pkg_work_scheduled) { 428 if (!temp) {
423 spin_unlock(&pkg_work_lock); 429 spin_unlock(&pkg_work_lock);
424 err = -ENOMEM; 430 err = -ENOMEM;
425 goto err_ret_free; 431 goto err_ret_free;
426 } 432 }
433 pkg_work_scheduled = temp;
427 pkg_work_scheduled[topology_physical_package_id(cpu)] = 0; 434 pkg_work_scheduled[topology_physical_package_id(cpu)] = 0;
428 spin_unlock(&pkg_work_lock); 435 spin_unlock(&pkg_work_lock);
429 436
@@ -511,7 +518,7 @@ static int get_core_online(unsigned int cpu)
511 518
512 /* Check if there is already an instance for this package */ 519 /* Check if there is already an instance for this package */
513 if (!phdev) { 520 if (!phdev) {
514 if (!cpu_has(c, X86_FEATURE_DTHERM) && 521 if (!cpu_has(c, X86_FEATURE_DTHERM) ||
515 !cpu_has(c, X86_FEATURE_PTS)) 522 !cpu_has(c, X86_FEATURE_PTS))
516 return -ENODEV; 523 return -ENODEV;
517 if (pkg_temp_thermal_device_add(cpu)) 524 if (pkg_temp_thermal_device_add(cpu))
@@ -562,7 +569,7 @@ static struct notifier_block pkg_temp_thermal_notifier __refdata = {
562}; 569};
563 570
564static const struct x86_cpu_id __initconst pkg_temp_thermal_ids[] = { 571static const struct x86_cpu_id __initconst pkg_temp_thermal_ids[] = {
565 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_DTHERM }, 572 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_PTS },
566 {} 573 {}
567}; 574};
568MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids); 575MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids);
@@ -592,7 +599,6 @@ static int __init pkg_temp_thermal_init(void)
592 return 0; 599 return 0;
593 600
594err_ret: 601err_ret:
595 get_online_cpus();
596 for_each_online_cpu(i) 602 for_each_online_cpu(i)
597 put_core_offline(i); 603 put_core_offline(i);
598 put_online_cpus(); 604 put_online_cpus();
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 721904f8efa9..946ddd2b3a54 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -193,7 +193,8 @@ static int __init parse_options(struct early_serial8250_device *device,
193 if (options) { 193 if (options) {
194 options++; 194 options++;
195 device->baud = simple_strtoul(options, NULL, 0); 195 device->baud = simple_strtoul(options, NULL, 0);
196 length = min(strcspn(options, " "), sizeof(device->options)); 196 length = min(strcspn(options, " ") + 1,
197 sizeof(device->options));
197 strlcpy(device->options, options, length); 198 strlcpy(device->options, options, length);
198 } else { 199 } else {
199 device->baud = probe_baud(port); 200 device->baud = probe_baud(port);
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 5e3d68917ffe..1456673bcca0 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -277,7 +277,7 @@ config SERIAL_TEGRA
277 select SERIAL_CORE 277 select SERIAL_CORE
278 help 278 help
279 Support for the on-chip UARTs on the NVIDIA Tegra series SOCs 279 Support for the on-chip UARTs on the NVIDIA Tegra series SOCs
280 providing /dev/ttyHS0, 1, 2, 3 and 4 (note, some machines may not 280 providing /dev/ttyTHS0, 1, 2, 3 and 4 (note, some machines may not
281 provide all of these ports, depending on how the serial port 281 provide all of these ports, depending on how the serial port
282 are enabled). This driver uses the APB DMA to achieve higher baudrate 282 are enabled). This driver uses the APB DMA to achieve higher baudrate
283 and better performance. 283 and better performance.
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index ff171384ea52..dc6e96996ead 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -3478,7 +3478,7 @@ static int alloc_buf_list(SLMP_INFO *info)
3478 for ( i = 0; i < info->rx_buf_count; i++ ) { 3478 for ( i = 0; i < info->rx_buf_count; i++ ) {
3479 /* calculate and store physical address of this buffer entry */ 3479 /* calculate and store physical address of this buffer entry */
3480 info->rx_buf_list_ex[i].phys_entry = 3480 info->rx_buf_list_ex[i].phys_entry =
3481 info->buffer_list_phys + (i * sizeof(SCABUFSIZE)); 3481 info->buffer_list_phys + (i * SCABUFSIZE);
3482 3482
3483 /* calculate and store physical address of */ 3483 /* calculate and store physical address of */
3484 /* next entry in cirular list of entries */ 3484 /* next entry in cirular list of entries */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4191db32f12c..4a8a1d68002c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -668,6 +668,15 @@ resubmit:
668static inline int 668static inline int
669hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt) 669hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
670{ 670{
671 /* Need to clear both directions for control ep */
672 if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) ==
673 USB_ENDPOINT_XFER_CONTROL) {
674 int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
675 HUB_CLEAR_TT_BUFFER, USB_RT_PORT,
676 devinfo ^ 0x8000, tt, NULL, 0, 1000);
677 if (status)
678 return status;
679 }
671 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), 680 return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
672 HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, 681 HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo,
673 tt, NULL, 0, 1000); 682 tt, NULL, 0, 1000);
@@ -2848,6 +2857,15 @@ static int usb_disable_function_remotewakeup(struct usb_device *udev)
2848 USB_CTRL_SET_TIMEOUT); 2857 USB_CTRL_SET_TIMEOUT);
2849} 2858}
2850 2859
2860/* Count of wakeup-enabled devices at or below udev */
2861static unsigned wakeup_enabled_descendants(struct usb_device *udev)
2862{
2863 struct usb_hub *hub = usb_hub_to_struct_hub(udev);
2864
2865 return udev->do_remote_wakeup +
2866 (hub ? hub->wakeup_enabled_descendants : 0);
2867}
2868
2851/* 2869/*
2852 * usb_port_suspend - suspend a usb device's upstream port 2870 * usb_port_suspend - suspend a usb device's upstream port
2853 * @udev: device that's no longer in active use, not a root hub 2871 * @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)
2888 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd 2906 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd
2889 * timer, no SRP, no requests through sysfs. 2907 * timer, no SRP, no requests through sysfs.
2890 * 2908 *
2891 * If Runtime PM isn't enabled or used, non-SuperSpeed devices really get 2909 * If Runtime PM isn't enabled or used, non-SuperSpeed devices may not get
2892 * suspended only when their bus goes into global suspend (i.e., the root 2910 * suspended until their bus goes into global suspend (i.e., the root
2893 * hub is suspended). Nevertheless, we change @udev->state to 2911 * hub is suspended). Nevertheless, we change @udev->state to
2894 * USB_STATE_SUSPENDED as this is the device's "logical" state. The actual 2912 * USB_STATE_SUSPENDED as this is the device's "logical" state. The actual
2895 * upstream port setting is stored in @udev->port_is_suspended. 2913 * 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)
2960 /* see 7.1.7.6 */ 2978 /* see 7.1.7.6 */
2961 if (hub_is_superspeed(hub->hdev)) 2979 if (hub_is_superspeed(hub->hdev))
2962 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); 2980 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3);
2963 else if (PMSG_IS_AUTO(msg)) 2981
2964 status = set_port_feature(hub->hdev, port1,
2965 USB_PORT_FEAT_SUSPEND);
2966 /* 2982 /*
2967 * For system suspend, we do not need to enable the suspend feature 2983 * For system suspend, we do not need to enable the suspend feature
2968 * on individual USB-2 ports. The devices will automatically go 2984 * on individual USB-2 ports. The devices will automatically go
2969 * into suspend a few ms after the root hub stops sending packets. 2985 * into suspend a few ms after the root hub stops sending packets.
2970 * The USB 2.0 spec calls this "global suspend". 2986 * The USB 2.0 spec calls this "global suspend".
2987 *
2988 * However, many USB hubs have a bug: They don't relay wakeup requests
2989 * from a downstream port if the port's suspend feature isn't on.
2990 * Therefore we will turn on the suspend feature if udev or any of its
2991 * descendants is enabled for remote wakeup.
2971 */ 2992 */
2993 else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0)
2994 status = set_port_feature(hub->hdev, port1,
2995 USB_PORT_FEAT_SUSPEND);
2972 else { 2996 else {
2973 really_suspend = false; 2997 really_suspend = false;
2974 status = 0; 2998 status = 0;
@@ -3003,15 +3027,16 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
3003 if (!PMSG_IS_AUTO(msg)) 3027 if (!PMSG_IS_AUTO(msg))
3004 status = 0; 3028 status = 0;
3005 } else { 3029 } else {
3006 /* device has up to 10 msec to fully suspend */
3007 dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n", 3030 dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n",
3008 (PMSG_IS_AUTO(msg) ? "auto-" : ""), 3031 (PMSG_IS_AUTO(msg) ? "auto-" : ""),
3009 udev->do_remote_wakeup); 3032 udev->do_remote_wakeup);
3010 usb_set_device_state(udev, USB_STATE_SUSPENDED);
3011 if (really_suspend) { 3033 if (really_suspend) {
3012 udev->port_is_suspended = 1; 3034 udev->port_is_suspended = 1;
3035
3036 /* device has up to 10 msec to fully suspend */
3013 msleep(10); 3037 msleep(10);
3014 } 3038 }
3039 usb_set_device_state(udev, USB_STATE_SUSPENDED);
3015 } 3040 }
3016 3041
3017 /* 3042 /*
@@ -3293,7 +3318,11 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
3293 unsigned port1; 3318 unsigned port1;
3294 int status; 3319 int status;
3295 3320
3296 /* Warn if children aren't already suspended */ 3321 /*
3322 * Warn if children aren't already suspended.
3323 * Also, add up the number of wakeup-enabled descendants.
3324 */
3325 hub->wakeup_enabled_descendants = 0;
3297 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 3326 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
3298 struct usb_device *udev; 3327 struct usb_device *udev;
3299 3328
@@ -3303,6 +3332,9 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
3303 if (PMSG_IS_AUTO(msg)) 3332 if (PMSG_IS_AUTO(msg))
3304 return -EBUSY; 3333 return -EBUSY;
3305 } 3334 }
3335 if (udev)
3336 hub->wakeup_enabled_descendants +=
3337 wakeup_enabled_descendants(udev);
3306 } 3338 }
3307 3339
3308 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { 3340 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) {
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 6508e02b3dac..4e4790dea343 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -59,6 +59,9 @@ struct usb_hub {
59 struct usb_tt tt; /* Transaction Translator */ 59 struct usb_tt tt; /* Transaction Translator */
60 60
61 unsigned mA_per_port; /* current for each child */ 61 unsigned mA_per_port; /* current for each child */
62#ifdef CONFIG_PM
63 unsigned wakeup_enabled_descendants;
64#endif
62 65
63 unsigned limited_power:1; 66 unsigned limited_power:1;
64 unsigned quiescing:1; 67 unsigned quiescing:1;
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 757aa18027d0..2378958ea63e 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -1,6 +1,6 @@
1config USB_DWC3 1config USB_DWC3
2 tristate "DesignWare USB3 DRD Core Support" 2 tristate "DesignWare USB3 DRD Core Support"
3 depends on (USB || USB_GADGET) && GENERIC_HARDIRQS 3 depends on (USB || USB_GADGET) && GENERIC_HARDIRQS && HAS_DMA
4 select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD 4 select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD
5 help 5 help
6 Say Y or M here if your system has a Dual Role SuperSpeed 6 Say Y or M here if your system has a Dual Role SuperSpeed
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c35d49d39b76..358375e0b291 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -450,7 +450,7 @@ static int dwc3_probe(struct platform_device *pdev)
450 } 450 }
451 451
452 if (IS_ERR(dwc->usb3_phy)) { 452 if (IS_ERR(dwc->usb3_phy)) {
453 ret = PTR_ERR(dwc->usb2_phy); 453 ret = PTR_ERR(dwc->usb3_phy);
454 454
455 /* 455 /*
456 * if -ENXIO is returned, it means PHY layer wasn't 456 * if -ENXIO is returned, it means PHY layer wasn't
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index b69d322e3cab..27dad993b007 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -759,8 +759,8 @@ struct dwc3 {
759 759
760struct dwc3_event_type { 760struct dwc3_event_type {
761 u32 is_devspec:1; 761 u32 is_devspec:1;
762 u32 type:6; 762 u32 type:7;
763 u32 reserved8_31:25; 763 u32 reserved8_31:24;
764} __packed; 764} __packed;
765 765
766#define DWC3_DEPEVT_XFERCOMPLETE 0x01 766#define DWC3_DEPEVT_XFERCOMPLETE 0x01
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index b5e5b35df49c..f77083fedc68 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1584,6 +1584,7 @@ err1:
1584 __dwc3_gadget_ep_disable(dwc->eps[0]); 1584 __dwc3_gadget_ep_disable(dwc->eps[0]);
1585 1585
1586err0: 1586err0:
1587 dwc->gadget_driver = NULL;
1587 spin_unlock_irqrestore(&dwc->lock, flags); 1588 spin_unlock_irqrestore(&dwc->lock, flags);
1588 1589
1589 return ret; 1590 return ret;
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 62f6802f6e0f..8e9368330b10 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -193,6 +193,7 @@ config USB_FUSB300
193 Faraday usb device controller FUSB300 driver 193 Faraday usb device controller FUSB300 driver
194 194
195config USB_FOTG210_UDC 195config USB_FOTG210_UDC
196 depends on HAS_DMA
196 tristate "Faraday FOTG210 USB Peripheral Controller" 197 tristate "Faraday FOTG210 USB Peripheral Controller"
197 help 198 help
198 Faraday USB2.0 OTG controller which can be configured as 199 Faraday USB2.0 OTG controller which can be configured as
@@ -328,13 +329,14 @@ config USB_S3C_HSUDC
328 329
329config USB_MV_UDC 330config USB_MV_UDC
330 tristate "Marvell USB2.0 Device Controller" 331 tristate "Marvell USB2.0 Device Controller"
331 depends on GENERIC_HARDIRQS 332 depends on GENERIC_HARDIRQS && HAS_DMA
332 help 333 help
333 Marvell Socs (including PXA and MMP series) include a high speed 334 Marvell Socs (including PXA and MMP series) include a high speed
334 USB2.0 OTG controller, which can be configured as high speed or 335 USB2.0 OTG controller, which can be configured as high speed or
335 full speed USB peripheral. 336 full speed USB peripheral.
336 337
337config USB_MV_U3D 338config USB_MV_U3D
339 depends on HAS_DMA
338 tristate "MARVELL PXA2128 USB 3.0 controller" 340 tristate "MARVELL PXA2128 USB 3.0 controller"
339 help 341 help
340 MARVELL PXA2128 Processor series include a super speed USB3.0 device 342 MARVELL PXA2128 Processor series include a super speed USB3.0 device
@@ -639,6 +641,7 @@ config USB_CONFIGFS_RNDIS
639 depends on USB_CONFIGFS 641 depends on USB_CONFIGFS
640 depends on NET 642 depends on NET
641 select USB_U_ETHER 643 select USB_U_ETHER
644 select USB_U_RNDIS
642 select USB_F_RNDIS 645 select USB_F_RNDIS
643 help 646 help
644 Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, 647 Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 073b938f9135..d9a6add0c852 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -870,8 +870,8 @@ static void clk_on(struct at91_udc *udc)
870 if (udc->clocked) 870 if (udc->clocked)
871 return; 871 return;
872 udc->clocked = 1; 872 udc->clocked = 1;
873 clk_enable(udc->iclk); 873 clk_prepare_enable(udc->iclk);
874 clk_enable(udc->fclk); 874 clk_prepare_enable(udc->fclk);
875} 875}
876 876
877static void clk_off(struct at91_udc *udc) 877static void clk_off(struct at91_udc *udc)
@@ -880,8 +880,8 @@ static void clk_off(struct at91_udc *udc)
880 return; 880 return;
881 udc->clocked = 0; 881 udc->clocked = 0;
882 udc->gadget.speed = USB_SPEED_UNKNOWN; 882 udc->gadget.speed = USB_SPEED_UNKNOWN;
883 clk_disable(udc->fclk); 883 clk_disable_unprepare(udc->fclk);
884 clk_disable(udc->iclk); 884 clk_disable_unprepare(udc->iclk);
885} 885}
886 886
887/* 887/*
@@ -1725,7 +1725,7 @@ static int at91udc_probe(struct platform_device *pdev)
1725 /* init software state */ 1725 /* init software state */
1726 udc = &controller; 1726 udc = &controller;
1727 udc->gadget.dev.parent = dev; 1727 udc->gadget.dev.parent = dev;
1728 if (pdev->dev.of_node) 1728 if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
1729 at91udc_of_init(udc, pdev->dev.of_node); 1729 at91udc_of_init(udc, pdev->dev.of_node);
1730 else 1730 else
1731 memcpy(&udc->board, dev->platform_data, 1731 memcpy(&udc->board, dev->platform_data,
@@ -1782,12 +1782,14 @@ static int at91udc_probe(struct platform_device *pdev)
1782 } 1782 }
1783 1783
1784 /* don't do anything until we have both gadget driver and VBUS */ 1784 /* don't do anything until we have both gadget driver and VBUS */
1785 clk_enable(udc->iclk); 1785 retval = clk_prepare_enable(udc->iclk);
1786 if (retval)
1787 goto fail1;
1786 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 1788 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
1787 at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff); 1789 at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff);
1788 /* Clear all pending interrupts - UDP may be used by bootloader. */ 1790 /* Clear all pending interrupts - UDP may be used by bootloader. */
1789 at91_udp_write(udc, AT91_UDP_ICR, 0xffffffff); 1791 at91_udp_write(udc, AT91_UDP_ICR, 0xffffffff);
1790 clk_disable(udc->iclk); 1792 clk_disable_unprepare(udc->iclk);
1791 1793
1792 /* request UDC and maybe VBUS irqs */ 1794 /* request UDC and maybe VBUS irqs */
1793 udc->udp_irq = platform_get_irq(pdev, 0); 1795 udc->udp_irq = platform_get_irq(pdev, 0);
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 5d3561ea1c15..edab45da3741 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -959,8 +959,11 @@ static struct usb_function_instance *ecm_alloc_inst(void)
959 mutex_init(&opts->lock); 959 mutex_init(&opts->lock);
960 opts->func_inst.free_func_inst = ecm_free_inst; 960 opts->func_inst.free_func_inst = ecm_free_inst;
961 opts->net = gether_setup_default(); 961 opts->net = gether_setup_default();
962 if (IS_ERR(opts->net)) 962 if (IS_ERR(opts->net)) {
963 return ERR_PTR(PTR_ERR(opts->net)); 963 struct net_device *net = opts->net;
964 kfree(opts);
965 return ERR_CAST(net);
966 }
964 967
965 config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type); 968 config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type);
966 969
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 90ee8022e8d8..d00392d879db 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -593,8 +593,11 @@ static struct usb_function_instance *eem_alloc_inst(void)
593 mutex_init(&opts->lock); 593 mutex_init(&opts->lock);
594 opts->func_inst.free_func_inst = eem_free_inst; 594 opts->func_inst.free_func_inst = eem_free_inst;
595 opts->net = gether_setup_default(); 595 opts->net = gether_setup_default();
596 if (IS_ERR(opts->net)) 596 if (IS_ERR(opts->net)) {
597 return ERR_CAST(opts->net); 597 struct net_device *net = opts->net;
598 kfree(opts);
599 return ERR_CAST(net);
600 }
598 601
599 config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type); 602 config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
600 603
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 952177f7eb9b..1c28fe13328a 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1350,8 +1350,11 @@ static struct usb_function_instance *ncm_alloc_inst(void)
1350 mutex_init(&opts->lock); 1350 mutex_init(&opts->lock);
1351 opts->func_inst.free_func_inst = ncm_free_inst; 1351 opts->func_inst.free_func_inst = ncm_free_inst;
1352 opts->net = gether_setup_default(); 1352 opts->net = gether_setup_default();
1353 if (IS_ERR(opts->net)) 1353 if (IS_ERR(opts->net)) {
1354 return ERR_PTR(PTR_ERR(opts->net)); 1354 struct net_device *net = opts->net;
1355 kfree(opts);
1356 return ERR_CAST(net);
1357 }
1355 1358
1356 config_group_init_type_name(&opts->func_inst.group, "", &ncm_func_type); 1359 config_group_init_type_name(&opts->func_inst.group, "", &ncm_func_type);
1357 1360
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 7944fb0efe3b..1bf26e9f38cd 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -656,8 +656,11 @@ static struct usb_function_instance *phonet_alloc_inst(void)
656 656
657 opts->func_inst.free_func_inst = phonet_free_inst; 657 opts->func_inst.free_func_inst = phonet_free_inst;
658 opts->net = gphonet_setup_default(); 658 opts->net = gphonet_setup_default();
659 if (IS_ERR(opts->net)) 659 if (IS_ERR(opts->net)) {
660 return ERR_PTR(PTR_ERR(opts->net)); 660 struct net_device *net = opts->net;
661 kfree(opts);
662 return ERR_CAST(net);
663 }
661 664
662 config_group_init_type_name(&opts->func_inst.group, "", 665 config_group_init_type_name(&opts->func_inst.group, "",
663 &phonet_func_type); 666 &phonet_func_type);
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 191df35ae69d..717ed7f95639 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -963,8 +963,11 @@ static struct usb_function_instance *rndis_alloc_inst(void)
963 mutex_init(&opts->lock); 963 mutex_init(&opts->lock);
964 opts->func_inst.free_func_inst = rndis_free_inst; 964 opts->func_inst.free_func_inst = rndis_free_inst;
965 opts->net = gether_setup_default(); 965 opts->net = gether_setup_default();
966 if (IS_ERR(opts->net)) 966 if (IS_ERR(opts->net)) {
967 return ERR_CAST(opts->net); 967 struct net_device *net = opts->net;
968 kfree(opts);
969 return ERR_CAST(net);
970 }
968 971
969 config_group_init_type_name(&opts->func_inst.group, "", 972 config_group_init_type_name(&opts->func_inst.group, "",
970 &rndis_func_type); 973 &rndis_func_type);
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index 5601e1d96c4f..7c8674fa7e80 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -505,8 +505,11 @@ static struct usb_function_instance *geth_alloc_inst(void)
505 mutex_init(&opts->lock); 505 mutex_init(&opts->lock);
506 opts->func_inst.free_func_inst = geth_free_inst; 506 opts->func_inst.free_func_inst = geth_free_inst;
507 opts->net = gether_setup_default(); 507 opts->net = gether_setup_default();
508 if (IS_ERR(opts->net)) 508 if (IS_ERR(opts->net)) {
509 return ERR_CAST(opts->net); 509 struct net_device *net = opts->net;
510 kfree(opts);
511 return ERR_CAST(net);
512 }
510 513
511 config_group_init_type_name(&opts->func_inst.group, "", 514 config_group_init_type_name(&opts->func_inst.group, "",
512 &gether_func_type); 515 &gether_func_type);
diff --git a/drivers/usb/gadget/fotg210-udc.c b/drivers/usb/gadget/fotg210-udc.c
index cce5535b1dc6..10cd18ddd0d4 100644
--- a/drivers/usb/gadget/fotg210-udc.c
+++ b/drivers/usb/gadget/fotg210-udc.c
@@ -1074,7 +1074,7 @@ static struct usb_gadget_ops fotg210_gadget_ops = {
1074 .udc_stop = fotg210_udc_stop, 1074 .udc_stop = fotg210_udc_stop,
1075}; 1075};
1076 1076
1077static int __exit fotg210_udc_remove(struct platform_device *pdev) 1077static int fotg210_udc_remove(struct platform_device *pdev)
1078{ 1078{
1079 struct fotg210_udc *fotg210 = dev_get_drvdata(&pdev->dev); 1079 struct fotg210_udc *fotg210 = dev_get_drvdata(&pdev->dev);
1080 1080
@@ -1088,7 +1088,7 @@ static int __exit fotg210_udc_remove(struct platform_device *pdev)
1088 return 0; 1088 return 0;
1089} 1089}
1090 1090
1091static int __init fotg210_udc_probe(struct platform_device *pdev) 1091static int fotg210_udc_probe(struct platform_device *pdev)
1092{ 1092{
1093 struct resource *res, *ires; 1093 struct resource *res, *ires;
1094 struct fotg210_udc *fotg210 = NULL; 1094 struct fotg210_udc *fotg210 = NULL;
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 07fdb3eaf48a..ec6a2d290398 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -1776,7 +1776,7 @@ static int mv_u3d_remove(struct platform_device *dev)
1776 kfree(u3d->eps); 1776 kfree(u3d->eps);
1777 1777
1778 if (u3d->irq) 1778 if (u3d->irq)
1779 free_irq(u3d->irq, &dev->dev); 1779 free_irq(u3d->irq, u3d);
1780 1780
1781 if (u3d->cap_regs) 1781 if (u3d->cap_regs)
1782 iounmap(u3d->cap_regs); 1782 iounmap(u3d->cap_regs);
@@ -1974,7 +1974,7 @@ static int mv_u3d_probe(struct platform_device *dev)
1974 return 0; 1974 return 0;
1975 1975
1976err_unregister: 1976err_unregister:
1977 free_irq(u3d->irq, &dev->dev); 1977 free_irq(u3d->irq, u3d);
1978err_request_irq: 1978err_request_irq:
1979err_get_irq: 1979err_get_irq:
1980 kfree(u3d->status_req); 1980 kfree(u3d->status_req);
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index ffd8fa541101..c28ac9872030 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -50,6 +50,8 @@ static DEFINE_MUTEX(udc_lock);
50 50
51/* ------------------------------------------------------------------------- */ 51/* ------------------------------------------------------------------------- */
52 52
53#ifdef CONFIG_HAS_DMA
54
53int usb_gadget_map_request(struct usb_gadget *gadget, 55int usb_gadget_map_request(struct usb_gadget *gadget,
54 struct usb_request *req, int is_in) 56 struct usb_request *req, int is_in)
55{ 57{
@@ -99,6 +101,8 @@ void usb_gadget_unmap_request(struct usb_gadget *gadget,
99} 101}
100EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); 102EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
101 103
104#endif /* CONFIG_HAS_DMA */
105
102/* ------------------------------------------------------------------------- */ 106/* ------------------------------------------------------------------------- */
103 107
104void usb_gadget_set_state(struct usb_gadget *gadget, 108void usb_gadget_set_state(struct usb_gadget *gadget,
@@ -194,9 +198,11 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
194 dev_set_name(&gadget->dev, "gadget"); 198 dev_set_name(&gadget->dev, "gadget");
195 gadget->dev.parent = parent; 199 gadget->dev.parent = parent;
196 200
201#ifdef CONFIG_HAS_DMA
197 dma_set_coherent_mask(&gadget->dev, parent->coherent_dma_mask); 202 dma_set_coherent_mask(&gadget->dev, parent->coherent_dma_mask);
198 gadget->dev.dma_parms = parent->dma_parms; 203 gadget->dev.dma_parms = parent->dma_parms;
199 gadget->dev.dma_mask = parent->dma_mask; 204 gadget->dev.dma_mask = parent->dma_mask;
205#endif
200 206
201 if (release) 207 if (release)
202 gadget->dev.release = release; 208 gadget->dev.release = release;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 2b702772d04d..6dce37555c4f 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -874,6 +874,7 @@ static int ehci_hub_control (
874 ehci->reset_done[wIndex] = jiffies 874 ehci->reset_done[wIndex] = jiffies
875 + msecs_to_jiffies(20); 875 + msecs_to_jiffies(20);
876 usb_hcd_start_port_resume(&hcd->self, wIndex); 876 usb_hcd_start_port_resume(&hcd->self, wIndex);
877 set_bit(wIndex, &ehci->resuming_ports);
877 /* check the port again */ 878 /* check the port again */
878 mod_timer(&ehci_to_hcd(ehci)->rh_timer, 879 mod_timer(&ehci_to_hcd(ehci)->rh_timer,
879 ehci->reset_done[wIndex]); 880 ehci->reset_done[wIndex]);
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h
index 4b8a2092432f..978c849f9c9a 100644
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quirks.h
@@ -13,6 +13,7 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev);
13void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); 13void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
14void sb800_prefetch(struct device *dev, int on); 14void sb800_prefetch(struct device *dev, int on);
15#else 15#else
16struct pci_dev;
16static inline void usb_amd_quirk_pll_disable(void) {} 17static inline void usb_amd_quirk_pll_disable(void) {}
17static inline void usb_amd_quirk_pll_enable(void) {} 18static inline void usb_amd_quirk_pll_enable(void) {}
18static inline void usb_amd_dev_put(void) {} 19static inline void usb_amd_dev_put(void) {}
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index cc24e39b97d5..f00cb203faea 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -93,7 +93,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
93 } 93 }
94 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 94 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
95 pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) { 95 pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) {
96 xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
97 xhci->quirks |= XHCI_EP_LIMIT_QUIRK; 96 xhci->quirks |= XHCI_EP_LIMIT_QUIRK;
98 xhci->limit_active_eps = 64; 97 xhci->limit_active_eps = 64;
99 xhci->quirks |= XHCI_SW_BW_CHECKING; 98 xhci->quirks |= XHCI_SW_BW_CHECKING;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 1e57eafa6910..5b08cd85f8e7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -434,7 +434,7 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
434 434
435 /* A ring has pending URBs if its TD list is not empty */ 435 /* A ring has pending URBs if its TD list is not empty */
436 if (!(ep->ep_state & EP_HAS_STREAMS)) { 436 if (!(ep->ep_state & EP_HAS_STREAMS)) {
437 if (!(list_empty(&ep->ring->td_list))) 437 if (ep->ring && !(list_empty(&ep->ring->td_list)))
438 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, 0); 438 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, 0);
439 return; 439 return;
440 } 440 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2c49f00260ca..41eb4fc33453 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -329,7 +329,7 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
329 return; 329 return;
330} 330}
331 331
332static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) 332static void __maybe_unused xhci_msix_sync_irqs(struct xhci_hcd *xhci)
333{ 333{
334 int i; 334 int i;
335 335
@@ -1181,9 +1181,6 @@ static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
1181 } 1181 }
1182 1182
1183 xhci = hcd_to_xhci(hcd); 1183 xhci = hcd_to_xhci(hcd);
1184 if (xhci->xhc_state & XHCI_STATE_HALTED)
1185 return -ENODEV;
1186
1187 if (check_virt_dev) { 1184 if (check_virt_dev) {
1188 if (!udev->slot_id || !xhci->devs[udev->slot_id]) { 1185 if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
1189 printk(KERN_DEBUG "xHCI %s called with unaddressed " 1186 printk(KERN_DEBUG "xHCI %s called with unaddressed "
@@ -1199,6 +1196,9 @@ static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
1199 } 1196 }
1200 } 1197 }
1201 1198
1199 if (xhci->xhc_state & XHCI_STATE_HALTED)
1200 return -ENODEV;
1201
1202 return 1; 1202 return 1;
1203} 1203}
1204 1204
@@ -3898,7 +3898,7 @@ int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1)
3898 * Issue an Evaluate Context command to change the Maximum Exit Latency in the 3898 * Issue an Evaluate Context command to change the Maximum Exit Latency in the
3899 * slot context. If that succeeds, store the new MEL in the xhci_virt_device. 3899 * slot context. If that succeeds, store the new MEL in the xhci_virt_device.
3900 */ 3900 */
3901static int xhci_change_max_exit_latency(struct xhci_hcd *xhci, 3901static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
3902 struct usb_device *udev, u16 max_exit_latency) 3902 struct usb_device *udev, u16 max_exit_latency)
3903{ 3903{
3904 struct xhci_virt_device *virt_dev; 3904 struct xhci_virt_device *virt_dev;
@@ -4892,6 +4892,13 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4892 4892
4893 get_quirks(dev, xhci); 4893 get_quirks(dev, xhci);
4894 4894
4895 /* In xhci controllers which follow xhci 1.0 spec gives a spurious
4896 * success event after a short transfer. This quirk will ignore such
4897 * spurious event.
4898 */
4899 if (xhci->hci_version > 0x96)
4900 xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
4901
4895 /* Make sure the HC is halted. */ 4902 /* Make sure the HC is halted. */
4896 retval = xhci_halt(xhci); 4903 retval = xhci_halt(xhci);
4897 if (retval) 4904 if (retval)
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index c21386ec5d35..de98906f786d 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3247,6 +3247,7 @@ static const struct usb_device_id sisusb_table[] = {
3247 { USB_DEVICE(0x0711, 0x0903) }, 3247 { USB_DEVICE(0x0711, 0x0903) },
3248 { USB_DEVICE(0x0711, 0x0918) }, 3248 { USB_DEVICE(0x0711, 0x0918) },
3249 { USB_DEVICE(0x0711, 0x0920) }, 3249 { USB_DEVICE(0x0711, 0x0920) },
3250 { USB_DEVICE(0x0711, 0x0950) },
3250 { USB_DEVICE(0x182d, 0x021c) }, 3251 { USB_DEVICE(0x182d, 0x021c) },
3251 { USB_DEVICE(0x182d, 0x0269) }, 3252 { USB_DEVICE(0x182d, 0x0269) },
3252 { } 3253 { }
diff --git a/drivers/usb/phy/phy-omap-usb3.c b/drivers/usb/phy/phy-omap-usb3.c
index efe6e1464f45..a2fb30bbb971 100644
--- a/drivers/usb/phy/phy-omap-usb3.c
+++ b/drivers/usb/phy/phy-omap-usb3.c
@@ -71,9 +71,9 @@ static struct usb_dpll_params omap_usb3_dpll_params[NUM_SYS_CLKS] = {
71 {1250, 5, 4, 20, 0}, /* 12 MHz */ 71 {1250, 5, 4, 20, 0}, /* 12 MHz */
72 {3125, 20, 4, 20, 0}, /* 16.8 MHz */ 72 {3125, 20, 4, 20, 0}, /* 16.8 MHz */
73 {1172, 8, 4, 20, 65537}, /* 19.2 MHz */ 73 {1172, 8, 4, 20, 65537}, /* 19.2 MHz */
74 {1000, 7, 4, 10, 0}, /* 20 MHz */
74 {1250, 12, 4, 20, 0}, /* 26 MHz */ 75 {1250, 12, 4, 20, 0}, /* 26 MHz */
75 {3125, 47, 4, 20, 92843}, /* 38.4 MHz */ 76 {3125, 47, 4, 20, 92843}, /* 38.4 MHz */
76 {1000, 7, 4, 10, 0}, /* 20 MHz */
77 77
78}; 78};
79 79
diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-samsung-usb2.c
index 1011c16ade7e..758b86d0fcb3 100644
--- a/drivers/usb/phy/phy-samsung-usb2.c
+++ b/drivers/usb/phy/phy-samsung-usb2.c
@@ -388,7 +388,7 @@ static int samsung_usb2phy_probe(struct platform_device *pdev)
388 clk = devm_clk_get(dev, "otg"); 388 clk = devm_clk_get(dev, "otg");
389 389
390 if (IS_ERR(clk)) { 390 if (IS_ERR(clk)) {
391 dev_err(dev, "Failed to get otg clock\n"); 391 dev_err(dev, "Failed to get usbhost/otg clock\n");
392 return PTR_ERR(clk); 392 return PTR_ERR(clk);
393 } 393 }
394 394
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index ed4949faa70d..805940c37353 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -855,10 +855,6 @@ static int usbhsg_gadget_stop(struct usb_gadget *gadget,
855 struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); 855 struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
856 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); 856 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
857 857
858 if (!driver ||
859 !driver->unbind)
860 return -EINVAL;
861
862 usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); 858 usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD);
863 gpriv->driver = NULL; 859 gpriv->driver = NULL;
864 860
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index d6ef2f8da37d..0eae4ba3760e 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -53,6 +53,7 @@ static const struct usb_device_id id_table[] = {
53 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 53 { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
54 { USB_DEVICE(0x0489, 0xE003) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */ 54 { USB_DEVICE(0x0489, 0xE003) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
55 { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */ 55 { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */
56 { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */
56 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ 57 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
57 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */ 58 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
58 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */ 59 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
@@ -118,6 +119,8 @@ static const struct usb_device_id id_table[] = {
118 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */ 119 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
119 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */ 120 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */
120 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ 121 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
122 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
123 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
121 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 124 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
122 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 125 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
123 { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ 126 { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
@@ -148,6 +151,7 @@ static const struct usb_device_id id_table[] = {
148 { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */ 151 { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
149 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ 152 { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
150 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 153 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
154 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
151 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ 155 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
152 { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ 156 { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
153 { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */ 157 { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 0a818b238508..603fb70dde80 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -905,20 +905,20 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
905 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); 905 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
906 if (status < 0) { 906 if (status < 0) {
907 dev_dbg(&port->dev, "Reading Spreg failed\n"); 907 dev_dbg(&port->dev, "Reading Spreg failed\n");
908 return -1; 908 goto err;
909 } 909 }
910 Data |= 0x80; 910 Data |= 0x80;
911 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); 911 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
912 if (status < 0) { 912 if (status < 0) {
913 dev_dbg(&port->dev, "writing Spreg failed\n"); 913 dev_dbg(&port->dev, "writing Spreg failed\n");
914 return -1; 914 goto err;
915 } 915 }
916 916
917 Data &= ~0x80; 917 Data &= ~0x80;
918 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); 918 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
919 if (status < 0) { 919 if (status < 0) {
920 dev_dbg(&port->dev, "writing Spreg failed\n"); 920 dev_dbg(&port->dev, "writing Spreg failed\n");
921 return -1; 921 goto err;
922 } 922 }
923 /* End of block to be checked */ 923 /* End of block to be checked */
924 924
@@ -927,7 +927,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
927 &Data); 927 &Data);
928 if (status < 0) { 928 if (status < 0) {
929 dev_dbg(&port->dev, "Reading Controlreg failed\n"); 929 dev_dbg(&port->dev, "Reading Controlreg failed\n");
930 return -1; 930 goto err;
931 } 931 }
932 Data |= 0x08; /* Driver done bit */ 932 Data |= 0x08; /* Driver done bit */
933 Data |= 0x20; /* rx_disable */ 933 Data |= 0x20; /* rx_disable */
@@ -935,7 +935,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
935 mos7840_port->ControlRegOffset, Data); 935 mos7840_port->ControlRegOffset, Data);
936 if (status < 0) { 936 if (status < 0) {
937 dev_dbg(&port->dev, "writing Controlreg failed\n"); 937 dev_dbg(&port->dev, "writing Controlreg failed\n");
938 return -1; 938 goto err;
939 } 939 }
940 /* do register settings here */ 940 /* do register settings here */
941 /* Set all regs to the device default values. */ 941 /* Set all regs to the device default values. */
@@ -946,21 +946,21 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
946 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 946 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
947 if (status < 0) { 947 if (status < 0) {
948 dev_dbg(&port->dev, "disabling interrupts failed\n"); 948 dev_dbg(&port->dev, "disabling interrupts failed\n");
949 return -1; 949 goto err;
950 } 950 }
951 /* Set FIFO_CONTROL_REGISTER to the default value */ 951 /* Set FIFO_CONTROL_REGISTER to the default value */
952 Data = 0x00; 952 Data = 0x00;
953 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 953 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
954 if (status < 0) { 954 if (status < 0) {
955 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n"); 955 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n");
956 return -1; 956 goto err;
957 } 957 }
958 958
959 Data = 0xcf; 959 Data = 0xcf;
960 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 960 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
961 if (status < 0) { 961 if (status < 0) {
962 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n"); 962 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n");
963 return -1; 963 goto err;
964 } 964 }
965 965
966 Data = 0x03; 966 Data = 0x03;
@@ -1103,6 +1103,15 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1103 /* mos7840_change_port_settings(mos7840_port,old_termios); */ 1103 /* mos7840_change_port_settings(mos7840_port,old_termios); */
1104 1104
1105 return 0; 1105 return 0;
1106err:
1107 for (j = 0; j < NUM_URBS; ++j) {
1108 urb = mos7840_port->write_urb_pool[j];
1109 if (!urb)
1110 continue;
1111 kfree(urb->transfer_buffer);
1112 usb_free_urb(urb);
1113 }
1114 return status;
1106} 1115}
1107 1116
1108/***************************************************************************** 1117/*****************************************************************************
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 5dd857de05b0..1cf6f125f5f0 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -341,17 +341,12 @@ static void option_instat_callback(struct urb *urb);
341#define OLIVETTI_VENDOR_ID 0x0b3c 341#define OLIVETTI_VENDOR_ID 0x0b3c
342#define OLIVETTI_PRODUCT_OLICARD100 0xc000 342#define OLIVETTI_PRODUCT_OLICARD100 0xc000
343#define OLIVETTI_PRODUCT_OLICARD145 0xc003 343#define OLIVETTI_PRODUCT_OLICARD145 0xc003
344#define OLIVETTI_PRODUCT_OLICARD200 0xc005
344 345
345/* Celot products */ 346/* Celot products */
346#define CELOT_VENDOR_ID 0x211f 347#define CELOT_VENDOR_ID 0x211f
347#define CELOT_PRODUCT_CT680M 0x6801 348#define CELOT_PRODUCT_CT680M 0x6801
348 349
349/* ONDA Communication vendor id */
350#define ONDA_VENDOR_ID 0x1ee8
351
352/* ONDA MT825UP HSDPA 14.2 modem */
353#define ONDA_MT825UP 0x000b
354
355/* Samsung products */ 350/* Samsung products */
356#define SAMSUNG_VENDOR_ID 0x04e8 351#define SAMSUNG_VENDOR_ID 0x04e8
357#define SAMSUNG_PRODUCT_GT_B3730 0x6889 352#define SAMSUNG_PRODUCT_GT_B3730 0x6889
@@ -444,7 +439,8 @@ static void option_instat_callback(struct urb *urb);
444 439
445/* Hyundai Petatel Inc. products */ 440/* Hyundai Petatel Inc. products */
446#define PETATEL_VENDOR_ID 0x1ff4 441#define PETATEL_VENDOR_ID 0x1ff4
447#define PETATEL_PRODUCT_NP10T 0x600e 442#define PETATEL_PRODUCT_NP10T_600A 0x600a
443#define PETATEL_PRODUCT_NP10T_600E 0x600e
448 444
449/* TP-LINK Incorporated products */ 445/* TP-LINK Incorporated products */
450#define TPLINK_VENDOR_ID 0x2357 446#define TPLINK_VENDOR_ID 0x2357
@@ -782,6 +778,7 @@ static const struct usb_device_id option_ids[] = {
782 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, 778 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
783 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 779 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
784 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 780 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
781 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
785 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ 782 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
786 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */ 783 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */
787 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) }, 784 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
@@ -817,7 +814,8 @@ static const struct usb_device_id option_ids[] = {
817 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff), 814 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff),
818 .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 815 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
819 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0018, 0xff, 0xff, 0xff) }, 816 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0018, 0xff, 0xff, 0xff) },
820 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0019, 0xff, 0xff, 0xff) }, 817 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0019, 0xff, 0xff, 0xff),
818 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
821 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0020, 0xff, 0xff, 0xff) }, 819 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0020, 0xff, 0xff, 0xff) },
822 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0021, 0xff, 0xff, 0xff), 820 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0021, 0xff, 0xff, 0xff),
823 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 821 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
@@ -1256,8 +1254,8 @@ static const struct usb_device_id option_ids[] = {
1256 1254
1257 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, 1255 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
1258 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) }, 1256 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
1257 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200) },
1259 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ 1258 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
1260 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
1261 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ 1259 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
1262 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, 1260 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
1263 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM610) }, 1261 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM610) },
@@ -1329,9 +1327,12 @@ static const struct usb_device_id option_ids[] = {
1329 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) }, 1327 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) },
1330 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) }, 1328 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) },
1331 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, 1329 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) },
1332 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T) }, 1330 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600A) },
1331 { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600E) },
1333 { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180), 1332 { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180),
1334 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1333 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1334 { USB_DEVICE(TPLINK_VENDOR_ID, 0x9000), /* TP-Link MA260 */
1335 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1335 { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) }, 1336 { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) },
1336 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) }, /* D-Link DWM-156 (variant) */ 1337 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) }, /* D-Link DWM-156 (variant) */
1337 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) }, /* D-Link DWM-156 (variant) */ 1338 { 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[] = {
1339 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) }, 1340 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
1340 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) }, 1341 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
1341 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, 1342 { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
1343 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1344 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1342 { } /* Terminating entry */ 1345 { } /* Terminating entry */
1343}; 1346};
1344MODULE_DEVICE_TABLE(usb, option_ids); 1347MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 7182bb774b79..375b5a400b6f 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -371,7 +371,7 @@ static int ti_startup(struct usb_serial *serial)
371 usb_set_serial_data(serial, tdev); 371 usb_set_serial_data(serial, tdev);
372 372
373 /* determine device type */ 373 /* determine device type */
374 if (usb_match_id(serial->interface, ti_id_table_3410)) 374 if (serial->type == &ti_1port_device)
375 tdev->td_is_3410 = 1; 375 tdev->td_is_3410 = 1;
376 dev_dbg(&dev->dev, "%s - device type is %s\n", __func__, 376 dev_dbg(&dev->dev, "%s - device type is %s\n", __func__,
377 tdev->td_is_3410 ? "3410" : "5052"); 377 tdev->td_is_3410 ? "3410" : "5052");
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 1799335288bd..c015f2c16729 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -665,6 +665,13 @@ UNUSUAL_DEV( 0x054c, 0x016a, 0x0000, 0x9999,
665 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 665 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
666 US_FL_FIX_INQUIRY ), 666 US_FL_FIX_INQUIRY ),
667 667
668/* Submitted by Ren Bigcren <bigcren.ren@sonymobile.com> */
669UNUSUAL_DEV( 0x054c, 0x02a5, 0x0100, 0x0100,
670 "Sony Corp.",
671 "MicroVault Flash Drive",
672 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
673 US_FL_NO_READ_CAPACITY_16 ),
674
668/* floppy reports multiple luns */ 675/* floppy reports multiple luns */
669UNUSUAL_DEV( 0x055d, 0x2020, 0x0000, 0x0210, 676UNUSUAL_DEV( 0x055d, 0x2020, 0x0000, 0x0210,
670 "SAMSUNG", 677 "SAMSUNG",
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 027be91db139..969a85960e9f 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -15,7 +15,6 @@
15#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18#include <linux/rcupdate.h>
19#include <linux/file.h> 18#include <linux/file.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21 20
@@ -346,12 +345,11 @@ static void handle_tx(struct vhost_net *net)
346 struct vhost_net_ubuf_ref *uninitialized_var(ubufs); 345 struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
347 bool zcopy, zcopy_used; 346 bool zcopy, zcopy_used;
348 347
349 /* TODO: check that we are running from vhost_worker? */ 348 mutex_lock(&vq->mutex);
350 sock = rcu_dereference_check(vq->private_data, 1); 349 sock = vq->private_data;
351 if (!sock) 350 if (!sock)
352 return; 351 goto out;
353 352
354 mutex_lock(&vq->mutex);
355 vhost_disable_notify(&net->dev, vq); 353 vhost_disable_notify(&net->dev, vq);
356 354
357 hdr_size = nvq->vhost_hlen; 355 hdr_size = nvq->vhost_hlen;
@@ -461,7 +459,7 @@ static void handle_tx(struct vhost_net *net)
461 break; 459 break;
462 } 460 }
463 } 461 }
464 462out:
465 mutex_unlock(&vq->mutex); 463 mutex_unlock(&vq->mutex);
466} 464}
467 465
@@ -570,14 +568,14 @@ static void handle_rx(struct vhost_net *net)
570 s16 headcount; 568 s16 headcount;
571 size_t vhost_hlen, sock_hlen; 569 size_t vhost_hlen, sock_hlen;
572 size_t vhost_len, sock_len; 570 size_t vhost_len, sock_len;
573 /* TODO: check that we are running from vhost_worker? */ 571 struct socket *sock;
574 struct socket *sock = rcu_dereference_check(vq->private_data, 1);
575
576 if (!sock)
577 return;
578 572
579 mutex_lock(&vq->mutex); 573 mutex_lock(&vq->mutex);
574 sock = vq->private_data;
575 if (!sock)
576 goto out;
580 vhost_disable_notify(&net->dev, vq); 577 vhost_disable_notify(&net->dev, vq);
578
581 vhost_hlen = nvq->vhost_hlen; 579 vhost_hlen = nvq->vhost_hlen;
582 sock_hlen = nvq->sock_hlen; 580 sock_hlen = nvq->sock_hlen;
583 581
@@ -652,7 +650,7 @@ static void handle_rx(struct vhost_net *net)
652 break; 650 break;
653 } 651 }
654 } 652 }
655 653out:
656 mutex_unlock(&vq->mutex); 654 mutex_unlock(&vq->mutex);
657} 655}
658 656
@@ -750,8 +748,7 @@ static int vhost_net_enable_vq(struct vhost_net *n,
750 struct vhost_poll *poll = n->poll + (nvq - n->vqs); 748 struct vhost_poll *poll = n->poll + (nvq - n->vqs);
751 struct socket *sock; 749 struct socket *sock;
752 750
753 sock = rcu_dereference_protected(vq->private_data, 751 sock = vq->private_data;
754 lockdep_is_held(&vq->mutex));
755 if (!sock) 752 if (!sock)
756 return 0; 753 return 0;
757 754
@@ -764,10 +761,9 @@ static struct socket *vhost_net_stop_vq(struct vhost_net *n,
764 struct socket *sock; 761 struct socket *sock;
765 762
766 mutex_lock(&vq->mutex); 763 mutex_lock(&vq->mutex);
767 sock = rcu_dereference_protected(vq->private_data, 764 sock = vq->private_data;
768 lockdep_is_held(&vq->mutex));
769 vhost_net_disable_vq(n, vq); 765 vhost_net_disable_vq(n, vq);
770 rcu_assign_pointer(vq->private_data, NULL); 766 vq->private_data = NULL;
771 mutex_unlock(&vq->mutex); 767 mutex_unlock(&vq->mutex);
772 return sock; 768 return sock;
773} 769}
@@ -923,8 +919,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
923 } 919 }
924 920
925 /* start polling new socket */ 921 /* start polling new socket */
926 oldsock = rcu_dereference_protected(vq->private_data, 922 oldsock = vq->private_data;
927 lockdep_is_held(&vq->mutex));
928 if (sock != oldsock) { 923 if (sock != oldsock) {
929 ubufs = vhost_net_ubuf_alloc(vq, 924 ubufs = vhost_net_ubuf_alloc(vq,
930 sock && vhost_sock_zcopy(sock)); 925 sock && vhost_sock_zcopy(sock));
@@ -934,7 +929,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
934 } 929 }
935 930
936 vhost_net_disable_vq(n, vq); 931 vhost_net_disable_vq(n, vq);
937 rcu_assign_pointer(vq->private_data, sock); 932 vq->private_data = sock;
938 r = vhost_init_used(vq); 933 r = vhost_init_used(vq);
939 if (r) 934 if (r)
940 goto err_used; 935 goto err_used;
@@ -968,7 +963,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
968 return 0; 963 return 0;
969 964
970err_used: 965err_used:
971 rcu_assign_pointer(vq->private_data, oldsock); 966 vq->private_data = oldsock;
972 vhost_net_enable_vq(n, vq); 967 vhost_net_enable_vq(n, vq);
973 if (ubufs) 968 if (ubufs)
974 vhost_net_ubuf_put_wait_and_free(ubufs); 969 vhost_net_ubuf_put_wait_and_free(ubufs);
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 06adf31a9248..0c27c7df1b09 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -902,19 +902,15 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
902 int head, ret; 902 int head, ret;
903 u8 target; 903 u8 target;
904 904
905 mutex_lock(&vq->mutex);
905 /* 906 /*
906 * We can handle the vq only after the endpoint is setup by calling the 907 * We can handle the vq only after the endpoint is setup by calling the
907 * VHOST_SCSI_SET_ENDPOINT ioctl. 908 * VHOST_SCSI_SET_ENDPOINT ioctl.
908 *
909 * TODO: Check that we are running from vhost_worker which acts
910 * as read-side critical section for vhost kind of RCU.
911 * See the comments in struct vhost_virtqueue in drivers/vhost/vhost.h
912 */ 909 */
913 vs_tpg = rcu_dereference_check(vq->private_data, 1); 910 vs_tpg = vq->private_data;
914 if (!vs_tpg) 911 if (!vs_tpg)
915 return; 912 goto out;
916 913
917 mutex_lock(&vq->mutex);
918 vhost_disable_notify(&vs->dev, vq); 914 vhost_disable_notify(&vs->dev, vq);
919 915
920 for (;;) { 916 for (;;) {
@@ -1064,6 +1060,7 @@ err_free:
1064 vhost_scsi_free_cmd(cmd); 1060 vhost_scsi_free_cmd(cmd);
1065err_cmd: 1061err_cmd:
1066 vhost_scsi_send_bad_target(vs, vq, head, out); 1062 vhost_scsi_send_bad_target(vs, vq, head, out);
1063out:
1067 mutex_unlock(&vq->mutex); 1064 mutex_unlock(&vq->mutex);
1068} 1065}
1069 1066
@@ -1232,9 +1229,8 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
1232 sizeof(vs->vs_vhost_wwpn)); 1229 sizeof(vs->vs_vhost_wwpn));
1233 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { 1230 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
1234 vq = &vs->vqs[i].vq; 1231 vq = &vs->vqs[i].vq;
1235 /* Flushing the vhost_work acts as synchronize_rcu */
1236 mutex_lock(&vq->mutex); 1232 mutex_lock(&vq->mutex);
1237 rcu_assign_pointer(vq->private_data, vs_tpg); 1233 vq->private_data = vs_tpg;
1238 vhost_init_used(vq); 1234 vhost_init_used(vq);
1239 mutex_unlock(&vq->mutex); 1235 mutex_unlock(&vq->mutex);
1240 } 1236 }
@@ -1313,9 +1309,8 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1313 if (match) { 1309 if (match) {
1314 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { 1310 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
1315 vq = &vs->vqs[i].vq; 1311 vq = &vs->vqs[i].vq;
1316 /* Flushing the vhost_work acts as synchronize_rcu */
1317 mutex_lock(&vq->mutex); 1312 mutex_lock(&vq->mutex);
1318 rcu_assign_pointer(vq->private_data, NULL); 1313 vq->private_data = NULL;
1319 mutex_unlock(&vq->mutex); 1314 mutex_unlock(&vq->mutex);
1320 } 1315 }
1321 } 1316 }
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index a73ea217f24d..339eae85859a 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/mutex.h> 14#include <linux/mutex.h>
15#include <linux/workqueue.h> 15#include <linux/workqueue.h>
16#include <linux/rcupdate.h>
17#include <linux/file.h> 16#include <linux/file.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19 18
@@ -200,9 +199,8 @@ static long vhost_test_run(struct vhost_test *n, int test)
200 priv = test ? n : NULL; 199 priv = test ? n : NULL;
201 200
202 /* start polling new socket */ 201 /* start polling new socket */
203 oldpriv = rcu_dereference_protected(vq->private_data, 202 oldpriv = vq->private_data;
204 lockdep_is_held(&vq->mutex)); 203 vq->private_data = priv;
205 rcu_assign_pointer(vq->private_data, priv);
206 204
207 r = vhost_init_used(&n->vqs[index]); 205 r = vhost_init_used(&n->vqs[index]);
208 206
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 42298cd23c73..4465ed5f316d 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -103,14 +103,8 @@ struct vhost_virtqueue {
103 struct iovec iov[UIO_MAXIOV]; 103 struct iovec iov[UIO_MAXIOV];
104 struct iovec *indirect; 104 struct iovec *indirect;
105 struct vring_used_elem *heads; 105 struct vring_used_elem *heads;
106 /* We use a kind of RCU to access private pointer. 106 /* Protected by virtqueue mutex. */
107 * All readers access it from worker, which makes it possible to 107 void *private_data;
108 * flush the vhost_work instead of synchronize_rcu. Therefore readers do
109 * not need to call rcu_read_lock/rcu_read_unlock: the beginning of
110 * vhost_work execution acts instead of rcu_read_lock() and the end of
111 * vhost_work execution acts instead of rcu_read_unlock().
112 * Writers use virtqueue mutex. */
113 void __rcu *private_data;
114 /* Log write descriptors */ 108 /* Log write descriptors */
115 void __user *log_base; 109 void __user *log_base;
116 struct vhost_log *log; 110 struct vhost_log *log;
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index 5ca11b066b7e..886e797f75f9 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -101,33 +101,37 @@ static const struct backlight_ops max8925_backlight_ops = {
101 .get_brightness = max8925_backlight_get_brightness, 101 .get_brightness = max8925_backlight_get_brightness,
102}; 102};
103 103
104#ifdef CONFIG_OF 104static void max8925_backlight_dt_init(struct platform_device *pdev)
105static int max8925_backlight_dt_init(struct platform_device *pdev,
106 struct max8925_backlight_pdata *pdata)
107{ 105{
108 struct device_node *nproot = pdev->dev.parent->of_node, *np; 106 struct device_node *nproot = pdev->dev.parent->of_node, *np;
109 int dual_string; 107 struct max8925_backlight_pdata *pdata;
108 u32 val;
109
110 if (!nproot || !IS_ENABLED(CONFIG_OF))
111 return;
112
113 pdata = devm_kzalloc(&pdev->dev,
114 sizeof(struct max8925_backlight_pdata),
115 GFP_KERNEL);
116 if (!pdata)
117 return;
110 118
111 if (!nproot)
112 return -ENODEV;
113 np = of_find_node_by_name(nproot, "backlight"); 119 np = of_find_node_by_name(nproot, "backlight");
114 if (!np) { 120 if (!np) {
115 dev_err(&pdev->dev, "failed to find backlight node\n"); 121 dev_err(&pdev->dev, "failed to find backlight node\n");
116 return -ENODEV; 122 return;
117 } 123 }
118 124
119 of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string); 125 if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val))
120 pdata->dual_string = dual_string; 126 pdata->dual_string = val;
121 return 0; 127
128 pdev->dev.platform_data = pdata;
122} 129}
123#else
124#define max8925_backlight_dt_init(x, y) (-1)
125#endif
126 130
127static int max8925_backlight_probe(struct platform_device *pdev) 131static int max8925_backlight_probe(struct platform_device *pdev)
128{ 132{
129 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 133 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
130 struct max8925_backlight_pdata *pdata = pdev->dev.platform_data; 134 struct max8925_backlight_pdata *pdata;
131 struct max8925_backlight_data *data; 135 struct max8925_backlight_data *data;
132 struct backlight_device *bl; 136 struct backlight_device *bl;
133 struct backlight_properties props; 137 struct backlight_properties props;
@@ -170,13 +174,10 @@ static int max8925_backlight_probe(struct platform_device *pdev)
170 platform_set_drvdata(pdev, bl); 174 platform_set_drvdata(pdev, bl);
171 175
172 value = 0; 176 value = 0;
173 if (pdev->dev.parent->of_node && !pdata) { 177 if (!pdev->dev.platform_data)
174 pdata = devm_kzalloc(&pdev->dev, 178 max8925_backlight_dt_init(pdev);
175 sizeof(struct max8925_backlight_pdata),
176 GFP_KERNEL);
177 max8925_backlight_dt_init(pdev, pdata);
178 }
179 179
180 pdata = pdev->dev.platform_data;
180 if (pdata) { 181 if (pdata) {
181 if (pdata->lxw_scl) 182 if (pdata->lxw_scl)
182 value |= (1 << 7); 183 value |= (1 << 7);
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index b963ea12d175..7aec6f39fdd5 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -1891,7 +1891,7 @@ static int uvesafb_setup(char *options)
1891 } 1891 }
1892 } 1892 }
1893 1893
1894 if (mtrr != 3 && mtrr != 1) 1894 if (mtrr != 3 && mtrr != 0)
1895 pr_warn("uvesafb: mtrr should be set to 0 or 3; %d is unsupported", mtrr); 1895 pr_warn("uvesafb: mtrr should be set to 0 or 3; %d is unsupported", mtrr);
1896 1896
1897 return 0; 1897 return 0;
diff --git a/drivers/xen/xen-acpi-cpuhotplug.c b/drivers/xen/xen-acpi-cpuhotplug.c
index 0caf4863be8c..8dae6c13063a 100644
--- a/drivers/xen/xen-acpi-cpuhotplug.c
+++ b/drivers/xen/xen-acpi-cpuhotplug.c
@@ -91,7 +91,7 @@ static int xen_acpi_processor_enable(struct acpi_device *device)
91 return 0; 91 return 0;
92} 92}
93 93
94static int __cpuinit xen_acpi_processor_add(struct acpi_device *device) 94static int xen_acpi_processor_add(struct acpi_device *device)
95{ 95{
96 int ret; 96 int ret;
97 struct acpi_processor *pr; 97 struct acpi_processor *pr;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0236de711989..1204c8ef6f32 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7466,6 +7466,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7466 int err = 0; 7466 int err = 0;
7467 int ret; 7467 int ret;
7468 int level; 7468 int level;
7469 bool root_dropped = false;
7469 7470
7470 path = btrfs_alloc_path(); 7471 path = btrfs_alloc_path();
7471 if (!path) { 7472 if (!path) {
@@ -7523,6 +7524,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7523 while (1) { 7524 while (1) {
7524 btrfs_tree_lock(path->nodes[level]); 7525 btrfs_tree_lock(path->nodes[level]);
7525 btrfs_set_lock_blocking(path->nodes[level]); 7526 btrfs_set_lock_blocking(path->nodes[level]);
7527 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
7526 7528
7527 ret = btrfs_lookup_extent_info(trans, root, 7529 ret = btrfs_lookup_extent_info(trans, root,
7528 path->nodes[level]->start, 7530 path->nodes[level]->start,
@@ -7538,6 +7540,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7538 break; 7540 break;
7539 7541
7540 btrfs_tree_unlock(path->nodes[level]); 7542 btrfs_tree_unlock(path->nodes[level]);
7543 path->locks[level] = 0;
7541 WARN_ON(wc->refs[level] != 1); 7544 WARN_ON(wc->refs[level] != 1);
7542 level--; 7545 level--;
7543 } 7546 }
@@ -7552,11 +7555,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7552 wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root); 7555 wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
7553 7556
7554 while (1) { 7557 while (1) {
7555 if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
7556 pr_debug("btrfs: drop snapshot early exit\n");
7557 err = -EAGAIN;
7558 goto out_end_trans;
7559 }
7560 7558
7561 ret = walk_down_tree(trans, root, path, wc); 7559 ret = walk_down_tree(trans, root, path, wc);
7562 if (ret < 0) { 7560 if (ret < 0) {
@@ -7584,7 +7582,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7584 } 7582 }
7585 7583
7586 BUG_ON(wc->level == 0); 7584 BUG_ON(wc->level == 0);
7587 if (btrfs_should_end_transaction(trans, tree_root)) { 7585 if (btrfs_should_end_transaction(trans, tree_root) ||
7586 (!for_reloc && btrfs_need_cleaner_sleep(root))) {
7588 ret = btrfs_update_root(trans, tree_root, 7587 ret = btrfs_update_root(trans, tree_root,
7589 &root->root_key, 7588 &root->root_key,
7590 root_item); 7589 root_item);
@@ -7595,6 +7594,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7595 } 7594 }
7596 7595
7597 btrfs_end_transaction_throttle(trans, tree_root); 7596 btrfs_end_transaction_throttle(trans, tree_root);
7597 if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
7598 pr_debug("btrfs: drop snapshot early exit\n");
7599 err = -EAGAIN;
7600 goto out_free;
7601 }
7602
7598 trans = btrfs_start_transaction(tree_root, 0); 7603 trans = btrfs_start_transaction(tree_root, 0);
7599 if (IS_ERR(trans)) { 7604 if (IS_ERR(trans)) {
7600 err = PTR_ERR(trans); 7605 err = PTR_ERR(trans);
@@ -7639,12 +7644,22 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
7639 free_extent_buffer(root->commit_root); 7644 free_extent_buffer(root->commit_root);
7640 btrfs_put_fs_root(root); 7645 btrfs_put_fs_root(root);
7641 } 7646 }
7647 root_dropped = true;
7642out_end_trans: 7648out_end_trans:
7643 btrfs_end_transaction_throttle(trans, tree_root); 7649 btrfs_end_transaction_throttle(trans, tree_root);
7644out_free: 7650out_free:
7645 kfree(wc); 7651 kfree(wc);
7646 btrfs_free_path(path); 7652 btrfs_free_path(path);
7647out: 7653out:
7654 /*
7655 * So if we need to stop dropping the snapshot for whatever reason we
7656 * need to make sure to add it back to the dead root list so that we
7657 * keep trying to do the work later. This also cleans up roots if we
7658 * don't have it in the radix (like when we recover after a power fail
7659 * or unmount) so we don't leak memory.
7660 */
7661 if (root_dropped == false)
7662 btrfs_add_dead_root(root);
7648 if (err) 7663 if (err)
7649 btrfs_std_error(root->fs_info, err); 7664 btrfs_std_error(root->fs_info, err);
7650 return err; 7665 return err;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 4ba2a69a60ad..64a157becbe5 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2495,7 +2495,7 @@ again:
2495 ret = scrub_extent(sctx, extent_logical, extent_len, 2495 ret = scrub_extent(sctx, extent_logical, extent_len,
2496 extent_physical, extent_dev, flags, 2496 extent_physical, extent_dev, flags,
2497 generation, extent_mirror_num, 2497 generation, extent_mirror_num,
2498 extent_physical); 2498 extent_logical - logical + physical);
2499 if (ret) 2499 if (ret)
2500 goto out; 2500 goto out;
2501 2501
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 998ea111e537..1194b1f0f839 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1780,11 +1780,11 @@ retry:
1780 inode->i_op = &ext3_file_inode_operations; 1780 inode->i_op = &ext3_file_inode_operations;
1781 inode->i_fop = &ext3_file_operations; 1781 inode->i_fop = &ext3_file_operations;
1782 ext3_set_aops(inode); 1782 ext3_set_aops(inode);
1783 d_tmpfile(dentry, inode);
1783 err = ext3_orphan_add(handle, inode); 1784 err = ext3_orphan_add(handle, inode);
1784 if (err) 1785 if (err)
1785 goto err_drop_inode; 1786 goto err_drop_inode;
1786 mark_inode_dirty(inode); 1787 mark_inode_dirty(inode);
1787 d_tmpfile(dentry, inode);
1788 unlock_new_inode(inode); 1788 unlock_new_inode(inode);
1789 } 1789 }
1790 ext3_journal_stop(handle); 1790 ext3_journal_stop(handle);
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 58339393fa6e..ddd715e42a5c 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -38,8 +38,8 @@ ext4_group_t ext4_get_group_number(struct super_block *sb,
38 ext4_group_t group; 38 ext4_group_t group;
39 39
40 if (test_opt2(sb, STD_GROUP_SIZE)) 40 if (test_opt2(sb, STD_GROUP_SIZE))
41 group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + 41 group = (block -
42 block) >> 42 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) >>
43 (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3); 43 (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3);
44 else 44 else
45 ext4_get_group_no_and_offset(sb, block, &group, NULL); 45 ext4_get_group_no_and_offset(sb, block, &group, NULL);
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 7097b0f680e6..a61873808f76 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2835,6 +2835,9 @@ again:
2835 err = -EIO; 2835 err = -EIO;
2836 break; 2836 break;
2837 } 2837 }
2838 /* Yield here to deal with large extent trees.
2839 * Should be a no-op if we did IO above. */
2840 cond_resched();
2838 if (WARN_ON(i + 1 > depth)) { 2841 if (WARN_ON(i + 1 > depth)) {
2839 err = -EIO; 2842 err = -EIO;
2840 break; 2843 break;
@@ -4261,8 +4264,8 @@ got_allocated_blocks:
4261 /* not a good idea to call discard here directly, 4264 /* not a good idea to call discard here directly,
4262 * but otherwise we'd need to call it every free() */ 4265 * but otherwise we'd need to call it every free() */
4263 ext4_discard_preallocations(inode); 4266 ext4_discard_preallocations(inode);
4264 ext4_free_blocks(handle, inode, NULL, ext4_ext_pblock(&newex), 4267 ext4_free_blocks(handle, inode, NULL, newblock,
4265 ext4_ext_get_actual_len(&newex), fb_flags); 4268 EXT4_C2B(sbi, allocated_clusters), fb_flags);
4266 goto out2; 4269 goto out2;
4267 } 4270 }
4268 4271
@@ -4382,8 +4385,9 @@ out2:
4382 } 4385 }
4383 4386
4384out3: 4387out3:
4385 trace_ext4_ext_map_blocks_exit(inode, flags, map, err ? err : allocated); 4388 trace_ext4_ext_map_blocks_exit(inode, flags, map,
4386 4389 err ? err : allocated);
4390 ext4_es_lru_add(inode);
4387 return err ? err : allocated; 4391 return err ? err : allocated;
4388} 4392}
4389 4393
@@ -4405,9 +4409,20 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode)
4405 4409
4406 last_block = (inode->i_size + sb->s_blocksize - 1) 4410 last_block = (inode->i_size + sb->s_blocksize - 1)
4407 >> EXT4_BLOCK_SIZE_BITS(sb); 4411 >> EXT4_BLOCK_SIZE_BITS(sb);
4412retry:
4408 err = ext4_es_remove_extent(inode, last_block, 4413 err = ext4_es_remove_extent(inode, last_block,
4409 EXT_MAX_BLOCKS - last_block); 4414 EXT_MAX_BLOCKS - last_block);
4415 if (err == ENOMEM) {
4416 cond_resched();
4417 congestion_wait(BLK_RW_ASYNC, HZ/50);
4418 goto retry;
4419 }
4420 if (err) {
4421 ext4_std_error(inode->i_sb, err);
4422 return;
4423 }
4410 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1); 4424 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
4425 ext4_std_error(inode->i_sb, err);
4411} 4426}
4412 4427
4413static void ext4_falloc_update_inode(struct inode *inode, 4428static void ext4_falloc_update_inode(struct inode *inode,
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index ee018d5f397e..91cb110da1b4 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -148,6 +148,8 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
148 ext4_lblk_t end); 148 ext4_lblk_t end);
149static int __es_try_to_reclaim_extents(struct ext4_inode_info *ei, 149static int __es_try_to_reclaim_extents(struct ext4_inode_info *ei,
150 int nr_to_scan); 150 int nr_to_scan);
151static int __ext4_es_shrink(struct ext4_sb_info *sbi, int nr_to_scan,
152 struct ext4_inode_info *locked_ei);
151 153
152int __init ext4_init_es(void) 154int __init ext4_init_es(void)
153{ 155{
@@ -439,7 +441,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
439 */ 441 */
440 if (!ext4_es_is_written(es) && !ext4_es_is_unwritten(es)) { 442 if (!ext4_es_is_written(es) && !ext4_es_is_unwritten(es)) {
441 if (in_range(es->es_lblk, ee_block, ee_len)) { 443 if (in_range(es->es_lblk, ee_block, ee_len)) {
442 pr_warn("ES insert assertation failed for " 444 pr_warn("ES insert assertion failed for "
443 "inode: %lu we can find an extent " 445 "inode: %lu we can find an extent "
444 "at block [%d/%d/%llu/%c], but we " 446 "at block [%d/%d/%llu/%c], but we "
445 "want to add an delayed/hole extent " 447 "want to add an delayed/hole extent "
@@ -458,7 +460,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
458 */ 460 */
459 if (es->es_lblk < ee_block || 461 if (es->es_lblk < ee_block ||
460 ext4_es_pblock(es) != ee_start + es->es_lblk - ee_block) { 462 ext4_es_pblock(es) != ee_start + es->es_lblk - ee_block) {
461 pr_warn("ES insert assertation failed for inode: %lu " 463 pr_warn("ES insert assertion failed for inode: %lu "
462 "ex_status [%d/%d/%llu/%c] != " 464 "ex_status [%d/%d/%llu/%c] != "
463 "es_status [%d/%d/%llu/%c]\n", inode->i_ino, 465 "es_status [%d/%d/%llu/%c]\n", inode->i_ino,
464 ee_block, ee_len, ee_start, 466 ee_block, ee_len, ee_start,
@@ -468,7 +470,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
468 } 470 }
469 471
470 if (ee_status ^ es_status) { 472 if (ee_status ^ es_status) {
471 pr_warn("ES insert assertation failed for inode: %lu " 473 pr_warn("ES insert assertion failed for inode: %lu "
472 "ex_status [%d/%d/%llu/%c] != " 474 "ex_status [%d/%d/%llu/%c] != "
473 "es_status [%d/%d/%llu/%c]\n", inode->i_ino, 475 "es_status [%d/%d/%llu/%c]\n", inode->i_ino,
474 ee_block, ee_len, ee_start, 476 ee_block, ee_len, ee_start,
@@ -481,7 +483,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
481 * that we don't want to add an written/unwritten extent. 483 * that we don't want to add an written/unwritten extent.
482 */ 484 */
483 if (!ext4_es_is_delayed(es) && !ext4_es_is_hole(es)) { 485 if (!ext4_es_is_delayed(es) && !ext4_es_is_hole(es)) {
484 pr_warn("ES insert assertation failed for inode: %lu " 486 pr_warn("ES insert assertion failed for inode: %lu "
485 "can't find an extent at block %d but we want " 487 "can't find an extent at block %d but we want "
486 "to add an written/unwritten extent " 488 "to add an written/unwritten extent "
487 "[%d/%d/%llu/%llx]\n", inode->i_ino, 489 "[%d/%d/%llu/%llx]\n", inode->i_ino,
@@ -519,7 +521,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
519 * We want to add a delayed/hole extent but this 521 * We want to add a delayed/hole extent but this
520 * block has been allocated. 522 * block has been allocated.
521 */ 523 */
522 pr_warn("ES insert assertation failed for inode: %lu " 524 pr_warn("ES insert assertion failed for inode: %lu "
523 "We can find blocks but we want to add a " 525 "We can find blocks but we want to add a "
524 "delayed/hole extent [%d/%d/%llu/%llx]\n", 526 "delayed/hole extent [%d/%d/%llu/%llx]\n",
525 inode->i_ino, es->es_lblk, es->es_len, 527 inode->i_ino, es->es_lblk, es->es_len,
@@ -527,13 +529,13 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
527 return; 529 return;
528 } else if (ext4_es_is_written(es)) { 530 } else if (ext4_es_is_written(es)) {
529 if (retval != es->es_len) { 531 if (retval != es->es_len) {
530 pr_warn("ES insert assertation failed for " 532 pr_warn("ES insert assertion failed for "
531 "inode: %lu retval %d != es_len %d\n", 533 "inode: %lu retval %d != es_len %d\n",
532 inode->i_ino, retval, es->es_len); 534 inode->i_ino, retval, es->es_len);
533 return; 535 return;
534 } 536 }
535 if (map.m_pblk != ext4_es_pblock(es)) { 537 if (map.m_pblk != ext4_es_pblock(es)) {
536 pr_warn("ES insert assertation failed for " 538 pr_warn("ES insert assertion failed for "
537 "inode: %lu m_pblk %llu != " 539 "inode: %lu m_pblk %llu != "
538 "es_pblk %llu\n", 540 "es_pblk %llu\n",
539 inode->i_ino, map.m_pblk, 541 inode->i_ino, map.m_pblk,
@@ -549,7 +551,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
549 } 551 }
550 } else if (retval == 0) { 552 } else if (retval == 0) {
551 if (ext4_es_is_written(es)) { 553 if (ext4_es_is_written(es)) {
552 pr_warn("ES insert assertation failed for inode: %lu " 554 pr_warn("ES insert assertion failed for inode: %lu "
553 "We can't find the block but we want to add " 555 "We can't find the block but we want to add "
554 "an written extent [%d/%d/%llu/%llx]\n", 556 "an written extent [%d/%d/%llu/%llx]\n",
555 inode->i_ino, es->es_lblk, es->es_len, 557 inode->i_ino, es->es_lblk, es->es_len,
@@ -632,10 +634,8 @@ out:
632} 634}
633 635
634/* 636/*
635 * ext4_es_insert_extent() adds a space to a extent status tree. 637 * ext4_es_insert_extent() adds information to an inode's extent
636 * 638 * status tree.
637 * ext4_es_insert_extent is called by ext4_da_write_begin and
638 * ext4_es_remove_extent.
639 * 639 *
640 * Return 0 on success, error code on failure. 640 * Return 0 on success, error code on failure.
641 */ 641 */
@@ -667,7 +667,13 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
667 err = __es_remove_extent(inode, lblk, end); 667 err = __es_remove_extent(inode, lblk, end);
668 if (err != 0) 668 if (err != 0)
669 goto error; 669 goto error;
670retry:
670 err = __es_insert_extent(inode, &newes); 671 err = __es_insert_extent(inode, &newes);
672 if (err == -ENOMEM && __ext4_es_shrink(EXT4_SB(inode->i_sb), 1,
673 EXT4_I(inode)))
674 goto retry;
675 if (err == -ENOMEM && !ext4_es_is_delayed(&newes))
676 err = 0;
671 677
672error: 678error:
673 write_unlock(&EXT4_I(inode)->i_es_lock); 679 write_unlock(&EXT4_I(inode)->i_es_lock);
@@ -746,8 +752,10 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
746 struct extent_status orig_es; 752 struct extent_status orig_es;
747 ext4_lblk_t len1, len2; 753 ext4_lblk_t len1, len2;
748 ext4_fsblk_t block; 754 ext4_fsblk_t block;
749 int err = 0; 755 int err;
750 756
757retry:
758 err = 0;
751 es = __es_tree_search(&tree->root, lblk); 759 es = __es_tree_search(&tree->root, lblk);
752 if (!es) 760 if (!es)
753 goto out; 761 goto out;
@@ -782,6 +790,10 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
782 if (err) { 790 if (err) {
783 es->es_lblk = orig_es.es_lblk; 791 es->es_lblk = orig_es.es_lblk;
784 es->es_len = orig_es.es_len; 792 es->es_len = orig_es.es_len;
793 if ((err == -ENOMEM) &&
794 __ext4_es_shrink(EXT4_SB(inode->i_sb), 1,
795 EXT4_I(inode)))
796 goto retry;
785 goto out; 797 goto out;
786 } 798 }
787 } else { 799 } else {
@@ -891,22 +903,14 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a,
891 return -1; 903 return -1;
892} 904}
893 905
894static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc) 906static int __ext4_es_shrink(struct ext4_sb_info *sbi, int nr_to_scan,
907 struct ext4_inode_info *locked_ei)
895{ 908{
896 struct ext4_sb_info *sbi = container_of(shrink,
897 struct ext4_sb_info, s_es_shrinker);
898 struct ext4_inode_info *ei; 909 struct ext4_inode_info *ei;
899 struct list_head *cur, *tmp; 910 struct list_head *cur, *tmp;
900 LIST_HEAD(skiped); 911 LIST_HEAD(skiped);
901 int nr_to_scan = sc->nr_to_scan;
902 int ret, nr_shrunk = 0; 912 int ret, nr_shrunk = 0;
903 913
904 ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt);
905 trace_ext4_es_shrink_enter(sbi->s_sb, nr_to_scan, ret);
906
907 if (!nr_to_scan)
908 return ret;
909
910 spin_lock(&sbi->s_es_lru_lock); 914 spin_lock(&sbi->s_es_lru_lock);
911 915
912 /* 916 /*
@@ -935,7 +939,7 @@ static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
935 continue; 939 continue;
936 } 940 }
937 941
938 if (ei->i_es_lru_nr == 0) 942 if (ei->i_es_lru_nr == 0 || ei == locked_ei)
939 continue; 943 continue;
940 944
941 write_lock(&ei->i_es_lock); 945 write_lock(&ei->i_es_lock);
@@ -954,6 +958,27 @@ static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
954 list_splice_tail(&skiped, &sbi->s_es_lru); 958 list_splice_tail(&skiped, &sbi->s_es_lru);
955 spin_unlock(&sbi->s_es_lru_lock); 959 spin_unlock(&sbi->s_es_lru_lock);
956 960
961 if (locked_ei && nr_shrunk == 0)
962 nr_shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan);
963
964 return nr_shrunk;
965}
966
967static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
968{
969 struct ext4_sb_info *sbi = container_of(shrink,
970 struct ext4_sb_info, s_es_shrinker);
971 int nr_to_scan = sc->nr_to_scan;
972 int ret, nr_shrunk;
973
974 ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt);
975 trace_ext4_es_shrink_enter(sbi->s_sb, nr_to_scan, ret);
976
977 if (!nr_to_scan)
978 return ret;
979
980 nr_shrunk = __ext4_es_shrink(sbi, nr_to_scan, NULL);
981
957 ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt); 982 ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt);
958 trace_ext4_es_shrink_exit(sbi->s_sb, nr_shrunk, ret); 983 trace_ext4_es_shrink_exit(sbi->s_sb, nr_shrunk, ret);
959 return ret; 984 return ret;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0188e65e1f58..ba33c67d6e48 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -465,7 +465,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle,
465 if (es_map->m_lblk != map->m_lblk || 465 if (es_map->m_lblk != map->m_lblk ||
466 es_map->m_flags != map->m_flags || 466 es_map->m_flags != map->m_flags ||
467 es_map->m_pblk != map->m_pblk) { 467 es_map->m_pblk != map->m_pblk) {
468 printk("ES cache assertation failed for inode: %lu " 468 printk("ES cache assertion failed for inode: %lu "
469 "es_cached ex [%d/%d/%llu/%x] != " 469 "es_cached ex [%d/%d/%llu/%x] != "
470 "found ex [%d/%d/%llu/%x] retval %d flags %x\n", 470 "found ex [%d/%d/%llu/%x] retval %d flags %x\n",
471 inode->i_ino, es_map->m_lblk, es_map->m_len, 471 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,
514 "logical block %lu\n", inode->i_ino, flags, map->m_len, 514 "logical block %lu\n", inode->i_ino, flags, map->m_len,
515 (unsigned long) map->m_lblk); 515 (unsigned long) map->m_lblk);
516 516
517 ext4_es_lru_add(inode);
518
519 /* Lookup extent status tree firstly */ 517 /* Lookup extent status tree firstly */
520 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { 518 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
519 ext4_es_lru_add(inode);
521 if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) { 520 if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) {
522 map->m_pblk = ext4_es_pblock(&es) + 521 map->m_pblk = ext4_es_pblock(&es) +
523 map->m_lblk - es.es_lblk; 522 map->m_lblk - es.es_lblk;
@@ -558,7 +557,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
558 557
559#ifdef ES_AGGRESSIVE_TEST 558#ifdef ES_AGGRESSIVE_TEST
560 if (retval != map->m_len) { 559 if (retval != map->m_len) {
561 printk("ES len assertation failed for inode: %lu " 560 printk("ES len assertion failed for inode: %lu "
562 "retval %d != map->m_len %d " 561 "retval %d != map->m_len %d "
563 "in %s (lookup)\n", inode->i_ino, retval, 562 "in %s (lookup)\n", inode->i_ino, retval,
564 map->m_len, __func__); 563 map->m_len, __func__);
@@ -659,7 +658,7 @@ found:
659 658
660#ifdef ES_AGGRESSIVE_TEST 659#ifdef ES_AGGRESSIVE_TEST
661 if (retval != map->m_len) { 660 if (retval != map->m_len) {
662 printk("ES len assertation failed for inode: %lu " 661 printk("ES len assertion failed for inode: %lu "
663 "retval %d != map->m_len %d " 662 "retval %d != map->m_len %d "
664 "in %s (allocation)\n", inode->i_ino, retval, 663 "in %s (allocation)\n", inode->i_ino, retval,
665 map->m_len, __func__); 664 map->m_len, __func__);
@@ -1529,11 +1528,9 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
1529 "logical block %lu\n", inode->i_ino, map->m_len, 1528 "logical block %lu\n", inode->i_ino, map->m_len,
1530 (unsigned long) map->m_lblk); 1529 (unsigned long) map->m_lblk);
1531 1530
1532 ext4_es_lru_add(inode);
1533
1534 /* Lookup extent status tree firstly */ 1531 /* Lookup extent status tree firstly */
1535 if (ext4_es_lookup_extent(inode, iblock, &es)) { 1532 if (ext4_es_lookup_extent(inode, iblock, &es)) {
1536 1533 ext4_es_lru_add(inode);
1537 if (ext4_es_is_hole(&es)) { 1534 if (ext4_es_is_hole(&es)) {
1538 retval = 0; 1535 retval = 0;
1539 down_read((&EXT4_I(inode)->i_data_sem)); 1536 down_read((&EXT4_I(inode)->i_data_sem));
@@ -1642,7 +1639,7 @@ add_delayed:
1642 1639
1643#ifdef ES_AGGRESSIVE_TEST 1640#ifdef ES_AGGRESSIVE_TEST
1644 if (retval != map->m_len) { 1641 if (retval != map->m_len) {
1645 printk("ES len assertation failed for inode: %lu " 1642 printk("ES len assertion failed for inode: %lu "
1646 "retval %d != map->m_len %d " 1643 "retval %d != map->m_len %d "
1647 "in %s (lookup)\n", inode->i_ino, retval, 1644 "in %s (lookup)\n", inode->i_ino, retval,
1648 map->m_len, __func__); 1645 map->m_len, __func__);
@@ -2163,7 +2160,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2163 2160
2164 mpd->io_submit.io_end->offset = 2161 mpd->io_submit.io_end->offset =
2165 ((loff_t)map->m_lblk) << inode->i_blkbits; 2162 ((loff_t)map->m_lblk) << inode->i_blkbits;
2166 while (map->m_len) { 2163 do {
2167 err = mpage_map_one_extent(handle, mpd); 2164 err = mpage_map_one_extent(handle, mpd);
2168 if (err < 0) { 2165 if (err < 0) {
2169 struct super_block *sb = inode->i_sb; 2166 struct super_block *sb = inode->i_sb;
@@ -2201,7 +2198,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2201 err = mpage_map_and_submit_buffers(mpd); 2198 err = mpage_map_and_submit_buffers(mpd);
2202 if (err < 0) 2199 if (err < 0)
2203 return err; 2200 return err;
2204 } 2201 } while (map->m_len);
2205 2202
2206 /* Update on-disk size after IO is submitted */ 2203 /* Update on-disk size after IO is submitted */
2207 disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT; 2204 disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a9ff5e5137ca..4bbbf13bd743 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4740,11 +4740,16 @@ do_more:
4740 * blocks being freed are metadata. these blocks shouldn't 4740 * blocks being freed are metadata. these blocks shouldn't
4741 * be used until this transaction is committed 4741 * be used until this transaction is committed
4742 */ 4742 */
4743 retry:
4743 new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS); 4744 new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS);
4744 if (!new_entry) { 4745 if (!new_entry) {
4745 ext4_mb_unload_buddy(&e4b); 4746 /*
4746 err = -ENOMEM; 4747 * We use a retry loop because
4747 goto error_return; 4748 * ext4_free_blocks() is not allowed to fail.
4749 */
4750 cond_resched();
4751 congestion_wait(BLK_RW_ASYNC, HZ/50);
4752 goto retry;
4748 } 4753 }
4749 new_entry->efd_start_cluster = bit; 4754 new_entry->efd_start_cluster = bit;
4750 new_entry->efd_group = block_group; 4755 new_entry->efd_group = block_group;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 234b834d5a97..35f55a0dbc4b 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2316,11 +2316,11 @@ retry:
2316 inode->i_op = &ext4_file_inode_operations; 2316 inode->i_op = &ext4_file_inode_operations;
2317 inode->i_fop = &ext4_file_operations; 2317 inode->i_fop = &ext4_file_operations;
2318 ext4_set_aops(inode); 2318 ext4_set_aops(inode);
2319 d_tmpfile(dentry, inode);
2319 err = ext4_orphan_add(handle, inode); 2320 err = ext4_orphan_add(handle, inode);
2320 if (err) 2321 if (err)
2321 goto err_drop_inode; 2322 goto err_drop_inode;
2322 mark_inode_dirty(inode); 2323 mark_inode_dirty(inode);
2323 d_tmpfile(dentry, inode);
2324 unlock_new_inode(inode); 2324 unlock_new_inode(inode);
2325 } 2325 }
2326 if (handle) 2326 if (handle)
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 48786cdb5e6c..6625d210fb45 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -25,6 +25,7 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/ratelimit.h>
28 29
29#include "ext4_jbd2.h" 30#include "ext4_jbd2.h"
30#include "xattr.h" 31#include "xattr.h"
@@ -55,7 +56,7 @@ void ext4_exit_pageio(void)
55static void buffer_io_error(struct buffer_head *bh) 56static void buffer_io_error(struct buffer_head *bh)
56{ 57{
57 char b[BDEVNAME_SIZE]; 58 char b[BDEVNAME_SIZE];
58 printk(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n", 59 printk_ratelimited(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n",
59 bdevname(bh->b_bdev, b), 60 bdevname(bh->b_bdev, b),
60 (unsigned long long)bh->b_blocknr); 61 (unsigned long long)bh->b_blocknr);
61} 62}
@@ -308,6 +309,7 @@ ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end)
308 return io_end; 309 return io_end;
309} 310}
310 311
312/* BIO completion function for page writeback */
311static void ext4_end_bio(struct bio *bio, int error) 313static void ext4_end_bio(struct bio *bio, int error)
312{ 314{
313 ext4_io_end_t *io_end = bio->bi_private; 315 ext4_io_end_t *io_end = bio->bi_private;
@@ -318,18 +320,6 @@ static void ext4_end_bio(struct bio *bio, int error)
318 if (test_bit(BIO_UPTODATE, &bio->bi_flags)) 320 if (test_bit(BIO_UPTODATE, &bio->bi_flags))
319 error = 0; 321 error = 0;
320 322
321 if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
322 /*
323 * Link bio into list hanging from io_end. We have to do it
324 * atomically as bio completions can be racing against each
325 * other.
326 */
327 bio->bi_private = xchg(&io_end->bio, bio);
328 } else {
329 ext4_finish_bio(bio);
330 bio_put(bio);
331 }
332
333 if (error) { 323 if (error) {
334 struct inode *inode = io_end->inode; 324 struct inode *inode = io_end->inode;
335 325
@@ -341,7 +331,24 @@ static void ext4_end_bio(struct bio *bio, int error)
341 (unsigned long long) 331 (unsigned long long)
342 bi_sector >> (inode->i_blkbits - 9)); 332 bi_sector >> (inode->i_blkbits - 9));
343 } 333 }
344 ext4_put_io_end_defer(io_end); 334
335 if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
336 /*
337 * Link bio into list hanging from io_end. We have to do it
338 * atomically as bio completions can be racing against each
339 * other.
340 */
341 bio->bi_private = xchg(&io_end->bio, bio);
342 ext4_put_io_end_defer(io_end);
343 } else {
344 /*
345 * Drop io_end reference early. Inode can get freed once
346 * we finish the bio.
347 */
348 ext4_put_io_end_defer(io_end);
349 ext4_finish_bio(bio);
350 bio_put(bio);
351 }
345} 352}
346 353
347void ext4_io_submit(struct ext4_io_submit *io) 354void ext4_io_submit(struct ext4_io_submit *io)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 85b3dd60169b..bca26f34edf4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1702,12 +1702,6 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
1702 1702
1703 if (sbi->s_qf_names[GRPQUOTA]) 1703 if (sbi->s_qf_names[GRPQUOTA])
1704 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); 1704 seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
1705
1706 if (test_opt(sb, USRQUOTA))
1707 seq_puts(seq, ",usrquota");
1708
1709 if (test_opt(sb, GRPQUOTA))
1710 seq_puts(seq, ",grpquota");
1711#endif 1705#endif
1712} 1706}
1713 1707
@@ -3624,10 +3618,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3624 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); 3618 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
3625 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); 3619 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
3626 3620
3627 /* Do we have standard group size of blocksize * 8 blocks ? */
3628 if (sbi->s_blocks_per_group == blocksize << 3)
3629 set_opt2(sb, STD_GROUP_SIZE);
3630
3631 for (i = 0; i < 4; i++) 3621 for (i = 0; i < 4; i++)
3632 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 3622 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
3633 sbi->s_def_hash_version = es->s_def_hash_version; 3623 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)
3697 goto failed_mount; 3687 goto failed_mount;
3698 } 3688 }
3699 3689
3690 /* Do we have standard group size of clustersize * 8 blocks ? */
3691 if (sbi->s_blocks_per_group == clustersize << 3)
3692 set_opt2(sb, STD_GROUP_SIZE);
3693
3700 /* 3694 /*
3701 * Test whether we have more sectors than will fit in sector_t, 3695 * Test whether we have more sectors than will fit in sector_t,
3702 * and whether the max offset is addressable by the page cache. 3696 * and whether the max offset is addressable by the page cache.
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0eda52738ec4..72a5d5b04494 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1223,30 +1223,46 @@ static int fuse_direntplus_link(struct file *file,
1223 if (name.name[1] == '.' && name.len == 2) 1223 if (name.name[1] == '.' && name.len == 2)
1224 return 0; 1224 return 0;
1225 } 1225 }
1226
1227 if (invalid_nodeid(o->nodeid))
1228 return -EIO;
1229 if (!fuse_valid_type(o->attr.mode))
1230 return -EIO;
1231
1226 fc = get_fuse_conn(dir); 1232 fc = get_fuse_conn(dir);
1227 1233
1228 name.hash = full_name_hash(name.name, name.len); 1234 name.hash = full_name_hash(name.name, name.len);
1229 dentry = d_lookup(parent, &name); 1235 dentry = d_lookup(parent, &name);
1230 if (dentry && dentry->d_inode) { 1236 if (dentry) {
1231 inode = dentry->d_inode; 1237 inode = dentry->d_inode;
1232 if (get_node_id(inode) == o->nodeid) { 1238 if (!inode) {
1239 d_drop(dentry);
1240 } else if (get_node_id(inode) != o->nodeid ||
1241 ((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
1242 err = d_invalidate(dentry);
1243 if (err)
1244 goto out;
1245 } else if (is_bad_inode(inode)) {
1246 err = -EIO;
1247 goto out;
1248 } else {
1233 struct fuse_inode *fi; 1249 struct fuse_inode *fi;
1234 fi = get_fuse_inode(inode); 1250 fi = get_fuse_inode(inode);
1235 spin_lock(&fc->lock); 1251 spin_lock(&fc->lock);
1236 fi->nlookup++; 1252 fi->nlookup++;
1237 spin_unlock(&fc->lock); 1253 spin_unlock(&fc->lock);
1238 1254
1255 fuse_change_attributes(inode, &o->attr,
1256 entry_attr_timeout(o),
1257 attr_version);
1258
1239 /* 1259 /*
1240 * The other branch to 'found' comes via fuse_iget() 1260 * The other branch to 'found' comes via fuse_iget()
1241 * which bumps nlookup inside 1261 * which bumps nlookup inside
1242 */ 1262 */
1243 goto found; 1263 goto found;
1244 } 1264 }
1245 err = d_invalidate(dentry);
1246 if (err)
1247 goto out;
1248 dput(dentry); 1265 dput(dentry);
1249 dentry = NULL;
1250 } 1266 }
1251 1267
1252 dentry = d_alloc(parent, &name); 1268 dentry = d_alloc(parent, &name);
@@ -1259,25 +1275,30 @@ static int fuse_direntplus_link(struct file *file,
1259 if (!inode) 1275 if (!inode)
1260 goto out; 1276 goto out;
1261 1277
1262 alias = d_materialise_unique(dentry, inode); 1278 if (S_ISDIR(inode->i_mode)) {
1263 err = PTR_ERR(alias); 1279 mutex_lock(&fc->inst_mutex);
1264 if (IS_ERR(alias)) 1280 alias = fuse_d_add_directory(dentry, inode);
1265 goto out; 1281 mutex_unlock(&fc->inst_mutex);
1282 err = PTR_ERR(alias);
1283 if (IS_ERR(alias)) {
1284 iput(inode);
1285 goto out;
1286 }
1287 } else {
1288 alias = d_splice_alias(inode, dentry);
1289 }
1290
1266 if (alias) { 1291 if (alias) {
1267 dput(dentry); 1292 dput(dentry);
1268 dentry = alias; 1293 dentry = alias;
1269 } 1294 }
1270 1295
1271found: 1296found:
1272 fuse_change_attributes(inode, &o->attr, entry_attr_timeout(o),
1273 attr_version);
1274
1275 fuse_change_entry_timeout(dentry, o); 1297 fuse_change_entry_timeout(dentry, o);
1276 1298
1277 err = 0; 1299 err = 0;
1278out: 1300out:
1279 if (dentry) 1301 dput(dentry);
1280 dput(dentry);
1281 return err; 1302 return err;
1282} 1303}
1283 1304
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 067778b0ccc9..e066a3902973 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -951,6 +951,7 @@ nlmsvc_retry_blocked(void)
951 unsigned long timeout = MAX_SCHEDULE_TIMEOUT; 951 unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
952 struct nlm_block *block; 952 struct nlm_block *block;
953 953
954 spin_lock(&nlm_blocked_lock);
954 while (!list_empty(&nlm_blocked) && !kthread_should_stop()) { 955 while (!list_empty(&nlm_blocked) && !kthread_should_stop()) {
955 block = list_entry(nlm_blocked.next, struct nlm_block, b_list); 956 block = list_entry(nlm_blocked.next, struct nlm_block, b_list);
956 957
@@ -960,6 +961,7 @@ nlmsvc_retry_blocked(void)
960 timeout = block->b_when - jiffies; 961 timeout = block->b_when - jiffies;
961 break; 962 break;
962 } 963 }
964 spin_unlock(&nlm_blocked_lock);
963 965
964 dprintk("nlmsvc_retry_blocked(%p, when=%ld)\n", 966 dprintk("nlmsvc_retry_blocked(%p, when=%ld)\n",
965 block, block->b_when); 967 block, block->b_when);
@@ -969,7 +971,9 @@ nlmsvc_retry_blocked(void)
969 retry_deferred_block(block); 971 retry_deferred_block(block);
970 } else 972 } else
971 nlmsvc_grant_blocked(block); 973 nlmsvc_grant_blocked(block);
974 spin_lock(&nlm_blocked_lock);
972 } 975 }
976 spin_unlock(&nlm_blocked_lock);
973 977
974 return timeout; 978 return timeout;
975} 979}
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 0abfb8466e79..3850b018815f 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -999,6 +999,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
999 __be32 *p; 999 __be32 *p;
1000 __be32 *q; 1000 __be32 *q;
1001 int len; 1001 int len;
1002 uint32_t bmval_len = 2;
1002 uint32_t bmval0 = 0; 1003 uint32_t bmval0 = 0;
1003 uint32_t bmval1 = 0; 1004 uint32_t bmval1 = 0;
1004 uint32_t bmval2 = 0; 1005 uint32_t bmval2 = 0;
@@ -1010,7 +1011,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1010 * = 40 bytes, plus any contribution from variable-length fields 1011 * = 40 bytes, plus any contribution from variable-length fields
1011 * such as owner/group. 1012 * such as owner/group.
1012 */ 1013 */
1013 len = 20; 1014 len = 8;
1014 1015
1015 /* Sigh */ 1016 /* Sigh */
1016 if (iap->ia_valid & ATTR_SIZE) 1017 if (iap->ia_valid & ATTR_SIZE)
@@ -1040,8 +1041,6 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1040 } 1041 }
1041 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); 1042 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
1042 } 1043 }
1043 if (label)
1044 len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
1045 if (iap->ia_valid & ATTR_ATIME_SET) 1044 if (iap->ia_valid & ATTR_ATIME_SET)
1046 len += 16; 1045 len += 16;
1047 else if (iap->ia_valid & ATTR_ATIME) 1046 else if (iap->ia_valid & ATTR_ATIME)
@@ -1050,15 +1049,22 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1050 len += 16; 1049 len += 16;
1051 else if (iap->ia_valid & ATTR_MTIME) 1050 else if (iap->ia_valid & ATTR_MTIME)
1052 len += 4; 1051 len += 4;
1052 if (label) {
1053 len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
1054 bmval_len = 3;
1055 }
1056
1057 len += bmval_len << 2;
1053 p = reserve_space(xdr, len); 1058 p = reserve_space(xdr, len);
1054 1059
1055 /* 1060 /*
1056 * We write the bitmap length now, but leave the bitmap and the attribute 1061 * We write the bitmap length now, but leave the bitmap and the attribute
1057 * buffer length to be backfilled at the end of this routine. 1062 * buffer length to be backfilled at the end of this routine.
1058 */ 1063 */
1059 *p++ = cpu_to_be32(3); 1064 *p++ = cpu_to_be32(bmval_len);
1060 q = p; 1065 q = p;
1061 p += 4; 1066 /* Skip bitmap entries + attrlen */
1067 p += bmval_len + 1;
1062 1068
1063 if (iap->ia_valid & ATTR_SIZE) { 1069 if (iap->ia_valid & ATTR_SIZE) {
1064 bmval0 |= FATTR4_WORD0_SIZE; 1070 bmval0 |= FATTR4_WORD0_SIZE;
@@ -1112,10 +1118,11 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
1112 len, ((char *)p - (char *)q) + 4); 1118 len, ((char *)p - (char *)q) + 4);
1113 BUG(); 1119 BUG();
1114 } 1120 }
1115 len = (char *)p - (char *)q - 16;
1116 *q++ = htonl(bmval0); 1121 *q++ = htonl(bmval0);
1117 *q++ = htonl(bmval1); 1122 *q++ = htonl(bmval1);
1118 *q++ = htonl(bmval2); 1123 if (bmval_len == 3)
1124 *q++ = htonl(bmval2);
1125 len = (char *)p - (char *)(q + 1);
1119 *q = htonl(len); 1126 *q = htonl(len);
1120 1127
1121/* out: */ 1128/* out: */
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index a7cee864e7b2..0d4c410e4589 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1293,7 +1293,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
1293 * According to RFC3010, this takes precedence over all other errors. 1293 * According to RFC3010, this takes precedence over all other errors.
1294 */ 1294 */
1295 status = nfserr_minor_vers_mismatch; 1295 status = nfserr_minor_vers_mismatch;
1296 if (args->minorversion > nfsd_supported_minorversion) 1296 if (nfsd_minorversion(args->minorversion, NFSD_TEST) <= 0)
1297 goto out; 1297 goto out;
1298 1298
1299 status = nfs41_check_op_ordering(args); 1299 status = nfs41_check_op_ordering(args);
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 2bbd94e51efc..30f34ab02137 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -53,7 +53,6 @@ struct readdir_cd {
53extern struct svc_program nfsd_program; 53extern struct svc_program nfsd_program;
54extern struct svc_version nfsd_version2, nfsd_version3, 54extern struct svc_version nfsd_version2, nfsd_version3,
55 nfsd_version4; 55 nfsd_version4;
56extern u32 nfsd_supported_minorversion;
57extern struct mutex nfsd_mutex; 56extern struct mutex nfsd_mutex;
58extern spinlock_t nfsd_drc_lock; 57extern spinlock_t nfsd_drc_lock;
59extern unsigned long nfsd_drc_max_mem; 58extern unsigned long nfsd_drc_max_mem;
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 6b9f48ca4c25..760c85a6f534 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -116,7 +116,10 @@ struct svc_program nfsd_program = {
116 116
117}; 117};
118 118
119u32 nfsd_supported_minorversion = 1; 119static bool nfsd_supported_minorversions[NFSD_SUPPORTED_MINOR_VERSION + 1] = {
120 [0] = 1,
121 [1] = 1,
122};
120 123
121int nfsd_vers(int vers, enum vers_op change) 124int nfsd_vers(int vers, enum vers_op change)
122{ 125{
@@ -151,15 +154,13 @@ int nfsd_minorversion(u32 minorversion, enum vers_op change)
151 return -1; 154 return -1;
152 switch(change) { 155 switch(change) {
153 case NFSD_SET: 156 case NFSD_SET:
154 nfsd_supported_minorversion = minorversion; 157 nfsd_supported_minorversions[minorversion] = true;
155 break; 158 break;
156 case NFSD_CLEAR: 159 case NFSD_CLEAR:
157 if (minorversion == 0) 160 nfsd_supported_minorversions[minorversion] = false;
158 return -1;
159 nfsd_supported_minorversion = minorversion - 1;
160 break; 161 break;
161 case NFSD_TEST: 162 case NFSD_TEST:
162 return minorversion <= nfsd_supported_minorversion; 163 return nfsd_supported_minorversions[minorversion];
163 case NFSD_AVAIL: 164 case NFSD_AVAIL:
164 return minorversion <= NFSD_SUPPORTED_MINOR_VERSION; 165 return minorversion <= NFSD_SUPPORTED_MINOR_VERSION;
165 } 166 }
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 8ff6a0019b0b..c827acb0e943 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -830,9 +830,10 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
830 flags = O_WRONLY|O_LARGEFILE; 830 flags = O_WRONLY|O_LARGEFILE;
831 } 831 }
832 *filp = dentry_open(&path, flags, current_cred()); 832 *filp = dentry_open(&path, flags, current_cred());
833 if (IS_ERR(*filp)) 833 if (IS_ERR(*filp)) {
834 host_err = PTR_ERR(*filp); 834 host_err = PTR_ERR(*filp);
835 else { 835 *filp = NULL;
836 } else {
836 host_err = ima_file_check(*filp, may_flags); 837 host_err = ima_file_check(*filp, may_flags);
837 838
838 if (may_flags & NFSD_MAY_64BIT_COOKIE) 839 if (may_flags & NFSD_MAY_64BIT_COOKIE)
diff --git a/fs/open.c b/fs/open.c
index 9156cb050d08..d53e29895082 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -844,6 +844,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
844 if ((flags & O_TMPFILE_MASK) != O_TMPFILE) 844 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
845 return -EINVAL; 845 return -EINVAL;
846 acc_mode = MAY_OPEN | ACC_MODE(flags); 846 acc_mode = MAY_OPEN | ACC_MODE(flags);
847 if (!(acc_mode & MAY_WRITE))
848 return -EINVAL;
847 } else if (flags & O_PATH) { 849 } else if (flags & O_PATH) {
848 /* 850 /*
849 * If we have O_PATH in the open flag. Then we 851 * If we have O_PATH in the open flag. Then we
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 28503172f2e4..a1a16eb97c7b 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -223,7 +223,7 @@ static inline char *alloc_elfnotes_buf(size_t notes_sz)
223 * regions in the 1st kernel pointed to by PT_LOAD entries) into 223 * regions in the 1st kernel pointed to by PT_LOAD entries) into
224 * virtually contiguous user-space in ELF layout. 224 * virtually contiguous user-space in ELF layout.
225 */ 225 */
226#ifdef CONFIG_MMU 226#if defined(CONFIG_MMU) && !defined(CONFIG_S390)
227static int mmap_vmcore(struct file *file, struct vm_area_struct *vma) 227static int mmap_vmcore(struct file *file, struct vm_area_struct *vma)
228{ 228{
229 size_t size = vma->vm_end - vma->vm_start; 229 size_t size = vma->vm_end - vma->vm_start;
diff --git a/fs/super.c b/fs/super.c
index 7465d4364208..68307c029228 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -336,19 +336,19 @@ EXPORT_SYMBOL(deactivate_super);
336 * and want to turn it into a full-blown active reference. grab_super() 336 * and want to turn it into a full-blown active reference. grab_super()
337 * is called with sb_lock held and drops it. Returns 1 in case of 337 * is called with sb_lock held and drops it. Returns 1 in case of
338 * success, 0 if we had failed (superblock contents was already dead or 338 * success, 0 if we had failed (superblock contents was already dead or
339 * dying when grab_super() had been called). 339 * dying when grab_super() had been called). Note that this is only
340 * called for superblocks not in rundown mode (== ones still on ->fs_supers
341 * of their type), so increment of ->s_count is OK here.
340 */ 342 */
341static int grab_super(struct super_block *s) __releases(sb_lock) 343static int grab_super(struct super_block *s) __releases(sb_lock)
342{ 344{
343 if (atomic_inc_not_zero(&s->s_active)) {
344 spin_unlock(&sb_lock);
345 return 1;
346 }
347 /* it's going away */
348 s->s_count++; 345 s->s_count++;
349 spin_unlock(&sb_lock); 346 spin_unlock(&sb_lock);
350 /* wait for it to die */
351 down_write(&s->s_umount); 347 down_write(&s->s_umount);
348 if ((s->s_flags & MS_BORN) && atomic_inc_not_zero(&s->s_active)) {
349 put_super(s);
350 return 1;
351 }
352 up_write(&s->s_umount); 352 up_write(&s->s_umount);
353 put_super(s); 353 put_super(s);
354 return 0; 354 return 0;
@@ -463,11 +463,6 @@ retry:
463 destroy_super(s); 463 destroy_super(s);
464 s = NULL; 464 s = NULL;
465 } 465 }
466 down_write(&old->s_umount);
467 if (unlikely(!(old->s_flags & MS_BORN))) {
468 deactivate_locked_super(old);
469 goto retry;
470 }
471 return old; 466 return old;
472 } 467 }
473 } 468 }
@@ -660,10 +655,10 @@ restart:
660 if (hlist_unhashed(&sb->s_instances)) 655 if (hlist_unhashed(&sb->s_instances))
661 continue; 656 continue;
662 if (sb->s_bdev == bdev) { 657 if (sb->s_bdev == bdev) {
663 if (grab_super(sb)) /* drops sb_lock */ 658 if (!grab_super(sb))
664 return sb;
665 else
666 goto restart; 659 goto restart;
660 up_write(&sb->s_umount);
661 return sb;
667 } 662 }
668 } 663 }
669 spin_unlock(&sb_lock); 664 spin_unlock(&sb_lock);
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index aec3d5c98c94..09a1a25cd145 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -20,38 +20,64 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
20 const struct attribute_group *grp) 20 const struct attribute_group *grp)
21{ 21{
22 struct attribute *const* attr; 22 struct attribute *const* attr;
23 int i; 23 struct bin_attribute *const* bin_attr;
24 24
25 for (i = 0, attr = grp->attrs; *attr; i++, attr++) 25 if (grp->attrs)
26 sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); 26 for (attr = grp->attrs; *attr; attr++)
27 sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
28 if (grp->bin_attrs)
29 for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++)
30 sysfs_remove_bin_file(kobj, *bin_attr);
27} 31}
28 32
29static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, 33static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
30 const struct attribute_group *grp, int update) 34 const struct attribute_group *grp, int update)
31{ 35{
32 struct attribute *const* attr; 36 struct attribute *const* attr;
37 struct bin_attribute *const* bin_attr;
33 int error = 0, i; 38 int error = 0, i;
34 39
35 for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { 40 if (grp->attrs) {
36 umode_t mode = 0; 41 for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) {
42 umode_t mode = 0;
43
44 /*
45 * In update mode, we're changing the permissions or
46 * visibility. Do this by first removing then
47 * re-adding (if required) the file.
48 */
49 if (update)
50 sysfs_hash_and_remove(dir_sd, NULL,
51 (*attr)->name);
52 if (grp->is_visible) {
53 mode = grp->is_visible(kobj, *attr, i);
54 if (!mode)
55 continue;
56 }
57 error = sysfs_add_file_mode(dir_sd, *attr,
58 SYSFS_KOBJ_ATTR,
59 (*attr)->mode | mode);
60 if (unlikely(error))
61 break;
62 }
63 if (error) {
64 remove_files(dir_sd, kobj, grp);
65 goto exit;
66 }
67 }
37 68
38 /* in update mode, we're changing the permissions or 69 if (grp->bin_attrs) {
39 * visibility. Do this by first removing then 70 for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
40 * re-adding (if required) the file */ 71 if (update)
41 if (update) 72 sysfs_remove_bin_file(kobj, *bin_attr);
42 sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); 73 error = sysfs_create_bin_file(kobj, *bin_attr);
43 if (grp->is_visible) { 74 if (error)
44 mode = grp->is_visible(kobj, *attr, i); 75 break;
45 if (!mode)
46 continue;
47 } 76 }
48 error = sysfs_add_file_mode(dir_sd, *attr, SYSFS_KOBJ_ATTR, 77 if (error)
49 (*attr)->mode | mode); 78 remove_files(dir_sd, kobj, grp);
50 if (unlikely(error))
51 break;
52 } 79 }
53 if (error) 80exit:
54 remove_files(dir_sd, kobj, grp);
55 return error; 81 return error;
56} 82}
57 83
@@ -67,8 +93,8 @@ static int internal_create_group(struct kobject *kobj, int update,
67 /* Updates may happen before the object has been instantiated */ 93 /* Updates may happen before the object has been instantiated */
68 if (unlikely(update && !kobj->sd)) 94 if (unlikely(update && !kobj->sd))
69 return -EINVAL; 95 return -EINVAL;
70 if (!grp->attrs) { 96 if (!grp->attrs && !grp->bin_attrs) {
71 WARN(1, "sysfs: attrs not set by subsystem for group: %s/%s\n", 97 WARN(1, "sysfs: (bin_)attrs not set by subsystem for group: %s/%s\n",
72 kobj->name, grp->name ? "" : grp->name); 98 kobj->name, grp->name ? "" : grp->name);
73 return -EINVAL; 99 return -EINVAL;
74 } 100 }
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h
index 07d735a80a0f..e5869b50dc41 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/xfs_dinode.h
@@ -39,6 +39,9 @@ typedef struct xfs_timestamp {
39 * There is a very similar struct icdinode in xfs_inode which matches the 39 * There is a very similar struct icdinode in xfs_inode which matches the
40 * layout of the first 96 bytes of this structure, but is kept in native 40 * layout of the first 96 bytes of this structure, but is kept in native
41 * format instead of big endian. 41 * format instead of big endian.
42 *
43 * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed
44 * padding field for v3 inodes.
42 */ 45 */
43typedef struct xfs_dinode { 46typedef struct xfs_dinode {
44 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 47 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b78481f99d9d..bb262c25c8de 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -896,7 +896,6 @@ xfs_dinode_to_disk(
896 to->di_projid_lo = cpu_to_be16(from->di_projid_lo); 896 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
897 to->di_projid_hi = cpu_to_be16(from->di_projid_hi); 897 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
898 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); 898 memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
899 to->di_flushiter = cpu_to_be16(from->di_flushiter);
900 to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec); 899 to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec);
901 to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec); 900 to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec);
902 to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec); 901 to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec);
@@ -924,6 +923,9 @@ xfs_dinode_to_disk(
924 to->di_lsn = cpu_to_be64(from->di_lsn); 923 to->di_lsn = cpu_to_be64(from->di_lsn);
925 memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2)); 924 memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2));
926 uuid_copy(&to->di_uuid, &from->di_uuid); 925 uuid_copy(&to->di_uuid, &from->di_uuid);
926 to->di_flushiter = 0;
927 } else {
928 to->di_flushiter = cpu_to_be16(from->di_flushiter);
927 } 929 }
928} 930}
929 931
@@ -1029,10 +1031,14 @@ xfs_dinode_calc_crc(
1029/* 1031/*
1030 * Read the disk inode attributes into the in-core inode structure. 1032 * Read the disk inode attributes into the in-core inode structure.
1031 * 1033 *
1032 * If we are initialising a new inode and we are not utilising the 1034 * For version 5 superblocks, if we are initialising a new inode and we are not
1033 * XFS_MOUNT_IKEEP inode cluster mode, we can simple build the new inode core 1035 * utilising the XFS_MOUNT_IKEEP inode cluster mode, we can simple build the new
1034 * with a random generation number. If we are keeping inodes around, we need to 1036 * inode core with a random generation number. If we are keeping inodes around,
1035 * read the inode cluster to get the existing generation number off disk. 1037 * we need to read the inode cluster to get the existing generation number off
1038 * disk. Further, if we are using version 4 superblocks (i.e. v1/v2 inode
1039 * format) then log recovery is dependent on the di_flushiter field being
1040 * initialised from the current on-disk value and hence we must also read the
1041 * inode off disk.
1036 */ 1042 */
1037int 1043int
1038xfs_iread( 1044xfs_iread(
@@ -1054,6 +1060,7 @@ xfs_iread(
1054 1060
1055 /* shortcut IO on inode allocation if possible */ 1061 /* shortcut IO on inode allocation if possible */
1056 if ((iget_flags & XFS_IGET_CREATE) && 1062 if ((iget_flags & XFS_IGET_CREATE) &&
1063 xfs_sb_version_hascrc(&mp->m_sb) &&
1057 !(mp->m_flags & XFS_MOUNT_IKEEP)) { 1064 !(mp->m_flags & XFS_MOUNT_IKEEP)) {
1058 /* initialise the on-disk inode core */ 1065 /* initialise the on-disk inode core */
1059 memset(&ip->i_d, 0, sizeof(ip->i_d)); 1066 memset(&ip->i_d, 0, sizeof(ip->i_d));
@@ -2882,12 +2889,18 @@ xfs_iflush_int(
2882 __func__, ip->i_ino, ip->i_d.di_forkoff, ip); 2889 __func__, ip->i_ino, ip->i_d.di_forkoff, ip);
2883 goto corrupt_out; 2890 goto corrupt_out;
2884 } 2891 }
2892
2885 /* 2893 /*
2886 * bump the flush iteration count, used to detect flushes which 2894 * Inode item log recovery for v1/v2 inodes are dependent on the
2887 * postdate a log record during recovery. This is redundant as we now 2895 * di_flushiter count for correct sequencing. We bump the flush
2888 * log every change and hence this can't happen. Still, it doesn't hurt. 2896 * iteration count so we can detect flushes which postdate a log record
2897 * during recovery. This is redundant as we now log every change and
2898 * hence this can't happen but we need to still do it to ensure
2899 * backwards compatibility with old kernels that predate logging all
2900 * inode changes.
2889 */ 2901 */
2890 ip->i_d.di_flushiter++; 2902 if (ip->i_d.di_version < 3)
2903 ip->i_d.di_flushiter++;
2891 2904
2892 /* 2905 /*
2893 * Copy the dirty parts of the inode into the on-disk 2906 * Copy the dirty parts of the inode into the on-disk
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 6fcc910a50b9..7681b19aa5dc 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2592,8 +2592,16 @@ xlog_recover_inode_pass2(
2592 goto error; 2592 goto error;
2593 } 2593 }
2594 2594
2595 /* Skip replay when the on disk inode is newer than the log one */ 2595 /*
2596 if (dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) { 2596 * di_flushiter is only valid for v1/2 inodes. All changes for v3 inodes
2597 * are transactional and if ordering is necessary we can determine that
2598 * more accurately by the LSN field in the V3 inode core. Don't trust
2599 * the inode versions we might be changing them here - use the
2600 * superblock flag to determine whether we need to look at di_flushiter
2601 * to skip replay when the on disk inode is newer than the log one
2602 */
2603 if (!xfs_sb_version_hascrc(&mp->m_sb) &&
2604 dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
2597 /* 2605 /*
2598 * Deal with the wrap case, DI_MAX_FLUSH is less 2606 * Deal with the wrap case, DI_MAX_FLUSH is less
2599 * than smaller numbers 2607 * than smaller numbers
@@ -2608,6 +2616,7 @@ xlog_recover_inode_pass2(
2608 goto error; 2616 goto error;
2609 } 2617 }
2610 } 2618 }
2619
2611 /* Take the opportunity to reset the flush iteration count */ 2620 /* Take the opportunity to reset the flush iteration count */
2612 dicp->di_flushiter = 0; 2621 dicp->di_flushiter = 0;
2613 2622
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 1b09300810e6..22d497ee6ef9 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -62,6 +62,7 @@ extern u32 acpi_current_gpe_count;
62extern struct acpi_table_fadt acpi_gbl_FADT; 62extern struct acpi_table_fadt acpi_gbl_FADT;
63extern u8 acpi_gbl_system_awake_and_running; 63extern u8 acpi_gbl_system_awake_and_running;
64extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */ 64extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */
65extern u8 acpi_gbl_osi_data;
65 66
66/* Runtime configuration of debug print levels */ 67/* Runtime configuration of debug print levels */
67 68
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index a64adcc29ae5..22b03c9286e9 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -1144,4 +1144,19 @@ struct acpi_memory_list {
1144#endif 1144#endif
1145}; 1145};
1146 1146
1147/* Definitions for _OSI support */
1148
1149#define ACPI_OSI_WIN_2000 0x01
1150#define ACPI_OSI_WIN_XP 0x02
1151#define ACPI_OSI_WIN_XP_SP1 0x03
1152#define ACPI_OSI_WINSRV_2003 0x04
1153#define ACPI_OSI_WIN_XP_SP2 0x05
1154#define ACPI_OSI_WINSRV_2003_SP1 0x06
1155#define ACPI_OSI_WIN_VISTA 0x07
1156#define ACPI_OSI_WINSRV_2008 0x08
1157#define ACPI_OSI_WIN_VISTA_SP1 0x09
1158#define ACPI_OSI_WIN_VISTA_SP2 0x0A
1159#define ACPI_OSI_WIN_7 0x0B
1160#define ACPI_OSI_WIN_8 0x0C
1161
1147#endif /* __ACTYPES_H__ */ 1162#endif /* __ACTYPES_H__ */
diff --git a/include/dt-bindings/clock/vf610-clock.h b/include/dt-bindings/clock/vf610-clock.h
index 15e997fa78f2..4aa2b48cd151 100644
--- a/include/dt-bindings/clock/vf610-clock.h
+++ b/include/dt-bindings/clock/vf610-clock.h
@@ -158,6 +158,8 @@
158#define VF610_CLK_GPU_SEL 145 158#define VF610_CLK_GPU_SEL 145
159#define VF610_CLK_GPU_EN 146 159#define VF610_CLK_GPU_EN 146
160#define VF610_CLK_GPU2D 147 160#define VF610_CLK_GPU2D 147
161#define VF610_CLK_END 148 161#define VF610_CLK_ENET0 148
162#define VF610_CLK_ENET1 149
163#define VF610_CLK_END 150
162 164
163#endif /* __DT_BINDINGS_CLOCK_VF610_H */ 165#endif /* __DT_BINDINGS_CLOCK_VF610_H */
diff --git a/include/dt-bindings/pinctrl/am33xx.h b/include/dt-bindings/pinctrl/am33xx.h
index 469e0325e6f4..2fbc804e1a45 100644
--- a/include/dt-bindings/pinctrl/am33xx.h
+++ b/include/dt-bindings/pinctrl/am33xx.h
@@ -5,7 +5,7 @@
5#ifndef _DT_BINDINGS_PINCTRL_AM33XX_H 5#ifndef _DT_BINDINGS_PINCTRL_AM33XX_H
6#define _DT_BINDINGS_PINCTRL_AM33XX_H 6#define _DT_BINDINGS_PINCTRL_AM33XX_H
7 7
8#include <include/dt-bindings/pinctrl/omap.h> 8#include <dt-bindings/pinctrl/omap.h>
9 9
10/* am33xx specific mux bit defines */ 10/* am33xx specific mux bit defines */
11#undef PULL_ENA 11#undef PULL_ENA
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 297462b9f41a..e9ac882868c0 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -542,8 +542,7 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
542bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); 542bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
543 543
544int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen); 544int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
545int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, 545int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
546 char *buf, size_t buflen);
547 546
548int cgroup_task_count(const struct cgroup *cgrp); 547int cgroup_task_count(const struct cgroup *cgrp);
549 548
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 6e7ec64b69ab..b613ffd402d1 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -1,86 +1,55 @@
1/* Add subsystem definitions of the form SUBSYS(<name>) in this 1/*
2 * file. Surround each one by a line of comment markers so that 2 * List of cgroup subsystems.
3 * patches don't collide 3 *
4 * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
4 */ 5 */
5
6/* */
7
8/* */
9
10#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS) 6#if IS_SUBSYS_ENABLED(CONFIG_CPUSETS)
11SUBSYS(cpuset) 7SUBSYS(cpuset)
12#endif 8#endif
13 9
14/* */
15
16#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG) 10#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG)
17SUBSYS(debug) 11SUBSYS(debug)
18#endif 12#endif
19 13
20/* */
21
22#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED) 14#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED)
23SUBSYS(cpu_cgroup) 15SUBSYS(cpu_cgroup)
24#endif 16#endif
25 17
26/* */
27
28#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT) 18#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT)
29SUBSYS(cpuacct) 19SUBSYS(cpuacct)
30#endif 20#endif
31 21
32/* */
33
34#if IS_SUBSYS_ENABLED(CONFIG_MEMCG) 22#if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
35SUBSYS(mem_cgroup) 23SUBSYS(mem_cgroup)
36#endif 24#endif
37 25
38/* */
39
40#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE) 26#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE)
41SUBSYS(devices) 27SUBSYS(devices)
42#endif 28#endif
43 29
44/* */
45
46#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER) 30#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER)
47SUBSYS(freezer) 31SUBSYS(freezer)
48#endif 32#endif
49 33
50/* */
51
52#if IS_SUBSYS_ENABLED(CONFIG_NET_CLS_CGROUP) 34#if IS_SUBSYS_ENABLED(CONFIG_NET_CLS_CGROUP)
53SUBSYS(net_cls) 35SUBSYS(net_cls)
54#endif 36#endif
55 37
56/* */
57
58#if IS_SUBSYS_ENABLED(CONFIG_BLK_CGROUP) 38#if IS_SUBSYS_ENABLED(CONFIG_BLK_CGROUP)
59SUBSYS(blkio) 39SUBSYS(blkio)
60#endif 40#endif
61 41
62/* */
63
64#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_PERF) 42#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_PERF)
65SUBSYS(perf) 43SUBSYS(perf)
66#endif 44#endif
67 45
68/* */
69
70#if IS_SUBSYS_ENABLED(CONFIG_NETPRIO_CGROUP) 46#if IS_SUBSYS_ENABLED(CONFIG_NETPRIO_CGROUP)
71SUBSYS(net_prio) 47SUBSYS(net_prio)
72#endif 48#endif
73 49
74/* */
75
76#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_HUGETLB) 50#if IS_SUBSYS_ENABLED(CONFIG_CGROUP_HUGETLB)
77SUBSYS(hugetlb) 51SUBSYS(hugetlb)
78#endif 52#endif
79 53/*
80/* */ 54 * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
81 55 */
82#ifdef CONFIG_CGROUP_BCACHE
83SUBSYS(bcache)
84#endif
85
86/* */
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 944f283f01c4..ab0eade73039 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -114,7 +114,7 @@ enum {
114/* Need to know about CPUs going up/down? */ 114/* Need to know about CPUs going up/down? */
115#if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) 115#if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
116#define cpu_notifier(fn, pri) { \ 116#define cpu_notifier(fn, pri) { \
117 static struct notifier_block fn##_nb __cpuinitdata = \ 117 static struct notifier_block fn##_nb = \
118 { .notifier_call = fn, .priority = pri }; \ 118 { .notifier_call = fn, .priority = pri }; \
119 register_cpu_notifier(&fn##_nb); \ 119 register_cpu_notifier(&fn##_nb); \
120} 120}
diff --git a/include/linux/crc-t10dif.h b/include/linux/crc-t10dif.h
index b3cb71f0d3b0..a9c96d865ee7 100644
--- a/include/linux/crc-t10dif.h
+++ b/include/linux/crc-t10dif.h
@@ -3,10 +3,6 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6#define CRC_T10DIF_DIGEST_SIZE 2
7#define CRC_T10DIF_BLOCK_SIZE 1
8
9__u16 crc_t10dif_generic(__u16 crc, const unsigned char *buffer, size_t len);
10__u16 crc_t10dif(unsigned char const *, size_t); 6__u16 crc_t10dif(unsigned char const *, size_t);
11 7
12#endif 8#endif
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 3092df3614ae..b90337c9d468 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -324,7 +324,7 @@ static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq)
324 return ret; 324 return ret;
325} 325}
326 326
327static inline unsigned d_count(struct dentry *dentry) 327static inline unsigned d_count(const struct dentry *dentry)
328{ 328{
329 return dentry->d_count; 329 return dentry->d_count;
330} 330}
diff --git a/include/linux/device.h b/include/linux/device.h
index bcf8c0d4cd98..22b546a58591 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -47,7 +47,11 @@ struct bus_attribute {
47}; 47};
48 48
49#define BUS_ATTR(_name, _mode, _show, _store) \ 49#define BUS_ATTR(_name, _mode, _show, _store) \
50struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) 50 struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
51#define BUS_ATTR_RW(_name) \
52 struct bus_attribute bus_attr_##_name = __ATTR_RW(_name)
53#define BUS_ATTR_RO(_name) \
54 struct bus_attribute bus_attr_##_name = __ATTR_RO(_name)
51 55
52extern int __must_check bus_create_file(struct bus_type *, 56extern int __must_check bus_create_file(struct bus_type *,
53 struct bus_attribute *); 57 struct bus_attribute *);
@@ -261,9 +265,12 @@ struct driver_attribute {
261 size_t count); 265 size_t count);
262}; 266};
263 267
264#define DRIVER_ATTR(_name, _mode, _show, _store) \ 268#define DRIVER_ATTR(_name, _mode, _show, _store) \
265struct driver_attribute driver_attr_##_name = \ 269 struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
266 __ATTR(_name, _mode, _show, _store) 270#define DRIVER_ATTR_RW(_name) \
271 struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
272#define DRIVER_ATTR_RO(_name) \
273 struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
267 274
268extern int __must_check driver_create_file(struct device_driver *driver, 275extern int __must_check driver_create_file(struct device_driver *driver,
269 const struct driver_attribute *attr); 276 const struct driver_attribute *attr);
@@ -313,6 +320,7 @@ int subsys_virtual_register(struct bus_type *subsys,
313 * @name: Name of the class. 320 * @name: Name of the class.
314 * @owner: The module owner. 321 * @owner: The module owner.
315 * @class_attrs: Default attributes of this class. 322 * @class_attrs: Default attributes of this class.
323 * @dev_groups: Default attributes of the devices that belong to the class.
316 * @dev_attrs: Default attributes of the devices belong to the class. 324 * @dev_attrs: Default attributes of the devices belong to the class.
317 * @dev_bin_attrs: Default binary attributes of the devices belong to the class. 325 * @dev_bin_attrs: Default binary attributes of the devices belong to the class.
318 * @dev_kobj: The kobject that represents this class and links it into the hierarchy. 326 * @dev_kobj: The kobject that represents this class and links it into the hierarchy.
@@ -342,7 +350,8 @@ struct class {
342 struct module *owner; 350 struct module *owner;
343 351
344 struct class_attribute *class_attrs; 352 struct class_attribute *class_attrs;
345 struct device_attribute *dev_attrs; 353 struct device_attribute *dev_attrs; /* use dev_groups instead */
354 const struct attribute_group **dev_groups;
346 struct bin_attribute *dev_bin_attrs; 355 struct bin_attribute *dev_bin_attrs;
347 struct kobject *dev_kobj; 356 struct kobject *dev_kobj;
348 357
@@ -414,8 +423,12 @@ struct class_attribute {
414 const struct class_attribute *attr); 423 const struct class_attribute *attr);
415}; 424};
416 425
417#define CLASS_ATTR(_name, _mode, _show, _store) \ 426#define CLASS_ATTR(_name, _mode, _show, _store) \
418struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) 427 struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
428#define CLASS_ATTR_RW(_name) \
429 struct class_attribute class_attr_##_name = __ATTR_RW(_name)
430#define CLASS_ATTR_RO(_name) \
431 struct class_attribute class_attr_##_name = __ATTR_RO(_name)
419 432
420extern int __must_check class_create_file(struct class *class, 433extern int __must_check class_create_file(struct class *class,
421 const struct class_attribute *attr); 434 const struct class_attribute *attr);
@@ -423,7 +436,6 @@ extern void class_remove_file(struct class *class,
423 const struct class_attribute *attr); 436 const struct class_attribute *attr);
424 437
425/* Simple class attribute that is just a static string */ 438/* Simple class attribute that is just a static string */
426
427struct class_attribute_string { 439struct class_attribute_string {
428 struct class_attribute attr; 440 struct class_attribute attr;
429 char *str; 441 char *str;
@@ -512,6 +524,10 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
512 524
513#define DEVICE_ATTR(_name, _mode, _show, _store) \ 525#define DEVICE_ATTR(_name, _mode, _show, _store) \
514 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) 526 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
527#define DEVICE_ATTR_RW(_name) \
528 struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
529#define DEVICE_ATTR_RO(_name) \
530 struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
515#define DEVICE_ULONG_ATTR(_name, _mode, _var) \ 531#define DEVICE_ULONG_ATTR(_name, _mode, _var) \
516 struct dev_ext_attribute dev_attr_##_name = \ 532 struct dev_ext_attribute dev_attr_##_name = \
517 { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } 533 { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) }
@@ -924,6 +940,11 @@ extern __printf(5, 6)
924struct device *device_create(struct class *cls, struct device *parent, 940struct device *device_create(struct class *cls, struct device *parent,
925 dev_t devt, void *drvdata, 941 dev_t devt, void *drvdata,
926 const char *fmt, ...); 942 const char *fmt, ...);
943extern __printf(6, 7)
944struct device *device_create_with_groups(struct class *cls,
945 struct device *parent, dev_t devt, void *drvdata,
946 const struct attribute_group **groups,
947 const char *fmt, ...);
927extern void device_destroy(struct class *cls, dev_t devt); 948extern void device_destroy(struct class *cls, dev_t devt);
928 949
929/* 950/*
diff --git a/include/linux/drbd.h b/include/linux/drbd.h
index 1b4d4ee1168f..de7d74ab3de6 100644
--- a/include/linux/drbd.h
+++ b/include/linux/drbd.h
@@ -177,7 +177,11 @@ enum drbd_ret_code {
177 ERR_NEED_APV_100 = 163, 177 ERR_NEED_APV_100 = 163,
178 ERR_NEED_ALLOW_TWO_PRI = 164, 178 ERR_NEED_ALLOW_TWO_PRI = 164,
179 ERR_MD_UNCLEAN = 165, 179 ERR_MD_UNCLEAN = 165,
180 180 ERR_MD_LAYOUT_CONNECTED = 166,
181 ERR_MD_LAYOUT_TOO_BIG = 167,
182 ERR_MD_LAYOUT_TOO_SMALL = 168,
183 ERR_MD_LAYOUT_NO_FIT = 169,
184 ERR_IMPLICIT_SHRINK = 170,
181 /* insert new ones above this line */ 185 /* insert new ones above this line */
182 AFTER_LAST_ERR_CODE 186 AFTER_LAST_ERR_CODE
183}; 187};
diff --git a/include/linux/drbd_genl.h b/include/linux/drbd_genl.h
index d0d8fac8a6e4..e8c44572b8cb 100644
--- a/include/linux/drbd_genl.h
+++ b/include/linux/drbd_genl.h
@@ -181,6 +181,8 @@ GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms,
181 __u64_field(1, DRBD_GENLA_F_MANDATORY, resize_size) 181 __u64_field(1, DRBD_GENLA_F_MANDATORY, resize_size)
182 __flg_field(2, DRBD_GENLA_F_MANDATORY, resize_force) 182 __flg_field(2, DRBD_GENLA_F_MANDATORY, resize_force)
183 __flg_field(3, DRBD_GENLA_F_MANDATORY, no_resync) 183 __flg_field(3, DRBD_GENLA_F_MANDATORY, no_resync)
184 __u32_field_def(4, 0 /* OPTIONAL */, al_stripes, DRBD_AL_STRIPES_DEF)
185 __u32_field_def(5, 0 /* OPTIONAL */, al_stripe_size, DRBD_AL_STRIPE_SIZE_DEF)
184) 186)
185 187
186GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info, 188GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info,
diff --git a/include/linux/drbd_limits.h b/include/linux/drbd_limits.h
index 1fedf2b17cc8..17e50bb00521 100644
--- a/include/linux/drbd_limits.h
+++ b/include/linux/drbd_limits.h
@@ -215,4 +215,13 @@
215#define DRBD_ALWAYS_ASBP_DEF 0 215#define DRBD_ALWAYS_ASBP_DEF 0
216#define DRBD_USE_RLE_DEF 1 216#define DRBD_USE_RLE_DEF 1
217 217
218#define DRBD_AL_STRIPES_MIN 1
219#define DRBD_AL_STRIPES_MAX 1024
220#define DRBD_AL_STRIPES_DEF 1
221#define DRBD_AL_STRIPES_SCALE '1'
222
223#define DRBD_AL_STRIPE_SIZE_MIN 4
224#define DRBD_AL_STRIPE_SIZE_MAX 16777216
225#define DRBD_AL_STRIPE_SIZE_DEF 32
226#define DRBD_AL_STRIPE_SIZE_SCALE 'k' /* kilobytes */
218#endif 227#endif
diff --git a/include/linux/edac.h b/include/linux/edac.h
index 0b763276f619..5c6d7fbaf89e 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -622,7 +622,7 @@ struct edac_raw_error_desc {
622 */ 622 */
623struct mem_ctl_info { 623struct mem_ctl_info {
624 struct device dev; 624 struct device dev;
625 struct bus_type bus; 625 struct bus_type *bus;
626 626
627 struct list_head link; /* for global list of mem_ctl_info structs */ 627 struct list_head link; /* for global list of mem_ctl_info structs */
628 628
@@ -742,4 +742,9 @@ struct mem_ctl_info {
742#endif 742#endif
743}; 743};
744 744
745/*
746 * Maximum number of memory controllers in the coherent fabric.
747 */
748#define EDAC_MAX_MCS 16
749
745#endif 750#endif
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index cdcbafa9b39a..715c343f7c00 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -79,9 +79,8 @@ static inline int is_vlan_dev(struct net_device *dev)
79} 79}
80 80
81#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) 81#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
82#define vlan_tx_nonzero_tag_present(__skb) \
83 (vlan_tx_tag_present(__skb) && ((__skb)->vlan_tci & VLAN_VID_MASK))
84#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) 82#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
83#define vlan_tx_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK)
85 84
86#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 85#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
87 86
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 8d171f427632..3d35b7023591 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -211,8 +211,8 @@ struct iio_chan_spec {
211static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, 211static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
212 enum iio_chan_info_enum type) 212 enum iio_chan_info_enum type)
213{ 213{
214 return (chan->info_mask_separate & type) | 214 return (chan->info_mask_separate & BIT(type)) |
215 (chan->info_mask_shared_by_type & type); 215 (chan->info_mask_shared_by_type & BIT(type));
216} 216}
217 217
218#define IIO_ST(si, rb, sb, sh) \ 218#define IIO_ST(si, rb, sb, sh) \
diff --git a/include/linux/list.h b/include/linux/list.h
index b83e5657365a..f4d8a2f12a33 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -381,17 +381,6 @@ static inline void list_splice_tail_init(struct list_head *list,
381 for (pos = (head)->next; pos != (head); pos = pos->next) 381 for (pos = (head)->next; pos != (head); pos = pos->next)
382 382
383/** 383/**
384 * __list_for_each - iterate over a list
385 * @pos: the &struct list_head to use as a loop cursor.
386 * @head: the head for your list.
387 *
388 * This variant doesn't differ from list_for_each() any more.
389 * We don't do prefetching in either case.
390 */
391#define __list_for_each(pos, head) \
392 for (pos = (head)->next; pos != (head); pos = pos->next)
393
394/**
395 * list_for_each_prev - iterate over a list backwards 384 * list_for_each_prev - iterate over a list backwards
396 * @pos: the &struct list_head to use as a loop cursor. 385 * @pos: the &struct list_head to use as a loop cursor.
397 * @head: the head for your list. 386 * @head: the head for your list.
diff --git a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
index dab34a1deb2c..b6bdcd66c07d 100644
--- a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
+++ b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
@@ -103,15 +103,15 @@
103#define IMX6Q_GPR1_EXC_MON_MASK BIT(22) 103#define IMX6Q_GPR1_EXC_MON_MASK BIT(22)
104#define IMX6Q_GPR1_EXC_MON_OKAY 0x0 104#define IMX6Q_GPR1_EXC_MON_OKAY 0x0
105#define IMX6Q_GPR1_EXC_MON_SLVE BIT(22) 105#define IMX6Q_GPR1_EXC_MON_SLVE BIT(22)
106#define IMX6Q_GPR1_MIPI_IPU2_SEL_MASK BIT(21) 106#define IMX6Q_GPR1_ENET_CLK_SEL_MASK BIT(21)
107#define IMX6Q_GPR1_MIPI_IPU2_SEL_GASKET 0x0 107#define IMX6Q_GPR1_ENET_CLK_SEL_PAD 0
108#define IMX6Q_GPR1_MIPI_IPU2_SEL_IOMUX BIT(21) 108#define IMX6Q_GPR1_ENET_CLK_SEL_ANATOP BIT(21)
109#define IMX6Q_GPR1_MIPI_IPU1_MUX_MASK BIT(20) 109#define IMX6Q_GPR1_MIPI_IPU2_MUX_MASK BIT(20)
110#define IMX6Q_GPR1_MIPI_IPU1_MUX_GASKET 0x0
111#define IMX6Q_GPR1_MIPI_IPU1_MUX_IOMUX BIT(20)
112#define IMX6Q_GPR1_MIPI_IPU2_MUX_MASK BIT(19)
113#define IMX6Q_GPR1_MIPI_IPU2_MUX_GASKET 0x0 110#define IMX6Q_GPR1_MIPI_IPU2_MUX_GASKET 0x0
114#define IMX6Q_GPR1_MIPI_IPU2_MUX_IOMUX BIT(19) 111#define IMX6Q_GPR1_MIPI_IPU2_MUX_IOMUX BIT(20)
112#define IMX6Q_GPR1_MIPI_IPU1_MUX_MASK BIT(19)
113#define IMX6Q_GPR1_MIPI_IPU1_MUX_GASKET 0x0
114#define IMX6Q_GPR1_MIPI_IPU1_MUX_IOMUX BIT(19)
115#define IMX6Q_GPR1_PCIE_TEST_PD BIT(18) 115#define IMX6Q_GPR1_PCIE_TEST_PD BIT(18)
116#define IMX6Q_GPR1_IPU_VPU_MUX_MASK BIT(17) 116#define IMX6Q_GPR1_IPU_VPU_MUX_MASK BIT(17)
117#define IMX6Q_GPR1_IPU_VPU_MUX_IPU1 0x0 117#define IMX6Q_GPR1_IPU_VPU_MUX_IPU1 0x0
@@ -279,41 +279,88 @@
279#define IMX6Q_GPR13_CAN2_STOP_REQ BIT(29) 279#define IMX6Q_GPR13_CAN2_STOP_REQ BIT(29)
280#define IMX6Q_GPR13_CAN1_STOP_REQ BIT(28) 280#define IMX6Q_GPR13_CAN1_STOP_REQ BIT(28)
281#define IMX6Q_GPR13_ENET_STOP_REQ BIT(27) 281#define IMX6Q_GPR13_ENET_STOP_REQ BIT(27)
282#define IMX6Q_GPR13_SATA_PHY_8_MASK (0x7 << 24) 282#define IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK (0x7 << 24)
283#define IMX6Q_GPR13_SATA_PHY_8_0_5_DB (0x0 << 24) 283#define IMX6Q_GPR13_SATA_RX_EQ_VAL_0_5_DB (0x0 << 24)
284#define IMX6Q_GPR13_SATA_PHY_8_1_0_DB (0x1 << 24) 284#define IMX6Q_GPR13_SATA_RX_EQ_VAL_1_0_DB (0x1 << 24)
285#define IMX6Q_GPR13_SATA_PHY_8_1_5_DB (0x2 << 24) 285#define IMX6Q_GPR13_SATA_RX_EQ_VAL_1_5_DB (0x2 << 24)
286#define IMX6Q_GPR13_SATA_PHY_8_2_0_DB (0x3 << 24) 286#define IMX6Q_GPR13_SATA_RX_EQ_VAL_2_0_DB (0x3 << 24)
287#define IMX6Q_GPR13_SATA_PHY_8_2_5_DB (0x4 << 24) 287#define IMX6Q_GPR13_SATA_RX_EQ_VAL_2_5_DB (0x4 << 24)
288#define IMX6Q_GPR13_SATA_PHY_8_3_0_DB (0x5 << 24) 288#define IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB (0x5 << 24)
289#define IMX6Q_GPR13_SATA_PHY_8_3_5_DB (0x6 << 24) 289#define IMX6Q_GPR13_SATA_RX_EQ_VAL_3_5_DB (0x6 << 24)
290#define IMX6Q_GPR13_SATA_PHY_8_4_0_DB (0x7 << 24) 290#define IMX6Q_GPR13_SATA_RX_EQ_VAL_4_0_DB (0x7 << 24)
291#define IMX6Q_GPR13_SATA_PHY_7_MASK (0x1f << 19) 291#define IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK (0x1f << 19)
292#define IMX6Q_GPR13_SATA_PHY_7_SATA1I (0x10 << 19) 292#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA1I (0x10 << 19)
293#define IMX6Q_GPR13_SATA_PHY_7_SATA1M (0x10 << 19) 293#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA1M (0x10 << 19)
294#define IMX6Q_GPR13_SATA_PHY_7_SATA1X (0x1a << 19) 294#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA1X (0x1a << 19)
295#define IMX6Q_GPR13_SATA_PHY_7_SATA2I (0x12 << 19) 295#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2I (0x12 << 19)
296#define IMX6Q_GPR13_SATA_PHY_7_SATA2M (0x12 << 19) 296#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M (0x12 << 19)
297#define IMX6Q_GPR13_SATA_PHY_7_SATA2X (0x1a << 19) 297#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2X (0x1a << 19)
298#define IMX6Q_GPR13_SATA_PHY_6_MASK (0x7 << 16) 298#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK (0x7 << 16)
299#define IMX6Q_GPR13_SATA_SPEED_MASK BIT(15) 299#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_1P_1F (0x0 << 16)
300#define IMX6Q_GPR13_SATA_SPEED_1P5G 0x0 300#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_2F (0x1 << 16)
301#define IMX6Q_GPR13_SATA_SPEED_3P0G BIT(15) 301#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_1P_4F (0x2 << 16)
302#define IMX6Q_GPR13_SATA_PHY_5 BIT(14) 302#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F (0x3 << 16)
303#define IMX6Q_GPR13_SATA_PHY_4_MASK (0x7 << 11) 303#define IMX6Q_GPR13_SATA_SPD_MODE_MASK BIT(15)
304#define IMX6Q_GPR13_SATA_PHY_4_16_16 (0x0 << 11) 304#define IMX6Q_GPR13_SATA_SPD_MODE_1P5G 0x0
305#define IMX6Q_GPR13_SATA_PHY_4_14_16 (0x1 << 11) 305#define IMX6Q_GPR13_SATA_SPD_MODE_3P0G BIT(15)
306#define IMX6Q_GPR13_SATA_PHY_4_12_16 (0x2 << 11) 306#define IMX6Q_GPR13_SATA_MPLL_SS_EN BIT(14)
307#define IMX6Q_GPR13_SATA_PHY_4_10_16 (0x3 << 11) 307#define IMX6Q_GPR13_SATA_TX_ATTEN_MASK (0x7 << 11)
308#define IMX6Q_GPR13_SATA_PHY_4_9_16 (0x4 << 11) 308#define IMX6Q_GPR13_SATA_TX_ATTEN_16_16 (0x0 << 11)
309#define IMX6Q_GPR13_SATA_PHY_4_8_16 (0x5 << 11) 309#define IMX6Q_GPR13_SATA_TX_ATTEN_14_16 (0x1 << 11)
310#define IMX6Q_GPR13_SATA_PHY_3_MASK (0xf << 7) 310#define IMX6Q_GPR13_SATA_TX_ATTEN_12_16 (0x2 << 11)
311#define IMX6Q_GPR13_SATA_PHY_3_OFF 0x7 311#define IMX6Q_GPR13_SATA_TX_ATTEN_10_16 (0x3 << 11)
312#define IMX6Q_GPR13_SATA_PHY_2_MASK (0x1f << 2) 312#define IMX6Q_GPR13_SATA_TX_ATTEN_9_16 (0x4 << 11)
313#define IMX6Q_GPR13_SATA_PHY_2_OFF 0x2 313#define IMX6Q_GPR13_SATA_TX_ATTEN_8_16 (0x5 << 11)
314#define IMX6Q_GPR13_SATA_PHY_1_MASK (0x3 << 0) 314#define IMX6Q_GPR13_SATA_TX_BOOST_MASK (0xf << 7)
315#define IMX6Q_GPR13_SATA_PHY_1_FAST (0x0 << 0) 315#define IMX6Q_GPR13_SATA_TX_BOOST_0_00_DB (0x0 << 7)
316#define IMX6Q_GPR13_SATA_PHY_1_MED (0x1 << 0) 316#define IMX6Q_GPR13_SATA_TX_BOOST_0_37_DB (0x1 << 7)
317#define IMX6Q_GPR13_SATA_PHY_1_SLOW (0x2 << 0) 317#define IMX6Q_GPR13_SATA_TX_BOOST_0_74_DB (0x2 << 7)
318 318#define IMX6Q_GPR13_SATA_TX_BOOST_1_11_DB (0x3 << 7)
319#define IMX6Q_GPR13_SATA_TX_BOOST_1_48_DB (0x4 << 7)
320#define IMX6Q_GPR13_SATA_TX_BOOST_1_85_DB (0x5 << 7)
321#define IMX6Q_GPR13_SATA_TX_BOOST_2_22_DB (0x6 << 7)
322#define IMX6Q_GPR13_SATA_TX_BOOST_2_59_DB (0x7 << 7)
323#define IMX6Q_GPR13_SATA_TX_BOOST_2_96_DB (0x8 << 7)
324#define IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB (0x9 << 7)
325#define IMX6Q_GPR13_SATA_TX_BOOST_3_70_DB (0xa << 7)
326#define IMX6Q_GPR13_SATA_TX_BOOST_4_07_DB (0xb << 7)
327#define IMX6Q_GPR13_SATA_TX_BOOST_4_44_DB (0xc << 7)
328#define IMX6Q_GPR13_SATA_TX_BOOST_4_81_DB (0xd << 7)
329#define IMX6Q_GPR13_SATA_TX_BOOST_5_28_DB (0xe << 7)
330#define IMX6Q_GPR13_SATA_TX_BOOST_5_75_DB (0xf << 7)
331#define IMX6Q_GPR13_SATA_TX_LVL_MASK (0x1f << 2)
332#define IMX6Q_GPR13_SATA_TX_LVL_0_937_V (0x00 << 2)
333#define IMX6Q_GPR13_SATA_TX_LVL_0_947_V (0x01 << 2)
334#define IMX6Q_GPR13_SATA_TX_LVL_0_957_V (0x02 << 2)
335#define IMX6Q_GPR13_SATA_TX_LVL_0_966_V (0x03 << 2)
336#define IMX6Q_GPR13_SATA_TX_LVL_0_976_V (0x04 << 2)
337#define IMX6Q_GPR13_SATA_TX_LVL_0_986_V (0x05 << 2)
338#define IMX6Q_GPR13_SATA_TX_LVL_0_996_V (0x06 << 2)
339#define IMX6Q_GPR13_SATA_TX_LVL_1_005_V (0x07 << 2)
340#define IMX6Q_GPR13_SATA_TX_LVL_1_015_V (0x08 << 2)
341#define IMX6Q_GPR13_SATA_TX_LVL_1_025_V (0x09 << 2)
342#define IMX6Q_GPR13_SATA_TX_LVL_1_035_V (0x0a << 2)
343#define IMX6Q_GPR13_SATA_TX_LVL_1_045_V (0x0b << 2)
344#define IMX6Q_GPR13_SATA_TX_LVL_1_054_V (0x0c << 2)
345#define IMX6Q_GPR13_SATA_TX_LVL_1_064_V (0x0d << 2)
346#define IMX6Q_GPR13_SATA_TX_LVL_1_074_V (0x0e << 2)
347#define IMX6Q_GPR13_SATA_TX_LVL_1_084_V (0x0f << 2)
348#define IMX6Q_GPR13_SATA_TX_LVL_1_094_V (0x10 << 2)
349#define IMX6Q_GPR13_SATA_TX_LVL_1_104_V (0x11 << 2)
350#define IMX6Q_GPR13_SATA_TX_LVL_1_113_V (0x12 << 2)
351#define IMX6Q_GPR13_SATA_TX_LVL_1_123_V (0x13 << 2)
352#define IMX6Q_GPR13_SATA_TX_LVL_1_133_V (0x14 << 2)
353#define IMX6Q_GPR13_SATA_TX_LVL_1_143_V (0x15 << 2)
354#define IMX6Q_GPR13_SATA_TX_LVL_1_152_V (0x16 << 2)
355#define IMX6Q_GPR13_SATA_TX_LVL_1_162_V (0x17 << 2)
356#define IMX6Q_GPR13_SATA_TX_LVL_1_172_V (0x18 << 2)
357#define IMX6Q_GPR13_SATA_TX_LVL_1_182_V (0x19 << 2)
358#define IMX6Q_GPR13_SATA_TX_LVL_1_191_V (0x1a << 2)
359#define IMX6Q_GPR13_SATA_TX_LVL_1_201_V (0x1b << 2)
360#define IMX6Q_GPR13_SATA_TX_LVL_1_211_V (0x1c << 2)
361#define IMX6Q_GPR13_SATA_TX_LVL_1_221_V (0x1d << 2)
362#define IMX6Q_GPR13_SATA_TX_LVL_1_230_V (0x1e << 2)
363#define IMX6Q_GPR13_SATA_TX_LVL_1_240_V (0x1f << 2)
364#define IMX6Q_GPR13_SATA_MPLL_CLK_EN BIT(1)
365#define IMX6Q_GPR13_SATA_TX_EDGE_RATE BIT(0)
319#endif /* __LINUX_IMX6Q_IOMUXC_GPR_H */ 366#endif /* __LINUX_IMX6Q_IOMUXC_GPR_H */
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 8873f82c7baa..c43f6eabad5b 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -826,7 +826,7 @@ static inline void perf_restore_debug_store(void) { }
826 */ 826 */
827#define perf_cpu_notifier(fn) \ 827#define perf_cpu_notifier(fn) \
828do { \ 828do { \
829 static struct notifier_block fn##_nb __cpuinitdata = \ 829 static struct notifier_block fn##_nb = \
830 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \ 830 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
831 unsigned long cpu = smp_processor_id(); \ 831 unsigned long cpu = smp_processor_id(); \
832 unsigned long flags; \ 832 unsigned long flags; \
diff --git a/include/linux/platform_data/mmc-pxamci.h b/include/linux/platform_data/mmc-pxamci.h
index 9eb515bb799d..1706b3597ce0 100644
--- a/include/linux/platform_data/mmc-pxamci.h
+++ b/include/linux/platform_data/mmc-pxamci.h
@@ -12,7 +12,7 @@ struct pxamci_platform_data {
12 unsigned long detect_delay_ms; /* delay in millisecond before detecting cards after interrupt */ 12 unsigned long detect_delay_ms; /* delay in millisecond before detecting cards after interrupt */
13 int (*init)(struct device *, irq_handler_t , void *); 13 int (*init)(struct device *, irq_handler_t , void *);
14 int (*get_ro)(struct device *); 14 int (*get_ro)(struct device *);
15 void (*setpower)(struct device *, unsigned int); 15 int (*setpower)(struct device *, unsigned int);
16 void (*exit)(struct device *, void *); 16 void (*exit)(struct device *, void *);
17 int gpio_card_detect; /* gpio detecting card insertion */ 17 int gpio_card_detect; /* gpio detecting card insertion */
18 int gpio_card_ro; /* gpio detecting read only toggle */ 18 int gpio_card_ro; /* gpio detecting read only toggle */
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
index 569781faa504..a0f70808d7f4 100644
--- a/include/linux/pm_wakeup.h
+++ b/include/linux/pm_wakeup.h
@@ -36,8 +36,8 @@
36 * @last_time: Monotonic clock when the wakeup source's was touched last time. 36 * @last_time: Monotonic clock when the wakeup source's was touched last time.
37 * @prevent_sleep_time: Total time this source has been preventing autosleep. 37 * @prevent_sleep_time: Total time this source has been preventing autosleep.
38 * @event_count: Number of signaled wakeup events. 38 * @event_count: Number of signaled wakeup events.
39 * @active_count: Number of times the wakeup sorce was activated. 39 * @active_count: Number of times the wakeup source was activated.
40 * @relax_count: Number of times the wakeup sorce was deactivated. 40 * @relax_count: Number of times the wakeup source was deactivated.
41 * @expire_count: Number of times the wakeup source's timeout has expired. 41 * @expire_count: Number of times the wakeup source's timeout has expired.
42 * @wakeup_count: Number of times the wakeup source might abort suspend. 42 * @wakeup_count: Number of times the wakeup source might abort suspend.
43 * @active: Status of the wakeup source. 43 * @active: Status of the wakeup source.
diff --git a/include/linux/shdma-base.h b/include/linux/shdma-base.h
index 382cf710ca9a..5b1c9848124c 100644
--- a/include/linux/shdma-base.h
+++ b/include/linux/shdma-base.h
@@ -124,6 +124,10 @@ void shdma_chan_remove(struct shdma_chan *schan);
124int shdma_init(struct device *dev, struct shdma_dev *sdev, 124int shdma_init(struct device *dev, struct shdma_dev *sdev,
125 int chan_num); 125 int chan_num);
126void shdma_cleanup(struct shdma_dev *sdev); 126void shdma_cleanup(struct shdma_dev *sdev);
127#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
127bool shdma_chan_filter(struct dma_chan *chan, void *arg); 128bool shdma_chan_filter(struct dma_chan *chan, void *arg);
129#else
130#define shdma_chan_filter NULL
131#endif
128 132
129#endif 133#endif
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index e2cee22f578a..9e8a9b555ad6 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -17,10 +17,12 @@
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/lockdep.h> 18#include <linux/lockdep.h>
19#include <linux/kobject_ns.h> 19#include <linux/kobject_ns.h>
20#include <linux/stat.h>
20#include <linux/atomic.h> 21#include <linux/atomic.h>
21 22
22struct kobject; 23struct kobject;
23struct module; 24struct module;
25struct bin_attribute;
24enum kobj_ns_type; 26enum kobj_ns_type;
25 27
26struct attribute { 28struct attribute {
@@ -59,26 +61,28 @@ struct attribute_group {
59 umode_t (*is_visible)(struct kobject *, 61 umode_t (*is_visible)(struct kobject *,
60 struct attribute *, int); 62 struct attribute *, int);
61 struct attribute **attrs; 63 struct attribute **attrs;
64 struct bin_attribute **bin_attrs;
62}; 65};
63 66
64
65
66/** 67/**
67 * Use these macros to make defining attributes easier. See include/linux/device.h 68 * Use these macros to make defining attributes easier. See include/linux/device.h
68 * for examples.. 69 * for examples..
69 */ 70 */
70 71
71#define __ATTR(_name,_mode,_show,_store) { \ 72#define __ATTR(_name,_mode,_show,_store) { \
72 .attr = {.name = __stringify(_name), .mode = _mode }, \ 73 .attr = {.name = __stringify(_name), .mode = _mode }, \
73 .show = _show, \ 74 .show = _show, \
74 .store = _store, \ 75 .store = _store, \
75} 76}
76 77
77#define __ATTR_RO(_name) { \ 78#define __ATTR_RO(_name) { \
78 .attr = { .name = __stringify(_name), .mode = 0444 }, \ 79 .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \
79 .show = _name##_show, \ 80 .show = _name##_show, \
80} 81}
81 82
83#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \
84 _name##_show, _name##_store)
85
82#define __ATTR_NULL { .attr = { .name = NULL } } 86#define __ATTR_NULL { .attr = { .name = NULL } }
83 87
84#ifdef CONFIG_DEBUG_LOCK_ALLOC 88#ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -92,6 +96,18 @@ struct attribute_group {
92#define __ATTR_IGNORE_LOCKDEP __ATTR 96#define __ATTR_IGNORE_LOCKDEP __ATTR
93#endif 97#endif
94 98
99#define __ATTRIBUTE_GROUPS(_name) \
100static const struct attribute_group *_name##_groups[] = { \
101 &_name##_group, \
102 NULL, \
103}
104
105#define ATTRIBUTE_GROUPS(_name) \
106static const struct attribute_group _name##_group = { \
107 .attrs = _name##_attrs, \
108}; \
109__ATTRIBUTE_GROUPS(_name)
110
95#define attr_name(_attr) (_attr).attr.name 111#define attr_name(_attr) (_attr).attr.name
96 112
97struct file; 113struct file;
@@ -121,6 +137,36 @@ struct bin_attribute {
121 */ 137 */
122#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) 138#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
123 139
140/* macros to create static binary attributes easier */
141#define __BIN_ATTR(_name, _mode, _read, _write, _size) { \
142 .attr = { .name = __stringify(_name), .mode = _mode }, \
143 .read = _read, \
144 .write = _write, \
145 .size = _size, \
146}
147
148#define __BIN_ATTR_RO(_name, _size) { \
149 .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \
150 .read = _name##_read, \
151 .size = _size, \
152}
153
154#define __BIN_ATTR_RW(_name, _size) __BIN_ATTR(_name, \
155 (S_IWUSR | S_IRUGO), _name##_read, \
156 _name##_write)
157
158#define __BIN_ATTR_NULL __ATTR_NULL
159
160#define BIN_ATTR(_name, _mode, _read, _write, _size) \
161struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read, \
162 _write, _size)
163
164#define BIN_ATTR_RO(_name, _size) \
165struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
166
167#define BIN_ATTR_RW(_name, _size) \
168struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
169
124struct sysfs_ops { 170struct sysfs_ops {
125 ssize_t (*show)(struct kobject *, struct attribute *,char *); 171 ssize_t (*show)(struct kobject *, struct attribute *,char *);
126 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 172 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index a232b7ece1f6..0eec2689b955 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -367,17 +367,6 @@ struct usb_bus {
367 367
368/* ----------------------------------------------------------------------- */ 368/* ----------------------------------------------------------------------- */
369 369
370/* This is arbitrary.
371 * From USB 2.0 spec Table 11-13, offset 7, a hub can
372 * have up to 255 ports. The most yet reported is 10.
373 *
374 * Current Wireless USB host hardware (Intel i1480 for example) allows
375 * up to 22 devices to connect. Upcoming hardware might raise that
376 * limit. Because the arrays need to add a bit for hub status data, we
377 * do 31, so plus one evens out to four bytes.
378 */
379#define USB_MAXCHILDREN (31)
380
381struct usb_tt; 370struct usb_tt;
382 371
383enum usb_device_removable { 372enum usb_device_removable {
diff --git a/include/trace/events/bcache.h b/include/trace/events/bcache.h
index 3cc5a0b278c3..5ebda976ea93 100644
--- a/include/trace/events/bcache.h
+++ b/include/trace/events/bcache.h
@@ -9,9 +9,7 @@
9struct search; 9struct search;
10 10
11DECLARE_EVENT_CLASS(bcache_request, 11DECLARE_EVENT_CLASS(bcache_request,
12
13 TP_PROTO(struct search *s, struct bio *bio), 12 TP_PROTO(struct search *s, struct bio *bio),
14
15 TP_ARGS(s, bio), 13 TP_ARGS(s, bio),
16 14
17 TP_STRUCT__entry( 15 TP_STRUCT__entry(
@@ -22,7 +20,6 @@ DECLARE_EVENT_CLASS(bcache_request,
22 __field(dev_t, orig_sector ) 20 __field(dev_t, orig_sector )
23 __field(unsigned int, nr_sector ) 21 __field(unsigned int, nr_sector )
24 __array(char, rwbs, 6 ) 22 __array(char, rwbs, 6 )
25 __array(char, comm, TASK_COMM_LEN )
26 ), 23 ),
27 24
28 TP_fast_assign( 25 TP_fast_assign(
@@ -33,36 +30,66 @@ DECLARE_EVENT_CLASS(bcache_request,
33 __entry->orig_sector = bio->bi_sector - 16; 30 __entry->orig_sector = bio->bi_sector - 16;
34 __entry->nr_sector = bio->bi_size >> 9; 31 __entry->nr_sector = bio->bi_size >> 9;
35 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 32 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
36 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
37 ), 33 ),
38 34
39 TP_printk("%d,%d %s %llu + %u [%s] (from %d,%d @ %llu)", 35 TP_printk("%d,%d %s %llu + %u (from %d,%d @ %llu)",
40 MAJOR(__entry->dev), MINOR(__entry->dev), 36 MAJOR(__entry->dev), MINOR(__entry->dev),
41 __entry->rwbs, 37 __entry->rwbs, (unsigned long long)__entry->sector,
42 (unsigned long long)__entry->sector, 38 __entry->nr_sector, __entry->orig_major, __entry->orig_minor,
43 __entry->nr_sector, __entry->comm,
44 __entry->orig_major, __entry->orig_minor,
45 (unsigned long long)__entry->orig_sector) 39 (unsigned long long)__entry->orig_sector)
46); 40);
47 41
48DEFINE_EVENT(bcache_request, bcache_request_start, 42DECLARE_EVENT_CLASS(bkey,
43 TP_PROTO(struct bkey *k),
44 TP_ARGS(k),
49 45
50 TP_PROTO(struct search *s, struct bio *bio), 46 TP_STRUCT__entry(
47 __field(u32, size )
48 __field(u32, inode )
49 __field(u64, offset )
50 __field(bool, dirty )
51 ),
51 52
52 TP_ARGS(s, bio) 53 TP_fast_assign(
54 __entry->inode = KEY_INODE(k);
55 __entry->offset = KEY_OFFSET(k);
56 __entry->size = KEY_SIZE(k);
57 __entry->dirty = KEY_DIRTY(k);
58 ),
59
60 TP_printk("%u:%llu len %u dirty %u", __entry->inode,
61 __entry->offset, __entry->size, __entry->dirty)
53); 62);
54 63
55DEFINE_EVENT(bcache_request, bcache_request_end, 64DECLARE_EVENT_CLASS(btree_node,
65 TP_PROTO(struct btree *b),
66 TP_ARGS(b),
67
68 TP_STRUCT__entry(
69 __field(size_t, bucket )
70 ),
56 71
72 TP_fast_assign(
73 __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
74 ),
75
76 TP_printk("bucket %zu", __entry->bucket)
77);
78
79/* request.c */
80
81DEFINE_EVENT(bcache_request, bcache_request_start,
57 TP_PROTO(struct search *s, struct bio *bio), 82 TP_PROTO(struct search *s, struct bio *bio),
83 TP_ARGS(s, bio)
84);
58 85
86DEFINE_EVENT(bcache_request, bcache_request_end,
87 TP_PROTO(struct search *s, struct bio *bio),
59 TP_ARGS(s, bio) 88 TP_ARGS(s, bio)
60); 89);
61 90
62DECLARE_EVENT_CLASS(bcache_bio, 91DECLARE_EVENT_CLASS(bcache_bio,
63
64 TP_PROTO(struct bio *bio), 92 TP_PROTO(struct bio *bio),
65
66 TP_ARGS(bio), 93 TP_ARGS(bio),
67 94
68 TP_STRUCT__entry( 95 TP_STRUCT__entry(
@@ -70,7 +97,6 @@ DECLARE_EVENT_CLASS(bcache_bio,
70 __field(sector_t, sector ) 97 __field(sector_t, sector )
71 __field(unsigned int, nr_sector ) 98 __field(unsigned int, nr_sector )
72 __array(char, rwbs, 6 ) 99 __array(char, rwbs, 6 )
73 __array(char, comm, TASK_COMM_LEN )
74 ), 100 ),
75 101
76 TP_fast_assign( 102 TP_fast_assign(
@@ -78,191 +104,328 @@ DECLARE_EVENT_CLASS(bcache_bio,
78 __entry->sector = bio->bi_sector; 104 __entry->sector = bio->bi_sector;
79 __entry->nr_sector = bio->bi_size >> 9; 105 __entry->nr_sector = bio->bi_size >> 9;
80 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 106 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
81 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
82 ), 107 ),
83 108
84 TP_printk("%d,%d %s %llu + %u [%s]", 109 TP_printk("%d,%d %s %llu + %u",
85 MAJOR(__entry->dev), MINOR(__entry->dev), 110 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
86 __entry->rwbs, 111 (unsigned long long)__entry->sector, __entry->nr_sector)
87 (unsigned long long)__entry->sector,
88 __entry->nr_sector, __entry->comm)
89); 112);
90 113
91 114DEFINE_EVENT(bcache_bio, bcache_bypass_sequential,
92DEFINE_EVENT(bcache_bio, bcache_passthrough,
93
94 TP_PROTO(struct bio *bio), 115 TP_PROTO(struct bio *bio),
116 TP_ARGS(bio)
117);
95 118
119DEFINE_EVENT(bcache_bio, bcache_bypass_congested,
120 TP_PROTO(struct bio *bio),
96 TP_ARGS(bio) 121 TP_ARGS(bio)
97); 122);
98 123
99DEFINE_EVENT(bcache_bio, bcache_cache_hit, 124TRACE_EVENT(bcache_read,
125 TP_PROTO(struct bio *bio, bool hit, bool bypass),
126 TP_ARGS(bio, hit, bypass),
100 127
101 TP_PROTO(struct bio *bio), 128 TP_STRUCT__entry(
129 __field(dev_t, dev )
130 __field(sector_t, sector )
131 __field(unsigned int, nr_sector )
132 __array(char, rwbs, 6 )
133 __field(bool, cache_hit )
134 __field(bool, bypass )
135 ),
102 136
103 TP_ARGS(bio) 137 TP_fast_assign(
138 __entry->dev = bio->bi_bdev->bd_dev;
139 __entry->sector = bio->bi_sector;
140 __entry->nr_sector = bio->bi_size >> 9;
141 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
142 __entry->cache_hit = hit;
143 __entry->bypass = bypass;
144 ),
145
146 TP_printk("%d,%d %s %llu + %u hit %u bypass %u",
147 MAJOR(__entry->dev), MINOR(__entry->dev),
148 __entry->rwbs, (unsigned long long)__entry->sector,
149 __entry->nr_sector, __entry->cache_hit, __entry->bypass)
104); 150);
105 151
106DEFINE_EVENT(bcache_bio, bcache_cache_miss, 152TRACE_EVENT(bcache_write,
153 TP_PROTO(struct bio *bio, bool writeback, bool bypass),
154 TP_ARGS(bio, writeback, bypass),
107 155
108 TP_PROTO(struct bio *bio), 156 TP_STRUCT__entry(
157 __field(dev_t, dev )
158 __field(sector_t, sector )
159 __field(unsigned int, nr_sector )
160 __array(char, rwbs, 6 )
161 __field(bool, writeback )
162 __field(bool, bypass )
163 ),
109 164
110 TP_ARGS(bio) 165 TP_fast_assign(
166 __entry->dev = bio->bi_bdev->bd_dev;
167 __entry->sector = bio->bi_sector;
168 __entry->nr_sector = bio->bi_size >> 9;
169 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
170 __entry->writeback = writeback;
171 __entry->bypass = bypass;
172 ),
173
174 TP_printk("%d,%d %s %llu + %u hit %u bypass %u",
175 MAJOR(__entry->dev), MINOR(__entry->dev),
176 __entry->rwbs, (unsigned long long)__entry->sector,
177 __entry->nr_sector, __entry->writeback, __entry->bypass)
111); 178);
112 179
113DEFINE_EVENT(bcache_bio, bcache_read_retry, 180DEFINE_EVENT(bcache_bio, bcache_read_retry,
114
115 TP_PROTO(struct bio *bio), 181 TP_PROTO(struct bio *bio),
116
117 TP_ARGS(bio) 182 TP_ARGS(bio)
118); 183);
119 184
120DEFINE_EVENT(bcache_bio, bcache_writethrough, 185DEFINE_EVENT(bkey, bcache_cache_insert,
186 TP_PROTO(struct bkey *k),
187 TP_ARGS(k)
188);
121 189
122 TP_PROTO(struct bio *bio), 190/* Journal */
123 191
124 TP_ARGS(bio) 192DECLARE_EVENT_CLASS(cache_set,
125); 193 TP_PROTO(struct cache_set *c),
194 TP_ARGS(c),
126 195
127DEFINE_EVENT(bcache_bio, bcache_writeback, 196 TP_STRUCT__entry(
197 __array(char, uuid, 16 )
198 ),
128 199
129 TP_PROTO(struct bio *bio), 200 TP_fast_assign(
201 memcpy(__entry->uuid, c->sb.set_uuid, 16);
202 ),
130 203
131 TP_ARGS(bio) 204 TP_printk("%pU", __entry->uuid)
132); 205);
133 206
134DEFINE_EVENT(bcache_bio, bcache_write_skip, 207DEFINE_EVENT(bkey, bcache_journal_replay_key,
135 208 TP_PROTO(struct bkey *k),
136 TP_PROTO(struct bio *bio), 209 TP_ARGS(k)
210);
137 211
138 TP_ARGS(bio) 212DEFINE_EVENT(cache_set, bcache_journal_full,
213 TP_PROTO(struct cache_set *c),
214 TP_ARGS(c)
139); 215);
140 216
141DEFINE_EVENT(bcache_bio, bcache_btree_read, 217DEFINE_EVENT(cache_set, bcache_journal_entry_full,
218 TP_PROTO(struct cache_set *c),
219 TP_ARGS(c)
220);
142 221
222DEFINE_EVENT(bcache_bio, bcache_journal_write,
143 TP_PROTO(struct bio *bio), 223 TP_PROTO(struct bio *bio),
144
145 TP_ARGS(bio) 224 TP_ARGS(bio)
146); 225);
147 226
148DEFINE_EVENT(bcache_bio, bcache_btree_write, 227/* Btree */
149 228
150 TP_PROTO(struct bio *bio), 229DEFINE_EVENT(cache_set, bcache_btree_cache_cannibalize,
230 TP_PROTO(struct cache_set *c),
231 TP_ARGS(c)
232);
151 233
152 TP_ARGS(bio) 234DEFINE_EVENT(btree_node, bcache_btree_read,
235 TP_PROTO(struct btree *b),
236 TP_ARGS(b)
153); 237);
154 238
155DEFINE_EVENT(bcache_bio, bcache_write_dirty, 239TRACE_EVENT(bcache_btree_write,
240 TP_PROTO(struct btree *b),
241 TP_ARGS(b),
156 242
157 TP_PROTO(struct bio *bio), 243 TP_STRUCT__entry(
244 __field(size_t, bucket )
245 __field(unsigned, block )
246 __field(unsigned, keys )
247 ),
158 248
159 TP_ARGS(bio) 249 TP_fast_assign(
250 __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
251 __entry->block = b->written;
252 __entry->keys = b->sets[b->nsets].data->keys;
253 ),
254
255 TP_printk("bucket %zu", __entry->bucket)
160); 256);
161 257
162DEFINE_EVENT(bcache_bio, bcache_read_dirty, 258DEFINE_EVENT(btree_node, bcache_btree_node_alloc,
259 TP_PROTO(struct btree *b),
260 TP_ARGS(b)
261);
163 262
164 TP_PROTO(struct bio *bio), 263DEFINE_EVENT(btree_node, bcache_btree_node_alloc_fail,
264 TP_PROTO(struct btree *b),
265 TP_ARGS(b)
266);
165 267
166 TP_ARGS(bio) 268DEFINE_EVENT(btree_node, bcache_btree_node_free,
269 TP_PROTO(struct btree *b),
270 TP_ARGS(b)
167); 271);
168 272
169DEFINE_EVENT(bcache_bio, bcache_write_moving, 273TRACE_EVENT(bcache_btree_gc_coalesce,
274 TP_PROTO(unsigned nodes),
275 TP_ARGS(nodes),
170 276
171 TP_PROTO(struct bio *bio), 277 TP_STRUCT__entry(
278 __field(unsigned, nodes )
279 ),
172 280
173 TP_ARGS(bio) 281 TP_fast_assign(
282 __entry->nodes = nodes;
283 ),
284
285 TP_printk("coalesced %u nodes", __entry->nodes)
174); 286);
175 287
176DEFINE_EVENT(bcache_bio, bcache_read_moving, 288DEFINE_EVENT(cache_set, bcache_gc_start,
289 TP_PROTO(struct cache_set *c),
290 TP_ARGS(c)
291);
177 292
178 TP_PROTO(struct bio *bio), 293DEFINE_EVENT(cache_set, bcache_gc_end,
294 TP_PROTO(struct cache_set *c),
295 TP_ARGS(c)
296);
179 297
180 TP_ARGS(bio) 298DEFINE_EVENT(bkey, bcache_gc_copy,
299 TP_PROTO(struct bkey *k),
300 TP_ARGS(k)
181); 301);
182 302
183DEFINE_EVENT(bcache_bio, bcache_journal_write, 303DEFINE_EVENT(bkey, bcache_gc_copy_collision,
304 TP_PROTO(struct bkey *k),
305 TP_ARGS(k)
306);
184 307
185 TP_PROTO(struct bio *bio), 308TRACE_EVENT(bcache_btree_insert_key,
309 TP_PROTO(struct btree *b, struct bkey *k, unsigned op, unsigned status),
310 TP_ARGS(b, k, op, status),
186 311
187 TP_ARGS(bio) 312 TP_STRUCT__entry(
188); 313 __field(u64, btree_node )
314 __field(u32, btree_level )
315 __field(u32, inode )
316 __field(u64, offset )
317 __field(u32, size )
318 __field(u8, dirty )
319 __field(u8, op )
320 __field(u8, status )
321 ),
189 322
190DECLARE_EVENT_CLASS(bcache_cache_bio, 323 TP_fast_assign(
324 __entry->btree_node = PTR_BUCKET_NR(b->c, &b->key, 0);
325 __entry->btree_level = b->level;
326 __entry->inode = KEY_INODE(k);
327 __entry->offset = KEY_OFFSET(k);
328 __entry->size = KEY_SIZE(k);
329 __entry->dirty = KEY_DIRTY(k);
330 __entry->op = op;
331 __entry->status = status;
332 ),
191 333
192 TP_PROTO(struct bio *bio, 334 TP_printk("%u for %u at %llu(%u): %u:%llu len %u dirty %u",
193 sector_t orig_sector, 335 __entry->status, __entry->op,
194 struct block_device* orig_bdev), 336 __entry->btree_node, __entry->btree_level,
337 __entry->inode, __entry->offset,
338 __entry->size, __entry->dirty)
339);
195 340
196 TP_ARGS(bio, orig_sector, orig_bdev), 341DECLARE_EVENT_CLASS(btree_split,
342 TP_PROTO(struct btree *b, unsigned keys),
343 TP_ARGS(b, keys),
197 344
198 TP_STRUCT__entry( 345 TP_STRUCT__entry(
199 __field(dev_t, dev ) 346 __field(size_t, bucket )
200 __field(dev_t, orig_dev ) 347 __field(unsigned, keys )
201 __field(sector_t, sector )
202 __field(sector_t, orig_sector )
203 __field(unsigned int, nr_sector )
204 __array(char, rwbs, 6 )
205 __array(char, comm, TASK_COMM_LEN )
206 ), 348 ),
207 349
208 TP_fast_assign( 350 TP_fast_assign(
209 __entry->dev = bio->bi_bdev->bd_dev; 351 __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
210 __entry->orig_dev = orig_bdev->bd_dev; 352 __entry->keys = keys;
211 __entry->sector = bio->bi_sector;
212 __entry->orig_sector = orig_sector;
213 __entry->nr_sector = bio->bi_size >> 9;
214 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
215 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
216 ), 353 ),
217 354
218 TP_printk("%d,%d %s %llu + %u [%s] (from %d,%d %llu)", 355 TP_printk("bucket %zu keys %u", __entry->bucket, __entry->keys)
219 MAJOR(__entry->dev), MINOR(__entry->dev),
220 __entry->rwbs,
221 (unsigned long long)__entry->sector,
222 __entry->nr_sector, __entry->comm,
223 MAJOR(__entry->orig_dev), MINOR(__entry->orig_dev),
224 (unsigned long long)__entry->orig_sector)
225); 356);
226 357
227DEFINE_EVENT(bcache_cache_bio, bcache_cache_insert, 358DEFINE_EVENT(btree_split, bcache_btree_node_split,
228 359 TP_PROTO(struct btree *b, unsigned keys),
229 TP_PROTO(struct bio *bio, 360 TP_ARGS(b, keys)
230 sector_t orig_sector, 361);
231 struct block_device *orig_bdev),
232 362
233 TP_ARGS(bio, orig_sector, orig_bdev) 363DEFINE_EVENT(btree_split, bcache_btree_node_compact,
364 TP_PROTO(struct btree *b, unsigned keys),
365 TP_ARGS(b, keys)
234); 366);
235 367
236DECLARE_EVENT_CLASS(bcache_gc, 368DEFINE_EVENT(btree_node, bcache_btree_set_root,
369 TP_PROTO(struct btree *b),
370 TP_ARGS(b)
371);
237 372
238 TP_PROTO(uint8_t *uuid), 373/* Allocator */
239 374
240 TP_ARGS(uuid), 375TRACE_EVENT(bcache_alloc_invalidate,
376 TP_PROTO(struct cache *ca),
377 TP_ARGS(ca),
241 378
242 TP_STRUCT__entry( 379 TP_STRUCT__entry(
243 __field(uint8_t *, uuid) 380 __field(unsigned, free )
381 __field(unsigned, free_inc )
382 __field(unsigned, free_inc_size )
383 __field(unsigned, unused )
244 ), 384 ),
245 385
246 TP_fast_assign( 386 TP_fast_assign(
247 __entry->uuid = uuid; 387 __entry->free = fifo_used(&ca->free);
388 __entry->free_inc = fifo_used(&ca->free_inc);
389 __entry->free_inc_size = ca->free_inc.size;
390 __entry->unused = fifo_used(&ca->unused);
248 ), 391 ),
249 392
250 TP_printk("%pU", __entry->uuid) 393 TP_printk("free %u free_inc %u/%u unused %u", __entry->free,
394 __entry->free_inc, __entry->free_inc_size, __entry->unused)
251); 395);
252 396
397TRACE_EVENT(bcache_alloc_fail,
398 TP_PROTO(struct cache *ca),
399 TP_ARGS(ca),
253 400
254DEFINE_EVENT(bcache_gc, bcache_gc_start, 401 TP_STRUCT__entry(
402 __field(unsigned, free )
403 __field(unsigned, free_inc )
404 __field(unsigned, unused )
405 __field(unsigned, blocked )
406 ),
255 407
256 TP_PROTO(uint8_t *uuid), 408 TP_fast_assign(
409 __entry->free = fifo_used(&ca->free);
410 __entry->free_inc = fifo_used(&ca->free_inc);
411 __entry->unused = fifo_used(&ca->unused);
412 __entry->blocked = atomic_read(&ca->set->prio_blocked);
413 ),
257 414
258 TP_ARGS(uuid) 415 TP_printk("free %u free_inc %u unused %u blocked %u", __entry->free,
416 __entry->free_inc, __entry->unused, __entry->blocked)
259); 417);
260 418
261DEFINE_EVENT(bcache_gc, bcache_gc_end, 419/* Background writeback */
262 420
263 TP_PROTO(uint8_t *uuid), 421DEFINE_EVENT(bkey, bcache_writeback,
422 TP_PROTO(struct bkey *k),
423 TP_ARGS(k)
424);
264 425
265 TP_ARGS(uuid) 426DEFINE_EVENT(bkey, bcache_writeback_collision,
427 TP_PROTO(struct bkey *k),
428 TP_ARGS(k)
266); 429);
267 430
268#endif /* _TRACE_BCACHE_H */ 431#endif /* _TRACE_BCACHE_H */
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index d615f78cc6b6..41a6643e2136 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -670,10 +670,6 @@ perf_trace_##call(void *__data, proto) \
670 sizeof(u64)); \ 670 sizeof(u64)); \
671 __entry_size -= sizeof(u32); \ 671 __entry_size -= sizeof(u32); \
672 \ 672 \
673 if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
674 "profile buffer not large enough")) \
675 return; \
676 \
677 entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \ 673 entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
678 __entry_size, event_call->event.type, &__regs, &rctx); \ 674 __entry_size, event_call->event.type, &__regs, &rctx); \
679 if (!entry) \ 675 if (!entry) \
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
index 05ac354e124d..95e46c8e05f9 100644
--- a/include/uapi/asm-generic/fcntl.h
+++ b/include/uapi/asm-generic/fcntl.h
@@ -89,8 +89,8 @@
89#endif 89#endif
90 90
91/* a horrid kludge trying to make sure that this will fail on old kernels */ 91/* a horrid kludge trying to make sure that this will fail on old kernels */
92#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR) 92#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
93#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE) 93#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
94 94
95#ifndef O_NDELAY 95#ifndef O_NDELAY
96#define O_NDELAY O_NONBLOCK 96#define O_NDELAY O_NONBLOCK
diff --git a/include/uapi/linux/usb/ch11.h b/include/uapi/linux/usb/ch11.h
index 7692dc69ccf7..331499d597fa 100644
--- a/include/uapi/linux/usb/ch11.h
+++ b/include/uapi/linux/usb/ch11.h
@@ -11,6 +11,17 @@
11 11
12#include <linux/types.h> /* __u8 etc */ 12#include <linux/types.h> /* __u8 etc */
13 13
14/* This is arbitrary.
15 * From USB 2.0 spec Table 11-13, offset 7, a hub can
16 * have up to 255 ports. The most yet reported is 10.
17 *
18 * Current Wireless USB host hardware (Intel i1480 for example) allows
19 * up to 22 devices to connect. Upcoming hardware might raise that
20 * limit. Because the arrays need to add a bit for hub status data, we
21 * use 31, so plus one evens out to four bytes.
22 */
23#define USB_MAXCHILDREN 31
24
14/* 25/*
15 * Hub request types 26 * Hub request types
16 */ 27 */
diff --git a/include/xen/interface/io/blkif.h b/include/xen/interface/io/blkif.h
index ffd4652de91c..65e12099ef89 100644
--- a/include/xen/interface/io/blkif.h
+++ b/include/xen/interface/io/blkif.h
@@ -103,12 +103,46 @@ typedef uint64_t blkif_sector_t;
103#define BLKIF_OP_DISCARD 5 103#define BLKIF_OP_DISCARD 5
104 104
105/* 105/*
106 * Recognized if "feature-max-indirect-segments" in present in the backend
107 * xenbus info. The "feature-max-indirect-segments" node contains the maximum
108 * number of segments allowed by the backend per request. If the node is
109 * present, the frontend might use blkif_request_indirect structs in order to
110 * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The
111 * maximum number of indirect segments is fixed by the backend, but the
112 * frontend can issue requests with any number of indirect segments as long as
113 * it's less than the number provided by the backend. The indirect_grefs field
114 * in blkif_request_indirect should be filled by the frontend with the
115 * grant references of the pages that are holding the indirect segments.
116 * This pages are filled with an array of blkif_request_segment_aligned
117 * that hold the information about the segments. The number of indirect
118 * pages to use is determined by the maximum number of segments
119 * a indirect request contains. Every indirect page can contain a maximum
120 * of 512 segments (PAGE_SIZE/sizeof(blkif_request_segment_aligned)),
121 * so to calculate the number of indirect pages to use we have to do
122 * ceil(indirect_segments/512).
123 *
124 * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not*
125 * create the "feature-max-indirect-segments" node!
126 */
127#define BLKIF_OP_INDIRECT 6
128
129/*
106 * Maximum scatter/gather segments per request. 130 * Maximum scatter/gather segments per request.
107 * This is carefully chosen so that sizeof(struct blkif_ring) <= PAGE_SIZE. 131 * This is carefully chosen so that sizeof(struct blkif_ring) <= PAGE_SIZE.
108 * NB. This could be 12 if the ring indexes weren't stored in the same page. 132 * NB. This could be 12 if the ring indexes weren't stored in the same page.
109 */ 133 */
110#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 134#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
111 135
136#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
137
138struct blkif_request_segment_aligned {
139 grant_ref_t gref; /* reference to I/O buffer frame */
140 /* @first_sect: first sector in frame to transfer (inclusive). */
141 /* @last_sect: last sector in frame to transfer (inclusive). */
142 uint8_t first_sect, last_sect;
143 uint16_t _pad; /* padding to make it 8 bytes, so it's cache-aligned */
144} __attribute__((__packed__));
145
112struct blkif_request_rw { 146struct blkif_request_rw {
113 uint8_t nr_segments; /* number of segments */ 147 uint8_t nr_segments; /* number of segments */
114 blkif_vdev_t handle; /* only for read/write requests */ 148 blkif_vdev_t handle; /* only for read/write requests */
@@ -147,12 +181,31 @@ struct blkif_request_other {
147 uint64_t id; /* private guest value, echoed in resp */ 181 uint64_t id; /* private guest value, echoed in resp */
148} __attribute__((__packed__)); 182} __attribute__((__packed__));
149 183
184struct blkif_request_indirect {
185 uint8_t indirect_op;
186 uint16_t nr_segments;
187#ifdef CONFIG_X86_64
188 uint32_t _pad1; /* offsetof(blkif_...,u.indirect.id) == 8 */
189#endif
190 uint64_t id;
191 blkif_sector_t sector_number;
192 blkif_vdev_t handle;
193 uint16_t _pad2;
194 grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
195#ifdef CONFIG_X86_64
196 uint32_t _pad3; /* make it 64 byte aligned */
197#else
198 uint64_t _pad3; /* make it 64 byte aligned */
199#endif
200} __attribute__((__packed__));
201
150struct blkif_request { 202struct blkif_request {
151 uint8_t operation; /* BLKIF_OP_??? */ 203 uint8_t operation; /* BLKIF_OP_??? */
152 union { 204 union {
153 struct blkif_request_rw rw; 205 struct blkif_request_rw rw;
154 struct blkif_request_discard discard; 206 struct blkif_request_discard discard;
155 struct blkif_request_other other; 207 struct blkif_request_other other;
208 struct blkif_request_indirect indirect;
156 } u; 209 } u;
157} __attribute__((__packed__)); 210} __attribute__((__packed__));
158 211
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h
index 75271b9a8f61..7d28aff605c7 100644
--- a/include/xen/interface/io/ring.h
+++ b/include/xen/interface/io/ring.h
@@ -188,6 +188,11 @@ struct __name##_back_ring { \
188#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ 188#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \
189 (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) 189 (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
190 190
191/* Ill-behaved frontend determination: Can there be this many requests? */
192#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \
193 (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
194
195
191#define RING_PUSH_REQUESTS(_r) do { \ 196#define RING_PUSH_REQUESTS(_r) do { \
192 wmb(); /* back sees requests /before/ updated producer index */ \ 197 wmb(); /* back sees requests /before/ updated producer index */ \
193 (_r)->sring->req_prod = (_r)->req_prod_pvt; \ 198 (_r)->sring->req_prod = (_r)->req_prod_pvt; \
diff --git a/init/calibrate.c b/init/calibrate.c
index fda0a7b0f06c..520702db9acc 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -31,7 +31,7 @@ __setup("lpj=", lpj_setup);
31#define DELAY_CALIBRATION_TICKS ((HZ < 100) ? 1 : (HZ/100)) 31#define DELAY_CALIBRATION_TICKS ((HZ < 100) ? 1 : (HZ/100))
32#define MAX_DIRECT_CALIBRATION_RETRIES 5 32#define MAX_DIRECT_CALIBRATION_RETRIES 5
33 33
34static unsigned long __cpuinit calibrate_delay_direct(void) 34static unsigned long calibrate_delay_direct(void)
35{ 35{
36 unsigned long pre_start, start, post_start; 36 unsigned long pre_start, start, post_start;
37 unsigned long pre_end, end, post_end; 37 unsigned long pre_end, end, post_end;
@@ -166,7 +166,10 @@ static unsigned long __cpuinit calibrate_delay_direct(void)
166 return 0; 166 return 0;
167} 167}
168#else 168#else
169static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;} 169static unsigned long calibrate_delay_direct(void)
170{
171 return 0;
172}
170#endif 173#endif
171 174
172/* 175/*
@@ -180,7 +183,7 @@ static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;}
180 */ 183 */
181#define LPS_PREC 8 184#define LPS_PREC 8
182 185
183static unsigned long __cpuinit calibrate_delay_converge(void) 186static unsigned long calibrate_delay_converge(void)
184{ 187{
185 /* First stage - slowly accelerate to find initial bounds */ 188 /* First stage - slowly accelerate to find initial bounds */
186 unsigned long lpj, lpj_base, ticks, loopadd, loopadd_base, chop_limit; 189 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 };
254 * Architectures should override this function if a faster calibration 257 * Architectures should override this function if a faster calibration
255 * method is available. 258 * method is available.
256 */ 259 */
257unsigned long __attribute__((weak)) __cpuinit calibrate_delay_is_known(void) 260unsigned long __attribute__((weak)) calibrate_delay_is_known(void)
258{ 261{
259 return 0; 262 return 0;
260} 263}
261 264
262void __cpuinit calibrate_delay(void) 265void calibrate_delay(void)
263{ 266{
264 unsigned long lpj; 267 unsigned long lpj;
265 static bool printed; 268 static bool printed;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0e0b20b8c5db..789ec4683db3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1845,36 +1845,43 @@ out:
1845EXPORT_SYMBOL_GPL(cgroup_path); 1845EXPORT_SYMBOL_GPL(cgroup_path);
1846 1846
1847/** 1847/**
1848 * task_cgroup_path_from_hierarchy - cgroup path of a task on a hierarchy 1848 * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
1849 * @task: target task 1849 * @task: target task
1850 * @hierarchy_id: the hierarchy to look up @task's cgroup from
1851 * @buf: the buffer to write the path into 1850 * @buf: the buffer to write the path into
1852 * @buflen: the length of the buffer 1851 * @buflen: the length of the buffer
1853 * 1852 *
1854 * Determine @task's cgroup on the hierarchy specified by @hierarchy_id and 1853 * Determine @task's cgroup on the first (the one with the lowest non-zero
1855 * copy its path into @buf. This function grabs cgroup_mutex and shouldn't 1854 * hierarchy_id) cgroup hierarchy and copy its path into @buf. This
1856 * be used inside locks used by cgroup controller callbacks. 1855 * function grabs cgroup_mutex and shouldn't be used inside locks used by
1856 * cgroup controller callbacks.
1857 *
1858 * Returns 0 on success, fails with -%ENAMETOOLONG if @buflen is too short.
1857 */ 1859 */
1858int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, 1860int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
1859 char *buf, size_t buflen)
1860{ 1861{
1861 struct cgroupfs_root *root; 1862 struct cgroupfs_root *root;
1862 struct cgroup *cgrp = NULL; 1863 struct cgroup *cgrp;
1863 int ret = -ENOENT; 1864 int hierarchy_id = 1, ret = 0;
1865
1866 if (buflen < 2)
1867 return -ENAMETOOLONG;
1864 1868
1865 mutex_lock(&cgroup_mutex); 1869 mutex_lock(&cgroup_mutex);
1866 1870
1867 root = idr_find(&cgroup_hierarchy_idr, hierarchy_id); 1871 root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id);
1872
1868 if (root) { 1873 if (root) {
1869 cgrp = task_cgroup_from_root(task, root); 1874 cgrp = task_cgroup_from_root(task, root);
1870 ret = cgroup_path(cgrp, buf, buflen); 1875 ret = cgroup_path(cgrp, buf, buflen);
1876 } else {
1877 /* if no hierarchy exists, everyone is in "/" */
1878 memcpy(buf, "/", 2);
1871 } 1879 }
1872 1880
1873 mutex_unlock(&cgroup_mutex); 1881 mutex_unlock(&cgroup_mutex);
1874
1875 return ret; 1882 return ret;
1876} 1883}
1877EXPORT_SYMBOL_GPL(task_cgroup_path_from_hierarchy); 1884EXPORT_SYMBOL_GPL(task_cgroup_path);
1878 1885
1879/* 1886/*
1880 * Control Group taskset 1887 * Control Group taskset
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 198a38883e64..b2b227b82123 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -366,7 +366,7 @@ EXPORT_SYMBOL(cpu_down);
366#endif /*CONFIG_HOTPLUG_CPU*/ 366#endif /*CONFIG_HOTPLUG_CPU*/
367 367
368/* Requires cpu_add_remove_lock to be held */ 368/* Requires cpu_add_remove_lock to be held */
369static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen) 369static int _cpu_up(unsigned int cpu, int tasks_frozen)
370{ 370{
371 int ret, nr_calls = 0; 371 int ret, nr_calls = 0;
372 void *hcpu = (void *)(long)cpu; 372 void *hcpu = (void *)(long)cpu;
@@ -419,7 +419,7 @@ out:
419 return ret; 419 return ret;
420} 420}
421 421
422int __cpuinit cpu_up(unsigned int cpu) 422int cpu_up(unsigned int cpu)
423{ 423{
424 int err = 0; 424 int err = 0;
425 425
@@ -618,7 +618,7 @@ core_initcall(cpu_hotplug_pm_sync_init);
618 * It must be called by the arch code on the new cpu, before the new cpu 618 * It must be called by the arch code on the new cpu, before the new cpu
619 * enables interrupts and before the "boot" cpu returns from __cpu_up(). 619 * enables interrupts and before the "boot" cpu returns from __cpu_up().
620 */ 620 */
621void __cpuinit notify_cpu_starting(unsigned int cpu) 621void notify_cpu_starting(unsigned int cpu)
622{ 622{
623 unsigned long val = CPU_STARTING; 623 unsigned long val = CPU_STARTING;
624 624
diff --git a/kernel/events/core.c b/kernel/events/core.c
index eba8fb5834ae..f86599e8c123 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6234,8 +6234,6 @@ perf_event_mux_interval_ms_store(struct device *dev,
6234 return count; 6234 return count;
6235} 6235}
6236 6236
6237#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
6238
6239static struct device_attribute pmu_dev_attrs[] = { 6237static struct device_attribute pmu_dev_attrs[] = {
6240 __ATTR_RO(type), 6238 __ATTR_RO(type),
6241 __ATTR_RW(perf_event_mux_interval_ms), 6239 __ATTR_RW(perf_event_mux_interval_ms),
@@ -7630,7 +7628,7 @@ static void __init perf_event_init_all_cpus(void)
7630 } 7628 }
7631} 7629}
7632 7630
7633static void __cpuinit perf_event_init_cpu(int cpu) 7631static void perf_event_init_cpu(int cpu)
7634{ 7632{
7635 struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu); 7633 struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
7636 7634
@@ -7719,7 +7717,7 @@ static struct notifier_block perf_reboot_notifier = {
7719 .priority = INT_MIN, 7717 .priority = INT_MIN,
7720}; 7718};
7721 7719
7722static int __cpuinit 7720static int
7723perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) 7721perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
7724{ 7722{
7725 unsigned int cpu = (long)hcpu; 7723 unsigned int cpu = (long)hcpu;
diff --git a/kernel/fork.c b/kernel/fork.c
index 66635c80a813..403d2bb8a968 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1546,7 +1546,7 @@ static inline void init_idle_pids(struct pid_link *links)
1546 } 1546 }
1547} 1547}
1548 1548
1549struct task_struct * __cpuinit fork_idle(int cpu) 1549struct task_struct *fork_idle(int cpu)
1550{ 1550{
1551 struct task_struct *task; 1551 struct task_struct *task;
1552 task = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0); 1552 task = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0);
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index f0f4fe29cd21..383319bae3f7 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1659,7 +1659,7 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
1659/* 1659/*
1660 * Functions related to boot-time initialization: 1660 * Functions related to boot-time initialization:
1661 */ 1661 */
1662static void __cpuinit init_hrtimers_cpu(int cpu) 1662static void init_hrtimers_cpu(int cpu)
1663{ 1663{
1664 struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu); 1664 struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
1665 int i; 1665 int i;
@@ -1740,7 +1740,7 @@ static void migrate_hrtimers(int scpu)
1740 1740
1741#endif /* CONFIG_HOTPLUG_CPU */ 1741#endif /* CONFIG_HOTPLUG_CPU */
1742 1742
1743static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self, 1743static int hrtimer_cpu_notify(struct notifier_block *self,
1744 unsigned long action, void *hcpu) 1744 unsigned long action, void *hcpu)
1745{ 1745{
1746 int scpu = (long)hcpu; 1746 int scpu = (long)hcpu;
@@ -1773,7 +1773,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
1773 return NOTIFY_OK; 1773 return NOTIFY_OK;
1774} 1774}
1775 1775
1776static struct notifier_block __cpuinitdata hrtimers_nb = { 1776static struct notifier_block hrtimers_nb = {
1777 .notifier_call = hrtimer_cpu_notify, 1777 .notifier_call = hrtimer_cpu_notify,
1778}; 1778};
1779 1779
diff --git a/kernel/power/autosleep.c b/kernel/power/autosleep.c
index c6422ffeda9a..9012ecf7b814 100644
--- a/kernel/power/autosleep.c
+++ b/kernel/power/autosleep.c
@@ -32,7 +32,8 @@ static void try_to_suspend(struct work_struct *work)
32 32
33 mutex_lock(&autosleep_lock); 33 mutex_lock(&autosleep_lock);
34 34
35 if (!pm_save_wakeup_count(initial_count)) { 35 if (!pm_save_wakeup_count(initial_count) ||
36 system_state != SYSTEM_RUNNING) {
36 mutex_unlock(&autosleep_lock); 37 mutex_unlock(&autosleep_lock);
37 goto out; 38 goto out;
38 } 39 }
diff --git a/kernel/printk.c b/kernel/printk.c
index d37d45c90ae6..69b0890ed7e5 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1921,7 +1921,7 @@ void resume_console(void)
1921 * called when a new CPU comes online (or fails to come up), and ensures 1921 * called when a new CPU comes online (or fails to come up), and ensures
1922 * that any such output gets printed. 1922 * that any such output gets printed.
1923 */ 1923 */
1924static int __cpuinit console_cpu_notify(struct notifier_block *self, 1924static int console_cpu_notify(struct notifier_block *self,
1925 unsigned long action, void *hcpu) 1925 unsigned long action, void *hcpu)
1926{ 1926{
1927 switch (action) { 1927 switch (action) {
diff --git a/kernel/profile.c b/kernel/profile.c
index 0bf400737660..6631e1ef55ab 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -331,7 +331,7 @@ out:
331 put_cpu(); 331 put_cpu();
332} 332}
333 333
334static int __cpuinit profile_cpu_callback(struct notifier_block *info, 334static int profile_cpu_callback(struct notifier_block *info,
335 unsigned long action, void *__cpu) 335 unsigned long action, void *__cpu)
336{ 336{
337 int node, cpu = (unsigned long)__cpu; 337 int node, cpu = (unsigned long)__cpu;
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index b1fa5510388d..f4871e52c546 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -1476,7 +1476,7 @@ rcu_torture_shutdown(void *arg)
1476 * Execute random CPU-hotplug operations at the interval specified 1476 * Execute random CPU-hotplug operations at the interval specified
1477 * by the onoff_interval. 1477 * by the onoff_interval.
1478 */ 1478 */
1479static int __cpuinit 1479static int
1480rcu_torture_onoff(void *arg) 1480rcu_torture_onoff(void *arg)
1481{ 1481{
1482 int cpu; 1482 int cpu;
@@ -1558,7 +1558,7 @@ rcu_torture_onoff(void *arg)
1558 return 0; 1558 return 0;
1559} 1559}
1560 1560
1561static int __cpuinit 1561static int
1562rcu_torture_onoff_init(void) 1562rcu_torture_onoff_init(void)
1563{ 1563{
1564 int ret; 1564 int ret;
@@ -1601,7 +1601,7 @@ static void rcu_torture_onoff_cleanup(void)
1601 * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then 1601 * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then
1602 * induces a CPU stall for the time specified by stall_cpu. 1602 * induces a CPU stall for the time specified by stall_cpu.
1603 */ 1603 */
1604static int __cpuinit rcu_torture_stall(void *args) 1604static int rcu_torture_stall(void *args)
1605{ 1605{
1606 unsigned long stop_at; 1606 unsigned long stop_at;
1607 1607
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index e08abb9461ac..068de3a93606 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -2910,7 +2910,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
2910 * can accept some slop in the rsp->completed access due to the fact 2910 * can accept some slop in the rsp->completed access due to the fact
2911 * that this CPU cannot possibly have any RCU callbacks in flight yet. 2911 * that this CPU cannot possibly have any RCU callbacks in flight yet.
2912 */ 2912 */
2913static void __cpuinit 2913static void
2914rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible) 2914rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
2915{ 2915{
2916 unsigned long flags; 2916 unsigned long flags;
@@ -2962,7 +2962,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
2962 mutex_unlock(&rsp->onoff_mutex); 2962 mutex_unlock(&rsp->onoff_mutex);
2963} 2963}
2964 2964
2965static void __cpuinit rcu_prepare_cpu(int cpu) 2965static void rcu_prepare_cpu(int cpu)
2966{ 2966{
2967 struct rcu_state *rsp; 2967 struct rcu_state *rsp;
2968 2968
@@ -2974,7 +2974,7 @@ static void __cpuinit rcu_prepare_cpu(int cpu)
2974/* 2974/*
2975 * Handle CPU online/offline notification events. 2975 * Handle CPU online/offline notification events.
2976 */ 2976 */
2977static int __cpuinit rcu_cpu_notify(struct notifier_block *self, 2977static int rcu_cpu_notify(struct notifier_block *self,
2978 unsigned long action, void *hcpu) 2978 unsigned long action, void *hcpu)
2979{ 2979{
2980 long cpu = (long)hcpu; 2980 long cpu = (long)hcpu;
diff --git a/kernel/rcutree.h b/kernel/rcutree.h
index 4a39d364493c..b3832581043c 100644
--- a/kernel/rcutree.h
+++ b/kernel/rcutree.h
@@ -521,10 +521,10 @@ static void invoke_rcu_callbacks_kthread(void);
521static bool rcu_is_callbacks_kthread(void); 521static bool rcu_is_callbacks_kthread(void);
522#ifdef CONFIG_RCU_BOOST 522#ifdef CONFIG_RCU_BOOST
523static void rcu_preempt_do_callbacks(void); 523static void rcu_preempt_do_callbacks(void);
524static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp, 524static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
525 struct rcu_node *rnp); 525 struct rcu_node *rnp);
526#endif /* #ifdef CONFIG_RCU_BOOST */ 526#endif /* #ifdef CONFIG_RCU_BOOST */
527static void __cpuinit rcu_prepare_kthreads(int cpu); 527static void rcu_prepare_kthreads(int cpu);
528static void rcu_cleanup_after_idle(int cpu); 528static void rcu_cleanup_after_idle(int cpu);
529static void rcu_prepare_for_idle(int cpu); 529static void rcu_prepare_for_idle(int cpu);
530static void rcu_idle_count_callbacks_posted(void); 530static void rcu_idle_count_callbacks_posted(void);
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 63098a59216e..769e12e3151b 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -1352,7 +1352,7 @@ static void rcu_preempt_boost_start_gp(struct rcu_node *rnp)
1352 * already exist. We only create this kthread for preemptible RCU. 1352 * already exist. We only create this kthread for preemptible RCU.
1353 * Returns zero if all is well, a negated errno otherwise. 1353 * Returns zero if all is well, a negated errno otherwise.
1354 */ 1354 */
1355static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp, 1355static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
1356 struct rcu_node *rnp) 1356 struct rcu_node *rnp)
1357{ 1357{
1358 int rnp_index = rnp - &rsp->node[0]; 1358 int rnp_index = rnp - &rsp->node[0];
@@ -1507,7 +1507,7 @@ static int __init rcu_spawn_kthreads(void)
1507} 1507}
1508early_initcall(rcu_spawn_kthreads); 1508early_initcall(rcu_spawn_kthreads);
1509 1509
1510static void __cpuinit rcu_prepare_kthreads(int cpu) 1510static void rcu_prepare_kthreads(int cpu)
1511{ 1511{
1512 struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu); 1512 struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu);
1513 struct rcu_node *rnp = rdp->mynode; 1513 struct rcu_node *rnp = rdp->mynode;
@@ -1549,7 +1549,7 @@ static int __init rcu_scheduler_really_started(void)
1549} 1549}
1550early_initcall(rcu_scheduler_really_started); 1550early_initcall(rcu_scheduler_really_started);
1551 1551
1552static void __cpuinit rcu_prepare_kthreads(int cpu) 1552static void rcu_prepare_kthreads(int cpu)
1553{ 1553{
1554} 1554}
1555 1555
diff --git a/kernel/relay.c b/kernel/relay.c
index b91488ba2e5a..5001c9887db1 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -516,7 +516,7 @@ static void setup_callbacks(struct rchan *chan,
516 * 516 *
517 * Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD) 517 * Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
518 */ 518 */
519static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb, 519static int relay_hotcpu_callback(struct notifier_block *nb,
520 unsigned long action, 520 unsigned long action,
521 void *hcpu) 521 void *hcpu)
522{ 522{
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0d8eb4525e76..b7c32cb7bfeb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4133,7 +4133,7 @@ void show_state_filter(unsigned long state_filter)
4133 debug_show_all_locks(); 4133 debug_show_all_locks();
4134} 4134}
4135 4135
4136void __cpuinit init_idle_bootup_task(struct task_struct *idle) 4136void init_idle_bootup_task(struct task_struct *idle)
4137{ 4137{
4138 idle->sched_class = &idle_sched_class; 4138 idle->sched_class = &idle_sched_class;
4139} 4139}
@@ -4146,7 +4146,7 @@ void __cpuinit init_idle_bootup_task(struct task_struct *idle)
4146 * NOTE: this function does not set the idle thread's NEED_RESCHED 4146 * NOTE: this function does not set the idle thread's NEED_RESCHED
4147 * flag, to make booting more robust. 4147 * flag, to make booting more robust.
4148 */ 4148 */
4149void __cpuinit init_idle(struct task_struct *idle, int cpu) 4149void init_idle(struct task_struct *idle, int cpu)
4150{ 4150{
4151 struct rq *rq = cpu_rq(cpu); 4151 struct rq *rq = cpu_rq(cpu);
4152 unsigned long flags; 4152 unsigned long flags;
@@ -4630,7 +4630,7 @@ static void set_rq_offline(struct rq *rq)
4630 * migration_call - callback that gets triggered when a CPU is added. 4630 * migration_call - callback that gets triggered when a CPU is added.
4631 * Here we can start up the necessary migration thread for the new CPU. 4631 * Here we can start up the necessary migration thread for the new CPU.
4632 */ 4632 */
4633static int __cpuinit 4633static int
4634migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) 4634migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
4635{ 4635{
4636 int cpu = (long)hcpu; 4636 int cpu = (long)hcpu;
@@ -4684,12 +4684,12 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
4684 * happens before everything else. This has to be lower priority than 4684 * happens before everything else. This has to be lower priority than
4685 * the notifier in the perf_event subsystem, though. 4685 * the notifier in the perf_event subsystem, though.
4686 */ 4686 */
4687static struct notifier_block __cpuinitdata migration_notifier = { 4687static struct notifier_block migration_notifier = {
4688 .notifier_call = migration_call, 4688 .notifier_call = migration_call,
4689 .priority = CPU_PRI_MIGRATION, 4689 .priority = CPU_PRI_MIGRATION,
4690}; 4690};
4691 4691
4692static int __cpuinit sched_cpu_active(struct notifier_block *nfb, 4692static int sched_cpu_active(struct notifier_block *nfb,
4693 unsigned long action, void *hcpu) 4693 unsigned long action, void *hcpu)
4694{ 4694{
4695 switch (action & ~CPU_TASKS_FROZEN) { 4695 switch (action & ~CPU_TASKS_FROZEN) {
@@ -4702,7 +4702,7 @@ static int __cpuinit sched_cpu_active(struct notifier_block *nfb,
4702 } 4702 }
4703} 4703}
4704 4704
4705static int __cpuinit sched_cpu_inactive(struct notifier_block *nfb, 4705static int sched_cpu_inactive(struct notifier_block *nfb,
4706 unsigned long action, void *hcpu) 4706 unsigned long action, void *hcpu)
4707{ 4707{
4708 switch (action & ~CPU_TASKS_FROZEN) { 4708 switch (action & ~CPU_TASKS_FROZEN) {
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f77f9c527449..bb456f44b7b1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5506,7 +5506,7 @@ void nohz_balance_enter_idle(int cpu)
5506 set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)); 5506 set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
5507} 5507}
5508 5508
5509static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb, 5509static int sched_ilb_notifier(struct notifier_block *nfb,
5510 unsigned long action, void *hcpu) 5510 unsigned long action, void *hcpu)
5511{ 5511{
5512 switch (action & ~CPU_TASKS_FROZEN) { 5512 switch (action & ~CPU_TASKS_FROZEN) {
diff --git a/kernel/smp.c b/kernel/smp.c
index 4dba0f7b72ad..fe9f773d7114 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
73 return NOTIFY_OK; 73 return NOTIFY_OK;
74} 74}
75 75
76static struct notifier_block __cpuinitdata hotplug_cfd_notifier = { 76static struct notifier_block hotplug_cfd_notifier = {
77 .notifier_call = hotplug_cfd, 77 .notifier_call = hotplug_cfd,
78}; 78};
79 79
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index 02fc5c933673..eb89e1807408 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -24,7 +24,7 @@
24 */ 24 */
25static DEFINE_PER_CPU(struct task_struct *, idle_threads); 25static DEFINE_PER_CPU(struct task_struct *, idle_threads);
26 26
27struct task_struct * __cpuinit idle_thread_get(unsigned int cpu) 27struct task_struct *idle_thread_get(unsigned int cpu)
28{ 28{
29 struct task_struct *tsk = per_cpu(idle_threads, cpu); 29 struct task_struct *tsk = per_cpu(idle_threads, cpu);
30 30
diff --git a/kernel/softirq.c b/kernel/softirq.c
index ca25e6e704a2..be3d3514c325 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -699,7 +699,7 @@ void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq)
699} 699}
700EXPORT_SYMBOL(send_remote_softirq); 700EXPORT_SYMBOL(send_remote_softirq);
701 701
702static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self, 702static int remote_softirq_cpu_notify(struct notifier_block *self,
703 unsigned long action, void *hcpu) 703 unsigned long action, void *hcpu)
704{ 704{
705 /* 705 /*
@@ -728,7 +728,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
728 return NOTIFY_OK; 728 return NOTIFY_OK;
729} 729}
730 730
731static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = { 731static struct notifier_block remote_softirq_cpu_notifier = {
732 .notifier_call = remote_softirq_cpu_notify, 732 .notifier_call = remote_softirq_cpu_notify,
733}; 733};
734 734
@@ -830,7 +830,7 @@ static void takeover_tasklets(unsigned int cpu)
830} 830}
831#endif /* CONFIG_HOTPLUG_CPU */ 831#endif /* CONFIG_HOTPLUG_CPU */
832 832
833static int __cpuinit cpu_callback(struct notifier_block *nfb, 833static int cpu_callback(struct notifier_block *nfb,
834 unsigned long action, 834 unsigned long action,
835 void *hcpu) 835 void *hcpu)
836{ 836{
@@ -845,7 +845,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
845 return NOTIFY_OK; 845 return NOTIFY_OK;
846} 846}
847 847
848static struct notifier_block __cpuinitdata cpu_nfb = { 848static struct notifier_block cpu_nfb = {
849 .notifier_call = cpu_callback 849 .notifier_call = cpu_callback
850}; 850};
851 851
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 69601726a745..e80183f4a6c4 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -298,7 +298,7 @@ static int __init tick_nohz_full_setup(char *str)
298} 298}
299__setup("nohz_full=", tick_nohz_full_setup); 299__setup("nohz_full=", tick_nohz_full_setup);
300 300
301static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb, 301static int tick_nohz_cpu_down_callback(struct notifier_block *nfb,
302 unsigned long action, 302 unsigned long action,
303 void *hcpu) 303 void *hcpu)
304{ 304{
diff --git a/kernel/timer.c b/kernel/timer.c
index 15bc1b41021d..4296d13db3d1 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1505,11 +1505,11 @@ signed long __sched schedule_timeout_uninterruptible(signed long timeout)
1505} 1505}
1506EXPORT_SYMBOL(schedule_timeout_uninterruptible); 1506EXPORT_SYMBOL(schedule_timeout_uninterruptible);
1507 1507
1508static int __cpuinit init_timers_cpu(int cpu) 1508static int init_timers_cpu(int cpu)
1509{ 1509{
1510 int j; 1510 int j;
1511 struct tvec_base *base; 1511 struct tvec_base *base;
1512 static char __cpuinitdata tvec_base_done[NR_CPUS]; 1512 static char tvec_base_done[NR_CPUS];
1513 1513
1514 if (!tvec_base_done[cpu]) { 1514 if (!tvec_base_done[cpu]) {
1515 static char boot_done; 1515 static char boot_done;
@@ -1577,7 +1577,7 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea
1577 } 1577 }
1578} 1578}
1579 1579
1580static void __cpuinit migrate_timers(int cpu) 1580static void migrate_timers(int cpu)
1581{ 1581{
1582 struct tvec_base *old_base; 1582 struct tvec_base *old_base;
1583 struct tvec_base *new_base; 1583 struct tvec_base *new_base;
@@ -1610,7 +1610,7 @@ static void __cpuinit migrate_timers(int cpu)
1610} 1610}
1611#endif /* CONFIG_HOTPLUG_CPU */ 1611#endif /* CONFIG_HOTPLUG_CPU */
1612 1612
1613static int __cpuinit timer_cpu_notify(struct notifier_block *self, 1613static int timer_cpu_notify(struct notifier_block *self,
1614 unsigned long action, void *hcpu) 1614 unsigned long action, void *hcpu)
1615{ 1615{
1616 long cpu = (long)hcpu; 1616 long cpu = (long)hcpu;
@@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
1635 return NOTIFY_OK; 1635 return NOTIFY_OK;
1636} 1636}
1637 1637
1638static struct notifier_block __cpuinitdata timers_nb = { 1638static struct notifier_block timers_nb = {
1639 .notifier_call = timer_cpu_notify, 1639 .notifier_call = timer_cpu_notify,
1640}; 1640};
1641 1641
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 67708f46baae..8ce9eefc5bb4 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1441,12 +1441,22 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable,
1441 * the hashes are freed with call_rcu_sched(). 1441 * the hashes are freed with call_rcu_sched().
1442 */ 1442 */
1443static int 1443static int
1444ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip) 1444ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs)
1445{ 1445{
1446 struct ftrace_hash *filter_hash; 1446 struct ftrace_hash *filter_hash;
1447 struct ftrace_hash *notrace_hash; 1447 struct ftrace_hash *notrace_hash;
1448 int ret; 1448 int ret;
1449 1449
1450#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
1451 /*
1452 * There's a small race when adding ops that the ftrace handler
1453 * that wants regs, may be called without them. We can not
1454 * allow that handler to be called if regs is NULL.
1455 */
1456 if (regs == NULL && (ops->flags & FTRACE_OPS_FL_SAVE_REGS))
1457 return 0;
1458#endif
1459
1450 filter_hash = rcu_dereference_raw_notrace(ops->filter_hash); 1460 filter_hash = rcu_dereference_raw_notrace(ops->filter_hash);
1451 notrace_hash = rcu_dereference_raw_notrace(ops->notrace_hash); 1461 notrace_hash = rcu_dereference_raw_notrace(ops->notrace_hash);
1452 1462
@@ -4218,7 +4228,7 @@ static inline void ftrace_startup_enable(int command) { }
4218# define ftrace_shutdown_sysctl() do { } while (0) 4228# define ftrace_shutdown_sysctl() do { } while (0)
4219 4229
4220static inline int 4230static inline int
4221ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip) 4231ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs)
4222{ 4232{
4223 return 1; 4233 return 1;
4224} 4234}
@@ -4241,7 +4251,7 @@ ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip,
4241 do_for_each_ftrace_op(op, ftrace_control_list) { 4251 do_for_each_ftrace_op(op, ftrace_control_list) {
4242 if (!(op->flags & FTRACE_OPS_FL_STUB) && 4252 if (!(op->flags & FTRACE_OPS_FL_STUB) &&
4243 !ftrace_function_local_disabled(op) && 4253 !ftrace_function_local_disabled(op) &&
4244 ftrace_ops_test(op, ip)) 4254 ftrace_ops_test(op, ip, regs))
4245 op->func(ip, parent_ip, op, regs); 4255 op->func(ip, parent_ip, op, regs);
4246 } while_for_each_ftrace_op(op); 4256 } while_for_each_ftrace_op(op);
4247 trace_recursion_clear(TRACE_CONTROL_BIT); 4257 trace_recursion_clear(TRACE_CONTROL_BIT);
@@ -4274,7 +4284,7 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
4274 */ 4284 */
4275 preempt_disable_notrace(); 4285 preempt_disable_notrace();
4276 do_for_each_ftrace_op(op, ftrace_ops_list) { 4286 do_for_each_ftrace_op(op, ftrace_ops_list) {
4277 if (ftrace_ops_test(op, ip)) 4287 if (ftrace_ops_test(op, ip, regs))
4278 op->func(ip, parent_ip, op, regs); 4288 op->func(ip, parent_ip, op, regs);
4279 } while_for_each_ftrace_op(op); 4289 } while_for_each_ftrace_op(op);
4280 preempt_enable_notrace(); 4290 preempt_enable_notrace();
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index e444ff88f0a4..cc2f66f68dc5 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -36,11 +36,11 @@ int ring_buffer_print_entry_header(struct trace_seq *s)
36{ 36{
37 int ret; 37 int ret;
38 38
39 ret = trace_seq_printf(s, "# compressed entry header\n"); 39 ret = trace_seq_puts(s, "# compressed entry header\n");
40 ret = trace_seq_printf(s, "\ttype_len : 5 bits\n"); 40 ret = trace_seq_puts(s, "\ttype_len : 5 bits\n");
41 ret = trace_seq_printf(s, "\ttime_delta : 27 bits\n"); 41 ret = trace_seq_puts(s, "\ttime_delta : 27 bits\n");
42 ret = trace_seq_printf(s, "\tarray : 32 bits\n"); 42 ret = trace_seq_puts(s, "\tarray : 32 bits\n");
43 ret = trace_seq_printf(s, "\n"); 43 ret = trace_seq_putc(s, '\n');
44 ret = trace_seq_printf(s, "\tpadding : type == %d\n", 44 ret = trace_seq_printf(s, "\tpadding : type == %d\n",
45 RINGBUF_TYPE_PADDING); 45 RINGBUF_TYPE_PADDING);
46 ret = trace_seq_printf(s, "\ttime_extend : type == %d\n", 46 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,
1066} 1066}
1067 1067
1068/** 1068/**
1069 * check_pages - integrity check of buffer pages 1069 * rb_check_pages - integrity check of buffer pages
1070 * @cpu_buffer: CPU buffer with pages to test 1070 * @cpu_buffer: CPU buffer with pages to test
1071 * 1071 *
1072 * As a safety measure we check to make sure the data pages have not 1072 * 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,
1258#endif 1258#endif
1259 1259
1260/** 1260/**
1261 * ring_buffer_alloc - allocate a new ring_buffer 1261 * __ring_buffer_alloc - allocate a new ring_buffer
1262 * @size: the size in bytes per cpu that is needed. 1262 * @size: the size in bytes per cpu that is needed.
1263 * @flags: attributes to set for the ring buffer. 1263 * @flags: attributes to set for the ring buffer.
1264 * 1264 *
@@ -1607,6 +1607,7 @@ static void update_pages_handler(struct work_struct *work)
1607 * ring_buffer_resize - resize the ring buffer 1607 * ring_buffer_resize - resize the ring buffer
1608 * @buffer: the buffer to resize. 1608 * @buffer: the buffer to resize.
1609 * @size: the new size. 1609 * @size: the new size.
1610 * @cpu_id: the cpu buffer to resize
1610 * 1611 *
1611 * Minimum size is 2 * BUF_PAGE_SIZE. 1612 * Minimum size is 2 * BUF_PAGE_SIZE.
1612 * 1613 *
@@ -3956,11 +3957,11 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
3956 * expected. 3957 * expected.
3957 * 3958 *
3958 * After a sequence of ring_buffer_read_prepare calls, the user is 3959 * After a sequence of ring_buffer_read_prepare calls, the user is
3959 * expected to make at least one call to ring_buffer_prepare_sync. 3960 * expected to make at least one call to ring_buffer_read_prepare_sync.
3960 * Afterwards, ring_buffer_read_start is invoked to get things going 3961 * Afterwards, ring_buffer_read_start is invoked to get things going
3961 * for real. 3962 * for real.
3962 * 3963 *
3963 * This overall must be paired with ring_buffer_finish. 3964 * This overall must be paired with ring_buffer_read_finish.
3964 */ 3965 */
3965struct ring_buffer_iter * 3966struct ring_buffer_iter *
3966ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu) 3967ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)
@@ -4009,7 +4010,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_prepare_sync);
4009 * an intervening ring_buffer_read_prepare_sync must have been 4010 * an intervening ring_buffer_read_prepare_sync must have been
4010 * performed. 4011 * performed.
4011 * 4012 *
4012 * Must be paired with ring_buffer_finish. 4013 * Must be paired with ring_buffer_read_finish.
4013 */ 4014 */
4014void 4015void
4015ring_buffer_read_start(struct ring_buffer_iter *iter) 4016ring_buffer_read_start(struct ring_buffer_iter *iter)
@@ -4031,7 +4032,7 @@ ring_buffer_read_start(struct ring_buffer_iter *iter)
4031EXPORT_SYMBOL_GPL(ring_buffer_read_start); 4032EXPORT_SYMBOL_GPL(ring_buffer_read_start);
4032 4033
4033/** 4034/**
4034 * ring_buffer_finish - finish reading the iterator of the buffer 4035 * ring_buffer_read_finish - finish reading the iterator of the buffer
4035 * @iter: The iterator retrieved by ring_buffer_start 4036 * @iter: The iterator retrieved by ring_buffer_start
4036 * 4037 *
4037 * This re-enables the recording to the buffer, and frees the 4038 * This re-enables the recording to the buffer, and frees the
@@ -4346,6 +4347,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
4346/** 4347/**
4347 * ring_buffer_alloc_read_page - allocate a page to read from buffer 4348 * ring_buffer_alloc_read_page - allocate a page to read from buffer
4348 * @buffer: the buffer to allocate for. 4349 * @buffer: the buffer to allocate for.
4350 * @cpu: the cpu buffer to allocate.
4349 * 4351 *
4350 * This function is used in conjunction with ring_buffer_read_page. 4352 * This function is used in conjunction with ring_buffer_read_page.
4351 * When reading a full page from the ring buffer, these functions 4353 * When reading a full page from the ring buffer, these functions
@@ -4403,7 +4405,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_free_read_page);
4403 * to swap with a page in the ring buffer. 4405 * to swap with a page in the ring buffer.
4404 * 4406 *
4405 * for example: 4407 * for example:
4406 * rpage = ring_buffer_alloc_read_page(buffer); 4408 * rpage = ring_buffer_alloc_read_page(buffer, cpu);
4407 * if (!rpage) 4409 * if (!rpage)
4408 * return error; 4410 * return error;
4409 * ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0); 4411 * ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0cd500bffd9b..882ec1dd1515 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1224,18 +1224,17 @@ void tracing_reset_current(int cpu)
1224 tracing_reset(&global_trace.trace_buffer, cpu); 1224 tracing_reset(&global_trace.trace_buffer, cpu);
1225} 1225}
1226 1226
1227/* Must have trace_types_lock held */
1227void tracing_reset_all_online_cpus(void) 1228void tracing_reset_all_online_cpus(void)
1228{ 1229{
1229 struct trace_array *tr; 1230 struct trace_array *tr;
1230 1231
1231 mutex_lock(&trace_types_lock);
1232 list_for_each_entry(tr, &ftrace_trace_arrays, list) { 1232 list_for_each_entry(tr, &ftrace_trace_arrays, list) {
1233 tracing_reset_online_cpus(&tr->trace_buffer); 1233 tracing_reset_online_cpus(&tr->trace_buffer);
1234#ifdef CONFIG_TRACER_MAX_TRACE 1234#ifdef CONFIG_TRACER_MAX_TRACE
1235 tracing_reset_online_cpus(&tr->max_buffer); 1235 tracing_reset_online_cpus(&tr->max_buffer);
1236#endif 1236#endif
1237 } 1237 }
1238 mutex_unlock(&trace_types_lock);
1239} 1238}
1240 1239
1241#define SAVED_CMDLINES 128 1240#define SAVED_CMDLINES 128
@@ -2843,6 +2842,17 @@ static int s_show(struct seq_file *m, void *v)
2843 return 0; 2842 return 0;
2844} 2843}
2845 2844
2845/*
2846 * Should be used after trace_array_get(), trace_types_lock
2847 * ensures that i_cdev was already initialized.
2848 */
2849static inline int tracing_get_cpu(struct inode *inode)
2850{
2851 if (inode->i_cdev) /* See trace_create_cpu_file() */
2852 return (long)inode->i_cdev - 1;
2853 return RING_BUFFER_ALL_CPUS;
2854}
2855
2846static const struct seq_operations tracer_seq_ops = { 2856static const struct seq_operations tracer_seq_ops = {
2847 .start = s_start, 2857 .start = s_start,
2848 .next = s_next, 2858 .next = s_next,
@@ -2851,9 +2861,9 @@ static const struct seq_operations tracer_seq_ops = {
2851}; 2861};
2852 2862
2853static struct trace_iterator * 2863static struct trace_iterator *
2854__tracing_open(struct trace_array *tr, struct trace_cpu *tc, 2864__tracing_open(struct inode *inode, struct file *file, bool snapshot)
2855 struct inode *inode, struct file *file, bool snapshot)
2856{ 2865{
2866 struct trace_array *tr = inode->i_private;
2857 struct trace_iterator *iter; 2867 struct trace_iterator *iter;
2858 int cpu; 2868 int cpu;
2859 2869
@@ -2894,8 +2904,8 @@ __tracing_open(struct trace_array *tr, struct trace_cpu *tc,
2894 iter->trace_buffer = &tr->trace_buffer; 2904 iter->trace_buffer = &tr->trace_buffer;
2895 iter->snapshot = snapshot; 2905 iter->snapshot = snapshot;
2896 iter->pos = -1; 2906 iter->pos = -1;
2907 iter->cpu_file = tracing_get_cpu(inode);
2897 mutex_init(&iter->mutex); 2908 mutex_init(&iter->mutex);
2898 iter->cpu_file = tc->cpu;
2899 2909
2900 /* Notify the tracer early; before we stop tracing. */ 2910 /* Notify the tracer early; before we stop tracing. */
2901 if (iter->trace && iter->trace->open) 2911 if (iter->trace && iter->trace->open)
@@ -2971,45 +2981,22 @@ static int tracing_open_generic_tr(struct inode *inode, struct file *filp)
2971 filp->private_data = inode->i_private; 2981 filp->private_data = inode->i_private;
2972 2982
2973 return 0; 2983 return 0;
2974
2975}
2976
2977static int tracing_open_generic_tc(struct inode *inode, struct file *filp)
2978{
2979 struct trace_cpu *tc = inode->i_private;
2980 struct trace_array *tr = tc->tr;
2981
2982 if (tracing_disabled)
2983 return -ENODEV;
2984
2985 if (trace_array_get(tr) < 0)
2986 return -ENODEV;
2987
2988 filp->private_data = inode->i_private;
2989
2990 return 0;
2991
2992} 2984}
2993 2985
2994static int tracing_release(struct inode *inode, struct file *file) 2986static int tracing_release(struct inode *inode, struct file *file)
2995{ 2987{
2988 struct trace_array *tr = inode->i_private;
2996 struct seq_file *m = file->private_data; 2989 struct seq_file *m = file->private_data;
2997 struct trace_iterator *iter; 2990 struct trace_iterator *iter;
2998 struct trace_array *tr;
2999 int cpu; 2991 int cpu;
3000 2992
3001 /* Writes do not use seq_file, need to grab tr from inode */
3002 if (!(file->f_mode & FMODE_READ)) { 2993 if (!(file->f_mode & FMODE_READ)) {
3003 struct trace_cpu *tc = inode->i_private; 2994 trace_array_put(tr);
3004
3005 trace_array_put(tc->tr);
3006 return 0; 2995 return 0;
3007 } 2996 }
3008 2997
2998 /* Writes do not use seq_file */
3009 iter = m->private; 2999 iter = m->private;
3010 tr = iter->tr;
3011 trace_array_put(tr);
3012
3013 mutex_lock(&trace_types_lock); 3000 mutex_lock(&trace_types_lock);
3014 3001
3015 for_each_tracing_cpu(cpu) { 3002 for_each_tracing_cpu(cpu) {
@@ -3023,6 +3010,9 @@ static int tracing_release(struct inode *inode, struct file *file)
3023 if (!iter->snapshot) 3010 if (!iter->snapshot)
3024 /* reenable tracing if it was previously enabled */ 3011 /* reenable tracing if it was previously enabled */
3025 tracing_start_tr(tr); 3012 tracing_start_tr(tr);
3013
3014 __trace_array_put(tr);
3015
3026 mutex_unlock(&trace_types_lock); 3016 mutex_unlock(&trace_types_lock);
3027 3017
3028 mutex_destroy(&iter->mutex); 3018 mutex_destroy(&iter->mutex);
@@ -3042,15 +3032,6 @@ static int tracing_release_generic_tr(struct inode *inode, struct file *file)
3042 return 0; 3032 return 0;
3043} 3033}
3044 3034
3045static int tracing_release_generic_tc(struct inode *inode, struct file *file)
3046{
3047 struct trace_cpu *tc = inode->i_private;
3048 struct trace_array *tr = tc->tr;
3049
3050 trace_array_put(tr);
3051 return 0;
3052}
3053
3054static int tracing_single_release_tr(struct inode *inode, struct file *file) 3035static int tracing_single_release_tr(struct inode *inode, struct file *file)
3055{ 3036{
3056 struct trace_array *tr = inode->i_private; 3037 struct trace_array *tr = inode->i_private;
@@ -3062,8 +3043,7 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)
3062 3043
3063static int tracing_open(struct inode *inode, struct file *file) 3044static int tracing_open(struct inode *inode, struct file *file)
3064{ 3045{
3065 struct trace_cpu *tc = inode->i_private; 3046 struct trace_array *tr = inode->i_private;
3066 struct trace_array *tr = tc->tr;
3067 struct trace_iterator *iter; 3047 struct trace_iterator *iter;
3068 int ret = 0; 3048 int ret = 0;
3069 3049
@@ -3071,16 +3051,17 @@ static int tracing_open(struct inode *inode, struct file *file)
3071 return -ENODEV; 3051 return -ENODEV;
3072 3052
3073 /* If this file was open for write, then erase contents */ 3053 /* If this file was open for write, then erase contents */
3074 if ((file->f_mode & FMODE_WRITE) && 3054 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
3075 (file->f_flags & O_TRUNC)) { 3055 int cpu = tracing_get_cpu(inode);
3076 if (tc->cpu == RING_BUFFER_ALL_CPUS) 3056
3057 if (cpu == RING_BUFFER_ALL_CPUS)
3077 tracing_reset_online_cpus(&tr->trace_buffer); 3058 tracing_reset_online_cpus(&tr->trace_buffer);
3078 else 3059 else
3079 tracing_reset(&tr->trace_buffer, tc->cpu); 3060 tracing_reset(&tr->trace_buffer, cpu);
3080 } 3061 }
3081 3062
3082 if (file->f_mode & FMODE_READ) { 3063 if (file->f_mode & FMODE_READ) {
3083 iter = __tracing_open(tr, tc, inode, file, false); 3064 iter = __tracing_open(inode, file, false);
3084 if (IS_ERR(iter)) 3065 if (IS_ERR(iter))
3085 ret = PTR_ERR(iter); 3066 ret = PTR_ERR(iter);
3086 else if (trace_flags & TRACE_ITER_LATENCY_FMT) 3067 else if (trace_flags & TRACE_ITER_LATENCY_FMT)
@@ -3447,6 +3428,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
3447static int tracing_trace_options_open(struct inode *inode, struct file *file) 3428static int tracing_trace_options_open(struct inode *inode, struct file *file)
3448{ 3429{
3449 struct trace_array *tr = inode->i_private; 3430 struct trace_array *tr = inode->i_private;
3431 int ret;
3450 3432
3451 if (tracing_disabled) 3433 if (tracing_disabled)
3452 return -ENODEV; 3434 return -ENODEV;
@@ -3454,7 +3436,11 @@ static int tracing_trace_options_open(struct inode *inode, struct file *file)
3454 if (trace_array_get(tr) < 0) 3436 if (trace_array_get(tr) < 0)
3455 return -ENODEV; 3437 return -ENODEV;
3456 3438
3457 return single_open(file, tracing_trace_options_show, inode->i_private); 3439 ret = single_open(file, tracing_trace_options_show, inode->i_private);
3440 if (ret < 0)
3441 trace_array_put(tr);
3442
3443 return ret;
3458} 3444}
3459 3445
3460static const struct file_operations tracing_iter_fops = { 3446static const struct file_operations tracing_iter_fops = {
@@ -3537,14 +3523,14 @@ static const char readme_msg[] =
3537 "\n snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n" 3523 "\n snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n"
3538 "\t\t\t Read the contents for more information\n" 3524 "\t\t\t Read the contents for more information\n"
3539#endif 3525#endif
3540#ifdef CONFIG_STACKTRACE 3526#ifdef CONFIG_STACK_TRACER
3541 " stack_trace\t\t- Shows the max stack trace when active\n" 3527 " stack_trace\t\t- Shows the max stack trace when active\n"
3542 " stack_max_size\t- Shows current max stack size that was traced\n" 3528 " stack_max_size\t- Shows current max stack size that was traced\n"
3543 "\t\t\t Write into this file to reset the max size (trigger a new trace)\n" 3529 "\t\t\t Write into this file to reset the max size (trigger a new trace)\n"
3544#ifdef CONFIG_DYNAMIC_FTRACE 3530#ifdef CONFIG_DYNAMIC_FTRACE
3545 " stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n" 3531 " stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n"
3546#endif 3532#endif
3547#endif /* CONFIG_STACKTRACE */ 3533#endif /* CONFIG_STACK_TRACER */
3548; 3534;
3549 3535
3550static ssize_t 3536static ssize_t
@@ -3941,8 +3927,7 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
3941 3927
3942static int tracing_open_pipe(struct inode *inode, struct file *filp) 3928static int tracing_open_pipe(struct inode *inode, struct file *filp)
3943{ 3929{
3944 struct trace_cpu *tc = inode->i_private; 3930 struct trace_array *tr = inode->i_private;
3945 struct trace_array *tr = tc->tr;
3946 struct trace_iterator *iter; 3931 struct trace_iterator *iter;
3947 int ret = 0; 3932 int ret = 0;
3948 3933
@@ -3958,6 +3943,7 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
3958 iter = kzalloc(sizeof(*iter), GFP_KERNEL); 3943 iter = kzalloc(sizeof(*iter), GFP_KERNEL);
3959 if (!iter) { 3944 if (!iter) {
3960 ret = -ENOMEM; 3945 ret = -ENOMEM;
3946 __trace_array_put(tr);
3961 goto out; 3947 goto out;
3962 } 3948 }
3963 3949
@@ -3987,9 +3973,9 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
3987 if (trace_clocks[tr->clock_id].in_ns) 3973 if (trace_clocks[tr->clock_id].in_ns)
3988 iter->iter_flags |= TRACE_FILE_TIME_IN_NS; 3974 iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
3989 3975
3990 iter->cpu_file = tc->cpu; 3976 iter->tr = tr;
3991 iter->tr = tc->tr; 3977 iter->trace_buffer = &tr->trace_buffer;
3992 iter->trace_buffer = &tc->tr->trace_buffer; 3978 iter->cpu_file = tracing_get_cpu(inode);
3993 mutex_init(&iter->mutex); 3979 mutex_init(&iter->mutex);
3994 filp->private_data = iter; 3980 filp->private_data = iter;
3995 3981
@@ -4012,8 +3998,7 @@ fail:
4012static int tracing_release_pipe(struct inode *inode, struct file *file) 3998static int tracing_release_pipe(struct inode *inode, struct file *file)
4013{ 3999{
4014 struct trace_iterator *iter = file->private_data; 4000 struct trace_iterator *iter = file->private_data;
4015 struct trace_cpu *tc = inode->i_private; 4001 struct trace_array *tr = inode->i_private;
4016 struct trace_array *tr = tc->tr;
4017 4002
4018 mutex_lock(&trace_types_lock); 4003 mutex_lock(&trace_types_lock);
4019 4004
@@ -4366,15 +4351,16 @@ static ssize_t
4366tracing_entries_read(struct file *filp, char __user *ubuf, 4351tracing_entries_read(struct file *filp, char __user *ubuf,
4367 size_t cnt, loff_t *ppos) 4352 size_t cnt, loff_t *ppos)
4368{ 4353{
4369 struct trace_cpu *tc = filp->private_data; 4354 struct inode *inode = file_inode(filp);
4370 struct trace_array *tr = tc->tr; 4355 struct trace_array *tr = inode->i_private;
4356 int cpu = tracing_get_cpu(inode);
4371 char buf[64]; 4357 char buf[64];
4372 int r = 0; 4358 int r = 0;
4373 ssize_t ret; 4359 ssize_t ret;
4374 4360
4375 mutex_lock(&trace_types_lock); 4361 mutex_lock(&trace_types_lock);
4376 4362
4377 if (tc->cpu == RING_BUFFER_ALL_CPUS) { 4363 if (cpu == RING_BUFFER_ALL_CPUS) {
4378 int cpu, buf_size_same; 4364 int cpu, buf_size_same;
4379 unsigned long size; 4365 unsigned long size;
4380 4366
@@ -4401,7 +4387,7 @@ tracing_entries_read(struct file *filp, char __user *ubuf,
4401 } else 4387 } else
4402 r = sprintf(buf, "X\n"); 4388 r = sprintf(buf, "X\n");
4403 } else 4389 } else
4404 r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->trace_buffer.data, tc->cpu)->entries >> 10); 4390 r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->trace_buffer.data, cpu)->entries >> 10);
4405 4391
4406 mutex_unlock(&trace_types_lock); 4392 mutex_unlock(&trace_types_lock);
4407 4393
@@ -4413,7 +4399,8 @@ static ssize_t
4413tracing_entries_write(struct file *filp, const char __user *ubuf, 4399tracing_entries_write(struct file *filp, const char __user *ubuf,
4414 size_t cnt, loff_t *ppos) 4400 size_t cnt, loff_t *ppos)
4415{ 4401{
4416 struct trace_cpu *tc = filp->private_data; 4402 struct inode *inode = file_inode(filp);
4403 struct trace_array *tr = inode->i_private;
4417 unsigned long val; 4404 unsigned long val;
4418 int ret; 4405 int ret;
4419 4406
@@ -4427,8 +4414,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
4427 4414
4428 /* value is in KB */ 4415 /* value is in KB */
4429 val <<= 10; 4416 val <<= 10;
4430 4417 ret = tracing_resize_ring_buffer(tr, val, tracing_get_cpu(inode));
4431 ret = tracing_resize_ring_buffer(tc->tr, val, tc->cpu);
4432 if (ret < 0) 4418 if (ret < 0)
4433 return ret; 4419 return ret;
4434 4420
@@ -4689,8 +4675,7 @@ struct ftrace_buffer_info {
4689#ifdef CONFIG_TRACER_SNAPSHOT 4675#ifdef CONFIG_TRACER_SNAPSHOT
4690static int tracing_snapshot_open(struct inode *inode, struct file *file) 4676static int tracing_snapshot_open(struct inode *inode, struct file *file)
4691{ 4677{
4692 struct trace_cpu *tc = inode->i_private; 4678 struct trace_array *tr = inode->i_private;
4693 struct trace_array *tr = tc->tr;
4694 struct trace_iterator *iter; 4679 struct trace_iterator *iter;
4695 struct seq_file *m; 4680 struct seq_file *m;
4696 int ret = 0; 4681 int ret = 0;
@@ -4699,26 +4684,29 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file)
4699 return -ENODEV; 4684 return -ENODEV;
4700 4685
4701 if (file->f_mode & FMODE_READ) { 4686 if (file->f_mode & FMODE_READ) {
4702 iter = __tracing_open(tr, tc, inode, file, true); 4687 iter = __tracing_open(inode, file, true);
4703 if (IS_ERR(iter)) 4688 if (IS_ERR(iter))
4704 ret = PTR_ERR(iter); 4689 ret = PTR_ERR(iter);
4705 } else { 4690 } else {
4706 /* Writes still need the seq_file to hold the private data */ 4691 /* Writes still need the seq_file to hold the private data */
4692 ret = -ENOMEM;
4707 m = kzalloc(sizeof(*m), GFP_KERNEL); 4693 m = kzalloc(sizeof(*m), GFP_KERNEL);
4708 if (!m) 4694 if (!m)
4709 return -ENOMEM; 4695 goto out;
4710 iter = kzalloc(sizeof(*iter), GFP_KERNEL); 4696 iter = kzalloc(sizeof(*iter), GFP_KERNEL);
4711 if (!iter) { 4697 if (!iter) {
4712 kfree(m); 4698 kfree(m);
4713 return -ENOMEM; 4699 goto out;
4714 } 4700 }
4701 ret = 0;
4702
4715 iter->tr = tr; 4703 iter->tr = tr;
4716 iter->trace_buffer = &tc->tr->max_buffer; 4704 iter->trace_buffer = &tr->max_buffer;
4717 iter->cpu_file = tc->cpu; 4705 iter->cpu_file = tracing_get_cpu(inode);
4718 m->private = iter; 4706 m->private = iter;
4719 file->private_data = m; 4707 file->private_data = m;
4720 } 4708 }
4721 4709out:
4722 if (ret < 0) 4710 if (ret < 0)
4723 trace_array_put(tr); 4711 trace_array_put(tr);
4724 4712
@@ -4873,11 +4861,11 @@ static const struct file_operations tracing_pipe_fops = {
4873}; 4861};
4874 4862
4875static const struct file_operations tracing_entries_fops = { 4863static const struct file_operations tracing_entries_fops = {
4876 .open = tracing_open_generic_tc, 4864 .open = tracing_open_generic_tr,
4877 .read = tracing_entries_read, 4865 .read = tracing_entries_read,
4878 .write = tracing_entries_write, 4866 .write = tracing_entries_write,
4879 .llseek = generic_file_llseek, 4867 .llseek = generic_file_llseek,
4880 .release = tracing_release_generic_tc, 4868 .release = tracing_release_generic_tr,
4881}; 4869};
4882 4870
4883static const struct file_operations tracing_total_entries_fops = { 4871static const struct file_operations tracing_total_entries_fops = {
@@ -4929,8 +4917,7 @@ static const struct file_operations snapshot_raw_fops = {
4929 4917
4930static int tracing_buffers_open(struct inode *inode, struct file *filp) 4918static int tracing_buffers_open(struct inode *inode, struct file *filp)
4931{ 4919{
4932 struct trace_cpu *tc = inode->i_private; 4920 struct trace_array *tr = inode->i_private;
4933 struct trace_array *tr = tc->tr;
4934 struct ftrace_buffer_info *info; 4921 struct ftrace_buffer_info *info;
4935 int ret; 4922 int ret;
4936 4923
@@ -4948,10 +4935,8 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
4948 4935
4949 mutex_lock(&trace_types_lock); 4936 mutex_lock(&trace_types_lock);
4950 4937
4951 tr->ref++;
4952
4953 info->iter.tr = tr; 4938 info->iter.tr = tr;
4954 info->iter.cpu_file = tc->cpu; 4939 info->iter.cpu_file = tracing_get_cpu(inode);
4955 info->iter.trace = tr->current_trace; 4940 info->iter.trace = tr->current_trace;
4956 info->iter.trace_buffer = &tr->trace_buffer; 4941 info->iter.trace_buffer = &tr->trace_buffer;
4957 info->spare = NULL; 4942 info->spare = NULL;
@@ -5268,14 +5253,14 @@ static ssize_t
5268tracing_stats_read(struct file *filp, char __user *ubuf, 5253tracing_stats_read(struct file *filp, char __user *ubuf,
5269 size_t count, loff_t *ppos) 5254 size_t count, loff_t *ppos)
5270{ 5255{
5271 struct trace_cpu *tc = filp->private_data; 5256 struct inode *inode = file_inode(filp);
5272 struct trace_array *tr = tc->tr; 5257 struct trace_array *tr = inode->i_private;
5273 struct trace_buffer *trace_buf = &tr->trace_buffer; 5258 struct trace_buffer *trace_buf = &tr->trace_buffer;
5259 int cpu = tracing_get_cpu(inode);
5274 struct trace_seq *s; 5260 struct trace_seq *s;
5275 unsigned long cnt; 5261 unsigned long cnt;
5276 unsigned long long t; 5262 unsigned long long t;
5277 unsigned long usec_rem; 5263 unsigned long usec_rem;
5278 int cpu = tc->cpu;
5279 5264
5280 s = kmalloc(sizeof(*s), GFP_KERNEL); 5265 s = kmalloc(sizeof(*s), GFP_KERNEL);
5281 if (!s) 5266 if (!s)
@@ -5328,9 +5313,10 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
5328} 5313}
5329 5314
5330static const struct file_operations tracing_stats_fops = { 5315static const struct file_operations tracing_stats_fops = {
5331 .open = tracing_open_generic, 5316 .open = tracing_open_generic_tr,
5332 .read = tracing_stats_read, 5317 .read = tracing_stats_read,
5333 .llseek = generic_file_llseek, 5318 .llseek = generic_file_llseek,
5319 .release = tracing_release_generic_tr,
5334}; 5320};
5335 5321
5336#ifdef CONFIG_DYNAMIC_FTRACE 5322#ifdef CONFIG_DYNAMIC_FTRACE
@@ -5519,10 +5505,20 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
5519 return tr->percpu_dir; 5505 return tr->percpu_dir;
5520} 5506}
5521 5507
5508static struct dentry *
5509trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
5510 void *data, long cpu, const struct file_operations *fops)
5511{
5512 struct dentry *ret = trace_create_file(name, mode, parent, data, fops);
5513
5514 if (ret) /* See tracing_get_cpu() */
5515 ret->d_inode->i_cdev = (void *)(cpu + 1);
5516 return ret;
5517}
5518
5522static void 5519static void
5523tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) 5520tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5524{ 5521{
5525 struct trace_array_cpu *data = per_cpu_ptr(tr->trace_buffer.data, cpu);
5526 struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu); 5522 struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu);
5527 struct dentry *d_cpu; 5523 struct dentry *d_cpu;
5528 char cpu_dir[30]; /* 30 characters should be more than enough */ 5524 char cpu_dir[30]; /* 30 characters should be more than enough */
@@ -5538,28 +5534,28 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5538 } 5534 }
5539 5535
5540 /* per cpu trace_pipe */ 5536 /* per cpu trace_pipe */
5541 trace_create_file("trace_pipe", 0444, d_cpu, 5537 trace_create_cpu_file("trace_pipe", 0444, d_cpu,
5542 (void *)&data->trace_cpu, &tracing_pipe_fops); 5538 tr, cpu, &tracing_pipe_fops);
5543 5539
5544 /* per cpu trace */ 5540 /* per cpu trace */
5545 trace_create_file("trace", 0644, d_cpu, 5541 trace_create_cpu_file("trace", 0644, d_cpu,
5546 (void *)&data->trace_cpu, &tracing_fops); 5542 tr, cpu, &tracing_fops);
5547 5543
5548 trace_create_file("trace_pipe_raw", 0444, d_cpu, 5544 trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
5549 (void *)&data->trace_cpu, &tracing_buffers_fops); 5545 tr, cpu, &tracing_buffers_fops);
5550 5546
5551 trace_create_file("stats", 0444, d_cpu, 5547 trace_create_cpu_file("stats", 0444, d_cpu,
5552 (void *)&data->trace_cpu, &tracing_stats_fops); 5548 tr, cpu, &tracing_stats_fops);
5553 5549
5554 trace_create_file("buffer_size_kb", 0444, d_cpu, 5550 trace_create_cpu_file("buffer_size_kb", 0444, d_cpu,
5555 (void *)&data->trace_cpu, &tracing_entries_fops); 5551 tr, cpu, &tracing_entries_fops);
5556 5552
5557#ifdef CONFIG_TRACER_SNAPSHOT 5553#ifdef CONFIG_TRACER_SNAPSHOT
5558 trace_create_file("snapshot", 0644, d_cpu, 5554 trace_create_cpu_file("snapshot", 0644, d_cpu,
5559 (void *)&data->trace_cpu, &snapshot_fops); 5555 tr, cpu, &snapshot_fops);
5560 5556
5561 trace_create_file("snapshot_raw", 0444, d_cpu, 5557 trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
5562 (void *)&data->trace_cpu, &snapshot_raw_fops); 5558 tr, cpu, &snapshot_raw_fops);
5563#endif 5559#endif
5564} 5560}
5565 5561
@@ -5868,17 +5864,6 @@ struct dentry *trace_instance_dir;
5868static void 5864static void
5869init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer); 5865init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer);
5870 5866
5871static void init_trace_buffers(struct trace_array *tr, struct trace_buffer *buf)
5872{
5873 int cpu;
5874
5875 for_each_tracing_cpu(cpu) {
5876 memset(per_cpu_ptr(buf->data, cpu), 0, sizeof(struct trace_array_cpu));
5877 per_cpu_ptr(buf->data, cpu)->trace_cpu.cpu = cpu;
5878 per_cpu_ptr(buf->data, cpu)->trace_cpu.tr = tr;
5879 }
5880}
5881
5882static int 5867static int
5883allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size) 5868allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size)
5884{ 5869{
@@ -5896,8 +5881,6 @@ allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size
5896 return -ENOMEM; 5881 return -ENOMEM;
5897 } 5882 }
5898 5883
5899 init_trace_buffers(tr, buf);
5900
5901 /* Allocate the first page for all buffers */ 5884 /* Allocate the first page for all buffers */
5902 set_buffer_entries(&tr->trace_buffer, 5885 set_buffer_entries(&tr->trace_buffer,
5903 ring_buffer_size(tr->trace_buffer.buffer, 0)); 5886 ring_buffer_size(tr->trace_buffer.buffer, 0));
@@ -5964,17 +5947,15 @@ static int new_instance_create(const char *name)
5964 if (allocate_trace_buffers(tr, trace_buf_size) < 0) 5947 if (allocate_trace_buffers(tr, trace_buf_size) < 0)
5965 goto out_free_tr; 5948 goto out_free_tr;
5966 5949
5967 /* Holder for file callbacks */
5968 tr->trace_cpu.cpu = RING_BUFFER_ALL_CPUS;
5969 tr->trace_cpu.tr = tr;
5970
5971 tr->dir = debugfs_create_dir(name, trace_instance_dir); 5950 tr->dir = debugfs_create_dir(name, trace_instance_dir);
5972 if (!tr->dir) 5951 if (!tr->dir)
5973 goto out_free_tr; 5952 goto out_free_tr;
5974 5953
5975 ret = event_trace_add_tracer(tr->dir, tr); 5954 ret = event_trace_add_tracer(tr->dir, tr);
5976 if (ret) 5955 if (ret) {
5956 debugfs_remove_recursive(tr->dir);
5977 goto out_free_tr; 5957 goto out_free_tr;
5958 }
5978 5959
5979 init_tracer_debugfs(tr, tr->dir); 5960 init_tracer_debugfs(tr, tr->dir);
5980 5961
@@ -6120,13 +6101,13 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
6120 tr, &tracing_iter_fops); 6101 tr, &tracing_iter_fops);
6121 6102
6122 trace_create_file("trace", 0644, d_tracer, 6103 trace_create_file("trace", 0644, d_tracer,
6123 (void *)&tr->trace_cpu, &tracing_fops); 6104 tr, &tracing_fops);
6124 6105
6125 trace_create_file("trace_pipe", 0444, d_tracer, 6106 trace_create_file("trace_pipe", 0444, d_tracer,
6126 (void *)&tr->trace_cpu, &tracing_pipe_fops); 6107 tr, &tracing_pipe_fops);
6127 6108
6128 trace_create_file("buffer_size_kb", 0644, d_tracer, 6109 trace_create_file("buffer_size_kb", 0644, d_tracer,
6129 (void *)&tr->trace_cpu, &tracing_entries_fops); 6110 tr, &tracing_entries_fops);
6130 6111
6131 trace_create_file("buffer_total_size_kb", 0444, d_tracer, 6112 trace_create_file("buffer_total_size_kb", 0444, d_tracer,
6132 tr, &tracing_total_entries_fops); 6113 tr, &tracing_total_entries_fops);
@@ -6141,11 +6122,11 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
6141 &trace_clock_fops); 6122 &trace_clock_fops);
6142 6123
6143 trace_create_file("tracing_on", 0644, d_tracer, 6124 trace_create_file("tracing_on", 0644, d_tracer,
6144 tr, &rb_simple_fops); 6125 tr, &rb_simple_fops);
6145 6126
6146#ifdef CONFIG_TRACER_SNAPSHOT 6127#ifdef CONFIG_TRACER_SNAPSHOT
6147 trace_create_file("snapshot", 0644, d_tracer, 6128 trace_create_file("snapshot", 0644, d_tracer,
6148 (void *)&tr->trace_cpu, &snapshot_fops); 6129 tr, &snapshot_fops);
6149#endif 6130#endif
6150 6131
6151 for_each_tracing_cpu(cpu) 6132 for_each_tracing_cpu(cpu)
@@ -6439,10 +6420,6 @@ __init static int tracer_alloc_buffers(void)
6439 6420
6440 global_trace.flags = TRACE_ARRAY_FL_GLOBAL; 6421 global_trace.flags = TRACE_ARRAY_FL_GLOBAL;
6441 6422
6442 /* Holder for file callbacks */
6443 global_trace.trace_cpu.cpu = RING_BUFFER_ALL_CPUS;
6444 global_trace.trace_cpu.tr = &global_trace;
6445
6446 INIT_LIST_HEAD(&global_trace.systems); 6423 INIT_LIST_HEAD(&global_trace.systems);
6447 INIT_LIST_HEAD(&global_trace.events); 6424 INIT_LIST_HEAD(&global_trace.events);
6448 list_add(&global_trace.list, &ftrace_trace_arrays); 6425 list_add(&global_trace.list, &ftrace_trace_arrays);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 4a4f6e1828b6..afaae41b0a02 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -130,19 +130,12 @@ enum trace_flag_type {
130 130
131struct trace_array; 131struct trace_array;
132 132
133struct trace_cpu {
134 struct trace_array *tr;
135 struct dentry *dir;
136 int cpu;
137};
138
139/* 133/*
140 * The CPU trace array - it consists of thousands of trace entries 134 * The CPU trace array - it consists of thousands of trace entries
141 * plus some other descriptor data: (for example which task started 135 * plus some other descriptor data: (for example which task started
142 * the trace, etc.) 136 * the trace, etc.)
143 */ 137 */
144struct trace_array_cpu { 138struct trace_array_cpu {
145 struct trace_cpu trace_cpu;
146 atomic_t disabled; 139 atomic_t disabled;
147 void *buffer_page; /* ring buffer spare */ 140 void *buffer_page; /* ring buffer spare */
148 141
@@ -196,7 +189,6 @@ struct trace_array {
196 bool allocated_snapshot; 189 bool allocated_snapshot;
197#endif 190#endif
198 int buffer_disabled; 191 int buffer_disabled;
199 struct trace_cpu trace_cpu; /* place holder */
200#ifdef CONFIG_FTRACE_SYSCALLS 192#ifdef CONFIG_FTRACE_SYSCALLS
201 int sys_refcount_enter; 193 int sys_refcount_enter;
202 int sys_refcount_exit; 194 int sys_refcount_exit;
@@ -214,7 +206,6 @@ struct trace_array {
214 struct dentry *event_dir; 206 struct dentry *event_dir;
215 struct list_head systems; 207 struct list_head systems;
216 struct list_head events; 208 struct list_head events;
217 struct task_struct *waiter;
218 int ref; 209 int ref;
219}; 210};
220 211
@@ -680,6 +671,15 @@ extern int trace_selftest_startup_sched_switch(struct tracer *trace,
680 struct trace_array *tr); 671 struct trace_array *tr);
681extern int trace_selftest_startup_branch(struct tracer *trace, 672extern int trace_selftest_startup_branch(struct tracer *trace,
682 struct trace_array *tr); 673 struct trace_array *tr);
674/*
675 * Tracer data references selftest functions that only occur
676 * on boot up. These can be __init functions. Thus, when selftests
677 * are enabled, then the tracers need to reference __init functions.
678 */
679#define __tracer_data __refdata
680#else
681/* Tracers are seldom changed. Optimize when selftests are disabled. */
682#define __tracer_data __read_mostly
683#endif /* CONFIG_FTRACE_STARTUP_TEST */ 683#endif /* CONFIG_FTRACE_STARTUP_TEST */
684 684
685extern void *head_page(struct trace_array_cpu *data); 685extern void *head_page(struct trace_array_cpu *data);
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 84b1e045faba..80c36bcf66e8 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -236,6 +236,10 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
236 236
237 BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long)); 237 BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
238 238
239 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
240 "perf buffer not large enough"))
241 return NULL;
242
239 pc = preempt_count(); 243 pc = preempt_count();
240 244
241 *rctxp = perf_swevent_get_recursion_context(); 245 *rctxp = perf_swevent_get_recursion_context();
@@ -266,6 +270,10 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
266 struct pt_regs regs; 270 struct pt_regs regs;
267 int rctx; 271 int rctx;
268 272
273 head = this_cpu_ptr(event_function.perf_events);
274 if (hlist_empty(head))
275 return;
276
269#define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \ 277#define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
270 sizeof(u64)) - sizeof(u32)) 278 sizeof(u64)) - sizeof(u32))
271 279
@@ -279,8 +287,6 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
279 287
280 entry->ip = ip; 288 entry->ip = ip;
281 entry->parent_ip = parent_ip; 289 entry->parent_ip = parent_ip;
282
283 head = this_cpu_ptr(event_function.perf_events);
284 perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0, 290 perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0,
285 1, &regs, head, NULL); 291 1, &regs, head, NULL);
286 292
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7d854290bf81..898f868833f2 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -826,59 +826,33 @@ enum {
826static void *f_next(struct seq_file *m, void *v, loff_t *pos) 826static void *f_next(struct seq_file *m, void *v, loff_t *pos)
827{ 827{
828 struct ftrace_event_call *call = m->private; 828 struct ftrace_event_call *call = m->private;
829 struct ftrace_event_field *field;
830 struct list_head *common_head = &ftrace_common_fields; 829 struct list_head *common_head = &ftrace_common_fields;
831 struct list_head *head = trace_get_fields(call); 830 struct list_head *head = trace_get_fields(call);
831 struct list_head *node = v;
832 832
833 (*pos)++; 833 (*pos)++;
834 834
835 switch ((unsigned long)v) { 835 switch ((unsigned long)v) {
836 case FORMAT_HEADER: 836 case FORMAT_HEADER:
837 if (unlikely(list_empty(common_head))) 837 node = common_head;
838 return NULL; 838 break;
839
840 field = list_entry(common_head->prev,
841 struct ftrace_event_field, link);
842 return field;
843 839
844 case FORMAT_FIELD_SEPERATOR: 840 case FORMAT_FIELD_SEPERATOR:
845 if (unlikely(list_empty(head))) 841 node = head;
846 return NULL; 842 break;
847
848 field = list_entry(head->prev, struct ftrace_event_field, link);
849 return field;
850 843
851 case FORMAT_PRINTFMT: 844 case FORMAT_PRINTFMT:
852 /* all done */ 845 /* all done */
853 return NULL; 846 return NULL;
854 } 847 }
855 848
856 field = v; 849 node = node->prev;
857 if (field->link.prev == common_head) 850 if (node == common_head)
858 return (void *)FORMAT_FIELD_SEPERATOR; 851 return (void *)FORMAT_FIELD_SEPERATOR;
859 else if (field->link.prev == head) 852 else if (node == head)
860 return (void *)FORMAT_PRINTFMT; 853 return (void *)FORMAT_PRINTFMT;
861 854 else
862 field = list_entry(field->link.prev, struct ftrace_event_field, link); 855 return node;
863
864 return field;
865}
866
867static void *f_start(struct seq_file *m, loff_t *pos)
868{
869 loff_t l = 0;
870 void *p;
871
872 /* Start by showing the header */
873 if (!*pos)
874 return (void *)FORMAT_HEADER;
875
876 p = (void *)FORMAT_HEADER;
877 do {
878 p = f_next(m, p, &l);
879 } while (p && l < *pos);
880
881 return p;
882} 856}
883 857
884static int f_show(struct seq_file *m, void *v) 858static int f_show(struct seq_file *m, void *v)
@@ -904,8 +878,7 @@ static int f_show(struct seq_file *m, void *v)
904 return 0; 878 return 0;
905 } 879 }
906 880
907 field = v; 881 field = list_entry(v, struct ftrace_event_field, link);
908
909 /* 882 /*
910 * Smartly shows the array type(except dynamic array). 883 * Smartly shows the array type(except dynamic array).
911 * Normal: 884 * Normal:
@@ -932,6 +905,17 @@ static int f_show(struct seq_file *m, void *v)
932 return 0; 905 return 0;
933} 906}
934 907
908static void *f_start(struct seq_file *m, loff_t *pos)
909{
910 void *p = (void *)FORMAT_HEADER;
911 loff_t l = 0;
912
913 while (l < *pos && p)
914 p = f_next(m, p, &l);
915
916 return p;
917}
918
935static void f_stop(struct seq_file *m, void *p) 919static void f_stop(struct seq_file *m, void *p)
936{ 920{
937} 921}
@@ -963,23 +947,14 @@ static ssize_t
963event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) 947event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
964{ 948{
965 struct ftrace_event_call *call = filp->private_data; 949 struct ftrace_event_call *call = filp->private_data;
966 struct trace_seq *s; 950 char buf[32];
967 int r; 951 int len;
968 952
969 if (*ppos) 953 if (*ppos)
970 return 0; 954 return 0;
971 955
972 s = kmalloc(sizeof(*s), GFP_KERNEL); 956 len = sprintf(buf, "%d\n", call->event.type);
973 if (!s) 957 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
974 return -ENOMEM;
975
976 trace_seq_init(s);
977 trace_seq_printf(s, "%d\n", call->event.type);
978
979 r = simple_read_from_buffer(ubuf, cnt, ppos,
980 s->buffer, s->len);
981 kfree(s);
982 return r;
983} 958}
984 959
985static ssize_t 960static ssize_t
@@ -1218,6 +1193,7 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
1218 1193
1219static int ftrace_event_avail_open(struct inode *inode, struct file *file); 1194static int ftrace_event_avail_open(struct inode *inode, struct file *file);
1220static int ftrace_event_set_open(struct inode *inode, struct file *file); 1195static int ftrace_event_set_open(struct inode *inode, struct file *file);
1196static int ftrace_event_release(struct inode *inode, struct file *file);
1221 1197
1222static const struct seq_operations show_event_seq_ops = { 1198static const struct seq_operations show_event_seq_ops = {
1223 .start = t_start, 1199 .start = t_start,
@@ -1245,7 +1221,7 @@ static const struct file_operations ftrace_set_event_fops = {
1245 .read = seq_read, 1221 .read = seq_read,
1246 .write = ftrace_event_write, 1222 .write = ftrace_event_write,
1247 .llseek = seq_lseek, 1223 .llseek = seq_lseek,
1248 .release = seq_release, 1224 .release = ftrace_event_release,
1249}; 1225};
1250 1226
1251static const struct file_operations ftrace_enable_fops = { 1227static const struct file_operations ftrace_enable_fops = {
@@ -1323,6 +1299,15 @@ ftrace_event_open(struct inode *inode, struct file *file,
1323 return ret; 1299 return ret;
1324} 1300}
1325 1301
1302static int ftrace_event_release(struct inode *inode, struct file *file)
1303{
1304 struct trace_array *tr = inode->i_private;
1305
1306 trace_array_put(tr);
1307
1308 return seq_release(inode, file);
1309}
1310
1326static int 1311static int
1327ftrace_event_avail_open(struct inode *inode, struct file *file) 1312ftrace_event_avail_open(struct inode *inode, struct file *file)
1328{ 1313{
@@ -1336,12 +1321,19 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
1336{ 1321{
1337 const struct seq_operations *seq_ops = &show_set_event_seq_ops; 1322 const struct seq_operations *seq_ops = &show_set_event_seq_ops;
1338 struct trace_array *tr = inode->i_private; 1323 struct trace_array *tr = inode->i_private;
1324 int ret;
1325
1326 if (trace_array_get(tr) < 0)
1327 return -ENODEV;
1339 1328
1340 if ((file->f_mode & FMODE_WRITE) && 1329 if ((file->f_mode & FMODE_WRITE) &&
1341 (file->f_flags & O_TRUNC)) 1330 (file->f_flags & O_TRUNC))
1342 ftrace_clear_events(tr); 1331 ftrace_clear_events(tr);
1343 1332
1344 return ftrace_event_open(inode, file, seq_ops); 1333 ret = ftrace_event_open(inode, file, seq_ops);
1334 if (ret < 0)
1335 trace_array_put(tr);
1336 return ret;
1345} 1337}
1346 1338
1347static struct event_subsystem * 1339static struct event_subsystem *
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 0d883dc057d6..0c7b75a8acc8 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -646,7 +646,7 @@ void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
646 if (filter && filter->filter_string) 646 if (filter && filter->filter_string)
647 trace_seq_printf(s, "%s\n", filter->filter_string); 647 trace_seq_printf(s, "%s\n", filter->filter_string);
648 else 648 else
649 trace_seq_printf(s, "none\n"); 649 trace_seq_puts(s, "none\n");
650 mutex_unlock(&event_mutex); 650 mutex_unlock(&event_mutex);
651} 651}
652 652
@@ -660,7 +660,7 @@ void print_subsystem_event_filter(struct event_subsystem *system,
660 if (filter && filter->filter_string) 660 if (filter && filter->filter_string)
661 trace_seq_printf(s, "%s\n", filter->filter_string); 661 trace_seq_printf(s, "%s\n", filter->filter_string);
662 else 662 else
663 trace_seq_printf(s, DEFAULT_SYS_FILTER_MESSAGE "\n"); 663 trace_seq_puts(s, DEFAULT_SYS_FILTER_MESSAGE "\n");
664 mutex_unlock(&event_mutex); 664 mutex_unlock(&event_mutex);
665} 665}
666 666
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index b863f93b30f3..38fe1483c508 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -199,7 +199,7 @@ static int func_set_flag(u32 old_flags, u32 bit, int set)
199 return 0; 199 return 0;
200} 200}
201 201
202static struct tracer function_trace __read_mostly = 202static struct tracer function_trace __tracer_data =
203{ 203{
204 .name = "function", 204 .name = "function",
205 .init = function_trace_init, 205 .init = function_trace_init,
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 8388bc99f2ee..b5c09242683d 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -446,7 +446,7 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
446 446
447 /* First spaces to align center */ 447 /* First spaces to align center */
448 for (i = 0; i < spaces / 2; i++) { 448 for (i = 0; i < spaces / 2; i++) {
449 ret = trace_seq_printf(s, " "); 449 ret = trace_seq_putc(s, ' ');
450 if (!ret) 450 if (!ret)
451 return TRACE_TYPE_PARTIAL_LINE; 451 return TRACE_TYPE_PARTIAL_LINE;
452 } 452 }
@@ -457,7 +457,7 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
457 457
458 /* Last spaces to align center */ 458 /* Last spaces to align center */
459 for (i = 0; i < spaces - (spaces / 2); i++) { 459 for (i = 0; i < spaces - (spaces / 2); i++) {
460 ret = trace_seq_printf(s, " "); 460 ret = trace_seq_putc(s, ' ');
461 if (!ret) 461 if (!ret)
462 return TRACE_TYPE_PARTIAL_LINE; 462 return TRACE_TYPE_PARTIAL_LINE;
463 } 463 }
@@ -503,7 +503,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
503 ------------------------------------------ 503 ------------------------------------------
504 504
505 */ 505 */
506 ret = trace_seq_printf(s, 506 ret = trace_seq_puts(s,
507 " ------------------------------------------\n"); 507 " ------------------------------------------\n");
508 if (!ret) 508 if (!ret)
509 return TRACE_TYPE_PARTIAL_LINE; 509 return TRACE_TYPE_PARTIAL_LINE;
@@ -516,7 +516,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
516 if (ret == TRACE_TYPE_PARTIAL_LINE) 516 if (ret == TRACE_TYPE_PARTIAL_LINE)
517 return TRACE_TYPE_PARTIAL_LINE; 517 return TRACE_TYPE_PARTIAL_LINE;
518 518
519 ret = trace_seq_printf(s, " => "); 519 ret = trace_seq_puts(s, " => ");
520 if (!ret) 520 if (!ret)
521 return TRACE_TYPE_PARTIAL_LINE; 521 return TRACE_TYPE_PARTIAL_LINE;
522 522
@@ -524,7 +524,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
524 if (ret == TRACE_TYPE_PARTIAL_LINE) 524 if (ret == TRACE_TYPE_PARTIAL_LINE)
525 return TRACE_TYPE_PARTIAL_LINE; 525 return TRACE_TYPE_PARTIAL_LINE;
526 526
527 ret = trace_seq_printf(s, 527 ret = trace_seq_puts(s,
528 "\n ------------------------------------------\n\n"); 528 "\n ------------------------------------------\n\n");
529 if (!ret) 529 if (!ret)
530 return TRACE_TYPE_PARTIAL_LINE; 530 return TRACE_TYPE_PARTIAL_LINE;
@@ -645,7 +645,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
645 ret = print_graph_proc(s, pid); 645 ret = print_graph_proc(s, pid);
646 if (ret == TRACE_TYPE_PARTIAL_LINE) 646 if (ret == TRACE_TYPE_PARTIAL_LINE)
647 return TRACE_TYPE_PARTIAL_LINE; 647 return TRACE_TYPE_PARTIAL_LINE;
648 ret = trace_seq_printf(s, " | "); 648 ret = trace_seq_puts(s, " | ");
649 if (!ret) 649 if (!ret)
650 return TRACE_TYPE_PARTIAL_LINE; 650 return TRACE_TYPE_PARTIAL_LINE;
651 } 651 }
@@ -657,9 +657,9 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
657 return ret; 657 return ret;
658 658
659 if (type == TRACE_GRAPH_ENT) 659 if (type == TRACE_GRAPH_ENT)
660 ret = trace_seq_printf(s, "==========>"); 660 ret = trace_seq_puts(s, "==========>");
661 else 661 else
662 ret = trace_seq_printf(s, "<=========="); 662 ret = trace_seq_puts(s, "<==========");
663 663
664 if (!ret) 664 if (!ret)
665 return TRACE_TYPE_PARTIAL_LINE; 665 return TRACE_TYPE_PARTIAL_LINE;
@@ -668,7 +668,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
668 if (ret != TRACE_TYPE_HANDLED) 668 if (ret != TRACE_TYPE_HANDLED)
669 return ret; 669 return ret;
670 670
671 ret = trace_seq_printf(s, "\n"); 671 ret = trace_seq_putc(s, '\n');
672 672
673 if (!ret) 673 if (!ret)
674 return TRACE_TYPE_PARTIAL_LINE; 674 return TRACE_TYPE_PARTIAL_LINE;
@@ -705,13 +705,13 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
705 len += strlen(nsecs_str); 705 len += strlen(nsecs_str);
706 } 706 }
707 707
708 ret = trace_seq_printf(s, " us "); 708 ret = trace_seq_puts(s, " us ");
709 if (!ret) 709 if (!ret)
710 return TRACE_TYPE_PARTIAL_LINE; 710 return TRACE_TYPE_PARTIAL_LINE;
711 711
712 /* Print remaining spaces to fit the row's width */ 712 /* Print remaining spaces to fit the row's width */
713 for (i = len; i < 7; i++) { 713 for (i = len; i < 7; i++) {
714 ret = trace_seq_printf(s, " "); 714 ret = trace_seq_putc(s, ' ');
715 if (!ret) 715 if (!ret)
716 return TRACE_TYPE_PARTIAL_LINE; 716 return TRACE_TYPE_PARTIAL_LINE;
717 } 717 }
@@ -731,13 +731,13 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
731 /* No real adata, just filling the column with spaces */ 731 /* No real adata, just filling the column with spaces */
732 switch (duration) { 732 switch (duration) {
733 case DURATION_FILL_FULL: 733 case DURATION_FILL_FULL:
734 ret = trace_seq_printf(s, " | "); 734 ret = trace_seq_puts(s, " | ");
735 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 735 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
736 case DURATION_FILL_START: 736 case DURATION_FILL_START:
737 ret = trace_seq_printf(s, " "); 737 ret = trace_seq_puts(s, " ");
738 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 738 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
739 case DURATION_FILL_END: 739 case DURATION_FILL_END:
740 ret = trace_seq_printf(s, " |"); 740 ret = trace_seq_puts(s, " |");
741 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 741 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
742 } 742 }
743 743
@@ -745,10 +745,10 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
745 if (flags & TRACE_GRAPH_PRINT_OVERHEAD) { 745 if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
746 /* Duration exceeded 100 msecs */ 746 /* Duration exceeded 100 msecs */
747 if (duration > 100000ULL) 747 if (duration > 100000ULL)
748 ret = trace_seq_printf(s, "! "); 748 ret = trace_seq_puts(s, "! ");
749 /* Duration exceeded 10 msecs */ 749 /* Duration exceeded 10 msecs */
750 else if (duration > 10000ULL) 750 else if (duration > 10000ULL)
751 ret = trace_seq_printf(s, "+ "); 751 ret = trace_seq_puts(s, "+ ");
752 } 752 }
753 753
754 /* 754 /*
@@ -757,7 +757,7 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
757 * to fill out the space. 757 * to fill out the space.
758 */ 758 */
759 if (ret == -1) 759 if (ret == -1)
760 ret = trace_seq_printf(s, " "); 760 ret = trace_seq_puts(s, " ");
761 761
762 /* Catching here any failure happenned above */ 762 /* Catching here any failure happenned above */
763 if (!ret) 763 if (!ret)
@@ -767,7 +767,7 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
767 if (ret != TRACE_TYPE_HANDLED) 767 if (ret != TRACE_TYPE_HANDLED)
768 return ret; 768 return ret;
769 769
770 ret = trace_seq_printf(s, "| "); 770 ret = trace_seq_puts(s, "| ");
771 if (!ret) 771 if (!ret)
772 return TRACE_TYPE_PARTIAL_LINE; 772 return TRACE_TYPE_PARTIAL_LINE;
773 773
@@ -817,7 +817,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
817 817
818 /* Function */ 818 /* Function */
819 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { 819 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
820 ret = trace_seq_printf(s, " "); 820 ret = trace_seq_putc(s, ' ');
821 if (!ret) 821 if (!ret)
822 return TRACE_TYPE_PARTIAL_LINE; 822 return TRACE_TYPE_PARTIAL_LINE;
823 } 823 }
@@ -858,7 +858,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
858 858
859 /* Function */ 859 /* Function */
860 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { 860 for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
861 ret = trace_seq_printf(s, " "); 861 ret = trace_seq_putc(s, ' ');
862 if (!ret) 862 if (!ret)
863 return TRACE_TYPE_PARTIAL_LINE; 863 return TRACE_TYPE_PARTIAL_LINE;
864 } 864 }
@@ -917,7 +917,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
917 if (ret == TRACE_TYPE_PARTIAL_LINE) 917 if (ret == TRACE_TYPE_PARTIAL_LINE)
918 return TRACE_TYPE_PARTIAL_LINE; 918 return TRACE_TYPE_PARTIAL_LINE;
919 919
920 ret = trace_seq_printf(s, " | "); 920 ret = trace_seq_puts(s, " | ");
921 if (!ret) 921 if (!ret)
922 return TRACE_TYPE_PARTIAL_LINE; 922 return TRACE_TYPE_PARTIAL_LINE;
923 } 923 }
@@ -1117,7 +1117,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
1117 1117
1118 /* Closing brace */ 1118 /* Closing brace */
1119 for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) { 1119 for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) {
1120 ret = trace_seq_printf(s, " "); 1120 ret = trace_seq_putc(s, ' ');
1121 if (!ret) 1121 if (!ret)
1122 return TRACE_TYPE_PARTIAL_LINE; 1122 return TRACE_TYPE_PARTIAL_LINE;
1123 } 1123 }
@@ -1129,7 +1129,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
1129 * belongs to, write out the function name. 1129 * belongs to, write out the function name.
1130 */ 1130 */
1131 if (func_match) { 1131 if (func_match) {
1132 ret = trace_seq_printf(s, "}\n"); 1132 ret = trace_seq_puts(s, "}\n");
1133 if (!ret) 1133 if (!ret)
1134 return TRACE_TYPE_PARTIAL_LINE; 1134 return TRACE_TYPE_PARTIAL_LINE;
1135 } else { 1135 } else {
@@ -1179,13 +1179,13 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
1179 /* Indentation */ 1179 /* Indentation */
1180 if (depth > 0) 1180 if (depth > 0)
1181 for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) { 1181 for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) {
1182 ret = trace_seq_printf(s, " "); 1182 ret = trace_seq_putc(s, ' ');
1183 if (!ret) 1183 if (!ret)
1184 return TRACE_TYPE_PARTIAL_LINE; 1184 return TRACE_TYPE_PARTIAL_LINE;
1185 } 1185 }
1186 1186
1187 /* The comment */ 1187 /* The comment */
1188 ret = trace_seq_printf(s, "/* "); 1188 ret = trace_seq_puts(s, "/* ");
1189 if (!ret) 1189 if (!ret)
1190 return TRACE_TYPE_PARTIAL_LINE; 1190 return TRACE_TYPE_PARTIAL_LINE;
1191 1191
@@ -1216,7 +1216,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
1216 s->len--; 1216 s->len--;
1217 } 1217 }
1218 1218
1219 ret = trace_seq_printf(s, " */\n"); 1219 ret = trace_seq_puts(s, " */\n");
1220 if (!ret) 1220 if (!ret)
1221 return TRACE_TYPE_PARTIAL_LINE; 1221 return TRACE_TYPE_PARTIAL_LINE;
1222 1222
@@ -1448,7 +1448,7 @@ static struct trace_event graph_trace_ret_event = {
1448 .funcs = &graph_functions 1448 .funcs = &graph_functions
1449}; 1449};
1450 1450
1451static struct tracer graph_trace __read_mostly = { 1451static struct tracer graph_trace __tracer_data = {
1452 .name = "function_graph", 1452 .name = "function_graph",
1453 .open = graph_trace_open, 1453 .open = graph_trace_open,
1454 .pipe_open = graph_trace_open, 1454 .pipe_open = graph_trace_open,
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 7ed6976493c8..3811487e7a7a 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -243,11 +243,11 @@ find_event_file_link(struct trace_probe *tp, struct ftrace_event_file *file)
243static int 243static int
244disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file) 244disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
245{ 245{
246 struct event_file_link *link = NULL;
247 int wait = 0;
246 int ret = 0; 248 int ret = 0;
247 249
248 if (file) { 250 if (file) {
249 struct event_file_link *link;
250
251 link = find_event_file_link(tp, file); 251 link = find_event_file_link(tp, file);
252 if (!link) { 252 if (!link) {
253 ret = -EINVAL; 253 ret = -EINVAL;
@@ -255,10 +255,7 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
255 } 255 }
256 256
257 list_del_rcu(&link->list); 257 list_del_rcu(&link->list);
258 /* synchronize with kprobe_trace_func/kretprobe_trace_func */ 258 wait = 1;
259 synchronize_sched();
260 kfree(link);
261
262 if (!list_empty(&tp->files)) 259 if (!list_empty(&tp->files))
263 goto out; 260 goto out;
264 261
@@ -271,8 +268,22 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
271 disable_kretprobe(&tp->rp); 268 disable_kretprobe(&tp->rp);
272 else 269 else
273 disable_kprobe(&tp->rp.kp); 270 disable_kprobe(&tp->rp.kp);
271 wait = 1;
274 } 272 }
275 out: 273 out:
274 if (wait) {
275 /*
276 * Synchronize with kprobe_trace_func/kretprobe_trace_func
277 * to ensure disabled (all running handlers are finished).
278 * This is not only for kfree(), but also the caller,
279 * trace_remove_event_call() supposes it for releasing
280 * event_call related objects, which will be accessed in
281 * the kprobe_trace_func/kretprobe_trace_func.
282 */
283 synchronize_sched();
284 kfree(link); /* Ignored if link == NULL */
285 }
286
276 return ret; 287 return ret;
277} 288}
278 289
@@ -1087,9 +1098,6 @@ kprobe_perf_func(struct trace_probe *tp, struct pt_regs *regs)
1087 __size = sizeof(*entry) + tp->size + dsize; 1098 __size = sizeof(*entry) + tp->size + dsize;
1088 size = ALIGN(__size + sizeof(u32), sizeof(u64)); 1099 size = ALIGN(__size + sizeof(u32), sizeof(u64));
1089 size -= sizeof(u32); 1100 size -= sizeof(u32);
1090 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
1091 "profile buffer not large enough"))
1092 return;
1093 1101
1094 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); 1102 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
1095 if (!entry) 1103 if (!entry)
@@ -1120,9 +1128,6 @@ kretprobe_perf_func(struct trace_probe *tp, struct kretprobe_instance *ri,
1120 __size = sizeof(*entry) + tp->size + dsize; 1128 __size = sizeof(*entry) + tp->size + dsize;
1121 size = ALIGN(__size + sizeof(u32), sizeof(u64)); 1129 size = ALIGN(__size + sizeof(u32), sizeof(u64));
1122 size -= sizeof(u32); 1130 size -= sizeof(u32);
1123 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
1124 "profile buffer not large enough"))
1125 return;
1126 1131
1127 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); 1132 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
1128 if (!entry) 1133 if (!entry)
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index a5e8f4878bfa..b3dcfb2f0fef 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -90,7 +90,7 @@ static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
90 if (drv) 90 if (drv)
91 ret += trace_seq_printf(s, " %s\n", drv->name); 91 ret += trace_seq_printf(s, " %s\n", drv->name);
92 else 92 else
93 ret += trace_seq_printf(s, " \n"); 93 ret += trace_seq_puts(s, " \n");
94 return ret; 94 return ret;
95} 95}
96 96
@@ -107,7 +107,7 @@ static void mmio_pipe_open(struct trace_iterator *iter)
107 struct header_iter *hiter; 107 struct header_iter *hiter;
108 struct trace_seq *s = &iter->seq; 108 struct trace_seq *s = &iter->seq;
109 109
110 trace_seq_printf(s, "VERSION 20070824\n"); 110 trace_seq_puts(s, "VERSION 20070824\n");
111 111
112 hiter = kzalloc(sizeof(*hiter), GFP_KERNEL); 112 hiter = kzalloc(sizeof(*hiter), GFP_KERNEL);
113 if (!hiter) 113 if (!hiter)
@@ -209,7 +209,7 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
209 (rw->value >> 0) & 0xff, rw->pc, 0); 209 (rw->value >> 0) & 0xff, rw->pc, 0);
210 break; 210 break;
211 default: 211 default:
212 ret = trace_seq_printf(s, "rw what?\n"); 212 ret = trace_seq_puts(s, "rw what?\n");
213 break; 213 break;
214 } 214 }
215 if (ret) 215 if (ret)
@@ -245,7 +245,7 @@ static enum print_line_t mmio_print_map(struct trace_iterator *iter)
245 secs, usec_rem, m->map_id, 0UL, 0); 245 secs, usec_rem, m->map_id, 0UL, 0);
246 break; 246 break;
247 default: 247 default:
248 ret = trace_seq_printf(s, "map what?\n"); 248 ret = trace_seq_puts(s, "map what?\n");
249 break; 249 break;
250 } 250 }
251 if (ret) 251 if (ret)
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index bb922d9ee51b..34e7cbac0c9c 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -78,7 +78,7 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
78 78
79 trace_assign_type(field, entry); 79 trace_assign_type(field, entry);
80 80
81 ret = trace_seq_printf(s, "%s", field->buf); 81 ret = trace_seq_puts(s, field->buf);
82 if (!ret) 82 if (!ret)
83 return TRACE_TYPE_PARTIAL_LINE; 83 return TRACE_TYPE_PARTIAL_LINE;
84 84
@@ -558,14 +558,14 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
558 if (ret) 558 if (ret)
559 ret = trace_seq_puts(s, "??"); 559 ret = trace_seq_puts(s, "??");
560 if (ret) 560 if (ret)
561 ret = trace_seq_puts(s, "\n"); 561 ret = trace_seq_putc(s, '\n');
562 continue; 562 continue;
563 } 563 }
564 if (!ret) 564 if (!ret)
565 break; 565 break;
566 if (ret) 566 if (ret)
567 ret = seq_print_user_ip(s, mm, ip, sym_flags); 567 ret = seq_print_user_ip(s, mm, ip, sym_flags);
568 ret = trace_seq_puts(s, "\n"); 568 ret = trace_seq_putc(s, '\n');
569 } 569 }
570 570
571 if (mm) 571 if (mm)
@@ -579,7 +579,7 @@ seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
579 int ret; 579 int ret;
580 580
581 if (!ip) 581 if (!ip)
582 return trace_seq_printf(s, "0"); 582 return trace_seq_putc(s, '0');
583 583
584 if (sym_flags & TRACE_ITER_SYM_OFFSET) 584 if (sym_flags & TRACE_ITER_SYM_OFFSET)
585 ret = seq_print_sym_offset(s, "%s", ip); 585 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,
964 goto partial; 964 goto partial;
965 965
966 if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) { 966 if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
967 if (!trace_seq_printf(s, " <-")) 967 if (!trace_seq_puts(s, " <-"))
968 goto partial; 968 goto partial;
969 if (!seq_print_ip_sym(s, 969 if (!seq_print_ip_sym(s,
970 field->parent_ip, 970 field->parent_ip,
971 flags)) 971 flags))
972 goto partial; 972 goto partial;
973 } 973 }
974 if (!trace_seq_printf(s, "\n")) 974 if (!trace_seq_putc(s, '\n'))
975 goto partial; 975 goto partial;
976 976
977 return TRACE_TYPE_HANDLED; 977 return TRACE_TYPE_HANDLED;
@@ -1210,7 +1210,7 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
1210 1210
1211 if (!seq_print_ip_sym(s, *p, flags)) 1211 if (!seq_print_ip_sym(s, *p, flags))
1212 goto partial; 1212 goto partial;
1213 if (!trace_seq_puts(s, "\n")) 1213 if (!trace_seq_putc(s, '\n'))
1214 goto partial; 1214 goto partial;
1215 } 1215 }
1216 1216
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 322e16461072..8fd03657bc7d 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -175,7 +175,7 @@ print_syscall_exit(struct trace_iterator *iter, int flags,
175 entry = syscall_nr_to_meta(syscall); 175 entry = syscall_nr_to_meta(syscall);
176 176
177 if (!entry) { 177 if (!entry) {
178 trace_seq_printf(s, "\n"); 178 trace_seq_putc(s, '\n');
179 return TRACE_TYPE_HANDLED; 179 return TRACE_TYPE_HANDLED;
180 } 180 }
181 181
@@ -566,15 +566,15 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
566 if (!sys_data) 566 if (!sys_data)
567 return; 567 return;
568 568
569 head = this_cpu_ptr(sys_data->enter_event->perf_events);
570 if (hlist_empty(head))
571 return;
572
569 /* get the size after alignment with the u32 buffer size field */ 573 /* get the size after alignment with the u32 buffer size field */
570 size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec); 574 size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
571 size = ALIGN(size + sizeof(u32), sizeof(u64)); 575 size = ALIGN(size + sizeof(u32), sizeof(u64));
572 size -= sizeof(u32); 576 size -= sizeof(u32);
573 577
574 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
575 "perf buffer not large enough"))
576 return;
577
578 rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size, 578 rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size,
579 sys_data->enter_event->event.type, regs, &rctx); 579 sys_data->enter_event->event.type, regs, &rctx);
580 if (!rec) 580 if (!rec)
@@ -583,8 +583,6 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
583 rec->nr = syscall_nr; 583 rec->nr = syscall_nr;
584 syscall_get_arguments(current, regs, 0, sys_data->nb_args, 584 syscall_get_arguments(current, regs, 0, sys_data->nb_args,
585 (unsigned long *)&rec->args); 585 (unsigned long *)&rec->args);
586
587 head = this_cpu_ptr(sys_data->enter_event->perf_events);
588 perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL); 586 perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
589} 587}
590 588
@@ -642,18 +640,14 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
642 if (!sys_data) 640 if (!sys_data)
643 return; 641 return;
644 642
643 head = this_cpu_ptr(sys_data->exit_event->perf_events);
644 if (hlist_empty(head))
645 return;
646
645 /* We can probably do that at build time */ 647 /* We can probably do that at build time */
646 size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64)); 648 size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));
647 size -= sizeof(u32); 649 size -= sizeof(u32);
648 650
649 /*
650 * Impossible, but be paranoid with the future
651 * How to put this check outside runtime?
652 */
653 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
654 "exit event has grown above perf buffer size"))
655 return;
656
657 rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size, 651 rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,
658 sys_data->exit_event->event.type, regs, &rctx); 652 sys_data->exit_event->event.type, regs, &rctx);
659 if (!rec) 653 if (!rec)
@@ -661,8 +655,6 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
661 655
662 rec->nr = syscall_nr; 656 rec->nr = syscall_nr;
663 rec->ret = syscall_get_return_value(current, regs); 657 rec->ret = syscall_get_return_value(current, regs);
664
665 head = this_cpu_ptr(sys_data->exit_event->perf_events);
666 perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL); 658 perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
667} 659}
668 660
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index d5d0cd368a56..a23d2d71188e 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -818,8 +818,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
818 818
819 size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu)); 819 size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
820 size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32); 820 size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
821 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
822 return;
823 821
824 preempt_disable(); 822 preempt_disable();
825 head = this_cpu_ptr(call->perf_events); 823 head = this_cpu_ptr(call->perf_events);
diff --git a/kernel/wait.c b/kernel/wait.c
index ce0daa320a26..dec68bd4e9d8 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -333,7 +333,8 @@ int __wait_on_atomic_t(wait_queue_head_t *wq, struct wait_bit_queue *q,
333 prepare_to_wait(wq, &q->wait, mode); 333 prepare_to_wait(wq, &q->wait, mode);
334 val = q->key.flags; 334 val = q->key.flags;
335 if (atomic_read(val) == 0) 335 if (atomic_read(val) == 0)
336 ret = (*action)(val); 336 break;
337 ret = (*action)(val);
337 } while (!ret && atomic_read(val) != 0); 338 } while (!ret && atomic_read(val) != 0);
338 finish_wait(wq, &q->wait); 339 finish_wait(wq, &q->wait);
339 return ret; 340 return ret;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index f02c4a4a0c3c..0b72e816b8d0 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4644,7 +4644,7 @@ static void restore_unbound_workers_cpumask(struct worker_pool *pool, int cpu)
4644 * Workqueues should be brought up before normal priority CPU notifiers. 4644 * Workqueues should be brought up before normal priority CPU notifiers.
4645 * This will be registered high priority CPU notifier. 4645 * This will be registered high priority CPU notifier.
4646 */ 4646 */
4647static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb, 4647static int workqueue_cpu_up_callback(struct notifier_block *nfb,
4648 unsigned long action, 4648 unsigned long action,
4649 void *hcpu) 4649 void *hcpu)
4650{ 4650{
@@ -4697,7 +4697,7 @@ static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb,
4697 * Workqueues should be brought down after normal priority CPU notifiers. 4697 * Workqueues should be brought down after normal priority CPU notifiers.
4698 * This will be registered as low priority CPU notifier. 4698 * This will be registered as low priority CPU notifier.
4699 */ 4699 */
4700static int __cpuinit workqueue_cpu_down_callback(struct notifier_block *nfb, 4700static int workqueue_cpu_down_callback(struct notifier_block *nfb,
4701 unsigned long action, 4701 unsigned long action,
4702 void *hcpu) 4702 void *hcpu)
4703{ 4703{
diff --git a/lib/Kconfig b/lib/Kconfig
index 35da51359d40..71d9f81f6eed 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -66,8 +66,6 @@ config CRC16
66 66
67config CRC_T10DIF 67config CRC_T10DIF
68 tristate "CRC calculation for the T10 Data Integrity Field" 68 tristate "CRC calculation for the T10 Data Integrity Field"
69 select CRYPTO
70 select CRYPTO_CRCT10DIF
71 help 69 help
72 This option is only needed if a module that's not in the 70 This option is only needed if a module that's not in the
73 kernel tree needs to calculate CRC checks for use with the 71 kernel tree needs to calculate CRC checks for use with the
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 98ac17ed6222..1501aa553221 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -238,7 +238,7 @@ config DEBUG_SECTION_MISMATCH
238 any use of code/data previously in these sections would 238 any use of code/data previously in these sections would
239 most likely result in an oops. 239 most likely result in an oops.
240 In the code, functions and variables are annotated with 240 In the code, functions and variables are annotated with
241 __init, __cpuinit, etc. (see the full list in include/linux/init.h), 241 __init,, etc. (see the full list in include/linux/init.h),
242 which results in the code/data being placed in specific sections. 242 which results in the code/data being placed in specific sections.
243 The section mismatch analysis is always performed after a full 243 The section mismatch analysis is always performed after a full
244 kernel build, and enabling this option causes the following 244 kernel build, and enabling this option causes the following
diff --git a/lib/crc-t10dif.c b/lib/crc-t10dif.c
index fe3428c07b47..fbbd66ed86cd 100644
--- a/lib/crc-t10dif.c
+++ b/lib/crc-t10dif.c
@@ -11,44 +11,57 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/crc-t10dif.h> 13#include <linux/crc-t10dif.h>
14#include <linux/err.h>
15#include <linux/init.h>
16#include <crypto/hash.h>
17 14
18static struct crypto_shash *crct10dif_tfm; 15/* Table generated using the following polynomium:
16 * x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
17 * gt: 0x8bb7
18 */
19static const __u16 t10_dif_crc_table[256] = {
20 0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B,
21 0xEFBD, 0x640A, 0x7364, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6,
22 0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F, 0x7A11, 0xF1A6,
23 0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B,
24 0xA99A, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1,
25 0x4627, 0xCD90, 0xDAFE, 0x5149, 0xF422, 0x7F95, 0x68FB, 0xE34C,
26 0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B, 0x583C,
27 0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781,
28 0xD883, 0x5334, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8,
29 0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B, 0x0E8C, 0x19E2, 0x9255,
30 0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925,
31 0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698,
32 0x7119, 0xFAAE, 0xEDC0, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472,
33 0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716, 0xB078, 0x3BCF,
34 0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF,
35 0xCA69, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02,
36 0x3AB1, 0xB106, 0xA668, 0x2DDF, 0x88B4, 0x0303, 0x146D, 0x9FDA,
37 0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0, 0x7067,
38 0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17,
39 0x81C1, 0x0A76, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA,
40 0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E, 0xAA99, 0xBDF7, 0x3640,
41 0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD,
42 0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D,
43 0x285B, 0xA3EC, 0xB482, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30,
44 0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80, 0xCCEE, 0x4759,
45 0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4,
46 0xB6FF, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394,
47 0x5942, 0xD2F5, 0xC59B, 0x4E2C, 0xEB47, 0x60F0, 0x779E, 0xFC29,
48 0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574, 0xEEC3,
49 0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E,
50 0x1F65, 0x94D2, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E,
51 0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD, 0xC96A, 0xDE04, 0x55B3
52};
19 53
20__u16 crc_t10dif(const unsigned char *buffer, size_t len) 54__u16 crc_t10dif(const unsigned char *buffer, size_t len)
21{ 55{
22 struct { 56 __u16 crc = 0;
23 struct shash_desc shash; 57 unsigned int i;
24 char ctx[2];
25 } desc;
26 int err;
27
28 desc.shash.tfm = crct10dif_tfm;
29 desc.shash.flags = 0;
30 *(__u16 *)desc.ctx = 0;
31 58
32 err = crypto_shash_update(&desc.shash, buffer, len); 59 for (i = 0 ; i < len ; i++)
33 BUG_ON(err); 60 crc = (crc << 8) ^ t10_dif_crc_table[((crc >> 8) ^ buffer[i]) & 0xff];
34 61
35 return *(__u16 *)desc.ctx; 62 return crc;
36} 63}
37EXPORT_SYMBOL(crc_t10dif); 64EXPORT_SYMBOL(crc_t10dif);
38 65
39static int __init crc_t10dif_mod_init(void)
40{
41 crct10dif_tfm = crypto_alloc_shash("crct10dif", 0, 0);
42 return PTR_RET(crct10dif_tfm);
43}
44
45static void __exit crc_t10dif_mod_fini(void)
46{
47 crypto_free_shash(crct10dif_tfm);
48}
49
50module_init(crc_t10dif_mod_init);
51module_exit(crc_t10dif_mod_fini);
52
53MODULE_DESCRIPTION("T10 DIF CRC calculation"); 66MODULE_DESCRIPTION("T10 DIF CRC calculation");
54MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
diff --git a/lib/earlycpio.c b/lib/earlycpio.c
index 8078ef49cb79..7aa7ce250c94 100644
--- a/lib/earlycpio.c
+++ b/lib/earlycpio.c
@@ -63,7 +63,7 @@ enum cpio_fields {
63 * the match returned an empty filename string. 63 * the match returned an empty filename string.
64 */ 64 */
65 65
66struct cpio_data __cpuinit find_cpio_data(const char *path, void *data, 66struct cpio_data find_cpio_data(const char *path, void *data,
67 size_t len, long *offset) 67 size_t len, long *offset)
68{ 68{
69 const size_t cpio_header_len = 8*C_NFIELDS - 2; 69 const size_t cpio_header_len = 8*C_NFIELDS - 2;
diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
index d411355f238e..aac511417ad1 100644
--- a/lib/mpi/longlong.h
+++ b/lib/mpi/longlong.h
@@ -151,15 +151,12 @@ do { \
151#endif /* __a29k__ */ 151#endif /* __a29k__ */
152 152
153#if defined(__alpha) && W_TYPE_SIZE == 64 153#if defined(__alpha) && W_TYPE_SIZE == 64
154#define umul_ppmm(ph, pl, m0, m1) \ 154#define umul_ppmm(ph, pl, m0, m1) \
155do { \ 155do { \
156 UDItype __m0 = (m0), __m1 = (m1); \ 156 UDItype __m0 = (m0), __m1 = (m1); \
157 __asm__ ("umulh %r1,%2,%0" \ 157 (ph) = __builtin_alpha_umulh(__m0, __m1); \
158 : "=r" ((UDItype) ph) \ 158 (pl) = __m0 * __m1; \
159 : "%rJ" (__m0), \ 159} while (0)
160 "rI" (__m1)); \
161 (pl) = __m0 * __m1; \
162 } while (0)
163#define UMUL_TIME 46 160#define UMUL_TIME 46
164#ifndef LONGLONG_STANDALONE 161#ifndef LONGLONG_STANDALONE
165#define udiv_qrnnd(q, r, n1, n0, d) \ 162#define udiv_qrnnd(q, r, n1, n0, d) \
@@ -167,7 +164,7 @@ do { UDItype __r; \
167 (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \ 164 (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \
168 (r) = __r; \ 165 (r) = __r; \
169} while (0) 166} while (0)
170extern UDItype __udiv_qrnnd(); 167extern UDItype __udiv_qrnnd(UDItype *, UDItype, UDItype, UDItype);
171#define UDIV_TIME 220 168#define UDIV_TIME 220
172#endif /* LONGLONG_STANDALONE */ 169#endif /* LONGLONG_STANDALONE */
173#endif /* __alpha */ 170#endif /* __alpha */
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 1fc23a3277e1..93c5d5ecff4e 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -158,7 +158,7 @@ static void compute_batch_value(void)
158 percpu_counter_batch = max(32, nr*2); 158 percpu_counter_batch = max(32, nr*2);
159} 159}
160 160
161static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb, 161static int percpu_counter_hotcpu_callback(struct notifier_block *nb,
162 unsigned long action, void *hcpu) 162 unsigned long action, void *hcpu)
163{ 163{
164#ifdef CONFIG_HOTPLUG_CPU 164#ifdef CONFIG_HOTPLUG_CPU
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index d014ee5fcbbd..e04454cdb33f 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -232,8 +232,6 @@ static ssize_t stable_pages_required_show(struct device *dev,
232 bdi_cap_stable_pages_required(bdi) ? 1 : 0); 232 bdi_cap_stable_pages_required(bdi) ? 1 : 0);
233} 233}
234 234
235#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
236
237static struct device_attribute bdi_dev_attrs[] = { 235static struct device_attribute bdi_dev_attrs[] = {
238 __ATTR_RW(read_ahead_kb), 236 __ATTR_RW(read_ahead_kb),
239 __ATTR_RW(min_ratio), 237 __ATTR_RW(min_ratio),
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d12ca6f3c293..00a7a664b9c1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2522,7 +2522,7 @@ static void mem_cgroup_drain_pcp_counter(struct mem_cgroup *memcg, int cpu)
2522 spin_unlock(&memcg->pcp_counter_lock); 2522 spin_unlock(&memcg->pcp_counter_lock);
2523} 2523}
2524 2524
2525static int __cpuinit memcg_cpu_hotplug_callback(struct notifier_block *nb, 2525static int memcg_cpu_hotplug_callback(struct notifier_block *nb,
2526 unsigned long action, 2526 unsigned long action,
2527 void *hcpu) 2527 void *hcpu)
2528{ 2528{
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 4514ad7415c3..3f0c895c71fe 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1619,7 +1619,7 @@ void writeback_set_ratelimit(void)
1619 ratelimit_pages = 16; 1619 ratelimit_pages = 16;
1620} 1620}
1621 1621
1622static int __cpuinit 1622static int
1623ratelimit_handler(struct notifier_block *self, unsigned long action, 1623ratelimit_handler(struct notifier_block *self, unsigned long action,
1624 void *hcpu) 1624 void *hcpu)
1625{ 1625{
@@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
1634 } 1634 }
1635} 1635}
1636 1636
1637static struct notifier_block __cpuinitdata ratelimit_nb = { 1637static struct notifier_block ratelimit_nb = {
1638 .notifier_call = ratelimit_handler, 1638 .notifier_call = ratelimit_handler,
1639 .next = NULL, 1639 .next = NULL,
1640}; 1640};
diff --git a/mm/slab.c b/mm/slab.c
index 35cb0c861508..2580db062df9 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -787,7 +787,7 @@ static void next_reap_node(void)
787 * the CPUs getting into lockstep and contending for the global cache chain 787 * the CPUs getting into lockstep and contending for the global cache chain
788 * lock. 788 * lock.
789 */ 789 */
790static void __cpuinit start_cpu_timer(int cpu) 790static void start_cpu_timer(int cpu)
791{ 791{
792 struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu); 792 struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu);
793 793
@@ -1186,7 +1186,7 @@ static inline int slabs_tofree(struct kmem_cache *cachep,
1186 return (n->free_objects + cachep->num - 1) / cachep->num; 1186 return (n->free_objects + cachep->num - 1) / cachep->num;
1187} 1187}
1188 1188
1189static void __cpuinit cpuup_canceled(long cpu) 1189static void cpuup_canceled(long cpu)
1190{ 1190{
1191 struct kmem_cache *cachep; 1191 struct kmem_cache *cachep;
1192 struct kmem_cache_node *n = NULL; 1192 struct kmem_cache_node *n = NULL;
@@ -1251,7 +1251,7 @@ free_array_cache:
1251 } 1251 }
1252} 1252}
1253 1253
1254static int __cpuinit cpuup_prepare(long cpu) 1254static int cpuup_prepare(long cpu)
1255{ 1255{
1256 struct kmem_cache *cachep; 1256 struct kmem_cache *cachep;
1257 struct kmem_cache_node *n = NULL; 1257 struct kmem_cache_node *n = NULL;
@@ -1334,7 +1334,7 @@ bad:
1334 return -ENOMEM; 1334 return -ENOMEM;
1335} 1335}
1336 1336
1337static int __cpuinit cpuup_callback(struct notifier_block *nfb, 1337static int cpuup_callback(struct notifier_block *nfb,
1338 unsigned long action, void *hcpu) 1338 unsigned long action, void *hcpu)
1339{ 1339{
1340 long cpu = (long)hcpu; 1340 long cpu = (long)hcpu;
@@ -1390,7 +1390,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1390 return notifier_from_errno(err); 1390 return notifier_from_errno(err);
1391} 1391}
1392 1392
1393static struct notifier_block __cpuinitdata cpucache_notifier = { 1393static struct notifier_block cpucache_notifier = {
1394 &cpuup_callback, NULL, 0 1394 &cpuup_callback, NULL, 0
1395}; 1395};
1396 1396
diff --git a/mm/slub.c b/mm/slub.c
index 3b482c863002..2b02d666bf63 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3773,7 +3773,7 @@ int __kmem_cache_create(struct kmem_cache *s, unsigned long flags)
3773 * Use the cpu notifier to insure that the cpu slabs are flushed when 3773 * Use the cpu notifier to insure that the cpu slabs are flushed when
3774 * necessary. 3774 * necessary.
3775 */ 3775 */
3776static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb, 3776static int slab_cpuup_callback(struct notifier_block *nfb,
3777 unsigned long action, void *hcpu) 3777 unsigned long action, void *hcpu)
3778{ 3778{
3779 long cpu = (long)hcpu; 3779 long cpu = (long)hcpu;
@@ -3799,7 +3799,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
3799 return NOTIFY_OK; 3799 return NOTIFY_OK;
3800} 3800}
3801 3801
3802static struct notifier_block __cpuinitdata slab_notifier = { 3802static struct notifier_block slab_notifier = {
3803 .notifier_call = slab_cpuup_callback 3803 .notifier_call = slab_cpuup_callback
3804}; 3804};
3805 3805
diff --git a/mm/vmstat.c b/mm/vmstat.c
index f42745e65780..20c2ef4458fa 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1182,7 +1182,7 @@ static void vmstat_update(struct work_struct *w)
1182 round_jiffies_relative(sysctl_stat_interval)); 1182 round_jiffies_relative(sysctl_stat_interval));
1183} 1183}
1184 1184
1185static void __cpuinit start_cpu_timer(int cpu) 1185static void start_cpu_timer(int cpu)
1186{ 1186{
1187 struct delayed_work *work = &per_cpu(vmstat_work, cpu); 1187 struct delayed_work *work = &per_cpu(vmstat_work, cpu);
1188 1188
@@ -1194,7 +1194,7 @@ static void __cpuinit start_cpu_timer(int cpu)
1194 * Use the cpu notifier to insure that the thresholds are recalculated 1194 * Use the cpu notifier to insure that the thresholds are recalculated
1195 * when necessary. 1195 * when necessary.
1196 */ 1196 */
1197static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb, 1197static int vmstat_cpuup_callback(struct notifier_block *nfb,
1198 unsigned long action, 1198 unsigned long action,
1199 void *hcpu) 1199 void *hcpu)
1200{ 1200{
@@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
1226 return NOTIFY_OK; 1226 return NOTIFY_OK;
1227} 1227}
1228 1228
1229static struct notifier_block __cpuinitdata vmstat_notifier = 1229static struct notifier_block vmstat_notifier =
1230 { &vmstat_cpuup_callback, NULL, 0 }; 1230 { &vmstat_cpuup_callback, NULL, 0 };
1231#endif 1231#endif
1232 1232
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 8a15eaadc4bd..4a78c4de9f20 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -9,7 +9,7 @@ bool vlan_do_receive(struct sk_buff **skbp)
9{ 9{
10 struct sk_buff *skb = *skbp; 10 struct sk_buff *skb = *skbp;
11 __be16 vlan_proto = skb->vlan_proto; 11 __be16 vlan_proto = skb->vlan_proto;
12 u16 vlan_id = skb->vlan_tci & VLAN_VID_MASK; 12 u16 vlan_id = vlan_tx_tag_get_id(skb);
13 struct net_device *vlan_dev; 13 struct net_device *vlan_dev;
14 struct vlan_pcpu_stats *rx_stats; 14 struct vlan_pcpu_stats *rx_stats;
15 15
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 3a8c8fd63c88..1cd3d2a406f5 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -73,6 +73,8 @@ vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
73{ 73{
74 struct vlan_priority_tci_mapping *mp; 74 struct vlan_priority_tci_mapping *mp;
75 75
76 smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */
77
76 mp = vlan_dev_priv(dev)->egress_priority_map[(skb->priority & 0xF)]; 78 mp = vlan_dev_priv(dev)->egress_priority_map[(skb->priority & 0xF)];
77 while (mp) { 79 while (mp) {
78 if (mp->priority == skb->priority) { 80 if (mp->priority == skb->priority) {
@@ -249,6 +251,11 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
249 np->next = mp; 251 np->next = mp;
250 np->priority = skb_prio; 252 np->priority = skb_prio;
251 np->vlan_qos = vlan_qos; 253 np->vlan_qos = vlan_qos;
254 /* Before inserting this element in hash table, make sure all its fields
255 * are committed to memory.
256 * coupled with smp_rmb() in vlan_dev_get_egress_qos_mask()
257 */
258 smp_wmb();
252 vlan->egress_priority_map[skb_prio & 0xF] = np; 259 vlan->egress_priority_map[skb_prio & 0xF] = np;
253 if (vlan_qos) 260 if (vlan_qos)
254 vlan->nr_egress_mappings++; 261 vlan->nr_egress_mappings++;
diff --git a/net/core/dev.c b/net/core/dev.c
index a3d8d44cb7f4..26755dd40daa 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3580,8 +3580,15 @@ ncls:
3580 } 3580 }
3581 } 3581 }
3582 3582
3583 if (vlan_tx_nonzero_tag_present(skb)) 3583 if (unlikely(vlan_tx_tag_present(skb))) {
3584 skb->pkt_type = PACKET_OTHERHOST; 3584 if (vlan_tx_tag_get_id(skb))
3585 skb->pkt_type = PACKET_OTHERHOST;
3586 /* Note: we might in the future use prio bits
3587 * and set skb->priority like in vlan_do_receive()
3588 * For the time being, just ignore Priority Code Point
3589 */
3590 skb->vlan_tci = 0;
3591 }
3585 3592
3586 /* deliver only exact match when indicated */ 3593 /* deliver only exact match when indicated */
3587 null_or_dev = deliver_exact ? skb->dev : NULL; 3594 null_or_dev = deliver_exact ? skb->dev : NULL;
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index ab5fa6336c84..78e9d9223e40 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -279,11 +279,16 @@ static u32 __ethtool_get_flags(struct net_device *dev)
279{ 279{
280 u32 flags = 0; 280 u32 flags = 0;
281 281
282 if (dev->features & NETIF_F_LRO) flags |= ETH_FLAG_LRO; 282 if (dev->features & NETIF_F_LRO)
283 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) flags |= ETH_FLAG_RXVLAN; 283 flags |= ETH_FLAG_LRO;
284 if (dev->features & NETIF_F_HW_VLAN_CTAG_TX) flags |= ETH_FLAG_TXVLAN; 284 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX)
285 if (dev->features & NETIF_F_NTUPLE) flags |= ETH_FLAG_NTUPLE; 285 flags |= ETH_FLAG_RXVLAN;
286 if (dev->features & NETIF_F_RXHASH) flags |= ETH_FLAG_RXHASH; 286 if (dev->features & NETIF_F_HW_VLAN_CTAG_TX)
287 flags |= ETH_FLAG_TXVLAN;
288 if (dev->features & NETIF_F_NTUPLE)
289 flags |= ETH_FLAG_NTUPLE;
290 if (dev->features & NETIF_F_RXHASH)
291 flags |= ETH_FLAG_RXHASH;
287 292
288 return flags; 293 return flags;
289} 294}
@@ -295,11 +300,16 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
295 if (data & ~ETH_ALL_FLAGS) 300 if (data & ~ETH_ALL_FLAGS)
296 return -EINVAL; 301 return -EINVAL;
297 302
298 if (data & ETH_FLAG_LRO) features |= NETIF_F_LRO; 303 if (data & ETH_FLAG_LRO)
299 if (data & ETH_FLAG_RXVLAN) features |= NETIF_F_HW_VLAN_CTAG_RX; 304 features |= NETIF_F_LRO;
300 if (data & ETH_FLAG_TXVLAN) features |= NETIF_F_HW_VLAN_CTAG_TX; 305 if (data & ETH_FLAG_RXVLAN)
301 if (data & ETH_FLAG_NTUPLE) features |= NETIF_F_NTUPLE; 306 features |= NETIF_F_HW_VLAN_CTAG_RX;
302 if (data & ETH_FLAG_RXHASH) features |= NETIF_F_RXHASH; 307 if (data & ETH_FLAG_TXVLAN)
308 features |= NETIF_F_HW_VLAN_CTAG_TX;
309 if (data & ETH_FLAG_NTUPLE)
310 features |= NETIF_F_NTUPLE;
311 if (data & ETH_FLAG_RXHASH)
312 features |= NETIF_F_RXHASH;
303 313
304 /* allow changing only bits set in hw_features */ 314 /* allow changing only bits set in hw_features */
305 changed = (features ^ dev->features) & ETH_ALL_FEATURES; 315 changed = (features ^ dev->features) & ETH_ALL_FEATURES;
diff --git a/net/core/flow.c b/net/core/flow.c
index 7102f166482d..dfa602ceb8cd 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -403,7 +403,7 @@ void flow_cache_flush_deferred(void)
403 schedule_work(&flow_cache_flush_work); 403 schedule_work(&flow_cache_flush_work);
404} 404}
405 405
406static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) 406static int flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
407{ 407{
408 struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu); 408 struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
409 size_t sz = sizeof(struct hlist_head) * flow_cache_hash_size(fc); 409 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)
421 return 0; 421 return 0;
422} 422}
423 423
424static int __cpuinit flow_cache_cpu(struct notifier_block *nfb, 424static int flow_cache_cpu(struct notifier_block *nfb,
425 unsigned long action, 425 unsigned long action,
426 void *hcpu) 426 void *hcpu)
427{ 427{
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 5359560926bc..be1f64d35358 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -401,27 +401,8 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
401} 401}
402EXPORT_SYMBOL(alloc_etherdev_mqs); 402EXPORT_SYMBOL(alloc_etherdev_mqs);
403 403
404static size_t _format_mac_addr(char *buf, int buflen,
405 const unsigned char *addr, int len)
406{
407 int i;
408 char *cp = buf;
409
410 for (i = 0; i < len; i++) {
411 cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]);
412 if (i == len - 1)
413 break;
414 cp += scnprintf(cp, buflen - (cp - buf), ":");
415 }
416 return cp - buf;
417}
418
419ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len) 404ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
420{ 405{
421 size_t l; 406 return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);
422
423 l = _format_mac_addr(buf, PAGE_SIZE, addr, len);
424 l += scnprintf(buf + l, PAGE_SIZE - l, "\n");
425 return (ssize_t)l;
426} 407}
427EXPORT_SYMBOL(sysfs_format_mac); 408EXPORT_SYMBOL(sysfs_format_mac);
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 3da817b89e9b..15e3e683adec 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -190,10 +190,7 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
190{ 190{
191 struct net *net = dev_net(skb->dev); 191 struct net *net = dev_net(skb->dev);
192 192
193 __skb_pull(skb, ip_hdrlen(skb)); 193 __skb_pull(skb, skb_network_header_len(skb));
194
195 /* Point into the IP datagram, just past the header. */
196 skb_reset_transport_header(skb);
197 194
198 rcu_read_lock(); 195 rcu_read_lock();
199 { 196 {
@@ -437,6 +434,8 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
437 goto drop; 434 goto drop;
438 } 435 }
439 436
437 skb->transport_header = skb->network_header + iph->ihl*4;
438
440 /* Remove any debris in the socket control block */ 439 /* Remove any debris in the socket control block */
441 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); 440 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
442 441
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index b3b5730b48c5..24c03396e008 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -479,7 +479,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
479 if (ifp) { 479 if (ifp) {
480 src_addr = solicited_addr; 480 src_addr = solicited_addr;
481 if (ifp->flags & IFA_F_OPTIMISTIC) 481 if (ifp->flags & IFA_F_OPTIMISTIC)
482 override = 0; 482 override = false;
483 inc_opt |= ifp->idev->cnf.force_tllao; 483 inc_opt |= ifp->idev->cnf.force_tllao;
484 in6_ifa_put(ifp); 484 in6_ifa_put(ifp);
485 } else { 485 } else {
@@ -557,7 +557,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
557 } 557 }
558 558
559 if (ipv6_addr_any(saddr)) 559 if (ipv6_addr_any(saddr))
560 inc_opt = 0; 560 inc_opt = false;
561 if (inc_opt) 561 if (inc_opt)
562 optlen += ndisc_opt_addr_space(dev); 562 optlen += ndisc_opt_addr_space(dev);
563 563
@@ -790,7 +790,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
790 (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) { 790 (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
791 if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && 791 if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
792 skb->pkt_type != PACKET_HOST && 792 skb->pkt_type != PACKET_HOST &&
793 inc != 0 && 793 inc &&
794 idev->nd_parms->proxy_delay != 0) { 794 idev->nd_parms->proxy_delay != 0) {
795 /* 795 /*
796 * for anycast or proxy, 796 * for anycast or proxy,
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index d14152e866d9..ffcec225b5d9 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -44,12 +44,12 @@ static int irlan_eth_open(struct net_device *dev);
44static int irlan_eth_close(struct net_device *dev); 44static int irlan_eth_close(struct net_device *dev);
45static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb, 45static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
46 struct net_device *dev); 46 struct net_device *dev);
47static void irlan_eth_set_multicast_list( struct net_device *dev); 47static void irlan_eth_set_multicast_list(struct net_device *dev);
48 48
49static const struct net_device_ops irlan_eth_netdev_ops = { 49static const struct net_device_ops irlan_eth_netdev_ops = {
50 .ndo_open = irlan_eth_open, 50 .ndo_open = irlan_eth_open,
51 .ndo_stop = irlan_eth_close, 51 .ndo_stop = irlan_eth_close,
52 .ndo_start_xmit = irlan_eth_xmit, 52 .ndo_start_xmit = irlan_eth_xmit,
53 .ndo_set_rx_mode = irlan_eth_set_multicast_list, 53 .ndo_set_rx_mode = irlan_eth_set_multicast_list,
54 .ndo_change_mtu = eth_change_mtu, 54 .ndo_change_mtu = eth_change_mtu,
55 .ndo_validate_addr = eth_validate_addr, 55 .ndo_validate_addr = eth_validate_addr,
@@ -110,7 +110,7 @@ static int irlan_eth_open(struct net_device *dev)
110{ 110{
111 struct irlan_cb *self = netdev_priv(dev); 111 struct irlan_cb *self = netdev_priv(dev);
112 112
113 IRDA_DEBUG(2, "%s()\n", __func__ ); 113 IRDA_DEBUG(2, "%s()\n", __func__);
114 114
115 /* Ready to play! */ 115 /* Ready to play! */
116 netif_stop_queue(dev); /* Wait until data link is ready */ 116 netif_stop_queue(dev); /* Wait until data link is ready */
@@ -137,7 +137,7 @@ static int irlan_eth_close(struct net_device *dev)
137{ 137{
138 struct irlan_cb *self = netdev_priv(dev); 138 struct irlan_cb *self = netdev_priv(dev);
139 139
140 IRDA_DEBUG(2, "%s()\n", __func__ ); 140 IRDA_DEBUG(2, "%s()\n", __func__);
141 141
142 /* Stop device */ 142 /* Stop device */
143 netif_stop_queue(dev); 143 netif_stop_queue(dev);
@@ -310,35 +310,32 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
310{ 310{
311 struct irlan_cb *self = netdev_priv(dev); 311 struct irlan_cb *self = netdev_priv(dev);
312 312
313 IRDA_DEBUG(2, "%s()\n", __func__ ); 313 IRDA_DEBUG(2, "%s()\n", __func__);
314 314
315 /* Check if data channel has been connected yet */ 315 /* Check if data channel has been connected yet */
316 if (self->client.state != IRLAN_DATA) { 316 if (self->client.state != IRLAN_DATA) {
317 IRDA_DEBUG(1, "%s(), delaying!\n", __func__ ); 317 IRDA_DEBUG(1, "%s(), delaying!\n", __func__);
318 return; 318 return;
319 } 319 }
320 320
321 if (dev->flags & IFF_PROMISC) { 321 if (dev->flags & IFF_PROMISC) {
322 /* Enable promiscuous mode */ 322 /* Enable promiscuous mode */
323 IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n"); 323 IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n");
324 } 324 } else if ((dev->flags & IFF_ALLMULTI) ||
325 else if ((dev->flags & IFF_ALLMULTI) ||
326 netdev_mc_count(dev) > HW_MAX_ADDRS) { 325 netdev_mc_count(dev) > HW_MAX_ADDRS) {
327 /* Disable promiscuous mode, use normal mode. */ 326 /* Disable promiscuous mode, use normal mode. */
328 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); 327 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__);
329 /* hardware_set_filter(NULL); */ 328 /* hardware_set_filter(NULL); */
330 329
331 irlan_set_multicast_filter(self, TRUE); 330 irlan_set_multicast_filter(self, TRUE);
332 } 331 } else if (!netdev_mc_empty(dev)) {
333 else if (!netdev_mc_empty(dev)) { 332 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__);
334 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ );
335 /* Walk the address list, and load the filter */ 333 /* Walk the address list, and load the filter */
336 /* hardware_set_filter(dev->mc_list); */ 334 /* hardware_set_filter(dev->mc_list); */
337 335
338 irlan_set_multicast_filter(self, TRUE); 336 irlan_set_multicast_filter(self, TRUE);
339 } 337 } else {
340 else { 338 IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__);
341 IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__ );
342 irlan_set_multicast_filter(self, FALSE); 339 irlan_set_multicast_filter(self, FALSE);
343 } 340 }
344 341
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 4fe76ff214c2..cd5b8ec9be04 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -621,7 +621,7 @@ static void iucv_disable(void)
621 put_online_cpus(); 621 put_online_cpus();
622} 622}
623 623
624static int __cpuinit iucv_cpu_notify(struct notifier_block *self, 624static int iucv_cpu_notify(struct notifier_block *self,
625 unsigned long action, void *hcpu) 625 unsigned long action, void *hcpu)
626{ 626{
627 cpumask_t cpumask; 627 cpumask_t cpumask;
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index a7ab323849b6..8056fb4e618a 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -113,7 +113,6 @@
113 113
114#define FRAC_BITS 30 /* fixed point arithmetic */ 114#define FRAC_BITS 30 /* fixed point arithmetic */
115#define ONE_FP (1UL << FRAC_BITS) 115#define ONE_FP (1UL << FRAC_BITS)
116#define IWSUM (ONE_FP/QFQ_MAX_WSUM)
117 116
118#define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */ 117#define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */
119#define QFQ_MIN_LMAX 512 /* see qfq_slot_insert */ 118#define QFQ_MIN_LMAX 512 /* see qfq_slot_insert */
@@ -189,6 +188,7 @@ struct qfq_sched {
189 struct qfq_aggregate *in_serv_agg; /* Aggregate being served. */ 188 struct qfq_aggregate *in_serv_agg; /* Aggregate being served. */
190 u32 num_active_agg; /* Num. of active aggregates */ 189 u32 num_active_agg; /* Num. of active aggregates */
191 u32 wsum; /* weight sum */ 190 u32 wsum; /* weight sum */
191 u32 iwsum; /* inverse weight sum */
192 192
193 unsigned long bitmaps[QFQ_MAX_STATE]; /* Group bitmaps. */ 193 unsigned long bitmaps[QFQ_MAX_STATE]; /* Group bitmaps. */
194 struct qfq_group groups[QFQ_MAX_INDEX + 1]; /* The groups. */ 194 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,
314 314
315 q->wsum += 315 q->wsum +=
316 (int) agg->class_weight * (new_num_classes - agg->num_classes); 316 (int) agg->class_weight * (new_num_classes - agg->num_classes);
317 q->iwsum = ONE_FP / q->wsum;
317 318
318 agg->num_classes = new_num_classes; 319 agg->num_classes = new_num_classes;
319} 320}
@@ -340,6 +341,10 @@ static void qfq_destroy_agg(struct qfq_sched *q, struct qfq_aggregate *agg)
340{ 341{
341 if (!hlist_unhashed(&agg->nonfull_next)) 342 if (!hlist_unhashed(&agg->nonfull_next))
342 hlist_del_init(&agg->nonfull_next); 343 hlist_del_init(&agg->nonfull_next);
344 q->wsum -= agg->class_weight;
345 if (q->wsum != 0)
346 q->iwsum = ONE_FP / q->wsum;
347
343 if (q->in_serv_agg == agg) 348 if (q->in_serv_agg == agg)
344 q->in_serv_agg = qfq_choose_next_agg(q); 349 q->in_serv_agg = qfq_choose_next_agg(q);
345 kfree(agg); 350 kfree(agg);
@@ -834,38 +839,60 @@ static void qfq_make_eligible(struct qfq_sched *q)
834 } 839 }
835} 840}
836 841
837
838/* 842/*
839 * The index of the slot in which the aggregate is to be inserted must 843 * The index of the slot in which the input aggregate agg is to be
840 * not be higher than QFQ_MAX_SLOTS-2. There is a '-2' and not a '-1' 844 * inserted must not be higher than QFQ_MAX_SLOTS-2. There is a '-2'
841 * because the start time of the group may be moved backward by one 845 * and not a '-1' because the start time of the group may be moved
842 * slot after the aggregate has been inserted, and this would cause 846 * backward by one slot after the aggregate has been inserted, and
843 * non-empty slots to be right-shifted by one position. 847 * this would cause non-empty slots to be right-shifted by one
848 * position.
849 *
850 * QFQ+ fully satisfies this bound to the slot index if the parameters
851 * of the classes are not changed dynamically, and if QFQ+ never
852 * happens to postpone the service of agg unjustly, i.e., it never
853 * happens that the aggregate becomes backlogged and eligible, or just
854 * eligible, while an aggregate with a higher approximated finish time
855 * is being served. In particular, in this case QFQ+ guarantees that
856 * the timestamps of agg are low enough that the slot index is never
857 * higher than 2. Unfortunately, QFQ+ cannot provide the same
858 * guarantee if it happens to unjustly postpone the service of agg, or
859 * if the parameters of some class are changed.
860 *
861 * As for the first event, i.e., an out-of-order service, the
862 * upper bound to the slot index guaranteed by QFQ+ grows to
863 * 2 +
864 * QFQ_MAX_AGG_CLASSES * ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) *
865 * (current_max_weight/current_wsum) <= 2 + 8 * 128 * 1.
844 * 866 *
845 * If the weight and lmax (max_pkt_size) of the classes do not change, 867 * The following function deals with this problem by backward-shifting
846 * then QFQ+ does meet the above contraint according to the current 868 * the timestamps of agg, if needed, so as to guarantee that the slot
847 * values of its parameters. In fact, if the weight and lmax of the 869 * index is never higher than QFQ_MAX_SLOTS-2. This backward-shift may
848 * classes do not change, then, from the theory, QFQ+ guarantees that 870 * cause the service of other aggregates to be postponed, yet the
849 * the slot index is never higher than 871 * worst-case guarantees of these aggregates are not violated. In
850 * 2 + QFQ_MAX_AGG_CLASSES * ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) * 872 * fact, in case of no out-of-order service, the timestamps of agg
851 * (QFQ_MAX_WEIGHT/QFQ_MAX_WSUM) = 2 + 8 * 128 * (1 / 64) = 18 873 * would have been even lower than they are after the backward shift,
874 * because QFQ+ would have guaranteed a maximum value equal to 2 for
875 * the slot index, and 2 < QFQ_MAX_SLOTS-2. Hence the aggregates whose
876 * service is postponed because of the backward-shift would have
877 * however waited for the service of agg before being served.
852 * 878 *
853 * When the weight of a class is increased or the lmax of the class is 879 * The other event that may cause the slot index to be higher than 2
854 * decreased, a new aggregate with smaller slot size than the original 880 * for agg is a recent change of the parameters of some class. If the
855 * parent aggregate of the class may happen to be activated. The 881 * weight of a class is increased or the lmax (max_pkt_size) of the
856 * activation of this aggregate should be properly delayed to when the 882 * class is decreased, then a new aggregate with smaller slot size
857 * service of the class has finished in the ideal system tracked by 883 * than the original parent aggregate of the class may happen to be
858 * QFQ+. If the activation of the aggregate is not delayed to this 884 * activated. The activation of this aggregate should be properly
859 * reference time instant, then this aggregate may be unjustly served 885 * delayed to when the service of the class has finished in the ideal
860 * before other aggregates waiting for service. This may cause the 886 * system tracked by QFQ+. If the activation of the aggregate is not
861 * above bound to the slot index to be violated for some of these 887 * delayed to this reference time instant, then this aggregate may be
862 * unlucky aggregates. 888 * unjustly served before other aggregates waiting for service. This
889 * may cause the above bound to the slot index to be violated for some
890 * of these unlucky aggregates.
863 * 891 *
864 * Instead of delaying the activation of the new aggregate, which is 892 * Instead of delaying the activation of the new aggregate, which is
865 * quite complex, the following inaccurate but simple solution is used: 893 * quite complex, the above-discussed capping of the slot index is
866 * if the slot index is higher than QFQ_MAX_SLOTS-2, then the 894 * used to handle also the consequences of a change of the parameters
867 * timestamps of the aggregate are shifted backward so as to let the 895 * of a class.
868 * slot index become equal to QFQ_MAX_SLOTS-2.
869 */ 896 */
870static void qfq_slot_insert(struct qfq_group *grp, struct qfq_aggregate *agg, 897static void qfq_slot_insert(struct qfq_group *grp, struct qfq_aggregate *agg,
871 u64 roundedS) 898 u64 roundedS)
@@ -1136,7 +1163,7 @@ static struct sk_buff *qfq_dequeue(struct Qdisc *sch)
1136 else 1163 else
1137 in_serv_agg->budget -= len; 1164 in_serv_agg->budget -= len;
1138 1165
1139 q->V += (u64)len * IWSUM; 1166 q->V += (u64)len * q->iwsum;
1140 pr_debug("qfq dequeue: len %u F %lld now %lld\n", 1167 pr_debug("qfq dequeue: len %u F %lld now %lld\n",
1141 len, (unsigned long long) in_serv_agg->F, 1168 len, (unsigned long long) in_serv_agg->F,
1142 (unsigned long long) q->V); 1169 (unsigned long long) q->V);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 9963584605c0..74f6a704e374 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -309,6 +309,7 @@ static int rpc_client_register(const struct rpc_create_args *args,
309 return 0; 309 return 0;
310err_auth: 310err_auth:
311 pipefs_sb = rpc_get_sb_net(net); 311 pipefs_sb = rpc_get_sb_net(net);
312 rpc_unregister_client(clnt);
312 __rpc_clnt_remove_pipedir(clnt); 313 __rpc_clnt_remove_pipedir(clnt);
313out: 314out:
314 if (pipefs_sb) 315 if (pipefs_sb)
diff --git a/net/sunrpc/xprtrdma/svc_rdma_marshal.c b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
index 8d2edddf48cf..65b146297f5a 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_marshal.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
@@ -98,6 +98,7 @@ void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch,
98 */ 98 */
99static u32 *decode_write_list(u32 *va, u32 *vaend) 99static u32 *decode_write_list(u32 *va, u32 *vaend)
100{ 100{
101 unsigned long start, end;
101 int nchunks; 102 int nchunks;
102 103
103 struct rpcrdma_write_array *ary = 104 struct rpcrdma_write_array *ary =
@@ -113,9 +114,12 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
113 return NULL; 114 return NULL;
114 } 115 }
115 nchunks = ntohl(ary->wc_nchunks); 116 nchunks = ntohl(ary->wc_nchunks);
116 if (((unsigned long)&ary->wc_array[0] + 117
117 (sizeof(struct rpcrdma_write_chunk) * nchunks)) > 118 start = (unsigned long)&ary->wc_array[0];
118 (unsigned long)vaend) { 119 end = (unsigned long)vaend;
120 if (nchunks < 0 ||
121 nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
122 (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
119 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n", 123 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
120 ary, nchunks, vaend); 124 ary, nchunks, vaend);
121 return NULL; 125 return NULL;
@@ -129,6 +133,7 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
129 133
130static u32 *decode_reply_array(u32 *va, u32 *vaend) 134static u32 *decode_reply_array(u32 *va, u32 *vaend)
131{ 135{
136 unsigned long start, end;
132 int nchunks; 137 int nchunks;
133 struct rpcrdma_write_array *ary = 138 struct rpcrdma_write_array *ary =
134 (struct rpcrdma_write_array *)va; 139 (struct rpcrdma_write_array *)va;
@@ -143,9 +148,12 @@ static u32 *decode_reply_array(u32 *va, u32 *vaend)
143 return NULL; 148 return NULL;
144 } 149 }
145 nchunks = ntohl(ary->wc_nchunks); 150 nchunks = ntohl(ary->wc_nchunks);
146 if (((unsigned long)&ary->wc_array[0] + 151
147 (sizeof(struct rpcrdma_write_chunk) * nchunks)) > 152 start = (unsigned long)&ary->wc_array[0];
148 (unsigned long)vaend) { 153 end = (unsigned long)vaend;
154 if (nchunks < 0 ||
155 nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
156 (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
149 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n", 157 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
150 ary, nchunks, vaend); 158 ary, nchunks, vaend);
151 return NULL; 159 return NULL;
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index 76e0d5695075..823359ed95e1 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -166,7 +166,9 @@ void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id)
166 } else { 166 } else {
167 printk(KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n", 167 printk(KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
168 rtd->params->name, dma_ch, dcsr); 168 rtd->params->name, dma_ch, dcsr);
169 snd_pcm_stream_lock(substream);
169 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); 170 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
171 snd_pcm_stream_unlock(substream);
170 } 172 }
171} 173}
172EXPORT_SYMBOL(pxa2xx_pcm_dma_irq); 174EXPORT_SYMBOL(pxa2xx_pcm_dma_irq);
diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index e3cb46fef2c7..b3f39b5ed742 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -31,6 +31,7 @@
31#include <linux/export.h> 31#include <linux/export.h>
32#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/workqueue.h>
34 35
35/* 36/*
36 * common variables 37 * common variables
@@ -60,6 +61,14 @@ static void free_devinfo(void *private);
60#define call_ctl(type,rec) snd_seq_kernel_client_ctl(system_client, type, rec) 61#define call_ctl(type,rec) snd_seq_kernel_client_ctl(system_client, type, rec)
61 62
62 63
64/* call snd_seq_oss_midi_lookup_ports() asynchronously */
65static void async_call_lookup_ports(struct work_struct *work)
66{
67 snd_seq_oss_midi_lookup_ports(system_client);
68}
69
70static DECLARE_WORK(async_lookup_work, async_call_lookup_ports);
71
63/* 72/*
64 * create sequencer client for OSS sequencer 73 * create sequencer client for OSS sequencer
65 */ 74 */
@@ -85,9 +94,6 @@ snd_seq_oss_create_client(void)
85 system_client = rc; 94 system_client = rc;
86 debug_printk(("new client = %d\n", rc)); 95 debug_printk(("new client = %d\n", rc));
87 96
88 /* look up midi devices */
89 snd_seq_oss_midi_lookup_ports(system_client);
90
91 /* create annoucement receiver port */ 97 /* create annoucement receiver port */
92 memset(port, 0, sizeof(*port)); 98 memset(port, 0, sizeof(*port));
93 strcpy(port->name, "Receiver"); 99 strcpy(port->name, "Receiver");
@@ -115,6 +121,9 @@ snd_seq_oss_create_client(void)
115 } 121 }
116 rc = 0; 122 rc = 0;
117 123
124 /* look up midi devices */
125 schedule_work(&async_lookup_work);
126
118 __error: 127 __error:
119 kfree(port); 128 kfree(port);
120 return rc; 129 return rc;
@@ -160,6 +169,7 @@ receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic
160int 169int
161snd_seq_oss_delete_client(void) 170snd_seq_oss_delete_client(void)
162{ 171{
172 cancel_work_sync(&async_lookup_work);
163 if (system_client >= 0) 173 if (system_client >= 0)
164 snd_seq_delete_kernel_client(system_client); 174 snd_seq_delete_kernel_client(system_client);
165 175
diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c
index 677dc84590c7..862d84893ee8 100644
--- a/sound/core/seq/oss/seq_oss_midi.c
+++ b/sound/core/seq/oss/seq_oss_midi.c
@@ -72,7 +72,7 @@ static int send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
72 * look up the existing ports 72 * look up the existing ports
73 * this looks a very exhausting job. 73 * this looks a very exhausting job.
74 */ 74 */
75int __init 75int
76snd_seq_oss_midi_lookup_ports(int client) 76snd_seq_oss_midi_lookup_ports(int client)
77{ 77{
78 struct snd_seq_client_info *clinfo; 78 struct snd_seq_client_info *clinfo;
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 7e814a5c3677..4bbcc0fcd4eb 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -149,17 +149,19 @@
149#include <linux/interrupt.h> 149#include <linux/interrupt.h>
150#include <linux/mutex.h> 150#include <linux/mutex.h>
151#include <linux/slab.h> 151#include <linux/slab.h>
152#include <linux/delay.h>
152 153
153#include <asm/visws/cobalt.h> 154#include <asm/visws/cobalt.h>
154 155
155#include "sound_config.h" 156#include "sound_config.h"
156 157
158static DEFINE_MUTEX(vwsnd_mutex);
159
157/*****************************************************************************/ 160/*****************************************************************************/
158/* debug stuff */ 161/* debug stuff */
159 162
160#ifdef VWSND_DEBUG 163#ifdef VWSND_DEBUG
161 164
162static DEFINE_MUTEX(vwsnd_mutex);
163static int shut_up = 1; 165static int shut_up = 1;
164 166
165/* 167/*
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 185d54a5cb1a..dc632cdc3870 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -769,7 +769,10 @@ static void snd_card_asihpi_timer_function(unsigned long data)
769 s->number); 769 s->number);
770 ds->drained_count++; 770 ds->drained_count++;
771 if (ds->drained_count > 20) { 771 if (ds->drained_count > 20) {
772 unsigned long flags;
773 snd_pcm_stream_lock_irqsave(s, flags);
772 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); 774 snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
775 snd_pcm_stream_unlock_irqrestore(s, flags);
773 continue; 776 continue;
774 } 777 }
775 } else { 778 } else {
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index fe4c61bdb8ba..f6dec3ea371f 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -689,7 +689,9 @@ static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
689 if (! dma->substream || ! dma->running) 689 if (! dma->substream || ! dma->running)
690 return; 690 return;
691 snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type); 691 snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type);
692 snd_pcm_stream_lock(dma->substream);
692 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); 693 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
694 snd_pcm_stream_unlock(dma->substream);
693} 695}
694 696
695/* 697/*
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index cf29b9a1d65d..289563ecb6dd 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -638,7 +638,9 @@ static void snd_atiixp_xrun_dma(struct atiixp_modem *chip,
638 if (! dma->substream || ! dma->running) 638 if (! dma->substream || ! dma->running)
639 return; 639 return;
640 snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type); 640 snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type);
641 snd_pcm_stream_lock(dma->substream);
641 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); 642 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
643 snd_pcm_stream_unlock(dma->substream);
642} 644}
643 645
644/* 646/*
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 540bdef2f904..030ca8652a1c 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -2622,6 +2622,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
2622{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi }, 2622{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi },
2623{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi }, 2623{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi },
2624{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi }, 2624{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi },
2625{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi },
2625{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 2626{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
2626{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 2627{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
2627{ .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, 2628{ .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
@@ -2674,6 +2675,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0042");
2674MODULE_ALIAS("snd-hda-codec-id:10de0043"); 2675MODULE_ALIAS("snd-hda-codec-id:10de0043");
2675MODULE_ALIAS("snd-hda-codec-id:10de0044"); 2676MODULE_ALIAS("snd-hda-codec-id:10de0044");
2676MODULE_ALIAS("snd-hda-codec-id:10de0051"); 2677MODULE_ALIAS("snd-hda-codec-id:10de0051");
2678MODULE_ALIAS("snd-hda-codec-id:10de0060");
2677MODULE_ALIAS("snd-hda-codec-id:10de0067"); 2679MODULE_ALIAS("snd-hda-codec-id:10de0067");
2678MODULE_ALIAS("snd-hda-codec-id:10de8001"); 2680MODULE_ALIAS("snd-hda-codec-id:10de8001");
2679MODULE_ALIAS("snd-hda-codec-id:11069f80"); 2681MODULE_ALIAS("snd-hda-codec-id:11069f80");
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index e2f83591161b..92b9b4324372 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -417,9 +417,11 @@ static void stac_update_outputs(struct hda_codec *codec)
417 val &= ~spec->eapd_mask; 417 val &= ~spec->eapd_mask;
418 else 418 else
419 val |= spec->eapd_mask; 419 val |= spec->eapd_mask;
420 if (spec->gpio_data != val) 420 if (spec->gpio_data != val) {
421 spec->gpio_data = val;
421 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, 422 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir,
422 val); 423 val);
424 }
423 } 425 }
424} 426}
425 427
@@ -3231,7 +3233,7 @@ static const struct hda_fixup stac927x_fixups[] = {
3231 /* configure the analog microphone on some laptops */ 3233 /* configure the analog microphone on some laptops */
3232 { 0x0c, 0x90a79130 }, 3234 { 0x0c, 0x90a79130 },
3233 /* correct the front output jack as a hp out */ 3235 /* correct the front output jack as a hp out */
3234 { 0x0f, 0x0227011f }, 3236 { 0x0f, 0x0221101f },
3235 /* correct the front input jack as a mic */ 3237 /* correct the front input jack as a mic */
3236 { 0x0e, 0x02a79130 }, 3238 { 0x0e, 0x02a79130 },
3237 {} 3239 {}
@@ -3612,20 +3614,18 @@ static int stac_parse_auto_config(struct hda_codec *codec)
3612static int stac_init(struct hda_codec *codec) 3614static int stac_init(struct hda_codec *codec)
3613{ 3615{
3614 struct sigmatel_spec *spec = codec->spec; 3616 struct sigmatel_spec *spec = codec->spec;
3615 unsigned int gpio;
3616 int i; 3617 int i;
3617 3618
3618 /* override some hints */ 3619 /* override some hints */
3619 stac_store_hints(codec); 3620 stac_store_hints(codec);
3620 3621
3621 /* set up GPIO */ 3622 /* set up GPIO */
3622 gpio = spec->gpio_data;
3623 /* turn on EAPD statically when spec->eapd_switch isn't set. 3623 /* turn on EAPD statically when spec->eapd_switch isn't set.
3624 * otherwise, unsol event will turn it on/off dynamically 3624 * otherwise, unsol event will turn it on/off dynamically
3625 */ 3625 */
3626 if (!spec->eapd_switch) 3626 if (!spec->eapd_switch)
3627 gpio |= spec->eapd_mask; 3627 spec->gpio_data |= spec->eapd_mask;
3628 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); 3628 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
3629 3629
3630 snd_hda_gen_init(codec); 3630 snd_hda_gen_init(codec);
3631 3631
@@ -3915,6 +3915,7 @@ static void stac_setup_gpio(struct hda_codec *codec)
3915{ 3915{
3916 struct sigmatel_spec *spec = codec->spec; 3916 struct sigmatel_spec *spec = codec->spec;
3917 3917
3918 spec->gpio_mask |= spec->eapd_mask;
3918 if (spec->gpio_led) { 3919 if (spec->gpio_led) {
3919 if (!spec->vref_mute_led_nid) { 3920 if (!spec->vref_mute_led_nid) {
3920 spec->gpio_mask |= spec->gpio_led; 3921 spec->gpio_mask |= spec->gpio_led;
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c
index 1d38fd0bc4e2..d12826526798 100644
--- a/sound/soc/atmel/atmel-pcm-dma.c
+++ b/sound/soc/atmel/atmel-pcm-dma.c
@@ -81,7 +81,9 @@ static void atmel_pcm_dma_irq(u32 ssc_sr,
81 81
82 /* stop RX and capture: will be enabled again at restart */ 82 /* stop RX and capture: will be enabled again at restart */
83 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable); 83 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable);
84 snd_pcm_stream_lock(substream);
84 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); 85 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
86 snd_pcm_stream_unlock(substream);
85 87
86 /* now drain RHR and read status to remove xrun condition */ 88 /* now drain RHR and read status to remove xrun condition */
87 ssc_readx(prtd->ssc->regs, SSC_RHR); 89 ssc_readx(prtd->ssc->regs, SSC_RHR);
diff --git a/sound/soc/cirrus/ep93xx-ac97.c b/sound/soc/cirrus/ep93xx-ac97.c
index ac73c607410a..04491f0e8d1b 100644
--- a/sound/soc/cirrus/ep93xx-ac97.c
+++ b/sound/soc/cirrus/ep93xx-ac97.c
@@ -102,13 +102,13 @@ static struct ep93xx_ac97_info *ep93xx_ac97_info;
102 102
103static struct ep93xx_dma_data ep93xx_ac97_pcm_out = { 103static struct ep93xx_dma_data ep93xx_ac97_pcm_out = {
104 .name = "ac97-pcm-out", 104 .name = "ac97-pcm-out",
105 .dma_port = EP93XX_DMA_AAC1, 105 .port = EP93XX_DMA_AAC1,
106 .direction = DMA_MEM_TO_DEV, 106 .direction = DMA_MEM_TO_DEV,
107}; 107};
108 108
109static struct ep93xx_dma_data ep93xx_ac97_pcm_in = { 109static struct ep93xx_dma_data ep93xx_ac97_pcm_in = {
110 .name = "ac97-pcm-in", 110 .name = "ac97-pcm-in",
111 .dma_port = EP93XX_DMA_AAC1, 111 .port = EP93XX_DMA_AAC1,
112 .direction = DMA_DEV_TO_MEM, 112 .direction = DMA_DEV_TO_MEM,
113}; 113};
114 114
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index 3eeada57e87d..566a367c94fa 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -1612,7 +1612,7 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute)
1612 1612
1613static void max98088_sync_cache(struct snd_soc_codec *codec) 1613static void max98088_sync_cache(struct snd_soc_codec *codec)
1614{ 1614{
1615 u16 *reg_cache = codec->reg_cache; 1615 u8 *reg_cache = codec->reg_cache;
1616 int i; 1616 int i;
1617 1617
1618 if (!codec->cache_sync) 1618 if (!codec->cache_sync)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index d441559dc92c..6c8a9e7bee25 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -38,7 +38,7 @@
38static const struct reg_default sgtl5000_reg_defaults[] = { 38static const struct reg_default sgtl5000_reg_defaults[] = {
39 { SGTL5000_CHIP_CLK_CTRL, 0x0008 }, 39 { SGTL5000_CHIP_CLK_CTRL, 0x0008 },
40 { SGTL5000_CHIP_I2S_CTRL, 0x0010 }, 40 { SGTL5000_CHIP_I2S_CTRL, 0x0010 },
41 { SGTL5000_CHIP_SSS_CTRL, 0x0008 }, 41 { SGTL5000_CHIP_SSS_CTRL, 0x0010 },
42 { SGTL5000_CHIP_DAC_VOL, 0x3c3c }, 42 { SGTL5000_CHIP_DAC_VOL, 0x3c3c },
43 { SGTL5000_CHIP_PAD_STRENGTH, 0x015f }, 43 { SGTL5000_CHIP_PAD_STRENGTH, 0x015f },
44 { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 }, 44 { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 },
@@ -1527,6 +1527,9 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1527 if (IS_ERR(sgtl5000->mclk)) { 1527 if (IS_ERR(sgtl5000->mclk)) {
1528 ret = PTR_ERR(sgtl5000->mclk); 1528 ret = PTR_ERR(sgtl5000->mclk);
1529 dev_err(&client->dev, "Failed to get mclock: %d\n", ret); 1529 dev_err(&client->dev, "Failed to get mclock: %d\n", ret);
1530 /* Defer the probe to see if the clk will be provided later */
1531 if (ret == -ENOENT)
1532 return -EPROBE_DEFER;
1530 return ret; 1533 return ret;
1531 } 1534 }
1532 1535
diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h
index 4b69229a9818..2f8c88931f69 100644
--- a/sound/soc/codecs/sgtl5000.h
+++ b/sound/soc/codecs/sgtl5000.h
@@ -347,7 +347,7 @@
347#define SGTL5000_PLL_INT_DIV_MASK 0xf800 347#define SGTL5000_PLL_INT_DIV_MASK 0xf800
348#define SGTL5000_PLL_INT_DIV_SHIFT 11 348#define SGTL5000_PLL_INT_DIV_SHIFT 11
349#define SGTL5000_PLL_INT_DIV_WIDTH 5 349#define SGTL5000_PLL_INT_DIV_WIDTH 5
350#define SGTL5000_PLL_FRAC_DIV_MASK 0x0700 350#define SGTL5000_PLL_FRAC_DIV_MASK 0x07ff
351#define SGTL5000_PLL_FRAC_DIV_SHIFT 0 351#define SGTL5000_PLL_FRAC_DIV_SHIFT 0
352#define SGTL5000_PLL_FRAC_DIV_WIDTH 11 352#define SGTL5000_PLL_FRAC_DIV_WIDTH 11
353 353
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index 029f31c8e703..d8fc531c0e59 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -921,6 +921,7 @@ static struct snd_soc_dai_driver wm8978_dai = {
921 .formats = WM8978_FORMATS, 921 .formats = WM8978_FORMATS,
922 }, 922 },
923 .ops = &wm8978_dai_ops, 923 .ops = &wm8978_dai_ops,
924 .symmetric_rates = 1,
924}; 925};
925 926
926static int wm8978_suspend(struct snd_soc_codec *codec) 927static int wm8978_suspend(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 1d4b1ec66e36..ba832b77c543 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -3852,8 +3852,6 @@ static void wm8958_mic_work(struct work_struct *work)
3852 mic_complete_work.work); 3852 mic_complete_work.work);
3853 struct snd_soc_codec *codec = wm8994->hubs.codec; 3853 struct snd_soc_codec *codec = wm8994->hubs.codec;
3854 3854
3855 dev_crit(codec->dev, "MIC WORK %x\n", wm8994->mic_status);
3856
3857 pm_runtime_get_sync(codec->dev); 3855 pm_runtime_get_sync(codec->dev);
3858 3856
3859 mutex_lock(&wm8994->accdet_lock); 3857 mutex_lock(&wm8994->accdet_lock);
@@ -3863,8 +3861,6 @@ static void wm8958_mic_work(struct work_struct *work)
3863 mutex_unlock(&wm8994->accdet_lock); 3861 mutex_unlock(&wm8994->accdet_lock);
3864 3862
3865 pm_runtime_put(codec->dev); 3863 pm_runtime_put(codec->dev);
3866
3867 dev_crit(codec->dev, "MIC WORK %x DONE\n", wm8994->mic_status);
3868} 3864}
3869 3865
3870static irqreturn_t wm8958_mic_irq(int irq, void *data) 3866static irqreturn_t wm8958_mic_irq(int irq, void *data)
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index eb68c7db1cf3..361e4c03646e 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -1012,28 +1012,33 @@ int omap_mcbsp_init(struct platform_device *pdev)
1012 } 1012 }
1013 } 1013 }
1014 1014
1015 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); 1015 if (!pdev->dev.of_node) {
1016 if (!res) { 1016 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
1017 dev_err(&pdev->dev, "invalid rx DMA channel\n"); 1017 if (!res) {
1018 return -ENODEV; 1018 dev_err(&pdev->dev, "invalid tx DMA channel\n");
1019 } 1019 return -ENODEV;
1020 /* RX DMA request number, and port address configuration */ 1020 }
1021 mcbsp->dma_req[1] = res->start; 1021 mcbsp->dma_req[0] = res->start;
1022 mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1]; 1022 mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0];
1023 mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
1024 mcbsp->dma_data[1].maxburst = 4;
1025 1023
1026 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); 1024 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
1027 if (!res) { 1025 if (!res) {
1028 dev_err(&pdev->dev, "invalid tx DMA channel\n"); 1026 dev_err(&pdev->dev, "invalid rx DMA channel\n");
1029 return -ENODEV; 1027 return -ENODEV;
1028 }
1029 mcbsp->dma_req[1] = res->start;
1030 mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1];
1031 } else {
1032 mcbsp->dma_data[0].filter_data = "tx";
1033 mcbsp->dma_data[1].filter_data = "rx";
1030 } 1034 }
1031 /* TX DMA request number, and port address configuration */ 1035
1032 mcbsp->dma_req[0] = res->start;
1033 mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0];
1034 mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0); 1036 mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
1035 mcbsp->dma_data[0].maxburst = 4; 1037 mcbsp->dma_data[0].maxburst = 4;
1036 1038
1039 mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
1040 mcbsp->dma_data[1].maxburst = 4;
1041
1037 mcbsp->fclk = clk_get(&pdev->dev, "fck"); 1042 mcbsp->fclk = clk_get(&pdev->dev, "fck");
1038 if (IS_ERR(mcbsp->fclk)) { 1043 if (IS_ERR(mcbsp->fclk)) {
1039 ret = PTR_ERR(mcbsp->fclk); 1044 ret = PTR_ERR(mcbsp->fclk);
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index 2ad0370146fd..4db1f8e6e172 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -57,7 +57,6 @@ struct omap_dmic {
57 struct mutex mutex; 57 struct mutex mutex;
58 58
59 struct snd_dmaengine_dai_dma_data dma_data; 59 struct snd_dmaengine_dai_dma_data dma_data;
60 unsigned int dma_req;
61}; 60};
62 61
63static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) 62static 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)
478 } 477 }
479 dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG; 478 dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG;
480 479
481 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 480 dmic->dma_data.filter_data = "up_link";
482 if (!res) {
483 dev_err(dmic->dev, "invalid dma resource\n");
484 ret = -ENODEV;
485 goto err_put_clk;
486 }
487
488 dmic->dma_req = res->start;
489 dmic->dma_data.filter_data = &dmic->dma_req;
490 481
491 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); 482 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
492 if (!res) { 483 if (!res) {
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index eb05c7ed6d05..a49dc52f8abc 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -66,7 +66,6 @@ struct omap_mcpdm {
66 bool restart; 66 bool restart;
67 67
68 struct snd_dmaengine_dai_dma_data dma_data[2]; 68 struct snd_dmaengine_dai_dma_data dma_data[2];
69 unsigned int dma_req[2];
70}; 69};
71 70
72/* 71/*
@@ -477,19 +476,8 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
477 mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA; 476 mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA;
478 mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA; 477 mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA;
479 478
480 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link"); 479 mcpdm->dma_data[0].filter_data = "dn_link";
481 if (!res) 480 mcpdm->dma_data[1].filter_data = "up_link";
482 return -ENODEV;
483
484 mcpdm->dma_req[0] = res->start;
485 mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0];
486
487 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link");
488 if (!res)
489 return -ENODEV;
490
491 mcpdm->dma_req[1] = res->start;
492 mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1];
493 481
494 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); 482 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
495 if (res == NULL) 483 if (res == NULL)
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index c28e042f2208..a11405de86e8 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -113,14 +113,25 @@ static int omap_pcm_open(struct snd_pcm_substream *substream)
113{ 113{
114 struct snd_soc_pcm_runtime *rtd = substream->private_data; 114 struct snd_soc_pcm_runtime *rtd = substream->private_data;
115 struct snd_dmaengine_dai_dma_data *dma_data; 115 struct snd_dmaengine_dai_dma_data *dma_data;
116 int ret;
116 117
117 snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware); 118 snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
118 119
119 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 120 dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
120 121
121 return snd_dmaengine_pcm_open_request_chan(substream, 122 /* DT boot: filter_data is the DMA name */
122 omap_dma_filter_fn, 123 if (rtd->cpu_dai->dev->of_node) {
123 dma_data->filter_data); 124 struct dma_chan *chan;
125
126 chan = dma_request_slave_channel(rtd->cpu_dai->dev,
127 dma_data->filter_data);
128 ret = snd_dmaengine_pcm_open(substream, chan);
129 } else {
130 ret = snd_dmaengine_pcm_open_request_chan(substream,
131 omap_dma_filter_fn,
132 dma_data->filter_data);
133 }
134 return ret;
124} 135}
125 136
126static int omap_pcm_mmap(struct snd_pcm_substream *substream, 137static int omap_pcm_mmap(struct snd_pcm_substream *substream,
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
index 1358c7de2521..d0740a762963 100644
--- a/sound/soc/s6000/s6000-pcm.c
+++ b/sound/soc/s6000/s6000-pcm.c
@@ -128,7 +128,9 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data)
128 substream->runtime && 128 substream->runtime &&
129 snd_pcm_running(substream)) { 129 snd_pcm_running(substream)) {
130 dev_dbg(pcm->dev, "xrun\n"); 130 dev_dbg(pcm->dev, "xrun\n");
131 snd_pcm_stream_lock(substream);
131 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); 132 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
133 snd_pcm_stream_unlock(substream);
132 ret = IRQ_HANDLED; 134 ret = IRQ_HANDLED;
133 } 135 }
134 136
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 7a1734697434..959c702235c8 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -742,13 +742,13 @@ static int config_setup(struct i2s_dai *i2s)
742 return -EAGAIN; 742 return -EAGAIN;
743 } 743 }
744 744
745 /* Don't bother RFS, BFS & PSR in Slave mode */
746 if (is_slave(i2s))
747 return 0;
748
749 set_bfs(i2s, bfs); 745 set_bfs(i2s, bfs);
750 set_rfs(i2s, rfs); 746 set_rfs(i2s, rfs);
751 747
748 /* Don't bother with PSR in Slave mode */
749 if (is_slave(i2s))
750 return 0;
751
752 if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { 752 if (!(i2s->quirks & QUIRK_NO_MUXPSR)) {
753 psr = i2s->rclk_srcrate / i2s->frmclk / rfs; 753 psr = i2s->rclk_srcrate / i2s->frmclk / rfs;
754 writel(((psr - 1) << 8) | PSR_PSREN, i2s->addr + I2SPSR); 754 writel(((psr - 1) << 8) | PSR_PSREN, i2s->addr + I2SPSR);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0ec070cf7231..d82ee386eab5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3908,10 +3908,8 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
3908{ 3908{
3909 /* create platform component name */ 3909 /* create platform component name */
3910 platform->name = fmt_single_name(dev, &platform->id); 3910 platform->name = fmt_single_name(dev, &platform->id);
3911 if (platform->name == NULL) { 3911 if (platform->name == NULL)
3912 kfree(platform);
3913 return -ENOMEM; 3912 return -ENOMEM;
3914 }
3915 3913
3916 platform->dev = dev; 3914 platform->dev = dev;
3917 platform->driver = platform_drv; 3915 platform->driver = platform_drv;
diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c
index e58233f7df61..6c486625321b 100644
--- a/sound/soc/tegra/tegra20_ac97.c
+++ b/sound/soc/tegra/tegra20_ac97.c
@@ -389,9 +389,9 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
389 ac97->capture_dma_data.slave_id = of_dma[1]; 389 ac97->capture_dma_data.slave_id = of_dma[1];
390 390
391 ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1; 391 ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1;
392 ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 392 ac97->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
393 ac97->capture_dma_data.maxburst = 4; 393 ac97->playback_dma_data.maxburst = 4;
394 ac97->capture_dma_data.slave_id = of_dma[0]; 394 ac97->playback_dma_data.slave_id = of_dma[1];
395 395
396 ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev); 396 ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev);
397 if (ret) 397 if (ret)
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c
index 5eaa12cdc6eb..551b3c93ce93 100644
--- a/sound/soc/tegra/tegra20_spdif.c
+++ b/sound/soc/tegra/tegra20_spdif.c
@@ -323,8 +323,8 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
323 } 323 }
324 324
325 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; 325 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT;
326 spdif->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 326 spdif->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
327 spdif->capture_dma_data.maxburst = 4; 327 spdif->playback_dma_data.maxburst = 4;
328 spdif->playback_dma_data.slave_id = dmareq->start; 328 spdif->playback_dma_data.slave_id = dmareq->start;
329 329
330 pm_runtime_enable(&pdev->dev); 330 pm_runtime_enable(&pdev->dev);
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index c5b9cac37dc4..3d2551cc10f2 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -543,7 +543,7 @@ static snd_pcm_uframes_t usb6fire_pcm_pointer(
543 snd_pcm_uframes_t ret; 543 snd_pcm_uframes_t ret;
544 544
545 if (rt->panic || !sub) 545 if (rt->panic || !sub)
546 return SNDRV_PCM_STATE_XRUN; 546 return SNDRV_PCM_POS_XRUN;
547 547
548 spin_lock_irqsave(&sub->lock, flags); 548 spin_lock_irqsave(&sub->lock, flags);
549 ret = sub->dma_off; 549 ret = sub->dma_off;
@@ -639,17 +639,25 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
639void usb6fire_pcm_abort(struct sfire_chip *chip) 639void usb6fire_pcm_abort(struct sfire_chip *chip)
640{ 640{
641 struct pcm_runtime *rt = chip->pcm; 641 struct pcm_runtime *rt = chip->pcm;
642 unsigned long flags;
642 int i; 643 int i;
643 644
644 if (rt) { 645 if (rt) {
645 rt->panic = true; 646 rt->panic = true;
646 647
647 if (rt->playback.instance) 648 if (rt->playback.instance) {
649 snd_pcm_stream_lock_irqsave(rt->playback.instance, flags);
648 snd_pcm_stop(rt->playback.instance, 650 snd_pcm_stop(rt->playback.instance,
649 SNDRV_PCM_STATE_XRUN); 651 SNDRV_PCM_STATE_XRUN);
650 if (rt->capture.instance) 652 snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags);
653 }
654
655 if (rt->capture.instance) {
656 snd_pcm_stream_lock_irqsave(rt->capture.instance, flags);
651 snd_pcm_stop(rt->capture.instance, 657 snd_pcm_stop(rt->capture.instance,
652 SNDRV_PCM_STATE_XRUN); 658 SNDRV_PCM_STATE_XRUN);
659 snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags);
660 }
653 661
654 for (i = 0; i < PCM_N_URBS; i++) { 662 for (i = 0; i < PCM_N_URBS; i++) {
655 usb_poison_urb(&rt->in_urbs[i].instance); 663 usb_poison_urb(&rt->in_urbs[i].instance);
diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c
index 6430ed2a9f65..c21a3df9a0df 100644
--- a/sound/usb/hiface/pcm.c
+++ b/sound/usb/hiface/pcm.c
@@ -503,7 +503,7 @@ static snd_pcm_uframes_t hiface_pcm_pointer(struct snd_pcm_substream *alsa_sub)
503 snd_pcm_uframes_t dma_offset; 503 snd_pcm_uframes_t dma_offset;
504 504
505 if (rt->panic || !sub) 505 if (rt->panic || !sub)
506 return SNDRV_PCM_STATE_XRUN; 506 return SNDRV_PCM_POS_XRUN;
507 507
508 spin_lock_irqsave(&sub->lock, flags); 508 spin_lock_irqsave(&sub->lock, flags);
509 dma_offset = sub->dma_off; 509 dma_offset = sub->dma_off;
diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
index 8b5d2c564e04..509315937f25 100644
--- a/sound/usb/misc/ua101.c
+++ b/sound/usb/misc/ua101.c
@@ -613,14 +613,24 @@ static int start_usb_playback(struct ua101 *ua)
613 613
614static void abort_alsa_capture(struct ua101 *ua) 614static void abort_alsa_capture(struct ua101 *ua)
615{ 615{
616 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) 616 unsigned long flags;
617
618 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) {
619 snd_pcm_stream_lock_irqsave(ua->capture.substream, flags);
617 snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN); 620 snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN);
621 snd_pcm_stream_unlock_irqrestore(ua->capture.substream, flags);
622 }
618} 623}
619 624
620static void abort_alsa_playback(struct ua101 *ua) 625static void abort_alsa_playback(struct ua101 *ua)
621{ 626{
622 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) 627 unsigned long flags;
628
629 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) {
630 snd_pcm_stream_lock_irqsave(ua->playback.substream, flags);
623 snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN); 631 snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN);
632 snd_pcm_stream_unlock_irqrestore(ua->playback.substream, flags);
633 }
624} 634}
625 635
626static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, 636static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream,
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 4967fe9c938d..63fb5219f0f8 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -273,7 +273,11 @@ static void usX2Y_clients_stop(struct usX2Ydev *usX2Y)
273 struct snd_usX2Y_substream *subs = usX2Y->subs[s]; 273 struct snd_usX2Y_substream *subs = usX2Y->subs[s];
274 if (subs) { 274 if (subs) {
275 if (atomic_read(&subs->state) >= state_PRERUNNING) { 275 if (atomic_read(&subs->state) >= state_PRERUNNING) {
276 unsigned long flags;
277
278 snd_pcm_stream_lock_irqsave(subs->pcm_substream, flags);
276 snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); 279 snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN);
280 snd_pcm_stream_unlock_irqrestore(subs->pcm_substream, flags);
277 } 281 }
278 for (u = 0; u < NRURBS; u++) { 282 for (u = 0; u < NRURBS; u++) {
279 struct urb *urb = subs->urb[u]; 283 struct urb *urb = subs->urb[u];
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index ca9fa4d32e07..07819bfa7dba 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -1026,9 +1026,10 @@ kvp_get_ip_info(int family, char *if_name, int op,
1026 1026
1027 if (sn_offset == 0) 1027 if (sn_offset == 0)
1028 strcpy(sn_str, cidr_mask); 1028 strcpy(sn_str, cidr_mask);
1029 else 1029 else {
1030 strcat((char *)ip_buffer->sub_net, ";");
1030 strcat(sn_str, cidr_mask); 1031 strcat(sn_str, cidr_mask);
1031 strcat((char *)ip_buffer->sub_net, ";"); 1032 }
1032 sn_offset += strlen(sn_str) + 1; 1033 sn_offset += strlen(sn_str) + 1;
1033 } 1034 }
1034 1035