aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-10-11 03:57:47 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-10-11 03:57:47 -0400
commit04a4e1fdd248d7a19d53e6e90f757e99093e3d29 (patch)
treeae16ad3f90d9dd726838077aae74675ba7ae51fc
parent19e737c98479f040e23987e50596a861e5e88b92 (diff)
parente25aa82a89db9e3b09d02b5481aa375c7712a10d (diff)
Merge remote-tracking branch 'wireless-next/master' into HEAD
-rw-r--r--Documentation/filesystems/vfs.txt14
-rw-r--r--Documentation/networking/bonding.txt6
-rw-r--r--Documentation/scheduler/sched-design-CFS.txt4
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/mips/Makefile3
-rw-r--r--arch/mips/alchemy/common/usb.c3
-rw-r--r--arch/mips/bcm63xx/cpu.c4
l---------arch/mips/boot/dts/include/dt-bindings2
-rw-r--r--arch/mips/cavium-octeon/csrc-octeon.c1
-rw-r--r--arch/mips/dec/prom/init.c1
-rw-r--r--arch/mips/include/asm/cpu-features.h6
-rw-r--r--arch/mips/include/asm/cpu-info.h1
-rw-r--r--arch/mips/include/asm/cpu-type.h203
-rw-r--r--arch/mips/include/asm/cpu.h38
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000.h4
-rw-r--r--arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h2
-rw-r--r--arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h2
-rw-r--r--arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h2
-rw-r--r--arch/mips/include/asm/mipsregs.h7
-rw-r--r--arch/mips/include/asm/pci.h12
-rw-r--r--arch/mips/include/asm/timex.h33
-rw-r--r--arch/mips/include/asm/vga.h3
-rw-r--r--arch/mips/kernel/cpu-probe.c58
-rw-r--r--arch/mips/kernel/idle.c3
-rw-r--r--arch/mips/kernel/time.c1
-rw-r--r--arch/mips/kernel/traps.c3
-rw-r--r--arch/mips/mm/c-octeon.c6
-rw-r--r--arch/mips/mm/c-r4k.c48
-rw-r--r--arch/mips/mm/dma-default.c1
-rw-r--r--arch/mips/mm/page.c1
-rw-r--r--arch/mips/mm/sc-mips.c3
-rw-r--r--arch/mips/mm/tlb-r4k.c1
-rw-r--r--arch/mips/mm/tlbex.c1
-rw-r--r--arch/mips/mti-malta/malta-time.c5
-rw-r--r--arch/mips/mti-sead3/sead3-time.c3
-rw-r--r--arch/mips/netlogic/xlr/fmn-config.c3
-rw-r--r--arch/mips/oprofile/common.c1
-rw-r--r--arch/mips/pci/pci-bcm1480.c1
-rw-r--r--arch/mips/sibyte/bcm1480/setup.c3
-rw-r--r--arch/mips/sibyte/sb1250/setup.c3
-rw-r--r--arch/mips/sni/setup.c3
-rw-r--r--arch/tile/Kconfig2
-rw-r--r--arch/tile/gxio/iorpc_mpipe.c90
-rw-r--r--arch/tile/gxio/iorpc_mpipe_info.c15
-rw-r--r--arch/tile/gxio/iorpc_trio.c28
-rw-r--r--arch/tile/gxio/iorpc_usb_host.c8
-rw-r--r--arch/tile/gxio/usb_host.c8
-rw-r--r--arch/tile/include/arch/mpipe.h24
-rw-r--r--arch/tile/include/arch/mpipe_constants.h6
-rw-r--r--arch/tile/include/arch/mpipe_shm.h54
-rw-r--r--arch/tile/include/arch/trio_constants.h10
-rw-r--r--arch/tile/include/asm/page.h5
-rw-r--r--arch/tile/include/asm/pgtable_32.h12
-rw-r--r--arch/tile/include/asm/pgtable_64.h4
-rw-r--r--arch/tile/include/gxio/iorpc_mpipe.h52
-rw-r--r--arch/tile/include/gxio/iorpc_mpipe_info.h12
-rw-r--r--arch/tile/include/gxio/iorpc_trio.h28
-rw-r--r--arch/tile/include/gxio/iorpc_usb_host.h8
-rw-r--r--arch/tile/include/gxio/usb_host.h8
-rw-r--r--arch/tile/kernel/compat.c2
-rw-r--r--arch/tile/kernel/futex_64.S55
-rw-r--r--arch/tile/kernel/setup.c3
-rw-r--r--arch/tile/kernel/unaligned.c4
-rw-r--r--arch/tile/mm/fault.c2
-rw-r--r--arch/tile/mm/init.c4
-rw-r--r--arch/tile/mm/pgtable.c3
-rw-r--r--arch/x86/Kconfig5
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c4
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c1
-rw-r--r--arch/x86/kernel/entry_64.S15
-rw-r--r--arch/x86/kernel/smpboot.c3
-rw-r--r--arch/x86/kvm/emulate.c14
-rw-r--r--arch/x86/kvm/paging_tmpl.h20
-rw-r--r--arch/x86/kvm/vmx.c13
-rw-r--r--drivers/atm/he.c13
-rw-r--r--drivers/atm/nicstar.c2
-rw-r--r--drivers/bcma/host_pci.c8
-rw-r--r--drivers/bcma/scan.c12
-rw-r--r--drivers/block/rbd.c77
-rw-r--r--drivers/bluetooth/Makefile2
-rw-r--r--drivers/bluetooth/ath3k.c2
-rw-r--r--drivers/bluetooth/btmrvl_drv.h12
-rw-r--r--drivers/bluetooth/btmrvl_main.c269
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c15
-rw-r--r--drivers/bluetooth/btmrvl_sdio.h2
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/bluetooth/hci_vhci.c170
-rw-r--r--drivers/gpu/drm/ast/ast_drv.h2
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c8
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/init.c21
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c35
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_sgdma.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c23
-rw-r--r--drivers/gpu/drm/radeon/btc_dpm.c6
-rw-r--r--drivers/gpu/drm/radeon/ci_dpm.c6
-rw-r--r--drivers/gpu/drm/radeon/ci_smc.c39
-rw-r--r--drivers/gpu/drm/radeon/cik.c36
-rw-r--r--drivers/gpu/drm/radeon/cypress_dpm.c6
-rw-r--r--drivers/gpu/drm/radeon/dce6_afmt.c12
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c164
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.h1
-rw-r--r--drivers/gpu/drm/radeon/kv_smc.c8
-rw-r--r--drivers/gpu/drm/radeon/ni_dpm.c6
-rw-r--r--drivers/gpu/drm/radeon/ppsmc.h2
-rw-r--r--drivers/gpu/drm/radeon/r100.c7
-rw-r--r--drivers/gpu/drm/radeon/r420.c7
-rw-r--r--drivers/gpu/drm/radeon/r600.c19
-rw-r--r--drivers/gpu/drm/radeon/r600_dpm.c38
-rw-r--r--drivers/gpu/drm/radeon/r600d.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon.h82
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h5
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c69
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c12
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h9
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c81
-rw-r--r--drivers/gpu/drm/radeon/radeon_trace.h27
-rw-r--r--drivers/gpu/drm/radeon/rs400.c7
-rw-r--r--drivers/gpu/drm/radeon/rs600.c12
-rw-r--r--drivers/gpu/drm/radeon/rs690.c7
-rw-r--r--drivers/gpu/drm/radeon/rs780_dpm.c112
-rw-r--r--drivers/gpu/drm/radeon/rv515.c8
-rw-r--r--drivers/gpu/drm/radeon/rv6xx_dpm.c2
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.c16
-rw-r--r--drivers/gpu/drm/radeon/rv770_smc.c44
-rw-r--r--drivers/gpu/drm/radeon/rv770_smc.h2
-rw-r--r--drivers/gpu/drm/radeon/rv770d.h2
-rw-r--r--drivers/gpu/drm/radeon/si.c21
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c6
-rw-r--r--drivers/gpu/drm/radeon/si_smc.c43
-rw-r--r--drivers/gpu/drm/radeon/sumo_dpm.c2
-rw-r--r--drivers/gpu/drm/radeon/trinity_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/trinity_dpm.h2
-rw-r--r--drivers/gpu/drm/radeon/trinity_smc.c8
-rw-r--r--drivers/gpu/drm/ttm/ttm_object.c2
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c2
-rw-r--r--drivers/gpu/drm/udl/udl_gem.c1
-rw-r--r--drivers/hid/hid-core.c74
-rw-r--r--drivers/hid/hid-input.c11
-rw-r--r--drivers/hid/hid-lenovo-tpkbd.c25
-rw-r--r--drivers/hid/hid-lg2ff.c19
-rw-r--r--drivers/hid/hid-lg3ff.c29
-rw-r--r--drivers/hid/hid-lg4ff.c20
-rw-r--r--drivers/hid/hid-lgff.c17
-rw-r--r--drivers/hid/hid-logitech-dj.c10
-rw-r--r--drivers/hid/hid-multitouch.c26
-rw-r--r--drivers/hid/hid-sony.c4
-rw-r--r--drivers/hid/hid-steelseries.c5
-rw-r--r--drivers/hid/hid-zpff.c18
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c4
-rw-r--r--drivers/isdn/hisax/amd7930_fn.c4
-rw-r--r--drivers/isdn/hisax/avm_pci.c4
-rw-r--r--drivers/isdn/hisax/config.c2
-rw-r--r--drivers/isdn/hisax/diva.c4
-rw-r--r--drivers/isdn/hisax/elsa.c2
-rw-r--r--drivers/isdn/hisax/elsa_ser.c2
-rw-r--r--drivers/isdn/hisax/hfc_pci.c2
-rw-r--r--drivers/isdn/hisax/hfc_sx.c2
-rw-r--r--drivers/isdn/hisax/hscx_irq.c4
-rw-r--r--drivers/isdn/hisax/icc.c4
-rw-r--r--drivers/isdn/hisax/ipacx.c8
-rw-r--r--drivers/isdn/hisax/isac.c4
-rw-r--r--drivers/isdn/hisax/isar.c6
-rw-r--r--drivers/isdn/hisax/jade.c18
-rw-r--r--drivers/isdn/hisax/jade_irq.c4
-rw-r--r--drivers/isdn/hisax/l3_1tr6.c50
-rw-r--r--drivers/isdn/hisax/netjet.c2
-rw-r--r--drivers/isdn/hisax/q931.c6
-rw-r--r--drivers/isdn/hisax/w6692.c8
-rw-r--r--drivers/net/bonding/bond_alb.c2
-rw-r--r--drivers/net/bonding/bond_alb.h9
-rw-r--r--drivers/net/bonding/bond_main.c1
-rw-r--r--drivers/net/bonding/bond_sysfs.c39
-rw-r--r--drivers/net/bonding/bonding.h1
-rw-r--r--drivers/net/ethernet/adi/bfin_mac.c4
-rw-r--r--drivers/net/ethernet/amd/sun3lance.c2
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c9
-rw-r--r--drivers/net/ethernet/broadcom/bgmac.c44
-rw-r--r--drivers/net/ethernet/broadcom/bgmac.h4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h37
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c8
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c14
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c6
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c6
-rw-r--r--drivers/net/ethernet/broadcom/tg3.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c4
-rw-r--r--drivers/net/ethernet/dec/tulip/de4x5.c2
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c2
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c2
-rw-r--r--drivers/net/ethernet/hp/hp100.c2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_main.c21
-rw-r--r--drivers/net/ethernet/intel/e1000e/ethtool.c8
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c13
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.h2
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c2
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c4
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.c10
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c25
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c19
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h1
-rw-r--r--drivers/net/ethernet/lantiq_etop.c6
-rw-r--r--drivers/net/ethernet/marvell/pxa168_eth.c3
-rw-r--r--drivers/net/ethernet/marvell/skge.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c16
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c2
-rw-r--r--drivers/net/ethernet/natsemi/jazzsonic.c3
-rw-r--r--drivers/net/ethernet/natsemi/xtsonic.c3
-rw-r--r--drivers/net/ethernet/pasemi/pasemi_mac.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c1
-rw-r--r--drivers/net/ethernet/realtek/r8169.c1
-rw-r--r--drivers/net/ethernet/sfc/Kconfig2
-rw-r--r--drivers/net/ethernet/sfc/ef10.c58
-rw-r--r--drivers/net/ethernet/sfc/mcdi_port.c2
-rw-r--r--drivers/net/ethernet/sfc/nic.h3
-rw-r--r--drivers/net/ethernet/smsc/smc91x.h2
-rw-r--r--drivers/net/ethernet/smsc/smsc9420.c3
-rw-r--r--drivers/net/ethernet/toshiba/ps3_gelic_net.c2
-rw-r--r--drivers/net/irda/mcs7780.c40
-rw-r--r--drivers/net/loopback.c1
-rw-r--r--drivers/net/netconsole.c5
-rw-r--r--drivers/net/phy/cicada.c4
-rw-r--r--drivers/net/ppp/pptp.c2
-rw-r--r--drivers/net/tun.c11
-rw-r--r--drivers/net/usb/cdc_ether.c115
-rw-r--r--drivers/net/vxlan.c40
-rw-r--r--drivers/net/wireless/adm8211.c1
-rw-r--r--drivers/net/wireless/airo.c1
-rw-r--r--drivers/net/wireless/ath/Kconfig1
-rw-r--r--drivers/net/wireless/ath/Makefile1
-rw-r--r--drivers/net/wireless/ath/ar5523/ar5523.c1
-rw-r--r--drivers/net/wireless/ath/ath10k/bmi.c42
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.c382
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.h120
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c70
-rw-r--r--drivers/net/wireless/ath/ath10k/core.h35
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.c144
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.h14
-rw-r--r--drivers/net/wireless/ath/ath10k/htc.c241
-rw-r--r--drivers/net/wireless/ath/ath10k/htc.h5
-rw-r--r--drivers/net/wireless/ath/ath10k/htt.c19
-rw-r--r--drivers/net/wireless/ath/ath10k/htt.h13
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_rx.c314
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_tx.c285
-rw-r--r--drivers/net/wireless/ath/ath10k/hw.h25
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c244
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c446
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.h73
-rw-r--r--drivers/net/wireless/ath/ath10k/rx_desc.h24
-rw-r--r--drivers/net/wireless/ath/ath10k/trace.h32
-rw-r--r--drivers/net/wireless/ath/ath10k/txrx.c67
-rw-r--r--drivers/net/wireless/ath/ath10k/txrx.h5
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.c232
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.h71
-rw-r--r--drivers/net/wireless/ath/ath5k/ahb.c15
-rw-r--r--drivers/net/wireless/ath/ath9k/ahb.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/antenna.c36
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_calib.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_phy.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c92
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c34
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_hw.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_mci.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c32
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_rtt.c58
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9485_initvals.h218
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9565_1p0_initvals.h24
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h20
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c14
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c446
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h12
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_debug.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pri_detector.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_4k.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_9287.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_def.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/gpio.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_debug.c456
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c59
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h26
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c20
-rw-r--r--drivers/net/wireless/ath/ath9k/link.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c195
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c32
-rw-r--r--drivers/net/wireless/ath/ath9k/wmi.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c2
-rw-r--r--drivers/net/wireless/ath/wcn36xx/Kconfig16
-rw-r--r--drivers/net/wireless/ath/wcn36xx/Makefile7
-rw-r--r--drivers/net/wireless/ath/wcn36xx/debug.c188
-rw-r--r--drivers/net/wireless/ath/wcn36xx/debug.h49
-rw-r--r--drivers/net/wireless/ath/wcn36xx/dxe.c805
-rw-r--r--drivers/net/wireless/ath/wcn36xx/dxe.h284
-rw-r--r--drivers/net/wireless/ath/wcn36xx/hal.h4657
-rw-r--r--drivers/net/wireless/ath/wcn36xx/main.c1036
-rw-r--r--drivers/net/wireless/ath/wcn36xx/pmc.c62
-rw-r--r--drivers/net/wireless/ath/wcn36xx/pmc.h33
-rw-r--r--drivers/net/wireless/ath/wcn36xx/smd.c2126
-rw-r--r--drivers/net/wireless/ath/wcn36xx/smd.h127
-rw-r--r--drivers/net/wireless/ath/wcn36xx/txrx.c284
-rw-r--r--drivers/net/wireless/ath/wcn36xx/txrx.h160
-rw-r--r--drivers/net/wireless/ath/wcn36xx/wcn36xx.h238
-rw-r--r--drivers/net/wireless/ath/wil6210/pcie_bus.c1
-rw-r--r--drivers/net/wireless/brcm80211/Kconfig4
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c13
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd.h2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c38
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c234
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/fweh.h5
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c28
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h8
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/usb.c5
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.c2
-rw-r--r--drivers/net/wireless/brcm80211/include/brcm_hw_ids.h1
-rw-r--r--drivers/net/wireless/cw1200/cw1200_spi.c32
-rw-r--r--drivers/net/wireless/cw1200/fwio.c2
-rw-r--r--drivers/net/wireless/cw1200/hwbus.h1
-rw-r--r--drivers/net/wireless/cw1200/hwio.c15
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c2
-rw-r--r--drivers/net/wireless/iwlegacy/3945-mac.c2
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c2
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c8
-rw-r--r--drivers/net/wireless/libertas/if_spi.c2
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c2
-rw-r--r--drivers/net/wireless/mwifiex/join.c2
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c6
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmd.c2
-rw-r--r--drivers/net/wireless/mwifiex/wmm.c2
-rw-r--r--drivers/net/wireless/mwl8k.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c2
-rw-r--r--drivers/net/wireless/p54/p54pci.c1
-rw-r--r--drivers/net/wireless/p54/p54spi.c2
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c128
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c17
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h16
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00link.c70
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c37
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180/dev.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187/dev.c15
-rw-r--r--drivers/net/wireless/rtlwifi/base.c29
-rw-r--r--drivers/net/wireless/rtlwifi/base.h2
-rw-r--r--drivers/net/wireless/rtlwifi/efuse.c18
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/hw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/phy.c28
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/phy.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/sw.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/trx.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c25
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c30
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/phy.h5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/reg.h20
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/mac.c187
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/trx.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/dm.c8
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/hw.c18
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/phy.c28
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/phy.h5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/trx.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/reg.h5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8723ae/phy.c29
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8723ae/phy.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8723ae/sw.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8723ae/trx.c1
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c6
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h2
-rw-r--r--drivers/net/wireless/ti/wl1251/spi.c2
-rw-r--r--drivers/net/wireless/ti/wl1251/wl1251.h4
-rw-r--r--drivers/net/wireless/ti/wl12xx/main.c2
-rw-r--r--drivers/net/wireless/ti/wl18xx/main.c95
-rw-r--r--drivers/net/wireless/ti/wl18xx/reg.h33
-rw-r--r--drivers/net/wireless/ti/wlcore/cmd.c58
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c158
-rw-r--r--drivers/net/wireless/ti/wlcore/ps.c4
-rw-r--r--drivers/net/wireless/ti/wlcore/scan.c27
-rw-r--r--drivers/net/wireless/ti/wlcore/spi.c2
-rw-r--r--drivers/net/wireless/ti/wlcore/testmode.c13
-rw-r--r--drivers/net/wireless/ti/wlcore/tx.c27
-rw-r--r--drivers/net/wireless/ti/wlcore/tx.h3
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore.h2
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore_i.h11
-rw-r--r--drivers/net/xen-netback/common.h1
-rw-r--r--drivers/net/xen-netback/interface.c28
-rw-r--r--drivers/net/xen-netback/netback.c94
-rw-r--r--drivers/net/xen-netback/xenbus.c17
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc.h2
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_hwi.c3
-rw-r--r--drivers/scsi/bnx2i/bnx2i.h2
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c3
-rw-r--r--drivers/staging/octeon/ethernet-mem.c7
-rw-r--r--drivers/staging/octeon/ethernet-rgmii.c4
-rw-r--r--drivers/staging/octeon/ethernet-rx.c5
-rw-r--r--drivers/tty/tty_io.c3
-rw-r--r--fs/9p/v9fs.c7
-rw-r--r--fs/9p/vfs_inode_dotl.c8
-rw-r--r--fs/autofs4/waitq.c13
-rw-r--r--fs/cifs/dir.c1
-rw-r--r--fs/fscache/cookie.c3
-rw-r--r--fs/gfs2/inode.c4
-rw-r--r--fs/namei.c34
-rw-r--r--fs/nfs/dir.c3
-rw-r--r--fs/open.c21
-rw-r--r--fs/pstore/platform.c29
-rw-r--r--include/drm/drm_pciids.h3
-rw-r--r--include/linux/ceph/osd_client.h2
-rw-r--r--include/linux/hid.h4
-rw-r--r--include/linux/ieee80211.h4
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--include/linux/netdevice.h8
-rw-r--r--include/linux/netfilter/ipset/ip_set.h6
-rw-r--r--include/linux/timex.h1
-rw-r--r--include/net/bluetooth/bluetooth.h5
-rw-r--r--include/net/bluetooth/hci.h82
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/bluetooth/l2cap.h1
-rw-r--r--include/net/bluetooth/mgmt.h11
-rw-r--r--include/net/cfg80211.h9
-rw-r--r--include/net/ip.h12
-rw-r--r--include/net/mac80211.h42
-rw-r--r--include/net/netfilter/nf_conntrack_extend.h2
-rw-r--r--include/uapi/linux/perf_event.h2
-rw-r--r--kernel/sched/debug.c6
-rw-r--r--kernel/sched/fair.c14
-rw-r--r--kernel/sched/stats.h5
-rw-r--r--kernel/time/ntp.c6
-rw-r--r--kernel/time/timekeeping.c2
-rw-r--r--net/batman-adv/soft-interface.c2
-rw-r--r--net/bluetooth/Makefile2
-rw-r--r--net/bluetooth/af_bluetooth.c41
-rw-r--r--net/bluetooth/hci_conn.c4
-rw-r--r--net/bluetooth/hci_core.c213
-rw-r--r--net/bluetooth/hci_event.c23
-rw-r--r--net/bluetooth/hci_sock.c204
-rw-r--r--net/bluetooth/l2cap_core.c169
-rw-r--r--net/bluetooth/l2cap_sock.c20
-rw-r--r--net/bluetooth/mgmt.c562
-rw-r--r--net/bluetooth/rfcomm/sock.c7
-rw-r--r--net/bluetooth/rfcomm/tty.c35
-rw-r--r--net/bluetooth/smp.c15
-rw-r--r--net/bridge/br_netlink.c4
-rw-r--r--net/bridge/br_private.h8
-rw-r--r--net/bridge/br_stp.c23
-rw-r--r--net/bridge/br_stp_if.c12
-rw-r--r--net/ceph/osd_client.c11
-rw-r--r--net/core/netpoll.c11
-rw-r--r--net/dccp/ipv6.c1
-rw-r--r--net/ipv4/igmp.c4
-rw-r--r--net/ipv4/inetpeer.c4
-rw-r--r--net/ipv4/ip_output.c8
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/tcp_metrics.c4
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c2
-rw-r--r--net/ipv6/ip6_tunnel.c4
-rw-r--r--net/ipv6/netfilter/nf_nat_proto_icmpv6.c4
-rw-r--r--net/mac80211/cfg.c92
-rw-r--r--net/mac80211/chan.c5
-rw-r--r--net/mac80211/debugfs.c55
-rw-r--r--net/mac80211/driver-ops.h27
-rw-r--r--net/mac80211/ibss.c608
-rw-r--r--net/mac80211/ieee80211_i.h30
-rw-r--r--net/mac80211/iface.c4
-rw-r--r--net/mac80211/key.c2
-rw-r--r--net/mac80211/mlme.c334
-rw-r--r--net/mac80211/rc80211_minstrel.c14
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c23
-rw-r--r--net/mac80211/rc80211_pid_debugfs.c26
-rw-r--r--net/mac80211/rx.c39
-rw-r--r--net/mac80211/scan.c3
-rw-r--r--net/mac80211/spectmgmt.c162
-rw-r--r--net/mac80211/trace.h35
-rw-r--r--net/mac80211/tx.c39
-rw-r--r--net/mac80211/util.c162
-rw-r--r--net/mac80211/vht.c4
-rw-r--r--net/netfilter/ipset/ip_set_core.c5
-rw-r--r--net/netfilter/ipset/ip_set_getport.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_gen.h28
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportnet.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_net.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_netiface.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_netport.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c2
-rw-r--r--net/netfilter/nfnetlink_queue_core.c2
-rw-r--r--net/sctp/input.c3
-rw-r--r--net/sctp/ipv6.c44
-rw-r--r--net/wireless/chan.c1
-rw-r--r--net/wireless/core.h9
-rw-r--r--net/wireless/debugfs.c24
-rw-r--r--net/wireless/genregdb.awk6
-rw-r--r--net/wireless/nl80211.c52
-rw-r--r--net/wireless/reg.c14
-rw-r--r--net/wireless/util.c9
-rw-r--r--virt/kvm/async_pf.c5
-rw-r--r--virt/kvm/kvm_main.c14
518 files changed, 18896 insertions, 5239 deletions
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index f93a88250a44..deb48b5fd883 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -359,11 +359,9 @@ struct inode_operations {
359 ssize_t (*listxattr) (struct dentry *, char *, size_t); 359 ssize_t (*listxattr) (struct dentry *, char *, size_t);
360 int (*removexattr) (struct dentry *, const char *); 360 int (*removexattr) (struct dentry *, const char *);
361 void (*update_time)(struct inode *, struct timespec *, int); 361 void (*update_time)(struct inode *, struct timespec *, int);
362 int (*atomic_open)(struct inode *, struct dentry *, 362 int (*atomic_open)(struct inode *, struct dentry *, struct file *,
363 unsigned open_flag, umode_t create_mode, int *opened);
363 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 364 int (*tmpfile) (struct inode *, struct dentry *, umode_t);
364} ____cacheline_aligned;
365 struct file *, unsigned open_flag,
366 umode_t create_mode, int *opened);
367}; 365};
368 366
369Again, all methods are called without any locks being held, unless 367Again, all methods are called without any locks being held, unless
@@ -470,9 +468,11 @@ otherwise noted.
470 method the filesystem can look up, possibly create and open the file in 468 method the filesystem can look up, possibly create and open the file in
471 one atomic operation. If it cannot perform this (e.g. the file type 469 one atomic operation. If it cannot perform this (e.g. the file type
472 turned out to be wrong) it may signal this by returning 1 instead of 470 turned out to be wrong) it may signal this by returning 1 instead of
473 usual 0 or -ve . This method is only called if the last 471 usual 0 or -ve . This method is only called if the last component is
474 component is negative or needs lookup. Cached positive dentries are 472 negative or needs lookup. Cached positive dentries are still handled by
475 still handled by f_op->open(). 473 f_op->open(). If the file was created, the FILE_CREATED flag should be
474 set in "opened". In case of O_EXCL the method must only succeed if the
475 file didn't exist and hence FILE_CREATED shall always be set on success.
476 476
477 tmpfile: called in the end of O_TMPFILE open(). Optional, equivalent to 477 tmpfile: called in the end of O_TMPFILE open(). Optional, equivalent to
478 atomically creating, opening and unlinking a file in given directory. 478 atomically creating, opening and unlinking a file in given directory.
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 87bbcfee2e06..9b28e714831a 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1362,6 +1362,12 @@ To add ARP targets:
1362To remove an ARP target: 1362To remove an ARP target:
1363# echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target 1363# echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
1364 1364
1365To configure the interval between learning packet transmits:
1366# echo 12 > /sys/class/net/bond0/bonding/lp_interval
1367 NOTE: the lp_inteval is the number of seconds between instances where
1368the bonding driver sends learning packets to each slaves peer switch. The
1369default interval is 1 second.
1370
1365Example Configuration 1371Example Configuration
1366--------------------- 1372---------------------
1367 We begin with the same example that is shown in section 3.3, 1373 We begin with the same example that is shown in section 3.3,
diff --git a/Documentation/scheduler/sched-design-CFS.txt b/Documentation/scheduler/sched-design-CFS.txt
index d529e02d928d..f14f49304222 100644
--- a/Documentation/scheduler/sched-design-CFS.txt
+++ b/Documentation/scheduler/sched-design-CFS.txt
@@ -66,9 +66,7 @@ rq->cfs.load value, which is the sum of the weights of the tasks queued on the
66runqueue. 66runqueue.
67 67
68CFS maintains a time-ordered rbtree, where all runnable tasks are sorted by the 68CFS maintains a time-ordered rbtree, where all runnable tasks are sorted by the
69p->se.vruntime key (there is a subtraction using rq->cfs.min_vruntime to 69p->se.vruntime key. CFS picks the "leftmost" task from this tree and sticks to it.
70account for possible wraparounds). CFS picks the "leftmost" task from this
71tree and sticks to it.
72As the system progresses forwards, the executed tasks are put into the tree 70As the system progresses forwards, the executed tasks are put into the tree
73more and more to the right --- slowly but surely giving a chance for every task 71more and more to the right --- slowly but surely giving a chance for every task
74to become the "leftmost task" and thus get on the CPU within a deterministic 72to become the "leftmost task" and thus get on the CPU within a deterministic
diff --git a/MAINTAINERS b/MAINTAINERS
index e61c2e83fc2b..da6cf1676f2c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6816,6 +6816,14 @@ L: linux-hexagon@vger.kernel.org
6816S: Supported 6816S: Supported
6817F: arch/hexagon/ 6817F: arch/hexagon/
6818 6818
6819QUALCOMM WCN36XX WIRELESS DRIVER
6820M: Eugene Krasnikov <k.eugene.e@gmail.com>
6821L: wcn36xx@lists.infradead.org
6822W: http://wireless.kernel.org/en/users/Drivers/wcn36xx
6823T: git git://github.com/KrasnikovEugene/wcn36xx.git
6824S: Supported
6825F: drivers/net/wireless/ath/wcn36xx/
6826
6819QUICKCAM PARALLEL PORT WEBCAMS 6827QUICKCAM PARALLEL PORT WEBCAMS
6820M: Hans Verkuil <hverkuil@xs4all.nl> 6828M: Hans Verkuil <hverkuil@xs4all.nl>
6821L: linux-media@vger.kernel.org 6829L: linux-media@vger.kernel.org
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 75a36ad11ff5..ca8f8340d75f 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -288,9 +288,6 @@ endif
288vmlinux.32: vmlinux 288vmlinux.32: vmlinux
289 $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 289 $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
290 290
291
292#obj-$(CONFIG_KPROBES) += kprobes.o
293
294# 291#
295# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit 292# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
296# ELF files from 32-bit files by conversion. 293# ELF files from 32-bit files by conversion.
diff --git a/arch/mips/alchemy/common/usb.c b/arch/mips/alchemy/common/usb.c
index fcc695626117..2adc7edda49c 100644
--- a/arch/mips/alchemy/common/usb.c
+++ b/arch/mips/alchemy/common/usb.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/syscore_ops.h> 16#include <linux/syscore_ops.h>
17#include <asm/cpu.h>
17#include <asm/mach-au1x00/au1000.h> 18#include <asm/mach-au1x00/au1000.h>
18 19
19/* control register offsets */ 20/* control register offsets */
@@ -358,7 +359,7 @@ static inline int au1200_coherency_bug(void)
358{ 359{
359#if defined(CONFIG_DMA_COHERENT) 360#if defined(CONFIG_DMA_COHERENT)
360 /* Au1200 AB USB does not support coherent memory */ 361 /* Au1200 AB USB does not support coherent memory */
361 if (!(read_c0_prid() & 0xff)) { 362 if (!(read_c0_prid() & PRID_REV_MASK)) {
362 printk(KERN_INFO "Au1200 USB: this is chip revision AB !!\n"); 363 printk(KERN_INFO "Au1200 USB: this is chip revision AB !!\n");
363 printk(KERN_INFO "Au1200 USB: update your board or re-configure" 364 printk(KERN_INFO "Au1200 USB: update your board or re-configure"
364 " the kernel\n"); 365 " the kernel\n");
diff --git a/arch/mips/bcm63xx/cpu.c b/arch/mips/bcm63xx/cpu.c
index 7e17374a9ae8..b713cd64b087 100644
--- a/arch/mips/bcm63xx/cpu.c
+++ b/arch/mips/bcm63xx/cpu.c
@@ -306,14 +306,14 @@ void __init bcm63xx_cpu_init(void)
306 306
307 switch (c->cputype) { 307 switch (c->cputype) {
308 case CPU_BMIPS3300: 308 case CPU_BMIPS3300:
309 if ((read_c0_prid() & 0xff00) != PRID_IMP_BMIPS3300_ALT) 309 if ((read_c0_prid() & PRID_IMP_MASK) != PRID_IMP_BMIPS3300_ALT)
310 __cpu_name[cpu] = "Broadcom BCM6338"; 310 __cpu_name[cpu] = "Broadcom BCM6338";
311 /* fall-through */ 311 /* fall-through */
312 case CPU_BMIPS32: 312 case CPU_BMIPS32:
313 chipid_reg = BCM_6345_PERF_BASE; 313 chipid_reg = BCM_6345_PERF_BASE;
314 break; 314 break;
315 case CPU_BMIPS4350: 315 case CPU_BMIPS4350:
316 switch ((read_c0_prid() & 0xff)) { 316 switch ((read_c0_prid() & PRID_REV_MASK)) {
317 case 0x04: 317 case 0x04:
318 chipid_reg = BCM_3368_PERF_BASE; 318 chipid_reg = BCM_3368_PERF_BASE;
319 break; 319 break;
diff --git a/arch/mips/boot/dts/include/dt-bindings b/arch/mips/boot/dts/include/dt-bindings
index 68ae3887b3e5..08c00e4972fa 120000
--- a/arch/mips/boot/dts/include/dt-bindings
+++ b/arch/mips/boot/dts/include/dt-bindings
@@ -1 +1 @@
../../../../../include/dt-bindings ../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/mips/cavium-octeon/csrc-octeon.c b/arch/mips/cavium-octeon/csrc-octeon.c
index 02193953eb9e..b752c4ed0b79 100644
--- a/arch/mips/cavium-octeon/csrc-octeon.c
+++ b/arch/mips/cavium-octeon/csrc-octeon.c
@@ -12,6 +12,7 @@
12#include <linux/smp.h> 12#include <linux/smp.h>
13 13
14#include <asm/cpu-info.h> 14#include <asm/cpu-info.h>
15#include <asm/cpu-type.h>
15#include <asm/time.h> 16#include <asm/time.h>
16 17
17#include <asm/octeon/octeon.h> 18#include <asm/octeon/octeon.h>
diff --git a/arch/mips/dec/prom/init.c b/arch/mips/dec/prom/init.c
index ab169046e442..468f665de7bb 100644
--- a/arch/mips/dec/prom/init.c
+++ b/arch/mips/dec/prom/init.c
@@ -13,6 +13,7 @@
13 13
14#include <asm/bootinfo.h> 14#include <asm/bootinfo.h>
15#include <asm/cpu.h> 15#include <asm/cpu.h>
16#include <asm/cpu-type.h>
16#include <asm/processor.h> 17#include <asm/processor.h>
17 18
18#include <asm/dec/prom.h> 19#include <asm/dec/prom.h>
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index fa44f3ec5302..51680d15ca8e 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -13,12 +13,6 @@
13#include <asm/cpu-info.h> 13#include <asm/cpu-info.h>
14#include <cpu-feature-overrides.h> 14#include <cpu-feature-overrides.h>
15 15
16#ifndef current_cpu_type
17#define current_cpu_type() current_cpu_data.cputype
18#endif
19
20#define boot_cpu_type() cpu_data[0].cputype
21
22/* 16/*
23 * SMP assumption: Options of CPU 0 are a superset of all processors. 17 * SMP assumption: Options of CPU 0 are a superset of all processors.
24 * This is true for all known MIPS systems. 18 * This is true for all known MIPS systems.
diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h
index 41401d8eb7d1..21c8e29c8f91 100644
--- a/arch/mips/include/asm/cpu-info.h
+++ b/arch/mips/include/asm/cpu-info.h
@@ -84,6 +84,7 @@ struct cpuinfo_mips {
84extern struct cpuinfo_mips cpu_data[]; 84extern struct cpuinfo_mips cpu_data[];
85#define current_cpu_data cpu_data[smp_processor_id()] 85#define current_cpu_data cpu_data[smp_processor_id()]
86#define raw_current_cpu_data cpu_data[raw_smp_processor_id()] 86#define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
87#define boot_cpu_data cpu_data[0]
87 88
88extern void cpu_probe(void); 89extern void cpu_probe(void);
89extern void cpu_report(void); 90extern void cpu_report(void);
diff --git a/arch/mips/include/asm/cpu-type.h b/arch/mips/include/asm/cpu-type.h
new file mode 100644
index 000000000000..4a402cc60c03
--- /dev/null
+++ b/arch/mips/include/asm/cpu-type.h
@@ -0,0 +1,203 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle
7 * Copyright (C) 2004 Maciej W. Rozycki
8 */
9#ifndef __ASM_CPU_TYPE_H
10#define __ASM_CPU_TYPE_H
11
12#include <linux/smp.h>
13#include <linux/compiler.h>
14
15static inline int __pure __get_cpu_type(const int cpu_type)
16{
17 switch (cpu_type) {
18#if defined(CONFIG_SYS_HAS_CPU_LOONGSON2E) || \
19 defined(CONFIG_SYS_HAS_CPU_LOONGSON2F)
20 case CPU_LOONGSON2:
21#endif
22
23#ifdef CONFIG_SYS_HAS_CPU_LOONGSON1B
24 case CPU_LOONGSON1:
25#endif
26
27#ifdef CONFIG_SYS_HAS_CPU_MIPS32_R1
28 case CPU_4KC:
29 case CPU_ALCHEMY:
30 case CPU_BMIPS3300:
31 case CPU_BMIPS4350:
32 case CPU_PR4450:
33 case CPU_BMIPS32:
34 case CPU_JZRISC:
35#endif
36
37#if defined(CONFIG_SYS_HAS_CPU_MIPS32_R1) || \
38 defined(CONFIG_SYS_HAS_CPU_MIPS32_R2)
39 case CPU_4KEC:
40#endif
41
42#ifdef CONFIG_SYS_HAS_CPU_MIPS32_R2
43 case CPU_4KSC:
44 case CPU_24K:
45 case CPU_34K:
46 case CPU_1004K:
47 case CPU_74K:
48 case CPU_M14KC:
49 case CPU_M14KEC:
50#endif
51
52#ifdef CONFIG_SYS_HAS_CPU_MIPS64_R1
53 case CPU_5KC:
54 case CPU_5KE:
55 case CPU_20KC:
56 case CPU_25KF:
57 case CPU_SB1:
58 case CPU_SB1A:
59#endif
60
61#ifdef CONFIG_SYS_HAS_CPU_MIPS64_R2
62 /*
63 * All MIPS64 R2 processors have their own special symbols. That is,
64 * there currently is no pure R2 core
65 */
66#endif
67
68#ifdef CONFIG_SYS_HAS_CPU_R3000
69 case CPU_R2000:
70 case CPU_R3000:
71 case CPU_R3000A:
72 case CPU_R3041:
73 case CPU_R3051:
74 case CPU_R3052:
75 case CPU_R3081:
76 case CPU_R3081E:
77#endif
78
79#ifdef CONFIG_SYS_HAS_CPU_TX39XX
80 case CPU_TX3912:
81 case CPU_TX3922:
82 case CPU_TX3927:
83#endif
84
85#ifdef CONFIG_SYS_HAS_CPU_VR41XX
86 case CPU_VR41XX:
87 case CPU_VR4111:
88 case CPU_VR4121:
89 case CPU_VR4122:
90 case CPU_VR4131:
91 case CPU_VR4133:
92 case CPU_VR4181:
93 case CPU_VR4181A:
94#endif
95
96#ifdef CONFIG_SYS_HAS_CPU_R4300
97 case CPU_R4300:
98 case CPU_R4310:
99#endif
100
101#ifdef CONFIG_SYS_HAS_CPU_R4X00
102 case CPU_R4000PC:
103 case CPU_R4000SC:
104 case CPU_R4000MC:
105 case CPU_R4200:
106 case CPU_R4400PC:
107 case CPU_R4400SC:
108 case CPU_R4400MC:
109 case CPU_R4600:
110 case CPU_R4700:
111 case CPU_R4640:
112 case CPU_R4650:
113#endif
114
115#ifdef CONFIG_SYS_HAS_CPU_TX49XX
116 case CPU_TX49XX:
117#endif
118
119#ifdef CONFIG_SYS_HAS_CPU_R5000
120 case CPU_R5000:
121#endif
122
123#ifdef CONFIG_SYS_HAS_CPU_R5432
124 case CPU_R5432:
125#endif
126
127#ifdef CONFIG_SYS_HAS_CPU_R5500
128 case CPU_R5500:
129#endif
130
131#ifdef CONFIG_SYS_HAS_CPU_R6000
132 case CPU_R6000:
133 case CPU_R6000A:
134#endif
135
136#ifdef CONFIG_SYS_HAS_CPU_NEVADA
137 case CPU_NEVADA:
138#endif
139
140#ifdef CONFIG_SYS_HAS_CPU_R8000
141 case CPU_R8000:
142#endif
143
144#ifdef CONFIG_SYS_HAS_CPU_R10000
145 case CPU_R10000:
146 case CPU_R12000:
147 case CPU_R14000:
148#endif
149#ifdef CONFIG_SYS_HAS_CPU_RM7000
150 case CPU_RM7000:
151 case CPU_SR71000:
152#endif
153#ifdef CONFIG_SYS_HAS_CPU_RM9000
154 case CPU_RM9000:
155#endif
156#ifdef CONFIG_SYS_HAS_CPU_SB1
157 case CPU_SB1:
158 case CPU_SB1A:
159#endif
160#ifdef CONFIG_SYS_HAS_CPU_CAVIUM_OCTEON
161 case CPU_CAVIUM_OCTEON:
162 case CPU_CAVIUM_OCTEON_PLUS:
163 case CPU_CAVIUM_OCTEON2:
164#endif
165
166#ifdef CONFIG_SYS_HAS_CPU_BMIPS4380
167 case CPU_BMIPS4380:
168#endif
169
170#ifdef CONFIG_SYS_HAS_CPU_BMIPS5000
171 case CPU_BMIPS5000:
172#endif
173
174#ifdef CONFIG_SYS_HAS_CPU_XLP
175 case CPU_XLP:
176#endif
177
178#ifdef CONFIG_SYS_HAS_CPU_XLR
179 case CPU_XLR:
180#endif
181 break;
182 default:
183 unreachable();
184 }
185
186 return cpu_type;
187}
188
189static inline int __pure current_cpu_type(void)
190{
191 const int cpu_type = current_cpu_data.cputype;
192
193 return __get_cpu_type(cpu_type);
194}
195
196static inline int __pure boot_cpu_type(void)
197{
198 const int cpu_type = cpu_data[0].cputype;
199
200 return __get_cpu_type(cpu_type);
201}
202
203#endif /* __ASM_CPU_TYPE_H */
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 71b9f1998be7..d2035e16502a 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -3,15 +3,14 @@
3 * various MIPS cpu types. 3 * various MIPS cpu types.
4 * 4 *
5 * Copyright (C) 1996 David S. Miller (davem@davemloft.net) 5 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
6 * Copyright (C) 2004 Maciej W. Rozycki 6 * Copyright (C) 2004, 2013 Maciej W. Rozycki
7 */ 7 */
8#ifndef _ASM_CPU_H 8#ifndef _ASM_CPU_H
9#define _ASM_CPU_H 9#define _ASM_CPU_H
10 10
11/* Assigned Company values for bits 23:16 of the PRId Register 11/*
12 (CP0 register 15, select 0). As of the MIPS32 and MIPS64 specs from 12 As of the MIPS32 and MIPS64 specs from MTI, the PRId register (CP0
13 MTI, the PRId register is defined in this (backwards compatible) 13 register 15, select 0) is defined in this (backwards compatible) way:
14 way:
15 14
16 +----------------+----------------+----------------+----------------+ 15 +----------------+----------------+----------------+----------------+
17 | Company Options| Company ID | Processor ID | Revision | 16 | Company Options| Company ID | Processor ID | Revision |
@@ -23,6 +22,14 @@
23 spec. 22 spec.
24*/ 23*/
25 24
25#define PRID_OPT_MASK 0xff000000
26
27/*
28 * Assigned Company values for bits 23:16 of the PRId register.
29 */
30
31#define PRID_COMP_MASK 0xff0000
32
26#define PRID_COMP_LEGACY 0x000000 33#define PRID_COMP_LEGACY 0x000000
27#define PRID_COMP_MIPS 0x010000 34#define PRID_COMP_MIPS 0x010000
28#define PRID_COMP_BROADCOM 0x020000 35#define PRID_COMP_BROADCOM 0x020000
@@ -38,10 +45,17 @@
38#define PRID_COMP_INGENIC 0xd00000 45#define PRID_COMP_INGENIC 0xd00000
39 46
40/* 47/*
41 * Assigned values for the product ID register. In order to detect a 48 * Assigned Processor ID (implementation) values for bits 15:8 of the PRId
42 * certain CPU type exactly eventually additional registers may need to 49 * register. In order to detect a certain CPU type exactly eventually
43 * be examined. These are valid when 23:16 == PRID_COMP_LEGACY 50 * additional registers may need to be examined.
44 */ 51 */
52
53#define PRID_IMP_MASK 0xff00
54
55/*
56 * These are valid when 23:16 == PRID_COMP_LEGACY
57 */
58
45#define PRID_IMP_R2000 0x0100 59#define PRID_IMP_R2000 0x0100
46#define PRID_IMP_AU1_REV1 0x0100 60#define PRID_IMP_AU1_REV1 0x0100
47#define PRID_IMP_AU1_REV2 0x0200 61#define PRID_IMP_AU1_REV2 0x0200
@@ -182,11 +196,15 @@
182#define PRID_IMP_NETLOGIC_XLP2XX 0x1200 196#define PRID_IMP_NETLOGIC_XLP2XX 0x1200
183 197
184/* 198/*
185 * Definitions for 7:0 on legacy processors 199 * Particular Revision values for bits 7:0 of the PRId register.
186 */ 200 */
187 201
188#define PRID_REV_MASK 0x00ff 202#define PRID_REV_MASK 0x00ff
189 203
204/*
205 * Definitions for 7:0 on legacy processors
206 */
207
190#define PRID_REV_TX4927 0x0022 208#define PRID_REV_TX4927 0x0022
191#define PRID_REV_TX4937 0x0030 209#define PRID_REV_TX4937 0x0030
192#define PRID_REV_R4400 0x0040 210#define PRID_REV_R4400 0x0040
@@ -227,6 +245,8 @@
227 * 31 16 15 8 7 0 245 * 31 16 15 8 7 0
228 */ 246 */
229 247
248#define FPIR_IMP_MASK 0xff00
249
230#define FPIR_IMP_NONE 0x0000 250#define FPIR_IMP_NONE 0x0000
231 251
232enum cpu_type_enum { 252enum cpu_type_enum {
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index 3e11a468cdf8..54f9e84db8ac 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -43,6 +43,8 @@
43#include <linux/io.h> 43#include <linux/io.h>
44#include <linux/irq.h> 44#include <linux/irq.h>
45 45
46#include <asm/cpu.h>
47
46/* cpu pipeline flush */ 48/* cpu pipeline flush */
47void static inline au_sync(void) 49void static inline au_sync(void)
48{ 50{
@@ -140,7 +142,7 @@ static inline int au1xxx_cpu_needs_config_od(void)
140 142
141static inline int alchemy_get_cputype(void) 143static inline int alchemy_get_cputype(void)
142{ 144{
143 switch (read_c0_prid() & 0xffff0000) { 145 switch (read_c0_prid() & (PRID_OPT_MASK | PRID_COMP_MASK)) {
144 case 0x00030000: 146 case 0x00030000:
145 return ALCHEMY_CPU_AU1000; 147 return ALCHEMY_CPU_AU1000;
146 break; 148 break;
diff --git a/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h
index f4caacd25552..1bcb6421205e 100644
--- a/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h
@@ -8,6 +8,8 @@
8#ifndef __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H 8#ifndef __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H 9#define __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
10 10
11#include <asm/cpu.h>
12
11/* 13/*
12 * IP22 with a variety of processors so we can't use defaults for everything. 14 * IP22 with a variety of processors so we can't use defaults for everything.
13 */ 15 */
diff --git a/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
index 1d2b6ff60d33..d6111aa2e886 100644
--- a/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
@@ -8,6 +8,8 @@
8#ifndef __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H 8#ifndef __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H 9#define __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H
10 10
11#include <asm/cpu.h>
12
11/* 13/*
12 * IP27 only comes with R10000 family processors all using the same config 14 * IP27 only comes with R10000 family processors all using the same config
13 */ 15 */
diff --git a/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h
index 65e9c856390d..4cec06d133db 100644
--- a/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h
@@ -9,6 +9,8 @@
9#ifndef __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H 9#ifndef __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H
10#define __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H 10#define __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H
11 11
12#include <asm/cpu.h>
13
12/* 14/*
13 * IP28 only comes with R10000 family processors all using the same config 15 * IP28 only comes with R10000 family processors all using the same config
14 */ 16 */
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index fed1c3e9b486..e0331414c7d6 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -603,6 +603,13 @@
603#define MIPS_CONF4_MMUEXTDEF (_ULCAST_(3) << 14) 603#define MIPS_CONF4_MMUEXTDEF (_ULCAST_(3) << 14)
604#define MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT (_ULCAST_(1) << 14) 604#define MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT (_ULCAST_(1) << 14)
605 605
606#define MIPS_CONF5_NF (_ULCAST_(1) << 0)
607#define MIPS_CONF5_UFR (_ULCAST_(1) << 2)
608#define MIPS_CONF5_MSAEN (_ULCAST_(1) << 27)
609#define MIPS_CONF5_EVA (_ULCAST_(1) << 28)
610#define MIPS_CONF5_CV (_ULCAST_(1) << 29)
611#define MIPS_CONF5_K (_ULCAST_(1) << 30)
612
606#define MIPS_CONF6_SYND (_ULCAST_(1) << 13) 613#define MIPS_CONF6_SYND (_ULCAST_(1) << 13)
607 614
608#define MIPS_CONF7_WII (_ULCAST_(1) << 31) 615#define MIPS_CONF7_WII (_ULCAST_(1) << 31)
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index f194c08bd057..12d6842962be 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -83,6 +83,18 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
83extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 83extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
84 enum pci_mmap_state mmap_state, int write_combine); 84 enum pci_mmap_state mmap_state, int write_combine);
85 85
86#define HAVE_ARCH_PCI_RESOURCE_TO_USER
87
88static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
89 const struct resource *rsrc, resource_size_t *start,
90 resource_size_t *end)
91{
92 phys_t size = resource_size(rsrc);
93
94 *start = fixup_bigphys_addr(rsrc->start, size);
95 *end = rsrc->start + size;
96}
97
86/* 98/*
87 * Dynamic DMA mapping stuff. 99 * Dynamic DMA mapping stuff.
88 * MIPS has everything mapped statically. 100 * MIPS has everything mapped statically.
diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h
index 6529704aa73a..c5424757da65 100644
--- a/arch/mips/include/asm/timex.h
+++ b/arch/mips/include/asm/timex.h
@@ -10,7 +10,9 @@
10 10
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12 12
13#include <asm/cpu-features.h>
13#include <asm/mipsregs.h> 14#include <asm/mipsregs.h>
15#include <asm/cpu-type.h>
14 16
15/* 17/*
16 * This is the clock rate of the i8253 PIT. A MIPS system may not have 18 * This is the clock rate of the i8253 PIT. A MIPS system may not have
@@ -33,9 +35,38 @@
33 35
34typedef unsigned int cycles_t; 36typedef unsigned int cycles_t;
35 37
38/*
39 * On R4000/R4400 before version 5.0 an erratum exists such that if the
40 * cycle counter is read in the exact moment that it is matching the
41 * compare register, no interrupt will be generated.
42 *
43 * There is a suggested workaround and also the erratum can't strike if
44 * the compare interrupt isn't being used as the clock source device.
45 * However for now the implementaton of this function doesn't get these
46 * fine details right.
47 */
36static inline cycles_t get_cycles(void) 48static inline cycles_t get_cycles(void)
37{ 49{
38 return 0; 50 switch (boot_cpu_type()) {
51 case CPU_R4400PC:
52 case CPU_R4400SC:
53 case CPU_R4400MC:
54 if ((read_c0_prid() & 0xff) >= 0x0050)
55 return read_c0_count();
56 break;
57
58 case CPU_R4000PC:
59 case CPU_R4000SC:
60 case CPU_R4000MC:
61 break;
62
63 default:
64 if (cpu_has_counter)
65 return read_c0_count();
66 break;
67 }
68
69 return 0; /* no usable counter */
39} 70}
40 71
41#endif /* __KERNEL__ */ 72#endif /* __KERNEL__ */
diff --git a/arch/mips/include/asm/vga.h b/arch/mips/include/asm/vga.h
index f4cff7e4fa8a..f82c83749a08 100644
--- a/arch/mips/include/asm/vga.h
+++ b/arch/mips/include/asm/vga.h
@@ -6,6 +6,7 @@
6#ifndef _ASM_VGA_H 6#ifndef _ASM_VGA_H
7#define _ASM_VGA_H 7#define _ASM_VGA_H
8 8
9#include <asm/addrspace.h>
9#include <asm/byteorder.h> 10#include <asm/byteorder.h>
10 11
11/* 12/*
@@ -13,7 +14,7 @@
13 * access the videoram directly without any black magic. 14 * access the videoram directly without any black magic.
14 */ 15 */
15 16
16#define VGA_MAP_MEM(x, s) (0xb0000000L + (unsigned long)(x)) 17#define VGA_MAP_MEM(x, s) CKSEG1ADDR(0x10000000L + (unsigned long)(x))
17 18
18#define vga_readb(x) (*(x)) 19#define vga_readb(x) (*(x))
19#define vga_writeb(x, y) (*(y) = (x)) 20#define vga_writeb(x, y) (*(y) = (x))
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 37663c7862a5..5465dc183e5a 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -20,6 +20,7 @@
20 20
21#include <asm/bugs.h> 21#include <asm/bugs.h>
22#include <asm/cpu.h> 22#include <asm/cpu.h>
23#include <asm/cpu-type.h>
23#include <asm/fpu.h> 24#include <asm/fpu.h>
24#include <asm/mipsregs.h> 25#include <asm/mipsregs.h>
25#include <asm/watch.h> 26#include <asm/watch.h>
@@ -55,7 +56,7 @@ static inline void check_errata(void)
55{ 56{
56 struct cpuinfo_mips *c = &current_cpu_data; 57 struct cpuinfo_mips *c = &current_cpu_data;
57 58
58 switch (c->cputype) { 59 switch (current_cpu_type()) {
59 case CPU_34K: 60 case CPU_34K:
60 /* 61 /*
61 * Erratum "RPS May Cause Incorrect Instruction Execution" 62 * Erratum "RPS May Cause Incorrect Instruction Execution"
@@ -122,7 +123,7 @@ static inline unsigned long cpu_get_fpu_id(void)
122 */ 123 */
123static inline int __cpu_has_fpu(void) 124static inline int __cpu_has_fpu(void)
124{ 125{
125 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE); 126 return ((cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE);
126} 127}
127 128
128static inline void cpu_probe_vmbits(struct cpuinfo_mips *c) 129static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
@@ -290,6 +291,17 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c)
290 return config4 & MIPS_CONF_M; 291 return config4 & MIPS_CONF_M;
291} 292}
292 293
294static inline unsigned int decode_config5(struct cpuinfo_mips *c)
295{
296 unsigned int config5;
297
298 config5 = read_c0_config5();
299 config5 &= ~MIPS_CONF5_UFR;
300 write_c0_config5(config5);
301
302 return config5 & MIPS_CONF_M;
303}
304
293static void decode_configs(struct cpuinfo_mips *c) 305static void decode_configs(struct cpuinfo_mips *c)
294{ 306{
295 int ok; 307 int ok;
@@ -310,6 +322,8 @@ static void decode_configs(struct cpuinfo_mips *c)
310 ok = decode_config3(c); 322 ok = decode_config3(c);
311 if (ok) 323 if (ok)
312 ok = decode_config4(c); 324 ok = decode_config4(c);
325 if (ok)
326 ok = decode_config5(c);
313 327
314 mips_probe_watch_registers(c); 328 mips_probe_watch_registers(c);
315 329
@@ -322,7 +336,7 @@ static void decode_configs(struct cpuinfo_mips *c)
322 336
323static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) 337static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
324{ 338{
325 switch (c->processor_id & 0xff00) { 339 switch (c->processor_id & PRID_IMP_MASK) {
326 case PRID_IMP_R2000: 340 case PRID_IMP_R2000:
327 c->cputype = CPU_R2000; 341 c->cputype = CPU_R2000;
328 __cpu_name[cpu] = "R2000"; 342 __cpu_name[cpu] = "R2000";
@@ -333,7 +347,7 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
333 c->tlbsize = 64; 347 c->tlbsize = 64;
334 break; 348 break;
335 case PRID_IMP_R3000: 349 case PRID_IMP_R3000:
336 if ((c->processor_id & 0xff) == PRID_REV_R3000A) { 350 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
337 if (cpu_has_confreg()) { 351 if (cpu_has_confreg()) {
338 c->cputype = CPU_R3081E; 352 c->cputype = CPU_R3081E;
339 __cpu_name[cpu] = "R3081"; 353 __cpu_name[cpu] = "R3081";
@@ -353,7 +367,8 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
353 break; 367 break;
354 case PRID_IMP_R4000: 368 case PRID_IMP_R4000:
355 if (read_c0_config() & CONF_SC) { 369 if (read_c0_config() & CONF_SC) {
356 if ((c->processor_id & 0xff) >= PRID_REV_R4400) { 370 if ((c->processor_id & PRID_REV_MASK) >=
371 PRID_REV_R4400) {
357 c->cputype = CPU_R4400PC; 372 c->cputype = CPU_R4400PC;
358 __cpu_name[cpu] = "R4400PC"; 373 __cpu_name[cpu] = "R4400PC";
359 } else { 374 } else {
@@ -361,7 +376,8 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
361 __cpu_name[cpu] = "R4000PC"; 376 __cpu_name[cpu] = "R4000PC";
362 } 377 }
363 } else { 378 } else {
364 if ((c->processor_id & 0xff) >= PRID_REV_R4400) { 379 if ((c->processor_id & PRID_REV_MASK) >=
380 PRID_REV_R4400) {
365 c->cputype = CPU_R4400SC; 381 c->cputype = CPU_R4400SC;
366 __cpu_name[cpu] = "R4400SC"; 382 __cpu_name[cpu] = "R4400SC";
367 } else { 383 } else {
@@ -454,7 +470,7 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
454 __cpu_name[cpu] = "TX3927"; 470 __cpu_name[cpu] = "TX3927";
455 c->tlbsize = 64; 471 c->tlbsize = 64;
456 } else { 472 } else {
457 switch (c->processor_id & 0xff) { 473 switch (c->processor_id & PRID_REV_MASK) {
458 case PRID_REV_TX3912: 474 case PRID_REV_TX3912:
459 c->cputype = CPU_TX3912; 475 c->cputype = CPU_TX3912;
460 __cpu_name[cpu] = "TX3912"; 476 __cpu_name[cpu] = "TX3912";
@@ -640,7 +656,7 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
640static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) 656static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
641{ 657{
642 decode_configs(c); 658 decode_configs(c);
643 switch (c->processor_id & 0xff00) { 659 switch (c->processor_id & PRID_IMP_MASK) {
644 case PRID_IMP_4KC: 660 case PRID_IMP_4KC:
645 c->cputype = CPU_4KC; 661 c->cputype = CPU_4KC;
646 __cpu_name[cpu] = "MIPS 4Kc"; 662 __cpu_name[cpu] = "MIPS 4Kc";
@@ -711,7 +727,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
711static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu) 727static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
712{ 728{
713 decode_configs(c); 729 decode_configs(c);
714 switch (c->processor_id & 0xff00) { 730 switch (c->processor_id & PRID_IMP_MASK) {
715 case PRID_IMP_AU1_REV1: 731 case PRID_IMP_AU1_REV1:
716 case PRID_IMP_AU1_REV2: 732 case PRID_IMP_AU1_REV2:
717 c->cputype = CPU_ALCHEMY; 733 c->cputype = CPU_ALCHEMY;
@@ -730,7 +746,7 @@ static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
730 break; 746 break;
731 case 4: 747 case 4:
732 __cpu_name[cpu] = "Au1200"; 748 __cpu_name[cpu] = "Au1200";
733 if ((c->processor_id & 0xff) == 2) 749 if ((c->processor_id & PRID_REV_MASK) == 2)
734 __cpu_name[cpu] = "Au1250"; 750 __cpu_name[cpu] = "Au1250";
735 break; 751 break;
736 case 5: 752 case 5:
@@ -748,12 +764,12 @@ static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
748{ 764{
749 decode_configs(c); 765 decode_configs(c);
750 766
751 switch (c->processor_id & 0xff00) { 767 switch (c->processor_id & PRID_IMP_MASK) {
752 case PRID_IMP_SB1: 768 case PRID_IMP_SB1:
753 c->cputype = CPU_SB1; 769 c->cputype = CPU_SB1;
754 __cpu_name[cpu] = "SiByte SB1"; 770 __cpu_name[cpu] = "SiByte SB1";
755 /* FPU in pass1 is known to have issues. */ 771 /* FPU in pass1 is known to have issues. */
756 if ((c->processor_id & 0xff) < 0x02) 772 if ((c->processor_id & PRID_REV_MASK) < 0x02)
757 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR); 773 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
758 break; 774 break;
759 case PRID_IMP_SB1A: 775 case PRID_IMP_SB1A:
@@ -766,7 +782,7 @@ static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
766static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu) 782static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
767{ 783{
768 decode_configs(c); 784 decode_configs(c);
769 switch (c->processor_id & 0xff00) { 785 switch (c->processor_id & PRID_IMP_MASK) {
770 case PRID_IMP_SR71000: 786 case PRID_IMP_SR71000:
771 c->cputype = CPU_SR71000; 787 c->cputype = CPU_SR71000;
772 __cpu_name[cpu] = "Sandcraft SR71000"; 788 __cpu_name[cpu] = "Sandcraft SR71000";
@@ -779,7 +795,7 @@ static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
779static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu) 795static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
780{ 796{
781 decode_configs(c); 797 decode_configs(c);
782 switch (c->processor_id & 0xff00) { 798 switch (c->processor_id & PRID_IMP_MASK) {
783 case PRID_IMP_PR4450: 799 case PRID_IMP_PR4450:
784 c->cputype = CPU_PR4450; 800 c->cputype = CPU_PR4450;
785 __cpu_name[cpu] = "Philips PR4450"; 801 __cpu_name[cpu] = "Philips PR4450";
@@ -791,7 +807,7 @@ static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
791static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) 807static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
792{ 808{
793 decode_configs(c); 809 decode_configs(c);
794 switch (c->processor_id & 0xff00) { 810 switch (c->processor_id & PRID_IMP_MASK) {
795 case PRID_IMP_BMIPS32_REV4: 811 case PRID_IMP_BMIPS32_REV4:
796 case PRID_IMP_BMIPS32_REV8: 812 case PRID_IMP_BMIPS32_REV8:
797 c->cputype = CPU_BMIPS32; 813 c->cputype = CPU_BMIPS32;
@@ -806,7 +822,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
806 set_elf_platform(cpu, "bmips3300"); 822 set_elf_platform(cpu, "bmips3300");
807 break; 823 break;
808 case PRID_IMP_BMIPS43XX: { 824 case PRID_IMP_BMIPS43XX: {
809 int rev = c->processor_id & 0xff; 825 int rev = c->processor_id & PRID_REV_MASK;
810 826
811 if (rev >= PRID_REV_BMIPS4380_LO && 827 if (rev >= PRID_REV_BMIPS4380_LO &&
812 rev <= PRID_REV_BMIPS4380_HI) { 828 rev <= PRID_REV_BMIPS4380_HI) {
@@ -832,7 +848,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
832static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu) 848static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
833{ 849{
834 decode_configs(c); 850 decode_configs(c);
835 switch (c->processor_id & 0xff00) { 851 switch (c->processor_id & PRID_IMP_MASK) {
836 case PRID_IMP_CAVIUM_CN38XX: 852 case PRID_IMP_CAVIUM_CN38XX:
837 case PRID_IMP_CAVIUM_CN31XX: 853 case PRID_IMP_CAVIUM_CN31XX:
838 case PRID_IMP_CAVIUM_CN30XX: 854 case PRID_IMP_CAVIUM_CN30XX:
@@ -875,7 +891,7 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
875 decode_configs(c); 891 decode_configs(c);
876 /* JZRISC does not implement the CP0 counter. */ 892 /* JZRISC does not implement the CP0 counter. */
877 c->options &= ~MIPS_CPU_COUNTER; 893 c->options &= ~MIPS_CPU_COUNTER;
878 switch (c->processor_id & 0xff00) { 894 switch (c->processor_id & PRID_IMP_MASK) {
879 case PRID_IMP_JZRISC: 895 case PRID_IMP_JZRISC:
880 c->cputype = CPU_JZRISC; 896 c->cputype = CPU_JZRISC;
881 __cpu_name[cpu] = "Ingenic JZRISC"; 897 __cpu_name[cpu] = "Ingenic JZRISC";
@@ -890,7 +906,7 @@ static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
890{ 906{
891 decode_configs(c); 907 decode_configs(c);
892 908
893 if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) { 909 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
894 c->cputype = CPU_ALCHEMY; 910 c->cputype = CPU_ALCHEMY;
895 __cpu_name[cpu] = "Au1300"; 911 __cpu_name[cpu] = "Au1300";
896 /* following stuff is not for Alchemy */ 912 /* following stuff is not for Alchemy */
@@ -905,7 +921,7 @@ static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
905 MIPS_CPU_EJTAG | 921 MIPS_CPU_EJTAG |
906 MIPS_CPU_LLSC); 922 MIPS_CPU_LLSC);
907 923
908 switch (c->processor_id & 0xff00) { 924 switch (c->processor_id & PRID_IMP_MASK) {
909 case PRID_IMP_NETLOGIC_XLP2XX: 925 case PRID_IMP_NETLOGIC_XLP2XX:
910 c->cputype = CPU_XLP; 926 c->cputype = CPU_XLP;
911 __cpu_name[cpu] = "Broadcom XLPII"; 927 __cpu_name[cpu] = "Broadcom XLPII";
@@ -984,7 +1000,7 @@ void cpu_probe(void)
984 c->cputype = CPU_UNKNOWN; 1000 c->cputype = CPU_UNKNOWN;
985 1001
986 c->processor_id = read_c0_prid(); 1002 c->processor_id = read_c0_prid();
987 switch (c->processor_id & 0xff0000) { 1003 switch (c->processor_id & PRID_COMP_MASK) {
988 case PRID_COMP_LEGACY: 1004 case PRID_COMP_LEGACY:
989 cpu_probe_legacy(c, cpu); 1005 cpu_probe_legacy(c, cpu);
990 break; 1006 break;
diff --git a/arch/mips/kernel/idle.c b/arch/mips/kernel/idle.c
index 42f8875d2444..f7991d95bff9 100644
--- a/arch/mips/kernel/idle.c
+++ b/arch/mips/kernel/idle.c
@@ -18,6 +18,7 @@
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <asm/cpu.h> 19#include <asm/cpu.h>
20#include <asm/cpu-info.h> 20#include <asm/cpu-info.h>
21#include <asm/cpu-type.h>
21#include <asm/idle.h> 22#include <asm/idle.h>
22#include <asm/mipsregs.h> 23#include <asm/mipsregs.h>
23 24
@@ -136,7 +137,7 @@ void __init check_wait(void)
136 return; 137 return;
137 } 138 }
138 139
139 switch (c->cputype) { 140 switch (current_cpu_type()) {
140 case CPU_R3081: 141 case CPU_R3081:
141 case CPU_R3081E: 142 case CPU_R3081E:
142 cpu_wait = r3081_wait; 143 cpu_wait = r3081_wait;
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 364d26ae4215..dcb8e5d3bb8a 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -24,6 +24,7 @@
24#include <linux/export.h> 24#include <linux/export.h>
25 25
26#include <asm/cpu-features.h> 26#include <asm/cpu-features.h>
27#include <asm/cpu-type.h>
27#include <asm/div64.h> 28#include <asm/div64.h>
28#include <asm/smtc_ipi.h> 29#include <asm/smtc_ipi.h>
29#include <asm/time.h> 30#include <asm/time.h>
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index aec3408edd4b..524841f02803 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -39,6 +39,7 @@
39#include <asm/break.h> 39#include <asm/break.h>
40#include <asm/cop2.h> 40#include <asm/cop2.h>
41#include <asm/cpu.h> 41#include <asm/cpu.h>
42#include <asm/cpu-type.h>
42#include <asm/dsp.h> 43#include <asm/dsp.h>
43#include <asm/fpu.h> 44#include <asm/fpu.h>
44#include <asm/fpu_emulator.h> 45#include <asm/fpu_emulator.h>
@@ -622,7 +623,7 @@ static int simulate_rdhwr(struct pt_regs *regs, int rd, int rt)
622 regs->regs[rt] = read_c0_count(); 623 regs->regs[rt] = read_c0_count();
623 return 0; 624 return 0;
624 case 3: /* Count register resolution */ 625 case 3: /* Count register resolution */
625 switch (current_cpu_data.cputype) { 626 switch (current_cpu_type()) {
626 case CPU_20KC: 627 case CPU_20KC:
627 case CPU_25KF: 628 case CPU_25KF:
628 regs->regs[rt] = 1; 629 regs->regs[rt] = 1;
diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c
index 729e7702b1de..c8efdb5b6ee0 100644
--- a/arch/mips/mm/c-octeon.c
+++ b/arch/mips/mm/c-octeon.c
@@ -19,6 +19,7 @@
19#include <asm/bootinfo.h> 19#include <asm/bootinfo.h>
20#include <asm/cacheops.h> 20#include <asm/cacheops.h>
21#include <asm/cpu-features.h> 21#include <asm/cpu-features.h>
22#include <asm/cpu-type.h>
22#include <asm/page.h> 23#include <asm/page.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
24#include <asm/r4kcache.h> 25#include <asm/r4kcache.h>
@@ -186,9 +187,10 @@ static void probe_octeon(void)
186 unsigned long dcache_size; 187 unsigned long dcache_size;
187 unsigned int config1; 188 unsigned int config1;
188 struct cpuinfo_mips *c = &current_cpu_data; 189 struct cpuinfo_mips *c = &current_cpu_data;
190 int cputype = current_cpu_type();
189 191
190 config1 = read_c0_config1(); 192 config1 = read_c0_config1();
191 switch (c->cputype) { 193 switch (cputype) {
192 case CPU_CAVIUM_OCTEON: 194 case CPU_CAVIUM_OCTEON:
193 case CPU_CAVIUM_OCTEON_PLUS: 195 case CPU_CAVIUM_OCTEON_PLUS:
194 c->icache.linesz = 2 << ((config1 >> 19) & 7); 196 c->icache.linesz = 2 << ((config1 >> 19) & 7);
@@ -199,7 +201,7 @@ static void probe_octeon(void)
199 c->icache.sets * c->icache.ways * c->icache.linesz; 201 c->icache.sets * c->icache.ways * c->icache.linesz;
200 c->icache.waybit = ffs(icache_size / c->icache.ways) - 1; 202 c->icache.waybit = ffs(icache_size / c->icache.ways) - 1;
201 c->dcache.linesz = 128; 203 c->dcache.linesz = 128;
202 if (c->cputype == CPU_CAVIUM_OCTEON_PLUS) 204 if (cputype == CPU_CAVIUM_OCTEON_PLUS)
203 c->dcache.sets = 2; /* CN5XXX has two Dcache sets */ 205 c->dcache.sets = 2; /* CN5XXX has two Dcache sets */
204 else 206 else
205 c->dcache.sets = 1; /* CN3XXX has one Dcache set */ 207 c->dcache.sets = 1; /* CN3XXX has one Dcache set */
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index f749f687ee87..627883bc6d5f 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -12,6 +12,7 @@
12#include <linux/highmem.h> 12#include <linux/highmem.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/linkage.h> 14#include <linux/linkage.h>
15#include <linux/preempt.h>
15#include <linux/sched.h> 16#include <linux/sched.h>
16#include <linux/smp.h> 17#include <linux/smp.h>
17#include <linux/mm.h> 18#include <linux/mm.h>
@@ -24,6 +25,7 @@
24#include <asm/cacheops.h> 25#include <asm/cacheops.h>
25#include <asm/cpu.h> 26#include <asm/cpu.h>
26#include <asm/cpu-features.h> 27#include <asm/cpu-features.h>
28#include <asm/cpu-type.h>
27#include <asm/io.h> 29#include <asm/io.h>
28#include <asm/page.h> 30#include <asm/page.h>
29#include <asm/pgtable.h> 31#include <asm/pgtable.h>
@@ -601,6 +603,7 @@ static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
601 /* Catch bad driver code */ 603 /* Catch bad driver code */
602 BUG_ON(size == 0); 604 BUG_ON(size == 0);
603 605
606 preempt_disable();
604 if (cpu_has_inclusive_pcaches) { 607 if (cpu_has_inclusive_pcaches) {
605 if (size >= scache_size) 608 if (size >= scache_size)
606 r4k_blast_scache(); 609 r4k_blast_scache();
@@ -621,6 +624,7 @@ static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
621 R4600_HIT_CACHEOP_WAR_IMPL; 624 R4600_HIT_CACHEOP_WAR_IMPL;
622 blast_dcache_range(addr, addr + size); 625 blast_dcache_range(addr, addr + size);
623 } 626 }
627 preempt_enable();
624 628
625 bc_wback_inv(addr, size); 629 bc_wback_inv(addr, size);
626 __sync(); 630 __sync();
@@ -631,6 +635,7 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
631 /* Catch bad driver code */ 635 /* Catch bad driver code */
632 BUG_ON(size == 0); 636 BUG_ON(size == 0);
633 637
638 preempt_disable();
634 if (cpu_has_inclusive_pcaches) { 639 if (cpu_has_inclusive_pcaches) {
635 if (size >= scache_size) 640 if (size >= scache_size)
636 r4k_blast_scache(); 641 r4k_blast_scache();
@@ -655,6 +660,7 @@ static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
655 R4600_HIT_CACHEOP_WAR_IMPL; 660 R4600_HIT_CACHEOP_WAR_IMPL;
656 blast_inv_dcache_range(addr, addr + size); 661 blast_inv_dcache_range(addr, addr + size);
657 } 662 }
663 preempt_enable();
658 664
659 bc_inv(addr, size); 665 bc_inv(addr, size);
660 __sync(); 666 __sync();
@@ -780,20 +786,30 @@ static inline void rm7k_erratum31(void)
780 786
781static inline void alias_74k_erratum(struct cpuinfo_mips *c) 787static inline void alias_74k_erratum(struct cpuinfo_mips *c)
782{ 788{
789 unsigned int imp = c->processor_id & PRID_IMP_MASK;
790 unsigned int rev = c->processor_id & PRID_REV_MASK;
791
783 /* 792 /*
784 * Early versions of the 74K do not update the cache tags on a 793 * Early versions of the 74K do not update the cache tags on a
785 * vtag miss/ptag hit which can occur in the case of KSEG0/KUSEG 794 * vtag miss/ptag hit which can occur in the case of KSEG0/KUSEG
786 * aliases. In this case it is better to treat the cache as always 795 * aliases. In this case it is better to treat the cache as always
787 * having aliases. 796 * having aliases.
788 */ 797 */
789 if ((c->processor_id & 0xff) <= PRID_REV_ENCODE_332(2, 4, 0)) 798 switch (imp) {
790 c->dcache.flags |= MIPS_CACHE_VTAG; 799 case PRID_IMP_74K:
791 if ((c->processor_id & 0xff) == PRID_REV_ENCODE_332(2, 4, 0)) 800 if (rev <= PRID_REV_ENCODE_332(2, 4, 0))
792 write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND); 801 c->dcache.flags |= MIPS_CACHE_VTAG;
793 if (((c->processor_id & 0xff00) == PRID_IMP_1074K) && 802 if (rev == PRID_REV_ENCODE_332(2, 4, 0))
794 ((c->processor_id & 0xff) <= PRID_REV_ENCODE_332(1, 1, 0))) { 803 write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND);
795 c->dcache.flags |= MIPS_CACHE_VTAG; 804 break;
796 write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND); 805 case PRID_IMP_1074K:
806 if (rev <= PRID_REV_ENCODE_332(1, 1, 0)) {
807 c->dcache.flags |= MIPS_CACHE_VTAG;
808 write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND);
809 }
810 break;
811 default:
812 BUG();
797 } 813 }
798} 814}
799 815
@@ -809,7 +825,7 @@ static void probe_pcache(void)
809 unsigned long config1; 825 unsigned long config1;
810 unsigned int lsize; 826 unsigned int lsize;
811 827
812 switch (c->cputype) { 828 switch (current_cpu_type()) {
813 case CPU_R4600: /* QED style two way caches? */ 829 case CPU_R4600: /* QED style two way caches? */
814 case CPU_R4700: 830 case CPU_R4700:
815 case CPU_R5000: 831 case CPU_R5000:
@@ -1025,7 +1041,8 @@ static void probe_pcache(void)
1025 * presumably no vendor is shipping his hardware in the "bad" 1041 * presumably no vendor is shipping his hardware in the "bad"
1026 * configuration. 1042 * configuration.
1027 */ 1043 */
1028 if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 && 1044 if ((prid & PRID_IMP_MASK) == PRID_IMP_R4000 &&
1045 (prid & PRID_REV_MASK) < PRID_REV_R4400 &&
1029 !(config & CONF_SC) && c->icache.linesz != 16 && 1046 !(config & CONF_SC) && c->icache.linesz != 16 &&
1030 PAGE_SIZE <= 0x8000) 1047 PAGE_SIZE <= 0x8000)
1031 panic("Improper R4000SC processor configuration detected"); 1048 panic("Improper R4000SC processor configuration detected");
@@ -1045,7 +1062,7 @@ static void probe_pcache(void)
1045 * normally they'd suffer from aliases but magic in the hardware deals 1062 * normally they'd suffer from aliases but magic in the hardware deals
1046 * with that for us so we don't need to take care ourselves. 1063 * with that for us so we don't need to take care ourselves.
1047 */ 1064 */
1048 switch (c->cputype) { 1065 switch (current_cpu_type()) {
1049 case CPU_20KC: 1066 case CPU_20KC:
1050 case CPU_25KF: 1067 case CPU_25KF:
1051 case CPU_SB1: 1068 case CPU_SB1:
@@ -1065,7 +1082,7 @@ static void probe_pcache(void)
1065 case CPU_34K: 1082 case CPU_34K:
1066 case CPU_74K: 1083 case CPU_74K:
1067 case CPU_1004K: 1084 case CPU_1004K:
1068 if (c->cputype == CPU_74K) 1085 if (current_cpu_type() == CPU_74K)
1069 alias_74k_erratum(c); 1086 alias_74k_erratum(c);
1070 if ((read_c0_config7() & (1 << 16))) { 1087 if ((read_c0_config7() & (1 << 16))) {
1071 /* effectively physically indexed dcache, 1088 /* effectively physically indexed dcache,
@@ -1078,7 +1095,7 @@ static void probe_pcache(void)
1078 c->dcache.flags |= MIPS_CACHE_ALIASES; 1095 c->dcache.flags |= MIPS_CACHE_ALIASES;
1079 } 1096 }
1080 1097
1081 switch (c->cputype) { 1098 switch (current_cpu_type()) {
1082 case CPU_20KC: 1099 case CPU_20KC:
1083 /* 1100 /*
1084 * Some older 20Kc chips doesn't have the 'VI' bit in 1101 * Some older 20Kc chips doesn't have the 'VI' bit in
@@ -1207,7 +1224,7 @@ static void setup_scache(void)
1207 * processors don't have a S-cache that would be relevant to the 1224 * processors don't have a S-cache that would be relevant to the
1208 * Linux memory management. 1225 * Linux memory management.
1209 */ 1226 */
1210 switch (c->cputype) { 1227 switch (current_cpu_type()) {
1211 case CPU_R4000SC: 1228 case CPU_R4000SC:
1212 case CPU_R4000MC: 1229 case CPU_R4000MC:
1213 case CPU_R4400SC: 1230 case CPU_R4400SC:
@@ -1384,9 +1401,8 @@ static void r4k_cache_error_setup(void)
1384{ 1401{
1385 extern char __weak except_vec2_generic; 1402 extern char __weak except_vec2_generic;
1386 extern char __weak except_vec2_sb1; 1403 extern char __weak except_vec2_sb1;
1387 struct cpuinfo_mips *c = &current_cpu_data;
1388 1404
1389 switch (c->cputype) { 1405 switch (current_cpu_type()) {
1390 case CPU_SB1: 1406 case CPU_SB1:
1391 case CPU_SB1A: 1407 case CPU_SB1A:
1392 set_uncached_handler(0x100, &except_vec2_sb1, 0x80); 1408 set_uncached_handler(0x100, &except_vec2_sb1, 0x80);
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 664e523653d0..f25a7e9f8cbc 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -18,6 +18,7 @@
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19 19
20#include <asm/cache.h> 20#include <asm/cache.h>
21#include <asm/cpu-type.h>
21#include <asm/io.h> 22#include <asm/io.h>
22 23
23#include <dma-coherence.h> 24#include <dma-coherence.h>
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c
index 218c2109a55d..cbd81d17793a 100644
--- a/arch/mips/mm/page.c
+++ b/arch/mips/mm/page.c
@@ -18,6 +18,7 @@
18 18
19#include <asm/bugs.h> 19#include <asm/bugs.h>
20#include <asm/cacheops.h> 20#include <asm/cacheops.h>
21#include <asm/cpu-type.h>
21#include <asm/inst.h> 22#include <asm/inst.h>
22#include <asm/io.h> 23#include <asm/io.h>
23#include <asm/page.h> 24#include <asm/page.h>
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 5d01392e3518..08d05aee8788 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -6,6 +6,7 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/mm.h> 7#include <linux/mm.h>
8 8
9#include <asm/cpu-type.h>
9#include <asm/mipsregs.h> 10#include <asm/mipsregs.h>
10#include <asm/bcache.h> 11#include <asm/bcache.h>
11#include <asm/cacheops.h> 12#include <asm/cacheops.h>
@@ -71,7 +72,7 @@ static inline int mips_sc_is_activated(struct cpuinfo_mips *c)
71 unsigned int tmp; 72 unsigned int tmp;
72 73
73 /* Check the bypass bit (L2B) */ 74 /* Check the bypass bit (L2B) */
74 switch (c->cputype) { 75 switch (current_cpu_type()) {
75 case CPU_34K: 76 case CPU_34K:
76 case CPU_74K: 77 case CPU_74K:
77 case CPU_1004K: 78 case CPU_1004K:
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 00b26a67a06d..bb3a5f643e97 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17 17
18#include <asm/cpu.h> 18#include <asm/cpu.h>
19#include <asm/cpu-type.h>
19#include <asm/bootinfo.h> 20#include <asm/bootinfo.h>
20#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
21#include <asm/pgtable.h> 22#include <asm/pgtable.h>
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 821b45175dc1..9bb3a9363b06 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -30,6 +30,7 @@
30#include <linux/cache.h> 30#include <linux/cache.h>
31 31
32#include <asm/cacheflush.h> 32#include <asm/cacheflush.h>
33#include <asm/cpu-type.h>
33#include <asm/pgtable.h> 34#include <asm/pgtable.h>
34#include <asm/war.h> 35#include <asm/war.h>
35#include <asm/uasm.h> 36#include <asm/uasm.h>
diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c
index 53aad4a35375..a18af5fce67e 100644
--- a/arch/mips/mti-malta/malta-time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -27,6 +27,7 @@
27#include <linux/timex.h> 27#include <linux/timex.h>
28#include <linux/mc146818rtc.h> 28#include <linux/mc146818rtc.h>
29 29
30#include <asm/cpu.h>
30#include <asm/mipsregs.h> 31#include <asm/mipsregs.h>
31#include <asm/mipsmtregs.h> 32#include <asm/mipsmtregs.h>
32#include <asm/hardirq.h> 33#include <asm/hardirq.h>
@@ -76,7 +77,7 @@ static void __init estimate_frequencies(void)
76#endif 77#endif
77 78
78#if defined (CONFIG_KVM_GUEST) && defined (CONFIG_KVM_HOST_FREQ) 79#if defined (CONFIG_KVM_GUEST) && defined (CONFIG_KVM_HOST_FREQ)
79 unsigned int prid = read_c0_prid() & 0xffff00; 80 unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK);
80 81
81 /* 82 /*
82 * XXXKYMA: hardwire the CPU frequency to Host Freq/4 83 * XXXKYMA: hardwire the CPU frequency to Host Freq/4
@@ -169,7 +170,7 @@ unsigned int get_c0_compare_int(void)
169 170
170void __init plat_time_init(void) 171void __init plat_time_init(void)
171{ 172{
172 unsigned int prid = read_c0_prid() & 0xffff00; 173 unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK);
173 unsigned int freq; 174 unsigned int freq;
174 175
175 estimate_frequencies(); 176 estimate_frequencies();
diff --git a/arch/mips/mti-sead3/sead3-time.c b/arch/mips/mti-sead3/sead3-time.c
index a43ea3cc0a3b..552d26c34386 100644
--- a/arch/mips/mti-sead3/sead3-time.c
+++ b/arch/mips/mti-sead3/sead3-time.c
@@ -7,6 +7,7 @@
7 */ 7 */
8#include <linux/init.h> 8#include <linux/init.h>
9 9
10#include <asm/cpu.h>
10#include <asm/setup.h> 11#include <asm/setup.h>
11#include <asm/time.h> 12#include <asm/time.h>
12#include <asm/irq.h> 13#include <asm/irq.h>
@@ -34,7 +35,7 @@ static void __iomem *status_reg = (void __iomem *)0xbf000410;
34 */ 35 */
35static unsigned int __init estimate_cpu_frequency(void) 36static unsigned int __init estimate_cpu_frequency(void)
36{ 37{
37 unsigned int prid = read_c0_prid() & 0xffff00; 38 unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK);
38 unsigned int tick = 0; 39 unsigned int tick = 0;
39 unsigned int freq; 40 unsigned int freq;
40 unsigned int orig; 41 unsigned int orig;
diff --git a/arch/mips/netlogic/xlr/fmn-config.c b/arch/mips/netlogic/xlr/fmn-config.c
index ed3bf0e3f309..c7622c6e5f67 100644
--- a/arch/mips/netlogic/xlr/fmn-config.c
+++ b/arch/mips/netlogic/xlr/fmn-config.c
@@ -36,6 +36,7 @@
36#include <linux/irq.h> 36#include <linux/irq.h>
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38 38
39#include <asm/cpu.h>
39#include <asm/mipsregs.h> 40#include <asm/mipsregs.h>
40#include <asm/netlogic/xlr/fmn.h> 41#include <asm/netlogic/xlr/fmn.h>
41#include <asm/netlogic/xlr/xlr.h> 42#include <asm/netlogic/xlr/xlr.h>
@@ -187,7 +188,7 @@ void xlr_board_info_setup(void)
187 int processor_id, num_core; 188 int processor_id, num_core;
188 189
189 num_core = hweight32(nlm_current_node()->coremask); 190 num_core = hweight32(nlm_current_node()->coremask);
190 processor_id = read_c0_prid() & 0xff00; 191 processor_id = read_c0_prid() & PRID_IMP_MASK;
191 192
192 setup_cpu_fmninfo(cpu, num_core); 193 setup_cpu_fmninfo(cpu, num_core);
193 switch (processor_id) { 194 switch (processor_id) {
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index 5e5424753b56..4d1736fc1955 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -12,6 +12,7 @@
12#include <linux/oprofile.h> 12#include <linux/oprofile.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <asm/cpu-info.h> 14#include <asm/cpu-info.h>
15#include <asm/cpu-type.h>
15 16
16#include "op_impl.h" 17#include "op_impl.h"
17 18
diff --git a/arch/mips/pci/pci-bcm1480.c b/arch/mips/pci/pci-bcm1480.c
index 44dd5aa2e36f..5ec2a7bae02c 100644
--- a/arch/mips/pci/pci-bcm1480.c
+++ b/arch/mips/pci/pci-bcm1480.c
@@ -39,6 +39,7 @@
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/console.h> 40#include <linux/console.h>
41#include <linux/tty.h> 41#include <linux/tty.h>
42#include <linux/vt.h>
42 43
43#include <asm/sibyte/bcm1480_regs.h> 44#include <asm/sibyte/bcm1480_regs.h>
44#include <asm/sibyte/bcm1480_scd.h> 45#include <asm/sibyte/bcm1480_scd.h>
diff --git a/arch/mips/sibyte/bcm1480/setup.c b/arch/mips/sibyte/bcm1480/setup.c
index 05ed92c92b69..8e2e04f77870 100644
--- a/arch/mips/sibyte/bcm1480/setup.c
+++ b/arch/mips/sibyte/bcm1480/setup.c
@@ -22,6 +22,7 @@
22#include <linux/string.h> 22#include <linux/string.h>
23 23
24#include <asm/bootinfo.h> 24#include <asm/bootinfo.h>
25#include <asm/cpu.h>
25#include <asm/mipsregs.h> 26#include <asm/mipsregs.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/sibyte/sb1250.h> 28#include <asm/sibyte/sb1250.h>
@@ -119,7 +120,7 @@ void __init bcm1480_setup(void)
119 uint64_t sys_rev; 120 uint64_t sys_rev;
120 int plldiv; 121 int plldiv;
121 122
122 sb1_pass = read_c0_prid() & 0xff; 123 sb1_pass = read_c0_prid() & PRID_REV_MASK;
123 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); 124 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
124 soc_type = SYS_SOC_TYPE(sys_rev); 125 soc_type = SYS_SOC_TYPE(sys_rev);
125 part_type = G_SYS_PART(sys_rev); 126 part_type = G_SYS_PART(sys_rev);
diff --git a/arch/mips/sibyte/sb1250/setup.c b/arch/mips/sibyte/sb1250/setup.c
index a14bd4cb0bc0..3c02b2a77ae9 100644
--- a/arch/mips/sibyte/sb1250/setup.c
+++ b/arch/mips/sibyte/sb1250/setup.c
@@ -22,6 +22,7 @@
22#include <linux/string.h> 22#include <linux/string.h>
23 23
24#include <asm/bootinfo.h> 24#include <asm/bootinfo.h>
25#include <asm/cpu.h>
25#include <asm/mipsregs.h> 26#include <asm/mipsregs.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/sibyte/sb1250.h> 28#include <asm/sibyte/sb1250.h>
@@ -182,7 +183,7 @@ void __init sb1250_setup(void)
182 int plldiv; 183 int plldiv;
183 int bad_config = 0; 184 int bad_config = 0;
184 185
185 sb1_pass = read_c0_prid() & 0xff; 186 sb1_pass = read_c0_prid() & PRID_REV_MASK;
186 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); 187 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION));
187 soc_type = SYS_SOC_TYPE(sys_rev); 188 soc_type = SYS_SOC_TYPE(sys_rev);
188 soc_pass = G_SYS_REVISION(sys_rev); 189 soc_pass = G_SYS_REVISION(sys_rev);
diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
index 5b09b3544edd..efad85c8c823 100644
--- a/arch/mips/sni/setup.c
+++ b/arch/mips/sni/setup.c
@@ -25,6 +25,7 @@
25#endif 25#endif
26 26
27#include <asm/bootinfo.h> 27#include <asm/bootinfo.h>
28#include <asm/cpu.h>
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/reboot.h> 30#include <asm/reboot.h>
30#include <asm/sni.h> 31#include <asm/sni.h>
@@ -173,7 +174,7 @@ void __init plat_mem_setup(void)
173 system_type = "RM300-Cxx"; 174 system_type = "RM300-Cxx";
174 break; 175 break;
175 case SNI_BRD_PCI_DESKTOP: 176 case SNI_BRD_PCI_DESKTOP:
176 switch (read_c0_prid() & 0xff00) { 177 switch (read_c0_prid() & PRID_IMP_MASK) {
177 case PRID_IMP_R4600: 178 case PRID_IMP_R4600:
178 case PRID_IMP_R4700: 179 case PRID_IMP_R4700:
179 system_type = "RM200-C20"; 180 system_type = "RM200-C20";
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 8a7cc663b3f8..d45a2c48f185 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -361,7 +361,7 @@ config CMDLINE_OVERRIDE
361 361
362config VMALLOC_RESERVE 362config VMALLOC_RESERVE
363 hex 363 hex
364 default 0x1000000 364 default 0x2000000
365 365
366config HARDWALL 366config HARDWALL
367 bool "Hardwall support to allow access to user dynamic network" 367 bool "Hardwall support to allow access to user dynamic network"
diff --git a/arch/tile/gxio/iorpc_mpipe.c b/arch/tile/gxio/iorpc_mpipe.c
index 4f8f3d619c4a..e19325c4c431 100644
--- a/arch/tile/gxio/iorpc_mpipe.c
+++ b/arch/tile/gxio/iorpc_mpipe.c
@@ -21,7 +21,7 @@ struct alloc_buffer_stacks_param {
21 unsigned int flags; 21 unsigned int flags;
22}; 22};
23 23
24int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t * context, 24int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t *context,
25 unsigned int count, unsigned int first, 25 unsigned int count, unsigned int first,
26 unsigned int flags) 26 unsigned int flags)
27{ 27{
@@ -45,7 +45,7 @@ struct init_buffer_stack_aux_param {
45 unsigned int buffer_size_enum; 45 unsigned int buffer_size_enum;
46}; 46};
47 47
48int gxio_mpipe_init_buffer_stack_aux(gxio_mpipe_context_t * context, 48int gxio_mpipe_init_buffer_stack_aux(gxio_mpipe_context_t *context,
49 void *mem_va, size_t mem_size, 49 void *mem_va, size_t mem_size,
50 unsigned int mem_flags, unsigned int stack, 50 unsigned int mem_flags, unsigned int stack,
51 unsigned int buffer_size_enum) 51 unsigned int buffer_size_enum)
@@ -80,7 +80,7 @@ struct alloc_notif_rings_param {
80 unsigned int flags; 80 unsigned int flags;
81}; 81};
82 82
83int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t * context, 83int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t *context,
84 unsigned int count, unsigned int first, 84 unsigned int count, unsigned int first,
85 unsigned int flags) 85 unsigned int flags)
86{ 86{
@@ -102,7 +102,7 @@ struct init_notif_ring_aux_param {
102 unsigned int ring; 102 unsigned int ring;
103}; 103};
104 104
105int gxio_mpipe_init_notif_ring_aux(gxio_mpipe_context_t * context, void *mem_va, 105int gxio_mpipe_init_notif_ring_aux(gxio_mpipe_context_t *context, void *mem_va,
106 size_t mem_size, unsigned int mem_flags, 106 size_t mem_size, unsigned int mem_flags,
107 unsigned int ring) 107 unsigned int ring)
108{ 108{
@@ -133,7 +133,7 @@ struct request_notif_ring_interrupt_param {
133 unsigned int ring; 133 unsigned int ring;
134}; 134};
135 135
136int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t * context, 136int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t *context,
137 int inter_x, int inter_y, 137 int inter_x, int inter_y,
138 int inter_ipi, int inter_event, 138 int inter_ipi, int inter_event,
139 unsigned int ring) 139 unsigned int ring)
@@ -158,7 +158,7 @@ struct enable_notif_ring_interrupt_param {
158 unsigned int ring; 158 unsigned int ring;
159}; 159};
160 160
161int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t * context, 161int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t *context,
162 unsigned int ring) 162 unsigned int ring)
163{ 163{
164 struct enable_notif_ring_interrupt_param temp; 164 struct enable_notif_ring_interrupt_param temp;
@@ -179,7 +179,7 @@ struct alloc_notif_groups_param {
179 unsigned int flags; 179 unsigned int flags;
180}; 180};
181 181
182int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t * context, 182int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t *context,
183 unsigned int count, unsigned int first, 183 unsigned int count, unsigned int first,
184 unsigned int flags) 184 unsigned int flags)
185{ 185{
@@ -201,7 +201,7 @@ struct init_notif_group_param {
201 gxio_mpipe_notif_group_bits_t bits; 201 gxio_mpipe_notif_group_bits_t bits;
202}; 202};
203 203
204int gxio_mpipe_init_notif_group(gxio_mpipe_context_t * context, 204int gxio_mpipe_init_notif_group(gxio_mpipe_context_t *context,
205 unsigned int group, 205 unsigned int group,
206 gxio_mpipe_notif_group_bits_t bits) 206 gxio_mpipe_notif_group_bits_t bits)
207{ 207{
@@ -223,7 +223,7 @@ struct alloc_buckets_param {
223 unsigned int flags; 223 unsigned int flags;
224}; 224};
225 225
226int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t * context, unsigned int count, 226int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t *context, unsigned int count,
227 unsigned int first, unsigned int flags) 227 unsigned int first, unsigned int flags)
228{ 228{
229 struct alloc_buckets_param temp; 229 struct alloc_buckets_param temp;
@@ -244,7 +244,7 @@ struct init_bucket_param {
244 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info; 244 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info;
245}; 245};
246 246
247int gxio_mpipe_init_bucket(gxio_mpipe_context_t * context, unsigned int bucket, 247int gxio_mpipe_init_bucket(gxio_mpipe_context_t *context, unsigned int bucket,
248 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info) 248 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info)
249{ 249{
250 struct init_bucket_param temp; 250 struct init_bucket_param temp;
@@ -265,7 +265,7 @@ struct alloc_edma_rings_param {
265 unsigned int flags; 265 unsigned int flags;
266}; 266};
267 267
268int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t * context, 268int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t *context,
269 unsigned int count, unsigned int first, 269 unsigned int count, unsigned int first,
270 unsigned int flags) 270 unsigned int flags)
271{ 271{
@@ -288,7 +288,7 @@ struct init_edma_ring_aux_param {
288 unsigned int channel; 288 unsigned int channel;
289}; 289};
290 290
291int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t * context, void *mem_va, 291int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t *context, void *mem_va,
292 size_t mem_size, unsigned int mem_flags, 292 size_t mem_size, unsigned int mem_flags,
293 unsigned int ring, unsigned int channel) 293 unsigned int ring, unsigned int channel)
294{ 294{
@@ -315,7 +315,7 @@ int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t * context, void *mem_va,
315EXPORT_SYMBOL(gxio_mpipe_init_edma_ring_aux); 315EXPORT_SYMBOL(gxio_mpipe_init_edma_ring_aux);
316 316
317 317
318int gxio_mpipe_commit_rules(gxio_mpipe_context_t * context, const void *blob, 318int gxio_mpipe_commit_rules(gxio_mpipe_context_t *context, const void *blob,
319 size_t blob_size) 319 size_t blob_size)
320{ 320{
321 const void *params = blob; 321 const void *params = blob;
@@ -332,7 +332,7 @@ struct register_client_memory_param {
332 unsigned int flags; 332 unsigned int flags;
333}; 333};
334 334
335int gxio_mpipe_register_client_memory(gxio_mpipe_context_t * context, 335int gxio_mpipe_register_client_memory(gxio_mpipe_context_t *context,
336 unsigned int iotlb, HV_PTE pte, 336 unsigned int iotlb, HV_PTE pte,
337 unsigned int flags) 337 unsigned int flags)
338{ 338{
@@ -355,7 +355,7 @@ struct link_open_aux_param {
355 unsigned int flags; 355 unsigned int flags;
356}; 356};
357 357
358int gxio_mpipe_link_open_aux(gxio_mpipe_context_t * context, 358int gxio_mpipe_link_open_aux(gxio_mpipe_context_t *context,
359 _gxio_mpipe_link_name_t name, unsigned int flags) 359 _gxio_mpipe_link_name_t name, unsigned int flags)
360{ 360{
361 struct link_open_aux_param temp; 361 struct link_open_aux_param temp;
@@ -374,7 +374,7 @@ struct link_close_aux_param {
374 int mac; 374 int mac;
375}; 375};
376 376
377int gxio_mpipe_link_close_aux(gxio_mpipe_context_t * context, int mac) 377int gxio_mpipe_link_close_aux(gxio_mpipe_context_t *context, int mac)
378{ 378{
379 struct link_close_aux_param temp; 379 struct link_close_aux_param temp;
380 struct link_close_aux_param *params = &temp; 380 struct link_close_aux_param *params = &temp;
@@ -393,7 +393,7 @@ struct link_set_attr_aux_param {
393 int64_t val; 393 int64_t val;
394}; 394};
395 395
396int gxio_mpipe_link_set_attr_aux(gxio_mpipe_context_t * context, int mac, 396int gxio_mpipe_link_set_attr_aux(gxio_mpipe_context_t *context, int mac,
397 uint32_t attr, int64_t val) 397 uint32_t attr, int64_t val)
398{ 398{
399 struct link_set_attr_aux_param temp; 399 struct link_set_attr_aux_param temp;
@@ -415,8 +415,8 @@ struct get_timestamp_aux_param {
415 uint64_t cycles; 415 uint64_t cycles;
416}; 416};
417 417
418int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t * context, uint64_t * sec, 418int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t *context, uint64_t *sec,
419 uint64_t * nsec, uint64_t * cycles) 419 uint64_t *nsec, uint64_t *cycles)
420{ 420{
421 int __result; 421 int __result;
422 struct get_timestamp_aux_param temp; 422 struct get_timestamp_aux_param temp;
@@ -440,7 +440,7 @@ struct set_timestamp_aux_param {
440 uint64_t cycles; 440 uint64_t cycles;
441}; 441};
442 442
443int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t * context, uint64_t sec, 443int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t *context, uint64_t sec,
444 uint64_t nsec, uint64_t cycles) 444 uint64_t nsec, uint64_t cycles)
445{ 445{
446 struct set_timestamp_aux_param temp; 446 struct set_timestamp_aux_param temp;
@@ -460,8 +460,7 @@ struct adjust_timestamp_aux_param {
460 int64_t nsec; 460 int64_t nsec;
461}; 461};
462 462
463int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context, 463int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t *context, int64_t nsec)
464 int64_t nsec)
465{ 464{
466 struct adjust_timestamp_aux_param temp; 465 struct adjust_timestamp_aux_param temp;
467 struct adjust_timestamp_aux_param *params = &temp; 466 struct adjust_timestamp_aux_param *params = &temp;
@@ -475,25 +474,6 @@ int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context,
475 474
476EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_aux); 475EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_aux);
477 476
478struct adjust_timestamp_freq_param {
479 int32_t ppb;
480};
481
482int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t * context,
483 int32_t ppb)
484{
485 struct adjust_timestamp_freq_param temp;
486 struct adjust_timestamp_freq_param *params = &temp;
487
488 params->ppb = ppb;
489
490 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
491 sizeof(*params),
492 GXIO_MPIPE_OP_ADJUST_TIMESTAMP_FREQ);
493}
494
495EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_freq);
496
497struct config_edma_ring_blks_param { 477struct config_edma_ring_blks_param {
498 unsigned int ering; 478 unsigned int ering;
499 unsigned int max_blks; 479 unsigned int max_blks;
@@ -501,7 +481,7 @@ struct config_edma_ring_blks_param {
501 unsigned int db; 481 unsigned int db;
502}; 482};
503 483
504int gxio_mpipe_config_edma_ring_blks(gxio_mpipe_context_t * context, 484int gxio_mpipe_config_edma_ring_blks(gxio_mpipe_context_t *context,
505 unsigned int ering, unsigned int max_blks, 485 unsigned int ering, unsigned int max_blks,
506 unsigned int min_snf_blks, unsigned int db) 486 unsigned int min_snf_blks, unsigned int db)
507{ 487{
@@ -520,11 +500,29 @@ int gxio_mpipe_config_edma_ring_blks(gxio_mpipe_context_t * context,
520 500
521EXPORT_SYMBOL(gxio_mpipe_config_edma_ring_blks); 501EXPORT_SYMBOL(gxio_mpipe_config_edma_ring_blks);
522 502
503struct adjust_timestamp_freq_param {
504 int32_t ppb;
505};
506
507int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t *context, int32_t ppb)
508{
509 struct adjust_timestamp_freq_param temp;
510 struct adjust_timestamp_freq_param *params = &temp;
511
512 params->ppb = ppb;
513
514 return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
515 sizeof(*params),
516 GXIO_MPIPE_OP_ADJUST_TIMESTAMP_FREQ);
517}
518
519EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_freq);
520
523struct arm_pollfd_param { 521struct arm_pollfd_param {
524 union iorpc_pollfd pollfd; 522 union iorpc_pollfd pollfd;
525}; 523};
526 524
527int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie) 525int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t *context, int pollfd_cookie)
528{ 526{
529 struct arm_pollfd_param temp; 527 struct arm_pollfd_param temp;
530 struct arm_pollfd_param *params = &temp; 528 struct arm_pollfd_param *params = &temp;
@@ -541,7 +539,7 @@ struct close_pollfd_param {
541 union iorpc_pollfd pollfd; 539 union iorpc_pollfd pollfd;
542}; 540};
543 541
544int gxio_mpipe_close_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie) 542int gxio_mpipe_close_pollfd(gxio_mpipe_context_t *context, int pollfd_cookie)
545{ 543{
546 struct close_pollfd_param temp; 544 struct close_pollfd_param temp;
547 struct close_pollfd_param *params = &temp; 545 struct close_pollfd_param *params = &temp;
@@ -558,7 +556,7 @@ struct get_mmio_base_param {
558 HV_PTE base; 556 HV_PTE base;
559}; 557};
560 558
561int gxio_mpipe_get_mmio_base(gxio_mpipe_context_t * context, HV_PTE *base) 559int gxio_mpipe_get_mmio_base(gxio_mpipe_context_t *context, HV_PTE *base)
562{ 560{
563 int __result; 561 int __result;
564 struct get_mmio_base_param temp; 562 struct get_mmio_base_param temp;
@@ -579,7 +577,7 @@ struct check_mmio_offset_param {
579 unsigned long size; 577 unsigned long size;
580}; 578};
581 579
582int gxio_mpipe_check_mmio_offset(gxio_mpipe_context_t * context, 580int gxio_mpipe_check_mmio_offset(gxio_mpipe_context_t *context,
583 unsigned long offset, unsigned long size) 581 unsigned long offset, unsigned long size)
584{ 582{
585 struct check_mmio_offset_param temp; 583 struct check_mmio_offset_param temp;
diff --git a/arch/tile/gxio/iorpc_mpipe_info.c b/arch/tile/gxio/iorpc_mpipe_info.c
index 64883aabeb9c..77019c6e9b4a 100644
--- a/arch/tile/gxio/iorpc_mpipe_info.c
+++ b/arch/tile/gxio/iorpc_mpipe_info.c
@@ -15,12 +15,11 @@
15/* This file is machine-generated; DO NOT EDIT! */ 15/* This file is machine-generated; DO NOT EDIT! */
16#include "gxio/iorpc_mpipe_info.h" 16#include "gxio/iorpc_mpipe_info.h"
17 17
18
19struct instance_aux_param { 18struct instance_aux_param {
20 _gxio_mpipe_link_name_t name; 19 _gxio_mpipe_link_name_t name;
21}; 20};
22 21
23int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context, 22int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t *context,
24 _gxio_mpipe_link_name_t name) 23 _gxio_mpipe_link_name_t name)
25{ 24{
26 struct instance_aux_param temp; 25 struct instance_aux_param temp;
@@ -39,10 +38,10 @@ struct enumerate_aux_param {
39 _gxio_mpipe_link_mac_t mac; 38 _gxio_mpipe_link_mac_t mac;
40}; 39};
41 40
42int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context, 41int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t *context,
43 unsigned int idx, 42 unsigned int idx,
44 _gxio_mpipe_link_name_t * name, 43 _gxio_mpipe_link_name_t *name,
45 _gxio_mpipe_link_mac_t * mac) 44 _gxio_mpipe_link_mac_t *mac)
46{ 45{
47 int __result; 46 int __result;
48 struct enumerate_aux_param temp; 47 struct enumerate_aux_param temp;
@@ -50,7 +49,7 @@ int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context,
50 49
51 __result = 50 __result =
52 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params), 51 hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
53 (((uint64_t) idx << 32) | 52 (((uint64_t)idx << 32) |
54 GXIO_MPIPE_INFO_OP_ENUMERATE_AUX)); 53 GXIO_MPIPE_INFO_OP_ENUMERATE_AUX));
55 *name = params->name; 54 *name = params->name;
56 *mac = params->mac; 55 *mac = params->mac;
@@ -64,7 +63,7 @@ struct get_mmio_base_param {
64 HV_PTE base; 63 HV_PTE base;
65}; 64};
66 65
67int gxio_mpipe_info_get_mmio_base(gxio_mpipe_info_context_t * context, 66int gxio_mpipe_info_get_mmio_base(gxio_mpipe_info_context_t *context,
68 HV_PTE *base) 67 HV_PTE *base)
69{ 68{
70 int __result; 69 int __result;
@@ -86,7 +85,7 @@ struct check_mmio_offset_param {
86 unsigned long size; 85 unsigned long size;
87}; 86};
88 87
89int gxio_mpipe_info_check_mmio_offset(gxio_mpipe_info_context_t * context, 88int gxio_mpipe_info_check_mmio_offset(gxio_mpipe_info_context_t *context,
90 unsigned long offset, unsigned long size) 89 unsigned long offset, unsigned long size)
91{ 90{
92 struct check_mmio_offset_param temp; 91 struct check_mmio_offset_param temp;
diff --git a/arch/tile/gxio/iorpc_trio.c b/arch/tile/gxio/iorpc_trio.c
index da6e18e049c3..1d3cedb9aeb4 100644
--- a/arch/tile/gxio/iorpc_trio.c
+++ b/arch/tile/gxio/iorpc_trio.c
@@ -21,7 +21,7 @@ struct alloc_asids_param {
21 unsigned int flags; 21 unsigned int flags;
22}; 22};
23 23
24int gxio_trio_alloc_asids(gxio_trio_context_t * context, unsigned int count, 24int gxio_trio_alloc_asids(gxio_trio_context_t *context, unsigned int count,
25 unsigned int first, unsigned int flags) 25 unsigned int first, unsigned int flags)
26{ 26{
27 struct alloc_asids_param temp; 27 struct alloc_asids_param temp;
@@ -44,7 +44,7 @@ struct alloc_memory_maps_param {
44 unsigned int flags; 44 unsigned int flags;
45}; 45};
46 46
47int gxio_trio_alloc_memory_maps(gxio_trio_context_t * context, 47int gxio_trio_alloc_memory_maps(gxio_trio_context_t *context,
48 unsigned int count, unsigned int first, 48 unsigned int count, unsigned int first,
49 unsigned int flags) 49 unsigned int flags)
50{ 50{
@@ -67,7 +67,7 @@ struct alloc_scatter_queues_param {
67 unsigned int flags; 67 unsigned int flags;
68}; 68};
69 69
70int gxio_trio_alloc_scatter_queues(gxio_trio_context_t * context, 70int gxio_trio_alloc_scatter_queues(gxio_trio_context_t *context,
71 unsigned int count, unsigned int first, 71 unsigned int count, unsigned int first,
72 unsigned int flags) 72 unsigned int flags)
73{ 73{
@@ -91,7 +91,7 @@ struct alloc_pio_regions_param {
91 unsigned int flags; 91 unsigned int flags;
92}; 92};
93 93
94int gxio_trio_alloc_pio_regions(gxio_trio_context_t * context, 94int gxio_trio_alloc_pio_regions(gxio_trio_context_t *context,
95 unsigned int count, unsigned int first, 95 unsigned int count, unsigned int first,
96 unsigned int flags) 96 unsigned int flags)
97{ 97{
@@ -115,7 +115,7 @@ struct init_pio_region_aux_param {
115 unsigned int flags; 115 unsigned int flags;
116}; 116};
117 117
118int gxio_trio_init_pio_region_aux(gxio_trio_context_t * context, 118int gxio_trio_init_pio_region_aux(gxio_trio_context_t *context,
119 unsigned int pio_region, unsigned int mac, 119 unsigned int pio_region, unsigned int mac,
120 uint32_t bus_address_hi, unsigned int flags) 120 uint32_t bus_address_hi, unsigned int flags)
121{ 121{
@@ -145,7 +145,7 @@ struct init_memory_map_mmu_aux_param {
145 unsigned int order_mode; 145 unsigned int order_mode;
146}; 146};
147 147
148int gxio_trio_init_memory_map_mmu_aux(gxio_trio_context_t * context, 148int gxio_trio_init_memory_map_mmu_aux(gxio_trio_context_t *context,
149 unsigned int map, unsigned long va, 149 unsigned int map, unsigned long va,
150 uint64_t size, unsigned int asid, 150 uint64_t size, unsigned int asid,
151 unsigned int mac, uint64_t bus_address, 151 unsigned int mac, uint64_t bus_address,
@@ -175,7 +175,7 @@ struct get_port_property_param {
175 struct pcie_trio_ports_property trio_ports; 175 struct pcie_trio_ports_property trio_ports;
176}; 176};
177 177
178int gxio_trio_get_port_property(gxio_trio_context_t * context, 178int gxio_trio_get_port_property(gxio_trio_context_t *context,
179 struct pcie_trio_ports_property *trio_ports) 179 struct pcie_trio_ports_property *trio_ports)
180{ 180{
181 int __result; 181 int __result;
@@ -198,7 +198,7 @@ struct config_legacy_intr_param {
198 unsigned int intx; 198 unsigned int intx;
199}; 199};
200 200
201int gxio_trio_config_legacy_intr(gxio_trio_context_t * context, int inter_x, 201int gxio_trio_config_legacy_intr(gxio_trio_context_t *context, int inter_x,
202 int inter_y, int inter_ipi, int inter_event, 202 int inter_y, int inter_ipi, int inter_event,
203 unsigned int mac, unsigned int intx) 203 unsigned int mac, unsigned int intx)
204{ 204{
@@ -227,7 +227,7 @@ struct config_msi_intr_param {
227 unsigned int asid; 227 unsigned int asid;
228}; 228};
229 229
230int gxio_trio_config_msi_intr(gxio_trio_context_t * context, int inter_x, 230int gxio_trio_config_msi_intr(gxio_trio_context_t *context, int inter_x,
231 int inter_y, int inter_ipi, int inter_event, 231 int inter_y, int inter_ipi, int inter_event,
232 unsigned int mac, unsigned int mem_map, 232 unsigned int mac, unsigned int mem_map,
233 uint64_t mem_map_base, uint64_t mem_map_limit, 233 uint64_t mem_map_base, uint64_t mem_map_limit,
@@ -259,7 +259,7 @@ struct set_mps_mrs_param {
259 unsigned int mac; 259 unsigned int mac;
260}; 260};
261 261
262int gxio_trio_set_mps_mrs(gxio_trio_context_t * context, uint16_t mps, 262int gxio_trio_set_mps_mrs(gxio_trio_context_t *context, uint16_t mps,
263 uint16_t mrs, unsigned int mac) 263 uint16_t mrs, unsigned int mac)
264{ 264{
265 struct set_mps_mrs_param temp; 265 struct set_mps_mrs_param temp;
@@ -279,7 +279,7 @@ struct force_rc_link_up_param {
279 unsigned int mac; 279 unsigned int mac;
280}; 280};
281 281
282int gxio_trio_force_rc_link_up(gxio_trio_context_t * context, unsigned int mac) 282int gxio_trio_force_rc_link_up(gxio_trio_context_t *context, unsigned int mac)
283{ 283{
284 struct force_rc_link_up_param temp; 284 struct force_rc_link_up_param temp;
285 struct force_rc_link_up_param *params = &temp; 285 struct force_rc_link_up_param *params = &temp;
@@ -296,7 +296,7 @@ struct force_ep_link_up_param {
296 unsigned int mac; 296 unsigned int mac;
297}; 297};
298 298
299int gxio_trio_force_ep_link_up(gxio_trio_context_t * context, unsigned int mac) 299int gxio_trio_force_ep_link_up(gxio_trio_context_t *context, unsigned int mac)
300{ 300{
301 struct force_ep_link_up_param temp; 301 struct force_ep_link_up_param temp;
302 struct force_ep_link_up_param *params = &temp; 302 struct force_ep_link_up_param *params = &temp;
@@ -313,7 +313,7 @@ struct get_mmio_base_param {
313 HV_PTE base; 313 HV_PTE base;
314}; 314};
315 315
316int gxio_trio_get_mmio_base(gxio_trio_context_t * context, HV_PTE *base) 316int gxio_trio_get_mmio_base(gxio_trio_context_t *context, HV_PTE *base)
317{ 317{
318 int __result; 318 int __result;
319 struct get_mmio_base_param temp; 319 struct get_mmio_base_param temp;
@@ -334,7 +334,7 @@ struct check_mmio_offset_param {
334 unsigned long size; 334 unsigned long size;
335}; 335};
336 336
337int gxio_trio_check_mmio_offset(gxio_trio_context_t * context, 337int gxio_trio_check_mmio_offset(gxio_trio_context_t *context,
338 unsigned long offset, unsigned long size) 338 unsigned long offset, unsigned long size)
339{ 339{
340 struct check_mmio_offset_param temp; 340 struct check_mmio_offset_param temp;
diff --git a/arch/tile/gxio/iorpc_usb_host.c b/arch/tile/gxio/iorpc_usb_host.c
index cf3c3cc12204..9c820073bfc0 100644
--- a/arch/tile/gxio/iorpc_usb_host.c
+++ b/arch/tile/gxio/iorpc_usb_host.c
@@ -19,7 +19,7 @@ struct cfg_interrupt_param {
19 union iorpc_interrupt interrupt; 19 union iorpc_interrupt interrupt;
20}; 20};
21 21
22int gxio_usb_host_cfg_interrupt(gxio_usb_host_context_t * context, int inter_x, 22int gxio_usb_host_cfg_interrupt(gxio_usb_host_context_t *context, int inter_x,
23 int inter_y, int inter_ipi, int inter_event) 23 int inter_y, int inter_ipi, int inter_event)
24{ 24{
25 struct cfg_interrupt_param temp; 25 struct cfg_interrupt_param temp;
@@ -41,7 +41,7 @@ struct register_client_memory_param {
41 unsigned int flags; 41 unsigned int flags;
42}; 42};
43 43
44int gxio_usb_host_register_client_memory(gxio_usb_host_context_t * context, 44int gxio_usb_host_register_client_memory(gxio_usb_host_context_t *context,
45 HV_PTE pte, unsigned int flags) 45 HV_PTE pte, unsigned int flags)
46{ 46{
47 struct register_client_memory_param temp; 47 struct register_client_memory_param temp;
@@ -61,7 +61,7 @@ struct get_mmio_base_param {
61 HV_PTE base; 61 HV_PTE base;
62}; 62};
63 63
64int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t * context, HV_PTE *base) 64int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t *context, HV_PTE *base)
65{ 65{
66 int __result; 66 int __result;
67 struct get_mmio_base_param temp; 67 struct get_mmio_base_param temp;
@@ -82,7 +82,7 @@ struct check_mmio_offset_param {
82 unsigned long size; 82 unsigned long size;
83}; 83};
84 84
85int gxio_usb_host_check_mmio_offset(gxio_usb_host_context_t * context, 85int gxio_usb_host_check_mmio_offset(gxio_usb_host_context_t *context,
86 unsigned long offset, unsigned long size) 86 unsigned long offset, unsigned long size)
87{ 87{
88 struct check_mmio_offset_param temp; 88 struct check_mmio_offset_param temp;
diff --git a/arch/tile/gxio/usb_host.c b/arch/tile/gxio/usb_host.c
index 66b002f54ecc..785afad7922e 100644
--- a/arch/tile/gxio/usb_host.c
+++ b/arch/tile/gxio/usb_host.c
@@ -26,7 +26,7 @@
26#include <gxio/kiorpc.h> 26#include <gxio/kiorpc.h>
27#include <gxio/usb_host.h> 27#include <gxio/usb_host.h>
28 28
29int gxio_usb_host_init(gxio_usb_host_context_t * context, int usb_index, 29int gxio_usb_host_init(gxio_usb_host_context_t *context, int usb_index,
30 int is_ehci) 30 int is_ehci)
31{ 31{
32 char file[32]; 32 char file[32];
@@ -63,7 +63,7 @@ int gxio_usb_host_init(gxio_usb_host_context_t * context, int usb_index,
63 63
64EXPORT_SYMBOL_GPL(gxio_usb_host_init); 64EXPORT_SYMBOL_GPL(gxio_usb_host_init);
65 65
66int gxio_usb_host_destroy(gxio_usb_host_context_t * context) 66int gxio_usb_host_destroy(gxio_usb_host_context_t *context)
67{ 67{
68 iounmap((void __force __iomem *)(context->mmio_base)); 68 iounmap((void __force __iomem *)(context->mmio_base));
69 hv_dev_close(context->fd); 69 hv_dev_close(context->fd);
@@ -76,14 +76,14 @@ int gxio_usb_host_destroy(gxio_usb_host_context_t * context)
76 76
77EXPORT_SYMBOL_GPL(gxio_usb_host_destroy); 77EXPORT_SYMBOL_GPL(gxio_usb_host_destroy);
78 78
79void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t * context) 79void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t *context)
80{ 80{
81 return context->mmio_base; 81 return context->mmio_base;
82} 82}
83 83
84EXPORT_SYMBOL_GPL(gxio_usb_host_get_reg_start); 84EXPORT_SYMBOL_GPL(gxio_usb_host_get_reg_start);
85 85
86size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t * context) 86size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t *context)
87{ 87{
88 return HV_USB_HOST_MMIO_SIZE; 88 return HV_USB_HOST_MMIO_SIZE;
89} 89}
diff --git a/arch/tile/include/arch/mpipe.h b/arch/tile/include/arch/mpipe.h
index 8a33912fd6cc..904538e754d8 100644
--- a/arch/tile/include/arch/mpipe.h
+++ b/arch/tile/include/arch/mpipe.h
@@ -176,7 +176,18 @@ typedef union
176 */ 176 */
177 uint_reg_t stack_idx : 5; 177 uint_reg_t stack_idx : 5;
178 /* Reserved. */ 178 /* Reserved. */
179 uint_reg_t __reserved_2 : 5; 179 uint_reg_t __reserved_2 : 3;
180 /*
181 * Instance ID. For devices that support automatic buffer return between
182 * mPIPE instances, this field indicates the buffer owner. If the INST
183 * field does not match the mPIPE's instance number when a packet is
184 * egressed, buffers with HWB set will be returned to the other mPIPE
185 * instance. Note that not all devices support multi-mPIPE buffer
186 * return. The MPIPE_EDMA_INFO.REMOTE_BUFF_RTN_SUPPORT bit indicates
187 * whether the INST field in the buffer descriptor is populated by iDMA
188 * hardware. This field is ignored on writes.
189 */
190 uint_reg_t inst : 2;
180 /* 191 /*
181 * Reads as one to indicate that this is a hardware managed buffer. 192 * Reads as one to indicate that this is a hardware managed buffer.
182 * Ignored on writes since all buffers on a given stack are the same size. 193 * Ignored on writes since all buffers on a given stack are the same size.
@@ -205,7 +216,8 @@ typedef union
205 uint_reg_t c : 2; 216 uint_reg_t c : 2;
206 uint_reg_t size : 3; 217 uint_reg_t size : 3;
207 uint_reg_t hwb : 1; 218 uint_reg_t hwb : 1;
208 uint_reg_t __reserved_2 : 5; 219 uint_reg_t inst : 2;
220 uint_reg_t __reserved_2 : 3;
209 uint_reg_t stack_idx : 5; 221 uint_reg_t stack_idx : 5;
210 uint_reg_t __reserved_1 : 6; 222 uint_reg_t __reserved_1 : 6;
211 int_reg_t va : 35; 223 int_reg_t va : 35;
@@ -231,9 +243,9 @@ typedef union
231 /* Reserved. */ 243 /* Reserved. */
232 uint_reg_t __reserved_0 : 3; 244 uint_reg_t __reserved_0 : 3;
233 /* eDMA ring being accessed */ 245 /* eDMA ring being accessed */
234 uint_reg_t ring : 5; 246 uint_reg_t ring : 6;
235 /* Reserved. */ 247 /* Reserved. */
236 uint_reg_t __reserved_1 : 18; 248 uint_reg_t __reserved_1 : 17;
237 /* 249 /*
238 * This field of the address selects the region (address space) to be 250 * This field of the address selects the region (address space) to be
239 * accessed. For the egress DMA post region, this field must be 5. 251 * accessed. For the egress DMA post region, this field must be 5.
@@ -250,8 +262,8 @@ typedef union
250 uint_reg_t svc_dom : 5; 262 uint_reg_t svc_dom : 5;
251 uint_reg_t __reserved_2 : 6; 263 uint_reg_t __reserved_2 : 6;
252 uint_reg_t region : 3; 264 uint_reg_t region : 3;
253 uint_reg_t __reserved_1 : 18; 265 uint_reg_t __reserved_1 : 17;
254 uint_reg_t ring : 5; 266 uint_reg_t ring : 6;
255 uint_reg_t __reserved_0 : 3; 267 uint_reg_t __reserved_0 : 3;
256#endif 268#endif
257 }; 269 };
diff --git a/arch/tile/include/arch/mpipe_constants.h b/arch/tile/include/arch/mpipe_constants.h
index 410a0400e055..84022ac5fe82 100644
--- a/arch/tile/include/arch/mpipe_constants.h
+++ b/arch/tile/include/arch/mpipe_constants.h
@@ -16,13 +16,13 @@
16#ifndef __ARCH_MPIPE_CONSTANTS_H__ 16#ifndef __ARCH_MPIPE_CONSTANTS_H__
17#define __ARCH_MPIPE_CONSTANTS_H__ 17#define __ARCH_MPIPE_CONSTANTS_H__
18 18
19#define MPIPE_NUM_CLASSIFIERS 10 19#define MPIPE_NUM_CLASSIFIERS 16
20#define MPIPE_CLS_MHZ 1200 20#define MPIPE_CLS_MHZ 1200
21 21
22#define MPIPE_NUM_EDMA_RINGS 32 22#define MPIPE_NUM_EDMA_RINGS 64
23 23
24#define MPIPE_NUM_SGMII_MACS 16 24#define MPIPE_NUM_SGMII_MACS 16
25#define MPIPE_NUM_XAUI_MACS 4 25#define MPIPE_NUM_XAUI_MACS 16
26#define MPIPE_NUM_LOOPBACK_CHANNELS 4 26#define MPIPE_NUM_LOOPBACK_CHANNELS 4
27#define MPIPE_NUM_NON_LB_CHANNELS 28 27#define MPIPE_NUM_NON_LB_CHANNELS 28
28 28
diff --git a/arch/tile/include/arch/mpipe_shm.h b/arch/tile/include/arch/mpipe_shm.h
index f2e9e122818d..13b3c4300e50 100644
--- a/arch/tile/include/arch/mpipe_shm.h
+++ b/arch/tile/include/arch/mpipe_shm.h
@@ -44,8 +44,14 @@ typedef union
44 * descriptors toggles each time the ring tail pointer wraps. 44 * descriptors toggles each time the ring tail pointer wraps.
45 */ 45 */
46 uint_reg_t gen : 1; 46 uint_reg_t gen : 1;
47 /**
48 * For devices with EDMA reorder support, this field allows the
49 * descriptor to select the egress FIFO. The associated DMA ring must
50 * have ALLOW_EFIFO_SEL enabled.
51 */
52 uint_reg_t efifo_sel : 6;
47 /** Reserved. Must be zero. */ 53 /** Reserved. Must be zero. */
48 uint_reg_t r0 : 7; 54 uint_reg_t r0 : 1;
49 /** Checksum generation enabled for this transfer. */ 55 /** Checksum generation enabled for this transfer. */
50 uint_reg_t csum : 1; 56 uint_reg_t csum : 1;
51 /** 57 /**
@@ -110,7 +116,8 @@ typedef union
110 uint_reg_t notif : 1; 116 uint_reg_t notif : 1;
111 uint_reg_t ns : 1; 117 uint_reg_t ns : 1;
112 uint_reg_t csum : 1; 118 uint_reg_t csum : 1;
113 uint_reg_t r0 : 7; 119 uint_reg_t r0 : 1;
120 uint_reg_t efifo_sel : 6;
114 uint_reg_t gen : 1; 121 uint_reg_t gen : 1;
115#endif 122#endif
116 123
@@ -126,14 +133,16 @@ typedef union
126 /** Reserved. */ 133 /** Reserved. */
127 uint_reg_t __reserved_1 : 3; 134 uint_reg_t __reserved_1 : 3;
128 /** 135 /**
129 * Instance ID. For devices that support more than one mPIPE instance, 136 * Instance ID. For devices that support automatic buffer return between
130 * this field indicates the buffer owner. If the INST field does not 137 * mPIPE instances, this field indicates the buffer owner. If the INST
131 * match the mPIPE's instance number when a packet is egressed, buffers 138 * field does not match the mPIPE's instance number when a packet is
132 * with HWB set will be returned to the other mPIPE instance. 139 * egressed, buffers with HWB set will be returned to the other mPIPE
140 * instance. Note that not all devices support multi-mPIPE buffer
141 * return. The MPIPE_EDMA_INFO.REMOTE_BUFF_RTN_SUPPORT bit indicates
142 * whether the INST field in the buffer descriptor is populated by iDMA
143 * hardware.
133 */ 144 */
134 uint_reg_t inst : 1; 145 uint_reg_t inst : 2;
135 /** Reserved. */
136 uint_reg_t __reserved_2 : 1;
137 /** 146 /**
138 * Always set to one by hardware in iDMA packet descriptors. For eDMA, 147 * Always set to one by hardware in iDMA packet descriptors. For eDMA,
139 * indicates whether the buffer will be released to the buffer stack 148 * indicates whether the buffer will be released to the buffer stack
@@ -166,8 +175,7 @@ typedef union
166 uint_reg_t c : 2; 175 uint_reg_t c : 2;
167 uint_reg_t size : 3; 176 uint_reg_t size : 3;
168 uint_reg_t hwb : 1; 177 uint_reg_t hwb : 1;
169 uint_reg_t __reserved_2 : 1; 178 uint_reg_t inst : 2;
170 uint_reg_t inst : 1;
171 uint_reg_t __reserved_1 : 3; 179 uint_reg_t __reserved_1 : 3;
172 uint_reg_t stack_idx : 5; 180 uint_reg_t stack_idx : 5;
173 uint_reg_t __reserved_0 : 6; 181 uint_reg_t __reserved_0 : 6;
@@ -408,7 +416,10 @@ typedef union
408 /** 416 /**
409 * Sequence number applied when packet is distributed. Classifier 417 * Sequence number applied when packet is distributed. Classifier
410 * selects which sequence number is to be applied by writing the 13-bit 418 * selects which sequence number is to be applied by writing the 13-bit
411 * SQN-selector into this field. 419 * SQN-selector into this field. For devices that support EXT_SQN (as
420 * indicated in IDMA_INFO.EXT_SQN_SUPPORT), the GP_SQN can be extended to
421 * 32-bits via the IDMA_CTL.EXT_SQN register. In this case the
422 * PACKET_SQN will be reduced to 32 bits.
412 */ 423 */
413 uint_reg_t gp_sqn : 16; 424 uint_reg_t gp_sqn : 16;
414 /** 425 /**
@@ -451,14 +462,16 @@ typedef union
451 /** Reserved. */ 462 /** Reserved. */
452 uint_reg_t __reserved_5 : 3; 463 uint_reg_t __reserved_5 : 3;
453 /** 464 /**
454 * Instance ID. For devices that support more than one mPIPE instance, 465 * Instance ID. For devices that support automatic buffer return between
455 * this field indicates the buffer owner. If the INST field does not 466 * mPIPE instances, this field indicates the buffer owner. If the INST
456 * match the mPIPE's instance number when a packet is egressed, buffers 467 * field does not match the mPIPE's instance number when a packet is
457 * with HWB set will be returned to the other mPIPE instance. 468 * egressed, buffers with HWB set will be returned to the other mPIPE
469 * instance. Note that not all devices support multi-mPIPE buffer
470 * return. The MPIPE_EDMA_INFO.REMOTE_BUFF_RTN_SUPPORT bit indicates
471 * whether the INST field in the buffer descriptor is populated by iDMA
472 * hardware.
458 */ 473 */
459 uint_reg_t inst : 1; 474 uint_reg_t inst : 2;
460 /** Reserved. */
461 uint_reg_t __reserved_6 : 1;
462 /** 475 /**
463 * Always set to one by hardware in iDMA packet descriptors. For eDMA, 476 * Always set to one by hardware in iDMA packet descriptors. For eDMA,
464 * indicates whether the buffer will be released to the buffer stack 477 * indicates whether the buffer will be released to the buffer stack
@@ -491,8 +504,7 @@ typedef union
491 uint_reg_t c : 2; 504 uint_reg_t c : 2;
492 uint_reg_t size : 3; 505 uint_reg_t size : 3;
493 uint_reg_t hwb : 1; 506 uint_reg_t hwb : 1;
494 uint_reg_t __reserved_6 : 1; 507 uint_reg_t inst : 2;
495 uint_reg_t inst : 1;
496 uint_reg_t __reserved_5 : 3; 508 uint_reg_t __reserved_5 : 3;
497 uint_reg_t stack_idx : 5; 509 uint_reg_t stack_idx : 5;
498 uint_reg_t __reserved_4 : 6; 510 uint_reg_t __reserved_4 : 6;
diff --git a/arch/tile/include/arch/trio_constants.h b/arch/tile/include/arch/trio_constants.h
index 628b045436b8..85647e91a458 100644
--- a/arch/tile/include/arch/trio_constants.h
+++ b/arch/tile/include/arch/trio_constants.h
@@ -16,21 +16,21 @@
16#ifndef __ARCH_TRIO_CONSTANTS_H__ 16#ifndef __ARCH_TRIO_CONSTANTS_H__
17#define __ARCH_TRIO_CONSTANTS_H__ 17#define __ARCH_TRIO_CONSTANTS_H__
18 18
19#define TRIO_NUM_ASIDS 16 19#define TRIO_NUM_ASIDS 32
20#define TRIO_NUM_TLBS_PER_ASID 16 20#define TRIO_NUM_TLBS_PER_ASID 16
21 21
22#define TRIO_NUM_TPIO_REGIONS 8 22#define TRIO_NUM_TPIO_REGIONS 8
23#define TRIO_LOG2_NUM_TPIO_REGIONS 3 23#define TRIO_LOG2_NUM_TPIO_REGIONS 3
24 24
25#define TRIO_NUM_MAP_MEM_REGIONS 16 25#define TRIO_NUM_MAP_MEM_REGIONS 32
26#define TRIO_LOG2_NUM_MAP_MEM_REGIONS 4 26#define TRIO_LOG2_NUM_MAP_MEM_REGIONS 5
27#define TRIO_NUM_MAP_SQ_REGIONS 8 27#define TRIO_NUM_MAP_SQ_REGIONS 8
28#define TRIO_LOG2_NUM_MAP_SQ_REGIONS 3 28#define TRIO_LOG2_NUM_MAP_SQ_REGIONS 3
29 29
30#define TRIO_LOG2_NUM_SQ_FIFO_ENTRIES 6 30#define TRIO_LOG2_NUM_SQ_FIFO_ENTRIES 6
31 31
32#define TRIO_NUM_PUSH_DMA_RINGS 32 32#define TRIO_NUM_PUSH_DMA_RINGS 64
33 33
34#define TRIO_NUM_PULL_DMA_RINGS 32 34#define TRIO_NUM_PULL_DMA_RINGS 64
35 35
36#endif /* __ARCH_TRIO_CONSTANTS_H__ */ 36#endif /* __ARCH_TRIO_CONSTANTS_H__ */
diff --git a/arch/tile/include/asm/page.h b/arch/tile/include/asm/page.h
index 6346888f7bdc..672768008618 100644
--- a/arch/tile/include/asm/page.h
+++ b/arch/tile/include/asm/page.h
@@ -182,10 +182,9 @@ static inline __attribute_const__ int get_order(unsigned long size)
182 182
183#define PAGE_OFFSET (-(_AC(1, UL) << (MAX_VA_WIDTH - 1))) 183#define PAGE_OFFSET (-(_AC(1, UL) << (MAX_VA_WIDTH - 1)))
184#define KERNEL_HIGH_VADDR _AC(0xfffffff800000000, UL) /* high 32GB */ 184#define KERNEL_HIGH_VADDR _AC(0xfffffff800000000, UL) /* high 32GB */
185#define FIXADDR_BASE (KERNEL_HIGH_VADDR - 0x400000000) /* 4 GB */ 185#define FIXADDR_BASE (KERNEL_HIGH_VADDR - 0x300000000) /* 4 GB */
186#define FIXADDR_TOP (KERNEL_HIGH_VADDR - 0x300000000) /* 4 GB */ 186#define FIXADDR_TOP (KERNEL_HIGH_VADDR - 0x200000000) /* 4 GB */
187#define _VMALLOC_START FIXADDR_TOP 187#define _VMALLOC_START FIXADDR_TOP
188#define HUGE_VMAP_BASE (KERNEL_HIGH_VADDR - 0x200000000) /* 4 GB */
189#define MEM_SV_START (KERNEL_HIGH_VADDR - 0x100000000) /* 256 MB */ 188#define MEM_SV_START (KERNEL_HIGH_VADDR - 0x100000000) /* 256 MB */
190#define MEM_MODULE_START (MEM_SV_START + (256*1024*1024)) /* 256 MB */ 189#define MEM_MODULE_START (MEM_SV_START + (256*1024*1024)) /* 256 MB */
191#define MEM_MODULE_END (MEM_MODULE_START + (256*1024*1024)) 190#define MEM_MODULE_END (MEM_MODULE_START + (256*1024*1024))
diff --git a/arch/tile/include/asm/pgtable_32.h b/arch/tile/include/asm/pgtable_32.h
index 63142ab3b3dd..d26a42279036 100644
--- a/arch/tile/include/asm/pgtable_32.h
+++ b/arch/tile/include/asm/pgtable_32.h
@@ -55,17 +55,9 @@
55#define PKMAP_BASE ((FIXADDR_BOOT_START - PAGE_SIZE*LAST_PKMAP) & PGDIR_MASK) 55#define PKMAP_BASE ((FIXADDR_BOOT_START - PAGE_SIZE*LAST_PKMAP) & PGDIR_MASK)
56 56
57#ifdef CONFIG_HIGHMEM 57#ifdef CONFIG_HIGHMEM
58# define __VMAPPING_END (PKMAP_BASE & ~(HPAGE_SIZE-1)) 58# define _VMALLOC_END (PKMAP_BASE & ~(HPAGE_SIZE-1))
59#else 59#else
60# define __VMAPPING_END (FIXADDR_START & ~(HPAGE_SIZE-1)) 60# define _VMALLOC_END (FIXADDR_START & ~(HPAGE_SIZE-1))
61#endif
62
63#ifdef CONFIG_HUGEVMAP
64#define HUGE_VMAP_END __VMAPPING_END
65#define HUGE_VMAP_BASE (HUGE_VMAP_END - CONFIG_NR_HUGE_VMAPS * HPAGE_SIZE)
66#define _VMALLOC_END HUGE_VMAP_BASE
67#else
68#define _VMALLOC_END __VMAPPING_END
69#endif 61#endif
70 62
71/* 63/*
diff --git a/arch/tile/include/asm/pgtable_64.h b/arch/tile/include/asm/pgtable_64.h
index 3421177f7370..2c8a9cd102d3 100644
--- a/arch/tile/include/asm/pgtable_64.h
+++ b/arch/tile/include/asm/pgtable_64.h
@@ -52,12 +52,10 @@
52 * memory allocation code). The vmalloc code puts in an internal 52 * memory allocation code). The vmalloc code puts in an internal
53 * guard page between each allocation. 53 * guard page between each allocation.
54 */ 54 */
55#define _VMALLOC_END HUGE_VMAP_BASE 55#define _VMALLOC_END MEM_SV_START
56#define VMALLOC_END _VMALLOC_END 56#define VMALLOC_END _VMALLOC_END
57#define VMALLOC_START _VMALLOC_START 57#define VMALLOC_START _VMALLOC_START
58 58
59#define HUGE_VMAP_END (HUGE_VMAP_BASE + PGDIR_SIZE)
60
61#ifndef __ASSEMBLY__ 59#ifndef __ASSEMBLY__
62 60
63/* We have no pud since we are a three-level page table. */ 61/* We have no pud since we are a three-level page table. */
diff --git a/arch/tile/include/gxio/iorpc_mpipe.h b/arch/tile/include/gxio/iorpc_mpipe.h
index fdd07f88cfd7..4cda03de734f 100644
--- a/arch/tile/include/gxio/iorpc_mpipe.h
+++ b/arch/tile/include/gxio/iorpc_mpipe.h
@@ -56,89 +56,89 @@
56#define GXIO_MPIPE_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000) 56#define GXIO_MPIPE_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
57#define GXIO_MPIPE_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) 57#define GXIO_MPIPE_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
58 58
59int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t * context, 59int gxio_mpipe_alloc_buffer_stacks(gxio_mpipe_context_t *context,
60 unsigned int count, unsigned int first, 60 unsigned int count, unsigned int first,
61 unsigned int flags); 61 unsigned int flags);
62 62
63int gxio_mpipe_init_buffer_stack_aux(gxio_mpipe_context_t * context, 63int gxio_mpipe_init_buffer_stack_aux(gxio_mpipe_context_t *context,
64 void *mem_va, size_t mem_size, 64 void *mem_va, size_t mem_size,
65 unsigned int mem_flags, unsigned int stack, 65 unsigned int mem_flags, unsigned int stack,
66 unsigned int buffer_size_enum); 66 unsigned int buffer_size_enum);
67 67
68 68
69int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t * context, 69int gxio_mpipe_alloc_notif_rings(gxio_mpipe_context_t *context,
70 unsigned int count, unsigned int first, 70 unsigned int count, unsigned int first,
71 unsigned int flags); 71 unsigned int flags);
72 72
73int gxio_mpipe_init_notif_ring_aux(gxio_mpipe_context_t * context, void *mem_va, 73int gxio_mpipe_init_notif_ring_aux(gxio_mpipe_context_t *context, void *mem_va,
74 size_t mem_size, unsigned int mem_flags, 74 size_t mem_size, unsigned int mem_flags,
75 unsigned int ring); 75 unsigned int ring);
76 76
77int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t * context, 77int gxio_mpipe_request_notif_ring_interrupt(gxio_mpipe_context_t *context,
78 int inter_x, int inter_y, 78 int inter_x, int inter_y,
79 int inter_ipi, int inter_event, 79 int inter_ipi, int inter_event,
80 unsigned int ring); 80 unsigned int ring);
81 81
82int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t * context, 82int gxio_mpipe_enable_notif_ring_interrupt(gxio_mpipe_context_t *context,
83 unsigned int ring); 83 unsigned int ring);
84 84
85int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t * context, 85int gxio_mpipe_alloc_notif_groups(gxio_mpipe_context_t *context,
86 unsigned int count, unsigned int first, 86 unsigned int count, unsigned int first,
87 unsigned int flags); 87 unsigned int flags);
88 88
89int gxio_mpipe_init_notif_group(gxio_mpipe_context_t * context, 89int gxio_mpipe_init_notif_group(gxio_mpipe_context_t *context,
90 unsigned int group, 90 unsigned int group,
91 gxio_mpipe_notif_group_bits_t bits); 91 gxio_mpipe_notif_group_bits_t bits);
92 92
93int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t * context, unsigned int count, 93int gxio_mpipe_alloc_buckets(gxio_mpipe_context_t *context, unsigned int count,
94 unsigned int first, unsigned int flags); 94 unsigned int first, unsigned int flags);
95 95
96int gxio_mpipe_init_bucket(gxio_mpipe_context_t * context, unsigned int bucket, 96int gxio_mpipe_init_bucket(gxio_mpipe_context_t *context, unsigned int bucket,
97 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info); 97 MPIPE_LBL_INIT_DAT_BSTS_TBL_t bucket_info);
98 98
99int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t * context, 99int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t *context,
100 unsigned int count, unsigned int first, 100 unsigned int count, unsigned int first,
101 unsigned int flags); 101 unsigned int flags);
102 102
103int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t * context, void *mem_va, 103int gxio_mpipe_init_edma_ring_aux(gxio_mpipe_context_t *context, void *mem_va,
104 size_t mem_size, unsigned int mem_flags, 104 size_t mem_size, unsigned int mem_flags,
105 unsigned int ring, unsigned int channel); 105 unsigned int ring, unsigned int channel);
106 106
107 107
108int gxio_mpipe_commit_rules(gxio_mpipe_context_t * context, const void *blob, 108int gxio_mpipe_commit_rules(gxio_mpipe_context_t *context, const void *blob,
109 size_t blob_size); 109 size_t blob_size);
110 110
111int gxio_mpipe_register_client_memory(gxio_mpipe_context_t * context, 111int gxio_mpipe_register_client_memory(gxio_mpipe_context_t *context,
112 unsigned int iotlb, HV_PTE pte, 112 unsigned int iotlb, HV_PTE pte,
113 unsigned int flags); 113 unsigned int flags);
114 114
115int gxio_mpipe_link_open_aux(gxio_mpipe_context_t * context, 115int gxio_mpipe_link_open_aux(gxio_mpipe_context_t *context,
116 _gxio_mpipe_link_name_t name, unsigned int flags); 116 _gxio_mpipe_link_name_t name, unsigned int flags);
117 117
118int gxio_mpipe_link_close_aux(gxio_mpipe_context_t * context, int mac); 118int gxio_mpipe_link_close_aux(gxio_mpipe_context_t *context, int mac);
119 119
120int gxio_mpipe_link_set_attr_aux(gxio_mpipe_context_t * context, int mac, 120int gxio_mpipe_link_set_attr_aux(gxio_mpipe_context_t *context, int mac,
121 uint32_t attr, int64_t val); 121 uint32_t attr, int64_t val);
122 122
123int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t * context, uint64_t * sec, 123int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t *context, uint64_t *sec,
124 uint64_t * nsec, uint64_t * cycles); 124 uint64_t *nsec, uint64_t *cycles);
125 125
126int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t * context, uint64_t sec, 126int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t *context, uint64_t sec,
127 uint64_t nsec, uint64_t cycles); 127 uint64_t nsec, uint64_t cycles);
128 128
129int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context, 129int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t *context,
130 int64_t nsec); 130 int64_t nsec);
131 131
132int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t * context, 132int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t *context,
133 int32_t ppb); 133 int32_t ppb);
134 134
135int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie); 135int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t *context, int pollfd_cookie);
136 136
137int gxio_mpipe_close_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie); 137int gxio_mpipe_close_pollfd(gxio_mpipe_context_t *context, int pollfd_cookie);
138 138
139int gxio_mpipe_get_mmio_base(gxio_mpipe_context_t * context, HV_PTE *base); 139int gxio_mpipe_get_mmio_base(gxio_mpipe_context_t *context, HV_PTE *base);
140 140
141int gxio_mpipe_check_mmio_offset(gxio_mpipe_context_t * context, 141int gxio_mpipe_check_mmio_offset(gxio_mpipe_context_t *context,
142 unsigned long offset, unsigned long size); 142 unsigned long offset, unsigned long size);
143 143
144#endif /* !__GXIO_MPIPE_LINUX_RPC_H__ */ 144#endif /* !__GXIO_MPIPE_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_mpipe_info.h b/arch/tile/include/gxio/iorpc_mpipe_info.h
index 476c5e5ca22c..f0b04284468b 100644
--- a/arch/tile/include/gxio/iorpc_mpipe_info.h
+++ b/arch/tile/include/gxio/iorpc_mpipe_info.h
@@ -33,18 +33,18 @@
33#define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) 33#define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
34 34
35 35
36int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context, 36int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t *context,
37 _gxio_mpipe_link_name_t name); 37 _gxio_mpipe_link_name_t name);
38 38
39int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context, 39int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t *context,
40 unsigned int idx, 40 unsigned int idx,
41 _gxio_mpipe_link_name_t * name, 41 _gxio_mpipe_link_name_t *name,
42 _gxio_mpipe_link_mac_t * mac); 42 _gxio_mpipe_link_mac_t *mac);
43 43
44int gxio_mpipe_info_get_mmio_base(gxio_mpipe_info_context_t * context, 44int gxio_mpipe_info_get_mmio_base(gxio_mpipe_info_context_t *context,
45 HV_PTE *base); 45 HV_PTE *base);
46 46
47int gxio_mpipe_info_check_mmio_offset(gxio_mpipe_info_context_t * context, 47int gxio_mpipe_info_check_mmio_offset(gxio_mpipe_info_context_t *context,
48 unsigned long offset, unsigned long size); 48 unsigned long offset, unsigned long size);
49 49
50#endif /* !__GXIO_MPIPE_INFO_LINUX_RPC_H__ */ 50#endif /* !__GXIO_MPIPE_INFO_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_trio.h b/arch/tile/include/gxio/iorpc_trio.h
index d95b96fd6c93..376a4f771167 100644
--- a/arch/tile/include/gxio/iorpc_trio.h
+++ b/arch/tile/include/gxio/iorpc_trio.h
@@ -46,59 +46,59 @@
46#define GXIO_TRIO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000) 46#define GXIO_TRIO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
47#define GXIO_TRIO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) 47#define GXIO_TRIO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
48 48
49int gxio_trio_alloc_asids(gxio_trio_context_t * context, unsigned int count, 49int gxio_trio_alloc_asids(gxio_trio_context_t *context, unsigned int count,
50 unsigned int first, unsigned int flags); 50 unsigned int first, unsigned int flags);
51 51
52 52
53int gxio_trio_alloc_memory_maps(gxio_trio_context_t * context, 53int gxio_trio_alloc_memory_maps(gxio_trio_context_t *context,
54 unsigned int count, unsigned int first, 54 unsigned int count, unsigned int first,
55 unsigned int flags); 55 unsigned int flags);
56 56
57 57
58int gxio_trio_alloc_scatter_queues(gxio_trio_context_t * context, 58int gxio_trio_alloc_scatter_queues(gxio_trio_context_t *context,
59 unsigned int count, unsigned int first, 59 unsigned int count, unsigned int first,
60 unsigned int flags); 60 unsigned int flags);
61 61
62int gxio_trio_alloc_pio_regions(gxio_trio_context_t * context, 62int gxio_trio_alloc_pio_regions(gxio_trio_context_t *context,
63 unsigned int count, unsigned int first, 63 unsigned int count, unsigned int first,
64 unsigned int flags); 64 unsigned int flags);
65 65
66int gxio_trio_init_pio_region_aux(gxio_trio_context_t * context, 66int gxio_trio_init_pio_region_aux(gxio_trio_context_t *context,
67 unsigned int pio_region, unsigned int mac, 67 unsigned int pio_region, unsigned int mac,
68 uint32_t bus_address_hi, unsigned int flags); 68 uint32_t bus_address_hi, unsigned int flags);
69 69
70 70
71int gxio_trio_init_memory_map_mmu_aux(gxio_trio_context_t * context, 71int gxio_trio_init_memory_map_mmu_aux(gxio_trio_context_t *context,
72 unsigned int map, unsigned long va, 72 unsigned int map, unsigned long va,
73 uint64_t size, unsigned int asid, 73 uint64_t size, unsigned int asid,
74 unsigned int mac, uint64_t bus_address, 74 unsigned int mac, uint64_t bus_address,
75 unsigned int node, 75 unsigned int node,
76 unsigned int order_mode); 76 unsigned int order_mode);
77 77
78int gxio_trio_get_port_property(gxio_trio_context_t * context, 78int gxio_trio_get_port_property(gxio_trio_context_t *context,
79 struct pcie_trio_ports_property *trio_ports); 79 struct pcie_trio_ports_property *trio_ports);
80 80
81int gxio_trio_config_legacy_intr(gxio_trio_context_t * context, int inter_x, 81int gxio_trio_config_legacy_intr(gxio_trio_context_t *context, int inter_x,
82 int inter_y, int inter_ipi, int inter_event, 82 int inter_y, int inter_ipi, int inter_event,
83 unsigned int mac, unsigned int intx); 83 unsigned int mac, unsigned int intx);
84 84
85int gxio_trio_config_msi_intr(gxio_trio_context_t * context, int inter_x, 85int gxio_trio_config_msi_intr(gxio_trio_context_t *context, int inter_x,
86 int inter_y, int inter_ipi, int inter_event, 86 int inter_y, int inter_ipi, int inter_event,
87 unsigned int mac, unsigned int mem_map, 87 unsigned int mac, unsigned int mem_map,
88 uint64_t mem_map_base, uint64_t mem_map_limit, 88 uint64_t mem_map_base, uint64_t mem_map_limit,
89 unsigned int asid); 89 unsigned int asid);
90 90
91 91
92int gxio_trio_set_mps_mrs(gxio_trio_context_t * context, uint16_t mps, 92int gxio_trio_set_mps_mrs(gxio_trio_context_t *context, uint16_t mps,
93 uint16_t mrs, unsigned int mac); 93 uint16_t mrs, unsigned int mac);
94 94
95int gxio_trio_force_rc_link_up(gxio_trio_context_t * context, unsigned int mac); 95int gxio_trio_force_rc_link_up(gxio_trio_context_t *context, unsigned int mac);
96 96
97int gxio_trio_force_ep_link_up(gxio_trio_context_t * context, unsigned int mac); 97int gxio_trio_force_ep_link_up(gxio_trio_context_t *context, unsigned int mac);
98 98
99int gxio_trio_get_mmio_base(gxio_trio_context_t * context, HV_PTE *base); 99int gxio_trio_get_mmio_base(gxio_trio_context_t *context, HV_PTE *base);
100 100
101int gxio_trio_check_mmio_offset(gxio_trio_context_t * context, 101int gxio_trio_check_mmio_offset(gxio_trio_context_t *context,
102 unsigned long offset, unsigned long size); 102 unsigned long offset, unsigned long size);
103 103
104#endif /* !__GXIO_TRIO_LINUX_RPC_H__ */ 104#endif /* !__GXIO_TRIO_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/iorpc_usb_host.h b/arch/tile/include/gxio/iorpc_usb_host.h
index 8622e7d126ad..79962a97de8e 100644
--- a/arch/tile/include/gxio/iorpc_usb_host.h
+++ b/arch/tile/include/gxio/iorpc_usb_host.h
@@ -31,16 +31,16 @@
31#define GXIO_USB_HOST_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000) 31#define GXIO_USB_HOST_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
32#define GXIO_USB_HOST_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001) 32#define GXIO_USB_HOST_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
33 33
34int gxio_usb_host_cfg_interrupt(gxio_usb_host_context_t * context, int inter_x, 34int gxio_usb_host_cfg_interrupt(gxio_usb_host_context_t *context, int inter_x,
35 int inter_y, int inter_ipi, int inter_event); 35 int inter_y, int inter_ipi, int inter_event);
36 36
37int gxio_usb_host_register_client_memory(gxio_usb_host_context_t * context, 37int gxio_usb_host_register_client_memory(gxio_usb_host_context_t *context,
38 HV_PTE pte, unsigned int flags); 38 HV_PTE pte, unsigned int flags);
39 39
40int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t * context, 40int gxio_usb_host_get_mmio_base(gxio_usb_host_context_t *context,
41 HV_PTE *base); 41 HV_PTE *base);
42 42
43int gxio_usb_host_check_mmio_offset(gxio_usb_host_context_t * context, 43int gxio_usb_host_check_mmio_offset(gxio_usb_host_context_t *context,
44 unsigned long offset, unsigned long size); 44 unsigned long offset, unsigned long size);
45 45
46#endif /* !__GXIO_USB_HOST_LINUX_RPC_H__ */ 46#endif /* !__GXIO_USB_HOST_LINUX_RPC_H__ */
diff --git a/arch/tile/include/gxio/usb_host.h b/arch/tile/include/gxio/usb_host.h
index 5eedec0e988e..93c9636d2dd7 100644
--- a/arch/tile/include/gxio/usb_host.h
+++ b/arch/tile/include/gxio/usb_host.h
@@ -53,7 +53,7 @@ typedef struct {
53 * @return Zero if the context was successfully initialized, else a 53 * @return Zero if the context was successfully initialized, else a
54 * GXIO_ERR_xxx error code. 54 * GXIO_ERR_xxx error code.
55 */ 55 */
56extern int gxio_usb_host_init(gxio_usb_host_context_t * context, int usb_index, 56extern int gxio_usb_host_init(gxio_usb_host_context_t *context, int usb_index,
57 int is_ehci); 57 int is_ehci);
58 58
59/* Destroy a USB context. 59/* Destroy a USB context.
@@ -68,20 +68,20 @@ extern int gxio_usb_host_init(gxio_usb_host_context_t * context, int usb_index,
68 * @return Zero if the context was successfully destroyed, else a 68 * @return Zero if the context was successfully destroyed, else a
69 * GXIO_ERR_xxx error code. 69 * GXIO_ERR_xxx error code.
70 */ 70 */
71extern int gxio_usb_host_destroy(gxio_usb_host_context_t * context); 71extern int gxio_usb_host_destroy(gxio_usb_host_context_t *context);
72 72
73/* Retrieve the address of the shim's MMIO registers. 73/* Retrieve the address of the shim's MMIO registers.
74 * 74 *
75 * @param context Pointer to a properly initialized gxio_usb_host_context_t. 75 * @param context Pointer to a properly initialized gxio_usb_host_context_t.
76 * @return The address of the shim's MMIO registers. 76 * @return The address of the shim's MMIO registers.
77 */ 77 */
78extern void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t * context); 78extern void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t *context);
79 79
80/* Retrieve the length of the shim's MMIO registers. 80/* Retrieve the length of the shim's MMIO registers.
81 * 81 *
82 * @param context Pointer to a properly initialized gxio_usb_host_context_t. 82 * @param context Pointer to a properly initialized gxio_usb_host_context_t.
83 * @return The length of the shim's MMIO registers. 83 * @return The length of the shim's MMIO registers.
84 */ 84 */
85extern size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t * context); 85extern size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t *context);
86 86
87#endif /* _GXIO_USB_H_ */ 87#endif /* _GXIO_USB_H_ */
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index ed378416b86a..49120843ff96 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -84,7 +84,7 @@ COMPAT_SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned int, offset_high,
84{ 84{
85 return sys_llseek(fd, offset_high, offset_low, result, origin); 85 return sys_llseek(fd, offset_high, offset_low, result, origin);
86} 86}
87 87
88/* Provide the compat syscall number to call mapping. */ 88/* Provide the compat syscall number to call mapping. */
89#undef __SYSCALL 89#undef __SYSCALL
90#define __SYSCALL(nr, call) [nr] = (call), 90#define __SYSCALL(nr, call) [nr] = (call),
diff --git a/arch/tile/kernel/futex_64.S b/arch/tile/kernel/futex_64.S
deleted file mode 100644
index f465d1eda20f..000000000000
--- a/arch/tile/kernel/futex_64.S
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * Copyright 2011 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 *
14 * Atomically access user memory, but use MMU to avoid propagating
15 * kernel exceptions.
16 */
17
18#include <linux/linkage.h>
19#include <asm/errno.h>
20#include <asm/futex.h>
21#include <asm/page.h>
22#include <asm/processor.h>
23
24/*
25 * Provide a set of atomic memory operations supporting <asm/futex.h>.
26 *
27 * r0: user address to manipulate
28 * r1: new value to write, or for cmpxchg, old value to compare against
29 * r2: (cmpxchg only) new value to write
30 *
31 * Return __get_user struct, r0 with value, r1 with error.
32 */
33#define FUTEX_OP(name, ...) \
34STD_ENTRY(futex_##name) \
35 __VA_ARGS__; \
36 { \
37 move r1, zero; \
38 jrp lr \
39 }; \
40 STD_ENDPROC(futex_##name); \
41 .pushsection __ex_table,"a"; \
42 .quad 1b, get_user_fault; \
43 .popsection
44
45 .pushsection .fixup,"ax"
46get_user_fault:
47 { movei r1, -EFAULT; jrp lr }
48 ENDPROC(get_user_fault)
49 .popsection
50
51FUTEX_OP(cmpxchg, mtspr CMPEXCH_VALUE, r1; 1: cmpexch4 r0, r0, r2)
52FUTEX_OP(set, 1: exch4 r0, r0, r1)
53FUTEX_OP(add, 1: fetchadd4 r0, r0, r1)
54FUTEX_OP(or, 1: fetchor4 r0, r0, r1)
55FUTEX_OP(andn, nor r1, r1, zero; 1: fetchand4 r0, r0, r1)
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index 4c34caea9dd3..74c91729a62a 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -1268,8 +1268,7 @@ static void __init validate_va(void)
1268 if ((long)VMALLOC_START >= 0) 1268 if ((long)VMALLOC_START >= 0)
1269 early_panic( 1269 early_panic(
1270 "Linux VMALLOC region below the 2GB line (%#lx)!\n" 1270 "Linux VMALLOC region below the 2GB line (%#lx)!\n"
1271 "Reconfigure the kernel with fewer NR_HUGE_VMAPS\n" 1271 "Reconfigure the kernel with smaller VMALLOC_RESERVE.\n",
1272 "or smaller VMALLOC_RESERVE.\n",
1273 VMALLOC_START); 1272 VMALLOC_START);
1274#endif 1273#endif
1275} 1274}
diff --git a/arch/tile/kernel/unaligned.c b/arch/tile/kernel/unaligned.c
index b425fb6a480d..b030b4e78845 100644
--- a/arch/tile/kernel/unaligned.c
+++ b/arch/tile/kernel/unaligned.c
@@ -551,8 +551,8 @@ static tilegx_bundle_bits jit_x1_bnezt(int ra, int broff)
551/* 551/*
552 * This function generates unalign fixup JIT. 552 * This function generates unalign fixup JIT.
553 * 553 *
554 * We fist find unalign load/store instruction's destination, source 554 * We first find unalign load/store instruction's destination, source
555 * reguisters: ra, rb and rd. and 3 scratch registers by calling 555 * registers: ra, rb and rd. and 3 scratch registers by calling
556 * find_regs(...). 3 scratch clobbers should not alias with any register 556 * find_regs(...). 3 scratch clobbers should not alias with any register
557 * used in the fault bundle. Then analyze the fault bundle to determine 557 * used in the fault bundle. Then analyze the fault bundle to determine
558 * if it's a load or store, operand width, branch or address increment etc. 558 * if it's a load or store, operand width, branch or address increment etc.
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 4c288f199453..6c0571216a9d 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -149,8 +149,6 @@ static inline int vmalloc_fault(pgd_t *pgd, unsigned long address)
149 pmd_k = vmalloc_sync_one(pgd, address); 149 pmd_k = vmalloc_sync_one(pgd, address);
150 if (!pmd_k) 150 if (!pmd_k)
151 return -1; 151 return -1;
152 if (pmd_huge(*pmd_k))
153 return 0; /* support TILE huge_vmap() API */
154 pte_k = pte_offset_kernel(pmd_k, address); 152 pte_k = pte_offset_kernel(pmd_k, address);
155 if (!pte_present(*pte_k)) 153 if (!pte_present(*pte_k))
156 return -1; 154 return -1;
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 4e316deb92fd..0fa1acfac79a 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -828,10 +828,6 @@ void __init mem_init(void)
828 printk(KERN_DEBUG " PKMAP %#lx - %#lx\n", 828 printk(KERN_DEBUG " PKMAP %#lx - %#lx\n",
829 PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP) - 1); 829 PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP) - 1);
830#endif 830#endif
831#ifdef CONFIG_HUGEVMAP
832 printk(KERN_DEBUG " HUGEMAP %#lx - %#lx\n",
833 HUGE_VMAP_BASE, HUGE_VMAP_END - 1);
834#endif
835 printk(KERN_DEBUG " VMALLOC %#lx - %#lx\n", 831 printk(KERN_DEBUG " VMALLOC %#lx - %#lx\n",
836 _VMALLOC_START, _VMALLOC_END - 1); 832 _VMALLOC_START, _VMALLOC_END - 1);
837#ifdef __tilegx__ 833#ifdef __tilegx__
diff --git a/arch/tile/mm/pgtable.c b/arch/tile/mm/pgtable.c
index 2deaddf3e01f..4fd9ec0b58ed 100644
--- a/arch/tile/mm/pgtable.c
+++ b/arch/tile/mm/pgtable.c
@@ -127,8 +127,7 @@ void shatter_huge_page(unsigned long addr)
127 } 127 }
128 128
129 /* Shatter the huge page into the preallocated L2 page table. */ 129 /* Shatter the huge page into the preallocated L2 page table. */
130 pmd_populate_kernel(&init_mm, pmd, 130 pmd_populate_kernel(&init_mm, pmd, get_prealloc_pte(pmd_pfn(*pmd)));
131 get_prealloc_pte(pte_pfn(*(pte_t *)pmd)));
132 131
133#ifdef __PAGETABLE_PMD_FOLDED 132#ifdef __PAGETABLE_PMD_FOLDED
134 /* Walk every pgd on the system and update the pmd there. */ 133 /* Walk every pgd on the system and update the pmd there. */
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e241a1930c98..ee2fb9d37745 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -481,11 +481,12 @@ config X86_INTEL_LPSS
481 bool "Intel Low Power Subsystem Support" 481 bool "Intel Low Power Subsystem Support"
482 depends on ACPI 482 depends on ACPI
483 select COMMON_CLK 483 select COMMON_CLK
484 select PINCTRL
484 ---help--- 485 ---help---
485 Select to build support for Intel Low Power Subsystem such as 486 Select to build support for Intel Low Power Subsystem such as
486 found on Intel Lynxpoint PCH. Selecting this option enables 487 found on Intel Lynxpoint PCH. Selecting this option enables
487 things like clock tree (common clock framework) which are needed 488 things like clock tree (common clock framework) and pincontrol
488 by the LPSS peripheral drivers. 489 which are needed by the LPSS peripheral drivers.
489 490
490config X86_RDC321X 491config X86_RDC321X
491 bool "RDC R-321x SoC" 492 bool "RDC R-321x SoC"
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index c62d88396ad5..9db76c31b3c3 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -899,8 +899,8 @@ static __initconst const u64 atom_hw_cache_event_ids
899static struct extra_reg intel_slm_extra_regs[] __read_mostly = 899static struct extra_reg intel_slm_extra_regs[] __read_mostly =
900{ 900{
901 /* must define OFFCORE_RSP_X first, see intel_fixup_er() */ 901 /* must define OFFCORE_RSP_X first, see intel_fixup_er() */
902 INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x768005ffff, RSP_0), 902 INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x768005ffffull, RSP_0),
903 INTEL_UEVENT_EXTRA_REG(0x02b7, MSR_OFFCORE_RSP_1, 0x768005ffff, RSP_1), 903 INTEL_UEVENT_EXTRA_REG(0x02b7, MSR_OFFCORE_RSP_1, 0x768005ffffull, RSP_1),
904 EVENT_EXTRA_END 904 EVENT_EXTRA_END
905}; 905};
906 906
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 63438aad177f..ab3ba1c1b7dd 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -584,6 +584,7 @@ struct event_constraint intel_snb_pebs_event_constraints[] = {
584 INTEL_EVENT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */ 584 INTEL_EVENT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */
585 INTEL_EVENT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */ 585 INTEL_EVENT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */
586 INTEL_EVENT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */ 586 INTEL_EVENT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
587 INTEL_EVENT_CONSTRAINT(0xd3, 0xf), /* MEM_LOAD_UOPS_LLC_MISS_RETIRED.* */
587 INTEL_UEVENT_CONSTRAINT(0x02d4, 0xf), /* MEM_LOAD_UOPS_MISC_RETIRED.LLC_MISS */ 588 INTEL_UEVENT_CONSTRAINT(0x02d4, 0xf), /* MEM_LOAD_UOPS_MISC_RETIRED.LLC_MISS */
588 EVENT_CONSTRAINT_END 589 EVENT_CONSTRAINT_END
589}; 590};
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1b69951a81e2..b077f4cc225a 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -487,21 +487,6 @@ ENDPROC(native_usergs_sysret64)
487 TRACE_IRQS_OFF 487 TRACE_IRQS_OFF
488 .endm 488 .endm
489 489
490ENTRY(save_rest)
491 PARTIAL_FRAME 1 (REST_SKIP+8)
492 movq 5*8+16(%rsp), %r11 /* save return address */
493 movq_cfi rbx, RBX+16
494 movq_cfi rbp, RBP+16
495 movq_cfi r12, R12+16
496 movq_cfi r13, R13+16
497 movq_cfi r14, R14+16
498 movq_cfi r15, R15+16
499 movq %r11, 8(%rsp) /* return address */
500 FIXUP_TOP_OF_STACK %r11, 16
501 ret
502 CFI_ENDPROC
503END(save_rest)
504
505/* save complete stack frame */ 490/* save complete stack frame */
506 .pushsection .kprobes.text, "ax" 491 .pushsection .kprobes.text, "ax"
507ENTRY(save_paranoid) 492ENTRY(save_paranoid)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index aecc98a93d1b..6cacab671f9b 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -653,6 +653,7 @@ static 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);
656 int max_cpu_present = find_last_bit(cpumask_bits(cpu_present_mask), NR_CPUS);
656 657
657 if (system_state == SYSTEM_BOOTING) { 658 if (system_state == SYSTEM_BOOTING) {
658 if (node != current_node) { 659 if (node != current_node) {
@@ -661,7 +662,7 @@ static void announce_cpu(int cpu, int apicid)
661 current_node = node; 662 current_node = node;
662 pr_info("Booting Node %3d, Processors ", node); 663 pr_info("Booting Node %3d, Processors ", node);
663 } 664 }
664 pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " OK\n" : ""); 665 pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
665 return; 666 return;
666 } else 667 } else
667 pr_info("Booting Node %d Processor %d APIC 0x%x\n", 668 pr_info("Booting Node %d Processor %d APIC 0x%x\n",
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2bc1e81045b0..ddc3f3d2afdb 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2025,6 +2025,17 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
2025 return rc; 2025 return rc;
2026} 2026}
2027 2027
2028static int em_ret_far_imm(struct x86_emulate_ctxt *ctxt)
2029{
2030 int rc;
2031
2032 rc = em_ret_far(ctxt);
2033 if (rc != X86EMUL_CONTINUE)
2034 return rc;
2035 rsp_increment(ctxt, ctxt->src.val);
2036 return X86EMUL_CONTINUE;
2037}
2038
2028static int em_cmpxchg(struct x86_emulate_ctxt *ctxt) 2039static int em_cmpxchg(struct x86_emulate_ctxt *ctxt)
2029{ 2040{
2030 /* Save real source value, then compare EAX against destination. */ 2041 /* Save real source value, then compare EAX against destination. */
@@ -3763,7 +3774,8 @@ static const struct opcode opcode_table[256] = {
3763 G(ByteOp, group11), G(0, group11), 3774 G(ByteOp, group11), G(0, group11),
3764 /* 0xC8 - 0xCF */ 3775 /* 0xC8 - 0xCF */
3765 I(Stack | SrcImmU16 | Src2ImmByte, em_enter), I(Stack, em_leave), 3776 I(Stack | SrcImmU16 | Src2ImmByte, em_enter), I(Stack, em_leave),
3766 N, I(ImplicitOps | Stack, em_ret_far), 3777 I(ImplicitOps | Stack | SrcImmU16, em_ret_far_imm),
3778 I(ImplicitOps | Stack, em_ret_far),
3767 D(ImplicitOps), DI(SrcImmByte, intn), 3779 D(ImplicitOps), DI(SrcImmByte, intn),
3768 D(ImplicitOps | No64), II(ImplicitOps, em_iret, iret), 3780 D(ImplicitOps | No64), II(ImplicitOps, em_iret, iret),
3769 /* 0xD0 - 0xD7 */ 3781 /* 0xD0 - 0xD7 */
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 043330159179..ad75d77999d0 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -99,6 +99,7 @@ struct guest_walker {
99 pt_element_t prefetch_ptes[PTE_PREFETCH_NUM]; 99 pt_element_t prefetch_ptes[PTE_PREFETCH_NUM];
100 gpa_t pte_gpa[PT_MAX_FULL_LEVELS]; 100 gpa_t pte_gpa[PT_MAX_FULL_LEVELS];
101 pt_element_t __user *ptep_user[PT_MAX_FULL_LEVELS]; 101 pt_element_t __user *ptep_user[PT_MAX_FULL_LEVELS];
102 bool pte_writable[PT_MAX_FULL_LEVELS];
102 unsigned pt_access; 103 unsigned pt_access;
103 unsigned pte_access; 104 unsigned pte_access;
104 gfn_t gfn; 105 gfn_t gfn;
@@ -235,6 +236,22 @@ static int FNAME(update_accessed_dirty_bits)(struct kvm_vcpu *vcpu,
235 if (pte == orig_pte) 236 if (pte == orig_pte)
236 continue; 237 continue;
237 238
239 /*
240 * If the slot is read-only, simply do not process the accessed
241 * and dirty bits. This is the correct thing to do if the slot
242 * is ROM, and page tables in read-as-ROM/write-as-MMIO slots
243 * are only supported if the accessed and dirty bits are already
244 * set in the ROM (so that MMIO writes are never needed).
245 *
246 * Note that NPT does not allow this at all and faults, since
247 * it always wants nested page table entries for the guest
248 * page tables to be writable. And EPT works but will simply
249 * overwrite the read-only memory to set the accessed and dirty
250 * bits.
251 */
252 if (unlikely(!walker->pte_writable[level - 1]))
253 continue;
254
238 ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index, orig_pte, pte); 255 ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index, orig_pte, pte);
239 if (ret) 256 if (ret)
240 return ret; 257 return ret;
@@ -309,7 +326,8 @@ retry_walk:
309 goto error; 326 goto error;
310 real_gfn = gpa_to_gfn(real_gfn); 327 real_gfn = gpa_to_gfn(real_gfn);
311 328
312 host_addr = gfn_to_hva(vcpu->kvm, real_gfn); 329 host_addr = gfn_to_hva_prot(vcpu->kvm, real_gfn,
330 &walker->pte_writable[walker->level - 1]);
313 if (unlikely(kvm_is_error_hva(host_addr))) 331 if (unlikely(kvm_is_error_hva(host_addr)))
314 goto error; 332 goto error;
315 333
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1f1da43ff2a2..a1216de9ffda 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5339,6 +5339,15 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
5339 return 0; 5339 return 0;
5340 } 5340 }
5341 5341
5342 /*
5343 * EPT violation happened while executing iret from NMI,
5344 * "blocked by NMI" bit has to be set before next VM entry.
5345 * There are errata that may cause this bit to not be set:
5346 * AAK134, BY25.
5347 */
5348 if (exit_qualification & INTR_INFO_UNBLOCK_NMI)
5349 vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, GUEST_INTR_STATE_NMI);
5350
5342 gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); 5351 gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS);
5343 trace_kvm_page_fault(gpa, exit_qualification); 5352 trace_kvm_page_fault(gpa, exit_qualification);
5344 5353
@@ -7766,6 +7775,10 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
7766 vmcs_write64(GUEST_PDPTR1, vmcs12->guest_pdptr1); 7775 vmcs_write64(GUEST_PDPTR1, vmcs12->guest_pdptr1);
7767 vmcs_write64(GUEST_PDPTR2, vmcs12->guest_pdptr2); 7776 vmcs_write64(GUEST_PDPTR2, vmcs12->guest_pdptr2);
7768 vmcs_write64(GUEST_PDPTR3, vmcs12->guest_pdptr3); 7777 vmcs_write64(GUEST_PDPTR3, vmcs12->guest_pdptr3);
7778 __clear_bit(VCPU_EXREG_PDPTR,
7779 (unsigned long *)&vcpu->arch.regs_avail);
7780 __clear_bit(VCPU_EXREG_PDPTR,
7781 (unsigned long *)&vcpu->arch.regs_dirty);
7769 } 7782 }
7770 7783
7771 kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->guest_rsp); 7784 kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->guest_rsp);
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 449f6298dc89..8557adcd34ee 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -2865,15 +2865,4 @@ static struct pci_driver he_driver = {
2865 .id_table = he_pci_tbl, 2865 .id_table = he_pci_tbl,
2866}; 2866};
2867 2867
2868static int __init he_init(void) 2868module_pci_driver(he_driver);
2869{
2870 return pci_register_driver(&he_driver);
2871}
2872
2873static void __exit he_cleanup(void)
2874{
2875 pci_unregister_driver(&he_driver);
2876}
2877
2878module_init(he_init);
2879module_exit(he_cleanup);
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 409502a78e7e..5aca5f4c5458 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -778,7 +778,7 @@ static int ns_init_card(int i, struct pci_dev *pcidev)
778 return error; 778 return error;
779 } 779 }
780 780
781 if (mac[i] == NULL || mac_pton(mac[i], card->atmdev->esi)) { 781 if (mac[i] == NULL || !mac_pton(mac[i], card->atmdev->esi)) {
782 nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET, 782 nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET,
783 card->atmdev->esi, 6); 783 card->atmdev->esi, 6);
784 if (memcmp(card->atmdev->esi, "\x00\x00\x00\x00\x00\x00", 6) == 784 if (memcmp(card->atmdev->esi, "\x00\x00\x00\x00\x00\x00", 6) ==
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index a355e63a3838..6fb98b53533f 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -188,8 +188,11 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
188 pci_write_config_dword(dev, 0x40, val & 0xffff00ff); 188 pci_write_config_dword(dev, 0x40, val & 0xffff00ff);
189 189
190 /* SSB needed additional powering up, do we have any AMBA PCI cards? */ 190 /* SSB needed additional powering up, do we have any AMBA PCI cards? */
191 if (!pci_is_pcie(dev)) 191 if (!pci_is_pcie(dev)) {
192 bcma_err(bus, "PCI card detected, report problems.\n"); 192 bcma_err(bus, "PCI card detected, they are not supported.\n");
193 err = -ENXIO;
194 goto err_pci_release_regions;
195 }
193 196
194 /* Map MMIO */ 197 /* Map MMIO */
195 err = -ENOMEM; 198 err = -ENOMEM;
@@ -269,6 +272,7 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend,
269 272
270static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = { 273static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
271 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, 274 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
275 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) },
272 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, 276 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) },
273 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, 277 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
274 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, 278 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index cd6b20fce680..37768401d113 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -269,6 +269,8 @@ static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 core
269 return NULL; 269 return NULL;
270} 270}
271 271
272#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
273
272static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, 274static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
273 struct bcma_device_id *match, int core_num, 275 struct bcma_device_id *match, int core_num,
274 struct bcma_device *core) 276 struct bcma_device *core)
@@ -351,11 +353,11 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
351 * the main register space for the core 353 * the main register space for the core
352 */ 354 */
353 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0); 355 tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
354 if (tmp == 0 || IS_ERR_VALUE(tmp)) { 356 if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
355 /* Try again to see if it is a bridge */ 357 /* Try again to see if it is a bridge */
356 tmp = bcma_erom_get_addr_desc(bus, eromptr, 358 tmp = bcma_erom_get_addr_desc(bus, eromptr,
357 SCAN_ADDR_TYPE_BRIDGE, 0); 359 SCAN_ADDR_TYPE_BRIDGE, 0);
358 if (tmp == 0 || IS_ERR_VALUE(tmp)) { 360 if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
359 return -EILSEQ; 361 return -EILSEQ;
360 } else { 362 } else {
361 bcma_info(bus, "Bridge found\n"); 363 bcma_info(bus, "Bridge found\n");
@@ -369,7 +371,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
369 for (j = 0; ; j++) { 371 for (j = 0; ; j++) {
370 tmp = bcma_erom_get_addr_desc(bus, eromptr, 372 tmp = bcma_erom_get_addr_desc(bus, eromptr,
371 SCAN_ADDR_TYPE_SLAVE, i); 373 SCAN_ADDR_TYPE_SLAVE, i);
372 if (IS_ERR_VALUE(tmp)) { 374 if (IS_ERR_VALUE_U32(tmp)) {
373 /* no more entries for port _i_ */ 375 /* no more entries for port _i_ */
374 /* pr_debug("erom: slave port %d " 376 /* pr_debug("erom: slave port %d "
375 * "has %d descriptors\n", i, j); */ 377 * "has %d descriptors\n", i, j); */
@@ -386,7 +388,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
386 for (j = 0; ; j++) { 388 for (j = 0; ; j++) {
387 tmp = bcma_erom_get_addr_desc(bus, eromptr, 389 tmp = bcma_erom_get_addr_desc(bus, eromptr,
388 SCAN_ADDR_TYPE_MWRAP, i); 390 SCAN_ADDR_TYPE_MWRAP, i);
389 if (IS_ERR_VALUE(tmp)) { 391 if (IS_ERR_VALUE_U32(tmp)) {
390 /* no more entries for port _i_ */ 392 /* no more entries for port _i_ */
391 /* pr_debug("erom: master wrapper %d " 393 /* pr_debug("erom: master wrapper %d "
392 * "has %d descriptors\n", i, j); */ 394 * "has %d descriptors\n", i, j); */
@@ -404,7 +406,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
404 for (j = 0; ; j++) { 406 for (j = 0; ; j++) {
405 tmp = bcma_erom_get_addr_desc(bus, eromptr, 407 tmp = bcma_erom_get_addr_desc(bus, eromptr,
406 SCAN_ADDR_TYPE_SWRAP, i + hack); 408 SCAN_ADDR_TYPE_SWRAP, i + hack);
407 if (IS_ERR_VALUE(tmp)) { 409 if (IS_ERR_VALUE_U32(tmp)) {
408 /* no more entries for port _i_ */ 410 /* no more entries for port _i_ */
409 /* pr_debug("erom: master wrapper %d " 411 /* pr_debug("erom: master wrapper %d "
410 * has %d descriptors\n", i, j); */ 412 * has %d descriptors\n", i, j); */
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b22a7d0fe5b7..cb1db2979d3d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -931,12 +931,14 @@ static const char *rbd_dev_v1_snap_name(struct rbd_device *rbd_dev,
931 u64 snap_id) 931 u64 snap_id)
932{ 932{
933 u32 which; 933 u32 which;
934 const char *snap_name;
934 935
935 which = rbd_dev_snap_index(rbd_dev, snap_id); 936 which = rbd_dev_snap_index(rbd_dev, snap_id);
936 if (which == BAD_SNAP_INDEX) 937 if (which == BAD_SNAP_INDEX)
937 return NULL; 938 return ERR_PTR(-ENOENT);
938 939
939 return _rbd_dev_v1_snap_name(rbd_dev, which); 940 snap_name = _rbd_dev_v1_snap_name(rbd_dev, which);
941 return snap_name ? snap_name : ERR_PTR(-ENOMEM);
940} 942}
941 943
942static const char *rbd_snap_name(struct rbd_device *rbd_dev, u64 snap_id) 944static const char *rbd_snap_name(struct rbd_device *rbd_dev, u64 snap_id)
@@ -2812,7 +2814,7 @@ out_err:
2812 obj_request_done_set(obj_request); 2814 obj_request_done_set(obj_request);
2813} 2815}
2814 2816
2815static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, u64 notify_id) 2817static int rbd_obj_notify_ack_sync(struct rbd_device *rbd_dev, u64 notify_id)
2816{ 2818{
2817 struct rbd_obj_request *obj_request; 2819 struct rbd_obj_request *obj_request;
2818 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; 2820 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
@@ -2827,16 +2829,17 @@ static int rbd_obj_notify_ack(struct rbd_device *rbd_dev, u64 notify_id)
2827 obj_request->osd_req = rbd_osd_req_create(rbd_dev, false, obj_request); 2829 obj_request->osd_req = rbd_osd_req_create(rbd_dev, false, obj_request);
2828 if (!obj_request->osd_req) 2830 if (!obj_request->osd_req)
2829 goto out; 2831 goto out;
2830 obj_request->callback = rbd_obj_request_put;
2831 2832
2832 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK, 2833 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_NOTIFY_ACK,
2833 notify_id, 0, 0); 2834 notify_id, 0, 0);
2834 rbd_osd_req_format_read(obj_request); 2835 rbd_osd_req_format_read(obj_request);
2835 2836
2836 ret = rbd_obj_request_submit(osdc, obj_request); 2837 ret = rbd_obj_request_submit(osdc, obj_request);
2837out:
2838 if (ret) 2838 if (ret)
2839 rbd_obj_request_put(obj_request); 2839 goto out;
2840 ret = rbd_obj_request_wait(obj_request);
2841out:
2842 rbd_obj_request_put(obj_request);
2840 2843
2841 return ret; 2844 return ret;
2842} 2845}
@@ -2856,7 +2859,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
2856 if (ret) 2859 if (ret)
2857 rbd_warn(rbd_dev, "header refresh error (%d)\n", ret); 2860 rbd_warn(rbd_dev, "header refresh error (%d)\n", ret);
2858 2861
2859 rbd_obj_notify_ack(rbd_dev, notify_id); 2862 rbd_obj_notify_ack_sync(rbd_dev, notify_id);
2860} 2863}
2861 2864
2862/* 2865/*
@@ -3328,6 +3331,31 @@ static void rbd_exists_validate(struct rbd_device *rbd_dev)
3328 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 3331 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
3329} 3332}
3330 3333
3334static void rbd_dev_update_size(struct rbd_device *rbd_dev)
3335{
3336 sector_t size;
3337 bool removing;
3338
3339 /*
3340 * Don't hold the lock while doing disk operations,
3341 * or lock ordering will conflict with the bdev mutex via:
3342 * rbd_add() -> blkdev_get() -> rbd_open()
3343 */
3344 spin_lock_irq(&rbd_dev->lock);
3345 removing = test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags);
3346 spin_unlock_irq(&rbd_dev->lock);
3347 /*
3348 * If the device is being removed, rbd_dev->disk has
3349 * been destroyed, so don't try to update its size
3350 */
3351 if (!removing) {
3352 size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE;
3353 dout("setting size to %llu sectors", (unsigned long long)size);
3354 set_capacity(rbd_dev->disk, size);
3355 revalidate_disk(rbd_dev->disk);
3356 }
3357}
3358
3331static int rbd_dev_refresh(struct rbd_device *rbd_dev) 3359static int rbd_dev_refresh(struct rbd_device *rbd_dev)
3332{ 3360{
3333 u64 mapping_size; 3361 u64 mapping_size;
@@ -3347,12 +3375,7 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)
3347 up_write(&rbd_dev->header_rwsem); 3375 up_write(&rbd_dev->header_rwsem);
3348 3376
3349 if (mapping_size != rbd_dev->mapping.size) { 3377 if (mapping_size != rbd_dev->mapping.size) {
3350 sector_t size; 3378 rbd_dev_update_size(rbd_dev);
3351
3352 size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE;
3353 dout("setting size to %llu sectors", (unsigned long long)size);
3354 set_capacity(rbd_dev->disk, size);
3355 revalidate_disk(rbd_dev->disk);
3356 } 3379 }
3357 3380
3358 return ret; 3381 return ret;
@@ -4061,8 +4084,13 @@ static u64 rbd_v2_snap_id_by_name(struct rbd_device *rbd_dev, const char *name)
4061 4084
4062 snap_id = snapc->snaps[which]; 4085 snap_id = snapc->snaps[which];
4063 snap_name = rbd_dev_v2_snap_name(rbd_dev, snap_id); 4086 snap_name = rbd_dev_v2_snap_name(rbd_dev, snap_id);
4064 if (IS_ERR(snap_name)) 4087 if (IS_ERR(snap_name)) {
4065 break; 4088 /* ignore no-longer existing snapshots */
4089 if (PTR_ERR(snap_name) == -ENOENT)
4090 continue;
4091 else
4092 break;
4093 }
4066 found = !strcmp(name, snap_name); 4094 found = !strcmp(name, snap_name);
4067 kfree(snap_name); 4095 kfree(snap_name);
4068 } 4096 }
@@ -4141,8 +4169,8 @@ static int rbd_dev_spec_update(struct rbd_device *rbd_dev)
4141 /* Look up the snapshot name, and make a copy */ 4169 /* Look up the snapshot name, and make a copy */
4142 4170
4143 snap_name = rbd_snap_name(rbd_dev, spec->snap_id); 4171 snap_name = rbd_snap_name(rbd_dev, spec->snap_id);
4144 if (!snap_name) { 4172 if (IS_ERR(snap_name)) {
4145 ret = -ENOMEM; 4173 ret = PTR_ERR(snap_name);
4146 goto out_err; 4174 goto out_err;
4147 } 4175 }
4148 4176
@@ -5163,10 +5191,23 @@ static ssize_t rbd_remove(struct bus_type *bus,
5163 if (ret < 0 || already) 5191 if (ret < 0 || already)
5164 return ret; 5192 return ret;
5165 5193
5166 rbd_bus_del_dev(rbd_dev);
5167 ret = rbd_dev_header_watch_sync(rbd_dev, false); 5194 ret = rbd_dev_header_watch_sync(rbd_dev, false);
5168 if (ret) 5195 if (ret)
5169 rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret); 5196 rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret);
5197
5198 /*
5199 * flush remaining watch callbacks - these must be complete
5200 * before the osd_client is shutdown
5201 */
5202 dout("%s: flushing notifies", __func__);
5203 ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc);
5204 /*
5205 * Don't free anything from rbd_dev->disk until after all
5206 * notifies are completely processed. Otherwise
5207 * rbd_bus_del_dev() will race with rbd_watch_cb(), resulting
5208 * in a potential use after free of rbd_dev->disk or rbd_dev.
5209 */
5210 rbd_bus_del_dev(rbd_dev);
5170 rbd_dev_image_release(rbd_dev); 5211 rbd_dev_image_release(rbd_dev);
5171 module_put(THIS_MODULE); 5212 module_put(THIS_MODULE);
5172 5213
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 4afae20df512..9fe8a875a827 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -30,3 +30,5 @@ hci_uart-$(CONFIG_BT_HCIUART_LL) += hci_ll.o
30hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o 30hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o
31hci_uart-$(CONFIG_BT_HCIUART_3WIRE) += hci_h5.o 31hci_uart-$(CONFIG_BT_HCIUART_3WIRE) += hci_h5.o
32hci_uart-objs := $(hci_uart-y) 32hci_uart-objs := $(hci_uart-y)
33
34ccflags-y += -D__CHECK_ENDIAN__
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index a12b923bbaca..0a327f4154a2 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -85,6 +85,7 @@ static struct usb_device_id ath3k_table[] = {
85 { USB_DEVICE(0x04CA, 0x3008) }, 85 { USB_DEVICE(0x04CA, 0x3008) },
86 { USB_DEVICE(0x13d3, 0x3362) }, 86 { USB_DEVICE(0x13d3, 0x3362) },
87 { USB_DEVICE(0x0CF3, 0xE004) }, 87 { USB_DEVICE(0x0CF3, 0xE004) },
88 { USB_DEVICE(0x0CF3, 0xE005) },
88 { USB_DEVICE(0x0930, 0x0219) }, 89 { USB_DEVICE(0x0930, 0x0219) },
89 { USB_DEVICE(0x0489, 0xe057) }, 90 { USB_DEVICE(0x0489, 0xe057) },
90 { USB_DEVICE(0x13d3, 0x3393) }, 91 { USB_DEVICE(0x13d3, 0x3393) },
@@ -126,6 +127,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
126 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 }, 127 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
127 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, 128 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
128 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 }, 129 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
130 { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
129 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 131 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
130 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 }, 132 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
131 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 }, 133 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
index 27068d149380..f9d183387f45 100644
--- a/drivers/bluetooth/btmrvl_drv.h
+++ b/drivers/bluetooth/btmrvl_drv.h
@@ -23,6 +23,8 @@
23#include <linux/bitops.h> 23#include <linux/bitops.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <net/bluetooth/bluetooth.h> 25#include <net/bluetooth/bluetooth.h>
26#include <linux/ctype.h>
27#include <linux/firmware.h>
26 28
27#define BTM_HEADER_LEN 4 29#define BTM_HEADER_LEN 4
28#define BTM_UPLD_SIZE 2312 30#define BTM_UPLD_SIZE 2312
@@ -41,6 +43,8 @@ struct btmrvl_thread {
41struct btmrvl_device { 43struct btmrvl_device {
42 void *card; 44 void *card;
43 struct hci_dev *hcidev; 45 struct hci_dev *hcidev;
46 struct device *dev;
47 const char *cal_data;
44 48
45 u8 dev_type; 49 u8 dev_type;
46 50
@@ -91,6 +95,7 @@ struct btmrvl_private {
91#define BT_CMD_HOST_SLEEP_CONFIG 0x59 95#define BT_CMD_HOST_SLEEP_CONFIG 0x59
92#define BT_CMD_HOST_SLEEP_ENABLE 0x5A 96#define BT_CMD_HOST_SLEEP_ENABLE 0x5A
93#define BT_CMD_MODULE_CFG_REQ 0x5B 97#define BT_CMD_MODULE_CFG_REQ 0x5B
98#define BT_CMD_LOAD_CONFIG_DATA 0x61
94 99
95/* Sub-commands: Module Bringup/Shutdown Request/Response */ 100/* Sub-commands: Module Bringup/Shutdown Request/Response */
96#define MODULE_BRINGUP_REQ 0xF1 101#define MODULE_BRINGUP_REQ 0xF1
@@ -116,11 +121,8 @@ struct btmrvl_private {
116#define PS_SLEEP 0x01 121#define PS_SLEEP 0x01
117#define PS_AWAKE 0x00 122#define PS_AWAKE 0x00
118 123
119struct btmrvl_cmd { 124#define BT_CMD_DATA_SIZE 32
120 __le16 ocf_ogf; 125#define BT_CAL_DATA_SIZE 28
121 u8 length;
122 u8 data[4];
123} __packed;
124 126
125struct btmrvl_event { 127struct btmrvl_event {
126 u8 ec; /* event counter */ 128 u8 ec; /* event counter */
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index 9a9f51875df5..6e7bd4e4adbb 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -57,8 +57,7 @@ bool btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb)
57 ocf = hci_opcode_ocf(opcode); 57 ocf = hci_opcode_ocf(opcode);
58 ogf = hci_opcode_ogf(opcode); 58 ogf = hci_opcode_ogf(opcode);
59 59
60 if (ocf == BT_CMD_MODULE_CFG_REQ && 60 if (priv->btmrvl_dev.sendcmdflag) {
61 priv->btmrvl_dev.sendcmdflag) {
62 priv->btmrvl_dev.sendcmdflag = false; 61 priv->btmrvl_dev.sendcmdflag = false;
63 priv->adapter->cmd_complete = true; 62 priv->adapter->cmd_complete = true;
64 wake_up_interruptible(&priv->adapter->cmd_wait_q); 63 wake_up_interruptible(&priv->adapter->cmd_wait_q);
@@ -116,7 +115,6 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
116 adapter->hs_state = HS_ACTIVATED; 115 adapter->hs_state = HS_ACTIVATED;
117 if (adapter->psmode) 116 if (adapter->psmode)
118 adapter->ps_state = PS_SLEEP; 117 adapter->ps_state = PS_SLEEP;
119 wake_up_interruptible(&adapter->cmd_wait_q);
120 BT_DBG("HS ACTIVATED!"); 118 BT_DBG("HS ACTIVATED!");
121 } else { 119 } else {
122 BT_DBG("HS Enable failed"); 120 BT_DBG("HS Enable failed");
@@ -168,22 +166,24 @@ exit:
168} 166}
169EXPORT_SYMBOL_GPL(btmrvl_process_event); 167EXPORT_SYMBOL_GPL(btmrvl_process_event);
170 168
171int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) 169static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 cmd_no,
170 const void *param, u8 len)
172{ 171{
173 struct sk_buff *skb; 172 struct sk_buff *skb;
174 struct btmrvl_cmd *cmd; 173 struct hci_command_hdr *hdr;
175 int ret = 0;
176 174
177 skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC); 175 skb = bt_skb_alloc(HCI_COMMAND_HDR_SIZE + len, GFP_ATOMIC);
178 if (skb == NULL) { 176 if (skb == NULL) {
179 BT_ERR("No free skb"); 177 BT_ERR("No free skb");
180 return -ENOMEM; 178 return -ENOMEM;
181 } 179 }
182 180
183 cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd)); 181 hdr = (struct hci_command_hdr *)skb_put(skb, HCI_COMMAND_HDR_SIZE);
184 cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_MODULE_CFG_REQ)); 182 hdr->opcode = cpu_to_le16(hci_opcode_pack(OGF, cmd_no));
185 cmd->length = 1; 183 hdr->plen = len;
186 cmd->data[0] = subcmd; 184
185 if (len)
186 memcpy(skb_put(skb, len), param, len);
187 187
188 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; 188 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
189 189
@@ -194,19 +194,23 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
194 194
195 priv->adapter->cmd_complete = false; 195 priv->adapter->cmd_complete = false;
196 196
197 BT_DBG("Queue module cfg Command");
198
199 wake_up_interruptible(&priv->main_thread.wait_q); 197 wake_up_interruptible(&priv->main_thread.wait_q);
200 198
201 if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q, 199 if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
202 priv->adapter->cmd_complete, 200 priv->adapter->cmd_complete,
203 msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) { 201 msecs_to_jiffies(WAIT_UNTIL_CMD_RESP)))
204 ret = -ETIMEDOUT; 202 return -ETIMEDOUT;
205 BT_ERR("module_cfg_cmd(%x): timeout: %d",
206 subcmd, priv->btmrvl_dev.sendcmdflag);
207 }
208 203
209 BT_DBG("module cfg Command done"); 204 return 0;
205}
206
207int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
208{
209 int ret;
210
211 ret = btmrvl_send_sync_cmd(priv, BT_CMD_MODULE_CFG_REQ, &subcmd, 1);
212 if (ret)
213 BT_ERR("module_cfg_cmd(%x) failed\n", subcmd);
210 214
211 return ret; 215 return ret;
212} 216}
@@ -214,61 +218,36 @@ EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
214 218
215int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv) 219int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv)
216{ 220{
217 struct sk_buff *skb; 221 int ret;
218 struct btmrvl_cmd *cmd; 222 u8 param[2];
219
220 skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
221 if (!skb) {
222 BT_ERR("No free skb");
223 return -ENOMEM;
224 }
225
226 cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
227 cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
228 BT_CMD_HOST_SLEEP_CONFIG));
229 cmd->length = 2;
230 cmd->data[0] = (priv->btmrvl_dev.gpio_gap & 0xff00) >> 8;
231 cmd->data[1] = (u8) (priv->btmrvl_dev.gpio_gap & 0x00ff);
232 223
233 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; 224 param[0] = (priv->btmrvl_dev.gpio_gap & 0xff00) >> 8;
225 param[1] = (u8) (priv->btmrvl_dev.gpio_gap & 0x00ff);
234 226
235 skb->dev = (void *) priv->btmrvl_dev.hcidev; 227 BT_DBG("Sending HSCFG Command, gpio=0x%x, gap=0x%x",
236 skb_queue_head(&priv->adapter->tx_queue, skb); 228 param[0], param[1]);
237 229
238 BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x", cmd->data[0], 230 ret = btmrvl_send_sync_cmd(priv, BT_CMD_HOST_SLEEP_CONFIG, param, 2);
239 cmd->data[1]); 231 if (ret)
232 BT_ERR("HSCFG command failed\n");
240 233
241 return 0; 234 return ret;
242} 235}
243EXPORT_SYMBOL_GPL(btmrvl_send_hscfg_cmd); 236EXPORT_SYMBOL_GPL(btmrvl_send_hscfg_cmd);
244 237
245int btmrvl_enable_ps(struct btmrvl_private *priv) 238int btmrvl_enable_ps(struct btmrvl_private *priv)
246{ 239{
247 struct sk_buff *skb; 240 int ret;
248 struct btmrvl_cmd *cmd; 241 u8 param;
249
250 skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
251 if (skb == NULL) {
252 BT_ERR("No free skb");
253 return -ENOMEM;
254 }
255
256 cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
257 cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
258 BT_CMD_AUTO_SLEEP_MODE));
259 cmd->length = 1;
260 242
261 if (priv->btmrvl_dev.psmode) 243 if (priv->btmrvl_dev.psmode)
262 cmd->data[0] = BT_PS_ENABLE; 244 param = BT_PS_ENABLE;
263 else 245 else
264 cmd->data[0] = BT_PS_DISABLE; 246 param = BT_PS_DISABLE;
265
266 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
267 247
268 skb->dev = (void *) priv->btmrvl_dev.hcidev; 248 ret = btmrvl_send_sync_cmd(priv, BT_CMD_AUTO_SLEEP_MODE, &param, 1);
269 skb_queue_head(&priv->adapter->tx_queue, skb); 249 if (ret)
270 250 BT_ERR("PSMODE command failed\n");
271 BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
272 251
273 return 0; 252 return 0;
274} 253}
@@ -276,37 +255,11 @@ EXPORT_SYMBOL_GPL(btmrvl_enable_ps);
276 255
277int btmrvl_enable_hs(struct btmrvl_private *priv) 256int btmrvl_enable_hs(struct btmrvl_private *priv)
278{ 257{
279 struct sk_buff *skb; 258 int ret;
280 struct btmrvl_cmd *cmd;
281 int ret = 0;
282
283 skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
284 if (skb == NULL) {
285 BT_ERR("No free skb");
286 return -ENOMEM;
287 }
288
289 cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
290 cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_HOST_SLEEP_ENABLE));
291 cmd->length = 0;
292
293 bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
294
295 skb->dev = (void *) priv->btmrvl_dev.hcidev;
296 skb_queue_head(&priv->adapter->tx_queue, skb);
297
298 BT_DBG("Queue hs enable Command");
299
300 wake_up_interruptible(&priv->main_thread.wait_q);
301 259
302 if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q, 260 ret = btmrvl_send_sync_cmd(priv, BT_CMD_HOST_SLEEP_ENABLE, NULL, 0);
303 priv->adapter->hs_state, 261 if (ret)
304 msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) { 262 BT_ERR("Host sleep enable command failed\n");
305 ret = -ETIMEDOUT;
306 BT_ERR("timeout: %d, %d,%d", priv->adapter->hs_state,
307 priv->adapter->ps_state,
308 priv->adapter->wakeup_tries);
309 }
310 263
311 return ret; 264 return ret;
312} 265}
@@ -480,6 +433,137 @@ static int btmrvl_open(struct hci_dev *hdev)
480} 433}
481 434
482/* 435/*
436 * This function parses provided calibration data input. It should contain
437 * hex bytes separated by space or new line character. Here is an example.
438 * 00 1C 01 37 FF FF FF FF 02 04 7F 01
439 * CE BA 00 00 00 2D C6 C0 00 00 00 00
440 * 00 F0 00 00
441 */
442static int btmrvl_parse_cal_cfg(const u8 *src, u32 len, u8 *dst, u32 dst_size)
443{
444 const u8 *s = src;
445 u8 *d = dst;
446 int ret;
447 u8 tmp[3];
448
449 tmp[2] = '\0';
450 while ((s - src) <= len - 2) {
451 if (isspace(*s)) {
452 s++;
453 continue;
454 }
455
456 if (isxdigit(*s)) {
457 if ((d - dst) >= dst_size) {
458 BT_ERR("calibration data file too big!!!");
459 return -EINVAL;
460 }
461
462 memcpy(tmp, s, 2);
463
464 ret = kstrtou8(tmp, 16, d++);
465 if (ret < 0)
466 return ret;
467
468 s += 2;
469 } else {
470 return -EINVAL;
471 }
472 }
473 if (d == dst)
474 return -EINVAL;
475
476 return 0;
477}
478
479static int btmrvl_load_cal_data(struct btmrvl_private *priv,
480 u8 *config_data)
481{
482 int i, ret;
483 u8 data[BT_CMD_DATA_SIZE];
484
485 data[0] = 0x00;
486 data[1] = 0x00;
487 data[2] = 0x00;
488 data[3] = BT_CMD_DATA_SIZE - 4;
489
490 /* Swap cal-data bytes. Each four bytes are swapped. Considering 4
491 * byte SDIO header offset, mapping of input and output bytes will be
492 * {3, 2, 1, 0} -> {0+4, 1+4, 2+4, 3+4},
493 * {7, 6, 5, 4} -> {4+4, 5+4, 6+4, 7+4} */
494 for (i = 4; i < BT_CMD_DATA_SIZE; i++)
495 data[i] = config_data[(i / 4) * 8 - 1 - i];
496
497 print_hex_dump_bytes("Calibration data: ",
498 DUMP_PREFIX_OFFSET, data, BT_CMD_DATA_SIZE);
499
500 ret = btmrvl_send_sync_cmd(priv, BT_CMD_LOAD_CONFIG_DATA, data,
501 BT_CMD_DATA_SIZE);
502 if (ret)
503 BT_ERR("Failed to download caibration data\n");
504
505 return 0;
506}
507
508static int
509btmrvl_process_cal_cfg(struct btmrvl_private *priv, u8 *data, u32 size)
510{
511 u8 cal_data[BT_CAL_DATA_SIZE];
512 int ret;
513
514 ret = btmrvl_parse_cal_cfg(data, size, cal_data, sizeof(cal_data));
515 if (ret)
516 return ret;
517
518 ret = btmrvl_load_cal_data(priv, cal_data);
519 if (ret) {
520 BT_ERR("Fail to load calibrate data");
521 return ret;
522 }
523
524 return 0;
525}
526
527static int btmrvl_cal_data_config(struct btmrvl_private *priv)
528{
529 const struct firmware *cfg;
530 int ret;
531 const char *cal_data = priv->btmrvl_dev.cal_data;
532
533 if (!cal_data)
534 return 0;
535
536 ret = request_firmware(&cfg, cal_data, priv->btmrvl_dev.dev);
537 if (ret < 0) {
538 BT_DBG("Failed to get %s file, skipping cal data download",
539 cal_data);
540 return 0;
541 }
542
543 ret = btmrvl_process_cal_cfg(priv, (u8 *)cfg->data, cfg->size);
544 release_firmware(cfg);
545 return ret;
546}
547
548static int btmrvl_setup(struct hci_dev *hdev)
549{
550 struct btmrvl_private *priv = hci_get_drvdata(hdev);
551
552 btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
553
554 if (btmrvl_cal_data_config(priv))
555 BT_ERR("Set cal data failed");
556
557 priv->btmrvl_dev.psmode = 1;
558 btmrvl_enable_ps(priv);
559
560 priv->btmrvl_dev.gpio_gap = 0xffff;
561 btmrvl_send_hscfg_cmd(priv);
562
563 return 0;
564}
565
566/*
483 * This function handles the event generated by firmware, rx data 567 * This function handles the event generated by firmware, rx data
484 * received from firmware, and tx data sent from kernel. 568 * received from firmware, and tx data sent from kernel.
485 */ 569 */
@@ -572,8 +656,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
572 hdev->flush = btmrvl_flush; 656 hdev->flush = btmrvl_flush;
573 hdev->send = btmrvl_send_frame; 657 hdev->send = btmrvl_send_frame;
574 hdev->ioctl = btmrvl_ioctl; 658 hdev->ioctl = btmrvl_ioctl;
575 659 hdev->setup = btmrvl_setup;
576 btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
577 660
578 hdev->dev_type = priv->btmrvl_dev.dev_type; 661 hdev->dev_type = priv->btmrvl_dev.dev_type;
579 662
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 00da6df9f71e..332475e400cf 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -18,7 +18,6 @@
18 * this warranty disclaimer. 18 * this warranty disclaimer.
19 **/ 19 **/
20 20
21#include <linux/firmware.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23 22
24#include <linux/mmc/sdio_ids.h> 23#include <linux/mmc/sdio_ids.h>
@@ -102,6 +101,7 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_88xx = {
102static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = { 101static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = {
103 .helper = "mrvl/sd8688_helper.bin", 102 .helper = "mrvl/sd8688_helper.bin",
104 .firmware = "mrvl/sd8688.bin", 103 .firmware = "mrvl/sd8688.bin",
104 .cal_data = NULL,
105 .reg = &btmrvl_reg_8688, 105 .reg = &btmrvl_reg_8688,
106 .sd_blksz_fw_dl = 64, 106 .sd_blksz_fw_dl = 64,
107}; 107};
@@ -109,6 +109,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = {
109static const struct btmrvl_sdio_device btmrvl_sdio_sd8787 = { 109static const struct btmrvl_sdio_device btmrvl_sdio_sd8787 = {
110 .helper = NULL, 110 .helper = NULL,
111 .firmware = "mrvl/sd8787_uapsta.bin", 111 .firmware = "mrvl/sd8787_uapsta.bin",
112 .cal_data = NULL,
112 .reg = &btmrvl_reg_87xx, 113 .reg = &btmrvl_reg_87xx,
113 .sd_blksz_fw_dl = 256, 114 .sd_blksz_fw_dl = 256,
114}; 115};
@@ -116,6 +117,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8787 = {
116static const struct btmrvl_sdio_device btmrvl_sdio_sd8797 = { 117static const struct btmrvl_sdio_device btmrvl_sdio_sd8797 = {
117 .helper = NULL, 118 .helper = NULL,
118 .firmware = "mrvl/sd8797_uapsta.bin", 119 .firmware = "mrvl/sd8797_uapsta.bin",
120 .cal_data = "mrvl/sd8797_caldata.conf",
119 .reg = &btmrvl_reg_87xx, 121 .reg = &btmrvl_reg_87xx,
120 .sd_blksz_fw_dl = 256, 122 .sd_blksz_fw_dl = 256,
121}; 123};
@@ -123,6 +125,7 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8797 = {
123static const struct btmrvl_sdio_device btmrvl_sdio_sd8897 = { 125static const struct btmrvl_sdio_device btmrvl_sdio_sd8897 = {
124 .helper = NULL, 126 .helper = NULL,
125 .firmware = "mrvl/sd8897_uapsta.bin", 127 .firmware = "mrvl/sd8897_uapsta.bin",
128 .cal_data = NULL,
126 .reg = &btmrvl_reg_88xx, 129 .reg = &btmrvl_reg_88xx,
127 .sd_blksz_fw_dl = 256, 130 .sd_blksz_fw_dl = 256,
128}; 131};
@@ -1006,6 +1009,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
1006 struct btmrvl_sdio_device *data = (void *) id->driver_data; 1009 struct btmrvl_sdio_device *data = (void *) id->driver_data;
1007 card->helper = data->helper; 1010 card->helper = data->helper;
1008 card->firmware = data->firmware; 1011 card->firmware = data->firmware;
1012 card->cal_data = data->cal_data;
1009 card->reg = data->reg; 1013 card->reg = data->reg;
1010 card->sd_blksz_fw_dl = data->sd_blksz_fw_dl; 1014 card->sd_blksz_fw_dl = data->sd_blksz_fw_dl;
1011 } 1015 }
@@ -1034,6 +1038,8 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
1034 } 1038 }
1035 1039
1036 card->priv = priv; 1040 card->priv = priv;
1041 priv->btmrvl_dev.dev = &card->func->dev;
1042 priv->btmrvl_dev.cal_data = card->cal_data;
1037 1043
1038 /* Initialize the interface specific function pointers */ 1044 /* Initialize the interface specific function pointers */
1039 priv->hw_host_to_card = btmrvl_sdio_host_to_card; 1045 priv->hw_host_to_card = btmrvl_sdio_host_to_card;
@@ -1046,12 +1052,6 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
1046 goto disable_host_int; 1052 goto disable_host_int;
1047 } 1053 }
1048 1054
1049 priv->btmrvl_dev.psmode = 1;
1050 btmrvl_enable_ps(priv);
1051
1052 priv->btmrvl_dev.gpio_gap = 0xffff;
1053 btmrvl_send_hscfg_cmd(priv);
1054
1055 return 0; 1055 return 0;
1056 1056
1057disable_host_int: 1057disable_host_int:
@@ -1222,4 +1222,5 @@ MODULE_FIRMWARE("mrvl/sd8688_helper.bin");
1222MODULE_FIRMWARE("mrvl/sd8688.bin"); 1222MODULE_FIRMWARE("mrvl/sd8688.bin");
1223MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin"); 1223MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
1224MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin"); 1224MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
1225MODULE_FIRMWARE("mrvl/sd8797_caldata.conf");
1225MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin"); 1226MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin");
diff --git a/drivers/bluetooth/btmrvl_sdio.h b/drivers/bluetooth/btmrvl_sdio.h
index 43d35a609ca9..6872d9ecac07 100644
--- a/drivers/bluetooth/btmrvl_sdio.h
+++ b/drivers/bluetooth/btmrvl_sdio.h
@@ -85,6 +85,7 @@ struct btmrvl_sdio_card {
85 u32 ioport; 85 u32 ioport;
86 const char *helper; 86 const char *helper;
87 const char *firmware; 87 const char *firmware;
88 const char *cal_data;
88 const struct btmrvl_sdio_card_reg *reg; 89 const struct btmrvl_sdio_card_reg *reg;
89 u16 sd_blksz_fw_dl; 90 u16 sd_blksz_fw_dl;
90 u8 rx_unit; 91 u8 rx_unit;
@@ -94,6 +95,7 @@ struct btmrvl_sdio_card {
94struct btmrvl_sdio_device { 95struct btmrvl_sdio_device {
95 const char *helper; 96 const char *helper;
96 const char *firmware; 97 const char *firmware;
98 const char *cal_data;
97 const struct btmrvl_sdio_card_reg *reg; 99 const struct btmrvl_sdio_card_reg *reg;
98 u16 sd_blksz_fw_dl; 100 u16 sd_blksz_fw_dl;
99}; 101};
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 8e16f0af6358..f3dfc0a88fdc 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -102,6 +102,7 @@ static struct usb_device_id btusb_table[] = {
102 102
103 /* Broadcom BCM20702A0 */ 103 /* Broadcom BCM20702A0 */
104 { USB_DEVICE(0x0b05, 0x17b5) }, 104 { USB_DEVICE(0x0b05, 0x17b5) },
105 { USB_DEVICE(0x0b05, 0x17cb) },
105 { USB_DEVICE(0x04ca, 0x2003) }, 106 { USB_DEVICE(0x04ca, 0x2003) },
106 { USB_DEVICE(0x0489, 0xe042) }, 107 { USB_DEVICE(0x0489, 0xe042) },
107 { USB_DEVICE(0x413c, 0x8197) }, 108 { USB_DEVICE(0x413c, 0x8197) },
@@ -112,6 +113,9 @@ static struct usb_device_id btusb_table[] = {
112 /*Broadcom devices with vendor specific id */ 113 /*Broadcom devices with vendor specific id */
113 { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) }, 114 { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) },
114 115
116 /* Belkin F8065bf - Broadcom based */
117 { USB_VENDOR_AND_INTERFACE_INFO(0x050d, 0xff, 0x01, 0x01) },
118
115 { } /* Terminating entry */ 119 { } /* Terminating entry */
116}; 120};
117 121
@@ -148,6 +152,7 @@ static struct usb_device_id blacklist_table[] = {
148 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 }, 152 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
149 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, 153 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
150 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 }, 154 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
155 { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
151 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 156 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
152 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 }, 157 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
153 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 }, 158 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index d8b7aed6e4a9..c04a3e6fb37c 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <asm/unaligned.h>
27 28
28#include <linux/kernel.h> 29#include <linux/kernel.h>
29#include <linux/init.h> 30#include <linux/init.h>
@@ -39,17 +40,17 @@
39#include <net/bluetooth/bluetooth.h> 40#include <net/bluetooth/bluetooth.h>
40#include <net/bluetooth/hci_core.h> 41#include <net/bluetooth/hci_core.h>
41 42
42#define VERSION "1.3" 43#define VERSION "1.4"
43 44
44static bool amp; 45static bool amp;
45 46
46struct vhci_data { 47struct vhci_data {
47 struct hci_dev *hdev; 48 struct hci_dev *hdev;
48 49
49 unsigned long flags;
50
51 wait_queue_head_t read_wait; 50 wait_queue_head_t read_wait;
52 struct sk_buff_head readq; 51 struct sk_buff_head readq;
52
53 struct delayed_work open_timeout;
53}; 54};
54 55
55static int vhci_open_dev(struct hci_dev *hdev) 56static int vhci_open_dev(struct hci_dev *hdev)
@@ -99,16 +100,62 @@ static int vhci_send_frame(struct sk_buff *skb)
99 skb_queue_tail(&data->readq, skb); 100 skb_queue_tail(&data->readq, skb);
100 101
101 wake_up_interruptible(&data->read_wait); 102 wake_up_interruptible(&data->read_wait);
103 return 0;
104}
105
106static int vhci_create_device(struct vhci_data *data, __u8 dev_type)
107{
108 struct hci_dev *hdev;
109 struct sk_buff *skb;
110
111 skb = bt_skb_alloc(4, GFP_KERNEL);
112 if (!skb)
113 return -ENOMEM;
114
115 hdev = hci_alloc_dev();
116 if (!hdev) {
117 kfree_skb(skb);
118 return -ENOMEM;
119 }
120
121 data->hdev = hdev;
122
123 hdev->bus = HCI_VIRTUAL;
124 hdev->dev_type = dev_type;
125 hci_set_drvdata(hdev, data);
126
127 hdev->open = vhci_open_dev;
128 hdev->close = vhci_close_dev;
129 hdev->flush = vhci_flush;
130 hdev->send = vhci_send_frame;
102 131
132 if (hci_register_dev(hdev) < 0) {
133 BT_ERR("Can't register HCI device");
134 hci_free_dev(hdev);
135 data->hdev = NULL;
136 kfree_skb(skb);
137 return -EBUSY;
138 }
139
140 bt_cb(skb)->pkt_type = HCI_VENDOR_PKT;
141
142 *skb_put(skb, 1) = 0xff;
143 *skb_put(skb, 1) = dev_type;
144 put_unaligned_le16(hdev->id, skb_put(skb, 2));
145 skb_queue_tail(&data->readq, skb);
146
147 wake_up_interruptible(&data->read_wait);
103 return 0; 148 return 0;
104} 149}
105 150
106static inline ssize_t vhci_get_user(struct vhci_data *data, 151static inline ssize_t vhci_get_user(struct vhci_data *data,
107 const char __user *buf, size_t count) 152 const char __user *buf, size_t count)
108{ 153{
109 struct sk_buff *skb; 154 struct sk_buff *skb;
155 __u8 pkt_type, dev_type;
156 int ret;
110 157
111 if (count > HCI_MAX_FRAME_SIZE) 158 if (count < 2 || count > HCI_MAX_FRAME_SIZE)
112 return -EINVAL; 159 return -EINVAL;
113 160
114 skb = bt_skb_alloc(count, GFP_KERNEL); 161 skb = bt_skb_alloc(count, GFP_KERNEL);
@@ -120,27 +167,70 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
120 return -EFAULT; 167 return -EFAULT;
121 } 168 }
122 169
123 skb->dev = (void *) data->hdev; 170 pkt_type = *((__u8 *) skb->data);
124 bt_cb(skb)->pkt_type = *((__u8 *) skb->data);
125 skb_pull(skb, 1); 171 skb_pull(skb, 1);
126 172
127 hci_recv_frame(skb); 173 switch (pkt_type) {
174 case HCI_EVENT_PKT:
175 case HCI_ACLDATA_PKT:
176 case HCI_SCODATA_PKT:
177 if (!data->hdev) {
178 kfree_skb(skb);
179 return -ENODEV;
180 }
181
182 skb->dev = (void *) data->hdev;
183 bt_cb(skb)->pkt_type = pkt_type;
184
185 ret = hci_recv_frame(skb);
186 break;
187
188 case HCI_VENDOR_PKT:
189 if (data->hdev) {
190 kfree_skb(skb);
191 return -EBADFD;
192 }
128 193
129 return count; 194 cancel_delayed_work_sync(&data->open_timeout);
195
196 dev_type = *((__u8 *) skb->data);
197 skb_pull(skb, 1);
198
199 if (skb->len > 0) {
200 kfree_skb(skb);
201 return -EINVAL;
202 }
203
204 kfree_skb(skb);
205
206 if (dev_type != HCI_BREDR && dev_type != HCI_AMP)
207 return -EINVAL;
208
209 ret = vhci_create_device(data, dev_type);
210 break;
211
212 default:
213 kfree_skb(skb);
214 return -EINVAL;
215 }
216
217 return (ret < 0) ? ret : count;
130} 218}
131 219
132static inline ssize_t vhci_put_user(struct vhci_data *data, 220static inline ssize_t vhci_put_user(struct vhci_data *data,
133 struct sk_buff *skb, char __user *buf, int count) 221 struct sk_buff *skb,
222 char __user *buf, int count)
134{ 223{
135 char __user *ptr = buf; 224 char __user *ptr = buf;
136 int len, total = 0; 225 int len;
137 226
138 len = min_t(unsigned int, skb->len, count); 227 len = min_t(unsigned int, skb->len, count);
139 228
140 if (copy_to_user(ptr, skb->data, len)) 229 if (copy_to_user(ptr, skb->data, len))
141 return -EFAULT; 230 return -EFAULT;
142 231
143 total += len; 232 if (!data->hdev)
233 return len;
144 234
145 data->hdev->stat.byte_tx += len; 235 data->hdev->stat.byte_tx += len;
146 236
@@ -148,21 +238,19 @@ static inline ssize_t vhci_put_user(struct vhci_data *data,
148 case HCI_COMMAND_PKT: 238 case HCI_COMMAND_PKT:
149 data->hdev->stat.cmd_tx++; 239 data->hdev->stat.cmd_tx++;
150 break; 240 break;
151
152 case HCI_ACLDATA_PKT: 241 case HCI_ACLDATA_PKT:
153 data->hdev->stat.acl_tx++; 242 data->hdev->stat.acl_tx++;
154 break; 243 break;
155
156 case HCI_SCODATA_PKT: 244 case HCI_SCODATA_PKT:
157 data->hdev->stat.sco_tx++; 245 data->hdev->stat.sco_tx++;
158 break; 246 break;
159 } 247 }
160 248
161 return total; 249 return len;
162} 250}
163 251
164static ssize_t vhci_read(struct file *file, 252static ssize_t vhci_read(struct file *file,
165 char __user *buf, size_t count, loff_t *pos) 253 char __user *buf, size_t count, loff_t *pos)
166{ 254{
167 struct vhci_data *data = file->private_data; 255 struct vhci_data *data = file->private_data;
168 struct sk_buff *skb; 256 struct sk_buff *skb;
@@ -185,7 +273,7 @@ static ssize_t vhci_read(struct file *file,
185 } 273 }
186 274
187 ret = wait_event_interruptible(data->read_wait, 275 ret = wait_event_interruptible(data->read_wait,
188 !skb_queue_empty(&data->readq)); 276 !skb_queue_empty(&data->readq));
189 if (ret < 0) 277 if (ret < 0)
190 break; 278 break;
191 } 279 }
@@ -194,7 +282,7 @@ static ssize_t vhci_read(struct file *file,
194} 282}
195 283
196static ssize_t vhci_write(struct file *file, 284static ssize_t vhci_write(struct file *file,
197 const char __user *buf, size_t count, loff_t *pos) 285 const char __user *buf, size_t count, loff_t *pos)
198{ 286{
199 struct vhci_data *data = file->private_data; 287 struct vhci_data *data = file->private_data;
200 288
@@ -213,10 +301,17 @@ static unsigned int vhci_poll(struct file *file, poll_table *wait)
213 return POLLOUT | POLLWRNORM; 301 return POLLOUT | POLLWRNORM;
214} 302}
215 303
304static void vhci_open_timeout(struct work_struct *work)
305{
306 struct vhci_data *data = container_of(work, struct vhci_data,
307 open_timeout.work);
308
309 vhci_create_device(data, amp ? HCI_AMP : HCI_BREDR);
310}
311
216static int vhci_open(struct inode *inode, struct file *file) 312static int vhci_open(struct inode *inode, struct file *file)
217{ 313{
218 struct vhci_data *data; 314 struct vhci_data *data;
219 struct hci_dev *hdev;
220 315
221 data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); 316 data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL);
222 if (!data) 317 if (!data)
@@ -225,35 +320,13 @@ static int vhci_open(struct inode *inode, struct file *file)
225 skb_queue_head_init(&data->readq); 320 skb_queue_head_init(&data->readq);
226 init_waitqueue_head(&data->read_wait); 321 init_waitqueue_head(&data->read_wait);
227 322
228 hdev = hci_alloc_dev(); 323 INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout);
229 if (!hdev) {
230 kfree(data);
231 return -ENOMEM;
232 }
233
234 data->hdev = hdev;
235
236 hdev->bus = HCI_VIRTUAL;
237 hci_set_drvdata(hdev, data);
238
239 if (amp)
240 hdev->dev_type = HCI_AMP;
241
242 hdev->open = vhci_open_dev;
243 hdev->close = vhci_close_dev;
244 hdev->flush = vhci_flush;
245 hdev->send = vhci_send_frame;
246
247 if (hci_register_dev(hdev) < 0) {
248 BT_ERR("Can't register HCI device");
249 kfree(data);
250 hci_free_dev(hdev);
251 return -EBUSY;
252 }
253 324
254 file->private_data = data; 325 file->private_data = data;
255 nonseekable_open(inode, file); 326 nonseekable_open(inode, file);
256 327
328 schedule_delayed_work(&data->open_timeout, msecs_to_jiffies(1000));
329
257 return 0; 330 return 0;
258} 331}
259 332
@@ -262,8 +335,12 @@ static int vhci_release(struct inode *inode, struct file *file)
262 struct vhci_data *data = file->private_data; 335 struct vhci_data *data = file->private_data;
263 struct hci_dev *hdev = data->hdev; 336 struct hci_dev *hdev = data->hdev;
264 337
265 hci_unregister_dev(hdev); 338 cancel_delayed_work_sync(&data->open_timeout);
266 hci_free_dev(hdev); 339
340 if (hdev) {
341 hci_unregister_dev(hdev);
342 hci_free_dev(hdev);
343 }
267 344
268 file->private_data = NULL; 345 file->private_data = NULL;
269 kfree(data); 346 kfree(data);
@@ -309,3 +386,4 @@ MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
309MODULE_DESCRIPTION("Bluetooth virtual HCI driver ver " VERSION); 386MODULE_DESCRIPTION("Bluetooth virtual HCI driver ver " VERSION);
310MODULE_VERSION(VERSION); 387MODULE_VERSION(VERSION);
311MODULE_LICENSE("GPL"); 388MODULE_LICENSE("GPL");
389MODULE_ALIAS("devname:vhci");
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 796dbb212a41..8492b68e873c 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -177,7 +177,7 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast,
177 177
178static inline void ast_open_key(struct ast_private *ast) 178static inline void ast_open_key(struct ast_private *ast)
179{ 179{
180 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xA1, 0xFF, 0x04); 180 ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x80, 0xA8);
181} 181}
182 182
183#define AST_VIDMEM_SIZE_8M 0x00800000 183#define AST_VIDMEM_SIZE_8M 0x00800000
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 3d13ca6e257f..f6f6cc7fc133 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -416,6 +416,14 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
416 return; 416 return;
417 417
418 /* 418 /*
419 * fbdev->blank can be called from irq context in case of a panic.
420 * Since we already have our own special panic handler which will
421 * restore the fbdev console mode completely, just bail out early.
422 */
423 if (oops_in_progress)
424 return;
425
426 /*
419 * For each CRTC in this fb, turn the connectors on/off. 427 * For each CRTC in this fb, turn the connectors on/off.
420 */ 428 */
421 drm_modeset_lock_all(dev); 429 drm_modeset_lock_all(dev);
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
index 2e11ea02cf87..57cda2a1437b 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/init.c
@@ -579,8 +579,22 @@ static void
579init_reserved(struct nvbios_init *init) 579init_reserved(struct nvbios_init *init)
580{ 580{
581 u8 opcode = nv_ro08(init->bios, init->offset); 581 u8 opcode = nv_ro08(init->bios, init->offset);
582 trace("RESERVED\t0x%02x\n", opcode); 582 u8 length, i;
583 init->offset += 1; 583
584 switch (opcode) {
585 case 0xaa:
586 length = 4;
587 break;
588 default:
589 length = 1;
590 break;
591 }
592
593 trace("RESERVED 0x%02x\t", opcode);
594 for (i = 1; i < length; i++)
595 cont(" 0x%02x", nv_ro08(init->bios, init->offset + i));
596 cont("\n");
597 init->offset += length;
584} 598}
585 599
586/** 600/**
@@ -1437,7 +1451,7 @@ init_configure_mem(struct nvbios_init *init)
1437 data = init_rdvgai(init, 0x03c4, 0x01); 1451 data = init_rdvgai(init, 0x03c4, 0x01);
1438 init_wrvgai(init, 0x03c4, 0x01, data | 0x20); 1452 init_wrvgai(init, 0x03c4, 0x01, data | 0x20);
1439 1453
1440 while ((addr = nv_ro32(bios, sdata)) != 0xffffffff) { 1454 for (; (addr = nv_ro32(bios, sdata)) != 0xffffffff; sdata += 4) {
1441 switch (addr) { 1455 switch (addr) {
1442 case 0x10021c: /* CKE_NORMAL */ 1456 case 0x10021c: /* CKE_NORMAL */
1443 case 0x1002d0: /* CMD_REFRESH */ 1457 case 0x1002d0: /* CMD_REFRESH */
@@ -2135,6 +2149,7 @@ static struct nvbios_init_opcode {
2135 [0x99] = { init_zm_auxch }, 2149 [0x99] = { init_zm_auxch },
2136 [0x9a] = { init_i2c_long_if }, 2150 [0x9a] = { init_i2c_long_if },
2137 [0xa9] = { init_gpio_ne }, 2151 [0xa9] = { init_gpio_ne },
2152 [0xaa] = { init_reserved },
2138}; 2153};
2139 2154
2140#define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0])) 2155#define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0]))
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index d2712e6e5d31..7848590f5568 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -278,7 +278,6 @@ nouveau_display_create(struct drm_device *dev)
278{ 278{
279 struct nouveau_drm *drm = nouveau_drm(dev); 279 struct nouveau_drm *drm = nouveau_drm(dev);
280 struct nouveau_display *disp; 280 struct nouveau_display *disp;
281 u32 pclass = dev->pdev->class >> 8;
282 int ret, gen; 281 int ret, gen;
283 282
284 disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL); 283 disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL);
@@ -340,29 +339,25 @@ nouveau_display_create(struct drm_device *dev)
340 drm_kms_helper_poll_init(dev); 339 drm_kms_helper_poll_init(dev);
341 drm_kms_helper_poll_disable(dev); 340 drm_kms_helper_poll_disable(dev);
342 341
343 if (nouveau_modeset == 1 || 342 if (drm->vbios.dcb.entries) {
344 (nouveau_modeset < 0 && pclass == PCI_CLASS_DISPLAY_VGA)) { 343 if (nv_device(drm->device)->card_type < NV_50)
345 if (drm->vbios.dcb.entries) { 344 ret = nv04_display_create(dev);
346 if (nv_device(drm->device)->card_type < NV_50) 345 else
347 ret = nv04_display_create(dev); 346 ret = nv50_display_create(dev);
348 else 347 } else {
349 ret = nv50_display_create(dev); 348 ret = 0;
350 } else { 349 }
351 ret = 0;
352 }
353
354 if (ret)
355 goto disp_create_err;
356 350
357 if (dev->mode_config.num_crtc) { 351 if (ret)
358 ret = drm_vblank_init(dev, dev->mode_config.num_crtc); 352 goto disp_create_err;
359 if (ret)
360 goto vblank_err;
361 }
362 353
363 nouveau_backlight_init(dev); 354 if (dev->mode_config.num_crtc) {
355 ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
356 if (ret)
357 goto vblank_err;
364 } 358 }
365 359
360 nouveau_backlight_init(dev);
366 return 0; 361 return 0;
367 362
368vblank_err: 363vblank_err:
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 8f6d63d7edd3..a86ecf65c164 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -454,7 +454,8 @@ nouveau_fbcon_init(struct drm_device *dev)
454 int preferred_bpp; 454 int preferred_bpp;
455 int ret; 455 int ret;
456 456
457 if (!dev->mode_config.num_crtc) 457 if (!dev->mode_config.num_crtc ||
458 (dev->pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
458 return 0; 459 return 0;
459 460
460 fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL); 461 fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL);
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index ca5492ac2da5..0843ebc910d4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -104,9 +104,7 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
104 else 104 else
105 nvbe->ttm.ttm.func = &nv50_sgdma_backend; 105 nvbe->ttm.ttm.func = &nv50_sgdma_backend;
106 106
107 if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) { 107 if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
108 kfree(nvbe);
109 return NULL; 108 return NULL;
110 }
111 return &nvbe->ttm.ttm; 109 return &nvbe->ttm.ttm;
112} 110}
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index dfac7965ea28..32923d2f6002 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -707,8 +707,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
707 switch (connector->connector_type) { 707 switch (connector->connector_type) {
708 case DRM_MODE_CONNECTOR_DVII: 708 case DRM_MODE_CONNECTOR_DVII:
709 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */ 709 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */
710 if (drm_detect_hdmi_monitor(radeon_connector->edid) && 710 if ((radeon_connector->audio == RADEON_AUDIO_ENABLE) ||
711 radeon_audio) 711 (drm_detect_hdmi_monitor(radeon_connector->edid) &&
712 (radeon_connector->audio == RADEON_AUDIO_AUTO)))
712 return ATOM_ENCODER_MODE_HDMI; 713 return ATOM_ENCODER_MODE_HDMI;
713 else if (radeon_connector->use_digital) 714 else if (radeon_connector->use_digital)
714 return ATOM_ENCODER_MODE_DVI; 715 return ATOM_ENCODER_MODE_DVI;
@@ -718,8 +719,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
718 case DRM_MODE_CONNECTOR_DVID: 719 case DRM_MODE_CONNECTOR_DVID:
719 case DRM_MODE_CONNECTOR_HDMIA: 720 case DRM_MODE_CONNECTOR_HDMIA:
720 default: 721 default:
721 if (drm_detect_hdmi_monitor(radeon_connector->edid) && 722 if ((radeon_connector->audio == RADEON_AUDIO_ENABLE) ||
722 radeon_audio) 723 (drm_detect_hdmi_monitor(radeon_connector->edid) &&
724 (radeon_connector->audio == RADEON_AUDIO_AUTO)))
723 return ATOM_ENCODER_MODE_HDMI; 725 return ATOM_ENCODER_MODE_HDMI;
724 else 726 else
725 return ATOM_ENCODER_MODE_DVI; 727 return ATOM_ENCODER_MODE_DVI;
@@ -732,8 +734,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
732 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 734 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
733 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) 735 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
734 return ATOM_ENCODER_MODE_DP; 736 return ATOM_ENCODER_MODE_DP;
735 else if (drm_detect_hdmi_monitor(radeon_connector->edid) && 737 else if ((radeon_connector->audio == RADEON_AUDIO_ENABLE) ||
736 radeon_audio) 738 (drm_detect_hdmi_monitor(radeon_connector->edid) &&
739 (radeon_connector->audio == RADEON_AUDIO_AUTO)))
737 return ATOM_ENCODER_MODE_HDMI; 740 return ATOM_ENCODER_MODE_HDMI;
738 else 741 else
739 return ATOM_ENCODER_MODE_DVI; 742 return ATOM_ENCODER_MODE_DVI;
@@ -1647,8 +1650,12 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1647 atombios_dig_encoder_setup(encoder, ATOM_ENABLE, 0); 1650 atombios_dig_encoder_setup(encoder, ATOM_ENABLE, 0);
1648 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); 1651 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0);
1649 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); 1652 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1650 /* some early dce3.2 boards have a bug in their transmitter control table */ 1653 /* some dce3.x boards have a bug in their transmitter control table.
1651 if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730)) 1654 * ACTION_ENABLE_OUTPUT can probably be dropped since ACTION_ENABLE
1655 * does the same thing and more.
1656 */
1657 if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730) &&
1658 (rdev->family != CHIP_RS880))
1652 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); 1659 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1653 } 1660 }
1654 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { 1661 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c
index 084e69414fd1..05ff315e8e9e 100644
--- a/drivers/gpu/drm/radeon/btc_dpm.c
+++ b/drivers/gpu/drm/radeon/btc_dpm.c
@@ -2340,12 +2340,6 @@ int btc_dpm_set_power_state(struct radeon_device *rdev)
2340 return ret; 2340 return ret;
2341 } 2341 }
2342 2342
2343 ret = rv770_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
2344 if (ret) {
2345 DRM_ERROR("rv770_dpm_force_performance_level failed\n");
2346 return ret;
2347 }
2348
2349 return 0; 2343 return 0;
2350} 2344}
2351 2345
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index 3cce533397c6..899627443030 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -4748,12 +4748,6 @@ int ci_dpm_set_power_state(struct radeon_device *rdev)
4748 if (pi->pcie_performance_request) 4748 if (pi->pcie_performance_request)
4749 ci_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); 4749 ci_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
4750 4750
4751 ret = ci_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
4752 if (ret) {
4753 DRM_ERROR("ci_dpm_force_performance_level failed\n");
4754 return ret;
4755 }
4756
4757 cik_update_cg(rdev, (RADEON_CG_BLOCK_GFX | 4751 cik_update_cg(rdev, (RADEON_CG_BLOCK_GFX |
4758 RADEON_CG_BLOCK_MC | 4752 RADEON_CG_BLOCK_MC |
4759 RADEON_CG_BLOCK_SDMA | 4753 RADEON_CG_BLOCK_SDMA |
diff --git a/drivers/gpu/drm/radeon/ci_smc.c b/drivers/gpu/drm/radeon/ci_smc.c
index 53b43dd3cf1e..252e10a41cf5 100644
--- a/drivers/gpu/drm/radeon/ci_smc.c
+++ b/drivers/gpu/drm/radeon/ci_smc.c
@@ -47,10 +47,11 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev,
47 u32 smc_start_address, 47 u32 smc_start_address,
48 const u8 *src, u32 byte_count, u32 limit) 48 const u8 *src, u32 byte_count, u32 limit)
49{ 49{
50 unsigned long flags;
50 u32 data, original_data; 51 u32 data, original_data;
51 u32 addr; 52 u32 addr;
52 u32 extra_shift; 53 u32 extra_shift;
53 int ret; 54 int ret = 0;
54 55
55 if (smc_start_address & 3) 56 if (smc_start_address & 3)
56 return -EINVAL; 57 return -EINVAL;
@@ -59,13 +60,14 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev,
59 60
60 addr = smc_start_address; 61 addr = smc_start_address;
61 62
63 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
62 while (byte_count >= 4) { 64 while (byte_count >= 4) {
63 /* SMC address space is BE */ 65 /* SMC address space is BE */
64 data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; 66 data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
65 67
66 ret = ci_set_smc_sram_address(rdev, addr, limit); 68 ret = ci_set_smc_sram_address(rdev, addr, limit);
67 if (ret) 69 if (ret)
68 return ret; 70 goto done;
69 71
70 WREG32(SMC_IND_DATA_0, data); 72 WREG32(SMC_IND_DATA_0, data);
71 73
@@ -80,7 +82,7 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev,
80 82
81 ret = ci_set_smc_sram_address(rdev, addr, limit); 83 ret = ci_set_smc_sram_address(rdev, addr, limit);
82 if (ret) 84 if (ret)
83 return ret; 85 goto done;
84 86
85 original_data = RREG32(SMC_IND_DATA_0); 87 original_data = RREG32(SMC_IND_DATA_0);
86 88
@@ -97,11 +99,15 @@ int ci_copy_bytes_to_smc(struct radeon_device *rdev,
97 99
98 ret = ci_set_smc_sram_address(rdev, addr, limit); 100 ret = ci_set_smc_sram_address(rdev, addr, limit);
99 if (ret) 101 if (ret)
100 return ret; 102 goto done;
101 103
102 WREG32(SMC_IND_DATA_0, data); 104 WREG32(SMC_IND_DATA_0, data);
103 } 105 }
104 return 0; 106
107done:
108 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
109
110 return ret;
105} 111}
106 112
107void ci_start_smc(struct radeon_device *rdev) 113void ci_start_smc(struct radeon_device *rdev)
@@ -197,6 +203,7 @@ PPSMC_Result ci_wait_for_smc_inactive(struct radeon_device *rdev)
197 203
198int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit) 204int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit)
199{ 205{
206 unsigned long flags;
200 u32 ucode_start_address; 207 u32 ucode_start_address;
201 u32 ucode_size; 208 u32 ucode_size;
202 const u8 *src; 209 const u8 *src;
@@ -219,6 +226,7 @@ int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit)
219 return -EINVAL; 226 return -EINVAL;
220 227
221 src = (const u8 *)rdev->smc_fw->data; 228 src = (const u8 *)rdev->smc_fw->data;
229 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
222 WREG32(SMC_IND_INDEX_0, ucode_start_address); 230 WREG32(SMC_IND_INDEX_0, ucode_start_address);
223 WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); 231 WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0);
224 while (ucode_size >= 4) { 232 while (ucode_size >= 4) {
@@ -231,6 +239,7 @@ int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit)
231 ucode_size -= 4; 239 ucode_size -= 4;
232 } 240 }
233 WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); 241 WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0);
242 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
234 243
235 return 0; 244 return 0;
236} 245}
@@ -238,25 +247,29 @@ int ci_load_smc_ucode(struct radeon_device *rdev, u32 limit)
238int ci_read_smc_sram_dword(struct radeon_device *rdev, 247int ci_read_smc_sram_dword(struct radeon_device *rdev,
239 u32 smc_address, u32 *value, u32 limit) 248 u32 smc_address, u32 *value, u32 limit)
240{ 249{
250 unsigned long flags;
241 int ret; 251 int ret;
242 252
253 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
243 ret = ci_set_smc_sram_address(rdev, smc_address, limit); 254 ret = ci_set_smc_sram_address(rdev, smc_address, limit);
244 if (ret) 255 if (ret == 0)
245 return ret; 256 *value = RREG32(SMC_IND_DATA_0);
257 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
246 258
247 *value = RREG32(SMC_IND_DATA_0); 259 return ret;
248 return 0;
249} 260}
250 261
251int ci_write_smc_sram_dword(struct radeon_device *rdev, 262int ci_write_smc_sram_dword(struct radeon_device *rdev,
252 u32 smc_address, u32 value, u32 limit) 263 u32 smc_address, u32 value, u32 limit)
253{ 264{
265 unsigned long flags;
254 int ret; 266 int ret;
255 267
268 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
256 ret = ci_set_smc_sram_address(rdev, smc_address, limit); 269 ret = ci_set_smc_sram_address(rdev, smc_address, limit);
257 if (ret) 270 if (ret == 0)
258 return ret; 271 WREG32(SMC_IND_DATA_0, value);
272 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
259 273
260 WREG32(SMC_IND_DATA_0, value); 274 return ret;
261 return 0;
262} 275}
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index a3bba0587276..adbdb6503b05 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -77,6 +77,8 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev);
77static void cik_program_aspm(struct radeon_device *rdev); 77static void cik_program_aspm(struct radeon_device *rdev);
78static void cik_init_pg(struct radeon_device *rdev); 78static void cik_init_pg(struct radeon_device *rdev);
79static void cik_init_cg(struct radeon_device *rdev); 79static void cik_init_cg(struct radeon_device *rdev);
80static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev,
81 bool enable);
80 82
81/* get temperature in millidegrees */ 83/* get temperature in millidegrees */
82int ci_get_temp(struct radeon_device *rdev) 84int ci_get_temp(struct radeon_device *rdev)
@@ -120,20 +122,27 @@ int kv_get_temp(struct radeon_device *rdev)
120 */ 122 */
121u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg) 123u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg)
122{ 124{
125 unsigned long flags;
123 u32 r; 126 u32 r;
124 127
128 spin_lock_irqsave(&rdev->pciep_idx_lock, flags);
125 WREG32(PCIE_INDEX, reg); 129 WREG32(PCIE_INDEX, reg);
126 (void)RREG32(PCIE_INDEX); 130 (void)RREG32(PCIE_INDEX);
127 r = RREG32(PCIE_DATA); 131 r = RREG32(PCIE_DATA);
132 spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags);
128 return r; 133 return r;
129} 134}
130 135
131void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) 136void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v)
132{ 137{
138 unsigned long flags;
139
140 spin_lock_irqsave(&rdev->pciep_idx_lock, flags);
133 WREG32(PCIE_INDEX, reg); 141 WREG32(PCIE_INDEX, reg);
134 (void)RREG32(PCIE_INDEX); 142 (void)RREG32(PCIE_INDEX);
135 WREG32(PCIE_DATA, v); 143 WREG32(PCIE_DATA, v);
136 (void)RREG32(PCIE_DATA); 144 (void)RREG32(PCIE_DATA);
145 spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags);
137} 146}
138 147
139static const u32 spectre_rlc_save_restore_register_list[] = 148static const u32 spectre_rlc_save_restore_register_list[] =
@@ -2722,7 +2731,8 @@ static void cik_gpu_init(struct radeon_device *rdev)
2722 } else if ((rdev->pdev->device == 0x1309) || 2731 } else if ((rdev->pdev->device == 0x1309) ||
2723 (rdev->pdev->device == 0x130A) || 2732 (rdev->pdev->device == 0x130A) ||
2724 (rdev->pdev->device == 0x130D) || 2733 (rdev->pdev->device == 0x130D) ||
2725 (rdev->pdev->device == 0x1313)) { 2734 (rdev->pdev->device == 0x1313) ||
2735 (rdev->pdev->device == 0x131D)) {
2726 rdev->config.cik.max_cu_per_sh = 6; 2736 rdev->config.cik.max_cu_per_sh = 6;
2727 rdev->config.cik.max_backends_per_se = 2; 2737 rdev->config.cik.max_backends_per_se = 2;
2728 } else if ((rdev->pdev->device == 0x1306) || 2738 } else if ((rdev->pdev->device == 0x1306) ||
@@ -4013,6 +4023,8 @@ static int cik_cp_resume(struct radeon_device *rdev)
4013{ 4023{
4014 int r; 4024 int r;
4015 4025
4026 cik_enable_gui_idle_interrupt(rdev, false);
4027
4016 r = cik_cp_load_microcode(rdev); 4028 r = cik_cp_load_microcode(rdev);
4017 if (r) 4029 if (r)
4018 return r; 4030 return r;
@@ -4024,6 +4036,8 @@ static int cik_cp_resume(struct radeon_device *rdev)
4024 if (r) 4036 if (r)
4025 return r; 4037 return r;
4026 4038
4039 cik_enable_gui_idle_interrupt(rdev, true);
4040
4027 return 0; 4041 return 0;
4028} 4042}
4029 4043
@@ -5376,7 +5390,9 @@ static void cik_enable_hdp_ls(struct radeon_device *rdev,
5376void cik_update_cg(struct radeon_device *rdev, 5390void cik_update_cg(struct radeon_device *rdev,
5377 u32 block, bool enable) 5391 u32 block, bool enable)
5378{ 5392{
5393
5379 if (block & RADEON_CG_BLOCK_GFX) { 5394 if (block & RADEON_CG_BLOCK_GFX) {
5395 cik_enable_gui_idle_interrupt(rdev, false);
5380 /* order matters! */ 5396 /* order matters! */
5381 if (enable) { 5397 if (enable) {
5382 cik_enable_mgcg(rdev, true); 5398 cik_enable_mgcg(rdev, true);
@@ -5385,6 +5401,7 @@ void cik_update_cg(struct radeon_device *rdev,
5385 cik_enable_cgcg(rdev, false); 5401 cik_enable_cgcg(rdev, false);
5386 cik_enable_mgcg(rdev, false); 5402 cik_enable_mgcg(rdev, false);
5387 } 5403 }
5404 cik_enable_gui_idle_interrupt(rdev, true);
5388 } 5405 }
5389 5406
5390 if (block & RADEON_CG_BLOCK_MC) { 5407 if (block & RADEON_CG_BLOCK_MC) {
@@ -5541,7 +5558,7 @@ static void cik_enable_gfx_cgpg(struct radeon_device *rdev,
5541{ 5558{
5542 u32 data, orig; 5559 u32 data, orig;
5543 5560
5544 if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG)) { 5561 if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG)) {
5545 orig = data = RREG32(RLC_PG_CNTL); 5562 orig = data = RREG32(RLC_PG_CNTL);
5546 data |= GFX_PG_ENABLE; 5563 data |= GFX_PG_ENABLE;
5547 if (orig != data) 5564 if (orig != data)
@@ -5805,7 +5822,7 @@ static void cik_init_pg(struct radeon_device *rdev)
5805 if (rdev->pg_flags) { 5822 if (rdev->pg_flags) {
5806 cik_enable_sck_slowdown_on_pu(rdev, true); 5823 cik_enable_sck_slowdown_on_pu(rdev, true);
5807 cik_enable_sck_slowdown_on_pd(rdev, true); 5824 cik_enable_sck_slowdown_on_pd(rdev, true);
5808 if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG) { 5825 if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) {
5809 cik_init_gfx_cgpg(rdev); 5826 cik_init_gfx_cgpg(rdev);
5810 cik_enable_cp_pg(rdev, true); 5827 cik_enable_cp_pg(rdev, true);
5811 cik_enable_gds_pg(rdev, true); 5828 cik_enable_gds_pg(rdev, true);
@@ -5819,7 +5836,7 @@ static void cik_fini_pg(struct radeon_device *rdev)
5819{ 5836{
5820 if (rdev->pg_flags) { 5837 if (rdev->pg_flags) {
5821 cik_update_gfx_pg(rdev, false); 5838 cik_update_gfx_pg(rdev, false);
5822 if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG) { 5839 if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) {
5823 cik_enable_cp_pg(rdev, false); 5840 cik_enable_cp_pg(rdev, false);
5824 cik_enable_gds_pg(rdev, false); 5841 cik_enable_gds_pg(rdev, false);
5825 } 5842 }
@@ -5895,7 +5912,9 @@ static void cik_disable_interrupt_state(struct radeon_device *rdev)
5895 u32 tmp; 5912 u32 tmp;
5896 5913
5897 /* gfx ring */ 5914 /* gfx ring */
5898 WREG32(CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); 5915 tmp = RREG32(CP_INT_CNTL_RING0) &
5916 (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE);
5917 WREG32(CP_INT_CNTL_RING0, tmp);
5899 /* sdma */ 5918 /* sdma */
5900 tmp = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; 5919 tmp = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE;
5901 WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, tmp); 5920 WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, tmp);
@@ -6036,8 +6055,7 @@ static int cik_irq_init(struct radeon_device *rdev)
6036 */ 6055 */
6037int cik_irq_set(struct radeon_device *rdev) 6056int cik_irq_set(struct radeon_device *rdev)
6038{ 6057{
6039 u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE | 6058 u32 cp_int_cntl;
6040 PRIV_INSTR_INT_ENABLE | PRIV_REG_INT_ENABLE;
6041 u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3; 6059 u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3;
6042 u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3; 6060 u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3;
6043 u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; 6061 u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0;
@@ -6058,6 +6076,10 @@ int cik_irq_set(struct radeon_device *rdev)
6058 return 0; 6076 return 0;
6059 } 6077 }
6060 6078
6079 cp_int_cntl = RREG32(CP_INT_CNTL_RING0) &
6080 (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE);
6081 cp_int_cntl |= PRIV_INSTR_INT_ENABLE | PRIV_REG_INT_ENABLE;
6082
6061 hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; 6083 hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN;
6062 hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; 6084 hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN;
6063 hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; 6085 hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN;
diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c
index 95a66db08d9b..91bb470de0a3 100644
--- a/drivers/gpu/drm/radeon/cypress_dpm.c
+++ b/drivers/gpu/drm/radeon/cypress_dpm.c
@@ -2014,12 +2014,6 @@ int cypress_dpm_set_power_state(struct radeon_device *rdev)
2014 if (eg_pi->pcie_performance_request) 2014 if (eg_pi->pcie_performance_request)
2015 cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); 2015 cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
2016 2016
2017 ret = rv770_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
2018 if (ret) {
2019 DRM_ERROR("rv770_dpm_force_performance_level failed\n");
2020 return ret;
2021 }
2022
2023 return 0; 2017 return 0;
2024} 2018}
2025 2019
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c
index 8953255e894b..85a69d2ea3d2 100644
--- a/drivers/gpu/drm/radeon/dce6_afmt.c
+++ b/drivers/gpu/drm/radeon/dce6_afmt.c
@@ -28,22 +28,30 @@
28static u32 dce6_endpoint_rreg(struct radeon_device *rdev, 28static u32 dce6_endpoint_rreg(struct radeon_device *rdev,
29 u32 block_offset, u32 reg) 29 u32 block_offset, u32 reg)
30{ 30{
31 unsigned long flags;
31 u32 r; 32 u32 r;
32 33
34 spin_lock_irqsave(&rdev->end_idx_lock, flags);
33 WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); 35 WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg);
34 r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset); 36 r = RREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset);
37 spin_unlock_irqrestore(&rdev->end_idx_lock, flags);
38
35 return r; 39 return r;
36} 40}
37 41
38static void dce6_endpoint_wreg(struct radeon_device *rdev, 42static void dce6_endpoint_wreg(struct radeon_device *rdev,
39 u32 block_offset, u32 reg, u32 v) 43 u32 block_offset, u32 reg, u32 v)
40{ 44{
45 unsigned long flags;
46
47 spin_lock_irqsave(&rdev->end_idx_lock, flags);
41 if (ASIC_IS_DCE8(rdev)) 48 if (ASIC_IS_DCE8(rdev))
42 WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg); 49 WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, reg);
43 else 50 else
44 WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset, 51 WREG32(AZ_F0_CODEC_ENDPOINT_INDEX + block_offset,
45 AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg)); 52 AZ_ENDPOINT_REG_WRITE_EN | AZ_ENDPOINT_REG_INDEX(reg));
46 WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v); 53 WREG32(AZ_F0_CODEC_ENDPOINT_DATA + block_offset, v);
54 spin_unlock_irqrestore(&rdev->end_idx_lock, flags);
47} 55}
48 56
49#define RREG32_ENDPOINT(block, reg) dce6_endpoint_rreg(rdev, (block), (reg)) 57#define RREG32_ENDPOINT(block, reg) dce6_endpoint_rreg(rdev, (block), (reg))
@@ -86,12 +94,12 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder)
86 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 94 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
87 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 95 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
88 u32 offset = dig->afmt->offset; 96 u32 offset = dig->afmt->offset;
89 u32 id = dig->afmt->pin->id;
90 97
91 if (!dig->afmt->pin) 98 if (!dig->afmt->pin)
92 return; 99 return;
93 100
94 WREG32(AFMT_AUDIO_SRC_CONTROL + offset, AFMT_AUDIO_SRC_SELECT(id)); 101 WREG32(AFMT_AUDIO_SRC_CONTROL + offset,
102 AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id));
95} 103}
96 104
97void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) 105void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index ecd60809db4e..71399065db04 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -40,6 +40,7 @@ static int kv_calculate_dpm_settings(struct radeon_device *rdev);
40static void kv_enable_new_levels(struct radeon_device *rdev); 40static void kv_enable_new_levels(struct radeon_device *rdev);
41static void kv_program_nbps_index_settings(struct radeon_device *rdev, 41static void kv_program_nbps_index_settings(struct radeon_device *rdev,
42 struct radeon_ps *new_rps); 42 struct radeon_ps *new_rps);
43static int kv_set_enabled_level(struct radeon_device *rdev, u32 level);
43static int kv_set_enabled_levels(struct radeon_device *rdev); 44static int kv_set_enabled_levels(struct radeon_device *rdev);
44static int kv_force_dpm_highest(struct radeon_device *rdev); 45static int kv_force_dpm_highest(struct radeon_device *rdev);
45static int kv_force_dpm_lowest(struct radeon_device *rdev); 46static int kv_force_dpm_lowest(struct radeon_device *rdev);
@@ -519,7 +520,7 @@ static int kv_set_dpm_boot_state(struct radeon_device *rdev)
519 520
520static void kv_program_vc(struct radeon_device *rdev) 521static void kv_program_vc(struct radeon_device *rdev)
521{ 522{
522 WREG32_SMC(CG_FTV_0, 0x3FFFC000); 523 WREG32_SMC(CG_FTV_0, 0x3FFFC100);
523} 524}
524 525
525static void kv_clear_vc(struct radeon_device *rdev) 526static void kv_clear_vc(struct radeon_device *rdev)
@@ -638,7 +639,10 @@ static int kv_force_lowest_valid(struct radeon_device *rdev)
638 639
639static int kv_unforce_levels(struct radeon_device *rdev) 640static int kv_unforce_levels(struct radeon_device *rdev)
640{ 641{
641 return kv_notify_message_to_smu(rdev, PPSMC_MSG_NoForcedLevel); 642 if (rdev->family == CHIP_KABINI)
643 return kv_notify_message_to_smu(rdev, PPSMC_MSG_NoForcedLevel);
644 else
645 return kv_set_enabled_levels(rdev);
642} 646}
643 647
644static int kv_update_sclk_t(struct radeon_device *rdev) 648static int kv_update_sclk_t(struct radeon_device *rdev)
@@ -667,9 +671,8 @@ static int kv_program_bootup_state(struct radeon_device *rdev)
667 &rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk; 671 &rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk;
668 672
669 if (table && table->count) { 673 if (table && table->count) {
670 for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { 674 for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) {
671 if ((table->entries[i].clk == pi->boot_pl.sclk) || 675 if (table->entries[i].clk == pi->boot_pl.sclk)
672 (i == 0))
673 break; 676 break;
674 } 677 }
675 678
@@ -682,9 +685,8 @@ static int kv_program_bootup_state(struct radeon_device *rdev)
682 if (table->num_max_dpm_entries == 0) 685 if (table->num_max_dpm_entries == 0)
683 return -EINVAL; 686 return -EINVAL;
684 687
685 for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { 688 for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) {
686 if ((table->entries[i].sclk_frequency == pi->boot_pl.sclk) || 689 if (table->entries[i].sclk_frequency == pi->boot_pl.sclk)
687 (i == 0))
688 break; 690 break;
689 } 691 }
690 692
@@ -1078,6 +1080,13 @@ static int kv_enable_ulv(struct radeon_device *rdev, bool enable)
1078 PPSMC_MSG_EnableULV : PPSMC_MSG_DisableULV); 1080 PPSMC_MSG_EnableULV : PPSMC_MSG_DisableULV);
1079} 1081}
1080 1082
1083static void kv_reset_acp_boot_level(struct radeon_device *rdev)
1084{
1085 struct kv_power_info *pi = kv_get_pi(rdev);
1086
1087 pi->acp_boot_level = 0xff;
1088}
1089
1081static void kv_update_current_ps(struct radeon_device *rdev, 1090static void kv_update_current_ps(struct radeon_device *rdev,
1082 struct radeon_ps *rps) 1091 struct radeon_ps *rps)
1083{ 1092{
@@ -1100,6 +1109,18 @@ static void kv_update_requested_ps(struct radeon_device *rdev,
1100 pi->requested_rps.ps_priv = &pi->requested_ps; 1109 pi->requested_rps.ps_priv = &pi->requested_ps;
1101} 1110}
1102 1111
1112void kv_dpm_enable_bapm(struct radeon_device *rdev, bool enable)
1113{
1114 struct kv_power_info *pi = kv_get_pi(rdev);
1115 int ret;
1116
1117 if (pi->bapm_enable) {
1118 ret = kv_smc_bapm_enable(rdev, enable);
1119 if (ret)
1120 DRM_ERROR("kv_smc_bapm_enable failed\n");
1121 }
1122}
1123
1103int kv_dpm_enable(struct radeon_device *rdev) 1124int kv_dpm_enable(struct radeon_device *rdev)
1104{ 1125{
1105 struct kv_power_info *pi = kv_get_pi(rdev); 1126 struct kv_power_info *pi = kv_get_pi(rdev);
@@ -1192,6 +1213,8 @@ int kv_dpm_enable(struct radeon_device *rdev)
1192 return ret; 1213 return ret;
1193 } 1214 }
1194 1215
1216 kv_reset_acp_boot_level(rdev);
1217
1195 if (rdev->irq.installed && 1218 if (rdev->irq.installed &&
1196 r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) { 1219 r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) {
1197 ret = kv_set_thermal_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX); 1220 ret = kv_set_thermal_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
@@ -1203,6 +1226,12 @@ int kv_dpm_enable(struct radeon_device *rdev)
1203 radeon_irq_set(rdev); 1226 radeon_irq_set(rdev);
1204 } 1227 }
1205 1228
1229 ret = kv_smc_bapm_enable(rdev, false);
1230 if (ret) {
1231 DRM_ERROR("kv_smc_bapm_enable failed\n");
1232 return ret;
1233 }
1234
1206 /* powerdown unused blocks for now */ 1235 /* powerdown unused blocks for now */
1207 kv_dpm_powergate_acp(rdev, true); 1236 kv_dpm_powergate_acp(rdev, true);
1208 kv_dpm_powergate_samu(rdev, true); 1237 kv_dpm_powergate_samu(rdev, true);
@@ -1226,6 +1255,8 @@ void kv_dpm_disable(struct radeon_device *rdev)
1226 RADEON_CG_BLOCK_BIF | 1255 RADEON_CG_BLOCK_BIF |
1227 RADEON_CG_BLOCK_HDP), false); 1256 RADEON_CG_BLOCK_HDP), false);
1228 1257
1258 kv_smc_bapm_enable(rdev, false);
1259
1229 /* powerup blocks */ 1260 /* powerup blocks */
1230 kv_dpm_powergate_acp(rdev, false); 1261 kv_dpm_powergate_acp(rdev, false);
1231 kv_dpm_powergate_samu(rdev, false); 1262 kv_dpm_powergate_samu(rdev, false);
@@ -1450,6 +1481,39 @@ static int kv_update_samu_dpm(struct radeon_device *rdev, bool gate)
1450 return kv_enable_samu_dpm(rdev, !gate); 1481 return kv_enable_samu_dpm(rdev, !gate);
1451} 1482}
1452 1483
1484static u8 kv_get_acp_boot_level(struct radeon_device *rdev)
1485{
1486 u8 i;
1487 struct radeon_clock_voltage_dependency_table *table =
1488 &rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table;
1489
1490 for (i = 0; i < table->count; i++) {
1491 if (table->entries[i].clk >= 0) /* XXX */
1492 break;
1493 }
1494
1495 if (i >= table->count)
1496 i = table->count - 1;
1497
1498 return i;
1499}
1500
1501static void kv_update_acp_boot_level(struct radeon_device *rdev)
1502{
1503 struct kv_power_info *pi = kv_get_pi(rdev);
1504 u8 acp_boot_level;
1505
1506 if (!pi->caps_stable_p_state) {
1507 acp_boot_level = kv_get_acp_boot_level(rdev);
1508 if (acp_boot_level != pi->acp_boot_level) {
1509 pi->acp_boot_level = acp_boot_level;
1510 kv_send_msg_to_smc_with_parameter(rdev,
1511 PPSMC_MSG_ACPDPM_SetEnabledMask,
1512 (1 << pi->acp_boot_level));
1513 }
1514 }
1515}
1516
1453static int kv_update_acp_dpm(struct radeon_device *rdev, bool gate) 1517static int kv_update_acp_dpm(struct radeon_device *rdev, bool gate)
1454{ 1518{
1455 struct kv_power_info *pi = kv_get_pi(rdev); 1519 struct kv_power_info *pi = kv_get_pi(rdev);
@@ -1461,7 +1525,7 @@ static int kv_update_acp_dpm(struct radeon_device *rdev, bool gate)
1461 if (pi->caps_stable_p_state) 1525 if (pi->caps_stable_p_state)
1462 pi->acp_boot_level = table->count - 1; 1526 pi->acp_boot_level = table->count - 1;
1463 else 1527 else
1464 pi->acp_boot_level = 0; 1528 pi->acp_boot_level = kv_get_acp_boot_level(rdev);
1465 1529
1466 ret = kv_copy_bytes_to_smc(rdev, 1530 ret = kv_copy_bytes_to_smc(rdev,
1467 pi->dpm_table_start + 1531 pi->dpm_table_start +
@@ -1588,13 +1652,11 @@ static void kv_set_valid_clock_range(struct radeon_device *rdev,
1588 } 1652 }
1589 } 1653 }
1590 1654
1591 for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { 1655 for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) {
1592 if ((table->entries[i].clk <= new_ps->levels[new_ps->num_levels -1].sclk) || 1656 if (table->entries[i].clk <= new_ps->levels[new_ps->num_levels - 1].sclk)
1593 (i == 0)) {
1594 pi->highest_valid = i;
1595 break; 1657 break;
1596 }
1597 } 1658 }
1659 pi->highest_valid = i;
1598 1660
1599 if (pi->lowest_valid > pi->highest_valid) { 1661 if (pi->lowest_valid > pi->highest_valid) {
1600 if ((new_ps->levels[0].sclk - table->entries[pi->highest_valid].clk) > 1662 if ((new_ps->levels[0].sclk - table->entries[pi->highest_valid].clk) >
@@ -1615,14 +1677,12 @@ static void kv_set_valid_clock_range(struct radeon_device *rdev,
1615 } 1677 }
1616 } 1678 }
1617 1679
1618 for (i = pi->graphics_dpm_level_count - 1; i >= 0; i--) { 1680 for (i = pi->graphics_dpm_level_count - 1; i > 0; i--) {
1619 if (table->entries[i].sclk_frequency <= 1681 if (table->entries[i].sclk_frequency <=
1620 new_ps->levels[new_ps->num_levels - 1].sclk || 1682 new_ps->levels[new_ps->num_levels - 1].sclk)
1621 i == 0) {
1622 pi->highest_valid = i;
1623 break; 1683 break;
1624 }
1625 } 1684 }
1685 pi->highest_valid = i;
1626 1686
1627 if (pi->lowest_valid > pi->highest_valid) { 1687 if (pi->lowest_valid > pi->highest_valid) {
1628 if ((new_ps->levels[0].sclk - 1688 if ((new_ps->levels[0].sclk -
@@ -1724,6 +1784,14 @@ int kv_dpm_set_power_state(struct radeon_device *rdev)
1724 RADEON_CG_BLOCK_BIF | 1784 RADEON_CG_BLOCK_BIF |
1725 RADEON_CG_BLOCK_HDP), false); 1785 RADEON_CG_BLOCK_HDP), false);
1726 1786
1787 if (pi->bapm_enable) {
1788 ret = kv_smc_bapm_enable(rdev, rdev->pm.dpm.ac_power);
1789 if (ret) {
1790 DRM_ERROR("kv_smc_bapm_enable failed\n");
1791 return ret;
1792 }
1793 }
1794
1727 if (rdev->family == CHIP_KABINI) { 1795 if (rdev->family == CHIP_KABINI) {
1728 if (pi->enable_dpm) { 1796 if (pi->enable_dpm) {
1729 kv_set_valid_clock_range(rdev, new_ps); 1797 kv_set_valid_clock_range(rdev, new_ps);
@@ -1775,6 +1843,7 @@ int kv_dpm_set_power_state(struct radeon_device *rdev)
1775 return ret; 1843 return ret;
1776 } 1844 }
1777#endif 1845#endif
1846 kv_update_acp_boot_level(rdev);
1778 kv_update_sclk_t(rdev); 1847 kv_update_sclk_t(rdev);
1779 kv_enable_nb_dpm(rdev); 1848 kv_enable_nb_dpm(rdev);
1780 } 1849 }
@@ -1785,7 +1854,6 @@ int kv_dpm_set_power_state(struct radeon_device *rdev)
1785 RADEON_CG_BLOCK_BIF | 1854 RADEON_CG_BLOCK_BIF |
1786 RADEON_CG_BLOCK_HDP), true); 1855 RADEON_CG_BLOCK_HDP), true);
1787 1856
1788 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
1789 return 0; 1857 return 0;
1790} 1858}
1791 1859
@@ -1806,12 +1874,23 @@ void kv_dpm_setup_asic(struct radeon_device *rdev)
1806 1874
1807void kv_dpm_reset_asic(struct radeon_device *rdev) 1875void kv_dpm_reset_asic(struct radeon_device *rdev)
1808{ 1876{
1809 kv_force_lowest_valid(rdev); 1877 struct kv_power_info *pi = kv_get_pi(rdev);
1810 kv_init_graphics_levels(rdev); 1878
1811 kv_program_bootup_state(rdev); 1879 if (rdev->family == CHIP_KABINI) {
1812 kv_upload_dpm_settings(rdev); 1880 kv_force_lowest_valid(rdev);
1813 kv_force_lowest_valid(rdev); 1881 kv_init_graphics_levels(rdev);
1814 kv_unforce_levels(rdev); 1882 kv_program_bootup_state(rdev);
1883 kv_upload_dpm_settings(rdev);
1884 kv_force_lowest_valid(rdev);
1885 kv_unforce_levels(rdev);
1886 } else {
1887 kv_init_graphics_levels(rdev);
1888 kv_program_bootup_state(rdev);
1889 kv_freeze_sclk_dpm(rdev, true);
1890 kv_upload_dpm_settings(rdev);
1891 kv_freeze_sclk_dpm(rdev, false);
1892 kv_set_enabled_level(rdev, pi->graphics_boot_level);
1893 }
1815} 1894}
1816 1895
1817//XXX use sumo_dpm_display_configuration_changed 1896//XXX use sumo_dpm_display_configuration_changed
@@ -1871,12 +1950,15 @@ static int kv_force_dpm_highest(struct radeon_device *rdev)
1871 if (ret) 1950 if (ret)
1872 return ret; 1951 return ret;
1873 1952
1874 for (i = SMU7_MAX_LEVELS_GRAPHICS - 1; i >= 0; i--) { 1953 for (i = SMU7_MAX_LEVELS_GRAPHICS - 1; i > 0; i--) {
1875 if (enable_mask & (1 << i)) 1954 if (enable_mask & (1 << i))
1876 break; 1955 break;
1877 } 1956 }
1878 1957
1879 return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i); 1958 if (rdev->family == CHIP_KABINI)
1959 return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i);
1960 else
1961 return kv_set_enabled_level(rdev, i);
1880} 1962}
1881 1963
1882static int kv_force_dpm_lowest(struct radeon_device *rdev) 1964static int kv_force_dpm_lowest(struct radeon_device *rdev)
@@ -1893,7 +1975,10 @@ static int kv_force_dpm_lowest(struct radeon_device *rdev)
1893 break; 1975 break;
1894 } 1976 }
1895 1977
1896 return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i); 1978 if (rdev->family == CHIP_KABINI)
1979 return kv_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_DPM_ForceState, i);
1980 else
1981 return kv_set_enabled_level(rdev, i);
1897} 1982}
1898 1983
1899static u8 kv_get_sleep_divider_id_from_clock(struct radeon_device *rdev, 1984static u8 kv_get_sleep_divider_id_from_clock(struct radeon_device *rdev,
@@ -1911,9 +1996,9 @@ static u8 kv_get_sleep_divider_id_from_clock(struct radeon_device *rdev,
1911 if (!pi->caps_sclk_ds) 1996 if (!pi->caps_sclk_ds)
1912 return 0; 1997 return 0;
1913 1998
1914 for (i = KV_MAX_DEEPSLEEP_DIVIDER_ID; i <= 0; i--) { 1999 for (i = KV_MAX_DEEPSLEEP_DIVIDER_ID; i > 0; i--) {
1915 temp = sclk / sumo_get_sleep_divider_from_id(i); 2000 temp = sclk / sumo_get_sleep_divider_from_id(i);
1916 if ((temp >= min) || (i == 0)) 2001 if (temp >= min)
1917 break; 2002 break;
1918 } 2003 }
1919 2004
@@ -2039,12 +2124,12 @@ static void kv_apply_state_adjust_rules(struct radeon_device *rdev,
2039 ps->dpmx_nb_ps_lo = 0x1; 2124 ps->dpmx_nb_ps_lo = 0x1;
2040 ps->dpmx_nb_ps_hi = 0x0; 2125 ps->dpmx_nb_ps_hi = 0x0;
2041 } else { 2126 } else {
2042 ps->dpm0_pg_nb_ps_lo = 0x1; 2127 ps->dpm0_pg_nb_ps_lo = 0x3;
2043 ps->dpm0_pg_nb_ps_hi = 0x0; 2128 ps->dpm0_pg_nb_ps_hi = 0x0;
2044 ps->dpmx_nb_ps_lo = 0x2; 2129 ps->dpmx_nb_ps_lo = 0x3;
2045 ps->dpmx_nb_ps_hi = 0x1; 2130 ps->dpmx_nb_ps_hi = 0x0;
2046 2131
2047 if (pi->sys_info.nb_dpm_enable && pi->battery_state) { 2132 if (pi->sys_info.nb_dpm_enable) {
2048 force_high = (mclk >= pi->sys_info.nbp_memory_clock[3]) || 2133 force_high = (mclk >= pi->sys_info.nbp_memory_clock[3]) ||
2049 pi->video_start || (rdev->pm.dpm.new_active_crtc_count >= 3) || 2134 pi->video_start || (rdev->pm.dpm.new_active_crtc_count >= 3) ||
2050 pi->disable_nb_ps3_in_battery; 2135 pi->disable_nb_ps3_in_battery;
@@ -2210,6 +2295,15 @@ static void kv_enable_new_levels(struct radeon_device *rdev)
2210 } 2295 }
2211} 2296}
2212 2297
2298static int kv_set_enabled_level(struct radeon_device *rdev, u32 level)
2299{
2300 u32 new_mask = (1 << level);
2301
2302 return kv_send_msg_to_smc_with_parameter(rdev,
2303 PPSMC_MSG_SCLKDPM_SetEnabledMask,
2304 new_mask);
2305}
2306
2213static int kv_set_enabled_levels(struct radeon_device *rdev) 2307static int kv_set_enabled_levels(struct radeon_device *rdev)
2214{ 2308{
2215 struct kv_power_info *pi = kv_get_pi(rdev); 2309 struct kv_power_info *pi = kv_get_pi(rdev);
diff --git a/drivers/gpu/drm/radeon/kv_dpm.h b/drivers/gpu/drm/radeon/kv_dpm.h
index 32bb079572d7..8cef7525d7a8 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.h
+++ b/drivers/gpu/drm/radeon/kv_dpm.h
@@ -192,6 +192,7 @@ int kv_send_msg_to_smc_with_parameter(struct radeon_device *rdev,
192int kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, 192int kv_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address,
193 u32 *value, u32 limit); 193 u32 *value, u32 limit);
194int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable); 194int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable);
195int kv_smc_bapm_enable(struct radeon_device *rdev, bool enable);
195int kv_copy_bytes_to_smc(struct radeon_device *rdev, 196int kv_copy_bytes_to_smc(struct radeon_device *rdev,
196 u32 smc_start_address, 197 u32 smc_start_address,
197 const u8 *src, u32 byte_count, u32 limit); 198 const u8 *src, u32 byte_count, u32 limit);
diff --git a/drivers/gpu/drm/radeon/kv_smc.c b/drivers/gpu/drm/radeon/kv_smc.c
index 34a226d7e34a..0000b59a6d05 100644
--- a/drivers/gpu/drm/radeon/kv_smc.c
+++ b/drivers/gpu/drm/radeon/kv_smc.c
@@ -107,6 +107,14 @@ int kv_smc_dpm_enable(struct radeon_device *rdev, bool enable)
107 return kv_notify_message_to_smu(rdev, PPSMC_MSG_DPM_Disable); 107 return kv_notify_message_to_smu(rdev, PPSMC_MSG_DPM_Disable);
108} 108}
109 109
110int kv_smc_bapm_enable(struct radeon_device *rdev, bool enable)
111{
112 if (enable)
113 return kv_notify_message_to_smu(rdev, PPSMC_MSG_EnableBAPM);
114 else
115 return kv_notify_message_to_smu(rdev, PPSMC_MSG_DisableBAPM);
116}
117
110int kv_copy_bytes_to_smc(struct radeon_device *rdev, 118int kv_copy_bytes_to_smc(struct radeon_device *rdev,
111 u32 smc_start_address, 119 u32 smc_start_address,
112 const u8 *src, u32 byte_count, u32 limit) 120 const u8 *src, u32 byte_count, u32 limit)
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index f7b625c9e0e9..6c398a456d78 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -3865,12 +3865,6 @@ int ni_dpm_set_power_state(struct radeon_device *rdev)
3865 return ret; 3865 return ret;
3866 } 3866 }
3867 3867
3868 ret = ni_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
3869 if (ret) {
3870 DRM_ERROR("ni_dpm_force_performance_level failed\n");
3871 return ret;
3872 }
3873
3874 return 0; 3868 return 0;
3875} 3869}
3876 3870
diff --git a/drivers/gpu/drm/radeon/ppsmc.h b/drivers/gpu/drm/radeon/ppsmc.h
index 682842804bce..5670b8291285 100644
--- a/drivers/gpu/drm/radeon/ppsmc.h
+++ b/drivers/gpu/drm/radeon/ppsmc.h
@@ -163,6 +163,8 @@ typedef uint8_t PPSMC_Result;
163#define PPSMC_MSG_VCEPowerON ((uint32_t) 0x10f) 163#define PPSMC_MSG_VCEPowerON ((uint32_t) 0x10f)
164#define PPSMC_MSG_DCE_RemoveVoltageAdjustment ((uint32_t) 0x11d) 164#define PPSMC_MSG_DCE_RemoveVoltageAdjustment ((uint32_t) 0x11d)
165#define PPSMC_MSG_DCE_AllowVoltageAdjustment ((uint32_t) 0x11e) 165#define PPSMC_MSG_DCE_AllowVoltageAdjustment ((uint32_t) 0x11e)
166#define PPSMC_MSG_EnableBAPM ((uint32_t) 0x120)
167#define PPSMC_MSG_DisableBAPM ((uint32_t) 0x121)
166#define PPSMC_MSG_UVD_DPM_Config ((uint32_t) 0x124) 168#define PPSMC_MSG_UVD_DPM_Config ((uint32_t) 0x124)
167 169
168 170
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 9fc61dd68bc0..24175717307b 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2853,21 +2853,28 @@ static void r100_pll_errata_after_data(struct radeon_device *rdev)
2853 2853
2854uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg) 2854uint32_t r100_pll_rreg(struct radeon_device *rdev, uint32_t reg)
2855{ 2855{
2856 unsigned long flags;
2856 uint32_t data; 2857 uint32_t data;
2857 2858
2859 spin_lock_irqsave(&rdev->pll_idx_lock, flags);
2858 WREG8(RADEON_CLOCK_CNTL_INDEX, reg & 0x3f); 2860 WREG8(RADEON_CLOCK_CNTL_INDEX, reg & 0x3f);
2859 r100_pll_errata_after_index(rdev); 2861 r100_pll_errata_after_index(rdev);
2860 data = RREG32(RADEON_CLOCK_CNTL_DATA); 2862 data = RREG32(RADEON_CLOCK_CNTL_DATA);
2861 r100_pll_errata_after_data(rdev); 2863 r100_pll_errata_after_data(rdev);
2864 spin_unlock_irqrestore(&rdev->pll_idx_lock, flags);
2862 return data; 2865 return data;
2863} 2866}
2864 2867
2865void r100_pll_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 2868void r100_pll_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
2866{ 2869{
2870 unsigned long flags;
2871
2872 spin_lock_irqsave(&rdev->pll_idx_lock, flags);
2867 WREG8(RADEON_CLOCK_CNTL_INDEX, ((reg & 0x3f) | RADEON_PLL_WR_EN)); 2873 WREG8(RADEON_CLOCK_CNTL_INDEX, ((reg & 0x3f) | RADEON_PLL_WR_EN));
2868 r100_pll_errata_after_index(rdev); 2874 r100_pll_errata_after_index(rdev);
2869 WREG32(RADEON_CLOCK_CNTL_DATA, v); 2875 WREG32(RADEON_CLOCK_CNTL_DATA, v);
2870 r100_pll_errata_after_data(rdev); 2876 r100_pll_errata_after_data(rdev);
2877 spin_unlock_irqrestore(&rdev->pll_idx_lock, flags);
2871} 2878}
2872 2879
2873static void r100_set_safe_registers(struct radeon_device *rdev) 2880static void r100_set_safe_registers(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 4e796ecf9ea4..6edf2b3a52b4 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -160,18 +160,25 @@ void r420_pipes_init(struct radeon_device *rdev)
160 160
161u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg) 161u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg)
162{ 162{
163 unsigned long flags;
163 u32 r; 164 u32 r;
164 165
166 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
165 WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg)); 167 WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg));
166 r = RREG32(R_0001FC_MC_IND_DATA); 168 r = RREG32(R_0001FC_MC_IND_DATA);
169 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
167 return r; 170 return r;
168} 171}
169 172
170void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v) 173void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v)
171{ 174{
175 unsigned long flags;
176
177 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
172 WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg) | 178 WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg) |
173 S_0001F8_MC_IND_WR_EN(1)); 179 S_0001F8_MC_IND_WR_EN(1));
174 WREG32(R_0001FC_MC_IND_DATA, v); 180 WREG32(R_0001FC_MC_IND_DATA, v);
181 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
175} 182}
176 183
177static void r420_debugfs(struct radeon_device *rdev) 184static void r420_debugfs(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index ea4d3734e6d9..2a1b1876b431 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -119,6 +119,11 @@ u32 r600_get_xclk(struct radeon_device *rdev)
119 return rdev->clock.spll.reference_freq; 119 return rdev->clock.spll.reference_freq;
120} 120}
121 121
122int r600_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk)
123{
124 return 0;
125}
126
122/* get temperature in millidegrees */ 127/* get temperature in millidegrees */
123int rv6xx_get_temp(struct radeon_device *rdev) 128int rv6xx_get_temp(struct radeon_device *rdev)
124{ 129{
@@ -1045,20 +1050,27 @@ int r600_mc_wait_for_idle(struct radeon_device *rdev)
1045 1050
1046uint32_t rs780_mc_rreg(struct radeon_device *rdev, uint32_t reg) 1051uint32_t rs780_mc_rreg(struct radeon_device *rdev, uint32_t reg)
1047{ 1052{
1053 unsigned long flags;
1048 uint32_t r; 1054 uint32_t r;
1049 1055
1056 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
1050 WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg)); 1057 WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg));
1051 r = RREG32(R_0028FC_MC_DATA); 1058 r = RREG32(R_0028FC_MC_DATA);
1052 WREG32(R_0028F8_MC_INDEX, ~C_0028F8_MC_IND_ADDR); 1059 WREG32(R_0028F8_MC_INDEX, ~C_0028F8_MC_IND_ADDR);
1060 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
1053 return r; 1061 return r;
1054} 1062}
1055 1063
1056void rs780_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 1064void rs780_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
1057{ 1065{
1066 unsigned long flags;
1067
1068 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
1058 WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg) | 1069 WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg) |
1059 S_0028F8_MC_IND_WR_EN(1)); 1070 S_0028F8_MC_IND_WR_EN(1));
1060 WREG32(R_0028FC_MC_DATA, v); 1071 WREG32(R_0028FC_MC_DATA, v);
1061 WREG32(R_0028F8_MC_INDEX, 0x7F); 1072 WREG32(R_0028F8_MC_INDEX, 0x7F);
1073 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
1062} 1074}
1063 1075
1064static void r600_mc_program(struct radeon_device *rdev) 1076static void r600_mc_program(struct radeon_device *rdev)
@@ -2092,20 +2104,27 @@ static void r600_gpu_init(struct radeon_device *rdev)
2092 */ 2104 */
2093u32 r600_pciep_rreg(struct radeon_device *rdev, u32 reg) 2105u32 r600_pciep_rreg(struct radeon_device *rdev, u32 reg)
2094{ 2106{
2107 unsigned long flags;
2095 u32 r; 2108 u32 r;
2096 2109
2110 spin_lock_irqsave(&rdev->pciep_idx_lock, flags);
2097 WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 2111 WREG32(PCIE_PORT_INDEX, ((reg) & 0xff));
2098 (void)RREG32(PCIE_PORT_INDEX); 2112 (void)RREG32(PCIE_PORT_INDEX);
2099 r = RREG32(PCIE_PORT_DATA); 2113 r = RREG32(PCIE_PORT_DATA);
2114 spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags);
2100 return r; 2115 return r;
2101} 2116}
2102 2117
2103void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2118void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2104{ 2119{
2120 unsigned long flags;
2121
2122 spin_lock_irqsave(&rdev->pciep_idx_lock, flags);
2105 WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); 2123 WREG32(PCIE_PORT_INDEX, ((reg) & 0xff));
2106 (void)RREG32(PCIE_PORT_INDEX); 2124 (void)RREG32(PCIE_PORT_INDEX);
2107 WREG32(PCIE_PORT_DATA, (v)); 2125 WREG32(PCIE_PORT_DATA, (v));
2108 (void)RREG32(PCIE_PORT_DATA); 2126 (void)RREG32(PCIE_PORT_DATA);
2127 spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags);
2109} 2128}
2110 2129
2111/* 2130/*
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index fa0de46fcc0d..e65f211a7be0 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -1219,30 +1219,20 @@ int r600_parse_extended_power_table(struct radeon_device *rdev)
1219 1219
1220void r600_free_extended_power_table(struct radeon_device *rdev) 1220void r600_free_extended_power_table(struct radeon_device *rdev)
1221{ 1221{
1222 if (rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries) 1222 struct radeon_dpm_dynamic_state *dyn_state = &rdev->pm.dpm.dyn_state;
1223 kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries); 1223
1224 if (rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk.entries) 1224 kfree(dyn_state->vddc_dependency_on_sclk.entries);
1225 kfree(rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk.entries); 1225 kfree(dyn_state->vddci_dependency_on_mclk.entries);
1226 if (rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk.entries) 1226 kfree(dyn_state->vddc_dependency_on_mclk.entries);
1227 kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk.entries); 1227 kfree(dyn_state->mvdd_dependency_on_mclk.entries);
1228 if (rdev->pm.dpm.dyn_state.mvdd_dependency_on_mclk.entries) 1228 kfree(dyn_state->cac_leakage_table.entries);
1229 kfree(rdev->pm.dpm.dyn_state.mvdd_dependency_on_mclk.entries); 1229 kfree(dyn_state->phase_shedding_limits_table.entries);
1230 if (rdev->pm.dpm.dyn_state.cac_leakage_table.entries) 1230 kfree(dyn_state->ppm_table);
1231 kfree(rdev->pm.dpm.dyn_state.cac_leakage_table.entries); 1231 kfree(dyn_state->cac_tdp_table);
1232 if (rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) 1232 kfree(dyn_state->vce_clock_voltage_dependency_table.entries);
1233 kfree(rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries); 1233 kfree(dyn_state->uvd_clock_voltage_dependency_table.entries);
1234 if (rdev->pm.dpm.dyn_state.ppm_table) 1234 kfree(dyn_state->samu_clock_voltage_dependency_table.entries);
1235 kfree(rdev->pm.dpm.dyn_state.ppm_table); 1235 kfree(dyn_state->acp_clock_voltage_dependency_table.entries);
1236 if (rdev->pm.dpm.dyn_state.cac_tdp_table)
1237 kfree(rdev->pm.dpm.dyn_state.cac_tdp_table);
1238 if (rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries)
1239 kfree(rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table.entries);
1240 if (rdev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries)
1241 kfree(rdev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table.entries);
1242 if (rdev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries)
1243 kfree(rdev->pm.dpm.dyn_state.samu_clock_voltage_dependency_table.entries);
1244 if (rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries)
1245 kfree(rdev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table.entries);
1246} 1236}
1247 1237
1248enum radeon_pcie_gen r600_get_pcie_gen_support(struct radeon_device *rdev, 1238enum radeon_pcie_gen r600_get_pcie_gen_support(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 454f90a849e4..e673fe26ea84 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -1040,7 +1040,7 @@
1040# define HDMI0_AVI_INFO_CONT (1 << 1) 1040# define HDMI0_AVI_INFO_CONT (1 << 1)
1041# define HDMI0_AUDIO_INFO_SEND (1 << 4) 1041# define HDMI0_AUDIO_INFO_SEND (1 << 4)
1042# define HDMI0_AUDIO_INFO_CONT (1 << 5) 1042# define HDMI0_AUDIO_INFO_CONT (1 << 5)
1043# define HDMI0_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hmdi regs */ 1043# define HDMI0_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hdmi regs */
1044# define HDMI0_AUDIO_INFO_UPDATE (1 << 7) 1044# define HDMI0_AUDIO_INFO_UPDATE (1 << 7)
1045# define HDMI0_MPEG_INFO_SEND (1 << 8) 1045# define HDMI0_MPEG_INFO_SEND (1 << 8)
1046# define HDMI0_MPEG_INFO_CONT (1 << 9) 1046# define HDMI0_MPEG_INFO_CONT (1 << 9)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index ff8b564ce2b2..a400ac1c4147 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -181,7 +181,7 @@ extern int radeon_aspm;
181#define RADEON_CG_SUPPORT_HDP_MGCG (1 << 16) 181#define RADEON_CG_SUPPORT_HDP_MGCG (1 << 16)
182 182
183/* PG flags */ 183/* PG flags */
184#define RADEON_PG_SUPPORT_GFX_CG (1 << 0) 184#define RADEON_PG_SUPPORT_GFX_PG (1 << 0)
185#define RADEON_PG_SUPPORT_GFX_SMG (1 << 1) 185#define RADEON_PG_SUPPORT_GFX_SMG (1 << 1)
186#define RADEON_PG_SUPPORT_GFX_DMG (1 << 2) 186#define RADEON_PG_SUPPORT_GFX_DMG (1 << 2)
187#define RADEON_PG_SUPPORT_UVD (1 << 3) 187#define RADEON_PG_SUPPORT_UVD (1 << 3)
@@ -1778,6 +1778,7 @@ struct radeon_asic {
1778 int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level); 1778 int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level);
1779 bool (*vblank_too_short)(struct radeon_device *rdev); 1779 bool (*vblank_too_short)(struct radeon_device *rdev);
1780 void (*powergate_uvd)(struct radeon_device *rdev, bool gate); 1780 void (*powergate_uvd)(struct radeon_device *rdev, bool gate);
1781 void (*enable_bapm)(struct radeon_device *rdev, bool enable);
1781 } dpm; 1782 } dpm;
1782 /* pageflipping */ 1783 /* pageflipping */
1783 struct { 1784 struct {
@@ -2110,6 +2111,28 @@ struct radeon_device {
2110 resource_size_t rmmio_size; 2111 resource_size_t rmmio_size;
2111 /* protects concurrent MM_INDEX/DATA based register access */ 2112 /* protects concurrent MM_INDEX/DATA based register access */
2112 spinlock_t mmio_idx_lock; 2113 spinlock_t mmio_idx_lock;
2114 /* protects concurrent SMC based register access */
2115 spinlock_t smc_idx_lock;
2116 /* protects concurrent PLL register access */
2117 spinlock_t pll_idx_lock;
2118 /* protects concurrent MC register access */
2119 spinlock_t mc_idx_lock;
2120 /* protects concurrent PCIE register access */
2121 spinlock_t pcie_idx_lock;
2122 /* protects concurrent PCIE_PORT register access */
2123 spinlock_t pciep_idx_lock;
2124 /* protects concurrent PIF register access */
2125 spinlock_t pif_idx_lock;
2126 /* protects concurrent CG register access */
2127 spinlock_t cg_idx_lock;
2128 /* protects concurrent UVD register access */
2129 spinlock_t uvd_idx_lock;
2130 /* protects concurrent RCU register access */
2131 spinlock_t rcu_idx_lock;
2132 /* protects concurrent DIDT register access */
2133 spinlock_t didt_idx_lock;
2134 /* protects concurrent ENDPOINT (audio) register access */
2135 spinlock_t end_idx_lock;
2113 void __iomem *rmmio; 2136 void __iomem *rmmio;
2114 radeon_rreg_t mc_rreg; 2137 radeon_rreg_t mc_rreg;
2115 radeon_wreg_t mc_wreg; 2138 radeon_wreg_t mc_wreg;
@@ -2277,123 +2300,179 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v);
2277 */ 2300 */
2278static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) 2301static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
2279{ 2302{
2303 unsigned long flags;
2280 uint32_t r; 2304 uint32_t r;
2281 2305
2306 spin_lock_irqsave(&rdev->pcie_idx_lock, flags);
2282 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); 2307 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
2283 r = RREG32(RADEON_PCIE_DATA); 2308 r = RREG32(RADEON_PCIE_DATA);
2309 spin_unlock_irqrestore(&rdev->pcie_idx_lock, flags);
2284 return r; 2310 return r;
2285} 2311}
2286 2312
2287static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 2313static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
2288{ 2314{
2315 unsigned long flags;
2316
2317 spin_lock_irqsave(&rdev->pcie_idx_lock, flags);
2289 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); 2318 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
2290 WREG32(RADEON_PCIE_DATA, (v)); 2319 WREG32(RADEON_PCIE_DATA, (v));
2320 spin_unlock_irqrestore(&rdev->pcie_idx_lock, flags);
2291} 2321}
2292 2322
2293static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg) 2323static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg)
2294{ 2324{
2325 unsigned long flags;
2295 u32 r; 2326 u32 r;
2296 2327
2328 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
2297 WREG32(TN_SMC_IND_INDEX_0, (reg)); 2329 WREG32(TN_SMC_IND_INDEX_0, (reg));
2298 r = RREG32(TN_SMC_IND_DATA_0); 2330 r = RREG32(TN_SMC_IND_DATA_0);
2331 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
2299 return r; 2332 return r;
2300} 2333}
2301 2334
2302static inline void tn_smc_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2335static inline void tn_smc_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2303{ 2336{
2337 unsigned long flags;
2338
2339 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
2304 WREG32(TN_SMC_IND_INDEX_0, (reg)); 2340 WREG32(TN_SMC_IND_INDEX_0, (reg));
2305 WREG32(TN_SMC_IND_DATA_0, (v)); 2341 WREG32(TN_SMC_IND_DATA_0, (v));
2342 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
2306} 2343}
2307 2344
2308static inline u32 r600_rcu_rreg(struct radeon_device *rdev, u32 reg) 2345static inline u32 r600_rcu_rreg(struct radeon_device *rdev, u32 reg)
2309{ 2346{
2347 unsigned long flags;
2310 u32 r; 2348 u32 r;
2311 2349
2350 spin_lock_irqsave(&rdev->rcu_idx_lock, flags);
2312 WREG32(R600_RCU_INDEX, ((reg) & 0x1fff)); 2351 WREG32(R600_RCU_INDEX, ((reg) & 0x1fff));
2313 r = RREG32(R600_RCU_DATA); 2352 r = RREG32(R600_RCU_DATA);
2353 spin_unlock_irqrestore(&rdev->rcu_idx_lock, flags);
2314 return r; 2354 return r;
2315} 2355}
2316 2356
2317static inline void r600_rcu_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2357static inline void r600_rcu_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2318{ 2358{
2359 unsigned long flags;
2360
2361 spin_lock_irqsave(&rdev->rcu_idx_lock, flags);
2319 WREG32(R600_RCU_INDEX, ((reg) & 0x1fff)); 2362 WREG32(R600_RCU_INDEX, ((reg) & 0x1fff));
2320 WREG32(R600_RCU_DATA, (v)); 2363 WREG32(R600_RCU_DATA, (v));
2364 spin_unlock_irqrestore(&rdev->rcu_idx_lock, flags);
2321} 2365}
2322 2366
2323static inline u32 eg_cg_rreg(struct radeon_device *rdev, u32 reg) 2367static inline u32 eg_cg_rreg(struct radeon_device *rdev, u32 reg)
2324{ 2368{
2369 unsigned long flags;
2325 u32 r; 2370 u32 r;
2326 2371
2372 spin_lock_irqsave(&rdev->cg_idx_lock, flags);
2327 WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff)); 2373 WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff));
2328 r = RREG32(EVERGREEN_CG_IND_DATA); 2374 r = RREG32(EVERGREEN_CG_IND_DATA);
2375 spin_unlock_irqrestore(&rdev->cg_idx_lock, flags);
2329 return r; 2376 return r;
2330} 2377}
2331 2378
2332static inline void eg_cg_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2379static inline void eg_cg_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2333{ 2380{
2381 unsigned long flags;
2382
2383 spin_lock_irqsave(&rdev->cg_idx_lock, flags);
2334 WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff)); 2384 WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff));
2335 WREG32(EVERGREEN_CG_IND_DATA, (v)); 2385 WREG32(EVERGREEN_CG_IND_DATA, (v));
2386 spin_unlock_irqrestore(&rdev->cg_idx_lock, flags);
2336} 2387}
2337 2388
2338static inline u32 eg_pif_phy0_rreg(struct radeon_device *rdev, u32 reg) 2389static inline u32 eg_pif_phy0_rreg(struct radeon_device *rdev, u32 reg)
2339{ 2390{
2391 unsigned long flags;
2340 u32 r; 2392 u32 r;
2341 2393
2394 spin_lock_irqsave(&rdev->pif_idx_lock, flags);
2342 WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 2395 WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff));
2343 r = RREG32(EVERGREEN_PIF_PHY0_DATA); 2396 r = RREG32(EVERGREEN_PIF_PHY0_DATA);
2397 spin_unlock_irqrestore(&rdev->pif_idx_lock, flags);
2344 return r; 2398 return r;
2345} 2399}
2346 2400
2347static inline void eg_pif_phy0_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2401static inline void eg_pif_phy0_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2348{ 2402{
2403 unsigned long flags;
2404
2405 spin_lock_irqsave(&rdev->pif_idx_lock, flags);
2349 WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff)); 2406 WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff));
2350 WREG32(EVERGREEN_PIF_PHY0_DATA, (v)); 2407 WREG32(EVERGREEN_PIF_PHY0_DATA, (v));
2408 spin_unlock_irqrestore(&rdev->pif_idx_lock, flags);
2351} 2409}
2352 2410
2353static inline u32 eg_pif_phy1_rreg(struct radeon_device *rdev, u32 reg) 2411static inline u32 eg_pif_phy1_rreg(struct radeon_device *rdev, u32 reg)
2354{ 2412{
2413 unsigned long flags;
2355 u32 r; 2414 u32 r;
2356 2415
2416 spin_lock_irqsave(&rdev->pif_idx_lock, flags);
2357 WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 2417 WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff));
2358 r = RREG32(EVERGREEN_PIF_PHY1_DATA); 2418 r = RREG32(EVERGREEN_PIF_PHY1_DATA);
2419 spin_unlock_irqrestore(&rdev->pif_idx_lock, flags);
2359 return r; 2420 return r;
2360} 2421}
2361 2422
2362static inline void eg_pif_phy1_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2423static inline void eg_pif_phy1_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2363{ 2424{
2425 unsigned long flags;
2426
2427 spin_lock_irqsave(&rdev->pif_idx_lock, flags);
2364 WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff)); 2428 WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff));
2365 WREG32(EVERGREEN_PIF_PHY1_DATA, (v)); 2429 WREG32(EVERGREEN_PIF_PHY1_DATA, (v));
2430 spin_unlock_irqrestore(&rdev->pif_idx_lock, flags);
2366} 2431}
2367 2432
2368static inline u32 r600_uvd_ctx_rreg(struct radeon_device *rdev, u32 reg) 2433static inline u32 r600_uvd_ctx_rreg(struct radeon_device *rdev, u32 reg)
2369{ 2434{
2435 unsigned long flags;
2370 u32 r; 2436 u32 r;
2371 2437
2438 spin_lock_irqsave(&rdev->uvd_idx_lock, flags);
2372 WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff)); 2439 WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff));
2373 r = RREG32(R600_UVD_CTX_DATA); 2440 r = RREG32(R600_UVD_CTX_DATA);
2441 spin_unlock_irqrestore(&rdev->uvd_idx_lock, flags);
2374 return r; 2442 return r;
2375} 2443}
2376 2444
2377static inline void r600_uvd_ctx_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2445static inline void r600_uvd_ctx_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2378{ 2446{
2447 unsigned long flags;
2448
2449 spin_lock_irqsave(&rdev->uvd_idx_lock, flags);
2379 WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff)); 2450 WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff));
2380 WREG32(R600_UVD_CTX_DATA, (v)); 2451 WREG32(R600_UVD_CTX_DATA, (v));
2452 spin_unlock_irqrestore(&rdev->uvd_idx_lock, flags);
2381} 2453}
2382 2454
2383 2455
2384static inline u32 cik_didt_rreg(struct radeon_device *rdev, u32 reg) 2456static inline u32 cik_didt_rreg(struct radeon_device *rdev, u32 reg)
2385{ 2457{
2458 unsigned long flags;
2386 u32 r; 2459 u32 r;
2387 2460
2461 spin_lock_irqsave(&rdev->didt_idx_lock, flags);
2388 WREG32(CIK_DIDT_IND_INDEX, (reg)); 2462 WREG32(CIK_DIDT_IND_INDEX, (reg));
2389 r = RREG32(CIK_DIDT_IND_DATA); 2463 r = RREG32(CIK_DIDT_IND_DATA);
2464 spin_unlock_irqrestore(&rdev->didt_idx_lock, flags);
2390 return r; 2465 return r;
2391} 2466}
2392 2467
2393static inline void cik_didt_wreg(struct radeon_device *rdev, u32 reg, u32 v) 2468static inline void cik_didt_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2394{ 2469{
2470 unsigned long flags;
2471
2472 spin_lock_irqsave(&rdev->didt_idx_lock, flags);
2395 WREG32(CIK_DIDT_IND_INDEX, (reg)); 2473 WREG32(CIK_DIDT_IND_INDEX, (reg));
2396 WREG32(CIK_DIDT_IND_DATA, (v)); 2474 WREG32(CIK_DIDT_IND_DATA, (v));
2475 spin_unlock_irqrestore(&rdev->didt_idx_lock, flags);
2397} 2476}
2398 2477
2399void r100_pll_errata_after_index(struct radeon_device *rdev); 2478void r100_pll_errata_after_index(struct radeon_device *rdev);
@@ -2569,6 +2648,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
2569#define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l)) 2648#define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l))
2570#define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev)) 2649#define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev))
2571#define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g)) 2650#define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g))
2651#define radeon_dpm_enable_bapm(rdev, e) rdev->asic->dpm.enable_bapm((rdev), (e))
2572 2652
2573/* Common functions */ 2653/* Common functions */
2574/* AGP */ 2654/* AGP */
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
index 630853b96841..5003385a7512 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -1037,6 +1037,7 @@ static struct radeon_asic rv6xx_asic = {
1037 .set_pcie_lanes = &r600_set_pcie_lanes, 1037 .set_pcie_lanes = &r600_set_pcie_lanes,
1038 .set_clock_gating = NULL, 1038 .set_clock_gating = NULL,
1039 .get_temperature = &rv6xx_get_temp, 1039 .get_temperature = &rv6xx_get_temp,
1040 .set_uvd_clocks = &r600_set_uvd_clocks,
1040 }, 1041 },
1041 .dpm = { 1042 .dpm = {
1042 .init = &rv6xx_dpm_init, 1043 .init = &rv6xx_dpm_init,
@@ -1126,6 +1127,7 @@ static struct radeon_asic rs780_asic = {
1126 .set_pcie_lanes = NULL, 1127 .set_pcie_lanes = NULL,
1127 .set_clock_gating = NULL, 1128 .set_clock_gating = NULL,
1128 .get_temperature = &rv6xx_get_temp, 1129 .get_temperature = &rv6xx_get_temp,
1130 .set_uvd_clocks = &r600_set_uvd_clocks,
1129 }, 1131 },
1130 .dpm = { 1132 .dpm = {
1131 .init = &rs780_dpm_init, 1133 .init = &rs780_dpm_init,
@@ -1141,6 +1143,7 @@ static struct radeon_asic rs780_asic = {
1141 .get_mclk = &rs780_dpm_get_mclk, 1143 .get_mclk = &rs780_dpm_get_mclk,
1142 .print_power_state = &rs780_dpm_print_power_state, 1144 .print_power_state = &rs780_dpm_print_power_state,
1143 .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level, 1145 .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level,
1146 .force_performance_level = &rs780_dpm_force_performance_level,
1144 }, 1147 },
1145 .pflip = { 1148 .pflip = {
1146 .pre_page_flip = &rs600_pre_page_flip, 1149 .pre_page_flip = &rs600_pre_page_flip,
@@ -1791,6 +1794,7 @@ static struct radeon_asic trinity_asic = {
1791 .print_power_state = &trinity_dpm_print_power_state, 1794 .print_power_state = &trinity_dpm_print_power_state,
1792 .debugfs_print_current_performance_level = &trinity_dpm_debugfs_print_current_performance_level, 1795 .debugfs_print_current_performance_level = &trinity_dpm_debugfs_print_current_performance_level,
1793 .force_performance_level = &trinity_dpm_force_performance_level, 1796 .force_performance_level = &trinity_dpm_force_performance_level,
1797 .enable_bapm = &trinity_dpm_enable_bapm,
1794 }, 1798 },
1795 .pflip = { 1799 .pflip = {
1796 .pre_page_flip = &evergreen_pre_page_flip, 1800 .pre_page_flip = &evergreen_pre_page_flip,
@@ -2166,6 +2170,7 @@ static struct radeon_asic kv_asic = {
2166 .debugfs_print_current_performance_level = &kv_dpm_debugfs_print_current_performance_level, 2170 .debugfs_print_current_performance_level = &kv_dpm_debugfs_print_current_performance_level,
2167 .force_performance_level = &kv_dpm_force_performance_level, 2171 .force_performance_level = &kv_dpm_force_performance_level,
2168 .powergate_uvd = &kv_dpm_powergate_uvd, 2172 .powergate_uvd = &kv_dpm_powergate_uvd,
2173 .enable_bapm = &kv_dpm_enable_bapm,
2169 }, 2174 },
2170 .pflip = { 2175 .pflip = {
2171 .pre_page_flip = &evergreen_pre_page_flip, 2176 .pre_page_flip = &evergreen_pre_page_flip,
@@ -2390,7 +2395,7 @@ int radeon_asic_init(struct radeon_device *rdev)
2390 RADEON_CG_SUPPORT_HDP_LS | 2395 RADEON_CG_SUPPORT_HDP_LS |
2391 RADEON_CG_SUPPORT_HDP_MGCG; 2396 RADEON_CG_SUPPORT_HDP_MGCG;
2392 rdev->pg_flags = 0 | 2397 rdev->pg_flags = 0 |
2393 /*RADEON_PG_SUPPORT_GFX_CG | */ 2398 /*RADEON_PG_SUPPORT_GFX_PG | */
2394 RADEON_PG_SUPPORT_SDMA; 2399 RADEON_PG_SUPPORT_SDMA;
2395 break; 2400 break;
2396 case CHIP_OLAND: 2401 case CHIP_OLAND:
@@ -2479,7 +2484,7 @@ int radeon_asic_init(struct radeon_device *rdev)
2479 RADEON_CG_SUPPORT_HDP_LS | 2484 RADEON_CG_SUPPORT_HDP_LS |
2480 RADEON_CG_SUPPORT_HDP_MGCG; 2485 RADEON_CG_SUPPORT_HDP_MGCG;
2481 rdev->pg_flags = 0; 2486 rdev->pg_flags = 0;
2482 /*RADEON_PG_SUPPORT_GFX_CG | 2487 /*RADEON_PG_SUPPORT_GFX_PG |
2483 RADEON_PG_SUPPORT_GFX_SMG | 2488 RADEON_PG_SUPPORT_GFX_SMG |
2484 RADEON_PG_SUPPORT_GFX_DMG | 2489 RADEON_PG_SUPPORT_GFX_DMG |
2485 RADEON_PG_SUPPORT_UVD | 2490 RADEON_PG_SUPPORT_UVD |
@@ -2507,7 +2512,7 @@ int radeon_asic_init(struct radeon_device *rdev)
2507 RADEON_CG_SUPPORT_HDP_LS | 2512 RADEON_CG_SUPPORT_HDP_LS |
2508 RADEON_CG_SUPPORT_HDP_MGCG; 2513 RADEON_CG_SUPPORT_HDP_MGCG;
2509 rdev->pg_flags = 0; 2514 rdev->pg_flags = 0;
2510 /*RADEON_PG_SUPPORT_GFX_CG | 2515 /*RADEON_PG_SUPPORT_GFX_PG |
2511 RADEON_PG_SUPPORT_GFX_SMG | 2516 RADEON_PG_SUPPORT_GFX_SMG |
2512 RADEON_PG_SUPPORT_UVD | 2517 RADEON_PG_SUPPORT_UVD |
2513 RADEON_PG_SUPPORT_VCE | 2518 RADEON_PG_SUPPORT_VCE |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 818bbe6b884b..70c29d5e080d 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -389,6 +389,7 @@ int r600_mc_wait_for_idle(struct radeon_device *rdev);
389u32 r600_get_xclk(struct radeon_device *rdev); 389u32 r600_get_xclk(struct radeon_device *rdev);
390uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev); 390uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev);
391int rv6xx_get_temp(struct radeon_device *rdev); 391int rv6xx_get_temp(struct radeon_device *rdev);
392int r600_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
392int r600_dpm_pre_set_power_state(struct radeon_device *rdev); 393int r600_dpm_pre_set_power_state(struct radeon_device *rdev);
393void r600_dpm_post_set_power_state(struct radeon_device *rdev); 394void r600_dpm_post_set_power_state(struct radeon_device *rdev);
394/* r600 dma */ 395/* r600 dma */
@@ -428,6 +429,8 @@ void rs780_dpm_print_power_state(struct radeon_device *rdev,
428 struct radeon_ps *ps); 429 struct radeon_ps *ps);
429void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, 430void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
430 struct seq_file *m); 431 struct seq_file *m);
432int rs780_dpm_force_performance_level(struct radeon_device *rdev,
433 enum radeon_dpm_forced_level level);
431 434
432/* 435/*
433 * rv770,rv730,rv710,rv740 436 * rv770,rv730,rv710,rv740
@@ -625,6 +628,7 @@ void trinity_dpm_debugfs_print_current_performance_level(struct radeon_device *r
625 struct seq_file *m); 628 struct seq_file *m);
626int trinity_dpm_force_performance_level(struct radeon_device *rdev, 629int trinity_dpm_force_performance_level(struct radeon_device *rdev,
627 enum radeon_dpm_forced_level level); 630 enum radeon_dpm_forced_level level);
631void trinity_dpm_enable_bapm(struct radeon_device *rdev, bool enable);
628 632
629/* DCE6 - SI */ 633/* DCE6 - SI */
630void dce6_bandwidth_update(struct radeon_device *rdev); 634void dce6_bandwidth_update(struct radeon_device *rdev);
@@ -781,6 +785,7 @@ void kv_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
781int kv_dpm_force_performance_level(struct radeon_device *rdev, 785int kv_dpm_force_performance_level(struct radeon_device *rdev,
782 enum radeon_dpm_forced_level level); 786 enum radeon_dpm_forced_level level);
783void kv_dpm_powergate_uvd(struct radeon_device *rdev, bool gate); 787void kv_dpm_powergate_uvd(struct radeon_device *rdev, bool gate);
788void kv_dpm_enable_bapm(struct radeon_device *rdev, bool enable);
784 789
785/* uvd v1.0 */ 790/* uvd v1.0 */
786uint32_t uvd_v1_0_get_rptr(struct radeon_device *rdev, 791uint32_t uvd_v1_0_get_rptr(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 2399f25ec037..79159b5da05b 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -396,6 +396,21 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
396 } 396 }
397 } 397 }
398 398
399 if (property == rdev->mode_info.audio_property) {
400 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
401 /* need to find digital encoder on connector */
402 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
403 if (!encoder)
404 return 0;
405
406 radeon_encoder = to_radeon_encoder(encoder);
407
408 if (radeon_connector->audio != val) {
409 radeon_connector->audio = val;
410 radeon_property_change_mode(&radeon_encoder->base);
411 }
412 }
413
399 if (property == rdev->mode_info.underscan_property) { 414 if (property == rdev->mode_info.underscan_property) {
400 /* need to find digital encoder on connector */ 415 /* need to find digital encoder on connector */
401 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 416 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
@@ -1420,7 +1435,7 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1420 if (radeon_dp_getdpcd(radeon_connector)) 1435 if (radeon_dp_getdpcd(radeon_connector))
1421 ret = connector_status_connected; 1436 ret = connector_status_connected;
1422 } else { 1437 } else {
1423 /* try non-aux ddc (DP to DVI/HMDI/etc. adapter) */ 1438 /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */
1424 if (radeon_ddc_probe(radeon_connector, false)) 1439 if (radeon_ddc_probe(radeon_connector, false))
1425 ret = connector_status_connected; 1440 ret = connector_status_connected;
1426 } 1441 }
@@ -1489,6 +1504,24 @@ static const struct drm_connector_funcs radeon_dp_connector_funcs = {
1489 .force = radeon_dvi_force, 1504 .force = radeon_dvi_force,
1490}; 1505};
1491 1506
1507static const struct drm_connector_funcs radeon_edp_connector_funcs = {
1508 .dpms = drm_helper_connector_dpms,
1509 .detect = radeon_dp_detect,
1510 .fill_modes = drm_helper_probe_single_connector_modes,
1511 .set_property = radeon_lvds_set_property,
1512 .destroy = radeon_dp_connector_destroy,
1513 .force = radeon_dvi_force,
1514};
1515
1516static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = {
1517 .dpms = drm_helper_connector_dpms,
1518 .detect = radeon_dp_detect,
1519 .fill_modes = drm_helper_probe_single_connector_modes,
1520 .set_property = radeon_lvds_set_property,
1521 .destroy = radeon_dp_connector_destroy,
1522 .force = radeon_dvi_force,
1523};
1524
1492void 1525void
1493radeon_add_atom_connector(struct drm_device *dev, 1526radeon_add_atom_connector(struct drm_device *dev,
1494 uint32_t connector_id, 1527 uint32_t connector_id,
@@ -1580,8 +1613,6 @@ radeon_add_atom_connector(struct drm_device *dev,
1580 goto failed; 1613 goto failed;
1581 radeon_dig_connector->igp_lane_info = igp_lane_info; 1614 radeon_dig_connector->igp_lane_info = igp_lane_info;
1582 radeon_connector->con_priv = radeon_dig_connector; 1615 radeon_connector->con_priv = radeon_dig_connector;
1583 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
1584 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
1585 if (i2c_bus->valid) { 1616 if (i2c_bus->valid) {
1586 /* add DP i2c bus */ 1617 /* add DP i2c bus */
1587 if (connector_type == DRM_MODE_CONNECTOR_eDP) 1618 if (connector_type == DRM_MODE_CONNECTOR_eDP)
@@ -1598,6 +1629,10 @@ radeon_add_atom_connector(struct drm_device *dev,
1598 case DRM_MODE_CONNECTOR_VGA: 1629 case DRM_MODE_CONNECTOR_VGA:
1599 case DRM_MODE_CONNECTOR_DVIA: 1630 case DRM_MODE_CONNECTOR_DVIA:
1600 default: 1631 default:
1632 drm_connector_init(dev, &radeon_connector->base,
1633 &radeon_dp_connector_funcs, connector_type);
1634 drm_connector_helper_add(&radeon_connector->base,
1635 &radeon_dp_connector_helper_funcs);
1601 connector->interlace_allowed = true; 1636 connector->interlace_allowed = true;
1602 connector->doublescan_allowed = true; 1637 connector->doublescan_allowed = true;
1603 radeon_connector->dac_load_detect = true; 1638 radeon_connector->dac_load_detect = true;
@@ -1610,6 +1645,10 @@ radeon_add_atom_connector(struct drm_device *dev,
1610 case DRM_MODE_CONNECTOR_HDMIA: 1645 case DRM_MODE_CONNECTOR_HDMIA:
1611 case DRM_MODE_CONNECTOR_HDMIB: 1646 case DRM_MODE_CONNECTOR_HDMIB:
1612 case DRM_MODE_CONNECTOR_DisplayPort: 1647 case DRM_MODE_CONNECTOR_DisplayPort:
1648 drm_connector_init(dev, &radeon_connector->base,
1649 &radeon_dp_connector_funcs, connector_type);
1650 drm_connector_helper_add(&radeon_connector->base,
1651 &radeon_dp_connector_helper_funcs);
1613 drm_object_attach_property(&radeon_connector->base.base, 1652 drm_object_attach_property(&radeon_connector->base.base,
1614 rdev->mode_info.underscan_property, 1653 rdev->mode_info.underscan_property,
1615 UNDERSCAN_OFF); 1654 UNDERSCAN_OFF);
@@ -1619,6 +1658,9 @@ radeon_add_atom_connector(struct drm_device *dev,
1619 drm_object_attach_property(&radeon_connector->base.base, 1658 drm_object_attach_property(&radeon_connector->base.base,
1620 rdev->mode_info.underscan_vborder_property, 1659 rdev->mode_info.underscan_vborder_property,
1621 0); 1660 0);
1661 drm_object_attach_property(&radeon_connector->base.base,
1662 rdev->mode_info.audio_property,
1663 RADEON_AUDIO_DISABLE);
1622 subpixel_order = SubPixelHorizontalRGB; 1664 subpixel_order = SubPixelHorizontalRGB;
1623 connector->interlace_allowed = true; 1665 connector->interlace_allowed = true;
1624 if (connector_type == DRM_MODE_CONNECTOR_HDMIB) 1666 if (connector_type == DRM_MODE_CONNECTOR_HDMIB)
@@ -1634,6 +1676,10 @@ radeon_add_atom_connector(struct drm_device *dev,
1634 break; 1676 break;
1635 case DRM_MODE_CONNECTOR_LVDS: 1677 case DRM_MODE_CONNECTOR_LVDS:
1636 case DRM_MODE_CONNECTOR_eDP: 1678 case DRM_MODE_CONNECTOR_eDP:
1679 drm_connector_init(dev, &radeon_connector->base,
1680 &radeon_lvds_bridge_connector_funcs, connector_type);
1681 drm_connector_helper_add(&radeon_connector->base,
1682 &radeon_dp_connector_helper_funcs);
1637 drm_object_attach_property(&radeon_connector->base.base, 1683 drm_object_attach_property(&radeon_connector->base.base,
1638 dev->mode_config.scaling_mode_property, 1684 dev->mode_config.scaling_mode_property,
1639 DRM_MODE_SCALE_FULLSCREEN); 1685 DRM_MODE_SCALE_FULLSCREEN);
@@ -1708,6 +1754,11 @@ radeon_add_atom_connector(struct drm_device *dev,
1708 rdev->mode_info.underscan_vborder_property, 1754 rdev->mode_info.underscan_vborder_property,
1709 0); 1755 0);
1710 } 1756 }
1757 if (ASIC_IS_DCE2(rdev)) {
1758 drm_object_attach_property(&radeon_connector->base.base,
1759 rdev->mode_info.audio_property,
1760 RADEON_AUDIO_DISABLE);
1761 }
1711 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 1762 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1712 radeon_connector->dac_load_detect = true; 1763 radeon_connector->dac_load_detect = true;
1713 drm_object_attach_property(&radeon_connector->base.base, 1764 drm_object_attach_property(&radeon_connector->base.base,
@@ -1748,6 +1799,11 @@ radeon_add_atom_connector(struct drm_device *dev,
1748 rdev->mode_info.underscan_vborder_property, 1799 rdev->mode_info.underscan_vborder_property,
1749 0); 1800 0);
1750 } 1801 }
1802 if (ASIC_IS_DCE2(rdev)) {
1803 drm_object_attach_property(&radeon_connector->base.base,
1804 rdev->mode_info.audio_property,
1805 RADEON_AUDIO_DISABLE);
1806 }
1751 subpixel_order = SubPixelHorizontalRGB; 1807 subpixel_order = SubPixelHorizontalRGB;
1752 connector->interlace_allowed = true; 1808 connector->interlace_allowed = true;
1753 if (connector_type == DRM_MODE_CONNECTOR_HDMIB) 1809 if (connector_type == DRM_MODE_CONNECTOR_HDMIB)
@@ -1787,6 +1843,11 @@ radeon_add_atom_connector(struct drm_device *dev,
1787 rdev->mode_info.underscan_vborder_property, 1843 rdev->mode_info.underscan_vborder_property,
1788 0); 1844 0);
1789 } 1845 }
1846 if (ASIC_IS_DCE2(rdev)) {
1847 drm_object_attach_property(&radeon_connector->base.base,
1848 rdev->mode_info.audio_property,
1849 RADEON_AUDIO_DISABLE);
1850 }
1790 connector->interlace_allowed = true; 1851 connector->interlace_allowed = true;
1791 /* in theory with a DP to VGA converter... */ 1852 /* in theory with a DP to VGA converter... */
1792 connector->doublescan_allowed = false; 1853 connector->doublescan_allowed = false;
@@ -1797,7 +1858,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1797 goto failed; 1858 goto failed;
1798 radeon_dig_connector->igp_lane_info = igp_lane_info; 1859 radeon_dig_connector->igp_lane_info = igp_lane_info;
1799 radeon_connector->con_priv = radeon_dig_connector; 1860 radeon_connector->con_priv = radeon_dig_connector;
1800 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); 1861 drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type);
1801 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); 1862 drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
1802 if (i2c_bus->valid) { 1863 if (i2c_bus->valid) {
1803 /* add DP i2c bus */ 1864 /* add DP i2c bus */
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index a56084410372..ac6ece61a476 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -28,6 +28,7 @@
28#include <drm/radeon_drm.h> 28#include <drm/radeon_drm.h>
29#include "radeon_reg.h" 29#include "radeon_reg.h"
30#include "radeon.h" 30#include "radeon.h"
31#include "radeon_trace.h"
31 32
32static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) 33static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
33{ 34{
@@ -80,9 +81,11 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
80 p->relocs[i].lobj.bo = p->relocs[i].robj; 81 p->relocs[i].lobj.bo = p->relocs[i].robj;
81 p->relocs[i].lobj.written = !!r->write_domain; 82 p->relocs[i].lobj.written = !!r->write_domain;
82 83
83 /* the first reloc of an UVD job is the 84 /* the first reloc of an UVD job is the msg and that must be in
84 msg and that must be in VRAM */ 85 VRAM, also but everything into VRAM on AGP cards to avoid
85 if (p->ring == R600_RING_TYPE_UVD_INDEX && i == 0) { 86 image corruptions */
87 if (p->ring == R600_RING_TYPE_UVD_INDEX &&
88 (i == 0 || p->rdev->flags & RADEON_IS_AGP)) {
86 /* TODO: is this still needed for NI+ ? */ 89 /* TODO: is this still needed for NI+ ? */
87 p->relocs[i].lobj.domain = 90 p->relocs[i].lobj.domain =
88 RADEON_GEM_DOMAIN_VRAM; 91 RADEON_GEM_DOMAIN_VRAM;
@@ -559,6 +562,8 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
559 return r; 562 return r;
560 } 563 }
561 564
565 trace_radeon_cs(&parser);
566
562 r = radeon_cs_ib_chunk(rdev, &parser); 567 r = radeon_cs_ib_chunk(rdev, &parser);
563 if (r) { 568 if (r) {
564 goto out; 569 goto out;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 16cb8792b1e6..e29faa73b574 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1249,6 +1249,17 @@ int radeon_device_init(struct radeon_device *rdev,
1249 /* Registers mapping */ 1249 /* Registers mapping */
1250 /* TODO: block userspace mapping of io register */ 1250 /* TODO: block userspace mapping of io register */
1251 spin_lock_init(&rdev->mmio_idx_lock); 1251 spin_lock_init(&rdev->mmio_idx_lock);
1252 spin_lock_init(&rdev->smc_idx_lock);
1253 spin_lock_init(&rdev->pll_idx_lock);
1254 spin_lock_init(&rdev->mc_idx_lock);
1255 spin_lock_init(&rdev->pcie_idx_lock);
1256 spin_lock_init(&rdev->pciep_idx_lock);
1257 spin_lock_init(&rdev->pif_idx_lock);
1258 spin_lock_init(&rdev->cg_idx_lock);
1259 spin_lock_init(&rdev->uvd_idx_lock);
1260 spin_lock_init(&rdev->rcu_idx_lock);
1261 spin_lock_init(&rdev->didt_idx_lock);
1262 spin_lock_init(&rdev->end_idx_lock);
1252 if (rdev->family >= CHIP_BONAIRE) { 1263 if (rdev->family >= CHIP_BONAIRE) {
1253 rdev->rmmio_base = pci_resource_start(rdev->pdev, 5); 1264 rdev->rmmio_base = pci_resource_start(rdev->pdev, 5);
1254 rdev->rmmio_size = pci_resource_len(rdev->pdev, 5); 1265 rdev->rmmio_size = pci_resource_len(rdev->pdev, 5);
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index b055bddaa94c..0d1aa050d41d 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1172,6 +1172,12 @@ static struct drm_prop_enum_list radeon_underscan_enum_list[] =
1172 { UNDERSCAN_AUTO, "auto" }, 1172 { UNDERSCAN_AUTO, "auto" },
1173}; 1173};
1174 1174
1175static struct drm_prop_enum_list radeon_audio_enum_list[] =
1176{ { RADEON_AUDIO_DISABLE, "off" },
1177 { RADEON_AUDIO_ENABLE, "on" },
1178 { RADEON_AUDIO_AUTO, "auto" },
1179};
1180
1175static int radeon_modeset_create_props(struct radeon_device *rdev) 1181static int radeon_modeset_create_props(struct radeon_device *rdev)
1176{ 1182{
1177 int sz; 1183 int sz;
@@ -1222,6 +1228,12 @@ static int radeon_modeset_create_props(struct radeon_device *rdev)
1222 if (!rdev->mode_info.underscan_vborder_property) 1228 if (!rdev->mode_info.underscan_vborder_property)
1223 return -ENOMEM; 1229 return -ENOMEM;
1224 1230
1231 sz = ARRAY_SIZE(radeon_audio_enum_list);
1232 rdev->mode_info.audio_property =
1233 drm_property_create_enum(rdev->ddev, 0,
1234 "audio",
1235 radeon_audio_enum_list, sz);
1236
1225 return 0; 1237 return 0;
1226} 1238}
1227 1239
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index cb4445f55a96..cdd12dcd988b 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -153,7 +153,7 @@ int radeon_benchmarking = 0;
153int radeon_testing = 0; 153int radeon_testing = 0;
154int radeon_connector_table = 0; 154int radeon_connector_table = 0;
155int radeon_tv = 1; 155int radeon_tv = 1;
156int radeon_audio = 0; 156int radeon_audio = 1;
157int radeon_disp_priority = 0; 157int radeon_disp_priority = 0;
158int radeon_hw_i2c = 0; 158int radeon_hw_i2c = 0;
159int radeon_pcie_gen2 = -1; 159int radeon_pcie_gen2 = -1;
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index d908d8d68f6b..ef63d3f00b2f 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -247,6 +247,8 @@ struct radeon_mode_info {
247 struct drm_property *underscan_property; 247 struct drm_property *underscan_property;
248 struct drm_property *underscan_hborder_property; 248 struct drm_property *underscan_hborder_property;
249 struct drm_property *underscan_vborder_property; 249 struct drm_property *underscan_vborder_property;
250 /* audio */
251 struct drm_property *audio_property;
250 /* hardcoded DFP edid from BIOS */ 252 /* hardcoded DFP edid from BIOS */
251 struct edid *bios_hardcoded_edid; 253 struct edid *bios_hardcoded_edid;
252 int bios_hardcoded_edid_size; 254 int bios_hardcoded_edid_size;
@@ -471,6 +473,12 @@ struct radeon_router {
471 u8 cd_mux_state; 473 u8 cd_mux_state;
472}; 474};
473 475
476enum radeon_connector_audio {
477 RADEON_AUDIO_DISABLE = 0,
478 RADEON_AUDIO_ENABLE = 1,
479 RADEON_AUDIO_AUTO = 2
480};
481
474struct radeon_connector { 482struct radeon_connector {
475 struct drm_connector base; 483 struct drm_connector base;
476 uint32_t connector_id; 484 uint32_t connector_id;
@@ -489,6 +497,7 @@ struct radeon_connector {
489 struct radeon_hpd hpd; 497 struct radeon_hpd hpd;
490 struct radeon_router router; 498 struct radeon_router router;
491 struct radeon_i2c_chan *router_bus; 499 struct radeon_i2c_chan *router_bus;
500 enum radeon_connector_audio audio;
492}; 501};
493 502
494struct radeon_framebuffer { 503struct radeon_framebuffer {
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index d7555369a3e5..87e1d69e8fdb 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -67,7 +67,16 @@ int radeon_pm_get_type_index(struct radeon_device *rdev,
67 67
68void radeon_pm_acpi_event_handler(struct radeon_device *rdev) 68void radeon_pm_acpi_event_handler(struct radeon_device *rdev)
69{ 69{
70 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { 70 if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) {
71 mutex_lock(&rdev->pm.mutex);
72 if (power_supply_is_system_supplied() > 0)
73 rdev->pm.dpm.ac_power = true;
74 else
75 rdev->pm.dpm.ac_power = false;
76 if (rdev->asic->dpm.enable_bapm)
77 radeon_dpm_enable_bapm(rdev, rdev->pm.dpm.ac_power);
78 mutex_unlock(&rdev->pm.mutex);
79 } else if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
71 if (rdev->pm.profile == PM_PROFILE_AUTO) { 80 if (rdev->pm.profile == PM_PROFILE_AUTO) {
72 mutex_lock(&rdev->pm.mutex); 81 mutex_lock(&rdev->pm.mutex);
73 radeon_pm_update_profile(rdev); 82 radeon_pm_update_profile(rdev);
@@ -333,7 +342,7 @@ static ssize_t radeon_get_pm_profile(struct device *dev,
333 struct device_attribute *attr, 342 struct device_attribute *attr,
334 char *buf) 343 char *buf)
335{ 344{
336 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 345 struct drm_device *ddev = dev_get_drvdata(dev);
337 struct radeon_device *rdev = ddev->dev_private; 346 struct radeon_device *rdev = ddev->dev_private;
338 int cp = rdev->pm.profile; 347 int cp = rdev->pm.profile;
339 348
@@ -349,7 +358,7 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
349 const char *buf, 358 const char *buf,
350 size_t count) 359 size_t count)
351{ 360{
352 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 361 struct drm_device *ddev = dev_get_drvdata(dev);
353 struct radeon_device *rdev = ddev->dev_private; 362 struct radeon_device *rdev = ddev->dev_private;
354 363
355 mutex_lock(&rdev->pm.mutex); 364 mutex_lock(&rdev->pm.mutex);
@@ -383,7 +392,7 @@ static ssize_t radeon_get_pm_method(struct device *dev,
383 struct device_attribute *attr, 392 struct device_attribute *attr,
384 char *buf) 393 char *buf)
385{ 394{
386 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 395 struct drm_device *ddev = dev_get_drvdata(dev);
387 struct radeon_device *rdev = ddev->dev_private; 396 struct radeon_device *rdev = ddev->dev_private;
388 int pm = rdev->pm.pm_method; 397 int pm = rdev->pm.pm_method;
389 398
@@ -397,7 +406,7 @@ static ssize_t radeon_set_pm_method(struct device *dev,
397 const char *buf, 406 const char *buf,
398 size_t count) 407 size_t count)
399{ 408{
400 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 409 struct drm_device *ddev = dev_get_drvdata(dev);
401 struct radeon_device *rdev = ddev->dev_private; 410 struct radeon_device *rdev = ddev->dev_private;
402 411
403 /* we don't support the legacy modes with dpm */ 412 /* we don't support the legacy modes with dpm */
@@ -433,7 +442,7 @@ static ssize_t radeon_get_dpm_state(struct device *dev,
433 struct device_attribute *attr, 442 struct device_attribute *attr,
434 char *buf) 443 char *buf)
435{ 444{
436 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 445 struct drm_device *ddev = dev_get_drvdata(dev);
437 struct radeon_device *rdev = ddev->dev_private; 446 struct radeon_device *rdev = ddev->dev_private;
438 enum radeon_pm_state_type pm = rdev->pm.dpm.user_state; 447 enum radeon_pm_state_type pm = rdev->pm.dpm.user_state;
439 448
@@ -447,7 +456,7 @@ static ssize_t radeon_set_dpm_state(struct device *dev,
447 const char *buf, 456 const char *buf,
448 size_t count) 457 size_t count)
449{ 458{
450 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 459 struct drm_device *ddev = dev_get_drvdata(dev);
451 struct radeon_device *rdev = ddev->dev_private; 460 struct radeon_device *rdev = ddev->dev_private;
452 461
453 mutex_lock(&rdev->pm.mutex); 462 mutex_lock(&rdev->pm.mutex);
@@ -472,7 +481,7 @@ static ssize_t radeon_get_dpm_forced_performance_level(struct device *dev,
472 struct device_attribute *attr, 481 struct device_attribute *attr,
473 char *buf) 482 char *buf)
474{ 483{
475 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 484 struct drm_device *ddev = dev_get_drvdata(dev);
476 struct radeon_device *rdev = ddev->dev_private; 485 struct radeon_device *rdev = ddev->dev_private;
477 enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level; 486 enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level;
478 487
@@ -486,7 +495,7 @@ static ssize_t radeon_set_dpm_forced_performance_level(struct device *dev,
486 const char *buf, 495 const char *buf,
487 size_t count) 496 size_t count)
488{ 497{
489 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 498 struct drm_device *ddev = dev_get_drvdata(dev);
490 struct radeon_device *rdev = ddev->dev_private; 499 struct radeon_device *rdev = ddev->dev_private;
491 enum radeon_dpm_forced_level level; 500 enum radeon_dpm_forced_level level;
492 int ret = 0; 501 int ret = 0;
@@ -524,7 +533,7 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev,
524 struct device_attribute *attr, 533 struct device_attribute *attr,
525 char *buf) 534 char *buf)
526{ 535{
527 struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); 536 struct drm_device *ddev = dev_get_drvdata(dev);
528 struct radeon_device *rdev = ddev->dev_private; 537 struct radeon_device *rdev = ddev->dev_private;
529 int temp; 538 int temp;
530 539
@@ -536,6 +545,23 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev,
536 return snprintf(buf, PAGE_SIZE, "%d\n", temp); 545 return snprintf(buf, PAGE_SIZE, "%d\n", temp);
537} 546}
538 547
548static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev,
549 struct device_attribute *attr,
550 char *buf)
551{
552 struct drm_device *ddev = dev_get_drvdata(dev);
553 struct radeon_device *rdev = ddev->dev_private;
554 int hyst = to_sensor_dev_attr(attr)->index;
555 int temp;
556
557 if (hyst)
558 temp = rdev->pm.dpm.thermal.min_temp;
559 else
560 temp = rdev->pm.dpm.thermal.max_temp;
561
562 return snprintf(buf, PAGE_SIZE, "%d\n", temp);
563}
564
539static ssize_t radeon_hwmon_show_name(struct device *dev, 565static ssize_t radeon_hwmon_show_name(struct device *dev,
540 struct device_attribute *attr, 566 struct device_attribute *attr,
541 char *buf) 567 char *buf)
@@ -544,16 +570,37 @@ static ssize_t radeon_hwmon_show_name(struct device *dev,
544} 570}
545 571
546static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); 572static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0);
573static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0);
574static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1);
547static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); 575static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0);
548 576
549static struct attribute *hwmon_attributes[] = { 577static struct attribute *hwmon_attributes[] = {
550 &sensor_dev_attr_temp1_input.dev_attr.attr, 578 &sensor_dev_attr_temp1_input.dev_attr.attr,
579 &sensor_dev_attr_temp1_crit.dev_attr.attr,
580 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
551 &sensor_dev_attr_name.dev_attr.attr, 581 &sensor_dev_attr_name.dev_attr.attr,
552 NULL 582 NULL
553}; 583};
554 584
585static umode_t hwmon_attributes_visible(struct kobject *kobj,
586 struct attribute *attr, int index)
587{
588 struct device *dev = container_of(kobj, struct device, kobj);
589 struct drm_device *ddev = dev_get_drvdata(dev);
590 struct radeon_device *rdev = ddev->dev_private;
591
592 /* Skip limit attributes if DPM is not enabled */
593 if (rdev->pm.pm_method != PM_METHOD_DPM &&
594 (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr ||
595 attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr))
596 return 0;
597
598 return attr->mode;
599}
600
555static const struct attribute_group hwmon_attrgroup = { 601static const struct attribute_group hwmon_attrgroup = {
556 .attrs = hwmon_attributes, 602 .attrs = hwmon_attributes,
603 .is_visible = hwmon_attributes_visible,
557}; 604};
558 605
559static int radeon_hwmon_init(struct radeon_device *rdev) 606static int radeon_hwmon_init(struct radeon_device *rdev)
@@ -870,10 +917,13 @@ static void radeon_dpm_change_power_state_locked(struct radeon_device *rdev)
870 917
871 radeon_dpm_post_set_power_state(rdev); 918 radeon_dpm_post_set_power_state(rdev);
872 919
873 /* force low perf level for thermal */ 920 if (rdev->asic->dpm.force_performance_level) {
874 if (rdev->pm.dpm.thermal_active && 921 if (rdev->pm.dpm.thermal_active)
875 rdev->asic->dpm.force_performance_level) { 922 /* force low perf level for thermal */
876 radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_LOW); 923 radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_LOW);
924 else
925 /* otherwise, enable auto */
926 radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
877 } 927 }
878 928
879done: 929done:
@@ -1102,9 +1152,10 @@ static int radeon_pm_init_dpm(struct radeon_device *rdev)
1102{ 1152{
1103 int ret; 1153 int ret;
1104 1154
1105 /* default to performance state */ 1155 /* default to balanced state */
1106 rdev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; 1156 rdev->pm.dpm.state = POWER_STATE_TYPE_BALANCED;
1107 rdev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; 1157 rdev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED;
1158 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
1108 rdev->pm.default_sclk = rdev->clock.default_sclk; 1159 rdev->pm.default_sclk = rdev->clock.default_sclk;
1109 rdev->pm.default_mclk = rdev->clock.default_mclk; 1160 rdev->pm.default_mclk = rdev->clock.default_mclk;
1110 rdev->pm.current_sclk = rdev->clock.default_sclk; 1161 rdev->pm.current_sclk = rdev->clock.default_sclk;
diff --git a/drivers/gpu/drm/radeon/radeon_trace.h b/drivers/gpu/drm/radeon/radeon_trace.h
index eafd8160a155..f7e367815964 100644
--- a/drivers/gpu/drm/radeon/radeon_trace.h
+++ b/drivers/gpu/drm/radeon/radeon_trace.h
@@ -27,6 +27,26 @@ TRACE_EVENT(radeon_bo_create,
27 TP_printk("bo=%p, pages=%u", __entry->bo, __entry->pages) 27 TP_printk("bo=%p, pages=%u", __entry->bo, __entry->pages)
28); 28);
29 29
30TRACE_EVENT(radeon_cs,
31 TP_PROTO(struct radeon_cs_parser *p),
32 TP_ARGS(p),
33 TP_STRUCT__entry(
34 __field(u32, ring)
35 __field(u32, dw)
36 __field(u32, fences)
37 ),
38
39 TP_fast_assign(
40 __entry->ring = p->ring;
41 __entry->dw = p->chunks[p->chunk_ib_idx].length_dw;
42 __entry->fences = radeon_fence_count_emitted(
43 p->rdev, p->ring);
44 ),
45 TP_printk("ring=%u, dw=%u, fences=%u",
46 __entry->ring, __entry->dw,
47 __entry->fences)
48);
49
30DECLARE_EVENT_CLASS(radeon_fence_request, 50DECLARE_EVENT_CLASS(radeon_fence_request,
31 51
32 TP_PROTO(struct drm_device *dev, u32 seqno), 52 TP_PROTO(struct drm_device *dev, u32 seqno),
@@ -53,13 +73,6 @@ DEFINE_EVENT(radeon_fence_request, radeon_fence_emit,
53 TP_ARGS(dev, seqno) 73 TP_ARGS(dev, seqno)
54); 74);
55 75
56DEFINE_EVENT(radeon_fence_request, radeon_fence_retire,
57
58 TP_PROTO(struct drm_device *dev, u32 seqno),
59
60 TP_ARGS(dev, seqno)
61);
62
63DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_begin, 76DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_begin,
64 77
65 TP_PROTO(struct drm_device *dev, u32 seqno), 78 TP_PROTO(struct drm_device *dev, u32 seqno),
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index b8074a8ec75a..9566b5940a5a 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -274,19 +274,26 @@ static void rs400_mc_init(struct radeon_device *rdev)
274 274
275uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg) 275uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg)
276{ 276{
277 unsigned long flags;
277 uint32_t r; 278 uint32_t r;
278 279
280 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
279 WREG32(RS480_NB_MC_INDEX, reg & 0xff); 281 WREG32(RS480_NB_MC_INDEX, reg & 0xff);
280 r = RREG32(RS480_NB_MC_DATA); 282 r = RREG32(RS480_NB_MC_DATA);
281 WREG32(RS480_NB_MC_INDEX, 0xff); 283 WREG32(RS480_NB_MC_INDEX, 0xff);
284 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
282 return r; 285 return r;
283} 286}
284 287
285void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 288void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
286{ 289{
290 unsigned long flags;
291
292 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
287 WREG32(RS480_NB_MC_INDEX, ((reg) & 0xff) | RS480_NB_MC_IND_WR_EN); 293 WREG32(RS480_NB_MC_INDEX, ((reg) & 0xff) | RS480_NB_MC_IND_WR_EN);
288 WREG32(RS480_NB_MC_DATA, (v)); 294 WREG32(RS480_NB_MC_DATA, (v));
289 WREG32(RS480_NB_MC_INDEX, 0xff); 295 WREG32(RS480_NB_MC_INDEX, 0xff);
296 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
290} 297}
291 298
292#if defined(CONFIG_DEBUG_FS) 299#if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 670b555d2ca2..6acba8017b9a 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -847,16 +847,26 @@ void rs600_bandwidth_update(struct radeon_device *rdev)
847 847
848uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg) 848uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg)
849{ 849{
850 unsigned long flags;
851 u32 r;
852
853 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
850 WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | 854 WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) |
851 S_000070_MC_IND_CITF_ARB0(1)); 855 S_000070_MC_IND_CITF_ARB0(1));
852 return RREG32(R_000074_MC_IND_DATA); 856 r = RREG32(R_000074_MC_IND_DATA);
857 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
858 return r;
853} 859}
854 860
855void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 861void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
856{ 862{
863 unsigned long flags;
864
865 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
857 WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | 866 WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) |
858 S_000070_MC_IND_CITF_ARB0(1) | S_000070_MC_IND_WR_EN(1)); 867 S_000070_MC_IND_CITF_ARB0(1) | S_000070_MC_IND_WR_EN(1));
859 WREG32(R_000074_MC_IND_DATA, v); 868 WREG32(R_000074_MC_IND_DATA, v);
869 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
860} 870}
861 871
862static void rs600_debugfs(struct radeon_device *rdev) 872static void rs600_debugfs(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index d8ddfb34545d..1447d794c22a 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -631,20 +631,27 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
631 631
632uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg) 632uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg)
633{ 633{
634 unsigned long flags;
634 uint32_t r; 635 uint32_t r;
635 636
637 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
636 WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg)); 638 WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg));
637 r = RREG32(R_00007C_MC_DATA); 639 r = RREG32(R_00007C_MC_DATA);
638 WREG32(R_000078_MC_INDEX, ~C_000078_MC_IND_ADDR); 640 WREG32(R_000078_MC_INDEX, ~C_000078_MC_IND_ADDR);
641 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
639 return r; 642 return r;
640} 643}
641 644
642void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 645void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
643{ 646{
647 unsigned long flags;
648
649 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
644 WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg) | 650 WREG32(R_000078_MC_INDEX, S_000078_MC_IND_ADDR(reg) |
645 S_000078_MC_IND_WR_EN(1)); 651 S_000078_MC_IND_WR_EN(1));
646 WREG32(R_00007C_MC_DATA, v); 652 WREG32(R_00007C_MC_DATA, v);
647 WREG32(R_000078_MC_INDEX, 0x7F); 653 WREG32(R_000078_MC_INDEX, 0x7F);
654 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
648} 655}
649 656
650static void rs690_mc_program(struct radeon_device *rdev) 657static void rs690_mc_program(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c
index d1a1ce73bd45..6af8505cf4d2 100644
--- a/drivers/gpu/drm/radeon/rs780_dpm.c
+++ b/drivers/gpu/drm/radeon/rs780_dpm.c
@@ -62,9 +62,7 @@ static void rs780_get_pm_mode_parameters(struct radeon_device *rdev)
62 radeon_crtc = to_radeon_crtc(crtc); 62 radeon_crtc = to_radeon_crtc(crtc);
63 pi->crtc_id = radeon_crtc->crtc_id; 63 pi->crtc_id = radeon_crtc->crtc_id;
64 if (crtc->mode.htotal && crtc->mode.vtotal) 64 if (crtc->mode.htotal && crtc->mode.vtotal)
65 pi->refresh_rate = 65 pi->refresh_rate = drm_mode_vrefresh(&crtc->mode);
66 (crtc->mode.clock * 1000) /
67 (crtc->mode.htotal * crtc->mode.vtotal);
68 break; 66 break;
69 } 67 }
70 } 68 }
@@ -376,9 +374,8 @@ static void rs780_disable_vbios_powersaving(struct radeon_device *rdev)
376 WREG32_P(CG_INTGFX_MISC, 0, ~0xFFF00000); 374 WREG32_P(CG_INTGFX_MISC, 0, ~0xFFF00000);
377} 375}
378 376
379static void rs780_force_voltage_to_high(struct radeon_device *rdev) 377static void rs780_force_voltage(struct radeon_device *rdev, u16 voltage)
380{ 378{
381 struct igp_power_info *pi = rs780_get_pi(rdev);
382 struct igp_ps *current_state = rs780_get_ps(rdev->pm.dpm.current_ps); 379 struct igp_ps *current_state = rs780_get_ps(rdev->pm.dpm.current_ps);
383 380
384 if ((current_state->max_voltage == RS780_VDDC_LEVEL_HIGH) && 381 if ((current_state->max_voltage == RS780_VDDC_LEVEL_HIGH) &&
@@ -390,7 +387,7 @@ static void rs780_force_voltage_to_high(struct radeon_device *rdev)
390 udelay(1); 387 udelay(1);
391 388
392 WREG32_P(FVTHROT_PWM_CTRL_REG0, 389 WREG32_P(FVTHROT_PWM_CTRL_REG0,
393 STARTING_PWM_HIGHTIME(pi->max_voltage), 390 STARTING_PWM_HIGHTIME(voltage),
394 ~STARTING_PWM_HIGHTIME_MASK); 391 ~STARTING_PWM_HIGHTIME_MASK);
395 392
396 WREG32_P(FVTHROT_PWM_CTRL_REG0, 393 WREG32_P(FVTHROT_PWM_CTRL_REG0,
@@ -404,6 +401,26 @@ static void rs780_force_voltage_to_high(struct radeon_device *rdev)
404 WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL); 401 WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL);
405} 402}
406 403
404static void rs780_force_fbdiv(struct radeon_device *rdev, u32 fb_div)
405{
406 struct igp_ps *current_state = rs780_get_ps(rdev->pm.dpm.current_ps);
407
408 if (current_state->sclk_low == current_state->sclk_high)
409 return;
410
411 WREG32_P(GFX_MACRO_BYPASS_CNTL, SPLL_BYPASS_CNTL, ~SPLL_BYPASS_CNTL);
412
413 WREG32_P(FVTHROT_FBDIV_REG2, FORCED_FEEDBACK_DIV(fb_div),
414 ~FORCED_FEEDBACK_DIV_MASK);
415 WREG32_P(FVTHROT_FBDIV_REG1, STARTING_FEEDBACK_DIV(fb_div),
416 ~STARTING_FEEDBACK_DIV_MASK);
417 WREG32_P(FVTHROT_FBDIV_REG1, FORCE_FEEDBACK_DIV, ~FORCE_FEEDBACK_DIV);
418
419 udelay(100);
420
421 WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL);
422}
423
407static int rs780_set_engine_clock_scaling(struct radeon_device *rdev, 424static int rs780_set_engine_clock_scaling(struct radeon_device *rdev,
408 struct radeon_ps *new_ps, 425 struct radeon_ps *new_ps,
409 struct radeon_ps *old_ps) 426 struct radeon_ps *old_ps)
@@ -432,17 +449,13 @@ static int rs780_set_engine_clock_scaling(struct radeon_device *rdev,
432 if (ret) 449 if (ret)
433 return ret; 450 return ret;
434 451
435 WREG32_P(GFX_MACRO_BYPASS_CNTL, SPLL_BYPASS_CNTL, ~SPLL_BYPASS_CNTL); 452 if ((min_dividers.ref_div != max_dividers.ref_div) ||
436 453 (min_dividers.post_div != max_dividers.post_div) ||
437 WREG32_P(FVTHROT_FBDIV_REG2, FORCED_FEEDBACK_DIV(max_dividers.fb_div), 454 (max_dividers.ref_div != current_max_dividers.ref_div) ||
438 ~FORCED_FEEDBACK_DIV_MASK); 455 (max_dividers.post_div != current_max_dividers.post_div))
439 WREG32_P(FVTHROT_FBDIV_REG1, STARTING_FEEDBACK_DIV(max_dividers.fb_div), 456 return -EINVAL;
440 ~STARTING_FEEDBACK_DIV_MASK);
441 WREG32_P(FVTHROT_FBDIV_REG1, FORCE_FEEDBACK_DIV, ~FORCE_FEEDBACK_DIV);
442
443 udelay(100);
444 457
445 WREG32_P(GFX_MACRO_BYPASS_CNTL, 0, ~SPLL_BYPASS_CNTL); 458 rs780_force_fbdiv(rdev, max_dividers.fb_div);
446 459
447 if (max_dividers.fb_div > min_dividers.fb_div) { 460 if (max_dividers.fb_div > min_dividers.fb_div) {
448 WREG32_P(FVTHROT_FBDIV_REG0, 461 WREG32_P(FVTHROT_FBDIV_REG0,
@@ -486,6 +499,9 @@ static void rs780_activate_engine_clk_scaling(struct radeon_device *rdev,
486 (new_state->sclk_low == old_state->sclk_low)) 499 (new_state->sclk_low == old_state->sclk_low))
487 return; 500 return;
488 501
502 if (new_state->sclk_high == new_state->sclk_low)
503 return;
504
489 rs780_clk_scaling_enable(rdev, true); 505 rs780_clk_scaling_enable(rdev, true);
490} 506}
491 507
@@ -649,7 +665,7 @@ int rs780_dpm_set_power_state(struct radeon_device *rdev)
649 rs780_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); 665 rs780_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
650 666
651 if (pi->voltage_control) { 667 if (pi->voltage_control) {
652 rs780_force_voltage_to_high(rdev); 668 rs780_force_voltage(rdev, pi->max_voltage);
653 mdelay(5); 669 mdelay(5);
654 } 670 }
655 671
@@ -717,14 +733,18 @@ static void rs780_parse_pplib_non_clock_info(struct radeon_device *rdev,
717 if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { 733 if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) {
718 rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); 734 rps->vclk = le32_to_cpu(non_clock_info->ulVCLK);
719 rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); 735 rps->dclk = le32_to_cpu(non_clock_info->ulDCLK);
720 } else if (r600_is_uvd_state(rps->class, rps->class2)) {
721 rps->vclk = RS780_DEFAULT_VCLK_FREQ;
722 rps->dclk = RS780_DEFAULT_DCLK_FREQ;
723 } else { 736 } else {
724 rps->vclk = 0; 737 rps->vclk = 0;
725 rps->dclk = 0; 738 rps->dclk = 0;
726 } 739 }
727 740
741 if (r600_is_uvd_state(rps->class, rps->class2)) {
742 if ((rps->vclk == 0) || (rps->dclk == 0)) {
743 rps->vclk = RS780_DEFAULT_VCLK_FREQ;
744 rps->dclk = RS780_DEFAULT_DCLK_FREQ;
745 }
746 }
747
728 if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) 748 if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT)
729 rdev->pm.dpm.boot_ps = rps; 749 rdev->pm.dpm.boot_ps = rps;
730 if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) 750 if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
@@ -986,3 +1006,55 @@ void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rde
986 seq_printf(m, "power level 1 sclk: %u vddc_index: %d\n", 1006 seq_printf(m, "power level 1 sclk: %u vddc_index: %d\n",
987 ps->sclk_high, ps->max_voltage); 1007 ps->sclk_high, ps->max_voltage);
988} 1008}
1009
1010int rs780_dpm_force_performance_level(struct radeon_device *rdev,
1011 enum radeon_dpm_forced_level level)
1012{
1013 struct igp_power_info *pi = rs780_get_pi(rdev);
1014 struct radeon_ps *rps = rdev->pm.dpm.current_ps;
1015 struct igp_ps *ps = rs780_get_ps(rps);
1016 struct atom_clock_dividers dividers;
1017 int ret;
1018
1019 rs780_clk_scaling_enable(rdev, false);
1020 rs780_voltage_scaling_enable(rdev, false);
1021
1022 if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
1023 if (pi->voltage_control)
1024 rs780_force_voltage(rdev, pi->max_voltage);
1025
1026 ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
1027 ps->sclk_high, false, &dividers);
1028 if (ret)
1029 return ret;
1030
1031 rs780_force_fbdiv(rdev, dividers.fb_div);
1032 } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
1033 ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
1034 ps->sclk_low, false, &dividers);
1035 if (ret)
1036 return ret;
1037
1038 rs780_force_fbdiv(rdev, dividers.fb_div);
1039
1040 if (pi->voltage_control)
1041 rs780_force_voltage(rdev, pi->min_voltage);
1042 } else {
1043 if (pi->voltage_control)
1044 rs780_force_voltage(rdev, pi->max_voltage);
1045
1046 if (ps->sclk_high != ps->sclk_low) {
1047 WREG32_P(FVTHROT_FBDIV_REG1, 0, ~FORCE_FEEDBACK_DIV);
1048 rs780_clk_scaling_enable(rdev, true);
1049 }
1050
1051 if (pi->voltage_control) {
1052 rs780_voltage_scaling_enable(rdev, true);
1053 rs780_enable_voltage_scaling(rdev, rps);
1054 }
1055 }
1056
1057 rdev->pm.dpm.forced_level = level;
1058
1059 return 0;
1060}
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 8ea1573ae820..873eb4b193b4 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -209,19 +209,27 @@ static void rv515_mc_init(struct radeon_device *rdev)
209 209
210uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg) 210uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg)
211{ 211{
212 unsigned long flags;
212 uint32_t r; 213 uint32_t r;
213 214
215 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
214 WREG32(MC_IND_INDEX, 0x7f0000 | (reg & 0xffff)); 216 WREG32(MC_IND_INDEX, 0x7f0000 | (reg & 0xffff));
215 r = RREG32(MC_IND_DATA); 217 r = RREG32(MC_IND_DATA);
216 WREG32(MC_IND_INDEX, 0); 218 WREG32(MC_IND_INDEX, 0);
219 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
220
217 return r; 221 return r;
218} 222}
219 223
220void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 224void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
221{ 225{
226 unsigned long flags;
227
228 spin_lock_irqsave(&rdev->mc_idx_lock, flags);
222 WREG32(MC_IND_INDEX, 0xff0000 | ((reg) & 0xffff)); 229 WREG32(MC_IND_INDEX, 0xff0000 | ((reg) & 0xffff));
223 WREG32(MC_IND_DATA, (v)); 230 WREG32(MC_IND_DATA, (v));
224 WREG32(MC_IND_INDEX, 0); 231 WREG32(MC_IND_INDEX, 0);
232 spin_unlock_irqrestore(&rdev->mc_idx_lock, flags);
225} 233}
226 234
227#if defined(CONFIG_DEBUG_FS) 235#if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index ab1f2016f21e..5811d277a36a 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -1758,8 +1758,6 @@ int rv6xx_dpm_set_power_state(struct radeon_device *rdev)
1758 1758
1759 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);
1760 1760
1761 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
1762
1763 return 0; 1761 return 0;
1764} 1762}
1765 1763
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index 8cbb85dae5aa..913b025ae9b3 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -2064,12 +2064,6 @@ int rv770_dpm_set_power_state(struct radeon_device *rdev)
2064 rv770_program_dcodt_after_state_switch(rdev, new_ps, old_ps); 2064 rv770_program_dcodt_after_state_switch(rdev, new_ps, old_ps);
2065 rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); 2065 rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
2066 2066
2067 ret = rv770_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
2068 if (ret) {
2069 DRM_ERROR("rv770_dpm_force_performance_level failed\n");
2070 return ret;
2071 }
2072
2073 return 0; 2067 return 0;
2074} 2068}
2075 2069
@@ -2147,14 +2141,18 @@ static void rv7xx_parse_pplib_non_clock_info(struct radeon_device *rdev,
2147 if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { 2141 if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) {
2148 rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); 2142 rps->vclk = le32_to_cpu(non_clock_info->ulVCLK);
2149 rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); 2143 rps->dclk = le32_to_cpu(non_clock_info->ulDCLK);
2150 } else if (r600_is_uvd_state(rps->class, rps->class2)) {
2151 rps->vclk = RV770_DEFAULT_VCLK_FREQ;
2152 rps->dclk = RV770_DEFAULT_DCLK_FREQ;
2153 } else { 2144 } else {
2154 rps->vclk = 0; 2145 rps->vclk = 0;
2155 rps->dclk = 0; 2146 rps->dclk = 0;
2156 } 2147 }
2157 2148
2149 if (r600_is_uvd_state(rps->class, rps->class2)) {
2150 if ((rps->vclk == 0) || (rps->dclk == 0)) {
2151 rps->vclk = RV770_DEFAULT_VCLK_FREQ;
2152 rps->dclk = RV770_DEFAULT_DCLK_FREQ;
2153 }
2154 }
2155
2158 if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) 2156 if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT)
2159 rdev->pm.dpm.boot_ps = rps; 2157 rdev->pm.dpm.boot_ps = rps;
2160 if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) 2158 if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
diff --git a/drivers/gpu/drm/radeon/rv770_smc.c b/drivers/gpu/drm/radeon/rv770_smc.c
index ab95da570215..b2a224407365 100644
--- a/drivers/gpu/drm/radeon/rv770_smc.c
+++ b/drivers/gpu/drm/radeon/rv770_smc.c
@@ -274,8 +274,8 @@ static const u8 cayman_smc_int_vectors[] =
274 0x08, 0x72, 0x08, 0x72 274 0x08, 0x72, 0x08, 0x72
275}; 275};
276 276
277int rv770_set_smc_sram_address(struct radeon_device *rdev, 277static int rv770_set_smc_sram_address(struct radeon_device *rdev,
278 u16 smc_address, u16 limit) 278 u16 smc_address, u16 limit)
279{ 279{
280 u32 addr; 280 u32 addr;
281 281
@@ -296,9 +296,10 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev,
296 u16 smc_start_address, const u8 *src, 296 u16 smc_start_address, const u8 *src,
297 u16 byte_count, u16 limit) 297 u16 byte_count, u16 limit)
298{ 298{
299 unsigned long flags;
299 u32 data, original_data, extra_shift; 300 u32 data, original_data, extra_shift;
300 u16 addr; 301 u16 addr;
301 int ret; 302 int ret = 0;
302 303
303 if (smc_start_address & 3) 304 if (smc_start_address & 3)
304 return -EINVAL; 305 return -EINVAL;
@@ -307,13 +308,14 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev,
307 308
308 addr = smc_start_address; 309 addr = smc_start_address;
309 310
311 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
310 while (byte_count >= 4) { 312 while (byte_count >= 4) {
311 /* SMC address space is BE */ 313 /* SMC address space is BE */
312 data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; 314 data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
313 315
314 ret = rv770_set_smc_sram_address(rdev, addr, limit); 316 ret = rv770_set_smc_sram_address(rdev, addr, limit);
315 if (ret) 317 if (ret)
316 return ret; 318 goto done;
317 319
318 WREG32(SMC_SRAM_DATA, data); 320 WREG32(SMC_SRAM_DATA, data);
319 321
@@ -328,7 +330,7 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev,
328 330
329 ret = rv770_set_smc_sram_address(rdev, addr, limit); 331 ret = rv770_set_smc_sram_address(rdev, addr, limit);
330 if (ret) 332 if (ret)
331 return ret; 333 goto done;
332 334
333 original_data = RREG32(SMC_SRAM_DATA); 335 original_data = RREG32(SMC_SRAM_DATA);
334 336
@@ -346,12 +348,15 @@ int rv770_copy_bytes_to_smc(struct radeon_device *rdev,
346 348
347 ret = rv770_set_smc_sram_address(rdev, addr, limit); 349 ret = rv770_set_smc_sram_address(rdev, addr, limit);
348 if (ret) 350 if (ret)
349 return ret; 351 goto done;
350 352
351 WREG32(SMC_SRAM_DATA, data); 353 WREG32(SMC_SRAM_DATA, data);
352 } 354 }
353 355
354 return 0; 356done:
357 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
358
359 return ret;
355} 360}
356 361
357static int rv770_program_interrupt_vectors(struct radeon_device *rdev, 362static int rv770_program_interrupt_vectors(struct radeon_device *rdev,
@@ -461,12 +466,15 @@ PPSMC_Result rv770_wait_for_smc_inactive(struct radeon_device *rdev)
461 466
462static void rv770_clear_smc_sram(struct radeon_device *rdev, u16 limit) 467static void rv770_clear_smc_sram(struct radeon_device *rdev, u16 limit)
463{ 468{
469 unsigned long flags;
464 u16 i; 470 u16 i;
465 471
472 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
466 for (i = 0; i < limit; i += 4) { 473 for (i = 0; i < limit; i += 4) {
467 rv770_set_smc_sram_address(rdev, i, limit); 474 rv770_set_smc_sram_address(rdev, i, limit);
468 WREG32(SMC_SRAM_DATA, 0); 475 WREG32(SMC_SRAM_DATA, 0);
469 } 476 }
477 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
470} 478}
471 479
472int rv770_load_smc_ucode(struct radeon_device *rdev, 480int rv770_load_smc_ucode(struct radeon_device *rdev,
@@ -595,27 +603,29 @@ int rv770_load_smc_ucode(struct radeon_device *rdev,
595int rv770_read_smc_sram_dword(struct radeon_device *rdev, 603int rv770_read_smc_sram_dword(struct radeon_device *rdev,
596 u16 smc_address, u32 *value, u16 limit) 604 u16 smc_address, u32 *value, u16 limit)
597{ 605{
606 unsigned long flags;
598 int ret; 607 int ret;
599 608
609 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
600 ret = rv770_set_smc_sram_address(rdev, smc_address, limit); 610 ret = rv770_set_smc_sram_address(rdev, smc_address, limit);
601 if (ret) 611 if (ret == 0)
602 return ret; 612 *value = RREG32(SMC_SRAM_DATA);
603 613 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
604 *value = RREG32(SMC_SRAM_DATA);
605 614
606 return 0; 615 return ret;
607} 616}
608 617
609int rv770_write_smc_sram_dword(struct radeon_device *rdev, 618int rv770_write_smc_sram_dword(struct radeon_device *rdev,
610 u16 smc_address, u32 value, u16 limit) 619 u16 smc_address, u32 value, u16 limit)
611{ 620{
621 unsigned long flags;
612 int ret; 622 int ret;
613 623
624 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
614 ret = rv770_set_smc_sram_address(rdev, smc_address, limit); 625 ret = rv770_set_smc_sram_address(rdev, smc_address, limit);
615 if (ret) 626 if (ret == 0)
616 return ret; 627 WREG32(SMC_SRAM_DATA, value);
628 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
617 629
618 WREG32(SMC_SRAM_DATA, value); 630 return ret;
619
620 return 0;
621} 631}
diff --git a/drivers/gpu/drm/radeon/rv770_smc.h b/drivers/gpu/drm/radeon/rv770_smc.h
index f78d92a4b325..3b2c963c4880 100644
--- a/drivers/gpu/drm/radeon/rv770_smc.h
+++ b/drivers/gpu/drm/radeon/rv770_smc.h
@@ -187,8 +187,6 @@ typedef struct RV770_SMC_STATETABLE RV770_SMC_STATETABLE;
187#define RV770_SMC_SOFT_REGISTER_uvd_enabled 0x9C 187#define RV770_SMC_SOFT_REGISTER_uvd_enabled 0x9C
188#define RV770_SMC_SOFT_REGISTER_is_asic_lombok 0xA0 188#define RV770_SMC_SOFT_REGISTER_is_asic_lombok 0xA0
189 189
190int rv770_set_smc_sram_address(struct radeon_device *rdev,
191 u16 smc_address, u16 limit);
192int rv770_copy_bytes_to_smc(struct radeon_device *rdev, 190int rv770_copy_bytes_to_smc(struct radeon_device *rdev,
193 u16 smc_start_address, const u8 *src, 191 u16 smc_start_address, const u8 *src,
194 u16 byte_count, u16 limit); 192 u16 byte_count, u16 limit);
diff --git a/drivers/gpu/drm/radeon/rv770d.h b/drivers/gpu/drm/radeon/rv770d.h
index 9fe60e542922..1ae277152cc7 100644
--- a/drivers/gpu/drm/radeon/rv770d.h
+++ b/drivers/gpu/drm/radeon/rv770d.h
@@ -852,7 +852,7 @@
852#define AFMT_VBI_PACKET_CONTROL 0x7608 852#define AFMT_VBI_PACKET_CONTROL 0x7608
853# define AFMT_GENERIC0_UPDATE (1 << 2) 853# define AFMT_GENERIC0_UPDATE (1 << 2)
854#define AFMT_INFOFRAME_CONTROL0 0x760c 854#define AFMT_INFOFRAME_CONTROL0 0x760c
855# define AFMT_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hmdi regs */ 855# define AFMT_AUDIO_INFO_SOURCE (1 << 6) /* 0 - sound block; 1 - hdmi regs */
856# define AFMT_AUDIO_INFO_UPDATE (1 << 7) 856# define AFMT_AUDIO_INFO_UPDATE (1 << 7)
857# define AFMT_MPEG_INFO_UPDATE (1 << 10) 857# define AFMT_MPEG_INFO_UPDATE (1 << 10)
858#define AFMT_GENERIC0_7 0x7610 858#define AFMT_GENERIC0_7 0x7610
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 3e23b757dcfa..c354c1094967 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -83,6 +83,8 @@ extern void si_dma_vm_set_page(struct radeon_device *rdev,
83 uint64_t pe, 83 uint64_t pe,
84 uint64_t addr, unsigned count, 84 uint64_t addr, unsigned count,
85 uint32_t incr, uint32_t flags); 85 uint32_t incr, uint32_t flags);
86static void si_enable_gui_idle_interrupt(struct radeon_device *rdev,
87 bool enable);
86 88
87static const u32 verde_rlc_save_restore_register_list[] = 89static const u32 verde_rlc_save_restore_register_list[] =
88{ 90{
@@ -3386,6 +3388,8 @@ static int si_cp_resume(struct radeon_device *rdev)
3386 u32 rb_bufsz; 3388 u32 rb_bufsz;
3387 int r; 3389 int r;
3388 3390
3391 si_enable_gui_idle_interrupt(rdev, false);
3392
3389 WREG32(CP_SEM_WAIT_TIMER, 0x0); 3393 WREG32(CP_SEM_WAIT_TIMER, 0x0);
3390 WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); 3394 WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0);
3391 3395
@@ -3501,6 +3505,8 @@ static int si_cp_resume(struct radeon_device *rdev)
3501 rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false; 3505 rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false;
3502 } 3506 }
3503 3507
3508 si_enable_gui_idle_interrupt(rdev, true);
3509
3504 return 0; 3510 return 0;
3505} 3511}
3506 3512
@@ -4888,7 +4894,7 @@ static void si_enable_gfx_cgpg(struct radeon_device *rdev,
4888{ 4894{
4889 u32 tmp; 4895 u32 tmp;
4890 4896
4891 if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG)) { 4897 if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG)) {
4892 tmp = RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10); 4898 tmp = RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10);
4893 WREG32(RLC_TTOP_D, tmp); 4899 WREG32(RLC_TTOP_D, tmp);
4894 4900
@@ -5250,6 +5256,7 @@ void si_update_cg(struct radeon_device *rdev,
5250 u32 block, bool enable) 5256 u32 block, bool enable)
5251{ 5257{
5252 if (block & RADEON_CG_BLOCK_GFX) { 5258 if (block & RADEON_CG_BLOCK_GFX) {
5259 si_enable_gui_idle_interrupt(rdev, false);
5253 /* order matters! */ 5260 /* order matters! */
5254 if (enable) { 5261 if (enable) {
5255 si_enable_mgcg(rdev, true); 5262 si_enable_mgcg(rdev, true);
@@ -5258,6 +5265,7 @@ void si_update_cg(struct radeon_device *rdev,
5258 si_enable_cgcg(rdev, false); 5265 si_enable_cgcg(rdev, false);
5259 si_enable_mgcg(rdev, false); 5266 si_enable_mgcg(rdev, false);
5260 } 5267 }
5268 si_enable_gui_idle_interrupt(rdev, true);
5261 } 5269 }
5262 5270
5263 if (block & RADEON_CG_BLOCK_MC) { 5271 if (block & RADEON_CG_BLOCK_MC) {
@@ -5408,7 +5416,7 @@ static void si_init_pg(struct radeon_device *rdev)
5408 si_init_dma_pg(rdev); 5416 si_init_dma_pg(rdev);
5409 } 5417 }
5410 si_init_ao_cu_mask(rdev); 5418 si_init_ao_cu_mask(rdev);
5411 if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_CG) { 5419 if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) {
5412 si_init_gfx_cgpg(rdev); 5420 si_init_gfx_cgpg(rdev);
5413 } 5421 }
5414 si_enable_dma_pg(rdev, true); 5422 si_enable_dma_pg(rdev, true);
@@ -5560,7 +5568,9 @@ static void si_disable_interrupt_state(struct radeon_device *rdev)
5560{ 5568{
5561 u32 tmp; 5569 u32 tmp;
5562 5570
5563 WREG32(CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); 5571 tmp = RREG32(CP_INT_CNTL_RING0) &
5572 (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE);
5573 WREG32(CP_INT_CNTL_RING0, tmp);
5564 WREG32(CP_INT_CNTL_RING1, 0); 5574 WREG32(CP_INT_CNTL_RING1, 0);
5565 WREG32(CP_INT_CNTL_RING2, 0); 5575 WREG32(CP_INT_CNTL_RING2, 0);
5566 tmp = RREG32(DMA_CNTL + DMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; 5576 tmp = RREG32(DMA_CNTL + DMA0_REGISTER_OFFSET) & ~TRAP_ENABLE;
@@ -5685,7 +5695,7 @@ static int si_irq_init(struct radeon_device *rdev)
5685 5695
5686int si_irq_set(struct radeon_device *rdev) 5696int si_irq_set(struct radeon_device *rdev)
5687{ 5697{
5688 u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE; 5698 u32 cp_int_cntl;
5689 u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0; 5699 u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0;
5690 u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; 5700 u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0;
5691 u32 hpd1 = 0, hpd2 = 0, hpd3 = 0, hpd4 = 0, hpd5 = 0, hpd6 = 0; 5701 u32 hpd1 = 0, hpd2 = 0, hpd3 = 0, hpd4 = 0, hpd5 = 0, hpd6 = 0;
@@ -5706,6 +5716,9 @@ int si_irq_set(struct radeon_device *rdev)
5706 return 0; 5716 return 0;
5707 } 5717 }
5708 5718
5719 cp_int_cntl = RREG32(CP_INT_CNTL_RING0) &
5720 (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE);
5721
5709 if (!ASIC_IS_NODCE(rdev)) { 5722 if (!ASIC_IS_NODCE(rdev)) {
5710 hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; 5723 hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN;
5711 hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; 5724 hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN;
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 5be9b4e72350..cfe5d4d28915 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -6075,12 +6075,6 @@ int si_dpm_set_power_state(struct radeon_device *rdev)
6075 return ret; 6075 return ret;
6076 } 6076 }
6077 6077
6078 ret = si_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
6079 if (ret) {
6080 DRM_ERROR("si_dpm_force_performance_level failed\n");
6081 return ret;
6082 }
6083
6084 si_update_cg(rdev, (RADEON_CG_BLOCK_GFX | 6078 si_update_cg(rdev, (RADEON_CG_BLOCK_GFX |
6085 RADEON_CG_BLOCK_MC | 6079 RADEON_CG_BLOCK_MC |
6086 RADEON_CG_BLOCK_SDMA | 6080 RADEON_CG_BLOCK_SDMA |
diff --git a/drivers/gpu/drm/radeon/si_smc.c b/drivers/gpu/drm/radeon/si_smc.c
index 5f524c0a541e..d422a1cbf727 100644
--- a/drivers/gpu/drm/radeon/si_smc.c
+++ b/drivers/gpu/drm/radeon/si_smc.c
@@ -29,8 +29,8 @@
29#include "ppsmc.h" 29#include "ppsmc.h"
30#include "radeon_ucode.h" 30#include "radeon_ucode.h"
31 31
32int si_set_smc_sram_address(struct radeon_device *rdev, 32static int si_set_smc_sram_address(struct radeon_device *rdev,
33 u32 smc_address, u32 limit) 33 u32 smc_address, u32 limit)
34{ 34{
35 if (smc_address & 3) 35 if (smc_address & 3)
36 return -EINVAL; 36 return -EINVAL;
@@ -47,7 +47,8 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev,
47 u32 smc_start_address, 47 u32 smc_start_address,
48 const u8 *src, u32 byte_count, u32 limit) 48 const u8 *src, u32 byte_count, u32 limit)
49{ 49{
50 int ret; 50 unsigned long flags;
51 int ret = 0;
51 u32 data, original_data, addr, extra_shift; 52 u32 data, original_data, addr, extra_shift;
52 53
53 if (smc_start_address & 3) 54 if (smc_start_address & 3)
@@ -57,13 +58,14 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev,
57 58
58 addr = smc_start_address; 59 addr = smc_start_address;
59 60
61 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
60 while (byte_count >= 4) { 62 while (byte_count >= 4) {
61 /* SMC address space is BE */ 63 /* SMC address space is BE */
62 data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; 64 data = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
63 65
64 ret = si_set_smc_sram_address(rdev, addr, limit); 66 ret = si_set_smc_sram_address(rdev, addr, limit);
65 if (ret) 67 if (ret)
66 return ret; 68 goto done;
67 69
68 WREG32(SMC_IND_DATA_0, data); 70 WREG32(SMC_IND_DATA_0, data);
69 71
@@ -78,7 +80,7 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev,
78 80
79 ret = si_set_smc_sram_address(rdev, addr, limit); 81 ret = si_set_smc_sram_address(rdev, addr, limit);
80 if (ret) 82 if (ret)
81 return ret; 83 goto done;
82 84
83 original_data = RREG32(SMC_IND_DATA_0); 85 original_data = RREG32(SMC_IND_DATA_0);
84 86
@@ -96,11 +98,15 @@ int si_copy_bytes_to_smc(struct radeon_device *rdev,
96 98
97 ret = si_set_smc_sram_address(rdev, addr, limit); 99 ret = si_set_smc_sram_address(rdev, addr, limit);
98 if (ret) 100 if (ret)
99 return ret; 101 goto done;
100 102
101 WREG32(SMC_IND_DATA_0, data); 103 WREG32(SMC_IND_DATA_0, data);
102 } 104 }
103 return 0; 105
106done:
107 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
108
109 return ret;
104} 110}
105 111
106void si_start_smc(struct radeon_device *rdev) 112void si_start_smc(struct radeon_device *rdev)
@@ -203,6 +209,7 @@ PPSMC_Result si_wait_for_smc_inactive(struct radeon_device *rdev)
203 209
204int si_load_smc_ucode(struct radeon_device *rdev, u32 limit) 210int si_load_smc_ucode(struct radeon_device *rdev, u32 limit)
205{ 211{
212 unsigned long flags;
206 u32 ucode_start_address; 213 u32 ucode_start_address;
207 u32 ucode_size; 214 u32 ucode_size;
208 const u8 *src; 215 const u8 *src;
@@ -241,6 +248,7 @@ int si_load_smc_ucode(struct radeon_device *rdev, u32 limit)
241 return -EINVAL; 248 return -EINVAL;
242 249
243 src = (const u8 *)rdev->smc_fw->data; 250 src = (const u8 *)rdev->smc_fw->data;
251 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
244 WREG32(SMC_IND_INDEX_0, ucode_start_address); 252 WREG32(SMC_IND_INDEX_0, ucode_start_address);
245 WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0); 253 WREG32_P(SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, ~AUTO_INCREMENT_IND_0);
246 while (ucode_size >= 4) { 254 while (ucode_size >= 4) {
@@ -253,6 +261,7 @@ int si_load_smc_ucode(struct radeon_device *rdev, u32 limit)
253 ucode_size -= 4; 261 ucode_size -= 4;
254 } 262 }
255 WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0); 263 WREG32_P(SMC_IND_ACCESS_CNTL, 0, ~AUTO_INCREMENT_IND_0);
264 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
256 265
257 return 0; 266 return 0;
258} 267}
@@ -260,25 +269,29 @@ int si_load_smc_ucode(struct radeon_device *rdev, u32 limit)
260int si_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, 269int si_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address,
261 u32 *value, u32 limit) 270 u32 *value, u32 limit)
262{ 271{
272 unsigned long flags;
263 int ret; 273 int ret;
264 274
275 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
265 ret = si_set_smc_sram_address(rdev, smc_address, limit); 276 ret = si_set_smc_sram_address(rdev, smc_address, limit);
266 if (ret) 277 if (ret == 0)
267 return ret; 278 *value = RREG32(SMC_IND_DATA_0);
279 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
268 280
269 *value = RREG32(SMC_IND_DATA_0); 281 return ret;
270 return 0;
271} 282}
272 283
273int si_write_smc_sram_dword(struct radeon_device *rdev, u32 smc_address, 284int si_write_smc_sram_dword(struct radeon_device *rdev, u32 smc_address,
274 u32 value, u32 limit) 285 u32 value, u32 limit)
275{ 286{
287 unsigned long flags;
276 int ret; 288 int ret;
277 289
290 spin_lock_irqsave(&rdev->smc_idx_lock, flags);
278 ret = si_set_smc_sram_address(rdev, smc_address, limit); 291 ret = si_set_smc_sram_address(rdev, smc_address, limit);
279 if (ret) 292 if (ret == 0)
280 return ret; 293 WREG32(SMC_IND_DATA_0, value);
294 spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
281 295
282 WREG32(SMC_IND_DATA_0, value); 296 return ret;
283 return 0;
284} 297}
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c
index 864761c0120e..96ea6db8bf57 100644
--- a/drivers/gpu/drm/radeon/sumo_dpm.c
+++ b/drivers/gpu/drm/radeon/sumo_dpm.c
@@ -1319,8 +1319,6 @@ int sumo_dpm_set_power_state(struct radeon_device *rdev)
1319 if (pi->enable_dpm) 1319 if (pi->enable_dpm)
1320 sumo_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); 1320 sumo_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
1321 1321
1322 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
1323
1324 return 0; 1322 return 0;
1325} 1323}
1326 1324
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c
index b07b7b8f1aff..7f998bf1cc9d 100644
--- a/drivers/gpu/drm/radeon/trinity_dpm.c
+++ b/drivers/gpu/drm/radeon/trinity_dpm.c
@@ -1068,6 +1068,17 @@ static void trinity_update_requested_ps(struct radeon_device *rdev,
1068 pi->requested_rps.ps_priv = &pi->requested_ps; 1068 pi->requested_rps.ps_priv = &pi->requested_ps;
1069} 1069}
1070 1070
1071void trinity_dpm_enable_bapm(struct radeon_device *rdev, bool enable)
1072{
1073 struct trinity_power_info *pi = trinity_get_pi(rdev);
1074
1075 if (pi->enable_bapm) {
1076 trinity_acquire_mutex(rdev);
1077 trinity_dpm_bapm_enable(rdev, enable);
1078 trinity_release_mutex(rdev);
1079 }
1080}
1081
1071int trinity_dpm_enable(struct radeon_device *rdev) 1082int trinity_dpm_enable(struct radeon_device *rdev)
1072{ 1083{
1073 struct trinity_power_info *pi = trinity_get_pi(rdev); 1084 struct trinity_power_info *pi = trinity_get_pi(rdev);
@@ -1091,6 +1102,7 @@ int trinity_dpm_enable(struct radeon_device *rdev)
1091 trinity_program_sclk_dpm(rdev); 1102 trinity_program_sclk_dpm(rdev);
1092 trinity_start_dpm(rdev); 1103 trinity_start_dpm(rdev);
1093 trinity_wait_for_dpm_enabled(rdev); 1104 trinity_wait_for_dpm_enabled(rdev);
1105 trinity_dpm_bapm_enable(rdev, false);
1094 trinity_release_mutex(rdev); 1106 trinity_release_mutex(rdev);
1095 1107
1096 if (rdev->irq.installed && 1108 if (rdev->irq.installed &&
@@ -1116,6 +1128,7 @@ void trinity_dpm_disable(struct radeon_device *rdev)
1116 trinity_release_mutex(rdev); 1128 trinity_release_mutex(rdev);
1117 return; 1129 return;
1118 } 1130 }
1131 trinity_dpm_bapm_enable(rdev, false);
1119 trinity_disable_clock_power_gating(rdev); 1132 trinity_disable_clock_power_gating(rdev);
1120 sumo_clear_vc(rdev); 1133 sumo_clear_vc(rdev);
1121 trinity_wait_for_level_0(rdev); 1134 trinity_wait_for_level_0(rdev);
@@ -1212,6 +1225,8 @@ int trinity_dpm_set_power_state(struct radeon_device *rdev)
1212 1225
1213 trinity_acquire_mutex(rdev); 1226 trinity_acquire_mutex(rdev);
1214 if (pi->enable_dpm) { 1227 if (pi->enable_dpm) {
1228 if (pi->enable_bapm)
1229 trinity_dpm_bapm_enable(rdev, rdev->pm.dpm.ac_power);
1215 trinity_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); 1230 trinity_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
1216 trinity_enable_power_level_0(rdev); 1231 trinity_enable_power_level_0(rdev);
1217 trinity_force_level_0(rdev); 1232 trinity_force_level_0(rdev);
@@ -1221,7 +1236,6 @@ int trinity_dpm_set_power_state(struct radeon_device *rdev)
1221 trinity_force_level_0(rdev); 1236 trinity_force_level_0(rdev);
1222 trinity_unforce_levels(rdev); 1237 trinity_unforce_levels(rdev);
1223 trinity_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); 1238 trinity_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
1224 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
1225 } 1239 }
1226 trinity_release_mutex(rdev); 1240 trinity_release_mutex(rdev);
1227 1241
@@ -1854,6 +1868,7 @@ int trinity_dpm_init(struct radeon_device *rdev)
1854 for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) 1868 for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++)
1855 pi->at[i] = TRINITY_AT_DFLT; 1869 pi->at[i] = TRINITY_AT_DFLT;
1856 1870
1871 pi->enable_bapm = true;
1857 pi->enable_nbps_policy = true; 1872 pi->enable_nbps_policy = true;
1858 pi->enable_sclk_ds = true; 1873 pi->enable_sclk_ds = true;
1859 pi->enable_gfx_power_gating = true; 1874 pi->enable_gfx_power_gating = true;
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.h b/drivers/gpu/drm/radeon/trinity_dpm.h
index e82df071f8b3..c261657750ca 100644
--- a/drivers/gpu/drm/radeon/trinity_dpm.h
+++ b/drivers/gpu/drm/radeon/trinity_dpm.h
@@ -108,6 +108,7 @@ struct trinity_power_info {
108 bool enable_auto_thermal_throttling; 108 bool enable_auto_thermal_throttling;
109 bool enable_dpm; 109 bool enable_dpm;
110 bool enable_sclk_ds; 110 bool enable_sclk_ds;
111 bool enable_bapm;
111 bool uvd_dpm; 112 bool uvd_dpm;
112 struct radeon_ps current_rps; 113 struct radeon_ps current_rps;
113 struct trinity_ps current_ps; 114 struct trinity_ps current_ps;
@@ -118,6 +119,7 @@ struct trinity_power_info {
118#define TRINITY_AT_DFLT 30 119#define TRINITY_AT_DFLT 30
119 120
120/* trinity_smc.c */ 121/* trinity_smc.c */
122int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable);
121int trinity_dpm_config(struct radeon_device *rdev, bool enable); 123int trinity_dpm_config(struct radeon_device *rdev, bool enable);
122int trinity_uvd_dpm_config(struct radeon_device *rdev); 124int trinity_uvd_dpm_config(struct radeon_device *rdev);
123int trinity_dpm_force_state(struct radeon_device *rdev, u32 n); 125int trinity_dpm_force_state(struct radeon_device *rdev, u32 n);
diff --git a/drivers/gpu/drm/radeon/trinity_smc.c b/drivers/gpu/drm/radeon/trinity_smc.c
index a42d89f1830c..9672bcbc7312 100644
--- a/drivers/gpu/drm/radeon/trinity_smc.c
+++ b/drivers/gpu/drm/radeon/trinity_smc.c
@@ -56,6 +56,14 @@ static int trinity_notify_message_to_smu(struct radeon_device *rdev, u32 id)
56 return 0; 56 return 0;
57} 57}
58 58
59int trinity_dpm_bapm_enable(struct radeon_device *rdev, bool enable)
60{
61 if (enable)
62 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_EnableBAPM);
63 else
64 return trinity_notify_message_to_smu(rdev, PPSMC_MSG_DisableBAPM);
65}
66
59int trinity_dpm_config(struct radeon_device *rdev, bool enable) 67int trinity_dpm_config(struct radeon_device *rdev, bool enable)
60{ 68{
61 if (enable) 69 if (enable)
diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c
index 58a5f3261c0b..a868176c258a 100644
--- a/drivers/gpu/drm/ttm/ttm_object.c
+++ b/drivers/gpu/drm/ttm/ttm_object.c
@@ -218,7 +218,7 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile,
218 uint32_t key) 218 uint32_t key)
219{ 219{
220 struct ttm_object_device *tdev = tfile->tdev; 220 struct ttm_object_device *tdev = tfile->tdev;
221 struct ttm_base_object *base; 221 struct ttm_base_object *uninitialized_var(base);
222 struct drm_hash_item *hash; 222 struct drm_hash_item *hash;
223 int ret; 223 int ret;
224 224
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 5e93a52d4f2c..210d50365162 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -170,7 +170,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
170 ttm_tt_unbind(ttm); 170 ttm_tt_unbind(ttm);
171 } 171 }
172 172
173 if (likely(ttm->pages != NULL)) { 173 if (ttm->state == tt_unbound) {
174 ttm->bdev->driver->ttm_tt_unpopulate(ttm); 174 ttm->bdev->driver->ttm_tt_unpopulate(ttm);
175 } 175 }
176 176
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 8dbe9d0ae9a7..8bf646183bac 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -97,7 +97,6 @@ int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
97 ret = vm_insert_page(vma, (unsigned long)vmf->virtual_address, page); 97 ret = vm_insert_page(vma, (unsigned long)vmf->virtual_address, page);
98 switch (ret) { 98 switch (ret) {
99 case -EAGAIN: 99 case -EAGAIN:
100 set_need_resched();
101 case 0: 100 case 0:
102 case -ERESTARTSYS: 101 case -ERESTARTSYS:
103 return VM_FAULT_NOPAGE; 102 return VM_FAULT_NOPAGE;
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ae88a97f976e..b8470b1a10fe 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -94,7 +94,6 @@ EXPORT_SYMBOL_GPL(hid_register_report);
94static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 94static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
95{ 95{
96 struct hid_field *field; 96 struct hid_field *field;
97 int i;
98 97
99 if (report->maxfield == HID_MAX_FIELDS) { 98 if (report->maxfield == HID_MAX_FIELDS) {
100 hid_err(report->device, "too many fields in report\n"); 99 hid_err(report->device, "too many fields in report\n");
@@ -113,9 +112,6 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
113 field->value = (s32 *)(field->usage + usages); 112 field->value = (s32 *)(field->usage + usages);
114 field->report = report; 113 field->report = report;
115 114
116 for (i = 0; i < usages; i++)
117 field->usage[i].usage_index = i;
118
119 return field; 115 return field;
120} 116}
121 117
@@ -226,9 +222,9 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
226{ 222{
227 struct hid_report *report; 223 struct hid_report *report;
228 struct hid_field *field; 224 struct hid_field *field;
229 int usages; 225 unsigned usages;
230 unsigned offset; 226 unsigned offset;
231 int i; 227 unsigned i;
232 228
233 report = hid_register_report(parser->device, report_type, parser->global.report_id); 229 report = hid_register_report(parser->device, report_type, parser->global.report_id);
234 if (!report) { 230 if (!report) {
@@ -255,7 +251,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
255 if (!parser->local.usage_index) /* Ignore padding fields */ 251 if (!parser->local.usage_index) /* Ignore padding fields */
256 return 0; 252 return 0;
257 253
258 usages = max_t(int, parser->local.usage_index, parser->global.report_count); 254 usages = max_t(unsigned, parser->local.usage_index,
255 parser->global.report_count);
259 256
260 field = hid_register_field(report, usages, parser->global.report_count); 257 field = hid_register_field(report, usages, parser->global.report_count);
261 if (!field) 258 if (!field)
@@ -266,13 +263,14 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
266 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 263 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
267 264
268 for (i = 0; i < usages; i++) { 265 for (i = 0; i < usages; i++) {
269 int j = i; 266 unsigned j = i;
270 /* Duplicate the last usage we parsed if we have excess values */ 267 /* Duplicate the last usage we parsed if we have excess values */
271 if (i >= parser->local.usage_index) 268 if (i >= parser->local.usage_index)
272 j = parser->local.usage_index - 1; 269 j = parser->local.usage_index - 1;
273 field->usage[i].hid = parser->local.usage[j]; 270 field->usage[i].hid = parser->local.usage[j];
274 field->usage[i].collection_index = 271 field->usage[i].collection_index =
275 parser->local.collection_index[j]; 272 parser->local.collection_index[j];
273 field->usage[i].usage_index = i;
276 } 274 }
277 275
278 field->maxusage = usages; 276 field->maxusage = usages;
@@ -801,6 +799,64 @@ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
801} 799}
802EXPORT_SYMBOL_GPL(hid_parse_report); 800EXPORT_SYMBOL_GPL(hid_parse_report);
803 801
802static const char * const hid_report_names[] = {
803 "HID_INPUT_REPORT",
804 "HID_OUTPUT_REPORT",
805 "HID_FEATURE_REPORT",
806};
807/**
808 * hid_validate_values - validate existing device report's value indexes
809 *
810 * @device: hid device
811 * @type: which report type to examine
812 * @id: which report ID to examine (0 for first)
813 * @field_index: which report field to examine
814 * @report_counts: expected number of values
815 *
816 * Validate the number of values in a given field of a given report, after
817 * parsing.
818 */
819struct hid_report *hid_validate_values(struct hid_device *hid,
820 unsigned int type, unsigned int id,
821 unsigned int field_index,
822 unsigned int report_counts)
823{
824 struct hid_report *report;
825
826 if (type > HID_FEATURE_REPORT) {
827 hid_err(hid, "invalid HID report type %u\n", type);
828 return NULL;
829 }
830
831 if (id >= HID_MAX_IDS) {
832 hid_err(hid, "invalid HID report id %u\n", id);
833 return NULL;
834 }
835
836 /*
837 * Explicitly not using hid_get_report() here since it depends on
838 * ->numbered being checked, which may not always be the case when
839 * drivers go to access report values.
840 */
841 report = hid->report_enum[type].report_id_hash[id];
842 if (!report) {
843 hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
844 return NULL;
845 }
846 if (report->maxfield <= field_index) {
847 hid_err(hid, "not enough fields in %s %u\n",
848 hid_report_names[type], id);
849 return NULL;
850 }
851 if (report->field[field_index]->report_count < report_counts) {
852 hid_err(hid, "not enough values in %s %u field %u\n",
853 hid_report_names[type], id, field_index);
854 return NULL;
855 }
856 return report;
857}
858EXPORT_SYMBOL_GPL(hid_validate_values);
859
804/** 860/**
805 * hid_open_report - open a driver-specific device report 861 * hid_open_report - open a driver-specific device report
806 * 862 *
@@ -1296,7 +1352,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
1296 goto out; 1352 goto out;
1297 } 1353 }
1298 1354
1299 if (hid->claimed != HID_CLAIMED_HIDRAW) { 1355 if (hid->claimed != HID_CLAIMED_HIDRAW && report->maxfield) {
1300 for (a = 0; a < report->maxfield; a++) 1356 for (a = 0; a < report->maxfield; a++)
1301 hid_input_field(hid, report->field[a], cdata, interrupt); 1357 hid_input_field(hid, report->field[a], cdata, interrupt);
1302 hdrv = hid->driver; 1358 hdrv = hid->driver;
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index b420f4a0fd28..8741d953dcc8 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -485,6 +485,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
485 if (field->flags & HID_MAIN_ITEM_CONSTANT) 485 if (field->flags & HID_MAIN_ITEM_CONSTANT)
486 goto ignore; 486 goto ignore;
487 487
488 /* Ignore if report count is out of bounds. */
489 if (field->report_count < 1)
490 goto ignore;
491
488 /* only LED usages are supported in output fields */ 492 /* only LED usages are supported in output fields */
489 if (field->report_type == HID_OUTPUT_REPORT && 493 if (field->report_type == HID_OUTPUT_REPORT &&
490 (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) { 494 (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) {
@@ -1236,7 +1240,11 @@ static void report_features(struct hid_device *hid)
1236 1240
1237 rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; 1241 rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
1238 list_for_each_entry(rep, &rep_enum->report_list, list) 1242 list_for_each_entry(rep, &rep_enum->report_list, list)
1239 for (i = 0; i < rep->maxfield; i++) 1243 for (i = 0; i < rep->maxfield; i++) {
1244 /* Ignore if report count is out of bounds. */
1245 if (rep->field[i]->report_count < 1)
1246 continue;
1247
1240 for (j = 0; j < rep->field[i]->maxusage; j++) { 1248 for (j = 0; j < rep->field[i]->maxusage; j++) {
1241 /* Verify if Battery Strength feature is available */ 1249 /* Verify if Battery Strength feature is available */
1242 hidinput_setup_battery(hid, HID_FEATURE_REPORT, rep->field[i]); 1250 hidinput_setup_battery(hid, HID_FEATURE_REPORT, rep->field[i]);
@@ -1245,6 +1253,7 @@ static void report_features(struct hid_device *hid)
1245 drv->feature_mapping(hid, rep->field[i], 1253 drv->feature_mapping(hid, rep->field[i],
1246 rep->field[i]->usage + j); 1254 rep->field[i]->usage + j);
1247 } 1255 }
1256 }
1248} 1257}
1249 1258
1250static struct hid_input *hidinput_allocate(struct hid_device *hid) 1259static struct hid_input *hidinput_allocate(struct hid_device *hid)
diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
index 07837f5a4eb8..31cf29a6ba17 100644
--- a/drivers/hid/hid-lenovo-tpkbd.c
+++ b/drivers/hid/hid-lenovo-tpkbd.c
@@ -339,7 +339,15 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
339 struct tpkbd_data_pointer *data_pointer; 339 struct tpkbd_data_pointer *data_pointer;
340 size_t name_sz = strlen(dev_name(dev)) + 16; 340 size_t name_sz = strlen(dev_name(dev)) + 16;
341 char *name_mute, *name_micmute; 341 char *name_mute, *name_micmute;
342 int ret; 342 int i, ret;
343
344 /* Validate required reports. */
345 for (i = 0; i < 4; i++) {
346 if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1))
347 return -ENODEV;
348 }
349 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 3, 0, 2))
350 return -ENODEV;
343 351
344 if (sysfs_create_group(&hdev->dev.kobj, 352 if (sysfs_create_group(&hdev->dev.kobj,
345 &tpkbd_attr_group_pointer)) { 353 &tpkbd_attr_group_pointer)) {
@@ -406,22 +414,27 @@ static int tpkbd_probe(struct hid_device *hdev,
406 ret = hid_parse(hdev); 414 ret = hid_parse(hdev);
407 if (ret) { 415 if (ret) {
408 hid_err(hdev, "hid_parse failed\n"); 416 hid_err(hdev, "hid_parse failed\n");
409 goto err_free; 417 goto err;
410 } 418 }
411 419
412 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 420 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
413 if (ret) { 421 if (ret) {
414 hid_err(hdev, "hid_hw_start failed\n"); 422 hid_err(hdev, "hid_hw_start failed\n");
415 goto err_free; 423 goto err;
416 } 424 }
417 425
418 uhdev = (struct usbhid_device *) hdev->driver_data; 426 uhdev = (struct usbhid_device *) hdev->driver_data;
419 427
420 if (uhdev->ifnum == 1) 428 if (uhdev->ifnum == 1) {
421 return tpkbd_probe_tp(hdev); 429 ret = tpkbd_probe_tp(hdev);
430 if (ret)
431 goto err_hid;
432 }
422 433
423 return 0; 434 return 0;
424err_free: 435err_hid:
436 hid_hw_stop(hdev);
437err:
425 return ret; 438 return ret;
426} 439}
427 440
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
index b3cd1507dda2..1a42eaa6ca02 100644
--- a/drivers/hid/hid-lg2ff.c
+++ b/drivers/hid/hid-lg2ff.c
@@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid)
64 struct hid_report *report; 64 struct hid_report *report;
65 struct hid_input *hidinput = list_entry(hid->inputs.next, 65 struct hid_input *hidinput = list_entry(hid->inputs.next,
66 struct hid_input, list); 66 struct hid_input, list);
67 struct list_head *report_list =
68 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
69 struct input_dev *dev = hidinput->input; 67 struct input_dev *dev = hidinput->input;
70 int error; 68 int error;
71 69
72 if (list_empty(report_list)) { 70 /* Check that the report looks ok */
73 hid_err(hid, "no output report found\n"); 71 report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7);
72 if (!report)
74 return -ENODEV; 73 return -ENODEV;
75 }
76
77 report = list_entry(report_list->next, struct hid_report, list);
78
79 if (report->maxfield < 1) {
80 hid_err(hid, "output report is empty\n");
81 return -ENODEV;
82 }
83 if (report->field[0]->report_count < 7) {
84 hid_err(hid, "not enough values in the field\n");
85 return -ENODEV;
86 }
87 74
88 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); 75 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
89 if (!lg2ff) 76 if (!lg2ff)
diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
index e52f181f6aa1..8c2da183d3bc 100644
--- a/drivers/hid/hid-lg3ff.c
+++ b/drivers/hid/hid-lg3ff.c
@@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data,
66 int x, y; 66 int x, y;
67 67
68/* 68/*
69 * Maxusage should always be 63 (maximum fields) 69 * Available values in the field should always be 63, but we only use up to
70 * likely a better way to ensure this data is clean 70 * 35. Instead, clear the entire area, however big it is.
71 */ 71 */
72 memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage); 72 memset(report->field[0]->value, 0,
73 sizeof(__s32) * report->field[0]->report_count);
73 74
74 switch (effect->type) { 75 switch (effect->type) {
75 case FF_CONSTANT: 76 case FF_CONSTANT:
@@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = {
129int lg3ff_init(struct hid_device *hid) 130int lg3ff_init(struct hid_device *hid)
130{ 131{
131 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 132 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
132 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
133 struct input_dev *dev = hidinput->input; 133 struct input_dev *dev = hidinput->input;
134 struct hid_report *report;
135 struct hid_field *field;
136 const signed short *ff_bits = ff3_joystick_ac; 134 const signed short *ff_bits = ff3_joystick_ac;
137 int error; 135 int error;
138 int i; 136 int i;
139 137
140 /* Find the report to use */
141 if (list_empty(report_list)) {
142 hid_err(hid, "No output report found\n");
143 return -1;
144 }
145
146 /* Check that the report looks ok */ 138 /* Check that the report looks ok */
147 report = list_entry(report_list->next, struct hid_report, list); 139 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35))
148 if (!report) { 140 return -ENODEV;
149 hid_err(hid, "NULL output report\n");
150 return -1;
151 }
152
153 field = report->field[0];
154 if (!field) {
155 hid_err(hid, "NULL field\n");
156 return -1;
157 }
158 141
159 /* Assume single fixed device G940 */ 142 /* Assume single fixed device G940 */
160 for (i = 0; ff_bits[i] >= 0; i++) 143 for (i = 0; ff_bits[i] >= 0; i++)
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 0ddae2a00d59..8782fe1aaa07 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
484int lg4ff_init(struct hid_device *hid) 484int lg4ff_init(struct hid_device *hid)
485{ 485{
486 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 486 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
487 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
488 struct input_dev *dev = hidinput->input; 487 struct input_dev *dev = hidinput->input;
489 struct hid_report *report;
490 struct hid_field *field;
491 struct lg4ff_device_entry *entry; 488 struct lg4ff_device_entry *entry;
492 struct lg_drv_data *drv_data; 489 struct lg_drv_data *drv_data;
493 struct usb_device_descriptor *udesc; 490 struct usb_device_descriptor *udesc;
494 int error, i, j; 491 int error, i, j;
495 __u16 bcdDevice, rev_maj, rev_min; 492 __u16 bcdDevice, rev_maj, rev_min;
496 493
497 /* Find the report to use */
498 if (list_empty(report_list)) {
499 hid_err(hid, "No output report found\n");
500 return -1;
501 }
502
503 /* Check that the report looks ok */ 494 /* Check that the report looks ok */
504 report = list_entry(report_list->next, struct hid_report, list); 495 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
505 if (!report) {
506 hid_err(hid, "NULL output report\n");
507 return -1; 496 return -1;
508 }
509
510 field = report->field[0];
511 if (!field) {
512 hid_err(hid, "NULL field\n");
513 return -1;
514 }
515 497
516 /* Check what wheel has been connected */ 498 /* Check what wheel has been connected */
517 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) { 499 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
index d7ea8c845b40..e1394af0ae7b 100644
--- a/drivers/hid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
128int lgff_init(struct hid_device* hid) 128int lgff_init(struct hid_device* hid)
129{ 129{
130 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 130 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
131 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
132 struct input_dev *dev = hidinput->input; 131 struct input_dev *dev = hidinput->input;
133 struct hid_report *report;
134 struct hid_field *field;
135 const signed short *ff_bits = ff_joystick; 132 const signed short *ff_bits = ff_joystick;
136 int error; 133 int error;
137 int i; 134 int i;
138 135
139 /* Find the report to use */
140 if (list_empty(report_list)) {
141 hid_err(hid, "No output report found\n");
142 return -1;
143 }
144
145 /* Check that the report looks ok */ 136 /* Check that the report looks ok */
146 report = list_entry(report_list->next, struct hid_report, list); 137 if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
147 field = report->field[0]; 138 return -ENODEV;
148 if (!field) {
149 hid_err(hid, "NULL field\n");
150 return -1;
151 }
152 139
153 for (i = 0; i < ARRAY_SIZE(devices); i++) { 140 for (i = 0; i < ARRAY_SIZE(devices); i++) {
154 if (dev->id.vendor == devices[i].idVendor && 141 if (dev->id.vendor == devices[i].idVendor &&
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 7800b1410562..2e5302462efb 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -461,7 +461,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
461 struct hid_report *report; 461 struct hid_report *report;
462 struct hid_report_enum *output_report_enum; 462 struct hid_report_enum *output_report_enum;
463 u8 *data = (u8 *)(&dj_report->device_index); 463 u8 *data = (u8 *)(&dj_report->device_index);
464 int i; 464 unsigned int i;
465 465
466 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT]; 466 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
467 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT]; 467 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
@@ -471,7 +471,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
471 return -ENODEV; 471 return -ENODEV;
472 } 472 }
473 473
474 for (i = 0; i < report->field[0]->report_count; i++) 474 for (i = 0; i < DJREPORT_SHORT_LENGTH - 1; i++)
475 report->field[0]->value[i] = data[i]; 475 report->field[0]->value[i] = data[i];
476 476
477 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); 477 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
@@ -791,6 +791,12 @@ static int logi_dj_probe(struct hid_device *hdev,
791 goto hid_parse_fail; 791 goto hid_parse_fail;
792 } 792 }
793 793
794 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
795 0, DJREPORT_SHORT_LENGTH - 1)) {
796 retval = -ENODEV;
797 goto hid_parse_fail;
798 }
799
794 /* Starts the usb device and connects to upper interfaces hiddev and 800 /* Starts the usb device and connects to upper interfaces hiddev and
795 * hidraw */ 801 * hidraw */
796 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 802 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index ac28f08c3866..5e5fe1b8eebb 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -101,9 +101,9 @@ struct mt_device {
101 unsigned last_slot_field; /* the last field of a slot */ 101 unsigned last_slot_field; /* the last field of a slot */
102 unsigned mt_report_id; /* the report ID of the multitouch device */ 102 unsigned mt_report_id; /* the report ID of the multitouch device */
103 unsigned pen_report_id; /* the report ID of the pen device */ 103 unsigned pen_report_id; /* the report ID of the pen device */
104 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ 104 __s16 inputmode; /* InputMode HID feature, -1 if non-existent */
105 __s8 inputmode_index; /* InputMode HID feature index in the report */ 105 __s16 inputmode_index; /* InputMode HID feature index in the report */
106 __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, 106 __s16 maxcontact_report_id; /* Maximum Contact Number HID feature,
107 -1 if non-existent */ 107 -1 if non-existent */
108 __u8 num_received; /* how many contacts we received */ 108 __u8 num_received; /* how many contacts we received */
109 __u8 num_expected; /* expected last contact index */ 109 __u8 num_expected; /* expected last contact index */
@@ -312,20 +312,18 @@ static void mt_feature_mapping(struct hid_device *hdev,
312 struct hid_field *field, struct hid_usage *usage) 312 struct hid_field *field, struct hid_usage *usage)
313{ 313{
314 struct mt_device *td = hid_get_drvdata(hdev); 314 struct mt_device *td = hid_get_drvdata(hdev);
315 int i;
316 315
317 switch (usage->hid) { 316 switch (usage->hid) {
318 case HID_DG_INPUTMODE: 317 case HID_DG_INPUTMODE:
319 td->inputmode = field->report->id; 318 /* Ignore if value index is out of bounds. */
320 td->inputmode_index = 0; /* has to be updated below */ 319 if (usage->usage_index >= field->report_count) {
321 320 dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n");
322 for (i=0; i < field->maxusage; i++) { 321 break;
323 if (field->usage[i].hid == usage->hid) {
324 td->inputmode_index = i;
325 break;
326 }
327 } 322 }
328 323
324 td->inputmode = field->report->id;
325 td->inputmode_index = usage->usage_index;
326
329 break; 327 break;
330 case HID_DG_CONTACTMAX: 328 case HID_DG_CONTACTMAX:
331 td->maxcontact_report_id = field->report->id; 329 td->maxcontact_report_id = field->report->id;
@@ -511,6 +509,10 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
511 mt_store_field(usage, td, hi); 509 mt_store_field(usage, td, hi);
512 return 1; 510 return 1;
513 case HID_DG_CONTACTCOUNT: 511 case HID_DG_CONTACTCOUNT:
512 /* Ignore if indexes are out of bounds. */
513 if (field->index >= field->report->maxfield ||
514 usage->usage_index >= field->report_count)
515 return 1;
514 td->cc_index = field->index; 516 td->cc_index = field->index;
515 td->cc_value_index = usage->usage_index; 517 td->cc_value_index = usage->usage_index;
516 return 1; 518 return 1;
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 30dbb6b40bbf..b18320db5f7d 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -537,6 +537,10 @@ static int buzz_init(struct hid_device *hdev)
537 drv_data = hid_get_drvdata(hdev); 537 drv_data = hid_get_drvdata(hdev);
538 BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER)); 538 BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER));
539 539
540 /* Validate expected report characteristics. */
541 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7))
542 return -ENODEV;
543
540 buzz = kzalloc(sizeof(*buzz), GFP_KERNEL); 544 buzz = kzalloc(sizeof(*buzz), GFP_KERNEL);
541 if (!buzz) { 545 if (!buzz) {
542 hid_err(hdev, "Insufficient memory, cannot allocate driver data\n"); 546 hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
index d16491192112..29f328f411fb 100644
--- a/drivers/hid/hid-steelseries.c
+++ b/drivers/hid/hid-steelseries.c
@@ -249,6 +249,11 @@ static int steelseries_srws1_probe(struct hid_device *hdev,
249 goto err_free; 249 goto err_free;
250 } 250 }
251 251
252 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 16)) {
253 ret = -ENODEV;
254 goto err_free;
255 }
256
252 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 257 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
253 if (ret) { 258 if (ret) {
254 hid_err(hdev, "hw start failed\n"); 259 hid_err(hdev, "hw start failed\n");
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
index 6ec28a37c146..a29756c6ca02 100644
--- a/drivers/hid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -68,21 +68,13 @@ static int zpff_init(struct hid_device *hid)
68 struct hid_report *report; 68 struct hid_report *report;
69 struct hid_input *hidinput = list_entry(hid->inputs.next, 69 struct hid_input *hidinput = list_entry(hid->inputs.next,
70 struct hid_input, list); 70 struct hid_input, list);
71 struct list_head *report_list =
72 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
73 struct input_dev *dev = hidinput->input; 71 struct input_dev *dev = hidinput->input;
74 int error; 72 int i, error;
75 73
76 if (list_empty(report_list)) { 74 for (i = 0; i < 4; i++) {
77 hid_err(hid, "no output report found\n"); 75 report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1);
78 return -ENODEV; 76 if (!report)
79 } 77 return -ENODEV;
80
81 report = list_entry(report_list->next, struct hid_report, list);
82
83 if (report->maxfield < 4) {
84 hid_err(hid, "not enough fields in report\n");
85 return -ENODEV;
86 } 78 }
87 79
88 zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL); 80 zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 7f910c76ca0a..3c92780bda09 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -2295,8 +2295,8 @@ _hfcpci_softirq(struct device *dev, void *arg)
2295static void 2295static void
2296hfcpci_softirq(void *arg) 2296hfcpci_softirq(void *arg)
2297{ 2297{
2298 (void) driver_for_each_device(&hfc_driver.driver, NULL, arg, 2298 WARN_ON_ONCE(driver_for_each_device(&hfc_driver.driver, NULL, arg,
2299 _hfcpci_softirq); 2299 _hfcpci_softirq) != 0);
2300 2300
2301 /* if next event would be in the past ... */ 2301 /* if next event would be in the past ... */
2302 if ((s32)(hfc_jiffies + tics - jiffies) <= 0) 2302 if ((s32)(hfc_jiffies + tics - jiffies) <= 0)
diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
index 1063babe1d3a..36817e0a0b94 100644
--- a/drivers/isdn/hisax/amd7930_fn.c
+++ b/drivers/isdn/hisax/amd7930_fn.c
@@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
314 314
315 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx); 315 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
316 QuickHex(t, cs->rcvbuf, cs->rcvidx); 316 QuickHex(t, cs->rcvbuf, cs->rcvidx);
317 debugl1(cs, cs->dlog); 317 debugl1(cs, "%s", cs->dlog);
318 } 318 }
319 /* moves received data in sk-buffer */ 319 /* moves received data in sk-buffer */
320 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx); 320 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
@@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
406 406
407 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count); 407 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
408 QuickHex(t, deb_ptr, count); 408 QuickHex(t, deb_ptr, count);
409 debugl1(cs, cs->dlog); 409 debugl1(cs, "%s", cs->dlog);
410 } 410 }
411 /* AMD interrupts on */ 411 /* AMD interrupts on */
412 AmdIrqOn(cs); 412 AmdIrqOn(cs);
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
index ee9b9a03cffa..d1427bd6452d 100644
--- a/drivers/isdn/hisax/avm_pci.c
+++ b/drivers/isdn/hisax/avm_pci.c
@@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
285 t += sprintf(t, "hdlc_empty_fifo %c cnt %d", 285 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
286 bcs->channel ? 'B' : 'A', count); 286 bcs->channel ? 'B' : 'A', count);
287 QuickHex(t, p, count); 287 QuickHex(t, p, count);
288 debugl1(cs, bcs->blog); 288 debugl1(cs, "%s", bcs->blog);
289 } 289 }
290} 290}
291 291
@@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
345 t += sprintf(t, "hdlc_fill_fifo %c cnt %d", 345 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
346 bcs->channel ? 'B' : 'A', count); 346 bcs->channel ? 'B' : 'A', count);
347 QuickHex(t, p, count); 347 QuickHex(t, p, count);
348 debugl1(cs, bcs->blog); 348 debugl1(cs, "%s", bcs->blog);
349 } 349 }
350} 350}
351 351
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index bf04d2a3cf4a..b33f53b3ca93 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
1896 ptr--; 1896 ptr--;
1897 *ptr++ = '\n'; 1897 *ptr++ = '\n';
1898 *ptr = 0; 1898 *ptr = 0;
1899 HiSax_putstatus(cs, NULL, cs->dlog); 1899 HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1900 } else 1900 } else
1901 HiSax_putstatus(cs, "LogEcho: ", 1901 HiSax_putstatus(cs, "LogEcho: ",
1902 "warning Frame too big (%d)", 1902 "warning Frame too big (%d)",
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
index 8d0cf6e4dc00..4fc90de68d18 100644
--- a/drivers/isdn/hisax/diva.c
+++ b/drivers/isdn/hisax/diva.c
@@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
427 t += sprintf(t, "hscx_empty_fifo %c cnt %d", 427 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
428 bcs->hw.hscx.hscx ? 'B' : 'A', count); 428 bcs->hw.hscx.hscx ? 'B' : 'A', count);
429 QuickHex(t, ptr, count); 429 QuickHex(t, ptr, count);
430 debugl1(cs, bcs->blog); 430 debugl1(cs, "%s", bcs->blog);
431 } 431 }
432} 432}
433 433
@@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
469 t += sprintf(t, "hscx_fill_fifo %c cnt %d", 469 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
470 bcs->hw.hscx.hscx ? 'B' : 'A', count); 470 bcs->hw.hscx.hscx ? 'B' : 'A', count);
471 QuickHex(t, ptr, count); 471 QuickHex(t, ptr, count);
472 debugl1(cs, bcs->blog); 472 debugl1(cs, "%s", bcs->blog);
473 } 473 }
474} 474}
475 475
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 1df6f9a56ca2..2be1c8a3bb5f 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
535 t = tmp; 535 t = tmp;
536 t += sprintf(tmp, "Arcofi data"); 536 t += sprintf(tmp, "Arcofi data");
537 QuickHex(t, p, cs->dc.isac.mon_rxp); 537 QuickHex(t, p, cs->dc.isac.mon_rxp);
538 debugl1(cs, tmp); 538 debugl1(cs, "%s", tmp);
539 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) { 539 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
540 switch (cs->dc.isac.mon_rx[1]) { 540 switch (cs->dc.isac.mon_rx[1]) {
541 case 0x80: 541 case 0x80:
diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
index d4c98d330bfe..3f84dd8f1757 100644
--- a/drivers/isdn/hisax/elsa_ser.c
+++ b/drivers/isdn/hisax/elsa_ser.c
@@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
344 344
345 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt); 345 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
346 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt); 346 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
347 debugl1(cs, tmp); 347 debugl1(cs, "%s", tmp);
348 } 348 }
349 cs->hw.elsa.rcvcnt = 0; 349 cs->hw.elsa.rcvcnt = 0;
350} 350}
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 3ccd724ff8c2..497bd026c237 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -901,7 +901,7 @@ Begin:
901 ptr--; 901 ptr--;
902 *ptr++ = '\n'; 902 *ptr++ = '\n';
903 *ptr = 0; 903 *ptr = 0;
904 HiSax_putstatus(cs, NULL, cs->dlog); 904 HiSax_putstatus(cs, NULL, "%s", cs->dlog);
905 } else 905 } else
906 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3); 906 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
907 } 907 }
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index dc4574f735ef..fa1fefd711cd 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
674 ptr--; 674 ptr--;
675 *ptr++ = '\n'; 675 *ptr++ = '\n';
676 *ptr = 0; 676 *ptr = 0;
677 HiSax_putstatus(cs, NULL, cs->dlog); 677 HiSax_putstatus(cs, NULL, "%s", cs->dlog);
678 } else 678 } else
679 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len); 679 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
680 } 680 }
diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
index f398d4838937..a8d6188402c6 100644
--- a/drivers/isdn/hisax/hscx_irq.c
+++ b/drivers/isdn/hisax/hscx_irq.c
@@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
75 t += sprintf(t, "hscx_empty_fifo %c cnt %d", 75 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
76 bcs->hw.hscx.hscx ? 'B' : 'A', count); 76 bcs->hw.hscx.hscx ? 'B' : 'A', count);
77 QuickHex(t, ptr, count); 77 QuickHex(t, ptr, count);
78 debugl1(cs, bcs->blog); 78 debugl1(cs, "%s", bcs->blog);
79 } 79 }
80} 80}
81 81
@@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
115 t += sprintf(t, "hscx_fill_fifo %c cnt %d", 115 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
116 bcs->hw.hscx.hscx ? 'B' : 'A', count); 116 bcs->hw.hscx.hscx ? 'B' : 'A', count);
117 QuickHex(t, ptr, count); 117 QuickHex(t, ptr, count);
118 debugl1(cs, bcs->blog); 118 debugl1(cs, "%s", bcs->blog);
119 } 119 }
120} 120}
121 121
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index db5321f6379b..51dae9167238 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
134 134
135 t += sprintf(t, "icc_empty_fifo cnt %d", count); 135 t += sprintf(t, "icc_empty_fifo cnt %d", count);
136 QuickHex(t, ptr, count); 136 QuickHex(t, ptr, count);
137 debugl1(cs, cs->dlog); 137 debugl1(cs, "%s", cs->dlog);
138 } 138 }
139} 139}
140 140
@@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
176 176
177 t += sprintf(t, "icc_fill_fifo cnt %d", count); 177 t += sprintf(t, "icc_fill_fifo cnt %d", count);
178 QuickHex(t, ptr, count); 178 QuickHex(t, ptr, count);
179 debugl1(cs, cs->dlog); 179 debugl1(cs, "%s", cs->dlog);
180 } 180 }
181} 181}
182 182
diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
index 74feb5c83067..5faa5de24305 100644
--- a/drivers/isdn/hisax/ipacx.c
+++ b/drivers/isdn/hisax/ipacx.c
@@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
260 260
261 t += sprintf(t, "dch_empty_fifo() cnt %d", count); 261 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
262 QuickHex(t, ptr, count); 262 QuickHex(t, ptr, count);
263 debugl1(cs, cs->dlog); 263 debugl1(cs, "%s", cs->dlog);
264 } 264 }
265} 265}
266 266
@@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
307 307
308 t += sprintf(t, "dch_fill_fifo() cnt %d", count); 308 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
309 QuickHex(t, ptr, count); 309 QuickHex(t, ptr, count);
310 debugl1(cs, cs->dlog); 310 debugl1(cs, "%s", cs->dlog);
311 } 311 }
312} 312}
313 313
@@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
539 539
540 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count); 540 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
541 QuickHex(t, ptr, count); 541 QuickHex(t, ptr, count);
542 debugl1(cs, bcs->blog); 542 debugl1(cs, "%s", bcs->blog);
543 } 543 }
544} 544}
545 545
@@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
582 582
583 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count); 583 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
584 QuickHex(t, ptr, count); 584 QuickHex(t, ptr, count);
585 debugl1(cs, bcs->blog); 585 debugl1(cs, "%s", bcs->blog);
586 } 586 }
587} 587}
588 588
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index a365ccc1c99c..7fdf78f46433 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
137 137
138 t += sprintf(t, "isac_empty_fifo cnt %d", count); 138 t += sprintf(t, "isac_empty_fifo cnt %d", count);
139 QuickHex(t, ptr, count); 139 QuickHex(t, ptr, count);
140 debugl1(cs, cs->dlog); 140 debugl1(cs, "%s", cs->dlog);
141 } 141 }
142} 142}
143 143
@@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
179 179
180 t += sprintf(t, "isac_fill_fifo cnt %d", count); 180 t += sprintf(t, "isac_fill_fifo cnt %d", count);
181 QuickHex(t, ptr, count); 181 QuickHex(t, ptr, count);
182 debugl1(cs, cs->dlog); 182 debugl1(cs, "%s", cs->dlog);
183 } 183 }
184} 184}
185 185
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 7fdf34704fe5..f4956c73aa11 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
74 t = tmp; 74 t = tmp;
75 t += sprintf(t, "sendmbox cnt %d", len); 75 t += sprintf(t, "sendmbox cnt %d", len);
76 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i); 76 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
77 debugl1(cs, tmp); 77 debugl1(cs, "%s", tmp);
78 i -= 64; 78 i -= 64;
79 } 79 }
80 } 80 }
@@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
105 t = tmp; 105 t = tmp;
106 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb); 106 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
107 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i); 107 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
108 debugl1(cs, tmp); 108 debugl1(cs, "%s", tmp);
109 i -= 64; 109 i -= 64;
110 } 110 }
111 } 111 }
@@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
1248 tp += sprintf(debbuf, "msg iis(%x) msb(%x)", 1248 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
1249 ireg->iis, ireg->cmsb); 1249 ireg->iis, ireg->cmsb);
1250 QuickHex(tp, (u_char *)ireg->par, ireg->clsb); 1250 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
1251 debugl1(cs, debbuf); 1251 debugl1(cs, "%s", debbuf);
1252 } 1252 }
1253 break; 1253 break;
1254 case ISAR_IIS_INVMSG: 1254 case ISAR_IIS_INVMSG:
diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
index f946c58d8ab1..e2ae7871a209 100644
--- a/drivers/isdn/hisax/jade.c
+++ b/drivers/isdn/hisax/jade.c
@@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
81 int jade = bcs->hw.hscx.hscx; 81 int jade = bcs->hw.hscx.hscx;
82 82
83 if (cs->debug & L1_DEB_HSCX) { 83 if (cs->debug & L1_DEB_HSCX) {
84 char tmp[40]; 84 debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
85 sprintf(tmp, "jade %c mode %d ichan %d",
86 'A' + jade, mode, bc);
87 debugl1(cs, tmp);
88 } 85 }
89 bcs->mode = mode; 86 bcs->mode = mode;
90 bcs->channel = bc; 87 bcs->channel = bc;
@@ -257,23 +254,18 @@ void
257clear_pending_jade_ints(struct IsdnCardState *cs) 254clear_pending_jade_ints(struct IsdnCardState *cs)
258{ 255{
259 int val; 256 int val;
260 char tmp[64];
261 257
262 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00); 258 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
263 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00); 259 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
264 260
265 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR); 261 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
266 sprintf(tmp, "jade B ISTA %x", val); 262 debugl1(cs, "jade B ISTA %x", val);
267 debugl1(cs, tmp);
268 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR); 263 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
269 sprintf(tmp, "jade A ISTA %x", val); 264 debugl1(cs, "jade A ISTA %x", val);
270 debugl1(cs, tmp);
271 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR); 265 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
272 sprintf(tmp, "jade B STAR %x", val); 266 debugl1(cs, "jade B STAR %x", val);
273 debugl1(cs, tmp);
274 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR); 267 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
275 sprintf(tmp, "jade A STAR %x", val); 268 debugl1(cs, "jade A STAR %x", val);
276 debugl1(cs, tmp);
277 /* Unmask ints */ 269 /* Unmask ints */
278 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8); 270 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
279 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8); 271 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
index f521fc83dc76..b930da9b5aa6 100644
--- a/drivers/isdn/hisax/jade_irq.c
+++ b/drivers/isdn/hisax/jade_irq.c
@@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
65 t += sprintf(t, "jade_empty_fifo %c cnt %d", 65 t += sprintf(t, "jade_empty_fifo %c cnt %d",
66 bcs->hw.hscx.hscx ? 'B' : 'A', count); 66 bcs->hw.hscx.hscx ? 'B' : 'A', count);
67 QuickHex(t, ptr, count); 67 QuickHex(t, ptr, count);
68 debugl1(cs, bcs->blog); 68 debugl1(cs, "%s", bcs->blog);
69 } 69 }
70} 70}
71 71
@@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
105 t += sprintf(t, "jade_fill_fifo %c cnt %d", 105 t += sprintf(t, "jade_fill_fifo %c cnt %d",
106 bcs->hw.hscx.hscx ? 'B' : 'A', count); 106 bcs->hw.hscx.hscx ? 'B' : 'A', count);
107 QuickHex(t, ptr, count); 107 QuickHex(t, ptr, count);
108 debugl1(cs, bcs->blog); 108 debugl1(cs, "%s", bcs->blog);
109 } 109 }
110} 110}
111 111
diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
index 4c1bca5caa1d..875402e76d0a 100644
--- a/drivers/isdn/hisax/l3_1tr6.c
+++ b/drivers/isdn/hisax/l3_1tr6.c
@@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
63{ 63{
64 dev_kfree_skb(skb); 64 dev_kfree_skb(skb);
65 if (pc->st->l3.debug & L3_DEB_WARN) 65 if (pc->st->l3.debug & L3_DEB_WARN)
66 l3_debug(pc->st, msg); 66 l3_debug(pc->st, "%s", msg);
67 l3_1tr6_release_req(pc, 0, NULL); 67 l3_1tr6_release_req(pc, 0, NULL);
68} 68}
69 69
@@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
161{ 161{
162 u_char *p; 162 u_char *p;
163 int bcfound = 0; 163 int bcfound = 0;
164 char tmp[80];
165 struct sk_buff *skb = arg; 164 struct sk_buff *skb = arg;
166 165
167 /* Channel Identification */ 166 /* Channel Identification */
@@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
214 /* Signal all services, linklevel takes care of Service-Indicator */ 213 /* Signal all services, linklevel takes care of Service-Indicator */
215 if (bcfound) { 214 if (bcfound) {
216 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) { 215 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
217 sprintf(tmp, "non-digital call: %s -> %s", 216 l3_debug(pc->st, "non-digital call: %s -> %s",
218 pc->para.setup.phone, 217 pc->para.setup.phone,
219 pc->para.setup.eazmsn); 218 pc->para.setup.eazmsn);
220 l3_debug(pc->st, tmp);
221 } 219 }
222 newl3state(pc, 6); 220 newl3state(pc, 6);
223 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc); 221 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
@@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
301{ 299{
302 u_char *p; 300 u_char *p;
303 int i, tmpcharge = 0; 301 int i, tmpcharge = 0;
304 char a_charge[8], tmp[32]; 302 char a_charge[8];
305 struct sk_buff *skb = arg; 303 struct sk_buff *skb = arg;
306 304
307 p = skb->data; 305 p = skb->data;
@@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
316 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc); 314 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
317 } 315 }
318 if (pc->st->l3.debug & L3_DEB_CHARGE) { 316 if (pc->st->l3.debug & L3_DEB_CHARGE) {
319 sprintf(tmp, "charging info %d", pc->para.chargeinfo); 317 l3_debug(pc->st, "charging info %d",
320 l3_debug(pc->st, tmp); 318 pc->para.chargeinfo);
321 } 319 }
322 } else if (pc->st->l3.debug & L3_DEB_CHARGE) 320 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
323 l3_debug(pc->st, "charging info not found"); 321 l3_debug(pc->st, "charging info not found");
@@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
399 struct sk_buff *skb = arg; 397 struct sk_buff *skb = arg;
400 u_char *p; 398 u_char *p;
401 int i, tmpcharge = 0; 399 int i, tmpcharge = 0;
402 char a_charge[8], tmp[32]; 400 char a_charge[8];
403 401
404 StopAllL3Timer(pc); 402 StopAllL3Timer(pc);
405 p = skb->data; 403 p = skb->data;
@@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
414 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc); 412 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
415 } 413 }
416 if (pc->st->l3.debug & L3_DEB_CHARGE) { 414 if (pc->st->l3.debug & L3_DEB_CHARGE) {
417 sprintf(tmp, "charging info %d", pc->para.chargeinfo); 415 l3_debug(pc->st, "charging info %d",
418 l3_debug(pc->st, tmp); 416 pc->para.chargeinfo);
419 } 417 }
420 } else if (pc->st->l3.debug & L3_DEB_CHARGE) 418 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
421 l3_debug(pc->st, "charging info not found"); 419 l3_debug(pc->st, "charging info not found");
@@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
746 int i, mt, cr; 744 int i, mt, cr;
747 struct l3_process *proc; 745 struct l3_process *proc;
748 struct sk_buff *skb = arg; 746 struct sk_buff *skb = arg;
749 char tmp[80];
750 747
751 switch (pr) { 748 switch (pr) {
752 case (DL_DATA | INDICATION): 749 case (DL_DATA | INDICATION):
@@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
762 } 759 }
763 if (skb->len < 4) { 760 if (skb->len < 4) {
764 if (st->l3.debug & L3_DEB_PROTERR) { 761 if (st->l3.debug & L3_DEB_PROTERR) {
765 sprintf(tmp, "up1tr6 len only %d", skb->len); 762 l3_debug(st, "up1tr6 len only %d", skb->len);
766 l3_debug(st, tmp);
767 } 763 }
768 dev_kfree_skb(skb); 764 dev_kfree_skb(skb);
769 return; 765 return;
770 } 766 }
771 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) { 767 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
772 if (st->l3.debug & L3_DEB_PROTERR) { 768 if (st->l3.debug & L3_DEB_PROTERR) {
773 sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d", 769 l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
774 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", 770 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
775 skb->data[0], skb->len); 771 skb->data[0], skb->len);
776 l3_debug(st, tmp);
777 } 772 }
778 dev_kfree_skb(skb); 773 dev_kfree_skb(skb);
779 return; 774 return;
780 } 775 }
781 if (skb->data[1] != 1) { 776 if (skb->data[1] != 1) {
782 if (st->l3.debug & L3_DEB_PROTERR) { 777 if (st->l3.debug & L3_DEB_PROTERR) {
783 sprintf(tmp, "up1tr6 CR len not 1"); 778 l3_debug(st, "up1tr6 CR len not 1");
784 l3_debug(st, tmp);
785 } 779 }
786 dev_kfree_skb(skb); 780 dev_kfree_skb(skb);
787 return; 781 return;
@@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
791 if (skb->data[0] == PROTO_DIS_N0) { 785 if (skb->data[0] == PROTO_DIS_N0) {
792 dev_kfree_skb(skb); 786 dev_kfree_skb(skb);
793 if (st->l3.debug & L3_DEB_STATE) { 787 if (st->l3.debug & L3_DEB_STATE) {
794 sprintf(tmp, "up1tr6%s N0 mt %x unhandled", 788 l3_debug(st, "up1tr6%s N0 mt %x unhandled",
795 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt); 789 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
796 l3_debug(st, tmp);
797 } 790 }
798 } else if (skb->data[0] == PROTO_DIS_N1) { 791 } else if (skb->data[0] == PROTO_DIS_N1) {
799 if (!(proc = getl3proc(st, cr))) { 792 if (!(proc = getl3proc(st, cr))) {
@@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
801 if (cr < 128) { 794 if (cr < 128) {
802 if (!(proc = new_l3_process(st, cr))) { 795 if (!(proc = new_l3_process(st, cr))) {
803 if (st->l3.debug & L3_DEB_PROTERR) { 796 if (st->l3.debug & L3_DEB_PROTERR) {
804 sprintf(tmp, "up1tr6 no roc mem"); 797 l3_debug(st, "up1tr6 no roc mem");
805 l3_debug(st, tmp);
806 } 798 }
807 dev_kfree_skb(skb); 799 dev_kfree_skb(skb);
808 return; 800 return;
@@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
821 } else { 813 } else {
822 if (!(proc = new_l3_process(st, cr))) { 814 if (!(proc = new_l3_process(st, cr))) {
823 if (st->l3.debug & L3_DEB_PROTERR) { 815 if (st->l3.debug & L3_DEB_PROTERR) {
824 sprintf(tmp, "up1tr6 no roc mem"); 816 l3_debug(st, "up1tr6 no roc mem");
825 l3_debug(st, tmp);
826 } 817 }
827 dev_kfree_skb(skb); 818 dev_kfree_skb(skb);
828 return; 819 return;
@@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
837 if (i == ARRAY_SIZE(datastln1)) { 828 if (i == ARRAY_SIZE(datastln1)) {
838 dev_kfree_skb(skb); 829 dev_kfree_skb(skb);
839 if (st->l3.debug & L3_DEB_STATE) { 830 if (st->l3.debug & L3_DEB_STATE) {
840 sprintf(tmp, "up1tr6%sstate %d mt %x unhandled", 831 l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
841 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", 832 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
842 proc->state, mt); 833 proc->state, mt);
843 l3_debug(st, tmp);
844 } 834 }
845 return; 835 return;
846 } else { 836 } else {
847 if (st->l3.debug & L3_DEB_STATE) { 837 if (st->l3.debug & L3_DEB_STATE) {
848 sprintf(tmp, "up1tr6%sstate %d mt %x", 838 l3_debug(st, "up1tr6%sstate %d mt %x",
849 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", 839 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
850 proc->state, mt); 840 proc->state, mt);
851 l3_debug(st, tmp);
852 } 841 }
853 datastln1[i].rout(proc, pr, skb); 842 datastln1[i].rout(proc, pr, skb);
854 } 843 }
@@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
861 int i, cr; 850 int i, cr;
862 struct l3_process *proc; 851 struct l3_process *proc;
863 struct Channel *chan; 852 struct Channel *chan;
864 char tmp[80];
865 853
866 if ((DL_ESTABLISH | REQUEST) == pr) { 854 if ((DL_ESTABLISH | REQUEST) == pr) {
867 l3_msg(st, pr, NULL); 855 l3_msg(st, pr, NULL);
@@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
888 break; 876 break;
889 if (i == ARRAY_SIZE(downstl)) { 877 if (i == ARRAY_SIZE(downstl)) {
890 if (st->l3.debug & L3_DEB_STATE) { 878 if (st->l3.debug & L3_DEB_STATE) {
891 sprintf(tmp, "down1tr6 state %d prim %d unhandled", 879 l3_debug(st, "down1tr6 state %d prim %d unhandled",
892 proc->state, pr); 880 proc->state, pr);
893 l3_debug(st, tmp);
894 } 881 }
895 } else { 882 } else {
896 if (st->l3.debug & L3_DEB_STATE) { 883 if (st->l3.debug & L3_DEB_STATE) {
897 sprintf(tmp, "down1tr6 state %d prim %d", 884 l3_debug(st, "down1tr6 state %d prim %d",
898 proc->state, pr); 885 proc->state, pr);
899 l3_debug(st, tmp);
900 } 886 }
901 downstl[i].rout(proc, pr, arg); 887 downstl[i].rout(proc, pr, arg);
902 } 888 }
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index b646eed379df..233e432e06f6 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
176 else 176 else
177 j = i; 177 j = i;
178 QuickHex(t, p, j); 178 QuickHex(t, p, j);
179 debugl1(cs, tmp); 179 debugl1(cs, "%s", tmp);
180 p += j; 180 p += j;
181 i -= j; 181 i -= j;
182 t = tmp; 182 t = tmp;
diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
index 041bf52d9d0a..af1b020a81f1 100644
--- a/drivers/isdn/hisax/q931.c
+++ b/drivers/isdn/hisax/q931.c
@@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
1179 dp--; 1179 dp--;
1180 *dp++ = '\n'; 1180 *dp++ = '\n';
1181 *dp = 0; 1181 *dp = 0;
1182 HiSax_putstatus(cs, NULL, cs->dlog); 1182 HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1183 } else 1183 } else
1184 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size); 1184 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
1185} 1185}
@@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
1246 } 1246 }
1247 if (finish) { 1247 if (finish) {
1248 *dp = 0; 1248 *dp = 0;
1249 HiSax_putstatus(cs, NULL, cs->dlog); 1249 HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1250 return; 1250 return;
1251 } 1251 }
1252 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */ 1252 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
@@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
1509 dp += sprintf(dp, "Unknown protocol %x!", buf[0]); 1509 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
1510 } 1510 }
1511 *dp = 0; 1511 *dp = 0;
1512 HiSax_putstatus(cs, NULL, cs->dlog); 1512 HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1513} 1513}
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index d8cac6935818..a85895585d90 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
154 154
155 t += sprintf(t, "W6692_empty_fifo cnt %d", count); 155 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
156 QuickHex(t, ptr, count); 156 QuickHex(t, ptr, count);
157 debugl1(cs, cs->dlog); 157 debugl1(cs, "%s", cs->dlog);
158 } 158 }
159} 159}
160 160
@@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
196 196
197 t += sprintf(t, "W6692_fill_fifo cnt %d", count); 197 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
198 QuickHex(t, ptr, count); 198 QuickHex(t, ptr, count);
199 debugl1(cs, cs->dlog); 199 debugl1(cs, "%s", cs->dlog);
200 } 200 }
201} 201}
202 202
@@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
226 t += sprintf(t, "W6692B_empty_fifo %c cnt %d", 226 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
227 bcs->channel + '1', count); 227 bcs->channel + '1', count);
228 QuickHex(t, ptr, count); 228 QuickHex(t, ptr, count);
229 debugl1(cs, bcs->blog); 229 debugl1(cs, "%s", bcs->blog);
230 } 230 }
231} 231}
232 232
@@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
264 t += sprintf(t, "W6692B_fill_fifo %c cnt %d", 264 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
265 bcs->channel + '1', count); 265 bcs->channel + '1', count);
266 QuickHex(t, ptr, count); 266 QuickHex(t, ptr, count);
267 debugl1(cs, bcs->blog); 267 debugl1(cs, "%s", bcs->blog);
268 } 268 }
269} 269}
270 270
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 91f179d5135c..f428ef574372 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
1472 bond_info->lp_counter++; 1472 bond_info->lp_counter++;
1473 1473
1474 /* send learning packets */ 1474 /* send learning packets */
1475 if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) { 1475 if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
1476 /* change of curr_active_slave involves swapping of mac addresses. 1476 /* change of curr_active_slave involves swapping of mac addresses.
1477 * in order to avoid this swapping from happening while 1477 * in order to avoid this swapping from happening while
1478 * sending the learning packets, the curr_slave_lock must be held for 1478 * sending the learning packets, the curr_slave_lock must be held for
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 28d8e4c7dc06..c5eff5dafdfe 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -36,14 +36,15 @@ struct slave;
36 * Used for division - never set 36 * Used for division - never set
37 * to zero !!! 37 * to zero !!!
38 */ 38 */
39#define BOND_ALB_LP_INTERVAL 1 /* In seconds, periodic send of 39#define BOND_ALB_DEFAULT_LP_INTERVAL 1
40 * learning packets to the switch 40#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval) /* In seconds, periodic send of
41 */ 41 * learning packets to the switch
42 */
42 43
43#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \ 44#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
44 * ALB_TIMER_TICKS_PER_SEC) 45 * ALB_TIMER_TICKS_PER_SEC)
45 46
46#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \ 47#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
47 * ALB_TIMER_TICKS_PER_SEC) 48 * ALB_TIMER_TICKS_PER_SEC)
48 49
49#define TLB_HASH_TABLE_SIZE 256 /* The size of the clients hash table. 50#define TLB_HASH_TABLE_SIZE 256 /* The size of the clients hash table.
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 72df399c4ab3..55bbb8b8200c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
4416 params->all_slaves_active = all_slaves_active; 4416 params->all_slaves_active = all_slaves_active;
4417 params->resend_igmp = resend_igmp; 4417 params->resend_igmp = resend_igmp;
4418 params->min_links = min_links; 4418 params->min_links = min_links;
4419 params->lp_interval = BOND_ALB_DEFAULT_LP_INTERVAL;
4419 4420
4420 if (primary) { 4421 if (primary) {
4421 strncpy(params->primary, primary, IFNAMSIZ); 4422 strncpy(params->primary, primary, IFNAMSIZ);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index eeab40b01b7a..c29b836749b6 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1699,6 +1699,44 @@ out:
1699static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR, 1699static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
1700 bonding_show_resend_igmp, bonding_store_resend_igmp); 1700 bonding_show_resend_igmp, bonding_store_resend_igmp);
1701 1701
1702
1703static ssize_t bonding_show_lp_interval(struct device *d,
1704 struct device_attribute *attr,
1705 char *buf)
1706{
1707 struct bonding *bond = to_bond(d);
1708 return sprintf(buf, "%d\n", bond->params.lp_interval);
1709}
1710
1711static ssize_t bonding_store_lp_interval(struct device *d,
1712 struct device_attribute *attr,
1713 const char *buf, size_t count)
1714{
1715 struct bonding *bond = to_bond(d);
1716 int new_value, ret = count;
1717
1718 if (sscanf(buf, "%d", &new_value) != 1) {
1719 pr_err("%s: no lp interval value specified.\n",
1720 bond->dev->name);
1721 ret = -EINVAL;
1722 goto out;
1723 }
1724
1725 if (new_value <= 0) {
1726 pr_err ("%s: lp_interval must be between 1 and %d\n",
1727 bond->dev->name, INT_MAX);
1728 ret = -EINVAL;
1729 goto out;
1730 }
1731
1732 bond->params.lp_interval = new_value;
1733out:
1734 return ret;
1735}
1736
1737static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
1738 bonding_show_lp_interval, bonding_store_lp_interval);
1739
1702static struct attribute *per_bond_attrs[] = { 1740static struct attribute *per_bond_attrs[] = {
1703 &dev_attr_slaves.attr, 1741 &dev_attr_slaves.attr,
1704 &dev_attr_mode.attr, 1742 &dev_attr_mode.attr,
@@ -1729,6 +1767,7 @@ static struct attribute *per_bond_attrs[] = {
1729 &dev_attr_all_slaves_active.attr, 1767 &dev_attr_all_slaves_active.attr,
1730 &dev_attr_resend_igmp.attr, 1768 &dev_attr_resend_igmp.attr,
1731 &dev_attr_min_links.attr, 1769 &dev_attr_min_links.attr,
1770 &dev_attr_lp_interval.attr,
1732 NULL, 1771 NULL,
1733}; 1772};
1734 1773
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 7ad8bd5cc947..03cf3fd14490 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -176,6 +176,7 @@ struct bond_params {
176 int tx_queues; 176 int tx_queues;
177 int all_slaves_active; 177 int all_slaves_active;
178 int resend_igmp; 178 int resend_igmp;
179 int lp_interval;
179}; 180};
180 181
181struct bond_parm_tbl { 182struct bond_parm_tbl {
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index e66684a438f5..75fb1d20d6fd 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -530,7 +530,7 @@ static int bfin_mac_ethtool_setwol(struct net_device *dev,
530 if (lp->wol && !lp->irq_wake_requested) { 530 if (lp->wol && !lp->irq_wake_requested) {
531 /* register wake irq handler */ 531 /* register wake irq handler */
532 rc = request_irq(IRQ_MAC_WAKEDET, bfin_mac_wake_interrupt, 532 rc = request_irq(IRQ_MAC_WAKEDET, bfin_mac_wake_interrupt,
533 IRQF_DISABLED, "EMAC_WAKE", dev); 533 0, "EMAC_WAKE", dev);
534 if (rc) 534 if (rc)
535 return rc; 535 return rc;
536 lp->irq_wake_requested = true; 536 lp->irq_wake_requested = true;
@@ -1686,7 +1686,7 @@ static int bfin_mac_probe(struct platform_device *pdev)
1686 /* now, enable interrupts */ 1686 /* now, enable interrupts */
1687 /* register irq handler */ 1687 /* register irq handler */
1688 rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt, 1688 rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt,
1689 IRQF_DISABLED, "EMAC_RX", ndev); 1689 0, "EMAC_RX", ndev);
1690 if (rc) { 1690 if (rc) {
1691 dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n"); 1691 dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n");
1692 rc = -EBUSY; 1692 rc = -EBUSY;
diff --git a/drivers/net/ethernet/amd/sun3lance.c b/drivers/net/ethernet/amd/sun3lance.c
index d6b20296b8e4..3d8c6b2cdea4 100644
--- a/drivers/net/ethernet/amd/sun3lance.c
+++ b/drivers/net/ethernet/amd/sun3lance.c
@@ -358,7 +358,7 @@ static int __init lance_probe( struct net_device *dev)
358 358
359 REGA(CSR0) = CSR0_STOP; 359 REGA(CSR0) = CSR0_STOP;
360 360
361 if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev) < 0) { 361 if (request_irq(LANCE_IRQ, lance_interrupt, 0, "SUN3 Lance", dev) < 0) {
362#ifdef CONFIG_SUN3 362#ifdef CONFIG_SUN3
363 iounmap((void __iomem *)ioaddr); 363 iounmap((void __iomem *)ioaddr);
364#endif 364#endif
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 027398ebbba6..fc95b235e210 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1188,7 +1188,7 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1188 struct alx_priv *alx; 1188 struct alx_priv *alx;
1189 struct alx_hw *hw; 1189 struct alx_hw *hw;
1190 bool phy_configured; 1190 bool phy_configured;
1191 int bars, pm_cap, err; 1191 int bars, err;
1192 1192
1193 err = pci_enable_device_mem(pdev); 1193 err = pci_enable_device_mem(pdev);
1194 if (err) 1194 if (err)
@@ -1225,18 +1225,13 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1225 pci_enable_pcie_error_reporting(pdev); 1225 pci_enable_pcie_error_reporting(pdev);
1226 pci_set_master(pdev); 1226 pci_set_master(pdev);
1227 1227
1228 pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); 1228 if (!pdev->pm_cap) {
1229 if (pm_cap == 0) {
1230 dev_err(&pdev->dev, 1229 dev_err(&pdev->dev,
1231 "Can't find power management capability, aborting\n"); 1230 "Can't find power management capability, aborting\n");
1232 err = -EIO; 1231 err = -EIO;
1233 goto out_pci_release; 1232 goto out_pci_release;
1234 } 1233 }
1235 1234
1236 err = pci_set_power_state(pdev, PCI_D0);
1237 if (err)
1238 goto out_pci_release;
1239
1240 netdev = alloc_etherdev(sizeof(*alx)); 1235 netdev = alloc_etherdev(sizeof(*alx));
1241 if (!netdev) { 1236 if (!netdev) {
1242 err = -ENOMEM; 1237 err = -ENOMEM;
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index eec0af45b859..249468f95365 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -157,6 +157,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
157 if (++ring->end >= BGMAC_TX_RING_SLOTS) 157 if (++ring->end >= BGMAC_TX_RING_SLOTS)
158 ring->end = 0; 158 ring->end = 0;
159 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_INDEX, 159 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_INDEX,
160 ring->index_base +
160 ring->end * sizeof(struct bgmac_dma_desc)); 161 ring->end * sizeof(struct bgmac_dma_desc));
161 162
162 /* Always keep one slot free to allow detecting bugged calls. */ 163 /* Always keep one slot free to allow detecting bugged calls. */
@@ -181,6 +182,8 @@ static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
181 /* The last slot that hardware didn't consume yet */ 182 /* The last slot that hardware didn't consume yet */
182 empty_slot = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS); 183 empty_slot = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
183 empty_slot &= BGMAC_DMA_TX_STATDPTR; 184 empty_slot &= BGMAC_DMA_TX_STATDPTR;
185 empty_slot -= ring->index_base;
186 empty_slot &= BGMAC_DMA_TX_STATDPTR;
184 empty_slot /= sizeof(struct bgmac_dma_desc); 187 empty_slot /= sizeof(struct bgmac_dma_desc);
185 188
186 while (ring->start != empty_slot) { 189 while (ring->start != empty_slot) {
@@ -274,6 +277,8 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
274 277
275 end_slot = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_STATUS); 278 end_slot = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_STATUS);
276 end_slot &= BGMAC_DMA_RX_STATDPTR; 279 end_slot &= BGMAC_DMA_RX_STATDPTR;
280 end_slot -= ring->index_base;
281 end_slot &= BGMAC_DMA_RX_STATDPTR;
277 end_slot /= sizeof(struct bgmac_dma_desc); 282 end_slot /= sizeof(struct bgmac_dma_desc);
278 283
279 ring->end = end_slot; 284 ring->end = end_slot;
@@ -418,9 +423,6 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
418 ring = &bgmac->tx_ring[i]; 423 ring = &bgmac->tx_ring[i];
419 ring->num_slots = BGMAC_TX_RING_SLOTS; 424 ring->num_slots = BGMAC_TX_RING_SLOTS;
420 ring->mmio_base = ring_base[i]; 425 ring->mmio_base = ring_base[i];
421 if (bgmac_dma_unaligned(bgmac, ring, BGMAC_DMA_RING_TX))
422 bgmac_warn(bgmac, "TX on ring 0x%X supports unaligned addressing but this feature is not implemented\n",
423 ring->mmio_base);
424 426
425 /* Alloc ring of descriptors */ 427 /* Alloc ring of descriptors */
426 size = ring->num_slots * sizeof(struct bgmac_dma_desc); 428 size = ring->num_slots * sizeof(struct bgmac_dma_desc);
@@ -435,6 +437,13 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
435 if (ring->dma_base & 0xC0000000) 437 if (ring->dma_base & 0xC0000000)
436 bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); 438 bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n");
437 439
440 ring->unaligned = bgmac_dma_unaligned(bgmac, ring,
441 BGMAC_DMA_RING_TX);
442 if (ring->unaligned)
443 ring->index_base = lower_32_bits(ring->dma_base);
444 else
445 ring->index_base = 0;
446
438 /* No need to alloc TX slots yet */ 447 /* No need to alloc TX slots yet */
439 } 448 }
440 449
@@ -444,9 +453,6 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
444 ring = &bgmac->rx_ring[i]; 453 ring = &bgmac->rx_ring[i];
445 ring->num_slots = BGMAC_RX_RING_SLOTS; 454 ring->num_slots = BGMAC_RX_RING_SLOTS;
446 ring->mmio_base = ring_base[i]; 455 ring->mmio_base = ring_base[i];
447 if (bgmac_dma_unaligned(bgmac, ring, BGMAC_DMA_RING_RX))
448 bgmac_warn(bgmac, "RX on ring 0x%X supports unaligned addressing but this feature is not implemented\n",
449 ring->mmio_base);
450 456
451 /* Alloc ring of descriptors */ 457 /* Alloc ring of descriptors */
452 size = ring->num_slots * sizeof(struct bgmac_dma_desc); 458 size = ring->num_slots * sizeof(struct bgmac_dma_desc);
@@ -462,6 +468,13 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
462 if (ring->dma_base & 0xC0000000) 468 if (ring->dma_base & 0xC0000000)
463 bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); 469 bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n");
464 470
471 ring->unaligned = bgmac_dma_unaligned(bgmac, ring,
472 BGMAC_DMA_RING_RX);
473 if (ring->unaligned)
474 ring->index_base = lower_32_bits(ring->dma_base);
475 else
476 ring->index_base = 0;
477
465 /* Alloc RX slots */ 478 /* Alloc RX slots */
466 for (j = 0; j < ring->num_slots; j++) { 479 for (j = 0; j < ring->num_slots; j++) {
467 err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]); 480 err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
@@ -489,12 +502,14 @@ static void bgmac_dma_init(struct bgmac *bgmac)
489 for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { 502 for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) {
490 ring = &bgmac->tx_ring[i]; 503 ring = &bgmac->tx_ring[i];
491 504
492 /* We don't implement unaligned addressing, so enable first */ 505 if (!ring->unaligned)
493 bgmac_dma_tx_enable(bgmac, ring); 506 bgmac_dma_tx_enable(bgmac, ring);
494 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_RINGLO, 507 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_RINGLO,
495 lower_32_bits(ring->dma_base)); 508 lower_32_bits(ring->dma_base));
496 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_RINGHI, 509 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_RINGHI,
497 upper_32_bits(ring->dma_base)); 510 upper_32_bits(ring->dma_base));
511 if (ring->unaligned)
512 bgmac_dma_tx_enable(bgmac, ring);
498 513
499 ring->start = 0; 514 ring->start = 0;
500 ring->end = 0; /* Points the slot that should *not* be read */ 515 ring->end = 0; /* Points the slot that should *not* be read */
@@ -505,12 +520,14 @@ static void bgmac_dma_init(struct bgmac *bgmac)
505 520
506 ring = &bgmac->rx_ring[i]; 521 ring = &bgmac->rx_ring[i];
507 522
508 /* We don't implement unaligned addressing, so enable first */ 523 if (!ring->unaligned)
509 bgmac_dma_rx_enable(bgmac, ring); 524 bgmac_dma_rx_enable(bgmac, ring);
510 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGLO, 525 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGLO,
511 lower_32_bits(ring->dma_base)); 526 lower_32_bits(ring->dma_base));
512 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGHI, 527 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGHI,
513 upper_32_bits(ring->dma_base)); 528 upper_32_bits(ring->dma_base));
529 if (ring->unaligned)
530 bgmac_dma_rx_enable(bgmac, ring);
514 531
515 for (j = 0, dma_desc = ring->cpu_base; j < ring->num_slots; 532 for (j = 0, dma_desc = ring->cpu_base; j < ring->num_slots;
516 j++, dma_desc++) { 533 j++, dma_desc++) {
@@ -531,6 +548,7 @@ static void bgmac_dma_init(struct bgmac *bgmac)
531 } 548 }
532 549
533 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX, 550 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX,
551 ring->index_base +
534 ring->num_slots * sizeof(struct bgmac_dma_desc)); 552 ring->num_slots * sizeof(struct bgmac_dma_desc));
535 553
536 ring->start = 0; 554 ring->start = 0;
@@ -908,10 +926,10 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
908 struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc; 926 struct bcma_drv_cc *cc = &bgmac->core->bus->drv_cc;
909 u8 et_swtype = 0; 927 u8 et_swtype = 0;
910 u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY | 928 u8 sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHY |
911 BGMAC_CHIPCTL_1_IF_TYPE_RMII; 929 BGMAC_CHIPCTL_1_IF_TYPE_MII;
912 char buf[2]; 930 char buf[4];
913 931
914 if (bcm47xx_nvram_getenv("et_swtype", buf, 1) > 0) { 932 if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
915 if (kstrtou8(buf, 0, &et_swtype)) 933 if (kstrtou8(buf, 0, &et_swtype))
916 bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n", 934 bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
917 buf); 935 buf);
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
index 98d4b5fcc070..66c8afbdc8c7 100644
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -333,7 +333,7 @@
333 333
334#define BGMAC_CHIPCTL_1_IF_TYPE_MASK 0x00000030 334#define BGMAC_CHIPCTL_1_IF_TYPE_MASK 0x00000030
335#define BGMAC_CHIPCTL_1_IF_TYPE_RMII 0x00000000 335#define BGMAC_CHIPCTL_1_IF_TYPE_RMII 0x00000000
336#define BGMAC_CHIPCTL_1_IF_TYPE_MI 0x00000010 336#define BGMAC_CHIPCTL_1_IF_TYPE_MII 0x00000010
337#define BGMAC_CHIPCTL_1_IF_TYPE_RGMII 0x00000020 337#define BGMAC_CHIPCTL_1_IF_TYPE_RGMII 0x00000020
338#define BGMAC_CHIPCTL_1_SW_TYPE_MASK 0x000000C0 338#define BGMAC_CHIPCTL_1_SW_TYPE_MASK 0x000000C0
339#define BGMAC_CHIPCTL_1_SW_TYPE_EPHY 0x00000000 339#define BGMAC_CHIPCTL_1_SW_TYPE_EPHY 0x00000000
@@ -384,6 +384,8 @@ struct bgmac_dma_ring {
384 u16 mmio_base; 384 u16 mmio_base;
385 struct bgmac_dma_desc *cpu_base; 385 struct bgmac_dma_desc *cpu_base;
386 dma_addr_t dma_base; 386 dma_addr_t dma_base;
387 u32 index_base; /* Used for unaligned rings only, otherwise 0 */
388 bool unaligned;
387 389
388 struct bgmac_slot_info slots[BGMAC_RX_RING_SLOTS]; 390 struct bgmac_slot_info slots[BGMAC_RX_RING_SLOTS];
389}; 391};
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 0c338026ce01..97b3d32a98bd 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -246,8 +246,37 @@ enum {
246 BNX2X_MAX_CNIC_ETH_CL_ID_IDX, 246 BNX2X_MAX_CNIC_ETH_CL_ID_IDX,
247}; 247};
248 248
249#define BNX2X_CNIC_START_ETH_CID(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) *\ 249/* use a value high enough to be above all the PFs, which has least significant
250 * nibble as 8, so when cnic needs to come up with a CID for UIO to use to
251 * calculate doorbell address according to old doorbell configuration scheme
252 * (db_msg_sz 1 << 7 * cid + 0x40 DPM offset) it can come up with a valid number
253 * We must avoid coming up with cid 8 for iscsi since according to this method
254 * the designated UIO cid will come out 0 and it has a special handling for that
255 * case which doesn't suit us. Therefore will will cieling to closes cid which
256 * has least signigifcant nibble 8 and if it is 8 we will move forward to 0x18.
257 */
258
259#define BNX2X_1st_NON_L2_ETH_CID(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * \
250 (bp)->max_cos) 260 (bp)->max_cos)
261/* amount of cids traversed by UIO's DPM addition to doorbell */
262#define UIO_DPM 8
263/* roundup to DPM offset */
264#define UIO_ROUNDUP(bp) (roundup(BNX2X_1st_NON_L2_ETH_CID(bp), \
265 UIO_DPM))
266/* offset to nearest value which has lsb nibble matching DPM */
267#define UIO_CID_OFFSET(bp) ((UIO_ROUNDUP(bp) + UIO_DPM) % \
268 (UIO_DPM * 2))
269/* add offset to rounded-up cid to get a value which could be used with UIO */
270#define UIO_DPM_ALIGN(bp) (UIO_ROUNDUP(bp) + UIO_CID_OFFSET(bp))
271/* but wait - avoid UIO special case for cid 0 */
272#define UIO_DPM_CID0_OFFSET(bp) ((UIO_DPM * 2) * \
273 (UIO_DPM_ALIGN(bp) == UIO_DPM))
274/* Properly DPM aligned CID dajusted to cid 0 secal case */
275#define BNX2X_CNIC_START_ETH_CID(bp) (UIO_DPM_ALIGN(bp) + \
276 (UIO_DPM_CID0_OFFSET(bp)))
277/* how many cids were wasted - need this value for cid allocation */
278#define UIO_CID_PAD(bp) (BNX2X_CNIC_START_ETH_CID(bp) - \
279 BNX2X_1st_NON_L2_ETH_CID(bp))
251 /* iSCSI L2 */ 280 /* iSCSI L2 */
252#define BNX2X_ISCSI_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp)) 281#define BNX2X_ISCSI_ETH_CID(bp) (BNX2X_CNIC_START_ETH_CID(bp))
253 /* FCoE L2 */ 282 /* FCoE L2 */
@@ -1542,7 +1571,6 @@ struct bnx2x {
1542 */ 1571 */
1543 bool fcoe_init; 1572 bool fcoe_init;
1544 1573
1545 int pm_cap;
1546 int mrrs; 1574 int mrrs;
1547 1575
1548 struct delayed_work sp_task; 1576 struct delayed_work sp_task;
@@ -1681,10 +1709,11 @@ struct bnx2x {
1681 * Maximum CID count that might be required by the bnx2x: 1709 * Maximum CID count that might be required by the bnx2x:
1682 * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI 1710 * Max RSS * Max_Tx_Multi_Cos + FCoE + iSCSI
1683 */ 1711 */
1712
1684#define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \ 1713#define BNX2X_L2_CID_COUNT(bp) (BNX2X_NUM_ETH_QUEUES(bp) * BNX2X_MULTI_TX_COS \
1685 + 2 * CNIC_SUPPORT(bp)) 1714 + CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
1686#define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \ 1715#define BNX2X_L2_MAX_CID(bp) (BNX2X_MAX_RSS_COUNT(bp) * BNX2X_MULTI_TX_COS \
1687 + 2 * CNIC_SUPPORT(bp)) 1716 + CNIC_SUPPORT(bp) * (2 + UIO_CID_PAD(bp)))
1688#define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\ 1717#define L2_ILT_LINES(bp) (DIV_ROUND_UP(BNX2X_L2_CID_COUNT(bp),\
1689 ILT_PAGE_CIDS)) 1718 ILT_PAGE_CIDS))
1690 1719
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 90045c920d09..61726af1de6e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3008,16 +3008,16 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
3008 u16 pmcsr; 3008 u16 pmcsr;
3009 3009
3010 /* If there is no power capability, silently succeed */ 3010 /* If there is no power capability, silently succeed */
3011 if (!bp->pm_cap) { 3011 if (!bp->pdev->pm_cap) {
3012 BNX2X_DEV_INFO("No power capability. Breaking.\n"); 3012 BNX2X_DEV_INFO("No power capability. Breaking.\n");
3013 return 0; 3013 return 0;
3014 } 3014 }
3015 3015
3016 pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr); 3016 pci_read_config_word(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL, &pmcsr);
3017 3017
3018 switch (state) { 3018 switch (state) {
3019 case PCI_D0: 3019 case PCI_D0:
3020 pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, 3020 pci_write_config_word(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL,
3021 ((pmcsr & ~PCI_PM_CTRL_STATE_MASK) | 3021 ((pmcsr & ~PCI_PM_CTRL_STATE_MASK) |
3022 PCI_PM_CTRL_PME_STATUS)); 3022 PCI_PM_CTRL_PME_STATUS));
3023 3023
@@ -3041,7 +3041,7 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
3041 if (bp->wol) 3041 if (bp->wol)
3042 pmcsr |= PCI_PM_CTRL_PME_ENABLE; 3042 pmcsr |= PCI_PM_CTRL_PME_ENABLE;
3043 3043
3044 pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, 3044 pci_write_config_word(bp->pdev, bp->pdev->pm_cap + PCI_PM_CTRL,
3045 pmcsr); 3045 pmcsr);
3046 3046
3047 /* No more memory access after this point until 3047 /* No more memory access after this point until
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 2612e3c715d4..324de5f05332 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1387,9 +1387,9 @@ static bool bnx2x_is_nvm_accessible(struct bnx2x *bp)
1387 u16 pm = 0; 1387 u16 pm = 0;
1388 struct net_device *dev = pci_get_drvdata(bp->pdev); 1388 struct net_device *dev = pci_get_drvdata(bp->pdev);
1389 1389
1390 if (bp->pm_cap) 1390 if (bp->pdev->pm_cap)
1391 rc = pci_read_config_word(bp->pdev, 1391 rc = pci_read_config_word(bp->pdev,
1392 bp->pm_cap + PCI_PM_CTRL, &pm); 1392 bp->pdev->pm_cap + PCI_PM_CTRL, &pm);
1393 1393
1394 if ((rc && !netif_running(dev)) || 1394 if ((rc && !netif_running(dev)) ||
1395 (!rc && ((pm & PCI_PM_CTRL_STATE_MASK) != (__force u16)PCI_D0))) 1395 (!rc && ((pm & PCI_PM_CTRL_STATE_MASK) != (__force u16)PCI_D0)))
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 2f8dbbbd7a86..a6704b555042 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -8652,6 +8652,7 @@ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode)
8652 else if (bp->wol) { 8652 else if (bp->wol) {
8653 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; 8653 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
8654 u8 *mac_addr = bp->dev->dev_addr; 8654 u8 *mac_addr = bp->dev->dev_addr;
8655 struct pci_dev *pdev = bp->pdev;
8655 u32 val; 8656 u32 val;
8656 u16 pmc; 8657 u16 pmc;
8657 8658
@@ -8668,9 +8669,9 @@ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode)
8668 EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + entry + 4, val); 8669 EMAC_WR(bp, EMAC_REG_EMAC_MAC_MATCH + entry + 4, val);
8669 8670
8670 /* Enable the PME and clear the status */ 8671 /* Enable the PME and clear the status */
8671 pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmc); 8672 pci_read_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, &pmc);
8672 pmc |= PCI_PM_CTRL_PME_ENABLE | PCI_PM_CTRL_PME_STATUS; 8673 pmc |= PCI_PM_CTRL_PME_ENABLE | PCI_PM_CTRL_PME_STATUS;
8673 pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, pmc); 8674 pci_write_config_word(pdev, pdev->pm_cap + PCI_PM_CTRL, pmc);
8674 8675
8675 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_EN; 8676 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_EN;
8676 8677
@@ -10399,7 +10400,7 @@ static void bnx2x_get_common_hwinfo(struct bnx2x *bp)
10399 break; 10400 break;
10400 } 10401 }
10401 10402
10402 pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc); 10403 pci_read_config_word(bp->pdev, bp->pdev->pm_cap + PCI_PM_PMC, &pmc);
10403 bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG; 10404 bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG;
10404 10405
10405 BNX2X_DEV_INFO("%sWoL capable\n", 10406 BNX2X_DEV_INFO("%sWoL capable\n",
@@ -12141,8 +12142,7 @@ static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
12141 } 12142 }
12142 12143
12143 if (IS_PF(bp)) { 12144 if (IS_PF(bp)) {
12144 bp->pm_cap = pdev->pm_cap; 12145 if (!pdev->pm_cap) {
12145 if (bp->pm_cap == 0) {
12146 dev_err(&bp->pdev->dev, 12146 dev_err(&bp->pdev->dev,
12147 "Cannot find power management capability, aborting\n"); 12147 "Cannot find power management capability, aborting\n");
12148 rc = -EIO; 12148 rc = -EIO;
@@ -13632,6 +13632,10 @@ void bnx2x_setup_cnic_info(struct bnx2x *bp)
13632 cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID(bp); 13632 cp->fcoe_init_cid = BNX2X_FCOE_ETH_CID(bp);
13633 cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID(bp); 13633 cp->iscsi_l2_cid = BNX2X_ISCSI_ETH_CID(bp);
13634 13634
13635 DP(NETIF_MSG_IFUP, "BNX2X_1st_NON_L2_ETH_CID(bp) %x, cp->starting_cid %x, cp->fcoe_init_cid %x, cp->iscsi_l2_cid %x\n",
13636 BNX2X_1st_NON_L2_ETH_CID(bp), cp->starting_cid, cp->fcoe_init_cid,
13637 cp->iscsi_l2_cid);
13638
13635 if (NO_ISCSI_OOO(bp)) 13639 if (NO_ISCSI_OOO(bp))
13636 cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO; 13640 cp->drv_state |= CNIC_DRV_STATE_NO_ISCSI_OOO;
13637} 13641}
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 8142480d9770..99394bd49a13 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -3135,6 +3135,7 @@ static void cnic_service_bnx2x_bh(unsigned long data)
3135{ 3135{
3136 struct cnic_dev *dev = (struct cnic_dev *) data; 3136 struct cnic_dev *dev = (struct cnic_dev *) data;
3137 struct cnic_local *cp = dev->cnic_priv; 3137 struct cnic_local *cp = dev->cnic_priv;
3138 struct bnx2x *bp = netdev_priv(dev->netdev);
3138 u32 status_idx, new_status_idx; 3139 u32 status_idx, new_status_idx;
3139 3140
3140 if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) 3141 if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags)))
@@ -3146,7 +3147,7 @@ static void cnic_service_bnx2x_bh(unsigned long data)
3146 CNIC_WR16(dev, cp->kcq1.io_addr, 3147 CNIC_WR16(dev, cp->kcq1.io_addr,
3147 cp->kcq1.sw_prod_idx + MAX_KCQ_IDX); 3148 cp->kcq1.sw_prod_idx + MAX_KCQ_IDX);
3148 3149
3149 if (cp->ethdev->drv_state & CNIC_DRV_STATE_NO_FCOE) { 3150 if (!CNIC_SUPPORTS_FCOE(bp)) {
3150 cp->arm_int(dev, status_idx); 3151 cp->arm_int(dev, status_idx);
3151 break; 3152 break;
3152 } 3153 }
@@ -5217,7 +5218,8 @@ static void cnic_init_rings(struct cnic_dev *dev)
5217 "iSCSI CLIENT_SETUP did not complete\n"); 5218 "iSCSI CLIENT_SETUP did not complete\n");
5218 cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); 5219 cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1);
5219 cnic_ring_ctl(dev, cid, cli, 1); 5220 cnic_ring_ctl(dev, cid, cli, 1);
5220 *cid_ptr = cid; 5221 *cid_ptr = cid >> 4;
5222 *(cid_ptr + 1) = cid * bp->db_size;
5221 } 5223 }
5222} 5224}
5223 5225
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 5701f3d1a169..12d961c4ebca 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -3034,6 +3034,7 @@ static bool tg3_phy_led_bug(struct tg3 *tp)
3034{ 3034{
3035 switch (tg3_asic_rev(tp)) { 3035 switch (tg3_asic_rev(tp)) {
3036 case ASIC_REV_5719: 3036 case ASIC_REV_5719:
3037 case ASIC_REV_5720:
3037 if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) && 3038 if ((tp->phy_flags & TG3_PHYFLG_MII_SERDES) &&
3038 !tp->pci_fn) 3039 !tp->pci_fn)
3039 return true; 3040 return true;
@@ -16192,12 +16193,12 @@ static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent)
16192 * So explicitly force the chip into D0 here. 16193 * So explicitly force the chip into D0 here.
16193 */ 16194 */
16194 pci_read_config_dword(tp->pdev, 16195 pci_read_config_dword(tp->pdev,
16195 tp->pm_cap + PCI_PM_CTRL, 16196 tp->pdev->pm_cap + PCI_PM_CTRL,
16196 &pm_reg); 16197 &pm_reg);
16197 pm_reg &= ~PCI_PM_CTRL_STATE_MASK; 16198 pm_reg &= ~PCI_PM_CTRL_STATE_MASK;
16198 pm_reg |= PCI_PM_CTRL_PME_ENABLE | 0 /* D0 */; 16199 pm_reg |= PCI_PM_CTRL_PME_ENABLE | 0 /* D0 */;
16199 pci_write_config_dword(tp->pdev, 16200 pci_write_config_dword(tp->pdev,
16200 tp->pm_cap + PCI_PM_CTRL, 16201 tp->pdev->pm_cap + PCI_PM_CTRL,
16201 pm_reg); 16202 pm_reg);
16202 16203
16203 /* Also, force SERR#/PERR# in PCI command. */ 16204 /* Also, force SERR#/PERR# in PCI command. */
@@ -17346,7 +17347,6 @@ static int tg3_init_one(struct pci_dev *pdev,
17346 tp = netdev_priv(dev); 17347 tp = netdev_priv(dev);
17347 tp->pdev = pdev; 17348 tp->pdev = pdev;
17348 tp->dev = dev; 17349 tp->dev = dev;
17349 tp->pm_cap = pdev->pm_cap;
17350 tp->rx_mode = TG3_DEF_RX_MODE; 17350 tp->rx_mode = TG3_DEF_RX_MODE;
17351 tp->tx_mode = TG3_DEF_TX_MODE; 17351 tp->tx_mode = TG3_DEF_TX_MODE;
17352 tp->irq_sync = 1; 17352 tp->irq_sync = 1;
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
index ddb8be1298ea..70257808aa37 100644
--- a/drivers/net/ethernet/broadcom/tg3.h
+++ b/drivers/net/ethernet/broadcom/tg3.h
@@ -3234,7 +3234,6 @@ struct tg3 {
3234 u8 pci_lat_timer; 3234 u8 pci_lat_timer;
3235 3235
3236 int pci_fn; 3236 int pci_fn;
3237 int pm_cap;
3238 int msi_cap; 3237 int msi_cap;
3239 int pcix_cap; 3238 int pcix_cap;
3240 int pcie_readrq; 3239 int pcie_readrq;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 0d0665ca6f19..c73cabdbd4c0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -6149,8 +6149,10 @@ static int __init cxgb4_init_module(void)
6149 pr_warn("could not create debugfs entry, continuing\n"); 6149 pr_warn("could not create debugfs entry, continuing\n");
6150 6150
6151 ret = pci_register_driver(&cxgb4_driver); 6151 ret = pci_register_driver(&cxgb4_driver);
6152 if (ret < 0) 6152 if (ret < 0) {
6153 debugfs_remove(cxgb4_debugfs_root); 6153 debugfs_remove(cxgb4_debugfs_root);
6154 destroy_workqueue(workq);
6155 }
6154 6156
6155 register_inet6addr_notifier(&cxgb4_inet6addr_notifier); 6157 register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
6156 6158
diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
index 2db6c573cec7..263b92c00cbf 100644
--- a/drivers/net/ethernet/dec/tulip/de4x5.c
+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
@@ -1321,7 +1321,7 @@ de4x5_open(struct net_device *dev)
1321 if (request_irq(dev->irq, de4x5_interrupt, IRQF_SHARED, 1321 if (request_irq(dev->irq, de4x5_interrupt, IRQF_SHARED,
1322 lp->adapter_name, dev)) { 1322 lp->adapter_name, dev)) {
1323 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq); 1323 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq);
1324 if (request_irq(dev->irq, de4x5_interrupt, IRQF_DISABLED | IRQF_SHARED, 1324 if (request_irq(dev->irq, de4x5_interrupt, IRQF_SHARED,
1325 lp->adapter_name, dev)) { 1325 lp->adapter_name, dev)) {
1326 printk("\n Cannot get IRQ- reconfigure your hardware.\n"); 1326 printk("\n Cannot get IRQ- reconfigure your hardware.\n");
1327 disable_ast(dev); 1327 disable_ast(dev);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 3224d28cdad4..100b528b9bd0 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2802,7 +2802,7 @@ static int be_vfs_if_create(struct be_adapter *adapter)
2802 struct be_resources res = {0}; 2802 struct be_resources res = {0};
2803 struct be_vf_cfg *vf_cfg; 2803 struct be_vf_cfg *vf_cfg;
2804 u32 cap_flags, en_flags, vf; 2804 u32 cap_flags, en_flags, vf;
2805 int status; 2805 int status = 0;
2806 2806
2807 cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 2807 cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
2808 BE_IF_FLAGS_MULTICAST; 2808 BE_IF_FLAGS_MULTICAST;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index f9aacf5d8523..b2793b91cc55 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2199,7 +2199,7 @@ fec_probe(struct platform_device *pdev)
2199 goto failed_irq; 2199 goto failed_irq;
2200 } 2200 }
2201 ret = devm_request_irq(&pdev->dev, irq, fec_enet_interrupt, 2201 ret = devm_request_irq(&pdev->dev, irq, fec_enet_interrupt,
2202 IRQF_DISABLED, pdev->name, ndev); 2202 0, pdev->name, ndev);
2203 if (ret) 2203 if (ret)
2204 goto failed_irq; 2204 goto failed_irq;
2205 } 2205 }
diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c
index e3c7c697fc45..91227d03274e 100644
--- a/drivers/net/ethernet/hp/hp100.c
+++ b/drivers/net/ethernet/hp/hp100.c
@@ -1097,7 +1097,7 @@ static int hp100_open(struct net_device *dev)
1097 /* New: if bus is PCI or EISA, interrupts might be shared interrupts */ 1097 /* New: if bus is PCI or EISA, interrupts might be shared interrupts */
1098 if (request_irq(dev->irq, hp100_interrupt, 1098 if (request_irq(dev->irq, hp100_interrupt,
1099 lp->bus == HP100_BUS_PCI || lp->bus == 1099 lp->bus == HP100_BUS_PCI || lp->bus ==
1100 HP100_BUS_EISA ? IRQF_SHARED : IRQF_DISABLED, 1100 HP100_BUS_EISA ? IRQF_SHARED : 0,
1101 "hp100", dev)) { 1101 "hp100", dev)) {
1102 printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq); 1102 printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq);
1103 return -EAGAIN; 1103 return -EAGAIN;
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index 35853b43d66e..2d1c6bdd3618 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -102,6 +102,19 @@ static int ehea_probe_adapter(struct platform_device *dev);
102 102
103static int ehea_remove(struct platform_device *dev); 103static int ehea_remove(struct platform_device *dev);
104 104
105static struct of_device_id ehea_module_device_table[] = {
106 {
107 .name = "lhea",
108 .compatible = "IBM,lhea",
109 },
110 {
111 .type = "network",
112 .compatible = "IBM,lhea-ethernet",
113 },
114 {},
115};
116MODULE_DEVICE_TABLE(of, ehea_module_device_table);
117
105static struct of_device_id ehea_device_table[] = { 118static struct of_device_id ehea_device_table[] = {
106 { 119 {
107 .name = "lhea", 120 .name = "lhea",
@@ -109,7 +122,6 @@ static struct of_device_id ehea_device_table[] = {
109 }, 122 },
110 {}, 123 {},
111}; 124};
112MODULE_DEVICE_TABLE(of, ehea_device_table);
113 125
114static struct platform_driver ehea_driver = { 126static struct platform_driver ehea_driver = {
115 .driver = { 127 .driver = {
@@ -1285,7 +1297,7 @@ static int ehea_reg_interrupts(struct net_device *dev)
1285 1297
1286 ret = ibmebus_request_irq(port->qp_eq->attr.ist1, 1298 ret = ibmebus_request_irq(port->qp_eq->attr.ist1,
1287 ehea_qp_aff_irq_handler, 1299 ehea_qp_aff_irq_handler,
1288 IRQF_DISABLED, port->int_aff_name, port); 1300 0, port->int_aff_name, port);
1289 if (ret) { 1301 if (ret) {
1290 netdev_err(dev, "failed registering irq for qp_aff_irq_handler:ist=%X\n", 1302 netdev_err(dev, "failed registering irq for qp_aff_irq_handler:ist=%X\n",
1291 port->qp_eq->attr.ist1); 1303 port->qp_eq->attr.ist1);
@@ -1303,8 +1315,7 @@ static int ehea_reg_interrupts(struct net_device *dev)
1303 "%s-queue%d", dev->name, i); 1315 "%s-queue%d", dev->name, i);
1304 ret = ibmebus_request_irq(pr->eq->attr.ist1, 1316 ret = ibmebus_request_irq(pr->eq->attr.ist1,
1305 ehea_recv_irq_handler, 1317 ehea_recv_irq_handler,
1306 IRQF_DISABLED, pr->int_send_name, 1318 0, pr->int_send_name, pr);
1307 pr);
1308 if (ret) { 1319 if (ret) {
1309 netdev_err(dev, "failed registering irq for ehea_queue port_res_nr:%d, ist=%X\n", 1320 netdev_err(dev, "failed registering irq for ehea_queue port_res_nr:%d, ist=%X\n",
1310 i, pr->eq->attr.ist1); 1321 i, pr->eq->attr.ist1);
@@ -3320,7 +3331,7 @@ static int ehea_probe_adapter(struct platform_device *dev)
3320 } 3331 }
3321 3332
3322 ret = ibmebus_request_irq(adapter->neq->attr.ist1, 3333 ret = ibmebus_request_irq(adapter->neq->attr.ist1,
3323 ehea_interrupt_neq, IRQF_DISABLED, 3334 ehea_interrupt_neq, 0,
3324 "ehea_neq", adapter); 3335 "ehea_neq", adapter);
3325 if (ret) { 3336 if (ret) {
3326 dev_err(&dev->dev, "requesting NEQ IRQ failed\n"); 3337 dev_err(&dev->dev, "requesting NEQ IRQ failed\n");
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index a8633b8f0ac5..d14c8f53384c 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -922,6 +922,14 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
922 else 922 else
923 mask &= ~(1 << 30); 923 mask &= ~(1 << 30);
924 } 924 }
925 if (mac->type == e1000_pch2lan) {
926 /* SHRAH[0,1,2] different than previous */
927 if (i == 7)
928 mask &= 0xFFF4FFFF;
929 /* SHRAH[3] different than SHRAH[0,1,2] */
930 if (i == 10)
931 mask |= (1 << 30);
932 }
925 933
926 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask, 934 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask,
927 0xFFFFFFFF); 935 0xFFFFFFFF);
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index af08188d7e62..42f0f6717511 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -1371,7 +1371,10 @@ static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1371 return; 1371 return;
1372 } 1372 }
1373 1373
1374 if (index < hw->mac.rar_entry_count) { 1374 /* RAR[1-6] are owned by manageability. Skip those and program the
1375 * next address into the SHRA register array.
1376 */
1377 if (index < (u32)(hw->mac.rar_entry_count - 6)) {
1375 s32 ret_val; 1378 s32 ret_val;
1376 1379
1377 ret_val = e1000_acquire_swflag_ich8lan(hw); 1380 ret_val = e1000_acquire_swflag_ich8lan(hw);
@@ -1962,8 +1965,8 @@ void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1962 if (ret_val) 1965 if (ret_val)
1963 goto release; 1966 goto release;
1964 1967
1965 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */ 1968 /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
1966 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) { 1969 for (i = 0; i < (hw->mac.rar_entry_count); i++) {
1967 mac_reg = er32(RAL(i)); 1970 mac_reg = er32(RAL(i));
1968 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i), 1971 hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
1969 (u16)(mac_reg & 0xFFFF)); 1972 (u16)(mac_reg & 0xFFFF));
@@ -2007,10 +2010,10 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
2007 return ret_val; 2010 return ret_val;
2008 2011
2009 if (enable) { 2012 if (enable) {
2010 /* Write Rx addresses (rar_entry_count for RAL/H, +4 for 2013 /* Write Rx addresses (rar_entry_count for RAL/H, and
2011 * SHRAL/H) and initial CRC values to the MAC 2014 * SHRAL/H) and initial CRC values to the MAC
2012 */ 2015 */
2013 for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) { 2016 for (i = 0; i < hw->mac.rar_entry_count; i++) {
2014 u8 mac_addr[ETH_ALEN] = { 0 }; 2017 u8 mac_addr[ETH_ALEN] = { 0 };
2015 u32 addr_high, addr_low; 2018 u32 addr_high, addr_low;
2016 2019
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.h b/drivers/net/ethernet/intel/e1000e/ich8lan.h
index 59865695b282..217090df33e7 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.h
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h
@@ -98,7 +98,7 @@
98#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL 98#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
99 99
100#define E1000_ICH_RAR_ENTRIES 7 100#define E1000_ICH_RAR_ENTRIES 7
101#define E1000_PCH2_RAR_ENTRIES 5 /* RAR[0], SHRA[0-3] */ 101#define E1000_PCH2_RAR_ENTRIES 11 /* RAR[0-6], SHRA[0-3] */
102#define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */ 102#define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */
103 103
104#define PHY_PAGE_SHIFT 5 104#define PHY_PAGE_SHIFT 5
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index e87e9b01f404..4ef786775acb 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -4868,7 +4868,7 @@ static void e1000_watchdog_task(struct work_struct *work)
4868 */ 4868 */
4869 if ((hw->phy.type == e1000_phy_igp_3 || 4869 if ((hw->phy.type == e1000_phy_igp_3 ||
4870 hw->phy.type == e1000_phy_bm) && 4870 hw->phy.type == e1000_phy_bm) &&
4871 (hw->mac.autoneg == true) && 4871 hw->mac.autoneg &&
4872 (adapter->link_speed == SPEED_10 || 4872 (adapter->link_speed == SPEED_10 ||
4873 adapter->link_speed == SPEED_100) && 4873 adapter->link_speed == SPEED_100) &&
4874 (adapter->link_duplex == HALF_DUPLEX)) { 4874 (adapter->link_duplex == HALF_DUPLEX)) {
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index 79b58353d849..47c2d10df826 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -719,6 +719,10 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
719 u32 ctrl_ext; 719 u32 ctrl_ext;
720 u32 mdic; 720 u32 mdic;
721 721
722 /* Extra read required for some PHY's on i354 */
723 if (hw->mac.type == e1000_i354)
724 igb_get_phy_id(hw);
725
722 /* For SGMII PHYs, we try the list of possible addresses until 726 /* For SGMII PHYs, we try the list of possible addresses until
723 * we find one that works. For non-SGMII PHYs 727 * we find one that works. For non-SGMII PHYs
724 * (e.g. integrated copper PHYs), an address of 1 should 728 * (e.g. integrated copper PHYs), an address of 1 should
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c
index f0dfd41dd4bd..298f0ed50670 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.c
@@ -712,6 +712,7 @@ static s32 igb_set_fc_watermarks(struct e1000_hw *hw)
712static s32 igb_set_default_fc(struct e1000_hw *hw) 712static s32 igb_set_default_fc(struct e1000_hw *hw)
713{ 713{
714 s32 ret_val = 0; 714 s32 ret_val = 0;
715 u16 lan_offset;
715 u16 nvm_data; 716 u16 nvm_data;
716 717
717 /* Read and store word 0x0F of the EEPROM. This word contains bits 718 /* Read and store word 0x0F of the EEPROM. This word contains bits
@@ -722,7 +723,14 @@ static s32 igb_set_default_fc(struct e1000_hw *hw)
722 * control setting, then the variable hw->fc will 723 * control setting, then the variable hw->fc will
723 * be initialized based on a value in the EEPROM. 724 * be initialized based on a value in the EEPROM.
724 */ 725 */
725 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data); 726 if (hw->mac.type == e1000_i350) {
727 lan_offset = NVM_82580_LAN_FUNC_OFFSET(hw->bus.func);
728 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG
729 + lan_offset, 1, &nvm_data);
730 } else {
731 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG,
732 1, &nvm_data);
733 }
726 734
727 if (ret_val) { 735 if (ret_val) {
728 hw_dbg("NVM Read Error\n"); 736 hw_dbg("NVM Read Error\n");
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 0e1b973659b0..e8649abf97c0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -160,6 +160,13 @@ static int ixgbe_get_settings(struct net_device *netdev,
160 bool autoneg = false; 160 bool autoneg = false;
161 bool link_up; 161 bool link_up;
162 162
163 /* SFP type is needed for get_link_capabilities */
164 if (hw->phy.media_type & (ixgbe_media_type_fiber |
165 ixgbe_media_type_fiber_qsfp)) {
166 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
167 hw->phy.ops.identify_sfp(hw);
168 }
169
163 hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg); 170 hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg);
164 171
165 /* set the supported link speeds */ 172 /* set the supported link speeds */
@@ -186,6 +193,11 @@ static int ixgbe_get_settings(struct net_device *netdev,
186 ecmd->advertising |= ADVERTISED_1000baseT_Full; 193 ecmd->advertising |= ADVERTISED_1000baseT_Full;
187 if (supported_link & IXGBE_LINK_SPEED_100_FULL) 194 if (supported_link & IXGBE_LINK_SPEED_100_FULL)
188 ecmd->advertising |= ADVERTISED_100baseT_Full; 195 ecmd->advertising |= ADVERTISED_100baseT_Full;
196
197 if (hw->phy.multispeed_fiber && !autoneg) {
198 if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
199 ecmd->advertising = ADVERTISED_10000baseT_Full;
200 }
189 } 201 }
190 202
191 if (autoneg) { 203 if (autoneg) {
@@ -314,6 +326,14 @@ static int ixgbe_set_settings(struct net_device *netdev,
314 if (ecmd->advertising & ~ecmd->supported) 326 if (ecmd->advertising & ~ecmd->supported)
315 return -EINVAL; 327 return -EINVAL;
316 328
329 /* only allow one speed at a time if no autoneg */
330 if (!ecmd->autoneg && hw->phy.multispeed_fiber) {
331 if (ecmd->advertising ==
332 (ADVERTISED_10000baseT_Full |
333 ADVERTISED_1000baseT_Full))
334 return -EINVAL;
335 }
336
317 old = hw->phy.autoneg_advertised; 337 old = hw->phy.autoneg_advertised;
318 advertised = 0; 338 advertised = 0;
319 if (ecmd->advertising & ADVERTISED_10000baseT_Full) 339 if (ecmd->advertising & ADVERTISED_10000baseT_Full)
@@ -1805,6 +1825,10 @@ static int ixgbe_run_loopback_test(struct ixgbe_adapter *adapter)
1805 unsigned int size = 1024; 1825 unsigned int size = 1024;
1806 netdev_tx_t tx_ret_val; 1826 netdev_tx_t tx_ret_val;
1807 struct sk_buff *skb; 1827 struct sk_buff *skb;
1828 u32 flags_orig = adapter->flags;
1829
1830 /* DCB can modify the frames on Tx */
1831 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
1808 1832
1809 /* allocate test skb */ 1833 /* allocate test skb */
1810 skb = alloc_skb(size, GFP_KERNEL); 1834 skb = alloc_skb(size, GFP_KERNEL);
@@ -1857,6 +1881,7 @@ static int ixgbe_run_loopback_test(struct ixgbe_adapter *adapter)
1857 1881
1858 /* free the original skb */ 1882 /* free the original skb */
1859 kfree_skb(skb); 1883 kfree_skb(skb);
1884 adapter->flags = flags_orig;
1860 1885
1861 return ret_val; 1886 return ret_val;
1862} 1887}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 7aba452833e5..0ade0cd5ef53 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3571,7 +3571,7 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
3571{ 3571{
3572 struct ixgbe_hw *hw = &adapter->hw; 3572 struct ixgbe_hw *hw = &adapter->hw;
3573 int i; 3573 int i;
3574 u32 rxctrl; 3574 u32 rxctrl, rfctl;
3575 3575
3576 /* disable receives while setting up the descriptors */ 3576 /* disable receives while setting up the descriptors */
3577 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); 3577 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
@@ -3580,6 +3580,13 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
3580 ixgbe_setup_psrtype(adapter); 3580 ixgbe_setup_psrtype(adapter);
3581 ixgbe_setup_rdrxctl(adapter); 3581 ixgbe_setup_rdrxctl(adapter);
3582 3582
3583 /* RSC Setup */
3584 rfctl = IXGBE_READ_REG(hw, IXGBE_RFCTL);
3585 rfctl &= ~IXGBE_RFCTL_RSC_DIS;
3586 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))
3587 rfctl |= IXGBE_RFCTL_RSC_DIS;
3588 IXGBE_WRITE_REG(hw, IXGBE_RFCTL, rfctl);
3589
3583 /* Program registers for the distribution of queues */ 3590 /* Program registers for the distribution of queues */
3584 ixgbe_setup_mrqc(adapter); 3591 ixgbe_setup_mrqc(adapter);
3585 3592
@@ -5993,8 +6000,16 @@ static void ixgbe_sfp_link_config_subtask(struct ixgbe_adapter *adapter)
5993 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; 6000 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
5994 6001
5995 speed = hw->phy.autoneg_advertised; 6002 speed = hw->phy.autoneg_advertised;
5996 if ((!speed) && (hw->mac.ops.get_link_capabilities)) 6003 if ((!speed) && (hw->mac.ops.get_link_capabilities)) {
5997 hw->mac.ops.get_link_capabilities(hw, &speed, &autoneg); 6004 hw->mac.ops.get_link_capabilities(hw, &speed, &autoneg);
6005
6006 /* setup the highest link when no autoneg */
6007 if (!autoneg) {
6008 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
6009 speed = IXGBE_LINK_SPEED_10GB_FULL;
6010 }
6011 }
6012
5998 if (hw->mac.ops.setup_link) 6013 if (hw->mac.ops.setup_link)
5999 hw->mac.ops.setup_link(hw, speed, true); 6014 hw->mac.ops.setup_link(hw, speed, true);
6000 6015
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 6442cf8f9dce..10775cb9b6d8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -1861,6 +1861,7 @@ enum {
1861#define IXGBE_RFCTL_ISCSI_DIS 0x00000001 1861#define IXGBE_RFCTL_ISCSI_DIS 0x00000001
1862#define IXGBE_RFCTL_ISCSI_DWC_MASK 0x0000003E 1862#define IXGBE_RFCTL_ISCSI_DWC_MASK 0x0000003E
1863#define IXGBE_RFCTL_ISCSI_DWC_SHIFT 1 1863#define IXGBE_RFCTL_ISCSI_DWC_SHIFT 1
1864#define IXGBE_RFCTL_RSC_DIS 0x00000020
1864#define IXGBE_RFCTL_NFSW_DIS 0x00000040 1865#define IXGBE_RFCTL_NFSW_DIS 0x00000040
1865#define IXGBE_RFCTL_NFSR_DIS 0x00000080 1866#define IXGBE_RFCTL_NFSR_DIS 0x00000080
1866#define IXGBE_RFCTL_NFS_VER_MASK 0x00000300 1867#define IXGBE_RFCTL_NFS_VER_MASK 0x00000300
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index bfdb06860397..6a6c1f76d8e0 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -282,8 +282,7 @@ ltq_etop_hw_init(struct net_device *dev)
282 282
283 if (IS_TX(i)) { 283 if (IS_TX(i)) {
284 ltq_dma_alloc_tx(&ch->dma); 284 ltq_dma_alloc_tx(&ch->dma);
285 request_irq(irq, ltq_etop_dma_irq, IRQF_DISABLED, 285 request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv);
286 "etop_tx", priv);
287 } else if (IS_RX(i)) { 286 } else if (IS_RX(i)) {
288 ltq_dma_alloc_rx(&ch->dma); 287 ltq_dma_alloc_rx(&ch->dma);
289 for (ch->dma.desc = 0; ch->dma.desc < LTQ_DESC_NUM; 288 for (ch->dma.desc = 0; ch->dma.desc < LTQ_DESC_NUM;
@@ -291,8 +290,7 @@ ltq_etop_hw_init(struct net_device *dev)
291 if (ltq_etop_alloc_skb(ch)) 290 if (ltq_etop_alloc_skb(ch))
292 return -ENOMEM; 291 return -ENOMEM;
293 ch->dma.desc = 0; 292 ch->dma.desc = 0;
294 request_irq(irq, ltq_etop_dma_irq, IRQF_DISABLED, 293 request_irq(irq, ltq_etop_dma_irq, 0, "etop_rx", priv);
295 "etop_rx", priv);
296 } 294 }
297 ch->dma.irq = irq; 295 ch->dma.irq = irq;
298 } 296 }
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 4ae0c7426010..fff62460185c 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1123,8 +1123,7 @@ static int pxa168_eth_open(struct net_device *dev)
1123 struct pxa168_eth_private *pep = netdev_priv(dev); 1123 struct pxa168_eth_private *pep = netdev_priv(dev);
1124 int err; 1124 int err;
1125 1125
1126 err = request_irq(dev->irq, pxa168_eth_int_handler, 1126 err = request_irq(dev->irq, pxa168_eth_int_handler, 0, dev->name, dev);
1127 IRQF_DISABLED, dev->name, dev);
1128 if (err) { 1127 if (err) {
1129 dev_err(&dev->dev, "can't assign irq\n"); 1128 dev_err(&dev->dev, "can't assign irq\n");
1130 return -EAGAIN; 1129 return -EAGAIN;
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index ef94a591f9e5..1a9c4f6269ea 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -3092,6 +3092,9 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
3092 if (!nskb) 3092 if (!nskb)
3093 goto resubmit; 3093 goto resubmit;
3094 3094
3095 skb = e->skb;
3096 prefetch(skb->data);
3097
3095 if (skge_rx_setup(skge, e, nskb, skge->rx_buf_size) < 0) { 3098 if (skge_rx_setup(skge, e, nskb, skge->rx_buf_size) < 0) {
3096 dev_kfree_skb(nskb); 3099 dev_kfree_skb(nskb);
3097 goto resubmit; 3100 goto resubmit;
@@ -3101,8 +3104,6 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
3101 dma_unmap_addr(e, mapaddr), 3104 dma_unmap_addr(e, mapaddr),
3102 dma_unmap_len(e, maplen), 3105 dma_unmap_len(e, maplen),
3103 PCI_DMA_FROMDEVICE); 3106 PCI_DMA_FROMDEVICE);
3104 skb = e->skb;
3105 prefetch(skb->data);
3106 } 3107 }
3107 3108
3108 skb_put(skb, len); 3109 skb_put(skb, len);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index a28cd801a236..0c750985f47e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -53,9 +53,11 @@ static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
53 for (i = 0; i < priv->tx_ring_num; i++) { 53 for (i = 0; i < priv->tx_ring_num; i++) {
54 priv->tx_cq[i].moder_cnt = priv->tx_frames; 54 priv->tx_cq[i].moder_cnt = priv->tx_frames;
55 priv->tx_cq[i].moder_time = priv->tx_usecs; 55 priv->tx_cq[i].moder_time = priv->tx_usecs;
56 err = mlx4_en_set_cq_moder(priv, &priv->tx_cq[i]); 56 if (priv->port_up) {
57 if (err) 57 err = mlx4_en_set_cq_moder(priv, &priv->tx_cq[i]);
58 return err; 58 if (err)
59 return err;
60 }
59 } 61 }
60 62
61 if (priv->adaptive_rx_coal) 63 if (priv->adaptive_rx_coal)
@@ -65,9 +67,11 @@ static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
65 priv->rx_cq[i].moder_cnt = priv->rx_frames; 67 priv->rx_cq[i].moder_cnt = priv->rx_frames;
66 priv->rx_cq[i].moder_time = priv->rx_usecs; 68 priv->rx_cq[i].moder_time = priv->rx_usecs;
67 priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; 69 priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
68 err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); 70 if (priv->port_up) {
69 if (err) 71 err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]);
70 return err; 72 if (err)
73 return err;
74 }
71 } 75 }
72 76
73 return err; 77 return err;
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index 0fba1532d326..075f4e21d33d 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -915,7 +915,7 @@ static int ks_net_open(struct net_device *netdev)
915 struct ks_net *ks = netdev_priv(netdev); 915 struct ks_net *ks = netdev_priv(netdev);
916 int err; 916 int err;
917 917
918#define KS_INT_FLAGS (IRQF_DISABLED|IRQF_TRIGGER_LOW) 918#define KS_INT_FLAGS IRQF_TRIGGER_LOW
919 /* lock the card, even if we may not actually do anything 919 /* lock the card, even if we may not actually do anything
920 * else at the moment. 920 * else at the moment.
921 */ 921 */
diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c b/drivers/net/ethernet/natsemi/jazzsonic.c
index c20766c2f65b..79257f71c5d9 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -83,8 +83,7 @@ static int jazzsonic_open(struct net_device* dev)
83{ 83{
84 int retval; 84 int retval;
85 85
86 retval = request_irq(dev->irq, sonic_interrupt, IRQF_DISABLED, 86 retval = request_irq(dev->irq, sonic_interrupt, 0, "sonic", dev);
87 "sonic", dev);
88 if (retval) { 87 if (retval) {
89 printk(KERN_ERR "%s: unable to get IRQ %d.\n", 88 printk(KERN_ERR "%s: unable to get IRQ %d.\n",
90 dev->name, dev->irq); 89 dev->name, dev->irq);
diff --git a/drivers/net/ethernet/natsemi/xtsonic.c b/drivers/net/ethernet/natsemi/xtsonic.c
index c2e0256fe3df..4da172ac5599 100644
--- a/drivers/net/ethernet/natsemi/xtsonic.c
+++ b/drivers/net/ethernet/natsemi/xtsonic.c
@@ -95,8 +95,7 @@ static int xtsonic_open(struct net_device *dev)
95{ 95{
96 int retval; 96 int retval;
97 97
98 retval = request_irq(dev->irq, sonic_interrupt, IRQF_DISABLED, 98 retval = request_irq(dev->irq, sonic_interrupt, 0, "sonic", dev);
99 "sonic", dev);
100 if (retval) { 99 if (retval) {
101 printk(KERN_ERR "%s: unable to get IRQ %d.\n", 100 printk(KERN_ERR "%s: unable to get IRQ %d.\n",
102 dev->name, dev->irq); 101 dev->name, dev->irq);
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index c498181a9aa8..5b65356e7568 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -1219,7 +1219,7 @@ static int pasemi_mac_open(struct net_device *dev)
1219 snprintf(mac->tx_irq_name, sizeof(mac->tx_irq_name), "%s tx", 1219 snprintf(mac->tx_irq_name, sizeof(mac->tx_irq_name), "%s tx",
1220 dev->name); 1220 dev->name);
1221 1221
1222 ret = request_irq(mac->tx->chan.irq, pasemi_mac_tx_intr, IRQF_DISABLED, 1222 ret = request_irq(mac->tx->chan.irq, pasemi_mac_tx_intr, 0,
1223 mac->tx_irq_name, mac->tx); 1223 mac->tx_irq_name, mac->tx);
1224 if (ret) { 1224 if (ret) {
1225 dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n", 1225 dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n",
@@ -1230,7 +1230,7 @@ static int pasemi_mac_open(struct net_device *dev)
1230 snprintf(mac->rx_irq_name, sizeof(mac->rx_irq_name), "%s rx", 1230 snprintf(mac->rx_irq_name, sizeof(mac->rx_irq_name), "%s rx",
1231 dev->name); 1231 dev->name);
1232 1232
1233 ret = request_irq(mac->rx->chan.irq, pasemi_mac_rx_intr, IRQF_DISABLED, 1233 ret = request_irq(mac->rx->chan.irq, pasemi_mac_rx_intr, 0,
1234 mac->rx_irq_name, mac->rx); 1234 mac->rx_irq_name, mac->rx);
1235 if (ret) { 1235 if (ret) {
1236 dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n", 1236 dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n",
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index 652cc13c5023..392b9bd12b4f 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -1561,6 +1561,7 @@ static int qlcnic_sriov_vf_reinit_driver(struct qlcnic_adapter *adapter)
1561{ 1561{
1562 int err; 1562 int err;
1563 1563
1564 adapter->need_fw_reset = 0;
1564 qlcnic_83xx_reinit_mbx_work(adapter->ahw->mailbox); 1565 qlcnic_83xx_reinit_mbx_work(adapter->ahw->mailbox);
1565 qlcnic_83xx_enable_mbx_interrupt(adapter); 1566 qlcnic_83xx_enable_mbx_interrupt(adapter);
1566 1567
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 6f87f2cde647..3397cee89777 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -4231,6 +4231,7 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
4231 case RTL_GIGA_MAC_VER_23: 4231 case RTL_GIGA_MAC_VER_23:
4232 case RTL_GIGA_MAC_VER_24: 4232 case RTL_GIGA_MAC_VER_24:
4233 case RTL_GIGA_MAC_VER_34: 4233 case RTL_GIGA_MAC_VER_34:
4234 case RTL_GIGA_MAC_VER_35:
4234 RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST); 4235 RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
4235 break; 4236 break;
4236 case RTL_GIGA_MAC_VER_40: 4237 case RTL_GIGA_MAC_VER_40:
diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index 8b7152565c5e..088921294448 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -7,7 +7,7 @@ config SFC
7 select I2C_ALGOBIT 7 select I2C_ALGOBIT
8 select PTP_1588_CLOCK 8 select PTP_1588_CLOCK
9 ---help--- 9 ---help---
10 This driver supports 10-gigabit Ethernet cards based on 10 This driver supports 10/40-gigabit Ethernet cards based on
11 the Solarflare SFC4000, SFC9000-family and SFC9100-family 11 the Solarflare SFC4000, SFC9000-family and SFC9100-family
12 controllers. 12 controllers.
13 13
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 5f42313b4965..9f18ae984f9e 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -94,7 +94,7 @@ static unsigned int efx_ef10_mem_map_size(struct efx_nic *efx)
94 return resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]); 94 return resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]);
95} 95}
96 96
97static int efx_ef10_init_capabilities(struct efx_nic *efx) 97static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
98{ 98{
99 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CAPABILITIES_OUT_LEN); 99 MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CAPABILITIES_OUT_LEN);
100 struct efx_ef10_nic_data *nic_data = efx->nic_data; 100 struct efx_ef10_nic_data *nic_data = efx->nic_data;
@@ -107,16 +107,27 @@ static int efx_ef10_init_capabilities(struct efx_nic *efx)
107 outbuf, sizeof(outbuf), &outlen); 107 outbuf, sizeof(outbuf), &outlen);
108 if (rc) 108 if (rc)
109 return rc; 109 return rc;
110 if (outlen < sizeof(outbuf)) {
111 netif_err(efx, drv, efx->net_dev,
112 "unable to read datapath firmware capabilities\n");
113 return -EIO;
114 }
110 115
111 if (outlen >= sizeof(outbuf)) { 116 nic_data->datapath_caps =
112 nic_data->datapath_caps = 117 MCDI_DWORD(outbuf, GET_CAPABILITIES_OUT_FLAGS1);
113 MCDI_DWORD(outbuf, GET_CAPABILITIES_OUT_FLAGS1); 118
114 if (!(nic_data->datapath_caps & 119 if (!(nic_data->datapath_caps &
115 (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN))) { 120 (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN))) {
116 netif_err(efx, drv, efx->net_dev, 121 netif_err(efx, drv, efx->net_dev,
117 "Capabilities don't indicate TSO support.\n"); 122 "current firmware does not support TSO\n");
118 return -ENODEV; 123 return -ENODEV;
119 } 124 }
125
126 if (!(nic_data->datapath_caps &
127 (1 << MC_CMD_GET_CAPABILITIES_OUT_RX_PREFIX_LEN_14_LBN))) {
128 netif_err(efx, probe, efx->net_dev,
129 "current firmware does not support an RX prefix\n");
130 return -ENODEV;
120 } 131 }
121 132
122 return 0; 133 return 0;
@@ -217,21 +228,13 @@ static int efx_ef10_probe(struct efx_nic *efx)
217 if (rc) 228 if (rc)
218 goto fail3; 229 goto fail3;
219 230
220 rc = efx_ef10_init_capabilities(efx); 231 rc = efx_ef10_init_datapath_caps(efx);
221 if (rc < 0) 232 if (rc < 0)
222 goto fail3; 233 goto fail3;
223 234
224 efx->rx_packet_len_offset = 235 efx->rx_packet_len_offset =
225 ES_DZ_RX_PREFIX_PKTLEN_OFST - ES_DZ_RX_PREFIX_SIZE; 236 ES_DZ_RX_PREFIX_PKTLEN_OFST - ES_DZ_RX_PREFIX_SIZE;
226 237
227 if (!(nic_data->datapath_caps &
228 (1 << MC_CMD_GET_CAPABILITIES_OUT_RX_PREFIX_LEN_14_LBN))) {
229 netif_err(efx, probe, efx->net_dev,
230 "current firmware does not support an RX prefix\n");
231 rc = -ENODEV;
232 goto fail3;
233 }
234
235 rc = efx_mcdi_port_get_number(efx); 238 rc = efx_mcdi_port_get_number(efx);
236 if (rc < 0) 239 if (rc < 0)
237 goto fail3; 240 goto fail3;
@@ -260,8 +263,6 @@ static int efx_ef10_probe(struct efx_nic *efx)
260 if (rc) 263 if (rc)
261 goto fail3; 264 goto fail3;
262 265
263 efx_ptp_probe(efx);
264
265 return 0; 266 return 0;
266 267
267fail3: 268fail3:
@@ -342,6 +343,13 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
342 struct efx_ef10_nic_data *nic_data = efx->nic_data; 343 struct efx_ef10_nic_data *nic_data = efx->nic_data;
343 int rc; 344 int rc;
344 345
346 if (nic_data->must_check_datapath_caps) {
347 rc = efx_ef10_init_datapath_caps(efx);
348 if (rc)
349 return rc;
350 nic_data->must_check_datapath_caps = false;
351 }
352
345 if (nic_data->must_realloc_vis) { 353 if (nic_data->must_realloc_vis) {
346 /* We cannot let the number of VIs change now */ 354 /* We cannot let the number of VIs change now */
347 rc = efx_ef10_alloc_vis(efx, nic_data->n_allocated_vis, 355 rc = efx_ef10_alloc_vis(efx, nic_data->n_allocated_vis,
@@ -710,6 +718,14 @@ static int efx_ef10_mcdi_poll_reboot(struct efx_nic *efx)
710 nic_data->must_restore_filters = true; 718 nic_data->must_restore_filters = true;
711 nic_data->rx_rss_context = EFX_EF10_RSS_CONTEXT_INVALID; 719 nic_data->rx_rss_context = EFX_EF10_RSS_CONTEXT_INVALID;
712 720
721 /* The datapath firmware might have been changed */
722 nic_data->must_check_datapath_caps = true;
723
724 /* MAC statistics have been cleared on the NIC; clear the local
725 * statistic that we update with efx_update_diff_stat().
726 */
727 nic_data->stats[EF10_STAT_rx_bad_bytes] = 0;
728
713 return -EIO; 729 return -EIO;
714} 730}
715 731
diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c
index 8d33da6697fb..7b6be61d549f 100644
--- a/drivers/net/ethernet/sfc/mcdi_port.c
+++ b/drivers/net/ethernet/sfc/mcdi_port.c
@@ -556,6 +556,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
556 case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break; 556 case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break;
557 case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break; 557 case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break;
558 case 10000: caps = 1 << MC_CMD_PHY_CAP_10000FDX_LBN; break; 558 case 10000: caps = 1 << MC_CMD_PHY_CAP_10000FDX_LBN; break;
559 case 40000: caps = 1 << MC_CMD_PHY_CAP_40000FDX_LBN; break;
559 default: return -EINVAL; 560 default: return -EINVAL;
560 } 561 }
561 } else { 562 } else {
@@ -841,6 +842,7 @@ static unsigned int efx_mcdi_event_link_speed[] = {
841 [MCDI_EVENT_LINKCHANGE_SPEED_100M] = 100, 842 [MCDI_EVENT_LINKCHANGE_SPEED_100M] = 100,
842 [MCDI_EVENT_LINKCHANGE_SPEED_1G] = 1000, 843 [MCDI_EVENT_LINKCHANGE_SPEED_1G] = 1000,
843 [MCDI_EVENT_LINKCHANGE_SPEED_10G] = 10000, 844 [MCDI_EVENT_LINKCHANGE_SPEED_10G] = 10000,
845 [MCDI_EVENT_LINKCHANGE_SPEED_40G] = 40000,
844}; 846};
845 847
846void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev) 848void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev)
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h
index 4b1e188f7a2f..fda29d39032f 100644
--- a/drivers/net/ethernet/sfc/nic.h
+++ b/drivers/net/ethernet/sfc/nic.h
@@ -400,6 +400,8 @@ enum {
400 * @rx_rss_context: Firmware handle for our RSS context 400 * @rx_rss_context: Firmware handle for our RSS context
401 * @stats: Hardware statistics 401 * @stats: Hardware statistics
402 * @workaround_35388: Flag: firmware supports workaround for bug 35388 402 * @workaround_35388: Flag: firmware supports workaround for bug 35388
403 * @must_check_datapath_caps: Flag: @datapath_caps needs to be revalidated
404 * after MC reboot
403 * @datapath_caps: Capabilities of datapath firmware (FLAGS1 field of 405 * @datapath_caps: Capabilities of datapath firmware (FLAGS1 field of
404 * %MC_CMD_GET_CAPABILITIES response) 406 * %MC_CMD_GET_CAPABILITIES response)
405 */ 407 */
@@ -413,6 +415,7 @@ struct efx_ef10_nic_data {
413 u32 rx_rss_context; 415 u32 rx_rss_context;
414 u64 stats[EF10_STAT_COUNT]; 416 u64 stats[EF10_STAT_COUNT];
415 bool workaround_35388; 417 bool workaround_35388;
418 bool must_check_datapath_caps;
416 u32 datapath_caps; 419 u32 datapath_caps;
417}; 420};
418 421
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
index 370e13dde115..5730fe2445a6 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -271,7 +271,7 @@ static inline void mcf_outsw(void *a, unsigned char *p, int l)
271#define SMC_insw(a, r, p, l) mcf_insw(a + r, p, l) 271#define SMC_insw(a, r, p, l) mcf_insw(a + r, p, l)
272#define SMC_outsw(a, r, p, l) mcf_outsw(a + r, p, l) 272#define SMC_outsw(a, r, p, l) mcf_outsw(a + r, p, l)
273 273
274#define SMC_IRQ_FLAGS (IRQF_DISABLED) 274#define SMC_IRQ_FLAGS 0
275 275
276#else 276#else
277 277
diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
index ffa5c4ad1210..5f9e79f7f2df 100644
--- a/drivers/net/ethernet/smsc/smsc9420.c
+++ b/drivers/net/ethernet/smsc/smsc9420.c
@@ -1356,8 +1356,7 @@ static int smsc9420_open(struct net_device *dev)
1356 smsc9420_reg_write(pd, INT_STAT, 0xFFFFFFFF); 1356 smsc9420_reg_write(pd, INT_STAT, 0xFFFFFFFF);
1357 smsc9420_pci_flush_write(pd); 1357 smsc9420_pci_flush_write(pd);
1358 1358
1359 result = request_irq(irq, smsc9420_isr, IRQF_SHARED | IRQF_DISABLED, 1359 result = request_irq(irq, smsc9420_isr, IRQF_SHARED, DRV_NAME, pd);
1360 DRV_NAME, pd);
1361 if (result) { 1360 if (result) {
1362 smsc_warn(IFUP, "Unable to use IRQ = %d", irq); 1361 smsc_warn(IFUP, "Unable to use IRQ = %d", irq);
1363 result = -ENODEV; 1362 result = -ENODEV;
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 9c805e0c0cae..f7f2ef49c0c1 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -1726,7 +1726,7 @@ static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
1726 goto fail_alloc_irq; 1726 goto fail_alloc_irq;
1727 } 1727 }
1728 result = request_irq(card->irq, gelic_card_interrupt, 1728 result = request_irq(card->irq, gelic_card_interrupt,
1729 IRQF_DISABLED, netdev->name, card); 1729 0, netdev->name, card);
1730 1730
1731 if (result) { 1731 if (result) {
1732 dev_info(ctodev(card), "%s:request_irq failed (%d)\n", 1732 dev_info(ctodev(card), "%s:request_irq failed (%d)\n",
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index f07c340990da..3f138ca88670 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -191,8 +191,8 @@ static inline int mcs_setup_transceiver_vishay(struct mcs_cb *mcs)
191 goto error; 191 goto error;
192 192
193 ret = 0; 193 ret = 0;
194 error: 194error:
195 return ret; 195 return ret;
196} 196}
197 197
198/* Setup a communication between mcs7780 and agilent chip. */ 198/* Setup a communication between mcs7780 and agilent chip. */
@@ -501,8 +501,11 @@ static inline int mcs_setup_urbs(struct mcs_cb *mcs)
501 return 0; 501 return 0;
502 502
503 mcs->rx_urb = usb_alloc_urb(0, GFP_KERNEL); 503 mcs->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
504 if (!mcs->rx_urb) 504 if (!mcs->rx_urb) {
505 usb_free_urb(mcs->tx_urb);
506 mcs->tx_urb = NULL;
505 return 0; 507 return 0;
508 }
506 509
507 return 1; 510 return 1;
508} 511}
@@ -643,9 +646,9 @@ static int mcs_speed_change(struct mcs_cb *mcs)
643 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval); 646 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval);
644 647
645 mcs->speed = mcs->new_speed; 648 mcs->speed = mcs->new_speed;
646 error: 649error:
647 mcs->new_speed = 0; 650 mcs->new_speed = 0;
648 return ret; 651 return ret;
649} 652}
650 653
651/* Ioctl calls not supported at this time. Can be an area of future work. */ 654/* Ioctl calls not supported at this time. Can be an area of future work. */
@@ -738,17 +741,20 @@ static int mcs_net_open(struct net_device *netdev)
738 741
739 ret = mcs_receive_start(mcs); 742 ret = mcs_receive_start(mcs);
740 if (ret) 743 if (ret)
741 goto error3; 744 goto error4;
742 745
743 netif_start_queue(netdev); 746 netif_start_queue(netdev);
744 return 0; 747 return 0;
745 748
746 error3: 749error4:
747 irlap_close(mcs->irlap); 750 usb_free_urb(mcs->rx_urb);
748 error2: 751 usb_free_urb(mcs->tx_urb);
749 kfree_skb(mcs->rx_buff.skb); 752error3:
750 error1: 753 irlap_close(mcs->irlap);
751 return ret; 754error2:
755 kfree_skb(mcs->rx_buff.skb);
756error1:
757 return ret;
752} 758}
753 759
754/* Receive callback function. */ 760/* Receive callback function. */
@@ -946,11 +952,11 @@ static int mcs_probe(struct usb_interface *intf,
946 usb_set_intfdata(intf, mcs); 952 usb_set_intfdata(intf, mcs);
947 return 0; 953 return 0;
948 954
949 error2: 955error2:
950 free_netdev(ndev); 956 free_netdev(ndev);
951 957
952 error1: 958error1:
953 return ret; 959 return ret;
954} 960}
955 961
956/* The current device is removed, the USB layer tells us to shut down. */ 962/* The current device is removed, the USB layer tells us to shut down. */
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index fcbf680c3e62..a17d85a331f1 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -146,6 +146,7 @@ static int loopback_dev_init(struct net_device *dev)
146 146
147static void loopback_dev_free(struct net_device *dev) 147static void loopback_dev_free(struct net_device *dev)
148{ 148{
149 dev_net(dev)->loopback_dev = NULL;
149 free_percpu(dev->lstats); 150 free_percpu(dev->lstats);
150 free_netdev(dev); 151 free_netdev(dev);
151} 152}
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index dcb21347c670..adeee615dd19 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -684,15 +684,12 @@ restart:
684 case NETDEV_RELEASE: 684 case NETDEV_RELEASE:
685 case NETDEV_JOIN: 685 case NETDEV_JOIN:
686 case NETDEV_UNREGISTER: 686 case NETDEV_UNREGISTER:
687 /* 687 /* rtnl_lock already held
688 * rtnl_lock already held
689 * we might sleep in __netpoll_cleanup() 688 * we might sleep in __netpoll_cleanup()
690 */ 689 */
691 spin_unlock_irqrestore(&target_list_lock, flags); 690 spin_unlock_irqrestore(&target_list_lock, flags);
692 691
693 mutex_lock(&nt->mutex);
694 __netpoll_cleanup(&nt->np); 692 __netpoll_cleanup(&nt->np);
695 mutex_unlock(&nt->mutex);
696 693
697 spin_lock_irqsave(&target_list_lock, flags); 694 spin_lock_irqsave(&target_list_lock, flags);
698 dev_put(nt->np.dev); 695 dev_put(nt->np.dev);
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c
index db472ffb6e89..313a0377f68f 100644
--- a/drivers/net/phy/cicada.c
+++ b/drivers/net/phy/cicada.c
@@ -30,9 +30,9 @@
30#include <linux/ethtool.h> 30#include <linux/ethtool.h>
31#include <linux/phy.h> 31#include <linux/phy.h>
32 32
33#include <asm/io.h> 33#include <linux/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/uaccess.h> 35#include <linux/uaccess.h>
36 36
37/* Cicada Extended Control Register 1 */ 37/* Cicada Extended Control Register 1 */
38#define MII_CIS8201_EXT_CON1 0x17 38#define MII_CIS8201_EXT_CON1 0x17
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 6fa5ae00039f..01805319e1e0 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
281 nf_reset(skb); 281 nf_reset(skb);
282 282
283 skb->ip_summed = CHECKSUM_NONE; 283 skb->ip_summed = CHECKSUM_NONE;
284 ip_select_ident(iph, &rt->dst, NULL); 284 ip_select_ident(skb, &rt->dst, NULL);
285 ip_send_check(iph); 285 ip_send_check(iph);
286 286
287 ip_local_out(skb); 287 ip_local_out(skb);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a639de8401f8..807815fc9968 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1641,11 +1641,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1641 INIT_LIST_HEAD(&tun->disabled); 1641 INIT_LIST_HEAD(&tun->disabled);
1642 err = tun_attach(tun, file, false); 1642 err = tun_attach(tun, file, false);
1643 if (err < 0) 1643 if (err < 0)
1644 goto err_free_dev; 1644 goto err_free_flow;
1645 1645
1646 err = register_netdevice(tun->dev); 1646 err = register_netdevice(tun->dev);
1647 if (err < 0) 1647 if (err < 0)
1648 goto err_free_dev; 1648 goto err_detach;
1649 1649
1650 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) || 1650 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
1651 device_create_file(&tun->dev->dev, &dev_attr_owner) || 1651 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
@@ -1689,7 +1689,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1689 strcpy(ifr->ifr_name, tun->dev->name); 1689 strcpy(ifr->ifr_name, tun->dev->name);
1690 return 0; 1690 return 0;
1691 1691
1692 err_free_dev: 1692err_detach:
1693 tun_detach_all(dev);
1694err_free_flow:
1695 tun_flow_uninit(tun);
1696 security_tun_dev_free_security(tun->security);
1697err_free_dev:
1693 free_netdev(dev); 1698 free_netdev(dev);
1694 return err; 1699 return err;
1695} 1700}
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 03ad4dc293aa..2023f3ea891e 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -33,7 +33,7 @@
33#include <linux/usb/usbnet.h> 33#include <linux/usb/usbnet.h>
34 34
35 35
36#if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE) 36#if IS_ENABLED(CONFIG_USB_NET_RNDIS_HOST)
37 37
38static int is_rndis(struct usb_interface_descriptor *desc) 38static int is_rndis(struct usb_interface_descriptor *desc)
39{ 39{
@@ -69,8 +69,7 @@ static const u8 mbm_guid[16] = {
69 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, 69 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
70}; 70};
71 71
72/* 72/* probes control interface, claims data interface, collects the bulk
73 * probes control interface, claims data interface, collects the bulk
74 * endpoints, activates data interface (if needed), maybe sets MTU. 73 * endpoints, activates data interface (if needed), maybe sets MTU.
75 * all pure cdc, except for certain firmware workarounds, and knowing 74 * all pure cdc, except for certain firmware workarounds, and knowing
76 * that rndis uses one different rule. 75 * that rndis uses one different rule.
@@ -88,7 +87,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
88 struct usb_cdc_mdlm_desc *desc = NULL; 87 struct usb_cdc_mdlm_desc *desc = NULL;
89 struct usb_cdc_mdlm_detail_desc *detail = NULL; 88 struct usb_cdc_mdlm_detail_desc *detail = NULL;
90 89
91 if (sizeof dev->data < sizeof *info) 90 if (sizeof(dev->data) < sizeof(*info))
92 return -EDOM; 91 return -EDOM;
93 92
94 /* expect strict spec conformance for the descriptors, but 93 /* expect strict spec conformance for the descriptors, but
@@ -126,10 +125,10 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
126 is_activesync(&intf->cur_altsetting->desc) || 125 is_activesync(&intf->cur_altsetting->desc) ||
127 is_wireless_rndis(&intf->cur_altsetting->desc)); 126 is_wireless_rndis(&intf->cur_altsetting->desc));
128 127
129 memset(info, 0, sizeof *info); 128 memset(info, 0, sizeof(*info));
130 info->control = intf; 129 info->control = intf;
131 while (len > 3) { 130 while (len > 3) {
132 if (buf [1] != USB_DT_CS_INTERFACE) 131 if (buf[1] != USB_DT_CS_INTERFACE)
133 goto next_desc; 132 goto next_desc;
134 133
135 /* use bDescriptorSubType to identify the CDC descriptors. 134 /* use bDescriptorSubType to identify the CDC descriptors.
@@ -139,14 +138,14 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
139 * in favor of a complicated OID-based RPC scheme doing what 138 * in favor of a complicated OID-based RPC scheme doing what
140 * CDC Ethernet achieves with a simple descriptor. 139 * CDC Ethernet achieves with a simple descriptor.
141 */ 140 */
142 switch (buf [2]) { 141 switch (buf[2]) {
143 case USB_CDC_HEADER_TYPE: 142 case USB_CDC_HEADER_TYPE:
144 if (info->header) { 143 if (info->header) {
145 dev_dbg(&intf->dev, "extra CDC header\n"); 144 dev_dbg(&intf->dev, "extra CDC header\n");
146 goto bad_desc; 145 goto bad_desc;
147 } 146 }
148 info->header = (void *) buf; 147 info->header = (void *) buf;
149 if (info->header->bLength != sizeof *info->header) { 148 if (info->header->bLength != sizeof(*info->header)) {
150 dev_dbg(&intf->dev, "CDC header len %u\n", 149 dev_dbg(&intf->dev, "CDC header len %u\n",
151 info->header->bLength); 150 info->header->bLength);
152 goto bad_desc; 151 goto bad_desc;
@@ -175,7 +174,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
175 goto bad_desc; 174 goto bad_desc;
176 } 175 }
177 info->u = (void *) buf; 176 info->u = (void *) buf;
178 if (info->u->bLength != sizeof *info->u) { 177 if (info->u->bLength != sizeof(*info->u)) {
179 dev_dbg(&intf->dev, "CDC union len %u\n", 178 dev_dbg(&intf->dev, "CDC union len %u\n",
180 info->u->bLength); 179 info->u->bLength);
181 goto bad_desc; 180 goto bad_desc;
@@ -233,7 +232,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
233 goto bad_desc; 232 goto bad_desc;
234 } 233 }
235 info->ether = (void *) buf; 234 info->ether = (void *) buf;
236 if (info->ether->bLength != sizeof *info->ether) { 235 if (info->ether->bLength != sizeof(*info->ether)) {
237 dev_dbg(&intf->dev, "CDC ether len %u\n", 236 dev_dbg(&intf->dev, "CDC ether len %u\n",
238 info->ether->bLength); 237 info->ether->bLength);
239 goto bad_desc; 238 goto bad_desc;
@@ -274,8 +273,8 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
274 break; 273 break;
275 } 274 }
276next_desc: 275next_desc:
277 len -= buf [0]; /* bLength */ 276 len -= buf[0]; /* bLength */
278 buf += buf [0]; 277 buf += buf[0];
279 } 278 }
280 279
281 /* Microsoft ActiveSync based and some regular RNDIS devices lack the 280 /* Microsoft ActiveSync based and some regular RNDIS devices lack the
@@ -379,9 +378,7 @@ void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
379} 378}
380EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); 379EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
381 380
382/*------------------------------------------------------------------------- 381/* Communications Device Class, Ethernet Control model
383 *
384 * Communications Device Class, Ethernet Control model
385 * 382 *
386 * Takes two interfaces. The DATA interface is inactive till an altsetting 383 * Takes two interfaces. The DATA interface is inactive till an altsetting
387 * is selected. Configuration data includes class descriptors. There's 384 * is selected. Configuration data includes class descriptors. There's
@@ -389,8 +386,7 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
389 * 386 *
390 * This should interop with whatever the 2.4 "CDCEther.c" driver 387 * This should interop with whatever the 2.4 "CDCEther.c" driver
391 * (by Brad Hards) talked with, with more functionality. 388 * (by Brad Hards) talked with, with more functionality.
392 * 389 */
393 *-------------------------------------------------------------------------*/
394 390
395static void dumpspeed(struct usbnet *dev, __le32 *speeds) 391static void dumpspeed(struct usbnet *dev, __le32 *speeds)
396{ 392{
@@ -404,7 +400,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
404{ 400{
405 struct usb_cdc_notification *event; 401 struct usb_cdc_notification *event;
406 402
407 if (urb->actual_length < sizeof *event) 403 if (urb->actual_length < sizeof(*event))
408 return; 404 return;
409 405
410 /* SPEED_CHANGE can get split into two 8-byte packets */ 406 /* SPEED_CHANGE can get split into two 8-byte packets */
@@ -423,7 +419,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
423 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ 419 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
424 netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n", 420 netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
425 urb->actual_length); 421 urb->actual_length);
426 if (urb->actual_length != (sizeof *event + 8)) 422 if (urb->actual_length != (sizeof(*event) + 8))
427 set_bit(EVENT_STS_SPLIT, &dev->flags); 423 set_bit(EVENT_STS_SPLIT, &dev->flags);
428 else 424 else
429 dumpspeed(dev, (__le32 *) &event[1]); 425 dumpspeed(dev, (__le32 *) &event[1]);
@@ -469,7 +465,6 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
469static const struct driver_info cdc_info = { 465static const struct driver_info cdc_info = {
470 .description = "CDC Ethernet Device", 466 .description = "CDC Ethernet Device",
471 .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 467 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
472 // .check_connect = cdc_check_connect,
473 .bind = usbnet_cdc_bind, 468 .bind = usbnet_cdc_bind,
474 .unbind = usbnet_cdc_unbind, 469 .unbind = usbnet_cdc_unbind,
475 .status = usbnet_cdc_status, 470 .status = usbnet_cdc_status,
@@ -493,9 +488,8 @@ static const struct driver_info wwan_info = {
493#define DELL_VENDOR_ID 0x413C 488#define DELL_VENDOR_ID 0x413C
494#define REALTEK_VENDOR_ID 0x0bda 489#define REALTEK_VENDOR_ID 0x0bda
495 490
496static const struct usb_device_id products [] = { 491static const struct usb_device_id products[] = {
497/* 492/* BLACKLIST !!
498 * BLACKLIST !!
499 * 493 *
500 * First blacklist any products that are egregiously nonconformant 494 * First blacklist any products that are egregiously nonconformant
501 * with the CDC Ethernet specs. Minor braindamage we cope with; when 495 * with the CDC Ethernet specs. Minor braindamage we cope with; when
@@ -542,7 +536,7 @@ static const struct usb_device_id products [] = {
542 .driver_info = 0, 536 .driver_info = 0,
543}, { 537}, {
544 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 538 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
545 | USB_DEVICE_ID_MATCH_DEVICE, 539 | USB_DEVICE_ID_MATCH_DEVICE,
546 .idVendor = 0x04DD, 540 .idVendor = 0x04DD,
547 .idProduct = 0x8007, /* C-700 */ 541 .idProduct = 0x8007, /* C-700 */
548 ZAURUS_MASTER_INTERFACE, 542 ZAURUS_MASTER_INTERFACE,
@@ -659,8 +653,7 @@ static const struct usb_device_id products [] = {
659 .driver_info = 0, 653 .driver_info = 0,
660}, 654},
661 655
662/* 656/* WHITELIST!!!
663 * WHITELIST!!!
664 * 657 *
665 * CDC Ether uses two interfaces, not necessarily consecutive. 658 * CDC Ether uses two interfaces, not necessarily consecutive.
666 * We match the main interface, ignoring the optional device 659 * We match the main interface, ignoring the optional device
@@ -672,60 +665,40 @@ static const struct usb_device_id products [] = {
672 */ 665 */
673{ 666{
674 /* ZTE (Vodafone) K3805-Z */ 667 /* ZTE (Vodafone) K3805-Z */
675 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 668 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1003, USB_CLASS_COMM,
676 | USB_DEVICE_ID_MATCH_PRODUCT 669 USB_CDC_SUBCLASS_ETHERNET,
677 | USB_DEVICE_ID_MATCH_INT_INFO, 670 USB_CDC_PROTO_NONE),
678 .idVendor = ZTE_VENDOR_ID,
679 .idProduct = 0x1003,
680 .bInterfaceClass = USB_CLASS_COMM,
681 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
682 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
683 .driver_info = (unsigned long)&wwan_info, 671 .driver_info = (unsigned long)&wwan_info,
684}, { 672}, {
685 /* ZTE (Vodafone) K3806-Z */ 673 /* ZTE (Vodafone) K3806-Z */
686 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 674 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1015, USB_CLASS_COMM,
687 | USB_DEVICE_ID_MATCH_PRODUCT 675 USB_CDC_SUBCLASS_ETHERNET,
688 | USB_DEVICE_ID_MATCH_INT_INFO, 676 USB_CDC_PROTO_NONE),
689 .idVendor = ZTE_VENDOR_ID,
690 .idProduct = 0x1015,
691 .bInterfaceClass = USB_CLASS_COMM,
692 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
693 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
694 .driver_info = (unsigned long)&wwan_info, 677 .driver_info = (unsigned long)&wwan_info,
695}, { 678}, {
696 /* ZTE (Vodafone) K4510-Z */ 679 /* ZTE (Vodafone) K4510-Z */
697 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 680 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1173, USB_CLASS_COMM,
698 | USB_DEVICE_ID_MATCH_PRODUCT 681 USB_CDC_SUBCLASS_ETHERNET,
699 | USB_DEVICE_ID_MATCH_INT_INFO, 682 USB_CDC_PROTO_NONE),
700 .idVendor = ZTE_VENDOR_ID,
701 .idProduct = 0x1173,
702 .bInterfaceClass = USB_CLASS_COMM,
703 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
704 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
705 .driver_info = (unsigned long)&wwan_info, 683 .driver_info = (unsigned long)&wwan_info,
706}, { 684}, {
707 /* ZTE (Vodafone) K3770-Z */ 685 /* ZTE (Vodafone) K3770-Z */
708 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 686 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1177, USB_CLASS_COMM,
709 | USB_DEVICE_ID_MATCH_PRODUCT 687 USB_CDC_SUBCLASS_ETHERNET,
710 | USB_DEVICE_ID_MATCH_INT_INFO, 688 USB_CDC_PROTO_NONE),
711 .idVendor = ZTE_VENDOR_ID,
712 .idProduct = 0x1177,
713 .bInterfaceClass = USB_CLASS_COMM,
714 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
715 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
716 .driver_info = (unsigned long)&wwan_info, 689 .driver_info = (unsigned long)&wwan_info,
717}, { 690}, {
718 /* ZTE (Vodafone) K3772-Z */ 691 /* ZTE (Vodafone) K3772-Z */
719 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 692 USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1181, USB_CLASS_COMM,
720 | USB_DEVICE_ID_MATCH_PRODUCT 693 USB_CDC_SUBCLASS_ETHERNET,
721 | USB_DEVICE_ID_MATCH_INT_INFO, 694 USB_CDC_PROTO_NONE),
722 .idVendor = ZTE_VENDOR_ID,
723 .idProduct = 0x1181,
724 .bInterfaceClass = USB_CLASS_COMM,
725 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
726 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
727 .driver_info = (unsigned long)&wwan_info, 695 .driver_info = (unsigned long)&wwan_info,
728}, { 696}, {
697 /* Telit modules */
698 USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM,
699 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
700 .driver_info = (kernel_ulong_t) &wwan_info,
701}, {
729 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, 702 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
730 USB_CDC_PROTO_NONE), 703 USB_CDC_PROTO_NONE),
731 .driver_info = (unsigned long) &cdc_info, 704 .driver_info = (unsigned long) &cdc_info,
@@ -736,15 +709,11 @@ static const struct usb_device_id products [] = {
736 709
737}, { 710}, {
738 /* Various Huawei modems with a network port like the UMG1831 */ 711 /* Various Huawei modems with a network port like the UMG1831 */
739 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 712 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_COMM,
740 | USB_DEVICE_ID_MATCH_INT_INFO, 713 USB_CDC_SUBCLASS_ETHERNET, 255),
741 .idVendor = HUAWEI_VENDOR_ID,
742 .bInterfaceClass = USB_CLASS_COMM,
743 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
744 .bInterfaceProtocol = 255,
745 .driver_info = (unsigned long)&wwan_info, 714 .driver_info = (unsigned long)&wwan_info,
746}, 715},
747 { }, // END 716 { }, /* END */
748}; 717};
749MODULE_DEVICE_TABLE(usb, products); 718MODULE_DEVICE_TABLE(usb, products);
750 719
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index bf64b4191dcc..d1292fe746bc 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -564,7 +564,7 @@ static void vxlan_notify_add_rx_port(struct sock *sk)
564 struct net_device *dev; 564 struct net_device *dev;
565 struct net *net = sock_net(sk); 565 struct net *net = sock_net(sk);
566 sa_family_t sa_family = sk->sk_family; 566 sa_family_t sa_family = sk->sk_family;
567 u16 port = htons(inet_sk(sk)->inet_sport); 567 __be16 port = inet_sk(sk)->inet_sport;
568 568
569 rcu_read_lock(); 569 rcu_read_lock();
570 for_each_netdev_rcu(net, dev) { 570 for_each_netdev_rcu(net, dev) {
@@ -581,7 +581,7 @@ static void vxlan_notify_del_rx_port(struct sock *sk)
581 struct net_device *dev; 581 struct net_device *dev;
582 struct net *net = sock_net(sk); 582 struct net *net = sock_net(sk);
583 sa_family_t sa_family = sk->sk_family; 583 sa_family_t sa_family = sk->sk_family;
584 u16 port = htons(inet_sk(sk)->inet_sport); 584 __be16 port = inet_sk(sk)->inet_sport;
585 585
586 rcu_read_lock(); 586 rcu_read_lock();
587 for_each_netdev_rcu(net, dev) { 587 for_each_netdev_rcu(net, dev) {
@@ -2021,7 +2021,8 @@ static struct device_type vxlan_type = {
2021}; 2021};
2022 2022
2023/* Calls the ndo_add_vxlan_port of the caller in order to 2023/* Calls the ndo_add_vxlan_port of the caller in order to
2024 * supply the listening VXLAN udp ports. 2024 * supply the listening VXLAN udp ports. Callers are expected
2025 * to implement the ndo_add_vxlan_port.
2025 */ 2026 */
2026void vxlan_get_rx_port(struct net_device *dev) 2027void vxlan_get_rx_port(struct net_device *dev)
2027{ 2028{
@@ -2029,16 +2030,13 @@ void vxlan_get_rx_port(struct net_device *dev)
2029 struct net *net = dev_net(dev); 2030 struct net *net = dev_net(dev);
2030 struct vxlan_net *vn = net_generic(net, vxlan_net_id); 2031 struct vxlan_net *vn = net_generic(net, vxlan_net_id);
2031 sa_family_t sa_family; 2032 sa_family_t sa_family;
2032 u16 port; 2033 __be16 port;
2033 int i; 2034 unsigned int i;
2034
2035 if (!dev || !dev->netdev_ops || !dev->netdev_ops->ndo_add_vxlan_port)
2036 return;
2037 2035
2038 spin_lock(&vn->sock_lock); 2036 spin_lock(&vn->sock_lock);
2039 for (i = 0; i < PORT_HASH_SIZE; ++i) { 2037 for (i = 0; i < PORT_HASH_SIZE; ++i) {
2040 hlist_for_each_entry_rcu(vs, vs_head(net, i), hlist) { 2038 hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist) {
2041 port = htons(inet_sk(vs->sock->sk)->inet_sport); 2039 port = inet_sk(vs->sock->sk)->inet_sport;
2042 sa_family = vs->sock->sk->sk_family; 2040 sa_family = vs->sock->sk->sk_family;
2043 dev->netdev_ops->ndo_add_vxlan_port(dev, sa_family, 2041 dev->netdev_ops->ndo_add_vxlan_port(dev, sa_family,
2044 port); 2042 port);
@@ -2492,15 +2490,19 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
2492 2490
2493 SET_ETHTOOL_OPS(dev, &vxlan_ethtool_ops); 2491 SET_ETHTOOL_OPS(dev, &vxlan_ethtool_ops);
2494 2492
2495 /* create an fdb entry for default destination */ 2493 /* create an fdb entry for a valid default destination */
2496 err = vxlan_fdb_create(vxlan, all_zeros_mac, 2494 if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) {
2497 &vxlan->default_dst.remote_ip, 2495 err = vxlan_fdb_create(vxlan, all_zeros_mac,
2498 NUD_REACHABLE|NUD_PERMANENT, 2496 &vxlan->default_dst.remote_ip,
2499 NLM_F_EXCL|NLM_F_CREATE, 2497 NUD_REACHABLE|NUD_PERMANENT,
2500 vxlan->dst_port, vxlan->default_dst.remote_vni, 2498 NLM_F_EXCL|NLM_F_CREATE,
2501 vxlan->default_dst.remote_ifindex, NTF_SELF); 2499 vxlan->dst_port,
2502 if (err) 2500 vxlan->default_dst.remote_vni,
2503 return err; 2501 vxlan->default_dst.remote_ifindex,
2502 NTF_SELF);
2503 if (err)
2504 return err;
2505 }
2504 2506
2505 err = register_netdevice(dev); 2507 err = register_netdevice(dev);
2506 if (err) { 2508 if (err) {
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index f9a24e599dee..cfce83e1f273 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1924,7 +1924,6 @@ static int adm8211_probe(struct pci_dev *pdev,
1924 pci_iounmap(pdev, priv->map); 1924 pci_iounmap(pdev, priv->map);
1925 1925
1926 err_free_dev: 1926 err_free_dev:
1927 pci_set_drvdata(pdev, NULL);
1928 ieee80211_free_hw(dev); 1927 ieee80211_free_hw(dev);
1929 1928
1930 err_free_reg: 1929 err_free_reg:
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 7fe19648f10e..edf4b57c4aaa 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -5570,7 +5570,6 @@ static void airo_pci_remove(struct pci_dev *pdev)
5570 airo_print_info(dev->name, "Unregistering..."); 5570 airo_print_info(dev->name, "Unregistering...");
5571 stop_airo_card(dev, 1); 5571 stop_airo_card(dev, 1);
5572 pci_disable_device(pdev); 5572 pci_disable_device(pdev);
5573 pci_set_drvdata(pdev, NULL);
5574} 5573}
5575 5574
5576static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) 5575static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig
index 1abf1d421173..ba81d6292eeb 100644
--- a/drivers/net/wireless/ath/Kconfig
+++ b/drivers/net/wireless/ath/Kconfig
@@ -32,5 +32,6 @@ source "drivers/net/wireless/ath/ath6kl/Kconfig"
32source "drivers/net/wireless/ath/ar5523/Kconfig" 32source "drivers/net/wireless/ath/ar5523/Kconfig"
33source "drivers/net/wireless/ath/wil6210/Kconfig" 33source "drivers/net/wireless/ath/wil6210/Kconfig"
34source "drivers/net/wireless/ath/ath10k/Kconfig" 34source "drivers/net/wireless/ath/ath10k/Kconfig"
35source "drivers/net/wireless/ath/wcn36xx/Kconfig"
35 36
36endif 37endif
diff --git a/drivers/net/wireless/ath/Makefile b/drivers/net/wireless/ath/Makefile
index fb05cfd19361..363b05653c7e 100644
--- a/drivers/net/wireless/ath/Makefile
+++ b/drivers/net/wireless/ath/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_ATH6KL) += ath6kl/
5obj-$(CONFIG_AR5523) += ar5523/ 5obj-$(CONFIG_AR5523) += ar5523/
6obj-$(CONFIG_WIL6210) += wil6210/ 6obj-$(CONFIG_WIL6210) += wil6210/
7obj-$(CONFIG_ATH10K) += ath10k/ 7obj-$(CONFIG_ATH10K) += ath10k/
8obj-$(CONFIG_WCN36XX) += wcn36xx/
8 9
9obj-$(CONFIG_ATH_COMMON) += ath.o 10obj-$(CONFIG_ATH_COMMON) += ath.o
10 11
diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c
index 17d7fece35d2..280fc3d53a36 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
@@ -1762,6 +1762,7 @@ static struct usb_device_id ar5523_id_table[] = {
1762 AR5523_DEVICE_UX(0x2001, 0x3a00), /* Dlink / DWLAG132 */ 1762 AR5523_DEVICE_UX(0x2001, 0x3a00), /* Dlink / DWLAG132 */
1763 AR5523_DEVICE_UG(0x2001, 0x3a02), /* Dlink / DWLG132 */ 1763 AR5523_DEVICE_UG(0x2001, 0x3a02), /* Dlink / DWLG132 */
1764 AR5523_DEVICE_UX(0x2001, 0x3a04), /* Dlink / DWLAG122 */ 1764 AR5523_DEVICE_UX(0x2001, 0x3a04), /* Dlink / DWLAG122 */
1765 AR5523_DEVICE_UG(0x07d1, 0x3a07), /* D-Link / WUA-2340 rev A1 */
1765 AR5523_DEVICE_UG(0x1690, 0x0712), /* Gigaset / AR5523 */ 1766 AR5523_DEVICE_UG(0x1690, 0x0712), /* Gigaset / AR5523 */
1766 AR5523_DEVICE_UG(0x1690, 0x0710), /* Gigaset / SMCWUSBTG */ 1767 AR5523_DEVICE_UG(0x1690, 0x0710), /* Gigaset / SMCWUSBTG */
1767 AR5523_DEVICE_UG(0x129b, 0x160c), /* Gigaset / USB stick 108 1768 AR5523_DEVICE_UG(0x129b, 0x160c), /* Gigaset / USB stick 108
diff --git a/drivers/net/wireless/ath/ath10k/bmi.c b/drivers/net/wireless/ath/ath10k/bmi.c
index 744da6d1c405..a1f099628850 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.c
+++ b/drivers/net/wireless/ath/ath10k/bmi.c
@@ -22,7 +22,8 @@
22 22
23void ath10k_bmi_start(struct ath10k *ar) 23void ath10k_bmi_start(struct ath10k *ar)
24{ 24{
25 ath10k_dbg(ATH10K_DBG_CORE, "BMI started\n"); 25 ath10k_dbg(ATH10K_DBG_BMI, "bmi start\n");
26
26 ar->bmi.done_sent = false; 27 ar->bmi.done_sent = false;
27} 28}
28 29
@@ -32,8 +33,10 @@ int ath10k_bmi_done(struct ath10k *ar)
32 u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.done); 33 u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.done);
33 int ret; 34 int ret;
34 35
36 ath10k_dbg(ATH10K_DBG_BMI, "bmi done\n");
37
35 if (ar->bmi.done_sent) { 38 if (ar->bmi.done_sent) {
36 ath10k_dbg(ATH10K_DBG_CORE, "%s skipped\n", __func__); 39 ath10k_dbg(ATH10K_DBG_BMI, "bmi skipped\n");
37 return 0; 40 return 0;
38 } 41 }
39 42
@@ -46,7 +49,6 @@ int ath10k_bmi_done(struct ath10k *ar)
46 return ret; 49 return ret;
47 } 50 }
48 51
49 ath10k_dbg(ATH10K_DBG_CORE, "BMI done\n");
50 return 0; 52 return 0;
51} 53}
52 54
@@ -59,6 +61,8 @@ int ath10k_bmi_get_target_info(struct ath10k *ar,
59 u32 resplen = sizeof(resp.get_target_info); 61 u32 resplen = sizeof(resp.get_target_info);
60 int ret; 62 int ret;
61 63
64 ath10k_dbg(ATH10K_DBG_BMI, "bmi get target info\n");
65
62 if (ar->bmi.done_sent) { 66 if (ar->bmi.done_sent) {
63 ath10k_warn("BMI Get Target Info Command disallowed\n"); 67 ath10k_warn("BMI Get Target Info Command disallowed\n");
64 return -EBUSY; 68 return -EBUSY;
@@ -80,6 +84,7 @@ int ath10k_bmi_get_target_info(struct ath10k *ar,
80 84
81 target_info->version = __le32_to_cpu(resp.get_target_info.version); 85 target_info->version = __le32_to_cpu(resp.get_target_info.version);
82 target_info->type = __le32_to_cpu(resp.get_target_info.type); 86 target_info->type = __le32_to_cpu(resp.get_target_info.type);
87
83 return 0; 88 return 0;
84} 89}
85 90
@@ -92,15 +97,14 @@ int ath10k_bmi_read_memory(struct ath10k *ar,
92 u32 rxlen; 97 u32 rxlen;
93 int ret; 98 int ret;
94 99
100 ath10k_dbg(ATH10K_DBG_BMI, "bmi read address 0x%x length %d\n",
101 address, length);
102
95 if (ar->bmi.done_sent) { 103 if (ar->bmi.done_sent) {
96 ath10k_warn("command disallowed\n"); 104 ath10k_warn("command disallowed\n");
97 return -EBUSY; 105 return -EBUSY;
98 } 106 }
99 107
100 ath10k_dbg(ATH10K_DBG_CORE,
101 "%s: (device: 0x%p, address: 0x%x, length: %d)\n",
102 __func__, ar, address, length);
103
104 while (length) { 108 while (length) {
105 rxlen = min_t(u32, length, BMI_MAX_DATA_SIZE); 109 rxlen = min_t(u32, length, BMI_MAX_DATA_SIZE);
106 110
@@ -133,15 +137,14 @@ int ath10k_bmi_write_memory(struct ath10k *ar,
133 u32 txlen; 137 u32 txlen;
134 int ret; 138 int ret;
135 139
140 ath10k_dbg(ATH10K_DBG_BMI, "bmi write address 0x%x length %d\n",
141 address, length);
142
136 if (ar->bmi.done_sent) { 143 if (ar->bmi.done_sent) {
137 ath10k_warn("command disallowed\n"); 144 ath10k_warn("command disallowed\n");
138 return -EBUSY; 145 return -EBUSY;
139 } 146 }
140 147
141 ath10k_dbg(ATH10K_DBG_CORE,
142 "%s: (device: 0x%p, address: 0x%x, length: %d)\n",
143 __func__, ar, address, length);
144
145 while (length) { 148 while (length) {
146 txlen = min(length, BMI_MAX_DATA_SIZE - hdrlen); 149 txlen = min(length, BMI_MAX_DATA_SIZE - hdrlen);
147 150
@@ -180,15 +183,14 @@ int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param)
180 u32 resplen = sizeof(resp.execute); 183 u32 resplen = sizeof(resp.execute);
181 int ret; 184 int ret;
182 185
186 ath10k_dbg(ATH10K_DBG_BMI, "bmi execute address 0x%x param 0x%x\n",
187 address, *param);
188
183 if (ar->bmi.done_sent) { 189 if (ar->bmi.done_sent) {
184 ath10k_warn("command disallowed\n"); 190 ath10k_warn("command disallowed\n");
185 return -EBUSY; 191 return -EBUSY;
186 } 192 }
187 193
188 ath10k_dbg(ATH10K_DBG_CORE,
189 "%s: (device: 0x%p, address: 0x%x, param: %d)\n",
190 __func__, ar, address, *param);
191
192 cmd.id = __cpu_to_le32(BMI_EXECUTE); 194 cmd.id = __cpu_to_le32(BMI_EXECUTE);
193 cmd.execute.addr = __cpu_to_le32(address); 195 cmd.execute.addr = __cpu_to_le32(address);
194 cmd.execute.param = __cpu_to_le32(*param); 196 cmd.execute.param = __cpu_to_le32(*param);
@@ -216,6 +218,9 @@ int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length)
216 u32 txlen; 218 u32 txlen;
217 int ret; 219 int ret;
218 220
221 ath10k_dbg(ATH10K_DBG_BMI, "bmi lz data buffer 0x%p length %d\n",
222 buffer, length);
223
219 if (ar->bmi.done_sent) { 224 if (ar->bmi.done_sent) {
220 ath10k_warn("command disallowed\n"); 225 ath10k_warn("command disallowed\n");
221 return -EBUSY; 226 return -EBUSY;
@@ -250,6 +255,9 @@ int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address)
250 u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.lz_start); 255 u32 cmdlen = sizeof(cmd.id) + sizeof(cmd.lz_start);
251 int ret; 256 int ret;
252 257
258 ath10k_dbg(ATH10K_DBG_BMI, "bmi lz stream start address 0x%x\n",
259 address);
260
253 if (ar->bmi.done_sent) { 261 if (ar->bmi.done_sent) {
254 ath10k_warn("command disallowed\n"); 262 ath10k_warn("command disallowed\n");
255 return -EBUSY; 263 return -EBUSY;
@@ -275,6 +283,10 @@ int ath10k_bmi_fast_download(struct ath10k *ar,
275 u32 trailer_len = length - head_len; 283 u32 trailer_len = length - head_len;
276 int ret; 284 int ret;
277 285
286 ath10k_dbg(ATH10K_DBG_BMI,
287 "bmi fast download address 0x%x buffer 0x%p length %d\n",
288 address, buffer, length);
289
278 ret = ath10k_bmi_lz_stream_start(ar, address); 290 ret = ath10k_bmi_lz_stream_start(ar, address);
279 if (ret) 291 if (ret)
280 return ret; 292 return ret;
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
index f8b969f518f8..834e29ea236c 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -76,36 +76,7 @@ static inline void ath10k_ce_src_ring_write_index_set(struct ath10k *ar,
76 u32 ce_ctrl_addr, 76 u32 ce_ctrl_addr,
77 unsigned int n) 77 unsigned int n)
78{ 78{
79 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 79 ath10k_pci_write32(ar, ce_ctrl_addr + SR_WR_INDEX_ADDRESS, n);
80 void __iomem *indicator_addr;
81
82 if (!test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features)) {
83 ath10k_pci_write32(ar, ce_ctrl_addr + SR_WR_INDEX_ADDRESS, n);
84 return;
85 }
86
87 /* workaround for QCA988x_1.0 HW CE */
88 indicator_addr = ar_pci->mem + ce_ctrl_addr + DST_WATERMARK_ADDRESS;
89
90 if (ce_ctrl_addr == ath10k_ce_base_address(CDC_WAR_DATA_CE)) {
91 iowrite32((CDC_WAR_MAGIC_STR | n), indicator_addr);
92 } else {
93 unsigned long irq_flags;
94 local_irq_save(irq_flags);
95 iowrite32(1, indicator_addr);
96
97 /*
98 * PCIE write waits for ACK in IPQ8K, there is no
99 * need to read back value.
100 */
101 (void)ioread32(indicator_addr);
102 (void)ioread32(indicator_addr); /* conservative */
103
104 ath10k_pci_write32(ar, ce_ctrl_addr + SR_WR_INDEX_ADDRESS, n);
105
106 iowrite32(0, indicator_addr);
107 local_irq_restore(irq_flags);
108 }
109} 80}
110 81
111static inline u32 ath10k_ce_src_ring_write_index_get(struct ath10k *ar, 82static inline u32 ath10k_ce_src_ring_write_index_get(struct ath10k *ar,
@@ -285,7 +256,7 @@ static inline void ath10k_ce_engine_int_status_clear(struct ath10k *ar,
285 * ath10k_ce_sendlist_send. 256 * ath10k_ce_sendlist_send.
286 * The caller takes responsibility for any needed locking. 257 * The caller takes responsibility for any needed locking.
287 */ 258 */
288static int ath10k_ce_send_nolock(struct ce_state *ce_state, 259static int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,
289 void *per_transfer_context, 260 void *per_transfer_context,
290 u32 buffer, 261 u32 buffer,
291 unsigned int nbytes, 262 unsigned int nbytes,
@@ -293,7 +264,7 @@ static int ath10k_ce_send_nolock(struct ce_state *ce_state,
293 unsigned int flags) 264 unsigned int flags)
294{ 265{
295 struct ath10k *ar = ce_state->ar; 266 struct ath10k *ar = ce_state->ar;
296 struct ce_ring_state *src_ring = ce_state->src_ring; 267 struct ath10k_ce_ring *src_ring = ce_state->src_ring;
297 struct ce_desc *desc, *sdesc; 268 struct ce_desc *desc, *sdesc;
298 unsigned int nentries_mask = src_ring->nentries_mask; 269 unsigned int nentries_mask = src_ring->nentries_mask;
299 unsigned int sw_index = src_ring->sw_index; 270 unsigned int sw_index = src_ring->sw_index;
@@ -306,7 +277,9 @@ static int ath10k_ce_send_nolock(struct ce_state *ce_state,
306 ath10k_warn("%s: send more we can (nbytes: %d, max: %d)\n", 277 ath10k_warn("%s: send more we can (nbytes: %d, max: %d)\n",
307 __func__, nbytes, ce_state->src_sz_max); 278 __func__, nbytes, ce_state->src_sz_max);
308 279
309 ath10k_pci_wake(ar); 280 ret = ath10k_pci_wake(ar);
281 if (ret)
282 return ret;
310 283
311 if (unlikely(CE_RING_DELTA(nentries_mask, 284 if (unlikely(CE_RING_DELTA(nentries_mask,
312 write_index, sw_index - 1) <= 0)) { 285 write_index, sw_index - 1) <= 0)) {
@@ -346,7 +319,7 @@ exit:
346 return ret; 319 return ret;
347} 320}
348 321
349int ath10k_ce_send(struct ce_state *ce_state, 322int ath10k_ce_send(struct ath10k_ce_pipe *ce_state,
350 void *per_transfer_context, 323 void *per_transfer_context,
351 u32 buffer, 324 u32 buffer,
352 unsigned int nbytes, 325 unsigned int nbytes,
@@ -365,33 +338,19 @@ int ath10k_ce_send(struct ce_state *ce_state,
365 return ret; 338 return ret;
366} 339}
367 340
368void ath10k_ce_sendlist_buf_add(struct ce_sendlist *sendlist, u32 buffer, 341int ath10k_ce_sendlist_send(struct ath10k_ce_pipe *ce_state,
369 unsigned int nbytes, u32 flags)
370{
371 unsigned int num_items = sendlist->num_items;
372 struct ce_sendlist_item *item;
373
374 item = &sendlist->item[num_items];
375 item->data = buffer;
376 item->u.nbytes = nbytes;
377 item->flags = flags;
378 sendlist->num_items++;
379}
380
381int ath10k_ce_sendlist_send(struct ce_state *ce_state,
382 void *per_transfer_context, 342 void *per_transfer_context,
383 struct ce_sendlist *sendlist, 343 unsigned int transfer_id,
384 unsigned int transfer_id) 344 u32 paddr, unsigned int nbytes,
345 u32 flags)
385{ 346{
386 struct ce_ring_state *src_ring = ce_state->src_ring; 347 struct ath10k_ce_ring *src_ring = ce_state->src_ring;
387 struct ce_sendlist_item *item;
388 struct ath10k *ar = ce_state->ar; 348 struct ath10k *ar = ce_state->ar;
389 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 349 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
390 unsigned int nentries_mask = src_ring->nentries_mask; 350 unsigned int nentries_mask = src_ring->nentries_mask;
391 unsigned int num_items = sendlist->num_items;
392 unsigned int sw_index; 351 unsigned int sw_index;
393 unsigned int write_index; 352 unsigned int write_index;
394 int i, delta, ret = -ENOMEM; 353 int delta, ret = -ENOMEM;
395 354
396 spin_lock_bh(&ar_pci->ce_lock); 355 spin_lock_bh(&ar_pci->ce_lock);
397 356
@@ -400,30 +359,12 @@ int ath10k_ce_sendlist_send(struct ce_state *ce_state,
400 359
401 delta = CE_RING_DELTA(nentries_mask, write_index, sw_index - 1); 360 delta = CE_RING_DELTA(nentries_mask, write_index, sw_index - 1);
402 361
403 if (delta >= num_items) { 362 if (delta >= 1) {
404 /*
405 * Handle all but the last item uniformly.
406 */
407 for (i = 0; i < num_items - 1; i++) {
408 item = &sendlist->item[i];
409 ret = ath10k_ce_send_nolock(ce_state,
410 CE_SENDLIST_ITEM_CTXT,
411 (u32) item->data,
412 item->u.nbytes, transfer_id,
413 item->flags |
414 CE_SEND_FLAG_GATHER);
415 if (ret)
416 ath10k_warn("CE send failed for item: %d\n", i);
417 }
418 /*
419 * Provide valid context pointer for final item.
420 */
421 item = &sendlist->item[i];
422 ret = ath10k_ce_send_nolock(ce_state, per_transfer_context, 363 ret = ath10k_ce_send_nolock(ce_state, per_transfer_context,
423 (u32) item->data, item->u.nbytes, 364 paddr, nbytes,
424 transfer_id, item->flags); 365 transfer_id, flags);
425 if (ret) 366 if (ret)
426 ath10k_warn("CE send failed for last item: %d\n", i); 367 ath10k_warn("CE send failed: %d\n", ret);
427 } 368 }
428 369
429 spin_unlock_bh(&ar_pci->ce_lock); 370 spin_unlock_bh(&ar_pci->ce_lock);
@@ -431,11 +372,11 @@ int ath10k_ce_sendlist_send(struct ce_state *ce_state,
431 return ret; 372 return ret;
432} 373}
433 374
434int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state, 375int ath10k_ce_recv_buf_enqueue(struct ath10k_ce_pipe *ce_state,
435 void *per_recv_context, 376 void *per_recv_context,
436 u32 buffer) 377 u32 buffer)
437{ 378{
438 struct ce_ring_state *dest_ring = ce_state->dest_ring; 379 struct ath10k_ce_ring *dest_ring = ce_state->dest_ring;
439 u32 ctrl_addr = ce_state->ctrl_addr; 380 u32 ctrl_addr = ce_state->ctrl_addr;
440 struct ath10k *ar = ce_state->ar; 381 struct ath10k *ar = ce_state->ar;
441 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 382 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
@@ -448,7 +389,9 @@ int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state,
448 write_index = dest_ring->write_index; 389 write_index = dest_ring->write_index;
449 sw_index = dest_ring->sw_index; 390 sw_index = dest_ring->sw_index;
450 391
451 ath10k_pci_wake(ar); 392 ret = ath10k_pci_wake(ar);
393 if (ret)
394 goto out;
452 395
453 if (CE_RING_DELTA(nentries_mask, write_index, sw_index - 1) > 0) { 396 if (CE_RING_DELTA(nentries_mask, write_index, sw_index - 1) > 0) {
454 struct ce_desc *base = dest_ring->base_addr_owner_space; 397 struct ce_desc *base = dest_ring->base_addr_owner_space;
@@ -470,6 +413,8 @@ int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state,
470 ret = -EIO; 413 ret = -EIO;
471 } 414 }
472 ath10k_pci_sleep(ar); 415 ath10k_pci_sleep(ar);
416
417out:
473 spin_unlock_bh(&ar_pci->ce_lock); 418 spin_unlock_bh(&ar_pci->ce_lock);
474 419
475 return ret; 420 return ret;
@@ -479,14 +424,14 @@ int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state,
479 * Guts of ath10k_ce_completed_recv_next. 424 * Guts of ath10k_ce_completed_recv_next.
480 * The caller takes responsibility for any necessary locking. 425 * The caller takes responsibility for any necessary locking.
481 */ 426 */
482static int ath10k_ce_completed_recv_next_nolock(struct ce_state *ce_state, 427static int ath10k_ce_completed_recv_next_nolock(struct ath10k_ce_pipe *ce_state,
483 void **per_transfer_contextp, 428 void **per_transfer_contextp,
484 u32 *bufferp, 429 u32 *bufferp,
485 unsigned int *nbytesp, 430 unsigned int *nbytesp,
486 unsigned int *transfer_idp, 431 unsigned int *transfer_idp,
487 unsigned int *flagsp) 432 unsigned int *flagsp)
488{ 433{
489 struct ce_ring_state *dest_ring = ce_state->dest_ring; 434 struct ath10k_ce_ring *dest_ring = ce_state->dest_ring;
490 unsigned int nentries_mask = dest_ring->nentries_mask; 435 unsigned int nentries_mask = dest_ring->nentries_mask;
491 unsigned int sw_index = dest_ring->sw_index; 436 unsigned int sw_index = dest_ring->sw_index;
492 437
@@ -535,7 +480,7 @@ static int ath10k_ce_completed_recv_next_nolock(struct ce_state *ce_state,
535 return 0; 480 return 0;
536} 481}
537 482
538int ath10k_ce_completed_recv_next(struct ce_state *ce_state, 483int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state,
539 void **per_transfer_contextp, 484 void **per_transfer_contextp,
540 u32 *bufferp, 485 u32 *bufferp,
541 unsigned int *nbytesp, 486 unsigned int *nbytesp,
@@ -556,11 +501,11 @@ int ath10k_ce_completed_recv_next(struct ce_state *ce_state,
556 return ret; 501 return ret;
557} 502}
558 503
559int ath10k_ce_revoke_recv_next(struct ce_state *ce_state, 504int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state,
560 void **per_transfer_contextp, 505 void **per_transfer_contextp,
561 u32 *bufferp) 506 u32 *bufferp)
562{ 507{
563 struct ce_ring_state *dest_ring; 508 struct ath10k_ce_ring *dest_ring;
564 unsigned int nentries_mask; 509 unsigned int nentries_mask;
565 unsigned int sw_index; 510 unsigned int sw_index;
566 unsigned int write_index; 511 unsigned int write_index;
@@ -612,19 +557,20 @@ int ath10k_ce_revoke_recv_next(struct ce_state *ce_state,
612 * Guts of ath10k_ce_completed_send_next. 557 * Guts of ath10k_ce_completed_send_next.
613 * The caller takes responsibility for any necessary locking. 558 * The caller takes responsibility for any necessary locking.
614 */ 559 */
615static int ath10k_ce_completed_send_next_nolock(struct ce_state *ce_state, 560static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
616 void **per_transfer_contextp, 561 void **per_transfer_contextp,
617 u32 *bufferp, 562 u32 *bufferp,
618 unsigned int *nbytesp, 563 unsigned int *nbytesp,
619 unsigned int *transfer_idp) 564 unsigned int *transfer_idp)
620{ 565{
621 struct ce_ring_state *src_ring = ce_state->src_ring; 566 struct ath10k_ce_ring *src_ring = ce_state->src_ring;
622 u32 ctrl_addr = ce_state->ctrl_addr; 567 u32 ctrl_addr = ce_state->ctrl_addr;
623 struct ath10k *ar = ce_state->ar; 568 struct ath10k *ar = ce_state->ar;
624 unsigned int nentries_mask = src_ring->nentries_mask; 569 unsigned int nentries_mask = src_ring->nentries_mask;
625 unsigned int sw_index = src_ring->sw_index; 570 unsigned int sw_index = src_ring->sw_index;
571 struct ce_desc *sdesc, *sbase;
626 unsigned int read_index; 572 unsigned int read_index;
627 int ret = -EIO; 573 int ret;
628 574
629 if (src_ring->hw_index == sw_index) { 575 if (src_ring->hw_index == sw_index) {
630 /* 576 /*
@@ -634,48 +580,54 @@ static int ath10k_ce_completed_send_next_nolock(struct ce_state *ce_state,
634 * the SW has really caught up to the HW, or if the cached 580 * the SW has really caught up to the HW, or if the cached
635 * value of the HW index has become stale. 581 * value of the HW index has become stale.
636 */ 582 */
637 ath10k_pci_wake(ar); 583
584 ret = ath10k_pci_wake(ar);
585 if (ret)
586 return ret;
587
638 src_ring->hw_index = 588 src_ring->hw_index =
639 ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); 589 ath10k_ce_src_ring_read_index_get(ar, ctrl_addr);
640 src_ring->hw_index &= nentries_mask; 590 src_ring->hw_index &= nentries_mask;
591
641 ath10k_pci_sleep(ar); 592 ath10k_pci_sleep(ar);
642 } 593 }
594
643 read_index = src_ring->hw_index; 595 read_index = src_ring->hw_index;
644 596
645 if ((read_index != sw_index) && (read_index != 0xffffffff)) { 597 if ((read_index == sw_index) || (read_index == 0xffffffff))
646 struct ce_desc *sbase = src_ring->shadow_base; 598 return -EIO;
647 struct ce_desc *sdesc = CE_SRC_RING_TO_DESC(sbase, sw_index);
648 599
649 /* Return data from completed source descriptor */ 600 sbase = src_ring->shadow_base;
650 *bufferp = __le32_to_cpu(sdesc->addr); 601 sdesc = CE_SRC_RING_TO_DESC(sbase, sw_index);
651 *nbytesp = __le16_to_cpu(sdesc->nbytes);
652 *transfer_idp = MS(__le16_to_cpu(sdesc->flags),
653 CE_DESC_FLAGS_META_DATA);
654 602
655 if (per_transfer_contextp) 603 /* Return data from completed source descriptor */
656 *per_transfer_contextp = 604 *bufferp = __le32_to_cpu(sdesc->addr);
657 src_ring->per_transfer_context[sw_index]; 605 *nbytesp = __le16_to_cpu(sdesc->nbytes);
606 *transfer_idp = MS(__le16_to_cpu(sdesc->flags),
607 CE_DESC_FLAGS_META_DATA);
658 608
659 /* sanity */ 609 if (per_transfer_contextp)
660 src_ring->per_transfer_context[sw_index] = NULL; 610 *per_transfer_contextp =
611 src_ring->per_transfer_context[sw_index];
661 612
662 /* Update sw_index */ 613 /* sanity */
663 sw_index = CE_RING_IDX_INCR(nentries_mask, sw_index); 614 src_ring->per_transfer_context[sw_index] = NULL;
664 src_ring->sw_index = sw_index;
665 ret = 0;
666 }
667 615
668 return ret; 616 /* Update sw_index */
617 sw_index = CE_RING_IDX_INCR(nentries_mask, sw_index);
618 src_ring->sw_index = sw_index;
619
620 return 0;
669} 621}
670 622
671/* NB: Modeled after ath10k_ce_completed_send_next */ 623/* NB: Modeled after ath10k_ce_completed_send_next */
672int ath10k_ce_cancel_send_next(struct ce_state *ce_state, 624int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state,
673 void **per_transfer_contextp, 625 void **per_transfer_contextp,
674 u32 *bufferp, 626 u32 *bufferp,
675 unsigned int *nbytesp, 627 unsigned int *nbytesp,
676 unsigned int *transfer_idp) 628 unsigned int *transfer_idp)
677{ 629{
678 struct ce_ring_state *src_ring; 630 struct ath10k_ce_ring *src_ring;
679 unsigned int nentries_mask; 631 unsigned int nentries_mask;
680 unsigned int sw_index; 632 unsigned int sw_index;
681 unsigned int write_index; 633 unsigned int write_index;
@@ -727,7 +679,7 @@ int ath10k_ce_cancel_send_next(struct ce_state *ce_state,
727 return ret; 679 return ret;
728} 680}
729 681
730int ath10k_ce_completed_send_next(struct ce_state *ce_state, 682int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state,
731 void **per_transfer_contextp, 683 void **per_transfer_contextp,
732 u32 *bufferp, 684 u32 *bufferp,
733 unsigned int *nbytesp, 685 unsigned int *nbytesp,
@@ -756,53 +708,29 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state,
756void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id) 708void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id)
757{ 709{
758 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 710 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
759 struct ce_state *ce_state = ar_pci->ce_id_to_state[ce_id]; 711 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
760 u32 ctrl_addr = ce_state->ctrl_addr; 712 u32 ctrl_addr = ce_state->ctrl_addr;
761 void *transfer_context; 713 int ret;
762 u32 buf; 714
763 unsigned int nbytes; 715 ret = ath10k_pci_wake(ar);
764 unsigned int id; 716 if (ret)
765 unsigned int flags; 717 return;
766 718
767 ath10k_pci_wake(ar);
768 spin_lock_bh(&ar_pci->ce_lock); 719 spin_lock_bh(&ar_pci->ce_lock);
769 720
770 /* Clear the copy-complete interrupts that will be handled here. */ 721 /* Clear the copy-complete interrupts that will be handled here. */
771 ath10k_ce_engine_int_status_clear(ar, ctrl_addr, 722 ath10k_ce_engine_int_status_clear(ar, ctrl_addr,
772 HOST_IS_COPY_COMPLETE_MASK); 723 HOST_IS_COPY_COMPLETE_MASK);
773 724
774 if (ce_state->recv_cb) { 725 spin_unlock_bh(&ar_pci->ce_lock);
775 /*
776 * Pop completed recv buffers and call the registered
777 * recv callback for each
778 */
779 while (ath10k_ce_completed_recv_next_nolock(ce_state,
780 &transfer_context,
781 &buf, &nbytes,
782 &id, &flags) == 0) {
783 spin_unlock_bh(&ar_pci->ce_lock);
784 ce_state->recv_cb(ce_state, transfer_context, buf,
785 nbytes, id, flags);
786 spin_lock_bh(&ar_pci->ce_lock);
787 }
788 }
789 726
790 if (ce_state->send_cb) { 727 if (ce_state->recv_cb)
791 /* 728 ce_state->recv_cb(ce_state);
792 * Pop completed send buffers and call the registered 729
793 * send callback for each 730 if (ce_state->send_cb)
794 */ 731 ce_state->send_cb(ce_state);
795 while (ath10k_ce_completed_send_next_nolock(ce_state, 732
796 &transfer_context, 733 spin_lock_bh(&ar_pci->ce_lock);
797 &buf,
798 &nbytes,
799 &id) == 0) {
800 spin_unlock_bh(&ar_pci->ce_lock);
801 ce_state->send_cb(ce_state, transfer_context,
802 buf, nbytes, id);
803 spin_lock_bh(&ar_pci->ce_lock);
804 }
805 }
806 734
807 /* 735 /*
808 * Misc CE interrupts are not being handled, but still need 736 * Misc CE interrupts are not being handled, but still need
@@ -823,10 +751,13 @@ void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id)
823void ath10k_ce_per_engine_service_any(struct ath10k *ar) 751void ath10k_ce_per_engine_service_any(struct ath10k *ar)
824{ 752{
825 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 753 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
826 int ce_id; 754 int ce_id, ret;
827 u32 intr_summary; 755 u32 intr_summary;
828 756
829 ath10k_pci_wake(ar); 757 ret = ath10k_pci_wake(ar);
758 if (ret)
759 return;
760
830 intr_summary = CE_INTERRUPT_SUMMARY(ar); 761 intr_summary = CE_INTERRUPT_SUMMARY(ar);
831 762
832 for (ce_id = 0; intr_summary && (ce_id < ar_pci->ce_count); ce_id++) { 763 for (ce_id = 0; intr_summary && (ce_id < ar_pci->ce_count); ce_id++) {
@@ -849,13 +780,16 @@ void ath10k_ce_per_engine_service_any(struct ath10k *ar)
849 * 780 *
850 * Called with ce_lock held. 781 * Called with ce_lock held.
851 */ 782 */
852static void ath10k_ce_per_engine_handler_adjust(struct ce_state *ce_state, 783static void ath10k_ce_per_engine_handler_adjust(struct ath10k_ce_pipe *ce_state,
853 int disable_copy_compl_intr) 784 int disable_copy_compl_intr)
854{ 785{
855 u32 ctrl_addr = ce_state->ctrl_addr; 786 u32 ctrl_addr = ce_state->ctrl_addr;
856 struct ath10k *ar = ce_state->ar; 787 struct ath10k *ar = ce_state->ar;
788 int ret;
857 789
858 ath10k_pci_wake(ar); 790 ret = ath10k_pci_wake(ar);
791 if (ret)
792 return;
859 793
860 if ((!disable_copy_compl_intr) && 794 if ((!disable_copy_compl_intr) &&
861 (ce_state->send_cb || ce_state->recv_cb)) 795 (ce_state->send_cb || ce_state->recv_cb))
@@ -871,11 +805,14 @@ static void ath10k_ce_per_engine_handler_adjust(struct ce_state *ce_state,
871void ath10k_ce_disable_interrupts(struct ath10k *ar) 805void ath10k_ce_disable_interrupts(struct ath10k *ar)
872{ 806{
873 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 807 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
874 int ce_id; 808 int ce_id, ret;
809
810 ret = ath10k_pci_wake(ar);
811 if (ret)
812 return;
875 813
876 ath10k_pci_wake(ar);
877 for (ce_id = 0; ce_id < ar_pci->ce_count; ce_id++) { 814 for (ce_id = 0; ce_id < ar_pci->ce_count; ce_id++) {
878 struct ce_state *ce_state = ar_pci->ce_id_to_state[ce_id]; 815 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
879 u32 ctrl_addr = ce_state->ctrl_addr; 816 u32 ctrl_addr = ce_state->ctrl_addr;
880 817
881 ath10k_ce_copy_complete_intr_disable(ar, ctrl_addr); 818 ath10k_ce_copy_complete_intr_disable(ar, ctrl_addr);
@@ -883,12 +820,8 @@ void ath10k_ce_disable_interrupts(struct ath10k *ar)
883 ath10k_pci_sleep(ar); 820 ath10k_pci_sleep(ar);
884} 821}
885 822
886void ath10k_ce_send_cb_register(struct ce_state *ce_state, 823void ath10k_ce_send_cb_register(struct ath10k_ce_pipe *ce_state,
887 void (*send_cb) (struct ce_state *ce_state, 824 void (*send_cb)(struct ath10k_ce_pipe *),
888 void *transfer_context,
889 u32 buffer,
890 unsigned int nbytes,
891 unsigned int transfer_id),
892 int disable_interrupts) 825 int disable_interrupts)
893{ 826{
894 struct ath10k *ar = ce_state->ar; 827 struct ath10k *ar = ce_state->ar;
@@ -900,13 +833,8 @@ void ath10k_ce_send_cb_register(struct ce_state *ce_state,
900 spin_unlock_bh(&ar_pci->ce_lock); 833 spin_unlock_bh(&ar_pci->ce_lock);
901} 834}
902 835
903void ath10k_ce_recv_cb_register(struct ce_state *ce_state, 836void ath10k_ce_recv_cb_register(struct ath10k_ce_pipe *ce_state,
904 void (*recv_cb) (struct ce_state *ce_state, 837 void (*recv_cb)(struct ath10k_ce_pipe *))
905 void *transfer_context,
906 u32 buffer,
907 unsigned int nbytes,
908 unsigned int transfer_id,
909 unsigned int flags))
910{ 838{
911 struct ath10k *ar = ce_state->ar; 839 struct ath10k *ar = ce_state->ar;
912 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 840 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
@@ -919,11 +847,11 @@ void ath10k_ce_recv_cb_register(struct ce_state *ce_state,
919 847
920static int ath10k_ce_init_src_ring(struct ath10k *ar, 848static int ath10k_ce_init_src_ring(struct ath10k *ar,
921 unsigned int ce_id, 849 unsigned int ce_id,
922 struct ce_state *ce_state, 850 struct ath10k_ce_pipe *ce_state,
923 const struct ce_attr *attr) 851 const struct ce_attr *attr)
924{ 852{
925 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 853 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
926 struct ce_ring_state *src_ring; 854 struct ath10k_ce_ring *src_ring;
927 unsigned int nentries = attr->src_nentries; 855 unsigned int nentries = attr->src_nentries;
928 unsigned int ce_nbytes; 856 unsigned int ce_nbytes;
929 u32 ctrl_addr = ath10k_ce_base_address(ce_id); 857 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
@@ -937,19 +865,18 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
937 return 0; 865 return 0;
938 } 866 }
939 867
940 ce_nbytes = sizeof(struct ce_ring_state) + (nentries * sizeof(void *)); 868 ce_nbytes = sizeof(struct ath10k_ce_ring) + (nentries * sizeof(void *));
941 ptr = kzalloc(ce_nbytes, GFP_KERNEL); 869 ptr = kzalloc(ce_nbytes, GFP_KERNEL);
942 if (ptr == NULL) 870 if (ptr == NULL)
943 return -ENOMEM; 871 return -ENOMEM;
944 872
945 ce_state->src_ring = (struct ce_ring_state *)ptr; 873 ce_state->src_ring = (struct ath10k_ce_ring *)ptr;
946 src_ring = ce_state->src_ring; 874 src_ring = ce_state->src_ring;
947 875
948 ptr += sizeof(struct ce_ring_state); 876 ptr += sizeof(struct ath10k_ce_ring);
949 src_ring->nentries = nentries; 877 src_ring->nentries = nentries;
950 src_ring->nentries_mask = nentries - 1; 878 src_ring->nentries_mask = nentries - 1;
951 879
952 ath10k_pci_wake(ar);
953 src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); 880 src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr);
954 src_ring->sw_index &= src_ring->nentries_mask; 881 src_ring->sw_index &= src_ring->nentries_mask;
955 src_ring->hw_index = src_ring->sw_index; 882 src_ring->hw_index = src_ring->sw_index;
@@ -957,7 +884,6 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
957 src_ring->write_index = 884 src_ring->write_index =
958 ath10k_ce_src_ring_write_index_get(ar, ctrl_addr); 885 ath10k_ce_src_ring_write_index_get(ar, ctrl_addr);
959 src_ring->write_index &= src_ring->nentries_mask; 886 src_ring->write_index &= src_ring->nentries_mask;
960 ath10k_pci_sleep(ar);
961 887
962 src_ring->per_transfer_context = (void **)ptr; 888 src_ring->per_transfer_context = (void **)ptr;
963 889
@@ -970,6 +896,12 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
970 (nentries * sizeof(struct ce_desc) + 896 (nentries * sizeof(struct ce_desc) +
971 CE_DESC_RING_ALIGN), 897 CE_DESC_RING_ALIGN),
972 &base_addr); 898 &base_addr);
899 if (!src_ring->base_addr_owner_space_unaligned) {
900 kfree(ce_state->src_ring);
901 ce_state->src_ring = NULL;
902 return -ENOMEM;
903 }
904
973 src_ring->base_addr_ce_space_unaligned = base_addr; 905 src_ring->base_addr_ce_space_unaligned = base_addr;
974 906
975 src_ring->base_addr_owner_space = PTR_ALIGN( 907 src_ring->base_addr_owner_space = PTR_ALIGN(
@@ -986,12 +918,21 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
986 src_ring->shadow_base_unaligned = 918 src_ring->shadow_base_unaligned =
987 kmalloc((nentries * sizeof(struct ce_desc) + 919 kmalloc((nentries * sizeof(struct ce_desc) +
988 CE_DESC_RING_ALIGN), GFP_KERNEL); 920 CE_DESC_RING_ALIGN), GFP_KERNEL);
921 if (!src_ring->shadow_base_unaligned) {
922 pci_free_consistent(ar_pci->pdev,
923 (nentries * sizeof(struct ce_desc) +
924 CE_DESC_RING_ALIGN),
925 src_ring->base_addr_owner_space,
926 src_ring->base_addr_ce_space);
927 kfree(ce_state->src_ring);
928 ce_state->src_ring = NULL;
929 return -ENOMEM;
930 }
989 931
990 src_ring->shadow_base = PTR_ALIGN( 932 src_ring->shadow_base = PTR_ALIGN(
991 src_ring->shadow_base_unaligned, 933 src_ring->shadow_base_unaligned,
992 CE_DESC_RING_ALIGN); 934 CE_DESC_RING_ALIGN);
993 935
994 ath10k_pci_wake(ar);
995 ath10k_ce_src_ring_base_addr_set(ar, ctrl_addr, 936 ath10k_ce_src_ring_base_addr_set(ar, ctrl_addr,
996 src_ring->base_addr_ce_space); 937 src_ring->base_addr_ce_space);
997 ath10k_ce_src_ring_size_set(ar, ctrl_addr, nentries); 938 ath10k_ce_src_ring_size_set(ar, ctrl_addr, nentries);
@@ -999,18 +940,21 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
999 ath10k_ce_src_ring_byte_swap_set(ar, ctrl_addr, 0); 940 ath10k_ce_src_ring_byte_swap_set(ar, ctrl_addr, 0);
1000 ath10k_ce_src_ring_lowmark_set(ar, ctrl_addr, 0); 941 ath10k_ce_src_ring_lowmark_set(ar, ctrl_addr, 0);
1001 ath10k_ce_src_ring_highmark_set(ar, ctrl_addr, nentries); 942 ath10k_ce_src_ring_highmark_set(ar, ctrl_addr, nentries);
1002 ath10k_pci_sleep(ar); 943
944 ath10k_dbg(ATH10K_DBG_BOOT,
945 "boot ce src ring id %d entries %d base_addr %p\n",
946 ce_id, nentries, src_ring->base_addr_owner_space);
1003 947
1004 return 0; 948 return 0;
1005} 949}
1006 950
1007static int ath10k_ce_init_dest_ring(struct ath10k *ar, 951static int ath10k_ce_init_dest_ring(struct ath10k *ar,
1008 unsigned int ce_id, 952 unsigned int ce_id,
1009 struct ce_state *ce_state, 953 struct ath10k_ce_pipe *ce_state,
1010 const struct ce_attr *attr) 954 const struct ce_attr *attr)
1011{ 955{
1012 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 956 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1013 struct ce_ring_state *dest_ring; 957 struct ath10k_ce_ring *dest_ring;
1014 unsigned int nentries = attr->dest_nentries; 958 unsigned int nentries = attr->dest_nentries;
1015 unsigned int ce_nbytes; 959 unsigned int ce_nbytes;
1016 u32 ctrl_addr = ath10k_ce_base_address(ce_id); 960 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
@@ -1024,25 +968,23 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
1024 return 0; 968 return 0;
1025 } 969 }
1026 970
1027 ce_nbytes = sizeof(struct ce_ring_state) + (nentries * sizeof(void *)); 971 ce_nbytes = sizeof(struct ath10k_ce_ring) + (nentries * sizeof(void *));
1028 ptr = kzalloc(ce_nbytes, GFP_KERNEL); 972 ptr = kzalloc(ce_nbytes, GFP_KERNEL);
1029 if (ptr == NULL) 973 if (ptr == NULL)
1030 return -ENOMEM; 974 return -ENOMEM;
1031 975
1032 ce_state->dest_ring = (struct ce_ring_state *)ptr; 976 ce_state->dest_ring = (struct ath10k_ce_ring *)ptr;
1033 dest_ring = ce_state->dest_ring; 977 dest_ring = ce_state->dest_ring;
1034 978
1035 ptr += sizeof(struct ce_ring_state); 979 ptr += sizeof(struct ath10k_ce_ring);
1036 dest_ring->nentries = nentries; 980 dest_ring->nentries = nentries;
1037 dest_ring->nentries_mask = nentries - 1; 981 dest_ring->nentries_mask = nentries - 1;
1038 982
1039 ath10k_pci_wake(ar);
1040 dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr); 983 dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr);
1041 dest_ring->sw_index &= dest_ring->nentries_mask; 984 dest_ring->sw_index &= dest_ring->nentries_mask;
1042 dest_ring->write_index = 985 dest_ring->write_index =
1043 ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr); 986 ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr);
1044 dest_ring->write_index &= dest_ring->nentries_mask; 987 dest_ring->write_index &= dest_ring->nentries_mask;
1045 ath10k_pci_sleep(ar);
1046 988
1047 dest_ring->per_transfer_context = (void **)ptr; 989 dest_ring->per_transfer_context = (void **)ptr;
1048 990
@@ -1055,6 +997,12 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
1055 (nentries * sizeof(struct ce_desc) + 997 (nentries * sizeof(struct ce_desc) +
1056 CE_DESC_RING_ALIGN), 998 CE_DESC_RING_ALIGN),
1057 &base_addr); 999 &base_addr);
1000 if (!dest_ring->base_addr_owner_space_unaligned) {
1001 kfree(ce_state->dest_ring);
1002 ce_state->dest_ring = NULL;
1003 return -ENOMEM;
1004 }
1005
1058 dest_ring->base_addr_ce_space_unaligned = base_addr; 1006 dest_ring->base_addr_ce_space_unaligned = base_addr;
1059 1007
1060 /* 1008 /*
@@ -1071,44 +1019,35 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
1071 dest_ring->base_addr_ce_space_unaligned, 1019 dest_ring->base_addr_ce_space_unaligned,
1072 CE_DESC_RING_ALIGN); 1020 CE_DESC_RING_ALIGN);
1073 1021
1074 ath10k_pci_wake(ar);
1075 ath10k_ce_dest_ring_base_addr_set(ar, ctrl_addr, 1022 ath10k_ce_dest_ring_base_addr_set(ar, ctrl_addr,
1076 dest_ring->base_addr_ce_space); 1023 dest_ring->base_addr_ce_space);
1077 ath10k_ce_dest_ring_size_set(ar, ctrl_addr, nentries); 1024 ath10k_ce_dest_ring_size_set(ar, ctrl_addr, nentries);
1078 ath10k_ce_dest_ring_byte_swap_set(ar, ctrl_addr, 0); 1025 ath10k_ce_dest_ring_byte_swap_set(ar, ctrl_addr, 0);
1079 ath10k_ce_dest_ring_lowmark_set(ar, ctrl_addr, 0); 1026 ath10k_ce_dest_ring_lowmark_set(ar, ctrl_addr, 0);
1080 ath10k_ce_dest_ring_highmark_set(ar, ctrl_addr, nentries); 1027 ath10k_ce_dest_ring_highmark_set(ar, ctrl_addr, nentries);
1081 ath10k_pci_sleep(ar); 1028
1029 ath10k_dbg(ATH10K_DBG_BOOT,
1030 "boot ce dest ring id %d entries %d base_addr %p\n",
1031 ce_id, nentries, dest_ring->base_addr_owner_space);
1082 1032
1083 return 0; 1033 return 0;
1084} 1034}
1085 1035
1086static struct ce_state *ath10k_ce_init_state(struct ath10k *ar, 1036static struct ath10k_ce_pipe *ath10k_ce_init_state(struct ath10k *ar,
1087 unsigned int ce_id, 1037 unsigned int ce_id,
1088 const struct ce_attr *attr) 1038 const struct ce_attr *attr)
1089{ 1039{
1090 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1040 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1091 struct ce_state *ce_state = NULL; 1041 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1092 u32 ctrl_addr = ath10k_ce_base_address(ce_id); 1042 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
1093 1043
1094 spin_lock_bh(&ar_pci->ce_lock); 1044 spin_lock_bh(&ar_pci->ce_lock);
1095 1045
1096 if (!ar_pci->ce_id_to_state[ce_id]) { 1046 ce_state->ar = ar;
1097 ce_state = kzalloc(sizeof(*ce_state), GFP_ATOMIC); 1047 ce_state->id = ce_id;
1098 if (ce_state == NULL) { 1048 ce_state->ctrl_addr = ctrl_addr;
1099 spin_unlock_bh(&ar_pci->ce_lock); 1049 ce_state->attr_flags = attr->flags;
1100 return NULL; 1050 ce_state->src_sz_max = attr->src_sz_max;
1101 }
1102
1103 ar_pci->ce_id_to_state[ce_id] = ce_state;
1104 ce_state->ar = ar;
1105 ce_state->id = ce_id;
1106 ce_state->ctrl_addr = ctrl_addr;
1107 ce_state->state = CE_RUNNING;
1108 /* Save attribute flags */
1109 ce_state->attr_flags = attr->flags;
1110 ce_state->src_sz_max = attr->src_sz_max;
1111 }
1112 1051
1113 spin_unlock_bh(&ar_pci->ce_lock); 1052 spin_unlock_bh(&ar_pci->ce_lock);
1114 1053
@@ -1122,12 +1061,17 @@ static struct ce_state *ath10k_ce_init_state(struct ath10k *ar,
1122 * initialization. It may be that only one side or the other is 1061 * initialization. It may be that only one side or the other is
1123 * initialized by software/firmware. 1062 * initialized by software/firmware.
1124 */ 1063 */
1125struct ce_state *ath10k_ce_init(struct ath10k *ar, 1064struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar,
1126 unsigned int ce_id, 1065 unsigned int ce_id,
1127 const struct ce_attr *attr) 1066 const struct ce_attr *attr)
1128{ 1067{
1129 struct ce_state *ce_state; 1068 struct ath10k_ce_pipe *ce_state;
1130 u32 ctrl_addr = ath10k_ce_base_address(ce_id); 1069 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
1070 int ret;
1071
1072 ret = ath10k_pci_wake(ar);
1073 if (ret)
1074 return NULL;
1131 1075
1132 ce_state = ath10k_ce_init_state(ar, ce_id, attr); 1076 ce_state = ath10k_ce_init_state(ar, ce_id, attr);
1133 if (!ce_state) { 1077 if (!ce_state) {
@@ -1136,40 +1080,38 @@ struct ce_state *ath10k_ce_init(struct ath10k *ar,
1136 } 1080 }
1137 1081
1138 if (attr->src_nentries) { 1082 if (attr->src_nentries) {
1139 if (ath10k_ce_init_src_ring(ar, ce_id, ce_state, attr)) { 1083 ret = ath10k_ce_init_src_ring(ar, ce_id, ce_state, attr);
1140 ath10k_err("Failed to initialize CE src ring for ID: %d\n", 1084 if (ret) {
1141 ce_id); 1085 ath10k_err("Failed to initialize CE src ring for ID: %d (%d)\n",
1086 ce_id, ret);
1142 ath10k_ce_deinit(ce_state); 1087 ath10k_ce_deinit(ce_state);
1143 return NULL; 1088 return NULL;
1144 } 1089 }
1145 } 1090 }
1146 1091
1147 if (attr->dest_nentries) { 1092 if (attr->dest_nentries) {
1148 if (ath10k_ce_init_dest_ring(ar, ce_id, ce_state, attr)) { 1093 ret = ath10k_ce_init_dest_ring(ar, ce_id, ce_state, attr);
1149 ath10k_err("Failed to initialize CE dest ring for ID: %d\n", 1094 if (ret) {
1150 ce_id); 1095 ath10k_err("Failed to initialize CE dest ring for ID: %d (%d)\n",
1096 ce_id, ret);
1151 ath10k_ce_deinit(ce_state); 1097 ath10k_ce_deinit(ce_state);
1152 return NULL; 1098 return NULL;
1153 } 1099 }
1154 } 1100 }
1155 1101
1156 /* Enable CE error interrupts */ 1102 /* Enable CE error interrupts */
1157 ath10k_pci_wake(ar);
1158 ath10k_ce_error_intr_enable(ar, ctrl_addr); 1103 ath10k_ce_error_intr_enable(ar, ctrl_addr);
1104
1159 ath10k_pci_sleep(ar); 1105 ath10k_pci_sleep(ar);
1160 1106
1161 return ce_state; 1107 return ce_state;
1162} 1108}
1163 1109
1164void ath10k_ce_deinit(struct ce_state *ce_state) 1110void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state)
1165{ 1111{
1166 unsigned int ce_id = ce_state->id;
1167 struct ath10k *ar = ce_state->ar; 1112 struct ath10k *ar = ce_state->ar;
1168 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1113 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1169 1114
1170 ce_state->state = CE_UNUSED;
1171 ar_pci->ce_id_to_state[ce_id] = NULL;
1172
1173 if (ce_state->src_ring) { 1115 if (ce_state->src_ring) {
1174 kfree(ce_state->src_ring->shadow_base_unaligned); 1116 kfree(ce_state->src_ring->shadow_base_unaligned);
1175 pci_free_consistent(ar_pci->pdev, 1117 pci_free_consistent(ar_pci->pdev,
@@ -1190,5 +1132,7 @@ void ath10k_ce_deinit(struct ce_state *ce_state)
1190 ce_state->dest_ring->base_addr_ce_space); 1132 ce_state->dest_ring->base_addr_ce_space);
1191 kfree(ce_state->dest_ring); 1133 kfree(ce_state->dest_ring);
1192 } 1134 }
1193 kfree(ce_state); 1135
1136 ce_state->src_ring = NULL;
1137 ce_state->dest_ring = NULL;
1194} 1138}
diff --git a/drivers/net/wireless/ath/ath10k/ce.h b/drivers/net/wireless/ath/ath10k/ce.h
index c17f07c026f4..aec802868341 100644
--- a/drivers/net/wireless/ath/ath10k/ce.h
+++ b/drivers/net/wireless/ath/ath10k/ce.h
@@ -27,7 +27,6 @@
27 27
28/* Descriptor rings must be aligned to this boundary */ 28/* Descriptor rings must be aligned to this boundary */
29#define CE_DESC_RING_ALIGN 8 29#define CE_DESC_RING_ALIGN 8
30#define CE_SENDLIST_ITEMS_MAX 12
31#define CE_SEND_FLAG_GATHER 0x00010000 30#define CE_SEND_FLAG_GATHER 0x00010000
32 31
33/* 32/*
@@ -36,16 +35,9 @@
36 * how to use copy engines. 35 * how to use copy engines.
37 */ 36 */
38 37
39struct ce_state; 38struct ath10k_ce_pipe;
40 39
41 40
42/* Copy Engine operational state */
43enum ce_op_state {
44 CE_UNUSED,
45 CE_PAUSED,
46 CE_RUNNING,
47};
48
49#define CE_DESC_FLAGS_GATHER (1 << 0) 41#define CE_DESC_FLAGS_GATHER (1 << 0)
50#define CE_DESC_FLAGS_BYTE_SWAP (1 << 1) 42#define CE_DESC_FLAGS_BYTE_SWAP (1 << 1)
51#define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC 43#define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC
@@ -57,8 +49,7 @@ struct ce_desc {
57 __le16 flags; /* %CE_DESC_FLAGS_ */ 49 __le16 flags; /* %CE_DESC_FLAGS_ */
58}; 50};
59 51
60/* Copy Engine Ring internal state */ 52struct ath10k_ce_ring {
61struct ce_ring_state {
62 /* Number of entries in this ring; must be power of 2 */ 53 /* Number of entries in this ring; must be power of 2 */
63 unsigned int nentries; 54 unsigned int nentries;
64 unsigned int nentries_mask; 55 unsigned int nentries_mask;
@@ -116,49 +107,20 @@ struct ce_ring_state {
116 void **per_transfer_context; 107 void **per_transfer_context;
117}; 108};
118 109
119/* Copy Engine internal state */ 110struct ath10k_ce_pipe {
120struct ce_state {
121 struct ath10k *ar; 111 struct ath10k *ar;
122 unsigned int id; 112 unsigned int id;
123 113
124 unsigned int attr_flags; 114 unsigned int attr_flags;
125 115
126 u32 ctrl_addr; 116 u32 ctrl_addr;
127 enum ce_op_state state;
128
129 void (*send_cb) (struct ce_state *ce_state,
130 void *per_transfer_send_context,
131 u32 buffer,
132 unsigned int nbytes,
133 unsigned int transfer_id);
134 void (*recv_cb) (struct ce_state *ce_state,
135 void *per_transfer_recv_context,
136 u32 buffer,
137 unsigned int nbytes,
138 unsigned int transfer_id,
139 unsigned int flags);
140 117
141 unsigned int src_sz_max; 118 void (*send_cb)(struct ath10k_ce_pipe *);
142 struct ce_ring_state *src_ring; 119 void (*recv_cb)(struct ath10k_ce_pipe *);
143 struct ce_ring_state *dest_ring;
144};
145 120
146struct ce_sendlist_item { 121 unsigned int src_sz_max;
147 /* e.g. buffer or desc list */ 122 struct ath10k_ce_ring *src_ring;
148 dma_addr_t data; 123 struct ath10k_ce_ring *dest_ring;
149 union {
150 /* simple buffer */
151 unsigned int nbytes;
152 /* Rx descriptor list */
153 unsigned int ndesc;
154 } u;
155 /* externally-specified flags; OR-ed with internal flags */
156 u32 flags;
157};
158
159struct ce_sendlist {
160 unsigned int num_items;
161 struct ce_sendlist_item item[CE_SENDLIST_ITEMS_MAX];
162}; 124};
163 125
164/* Copy Engine settable attributes */ 126/* Copy Engine settable attributes */
@@ -182,7 +144,7 @@ struct ce_attr;
182 * 144 *
183 * Implementation note: pushes 1 buffer to Source ring 145 * Implementation note: pushes 1 buffer to Source ring
184 */ 146 */
185int ath10k_ce_send(struct ce_state *ce_state, 147int ath10k_ce_send(struct ath10k_ce_pipe *ce_state,
186 void *per_transfer_send_context, 148 void *per_transfer_send_context,
187 u32 buffer, 149 u32 buffer,
188 unsigned int nbytes, 150 unsigned int nbytes,
@@ -190,21 +152,10 @@ int ath10k_ce_send(struct ce_state *ce_state,
190 unsigned int transfer_id, 152 unsigned int transfer_id,
191 unsigned int flags); 153 unsigned int flags);
192 154
193void ath10k_ce_send_cb_register(struct ce_state *ce_state, 155void ath10k_ce_send_cb_register(struct ath10k_ce_pipe *ce_state,
194 void (*send_cb) (struct ce_state *ce_state, 156 void (*send_cb)(struct ath10k_ce_pipe *),
195 void *transfer_context,
196 u32 buffer,
197 unsigned int nbytes,
198 unsigned int transfer_id),
199 int disable_interrupts); 157 int disable_interrupts);
200 158
201/* Append a simple buffer (address/length) to a sendlist. */
202void ath10k_ce_sendlist_buf_add(struct ce_sendlist *sendlist,
203 u32 buffer,
204 unsigned int nbytes,
205 /* OR-ed with internal flags */
206 u32 flags);
207
208/* 159/*
209 * Queue a "sendlist" of buffers to be sent using gather to a single 160 * Queue a "sendlist" of buffers to be sent using gather to a single
210 * anonymous destination buffer 161 * anonymous destination buffer
@@ -215,11 +166,11 @@ void ath10k_ce_sendlist_buf_add(struct ce_sendlist *sendlist,
215 * 166 *
216 * Implemenation note: Pushes multiple buffers with Gather to Source ring. 167 * Implemenation note: Pushes multiple buffers with Gather to Source ring.
217 */ 168 */
218int ath10k_ce_sendlist_send(struct ce_state *ce_state, 169int ath10k_ce_sendlist_send(struct ath10k_ce_pipe *ce_state,
219 void *per_transfer_send_context, 170 void *per_transfer_context,
220 struct ce_sendlist *sendlist, 171 unsigned int transfer_id,
221 /* 14 bits */ 172 u32 paddr, unsigned int nbytes,
222 unsigned int transfer_id); 173 u32 flags);
223 174
224/*==================Recv=======================*/ 175/*==================Recv=======================*/
225 176
@@ -233,17 +184,12 @@ int ath10k_ce_sendlist_send(struct ce_state *ce_state,
233 * 184 *
234 * Implemenation note: Pushes a buffer to Dest ring. 185 * Implemenation note: Pushes a buffer to Dest ring.
235 */ 186 */
236int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state, 187int ath10k_ce_recv_buf_enqueue(struct ath10k_ce_pipe *ce_state,
237 void *per_transfer_recv_context, 188 void *per_transfer_recv_context,
238 u32 buffer); 189 u32 buffer);
239 190
240void ath10k_ce_recv_cb_register(struct ce_state *ce_state, 191void ath10k_ce_recv_cb_register(struct ath10k_ce_pipe *ce_state,
241 void (*recv_cb) (struct ce_state *ce_state, 192 void (*recv_cb)(struct ath10k_ce_pipe *));
242 void *transfer_context,
243 u32 buffer,
244 unsigned int nbytes,
245 unsigned int transfer_id,
246 unsigned int flags));
247 193
248/* recv flags */ 194/* recv flags */
249/* Data is byte-swapped */ 195/* Data is byte-swapped */
@@ -253,7 +199,7 @@ void ath10k_ce_recv_cb_register(struct ce_state *ce_state,
253 * Supply data for the next completed unprocessed receive descriptor. 199 * Supply data for the next completed unprocessed receive descriptor.
254 * Pops buffer from Dest ring. 200 * Pops buffer from Dest ring.
255 */ 201 */
256int ath10k_ce_completed_recv_next(struct ce_state *ce_state, 202int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state,
257 void **per_transfer_contextp, 203 void **per_transfer_contextp,
258 u32 *bufferp, 204 u32 *bufferp,
259 unsigned int *nbytesp, 205 unsigned int *nbytesp,
@@ -263,7 +209,7 @@ int ath10k_ce_completed_recv_next(struct ce_state *ce_state,
263 * Supply data for the next completed unprocessed send descriptor. 209 * Supply data for the next completed unprocessed send descriptor.
264 * Pops 1 completed send buffer from Source ring. 210 * Pops 1 completed send buffer from Source ring.
265 */ 211 */
266int ath10k_ce_completed_send_next(struct ce_state *ce_state, 212int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state,
267 void **per_transfer_contextp, 213 void **per_transfer_contextp,
268 u32 *bufferp, 214 u32 *bufferp,
269 unsigned int *nbytesp, 215 unsigned int *nbytesp,
@@ -272,7 +218,7 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state,
272/*==================CE Engine Initialization=======================*/ 218/*==================CE Engine Initialization=======================*/
273 219
274/* Initialize an instance of a CE */ 220/* Initialize an instance of a CE */
275struct ce_state *ath10k_ce_init(struct ath10k *ar, 221struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar,
276 unsigned int ce_id, 222 unsigned int ce_id,
277 const struct ce_attr *attr); 223 const struct ce_attr *attr);
278 224
@@ -282,7 +228,7 @@ struct ce_state *ath10k_ce_init(struct ath10k *ar,
282 * receive buffers. Target DMA must be stopped before using 228 * receive buffers. Target DMA must be stopped before using
283 * this API. 229 * this API.
284 */ 230 */
285int ath10k_ce_revoke_recv_next(struct ce_state *ce_state, 231int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state,
286 void **per_transfer_contextp, 232 void **per_transfer_contextp,
287 u32 *bufferp); 233 u32 *bufferp);
288 234
@@ -291,13 +237,13 @@ int ath10k_ce_revoke_recv_next(struct ce_state *ce_state,
291 * pending sends. Target DMA must be stopped before using 237 * pending sends. Target DMA must be stopped before using
292 * this API. 238 * this API.
293 */ 239 */
294int ath10k_ce_cancel_send_next(struct ce_state *ce_state, 240int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state,
295 void **per_transfer_contextp, 241 void **per_transfer_contextp,
296 u32 *bufferp, 242 u32 *bufferp,
297 unsigned int *nbytesp, 243 unsigned int *nbytesp,
298 unsigned int *transfer_idp); 244 unsigned int *transfer_idp);
299 245
300void ath10k_ce_deinit(struct ce_state *ce_state); 246void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state);
301 247
302/*==================CE Interrupt Handlers====================*/ 248/*==================CE Interrupt Handlers====================*/
303void ath10k_ce_per_engine_service_any(struct ath10k *ar); 249void ath10k_ce_per_engine_service_any(struct ath10k *ar);
@@ -322,9 +268,6 @@ struct ce_attr {
322 /* CE_ATTR_* values */ 268 /* CE_ATTR_* values */
323 unsigned int flags; 269 unsigned int flags;
324 270
325 /* currently not in use */
326 unsigned int priority;
327
328 /* #entries in source ring - Must be a power of 2 */ 271 /* #entries in source ring - Must be a power of 2 */
329 unsigned int src_nentries; 272 unsigned int src_nentries;
330 273
@@ -336,21 +279,8 @@ struct ce_attr {
336 279
337 /* #entries in destination ring - Must be a power of 2 */ 280 /* #entries in destination ring - Must be a power of 2 */
338 unsigned int dest_nentries; 281 unsigned int dest_nentries;
339
340 /* Future use */
341 void *reserved;
342}; 282};
343 283
344/*
345 * When using sendlist_send to transfer multiple buffer fragments, the
346 * transfer context of each fragment, except last one, will be filled
347 * with CE_SENDLIST_ITEM_CTXT. ce_completed_send will return success for
348 * each fragment done with send and the transfer context would be
349 * CE_SENDLIST_ITEM_CTXT. Upper layer could use this to identify the
350 * status of a send completion.
351 */
352#define CE_SENDLIST_ITEM_CTXT ((void *)0xcecebeef)
353
354#define SR_BA_ADDRESS 0x0000 284#define SR_BA_ADDRESS 0x0000
355#define SR_SIZE_ADDRESS 0x0004 285#define SR_SIZE_ADDRESS 0x0004
356#define DR_BA_ADDRESS 0x0008 286#define DR_BA_ADDRESS 0x0008
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 7226c23b9569..76906d5a082e 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -39,17 +39,6 @@ MODULE_PARM_DESC(p2p, "Enable ath10k P2P support");
39 39
40static const struct ath10k_hw_params ath10k_hw_params_list[] = { 40static const struct ath10k_hw_params ath10k_hw_params_list[] = {
41 { 41 {
42 .id = QCA988X_HW_1_0_VERSION,
43 .name = "qca988x hw1.0",
44 .patch_load_addr = QCA988X_HW_1_0_PATCH_LOAD_ADDR,
45 .fw = {
46 .dir = QCA988X_HW_1_0_FW_DIR,
47 .fw = QCA988X_HW_1_0_FW_FILE,
48 .otp = QCA988X_HW_1_0_OTP_FILE,
49 .board = QCA988X_HW_1_0_BOARD_DATA_FILE,
50 },
51 },
52 {
53 .id = QCA988X_HW_2_0_VERSION, 42 .id = QCA988X_HW_2_0_VERSION,
54 .name = "qca988x hw2.0", 43 .name = "qca988x hw2.0",
55 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, 44 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
@@ -64,7 +53,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = {
64 53
65static void ath10k_send_suspend_complete(struct ath10k *ar) 54static void ath10k_send_suspend_complete(struct ath10k *ar)
66{ 55{
67 ath10k_dbg(ATH10K_DBG_CORE, "%s\n", __func__); 56 ath10k_dbg(ATH10K_DBG_BOOT, "boot suspend complete\n");
68 57
69 ar->is_target_paused = true; 58 ar->is_target_paused = true;
70 wake_up(&ar->event_queue); 59 wake_up(&ar->event_queue);
@@ -112,7 +101,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar)
112 goto timeout; 101 goto timeout;
113 } 102 }
114 103
115 ath10k_dbg(ATH10K_DBG_CORE, "core wmi ready\n"); 104 ath10k_dbg(ATH10K_DBG_BOOT, "boot wmi ready\n");
116 return 0; 105 return 0;
117 106
118timeout: 107timeout:
@@ -214,8 +203,8 @@ static int ath10k_push_board_ext_data(struct ath10k *ar,
214 return ret; 203 return ret;
215 } 204 }
216 205
217 ath10k_dbg(ATH10K_DBG_CORE, 206 ath10k_dbg(ATH10K_DBG_BOOT,
218 "ath10k: Board extended Data download addr: 0x%x\n", 207 "boot push board extended data addr 0x%x\n",
219 board_ext_data_addr); 208 board_ext_data_addr);
220 209
221 if (board_ext_data_addr == 0) 210 if (board_ext_data_addr == 0)
@@ -446,6 +435,13 @@ static int ath10k_init_uart(struct ath10k *ar)
446 return ret; 435 return ret;
447 } 436 }
448 437
438 /* Set the UART baud rate to 19200. */
439 ret = ath10k_bmi_write32(ar, hi_desired_baud_rate, 19200);
440 if (ret) {
441 ath10k_warn("could not set the baud rate (%d)\n", ret);
442 return ret;
443 }
444
449 ath10k_info("UART prints enabled\n"); 445 ath10k_info("UART prints enabled\n");
450 return 0; 446 return 0;
451} 447}
@@ -641,6 +637,10 @@ int ath10k_core_start(struct ath10k *ar)
641 if (status) 637 if (status)
642 goto err_disconnect_htc; 638 goto err_disconnect_htc;
643 639
640 status = ath10k_debug_start(ar);
641 if (status)
642 goto err_disconnect_htc;
643
644 ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1; 644 ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1;
645 645
646 return 0; 646 return 0;
@@ -658,6 +658,7 @@ EXPORT_SYMBOL(ath10k_core_start);
658 658
659void ath10k_core_stop(struct ath10k *ar) 659void ath10k_core_stop(struct ath10k *ar)
660{ 660{
661 ath10k_debug_stop(ar);
661 ath10k_htc_stop(&ar->htc); 662 ath10k_htc_stop(&ar->htc);
662 ath10k_htt_detach(&ar->htt); 663 ath10k_htt_detach(&ar->htt);
663 ath10k_wmi_detach(ar); 664 ath10k_wmi_detach(ar);
@@ -717,10 +718,46 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
717 return 0; 718 return 0;
718} 719}
719 720
720int ath10k_core_register(struct ath10k *ar) 721static int ath10k_core_check_chip_id(struct ath10k *ar)
722{
723 u32 hw_revision = MS(ar->chip_id, SOC_CHIP_ID_REV);
724
725 ath10k_dbg(ATH10K_DBG_BOOT, "boot chip_id 0x%08x hw_revision 0x%x\n",
726 ar->chip_id, hw_revision);
727
728 /* Check that we are not using hw1.0 (some of them have same pci id
729 * as hw2.0) before doing anything else as ath10k crashes horribly
730 * due to missing hw1.0 workarounds. */
731 switch (hw_revision) {
732 case QCA988X_HW_1_0_CHIP_ID_REV:
733 ath10k_err("ERROR: qca988x hw1.0 is not supported\n");
734 return -EOPNOTSUPP;
735
736 case QCA988X_HW_2_0_CHIP_ID_REV:
737 /* known hardware revision, continue normally */
738 return 0;
739
740 default:
741 ath10k_warn("Warning: hardware revision unknown (0x%x), expect problems\n",
742 ar->chip_id);
743 return 0;
744 }
745
746 return 0;
747}
748
749int ath10k_core_register(struct ath10k *ar, u32 chip_id)
721{ 750{
722 int status; 751 int status;
723 752
753 ar->chip_id = chip_id;
754
755 status = ath10k_core_check_chip_id(ar);
756 if (status) {
757 ath10k_err("Unsupported chip id 0x%08x\n", ar->chip_id);
758 return status;
759 }
760
724 status = ath10k_core_probe_fw(ar); 761 status = ath10k_core_probe_fw(ar);
725 if (status) { 762 if (status) {
726 ath10k_err("could not probe fw (%d)\n", status); 763 ath10k_err("could not probe fw (%d)\n", status);
@@ -755,6 +792,7 @@ void ath10k_core_unregister(struct ath10k *ar)
755 * Otherwise we will fail to submit commands to FW and mac80211 will be 792 * Otherwise we will fail to submit commands to FW and mac80211 will be
756 * unhappy about callback failures. */ 793 * unhappy about callback failures. */
757 ath10k_mac_unregister(ar); 794 ath10k_mac_unregister(ar);
795
758 ath10k_core_free_firmware_files(ar); 796 ath10k_core_free_firmware_files(ar);
759} 797}
760EXPORT_SYMBOL(ath10k_core_unregister); 798EXPORT_SYMBOL(ath10k_core_unregister);
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index e4bba563ed42..292ad4577c98 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -52,18 +52,12 @@ struct ath10k_skb_cb {
52 52
53 struct { 53 struct {
54 u8 vdev_id; 54 u8 vdev_id;
55 u16 msdu_id;
56 u8 tid; 55 u8 tid;
57 bool is_offchan; 56 bool is_offchan;
58 bool is_conf;
59 bool discard;
60 bool no_ack;
61 u8 refcount;
62 struct sk_buff *txfrag;
63 struct sk_buff *msdu;
64 } __packed htt;
65 57
66 /* 4 bytes left on 64bit arch */ 58 u8 frag_len;
59 u8 pad_len;
60 } __packed htt;
67} __packed; 61} __packed;
68 62
69static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb) 63static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
@@ -112,11 +106,7 @@ struct ath10k_wmi {
112 enum ath10k_htc_ep_id eid; 106 enum ath10k_htc_ep_id eid;
113 struct completion service_ready; 107 struct completion service_ready;
114 struct completion unified_ready; 108 struct completion unified_ready;
115 atomic_t pending_tx_count; 109 wait_queue_head_t tx_credits_wq;
116 wait_queue_head_t wq;
117
118 struct sk_buff_head wmi_event_list;
119 struct work_struct wmi_event_work;
120}; 110};
121 111
122struct ath10k_peer_stat { 112struct ath10k_peer_stat {
@@ -203,6 +193,7 @@ struct ath10k_vif {
203 enum wmi_vdev_subtype vdev_subtype; 193 enum wmi_vdev_subtype vdev_subtype;
204 u32 beacon_interval; 194 u32 beacon_interval;
205 u32 dtim_period; 195 u32 dtim_period;
196 struct sk_buff *beacon;
206 197
207 struct ath10k *ar; 198 struct ath10k *ar;
208 struct ieee80211_vif *vif; 199 struct ieee80211_vif *vif;
@@ -246,6 +237,9 @@ struct ath10k_debug {
246 u32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE]; 237 u32 wmi_service_bitmap[WMI_SERVICE_BM_SIZE];
247 238
248 struct completion event_stats_compl; 239 struct completion event_stats_compl;
240
241 unsigned long htt_stats_mask;
242 struct delayed_work htt_stats_dwork;
249}; 243};
250 244
251enum ath10k_state { 245enum ath10k_state {
@@ -270,12 +264,21 @@ enum ath10k_state {
270 ATH10K_STATE_WEDGED, 264 ATH10K_STATE_WEDGED,
271}; 265};
272 266
267enum ath10k_fw_features {
268 /* wmi_mgmt_rx_hdr contains extra RSSI information */
269 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
270
271 /* keep last */
272 ATH10K_FW_FEATURE_COUNT,
273};
274
273struct ath10k { 275struct ath10k {
274 struct ath_common ath_common; 276 struct ath_common ath_common;
275 struct ieee80211_hw *hw; 277 struct ieee80211_hw *hw;
276 struct device *dev; 278 struct device *dev;
277 u8 mac_addr[ETH_ALEN]; 279 u8 mac_addr[ETH_ALEN];
278 280
281 u32 chip_id;
279 u32 target_version; 282 u32 target_version;
280 u8 fw_version_major; 283 u8 fw_version_major;
281 u32 fw_version_minor; 284 u32 fw_version_minor;
@@ -288,6 +291,8 @@ struct ath10k {
288 u32 vht_cap_info; 291 u32 vht_cap_info;
289 u32 num_rf_chains; 292 u32 num_rf_chains;
290 293
294 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
295
291 struct targetdef *targetdef; 296 struct targetdef *targetdef;
292 struct hostdef *hostdef; 297 struct hostdef *hostdef;
293 298
@@ -393,7 +398,7 @@ void ath10k_core_destroy(struct ath10k *ar);
393 398
394int ath10k_core_start(struct ath10k *ar); 399int ath10k_core_start(struct ath10k *ar);
395void ath10k_core_stop(struct ath10k *ar); 400void ath10k_core_stop(struct ath10k *ar);
396int ath10k_core_register(struct ath10k *ar); 401int ath10k_core_register(struct ath10k *ar, u32 chip_id);
397void ath10k_core_unregister(struct ath10k *ar); 402void ath10k_core_unregister(struct ath10k *ar);
398 403
399#endif /* _CORE_H_ */ 404#endif /* _CORE_H_ */
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 3d65594fa098..59615c7f217e 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -21,6 +21,9 @@
21#include "core.h" 21#include "core.h"
22#include "debug.h" 22#include "debug.h"
23 23
24/* ms */
25#define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000
26
24static int ath10k_printk(const char *level, const char *fmt, ...) 27static int ath10k_printk(const char *level, const char *fmt, ...)
25{ 28{
26 struct va_format vaf; 29 struct va_format vaf;
@@ -260,7 +263,6 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
260 } 263 }
261 264
262 spin_unlock_bh(&ar->data_lock); 265 spin_unlock_bh(&ar->data_lock);
263 mutex_unlock(&ar->conf_mutex);
264 complete(&ar->debug.event_stats_compl); 266 complete(&ar->debug.event_stats_compl);
265} 267}
266 268
@@ -499,6 +501,136 @@ static const struct file_operations fops_simulate_fw_crash = {
499 .llseek = default_llseek, 501 .llseek = default_llseek,
500}; 502};
501 503
504static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf,
505 size_t count, loff_t *ppos)
506{
507 struct ath10k *ar = file->private_data;
508 unsigned int len;
509 char buf[50];
510
511 len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->chip_id);
512
513 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
514}
515
516static const struct file_operations fops_chip_id = {
517 .read = ath10k_read_chip_id,
518 .open = simple_open,
519 .owner = THIS_MODULE,
520 .llseek = default_llseek,
521};
522
523static int ath10k_debug_htt_stats_req(struct ath10k *ar)
524{
525 u64 cookie;
526 int ret;
527
528 lockdep_assert_held(&ar->conf_mutex);
529
530 if (ar->debug.htt_stats_mask == 0)
531 /* htt stats are disabled */
532 return 0;
533
534 if (ar->state != ATH10K_STATE_ON)
535 return 0;
536
537 cookie = get_jiffies_64();
538
539 ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask,
540 cookie);
541 if (ret) {
542 ath10k_warn("failed to send htt stats request: %d\n", ret);
543 return ret;
544 }
545
546 queue_delayed_work(ar->workqueue, &ar->debug.htt_stats_dwork,
547 msecs_to_jiffies(ATH10K_DEBUG_HTT_STATS_INTERVAL));
548
549 return 0;
550}
551
552static void ath10k_debug_htt_stats_dwork(struct work_struct *work)
553{
554 struct ath10k *ar = container_of(work, struct ath10k,
555 debug.htt_stats_dwork.work);
556
557 mutex_lock(&ar->conf_mutex);
558
559 ath10k_debug_htt_stats_req(ar);
560
561 mutex_unlock(&ar->conf_mutex);
562}
563
564static ssize_t ath10k_read_htt_stats_mask(struct file *file,
565 char __user *user_buf,
566 size_t count, loff_t *ppos)
567{
568 struct ath10k *ar = file->private_data;
569 char buf[32];
570 unsigned int len;
571
572 len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask);
573
574 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
575}
576
577static ssize_t ath10k_write_htt_stats_mask(struct file *file,
578 const char __user *user_buf,
579 size_t count, loff_t *ppos)
580{
581 struct ath10k *ar = file->private_data;
582 unsigned long mask;
583 int ret;
584
585 ret = kstrtoul_from_user(user_buf, count, 0, &mask);
586 if (ret)
587 return ret;
588
589 /* max 8 bit masks (for now) */
590 if (mask > 0xff)
591 return -E2BIG;
592
593 mutex_lock(&ar->conf_mutex);
594
595 ar->debug.htt_stats_mask = mask;
596
597 ret = ath10k_debug_htt_stats_req(ar);
598 if (ret)
599 goto out;
600
601 ret = count;
602
603out:
604 mutex_unlock(&ar->conf_mutex);
605
606 return ret;
607}
608
609static const struct file_operations fops_htt_stats_mask = {
610 .read = ath10k_read_htt_stats_mask,
611 .write = ath10k_write_htt_stats_mask,
612 .open = simple_open,
613 .owner = THIS_MODULE,
614 .llseek = default_llseek,
615};
616
617int ath10k_debug_start(struct ath10k *ar)
618{
619 int ret;
620
621 ret = ath10k_debug_htt_stats_req(ar);
622 if (ret)
623 /* continue normally anyway, this isn't serious */
624 ath10k_warn("failed to start htt stats workqueue: %d\n", ret);
625
626 return 0;
627}
628
629void ath10k_debug_stop(struct ath10k *ar)
630{
631 cancel_delayed_work_sync(&ar->debug.htt_stats_dwork);
632}
633
502int ath10k_debug_create(struct ath10k *ar) 634int ath10k_debug_create(struct ath10k *ar)
503{ 635{
504 ar->debug.debugfs_phy = debugfs_create_dir("ath10k", 636 ar->debug.debugfs_phy = debugfs_create_dir("ath10k",
@@ -507,6 +639,9 @@ int ath10k_debug_create(struct ath10k *ar)
507 if (!ar->debug.debugfs_phy) 639 if (!ar->debug.debugfs_phy)
508 return -ENOMEM; 640 return -ENOMEM;
509 641
642 INIT_DELAYED_WORK(&ar->debug.htt_stats_dwork,
643 ath10k_debug_htt_stats_dwork);
644
510 init_completion(&ar->debug.event_stats_compl); 645 init_completion(&ar->debug.event_stats_compl);
511 646
512 debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar, 647 debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar,
@@ -518,8 +653,15 @@ int ath10k_debug_create(struct ath10k *ar)
518 debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy, 653 debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy,
519 ar, &fops_simulate_fw_crash); 654 ar, &fops_simulate_fw_crash);
520 655
656 debugfs_create_file("chip_id", S_IRUSR, ar->debug.debugfs_phy,
657 ar, &fops_chip_id);
658
659 debugfs_create_file("htt_stats_mask", S_IRUSR, ar->debug.debugfs_phy,
660 ar, &fops_htt_stats_mask);
661
521 return 0; 662 return 0;
522} 663}
664
523#endif /* CONFIG_ATH10K_DEBUGFS */ 665#endif /* CONFIG_ATH10K_DEBUGFS */
524 666
525#ifdef CONFIG_ATH10K_DEBUG 667#ifdef CONFIG_ATH10K_DEBUG
diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h
index 168140c54028..fa581486626f 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -27,11 +27,12 @@ enum ath10k_debug_mask {
27 ATH10K_DBG_HTC = 0x00000004, 27 ATH10K_DBG_HTC = 0x00000004,
28 ATH10K_DBG_HTT = 0x00000008, 28 ATH10K_DBG_HTT = 0x00000008,
29 ATH10K_DBG_MAC = 0x00000010, 29 ATH10K_DBG_MAC = 0x00000010,
30 ATH10K_DBG_CORE = 0x00000020, 30 ATH10K_DBG_BOOT = 0x00000020,
31 ATH10K_DBG_PCI_DUMP = 0x00000040, 31 ATH10K_DBG_PCI_DUMP = 0x00000040,
32 ATH10K_DBG_HTT_DUMP = 0x00000080, 32 ATH10K_DBG_HTT_DUMP = 0x00000080,
33 ATH10K_DBG_MGMT = 0x00000100, 33 ATH10K_DBG_MGMT = 0x00000100,
34 ATH10K_DBG_DATA = 0x00000200, 34 ATH10K_DBG_DATA = 0x00000200,
35 ATH10K_DBG_BMI = 0x00000400,
35 ATH10K_DBG_ANY = 0xffffffff, 36 ATH10K_DBG_ANY = 0xffffffff,
36}; 37};
37 38
@@ -42,6 +43,8 @@ extern __printf(1, 2) int ath10k_err(const char *fmt, ...);
42extern __printf(1, 2) int ath10k_warn(const char *fmt, ...); 43extern __printf(1, 2) int ath10k_warn(const char *fmt, ...);
43 44
44#ifdef CONFIG_ATH10K_DEBUGFS 45#ifdef CONFIG_ATH10K_DEBUGFS
46int ath10k_debug_start(struct ath10k *ar);
47void ath10k_debug_stop(struct ath10k *ar);
45int ath10k_debug_create(struct ath10k *ar); 48int ath10k_debug_create(struct ath10k *ar);
46void ath10k_debug_read_service_map(struct ath10k *ar, 49void ath10k_debug_read_service_map(struct ath10k *ar,
47 void *service_map, 50 void *service_map,
@@ -50,6 +53,15 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
50 struct wmi_stats_event *ev); 53 struct wmi_stats_event *ev);
51 54
52#else 55#else
56static inline int ath10k_debug_start(struct ath10k *ar)
57{
58 return 0;
59}
60
61static inline void ath10k_debug_stop(struct ath10k *ar)
62{
63}
64
53static inline int ath10k_debug_create(struct ath10k *ar) 65static inline int ath10k_debug_create(struct ath10k *ar)
54{ 66{
55 return 0; 67 return 0;
diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
index ef3329ef52f3..3118d7506734 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -103,10 +103,10 @@ static void ath10k_htc_prepare_tx_skb(struct ath10k_htc_ep *ep,
103 struct ath10k_htc_hdr *hdr; 103 struct ath10k_htc_hdr *hdr;
104 104
105 hdr = (struct ath10k_htc_hdr *)skb->data; 105 hdr = (struct ath10k_htc_hdr *)skb->data;
106 memset(hdr, 0, sizeof(*hdr));
107 106
108 hdr->eid = ep->eid; 107 hdr->eid = ep->eid;
109 hdr->len = __cpu_to_le16(skb->len - sizeof(*hdr)); 108 hdr->len = __cpu_to_le16(skb->len - sizeof(*hdr));
109 hdr->flags = 0;
110 110
111 spin_lock_bh(&ep->htc->tx_lock); 111 spin_lock_bh(&ep->htc->tx_lock);
112 hdr->seq_no = ep->seq_no++; 112 hdr->seq_no = ep->seq_no++;
@@ -117,134 +117,13 @@ static void ath10k_htc_prepare_tx_skb(struct ath10k_htc_ep *ep,
117 spin_unlock_bh(&ep->htc->tx_lock); 117 spin_unlock_bh(&ep->htc->tx_lock);
118} 118}
119 119
120static int ath10k_htc_issue_skb(struct ath10k_htc *htc,
121 struct ath10k_htc_ep *ep,
122 struct sk_buff *skb,
123 u8 credits)
124{
125 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
126 int ret;
127
128 ath10k_dbg(ATH10K_DBG_HTC, "%s: ep %d skb %p\n", __func__,
129 ep->eid, skb);
130
131 ath10k_htc_prepare_tx_skb(ep, skb);
132
133 ret = ath10k_skb_map(htc->ar->dev, skb);
134 if (ret)
135 goto err;
136
137 ret = ath10k_hif_send_head(htc->ar,
138 ep->ul_pipe_id,
139 ep->eid,
140 skb->len,
141 skb);
142 if (unlikely(ret))
143 goto err;
144
145 return 0;
146err:
147 ath10k_warn("HTC issue failed: %d\n", ret);
148
149 spin_lock_bh(&htc->tx_lock);
150 ep->tx_credits += credits;
151 spin_unlock_bh(&htc->tx_lock);
152
153 /* this is the simplest way to handle out-of-resources for non-credit
154 * based endpoints. credit based endpoints can still get -ENOSR, but
155 * this is highly unlikely as credit reservation should prevent that */
156 if (ret == -ENOSR) {
157 spin_lock_bh(&htc->tx_lock);
158 __skb_queue_head(&ep->tx_queue, skb);
159 spin_unlock_bh(&htc->tx_lock);
160
161 return ret;
162 }
163
164 skb_cb->is_aborted = true;
165 ath10k_htc_notify_tx_completion(ep, skb);
166
167 return ret;
168}
169
170static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc,
171 struct ath10k_htc_ep *ep,
172 u8 *credits)
173{
174 struct sk_buff *skb;
175 struct ath10k_skb_cb *skb_cb;
176 int credits_required;
177 int remainder;
178 unsigned int transfer_len;
179
180 lockdep_assert_held(&htc->tx_lock);
181
182 skb = __skb_dequeue(&ep->tx_queue);
183 if (!skb)
184 return NULL;
185
186 skb_cb = ATH10K_SKB_CB(skb);
187 transfer_len = skb->len;
188
189 if (likely(transfer_len <= htc->target_credit_size)) {
190 credits_required = 1;
191 } else {
192 /* figure out how many credits this message requires */
193 credits_required = transfer_len / htc->target_credit_size;
194 remainder = transfer_len % htc->target_credit_size;
195
196 if (remainder)
197 credits_required++;
198 }
199
200 ath10k_dbg(ATH10K_DBG_HTC, "Credits required %d got %d\n",
201 credits_required, ep->tx_credits);
202
203 if (ep->tx_credits < credits_required) {
204 __skb_queue_head(&ep->tx_queue, skb);
205 return NULL;
206 }
207
208 ep->tx_credits -= credits_required;
209 *credits = credits_required;
210 return skb;
211}
212
213static void ath10k_htc_send_work(struct work_struct *work)
214{
215 struct ath10k_htc_ep *ep = container_of(work,
216 struct ath10k_htc_ep, send_work);
217 struct ath10k_htc *htc = ep->htc;
218 struct sk_buff *skb;
219 u8 credits = 0;
220 int ret;
221
222 while (true) {
223 if (ep->ul_is_polled)
224 ath10k_htc_send_complete_check(ep, 0);
225
226 spin_lock_bh(&htc->tx_lock);
227 if (ep->tx_credit_flow_enabled)
228 skb = ath10k_htc_get_skb_credit_based(htc, ep,
229 &credits);
230 else
231 skb = __skb_dequeue(&ep->tx_queue);
232 spin_unlock_bh(&htc->tx_lock);
233
234 if (!skb)
235 break;
236
237 ret = ath10k_htc_issue_skb(htc, ep, skb, credits);
238 if (ret == -ENOSR)
239 break;
240 }
241}
242
243int ath10k_htc_send(struct ath10k_htc *htc, 120int ath10k_htc_send(struct ath10k_htc *htc,
244 enum ath10k_htc_ep_id eid, 121 enum ath10k_htc_ep_id eid,
245 struct sk_buff *skb) 122 struct sk_buff *skb)
246{ 123{
247 struct ath10k_htc_ep *ep = &htc->endpoint[eid]; 124 struct ath10k_htc_ep *ep = &htc->endpoint[eid];
125 int credits = 0;
126 int ret;
248 127
249 if (htc->ar->state == ATH10K_STATE_WEDGED) 128 if (htc->ar->state == ATH10K_STATE_WEDGED)
250 return -ECOMM; 129 return -ECOMM;
@@ -254,18 +133,55 @@ int ath10k_htc_send(struct ath10k_htc *htc,
254 return -ENOENT; 133 return -ENOENT;
255 } 134 }
256 135
136 /* FIXME: This looks ugly, can we fix it? */
257 spin_lock_bh(&htc->tx_lock); 137 spin_lock_bh(&htc->tx_lock);
258 if (htc->stopped) { 138 if (htc->stopped) {
259 spin_unlock_bh(&htc->tx_lock); 139 spin_unlock_bh(&htc->tx_lock);
260 return -ESHUTDOWN; 140 return -ESHUTDOWN;
261 } 141 }
142 spin_unlock_bh(&htc->tx_lock);
262 143
263 __skb_queue_tail(&ep->tx_queue, skb);
264 skb_push(skb, sizeof(struct ath10k_htc_hdr)); 144 skb_push(skb, sizeof(struct ath10k_htc_hdr));
265 spin_unlock_bh(&htc->tx_lock);
266 145
267 queue_work(htc->ar->workqueue, &ep->send_work); 146 if (ep->tx_credit_flow_enabled) {
147 credits = DIV_ROUND_UP(skb->len, htc->target_credit_size);
148 spin_lock_bh(&htc->tx_lock);
149 if (ep->tx_credits < credits) {
150 spin_unlock_bh(&htc->tx_lock);
151 ret = -EAGAIN;
152 goto err_pull;
153 }
154 ep->tx_credits -= credits;
155 spin_unlock_bh(&htc->tx_lock);
156 }
157
158 ath10k_htc_prepare_tx_skb(ep, skb);
159
160 ret = ath10k_skb_map(htc->ar->dev, skb);
161 if (ret)
162 goto err_credits;
163
164 ret = ath10k_hif_send_head(htc->ar, ep->ul_pipe_id, ep->eid,
165 skb->len, skb);
166 if (ret)
167 goto err_unmap;
168
268 return 0; 169 return 0;
170
171err_unmap:
172 ath10k_skb_unmap(htc->ar->dev, skb);
173err_credits:
174 if (ep->tx_credit_flow_enabled) {
175 spin_lock_bh(&htc->tx_lock);
176 ep->tx_credits += credits;
177 spin_unlock_bh(&htc->tx_lock);
178
179 if (ep->ep_ops.ep_tx_credits)
180 ep->ep_ops.ep_tx_credits(htc->ar);
181 }
182err_pull:
183 skb_pull(skb, sizeof(struct ath10k_htc_hdr));
184 return ret;
269} 185}
270 186
271static int ath10k_htc_tx_completion_handler(struct ath10k *ar, 187static int ath10k_htc_tx_completion_handler(struct ath10k *ar,
@@ -278,39 +194,9 @@ static int ath10k_htc_tx_completion_handler(struct ath10k *ar,
278 ath10k_htc_notify_tx_completion(ep, skb); 194 ath10k_htc_notify_tx_completion(ep, skb);
279 /* the skb now belongs to the completion handler */ 195 /* the skb now belongs to the completion handler */
280 196
281 /* note: when using TX credit flow, the re-checking of queues happens
282 * when credits flow back from the target. in the non-TX credit case,
283 * we recheck after the packet completes */
284 spin_lock_bh(&htc->tx_lock);
285 if (!ep->tx_credit_flow_enabled && !htc->stopped)
286 queue_work(ar->workqueue, &ep->send_work);
287 spin_unlock_bh(&htc->tx_lock);
288
289 return 0; 197 return 0;
290} 198}
291 199
292/* flush endpoint TX queue */
293static void ath10k_htc_flush_endpoint_tx(struct ath10k_htc *htc,
294 struct ath10k_htc_ep *ep)
295{
296 struct sk_buff *skb;
297 struct ath10k_skb_cb *skb_cb;
298
299 spin_lock_bh(&htc->tx_lock);
300 for (;;) {
301 skb = __skb_dequeue(&ep->tx_queue);
302 if (!skb)
303 break;
304
305 skb_cb = ATH10K_SKB_CB(skb);
306 skb_cb->is_aborted = true;
307 ath10k_htc_notify_tx_completion(ep, skb);
308 }
309 spin_unlock_bh(&htc->tx_lock);
310
311 cancel_work_sync(&ep->send_work);
312}
313
314/***********/ 200/***********/
315/* Receive */ 201/* Receive */
316/***********/ 202/***********/
@@ -340,8 +226,11 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc,
340 ep = &htc->endpoint[report->eid]; 226 ep = &htc->endpoint[report->eid];
341 ep->tx_credits += report->credits; 227 ep->tx_credits += report->credits;
342 228
343 if (ep->tx_credits && !skb_queue_empty(&ep->tx_queue)) 229 if (ep->ep_ops.ep_tx_credits) {
344 queue_work(htc->ar->workqueue, &ep->send_work); 230 spin_unlock_bh(&htc->tx_lock);
231 ep->ep_ops.ep_tx_credits(htc->ar);
232 spin_lock_bh(&htc->tx_lock);
233 }
345 } 234 }
346 spin_unlock_bh(&htc->tx_lock); 235 spin_unlock_bh(&htc->tx_lock);
347} 236}
@@ -599,10 +488,8 @@ static void ath10k_htc_reset_endpoint_states(struct ath10k_htc *htc)
599 ep->max_ep_message_len = 0; 488 ep->max_ep_message_len = 0;
600 ep->max_tx_queue_depth = 0; 489 ep->max_tx_queue_depth = 0;
601 ep->eid = i; 490 ep->eid = i;
602 skb_queue_head_init(&ep->tx_queue);
603 ep->htc = htc; 491 ep->htc = htc;
604 ep->tx_credit_flow_enabled = true; 492 ep->tx_credit_flow_enabled = true;
605 INIT_WORK(&ep->send_work, ath10k_htc_send_work);
606 } 493 }
607} 494}
608 495
@@ -752,8 +639,8 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc,
752 tx_alloc = ath10k_htc_get_credit_allocation(htc, 639 tx_alloc = ath10k_htc_get_credit_allocation(htc,
753 conn_req->service_id); 640 conn_req->service_id);
754 if (!tx_alloc) 641 if (!tx_alloc)
755 ath10k_dbg(ATH10K_DBG_HTC, 642 ath10k_dbg(ATH10K_DBG_BOOT,
756 "HTC Service %s does not allocate target credits\n", 643 "boot htc service %s does not allocate target credits\n",
757 htc_service_name(conn_req->service_id)); 644 htc_service_name(conn_req->service_id));
758 645
759 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar); 646 skb = ath10k_htc_build_tx_ctrl_skb(htc->ar);
@@ -772,16 +659,16 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc,
772 659
773 flags |= SM(tx_alloc, ATH10K_HTC_CONN_FLAGS_RECV_ALLOC); 660 flags |= SM(tx_alloc, ATH10K_HTC_CONN_FLAGS_RECV_ALLOC);
774 661
775 req_msg = &msg->connect_service;
776 req_msg->flags = __cpu_to_le16(flags);
777 req_msg->service_id = __cpu_to_le16(conn_req->service_id);
778
779 /* Only enable credit flow control for WMI ctrl service */ 662 /* Only enable credit flow control for WMI ctrl service */
780 if (conn_req->service_id != ATH10K_HTC_SVC_ID_WMI_CONTROL) { 663 if (conn_req->service_id != ATH10K_HTC_SVC_ID_WMI_CONTROL) {
781 flags |= ATH10K_HTC_CONN_FLAGS_DISABLE_CREDIT_FLOW_CTRL; 664 flags |= ATH10K_HTC_CONN_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
782 disable_credit_flow_ctrl = true; 665 disable_credit_flow_ctrl = true;
783 } 666 }
784 667
668 req_msg = &msg->connect_service;
669 req_msg->flags = __cpu_to_le16(flags);
670 req_msg->service_id = __cpu_to_le16(conn_req->service_id);
671
785 INIT_COMPLETION(htc->ctl_resp); 672 INIT_COMPLETION(htc->ctl_resp);
786 673
787 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb); 674 status = ath10k_htc_send(htc, ATH10K_HTC_EP_0, skb);
@@ -873,19 +760,19 @@ setup:
873 if (status) 760 if (status)
874 return status; 761 return status;
875 762
876 ath10k_dbg(ATH10K_DBG_HTC, 763 ath10k_dbg(ATH10K_DBG_BOOT,
877 "HTC service: %s UL pipe: %d DL pipe: %d eid: %d ready\n", 764 "boot htc service '%s' ul pipe %d dl pipe %d eid %d ready\n",
878 htc_service_name(ep->service_id), ep->ul_pipe_id, 765 htc_service_name(ep->service_id), ep->ul_pipe_id,
879 ep->dl_pipe_id, ep->eid); 766 ep->dl_pipe_id, ep->eid);
880 767
881 ath10k_dbg(ATH10K_DBG_HTC, 768 ath10k_dbg(ATH10K_DBG_BOOT,
882 "EP %d UL polled: %d, DL polled: %d\n", 769 "boot htc ep %d ul polled %d dl polled %d\n",
883 ep->eid, ep->ul_is_polled, ep->dl_is_polled); 770 ep->eid, ep->ul_is_polled, ep->dl_is_polled);
884 771
885 if (disable_credit_flow_ctrl && ep->tx_credit_flow_enabled) { 772 if (disable_credit_flow_ctrl && ep->tx_credit_flow_enabled) {
886 ep->tx_credit_flow_enabled = false; 773 ep->tx_credit_flow_enabled = false;
887 ath10k_dbg(ATH10K_DBG_HTC, 774 ath10k_dbg(ATH10K_DBG_BOOT,
888 "HTC service: %s eid: %d TX flow control disabled\n", 775 "boot htc service '%s' eid %d TX flow control disabled\n",
889 htc_service_name(ep->service_id), assigned_eid); 776 htc_service_name(ep->service_id), assigned_eid);
890 } 777 }
891 778
@@ -945,18 +832,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
945 */ 832 */
946void ath10k_htc_stop(struct ath10k_htc *htc) 833void ath10k_htc_stop(struct ath10k_htc *htc)
947{ 834{
948 int i;
949 struct ath10k_htc_ep *ep;
950
951 spin_lock_bh(&htc->tx_lock); 835 spin_lock_bh(&htc->tx_lock);
952 htc->stopped = true; 836 htc->stopped = true;
953 spin_unlock_bh(&htc->tx_lock); 837 spin_unlock_bh(&htc->tx_lock);
954 838
955 for (i = ATH10K_HTC_EP_0; i < ATH10K_HTC_EP_COUNT; i++) {
956 ep = &htc->endpoint[i];
957 ath10k_htc_flush_endpoint_tx(htc, ep);
958 }
959
960 ath10k_hif_stop(htc->ar); 839 ath10k_hif_stop(htc->ar);
961} 840}
962 841
diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
index e1dd8c761853..4716d331e6b6 100644
--- a/drivers/net/wireless/ath/ath10k/htc.h
+++ b/drivers/net/wireless/ath/ath10k/htc.h
@@ -276,6 +276,7 @@ struct ath10k_htc_ops {
276struct ath10k_htc_ep_ops { 276struct ath10k_htc_ep_ops {
277 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *); 277 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
278 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *); 278 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
279 void (*ep_tx_credits)(struct ath10k *);
279}; 280};
280 281
281/* service connection information */ 282/* service connection information */
@@ -315,15 +316,11 @@ struct ath10k_htc_ep {
315 int ul_is_polled; /* call HIF to get tx completions */ 316 int ul_is_polled; /* call HIF to get tx completions */
316 int dl_is_polled; /* call HIF to fetch rx (not implemented) */ 317 int dl_is_polled; /* call HIF to fetch rx (not implemented) */
317 318
318 struct sk_buff_head tx_queue;
319
320 u8 seq_no; /* for debugging */ 319 u8 seq_no; /* for debugging */
321 int tx_credits; 320 int tx_credits;
322 int tx_credit_size; 321 int tx_credit_size;
323 int tx_credits_per_max_message; 322 int tx_credits_per_max_message;
324 bool tx_credit_flow_enabled; 323 bool tx_credit_flow_enabled;
325
326 struct work_struct send_work;
327}; 324};
328 325
329struct ath10k_htc_svc_tx_credits { 326struct ath10k_htc_svc_tx_credits {
diff --git a/drivers/net/wireless/ath/ath10k/htt.c b/drivers/net/wireless/ath/ath10k/htt.c
index 39342c5cfcb2..5f7eeebc5432 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -104,21 +104,16 @@ err_htc_attach:
104 104
105static int ath10k_htt_verify_version(struct ath10k_htt *htt) 105static int ath10k_htt_verify_version(struct ath10k_htt *htt)
106{ 106{
107 ath10k_dbg(ATH10K_DBG_HTT, 107 ath10k_info("htt target version %d.%d\n",
108 "htt target version %d.%d; host version %d.%d\n", 108 htt->target_version_major, htt->target_version_minor);
109 htt->target_version_major, 109
110 htt->target_version_minor, 110 if (htt->target_version_major != 2 &&
111 HTT_CURRENT_VERSION_MAJOR, 111 htt->target_version_major != 3) {
112 HTT_CURRENT_VERSION_MINOR); 112 ath10k_err("unsupported htt major version %d. supported versions are 2 and 3\n",
113 113 htt->target_version_major);
114 if (htt->target_version_major != HTT_CURRENT_VERSION_MAJOR) {
115 ath10k_err("htt major versions are incompatible!\n");
116 return -ENOTSUPP; 114 return -ENOTSUPP;
117 } 115 }
118 116
119 if (htt->target_version_minor != HTT_CURRENT_VERSION_MINOR)
120 ath10k_warn("htt minor version differ but still compatible\n");
121
122 return 0; 117 return 0;
123} 118}
124 119
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h
index 318be4629cde..1a337e93b7e9 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -19,13 +19,11 @@
19#define _HTT_H_ 19#define _HTT_H_
20 20
21#include <linux/bug.h> 21#include <linux/bug.h>
22#include <linux/interrupt.h>
22 23
23#include "htc.h" 24#include "htc.h"
24#include "rx_desc.h" 25#include "rx_desc.h"
25 26
26#define HTT_CURRENT_VERSION_MAJOR 2
27#define HTT_CURRENT_VERSION_MINOR 1
28
29enum htt_dbg_stats_type { 27enum htt_dbg_stats_type {
30 HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0, 28 HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
31 HTT_DBG_STATS_RX_REORDER = 1 << 1, 29 HTT_DBG_STATS_RX_REORDER = 1 << 1,
@@ -45,6 +43,9 @@ enum htt_h2t_msg_type { /* host-to-target */
45 HTT_H2T_MSG_TYPE_SYNC = 4, 43 HTT_H2T_MSG_TYPE_SYNC = 4,
46 HTT_H2T_MSG_TYPE_AGGR_CFG = 5, 44 HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
47 HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6, 45 HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
46
47 /* This command is used for sending management frames in HTT < 3.0.
48 * HTT >= 3.0 uses TX_FRM for everything. */
48 HTT_H2T_MSG_TYPE_MGMT_TX = 7, 49 HTT_H2T_MSG_TYPE_MGMT_TX = 7,
49 50
50 HTT_H2T_NUM_MSGS /* keep this last */ 51 HTT_H2T_NUM_MSGS /* keep this last */
@@ -1268,6 +1269,7 @@ struct ath10k_htt {
1268 /* set if host-fw communication goes haywire 1269 /* set if host-fw communication goes haywire
1269 * used to avoid further failures */ 1270 * used to avoid further failures */
1270 bool rx_confused; 1271 bool rx_confused;
1272 struct tasklet_struct rx_replenish_task;
1271}; 1273};
1272 1274
1273#define RX_HTT_HDR_STATUS_LEN 64 1275#define RX_HTT_HDR_STATUS_LEN 64
@@ -1308,6 +1310,10 @@ struct htt_rx_desc {
1308#define HTT_RX_BUF_SIZE 1920 1310#define HTT_RX_BUF_SIZE 1920
1309#define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc)) 1311#define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
1310 1312
1313/* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
1314 * aggregated traffic more nicely. */
1315#define ATH10K_HTT_MAX_NUM_REFILL 16
1316
1311/* 1317/*
1312 * DMA_MAP expects the buffer to be an integral number of cache lines. 1318 * DMA_MAP expects the buffer to be an integral number of cache lines.
1313 * Rather than checking the actual cache line size, this code makes a 1319 * Rather than checking the actual cache line size, this code makes a
@@ -1327,6 +1333,7 @@ void ath10k_htt_rx_detach(struct ath10k_htt *htt);
1327void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb); 1333void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
1328void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb); 1334void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
1329int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt); 1335int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
1336int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
1330int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt); 1337int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
1331 1338
1332void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt); 1339void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index e784c40b904b..90d4f74c28d7 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -20,6 +20,7 @@
20#include "htt.h" 20#include "htt.h"
21#include "txrx.h" 21#include "txrx.h"
22#include "debug.h" 22#include "debug.h"
23#include "trace.h"
23 24
24#include <linux/log2.h> 25#include <linux/log2.h>
25 26
@@ -40,6 +41,10 @@
40/* when under memory pressure rx ring refill may fail and needs a retry */ 41/* when under memory pressure rx ring refill may fail and needs a retry */
41#define HTT_RX_RING_REFILL_RETRY_MS 50 42#define HTT_RX_RING_REFILL_RETRY_MS 50
42 43
44
45static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb);
46
47
43static int ath10k_htt_rx_ring_size(struct ath10k_htt *htt) 48static int ath10k_htt_rx_ring_size(struct ath10k_htt *htt)
44{ 49{
45 int size; 50 int size;
@@ -177,10 +182,27 @@ static int ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)
177 182
178static void ath10k_htt_rx_msdu_buff_replenish(struct ath10k_htt *htt) 183static void ath10k_htt_rx_msdu_buff_replenish(struct ath10k_htt *htt)
179{ 184{
180 int ret, num_to_fill; 185 int ret, num_deficit, num_to_fill;
181 186
187 /* Refilling the whole RX ring buffer proves to be a bad idea. The
188 * reason is RX may take up significant amount of CPU cycles and starve
189 * other tasks, e.g. TX on an ethernet device while acting as a bridge
190 * with ath10k wlan interface. This ended up with very poor performance
191 * once CPU the host system was overwhelmed with RX on ath10k.
192 *
193 * By limiting the number of refills the replenishing occurs
194 * progressively. This in turns makes use of the fact tasklets are
195 * processed in FIFO order. This means actual RX processing can starve
196 * out refilling. If there's not enough buffers on RX ring FW will not
197 * report RX until it is refilled with enough buffers. This
198 * automatically balances load wrt to CPU power.
199 *
200 * This probably comes at a cost of lower maximum throughput but
201 * improves the avarage and stability. */
182 spin_lock_bh(&htt->rx_ring.lock); 202 spin_lock_bh(&htt->rx_ring.lock);
183 num_to_fill = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt; 203 num_deficit = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt;
204 num_to_fill = min(ATH10K_HTT_MAX_NUM_REFILL, num_deficit);
205 num_deficit -= num_to_fill;
184 ret = ath10k_htt_rx_ring_fill_n(htt, num_to_fill); 206 ret = ath10k_htt_rx_ring_fill_n(htt, num_to_fill);
185 if (ret == -ENOMEM) { 207 if (ret == -ENOMEM) {
186 /* 208 /*
@@ -191,6 +213,8 @@ static void ath10k_htt_rx_msdu_buff_replenish(struct ath10k_htt *htt)
191 */ 213 */
192 mod_timer(&htt->rx_ring.refill_retry_timer, jiffies + 214 mod_timer(&htt->rx_ring.refill_retry_timer, jiffies +
193 msecs_to_jiffies(HTT_RX_RING_REFILL_RETRY_MS)); 215 msecs_to_jiffies(HTT_RX_RING_REFILL_RETRY_MS));
216 } else if (num_deficit > 0) {
217 tasklet_schedule(&htt->rx_replenish_task);
194 } 218 }
195 spin_unlock_bh(&htt->rx_ring.lock); 219 spin_unlock_bh(&htt->rx_ring.lock);
196} 220}
@@ -212,6 +236,7 @@ void ath10k_htt_rx_detach(struct ath10k_htt *htt)
212 int sw_rd_idx = htt->rx_ring.sw_rd_idx.msdu_payld; 236 int sw_rd_idx = htt->rx_ring.sw_rd_idx.msdu_payld;
213 237
214 del_timer_sync(&htt->rx_ring.refill_retry_timer); 238 del_timer_sync(&htt->rx_ring.refill_retry_timer);
239 tasklet_kill(&htt->rx_replenish_task);
215 240
216 while (sw_rd_idx != __le32_to_cpu(*(htt->rx_ring.alloc_idx.vaddr))) { 241 while (sw_rd_idx != __le32_to_cpu(*(htt->rx_ring.alloc_idx.vaddr))) {
217 struct sk_buff *skb = 242 struct sk_buff *skb =
@@ -441,6 +466,12 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
441 return msdu_chaining; 466 return msdu_chaining;
442} 467}
443 468
469static void ath10k_htt_rx_replenish_task(unsigned long ptr)
470{
471 struct ath10k_htt *htt = (struct ath10k_htt *)ptr;
472 ath10k_htt_rx_msdu_buff_replenish(htt);
473}
474
444int ath10k_htt_rx_attach(struct ath10k_htt *htt) 475int ath10k_htt_rx_attach(struct ath10k_htt *htt)
445{ 476{
446 dma_addr_t paddr; 477 dma_addr_t paddr;
@@ -501,7 +532,10 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)
501 if (__ath10k_htt_rx_ring_fill_n(htt, htt->rx_ring.fill_level)) 532 if (__ath10k_htt_rx_ring_fill_n(htt, htt->rx_ring.fill_level))
502 goto err_fill_ring; 533 goto err_fill_ring;
503 534
504 ath10k_dbg(ATH10K_DBG_HTT, "HTT RX ring size: %d, fill_level: %d\n", 535 tasklet_init(&htt->rx_replenish_task, ath10k_htt_rx_replenish_task,
536 (unsigned long)htt);
537
538 ath10k_dbg(ATH10K_DBG_BOOT, "htt rx ring size %d fill_level %d\n",
505 htt->rx_ring.size, htt->rx_ring.fill_level); 539 htt->rx_ring.size, htt->rx_ring.fill_level);
506 return 0; 540 return 0;
507 541
@@ -590,134 +624,144 @@ static bool ath10k_htt_rx_hdr_is_amsdu(struct ieee80211_hdr *hdr)
590 return false; 624 return false;
591} 625}
592 626
593static int ath10k_htt_rx_amsdu(struct ath10k_htt *htt, 627struct rfc1042_hdr {
594 struct htt_rx_info *info) 628 u8 llc_dsap;
629 u8 llc_ssap;
630 u8 llc_ctrl;
631 u8 snap_oui[3];
632 __be16 snap_type;
633} __packed;
634
635struct amsdu_subframe_hdr {
636 u8 dst[ETH_ALEN];
637 u8 src[ETH_ALEN];
638 __be16 len;
639} __packed;
640
641static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt,
642 struct htt_rx_info *info)
595{ 643{
596 struct htt_rx_desc *rxd; 644 struct htt_rx_desc *rxd;
597 struct sk_buff *amsdu;
598 struct sk_buff *first; 645 struct sk_buff *first;
599 struct ieee80211_hdr *hdr;
600 struct sk_buff *skb = info->skb; 646 struct sk_buff *skb = info->skb;
601 enum rx_msdu_decap_format fmt; 647 enum rx_msdu_decap_format fmt;
602 enum htt_rx_mpdu_encrypt_type enctype; 648 enum htt_rx_mpdu_encrypt_type enctype;
649 struct ieee80211_hdr *hdr;
650 u8 hdr_buf[64], addr[ETH_ALEN], *qos;
603 unsigned int hdr_len; 651 unsigned int hdr_len;
604 int crypto_len;
605 652
606 rxd = (void *)skb->data - sizeof(*rxd); 653 rxd = (void *)skb->data - sizeof(*rxd);
607 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1),
608 RX_MSDU_START_INFO1_DECAP_FORMAT);
609 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0), 654 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
610 RX_MPDU_START_INFO0_ENCRYPT_TYPE); 655 RX_MPDU_START_INFO0_ENCRYPT_TYPE);
611 656
612 /* FIXME: No idea what assumptions are safe here. Need logs */ 657 hdr = (struct ieee80211_hdr *)rxd->rx_hdr_status;
613 if ((fmt == RX_MSDU_DECAP_RAW && skb->next) || 658 hdr_len = ieee80211_hdrlen(hdr->frame_control);
614 (fmt == RX_MSDU_DECAP_8023_SNAP_LLC)) { 659 memcpy(hdr_buf, hdr, hdr_len);
615 ath10k_htt_rx_free_msdu_chain(skb->next); 660 hdr = (struct ieee80211_hdr *)hdr_buf;
616 skb->next = NULL;
617 return -ENOTSUPP;
618 }
619 661
620 /* A-MSDU max is a little less than 8K */ 662 /* FIXME: Hopefully this is a temporary measure.
621 amsdu = dev_alloc_skb(8*1024); 663 *
622 if (!amsdu) { 664 * Reporting individual A-MSDU subframes means each reported frame
623 ath10k_warn("A-MSDU allocation failed\n"); 665 * shares the same sequence number.
624 ath10k_htt_rx_free_msdu_chain(skb->next); 666 *
625 skb->next = NULL; 667 * mac80211 drops frames it recognizes as duplicates, i.e.
626 return -ENOMEM; 668 * retransmission flag is set and sequence number matches sequence
627 } 669 * number from a previous frame (as per IEEE 802.11-2012: 9.3.2.10
628 670 * "Duplicate detection and recovery")
629 if (fmt >= RX_MSDU_DECAP_NATIVE_WIFI) { 671 *
630 int hdrlen; 672 * To avoid frames being dropped clear retransmission flag for all
631 673 * received A-MSDUs.
632 hdr = (void *)rxd->rx_hdr_status; 674 *
633 hdrlen = ieee80211_hdrlen(hdr->frame_control); 675 * Worst case: actual duplicate frames will be reported but this should
634 memcpy(skb_put(amsdu, hdrlen), hdr, hdrlen); 676 * still be handled gracefully by other OSI/ISO layers. */
635 } 677 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_RETRY);
636 678
637 first = skb; 679 first = skb;
638 while (skb) { 680 while (skb) {
639 void *decap_hdr; 681 void *decap_hdr;
640 int decap_len = 0; 682 int len;
641 683
642 rxd = (void *)skb->data - sizeof(*rxd); 684 rxd = (void *)skb->data - sizeof(*rxd);
643 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1), 685 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1),
644 RX_MSDU_START_INFO1_DECAP_FORMAT); 686 RX_MSDU_START_INFO1_DECAP_FORMAT);
645 decap_hdr = (void *)rxd->rx_hdr_status; 687 decap_hdr = (void *)rxd->rx_hdr_status;
646 688
647 if (skb == first) { 689 skb->ip_summed = ath10k_htt_rx_get_csum_state(skb);
648 /* We receive linked A-MSDU subframe skbuffs. The
649 * first one contains the original 802.11 header (and
650 * possible crypto param) in the RX descriptor. The
651 * A-MSDU subframe header follows that. Each part is
652 * aligned to 4 byte boundary. */
653
654 hdr = (void *)amsdu->data;
655 hdr_len = ieee80211_hdrlen(hdr->frame_control);
656 crypto_len = ath10k_htt_rx_crypto_param_len(enctype);
657
658 decap_hdr += roundup(hdr_len, 4);
659 decap_hdr += roundup(crypto_len, 4);
660 }
661 690
662 if (fmt == RX_MSDU_DECAP_ETHERNET2_DIX) { 691 /* First frame in an A-MSDU chain has more decapped data. */
663 /* Ethernet2 decap inserts ethernet header in place of 692 if (skb == first) {
664 * A-MSDU subframe header. */ 693 len = round_up(ieee80211_hdrlen(hdr->frame_control), 4);
665 skb_pull(skb, 6 + 6 + 2); 694 len += round_up(ath10k_htt_rx_crypto_param_len(enctype),
666 695 4);
667 /* A-MSDU subframe header length */ 696 decap_hdr += len;
668 decap_len += 6 + 6 + 2;
669
670 /* Ethernet2 decap also strips the LLC/SNAP so we need
671 * to re-insert it. The LLC/SNAP follows A-MSDU
672 * subframe header. */
673 /* FIXME: Not all LLCs are 8 bytes long */
674 decap_len += 8;
675
676 memcpy(skb_put(amsdu, decap_len), decap_hdr, decap_len);
677 } 697 }
678 698
679 if (fmt == RX_MSDU_DECAP_NATIVE_WIFI) { 699 switch (fmt) {
680 /* Native Wifi decap inserts regular 802.11 header 700 case RX_MSDU_DECAP_RAW:
681 * in place of A-MSDU subframe header. */ 701 /* remove trailing FCS */
702 skb_trim(skb, skb->len - FCS_LEN);
703 break;
704 case RX_MSDU_DECAP_NATIVE_WIFI:
705 /* pull decapped header and copy DA */
682 hdr = (struct ieee80211_hdr *)skb->data; 706 hdr = (struct ieee80211_hdr *)skb->data;
683 skb_pull(skb, ieee80211_hdrlen(hdr->frame_control)); 707 hdr_len = ieee80211_hdrlen(hdr->frame_control);
708 memcpy(addr, ieee80211_get_DA(hdr), ETH_ALEN);
709 skb_pull(skb, hdr_len);
684 710
685 /* A-MSDU subframe header length */ 711 /* push original 802.11 header */
686 decap_len += 6 + 6 + 2; 712 hdr = (struct ieee80211_hdr *)hdr_buf;
713 hdr_len = ieee80211_hdrlen(hdr->frame_control);
714 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
687 715
688 memcpy(skb_put(amsdu, decap_len), decap_hdr, decap_len); 716 /* original A-MSDU header has the bit set but we're
689 } 717 * not including A-MSDU subframe header */
718 hdr = (struct ieee80211_hdr *)skb->data;
719 qos = ieee80211_get_qos_ctl(hdr);
720 qos[0] &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
690 721
691 if (fmt == RX_MSDU_DECAP_RAW) 722 /* original 802.11 header has a different DA */
692 skb_trim(skb, skb->len - 4); /* remove FCS */ 723 memcpy(ieee80211_get_DA(hdr), addr, ETH_ALEN);
724 break;
725 case RX_MSDU_DECAP_ETHERNET2_DIX:
726 /* strip ethernet header and insert decapped 802.11
727 * header, amsdu subframe header and rfc1042 header */
693 728
694 memcpy(skb_put(amsdu, skb->len), skb->data, skb->len); 729 len = 0;
730 len += sizeof(struct rfc1042_hdr);
731 len += sizeof(struct amsdu_subframe_hdr);
695 732
696 /* A-MSDU subframes are padded to 4bytes 733 skb_pull(skb, sizeof(struct ethhdr));
697 * but relative to first subframe, not the whole MPDU */ 734 memcpy(skb_push(skb, len), decap_hdr, len);
698 if (skb->next && ((decap_len + skb->len) & 3)) { 735 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
699 int padlen = 4 - ((decap_len + skb->len) & 3); 736 break;
700 memset(skb_put(amsdu, padlen), 0, padlen); 737 case RX_MSDU_DECAP_8023_SNAP_LLC:
738 /* insert decapped 802.11 header making a singly
739 * A-MSDU */
740 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
741 break;
701 } 742 }
702 743
744 info->skb = skb;
745 info->encrypt_type = enctype;
703 skb = skb->next; 746 skb = skb->next;
704 } 747 info->skb->next = NULL;
705 748
706 info->skb = amsdu; 749 ath10k_process_rx(htt->ar, info);
707 info->encrypt_type = enctype; 750 }
708
709 ath10k_htt_rx_free_msdu_chain(first);
710 751
711 return 0; 752 /* FIXME: It might be nice to re-assemble the A-MSDU when there's a
753 * monitor interface active for sniffing purposes. */
712} 754}
713 755
714static int ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info) 756static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
715{ 757{
716 struct sk_buff *skb = info->skb; 758 struct sk_buff *skb = info->skb;
717 struct htt_rx_desc *rxd; 759 struct htt_rx_desc *rxd;
718 struct ieee80211_hdr *hdr; 760 struct ieee80211_hdr *hdr;
719 enum rx_msdu_decap_format fmt; 761 enum rx_msdu_decap_format fmt;
720 enum htt_rx_mpdu_encrypt_type enctype; 762 enum htt_rx_mpdu_encrypt_type enctype;
763 int hdr_len;
764 void *rfc1042;
721 765
722 /* This shouldn't happen. If it does than it may be a FW bug. */ 766 /* This shouldn't happen. If it does than it may be a FW bug. */
723 if (skb->next) { 767 if (skb->next) {
@@ -731,49 +775,53 @@ static int ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
731 RX_MSDU_START_INFO1_DECAP_FORMAT); 775 RX_MSDU_START_INFO1_DECAP_FORMAT);
732 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0), 776 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
733 RX_MPDU_START_INFO0_ENCRYPT_TYPE); 777 RX_MPDU_START_INFO0_ENCRYPT_TYPE);
734 hdr = (void *)skb->data - RX_HTT_HDR_STATUS_LEN; 778 hdr = (struct ieee80211_hdr *)rxd->rx_hdr_status;
779 hdr_len = ieee80211_hdrlen(hdr->frame_control);
780
781 skb->ip_summed = ath10k_htt_rx_get_csum_state(skb);
735 782
736 switch (fmt) { 783 switch (fmt) {
737 case RX_MSDU_DECAP_RAW: 784 case RX_MSDU_DECAP_RAW:
738 /* remove trailing FCS */ 785 /* remove trailing FCS */
739 skb_trim(skb, skb->len - 4); 786 skb_trim(skb, skb->len - FCS_LEN);
740 break; 787 break;
741 case RX_MSDU_DECAP_NATIVE_WIFI: 788 case RX_MSDU_DECAP_NATIVE_WIFI:
742 /* nothing to do here */ 789 /* Pull decapped header */
790 hdr = (struct ieee80211_hdr *)skb->data;
791 hdr_len = ieee80211_hdrlen(hdr->frame_control);
792 skb_pull(skb, hdr_len);
793
794 /* Push original header */
795 hdr = (struct ieee80211_hdr *)rxd->rx_hdr_status;
796 hdr_len = ieee80211_hdrlen(hdr->frame_control);
797 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
743 break; 798 break;
744 case RX_MSDU_DECAP_ETHERNET2_DIX: 799 case RX_MSDU_DECAP_ETHERNET2_DIX:
745 /* macaddr[6] + macaddr[6] + ethertype[2] */ 800 /* strip ethernet header and insert decapped 802.11 header and
746 skb_pull(skb, 6 + 6 + 2); 801 * rfc1042 header */
747 break;
748 case RX_MSDU_DECAP_8023_SNAP_LLC:
749 /* macaddr[6] + macaddr[6] + len[2] */
750 /* we don't need this for non-A-MSDU */
751 skb_pull(skb, 6 + 6 + 2);
752 break;
753 }
754 802
755 if (fmt == RX_MSDU_DECAP_ETHERNET2_DIX) { 803 rfc1042 = hdr;
756 void *llc; 804 rfc1042 += roundup(hdr_len, 4);
757 int llclen; 805 rfc1042 += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4);
758 806
759 llclen = 8; 807 skb_pull(skb, sizeof(struct ethhdr));
760 llc = hdr; 808 memcpy(skb_push(skb, sizeof(struct rfc1042_hdr)),
761 llc += roundup(ieee80211_hdrlen(hdr->frame_control), 4); 809 rfc1042, sizeof(struct rfc1042_hdr));
762 llc += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4); 810 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
763 811 break;
764 skb_push(skb, llclen); 812 case RX_MSDU_DECAP_8023_SNAP_LLC:
765 memcpy(skb->data, llc, llclen); 813 /* remove A-MSDU subframe header and insert
766 } 814 * decapped 802.11 header. rfc1042 header is already there */
767 815
768 if (fmt >= RX_MSDU_DECAP_ETHERNET2_DIX) { 816 skb_pull(skb, sizeof(struct amsdu_subframe_hdr));
769 int len = ieee80211_hdrlen(hdr->frame_control); 817 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
770 skb_push(skb, len); 818 break;
771 memcpy(skb->data, hdr, len);
772 } 819 }
773 820
774 info->skb = skb; 821 info->skb = skb;
775 info->encrypt_type = enctype; 822 info->encrypt_type = enctype;
776 return 0; 823
824 ath10k_process_rx(htt->ar, info);
777} 825}
778 826
779static bool ath10k_htt_rx_has_decrypt_err(struct sk_buff *skb) 827static bool ath10k_htt_rx_has_decrypt_err(struct sk_buff *skb)
@@ -845,8 +893,6 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
845 int fw_desc_len; 893 int fw_desc_len;
846 u8 *fw_desc; 894 u8 *fw_desc;
847 int i, j; 895 int i, j;
848 int ret;
849 int ip_summed;
850 896
851 memset(&info, 0, sizeof(info)); 897 memset(&info, 0, sizeof(info));
852 898
@@ -921,11 +967,6 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
921 continue; 967 continue;
922 } 968 }
923 969
924 /* The skb is not yet processed and it may be
925 * reallocated. Since the offload is in the original
926 * skb extract the checksum now and assign it later */
927 ip_summed = ath10k_htt_rx_get_csum_state(msdu_head);
928
929 info.skb = msdu_head; 970 info.skb = msdu_head;
930 info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head); 971 info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head);
931 info.signal = ATH10K_DEFAULT_NOISE_FLOOR; 972 info.signal = ATH10K_DEFAULT_NOISE_FLOOR;
@@ -938,28 +979,13 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
938 hdr = ath10k_htt_rx_skb_get_hdr(msdu_head); 979 hdr = ath10k_htt_rx_skb_get_hdr(msdu_head);
939 980
940 if (ath10k_htt_rx_hdr_is_amsdu(hdr)) 981 if (ath10k_htt_rx_hdr_is_amsdu(hdr))
941 ret = ath10k_htt_rx_amsdu(htt, &info); 982 ath10k_htt_rx_amsdu(htt, &info);
942 else 983 else
943 ret = ath10k_htt_rx_msdu(htt, &info); 984 ath10k_htt_rx_msdu(htt, &info);
944
945 if (ret && !info.fcs_err) {
946 ath10k_warn("error processing msdus %d\n", ret);
947 dev_kfree_skb_any(info.skb);
948 continue;
949 }
950
951 if (ath10k_htt_rx_hdr_is_amsdu((void *)info.skb->data))
952 ath10k_dbg(ATH10K_DBG_HTT, "htt mpdu is amsdu\n");
953
954 info.skb->ip_summed = ip_summed;
955
956 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt mpdu: ",
957 info.skb->data, info.skb->len);
958 ath10k_process_rx(htt->ar, &info);
959 } 985 }
960 } 986 }
961 987
962 ath10k_htt_rx_msdu_buff_replenish(htt); 988 tasklet_schedule(&htt->rx_replenish_task);
963} 989}
964 990
965static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt, 991static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
@@ -1131,7 +1157,7 @@ void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
1131 break; 1157 break;
1132 } 1158 }
1133 1159
1134 ath10k_txrx_tx_completed(htt, &tx_done); 1160 ath10k_txrx_tx_unref(htt, &tx_done);
1135 break; 1161 break;
1136 } 1162 }
1137 case HTT_T2H_MSG_TYPE_TX_COMPL_IND: { 1163 case HTT_T2H_MSG_TYPE_TX_COMPL_IND: {
@@ -1165,7 +1191,7 @@ void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
1165 for (i = 0; i < resp->data_tx_completion.num_msdus; i++) { 1191 for (i = 0; i < resp->data_tx_completion.num_msdus; i++) {
1166 msdu_id = resp->data_tx_completion.msdus[i]; 1192 msdu_id = resp->data_tx_completion.msdus[i];
1167 tx_done.msdu_id = __le16_to_cpu(msdu_id); 1193 tx_done.msdu_id = __le16_to_cpu(msdu_id);
1168 ath10k_txrx_tx_completed(htt, &tx_done); 1194 ath10k_txrx_tx_unref(htt, &tx_done);
1169 } 1195 }
1170 break; 1196 break;
1171 } 1197 }
@@ -1190,8 +1216,10 @@ void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
1190 case HTT_T2H_MSG_TYPE_TEST: 1216 case HTT_T2H_MSG_TYPE_TEST:
1191 /* FIX THIS */ 1217 /* FIX THIS */
1192 break; 1218 break;
1193 case HTT_T2H_MSG_TYPE_TX_INSPECT_IND:
1194 case HTT_T2H_MSG_TYPE_STATS_CONF: 1219 case HTT_T2H_MSG_TYPE_STATS_CONF:
1220 trace_ath10k_htt_stats(skb->data, skb->len);
1221 break;
1222 case HTT_T2H_MSG_TYPE_TX_INSPECT_IND:
1195 case HTT_T2H_MSG_TYPE_RX_ADDBA: 1223 case HTT_T2H_MSG_TYPE_RX_ADDBA:
1196 case HTT_T2H_MSG_TYPE_RX_DELBA: 1224 case HTT_T2H_MSG_TYPE_RX_DELBA:
1197 case HTT_T2H_MSG_TYPE_RX_FLUSH: 1225 case HTT_T2H_MSG_TYPE_RX_FLUSH:
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 656c2546b294..3b93c6a01c6c 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -96,7 +96,7 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt)
96 htt->max_num_pending_tx = ath10k_hif_get_free_queue_number(htt->ar, 96 htt->max_num_pending_tx = ath10k_hif_get_free_queue_number(htt->ar,
97 pipe); 97 pipe);
98 98
99 ath10k_dbg(ATH10K_DBG_HTT, "htt tx max num pending tx %d\n", 99 ath10k_dbg(ATH10K_DBG_BOOT, "htt tx max num pending tx %d\n",
100 htt->max_num_pending_tx); 100 htt->max_num_pending_tx);
101 101
102 htt->pending_tx = kzalloc(sizeof(*htt->pending_tx) * 102 htt->pending_tx = kzalloc(sizeof(*htt->pending_tx) *
@@ -117,7 +117,7 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt)
117 117
118static void ath10k_htt_tx_cleanup_pending(struct ath10k_htt *htt) 118static void ath10k_htt_tx_cleanup_pending(struct ath10k_htt *htt)
119{ 119{
120 struct sk_buff *txdesc; 120 struct htt_tx_done tx_done = {0};
121 int msdu_id; 121 int msdu_id;
122 122
123 /* No locks needed. Called after communication with the device has 123 /* No locks needed. Called after communication with the device has
@@ -127,18 +127,13 @@ static void ath10k_htt_tx_cleanup_pending(struct ath10k_htt *htt)
127 if (!test_bit(msdu_id, htt->used_msdu_ids)) 127 if (!test_bit(msdu_id, htt->used_msdu_ids))
128 continue; 128 continue;
129 129
130 txdesc = htt->pending_tx[msdu_id];
131 if (!txdesc)
132 continue;
133
134 ath10k_dbg(ATH10K_DBG_HTT, "force cleanup msdu_id %hu\n", 130 ath10k_dbg(ATH10K_DBG_HTT, "force cleanup msdu_id %hu\n",
135 msdu_id); 131 msdu_id);
136 132
137 if (ATH10K_SKB_CB(txdesc)->htt.refcount > 0) 133 tx_done.discard = 1;
138 ATH10K_SKB_CB(txdesc)->htt.refcount = 1; 134 tx_done.msdu_id = msdu_id;
139 135
140 ATH10K_SKB_CB(txdesc)->htt.discard = true; 136 ath10k_txrx_tx_unref(htt, &tx_done);
141 ath10k_txrx_tx_unref(htt, txdesc);
142 } 137 }
143} 138}
144 139
@@ -152,26 +147,7 @@ void ath10k_htt_tx_detach(struct ath10k_htt *htt)
152 147
153void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb) 148void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
154{ 149{
155 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); 150 dev_kfree_skb_any(skb);
156 struct ath10k_htt *htt = &ar->htt;
157
158 if (skb_cb->htt.is_conf) {
159 dev_kfree_skb_any(skb);
160 return;
161 }
162
163 if (skb_cb->is_aborted) {
164 skb_cb->htt.discard = true;
165
166 /* if the skbuff is aborted we need to make sure we'll free up
167 * the tx resources, we can't simply run tx_unref() 2 times
168 * because if htt tx completion came in earlier we'd access
169 * unallocated memory */
170 if (skb_cb->htt.refcount > 1)
171 skb_cb->htt.refcount = 1;
172 }
173
174 ath10k_txrx_tx_unref(htt, skb);
175} 151}
176 152
177int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt) 153int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)
@@ -192,10 +168,48 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)
192 cmd = (struct htt_cmd *)skb->data; 168 cmd = (struct htt_cmd *)skb->data;
193 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_VERSION_REQ; 169 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_VERSION_REQ;
194 170
195 ATH10K_SKB_CB(skb)->htt.is_conf = true; 171 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
172 if (ret) {
173 dev_kfree_skb_any(skb);
174 return ret;
175 }
176
177 return 0;
178}
179
180int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie)
181{
182 struct htt_stats_req *req;
183 struct sk_buff *skb;
184 struct htt_cmd *cmd;
185 int len = 0, ret;
186
187 len += sizeof(cmd->hdr);
188 len += sizeof(cmd->stats_req);
189
190 skb = ath10k_htc_alloc_skb(len);
191 if (!skb)
192 return -ENOMEM;
193
194 skb_put(skb, len);
195 cmd = (struct htt_cmd *)skb->data;
196 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_STATS_REQ;
197
198 req = &cmd->stats_req;
199
200 memset(req, 0, sizeof(*req));
201
202 /* currently we support only max 8 bit masks so no need to worry
203 * about endian support */
204 req->upload_types[0] = mask;
205 req->reset_types[0] = mask;
206 req->stat_type = HTT_STATS_REQ_CFG_STAT_TYPE_INVALID;
207 req->cookie_lsb = cpu_to_le32(cookie & 0xffffffff);
208 req->cookie_msb = cpu_to_le32((cookie & 0xffffffff00000000ULL) >> 32);
196 209
197 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb); 210 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
198 if (ret) { 211 if (ret) {
212 ath10k_warn("failed to send htt type stats request: %d", ret);
199 dev_kfree_skb_any(skb); 213 dev_kfree_skb_any(skb);
200 return ret; 214 return ret;
201 } 215 }
@@ -279,8 +293,6 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)
279 293
280#undef desc_offset 294#undef desc_offset
281 295
282 ATH10K_SKB_CB(skb)->htt.is_conf = true;
283
284 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb); 296 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
285 if (ret) { 297 if (ret) {
286 dev_kfree_skb_any(skb); 298 dev_kfree_skb_any(skb);
@@ -293,10 +305,10 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)
293int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) 305int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
294{ 306{
295 struct device *dev = htt->ar->dev; 307 struct device *dev = htt->ar->dev;
296 struct ath10k_skb_cb *skb_cb;
297 struct sk_buff *txdesc = NULL; 308 struct sk_buff *txdesc = NULL;
298 struct htt_cmd *cmd; 309 struct htt_cmd *cmd;
299 u8 vdev_id = ATH10K_SKB_CB(msdu)->htt.vdev_id; 310 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
311 u8 vdev_id = skb_cb->htt.vdev_id;
300 int len = 0; 312 int len = 0;
301 int msdu_id = -1; 313 int msdu_id = -1;
302 int res; 314 int res;
@@ -304,30 +316,30 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
304 316
305 res = ath10k_htt_tx_inc_pending(htt); 317 res = ath10k_htt_tx_inc_pending(htt);
306 if (res) 318 if (res)
307 return res; 319 goto err;
308 320
309 len += sizeof(cmd->hdr); 321 len += sizeof(cmd->hdr);
310 len += sizeof(cmd->mgmt_tx); 322 len += sizeof(cmd->mgmt_tx);
311 323
312 txdesc = ath10k_htc_alloc_skb(len);
313 if (!txdesc) {
314 res = -ENOMEM;
315 goto err;
316 }
317
318 spin_lock_bh(&htt->tx_lock); 324 spin_lock_bh(&htt->tx_lock);
319 msdu_id = ath10k_htt_tx_alloc_msdu_id(htt); 325 res = ath10k_htt_tx_alloc_msdu_id(htt);
320 if (msdu_id < 0) { 326 if (res < 0) {
321 spin_unlock_bh(&htt->tx_lock); 327 spin_unlock_bh(&htt->tx_lock);
322 res = msdu_id; 328 goto err_tx_dec;
323 goto err;
324 } 329 }
325 htt->pending_tx[msdu_id] = txdesc; 330 msdu_id = res;
331 htt->pending_tx[msdu_id] = msdu;
326 spin_unlock_bh(&htt->tx_lock); 332 spin_unlock_bh(&htt->tx_lock);
327 333
334 txdesc = ath10k_htc_alloc_skb(len);
335 if (!txdesc) {
336 res = -ENOMEM;
337 goto err_free_msdu_id;
338 }
339
328 res = ath10k_skb_map(dev, msdu); 340 res = ath10k_skb_map(dev, msdu);
329 if (res) 341 if (res)
330 goto err; 342 goto err_free_txdesc;
331 343
332 skb_put(txdesc, len); 344 skb_put(txdesc, len);
333 cmd = (struct htt_cmd *)txdesc->data; 345 cmd = (struct htt_cmd *)txdesc->data;
@@ -339,31 +351,27 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
339 memcpy(cmd->mgmt_tx.hdr, msdu->data, 351 memcpy(cmd->mgmt_tx.hdr, msdu->data,
340 min_t(int, msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN)); 352 min_t(int, msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
341 353
342 /* refcount is decremented by HTC and HTT completions until it reaches 354 skb_cb->htt.frag_len = 0;
343 * zero and is freed */ 355 skb_cb->htt.pad_len = 0;
344 skb_cb = ATH10K_SKB_CB(txdesc);
345 skb_cb->htt.msdu_id = msdu_id;
346 skb_cb->htt.refcount = 2;
347 skb_cb->htt.msdu = msdu;
348 356
349 res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc); 357 res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
350 if (res) 358 if (res)
351 goto err; 359 goto err_unmap_msdu;
352 360
353 return 0; 361 return 0;
354 362
355err: 363err_unmap_msdu:
356 ath10k_skb_unmap(dev, msdu); 364 ath10k_skb_unmap(dev, msdu);
357 365err_free_txdesc:
358 if (txdesc) 366 dev_kfree_skb_any(txdesc);
359 dev_kfree_skb_any(txdesc); 367err_free_msdu_id:
360 if (msdu_id >= 0) { 368 spin_lock_bh(&htt->tx_lock);
361 spin_lock_bh(&htt->tx_lock); 369 htt->pending_tx[msdu_id] = NULL;
362 htt->pending_tx[msdu_id] = NULL; 370 ath10k_htt_tx_free_msdu_id(htt, msdu_id);
363 ath10k_htt_tx_free_msdu_id(htt, msdu_id); 371 spin_unlock_bh(&htt->tx_lock);
364 spin_unlock_bh(&htt->tx_lock); 372err_tx_dec:
365 }
366 ath10k_htt_tx_dec_pending(htt); 373 ath10k_htt_tx_dec_pending(htt);
374err:
367 return res; 375 return res;
368} 376}
369 377
@@ -373,13 +381,12 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
373 struct htt_cmd *cmd; 381 struct htt_cmd *cmd;
374 struct htt_data_tx_desc_frag *tx_frags; 382 struct htt_data_tx_desc_frag *tx_frags;
375 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; 383 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
376 struct ath10k_skb_cb *skb_cb; 384 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
377 struct sk_buff *txdesc = NULL; 385 struct sk_buff *txdesc = NULL;
378 struct sk_buff *txfrag = NULL; 386 bool use_frags;
379 u8 vdev_id = ATH10K_SKB_CB(msdu)->htt.vdev_id; 387 u8 vdev_id = ATH10K_SKB_CB(msdu)->htt.vdev_id;
380 u8 tid; 388 u8 tid;
381 int prefetch_len, desc_len, frag_len; 389 int prefetch_len, desc_len;
382 dma_addr_t frags_paddr;
383 int msdu_id = -1; 390 int msdu_id = -1;
384 int res; 391 int res;
385 u8 flags0; 392 u8 flags0;
@@ -387,69 +394,82 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
387 394
388 res = ath10k_htt_tx_inc_pending(htt); 395 res = ath10k_htt_tx_inc_pending(htt);
389 if (res) 396 if (res)
390 return res; 397 goto err;
398
399 spin_lock_bh(&htt->tx_lock);
400 res = ath10k_htt_tx_alloc_msdu_id(htt);
401 if (res < 0) {
402 spin_unlock_bh(&htt->tx_lock);
403 goto err_tx_dec;
404 }
405 msdu_id = res;
406 htt->pending_tx[msdu_id] = msdu;
407 spin_unlock_bh(&htt->tx_lock);
391 408
392 prefetch_len = min(htt->prefetch_len, msdu->len); 409 prefetch_len = min(htt->prefetch_len, msdu->len);
393 prefetch_len = roundup(prefetch_len, 4); 410 prefetch_len = roundup(prefetch_len, 4);
394 411
395 desc_len = sizeof(cmd->hdr) + sizeof(cmd->data_tx) + prefetch_len; 412 desc_len = sizeof(cmd->hdr) + sizeof(cmd->data_tx) + prefetch_len;
396 frag_len = sizeof(*tx_frags) * 2;
397 413
398 txdesc = ath10k_htc_alloc_skb(desc_len); 414 txdesc = ath10k_htc_alloc_skb(desc_len);
399 if (!txdesc) { 415 if (!txdesc) {
400 res = -ENOMEM; 416 res = -ENOMEM;
401 goto err; 417 goto err_free_msdu_id;
402 } 418 }
403 419
404 txfrag = dev_alloc_skb(frag_len); 420 /* Since HTT 3.0 there is no separate mgmt tx command. However in case
405 if (!txfrag) { 421 * of mgmt tx using TX_FRM there is not tx fragment list. Instead of tx
406 res = -ENOMEM; 422 * fragment list host driver specifies directly frame pointer. */
407 goto err; 423 use_frags = htt->target_version_major < 3 ||
408 } 424 !ieee80211_is_mgmt(hdr->frame_control);
409 425
410 if (!IS_ALIGNED((unsigned long)txdesc->data, 4)) { 426 if (!IS_ALIGNED((unsigned long)txdesc->data, 4)) {
411 ath10k_warn("htt alignment check failed. dropping packet.\n"); 427 ath10k_warn("htt alignment check failed. dropping packet.\n");
412 res = -EIO; 428 res = -EIO;
413 goto err; 429 goto err_free_txdesc;
414 } 430 }
415 431
416 spin_lock_bh(&htt->tx_lock); 432 if (use_frags) {
417 msdu_id = ath10k_htt_tx_alloc_msdu_id(htt); 433 skb_cb->htt.frag_len = sizeof(*tx_frags) * 2;
418 if (msdu_id < 0) { 434 skb_cb->htt.pad_len = (unsigned long)msdu->data -
419 spin_unlock_bh(&htt->tx_lock); 435 round_down((unsigned long)msdu->data, 4);
420 res = msdu_id; 436
421 goto err; 437 skb_push(msdu, skb_cb->htt.frag_len + skb_cb->htt.pad_len);
438 } else {
439 skb_cb->htt.frag_len = 0;
440 skb_cb->htt.pad_len = 0;
422 } 441 }
423 htt->pending_tx[msdu_id] = txdesc;
424 spin_unlock_bh(&htt->tx_lock);
425 442
426 res = ath10k_skb_map(dev, msdu); 443 res = ath10k_skb_map(dev, msdu);
427 if (res) 444 if (res)
428 goto err; 445 goto err_pull_txfrag;
429 446
430 /* tx fragment list must be terminated with zero-entry */ 447 if (use_frags) {
431 skb_put(txfrag, frag_len); 448 dma_sync_single_for_cpu(dev, skb_cb->paddr, msdu->len,
432 tx_frags = (struct htt_data_tx_desc_frag *)txfrag->data; 449 DMA_TO_DEVICE);
433 tx_frags[0].paddr = __cpu_to_le32(ATH10K_SKB_CB(msdu)->paddr); 450
434 tx_frags[0].len = __cpu_to_le32(msdu->len); 451 /* tx fragment list must be terminated with zero-entry */
435 tx_frags[1].paddr = __cpu_to_le32(0); 452 tx_frags = (struct htt_data_tx_desc_frag *)msdu->data;
436 tx_frags[1].len = __cpu_to_le32(0); 453 tx_frags[0].paddr = __cpu_to_le32(skb_cb->paddr +
437 454 skb_cb->htt.frag_len +
438 res = ath10k_skb_map(dev, txfrag); 455 skb_cb->htt.pad_len);
439 if (res) 456 tx_frags[0].len = __cpu_to_le32(msdu->len -
440 goto err; 457 skb_cb->htt.frag_len -
458 skb_cb->htt.pad_len);
459 tx_frags[1].paddr = __cpu_to_le32(0);
460 tx_frags[1].len = __cpu_to_le32(0);
461
462 dma_sync_single_for_device(dev, skb_cb->paddr, msdu->len,
463 DMA_TO_DEVICE);
464 }
441 465
442 ath10k_dbg(ATH10K_DBG_HTT, "txfrag 0x%llx msdu 0x%llx\n", 466 ath10k_dbg(ATH10K_DBG_HTT, "msdu 0x%llx\n",
443 (unsigned long long) ATH10K_SKB_CB(txfrag)->paddr,
444 (unsigned long long) ATH10K_SKB_CB(msdu)->paddr); 467 (unsigned long long) ATH10K_SKB_CB(msdu)->paddr);
445 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "txfrag: ",
446 txfrag->data, frag_len);
447 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "msdu: ", 468 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "msdu: ",
448 msdu->data, msdu->len); 469 msdu->data, msdu->len);
449 470
450 skb_put(txdesc, desc_len); 471 skb_put(txdesc, desc_len);
451 cmd = (struct htt_cmd *)txdesc->data; 472 cmd = (struct htt_cmd *)txdesc->data;
452 memset(cmd, 0, desc_len);
453 473
454 tid = ATH10K_SKB_CB(msdu)->htt.tid; 474 tid = ATH10K_SKB_CB(msdu)->htt.tid;
455 475
@@ -459,8 +479,13 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
459 if (!ieee80211_has_protected(hdr->frame_control)) 479 if (!ieee80211_has_protected(hdr->frame_control))
460 flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT; 480 flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT;
461 flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT; 481 flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
462 flags0 |= SM(ATH10K_HW_TXRX_NATIVE_WIFI, 482
463 HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE); 483 if (use_frags)
484 flags0 |= SM(ATH10K_HW_TXRX_NATIVE_WIFI,
485 HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
486 else
487 flags0 |= SM(ATH10K_HW_TXRX_MGMT,
488 HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
464 489
465 flags1 = 0; 490 flags1 = 0;
466 flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID); 491 flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID);
@@ -468,45 +493,37 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
468 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD; 493 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD;
469 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD; 494 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD;
470 495
471 frags_paddr = ATH10K_SKB_CB(txfrag)->paddr;
472
473 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_TX_FRM; 496 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_TX_FRM;
474 cmd->data_tx.flags0 = flags0; 497 cmd->data_tx.flags0 = flags0;
475 cmd->data_tx.flags1 = __cpu_to_le16(flags1); 498 cmd->data_tx.flags1 = __cpu_to_le16(flags1);
476 cmd->data_tx.len = __cpu_to_le16(msdu->len); 499 cmd->data_tx.len = __cpu_to_le16(msdu->len -
500 skb_cb->htt.frag_len -
501 skb_cb->htt.pad_len);
477 cmd->data_tx.id = __cpu_to_le16(msdu_id); 502 cmd->data_tx.id = __cpu_to_le16(msdu_id);
478 cmd->data_tx.frags_paddr = __cpu_to_le32(frags_paddr); 503 cmd->data_tx.frags_paddr = __cpu_to_le32(skb_cb->paddr);
479 cmd->data_tx.peerid = __cpu_to_le32(HTT_INVALID_PEERID); 504 cmd->data_tx.peerid = __cpu_to_le32(HTT_INVALID_PEERID);
480 505
481 memcpy(cmd->data_tx.prefetch, msdu->data, prefetch_len); 506 memcpy(cmd->data_tx.prefetch, hdr, prefetch_len);
482
483 /* refcount is decremented by HTC and HTT completions until it reaches
484 * zero and is freed */
485 skb_cb = ATH10K_SKB_CB(txdesc);
486 skb_cb->htt.msdu_id = msdu_id;
487 skb_cb->htt.refcount = 2;
488 skb_cb->htt.txfrag = txfrag;
489 skb_cb->htt.msdu = msdu;
490 507
491 res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc); 508 res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
492 if (res) 509 if (res)
493 goto err; 510 goto err_unmap_msdu;
494 511
495 return 0; 512 return 0;
496err: 513
497 if (txfrag) 514err_unmap_msdu:
498 ath10k_skb_unmap(dev, txfrag);
499 if (txdesc)
500 dev_kfree_skb_any(txdesc);
501 if (txfrag)
502 dev_kfree_skb_any(txfrag);
503 if (msdu_id >= 0) {
504 spin_lock_bh(&htt->tx_lock);
505 htt->pending_tx[msdu_id] = NULL;
506 ath10k_htt_tx_free_msdu_id(htt, msdu_id);
507 spin_unlock_bh(&htt->tx_lock);
508 }
509 ath10k_htt_tx_dec_pending(htt);
510 ath10k_skb_unmap(dev, msdu); 515 ath10k_skb_unmap(dev, msdu);
516err_pull_txfrag:
517 skb_pull(msdu, skb_cb->htt.frag_len + skb_cb->htt.pad_len);
518err_free_txdesc:
519 dev_kfree_skb_any(txdesc);
520err_free_msdu_id:
521 spin_lock_bh(&htt->tx_lock);
522 htt->pending_tx[msdu_id] = NULL;
523 ath10k_htt_tx_free_msdu_id(htt, msdu_id);
524 spin_unlock_bh(&htt->tx_lock);
525err_tx_dec:
526 ath10k_htt_tx_dec_pending(htt);
527err:
511 return res; 528 return res;
512} 529}
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
index 44ed5af0a204..8c1be7685922 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -24,18 +24,14 @@
24#define SUPPORTED_FW_MAJOR 1 24#define SUPPORTED_FW_MAJOR 1
25#define SUPPORTED_FW_MINOR 0 25#define SUPPORTED_FW_MINOR 0
26#define SUPPORTED_FW_RELEASE 0 26#define SUPPORTED_FW_RELEASE 0
27#define SUPPORTED_FW_BUILD 629 27#define SUPPORTED_FW_BUILD 636
28 28
29/* QCA988X 1.0 definitions */ 29/* QCA988X 1.0 definitions (unsupported) */
30#define QCA988X_HW_1_0_VERSION 0x4000002c 30#define QCA988X_HW_1_0_CHIP_ID_REV 0x0
31#define QCA988X_HW_1_0_FW_DIR "ath10k/QCA988X/hw1.0"
32#define QCA988X_HW_1_0_FW_FILE "firmware.bin"
33#define QCA988X_HW_1_0_OTP_FILE "otp.bin"
34#define QCA988X_HW_1_0_BOARD_DATA_FILE "board.bin"
35#define QCA988X_HW_1_0_PATCH_LOAD_ADDR 0x1234
36 31
37/* QCA988X 2.0 definitions */ 32/* QCA988X 2.0 definitions */
38#define QCA988X_HW_2_0_VERSION 0x4100016c 33#define QCA988X_HW_2_0_VERSION 0x4100016c
34#define QCA988X_HW_2_0_CHIP_ID_REV 0x2
39#define QCA988X_HW_2_0_FW_DIR "ath10k/QCA988X/hw2.0" 35#define QCA988X_HW_2_0_FW_DIR "ath10k/QCA988X/hw2.0"
40#define QCA988X_HW_2_0_FW_FILE "firmware.bin" 36#define QCA988X_HW_2_0_FW_FILE "firmware.bin"
41#define QCA988X_HW_2_0_OTP_FILE "otp.bin" 37#define QCA988X_HW_2_0_OTP_FILE "otp.bin"
@@ -53,6 +49,9 @@ enum ath10k_hw_txrx_mode {
53 ATH10K_HW_TXRX_RAW = 0, 49 ATH10K_HW_TXRX_RAW = 0,
54 ATH10K_HW_TXRX_NATIVE_WIFI = 1, 50 ATH10K_HW_TXRX_NATIVE_WIFI = 1,
55 ATH10K_HW_TXRX_ETHERNET = 2, 51 ATH10K_HW_TXRX_ETHERNET = 2,
52
53 /* Valid for HTT >= 3.0. Used for management frames in TX_FRM. */
54 ATH10K_HW_TXRX_MGMT = 3,
56}; 55};
57 56
58enum ath10k_mcast2ucast_mode { 57enum ath10k_mcast2ucast_mode {
@@ -75,7 +74,11 @@ enum ath10k_mcast2ucast_mode {
75#define TARGET_RX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2)) 74#define TARGET_RX_CHAIN_MASK (BIT(0) | BIT(1) | BIT(2))
76#define TARGET_RX_TIMEOUT_LO_PRI 100 75#define TARGET_RX_TIMEOUT_LO_PRI 100
77#define TARGET_RX_TIMEOUT_HI_PRI 40 76#define TARGET_RX_TIMEOUT_HI_PRI 40
78#define TARGET_RX_DECAP_MODE ATH10K_HW_TXRX_ETHERNET 77
78/* Native Wifi decap mode is used to align IP frames to 4-byte boundaries and
79 * avoid a very expensive re-alignment in mac80211. */
80#define TARGET_RX_DECAP_MODE ATH10K_HW_TXRX_NATIVE_WIFI
81
79#define TARGET_SCAN_MAX_PENDING_REQS 4 82#define TARGET_SCAN_MAX_PENDING_REQS 4
80#define TARGET_BMISS_OFFLOAD_MAX_VDEV 3 83#define TARGET_BMISS_OFFLOAD_MAX_VDEV 3
81#define TARGET_ROAM_OFFLOAD_MAX_VDEV 3 84#define TARGET_ROAM_OFFLOAD_MAX_VDEV 3
@@ -169,6 +172,10 @@ enum ath10k_mcast2ucast_mode {
169#define SOC_LPO_CAL_ENABLE_LSB 20 172#define SOC_LPO_CAL_ENABLE_LSB 20
170#define SOC_LPO_CAL_ENABLE_MASK 0x00100000 173#define SOC_LPO_CAL_ENABLE_MASK 0x00100000
171 174
175#define SOC_CHIP_ID_ADDRESS 0x000000ec
176#define SOC_CHIP_ID_REV_LSB 8
177#define SOC_CHIP_ID_REV_MASK 0x00000f00
178
172#define WLAN_RESET_CONTROL_COLD_RST_MASK 0x00000008 179#define WLAN_RESET_CONTROL_COLD_RST_MASK 0x00000008
173#define WLAN_RESET_CONTROL_WARM_RST_MASK 0x00000004 180#define WLAN_RESET_CONTROL_WARM_RST_MASK 0x00000004
174#define WLAN_SYSTEM_SLEEP_DISABLE_LSB 0 181#define WLAN_SYSTEM_SLEEP_DISABLE_LSB 0
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index cf2ba4d850c9..99a9bad3f398 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -460,6 +460,11 @@ static int ath10k_vdev_start(struct ath10k_vif *arvif)
460 arg.ssid_len = arvif->vif->bss_conf.ssid_len; 460 arg.ssid_len = arvif->vif->bss_conf.ssid_len;
461 } 461 }
462 462
463 ath10k_dbg(ATH10K_DBG_MAC,
464 "mac vdev %d start center_freq %d phymode %s\n",
465 arg.vdev_id, arg.channel.freq,
466 ath10k_wmi_phymode_str(arg.channel.mode));
467
463 ret = ath10k_wmi_vdev_start(ar, &arg); 468 ret = ath10k_wmi_vdev_start(ar, &arg);
464 if (ret) { 469 if (ret) {
465 ath10k_warn("WMI vdev start failed: ret %d\n", ret); 470 ath10k_warn("WMI vdev start failed: ret %d\n", ret);
@@ -503,13 +508,10 @@ static int ath10k_monitor_start(struct ath10k *ar, int vdev_id)
503{ 508{
504 struct ieee80211_channel *channel = ar->hw->conf.chandef.chan; 509 struct ieee80211_channel *channel = ar->hw->conf.chandef.chan;
505 struct wmi_vdev_start_request_arg arg = {}; 510 struct wmi_vdev_start_request_arg arg = {};
506 enum nl80211_channel_type type;
507 int ret = 0; 511 int ret = 0;
508 512
509 lockdep_assert_held(&ar->conf_mutex); 513 lockdep_assert_held(&ar->conf_mutex);
510 514
511 type = cfg80211_get_chandef_type(&ar->hw->conf.chandef);
512
513 arg.vdev_id = vdev_id; 515 arg.vdev_id = vdev_id;
514 arg.channel.freq = channel->center_freq; 516 arg.channel.freq = channel->center_freq;
515 arg.channel.band_center_freq1 = ar->hw->conf.chandef.center_freq1; 517 arg.channel.band_center_freq1 = ar->hw->conf.chandef.center_freq1;
@@ -607,7 +609,7 @@ static int ath10k_monitor_create(struct ath10k *ar)
607 goto vdev_fail; 609 goto vdev_fail;
608 } 610 }
609 611
610 ath10k_dbg(ATH10K_DBG_MAC, "Monitor interface created, vdev id: %d\n", 612 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %d created\n",
611 ar->monitor_vdev_id); 613 ar->monitor_vdev_id);
612 614
613 ar->monitor_present = true; 615 ar->monitor_present = true;
@@ -639,7 +641,7 @@ static int ath10k_monitor_destroy(struct ath10k *ar)
639 ar->free_vdev_map |= 1 << (ar->monitor_vdev_id); 641 ar->free_vdev_map |= 1 << (ar->monitor_vdev_id);
640 ar->monitor_present = false; 642 ar->monitor_present = false;
641 643
642 ath10k_dbg(ATH10K_DBG_MAC, "Monitor interface destroyed, vdev id: %d\n", 644 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %d deleted\n",
643 ar->monitor_vdev_id); 645 ar->monitor_vdev_id);
644 return ret; 646 return ret;
645} 647}
@@ -668,7 +670,7 @@ static void ath10k_control_beaconing(struct ath10k_vif *arvif,
668 arvif->vdev_id); 670 arvif->vdev_id);
669 return; 671 return;
670 } 672 }
671 ath10k_dbg(ATH10K_DBG_MAC, "VDEV: %d up\n", arvif->vdev_id); 673 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d up\n", arvif->vdev_id);
672} 674}
673 675
674static void ath10k_control_ibss(struct ath10k_vif *arvif, 676static void ath10k_control_ibss(struct ath10k_vif *arvif,
@@ -752,14 +754,14 @@ static void ath10k_ps_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
752 psmode = WMI_STA_PS_MODE_DISABLED; 754 psmode = WMI_STA_PS_MODE_DISABLED;
753 } 755 }
754 756
757 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d psmode %s\n",
758 arvif->vdev_id, psmode ? "enable" : "disable");
759
755 ar_iter->ret = ath10k_wmi_set_psmode(ar_iter->ar, arvif->vdev_id, 760 ar_iter->ret = ath10k_wmi_set_psmode(ar_iter->ar, arvif->vdev_id,
756 psmode); 761 psmode);
757 if (ar_iter->ret) 762 if (ar_iter->ret)
758 ath10k_warn("Failed to set PS Mode: %d for VDEV: %d\n", 763 ath10k_warn("Failed to set PS Mode: %d for VDEV: %d\n",
759 psmode, arvif->vdev_id); 764 psmode, arvif->vdev_id);
760 else
761 ath10k_dbg(ATH10K_DBG_MAC, "Set PS Mode: %d for VDEV: %d\n",
762 psmode, arvif->vdev_id);
763} 765}
764 766
765/**********************/ 767/**********************/
@@ -949,7 +951,8 @@ static void ath10k_peer_assoc_h_ht(struct ath10k *ar,
949 arg->peer_ht_rates.num_rates = n; 951 arg->peer_ht_rates.num_rates = n;
950 arg->peer_num_spatial_streams = max((n+7) / 8, 1); 952 arg->peer_num_spatial_streams = max((n+7) / 8, 1);
951 953
952 ath10k_dbg(ATH10K_DBG_MAC, "mcs cnt %d nss %d\n", 954 ath10k_dbg(ATH10K_DBG_MAC, "mac ht peer %pM mcs cnt %d nss %d\n",
955 arg->addr,
953 arg->peer_ht_rates.num_rates, 956 arg->peer_ht_rates.num_rates,
954 arg->peer_num_spatial_streams); 957 arg->peer_num_spatial_streams);
955} 958}
@@ -969,11 +972,11 @@ static void ath10k_peer_assoc_h_qos_ap(struct ath10k *ar,
969 arg->peer_flags |= WMI_PEER_QOS; 972 arg->peer_flags |= WMI_PEER_QOS;
970 973
971 if (sta->wme && sta->uapsd_queues) { 974 if (sta->wme && sta->uapsd_queues) {
972 ath10k_dbg(ATH10K_DBG_MAC, "uapsd_queues: 0x%X, max_sp: %d\n", 975 ath10k_dbg(ATH10K_DBG_MAC, "mac uapsd_queues 0x%x max_sp %d\n",
973 sta->uapsd_queues, sta->max_sp); 976 sta->uapsd_queues, sta->max_sp);
974 977
975 arg->peer_flags |= WMI_PEER_APSD; 978 arg->peer_flags |= WMI_PEER_APSD;
976 arg->peer_flags |= WMI_RC_UAPSD_FLAG; 979 arg->peer_rate_caps |= WMI_RC_UAPSD_FLAG;
977 980
978 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) 981 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
979 uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN | 982 uapsd |= WMI_AP_PS_UAPSD_AC3_DELIVERY_EN |
@@ -1048,7 +1051,8 @@ static void ath10k_peer_assoc_h_vht(struct ath10k *ar,
1048 arg->peer_vht_rates.tx_mcs_set = 1051 arg->peer_vht_rates.tx_mcs_set =
1049 __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); 1052 __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map);
1050 1053
1051 ath10k_dbg(ATH10K_DBG_MAC, "mac vht peer\n"); 1054 ath10k_dbg(ATH10K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n",
1055 sta->addr, arg->peer_max_mpdu, arg->peer_flags);
1052} 1056}
1053 1057
1054static void ath10k_peer_assoc_h_qos(struct ath10k *ar, 1058static void ath10k_peer_assoc_h_qos(struct ath10k *ar,
@@ -1076,8 +1080,6 @@ static void ath10k_peer_assoc_h_phymode(struct ath10k *ar,
1076{ 1080{
1077 enum wmi_phy_mode phymode = MODE_UNKNOWN; 1081 enum wmi_phy_mode phymode = MODE_UNKNOWN;
1078 1082
1079 /* FIXME: add VHT */
1080
1081 switch (ar->hw->conf.chandef.chan->band) { 1083 switch (ar->hw->conf.chandef.chan->band) {
1082 case IEEE80211_BAND_2GHZ: 1084 case IEEE80211_BAND_2GHZ:
1083 if (sta->ht_cap.ht_supported) { 1085 if (sta->ht_cap.ht_supported) {
@@ -1091,7 +1093,17 @@ static void ath10k_peer_assoc_h_phymode(struct ath10k *ar,
1091 1093
1092 break; 1094 break;
1093 case IEEE80211_BAND_5GHZ: 1095 case IEEE80211_BAND_5GHZ:
1094 if (sta->ht_cap.ht_supported) { 1096 /*
1097 * Check VHT first.
1098 */
1099 if (sta->vht_cap.vht_supported) {
1100 if (sta->bandwidth == IEEE80211_STA_RX_BW_80)
1101 phymode = MODE_11AC_VHT80;
1102 else if (sta->bandwidth == IEEE80211_STA_RX_BW_40)
1103 phymode = MODE_11AC_VHT40;
1104 else if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
1105 phymode = MODE_11AC_VHT20;
1106 } else if (sta->ht_cap.ht_supported) {
1095 if (sta->bandwidth == IEEE80211_STA_RX_BW_40) 1107 if (sta->bandwidth == IEEE80211_STA_RX_BW_40)
1096 phymode = MODE_11NA_HT40; 1108 phymode = MODE_11NA_HT40;
1097 else 1109 else
@@ -1105,6 +1117,9 @@ static void ath10k_peer_assoc_h_phymode(struct ath10k *ar,
1105 break; 1117 break;
1106 } 1118 }
1107 1119
1120 ath10k_dbg(ATH10K_DBG_MAC, "mac peer %pM phymode %s\n",
1121 sta->addr, ath10k_wmi_phymode_str(phymode));
1122
1108 arg->peer_phymode = phymode; 1123 arg->peer_phymode = phymode;
1109 WARN_ON(phymode == MODE_UNKNOWN); 1124 WARN_ON(phymode == MODE_UNKNOWN);
1110} 1125}
@@ -1162,15 +1177,15 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw,
1162 1177
1163 rcu_read_unlock(); 1178 rcu_read_unlock();
1164 1179
1180 ath10k_dbg(ATH10K_DBG_MAC,
1181 "mac vdev %d up (associated) bssid %pM aid %d\n",
1182 arvif->vdev_id, bss_conf->bssid, bss_conf->aid);
1183
1165 ret = ath10k_wmi_vdev_up(ar, arvif->vdev_id, bss_conf->aid, 1184 ret = ath10k_wmi_vdev_up(ar, arvif->vdev_id, bss_conf->aid,
1166 bss_conf->bssid); 1185 bss_conf->bssid);
1167 if (ret) 1186 if (ret)
1168 ath10k_warn("VDEV: %d up failed: ret %d\n", 1187 ath10k_warn("VDEV: %d up failed: ret %d\n",
1169 arvif->vdev_id, ret); 1188 arvif->vdev_id, ret);
1170 else
1171 ath10k_dbg(ATH10K_DBG_MAC,
1172 "VDEV: %d associated, BSSID: %pM, AID: %d\n",
1173 arvif->vdev_id, bss_conf->bssid, bss_conf->aid);
1174} 1189}
1175 1190
1176/* 1191/*
@@ -1191,10 +1206,11 @@ static void ath10k_bss_disassoc(struct ieee80211_hw *hw,
1191 * No idea why this happens, even though VDEV-DOWN is supposed 1206 * No idea why this happens, even though VDEV-DOWN is supposed
1192 * to be analogous to link down, so just stop the VDEV. 1207 * to be analogous to link down, so just stop the VDEV.
1193 */ 1208 */
1209 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d stop (disassociated\n",
1210 arvif->vdev_id);
1211
1212 /* FIXME: check return value */
1194 ret = ath10k_vdev_stop(arvif); 1213 ret = ath10k_vdev_stop(arvif);
1195 if (!ret)
1196 ath10k_dbg(ATH10K_DBG_MAC, "VDEV: %d stopped\n",
1197 arvif->vdev_id);
1198 1214
1199 /* 1215 /*
1200 * If we don't call VDEV-DOWN after VDEV-STOP FW will remain active and 1216 * If we don't call VDEV-DOWN after VDEV-STOP FW will remain active and
@@ -1203,12 +1219,10 @@ static void ath10k_bss_disassoc(struct ieee80211_hw *hw,
1203 * interfaces as it expects there is no rx when no interface is 1219 * interfaces as it expects there is no rx when no interface is
1204 * running. 1220 * running.
1205 */ 1221 */
1206 ret = ath10k_wmi_vdev_down(ar, arvif->vdev_id); 1222 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d down\n", arvif->vdev_id);
1207 if (ret)
1208 ath10k_dbg(ATH10K_DBG_MAC, "VDEV: %d ath10k_wmi_vdev_down failed (%d)\n",
1209 arvif->vdev_id, ret);
1210 1223
1211 ath10k_wmi_flush_tx(ar); 1224 /* FIXME: why don't we print error if wmi call fails? */
1225 ret = ath10k_wmi_vdev_down(ar, arvif->vdev_id);
1212 1226
1213 arvif->def_wep_key_index = 0; 1227 arvif->def_wep_key_index = 0;
1214} 1228}
@@ -1333,8 +1347,8 @@ static int ath10k_update_channel_list(struct ath10k *ar)
1333 continue; 1347 continue;
1334 1348
1335 ath10k_dbg(ATH10K_DBG_WMI, 1349 ath10k_dbg(ATH10K_DBG_WMI,
1336 "%s: [%zd/%d] freq %d maxpower %d regpower %d antenna %d mode %d\n", 1350 "mac channel [%zd/%d] freq %d maxpower %d regpower %d antenna %d mode %d\n",
1337 __func__, ch - arg.channels, arg.n_channels, 1351 ch - arg.channels, arg.n_channels,
1338 ch->freq, ch->max_power, ch->max_reg_power, 1352 ch->freq, ch->max_power, ch->max_reg_power,
1339 ch->max_antenna_gain, ch->mode); 1353 ch->max_antenna_gain, ch->mode);
1340 1354
@@ -1421,10 +1435,6 @@ static void ath10k_tx_h_update_wep_key(struct sk_buff *skb)
1421 struct ieee80211_key_conf *key = info->control.hw_key; 1435 struct ieee80211_key_conf *key = info->control.hw_key;
1422 int ret; 1436 int ret;
1423 1437
1424 /* TODO AP mode should be implemented */
1425 if (vif->type != NL80211_IFTYPE_STATION)
1426 return;
1427
1428 if (!ieee80211_has_protected(hdr->frame_control)) 1438 if (!ieee80211_has_protected(hdr->frame_control))
1429 return; 1439 return;
1430 1440
@@ -1438,7 +1448,8 @@ static void ath10k_tx_h_update_wep_key(struct sk_buff *skb)
1438 if (key->keyidx == arvif->def_wep_key_index) 1448 if (key->keyidx == arvif->def_wep_key_index)
1439 return; 1449 return;
1440 1450
1441 ath10k_dbg(ATH10K_DBG_MAC, "new wep keyidx will be %d\n", key->keyidx); 1451 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d keyidx %d\n",
1452 arvif->vdev_id, key->keyidx);
1442 1453
1443 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 1454 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
1444 WMI_VDEV_PARAM_DEF_KEYID, 1455 WMI_VDEV_PARAM_DEF_KEYID,
@@ -1480,6 +1491,12 @@ static void ath10k_tx_htt(struct ath10k *ar, struct sk_buff *skb)
1480 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1491 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1481 int ret; 1492 int ret;
1482 1493
1494 if (ar->htt.target_version_major >= 3) {
1495 /* Since HTT 3.0 there is no separate mgmt tx command */
1496 ret = ath10k_htt_tx(&ar->htt, skb);
1497 goto exit;
1498 }
1499
1483 if (ieee80211_is_mgmt(hdr->frame_control)) 1500 if (ieee80211_is_mgmt(hdr->frame_control))
1484 ret = ath10k_htt_mgmt_tx(&ar->htt, skb); 1501 ret = ath10k_htt_mgmt_tx(&ar->htt, skb);
1485 else if (ieee80211_is_nullfunc(hdr->frame_control)) 1502 else if (ieee80211_is_nullfunc(hdr->frame_control))
@@ -1491,6 +1508,7 @@ static void ath10k_tx_htt(struct ath10k *ar, struct sk_buff *skb)
1491 else 1508 else
1492 ret = ath10k_htt_tx(&ar->htt, skb); 1509 ret = ath10k_htt_tx(&ar->htt, skb);
1493 1510
1511exit:
1494 if (ret) { 1512 if (ret) {
1495 ath10k_warn("tx failed (%d). dropping packet.\n", ret); 1513 ath10k_warn("tx failed (%d). dropping packet.\n", ret);
1496 ieee80211_free_txskb(ar->hw, skb); 1514 ieee80211_free_txskb(ar->hw, skb);
@@ -1534,7 +1552,7 @@ void ath10k_offchan_tx_work(struct work_struct *work)
1534 1552
1535 mutex_lock(&ar->conf_mutex); 1553 mutex_lock(&ar->conf_mutex);
1536 1554
1537 ath10k_dbg(ATH10K_DBG_MAC, "processing offchannel skb %p\n", 1555 ath10k_dbg(ATH10K_DBG_MAC, "mac offchannel skb %p\n",
1538 skb); 1556 skb);
1539 1557
1540 hdr = (struct ieee80211_hdr *)skb->data; 1558 hdr = (struct ieee80211_hdr *)skb->data;
@@ -1546,6 +1564,7 @@ void ath10k_offchan_tx_work(struct work_struct *work)
1546 spin_unlock_bh(&ar->data_lock); 1564 spin_unlock_bh(&ar->data_lock);
1547 1565
1548 if (peer) 1566 if (peer)
1567 /* FIXME: should this use ath10k_warn()? */
1549 ath10k_dbg(ATH10K_DBG_MAC, "peer %pM on vdev %d already present\n", 1568 ath10k_dbg(ATH10K_DBG_MAC, "peer %pM on vdev %d already present\n",
1550 peer_addr, vdev_id); 1569 peer_addr, vdev_id);
1551 1570
@@ -1643,8 +1662,6 @@ static int ath10k_abort_scan(struct ath10k *ar)
1643 return -EIO; 1662 return -EIO;
1644 } 1663 }
1645 1664
1646 ath10k_wmi_flush_tx(ar);
1647
1648 ret = wait_for_completion_timeout(&ar->scan.completed, 3*HZ); 1665 ret = wait_for_completion_timeout(&ar->scan.completed, 3*HZ);
1649 if (ret == 0) 1666 if (ret == 0)
1650 ath10k_warn("timed out while waiting for scan to stop\n"); 1667 ath10k_warn("timed out while waiting for scan to stop\n");
@@ -1678,10 +1695,6 @@ static int ath10k_start_scan(struct ath10k *ar,
1678 if (ret) 1695 if (ret)
1679 return ret; 1696 return ret;
1680 1697
1681 /* make sure we submit the command so the completion
1682 * timeout makes sense */
1683 ath10k_wmi_flush_tx(ar);
1684
1685 ret = wait_for_completion_timeout(&ar->scan.started, 1*HZ); 1698 ret = wait_for_completion_timeout(&ar->scan.started, 1*HZ);
1686 if (ret == 0) { 1699 if (ret == 0) {
1687 ath10k_abort_scan(ar); 1700 ath10k_abort_scan(ar);
@@ -1727,8 +1740,10 @@ static void ath10k_tx(struct ieee80211_hw *hw,
1727 /* we must calculate tid before we apply qos workaround 1740 /* we must calculate tid before we apply qos workaround
1728 * as we'd lose the qos control field */ 1741 * as we'd lose the qos control field */
1729 tid = HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST; 1742 tid = HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST;
1730 if (ieee80211_is_data_qos(hdr->frame_control) && 1743 if (ieee80211_is_mgmt(hdr->frame_control)) {
1731 is_unicast_ether_addr(ieee80211_get_DA(hdr))) { 1744 tid = HTT_DATA_TX_EXT_TID_MGMT;
1745 } else if (ieee80211_is_data_qos(hdr->frame_control) &&
1746 is_unicast_ether_addr(ieee80211_get_DA(hdr))) {
1732 u8 *qc = ieee80211_get_qos_ctl(hdr); 1747 u8 *qc = ieee80211_get_qos_ctl(hdr);
1733 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; 1748 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
1734 } 1749 }
@@ -1742,7 +1757,7 @@ static void ath10k_tx(struct ieee80211_hw *hw,
1742 ath10k_tx_h_seq_no(skb); 1757 ath10k_tx_h_seq_no(skb);
1743 } 1758 }
1744 1759
1745 memset(ATH10K_SKB_CB(skb), 0, sizeof(*ATH10K_SKB_CB(skb))); 1760 ATH10K_SKB_CB(skb)->htt.is_offchan = false;
1746 ATH10K_SKB_CB(skb)->htt.vdev_id = vdev_id; 1761 ATH10K_SKB_CB(skb)->htt.vdev_id = vdev_id;
1747 ATH10K_SKB_CB(skb)->htt.tid = tid; 1762 ATH10K_SKB_CB(skb)->htt.tid = tid;
1748 1763
@@ -1884,7 +1899,7 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed)
1884 mutex_lock(&ar->conf_mutex); 1899 mutex_lock(&ar->conf_mutex);
1885 1900
1886 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 1901 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
1887 ath10k_dbg(ATH10K_DBG_MAC, "Config channel %d mhz\n", 1902 ath10k_dbg(ATH10K_DBG_MAC, "mac config channel %d mhz\n",
1888 conf->chandef.chan->center_freq); 1903 conf->chandef.chan->center_freq);
1889 spin_lock_bh(&ar->data_lock); 1904 spin_lock_bh(&ar->data_lock);
1890 ar->rx_channel = conf->chandef.chan; 1905 ar->rx_channel = conf->chandef.chan;
@@ -1901,7 +1916,6 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed)
1901 ret = ath10k_monitor_destroy(ar); 1916 ret = ath10k_monitor_destroy(ar);
1902 } 1917 }
1903 1918
1904 ath10k_wmi_flush_tx(ar);
1905 mutex_unlock(&ar->conf_mutex); 1919 mutex_unlock(&ar->conf_mutex);
1906 return ret; 1920 return ret;
1907} 1921}
@@ -1973,7 +1987,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
1973 break; 1987 break;
1974 } 1988 }
1975 1989
1976 ath10k_dbg(ATH10K_DBG_MAC, "Add interface: id %d type %d subtype %d\n", 1990 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev create %d (add interface) type %d subtype %d\n",
1977 arvif->vdev_id, arvif->vdev_type, arvif->vdev_subtype); 1991 arvif->vdev_id, arvif->vdev_type, arvif->vdev_subtype);
1978 1992
1979 ret = ath10k_wmi_vdev_create(ar, arvif->vdev_id, arvif->vdev_type, 1993 ret = ath10k_wmi_vdev_create(ar, arvif->vdev_id, arvif->vdev_type,
@@ -2052,7 +2066,12 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
2052 2066
2053 mutex_lock(&ar->conf_mutex); 2067 mutex_lock(&ar->conf_mutex);
2054 2068
2055 ath10k_dbg(ATH10K_DBG_MAC, "Remove interface: id %d\n", arvif->vdev_id); 2069 spin_lock_bh(&ar->data_lock);
2070 if (arvif->beacon) {
2071 dev_kfree_skb_any(arvif->beacon);
2072 arvif->beacon = NULL;
2073 }
2074 spin_unlock_bh(&ar->data_lock);
2056 2075
2057 ar->free_vdev_map |= 1 << (arvif->vdev_id); 2076 ar->free_vdev_map |= 1 << (arvif->vdev_id);
2058 2077
@@ -2064,6 +2083,9 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
2064 kfree(arvif->u.ap.noa_data); 2083 kfree(arvif->u.ap.noa_data);
2065 } 2084 }
2066 2085
2086 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev delete %d (remove interface)\n",
2087 arvif->vdev_id);
2088
2067 ret = ath10k_wmi_vdev_delete(ar, arvif->vdev_id); 2089 ret = ath10k_wmi_vdev_delete(ar, arvif->vdev_id);
2068 if (ret) 2090 if (ret)
2069 ath10k_warn("WMI vdev delete failed: %d\n", ret); 2091 ath10k_warn("WMI vdev delete failed: %d\n", ret);
@@ -2105,18 +2127,20 @@ static void ath10k_configure_filter(struct ieee80211_hw *hw,
2105 2127
2106 if ((ar->filter_flags & FIF_PROMISC_IN_BSS) && 2128 if ((ar->filter_flags & FIF_PROMISC_IN_BSS) &&
2107 !ar->monitor_enabled) { 2129 !ar->monitor_enabled) {
2130 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor %d start\n",
2131 ar->monitor_vdev_id);
2132
2108 ret = ath10k_monitor_start(ar, ar->monitor_vdev_id); 2133 ret = ath10k_monitor_start(ar, ar->monitor_vdev_id);
2109 if (ret) 2134 if (ret)
2110 ath10k_warn("Unable to start monitor mode\n"); 2135 ath10k_warn("Unable to start monitor mode\n");
2111 else
2112 ath10k_dbg(ATH10K_DBG_MAC, "Monitor mode started\n");
2113 } else if (!(ar->filter_flags & FIF_PROMISC_IN_BSS) && 2136 } else if (!(ar->filter_flags & FIF_PROMISC_IN_BSS) &&
2114 ar->monitor_enabled) { 2137 ar->monitor_enabled) {
2138 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor %d stop\n",
2139 ar->monitor_vdev_id);
2140
2115 ret = ath10k_monitor_stop(ar); 2141 ret = ath10k_monitor_stop(ar);
2116 if (ret) 2142 if (ret)
2117 ath10k_warn("Unable to stop monitor mode\n"); 2143 ath10k_warn("Unable to stop monitor mode\n");
2118 else
2119 ath10k_dbg(ATH10K_DBG_MAC, "Monitor mode stopped\n");
2120 } 2144 }
2121 2145
2122 mutex_unlock(&ar->conf_mutex); 2146 mutex_unlock(&ar->conf_mutex);
@@ -2141,41 +2165,41 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2141 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 2165 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
2142 WMI_VDEV_PARAM_BEACON_INTERVAL, 2166 WMI_VDEV_PARAM_BEACON_INTERVAL,
2143 arvif->beacon_interval); 2167 arvif->beacon_interval);
2168 ath10k_dbg(ATH10K_DBG_MAC,
2169 "mac vdev %d beacon_interval %d\n",
2170 arvif->vdev_id, arvif->beacon_interval);
2171
2144 if (ret) 2172 if (ret)
2145 ath10k_warn("Failed to set beacon interval for VDEV: %d\n", 2173 ath10k_warn("Failed to set beacon interval for VDEV: %d\n",
2146 arvif->vdev_id); 2174 arvif->vdev_id);
2147 else
2148 ath10k_dbg(ATH10K_DBG_MAC,
2149 "Beacon interval: %d set for VDEV: %d\n",
2150 arvif->beacon_interval, arvif->vdev_id);
2151 } 2175 }
2152 2176
2153 if (changed & BSS_CHANGED_BEACON) { 2177 if (changed & BSS_CHANGED_BEACON) {
2178 ath10k_dbg(ATH10K_DBG_MAC,
2179 "vdev %d set beacon tx mode to staggered\n",
2180 arvif->vdev_id);
2181
2154 ret = ath10k_wmi_pdev_set_param(ar, 2182 ret = ath10k_wmi_pdev_set_param(ar,
2155 WMI_PDEV_PARAM_BEACON_TX_MODE, 2183 WMI_PDEV_PARAM_BEACON_TX_MODE,
2156 WMI_BEACON_STAGGERED_MODE); 2184 WMI_BEACON_STAGGERED_MODE);
2157 if (ret) 2185 if (ret)
2158 ath10k_warn("Failed to set beacon mode for VDEV: %d\n", 2186 ath10k_warn("Failed to set beacon mode for VDEV: %d\n",
2159 arvif->vdev_id); 2187 arvif->vdev_id);
2160 else
2161 ath10k_dbg(ATH10K_DBG_MAC,
2162 "Set staggered beacon mode for VDEV: %d\n",
2163 arvif->vdev_id);
2164 } 2188 }
2165 2189
2166 if (changed & BSS_CHANGED_BEACON_INFO) { 2190 if (changed & BSS_CHANGED_BEACON_INFO) {
2167 arvif->dtim_period = info->dtim_period; 2191 arvif->dtim_period = info->dtim_period;
2168 2192
2193 ath10k_dbg(ATH10K_DBG_MAC,
2194 "mac vdev %d dtim_period %d\n",
2195 arvif->vdev_id, arvif->dtim_period);
2196
2169 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 2197 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
2170 WMI_VDEV_PARAM_DTIM_PERIOD, 2198 WMI_VDEV_PARAM_DTIM_PERIOD,
2171 arvif->dtim_period); 2199 arvif->dtim_period);
2172 if (ret) 2200 if (ret)
2173 ath10k_warn("Failed to set dtim period for VDEV: %d\n", 2201 ath10k_warn("Failed to set dtim period for VDEV: %d\n",
2174 arvif->vdev_id); 2202 arvif->vdev_id);
2175 else
2176 ath10k_dbg(ATH10K_DBG_MAC,
2177 "Set dtim period: %d for VDEV: %d\n",
2178 arvif->dtim_period, arvif->vdev_id);
2179 } 2203 }
2180 2204
2181 if (changed & BSS_CHANGED_SSID && 2205 if (changed & BSS_CHANGED_SSID &&
@@ -2188,16 +2212,15 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2188 2212
2189 if (changed & BSS_CHANGED_BSSID) { 2213 if (changed & BSS_CHANGED_BSSID) {
2190 if (!is_zero_ether_addr(info->bssid)) { 2214 if (!is_zero_ether_addr(info->bssid)) {
2215 ath10k_dbg(ATH10K_DBG_MAC,
2216 "mac vdev %d create peer %pM\n",
2217 arvif->vdev_id, info->bssid);
2218
2191 ret = ath10k_peer_create(ar, arvif->vdev_id, 2219 ret = ath10k_peer_create(ar, arvif->vdev_id,
2192 info->bssid); 2220 info->bssid);
2193 if (ret) 2221 if (ret)
2194 ath10k_warn("Failed to add peer: %pM for VDEV: %d\n", 2222 ath10k_warn("Failed to add peer: %pM for VDEV: %d\n",
2195 info->bssid, arvif->vdev_id); 2223 info->bssid, arvif->vdev_id);
2196 else
2197 ath10k_dbg(ATH10K_DBG_MAC,
2198 "Added peer: %pM for VDEV: %d\n",
2199 info->bssid, arvif->vdev_id);
2200
2201 2224
2202 if (vif->type == NL80211_IFTYPE_STATION) { 2225 if (vif->type == NL80211_IFTYPE_STATION) {
2203 /* 2226 /*
@@ -2207,11 +2230,12 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2207 memcpy(arvif->u.sta.bssid, info->bssid, 2230 memcpy(arvif->u.sta.bssid, info->bssid,
2208 ETH_ALEN); 2231 ETH_ALEN);
2209 2232
2233 ath10k_dbg(ATH10K_DBG_MAC,
2234 "mac vdev %d start %pM\n",
2235 arvif->vdev_id, info->bssid);
2236
2237 /* FIXME: check return value */
2210 ret = ath10k_vdev_start(arvif); 2238 ret = ath10k_vdev_start(arvif);
2211 if (!ret)
2212 ath10k_dbg(ATH10K_DBG_MAC,
2213 "VDEV: %d started with BSSID: %pM\n",
2214 arvif->vdev_id, info->bssid);
2215 } 2239 }
2216 2240
2217 /* 2241 /*
@@ -2235,16 +2259,15 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2235 else 2259 else
2236 cts_prot = 0; 2260 cts_prot = 0;
2237 2261
2262 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d cts_prot %d\n",
2263 arvif->vdev_id, cts_prot);
2264
2238 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 2265 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
2239 WMI_VDEV_PARAM_ENABLE_RTSCTS, 2266 WMI_VDEV_PARAM_ENABLE_RTSCTS,
2240 cts_prot); 2267 cts_prot);
2241 if (ret) 2268 if (ret)
2242 ath10k_warn("Failed to set CTS prot for VDEV: %d\n", 2269 ath10k_warn("Failed to set CTS prot for VDEV: %d\n",
2243 arvif->vdev_id); 2270 arvif->vdev_id);
2244 else
2245 ath10k_dbg(ATH10K_DBG_MAC,
2246 "Set CTS prot: %d for VDEV: %d\n",
2247 cts_prot, arvif->vdev_id);
2248 } 2271 }
2249 2272
2250 if (changed & BSS_CHANGED_ERP_SLOT) { 2273 if (changed & BSS_CHANGED_ERP_SLOT) {
@@ -2255,16 +2278,15 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2255 else 2278 else
2256 slottime = WMI_VDEV_SLOT_TIME_LONG; /* 20us */ 2279 slottime = WMI_VDEV_SLOT_TIME_LONG; /* 20us */
2257 2280
2281 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d slot_time %d\n",
2282 arvif->vdev_id, slottime);
2283
2258 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 2284 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
2259 WMI_VDEV_PARAM_SLOT_TIME, 2285 WMI_VDEV_PARAM_SLOT_TIME,
2260 slottime); 2286 slottime);
2261 if (ret) 2287 if (ret)
2262 ath10k_warn("Failed to set erp slot for VDEV: %d\n", 2288 ath10k_warn("Failed to set erp slot for VDEV: %d\n",
2263 arvif->vdev_id); 2289 arvif->vdev_id);
2264 else
2265 ath10k_dbg(ATH10K_DBG_MAC,
2266 "Set slottime: %d for VDEV: %d\n",
2267 slottime, arvif->vdev_id);
2268 } 2290 }
2269 2291
2270 if (changed & BSS_CHANGED_ERP_PREAMBLE) { 2292 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
@@ -2274,16 +2296,16 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2274 else 2296 else
2275 preamble = WMI_VDEV_PREAMBLE_LONG; 2297 preamble = WMI_VDEV_PREAMBLE_LONG;
2276 2298
2299 ath10k_dbg(ATH10K_DBG_MAC,
2300 "mac vdev %d preamble %dn",
2301 arvif->vdev_id, preamble);
2302
2277 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 2303 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
2278 WMI_VDEV_PARAM_PREAMBLE, 2304 WMI_VDEV_PARAM_PREAMBLE,
2279 preamble); 2305 preamble);
2280 if (ret) 2306 if (ret)
2281 ath10k_warn("Failed to set preamble for VDEV: %d\n", 2307 ath10k_warn("Failed to set preamble for VDEV: %d\n",
2282 arvif->vdev_id); 2308 arvif->vdev_id);
2283 else
2284 ath10k_dbg(ATH10K_DBG_MAC,
2285 "Set preamble: %d for VDEV: %d\n",
2286 preamble, arvif->vdev_id);
2287 } 2309 }
2288 2310
2289 if (changed & BSS_CHANGED_ASSOC) { 2311 if (changed & BSS_CHANGED_ASSOC) {
@@ -2474,27 +2496,26 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
2474 /* 2496 /*
2475 * New station addition. 2497 * New station addition.
2476 */ 2498 */
2499 ath10k_dbg(ATH10K_DBG_MAC,
2500 "mac vdev %d peer create %pM (new sta)\n",
2501 arvif->vdev_id, sta->addr);
2502
2477 ret = ath10k_peer_create(ar, arvif->vdev_id, sta->addr); 2503 ret = ath10k_peer_create(ar, arvif->vdev_id, sta->addr);
2478 if (ret) 2504 if (ret)
2479 ath10k_warn("Failed to add peer: %pM for VDEV: %d\n", 2505 ath10k_warn("Failed to add peer: %pM for VDEV: %d\n",
2480 sta->addr, arvif->vdev_id); 2506 sta->addr, arvif->vdev_id);
2481 else
2482 ath10k_dbg(ATH10K_DBG_MAC,
2483 "Added peer: %pM for VDEV: %d\n",
2484 sta->addr, arvif->vdev_id);
2485 } else if ((old_state == IEEE80211_STA_NONE && 2507 } else if ((old_state == IEEE80211_STA_NONE &&
2486 new_state == IEEE80211_STA_NOTEXIST)) { 2508 new_state == IEEE80211_STA_NOTEXIST)) {
2487 /* 2509 /*
2488 * Existing station deletion. 2510 * Existing station deletion.
2489 */ 2511 */
2512 ath10k_dbg(ATH10K_DBG_MAC,
2513 "mac vdev %d peer delete %pM (sta gone)\n",
2514 arvif->vdev_id, sta->addr);
2490 ret = ath10k_peer_delete(ar, arvif->vdev_id, sta->addr); 2515 ret = ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
2491 if (ret) 2516 if (ret)
2492 ath10k_warn("Failed to delete peer: %pM for VDEV: %d\n", 2517 ath10k_warn("Failed to delete peer: %pM for VDEV: %d\n",
2493 sta->addr, arvif->vdev_id); 2518 sta->addr, arvif->vdev_id);
2494 else
2495 ath10k_dbg(ATH10K_DBG_MAC,
2496 "Removed peer: %pM for VDEV: %d\n",
2497 sta->addr, arvif->vdev_id);
2498 2519
2499 if (vif->type == NL80211_IFTYPE_STATION) 2520 if (vif->type == NL80211_IFTYPE_STATION)
2500 ath10k_bss_disassoc(hw, vif); 2521 ath10k_bss_disassoc(hw, vif);
@@ -2505,14 +2526,13 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
2505 /* 2526 /*
2506 * New association. 2527 * New association.
2507 */ 2528 */
2529 ath10k_dbg(ATH10K_DBG_MAC, "mac sta %pM associated\n",
2530 sta->addr);
2531
2508 ret = ath10k_station_assoc(ar, arvif, sta); 2532 ret = ath10k_station_assoc(ar, arvif, sta);
2509 if (ret) 2533 if (ret)
2510 ath10k_warn("Failed to associate station: %pM\n", 2534 ath10k_warn("Failed to associate station: %pM\n",
2511 sta->addr); 2535 sta->addr);
2512 else
2513 ath10k_dbg(ATH10K_DBG_MAC,
2514 "Station %pM moved to assoc state\n",
2515 sta->addr);
2516 } else if (old_state == IEEE80211_STA_ASSOC && 2536 } else if (old_state == IEEE80211_STA_ASSOC &&
2517 new_state == IEEE80211_STA_AUTH && 2537 new_state == IEEE80211_STA_AUTH &&
2518 (vif->type == NL80211_IFTYPE_AP || 2538 (vif->type == NL80211_IFTYPE_AP ||
@@ -2520,14 +2540,13 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
2520 /* 2540 /*
2521 * Disassociation. 2541 * Disassociation.
2522 */ 2542 */
2543 ath10k_dbg(ATH10K_DBG_MAC, "mac sta %pM disassociated\n",
2544 sta->addr);
2545
2523 ret = ath10k_station_disassoc(ar, arvif, sta); 2546 ret = ath10k_station_disassoc(ar, arvif, sta);
2524 if (ret) 2547 if (ret)
2525 ath10k_warn("Failed to disassociate station: %pM\n", 2548 ath10k_warn("Failed to disassociate station: %pM\n",
2526 sta->addr); 2549 sta->addr);
2527 else
2528 ath10k_dbg(ATH10K_DBG_MAC,
2529 "Station %pM moved to disassociated state\n",
2530 sta->addr);
2531 } 2550 }
2532 2551
2533 mutex_unlock(&ar->conf_mutex); 2552 mutex_unlock(&ar->conf_mutex);
@@ -2747,14 +2766,13 @@ static void ath10k_set_rts_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
2747 if (ar_iter->ar->state == ATH10K_STATE_RESTARTED) 2766 if (ar_iter->ar->state == ATH10K_STATE_RESTARTED)
2748 return; 2767 return;
2749 2768
2769 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d rts_threshold %d\n",
2770 arvif->vdev_id, rts);
2771
2750 ar_iter->ret = ath10k_mac_set_rts(arvif, rts); 2772 ar_iter->ret = ath10k_mac_set_rts(arvif, rts);
2751 if (ar_iter->ret) 2773 if (ar_iter->ret)
2752 ath10k_warn("Failed to set RTS threshold for VDEV: %d\n", 2774 ath10k_warn("Failed to set RTS threshold for VDEV: %d\n",
2753 arvif->vdev_id); 2775 arvif->vdev_id);
2754 else
2755 ath10k_dbg(ATH10K_DBG_MAC,
2756 "Set RTS threshold: %d for VDEV: %d\n",
2757 rts, arvif->vdev_id);
2758} 2776}
2759 2777
2760static int ath10k_set_rts_threshold(struct ieee80211_hw *hw, u32 value) 2778static int ath10k_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
@@ -2789,14 +2807,13 @@ static void ath10k_set_frag_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
2789 if (ar_iter->ar->state == ATH10K_STATE_RESTARTED) 2807 if (ar_iter->ar->state == ATH10K_STATE_RESTARTED)
2790 return; 2808 return;
2791 2809
2810 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d fragmentation_threshold %d\n",
2811 arvif->vdev_id, frag);
2812
2792 ar_iter->ret = ath10k_mac_set_frag(arvif, frag); 2813 ar_iter->ret = ath10k_mac_set_frag(arvif, frag);
2793 if (ar_iter->ret) 2814 if (ar_iter->ret)
2794 ath10k_warn("Failed to set frag threshold for VDEV: %d\n", 2815 ath10k_warn("Failed to set frag threshold for VDEV: %d\n",
2795 arvif->vdev_id); 2816 arvif->vdev_id);
2796 else
2797 ath10k_dbg(ATH10K_DBG_MAC,
2798 "Set frag threshold: %d for VDEV: %d\n",
2799 frag, arvif->vdev_id);
2800} 2817}
2801 2818
2802static int ath10k_set_frag_threshold(struct ieee80211_hw *hw, u32 value) 2819static int ath10k_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
@@ -2836,8 +2853,7 @@ static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
2836 bool empty; 2853 bool empty;
2837 2854
2838 spin_lock_bh(&ar->htt.tx_lock); 2855 spin_lock_bh(&ar->htt.tx_lock);
2839 empty = bitmap_empty(ar->htt.used_msdu_ids, 2856 empty = (ar->htt.num_pending_tx == 0);
2840 ar->htt.max_num_pending_tx);
2841 spin_unlock_bh(&ar->htt.tx_lock); 2857 spin_unlock_bh(&ar->htt.tx_lock);
2842 2858
2843 skip = (ar->state == ATH10K_STATE_WEDGED); 2859 skip = (ar->state == ATH10K_STATE_WEDGED);
@@ -3326,6 +3342,10 @@ int ath10k_mac_register(struct ath10k *ar)
3326 IEEE80211_HW_WANT_MONITOR_VIF | 3342 IEEE80211_HW_WANT_MONITOR_VIF |
3327 IEEE80211_HW_AP_LINK_PS; 3343 IEEE80211_HW_AP_LINK_PS;
3328 3344
3345 /* MSDU can have HTT TX fragment pushed in front. The additional 4
3346 * bytes is used for padding/alignment if necessary. */
3347 ar->hw->extra_tx_headroom += sizeof(struct htt_data_tx_desc_frag)*2 + 4;
3348
3329 if (ar->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS) 3349 if (ar->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS)
3330 ar->hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS; 3350 ar->hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS;
3331 3351
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index e2f9ef50b1bd..dff23d97bed0 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -36,11 +36,9 @@ static unsigned int ath10k_target_ps;
36module_param(ath10k_target_ps, uint, 0644); 36module_param(ath10k_target_ps, uint, 0644);
37MODULE_PARM_DESC(ath10k_target_ps, "Enable ath10k Target (SoC) PS option"); 37MODULE_PARM_DESC(ath10k_target_ps, "Enable ath10k Target (SoC) PS option");
38 38
39#define QCA988X_1_0_DEVICE_ID (0xabcd)
40#define QCA988X_2_0_DEVICE_ID (0x003c) 39#define QCA988X_2_0_DEVICE_ID (0x003c)
41 40
42static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = { 41static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = {
43 { PCI_VDEVICE(ATHEROS, QCA988X_1_0_DEVICE_ID) }, /* PCI-E QCA988X V1 */
44 { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */ 42 { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */
45 {0} 43 {0}
46}; 44};
@@ -50,9 +48,9 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address,
50 48
51static void ath10k_pci_process_ce(struct ath10k *ar); 49static void ath10k_pci_process_ce(struct ath10k *ar);
52static int ath10k_pci_post_rx(struct ath10k *ar); 50static int ath10k_pci_post_rx(struct ath10k *ar);
53static int ath10k_pci_post_rx_pipe(struct hif_ce_pipe_info *pipe_info, 51static int ath10k_pci_post_rx_pipe(struct ath10k_pci_pipe *pipe_info,
54 int num); 52 int num);
55static void ath10k_pci_rx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info); 53static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info);
56static void ath10k_pci_stop_ce(struct ath10k *ar); 54static void ath10k_pci_stop_ce(struct ath10k *ar);
57static void ath10k_pci_device_reset(struct ath10k *ar); 55static void ath10k_pci_device_reset(struct ath10k *ar);
58static int ath10k_pci_reset_target(struct ath10k *ar); 56static int ath10k_pci_reset_target(struct ath10k *ar);
@@ -60,43 +58,145 @@ static int ath10k_pci_start_intr(struct ath10k *ar);
60static void ath10k_pci_stop_intr(struct ath10k *ar); 58static void ath10k_pci_stop_intr(struct ath10k *ar);
61 59
62static const struct ce_attr host_ce_config_wlan[] = { 60static const struct ce_attr host_ce_config_wlan[] = {
63 /* host->target HTC control and raw streams */ 61 /* CE0: host->target HTC control and raw streams */
64 { /* CE0 */ CE_ATTR_FLAGS, 0, 16, 256, 0, NULL,}, 62 {
65 /* could be moved to share CE3 */ 63 .flags = CE_ATTR_FLAGS,
66 /* target->host HTT + HTC control */ 64 .src_nentries = 16,
67 { /* CE1 */ CE_ATTR_FLAGS, 0, 0, 512, 512, NULL,}, 65 .src_sz_max = 256,
68 /* target->host WMI */ 66 .dest_nentries = 0,
69 { /* CE2 */ CE_ATTR_FLAGS, 0, 0, 2048, 32, NULL,}, 67 },
70 /* host->target WMI */ 68
71 { /* CE3 */ CE_ATTR_FLAGS, 0, 32, 2048, 0, NULL,}, 69 /* CE1: target->host HTT + HTC control */
72 /* host->target HTT */ 70 {
73 { /* CE4 */ CE_ATTR_FLAGS | CE_ATTR_DIS_INTR, 0, 71 .flags = CE_ATTR_FLAGS,
74 CE_HTT_H2T_MSG_SRC_NENTRIES, 256, 0, NULL,}, 72 .src_nentries = 0,
75 /* unused */ 73 .src_sz_max = 512,
76 { /* CE5 */ CE_ATTR_FLAGS, 0, 0, 0, 0, NULL,}, 74 .dest_nentries = 512,
77 /* Target autonomous hif_memcpy */ 75 },
78 { /* CE6 */ CE_ATTR_FLAGS, 0, 0, 0, 0, NULL,}, 76
79 /* ce_diag, the Diagnostic Window */ 77 /* CE2: target->host WMI */
80 { /* CE7 */ CE_ATTR_FLAGS, 0, 2, DIAG_TRANSFER_LIMIT, 2, NULL,}, 78 {
79 .flags = CE_ATTR_FLAGS,
80 .src_nentries = 0,
81 .src_sz_max = 2048,
82 .dest_nentries = 32,
83 },
84
85 /* CE3: host->target WMI */
86 {
87 .flags = CE_ATTR_FLAGS,
88 .src_nentries = 32,
89 .src_sz_max = 2048,
90 .dest_nentries = 0,
91 },
92
93 /* CE4: host->target HTT */
94 {
95 .flags = CE_ATTR_FLAGS | CE_ATTR_DIS_INTR,
96 .src_nentries = CE_HTT_H2T_MSG_SRC_NENTRIES,
97 .src_sz_max = 256,
98 .dest_nentries = 0,
99 },
100
101 /* CE5: unused */
102 {
103 .flags = CE_ATTR_FLAGS,
104 .src_nentries = 0,
105 .src_sz_max = 0,
106 .dest_nentries = 0,
107 },
108
109 /* CE6: target autonomous hif_memcpy */
110 {
111 .flags = CE_ATTR_FLAGS,
112 .src_nentries = 0,
113 .src_sz_max = 0,
114 .dest_nentries = 0,
115 },
116
117 /* CE7: ce_diag, the Diagnostic Window */
118 {
119 .flags = CE_ATTR_FLAGS,
120 .src_nentries = 2,
121 .src_sz_max = DIAG_TRANSFER_LIMIT,
122 .dest_nentries = 2,
123 },
81}; 124};
82 125
83/* Target firmware's Copy Engine configuration. */ 126/* Target firmware's Copy Engine configuration. */
84static const struct ce_pipe_config target_ce_config_wlan[] = { 127static const struct ce_pipe_config target_ce_config_wlan[] = {
85 /* host->target HTC control and raw streams */ 128 /* CE0: host->target HTC control and raw streams */
86 { /* CE0 */ 0, PIPEDIR_OUT, 32, 256, CE_ATTR_FLAGS, 0,}, 129 {
87 /* target->host HTT + HTC control */ 130 .pipenum = 0,
88 { /* CE1 */ 1, PIPEDIR_IN, 32, 512, CE_ATTR_FLAGS, 0,}, 131 .pipedir = PIPEDIR_OUT,
89 /* target->host WMI */ 132 .nentries = 32,
90 { /* CE2 */ 2, PIPEDIR_IN, 32, 2048, CE_ATTR_FLAGS, 0,}, 133 .nbytes_max = 256,
91 /* host->target WMI */ 134 .flags = CE_ATTR_FLAGS,
92 { /* CE3 */ 3, PIPEDIR_OUT, 32, 2048, CE_ATTR_FLAGS, 0,}, 135 .reserved = 0,
93 /* host->target HTT */ 136 },
94 { /* CE4 */ 4, PIPEDIR_OUT, 256, 256, CE_ATTR_FLAGS, 0,}, 137
138 /* CE1: target->host HTT + HTC control */
139 {
140 .pipenum = 1,
141 .pipedir = PIPEDIR_IN,
142 .nentries = 32,
143 .nbytes_max = 512,
144 .flags = CE_ATTR_FLAGS,
145 .reserved = 0,
146 },
147
148 /* CE2: target->host WMI */
149 {
150 .pipenum = 2,
151 .pipedir = PIPEDIR_IN,
152 .nentries = 32,
153 .nbytes_max = 2048,
154 .flags = CE_ATTR_FLAGS,
155 .reserved = 0,
156 },
157
158 /* CE3: host->target WMI */
159 {
160 .pipenum = 3,
161 .pipedir = PIPEDIR_OUT,
162 .nentries = 32,
163 .nbytes_max = 2048,
164 .flags = CE_ATTR_FLAGS,
165 .reserved = 0,
166 },
167
168 /* CE4: host->target HTT */
169 {
170 .pipenum = 4,
171 .pipedir = PIPEDIR_OUT,
172 .nentries = 256,
173 .nbytes_max = 256,
174 .flags = CE_ATTR_FLAGS,
175 .reserved = 0,
176 },
177
95 /* NB: 50% of src nentries, since tx has 2 frags */ 178 /* NB: 50% of src nentries, since tx has 2 frags */
96 /* unused */ 179
97 { /* CE5 */ 5, PIPEDIR_OUT, 32, 2048, CE_ATTR_FLAGS, 0,}, 180 /* CE5: unused */
98 /* Reserved for target autonomous hif_memcpy */ 181 {
99 { /* CE6 */ 6, PIPEDIR_INOUT, 32, 4096, CE_ATTR_FLAGS, 0,}, 182 .pipenum = 5,
183 .pipedir = PIPEDIR_OUT,
184 .nentries = 32,
185 .nbytes_max = 2048,
186 .flags = CE_ATTR_FLAGS,
187 .reserved = 0,
188 },
189
190 /* CE6: Reserved for target autonomous hif_memcpy */
191 {
192 .pipenum = 6,
193 .pipedir = PIPEDIR_INOUT,
194 .nentries = 32,
195 .nbytes_max = 4096,
196 .flags = CE_ATTR_FLAGS,
197 .reserved = 0,
198 },
199
100 /* CE7 used only by Host */ 200 /* CE7 used only by Host */
101}; 201};
102 202
@@ -114,7 +214,7 @@ static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data,
114 unsigned int completed_nbytes, orig_nbytes, remaining_bytes; 214 unsigned int completed_nbytes, orig_nbytes, remaining_bytes;
115 unsigned int id; 215 unsigned int id;
116 unsigned int flags; 216 unsigned int flags;
117 struct ce_state *ce_diag; 217 struct ath10k_ce_pipe *ce_diag;
118 /* Host buffer address in CE space */ 218 /* Host buffer address in CE space */
119 u32 ce_data; 219 u32 ce_data;
120 dma_addr_t ce_data_base = 0; 220 dma_addr_t ce_data_base = 0;
@@ -278,7 +378,7 @@ static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
278 unsigned int completed_nbytes, orig_nbytes, remaining_bytes; 378 unsigned int completed_nbytes, orig_nbytes, remaining_bytes;
279 unsigned int id; 379 unsigned int id;
280 unsigned int flags; 380 unsigned int flags;
281 struct ce_state *ce_diag; 381 struct ath10k_ce_pipe *ce_diag;
282 void *data_buf = NULL; 382 void *data_buf = NULL;
283 u32 ce_data; /* Host buffer address in CE space */ 383 u32 ce_data; /* Host buffer address in CE space */
284 dma_addr_t ce_data_base = 0; 384 dma_addr_t ce_data_base = 0;
@@ -437,7 +537,7 @@ static void ath10k_pci_wait(struct ath10k *ar)
437 ath10k_warn("Unable to wakeup target\n"); 537 ath10k_warn("Unable to wakeup target\n");
438} 538}
439 539
440void ath10k_do_pci_wake(struct ath10k *ar) 540int ath10k_do_pci_wake(struct ath10k *ar)
441{ 541{
442 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 542 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
443 void __iomem *pci_addr = ar_pci->mem; 543 void __iomem *pci_addr = ar_pci->mem;
@@ -453,18 +553,19 @@ void ath10k_do_pci_wake(struct ath10k *ar)
453 atomic_inc(&ar_pci->keep_awake_count); 553 atomic_inc(&ar_pci->keep_awake_count);
454 554
455 if (ar_pci->verified_awake) 555 if (ar_pci->verified_awake)
456 return; 556 return 0;
457 557
458 for (;;) { 558 for (;;) {
459 if (ath10k_pci_target_is_awake(ar)) { 559 if (ath10k_pci_target_is_awake(ar)) {
460 ar_pci->verified_awake = true; 560 ar_pci->verified_awake = true;
461 break; 561 return 0;
462 } 562 }
463 563
464 if (tot_delay > PCIE_WAKE_TIMEOUT) { 564 if (tot_delay > PCIE_WAKE_TIMEOUT) {
465 ath10k_warn("target takes too long to wake up (awake count %d)\n", 565 ath10k_warn("target took longer %d us to wake up (awake count %d)\n",
566 PCIE_WAKE_TIMEOUT,
466 atomic_read(&ar_pci->keep_awake_count)); 567 atomic_read(&ar_pci->keep_awake_count));
467 break; 568 return -ETIMEDOUT;
468 } 569 }
469 570
470 udelay(curr_delay); 571 udelay(curr_delay);
@@ -493,7 +594,7 @@ void ath10k_do_pci_sleep(struct ath10k *ar)
493 * FIXME: Handle OOM properly. 594 * FIXME: Handle OOM properly.
494 */ 595 */
495static inline 596static inline
496struct ath10k_pci_compl *get_free_compl(struct hif_ce_pipe_info *pipe_info) 597struct ath10k_pci_compl *get_free_compl(struct ath10k_pci_pipe *pipe_info)
497{ 598{
498 struct ath10k_pci_compl *compl = NULL; 599 struct ath10k_pci_compl *compl = NULL;
499 600
@@ -511,39 +612,28 @@ exit:
511} 612}
512 613
513/* Called by lower (CE) layer when a send to Target completes. */ 614/* Called by lower (CE) layer when a send to Target completes. */
514static void ath10k_pci_ce_send_done(struct ce_state *ce_state, 615static void ath10k_pci_ce_send_done(struct ath10k_ce_pipe *ce_state)
515 void *transfer_context,
516 u32 ce_data,
517 unsigned int nbytes,
518 unsigned int transfer_id)
519{ 616{
520 struct ath10k *ar = ce_state->ar; 617 struct ath10k *ar = ce_state->ar;
521 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 618 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
522 struct hif_ce_pipe_info *pipe_info = &ar_pci->pipe_info[ce_state->id]; 619 struct ath10k_pci_pipe *pipe_info = &ar_pci->pipe_info[ce_state->id];
523 struct ath10k_pci_compl *compl; 620 struct ath10k_pci_compl *compl;
524 bool process = false; 621 void *transfer_context;
525 622 u32 ce_data;
526 do { 623 unsigned int nbytes;
527 /* 624 unsigned int transfer_id;
528 * For the send completion of an item in sendlist, just
529 * increment num_sends_allowed. The upper layer callback will
530 * be triggered when last fragment is done with send.
531 */
532 if (transfer_context == CE_SENDLIST_ITEM_CTXT) {
533 spin_lock_bh(&pipe_info->pipe_lock);
534 pipe_info->num_sends_allowed++;
535 spin_unlock_bh(&pipe_info->pipe_lock);
536 continue;
537 }
538 625
626 while (ath10k_ce_completed_send_next(ce_state, &transfer_context,
627 &ce_data, &nbytes,
628 &transfer_id) == 0) {
539 compl = get_free_compl(pipe_info); 629 compl = get_free_compl(pipe_info);
540 if (!compl) 630 if (!compl)
541 break; 631 break;
542 632
543 compl->send_or_recv = HIF_CE_COMPLETE_SEND; 633 compl->state = ATH10K_PCI_COMPL_SEND;
544 compl->ce_state = ce_state; 634 compl->ce_state = ce_state;
545 compl->pipe_info = pipe_info; 635 compl->pipe_info = pipe_info;
546 compl->transfer_context = transfer_context; 636 compl->skb = transfer_context;
547 compl->nbytes = nbytes; 637 compl->nbytes = nbytes;
548 compl->transfer_id = transfer_id; 638 compl->transfer_id = transfer_id;
549 compl->flags = 0; 639 compl->flags = 0;
@@ -554,46 +644,36 @@ static void ath10k_pci_ce_send_done(struct ce_state *ce_state,
554 spin_lock_bh(&ar_pci->compl_lock); 644 spin_lock_bh(&ar_pci->compl_lock);
555 list_add_tail(&compl->list, &ar_pci->compl_process); 645 list_add_tail(&compl->list, &ar_pci->compl_process);
556 spin_unlock_bh(&ar_pci->compl_lock); 646 spin_unlock_bh(&ar_pci->compl_lock);
557 647 }
558 process = true;
559 } while (ath10k_ce_completed_send_next(ce_state,
560 &transfer_context,
561 &ce_data, &nbytes,
562 &transfer_id) == 0);
563
564 /*
565 * If only some of the items within a sendlist have completed,
566 * don't invoke completion processing until the entire sendlist
567 * has been sent.
568 */
569 if (!process)
570 return;
571 648
572 ath10k_pci_process_ce(ar); 649 ath10k_pci_process_ce(ar);
573} 650}
574 651
575/* Called by lower (CE) layer when data is received from the Target. */ 652/* Called by lower (CE) layer when data is received from the Target. */
576static void ath10k_pci_ce_recv_data(struct ce_state *ce_state, 653static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state)
577 void *transfer_context, u32 ce_data,
578 unsigned int nbytes,
579 unsigned int transfer_id,
580 unsigned int flags)
581{ 654{
582 struct ath10k *ar = ce_state->ar; 655 struct ath10k *ar = ce_state->ar;
583 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 656 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
584 struct hif_ce_pipe_info *pipe_info = &ar_pci->pipe_info[ce_state->id]; 657 struct ath10k_pci_pipe *pipe_info = &ar_pci->pipe_info[ce_state->id];
585 struct ath10k_pci_compl *compl; 658 struct ath10k_pci_compl *compl;
586 struct sk_buff *skb; 659 struct sk_buff *skb;
660 void *transfer_context;
661 u32 ce_data;
662 unsigned int nbytes;
663 unsigned int transfer_id;
664 unsigned int flags;
587 665
588 do { 666 while (ath10k_ce_completed_recv_next(ce_state, &transfer_context,
667 &ce_data, &nbytes, &transfer_id,
668 &flags) == 0) {
589 compl = get_free_compl(pipe_info); 669 compl = get_free_compl(pipe_info);
590 if (!compl) 670 if (!compl)
591 break; 671 break;
592 672
593 compl->send_or_recv = HIF_CE_COMPLETE_RECV; 673 compl->state = ATH10K_PCI_COMPL_RECV;
594 compl->ce_state = ce_state; 674 compl->ce_state = ce_state;
595 compl->pipe_info = pipe_info; 675 compl->pipe_info = pipe_info;
596 compl->transfer_context = transfer_context; 676 compl->skb = transfer_context;
597 compl->nbytes = nbytes; 677 compl->nbytes = nbytes;
598 compl->transfer_id = transfer_id; 678 compl->transfer_id = transfer_id;
599 compl->flags = flags; 679 compl->flags = flags;
@@ -608,12 +688,7 @@ static void ath10k_pci_ce_recv_data(struct ce_state *ce_state,
608 spin_lock_bh(&ar_pci->compl_lock); 688 spin_lock_bh(&ar_pci->compl_lock);
609 list_add_tail(&compl->list, &ar_pci->compl_process); 689 list_add_tail(&compl->list, &ar_pci->compl_process);
610 spin_unlock_bh(&ar_pci->compl_lock); 690 spin_unlock_bh(&ar_pci->compl_lock);
611 691 }
612 } while (ath10k_ce_completed_recv_next(ce_state,
613 &transfer_context,
614 &ce_data, &nbytes,
615 &transfer_id,
616 &flags) == 0);
617 692
618 ath10k_pci_process_ce(ar); 693 ath10k_pci_process_ce(ar);
619} 694}
@@ -625,15 +700,12 @@ static int ath10k_pci_hif_send_head(struct ath10k *ar, u8 pipe_id,
625{ 700{
626 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(nbuf); 701 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(nbuf);
627 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 702 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
628 struct hif_ce_pipe_info *pipe_info = &(ar_pci->pipe_info[pipe_id]); 703 struct ath10k_pci_pipe *pipe_info = &(ar_pci->pipe_info[pipe_id]);
629 struct ce_state *ce_hdl = pipe_info->ce_hdl; 704 struct ath10k_ce_pipe *ce_hdl = pipe_info->ce_hdl;
630 struct ce_sendlist sendlist;
631 unsigned int len; 705 unsigned int len;
632 u32 flags = 0; 706 u32 flags = 0;
633 int ret; 707 int ret;
634 708
635 memset(&sendlist, 0, sizeof(struct ce_sendlist));
636
637 len = min(bytes, nbuf->len); 709 len = min(bytes, nbuf->len);
638 bytes -= len; 710 bytes -= len;
639 711
@@ -648,8 +720,6 @@ static int ath10k_pci_hif_send_head(struct ath10k *ar, u8 pipe_id,
648 "ath10k tx: data: ", 720 "ath10k tx: data: ",
649 nbuf->data, nbuf->len); 721 nbuf->data, nbuf->len);
650 722
651 ath10k_ce_sendlist_buf_add(&sendlist, skb_cb->paddr, len, flags);
652
653 /* Make sure we have resources to handle this request */ 723 /* Make sure we have resources to handle this request */
654 spin_lock_bh(&pipe_info->pipe_lock); 724 spin_lock_bh(&pipe_info->pipe_lock);
655 if (!pipe_info->num_sends_allowed) { 725 if (!pipe_info->num_sends_allowed) {
@@ -660,7 +730,8 @@ static int ath10k_pci_hif_send_head(struct ath10k *ar, u8 pipe_id,
660 pipe_info->num_sends_allowed--; 730 pipe_info->num_sends_allowed--;
661 spin_unlock_bh(&pipe_info->pipe_lock); 731 spin_unlock_bh(&pipe_info->pipe_lock);
662 732
663 ret = ath10k_ce_sendlist_send(ce_hdl, nbuf, &sendlist, transfer_id); 733 ret = ath10k_ce_sendlist_send(ce_hdl, nbuf, transfer_id,
734 skb_cb->paddr, len, flags);
664 if (ret) 735 if (ret)
665 ath10k_warn("CE send failed: %p\n", nbuf); 736 ath10k_warn("CE send failed: %p\n", nbuf);
666 737
@@ -670,7 +741,7 @@ static int ath10k_pci_hif_send_head(struct ath10k *ar, u8 pipe_id,
670static u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe) 741static u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe)
671{ 742{
672 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 743 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
673 struct hif_ce_pipe_info *pipe_info = &(ar_pci->pipe_info[pipe]); 744 struct ath10k_pci_pipe *pipe_info = &(ar_pci->pipe_info[pipe]);
674 int ret; 745 int ret;
675 746
676 spin_lock_bh(&pipe_info->pipe_lock); 747 spin_lock_bh(&pipe_info->pipe_lock);
@@ -764,9 +835,9 @@ static void ath10k_pci_hif_set_callbacks(struct ath10k *ar,
764static int ath10k_pci_start_ce(struct ath10k *ar) 835static int ath10k_pci_start_ce(struct ath10k *ar)
765{ 836{
766 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 837 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
767 struct ce_state *ce_diag = ar_pci->ce_diag; 838 struct ath10k_ce_pipe *ce_diag = ar_pci->ce_diag;
768 const struct ce_attr *attr; 839 const struct ce_attr *attr;
769 struct hif_ce_pipe_info *pipe_info; 840 struct ath10k_pci_pipe *pipe_info;
770 struct ath10k_pci_compl *compl; 841 struct ath10k_pci_compl *compl;
771 int i, pipe_num, completions, disable_interrupts; 842 int i, pipe_num, completions, disable_interrupts;
772 843
@@ -805,15 +876,14 @@ static int ath10k_pci_start_ce(struct ath10k *ar)
805 continue; 876 continue;
806 877
807 for (i = 0; i < completions; i++) { 878 for (i = 0; i < completions; i++) {
808 compl = kmalloc(sizeof(struct ath10k_pci_compl), 879 compl = kmalloc(sizeof(*compl), GFP_KERNEL);
809 GFP_KERNEL);
810 if (!compl) { 880 if (!compl) {
811 ath10k_warn("No memory for completion state\n"); 881 ath10k_warn("No memory for completion state\n");
812 ath10k_pci_stop_ce(ar); 882 ath10k_pci_stop_ce(ar);
813 return -ENOMEM; 883 return -ENOMEM;
814 } 884 }
815 885
816 compl->send_or_recv = HIF_CE_COMPLETE_FREE; 886 compl->state = ATH10K_PCI_COMPL_FREE;
817 list_add_tail(&compl->list, &pipe_info->compl_free); 887 list_add_tail(&compl->list, &pipe_info->compl_free);
818 } 888 }
819 } 889 }
@@ -840,7 +910,7 @@ static void ath10k_pci_stop_ce(struct ath10k *ar)
840 * their associated resources */ 910 * their associated resources */
841 spin_lock_bh(&ar_pci->compl_lock); 911 spin_lock_bh(&ar_pci->compl_lock);
842 list_for_each_entry(compl, &ar_pci->compl_process, list) { 912 list_for_each_entry(compl, &ar_pci->compl_process, list) {
843 skb = (struct sk_buff *)compl->transfer_context; 913 skb = compl->skb;
844 ATH10K_SKB_CB(skb)->is_aborted = true; 914 ATH10K_SKB_CB(skb)->is_aborted = true;
845 } 915 }
846 spin_unlock_bh(&ar_pci->compl_lock); 916 spin_unlock_bh(&ar_pci->compl_lock);
@@ -850,7 +920,7 @@ static void ath10k_pci_cleanup_ce(struct ath10k *ar)
850{ 920{
851 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 921 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
852 struct ath10k_pci_compl *compl, *tmp; 922 struct ath10k_pci_compl *compl, *tmp;
853 struct hif_ce_pipe_info *pipe_info; 923 struct ath10k_pci_pipe *pipe_info;
854 struct sk_buff *netbuf; 924 struct sk_buff *netbuf;
855 int pipe_num; 925 int pipe_num;
856 926
@@ -861,7 +931,7 @@ static void ath10k_pci_cleanup_ce(struct ath10k *ar)
861 931
862 list_for_each_entry_safe(compl, tmp, &ar_pci->compl_process, list) { 932 list_for_each_entry_safe(compl, tmp, &ar_pci->compl_process, list) {
863 list_del(&compl->list); 933 list_del(&compl->list);
864 netbuf = (struct sk_buff *)compl->transfer_context; 934 netbuf = compl->skb;
865 dev_kfree_skb_any(netbuf); 935 dev_kfree_skb_any(netbuf);
866 kfree(compl); 936 kfree(compl);
867 } 937 }
@@ -912,12 +982,14 @@ static void ath10k_pci_process_ce(struct ath10k *ar)
912 list_del(&compl->list); 982 list_del(&compl->list);
913 spin_unlock_bh(&ar_pci->compl_lock); 983 spin_unlock_bh(&ar_pci->compl_lock);
914 984
915 if (compl->send_or_recv == HIF_CE_COMPLETE_SEND) { 985 switch (compl->state) {
986 case ATH10K_PCI_COMPL_SEND:
916 cb->tx_completion(ar, 987 cb->tx_completion(ar,
917 compl->transfer_context, 988 compl->skb,
918 compl->transfer_id); 989 compl->transfer_id);
919 send_done = 1; 990 send_done = 1;
920 } else { 991 break;
992 case ATH10K_PCI_COMPL_RECV:
921 ret = ath10k_pci_post_rx_pipe(compl->pipe_info, 1); 993 ret = ath10k_pci_post_rx_pipe(compl->pipe_info, 1);
922 if (ret) { 994 if (ret) {
923 ath10k_warn("Unable to post recv buffer for pipe: %d\n", 995 ath10k_warn("Unable to post recv buffer for pipe: %d\n",
@@ -925,7 +997,7 @@ static void ath10k_pci_process_ce(struct ath10k *ar)
925 break; 997 break;
926 } 998 }
927 999
928 skb = (struct sk_buff *)compl->transfer_context; 1000 skb = compl->skb;
929 nbytes = compl->nbytes; 1001 nbytes = compl->nbytes;
930 1002
931 ath10k_dbg(ATH10K_DBG_PCI, 1003 ath10k_dbg(ATH10K_DBG_PCI,
@@ -944,9 +1016,17 @@ static void ath10k_pci_process_ce(struct ath10k *ar)
944 nbytes, 1016 nbytes,
945 skb->len + skb_tailroom(skb)); 1017 skb->len + skb_tailroom(skb));
946 } 1018 }
1019 break;
1020 case ATH10K_PCI_COMPL_FREE:
1021 ath10k_warn("free completion cannot be processed\n");
1022 break;
1023 default:
1024 ath10k_warn("invalid completion state (%d)\n",
1025 compl->state);
1026 break;
947 } 1027 }
948 1028
949 compl->send_or_recv = HIF_CE_COMPLETE_FREE; 1029 compl->state = ATH10K_PCI_COMPL_FREE;
950 1030
951 /* 1031 /*
952 * Add completion back to the pipe's free list. 1032 * Add completion back to the pipe's free list.
@@ -1037,12 +1117,12 @@ static void ath10k_pci_hif_get_default_pipe(struct ath10k *ar,
1037 &dl_is_polled); 1117 &dl_is_polled);
1038} 1118}
1039 1119
1040static int ath10k_pci_post_rx_pipe(struct hif_ce_pipe_info *pipe_info, 1120static int ath10k_pci_post_rx_pipe(struct ath10k_pci_pipe *pipe_info,
1041 int num) 1121 int num)
1042{ 1122{
1043 struct ath10k *ar = pipe_info->hif_ce_state; 1123 struct ath10k *ar = pipe_info->hif_ce_state;
1044 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1124 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1045 struct ce_state *ce_state = pipe_info->ce_hdl; 1125 struct ath10k_ce_pipe *ce_state = pipe_info->ce_hdl;
1046 struct sk_buff *skb; 1126 struct sk_buff *skb;
1047 dma_addr_t ce_data; 1127 dma_addr_t ce_data;
1048 int i, ret = 0; 1128 int i, ret = 0;
@@ -1097,7 +1177,7 @@ err:
1097static int ath10k_pci_post_rx(struct ath10k *ar) 1177static int ath10k_pci_post_rx(struct ath10k *ar)
1098{ 1178{
1099 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1179 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1100 struct hif_ce_pipe_info *pipe_info; 1180 struct ath10k_pci_pipe *pipe_info;
1101 const struct ce_attr *attr; 1181 const struct ce_attr *attr;
1102 int pipe_num, ret = 0; 1182 int pipe_num, ret = 0;
1103 1183
@@ -1147,11 +1227,11 @@ static int ath10k_pci_hif_start(struct ath10k *ar)
1147 return 0; 1227 return 0;
1148} 1228}
1149 1229
1150static void ath10k_pci_rx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info) 1230static void ath10k_pci_rx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info)
1151{ 1231{
1152 struct ath10k *ar; 1232 struct ath10k *ar;
1153 struct ath10k_pci *ar_pci; 1233 struct ath10k_pci *ar_pci;
1154 struct ce_state *ce_hdl; 1234 struct ath10k_ce_pipe *ce_hdl;
1155 u32 buf_sz; 1235 u32 buf_sz;
1156 struct sk_buff *netbuf; 1236 struct sk_buff *netbuf;
1157 u32 ce_data; 1237 u32 ce_data;
@@ -1179,11 +1259,11 @@ static void ath10k_pci_rx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info)
1179 } 1259 }
1180} 1260}
1181 1261
1182static void ath10k_pci_tx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info) 1262static void ath10k_pci_tx_pipe_cleanup(struct ath10k_pci_pipe *pipe_info)
1183{ 1263{
1184 struct ath10k *ar; 1264 struct ath10k *ar;
1185 struct ath10k_pci *ar_pci; 1265 struct ath10k_pci *ar_pci;
1186 struct ce_state *ce_hdl; 1266 struct ath10k_ce_pipe *ce_hdl;
1187 struct sk_buff *netbuf; 1267 struct sk_buff *netbuf;
1188 u32 ce_data; 1268 u32 ce_data;
1189 unsigned int nbytes; 1269 unsigned int nbytes;
@@ -1206,15 +1286,14 @@ static void ath10k_pci_tx_pipe_cleanup(struct hif_ce_pipe_info *pipe_info)
1206 1286
1207 while (ath10k_ce_cancel_send_next(ce_hdl, (void **)&netbuf, 1287 while (ath10k_ce_cancel_send_next(ce_hdl, (void **)&netbuf,
1208 &ce_data, &nbytes, &id) == 0) { 1288 &ce_data, &nbytes, &id) == 0) {
1209 if (netbuf != CE_SENDLIST_ITEM_CTXT) 1289 /*
1210 /* 1290 * Indicate the completion to higer layer to free
1211 * Indicate the completion to higer layer to free 1291 * the buffer
1212 * the buffer 1292 */
1213 */ 1293 ATH10K_SKB_CB(netbuf)->is_aborted = true;
1214 ATH10K_SKB_CB(netbuf)->is_aborted = true; 1294 ar_pci->msg_callbacks_current.tx_completion(ar,
1215 ar_pci->msg_callbacks_current.tx_completion(ar, 1295 netbuf,
1216 netbuf, 1296 id);
1217 id);
1218 } 1297 }
1219} 1298}
1220 1299
@@ -1232,7 +1311,7 @@ static void ath10k_pci_buffer_cleanup(struct ath10k *ar)
1232 int pipe_num; 1311 int pipe_num;
1233 1312
1234 for (pipe_num = 0; pipe_num < ar_pci->ce_count; pipe_num++) { 1313 for (pipe_num = 0; pipe_num < ar_pci->ce_count; pipe_num++) {
1235 struct hif_ce_pipe_info *pipe_info; 1314 struct ath10k_pci_pipe *pipe_info;
1236 1315
1237 pipe_info = &ar_pci->pipe_info[pipe_num]; 1316 pipe_info = &ar_pci->pipe_info[pipe_num];
1238 ath10k_pci_rx_pipe_cleanup(pipe_info); 1317 ath10k_pci_rx_pipe_cleanup(pipe_info);
@@ -1243,7 +1322,7 @@ static void ath10k_pci_buffer_cleanup(struct ath10k *ar)
1243static void ath10k_pci_ce_deinit(struct ath10k *ar) 1322static void ath10k_pci_ce_deinit(struct ath10k *ar)
1244{ 1323{
1245 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1324 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1246 struct hif_ce_pipe_info *pipe_info; 1325 struct ath10k_pci_pipe *pipe_info;
1247 int pipe_num; 1326 int pipe_num;
1248 1327
1249 for (pipe_num = 0; pipe_num < ar_pci->ce_count; pipe_num++) { 1328 for (pipe_num = 0; pipe_num < ar_pci->ce_count; pipe_num++) {
@@ -1293,8 +1372,10 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
1293 void *resp, u32 *resp_len) 1372 void *resp, u32 *resp_len)
1294{ 1373{
1295 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1374 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1296 struct ce_state *ce_tx = ar_pci->pipe_info[BMI_CE_NUM_TO_TARG].ce_hdl; 1375 struct ath10k_pci_pipe *pci_tx = &ar_pci->pipe_info[BMI_CE_NUM_TO_TARG];
1297 struct ce_state *ce_rx = ar_pci->pipe_info[BMI_CE_NUM_TO_HOST].ce_hdl; 1376 struct ath10k_pci_pipe *pci_rx = &ar_pci->pipe_info[BMI_CE_NUM_TO_HOST];
1377 struct ath10k_ce_pipe *ce_tx = pci_tx->ce_hdl;
1378 struct ath10k_ce_pipe *ce_rx = pci_rx->ce_hdl;
1298 dma_addr_t req_paddr = 0; 1379 dma_addr_t req_paddr = 0;
1299 dma_addr_t resp_paddr = 0; 1380 dma_addr_t resp_paddr = 0;
1300 struct bmi_xfer xfer = {}; 1381 struct bmi_xfer xfer = {};
@@ -1378,13 +1459,16 @@ err_dma:
1378 return ret; 1459 return ret;
1379} 1460}
1380 1461
1381static void ath10k_pci_bmi_send_done(struct ce_state *ce_state, 1462static void ath10k_pci_bmi_send_done(struct ath10k_ce_pipe *ce_state)
1382 void *transfer_context,
1383 u32 data,
1384 unsigned int nbytes,
1385 unsigned int transfer_id)
1386{ 1463{
1387 struct bmi_xfer *xfer = transfer_context; 1464 struct bmi_xfer *xfer;
1465 u32 ce_data;
1466 unsigned int nbytes;
1467 unsigned int transfer_id;
1468
1469 if (ath10k_ce_completed_send_next(ce_state, (void **)&xfer, &ce_data,
1470 &nbytes, &transfer_id))
1471 return;
1388 1472
1389 if (xfer->wait_for_resp) 1473 if (xfer->wait_for_resp)
1390 return; 1474 return;
@@ -1392,14 +1476,17 @@ static void ath10k_pci_bmi_send_done(struct ce_state *ce_state,
1392 complete(&xfer->done); 1476 complete(&xfer->done);
1393} 1477}
1394 1478
1395static void ath10k_pci_bmi_recv_data(struct ce_state *ce_state, 1479static void ath10k_pci_bmi_recv_data(struct ath10k_ce_pipe *ce_state)
1396 void *transfer_context,
1397 u32 data,
1398 unsigned int nbytes,
1399 unsigned int transfer_id,
1400 unsigned int flags)
1401{ 1480{
1402 struct bmi_xfer *xfer = transfer_context; 1481 struct bmi_xfer *xfer;
1482 u32 ce_data;
1483 unsigned int nbytes;
1484 unsigned int transfer_id;
1485 unsigned int flags;
1486
1487 if (ath10k_ce_completed_recv_next(ce_state, (void **)&xfer, &ce_data,
1488 &nbytes, &transfer_id, &flags))
1489 return;
1403 1490
1404 if (!xfer->wait_for_resp) { 1491 if (!xfer->wait_for_resp) {
1405 ath10k_warn("unexpected: BMI data received; ignoring\n"); 1492 ath10k_warn("unexpected: BMI data received; ignoring\n");
@@ -1679,7 +1766,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
1679static int ath10k_pci_ce_init(struct ath10k *ar) 1766static int ath10k_pci_ce_init(struct ath10k *ar)
1680{ 1767{
1681 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1768 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1682 struct hif_ce_pipe_info *pipe_info; 1769 struct ath10k_pci_pipe *pipe_info;
1683 const struct ce_attr *attr; 1770 const struct ce_attr *attr;
1684 int pipe_num; 1771 int pipe_num;
1685 1772
@@ -1895,7 +1982,7 @@ static const struct ath10k_hif_ops ath10k_pci_hif_ops = {
1895 1982
1896static void ath10k_pci_ce_tasklet(unsigned long ptr) 1983static void ath10k_pci_ce_tasklet(unsigned long ptr)
1897{ 1984{
1898 struct hif_ce_pipe_info *pipe = (struct hif_ce_pipe_info *)ptr; 1985 struct ath10k_pci_pipe *pipe = (struct ath10k_pci_pipe *)ptr;
1899 struct ath10k_pci *ar_pci = pipe->ar_pci; 1986 struct ath10k_pci *ar_pci = pipe->ar_pci;
1900 1987
1901 ath10k_ce_per_engine_service(ar_pci->ar, pipe->pipe_num); 1988 ath10k_ce_per_engine_service(ar_pci->ar, pipe->pipe_num);
@@ -2212,18 +2299,13 @@ static int ath10k_pci_reset_target(struct ath10k *ar)
2212 2299
2213static void ath10k_pci_device_reset(struct ath10k *ar) 2300static void ath10k_pci_device_reset(struct ath10k *ar)
2214{ 2301{
2215 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
2216 void __iomem *mem = ar_pci->mem;
2217 int i; 2302 int i;
2218 u32 val; 2303 u32 val;
2219 2304
2220 if (!SOC_GLOBAL_RESET_ADDRESS) 2305 if (!SOC_GLOBAL_RESET_ADDRESS)
2221 return; 2306 return;
2222 2307
2223 if (!mem) 2308 ath10k_pci_reg_write32(ar, PCIE_SOC_WAKE_ADDRESS,
2224 return;
2225
2226 ath10k_pci_reg_write32(mem, PCIE_SOC_WAKE_ADDRESS,
2227 PCIE_SOC_WAKE_V_MASK); 2309 PCIE_SOC_WAKE_V_MASK);
2228 for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) { 2310 for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) {
2229 if (ath10k_pci_target_is_awake(ar)) 2311 if (ath10k_pci_target_is_awake(ar))
@@ -2232,12 +2314,12 @@ static void ath10k_pci_device_reset(struct ath10k *ar)
2232 } 2314 }
2233 2315
2234 /* Put Target, including PCIe, into RESET. */ 2316 /* Put Target, including PCIe, into RESET. */
2235 val = ath10k_pci_reg_read32(mem, SOC_GLOBAL_RESET_ADDRESS); 2317 val = ath10k_pci_reg_read32(ar, SOC_GLOBAL_RESET_ADDRESS);
2236 val |= 1; 2318 val |= 1;
2237 ath10k_pci_reg_write32(mem, SOC_GLOBAL_RESET_ADDRESS, val); 2319 ath10k_pci_reg_write32(ar, SOC_GLOBAL_RESET_ADDRESS, val);
2238 2320
2239 for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) { 2321 for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) {
2240 if (ath10k_pci_reg_read32(mem, RTC_STATE_ADDRESS) & 2322 if (ath10k_pci_reg_read32(ar, RTC_STATE_ADDRESS) &
2241 RTC_STATE_COLD_RESET_MASK) 2323 RTC_STATE_COLD_RESET_MASK)
2242 break; 2324 break;
2243 msleep(1); 2325 msleep(1);
@@ -2245,16 +2327,16 @@ static void ath10k_pci_device_reset(struct ath10k *ar)
2245 2327
2246 /* Pull Target, including PCIe, out of RESET. */ 2328 /* Pull Target, including PCIe, out of RESET. */
2247 val &= ~1; 2329 val &= ~1;
2248 ath10k_pci_reg_write32(mem, SOC_GLOBAL_RESET_ADDRESS, val); 2330 ath10k_pci_reg_write32(ar, SOC_GLOBAL_RESET_ADDRESS, val);
2249 2331
2250 for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) { 2332 for (i = 0; i < ATH_PCI_RESET_WAIT_MAX; i++) {
2251 if (!(ath10k_pci_reg_read32(mem, RTC_STATE_ADDRESS) & 2333 if (!(ath10k_pci_reg_read32(ar, RTC_STATE_ADDRESS) &
2252 RTC_STATE_COLD_RESET_MASK)) 2334 RTC_STATE_COLD_RESET_MASK))
2253 break; 2335 break;
2254 msleep(1); 2336 msleep(1);
2255 } 2337 }
2256 2338
2257 ath10k_pci_reg_write32(mem, PCIE_SOC_WAKE_ADDRESS, PCIE_SOC_WAKE_RESET); 2339 ath10k_pci_reg_write32(ar, PCIE_SOC_WAKE_ADDRESS, PCIE_SOC_WAKE_RESET);
2258} 2340}
2259 2341
2260static void ath10k_pci_dump_features(struct ath10k_pci *ar_pci) 2342static void ath10k_pci_dump_features(struct ath10k_pci *ar_pci)
@@ -2267,13 +2349,10 @@ static void ath10k_pci_dump_features(struct ath10k_pci *ar_pci)
2267 2349
2268 switch (i) { 2350 switch (i) {
2269 case ATH10K_PCI_FEATURE_MSI_X: 2351 case ATH10K_PCI_FEATURE_MSI_X:
2270 ath10k_dbg(ATH10K_DBG_PCI, "device supports MSI-X\n"); 2352 ath10k_dbg(ATH10K_DBG_BOOT, "device supports MSI-X\n");
2271 break;
2272 case ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND:
2273 ath10k_dbg(ATH10K_DBG_PCI, "QCA988X_1.0 workaround enabled\n");
2274 break; 2353 break;
2275 case ATH10K_PCI_FEATURE_SOC_POWER_SAVE: 2354 case ATH10K_PCI_FEATURE_SOC_POWER_SAVE:
2276 ath10k_dbg(ATH10K_DBG_PCI, "QCA98XX SoC power save enabled\n"); 2355 ath10k_dbg(ATH10K_DBG_BOOT, "QCA98XX SoC power save enabled\n");
2277 break; 2356 break;
2278 } 2357 }
2279 } 2358 }
@@ -2286,7 +2365,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2286 int ret = 0; 2365 int ret = 0;
2287 struct ath10k *ar; 2366 struct ath10k *ar;
2288 struct ath10k_pci *ar_pci; 2367 struct ath10k_pci *ar_pci;
2289 u32 lcr_val; 2368 u32 lcr_val, chip_id;
2290 2369
2291 ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); 2370 ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__);
2292 2371
@@ -2298,9 +2377,6 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2298 ar_pci->dev = &pdev->dev; 2377 ar_pci->dev = &pdev->dev;
2299 2378
2300 switch (pci_dev->device) { 2379 switch (pci_dev->device) {
2301 case QCA988X_1_0_DEVICE_ID:
2302 set_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features);
2303 break;
2304 case QCA988X_2_0_DEVICE_ID: 2380 case QCA988X_2_0_DEVICE_ID:
2305 set_bit(ATH10K_PCI_FEATURE_MSI_X, ar_pci->features); 2381 set_bit(ATH10K_PCI_FEATURE_MSI_X, ar_pci->features);
2306 break; 2382 break;
@@ -2322,10 +2398,6 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2322 goto err_ar_pci; 2398 goto err_ar_pci;
2323 } 2399 }
2324 2400
2325 /* Enable QCA988X_1.0 HW workarounds */
2326 if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features))
2327 spin_lock_init(&ar_pci->hw_v1_workaround_lock);
2328
2329 ar_pci->ar = ar; 2401 ar_pci->ar = ar;
2330 ar_pci->fw_indicator_address = FW_INDICATOR_ADDRESS; 2402 ar_pci->fw_indicator_address = FW_INDICATOR_ADDRESS;
2331 atomic_set(&ar_pci->keep_awake_count, 0); 2403 atomic_set(&ar_pci->keep_awake_count, 0);
@@ -2395,9 +2467,20 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2395 2467
2396 spin_lock_init(&ar_pci->ce_lock); 2468 spin_lock_init(&ar_pci->ce_lock);
2397 2469
2398 ar_pci->cacheline_sz = dma_get_cache_alignment(); 2470 ret = ath10k_do_pci_wake(ar);
2471 if (ret) {
2472 ath10k_err("Failed to get chip id: %d\n", ret);
2473 return ret;
2474 }
2475
2476 chip_id = ath10k_pci_read32(ar,
2477 RTC_SOC_BASE_ADDRESS + SOC_CHIP_ID_ADDRESS);
2478
2479 ath10k_do_pci_sleep(ar);
2480
2481 ath10k_dbg(ATH10K_DBG_BOOT, "boot pci_mem 0x%p\n", ar_pci->mem);
2399 2482
2400 ret = ath10k_core_register(ar); 2483 ret = ath10k_core_register(ar, chip_id);
2401 if (ret) { 2484 if (ret) {
2402 ath10k_err("could not register driver core (%d)\n", ret); 2485 ath10k_err("could not register driver core (%d)\n", ret);
2403 goto err_iomap; 2486 goto err_iomap;
@@ -2414,7 +2497,6 @@ err_region:
2414err_device: 2497err_device:
2415 pci_disable_device(pdev); 2498 pci_disable_device(pdev);
2416err_ar: 2499err_ar:
2417 pci_set_drvdata(pdev, NULL);
2418 ath10k_core_destroy(ar); 2500 ath10k_core_destroy(ar);
2419err_ar_pci: 2501err_ar_pci:
2420 /* call HIF PCI free here */ 2502 /* call HIF PCI free here */
@@ -2442,7 +2524,6 @@ static void ath10k_pci_remove(struct pci_dev *pdev)
2442 2524
2443 ath10k_core_unregister(ar); 2525 ath10k_core_unregister(ar);
2444 2526
2445 pci_set_drvdata(pdev, NULL);
2446 pci_iounmap(pdev, ar_pci->mem); 2527 pci_iounmap(pdev, ar_pci->mem);
2447 pci_release_region(pdev, BAR_NUM); 2528 pci_release_region(pdev, BAR_NUM);
2448 pci_clear_master(pdev); 2529 pci_clear_master(pdev);
@@ -2483,9 +2564,6 @@ module_exit(ath10k_pci_exit);
2483MODULE_AUTHOR("Qualcomm Atheros"); 2564MODULE_AUTHOR("Qualcomm Atheros");
2484MODULE_DESCRIPTION("Driver support for Atheros QCA988X PCIe devices"); 2565MODULE_DESCRIPTION("Driver support for Atheros QCA988X PCIe devices");
2485MODULE_LICENSE("Dual BSD/GPL"); 2566MODULE_LICENSE("Dual BSD/GPL");
2486MODULE_FIRMWARE(QCA988X_HW_1_0_FW_DIR "/" QCA988X_HW_1_0_FW_FILE);
2487MODULE_FIRMWARE(QCA988X_HW_1_0_FW_DIR "/" QCA988X_HW_1_0_OTP_FILE);
2488MODULE_FIRMWARE(QCA988X_HW_1_0_FW_DIR "/" QCA988X_HW_1_0_BOARD_DATA_FILE);
2489MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_FW_FILE); 2567MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_FW_FILE);
2490MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_OTP_FILE); 2568MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_OTP_FILE);
2491MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_BOARD_DATA_FILE); 2569MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_BOARD_DATA_FILE);
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index 871bb339d56d..7c49f6f96f70 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -43,22 +43,23 @@ struct bmi_xfer {
43 u32 resp_len; 43 u32 resp_len;
44}; 44};
45 45
46enum ath10k_pci_compl_state {
47 ATH10K_PCI_COMPL_FREE = 0,
48 ATH10K_PCI_COMPL_SEND,
49 ATH10K_PCI_COMPL_RECV,
50};
51
46struct ath10k_pci_compl { 52struct ath10k_pci_compl {
47 struct list_head list; 53 struct list_head list;
48 int send_or_recv; 54 enum ath10k_pci_compl_state state;
49 struct ce_state *ce_state; 55 struct ath10k_ce_pipe *ce_state;
50 struct hif_ce_pipe_info *pipe_info; 56 struct ath10k_pci_pipe *pipe_info;
51 void *transfer_context; 57 struct sk_buff *skb;
52 unsigned int nbytes; 58 unsigned int nbytes;
53 unsigned int transfer_id; 59 unsigned int transfer_id;
54 unsigned int flags; 60 unsigned int flags;
55}; 61};
56 62
57/* compl_state.send_or_recv */
58#define HIF_CE_COMPLETE_FREE 0
59#define HIF_CE_COMPLETE_SEND 1
60#define HIF_CE_COMPLETE_RECV 2
61
62/* 63/*
63 * PCI-specific Target state 64 * PCI-specific Target state
64 * 65 *
@@ -152,17 +153,16 @@ struct service_to_pipe {
152 153
153enum ath10k_pci_features { 154enum ath10k_pci_features {
154 ATH10K_PCI_FEATURE_MSI_X = 0, 155 ATH10K_PCI_FEATURE_MSI_X = 0,
155 ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND = 1, 156 ATH10K_PCI_FEATURE_SOC_POWER_SAVE = 1,
156 ATH10K_PCI_FEATURE_SOC_POWER_SAVE = 2,
157 157
158 /* keep last */ 158 /* keep last */
159 ATH10K_PCI_FEATURE_COUNT 159 ATH10K_PCI_FEATURE_COUNT
160}; 160};
161 161
162/* Per-pipe state. */ 162/* Per-pipe state. */
163struct hif_ce_pipe_info { 163struct ath10k_pci_pipe {
164 /* Handle of underlying Copy Engine */ 164 /* Handle of underlying Copy Engine */
165 struct ce_state *ce_hdl; 165 struct ath10k_ce_pipe *ce_hdl;
166 166
167 /* Our pipe number; facilitiates use of pipe_info ptrs. */ 167 /* Our pipe number; facilitiates use of pipe_info ptrs. */
168 u8 pipe_num; 168 u8 pipe_num;
@@ -190,7 +190,6 @@ struct ath10k_pci {
190 struct device *dev; 190 struct device *dev;
191 struct ath10k *ar; 191 struct ath10k *ar;
192 void __iomem *mem; 192 void __iomem *mem;
193 int cacheline_sz;
194 193
195 DECLARE_BITMAP(features, ATH10K_PCI_FEATURE_COUNT); 194 DECLARE_BITMAP(features, ATH10K_PCI_FEATURE_COUNT);
196 195
@@ -219,7 +218,7 @@ struct ath10k_pci {
219 218
220 bool compl_processing; 219 bool compl_processing;
221 220
222 struct hif_ce_pipe_info pipe_info[CE_COUNT_MAX]; 221 struct ath10k_pci_pipe pipe_info[CE_COUNT_MAX];
223 222
224 struct ath10k_hif_cb msg_callbacks_current; 223 struct ath10k_hif_cb msg_callbacks_current;
225 224
@@ -227,16 +226,13 @@ struct ath10k_pci {
227 u32 fw_indicator_address; 226 u32 fw_indicator_address;
228 227
229 /* Copy Engine used for Diagnostic Accesses */ 228 /* Copy Engine used for Diagnostic Accesses */
230 struct ce_state *ce_diag; 229 struct ath10k_ce_pipe *ce_diag;
231 230
232 /* FIXME: document what this really protects */ 231 /* FIXME: document what this really protects */
233 spinlock_t ce_lock; 232 spinlock_t ce_lock;
234 233
235 /* Map CE id to ce_state */ 234 /* Map CE id to ce_state */
236 struct ce_state *ce_id_to_state[CE_COUNT_MAX]; 235 struct ath10k_ce_pipe ce_states[CE_COUNT_MAX];
237
238 /* makes sure that dummy reads are atomic */
239 spinlock_t hw_v1_workaround_lock;
240}; 236};
241 237
242static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar) 238static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
@@ -244,14 +240,18 @@ static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
244 return ar->hif.priv; 240 return ar->hif.priv;
245} 241}
246 242
247static inline u32 ath10k_pci_reg_read32(void __iomem *mem, u32 addr) 243static inline u32 ath10k_pci_reg_read32(struct ath10k *ar, u32 addr)
248{ 244{
249 return ioread32(mem + PCIE_LOCAL_BASE_ADDRESS + addr); 245 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
246
247 return ioread32(ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + addr);
250} 248}
251 249
252static inline void ath10k_pci_reg_write32(void __iomem *mem, u32 addr, u32 val) 250static inline void ath10k_pci_reg_write32(struct ath10k *ar, u32 addr, u32 val)
253{ 251{
254 iowrite32(val, mem + PCIE_LOCAL_BASE_ADDRESS + addr); 252 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
253
254 iowrite32(val, ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + addr);
255} 255}
256 256
257#define ATH_PCI_RESET_WAIT_MAX 10 /* ms */ 257#define ATH_PCI_RESET_WAIT_MAX 10 /* ms */
@@ -310,23 +310,8 @@ static inline void ath10k_pci_write32(struct ath10k *ar, u32 offset,
310 u32 value) 310 u32 value)
311{ 311{
312 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 312 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
313 void __iomem *addr = ar_pci->mem;
314
315 if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features)) {
316 unsigned long irq_flags;
317 313
318 spin_lock_irqsave(&ar_pci->hw_v1_workaround_lock, irq_flags); 314 iowrite32(value, ar_pci->mem + offset);
319
320 ioread32(addr+offset+4); /* 3rd read prior to write */
321 ioread32(addr+offset+4); /* 2nd read prior to write */
322 ioread32(addr+offset+4); /* 1st read prior to write */
323 iowrite32(value, addr+offset);
324
325 spin_unlock_irqrestore(&ar_pci->hw_v1_workaround_lock,
326 irq_flags);
327 } else {
328 iowrite32(value, addr+offset);
329 }
330} 315}
331 316
332static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset) 317static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset)
@@ -336,15 +321,17 @@ static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset)
336 return ioread32(ar_pci->mem + offset); 321 return ioread32(ar_pci->mem + offset);
337} 322}
338 323
339void ath10k_do_pci_wake(struct ath10k *ar); 324int ath10k_do_pci_wake(struct ath10k *ar);
340void ath10k_do_pci_sleep(struct ath10k *ar); 325void ath10k_do_pci_sleep(struct ath10k *ar);
341 326
342static inline void ath10k_pci_wake(struct ath10k *ar) 327static inline int ath10k_pci_wake(struct ath10k *ar)
343{ 328{
344 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 329 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
345 330
346 if (test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) 331 if (test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features))
347 ath10k_do_pci_wake(ar); 332 return ath10k_do_pci_wake(ar);
333
334 return 0;
348} 335}
349 336
350static inline void ath10k_pci_sleep(struct ath10k *ar) 337static inline void ath10k_pci_sleep(struct ath10k *ar)
diff --git a/drivers/net/wireless/ath/ath10k/rx_desc.h b/drivers/net/wireless/ath/ath10k/rx_desc.h
index bfec6c8f2ecb..1c584c4b019c 100644
--- a/drivers/net/wireless/ath/ath10k/rx_desc.h
+++ b/drivers/net/wireless/ath/ath10k/rx_desc.h
@@ -422,10 +422,30 @@ struct rx_mpdu_end {
422#define RX_MSDU_START_INFO1_IP_FRAG (1 << 14) 422#define RX_MSDU_START_INFO1_IP_FRAG (1 << 14)
423#define RX_MSDU_START_INFO1_TCP_ONLY_ACK (1 << 15) 423#define RX_MSDU_START_INFO1_TCP_ONLY_ACK (1 << 15)
424 424
425/* The decapped header (rx_hdr_status) contains the following:
426 * a) 802.11 header
427 * [padding to 4 bytes]
428 * b) HW crypto parameter
429 * - 0 bytes for no security
430 * - 4 bytes for WEP
431 * - 8 bytes for TKIP, AES
432 * [padding to 4 bytes]
433 * c) A-MSDU subframe header (14 bytes) if appliable
434 * d) LLC/SNAP (RFC1042, 8 bytes)
435 *
436 * In case of A-MSDU only first frame in sequence contains (a) and (b). */
425enum rx_msdu_decap_format { 437enum rx_msdu_decap_format {
426 RX_MSDU_DECAP_RAW = 0, 438 RX_MSDU_DECAP_RAW = 0,
427 RX_MSDU_DECAP_NATIVE_WIFI = 1, 439
440 /* Note: QoS frames are reported as non-QoS. The rx_hdr_status in
441 * htt_rx_desc contains the original decapped 802.11 header. */
442 RX_MSDU_DECAP_NATIVE_WIFI = 1,
443
444 /* Payload contains an ethernet header (struct ethhdr). */
428 RX_MSDU_DECAP_ETHERNET2_DIX = 2, 445 RX_MSDU_DECAP_ETHERNET2_DIX = 2,
446
447 /* Payload contains two 48-bit addresses and 2-byte length (14 bytes
448 * total), followed by an RFC1042 header (8 bytes). */
429 RX_MSDU_DECAP_8023_SNAP_LLC = 3 449 RX_MSDU_DECAP_8023_SNAP_LLC = 3
430}; 450};
431 451
diff --git a/drivers/net/wireless/ath/ath10k/trace.h b/drivers/net/wireless/ath/ath10k/trace.h
index 85e806bf7257..90817ddc92ba 100644
--- a/drivers/net/wireless/ath/ath10k/trace.h
+++ b/drivers/net/wireless/ath/ath10k/trace.h
@@ -111,26 +111,29 @@ TRACE_EVENT(ath10k_log_dbg_dump,
111); 111);
112 112
113TRACE_EVENT(ath10k_wmi_cmd, 113TRACE_EVENT(ath10k_wmi_cmd,
114 TP_PROTO(int id, void *buf, size_t buf_len), 114 TP_PROTO(int id, void *buf, size_t buf_len, int ret),
115 115
116 TP_ARGS(id, buf, buf_len), 116 TP_ARGS(id, buf, buf_len, ret),
117 117
118 TP_STRUCT__entry( 118 TP_STRUCT__entry(
119 __field(unsigned int, id) 119 __field(unsigned int, id)
120 __field(size_t, buf_len) 120 __field(size_t, buf_len)
121 __dynamic_array(u8, buf, buf_len) 121 __dynamic_array(u8, buf, buf_len)
122 __field(int, ret)
122 ), 123 ),
123 124
124 TP_fast_assign( 125 TP_fast_assign(
125 __entry->id = id; 126 __entry->id = id;
126 __entry->buf_len = buf_len; 127 __entry->buf_len = buf_len;
128 __entry->ret = ret;
127 memcpy(__get_dynamic_array(buf), buf, buf_len); 129 memcpy(__get_dynamic_array(buf), buf, buf_len);
128 ), 130 ),
129 131
130 TP_printk( 132 TP_printk(
131 "id %d len %zu", 133 "id %d len %zu ret %d",
132 __entry->id, 134 __entry->id,
133 __entry->buf_len 135 __entry->buf_len,
136 __entry->ret
134 ) 137 )
135); 138);
136 139
@@ -158,6 +161,27 @@ TRACE_EVENT(ath10k_wmi_event,
158 ) 161 )
159); 162);
160 163
164TRACE_EVENT(ath10k_htt_stats,
165 TP_PROTO(void *buf, size_t buf_len),
166
167 TP_ARGS(buf, buf_len),
168
169 TP_STRUCT__entry(
170 __field(size_t, buf_len)
171 __dynamic_array(u8, buf, buf_len)
172 ),
173
174 TP_fast_assign(
175 __entry->buf_len = buf_len;
176 memcpy(__get_dynamic_array(buf), buf, buf_len);
177 ),
178
179 TP_printk(
180 "len %zu",
181 __entry->buf_len
182 )
183);
184
161#endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/ 185#endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
162 186
163/* we don't want to use include/trace/events */ 187/* we don't want to use include/trace/events */
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index 68b6faefd1d8..5ae373a1e294 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -44,40 +44,39 @@ out:
44 spin_unlock_bh(&ar->data_lock); 44 spin_unlock_bh(&ar->data_lock);
45} 45}
46 46
47void ath10k_txrx_tx_unref(struct ath10k_htt *htt, struct sk_buff *txdesc) 47void ath10k_txrx_tx_unref(struct ath10k_htt *htt,
48 const struct htt_tx_done *tx_done)
48{ 49{
49 struct device *dev = htt->ar->dev; 50 struct device *dev = htt->ar->dev;
50 struct ieee80211_tx_info *info; 51 struct ieee80211_tx_info *info;
51 struct sk_buff *txfrag = ATH10K_SKB_CB(txdesc)->htt.txfrag; 52 struct ath10k_skb_cb *skb_cb;
52 struct sk_buff *msdu = ATH10K_SKB_CB(txdesc)->htt.msdu; 53 struct sk_buff *msdu;
53 int ret; 54 int ret;
54 55
55 if (ATH10K_SKB_CB(txdesc)->htt.refcount == 0) 56 ath10k_dbg(ATH10K_DBG_HTT, "htt tx completion msdu_id %u discard %d no_ack %d\n",
56 return; 57 tx_done->msdu_id, !!tx_done->discard, !!tx_done->no_ack);
57
58 ATH10K_SKB_CB(txdesc)->htt.refcount--;
59 58
60 if (ATH10K_SKB_CB(txdesc)->htt.refcount > 0) 59 if (tx_done->msdu_id >= htt->max_num_pending_tx) {
60 ath10k_warn("warning: msdu_id %d too big, ignoring\n",
61 tx_done->msdu_id);
61 return; 62 return;
62
63 if (txfrag) {
64 ret = ath10k_skb_unmap(dev, txfrag);
65 if (ret)
66 ath10k_warn("txfrag unmap failed (%d)\n", ret);
67
68 dev_kfree_skb_any(txfrag);
69 } 63 }
70 64
65 msdu = htt->pending_tx[tx_done->msdu_id];
66 skb_cb = ATH10K_SKB_CB(msdu);
67
71 ret = ath10k_skb_unmap(dev, msdu); 68 ret = ath10k_skb_unmap(dev, msdu);
72 if (ret) 69 if (ret)
73 ath10k_warn("data skb unmap failed (%d)\n", ret); 70 ath10k_warn("data skb unmap failed (%d)\n", ret);
74 71
72 if (skb_cb->htt.frag_len)
73 skb_pull(msdu, skb_cb->htt.frag_len + skb_cb->htt.pad_len);
74
75 ath10k_report_offchan_tx(htt->ar, msdu); 75 ath10k_report_offchan_tx(htt->ar, msdu);
76 76
77 info = IEEE80211_SKB_CB(msdu); 77 info = IEEE80211_SKB_CB(msdu);
78 memset(&info->status, 0, sizeof(info->status));
79 78
80 if (ATH10K_SKB_CB(txdesc)->htt.discard) { 79 if (tx_done->discard) {
81 ieee80211_free_txskb(htt->ar->hw, msdu); 80 ieee80211_free_txskb(htt->ar->hw, msdu);
82 goto exit; 81 goto exit;
83 } 82 }
@@ -85,7 +84,7 @@ void ath10k_txrx_tx_unref(struct ath10k_htt *htt, struct sk_buff *txdesc)
85 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) 84 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
86 info->flags |= IEEE80211_TX_STAT_ACK; 85 info->flags |= IEEE80211_TX_STAT_ACK;
87 86
88 if (ATH10K_SKB_CB(txdesc)->htt.no_ack) 87 if (tx_done->no_ack)
89 info->flags &= ~IEEE80211_TX_STAT_ACK; 88 info->flags &= ~IEEE80211_TX_STAT_ACK;
90 89
91 ieee80211_tx_status(htt->ar->hw, msdu); 90 ieee80211_tx_status(htt->ar->hw, msdu);
@@ -93,36 +92,12 @@ void ath10k_txrx_tx_unref(struct ath10k_htt *htt, struct sk_buff *txdesc)
93 92
94exit: 93exit:
95 spin_lock_bh(&htt->tx_lock); 94 spin_lock_bh(&htt->tx_lock);
96 htt->pending_tx[ATH10K_SKB_CB(txdesc)->htt.msdu_id] = NULL; 95 htt->pending_tx[tx_done->msdu_id] = NULL;
97 ath10k_htt_tx_free_msdu_id(htt, ATH10K_SKB_CB(txdesc)->htt.msdu_id); 96 ath10k_htt_tx_free_msdu_id(htt, tx_done->msdu_id);
98 __ath10k_htt_tx_dec_pending(htt); 97 __ath10k_htt_tx_dec_pending(htt);
99 if (bitmap_empty(htt->used_msdu_ids, htt->max_num_pending_tx)) 98 if (htt->num_pending_tx == 0)
100 wake_up(&htt->empty_tx_wq); 99 wake_up(&htt->empty_tx_wq);
101 spin_unlock_bh(&htt->tx_lock); 100 spin_unlock_bh(&htt->tx_lock);
102
103 dev_kfree_skb_any(txdesc);
104}
105
106void ath10k_txrx_tx_completed(struct ath10k_htt *htt,
107 const struct htt_tx_done *tx_done)
108{
109 struct sk_buff *txdesc;
110
111 ath10k_dbg(ATH10K_DBG_HTT, "htt tx completion msdu_id %u discard %d no_ack %d\n",
112 tx_done->msdu_id, !!tx_done->discard, !!tx_done->no_ack);
113
114 if (tx_done->msdu_id >= htt->max_num_pending_tx) {
115 ath10k_warn("warning: msdu_id %d too big, ignoring\n",
116 tx_done->msdu_id);
117 return;
118 }
119
120 txdesc = htt->pending_tx[tx_done->msdu_id];
121
122 ATH10K_SKB_CB(txdesc)->htt.discard = tx_done->discard;
123 ATH10K_SKB_CB(txdesc)->htt.no_ack = tx_done->no_ack;
124
125 ath10k_txrx_tx_unref(htt, txdesc);
126} 101}
127 102
128static const u8 rx_legacy_rate_idx[] = { 103static const u8 rx_legacy_rate_idx[] = {
@@ -293,6 +268,8 @@ void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info)
293 status->vht_nss, 268 status->vht_nss,
294 status->freq, 269 status->freq,
295 status->band); 270 status->band);
271 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "rx skb: ",
272 info->skb->data, info->skb->len);
296 273
297 ieee80211_rx(ar->hw, info->skb); 274 ieee80211_rx(ar->hw, info->skb);
298} 275}
diff --git a/drivers/net/wireless/ath/ath10k/txrx.h b/drivers/net/wireless/ath/ath10k/txrx.h
index e78632a76df7..356dc9c04c9e 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.h
+++ b/drivers/net/wireless/ath/ath10k/txrx.h
@@ -19,9 +19,8 @@
19 19
20#include "htt.h" 20#include "htt.h"
21 21
22void ath10k_txrx_tx_unref(struct ath10k_htt *htt, struct sk_buff *txdesc); 22void ath10k_txrx_tx_unref(struct ath10k_htt *htt,
23void ath10k_txrx_tx_completed(struct ath10k_htt *htt, 23 const struct htt_tx_done *tx_done);
24 const struct htt_tx_done *tx_done);
25void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info); 24void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info);
26 25
27struct ath10k_peer *ath10k_peer_find(struct ath10k *ar, int vdev_id, 26struct ath10k_peer *ath10k_peer_find(struct ath10k *ar, int vdev_id,
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 55f90c761868..6803ead9b9cf 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -23,30 +23,6 @@
23#include "wmi.h" 23#include "wmi.h"
24#include "mac.h" 24#include "mac.h"
25 25
26void ath10k_wmi_flush_tx(struct ath10k *ar)
27{
28 int ret;
29
30 lockdep_assert_held(&ar->conf_mutex);
31
32 if (ar->state == ATH10K_STATE_WEDGED) {
33 ath10k_warn("wmi flush skipped - device is wedged anyway\n");
34 return;
35 }
36
37 ret = wait_event_timeout(ar->wmi.wq,
38 atomic_read(&ar->wmi.pending_tx_count) == 0,
39 5*HZ);
40 if (atomic_read(&ar->wmi.pending_tx_count) == 0)
41 return;
42
43 if (ret == 0)
44 ret = -ETIMEDOUT;
45
46 if (ret < 0)
47 ath10k_warn("wmi flush failed (%d)\n", ret);
48}
49
50int ath10k_wmi_wait_for_service_ready(struct ath10k *ar) 26int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
51{ 27{
52 int ret; 28 int ret;
@@ -85,18 +61,14 @@ static struct sk_buff *ath10k_wmi_alloc_skb(u32 len)
85static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb) 61static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
86{ 62{
87 dev_kfree_skb(skb); 63 dev_kfree_skb(skb);
88
89 if (atomic_sub_return(1, &ar->wmi.pending_tx_count) == 0)
90 wake_up(&ar->wmi.wq);
91} 64}
92 65
93/* WMI command API */ 66static int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
94static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, 67 enum wmi_cmd_id cmd_id)
95 enum wmi_cmd_id cmd_id)
96{ 68{
97 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); 69 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
98 struct wmi_cmd_hdr *cmd_hdr; 70 struct wmi_cmd_hdr *cmd_hdr;
99 int status; 71 int ret;
100 u32 cmd = 0; 72 u32 cmd = 0;
101 73
102 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL) 74 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
@@ -107,25 +79,87 @@ static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb,
107 cmd_hdr = (struct wmi_cmd_hdr *)skb->data; 79 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
108 cmd_hdr->cmd_id = __cpu_to_le32(cmd); 80 cmd_hdr->cmd_id = __cpu_to_le32(cmd);
109 81
110 if (atomic_add_return(1, &ar->wmi.pending_tx_count) >
111 WMI_MAX_PENDING_TX_COUNT) {
112 /* avoid using up memory when FW hangs */
113 atomic_dec(&ar->wmi.pending_tx_count);
114 return -EBUSY;
115 }
116
117 memset(skb_cb, 0, sizeof(*skb_cb)); 82 memset(skb_cb, 0, sizeof(*skb_cb));
83 ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
84 trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len, ret);
118 85
119 trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len); 86 if (ret)
87 goto err_pull;
120 88
121 status = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb); 89 return 0;
122 if (status) { 90
91err_pull:
92 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
93 return ret;
94}
95
96static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
97{
98 struct wmi_bcn_tx_arg arg = {0};
99 int ret;
100
101 lockdep_assert_held(&arvif->ar->data_lock);
102
103 if (arvif->beacon == NULL)
104 return;
105
106 arg.vdev_id = arvif->vdev_id;
107 arg.tx_rate = 0;
108 arg.tx_power = 0;
109 arg.bcn = arvif->beacon->data;
110 arg.bcn_len = arvif->beacon->len;
111
112 ret = ath10k_wmi_beacon_send_nowait(arvif->ar, &arg);
113 if (ret)
114 return;
115
116 dev_kfree_skb_any(arvif->beacon);
117 arvif->beacon = NULL;
118}
119
120static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
121 struct ieee80211_vif *vif)
122{
123 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
124
125 ath10k_wmi_tx_beacon_nowait(arvif);
126}
127
128static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
129{
130 spin_lock_bh(&ar->data_lock);
131 ieee80211_iterate_active_interfaces_atomic(ar->hw,
132 IEEE80211_IFACE_ITER_NORMAL,
133 ath10k_wmi_tx_beacons_iter,
134 NULL);
135 spin_unlock_bh(&ar->data_lock);
136}
137
138static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
139{
140 /* try to send pending beacons first. they take priority */
141 ath10k_wmi_tx_beacons_nowait(ar);
142
143 wake_up(&ar->wmi.tx_credits_wq);
144}
145
146static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb,
147 enum wmi_cmd_id cmd_id)
148{
149 int ret = -EINVAL;
150
151 wait_event_timeout(ar->wmi.tx_credits_wq, ({
152 /* try to send pending beacons first. they take priority */
153 ath10k_wmi_tx_beacons_nowait(ar);
154
155 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
156 (ret != -EAGAIN);
157 }), 3*HZ);
158
159 if (ret)
123 dev_kfree_skb_any(skb); 160 dev_kfree_skb_any(skb);
124 atomic_dec(&ar->wmi.pending_tx_count);
125 return status;
126 }
127 161
128 return 0; 162 return ret;
129} 163}
130 164
131static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb) 165static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
@@ -315,7 +349,9 @@ static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band)
315 349
316static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) 350static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
317{ 351{
318 struct wmi_mgmt_rx_event *event = (struct wmi_mgmt_rx_event *)skb->data; 352 struct wmi_mgmt_rx_event_v1 *ev_v1;
353 struct wmi_mgmt_rx_event_v2 *ev_v2;
354 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
319 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 355 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
320 struct ieee80211_hdr *hdr; 356 struct ieee80211_hdr *hdr;
321 u32 rx_status; 357 u32 rx_status;
@@ -325,13 +361,24 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
325 u32 rate; 361 u32 rate;
326 u32 buf_len; 362 u32 buf_len;
327 u16 fc; 363 u16 fc;
364 int pull_len;
365
366 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
367 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
368 ev_hdr = &ev_v2->hdr.v1;
369 pull_len = sizeof(*ev_v2);
370 } else {
371 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
372 ev_hdr = &ev_v1->hdr;
373 pull_len = sizeof(*ev_v1);
374 }
328 375
329 channel = __le32_to_cpu(event->hdr.channel); 376 channel = __le32_to_cpu(ev_hdr->channel);
330 buf_len = __le32_to_cpu(event->hdr.buf_len); 377 buf_len = __le32_to_cpu(ev_hdr->buf_len);
331 rx_status = __le32_to_cpu(event->hdr.status); 378 rx_status = __le32_to_cpu(ev_hdr->status);
332 snr = __le32_to_cpu(event->hdr.snr); 379 snr = __le32_to_cpu(ev_hdr->snr);
333 phy_mode = __le32_to_cpu(event->hdr.phy_mode); 380 phy_mode = __le32_to_cpu(ev_hdr->phy_mode);
334 rate = __le32_to_cpu(event->hdr.rate); 381 rate = __le32_to_cpu(ev_hdr->rate);
335 382
336 memset(status, 0, sizeof(*status)); 383 memset(status, 0, sizeof(*status));
337 384
@@ -358,7 +405,7 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
358 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR; 405 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
359 status->rate_idx = get_rate_idx(rate, status->band); 406 status->rate_idx = get_rate_idx(rate, status->band);
360 407
361 skb_pull(skb, sizeof(event->hdr)); 408 skb_pull(skb, pull_len);
362 409
363 hdr = (struct ieee80211_hdr *)skb->data; 410 hdr = (struct ieee80211_hdr *)skb->data;
364 fc = le16_to_cpu(hdr->frame_control); 411 fc = le16_to_cpu(hdr->frame_control);
@@ -734,10 +781,8 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
734 int i = -1; 781 int i = -1;
735 struct wmi_bcn_info *bcn_info; 782 struct wmi_bcn_info *bcn_info;
736 struct ath10k_vif *arvif; 783 struct ath10k_vif *arvif;
737 struct wmi_bcn_tx_arg arg;
738 struct sk_buff *bcn; 784 struct sk_buff *bcn;
739 int vdev_id = 0; 785 int vdev_id = 0;
740 int ret;
741 786
742 ath10k_dbg(ATH10K_DBG_MGMT, "WMI_HOST_SWBA_EVENTID\n"); 787 ath10k_dbg(ATH10K_DBG_MGMT, "WMI_HOST_SWBA_EVENTID\n");
743 788
@@ -794,17 +839,17 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
794 ath10k_wmi_update_tim(ar, arvif, bcn, bcn_info); 839 ath10k_wmi_update_tim(ar, arvif, bcn, bcn_info);
795 ath10k_wmi_update_noa(ar, arvif, bcn, bcn_info); 840 ath10k_wmi_update_noa(ar, arvif, bcn, bcn_info);
796 841
797 arg.vdev_id = arvif->vdev_id; 842 spin_lock_bh(&ar->data_lock);
798 arg.tx_rate = 0; 843 if (arvif->beacon) {
799 arg.tx_power = 0; 844 ath10k_warn("SWBA overrun on vdev %d\n",
800 arg.bcn = bcn->data; 845 arvif->vdev_id);
801 arg.bcn_len = bcn->len; 846 dev_kfree_skb_any(arvif->beacon);
847 }
802 848
803 ret = ath10k_wmi_beacon_send(ar, &arg); 849 arvif->beacon = bcn;
804 if (ret)
805 ath10k_warn("could not send beacon (%d)\n", ret);
806 850
807 dev_kfree_skb_any(bcn); 851 ath10k_wmi_tx_beacon_nowait(arvif);
852 spin_unlock_bh(&ar->data_lock);
808 } 853 }
809} 854}
810 855
@@ -943,6 +988,9 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar,
943 ar->phy_capability = __le32_to_cpu(ev->phy_capability); 988 ar->phy_capability = __le32_to_cpu(ev->phy_capability);
944 ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains); 989 ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains);
945 990
991 if (ar->fw_version_build > 636)
992 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
993
946 if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { 994 if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) {
947 ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n", 995 ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
948 ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); 996 ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM);
@@ -1007,7 +1055,7 @@ static int ath10k_wmi_ready_event_rx(struct ath10k *ar, struct sk_buff *skb)
1007 return 0; 1055 return 0;
1008} 1056}
1009 1057
1010static void ath10k_wmi_event_process(struct ath10k *ar, struct sk_buff *skb) 1058static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
1011{ 1059{
1012 struct wmi_cmd_hdr *cmd_hdr; 1060 struct wmi_cmd_hdr *cmd_hdr;
1013 enum wmi_event_id id; 1061 enum wmi_event_id id;
@@ -1126,64 +1174,18 @@ static void ath10k_wmi_event_process(struct ath10k *ar, struct sk_buff *skb)
1126 dev_kfree_skb(skb); 1174 dev_kfree_skb(skb);
1127} 1175}
1128 1176
1129static void ath10k_wmi_event_work(struct work_struct *work)
1130{
1131 struct ath10k *ar = container_of(work, struct ath10k,
1132 wmi.wmi_event_work);
1133 struct sk_buff *skb;
1134
1135 for (;;) {
1136 skb = skb_dequeue(&ar->wmi.wmi_event_list);
1137 if (!skb)
1138 break;
1139
1140 ath10k_wmi_event_process(ar, skb);
1141 }
1142}
1143
1144static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
1145{
1146 struct wmi_cmd_hdr *cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1147 enum wmi_event_id event_id;
1148
1149 event_id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
1150
1151 /* some events require to be handled ASAP
1152 * thus can't be defered to a worker thread */
1153 switch (event_id) {
1154 case WMI_HOST_SWBA_EVENTID:
1155 case WMI_MGMT_RX_EVENTID:
1156 ath10k_wmi_event_process(ar, skb);
1157 return;
1158 default:
1159 break;
1160 }
1161
1162 skb_queue_tail(&ar->wmi.wmi_event_list, skb);
1163 queue_work(ar->workqueue, &ar->wmi.wmi_event_work);
1164}
1165
1166/* WMI Initialization functions */ 1177/* WMI Initialization functions */
1167int ath10k_wmi_attach(struct ath10k *ar) 1178int ath10k_wmi_attach(struct ath10k *ar)
1168{ 1179{
1169 init_completion(&ar->wmi.service_ready); 1180 init_completion(&ar->wmi.service_ready);
1170 init_completion(&ar->wmi.unified_ready); 1181 init_completion(&ar->wmi.unified_ready);
1171 init_waitqueue_head(&ar->wmi.wq); 1182 init_waitqueue_head(&ar->wmi.tx_credits_wq);
1172
1173 skb_queue_head_init(&ar->wmi.wmi_event_list);
1174 INIT_WORK(&ar->wmi.wmi_event_work, ath10k_wmi_event_work);
1175 1183
1176 return 0; 1184 return 0;
1177} 1185}
1178 1186
1179void ath10k_wmi_detach(struct ath10k *ar) 1187void ath10k_wmi_detach(struct ath10k *ar)
1180{ 1188{
1181 /* HTC should've drained the packets already */
1182 if (WARN_ON(atomic_read(&ar->wmi.pending_tx_count) > 0))
1183 ath10k_warn("there are still pending packets\n");
1184
1185 cancel_work_sync(&ar->wmi.wmi_event_work);
1186 skb_queue_purge(&ar->wmi.wmi_event_list);
1187} 1189}
1188 1190
1189int ath10k_wmi_connect_htc_service(struct ath10k *ar) 1191int ath10k_wmi_connect_htc_service(struct ath10k *ar)
@@ -1198,6 +1200,7 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar)
1198 /* these fields are the same for all service endpoints */ 1200 /* these fields are the same for all service endpoints */
1199 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete; 1201 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
1200 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx; 1202 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
1203 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
1201 1204
1202 /* connect to control service */ 1205 /* connect to control service */
1203 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; 1206 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
@@ -2108,7 +2111,8 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar,
2108 return ath10k_wmi_cmd_send(ar, skb, WMI_PEER_ASSOC_CMDID); 2111 return ath10k_wmi_cmd_send(ar, skb, WMI_PEER_ASSOC_CMDID);
2109} 2112}
2110 2113
2111int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_arg *arg) 2114int ath10k_wmi_beacon_send_nowait(struct ath10k *ar,
2115 const struct wmi_bcn_tx_arg *arg)
2112{ 2116{
2113 struct wmi_bcn_tx_cmd *cmd; 2117 struct wmi_bcn_tx_cmd *cmd;
2114 struct sk_buff *skb; 2118 struct sk_buff *skb;
@@ -2124,7 +2128,7 @@ int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_arg *arg)
2124 cmd->hdr.bcn_len = __cpu_to_le32(arg->bcn_len); 2128 cmd->hdr.bcn_len = __cpu_to_le32(arg->bcn_len);
2125 memcpy(cmd->bcn, arg->bcn, arg->bcn_len); 2129 memcpy(cmd->bcn, arg->bcn, arg->bcn_len);
2126 2130
2127 return ath10k_wmi_cmd_send(ar, skb, WMI_BCN_TX_CMDID); 2131 return ath10k_wmi_cmd_send_nowait(ar, skb, WMI_BCN_TX_CMDID);
2128} 2132}
2129 2133
2130static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params, 2134static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params,
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index 2c5a4f8daf2e..2c52c23107dd 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -508,6 +508,48 @@ enum wmi_phy_mode {
508 MODE_MAX = 14 508 MODE_MAX = 14
509}; 509};
510 510
511static inline const char *ath10k_wmi_phymode_str(enum wmi_phy_mode mode)
512{
513 switch (mode) {
514 case MODE_11A:
515 return "11a";
516 case MODE_11G:
517 return "11g";
518 case MODE_11B:
519 return "11b";
520 case MODE_11GONLY:
521 return "11gonly";
522 case MODE_11NA_HT20:
523 return "11na-ht20";
524 case MODE_11NG_HT20:
525 return "11ng-ht20";
526 case MODE_11NA_HT40:
527 return "11na-ht40";
528 case MODE_11NG_HT40:
529 return "11ng-ht40";
530 case MODE_11AC_VHT20:
531 return "11ac-vht20";
532 case MODE_11AC_VHT40:
533 return "11ac-vht40";
534 case MODE_11AC_VHT80:
535 return "11ac-vht80";
536 case MODE_11AC_VHT20_2G:
537 return "11ac-vht20-2g";
538 case MODE_11AC_VHT40_2G:
539 return "11ac-vht40-2g";
540 case MODE_11AC_VHT80_2G:
541 return "11ac-vht80-2g";
542 case MODE_UNKNOWN:
543 /* skip */
544 break;
545
546 /* no default handler to allow compiler to check that the
547 * enum is fully handled */
548 };
549
550 return "<unknown>";
551}
552
511#define WMI_CHAN_LIST_TAG 0x1 553#define WMI_CHAN_LIST_TAG 0x1
512#define WMI_SSID_LIST_TAG 0x2 554#define WMI_SSID_LIST_TAG 0x2
513#define WMI_BSSID_LIST_TAG 0x3 555#define WMI_BSSID_LIST_TAG 0x3
@@ -763,14 +805,6 @@ struct wmi_service_ready_event {
763 struct wlan_host_mem_req mem_reqs[1]; 805 struct wlan_host_mem_req mem_reqs[1];
764} __packed; 806} __packed;
765 807
766/*
767 * status consists of upper 16 bits fo int status and lower 16 bits of
768 * module ID that retuned status
769 */
770#define WLAN_INIT_STATUS_SUCCESS 0x0
771#define WLAN_GET_INIT_STATUS_REASON(status) ((status) & 0xffff)
772#define WLAN_GET_INIT_STATUS_MODULE_ID(status) (((status) >> 16) & 0xffff)
773
774#define WMI_SERVICE_READY_TIMEOUT_HZ (5*HZ) 808#define WMI_SERVICE_READY_TIMEOUT_HZ (5*HZ)
775#define WMI_UNIFIED_READY_TIMEOUT_HZ (5*HZ) 809#define WMI_UNIFIED_READY_TIMEOUT_HZ (5*HZ)
776 810
@@ -1268,7 +1302,7 @@ struct wmi_scan_event {
1268 * good idea to pass all the fields in the RX status 1302 * good idea to pass all the fields in the RX status
1269 * descriptor up to the host. 1303 * descriptor up to the host.
1270 */ 1304 */
1271struct wmi_mgmt_rx_hdr { 1305struct wmi_mgmt_rx_hdr_v1 {
1272 __le32 channel; 1306 __le32 channel;
1273 __le32 snr; 1307 __le32 snr;
1274 __le32 rate; 1308 __le32 rate;
@@ -1277,8 +1311,18 @@ struct wmi_mgmt_rx_hdr {
1277 __le32 status; /* %WMI_RX_STATUS_ */ 1311 __le32 status; /* %WMI_RX_STATUS_ */
1278} __packed; 1312} __packed;
1279 1313
1280struct wmi_mgmt_rx_event { 1314struct wmi_mgmt_rx_hdr_v2 {
1281 struct wmi_mgmt_rx_hdr hdr; 1315 struct wmi_mgmt_rx_hdr_v1 v1;
1316 __le32 rssi_ctl[4];
1317} __packed;
1318
1319struct wmi_mgmt_rx_event_v1 {
1320 struct wmi_mgmt_rx_hdr_v1 hdr;
1321 u8 buf[0];
1322} __packed;
1323
1324struct wmi_mgmt_rx_event_v2 {
1325 struct wmi_mgmt_rx_hdr_v2 hdr;
1282 u8 buf[0]; 1326 u8 buf[0];
1283} __packed; 1327} __packed;
1284 1328
@@ -3000,7 +3044,6 @@ struct wmi_force_fw_hang_cmd {
3000 3044
3001#define WMI_MAX_EVENT 0x1000 3045#define WMI_MAX_EVENT 0x1000
3002/* Maximum number of pending TXed WMI packets */ 3046/* Maximum number of pending TXed WMI packets */
3003#define WMI_MAX_PENDING_TX_COUNT 128
3004#define WMI_SKB_HEADROOM sizeof(struct wmi_cmd_hdr) 3047#define WMI_SKB_HEADROOM sizeof(struct wmi_cmd_hdr)
3005 3048
3006/* By default disable power save for IBSS */ 3049/* By default disable power save for IBSS */
@@ -3013,7 +3056,6 @@ int ath10k_wmi_attach(struct ath10k *ar);
3013void ath10k_wmi_detach(struct ath10k *ar); 3056void ath10k_wmi_detach(struct ath10k *ar);
3014int ath10k_wmi_wait_for_service_ready(struct ath10k *ar); 3057int ath10k_wmi_wait_for_service_ready(struct ath10k *ar);
3015int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar); 3058int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar);
3016void ath10k_wmi_flush_tx(struct ath10k *ar);
3017 3059
3018int ath10k_wmi_connect_htc_service(struct ath10k *ar); 3060int ath10k_wmi_connect_htc_service(struct ath10k *ar);
3019int ath10k_wmi_pdev_set_channel(struct ath10k *ar, 3061int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
@@ -3066,7 +3108,8 @@ int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
3066 enum wmi_ap_ps_peer_param param_id, u32 value); 3108 enum wmi_ap_ps_peer_param param_id, u32 value);
3067int ath10k_wmi_scan_chan_list(struct ath10k *ar, 3109int ath10k_wmi_scan_chan_list(struct ath10k *ar,
3068 const struct wmi_scan_chan_list_arg *arg); 3110 const struct wmi_scan_chan_list_arg *arg);
3069int ath10k_wmi_beacon_send(struct ath10k *ar, const struct wmi_bcn_tx_arg *arg); 3111int ath10k_wmi_beacon_send_nowait(struct ath10k *ar,
3112 const struct wmi_bcn_tx_arg *arg);
3070int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, 3113int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
3071 const struct wmi_pdev_set_wmm_params_arg *arg); 3114 const struct wmi_pdev_set_wmm_params_arg *arg);
3072int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id); 3115int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id);
diff --git a/drivers/net/wireless/ath/ath5k/ahb.c b/drivers/net/wireless/ath/ath5k/ahb.c
index e9bc9e616b69..79bffe165cab 100644
--- a/drivers/net/wireless/ath/ath5k/ahb.c
+++ b/drivers/net/wireless/ath/ath5k/ahb.c
@@ -37,12 +37,9 @@ ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
37{ 37{
38 struct ath5k_hw *ah = common->priv; 38 struct ath5k_hw *ah = common->priv;
39 struct platform_device *pdev = to_platform_device(ah->dev); 39 struct platform_device *pdev = to_platform_device(ah->dev);
40 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 40 struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
41 u16 *eeprom, *eeprom_end; 41 u16 *eeprom, *eeprom_end;
42 42
43
44
45 bcfg = pdev->dev.platform_data;
46 eeprom = (u16 *) bcfg->radio; 43 eeprom = (u16 *) bcfg->radio;
47 eeprom_end = ((void *) bcfg->config) + BOARD_CONFIG_BUFSZ; 44 eeprom_end = ((void *) bcfg->config) + BOARD_CONFIG_BUFSZ;
48 45
@@ -57,7 +54,7 @@ ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
57int ath5k_hw_read_srev(struct ath5k_hw *ah) 54int ath5k_hw_read_srev(struct ath5k_hw *ah)
58{ 55{
59 struct platform_device *pdev = to_platform_device(ah->dev); 56 struct platform_device *pdev = to_platform_device(ah->dev);
60 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 57 struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
61 ah->ah_mac_srev = bcfg->devid; 58 ah->ah_mac_srev = bcfg->devid;
62 return 0; 59 return 0;
63} 60}
@@ -65,7 +62,7 @@ int ath5k_hw_read_srev(struct ath5k_hw *ah)
65static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac) 62static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
66{ 63{
67 struct platform_device *pdev = to_platform_device(ah->dev); 64 struct platform_device *pdev = to_platform_device(ah->dev);
68 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 65 struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
69 u8 *cfg_mac; 66 u8 *cfg_mac;
70 67
71 if (to_platform_device(ah->dev)->id == 0) 68 if (to_platform_device(ah->dev)->id == 0)
@@ -87,7 +84,7 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {
87/*Initialization*/ 84/*Initialization*/
88static int ath_ahb_probe(struct platform_device *pdev) 85static int ath_ahb_probe(struct platform_device *pdev)
89{ 86{
90 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 87 struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
91 struct ath5k_hw *ah; 88 struct ath5k_hw *ah;
92 struct ieee80211_hw *hw; 89 struct ieee80211_hw *hw;
93 struct resource *res; 90 struct resource *res;
@@ -96,7 +93,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
96 int ret = 0; 93 int ret = 0;
97 u32 reg; 94 u32 reg;
98 95
99 if (!pdev->dev.platform_data) { 96 if (!dev_get_platdata(&pdev->dev)) {
100 dev_err(&pdev->dev, "no platform data specified\n"); 97 dev_err(&pdev->dev, "no platform data specified\n");
101 ret = -EINVAL; 98 ret = -EINVAL;
102 goto err_out; 99 goto err_out;
@@ -193,7 +190,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
193 190
194static int ath_ahb_remove(struct platform_device *pdev) 191static int ath_ahb_remove(struct platform_device *pdev)
195{ 192{
196 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 193 struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
197 struct ieee80211_hw *hw = platform_get_drvdata(pdev); 194 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
198 struct ath5k_hw *ah; 195 struct ath5k_hw *ah;
199 u32 reg; 196 u32 reg;
diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index 072e4b531067..2dff2765769b 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -54,7 +54,7 @@ static bool ath_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
54 struct platform_device *pdev = to_platform_device(sc->dev); 54 struct platform_device *pdev = to_platform_device(sc->dev);
55 struct ath9k_platform_data *pdata; 55 struct ath9k_platform_data *pdata;
56 56
57 pdata = (struct ath9k_platform_data *) pdev->dev.platform_data; 57 pdata = dev_get_platdata(&pdev->dev);
58 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) { 58 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
59 ath_err(common, 59 ath_err(common,
60 "%s: flash read failed, offset %08x is out of range\n", 60 "%s: flash read failed, offset %08x is out of range\n",
@@ -84,7 +84,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
84 struct ath_hw *ah; 84 struct ath_hw *ah;
85 char hw_name[64]; 85 char hw_name[64];
86 86
87 if (!pdev->dev.platform_data) { 87 if (!dev_get_platdata(&pdev->dev)) {
88 dev_err(&pdev->dev, "no platform data specified\n"); 88 dev_err(&pdev->dev, "no platform data specified\n");
89 return -EINVAL; 89 return -EINVAL;
90 } 90 }
diff --git a/drivers/net/wireless/ath/ath9k/antenna.c b/drivers/net/wireless/ath/ath9k/antenna.c
index dd1cc73d7946..bd048cc69a33 100644
--- a/drivers/net/wireless/ath/ath9k/antenna.c
+++ b/drivers/net/wireless/ath/ath9k/antenna.c
@@ -332,7 +332,7 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb,
332 } 332 }
333 333
334 if (antcomb->rssi_lna2 > antcomb->rssi_lna1 + 334 if (antcomb->rssi_lna2 > antcomb->rssi_lna1 +
335 ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA) 335 div_ant_conf->lna1_lna2_switch_delta)
336 div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2; 336 div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
337 else 337 else
338 div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1; 338 div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
@@ -554,42 +554,22 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf,
554 ant_conf->fast_div_bias = 0x1; 554 ant_conf->fast_div_bias = 0x1;
555 break; 555 break;
556 case 0x10: /* LNA2 A-B */ 556 case 0x10: /* LNA2 A-B */
557 if ((antcomb->scan == 0) && 557 ant_conf->fast_div_bias = 0x2;
558 (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) {
559 ant_conf->fast_div_bias = 0x3f;
560 } else {
561 ant_conf->fast_div_bias = 0x1;
562 }
563 break; 558 break;
564 case 0x12: /* LNA2 LNA1 */ 559 case 0x12: /* LNA2 LNA1 */
565 ant_conf->fast_div_bias = 0x39; 560 ant_conf->fast_div_bias = 0x3f;
566 break; 561 break;
567 case 0x13: /* LNA2 A+B */ 562 case 0x13: /* LNA2 A+B */
568 if ((antcomb->scan == 0) && 563 ant_conf->fast_div_bias = 0x2;
569 (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) {
570 ant_conf->fast_div_bias = 0x3f;
571 } else {
572 ant_conf->fast_div_bias = 0x1;
573 }
574 break; 564 break;
575 case 0x20: /* LNA1 A-B */ 565 case 0x20: /* LNA1 A-B */
576 if ((antcomb->scan == 0) && 566 ant_conf->fast_div_bias = 0x3;
577 (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) {
578 ant_conf->fast_div_bias = 0x3f;
579 } else {
580 ant_conf->fast_div_bias = 0x4;
581 }
582 break; 567 break;
583 case 0x21: /* LNA1 LNA2 */ 568 case 0x21: /* LNA1 LNA2 */
584 ant_conf->fast_div_bias = 0x6; 569 ant_conf->fast_div_bias = 0x3;
585 break; 570 break;
586 case 0x23: /* LNA1 A+B */ 571 case 0x23: /* LNA1 A+B */
587 if ((antcomb->scan == 0) && 572 ant_conf->fast_div_bias = 0x3;
588 (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) {
589 ant_conf->fast_div_bias = 0x3f;
590 } else {
591 ant_conf->fast_div_bias = 0x6;
592 }
593 break; 573 break;
594 case 0x30: /* A+B A-B */ 574 case 0x30: /* A+B A-B */
595 ant_conf->fast_div_bias = 0x1; 575 ant_conf->fast_div_bias = 0x1;
@@ -638,7 +618,7 @@ static void ath_ant_try_scan(struct ath_ant_comb *antcomb,
638 antcomb->rssi_sub = alt_rssi_avg; 618 antcomb->rssi_sub = alt_rssi_avg;
639 antcomb->scan = false; 619 antcomb->scan = false;
640 if (antcomb->rssi_lna2 > 620 if (antcomb->rssi_lna2 >
641 (antcomb->rssi_lna1 + ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) { 621 (antcomb->rssi_lna1 + conf->lna1_lna2_switch_delta)) {
642 /* use LNA2 as main LNA */ 622 /* use LNA2 as main LNA */
643 if ((antcomb->rssi_add > antcomb->rssi_lna1) && 623 if ((antcomb->rssi_add > antcomb->rssi_lna1) &&
644 (antcomb->rssi_add > antcomb->rssi_sub)) { 624 (antcomb->rssi_add > antcomb->rssi_sub)) {
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 08656473c63e..cb6435e7c6f5 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -626,12 +626,11 @@ static void ar5008_hw_override_ini(struct ath_hw *ah,
626 if (AR_SREV_9287_11_OR_LATER(ah)) 626 if (AR_SREV_9287_11_OR_LATER(ah))
627 val = val & (~AR_PCU_MISC_MODE2_HWWAR2); 627 val = val & (~AR_PCU_MISC_MODE2_HWWAR2);
628 628
629 val |= AR_PCU_MISC_MODE2_CFP_IGNORE;
630
629 REG_WRITE(ah, AR_PCU_MISC_MODE2, val); 631 REG_WRITE(ah, AR_PCU_MISC_MODE2, val);
630 } 632 }
631 633
632 REG_SET_BIT(ah, AR_PHY_CCK_DETECT,
633 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
634
635 if (AR_SREV_9280_20_OR_LATER(ah)) 634 if (AR_SREV_9280_20_OR_LATER(ah))
636 return; 635 return;
637 /* 636 /*
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
index 9f589744a9f9..32376ad74011 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
@@ -671,7 +671,7 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
671 671
672 nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF); 672 nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF);
673 if (ah->caldata) 673 if (ah->caldata)
674 nfcal_pending = ah->caldata->nfcal_pending; 674 nfcal_pending = test_bit(NFCAL_PENDING, &ah->caldata->cal_flags);
675 675
676 if (currCal && !nfcal && 676 if (currCal && !nfcal &&
677 (currCal->calState == CAL_RUNNING || 677 (currCal->calState == CAL_RUNNING ||
@@ -861,7 +861,7 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
861 ar9002_hw_pa_cal(ah, true); 861 ar9002_hw_pa_cal(ah, true);
862 862
863 if (ah->caldata) 863 if (ah->caldata)
864 ah->caldata->nfcal_pending = true; 864 set_bit(NFCAL_PENDING, &ah->caldata->cal_flags);
865 865
866 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; 866 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
867 867
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index 1fc1fa955d44..17970d49d858 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -485,7 +485,7 @@ static void ar9002_hw_do_getnf(struct ath_hw *ah,
485 if (IS_CHAN_HT40(ah->curchan)) 485 if (IS_CHAN_HT40(ah->curchan))
486 nfarray[3] = sign_extend32(nf, 8); 486 nfarray[3] = sign_extend32(nf, 8);
487 487
488 if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) 488 if (!(ah->rxchainmask & BIT(1)))
489 return; 489 return;
490 490
491 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA), AR9280_PHY_CH1_MINCCA_PWR); 491 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA), AR9280_PHY_CH1_MINCCA_PWR);
@@ -532,6 +532,7 @@ static void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah,
532 AR_PHY_9285_ANT_DIV_ALT_LNACONF_S; 532 AR_PHY_9285_ANT_DIV_ALT_LNACONF_S;
533 antconf->fast_div_bias = (regval & AR_PHY_9285_FAST_DIV_BIAS) >> 533 antconf->fast_div_bias = (regval & AR_PHY_9285_FAST_DIV_BIAS) >>
534 AR_PHY_9285_FAST_DIV_BIAS_S; 534 AR_PHY_9285_FAST_DIV_BIAS_S;
535 antconf->lna1_lna2_switch_delta = -1;
535 antconf->lna1_lna2_delta = -3; 536 antconf->lna1_lna2_delta = -3;
536 antconf->div_group = 0; 537 antconf->div_group = 0;
537} 538}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 6988e1d081f2..22934d3ca544 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -727,8 +727,12 @@ static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
727 REG_RMW_FIELD(ah, AR_PHY_RX_IQCAL_CORR_B0, 727 REG_RMW_FIELD(ah, AR_PHY_RX_IQCAL_CORR_B0,
728 AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN, 0x1); 728 AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN, 0x1);
729 729
730 if (caldata) 730 if (caldata) {
731 caldata->done_txiqcal_once = is_reusable; 731 if (is_reusable)
732 set_bit(TXIQCAL_DONE, &caldata->cal_flags);
733 else
734 clear_bit(TXIQCAL_DONE, &caldata->cal_flags);
735 }
732 736
733 return; 737 return;
734} 738}
@@ -961,18 +965,44 @@ static void ar9003_hw_manual_peak_cal(struct ath_hw *ah, u8 chain, bool is_2g)
961} 965}
962 966
963static void ar9003_hw_do_manual_peak_cal(struct ath_hw *ah, 967static void ar9003_hw_do_manual_peak_cal(struct ath_hw *ah,
964 struct ath9k_channel *chan) 968 struct ath9k_channel *chan,
969 bool run_rtt_cal)
965{ 970{
971 struct ath9k_hw_cal_data *caldata = ah->caldata;
966 int i; 972 int i;
967 973
968 if (!AR_SREV_9462(ah) && !AR_SREV_9565(ah) && !AR_SREV_9485(ah)) 974 if (!AR_SREV_9462(ah) && !AR_SREV_9565(ah) && !AR_SREV_9485(ah))
969 return; 975 return;
970 976
977 if ((ah->caps.hw_caps & ATH9K_HW_CAP_RTT) && !run_rtt_cal)
978 return;
979
971 for (i = 0; i < AR9300_MAX_CHAINS; i++) { 980 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
972 if (!(ah->rxchainmask & (1 << i))) 981 if (!(ah->rxchainmask & (1 << i)))
973 continue; 982 continue;
974 ar9003_hw_manual_peak_cal(ah, i, IS_CHAN_2GHZ(chan)); 983 ar9003_hw_manual_peak_cal(ah, i, IS_CHAN_2GHZ(chan));
975 } 984 }
985
986 if (caldata)
987 set_bit(SW_PKDET_DONE, &caldata->cal_flags);
988
989 if ((ah->caps.hw_caps & ATH9K_HW_CAP_RTT) && caldata) {
990 if (IS_CHAN_2GHZ(chan)){
991 caldata->caldac[0] = REG_READ_FIELD(ah,
992 AR_PHY_65NM_RXRF_AGC(0),
993 AR_PHY_65NM_RXRF_AGC_AGC2G_CALDAC_OVR);
994 caldata->caldac[1] = REG_READ_FIELD(ah,
995 AR_PHY_65NM_RXRF_AGC(1),
996 AR_PHY_65NM_RXRF_AGC_AGC2G_CALDAC_OVR);
997 } else {
998 caldata->caldac[0] = REG_READ_FIELD(ah,
999 AR_PHY_65NM_RXRF_AGC(0),
1000 AR_PHY_65NM_RXRF_AGC_AGC5G_CALDAC_OVR);
1001 caldata->caldac[1] = REG_READ_FIELD(ah,
1002 AR_PHY_65NM_RXRF_AGC(1),
1003 AR_PHY_65NM_RXRF_AGC_AGC5G_CALDAC_OVR);
1004 }
1005 }
976} 1006}
977 1007
978static void ar9003_hw_cl_cal_post_proc(struct ath_hw *ah, bool is_reusable) 1008static void ar9003_hw_cl_cal_post_proc(struct ath_hw *ah, bool is_reusable)
@@ -990,7 +1020,7 @@ static void ar9003_hw_cl_cal_post_proc(struct ath_hw *ah, bool is_reusable)
990 txclcal_done = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & 1020 txclcal_done = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) &
991 AR_PHY_AGC_CONTROL_CLC_SUCCESS); 1021 AR_PHY_AGC_CONTROL_CLC_SUCCESS);
992 1022
993 if (caldata->done_txclcal_once) { 1023 if (test_bit(TXCLCAL_DONE, &caldata->cal_flags)) {
994 for (i = 0; i < AR9300_MAX_CHAINS; i++) { 1024 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
995 if (!(ah->txchainmask & (1 << i))) 1025 if (!(ah->txchainmask & (1 << i)))
996 continue; 1026 continue;
@@ -1006,7 +1036,7 @@ static void ar9003_hw_cl_cal_post_proc(struct ath_hw *ah, bool is_reusable)
1006 caldata->tx_clcal[i][j] = 1036 caldata->tx_clcal[i][j] =
1007 REG_READ(ah, CL_TAB_ENTRY(cl_idx[i])); 1037 REG_READ(ah, CL_TAB_ENTRY(cl_idx[i]));
1008 } 1038 }
1009 caldata->done_txclcal_once = true; 1039 set_bit(TXCLCAL_DONE, &caldata->cal_flags);
1010 } 1040 }
1011} 1041}
1012 1042
@@ -1019,6 +1049,7 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
1019 bool is_reusable = true, status = true; 1049 bool is_reusable = true, status = true;
1020 bool run_rtt_cal = false, run_agc_cal, sep_iq_cal = false; 1050 bool run_rtt_cal = false, run_agc_cal, sep_iq_cal = false;
1021 bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT); 1051 bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT);
1052 u32 rx_delay = 0;
1022 u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL | 1053 u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL |
1023 AR_PHY_AGC_CONTROL_FLTR_CAL | 1054 AR_PHY_AGC_CONTROL_FLTR_CAL |
1024 AR_PHY_AGC_CONTROL_PKDET_CAL; 1055 AR_PHY_AGC_CONTROL_PKDET_CAL;
@@ -1042,17 +1073,22 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
1042 ar9003_hw_rtt_clear_hist(ah); 1073 ar9003_hw_rtt_clear_hist(ah);
1043 } 1074 }
1044 1075
1045 if (rtt && !run_rtt_cal) { 1076 if (rtt) {
1046 agc_ctrl = REG_READ(ah, AR_PHY_AGC_CONTROL); 1077 if (!run_rtt_cal) {
1047 agc_supp_cals &= agc_ctrl; 1078 agc_ctrl = REG_READ(ah, AR_PHY_AGC_CONTROL);
1048 agc_ctrl &= ~(AR_PHY_AGC_CONTROL_OFFSET_CAL | 1079 agc_supp_cals &= agc_ctrl;
1049 AR_PHY_AGC_CONTROL_FLTR_CAL | 1080 agc_ctrl &= ~(AR_PHY_AGC_CONTROL_OFFSET_CAL |
1050 AR_PHY_AGC_CONTROL_PKDET_CAL); 1081 AR_PHY_AGC_CONTROL_FLTR_CAL |
1051 REG_WRITE(ah, AR_PHY_AGC_CONTROL, agc_ctrl); 1082 AR_PHY_AGC_CONTROL_PKDET_CAL);
1083 REG_WRITE(ah, AR_PHY_AGC_CONTROL, agc_ctrl);
1084 } else {
1085 if (ah->ah_flags & AH_FASTCC)
1086 run_agc_cal = true;
1087 }
1052 } 1088 }
1053 1089
1054 if (ah->enabled_cals & TX_CL_CAL) { 1090 if (ah->enabled_cals & TX_CL_CAL) {
1055 if (caldata && caldata->done_txclcal_once) 1091 if (caldata && test_bit(TXCLCAL_DONE, &caldata->cal_flags))
1056 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, 1092 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL,
1057 AR_PHY_CL_CAL_ENABLE); 1093 AR_PHY_CL_CAL_ENABLE);
1058 else { 1094 else {
@@ -1076,14 +1112,14 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
1076 * AGC calibration 1112 * AGC calibration
1077 */ 1113 */
1078 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) { 1114 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) {
1079 if (caldata && !caldata->done_txiqcal_once) 1115 if (caldata && !test_bit(TXIQCAL_DONE, &caldata->cal_flags))
1080 REG_SET_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0, 1116 REG_SET_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0,
1081 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL); 1117 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL);
1082 else 1118 else
1083 REG_CLR_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0, 1119 REG_CLR_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0,
1084 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL); 1120 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL);
1085 txiqcal_done = run_agc_cal = true; 1121 txiqcal_done = run_agc_cal = true;
1086 } else if (caldata && !caldata->done_txiqcal_once) { 1122 } else if (caldata && !test_bit(TXIQCAL_DONE, &caldata->cal_flags)) {
1087 run_agc_cal = true; 1123 run_agc_cal = true;
1088 sep_iq_cal = true; 1124 sep_iq_cal = true;
1089 } 1125 }
@@ -1099,6 +1135,15 @@ skip_tx_iqcal:
1099 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN); 1135 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
1100 } 1136 }
1101 1137
1138 if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE) {
1139 rx_delay = REG_READ(ah, AR_PHY_RX_DELAY);
1140 /* Disable BB_active */
1141 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
1142 udelay(5);
1143 REG_WRITE(ah, AR_PHY_RX_DELAY, AR_PHY_RX_DELAY_DELAY);
1144 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
1145 }
1146
1102 if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) { 1147 if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
1103 /* Calibrate the AGC */ 1148 /* Calibrate the AGC */
1104 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 1149 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
@@ -1110,7 +1155,12 @@ skip_tx_iqcal:
1110 AR_PHY_AGC_CONTROL_CAL, 1155 AR_PHY_AGC_CONTROL_CAL,
1111 0, AH_WAIT_TIMEOUT); 1156 0, AH_WAIT_TIMEOUT);
1112 1157
1113 ar9003_hw_do_manual_peak_cal(ah, chan); 1158 ar9003_hw_do_manual_peak_cal(ah, chan, run_rtt_cal);
1159 }
1160
1161 if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE) {
1162 REG_WRITE(ah, AR_PHY_RX_DELAY, rx_delay);
1163 udelay(5);
1114 } 1164 }
1115 1165
1116 if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal) 1166 if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal)
@@ -1133,19 +1183,23 @@ skip_tx_iqcal:
1133 1183
1134 if (txiqcal_done) 1184 if (txiqcal_done)
1135 ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable); 1185 ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
1136 else if (caldata && caldata->done_txiqcal_once) 1186 else if (caldata && test_bit(TXIQCAL_DONE, &caldata->cal_flags))
1137 ar9003_hw_tx_iq_cal_reload(ah); 1187 ar9003_hw_tx_iq_cal_reload(ah);
1138 1188
1139 ar9003_hw_cl_cal_post_proc(ah, is_reusable); 1189 ar9003_hw_cl_cal_post_proc(ah, is_reusable);
1140 1190
1141 if (run_rtt_cal && caldata) { 1191 if (run_rtt_cal && caldata) {
1142 if (is_reusable) { 1192 if (is_reusable) {
1143 if (!ath9k_hw_rfbus_req(ah)) 1193 if (!ath9k_hw_rfbus_req(ah)) {
1144 ath_err(ath9k_hw_common(ah), 1194 ath_err(ath9k_hw_common(ah),
1145 "Could not stop baseband\n"); 1195 "Could not stop baseband\n");
1146 else 1196 } else {
1147 ar9003_hw_rtt_fill_hist(ah); 1197 ar9003_hw_rtt_fill_hist(ah);
1148 1198
1199 if (test_bit(SW_PKDET_DONE, &caldata->cal_flags))
1200 ar9003_hw_rtt_load_hist(ah);
1201 }
1202
1149 ath9k_hw_rfbus_done(ah); 1203 ath9k_hw_rfbus_done(ah);
1150 } 1204 }
1151 1205
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index f4864807e15b..1ec52356b5a1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -2991,7 +2991,10 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
2991 case EEP_CHAIN_MASK_REDUCE: 2991 case EEP_CHAIN_MASK_REDUCE:
2992 return (pBase->miscConfiguration >> 0x3) & 0x1; 2992 return (pBase->miscConfiguration >> 0x3) & 0x1;
2993 case EEP_ANT_DIV_CTL1: 2993 case EEP_ANT_DIV_CTL1:
2994 return eep->base_ext1.ant_div_control; 2994 if (AR_SREV_9565(ah))
2995 return AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE;
2996 else
2997 return eep->base_ext1.ant_div_control;
2995 case EEP_ANTENNA_GAIN_5G: 2998 case EEP_ANTENNA_GAIN_5G:
2996 return eep->modalHeader5G.antennaGain; 2999 return eep->modalHeader5G.antennaGain;
2997 case EEP_ANTENNA_GAIN_2G: 3000 case EEP_ANTENNA_GAIN_2G:
@@ -3424,12 +3427,12 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
3424 struct ar9300_base_eep_hdr *pBase; 3427 struct ar9300_base_eep_hdr *pBase;
3425 3428
3426 if (!dump_base_hdr) { 3429 if (!dump_base_hdr) {
3427 len += snprintf(buf + len, size - len, 3430 len += scnprintf(buf + len, size - len,
3428 "%20s :\n", "2GHz modal Header"); 3431 "%20s :\n", "2GHz modal Header");
3429 len = ar9003_dump_modal_eeprom(buf, len, size, 3432 len = ar9003_dump_modal_eeprom(buf, len, size,
3430 &eep->modalHeader2G); 3433 &eep->modalHeader2G);
3431 len += snprintf(buf + len, size - len, 3434 len += scnprintf(buf + len, size - len,
3432 "%20s :\n", "5GHz modal Header"); 3435 "%20s :\n", "5GHz modal Header");
3433 len = ar9003_dump_modal_eeprom(buf, len, size, 3436 len = ar9003_dump_modal_eeprom(buf, len, size,
3434 &eep->modalHeader5G); 3437 &eep->modalHeader5G);
3435 goto out; 3438 goto out;
@@ -3479,8 +3482,8 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
3479 PR_EEP("Rx Gain", pBase->txrxgain & 0xf); 3482 PR_EEP("Rx Gain", pBase->txrxgain & 0xf);
3480 PR_EEP("SW Reg", le32_to_cpu(pBase->swreg)); 3483 PR_EEP("SW Reg", le32_to_cpu(pBase->swreg));
3481 3484
3482 len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", 3485 len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
3483 ah->eeprom.ar9300_eep.macAddr); 3486 ah->eeprom.ar9300_eep.macAddr);
3484out: 3487out:
3485 if (len > size) 3488 if (len > size)
3486 len = size; 3489 len = size;
@@ -3656,9 +3659,23 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
3656 if (AR_SREV_9565(ah)) { 3659 if (AR_SREV_9565(ah)) {
3657 if (common->bt_ant_diversity) { 3660 if (common->bt_ant_diversity) {
3658 regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S); 3661 regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S);
3662
3663 REG_SET_BIT(ah, AR_PHY_RESTART,
3664 AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
3665
3666 /* Force WLAN LNA diversity ON */
3667 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
3668 AR_BTCOEX_WL_LNADIV_FORCE_ON);
3659 } else { 3669 } else {
3660 regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S); 3670 regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S);
3661 regval &= ~(1 << AR_PHY_ANT_SW_RX_PROT_S); 3671 regval &= ~(1 << AR_PHY_ANT_SW_RX_PROT_S);
3672
3673 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
3674 (1 << AR_PHY_ANT_SW_RX_PROT_S));
3675
3676 /* Force WLAN LNA diversity OFF */
3677 REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
3678 AR_BTCOEX_WL_LNADIV_FORCE_ON);
3662 } 3679 }
3663 } 3680 }
3664 3681
@@ -3669,7 +3686,8 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
3669 regval &= (~AR_FAST_DIV_ENABLE); 3686 regval &= (~AR_FAST_DIV_ENABLE);
3670 regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S; 3687 regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
3671 3688
3672 if (AR_SREV_9485(ah) && common->bt_ant_diversity) 3689 if ((AR_SREV_9485(ah) || AR_SREV_9565(ah))
3690 && common->bt_ant_diversity)
3673 regval |= AR_FAST_DIV_ENABLE; 3691 regval |= AR_FAST_DIV_ENABLE;
3674 3692
3675 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); 3693 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index 75d4fb41962f..0e5daa58a4fc 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -52,6 +52,8 @@
52#define AR9300_PAPRD_SCALE_2 0x70000000 52#define AR9300_PAPRD_SCALE_2 0x70000000
53#define AR9300_PAPRD_SCALE_2_S 28 53#define AR9300_PAPRD_SCALE_2_S 28
54 54
55#define AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE 0xc9
56
55/* Delta from which to start power to pdadc table */ 57/* Delta from which to start power to pdadc table */
56/* This offset is used in both open loop and closed loop power control 58/* This offset is used in both open loop and closed loop power control
57 * schemes. In open loop power control, it is not really needed, but for 59 * schemes. In open loop power control, it is not really needed, but for
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index 608bb4824e2a..b07f164d65cf 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -364,6 +364,8 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
364 364
365 INIT_INI_ARRAY(&ah->iniModesFastClock, 365 INIT_INI_ARRAY(&ah->iniModesFastClock,
366 ar9565_1p0_modes_fast_clock); 366 ar9565_1p0_modes_fast_clock);
367 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
368 ar9565_1p0_baseband_core_txfir_coeff_japan_2484);
367 } else { 369 } else {
368 /* mac */ 370 /* mac */
369 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], 371 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
@@ -628,6 +630,9 @@ static void ar9003_rx_gain_table_mode0(struct ath_hw *ah)
628 else if (AR_SREV_9462_20(ah)) 630 else if (AR_SREV_9462_20(ah))
629 INIT_INI_ARRAY(&ah->iniModesRxGain, 631 INIT_INI_ARRAY(&ah->iniModesRxGain,
630 ar9462_common_rx_gain_table_2p0); 632 ar9462_common_rx_gain_table_2p0);
633 else if (AR_SREV_9565(ah))
634 INIT_INI_ARRAY(&ah->iniModesRxGain,
635 ar9565_1p0_Common_rx_gain_table);
631 else 636 else
632 INIT_INI_ARRAY(&ah->iniModesRxGain, 637 INIT_INI_ARRAY(&ah->iniModesRxGain,
633 ar9300Common_rx_gain_table_2p2); 638 ar9300Common_rx_gain_table_2p2);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index 8dd069259e7b..7b94a6c7db3d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -753,9 +753,9 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan,
753 1 << AR_PHY_TIMING_CONTROL4_DO_GAIN_DC_IQ_CAL_SHIFT); 753 1 << AR_PHY_TIMING_CONTROL4_DO_GAIN_DC_IQ_CAL_SHIFT);
754 754
755 if (caldata) { 755 if (caldata) {
756 caldata->done_txiqcal_once = false; 756 clear_bit(TXIQCAL_DONE, &caldata->cal_flags);
757 caldata->done_txclcal_once = false; 757 clear_bit(TXCLCAL_DONE, &caldata->cal_flags);
758 caldata->rtt_done = false; 758 clear_bit(RTT_DONE, &caldata->cal_flags);
759 } 759 }
760 760
761 if (!ath9k_hw_init_cal(ah, chan)) 761 if (!ath9k_hw_init_cal(ah, chan))
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index e897648d3233..0131ba2f5d51 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -627,11 +627,10 @@ static void ar9003_hw_override_ini(struct ath_hw *ah)
627 * MAC addr only will fail. 627 * MAC addr only will fail.
628 */ 628 */
629 val = REG_READ(ah, AR_PCU_MISC_MODE2) & (~AR_ADHOC_MCAST_KEYID_ENABLE); 629 val = REG_READ(ah, AR_PCU_MISC_MODE2) & (~AR_ADHOC_MCAST_KEYID_ENABLE);
630 REG_WRITE(ah, AR_PCU_MISC_MODE2, 630 val |= AR_AGG_WEP_ENABLE_FIX |
631 val | AR_AGG_WEP_ENABLE_FIX | AR_AGG_WEP_ENABLE); 631 AR_AGG_WEP_ENABLE |
632 632 AR_PCU_MISC_MODE2_CFP_IGNORE;
633 REG_SET_BIT(ah, AR_PHY_CCK_DETECT, 633 REG_WRITE(ah, AR_PCU_MISC_MODE2, val);
634 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
635 634
636 if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) { 635 if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
637 REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE, 636 REG_WRITE(ah, AR_GLB_SWREG_DISCONT_MODE,
@@ -1375,15 +1374,19 @@ static void ar9003_hw_antdiv_comb_conf_get(struct ath_hw *ah,
1375 AR_PHY_ANT_FAST_DIV_BIAS_S; 1374 AR_PHY_ANT_FAST_DIV_BIAS_S;
1376 1375
1377 if (AR_SREV_9330_11(ah)) { 1376 if (AR_SREV_9330_11(ah)) {
1377 antconf->lna1_lna2_switch_delta = -1;
1378 antconf->lna1_lna2_delta = -9; 1378 antconf->lna1_lna2_delta = -9;
1379 antconf->div_group = 1; 1379 antconf->div_group = 1;
1380 } else if (AR_SREV_9485(ah)) { 1380 } else if (AR_SREV_9485(ah)) {
1381 antconf->lna1_lna2_switch_delta = -1;
1381 antconf->lna1_lna2_delta = -9; 1382 antconf->lna1_lna2_delta = -9;
1382 antconf->div_group = 2; 1383 antconf->div_group = 2;
1383 } else if (AR_SREV_9565(ah)) { 1384 } else if (AR_SREV_9565(ah)) {
1384 antconf->lna1_lna2_delta = -3; 1385 antconf->lna1_lna2_switch_delta = 3;
1386 antconf->lna1_lna2_delta = -9;
1385 antconf->div_group = 3; 1387 antconf->div_group = 3;
1386 } else { 1388 } else {
1389 antconf->lna1_lna2_switch_delta = -1;
1387 antconf->lna1_lna2_delta = -3; 1390 antconf->lna1_lna2_delta = -3;
1388 antconf->div_group = 0; 1391 antconf->div_group = 0;
1389 } 1392 }
@@ -1489,17 +1492,24 @@ static void ar9003_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
1489 } else if (AR_SREV_9565(ah)) { 1492 } else if (AR_SREV_9565(ah)) {
1490 if (enable) { 1493 if (enable) {
1491 REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL, 1494 REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1495 AR_ANT_DIV_ENABLE);
1496 REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1492 (1 << AR_PHY_ANT_SW_RX_PROT_S)); 1497 (1 << AR_PHY_ANT_SW_RX_PROT_S));
1493 if (ah->curchan && IS_CHAN_2GHZ(ah->curchan)) 1498 REG_SET_BIT(ah, AR_PHY_CCK_DETECT,
1494 REG_SET_BIT(ah, AR_PHY_RESTART, 1499 AR_FAST_DIV_ENABLE);
1495 AR_PHY_RESTART_ENABLE_DIV_M2FLAG); 1500 REG_SET_BIT(ah, AR_PHY_RESTART,
1501 AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
1496 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, 1502 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
1497 AR_BTCOEX_WL_LNADIV_FORCE_ON); 1503 AR_BTCOEX_WL_LNADIV_FORCE_ON);
1498 } else { 1504 } else {
1499 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE); 1505 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1506 AR_ANT_DIV_ENABLE);
1500 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL, 1507 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
1501 (1 << AR_PHY_ANT_SW_RX_PROT_S)); 1508 (1 << AR_PHY_ANT_SW_RX_PROT_S));
1502 REG_CLR_BIT(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE); 1509 REG_CLR_BIT(ah, AR_PHY_CCK_DETECT,
1510 AR_FAST_DIV_ENABLE);
1511 REG_CLR_BIT(ah, AR_PHY_RESTART,
1512 AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
1503 REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV, 1513 REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
1504 AR_BTCOEX_WL_LNADIV_FORCE_ON); 1514 AR_BTCOEX_WL_LNADIV_FORCE_ON);
1505 1515
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index 6fd752321e36..fca624322dc8 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -343,8 +343,12 @@
343 343
344#define AR_PHY_CCA_NOM_VAL_9462_2GHZ -127 344#define AR_PHY_CCA_NOM_VAL_9462_2GHZ -127
345#define AR_PHY_CCA_MIN_GOOD_VAL_9462_2GHZ -127 345#define AR_PHY_CCA_MIN_GOOD_VAL_9462_2GHZ -127
346#define AR_PHY_CCA_MAX_GOOD_VAL_9462_2GHZ -60
347#define AR_PHY_CCA_MAX_GOOD_VAL_9462_FCC_2GHZ -95
346#define AR_PHY_CCA_NOM_VAL_9462_5GHZ -127 348#define AR_PHY_CCA_NOM_VAL_9462_5GHZ -127
347#define AR_PHY_CCA_MIN_GOOD_VAL_9462_5GHZ -127 349#define AR_PHY_CCA_MIN_GOOD_VAL_9462_5GHZ -127
350#define AR_PHY_CCA_MAX_GOOD_VAL_9462_5GHZ -60
351#define AR_PHY_CCA_MAX_GOOD_VAL_9462_FCC_5GHZ -100
348 352
349#define AR_PHY_CCA_NOM_VAL_9330_2GHZ -118 353#define AR_PHY_CCA_NOM_VAL_9330_2GHZ -118
350 354
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_rtt.c b/drivers/net/wireless/ath/ath9k/ar9003_rtt.c
index 74de3539c2c8..934418872e8e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_rtt.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_rtt.c
@@ -118,6 +118,27 @@ void ar9003_hw_rtt_load_hist(struct ath_hw *ah)
118 } 118 }
119} 119}
120 120
121static void ar9003_hw_patch_rtt(struct ath_hw *ah, int index, int chain)
122{
123 int agc, caldac;
124
125 if (!test_bit(SW_PKDET_DONE, &ah->caldata->cal_flags))
126 return;
127
128 if ((index != 5) || (chain >= 2))
129 return;
130
131 agc = REG_READ_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
132 AR_PHY_65NM_RXRF_AGC_AGC_OVERRIDE);
133 if (!agc)
134 return;
135
136 caldac = ah->caldata->caldac[chain];
137 ah->caldata->rtt_table[chain][index] &= 0xFFFF05FF;
138 caldac = (caldac & 0x20) | ((caldac & 0x1F) << 7);
139 ah->caldata->rtt_table[chain][index] |= (caldac << 4);
140}
141
121static int ar9003_hw_rtt_fill_hist_entry(struct ath_hw *ah, u8 chain, u32 index) 142static int ar9003_hw_rtt_fill_hist_entry(struct ath_hw *ah, u8 chain, u32 index)
122{ 143{
123 u32 val; 144 u32 val;
@@ -155,13 +176,16 @@ void ar9003_hw_rtt_fill_hist(struct ath_hw *ah)
155 for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++) { 176 for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++) {
156 ah->caldata->rtt_table[chain][i] = 177 ah->caldata->rtt_table[chain][i] =
157 ar9003_hw_rtt_fill_hist_entry(ah, chain, i); 178 ar9003_hw_rtt_fill_hist_entry(ah, chain, i);
179
180 ar9003_hw_patch_rtt(ah, i, chain);
181
158 ath_dbg(ath9k_hw_common(ah), CALIBRATE, 182 ath_dbg(ath9k_hw_common(ah), CALIBRATE,
159 "RTT value at idx %d, chain %d is: 0x%x\n", 183 "RTT value at idx %d, chain %d is: 0x%x\n",
160 i, chain, ah->caldata->rtt_table[chain][i]); 184 i, chain, ah->caldata->rtt_table[chain][i]);
161 } 185 }
162 } 186 }
163 187
164 ah->caldata->rtt_done = true; 188 set_bit(RTT_DONE, &ah->caldata->cal_flags);
165} 189}
166 190
167void ar9003_hw_rtt_clear_hist(struct ath_hw *ah) 191void ar9003_hw_rtt_clear_hist(struct ath_hw *ah)
@@ -176,7 +200,7 @@ void ar9003_hw_rtt_clear_hist(struct ath_hw *ah)
176 } 200 }
177 201
178 if (ah->caldata) 202 if (ah->caldata)
179 ah->caldata->rtt_done = false; 203 clear_bit(RTT_DONE, &ah->caldata->cal_flags);
180} 204}
181 205
182bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan) 206bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan)
@@ -186,11 +210,37 @@ bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan)
186 if (!ah->caldata) 210 if (!ah->caldata)
187 return false; 211 return false;
188 212
189 if (!ah->caldata->rtt_done) 213 if (test_bit(SW_PKDET_DONE, &ah->caldata->cal_flags)) {
214 if (IS_CHAN_2GHZ(chan)){
215 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(0),
216 AR_PHY_65NM_RXRF_AGC_AGC2G_CALDAC_OVR,
217 ah->caldata->caldac[0]);
218 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(1),
219 AR_PHY_65NM_RXRF_AGC_AGC2G_CALDAC_OVR,
220 ah->caldata->caldac[1]);
221 } else {
222 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(0),
223 AR_PHY_65NM_RXRF_AGC_AGC5G_CALDAC_OVR,
224 ah->caldata->caldac[0]);
225 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(1),
226 AR_PHY_65NM_RXRF_AGC_AGC5G_CALDAC_OVR,
227 ah->caldata->caldac[1]);
228 }
229 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(1),
230 AR_PHY_65NM_RXRF_AGC_AGC_OVERRIDE, 0x1);
231 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(0),
232 AR_PHY_65NM_RXRF_AGC_AGC_OVERRIDE, 0x1);
233 }
234
235 if (!test_bit(RTT_DONE, &ah->caldata->cal_flags))
190 return false; 236 return false;
191 237
192 ar9003_hw_rtt_enable(ah); 238 ar9003_hw_rtt_enable(ah);
193 ar9003_hw_rtt_set_mask(ah, 0x10); 239
240 if (test_bit(SW_PKDET_DONE, &ah->caldata->cal_flags))
241 ar9003_hw_rtt_set_mask(ah, 0x30);
242 else
243 ar9003_hw_rtt_set_mask(ah, 0x10);
194 244
195 if (!ath9k_hw_rfbus_req(ah)) { 245 if (!ath9k_hw_rfbus_req(ah)) {
196 ath_err(ath9k_hw_common(ah), "Could not stop baseband\n"); 246 ath_err(ath9k_hw_common(ah), "Could not stop baseband\n");
diff --git a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
index 88ff1d7b53ab..6f899c692647 100644
--- a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
@@ -20,7 +20,17 @@
20 20
21/* AR9485 1.1 */ 21/* AR9485 1.1 */
22 22
23#define ar9485_1_1_mac_postamble ar9300_2p2_mac_postamble 23static const u32 ar9485_1_1_mac_postamble[][5] = {
24 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
25 {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160},
26 {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c},
27 {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38},
28 {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00},
29 {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b},
30 {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810},
31 {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a},
32 {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440},
33};
24 34
25static const u32 ar9485_1_1_pcie_phy_pll_on_clkreq_disable_L1[][2] = { 35static const u32 ar9485_1_1_pcie_phy_pll_on_clkreq_disable_L1[][2] = {
26 /* Addr allmodes */ 36 /* Addr allmodes */
@@ -34,6 +44,7 @@ static const u32 ar9485Common_wo_xlna_rx_gain_1_1[][2] = {
34 {0x00009e00, 0x037216a0}, 44 {0x00009e00, 0x037216a0},
35 {0x00009e04, 0x00182020}, 45 {0x00009e04, 0x00182020},
36 {0x00009e18, 0x00000000}, 46 {0x00009e18, 0x00000000},
47 {0x00009e20, 0x000003a8},
37 {0x00009e2c, 0x00004121}, 48 {0x00009e2c, 0x00004121},
38 {0x00009e44, 0x02282324}, 49 {0x00009e44, 0x02282324},
39 {0x0000a000, 0x00060005}, 50 {0x0000a000, 0x00060005},
@@ -174,7 +185,7 @@ static const u32 ar9485Modes_high_power_tx_gain_1_1[][5] = {
174 {0x0000a2e0, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552}, 185 {0x0000a2e0, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
175 {0x0000a2e4, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552}, 186 {0x0000a2e4, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
176 {0x0000a2e8, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552}, 187 {0x0000a2e8, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
177 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8}, 188 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050da, 0x000050da},
178 {0x0000a458, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 189 {0x0000a458, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
179 {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, 190 {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000},
180 {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, 191 {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002},
@@ -200,14 +211,14 @@ static const u32 ar9485Modes_high_power_tx_gain_1_1[][5] = {
200 {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x57001ce9, 0x57001ce9}, 211 {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x57001ce9, 0x57001ce9},
201 {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5a001ceb, 0x5a001ceb}, 212 {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5a001ceb, 0x5a001ceb},
202 {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x5e001eeb, 0x5e001eeb}, 213 {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x5e001eeb, 0x5e001eeb},
203 {0x0000a560, 0x900fff0b, 0x900fff0b, 0x5e001eeb, 0x5e001eeb}, 214 {0x0000a560, 0x900fff0b, 0x900fff0b, 0x62001eee, 0x62001eee},
204 {0x0000a564, 0x960fffcb, 0x960fffcb, 0x5e001eeb, 0x5e001eeb}, 215 {0x0000a564, 0x960fffcb, 0x960fffcb, 0x66001ff6, 0x66001ff6},
205 {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 216 {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
206 {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 217 {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
207 {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 218 {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
208 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 219 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
209 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 220 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
210 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 221 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
211 {0x0000a580, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 222 {0x0000a580, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
212 {0x0000a584, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 223 {0x0000a584, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
213 {0x0000a588, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 224 {0x0000a588, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
@@ -263,6 +274,11 @@ static const u32 ar9485Modes_high_power_tx_gain_1_1[][5] = {
263static const u32 ar9485Modes_green_ob_db_tx_gain_1_1[][5] = { 274static const u32 ar9485Modes_green_ob_db_tx_gain_1_1[][5] = {
264 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 275 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
265 {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003}, 276 {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003},
277 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0x7999a83a, 0x7999a83a},
278 {0x0000a2dc, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
279 {0x0000a2e0, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
280 {0x0000a2e4, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
281 {0x0000a2e8, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
266 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8}, 282 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8},
267 {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000}, 283 {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000},
268 {0x0000a500, 0x00022200, 0x00022200, 0x00000006, 0x00000006}, 284 {0x0000a500, 0x00022200, 0x00022200, 0x00000006, 0x00000006},
@@ -297,6 +313,22 @@ static const u32 ar9485Modes_green_ob_db_tx_gain_1_1[][5] = {
297 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 313 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
298 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 314 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
299 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb}, 315 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x5e001eeb, 0x5e001eeb},
316 {0x0000a580, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
317 {0x0000a584, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
318 {0x0000a588, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
319 {0x0000a58c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
320 {0x0000a590, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
321 {0x0000a594, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
322 {0x0000a598, 0x00000000, 0x00000000, 0x01404501, 0x01404501},
323 {0x0000a59c, 0x00000000, 0x00000000, 0x02808a02, 0x02808a02},
324 {0x0000a5a0, 0x00000000, 0x00000000, 0x02808a02, 0x02808a02},
325 {0x0000a5a4, 0x00000000, 0x00000000, 0x02808803, 0x02808803},
326 {0x0000a5a8, 0x00000000, 0x00000000, 0x04c14b04, 0x04c14b04},
327 {0x0000a5ac, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
328 {0x0000a5b0, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
329 {0x0000a5b4, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
330 {0x0000a5b8, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
331 {0x0000a5bc, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
300 {0x0000b500, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a}, 332 {0x0000b500, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
301 {0x0000b504, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a}, 333 {0x0000b504, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
302 {0x0000b508, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a}, 334 {0x0000b508, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
@@ -341,6 +373,100 @@ static const u32 ar9485Modes_high_ob_db_tx_gain_1_1[][5] = {
341 {0x0000a2e0, 0x00000000, 0x00000000, 0xffc63a84, 0xffc63a84}, 373 {0x0000a2e0, 0x00000000, 0x00000000, 0xffc63a84, 0xffc63a84},
342 {0x0000a2e4, 0x00000000, 0x00000000, 0xfe0fc000, 0xfe0fc000}, 374 {0x0000a2e4, 0x00000000, 0x00000000, 0xfe0fc000, 0xfe0fc000},
343 {0x0000a2e8, 0x00000000, 0x00000000, 0xfff00000, 0xfff00000}, 375 {0x0000a2e8, 0x00000000, 0x00000000, 0xfff00000, 0xfff00000},
376 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050da, 0x000050da},
377 {0x0000a458, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
378 {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000},
379 {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002},
380 {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004},
381 {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200},
382 {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202},
383 {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400},
384 {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402},
385 {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404},
386 {0x0000a520, 0x2f001f04, 0x2f001f04, 0x21000603, 0x21000603},
387 {0x0000a524, 0x35001fc4, 0x35001fc4, 0x25000605, 0x25000605},
388 {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2a000a03, 0x2a000a03},
389 {0x0000a52c, 0x41023e85, 0x41023e85, 0x2c000a04, 0x2c000a04},
390 {0x0000a530, 0x48023ec6, 0x48023ec6, 0x34000e20, 0x34000e20},
391 {0x0000a534, 0x4d023f01, 0x4d023f01, 0x35000e21, 0x35000e21},
392 {0x0000a538, 0x53023f4b, 0x53023f4b, 0x43000e62, 0x43000e62},
393 {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x45000e63, 0x45000e63},
394 {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x49000e65, 0x49000e65},
395 {0x0000a544, 0x6502feca, 0x6502feca, 0x4b000e66, 0x4b000e66},
396 {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x4d001645, 0x4d001645},
397 {0x0000a54c, 0x7203feca, 0x7203feca, 0x51001865, 0x51001865},
398 {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x55001a86, 0x55001a86},
399 {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x57001ce9, 0x57001ce9},
400 {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5a001ceb, 0x5a001ceb},
401 {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x5e001eeb, 0x5e001eeb},
402 {0x0000a560, 0x900fff0b, 0x900fff0b, 0x62001eee, 0x62001eee},
403 {0x0000a564, 0x960fffcb, 0x960fffcb, 0x66001ff6, 0x66001ff6},
404 {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
405 {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
406 {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
407 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
408 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
409 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x66001ff6, 0x66001ff6},
410 {0x0000a580, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
411 {0x0000a584, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
412 {0x0000a588, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
413 {0x0000a58c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
414 {0x0000a590, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
415 {0x0000a594, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
416 {0x0000a598, 0x00000000, 0x00000000, 0x01404501, 0x01404501},
417 {0x0000a59c, 0x00000000, 0x00000000, 0x02808a02, 0x02808a02},
418 {0x0000a5a0, 0x00000000, 0x00000000, 0x02808a02, 0x02808a02},
419 {0x0000a5a4, 0x00000000, 0x00000000, 0x02808803, 0x02808803},
420 {0x0000a5a8, 0x00000000, 0x00000000, 0x04c14b04, 0x04c14b04},
421 {0x0000a5ac, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
422 {0x0000a5b0, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
423 {0x0000a5b4, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
424 {0x0000a5b8, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
425 {0x0000a5bc, 0x00000000, 0x00000000, 0x04c15305, 0x04c15305},
426 {0x0000b500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
427 {0x0000b504, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
428 {0x0000b508, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
429 {0x0000b50c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
430 {0x0000b510, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
431 {0x0000b514, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
432 {0x0000b518, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
433 {0x0000b51c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
434 {0x0000b520, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
435 {0x0000b524, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
436 {0x0000b528, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
437 {0x0000b52c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
438 {0x0000b530, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
439 {0x0000b534, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
440 {0x0000b538, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
441 {0x0000b53c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
442 {0x0000b540, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
443 {0x0000b544, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
444 {0x0000b548, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
445 {0x0000b54c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
446 {0x0000b550, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
447 {0x0000b554, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
448 {0x0000b558, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
449 {0x0000b55c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
450 {0x0000b560, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
451 {0x0000b564, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
452 {0x0000b568, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
453 {0x0000b56c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
454 {0x0000b570, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
455 {0x0000b574, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
456 {0x0000b578, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
457 {0x0000b57c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
458 {0x00016044, 0x05d6b2db, 0x05d6b2db, 0x05d6b2db, 0x05d6b2db},
459 {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260},
460};
461
462static const u32 ar9485Modes_low_ob_db_tx_gain_1_1[][5] = {
463 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
464 {0x000098bc, 0x00000002, 0x00000002, 0x00000002, 0x00000002},
465 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0x7999a83a, 0x7999a83a},
466 {0x0000a2dc, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
467 {0x0000a2e0, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
468 {0x0000a2e4, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
469 {0x0000a2e8, 0x00000000, 0x00000000, 0xfe2d3552, 0xfe2d3552},
344 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8}, 470 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8},
345 {0x0000a458, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 471 {0x0000a458, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
346 {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, 472 {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000},
@@ -427,7 +553,7 @@ static const u32 ar9485Modes_high_ob_db_tx_gain_1_1[][5] = {
427 {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260}, 553 {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260},
428}; 554};
429 555
430static const u32 ar9485Modes_low_ob_db_tx_gain_1_1[][5] = { 556static const u32 ar9485_modes_lowest_ob_db_tx_gain_1_1[][5] = {
431 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 557 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
432 {0x000098bc, 0x00000002, 0x00000002, 0x00000002, 0x00000002}, 558 {0x000098bc, 0x00000002, 0x00000002, 0x00000002, 0x00000002},
433 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0x7999a83a, 0x7999a83a}, 559 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0x7999a83a, 0x7999a83a},
@@ -521,12 +647,15 @@ static const u32 ar9485Modes_low_ob_db_tx_gain_1_1[][5] = {
521 {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260}, 647 {0x00016048, 0x6c924260, 0x6c924260, 0x6c924260, 0x6c924260},
522}; 648};
523 649
524#define ar9485_modes_lowest_ob_db_tx_gain_1_1 ar9485Modes_low_ob_db_tx_gain_1_1
525
526static const u32 ar9485Modes_green_spur_ob_db_tx_gain_1_1[][5] = { 650static const u32 ar9485Modes_green_spur_ob_db_tx_gain_1_1[][5] = {
527 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 651 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
528 {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003}, 652 {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003},
529 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d8, 0x000050d8}, 653 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0x7999a83a, 0x7999a83a},
654 {0x0000a2dc, 0x00000000, 0x00000000, 0xffad452a, 0xffad452a},
655 {0x0000a2e0, 0x00000000, 0x00000000, 0xffc98634, 0xffc98634},
656 {0x0000a2e4, 0x00000000, 0x00000000, 0xfff60780, 0xfff60780},
657 {0x0000a2e8, 0x00000000, 0x00000000, 0xfffff800, 0xfffff800},
658 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
530 {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000}, 659 {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000},
531 {0x0000a500, 0x00022200, 0x00022200, 0x00000006, 0x00000006}, 660 {0x0000a500, 0x00022200, 0x00022200, 0x00000006, 0x00000006},
532 {0x0000a504, 0x05062002, 0x05062002, 0x03000201, 0x03000201}, 661 {0x0000a504, 0x05062002, 0x05062002, 0x03000201, 0x03000201},
@@ -543,23 +672,39 @@ static const u32 ar9485Modes_green_spur_ob_db_tx_gain_1_1[][5] = {
543 {0x0000a530, 0x48023ec6, 0x48023ec6, 0x310006e0, 0x310006e0}, 672 {0x0000a530, 0x48023ec6, 0x48023ec6, 0x310006e0, 0x310006e0},
544 {0x0000a534, 0x4d023f01, 0x4d023f01, 0x330006e0, 0x330006e0}, 673 {0x0000a534, 0x4d023f01, 0x4d023f01, 0x330006e0, 0x330006e0},
545 {0x0000a538, 0x53023f4b, 0x53023f4b, 0x3e0008e3, 0x3e0008e3}, 674 {0x0000a538, 0x53023f4b, 0x53023f4b, 0x3e0008e3, 0x3e0008e3},
546 {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x410008e5, 0x410008e5}, 675 {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x430008e6, 0x430008e6},
547 {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x430008e6, 0x430008e6}, 676 {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x4a0008ec, 0x4a0008ec},
548 {0x0000a544, 0x6502feca, 0x6502feca, 0x4a0008ec, 0x4a0008ec}, 677 {0x0000a544, 0x6502feca, 0x6502feca, 0x4e0008f1, 0x4e0008f1},
549 {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x4e0008f1, 0x4e0008f1}, 678 {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x520008f3, 0x520008f3},
550 {0x0000a54c, 0x7203feca, 0x7203feca, 0x520008f3, 0x520008f3}, 679 {0x0000a54c, 0x7203feca, 0x7203feca, 0x54000eed, 0x54000eed},
551 {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x54000eed, 0x54000eed}, 680 {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x58000ef1, 0x58000ef1},
552 {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x58000ef1, 0x58000ef1}, 681 {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x5c000ef3, 0x5c000ef3},
553 {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5c000ef3, 0x5c000ef3}, 682 {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x62000ef6, 0x62000ef6},
554 {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x60000ef5, 0x60000ef5}, 683 {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x66001ff0, 0x66001ff0},
555 {0x0000a560, 0x900fff0b, 0x900fff0b, 0x62000ef6, 0x62000ef6}, 684 {0x0000a560, 0x900fff0b, 0x900fff0b, 0x68001ff6, 0x68001ff6},
556 {0x0000a564, 0x960fffcb, 0x960fffcb, 0x62000ef6, 0x62000ef6}, 685 {0x0000a564, 0x960fffcb, 0x960fffcb, 0x68001ff6, 0x68001ff6},
557 {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6}, 686 {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x68001ff6, 0x68001ff6},
558 {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6}, 687 {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x68001ff6, 0x68001ff6},
559 {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6}, 688 {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x68001ff6, 0x68001ff6},
560 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6}, 689 {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x68001ff6, 0x68001ff6},
561 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6}, 690 {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x68001ff6, 0x68001ff6},
562 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x62000ef6, 0x62000ef6}, 691 {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x68001ff6, 0x68001ff6},
692 {0x0000a580, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
693 {0x0000a584, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
694 {0x0000a588, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
695 {0x0000a58c, 0x00000000, 0x00000000, 0x01804000, 0x01804000},
696 {0x0000a590, 0x00000000, 0x00000000, 0x02808a02, 0x02808a02},
697 {0x0000a594, 0x00000000, 0x00000000, 0x0340ca02, 0x0340ca02},
698 {0x0000a598, 0x00000000, 0x00000000, 0x0340cd03, 0x0340cd03},
699 {0x0000a59c, 0x00000000, 0x00000000, 0x0340cd03, 0x0340cd03},
700 {0x0000a5a0, 0x00000000, 0x00000000, 0x06415304, 0x06415304},
701 {0x0000a5a4, 0x00000000, 0x00000000, 0x04c11905, 0x04c11905},
702 {0x0000a5a8, 0x00000000, 0x00000000, 0x06415905, 0x06415905},
703 {0x0000a5ac, 0x00000000, 0x00000000, 0x06415905, 0x06415905},
704 {0x0000a5b0, 0x00000000, 0x00000000, 0x06415905, 0x06415905},
705 {0x0000a5b4, 0x00000000, 0x00000000, 0x06415905, 0x06415905},
706 {0x0000a5b8, 0x00000000, 0x00000000, 0x06415905, 0x06415905},
707 {0x0000a5bc, 0x00000000, 0x00000000, 0x06415905, 0x06415905},
563 {0x0000b500, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a}, 708 {0x0000b500, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
564 {0x0000b504, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a}, 709 {0x0000b504, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
565 {0x0000b508, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a}, 710 {0x0000b508, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a},
@@ -823,6 +968,7 @@ static const u32 ar9485_common_rx_gain_1_1[][2] = {
823 {0x00009e00, 0x03721b20}, 968 {0x00009e00, 0x03721b20},
824 {0x00009e04, 0x00082020}, 969 {0x00009e04, 0x00082020},
825 {0x00009e18, 0x0300501e}, 970 {0x00009e18, 0x0300501e},
971 {0x00009e20, 0x000003ba},
826 {0x00009e2c, 0x00002e21}, 972 {0x00009e2c, 0x00002e21},
827 {0x00009e44, 0x02182324}, 973 {0x00009e44, 0x02182324},
828 {0x0000a000, 0x00060005}, 974 {0x0000a000, 0x00060005},
@@ -1001,7 +1147,6 @@ static const u32 ar9485_1_1_baseband_postamble[][5] = {
1001 {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec80d2e, 0x7ec80d2e}, 1147 {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec80d2e, 0x7ec80d2e},
1002 {0x00009e14, 0x31395d53, 0x31396053, 0x312e6053, 0x312e5d53}, 1148 {0x00009e14, 0x31395d53, 0x31396053, 0x312e6053, 0x312e5d53},
1003 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 1149 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
1004 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
1005 {0x00009e3c, 0xcf946220, 0xcf946220, 0xcf946222, 0xcf946222}, 1150 {0x00009e3c, 0xcf946220, 0xcf946220, 0xcf946222, 0xcf946222},
1006 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302010, 0x50302010}, 1151 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302010, 0x50302010},
1007 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, 1152 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
@@ -1020,7 +1165,7 @@ static const u32 ar9485_1_1_baseband_postamble[][5] = {
1020 {0x0000a284, 0x00000000, 0x00000000, 0x000002a0, 0x000002a0}, 1165 {0x0000a284, 0x00000000, 0x00000000, 0x000002a0, 0x000002a0},
1021 {0x0000a288, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1166 {0x0000a288, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1022 {0x0000a28c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1167 {0x0000a28c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1023 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00058d18, 0x00058d18}, 1168 {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
1024 {0x0000a2d0, 0x00071981, 0x00071981, 0x00071982, 0x00071982}, 1169 {0x0000a2d0, 0x00071981, 0x00071981, 0x00071982, 0x00071982},
1025 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a}, 1170 {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a},
1026 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1171 {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
@@ -1206,6 +1351,11 @@ static const u32 ar9485_1_1_mac_core[][2] = {
1206 {0x000083d0, 0x000301ff}, 1351 {0x000083d0, 0x000301ff},
1207}; 1352};
1208 1353
1209#define ar9485_1_1_baseband_core_txfir_coeff_japan_2484 ar9462_2p0_baseband_core_txfir_coeff_japan_2484 1354static const u32 ar9485_1_1_baseband_core_txfir_coeff_japan_2484[][2] = {
1355 /* Addr allmodes */
1356 {0x0000a398, 0x00000000},
1357 {0x0000a39c, 0x6f7f0301},
1358 {0x0000a3a0, 0xca9228ee},
1359};
1210 1360
1211#endif /* INITVALS_9485_H */ 1361#endif /* INITVALS_9485_H */
diff --git a/drivers/net/wireless/ath/ath9k/ar9565_1p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9565_1p0_initvals.h
index e85a8b076c22..a8c757b6124f 100644
--- a/drivers/net/wireless/ath/ath9k/ar9565_1p0_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9565_1p0_initvals.h
@@ -272,9 +272,9 @@ static const u32 ar9565_1p0_baseband_core[][2] = {
272 {0x0000a398, 0x001f0e0f}, 272 {0x0000a398, 0x001f0e0f},
273 {0x0000a39c, 0x0075393f}, 273 {0x0000a39c, 0x0075393f},
274 {0x0000a3a0, 0xb79f6427}, 274 {0x0000a3a0, 0xb79f6427},
275 {0x0000a3a4, 0x00000000}, 275 {0x0000a3a4, 0x00000011},
276 {0x0000a3a8, 0xaaaaaaaa}, 276 {0x0000a3a8, 0xaaaaaa6e},
277 {0x0000a3ac, 0x3c466478}, 277 {0x0000a3ac, 0x3c466455},
278 {0x0000a3c0, 0x20202020}, 278 {0x0000a3c0, 0x20202020},
279 {0x0000a3c4, 0x22222220}, 279 {0x0000a3c4, 0x22222220},
280 {0x0000a3c8, 0x20200020}, 280 {0x0000a3c8, 0x20200020},
@@ -295,11 +295,11 @@ static const u32 ar9565_1p0_baseband_core[][2] = {
295 {0x0000a404, 0x00000000}, 295 {0x0000a404, 0x00000000},
296 {0x0000a408, 0x0e79e5c6}, 296 {0x0000a408, 0x0e79e5c6},
297 {0x0000a40c, 0x00820820}, 297 {0x0000a40c, 0x00820820},
298 {0x0000a414, 0x1ce739ce}, 298 {0x0000a414, 0x1ce739c5},
299 {0x0000a418, 0x2d001dce}, 299 {0x0000a418, 0x2d001dce},
300 {0x0000a41c, 0x1ce739ce}, 300 {0x0000a41c, 0x1ce739c5},
301 {0x0000a420, 0x000001ce}, 301 {0x0000a420, 0x000001ce},
302 {0x0000a424, 0x1ce739ce}, 302 {0x0000a424, 0x1ce739c5},
303 {0x0000a428, 0x000001ce}, 303 {0x0000a428, 0x000001ce},
304 {0x0000a42c, 0x1ce739ce}, 304 {0x0000a42c, 0x1ce739ce},
305 {0x0000a430, 0x1ce739ce}, 305 {0x0000a430, 0x1ce739ce},
@@ -351,9 +351,9 @@ static const u32 ar9565_1p0_baseband_postamble[][5] = {
351 {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e}, 351 {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e},
352 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 352 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
353 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 353 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
354 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, 354 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003a4, 0x000003a4},
355 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021}, 355 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
356 {0x00009e3c, 0xcf946222, 0xcf946222, 0xcf946222, 0xcf946222}, 356 {0x00009e3c, 0xcf946222, 0xcf946222, 0xcf946220, 0xcf946220},
357 {0x00009e44, 0xfe321e27, 0xfe321e27, 0xfe291e27, 0xfe291e27}, 357 {0x00009e44, 0xfe321e27, 0xfe321e27, 0xfe291e27, 0xfe291e27},
358 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012}, 358 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
359 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, 359 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
@@ -452,6 +452,7 @@ static const u32 ar9565_1p0_Common_rx_gain_table[][2] = {
452 /* Addr allmodes */ 452 /* Addr allmodes */
453 {0x00004050, 0x00300300}, 453 {0x00004050, 0x00300300},
454 {0x0000406c, 0x00100000}, 454 {0x0000406c, 0x00100000},
455 {0x00009e20, 0x000003b6},
455 {0x0000a000, 0x00010000}, 456 {0x0000a000, 0x00010000},
456 {0x0000a004, 0x00030002}, 457 {0x0000a004, 0x00030002},
457 {0x0000a008, 0x00050004}, 458 {0x0000a008, 0x00050004},
@@ -1230,4 +1231,11 @@ static const u32 ar9565_1p0_modes_high_power_tx_gain_table[][5] = {
1230 {0x00016054, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1231 {0x00016054, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1231}; 1232};
1232 1233
1234static const u32 ar9565_1p0_baseband_core_txfir_coeff_japan_2484[][2] = {
1235 /* Addr allmodes */
1236 {0x0000a398, 0x00000000},
1237 {0x0000a39c, 0x6f7f0301},
1238 {0x0000a3a0, 0xca9228ee},
1239};
1240
1233#endif /* INITVALS_9565_1P0_H */ 1241#endif /* INITVALS_9565_1P0_H */
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 2ee35f677c0e..8878f2dada2d 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -459,8 +459,8 @@ void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type);
459 459
460#define ATH_DUMP_BTCOEX(_s, _val) \ 460#define ATH_DUMP_BTCOEX(_s, _val) \
461 do { \ 461 do { \
462 len += snprintf(buf + len, size - len, \ 462 len += scnprintf(buf + len, size - len, \
463 "%20s : %10d\n", _s, (_val)); \ 463 "%20s : %10d\n", _s, (_val)); \
464 } while (0) 464 } while (0)
465 465
466enum bt_op_flags { 466enum bt_op_flags {
@@ -581,7 +581,6 @@ static inline void ath_fill_led_pin(struct ath_softc *sc)
581#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50 581#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50
582#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50 582#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50
583 583
584#define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1
585#define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 584#define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4
586#define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 585#define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2
587#define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 586#define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2
@@ -626,12 +625,15 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
626/* Main driver core */ 625/* Main driver core */
627/********************/ 626/********************/
628 627
629#define ATH9K_PCI_CUS198 0x0001 628#define ATH9K_PCI_CUS198 0x0001
630#define ATH9K_PCI_CUS230 0x0002 629#define ATH9K_PCI_CUS230 0x0002
631#define ATH9K_PCI_CUS217 0x0004 630#define ATH9K_PCI_CUS217 0x0004
632#define ATH9K_PCI_WOW 0x0008 631#define ATH9K_PCI_CUS252 0x0008
633#define ATH9K_PCI_BT_ANT_DIV 0x0010 632#define ATH9K_PCI_WOW 0x0010
634#define ATH9K_PCI_D3_L1_WAR 0x0020 633#define ATH9K_PCI_BT_ANT_DIV 0x0020
634#define ATH9K_PCI_D3_L1_WAR 0x0040
635#define ATH9K_PCI_AR9565_1ANT 0x0080
636#define ATH9K_PCI_AR9565_2ANT 0x0100
635 637
636/* 638/*
637 * Default cache line size, in bytes. 639 * Default cache line size, in bytes.
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index b5c16b3a37b9..17be35392bb4 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -334,6 +334,8 @@ void ath9k_beacon_tasklet(unsigned long data)
334 if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) { 334 if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) {
335 sc->beacon.bmisscnt++; 335 sc->beacon.bmisscnt++;
336 336
337 ath9k_hw_check_nav(ah);
338
337 if (!ath9k_hw_check_alive(ah)) 339 if (!ath9k_hw_check_alive(ah))
338 ieee80211_queue_work(sc->hw, &sc->hw_check_work); 340 ieee80211_queue_work(sc->hw, &sc->hw_check_work);
339 341
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 5e8219a91e25..d438a0341e68 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -119,7 +119,7 @@ static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah,
119 ath_dbg(common, CALIBRATE, 119 ath_dbg(common, CALIBRATE,
120 "NFmid[%d] (%d) > MAX (%d), %s\n", 120 "NFmid[%d] (%d) > MAX (%d), %s\n",
121 i, h[i].privNF, limit->max, 121 i, h[i].privNF, limit->max,
122 (cal->nfcal_interference ? 122 (test_bit(NFCAL_INTF, &cal->cal_flags) ?
123 "not corrected (due to interference)" : 123 "not corrected (due to interference)" :
124 "correcting to MAX")); 124 "correcting to MAX"));
125 125
@@ -130,7 +130,7 @@ static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah,
130 * we bypass this limit here in order to better deal 130 * we bypass this limit here in order to better deal
131 * with our environment. 131 * with our environment.
132 */ 132 */
133 if (!cal->nfcal_interference) 133 if (!test_bit(NFCAL_INTF, &cal->cal_flags))
134 h[i].privNF = limit->max; 134 h[i].privNF = limit->max;
135 } 135 }
136 } 136 }
@@ -141,7 +141,7 @@ static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah,
141 * Re-enable the enforcement of the NF maximum again. 141 * Re-enable the enforcement of the NF maximum again.
142 */ 142 */
143 if (!high_nf_mid) 143 if (!high_nf_mid)
144 cal->nfcal_interference = false; 144 clear_bit(NFCAL_INTF, &cal->cal_flags);
145} 145}
146 146
147static bool ath9k_hw_get_nf_thresh(struct ath_hw *ah, 147static bool ath9k_hw_get_nf_thresh(struct ath_hw *ah,
@@ -220,7 +220,7 @@ EXPORT_SYMBOL(ath9k_hw_reset_calvalid);
220void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update) 220void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update)
221{ 221{
222 if (ah->caldata) 222 if (ah->caldata)
223 ah->caldata->nfcal_pending = true; 223 set_bit(NFCAL_PENDING, &ah->caldata->cal_flags);
224 224
225 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, 225 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
226 AR_PHY_AGC_CONTROL_ENABLE_NF); 226 AR_PHY_AGC_CONTROL_ENABLE_NF);
@@ -391,7 +391,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan)
391 } 391 }
392 392
393 h = caldata->nfCalHist; 393 h = caldata->nfCalHist;
394 caldata->nfcal_pending = false; 394 clear_bit(NFCAL_PENDING, &caldata->cal_flags);
395 ath9k_hw_update_nfcal_hist_buffer(ah, caldata, nfarray); 395 ath9k_hw_update_nfcal_hist_buffer(ah, caldata, nfarray);
396 chan->noisefloor = h[0].privNF; 396 chan->noisefloor = h[0].privNF;
397 ah->noise = ath9k_hw_getchan_noise(ah, chan); 397 ah->noise = ath9k_hw_getchan_noise(ah, chan);
@@ -437,12 +437,12 @@ void ath9k_hw_bstuck_nfcal(struct ath_hw *ah)
437 * the baseband update the internal NF value itself, similar to 437 * the baseband update the internal NF value itself, similar to
438 * what is being done after a full reset. 438 * what is being done after a full reset.
439 */ 439 */
440 if (!caldata->nfcal_pending) 440 if (!test_bit(NFCAL_PENDING, &caldata->cal_flags))
441 ath9k_hw_start_nfcal(ah, true); 441 ath9k_hw_start_nfcal(ah, true);
442 else if (!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF)) 442 else if (!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF))
443 ath9k_hw_getnf(ah, ah->curchan); 443 ath9k_hw_getnf(ah, ah->curchan);
444 444
445 caldata->nfcal_interference = true; 445 set_bit(NFCAL_INTF, &caldata->cal_flags);
446} 446}
447EXPORT_SYMBOL(ath9k_hw_bstuck_nfcal); 447EXPORT_SYMBOL(ath9k_hw_bstuck_nfcal);
448 448
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index c088744a6bfb..1be2c787aac9 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -104,37 +104,37 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
104 return -ENOMEM; 104 return -ENOMEM;
105 105
106 if (common->disable_ani) { 106 if (common->disable_ani) {
107 len += snprintf(buf + len, size - len, "%s: %s\n", 107 len += scnprintf(buf + len, size - len, "%s: %s\n",
108 "ANI", "DISABLED"); 108 "ANI", "DISABLED");
109 goto exit; 109 goto exit;
110 } 110 }
111 111
112 len += snprintf(buf + len, size - len, "%15s: %s\n", 112 len += scnprintf(buf + len, size - len, "%15s: %s\n",
113 "ANI", "ENABLED"); 113 "ANI", "ENABLED");
114 len += snprintf(buf + len, size - len, "%15s: %u\n", 114 len += scnprintf(buf + len, size - len, "%15s: %u\n",
115 "ANI RESET", ah->stats.ast_ani_reset); 115 "ANI RESET", ah->stats.ast_ani_reset);
116 len += snprintf(buf + len, size - len, "%15s: %u\n", 116 len += scnprintf(buf + len, size - len, "%15s: %u\n",
117 "SPUR UP", ah->stats.ast_ani_spurup); 117 "SPUR UP", ah->stats.ast_ani_spurup);
118 len += snprintf(buf + len, size - len, "%15s: %u\n", 118 len += scnprintf(buf + len, size - len, "%15s: %u\n",
119 "SPUR DOWN", ah->stats.ast_ani_spurup); 119 "SPUR DOWN", ah->stats.ast_ani_spurup);
120 len += snprintf(buf + len, size - len, "%15s: %u\n", 120 len += scnprintf(buf + len, size - len, "%15s: %u\n",
121 "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon); 121 "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon);
122 len += snprintf(buf + len, size - len, "%15s: %u\n", 122 len += scnprintf(buf + len, size - len, "%15s: %u\n",
123 "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff); 123 "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff);
124 len += snprintf(buf + len, size - len, "%15s: %u\n", 124 len += scnprintf(buf + len, size - len, "%15s: %u\n",
125 "MRC-CCK ON", ah->stats.ast_ani_ccklow); 125 "MRC-CCK ON", ah->stats.ast_ani_ccklow);
126 len += snprintf(buf + len, size - len, "%15s: %u\n", 126 len += scnprintf(buf + len, size - len, "%15s: %u\n",
127 "MRC-CCK OFF", ah->stats.ast_ani_cckhigh); 127 "MRC-CCK OFF", ah->stats.ast_ani_cckhigh);
128 len += snprintf(buf + len, size - len, "%15s: %u\n", 128 len += scnprintf(buf + len, size - len, "%15s: %u\n",
129 "FIR-STEP UP", ah->stats.ast_ani_stepup); 129 "FIR-STEP UP", ah->stats.ast_ani_stepup);
130 len += snprintf(buf + len, size - len, "%15s: %u\n", 130 len += scnprintf(buf + len, size - len, "%15s: %u\n",
131 "FIR-STEP DOWN", ah->stats.ast_ani_stepdown); 131 "FIR-STEP DOWN", ah->stats.ast_ani_stepdown);
132 len += snprintf(buf + len, size - len, "%15s: %u\n", 132 len += scnprintf(buf + len, size - len, "%15s: %u\n",
133 "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero); 133 "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero);
134 len += snprintf(buf + len, size - len, "%15s: %u\n", 134 len += scnprintf(buf + len, size - len, "%15s: %u\n",
135 "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs); 135 "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs);
136 len += snprintf(buf + len, size - len, "%15s: %u\n", 136 len += scnprintf(buf + len, size - len, "%15s: %u\n",
137 "CCK ERRORS", ah->stats.ast_ani_cckerrs); 137 "CCK ERRORS", ah->stats.ast_ani_cckerrs);
138exit: 138exit:
139 if (len > size) 139 if (len > size)
140 len = size; 140 len = size;
@@ -280,70 +280,70 @@ static ssize_t read_file_antenna_diversity(struct file *file,
280 return -ENOMEM; 280 return -ENOMEM;
281 281
282 if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { 282 if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
283 len += snprintf(buf + len, size - len, "%s\n", 283 len += scnprintf(buf + len, size - len, "%s\n",
284 "Antenna Diversity Combining is disabled"); 284 "Antenna Diversity Combining is disabled");
285 goto exit; 285 goto exit;
286 } 286 }
287 287
288 ath9k_ps_wakeup(sc); 288 ath9k_ps_wakeup(sc);
289 ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); 289 ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
290 len += snprintf(buf + len, size - len, "Current MAIN config : %s\n", 290 len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n",
291 lna_conf_str[div_ant_conf.main_lna_conf]); 291 lna_conf_str[div_ant_conf.main_lna_conf]);
292 len += snprintf(buf + len, size - len, "Current ALT config : %s\n", 292 len += scnprintf(buf + len, size - len, "Current ALT config : %s\n",
293 lna_conf_str[div_ant_conf.alt_lna_conf]); 293 lna_conf_str[div_ant_conf.alt_lna_conf]);
294 len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", 294 len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
295 as_main->rssi_avg); 295 as_main->rssi_avg);
296 len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", 296 len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
297 as_alt->rssi_avg); 297 as_alt->rssi_avg);
298 ath9k_ps_restore(sc); 298 ath9k_ps_restore(sc);
299 299
300 len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n"); 300 len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n");
301 len += snprintf(buf + len, size - len, "-------------------\n"); 301 len += scnprintf(buf + len, size - len, "-------------------\n");
302 302
303 len += snprintf(buf + len, size - len, "%30s%15s\n", 303 len += scnprintf(buf + len, size - len, "%30s%15s\n",
304 "MAIN", "ALT"); 304 "MAIN", "ALT");
305 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 305 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
306 "TOTAL COUNT", 306 "TOTAL COUNT",
307 as_main->recv_cnt, 307 as_main->recv_cnt,
308 as_alt->recv_cnt); 308 as_alt->recv_cnt);
309 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 309 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
310 "LNA1", 310 "LNA1",
311 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], 311 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
312 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); 312 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
313 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 313 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
314 "LNA2", 314 "LNA2",
315 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], 315 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
316 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); 316 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
317 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 317 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
318 "LNA1 + LNA2", 318 "LNA1 + LNA2",
319 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], 319 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
320 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 320 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
321 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 321 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
322 "LNA1 - LNA2", 322 "LNA1 - LNA2",
323 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 323 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
324 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 324 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
325 325
326 len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); 326 len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
327 len += snprintf(buf + len, size - len, "--------------------\n"); 327 len += scnprintf(buf + len, size - len, "--------------------\n");
328 328
329 len += snprintf(buf + len, size - len, "%30s%15s\n", 329 len += scnprintf(buf + len, size - len, "%30s%15s\n",
330 "MAIN", "ALT"); 330 "MAIN", "ALT");
331 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 331 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
332 "LNA1", 332 "LNA1",
333 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], 333 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
334 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); 334 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
335 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 335 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
336 "LNA2", 336 "LNA2",
337 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], 337 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
338 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); 338 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
339 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 339 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
340 "LNA1 + LNA2", 340 "LNA1 + LNA2",
341 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], 341 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
342 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 342 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
343 len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 343 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
344 "LNA1 - LNA2", 344 "LNA1 - LNA2",
345 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 345 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
346 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 346 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
347 347
348exit: 348exit:
349 if (len > size) 349 if (len > size)
@@ -385,21 +385,21 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
385 (AR_MACMISC_MISC_OBS_BUS_1 << 385 (AR_MACMISC_MISC_OBS_BUS_1 <<
386 AR_MACMISC_MISC_OBS_BUS_MSB_S))); 386 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
387 387
388 len += snprintf(buf + len, DMA_BUF_LEN - len, 388 len += scnprintf(buf + len, DMA_BUF_LEN - len,
389 "Raw DMA Debug values:\n"); 389 "Raw DMA Debug values:\n");
390 390
391 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 391 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
392 if (i % 4 == 0) 392 if (i % 4 == 0)
393 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 393 len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n");
394 394
395 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 395 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
396 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 396 len += scnprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
397 i, val[i]); 397 i, val[i]);
398 } 398 }
399 399
400 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 400 len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
401 len += snprintf(buf + len, DMA_BUF_LEN - len, 401 len += scnprintf(buf + len, DMA_BUF_LEN - len,
402 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 402 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
403 403
404 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 404 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
405 if (i == 8) { 405 if (i == 8) {
@@ -412,39 +412,39 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
412 dcuBase++; 412 dcuBase++;
413 } 413 }
414 414
415 len += snprintf(buf + len, DMA_BUF_LEN - len, 415 len += scnprintf(buf + len, DMA_BUF_LEN - len,
416 "%2d %2x %1x %2x %2x\n", 416 "%2d %2x %1x %2x %2x\n",
417 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 417 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
418 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 418 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
419 val[2] & (0x7 << (i * 3)) >> (i * 3), 419 val[2] & (0x7 << (i * 3)) >> (i * 3),
420 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 420 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
421 } 421 }
422 422
423 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 423 len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n");
424 424
425 len += snprintf(buf + len, DMA_BUF_LEN - len, 425 len += scnprintf(buf + len, DMA_BUF_LEN - len,
426 "qcu_stitch state: %2x qcu_fetch state: %2x\n", 426 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
427 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 427 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
428 len += snprintf(buf + len, DMA_BUF_LEN - len, 428 len += scnprintf(buf + len, DMA_BUF_LEN - len,
429 "qcu_complete state: %2x dcu_complete state: %2x\n", 429 "qcu_complete state: %2x dcu_complete state: %2x\n",
430 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 430 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
431 len += snprintf(buf + len, DMA_BUF_LEN - len, 431 len += scnprintf(buf + len, DMA_BUF_LEN - len,
432 "dcu_arb state: %2x dcu_fp state: %2x\n", 432 "dcu_arb state: %2x dcu_fp state: %2x\n",
433 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 433 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
434 len += snprintf(buf + len, DMA_BUF_LEN - len, 434 len += scnprintf(buf + len, DMA_BUF_LEN - len,
435 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 435 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
436 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 436 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
437 len += snprintf(buf + len, DMA_BUF_LEN - len, 437 len += scnprintf(buf + len, DMA_BUF_LEN - len,
438 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 438 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
439 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 439 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
440 len += snprintf(buf + len, DMA_BUF_LEN - len, 440 len += scnprintf(buf + len, DMA_BUF_LEN - len,
441 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 441 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
442 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 442 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
443 443
444 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 444 len += scnprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
445 REG_READ_D(ah, AR_OBS_BUS_1)); 445 REG_READ_D(ah, AR_OBS_BUS_1));
446 len += snprintf(buf + len, DMA_BUF_LEN - len, 446 len += scnprintf(buf + len, DMA_BUF_LEN - len,
447 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 447 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
448 448
449 ath9k_ps_restore(sc); 449 ath9k_ps_restore(sc);
450 450
@@ -530,9 +530,9 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
530 530
531#define PR_IS(a, s) \ 531#define PR_IS(a, s) \
532 do { \ 532 do { \
533 len += snprintf(buf + len, mxlen - len, \ 533 len += scnprintf(buf + len, mxlen - len, \
534 "%21s: %10u\n", a, \ 534 "%21s: %10u\n", a, \
535 sc->debug.stats.istats.s); \ 535 sc->debug.stats.istats.s); \
536 } while (0) 536 } while (0)
537 537
538 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 538 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
@@ -563,8 +563,8 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
563 PR_IS("GENTIMER", gen_timer); 563 PR_IS("GENTIMER", gen_timer);
564 PR_IS("TOTAL", total); 564 PR_IS("TOTAL", total);
565 565
566 len += snprintf(buf + len, mxlen - len, 566 len += scnprintf(buf + len, mxlen - len,
567 "SYNC_CAUSE stats:\n"); 567 "SYNC_CAUSE stats:\n");
568 568
569 PR_IS("Sync-All", sync_cause_all); 569 PR_IS("Sync-All", sync_cause_all);
570 PR_IS("RTC-IRQ", sync_rtc_irq); 570 PR_IS("RTC-IRQ", sync_rtc_irq);
@@ -655,16 +655,16 @@ static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
655 655
656 ath_txq_lock(sc, txq); 656 ath_txq_lock(sc, txq);
657 657
658 len += snprintf(buf + len, size - len, "%s: %d ", 658 len += scnprintf(buf + len, size - len, "%s: %d ",
659 "qnum", txq->axq_qnum); 659 "qnum", txq->axq_qnum);
660 len += snprintf(buf + len, size - len, "%s: %2d ", 660 len += scnprintf(buf + len, size - len, "%s: %2d ",
661 "qdepth", txq->axq_depth); 661 "qdepth", txq->axq_depth);
662 len += snprintf(buf + len, size - len, "%s: %2d ", 662 len += scnprintf(buf + len, size - len, "%s: %2d ",
663 "ampdu-depth", txq->axq_ampdu_depth); 663 "ampdu-depth", txq->axq_ampdu_depth);
664 len += snprintf(buf + len, size - len, "%s: %3d ", 664 len += scnprintf(buf + len, size - len, "%s: %3d ",
665 "pending", txq->pending_frames); 665 "pending", txq->pending_frames);
666 len += snprintf(buf + len, size - len, "%s: %d\n", 666 len += scnprintf(buf + len, size - len, "%s: %d\n",
667 "stopped", txq->stopped); 667 "stopped", txq->stopped);
668 668
669 ath_txq_unlock(sc, txq); 669 ath_txq_unlock(sc, txq);
670 return len; 670 return len;
@@ -687,11 +687,11 @@ static ssize_t read_file_queues(struct file *file, char __user *user_buf,
687 687
688 for (i = 0; i < IEEE80211_NUM_ACS; i++) { 688 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
689 txq = sc->tx.txq_map[i]; 689 txq = sc->tx.txq_map[i];
690 len += snprintf(buf + len, size - len, "(%s): ", qname[i]); 690 len += scnprintf(buf + len, size - len, "(%s): ", qname[i]);
691 len += print_queue(sc, txq, buf + len, size - len); 691 len += print_queue(sc, txq, buf + len, size - len);
692 } 692 }
693 693
694 len += snprintf(buf + len, size - len, "(CAB): "); 694 len += scnprintf(buf + len, size - len, "(CAB): ");
695 len += print_queue(sc, sc->beacon.cabq, buf + len, size - len); 695 len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);
696 696
697 if (len > size) 697 if (len > size)
@@ -716,80 +716,82 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
716 unsigned int reg; 716 unsigned int reg;
717 u32 rxfilter; 717 u32 rxfilter;
718 718
719 len += snprintf(buf + len, sizeof(buf) - len, 719 len += scnprintf(buf + len, sizeof(buf) - len,
720 "BSSID: %pM\n", common->curbssid); 720 "BSSID: %pM\n", common->curbssid);
721 len += snprintf(buf + len, sizeof(buf) - len, 721 len += scnprintf(buf + len, sizeof(buf) - len,
722 "BSSID-MASK: %pM\n", common->bssidmask); 722 "BSSID-MASK: %pM\n", common->bssidmask);
723 len += snprintf(buf + len, sizeof(buf) - len, 723 len += scnprintf(buf + len, sizeof(buf) - len,
724 "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); 724 "OPMODE: %s\n",
725 ath_opmode_to_string(sc->sc_ah->opmode));
725 726
726 ath9k_ps_wakeup(sc); 727 ath9k_ps_wakeup(sc);
727 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); 728 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
728 ath9k_ps_restore(sc); 729 ath9k_ps_restore(sc);
729 730
730 len += snprintf(buf + len, sizeof(buf) - len, 731 len += scnprintf(buf + len, sizeof(buf) - len,
731 "RXFILTER: 0x%x", rxfilter); 732 "RXFILTER: 0x%x", rxfilter);
732 733
733 if (rxfilter & ATH9K_RX_FILTER_UCAST) 734 if (rxfilter & ATH9K_RX_FILTER_UCAST)
734 len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 735 len += scnprintf(buf + len, sizeof(buf) - len, " UCAST");
735 if (rxfilter & ATH9K_RX_FILTER_MCAST) 736 if (rxfilter & ATH9K_RX_FILTER_MCAST)
736 len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 737 len += scnprintf(buf + len, sizeof(buf) - len, " MCAST");
737 if (rxfilter & ATH9K_RX_FILTER_BCAST) 738 if (rxfilter & ATH9K_RX_FILTER_BCAST)
738 len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 739 len += scnprintf(buf + len, sizeof(buf) - len, " BCAST");
739 if (rxfilter & ATH9K_RX_FILTER_CONTROL) 740 if (rxfilter & ATH9K_RX_FILTER_CONTROL)
740 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 741 len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL");
741 if (rxfilter & ATH9K_RX_FILTER_BEACON) 742 if (rxfilter & ATH9K_RX_FILTER_BEACON)
742 len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 743 len += scnprintf(buf + len, sizeof(buf) - len, " BEACON");
743 if (rxfilter & ATH9K_RX_FILTER_PROM) 744 if (rxfilter & ATH9K_RX_FILTER_PROM)
744 len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 745 len += scnprintf(buf + len, sizeof(buf) - len, " PROM");
745 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) 746 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
746 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 747 len += scnprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
747 if (rxfilter & ATH9K_RX_FILTER_PHYERR) 748 if (rxfilter & ATH9K_RX_FILTER_PHYERR)
748 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 749 len += scnprintf(buf + len, sizeof(buf) - len, " PHYERR");
749 if (rxfilter & ATH9K_RX_FILTER_MYBEACON) 750 if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
750 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 751 len += scnprintf(buf + len, sizeof(buf) - len, " MYBEACON");
751 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) 752 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
752 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 753 len += scnprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
753 if (rxfilter & ATH9K_RX_FILTER_PSPOLL) 754 if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
754 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 755 len += scnprintf(buf + len, sizeof(buf) - len, " PSPOLL");
755 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) 756 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
756 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 757 len += scnprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
757 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 758 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
758 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 759 len += scnprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
759 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) 760 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
760 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); 761 len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER");
761 762
762 len += snprintf(buf + len, sizeof(buf) - len, "\n"); 763 len += scnprintf(buf + len, sizeof(buf) - len, "\n");
763 764
764 reg = sc->sc_ah->imask; 765 reg = sc->sc_ah->imask;
765 766
766 len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); 767 len += scnprintf(buf + len, sizeof(buf) - len,
768 "INTERRUPT-MASK: 0x%x", reg);
767 769
768 if (reg & ATH9K_INT_SWBA) 770 if (reg & ATH9K_INT_SWBA)
769 len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); 771 len += scnprintf(buf + len, sizeof(buf) - len, " SWBA");
770 if (reg & ATH9K_INT_BMISS) 772 if (reg & ATH9K_INT_BMISS)
771 len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); 773 len += scnprintf(buf + len, sizeof(buf) - len, " BMISS");
772 if (reg & ATH9K_INT_CST) 774 if (reg & ATH9K_INT_CST)
773 len += snprintf(buf + len, sizeof(buf) - len, " CST"); 775 len += scnprintf(buf + len, sizeof(buf) - len, " CST");
774 if (reg & ATH9K_INT_RX) 776 if (reg & ATH9K_INT_RX)
775 len += snprintf(buf + len, sizeof(buf) - len, " RX"); 777 len += scnprintf(buf + len, sizeof(buf) - len, " RX");
776 if (reg & ATH9K_INT_RXHP) 778 if (reg & ATH9K_INT_RXHP)
777 len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); 779 len += scnprintf(buf + len, sizeof(buf) - len, " RXHP");
778 if (reg & ATH9K_INT_RXLP) 780 if (reg & ATH9K_INT_RXLP)
779 len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); 781 len += scnprintf(buf + len, sizeof(buf) - len, " RXLP");
780 if (reg & ATH9K_INT_BB_WATCHDOG) 782 if (reg & ATH9K_INT_BB_WATCHDOG)
781 len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); 783 len += scnprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG");
782 784
783 len += snprintf(buf + len, sizeof(buf) - len, "\n"); 785 len += scnprintf(buf + len, sizeof(buf) - len, "\n");
784 786
785 ath9k_calculate_iter_data(hw, NULL, &iter_data); 787 ath9k_calculate_iter_data(hw, NULL, &iter_data);
786 788
787 len += snprintf(buf + len, sizeof(buf) - len, 789 len += scnprintf(buf + len, sizeof(buf) - len,
788 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" 790 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
789 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", 791 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
790 iter_data.naps, iter_data.nstations, iter_data.nmeshes, 792 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
791 iter_data.nwds, iter_data.nadhocs, 793 iter_data.nwds, iter_data.nadhocs,
792 sc->nvifs, sc->nbcnvifs); 794 sc->nvifs, sc->nbcnvifs);
793 795
794 if (len > sizeof(buf)) 796 if (len > sizeof(buf))
795 len = sizeof(buf); 797 len = sizeof(buf);
@@ -805,27 +807,27 @@ static ssize_t read_file_reset(struct file *file, char __user *user_buf,
805 char buf[512]; 807 char buf[512];
806 unsigned int len = 0; 808 unsigned int len = 0;
807 809
808 len += snprintf(buf + len, sizeof(buf) - len, 810 len += scnprintf(buf + len, sizeof(buf) - len,
809 "%17s: %2d\n", "Baseband Hang", 811 "%17s: %2d\n", "Baseband Hang",
810 sc->debug.stats.reset[RESET_TYPE_BB_HANG]); 812 sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
811 len += snprintf(buf + len, sizeof(buf) - len, 813 len += scnprintf(buf + len, sizeof(buf) - len,
812 "%17s: %2d\n", "Baseband Watchdog", 814 "%17s: %2d\n", "Baseband Watchdog",
813 sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); 815 sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
814 len += snprintf(buf + len, sizeof(buf) - len, 816 len += scnprintf(buf + len, sizeof(buf) - len,
815 "%17s: %2d\n", "Fatal HW Error", 817 "%17s: %2d\n", "Fatal HW Error",
816 sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); 818 sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
817 len += snprintf(buf + len, sizeof(buf) - len, 819 len += scnprintf(buf + len, sizeof(buf) - len,
818 "%17s: %2d\n", "TX HW error", 820 "%17s: %2d\n", "TX HW error",
819 sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); 821 sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
820 len += snprintf(buf + len, sizeof(buf) - len, 822 len += scnprintf(buf + len, sizeof(buf) - len,
821 "%17s: %2d\n", "TX Path Hang", 823 "%17s: %2d\n", "TX Path Hang",
822 sc->debug.stats.reset[RESET_TYPE_TX_HANG]); 824 sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
823 len += snprintf(buf + len, sizeof(buf) - len, 825 len += scnprintf(buf + len, sizeof(buf) - len,
824 "%17s: %2d\n", "PLL RX Hang", 826 "%17s: %2d\n", "PLL RX Hang",
825 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 827 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
826 len += snprintf(buf + len, sizeof(buf) - len, 828 len += scnprintf(buf + len, sizeof(buf) - len,
827 "%17s: %2d\n", "MCI Reset", 829 "%17s: %2d\n", "MCI Reset",
828 sc->debug.stats.reset[RESET_TYPE_MCI]); 830 sc->debug.stats.reset[RESET_TYPE_MCI]);
829 831
830 if (len > sizeof(buf)) 832 if (len > sizeof(buf))
831 len = sizeof(buf); 833 len = sizeof(buf);
@@ -902,14 +904,14 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
902 size_t count, loff_t *ppos) 904 size_t count, loff_t *ppos)
903{ 905{
904#define PHY_ERR(s, p) \ 906#define PHY_ERR(s, p) \
905 len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ 907 len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \
906 sc->debug.stats.rxstats.phy_err_stats[p]); 908 sc->debug.stats.rxstats.phy_err_stats[p]);
907 909
908#define RXS_ERR(s, e) \ 910#define RXS_ERR(s, e) \
909 do { \ 911 do { \
910 len += snprintf(buf + len, size - len, \ 912 len += scnprintf(buf + len, size - len, \
911 "%22s : %10u\n", s, \ 913 "%22s : %10u\n", s, \
912 sc->debug.stats.rxstats.e); \ 914 sc->debug.stats.rxstats.e);\
913 } while (0) 915 } while (0)
914 916
915 struct ath_softc *sc = file->private_data; 917 struct ath_softc *sc = file->private_data;
@@ -1439,22 +1441,22 @@ static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1439 if (!buf) 1441 if (!buf)
1440 return -ENOMEM; 1442 return -ENOMEM;
1441 1443
1442 len += snprintf(buf + len, size - len, 1444 len += scnprintf(buf + len, size - len,
1443 "Channel Noise Floor : %d\n", ah->noise); 1445 "Channel Noise Floor : %d\n", ah->noise);
1444 len += snprintf(buf + len, size - len, 1446 len += scnprintf(buf + len, size - len,
1445 "Chain | privNF | # Readings | NF Readings\n"); 1447 "Chain | privNF | # Readings | NF Readings\n");
1446 for (i = 0; i < NUM_NF_READINGS; i++) { 1448 for (i = 0; i < NUM_NF_READINGS; i++) {
1447 if (!(chainmask & (1 << i)) || 1449 if (!(chainmask & (1 << i)) ||
1448 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1450 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1449 continue; 1451 continue;
1450 1452
1451 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1453 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
1452 len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1454 len += scnprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
1453 i, h[i].privNF, nread); 1455 i, h[i].privNF, nread);
1454 for (j = 0; j < nread; j++) 1456 for (j = 0; j < nread; j++)
1455 len += snprintf(buf + len, size - len, 1457 len += scnprintf(buf + len, size - len,
1456 " %d", h[i].nfCalBuffer[j]); 1458 " %d", h[i].nfCalBuffer[j]);
1457 len += snprintf(buf + len, size - len, "\n"); 1459 len += scnprintf(buf + len, size - len, "\n");
1458 } 1460 }
1459 1461
1460 if (len > size) 1462 if (len > size)
@@ -1543,8 +1545,8 @@ static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
1543 return -ENOMEM; 1545 return -ENOMEM;
1544 1546
1545 if (!sc->sc_ah->common.btcoex_enabled) { 1547 if (!sc->sc_ah->common.btcoex_enabled) {
1546 len = snprintf(buf, size, "%s\n", 1548 len = scnprintf(buf, size, "%s\n",
1547 "BTCOEX is disabled"); 1549 "BTCOEX is disabled");
1548 goto exit; 1550 goto exit;
1549 } 1551 }
1550 1552
@@ -1582,43 +1584,43 @@ static ssize_t read_file_node_stat(struct file *file, char __user *user_buf,
1582 return -ENOMEM; 1584 return -ENOMEM;
1583 1585
1584 if (!an->sta->ht_cap.ht_supported) { 1586 if (!an->sta->ht_cap.ht_supported) {
1585 len = snprintf(buf, size, "%s\n", 1587 len = scnprintf(buf, size, "%s\n",
1586 "HT not supported"); 1588 "HT not supported");
1587 goto exit; 1589 goto exit;
1588 } 1590 }
1589 1591
1590 len = snprintf(buf, size, "Max-AMPDU: %d\n", 1592 len = scnprintf(buf, size, "Max-AMPDU: %d\n",
1591 an->maxampdu); 1593 an->maxampdu);
1592 len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n", 1594 len += scnprintf(buf + len, size - len, "MPDU Density: %d\n\n",
1593 an->mpdudensity); 1595 an->mpdudensity);
1594 1596
1595 len += snprintf(buf + len, size - len, 1597 len += scnprintf(buf + len, size - len,
1596 "%2s%7s\n", "AC", "SCHED"); 1598 "%2s%7s\n", "AC", "SCHED");
1597 1599
1598 for (acno = 0, ac = &an->ac[acno]; 1600 for (acno = 0, ac = &an->ac[acno];
1599 acno < IEEE80211_NUM_ACS; acno++, ac++) { 1601 acno < IEEE80211_NUM_ACS; acno++, ac++) {
1600 txq = ac->txq; 1602 txq = ac->txq;
1601 ath_txq_lock(sc, txq); 1603 ath_txq_lock(sc, txq);
1602 len += snprintf(buf + len, size - len, 1604 len += scnprintf(buf + len, size - len,
1603 "%2d%7d\n", 1605 "%2d%7d\n",
1604 acno, ac->sched); 1606 acno, ac->sched);
1605 ath_txq_unlock(sc, txq); 1607 ath_txq_unlock(sc, txq);
1606 } 1608 }
1607 1609
1608 len += snprintf(buf + len, size - len, 1610 len += scnprintf(buf + len, size - len,
1609 "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 1611 "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
1610 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 1612 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
1611 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 1613 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
1612 1614
1613 for (tidno = 0, tid = &an->tid[tidno]; 1615 for (tidno = 0, tid = &an->tid[tidno];
1614 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1616 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
1615 txq = tid->ac->txq; 1617 txq = tid->ac->txq;
1616 ath_txq_lock(sc, txq); 1618 ath_txq_lock(sc, txq);
1617 len += snprintf(buf + len, size - len, 1619 len += scnprintf(buf + len, size - len,
1618 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 1620 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n",
1619 tid->tidno, tid->seq_start, tid->seq_next, 1621 tid->tidno, tid->seq_start, tid->seq_next,
1620 tid->baw_size, tid->baw_head, tid->baw_tail, 1622 tid->baw_size, tid->baw_head, tid->baw_tail,
1621 tid->bar_index, tid->sched, tid->paused); 1623 tid->bar_index, tid->sched, tid->paused);
1622 ath_txq_unlock(sc, txq); 1624 ath_txq_unlock(sc, txq);
1623 } 1625 }
1624exit: 1626exit:
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 6e1556fa2f3e..d6e3fa4299a4 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -193,12 +193,12 @@ struct ath_tx_stats {
193#define TXSTATS sc->debug.stats.txstats 193#define TXSTATS sc->debug.stats.txstats
194#define PR(str, elem) \ 194#define PR(str, elem) \
195 do { \ 195 do { \
196 len += snprintf(buf + len, size - len, \ 196 len += scnprintf(buf + len, size - len, \
197 "%s%13u%11u%10u%10u\n", str, \ 197 "%s%13u%11u%10u%10u\n", str, \
198 TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem, \ 198 TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\
199 TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem, \ 199 TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\
200 TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem, \ 200 TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\
201 TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \ 201 TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \
202 } while(0) 202 } while(0)
203 203
204#define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++) 204#define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++)
diff --git a/drivers/net/wireless/ath/ath9k/dfs_debug.c b/drivers/net/wireless/ath/ath9k/dfs_debug.c
index 3c6e4138a95d..821599135d8a 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_debug.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_debug.c
@@ -25,11 +25,11 @@
25struct ath_dfs_pool_stats global_dfs_pool_stats = { 0 }; 25struct ath_dfs_pool_stats global_dfs_pool_stats = { 0 };
26 26
27#define ATH9K_DFS_STAT(s, p) \ 27#define ATH9K_DFS_STAT(s, p) \
28 len += snprintf(buf + len, size - len, "%28s : %10u\n", s, \ 28 len += scnprintf(buf + len, size - len, "%28s : %10u\n", s, \
29 sc->debug.stats.dfs_stats.p); 29 sc->debug.stats.dfs_stats.p);
30#define ATH9K_DFS_POOL_STAT(s, p) \ 30#define ATH9K_DFS_POOL_STAT(s, p) \
31 len += snprintf(buf + len, size - len, "%28s : %10u\n", s, \ 31 len += scnprintf(buf + len, size - len, "%28s : %10u\n", s, \
32 global_dfs_pool_stats.p); 32 global_dfs_pool_stats.p);
33 33
34static ssize_t read_file_dfs(struct file *file, char __user *user_buf, 34static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos) 35 size_t count, loff_t *ppos)
@@ -44,12 +44,12 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
44 if (buf == NULL) 44 if (buf == NULL)
45 return -ENOMEM; 45 return -ENOMEM;
46 46
47 len += snprintf(buf + len, size - len, "DFS support for " 47 len += scnprintf(buf + len, size - len, "DFS support for "
48 "macVersion = 0x%x, macRev = 0x%x: %s\n", 48 "macVersion = 0x%x, macRev = 0x%x: %s\n",
49 hw_ver->macVersion, hw_ver->macRev, 49 hw_ver->macVersion, hw_ver->macRev,
50 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ? 50 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ?
51 "enabled" : "disabled"); 51 "enabled" : "disabled");
52 len += snprintf(buf + len, size - len, "Pulse detector statistics:\n"); 52 len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n");
53 ATH9K_DFS_STAT("pulse events reported ", pulses_total); 53 ATH9K_DFS_STAT("pulse events reported ", pulses_total);
54 ATH9K_DFS_STAT("invalid pulse events ", pulses_no_dfs); 54 ATH9K_DFS_STAT("invalid pulse events ", pulses_no_dfs);
55 ATH9K_DFS_STAT("DFS pulses detected ", pulses_detected); 55 ATH9K_DFS_STAT("DFS pulses detected ", pulses_detected);
@@ -59,11 +59,12 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
59 ATH9K_DFS_STAT("Primary channel pulses ", pri_phy_errors); 59 ATH9K_DFS_STAT("Primary channel pulses ", pri_phy_errors);
60 ATH9K_DFS_STAT("Secondary channel pulses", ext_phy_errors); 60 ATH9K_DFS_STAT("Secondary channel pulses", ext_phy_errors);
61 ATH9K_DFS_STAT("Dual channel pulses ", dc_phy_errors); 61 ATH9K_DFS_STAT("Dual channel pulses ", dc_phy_errors);
62 len += snprintf(buf + len, size - len, "Radar detector statistics " 62 len += scnprintf(buf + len, size - len, "Radar detector statistics "
63 "(current DFS region: %d)\n", sc->dfs_detector->region); 63 "(current DFS region: %d)\n",
64 sc->dfs_detector->region);
64 ATH9K_DFS_STAT("Pulse events processed ", pulses_processed); 65 ATH9K_DFS_STAT("Pulse events processed ", pulses_processed);
65 ATH9K_DFS_STAT("Radars detected ", radar_detected); 66 ATH9K_DFS_STAT("Radars detected ", radar_detected);
66 len += snprintf(buf + len, size - len, "Global Pool statistics:\n"); 67 len += scnprintf(buf + len, size - len, "Global Pool statistics:\n");
67 ATH9K_DFS_POOL_STAT("Pool references ", pool_reference); 68 ATH9K_DFS_POOL_STAT("Pool references ", pool_reference);
68 ATH9K_DFS_POOL_STAT("Pulses allocated ", pulse_allocated); 69 ATH9K_DFS_POOL_STAT("Pulses allocated ", pulse_allocated);
69 ATH9K_DFS_POOL_STAT("Pulses alloc error ", pulse_alloc_error); 70 ATH9K_DFS_POOL_STAT("Pulses alloc error ", pulse_alloc_error);
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
index 5ba4b6fe37c0..c718fc379a10 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
@@ -392,7 +392,7 @@ static struct pri_sequence *pri_detector_add_pulse(struct pri_detector *de,
392 392
393 if (!pseq_handler_create_sequences(de, ts, max_updated_seq)) { 393 if (!pseq_handler_create_sequences(de, ts, max_updated_seq)) {
394 pri_detector_reset(de, ts); 394 pri_detector_reset(de, ts);
395 return false; 395 return NULL;
396 } 396 }
397 397
398 ps = pseq_handler_check_detection(de); 398 ps = pseq_handler_check_detection(de);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index 9ea8e4b779c9..b4091716e9b3 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -129,10 +129,10 @@ static u32 ath9k_hw_4k_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
129 struct base_eep_header_4k *pBase = &eep->baseEepHeader; 129 struct base_eep_header_4k *pBase = &eep->baseEepHeader;
130 130
131 if (!dump_base_hdr) { 131 if (!dump_base_hdr) {
132 len += snprintf(buf + len, size - len, 132 len += scnprintf(buf + len, size - len,
133 "%20s :\n", "2GHz modal Header"); 133 "%20s :\n", "2GHz modal Header");
134 len = ath9k_dump_4k_modal_eeprom(buf, len, size, 134 len = ath9k_dump_4k_modal_eeprom(buf, len, size,
135 &eep->modalHeader); 135 &eep->modalHeader);
136 goto out; 136 goto out;
137 } 137 }
138 138
@@ -160,8 +160,8 @@ static u32 ath9k_hw_4k_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
160 PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); 160 PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
161 PR_EEP("TX Gain type", pBase->txGainType); 161 PR_EEP("TX Gain type", pBase->txGainType);
162 162
163 len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", 163 len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
164 pBase->macAddr); 164 pBase->macAddr);
165 165
166out: 166out:
167 if (len > size) 167 if (len > size)
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 3ae1f3df0637..e1d0c217c104 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -125,8 +125,8 @@ static u32 ath9k_hw_ar9287_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
125 struct base_eep_ar9287_header *pBase = &eep->baseEepHeader; 125 struct base_eep_ar9287_header *pBase = &eep->baseEepHeader;
126 126
127 if (!dump_base_hdr) { 127 if (!dump_base_hdr) {
128 len += snprintf(buf + len, size - len, 128 len += scnprintf(buf + len, size - len,
129 "%20s :\n", "2GHz modal Header"); 129 "%20s :\n", "2GHz modal Header");
130 len = ar9287_dump_modal_eeprom(buf, len, size, 130 len = ar9287_dump_modal_eeprom(buf, len, size,
131 &eep->modalHeader); 131 &eep->modalHeader);
132 goto out; 132 goto out;
@@ -157,8 +157,8 @@ static u32 ath9k_hw_ar9287_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
157 PR_EEP("Power Table Offset", pBase->pwrTableOffset); 157 PR_EEP("Power Table Offset", pBase->pwrTableOffset);
158 PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl); 158 PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
159 159
160 len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", 160 len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
161 pBase->macAddr); 161 pBase->macAddr);
162 162
163out: 163out:
164 if (len > size) 164 if (len > size)
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index 1c25368b3836..39107e31e79a 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -205,12 +205,12 @@ static u32 ath9k_hw_def_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
205 struct base_eep_header *pBase = &eep->baseEepHeader; 205 struct base_eep_header *pBase = &eep->baseEepHeader;
206 206
207 if (!dump_base_hdr) { 207 if (!dump_base_hdr) {
208 len += snprintf(buf + len, size - len, 208 len += scnprintf(buf + len, size - len,
209 "%20s :\n", "2GHz modal Header"); 209 "%20s :\n", "2GHz modal Header");
210 len = ath9k_def_dump_modal_eeprom(buf, len, size, 210 len = ath9k_def_dump_modal_eeprom(buf, len, size,
211 &eep->modalHeader[0]); 211 &eep->modalHeader[0]);
212 len += snprintf(buf + len, size - len, 212 len += scnprintf(buf + len, size - len,
213 "%20s :\n", "5GHz modal Header"); 213 "%20s :\n", "5GHz modal Header");
214 len = ath9k_def_dump_modal_eeprom(buf, len, size, 214 len = ath9k_def_dump_modal_eeprom(buf, len, size,
215 &eep->modalHeader[1]); 215 &eep->modalHeader[1]);
216 goto out; 216 goto out;
@@ -240,8 +240,8 @@ static u32 ath9k_hw_def_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
240 PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); 240 PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
241 PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl); 241 PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
242 242
243 len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", 243 len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
244 pBase->macAddr); 244 pBase->macAddr);
245 245
246out: 246out:
247 if (len > size) 247 if (len > size)
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c
index 4b412aaf4f36..c34f21241da9 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -522,22 +522,22 @@ static int ath9k_dump_mci_btcoex(struct ath_softc *sc, u8 *buf, u32 size)
522 ATH_DUMP_BTCOEX("Concurrent Tx", btcoex_hw->mci.concur_tx); 522 ATH_DUMP_BTCOEX("Concurrent Tx", btcoex_hw->mci.concur_tx);
523 ATH_DUMP_BTCOEX("Concurrent RSSI cnt", btcoex->rssi_count); 523 ATH_DUMP_BTCOEX("Concurrent RSSI cnt", btcoex->rssi_count);
524 524
525 len += snprintf(buf + len, size - len, "BT Weights: "); 525 len += scnprintf(buf + len, size - len, "BT Weights: ");
526 for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++) 526 for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++)
527 len += snprintf(buf + len, size - len, "%08x ", 527 len += scnprintf(buf + len, size - len, "%08x ",
528 btcoex_hw->bt_weight[i]); 528 btcoex_hw->bt_weight[i]);
529 len += snprintf(buf + len, size - len, "\n"); 529 len += scnprintf(buf + len, size - len, "\n");
530 len += snprintf(buf + len, size - len, "WLAN Weights: "); 530 len += scnprintf(buf + len, size - len, "WLAN Weights: ");
531 for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++) 531 for (i = 0; i < AR9300_NUM_BT_WEIGHTS; i++)
532 len += snprintf(buf + len, size - len, "%08x ", 532 len += scnprintf(buf + len, size - len, "%08x ",
533 btcoex_hw->wlan_weight[i]); 533 btcoex_hw->wlan_weight[i]);
534 len += snprintf(buf + len, size - len, "\n"); 534 len += scnprintf(buf + len, size - len, "\n");
535 len += snprintf(buf + len, size - len, "Tx Priorities: "); 535 len += scnprintf(buf + len, size - len, "Tx Priorities: ");
536 for (i = 0; i < ATH_BTCOEX_STOMP_MAX; i++) 536 for (i = 0; i < ATH_BTCOEX_STOMP_MAX; i++)
537 len += snprintf(buf + len, size - len, "%08x ", 537 len += scnprintf(buf + len, size - len, "%08x ",
538 btcoex_hw->tx_prio[i]); 538 btcoex_hw->tx_prio[i]);
539 539
540 len += snprintf(buf + len, size - len, "\n"); 540 len += scnprintf(buf + len, size - len, "\n");
541 541
542 return len; 542 return len;
543} 543}
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
index c1b45e2f8481..fb071ee4fcfb 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -37,29 +37,29 @@ static ssize_t read_file_tgt_int_stats(struct file *file, char __user *user_buf,
37 37
38 ath9k_htc_ps_restore(priv); 38 ath9k_htc_ps_restore(priv);
39 39
40 len += snprintf(buf + len, sizeof(buf) - len, 40 len += scnprintf(buf + len, sizeof(buf) - len,
41 "%20s : %10u\n", "RX", 41 "%20s : %10u\n", "RX",
42 be32_to_cpu(cmd_rsp.rx)); 42 be32_to_cpu(cmd_rsp.rx));
43 43
44 len += snprintf(buf + len, sizeof(buf) - len, 44 len += scnprintf(buf + len, sizeof(buf) - len,
45 "%20s : %10u\n", "RXORN", 45 "%20s : %10u\n", "RXORN",
46 be32_to_cpu(cmd_rsp.rxorn)); 46 be32_to_cpu(cmd_rsp.rxorn));
47 47
48 len += snprintf(buf + len, sizeof(buf) - len, 48 len += scnprintf(buf + len, sizeof(buf) - len,
49 "%20s : %10u\n", "RXEOL", 49 "%20s : %10u\n", "RXEOL",
50 be32_to_cpu(cmd_rsp.rxeol)); 50 be32_to_cpu(cmd_rsp.rxeol));
51 51
52 len += snprintf(buf + len, sizeof(buf) - len, 52 len += scnprintf(buf + len, sizeof(buf) - len,
53 "%20s : %10u\n", "TXURN", 53 "%20s : %10u\n", "TXURN",
54 be32_to_cpu(cmd_rsp.txurn)); 54 be32_to_cpu(cmd_rsp.txurn));
55 55
56 len += snprintf(buf + len, sizeof(buf) - len, 56 len += scnprintf(buf + len, sizeof(buf) - len,
57 "%20s : %10u\n", "TXTO", 57 "%20s : %10u\n", "TXTO",
58 be32_to_cpu(cmd_rsp.txto)); 58 be32_to_cpu(cmd_rsp.txto));
59 59
60 len += snprintf(buf + len, sizeof(buf) - len, 60 len += scnprintf(buf + len, sizeof(buf) - len,
61 "%20s : %10u\n", "CST", 61 "%20s : %10u\n", "CST",
62 be32_to_cpu(cmd_rsp.cst)); 62 be32_to_cpu(cmd_rsp.cst));
63 63
64 if (len > sizeof(buf)) 64 if (len > sizeof(buf))
65 len = sizeof(buf); 65 len = sizeof(buf);
@@ -95,41 +95,41 @@ static ssize_t read_file_tgt_tx_stats(struct file *file, char __user *user_buf,
95 95
96 ath9k_htc_ps_restore(priv); 96 ath9k_htc_ps_restore(priv);
97 97
98 len += snprintf(buf + len, sizeof(buf) - len, 98 len += scnprintf(buf + len, sizeof(buf) - len,
99 "%20s : %10u\n", "Xretries", 99 "%20s : %10u\n", "Xretries",
100 be32_to_cpu(cmd_rsp.xretries)); 100 be32_to_cpu(cmd_rsp.xretries));
101 101
102 len += snprintf(buf + len, sizeof(buf) - len, 102 len += scnprintf(buf + len, sizeof(buf) - len,
103 "%20s : %10u\n", "FifoErr", 103 "%20s : %10u\n", "FifoErr",
104 be32_to_cpu(cmd_rsp.fifoerr)); 104 be32_to_cpu(cmd_rsp.fifoerr));
105 105
106 len += snprintf(buf + len, sizeof(buf) - len, 106 len += scnprintf(buf + len, sizeof(buf) - len,
107 "%20s : %10u\n", "Filtered", 107 "%20s : %10u\n", "Filtered",
108 be32_to_cpu(cmd_rsp.filtered)); 108 be32_to_cpu(cmd_rsp.filtered));
109 109
110 len += snprintf(buf + len, sizeof(buf) - len, 110 len += scnprintf(buf + len, sizeof(buf) - len,
111 "%20s : %10u\n", "TimerExp", 111 "%20s : %10u\n", "TimerExp",
112 be32_to_cpu(cmd_rsp.timer_exp)); 112 be32_to_cpu(cmd_rsp.timer_exp));
113 113
114 len += snprintf(buf + len, sizeof(buf) - len, 114 len += scnprintf(buf + len, sizeof(buf) - len,
115 "%20s : %10u\n", "ShortRetries", 115 "%20s : %10u\n", "ShortRetries",
116 be32_to_cpu(cmd_rsp.shortretries)); 116 be32_to_cpu(cmd_rsp.shortretries));
117 117
118 len += snprintf(buf + len, sizeof(buf) - len, 118 len += scnprintf(buf + len, sizeof(buf) - len,
119 "%20s : %10u\n", "LongRetries", 119 "%20s : %10u\n", "LongRetries",
120 be32_to_cpu(cmd_rsp.longretries)); 120 be32_to_cpu(cmd_rsp.longretries));
121 121
122 len += snprintf(buf + len, sizeof(buf) - len, 122 len += scnprintf(buf + len, sizeof(buf) - len,
123 "%20s : %10u\n", "QueueNull", 123 "%20s : %10u\n", "QueueNull",
124 be32_to_cpu(cmd_rsp.qnull)); 124 be32_to_cpu(cmd_rsp.qnull));
125 125
126 len += snprintf(buf + len, sizeof(buf) - len, 126 len += scnprintf(buf + len, sizeof(buf) - len,
127 "%20s : %10u\n", "EncapFail", 127 "%20s : %10u\n", "EncapFail",
128 be32_to_cpu(cmd_rsp.encap_fail)); 128 be32_to_cpu(cmd_rsp.encap_fail));
129 129
130 len += snprintf(buf + len, sizeof(buf) - len, 130 len += scnprintf(buf + len, sizeof(buf) - len,
131 "%20s : %10u\n", "NoBuf", 131 "%20s : %10u\n", "NoBuf",
132 be32_to_cpu(cmd_rsp.nobuf)); 132 be32_to_cpu(cmd_rsp.nobuf));
133 133
134 if (len > sizeof(buf)) 134 if (len > sizeof(buf))
135 len = sizeof(buf); 135 len = sizeof(buf);
@@ -165,17 +165,17 @@ static ssize_t read_file_tgt_rx_stats(struct file *file, char __user *user_buf,
165 165
166 ath9k_htc_ps_restore(priv); 166 ath9k_htc_ps_restore(priv);
167 167
168 len += snprintf(buf + len, sizeof(buf) - len, 168 len += scnprintf(buf + len, sizeof(buf) - len,
169 "%20s : %10u\n", "NoBuf", 169 "%20s : %10u\n", "NoBuf",
170 be32_to_cpu(cmd_rsp.nobuf)); 170 be32_to_cpu(cmd_rsp.nobuf));
171 171
172 len += snprintf(buf + len, sizeof(buf) - len, 172 len += scnprintf(buf + len, sizeof(buf) - len,
173 "%20s : %10u\n", "HostSend", 173 "%20s : %10u\n", "HostSend",
174 be32_to_cpu(cmd_rsp.host_send)); 174 be32_to_cpu(cmd_rsp.host_send));
175 175
176 len += snprintf(buf + len, sizeof(buf) - len, 176 len += scnprintf(buf + len, sizeof(buf) - len,
177 "%20s : %10u\n", "HostDone", 177 "%20s : %10u\n", "HostDone",
178 be32_to_cpu(cmd_rsp.host_done)); 178 be32_to_cpu(cmd_rsp.host_done));
179 179
180 if (len > sizeof(buf)) 180 if (len > sizeof(buf))
181 len = sizeof(buf); 181 len = sizeof(buf);
@@ -197,37 +197,37 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
197 char buf[512]; 197 char buf[512];
198 unsigned int len = 0; 198 unsigned int len = 0;
199 199
200 len += snprintf(buf + len, sizeof(buf) - len, 200 len += scnprintf(buf + len, sizeof(buf) - len,
201 "%20s : %10u\n", "Buffers queued", 201 "%20s : %10u\n", "Buffers queued",
202 priv->debug.tx_stats.buf_queued); 202 priv->debug.tx_stats.buf_queued);
203 len += snprintf(buf + len, sizeof(buf) - len, 203 len += scnprintf(buf + len, sizeof(buf) - len,
204 "%20s : %10u\n", "Buffers completed", 204 "%20s : %10u\n", "Buffers completed",
205 priv->debug.tx_stats.buf_completed); 205 priv->debug.tx_stats.buf_completed);
206 len += snprintf(buf + len, sizeof(buf) - len, 206 len += scnprintf(buf + len, sizeof(buf) - len,
207 "%20s : %10u\n", "SKBs queued", 207 "%20s : %10u\n", "SKBs queued",
208 priv->debug.tx_stats.skb_queued); 208 priv->debug.tx_stats.skb_queued);
209 len += snprintf(buf + len, sizeof(buf) - len, 209 len += scnprintf(buf + len, sizeof(buf) - len,
210 "%20s : %10u\n", "SKBs success", 210 "%20s : %10u\n", "SKBs success",
211 priv->debug.tx_stats.skb_success); 211 priv->debug.tx_stats.skb_success);
212 len += snprintf(buf + len, sizeof(buf) - len, 212 len += scnprintf(buf + len, sizeof(buf) - len,
213 "%20s : %10u\n", "SKBs failed", 213 "%20s : %10u\n", "SKBs failed",
214 priv->debug.tx_stats.skb_failed); 214 priv->debug.tx_stats.skb_failed);
215 len += snprintf(buf + len, sizeof(buf) - len, 215 len += scnprintf(buf + len, sizeof(buf) - len,
216 "%20s : %10u\n", "CAB queued", 216 "%20s : %10u\n", "CAB queued",
217 priv->debug.tx_stats.cab_queued); 217 priv->debug.tx_stats.cab_queued);
218 218
219 len += snprintf(buf + len, sizeof(buf) - len, 219 len += scnprintf(buf + len, sizeof(buf) - len,
220 "%20s : %10u\n", "BE queued", 220 "%20s : %10u\n", "BE queued",
221 priv->debug.tx_stats.queue_stats[IEEE80211_AC_BE]); 221 priv->debug.tx_stats.queue_stats[IEEE80211_AC_BE]);
222 len += snprintf(buf + len, sizeof(buf) - len, 222 len += scnprintf(buf + len, sizeof(buf) - len,
223 "%20s : %10u\n", "BK queued", 223 "%20s : %10u\n", "BK queued",
224 priv->debug.tx_stats.queue_stats[IEEE80211_AC_BK]); 224 priv->debug.tx_stats.queue_stats[IEEE80211_AC_BK]);
225 len += snprintf(buf + len, sizeof(buf) - len, 225 len += scnprintf(buf + len, sizeof(buf) - len,
226 "%20s : %10u\n", "VI queued", 226 "%20s : %10u\n", "VI queued",
227 priv->debug.tx_stats.queue_stats[IEEE80211_AC_VI]); 227 priv->debug.tx_stats.queue_stats[IEEE80211_AC_VI]);
228 len += snprintf(buf + len, sizeof(buf) - len, 228 len += scnprintf(buf + len, sizeof(buf) - len,
229 "%20s : %10u\n", "VO queued", 229 "%20s : %10u\n", "VO queued",
230 priv->debug.tx_stats.queue_stats[IEEE80211_AC_VO]); 230 priv->debug.tx_stats.queue_stats[IEEE80211_AC_VO]);
231 231
232 if (len > sizeof(buf)) 232 if (len > sizeof(buf))
233 len = sizeof(buf); 233 len = sizeof(buf);
@@ -273,8 +273,8 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
273 size_t count, loff_t *ppos) 273 size_t count, loff_t *ppos)
274{ 274{
275#define PHY_ERR(s, p) \ 275#define PHY_ERR(s, p) \
276 len += snprintf(buf + len, size - len, "%20s : %10u\n", s, \ 276 len += scnprintf(buf + len, size - len, "%20s : %10u\n", s, \
277 priv->debug.rx_stats.err_phy_stats[p]); 277 priv->debug.rx_stats.err_phy_stats[p]);
278 278
279 struct ath9k_htc_priv *priv = file->private_data; 279 struct ath9k_htc_priv *priv = file->private_data;
280 char *buf; 280 char *buf;
@@ -285,37 +285,37 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
285 if (buf == NULL) 285 if (buf == NULL)
286 return -ENOMEM; 286 return -ENOMEM;
287 287
288 len += snprintf(buf + len, size - len, 288 len += scnprintf(buf + len, size - len,
289 "%20s : %10u\n", "SKBs allocated", 289 "%20s : %10u\n", "SKBs allocated",
290 priv->debug.rx_stats.skb_allocated); 290 priv->debug.rx_stats.skb_allocated);
291 len += snprintf(buf + len, size - len, 291 len += scnprintf(buf + len, size - len,
292 "%20s : %10u\n", "SKBs completed", 292 "%20s : %10u\n", "SKBs completed",
293 priv->debug.rx_stats.skb_completed); 293 priv->debug.rx_stats.skb_completed);
294 len += snprintf(buf + len, size - len, 294 len += scnprintf(buf + len, size - len,
295 "%20s : %10u\n", "SKBs Dropped", 295 "%20s : %10u\n", "SKBs Dropped",
296 priv->debug.rx_stats.skb_dropped); 296 priv->debug.rx_stats.skb_dropped);
297 297
298 len += snprintf(buf + len, size - len, 298 len += scnprintf(buf + len, size - len,
299 "%20s : %10u\n", "CRC ERR", 299 "%20s : %10u\n", "CRC ERR",
300 priv->debug.rx_stats.err_crc); 300 priv->debug.rx_stats.err_crc);
301 len += snprintf(buf + len, size - len, 301 len += scnprintf(buf + len, size - len,
302 "%20s : %10u\n", "DECRYPT CRC ERR", 302 "%20s : %10u\n", "DECRYPT CRC ERR",
303 priv->debug.rx_stats.err_decrypt_crc); 303 priv->debug.rx_stats.err_decrypt_crc);
304 len += snprintf(buf + len, size - len, 304 len += scnprintf(buf + len, size - len,
305 "%20s : %10u\n", "MIC ERR", 305 "%20s : %10u\n", "MIC ERR",
306 priv->debug.rx_stats.err_mic); 306 priv->debug.rx_stats.err_mic);
307 len += snprintf(buf + len, size - len, 307 len += scnprintf(buf + len, size - len,
308 "%20s : %10u\n", "PRE-DELIM CRC ERR", 308 "%20s : %10u\n", "PRE-DELIM CRC ERR",
309 priv->debug.rx_stats.err_pre_delim); 309 priv->debug.rx_stats.err_pre_delim);
310 len += snprintf(buf + len, size - len, 310 len += scnprintf(buf + len, size - len,
311 "%20s : %10u\n", "POST-DELIM CRC ERR", 311 "%20s : %10u\n", "POST-DELIM CRC ERR",
312 priv->debug.rx_stats.err_post_delim); 312 priv->debug.rx_stats.err_post_delim);
313 len += snprintf(buf + len, size - len, 313 len += scnprintf(buf + len, size - len,
314 "%20s : %10u\n", "DECRYPT BUSY ERR", 314 "%20s : %10u\n", "DECRYPT BUSY ERR",
315 priv->debug.rx_stats.err_decrypt_busy); 315 priv->debug.rx_stats.err_decrypt_busy);
316 len += snprintf(buf + len, size - len, 316 len += scnprintf(buf + len, size - len,
317 "%20s : %10u\n", "TOTAL PHY ERR", 317 "%20s : %10u\n", "TOTAL PHY ERR",
318 priv->debug.rx_stats.err_phy); 318 priv->debug.rx_stats.err_phy);
319 319
320 320
321 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); 321 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
@@ -372,16 +372,16 @@ static ssize_t read_file_slot(struct file *file, char __user *user_buf,
372 372
373 spin_lock_bh(&priv->tx.tx_lock); 373 spin_lock_bh(&priv->tx.tx_lock);
374 374
375 len += snprintf(buf + len, sizeof(buf) - len, "TX slot bitmap : "); 375 len += scnprintf(buf + len, sizeof(buf) - len, "TX slot bitmap : ");
376 376
377 len += bitmap_scnprintf(buf + len, sizeof(buf) - len, 377 len += bitmap_scnprintf(buf + len, sizeof(buf) - len,
378 priv->tx.tx_slot, MAX_TX_BUF_NUM); 378 priv->tx.tx_slot, MAX_TX_BUF_NUM);
379 379
380 len += snprintf(buf + len, sizeof(buf) - len, "\n"); 380 len += scnprintf(buf + len, sizeof(buf) - len, "\n");
381 381
382 len += snprintf(buf + len, sizeof(buf) - len, 382 len += scnprintf(buf + len, sizeof(buf) - len,
383 "Used slots : %d\n", 383 "Used slots : %d\n",
384 bitmap_weight(priv->tx.tx_slot, MAX_TX_BUF_NUM)); 384 bitmap_weight(priv->tx.tx_slot, MAX_TX_BUF_NUM));
385 385
386 spin_unlock_bh(&priv->tx.tx_lock); 386 spin_unlock_bh(&priv->tx.tx_lock);
387 387
@@ -405,30 +405,30 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
405 char buf[512]; 405 char buf[512];
406 unsigned int len = 0; 406 unsigned int len = 0;
407 407
408 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 408 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
409 "Mgmt endpoint", skb_queue_len(&priv->tx.mgmt_ep_queue)); 409 "Mgmt endpoint", skb_queue_len(&priv->tx.mgmt_ep_queue));
410 410
411 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 411 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
412 "Cab endpoint", skb_queue_len(&priv->tx.cab_ep_queue)); 412 "Cab endpoint", skb_queue_len(&priv->tx.cab_ep_queue));
413 413
414 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 414 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
415 "Data BE endpoint", skb_queue_len(&priv->tx.data_be_queue)); 415 "Data BE endpoint", skb_queue_len(&priv->tx.data_be_queue));
416 416
417 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 417 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
418 "Data BK endpoint", skb_queue_len(&priv->tx.data_bk_queue)); 418 "Data BK endpoint", skb_queue_len(&priv->tx.data_bk_queue));
419 419
420 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 420 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
421 "Data VI endpoint", skb_queue_len(&priv->tx.data_vi_queue)); 421 "Data VI endpoint", skb_queue_len(&priv->tx.data_vi_queue));
422 422
423 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 423 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
424 "Data VO endpoint", skb_queue_len(&priv->tx.data_vo_queue)); 424 "Data VO endpoint", skb_queue_len(&priv->tx.data_vo_queue));
425 425
426 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 426 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
427 "Failed queue", skb_queue_len(&priv->tx.tx_failed)); 427 "Failed queue", skb_queue_len(&priv->tx.tx_failed));
428 428
429 spin_lock_bh(&priv->tx.tx_lock); 429 spin_lock_bh(&priv->tx.tx_lock);
430 len += snprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n", 430 len += scnprintf(buf + len, sizeof(buf) - len, "%20s : %10u\n",
431 "Queued count", priv->tx.queued_cnt); 431 "Queued count", priv->tx.queued_cnt);
432 spin_unlock_bh(&priv->tx.tx_lock); 432 spin_unlock_bh(&priv->tx.tx_lock);
433 433
434 if (len > sizeof(buf)) 434 if (len > sizeof(buf))
@@ -507,70 +507,70 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
507 if (buf == NULL) 507 if (buf == NULL)
508 return -ENOMEM; 508 return -ENOMEM;
509 509
510 len += snprintf(buf + len, size - len, 510 len += scnprintf(buf + len, size - len,
511 "%20s : %10d\n", "Major Version", 511 "%20s : %10d\n", "Major Version",
512 pBase->version >> 12); 512 pBase->version >> 12);
513 len += snprintf(buf + len, size - len, 513 len += scnprintf(buf + len, size - len,
514 "%20s : %10d\n", "Minor Version", 514 "%20s : %10d\n", "Minor Version",
515 pBase->version & 0xFFF); 515 pBase->version & 0xFFF);
516 len += snprintf(buf + len, size - len, 516 len += scnprintf(buf + len, size - len,
517 "%20s : %10d\n", "Checksum", 517 "%20s : %10d\n", "Checksum",
518 pBase->checksum); 518 pBase->checksum);
519 len += snprintf(buf + len, size - len, 519 len += scnprintf(buf + len, size - len,
520 "%20s : %10d\n", "Length", 520 "%20s : %10d\n", "Length",
521 pBase->length); 521 pBase->length);
522 len += snprintf(buf + len, size - len, 522 len += scnprintf(buf + len, size - len,
523 "%20s : %10d\n", "RegDomain1", 523 "%20s : %10d\n", "RegDomain1",
524 pBase->regDmn[0]); 524 pBase->regDmn[0]);
525 len += snprintf(buf + len, size - len, 525 len += scnprintf(buf + len, size - len,
526 "%20s : %10d\n", "RegDomain2", 526 "%20s : %10d\n", "RegDomain2",
527 pBase->regDmn[1]); 527 pBase->regDmn[1]);
528 len += snprintf(buf + len, size - len, 528 len += scnprintf(buf + len, size - len,
529 "%20s : %10d\n", 529 "%20s : %10d\n",
530 "TX Mask", pBase->txMask); 530 "TX Mask", pBase->txMask);
531 len += snprintf(buf + len, size - len, 531 len += scnprintf(buf + len, size - len,
532 "%20s : %10d\n", 532 "%20s : %10d\n",
533 "RX Mask", pBase->rxMask); 533 "RX Mask", pBase->rxMask);
534 len += snprintf(buf + len, size - len, 534 len += scnprintf(buf + len, size - len,
535 "%20s : %10d\n", 535 "%20s : %10d\n",
536 "Allow 5GHz", 536 "Allow 5GHz",
537 !!(pBase->opCapFlags & AR5416_OPFLAGS_11A)); 537 !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
538 len += snprintf(buf + len, size - len, 538 len += scnprintf(buf + len, size - len,
539 "%20s : %10d\n", 539 "%20s : %10d\n",
540 "Allow 2GHz", 540 "Allow 2GHz",
541 !!(pBase->opCapFlags & AR5416_OPFLAGS_11G)); 541 !!(pBase->opCapFlags & AR5416_OPFLAGS_11G));
542 len += snprintf(buf + len, size - len, 542 len += scnprintf(buf + len, size - len,
543 "%20s : %10d\n", 543 "%20s : %10d\n",
544 "Disable 2GHz HT20", 544 "Disable 2GHz HT20",
545 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_2G_HT20)); 545 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_2G_HT20));
546 len += snprintf(buf + len, size - len, 546 len += scnprintf(buf + len, size - len,
547 "%20s : %10d\n", 547 "%20s : %10d\n",
548 "Disable 2GHz HT40", 548 "Disable 2GHz HT40",
549 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_2G_HT40)); 549 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_2G_HT40));
550 len += snprintf(buf + len, size - len, 550 len += scnprintf(buf + len, size - len,
551 "%20s : %10d\n", 551 "%20s : %10d\n",
552 "Disable 5Ghz HT20", 552 "Disable 5Ghz HT20",
553 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_5G_HT20)); 553 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_5G_HT20));
554 len += snprintf(buf + len, size - len, 554 len += scnprintf(buf + len, size - len,
555 "%20s : %10d\n", 555 "%20s : %10d\n",
556 "Disable 5Ghz HT40", 556 "Disable 5Ghz HT40",
557 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_5G_HT40)); 557 !!(pBase->opCapFlags & AR5416_OPFLAGS_N_5G_HT40));
558 len += snprintf(buf + len, size - len, 558 len += scnprintf(buf + len, size - len,
559 "%20s : %10d\n", 559 "%20s : %10d\n",
560 "Big Endian", 560 "Big Endian",
561 !!(pBase->eepMisc & 0x01)); 561 !!(pBase->eepMisc & 0x01));
562 len += snprintf(buf + len, size - len, 562 len += scnprintf(buf + len, size - len,
563 "%20s : %10d\n", 563 "%20s : %10d\n",
564 "Cal Bin Major Ver", 564 "Cal Bin Major Ver",
565 (pBase->binBuildNumber >> 24) & 0xFF); 565 (pBase->binBuildNumber >> 24) & 0xFF);
566 len += snprintf(buf + len, size - len, 566 len += scnprintf(buf + len, size - len,
567 "%20s : %10d\n", 567 "%20s : %10d\n",
568 "Cal Bin Minor Ver", 568 "Cal Bin Minor Ver",
569 (pBase->binBuildNumber >> 16) & 0xFF); 569 (pBase->binBuildNumber >> 16) & 0xFF);
570 len += snprintf(buf + len, size - len, 570 len += scnprintf(buf + len, size - len,
571 "%20s : %10d\n", 571 "%20s : %10d\n",
572 "Cal Bin Build", 572 "Cal Bin Build",
573 (pBase->binBuildNumber >> 8) & 0xFF); 573 (pBase->binBuildNumber >> 8) & 0xFF);
574 574
575 /* 575 /*
576 * UB91 specific data. 576 * UB91 specific data.
@@ -579,10 +579,10 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
579 struct base_eep_header_4k *pBase4k = 579 struct base_eep_header_4k *pBase4k =
580 &priv->ah->eeprom.map4k.baseEepHeader; 580 &priv->ah->eeprom.map4k.baseEepHeader;
581 581
582 len += snprintf(buf + len, size - len, 582 len += scnprintf(buf + len, size - len,
583 "%20s : %10d\n", 583 "%20s : %10d\n",
584 "TX Gain type", 584 "TX Gain type",
585 pBase4k->txGainType); 585 pBase4k->txGainType);
586 } 586 }
587 587
588 /* 588 /*
@@ -592,19 +592,19 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
592 struct base_eep_ar9287_header *pBase9287 = 592 struct base_eep_ar9287_header *pBase9287 =
593 &priv->ah->eeprom.map9287.baseEepHeader; 593 &priv->ah->eeprom.map9287.baseEepHeader;
594 594
595 len += snprintf(buf + len, size - len, 595 len += scnprintf(buf + len, size - len,
596 "%20s : %10ddB\n", 596 "%20s : %10ddB\n",
597 "Power Table Offset", 597 "Power Table Offset",
598 pBase9287->pwrTableOffset); 598 pBase9287->pwrTableOffset);
599 599
600 len += snprintf(buf + len, size - len, 600 len += scnprintf(buf + len, size - len,
601 "%20s : %10d\n", 601 "%20s : %10d\n",
602 "OpenLoop Power Ctrl", 602 "OpenLoop Power Ctrl",
603 pBase9287->openLoopPwrCntl); 603 pBase9287->openLoopPwrCntl);
604 } 604 }
605 605
606 len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", 606 len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
607 pBase->macAddr); 607 pBase->macAddr);
608 if (len > size) 608 if (len > size)
609 len = size; 609 len = size;
610 610
@@ -627,8 +627,8 @@ static ssize_t read_4k_modal_eeprom(struct file *file,
627{ 627{
628#define PR_EEP(_s, _val) \ 628#define PR_EEP(_s, _val) \
629 do { \ 629 do { \
630 len += snprintf(buf + len, size - len, "%20s : %10d\n", \ 630 len += scnprintf(buf + len, size - len, "%20s : %10d\n",\
631 _s, (_val)); \ 631 _s, (_val)); \
632 } while (0) 632 } while (0)
633 633
634 struct ath9k_htc_priv *priv = file->private_data; 634 struct ath9k_htc_priv *priv = file->private_data;
@@ -708,12 +708,12 @@ static ssize_t read_def_modal_eeprom(struct file *file,
708 do { \ 708 do { \
709 if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \ 709 if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \
710 pModal = &priv->ah->eeprom.def.modalHeader[1]; \ 710 pModal = &priv->ah->eeprom.def.modalHeader[1]; \
711 len += snprintf(buf + len, size - len, "%20s : %8d%7s", \ 711 len += scnprintf(buf + len, size - len, "%20s : %8d%7s", \
712 _s, (_val), "|"); \ 712 _s, (_val), "|"); \
713 } \ 713 } \
714 if (pBase->opCapFlags & AR5416_OPFLAGS_11A) { \ 714 if (pBase->opCapFlags & AR5416_OPFLAGS_11A) { \
715 pModal = &priv->ah->eeprom.def.modalHeader[0]; \ 715 pModal = &priv->ah->eeprom.def.modalHeader[0]; \
716 len += snprintf(buf + len, size - len, "%9d\n", \ 716 len += scnprintf(buf + len, size - len, "%9d\n",\
717 (_val)); \ 717 (_val)); \
718 } \ 718 } \
719 } while (0) 719 } while (0)
@@ -729,10 +729,10 @@ static ssize_t read_def_modal_eeprom(struct file *file,
729 if (buf == NULL) 729 if (buf == NULL)
730 return -ENOMEM; 730 return -ENOMEM;
731 731
732 len += snprintf(buf + len, size - len, 732 len += scnprintf(buf + len, size - len,
733 "%31s %15s\n", "2G", "5G"); 733 "%31s %15s\n", "2G", "5G");
734 len += snprintf(buf + len, size - len, 734 len += scnprintf(buf + len, size - len,
735 "%32s %16s\n", "====", "====\n"); 735 "%32s %16s\n", "====", "====\n");
736 736
737 PR_EEP("Chain0 Ant. Control", pModal->antCtrlChain[0]); 737 PR_EEP("Chain0 Ant. Control", pModal->antCtrlChain[0]);
738 PR_EEP("Chain1 Ant. Control", pModal->antCtrlChain[1]); 738 PR_EEP("Chain1 Ant. Control", pModal->antCtrlChain[1]);
@@ -814,8 +814,8 @@ static ssize_t read_9287_modal_eeprom(struct file *file,
814{ 814{
815#define PR_EEP(_s, _val) \ 815#define PR_EEP(_s, _val) \
816 do { \ 816 do { \
817 len += snprintf(buf + len, size - len, "%20s : %10d\n", \ 817 len += scnprintf(buf + len, size - len, "%20s : %10d\n",\
818 _s, (_val)); \ 818 _s, (_val)); \
819 } while (0) 819 } while (0)
820 820
821 struct ath9k_htc_priv *priv = file->private_data; 821 struct ath9k_htc_priv *priv = file->private_data;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index ecc6ec4a1edb..f11e8389a9be 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -549,6 +549,18 @@ static int ath9k_hw_post_init(struct ath_hw *ah)
549 549
550 ath9k_hw_ani_init(ah); 550 ath9k_hw_ani_init(ah);
551 551
552 /*
553 * EEPROM needs to be initialized before we do this.
554 * This is required for regulatory compliance.
555 */
556 if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
557 u16 regdmn = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
558 if ((regdmn & 0xF0) == CTL_FCC) {
559 ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9462_FCC_2GHZ;
560 ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9462_FCC_5GHZ;
561 }
562 }
563
552 return 0; 564 return 0;
553} 565}
554 566
@@ -1644,6 +1656,19 @@ hang_check_iter:
1644 return true; 1656 return true;
1645} 1657}
1646 1658
1659void ath9k_hw_check_nav(struct ath_hw *ah)
1660{
1661 struct ath_common *common = ath9k_hw_common(ah);
1662 u32 val;
1663
1664 val = REG_READ(ah, AR_NAV);
1665 if (val != 0xdeadbeef && val > 0x7fff) {
1666 ath_dbg(common, BSTUCK, "Abnormal NAV: 0x%x\n", val);
1667 REG_WRITE(ah, AR_NAV, 0);
1668 }
1669}
1670EXPORT_SYMBOL(ath9k_hw_check_nav);
1671
1647bool ath9k_hw_check_alive(struct ath_hw *ah) 1672bool ath9k_hw_check_alive(struct ath_hw *ah)
1648{ 1673{
1649 int count = 50; 1674 int count = 50;
@@ -1822,9 +1847,9 @@ static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan)
1822 * re-using are present. 1847 * re-using are present.
1823 */ 1848 */
1824 if (AR_SREV_9462(ah) && (ah->caldata && 1849 if (AR_SREV_9462(ah) && (ah->caldata &&
1825 (!ah->caldata->done_txiqcal_once || 1850 (!test_bit(TXIQCAL_DONE, &ah->caldata->cal_flags) ||
1826 !ah->caldata->done_txclcal_once || 1851 !test_bit(TXCLCAL_DONE, &ah->caldata->cal_flags) ||
1827 !ah->caldata->rtt_done))) 1852 !test_bit(RTT_DONE, &ah->caldata->cal_flags))))
1828 goto fail; 1853 goto fail;
1829 1854
1830 ath_dbg(common, RESET, "FastChannelChange for %d -> %d\n", 1855 ath_dbg(common, RESET, "FastChannelChange for %d -> %d\n",
@@ -1880,7 +1905,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1880 memset(caldata, 0, sizeof(*caldata)); 1905 memset(caldata, 0, sizeof(*caldata));
1881 ath9k_init_nfcal_hist_buffer(ah, chan); 1906 ath9k_init_nfcal_hist_buffer(ah, chan);
1882 } else if (caldata) { 1907 } else if (caldata) {
1883 caldata->paprd_packet_sent = false; 1908 clear_bit(PAPRD_PACKET_SENT, &caldata->cal_flags);
1884 } 1909 }
1885 ah->noise = ath9k_hw_getchan_noise(ah, chan); 1910 ah->noise = ath9k_hw_getchan_noise(ah, chan);
1886 1911
@@ -2017,8 +2042,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2017 ath9k_hw_init_bb(ah, chan); 2042 ath9k_hw_init_bb(ah, chan);
2018 2043
2019 if (caldata) { 2044 if (caldata) {
2020 caldata->done_txiqcal_once = false; 2045 clear_bit(TXIQCAL_DONE, &caldata->cal_flags);
2021 caldata->done_txclcal_once = false; 2046 clear_bit(TXCLCAL_DONE, &caldata->cal_flags);
2022 } 2047 }
2023 if (!ath9k_hw_init_cal(ah, chan)) 2048 if (!ath9k_hw_init_cal(ah, chan))
2024 return -EIO; 2049 return -EIO;
@@ -3240,19 +3265,19 @@ void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len)
3240 3265
3241 /* chipsets >= AR9280 are single-chip */ 3266 /* chipsets >= AR9280 are single-chip */
3242 if (AR_SREV_9280_20_OR_LATER(ah)) { 3267 if (AR_SREV_9280_20_OR_LATER(ah)) {
3243 used = snprintf(hw_name, len, 3268 used = scnprintf(hw_name, len,
3244 "Atheros AR%s Rev:%x", 3269 "Atheros AR%s Rev:%x",
3245 ath9k_hw_mac_bb_name(ah->hw_version.macVersion), 3270 ath9k_hw_mac_bb_name(ah->hw_version.macVersion),
3246 ah->hw_version.macRev); 3271 ah->hw_version.macRev);
3247 } 3272 }
3248 else { 3273 else {
3249 used = snprintf(hw_name, len, 3274 used = scnprintf(hw_name, len,
3250 "Atheros AR%s MAC/BB Rev:%x AR%s RF Rev:%x", 3275 "Atheros AR%s MAC/BB Rev:%x AR%s RF Rev:%x",
3251 ath9k_hw_mac_bb_name(ah->hw_version.macVersion), 3276 ath9k_hw_mac_bb_name(ah->hw_version.macVersion),
3252 ah->hw_version.macRev, 3277 ah->hw_version.macRev,
3253 ath9k_hw_rf_name((ah->hw_version.analog5GhzRev & 3278 ath9k_hw_rf_name((ah->hw_version.analog5GhzRev
3254 AR_RADIO_SREV_MAJOR)), 3279 & AR_RADIO_SREV_MAJOR)),
3255 ah->hw_version.phyRev); 3280 ah->hw_version.phyRev);
3256 } 3281 }
3257 3282
3258 hw_name[used] = '\0'; 3283 hw_name[used] = '\0';
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 69a907b55a73..2babf931b459 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -98,8 +98,8 @@
98 98
99#define PR_EEP(_s, _val) \ 99#define PR_EEP(_s, _val) \
100 do { \ 100 do { \
101 len += snprintf(buf + len, size - len, "%20s : %10d\n", \ 101 len += scnprintf(buf + len, size - len, "%20s : %10d\n",\
102 _s, (_val)); \ 102 _s, (_val)); \
103 } while (0) 103 } while (0)
104 104
105#define SM(_v, _f) (((_v) << _f##_S) & _f) 105#define SM(_v, _f) (((_v) << _f##_S) & _f)
@@ -404,20 +404,26 @@ enum ath9k_int {
404#define MAX_CL_TAB_ENTRY 16 404#define MAX_CL_TAB_ENTRY 16
405#define CL_TAB_ENTRY(reg_base) (reg_base + (4 * j)) 405#define CL_TAB_ENTRY(reg_base) (reg_base + (4 * j))
406 406
407enum ath9k_cal_flags {
408 RTT_DONE,
409 PAPRD_PACKET_SENT,
410 PAPRD_DONE,
411 NFCAL_PENDING,
412 NFCAL_INTF,
413 TXIQCAL_DONE,
414 TXCLCAL_DONE,
415 SW_PKDET_DONE,
416};
417
407struct ath9k_hw_cal_data { 418struct ath9k_hw_cal_data {
408 u16 channel; 419 u16 channel;
409 u32 channelFlags; 420 u32 channelFlags;
410 u32 chanmode; 421 u32 chanmode;
422 unsigned long cal_flags;
411 int32_t CalValid; 423 int32_t CalValid;
412 int8_t iCoff; 424 int8_t iCoff;
413 int8_t qCoff; 425 int8_t qCoff;
414 bool rtt_done; 426 u8 caldac[2];
415 bool paprd_packet_sent;
416 bool paprd_done;
417 bool nfcal_pending;
418 bool nfcal_interference;
419 bool done_txiqcal_once;
420 bool done_txclcal_once;
421 u16 small_signal_gain[AR9300_MAX_CHAINS]; 427 u16 small_signal_gain[AR9300_MAX_CHAINS];
422 u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; 428 u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ];
423 u32 num_measures[AR9300_MAX_CHAINS]; 429 u32 num_measures[AR9300_MAX_CHAINS];
@@ -558,6 +564,7 @@ struct ath_hw_antcomb_conf {
558 u8 main_gaintb; 564 u8 main_gaintb;
559 u8 alt_gaintb; 565 u8 alt_gaintb;
560 int lna1_lna2_delta; 566 int lna1_lna2_delta;
567 int lna1_lna2_switch_delta;
561 u8 div_group; 568 u8 div_group;
562}; 569};
563 570
@@ -1030,6 +1037,7 @@ void ath9k_hw_set11nmac2040(struct ath_hw *ah);
1030void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); 1037void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
1031void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, 1038void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
1032 const struct ath9k_beacon_state *bs); 1039 const struct ath9k_beacon_state *bs);
1040void ath9k_hw_check_nav(struct ath_hw *ah);
1033bool ath9k_hw_check_alive(struct ath_hw *ah); 1041bool ath9k_hw_check_alive(struct ath_hw *ah);
1034 1042
1035bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode); 1043bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 9a1f349f9260..e3d11c41a145 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -547,6 +547,26 @@ static void ath9k_init_platform(struct ath_softc *sc)
547 if (sc->driver_data & ATH9K_PCI_CUS217) 547 if (sc->driver_data & ATH9K_PCI_CUS217)
548 ath_info(common, "CUS217 card detected\n"); 548 ath_info(common, "CUS217 card detected\n");
549 549
550 if (sc->driver_data & ATH9K_PCI_CUS252)
551 ath_info(common, "CUS252 card detected\n");
552
553 if (sc->driver_data & ATH9K_PCI_AR9565_1ANT)
554 ath_info(common, "WB335 1-ANT card detected\n");
555
556 if (sc->driver_data & ATH9K_PCI_AR9565_2ANT)
557 ath_info(common, "WB335 2-ANT card detected\n");
558
559 /*
560 * Some WB335 cards do not support antenna diversity. Since
561 * we use a hardcoded value for AR9565 instead of using the
562 * EEPROM/OTP data, remove the combining feature from
563 * the HW capabilities bitmap.
564 */
565 if (sc->driver_data & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) {
566 if (!(sc->driver_data & ATH9K_PCI_BT_ANT_DIV))
567 pCap->hw_caps &= ~ATH9K_HW_CAP_ANT_DIV_COMB;
568 }
569
550 if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) { 570 if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) {
551 pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV; 571 pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV;
552 ath_info(common, "Set BT/WLAN RX diversity capability\n"); 572 ath_info(common, "Set BT/WLAN RX diversity capability\n");
diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c
index 2f831db396ac..84a60644f93a 100644
--- a/drivers/net/wireless/ath/ath9k/link.c
+++ b/drivers/net/wireless/ath/ath9k/link.c
@@ -184,7 +184,7 @@ static void ath_paprd_activate(struct ath_softc *sc)
184 struct ath9k_hw_cal_data *caldata = ah->caldata; 184 struct ath9k_hw_cal_data *caldata = ah->caldata;
185 int chain; 185 int chain;
186 186
187 if (!caldata || !caldata->paprd_done) { 187 if (!caldata || !test_bit(PAPRD_DONE, &caldata->cal_flags)) {
188 ath_dbg(common, CALIBRATE, "Failed to activate PAPRD\n"); 188 ath_dbg(common, CALIBRATE, "Failed to activate PAPRD\n");
189 return; 189 return;
190 } 190 }
@@ -256,7 +256,9 @@ void ath_paprd_calibrate(struct work_struct *work)
256 int len = 1800; 256 int len = 1800;
257 int ret; 257 int ret;
258 258
259 if (!caldata || !caldata->paprd_packet_sent || caldata->paprd_done) { 259 if (!caldata ||
260 !test_bit(PAPRD_PACKET_SENT, &caldata->cal_flags) ||
261 test_bit(PAPRD_DONE, &caldata->cal_flags)) {
260 ath_dbg(common, CALIBRATE, "Skipping PAPRD calibration\n"); 262 ath_dbg(common, CALIBRATE, "Skipping PAPRD calibration\n");
261 return; 263 return;
262 } 264 }
@@ -316,7 +318,7 @@ void ath_paprd_calibrate(struct work_struct *work)
316 kfree_skb(skb); 318 kfree_skb(skb);
317 319
318 if (chain_ok) { 320 if (chain_ok) {
319 caldata->paprd_done = true; 321 set_bit(PAPRD_DONE, &caldata->cal_flags);
320 ath_paprd_activate(sc); 322 ath_paprd_activate(sc);
321 } 323 }
322 324
@@ -343,7 +345,7 @@ void ath_ani_calibrate(unsigned long data)
343 u32 cal_interval, short_cal_interval, long_cal_interval; 345 u32 cal_interval, short_cal_interval, long_cal_interval;
344 unsigned long flags; 346 unsigned long flags;
345 347
346 if (ah->caldata && ah->caldata->nfcal_interference) 348 if (ah->caldata && test_bit(NFCAL_INTF, &ah->caldata->cal_flags))
347 long_cal_interval = ATH_LONG_CALINTERVAL_INT; 349 long_cal_interval = ATH_LONG_CALINTERVAL_INT;
348 else 350 else
349 long_cal_interval = ATH_LONG_CALINTERVAL; 351 long_cal_interval = ATH_LONG_CALINTERVAL;
@@ -432,7 +434,7 @@ set_timer:
432 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); 434 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
433 435
434 if (ar9003_is_paprd_enabled(ah) && ah->caldata) { 436 if (ar9003_is_paprd_enabled(ah) && ah->caldata) {
435 if (!ah->caldata->paprd_done) { 437 if (!test_bit(PAPRD_DONE, &ah->caldata->cal_flags)) {
436 ieee80211_queue_work(sc->hw, &sc->paprd_work); 438 ieee80211_queue_work(sc->hw, &sc->paprd_work);
437 } else if (!ah->paprd_table_write_done) { 439 } else if (!ah->paprd_table_write_done) {
438 ath9k_ps_wakeup(sc); 440 ath9k_ps_wakeup(sc);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index e4f65900132d..cdb3b1e10b95 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -362,6 +362,13 @@ void ath9k_tasklet(unsigned long data)
362 type = RESET_TYPE_BB_WATCHDOG; 362 type = RESET_TYPE_BB_WATCHDOG;
363 363
364 ath9k_queue_reset(sc, type); 364 ath9k_queue_reset(sc, type);
365
366 /*
367 * Increment the ref. counter here so that
368 * interrupts are enabled in the reset routine.
369 */
370 atomic_inc(&ah->intr_ref_cnt);
371 ath_dbg(common, ANY, "FATAL: Skipping interrupts\n");
365 goto out; 372 goto out;
366 } 373 }
367 374
@@ -400,10 +407,9 @@ void ath9k_tasklet(unsigned long data)
400 407
401 ath9k_btcoex_handle_interrupt(sc, status); 408 ath9k_btcoex_handle_interrupt(sc, status);
402 409
403out:
404 /* re-enable hardware interrupt */ 410 /* re-enable hardware interrupt */
405 ath9k_hw_enable_interrupts(ah); 411 ath9k_hw_enable_interrupts(ah);
406 412out:
407 spin_unlock(&sc->sc_pcu_lock); 413 spin_unlock(&sc->sc_pcu_lock);
408 ath9k_ps_restore(sc); 414 ath9k_ps_restore(sc);
409} 415}
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index d089a7cf01c4..7e4c2524b630 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -269,7 +269,200 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
269 269
270 { PCI_VDEVICE(ATHEROS, 0x0034) }, /* PCI-E AR9462 */ 270 { PCI_VDEVICE(ATHEROS, 0x0034) }, /* PCI-E AR9462 */
271 { PCI_VDEVICE(ATHEROS, 0x0037) }, /* PCI-E AR1111/AR9485 */ 271 { PCI_VDEVICE(ATHEROS, 0x0037) }, /* PCI-E AR1111/AR9485 */
272 { PCI_VDEVICE(ATHEROS, 0x0036) }, /* PCI-E AR9565 */ 272
273 /* CUS252 */
274 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
275 0x0036,
276 PCI_VENDOR_ID_ATHEROS,
277 0x3028),
278 .driver_data = ATH9K_PCI_CUS252 |
279 ATH9K_PCI_AR9565_2ANT |
280 ATH9K_PCI_BT_ANT_DIV },
281 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
282 0x0036,
283 PCI_VENDOR_ID_AZWAVE,
284 0x2176),
285 .driver_data = ATH9K_PCI_CUS252 |
286 ATH9K_PCI_AR9565_2ANT |
287 ATH9K_PCI_BT_ANT_DIV },
288
289 /* WB335 1-ANT */
290 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
291 0x0036,
292 PCI_VENDOR_ID_FOXCONN,
293 0xE068),
294 .driver_data = ATH9K_PCI_AR9565_1ANT },
295 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
296 0x0036,
297 0x185F, /* WNC */
298 0xA119),
299 .driver_data = ATH9K_PCI_AR9565_1ANT },
300 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
301 0x0036,
302 0x11AD, /* LITEON */
303 0x0632),
304 .driver_data = ATH9K_PCI_AR9565_1ANT },
305 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
306 0x0036,
307 0x11AD, /* LITEON */
308 0x6671),
309 .driver_data = ATH9K_PCI_AR9565_1ANT },
310 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
311 0x0036,
312 0x1B9A, /* XAVI */
313 0x2811),
314 .driver_data = ATH9K_PCI_AR9565_1ANT },
315 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
316 0x0036,
317 0x1B9A, /* XAVI */
318 0x2812),
319 .driver_data = ATH9K_PCI_AR9565_1ANT },
320
321 /* WB335 1-ANT / Antenna Diversity */
322 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
323 0x0036,
324 PCI_VENDOR_ID_ATHEROS,
325 0x3025),
326 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
327 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
328 0x0036,
329 PCI_VENDOR_ID_ATHEROS,
330 0x3026),
331 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
332 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
333 0x0036,
334 PCI_VENDOR_ID_ATHEROS,
335 0x302B),
336 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
337 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
338 0x0036,
339 PCI_VENDOR_ID_FOXCONN,
340 0xE069),
341 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
342 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
343 0x0036,
344 0x185F, /* WNC */
345 0x3028),
346 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
347 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
348 0x0036,
349 0x11AD, /* LITEON */
350 0x0622),
351 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
352 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
353 0x0036,
354 0x11AD, /* LITEON */
355 0x0672),
356 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
357 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
358 0x0036,
359 0x11AD, /* LITEON */
360 0x0662),
361 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
362 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
363 0x0036,
364 PCI_VENDOR_ID_AZWAVE,
365 0x213A),
366 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
367 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
368 0x0036,
369 PCI_VENDOR_ID_LENOVO,
370 0x3026),
371 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
372 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
373 0x0036,
374 PCI_VENDOR_ID_HP,
375 0x18E3),
376 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
377 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
378 0x0036,
379 PCI_VENDOR_ID_HP,
380 0x217F),
381 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
382 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
383 0x0036,
384 PCI_VENDOR_ID_DELL,
385 0x020E),
386 .driver_data = ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_BT_ANT_DIV },
387
388 /* WB335 2-ANT */
389 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
390 0x0036,
391 PCI_VENDOR_ID_SAMSUNG,
392 0x411A),
393 .driver_data = ATH9K_PCI_AR9565_2ANT },
394 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
395 0x0036,
396 PCI_VENDOR_ID_SAMSUNG,
397 0x411B),
398 .driver_data = ATH9K_PCI_AR9565_2ANT },
399 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
400 0x0036,
401 PCI_VENDOR_ID_SAMSUNG,
402 0x411C),
403 .driver_data = ATH9K_PCI_AR9565_2ANT },
404 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
405 0x0036,
406 PCI_VENDOR_ID_SAMSUNG,
407 0x411D),
408 .driver_data = ATH9K_PCI_AR9565_2ANT },
409 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
410 0x0036,
411 PCI_VENDOR_ID_SAMSUNG,
412 0x411E),
413 .driver_data = ATH9K_PCI_AR9565_2ANT },
414
415 /* WB335 2-ANT / Antenna-Diversity */
416 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
417 0x0036,
418 PCI_VENDOR_ID_ATHEROS,
419 0x3027),
420 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
421 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
422 0x0036,
423 PCI_VENDOR_ID_ATHEROS,
424 0x302C),
425 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
426 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
427 0x0036,
428 0x11AD, /* LITEON */
429 0x0642),
430 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
431 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
432 0x0036,
433 0x11AD, /* LITEON */
434 0x0652),
435 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
436 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
437 0x0036,
438 0x11AD, /* LITEON */
439 0x0612),
440 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
441 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
442 0x0036,
443 PCI_VENDOR_ID_AZWAVE,
444 0x2130),
445 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
446 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
447 0x0036,
448 0x144F, /* ASKEY */
449 0x7202),
450 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
451 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
452 0x0036,
453 0x1B9A, /* XAVI */
454 0x2810),
455 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
456 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
457 0x0036,
458 0x185F, /* WNC */
459 0x3027),
460 .driver_data = ATH9K_PCI_AR9565_2ANT | ATH9K_PCI_BT_ANT_DIV },
461
462 /* PCI-E AR9565 (WB335) */
463 { PCI_VDEVICE(ATHEROS, 0x0036),
464 .driver_data = ATH9K_PCI_BT_ANT_DIV },
465
273 { 0 } 466 { 0 }
274}; 467};
275 468
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index d3d7c51fa6c8..d829bb62a3fc 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1387,31 +1387,31 @@ static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
1387 int used_mcs = 0, used_htmode = 0; 1387 int used_mcs = 0, used_htmode = 0;
1388 1388
1389 if (WLAN_RC_PHY_HT(rc->rate_table->info[i].phy)) { 1389 if (WLAN_RC_PHY_HT(rc->rate_table->info[i].phy)) {
1390 used_mcs = snprintf(mcs, 5, "%d", 1390 used_mcs = scnprintf(mcs, 5, "%d",
1391 rc->rate_table->info[i].ratecode); 1391 rc->rate_table->info[i].ratecode);
1392 1392
1393 if (WLAN_RC_PHY_40(rc->rate_table->info[i].phy)) 1393 if (WLAN_RC_PHY_40(rc->rate_table->info[i].phy))
1394 used_htmode = snprintf(htmode, 5, "HT40"); 1394 used_htmode = scnprintf(htmode, 5, "HT40");
1395 else if (WLAN_RC_PHY_20(rc->rate_table->info[i].phy)) 1395 else if (WLAN_RC_PHY_20(rc->rate_table->info[i].phy))
1396 used_htmode = snprintf(htmode, 5, "HT20"); 1396 used_htmode = scnprintf(htmode, 5, "HT20");
1397 else 1397 else
1398 used_htmode = snprintf(htmode, 5, "????"); 1398 used_htmode = scnprintf(htmode, 5, "????");
1399 } 1399 }
1400 1400
1401 mcs[used_mcs] = '\0'; 1401 mcs[used_mcs] = '\0';
1402 htmode[used_htmode] = '\0'; 1402 htmode[used_htmode] = '\0';
1403 1403
1404 len += snprintf(buf + len, max - len, 1404 len += scnprintf(buf + len, max - len,
1405 "%6s %6s %3u.%d: " 1405 "%6s %6s %3u.%d: "
1406 "%10u %10u %10u %10u\n", 1406 "%10u %10u %10u %10u\n",
1407 htmode, 1407 htmode,
1408 mcs, 1408 mcs,
1409 ratekbps / 1000, 1409 ratekbps / 1000,
1410 (ratekbps % 1000) / 100, 1410 (ratekbps % 1000) / 100,
1411 stats->success, 1411 stats->success,
1412 stats->retries, 1412 stats->retries,
1413 stats->xretries, 1413 stats->xretries,
1414 stats->per); 1414 stats->per);
1415 } 1415 }
1416 1416
1417 if (len > max) 1417 if (len > max)
diff --git a/drivers/net/wireless/ath/ath9k/wmi.h b/drivers/net/wireless/ath/ath9k/wmi.h
index fde6da619f30..0db37f230018 100644
--- a/drivers/net/wireless/ath/ath9k/wmi.h
+++ b/drivers/net/wireless/ath/ath9k/wmi.h
@@ -39,7 +39,7 @@ struct wmi_fw_version {
39struct wmi_event_swba { 39struct wmi_event_swba {
40 __be64 tsf; 40 __be64 tsf;
41 u8 beacon_pending; 41 u8 beacon_pending;
42}; 42} __packed;
43 43
44/* 44/*
45 * 64 - HTC header - WMI header - 1 / txstatus 45 * 64 - HTC header - WMI header - 1 / txstatus
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 35b515fe3ffa..62c93a655df9 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2315,7 +2315,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
2315 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb); 2315 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
2316 2316
2317 if (sc->sc_ah->caldata) 2317 if (sc->sc_ah->caldata)
2318 sc->sc_ah->caldata->paprd_packet_sent = true; 2318 set_bit(PAPRD_PACKET_SENT, &sc->sc_ah->caldata->cal_flags);
2319 2319
2320 if (!(tx_flags & ATH_TX_ERROR)) 2320 if (!(tx_flags & ATH_TX_ERROR))
2321 /* Frame was ACKed */ 2321 /* Frame was ACKed */
diff --git a/drivers/net/wireless/ath/wcn36xx/Kconfig b/drivers/net/wireless/ath/wcn36xx/Kconfig
new file mode 100644
index 000000000000..591ebaea8265
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/Kconfig
@@ -0,0 +1,16 @@
1config WCN36XX
2 tristate "Qualcomm Atheros WCN3660/3680 support"
3 depends on MAC80211 && HAS_DMA
4 ---help---
5 This module adds support for wireless adapters based on
6 Qualcomm Atheros WCN3660 and WCN3680 mobile chipsets.
7
8 If you choose to build a module, it'll be called wcn36xx.
9
10config WCN36XX_DEBUGFS
11 bool "WCN36XX debugfs support"
12 depends on WCN36XX
13 ---help---
14 Enabled debugfs support
15
16 If unsure, say Y to make it easier to debug problems.
diff --git a/drivers/net/wireless/ath/wcn36xx/Makefile b/drivers/net/wireless/ath/wcn36xx/Makefile
new file mode 100644
index 000000000000..50c43b4382ba
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/Makefile
@@ -0,0 +1,7 @@
1obj-$(CONFIG_WCN36XX) := wcn36xx.o
2wcn36xx-y += main.o \
3 dxe.o \
4 txrx.o \
5 smd.o \
6 pmc.o \
7 debug.o
diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
new file mode 100644
index 000000000000..682bcd650f70
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -0,0 +1,188 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19#include <linux/debugfs.h>
20#include <linux/uaccess.h>
21#include "wcn36xx.h"
22#include "debug.h"
23#include "pmc.h"
24
25#ifdef CONFIG_WCN36XX_DEBUGFS
26
27static int wcn36xx_debugfs_open(struct inode *inode, struct file *file)
28{
29 file->private_data = inode->i_private;
30
31 return 0;
32}
33
34static ssize_t read_file_bool_bmps(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos)
36{
37 struct wcn36xx *wcn = file->private_data;
38 struct wcn36xx_vif *vif_priv = NULL;
39 struct ieee80211_vif *vif = NULL;
40 char buf[3];
41
42 list_for_each_entry(vif_priv, &wcn->vif_list, list) {
43 vif = container_of((void *)vif_priv,
44 struct ieee80211_vif,
45 drv_priv);
46 if (NL80211_IFTYPE_STATION == vif->type) {
47 if (vif_priv->pw_state == WCN36XX_BMPS)
48 buf[0] = '1';
49 else
50 buf[0] = '0';
51 break;
52 }
53 }
54 buf[1] = '\n';
55 buf[2] = 0x00;
56
57 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
58}
59
60static ssize_t write_file_bool_bmps(struct file *file,
61 const char __user *user_buf,
62 size_t count, loff_t *ppos)
63{
64 struct wcn36xx *wcn = file->private_data;
65 struct wcn36xx_vif *vif_priv = NULL;
66 struct ieee80211_vif *vif = NULL;
67
68 char buf[32];
69 int buf_size;
70
71 buf_size = min(count, (sizeof(buf)-1));
72 if (copy_from_user(buf, user_buf, buf_size))
73 return -EFAULT;
74
75 switch (buf[0]) {
76 case 'y':
77 case 'Y':
78 case '1':
79 list_for_each_entry(vif_priv, &wcn->vif_list, list) {
80 vif = container_of((void *)vif_priv,
81 struct ieee80211_vif,
82 drv_priv);
83 if (NL80211_IFTYPE_STATION == vif->type) {
84 wcn36xx_enable_keep_alive_null_packet(wcn, vif);
85 wcn36xx_pmc_enter_bmps_state(wcn, vif);
86 }
87 }
88 break;
89 case 'n':
90 case 'N':
91 case '0':
92 list_for_each_entry(vif_priv, &wcn->vif_list, list) {
93 vif = container_of((void *)vif_priv,
94 struct ieee80211_vif,
95 drv_priv);
96 if (NL80211_IFTYPE_STATION == vif->type)
97 wcn36xx_pmc_exit_bmps_state(wcn, vif);
98 }
99 break;
100 }
101
102 return count;
103}
104
105static const struct file_operations fops_wcn36xx_bmps = {
106 .open = wcn36xx_debugfs_open,
107 .read = read_file_bool_bmps,
108 .write = write_file_bool_bmps,
109};
110
111static ssize_t write_file_dump(struct file *file,
112 const char __user *user_buf,
113 size_t count, loff_t *ppos)
114{
115 struct wcn36xx *wcn = file->private_data;
116 char buf[255], *tmp;
117 int buf_size;
118 u32 arg[WCN36xx_MAX_DUMP_ARGS];
119 int i;
120
121 memset(buf, 0, sizeof(buf));
122 memset(arg, 0, sizeof(arg));
123
124 buf_size = min(count, (sizeof(buf) - 1));
125 if (copy_from_user(buf, user_buf, buf_size))
126 return -EFAULT;
127
128 tmp = buf;
129
130 for (i = 0; i < WCN36xx_MAX_DUMP_ARGS; i++) {
131 char *begin;
132 begin = strsep(&tmp, " ");
133 if (begin == NULL)
134 break;
135
136 if (kstrtoul(begin, 0, (unsigned long *)(arg + i)) != 0)
137 break;
138 }
139
140 wcn36xx_info("DUMP args is %d %d %d %d %d\n", arg[0], arg[1], arg[2],
141 arg[3], arg[4]);
142 wcn36xx_smd_dump_cmd_req(wcn, arg[0], arg[1], arg[2], arg[3], arg[4]);
143
144 return count;
145}
146
147static const struct file_operations fops_wcn36xx_dump = {
148 .open = wcn36xx_debugfs_open,
149 .write = write_file_dump,
150};
151
152#define ADD_FILE(name, mode, fop, priv_data) \
153 do { \
154 struct dentry *d; \
155 d = debugfs_create_file(__stringify(name), \
156 mode, dfs->rootdir, \
157 priv_data, fop); \
158 dfs->file_##name.dentry = d; \
159 if (IS_ERR(d)) { \
160 wcn36xx_warn("Create the debugfs entry failed");\
161 dfs->file_##name.dentry = NULL; \
162 } \
163 } while (0)
164
165
166void wcn36xx_debugfs_init(struct wcn36xx *wcn)
167{
168 struct wcn36xx_dfs_entry *dfs = &wcn->dfs;
169
170 dfs->rootdir = debugfs_create_dir(KBUILD_MODNAME,
171 wcn->hw->wiphy->debugfsdir);
172 if (IS_ERR(dfs->rootdir)) {
173 wcn36xx_warn("Create the debugfs failed\n");
174 dfs->rootdir = NULL;
175 }
176
177 ADD_FILE(bmps_switcher, S_IRUSR | S_IWUSR,
178 &fops_wcn36xx_bmps, wcn);
179 ADD_FILE(dump, S_IWUSR, &fops_wcn36xx_dump, wcn);
180}
181
182void wcn36xx_debugfs_exit(struct wcn36xx *wcn)
183{
184 struct wcn36xx_dfs_entry *dfs = &wcn->dfs;
185 debugfs_remove_recursive(dfs->rootdir);
186}
187
188#endif /* CONFIG_WCN36XX_DEBUGFS */
diff --git a/drivers/net/wireless/ath/wcn36xx/debug.h b/drivers/net/wireless/ath/wcn36xx/debug.h
new file mode 100644
index 000000000000..46307aa562d3
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/debug.h
@@ -0,0 +1,49 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _WCN36XX_DEBUG_H_
18#define _WCN36XX_DEBUG_H_
19
20#include <linux/kernel.h>
21
22#define WCN36xx_MAX_DUMP_ARGS 5
23
24#ifdef CONFIG_WCN36XX_DEBUGFS
25struct wcn36xx_dfs_file {
26 struct dentry *dentry;
27 u32 value;
28};
29
30struct wcn36xx_dfs_entry {
31 struct dentry *rootdir;
32 struct wcn36xx_dfs_file file_bmps_switcher;
33 struct wcn36xx_dfs_file file_dump;
34};
35
36void wcn36xx_debugfs_init(struct wcn36xx *wcn);
37void wcn36xx_debugfs_exit(struct wcn36xx *wcn);
38
39#else
40static inline void wcn36xx_debugfs_init(struct wcn36xx *wcn)
41{
42}
43static inline void wcn36xx_debugfs_exit(struct wcn36xx *wcn)
44{
45}
46
47#endif /* CONFIG_WCN36XX_DEBUGFS */
48
49#endif /* _WCN36XX_DEBUG_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c
new file mode 100644
index 000000000000..ee25786b4447
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/dxe.c
@@ -0,0 +1,805 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* DXE - DMA transfer engine
18 * we have 2 channels(High prio and Low prio) for TX and 2 channels for RX.
19 * through low channels data packets are transfered
20 * through high channels managment packets are transfered
21 */
22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
25#include <linux/interrupt.h>
26#include "wcn36xx.h"
27#include "txrx.h"
28
29void *wcn36xx_dxe_get_next_bd(struct wcn36xx *wcn, bool is_low)
30{
31 struct wcn36xx_dxe_ch *ch = is_low ?
32 &wcn->dxe_tx_l_ch :
33 &wcn->dxe_tx_h_ch;
34
35 return ch->head_blk_ctl->bd_cpu_addr;
36}
37
38static void wcn36xx_dxe_write_register(struct wcn36xx *wcn, int addr, int data)
39{
40 wcn36xx_dbg(WCN36XX_DBG_DXE,
41 "wcn36xx_dxe_write_register: addr=%x, data=%x\n",
42 addr, data);
43
44 writel(data, wcn->mmio + addr);
45}
46
47static void wcn36xx_dxe_read_register(struct wcn36xx *wcn, int addr, int *data)
48{
49 *data = readl(wcn->mmio + addr);
50
51 wcn36xx_dbg(WCN36XX_DBG_DXE,
52 "wcn36xx_dxe_read_register: addr=%x, data=%x\n",
53 addr, *data);
54}
55
56static void wcn36xx_dxe_free_ctl_block(struct wcn36xx_dxe_ch *ch)
57{
58 struct wcn36xx_dxe_ctl *ctl = ch->head_blk_ctl, *next;
59 int i;
60
61 for (i = 0; i < ch->desc_num && ctl; i++) {
62 next = ctl->next;
63 kfree(ctl);
64 ctl = next;
65 }
66}
67
68static int wcn36xx_dxe_allocate_ctl_block(struct wcn36xx_dxe_ch *ch)
69{
70 struct wcn36xx_dxe_ctl *prev_ctl = NULL;
71 struct wcn36xx_dxe_ctl *cur_ctl = NULL;
72 int i;
73
74 for (i = 0; i < ch->desc_num; i++) {
75 cur_ctl = kzalloc(sizeof(*cur_ctl), GFP_KERNEL);
76 if (!cur_ctl)
77 goto out_fail;
78
79 cur_ctl->ctl_blk_order = i;
80 if (i == 0) {
81 ch->head_blk_ctl = cur_ctl;
82 ch->tail_blk_ctl = cur_ctl;
83 } else if (ch->desc_num - 1 == i) {
84 prev_ctl->next = cur_ctl;
85 cur_ctl->next = ch->head_blk_ctl;
86 } else {
87 prev_ctl->next = cur_ctl;
88 }
89 prev_ctl = cur_ctl;
90 }
91
92 return 0;
93
94out_fail:
95 wcn36xx_dxe_free_ctl_block(ch);
96 return -ENOMEM;
97}
98
99int wcn36xx_dxe_alloc_ctl_blks(struct wcn36xx *wcn)
100{
101 int ret;
102
103 wcn->dxe_tx_l_ch.ch_type = WCN36XX_DXE_CH_TX_L;
104 wcn->dxe_tx_h_ch.ch_type = WCN36XX_DXE_CH_TX_H;
105 wcn->dxe_rx_l_ch.ch_type = WCN36XX_DXE_CH_RX_L;
106 wcn->dxe_rx_h_ch.ch_type = WCN36XX_DXE_CH_RX_H;
107
108 wcn->dxe_tx_l_ch.desc_num = WCN36XX_DXE_CH_DESC_NUMB_TX_L;
109 wcn->dxe_tx_h_ch.desc_num = WCN36XX_DXE_CH_DESC_NUMB_TX_H;
110 wcn->dxe_rx_l_ch.desc_num = WCN36XX_DXE_CH_DESC_NUMB_RX_L;
111 wcn->dxe_rx_h_ch.desc_num = WCN36XX_DXE_CH_DESC_NUMB_RX_H;
112
113 wcn->dxe_tx_l_ch.dxe_wq = WCN36XX_DXE_WQ_TX_L;
114 wcn->dxe_tx_h_ch.dxe_wq = WCN36XX_DXE_WQ_TX_H;
115
116 wcn->dxe_tx_l_ch.ctrl_bd = WCN36XX_DXE_CTRL_TX_L_BD;
117 wcn->dxe_tx_h_ch.ctrl_bd = WCN36XX_DXE_CTRL_TX_H_BD;
118
119 wcn->dxe_tx_l_ch.ctrl_skb = WCN36XX_DXE_CTRL_TX_L_SKB;
120 wcn->dxe_tx_h_ch.ctrl_skb = WCN36XX_DXE_CTRL_TX_H_SKB;
121
122 wcn->dxe_tx_l_ch.reg_ctrl = WCN36XX_DXE_REG_CTL_TX_L;
123 wcn->dxe_tx_h_ch.reg_ctrl = WCN36XX_DXE_REG_CTL_TX_H;
124
125 wcn->dxe_tx_l_ch.def_ctrl = WCN36XX_DXE_CH_DEFAULT_CTL_TX_L;
126 wcn->dxe_tx_h_ch.def_ctrl = WCN36XX_DXE_CH_DEFAULT_CTL_TX_H;
127
128 /* DXE control block allocation */
129 ret = wcn36xx_dxe_allocate_ctl_block(&wcn->dxe_tx_l_ch);
130 if (ret)
131 goto out_err;
132 ret = wcn36xx_dxe_allocate_ctl_block(&wcn->dxe_tx_h_ch);
133 if (ret)
134 goto out_err;
135 ret = wcn36xx_dxe_allocate_ctl_block(&wcn->dxe_rx_l_ch);
136 if (ret)
137 goto out_err;
138 ret = wcn36xx_dxe_allocate_ctl_block(&wcn->dxe_rx_h_ch);
139 if (ret)
140 goto out_err;
141
142 /* Initialize SMSM state Clear TX Enable RING EMPTY STATE */
143 ret = wcn->ctrl_ops->smsm_change_state(
144 WCN36XX_SMSM_WLAN_TX_ENABLE,
145 WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY);
146
147 return 0;
148
149out_err:
150 wcn36xx_err("Failed to allocate DXE control blocks\n");
151 wcn36xx_dxe_free_ctl_blks(wcn);
152 return -ENOMEM;
153}
154
155void wcn36xx_dxe_free_ctl_blks(struct wcn36xx *wcn)
156{
157 wcn36xx_dxe_free_ctl_block(&wcn->dxe_tx_l_ch);
158 wcn36xx_dxe_free_ctl_block(&wcn->dxe_tx_h_ch);
159 wcn36xx_dxe_free_ctl_block(&wcn->dxe_rx_l_ch);
160 wcn36xx_dxe_free_ctl_block(&wcn->dxe_rx_h_ch);
161}
162
163static int wcn36xx_dxe_init_descs(struct wcn36xx_dxe_ch *wcn_ch)
164{
165 struct wcn36xx_dxe_desc *cur_dxe = NULL;
166 struct wcn36xx_dxe_desc *prev_dxe = NULL;
167 struct wcn36xx_dxe_ctl *cur_ctl = NULL;
168 size_t size;
169 int i;
170
171 size = wcn_ch->desc_num * sizeof(struct wcn36xx_dxe_desc);
172 wcn_ch->cpu_addr = dma_alloc_coherent(NULL, size, &wcn_ch->dma_addr,
173 GFP_KERNEL);
174 if (!wcn_ch->cpu_addr)
175 return -ENOMEM;
176
177 memset(wcn_ch->cpu_addr, 0, size);
178
179 cur_dxe = (struct wcn36xx_dxe_desc *)wcn_ch->cpu_addr;
180 cur_ctl = wcn_ch->head_blk_ctl;
181
182 for (i = 0; i < wcn_ch->desc_num; i++) {
183 cur_ctl->desc = cur_dxe;
184 cur_ctl->desc_phy_addr = wcn_ch->dma_addr +
185 i * sizeof(struct wcn36xx_dxe_desc);
186
187 switch (wcn_ch->ch_type) {
188 case WCN36XX_DXE_CH_TX_L:
189 cur_dxe->ctrl = WCN36XX_DXE_CTRL_TX_L;
190 cur_dxe->dst_addr_l = WCN36XX_DXE_WQ_TX_L;
191 break;
192 case WCN36XX_DXE_CH_TX_H:
193 cur_dxe->ctrl = WCN36XX_DXE_CTRL_TX_H;
194 cur_dxe->dst_addr_l = WCN36XX_DXE_WQ_TX_H;
195 break;
196 case WCN36XX_DXE_CH_RX_L:
197 cur_dxe->ctrl = WCN36XX_DXE_CTRL_RX_L;
198 cur_dxe->src_addr_l = WCN36XX_DXE_WQ_RX_L;
199 break;
200 case WCN36XX_DXE_CH_RX_H:
201 cur_dxe->ctrl = WCN36XX_DXE_CTRL_RX_H;
202 cur_dxe->src_addr_l = WCN36XX_DXE_WQ_RX_H;
203 break;
204 }
205 if (0 == i) {
206 cur_dxe->phy_next_l = 0;
207 } else if ((0 < i) && (i < wcn_ch->desc_num - 1)) {
208 prev_dxe->phy_next_l =
209 cur_ctl->desc_phy_addr;
210 } else if (i == (wcn_ch->desc_num - 1)) {
211 prev_dxe->phy_next_l =
212 cur_ctl->desc_phy_addr;
213 cur_dxe->phy_next_l =
214 wcn_ch->head_blk_ctl->desc_phy_addr;
215 }
216 cur_ctl = cur_ctl->next;
217 prev_dxe = cur_dxe;
218 cur_dxe++;
219 }
220
221 return 0;
222}
223
224static void wcn36xx_dxe_init_tx_bd(struct wcn36xx_dxe_ch *ch,
225 struct wcn36xx_dxe_mem_pool *pool)
226{
227 int i, chunk_size = pool->chunk_size;
228 dma_addr_t bd_phy_addr = pool->phy_addr;
229 void *bd_cpu_addr = pool->virt_addr;
230 struct wcn36xx_dxe_ctl *cur = ch->head_blk_ctl;
231
232 for (i = 0; i < ch->desc_num; i++) {
233 /* Only every second dxe needs a bd pointer,
234 the other will point to the skb data */
235 if (!(i & 1)) {
236 cur->bd_phy_addr = bd_phy_addr;
237 cur->bd_cpu_addr = bd_cpu_addr;
238 bd_phy_addr += chunk_size;
239 bd_cpu_addr += chunk_size;
240 } else {
241 cur->bd_phy_addr = 0;
242 cur->bd_cpu_addr = NULL;
243 }
244 cur = cur->next;
245 }
246}
247
248static int wcn36xx_dxe_enable_ch_int(struct wcn36xx *wcn, u16 wcn_ch)
249{
250 int reg_data = 0;
251
252 wcn36xx_dxe_read_register(wcn,
253 WCN36XX_DXE_INT_MASK_REG,
254 &reg_data);
255
256 reg_data |= wcn_ch;
257
258 wcn36xx_dxe_write_register(wcn,
259 WCN36XX_DXE_INT_MASK_REG,
260 (int)reg_data);
261 return 0;
262}
263
264static int wcn36xx_dxe_fill_skb(struct wcn36xx_dxe_ctl *ctl)
265{
266 struct wcn36xx_dxe_desc *dxe = ctl->desc;
267 struct sk_buff *skb;
268
269 skb = alloc_skb(WCN36XX_PKT_SIZE, GFP_ATOMIC);
270 if (skb == NULL)
271 return -ENOMEM;
272
273 dxe->dst_addr_l = dma_map_single(NULL,
274 skb_tail_pointer(skb),
275 WCN36XX_PKT_SIZE,
276 DMA_FROM_DEVICE);
277 ctl->skb = skb;
278
279 return 0;
280}
281
282static int wcn36xx_dxe_ch_alloc_skb(struct wcn36xx *wcn,
283 struct wcn36xx_dxe_ch *wcn_ch)
284{
285 int i;
286 struct wcn36xx_dxe_ctl *cur_ctl = NULL;
287
288 cur_ctl = wcn_ch->head_blk_ctl;
289
290 for (i = 0; i < wcn_ch->desc_num; i++) {
291 wcn36xx_dxe_fill_skb(cur_ctl);
292 cur_ctl = cur_ctl->next;
293 }
294
295 return 0;
296}
297
298static void wcn36xx_dxe_ch_free_skbs(struct wcn36xx *wcn,
299 struct wcn36xx_dxe_ch *wcn_ch)
300{
301 struct wcn36xx_dxe_ctl *cur = wcn_ch->head_blk_ctl;
302 int i;
303
304 for (i = 0; i < wcn_ch->desc_num; i++) {
305 kfree_skb(cur->skb);
306 cur = cur->next;
307 }
308}
309
310void wcn36xx_dxe_tx_ack_ind(struct wcn36xx *wcn, u32 status)
311{
312 struct ieee80211_tx_info *info;
313 struct sk_buff *skb;
314 unsigned long flags;
315
316 spin_lock_irqsave(&wcn->dxe_lock, flags);
317 skb = wcn->tx_ack_skb;
318 wcn->tx_ack_skb = NULL;
319 spin_unlock_irqrestore(&wcn->dxe_lock, flags);
320
321 if (!skb) {
322 wcn36xx_warn("Spurious TX complete indication\n");
323 return;
324 }
325
326 info = IEEE80211_SKB_CB(skb);
327
328 if (status == 1)
329 info->flags |= IEEE80211_TX_STAT_ACK;
330
331 wcn36xx_dbg(WCN36XX_DBG_DXE, "dxe tx ack status: %d\n", status);
332
333 ieee80211_tx_status_irqsafe(wcn->hw, skb);
334 ieee80211_wake_queues(wcn->hw);
335}
336
337static void reap_tx_dxes(struct wcn36xx *wcn, struct wcn36xx_dxe_ch *ch)
338{
339 struct wcn36xx_dxe_ctl *ctl = ch->tail_blk_ctl;
340 struct ieee80211_tx_info *info;
341 unsigned long flags;
342
343 /*
344 * Make at least one loop of do-while because in case ring is
345 * completely full head and tail are pointing to the same element
346 * and while-do will not make any cycles.
347 */
348 do {
349 if (ctl->skb) {
350 dma_unmap_single(NULL, ctl->desc->src_addr_l,
351 ctl->skb->len, DMA_TO_DEVICE);
352 info = IEEE80211_SKB_CB(ctl->skb);
353 if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) {
354 /* Keep frame until TX status comes */
355 ieee80211_free_txskb(wcn->hw, ctl->skb);
356 }
357 spin_lock_irqsave(&ctl->skb_lock, flags);
358 if (wcn->queues_stopped) {
359 wcn->queues_stopped = false;
360 ieee80211_wake_queues(wcn->hw);
361 }
362 spin_unlock_irqrestore(&ctl->skb_lock, flags);
363
364 ctl->skb = NULL;
365 }
366 ctl = ctl->next;
367 } while (ctl != ch->head_blk_ctl &&
368 !(ctl->desc->ctrl & WCN36XX_DXE_CTRL_VALID_MASK));
369
370 ch->tail_blk_ctl = ctl;
371}
372
373static irqreturn_t wcn36xx_irq_tx_complete(int irq, void *dev)
374{
375 struct wcn36xx *wcn = (struct wcn36xx *)dev;
376 int int_src, int_reason;
377
378 wcn36xx_dxe_read_register(wcn, WCN36XX_DXE_INT_SRC_RAW_REG, &int_src);
379
380 if (int_src & WCN36XX_INT_MASK_CHAN_TX_H) {
381 wcn36xx_dxe_read_register(wcn,
382 WCN36XX_DXE_CH_STATUS_REG_ADDR_TX_H,
383 &int_reason);
384
385 /* TODO: Check int_reason */
386
387 wcn36xx_dxe_write_register(wcn,
388 WCN36XX_DXE_0_INT_CLR,
389 WCN36XX_INT_MASK_CHAN_TX_H);
390
391 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_0_INT_ED_CLR,
392 WCN36XX_INT_MASK_CHAN_TX_H);
393 wcn36xx_dbg(WCN36XX_DBG_DXE, "dxe tx ready high\n");
394 reap_tx_dxes(wcn, &wcn->dxe_tx_h_ch);
395 }
396
397 if (int_src & WCN36XX_INT_MASK_CHAN_TX_L) {
398 wcn36xx_dxe_read_register(wcn,
399 WCN36XX_DXE_CH_STATUS_REG_ADDR_TX_L,
400 &int_reason);
401 /* TODO: Check int_reason */
402
403 wcn36xx_dxe_write_register(wcn,
404 WCN36XX_DXE_0_INT_CLR,
405 WCN36XX_INT_MASK_CHAN_TX_L);
406
407 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_0_INT_ED_CLR,
408 WCN36XX_INT_MASK_CHAN_TX_L);
409 wcn36xx_dbg(WCN36XX_DBG_DXE, "dxe tx ready low\n");
410 reap_tx_dxes(wcn, &wcn->dxe_tx_l_ch);
411 }
412
413 return IRQ_HANDLED;
414}
415
416static irqreturn_t wcn36xx_irq_rx_ready(int irq, void *dev)
417{
418 struct wcn36xx *wcn = (struct wcn36xx *)dev;
419
420 disable_irq_nosync(wcn->rx_irq);
421 wcn36xx_dxe_rx_frame(wcn);
422 enable_irq(wcn->rx_irq);
423 return IRQ_HANDLED;
424}
425
426static int wcn36xx_dxe_request_irqs(struct wcn36xx *wcn)
427{
428 int ret;
429
430 ret = request_irq(wcn->tx_irq, wcn36xx_irq_tx_complete,
431 IRQF_TRIGGER_HIGH, "wcn36xx_tx", wcn);
432 if (ret) {
433 wcn36xx_err("failed to alloc tx irq\n");
434 goto out_err;
435 }
436
437 ret = request_irq(wcn->rx_irq, wcn36xx_irq_rx_ready, IRQF_TRIGGER_HIGH,
438 "wcn36xx_rx", wcn);
439 if (ret) {
440 wcn36xx_err("failed to alloc rx irq\n");
441 goto out_txirq;
442 }
443
444 enable_irq_wake(wcn->rx_irq);
445
446 return 0;
447
448out_txirq:
449 free_irq(wcn->tx_irq, wcn);
450out_err:
451 return ret;
452
453}
454
455static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn,
456 struct wcn36xx_dxe_ch *ch)
457{
458 struct wcn36xx_dxe_ctl *ctl = ch->head_blk_ctl;
459 struct wcn36xx_dxe_desc *dxe = ctl->desc;
460 dma_addr_t dma_addr;
461 struct sk_buff *skb;
462
463 while (!(dxe->ctrl & WCN36XX_DXE_CTRL_VALID_MASK)) {
464 skb = ctl->skb;
465 dma_addr = dxe->dst_addr_l;
466 wcn36xx_dxe_fill_skb(ctl);
467
468 switch (ch->ch_type) {
469 case WCN36XX_DXE_CH_RX_L:
470 dxe->ctrl = WCN36XX_DXE_CTRL_RX_L;
471 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_ENCH_ADDR,
472 WCN36XX_DXE_INT_CH1_MASK);
473 break;
474 case WCN36XX_DXE_CH_RX_H:
475 dxe->ctrl = WCN36XX_DXE_CTRL_RX_H;
476 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_ENCH_ADDR,
477 WCN36XX_DXE_INT_CH3_MASK);
478 break;
479 default:
480 wcn36xx_warn("Unknown channel\n");
481 }
482
483 dma_unmap_single(NULL, dma_addr, WCN36XX_PKT_SIZE,
484 DMA_FROM_DEVICE);
485 wcn36xx_rx_skb(wcn, skb);
486 ctl = ctl->next;
487 dxe = ctl->desc;
488 }
489
490 ch->head_blk_ctl = ctl;
491
492 return 0;
493}
494
495void wcn36xx_dxe_rx_frame(struct wcn36xx *wcn)
496{
497 int int_src;
498
499 wcn36xx_dxe_read_register(wcn, WCN36XX_DXE_INT_SRC_RAW_REG, &int_src);
500
501 /* RX_LOW_PRI */
502 if (int_src & WCN36XX_DXE_INT_CH1_MASK) {
503 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_0_INT_CLR,
504 WCN36XX_DXE_INT_CH1_MASK);
505 wcn36xx_rx_handle_packets(wcn, &(wcn->dxe_rx_l_ch));
506 }
507
508 /* RX_HIGH_PRI */
509 if (int_src & WCN36XX_DXE_INT_CH3_MASK) {
510 /* Clean up all the INT within this channel */
511 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_0_INT_CLR,
512 WCN36XX_DXE_INT_CH3_MASK);
513 wcn36xx_rx_handle_packets(wcn, &(wcn->dxe_rx_h_ch));
514 }
515
516 if (!int_src)
517 wcn36xx_warn("No DXE interrupt pending\n");
518}
519
520int wcn36xx_dxe_allocate_mem_pools(struct wcn36xx *wcn)
521{
522 size_t s;
523 void *cpu_addr;
524
525 /* Allocate BD headers for MGMT frames */
526
527 /* Where this come from ask QC */
528 wcn->mgmt_mem_pool.chunk_size = WCN36XX_BD_CHUNK_SIZE +
529 16 - (WCN36XX_BD_CHUNK_SIZE % 8);
530
531 s = wcn->mgmt_mem_pool.chunk_size * WCN36XX_DXE_CH_DESC_NUMB_TX_H;
532 cpu_addr = dma_alloc_coherent(NULL, s, &wcn->mgmt_mem_pool.phy_addr,
533 GFP_KERNEL);
534 if (!cpu_addr)
535 goto out_err;
536
537 wcn->mgmt_mem_pool.virt_addr = cpu_addr;
538 memset(cpu_addr, 0, s);
539
540 /* Allocate BD headers for DATA frames */
541
542 /* Where this come from ask QC */
543 wcn->data_mem_pool.chunk_size = WCN36XX_BD_CHUNK_SIZE +
544 16 - (WCN36XX_BD_CHUNK_SIZE % 8);
545
546 s = wcn->data_mem_pool.chunk_size * WCN36XX_DXE_CH_DESC_NUMB_TX_L;
547 cpu_addr = dma_alloc_coherent(NULL, s, &wcn->data_mem_pool.phy_addr,
548 GFP_KERNEL);
549 if (!cpu_addr)
550 goto out_err;
551
552 wcn->data_mem_pool.virt_addr = cpu_addr;
553 memset(cpu_addr, 0, s);
554
555 return 0;
556
557out_err:
558 wcn36xx_dxe_free_mem_pools(wcn);
559 wcn36xx_err("Failed to allocate BD mempool\n");
560 return -ENOMEM;
561}
562
563void wcn36xx_dxe_free_mem_pools(struct wcn36xx *wcn)
564{
565 if (wcn->mgmt_mem_pool.virt_addr)
566 dma_free_coherent(NULL, wcn->mgmt_mem_pool.chunk_size *
567 WCN36XX_DXE_CH_DESC_NUMB_TX_H,
568 wcn->mgmt_mem_pool.virt_addr,
569 wcn->mgmt_mem_pool.phy_addr);
570
571 if (wcn->data_mem_pool.virt_addr) {
572 dma_free_coherent(NULL, wcn->data_mem_pool.chunk_size *
573 WCN36XX_DXE_CH_DESC_NUMB_TX_L,
574 wcn->data_mem_pool.virt_addr,
575 wcn->data_mem_pool.phy_addr);
576 }
577}
578
579int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn,
580 struct wcn36xx_vif *vif_priv,
581 struct sk_buff *skb,
582 bool is_low)
583{
584 struct wcn36xx_dxe_ctl *ctl = NULL;
585 struct wcn36xx_dxe_desc *desc = NULL;
586 struct wcn36xx_dxe_ch *ch = NULL;
587 unsigned long flags;
588
589 ch = is_low ? &wcn->dxe_tx_l_ch : &wcn->dxe_tx_h_ch;
590
591 ctl = ch->head_blk_ctl;
592
593 spin_lock_irqsave(&ctl->next->skb_lock, flags);
594
595 /*
596 * If skb is not null that means that we reached the tail of the ring
597 * hence ring is full. Stop queues to let mac80211 back off until ring
598 * has an empty slot again.
599 */
600 if (NULL != ctl->next->skb) {
601 ieee80211_stop_queues(wcn->hw);
602 wcn->queues_stopped = true;
603 spin_unlock_irqrestore(&ctl->next->skb_lock, flags);
604 return -EBUSY;
605 }
606 spin_unlock_irqrestore(&ctl->next->skb_lock, flags);
607
608 ctl->skb = NULL;
609 desc = ctl->desc;
610
611 /* Set source address of the BD we send */
612 desc->src_addr_l = ctl->bd_phy_addr;
613
614 desc->dst_addr_l = ch->dxe_wq;
615 desc->fr_len = sizeof(struct wcn36xx_tx_bd);
616 desc->ctrl = ch->ctrl_bd;
617
618 wcn36xx_dbg(WCN36XX_DBG_DXE, "DXE TX\n");
619
620 wcn36xx_dbg_dump(WCN36XX_DBG_DXE_DUMP, "DESC1 >>> ",
621 (char *)desc, sizeof(*desc));
622 wcn36xx_dbg_dump(WCN36XX_DBG_DXE_DUMP,
623 "BD >>> ", (char *)ctl->bd_cpu_addr,
624 sizeof(struct wcn36xx_tx_bd));
625
626 /* Set source address of the SKB we send */
627 ctl = ctl->next;
628 ctl->skb = skb;
629 desc = ctl->desc;
630 if (ctl->bd_cpu_addr) {
631 wcn36xx_err("bd_cpu_addr cannot be NULL for skb DXE\n");
632 return -EINVAL;
633 }
634
635 desc->src_addr_l = dma_map_single(NULL,
636 ctl->skb->data,
637 ctl->skb->len,
638 DMA_TO_DEVICE);
639
640 desc->dst_addr_l = ch->dxe_wq;
641 desc->fr_len = ctl->skb->len;
642
643 /* set dxe descriptor to VALID */
644 desc->ctrl = ch->ctrl_skb;
645
646 wcn36xx_dbg_dump(WCN36XX_DBG_DXE_DUMP, "DESC2 >>> ",
647 (char *)desc, sizeof(*desc));
648 wcn36xx_dbg_dump(WCN36XX_DBG_DXE_DUMP, "SKB >>> ",
649 (char *)ctl->skb->data, ctl->skb->len);
650
651 /* Move the head of the ring to the next empty descriptor */
652 ch->head_blk_ctl = ctl->next;
653
654 /*
655 * When connected and trying to send data frame chip can be in sleep
656 * mode and writing to the register will not wake up the chip. Instead
657 * notify chip about new frame through SMSM bus.
658 */
659 if (is_low && vif_priv->pw_state == WCN36XX_BMPS) {
660 wcn->ctrl_ops->smsm_change_state(
661 0,
662 WCN36XX_SMSM_WLAN_TX_ENABLE);
663 } else {
664 /* indicate End Of Packet and generate interrupt on descriptor
665 * done.
666 */
667 wcn36xx_dxe_write_register(wcn,
668 ch->reg_ctrl, ch->def_ctrl);
669 }
670
671 return 0;
672}
673
674int wcn36xx_dxe_init(struct wcn36xx *wcn)
675{
676 int reg_data = 0, ret;
677
678 reg_data = WCN36XX_DXE_REG_RESET;
679 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_REG_CSR_RESET, reg_data);
680
681 /* Setting interrupt path */
682 reg_data = WCN36XX_DXE_CCU_INT;
683 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_REG_CCU_INT, reg_data);
684
685 /***************************************/
686 /* Init descriptors for TX LOW channel */
687 /***************************************/
688 wcn36xx_dxe_init_descs(&wcn->dxe_tx_l_ch);
689 wcn36xx_dxe_init_tx_bd(&wcn->dxe_tx_l_ch, &wcn->data_mem_pool);
690
691 /* Write channel head to a NEXT register */
692 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_CH_NEXT_DESC_ADDR_TX_L,
693 wcn->dxe_tx_l_ch.head_blk_ctl->desc_phy_addr);
694
695 /* Program DMA destination addr for TX LOW */
696 wcn36xx_dxe_write_register(wcn,
697 WCN36XX_DXE_CH_DEST_ADDR_TX_L,
698 WCN36XX_DXE_WQ_TX_L);
699
700 wcn36xx_dxe_read_register(wcn, WCN36XX_DXE_REG_CH_EN, &reg_data);
701 wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_L);
702
703 /***************************************/
704 /* Init descriptors for TX HIGH channel */
705 /***************************************/
706 wcn36xx_dxe_init_descs(&wcn->dxe_tx_h_ch);
707 wcn36xx_dxe_init_tx_bd(&wcn->dxe_tx_h_ch, &wcn->mgmt_mem_pool);
708
709 /* Write channel head to a NEXT register */
710 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_CH_NEXT_DESC_ADDR_TX_H,
711 wcn->dxe_tx_h_ch.head_blk_ctl->desc_phy_addr);
712
713 /* Program DMA destination addr for TX HIGH */
714 wcn36xx_dxe_write_register(wcn,
715 WCN36XX_DXE_CH_DEST_ADDR_TX_H,
716 WCN36XX_DXE_WQ_TX_H);
717
718 wcn36xx_dxe_read_register(wcn, WCN36XX_DXE_REG_CH_EN, &reg_data);
719
720 /* Enable channel interrupts */
721 wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_H);
722
723 /***************************************/
724 /* Init descriptors for RX LOW channel */
725 /***************************************/
726 wcn36xx_dxe_init_descs(&wcn->dxe_rx_l_ch);
727
728 /* For RX we need to preallocated buffers */
729 wcn36xx_dxe_ch_alloc_skb(wcn, &wcn->dxe_rx_l_ch);
730
731 /* Write channel head to a NEXT register */
732 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_CH_NEXT_DESC_ADDR_RX_L,
733 wcn->dxe_rx_l_ch.head_blk_ctl->desc_phy_addr);
734
735 /* Write DMA source address */
736 wcn36xx_dxe_write_register(wcn,
737 WCN36XX_DXE_CH_SRC_ADDR_RX_L,
738 WCN36XX_DXE_WQ_RX_L);
739
740 /* Program preallocated destination address */
741 wcn36xx_dxe_write_register(wcn,
742 WCN36XX_DXE_CH_DEST_ADDR_RX_L,
743 wcn->dxe_rx_l_ch.head_blk_ctl->desc->phy_next_l);
744
745 /* Enable default control registers */
746 wcn36xx_dxe_write_register(wcn,
747 WCN36XX_DXE_REG_CTL_RX_L,
748 WCN36XX_DXE_CH_DEFAULT_CTL_RX_L);
749
750 /* Enable channel interrupts */
751 wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_L);
752
753 /***************************************/
754 /* Init descriptors for RX HIGH channel */
755 /***************************************/
756 wcn36xx_dxe_init_descs(&wcn->dxe_rx_h_ch);
757
758 /* For RX we need to prealocat buffers */
759 wcn36xx_dxe_ch_alloc_skb(wcn, &wcn->dxe_rx_h_ch);
760
761 /* Write chanel head to a NEXT register */
762 wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_CH_NEXT_DESC_ADDR_RX_H,
763 wcn->dxe_rx_h_ch.head_blk_ctl->desc_phy_addr);
764
765 /* Write DMA source address */
766 wcn36xx_dxe_write_register(wcn,
767 WCN36XX_DXE_CH_SRC_ADDR_RX_H,
768 WCN36XX_DXE_WQ_RX_H);
769
770 /* Program preallocated destination address */
771 wcn36xx_dxe_write_register(wcn,
772 WCN36XX_DXE_CH_DEST_ADDR_RX_H,
773 wcn->dxe_rx_h_ch.head_blk_ctl->desc->phy_next_l);
774
775 /* Enable default control registers */
776 wcn36xx_dxe_write_register(wcn,
777 WCN36XX_DXE_REG_CTL_RX_H,
778 WCN36XX_DXE_CH_DEFAULT_CTL_RX_H);
779
780 /* Enable channel interrupts */
781 wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_H);
782
783 ret = wcn36xx_dxe_request_irqs(wcn);
784 if (ret < 0)
785 goto out_err;
786
787 return 0;
788
789out_err:
790 return ret;
791}
792
793void wcn36xx_dxe_deinit(struct wcn36xx *wcn)
794{
795 free_irq(wcn->tx_irq, wcn);
796 free_irq(wcn->rx_irq, wcn);
797
798 if (wcn->tx_ack_skb) {
799 ieee80211_tx_status_irqsafe(wcn->hw, wcn->tx_ack_skb);
800 wcn->tx_ack_skb = NULL;
801 }
802
803 wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_l_ch);
804 wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_h_ch);
805}
diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.h b/drivers/net/wireless/ath/wcn36xx/dxe.h
new file mode 100644
index 000000000000..c88562f85de1
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/dxe.h
@@ -0,0 +1,284 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _DXE_H_
18#define _DXE_H_
19
20#include "wcn36xx.h"
21
22/*
23TX_LOW = DMA0
24TX_HIGH = DMA4
25RX_LOW = DMA1
26RX_HIGH = DMA3
27H2H_TEST_RX_TX = DMA2
28*/
29
30/* DXE registers */
31#define WCN36XX_DXE_MEM_BASE 0x03000000
32#define WCN36XX_DXE_MEM_REG 0x202000
33
34#define WCN36XX_DXE_CCU_INT 0xA0011
35#define WCN36XX_DXE_REG_CCU_INT 0x200b10
36
37/* TODO This must calculated properly but not hardcoded */
38#define WCN36XX_DXE_CTRL_TX_L 0x328a44
39#define WCN36XX_DXE_CTRL_TX_H 0x32ce44
40#define WCN36XX_DXE_CTRL_RX_L 0x12ad2f
41#define WCN36XX_DXE_CTRL_RX_H 0x12d12f
42#define WCN36XX_DXE_CTRL_TX_H_BD 0x30ce45
43#define WCN36XX_DXE_CTRL_TX_H_SKB 0x32ce4d
44#define WCN36XX_DXE_CTRL_TX_L_BD 0x308a45
45#define WCN36XX_DXE_CTRL_TX_L_SKB 0x328a4d
46
47/* TODO This must calculated properly but not hardcoded */
48#define WCN36XX_DXE_WQ_TX_L 0x17
49#define WCN36XX_DXE_WQ_TX_H 0x17
50#define WCN36XX_DXE_WQ_RX_L 0xB
51#define WCN36XX_DXE_WQ_RX_H 0x4
52
53/* DXE descriptor control filed */
54#define WCN36XX_DXE_CTRL_VALID_MASK (0x00000001)
55
56/* TODO This must calculated properly but not hardcoded */
57/* DXE default control register values */
58#define WCN36XX_DXE_CH_DEFAULT_CTL_RX_L 0x847EAD2F
59#define WCN36XX_DXE_CH_DEFAULT_CTL_RX_H 0x84FED12F
60#define WCN36XX_DXE_CH_DEFAULT_CTL_TX_H 0x853ECF4D
61#define WCN36XX_DXE_CH_DEFAULT_CTL_TX_L 0x843e8b4d
62
63/* Common DXE registers */
64#define WCN36XX_DXE_MEM_CSR (WCN36XX_DXE_MEM_REG + 0x00)
65#define WCN36XX_DXE_REG_CSR_RESET (WCN36XX_DXE_MEM_REG + 0x00)
66#define WCN36XX_DXE_ENCH_ADDR (WCN36XX_DXE_MEM_REG + 0x04)
67#define WCN36XX_DXE_REG_CH_EN (WCN36XX_DXE_MEM_REG + 0x08)
68#define WCN36XX_DXE_REG_CH_DONE (WCN36XX_DXE_MEM_REG + 0x0C)
69#define WCN36XX_DXE_REG_CH_ERR (WCN36XX_DXE_MEM_REG + 0x10)
70#define WCN36XX_DXE_INT_MASK_REG (WCN36XX_DXE_MEM_REG + 0x18)
71#define WCN36XX_DXE_INT_SRC_RAW_REG (WCN36XX_DXE_MEM_REG + 0x20)
72 /* #define WCN36XX_DXE_INT_CH6_MASK 0x00000040 */
73 /* #define WCN36XX_DXE_INT_CH5_MASK 0x00000020 */
74 #define WCN36XX_DXE_INT_CH4_MASK 0x00000010
75 #define WCN36XX_DXE_INT_CH3_MASK 0x00000008
76 /* #define WCN36XX_DXE_INT_CH2_MASK 0x00000004 */
77 #define WCN36XX_DXE_INT_CH1_MASK 0x00000002
78 #define WCN36XX_DXE_INT_CH0_MASK 0x00000001
79#define WCN36XX_DXE_0_INT_CLR (WCN36XX_DXE_MEM_REG + 0x30)
80#define WCN36XX_DXE_0_INT_ED_CLR (WCN36XX_DXE_MEM_REG + 0x34)
81#define WCN36XX_DXE_0_INT_DONE_CLR (WCN36XX_DXE_MEM_REG + 0x38)
82#define WCN36XX_DXE_0_INT_ERR_CLR (WCN36XX_DXE_MEM_REG + 0x3C)
83
84#define WCN36XX_DXE_0_CH0_STATUS (WCN36XX_DXE_MEM_REG + 0x404)
85#define WCN36XX_DXE_0_CH1_STATUS (WCN36XX_DXE_MEM_REG + 0x444)
86#define WCN36XX_DXE_0_CH2_STATUS (WCN36XX_DXE_MEM_REG + 0x484)
87#define WCN36XX_DXE_0_CH3_STATUS (WCN36XX_DXE_MEM_REG + 0x4C4)
88#define WCN36XX_DXE_0_CH4_STATUS (WCN36XX_DXE_MEM_REG + 0x504)
89
90#define WCN36XX_DXE_REG_RESET 0x5c89
91
92/* Temporary BMU Workqueue 4 */
93#define WCN36XX_DXE_BMU_WQ_RX_LOW 0xB
94#define WCN36XX_DXE_BMU_WQ_RX_HIGH 0x4
95/* DMA channel offset */
96#define WCN36XX_DXE_TX_LOW_OFFSET 0x400
97#define WCN36XX_DXE_TX_HIGH_OFFSET 0x500
98#define WCN36XX_DXE_RX_LOW_OFFSET 0x440
99#define WCN36XX_DXE_RX_HIGH_OFFSET 0x4C0
100
101/* Address of the next DXE descriptor */
102#define WCN36XX_DXE_CH_NEXT_DESC_ADDR 0x001C
103#define WCN36XX_DXE_CH_NEXT_DESC_ADDR_TX_L (WCN36XX_DXE_MEM_REG + \
104 WCN36XX_DXE_TX_LOW_OFFSET + \
105 WCN36XX_DXE_CH_NEXT_DESC_ADDR)
106#define WCN36XX_DXE_CH_NEXT_DESC_ADDR_TX_H (WCN36XX_DXE_MEM_REG + \
107 WCN36XX_DXE_TX_HIGH_OFFSET + \
108 WCN36XX_DXE_CH_NEXT_DESC_ADDR)
109#define WCN36XX_DXE_CH_NEXT_DESC_ADDR_RX_L (WCN36XX_DXE_MEM_REG + \
110 WCN36XX_DXE_RX_LOW_OFFSET + \
111 WCN36XX_DXE_CH_NEXT_DESC_ADDR)
112#define WCN36XX_DXE_CH_NEXT_DESC_ADDR_RX_H (WCN36XX_DXE_MEM_REG + \
113 WCN36XX_DXE_RX_HIGH_OFFSET + \
114 WCN36XX_DXE_CH_NEXT_DESC_ADDR)
115
116/* DXE Descriptor source address */
117#define WCN36XX_DXE_CH_SRC_ADDR 0x000C
118#define WCN36XX_DXE_CH_SRC_ADDR_RX_L (WCN36XX_DXE_MEM_REG + \
119 WCN36XX_DXE_RX_LOW_OFFSET + \
120 WCN36XX_DXE_CH_SRC_ADDR)
121#define WCN36XX_DXE_CH_SRC_ADDR_RX_H (WCN36XX_DXE_MEM_REG + \
122 WCN36XX_DXE_RX_HIGH_OFFSET + \
123 WCN36XX_DXE_CH_SRC_ADDR)
124
125/* DXE Descriptor address destination address */
126#define WCN36XX_DXE_CH_DEST_ADDR 0x0014
127#define WCN36XX_DXE_CH_DEST_ADDR_TX_L (WCN36XX_DXE_MEM_REG + \
128 WCN36XX_DXE_TX_LOW_OFFSET + \
129 WCN36XX_DXE_CH_DEST_ADDR)
130#define WCN36XX_DXE_CH_DEST_ADDR_TX_H (WCN36XX_DXE_MEM_REG + \
131 WCN36XX_DXE_TX_HIGH_OFFSET + \
132 WCN36XX_DXE_CH_DEST_ADDR)
133#define WCN36XX_DXE_CH_DEST_ADDR_RX_L (WCN36XX_DXE_MEM_REG + \
134 WCN36XX_DXE_RX_LOW_OFFSET + \
135 WCN36XX_DXE_CH_DEST_ADDR)
136#define WCN36XX_DXE_CH_DEST_ADDR_RX_H (WCN36XX_DXE_MEM_REG + \
137 WCN36XX_DXE_RX_HIGH_OFFSET + \
138 WCN36XX_DXE_CH_DEST_ADDR)
139
140/* Interrupt status */
141#define WCN36XX_DXE_CH_STATUS_REG_ADDR 0x0004
142#define WCN36XX_DXE_CH_STATUS_REG_ADDR_TX_L (WCN36XX_DXE_MEM_REG + \
143 WCN36XX_DXE_TX_LOW_OFFSET + \
144 WCN36XX_DXE_CH_STATUS_REG_ADDR)
145#define WCN36XX_DXE_CH_STATUS_REG_ADDR_TX_H (WCN36XX_DXE_MEM_REG + \
146 WCN36XX_DXE_TX_HIGH_OFFSET + \
147 WCN36XX_DXE_CH_STATUS_REG_ADDR)
148#define WCN36XX_DXE_CH_STATUS_REG_ADDR_RX_L (WCN36XX_DXE_MEM_REG + \
149 WCN36XX_DXE_RX_LOW_OFFSET + \
150 WCN36XX_DXE_CH_STATUS_REG_ADDR)
151#define WCN36XX_DXE_CH_STATUS_REG_ADDR_RX_H (WCN36XX_DXE_MEM_REG + \
152 WCN36XX_DXE_RX_HIGH_OFFSET + \
153 WCN36XX_DXE_CH_STATUS_REG_ADDR)
154
155
156/* DXE default control register */
157#define WCN36XX_DXE_REG_CTL_RX_L (WCN36XX_DXE_MEM_REG + \
158 WCN36XX_DXE_RX_LOW_OFFSET)
159#define WCN36XX_DXE_REG_CTL_RX_H (WCN36XX_DXE_MEM_REG + \
160 WCN36XX_DXE_RX_HIGH_OFFSET)
161#define WCN36XX_DXE_REG_CTL_TX_H (WCN36XX_DXE_MEM_REG + \
162 WCN36XX_DXE_TX_HIGH_OFFSET)
163#define WCN36XX_DXE_REG_CTL_TX_L (WCN36XX_DXE_MEM_REG + \
164 WCN36XX_DXE_TX_LOW_OFFSET)
165
166#define WCN36XX_SMSM_WLAN_TX_ENABLE 0x00000400
167#define WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY 0x00000200
168
169
170/* Interrupt control channel mask */
171#define WCN36XX_INT_MASK_CHAN_TX_L 0x00000001
172#define WCN36XX_INT_MASK_CHAN_RX_L 0x00000002
173#define WCN36XX_INT_MASK_CHAN_RX_H 0x00000008
174#define WCN36XX_INT_MASK_CHAN_TX_H 0x00000010
175
176#define WCN36XX_BD_CHUNK_SIZE 128
177
178#define WCN36XX_PKT_SIZE 0xF20
179enum wcn36xx_dxe_ch_type {
180 WCN36XX_DXE_CH_TX_L,
181 WCN36XX_DXE_CH_TX_H,
182 WCN36XX_DXE_CH_RX_L,
183 WCN36XX_DXE_CH_RX_H
184};
185
186/* amount of descriptors per channel */
187enum wcn36xx_dxe_ch_desc_num {
188 WCN36XX_DXE_CH_DESC_NUMB_TX_L = 128,
189 WCN36XX_DXE_CH_DESC_NUMB_TX_H = 10,
190 WCN36XX_DXE_CH_DESC_NUMB_RX_L = 512,
191 WCN36XX_DXE_CH_DESC_NUMB_RX_H = 40
192};
193
194/**
195 * struct wcn36xx_dxe_desc - describes descriptor of one DXE buffer
196 *
197 * @ctrl: is a union that consists of following bits:
198 * union {
199 * u32 valid :1; //0 = DMA stop, 1 = DMA continue with this
200 * //descriptor
201 * u32 transfer_type :2; //0 = Host to Host space
202 * u32 eop :1; //End of Packet
203 * u32 bd_handling :1; //if transferType = Host to BMU, then 0
204 * // means first 128 bytes contain BD, and 1
205 * // means create new empty BD
206 * u32 siq :1; // SIQ
207 * u32 diq :1; // DIQ
208 * u32 pdu_rel :1; //0 = don't release BD and PDUs when done,
209 * // 1 = release them
210 * u32 bthld_sel :4; //BMU Threshold Select
211 * u32 prio :3; //Specifies the priority level to use for
212 * // the transfer
213 * u32 stop_channel :1; //1 = DMA stops processing further, channel
214 * //requires re-enabling after this
215 * u32 intr :1; //Interrupt on Descriptor Done
216 * u32 rsvd :1; //reserved
217 * u32 size :14;//14 bits used - ignored for BMU transfers,
218 * //only used for host to host transfers?
219 * } ctrl;
220 */
221struct wcn36xx_dxe_desc {
222 u32 ctrl;
223 u32 fr_len;
224
225 u32 src_addr_l;
226 u32 dst_addr_l;
227 u32 phy_next_l;
228 u32 src_addr_h;
229 u32 dst_addr_h;
230 u32 phy_next_h;
231} __packed;
232
233/* DXE Control block */
234struct wcn36xx_dxe_ctl {
235 struct wcn36xx_dxe_ctl *next;
236 struct wcn36xx_dxe_desc *desc;
237 unsigned int desc_phy_addr;
238 int ctl_blk_order;
239 struct sk_buff *skb;
240 spinlock_t skb_lock;
241 void *bd_cpu_addr;
242 dma_addr_t bd_phy_addr;
243};
244
245struct wcn36xx_dxe_ch {
246 enum wcn36xx_dxe_ch_type ch_type;
247 void *cpu_addr;
248 dma_addr_t dma_addr;
249 enum wcn36xx_dxe_ch_desc_num desc_num;
250 /* DXE control block ring */
251 struct wcn36xx_dxe_ctl *head_blk_ctl;
252 struct wcn36xx_dxe_ctl *tail_blk_ctl;
253
254 /* DXE channel specific configs */
255 u32 dxe_wq;
256 u32 ctrl_bd;
257 u32 ctrl_skb;
258 u32 reg_ctrl;
259 u32 def_ctrl;
260};
261
262/* Memory Pool for BD headers */
263struct wcn36xx_dxe_mem_pool {
264 int chunk_size;
265 void *virt_addr;
266 dma_addr_t phy_addr;
267};
268
269struct wcn36xx_vif;
270int wcn36xx_dxe_allocate_mem_pools(struct wcn36xx *wcn);
271void wcn36xx_dxe_free_mem_pools(struct wcn36xx *wcn);
272void wcn36xx_dxe_rx_frame(struct wcn36xx *wcn);
273int wcn36xx_dxe_alloc_ctl_blks(struct wcn36xx *wcn);
274void wcn36xx_dxe_free_ctl_blks(struct wcn36xx *wcn);
275int wcn36xx_dxe_init(struct wcn36xx *wcn);
276void wcn36xx_dxe_deinit(struct wcn36xx *wcn);
277int wcn36xx_dxe_init_channels(struct wcn36xx *wcn);
278int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn,
279 struct wcn36xx_vif *vif_priv,
280 struct sk_buff *skb,
281 bool is_low);
282void wcn36xx_dxe_tx_ack_ind(struct wcn36xx *wcn, u32 status);
283void *wcn36xx_dxe_get_next_bd(struct wcn36xx *wcn, bool is_low);
284#endif /* _DXE_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
new file mode 100644
index 000000000000..c02dbc618724
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -0,0 +1,4657 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _HAL_H_
18#define _HAL_H_
19
20/*---------------------------------------------------------------------------
21 API VERSIONING INFORMATION
22
23 The RIVA API is versioned as MAJOR.MINOR.VERSION.REVISION
24 The MAJOR is incremented for major product/architecture changes
25 (and then MINOR/VERSION/REVISION are zeroed)
26 The MINOR is incremented for minor product/architecture changes
27 (and then VERSION/REVISION are zeroed)
28 The VERSION is incremented if a significant API change occurs
29 (and then REVISION is zeroed)
30 The REVISION is incremented if an insignificant API change occurs
31 or if a new API is added
32 All values are in the range 0..255 (ie they are 8-bit values)
33 ---------------------------------------------------------------------------*/
34#define WCN36XX_HAL_VER_MAJOR 1
35#define WCN36XX_HAL_VER_MINOR 4
36#define WCN36XX_HAL_VER_VERSION 1
37#define WCN36XX_HAL_VER_REVISION 2
38
39/* This is to force compiler to use the maximum of an int ( 4 bytes ) */
40#define WCN36XX_HAL_MAX_ENUM_SIZE 0x7FFFFFFF
41#define WCN36XX_HAL_MSG_TYPE_MAX_ENUM_SIZE 0x7FFF
42
43/* Max no. of transmit categories */
44#define STACFG_MAX_TC 8
45
46/* The maximum value of access category */
47#define WCN36XX_HAL_MAX_AC 4
48
49#define WCN36XX_HAL_IPV4_ADDR_LEN 4
50
51#define WALN_HAL_STA_INVALID_IDX 0xFF
52#define WCN36XX_HAL_BSS_INVALID_IDX 0xFF
53
54/* Default Beacon template size */
55#define BEACON_TEMPLATE_SIZE 0x180
56
57/* Param Change Bitmap sent to HAL */
58#define PARAM_BCN_INTERVAL_CHANGED (1 << 0)
59#define PARAM_SHORT_PREAMBLE_CHANGED (1 << 1)
60#define PARAM_SHORT_SLOT_TIME_CHANGED (1 << 2)
61#define PARAM_llACOEXIST_CHANGED (1 << 3)
62#define PARAM_llBCOEXIST_CHANGED (1 << 4)
63#define PARAM_llGCOEXIST_CHANGED (1 << 5)
64#define PARAM_HT20MHZCOEXIST_CHANGED (1<<6)
65#define PARAM_NON_GF_DEVICES_PRESENT_CHANGED (1<<7)
66#define PARAM_RIFS_MODE_CHANGED (1<<8)
67#define PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED (1<<9)
68#define PARAM_OBSS_MODE_CHANGED (1<<10)
69#define PARAM_BEACON_UPDATE_MASK \
70 (PARAM_BCN_INTERVAL_CHANGED | \
71 PARAM_SHORT_PREAMBLE_CHANGED | \
72 PARAM_SHORT_SLOT_TIME_CHANGED | \
73 PARAM_llACOEXIST_CHANGED | \
74 PARAM_llBCOEXIST_CHANGED | \
75 PARAM_llGCOEXIST_CHANGED | \
76 PARAM_HT20MHZCOEXIST_CHANGED | \
77 PARAM_NON_GF_DEVICES_PRESENT_CHANGED | \
78 PARAM_RIFS_MODE_CHANGED | \
79 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED | \
80 PARAM_OBSS_MODE_CHANGED)
81
82/* dump command response Buffer size */
83#define DUMPCMD_RSP_BUFFER 100
84
85/* version string max length (including NULL) */
86#define WCN36XX_HAL_VERSION_LENGTH 64
87
88/* message types for messages exchanged between WDI and HAL */
89enum wcn36xx_hal_host_msg_type {
90 /* Init/De-Init */
91 WCN36XX_HAL_START_REQ = 0,
92 WCN36XX_HAL_START_RSP = 1,
93 WCN36XX_HAL_STOP_REQ = 2,
94 WCN36XX_HAL_STOP_RSP = 3,
95
96 /* Scan */
97 WCN36XX_HAL_INIT_SCAN_REQ = 4,
98 WCN36XX_HAL_INIT_SCAN_RSP = 5,
99 WCN36XX_HAL_START_SCAN_REQ = 6,
100 WCN36XX_HAL_START_SCAN_RSP = 7,
101 WCN36XX_HAL_END_SCAN_REQ = 8,
102 WCN36XX_HAL_END_SCAN_RSP = 9,
103 WCN36XX_HAL_FINISH_SCAN_REQ = 10,
104 WCN36XX_HAL_FINISH_SCAN_RSP = 11,
105
106 /* HW STA configuration/deconfiguration */
107 WCN36XX_HAL_CONFIG_STA_REQ = 12,
108 WCN36XX_HAL_CONFIG_STA_RSP = 13,
109 WCN36XX_HAL_DELETE_STA_REQ = 14,
110 WCN36XX_HAL_DELETE_STA_RSP = 15,
111 WCN36XX_HAL_CONFIG_BSS_REQ = 16,
112 WCN36XX_HAL_CONFIG_BSS_RSP = 17,
113 WCN36XX_HAL_DELETE_BSS_REQ = 18,
114 WCN36XX_HAL_DELETE_BSS_RSP = 19,
115
116 /* Infra STA asscoiation */
117 WCN36XX_HAL_JOIN_REQ = 20,
118 WCN36XX_HAL_JOIN_RSP = 21,
119 WCN36XX_HAL_POST_ASSOC_REQ = 22,
120 WCN36XX_HAL_POST_ASSOC_RSP = 23,
121
122 /* Security */
123 WCN36XX_HAL_SET_BSSKEY_REQ = 24,
124 WCN36XX_HAL_SET_BSSKEY_RSP = 25,
125 WCN36XX_HAL_SET_STAKEY_REQ = 26,
126 WCN36XX_HAL_SET_STAKEY_RSP = 27,
127 WCN36XX_HAL_RMV_BSSKEY_REQ = 28,
128 WCN36XX_HAL_RMV_BSSKEY_RSP = 29,
129 WCN36XX_HAL_RMV_STAKEY_REQ = 30,
130 WCN36XX_HAL_RMV_STAKEY_RSP = 31,
131
132 /* Qos Related */
133 WCN36XX_HAL_ADD_TS_REQ = 32,
134 WCN36XX_HAL_ADD_TS_RSP = 33,
135 WCN36XX_HAL_DEL_TS_REQ = 34,
136 WCN36XX_HAL_DEL_TS_RSP = 35,
137 WCN36XX_HAL_UPD_EDCA_PARAMS_REQ = 36,
138 WCN36XX_HAL_UPD_EDCA_PARAMS_RSP = 37,
139 WCN36XX_HAL_ADD_BA_REQ = 38,
140 WCN36XX_HAL_ADD_BA_RSP = 39,
141 WCN36XX_HAL_DEL_BA_REQ = 40,
142 WCN36XX_HAL_DEL_BA_RSP = 41,
143
144 WCN36XX_HAL_CH_SWITCH_REQ = 42,
145 WCN36XX_HAL_CH_SWITCH_RSP = 43,
146 WCN36XX_HAL_SET_LINK_ST_REQ = 44,
147 WCN36XX_HAL_SET_LINK_ST_RSP = 45,
148 WCN36XX_HAL_GET_STATS_REQ = 46,
149 WCN36XX_HAL_GET_STATS_RSP = 47,
150 WCN36XX_HAL_UPDATE_CFG_REQ = 48,
151 WCN36XX_HAL_UPDATE_CFG_RSP = 49,
152
153 WCN36XX_HAL_MISSED_BEACON_IND = 50,
154 WCN36XX_HAL_UNKNOWN_ADDR2_FRAME_RX_IND = 51,
155 WCN36XX_HAL_MIC_FAILURE_IND = 52,
156 WCN36XX_HAL_FATAL_ERROR_IND = 53,
157 WCN36XX_HAL_SET_KEYDONE_MSG = 54,
158
159 /* NV Interface */
160 WCN36XX_HAL_DOWNLOAD_NV_REQ = 55,
161 WCN36XX_HAL_DOWNLOAD_NV_RSP = 56,
162
163 WCN36XX_HAL_ADD_BA_SESSION_REQ = 57,
164 WCN36XX_HAL_ADD_BA_SESSION_RSP = 58,
165 WCN36XX_HAL_TRIGGER_BA_REQ = 59,
166 WCN36XX_HAL_TRIGGER_BA_RSP = 60,
167 WCN36XX_HAL_UPDATE_BEACON_REQ = 61,
168 WCN36XX_HAL_UPDATE_BEACON_RSP = 62,
169 WCN36XX_HAL_SEND_BEACON_REQ = 63,
170 WCN36XX_HAL_SEND_BEACON_RSP = 64,
171
172 WCN36XX_HAL_SET_BCASTKEY_REQ = 65,
173 WCN36XX_HAL_SET_BCASTKEY_RSP = 66,
174 WCN36XX_HAL_DELETE_STA_CONTEXT_IND = 67,
175 WCN36XX_HAL_UPDATE_PROBE_RSP_TEMPLATE_REQ = 68,
176 WCN36XX_HAL_UPDATE_PROBE_RSP_TEMPLATE_RSP = 69,
177
178 /* PTT interface support */
179 WCN36XX_HAL_PROCESS_PTT_REQ = 70,
180 WCN36XX_HAL_PROCESS_PTT_RSP = 71,
181
182 /* BTAMP related events */
183 WCN36XX_HAL_SIGNAL_BTAMP_EVENT_REQ = 72,
184 WCN36XX_HAL_SIGNAL_BTAMP_EVENT_RSP = 73,
185 WCN36XX_HAL_TL_HAL_FLUSH_AC_REQ = 74,
186 WCN36XX_HAL_TL_HAL_FLUSH_AC_RSP = 75,
187
188 WCN36XX_HAL_ENTER_IMPS_REQ = 76,
189 WCN36XX_HAL_EXIT_IMPS_REQ = 77,
190 WCN36XX_HAL_ENTER_BMPS_REQ = 78,
191 WCN36XX_HAL_EXIT_BMPS_REQ = 79,
192 WCN36XX_HAL_ENTER_UAPSD_REQ = 80,
193 WCN36XX_HAL_EXIT_UAPSD_REQ = 81,
194 WCN36XX_HAL_UPDATE_UAPSD_PARAM_REQ = 82,
195 WCN36XX_HAL_CONFIGURE_RXP_FILTER_REQ = 83,
196 WCN36XX_HAL_ADD_BCN_FILTER_REQ = 84,
197 WCN36XX_HAL_REM_BCN_FILTER_REQ = 85,
198 WCN36XX_HAL_ADD_WOWL_BCAST_PTRN = 86,
199 WCN36XX_HAL_DEL_WOWL_BCAST_PTRN = 87,
200 WCN36XX_HAL_ENTER_WOWL_REQ = 88,
201 WCN36XX_HAL_EXIT_WOWL_REQ = 89,
202 WCN36XX_HAL_HOST_OFFLOAD_REQ = 90,
203 WCN36XX_HAL_SET_RSSI_THRESH_REQ = 91,
204 WCN36XX_HAL_GET_RSSI_REQ = 92,
205 WCN36XX_HAL_SET_UAPSD_AC_PARAMS_REQ = 93,
206 WCN36XX_HAL_CONFIGURE_APPS_CPU_WAKEUP_STATE_REQ = 94,
207
208 WCN36XX_HAL_ENTER_IMPS_RSP = 95,
209 WCN36XX_HAL_EXIT_IMPS_RSP = 96,
210 WCN36XX_HAL_ENTER_BMPS_RSP = 97,
211 WCN36XX_HAL_EXIT_BMPS_RSP = 98,
212 WCN36XX_HAL_ENTER_UAPSD_RSP = 99,
213 WCN36XX_HAL_EXIT_UAPSD_RSP = 100,
214 WCN36XX_HAL_SET_UAPSD_AC_PARAMS_RSP = 101,
215 WCN36XX_HAL_UPDATE_UAPSD_PARAM_RSP = 102,
216 WCN36XX_HAL_CONFIGURE_RXP_FILTER_RSP = 103,
217 WCN36XX_HAL_ADD_BCN_FILTER_RSP = 104,
218 WCN36XX_HAL_REM_BCN_FILTER_RSP = 105,
219 WCN36XX_HAL_SET_RSSI_THRESH_RSP = 106,
220 WCN36XX_HAL_HOST_OFFLOAD_RSP = 107,
221 WCN36XX_HAL_ADD_WOWL_BCAST_PTRN_RSP = 108,
222 WCN36XX_HAL_DEL_WOWL_BCAST_PTRN_RSP = 109,
223 WCN36XX_HAL_ENTER_WOWL_RSP = 110,
224 WCN36XX_HAL_EXIT_WOWL_RSP = 111,
225 WCN36XX_HAL_RSSI_NOTIFICATION_IND = 112,
226 WCN36XX_HAL_GET_RSSI_RSP = 113,
227 WCN36XX_HAL_CONFIGURE_APPS_CPU_WAKEUP_STATE_RSP = 114,
228
229 /* 11k related events */
230 WCN36XX_HAL_SET_MAX_TX_POWER_REQ = 115,
231 WCN36XX_HAL_SET_MAX_TX_POWER_RSP = 116,
232
233 /* 11R related msgs */
234 WCN36XX_HAL_AGGR_ADD_TS_REQ = 117,
235 WCN36XX_HAL_AGGR_ADD_TS_RSP = 118,
236
237 /* P2P WLAN_FEATURE_P2P */
238 WCN36XX_HAL_SET_P2P_GONOA_REQ = 119,
239 WCN36XX_HAL_SET_P2P_GONOA_RSP = 120,
240
241 /* WLAN Dump commands */
242 WCN36XX_HAL_DUMP_COMMAND_REQ = 121,
243 WCN36XX_HAL_DUMP_COMMAND_RSP = 122,
244
245 /* OEM_DATA FEATURE SUPPORT */
246 WCN36XX_HAL_START_OEM_DATA_REQ = 123,
247 WCN36XX_HAL_START_OEM_DATA_RSP = 124,
248
249 /* ADD SELF STA REQ and RSP */
250 WCN36XX_HAL_ADD_STA_SELF_REQ = 125,
251 WCN36XX_HAL_ADD_STA_SELF_RSP = 126,
252
253 /* DEL SELF STA SUPPORT */
254 WCN36XX_HAL_DEL_STA_SELF_REQ = 127,
255 WCN36XX_HAL_DEL_STA_SELF_RSP = 128,
256
257 /* Coex Indication */
258 WCN36XX_HAL_COEX_IND = 129,
259
260 /* Tx Complete Indication */
261 WCN36XX_HAL_OTA_TX_COMPL_IND = 130,
262
263 /* Host Suspend/resume messages */
264 WCN36XX_HAL_HOST_SUSPEND_IND = 131,
265 WCN36XX_HAL_HOST_RESUME_REQ = 132,
266 WCN36XX_HAL_HOST_RESUME_RSP = 133,
267
268 WCN36XX_HAL_SET_TX_POWER_REQ = 134,
269 WCN36XX_HAL_SET_TX_POWER_RSP = 135,
270 WCN36XX_HAL_GET_TX_POWER_REQ = 136,
271 WCN36XX_HAL_GET_TX_POWER_RSP = 137,
272
273 WCN36XX_HAL_P2P_NOA_ATTR_IND = 138,
274
275 WCN36XX_HAL_ENABLE_RADAR_DETECT_REQ = 139,
276 WCN36XX_HAL_ENABLE_RADAR_DETECT_RSP = 140,
277 WCN36XX_HAL_GET_TPC_REPORT_REQ = 141,
278 WCN36XX_HAL_GET_TPC_REPORT_RSP = 142,
279 WCN36XX_HAL_RADAR_DETECT_IND = 143,
280 WCN36XX_HAL_RADAR_DETECT_INTR_IND = 144,
281 WCN36XX_HAL_KEEP_ALIVE_REQ = 145,
282 WCN36XX_HAL_KEEP_ALIVE_RSP = 146,
283
284 /* PNO messages */
285 WCN36XX_HAL_SET_PREF_NETWORK_REQ = 147,
286 WCN36XX_HAL_SET_PREF_NETWORK_RSP = 148,
287 WCN36XX_HAL_SET_RSSI_FILTER_REQ = 149,
288 WCN36XX_HAL_SET_RSSI_FILTER_RSP = 150,
289 WCN36XX_HAL_UPDATE_SCAN_PARAM_REQ = 151,
290 WCN36XX_HAL_UPDATE_SCAN_PARAM_RSP = 152,
291 WCN36XX_HAL_PREF_NETW_FOUND_IND = 153,
292
293 WCN36XX_HAL_SET_TX_PER_TRACKING_REQ = 154,
294 WCN36XX_HAL_SET_TX_PER_TRACKING_RSP = 155,
295 WCN36XX_HAL_TX_PER_HIT_IND = 156,
296
297 WCN36XX_HAL_8023_MULTICAST_LIST_REQ = 157,
298 WCN36XX_HAL_8023_MULTICAST_LIST_RSP = 158,
299
300 WCN36XX_HAL_SET_PACKET_FILTER_REQ = 159,
301 WCN36XX_HAL_SET_PACKET_FILTER_RSP = 160,
302 WCN36XX_HAL_PACKET_FILTER_MATCH_COUNT_REQ = 161,
303 WCN36XX_HAL_PACKET_FILTER_MATCH_COUNT_RSP = 162,
304 WCN36XX_HAL_CLEAR_PACKET_FILTER_REQ = 163,
305 WCN36XX_HAL_CLEAR_PACKET_FILTER_RSP = 164,
306
307 /*
308 * This is temp fix. Should be removed once Host and Riva code is
309 * in sync.
310 */
311 WCN36XX_HAL_INIT_SCAN_CON_REQ = 165,
312
313 WCN36XX_HAL_SET_POWER_PARAMS_REQ = 166,
314 WCN36XX_HAL_SET_POWER_PARAMS_RSP = 167,
315
316 WCN36XX_HAL_TSM_STATS_REQ = 168,
317 WCN36XX_HAL_TSM_STATS_RSP = 169,
318
319 /* wake reason indication (WOW) */
320 WCN36XX_HAL_WAKE_REASON_IND = 170,
321
322 /* GTK offload support */
323 WCN36XX_HAL_GTK_OFFLOAD_REQ = 171,
324 WCN36XX_HAL_GTK_OFFLOAD_RSP = 172,
325 WCN36XX_HAL_GTK_OFFLOAD_GETINFO_REQ = 173,
326 WCN36XX_HAL_GTK_OFFLOAD_GETINFO_RSP = 174,
327
328 WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_REQ = 175,
329 WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_RSP = 176,
330 WCN36XX_HAL_EXCLUDE_UNENCRYPTED_IND = 177,
331
332 WCN36XX_HAL_SET_THERMAL_MITIGATION_REQ = 178,
333 WCN36XX_HAL_SET_THERMAL_MITIGATION_RSP = 179,
334
335 WCN36XX_HAL_UPDATE_VHT_OP_MODE_REQ = 182,
336 WCN36XX_HAL_UPDATE_VHT_OP_MODE_RSP = 183,
337
338 WCN36XX_HAL_P2P_NOA_START_IND = 184,
339
340 WCN36XX_HAL_GET_ROAM_RSSI_REQ = 185,
341 WCN36XX_HAL_GET_ROAM_RSSI_RSP = 186,
342
343 WCN36XX_HAL_CLASS_B_STATS_IND = 187,
344 WCN36XX_HAL_DEL_BA_IND = 188,
345 WCN36XX_HAL_DHCP_START_IND = 189,
346 WCN36XX_HAL_DHCP_STOP_IND = 190,
347
348 WCN36XX_HAL_MSG_MAX = WCN36XX_HAL_MSG_TYPE_MAX_ENUM_SIZE
349};
350
351/* Enumeration for Version */
352enum wcn36xx_hal_host_msg_version {
353 WCN36XX_HAL_MSG_VERSION0 = 0,
354 WCN36XX_HAL_MSG_VERSION1 = 1,
355 /* define as 2 bytes data */
356 WCN36XX_HAL_MSG_WCNSS_CTRL_VERSION = 0x7FFF,
357 WCN36XX_HAL_MSG_VERSION_MAX_FIELD = WCN36XX_HAL_MSG_WCNSS_CTRL_VERSION
358};
359
360enum driver_type {
361 DRIVER_TYPE_PRODUCTION = 0,
362 DRIVER_TYPE_MFG = 1,
363 DRIVER_TYPE_DVT = 2,
364 DRIVER_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
365};
366
367enum wcn36xx_hal_stop_type {
368 HAL_STOP_TYPE_SYS_RESET,
369 HAL_STOP_TYPE_SYS_DEEP_SLEEP,
370 HAL_STOP_TYPE_RF_KILL,
371 HAL_STOP_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
372};
373
374enum wcn36xx_hal_sys_mode {
375 HAL_SYS_MODE_NORMAL,
376 HAL_SYS_MODE_LEARN,
377 HAL_SYS_MODE_SCAN,
378 HAL_SYS_MODE_PROMISC,
379 HAL_SYS_MODE_SUSPEND_LINK,
380 HAL_SYS_MODE_ROAM_SCAN,
381 HAL_SYS_MODE_ROAM_SUSPEND_LINK,
382 HAL_SYS_MODE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
383};
384
385enum phy_chan_bond_state {
386 /* 20MHz IF bandwidth centered on IF carrier */
387 PHY_SINGLE_CHANNEL_CENTERED = 0,
388
389 /* 40MHz IF bandwidth with lower 20MHz supporting the primary channel */
390 PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1,
391
392 /* 40MHz IF bandwidth centered on IF carrier */
393 PHY_DOUBLE_CHANNEL_CENTERED = 2,
394
395 /* 40MHz IF bandwidth with higher 20MHz supporting the primary ch */
396 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3,
397
398 /* 20/40MHZ offset LOW 40/80MHZ offset CENTERED */
399 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED = 4,
400
401 /* 20/40MHZ offset CENTERED 40/80MHZ offset CENTERED */
402 PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED = 5,
403
404 /* 20/40MHZ offset HIGH 40/80MHZ offset CENTERED */
405 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED = 6,
406
407 /* 20/40MHZ offset LOW 40/80MHZ offset LOW */
408 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW = 7,
409
410 /* 20/40MHZ offset HIGH 40/80MHZ offset LOW */
411 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW = 8,
412
413 /* 20/40MHZ offset LOW 40/80MHZ offset HIGH */
414 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH = 9,
415
416 /* 20/40MHZ offset-HIGH 40/80MHZ offset HIGH */
417 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH = 10,
418
419 PHY_CHANNEL_BONDING_STATE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
420};
421
422/* Spatial Multiplexing(SM) Power Save mode */
423enum wcn36xx_hal_ht_mimo_state {
424 /* Static SM Power Save mode */
425 WCN36XX_HAL_HT_MIMO_PS_STATIC = 0,
426
427 /* Dynamic SM Power Save mode */
428 WCN36XX_HAL_HT_MIMO_PS_DYNAMIC = 1,
429
430 /* reserved */
431 WCN36XX_HAL_HT_MIMO_PS_NA = 2,
432
433 /* SM Power Save disabled */
434 WCN36XX_HAL_HT_MIMO_PS_NO_LIMIT = 3,
435
436 WCN36XX_HAL_HT_MIMO_PS_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
437};
438
439/* each station added has a rate mode which specifies the sta attributes */
440enum sta_rate_mode {
441 STA_TAURUS = 0,
442 STA_TITAN,
443 STA_POLARIS,
444 STA_11b,
445 STA_11bg,
446 STA_11a,
447 STA_11n,
448 STA_11ac,
449 STA_INVALID_RATE_MODE = WCN36XX_HAL_MAX_ENUM_SIZE
450};
451
452/* 1,2,5.5,11 */
453#define WCN36XX_HAL_NUM_DSSS_RATES 4
454
455/* 6,9,12,18,24,36,48,54 */
456#define WCN36XX_HAL_NUM_OFDM_RATES 8
457
458/* 72,96,108 */
459#define WCN36XX_HAL_NUM_POLARIS_RATES 3
460
461#define WCN36XX_HAL_MAC_MAX_SUPPORTED_MCS_SET 16
462
463enum wcn36xx_hal_bss_type {
464 WCN36XX_HAL_INFRASTRUCTURE_MODE,
465
466 /* Added for softAP support */
467 WCN36XX_HAL_INFRA_AP_MODE,
468
469 WCN36XX_HAL_IBSS_MODE,
470
471 /* Added for BT-AMP support */
472 WCN36XX_HAL_BTAMP_STA_MODE,
473
474 /* Added for BT-AMP support */
475 WCN36XX_HAL_BTAMP_AP_MODE,
476
477 WCN36XX_HAL_AUTO_MODE,
478
479 WCN36XX_HAL_DONOT_USE_BSS_TYPE = WCN36XX_HAL_MAX_ENUM_SIZE
480};
481
482enum wcn36xx_hal_nw_type {
483 WCN36XX_HAL_11A_NW_TYPE,
484 WCN36XX_HAL_11B_NW_TYPE,
485 WCN36XX_HAL_11G_NW_TYPE,
486 WCN36XX_HAL_11N_NW_TYPE,
487 WCN36XX_HAL_DONOT_USE_NW_TYPE = WCN36XX_HAL_MAX_ENUM_SIZE
488};
489
490#define WCN36XX_HAL_MAC_RATESET_EID_MAX 12
491
492enum wcn36xx_hal_ht_operating_mode {
493 /* No Protection */
494 WCN36XX_HAL_HT_OP_MODE_PURE,
495
496 /* Overlap Legacy device present, protection is optional */
497 WCN36XX_HAL_HT_OP_MODE_OVERLAP_LEGACY,
498
499 /* No legacy device, but 20 MHz HT present */
500 WCN36XX_HAL_HT_OP_MODE_NO_LEGACY_20MHZ_HT,
501
502 /* Protection is required */
503 WCN36XX_HAL_HT_OP_MODE_MIXED,
504
505 WCN36XX_HAL_HT_OP_MODE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
506};
507
508/* Encryption type enum used with peer */
509enum ani_ed_type {
510 WCN36XX_HAL_ED_NONE,
511 WCN36XX_HAL_ED_WEP40,
512 WCN36XX_HAL_ED_WEP104,
513 WCN36XX_HAL_ED_TKIP,
514 WCN36XX_HAL_ED_CCMP,
515 WCN36XX_HAL_ED_WPI,
516 WCN36XX_HAL_ED_AES_128_CMAC,
517 WCN36XX_HAL_ED_NOT_IMPLEMENTED = WCN36XX_HAL_MAX_ENUM_SIZE
518};
519
520#define WLAN_MAX_KEY_RSC_LEN 16
521#define WLAN_WAPI_KEY_RSC_LEN 16
522
523/* MAX key length when ULA is used */
524#define WCN36XX_HAL_MAC_MAX_KEY_LENGTH 32
525#define WCN36XX_HAL_MAC_MAX_NUM_OF_DEFAULT_KEYS 4
526
527/*
528 * Enum to specify whether key is used for TX only, RX only or both.
529 */
530enum ani_key_direction {
531 WCN36XX_HAL_TX_ONLY,
532 WCN36XX_HAL_RX_ONLY,
533 WCN36XX_HAL_TX_RX,
534 WCN36XX_HAL_TX_DEFAULT,
535 WCN36XX_HAL_DONOT_USE_KEY_DIRECTION = WCN36XX_HAL_MAX_ENUM_SIZE
536};
537
538enum ani_wep_type {
539 WCN36XX_HAL_WEP_STATIC,
540 WCN36XX_HAL_WEP_DYNAMIC,
541 WCN36XX_HAL_WEP_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
542};
543
544enum wcn36xx_hal_link_state {
545
546 WCN36XX_HAL_LINK_IDLE_STATE = 0,
547 WCN36XX_HAL_LINK_PREASSOC_STATE = 1,
548 WCN36XX_HAL_LINK_POSTASSOC_STATE = 2,
549 WCN36XX_HAL_LINK_AP_STATE = 3,
550 WCN36XX_HAL_LINK_IBSS_STATE = 4,
551
552 /* BT-AMP Case */
553 WCN36XX_HAL_LINK_BTAMP_PREASSOC_STATE = 5,
554 WCN36XX_HAL_LINK_BTAMP_POSTASSOC_STATE = 6,
555 WCN36XX_HAL_LINK_BTAMP_AP_STATE = 7,
556 WCN36XX_HAL_LINK_BTAMP_STA_STATE = 8,
557
558 /* Reserved for HAL Internal Use */
559 WCN36XX_HAL_LINK_LEARN_STATE = 9,
560 WCN36XX_HAL_LINK_SCAN_STATE = 10,
561 WCN36XX_HAL_LINK_FINISH_SCAN_STATE = 11,
562 WCN36XX_HAL_LINK_INIT_CAL_STATE = 12,
563 WCN36XX_HAL_LINK_FINISH_CAL_STATE = 13,
564 WCN36XX_HAL_LINK_LISTEN_STATE = 14,
565
566 WCN36XX_HAL_LINK_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
567};
568
569enum wcn36xx_hal_stats_mask {
570 HAL_SUMMARY_STATS_INFO = 0x00000001,
571 HAL_GLOBAL_CLASS_A_STATS_INFO = 0x00000002,
572 HAL_GLOBAL_CLASS_B_STATS_INFO = 0x00000004,
573 HAL_GLOBAL_CLASS_C_STATS_INFO = 0x00000008,
574 HAL_GLOBAL_CLASS_D_STATS_INFO = 0x00000010,
575 HAL_PER_STA_STATS_INFO = 0x00000020
576};
577
578/* BT-AMP events type */
579enum bt_amp_event_type {
580 BTAMP_EVENT_CONNECTION_START,
581 BTAMP_EVENT_CONNECTION_STOP,
582 BTAMP_EVENT_CONNECTION_TERMINATED,
583
584 /* This and beyond are invalid values */
585 BTAMP_EVENT_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE,
586};
587
588/* PE Statistics */
589enum pe_stats_mask {
590 PE_SUMMARY_STATS_INFO = 0x00000001,
591 PE_GLOBAL_CLASS_A_STATS_INFO = 0x00000002,
592 PE_GLOBAL_CLASS_B_STATS_INFO = 0x00000004,
593 PE_GLOBAL_CLASS_C_STATS_INFO = 0x00000008,
594 PE_GLOBAL_CLASS_D_STATS_INFO = 0x00000010,
595 PE_PER_STA_STATS_INFO = 0x00000020,
596
597 /* This and beyond are invalid values */
598 PE_STATS_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
599};
600
601/*
602 * Configuration Parameter IDs
603 */
604#define WCN36XX_HAL_CFG_STA_ID 0
605#define WCN36XX_HAL_CFG_CURRENT_TX_ANTENNA 1
606#define WCN36XX_HAL_CFG_CURRENT_RX_ANTENNA 2
607#define WCN36XX_HAL_CFG_LOW_GAIN_OVERRIDE 3
608#define WCN36XX_HAL_CFG_POWER_STATE_PER_CHAIN 4
609#define WCN36XX_HAL_CFG_CAL_PERIOD 5
610#define WCN36XX_HAL_CFG_CAL_CONTROL 6
611#define WCN36XX_HAL_CFG_PROXIMITY 7
612#define WCN36XX_HAL_CFG_NETWORK_DENSITY 8
613#define WCN36XX_HAL_CFG_MAX_MEDIUM_TIME 9
614#define WCN36XX_HAL_CFG_MAX_MPDUS_IN_AMPDU 10
615#define WCN36XX_HAL_CFG_RTS_THRESHOLD 11
616#define WCN36XX_HAL_CFG_SHORT_RETRY_LIMIT 12
617#define WCN36XX_HAL_CFG_LONG_RETRY_LIMIT 13
618#define WCN36XX_HAL_CFG_FRAGMENTATION_THRESHOLD 14
619#define WCN36XX_HAL_CFG_DYNAMIC_THRESHOLD_ZERO 15
620#define WCN36XX_HAL_CFG_DYNAMIC_THRESHOLD_ONE 16
621#define WCN36XX_HAL_CFG_DYNAMIC_THRESHOLD_TWO 17
622#define WCN36XX_HAL_CFG_FIXED_RATE 18
623#define WCN36XX_HAL_CFG_RETRYRATE_POLICY 19
624#define WCN36XX_HAL_CFG_RETRYRATE_SECONDARY 20
625#define WCN36XX_HAL_CFG_RETRYRATE_TERTIARY 21
626#define WCN36XX_HAL_CFG_FORCE_POLICY_PROTECTION 22
627#define WCN36XX_HAL_CFG_FIXED_RATE_MULTICAST_24GHZ 23
628#define WCN36XX_HAL_CFG_FIXED_RATE_MULTICAST_5GHZ 24
629#define WCN36XX_HAL_CFG_DEFAULT_RATE_INDEX_24GHZ 25
630#define WCN36XX_HAL_CFG_DEFAULT_RATE_INDEX_5GHZ 26
631#define WCN36XX_HAL_CFG_MAX_BA_SESSIONS 27
632#define WCN36XX_HAL_CFG_PS_DATA_INACTIVITY_TIMEOUT 28
633#define WCN36XX_HAL_CFG_PS_ENABLE_BCN_FILTER 29
634#define WCN36XX_HAL_CFG_PS_ENABLE_RSSI_MONITOR 30
635#define WCN36XX_HAL_CFG_NUM_BEACON_PER_RSSI_AVERAGE 31
636#define WCN36XX_HAL_CFG_STATS_PERIOD 32
637#define WCN36XX_HAL_CFG_CFP_MAX_DURATION 33
638#define WCN36XX_HAL_CFG_FRAME_TRANS_ENABLED 34
639#define WCN36XX_HAL_CFG_DTIM_PERIOD 35
640#define WCN36XX_HAL_CFG_EDCA_WMM_ACBK 36
641#define WCN36XX_HAL_CFG_EDCA_WMM_ACBE 37
642#define WCN36XX_HAL_CFG_EDCA_WMM_ACVO 38
643#define WCN36XX_HAL_CFG_EDCA_WMM_ACVI 39
644#define WCN36XX_HAL_CFG_BA_THRESHOLD_HIGH 40
645#define WCN36XX_HAL_CFG_MAX_BA_BUFFERS 41
646#define WCN36XX_HAL_CFG_RPE_POLLING_THRESHOLD 42
647#define WCN36XX_HAL_CFG_RPE_AGING_THRESHOLD_FOR_AC0_REG 43
648#define WCN36XX_HAL_CFG_RPE_AGING_THRESHOLD_FOR_AC1_REG 44
649#define WCN36XX_HAL_CFG_RPE_AGING_THRESHOLD_FOR_AC2_REG 45
650#define WCN36XX_HAL_CFG_RPE_AGING_THRESHOLD_FOR_AC3_REG 46
651#define WCN36XX_HAL_CFG_NO_OF_ONCHIP_REORDER_SESSIONS 47
652#define WCN36XX_HAL_CFG_PS_LISTEN_INTERVAL 48
653#define WCN36XX_HAL_CFG_PS_HEART_BEAT_THRESHOLD 49
654#define WCN36XX_HAL_CFG_PS_NTH_BEACON_FILTER 50
655#define WCN36XX_HAL_CFG_PS_MAX_PS_POLL 51
656#define WCN36XX_HAL_CFG_PS_MIN_RSSI_THRESHOLD 52
657#define WCN36XX_HAL_CFG_PS_RSSI_FILTER_PERIOD 53
658#define WCN36XX_HAL_CFG_PS_BROADCAST_FRAME_FILTER_ENABLE 54
659#define WCN36XX_HAL_CFG_PS_IGNORE_DTIM 55
660#define WCN36XX_HAL_CFG_PS_ENABLE_BCN_EARLY_TERM 56
661#define WCN36XX_HAL_CFG_DYNAMIC_PS_POLL_VALUE 57
662#define WCN36XX_HAL_CFG_PS_NULLDATA_AP_RESP_TIMEOUT 58
663#define WCN36XX_HAL_CFG_TELE_BCN_WAKEUP_EN 59
664#define WCN36XX_HAL_CFG_TELE_BCN_TRANS_LI 60
665#define WCN36XX_HAL_CFG_TELE_BCN_TRANS_LI_IDLE_BCNS 61
666#define WCN36XX_HAL_CFG_TELE_BCN_MAX_LI 62
667#define WCN36XX_HAL_CFG_TELE_BCN_MAX_LI_IDLE_BCNS 63
668#define WCN36XX_HAL_CFG_TX_PWR_CTRL_ENABLE 64
669#define WCN36XX_HAL_CFG_VALID_RADAR_CHANNEL_LIST 65
670#define WCN36XX_HAL_CFG_TX_POWER_24_20 66
671#define WCN36XX_HAL_CFG_TX_POWER_24_40 67
672#define WCN36XX_HAL_CFG_TX_POWER_50_20 68
673#define WCN36XX_HAL_CFG_TX_POWER_50_40 69
674#define WCN36XX_HAL_CFG_MCAST_BCAST_FILTER_SETTING 70
675#define WCN36XX_HAL_CFG_BCN_EARLY_TERM_WAKEUP_INTERVAL 71
676#define WCN36XX_HAL_CFG_MAX_TX_POWER_2_4 72
677#define WCN36XX_HAL_CFG_MAX_TX_POWER_5 73
678#define WCN36XX_HAL_CFG_INFRA_STA_KEEP_ALIVE_PERIOD 74
679#define WCN36XX_HAL_CFG_ENABLE_CLOSE_LOOP 75
680#define WCN36XX_HAL_CFG_BTC_EXECUTION_MODE 76
681#define WCN36XX_HAL_CFG_BTC_DHCP_BT_SLOTS_TO_BLOCK 77
682#define WCN36XX_HAL_CFG_BTC_A2DP_DHCP_BT_SUB_INTERVALS 78
683#define WCN36XX_HAL_CFG_PS_TX_INACTIVITY_TIMEOUT 79
684#define WCN36XX_HAL_CFG_WCNSS_API_VERSION 80
685#define WCN36XX_HAL_CFG_AP_KEEPALIVE_TIMEOUT 81
686#define WCN36XX_HAL_CFG_GO_KEEPALIVE_TIMEOUT 82
687#define WCN36XX_HAL_CFG_ENABLE_MC_ADDR_LIST 83
688#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_INQ_BT 84
689#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_PAGE_BT 85
690#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_CONN_BT 86
691#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_LE_BT 87
692#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_INQ_WLAN 88
693#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_PAGE_WLAN 89
694#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_CONN_WLAN 90
695#define WCN36XX_HAL_CFG_BTC_STATIC_LEN_LE_WLAN 91
696#define WCN36XX_HAL_CFG_BTC_DYN_MAX_LEN_BT 92
697#define WCN36XX_HAL_CFG_BTC_DYN_MAX_LEN_WLAN 93
698#define WCN36XX_HAL_CFG_BTC_MAX_SCO_BLOCK_PERC 94
699#define WCN36XX_HAL_CFG_BTC_DHCP_PROT_ON_A2DP 95
700#define WCN36XX_HAL_CFG_BTC_DHCP_PROT_ON_SCO 96
701#define WCN36XX_HAL_CFG_ENABLE_UNICAST_FILTER 97
702#define WCN36XX_HAL_CFG_MAX_ASSOC_LIMIT 98
703#define WCN36XX_HAL_CFG_ENABLE_LPWR_IMG_TRANSITION 99
704#define WCN36XX_HAL_CFG_ENABLE_MCC_ADAPTIVE_SCHEDULER 100
705#define WCN36XX_HAL_CFG_ENABLE_DETECT_PS_SUPPORT 101
706#define WCN36XX_HAL_CFG_AP_LINK_MONITOR_TIMEOUT 102
707#define WCN36XX_HAL_CFG_BTC_DWELL_TIME_MULTIPLIER 103
708#define WCN36XX_HAL_CFG_ENABLE_TDLS_OXYGEN_MODE 104
709#define WCN36XX_HAL_CFG_MAX_PARAMS 105
710
711/* Message definitons - All the messages below need to be packed */
712
713/* Definition for HAL API Version. */
714struct wcnss_wlan_version {
715 u8 revision;
716 u8 version;
717 u8 minor;
718 u8 major;
719} __packed;
720
721/* Definition for Encryption Keys */
722struct wcn36xx_hal_keys {
723 u8 id;
724
725 /* 0 for multicast */
726 u8 unicast;
727
728 enum ani_key_direction direction;
729
730 /* Usage is unknown */
731 u8 rsc[WLAN_MAX_KEY_RSC_LEN];
732
733 /* =1 for authenticator,=0 for supplicant */
734 u8 pae_role;
735
736 u16 length;
737 u8 key[WCN36XX_HAL_MAC_MAX_KEY_LENGTH];
738} __packed;
739
740/*
741 * set_sta_key_params Moving here since it is shared by
742 * configbss/setstakey msgs
743 */
744struct wcn36xx_hal_set_sta_key_params {
745 /* STA Index */
746 u16 sta_index;
747
748 /* Encryption Type used with peer */
749 enum ani_ed_type enc_type;
750
751 /* STATIC/DYNAMIC - valid only for WEP */
752 enum ani_wep_type wep_type;
753
754 /* Default WEP key, valid only for static WEP, must between 0 and 3. */
755 u8 def_wep_idx;
756
757 /* valid only for non-static WEP encyrptions */
758 struct wcn36xx_hal_keys key[WCN36XX_HAL_MAC_MAX_NUM_OF_DEFAULT_KEYS];
759
760 /*
761 * Control for Replay Count, 1= Single TID based replay count on Tx
762 * 0 = Per TID based replay count on TX
763 */
764 u8 single_tid_rc;
765
766} __packed;
767
768/* 4-byte control message header used by HAL*/
769struct wcn36xx_hal_msg_header {
770 enum wcn36xx_hal_host_msg_type msg_type:16;
771 enum wcn36xx_hal_host_msg_version msg_version:16;
772 u32 len;
773} __packed;
774
775/* Config format required by HAL for each CFG item*/
776struct wcn36xx_hal_cfg {
777 /* Cfg Id. The Id required by HAL is exported by HAL
778 * in shared header file between UMAC and HAL.*/
779 u16 id;
780
781 /* Length of the Cfg. This parameter is used to go to next cfg
782 * in the TLV format.*/
783 u16 len;
784
785 /* Padding bytes for unaligned address's */
786 u16 pad_bytes;
787
788 /* Reserve bytes for making cfgVal to align address */
789 u16 reserve;
790
791 /* Following the uCfgLen field there should be a 'uCfgLen' bytes
792 * containing the uCfgValue ; u8 uCfgValue[uCfgLen] */
793} __packed;
794
795struct wcn36xx_hal_mac_start_parameters {
796 /* Drive Type - Production or FTM etc */
797 enum driver_type type;
798
799 /* Length of the config buffer */
800 u32 len;
801
802 /* Following this there is a TLV formatted buffer of length
803 * "len" bytes containing all config values.
804 * The TLV is expected to be formatted like this:
805 * 0 15 31 31+CFG_LEN-1 length-1
806 * | CFG_ID | CFG_LEN | CFG_BODY | CFG_ID |......|
807 */
808} __packed;
809
810struct wcn36xx_hal_mac_start_req_msg {
811 /* config buffer must start in TLV format just here */
812 struct wcn36xx_hal_msg_header header;
813 struct wcn36xx_hal_mac_start_parameters params;
814} __packed;
815
816struct wcn36xx_hal_mac_start_rsp_params {
817 /* success or failure */
818 u16 status;
819
820 /* Max number of STA supported by the device */
821 u8 stations;
822
823 /* Max number of BSS supported by the device */
824 u8 bssids;
825
826 /* API Version */
827 struct wcnss_wlan_version version;
828
829 /* CRM build information */
830 u8 crm_version[WCN36XX_HAL_VERSION_LENGTH];
831
832 /* hardware/chipset/misc version information */
833 u8 wlan_version[WCN36XX_HAL_VERSION_LENGTH];
834
835} __packed;
836
837struct wcn36xx_hal_mac_start_rsp_msg {
838 struct wcn36xx_hal_msg_header header;
839 struct wcn36xx_hal_mac_start_rsp_params start_rsp_params;
840} __packed;
841
842struct wcn36xx_hal_mac_stop_req_params {
843 /* The reason for which the device is being stopped */
844 enum wcn36xx_hal_stop_type reason;
845
846} __packed;
847
848struct wcn36xx_hal_mac_stop_req_msg {
849 struct wcn36xx_hal_msg_header header;
850 struct wcn36xx_hal_mac_stop_req_params stop_req_params;
851} __packed;
852
853struct wcn36xx_hal_mac_stop_rsp_msg {
854 struct wcn36xx_hal_msg_header header;
855
856 /* success or failure */
857 u32 status;
858} __packed;
859
860struct wcn36xx_hal_update_cfg_req_msg {
861 /*
862 * Note: The length specified in tHalUpdateCfgReqMsg messages should be
863 * header.msgLen = sizeof(tHalUpdateCfgReqMsg) + uConfigBufferLen
864 */
865 struct wcn36xx_hal_msg_header header;
866
867 /* Length of the config buffer. Allows UMAC to update multiple CFGs */
868 u32 len;
869
870 /*
871 * Following this there is a TLV formatted buffer of length
872 * "uConfigBufferLen" bytes containing all config values.
873 * The TLV is expected to be formatted like this:
874 * 0 15 31 31+CFG_LEN-1 length-1
875 * | CFG_ID | CFG_LEN | CFG_BODY | CFG_ID |......|
876 */
877
878} __packed;
879
880struct wcn36xx_hal_update_cfg_rsp_msg {
881 struct wcn36xx_hal_msg_header header;
882
883 /* success or failure */
884 u32 status;
885
886} __packed;
887
888/* Frame control field format (2 bytes) */
889struct wcn36xx_hal_mac_frame_ctl {
890
891#ifndef ANI_LITTLE_BIT_ENDIAN
892
893 u8 subType:4;
894 u8 type:2;
895 u8 protVer:2;
896
897 u8 order:1;
898 u8 wep:1;
899 u8 moreData:1;
900 u8 powerMgmt:1;
901 u8 retry:1;
902 u8 moreFrag:1;
903 u8 fromDS:1;
904 u8 toDS:1;
905
906#else
907
908 u8 protVer:2;
909 u8 type:2;
910 u8 subType:4;
911
912 u8 toDS:1;
913 u8 fromDS:1;
914 u8 moreFrag:1;
915 u8 retry:1;
916 u8 powerMgmt:1;
917 u8 moreData:1;
918 u8 wep:1;
919 u8 order:1;
920
921#endif
922
923};
924
925/* Sequence control field */
926struct wcn36xx_hal_mac_seq_ctl {
927 u8 fragNum:4;
928 u8 seqNumLo:4;
929 u8 seqNumHi:8;
930};
931
932/* Management header format */
933struct wcn36xx_hal_mac_mgmt_hdr {
934 struct wcn36xx_hal_mac_frame_ctl fc;
935 u8 durationLo;
936 u8 durationHi;
937 u8 da[6];
938 u8 sa[6];
939 u8 bssId[6];
940 struct wcn36xx_hal_mac_seq_ctl seqControl;
941};
942
943/* FIXME: pronto v1 apparently has 4 */
944#define WCN36XX_HAL_NUM_BSSID 2
945
946/* Scan Entry to hold active BSS idx's */
947struct wcn36xx_hal_scan_entry {
948 u8 bss_index[WCN36XX_HAL_NUM_BSSID];
949 u8 active_bss_count;
950};
951
952struct wcn36xx_hal_init_scan_req_msg {
953 struct wcn36xx_hal_msg_header header;
954
955 /* LEARN - AP Role
956 SCAN - STA Role */
957 enum wcn36xx_hal_sys_mode mode;
958
959 /* BSSID of the BSS */
960 u8 bssid[ETH_ALEN];
961
962 /* Whether BSS needs to be notified */
963 u8 notify;
964
965 /* Kind of frame to be used for notifying the BSS (Data Null, QoS
966 * Null, or CTS to Self). Must always be a valid frame type. */
967 u8 frame_type;
968
969 /* UMAC has the option of passing the MAC frame to be used for
970 * notifying the BSS. If non-zero, HAL will use the MAC frame
971 * buffer pointed to by macMgmtHdr. If zero, HAL will generate the
972 * appropriate MAC frame based on frameType. */
973 u8 frame_len;
974
975 /* Following the framelength there is a MAC frame buffer if
976 * frameLength is non-zero. */
977 struct wcn36xx_hal_mac_mgmt_hdr mac_mgmt_hdr;
978
979 /* Entry to hold number of active BSS idx's */
980 struct wcn36xx_hal_scan_entry scan_entry;
981};
982
983struct wcn36xx_hal_init_scan_con_req_msg {
984 struct wcn36xx_hal_msg_header header;
985
986 /* LEARN - AP Role
987 SCAN - STA Role */
988 enum wcn36xx_hal_sys_mode mode;
989
990 /* BSSID of the BSS */
991 u8 bssid[ETH_ALEN];
992
993 /* Whether BSS needs to be notified */
994 u8 notify;
995
996 /* Kind of frame to be used for notifying the BSS (Data Null, QoS
997 * Null, or CTS to Self). Must always be a valid frame type. */
998 u8 frame_type;
999
1000 /* UMAC has the option of passing the MAC frame to be used for
1001 * notifying the BSS. If non-zero, HAL will use the MAC frame
1002 * buffer pointed to by macMgmtHdr. If zero, HAL will generate the
1003 * appropriate MAC frame based on frameType. */
1004 u8 frame_length;
1005
1006 /* Following the framelength there is a MAC frame buffer if
1007 * frameLength is non-zero. */
1008 struct wcn36xx_hal_mac_mgmt_hdr mac_mgmt_hdr;
1009
1010 /* Entry to hold number of active BSS idx's */
1011 struct wcn36xx_hal_scan_entry scan_entry;
1012
1013 /* Single NoA usage in Scanning */
1014 u8 use_noa;
1015
1016 /* Indicates the scan duration (in ms) */
1017 u16 scan_duration;
1018
1019};
1020
1021struct wcn36xx_hal_init_scan_rsp_msg {
1022 struct wcn36xx_hal_msg_header header;
1023
1024 /* success or failure */
1025 u32 status;
1026
1027} __packed;
1028
1029struct wcn36xx_hal_start_scan_req_msg {
1030 struct wcn36xx_hal_msg_header header;
1031
1032 /* Indicates the channel to scan */
1033 u8 scan_channel;
1034} __packed;
1035
1036struct wcn36xx_hal_start_rsp_msg {
1037 struct wcn36xx_hal_msg_header header;
1038
1039 /* success or failure */
1040 u32 status;
1041
1042 u32 start_tsf[2];
1043 u8 tx_mgmt_power;
1044
1045} __packed;
1046
1047struct wcn36xx_hal_end_scan_req_msg {
1048 struct wcn36xx_hal_msg_header header;
1049
1050 /* Indicates the channel to stop scanning. Not used really. But
1051 * retained for symmetry with "start Scan" message. It can also
1052 * help in error check if needed. */
1053 u8 scan_channel;
1054} __packed;
1055
1056struct wcn36xx_hal_end_scan_rsp_msg {
1057 struct wcn36xx_hal_msg_header header;
1058
1059 /* success or failure */
1060 u32 status;
1061} __packed;
1062
1063struct wcn36xx_hal_finish_scan_req_msg {
1064 struct wcn36xx_hal_msg_header header;
1065
1066 /* Identifies the operational state of the AP/STA
1067 * LEARN - AP Role SCAN - STA Role */
1068 enum wcn36xx_hal_sys_mode mode;
1069
1070 /* Operating channel to tune to. */
1071 u8 oper_channel;
1072
1073 /* Channel Bonding state If 20/40 MHz is operational, this will
1074 * indicate the 40 MHz extension channel in combination with the
1075 * control channel */
1076 enum phy_chan_bond_state cb_state;
1077
1078 /* BSSID of the BSS */
1079 u8 bssid[ETH_ALEN];
1080
1081 /* Whether BSS needs to be notified */
1082 u8 notify;
1083
1084 /* Kind of frame to be used for notifying the BSS (Data Null, QoS
1085 * Null, or CTS to Self). Must always be a valid frame type. */
1086 u8 frame_type;
1087
1088 /* UMAC has the option of passing the MAC frame to be used for
1089 * notifying the BSS. If non-zero, HAL will use the MAC frame
1090 * buffer pointed to by macMgmtHdr. If zero, HAL will generate the
1091 * appropriate MAC frame based on frameType. */
1092 u8 frame_length;
1093
1094 /* Following the framelength there is a MAC frame buffer if
1095 * frameLength is non-zero. */
1096 struct wcn36xx_hal_mac_mgmt_hdr mac_mgmt_hdr;
1097
1098 /* Entry to hold number of active BSS idx's */
1099 struct wcn36xx_hal_scan_entry scan_entry;
1100
1101} __packed;
1102
1103struct wcn36xx_hal_finish_scan_rsp_msg {
1104 struct wcn36xx_hal_msg_header header;
1105
1106 /* success or failure */
1107 u32 status;
1108
1109} __packed;
1110
1111enum wcn36xx_hal_rate_index {
1112 HW_RATE_INDEX_1MBPS = 0x82,
1113 HW_RATE_INDEX_2MBPS = 0x84,
1114 HW_RATE_INDEX_5_5MBPS = 0x8B,
1115 HW_RATE_INDEX_6MBPS = 0x0C,
1116 HW_RATE_INDEX_9MBPS = 0x12,
1117 HW_RATE_INDEX_11MBPS = 0x96,
1118 HW_RATE_INDEX_12MBPS = 0x18,
1119 HW_RATE_INDEX_18MBPS = 0x24,
1120 HW_RATE_INDEX_24MBPS = 0x30,
1121 HW_RATE_INDEX_36MBPS = 0x48,
1122 HW_RATE_INDEX_48MBPS = 0x60,
1123 HW_RATE_INDEX_54MBPS = 0x6C
1124};
1125
1126struct wcn36xx_hal_supported_rates {
1127 /*
1128 * For Self STA Entry: this represents Self Mode.
1129 * For Peer Stations, this represents the mode of the peer.
1130 * On Station:
1131 *
1132 * --this mode is updated when PE adds the Self Entry.
1133 *
1134 * -- OR when PE sends 'ADD_BSS' message and station context in BSS
1135 * is used to indicate the mode of the AP.
1136 *
1137 * ON AP:
1138 *
1139 * -- this mode is updated when PE sends 'ADD_BSS' and Sta entry
1140 * for that BSS is used to indicate the self mode of the AP.
1141 *
1142 * -- OR when a station is associated, PE sends 'ADD_STA' message
1143 * with this mode updated.
1144 */
1145
1146 enum sta_rate_mode op_rate_mode;
1147
1148 /* 11b, 11a and aniLegacyRates are IE rates which gives rate in
1149 * unit of 500Kbps */
1150 u16 dsss_rates[WCN36XX_HAL_NUM_DSSS_RATES];
1151 u16 ofdm_rates[WCN36XX_HAL_NUM_OFDM_RATES];
1152 u16 legacy_rates[WCN36XX_HAL_NUM_POLARIS_RATES];
1153 u16 reserved;
1154
1155 /* Taurus only supports 26 Titan Rates(no ESF/concat Rates will be
1156 * supported) First 26 bits are reserved for those Titan rates and
1157 * the last 4 bits(bit28-31) for Taurus, 2(bit26-27) bits are
1158 * reserved. */
1159 /* Titan and Taurus Rates */
1160 u32 enhanced_rate_bitmap;
1161
1162 /*
1163 * 0-76 bits used, remaining reserved
1164 * bits 0-15 and 32 should be set.
1165 */
1166 u8 supported_mcs_set[WCN36XX_HAL_MAC_MAX_SUPPORTED_MCS_SET];
1167
1168 /*
1169 * RX Highest Supported Data Rate defines the highest data
1170 * rate that the STA is able to receive, in unites of 1Mbps.
1171 * This value is derived from "Supported MCS Set field" inside
1172 * the HT capability element.
1173 */
1174 u16 rx_highest_data_rate;
1175
1176} __packed;
1177
1178struct wcn36xx_hal_config_sta_params {
1179 /* BSSID of STA */
1180 u8 bssid[ETH_ALEN];
1181
1182 /* ASSOC ID, as assigned by UMAC */
1183 u16 aid;
1184
1185 /* STA entry Type: 0 - Self, 1 - Other/Peer, 2 - BSSID, 3 - BCAST */
1186 u8 type;
1187
1188 /* Short Preamble Supported. */
1189 u8 short_preamble_supported;
1190
1191 /* MAC Address of STA */
1192 u8 mac[ETH_ALEN];
1193
1194 /* Listen interval of the STA */
1195 u16 listen_interval;
1196
1197 /* Support for 11e/WMM */
1198 u8 wmm_enabled;
1199
1200 /* 11n HT capable STA */
1201 u8 ht_capable;
1202
1203 /* TX Width Set: 0 - 20 MHz only, 1 - 20/40 MHz */
1204 u8 tx_channel_width_set;
1205
1206 /* RIFS mode 0 - NA, 1 - Allowed */
1207 u8 rifs_mode;
1208
1209 /* L-SIG TXOP Protection mechanism
1210 0 - No Support, 1 - Supported
1211 SG - there is global field */
1212 u8 lsig_txop_protection;
1213
1214 /* Max Ampdu Size supported by STA. TPE programming.
1215 0 : 8k , 1 : 16k, 2 : 32k, 3 : 64k */
1216 u8 max_ampdu_size;
1217
1218 /* Max Ampdu density. Used by RA. 3 : 0~7 : 2^(11nAMPDUdensity -4) */
1219 u8 max_ampdu_density;
1220
1221 /* Max AMSDU size 1 : 3839 bytes, 0 : 7935 bytes */
1222 u8 max_amsdu_size;
1223
1224 /* Short GI support for 40Mhz packets */
1225 u8 sgi_40mhz;
1226
1227 /* Short GI support for 20Mhz packets */
1228 u8 sgi_20Mhz;
1229
1230 /* TODO move this parameter to the end for 3680 */
1231 /* These rates are the intersection of peer and self capabilities. */
1232 struct wcn36xx_hal_supported_rates supported_rates;
1233
1234 /* Robust Management Frame (RMF) enabled/disabled */
1235 u8 rmf;
1236
1237 /* The unicast encryption type in the association */
1238 u32 encrypt_type;
1239
1240 /* HAL should update the existing STA entry, if this flag is set. UMAC
1241 will set this flag in case of RE-ASSOC, where we want to reuse the
1242 old STA ID. 0 = Add, 1 = Update */
1243 u8 action;
1244
1245 /* U-APSD Flags: 1b per AC. Encoded as follows:
1246 b7 b6 b5 b4 b3 b2 b1 b0 =
1247 X X X X BE BK VI VO */
1248 u8 uapsd;
1249
1250 /* Max SP Length */
1251 u8 max_sp_len;
1252
1253 /* 11n Green Field preamble support
1254 0 - Not supported, 1 - Supported */
1255 u8 green_field_capable;
1256
1257 /* MIMO Power Save mode */
1258 enum wcn36xx_hal_ht_mimo_state mimo_ps;
1259
1260 /* Delayed BA Support */
1261 u8 delayed_ba_support;
1262
1263 /* Max AMPDU duration in 32us */
1264 u8 max_ampdu_duration;
1265
1266 /* HT STA should set it to 1 if it is enabled in BSS. HT STA should
1267 * set it to 0 if AP does not support it. This indication is sent
1268 * to HAL and HAL uses this flag to pickup up appropriate 40Mhz
1269 * rates. */
1270 u8 dsss_cck_mode_40mhz;
1271
1272 /* Valid STA Idx when action=Update. Set to 0xFF when invalid!
1273 * Retained for backward compalibity with existing HAL code */
1274 u8 sta_index;
1275
1276 /* BSSID of BSS to which station is associated. Set to 0xFF when
1277 * invalid. Retained for backward compalibity with existing HAL
1278 * code */
1279 u8 bssid_index;
1280
1281 u8 p2p;
1282
1283 /* TODO add this parameter for 3680. */
1284 /* Reserved to align next field on a dword boundary */
1285 /* u8 reserved; */
1286} __packed;
1287
1288struct wcn36xx_hal_config_sta_req_msg {
1289 struct wcn36xx_hal_msg_header header;
1290 struct wcn36xx_hal_config_sta_params sta_params;
1291} __packed;
1292
1293struct wcn36xx_hal_config_sta_params_v1 {
1294 /* BSSID of STA */
1295 u8 bssid[ETH_ALEN];
1296
1297 /* ASSOC ID, as assigned by UMAC */
1298 u16 aid;
1299
1300 /* STA entry Type: 0 - Self, 1 - Other/Peer, 2 - BSSID, 3 - BCAST */
1301 u8 type;
1302
1303 /* Short Preamble Supported. */
1304 u8 short_preamble_supported;
1305
1306 /* MAC Address of STA */
1307 u8 mac[ETH_ALEN];
1308
1309 /* Listen interval of the STA */
1310 u16 listen_interval;
1311
1312 /* Support for 11e/WMM */
1313 u8 wmm_enabled;
1314
1315 /* 11n HT capable STA */
1316 u8 ht_capable;
1317
1318 /* TX Width Set: 0 - 20 MHz only, 1 - 20/40 MHz */
1319 u8 tx_channel_width_set;
1320
1321 /* RIFS mode 0 - NA, 1 - Allowed */
1322 u8 rifs_mode;
1323
1324 /* L-SIG TXOP Protection mechanism
1325 0 - No Support, 1 - Supported
1326 SG - there is global field */
1327 u8 lsig_txop_protection;
1328
1329 /* Max Ampdu Size supported by STA. TPE programming.
1330 0 : 8k , 1 : 16k, 2 : 32k, 3 : 64k */
1331 u8 max_ampdu_size;
1332
1333 /* Max Ampdu density. Used by RA. 3 : 0~7 : 2^(11nAMPDUdensity -4) */
1334 u8 max_ampdu_density;
1335
1336 /* Max AMSDU size 1 : 3839 bytes, 0 : 7935 bytes */
1337 u8 max_amsdu_size;
1338
1339 /* Short GI support for 40Mhz packets */
1340 u8 sgi_40mhz;
1341
1342 /* Short GI support for 20Mhz packets */
1343 u8 sgi_20Mhz;
1344
1345 /* Robust Management Frame (RMF) enabled/disabled */
1346 u8 rmf;
1347
1348 /* The unicast encryption type in the association */
1349 u32 encrypt_type;
1350
1351 /* HAL should update the existing STA entry, if this flag is set. UMAC
1352 will set this flag in case of RE-ASSOC, where we want to reuse the
1353 old STA ID. 0 = Add, 1 = Update */
1354 u8 action;
1355
1356 /* U-APSD Flags: 1b per AC. Encoded as follows:
1357 b7 b6 b5 b4 b3 b2 b1 b0 =
1358 X X X X BE BK VI VO */
1359 u8 uapsd;
1360
1361 /* Max SP Length */
1362 u8 max_sp_len;
1363
1364 /* 11n Green Field preamble support
1365 0 - Not supported, 1 - Supported */
1366 u8 green_field_capable;
1367
1368 /* MIMO Power Save mode */
1369 enum wcn36xx_hal_ht_mimo_state mimo_ps;
1370
1371 /* Delayed BA Support */
1372 u8 delayed_ba_support;
1373
1374 /* Max AMPDU duration in 32us */
1375 u8 max_ampdu_duration;
1376
1377 /* HT STA should set it to 1 if it is enabled in BSS. HT STA should
1378 * set it to 0 if AP does not support it. This indication is sent
1379 * to HAL and HAL uses this flag to pickup up appropriate 40Mhz
1380 * rates. */
1381 u8 dsss_cck_mode_40mhz;
1382
1383 /* Valid STA Idx when action=Update. Set to 0xFF when invalid!
1384 * Retained for backward compalibity with existing HAL code */
1385 u8 sta_index;
1386
1387 /* BSSID of BSS to which station is associated. Set to 0xFF when
1388 * invalid. Retained for backward compalibity with existing HAL
1389 * code */
1390 u8 bssid_index;
1391
1392 u8 p2p;
1393
1394 /* Reserved to align next field on a dword boundary */
1395 u8 reserved;
1396
1397 /* These rates are the intersection of peer and self capabilities. */
1398 struct wcn36xx_hal_supported_rates supported_rates;
1399} __packed;
1400
1401struct wcn36xx_hal_config_sta_req_msg_v1 {
1402 struct wcn36xx_hal_msg_header header;
1403 struct wcn36xx_hal_config_sta_params_v1 sta_params;
1404} __packed;
1405
1406struct config_sta_rsp_params {
1407 /* success or failure */
1408 u32 status;
1409
1410 /* Station index; valid only when 'status' field value SUCCESS */
1411 u8 sta_index;
1412
1413 /* BSSID Index of BSS to which the station is associated */
1414 u8 bssid_index;
1415
1416 /* DPU Index for PTK */
1417 u8 dpu_index;
1418
1419 /* DPU Index for GTK */
1420 u8 bcast_dpu_index;
1421
1422 /* DPU Index for IGTK */
1423 u8 bcast_mgmt_dpu_idx;
1424
1425 /* PTK DPU signature */
1426 u8 uc_ucast_sig;
1427
1428 /* GTK DPU isignature */
1429 u8 uc_bcast_sig;
1430
1431 /* IGTK DPU signature */
1432 u8 uc_mgmt_sig;
1433
1434 u8 p2p;
1435
1436} __packed;
1437
1438struct wcn36xx_hal_config_sta_rsp_msg {
1439 struct wcn36xx_hal_msg_header header;
1440
1441 struct config_sta_rsp_params params;
1442} __packed;
1443
1444/* Delete STA Request message */
1445struct wcn36xx_hal_delete_sta_req_msg {
1446 struct wcn36xx_hal_msg_header header;
1447
1448 /* Index of STA to delete */
1449 u8 sta_index;
1450
1451} __packed;
1452
1453/* Delete STA Response message */
1454struct wcn36xx_hal_delete_sta_rsp_msg {
1455 struct wcn36xx_hal_msg_header header;
1456
1457 /* success or failure */
1458 u32 status;
1459
1460 /* Index of STA deleted */
1461 u8 sta_id;
1462} __packed;
1463
1464/* 12 Bytes long because this structure can be used to represent rate and
1465 * extended rate set IEs. The parser assume this to be at least 12 */
1466struct wcn36xx_hal_rate_set {
1467 u8 num_rates;
1468 u8 rate[WCN36XX_HAL_MAC_RATESET_EID_MAX];
1469} __packed;
1470
1471/* access category record */
1472struct wcn36xx_hal_aci_aifsn {
1473#ifndef ANI_LITTLE_BIT_ENDIAN
1474 u8 rsvd:1;
1475 u8 aci:2;
1476 u8 acm:1;
1477 u8 aifsn:4;
1478#else
1479 u8 aifsn:4;
1480 u8 acm:1;
1481 u8 aci:2;
1482 u8 rsvd:1;
1483#endif
1484} __packed;
1485
1486/* contention window size */
1487struct wcn36xx_hal_mac_cw {
1488#ifndef ANI_LITTLE_BIT_ENDIAN
1489 u8 max:4;
1490 u8 min:4;
1491#else
1492 u8 min:4;
1493 u8 max:4;
1494#endif
1495} __packed;
1496
1497struct wcn36xx_hal_edca_param_record {
1498 struct wcn36xx_hal_aci_aifsn aci;
1499 struct wcn36xx_hal_mac_cw cw;
1500 u16 txop_limit;
1501} __packed;
1502
1503struct wcn36xx_hal_mac_ssid {
1504 u8 length;
1505 u8 ssid[32];
1506} __packed;
1507
1508/* Concurrency role. These are generic IDs that identify the various roles
1509 * in the software system. */
1510enum wcn36xx_hal_con_mode {
1511 WCN36XX_HAL_STA_MODE = 0,
1512
1513 /* to support softAp mode . This is misleading.
1514 It means AP MODE only. */
1515 WCN36XX_HAL_STA_SAP_MODE = 1,
1516
1517 WCN36XX_HAL_P2P_CLIENT_MODE,
1518 WCN36XX_HAL_P2P_GO_MODE,
1519 WCN36XX_HAL_MONITOR_MODE,
1520};
1521
1522/* This is a bit pattern to be set for each mode
1523 * bit 0 - sta mode
1524 * bit 1 - ap mode
1525 * bit 2 - p2p client mode
1526 * bit 3 - p2p go mode */
1527enum wcn36xx_hal_concurrency_mode {
1528 HAL_STA = 1,
1529 HAL_SAP = 2,
1530
1531 /* to support sta, softAp mode . This means STA+AP mode */
1532 HAL_STA_SAP = 3,
1533
1534 HAL_P2P_CLIENT = 4,
1535 HAL_P2P_GO = 8,
1536 HAL_MAX_CONCURRENCY_PERSONA = 4
1537};
1538
1539struct wcn36xx_hal_config_bss_params {
1540 /* BSSID */
1541 u8 bssid[ETH_ALEN];
1542
1543 /* Self Mac Address */
1544 u8 self_mac_addr[ETH_ALEN];
1545
1546 /* BSS type */
1547 enum wcn36xx_hal_bss_type bss_type;
1548
1549 /* Operational Mode: AP =0, STA = 1 */
1550 u8 oper_mode;
1551
1552 /* Network Type */
1553 enum wcn36xx_hal_nw_type nw_type;
1554
1555 /* Used to classify PURE_11G/11G_MIXED to program MTU */
1556 u8 short_slot_time_supported;
1557
1558 /* Co-exist with 11a STA */
1559 u8 lla_coexist;
1560
1561 /* Co-exist with 11b STA */
1562 u8 llb_coexist;
1563
1564 /* Co-exist with 11g STA */
1565 u8 llg_coexist;
1566
1567 /* Coexistence with 11n STA */
1568 u8 ht20_coexist;
1569
1570 /* Non GF coexist flag */
1571 u8 lln_non_gf_coexist;
1572
1573 /* TXOP protection support */
1574 u8 lsig_tx_op_protection_full_support;
1575
1576 /* RIFS mode */
1577 u8 rifs_mode;
1578
1579 /* Beacon Interval in TU */
1580 u16 beacon_interval;
1581
1582 /* DTIM period */
1583 u8 dtim_period;
1584
1585 /* TX Width Set: 0 - 20 MHz only, 1 - 20/40 MHz */
1586 u8 tx_channel_width_set;
1587
1588 /* Operating channel */
1589 u8 oper_channel;
1590
1591 /* Extension channel for channel bonding */
1592 u8 ext_channel;
1593
1594 /* Reserved to align next field on a dword boundary */
1595 u8 reserved;
1596
1597 /* TODO move sta to the end for 3680 */
1598 /* Context of the station being added in HW
1599 * Add a STA entry for "itself" -
1600 *
1601 * On AP - Add the AP itself in an "STA context"
1602 *
1603 * On STA - Add the AP to which this STA is joining in an
1604 * "STA context"
1605 */
1606 struct wcn36xx_hal_config_sta_params sta;
1607 /* SSID of the BSS */
1608 struct wcn36xx_hal_mac_ssid ssid;
1609
1610 /* HAL should update the existing BSS entry, if this flag is set.
1611 * UMAC will set this flag in case of reassoc, where we want to
1612 * resue the the old BSSID and still return success 0 = Add, 1 =
1613 * Update */
1614 u8 action;
1615
1616 /* MAC Rate Set */
1617 struct wcn36xx_hal_rate_set rateset;
1618
1619 /* Enable/Disable HT capabilities of the BSS */
1620 u8 ht;
1621
1622 /* Enable/Disable OBSS protection */
1623 u8 obss_prot_enabled;
1624
1625 /* RMF enabled/disabled */
1626 u8 rmf;
1627
1628 /* HT Operating Mode operating mode of the 802.11n STA */
1629 enum wcn36xx_hal_ht_operating_mode ht_oper_mode;
1630
1631 /* Dual CTS Protection: 0 - Unused, 1 - Used */
1632 u8 dual_cts_protection;
1633
1634 /* Probe Response Max retries */
1635 u8 max_probe_resp_retry_limit;
1636
1637 /* To Enable Hidden ssid */
1638 u8 hidden_ssid;
1639
1640 /* To Enable Disable FW Proxy Probe Resp */
1641 u8 proxy_probe_resp;
1642
1643 /* Boolean to indicate if EDCA params are valid. UMAC might not
1644 * have valid EDCA params or might not desire to apply EDCA params
1645 * during config BSS. 0 implies Not Valid ; Non-Zero implies
1646 * valid */
1647 u8 edca_params_valid;
1648
1649 /* EDCA Parameters for Best Effort Access Category */
1650 struct wcn36xx_hal_edca_param_record acbe;
1651
1652 /* EDCA Parameters forBackground Access Category */
1653 struct wcn36xx_hal_edca_param_record acbk;
1654
1655 /* EDCA Parameters for Video Access Category */
1656 struct wcn36xx_hal_edca_param_record acvi;
1657
1658 /* EDCA Parameters for Voice Access Category */
1659 struct wcn36xx_hal_edca_param_record acvo;
1660
1661 /* Ext Bss Config Msg if set */
1662 u8 ext_set_sta_key_param_valid;
1663
1664 /* SetStaKeyParams for ext bss msg */
1665 struct wcn36xx_hal_set_sta_key_params ext_set_sta_key_param;
1666
1667 /* Persona for the BSS can be STA,AP,GO,CLIENT value same as enum
1668 * wcn36xx_hal_con_mode */
1669 u8 wcn36xx_hal_persona;
1670
1671 u8 spectrum_mgt_enable;
1672
1673 /* HAL fills in the tx power used for mgmt frames in txMgmtPower */
1674 s8 tx_mgmt_power;
1675
1676 /* maxTxPower has max power to be used after applying the power
1677 * constraint if any */
1678 s8 max_tx_power;
1679} __packed;
1680
1681struct wcn36xx_hal_config_bss_req_msg {
1682 struct wcn36xx_hal_msg_header header;
1683 struct wcn36xx_hal_config_bss_params bss_params;
1684} __packed;
1685
1686struct wcn36xx_hal_config_bss_params_v1 {
1687 /* BSSID */
1688 u8 bssid[ETH_ALEN];
1689
1690 /* Self Mac Address */
1691 u8 self_mac_addr[ETH_ALEN];
1692
1693 /* BSS type */
1694 enum wcn36xx_hal_bss_type bss_type;
1695
1696 /* Operational Mode: AP =0, STA = 1 */
1697 u8 oper_mode;
1698
1699 /* Network Type */
1700 enum wcn36xx_hal_nw_type nw_type;
1701
1702 /* Used to classify PURE_11G/11G_MIXED to program MTU */
1703 u8 short_slot_time_supported;
1704
1705 /* Co-exist with 11a STA */
1706 u8 lla_coexist;
1707
1708 /* Co-exist with 11b STA */
1709 u8 llb_coexist;
1710
1711 /* Co-exist with 11g STA */
1712 u8 llg_coexist;
1713
1714 /* Coexistence with 11n STA */
1715 u8 ht20_coexist;
1716
1717 /* Non GF coexist flag */
1718 u8 lln_non_gf_coexist;
1719
1720 /* TXOP protection support */
1721 u8 lsig_tx_op_protection_full_support;
1722
1723 /* RIFS mode */
1724 u8 rifs_mode;
1725
1726 /* Beacon Interval in TU */
1727 u16 beacon_interval;
1728
1729 /* DTIM period */
1730 u8 dtim_period;
1731
1732 /* TX Width Set: 0 - 20 MHz only, 1 - 20/40 MHz */
1733 u8 tx_channel_width_set;
1734
1735 /* Operating channel */
1736 u8 oper_channel;
1737
1738 /* Extension channel for channel bonding */
1739 u8 ext_channel;
1740
1741 /* Reserved to align next field on a dword boundary */
1742 u8 reserved;
1743
1744 /* SSID of the BSS */
1745 struct wcn36xx_hal_mac_ssid ssid;
1746
1747 /* HAL should update the existing BSS entry, if this flag is set.
1748 * UMAC will set this flag in case of reassoc, where we want to
1749 * resue the the old BSSID and still return success 0 = Add, 1 =
1750 * Update */
1751 u8 action;
1752
1753 /* MAC Rate Set */
1754 struct wcn36xx_hal_rate_set rateset;
1755
1756 /* Enable/Disable HT capabilities of the BSS */
1757 u8 ht;
1758
1759 /* Enable/Disable OBSS protection */
1760 u8 obss_prot_enabled;
1761
1762 /* RMF enabled/disabled */
1763 u8 rmf;
1764
1765 /* HT Operating Mode operating mode of the 802.11n STA */
1766 enum wcn36xx_hal_ht_operating_mode ht_oper_mode;
1767
1768 /* Dual CTS Protection: 0 - Unused, 1 - Used */
1769 u8 dual_cts_protection;
1770
1771 /* Probe Response Max retries */
1772 u8 max_probe_resp_retry_limit;
1773
1774 /* To Enable Hidden ssid */
1775 u8 hidden_ssid;
1776
1777 /* To Enable Disable FW Proxy Probe Resp */
1778 u8 proxy_probe_resp;
1779
1780 /* Boolean to indicate if EDCA params are valid. UMAC might not
1781 * have valid EDCA params or might not desire to apply EDCA params
1782 * during config BSS. 0 implies Not Valid ; Non-Zero implies
1783 * valid */
1784 u8 edca_params_valid;
1785
1786 /* EDCA Parameters for Best Effort Access Category */
1787 struct wcn36xx_hal_edca_param_record acbe;
1788
1789 /* EDCA Parameters forBackground Access Category */
1790 struct wcn36xx_hal_edca_param_record acbk;
1791
1792 /* EDCA Parameters for Video Access Category */
1793 struct wcn36xx_hal_edca_param_record acvi;
1794
1795 /* EDCA Parameters for Voice Access Category */
1796 struct wcn36xx_hal_edca_param_record acvo;
1797
1798 /* Ext Bss Config Msg if set */
1799 u8 ext_set_sta_key_param_valid;
1800
1801 /* SetStaKeyParams for ext bss msg */
1802 struct wcn36xx_hal_set_sta_key_params ext_set_sta_key_param;
1803
1804 /* Persona for the BSS can be STA,AP,GO,CLIENT value same as enum
1805 * wcn36xx_hal_con_mode */
1806 u8 wcn36xx_hal_persona;
1807
1808 u8 spectrum_mgt_enable;
1809
1810 /* HAL fills in the tx power used for mgmt frames in txMgmtPower */
1811 s8 tx_mgmt_power;
1812
1813 /* maxTxPower has max power to be used after applying the power
1814 * constraint if any */
1815 s8 max_tx_power;
1816
1817 /* Context of the station being added in HW
1818 * Add a STA entry for "itself" -
1819 *
1820 * On AP - Add the AP itself in an "STA context"
1821 *
1822 * On STA - Add the AP to which this STA is joining in an
1823 * "STA context"
1824 */
1825 struct wcn36xx_hal_config_sta_params_v1 sta;
1826} __packed;
1827
1828struct wcn36xx_hal_config_bss_req_msg_v1 {
1829 struct wcn36xx_hal_msg_header header;
1830 struct wcn36xx_hal_config_bss_params_v1 bss_params;
1831} __packed;
1832
1833struct wcn36xx_hal_config_bss_rsp_params {
1834 /* Success or Failure */
1835 u32 status;
1836
1837 /* BSS index allocated by HAL */
1838 u8 bss_index;
1839
1840 /* DPU descriptor index for PTK */
1841 u8 dpu_desc_index;
1842
1843 /* PTK DPU signature */
1844 u8 ucast_dpu_signature;
1845
1846 /* DPU descriptor index for GTK */
1847 u8 bcast_dpu_desc_indx;
1848
1849 /* GTK DPU signature */
1850 u8 bcast_dpu_signature;
1851
1852 /* DPU descriptor for IGTK */
1853 u8 mgmt_dpu_desc_index;
1854
1855 /* IGTK DPU signature */
1856 u8 mgmt_dpu_signature;
1857
1858 /* Station Index for BSS entry */
1859 u8 bss_sta_index;
1860
1861 /* Self station index for this BSS */
1862 u8 bss_self_sta_index;
1863
1864 /* Bcast station for buffering bcast frames in AP role */
1865 u8 bss_bcast_sta_idx;
1866
1867 /* MAC Address of STA(PEER/SELF) in staContext of configBSSReq */
1868 u8 mac[ETH_ALEN];
1869
1870 /* HAL fills in the tx power used for mgmt frames in this field. */
1871 s8 tx_mgmt_power;
1872
1873} __packed;
1874
1875struct wcn36xx_hal_config_bss_rsp_msg {
1876 struct wcn36xx_hal_msg_header header;
1877 struct wcn36xx_hal_config_bss_rsp_params bss_rsp_params;
1878} __packed;
1879
1880struct wcn36xx_hal_delete_bss_req_msg {
1881 struct wcn36xx_hal_msg_header header;
1882
1883 /* BSS index to be deleted */
1884 u8 bss_index;
1885
1886} __packed;
1887
1888struct wcn36xx_hal_delete_bss_rsp_msg {
1889 struct wcn36xx_hal_msg_header header;
1890
1891 /* Success or Failure */
1892 u32 status;
1893
1894 /* BSS index that has been deleted */
1895 u8 bss_index;
1896
1897} __packed;
1898
1899struct wcn36xx_hal_join_req_msg {
1900 struct wcn36xx_hal_msg_header header;
1901
1902 /* Indicates the BSSID to which STA is going to associate */
1903 u8 bssid[ETH_ALEN];
1904
1905 /* Indicates the channel to switch to. */
1906 u8 channel;
1907
1908 /* Self STA MAC */
1909 u8 self_sta_mac_addr[ETH_ALEN];
1910
1911 /* Local power constraint */
1912 u8 local_power_constraint;
1913
1914 /* Secondary channel offset */
1915 enum phy_chan_bond_state secondary_channel_offset;
1916
1917 /* link State */
1918 enum wcn36xx_hal_link_state link_state;
1919
1920 /* Max TX power */
1921 s8 max_tx_power;
1922} __packed;
1923
1924struct wcn36xx_hal_join_rsp_msg {
1925 struct wcn36xx_hal_msg_header header;
1926
1927 /* success or failure */
1928 u32 status;
1929
1930 /* HAL fills in the tx power used for mgmt frames in this field */
1931 u8 tx_mgmt_power;
1932} __packed;
1933
1934struct post_assoc_req_msg {
1935 struct wcn36xx_hal_msg_header header;
1936
1937 struct wcn36xx_hal_config_sta_params sta_params;
1938 struct wcn36xx_hal_config_bss_params bss_params;
1939};
1940
1941struct post_assoc_rsp_msg {
1942 struct wcn36xx_hal_msg_header header;
1943 struct config_sta_rsp_params sta_rsp_params;
1944 struct wcn36xx_hal_config_bss_rsp_params bss_rsp_params;
1945};
1946
1947/* This is used to create a set of WEP keys for a given BSS. */
1948struct wcn36xx_hal_set_bss_key_req_msg {
1949 struct wcn36xx_hal_msg_header header;
1950
1951 /* BSS Index of the BSS */
1952 u8 bss_idx;
1953
1954 /* Encryption Type used with peer */
1955 enum ani_ed_type enc_type;
1956
1957 /* Number of keys */
1958 u8 num_keys;
1959
1960 /* Array of keys. */
1961 struct wcn36xx_hal_keys keys[WCN36XX_HAL_MAC_MAX_NUM_OF_DEFAULT_KEYS];
1962
1963 /* Control for Replay Count, 1= Single TID based replay count on Tx
1964 * 0 = Per TID based replay count on TX */
1965 u8 single_tid_rc;
1966} __packed;
1967
1968/* tagged version of set bss key */
1969struct wcn36xx_hal_set_bss_key_req_msg_tagged {
1970 struct wcn36xx_hal_set_bss_key_req_msg Msg;
1971 u32 tag;
1972} __packed;
1973
1974struct wcn36xx_hal_set_bss_key_rsp_msg {
1975 struct wcn36xx_hal_msg_header header;
1976
1977 /* success or failure */
1978 u32 status;
1979} __packed;
1980
1981/*
1982 * This is used configure the key information on a given station.
1983 * When the sec_type is WEP40 or WEP104, the def_wep_idx is used to locate
1984 * a preconfigured key from a BSS the station assoicated with; otherwise
1985 * a new key descriptor is created based on the key field.
1986 */
1987struct wcn36xx_hal_set_sta_key_req_msg {
1988 struct wcn36xx_hal_msg_header header;
1989 struct wcn36xx_hal_set_sta_key_params set_sta_key_params;
1990} __packed;
1991
1992struct wcn36xx_hal_set_sta_key_rsp_msg {
1993 struct wcn36xx_hal_msg_header header;
1994
1995 /* success or failure */
1996 u32 status;
1997} __packed;
1998
1999struct wcn36xx_hal_remove_bss_key_req_msg {
2000 struct wcn36xx_hal_msg_header header;
2001
2002 /* BSS Index of the BSS */
2003 u8 bss_idx;
2004
2005 /* Encryption Type used with peer */
2006 enum ani_ed_type enc_type;
2007
2008 /* Key Id */
2009 u8 key_id;
2010
2011 /* STATIC/DYNAMIC. Used in Nullifying in Key Descriptors for
2012 * Static/Dynamic keys */
2013 enum ani_wep_type wep_type;
2014} __packed;
2015
2016struct wcn36xx_hal_remove_bss_key_rsp_msg {
2017 struct wcn36xx_hal_msg_header header;
2018
2019 /* success or failure */
2020 u32 status;
2021} __packed;
2022
2023/*
2024 * This is used by PE to Remove the key information on a given station.
2025 */
2026struct wcn36xx_hal_remove_sta_key_req_msg {
2027 struct wcn36xx_hal_msg_header header;
2028
2029 /* STA Index */
2030 u16 sta_idx;
2031
2032 /* Encryption Type used with peer */
2033 enum ani_ed_type enc_type;
2034
2035 /* Key Id */
2036 u8 key_id;
2037
2038 /* Whether to invalidate the Broadcast key or Unicast key. In case
2039 * of WEP, the same key is used for both broadcast and unicast. */
2040 u8 unicast;
2041
2042} __packed;
2043
2044struct wcn36xx_hal_remove_sta_key_rsp_msg {
2045 struct wcn36xx_hal_msg_header header;
2046
2047 /*success or failure */
2048 u32 status;
2049
2050} __packed;
2051
2052#ifdef FEATURE_OEM_DATA_SUPPORT
2053
2054#ifndef OEM_DATA_REQ_SIZE
2055#define OEM_DATA_REQ_SIZE 134
2056#endif
2057
2058#ifndef OEM_DATA_RSP_SIZE
2059#define OEM_DATA_RSP_SIZE 1968
2060#endif
2061
2062struct start_oem_data_req_msg {
2063 struct wcn36xx_hal_msg_header header;
2064
2065 u32 status;
2066 tSirMacAddr self_mac_addr;
2067 u8 oem_data_req[OEM_DATA_REQ_SIZE];
2068
2069};
2070
2071struct start_oem_data_rsp_msg {
2072 struct wcn36xx_hal_msg_header header;
2073
2074 u8 oem_data_rsp[OEM_DATA_RSP_SIZE];
2075};
2076
2077#endif
2078
2079struct wcn36xx_hal_switch_channel_req_msg {
2080 struct wcn36xx_hal_msg_header header;
2081
2082 /* Channel number */
2083 u8 channel_number;
2084
2085 /* Local power constraint */
2086 u8 local_power_constraint;
2087
2088 /* Secondary channel offset */
2089 enum phy_chan_bond_state secondary_channel_offset;
2090
2091 /* HAL fills in the tx power used for mgmt frames in this field. */
2092 u8 tx_mgmt_power;
2093
2094 /* Max TX power */
2095 u8 max_tx_power;
2096
2097 /* Self STA MAC */
2098 u8 self_sta_mac_addr[ETH_ALEN];
2099
2100 /* VO WIFI comment: BSSID needed to identify session. As the
2101 * request has power constraints, this should be applied only to
2102 * that session Since MTU timing and EDCA are sessionized, this
2103 * struct needs to be sessionized and bssid needs to be out of the
2104 * VOWifi feature flag V IMP: Keep bssId field at the end of this
2105 * msg. It is used to mantain backward compatbility by way of
2106 * ignoring if using new host/old FW or old host/new FW since it is
2107 * at the end of this struct
2108 */
2109 u8 bssid[ETH_ALEN];
2110} __packed;
2111
2112struct wcn36xx_hal_switch_channel_rsp_msg {
2113 struct wcn36xx_hal_msg_header header;
2114
2115 /* Status */
2116 u32 status;
2117
2118 /* Channel number - same as in request */
2119 u8 channel_number;
2120
2121 /* HAL fills in the tx power used for mgmt frames in this field */
2122 u8 tx_mgmt_power;
2123
2124 /* BSSID needed to identify session - same as in request */
2125 u8 bssid[ETH_ALEN];
2126
2127} __packed;
2128
2129struct update_edca_params_req_msg {
2130 struct wcn36xx_hal_msg_header header;
2131
2132 /*BSS Index */
2133 u16 bss_index;
2134
2135 /* Best Effort */
2136 struct wcn36xx_hal_edca_param_record acbe;
2137
2138 /* Background */
2139 struct wcn36xx_hal_edca_param_record acbk;
2140
2141 /* Video */
2142 struct wcn36xx_hal_edca_param_record acvi;
2143
2144 /* Voice */
2145 struct wcn36xx_hal_edca_param_record acvo;
2146};
2147
2148struct update_edca_params_rsp_msg {
2149 struct wcn36xx_hal_msg_header header;
2150
2151 /* success or failure */
2152 u32 status;
2153};
2154
2155struct dpu_stats_params {
2156 /* Index of STA to which the statistics */
2157 u16 sta_index;
2158
2159 /* Encryption mode */
2160 u8 enc_mode;
2161
2162 /* status */
2163 u32 status;
2164
2165 /* Statistics */
2166 u32 send_blocks;
2167 u32 recv_blocks;
2168 u32 replays;
2169 u8 mic_error_cnt;
2170 u32 prot_excl_cnt;
2171 u16 format_err_cnt;
2172 u16 un_decryptable_cnt;
2173 u32 decrypt_err_cnt;
2174 u32 decrypt_ok_cnt;
2175};
2176
2177struct wcn36xx_hal_stats_req_msg {
2178 struct wcn36xx_hal_msg_header header;
2179
2180 /* Valid STA Idx for per STA stats request */
2181 u32 sta_id;
2182
2183 /* Categories of stats requested as specified in eHalStatsMask */
2184 u32 stats_mask;
2185};
2186
2187struct ani_summary_stats_info {
2188 /* Total number of packets(per AC) that were successfully
2189 * transmitted with retries */
2190 u32 retry_cnt[4];
2191
2192 /* The number of MSDU packets and MMPDU frames per AC that the
2193 * 802.11 station successfully transmitted after more than one
2194 * retransmission attempt */
2195 u32 multiple_retry_cnt[4];
2196
2197 /* Total number of packets(per AC) that were successfully
2198 * transmitted (with and without retries, including multi-cast,
2199 * broadcast) */
2200 u32 tx_frm_cnt[4];
2201
2202 /* Total number of packets that were successfully received (after
2203 * appropriate filter rules including multi-cast, broadcast) */
2204 u32 rx_frm_cnt;
2205
2206 /* Total number of duplicate frames received successfully */
2207 u32 frm_dup_cnt;
2208
2209 /* Total number packets(per AC) failed to transmit */
2210 u32 fail_cnt[4];
2211
2212 /* Total number of RTS/CTS sequence failures for transmission of a
2213 * packet */
2214 u32 rts_fail_cnt;
2215
2216 /* Total number packets failed transmit because of no ACK from the
2217 * remote entity */
2218 u32 ack_fail_cnt;
2219
2220 /* Total number of RTS/CTS sequence success for transmission of a
2221 * packet */
2222 u32 rts_succ_cnt;
2223
2224 /* The sum of the receive error count and dropped-receive-buffer
2225 * error count. HAL will provide this as a sum of (FCS error) +
2226 * (Fail get BD/PDU in HW) */
2227 u32 rx_discard_cnt;
2228
2229 /*
2230 * The receive error count. HAL will provide the RxP FCS error
2231 * global counter. */
2232 u32 rx_error_cnt;
2233
2234 /* The sum of the transmit-directed byte count, transmit-multicast
2235 * byte count and transmit-broadcast byte count. HAL will sum TPE
2236 * UC/MC/BCAST global counters to provide this. */
2237 u32 tx_byte_cnt;
2238};
2239
2240/* defines tx_rate_flags */
2241enum tx_rate_info {
2242 /* Legacy rates */
2243 HAL_TX_RATE_LEGACY = 0x1,
2244
2245 /* HT20 rates */
2246 HAL_TX_RATE_HT20 = 0x2,
2247
2248 /* HT40 rates */
2249 HAL_TX_RATE_HT40 = 0x4,
2250
2251 /* Rate with Short guard interval */
2252 HAL_TX_RATE_SGI = 0x8,
2253
2254 /* Rate with Long guard interval */
2255 HAL_TX_RATE_LGI = 0x10
2256};
2257
2258struct ani_global_class_a_stats_info {
2259 /* The number of MPDU frames received by the 802.11 station for
2260 * MSDU packets or MMPDU frames */
2261 u32 rx_frag_cnt;
2262
2263 /* The number of MPDU frames received by the 802.11 station for
2264 * MSDU packets or MMPDU frames when a promiscuous packet filter
2265 * was enabled */
2266 u32 promiscuous_rx_frag_cnt;
2267
2268 /* The receiver input sensitivity referenced to a FER of 8% at an
2269 * MPDU length of 1024 bytes at the antenna connector. Each element
2270 * of the array shall correspond to a supported rate and the order
2271 * shall be the same as the supporteRates parameter. */
2272 u32 rx_input_sensitivity;
2273
2274 /* The maximum transmit power in dBm upto one decimal. for eg: if
2275 * it is 10.5dBm, the value would be 105 */
2276 u32 max_pwr;
2277
2278 /* Number of times the receiver failed to synchronize with the
2279 * incoming signal after detecting the sync in the preamble of the
2280 * transmitted PLCP protocol data unit. */
2281 u32 sync_fail_cnt;
2282
2283 /* Legacy transmit rate, in units of 500 kbit/sec, for the most
2284 * recently transmitted frame */
2285 u32 tx_rate;
2286
2287 /* mcs index for HT20 and HT40 rates */
2288 u32 mcs_index;
2289
2290 /* to differentiate between HT20 and HT40 rates; short and long
2291 * guard interval */
2292 u32 tx_rate_flags;
2293};
2294
2295struct ani_global_security_stats {
2296 /* The number of unencrypted received MPDU frames that the MAC
2297 * layer discarded when the IEEE 802.11 dot11ExcludeUnencrypted
2298 * management information base (MIB) object is enabled */
2299 u32 rx_wep_unencrypted_frm_cnt;
2300
2301 /* The number of received MSDU packets that that the 802.11 station
2302 * discarded because of MIC failures */
2303 u32 rx_mic_fail_cnt;
2304
2305 /* The number of encrypted MPDU frames that the 802.11 station
2306 * failed to decrypt because of a TKIP ICV error */
2307 u32 tkip_icv_err;
2308
2309 /* The number of received MPDU frames that the 802.11 discarded
2310 * because of an invalid AES-CCMP format */
2311 u32 aes_ccmp_format_err;
2312
2313 /* The number of received MPDU frames that the 802.11 station
2314 * discarded because of the AES-CCMP replay protection procedure */
2315 u32 aes_ccmp_replay_cnt;
2316
2317 /* The number of received MPDU frames that the 802.11 station
2318 * discarded because of errors detected by the AES-CCMP decryption
2319 * algorithm */
2320 u32 aes_ccmp_decrpt_err;
2321
2322 /* The number of encrypted MPDU frames received for which a WEP
2323 * decryption key was not available on the 802.11 station */
2324 u32 wep_undecryptable_cnt;
2325
2326 /* The number of encrypted MPDU frames that the 802.11 station
2327 * failed to decrypt because of a WEP ICV error */
2328 u32 wep_icv_err;
2329
2330 /* The number of received encrypted packets that the 802.11 station
2331 * successfully decrypted */
2332 u32 rx_decrypt_succ_cnt;
2333
2334 /* The number of encrypted packets that the 802.11 station failed
2335 * to decrypt */
2336 u32 rx_decrypt_fail_cnt;
2337};
2338
2339struct ani_global_class_b_stats_info {
2340 struct ani_global_security_stats uc_stats;
2341 struct ani_global_security_stats mc_bc_stats;
2342};
2343
2344struct ani_global_class_c_stats_info {
2345 /* This counter shall be incremented for a received A-MSDU frame
2346 * with the stations MAC address in the address 1 field or an
2347 * A-MSDU frame with a group address in the address 1 field */
2348 u32 rx_amsdu_cnt;
2349
2350 /* This counter shall be incremented when the MAC receives an AMPDU
2351 * from the PHY */
2352 u32 rx_ampdu_cnt;
2353
2354 /* This counter shall be incremented when a Frame is transmitted
2355 * only on the primary channel */
2356 u32 tx_20_frm_cnt;
2357
2358 /* This counter shall be incremented when a Frame is received only
2359 * on the primary channel */
2360 u32 rx_20_frm_cnt;
2361
2362 /* This counter shall be incremented by the number of MPDUs
2363 * received in the A-MPDU when an A-MPDU is received */
2364 u32 rx_mpdu_in_ampdu_cnt;
2365
2366 /* This counter shall be incremented when an MPDU delimiter has a
2367 * CRC error when this is the first CRC error in the received AMPDU
2368 * or when the previous delimiter has been decoded correctly */
2369 u32 ampdu_delimiter_crc_err;
2370};
2371
2372struct ani_per_sta_stats_info {
2373 /* The number of MPDU frames that the 802.11 station transmitted
2374 * and acknowledged through a received 802.11 ACK frame */
2375 u32 tx_frag_cnt[4];
2376
2377 /* This counter shall be incremented when an A-MPDU is transmitted */
2378 u32 tx_ampdu_cnt;
2379
2380 /* This counter shall increment by the number of MPDUs in the AMPDU
2381 * when an A-MPDU is transmitted */
2382 u32 tx_mpdu_in_ampdu_cnt;
2383};
2384
2385struct wcn36xx_hal_stats_rsp_msg {
2386 struct wcn36xx_hal_msg_header header;
2387
2388 /* Success or Failure */
2389 u32 status;
2390
2391 /* STA Idx */
2392 u32 sta_index;
2393
2394 /* Categories of STATS being returned as per eHalStatsMask */
2395 u32 stats_mask;
2396
2397 /* message type is same as the request type */
2398 u16 msg_type;
2399
2400 /* length of the entire request, includes the pStatsBuf length too */
2401 u16 msg_len;
2402};
2403
2404struct wcn36xx_hal_set_link_state_req_msg {
2405 struct wcn36xx_hal_msg_header header;
2406
2407 u8 bssid[ETH_ALEN];
2408 enum wcn36xx_hal_link_state state;
2409 u8 self_mac_addr[ETH_ALEN];
2410
2411} __packed;
2412
2413struct set_link_state_rsp_msg {
2414 struct wcn36xx_hal_msg_header header;
2415
2416 /* success or failure */
2417 u32 status;
2418};
2419
2420/* TSPEC Params */
2421struct wcn36xx_hal_ts_info_tfc {
2422#ifndef ANI_LITTLE_BIT_ENDIAN
2423 u16 ackPolicy:2;
2424 u16 userPrio:3;
2425 u16 psb:1;
2426 u16 aggregation:1;
2427 u16 accessPolicy:2;
2428 u16 direction:2;
2429 u16 tsid:4;
2430 u16 trafficType:1;
2431#else
2432 u16 trafficType:1;
2433 u16 tsid:4;
2434 u16 direction:2;
2435 u16 accessPolicy:2;
2436 u16 aggregation:1;
2437 u16 psb:1;
2438 u16 userPrio:3;
2439 u16 ackPolicy:2;
2440#endif
2441};
2442
2443/* Flag to schedule the traffic type */
2444struct wcn36xx_hal_ts_info_sch {
2445#ifndef ANI_LITTLE_BIT_ENDIAN
2446 u8 rsvd:7;
2447 u8 schedule:1;
2448#else
2449 u8 schedule:1;
2450 u8 rsvd:7;
2451#endif
2452};
2453
2454/* Traffic and scheduling info */
2455struct wcn36xx_hal_ts_info {
2456 struct wcn36xx_hal_ts_info_tfc traffic;
2457 struct wcn36xx_hal_ts_info_sch schedule;
2458};
2459
2460/* Information elements */
2461struct wcn36xx_hal_tspec_ie {
2462 u8 type;
2463 u8 length;
2464 struct wcn36xx_hal_ts_info ts_info;
2465 u16 nom_msdu_size;
2466 u16 max_msdu_size;
2467 u32 min_svc_interval;
2468 u32 max_svc_interval;
2469 u32 inact_interval;
2470 u32 suspend_interval;
2471 u32 svc_start_time;
2472 u32 min_data_rate;
2473 u32 mean_data_rate;
2474 u32 peak_data_rate;
2475 u32 max_burst_sz;
2476 u32 delay_bound;
2477 u32 min_phy_rate;
2478 u16 surplus_bw;
2479 u16 medium_time;
2480};
2481
2482struct add_ts_req_msg {
2483 struct wcn36xx_hal_msg_header header;
2484
2485 /* Station Index */
2486 u16 sta_index;
2487
2488 /* TSPEC handler uniquely identifying a TSPEC for a STA in a BSS */
2489 u16 tspec_index;
2490
2491 /* To program TPE with required parameters */
2492 struct wcn36xx_hal_tspec_ie tspec;
2493
2494 /* U-APSD Flags: 1b per AC. Encoded as follows:
2495 b7 b6 b5 b4 b3 b2 b1 b0 =
2496 X X X X BE BK VI VO */
2497 u8 uapsd;
2498
2499 /* These parameters are for all the access categories */
2500
2501 /* Service Interval */
2502 u32 service_interval[WCN36XX_HAL_MAX_AC];
2503
2504 /* Suspend Interval */
2505 u32 suspend_interval[WCN36XX_HAL_MAX_AC];
2506
2507 /* Delay Interval */
2508 u32 delay_interval[WCN36XX_HAL_MAX_AC];
2509};
2510
2511struct add_rs_rsp_msg {
2512 struct wcn36xx_hal_msg_header header;
2513
2514 /* success or failure */
2515 u32 status;
2516};
2517
2518struct del_ts_req_msg {
2519 struct wcn36xx_hal_msg_header header;
2520
2521 /* Station Index */
2522 u16 sta_index;
2523
2524 /* TSPEC identifier uniquely identifying a TSPEC for a STA in a BSS */
2525 u16 tspec_index;
2526
2527 /* To lookup station id using the mac address */
2528 u8 bssid[ETH_ALEN];
2529};
2530
2531struct del_ts_rsp_msg {
2532 struct wcn36xx_hal_msg_header header;
2533
2534 /* success or failure */
2535 u32 status;
2536};
2537
2538/* End of TSpec Parameters */
2539
2540/* Start of BLOCK ACK related Parameters */
2541
2542struct wcn36xx_hal_add_ba_session_req_msg {
2543 struct wcn36xx_hal_msg_header header;
2544
2545 /* Station Index */
2546 u16 sta_index;
2547
2548 /* Peer MAC Address */
2549 u8 mac_addr[ETH_ALEN];
2550
2551 /* ADDBA Action Frame dialog token
2552 HAL will not interpret this object */
2553 u8 dialog_token;
2554
2555 /* TID for which the BA is being setup
2556 This identifies the TC or TS of interest */
2557 u8 tid;
2558
2559 /* 0 - Delayed BA (Not supported)
2560 1 - Immediate BA */
2561 u8 policy;
2562
2563 /* Indicates the number of buffers for this TID (baTID)
2564 NOTE - This is the requested buffer size. When this
2565 is processed by HAL and subsequently by HDD, it is
2566 possible that HDD may change this buffer size. Any
2567 change in the buffer size should be noted by PE and
2568 advertized appropriately in the ADDBA response */
2569 u16 buffer_size;
2570
2571 /* BA timeout in TU's 0 means no timeout will occur */
2572 u16 timeout;
2573
2574 /* b0..b3 - Fragment Number - Always set to 0
2575 b4..b15 - Starting Sequence Number of first MSDU
2576 for which this BA is setup */
2577 u16 ssn;
2578
2579 /* ADDBA direction
2580 1 - Originator
2581 0 - Recipient */
2582 u8 direction;
2583} __packed;
2584
2585struct wcn36xx_hal_add_ba_session_rsp_msg {
2586 struct wcn36xx_hal_msg_header header;
2587
2588 /* success or failure */
2589 u32 status;
2590
2591 /* Dialog token */
2592 u8 dialog_token;
2593
2594 /* TID for which the BA session has been setup */
2595 u8 ba_tid;
2596
2597 /* BA Buffer Size allocated for the current BA session */
2598 u8 ba_buffer_size;
2599
2600 u8 ba_session_id;
2601
2602 /* Reordering Window buffer */
2603 u8 win_size;
2604
2605 /* Station Index to id the sta */
2606 u8 sta_index;
2607
2608 /* Starting Sequence Number */
2609 u16 ssn;
2610} __packed;
2611
2612struct wcn36xx_hal_add_ba_req_msg {
2613 struct wcn36xx_hal_msg_header header;
2614
2615 /* Session Id */
2616 u8 session_id;
2617
2618 /* Reorder Window Size */
2619 u8 win_size;
2620/* Old FW 1.2.2.4 does not support this*/
2621#ifdef FEATURE_ON_CHIP_REORDERING
2622 u8 reordering_done_on_chip;
2623#endif
2624} __packed;
2625
2626struct wcn36xx_hal_add_ba_rsp_msg {
2627 struct wcn36xx_hal_msg_header header;
2628
2629 /* success or failure */
2630 u32 status;
2631
2632 /* Dialog token */
2633 u8 dialog_token;
2634} __packed;
2635
2636struct add_ba_info {
2637 u16 ba_enable:1;
2638 u16 starting_seq_num:12;
2639 u16 reserved:3;
2640};
2641
2642struct wcn36xx_hal_trigger_ba_rsp_candidate {
2643 u8 sta_addr[ETH_ALEN];
2644 struct add_ba_info ba_info[STACFG_MAX_TC];
2645} __packed;
2646
2647struct wcn36xx_hal_trigget_ba_req_candidate {
2648 u8 sta_index;
2649 u8 tid_bitmap;
2650} __packed;
2651
2652struct wcn36xx_hal_trigger_ba_req_msg {
2653 struct wcn36xx_hal_msg_header header;
2654
2655 /* Session Id */
2656 u8 session_id;
2657
2658 /* baCandidateCnt is followed by trigger BA
2659 * Candidate List(tTriggerBaCandidate)
2660 */
2661 u16 candidate_cnt;
2662
2663} __packed;
2664
2665struct wcn36xx_hal_trigger_ba_rsp_msg {
2666 struct wcn36xx_hal_msg_header header;
2667
2668 /* TO SUPPORT BT-AMP */
2669 u8 bssid[ETH_ALEN];
2670
2671 /* success or failure */
2672 u32 status;
2673
2674 /* baCandidateCnt is followed by trigger BA
2675 * Rsp Candidate List(tTriggerRspBaCandidate)
2676 */
2677 u16 candidate_cnt;
2678} __packed;
2679
2680struct wcn36xx_hal_del_ba_req_msg {
2681 struct wcn36xx_hal_msg_header header;
2682
2683 /* Station Index */
2684 u16 sta_index;
2685
2686 /* TID for which the BA session is being deleted */
2687 u8 tid;
2688
2689 /* DELBA direction
2690 1 - Originator
2691 0 - Recipient */
2692 u8 direction;
2693} __packed;
2694
2695struct wcn36xx_hal_del_ba_rsp_msg {
2696 struct wcn36xx_hal_msg_header header;
2697
2698 /* success or failure */
2699 u32 status;
2700} __packed;
2701
2702struct tsm_stats_req_msg {
2703 struct wcn36xx_hal_msg_header header;
2704
2705 /* Traffic Id */
2706 u8 tid;
2707
2708 u8 bssid[ETH_ALEN];
2709};
2710
2711struct tsm_stats_rsp_msg {
2712 struct wcn36xx_hal_msg_header header;
2713
2714 /*success or failure */
2715 u32 status;
2716
2717 /* Uplink Packet Queue delay */
2718 u16 uplink_pkt_queue_delay;
2719
2720 /* Uplink Packet Queue delay histogram */
2721 u16 uplink_pkt_queue_delay_hist[4];
2722
2723 /* Uplink Packet Transmit delay */
2724 u32 uplink_pkt_tx_delay;
2725
2726 /* Uplink Packet loss */
2727 u16 uplink_pkt_loss;
2728
2729 /* Uplink Packet count */
2730 u16 uplink_pkt_count;
2731
2732 /* Roaming count */
2733 u8 roaming_count;
2734
2735 /* Roaming Delay */
2736 u16 roaming_delay;
2737};
2738
2739struct set_key_done_msg {
2740 struct wcn36xx_hal_msg_header header;
2741
2742 /*bssid of the keys */
2743 u8 bssidx;
2744 u8 enc_type;
2745};
2746
2747struct wcn36xx_hal_nv_img_download_req_msg {
2748 /* Note: The length specified in wcn36xx_hal_nv_img_download_req_msg
2749 * messages should be
2750 * header.len = sizeof(wcn36xx_hal_nv_img_download_req_msg) +
2751 * nv_img_buffer_size */
2752 struct wcn36xx_hal_msg_header header;
2753
2754 /* Fragment sequence number of the NV Image. Note that NV Image
2755 * might not fit into one message due to size limitation of the SMD
2756 * channel FIFO. UMAC can hence choose to chop the NV blob into
2757 * multiple fragments starting with seqeunce number 0, 1, 2 etc.
2758 * The last fragment MUST be indicated by marking the
2759 * isLastFragment field to 1. Note that all the NV blobs would be
2760 * concatenated together by HAL without any padding bytes in
2761 * between.*/
2762 u16 frag_number;
2763
2764 /* Is this the last fragment? When set to 1 it indicates that no
2765 * more fragments will be sent by UMAC and HAL can concatenate all
2766 * the NV blobs rcvd & proceed with the parsing. HAL would generate
2767 * a WCN36XX_HAL_DOWNLOAD_NV_RSP to the WCN36XX_HAL_DOWNLOAD_NV_REQ
2768 * after it receives each fragment */
2769 u16 last_fragment;
2770
2771 /* NV Image size (number of bytes) */
2772 u32 nv_img_buffer_size;
2773
2774 /* Following the 'nv_img_buffer_size', there should be
2775 * nv_img_buffer_size bytes of NV Image i.e.
2776 * u8[nv_img_buffer_size] */
2777} __packed;
2778
2779struct wcn36xx_hal_nv_img_download_rsp_msg {
2780 struct wcn36xx_hal_msg_header header;
2781
2782 /* Success or Failure. HAL would generate a
2783 * WCN36XX_HAL_DOWNLOAD_NV_RSP after each fragment */
2784 u32 status;
2785} __packed;
2786
2787struct wcn36xx_hal_nv_store_ind {
2788 /* Note: The length specified in tHalNvStoreInd messages should be
2789 * header.msgLen = sizeof(tHalNvStoreInd) + nvBlobSize */
2790 struct wcn36xx_hal_msg_header header;
2791
2792 /* NV Item */
2793 u32 table_id;
2794
2795 /* Size of NV Blob */
2796 u32 nv_blob_size;
2797
2798 /* Following the 'nvBlobSize', there should be nvBlobSize bytes of
2799 * NV blob i.e. u8[nvBlobSize] */
2800};
2801
2802/* End of Block Ack Related Parameters */
2803
2804#define WCN36XX_HAL_CIPHER_SEQ_CTR_SIZE 6
2805
2806/* Definition for MIC failure indication MAC reports this each time a MIC
2807 * failure occures on Rx TKIP packet
2808 */
2809struct mic_failure_ind_msg {
2810 struct wcn36xx_hal_msg_header header;
2811
2812 u8 bssid[ETH_ALEN];
2813
2814 /* address used to compute MIC */
2815 u8 src_addr[ETH_ALEN];
2816
2817 /* transmitter address */
2818 u8 ta_addr[ETH_ALEN];
2819
2820 u8 dst_addr[ETH_ALEN];
2821
2822 u8 multicast;
2823
2824 /* first byte of IV */
2825 u8 iv1;
2826
2827 /* second byte of IV */
2828 u8 key_id;
2829
2830 /* sequence number */
2831 u8 tsc[WCN36XX_HAL_CIPHER_SEQ_CTR_SIZE];
2832
2833 /* receive address */
2834 u8 rx_addr[ETH_ALEN];
2835};
2836
2837struct update_vht_op_mode_req_msg {
2838 struct wcn36xx_hal_msg_header header;
2839
2840 u16 op_mode;
2841 u16 sta_id;
2842};
2843
2844struct update_vht_op_mode_params_rsp_msg {
2845 struct wcn36xx_hal_msg_header header;
2846
2847 u32 status;
2848};
2849
2850struct update_beacon_req_msg {
2851 struct wcn36xx_hal_msg_header header;
2852
2853 u8 bss_index;
2854
2855 /* shortPreamble mode. HAL should update all the STA rates when it
2856 * receives this message */
2857 u8 short_preamble;
2858
2859 /* short Slot time. */
2860 u8 short_slot_time;
2861
2862 /* Beacon Interval */
2863 u16 beacon_interval;
2864
2865 /* Protection related */
2866 u8 lla_coexist;
2867 u8 llb_coexist;
2868 u8 llg_coexist;
2869 u8 ht20_coexist;
2870 u8 lln_non_gf_coexist;
2871 u8 lsig_tx_op_protection_full_support;
2872 u8 rifs_mode;
2873
2874 u16 param_change_bitmap;
2875};
2876
2877struct update_beacon_rsp_msg {
2878 struct wcn36xx_hal_msg_header header;
2879 u32 status;
2880};
2881
2882struct wcn36xx_hal_send_beacon_req_msg {
2883 struct wcn36xx_hal_msg_header header;
2884
2885 /* length of the template. */
2886 u32 beacon_length;
2887
2888 /* Beacon data. */
2889 u8 beacon[BEACON_TEMPLATE_SIZE];
2890
2891 u8 bssid[ETH_ALEN];
2892
2893 /* TIM IE offset from the beginning of the template. */
2894 u32 tim_ie_offset;
2895
2896 /* P2P IE offset from the begining of the template */
2897 u16 p2p_ie_offset;
2898} __packed;
2899
2900struct send_beacon_rsp_msg {
2901 struct wcn36xx_hal_msg_header header;
2902 u32 status;
2903} __packed;
2904
2905struct enable_radar_req_msg {
2906 struct wcn36xx_hal_msg_header header;
2907
2908 u8 bssid[ETH_ALEN];
2909 u8 channel;
2910};
2911
2912struct enable_radar_rsp_msg {
2913 struct wcn36xx_hal_msg_header header;
2914
2915 /* Link Parameters */
2916 u8 bssid[ETH_ALEN];
2917
2918 /* success or failure */
2919 u32 status;
2920};
2921
2922struct radar_detect_intr_ind_msg {
2923 struct wcn36xx_hal_msg_header header;
2924
2925 u8 radar_det_channel;
2926};
2927
2928struct radar_detect_ind_msg {
2929 struct wcn36xx_hal_msg_header header;
2930
2931 /* channel number in which the RADAR detected */
2932 u8 channel_number;
2933
2934 /* RADAR pulse width in usecond */
2935 u16 radar_pulse_width;
2936
2937 /* Number of RADAR pulses */
2938 u16 num_radar_pulse;
2939};
2940
2941struct wcn36xx_hal_get_tpc_report_req_msg {
2942 struct wcn36xx_hal_msg_header header;
2943
2944 u8 sta[ETH_ALEN];
2945 u8 dialog_token;
2946 u8 txpower;
2947};
2948
2949struct wcn36xx_hal_get_tpc_report_rsp_msg {
2950 struct wcn36xx_hal_msg_header header;
2951
2952 /* success or failure */
2953 u32 status;
2954};
2955
2956struct wcn36xx_hal_send_probe_resp_req_msg {
2957 struct wcn36xx_hal_msg_header header;
2958
2959 u8 probe_resp_template[BEACON_TEMPLATE_SIZE];
2960 u32 probe_resp_template_len;
2961 u32 proxy_probe_req_valid_ie_bmap[8];
2962 u8 bssid[ETH_ALEN];
2963};
2964
2965struct send_probe_resp_rsp_msg {
2966 struct wcn36xx_hal_msg_header header;
2967
2968 /* success or failure */
2969 u32 status;
2970};
2971
2972struct send_unknown_frame_rx_ind_msg {
2973 struct wcn36xx_hal_msg_header header;
2974
2975 /* success or failure */
2976 u32 status;
2977};
2978
2979struct wcn36xx_hal_delete_sta_context_ind_msg {
2980 struct wcn36xx_hal_msg_header header;
2981
2982 u16 aid;
2983 u16 sta_id;
2984
2985 /* TO SUPPORT BT-AMP */
2986 u8 bssid[ETH_ALEN];
2987
2988 /* HAL copies bssid from the sta table. */
2989 u8 addr2[ETH_ALEN];
2990
2991 /* To unify the keepalive / unknown A2 / tim-based disa */
2992 u16 reason_code;
2993} __packed;
2994
2995struct indicate_del_sta {
2996 struct wcn36xx_hal_msg_header header;
2997 u8 aid;
2998 u8 sta_index;
2999 u8 bss_index;
3000 u8 reason_code;
3001 u32 status;
3002};
3003
3004struct bt_amp_event_msg {
3005 struct wcn36xx_hal_msg_header header;
3006
3007 enum bt_amp_event_type btAmpEventType;
3008};
3009
3010struct bt_amp_event_rsp {
3011 struct wcn36xx_hal_msg_header header;
3012
3013 /* success or failure */
3014 u32 status;
3015};
3016
3017struct tl_hal_flush_ac_req_msg {
3018 struct wcn36xx_hal_msg_header header;
3019
3020 /* Station Index. originates from HAL */
3021 u8 sta_id;
3022
3023 /* TID for which the transmit queue is being flushed */
3024 u8 tid;
3025};
3026
3027struct tl_hal_flush_ac_rsp_msg {
3028 struct wcn36xx_hal_msg_header header;
3029
3030 /* Station Index. originates from HAL */
3031 u8 sta_id;
3032
3033 /* TID for which the transmit queue is being flushed */
3034 u8 tid;
3035
3036 /* success or failure */
3037 u32 status;
3038};
3039
3040struct wcn36xx_hal_enter_imps_req_msg {
3041 struct wcn36xx_hal_msg_header header;
3042};
3043
3044struct wcn36xx_hal_exit_imps_req {
3045 struct wcn36xx_hal_msg_header header;
3046};
3047
3048struct wcn36xx_hal_enter_bmps_req_msg {
3049 struct wcn36xx_hal_msg_header header;
3050
3051 u8 bss_index;
3052
3053 /* TBTT value derived from the last beacon */
3054#ifndef BUILD_QWPTTSTATIC
3055 u64 tbtt;
3056#endif
3057 u8 dtim_count;
3058
3059 /* DTIM period given to HAL during association may not be valid, if
3060 * association is based on ProbeRsp instead of beacon. */
3061 u8 dtim_period;
3062
3063 /* For CCX and 11R Roaming */
3064 u32 rssi_filter_period;
3065
3066 u32 num_beacon_per_rssi_average;
3067 u8 rssi_filter_enable;
3068} __packed;
3069
3070struct wcn36xx_hal_exit_bmps_req_msg {
3071 struct wcn36xx_hal_msg_header header;
3072
3073 u8 send_data_null;
3074 u8 bss_index;
3075} __packed;
3076
3077struct wcn36xx_hal_missed_beacon_ind_msg {
3078 struct wcn36xx_hal_msg_header header;
3079
3080 u8 bss_index;
3081} __packed;
3082
3083/* Beacon Filtering data structures */
3084
3085/* The above structure would be followed by multiple of below mentioned
3086 * structure
3087 */
3088struct beacon_filter_ie {
3089 u8 element_id;
3090 u8 check_ie_presence;
3091 u8 offset;
3092 u8 value;
3093 u8 bitmask;
3094 u8 ref;
3095};
3096
3097struct wcn36xx_hal_add_bcn_filter_req_msg {
3098 struct wcn36xx_hal_msg_header header;
3099
3100 u16 capability_info;
3101 u16 capability_mask;
3102 u16 beacon_interval;
3103 u16 ie_num;
3104 u8 bss_index;
3105 u8 reserved;
3106};
3107
3108struct wcn36xx_hal_rem_bcn_filter_req {
3109 struct wcn36xx_hal_msg_header header;
3110
3111 u8 ie_Count;
3112 u8 rem_ie_id[1];
3113};
3114
3115#define WCN36XX_HAL_IPV4_ARP_REPLY_OFFLOAD 0
3116#define WCN36XX_HAL_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD 1
3117#define WCN36XX_HAL_IPV6_NS_OFFLOAD 2
3118#define WCN36XX_HAL_IPV6_ADDR_LEN 16
3119#define WCN36XX_HAL_OFFLOAD_DISABLE 0
3120#define WCN36XX_HAL_OFFLOAD_ENABLE 1
3121#define WCN36XX_HAL_OFFLOAD_BCAST_FILTER_ENABLE 0x2
3122#define WCN36XX_HAL_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE \
3123 (HAL_OFFLOAD_ENABLE|HAL_OFFLOAD_BCAST_FILTER_ENABLE)
3124
3125struct wcn36xx_hal_ns_offload_params {
3126 u8 src_ipv6_addr[WCN36XX_HAL_IPV6_ADDR_LEN];
3127 u8 self_ipv6_addr[WCN36XX_HAL_IPV6_ADDR_LEN];
3128
3129 /* Only support 2 possible Network Advertisement IPv6 address */
3130 u8 target_ipv6_addr1[WCN36XX_HAL_IPV6_ADDR_LEN];
3131 u8 target_ipv6_addr2[WCN36XX_HAL_IPV6_ADDR_LEN];
3132
3133 u8 self_addr[ETH_ALEN];
3134 u8 src_ipv6_addr_valid:1;
3135 u8 target_ipv6_addr1_valid:1;
3136 u8 target_ipv6_addr2_valid:1;
3137 u8 reserved1:5;
3138
3139 /* make it DWORD aligned */
3140 u8 reserved2;
3141
3142 /* slot index for this offload */
3143 u32 slot_index;
3144 u8 bss_index;
3145};
3146
3147struct wcn36xx_hal_host_offload_req {
3148 u8 offload_Type;
3149
3150 /* enable or disable */
3151 u8 enable;
3152
3153 union {
3154 u8 host_ipv4_addr[4];
3155 u8 host_ipv6_addr[WCN36XX_HAL_IPV6_ADDR_LEN];
3156 } u;
3157};
3158
3159struct wcn36xx_hal_host_offload_req_msg {
3160 struct wcn36xx_hal_msg_header header;
3161 struct wcn36xx_hal_host_offload_req host_offload_params;
3162 struct wcn36xx_hal_ns_offload_params ns_offload_params;
3163};
3164
3165/* Packet Types. */
3166#define WCN36XX_HAL_KEEP_ALIVE_NULL_PKT 1
3167#define WCN36XX_HAL_KEEP_ALIVE_UNSOLICIT_ARP_RSP 2
3168
3169/* Enable or disable keep alive */
3170#define WCN36XX_HAL_KEEP_ALIVE_DISABLE 0
3171#define WCN36XX_HAL_KEEP_ALIVE_ENABLE 1
3172#define WCN36XX_KEEP_ALIVE_TIME_PERIOD 30 /* unit: s */
3173
3174/* Keep Alive request. */
3175struct wcn36xx_hal_keep_alive_req_msg {
3176 struct wcn36xx_hal_msg_header header;
3177
3178 u8 packet_type;
3179 u32 time_period;
3180 u8 host_ipv4_addr[WCN36XX_HAL_IPV4_ADDR_LEN];
3181 u8 dest_ipv4_addr[WCN36XX_HAL_IPV4_ADDR_LEN];
3182 u8 dest_addr[ETH_ALEN];
3183 u8 bss_index;
3184} __packed;
3185
3186struct wcn36xx_hal_rssi_threshold_req_msg {
3187 struct wcn36xx_hal_msg_header header;
3188
3189 s8 threshold1:8;
3190 s8 threshold2:8;
3191 s8 threshold3:8;
3192 u8 thres1_pos_notify:1;
3193 u8 thres1_neg_notify:1;
3194 u8 thres2_pos_notify:1;
3195 u8 thres2_neg_notify:1;
3196 u8 thres3_pos_notify:1;
3197 u8 thres3_neg_notify:1;
3198 u8 reserved10:2;
3199};
3200
3201struct wcn36xx_hal_enter_uapsd_req_msg {
3202 struct wcn36xx_hal_msg_header header;
3203
3204 u8 bk_delivery:1;
3205 u8 be_delivery:1;
3206 u8 vi_delivery:1;
3207 u8 vo_delivery:1;
3208 u8 bk_trigger:1;
3209 u8 be_trigger:1;
3210 u8 vi_trigger:1;
3211 u8 vo_trigger:1;
3212 u8 bss_index;
3213};
3214
3215struct wcn36xx_hal_exit_uapsd_req_msg {
3216 struct wcn36xx_hal_msg_header header;
3217 u8 bss_index;
3218};
3219
3220#define WCN36XX_HAL_WOWL_BCAST_PATTERN_MAX_SIZE 128
3221#define WCN36XX_HAL_WOWL_BCAST_MAX_NUM_PATTERNS 16
3222
3223struct wcn36xx_hal_wowl_add_bcast_ptrn_req_msg {
3224 struct wcn36xx_hal_msg_header header;
3225
3226 /* Pattern ID */
3227 u8 id;
3228
3229 /* Pattern byte offset from beginning of the 802.11 packet to start
3230 * of the wake-up pattern */
3231 u8 byte_Offset;
3232
3233 /* Non-Zero Pattern size */
3234 u8 size;
3235
3236 /* Pattern */
3237 u8 pattern[WCN36XX_HAL_WOWL_BCAST_PATTERN_MAX_SIZE];
3238
3239 /* Non-zero pattern mask size */
3240 u8 mask_size;
3241
3242 /* Pattern mask */
3243 u8 mask[WCN36XX_HAL_WOWL_BCAST_PATTERN_MAX_SIZE];
3244
3245 /* Extra pattern */
3246 u8 extra[WCN36XX_HAL_WOWL_BCAST_PATTERN_MAX_SIZE];
3247
3248 /* Extra pattern mask */
3249 u8 mask_extra[WCN36XX_HAL_WOWL_BCAST_PATTERN_MAX_SIZE];
3250
3251 u8 bss_index;
3252};
3253
3254struct wcn36xx_hal_wow_del_bcast_ptrn_req_msg {
3255 struct wcn36xx_hal_msg_header header;
3256
3257 /* Pattern ID of the wakeup pattern to be deleted */
3258 u8 id;
3259 u8 bss_index;
3260};
3261
3262struct wcn36xx_hal_wowl_enter_req_msg {
3263 struct wcn36xx_hal_msg_header header;
3264
3265 /* Enables/disables magic packet filtering */
3266 u8 magic_packet_enable;
3267
3268 /* Magic pattern */
3269 u8 magic_pattern[ETH_ALEN];
3270
3271 /* Enables/disables packet pattern filtering in firmware. Enabling
3272 * this flag enables broadcast pattern matching in Firmware. If
3273 * unicast pattern matching is also desired,
3274 * ucUcastPatternFilteringEnable flag must be set tot true as well
3275 */
3276 u8 pattern_filtering_enable;
3277
3278 /* Enables/disables unicast packet pattern filtering. This flag
3279 * specifies whether we want to do pattern match on unicast packets
3280 * as well and not just broadcast packets. This flag has no effect
3281 * if the ucPatternFilteringEnable (main controlling flag) is set
3282 * to false
3283 */
3284 u8 ucast_pattern_filtering_enable;
3285
3286 /* This configuration is valid only when magicPktEnable=1. It
3287 * requests hardware to wake up when it receives the Channel Switch
3288 * Action Frame.
3289 */
3290 u8 wow_channel_switch_receive;
3291
3292 /* This configuration is valid only when magicPktEnable=1. It
3293 * requests hardware to wake up when it receives the
3294 * Deauthentication Frame.
3295 */
3296 u8 wow_deauth_receive;
3297
3298 /* This configuration is valid only when magicPktEnable=1. It
3299 * requests hardware to wake up when it receives the Disassociation
3300 * Frame.
3301 */
3302 u8 wow_disassoc_receive;
3303
3304 /* This configuration is valid only when magicPktEnable=1. It
3305 * requests hardware to wake up when it has missed consecutive
3306 * beacons. This is a hardware register configuration (NOT a
3307 * firmware configuration).
3308 */
3309 u8 wow_max_missed_beacons;
3310
3311 /* This configuration is valid only when magicPktEnable=1. This is
3312 * a timeout value in units of microsec. It requests hardware to
3313 * unconditionally wake up after it has stayed in WoWLAN mode for
3314 * some time. Set 0 to disable this feature.
3315 */
3316 u8 wow_max_sleep;
3317
3318 /* This configuration directs the WoW packet filtering to look for
3319 * EAP-ID requests embedded in EAPOL frames and use this as a wake
3320 * source.
3321 */
3322 u8 wow_eap_id_request_enable;
3323
3324 /* This configuration directs the WoW packet filtering to look for
3325 * EAPOL-4WAY requests and use this as a wake source.
3326 */
3327 u8 wow_eapol_4way_enable;
3328
3329 /* This configuration allows a host wakeup on an network scan
3330 * offload match.
3331 */
3332 u8 wow_net_scan_offload_match;
3333
3334 /* This configuration allows a host wakeup on any GTK rekeying
3335 * error.
3336 */
3337 u8 wow_gtk_rekey_error;
3338
3339 /* This configuration allows a host wakeup on BSS connection loss.
3340 */
3341 u8 wow_bss_connection_loss;
3342
3343 u8 bss_index;
3344};
3345
3346struct wcn36xx_hal_wowl_exit_req_msg {
3347 struct wcn36xx_hal_msg_header header;
3348
3349 u8 bss_index;
3350};
3351
3352struct wcn36xx_hal_get_rssi_req_msg {
3353 struct wcn36xx_hal_msg_header header;
3354};
3355
3356struct wcn36xx_hal_get_roam_rssi_req_msg {
3357 struct wcn36xx_hal_msg_header header;
3358
3359 /* Valid STA Idx for per STA stats request */
3360 u32 sta_id;
3361};
3362
3363struct wcn36xx_hal_set_uapsd_ac_params_req_msg {
3364 struct wcn36xx_hal_msg_header header;
3365
3366 /* STA index */
3367 u8 sta_idx;
3368
3369 /* Access Category */
3370 u8 ac;
3371
3372 /* User Priority */
3373 u8 up;
3374
3375 /* Service Interval */
3376 u32 service_interval;
3377
3378 /* Suspend Interval */
3379 u32 suspend_interval;
3380
3381 /* Delay Interval */
3382 u32 delay_interval;
3383};
3384
3385struct wcn36xx_hal_configure_rxp_filter_req_msg {
3386 struct wcn36xx_hal_msg_header header;
3387
3388 u8 set_mcst_bcst_filter_setting;
3389 u8 set_mcst_bcst_filter;
3390};
3391
3392struct wcn36xx_hal_enter_imps_rsp_msg {
3393 struct wcn36xx_hal_msg_header header;
3394
3395 /* success or failure */
3396 u32 status;
3397};
3398
3399struct wcn36xx_hal_exit_imps_rsp_msg {
3400 struct wcn36xx_hal_msg_header header;
3401
3402 /* success or failure */
3403 u32 status;
3404};
3405
3406struct wcn36xx_hal_enter_bmps_rsp_msg {
3407 struct wcn36xx_hal_msg_header header;
3408
3409 /* success or failure */
3410 u32 status;
3411
3412 u8 bss_index;
3413} __packed;
3414
3415struct wcn36xx_hal_exit_bmps_rsp_msg {
3416 struct wcn36xx_hal_msg_header header;
3417
3418 /* success or failure */
3419 u32 status;
3420
3421 u8 bss_index;
3422} __packed;
3423
3424struct wcn36xx_hal_enter_uapsd_rsp_msg {
3425 struct wcn36xx_hal_msg_header header;
3426
3427 /* success or failure */
3428 u32 status;
3429
3430 u8 bss_index;
3431};
3432
3433struct wcn36xx_hal_exit_uapsd_rsp_msg {
3434 struct wcn36xx_hal_msg_header header;
3435
3436 /* success or failure */
3437 u32 status;
3438
3439 u8 bss_index;
3440};
3441
3442struct wcn36xx_hal_rssi_notification_ind_msg {
3443 struct wcn36xx_hal_msg_header header;
3444
3445 u32 rssi_thres1_pos_cross:1;
3446 u32 rssi_thres1_neg_cross:1;
3447 u32 rssi_thres2_pos_cross:1;
3448 u32 rssi_thres2_neg_cross:1;
3449 u32 rssi_thres3_pos_cross:1;
3450 u32 rssi_thres3_neg_cross:1;
3451 u32 avg_rssi:8;
3452 u32 reserved:18;
3453
3454};
3455
3456struct wcn36xx_hal_get_rssio_rsp_msg {
3457 struct wcn36xx_hal_msg_header header;
3458
3459 /* success or failure */
3460 u32 status;
3461 s8 rssi;
3462
3463};
3464
3465struct wcn36xx_hal_get_roam_rssi_rsp_msg {
3466 struct wcn36xx_hal_msg_header header;
3467
3468 /* success or failure */
3469 u32 status;
3470
3471 u8 sta_id;
3472 s8 rssi;
3473};
3474
3475struct wcn36xx_hal_wowl_enter_rsp_msg {
3476 struct wcn36xx_hal_msg_header header;
3477
3478 /* success or failure */
3479 u32 status;
3480 u8 bss_index;
3481};
3482
3483struct wcn36xx_hal_wowl_exit_rsp_msg {
3484 struct wcn36xx_hal_msg_header header;
3485
3486 /* success or failure */
3487 u32 status;
3488 u8 bss_index;
3489};
3490
3491struct wcn36xx_hal_add_bcn_filter_rsp_msg {
3492 struct wcn36xx_hal_msg_header header;
3493
3494 /* success or failure */
3495 u32 status;
3496};
3497
3498struct wcn36xx_hal_rem_bcn_filter_rsp_msg {
3499 struct wcn36xx_hal_msg_header header;
3500
3501 /* success or failure */
3502 u32 status;
3503};
3504
3505struct wcn36xx_hal_add_wowl_bcast_ptrn_rsp_msg {
3506 struct wcn36xx_hal_msg_header header;
3507
3508 /* success or failure */
3509 u32 status;
3510 u8 bss_index;
3511};
3512
3513struct wcn36xx_hal_del_wowl_bcast_ptrn_rsp_msg {
3514 struct wcn36xx_hal_msg_header header;
3515
3516 /* success or failure */
3517 u32 status;
3518 u8 bss_index;
3519};
3520
3521struct wcn36xx_hal_host_offload_rsp_msg {
3522 struct wcn36xx_hal_msg_header header;
3523
3524 /* success or failure */
3525 u32 status;
3526};
3527
3528struct wcn36xx_hal_keep_alive_rsp_msg {
3529 struct wcn36xx_hal_msg_header header;
3530
3531 /* success or failure */
3532 u32 status;
3533};
3534
3535struct wcn36xx_hal_set_rssi_thresh_rsp_msg {
3536 struct wcn36xx_hal_msg_header header;
3537
3538 /* success or failure */
3539 u32 status;
3540};
3541
3542struct wcn36xx_hal_set_uapsd_ac_params_rsp_msg {
3543 struct wcn36xx_hal_msg_header header;
3544
3545 /* success or failure */
3546 u32 status;
3547};
3548
3549struct wcn36xx_hal_configure_rxp_filter_rsp_msg {
3550 struct wcn36xx_hal_msg_header header;
3551
3552 /* success or failure */
3553 u32 status;
3554};
3555
3556struct set_max_tx_pwr_req {
3557 struct wcn36xx_hal_msg_header header;
3558
3559 /* BSSID is needed to identify which session issued this request.
3560 * As the request has power constraints, this should be applied
3561 * only to that session */
3562 u8 bssid[ETH_ALEN];
3563
3564 u8 self_addr[ETH_ALEN];
3565
3566 /* In request, power == MaxTx power to be used. */
3567 u8 power;
3568};
3569
3570struct set_max_tx_pwr_rsp_msg {
3571 struct wcn36xx_hal_msg_header header;
3572
3573 /* power == tx power used for management frames */
3574 u8 power;
3575
3576 /* success or failure */
3577 u32 status;
3578};
3579
3580struct set_tx_pwr_req_msg {
3581 struct wcn36xx_hal_msg_header header;
3582
3583 /* TX Power in milli watts */
3584 u32 tx_power;
3585
3586 u8 bss_index;
3587};
3588
3589struct set_tx_pwr_rsp_msg {
3590 struct wcn36xx_hal_msg_header header;
3591
3592 /* success or failure */
3593 u32 status;
3594};
3595
3596struct get_tx_pwr_req_msg {
3597 struct wcn36xx_hal_msg_header header;
3598
3599 u8 sta_id;
3600};
3601
3602struct get_tx_pwr_rsp_msg {
3603 struct wcn36xx_hal_msg_header header;
3604
3605 /* success or failure */
3606 u32 status;
3607
3608 /* TX Power in milli watts */
3609 u32 tx_power;
3610};
3611
3612struct set_p2p_gonoa_req_msg {
3613 struct wcn36xx_hal_msg_header header;
3614
3615 u8 opp_ps;
3616 u32 ct_window;
3617 u8 count;
3618 u32 duration;
3619 u32 interval;
3620 u32 single_noa_duration;
3621 u8 ps_selection;
3622};
3623
3624struct set_p2p_gonoa_rsp_msg {
3625 struct wcn36xx_hal_msg_header header;
3626
3627 /* success or failure */
3628 u32 status;
3629};
3630
3631struct wcn36xx_hal_add_sta_self_req {
3632 struct wcn36xx_hal_msg_header header;
3633
3634 u8 self_addr[ETH_ALEN];
3635 u32 status;
3636} __packed;
3637
3638struct wcn36xx_hal_add_sta_self_rsp_msg {
3639 struct wcn36xx_hal_msg_header header;
3640
3641 /* success or failure */
3642 u32 status;
3643
3644 /* Self STA Index */
3645 u8 self_sta_index;
3646
3647 /* DPU Index (IGTK, PTK, GTK all same) */
3648 u8 dpu_index;
3649
3650 /* DPU Signature */
3651 u8 dpu_signature;
3652} __packed;
3653
3654struct wcn36xx_hal_del_sta_self_req_msg {
3655 struct wcn36xx_hal_msg_header header;
3656
3657 u8 self_addr[ETH_ALEN];
3658} __packed;
3659
3660struct wcn36xx_hal_del_sta_self_rsp_msg {
3661 struct wcn36xx_hal_msg_header header;
3662
3663 /*success or failure */
3664 u32 status;
3665
3666 u8 self_addr[ETH_ALEN];
3667} __packed;
3668
3669struct aggr_add_ts_req {
3670 struct wcn36xx_hal_msg_header header;
3671
3672 /* Station Index */
3673 u16 sta_idx;
3674
3675 /* TSPEC handler uniquely identifying a TSPEC for a STA in a BSS.
3676 * This will carry the bitmap with the bit positions representing
3677 * different AC.s */
3678 u16 tspec_index;
3679
3680 /* Tspec info per AC To program TPE with required parameters */
3681 struct wcn36xx_hal_tspec_ie tspec[WCN36XX_HAL_MAX_AC];
3682
3683 /* U-APSD Flags: 1b per AC. Encoded as follows:
3684 b7 b6 b5 b4 b3 b2 b1 b0 =
3685 X X X X BE BK VI VO */
3686 u8 uapsd;
3687
3688 /* These parameters are for all the access categories */
3689
3690 /* Service Interval */
3691 u32 service_interval[WCN36XX_HAL_MAX_AC];
3692
3693 /* Suspend Interval */
3694 u32 suspend_interval[WCN36XX_HAL_MAX_AC];
3695
3696 /* Delay Interval */
3697 u32 delay_interval[WCN36XX_HAL_MAX_AC];
3698};
3699
3700struct aggr_add_ts_rsp_msg {
3701 struct wcn36xx_hal_msg_header header;
3702
3703 /* success or failure */
3704 u32 status0;
3705
3706 /* FIXME PRIMA for future use for 11R */
3707 u32 status1;
3708};
3709
3710struct wcn36xx_hal_configure_apps_cpu_wakeup_state_req_msg {
3711 struct wcn36xx_hal_msg_header header;
3712
3713 u8 is_apps_cpu_awake;
3714};
3715
3716struct wcn36xx_hal_configure_apps_cpu_wakeup_state_rsp_msg {
3717 struct wcn36xx_hal_msg_header header;
3718
3719 /* success or failure */
3720 u32 status;
3721};
3722
3723struct wcn36xx_hal_dump_cmd_req_msg {
3724 struct wcn36xx_hal_msg_header header;
3725
3726 u32 arg1;
3727 u32 arg2;
3728 u32 arg3;
3729 u32 arg4;
3730 u32 arg5;
3731} __packed;
3732
3733struct wcn36xx_hal_dump_cmd_rsp_msg {
3734 struct wcn36xx_hal_msg_header header;
3735
3736 /* success or failure */
3737 u32 status;
3738
3739 /* Length of the responce message */
3740 u32 rsp_length;
3741
3742 /* FIXME: Currently considering the the responce will be less than
3743 * 100bytes */
3744 u8 rsp_buffer[DUMPCMD_RSP_BUFFER];
3745} __packed;
3746
3747#define WLAN_COEX_IND_DATA_SIZE (4)
3748#define WLAN_COEX_IND_TYPE_DISABLE_HB_MONITOR (0)
3749#define WLAN_COEX_IND_TYPE_ENABLE_HB_MONITOR (1)
3750
3751struct coex_ind_msg {
3752 struct wcn36xx_hal_msg_header header;
3753
3754 /* Coex Indication Type */
3755 u32 type;
3756
3757 /* Coex Indication Data */
3758 u32 data[WLAN_COEX_IND_DATA_SIZE];
3759};
3760
3761struct wcn36xx_hal_tx_compl_ind_msg {
3762 struct wcn36xx_hal_msg_header header;
3763
3764 /* Tx Complete Indication Success or Failure */
3765 u32 status;
3766};
3767
3768struct wcn36xx_hal_wlan_host_suspend_ind_msg {
3769 struct wcn36xx_hal_msg_header header;
3770
3771 u32 configured_mcst_bcst_filter_setting;
3772 u32 active_session_count;
3773};
3774
3775struct wcn36xx_hal_wlan_exclude_unencrpted_ind_msg {
3776 struct wcn36xx_hal_msg_header header;
3777
3778 u8 dot11_exclude_unencrypted;
3779 u8 bssid[ETH_ALEN];
3780};
3781
3782struct noa_attr_ind_msg {
3783 struct wcn36xx_hal_msg_header header;
3784
3785 u8 index;
3786 u8 opp_ps_flag;
3787 u16 ctwin;
3788
3789 u16 noa1_interval_count;
3790 u16 bss_index;
3791 u32 noa1_duration;
3792 u32 noa1_interval;
3793 u32 noa1_starttime;
3794
3795 u16 noa2_interval_count;
3796 u16 reserved2;
3797 u32 noa2_duration;
3798 u32 noa2_interval;
3799 u32 noa2_start_time;
3800
3801 u32 status;
3802};
3803
3804struct noa_start_ind_msg {
3805 struct wcn36xx_hal_msg_header header;
3806
3807 u32 status;
3808 u32 bss_index;
3809};
3810
3811struct wcn36xx_hal_wlan_host_resume_req_msg {
3812 struct wcn36xx_hal_msg_header header;
3813
3814 u8 configured_mcst_bcst_filter_setting;
3815};
3816
3817struct wcn36xx_hal_host_resume_rsp_msg {
3818 struct wcn36xx_hal_msg_header header;
3819
3820 /* success or failure */
3821 u32 status;
3822};
3823
3824struct wcn36xx_hal_del_ba_ind_msg {
3825 struct wcn36xx_hal_msg_header header;
3826
3827 u16 sta_idx;
3828
3829 /* Peer MAC Address, whose BA session has timed out */
3830 u8 peer_addr[ETH_ALEN];
3831
3832 /* TID for which a BA session timeout is being triggered */
3833 u8 ba_tid;
3834
3835 /* DELBA direction
3836 * 1 - Originator
3837 * 0 - Recipient
3838 */
3839 u8 direction;
3840
3841 u32 reason_code;
3842
3843 /* TO SUPPORT BT-AMP */
3844 u8 bssid[ETH_ALEN];
3845};
3846
3847/* PNO Messages */
3848
3849/* Max number of channels that a network can be found on */
3850#define WCN36XX_HAL_PNO_MAX_NETW_CHANNELS 26
3851
3852/* Max number of channels that a network can be found on */
3853#define WCN36XX_HAL_PNO_MAX_NETW_CHANNELS_EX 60
3854
3855/* Maximum numbers of networks supported by PNO */
3856#define WCN36XX_HAL_PNO_MAX_SUPP_NETWORKS 16
3857
3858/* The number of scan time intervals that can be programmed into PNO */
3859#define WCN36XX_HAL_PNO_MAX_SCAN_TIMERS 10
3860
3861/* Maximum size of the probe template */
3862#define WCN36XX_HAL_PNO_MAX_PROBE_SIZE 450
3863
3864/* Type of PNO enabling:
3865 *
3866 * Immediate - scanning will start immediately and PNO procedure will be
3867 * repeated based on timer
3868 *
3869 * Suspend - scanning will start at suspend
3870 *
3871 * Resume - scanning will start on system resume
3872 */
3873enum pno_mode {
3874 PNO_MODE_IMMEDIATE,
3875 PNO_MODE_ON_SUSPEND,
3876 PNO_MODE_ON_RESUME,
3877 PNO_MODE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
3878};
3879
3880/* Authentication type */
3881enum auth_type {
3882 AUTH_TYPE_ANY = 0,
3883 AUTH_TYPE_OPEN_SYSTEM = 1,
3884
3885 /* Upper layer authentication types */
3886 AUTH_TYPE_WPA = 2,
3887 AUTH_TYPE_WPA_PSK = 3,
3888
3889 AUTH_TYPE_RSN = 4,
3890 AUTH_TYPE_RSN_PSK = 5,
3891 AUTH_TYPE_FT_RSN = 6,
3892 AUTH_TYPE_FT_RSN_PSK = 7,
3893 AUTH_TYPE_WAPI_WAI_CERTIFICATE = 8,
3894 AUTH_TYPE_WAPI_WAI_PSK = 9,
3895
3896 AUTH_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
3897};
3898
3899/* Encryption type */
3900enum ed_type {
3901 ED_ANY = 0,
3902 ED_NONE = 1,
3903 ED_WEP = 2,
3904 ED_TKIP = 3,
3905 ED_CCMP = 4,
3906 ED_WPI = 5,
3907
3908 ED_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
3909};
3910
3911/* SSID broadcast type */
3912enum ssid_bcast_type {
3913 BCAST_UNKNOWN = 0,
3914 BCAST_NORMAL = 1,
3915 BCAST_HIDDEN = 2,
3916
3917 BCAST_TYPE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE
3918};
3919
3920/* The network description for which PNO will have to look for */
3921struct network_type {
3922 /* SSID of the BSS */
3923 struct wcn36xx_hal_mac_ssid ssid;
3924
3925 /* Authentication type for the network */
3926 enum auth_type authentication;
3927
3928 /* Encryption type for the network */
3929 enum ed_type encryption;
3930
3931 /* Indicate the channel on which the Network can be found 0 - if
3932 * all channels */
3933 u8 channel_count;
3934 u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS];
3935
3936 /* Indicates the RSSI threshold for the network to be considered */
3937 u8 rssi_threshold;
3938};
3939
3940struct scan_timer {
3941 /* How much it should wait */
3942 u32 value;
3943
3944 /* How many times it should repeat that wait value 0 - keep using
3945 * this timer until PNO is disabled */
3946 u32 repeat;
3947
3948 /* e.g: 2 3 4 0 - it will wait 2s between consecutive scans for 3
3949 * times - after that it will wait 4s between consecutive scans
3950 * until disabled */
3951};
3952
3953/* The network parameters to be sent to the PNO algorithm */
3954struct scan_timers_type {
3955 /* set to 0 if you wish for PNO to use its default telescopic timer */
3956 u8 count;
3957
3958 /* A set value represents the amount of time that PNO will wait
3959 * between two consecutive scan procedures If the desired is for a
3960 * uniform timer that fires always at the exact same interval - one
3961 * single value is to be set If there is a desire for a more
3962 * complex - telescopic like timer multiple values can be set -
3963 * once PNO reaches the end of the array it will continue scanning
3964 * at intervals presented by the last value */
3965 struct scan_timer values[WCN36XX_HAL_PNO_MAX_SCAN_TIMERS];
3966};
3967
3968/* Preferred network list request */
3969struct set_pref_netw_list_req {
3970 struct wcn36xx_hal_msg_header header;
3971
3972 /* Enable PNO */
3973 u32 enable;
3974
3975 /* Immediate, On Suspend, On Resume */
3976 enum pno_mode mode;
3977
3978 /* Number of networks sent for PNO */
3979 u32 networks_count;
3980
3981 /* The networks that PNO needs to look for */
3982 struct network_type networks[WCN36XX_HAL_PNO_MAX_SUPP_NETWORKS];
3983
3984 /* The scan timers required for PNO */
3985 struct scan_timers_type scan_timers;
3986
3987 /* Probe template for 2.4GHz band */
3988 u16 band_24g_probe_size;
3989 u8 band_24g_probe_template[WCN36XX_HAL_PNO_MAX_PROBE_SIZE];
3990
3991 /* Probe template for 5GHz band */
3992 u16 band_5g_probe_size;
3993 u8 band_5g_probe_template[WCN36XX_HAL_PNO_MAX_PROBE_SIZE];
3994};
3995
3996/* The network description for which PNO will have to look for */
3997struct network_type_new {
3998 /* SSID of the BSS */
3999 struct wcn36xx_hal_mac_ssid ssid;
4000
4001 /* Authentication type for the network */
4002 enum auth_type authentication;
4003
4004 /* Encryption type for the network */
4005 enum ed_type encryption;
4006
4007 /* SSID broadcast type, normal, hidden or unknown */
4008 enum ssid_bcast_type bcast_network_type;
4009
4010 /* Indicate the channel on which the Network can be found 0 - if
4011 * all channels */
4012 u8 channel_count;
4013 u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS];
4014
4015 /* Indicates the RSSI threshold for the network to be considered */
4016 u8 rssi_threshold;
4017};
4018
4019/* Preferred network list request new */
4020struct set_pref_netw_list_req_new {
4021 struct wcn36xx_hal_msg_header header;
4022
4023 /* Enable PNO */
4024 u32 enable;
4025
4026 /* Immediate, On Suspend, On Resume */
4027 enum pno_mode mode;
4028
4029 /* Number of networks sent for PNO */
4030 u32 networks_count;
4031
4032 /* The networks that PNO needs to look for */
4033 struct network_type_new networks[WCN36XX_HAL_PNO_MAX_SUPP_NETWORKS];
4034
4035 /* The scan timers required for PNO */
4036 struct scan_timers_type scan_timers;
4037
4038 /* Probe template for 2.4GHz band */
4039 u16 band_24g_probe_size;
4040 u8 band_24g_probe_template[WCN36XX_HAL_PNO_MAX_PROBE_SIZE];
4041
4042 /* Probe template for 5GHz band */
4043 u16 band_5g_probe_size;
4044 u8 band_5g_probe_template[WCN36XX_HAL_PNO_MAX_PROBE_SIZE];
4045};
4046
4047/* Preferred network list response */
4048struct set_pref_netw_list_resp {
4049 struct wcn36xx_hal_msg_header header;
4050
4051 /* status of the request - just to indicate that PNO has
4052 * acknowledged the request and will start scanning */
4053 u32 status;
4054};
4055
4056/* Preferred network found indication */
4057struct pref_netw_found_ind {
4058
4059 struct wcn36xx_hal_msg_header header;
4060
4061 /* Network that was found with the highest RSSI */
4062 struct wcn36xx_hal_mac_ssid ssid;
4063
4064 /* Indicates the RSSI */
4065 u8 rssi;
4066};
4067
4068/* RSSI Filter request */
4069struct set_rssi_filter_req {
4070 struct wcn36xx_hal_msg_header header;
4071
4072 /* RSSI Threshold */
4073 u8 rssi_threshold;
4074};
4075
4076/* Set RSSI filter resp */
4077struct set_rssi_filter_resp {
4078 struct wcn36xx_hal_msg_header header;
4079
4080 /* status of the request */
4081 u32 status;
4082};
4083
4084/* Update scan params - sent from host to PNO to be used during PNO
4085 * scanningx */
4086struct wcn36xx_hal_update_scan_params_req {
4087
4088 struct wcn36xx_hal_msg_header header;
4089
4090 /* Host setting for 11d */
4091 u8 dot11d_enabled;
4092
4093 /* Lets PNO know that host has determined the regulatory domain */
4094 u8 dot11d_resolved;
4095
4096 /* Channels on which PNO is allowed to scan */
4097 u8 channel_count;
4098 u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS];
4099
4100 /* Minimum channel time */
4101 u16 active_min_ch_time;
4102
4103 /* Maximum channel time */
4104 u16 active_max_ch_time;
4105
4106 /* Minimum channel time */
4107 u16 passive_min_ch_time;
4108
4109 /* Maximum channel time */
4110 u16 passive_max_ch_time;
4111
4112 /* Cb State */
4113 enum phy_chan_bond_state state;
4114} __packed;
4115
4116/* Update scan params - sent from host to PNO to be used during PNO
4117 * scanningx */
4118struct update_scan_params_req_ex {
4119
4120 struct wcn36xx_hal_msg_header header;
4121
4122 /* Host setting for 11d */
4123 u8 dot11d_enabled;
4124
4125 /* Lets PNO know that host has determined the regulatory domain */
4126 u8 dot11d_resolved;
4127
4128 /* Channels on which PNO is allowed to scan */
4129 u8 channel_count;
4130 u8 channels[WCN36XX_HAL_PNO_MAX_NETW_CHANNELS_EX];
4131
4132 /* Minimum channel time */
4133 u16 active_min_ch_time;
4134
4135 /* Maximum channel time */
4136 u16 active_max_ch_time;
4137
4138 /* Minimum channel time */
4139 u16 passive_min_ch_time;
4140
4141 /* Maximum channel time */
4142 u16 passive_max_ch_time;
4143
4144 /* Cb State */
4145 enum phy_chan_bond_state state;
4146};
4147
4148/* Update scan params - sent from host to PNO to be used during PNO
4149 * scanningx */
4150struct wcn36xx_hal_update_scan_params_resp {
4151
4152 struct wcn36xx_hal_msg_header header;
4153
4154 /* status of the request */
4155 u32 status;
4156} __packed;
4157
4158struct wcn36xx_hal_set_tx_per_tracking_req_msg {
4159 struct wcn36xx_hal_msg_header header;
4160
4161 /* 0: disable, 1:enable */
4162 u8 tx_per_tracking_enable;
4163
4164 /* Check period, unit is sec. */
4165 u8 tx_per_tracking_period;
4166
4167 /* (Fail TX packet)/(Total TX packet) ratio, the unit is 10%. */
4168 u8 tx_per_tracking_ratio;
4169
4170 /* A watermark of check number, once the tx packet exceed this
4171 * number, we do the check, default is 5 */
4172 u32 tx_per_tracking_watermark;
4173};
4174
4175struct wcn36xx_hal_set_tx_per_tracking_rsp_msg {
4176 struct wcn36xx_hal_msg_header header;
4177
4178 /* success or failure */
4179 u32 status;
4180
4181};
4182
4183struct tx_per_hit_ind_msg {
4184 struct wcn36xx_hal_msg_header header;
4185};
4186
4187/* Packet Filtering Definitions Begin */
4188#define WCN36XX_HAL_PROTOCOL_DATA_LEN 8
4189#define WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS 240
4190#define WCN36XX_HAL_MAX_NUM_FILTERS 20
4191#define WCN36XX_HAL_MAX_CMP_PER_FILTER 10
4192
4193enum wcn36xx_hal_receive_packet_filter_type {
4194 HAL_RCV_FILTER_TYPE_INVALID,
4195 HAL_RCV_FILTER_TYPE_FILTER_PKT,
4196 HAL_RCV_FILTER_TYPE_BUFFER_PKT,
4197 HAL_RCV_FILTER_TYPE_MAX_ENUM_SIZE
4198};
4199
4200enum wcn36xx_hal_rcv_pkt_flt_protocol_type {
4201 HAL_FILTER_PROTO_TYPE_INVALID,
4202 HAL_FILTER_PROTO_TYPE_MAC,
4203 HAL_FILTER_PROTO_TYPE_ARP,
4204 HAL_FILTER_PROTO_TYPE_IPV4,
4205 HAL_FILTER_PROTO_TYPE_IPV6,
4206 HAL_FILTER_PROTO_TYPE_UDP,
4207 HAL_FILTER_PROTO_TYPE_MAX
4208};
4209
4210enum wcn36xx_hal_rcv_pkt_flt_cmp_flag_type {
4211 HAL_FILTER_CMP_TYPE_INVALID,
4212 HAL_FILTER_CMP_TYPE_EQUAL,
4213 HAL_FILTER_CMP_TYPE_MASK_EQUAL,
4214 HAL_FILTER_CMP_TYPE_NOT_EQUAL,
4215 HAL_FILTER_CMP_TYPE_MAX
4216};
4217
4218struct wcn36xx_hal_rcv_pkt_filter_params {
4219 u8 protocol_layer;
4220 u8 cmp_flag;
4221
4222 /* Length of the data to compare */
4223 u16 data_length;
4224
4225 /* from start of the respective frame header */
4226 u8 data_offset;
4227
4228 /* Reserved field */
4229 u8 reserved;
4230
4231 /* Data to compare */
4232 u8 compare_data[WCN36XX_HAL_PROTOCOL_DATA_LEN];
4233
4234 /* Mask to be applied on the received packet data before compare */
4235 u8 data_mask[WCN36XX_HAL_PROTOCOL_DATA_LEN];
4236};
4237
4238struct wcn36xx_hal_sessionized_rcv_pkt_filter_cfg_type {
4239 u8 id;
4240 u8 type;
4241 u8 params_count;
4242 u32 coleasce_time;
4243 u8 bss_index;
4244 struct wcn36xx_hal_rcv_pkt_filter_params params[1];
4245};
4246
4247struct wcn36xx_hal_set_rcv_pkt_filter_req_msg {
4248 struct wcn36xx_hal_msg_header header;
4249
4250 u8 id;
4251 u8 type;
4252 u8 params_count;
4253 u32 coalesce_time;
4254 struct wcn36xx_hal_rcv_pkt_filter_params params[1];
4255};
4256
4257struct wcn36xx_hal_rcv_flt_mc_addr_list_type {
4258 /* from start of the respective frame header */
4259 u8 data_offset;
4260
4261 u32 mc_addr_count;
4262 u8 mc_addr[ETH_ALEN][WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS];
4263 u8 bss_index;
4264};
4265
4266struct wcn36xx_hal_set_pkt_filter_rsp_msg {
4267 struct wcn36xx_hal_msg_header header;
4268
4269 /* success or failure */
4270 u32 status;
4271
4272 u8 bss_index;
4273};
4274
4275struct wcn36xx_hal_rcv_flt_pkt_match_cnt_req_msg {
4276 struct wcn36xx_hal_msg_header header;
4277
4278 u8 bss_index;
4279};
4280
4281struct wcn36xx_hal_rcv_flt_pkt_match_cnt {
4282 u8 id;
4283 u32 match_cnt;
4284};
4285
4286struct wcn36xx_hal_rcv_flt_pkt_match_cnt_rsp_msg {
4287 struct wcn36xx_hal_msg_header header;
4288
4289 /* Success or Failure */
4290 u32 status;
4291
4292 u32 match_count;
4293 struct wcn36xx_hal_rcv_flt_pkt_match_cnt
4294 matches[WCN36XX_HAL_MAX_NUM_FILTERS];
4295 u8 bss_index;
4296};
4297
4298struct wcn36xx_hal_rcv_flt_pkt_clear_param {
4299 /* only valid for response message */
4300 u32 status;
4301 u8 id;
4302 u8 bss_index;
4303};
4304
4305struct wcn36xx_hal_rcv_flt_pkt_clear_req_msg {
4306 struct wcn36xx_hal_msg_header header;
4307 struct wcn36xx_hal_rcv_flt_pkt_clear_param param;
4308};
4309
4310struct wcn36xx_hal_rcv_flt_pkt_clear_rsp_msg {
4311 struct wcn36xx_hal_msg_header header;
4312 struct wcn36xx_hal_rcv_flt_pkt_clear_param param;
4313};
4314
4315struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_req_msg {
4316 struct wcn36xx_hal_msg_header header;
4317 struct wcn36xx_hal_rcv_flt_mc_addr_list_type mc_addr_list;
4318};
4319
4320struct wcn36xx_hal_rcv_flt_pkt_set_mc_list_rsp_msg {
4321 struct wcn36xx_hal_msg_header header;
4322 u32 status;
4323 u8 bss_index;
4324};
4325
4326/* Packet Filtering Definitions End */
4327
4328struct wcn36xx_hal_set_power_params_req_msg {
4329 struct wcn36xx_hal_msg_header header;
4330
4331 /* Ignore DTIM */
4332 u32 ignore_dtim;
4333
4334 /* DTIM Period */
4335 u32 dtim_period;
4336
4337 /* Listen Interval */
4338 u32 listen_interval;
4339
4340 /* Broadcast Multicast Filter */
4341 u32 bcast_mcast_filter;
4342
4343 /* Beacon Early Termination */
4344 u32 enable_bet;
4345
4346 /* Beacon Early Termination Interval */
4347 u32 bet_interval;
4348} __packed;
4349
4350struct wcn36xx_hal_set_power_params_resp {
4351
4352 struct wcn36xx_hal_msg_header header;
4353
4354 /* status of the request */
4355 u32 status;
4356} __packed;
4357
4358/* Capability bitmap exchange definitions and macros starts */
4359
4360enum place_holder_in_cap_bitmap {
4361 MCC = 0,
4362 P2P = 1,
4363 DOT11AC = 2,
4364 SLM_SESSIONIZATION = 3,
4365 DOT11AC_OPMODE = 4,
4366 SAP32STA = 5,
4367 TDLS = 6,
4368 P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
4369 WLANACTIVE_OFFLOAD = 8,
4370 BEACON_OFFLOAD = 9,
4371 SCAN_OFFLOAD = 10,
4372 ROAM_OFFLOAD = 11,
4373 BCN_MISS_OFFLOAD = 12,
4374 STA_POWERSAVE = 13,
4375 STA_ADVANCED_PWRSAVE = 14,
4376 AP_UAPSD = 15,
4377 AP_DFS = 16,
4378 BLOCKACK = 17,
4379 PHY_ERR = 18,
4380 BCN_FILTER = 19,
4381 RTT = 20,
4382 RATECTRL = 21,
4383 WOW = 22,
4384 MAX_FEATURE_SUPPORTED = 128,
4385};
4386
4387struct wcn36xx_hal_feat_caps_msg {
4388
4389 struct wcn36xx_hal_msg_header header;
4390
4391 u32 feat_caps[4];
4392} __packed;
4393
4394/* status codes to help debug rekey failures */
4395enum gtk_rekey_status {
4396 WCN36XX_HAL_GTK_REKEY_STATUS_SUCCESS = 0,
4397
4398 /* rekey detected, but not handled */
4399 WCN36XX_HAL_GTK_REKEY_STATUS_NOT_HANDLED = 1,
4400
4401 /* MIC check error on M1 */
4402 WCN36XX_HAL_GTK_REKEY_STATUS_MIC_ERROR = 2,
4403
4404 /* decryption error on M1 */
4405 WCN36XX_HAL_GTK_REKEY_STATUS_DECRYPT_ERROR = 3,
4406
4407 /* M1 replay detected */
4408 WCN36XX_HAL_GTK_REKEY_STATUS_REPLAY_ERROR = 4,
4409
4410 /* missing GTK key descriptor in M1 */
4411 WCN36XX_HAL_GTK_REKEY_STATUS_MISSING_KDE = 5,
4412
4413 /* missing iGTK key descriptor in M1 */
4414 WCN36XX_HAL_GTK_REKEY_STATUS_MISSING_IGTK_KDE = 6,
4415
4416 /* key installation error */
4417 WCN36XX_HAL_GTK_REKEY_STATUS_INSTALL_ERROR = 7,
4418
4419 /* iGTK key installation error */
4420 WCN36XX_HAL_GTK_REKEY_STATUS_IGTK_INSTALL_ERROR = 8,
4421
4422 /* GTK rekey M2 response TX error */
4423 WCN36XX_HAL_GTK_REKEY_STATUS_RESP_TX_ERROR = 9,
4424
4425 /* non-specific general error */
4426 WCN36XX_HAL_GTK_REKEY_STATUS_GEN_ERROR = 255
4427};
4428
4429/* wake reason types */
4430enum wake_reason_type {
4431 WCN36XX_HAL_WAKE_REASON_NONE = 0,
4432
4433 /* magic packet match */
4434 WCN36XX_HAL_WAKE_REASON_MAGIC_PACKET = 1,
4435
4436 /* host defined pattern match */
4437 WCN36XX_HAL_WAKE_REASON_PATTERN_MATCH = 2,
4438
4439 /* EAP-ID frame detected */
4440 WCN36XX_HAL_WAKE_REASON_EAPID_PACKET = 3,
4441
4442 /* start of EAPOL 4-way handshake detected */
4443 WCN36XX_HAL_WAKE_REASON_EAPOL4WAY_PACKET = 4,
4444
4445 /* network scan offload match */
4446 WCN36XX_HAL_WAKE_REASON_NETSCAN_OFFL_MATCH = 5,
4447
4448 /* GTK rekey status wakeup (see status) */
4449 WCN36XX_HAL_WAKE_REASON_GTK_REKEY_STATUS = 6,
4450
4451 /* BSS connection lost */
4452 WCN36XX_HAL_WAKE_REASON_BSS_CONN_LOST = 7,
4453};
4454
4455/*
4456 Wake Packet which is saved at tWakeReasonParams.DataStart
4457 This data is sent for any wake reasons that involve a packet-based wakeup :
4458
4459 WCN36XX_HAL_WAKE_REASON_TYPE_MAGIC_PACKET
4460 WCN36XX_HAL_WAKE_REASON_TYPE_PATTERN_MATCH
4461 WCN36XX_HAL_WAKE_REASON_TYPE_EAPID_PACKET
4462 WCN36XX_HAL_WAKE_REASON_TYPE_EAPOL4WAY_PACKET
4463 WCN36XX_HAL_WAKE_REASON_TYPE_GTK_REKEY_STATUS
4464
4465 The information is provided to the host for auditing and debug purposes
4466
4467*/
4468
4469/* Wake reason indication */
4470struct wcn36xx_hal_wake_reason_ind {
4471 struct wcn36xx_hal_msg_header header;
4472
4473 /* see tWakeReasonType */
4474 u32 reason;
4475
4476 /* argument specific to the reason type */
4477 u32 reason_arg;
4478
4479 /* length of optional data stored in this message, in case HAL
4480 * truncates the data (i.e. data packets) this length will be less
4481 * than the actual length */
4482 u32 stored_data_len;
4483
4484 /* actual length of data */
4485 u32 actual_data_len;
4486
4487 /* variable length start of data (length == storedDataLen) see
4488 * specific wake type */
4489 u8 data_start[1];
4490
4491 u32 bss_index:8;
4492 u32 reserved:24;
4493};
4494
4495#define WCN36XX_HAL_GTK_KEK_BYTES 16
4496#define WCN36XX_HAL_GTK_KCK_BYTES 16
4497
4498#define WCN36XX_HAL_GTK_OFFLOAD_FLAGS_DISABLE (1 << 0)
4499
4500#define GTK_SET_BSS_KEY_TAG 0x1234AA55
4501
4502struct wcn36xx_hal_gtk_offload_req_msg {
4503 struct wcn36xx_hal_msg_header header;
4504
4505 /* optional flags */
4506 u32 flags;
4507
4508 /* Key confirmation key */
4509 u8 kck[WCN36XX_HAL_GTK_KCK_BYTES];
4510
4511 /* key encryption key */
4512 u8 kek[WCN36XX_HAL_GTK_KEK_BYTES];
4513
4514 /* replay counter */
4515 u64 key_replay_counter;
4516
4517 u8 bss_index;
4518};
4519
4520struct wcn36xx_hal_gtk_offload_rsp_msg {
4521 struct wcn36xx_hal_msg_header header;
4522
4523 /* success or failure */
4524 u32 status;
4525
4526 u8 bss_index;
4527};
4528
4529struct wcn36xx_hal_gtk_offload_get_info_req_msg {
4530 struct wcn36xx_hal_msg_header header;
4531 u8 bss_index;
4532};
4533
4534struct wcn36xx_hal_gtk_offload_get_info_rsp_msg {
4535 struct wcn36xx_hal_msg_header header;
4536
4537 /* success or failure */
4538 u32 status;
4539
4540 /* last rekey status when the rekey was offloaded */
4541 u32 last_rekey_status;
4542
4543 /* current replay counter value */
4544 u64 key_replay_counter;
4545
4546 /* total rekey attempts */
4547 u32 total_rekey_count;
4548
4549 /* successful GTK rekeys */
4550 u32 gtk_rekey_count;
4551
4552 /* successful iGTK rekeys */
4553 u32 igtk_rekey_count;
4554
4555 u8 bss_index;
4556};
4557
4558struct dhcp_info {
4559 /* Indicates the device mode which indicates about the DHCP activity */
4560 u8 device_mode;
4561
4562 u8 addr[ETH_ALEN];
4563};
4564
4565struct dhcp_ind_status {
4566 struct wcn36xx_hal_msg_header header;
4567
4568 /* success or failure */
4569 u32 status;
4570};
4571
4572/*
4573 * Thermal Mitigation mode of operation.
4574 *
4575 * WCN36XX_HAL_THERMAL_MITIGATION_MODE_0 - Based on AMPDU disabling aggregation
4576 *
4577 * WCN36XX_HAL_THERMAL_MITIGATION_MODE_1 - Based on AMPDU disabling aggregation
4578 * and reducing transmit power
4579 *
4580 * WCN36XX_HAL_THERMAL_MITIGATION_MODE_2 - Not supported */
4581enum wcn36xx_hal_thermal_mitigation_mode_type {
4582 HAL_THERMAL_MITIGATION_MODE_INVALID = -1,
4583 HAL_THERMAL_MITIGATION_MODE_0,
4584 HAL_THERMAL_MITIGATION_MODE_1,
4585 HAL_THERMAL_MITIGATION_MODE_2,
4586 HAL_THERMAL_MITIGATION_MODE_MAX = WCN36XX_HAL_MAX_ENUM_SIZE,
4587};
4588
4589
4590/*
4591 * Thermal Mitigation level.
4592 * Note the levels are incremental i.e WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_2 =
4593 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_0 +
4594 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_1
4595 *
4596 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_0 - lowest level of thermal mitigation.
4597 * This level indicates normal mode of operation
4598 *
4599 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_1 - 1st level of thermal mitigation
4600 *
4601 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_2 - 2nd level of thermal mitigation
4602 *
4603 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_3 - 3rd level of thermal mitigation
4604 *
4605 * WCN36XX_HAL_THERMAL_MITIGATION_LEVEL_4 - 4th level of thermal mitigation
4606 */
4607enum wcn36xx_hal_thermal_mitigation_level_type {
4608 HAL_THERMAL_MITIGATION_LEVEL_INVALID = -1,
4609 HAL_THERMAL_MITIGATION_LEVEL_0,
4610 HAL_THERMAL_MITIGATION_LEVEL_1,
4611 HAL_THERMAL_MITIGATION_LEVEL_2,
4612 HAL_THERMAL_MITIGATION_LEVEL_3,
4613 HAL_THERMAL_MITIGATION_LEVEL_4,
4614 HAL_THERMAL_MITIGATION_LEVEL_MAX = WCN36XX_HAL_MAX_ENUM_SIZE,
4615};
4616
4617
4618/* WCN36XX_HAL_SET_THERMAL_MITIGATION_REQ */
4619struct set_thermal_mitigation_req_msg {
4620 struct wcn36xx_hal_msg_header header;
4621
4622 /* Thermal Mitigation Operation Mode */
4623 enum wcn36xx_hal_thermal_mitigation_mode_type mode;
4624
4625 /* Thermal Mitigation Level */
4626 enum wcn36xx_hal_thermal_mitigation_level_type level;
4627};
4628
4629struct set_thermal_mitigation_resp {
4630
4631 struct wcn36xx_hal_msg_header header;
4632
4633 /* status of the request */
4634 u32 status;
4635};
4636
4637/* Per STA Class B Statistics. Class B statistics are STA TX/RX stats
4638 * provided to FW from Host via periodic messages */
4639struct stats_class_b_ind {
4640 struct wcn36xx_hal_msg_header header;
4641
4642 /* Duration over which this stats was collected */
4643 u32 duration;
4644
4645 /* Per STA Stats */
4646
4647 /* TX stats */
4648 u32 tx_bytes_pushed;
4649 u32 tx_packets_pushed;
4650
4651 /* RX stats */
4652 u32 rx_bytes_rcvd;
4653 u32 rx_packets_rcvd;
4654 u32 rx_time_total;
4655};
4656
4657#endif /* _HAL_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
new file mode 100644
index 000000000000..7839b31e4826
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -0,0 +1,1036 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19#include <linux/module.h>
20#include <linux/platform_device.h>
21#include "wcn36xx.h"
22
23unsigned int wcn36xx_dbg_mask;
24module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
25MODULE_PARM_DESC(debug_mask, "Debugging mask");
26
27#define CHAN2G(_freq, _idx) { \
28 .band = IEEE80211_BAND_2GHZ, \
29 .center_freq = (_freq), \
30 .hw_value = (_idx), \
31 .max_power = 25, \
32}
33
34#define CHAN5G(_freq, _idx) { \
35 .band = IEEE80211_BAND_5GHZ, \
36 .center_freq = (_freq), \
37 .hw_value = (_idx), \
38 .max_power = 25, \
39}
40
41/* The wcn firmware expects channel values to matching
42 * their mnemonic values. So use these for .hw_value. */
43static struct ieee80211_channel wcn_2ghz_channels[] = {
44 CHAN2G(2412, 1), /* Channel 1 */
45 CHAN2G(2417, 2), /* Channel 2 */
46 CHAN2G(2422, 3), /* Channel 3 */
47 CHAN2G(2427, 4), /* Channel 4 */
48 CHAN2G(2432, 5), /* Channel 5 */
49 CHAN2G(2437, 6), /* Channel 6 */
50 CHAN2G(2442, 7), /* Channel 7 */
51 CHAN2G(2447, 8), /* Channel 8 */
52 CHAN2G(2452, 9), /* Channel 9 */
53 CHAN2G(2457, 10), /* Channel 10 */
54 CHAN2G(2462, 11), /* Channel 11 */
55 CHAN2G(2467, 12), /* Channel 12 */
56 CHAN2G(2472, 13), /* Channel 13 */
57 CHAN2G(2484, 14) /* Channel 14 */
58
59};
60
61static struct ieee80211_channel wcn_5ghz_channels[] = {
62 CHAN5G(5180, 36),
63 CHAN5G(5200, 40),
64 CHAN5G(5220, 44),
65 CHAN5G(5240, 48),
66 CHAN5G(5260, 52),
67 CHAN5G(5280, 56),
68 CHAN5G(5300, 60),
69 CHAN5G(5320, 64),
70 CHAN5G(5500, 100),
71 CHAN5G(5520, 104),
72 CHAN5G(5540, 108),
73 CHAN5G(5560, 112),
74 CHAN5G(5580, 116),
75 CHAN5G(5600, 120),
76 CHAN5G(5620, 124),
77 CHAN5G(5640, 128),
78 CHAN5G(5660, 132),
79 CHAN5G(5700, 140),
80 CHAN5G(5745, 149),
81 CHAN5G(5765, 153),
82 CHAN5G(5785, 157),
83 CHAN5G(5805, 161),
84 CHAN5G(5825, 165)
85};
86
87#define RATE(_bitrate, _hw_rate, _flags) { \
88 .bitrate = (_bitrate), \
89 .flags = (_flags), \
90 .hw_value = (_hw_rate), \
91 .hw_value_short = (_hw_rate) \
92}
93
94static struct ieee80211_rate wcn_2ghz_rates[] = {
95 RATE(10, HW_RATE_INDEX_1MBPS, 0),
96 RATE(20, HW_RATE_INDEX_2MBPS, IEEE80211_RATE_SHORT_PREAMBLE),
97 RATE(55, HW_RATE_INDEX_5_5MBPS, IEEE80211_RATE_SHORT_PREAMBLE),
98 RATE(110, HW_RATE_INDEX_11MBPS, IEEE80211_RATE_SHORT_PREAMBLE),
99 RATE(60, HW_RATE_INDEX_6MBPS, 0),
100 RATE(90, HW_RATE_INDEX_9MBPS, 0),
101 RATE(120, HW_RATE_INDEX_12MBPS, 0),
102 RATE(180, HW_RATE_INDEX_18MBPS, 0),
103 RATE(240, HW_RATE_INDEX_24MBPS, 0),
104 RATE(360, HW_RATE_INDEX_36MBPS, 0),
105 RATE(480, HW_RATE_INDEX_48MBPS, 0),
106 RATE(540, HW_RATE_INDEX_54MBPS, 0)
107};
108
109static struct ieee80211_rate wcn_5ghz_rates[] = {
110 RATE(60, HW_RATE_INDEX_6MBPS, 0),
111 RATE(90, HW_RATE_INDEX_9MBPS, 0),
112 RATE(120, HW_RATE_INDEX_12MBPS, 0),
113 RATE(180, HW_RATE_INDEX_18MBPS, 0),
114 RATE(240, HW_RATE_INDEX_24MBPS, 0),
115 RATE(360, HW_RATE_INDEX_36MBPS, 0),
116 RATE(480, HW_RATE_INDEX_48MBPS, 0),
117 RATE(540, HW_RATE_INDEX_54MBPS, 0)
118};
119
120static struct ieee80211_supported_band wcn_band_2ghz = {
121 .channels = wcn_2ghz_channels,
122 .n_channels = ARRAY_SIZE(wcn_2ghz_channels),
123 .bitrates = wcn_2ghz_rates,
124 .n_bitrates = ARRAY_SIZE(wcn_2ghz_rates),
125 .ht_cap = {
126 .cap = IEEE80211_HT_CAP_GRN_FLD |
127 IEEE80211_HT_CAP_SGI_20 |
128 IEEE80211_HT_CAP_DSSSCCK40 |
129 IEEE80211_HT_CAP_LSIG_TXOP_PROT,
130 .ht_supported = true,
131 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
132 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
133 .mcs = {
134 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
135 .rx_highest = cpu_to_le16(72),
136 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
137 }
138 }
139};
140
141static struct ieee80211_supported_band wcn_band_5ghz = {
142 .channels = wcn_5ghz_channels,
143 .n_channels = ARRAY_SIZE(wcn_5ghz_channels),
144 .bitrates = wcn_5ghz_rates,
145 .n_bitrates = ARRAY_SIZE(wcn_5ghz_rates),
146 .ht_cap = {
147 .cap = IEEE80211_HT_CAP_GRN_FLD |
148 IEEE80211_HT_CAP_SGI_20 |
149 IEEE80211_HT_CAP_DSSSCCK40 |
150 IEEE80211_HT_CAP_LSIG_TXOP_PROT |
151 IEEE80211_HT_CAP_SGI_40 |
152 IEEE80211_HT_CAP_SUP_WIDTH_20_40,
153 .ht_supported = true,
154 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
155 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
156 .mcs = {
157 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
158 .rx_highest = cpu_to_le16(72),
159 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
160 }
161 }
162};
163
164#ifdef CONFIG_PM
165
166static const struct wiphy_wowlan_support wowlan_support = {
167 .flags = WIPHY_WOWLAN_ANY
168};
169
170#endif
171
172static inline u8 get_sta_index(struct ieee80211_vif *vif,
173 struct wcn36xx_sta *sta_priv)
174{
175 return NL80211_IFTYPE_STATION == vif->type ?
176 sta_priv->bss_sta_index :
177 sta_priv->sta_index;
178}
179
180static int wcn36xx_start(struct ieee80211_hw *hw)
181{
182 struct wcn36xx *wcn = hw->priv;
183 int ret;
184
185 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac start\n");
186
187 /* SMD initialization */
188 ret = wcn36xx_smd_open(wcn);
189 if (ret) {
190 wcn36xx_err("Failed to open smd channel: %d\n", ret);
191 goto out_err;
192 }
193
194 /* Allocate memory pools for Mgmt BD headers and Data BD headers */
195 ret = wcn36xx_dxe_allocate_mem_pools(wcn);
196 if (ret) {
197 wcn36xx_err("Failed to alloc DXE mempool: %d\n", ret);
198 goto out_smd_close;
199 }
200
201 ret = wcn36xx_dxe_alloc_ctl_blks(wcn);
202 if (ret) {
203 wcn36xx_err("Failed to alloc DXE ctl blocks: %d\n", ret);
204 goto out_free_dxe_pool;
205 }
206
207 wcn->hal_buf = kmalloc(WCN36XX_HAL_BUF_SIZE, GFP_KERNEL);
208 if (!wcn->hal_buf) {
209 wcn36xx_err("Failed to allocate smd buf\n");
210 ret = -ENOMEM;
211 goto out_free_dxe_ctl;
212 }
213
214 ret = wcn36xx_smd_load_nv(wcn);
215 if (ret) {
216 wcn36xx_err("Failed to push NV to chip\n");
217 goto out_free_smd_buf;
218 }
219
220 ret = wcn36xx_smd_start(wcn);
221 if (ret) {
222 wcn36xx_err("Failed to start chip\n");
223 goto out_free_smd_buf;
224 }
225
226 /* DMA channel initialization */
227 ret = wcn36xx_dxe_init(wcn);
228 if (ret) {
229 wcn36xx_err("DXE init failed\n");
230 goto out_smd_stop;
231 }
232
233 wcn36xx_debugfs_init(wcn);
234
235 if (!wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) {
236 ret = wcn36xx_smd_feature_caps_exchange(wcn);
237 if (ret)
238 wcn36xx_warn("Exchange feature caps failed\n");
239 }
240 INIT_LIST_HEAD(&wcn->vif_list);
241 return 0;
242
243out_smd_stop:
244 wcn36xx_smd_stop(wcn);
245out_free_smd_buf:
246 kfree(wcn->hal_buf);
247out_free_dxe_pool:
248 wcn36xx_dxe_free_mem_pools(wcn);
249out_free_dxe_ctl:
250 wcn36xx_dxe_free_ctl_blks(wcn);
251out_smd_close:
252 wcn36xx_smd_close(wcn);
253out_err:
254 return ret;
255}
256
257static void wcn36xx_stop(struct ieee80211_hw *hw)
258{
259 struct wcn36xx *wcn = hw->priv;
260
261 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac stop\n");
262
263 wcn36xx_debugfs_exit(wcn);
264 wcn36xx_smd_stop(wcn);
265 wcn36xx_dxe_deinit(wcn);
266 wcn36xx_smd_close(wcn);
267
268 wcn36xx_dxe_free_mem_pools(wcn);
269 wcn36xx_dxe_free_ctl_blks(wcn);
270
271 kfree(wcn->hal_buf);
272}
273
274static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
275{
276 struct wcn36xx *wcn = hw->priv;
277 struct ieee80211_vif *vif = NULL;
278 struct wcn36xx_vif *tmp;
279
280 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac config changed 0x%08x\n", changed);
281
282 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
283 int ch = WCN36XX_HW_CHANNEL(wcn);
284 wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel switch=%d\n",
285 ch);
286 list_for_each_entry(tmp, &wcn->vif_list, list) {
287 vif = container_of((void *)tmp,
288 struct ieee80211_vif,
289 drv_priv);
290 wcn36xx_smd_switch_channel(wcn, vif, ch);
291 }
292 }
293
294 return 0;
295}
296
297#define WCN36XX_SUPPORTED_FILTERS (0)
298
299static void wcn36xx_configure_filter(struct ieee80211_hw *hw,
300 unsigned int changed,
301 unsigned int *total, u64 multicast)
302{
303 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac configure filter\n");
304
305 *total &= WCN36XX_SUPPORTED_FILTERS;
306}
307
308static void wcn36xx_tx(struct ieee80211_hw *hw,
309 struct ieee80211_tx_control *control,
310 struct sk_buff *skb)
311{
312 struct wcn36xx *wcn = hw->priv;
313 struct wcn36xx_sta *sta_priv = NULL;
314
315 if (control->sta)
316 sta_priv = (struct wcn36xx_sta *)control->sta->drv_priv;
317
318 if (wcn36xx_start_tx(wcn, sta_priv, skb))
319 ieee80211_free_txskb(wcn->hw, skb);
320}
321
322static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
323 struct ieee80211_vif *vif,
324 struct ieee80211_sta *sta,
325 struct ieee80211_key_conf *key_conf)
326{
327 struct wcn36xx *wcn = hw->priv;
328 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
329 struct wcn36xx_sta *sta_priv = vif_priv->sta;
330 int ret = 0;
331 u8 key[WLAN_MAX_KEY_LEN];
332
333 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac80211 set key\n");
334 wcn36xx_dbg(WCN36XX_DBG_MAC, "Key: cmd=0x%x algo:0x%x, id:%d, len:%d flags 0x%x\n",
335 cmd, key_conf->cipher, key_conf->keyidx,
336 key_conf->keylen, key_conf->flags);
337 wcn36xx_dbg_dump(WCN36XX_DBG_MAC, "KEY: ",
338 key_conf->key,
339 key_conf->keylen);
340
341 switch (key_conf->cipher) {
342 case WLAN_CIPHER_SUITE_WEP40:
343 vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
344 break;
345 case WLAN_CIPHER_SUITE_WEP104:
346 vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
347 break;
348 case WLAN_CIPHER_SUITE_CCMP:
349 vif_priv->encrypt_type = WCN36XX_HAL_ED_CCMP;
350 break;
351 case WLAN_CIPHER_SUITE_TKIP:
352 vif_priv->encrypt_type = WCN36XX_HAL_ED_TKIP;
353 break;
354 default:
355 wcn36xx_err("Unsupported key type 0x%x\n",
356 key_conf->cipher);
357 ret = -EOPNOTSUPP;
358 goto out;
359 }
360
361 switch (cmd) {
362 case SET_KEY:
363 if (WCN36XX_HAL_ED_TKIP == vif_priv->encrypt_type) {
364 /*
365 * Supplicant is sending key in the wrong order:
366 * Temporal Key (16 b) - TX MIC (8 b) - RX MIC (8 b)
367 * but HW expects it to be in the order as described in
368 * IEEE 802.11 spec (see chapter 11.7) like this:
369 * Temporal Key (16 b) - RX MIC (8 b) - TX MIC (8 b)
370 */
371 memcpy(key, key_conf->key, 16);
372 memcpy(key + 16, key_conf->key + 24, 8);
373 memcpy(key + 24, key_conf->key + 16, 8);
374 } else {
375 memcpy(key, key_conf->key, key_conf->keylen);
376 }
377
378 if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) {
379 sta_priv->is_data_encrypted = true;
380 /* Reconfigure bss with encrypt_type */
381 if (NL80211_IFTYPE_STATION == vif->type)
382 wcn36xx_smd_config_bss(wcn,
383 vif,
384 sta,
385 sta->addr,
386 true);
387
388 wcn36xx_smd_set_stakey(wcn,
389 vif_priv->encrypt_type,
390 key_conf->keyidx,
391 key_conf->keylen,
392 key,
393 get_sta_index(vif, sta_priv));
394 } else {
395 wcn36xx_smd_set_bsskey(wcn,
396 vif_priv->encrypt_type,
397 key_conf->keyidx,
398 key_conf->keylen,
399 key);
400 if ((WLAN_CIPHER_SUITE_WEP40 == key_conf->cipher) ||
401 (WLAN_CIPHER_SUITE_WEP104 == key_conf->cipher)) {
402 sta_priv->is_data_encrypted = true;
403 wcn36xx_smd_set_stakey(wcn,
404 vif_priv->encrypt_type,
405 key_conf->keyidx,
406 key_conf->keylen,
407 key,
408 get_sta_index(vif, sta_priv));
409 }
410 }
411 break;
412 case DISABLE_KEY:
413 if (!(IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)) {
414 wcn36xx_smd_remove_bsskey(wcn,
415 vif_priv->encrypt_type,
416 key_conf->keyidx);
417 } else {
418 sta_priv->is_data_encrypted = false;
419 /* do not remove key if disassociated */
420 if (sta_priv->aid)
421 wcn36xx_smd_remove_stakey(wcn,
422 vif_priv->encrypt_type,
423 key_conf->keyidx,
424 get_sta_index(vif, sta_priv));
425 }
426 break;
427 default:
428 wcn36xx_err("Unsupported key cmd 0x%x\n", cmd);
429 ret = -EOPNOTSUPP;
430 goto out;
431 break;
432 }
433
434out:
435 return ret;
436}
437
438static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw)
439{
440 struct wcn36xx *wcn = hw->priv;
441
442 wcn36xx_smd_init_scan(wcn, HAL_SYS_MODE_SCAN);
443 wcn36xx_smd_start_scan(wcn);
444}
445
446static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw)
447{
448 struct wcn36xx *wcn = hw->priv;
449
450 wcn36xx_smd_end_scan(wcn);
451 wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN);
452}
453
454static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
455 enum ieee80211_band band)
456{
457 int i, size;
458 u16 *rates_table;
459 struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
460 u32 rates = sta->supp_rates[band];
461
462 memset(&sta_priv->supported_rates, 0,
463 sizeof(sta_priv->supported_rates));
464 sta_priv->supported_rates.op_rate_mode = STA_11n;
465
466 size = ARRAY_SIZE(sta_priv->supported_rates.dsss_rates);
467 rates_table = sta_priv->supported_rates.dsss_rates;
468 if (band == IEEE80211_BAND_2GHZ) {
469 for (i = 0; i < size; i++) {
470 if (rates & 0x01) {
471 rates_table[i] = wcn_2ghz_rates[i].hw_value;
472 rates = rates >> 1;
473 }
474 }
475 }
476
477 size = ARRAY_SIZE(sta_priv->supported_rates.ofdm_rates);
478 rates_table = sta_priv->supported_rates.ofdm_rates;
479 for (i = 0; i < size; i++) {
480 if (rates & 0x01) {
481 rates_table[i] = wcn_5ghz_rates[i].hw_value;
482 rates = rates >> 1;
483 }
484 }
485
486 if (sta->ht_cap.ht_supported) {
487 BUILD_BUG_ON(sizeof(sta->ht_cap.mcs.rx_mask) >
488 sizeof(sta_priv->supported_rates.supported_mcs_set));
489 memcpy(sta_priv->supported_rates.supported_mcs_set,
490 sta->ht_cap.mcs.rx_mask,
491 sizeof(sta->ht_cap.mcs.rx_mask));
492 }
493}
494void wcn36xx_set_default_rates(struct wcn36xx_hal_supported_rates *rates)
495{
496 u16 ofdm_rates[WCN36XX_HAL_NUM_OFDM_RATES] = {
497 HW_RATE_INDEX_6MBPS,
498 HW_RATE_INDEX_9MBPS,
499 HW_RATE_INDEX_12MBPS,
500 HW_RATE_INDEX_18MBPS,
501 HW_RATE_INDEX_24MBPS,
502 HW_RATE_INDEX_36MBPS,
503 HW_RATE_INDEX_48MBPS,
504 HW_RATE_INDEX_54MBPS
505 };
506 u16 dsss_rates[WCN36XX_HAL_NUM_DSSS_RATES] = {
507 HW_RATE_INDEX_1MBPS,
508 HW_RATE_INDEX_2MBPS,
509 HW_RATE_INDEX_5_5MBPS,
510 HW_RATE_INDEX_11MBPS
511 };
512
513 rates->op_rate_mode = STA_11n;
514 memcpy(rates->dsss_rates, dsss_rates,
515 sizeof(*dsss_rates) * WCN36XX_HAL_NUM_DSSS_RATES);
516 memcpy(rates->ofdm_rates, ofdm_rates,
517 sizeof(*ofdm_rates) * WCN36XX_HAL_NUM_OFDM_RATES);
518 rates->supported_mcs_set[0] = 0xFF;
519}
520static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
521 struct ieee80211_vif *vif,
522 struct ieee80211_bss_conf *bss_conf,
523 u32 changed)
524{
525 struct wcn36xx *wcn = hw->priv;
526 struct sk_buff *skb = NULL;
527 u16 tim_off, tim_len;
528 enum wcn36xx_hal_link_state link_state;
529 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
530
531 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss info changed vif %p changed 0x%08x\n",
532 vif, changed);
533
534 if (changed & BSS_CHANGED_BEACON_INFO) {
535 wcn36xx_dbg(WCN36XX_DBG_MAC,
536 "mac bss changed dtim period %d\n",
537 bss_conf->dtim_period);
538
539 vif_priv->dtim_period = bss_conf->dtim_period;
540 }
541
542 if (changed & BSS_CHANGED_PS) {
543 wcn36xx_dbg(WCN36XX_DBG_MAC,
544 "mac bss PS set %d\n",
545 bss_conf->ps);
546 if (bss_conf->ps) {
547 wcn36xx_pmc_enter_bmps_state(wcn, vif);
548 } else {
549 wcn36xx_pmc_exit_bmps_state(wcn, vif);
550 }
551 }
552
553 if (changed & BSS_CHANGED_BSSID) {
554 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss changed_bssid %pM\n",
555 bss_conf->bssid);
556
557 if (!is_zero_ether_addr(bss_conf->bssid)) {
558 vif_priv->is_joining = true;
559 vif_priv->bss_index = 0xff;
560 wcn36xx_smd_join(wcn, bss_conf->bssid,
561 vif->addr, WCN36XX_HW_CHANNEL(wcn));
562 wcn36xx_smd_config_bss(wcn, vif, NULL,
563 bss_conf->bssid, false);
564 } else {
565 vif_priv->is_joining = false;
566 wcn36xx_smd_delete_bss(wcn, vif);
567 }
568 }
569
570 if (changed & BSS_CHANGED_SSID) {
571 wcn36xx_dbg(WCN36XX_DBG_MAC,
572 "mac bss changed ssid\n");
573 wcn36xx_dbg_dump(WCN36XX_DBG_MAC, "ssid ",
574 bss_conf->ssid, bss_conf->ssid_len);
575
576 vif_priv->ssid.length = bss_conf->ssid_len;
577 memcpy(&vif_priv->ssid.ssid,
578 bss_conf->ssid,
579 bss_conf->ssid_len);
580 }
581
582 if (changed & BSS_CHANGED_ASSOC) {
583 vif_priv->is_joining = false;
584 if (bss_conf->assoc) {
585 struct ieee80211_sta *sta;
586 struct wcn36xx_sta *sta_priv;
587
588 wcn36xx_dbg(WCN36XX_DBG_MAC,
589 "mac assoc bss %pM vif %pM AID=%d\n",
590 bss_conf->bssid,
591 vif->addr,
592 bss_conf->aid);
593
594 rcu_read_lock();
595 sta = ieee80211_find_sta(vif, bss_conf->bssid);
596 if (!sta) {
597 wcn36xx_err("sta %pM is not found\n",
598 bss_conf->bssid);
599 rcu_read_unlock();
600 goto out;
601 }
602 sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
603
604 wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
605
606 wcn36xx_smd_set_link_st(wcn, bss_conf->bssid,
607 vif->addr,
608 WCN36XX_HAL_LINK_POSTASSOC_STATE);
609 wcn36xx_smd_config_bss(wcn, vif, sta,
610 bss_conf->bssid,
611 true);
612 sta_priv->aid = bss_conf->aid;
613 /*
614 * config_sta must be called from because this is the
615 * place where AID is available.
616 */
617 wcn36xx_smd_config_sta(wcn, vif, sta);
618 rcu_read_unlock();
619 } else {
620 wcn36xx_dbg(WCN36XX_DBG_MAC,
621 "disassociated bss %pM vif %pM AID=%d\n",
622 bss_conf->bssid,
623 vif->addr,
624 bss_conf->aid);
625 wcn36xx_smd_set_link_st(wcn,
626 bss_conf->bssid,
627 vif->addr,
628 WCN36XX_HAL_LINK_IDLE_STATE);
629 }
630 }
631
632 if (changed & BSS_CHANGED_AP_PROBE_RESP) {
633 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss changed ap probe resp\n");
634 skb = ieee80211_proberesp_get(hw, vif);
635 if (!skb) {
636 wcn36xx_err("failed to alloc probereq skb\n");
637 goto out;
638 }
639
640 wcn36xx_smd_update_proberesp_tmpl(wcn, vif, skb);
641 dev_kfree_skb(skb);
642 }
643
644 if (changed & BSS_CHANGED_BEACON_ENABLED) {
645 wcn36xx_dbg(WCN36XX_DBG_MAC,
646 "mac bss changed beacon enabled %d\n",
647 bss_conf->enable_beacon);
648
649 if (bss_conf->enable_beacon) {
650 vif_priv->bss_index = 0xff;
651 wcn36xx_smd_config_bss(wcn, vif, NULL,
652 vif->addr, false);
653 skb = ieee80211_beacon_get_tim(hw, vif, &tim_off,
654 &tim_len);
655 if (!skb) {
656 wcn36xx_err("failed to alloc beacon skb\n");
657 goto out;
658 }
659 wcn36xx_smd_send_beacon(wcn, vif, skb, tim_off, 0);
660 dev_kfree_skb(skb);
661
662 if (vif->type == NL80211_IFTYPE_ADHOC ||
663 vif->type == NL80211_IFTYPE_MESH_POINT)
664 link_state = WCN36XX_HAL_LINK_IBSS_STATE;
665 else
666 link_state = WCN36XX_HAL_LINK_AP_STATE;
667
668 wcn36xx_smd_set_link_st(wcn, vif->addr, vif->addr,
669 link_state);
670 } else {
671 wcn36xx_smd_set_link_st(wcn, vif->addr, vif->addr,
672 WCN36XX_HAL_LINK_IDLE_STATE);
673 wcn36xx_smd_delete_bss(wcn, vif);
674 }
675 }
676out:
677 return;
678}
679
680/* this is required when using IEEE80211_HW_HAS_RATE_CONTROL */
681static int wcn36xx_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
682{
683 struct wcn36xx *wcn = hw->priv;
684 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac set RTS threshold %d\n", value);
685
686 wcn36xx_smd_update_cfg(wcn, WCN36XX_HAL_CFG_RTS_THRESHOLD, value);
687 return 0;
688}
689
690static void wcn36xx_remove_interface(struct ieee80211_hw *hw,
691 struct ieee80211_vif *vif)
692{
693 struct wcn36xx *wcn = hw->priv;
694 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
695 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac remove interface vif %p\n", vif);
696
697 list_del(&vif_priv->list);
698 wcn36xx_smd_delete_sta_self(wcn, vif->addr);
699}
700
701static int wcn36xx_add_interface(struct ieee80211_hw *hw,
702 struct ieee80211_vif *vif)
703{
704 struct wcn36xx *wcn = hw->priv;
705 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
706
707 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac add interface vif %p type %d\n",
708 vif, vif->type);
709
710 if (!(NL80211_IFTYPE_STATION == vif->type ||
711 NL80211_IFTYPE_AP == vif->type ||
712 NL80211_IFTYPE_ADHOC == vif->type ||
713 NL80211_IFTYPE_MESH_POINT == vif->type)) {
714 wcn36xx_warn("Unsupported interface type requested: %d\n",
715 vif->type);
716 return -EOPNOTSUPP;
717 }
718
719 list_add(&vif_priv->list, &wcn->vif_list);
720 wcn36xx_smd_add_sta_self(wcn, vif);
721
722 return 0;
723}
724
725static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
726 struct ieee80211_sta *sta)
727{
728 struct wcn36xx *wcn = hw->priv;
729 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
730 struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
731 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM\n",
732 vif, sta->addr);
733
734 vif_priv->sta = sta_priv;
735 sta_priv->vif = vif_priv;
736 /*
737 * For STA mode HW will be configured on BSS_CHANGED_ASSOC because
738 * at this stage AID is not available yet.
739 */
740 if (NL80211_IFTYPE_STATION != vif->type) {
741 wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
742 sta_priv->aid = sta->aid;
743 wcn36xx_smd_config_sta(wcn, vif, sta);
744 }
745 return 0;
746}
747
748static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
749 struct ieee80211_vif *vif,
750 struct ieee80211_sta *sta)
751{
752 struct wcn36xx *wcn = hw->priv;
753 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
754 struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
755
756 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d\n",
757 vif, sta->addr, sta_priv->sta_index);
758
759 wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index);
760 vif_priv->sta = NULL;
761 sta_priv->vif = NULL;
762 return 0;
763}
764
765#ifdef CONFIG_PM
766
767static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)
768{
769 struct wcn36xx *wcn = hw->priv;
770
771 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac suspend\n");
772
773 flush_workqueue(wcn->hal_ind_wq);
774 wcn36xx_smd_set_power_params(wcn, true);
775 return 0;
776}
777
778static int wcn36xx_resume(struct ieee80211_hw *hw)
779{
780 struct wcn36xx *wcn = hw->priv;
781
782 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac resume\n");
783
784 flush_workqueue(wcn->hal_ind_wq);
785 wcn36xx_smd_set_power_params(wcn, false);
786 return 0;
787}
788
789#endif
790
791static int wcn36xx_ampdu_action(struct ieee80211_hw *hw,
792 struct ieee80211_vif *vif,
793 enum ieee80211_ampdu_mlme_action action,
794 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
795 u8 buf_size)
796{
797 struct wcn36xx *wcn = hw->priv;
798 struct wcn36xx_sta *sta_priv = NULL;
799
800 wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu action action %d tid %d\n",
801 action, tid);
802
803 sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
804
805 switch (action) {
806 case IEEE80211_AMPDU_RX_START:
807 sta_priv->tid = tid;
808 wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 0,
809 get_sta_index(vif, sta_priv));
810 wcn36xx_smd_add_ba(wcn);
811 wcn36xx_smd_trigger_ba(wcn, get_sta_index(vif, sta_priv));
812 ieee80211_start_tx_ba_session(sta, tid, 0);
813 break;
814 case IEEE80211_AMPDU_RX_STOP:
815 wcn36xx_smd_del_ba(wcn, tid, get_sta_index(vif, sta_priv));
816 break;
817 case IEEE80211_AMPDU_TX_START:
818 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
819 break;
820 case IEEE80211_AMPDU_TX_OPERATIONAL:
821 wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 1,
822 get_sta_index(vif, sta_priv));
823 break;
824 case IEEE80211_AMPDU_TX_STOP_FLUSH:
825 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
826 case IEEE80211_AMPDU_TX_STOP_CONT:
827 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
828 break;
829 default:
830 wcn36xx_err("Unknown AMPDU action\n");
831 }
832
833 return 0;
834}
835
836static const struct ieee80211_ops wcn36xx_ops = {
837 .start = wcn36xx_start,
838 .stop = wcn36xx_stop,
839 .add_interface = wcn36xx_add_interface,
840 .remove_interface = wcn36xx_remove_interface,
841#ifdef CONFIG_PM
842 .suspend = wcn36xx_suspend,
843 .resume = wcn36xx_resume,
844#endif
845 .config = wcn36xx_config,
846 .configure_filter = wcn36xx_configure_filter,
847 .tx = wcn36xx_tx,
848 .set_key = wcn36xx_set_key,
849 .sw_scan_start = wcn36xx_sw_scan_start,
850 .sw_scan_complete = wcn36xx_sw_scan_complete,
851 .bss_info_changed = wcn36xx_bss_info_changed,
852 .set_rts_threshold = wcn36xx_set_rts_threshold,
853 .sta_add = wcn36xx_sta_add,
854 .sta_remove = wcn36xx_sta_remove,
855 .ampdu_action = wcn36xx_ampdu_action,
856};
857
858static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
859{
860 int ret = 0;
861
862 static const u32 cipher_suites[] = {
863 WLAN_CIPHER_SUITE_WEP40,
864 WLAN_CIPHER_SUITE_WEP104,
865 WLAN_CIPHER_SUITE_TKIP,
866 WLAN_CIPHER_SUITE_CCMP,
867 };
868
869 wcn->hw->flags = IEEE80211_HW_SIGNAL_DBM |
870 IEEE80211_HW_HAS_RATE_CONTROL |
871 IEEE80211_HW_SUPPORTS_PS |
872 IEEE80211_HW_CONNECTION_MONITOR |
873 IEEE80211_HW_AMPDU_AGGREGATION |
874 IEEE80211_HW_TIMING_BEACON_ONLY;
875
876 wcn->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
877 BIT(NL80211_IFTYPE_AP) |
878 BIT(NL80211_IFTYPE_ADHOC) |
879 BIT(NL80211_IFTYPE_MESH_POINT);
880
881 wcn->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wcn_band_2ghz;
882 wcn->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &wcn_band_5ghz;
883
884 wcn->hw->wiphy->cipher_suites = cipher_suites;
885 wcn->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
886
887 wcn->hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
888
889#ifdef CONFIG_PM
890 wcn->hw->wiphy->wowlan = &wowlan_support;
891#endif
892
893 wcn->hw->max_listen_interval = 200;
894
895 wcn->hw->queues = 4;
896
897 SET_IEEE80211_DEV(wcn->hw, wcn->dev);
898
899 wcn->hw->sta_data_size = sizeof(struct wcn36xx_sta);
900 wcn->hw->vif_data_size = sizeof(struct wcn36xx_vif);
901
902 return ret;
903}
904
905static int wcn36xx_platform_get_resources(struct wcn36xx *wcn,
906 struct platform_device *pdev)
907{
908 struct resource *res;
909 /* Set TX IRQ */
910 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
911 "wcnss_wlantx_irq");
912 if (!res) {
913 wcn36xx_err("failed to get tx_irq\n");
914 return -ENOENT;
915 }
916 wcn->tx_irq = res->start;
917
918 /* Set RX IRQ */
919 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
920 "wcnss_wlanrx_irq");
921 if (!res) {
922 wcn36xx_err("failed to get rx_irq\n");
923 return -ENOENT;
924 }
925 wcn->rx_irq = res->start;
926
927 /* Map the memory */
928 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
929 "wcnss_mmio");
930 if (!res) {
931 wcn36xx_err("failed to get mmio\n");
932 return -ENOENT;
933 }
934 wcn->mmio = ioremap(res->start, resource_size(res));
935 if (!wcn->mmio) {
936 wcn36xx_err("failed to map io memory\n");
937 return -ENOMEM;
938 }
939 return 0;
940}
941
942static int wcn36xx_probe(struct platform_device *pdev)
943{
944 struct ieee80211_hw *hw;
945 struct wcn36xx *wcn;
946 int ret;
947 u8 addr[ETH_ALEN];
948
949 wcn36xx_dbg(WCN36XX_DBG_MAC, "platform probe\n");
950
951 hw = ieee80211_alloc_hw(sizeof(struct wcn36xx), &wcn36xx_ops);
952 if (!hw) {
953 wcn36xx_err("failed to alloc hw\n");
954 ret = -ENOMEM;
955 goto out_err;
956 }
957 platform_set_drvdata(pdev, hw);
958 wcn = hw->priv;
959 wcn->hw = hw;
960 wcn->dev = &pdev->dev;
961 wcn->ctrl_ops = pdev->dev.platform_data;
962
963 mutex_init(&wcn->hal_mutex);
964
965 if (!wcn->ctrl_ops->get_hw_mac(addr)) {
966 wcn36xx_info("mac address: %pM\n", addr);
967 SET_IEEE80211_PERM_ADDR(wcn->hw, addr);
968 }
969
970 ret = wcn36xx_platform_get_resources(wcn, pdev);
971 if (ret)
972 goto out_wq;
973
974 wcn36xx_init_ieee80211(wcn);
975 ret = ieee80211_register_hw(wcn->hw);
976 if (ret)
977 goto out_unmap;
978
979 return 0;
980
981out_unmap:
982 iounmap(wcn->mmio);
983out_wq:
984 ieee80211_free_hw(hw);
985out_err:
986 return ret;
987}
988static int wcn36xx_remove(struct platform_device *pdev)
989{
990 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
991 struct wcn36xx *wcn = hw->priv;
992 wcn36xx_dbg(WCN36XX_DBG_MAC, "platform remove\n");
993
994 mutex_destroy(&wcn->hal_mutex);
995
996 ieee80211_unregister_hw(hw);
997 iounmap(wcn->mmio);
998 ieee80211_free_hw(hw);
999
1000 return 0;
1001}
1002static const struct platform_device_id wcn36xx_platform_id_table[] = {
1003 {
1004 .name = "wcn36xx",
1005 .driver_data = 0
1006 },
1007 {}
1008};
1009MODULE_DEVICE_TABLE(platform, wcn36xx_platform_id_table);
1010
1011static struct platform_driver wcn36xx_driver = {
1012 .probe = wcn36xx_probe,
1013 .remove = wcn36xx_remove,
1014 .driver = {
1015 .name = "wcn36xx",
1016 .owner = THIS_MODULE,
1017 },
1018 .id_table = wcn36xx_platform_id_table,
1019};
1020
1021static int __init wcn36xx_init(void)
1022{
1023 platform_driver_register(&wcn36xx_driver);
1024 return 0;
1025}
1026module_init(wcn36xx_init);
1027
1028static void __exit wcn36xx_exit(void)
1029{
1030 platform_driver_unregister(&wcn36xx_driver);
1031}
1032module_exit(wcn36xx_exit);
1033
1034MODULE_LICENSE("Dual BSD/GPL");
1035MODULE_AUTHOR("Eugene Krasnikov k.eugene.e@gmail.com");
1036MODULE_FIRMWARE(WLAN_NV_FILE);
diff --git a/drivers/net/wireless/ath/wcn36xx/pmc.c b/drivers/net/wireless/ath/wcn36xx/pmc.c
new file mode 100644
index 000000000000..28b515c81b0e
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/pmc.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19#include "wcn36xx.h"
20
21int wcn36xx_pmc_enter_bmps_state(struct wcn36xx *wcn,
22 struct ieee80211_vif *vif)
23{
24 int ret = 0;
25 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
26 /* TODO: Make sure the TX chain clean */
27 ret = wcn36xx_smd_enter_bmps(wcn, vif);
28 if (!ret) {
29 wcn36xx_dbg(WCN36XX_DBG_PMC, "Entered BMPS\n");
30 vif_priv->pw_state = WCN36XX_BMPS;
31 } else {
32 /*
33 * One of the reasons why HW will not enter BMPS is because
34 * driver is trying to enter bmps before first beacon was
35 * received just after auth complete
36 */
37 wcn36xx_err("Can not enter BMPS!\n");
38 }
39 return ret;
40}
41
42int wcn36xx_pmc_exit_bmps_state(struct wcn36xx *wcn,
43 struct ieee80211_vif *vif)
44{
45 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
46
47 if (WCN36XX_BMPS != vif_priv->pw_state) {
48 wcn36xx_err("Not in BMPS mode, no need to exit from BMPS mode!\n");
49 return -EINVAL;
50 }
51 wcn36xx_smd_exit_bmps(wcn, vif);
52 vif_priv->pw_state = WCN36XX_FULL_POWER;
53 return 0;
54}
55
56int wcn36xx_enable_keep_alive_null_packet(struct wcn36xx *wcn,
57 struct ieee80211_vif *vif)
58{
59 wcn36xx_dbg(WCN36XX_DBG_PMC, "%s\n", __func__);
60 return wcn36xx_smd_keep_alive_req(wcn, vif,
61 WCN36XX_HAL_KEEP_ALIVE_NULL_PKT);
62}
diff --git a/drivers/net/wireless/ath/wcn36xx/pmc.h b/drivers/net/wireless/ath/wcn36xx/pmc.h
new file mode 100644
index 000000000000..f72ed68b5a07
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/pmc.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _WCN36XX_PMC_H_
18#define _WCN36XX_PMC_H_
19
20struct wcn36xx;
21
22enum wcn36xx_power_state {
23 WCN36XX_FULL_POWER,
24 WCN36XX_BMPS
25};
26
27int wcn36xx_pmc_enter_bmps_state(struct wcn36xx *wcn,
28 struct ieee80211_vif *vif);
29int wcn36xx_pmc_exit_bmps_state(struct wcn36xx *wcn,
30 struct ieee80211_vif *vif);
31int wcn36xx_enable_keep_alive_null_packet(struct wcn36xx *wcn,
32 struct ieee80211_vif *vif);
33#endif /* _WCN36XX_PMC_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
new file mode 100644
index 000000000000..f8c3a10510c2
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -0,0 +1,2126 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19#include <linux/etherdevice.h>
20#include <linux/firmware.h>
21#include <linux/bitops.h>
22#include "smd.h"
23
24static int put_cfg_tlv_u32(struct wcn36xx *wcn, size_t *len, u32 id, u32 value)
25{
26 struct wcn36xx_hal_cfg *entry;
27 u32 *val;
28
29 if (*len + sizeof(*entry) + sizeof(u32) >= WCN36XX_HAL_BUF_SIZE) {
30 wcn36xx_err("Not enough room for TLV entry\n");
31 return -ENOMEM;
32 }
33
34 entry = (struct wcn36xx_hal_cfg *) (wcn->hal_buf + *len);
35 entry->id = id;
36 entry->len = sizeof(u32);
37 entry->pad_bytes = 0;
38 entry->reserve = 0;
39
40 val = (u32 *) (entry + 1);
41 *val = value;
42
43 *len += sizeof(*entry) + sizeof(u32);
44
45 return 0;
46}
47
48static void wcn36xx_smd_set_bss_nw_type(struct wcn36xx *wcn,
49 struct ieee80211_sta *sta,
50 struct wcn36xx_hal_config_bss_params *bss_params)
51{
52 if (IEEE80211_BAND_5GHZ == WCN36XX_BAND(wcn))
53 bss_params->nw_type = WCN36XX_HAL_11A_NW_TYPE;
54 else if (sta && sta->ht_cap.ht_supported)
55 bss_params->nw_type = WCN36XX_HAL_11N_NW_TYPE;
56 else if (sta && (sta->supp_rates[IEEE80211_BAND_2GHZ] & 0x7f))
57 bss_params->nw_type = WCN36XX_HAL_11G_NW_TYPE;
58 else
59 bss_params->nw_type = WCN36XX_HAL_11B_NW_TYPE;
60}
61
62static inline u8 is_cap_supported(unsigned long caps, unsigned long flag)
63{
64 return caps & flag ? 1 : 0;
65}
66static void wcn36xx_smd_set_bss_ht_params(struct ieee80211_vif *vif,
67 struct ieee80211_sta *sta,
68 struct wcn36xx_hal_config_bss_params *bss_params)
69{
70 if (sta && sta->ht_cap.ht_supported) {
71 unsigned long caps = sta->ht_cap.cap;
72 bss_params->ht = sta->ht_cap.ht_supported;
73 bss_params->tx_channel_width_set = is_cap_supported(caps,
74 IEEE80211_HT_CAP_SUP_WIDTH_20_40);
75 bss_params->lsig_tx_op_protection_full_support =
76 is_cap_supported(caps,
77 IEEE80211_HT_CAP_LSIG_TXOP_PROT);
78
79 bss_params->ht_oper_mode = vif->bss_conf.ht_operation_mode;
80 bss_params->lln_non_gf_coexist =
81 !!(vif->bss_conf.ht_operation_mode &
82 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
83 /* IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT */
84 bss_params->dual_cts_protection = 0;
85 /* IEEE80211_HT_OP_MODE_PROTECTION_20MHZ */
86 bss_params->ht20_coexist = 0;
87 }
88}
89
90static void wcn36xx_smd_set_sta_ht_params(struct ieee80211_sta *sta,
91 struct wcn36xx_hal_config_sta_params *sta_params)
92{
93 if (sta->ht_cap.ht_supported) {
94 unsigned long caps = sta->ht_cap.cap;
95 sta_params->ht_capable = sta->ht_cap.ht_supported;
96 sta_params->tx_channel_width_set = is_cap_supported(caps,
97 IEEE80211_HT_CAP_SUP_WIDTH_20_40);
98 sta_params->lsig_txop_protection = is_cap_supported(caps,
99 IEEE80211_HT_CAP_LSIG_TXOP_PROT);
100
101 sta_params->max_ampdu_size = sta->ht_cap.ampdu_factor;
102 sta_params->max_ampdu_density = sta->ht_cap.ampdu_density;
103 sta_params->max_amsdu_size = is_cap_supported(caps,
104 IEEE80211_HT_CAP_MAX_AMSDU);
105 sta_params->sgi_20Mhz = is_cap_supported(caps,
106 IEEE80211_HT_CAP_SGI_20);
107 sta_params->sgi_40mhz = is_cap_supported(caps,
108 IEEE80211_HT_CAP_SGI_40);
109 sta_params->green_field_capable = is_cap_supported(caps,
110 IEEE80211_HT_CAP_GRN_FLD);
111 sta_params->delayed_ba_support = is_cap_supported(caps,
112 IEEE80211_HT_CAP_DELAY_BA);
113 sta_params->dsss_cck_mode_40mhz = is_cap_supported(caps,
114 IEEE80211_HT_CAP_DSSSCCK40);
115 }
116}
117
118static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
119 struct ieee80211_vif *vif,
120 struct ieee80211_sta *sta,
121 struct wcn36xx_hal_config_sta_params *sta_params)
122{
123 struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv;
124 struct wcn36xx_sta *priv_sta = NULL;
125 if (vif->type == NL80211_IFTYPE_ADHOC ||
126 vif->type == NL80211_IFTYPE_AP ||
127 vif->type == NL80211_IFTYPE_MESH_POINT) {
128 sta_params->type = 1;
129 sta_params->sta_index = 0xFF;
130 } else {
131 sta_params->type = 0;
132 sta_params->sta_index = 1;
133 }
134
135 sta_params->listen_interval = WCN36XX_LISTEN_INTERVAL(wcn);
136
137 /*
138 * In STA mode ieee80211_sta contains bssid and ieee80211_vif
139 * contains our mac address. In AP mode we are bssid so vif
140 * contains bssid and ieee80211_sta contains mac.
141 */
142 if (NL80211_IFTYPE_STATION == vif->type)
143 memcpy(&sta_params->mac, vif->addr, ETH_ALEN);
144 else
145 memcpy(&sta_params->bssid, vif->addr, ETH_ALEN);
146
147 sta_params->encrypt_type = priv_vif->encrypt_type;
148 sta_params->short_preamble_supported =
149 !(WCN36XX_FLAGS(wcn) &
150 IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE);
151
152 sta_params->rifs_mode = 0;
153 sta_params->rmf = 0;
154 sta_params->action = 0;
155 sta_params->uapsd = 0;
156 sta_params->mimo_ps = WCN36XX_HAL_HT_MIMO_PS_STATIC;
157 sta_params->max_ampdu_duration = 0;
158 sta_params->bssid_index = priv_vif->bss_index;
159 sta_params->p2p = 0;
160
161 if (sta) {
162 priv_sta = (struct wcn36xx_sta *)sta->drv_priv;
163 if (NL80211_IFTYPE_STATION == vif->type)
164 memcpy(&sta_params->bssid, sta->addr, ETH_ALEN);
165 else
166 memcpy(&sta_params->mac, sta->addr, ETH_ALEN);
167 sta_params->wmm_enabled = sta->wme;
168 sta_params->max_sp_len = sta->max_sp;
169 sta_params->aid = priv_sta->aid;
170 wcn36xx_smd_set_sta_ht_params(sta, sta_params);
171 memcpy(&sta_params->supported_rates, &priv_sta->supported_rates,
172 sizeof(priv_sta->supported_rates));
173 } else {
174 wcn36xx_set_default_rates(&sta_params->supported_rates);
175 }
176}
177
178static int wcn36xx_smd_send_and_wait(struct wcn36xx *wcn, size_t len)
179{
180 int ret = 0;
181 wcn36xx_dbg_dump(WCN36XX_DBG_SMD_DUMP, "HAL >>> ", wcn->hal_buf, len);
182
183 init_completion(&wcn->hal_rsp_compl);
184 ret = wcn->ctrl_ops->tx(wcn->hal_buf, len);
185 if (ret) {
186 wcn36xx_err("HAL TX failed\n");
187 goto out;
188 }
189 if (wait_for_completion_timeout(&wcn->hal_rsp_compl,
190 msecs_to_jiffies(HAL_MSG_TIMEOUT)) <= 0) {
191 wcn36xx_err("Timeout while waiting SMD response\n");
192 ret = -ETIME;
193 goto out;
194 }
195out:
196 return ret;
197}
198
199#define INIT_HAL_MSG(msg_body, type) \
200 do { \
201 memset(&msg_body, 0, sizeof(msg_body)); \
202 msg_body.header.msg_type = type; \
203 msg_body.header.msg_version = WCN36XX_HAL_MSG_VERSION0; \
204 msg_body.header.len = sizeof(msg_body); \
205 } while (0) \
206
207#define PREPARE_HAL_BUF(send_buf, msg_body) \
208 do { \
209 memset(send_buf, 0, msg_body.header.len); \
210 memcpy(send_buf, &msg_body, sizeof(msg_body)); \
211 } while (0) \
212
213static int wcn36xx_smd_rsp_status_check(void *buf, size_t len)
214{
215 struct wcn36xx_fw_msg_status_rsp *rsp;
216
217 if (len < sizeof(struct wcn36xx_hal_msg_header) +
218 sizeof(struct wcn36xx_fw_msg_status_rsp))
219 return -EIO;
220
221 rsp = (struct wcn36xx_fw_msg_status_rsp *)
222 (buf + sizeof(struct wcn36xx_hal_msg_header));
223
224 if (WCN36XX_FW_MSG_RESULT_SUCCESS != rsp->status)
225 return rsp->status;
226
227 return 0;
228}
229
230int wcn36xx_smd_load_nv(struct wcn36xx *wcn)
231{
232 const struct firmware *nv;
233 struct nv_data *nv_d;
234 struct wcn36xx_hal_nv_img_download_req_msg msg_body;
235 int fw_bytes_left;
236 int ret;
237 u16 fm_offset = 0;
238
239 ret = request_firmware(&nv, WLAN_NV_FILE, wcn->dev);
240 if (ret) {
241 wcn36xx_err("Failed to load nv file %s: %d\n",
242 WLAN_NV_FILE, ret);
243 goto out_free_nv;
244 }
245
246 nv_d = (struct nv_data *)nv->data;
247 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DOWNLOAD_NV_REQ);
248
249 msg_body.header.len += WCN36XX_NV_FRAGMENT_SIZE;
250
251 msg_body.frag_number = 0;
252 /* hal_buf must be protected with mutex */
253 mutex_lock(&wcn->hal_mutex);
254
255 do {
256 fw_bytes_left = nv->size - fm_offset - 4;
257 if (fw_bytes_left > WCN36XX_NV_FRAGMENT_SIZE) {
258 msg_body.last_fragment = 0;
259 msg_body.nv_img_buffer_size = WCN36XX_NV_FRAGMENT_SIZE;
260 } else {
261 msg_body.last_fragment = 1;
262 msg_body.nv_img_buffer_size = fw_bytes_left;
263
264 /* Do not forget update general message len */
265 msg_body.header.len = sizeof(msg_body) + fw_bytes_left;
266
267 }
268
269 /* Add load NV request message header */
270 memcpy(wcn->hal_buf, &msg_body, sizeof(msg_body));
271
272 /* Add NV body itself */
273 memcpy(wcn->hal_buf + sizeof(msg_body),
274 &nv_d->table + fm_offset,
275 msg_body.nv_img_buffer_size);
276
277 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
278 if (ret)
279 goto out_unlock;
280 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf,
281 wcn->hal_rsp_len);
282 if (ret) {
283 wcn36xx_err("hal_load_nv response failed err=%d\n",
284 ret);
285 goto out_unlock;
286 }
287 msg_body.frag_number++;
288 fm_offset += WCN36XX_NV_FRAGMENT_SIZE;
289
290 } while (msg_body.last_fragment != 1);
291
292out_unlock:
293 mutex_unlock(&wcn->hal_mutex);
294out_free_nv:
295 release_firmware(nv);
296
297 return ret;
298}
299
300static int wcn36xx_smd_start_rsp(struct wcn36xx *wcn, void *buf, size_t len)
301{
302 struct wcn36xx_hal_mac_start_rsp_msg *rsp;
303
304 if (len < sizeof(*rsp))
305 return -EIO;
306
307 rsp = (struct wcn36xx_hal_mac_start_rsp_msg *)buf;
308
309 if (WCN36XX_FW_MSG_RESULT_SUCCESS != rsp->start_rsp_params.status)
310 return -EIO;
311
312 memcpy(wcn->crm_version, rsp->start_rsp_params.crm_version,
313 WCN36XX_HAL_VERSION_LENGTH);
314 memcpy(wcn->wlan_version, rsp->start_rsp_params.wlan_version,
315 WCN36XX_HAL_VERSION_LENGTH);
316
317 /* null terminate the strings, just in case */
318 wcn->crm_version[WCN36XX_HAL_VERSION_LENGTH] = '\0';
319 wcn->wlan_version[WCN36XX_HAL_VERSION_LENGTH] = '\0';
320
321 wcn->fw_revision = rsp->start_rsp_params.version.revision;
322 wcn->fw_version = rsp->start_rsp_params.version.version;
323 wcn->fw_minor = rsp->start_rsp_params.version.minor;
324 wcn->fw_major = rsp->start_rsp_params.version.major;
325
326 wcn36xx_info("firmware WLAN version '%s' and CRM version '%s'\n",
327 wcn->wlan_version, wcn->crm_version);
328
329 wcn36xx_info("firmware API %u.%u.%u.%u, %u stations, %u bssids\n",
330 wcn->fw_major, wcn->fw_minor,
331 wcn->fw_version, wcn->fw_revision,
332 rsp->start_rsp_params.stations,
333 rsp->start_rsp_params.bssids);
334
335 return 0;
336}
337
338int wcn36xx_smd_start(struct wcn36xx *wcn)
339{
340 struct wcn36xx_hal_mac_start_req_msg msg_body;
341 int ret = 0;
342
343 mutex_lock(&wcn->hal_mutex);
344 INIT_HAL_MSG(msg_body, WCN36XX_HAL_START_REQ);
345
346 msg_body.params.type = DRIVER_TYPE_PRODUCTION;
347 msg_body.params.len = 0;
348
349 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
350
351 wcn36xx_dbg(WCN36XX_DBG_HAL, "hal start type %d\n",
352 msg_body.params.type);
353
354 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
355 if (ret) {
356 wcn36xx_err("Sending hal_start failed\n");
357 goto out;
358 }
359
360 ret = wcn36xx_smd_start_rsp(wcn, wcn->hal_buf, wcn->hal_rsp_len);
361 if (ret) {
362 wcn36xx_err("hal_start response failed err=%d\n", ret);
363 goto out;
364 }
365
366out:
367 mutex_unlock(&wcn->hal_mutex);
368 return ret;
369}
370
371int wcn36xx_smd_stop(struct wcn36xx *wcn)
372{
373 struct wcn36xx_hal_mac_stop_req_msg msg_body;
374 int ret = 0;
375
376 mutex_lock(&wcn->hal_mutex);
377 INIT_HAL_MSG(msg_body, WCN36XX_HAL_STOP_REQ);
378
379 msg_body.stop_req_params.reason = HAL_STOP_TYPE_RF_KILL;
380
381 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
382
383 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
384 if (ret) {
385 wcn36xx_err("Sending hal_stop failed\n");
386 goto out;
387 }
388 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
389 if (ret) {
390 wcn36xx_err("hal_stop response failed err=%d\n", ret);
391 goto out;
392 }
393out:
394 mutex_unlock(&wcn->hal_mutex);
395 return ret;
396}
397
398int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode)
399{
400 struct wcn36xx_hal_init_scan_req_msg msg_body;
401 int ret = 0;
402
403 mutex_lock(&wcn->hal_mutex);
404 INIT_HAL_MSG(msg_body, WCN36XX_HAL_INIT_SCAN_REQ);
405
406 msg_body.mode = mode;
407
408 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
409
410 wcn36xx_dbg(WCN36XX_DBG_HAL, "hal init scan mode %d\n", msg_body.mode);
411
412 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
413 if (ret) {
414 wcn36xx_err("Sending hal_init_scan failed\n");
415 goto out;
416 }
417 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
418 if (ret) {
419 wcn36xx_err("hal_init_scan response failed err=%d\n", ret);
420 goto out;
421 }
422out:
423 mutex_unlock(&wcn->hal_mutex);
424 return ret;
425}
426
427int wcn36xx_smd_start_scan(struct wcn36xx *wcn)
428{
429 struct wcn36xx_hal_start_scan_req_msg msg_body;
430 int ret = 0;
431
432 mutex_lock(&wcn->hal_mutex);
433 INIT_HAL_MSG(msg_body, WCN36XX_HAL_START_SCAN_REQ);
434
435 msg_body.scan_channel = WCN36XX_HW_CHANNEL(wcn);
436
437 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
438
439 wcn36xx_dbg(WCN36XX_DBG_HAL, "hal start scan channel %d\n",
440 msg_body.scan_channel);
441
442 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
443 if (ret) {
444 wcn36xx_err("Sending hal_start_scan failed\n");
445 goto out;
446 }
447 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
448 if (ret) {
449 wcn36xx_err("hal_start_scan response failed err=%d\n", ret);
450 goto out;
451 }
452out:
453 mutex_unlock(&wcn->hal_mutex);
454 return ret;
455}
456
457int wcn36xx_smd_end_scan(struct wcn36xx *wcn)
458{
459 struct wcn36xx_hal_end_scan_req_msg msg_body;
460 int ret = 0;
461
462 mutex_lock(&wcn->hal_mutex);
463 INIT_HAL_MSG(msg_body, WCN36XX_HAL_END_SCAN_REQ);
464
465 msg_body.scan_channel = WCN36XX_HW_CHANNEL(wcn);
466
467 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
468
469 wcn36xx_dbg(WCN36XX_DBG_HAL, "hal end scan channel %d\n",
470 msg_body.scan_channel);
471
472 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
473 if (ret) {
474 wcn36xx_err("Sending hal_end_scan failed\n");
475 goto out;
476 }
477 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
478 if (ret) {
479 wcn36xx_err("hal_end_scan response failed err=%d\n", ret);
480 goto out;
481 }
482out:
483 mutex_unlock(&wcn->hal_mutex);
484 return ret;
485}
486
487int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
488 enum wcn36xx_hal_sys_mode mode)
489{
490 struct wcn36xx_hal_finish_scan_req_msg msg_body;
491 int ret = 0;
492
493 mutex_lock(&wcn->hal_mutex);
494 INIT_HAL_MSG(msg_body, WCN36XX_HAL_FINISH_SCAN_REQ);
495
496 msg_body.mode = mode;
497
498 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
499
500 wcn36xx_dbg(WCN36XX_DBG_HAL, "hal finish scan mode %d\n",
501 msg_body.mode);
502
503 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
504 if (ret) {
505 wcn36xx_err("Sending hal_finish_scan failed\n");
506 goto out;
507 }
508 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
509 if (ret) {
510 wcn36xx_err("hal_finish_scan response failed err=%d\n", ret);
511 goto out;
512 }
513out:
514 mutex_unlock(&wcn->hal_mutex);
515 return ret;
516}
517
518static int wcn36xx_smd_switch_channel_rsp(void *buf, size_t len)
519{
520 struct wcn36xx_hal_switch_channel_rsp_msg *rsp;
521 int ret = 0;
522
523 ret = wcn36xx_smd_rsp_status_check(buf, len);
524 if (ret)
525 return ret;
526 rsp = (struct wcn36xx_hal_switch_channel_rsp_msg *)buf;
527 wcn36xx_dbg(WCN36XX_DBG_HAL, "channel switched to: %d, status: %d\n",
528 rsp->channel_number, rsp->status);
529 return ret;
530}
531
532int wcn36xx_smd_switch_channel(struct wcn36xx *wcn,
533 struct ieee80211_vif *vif, int ch)
534{
535 struct wcn36xx_hal_switch_channel_req_msg msg_body;
536 int ret = 0;
537
538 mutex_lock(&wcn->hal_mutex);
539 INIT_HAL_MSG(msg_body, WCN36XX_HAL_CH_SWITCH_REQ);
540
541 msg_body.channel_number = (u8)ch;
542 msg_body.tx_mgmt_power = 0xbf;
543 msg_body.max_tx_power = 0xbf;
544 memcpy(msg_body.self_sta_mac_addr, vif->addr, ETH_ALEN);
545
546 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
547
548 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
549 if (ret) {
550 wcn36xx_err("Sending hal_switch_channel failed\n");
551 goto out;
552 }
553 ret = wcn36xx_smd_switch_channel_rsp(wcn->hal_buf, wcn->hal_rsp_len);
554 if (ret) {
555 wcn36xx_err("hal_switch_channel response failed err=%d\n", ret);
556 goto out;
557 }
558out:
559 mutex_unlock(&wcn->hal_mutex);
560 return ret;
561}
562
563static int wcn36xx_smd_update_scan_params_rsp(void *buf, size_t len)
564{
565 struct wcn36xx_hal_update_scan_params_resp *rsp;
566
567 rsp = (struct wcn36xx_hal_update_scan_params_resp *)buf;
568
569 /* Remove the PNO version bit */
570 rsp->status &= (~(WCN36XX_FW_MSG_PNO_VERSION_MASK));
571
572 if (WCN36XX_FW_MSG_RESULT_SUCCESS != rsp->status) {
573 wcn36xx_warn("error response from update scan\n");
574 return rsp->status;
575 }
576
577 return 0;
578}
579
580int wcn36xx_smd_update_scan_params(struct wcn36xx *wcn)
581{
582 struct wcn36xx_hal_update_scan_params_req msg_body;
583 int ret = 0;
584
585 mutex_lock(&wcn->hal_mutex);
586 INIT_HAL_MSG(msg_body, WCN36XX_HAL_UPDATE_SCAN_PARAM_REQ);
587
588 msg_body.dot11d_enabled = 0;
589 msg_body.dot11d_resolved = 0;
590 msg_body.channel_count = 26;
591 msg_body.active_min_ch_time = 60;
592 msg_body.active_max_ch_time = 120;
593 msg_body.passive_min_ch_time = 60;
594 msg_body.passive_max_ch_time = 110;
595 msg_body.state = 0;
596
597 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
598
599 wcn36xx_dbg(WCN36XX_DBG_HAL,
600 "hal update scan params channel_count %d\n",
601 msg_body.channel_count);
602
603 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
604 if (ret) {
605 wcn36xx_err("Sending hal_update_scan_params failed\n");
606 goto out;
607 }
608 ret = wcn36xx_smd_update_scan_params_rsp(wcn->hal_buf,
609 wcn->hal_rsp_len);
610 if (ret) {
611 wcn36xx_err("hal_update_scan_params response failed err=%d\n",
612 ret);
613 goto out;
614 }
615out:
616 mutex_unlock(&wcn->hal_mutex);
617 return ret;
618}
619
620static int wcn36xx_smd_add_sta_self_rsp(struct wcn36xx *wcn,
621 struct ieee80211_vif *vif,
622 void *buf,
623 size_t len)
624{
625 struct wcn36xx_hal_add_sta_self_rsp_msg *rsp;
626 struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv;
627
628 if (len < sizeof(*rsp))
629 return -EINVAL;
630
631 rsp = (struct wcn36xx_hal_add_sta_self_rsp_msg *)buf;
632
633 if (rsp->status != WCN36XX_FW_MSG_RESULT_SUCCESS) {
634 wcn36xx_warn("hal add sta self failure: %d\n",
635 rsp->status);
636 return rsp->status;
637 }
638
639 wcn36xx_dbg(WCN36XX_DBG_HAL,
640 "hal add sta self status %d self_sta_index %d dpu_index %d\n",
641 rsp->status, rsp->self_sta_index, rsp->dpu_index);
642
643 priv_vif->self_sta_index = rsp->self_sta_index;
644 priv_vif->self_dpu_desc_index = rsp->dpu_index;
645
646 return 0;
647}
648
649int wcn36xx_smd_add_sta_self(struct wcn36xx *wcn, struct ieee80211_vif *vif)
650{
651 struct wcn36xx_hal_add_sta_self_req msg_body;
652 int ret = 0;
653
654 mutex_lock(&wcn->hal_mutex);
655 INIT_HAL_MSG(msg_body, WCN36XX_HAL_ADD_STA_SELF_REQ);
656
657 memcpy(&msg_body.self_addr, vif->addr, ETH_ALEN);
658
659 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
660
661 wcn36xx_dbg(WCN36XX_DBG_HAL,
662 "hal add sta self self_addr %pM status %d\n",
663 msg_body.self_addr, msg_body.status);
664
665 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
666 if (ret) {
667 wcn36xx_err("Sending hal_add_sta_self failed\n");
668 goto out;
669 }
670 ret = wcn36xx_smd_add_sta_self_rsp(wcn,
671 vif,
672 wcn->hal_buf,
673 wcn->hal_rsp_len);
674 if (ret) {
675 wcn36xx_err("hal_add_sta_self response failed err=%d\n", ret);
676 goto out;
677 }
678out:
679 mutex_unlock(&wcn->hal_mutex);
680 return ret;
681}
682
683int wcn36xx_smd_delete_sta_self(struct wcn36xx *wcn, u8 *addr)
684{
685 struct wcn36xx_hal_del_sta_self_req_msg msg_body;
686 int ret = 0;
687
688 mutex_lock(&wcn->hal_mutex);
689 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DEL_STA_SELF_REQ);
690
691 memcpy(&msg_body.self_addr, addr, ETH_ALEN);
692
693 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
694
695 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
696 if (ret) {
697 wcn36xx_err("Sending hal_delete_sta_self failed\n");
698 goto out;
699 }
700 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
701 if (ret) {
702 wcn36xx_err("hal_delete_sta_self response failed err=%d\n",
703 ret);
704 goto out;
705 }
706out:
707 mutex_unlock(&wcn->hal_mutex);
708 return ret;
709}
710
711int wcn36xx_smd_delete_sta(struct wcn36xx *wcn, u8 sta_index)
712{
713 struct wcn36xx_hal_delete_sta_req_msg msg_body;
714 int ret = 0;
715
716 mutex_lock(&wcn->hal_mutex);
717 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DELETE_STA_REQ);
718
719 msg_body.sta_index = sta_index;
720
721 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
722
723 wcn36xx_dbg(WCN36XX_DBG_HAL,
724 "hal delete sta sta_index %d\n",
725 msg_body.sta_index);
726
727 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
728 if (ret) {
729 wcn36xx_err("Sending hal_delete_sta failed\n");
730 goto out;
731 }
732 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
733 if (ret) {
734 wcn36xx_err("hal_delete_sta response failed err=%d\n", ret);
735 goto out;
736 }
737out:
738 mutex_unlock(&wcn->hal_mutex);
739 return ret;
740}
741
742static int wcn36xx_smd_join_rsp(void *buf, size_t len)
743{
744 struct wcn36xx_hal_join_rsp_msg *rsp;
745
746 if (wcn36xx_smd_rsp_status_check(buf, len))
747 return -EIO;
748
749 rsp = (struct wcn36xx_hal_join_rsp_msg *)buf;
750
751 wcn36xx_dbg(WCN36XX_DBG_HAL,
752 "hal rsp join status %d tx_mgmt_power %d\n",
753 rsp->status, rsp->tx_mgmt_power);
754
755 return 0;
756}
757
758int wcn36xx_smd_join(struct wcn36xx *wcn, const u8 *bssid, u8 *vif, u8 ch)
759{
760 struct wcn36xx_hal_join_req_msg msg_body;
761 int ret = 0;
762
763 mutex_lock(&wcn->hal_mutex);
764 INIT_HAL_MSG(msg_body, WCN36XX_HAL_JOIN_REQ);
765
766 memcpy(&msg_body.bssid, bssid, ETH_ALEN);
767 memcpy(&msg_body.self_sta_mac_addr, vif, ETH_ALEN);
768 msg_body.channel = ch;
769
770 if (conf_is_ht40_minus(&wcn->hw->conf))
771 msg_body.secondary_channel_offset =
772 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
773 else if (conf_is_ht40_plus(&wcn->hw->conf))
774 msg_body.secondary_channel_offset =
775 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
776 else
777 msg_body.secondary_channel_offset =
778 PHY_SINGLE_CHANNEL_CENTERED;
779
780 msg_body.link_state = WCN36XX_HAL_LINK_PREASSOC_STATE;
781
782 msg_body.max_tx_power = 0xbf;
783 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
784
785 wcn36xx_dbg(WCN36XX_DBG_HAL,
786 "hal join req bssid %pM self_sta_mac_addr %pM channel %d link_state %d\n",
787 msg_body.bssid, msg_body.self_sta_mac_addr,
788 msg_body.channel, msg_body.link_state);
789
790 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
791 if (ret) {
792 wcn36xx_err("Sending hal_join failed\n");
793 goto out;
794 }
795 ret = wcn36xx_smd_join_rsp(wcn->hal_buf, wcn->hal_rsp_len);
796 if (ret) {
797 wcn36xx_err("hal_join response failed err=%d\n", ret);
798 goto out;
799 }
800out:
801 mutex_unlock(&wcn->hal_mutex);
802 return ret;
803}
804
805int wcn36xx_smd_set_link_st(struct wcn36xx *wcn, const u8 *bssid,
806 const u8 *sta_mac,
807 enum wcn36xx_hal_link_state state)
808{
809 struct wcn36xx_hal_set_link_state_req_msg msg_body;
810 int ret = 0;
811
812 mutex_lock(&wcn->hal_mutex);
813 INIT_HAL_MSG(msg_body, WCN36XX_HAL_SET_LINK_ST_REQ);
814
815 memcpy(&msg_body.bssid, bssid, ETH_ALEN);
816 memcpy(&msg_body.self_mac_addr, sta_mac, ETH_ALEN);
817 msg_body.state = state;
818
819 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
820
821 wcn36xx_dbg(WCN36XX_DBG_HAL,
822 "hal set link state bssid %pM self_mac_addr %pM state %d\n",
823 msg_body.bssid, msg_body.self_mac_addr, msg_body.state);
824
825 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
826 if (ret) {
827 wcn36xx_err("Sending hal_set_link_st failed\n");
828 goto out;
829 }
830 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
831 if (ret) {
832 wcn36xx_err("hal_set_link_st response failed err=%d\n", ret);
833 goto out;
834 }
835out:
836 mutex_unlock(&wcn->hal_mutex);
837 return ret;
838}
839
840static void wcn36xx_smd_convert_sta_to_v1(struct wcn36xx *wcn,
841 const struct wcn36xx_hal_config_sta_params *orig,
842 struct wcn36xx_hal_config_sta_params_v1 *v1)
843{
844 /* convert orig to v1 format */
845 memcpy(&v1->bssid, orig->bssid, ETH_ALEN);
846 memcpy(&v1->mac, orig->mac, ETH_ALEN);
847 v1->aid = orig->aid;
848 v1->type = orig->type;
849 v1->listen_interval = orig->listen_interval;
850 v1->ht_capable = orig->ht_capable;
851
852 v1->max_ampdu_size = orig->max_ampdu_size;
853 v1->max_ampdu_density = orig->max_ampdu_density;
854 v1->sgi_40mhz = orig->sgi_40mhz;
855 v1->sgi_20Mhz = orig->sgi_20Mhz;
856
857 memcpy(&v1->supported_rates, &orig->supported_rates,
858 sizeof(orig->supported_rates));
859 v1->sta_index = orig->sta_index;
860}
861
862static int wcn36xx_smd_config_sta_rsp(struct wcn36xx *wcn,
863 struct ieee80211_sta *sta,
864 void *buf,
865 size_t len)
866{
867 struct wcn36xx_hal_config_sta_rsp_msg *rsp;
868 struct config_sta_rsp_params *params;
869 struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
870
871 if (len < sizeof(*rsp))
872 return -EINVAL;
873
874 rsp = (struct wcn36xx_hal_config_sta_rsp_msg *)buf;
875 params = &rsp->params;
876
877 if (params->status != WCN36XX_FW_MSG_RESULT_SUCCESS) {
878 wcn36xx_warn("hal config sta response failure: %d\n",
879 params->status);
880 return -EIO;
881 }
882
883 sta_priv->sta_index = params->sta_index;
884 sta_priv->dpu_desc_index = params->dpu_index;
885
886 wcn36xx_dbg(WCN36XX_DBG_HAL,
887 "hal config sta rsp status %d sta_index %d bssid_index %d p2p %d\n",
888 params->status, params->sta_index, params->bssid_index,
889 params->p2p);
890
891 return 0;
892}
893
894static int wcn36xx_smd_config_sta_v1(struct wcn36xx *wcn,
895 const struct wcn36xx_hal_config_sta_req_msg *orig)
896{
897 struct wcn36xx_hal_config_sta_req_msg_v1 msg_body;
898 struct wcn36xx_hal_config_sta_params_v1 *sta = &msg_body.sta_params;
899
900 INIT_HAL_MSG(msg_body, WCN36XX_HAL_CONFIG_STA_REQ);
901
902 wcn36xx_smd_convert_sta_to_v1(wcn, &orig->sta_params,
903 &msg_body.sta_params);
904
905 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
906
907 wcn36xx_dbg(WCN36XX_DBG_HAL,
908 "hal config sta v1 action %d sta_index %d bssid_index %d bssid %pM type %d mac %pM aid %d\n",
909 sta->action, sta->sta_index, sta->bssid_index,
910 sta->bssid, sta->type, sta->mac, sta->aid);
911
912 return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
913}
914
915int wcn36xx_smd_config_sta(struct wcn36xx *wcn, struct ieee80211_vif *vif,
916 struct ieee80211_sta *sta)
917{
918 struct wcn36xx_hal_config_sta_req_msg msg;
919 struct wcn36xx_hal_config_sta_params *sta_params;
920 int ret = 0;
921
922 mutex_lock(&wcn->hal_mutex);
923 INIT_HAL_MSG(msg, WCN36XX_HAL_CONFIG_STA_REQ);
924
925 sta_params = &msg.sta_params;
926
927 wcn36xx_smd_set_sta_params(wcn, vif, sta, sta_params);
928
929 if (!wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) {
930 ret = wcn36xx_smd_config_sta_v1(wcn, &msg);
931 } else {
932 PREPARE_HAL_BUF(wcn->hal_buf, msg);
933
934 wcn36xx_dbg(WCN36XX_DBG_HAL,
935 "hal config sta action %d sta_index %d bssid_index %d bssid %pM type %d mac %pM aid %d\n",
936 sta_params->action, sta_params->sta_index,
937 sta_params->bssid_index, sta_params->bssid,
938 sta_params->type, sta_params->mac, sta_params->aid);
939
940 ret = wcn36xx_smd_send_and_wait(wcn, msg.header.len);
941 }
942 if (ret) {
943 wcn36xx_err("Sending hal_config_sta failed\n");
944 goto out;
945 }
946 ret = wcn36xx_smd_config_sta_rsp(wcn,
947 sta,
948 wcn->hal_buf,
949 wcn->hal_rsp_len);
950 if (ret) {
951 wcn36xx_err("hal_config_sta response failed err=%d\n", ret);
952 goto out;
953 }
954out:
955 mutex_unlock(&wcn->hal_mutex);
956 return ret;
957}
958
959static int wcn36xx_smd_config_bss_v1(struct wcn36xx *wcn,
960 const struct wcn36xx_hal_config_bss_req_msg *orig)
961{
962 struct wcn36xx_hal_config_bss_req_msg_v1 msg_body;
963 struct wcn36xx_hal_config_bss_params_v1 *bss = &msg_body.bss_params;
964 struct wcn36xx_hal_config_sta_params_v1 *sta = &bss->sta;
965
966 INIT_HAL_MSG(msg_body, WCN36XX_HAL_CONFIG_BSS_REQ);
967
968 /* convert orig to v1 */
969 memcpy(&msg_body.bss_params.bssid,
970 &orig->bss_params.bssid, ETH_ALEN);
971 memcpy(&msg_body.bss_params.self_mac_addr,
972 &orig->bss_params.self_mac_addr, ETH_ALEN);
973
974 msg_body.bss_params.bss_type = orig->bss_params.bss_type;
975 msg_body.bss_params.oper_mode = orig->bss_params.oper_mode;
976 msg_body.bss_params.nw_type = orig->bss_params.nw_type;
977
978 msg_body.bss_params.short_slot_time_supported =
979 orig->bss_params.short_slot_time_supported;
980 msg_body.bss_params.lla_coexist = orig->bss_params.lla_coexist;
981 msg_body.bss_params.llb_coexist = orig->bss_params.llb_coexist;
982 msg_body.bss_params.llg_coexist = orig->bss_params.llg_coexist;
983 msg_body.bss_params.ht20_coexist = orig->bss_params.ht20_coexist;
984 msg_body.bss_params.lln_non_gf_coexist =
985 orig->bss_params.lln_non_gf_coexist;
986
987 msg_body.bss_params.lsig_tx_op_protection_full_support =
988 orig->bss_params.lsig_tx_op_protection_full_support;
989 msg_body.bss_params.rifs_mode = orig->bss_params.rifs_mode;
990 msg_body.bss_params.beacon_interval = orig->bss_params.beacon_interval;
991 msg_body.bss_params.dtim_period = orig->bss_params.dtim_period;
992 msg_body.bss_params.tx_channel_width_set =
993 orig->bss_params.tx_channel_width_set;
994 msg_body.bss_params.oper_channel = orig->bss_params.oper_channel;
995 msg_body.bss_params.ext_channel = orig->bss_params.ext_channel;
996
997 msg_body.bss_params.reserved = orig->bss_params.reserved;
998
999 memcpy(&msg_body.bss_params.ssid,
1000 &orig->bss_params.ssid,
1001 sizeof(orig->bss_params.ssid));
1002
1003 msg_body.bss_params.action = orig->bss_params.action;
1004 msg_body.bss_params.rateset = orig->bss_params.rateset;
1005 msg_body.bss_params.ht = orig->bss_params.ht;
1006 msg_body.bss_params.obss_prot_enabled =
1007 orig->bss_params.obss_prot_enabled;
1008 msg_body.bss_params.rmf = orig->bss_params.rmf;
1009 msg_body.bss_params.ht_oper_mode = orig->bss_params.ht_oper_mode;
1010 msg_body.bss_params.dual_cts_protection =
1011 orig->bss_params.dual_cts_protection;
1012
1013 msg_body.bss_params.max_probe_resp_retry_limit =
1014 orig->bss_params.max_probe_resp_retry_limit;
1015 msg_body.bss_params.hidden_ssid = orig->bss_params.hidden_ssid;
1016 msg_body.bss_params.proxy_probe_resp =
1017 orig->bss_params.proxy_probe_resp;
1018 msg_body.bss_params.edca_params_valid =
1019 orig->bss_params.edca_params_valid;
1020
1021 memcpy(&msg_body.bss_params.acbe,
1022 &orig->bss_params.acbe,
1023 sizeof(orig->bss_params.acbe));
1024 memcpy(&msg_body.bss_params.acbk,
1025 &orig->bss_params.acbk,
1026 sizeof(orig->bss_params.acbk));
1027 memcpy(&msg_body.bss_params.acvi,
1028 &orig->bss_params.acvi,
1029 sizeof(orig->bss_params.acvi));
1030 memcpy(&msg_body.bss_params.acvo,
1031 &orig->bss_params.acvo,
1032 sizeof(orig->bss_params.acvo));
1033
1034 msg_body.bss_params.ext_set_sta_key_param_valid =
1035 orig->bss_params.ext_set_sta_key_param_valid;
1036
1037 memcpy(&msg_body.bss_params.ext_set_sta_key_param,
1038 &orig->bss_params.ext_set_sta_key_param,
1039 sizeof(orig->bss_params.acvo));
1040
1041 msg_body.bss_params.wcn36xx_hal_persona =
1042 orig->bss_params.wcn36xx_hal_persona;
1043 msg_body.bss_params.spectrum_mgt_enable =
1044 orig->bss_params.spectrum_mgt_enable;
1045 msg_body.bss_params.tx_mgmt_power = orig->bss_params.tx_mgmt_power;
1046 msg_body.bss_params.max_tx_power = orig->bss_params.max_tx_power;
1047
1048 wcn36xx_smd_convert_sta_to_v1(wcn, &orig->bss_params.sta,
1049 &msg_body.bss_params.sta);
1050
1051 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1052
1053 wcn36xx_dbg(WCN36XX_DBG_HAL,
1054 "hal config bss v1 bssid %pM self_mac_addr %pM bss_type %d oper_mode %d nw_type %d\n",
1055 bss->bssid, bss->self_mac_addr, bss->bss_type,
1056 bss->oper_mode, bss->nw_type);
1057
1058 wcn36xx_dbg(WCN36XX_DBG_HAL,
1059 "- sta bssid %pM action %d sta_index %d bssid_index %d aid %d type %d mac %pM\n",
1060 sta->bssid, sta->action, sta->sta_index,
1061 sta->bssid_index, sta->aid, sta->type, sta->mac);
1062
1063 return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1064}
1065
1066
1067static int wcn36xx_smd_config_bss_rsp(struct wcn36xx *wcn,
1068 struct ieee80211_vif *vif,
1069 void *buf,
1070 size_t len)
1071{
1072 struct wcn36xx_hal_config_bss_rsp_msg *rsp;
1073 struct wcn36xx_hal_config_bss_rsp_params *params;
1074 struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv;
1075
1076 if (len < sizeof(*rsp))
1077 return -EINVAL;
1078
1079 rsp = (struct wcn36xx_hal_config_bss_rsp_msg *)buf;
1080 params = &rsp->bss_rsp_params;
1081
1082 if (params->status != WCN36XX_FW_MSG_RESULT_SUCCESS) {
1083 wcn36xx_warn("hal config bss response failure: %d\n",
1084 params->status);
1085 return -EIO;
1086 }
1087
1088 wcn36xx_dbg(WCN36XX_DBG_HAL,
1089 "hal config bss rsp status %d bss_idx %d dpu_desc_index %d"
1090 " sta_idx %d self_idx %d bcast_idx %d mac %pM"
1091 " power %d ucast_dpu_signature %d\n",
1092 params->status, params->bss_index, params->dpu_desc_index,
1093 params->bss_sta_index, params->bss_self_sta_index,
1094 params->bss_bcast_sta_idx, params->mac,
1095 params->tx_mgmt_power, params->ucast_dpu_signature);
1096
1097 priv_vif->bss_index = params->bss_index;
1098
1099 if (priv_vif->sta) {
1100 priv_vif->sta->bss_sta_index = params->bss_sta_index;
1101 priv_vif->sta->bss_dpu_desc_index = params->dpu_desc_index;
1102 }
1103
1104 priv_vif->ucast_dpu_signature = params->ucast_dpu_signature;
1105
1106 return 0;
1107}
1108
1109int wcn36xx_smd_config_bss(struct wcn36xx *wcn, struct ieee80211_vif *vif,
1110 struct ieee80211_sta *sta, const u8 *bssid,
1111 bool update)
1112{
1113 struct wcn36xx_hal_config_bss_req_msg msg;
1114 struct wcn36xx_hal_config_bss_params *bss;
1115 struct wcn36xx_hal_config_sta_params *sta_params;
1116 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
1117 int ret = 0;
1118
1119 mutex_lock(&wcn->hal_mutex);
1120 INIT_HAL_MSG(msg, WCN36XX_HAL_CONFIG_BSS_REQ);
1121
1122 bss = &msg.bss_params;
1123 sta_params = &bss->sta;
1124
1125 WARN_ON(is_zero_ether_addr(bssid));
1126
1127 memcpy(&bss->bssid, bssid, ETH_ALEN);
1128
1129 memcpy(bss->self_mac_addr, vif->addr, ETH_ALEN);
1130
1131 if (vif->type == NL80211_IFTYPE_STATION) {
1132 bss->bss_type = WCN36XX_HAL_INFRASTRUCTURE_MODE;
1133
1134 /* STA */
1135 bss->oper_mode = 1;
1136 bss->wcn36xx_hal_persona = WCN36XX_HAL_STA_MODE;
1137 } else if (vif->type == NL80211_IFTYPE_AP) {
1138 bss->bss_type = WCN36XX_HAL_INFRA_AP_MODE;
1139
1140 /* AP */
1141 bss->oper_mode = 0;
1142 bss->wcn36xx_hal_persona = WCN36XX_HAL_STA_SAP_MODE;
1143 } else if (vif->type == NL80211_IFTYPE_ADHOC ||
1144 vif->type == NL80211_IFTYPE_MESH_POINT) {
1145 bss->bss_type = WCN36XX_HAL_IBSS_MODE;
1146
1147 /* STA */
1148 bss->oper_mode = 1;
1149 } else {
1150 wcn36xx_warn("Unknown type for bss config: %d\n", vif->type);
1151 }
1152
1153 if (vif->type == NL80211_IFTYPE_STATION)
1154 wcn36xx_smd_set_bss_nw_type(wcn, sta, bss);
1155 else
1156 bss->nw_type = WCN36XX_HAL_11N_NW_TYPE;
1157
1158 bss->short_slot_time_supported = vif->bss_conf.use_short_slot;
1159 bss->lla_coexist = 0;
1160 bss->llb_coexist = 0;
1161 bss->llg_coexist = 0;
1162 bss->rifs_mode = 0;
1163 bss->beacon_interval = vif->bss_conf.beacon_int;
1164 bss->dtim_period = vif_priv->dtim_period;
1165
1166 wcn36xx_smd_set_bss_ht_params(vif, sta, bss);
1167
1168 bss->oper_channel = WCN36XX_HW_CHANNEL(wcn);
1169
1170 if (conf_is_ht40_minus(&wcn->hw->conf))
1171 bss->ext_channel = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
1172 else if (conf_is_ht40_plus(&wcn->hw->conf))
1173 bss->ext_channel = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
1174 else
1175 bss->ext_channel = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1176
1177 bss->reserved = 0;
1178 wcn36xx_smd_set_sta_params(wcn, vif, sta, sta_params);
1179
1180 /* wcn->ssid is only valid in AP and IBSS mode */
1181 bss->ssid.length = vif_priv->ssid.length;
1182 memcpy(bss->ssid.ssid, vif_priv->ssid.ssid, vif_priv->ssid.length);
1183
1184 bss->obss_prot_enabled = 0;
1185 bss->rmf = 0;
1186 bss->max_probe_resp_retry_limit = 0;
1187 bss->hidden_ssid = vif->bss_conf.hidden_ssid;
1188 bss->proxy_probe_resp = 0;
1189 bss->edca_params_valid = 0;
1190
1191 /* FIXME: set acbe, acbk, acvi and acvo */
1192
1193 bss->ext_set_sta_key_param_valid = 0;
1194
1195 /* FIXME: set ext_set_sta_key_param */
1196
1197 bss->spectrum_mgt_enable = 0;
1198 bss->tx_mgmt_power = 0;
1199 bss->max_tx_power = WCN36XX_MAX_POWER(wcn);
1200
1201 bss->action = update;
1202
1203 wcn36xx_dbg(WCN36XX_DBG_HAL,
1204 "hal config bss bssid %pM self_mac_addr %pM bss_type %d oper_mode %d nw_type %d\n",
1205 bss->bssid, bss->self_mac_addr, bss->bss_type,
1206 bss->oper_mode, bss->nw_type);
1207
1208 wcn36xx_dbg(WCN36XX_DBG_HAL,
1209 "- sta bssid %pM action %d sta_index %d bssid_index %d aid %d type %d mac %pM\n",
1210 sta_params->bssid, sta_params->action,
1211 sta_params->sta_index, sta_params->bssid_index,
1212 sta_params->aid, sta_params->type,
1213 sta_params->mac);
1214
1215 if (!wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) {
1216 ret = wcn36xx_smd_config_bss_v1(wcn, &msg);
1217 } else {
1218 PREPARE_HAL_BUF(wcn->hal_buf, msg);
1219
1220 ret = wcn36xx_smd_send_and_wait(wcn, msg.header.len);
1221 }
1222 if (ret) {
1223 wcn36xx_err("Sending hal_config_bss failed\n");
1224 goto out;
1225 }
1226 ret = wcn36xx_smd_config_bss_rsp(wcn,
1227 vif,
1228 wcn->hal_buf,
1229 wcn->hal_rsp_len);
1230 if (ret) {
1231 wcn36xx_err("hal_config_bss response failed err=%d\n", ret);
1232 goto out;
1233 }
1234out:
1235 mutex_unlock(&wcn->hal_mutex);
1236 return ret;
1237}
1238
1239int wcn36xx_smd_delete_bss(struct wcn36xx *wcn, struct ieee80211_vif *vif)
1240{
1241 struct wcn36xx_hal_delete_bss_req_msg msg_body;
1242 struct wcn36xx_vif *priv_vif = (struct wcn36xx_vif *)vif->drv_priv;
1243 int ret = 0;
1244
1245 mutex_lock(&wcn->hal_mutex);
1246 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DELETE_BSS_REQ);
1247
1248 msg_body.bss_index = priv_vif->bss_index;
1249
1250 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1251
1252 wcn36xx_dbg(WCN36XX_DBG_HAL, "hal delete bss %d\n", msg_body.bss_index);
1253
1254 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1255 if (ret) {
1256 wcn36xx_err("Sending hal_delete_bss failed\n");
1257 goto out;
1258 }
1259 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1260 if (ret) {
1261 wcn36xx_err("hal_delete_bss response failed err=%d\n", ret);
1262 goto out;
1263 }
1264out:
1265 mutex_unlock(&wcn->hal_mutex);
1266 return ret;
1267}
1268
1269int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct ieee80211_vif *vif,
1270 struct sk_buff *skb_beacon, u16 tim_off,
1271 u16 p2p_off)
1272{
1273 struct wcn36xx_hal_send_beacon_req_msg msg_body;
1274 int ret = 0;
1275
1276 mutex_lock(&wcn->hal_mutex);
1277 INIT_HAL_MSG(msg_body, WCN36XX_HAL_SEND_BEACON_REQ);
1278
1279 /* TODO need to find out why this is needed? */
1280 msg_body.beacon_length = skb_beacon->len + 6;
1281
1282 if (BEACON_TEMPLATE_SIZE > msg_body.beacon_length) {
1283 memcpy(&msg_body.beacon, &skb_beacon->len, sizeof(u32));
1284 memcpy(&(msg_body.beacon[4]), skb_beacon->data,
1285 skb_beacon->len);
1286 } else {
1287 wcn36xx_err("Beacon is to big: beacon size=%d\n",
1288 msg_body.beacon_length);
1289 return -ENOMEM;
1290 }
1291 memcpy(msg_body.bssid, vif->addr, ETH_ALEN);
1292
1293 /* TODO need to find out why this is needed? */
1294 msg_body.tim_ie_offset = tim_off+4;
1295 msg_body.p2p_ie_offset = p2p_off;
1296 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1297
1298 wcn36xx_dbg(WCN36XX_DBG_HAL,
1299 "hal send beacon beacon_length %d\n",
1300 msg_body.beacon_length);
1301
1302 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1303 if (ret) {
1304 wcn36xx_err("Sending hal_send_beacon failed\n");
1305 goto out;
1306 }
1307 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1308 if (ret) {
1309 wcn36xx_err("hal_send_beacon response failed err=%d\n", ret);
1310 goto out;
1311 }
1312out:
1313 mutex_unlock(&wcn->hal_mutex);
1314 return ret;
1315}
1316
1317int wcn36xx_smd_update_proberesp_tmpl(struct wcn36xx *wcn,
1318 struct ieee80211_vif *vif,
1319 struct sk_buff *skb)
1320{
1321 struct wcn36xx_hal_send_probe_resp_req_msg msg;
1322 int ret = 0;
1323
1324 mutex_lock(&wcn->hal_mutex);
1325 INIT_HAL_MSG(msg, WCN36XX_HAL_UPDATE_PROBE_RSP_TEMPLATE_REQ);
1326
1327 if (skb->len > BEACON_TEMPLATE_SIZE) {
1328 wcn36xx_warn("probe response template is too big: %d\n",
1329 skb->len);
1330 return -E2BIG;
1331 }
1332
1333 msg.probe_resp_template_len = skb->len;
1334 memcpy(&msg.probe_resp_template, skb->data, skb->len);
1335
1336 memcpy(msg.bssid, vif->addr, ETH_ALEN);
1337
1338 PREPARE_HAL_BUF(wcn->hal_buf, msg);
1339
1340 wcn36xx_dbg(WCN36XX_DBG_HAL,
1341 "hal update probe rsp len %d bssid %pM\n",
1342 msg.probe_resp_template_len, msg.bssid);
1343
1344 ret = wcn36xx_smd_send_and_wait(wcn, msg.header.len);
1345 if (ret) {
1346 wcn36xx_err("Sending hal_update_proberesp_tmpl failed\n");
1347 goto out;
1348 }
1349 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1350 if (ret) {
1351 wcn36xx_err("hal_update_proberesp_tmpl response failed err=%d\n",
1352 ret);
1353 goto out;
1354 }
1355out:
1356 mutex_unlock(&wcn->hal_mutex);
1357 return ret;
1358}
1359
1360int wcn36xx_smd_set_stakey(struct wcn36xx *wcn,
1361 enum ani_ed_type enc_type,
1362 u8 keyidx,
1363 u8 keylen,
1364 u8 *key,
1365 u8 sta_index)
1366{
1367 struct wcn36xx_hal_set_sta_key_req_msg msg_body;
1368 int ret = 0;
1369
1370 mutex_lock(&wcn->hal_mutex);
1371 INIT_HAL_MSG(msg_body, WCN36XX_HAL_SET_STAKEY_REQ);
1372
1373 msg_body.set_sta_key_params.sta_index = sta_index;
1374 msg_body.set_sta_key_params.enc_type = enc_type;
1375
1376 msg_body.set_sta_key_params.key[0].id = keyidx;
1377 msg_body.set_sta_key_params.key[0].unicast = 1;
1378 msg_body.set_sta_key_params.key[0].direction = WCN36XX_HAL_TX_RX;
1379 msg_body.set_sta_key_params.key[0].pae_role = 0;
1380 msg_body.set_sta_key_params.key[0].length = keylen;
1381 memcpy(msg_body.set_sta_key_params.key[0].key, key, keylen);
1382 msg_body.set_sta_key_params.single_tid_rc = 1;
1383
1384 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1385
1386 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1387 if (ret) {
1388 wcn36xx_err("Sending hal_set_stakey failed\n");
1389 goto out;
1390 }
1391 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1392 if (ret) {
1393 wcn36xx_err("hal_set_stakey response failed err=%d\n", ret);
1394 goto out;
1395 }
1396out:
1397 mutex_unlock(&wcn->hal_mutex);
1398 return ret;
1399}
1400
1401int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
1402 enum ani_ed_type enc_type,
1403 u8 keyidx,
1404 u8 keylen,
1405 u8 *key)
1406{
1407 struct wcn36xx_hal_set_bss_key_req_msg msg_body;
1408 int ret = 0;
1409
1410 mutex_lock(&wcn->hal_mutex);
1411 INIT_HAL_MSG(msg_body, WCN36XX_HAL_SET_BSSKEY_REQ);
1412 msg_body.bss_idx = 0;
1413 msg_body.enc_type = enc_type;
1414 msg_body.num_keys = 1;
1415 msg_body.keys[0].id = keyidx;
1416 msg_body.keys[0].unicast = 0;
1417 msg_body.keys[0].direction = WCN36XX_HAL_RX_ONLY;
1418 msg_body.keys[0].pae_role = 0;
1419 msg_body.keys[0].length = keylen;
1420 memcpy(msg_body.keys[0].key, key, keylen);
1421
1422 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1423
1424 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1425 if (ret) {
1426 wcn36xx_err("Sending hal_set_bsskey failed\n");
1427 goto out;
1428 }
1429 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1430 if (ret) {
1431 wcn36xx_err("hal_set_bsskey response failed err=%d\n", ret);
1432 goto out;
1433 }
1434out:
1435 mutex_unlock(&wcn->hal_mutex);
1436 return ret;
1437}
1438
1439int wcn36xx_smd_remove_stakey(struct wcn36xx *wcn,
1440 enum ani_ed_type enc_type,
1441 u8 keyidx,
1442 u8 sta_index)
1443{
1444 struct wcn36xx_hal_remove_sta_key_req_msg msg_body;
1445 int ret = 0;
1446
1447 mutex_lock(&wcn->hal_mutex);
1448 INIT_HAL_MSG(msg_body, WCN36XX_HAL_RMV_STAKEY_REQ);
1449
1450 msg_body.sta_idx = sta_index;
1451 msg_body.enc_type = enc_type;
1452 msg_body.key_id = keyidx;
1453
1454 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1455
1456 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1457 if (ret) {
1458 wcn36xx_err("Sending hal_remove_stakey failed\n");
1459 goto out;
1460 }
1461 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1462 if (ret) {
1463 wcn36xx_err("hal_remove_stakey response failed err=%d\n", ret);
1464 goto out;
1465 }
1466out:
1467 mutex_unlock(&wcn->hal_mutex);
1468 return ret;
1469}
1470
1471int wcn36xx_smd_remove_bsskey(struct wcn36xx *wcn,
1472 enum ani_ed_type enc_type,
1473 u8 keyidx)
1474{
1475 struct wcn36xx_hal_remove_bss_key_req_msg msg_body;
1476 int ret = 0;
1477
1478 mutex_lock(&wcn->hal_mutex);
1479 INIT_HAL_MSG(msg_body, WCN36XX_HAL_RMV_BSSKEY_REQ);
1480 msg_body.bss_idx = 0;
1481 msg_body.enc_type = enc_type;
1482 msg_body.key_id = keyidx;
1483
1484 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1485
1486 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1487 if (ret) {
1488 wcn36xx_err("Sending hal_remove_bsskey failed\n");
1489 goto out;
1490 }
1491 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1492 if (ret) {
1493 wcn36xx_err("hal_remove_bsskey response failed err=%d\n", ret);
1494 goto out;
1495 }
1496out:
1497 mutex_unlock(&wcn->hal_mutex);
1498 return ret;
1499}
1500
1501int wcn36xx_smd_enter_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif)
1502{
1503 struct wcn36xx_hal_enter_bmps_req_msg msg_body;
1504 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
1505 int ret = 0;
1506
1507 mutex_lock(&wcn->hal_mutex);
1508 INIT_HAL_MSG(msg_body, WCN36XX_HAL_ENTER_BMPS_REQ);
1509
1510 msg_body.bss_index = vif_priv->bss_index;
1511 msg_body.tbtt = vif->bss_conf.sync_tsf;
1512 msg_body.dtim_period = vif_priv->dtim_period;
1513
1514 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1515
1516 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1517 if (ret) {
1518 wcn36xx_err("Sending hal_enter_bmps failed\n");
1519 goto out;
1520 }
1521 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1522 if (ret) {
1523 wcn36xx_err("hal_enter_bmps response failed err=%d\n", ret);
1524 goto out;
1525 }
1526out:
1527 mutex_unlock(&wcn->hal_mutex);
1528 return ret;
1529}
1530
1531int wcn36xx_smd_exit_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif)
1532{
1533 struct wcn36xx_hal_enter_bmps_req_msg msg_body;
1534 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
1535 int ret = 0;
1536
1537 mutex_lock(&wcn->hal_mutex);
1538 INIT_HAL_MSG(msg_body, WCN36XX_HAL_EXIT_BMPS_REQ);
1539
1540 msg_body.bss_index = vif_priv->bss_index;
1541
1542 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1543
1544 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1545 if (ret) {
1546 wcn36xx_err("Sending hal_exit_bmps failed\n");
1547 goto out;
1548 }
1549 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1550 if (ret) {
1551 wcn36xx_err("hal_exit_bmps response failed err=%d\n", ret);
1552 goto out;
1553 }
1554out:
1555 mutex_unlock(&wcn->hal_mutex);
1556 return ret;
1557}
1558int wcn36xx_smd_set_power_params(struct wcn36xx *wcn, bool ignore_dtim)
1559{
1560 struct wcn36xx_hal_set_power_params_req_msg msg_body;
1561 int ret = 0;
1562
1563 mutex_lock(&wcn->hal_mutex);
1564 INIT_HAL_MSG(msg_body, WCN36XX_HAL_SET_POWER_PARAMS_REQ);
1565
1566 /*
1567 * When host is down ignore every second dtim
1568 */
1569 if (ignore_dtim) {
1570 msg_body.ignore_dtim = 1;
1571 msg_body.dtim_period = 2;
1572 }
1573 msg_body.listen_interval = WCN36XX_LISTEN_INTERVAL(wcn);
1574
1575 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1576
1577 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1578 if (ret) {
1579 wcn36xx_err("Sending hal_set_power_params failed\n");
1580 goto out;
1581 }
1582
1583out:
1584 mutex_unlock(&wcn->hal_mutex);
1585 return ret;
1586}
1587/* Notice: This function should be called after associated, or else it
1588 * will be invalid
1589 */
1590int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
1591 struct ieee80211_vif *vif,
1592 int packet_type)
1593{
1594 struct wcn36xx_hal_keep_alive_req_msg msg_body;
1595 struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
1596 int ret = 0;
1597
1598 mutex_lock(&wcn->hal_mutex);
1599 INIT_HAL_MSG(msg_body, WCN36XX_HAL_KEEP_ALIVE_REQ);
1600
1601 if (packet_type == WCN36XX_HAL_KEEP_ALIVE_NULL_PKT) {
1602 msg_body.bss_index = vif_priv->bss_index;
1603 msg_body.packet_type = WCN36XX_HAL_KEEP_ALIVE_NULL_PKT;
1604 msg_body.time_period = WCN36XX_KEEP_ALIVE_TIME_PERIOD;
1605 } else if (packet_type == WCN36XX_HAL_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
1606 /* TODO: it also support ARP response type */
1607 } else {
1608 wcn36xx_warn("unknow keep alive packet type %d\n", packet_type);
1609 return -EINVAL;
1610 }
1611
1612 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1613
1614 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1615 if (ret) {
1616 wcn36xx_err("Sending hal_exit_bmps failed\n");
1617 goto out;
1618 }
1619 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1620 if (ret) {
1621 wcn36xx_err("hal_exit_bmps response failed err=%d\n", ret);
1622 goto out;
1623 }
1624out:
1625 mutex_unlock(&wcn->hal_mutex);
1626 return ret;
1627}
1628
1629int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
1630 u32 arg3, u32 arg4, u32 arg5)
1631{
1632 struct wcn36xx_hal_dump_cmd_req_msg msg_body;
1633 int ret = 0;
1634
1635 mutex_lock(&wcn->hal_mutex);
1636 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DUMP_COMMAND_REQ);
1637
1638 msg_body.arg1 = arg1;
1639 msg_body.arg2 = arg2;
1640 msg_body.arg3 = arg3;
1641 msg_body.arg4 = arg4;
1642 msg_body.arg5 = arg5;
1643
1644 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1645
1646 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1647 if (ret) {
1648 wcn36xx_err("Sending hal_dump_cmd failed\n");
1649 goto out;
1650 }
1651 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1652 if (ret) {
1653 wcn36xx_err("hal_dump_cmd response failed err=%d\n", ret);
1654 goto out;
1655 }
1656out:
1657 mutex_unlock(&wcn->hal_mutex);
1658 return ret;
1659}
1660
1661static inline void set_feat_caps(u32 *bitmap,
1662 enum place_holder_in_cap_bitmap cap)
1663{
1664 int arr_idx, bit_idx;
1665
1666 if (cap < 0 || cap > 127) {
1667 wcn36xx_warn("error cap idx %d\n", cap);
1668 return;
1669 }
1670
1671 arr_idx = cap / 32;
1672 bit_idx = cap % 32;
1673 bitmap[arr_idx] |= (1 << bit_idx);
1674}
1675
1676static inline int get_feat_caps(u32 *bitmap,
1677 enum place_holder_in_cap_bitmap cap)
1678{
1679 int arr_idx, bit_idx;
1680 int ret = 0;
1681
1682 if (cap < 0 || cap > 127) {
1683 wcn36xx_warn("error cap idx %d\n", cap);
1684 return -EINVAL;
1685 }
1686
1687 arr_idx = cap / 32;
1688 bit_idx = cap % 32;
1689 ret = (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
1690 return ret;
1691}
1692
1693static inline void clear_feat_caps(u32 *bitmap,
1694 enum place_holder_in_cap_bitmap cap)
1695{
1696 int arr_idx, bit_idx;
1697
1698 if (cap < 0 || cap > 127) {
1699 wcn36xx_warn("error cap idx %d\n", cap);
1700 return;
1701 }
1702
1703 arr_idx = cap / 32;
1704 bit_idx = cap % 32;
1705 bitmap[arr_idx] &= ~(1 << bit_idx);
1706}
1707
1708int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
1709{
1710 struct wcn36xx_hal_feat_caps_msg msg_body;
1711 int ret = 0;
1712
1713 mutex_lock(&wcn->hal_mutex);
1714 INIT_HAL_MSG(msg_body, WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_REQ);
1715
1716 set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
1717
1718 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1719
1720 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1721 if (ret) {
1722 wcn36xx_err("Sending hal_feature_caps_exchange failed\n");
1723 goto out;
1724 }
1725 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1726 if (ret) {
1727 wcn36xx_err("hal_feature_caps_exchange response failed err=%d\n",
1728 ret);
1729 goto out;
1730 }
1731out:
1732 mutex_unlock(&wcn->hal_mutex);
1733 return ret;
1734}
1735
1736int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
1737 struct ieee80211_sta *sta,
1738 u16 tid,
1739 u16 *ssn,
1740 u8 direction,
1741 u8 sta_index)
1742{
1743 struct wcn36xx_hal_add_ba_session_req_msg msg_body;
1744 int ret = 0;
1745
1746 mutex_lock(&wcn->hal_mutex);
1747 INIT_HAL_MSG(msg_body, WCN36XX_HAL_ADD_BA_SESSION_REQ);
1748
1749 msg_body.sta_index = sta_index;
1750 memcpy(&msg_body.mac_addr, sta->addr, ETH_ALEN);
1751 msg_body.dialog_token = 0x10;
1752 msg_body.tid = tid;
1753
1754 /* Immediate BA because Delayed BA is not supported */
1755 msg_body.policy = 1;
1756 msg_body.buffer_size = WCN36XX_AGGR_BUFFER_SIZE;
1757 msg_body.timeout = 0;
1758 if (ssn)
1759 msg_body.ssn = *ssn;
1760 msg_body.direction = direction;
1761
1762 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1763
1764 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1765 if (ret) {
1766 wcn36xx_err("Sending hal_add_ba_session failed\n");
1767 goto out;
1768 }
1769 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1770 if (ret) {
1771 wcn36xx_err("hal_add_ba_session response failed err=%d\n", ret);
1772 goto out;
1773 }
1774out:
1775 mutex_unlock(&wcn->hal_mutex);
1776 return ret;
1777}
1778
1779int wcn36xx_smd_add_ba(struct wcn36xx *wcn)
1780{
1781 struct wcn36xx_hal_add_ba_req_msg msg_body;
1782 int ret = 0;
1783
1784 mutex_lock(&wcn->hal_mutex);
1785 INIT_HAL_MSG(msg_body, WCN36XX_HAL_ADD_BA_REQ);
1786
1787 msg_body.session_id = 0;
1788 msg_body.win_size = WCN36XX_AGGR_BUFFER_SIZE;
1789
1790 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1791
1792 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1793 if (ret) {
1794 wcn36xx_err("Sending hal_add_ba failed\n");
1795 goto out;
1796 }
1797 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1798 if (ret) {
1799 wcn36xx_err("hal_add_ba response failed err=%d\n", ret);
1800 goto out;
1801 }
1802out:
1803 mutex_unlock(&wcn->hal_mutex);
1804 return ret;
1805}
1806
1807int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid, u8 sta_index)
1808{
1809 struct wcn36xx_hal_del_ba_req_msg msg_body;
1810 int ret = 0;
1811
1812 mutex_lock(&wcn->hal_mutex);
1813 INIT_HAL_MSG(msg_body, WCN36XX_HAL_DEL_BA_REQ);
1814
1815 msg_body.sta_index = sta_index;
1816 msg_body.tid = tid;
1817 msg_body.direction = 0;
1818 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1819
1820 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1821 if (ret) {
1822 wcn36xx_err("Sending hal_del_ba failed\n");
1823 goto out;
1824 }
1825 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1826 if (ret) {
1827 wcn36xx_err("hal_del_ba response failed err=%d\n", ret);
1828 goto out;
1829 }
1830out:
1831 mutex_unlock(&wcn->hal_mutex);
1832 return ret;
1833}
1834
1835int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index)
1836{
1837 struct wcn36xx_hal_trigger_ba_req_msg msg_body;
1838 struct wcn36xx_hal_trigget_ba_req_candidate *candidate;
1839 int ret = 0;
1840
1841 mutex_lock(&wcn->hal_mutex);
1842 INIT_HAL_MSG(msg_body, WCN36XX_HAL_TRIGGER_BA_REQ);
1843
1844 msg_body.session_id = 0;
1845 msg_body.candidate_cnt = 1;
1846 msg_body.header.len += sizeof(*candidate);
1847 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1848
1849 candidate = (struct wcn36xx_hal_trigget_ba_req_candidate *)
1850 (wcn->hal_buf + sizeof(msg_body));
1851 candidate->sta_index = sta_index;
1852 candidate->tid_bitmap = 1;
1853
1854 ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
1855 if (ret) {
1856 wcn36xx_err("Sending hal_trigger_ba failed\n");
1857 goto out;
1858 }
1859 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1860 if (ret) {
1861 wcn36xx_err("hal_trigger_ba response failed err=%d\n", ret);
1862 goto out;
1863 }
1864out:
1865 mutex_unlock(&wcn->hal_mutex);
1866 return ret;
1867}
1868
1869static int wcn36xx_smd_tx_compl_ind(struct wcn36xx *wcn, void *buf, size_t len)
1870{
1871 struct wcn36xx_hal_tx_compl_ind_msg *rsp = buf;
1872
1873 if (len != sizeof(*rsp)) {
1874 wcn36xx_warn("Bad TX complete indication\n");
1875 return -EIO;
1876 }
1877
1878 wcn36xx_dxe_tx_ack_ind(wcn, rsp->status);
1879
1880 return 0;
1881}
1882
1883static int wcn36xx_smd_missed_beacon_ind(struct wcn36xx *wcn,
1884 void *buf,
1885 size_t len)
1886{
1887 struct wcn36xx_hal_missed_beacon_ind_msg *rsp = buf;
1888 struct ieee80211_vif *vif = NULL;
1889 struct wcn36xx_vif *tmp;
1890
1891 /* Old FW does not have bss index */
1892 if (wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) {
1893 list_for_each_entry(tmp, &wcn->vif_list, list) {
1894 wcn36xx_dbg(WCN36XX_DBG_HAL, "beacon missed bss_index %d\n",
1895 tmp->bss_index);
1896 vif = container_of((void *)tmp,
1897 struct ieee80211_vif,
1898 drv_priv);
1899 ieee80211_connection_loss(vif);
1900 }
1901 return 0;
1902 }
1903
1904 if (len != sizeof(*rsp)) {
1905 wcn36xx_warn("Corrupted missed beacon indication\n");
1906 return -EIO;
1907 }
1908
1909 list_for_each_entry(tmp, &wcn->vif_list, list) {
1910 if (tmp->bss_index == rsp->bss_index) {
1911 wcn36xx_dbg(WCN36XX_DBG_HAL, "beacon missed bss_index %d\n",
1912 rsp->bss_index);
1913 vif = container_of((void *)tmp,
1914 struct ieee80211_vif,
1915 drv_priv);
1916 ieee80211_connection_loss(vif);
1917 return 0;
1918 }
1919 }
1920
1921 wcn36xx_warn("BSS index %d not found\n", rsp->bss_index);
1922 return -ENOENT;
1923}
1924
1925static int wcn36xx_smd_delete_sta_context_ind(struct wcn36xx *wcn,
1926 void *buf,
1927 size_t len)
1928{
1929 struct wcn36xx_hal_delete_sta_context_ind_msg *rsp = buf;
1930 struct wcn36xx_vif *tmp;
1931 struct ieee80211_sta *sta = NULL;
1932
1933 if (len != sizeof(*rsp)) {
1934 wcn36xx_warn("Corrupted delete sta indication\n");
1935 return -EIO;
1936 }
1937
1938 list_for_each_entry(tmp, &wcn->vif_list, list) {
1939 if (sta && (tmp->sta->sta_index == rsp->sta_id)) {
1940 sta = container_of((void *)tmp->sta,
1941 struct ieee80211_sta,
1942 drv_priv);
1943 wcn36xx_dbg(WCN36XX_DBG_HAL,
1944 "delete station indication %pM index %d\n",
1945 rsp->addr2,
1946 rsp->sta_id);
1947 ieee80211_report_low_ack(sta, 0);
1948 return 0;
1949 }
1950 }
1951
1952 wcn36xx_warn("STA with addr %pM and index %d not found\n",
1953 rsp->addr2,
1954 rsp->sta_id);
1955 return -ENOENT;
1956}
1957
1958int wcn36xx_smd_update_cfg(struct wcn36xx *wcn, u32 cfg_id, u32 value)
1959{
1960 struct wcn36xx_hal_update_cfg_req_msg msg_body, *body;
1961 size_t len;
1962 int ret = 0;
1963
1964 mutex_lock(&wcn->hal_mutex);
1965 INIT_HAL_MSG(msg_body, WCN36XX_HAL_UPDATE_CFG_REQ);
1966
1967 PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
1968
1969 body = (struct wcn36xx_hal_update_cfg_req_msg *) wcn->hal_buf;
1970 len = msg_body.header.len;
1971
1972 put_cfg_tlv_u32(wcn, &len, cfg_id, value);
1973 body->header.len = len;
1974 body->len = len - sizeof(*body);
1975
1976 ret = wcn36xx_smd_send_and_wait(wcn, body->header.len);
1977 if (ret) {
1978 wcn36xx_err("Sending hal_update_cfg failed\n");
1979 goto out;
1980 }
1981 ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
1982 if (ret) {
1983 wcn36xx_err("hal_update_cfg response failed err=%d\n", ret);
1984 goto out;
1985 }
1986out:
1987 mutex_unlock(&wcn->hal_mutex);
1988 return ret;
1989}
1990static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len)
1991{
1992 struct wcn36xx_hal_msg_header *msg_header = buf;
1993 struct wcn36xx_hal_ind_msg *msg_ind;
1994 wcn36xx_dbg_dump(WCN36XX_DBG_SMD_DUMP, "SMD <<< ", buf, len);
1995
1996 switch (msg_header->msg_type) {
1997 case WCN36XX_HAL_START_RSP:
1998 case WCN36XX_HAL_CONFIG_STA_RSP:
1999 case WCN36XX_HAL_CONFIG_BSS_RSP:
2000 case WCN36XX_HAL_ADD_STA_SELF_RSP:
2001 case WCN36XX_HAL_STOP_RSP:
2002 case WCN36XX_HAL_DEL_STA_SELF_RSP:
2003 case WCN36XX_HAL_DELETE_STA_RSP:
2004 case WCN36XX_HAL_INIT_SCAN_RSP:
2005 case WCN36XX_HAL_START_SCAN_RSP:
2006 case WCN36XX_HAL_END_SCAN_RSP:
2007 case WCN36XX_HAL_FINISH_SCAN_RSP:
2008 case WCN36XX_HAL_DOWNLOAD_NV_RSP:
2009 case WCN36XX_HAL_DELETE_BSS_RSP:
2010 case WCN36XX_HAL_SEND_BEACON_RSP:
2011 case WCN36XX_HAL_SET_LINK_ST_RSP:
2012 case WCN36XX_HAL_UPDATE_PROBE_RSP_TEMPLATE_RSP:
2013 case WCN36XX_HAL_SET_BSSKEY_RSP:
2014 case WCN36XX_HAL_SET_STAKEY_RSP:
2015 case WCN36XX_HAL_RMV_STAKEY_RSP:
2016 case WCN36XX_HAL_RMV_BSSKEY_RSP:
2017 case WCN36XX_HAL_ENTER_BMPS_RSP:
2018 case WCN36XX_HAL_SET_POWER_PARAMS_RSP:
2019 case WCN36XX_HAL_EXIT_BMPS_RSP:
2020 case WCN36XX_HAL_KEEP_ALIVE_RSP:
2021 case WCN36XX_HAL_DUMP_COMMAND_RSP:
2022 case WCN36XX_HAL_ADD_BA_SESSION_RSP:
2023 case WCN36XX_HAL_ADD_BA_RSP:
2024 case WCN36XX_HAL_DEL_BA_RSP:
2025 case WCN36XX_HAL_TRIGGER_BA_RSP:
2026 case WCN36XX_HAL_UPDATE_CFG_RSP:
2027 case WCN36XX_HAL_JOIN_RSP:
2028 case WCN36XX_HAL_UPDATE_SCAN_PARAM_RSP:
2029 case WCN36XX_HAL_CH_SWITCH_RSP:
2030 case WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_RSP:
2031 memcpy(wcn->hal_buf, buf, len);
2032 wcn->hal_rsp_len = len;
2033 complete(&wcn->hal_rsp_compl);
2034 break;
2035
2036 case WCN36XX_HAL_OTA_TX_COMPL_IND:
2037 case WCN36XX_HAL_MISSED_BEACON_IND:
2038 case WCN36XX_HAL_DELETE_STA_CONTEXT_IND:
2039 mutex_lock(&wcn->hal_ind_mutex);
2040 msg_ind = kmalloc(sizeof(*msg_ind), GFP_KERNEL);
2041 msg_ind->msg_len = len;
2042 msg_ind->msg = kmalloc(len, GFP_KERNEL);
2043 memcpy(msg_ind->msg, buf, len);
2044 list_add_tail(&msg_ind->list, &wcn->hal_ind_queue);
2045 queue_work(wcn->hal_ind_wq, &wcn->hal_ind_work);
2046 wcn36xx_dbg(WCN36XX_DBG_HAL, "indication arrived\n");
2047 mutex_unlock(&wcn->hal_ind_mutex);
2048 break;
2049 default:
2050 wcn36xx_err("SMD_EVENT (%d) not supported\n",
2051 msg_header->msg_type);
2052 }
2053}
2054static void wcn36xx_ind_smd_work(struct work_struct *work)
2055{
2056 struct wcn36xx *wcn =
2057 container_of(work, struct wcn36xx, hal_ind_work);
2058 struct wcn36xx_hal_msg_header *msg_header;
2059 struct wcn36xx_hal_ind_msg *hal_ind_msg;
2060
2061 mutex_lock(&wcn->hal_ind_mutex);
2062
2063 hal_ind_msg = list_first_entry(&wcn->hal_ind_queue,
2064 struct wcn36xx_hal_ind_msg,
2065 list);
2066
2067 msg_header = (struct wcn36xx_hal_msg_header *)hal_ind_msg->msg;
2068
2069 switch (msg_header->msg_type) {
2070 case WCN36XX_HAL_OTA_TX_COMPL_IND:
2071 wcn36xx_smd_tx_compl_ind(wcn,
2072 hal_ind_msg->msg,
2073 hal_ind_msg->msg_len);
2074 break;
2075 case WCN36XX_HAL_MISSED_BEACON_IND:
2076 wcn36xx_smd_missed_beacon_ind(wcn,
2077 hal_ind_msg->msg,
2078 hal_ind_msg->msg_len);
2079 break;
2080 case WCN36XX_HAL_DELETE_STA_CONTEXT_IND:
2081 wcn36xx_smd_delete_sta_context_ind(wcn,
2082 hal_ind_msg->msg,
2083 hal_ind_msg->msg_len);
2084 break;
2085 default:
2086 wcn36xx_err("SMD_EVENT (%d) not supported\n",
2087 msg_header->msg_type);
2088 }
2089 list_del(wcn->hal_ind_queue.next);
2090 kfree(hal_ind_msg->msg);
2091 kfree(hal_ind_msg);
2092 mutex_unlock(&wcn->hal_ind_mutex);
2093}
2094int wcn36xx_smd_open(struct wcn36xx *wcn)
2095{
2096 int ret = 0;
2097 wcn->hal_ind_wq = create_freezable_workqueue("wcn36xx_smd_ind");
2098 if (!wcn->hal_ind_wq) {
2099 wcn36xx_err("failed to allocate wq\n");
2100 ret = -ENOMEM;
2101 goto out;
2102 }
2103 INIT_WORK(&wcn->hal_ind_work, wcn36xx_ind_smd_work);
2104 INIT_LIST_HEAD(&wcn->hal_ind_queue);
2105 mutex_init(&wcn->hal_ind_mutex);
2106
2107 ret = wcn->ctrl_ops->open(wcn, wcn36xx_smd_rsp_process);
2108 if (ret) {
2109 wcn36xx_err("failed to open control channel\n");
2110 goto free_wq;
2111 }
2112
2113 return ret;
2114
2115free_wq:
2116 destroy_workqueue(wcn->hal_ind_wq);
2117out:
2118 return ret;
2119}
2120
2121void wcn36xx_smd_close(struct wcn36xx *wcn)
2122{
2123 wcn->ctrl_ops->close();
2124 destroy_workqueue(wcn->hal_ind_wq);
2125 mutex_destroy(&wcn->hal_ind_mutex);
2126}
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
new file mode 100644
index 000000000000..e7c39019c6f1
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -0,0 +1,127 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _SMD_H_
18#define _SMD_H_
19
20#include "wcn36xx.h"
21
22/* Max shared size is 4k but we take less.*/
23#define WCN36XX_NV_FRAGMENT_SIZE 3072
24
25#define WCN36XX_HAL_BUF_SIZE 4096
26
27#define HAL_MSG_TIMEOUT 200
28#define WCN36XX_SMSM_WLAN_TX_ENABLE 0x00000400
29#define WCN36XX_SMSM_WLAN_TX_RINGS_EMPTY 0x00000200
30/* The PNO version info be contained in the rsp msg */
31#define WCN36XX_FW_MSG_PNO_VERSION_MASK 0x8000
32
33enum wcn36xx_fw_msg_result {
34 WCN36XX_FW_MSG_RESULT_SUCCESS = 0,
35 WCN36XX_FW_MSG_RESULT_SUCCESS_SYNC = 1,
36
37 WCN36XX_FW_MSG_RESULT_MEM_FAIL = 5,
38};
39
40/******************************/
41/* SMD requests and responses */
42/******************************/
43struct wcn36xx_fw_msg_status_rsp {
44 u32 status;
45} __packed;
46
47struct wcn36xx_hal_ind_msg {
48 struct list_head list;
49 u8 *msg;
50 size_t msg_len;
51};
52
53struct wcn36xx;
54
55int wcn36xx_smd_open(struct wcn36xx *wcn);
56void wcn36xx_smd_close(struct wcn36xx *wcn);
57
58int wcn36xx_smd_load_nv(struct wcn36xx *wcn);
59int wcn36xx_smd_start(struct wcn36xx *wcn);
60int wcn36xx_smd_stop(struct wcn36xx *wcn);
61int wcn36xx_smd_init_scan(struct wcn36xx *wcn, enum wcn36xx_hal_sys_mode mode);
62int wcn36xx_smd_start_scan(struct wcn36xx *wcn);
63int wcn36xx_smd_end_scan(struct wcn36xx *wcn);
64int wcn36xx_smd_finish_scan(struct wcn36xx *wcn,
65 enum wcn36xx_hal_sys_mode mode);
66int wcn36xx_smd_update_scan_params(struct wcn36xx *wcn);
67int wcn36xx_smd_add_sta_self(struct wcn36xx *wcn, struct ieee80211_vif *vif);
68int wcn36xx_smd_delete_sta_self(struct wcn36xx *wcn, u8 *addr);
69int wcn36xx_smd_delete_sta(struct wcn36xx *wcn, u8 sta_index);
70int wcn36xx_smd_join(struct wcn36xx *wcn, const u8 *bssid, u8 *vif, u8 ch);
71int wcn36xx_smd_set_link_st(struct wcn36xx *wcn, const u8 *bssid,
72 const u8 *sta_mac,
73 enum wcn36xx_hal_link_state state);
74int wcn36xx_smd_config_bss(struct wcn36xx *wcn, struct ieee80211_vif *vif,
75 struct ieee80211_sta *sta, const u8 *bssid,
76 bool update);
77int wcn36xx_smd_delete_bss(struct wcn36xx *wcn, struct ieee80211_vif *vif);
78int wcn36xx_smd_config_sta(struct wcn36xx *wcn, struct ieee80211_vif *vif,
79 struct ieee80211_sta *sta);
80int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct ieee80211_vif *vif,
81 struct sk_buff *skb_beacon, u16 tim_off,
82 u16 p2p_off);
83int wcn36xx_smd_switch_channel(struct wcn36xx *wcn,
84 struct ieee80211_vif *vif, int ch);
85int wcn36xx_smd_update_proberesp_tmpl(struct wcn36xx *wcn,
86 struct ieee80211_vif *vif,
87 struct sk_buff *skb);
88int wcn36xx_smd_set_stakey(struct wcn36xx *wcn,
89 enum ani_ed_type enc_type,
90 u8 keyidx,
91 u8 keylen,
92 u8 *key,
93 u8 sta_index);
94int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
95 enum ani_ed_type enc_type,
96 u8 keyidx,
97 u8 keylen,
98 u8 *key);
99int wcn36xx_smd_remove_stakey(struct wcn36xx *wcn,
100 enum ani_ed_type enc_type,
101 u8 keyidx,
102 u8 sta_index);
103int wcn36xx_smd_remove_bsskey(struct wcn36xx *wcn,
104 enum ani_ed_type enc_type,
105 u8 keyidx);
106int wcn36xx_smd_enter_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif);
107int wcn36xx_smd_exit_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif);
108int wcn36xx_smd_set_power_params(struct wcn36xx *wcn, bool ignore_dtim);
109int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
110 struct ieee80211_vif *vif,
111 int packet_type);
112int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
113 u32 arg3, u32 arg4, u32 arg5);
114int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
115
116int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
117 struct ieee80211_sta *sta,
118 u16 tid,
119 u16 *ssn,
120 u8 direction,
121 u8 sta_index);
122int wcn36xx_smd_add_ba(struct wcn36xx *wcn);
123int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid, u8 sta_index);
124int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index);
125
126int wcn36xx_smd_update_cfg(struct wcn36xx *wcn, u32 cfg_id, u32 value);
127#endif /* _SMD_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c
new file mode 100644
index 000000000000..b2b60e30caaf
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/txrx.c
@@ -0,0 +1,284 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
19#include "txrx.h"
20
21static inline int get_rssi0(struct wcn36xx_rx_bd *bd)
22{
23 return 100 - ((bd->phy_stat0 >> 24) & 0xff);
24}
25
26int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
27{
28 struct ieee80211_rx_status status;
29 struct ieee80211_hdr *hdr;
30 struct wcn36xx_rx_bd *bd;
31 u16 fc, sn;
32
33 /*
34 * All fields must be 0, otherwise it can lead to
35 * unexpected consequences.
36 */
37 memset(&status, 0, sizeof(status));
38
39 bd = (struct wcn36xx_rx_bd *)skb->data;
40 buff_to_be((u32 *)bd, sizeof(*bd)/sizeof(u32));
41 wcn36xx_dbg_dump(WCN36XX_DBG_RX_DUMP,
42 "BD <<< ", (char *)bd,
43 sizeof(struct wcn36xx_rx_bd));
44
45 skb_put(skb, bd->pdu.mpdu_header_off + bd->pdu.mpdu_len);
46 skb_pull(skb, bd->pdu.mpdu_header_off);
47
48 status.mactime = 10;
49 status.freq = WCN36XX_CENTER_FREQ(wcn);
50 status.band = WCN36XX_BAND(wcn);
51 status.signal = -get_rssi0(bd);
52 status.antenna = 1;
53 status.rate_idx = 1;
54 status.flag = 0;
55 status.rx_flags = 0;
56 status.flag |= RX_FLAG_IV_STRIPPED |
57 RX_FLAG_MMIC_STRIPPED |
58 RX_FLAG_DECRYPTED;
59
60 wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x status->vendor_radiotap_len=%x\n",
61 status.flag, status.vendor_radiotap_len);
62
63 memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
64
65 hdr = (struct ieee80211_hdr *) skb->data;
66 fc = __le16_to_cpu(hdr->frame_control);
67 sn = IEEE80211_SEQ_TO_SN(__le16_to_cpu(hdr->seq_ctrl));
68
69 if (ieee80211_is_beacon(hdr->frame_control)) {
70 wcn36xx_dbg(WCN36XX_DBG_BEACON, "beacon skb %p len %d fc %04x sn %d\n",
71 skb, skb->len, fc, sn);
72 wcn36xx_dbg_dump(WCN36XX_DBG_BEACON_DUMP, "SKB <<< ",
73 (char *)skb->data, skb->len);
74 } else {
75 wcn36xx_dbg(WCN36XX_DBG_RX, "rx skb %p len %d fc %04x sn %d\n",
76 skb, skb->len, fc, sn);
77 wcn36xx_dbg_dump(WCN36XX_DBG_RX_DUMP, "SKB <<< ",
78 (char *)skb->data, skb->len);
79 }
80
81 ieee80211_rx_irqsafe(wcn->hw, skb);
82
83 return 0;
84}
85
86static void wcn36xx_set_tx_pdu(struct wcn36xx_tx_bd *bd,
87 u32 mpdu_header_len,
88 u32 len,
89 u16 tid)
90{
91 bd->pdu.mpdu_header_len = mpdu_header_len;
92 bd->pdu.mpdu_header_off = sizeof(*bd);
93 bd->pdu.mpdu_data_off = bd->pdu.mpdu_header_len +
94 bd->pdu.mpdu_header_off;
95 bd->pdu.mpdu_len = len;
96 bd->pdu.tid = tid;
97}
98
99static inline struct wcn36xx_vif *get_vif_by_addr(struct wcn36xx *wcn,
100 u8 *addr)
101{
102 struct wcn36xx_vif *vif_priv = NULL;
103 struct ieee80211_vif *vif = NULL;
104 list_for_each_entry(vif_priv, &wcn->vif_list, list) {
105 vif = container_of((void *)vif_priv,
106 struct ieee80211_vif,
107 drv_priv);
108 if (memcmp(vif->addr, addr, ETH_ALEN) == 0)
109 return vif_priv;
110 }
111 wcn36xx_warn("vif %pM not found\n", addr);
112 return NULL;
113}
114static void wcn36xx_set_tx_data(struct wcn36xx_tx_bd *bd,
115 struct wcn36xx *wcn,
116 struct wcn36xx_vif **vif_priv,
117 struct wcn36xx_sta *sta_priv,
118 struct ieee80211_hdr *hdr,
119 bool bcast)
120{
121 struct ieee80211_vif *vif = NULL;
122 struct wcn36xx_vif *__vif_priv = NULL;
123 bd->bd_rate = WCN36XX_BD_RATE_DATA;
124
125 /*
126 * For not unicast frames mac80211 will not set sta pointer so use
127 * self_sta_index instead.
128 */
129 if (sta_priv) {
130 __vif_priv = sta_priv->vif;
131 vif = container_of((void *)__vif_priv,
132 struct ieee80211_vif,
133 drv_priv);
134
135 if (vif->type == NL80211_IFTYPE_STATION) {
136 bd->sta_index = sta_priv->bss_sta_index;
137 bd->dpu_desc_idx = sta_priv->bss_dpu_desc_index;
138 } else if (vif->type == NL80211_IFTYPE_AP ||
139 vif->type == NL80211_IFTYPE_ADHOC ||
140 vif->type == NL80211_IFTYPE_MESH_POINT) {
141 bd->sta_index = sta_priv->sta_index;
142 bd->dpu_desc_idx = sta_priv->dpu_desc_index;
143 }
144 } else {
145 __vif_priv = get_vif_by_addr(wcn, hdr->addr2);
146 bd->sta_index = __vif_priv->self_sta_index;
147 bd->dpu_desc_idx = __vif_priv->self_dpu_desc_index;
148 }
149
150 bd->dpu_sign = __vif_priv->ucast_dpu_signature;
151
152 if (ieee80211_is_nullfunc(hdr->frame_control) ||
153 (sta_priv && !sta_priv->is_data_encrypted))
154 bd->dpu_ne = 1;
155
156 if (bcast) {
157 bd->ub = 1;
158 bd->ack_policy = 1;
159 }
160 *vif_priv = __vif_priv;
161}
162
163static void wcn36xx_set_tx_mgmt(struct wcn36xx_tx_bd *bd,
164 struct wcn36xx *wcn,
165 struct wcn36xx_vif **vif_priv,
166 struct ieee80211_hdr *hdr,
167 bool bcast)
168{
169 struct wcn36xx_vif *__vif_priv =
170 get_vif_by_addr(wcn, hdr->addr2);
171 bd->sta_index = __vif_priv->self_sta_index;
172 bd->dpu_desc_idx = __vif_priv->self_dpu_desc_index;
173 bd->dpu_ne = 1;
174
175 /* default rate for unicast */
176 if (ieee80211_is_mgmt(hdr->frame_control))
177 bd->bd_rate = (WCN36XX_BAND(wcn) == IEEE80211_BAND_5GHZ) ?
178 WCN36XX_BD_RATE_CTRL :
179 WCN36XX_BD_RATE_MGMT;
180 else if (ieee80211_is_ctl(hdr->frame_control))
181 bd->bd_rate = WCN36XX_BD_RATE_CTRL;
182 else
183 wcn36xx_warn("frame control type unknown\n");
184
185 /*
186 * In joining state trick hardware that probe is sent as
187 * unicast even if address is broadcast.
188 */
189 if (__vif_priv->is_joining &&
190 ieee80211_is_probe_req(hdr->frame_control))
191 bcast = false;
192
193 if (bcast) {
194 /* broadcast */
195 bd->ub = 1;
196 /* No ack needed not unicast */
197 bd->ack_policy = 1;
198 bd->queue_id = WCN36XX_TX_B_WQ_ID;
199 } else
200 bd->queue_id = WCN36XX_TX_U_WQ_ID;
201 *vif_priv = __vif_priv;
202}
203
204int wcn36xx_start_tx(struct wcn36xx *wcn,
205 struct wcn36xx_sta *sta_priv,
206 struct sk_buff *skb)
207{
208 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
209 struct wcn36xx_vif *vif_priv = NULL;
210 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
211 unsigned long flags;
212 bool is_low = ieee80211_is_data(hdr->frame_control);
213 bool bcast = is_broadcast_ether_addr(hdr->addr1) ||
214 is_multicast_ether_addr(hdr->addr1);
215 struct wcn36xx_tx_bd *bd = wcn36xx_dxe_get_next_bd(wcn, is_low);
216
217 if (!bd) {
218 /*
219 * TX DXE are used in pairs. One for the BD and one for the
220 * actual frame. The BD DXE's has a preallocated buffer while
221 * the skb ones does not. If this isn't true something is really
222 * wierd. TODO: Recover from this situation
223 */
224
225 wcn36xx_err("bd address may not be NULL for BD DXE\n");
226 return -EINVAL;
227 }
228
229 memset(bd, 0, sizeof(*bd));
230
231 wcn36xx_dbg(WCN36XX_DBG_TX,
232 "tx skb %p len %d fc %04x sn %d %s %s\n",
233 skb, skb->len, __le16_to_cpu(hdr->frame_control),
234 IEEE80211_SEQ_TO_SN(__le16_to_cpu(hdr->seq_ctrl)),
235 is_low ? "low" : "high", bcast ? "bcast" : "ucast");
236
237 wcn36xx_dbg_dump(WCN36XX_DBG_TX_DUMP, "", skb->data, skb->len);
238
239 bd->dpu_rf = WCN36XX_BMU_WQ_TX;
240
241 bd->tx_comp = info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS;
242 if (bd->tx_comp) {
243 wcn36xx_dbg(WCN36XX_DBG_DXE, "TX_ACK status requested\n");
244 spin_lock_irqsave(&wcn->dxe_lock, flags);
245 if (wcn->tx_ack_skb) {
246 spin_unlock_irqrestore(&wcn->dxe_lock, flags);
247 wcn36xx_warn("tx_ack_skb already set\n");
248 return -EINVAL;
249 }
250
251 wcn->tx_ack_skb = skb;
252 spin_unlock_irqrestore(&wcn->dxe_lock, flags);
253
254 /* Only one at a time is supported by fw. Stop the TX queues
255 * until the ack status gets back.
256 *
257 * TODO: Add watchdog in case FW does not answer
258 */
259 ieee80211_stop_queues(wcn->hw);
260 }
261
262 /* Data frames served first*/
263 if (is_low) {
264 wcn36xx_set_tx_data(bd, wcn, &vif_priv, sta_priv, hdr, bcast);
265 wcn36xx_set_tx_pdu(bd,
266 ieee80211_is_data_qos(hdr->frame_control) ?
267 sizeof(struct ieee80211_qos_hdr) :
268 sizeof(struct ieee80211_hdr_3addr),
269 skb->len, sta_priv ? sta_priv->tid : 0);
270 } else {
271 /* MGMT and CTRL frames are handeld here*/
272 wcn36xx_set_tx_mgmt(bd, wcn, &vif_priv, hdr, bcast);
273 wcn36xx_set_tx_pdu(bd,
274 ieee80211_is_data_qos(hdr->frame_control) ?
275 sizeof(struct ieee80211_qos_hdr) :
276 sizeof(struct ieee80211_hdr_3addr),
277 skb->len, WCN36XX_TID);
278 }
279
280 buff_to_be((u32 *)bd, sizeof(*bd)/sizeof(u32));
281 bd->tx_bd_sign = 0xbdbdbdbd;
282
283 return wcn36xx_dxe_tx_frame(wcn, vif_priv, skb, is_low);
284}
diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.h b/drivers/net/wireless/ath/wcn36xx/txrx.h
new file mode 100644
index 000000000000..bbfbcf808c77
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/txrx.h
@@ -0,0 +1,160 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _TXRX_H_
18#define _TXRX_H_
19
20#include <linux/etherdevice.h>
21#include "wcn36xx.h"
22
23/* TODO describe all properties */
24#define WCN36XX_802_11_HEADER_LEN 24
25#define WCN36XX_BMU_WQ_TX 25
26#define WCN36XX_TID 7
27/* broadcast wq ID */
28#define WCN36XX_TX_B_WQ_ID 0xA
29#define WCN36XX_TX_U_WQ_ID 0x9
30/* bd_rate */
31#define WCN36XX_BD_RATE_DATA 0
32#define WCN36XX_BD_RATE_MGMT 2
33#define WCN36XX_BD_RATE_CTRL 3
34
35struct wcn36xx_pdu {
36 u32 dpu_fb:8;
37 u32 adu_fb:8;
38 u32 pdu_id:16;
39
40 /* 0x04*/
41 u32 tail_pdu_idx:16;
42 u32 head_pdu_idx:16;
43
44 /* 0x08*/
45 u32 pdu_count:7;
46 u32 mpdu_data_off:9;
47 u32 mpdu_header_off:8;
48 u32 mpdu_header_len:8;
49
50 /* 0x0c*/
51 u32 reserved4:8;
52 u32 tid:4;
53 u32 reserved3:4;
54 u32 mpdu_len:16;
55};
56
57struct wcn36xx_rx_bd {
58 u32 bdt:2;
59 u32 ft:1;
60 u32 dpu_ne:1;
61 u32 rx_key_id:3;
62 u32 ub:1;
63 u32 rmf:1;
64 u32 uma_bypass:1;
65 u32 csr11:1;
66 u32 reserved0:1;
67 u32 scan_learn:1;
68 u32 rx_ch:4;
69 u32 rtsf:1;
70 u32 bsf:1;
71 u32 a2hf:1;
72 u32 st_auf:1;
73 u32 dpu_sign:3;
74 u32 dpu_rf:8;
75
76 struct wcn36xx_pdu pdu;
77
78 /* 0x14*/
79 u32 addr3:8;
80 u32 addr2:8;
81 u32 addr1:8;
82 u32 dpu_desc_idx:8;
83
84 /* 0x18*/
85 u32 rxp_flags:23;
86 u32 rate_id:9;
87
88 u32 phy_stat0;
89 u32 phy_stat1;
90
91 /* 0x24 */
92 u32 rx_times;
93
94 u32 pmi_cmd[6];
95
96 /* 0x40 */
97 u32 reserved7:4;
98 u32 reorder_slot_id:6;
99 u32 reorder_fwd_id:6;
100 u32 reserved6:12;
101 u32 reorder_code:4;
102
103 /* 0x44 */
104 u32 exp_seq_num:12;
105 u32 cur_seq_num:12;
106 u32 fr_type_subtype:8;
107
108 /* 0x48 */
109 u32 msdu_size:16;
110 u32 sub_fr_id:4;
111 u32 proc_order:4;
112 u32 reserved9:4;
113 u32 aef:1;
114 u32 lsf:1;
115 u32 esf:1;
116 u32 asf:1;
117};
118
119struct wcn36xx_tx_bd {
120 u32 bdt:2;
121 u32 ft:1;
122 u32 dpu_ne:1;
123 u32 fw_tx_comp:1;
124 u32 tx_comp:1;
125 u32 reserved1:1;
126 u32 ub:1;
127 u32 rmf:1;
128 u32 reserved0:12;
129 u32 dpu_sign:3;
130 u32 dpu_rf:8;
131
132 struct wcn36xx_pdu pdu;
133
134 /* 0x14*/
135 u32 reserved5:7;
136 u32 queue_id:5;
137 u32 bd_rate:2;
138 u32 ack_policy:2;
139 u32 sta_index:8;
140 u32 dpu_desc_idx:8;
141
142 u32 tx_bd_sign;
143 u32 reserved6;
144 u32 dxe_start_time;
145 u32 dxe_end_time;
146
147 /*u32 tcp_udp_start_off:10;
148 u32 header_cks:16;
149 u32 reserved7:6;*/
150};
151
152struct wcn36xx_sta;
153struct wcn36xx;
154
155int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb);
156int wcn36xx_start_tx(struct wcn36xx *wcn,
157 struct wcn36xx_sta *sta_priv,
158 struct sk_buff *skb);
159
160#endif /* _TXRX_H_ */
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
new file mode 100644
index 000000000000..58b63833e8e7
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -0,0 +1,238 @@
1/*
2 * Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _WCN36XX_H_
18#define _WCN36XX_H_
19
20#include <linux/completion.h>
21#include <linux/printk.h>
22#include <linux/spinlock.h>
23#include <net/mac80211.h>
24
25#include "hal.h"
26#include "smd.h"
27#include "txrx.h"
28#include "dxe.h"
29#include "pmc.h"
30#include "debug.h"
31
32#define WLAN_NV_FILE "wlan/prima/WCNSS_qcom_wlan_nv.bin"
33#define WCN36XX_AGGR_BUFFER_SIZE 64
34
35extern unsigned int wcn36xx_dbg_mask;
36
37enum wcn36xx_debug_mask {
38 WCN36XX_DBG_DXE = 0x00000001,
39 WCN36XX_DBG_DXE_DUMP = 0x00000002,
40 WCN36XX_DBG_SMD = 0x00000004,
41 WCN36XX_DBG_SMD_DUMP = 0x00000008,
42 WCN36XX_DBG_RX = 0x00000010,
43 WCN36XX_DBG_RX_DUMP = 0x00000020,
44 WCN36XX_DBG_TX = 0x00000040,
45 WCN36XX_DBG_TX_DUMP = 0x00000080,
46 WCN36XX_DBG_HAL = 0x00000100,
47 WCN36XX_DBG_HAL_DUMP = 0x00000200,
48 WCN36XX_DBG_MAC = 0x00000400,
49 WCN36XX_DBG_BEACON = 0x00000800,
50 WCN36XX_DBG_BEACON_DUMP = 0x00001000,
51 WCN36XX_DBG_PMC = 0x00002000,
52 WCN36XX_DBG_PMC_DUMP = 0x00004000,
53 WCN36XX_DBG_ANY = 0xffffffff,
54};
55
56#define wcn36xx_err(fmt, arg...) \
57 printk(KERN_ERR pr_fmt("ERROR " fmt), ##arg);
58
59#define wcn36xx_warn(fmt, arg...) \
60 printk(KERN_WARNING pr_fmt("WARNING " fmt), ##arg)
61
62#define wcn36xx_info(fmt, arg...) \
63 printk(KERN_INFO pr_fmt(fmt), ##arg)
64
65#define wcn36xx_dbg(mask, fmt, arg...) do { \
66 if (wcn36xx_dbg_mask & mask) \
67 printk(KERN_DEBUG pr_fmt(fmt), ##arg); \
68} while (0)
69
70#define wcn36xx_dbg_dump(mask, prefix_str, buf, len) do { \
71 if (wcn36xx_dbg_mask & mask) \
72 print_hex_dump(KERN_DEBUG, pr_fmt(prefix_str), \
73 DUMP_PREFIX_OFFSET, 32, 1, \
74 buf, len, false); \
75} while (0)
76
77#define WCN36XX_HW_CHANNEL(__wcn) (__wcn->hw->conf.chandef.chan->hw_value)
78#define WCN36XX_BAND(__wcn) (__wcn->hw->conf.chandef.chan->band)
79#define WCN36XX_CENTER_FREQ(__wcn) (__wcn->hw->conf.chandef.chan->center_freq)
80#define WCN36XX_LISTEN_INTERVAL(__wcn) (__wcn->hw->conf.listen_interval)
81#define WCN36XX_FLAGS(__wcn) (__wcn->hw->flags)
82#define WCN36XX_MAX_POWER(__wcn) (__wcn->hw->conf.chandef.chan->max_power)
83
84static inline void buff_to_be(u32 *buf, size_t len)
85{
86 int i;
87 for (i = 0; i < len; i++)
88 buf[i] = cpu_to_be32(buf[i]);
89}
90
91struct nv_data {
92 int is_valid;
93 u8 table;
94};
95
96/* Interface for platform control path
97 *
98 * @open: hook must be called when wcn36xx wants to open control channel.
99 * @tx: sends a buffer.
100 */
101struct wcn36xx_platform_ctrl_ops {
102 int (*open)(void *drv_priv, void *rsp_cb);
103 void (*close)(void);
104 int (*tx)(char *buf, size_t len);
105 int (*get_hw_mac)(u8 *addr);
106 int (*smsm_change_state)(u32 clear_mask, u32 set_mask);
107};
108
109/**
110 * struct wcn36xx_vif - holds VIF related fields
111 *
112 * @bss_index: bss_index is initially set to 0xFF. bss_index is received from
113 * HW after first config_bss call and must be used in delete_bss and
114 * enter/exit_bmps.
115 */
116struct wcn36xx_vif {
117 struct list_head list;
118 struct wcn36xx_sta *sta;
119 u8 dtim_period;
120 enum ani_ed_type encrypt_type;
121 bool is_joining;
122 struct wcn36xx_hal_mac_ssid ssid;
123
124 /* Power management */
125 enum wcn36xx_power_state pw_state;
126
127 u8 bss_index;
128 u8 ucast_dpu_signature;
129 /* Returned from WCN36XX_HAL_ADD_STA_SELF_RSP */
130 u8 self_sta_index;
131 u8 self_dpu_desc_index;
132};
133
134/**
135 * struct wcn36xx_sta - holds STA related fields
136 *
137 * @tid: traffic ID that is used during AMPDU and in TX BD.
138 * @sta_index: STA index is returned from HW after config_sta call and is
139 * used in both SMD channel and TX BD.
140 * @dpu_desc_index: DPU descriptor index is returned from HW after config_sta
141 * call and is used in TX BD.
142 * @bss_sta_index: STA index is returned from HW after config_bss call and is
143 * used in both SMD channel and TX BD. See table bellow when it is used.
144 * @bss_dpu_desc_index: DPU descriptor index is returned from HW after
145 * config_bss call and is used in TX BD.
146 * ______________________________________________
147 * | | STA | AP |
148 * |______________|_____________|_______________|
149 * | TX BD |bss_sta_index| sta_index |
150 * |______________|_____________|_______________|
151 * |all SMD calls |bss_sta_index| sta_index |
152 * |______________|_____________|_______________|
153 * |smd_delete_sta| sta_index | sta_index |
154 * |______________|_____________|_______________|
155 */
156struct wcn36xx_sta {
157 struct wcn36xx_vif *vif;
158 u16 aid;
159 u16 tid;
160 u8 sta_index;
161 u8 dpu_desc_index;
162 u8 bss_sta_index;
163 u8 bss_dpu_desc_index;
164 bool is_data_encrypted;
165 /* Rates */
166 struct wcn36xx_hal_supported_rates supported_rates;
167};
168struct wcn36xx_dxe_ch;
169struct wcn36xx {
170 struct ieee80211_hw *hw;
171 struct device *dev;
172 struct list_head vif_list;
173
174 u8 fw_revision;
175 u8 fw_version;
176 u8 fw_minor;
177 u8 fw_major;
178
179 /* extra byte for the NULL termination */
180 u8 crm_version[WCN36XX_HAL_VERSION_LENGTH + 1];
181 u8 wlan_version[WCN36XX_HAL_VERSION_LENGTH + 1];
182
183 /* IRQs */
184 int tx_irq;
185 int rx_irq;
186 void __iomem *mmio;
187
188 struct wcn36xx_platform_ctrl_ops *ctrl_ops;
189 /*
190 * smd_buf must be protected with smd_mutex to garantee
191 * that all messages are sent one after another
192 */
193 u8 *hal_buf;
194 size_t hal_rsp_len;
195 struct mutex hal_mutex;
196 struct completion hal_rsp_compl;
197 struct workqueue_struct *hal_ind_wq;
198 struct work_struct hal_ind_work;
199 struct mutex hal_ind_mutex;
200 struct list_head hal_ind_queue;
201
202 /* DXE channels */
203 struct wcn36xx_dxe_ch dxe_tx_l_ch; /* TX low */
204 struct wcn36xx_dxe_ch dxe_tx_h_ch; /* TX high */
205 struct wcn36xx_dxe_ch dxe_rx_l_ch; /* RX low */
206 struct wcn36xx_dxe_ch dxe_rx_h_ch; /* RX high */
207
208 /* For synchronization of DXE resources from BH, IRQ and WQ contexts */
209 spinlock_t dxe_lock;
210 bool queues_stopped;
211
212 /* Memory pools */
213 struct wcn36xx_dxe_mem_pool mgmt_mem_pool;
214 struct wcn36xx_dxe_mem_pool data_mem_pool;
215
216 struct sk_buff *tx_ack_skb;
217
218#ifdef CONFIG_WCN36XX_DEBUGFS
219 /* Debug file system entry */
220 struct wcn36xx_dfs_entry dfs;
221#endif /* CONFIG_WCN36XX_DEBUGFS */
222
223};
224
225static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn,
226 u8 major,
227 u8 minor,
228 u8 version,
229 u8 revision)
230{
231 return (wcn->fw_major == major &&
232 wcn->fw_minor == minor &&
233 wcn->fw_version == version &&
234 wcn->fw_revision == revision);
235}
236void wcn36xx_set_default_rates(struct wcn36xx_hal_supported_rates *rates);
237
238#endif /* _WCN36XX_H_ */
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index eb1dc7ad80fb..eeceab39cda2 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -197,7 +197,6 @@ static void wil_pcie_remove(struct pci_dev *pdev)
197 pci_iounmap(pdev, wil->csr); 197 pci_iounmap(pdev, wil->csr);
198 pci_release_region(pdev, 0); 198 pci_release_region(pdev, 0);
199 pci_disable_device(pdev); 199 pci_disable_device(pdev);
200 pci_set_drvdata(pdev, NULL);
201} 200}
202 201
203static DEFINE_PCI_DEVICE_TABLE(wil6210_pcie_ids) = { 202static DEFINE_PCI_DEVICE_TABLE(wil6210_pcie_ids) = {
diff --git a/drivers/net/wireless/brcm80211/Kconfig b/drivers/net/wireless/brcm80211/Kconfig
index fc8a0fa6d3b2..b00a7e92225f 100644
--- a/drivers/net/wireless/brcm80211/Kconfig
+++ b/drivers/net/wireless/brcm80211/Kconfig
@@ -28,7 +28,7 @@ config BRCMFMAC
28 28
29config BRCMFMAC_SDIO 29config BRCMFMAC_SDIO
30 bool "SDIO bus interface support for FullMAC driver" 30 bool "SDIO bus interface support for FullMAC driver"
31 depends on MMC 31 depends on (MMC = y || MMC = BRCMFMAC)
32 depends on BRCMFMAC 32 depends on BRCMFMAC
33 select FW_LOADER 33 select FW_LOADER
34 default y 34 default y
@@ -39,7 +39,7 @@ config BRCMFMAC_SDIO
39 39
40config BRCMFMAC_USB 40config BRCMFMAC_USB
41 bool "USB bus interface support for FullMAC driver" 41 bool "USB bus interface support for FullMAC driver"
42 depends on USB 42 depends on (USB = y || USB = BRCMFMAC)
43 depends on BRCMFMAC 43 depends on BRCMFMAC
44 select FW_LOADER 44 select FW_LOADER
45 ---help--- 45 ---help---
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
index 64f4a2bc8dde..091c905871cc 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
@@ -34,6 +34,7 @@
34#include <brcmu_utils.h> 34#include <brcmu_utils.h>
35#include <brcmu_wifi.h> 35#include <brcmu_wifi.h>
36#include "sdio_host.h" 36#include "sdio_host.h"
37#include "sdio_chip.h"
37#include "dhd_dbg.h" 38#include "dhd_dbg.h"
38#include "dhd_bus.h" 39#include "dhd_bus.h"
39 40
@@ -41,13 +42,6 @@
41 42
42#define DMA_ALIGN_MASK 0x03 43#define DMA_ALIGN_MASK 0x03
43 44
44#define SDIO_DEVICE_ID_BROADCOM_43143 43143
45#define SDIO_DEVICE_ID_BROADCOM_43241 0x4324
46#define SDIO_DEVICE_ID_BROADCOM_4329 0x4329
47#define SDIO_DEVICE_ID_BROADCOM_4330 0x4330
48#define SDIO_DEVICE_ID_BROADCOM_4334 0x4334
49#define SDIO_DEVICE_ID_BROADCOM_4335 0x4335
50
51#define SDIO_FUNC1_BLOCKSIZE 64 45#define SDIO_FUNC1_BLOCKSIZE 64
52#define SDIO_FUNC2_BLOCKSIZE 512 46#define SDIO_FUNC2_BLOCKSIZE 512
53 47
@@ -58,7 +52,8 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
58 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, 52 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)},
59 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4330)}, 53 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4330)},
60 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4334)}, 54 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4334)},
61 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4335)}, 55 {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM,
56 SDIO_DEVICE_ID_BROADCOM_4335_4339)},
62 { /* end: all zeroes */ }, 57 { /* end: all zeroes */ },
63}; 58};
64MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); 59MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
@@ -468,7 +463,7 @@ static int brcmf_sdio_pd_probe(struct platform_device *pdev)
468 463
469 brcmf_dbg(SDIO, "Enter\n"); 464 brcmf_dbg(SDIO, "Enter\n");
470 465
471 brcmfmac_sdio_pdata = pdev->dev.platform_data; 466 brcmfmac_sdio_pdata = dev_get_platdata(&pdev->dev);
472 467
473 if (brcmfmac_sdio_pdata->power_on) 468 if (brcmfmac_sdio_pdata->power_on)
474 brcmfmac_sdio_pdata->power_on(); 469 brcmfmac_sdio_pdata->power_on();
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
index 2eb9e642c9bf..4de9aac6666d 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
@@ -97,8 +97,6 @@
97#define WLC_PHY_TYPE_LCN 8 97#define WLC_PHY_TYPE_LCN 8
98#define WLC_PHY_TYPE_NULL 0xf 98#define WLC_PHY_TYPE_NULL 0xf
99 99
100#define BRCMF_EVENTING_MASK_LEN 16
101
102#define TOE_TX_CSUM_OL 0x00000001 100#define TOE_TX_CSUM_OL 0x00000001
103#define TOE_RX_CSUM_OL 0x00000002 101#define TOE_RX_CSUM_OL 0x00000002
104 102
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
index f7c1985844e4..200ee9b485bf 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
@@ -136,7 +136,7 @@ extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
136 struct sk_buff *pkt, int prec); 136 struct sk_buff *pkt, int prec);
137 137
138/* Receive frame for delivery to OS. Callee disposes of rxp. */ 138/* Receive frame for delivery to OS. Callee disposes of rxp. */
139extern void brcmf_rx_frames(struct device *dev, struct sk_buff_head *rxlist); 139extern void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp);
140 140
141/* Indication from bus module regarding presence/insertion of dongle. */ 141/* Indication from bus module regarding presence/insertion of dongle. */
142extern int brcmf_attach(uint bus_hdrlen, struct device *dev); 142extern int brcmf_attach(uint bus_hdrlen, struct device *dev);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
index e067aec1fbf1..42bf19a2eeee 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
@@ -509,9 +509,8 @@ netif_rx:
509 } 509 }
510} 510}
511 511
512void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list) 512void brcmf_rx_frame(struct device *dev, struct sk_buff *skb)
513{ 513{
514 struct sk_buff *skb, *pnext;
515 struct brcmf_if *ifp; 514 struct brcmf_if *ifp;
516 struct brcmf_bus *bus_if = dev_get_drvdata(dev); 515 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
517 struct brcmf_pub *drvr = bus_if->drvr; 516 struct brcmf_pub *drvr = bus_if->drvr;
@@ -519,29 +518,24 @@ void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list)
519 u8 ifidx; 518 u8 ifidx;
520 int ret; 519 int ret;
521 520
522 brcmf_dbg(DATA, "Enter: %s: count=%u\n", dev_name(dev), 521 brcmf_dbg(DATA, "Enter: %s: rxp=%p\n", dev_name(dev), skb);
523 skb_queue_len(skb_list));
524 522
525 skb_queue_walk_safe(skb_list, skb, pnext) { 523 /* process and remove protocol-specific header */
526 skb_unlink(skb, skb_list); 524 ret = brcmf_proto_hdrpull(drvr, true, &ifidx, skb);
527 525 ifp = drvr->iflist[ifidx];
528 /* process and remove protocol-specific header */
529 ret = brcmf_proto_hdrpull(drvr, true, &ifidx, skb);
530 ifp = drvr->iflist[ifidx];
531
532 if (ret || !ifp || !ifp->ndev) {
533 if ((ret != -ENODATA) && ifp)
534 ifp->stats.rx_errors++;
535 brcmu_pkt_buf_free_skb(skb);
536 continue;
537 }
538 526
539 rd = (struct brcmf_skb_reorder_data *)skb->cb; 527 if (ret || !ifp || !ifp->ndev) {
540 if (rd->reorder) 528 if ((ret != -ENODATA) && ifp)
541 brcmf_rxreorder_process_info(ifp, rd->reorder, skb); 529 ifp->stats.rx_errors++;
542 else 530 brcmu_pkt_buf_free_skb(skb);
543 brcmf_netif_rx(ifp, skb); 531 return;
544 } 532 }
533
534 rd = (struct brcmf_skb_reorder_data *)skb->cb;
535 if (rd->reorder)
536 brcmf_rxreorder_process_info(ifp, rd->reorder, skb);
537 else
538 brcmf_netif_rx(ifp, skb);
545} 539}
546 540
547void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp, 541void brcmf_txfinalize(struct brcmf_pub *drvr, struct sk_buff *txp,
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 1aa75d5951b8..67f05db4b9b8 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -275,11 +275,6 @@ struct rte_console {
275/* Flags for SDH calls */ 275/* Flags for SDH calls */
276#define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) 276#define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED)
277 277
278#define BRCMF_SDIO_FW_NAME "brcm/brcmfmac-sdio.bin"
279#define BRCMF_SDIO_NV_NAME "brcm/brcmfmac-sdio.txt"
280MODULE_FIRMWARE(BRCMF_SDIO_FW_NAME);
281MODULE_FIRMWARE(BRCMF_SDIO_NV_NAME);
282
283#define BRCMF_IDLE_IMMEDIATE (-1) /* Enter idle immediately */ 278#define BRCMF_IDLE_IMMEDIATE (-1) /* Enter idle immediately */
284#define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change 279#define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change
285 * when idle 280 * when idle
@@ -454,9 +449,6 @@ struct brcmf_sdio {
454 struct work_struct datawork; 449 struct work_struct datawork;
455 atomic_t dpc_tskcnt; 450 atomic_t dpc_tskcnt;
456 451
457 const struct firmware *firmware;
458 u32 fw_ptr;
459
460 bool txoff; /* Transmit flow-controlled */ 452 bool txoff; /* Transmit flow-controlled */
461 struct brcmf_sdio_count sdcnt; 453 struct brcmf_sdio_count sdcnt;
462 bool sr_enabled; /* SaveRestore enabled */ 454 bool sr_enabled; /* SaveRestore enabled */
@@ -493,6 +485,100 @@ enum brcmf_sdio_frmtype {
493 BRCMF_SDIO_FT_SUB, 485 BRCMF_SDIO_FT_SUB,
494}; 486};
495 487
488#define BCM43143_FIRMWARE_NAME "brcm/brcmfmac43143-sdio.bin"
489#define BCM43143_NVRAM_NAME "brcm/brcmfmac43143-sdio.txt"
490#define BCM43241B0_FIRMWARE_NAME "brcm/brcmfmac43241b0-sdio.bin"
491#define BCM43241B0_NVRAM_NAME "brcm/brcmfmac43241b0-sdio.txt"
492#define BCM43241B4_FIRMWARE_NAME "brcm/brcmfmac43241b4-sdio.bin"
493#define BCM43241B4_NVRAM_NAME "brcm/brcmfmac43241b4-sdio.txt"
494#define BCM4329_FIRMWARE_NAME "brcm/brcmfmac4329-sdio.bin"
495#define BCM4329_NVRAM_NAME "brcm/brcmfmac4329-sdio.txt"
496#define BCM4330_FIRMWARE_NAME "brcm/brcmfmac4330-sdio.bin"
497#define BCM4330_NVRAM_NAME "brcm/brcmfmac4330-sdio.txt"
498#define BCM4334_FIRMWARE_NAME "brcm/brcmfmac4334-sdio.bin"
499#define BCM4334_NVRAM_NAME "brcm/brcmfmac4334-sdio.txt"
500#define BCM4335_FIRMWARE_NAME "brcm/brcmfmac4335-sdio.bin"
501#define BCM4335_NVRAM_NAME "brcm/brcmfmac4335-sdio.txt"
502
503MODULE_FIRMWARE(BCM43143_FIRMWARE_NAME);
504MODULE_FIRMWARE(BCM43143_NVRAM_NAME);
505MODULE_FIRMWARE(BCM43241B0_FIRMWARE_NAME);
506MODULE_FIRMWARE(BCM43241B0_NVRAM_NAME);
507MODULE_FIRMWARE(BCM43241B4_FIRMWARE_NAME);
508MODULE_FIRMWARE(BCM43241B4_NVRAM_NAME);
509MODULE_FIRMWARE(BCM4329_FIRMWARE_NAME);
510MODULE_FIRMWARE(BCM4329_NVRAM_NAME);
511MODULE_FIRMWARE(BCM4330_FIRMWARE_NAME);
512MODULE_FIRMWARE(BCM4330_NVRAM_NAME);
513MODULE_FIRMWARE(BCM4334_FIRMWARE_NAME);
514MODULE_FIRMWARE(BCM4334_NVRAM_NAME);
515MODULE_FIRMWARE(BCM4335_FIRMWARE_NAME);
516MODULE_FIRMWARE(BCM4335_NVRAM_NAME);
517
518struct brcmf_firmware_names {
519 u32 chipid;
520 u32 revmsk;
521 const char *bin;
522 const char *nv;
523};
524
525enum brcmf_firmware_type {
526 BRCMF_FIRMWARE_BIN,
527 BRCMF_FIRMWARE_NVRAM
528};
529
530#define BRCMF_FIRMWARE_NVRAM(name) \
531 name ## _FIRMWARE_NAME, name ## _NVRAM_NAME
532
533static const struct brcmf_firmware_names brcmf_fwname_data[] = {
534 { BCM43143_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM43143) },
535 { BCM43241_CHIP_ID, 0x0000001F, BRCMF_FIRMWARE_NVRAM(BCM43241B0) },
536 { BCM43241_CHIP_ID, 0xFFFFFFE0, BRCMF_FIRMWARE_NVRAM(BCM43241B4) },
537 { BCM4329_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4329) },
538 { BCM4330_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4330) },
539 { BCM4334_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4334) },
540 { BCM4335_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4335) }
541};
542
543
544static const struct firmware *brcmf_sdbrcm_get_fw(struct brcmf_sdio *bus,
545 enum brcmf_firmware_type type)
546{
547 const struct firmware *fw;
548 const char *name;
549 int err, i;
550
551 for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) {
552 if (brcmf_fwname_data[i].chipid == bus->ci->chip &&
553 brcmf_fwname_data[i].revmsk & BIT(bus->ci->chiprev)) {
554 switch (type) {
555 case BRCMF_FIRMWARE_BIN:
556 name = brcmf_fwname_data[i].bin;
557 break;
558 case BRCMF_FIRMWARE_NVRAM:
559 name = brcmf_fwname_data[i].nv;
560 break;
561 default:
562 brcmf_err("invalid firmware type (%d)\n", type);
563 return NULL;
564 }
565 goto found;
566 }
567 }
568 brcmf_err("Unknown chipid %d [%d]\n",
569 bus->ci->chip, bus->ci->chiprev);
570 return NULL;
571
572found:
573 err = request_firmware(&fw, name, &bus->sdiodev->func[2]->dev);
574 if ((err) || (!fw)) {
575 brcmf_err("fail to request firmware %s (%d)\n", name, err);
576 return NULL;
577 }
578
579 return fw;
580}
581
496static void pkt_align(struct sk_buff *p, int len, int align) 582static void pkt_align(struct sk_buff *p, int len, int align)
497{ 583{
498 uint datalign; 584 uint datalign;
@@ -1406,13 +1492,12 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
1406 bus->glom.qlen, pfirst, pfirst->data, 1492 bus->glom.qlen, pfirst, pfirst->data,
1407 pfirst->len, pfirst->next, 1493 pfirst->len, pfirst->next,
1408 pfirst->prev); 1494 pfirst->prev);
1495 skb_unlink(pfirst, &bus->glom);
1496 brcmf_rx_frame(bus->sdiodev->dev, pfirst);
1497 bus->sdcnt.rxglompkts++;
1409 } 1498 }
1410 /* sent any remaining packets up */
1411 if (bus->glom.qlen)
1412 brcmf_rx_frames(bus->sdiodev->dev, &bus->glom);
1413 1499
1414 bus->sdcnt.rxglomframes++; 1500 bus->sdcnt.rxglomframes++;
1415 bus->sdcnt.rxglompkts += bus->glom.qlen;
1416 } 1501 }
1417 return num; 1502 return num;
1418} 1503}
@@ -1557,7 +1642,6 @@ static void brcmf_pad(struct brcmf_sdio *bus, u16 *pad, u16 *rdlen)
1557static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) 1642static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
1558{ 1643{
1559 struct sk_buff *pkt; /* Packet for event or data frames */ 1644 struct sk_buff *pkt; /* Packet for event or data frames */
1560 struct sk_buff_head pktlist; /* needed for bus interface */
1561 u16 pad; /* Number of pad bytes to read */ 1645 u16 pad; /* Number of pad bytes to read */
1562 uint rxleft = 0; /* Remaining number of frames allowed */ 1646 uint rxleft = 0; /* Remaining number of frames allowed */
1563 int ret; /* Return code from calls */ 1647 int ret; /* Return code from calls */
@@ -1759,9 +1843,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
1759 continue; 1843 continue;
1760 } 1844 }
1761 1845
1762 skb_queue_head_init(&pktlist); 1846 brcmf_rx_frame(bus->sdiodev->dev, pkt);
1763 skb_queue_tail(&pktlist, pkt);
1764 brcmf_rx_frames(bus->sdiodev->dev, &pktlist);
1765 } 1847 }
1766 1848
1767 rxcount = maxframes - rxleft; 1849 rxcount = maxframes - rxleft;
@@ -1786,10 +1868,15 @@ brcmf_sdbrcm_wait_event_wakeup(struct brcmf_sdio *bus)
1786 return; 1868 return;
1787} 1869}
1788 1870
1871/**
1872 * struct brcmf_skbuff_cb reserves first two bytes in sk_buff::cb for
1873 * bus layer usage.
1874 */
1789/* flag marking a dummy skb added for DMA alignment requirement */ 1875/* flag marking a dummy skb added for DMA alignment requirement */
1790#define DUMMY_SKB_FLAG 0x10000 1876#define ALIGN_SKB_FLAG 0x8000
1791/* bit mask of data length chopped from the previous packet */ 1877/* bit mask of data length chopped from the previous packet */
1792#define DUMMY_SKB_CHOP_LEN_MASK 0xffff 1878#define ALIGN_SKB_CHOP_LEN_MASK 0x7fff
1879
1793/** 1880/**
1794 * brcmf_sdio_txpkt_prep - packet preparation for transmit 1881 * brcmf_sdio_txpkt_prep - packet preparation for transmit
1795 * @bus: brcmf_sdio structure pointer 1882 * @bus: brcmf_sdio structure pointer
@@ -1854,7 +1941,7 @@ brcmf_sdio_txpkt_prep(struct brcmf_sdio *bus, struct sk_buff_head *pktq,
1854 memcpy(pkt_new->data, 1941 memcpy(pkt_new->data,
1855 pkt_next->data + pkt_next->len - tail_chop, 1942 pkt_next->data + pkt_next->len - tail_chop,
1856 tail_chop); 1943 tail_chop);
1857 *(u32 *)(pkt_new->cb) = DUMMY_SKB_FLAG + tail_chop; 1944 *(u32 *)(pkt_new->cb) = ALIGN_SKB_FLAG + tail_chop;
1858 skb_trim(pkt_next, pkt_next->len - tail_chop); 1945 skb_trim(pkt_next, pkt_next->len - tail_chop);
1859 __skb_queue_after(pktq, pkt_next, pkt_new); 1946 __skb_queue_after(pktq, pkt_next, pkt_new);
1860 } else { 1947 } else {
@@ -1908,8 +1995,8 @@ brcmf_sdio_txpkt_postp(struct brcmf_sdio *bus, struct sk_buff_head *pktq)
1908 1995
1909 skb_queue_walk_safe(pktq, pkt_next, tmp) { 1996 skb_queue_walk_safe(pktq, pkt_next, tmp) {
1910 dummy_flags = *(u32 *)(pkt_next->cb); 1997 dummy_flags = *(u32 *)(pkt_next->cb);
1911 if (dummy_flags & DUMMY_SKB_FLAG) { 1998 if (dummy_flags & ALIGN_SKB_FLAG) {
1912 chop_len = dummy_flags & DUMMY_SKB_CHOP_LEN_MASK; 1999 chop_len = dummy_flags & ALIGN_SKB_CHOP_LEN_MASK;
1913 if (chop_len) { 2000 if (chop_len) {
1914 pkt_prev = pkt_next->prev; 2001 pkt_prev = pkt_next->prev;
1915 memcpy(pkt_prev->data + pkt_prev->len, 2002 memcpy(pkt_prev->data + pkt_prev->len,
@@ -3037,69 +3124,43 @@ static bool brcmf_sdbrcm_download_state(struct brcmf_sdio *bus, bool enter)
3037 return true; 3124 return true;
3038} 3125}
3039 3126
3040static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_sdio *bus)
3041{
3042 if (bus->firmware->size < bus->fw_ptr + len)
3043 len = bus->firmware->size - bus->fw_ptr;
3044
3045 memcpy(buf, &bus->firmware->data[bus->fw_ptr], len);
3046 bus->fw_ptr += len;
3047 return len;
3048}
3049
3050static int brcmf_sdbrcm_download_code_file(struct brcmf_sdio *bus) 3127static int brcmf_sdbrcm_download_code_file(struct brcmf_sdio *bus)
3051{ 3128{
3129 const struct firmware *fw;
3130 int err;
3052 int offset; 3131 int offset;
3053 uint len; 3132 int address;
3054 u8 *memblock = NULL, *memptr; 3133 int len;
3055 int ret; 3134
3056 u8 idx; 3135 fw = brcmf_sdbrcm_get_fw(bus, BRCMF_FIRMWARE_BIN);
3057 3136 if (fw == NULL)
3058 brcmf_dbg(INFO, "Enter\n"); 3137 return -ENOENT;
3059 3138
3060 ret = request_firmware(&bus->firmware, BRCMF_SDIO_FW_NAME, 3139 if (brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_ARM_CR4) !=
3061 &bus->sdiodev->func[2]->dev); 3140 BRCMF_MAX_CORENUM)
3062 if (ret) { 3141 memcpy(&bus->ci->rst_vec, fw->data, sizeof(bus->ci->rst_vec));
3063 brcmf_err("Fail to request firmware %d\n", ret); 3142
3064 return ret; 3143 err = 0;
3065 } 3144 offset = 0;
3066 bus->fw_ptr = 0; 3145 address = bus->ci->rambase;
3067 3146 while (offset < fw->size) {
3068 memptr = memblock = kmalloc(MEMBLOCK + BRCMF_SDALIGN, GFP_ATOMIC); 3147 len = ((offset + MEMBLOCK) < fw->size) ? MEMBLOCK :
3069 if (memblock == NULL) { 3148 fw->size - offset;
3070 ret = -ENOMEM; 3149 err = brcmf_sdio_ramrw(bus->sdiodev, true, address,
3071 goto err; 3150 (u8 *)&fw->data[offset], len);
3072 } 3151 if (err) {
3073 if ((u32)(unsigned long)memblock % BRCMF_SDALIGN)
3074 memptr += (BRCMF_SDALIGN -
3075 ((u32)(unsigned long)memblock % BRCMF_SDALIGN));
3076
3077 offset = bus->ci->rambase;
3078
3079 /* Download image */
3080 len = brcmf_sdbrcm_get_image((char *)memptr, MEMBLOCK, bus);
3081 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_ARM_CR4);
3082 if (BRCMF_MAX_CORENUM != idx)
3083 memcpy(&bus->ci->rst_vec, memptr, sizeof(bus->ci->rst_vec));
3084 while (len) {
3085 ret = brcmf_sdio_ramrw(bus->sdiodev, true, offset, memptr, len);
3086 if (ret) {
3087 brcmf_err("error %d on writing %d membytes at 0x%08x\n", 3152 brcmf_err("error %d on writing %d membytes at 0x%08x\n",
3088 ret, MEMBLOCK, offset); 3153 err, len, address);
3089 goto err; 3154 goto failure;
3090 } 3155 }
3091 3156 offset += len;
3092 offset += MEMBLOCK; 3157 address += len;
3093 len = brcmf_sdbrcm_get_image((char *)memptr, MEMBLOCK, bus);
3094 } 3158 }
3095 3159
3096err: 3160failure:
3097 kfree(memblock); 3161 release_firmware(fw);
3098 3162
3099 release_firmware(bus->firmware); 3163 return err;
3100 bus->fw_ptr = 0;
3101
3102 return ret;
3103} 3164}
3104 3165
3105/* 3166/*
@@ -3111,7 +3172,8 @@ err:
3111 * by two NULs. 3172 * by two NULs.
3112*/ 3173*/
3113 3174
3114static int brcmf_process_nvram_vars(struct brcmf_sdio *bus) 3175static int brcmf_process_nvram_vars(struct brcmf_sdio *bus,
3176 const struct firmware *nv)
3115{ 3177{
3116 char *varbuf; 3178 char *varbuf;
3117 char *dp; 3179 char *dp;
@@ -3120,12 +3182,12 @@ static int brcmf_process_nvram_vars(struct brcmf_sdio *bus)
3120 int ret = 0; 3182 int ret = 0;
3121 uint buf_len, n, len; 3183 uint buf_len, n, len;
3122 3184
3123 len = bus->firmware->size; 3185 len = nv->size;
3124 varbuf = vmalloc(len); 3186 varbuf = vmalloc(len);
3125 if (!varbuf) 3187 if (!varbuf)
3126 return -ENOMEM; 3188 return -ENOMEM;
3127 3189
3128 memcpy(varbuf, bus->firmware->data, len); 3190 memcpy(varbuf, nv->data, len);
3129 dp = varbuf; 3191 dp = varbuf;
3130 3192
3131 findNewline = false; 3193 findNewline = false;
@@ -3177,18 +3239,16 @@ err:
3177 3239
3178static int brcmf_sdbrcm_download_nvram(struct brcmf_sdio *bus) 3240static int brcmf_sdbrcm_download_nvram(struct brcmf_sdio *bus)
3179{ 3241{
3242 const struct firmware *nv;
3180 int ret; 3243 int ret;
3181 3244
3182 ret = request_firmware(&bus->firmware, BRCMF_SDIO_NV_NAME, 3245 nv = brcmf_sdbrcm_get_fw(bus, BRCMF_FIRMWARE_NVRAM);
3183 &bus->sdiodev->func[2]->dev); 3246 if (nv == NULL)
3184 if (ret) { 3247 return -ENOENT;
3185 brcmf_err("Fail to request nvram %d\n", ret);
3186 return ret;
3187 }
3188 3248
3189 ret = brcmf_process_nvram_vars(bus); 3249 ret = brcmf_process_nvram_vars(bus, nv);
3190 3250
3191 release_firmware(bus->firmware); 3251 release_firmware(nv);
3192 3252
3193 return ret; 3253 return ret;
3194} 3254}
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.h b/drivers/net/wireless/brcm80211/brcmfmac/fweh.h
index e679214b3c98..14bc24dc5bae 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.h
@@ -102,7 +102,8 @@ struct brcmf_event;
102 BRCMF_ENUM_DEF(DCS_REQUEST, 73) \ 102 BRCMF_ENUM_DEF(DCS_REQUEST, 73) \
103 BRCMF_ENUM_DEF(FIFO_CREDIT_MAP, 74) \ 103 BRCMF_ENUM_DEF(FIFO_CREDIT_MAP, 74) \
104 BRCMF_ENUM_DEF(ACTION_FRAME_RX, 75) \ 104 BRCMF_ENUM_DEF(ACTION_FRAME_RX, 75) \
105 BRCMF_ENUM_DEF(BCMC_CREDIT_SUPPORT, 127) 105 BRCMF_ENUM_DEF(BCMC_CREDIT_SUPPORT, 127) \
106 BRCMF_ENUM_DEF(PSTA_PRIMARY_INTF_IND, 128)
106 107
107#define BRCMF_ENUM_DEF(id, val) \ 108#define BRCMF_ENUM_DEF(id, val) \
108 BRCMF_E_##id = (val), 109 BRCMF_E_##id = (val),
@@ -114,6 +115,8 @@ enum brcmf_fweh_event_code {
114}; 115};
115#undef BRCMF_ENUM_DEF 116#undef BRCMF_ENUM_DEF
116 117
118#define BRCMF_EVENTING_MASK_LEN DIV_ROUND_UP(BRCMF_E_LAST, 8)
119
117/* flags field values in struct brcmf_event_msg */ 120/* flags field values in struct brcmf_event_msg */
118#define BRCMF_EVENT_MSG_LINK 0x01 121#define BRCMF_EVENT_MSG_LINK 0x01
119#define BRCMF_EVENT_MSG_FLUSHTXQ 0x02 122#define BRCMF_EVENT_MSG_FLUSHTXQ 0x02
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
index 82f9140f3d35..d0cd0bf95c5a 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
@@ -168,6 +168,7 @@ enum brcmf_fws_skb_state {
168/** 168/**
169 * struct brcmf_skbuff_cb - control buffer associated with skbuff. 169 * struct brcmf_skbuff_cb - control buffer associated with skbuff.
170 * 170 *
171 * @bus_flags: 2 bytes reserved for bus specific parameters
171 * @if_flags: holds interface index and packet related flags. 172 * @if_flags: holds interface index and packet related flags.
172 * @htod: host to device packet identifier (used in PKTTAG tlv). 173 * @htod: host to device packet identifier (used in PKTTAG tlv).
173 * @state: transmit state of the packet. 174 * @state: transmit state of the packet.
@@ -177,6 +178,7 @@ enum brcmf_fws_skb_state {
177 * provides 48 bytes of storage so this structure should not exceed that. 178 * provides 48 bytes of storage so this structure should not exceed that.
178 */ 179 */
179struct brcmf_skbuff_cb { 180struct brcmf_skbuff_cb {
181 u16 bus_flags;
180 u16 if_flags; 182 u16 if_flags;
181 u32 htod; 183 u32 htod;
182 enum brcmf_fws_skb_state state; 184 enum brcmf_fws_skb_state state;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
index ca72177388b9..2096a14ef1fb 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
@@ -18,6 +18,7 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/netdevice.h> 19#include <linux/netdevice.h>
20#include <linux/mmc/card.h> 20#include <linux/mmc/card.h>
21#include <linux/mmc/sdio_func.h>
21#include <linux/ssb/ssb_regs.h> 22#include <linux/ssb/ssb_regs.h>
22#include <linux/bcma/bcma.h> 23#include <linux/bcma/bcma.h>
23 24
@@ -136,6 +137,8 @@ brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev,
136 u8 idx; 137 u8 idx;
137 138
138 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 139 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
140 if (idx == BRCMF_MAX_CORENUM)
141 return false;
139 142
140 regdata = brcmf_sdio_regrl(sdiodev, 143 regdata = brcmf_sdio_regrl(sdiodev,
141 CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 144 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
@@ -154,6 +157,8 @@ brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev,
154 bool ret; 157 bool ret;
155 158
156 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 159 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
160 if (idx == BRCMF_MAX_CORENUM)
161 return false;
157 162
158 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 163 regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
159 NULL); 164 NULL);
@@ -261,6 +266,8 @@ brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev,
261 u32 regdata; 266 u32 regdata;
262 267
263 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 268 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
269 if (idx == BRCMF_MAX_CORENUM)
270 return;
264 271
265 /* if core is already in reset, just return */ 272 /* if core is already in reset, just return */
266 regdata = brcmf_sdio_regrl(sdiodev, 273 regdata = brcmf_sdio_regrl(sdiodev,
@@ -304,6 +311,8 @@ brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev,
304 u8 idx; 311 u8 idx;
305 312
306 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 313 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
314 if (idx == BRCMF_MAX_CORENUM)
315 return;
307 316
308 /* 317 /*
309 * Must do the disable sequence first to work for 318 * Must do the disable sequence first to work for
@@ -368,6 +377,8 @@ brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev,
368 u32 regdata; 377 u32 regdata;
369 378
370 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 379 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
380 if (idx == BRCMF_MAX_CORENUM)
381 return;
371 382
372 /* must disable first to work for arbitrary current core state */ 383 /* must disable first to work for arbitrary current core state */
373 brcmf_sdio_ai_coredisable(sdiodev, ci, coreid, core_bits); 384 brcmf_sdio_ai_coredisable(sdiodev, ci, coreid, core_bits);
@@ -444,6 +455,9 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev,
444 NULL); 455 NULL);
445 ci->chip = regdata & CID_ID_MASK; 456 ci->chip = regdata & CID_ID_MASK;
446 ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; 457 ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
458 if (sdiodev->func[0]->device == SDIO_DEVICE_ID_BROADCOM_4335_4339 &&
459 ci->chiprev >= 2)
460 ci->chip = BCM4339_CHIP_ID;
447 ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT; 461 ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
448 462
449 brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); 463 brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev);
@@ -541,6 +555,20 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev,
541 ci->ramsize = 0xc0000; 555 ci->ramsize = 0xc0000;
542 ci->rambase = 0x180000; 556 ci->rambase = 0x180000;
543 break; 557 break;
558 case BCM4339_CHIP_ID:
559 ci->c_inf[0].wrapbase = 0x18100000;
560 ci->c_inf[0].cib = 0x2e084411;
561 ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
562 ci->c_inf[1].base = 0x18005000;
563 ci->c_inf[1].wrapbase = 0x18105000;
564 ci->c_inf[1].cib = 0x15004211;
565 ci->c_inf[2].id = BCMA_CORE_ARM_CR4;
566 ci->c_inf[2].base = 0x18002000;
567 ci->c_inf[2].wrapbase = 0x18102000;
568 ci->c_inf[2].cib = 0x04084411;
569 ci->ramsize = 0xc0000;
570 ci->rambase = 0x180000;
571 break;
544 default: 572 default:
545 brcmf_err("chipid 0x%x is not supported\n", ci->chip); 573 brcmf_err("chipid 0x%x is not supported\n", ci->chip);
546 return -ENODEV; 574 return -ENODEV;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
index 83c041f1bf4a..076b83c7c896 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
@@ -54,6 +54,14 @@
54 54
55#define BRCMF_MAX_CORENUM 6 55#define BRCMF_MAX_CORENUM 6
56 56
57/* SDIO device ID */
58#define SDIO_DEVICE_ID_BROADCOM_43143 43143
59#define SDIO_DEVICE_ID_BROADCOM_43241 0x4324
60#define SDIO_DEVICE_ID_BROADCOM_4329 0x4329
61#define SDIO_DEVICE_ID_BROADCOM_4330 0x4330
62#define SDIO_DEVICE_ID_BROADCOM_4334 0x4334
63#define SDIO_DEVICE_ID_BROADCOM_4335_4339 0x4335
64
57struct chip_core_info { 65struct chip_core_info {
58 u16 id; 66 u16 id;
59 u16 rev; 67 u16 rev;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index 39e01a7c8556..bf6758d95600 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -435,7 +435,6 @@ static void brcmf_usb_rx_complete(struct urb *urb)
435 struct brcmf_usbreq *req = (struct brcmf_usbreq *)urb->context; 435 struct brcmf_usbreq *req = (struct brcmf_usbreq *)urb->context;
436 struct brcmf_usbdev_info *devinfo = req->devinfo; 436 struct brcmf_usbdev_info *devinfo = req->devinfo;
437 struct sk_buff *skb; 437 struct sk_buff *skb;
438 struct sk_buff_head skbq;
439 438
440 brcmf_dbg(USB, "Enter, urb->status=%d\n", urb->status); 439 brcmf_dbg(USB, "Enter, urb->status=%d\n", urb->status);
441 brcmf_usb_del_fromq(devinfo, req); 440 brcmf_usb_del_fromq(devinfo, req);
@@ -450,10 +449,8 @@ static void brcmf_usb_rx_complete(struct urb *urb)
450 } 449 }
451 450
452 if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP) { 451 if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP) {
453 skb_queue_head_init(&skbq);
454 skb_queue_tail(&skbq, skb);
455 skb_put(skb, urb->actual_length); 452 skb_put(skb, urb->actual_length);
456 brcmf_rx_frames(devinfo->dev, &skbq); 453 brcmf_rx_frame(devinfo->dev, skb);
457 brcmf_usb_rx_refill(devinfo, req); 454 brcmf_usb_rx_refill(devinfo, req);
458 } else { 455 } else {
459 brcmu_pkt_buf_free_skb(skb); 456 brcmu_pkt_buf_free_skb(skb);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 4608e0eb1493..df6229ed52c8 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -5695,7 +5695,7 @@ static bool brcms_c_chipmatch_pci(struct bcma_device *core)
5695 return true; 5695 return true;
5696 if ((device == BCM43224_D11N_ID) || (device == BCM43225_D11N2G_ID)) 5696 if ((device == BCM43224_D11N_ID) || (device == BCM43225_D11N2G_ID))
5697 return true; 5697 return true;
5698 if (device == BCM4313_D11N2G_ID) 5698 if (device == BCM4313_D11N2G_ID || device == BCM4313_CHIP_ID)
5699 return true; 5699 return true;
5700 if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID)) 5700 if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID))
5701 return true; 5701 return true;
diff --git a/drivers/net/wireless/brcm80211/include/brcm_hw_ids.h b/drivers/net/wireless/brcm80211/include/brcm_hw_ids.h
index c1fe245bb07e..84113ea16f84 100644
--- a/drivers/net/wireless/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/brcm80211/include/brcm_hw_ids.h
@@ -41,5 +41,6 @@
41#define BCM4331_CHIP_ID 0x4331 41#define BCM4331_CHIP_ID 0x4331
42#define BCM4334_CHIP_ID 0x4334 42#define BCM4334_CHIP_ID 0x4334
43#define BCM4335_CHIP_ID 0x4335 43#define BCM4335_CHIP_ID 0x4335
44#define BCM4339_CHIP_ID 0x4339
44 45
45#endif /* _BRCM_HW_IDS_H_ */ 46#endif /* _BRCM_HW_IDS_H_ */
diff --git a/drivers/net/wireless/cw1200/cw1200_spi.c b/drivers/net/wireless/cw1200/cw1200_spi.c
index d06376014bcd..e310752f0e33 100644
--- a/drivers/net/wireless/cw1200/cw1200_spi.c
+++ b/drivers/net/wireless/cw1200/cw1200_spi.c
@@ -40,7 +40,9 @@ struct hwbus_priv {
40 struct cw1200_common *core; 40 struct cw1200_common *core;
41 const struct cw1200_platform_data_spi *pdata; 41 const struct cw1200_platform_data_spi *pdata;
42 spinlock_t lock; /* Serialize all bus operations */ 42 spinlock_t lock; /* Serialize all bus operations */
43 wait_queue_head_t wq;
43 int claimed; 44 int claimed;
45 int irq_disabled;
44}; 46};
45 47
46#define SDIO_TO_SPI_ADDR(addr) ((addr & 0x1f)>>2) 48#define SDIO_TO_SPI_ADDR(addr) ((addr & 0x1f)>>2)
@@ -197,8 +199,11 @@ static void cw1200_spi_lock(struct hwbus_priv *self)
197{ 199{
198 unsigned long flags; 200 unsigned long flags;
199 201
202 DECLARE_WAITQUEUE(wait, current);
203
200 might_sleep(); 204 might_sleep();
201 205
206 add_wait_queue(&self->wq, &wait);
202 spin_lock_irqsave(&self->lock, flags); 207 spin_lock_irqsave(&self->lock, flags);
203 while (1) { 208 while (1) {
204 set_current_state(TASK_UNINTERRUPTIBLE); 209 set_current_state(TASK_UNINTERRUPTIBLE);
@@ -211,6 +216,7 @@ static void cw1200_spi_lock(struct hwbus_priv *self)
211 set_current_state(TASK_RUNNING); 216 set_current_state(TASK_RUNNING);
212 self->claimed = 1; 217 self->claimed = 1;
213 spin_unlock_irqrestore(&self->lock, flags); 218 spin_unlock_irqrestore(&self->lock, flags);
219 remove_wait_queue(&self->wq, &wait);
214 220
215 return; 221 return;
216} 222}
@@ -222,6 +228,8 @@ static void cw1200_spi_unlock(struct hwbus_priv *self)
222 spin_lock_irqsave(&self->lock, flags); 228 spin_lock_irqsave(&self->lock, flags);
223 self->claimed = 0; 229 self->claimed = 0;
224 spin_unlock_irqrestore(&self->lock, flags); 230 spin_unlock_irqrestore(&self->lock, flags);
231 wake_up(&self->wq);
232
225 return; 233 return;
226} 234}
227 235
@@ -230,6 +238,8 @@ static irqreturn_t cw1200_spi_irq_handler(int irq, void *dev_id)
230 struct hwbus_priv *self = dev_id; 238 struct hwbus_priv *self = dev_id;
231 239
232 if (self->core) { 240 if (self->core) {
241 disable_irq_nosync(self->func->irq);
242 self->irq_disabled = 1;
233 cw1200_irq_handler(self->core); 243 cw1200_irq_handler(self->core);
234 return IRQ_HANDLED; 244 return IRQ_HANDLED;
235 } else { 245 } else {
@@ -263,13 +273,22 @@ exit:
263 273
264static int cw1200_spi_irq_unsubscribe(struct hwbus_priv *self) 274static int cw1200_spi_irq_unsubscribe(struct hwbus_priv *self)
265{ 275{
266 int ret = 0;
267
268 pr_debug("SW IRQ unsubscribe\n"); 276 pr_debug("SW IRQ unsubscribe\n");
269 disable_irq_wake(self->func->irq); 277 disable_irq_wake(self->func->irq);
270 free_irq(self->func->irq, self); 278 free_irq(self->func->irq, self);
271 279
272 return ret; 280 return 0;
281}
282
283static int cw1200_spi_irq_enable(struct hwbus_priv *self, int enable)
284{
285 /* Disables are handled by the interrupt handler */
286 if (enable && self->irq_disabled) {
287 enable_irq(self->func->irq);
288 self->irq_disabled = 0;
289 }
290
291 return 0;
273} 292}
274 293
275static int cw1200_spi_off(const struct cw1200_platform_data_spi *pdata) 294static int cw1200_spi_off(const struct cw1200_platform_data_spi *pdata)
@@ -349,13 +368,14 @@ static struct hwbus_ops cw1200_spi_hwbus_ops = {
349 .unlock = cw1200_spi_unlock, 368 .unlock = cw1200_spi_unlock,
350 .align_size = cw1200_spi_align_size, 369 .align_size = cw1200_spi_align_size,
351 .power_mgmt = cw1200_spi_pm, 370 .power_mgmt = cw1200_spi_pm,
371 .irq_enable = cw1200_spi_irq_enable,
352}; 372};
353 373
354/* Probe Function to be called by SPI stack when device is discovered */ 374/* Probe Function to be called by SPI stack when device is discovered */
355static int cw1200_spi_probe(struct spi_device *func) 375static int cw1200_spi_probe(struct spi_device *func)
356{ 376{
357 const struct cw1200_platform_data_spi *plat_data = 377 const struct cw1200_platform_data_spi *plat_data =
358 func->dev.platform_data; 378 dev_get_platdata(&func->dev);
359 struct hwbus_priv *self; 379 struct hwbus_priv *self;
360 int status; 380 int status;
361 381
@@ -400,6 +420,8 @@ static int cw1200_spi_probe(struct spi_device *func)
400 420
401 spi_set_drvdata(func, self); 421 spi_set_drvdata(func, self);
402 422
423 init_waitqueue_head(&self->wq);
424
403 status = cw1200_spi_irq_subscribe(self); 425 status = cw1200_spi_irq_subscribe(self);
404 426
405 status = cw1200_core_probe(&cw1200_spi_hwbus_ops, 427 status = cw1200_core_probe(&cw1200_spi_hwbus_ops,
@@ -431,7 +453,7 @@ static int cw1200_spi_disconnect(struct spi_device *func)
431 } 453 }
432 kfree(self); 454 kfree(self);
433 } 455 }
434 cw1200_spi_off(func->dev.platform_data); 456 cw1200_spi_off(dev_get_platdata(&func->dev));
435 457
436 return 0; 458 return 0;
437} 459}
diff --git a/drivers/net/wireless/cw1200/fwio.c b/drivers/net/wireless/cw1200/fwio.c
index acdff0f7f952..0b2061bbc68b 100644
--- a/drivers/net/wireless/cw1200/fwio.c
+++ b/drivers/net/wireless/cw1200/fwio.c
@@ -485,7 +485,7 @@ int cw1200_load_firmware(struct cw1200_common *priv)
485 485
486 /* Enable interrupt signalling */ 486 /* Enable interrupt signalling */
487 priv->hwbus_ops->lock(priv->hwbus_priv); 487 priv->hwbus_ops->lock(priv->hwbus_priv);
488 ret = __cw1200_irq_enable(priv, 1); 488 ret = __cw1200_irq_enable(priv, 2);
489 priv->hwbus_ops->unlock(priv->hwbus_priv); 489 priv->hwbus_ops->unlock(priv->hwbus_priv);
490 if (ret < 0) 490 if (ret < 0)
491 goto unsubscribe; 491 goto unsubscribe;
diff --git a/drivers/net/wireless/cw1200/hwbus.h b/drivers/net/wireless/cw1200/hwbus.h
index 8b2fc831c3de..51dfb3a90735 100644
--- a/drivers/net/wireless/cw1200/hwbus.h
+++ b/drivers/net/wireless/cw1200/hwbus.h
@@ -28,6 +28,7 @@ struct hwbus_ops {
28 void (*unlock)(struct hwbus_priv *self); 28 void (*unlock)(struct hwbus_priv *self);
29 size_t (*align_size)(struct hwbus_priv *self, size_t size); 29 size_t (*align_size)(struct hwbus_priv *self, size_t size);
30 int (*power_mgmt)(struct hwbus_priv *self, bool suspend); 30 int (*power_mgmt)(struct hwbus_priv *self, bool suspend);
31 int (*irq_enable)(struct hwbus_priv *self, int enable);
31}; 32};
32 33
33#endif /* CW1200_HWBUS_H */ 34#endif /* CW1200_HWBUS_H */
diff --git a/drivers/net/wireless/cw1200/hwio.c b/drivers/net/wireless/cw1200/hwio.c
index ff230b7aeedd..41bd7615ccaa 100644
--- a/drivers/net/wireless/cw1200/hwio.c
+++ b/drivers/net/wireless/cw1200/hwio.c
@@ -273,6 +273,21 @@ int __cw1200_irq_enable(struct cw1200_common *priv, int enable)
273 u16 val16; 273 u16 val16;
274 int ret; 274 int ret;
275 275
276 /* We need to do this hack because the SPI layer can sleep on I/O
277 and the general path involves I/O to the device in interrupt
278 context.
279
280 However, the initial enable call needs to go to the hardware.
281
282 We don't worry about shutdown because we do a full reset which
283 clears the interrupt enabled bits.
284 */
285 if (priv->hwbus_ops->irq_enable) {
286 ret = priv->hwbus_ops->irq_enable(priv->hwbus_priv, enable);
287 if (ret || enable < 2)
288 return ret;
289 }
290
276 if (HIF_8601_SILICON == priv->hw_type) { 291 if (HIF_8601_SILICON == priv->hw_type) {
277 ret = __cw1200_reg_read_32(priv, ST90TDS_CONFIG_REG_ID, &val32); 292 ret = __cw1200_reg_read_32(priv, ST90TDS_CONFIG_REG_ID, &val32);
278 if (ret < 0) { 293 if (ret < 0) {
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 6b823a1ab789..f394af777cf5 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -11885,7 +11885,6 @@ static int ipw_pci_probe(struct pci_dev *pdev,
11885 pci_release_regions(pdev); 11885 pci_release_regions(pdev);
11886 out_pci_disable_device: 11886 out_pci_disable_device:
11887 pci_disable_device(pdev); 11887 pci_disable_device(pdev);
11888 pci_set_drvdata(pdev, NULL);
11889 out_free_libipw: 11888 out_free_libipw:
11890 free_libipw(priv->net_dev, 0); 11889 free_libipw(priv->net_dev, 0);
11891 out: 11890 out:
@@ -11966,7 +11965,6 @@ static void ipw_pci_remove(struct pci_dev *pdev)
11966 iounmap(priv->hw_base); 11965 iounmap(priv->hw_base);
11967 pci_release_regions(pdev); 11966 pci_release_regions(pdev);
11968 pci_disable_device(pdev); 11967 pci_disable_device(pdev);
11969 pci_set_drvdata(pdev, NULL);
11970 /* wiphy_unregister needs to be here, before free_libipw */ 11968 /* wiphy_unregister needs to be here, before free_libipw */
11971 wiphy_unregister(priv->ieee->wdev.wiphy); 11969 wiphy_unregister(priv->ieee->wdev.wiphy);
11972 kfree(priv->ieee->a_band.channels); 11970 kfree(priv->ieee->a_band.channels);
diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index 9581d07a4242..dea3b50d68b9 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -3811,7 +3811,6 @@ out_iounmap:
3811out_pci_release_regions: 3811out_pci_release_regions:
3812 pci_release_regions(pdev); 3812 pci_release_regions(pdev);
3813out_pci_disable_device: 3813out_pci_disable_device:
3814 pci_set_drvdata(pdev, NULL);
3815 pci_disable_device(pdev); 3814 pci_disable_device(pdev);
3816out_ieee80211_free_hw: 3815out_ieee80211_free_hw:
3817 ieee80211_free_hw(il->hw); 3816 ieee80211_free_hw(il->hw);
@@ -3888,7 +3887,6 @@ il3945_pci_remove(struct pci_dev *pdev)
3888 iounmap(il->hw_base); 3887 iounmap(il->hw_base);
3889 pci_release_regions(pdev); 3888 pci_release_regions(pdev);
3890 pci_disable_device(pdev); 3889 pci_disable_device(pdev);
3891 pci_set_drvdata(pdev, NULL);
3892 3890
3893 il_free_channel_map(il); 3891 il_free_channel_map(il);
3894 il_free_geos(il); 3892 il_free_geos(il);
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 5ab50a5b48b1..3982ab76f375 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -6706,7 +6706,6 @@ out_free_eeprom:
6706out_iounmap: 6706out_iounmap:
6707 iounmap(il->hw_base); 6707 iounmap(il->hw_base);
6708out_pci_release_regions: 6708out_pci_release_regions:
6709 pci_set_drvdata(pdev, NULL);
6710 pci_release_regions(pdev); 6709 pci_release_regions(pdev);
6711out_pci_disable_device: 6710out_pci_disable_device:
6712 pci_disable_device(pdev); 6711 pci_disable_device(pdev);
@@ -6787,7 +6786,6 @@ il4965_pci_remove(struct pci_dev *pdev)
6787 iounmap(il->hw_base); 6786 iounmap(il->hw_base);
6788 pci_release_regions(pdev); 6787 pci_release_regions(pdev);
6789 pci_disable_device(pdev); 6788 pci_disable_device(pdev);
6790 pci_set_drvdata(pdev, NULL);
6791 6789
6792 il4965_uninit_drv(il); 6790 il4965_uninit_drv(il);
6793 6791
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index e66c7e378a3e..6392f67dc1af 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -1404,6 +1404,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
1404 spin_lock_init(&trans_pcie->reg_lock); 1404 spin_lock_init(&trans_pcie->reg_lock);
1405 init_waitqueue_head(&trans_pcie->ucode_write_waitq); 1405 init_waitqueue_head(&trans_pcie->ucode_write_waitq);
1406 1406
1407 err = pci_enable_device(pdev);
1408 if (err)
1409 goto out_no_pci;
1410
1407 if (!cfg->base_params->pcie_l1_allowed) { 1411 if (!cfg->base_params->pcie_l1_allowed) {
1408 /* 1412 /*
1409 * W/A - seems to solve weird behavior. We need to remove this 1413 * W/A - seems to solve weird behavior. We need to remove this
@@ -1415,10 +1419,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
1415 PCIE_LINK_STATE_CLKPM); 1419 PCIE_LINK_STATE_CLKPM);
1416 } 1420 }
1417 1421
1418 err = pci_enable_device(pdev);
1419 if (err)
1420 goto out_no_pci;
1421
1422 pci_set_master(pdev); 1422 pci_set_master(pdev);
1423 1423
1424 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); 1424 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index 4bb6574f4073..5d39ec880d84 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -1128,7 +1128,7 @@ static int if_spi_probe(struct spi_device *spi)
1128{ 1128{
1129 struct if_spi_card *card; 1129 struct if_spi_card *card;
1130 struct lbs_private *priv = NULL; 1130 struct lbs_private *priv = NULL;
1131 struct libertas_spi_platform_data *pdata = spi->dev.platform_data; 1131 struct libertas_spi_platform_data *pdata = dev_get_platdata(&spi->dev);
1132 int err = 0; 1132 int err = 0;
1133 1133
1134 lbs_deb_enter(LBS_DEB_SPI); 1134 lbs_deb_enter(LBS_DEB_SPI);
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index 2d761477d15e..fb3fa18390b8 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -1048,7 +1048,7 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
1048 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 1048 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
1049 unsigned long cmd_flags; 1049 unsigned long cmd_flags;
1050 unsigned long scan_pending_q_flags; 1050 unsigned long scan_pending_q_flags;
1051 uint16_t cancel_scan_cmd = false; 1051 bool cancel_scan_cmd = false;
1052 1052
1053 if ((adapter->curr_cmd) && 1053 if ((adapter->curr_cmd) &&
1054 (adapter->curr_cmd->wait_q_enabled)) { 1054 (adapter->curr_cmd->wait_q_enabled)) {
diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c
index 9d7c0e6c4fc7..717fbe2e0e5a 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -621,7 +621,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
621 int ret = 0; 621 int ret = 0;
622 struct ieee_types_assoc_rsp *assoc_rsp; 622 struct ieee_types_assoc_rsp *assoc_rsp;
623 struct mwifiex_bssdescriptor *bss_desc; 623 struct mwifiex_bssdescriptor *bss_desc;
624 u8 enable_data = true; 624 bool enable_data = true;
625 u16 cap_info, status_code; 625 u16 cap_info, status_code;
626 626
627 assoc_rsp = (struct ieee_types_assoc_rsp *) &resp->params; 627 assoc_rsp = (struct ieee_types_assoc_rsp *) &resp->params;
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 52da8ee7599a..33fa9432b241 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -93,7 +93,7 @@ static int mwifiex_pcie_suspend(struct device *dev)
93 struct pci_dev *pdev = to_pci_dev(dev); 93 struct pci_dev *pdev = to_pci_dev(dev);
94 94
95 if (pdev) { 95 if (pdev) {
96 card = (struct pcie_service_card *) pci_get_drvdata(pdev); 96 card = pci_get_drvdata(pdev);
97 if (!card || !card->adapter) { 97 if (!card || !card->adapter) {
98 pr_err("Card or adapter structure is not valid\n"); 98 pr_err("Card or adapter structure is not valid\n");
99 return 0; 99 return 0;
@@ -128,7 +128,7 @@ static int mwifiex_pcie_resume(struct device *dev)
128 struct pci_dev *pdev = to_pci_dev(dev); 128 struct pci_dev *pdev = to_pci_dev(dev);
129 129
130 if (pdev) { 130 if (pdev) {
131 card = (struct pcie_service_card *) pci_get_drvdata(pdev); 131 card = pci_get_drvdata(pdev);
132 if (!card || !card->adapter) { 132 if (!card || !card->adapter) {
133 pr_err("Card or adapter structure is not valid\n"); 133 pr_err("Card or adapter structure is not valid\n");
134 return 0; 134 return 0;
@@ -2037,7 +2037,7 @@ static irqreturn_t mwifiex_pcie_interrupt(int irq, void *context)
2037 goto exit; 2037 goto exit;
2038 } 2038 }
2039 2039
2040 card = (struct pcie_service_card *) pci_get_drvdata(pdev); 2040 card = pci_get_drvdata(pdev);
2041 if (!card || !card->adapter) { 2041 if (!card || !card->adapter) {
2042 pr_debug("info: %s: card=%p adapter=%p\n", __func__, card, 2042 pr_debug("info: %s: card=%p adapter=%p\n", __func__, card,
2043 card ? card->adapter : NULL); 2043 card ? card->adapter : NULL);
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index c0268b597748..7d66018a2e33 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -327,7 +327,7 @@ mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv,
327{ 327{
328 struct mwifiex_adapter *adapter = priv->adapter; 328 struct mwifiex_adapter *adapter = priv->adapter;
329 struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg; 329 struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg;
330 u16 hs_activate = false; 330 bool hs_activate = false;
331 331
332 if (!hscfg_param) 332 if (!hscfg_param)
333 /* New Activate command */ 333 /* New Activate command */
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index 2e8f9cdea54d..8f8fea015cb4 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -708,7 +708,7 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv,
708{ 708{
709 u8 *curr = (u8 *) &resp->params.get_wmm_status; 709 u8 *curr = (u8 *) &resp->params.get_wmm_status;
710 uint16_t resp_len = le16_to_cpu(resp->size), tlv_len; 710 uint16_t resp_len = le16_to_cpu(resp->size), tlv_len;
711 int valid = true; 711 bool valid = true;
712 712
713 struct mwifiex_ie_types_data *tlv_hdr; 713 struct mwifiex_ie_types_data *tlv_hdr;
714 struct mwifiex_ie_types_wmm_queue_status *tlv_wmm_qstatus; 714 struct mwifiex_ie_types_wmm_queue_status *tlv_wmm_qstatus;
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index a3707fd4ef62..b953ad621e0b 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -6093,7 +6093,6 @@ err_iounmap:
6093 if (priv->sram != NULL) 6093 if (priv->sram != NULL)
6094 pci_iounmap(pdev, priv->sram); 6094 pci_iounmap(pdev, priv->sram);
6095 6095
6096 pci_set_drvdata(pdev, NULL);
6097 ieee80211_free_hw(hw); 6096 ieee80211_free_hw(hw);
6098 6097
6099err_free_reg: 6098err_free_reg:
@@ -6147,7 +6146,6 @@ static void mwl8k_remove(struct pci_dev *pdev)
6147unmap: 6146unmap:
6148 pci_iounmap(pdev, priv->regs); 6147 pci_iounmap(pdev, priv->regs);
6149 pci_iounmap(pdev, priv->sram); 6148 pci_iounmap(pdev, priv->sram);
6150 pci_set_drvdata(pdev, NULL);
6151 ieee80211_free_hw(hw); 6149 ieee80211_free_hw(hw);
6152 pci_release_regions(pdev); 6150 pci_release_regions(pdev);
6153 pci_disable_device(pdev); 6151 pci_disable_device(pdev);
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index d73fdf6185a2..ffb2469eb679 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -234,7 +234,6 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
234 free_irq(pdev->irq, priv); 234 free_irq(pdev->irq, priv);
235 235
236 fail_irq: 236 fail_irq:
237 pci_set_drvdata(pdev, NULL);
238 free_orinocodev(priv); 237 free_orinocodev(priv);
239 238
240 fail_alloc: 239 fail_alloc:
@@ -265,7 +264,6 @@ static void orinoco_nortel_remove_one(struct pci_dev *pdev)
265 264
266 orinoco_if_del(priv); 265 orinoco_if_del(priv);
267 free_irq(pdev->irq, priv); 266 free_irq(pdev->irq, priv);
268 pci_set_drvdata(pdev, NULL);
269 free_orinocodev(priv); 267 free_orinocodev(priv);
270 pci_iounmap(pdev, priv->hw.iobase); 268 pci_iounmap(pdev, priv->hw.iobase);
271 pci_iounmap(pdev, card->attr_io); 269 pci_iounmap(pdev, card->attr_io);
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index 677bf14eca84..5ae1191d2532 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -184,7 +184,6 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
184 free_irq(pdev->irq, priv); 184 free_irq(pdev->irq, priv);
185 185
186 fail_irq: 186 fail_irq:
187 pci_set_drvdata(pdev, NULL);
188 free_orinocodev(priv); 187 free_orinocodev(priv);
189 188
190 fail_alloc: 189 fail_alloc:
@@ -205,7 +204,6 @@ static void orinoco_pci_remove_one(struct pci_dev *pdev)
205 204
206 orinoco_if_del(priv); 205 orinoco_if_del(priv);
207 free_irq(pdev->irq, priv); 206 free_irq(pdev->irq, priv);
208 pci_set_drvdata(pdev, NULL);
209 free_orinocodev(priv); 207 free_orinocodev(priv);
210 pci_iounmap(pdev, priv->hw.iobase); 208 pci_iounmap(pdev, priv->hw.iobase);
211 pci_release_regions(pdev); 209 pci_release_regions(pdev);
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index 2559dbd6184b..bbd36d1676ff 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -273,7 +273,6 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
273 free_irq(pdev->irq, priv); 273 free_irq(pdev->irq, priv);
274 274
275 fail_irq: 275 fail_irq:
276 pci_set_drvdata(pdev, NULL);
277 free_orinocodev(priv); 276 free_orinocodev(priv);
278 277
279 fail_alloc: 278 fail_alloc:
@@ -301,7 +300,6 @@ static void orinoco_plx_remove_one(struct pci_dev *pdev)
301 300
302 orinoco_if_del(priv); 301 orinoco_if_del(priv);
303 free_irq(pdev->irq, priv); 302 free_irq(pdev->irq, priv);
304 pci_set_drvdata(pdev, NULL);
305 free_orinocodev(priv); 303 free_orinocodev(priv);
306 pci_iounmap(pdev, priv->hw.iobase); 304 pci_iounmap(pdev, priv->hw.iobase);
307 pci_iounmap(pdev, card->attr_io); 305 pci_iounmap(pdev, card->attr_io);
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index 42afeeea2c40..04b08de5fd5d 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -170,7 +170,6 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
170 free_irq(pdev->irq, priv); 170 free_irq(pdev->irq, priv);
171 171
172 fail_irq: 172 fail_irq:
173 pci_set_drvdata(pdev, NULL);
174 free_orinocodev(priv); 173 free_orinocodev(priv);
175 174
176 fail_alloc: 175 fail_alloc:
@@ -195,7 +194,6 @@ static void orinoco_tmd_remove_one(struct pci_dev *pdev)
195 194
196 orinoco_if_del(priv); 195 orinoco_if_del(priv);
197 free_irq(pdev->irq, priv); 196 free_irq(pdev->irq, priv);
198 pci_set_drvdata(pdev, NULL);
199 free_orinocodev(priv); 197 free_orinocodev(priv);
200 pci_iounmap(pdev, priv->hw.iobase); 198 pci_iounmap(pdev, priv->hw.iobase);
201 pci_iounmap(pdev, card->bridge_io); 199 pci_iounmap(pdev, card->bridge_io);
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 57e3af8ebb4b..f9a07b0d83ac 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -631,7 +631,6 @@ static int p54p_probe(struct pci_dev *pdev,
631 iounmap(priv->map); 631 iounmap(priv->map);
632 632
633 err_free_dev: 633 err_free_dev:
634 pci_set_drvdata(pdev, NULL);
635 p54_free_common(dev); 634 p54_free_common(dev);
636 635
637 err_free_reg: 636 err_free_reg:
diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c
index 7fc46f26cf2b..de15171e2cd8 100644
--- a/drivers/net/wireless/p54/p54spi.c
+++ b/drivers/net/wireless/p54/p54spi.c
@@ -636,7 +636,7 @@ static int p54spi_probe(struct spi_device *spi)
636 gpio_direction_input(p54spi_gpio_irq); 636 gpio_direction_input(p54spi_gpio_irq);
637 637
638 ret = request_irq(gpio_to_irq(p54spi_gpio_irq), 638 ret = request_irq(gpio_to_irq(p54spi_gpio_irq),
639 p54spi_interrupt, IRQF_DISABLED, "p54spi", 639 p54spi_interrupt, 0, "p54spi",
640 priv->spi); 640 priv->spi);
641 if (ret < 0) { 641 if (ret < 0) {
642 dev_err(&priv->spi->dev, "request_irq() failed"); 642 dev_err(&priv->spi->dev, "request_irq() failed");
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 68dbbb9c6d12..a18b0051a745 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -219,6 +219,7 @@ config RT2X00_LIB_USB
219 219
220config RT2X00_LIB 220config RT2X00_LIB
221 tristate 221 tristate
222 select AVERAGE
222 223
223config RT2X00_LIB_FIRMWARE 224config RT2X00_LIB_FIRMWARE
224 boolean 225 boolean
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index fa33b5edf931..e3eb95292a7f 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -52,6 +52,7 @@
52 * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392) 52 * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392)
53 * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662) 53 * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662)
54 * RF5592 2.4G/5G 2T2R 54 * RF5592 2.4G/5G 2T2R
55 * RF3070 2.4G 1T1R
55 * RF5360 2.4G 1T1R 56 * RF5360 2.4G 1T1R
56 * RF5370 2.4G 1T1R 57 * RF5370 2.4G 1T1R
57 * RF5390 2.4G 1T1R 58 * RF5390 2.4G 1T1R
@@ -70,6 +71,7 @@
70#define RF3322 0x000c 71#define RF3322 0x000c
71#define RF3053 0x000d 72#define RF3053 0x000d
72#define RF5592 0x000f 73#define RF5592 0x000f
74#define RF3070 0x3070
73#define RF3290 0x3290 75#define RF3290 0x3290
74#define RF5360 0x5360 76#define RF5360 0x5360
75#define RF5370 0x5370 77#define RF5370 0x5370
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 95e6e61c3de0..a114cab413e9 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -278,12 +278,9 @@ static const unsigned int rt2800_eeprom_map_ext[EEPROM_WORD_COUNT] = {
278 [EEPROM_LNA] = 0x0026, 278 [EEPROM_LNA] = 0x0026,
279 [EEPROM_EXT_LNA2] = 0x0027, 279 [EEPROM_EXT_LNA2] = 0x0027,
280 [EEPROM_RSSI_BG] = 0x0028, 280 [EEPROM_RSSI_BG] = 0x0028,
281 [EEPROM_TXPOWER_DELTA] = 0x0028, /* Overlaps with RSSI_BG */
282 [EEPROM_RSSI_BG2] = 0x0029, 281 [EEPROM_RSSI_BG2] = 0x0029,
283 [EEPROM_TXMIXER_GAIN_BG] = 0x0029, /* Overlaps with RSSI_BG2 */
284 [EEPROM_RSSI_A] = 0x002a, 282 [EEPROM_RSSI_A] = 0x002a,
285 [EEPROM_RSSI_A2] = 0x002b, 283 [EEPROM_RSSI_A2] = 0x002b,
286 [EEPROM_TXMIXER_GAIN_A] = 0x002b, /* Overlaps with RSSI_A2 */
287 [EEPROM_TXPOWER_BG1] = 0x0030, 284 [EEPROM_TXPOWER_BG1] = 0x0030,
288 [EEPROM_TXPOWER_BG2] = 0x0037, 285 [EEPROM_TXPOWER_BG2] = 0x0037,
289 [EEPROM_EXT_TXPOWER_BG3] = 0x003e, 286 [EEPROM_EXT_TXPOWER_BG3] = 0x003e,
@@ -2029,13 +2026,6 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev,
2029 rt2x00dev->default_ant.tx_chain_num <= 2); 2026 rt2x00dev->default_ant.tx_chain_num <= 2);
2030 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); 2027 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
2031 2028
2032 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
2033 rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
2034 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
2035 msleep(1);
2036 rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0);
2037 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
2038
2039 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr); 2029 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
2040 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); 2030 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset);
2041 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); 2031 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr);
@@ -3152,6 +3142,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
3152 case RF3322: 3142 case RF3322:
3153 rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info); 3143 rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info);
3154 break; 3144 break;
3145 case RF3070:
3155 case RF5360: 3146 case RF5360:
3156 case RF5370: 3147 case RF5370:
3157 case RF5372: 3148 case RF5372:
@@ -3166,7 +3157,8 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
3166 rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info); 3157 rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info);
3167 } 3158 }
3168 3159
3169 if (rt2x00_rf(rt2x00dev, RF3290) || 3160 if (rt2x00_rf(rt2x00dev, RF3070) ||
3161 rt2x00_rf(rt2x00dev, RF3290) ||
3170 rt2x00_rf(rt2x00dev, RF3322) || 3162 rt2x00_rf(rt2x00dev, RF3322) ||
3171 rt2x00_rf(rt2x00dev, RF5360) || 3163 rt2x00_rf(rt2x00dev, RF5360) ||
3172 rt2x00_rf(rt2x00dev, RF5370) || 3164 rt2x00_rf(rt2x00dev, RF5370) ||
@@ -3311,33 +3303,50 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
3311 3303
3312 rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); 3304 rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
3313 3305
3314 if (rt2x00_rt(rt2x00dev, RT3572)) 3306 if (rt2x00_rt(rt2x00dev, RT3572)) {
3315 rt2800_rfcsr_write(rt2x00dev, 8, 0x80); 3307 rt2800_rfcsr_write(rt2x00dev, 8, 0x80);
3316 3308
3309 /* AGC init */
3310 if (rf->channel <= 14)
3311 reg = 0x1c + (2 * rt2x00dev->lna_gain);
3312 else
3313 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3);
3314
3315 rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
3316 }
3317
3317 if (rt2x00_rt(rt2x00dev, RT3593)) { 3318 if (rt2x00_rt(rt2x00dev, RT3593)) {
3318 if (rt2x00_is_usb(rt2x00dev)) { 3319 rt2800_register_read(rt2x00dev, GPIO_CTRL, &reg);
3319 rt2800_register_read(rt2x00dev, GPIO_CTRL, &reg);
3320 3320
3321 /* Band selection. GPIO #8 controls all paths */ 3321 /* Band selection */
3322 if (rt2x00_is_usb(rt2x00dev) ||
3323 rt2x00_is_pcie(rt2x00dev)) {
3324 /* GPIO #8 controls all paths */
3322 rt2x00_set_field32(&reg, GPIO_CTRL_DIR8, 0); 3325 rt2x00_set_field32(&reg, GPIO_CTRL_DIR8, 0);
3323 if (rf->channel <= 14) 3326 if (rf->channel <= 14)
3324 rt2x00_set_field32(&reg, GPIO_CTRL_VAL8, 1); 3327 rt2x00_set_field32(&reg, GPIO_CTRL_VAL8, 1);
3325 else 3328 else
3326 rt2x00_set_field32(&reg, GPIO_CTRL_VAL8, 0); 3329 rt2x00_set_field32(&reg, GPIO_CTRL_VAL8, 0);
3330 }
3327 3331
3332 /* LNA PE control. */
3333 if (rt2x00_is_usb(rt2x00dev)) {
3334 /* GPIO #4 controls PE0 and PE1,
3335 * GPIO #7 controls PE2
3336 */
3328 rt2x00_set_field32(&reg, GPIO_CTRL_DIR4, 0); 3337 rt2x00_set_field32(&reg, GPIO_CTRL_DIR4, 0);
3329 rt2x00_set_field32(&reg, GPIO_CTRL_DIR7, 0); 3338 rt2x00_set_field32(&reg, GPIO_CTRL_DIR7, 0);
3330 3339
3331 /* LNA PE control.
3332 * GPIO #4 controls PE0 and PE1,
3333 * GPIO #7 controls PE2
3334 */
3335 rt2x00_set_field32(&reg, GPIO_CTRL_VAL4, 1); 3340 rt2x00_set_field32(&reg, GPIO_CTRL_VAL4, 1);
3336 rt2x00_set_field32(&reg, GPIO_CTRL_VAL7, 1); 3341 rt2x00_set_field32(&reg, GPIO_CTRL_VAL7, 1);
3337 3342 } else if (rt2x00_is_pcie(rt2x00dev)) {
3338 rt2800_register_write(rt2x00dev, GPIO_CTRL, reg); 3343 /* GPIO #4 controls PE0, PE1 and PE2 */
3344 rt2x00_set_field32(&reg, GPIO_CTRL_DIR4, 0);
3345 rt2x00_set_field32(&reg, GPIO_CTRL_VAL4, 1);
3339 } 3346 }
3340 3347
3348 rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
3349
3341 /* AGC init */ 3350 /* AGC init */
3342 if (rf->channel <= 14) 3351 if (rf->channel <= 14)
3343 reg = 0x1c + 2 * rt2x00dev->lna_gain; 3352 reg = 0x1c + 2 * rt2x00dev->lna_gain;
@@ -4264,6 +4273,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev)
4264 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); 4273 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
4265 break; 4274 break;
4266 case RF3053: 4275 case RF3053:
4276 case RF3070:
4267 case RF3290: 4277 case RF3290:
4268 case RF5360: 4278 case RF5360:
4269 case RF5370: 4279 case RF5370:
@@ -4405,6 +4415,7 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
4405 rt2x00_rt(rt2x00dev, RT3290) || 4415 rt2x00_rt(rt2x00dev, RT3290) ||
4406 rt2x00_rt(rt2x00dev, RT3390) || 4416 rt2x00_rt(rt2x00dev, RT3390) ||
4407 rt2x00_rt(rt2x00dev, RT3572) || 4417 rt2x00_rt(rt2x00dev, RT3572) ||
4418 rt2x00_rt(rt2x00dev, RT3593) ||
4408 rt2x00_rt(rt2x00dev, RT5390) || 4419 rt2x00_rt(rt2x00dev, RT5390) ||
4409 rt2x00_rt(rt2x00dev, RT5392) || 4420 rt2x00_rt(rt2x00dev, RT5392) ||
4410 rt2x00_rt(rt2x00dev, RT5592)) 4421 rt2x00_rt(rt2x00dev, RT5592))
@@ -4412,8 +4423,8 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
4412 else 4423 else
4413 vgc = 0x2e + rt2x00dev->lna_gain; 4424 vgc = 0x2e + rt2x00dev->lna_gain;
4414 } else { /* 5GHZ band */ 4425 } else { /* 5GHZ band */
4415 if (rt2x00_rt(rt2x00dev, RT3572)) 4426 if (rt2x00_rt(rt2x00dev, RT3593))
4416 vgc = 0x22 + (rt2x00dev->lna_gain * 5) / 3; 4427 vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3;
4417 else if (rt2x00_rt(rt2x00dev, RT5592)) 4428 else if (rt2x00_rt(rt2x00dev, RT5592))
4418 vgc = 0x24 + (2 * rt2x00dev->lna_gain); 4429 vgc = 0x24 + (2 * rt2x00dev->lna_gain);
4419 else { 4430 else {
@@ -4431,11 +4442,17 @@ static inline void rt2800_set_vgc(struct rt2x00_dev *rt2x00dev,
4431 struct link_qual *qual, u8 vgc_level) 4442 struct link_qual *qual, u8 vgc_level)
4432{ 4443{
4433 if (qual->vgc_level != vgc_level) { 4444 if (qual->vgc_level != vgc_level) {
4434 if (rt2x00_rt(rt2x00dev, RT5592)) { 4445 if (rt2x00_rt(rt2x00dev, RT3572) ||
4446 rt2x00_rt(rt2x00dev, RT3593)) {
4447 rt2800_bbp_write_with_rx_chain(rt2x00dev, 66,
4448 vgc_level);
4449 } else if (rt2x00_rt(rt2x00dev, RT5592)) {
4435 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a); 4450 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a);
4436 rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, vgc_level); 4451 rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, vgc_level);
4437 } else 4452 } else {
4438 rt2800_bbp_write(rt2x00dev, 66, vgc_level); 4453 rt2800_bbp_write(rt2x00dev, 66, vgc_level);
4454 }
4455
4439 qual->vgc_level = vgc_level; 4456 qual->vgc_level = vgc_level;
4440 qual->vgc_level_reg = vgc_level; 4457 qual->vgc_level_reg = vgc_level;
4441 } 4458 }
@@ -4454,17 +4471,35 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
4454 4471
4455 if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) 4472 if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C))
4456 return; 4473 return;
4457 /* 4474
4458 * When RSSI is better then -80 increase VGC level with 0x10, except 4475 /* When RSSI is better than a certain threshold, increase VGC
4459 * for rt5592 chip. 4476 * with a chip specific value in order to improve the balance
4477 * between sensibility and noise isolation.
4460 */ 4478 */
4461 4479
4462 vgc = rt2800_get_default_vgc(rt2x00dev); 4480 vgc = rt2800_get_default_vgc(rt2x00dev);
4463 4481
4464 if (rt2x00_rt(rt2x00dev, RT5592) && qual->rssi > -65) 4482 switch (rt2x00dev->chip.rt) {
4465 vgc += 0x20; 4483 case RT3572:
4466 else if (qual->rssi > -80) 4484 case RT3593:
4467 vgc += 0x10; 4485 if (qual->rssi > -65) {
4486 if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ)
4487 vgc += 0x20;
4488 else
4489 vgc += 0x10;
4490 }
4491 break;
4492
4493 case RT5592:
4494 if (qual->rssi > -65)
4495 vgc += 0x20;
4496 break;
4497
4498 default:
4499 if (qual->rssi > -80)
4500 vgc += 0x10;
4501 break;
4502 }
4468 4503
4469 rt2800_set_vgc(rt2x00dev, qual, vgc); 4504 rt2800_set_vgc(rt2x00dev, qual, vgc);
4470} 4505}
@@ -5985,7 +6020,7 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
5985 rt2800_rfcsr_write(rt2x00dev, 20, 0xba); 6020 rt2800_rfcsr_write(rt2x00dev, 20, 0xba);
5986 rt2800_rfcsr_write(rt2x00dev, 21, 0xdb); 6021 rt2800_rfcsr_write(rt2x00dev, 21, 0xdb);
5987 rt2800_rfcsr_write(rt2x00dev, 24, 0x16); 6022 rt2800_rfcsr_write(rt2x00dev, 24, 0x16);
5988 rt2800_rfcsr_write(rt2x00dev, 25, 0x01); 6023 rt2800_rfcsr_write(rt2x00dev, 25, 0x03);
5989 rt2800_rfcsr_write(rt2x00dev, 29, 0x1f); 6024 rt2800_rfcsr_write(rt2x00dev, 29, 0x1f);
5990 6025
5991 if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) { 6026 if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) {
@@ -6653,27 +6688,37 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev)
6653 u16 word; 6688 u16 word;
6654 6689
6655 /* 6690 /*
6656 * Initialize all registers. 6691 * Initialize MAC registers.
6657 */ 6692 */
6658 if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) || 6693 if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) ||
6659 rt2800_init_registers(rt2x00dev))) 6694 rt2800_init_registers(rt2x00dev)))
6660 return -EIO; 6695 return -EIO;
6661 6696
6662 /* 6697 /*
6663 * Send signal to firmware during boot time. 6698 * Wait BBP/RF to wake up.
6699 */
6700 if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev)))
6701 return -EIO;
6702
6703 /*
6704 * Send signal during boot time to initialize firmware.
6664 */ 6705 */
6665 rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); 6706 rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
6666 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); 6707 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
6667 if (rt2x00_is_usb(rt2x00dev)) { 6708 if (rt2x00_is_usb(rt2x00dev))
6668 rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0); 6709 rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0);
6669 rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0); 6710 rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
6670 }
6671 msleep(1); 6711 msleep(1);
6672 6712
6673 if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) || 6713 /*
6674 rt2800_wait_bbp_ready(rt2x00dev))) 6714 * Make sure BBP is up and running.
6715 */
6716 if (unlikely(rt2800_wait_bbp_ready(rt2x00dev)))
6675 return -EIO; 6717 return -EIO;
6676 6718
6719 /*
6720 * Initialize BBP/RF registers.
6721 */
6677 rt2800_init_bbp(rt2x00dev); 6722 rt2800_init_bbp(rt2x00dev);
6678 rt2800_init_rfcsr(rt2x00dev); 6723 rt2800_init_rfcsr(rt2x00dev);
6679 6724
@@ -7020,6 +7065,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
7020 case RF3022: 7065 case RF3022:
7021 case RF3052: 7066 case RF3052:
7022 case RF3053: 7067 case RF3053:
7068 case RF3070:
7023 case RF3290: 7069 case RF3290:
7024 case RF3320: 7070 case RF3320:
7025 case RF3322: 7071 case RF3322:
@@ -7542,6 +7588,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
7542 rt2x00_rf(rt2x00dev, RF2020) || 7588 rt2x00_rf(rt2x00dev, RF2020) ||
7543 rt2x00_rf(rt2x00dev, RF3021) || 7589 rt2x00_rf(rt2x00dev, RF3021) ||
7544 rt2x00_rf(rt2x00dev, RF3022) || 7590 rt2x00_rf(rt2x00dev, RF3022) ||
7591 rt2x00_rf(rt2x00dev, RF3070) ||
7545 rt2x00_rf(rt2x00dev, RF3290) || 7592 rt2x00_rf(rt2x00dev, RF3290) ||
7546 rt2x00_rf(rt2x00dev, RF3320) || 7593 rt2x00_rf(rt2x00dev, RF3320) ||
7547 rt2x00_rf(rt2x00dev, RF3322) || 7594 rt2x00_rf(rt2x00dev, RF3322) ||
@@ -7670,6 +7717,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
7670 case RF3320: 7717 case RF3320:
7671 case RF3052: 7718 case RF3052:
7672 case RF3053: 7719 case RF3053:
7720 case RF3070:
7673 case RF3290: 7721 case RF3290:
7674 case RF5360: 7722 case RF5360:
7675 case RF5370: 7723 case RF5370:
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 96961b9a395c..96677ce55da4 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1176,6 +1176,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
1176 /* Linksys */ 1176 /* Linksys */
1177 { USB_DEVICE(0x13b1, 0x002f) }, 1177 { USB_DEVICE(0x13b1, 0x002f) },
1178 { USB_DEVICE(0x1737, 0x0079) }, 1178 { USB_DEVICE(0x1737, 0x0079) },
1179 /* Logitec */
1180 { USB_DEVICE(0x0789, 0x0170) },
1179 /* Ralink */ 1181 /* Ralink */
1180 { USB_DEVICE(0x148f, 0x3572) }, 1182 { USB_DEVICE(0x148f, 0x3572) },
1181 /* Sitecom */ 1183 /* Sitecom */
@@ -1199,6 +1201,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
1199 { USB_DEVICE(0x050d, 0x1103) }, 1201 { USB_DEVICE(0x050d, 0x1103) },
1200 /* Cameo */ 1202 /* Cameo */
1201 { USB_DEVICE(0x148f, 0xf301) }, 1203 { USB_DEVICE(0x148f, 0xf301) },
1204 /* D-Link */
1205 { USB_DEVICE(0x2001, 0x3c1f) },
1202 /* Edimax */ 1206 /* Edimax */
1203 { USB_DEVICE(0x7392, 0x7733) }, 1207 { USB_DEVICE(0x7392, 0x7733) },
1204 /* Hawking */ 1208 /* Hawking */
@@ -1212,6 +1216,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1212 { USB_DEVICE(0x0789, 0x016b) }, 1216 { USB_DEVICE(0x0789, 0x016b) },
1213 /* NETGEAR */ 1217 /* NETGEAR */
1214 { USB_DEVICE(0x0846, 0x9012) }, 1218 { USB_DEVICE(0x0846, 0x9012) },
1219 { USB_DEVICE(0x0846, 0x9013) },
1215 { USB_DEVICE(0x0846, 0x9019) }, 1220 { USB_DEVICE(0x0846, 0x9019) },
1216 /* Planex */ 1221 /* Planex */
1217 { USB_DEVICE(0x2019, 0xed19) }, 1222 { USB_DEVICE(0x2019, 0xed19) },
@@ -1220,6 +1225,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1220 /* Sitecom */ 1225 /* Sitecom */
1221 { USB_DEVICE(0x0df6, 0x0067) }, 1226 { USB_DEVICE(0x0df6, 0x0067) },
1222 { USB_DEVICE(0x0df6, 0x006a) }, 1227 { USB_DEVICE(0x0df6, 0x006a) },
1228 { USB_DEVICE(0x0df6, 0x006e) },
1223 /* ZyXEL */ 1229 /* ZyXEL */
1224 { USB_DEVICE(0x0586, 0x3421) }, 1230 { USB_DEVICE(0x0586, 0x3421) },
1225#endif 1231#endif
@@ -1236,6 +1242,9 @@ static struct usb_device_id rt2800usb_device_table[] = {
1236 { USB_DEVICE(0x2001, 0x3c1c) }, 1242 { USB_DEVICE(0x2001, 0x3c1c) },
1237 { USB_DEVICE(0x2001, 0x3c1d) }, 1243 { USB_DEVICE(0x2001, 0x3c1d) },
1238 { USB_DEVICE(0x2001, 0x3c1e) }, 1244 { USB_DEVICE(0x2001, 0x3c1e) },
1245 { USB_DEVICE(0x2001, 0x3c20) },
1246 { USB_DEVICE(0x2001, 0x3c22) },
1247 { USB_DEVICE(0x2001, 0x3c23) },
1239 /* LG innotek */ 1248 /* LG innotek */
1240 { USB_DEVICE(0x043e, 0x7a22) }, 1249 { USB_DEVICE(0x043e, 0x7a22) },
1241 { USB_DEVICE(0x043e, 0x7a42) }, 1250 { USB_DEVICE(0x043e, 0x7a42) },
@@ -1258,12 +1267,17 @@ static struct usb_device_id rt2800usb_device_table[] = {
1258 { USB_DEVICE(0x043e, 0x7a32) }, 1267 { USB_DEVICE(0x043e, 0x7a32) },
1259 /* AVM GmbH */ 1268 /* AVM GmbH */
1260 { USB_DEVICE(0x057c, 0x8501) }, 1269 { USB_DEVICE(0x057c, 0x8501) },
1261 /* D-Link DWA-160-B2 */ 1270 /* Buffalo */
1271 { USB_DEVICE(0x0411, 0x0241) },
1272 /* D-Link */
1262 { USB_DEVICE(0x2001, 0x3c1a) }, 1273 { USB_DEVICE(0x2001, 0x3c1a) },
1274 { USB_DEVICE(0x2001, 0x3c21) },
1263 /* Proware */ 1275 /* Proware */
1264 { USB_DEVICE(0x043e, 0x7a13) }, 1276 { USB_DEVICE(0x043e, 0x7a13) },
1265 /* Ralink */ 1277 /* Ralink */
1266 { USB_DEVICE(0x148f, 0x5572) }, 1278 { USB_DEVICE(0x148f, 0x5572) },
1279 /* TRENDnet */
1280 { USB_DEVICE(0x20f4, 0x724a) },
1267#endif 1281#endif
1268#ifdef CONFIG_RT2800USB_UNKNOWN 1282#ifdef CONFIG_RT2800USB_UNKNOWN
1269 /* 1283 /*
@@ -1333,6 +1347,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1333 { USB_DEVICE(0x1d4d, 0x0010) }, 1347 { USB_DEVICE(0x1d4d, 0x0010) },
1334 /* Planex */ 1348 /* Planex */
1335 { USB_DEVICE(0x2019, 0xab24) }, 1349 { USB_DEVICE(0x2019, 0xab24) },
1350 { USB_DEVICE(0x2019, 0xab29) },
1336 /* Qcom */ 1351 /* Qcom */
1337 { USB_DEVICE(0x18e8, 0x6259) }, 1352 { USB_DEVICE(0x18e8, 0x6259) },
1338 /* RadioShack */ 1353 /* RadioShack */
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index fe4c572db52c..30ed92a6121e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -39,6 +39,7 @@
39#include <linux/input-polldev.h> 39#include <linux/input-polldev.h>
40#include <linux/kfifo.h> 40#include <linux/kfifo.h>
41#include <linux/hrtimer.h> 41#include <linux/hrtimer.h>
42#include <linux/average.h>
42 43
43#include <net/mac80211.h> 44#include <net/mac80211.h>
44 45
@@ -138,17 +139,6 @@
138#define SHORT_EIFS ( SIFS + SHORT_DIFS + \ 139#define SHORT_EIFS ( SIFS + SHORT_DIFS + \
139 GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) ) 140 GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) )
140 141
141/*
142 * Structure for average calculation
143 * The avg field contains the actual average value,
144 * but avg_weight is internally used during calculations
145 * to prevent rounding errors.
146 */
147struct avg_val {
148 int avg;
149 int avg_weight;
150};
151
152enum rt2x00_chip_intf { 142enum rt2x00_chip_intf {
153 RT2X00_CHIP_INTF_PCI, 143 RT2X00_CHIP_INTF_PCI,
154 RT2X00_CHIP_INTF_PCIE, 144 RT2X00_CHIP_INTF_PCIE,
@@ -297,7 +287,7 @@ struct link_ant {
297 * Similar to the avg_rssi in the link_qual structure 287 * Similar to the avg_rssi in the link_qual structure
298 * this value is updated by using the walking average. 288 * this value is updated by using the walking average.
299 */ 289 */
300 struct avg_val rssi_ant; 290 struct ewma rssi_ant;
301}; 291};
302 292
303/* 293/*
@@ -326,7 +316,7 @@ struct link {
326 /* 316 /*
327 * Currently active average RSSI value 317 * Currently active average RSSI value
328 */ 318 */
329 struct avg_val avg_rssi; 319 struct ewma avg_rssi;
330 320
331 /* 321 /*
332 * Work structure for scheduling periodic link tuning. 322 * Work structure for scheduling periodic link tuning.
diff --git a/drivers/net/wireless/rt2x00/rt2x00link.c b/drivers/net/wireless/rt2x00/rt2x00link.c
index 8368aab86f28..a0e3c021c128 100644
--- a/drivers/net/wireless/rt2x00/rt2x00link.c
+++ b/drivers/net/wireless/rt2x00/rt2x00link.c
@@ -35,50 +35,28 @@
35 */ 35 */
36#define DEFAULT_RSSI -128 36#define DEFAULT_RSSI -128
37 37
38/* 38/* Constants for EWMA calculations. */
39 * Helper struct and macro to work with moving/walking averages. 39#define RT2X00_EWMA_FACTOR 1024
40 * When adding a value to the average value the following calculation 40#define RT2X00_EWMA_WEIGHT 8
41 * is needed: 41
42 * 42static inline int rt2x00link_get_avg_rssi(struct ewma *ewma)
43 * avg_rssi = ((avg_rssi * 7) + rssi) / 8; 43{
44 * 44 unsigned long avg;
45 * The advantage of this approach is that we only need 1 variable 45
46 * to store the average in (No need for a count and a total). 46 avg = ewma_read(ewma);
47 * But more importantly, normal average values will over time 47 if (avg)
48 * move less and less towards newly added values this results 48 return -avg;
49 * that with link tuning, the device can have a very good RSSI 49
50 * for a few minutes but when the device is moved away from the AP 50 return DEFAULT_RSSI;
51 * the average will not decrease fast enough to compensate. 51}
52 * The walking average compensates this and will move towards
53 * the new values correctly allowing a effective link tuning,
54 * the speed of the average moving towards other values depends
55 * on the value for the number of samples. The higher the number
56 * of samples, the slower the average will move.
57 * We use two variables to keep track of the average value to
58 * compensate for the rounding errors. This can be a significant
59 * error (>5dBm) if the factor is too low.
60 */
61#define AVG_SAMPLES 8
62#define AVG_FACTOR 1000
63#define MOVING_AVERAGE(__avg, __val) \
64({ \
65 struct avg_val __new; \
66 __new.avg_weight = \
67 (__avg).avg_weight ? \
68 ((((__avg).avg_weight * ((AVG_SAMPLES) - 1)) + \
69 ((__val) * (AVG_FACTOR))) / \
70 (AVG_SAMPLES)) : \
71 ((__val) * (AVG_FACTOR)); \
72 __new.avg = __new.avg_weight / (AVG_FACTOR); \
73 __new; \
74})
75 52
76static int rt2x00link_antenna_get_link_rssi(struct rt2x00_dev *rt2x00dev) 53static int rt2x00link_antenna_get_link_rssi(struct rt2x00_dev *rt2x00dev)
77{ 54{
78 struct link_ant *ant = &rt2x00dev->link.ant; 55 struct link_ant *ant = &rt2x00dev->link.ant;
79 56
80 if (ant->rssi_ant.avg && rt2x00dev->link.qual.rx_success) 57 if (rt2x00dev->link.qual.rx_success)
81 return ant->rssi_ant.avg; 58 return rt2x00link_get_avg_rssi(&ant->rssi_ant);
59
82 return DEFAULT_RSSI; 60 return DEFAULT_RSSI;
83} 61}
84 62
@@ -100,8 +78,8 @@ static void rt2x00link_antenna_update_rssi_history(struct rt2x00_dev *rt2x00dev,
100 78
101static void rt2x00link_antenna_reset(struct rt2x00_dev *rt2x00dev) 79static void rt2x00link_antenna_reset(struct rt2x00_dev *rt2x00dev)
102{ 80{
103 rt2x00dev->link.ant.rssi_ant.avg = 0; 81 ewma_init(&rt2x00dev->link.ant.rssi_ant, RT2X00_EWMA_FACTOR,
104 rt2x00dev->link.ant.rssi_ant.avg_weight = 0; 82 RT2X00_EWMA_WEIGHT);
105} 83}
106 84
107static void rt2x00lib_antenna_diversity_sample(struct rt2x00_dev *rt2x00dev) 85static void rt2x00lib_antenna_diversity_sample(struct rt2x00_dev *rt2x00dev)
@@ -249,12 +227,12 @@ void rt2x00link_update_stats(struct rt2x00_dev *rt2x00dev,
249 /* 227 /*
250 * Update global RSSI 228 * Update global RSSI
251 */ 229 */
252 link->avg_rssi = MOVING_AVERAGE(link->avg_rssi, rxdesc->rssi); 230 ewma_add(&link->avg_rssi, -rxdesc->rssi);
253 231
254 /* 232 /*
255 * Update antenna RSSI 233 * Update antenna RSSI
256 */ 234 */
257 ant->rssi_ant = MOVING_AVERAGE(ant->rssi_ant, rxdesc->rssi); 235 ewma_add(&ant->rssi_ant, -rxdesc->rssi);
258} 236}
259 237
260void rt2x00link_start_tuner(struct rt2x00_dev *rt2x00dev) 238void rt2x00link_start_tuner(struct rt2x00_dev *rt2x00dev)
@@ -309,6 +287,8 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)
309 */ 287 */
310 rt2x00dev->link.count = 0; 288 rt2x00dev->link.count = 0;
311 memset(qual, 0, sizeof(*qual)); 289 memset(qual, 0, sizeof(*qual));
290 ewma_init(&rt2x00dev->link.avg_rssi, RT2X00_EWMA_FACTOR,
291 RT2X00_EWMA_WEIGHT);
312 292
313 /* 293 /*
314 * Restore the VGC level as stored in the registers, 294 * Restore the VGC level as stored in the registers,
@@ -363,10 +343,10 @@ static void rt2x00link_tuner(struct work_struct *work)
363 * collect the RSSI data we could use this. Otherwise we 343 * collect the RSSI data we could use this. Otherwise we
364 * must fallback to the default RSSI value. 344 * must fallback to the default RSSI value.
365 */ 345 */
366 if (!link->avg_rssi.avg || !qual->rx_success) 346 if (!qual->rx_success)
367 qual->rssi = DEFAULT_RSSI; 347 qual->rssi = DEFAULT_RSSI;
368 else 348 else
369 qual->rssi = link->avg_rssi.avg; 349 qual->rssi = rt2x00link_get_avg_rssi(&link->avg_rssi);
370 350
371 /* 351 /*
372 * Check if link tuning is supported by the hardware, some hardware 352 * Check if link tuning is supported by the hardware, some hardware
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 76d95deb274b..6c5d667103c4 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -121,7 +121,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops)
121 rt2x00dev->ops = ops; 121 rt2x00dev->ops = ops;
122 rt2x00dev->hw = hw; 122 rt2x00dev->hw = hw;
123 rt2x00dev->irq = pci_dev->irq; 123 rt2x00dev->irq = pci_dev->irq;
124 rt2x00dev->name = pci_name(pci_dev); 124 rt2x00dev->name = ops->name;
125 125
126 if (pci_is_pcie(pci_dev)) 126 if (pci_is_pcie(pci_dev))
127 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE); 127 rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCIE);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 6c8a33b6ee22..218e3206ce1b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -1033,38 +1033,21 @@ EXPORT_SYMBOL_GPL(rt2x00queue_stop_queue);
1033 1033
1034void rt2x00queue_flush_queue(struct data_queue *queue, bool drop) 1034void rt2x00queue_flush_queue(struct data_queue *queue, bool drop)
1035{ 1035{
1036 bool started;
1037 bool tx_queue = 1036 bool tx_queue =
1038 (queue->qid == QID_AC_VO) || 1037 (queue->qid == QID_AC_VO) ||
1039 (queue->qid == QID_AC_VI) || 1038 (queue->qid == QID_AC_VI) ||
1040 (queue->qid == QID_AC_BE) || 1039 (queue->qid == QID_AC_BE) ||
1041 (queue->qid == QID_AC_BK); 1040 (queue->qid == QID_AC_BK);
1042 1041
1043 mutex_lock(&queue->status_lock);
1044 1042
1045 /* 1043 /*
1046 * If the queue has been started, we must stop it temporarily 1044 * If we are not supposed to drop any pending
1047 * to prevent any new frames to be queued on the device. If 1045 * frames, this means we must force a start (=kick)
1048 * we are not dropping the pending frames, the queue must 1046 * to the queue to make sure the hardware will
1049 * only be stopped in the software and not the hardware, 1047 * start transmitting.
1050 * otherwise the queue will never become empty on its own.
1051 */ 1048 */
1052 started = test_bit(QUEUE_STARTED, &queue->flags); 1049 if (!drop && tx_queue)
1053 if (started) { 1050 queue->rt2x00dev->ops->lib->kick_queue(queue);
1054 /*
1055 * Pause the queue
1056 */
1057 rt2x00queue_pause_queue(queue);
1058
1059 /*
1060 * If we are not supposed to drop any pending
1061 * frames, this means we must force a start (=kick)
1062 * to the queue to make sure the hardware will
1063 * start transmitting.
1064 */
1065 if (!drop && tx_queue)
1066 queue->rt2x00dev->ops->lib->kick_queue(queue);
1067 }
1068 1051
1069 /* 1052 /*
1070 * Check if driver supports flushing, if that is the case we can 1053 * Check if driver supports flushing, if that is the case we can
@@ -1080,14 +1063,6 @@ void rt2x00queue_flush_queue(struct data_queue *queue, bool drop)
1080 if (unlikely(!rt2x00queue_empty(queue))) 1063 if (unlikely(!rt2x00queue_empty(queue)))
1081 rt2x00_warn(queue->rt2x00dev, "Queue %d failed to flush\n", 1064 rt2x00_warn(queue->rt2x00dev, "Queue %d failed to flush\n",
1082 queue->qid); 1065 queue->qid);
1083
1084 /*
1085 * Restore the queue to the previous status
1086 */
1087 if (started)
1088 rt2x00queue_unpause_queue(queue);
1089
1090 mutex_unlock(&queue->status_lock);
1091} 1066}
1092EXPORT_SYMBOL_GPL(rt2x00queue_flush_queue); 1067EXPORT_SYMBOL_GPL(rt2x00queue_flush_queue);
1093 1068
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 88289873c0cf..4e121627925d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -523,7 +523,9 @@ static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue)
523 rt2x00_warn(queue->rt2x00dev, "TX queue %d DMA timed out, invoke forced forced reset\n", 523 rt2x00_warn(queue->rt2x00dev, "TX queue %d DMA timed out, invoke forced forced reset\n",
524 queue->qid); 524 queue->qid);
525 525
526 rt2x00queue_stop_queue(queue);
526 rt2x00queue_flush_queue(queue, true); 527 rt2x00queue_flush_queue(queue, true);
528 rt2x00queue_start_queue(queue);
527} 529}
528 530
529static int rt2x00usb_dma_timeout(struct data_queue *queue) 531static int rt2x00usb_dma_timeout(struct data_queue *queue)
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c
index fc207b268e4f..a91506b12a62 100644
--- a/drivers/net/wireless/rtl818x/rtl8180/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c
@@ -1122,7 +1122,6 @@ static int rtl8180_probe(struct pci_dev *pdev,
1122 iounmap(priv->map); 1122 iounmap(priv->map);
1123 1123
1124 err_free_dev: 1124 err_free_dev:
1125 pci_set_drvdata(pdev, NULL);
1126 ieee80211_free_hw(dev); 1125 ieee80211_free_hw(dev);
1127 1126
1128 err_free_reg: 1127 err_free_reg:
diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c
index 841fb9dfc9da..9a6edb0c014e 100644
--- a/drivers/net/wireless/rtl818x/rtl8187/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c
@@ -438,17 +438,16 @@ static int rtl8187_init_urbs(struct ieee80211_hw *dev)
438 skb_queue_tail(&priv->rx_queue, skb); 438 skb_queue_tail(&priv->rx_queue, skb);
439 usb_anchor_urb(entry, &priv->anchored); 439 usb_anchor_urb(entry, &priv->anchored);
440 ret = usb_submit_urb(entry, GFP_KERNEL); 440 ret = usb_submit_urb(entry, GFP_KERNEL);
441 usb_put_urb(entry);
441 if (ret) { 442 if (ret) {
442 skb_unlink(skb, &priv->rx_queue); 443 skb_unlink(skb, &priv->rx_queue);
443 usb_unanchor_urb(entry); 444 usb_unanchor_urb(entry);
444 goto err; 445 goto err;
445 } 446 }
446 usb_free_urb(entry);
447 } 447 }
448 return ret; 448 return ret;
449 449
450err: 450err:
451 usb_free_urb(entry);
452 kfree_skb(skb); 451 kfree_skb(skb);
453 usb_kill_anchored_urbs(&priv->anchored); 452 usb_kill_anchored_urbs(&priv->anchored);
454 return ret; 453 return ret;
@@ -956,8 +955,12 @@ static int rtl8187_start(struct ieee80211_hw *dev)
956 (RETRY_COUNT << 8 /* short retry limit */) | 955 (RETRY_COUNT << 8 /* short retry limit */) |
957 (RETRY_COUNT << 0 /* long retry limit */) | 956 (RETRY_COUNT << 0 /* long retry limit */) |
958 (7 << 21 /* MAX TX DMA */)); 957 (7 << 21 /* MAX TX DMA */));
959 rtl8187_init_urbs(dev); 958 ret = rtl8187_init_urbs(dev);
960 rtl8187b_init_status_urb(dev); 959 if (ret)
960 goto rtl8187_start_exit;
961 ret = rtl8187b_init_status_urb(dev);
962 if (ret)
963 usb_kill_anchored_urbs(&priv->anchored);
961 goto rtl8187_start_exit; 964 goto rtl8187_start_exit;
962 } 965 }
963 966
@@ -966,7 +969,9 @@ static int rtl8187_start(struct ieee80211_hw *dev)
966 rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0); 969 rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0);
967 rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0); 970 rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0);
968 971
969 rtl8187_init_urbs(dev); 972 ret = rtl8187_init_urbs(dev);
973 if (ret)
974 goto rtl8187_start_exit;
970 975
971 reg = RTL818X_RX_CONF_ONLYERLPKT | 976 reg = RTL818X_RX_CONF_ONLYERLPKT |
972 RTL818X_RX_CONF_RX_AUTORESETPHY | 977 RTL818X_RX_CONF_RX_AUTORESETPHY |
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 8bb4a9a01a18..9a78e3daf742 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -1613,6 +1613,35 @@ err_free:
1613} 1613}
1614EXPORT_SYMBOL(rtl_send_smps_action); 1614EXPORT_SYMBOL(rtl_send_smps_action);
1615 1615
1616void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
1617{
1618 struct rtl_priv *rtlpriv = rtl_priv(hw);
1619 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1620 enum io_type iotype;
1621
1622 if (!is_hal_stop(rtlhal)) {
1623 switch (operation) {
1624 case SCAN_OPT_BACKUP:
1625 iotype = IO_CMD_PAUSE_DM_BY_SCAN;
1626 rtlpriv->cfg->ops->set_hw_reg(hw,
1627 HW_VAR_IO_CMD,
1628 (u8 *)&iotype);
1629 break;
1630 case SCAN_OPT_RESTORE:
1631 iotype = IO_CMD_RESUME_DM_BY_SCAN;
1632 rtlpriv->cfg->ops->set_hw_reg(hw,
1633 HW_VAR_IO_CMD,
1634 (u8 *)&iotype);
1635 break;
1636 default:
1637 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1638 "Unknown Scan Backup operation.\n");
1639 break;
1640 }
1641 }
1642}
1643EXPORT_SYMBOL(rtl_phy_scan_operation_backup);
1644
1616/* There seem to be issues in mac80211 regarding when del ba frames can be 1645/* There seem to be issues in mac80211 regarding when del ba frames can be
1617 * received. As a work around, we make a fake del_ba if we receive a ba_req; 1646 * received. As a work around, we make a fake del_ba if we receive a ba_req;
1618 * however, rx_agg was opened to let mac80211 release some ba related 1647 * however, rx_agg was opened to let mac80211 release some ba related
diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h
index 0e5fe0902daf..0cd07420777a 100644
--- a/drivers/net/wireless/rtlwifi/base.h
+++ b/drivers/net/wireless/rtlwifi/base.h
@@ -114,7 +114,6 @@ void rtl_init_rfkill(struct ieee80211_hw *hw);
114void rtl_deinit_rfkill(struct ieee80211_hw *hw); 114void rtl_deinit_rfkill(struct ieee80211_hw *hw);
115 115
116void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb); 116void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb);
117void rtl_watch_dog_timer_callback(unsigned long data);
118void rtl_deinit_deferred_work(struct ieee80211_hw *hw); 117void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
119 118
120bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx); 119bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
@@ -153,5 +152,6 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
153bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb); 152bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
154struct sk_buff *rtl_make_del_ba(struct ieee80211_hw *hw, 153struct sk_buff *rtl_make_del_ba(struct ieee80211_hw *hw,
155 u8 *sa, u8 *bssid, u16 tid); 154 u8 *sa, u8 *bssid, u16 tid);
155void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
156 156
157#endif 157#endif
diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c
index 838a1ed3f194..ae13fb94b2e8 100644
--- a/drivers/net/wireless/rtlwifi/efuse.c
+++ b/drivers/net/wireless/rtlwifi/efuse.c
@@ -1203,20 +1203,18 @@ static void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate)
1203 1203
1204static u16 efuse_get_current_size(struct ieee80211_hw *hw) 1204static u16 efuse_get_current_size(struct ieee80211_hw *hw)
1205{ 1205{
1206 int continual = true;
1207 u16 efuse_addr = 0; 1206 u16 efuse_addr = 0;
1208 u8 hworden; 1207 u8 hworden;
1209 u8 efuse_data, word_cnts; 1208 u8 efuse_data, word_cnts;
1210 1209
1211 while (continual && efuse_one_byte_read(hw, efuse_addr, &efuse_data) 1210 while (efuse_one_byte_read(hw, efuse_addr, &efuse_data) &&
1212 && (efuse_addr < EFUSE_MAX_SIZE)) { 1211 efuse_addr < EFUSE_MAX_SIZE) {
1213 if (efuse_data != 0xFF) { 1212 if (efuse_data == 0xFF)
1214 hworden = efuse_data & 0x0F; 1213 break;
1215 word_cnts = efuse_calculate_word_cnts(hworden); 1214
1216 efuse_addr = efuse_addr + (word_cnts * 2) + 1; 1215 hworden = efuse_data & 0x0F;
1217 } else { 1216 word_cnts = efuse_calculate_word_cnts(hworden);
1218 continual = false; 1217 efuse_addr = efuse_addr + (word_cnts * 2) + 1;
1219 }
1220 } 1218 }
1221 1219
1222 return efuse_addr; 1220 return efuse_addr;
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 703f839af6ca..0f494444bcd1 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -736,7 +736,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
736 736
737 struct rtl_stats stats = { 737 struct rtl_stats stats = {
738 .signal = 0, 738 .signal = 0,
739 .noise = -98,
740 .rate = 0, 739 .rate = 0,
741 }; 740 };
742 int index = rtlpci->rx_ring[rx_queue_idx].idx; 741 int index = rtlpci->rx_ring[rx_queue_idx].idx;
@@ -2009,7 +2008,6 @@ fail2:
2009fail1: 2008fail1:
2010 if (hw) 2009 if (hw)
2011 ieee80211_free_hw(hw); 2010 ieee80211_free_hw(hw);
2012 pci_set_drvdata(pdev, NULL);
2013 pci_disable_device(pdev); 2011 pci_disable_device(pdev);
2014 2012
2015 return err; 2013 return err;
@@ -2064,8 +2062,6 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
2064 2062
2065 rtl_pci_disable_aspm(hw); 2063 rtl_pci_disable_aspm(hw);
2066 2064
2067 pci_set_drvdata(pdev, NULL);
2068
2069 ieee80211_free_hw(hw); 2065 ieee80211_free_hw(hw);
2070} 2066}
2071EXPORT_SYMBOL(rtl_pci_disconnect); 2067EXPORT_SYMBOL(rtl_pci_disconnect);
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
index b68cae3024fc..e06971be7df7 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
@@ -143,6 +143,7 @@ static void _rtl88ee_set_fw_clock_on(struct ieee80211_hw *hw,
143 } else { 143 } else {
144 rtlhal->fw_clk_change_in_progress = false; 144 rtlhal->fw_clk_change_in_progress = false;
145 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); 145 spin_unlock_bh(&rtlpriv->locks.fw_ps_lock);
146 break;
146 } 147 }
147 } 148 }
148 149
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/phy.c b/drivers/net/wireless/rtlwifi/rtl8188ee/phy.c
index e655c0473225..d67f9c731cc4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/phy.c
@@ -1136,34 +1136,6 @@ void rtl88e_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel)
1136 &bw40_pwr[0], channel); 1136 &bw40_pwr[0], channel);
1137} 1137}
1138 1138
1139void rtl88e_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
1140{
1141 struct rtl_priv *rtlpriv = rtl_priv(hw);
1142 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1143 enum io_type iotype;
1144
1145 if (!is_hal_stop(rtlhal)) {
1146 switch (operation) {
1147 case SCAN_OPT_BACKUP:
1148 iotype = IO_CMD_PAUSE_DM_BY_SCAN;
1149 rtlpriv->cfg->ops->set_hw_reg(hw,
1150 HW_VAR_IO_CMD,
1151 (u8 *)&iotype);
1152 break;
1153 case SCAN_OPT_RESTORE:
1154 iotype = IO_CMD_RESUME_DM_BY_SCAN;
1155 rtlpriv->cfg->ops->set_hw_reg(hw,
1156 HW_VAR_IO_CMD,
1157 (u8 *)&iotype);
1158 break;
1159 default:
1160 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1161 "Unknown Scan Backup operation.\n");
1162 break;
1163 }
1164 }
1165}
1166
1167void rtl88e_phy_set_bw_mode_callback(struct ieee80211_hw *hw) 1139void rtl88e_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
1168{ 1140{
1169 struct rtl_priv *rtlpriv = rtl_priv(hw); 1141 struct rtl_priv *rtlpriv = rtl_priv(hw);
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/phy.h b/drivers/net/wireless/rtlwifi/rtl8188ee/phy.h
index f1acd6d27e44..d4545f06e185 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/phy.h
@@ -217,8 +217,6 @@ extern void rtl88e_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw);
217extern void rtl88e_phy_get_txpower_level(struct ieee80211_hw *hw, 217extern void rtl88e_phy_get_txpower_level(struct ieee80211_hw *hw,
218 long *powerlevel); 218 long *powerlevel);
219extern void rtl88e_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); 219extern void rtl88e_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel);
220extern void rtl88e_phy_scan_operation_backup(struct ieee80211_hw *hw,
221 u8 operation);
222extern void rtl88e_phy_set_bw_mode_callback(struct ieee80211_hw *hw); 220extern void rtl88e_phy_set_bw_mode_callback(struct ieee80211_hw *hw);
223extern void rtl88e_phy_set_bw_mode(struct ieee80211_hw *hw, 221extern void rtl88e_phy_set_bw_mode(struct ieee80211_hw *hw,
224 enum nl80211_channel_type ch_type); 222 enum nl80211_channel_type ch_type);
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c b/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c
index c254693a1e6a..347af1e4f438 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c
@@ -30,6 +30,7 @@
30#include "../wifi.h" 30#include "../wifi.h"
31#include "../core.h" 31#include "../core.h"
32#include "../pci.h" 32#include "../pci.h"
33#include "../base.h"
33#include "reg.h" 34#include "reg.h"
34#include "def.h" 35#include "def.h"
35#include "phy.h" 36#include "phy.h"
@@ -244,7 +245,7 @@ static struct rtl_hal_ops rtl8188ee_hal_ops = {
244 .set_bw_mode = rtl88e_phy_set_bw_mode, 245 .set_bw_mode = rtl88e_phy_set_bw_mode,
245 .switch_channel = rtl88e_phy_sw_chnl, 246 .switch_channel = rtl88e_phy_sw_chnl,
246 .dm_watchdog = rtl88e_dm_watchdog, 247 .dm_watchdog = rtl88e_dm_watchdog,
247 .scan_operation_backup = rtl88e_phy_scan_operation_backup, 248 .scan_operation_backup = rtl_phy_scan_operation_backup,
248 .set_rf_power_state = rtl88e_phy_set_rf_power_state, 249 .set_rf_power_state = rtl88e_phy_set_rf_power_state,
249 .led_control = rtl88ee_led_control, 250 .led_control = rtl88ee_led_control,
250 .set_desc = rtl88ee_set_desc, 251 .set_desc = rtl88ee_set_desc,
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
index 68685a898257..aece6c9cccf1 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
@@ -478,7 +478,6 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw,
478 478
479 /*rx_status->qual = status->signal; */ 479 /*rx_status->qual = status->signal; */
480 rx_status->signal = status->recvsignalpower + 10; 480 rx_status->signal = status->recvsignalpower + 10;
481 /*rx_status->noise = -status->noise; */
482 if (status->packet_report_type == TX_REPORT2) { 481 if (status->packet_report_type == TX_REPORT2) {
483 status->macid_valid_entry[0] = 482 status->macid_valid_entry[0] =
484 GET_RX_RPT2_DESC_MACID_VALID_1(pdesc); 483 GET_RX_RPT2_DESC_MACID_VALID_1(pdesc);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
index d2d57a27a7c1..e9caa5d4cff0 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
@@ -541,29 +541,6 @@ EXPORT_SYMBOL(rtl92c_dm_write_dig);
541 541
542static void rtl92c_dm_pwdb_monitor(struct ieee80211_hw *hw) 542static void rtl92c_dm_pwdb_monitor(struct ieee80211_hw *hw)
543{ 543{
544 struct rtl_priv *rtlpriv = rtl_priv(hw);
545 long tmpentry_max_pwdb = 0, tmpentry_min_pwdb = 0xff;
546
547 u8 h2c_parameter[3] = { 0 };
548
549 return;
550
551 if (tmpentry_max_pwdb != 0) {
552 rtlpriv->dm.entry_max_undec_sm_pwdb = tmpentry_max_pwdb;
553 } else {
554 rtlpriv->dm.entry_max_undec_sm_pwdb = 0;
555 }
556
557 if (tmpentry_min_pwdb != 0xff) {
558 rtlpriv->dm.entry_min_undec_sm_pwdb = tmpentry_min_pwdb;
559 } else {
560 rtlpriv->dm.entry_min_undec_sm_pwdb = 0;
561 }
562
563 h2c_parameter[2] = (u8) (rtlpriv->dm.undec_sm_pwdb & 0xFF);
564 h2c_parameter[0] = 0;
565
566 rtl92c_fill_h2c_cmd(hw, H2C_RSSI_REPORT, 3, h2c_parameter);
567} 544}
568 545
569void rtl92c_dm_init_edca_turbo(struct ieee80211_hw *hw) 546void rtl92c_dm_init_edca_turbo(struct ieee80211_hw *hw)
@@ -673,7 +650,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
673 s8 cck_index = 0; 650 s8 cck_index = 0;
674 int i; 651 int i;
675 bool is2t = IS_92C_SERIAL(rtlhal->version); 652 bool is2t = IS_92C_SERIAL(rtlhal->version);
676 s8 txpwr_level[2] = {0, 0}; 653 s8 txpwr_level[3] = {0, 0, 0};
677 u8 ofdm_min_index = 6, rf; 654 u8 ofdm_min_index = 6, rf;
678 655
679 rtlpriv->dm.txpower_trackinginit = true; 656 rtlpriv->dm.txpower_trackinginit = true;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
index 246e5352f2e1..0c0e78263a66 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
@@ -592,36 +592,6 @@ long _rtl92c_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
592} 592}
593EXPORT_SYMBOL(_rtl92c_phy_txpwr_idx_to_dbm); 593EXPORT_SYMBOL(_rtl92c_phy_txpwr_idx_to_dbm);
594 594
595void rtl92c_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
596{
597 struct rtl_priv *rtlpriv = rtl_priv(hw);
598 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
599 enum io_type iotype;
600
601 if (!is_hal_stop(rtlhal)) {
602 switch (operation) {
603 case SCAN_OPT_BACKUP:
604 iotype = IO_CMD_PAUSE_DM_BY_SCAN;
605 rtlpriv->cfg->ops->set_hw_reg(hw,
606 HW_VAR_IO_CMD,
607 (u8 *)&iotype);
608
609 break;
610 case SCAN_OPT_RESTORE:
611 iotype = IO_CMD_RESUME_DM_BY_SCAN;
612 rtlpriv->cfg->ops->set_hw_reg(hw,
613 HW_VAR_IO_CMD,
614 (u8 *)&iotype);
615 break;
616 default:
617 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
618 "Unknown Scan Backup operation\n");
619 break;
620 }
621 }
622}
623EXPORT_SYMBOL(rtl92c_phy_scan_operation_backup);
624
625void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw, 595void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw,
626 enum nl80211_channel_type ch_type) 596 enum nl80211_channel_type ch_type)
627{ 597{
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h
index cec10d696492..e79dabe9ba1d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h
@@ -39,9 +39,7 @@
39#define RT_CANNOT_IO(hw) false 39#define RT_CANNOT_IO(hw) false
40#define HIGHPOWER_RADIOA_ARRAYLEN 22 40#define HIGHPOWER_RADIOA_ARRAYLEN 22
41 41
42#define IQK_ADDA_REG_NUM 16
43#define MAX_TOLERANCE 5 42#define MAX_TOLERANCE 5
44#define IQK_DELAY_TIME 1
45 43
46#define APK_BB_REG_NUM 5 44#define APK_BB_REG_NUM 5
47#define APK_AFE_REG_NUM 16 45#define APK_AFE_REG_NUM 16
@@ -205,8 +203,6 @@ void rtl92c_phy_get_txpower_level(struct ieee80211_hw *hw,
205void rtl92c_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); 203void rtl92c_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel);
206bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw, 204bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw,
207 long power_indbm); 205 long power_indbm);
208void rtl92c_phy_scan_operation_backup(struct ieee80211_hw *hw,
209 u8 operation);
210void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw, 206void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw,
211 enum nl80211_channel_type ch_type); 207 enum nl80211_channel_type ch_type);
212void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw); 208void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 3cfa1bb0f476..fa24de43ce79 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -152,8 +152,6 @@ enum version_8192c {
152#define IS_VENDOR_UMC_A_CUT(version) ((IS_CHIP_VENDOR_UMC(version)) ? \ 152#define IS_VENDOR_UMC_A_CUT(version) ((IS_CHIP_VENDOR_UMC(version)) ? \
153 ((GET_CVID_CUT_VERSION(version)) ? false : true) : false) 153 ((GET_CVID_CUT_VERSION(version)) ? false : true) : false)
154#define IS_CHIP_VER_B(version) ((version & CHIP_VER_B) ? true : false) 154#define IS_CHIP_VER_B(version) ((version & CHIP_VER_B) ? true : false)
155#define IS_VENDOR_UMC_A_CUT(version) ((IS_CHIP_VENDOR_UMC(version)) ? \
156 ((GET_CVID_CUT_VERSION(version)) ? false : true) : false)
157#define IS_92C_SERIAL(version) ((version & CHIP_92C_BITMASK) ? true : false) 155#define IS_92C_SERIAL(version) ((version & CHIP_92C_BITMASK) ? true : false)
158#define IS_CHIP_VENDOR_UMC(version) \ 156#define IS_CHIP_VENDOR_UMC(version) \
159 ((version & CHIP_VENDOR_UMC) ? true : false) 157 ((version & CHIP_VENDOR_UMC) ? true : false)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h
index d5e3b704f930..aeb268b190c6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h
@@ -39,9 +39,7 @@
39#define RT_CANNOT_IO(hw) false 39#define RT_CANNOT_IO(hw) false
40#define HIGHPOWER_RADIOA_ARRAYLEN 22 40#define HIGHPOWER_RADIOA_ARRAYLEN 22
41 41
42#define IQK_ADDA_REG_NUM 16
43#define MAX_TOLERANCE 5 42#define MAX_TOLERANCE 5
44#define IQK_DELAY_TIME 1
45 43
46#define APK_BB_REG_NUM 5 44#define APK_BB_REG_NUM 5
47#define APK_AFE_REG_NUM 16 45#define APK_AFE_REG_NUM 16
@@ -209,8 +207,6 @@ void rtl92c_phy_get_txpower_level(struct ieee80211_hw *hw,
209void rtl92c_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); 207void rtl92c_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel);
210bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw, 208bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw,
211 long power_indbm); 209 long power_indbm);
212void rtl92c_phy_scan_operation_backup(struct ieee80211_hw *hw,
213 u8 operation);
214void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw, 210void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw,
215 enum nl80211_channel_type ch_type); 211 enum nl80211_channel_type ch_type);
216void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw); 212void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw);
@@ -226,7 +222,6 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
226 enum radio_path rfpath); 222 enum radio_path rfpath);
227bool rtl8192_phy_check_is_legal_rfpath(struct ieee80211_hw *hw, 223bool rtl8192_phy_check_is_legal_rfpath(struct ieee80211_hw *hw,
228 u32 rfpath); 224 u32 rfpath);
229bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype);
230bool rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, 225bool rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
231 enum rf_pwrstate rfpwr_state); 226 enum rf_pwrstate rfpwr_state);
232void rtl92ce_phy_set_rf_on(struct ieee80211_hw *hw); 227void rtl92ce_phy_set_rf_on(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h
index bd4aef74c056..8922ecb47ad2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h
@@ -560,7 +560,6 @@
560#define EEPROM_DEFAULT_TXPOWERLEVEL 0x22 560#define EEPROM_DEFAULT_TXPOWERLEVEL 0x22
561#define EEPROM_DEFAULT_HT40_2SDIFF 0x0 561#define EEPROM_DEFAULT_HT40_2SDIFF 0x0
562#define EEPROM_DEFAULT_HT20_DIFF 2 562#define EEPROM_DEFAULT_HT20_DIFF 2
563#define EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF 0x3
564#define EEPROM_DEFAULT_HT40_PWRMAXOFFSET 0 563#define EEPROM_DEFAULT_HT40_PWRMAXOFFSET 0
565#define EEPROM_DEFAULT_HT20_PWRMAXOFFSET 0 564#define EEPROM_DEFAULT_HT20_PWRMAXOFFSET 0
566 565
@@ -639,17 +638,8 @@
639 638
640#define EEPROM_TXPWR_GROUP 0x6F 639#define EEPROM_TXPWR_GROUP 0x6F
641 640
642#define EEPROM_TSSI_A 0x76
643#define EEPROM_TSSI_B 0x77
644#define EEPROM_THERMAL_METER 0x78
645
646#define EEPROM_CHANNELPLAN 0x75 641#define EEPROM_CHANNELPLAN 0x75
647 642
648#define RF_OPTION1 0x79
649#define RF_OPTION2 0x7A
650#define RF_OPTION3 0x7B
651#define RF_OPTION4 0x7C
652
653#define STOPBECON BIT(6) 643#define STOPBECON BIT(6)
654#define STOPHIGHT BIT(5) 644#define STOPHIGHT BIT(5)
655#define STOPMGT BIT(4) 645#define STOPMGT BIT(4)
@@ -689,13 +679,6 @@
689#define RSV_CTRL 0x001C 679#define RSV_CTRL 0x001C
690#define RD_CTRL 0x0524 680#define RD_CTRL 0x0524
691 681
692#define REG_USB_INFO 0xFE17
693#define REG_USB_SPECIAL_OPTION 0xFE55
694
695#define REG_USB_DMA_AGG_TO 0xFE5B
696#define REG_USB_AGG_TO 0xFE5C
697#define REG_USB_AGG_TH 0xFE5D
698
699#define REG_USB_VID 0xFE60 682#define REG_USB_VID 0xFE60
700#define REG_USB_PID 0xFE62 683#define REG_USB_PID 0xFE62
701#define REG_USB_OPTIONAL 0xFE64 684#define REG_USB_OPTIONAL 0xFE64
@@ -1196,9 +1179,6 @@
1196#define POLLING_LLT_THRESHOLD 20 1179#define POLLING_LLT_THRESHOLD 20
1197#define POLLING_READY_TIMEOUT_COUNT 1000 1180#define POLLING_READY_TIMEOUT_COUNT 1000
1198 1181
1199#define MAX_MSS_DENSITY_2T 0x13
1200#define MAX_MSS_DENSITY_1T 0x0A
1201
1202#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6)) 1182#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6))
1203#define EPROM_CMD_CONFIG 0x3 1183#define EPROM_CMD_CONFIG 0x3
1204#define EPROM_CMD_LOAD 1 1184#define EPROM_CMD_LOAD 1
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index 14203561b6ee..b790320d2030 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -30,6 +30,7 @@
30#include "../wifi.h" 30#include "../wifi.h"
31#include "../core.h" 31#include "../core.h"
32#include "../pci.h" 32#include "../pci.h"
33#include "../base.h"
33#include "reg.h" 34#include "reg.h"
34#include "def.h" 35#include "def.h"
35#include "phy.h" 36#include "phy.h"
@@ -219,7 +220,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
219 .set_bw_mode = rtl92c_phy_set_bw_mode, 220 .set_bw_mode = rtl92c_phy_set_bw_mode,
220 .switch_channel = rtl92c_phy_sw_chnl, 221 .switch_channel = rtl92c_phy_sw_chnl,
221 .dm_watchdog = rtl92c_dm_watchdog, 222 .dm_watchdog = rtl92c_dm_watchdog,
222 .scan_operation_backup = rtl92c_phy_scan_operation_backup, 223 .scan_operation_backup = rtl_phy_scan_operation_backup,
223 .set_rf_power_state = rtl92c_phy_set_rf_power_state, 224 .set_rf_power_state = rtl92c_phy_set_rf_power_state,
224 .led_control = rtl92ce_led_control, 225 .led_control = rtl92ce_led_control,
225 .set_desc = rtl92ce_set_desc, 226 .set_desc = rtl92ce_set_desc,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 6ad23b413eb3..52abf0a862fa 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -420,7 +420,6 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
420 420
421 /*rx_status->qual = stats->signal; */ 421 /*rx_status->qual = stats->signal; */
422 rx_status->signal = stats->recvsignalpower + 10; 422 rx_status->signal = stats->recvsignalpower + 10;
423 /*rx_status->noise = -stats->noise; */
424 423
425 return true; 424 return true;
426} 425}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index da4f587199ee..393685390f3e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -32,6 +32,7 @@
32#include "../usb.h" 32#include "../usb.h"
33#include "../ps.h" 33#include "../ps.h"
34#include "../cam.h" 34#include "../cam.h"
35#include "../stats.h"
35#include "reg.h" 36#include "reg.h"
36#include "def.h" 37#include "def.h"
37#include "phy.h" 38#include "phy.h"
@@ -738,16 +739,6 @@ static u8 _rtl92c_evm_db_to_percentage(char value)
738 return ret_val; 739 return ret_val;
739} 740}
740 741
741static long _rtl92c_translate_todbm(struct ieee80211_hw *hw,
742 u8 signal_strength_index)
743{
744 long signal_power;
745
746 signal_power = (long)((signal_strength_index + 1) >> 1);
747 signal_power -= 95;
748 return signal_power;
749}
750
751static long _rtl92c_signal_scale_mapping(struct ieee80211_hw *hw, 742static long _rtl92c_signal_scale_mapping(struct ieee80211_hw *hw,
752 long currsig) 743 long currsig)
753{ 744{
@@ -913,180 +904,6 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
913 (hw, total_rssi /= rf_rx_num)); 904 (hw, total_rssi /= rf_rx_num));
914} 905}
915 906
916static void _rtl92c_process_ui_rssi(struct ieee80211_hw *hw,
917 struct rtl_stats *pstats)
918{
919 struct rtl_priv *rtlpriv = rtl_priv(hw);
920 struct rtl_phy *rtlphy = &(rtlpriv->phy);
921 u8 rfpath;
922 u32 last_rssi, tmpval;
923
924 if (pstats->packet_toself || pstats->packet_beacon) {
925 rtlpriv->stats.rssi_calculate_cnt++;
926 if (rtlpriv->stats.ui_rssi.total_num++ >=
927 PHY_RSSI_SLID_WIN_MAX) {
928 rtlpriv->stats.ui_rssi.total_num =
929 PHY_RSSI_SLID_WIN_MAX;
930 last_rssi =
931 rtlpriv->stats.ui_rssi.elements[rtlpriv->
932 stats.ui_rssi.index];
933 rtlpriv->stats.ui_rssi.total_val -= last_rssi;
934 }
935 rtlpriv->stats.ui_rssi.total_val += pstats->signalstrength;
936 rtlpriv->stats.ui_rssi.elements[rtlpriv->stats.ui_rssi.
937 index++] = pstats->signalstrength;
938 if (rtlpriv->stats.ui_rssi.index >= PHY_RSSI_SLID_WIN_MAX)
939 rtlpriv->stats.ui_rssi.index = 0;
940 tmpval = rtlpriv->stats.ui_rssi.total_val /
941 rtlpriv->stats.ui_rssi.total_num;
942 rtlpriv->stats.signal_strength =
943 _rtl92c_translate_todbm(hw, (u8) tmpval);
944 pstats->rssi = rtlpriv->stats.signal_strength;
945 }
946 if (!pstats->is_cck && pstats->packet_toself) {
947 for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath;
948 rfpath++) {
949 if (!rtl8192_phy_check_is_legal_rfpath(hw, rfpath))
950 continue;
951 if (rtlpriv->stats.rx_rssi_percentage[rfpath] == 0) {
952 rtlpriv->stats.rx_rssi_percentage[rfpath] =
953 pstats->rx_mimo_signalstrength[rfpath];
954 }
955 if (pstats->rx_mimo_signalstrength[rfpath] >
956 rtlpriv->stats.rx_rssi_percentage[rfpath]) {
957 rtlpriv->stats.rx_rssi_percentage[rfpath] =
958 ((rtlpriv->stats.
959 rx_rssi_percentage[rfpath] *
960 (RX_SMOOTH_FACTOR - 1)) +
961 (pstats->rx_mimo_signalstrength[rfpath])) /
962 (RX_SMOOTH_FACTOR);
963
964 rtlpriv->stats.rx_rssi_percentage[rfpath] =
965 rtlpriv->stats.rx_rssi_percentage[rfpath] +
966 1;
967 } else {
968 rtlpriv->stats.rx_rssi_percentage[rfpath] =
969 ((rtlpriv->stats.
970 rx_rssi_percentage[rfpath] *
971 (RX_SMOOTH_FACTOR - 1)) +
972 (pstats->rx_mimo_signalstrength[rfpath])) /
973 (RX_SMOOTH_FACTOR);
974 }
975 }
976 }
977}
978
979static void _rtl92c_update_rxsignalstatistics(struct ieee80211_hw *hw,
980 struct rtl_stats *pstats)
981{
982 struct rtl_priv *rtlpriv = rtl_priv(hw);
983 int weighting = 0;
984
985 if (rtlpriv->stats.recv_signal_power == 0)
986 rtlpriv->stats.recv_signal_power = pstats->recvsignalpower;
987 if (pstats->recvsignalpower > rtlpriv->stats.recv_signal_power)
988 weighting = 5;
989 else if (pstats->recvsignalpower < rtlpriv->stats.recv_signal_power)
990 weighting = (-5);
991 rtlpriv->stats.recv_signal_power =
992 (rtlpriv->stats.recv_signal_power * 5 +
993 pstats->recvsignalpower + weighting) / 6;
994}
995
996static void _rtl92c_process_pwdb(struct ieee80211_hw *hw,
997 struct rtl_stats *pstats)
998{
999 struct rtl_priv *rtlpriv = rtl_priv(hw);
1000 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1001 long undec_sm_pwdb = 0;
1002
1003 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
1004 return;
1005 } else {
1006 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
1007 }
1008 if (pstats->packet_toself || pstats->packet_beacon) {
1009 if (undec_sm_pwdb < 0)
1010 undec_sm_pwdb = pstats->rx_pwdb_all;
1011 if (pstats->rx_pwdb_all > (u32) undec_sm_pwdb) {
1012 undec_sm_pwdb = (((undec_sm_pwdb) *
1013 (RX_SMOOTH_FACTOR - 1)) +
1014 (pstats->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
1015 undec_sm_pwdb += 1;
1016 } else {
1017 undec_sm_pwdb = (((undec_sm_pwdb) *
1018 (RX_SMOOTH_FACTOR - 1)) +
1019 (pstats->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
1020 }
1021 rtlpriv->dm.undec_sm_pwdb = undec_sm_pwdb;
1022 _rtl92c_update_rxsignalstatistics(hw, pstats);
1023 }
1024}
1025
1026static void _rtl92c_process_LINK_Q(struct ieee80211_hw *hw,
1027 struct rtl_stats *pstats)
1028{
1029 struct rtl_priv *rtlpriv = rtl_priv(hw);
1030 u32 last_evm = 0, n_stream, tmpval;
1031
1032 if (pstats->signalquality != 0) {
1033 if (pstats->packet_toself || pstats->packet_beacon) {
1034 if (rtlpriv->stats.LINK_Q.total_num++ >=
1035 PHY_LINKQUALITY_SLID_WIN_MAX) {
1036 rtlpriv->stats.LINK_Q.total_num =
1037 PHY_LINKQUALITY_SLID_WIN_MAX;
1038 last_evm =
1039 rtlpriv->stats.LINK_Q.elements
1040 [rtlpriv->stats.LINK_Q.index];
1041 rtlpriv->stats.LINK_Q.total_val -=
1042 last_evm;
1043 }
1044 rtlpriv->stats.LINK_Q.total_val +=
1045 pstats->signalquality;
1046 rtlpriv->stats.LINK_Q.elements
1047 [rtlpriv->stats.LINK_Q.index++] =
1048 pstats->signalquality;
1049 if (rtlpriv->stats.LINK_Q.index >=
1050 PHY_LINKQUALITY_SLID_WIN_MAX)
1051 rtlpriv->stats.LINK_Q.index = 0;
1052 tmpval = rtlpriv->stats.LINK_Q.total_val /
1053 rtlpriv->stats.LINK_Q.total_num;
1054 rtlpriv->stats.signal_quality = tmpval;
1055 rtlpriv->stats.last_sigstrength_inpercent = tmpval;
1056 for (n_stream = 0; n_stream < 2;
1057 n_stream++) {
1058 if (pstats->RX_SIGQ[n_stream] != -1) {
1059 if (!rtlpriv->stats.RX_EVM[n_stream]) {
1060 rtlpriv->stats.RX_EVM[n_stream]
1061 = pstats->RX_SIGQ[n_stream];
1062 }
1063 rtlpriv->stats.RX_EVM[n_stream] =
1064 ((rtlpriv->stats.RX_EVM
1065 [n_stream] *
1066 (RX_SMOOTH_FACTOR - 1)) +
1067 (pstats->RX_SIGQ
1068 [n_stream] * 1)) /
1069 (RX_SMOOTH_FACTOR);
1070 }
1071 }
1072 }
1073 } else {
1074 ;
1075 }
1076}
1077
1078static void _rtl92c_process_phyinfo(struct ieee80211_hw *hw,
1079 u8 *buffer,
1080 struct rtl_stats *pcurrent_stats)
1081{
1082 if (!pcurrent_stats->packet_matchbssid &&
1083 !pcurrent_stats->packet_beacon)
1084 return;
1085 _rtl92c_process_ui_rssi(hw, pcurrent_stats);
1086 _rtl92c_process_pwdb(hw, pcurrent_stats);
1087 _rtl92c_process_LINK_Q(hw, pcurrent_stats);
1088}
1089
1090void rtl92c_translate_rx_signal_stuff(struct ieee80211_hw *hw, 907void rtl92c_translate_rx_signal_stuff(struct ieee80211_hw *hw,
1091 struct sk_buff *skb, 908 struct sk_buff *skb,
1092 struct rtl_stats *pstats, 909 struct rtl_stats *pstats,
@@ -1123,5 +940,5 @@ void rtl92c_translate_rx_signal_stuff(struct ieee80211_hw *hw,
1123 _rtl92c_query_rxphystatus(hw, pstats, pdesc, p_drvinfo, 940 _rtl92c_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
1124 packet_matchbssid, packet_toself, 941 packet_matchbssid, packet_toself,
1125 packet_beacon); 942 packet_beacon);
1126 _rtl92c_process_phyinfo(hw, tmp_buf, pstats); 943 rtl_process_phyinfo(hw, tmp_buf, pstats);
1127} 944}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 2bd598526217..9936de716ad5 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -31,6 +31,7 @@
31#include "../core.h" 31#include "../core.h"
32#include "../usb.h" 32#include "../usb.h"
33#include "../efuse.h" 33#include "../efuse.h"
34#include "../base.h"
34#include "reg.h" 35#include "reg.h"
35#include "def.h" 36#include "def.h"
36#include "phy.h" 37#include "phy.h"
@@ -117,7 +118,7 @@ static struct rtl_hal_ops rtl8192cu_hal_ops = {
117 .set_bw_mode = rtl92c_phy_set_bw_mode, 118 .set_bw_mode = rtl92c_phy_set_bw_mode,
118 .switch_channel = rtl92c_phy_sw_chnl, 119 .switch_channel = rtl92c_phy_sw_chnl,
119 .dm_watchdog = rtl92c_dm_watchdog, 120 .dm_watchdog = rtl92c_dm_watchdog,
120 .scan_operation_backup = rtl92c_phy_scan_operation_backup, 121 .scan_operation_backup = rtl_phy_scan_operation_backup,
121 .set_rf_power_state = rtl92cu_phy_set_rf_power_state, 122 .set_rf_power_state = rtl92cu_phy_set_rf_power_state,
122 .led_control = rtl92cu_led_control, 123 .led_control = rtl92cu_led_control,
123 .enable_hw_sec = rtl92cu_enable_hw_security_config, 124 .enable_hw_sec = rtl92cu_enable_hw_security_config,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
index 763cf1defab5..04c7e57dbce2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
@@ -349,7 +349,6 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
349 } 349 }
350 /*rx_status->qual = stats->signal; */ 350 /*rx_status->qual = stats->signal; */
351 rx_status->signal = stats->rssi + 10; 351 rx_status->signal = stats->rssi + 10;
352 /*rx_status->noise = -stats->noise; */
353 return true; 352 return true;
354} 353}
355 354
@@ -364,7 +363,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
364 u8 *rxdesc; 363 u8 *rxdesc;
365 struct rtl_stats stats = { 364 struct rtl_stats stats = {
366 .signal = 0, 365 .signal = 0,
367 .noise = -98,
368 .rate = 0, 366 .rate = 0,
369 }; 367 };
370 struct rx_fwinfo_92c *p_drvinfo; 368 struct rx_fwinfo_92c *p_drvinfo;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
index f700f7a614b2..7908e1c85819 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
@@ -840,9 +840,9 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
840 bool internal_pa = false; 840 bool internal_pa = false;
841 long ele_a = 0, ele_d, temp_cck, val_x, value32; 841 long ele_a = 0, ele_d, temp_cck, val_x, value32;
842 long val_y, ele_c = 0; 842 long val_y, ele_c = 0;
843 u8 ofdm_index[2]; 843 u8 ofdm_index[3];
844 s8 cck_index = 0; 844 s8 cck_index = 0;
845 u8 ofdm_index_old[2] = {0, 0}; 845 u8 ofdm_index_old[3] = {0, 0, 0};
846 s8 cck_index_old = 0; 846 s8 cck_index_old = 0;
847 u8 index; 847 u8 index;
848 int i; 848 int i;
@@ -1118,6 +1118,10 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
1118 val_x, val_y, ele_a, ele_c, ele_d, 1118 val_x, val_y, ele_a, ele_c, ele_d,
1119 val_x, val_y); 1119 val_x, val_y);
1120 1120
1121 if (cck_index >= CCK_TABLE_SIZE)
1122 cck_index = CCK_TABLE_SIZE - 1;
1123 if (cck_index < 0)
1124 cck_index = 0;
1121 if (rtlhal->current_bandtype == BAND_ON_2_4G) { 1125 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
1122 /* Adjust CCK according to IQK result */ 1126 /* Adjust CCK according to IQK result */
1123 if (!rtlpriv->dm.cck_inch14) { 1127 if (!rtlpriv->dm.cck_inch14) {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
index 7dd8f6de0550..c4a7db9135d6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
@@ -1194,25 +1194,7 @@ void rtl92d_linked_set_reg(struct ieee80211_hw *hw)
1194 * mac80211 will send pkt when scan */ 1194 * mac80211 will send pkt when scan */
1195void rtl92de_set_qos(struct ieee80211_hw *hw, int aci) 1195void rtl92de_set_qos(struct ieee80211_hw *hw, int aci)
1196{ 1196{
1197 struct rtl_priv *rtlpriv = rtl_priv(hw);
1198 rtl92d_dm_init_edca_turbo(hw); 1197 rtl92d_dm_init_edca_turbo(hw);
1199 return;
1200 switch (aci) {
1201 case AC1_BK:
1202 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 0xa44f);
1203 break;
1204 case AC0_BE:
1205 break;
1206 case AC2_VI:
1207 rtl_write_dword(rtlpriv, REG_EDCA_VI_PARAM, 0x5e4322);
1208 break;
1209 case AC3_VO:
1210 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222);
1211 break;
1212 default:
1213 RT_ASSERT(false, "invalid aci: %d !\n", aci);
1214 break;
1215 }
1216} 1198}
1217 1199
1218void rtl92de_enable_interrupt(struct ieee80211_hw *hw) 1200void rtl92de_enable_interrupt(struct ieee80211_hw *hw)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
index 840bac5fa2f8..13196cc4b1d3 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
@@ -1022,34 +1022,6 @@ void rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel)
1022 rtl92d_phy_rf6052_set_ofdm_txpower(hw, &ofdmpowerlevel[0], channel); 1022 rtl92d_phy_rf6052_set_ofdm_txpower(hw, &ofdmpowerlevel[0], channel);
1023} 1023}
1024 1024
1025void rtl92d_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
1026{
1027 struct rtl_priv *rtlpriv = rtl_priv(hw);
1028 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1029 enum io_type iotype;
1030
1031 if (!is_hal_stop(rtlhal)) {
1032 switch (operation) {
1033 case SCAN_OPT_BACKUP:
1034 rtlhal->current_bandtypebackup =
1035 rtlhal->current_bandtype;
1036 iotype = IO_CMD_PAUSE_DM_BY_SCAN;
1037 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_IO_CMD,
1038 (u8 *)&iotype);
1039 break;
1040 case SCAN_OPT_RESTORE:
1041 iotype = IO_CMD_RESUME_DM_BY_SCAN;
1042 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_IO_CMD,
1043 (u8 *)&iotype);
1044 break;
1045 default:
1046 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1047 "Unknown Scan Backup operation\n");
1048 break;
1049 }
1050 }
1051}
1052
1053void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, 1025void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw,
1054 enum nl80211_channel_type ch_type) 1026 enum nl80211_channel_type ch_type)
1055{ 1027{
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.h b/drivers/net/wireless/rtlwifi/rtl8192de/phy.h
index f074952bf25c..bef3040555dd 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.h
@@ -39,9 +39,7 @@
39#define RT_CANNOT_IO(hw) false 39#define RT_CANNOT_IO(hw) false
40#define HIGHPOWER_RADIOA_ARRAYLEN 22 40#define HIGHPOWER_RADIOA_ARRAYLEN 22
41 41
42#define IQK_ADDA_REG_NUM 16
43#define MAX_TOLERANCE 5 42#define MAX_TOLERANCE 5
44#define IQK_DELAY_TIME 1
45 43
46#define APK_BB_REG_NUM 5 44#define APK_BB_REG_NUM 5
47#define APK_AFE_REG_NUM 16 45#define APK_AFE_REG_NUM 16
@@ -144,8 +142,6 @@ extern bool rtl92c_phy_config_rf_with_feaderfile(struct ieee80211_hw *hw,
144 enum radio_path rfpath); 142 enum radio_path rfpath);
145extern void rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); 143extern void rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw);
146extern void rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); 144extern void rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel);
147extern void rtl92d_phy_scan_operation_backup(struct ieee80211_hw *hw,
148 u8 operation);
149extern void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, 145extern void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw,
150 enum nl80211_channel_type ch_type); 146 enum nl80211_channel_type ch_type);
151extern u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw); 147extern u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw);
@@ -173,6 +169,5 @@ void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
173 unsigned long *flag); 169 unsigned long *flag);
174u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl); 170u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl);
175void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel); 171void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel);
176void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw);
177 172
178#endif 173#endif
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index c18c04bf0c13..edab5a5351b5 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -30,6 +30,7 @@
30#include "../wifi.h" 30#include "../wifi.h"
31#include "../core.h" 31#include "../core.h"
32#include "../pci.h" 32#include "../pci.h"
33#include "../base.h"
33#include "reg.h" 34#include "reg.h"
34#include "def.h" 35#include "def.h"
35#include "phy.h" 36#include "phy.h"
@@ -236,7 +237,7 @@ static struct rtl_hal_ops rtl8192de_hal_ops = {
236 .set_bw_mode = rtl92d_phy_set_bw_mode, 237 .set_bw_mode = rtl92d_phy_set_bw_mode,
237 .switch_channel = rtl92d_phy_sw_chnl, 238 .switch_channel = rtl92d_phy_sw_chnl,
238 .dm_watchdog = rtl92d_dm_watchdog, 239 .dm_watchdog = rtl92d_dm_watchdog,
239 .scan_operation_backup = rtl92d_phy_scan_operation_backup, 240 .scan_operation_backup = rtl_phy_scan_operation_backup,
240 .set_rf_power_state = rtl92d_phy_set_rf_power_state, 241 .set_rf_power_state = rtl92d_phy_set_rf_power_state,
241 .led_control = rtl92de_led_control, 242 .led_control = rtl92de_led_control,
242 .set_desc = rtl92de_set_desc, 243 .set_desc = rtl92de_set_desc,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index b8ec718a0fab..945ddecf90c9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -526,7 +526,6 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
526 } 526 }
527 /*rx_status->qual = stats->signal; */ 527 /*rx_status->qual = stats->signal; */
528 rx_status->signal = stats->rssi + 10; 528 rx_status->signal = stats->rssi + 10;
529 /*rx_status->noise = -stats->noise; */
530 return true; 529 return true;
531} 530}
532 531
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/reg.h b/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
index 84d1181795b8..c81c83591940 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
@@ -425,14 +425,9 @@
425#define EXT_IMEM_CODE_DONE BIT(2) 425#define EXT_IMEM_CODE_DONE BIT(2)
426#define IMEM_CHK_RPT BIT(1) 426#define IMEM_CHK_RPT BIT(1)
427#define IMEM_CODE_DONE BIT(0) 427#define IMEM_CODE_DONE BIT(0)
428#define IMEM_CODE_DONE BIT(0)
429#define IMEM_CHK_RPT BIT(1)
430#define EMEM_CODE_DONE BIT(2) 428#define EMEM_CODE_DONE BIT(2)
431#define EMEM_CHK_RPT BIT(3) 429#define EMEM_CHK_RPT BIT(3)
432#define DMEM_CODE_DONE BIT(4)
433#define IMEM_RDY BIT(5) 430#define IMEM_RDY BIT(5)
434#define BASECHG BIT(6)
435#define FWRDY BIT(7)
436#define LOAD_FW_READY (IMEM_CODE_DONE | \ 431#define LOAD_FW_READY (IMEM_CODE_DONE | \
437 IMEM_CHK_RPT | \ 432 IMEM_CHK_RPT | \
438 EMEM_CODE_DONE | \ 433 EMEM_CODE_DONE | \
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index c7095118de6e..222d2e792ca6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -330,7 +330,6 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
330 330
331 /*rx_status->qual = stats->signal; */ 331 /*rx_status->qual = stats->signal; */
332 rx_status->signal = stats->rssi + 10; 332 rx_status->signal = stats->rssi + 10;
333 /*rx_status->noise = -stats->noise; */
334 333
335 return true; 334 return true;
336} 335}
diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/phy.c b/drivers/net/wireless/rtlwifi/rtl8723ae/phy.c
index eafbb18dd48e..5d318a85eda4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723ae/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723ae/phy.c
@@ -934,35 +934,6 @@ static long _phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw,
934 return pwrout_dbm; 934 return pwrout_dbm;
935} 935}
936 936
937void rtl8723ae_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
938{
939 struct rtl_priv *rtlpriv = rtl_priv(hw);
940 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
941 enum io_type iotype;
942
943 if (!is_hal_stop(rtlhal)) {
944 switch (operation) {
945 case SCAN_OPT_BACKUP:
946 iotype = IO_CMD_PAUSE_DM_BY_SCAN;
947 rtlpriv->cfg->ops->set_hw_reg(hw,
948 HW_VAR_IO_CMD,
949 (u8 *)&iotype);
950
951 break;
952 case SCAN_OPT_RESTORE:
953 iotype = IO_CMD_RESUME_DM_BY_SCAN;
954 rtlpriv->cfg->ops->set_hw_reg(hw,
955 HW_VAR_IO_CMD,
956 (u8 *)&iotype);
957 break;
958 default:
959 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
960 "Unknown Scan Backup operation.\n");
961 break;
962 }
963 }
964}
965
966void rtl8723ae_phy_set_bw_mode_callback(struct ieee80211_hw *hw) 937void rtl8723ae_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
967{ 938{
968 struct rtl_priv *rtlpriv = rtl_priv(hw); 939 struct rtl_priv *rtlpriv = rtl_priv(hw);
diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/phy.h b/drivers/net/wireless/rtlwifi/rtl8723ae/phy.h
index e7a59eba351a..3d8f9e3aad76 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723ae/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8723ae/phy.h
@@ -205,8 +205,6 @@ extern void rtl8723ae_phy_set_txpower_level(struct ieee80211_hw *hw,
205 u8 channel); 205 u8 channel);
206extern bool rtl8723ae_phy_update_txpower_dbm(struct ieee80211_hw *hw, 206extern bool rtl8723ae_phy_update_txpower_dbm(struct ieee80211_hw *hw,
207 long power_indbm); 207 long power_indbm);
208extern void rtl8723ae_phy_scan_operation_backup(struct ieee80211_hw *hw,
209 u8 operation);
210extern void rtl8723ae_phy_set_bw_mode_callback(struct ieee80211_hw *hw); 208extern void rtl8723ae_phy_set_bw_mode_callback(struct ieee80211_hw *hw);
211extern void rtl8723ae_phy_set_bw_mode(struct ieee80211_hw *hw, 209extern void rtl8723ae_phy_set_bw_mode(struct ieee80211_hw *hw,
212 enum nl80211_channel_type ch_type); 210 enum nl80211_channel_type ch_type);
diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/sw.c b/drivers/net/wireless/rtlwifi/rtl8723ae/sw.c
index d9ee2efffe5f..62b204faf773 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723ae/sw.c
@@ -33,6 +33,7 @@
33 33
34#include "../core.h" 34#include "../core.h"
35#include "../pci.h" 35#include "../pci.h"
36#include "../base.h"
36#include "reg.h" 37#include "reg.h"
37#include "def.h" 38#include "def.h"
38#include "phy.h" 39#include "phy.h"
@@ -220,7 +221,7 @@ static struct rtl_hal_ops rtl8723ae_hal_ops = {
220 .set_bw_mode = rtl8723ae_phy_set_bw_mode, 221 .set_bw_mode = rtl8723ae_phy_set_bw_mode,
221 .switch_channel = rtl8723ae_phy_sw_chnl, 222 .switch_channel = rtl8723ae_phy_sw_chnl,
222 .dm_watchdog = rtl8723ae_dm_watchdog, 223 .dm_watchdog = rtl8723ae_dm_watchdog,
223 .scan_operation_backup = rtl8723ae_phy_scan_operation_backup, 224 .scan_operation_backup = rtl_phy_scan_operation_backup,
224 .set_rf_power_state = rtl8723ae_phy_set_rf_power_state, 225 .set_rf_power_state = rtl8723ae_phy_set_rf_power_state,
225 .led_control = rtl8723ae_led_control, 226 .led_control = rtl8723ae_led_control,
226 .set_desc = rtl8723ae_set_desc, 227 .set_desc = rtl8723ae_set_desc,
diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
index bcd82a1020a5..50b7be3f3a60 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
@@ -359,7 +359,6 @@ bool rtl8723ae_rx_query_desc(struct ieee80211_hw *hw,
359 359
360 /*rx_status->qual = status->signal; */ 360 /*rx_status->qual = status->signal; */
361 rx_status->signal = status->recvsignalpower + 10; 361 rx_status->signal = status->recvsignalpower + 10;
362 /*rx_status->noise = -status->noise; */
363 362
364 return true; 363 return true;
365} 364}
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index e56778cac9bf..6e2b5c5c83c8 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -455,7 +455,6 @@ static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
455 struct ieee80211_rx_status rx_status = {0}; 455 struct ieee80211_rx_status rx_status = {0};
456 struct rtl_stats stats = { 456 struct rtl_stats stats = {
457 .signal = 0, 457 .signal = 0,
458 .noise = -98,
459 .rate = 0, 458 .rate = 0,
460 }; 459 };
461 460
@@ -498,7 +497,6 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
498 struct ieee80211_rx_status rx_status = {0}; 497 struct ieee80211_rx_status rx_status = {0};
499 struct rtl_stats stats = { 498 struct rtl_stats stats = {
500 .signal = 0, 499 .signal = 0,
501 .noise = -98,
502 .rate = 0, 500 .rate = 0,
503 }; 501 };
504 502
@@ -582,12 +580,15 @@ static void _rtl_rx_work(unsigned long param)
582static unsigned int _rtl_rx_get_padding(struct ieee80211_hdr *hdr, 580static unsigned int _rtl_rx_get_padding(struct ieee80211_hdr *hdr,
583 unsigned int len) 581 unsigned int len)
584{ 582{
583#if NET_IP_ALIGN != 0
585 unsigned int padding = 0; 584 unsigned int padding = 0;
585#endif
586 586
587 /* make function no-op when possible */ 587 /* make function no-op when possible */
588 if (NET_IP_ALIGN == 0 || len < sizeof(*hdr)) 588 if (NET_IP_ALIGN == 0 || len < sizeof(*hdr))
589 return 0; 589 return 0;
590 590
591#if NET_IP_ALIGN != 0
591 /* alignment calculation as in lbtf_rx() / carl9170_rx_copy_data() */ 592 /* alignment calculation as in lbtf_rx() / carl9170_rx_copy_data() */
592 /* TODO: deduplicate common code, define helper function instead? */ 593 /* TODO: deduplicate common code, define helper function instead? */
593 594
@@ -608,6 +609,7 @@ static unsigned int _rtl_rx_get_padding(struct ieee80211_hdr *hdr,
608 padding ^= NET_IP_ALIGN; 609 padding ^= NET_IP_ALIGN;
609 610
610 return padding; 611 return padding;
612#endif
611} 613}
612 614
613#define __RADIO_TAP_SIZE_RSV 32 615#define __RADIO_TAP_SIZE_RSV 32
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index cc03e7c87cbe..96763dcff5ae 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -192,8 +192,6 @@ enum hardware_type {
192(IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal)) 192(IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal))
193#define IS_HARDWARE_TYPE_8723(rtlhal) \ 193#define IS_HARDWARE_TYPE_8723(rtlhal) \
194(IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal)) 194(IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
195#define IS_HARDWARE_TYPE_8723U(rtlhal) \
196 (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
197 195
198#define RX_HAL_IS_CCK_RATE(_pdesc)\ 196#define RX_HAL_IS_CCK_RATE(_pdesc)\
199 (_pdesc->rxmcs == DESC92_RATE1M || \ 197 (_pdesc->rxmcs == DESC92_RATE1M || \
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index c7dc6feab2ff..1342f81e683d 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -243,7 +243,7 @@ static int wl1251_spi_probe(struct spi_device *spi)
243 struct wl1251 *wl; 243 struct wl1251 *wl;
244 int ret; 244 int ret;
245 245
246 pdata = spi->dev.platform_data; 246 pdata = dev_get_platdata(&spi->dev);
247 if (!pdata) { 247 if (!pdata) {
248 wl1251_error("no platform data"); 248 wl1251_error("no platform data");
249 return -ENODEV; 249 return -ENODEV;
diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index fd02060038de..2c3bd1bff3f6 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -424,8 +424,8 @@ void wl1251_disable_interrupts(struct wl1251 *wl);
424#define CHIP_ID_1271_PG10 (0x4030101) 424#define CHIP_ID_1271_PG10 (0x4030101)
425#define CHIP_ID_1271_PG20 (0x4030111) 425#define CHIP_ID_1271_PG20 (0x4030111)
426 426
427#define WL1251_FW_NAME "wl1251-fw.bin" 427#define WL1251_FW_NAME "ti-connectivity/wl1251-fw.bin"
428#define WL1251_NVS_NAME "wl1251-nvs.bin" 428#define WL1251_NVS_NAME "ti-connectivity/wl1251-nvs.bin"
429 429
430#define WL1251_POWER_ON_SLEEP 10 /* in milliseconds */ 430#define WL1251_POWER_ON_SLEEP 10 /* in milliseconds */
431 431
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
index 1c627da85083..591526b99154 100644
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -1704,7 +1704,7 @@ static struct ieee80211_sta_ht_cap wl12xx_ht_cap = {
1704static int wl12xx_setup(struct wl1271 *wl) 1704static int wl12xx_setup(struct wl1271 *wl)
1705{ 1705{
1706 struct wl12xx_priv *priv = wl->priv; 1706 struct wl12xx_priv *priv = wl->priv;
1707 struct wlcore_platdev_data *pdev_data = wl->pdev->dev.platform_data; 1707 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&wl->pdev->dev);
1708 struct wl12xx_platform_data *pdata = pdev_data->pdata; 1708 struct wl12xx_platform_data *pdata = pdev_data->pdata;
1709 1709
1710 wl->rtable = wl12xx_rtable; 1710 wl->rtable = wl12xx_rtable;
diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
index 7aa0eb848c5a..d0daca1d23bc 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -623,6 +623,18 @@ static const int wl18xx_rtable[REG_TABLE_LEN] = {
623 [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR, 623 [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR,
624}; 624};
625 625
626static const struct wl18xx_clk_cfg wl18xx_clk_table_coex[NUM_CLOCK_CONFIGS] = {
627 [CLOCK_CONFIG_16_2_M] = { 8, 121, 0, 0, false },
628 [CLOCK_CONFIG_16_368_M] = { 8, 120, 0, 0, false },
629 [CLOCK_CONFIG_16_8_M] = { 8, 117, 0, 0, false },
630 [CLOCK_CONFIG_19_2_M] = { 10, 128, 0, 0, false },
631 [CLOCK_CONFIG_26_M] = { 11, 104, 0, 0, false },
632 [CLOCK_CONFIG_32_736_M] = { 8, 120, 0, 0, false },
633 [CLOCK_CONFIG_33_6_M] = { 8, 117, 0, 0, false },
634 [CLOCK_CONFIG_38_468_M] = { 10, 128, 0, 0, false },
635 [CLOCK_CONFIG_52_M] = { 11, 104, 0, 0, false },
636};
637
626static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = { 638static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = {
627 [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true }, 639 [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true },
628 [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true }, 640 [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true },
@@ -704,6 +716,23 @@ static int wl18xx_set_clk(struct wl1271 *wl)
704 wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q, 716 wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
705 wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit"); 717 wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
706 718
719 /* coex PLL configuration */
720 ret = wl18xx_top_reg_write(wl, PLLSH_COEX_PLL_N,
721 wl18xx_clk_table_coex[clk_freq].n);
722 if (ret < 0)
723 goto out;
724
725 ret = wl18xx_top_reg_write(wl, PLLSH_COEX_PLL_M,
726 wl18xx_clk_table_coex[clk_freq].m);
727 if (ret < 0)
728 goto out;
729
730 /* bypass the swallowing logic */
731 ret = wl18xx_top_reg_write(wl, PLLSH_COEX_PLL_SWALLOW_EN,
732 PLLSH_COEX_PLL_SWALLOW_EN_VAL1);
733 if (ret < 0)
734 goto out;
735
707 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N, 736 ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N,
708 wl18xx_clk_table[clk_freq].n); 737 wl18xx_clk_table[clk_freq].n);
709 if (ret < 0) 738 if (ret < 0)
@@ -745,6 +774,30 @@ static int wl18xx_set_clk(struct wl1271 *wl)
745 PLLSH_WCS_PLL_SWALLOW_EN_VAL2); 774 PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
746 } 775 }
747 776
777 /* choose WCS PLL */
778 ret = wl18xx_top_reg_write(wl, PLLSH_WL_PLL_SEL,
779 PLLSH_WL_PLL_SEL_WCS_PLL);
780 if (ret < 0)
781 goto out;
782
783 /* enable both PLLs */
784 ret = wl18xx_top_reg_write(wl, PLLSH_WL_PLL_EN, PLLSH_WL_PLL_EN_VAL1);
785 if (ret < 0)
786 goto out;
787
788 udelay(1000);
789
790 /* disable coex PLL */
791 ret = wl18xx_top_reg_write(wl, PLLSH_WL_PLL_EN, PLLSH_WL_PLL_EN_VAL2);
792 if (ret < 0)
793 goto out;
794
795 /* reset the swallowing logic */
796 ret = wl18xx_top_reg_write(wl, PLLSH_COEX_PLL_SWALLOW_EN,
797 PLLSH_COEX_PLL_SWALLOW_EN_VAL2);
798 if (ret < 0)
799 goto out;
800
748out: 801out:
749 return ret; 802 return ret;
750} 803}
@@ -1175,16 +1228,48 @@ static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
1175 } 1228 }
1176} 1229}
1177 1230
1231static const char *wl18xx_rdl_name(enum wl18xx_rdl_num rdl_num)
1232{
1233 switch (rdl_num) {
1234 case RDL_1_HP:
1235 return "183xH";
1236 case RDL_2_SP:
1237 return "183x or 180x";
1238 case RDL_3_HP:
1239 return "187xH";
1240 case RDL_4_SP:
1241 return "187x";
1242 case RDL_5_SP:
1243 return "RDL11 - Not Supported";
1244 case RDL_6_SP:
1245 return "180xD";
1246 case RDL_7_SP:
1247 return "RDL13 - Not Supported (1893Q)";
1248 case RDL_8_SP:
1249 return "18xxQ";
1250 case RDL_NONE:
1251 return "UNTRIMMED";
1252 default:
1253 return "UNKNOWN";
1254 }
1255}
1256
1178static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver) 1257static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
1179{ 1258{
1180 u32 fuse; 1259 u32 fuse;
1181 s8 rom = 0, metal = 0, pg_ver = 0, rdl_ver = 0; 1260 s8 rom = 0, metal = 0, pg_ver = 0, rdl_ver = 0, package_type = 0;
1182 int ret; 1261 int ret;
1183 1262
1184 ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]); 1263 ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
1185 if (ret < 0) 1264 if (ret < 0)
1186 goto out; 1265 goto out;
1187 1266
1267 ret = wlcore_read32(wl, WL18XX_REG_FUSE_DATA_2_3, &fuse);
1268 if (ret < 0)
1269 goto out;
1270
1271 package_type = (fuse >> WL18XX_PACKAGE_TYPE_OFFSET) & 1;
1272
1188 ret = wlcore_read32(wl, WL18XX_REG_FUSE_DATA_1_3, &fuse); 1273 ret = wlcore_read32(wl, WL18XX_REG_FUSE_DATA_1_3, &fuse);
1189 if (ret < 0) 1274 if (ret < 0)
1190 goto out; 1275 goto out;
@@ -1192,7 +1277,7 @@ static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
1192 pg_ver = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET; 1277 pg_ver = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
1193 rom = (fuse & WL18XX_ROM_VER_MASK) >> WL18XX_ROM_VER_OFFSET; 1278 rom = (fuse & WL18XX_ROM_VER_MASK) >> WL18XX_ROM_VER_OFFSET;
1194 1279
1195 if (rom <= 0xE) 1280 if ((rom <= 0xE) && (package_type == WL18XX_PACKAGE_TYPE_WSP))
1196 metal = (fuse & WL18XX_METAL_VER_MASK) >> 1281 metal = (fuse & WL18XX_METAL_VER_MASK) >>
1197 WL18XX_METAL_VER_OFFSET; 1282 WL18XX_METAL_VER_OFFSET;
1198 else 1283 else
@@ -1204,11 +1289,9 @@ static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
1204 goto out; 1289 goto out;
1205 1290
1206 rdl_ver = (fuse & WL18XX_RDL_VER_MASK) >> WL18XX_RDL_VER_OFFSET; 1291 rdl_ver = (fuse & WL18XX_RDL_VER_MASK) >> WL18XX_RDL_VER_OFFSET;
1207 if (rdl_ver > RDL_MAX)
1208 rdl_ver = RDL_NONE;
1209 1292
1210 wl1271_info("wl18xx HW: RDL %d, %s, PG %x.%x (ROM %x)", 1293 wl1271_info("wl18xx HW: %s, PG %d.%d (ROM 0x%x)",
1211 rdl_ver, rdl_names[rdl_ver], pg_ver, metal, rom); 1294 wl18xx_rdl_name(rdl_ver), pg_ver, metal, rom);
1212 1295
1213 if (ver) 1296 if (ver)
1214 *ver = pg_ver; 1297 *ver = pg_ver;
diff --git a/drivers/net/wireless/ti/wl18xx/reg.h b/drivers/net/wireless/ti/wl18xx/reg.h
index 05dd8bad2746..a433a75f3cd7 100644
--- a/drivers/net/wireless/ti/wl18xx/reg.h
+++ b/drivers/net/wireless/ti/wl18xx/reg.h
@@ -114,6 +114,11 @@
114#define PLATFORM_DETECTION 0xA0E3E0 114#define PLATFORM_DETECTION 0xA0E3E0
115#define OCS_EN 0xA02080 115#define OCS_EN 0xA02080
116#define PRIMARY_CLK_DETECT 0xA020A6 116#define PRIMARY_CLK_DETECT 0xA020A6
117#define PLLSH_COEX_PLL_N 0xA02384
118#define PLLSH_COEX_PLL_M 0xA02382
119#define PLLSH_COEX_PLL_SWALLOW_EN 0xA0238E
120#define PLLSH_WL_PLL_SEL 0xA02398
121
117#define PLLSH_WCS_PLL_N 0xA02362 122#define PLLSH_WCS_PLL_N 0xA02362
118#define PLLSH_WCS_PLL_M 0xA02360 123#define PLLSH_WCS_PLL_M 0xA02360
119#define PLLSH_WCS_PLL_Q_FACTOR_CFG_1 0xA02364 124#define PLLSH_WCS_PLL_Q_FACTOR_CFG_1 0xA02364
@@ -128,19 +133,30 @@
128#define PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK 0xFFFF 133#define PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK 0xFFFF
129#define PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK 0x000F 134#define PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK 0x000F
130 135
136#define PLLSH_WL_PLL_EN_VAL1 0x7
137#define PLLSH_WL_PLL_EN_VAL2 0x2
138#define PLLSH_COEX_PLL_SWALLOW_EN_VAL1 0x2
139#define PLLSH_COEX_PLL_SWALLOW_EN_VAL2 0x11
140
131#define PLLSH_WCS_PLL_SWALLOW_EN_VAL1 0x1 141#define PLLSH_WCS_PLL_SWALLOW_EN_VAL1 0x1
132#define PLLSH_WCS_PLL_SWALLOW_EN_VAL2 0x12 142#define PLLSH_WCS_PLL_SWALLOW_EN_VAL2 0x12
133 143
144#define PLLSH_WL_PLL_SEL_WCS_PLL 0x0
145#define PLLSH_WL_PLL_SEL_COEX_PLL 0x1
146
134#define WL18XX_REG_FUSE_DATA_1_3 0xA0260C 147#define WL18XX_REG_FUSE_DATA_1_3 0xA0260C
135#define WL18XX_PG_VER_MASK 0x70 148#define WL18XX_PG_VER_MASK 0x70
136#define WL18XX_PG_VER_OFFSET 4 149#define WL18XX_PG_VER_OFFSET 4
137#define WL18XX_ROM_VER_MASK 0x3 150#define WL18XX_ROM_VER_MASK 0x3e00
138#define WL18XX_ROM_VER_OFFSET 0 151#define WL18XX_ROM_VER_OFFSET 9
139#define WL18XX_METAL_VER_MASK 0xC 152#define WL18XX_METAL_VER_MASK 0xC
140#define WL18XX_METAL_VER_OFFSET 2 153#define WL18XX_METAL_VER_OFFSET 2
141#define WL18XX_NEW_METAL_VER_MASK 0x180 154#define WL18XX_NEW_METAL_VER_MASK 0x180
142#define WL18XX_NEW_METAL_VER_OFFSET 7 155#define WL18XX_NEW_METAL_VER_OFFSET 7
143 156
157#define WL18XX_PACKAGE_TYPE_OFFSET 13
158#define WL18XX_PACKAGE_TYPE_WSP 0
159
144#define WL18XX_REG_FUSE_DATA_2_3 0xA02614 160#define WL18XX_REG_FUSE_DATA_2_3 0xA02614
145#define WL18XX_RDL_VER_MASK 0x1f00 161#define WL18XX_RDL_VER_MASK 0x1f00
146#define WL18XX_RDL_VER_OFFSET 8 162#define WL18XX_RDL_VER_OFFSET 8
@@ -201,24 +217,21 @@ enum {
201 NUM_BOARD_TYPES, 217 NUM_BOARD_TYPES,
202}; 218};
203 219
204enum { 220enum wl18xx_rdl_num {
205 RDL_NONE = 0, 221 RDL_NONE = 0,
206 RDL_1_HP = 1, 222 RDL_1_HP = 1,
207 RDL_2_SP = 2, 223 RDL_2_SP = 2,
208 RDL_3_HP = 3, 224 RDL_3_HP = 3,
209 RDL_4_SP = 4, 225 RDL_4_SP = 4,
226 RDL_5_SP = 0x11,
227 RDL_6_SP = 0x12,
228 RDL_7_SP = 0x13,
229 RDL_8_SP = 0x14,
210 230
211 _RDL_LAST, 231 _RDL_LAST,
212 RDL_MAX = _RDL_LAST - 1, 232 RDL_MAX = _RDL_LAST - 1,
213}; 233};
214 234
215static const char * const rdl_names[] = {
216 [RDL_NONE] = "",
217 [RDL_1_HP] = "1853 SISO",
218 [RDL_2_SP] = "1857 MIMO",
219 [RDL_3_HP] = "1893 SISO",
220 [RDL_4_SP] = "1897 MIMO",
221};
222 235
223/* FPGA_SPARE_1 register - used to change the PHY ATPG clock at boot time */ 236/* FPGA_SPARE_1 register - used to change the PHY ATPG clock at boot time */
224#define WL18XX_PHY_FPGA_SPARE_1 0x8093CA40 237#define WL18XX_PHY_FPGA_SPARE_1 0x8093CA40
diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
index c9e060795d13..9e5416f8764d 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.c
+++ b/drivers/net/wireless/ti/wlcore/cmd.c
@@ -1126,6 +1126,8 @@ int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1126 u16 template_id_2_4 = wl->scan_templ_id_2_4; 1126 u16 template_id_2_4 = wl->scan_templ_id_2_4;
1127 u16 template_id_5 = wl->scan_templ_id_5; 1127 u16 template_id_5 = wl->scan_templ_id_5;
1128 1128
1129 wl1271_debug(DEBUG_SCAN, "build probe request band %d", band);
1130
1129 skb = ieee80211_probereq_get(wl->hw, vif, ssid, ssid_len, 1131 skb = ieee80211_probereq_get(wl->hw, vif, ssid, ssid_len,
1130 ie_len); 1132 ie_len);
1131 if (!skb) { 1133 if (!skb) {
@@ -1135,8 +1137,6 @@ int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1135 if (ie_len) 1137 if (ie_len)
1136 memcpy(skb_put(skb, ie_len), ie, ie_len); 1138 memcpy(skb_put(skb, ie_len), ie, ie_len);
1137 1139
1138 wl1271_dump(DEBUG_SCAN, "PROBE REQ: ", skb->data, skb->len);
1139
1140 if (sched_scan && 1140 if (sched_scan &&
1141 (wl->quirks & WLCORE_QUIRK_DUAL_PROBE_TMPL)) { 1141 (wl->quirks & WLCORE_QUIRK_DUAL_PROBE_TMPL)) {
1142 template_id_2_4 = wl->sched_scan_templ_id_2_4; 1142 template_id_2_4 = wl->sched_scan_templ_id_2_4;
@@ -1172,7 +1172,7 @@ struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl,
1172 if (!skb) 1172 if (!skb)
1173 goto out; 1173 goto out;
1174 1174
1175 wl1271_dump(DEBUG_SCAN, "AP PROBE REQ: ", skb->data, skb->len); 1175 wl1271_debug(DEBUG_SCAN, "set ap probe request template");
1176 1176
1177 rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wlvif->band]); 1177 rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wlvif->band]);
1178 if (wlvif->band == IEEE80211_BAND_2GHZ) 1178 if (wlvif->band == IEEE80211_BAND_2GHZ)
@@ -1607,33 +1607,43 @@ out:
1607 1607
1608static int wlcore_get_reg_conf_ch_idx(enum ieee80211_band band, u16 ch) 1608static int wlcore_get_reg_conf_ch_idx(enum ieee80211_band band, u16 ch)
1609{ 1609{
1610 int idx = -1; 1610 /*
1611 1611 * map the given band/channel to the respective predefined
1612 * bit expected by the fw
1613 */
1612 switch (band) { 1614 switch (band) {
1613 case IEEE80211_BAND_5GHZ:
1614 if (ch >= 8 && ch <= 16)
1615 idx = ((ch-8)/4 + 18);
1616 else if (ch >= 34 && ch <= 64)
1617 idx = ((ch-34)/2 + 3 + 18);
1618 else if (ch >= 100 && ch <= 140)
1619 idx = ((ch-100)/4 + 15 + 18);
1620 else if (ch >= 149 && ch <= 165)
1621 idx = ((ch-149)/4 + 26 + 18);
1622 else
1623 idx = -1;
1624 break;
1625 case IEEE80211_BAND_2GHZ: 1615 case IEEE80211_BAND_2GHZ:
1616 /* channels 1..14 are mapped to 0..13 */
1626 if (ch >= 1 && ch <= 14) 1617 if (ch >= 1 && ch <= 14)
1627 idx = ch - 1; 1618 return ch - 1;
1628 else 1619 break;
1629 idx = -1; 1620 case IEEE80211_BAND_5GHZ:
1621 switch (ch) {
1622 case 8 ... 16:
1623 /* channels 8,12,16 are mapped to 18,19,20 */
1624 return 18 + (ch-8)/4;
1625 case 34 ... 48:
1626 /* channels 34,36..48 are mapped to 21..28 */
1627 return 21 + (ch-34)/2;
1628 case 52 ... 64:
1629 /* channels 52,56..64 are mapped to 29..32 */
1630 return 29 + (ch-52)/4;
1631 case 100 ... 140:
1632 /* channels 100,104..140 are mapped to 33..43 */
1633 return 33 + (ch-100)/4;
1634 case 149 ... 165:
1635 /* channels 149,153..165 are mapped to 44..48 */
1636 return 44 + (ch-149)/4;
1637 default:
1638 break;
1639 }
1630 break; 1640 break;
1631 default: 1641 default:
1632 wl1271_error("get reg conf ch idx - unknown band: %d", 1642 break;
1633 (int)band);
1634 } 1643 }
1635 1644
1636 return idx; 1645 wl1271_error("%s: unknown band/channel: %d/%d", __func__, band, ch);
1646 return -1;
1637} 1647}
1638 1648
1639void wlcore_set_pending_regdomain_ch(struct wl1271 *wl, u16 channel, 1649void wlcore_set_pending_regdomain_ch(struct wl1271 *wl, u16 channel,
@@ -1646,7 +1656,7 @@ void wlcore_set_pending_regdomain_ch(struct wl1271 *wl, u16 channel,
1646 1656
1647 ch_bit_idx = wlcore_get_reg_conf_ch_idx(band, channel); 1657 ch_bit_idx = wlcore_get_reg_conf_ch_idx(band, channel);
1648 1658
1649 if (ch_bit_idx > 0 && ch_bit_idx <= WL1271_MAX_CHANNELS) 1659 if (ch_bit_idx >= 0 && ch_bit_idx <= WL1271_MAX_CHANNELS)
1650 set_bit(ch_bit_idx, (long *)wl->reg_ch_conf_pending); 1660 set_bit(ch_bit_idx, (long *)wl->reg_ch_conf_pending);
1651} 1661}
1652 1662
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index 38995f90040d..bbdd10632373 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -1062,7 +1062,8 @@ int wl1271_plt_start(struct wl1271 *wl, const enum plt_mode plt_mode)
1062 static const char* const PLT_MODE[] = { 1062 static const char* const PLT_MODE[] = {
1063 "PLT_OFF", 1063 "PLT_OFF",
1064 "PLT_ON", 1064 "PLT_ON",
1065 "PLT_FEM_DETECT" 1065 "PLT_FEM_DETECT",
1066 "PLT_CHIP_AWAKE"
1066 }; 1067 };
1067 1068
1068 int ret; 1069 int ret;
@@ -1088,9 +1089,11 @@ int wl1271_plt_start(struct wl1271 *wl, const enum plt_mode plt_mode)
1088 if (ret < 0) 1089 if (ret < 0)
1089 goto power_off; 1090 goto power_off;
1090 1091
1091 ret = wl->ops->plt_init(wl); 1092 if (plt_mode != PLT_CHIP_AWAKE) {
1092 if (ret < 0) 1093 ret = wl->ops->plt_init(wl);
1093 goto power_off; 1094 if (ret < 0)
1095 goto power_off;
1096 }
1094 1097
1095 wl->state = WLCORE_STATE_ON; 1098 wl->state = WLCORE_STATE_ON;
1096 wl1271_notice("firmware booted in PLT mode %s (%s)", 1099 wl1271_notice("firmware booted in PLT mode %s (%s)",
@@ -2008,6 +2011,47 @@ out:
2008 mutex_unlock(&wl->mutex); 2011 mutex_unlock(&wl->mutex);
2009} 2012}
2010 2013
2014static void wlcore_pending_auth_complete_work(struct work_struct *work)
2015{
2016 struct delayed_work *dwork;
2017 struct wl1271 *wl;
2018 struct wl12xx_vif *wlvif;
2019 unsigned long time_spare;
2020 int ret;
2021
2022 dwork = container_of(work, struct delayed_work, work);
2023 wlvif = container_of(dwork, struct wl12xx_vif,
2024 pending_auth_complete_work);
2025 wl = wlvif->wl;
2026
2027 mutex_lock(&wl->mutex);
2028
2029 if (unlikely(wl->state != WLCORE_STATE_ON))
2030 goto out;
2031
2032 /*
2033 * Make sure a second really passed since the last auth reply. Maybe
2034 * a second auth reply arrived while we were stuck on the mutex.
2035 * Check for a little less than the timeout to protect from scheduler
2036 * irregularities.
2037 */
2038 time_spare = jiffies +
2039 msecs_to_jiffies(WLCORE_PEND_AUTH_ROC_TIMEOUT - 50);
2040 if (!time_after(time_spare, wlvif->pending_auth_reply_time))
2041 goto out;
2042
2043 ret = wl1271_ps_elp_wakeup(wl);
2044 if (ret < 0)
2045 goto out;
2046
2047 /* cancel the ROC if active */
2048 wlcore_update_inconn_sta(wl, wlvif, NULL, false);
2049
2050 wl1271_ps_elp_sleep(wl);
2051out:
2052 mutex_unlock(&wl->mutex);
2053}
2054
2011static int wl12xx_allocate_rate_policy(struct wl1271 *wl, u8 *idx) 2055static int wl12xx_allocate_rate_policy(struct wl1271 *wl, u8 *idx)
2012{ 2056{
2013 u8 policy = find_first_zero_bit(wl->rate_policies_map, 2057 u8 policy = find_first_zero_bit(wl->rate_policies_map,
@@ -2159,6 +2203,8 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif)
2159 wlcore_channel_switch_work); 2203 wlcore_channel_switch_work);
2160 INIT_DELAYED_WORK(&wlvif->connection_loss_work, 2204 INIT_DELAYED_WORK(&wlvif->connection_loss_work,
2161 wlcore_connection_loss_work); 2205 wlcore_connection_loss_work);
2206 INIT_DELAYED_WORK(&wlvif->pending_auth_complete_work,
2207 wlcore_pending_auth_complete_work);
2162 INIT_LIST_HEAD(&wlvif->list); 2208 INIT_LIST_HEAD(&wlvif->list);
2163 2209
2164 setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, 2210 setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer,
@@ -2376,6 +2422,11 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
2376 int ret = 0; 2422 int ret = 0;
2377 u8 role_type; 2423 u8 role_type;
2378 2424
2425 if (wl->plt) {
2426 wl1271_error("Adding Interface not allowed while in PLT mode");
2427 return -EBUSY;
2428 }
2429
2379 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | 2430 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
2380 IEEE80211_VIF_SUPPORTS_CQM_RSSI; 2431 IEEE80211_VIF_SUPPORTS_CQM_RSSI;
2381 2432
@@ -2590,6 +2641,7 @@ unlock:
2590 cancel_work_sync(&wlvif->rx_streaming_disable_work); 2641 cancel_work_sync(&wlvif->rx_streaming_disable_work);
2591 cancel_delayed_work_sync(&wlvif->connection_loss_work); 2642 cancel_delayed_work_sync(&wlvif->connection_loss_work);
2592 cancel_delayed_work_sync(&wlvif->channel_switch_work); 2643 cancel_delayed_work_sync(&wlvif->channel_switch_work);
2644 cancel_delayed_work_sync(&wlvif->pending_auth_complete_work);
2593 2645
2594 mutex_lock(&wl->mutex); 2646 mutex_lock(&wl->mutex);
2595} 2647}
@@ -2875,6 +2927,25 @@ static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif)
2875 wlvif->rate_set = wlvif->basic_rate_set; 2927 wlvif->rate_set = wlvif->basic_rate_set;
2876} 2928}
2877 2929
2930static void wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2931 bool idle)
2932{
2933 bool cur_idle = !test_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags);
2934
2935 if (idle == cur_idle)
2936 return;
2937
2938 if (idle) {
2939 clear_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags);
2940 } else {
2941 /* The current firmware only supports sched_scan in idle */
2942 if (wl->sched_vif == wlvif)
2943 wl->ops->sched_scan_stop(wl, wlvif);
2944
2945 set_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags);
2946 }
2947}
2948
2878static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, 2949static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2879 struct ieee80211_conf *conf, u32 changed) 2950 struct ieee80211_conf *conf, u32 changed)
2880{ 2951{
@@ -3969,6 +4040,13 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl,
3969 } 4040 }
3970 } else { 4041 } else {
3971 if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { 4042 if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) {
4043 /*
4044 * AP might be in ROC in case we have just
4045 * sent auth reply. handle it.
4046 */
4047 if (test_bit(wlvif->role_id, wl->roc_map))
4048 wl12xx_croc(wl, wlvif->role_id);
4049
3972 ret = wl12xx_cmd_role_stop_ap(wl, wlvif); 4050 ret = wl12xx_cmd_role_stop_ap(wl, wlvif);
3973 if (ret < 0) 4051 if (ret < 0)
3974 goto out; 4052 goto out;
@@ -4120,6 +4198,9 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl,
4120 do_join = true; 4198 do_join = true;
4121 } 4199 }
4122 4200
4201 if (changed & BSS_CHANGED_IDLE && !is_ibss)
4202 wl1271_sta_handle_idle(wl, wlvif, bss_conf->idle);
4203
4123 if (changed & BSS_CHANGED_CQM) { 4204 if (changed & BSS_CHANGED_CQM) {
4124 bool enable = false; 4205 bool enable = false;
4125 if (bss_conf->cqm_rssi_thold) 4206 if (bss_conf->cqm_rssi_thold)
@@ -4656,29 +4737,49 @@ static void wlcore_roc_if_possible(struct wl1271 *wl,
4656 wl12xx_roc(wl, wlvif, wlvif->role_id, wlvif->band, wlvif->channel); 4737 wl12xx_roc(wl, wlvif, wlvif->role_id, wlvif->band, wlvif->channel);
4657} 4738}
4658 4739
4659static void wlcore_update_inconn_sta(struct wl1271 *wl, 4740/*
4660 struct wl12xx_vif *wlvif, 4741 * when wl_sta is NULL, we treat this call as if coming from a
4661 struct wl1271_station *wl_sta, 4742 * pending auth reply.
4662 bool in_connection) 4743 * wl->mutex must be taken and the FW must be awake when the call
4744 * takes place.
4745 */
4746void wlcore_update_inconn_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif,
4747 struct wl1271_station *wl_sta, bool in_conn)
4663{ 4748{
4664 if (in_connection) { 4749 if (in_conn) {
4665 if (WARN_ON(wl_sta->in_connection)) 4750 if (WARN_ON(wl_sta && wl_sta->in_connection))
4666 return; 4751 return;
4667 wl_sta->in_connection = true; 4752
4668 if (!wlvif->inconn_count++) 4753 if (!wlvif->ap_pending_auth_reply &&
4754 !wlvif->inconn_count)
4669 wlcore_roc_if_possible(wl, wlvif); 4755 wlcore_roc_if_possible(wl, wlvif);
4756
4757 if (wl_sta) {
4758 wl_sta->in_connection = true;
4759 wlvif->inconn_count++;
4760 } else {
4761 wlvif->ap_pending_auth_reply = true;
4762 }
4670 } else { 4763 } else {
4671 if (!wl_sta->in_connection) 4764 if (wl_sta && !wl_sta->in_connection)
4765 return;
4766
4767 if (WARN_ON(!wl_sta && !wlvif->ap_pending_auth_reply))
4672 return; 4768 return;
4673 4769
4674 wl_sta->in_connection = false; 4770 if (WARN_ON(wl_sta && !wlvif->inconn_count))
4675 wlvif->inconn_count--;
4676 if (WARN_ON(wlvif->inconn_count < 0))
4677 return; 4771 return;
4678 4772
4679 if (!wlvif->inconn_count) 4773 if (wl_sta) {
4680 if (test_bit(wlvif->role_id, wl->roc_map)) 4774 wl_sta->in_connection = false;
4681 wl12xx_croc(wl, wlvif->role_id); 4775 wlvif->inconn_count--;
4776 } else {
4777 wlvif->ap_pending_auth_reply = false;
4778 }
4779
4780 if (!wlvif->inconn_count && !wlvif->ap_pending_auth_reply &&
4781 test_bit(wlvif->role_id, wl->roc_map))
4782 wl12xx_croc(wl, wlvif->role_id);
4682 } 4783 }
4683} 4784}
4684 4785
@@ -5313,10 +5414,7 @@ static struct ieee80211_rate wl1271_rates_5ghz[] = {
5313 5414
5314/* 5 GHz band channels for WL1273 */ 5415/* 5 GHz band channels for WL1273 */
5315static struct ieee80211_channel wl1271_channels_5ghz[] = { 5416static struct ieee80211_channel wl1271_channels_5ghz[] = {
5316 { .hw_value = 7, .center_freq = 5035, .max_power = WLCORE_MAX_TXPWR },
5317 { .hw_value = 8, .center_freq = 5040, .max_power = WLCORE_MAX_TXPWR }, 5417 { .hw_value = 8, .center_freq = 5040, .max_power = WLCORE_MAX_TXPWR },
5318 { .hw_value = 9, .center_freq = 5045, .max_power = WLCORE_MAX_TXPWR },
5319 { .hw_value = 11, .center_freq = 5055, .max_power = WLCORE_MAX_TXPWR },
5320 { .hw_value = 12, .center_freq = 5060, .max_power = WLCORE_MAX_TXPWR }, 5418 { .hw_value = 12, .center_freq = 5060, .max_power = WLCORE_MAX_TXPWR },
5321 { .hw_value = 16, .center_freq = 5080, .max_power = WLCORE_MAX_TXPWR }, 5419 { .hw_value = 16, .center_freq = 5080, .max_power = WLCORE_MAX_TXPWR },
5322 { .hw_value = 34, .center_freq = 5170, .max_power = WLCORE_MAX_TXPWR }, 5420 { .hw_value = 34, .center_freq = 5170, .max_power = WLCORE_MAX_TXPWR },
@@ -5896,14 +5994,20 @@ static const struct wiphy_wowlan_support wlcore_wowlan_support = {
5896}; 5994};
5897#endif 5995#endif
5898 5996
5997static irqreturn_t wlcore_hardirq(int irq, void *cookie)
5998{
5999 return IRQ_WAKE_THREAD;
6000}
6001
5899static void wlcore_nvs_cb(const struct firmware *fw, void *context) 6002static void wlcore_nvs_cb(const struct firmware *fw, void *context)
5900{ 6003{
5901 struct wl1271 *wl = context; 6004 struct wl1271 *wl = context;
5902 struct platform_device *pdev = wl->pdev; 6005 struct platform_device *pdev = wl->pdev;
5903 struct wlcore_platdev_data *pdev_data = pdev->dev.platform_data; 6006 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&pdev->dev);
5904 struct wl12xx_platform_data *pdata = pdev_data->pdata; 6007 struct wl12xx_platform_data *pdata = pdev_data->pdata;
5905 unsigned long irqflags; 6008 unsigned long irqflags;
5906 int ret; 6009 int ret;
6010 irq_handler_t hardirq_fn = NULL;
5907 6011
5908 if (fw) { 6012 if (fw) {
5909 wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL); 6013 wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
@@ -5932,12 +6036,14 @@ static void wlcore_nvs_cb(const struct firmware *fw, void *context)
5932 wl->platform_quirks = pdata->platform_quirks; 6036 wl->platform_quirks = pdata->platform_quirks;
5933 wl->if_ops = pdev_data->if_ops; 6037 wl->if_ops = pdev_data->if_ops;
5934 6038
5935 if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) 6039 if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) {
5936 irqflags = IRQF_TRIGGER_RISING; 6040 irqflags = IRQF_TRIGGER_RISING;
5937 else 6041 hardirq_fn = wlcore_hardirq;
6042 } else {
5938 irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; 6043 irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
6044 }
5939 6045
5940 ret = request_threaded_irq(wl->irq, NULL, wlcore_irq, 6046 ret = request_threaded_irq(wl->irq, hardirq_fn, wlcore_irq,
5941 irqflags, pdev->name, wl); 6047 irqflags, pdev->name, wl);
5942 if (ret < 0) { 6048 if (ret < 0) {
5943 wl1271_error("request_irq() failed: %d", ret); 6049 wl1271_error("request_irq() failed: %d", ret);
diff --git a/drivers/net/wireless/ti/wlcore/ps.c b/drivers/net/wireless/ti/wlcore/ps.c
index 98066d40c2ad..26bfc365ba70 100644
--- a/drivers/net/wireless/ti/wlcore/ps.c
+++ b/drivers/net/wireless/ti/wlcore/ps.c
@@ -83,6 +83,10 @@ void wl1271_ps_elp_sleep(struct wl1271 *wl)
83 struct wl12xx_vif *wlvif; 83 struct wl12xx_vif *wlvif;
84 u32 timeout; 84 u32 timeout;
85 85
86 /* We do not enter elp sleep in PLT mode */
87 if (wl->plt)
88 return;
89
86 if (wl->sleep_auth != WL1271_PSM_ELP) 90 if (wl->sleep_auth != WL1271_PSM_ELP)
87 return; 91 return;
88 92
diff --git a/drivers/net/wireless/ti/wlcore/scan.c b/drivers/net/wireless/ti/wlcore/scan.c
index f407101e525b..13e743df2e31 100644
--- a/drivers/net/wireless/ti/wlcore/scan.c
+++ b/drivers/net/wireless/ti/wlcore/scan.c
@@ -174,17 +174,7 @@ wlcore_scan_get_channels(struct wl1271 *wl,
174 /* if radar is set, we ignore the passive flag */ 174 /* if radar is set, we ignore the passive flag */
175 (radar || 175 (radar ||
176 !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) { 176 !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
177 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ", 177
178 req_channels[i]->band,
179 req_channels[i]->center_freq);
180 wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
181 req_channels[i]->hw_value,
182 req_channels[i]->flags);
183 wl1271_debug(DEBUG_SCAN, "max_power %d",
184 req_channels[i]->max_power);
185 wl1271_debug(DEBUG_SCAN, "min_dwell_time %d max dwell time %d",
186 min_dwell_time_active,
187 max_dwell_time_active);
188 178
189 if (flags & IEEE80211_CHAN_RADAR) { 179 if (flags & IEEE80211_CHAN_RADAR) {
190 channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS; 180 channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
@@ -222,6 +212,17 @@ wlcore_scan_get_channels(struct wl1271 *wl,
222 *n_pactive_ch); 212 *n_pactive_ch);
223 } 213 }
224 214
215 wl1271_debug(DEBUG_SCAN, "freq %d, ch. %d, flags 0x%x, power %d, min/max_dwell %d/%d%s%s",
216 req_channels[i]->center_freq,
217 req_channels[i]->hw_value,
218 req_channels[i]->flags,
219 req_channels[i]->max_power,
220 min_dwell_time_active,
221 max_dwell_time_active,
222 flags & IEEE80211_CHAN_RADAR ?
223 ", DFS" : "",
224 flags & IEEE80211_CHAN_PASSIVE_SCAN ?
225 ", PASSIVE" : "");
225 j++; 226 j++;
226 } 227 }
227 } 228 }
@@ -364,7 +365,7 @@ wlcore_scan_sched_scan_ssid_list(struct wl1271 *wl,
364 struct cfg80211_ssid *ssids = req->ssids; 365 struct cfg80211_ssid *ssids = req->ssids;
365 int ret = 0, type, i, j, n_match_ssids = 0; 366 int ret = 0, type, i, j, n_match_ssids = 0;
366 367
367 wl1271_debug(DEBUG_CMD, "cmd sched scan ssid list"); 368 wl1271_debug((DEBUG_CMD | DEBUG_SCAN), "cmd sched scan ssid list");
368 369
369 /* count the match sets that contain SSIDs */ 370 /* count the match sets that contain SSIDs */
370 for (i = 0; i < req->n_match_sets; i++) 371 for (i = 0; i < req->n_match_sets; i++)
@@ -442,8 +443,6 @@ wlcore_scan_sched_scan_ssid_list(struct wl1271 *wl,
442 } 443 }
443 } 444 }
444 445
445 wl1271_dump(DEBUG_SCAN, "SSID_LIST: ", cmd, sizeof(*cmd));
446
447 ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_SSID_CFG, cmd, 446 ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_SSID_CFG, cmd,
448 sizeof(*cmd), 0); 447 sizeof(*cmd), 0);
449 if (ret < 0) { 448 if (ret < 0) {
diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c
index 1b0cd98e35f1..b2c018dccf18 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -335,7 +335,7 @@ static int wl1271_probe(struct spi_device *spi)
335 if (!pdev_data) 335 if (!pdev_data)
336 goto out; 336 goto out;
337 337
338 pdev_data->pdata = spi->dev.platform_data; 338 pdev_data->pdata = dev_get_platdata(&spi->dev);
339 if (!pdev_data->pdata) { 339 if (!pdev_data->pdata) {
340 dev_err(&spi->dev, "no platform data\n"); 340 dev_err(&spi->dev, "no platform data\n");
341 ret = -ENODEV; 341 ret = -ENODEV;
diff --git a/drivers/net/wireless/ti/wlcore/testmode.c b/drivers/net/wireless/ti/wlcore/testmode.c
index 527590f2adfb..a3b7d950d8e9 100644
--- a/drivers/net/wireless/ti/wlcore/testmode.c
+++ b/drivers/net/wireless/ti/wlcore/testmode.c
@@ -297,7 +297,8 @@ static int wl1271_tm_cmd_set_plt_mode(struct wl1271 *wl, struct nlattr *tb[])
297 ret = wl1271_plt_stop(wl); 297 ret = wl1271_plt_stop(wl);
298 break; 298 break;
299 case PLT_ON: 299 case PLT_ON:
300 ret = wl1271_plt_start(wl, PLT_ON); 300 case PLT_CHIP_AWAKE:
301 ret = wl1271_plt_start(wl, val);
301 break; 302 break;
302 case PLT_FEM_DETECT: 303 case PLT_FEM_DETECT:
303 ret = wl1271_tm_detect_fem(wl, tb); 304 ret = wl1271_tm_detect_fem(wl, tb);
@@ -361,6 +362,7 @@ int wl1271_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
361{ 362{
362 struct wl1271 *wl = hw->priv; 363 struct wl1271 *wl = hw->priv;
363 struct nlattr *tb[WL1271_TM_ATTR_MAX + 1]; 364 struct nlattr *tb[WL1271_TM_ATTR_MAX + 1];
365 u32 nla_cmd;
364 int err; 366 int err;
365 367
366 err = nla_parse(tb, WL1271_TM_ATTR_MAX, data, len, wl1271_tm_policy); 368 err = nla_parse(tb, WL1271_TM_ATTR_MAX, data, len, wl1271_tm_policy);
@@ -370,7 +372,14 @@ int wl1271_tm_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
370 if (!tb[WL1271_TM_ATTR_CMD_ID]) 372 if (!tb[WL1271_TM_ATTR_CMD_ID])
371 return -EINVAL; 373 return -EINVAL;
372 374
373 switch (nla_get_u32(tb[WL1271_TM_ATTR_CMD_ID])) { 375 nla_cmd = nla_get_u32(tb[WL1271_TM_ATTR_CMD_ID]);
376
377 /* Only SET_PLT_MODE is allowed in case of mode PLT_CHIP_AWAKE */
378 if (wl->plt_mode == PLT_CHIP_AWAKE &&
379 nla_cmd != WL1271_TM_CMD_SET_PLT_MODE)
380 return -EOPNOTSUPP;
381
382 switch (nla_cmd) {
374 case WL1271_TM_CMD_TEST: 383 case WL1271_TM_CMD_TEST:
375 return wl1271_tm_cmd_test(wl, tb); 384 return wl1271_tm_cmd_test(wl, tb);
376 case WL1271_TM_CMD_INTERROGATE: 385 case WL1271_TM_CMD_INTERROGATE:
diff --git a/drivers/net/wireless/ti/wlcore/tx.c b/drivers/net/wireless/ti/wlcore/tx.c
index 7e93fe63a2c7..87cd707affa2 100644
--- a/drivers/net/wireless/ti/wlcore/tx.c
+++ b/drivers/net/wireless/ti/wlcore/tx.c
@@ -86,19 +86,34 @@ void wl1271_free_tx_id(struct wl1271 *wl, int id)
86EXPORT_SYMBOL(wl1271_free_tx_id); 86EXPORT_SYMBOL(wl1271_free_tx_id);
87 87
88static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl, 88static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl,
89 struct wl12xx_vif *wlvif,
89 struct sk_buff *skb) 90 struct sk_buff *skb)
90{ 91{
91 struct ieee80211_hdr *hdr; 92 struct ieee80211_hdr *hdr;
92 93
94 hdr = (struct ieee80211_hdr *)(skb->data +
95 sizeof(struct wl1271_tx_hw_descr));
96 if (!ieee80211_is_auth(hdr->frame_control))
97 return;
98
93 /* 99 /*
94 * add the station to the known list before transmitting the 100 * add the station to the known list before transmitting the
95 * authentication response. this way it won't get de-authed by FW 101 * authentication response. this way it won't get de-authed by FW
96 * when transmitting too soon. 102 * when transmitting too soon.
97 */ 103 */
98 hdr = (struct ieee80211_hdr *)(skb->data + 104 wl1271_acx_set_inconnection_sta(wl, hdr->addr1);
99 sizeof(struct wl1271_tx_hw_descr)); 105
100 if (ieee80211_is_auth(hdr->frame_control)) 106 /*
101 wl1271_acx_set_inconnection_sta(wl, hdr->addr1); 107 * ROC for 1 second on the AP channel for completing the connection.
108 * Note the ROC will be continued by the update_sta_state callbacks
109 * once the station reaches the associated state.
110 */
111 wlcore_update_inconn_sta(wl, wlvif, NULL, true);
112 wlvif->pending_auth_reply_time = jiffies;
113 cancel_delayed_work(&wlvif->pending_auth_complete_work);
114 ieee80211_queue_delayed_work(wl->hw,
115 &wlvif->pending_auth_complete_work,
116 msecs_to_jiffies(WLCORE_PEND_AUTH_ROC_TIMEOUT));
102} 117}
103 118
104static void wl1271_tx_regulate_link(struct wl1271 *wl, 119static void wl1271_tx_regulate_link(struct wl1271 *wl,
@@ -386,7 +401,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif,
386 is_wep = (cipher == WLAN_CIPHER_SUITE_WEP40) || 401 is_wep = (cipher == WLAN_CIPHER_SUITE_WEP40) ||
387 (cipher == WLAN_CIPHER_SUITE_WEP104); 402 (cipher == WLAN_CIPHER_SUITE_WEP104);
388 403
389 if (WARN_ON(is_wep && wlvif->default_key != idx)) { 404 if (WARN_ON(is_wep && wlvif && wlvif->default_key != idx)) {
390 ret = wl1271_set_default_wep_key(wl, wlvif, idx); 405 ret = wl1271_set_default_wep_key(wl, wlvif, idx);
391 if (ret < 0) 406 if (ret < 0)
392 return ret; 407 return ret;
@@ -404,7 +419,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif,
404 wl1271_tx_fill_hdr(wl, wlvif, skb, extra, info, hlid); 419 wl1271_tx_fill_hdr(wl, wlvif, skb, extra, info, hlid);
405 420
406 if (!is_dummy && wlvif && wlvif->bss_type == BSS_TYPE_AP_BSS) { 421 if (!is_dummy && wlvif && wlvif->bss_type == BSS_TYPE_AP_BSS) {
407 wl1271_tx_ap_update_inconnection_sta(wl, skb); 422 wl1271_tx_ap_update_inconnection_sta(wl, wlvif, skb);
408 wl1271_tx_regulate_link(wl, wlvif, hlid); 423 wl1271_tx_regulate_link(wl, wlvif, hlid);
409 } 424 }
410 425
diff --git a/drivers/net/wireless/ti/wlcore/tx.h b/drivers/net/wireless/ti/wlcore/tx.h
index 55aa4acf9105..35489c300da1 100644
--- a/drivers/net/wireless/ti/wlcore/tx.h
+++ b/drivers/net/wireless/ti/wlcore/tx.h
@@ -56,6 +56,9 @@
56/* Used for management frames and dummy packets */ 56/* Used for management frames and dummy packets */
57#define WL1271_TID_MGMT 7 57#define WL1271_TID_MGMT 7
58 58
59/* stop a ROC for pending authentication reply after this time (ms) */
60#define WLCORE_PEND_AUTH_ROC_TIMEOUT 1000
61
59struct wl127x_tx_mem { 62struct wl127x_tx_mem {
60 /* 63 /*
61 * Number of extra memory blocks to allocate for this packet 64 * Number of extra memory blocks to allocate for this packet
diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h
index 0034979e97cb..54ce5d5e84db 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore.h
@@ -481,6 +481,8 @@ int wlcore_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
481 struct ieee80211_sta *sta, 481 struct ieee80211_sta *sta,
482 struct ieee80211_key_conf *key_conf); 482 struct ieee80211_key_conf *key_conf);
483void wlcore_regdomain_config(struct wl1271 *wl); 483void wlcore_regdomain_config(struct wl1271 *wl);
484void wlcore_update_inconn_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif,
485 struct wl1271_station *wl_sta, bool in_conn);
484 486
485static inline void 487static inline void
486wlcore_set_ht_cap(struct wl1271 *wl, enum ieee80211_band band, 488wlcore_set_ht_cap(struct wl1271 *wl, enum ieee80211_band band,
diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h
index e5e146435fe7..2a50e089b0e7 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore_i.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h
@@ -255,6 +255,7 @@ enum wl12xx_vif_flags {
255 WLVIF_FLAG_CS_PROGRESS, 255 WLVIF_FLAG_CS_PROGRESS,
256 WLVIF_FLAG_AP_PROBE_RESP_SET, 256 WLVIF_FLAG_AP_PROBE_RESP_SET,
257 WLVIF_FLAG_IN_USE, 257 WLVIF_FLAG_IN_USE,
258 WLVIF_FLAG_ACTIVE,
258}; 259};
259 260
260struct wl12xx_vif; 261struct wl12xx_vif;
@@ -307,6 +308,7 @@ enum plt_mode {
307 PLT_OFF = 0, 308 PLT_OFF = 0,
308 PLT_ON = 1, 309 PLT_ON = 1,
309 PLT_FEM_DETECT = 2, 310 PLT_FEM_DETECT = 2,
311 PLT_CHIP_AWAKE = 3
310}; 312};
311 313
312struct wl12xx_rx_filter_field { 314struct wl12xx_rx_filter_field {
@@ -456,6 +458,15 @@ struct wl12xx_vif {
456 */ 458 */
457 int hw_queue_base; 459 int hw_queue_base;
458 460
461 /* do we have a pending auth reply? (and ROC) */
462 bool ap_pending_auth_reply;
463
464 /* time when we sent the pending auth reply */
465 unsigned long pending_auth_reply_time;
466
467 /* work for canceling ROC after pending auth reply */
468 struct delayed_work pending_auth_complete_work;
469
459 /* 470 /*
460 * This struct must be last! 471 * This struct must be last!
461 * data that has to be saved acrossed reconfigs (e.g. recovery) 472 * data that has to be saved acrossed reconfigs (e.g. recovery)
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index a1977430ddfb..5715318d6bab 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -184,6 +184,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
184 unsigned long rx_ring_ref, unsigned int tx_evtchn, 184 unsigned long rx_ring_ref, unsigned int tx_evtchn,
185 unsigned int rx_evtchn); 185 unsigned int rx_evtchn);
186void xenvif_disconnect(struct xenvif *vif); 186void xenvif_disconnect(struct xenvif *vif);
187void xenvif_free(struct xenvif *vif);
187 188
188int xenvif_xenbus_init(void); 189int xenvif_xenbus_init(void);
189void xenvif_xenbus_fini(void); 190void xenvif_xenbus_fini(void);
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 625c6f49cfba..01bb854c7f62 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -353,6 +353,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
353 } 353 }
354 354
355 netdev_dbg(dev, "Successfully created xenvif\n"); 355 netdev_dbg(dev, "Successfully created xenvif\n");
356
357 __module_get(THIS_MODULE);
358
356 return vif; 359 return vif;
357} 360}
358 361
@@ -366,8 +369,6 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
366 if (vif->tx_irq) 369 if (vif->tx_irq)
367 return 0; 370 return 0;
368 371
369 __module_get(THIS_MODULE);
370
371 err = xenvif_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref); 372 err = xenvif_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref);
372 if (err < 0) 373 if (err < 0)
373 goto err; 374 goto err;
@@ -406,7 +407,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
406 407
407 init_waitqueue_head(&vif->wq); 408 init_waitqueue_head(&vif->wq);
408 vif->task = kthread_create(xenvif_kthread, 409 vif->task = kthread_create(xenvif_kthread,
409 (void *)vif, vif->dev->name); 410 (void *)vif, "%s", vif->dev->name);
410 if (IS_ERR(vif->task)) { 411 if (IS_ERR(vif->task)) {
411 pr_warn("Could not allocate kthread for %s\n", vif->dev->name); 412 pr_warn("Could not allocate kthread for %s\n", vif->dev->name);
412 err = PTR_ERR(vif->task); 413 err = PTR_ERR(vif->task);
@@ -452,12 +453,6 @@ void xenvif_carrier_off(struct xenvif *vif)
452 453
453void xenvif_disconnect(struct xenvif *vif) 454void xenvif_disconnect(struct xenvif *vif)
454{ 455{
455 /* Disconnect funtion might get called by generic framework
456 * even before vif connects, so we need to check if we really
457 * need to do a module_put.
458 */
459 int need_module_put = 0;
460
461 if (netif_carrier_ok(vif->dev)) 456 if (netif_carrier_ok(vif->dev))
462 xenvif_carrier_off(vif); 457 xenvif_carrier_off(vif);
463 458
@@ -468,23 +463,22 @@ void xenvif_disconnect(struct xenvif *vif)
468 unbind_from_irqhandler(vif->tx_irq, vif); 463 unbind_from_irqhandler(vif->tx_irq, vif);
469 unbind_from_irqhandler(vif->rx_irq, vif); 464 unbind_from_irqhandler(vif->rx_irq, vif);
470 } 465 }
471 /* vif->irq is valid, we had a module_get in 466 vif->tx_irq = 0;
472 * xenvif_connect.
473 */
474 need_module_put = 1;
475 } 467 }
476 468
477 if (vif->task) 469 if (vif->task)
478 kthread_stop(vif->task); 470 kthread_stop(vif->task);
479 471
472 xenvif_unmap_frontend_rings(vif);
473}
474
475void xenvif_free(struct xenvif *vif)
476{
480 netif_napi_del(&vif->napi); 477 netif_napi_del(&vif->napi);
481 478
482 unregister_netdev(vif->dev); 479 unregister_netdev(vif->dev);
483 480
484 xenvif_unmap_frontend_rings(vif);
485
486 free_netdev(vif->dev); 481 free_netdev(vif->dev);
487 482
488 if (need_module_put) 483 module_put(THIS_MODULE);
489 module_put(THIS_MODULE);
490} 484}
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 956130c70036..f3e591c611de 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -212,6 +212,49 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head)
212 return false; 212 return false;
213} 213}
214 214
215struct xenvif_count_slot_state {
216 unsigned long copy_off;
217 bool head;
218};
219
220unsigned int xenvif_count_frag_slots(struct xenvif *vif,
221 unsigned long offset, unsigned long size,
222 struct xenvif_count_slot_state *state)
223{
224 unsigned count = 0;
225
226 offset &= ~PAGE_MASK;
227
228 while (size > 0) {
229 unsigned long bytes;
230
231 bytes = PAGE_SIZE - offset;
232
233 if (bytes > size)
234 bytes = size;
235
236 if (start_new_rx_buffer(state->copy_off, bytes, state->head)) {
237 count++;
238 state->copy_off = 0;
239 }
240
241 if (state->copy_off + bytes > MAX_BUFFER_OFFSET)
242 bytes = MAX_BUFFER_OFFSET - state->copy_off;
243
244 state->copy_off += bytes;
245
246 offset += bytes;
247 size -= bytes;
248
249 if (offset == PAGE_SIZE)
250 offset = 0;
251
252 state->head = false;
253 }
254
255 return count;
256}
257
215/* 258/*
216 * Figure out how many ring slots we're going to need to send @skb to 259 * Figure out how many ring slots we're going to need to send @skb to
217 * the guest. This function is essentially a dry run of 260 * the guest. This function is essentially a dry run of
@@ -219,48 +262,39 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head)
219 */ 262 */
220unsigned int xenvif_count_skb_slots(struct xenvif *vif, struct sk_buff *skb) 263unsigned int xenvif_count_skb_slots(struct xenvif *vif, struct sk_buff *skb)
221{ 264{
265 struct xenvif_count_slot_state state;
222 unsigned int count; 266 unsigned int count;
223 int i, copy_off; 267 unsigned char *data;
268 unsigned i;
224 269
225 count = DIV_ROUND_UP(skb_headlen(skb), PAGE_SIZE); 270 state.head = true;
271 state.copy_off = 0;
226 272
227 copy_off = skb_headlen(skb) % PAGE_SIZE; 273 /* Slot for the first (partial) page of data. */
274 count = 1;
228 275
276 /* Need a slot for the GSO prefix for GSO extra data? */
229 if (skb_shinfo(skb)->gso_size) 277 if (skb_shinfo(skb)->gso_size)
230 count++; 278 count++;
231 279
232 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 280 data = skb->data;
233 unsigned long size = skb_frag_size(&skb_shinfo(skb)->frags[i]); 281 while (data < skb_tail_pointer(skb)) {
234 unsigned long offset = skb_shinfo(skb)->frags[i].page_offset; 282 unsigned long offset = offset_in_page(data);
235 unsigned long bytes; 283 unsigned long size = PAGE_SIZE - offset;
236
237 offset &= ~PAGE_MASK;
238
239 while (size > 0) {
240 BUG_ON(offset >= PAGE_SIZE);
241 BUG_ON(copy_off > MAX_BUFFER_OFFSET);
242
243 bytes = PAGE_SIZE - offset;
244
245 if (bytes > size)
246 bytes = size;
247 284
248 if (start_new_rx_buffer(copy_off, bytes, 0)) { 285 if (data + size > skb_tail_pointer(skb))
249 count++; 286 size = skb_tail_pointer(skb) - data;
250 copy_off = 0;
251 }
252 287
253 if (copy_off + bytes > MAX_BUFFER_OFFSET) 288 count += xenvif_count_frag_slots(vif, offset, size, &state);
254 bytes = MAX_BUFFER_OFFSET - copy_off;
255 289
256 copy_off += bytes; 290 data += size;
291 }
257 292
258 offset += bytes; 293 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
259 size -= bytes; 294 unsigned long size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
295 unsigned long offset = skb_shinfo(skb)->frags[i].page_offset;
260 296
261 if (offset == PAGE_SIZE) 297 count += xenvif_count_frag_slots(vif, offset, size, &state);
262 offset = 0;
263 }
264 } 298 }
265 return count; 299 return count;
266} 300}
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 1fe48fe364ed..a53782ef1540 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -42,7 +42,7 @@ static int netback_remove(struct xenbus_device *dev)
42 if (be->vif) { 42 if (be->vif) {
43 kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE); 43 kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
44 xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status"); 44 xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
45 xenvif_disconnect(be->vif); 45 xenvif_free(be->vif);
46 be->vif = NULL; 46 be->vif = NULL;
47 } 47 }
48 kfree(be); 48 kfree(be);
@@ -213,9 +213,18 @@ static void disconnect_backend(struct xenbus_device *dev)
213{ 213{
214 struct backend_info *be = dev_get_drvdata(&dev->dev); 214 struct backend_info *be = dev_get_drvdata(&dev->dev);
215 215
216 if (be->vif)
217 xenvif_disconnect(be->vif);
218}
219
220static void destroy_backend(struct xenbus_device *dev)
221{
222 struct backend_info *be = dev_get_drvdata(&dev->dev);
223
216 if (be->vif) { 224 if (be->vif) {
225 kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
217 xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status"); 226 xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
218 xenvif_disconnect(be->vif); 227 xenvif_free(be->vif);
219 be->vif = NULL; 228 be->vif = NULL;
220 } 229 }
221} 230}
@@ -246,14 +255,11 @@ static void frontend_changed(struct xenbus_device *dev,
246 case XenbusStateConnected: 255 case XenbusStateConnected:
247 if (dev->state == XenbusStateConnected) 256 if (dev->state == XenbusStateConnected)
248 break; 257 break;
249 backend_create_xenvif(be);
250 if (be->vif) 258 if (be->vif)
251 connect(be); 259 connect(be);
252 break; 260 break;
253 261
254 case XenbusStateClosing: 262 case XenbusStateClosing:
255 if (be->vif)
256 kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
257 disconnect_backend(dev); 263 disconnect_backend(dev);
258 xenbus_switch_state(dev, XenbusStateClosing); 264 xenbus_switch_state(dev, XenbusStateClosing);
259 break; 265 break;
@@ -262,6 +268,7 @@ static void frontend_changed(struct xenbus_device *dev,
262 xenbus_switch_state(dev, XenbusStateClosed); 268 xenbus_switch_state(dev, XenbusStateClosed);
263 if (xenbus_dev_is_online(dev)) 269 if (xenbus_dev_is_online(dev))
264 break; 270 break;
271 destroy_backend(dev);
265 /* fall through if not online */ 272 /* fall through if not online */
266 case XenbusStateUnknown: 273 case XenbusStateUnknown:
267 device_unregister(&dev->dev); 274 device_unregister(&dev->dev);
diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 08b22a901c25..d7ca9305ff45 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -105,7 +105,7 @@
105#define BNX2FC_RQ_WQE_SIZE (BNX2FC_RQ_BUF_SZ) 105#define BNX2FC_RQ_WQE_SIZE (BNX2FC_RQ_BUF_SZ)
106#define BNX2FC_XFERQ_WQE_SIZE (sizeof(struct fcoe_xfrqe)) 106#define BNX2FC_XFERQ_WQE_SIZE (sizeof(struct fcoe_xfrqe))
107#define BNX2FC_CONFQ_WQE_SIZE (sizeof(struct fcoe_confqe)) 107#define BNX2FC_CONFQ_WQE_SIZE (sizeof(struct fcoe_confqe))
108#define BNX2FC_5771X_DB_PAGE_SIZE 128 108#define BNX2X_DB_SHIFT 3
109 109
110#define BNX2FC_TASK_SIZE 128 110#define BNX2FC_TASK_SIZE 128
111#define BNX2FC_TASKS_PER_PAGE (PAGE_SIZE/BNX2FC_TASK_SIZE) 111#define BNX2FC_TASKS_PER_PAGE (PAGE_SIZE/BNX2FC_TASK_SIZE)
diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index c0d035a8f8f9..46a37657307f 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -1421,8 +1421,7 @@ int bnx2fc_map_doorbell(struct bnx2fc_rport *tgt)
1421 1421
1422 reg_base = pci_resource_start(hba->pcidev, 1422 reg_base = pci_resource_start(hba->pcidev,
1423 BNX2X_DOORBELL_PCI_BAR); 1423 BNX2X_DOORBELL_PCI_BAR);
1424 reg_off = BNX2FC_5771X_DB_PAGE_SIZE * 1424 reg_off = (1 << BNX2X_DB_SHIFT) * (context_id & 0x1FFFF);
1425 (context_id & 0x1FFFF) + DPM_TRIGER_TYPE;
1426 tgt->ctx_base = ioremap_nocache(reg_base + reg_off, 4); 1425 tgt->ctx_base = ioremap_nocache(reg_base + reg_off, 4);
1427 if (!tgt->ctx_base) 1426 if (!tgt->ctx_base)
1428 return -ENOMEM; 1427 return -ENOMEM;
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 6940f0930a84..c73bbcb63c02 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -64,7 +64,7 @@
64#define MAX_PAGES_PER_CTRL_STRUCT_POOL 8 64#define MAX_PAGES_PER_CTRL_STRUCT_POOL 8
65#define BNX2I_RESERVED_SLOW_PATH_CMD_SLOTS 4 65#define BNX2I_RESERVED_SLOW_PATH_CMD_SLOTS 4
66 66
67#define BNX2I_5771X_DBELL_PAGE_SIZE 128 67#define BNX2X_DB_SHIFT 3
68 68
69/* 5706/08 hardware has limit on maximum buffer size per BD it can handle */ 69/* 5706/08 hardware has limit on maximum buffer size per BD it can handle */
70#define MAX_BD_LENGTH 65535 70#define MAX_BD_LENGTH 65535
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index af3e675d4d48..5be718c241c4 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -2738,8 +2738,7 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
2738 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { 2738 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) {
2739 reg_base = pci_resource_start(ep->hba->pcidev, 2739 reg_base = pci_resource_start(ep->hba->pcidev,
2740 BNX2X_DOORBELL_PCI_BAR); 2740 BNX2X_DOORBELL_PCI_BAR);
2741 reg_off = BNX2I_5771X_DBELL_PAGE_SIZE * (cid_num & 0x1FFFF) + 2741 reg_off = (1 << BNX2X_DB_SHIFT) * (cid_num & 0x1FFFF);
2742 DPM_TRIGER_TYPE;
2743 ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, 4); 2742 ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, 4);
2744 goto arm_cq; 2743 goto arm_cq;
2745 } 2744 }
diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c
index 78b6cb743769..199059d64c9b 100644
--- a/drivers/staging/octeon/ethernet-mem.c
+++ b/drivers/staging/octeon/ethernet-mem.c
@@ -48,13 +48,8 @@ static int cvm_oct_fill_hw_skbuff(int pool, int size, int elements)
48 while (freed) { 48 while (freed) {
49 49
50 struct sk_buff *skb = dev_alloc_skb(size + 256); 50 struct sk_buff *skb = dev_alloc_skb(size + 256);
51 if (unlikely(skb == NULL)) { 51 if (unlikely(skb == NULL))
52 pr_warning
53 ("Failed to allocate skb for hardware pool %d\n",
54 pool);
55 break; 52 break;
56 }
57
58 skb_reserve(skb, 256 - (((unsigned long)skb->data) & 0x7f)); 53 skb_reserve(skb, 256 - (((unsigned long)skb->data) & 0x7f));
59 *(struct sk_buff **)(skb->data - sizeof(void *)) = skb; 54 *(struct sk_buff **)(skb->data - sizeof(void *)) = skb;
60 cvmx_fpa_free(skb->data, pool, DONT_WRITEBACK(size / 128)); 55 cvmx_fpa_free(skb->data, pool, DONT_WRITEBACK(size / 128));
diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c
index d8f5f694ec35..ea53af30dfa7 100644
--- a/drivers/staging/octeon/ethernet-rgmii.c
+++ b/drivers/staging/octeon/ethernet-rgmii.c
@@ -373,9 +373,7 @@ int cvm_oct_rgmii_init(struct net_device *dev)
373 * Enable interrupts on inband status changes 373 * Enable interrupts on inband status changes
374 * for this port. 374 * for this port.
375 */ 375 */
376 gmx_rx_int_en.u64 = 376 gmx_rx_int_en.u64 = 0;
377 cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
378 (index, interface));
379 gmx_rx_int_en.s.phy_dupx = 1; 377 gmx_rx_int_en.s.phy_dupx = 1;
380 gmx_rx_int_en.s.phy_link = 1; 378 gmx_rx_int_en.s.phy_link = 1;
381 gmx_rx_int_en.s.phy_spd = 1; 379 gmx_rx_int_en.s.phy_spd = 1;
diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index 34afc16bc493..e14a1bb04361 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -303,6 +303,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
303 if (backlog > budget * cores_in_use && napi != NULL) 303 if (backlog > budget * cores_in_use && napi != NULL)
304 cvm_oct_enable_one_cpu(); 304 cvm_oct_enable_one_cpu();
305 } 305 }
306 rx_count++;
306 307
307 skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1; 308 skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1;
308 if (likely(skb_in_hw)) { 309 if (likely(skb_in_hw)) {
@@ -336,9 +337,6 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
336 */ 337 */
337 skb = dev_alloc_skb(work->len); 338 skb = dev_alloc_skb(work->len);
338 if (!skb) { 339 if (!skb) {
339 printk_ratelimited("Port %d failed to allocate "
340 "skbuff, packet dropped\n",
341 work->ipprt);
342 cvm_oct_free_work(work); 340 cvm_oct_free_work(work);
343 continue; 341 continue;
344 } 342 }
@@ -429,7 +427,6 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
429#endif 427#endif
430 } 428 }
431 netif_receive_skb(skb); 429 netif_receive_skb(skb);
432 rx_count++;
433 } else { 430 } else {
434 /* Drop any packet received for a device that isn't up */ 431 /* Drop any packet received for a device that isn't up */
435 /* 432 /*
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index a9355ce1c6d5..3a1a01af9a80 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -854,7 +854,8 @@ void disassociate_ctty(int on_exit)
854 struct pid *tty_pgrp = tty_get_pgrp(tty); 854 struct pid *tty_pgrp = tty_get_pgrp(tty);
855 if (tty_pgrp) { 855 if (tty_pgrp) {
856 kill_pgrp(tty_pgrp, SIGHUP, on_exit); 856 kill_pgrp(tty_pgrp, SIGHUP, on_exit);
857 kill_pgrp(tty_pgrp, SIGCONT, on_exit); 857 if (!on_exit)
858 kill_pgrp(tty_pgrp, SIGCONT, on_exit);
858 put_pid(tty_pgrp); 859 put_pid(tty_pgrp);
859 } 860 }
860 } 861 }
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 58e6cbce4156..08f2e1e9a7e6 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -603,10 +603,11 @@ static int v9fs_cache_register(void)
603 if (ret < 0) 603 if (ret < 0)
604 return ret; 604 return ret;
605#ifdef CONFIG_9P_FSCACHE 605#ifdef CONFIG_9P_FSCACHE
606 return fscache_register_netfs(&v9fs_cache_netfs); 606 ret = fscache_register_netfs(&v9fs_cache_netfs);
607#else 607 if (ret < 0)
608 return ret; 608 v9fs_destroy_inode_cache();
609#endif 609#endif
610 return ret;
610} 611}
611 612
612static void v9fs_cache_unregister(void) 613static void v9fs_cache_unregister(void)
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 53687bbf2296..a7c481402c46 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -267,14 +267,8 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
267 } 267 }
268 268
269 /* Only creates */ 269 /* Only creates */
270 if (!(flags & O_CREAT)) 270 if (!(flags & O_CREAT) || dentry->d_inode)
271 return finish_no_open(file, res); 271 return finish_no_open(file, res);
272 else if (dentry->d_inode) {
273 if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
274 return -EEXIST;
275 else
276 return finish_no_open(file, res);
277 }
278 272
279 v9ses = v9fs_inode2v9ses(dir); 273 v9ses = v9fs_inode2v9ses(dir);
280 274
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 3db70dae40d3..689e40d983ad 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -109,13 +109,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
109 109
110 pkt.hdr.proto_version = sbi->version; 110 pkt.hdr.proto_version = sbi->version;
111 pkt.hdr.type = type; 111 pkt.hdr.type = type;
112 mutex_lock(&sbi->wq_mutex);
113 112
114 /* Check if we have become catatonic */
115 if (sbi->catatonic) {
116 mutex_unlock(&sbi->wq_mutex);
117 return;
118 }
119 switch (type) { 113 switch (type) {
120 /* Kernel protocol v4 missing and expire packets */ 114 /* Kernel protocol v4 missing and expire packets */
121 case autofs_ptype_missing: 115 case autofs_ptype_missing:
@@ -427,7 +421,6 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
427 wq->tgid = current->tgid; 421 wq->tgid = current->tgid;
428 wq->status = -EINTR; /* Status return if interrupted */ 422 wq->status = -EINTR; /* Status return if interrupted */
429 wq->wait_ctr = 2; 423 wq->wait_ctr = 2;
430 mutex_unlock(&sbi->wq_mutex);
431 424
432 if (sbi->version < 5) { 425 if (sbi->version < 5) {
433 if (notify == NFY_MOUNT) 426 if (notify == NFY_MOUNT)
@@ -449,15 +442,15 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
449 (unsigned long) wq->wait_queue_token, wq->name.len, 442 (unsigned long) wq->wait_queue_token, wq->name.len,
450 wq->name.name, notify); 443 wq->name.name, notify);
451 444
452 /* autofs4_notify_daemon() may block */ 445 /* autofs4_notify_daemon() may block; it will unlock ->wq_mutex */
453 autofs4_notify_daemon(sbi, wq, type); 446 autofs4_notify_daemon(sbi, wq, type);
454 } else { 447 } else {
455 wq->wait_ctr++; 448 wq->wait_ctr++;
456 mutex_unlock(&sbi->wq_mutex);
457 kfree(qstr.name);
458 DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d", 449 DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
459 (unsigned long) wq->wait_queue_token, wq->name.len, 450 (unsigned long) wq->wait_queue_token, wq->name.len,
460 wq->name.name, notify); 451 wq->name.name, notify);
452 mutex_unlock(&sbi->wq_mutex);
453 kfree(qstr.name);
461 } 454 }
462 455
463 /* 456 /*
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index d3e2eaa503a6..5384c2a640ca 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -500,6 +500,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
500 if (server->ops->close) 500 if (server->ops->close)
501 server->ops->close(xid, tcon, &fid); 501 server->ops->close(xid, tcon, &fid);
502 cifs_del_pending_open(&open); 502 cifs_del_pending_open(&open);
503 fput(file);
503 rc = -ENOMEM; 504 rc = -ENOMEM;
504 } 505 }
505 506
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 318e8433527c..b2a86e324aac 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -586,7 +586,8 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
586 586
587 fscache_operation_init(op, NULL, NULL); 587 fscache_operation_init(op, NULL, NULL);
588 op->flags = FSCACHE_OP_MYTHREAD | 588 op->flags = FSCACHE_OP_MYTHREAD |
589 (1 << FSCACHE_OP_WAITING); 589 (1 << FSCACHE_OP_WAITING) |
590 (1 << FSCACHE_OP_UNUSE_COOKIE);
590 591
591 spin_lock(&cookie->lock); 592 spin_lock(&cookie->lock);
592 593
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 64915eeae5a7..ced3257f06e8 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -694,8 +694,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
694 694
695 mark_inode_dirty(inode); 695 mark_inode_dirty(inode);
696 d_instantiate(dentry, inode); 696 d_instantiate(dentry, inode);
697 if (file) 697 if (file) {
698 *opened |= FILE_CREATED;
698 error = finish_open(file, dentry, gfs2_open_common, opened); 699 error = finish_open(file, dentry, gfs2_open_common, opened);
700 }
699 gfs2_glock_dq_uninit(ghs); 701 gfs2_glock_dq_uninit(ghs);
700 gfs2_glock_dq_uninit(ghs + 1); 702 gfs2_glock_dq_uninit(ghs + 1);
701 return error; 703 return error;
diff --git a/fs/namei.c b/fs/namei.c
index 0dc4cbf21f37..645268f23eb6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2656,6 +2656,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2656 int acc_mode; 2656 int acc_mode;
2657 int create_error = 0; 2657 int create_error = 0;
2658 struct dentry *const DENTRY_NOT_SET = (void *) -1UL; 2658 struct dentry *const DENTRY_NOT_SET = (void *) -1UL;
2659 bool excl;
2659 2660
2660 BUG_ON(dentry->d_inode); 2661 BUG_ON(dentry->d_inode);
2661 2662
@@ -2669,10 +2670,9 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2669 if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) 2670 if ((open_flag & O_CREAT) && !IS_POSIXACL(dir))
2670 mode &= ~current_umask(); 2671 mode &= ~current_umask();
2671 2672
2672 if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) { 2673 excl = (open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT);
2674 if (excl)
2673 open_flag &= ~O_TRUNC; 2675 open_flag &= ~O_TRUNC;
2674 *opened |= FILE_CREATED;
2675 }
2676 2676
2677 /* 2677 /*
2678 * Checking write permission is tricky, bacuse we don't know if we are 2678 * Checking write permission is tricky, bacuse we don't know if we are
@@ -2725,12 +2725,6 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2725 goto out; 2725 goto out;
2726 } 2726 }
2727 2727
2728 acc_mode = op->acc_mode;
2729 if (*opened & FILE_CREATED) {
2730 fsnotify_create(dir, dentry);
2731 acc_mode = MAY_OPEN;
2732 }
2733
2734 if (error) { /* returned 1, that is */ 2728 if (error) { /* returned 1, that is */
2735 if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { 2729 if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {
2736 error = -EIO; 2730 error = -EIO;
@@ -2740,9 +2734,19 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2740 dput(dentry); 2734 dput(dentry);
2741 dentry = file->f_path.dentry; 2735 dentry = file->f_path.dentry;
2742 } 2736 }
2743 if (create_error && dentry->d_inode == NULL) { 2737 if (*opened & FILE_CREATED)
2744 error = create_error; 2738 fsnotify_create(dir, dentry);
2745 goto out; 2739 if (!dentry->d_inode) {
2740 WARN_ON(*opened & FILE_CREATED);
2741 if (create_error) {
2742 error = create_error;
2743 goto out;
2744 }
2745 } else {
2746 if (excl && !(*opened & FILE_CREATED)) {
2747 error = -EEXIST;
2748 goto out;
2749 }
2746 } 2750 }
2747 goto looked_up; 2751 goto looked_up;
2748 } 2752 }
@@ -2751,6 +2755,12 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2751 * We didn't have the inode before the open, so check open permission 2755 * We didn't have the inode before the open, so check open permission
2752 * here. 2756 * here.
2753 */ 2757 */
2758 acc_mode = op->acc_mode;
2759 if (*opened & FILE_CREATED) {
2760 WARN_ON(!(open_flag & O_CREAT));
2761 fsnotify_create(dir, dentry);
2762 acc_mode = MAY_OPEN;
2763 }
2754 error = may_open(&file->f_path, acc_mode, open_flag); 2764 error = may_open(&file->f_path, acc_mode, open_flag);
2755 if (error) 2765 if (error)
2756 fput(file); 2766 fput(file);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index de434f309af0..854a8f05a610 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1392,6 +1392,9 @@ static int nfs_finish_open(struct nfs_open_context *ctx,
1392{ 1392{
1393 int err; 1393 int err;
1394 1394
1395 if ((open_flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
1396 *opened |= FILE_CREATED;
1397
1395 err = finish_open(file, dentry, do_open, opened); 1398 err = finish_open(file, dentry, do_open, opened);
1396 if (err) 1399 if (err)
1397 goto out; 1400 goto out;
diff --git a/fs/open.c b/fs/open.c
index 2a731b0d08bc..d420331ca32a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -744,14 +744,24 @@ cleanup_file:
744 744
745/** 745/**
746 * finish_open - finish opening a file 746 * finish_open - finish opening a file
747 * @od: opaque open data 747 * @file: file pointer
748 * @dentry: pointer to dentry 748 * @dentry: pointer to dentry
749 * @open: open callback 749 * @open: open callback
750 * @opened: state of open
750 * 751 *
751 * This can be used to finish opening a file passed to i_op->atomic_open(). 752 * This can be used to finish opening a file passed to i_op->atomic_open().
752 * 753 *
753 * If the open callback is set to NULL, then the standard f_op->open() 754 * If the open callback is set to NULL, then the standard f_op->open()
754 * filesystem callback is substituted. 755 * filesystem callback is substituted.
756 *
757 * NB: the dentry reference is _not_ consumed. If, for example, the dentry is
758 * the return value of d_splice_alias(), then the caller needs to perform dput()
759 * on it after finish_open().
760 *
761 * On successful return @file is a fully instantiated open file. After this, if
762 * an error occurs in ->atomic_open(), it needs to clean up with fput().
763 *
764 * Returns zero on success or -errno if the open failed.
755 */ 765 */
756int finish_open(struct file *file, struct dentry *dentry, 766int finish_open(struct file *file, struct dentry *dentry,
757 int (*open)(struct inode *, struct file *), 767 int (*open)(struct inode *, struct file *),
@@ -772,11 +782,16 @@ EXPORT_SYMBOL(finish_open);
772/** 782/**
773 * finish_no_open - finish ->atomic_open() without opening the file 783 * finish_no_open - finish ->atomic_open() without opening the file
774 * 784 *
775 * @od: opaque open data 785 * @file: file pointer
776 * @dentry: dentry or NULL (as returned from ->lookup()) 786 * @dentry: dentry or NULL (as returned from ->lookup())
777 * 787 *
778 * This can be used to set the result of a successful lookup in ->atomic_open(). 788 * This can be used to set the result of a successful lookup in ->atomic_open().
779 * The filesystem's atomic_open() method shall return NULL after calling this. 789 *
790 * NB: unlike finish_open() this function does consume the dentry reference and
791 * the caller need not dput() it.
792 *
793 * Returns "1" which must be the return value of ->atomic_open() after having
794 * called this function.
780 */ 795 */
781int finish_no_open(struct file *file, struct dentry *dentry) 796int finish_no_open(struct file *file, struct dentry *dentry)
782{ 797{
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 4ffb7ab5e397..b8e93a40a5d3 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -168,7 +168,7 @@ static int pstore_decompress(void *in, void *out, size_t inlen, size_t outlen)
168 int err, ret; 168 int err, ret;
169 169
170 ret = -EIO; 170 ret = -EIO;
171 err = zlib_inflateInit(&stream); 171 err = zlib_inflateInit2(&stream, WINDOW_BITS);
172 if (err != Z_OK) 172 if (err != Z_OK)
173 goto error; 173 goto error;
174 174
@@ -195,8 +195,29 @@ error:
195static void allocate_buf_for_compression(void) 195static void allocate_buf_for_compression(void)
196{ 196{
197 size_t size; 197 size_t size;
198 size_t cmpr;
199
200 switch (psinfo->bufsize) {
201 /* buffer range for efivars */
202 case 1000 ... 2000:
203 cmpr = 56;
204 break;
205 case 2001 ... 3000:
206 cmpr = 54;
207 break;
208 case 3001 ... 3999:
209 cmpr = 52;
210 break;
211 /* buffer range for nvram, erst */
212 case 4000 ... 10000:
213 cmpr = 45;
214 break;
215 default:
216 cmpr = 60;
217 break;
218 }
198 219
199 big_oops_buf_sz = (psinfo->bufsize * 100) / 45; 220 big_oops_buf_sz = (psinfo->bufsize * 100) / cmpr;
200 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); 221 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
201 if (big_oops_buf) { 222 if (big_oops_buf) {
202 size = max(zlib_deflate_workspacesize(WINDOW_BITS, MEM_LEVEL), 223 size = max(zlib_deflate_workspacesize(WINDOW_BITS, MEM_LEVEL),
@@ -295,10 +316,6 @@ static void pstore_dump(struct kmsg_dumper *dumper,
295 compressed = true; 316 compressed = true;
296 total_len = zipped_len; 317 total_len = zipped_len;
297 } else { 318 } else {
298 pr_err("pstore: compression failed for Part %d"
299 " returned %d\n", part, zipped_len);
300 pr_err("pstore: Capture uncompressed"
301 " oops/panic report of Part %d\n", part);
302 compressed = false; 319 compressed = false;
303 total_len = copy_kmsg_to_buffer(hsize, len); 320 total_len = copy_kmsg_to_buffer(hsize, len);
304 } 321 }
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index fd54a14a7c2a..3d79e513c0b3 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -12,11 +12,14 @@
12 {0x1002, 0x130F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 12 {0x1002, 0x130F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
13 {0x1002, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 13 {0x1002, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
14 {0x1002, 0x1311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 14 {0x1002, 0x1311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
15 {0x1002, 0x1312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
15 {0x1002, 0x1313, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 16 {0x1002, 0x1313, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
16 {0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 17 {0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
17 {0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 18 {0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
19 {0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
18 {0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 20 {0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
19 {0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 21 {0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
22 {0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
20 {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ 23 {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \
21 {0x1002, 0x3151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 24 {0x1002, 0x3151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
22 {0x1002, 0x3152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 25 {0x1002, 0x3152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index ce6df39f60ff..8f47625a0661 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -335,6 +335,8 @@ extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
335 struct ceph_osd_request *req); 335 struct ceph_osd_request *req);
336extern void ceph_osdc_sync(struct ceph_osd_client *osdc); 336extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
337 337
338extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc);
339
338extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, 340extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
339 struct ceph_vino vino, 341 struct ceph_vino vino,
340 struct ceph_file_layout *layout, 342 struct ceph_file_layout *layout,
diff --git a/include/linux/hid.h b/include/linux/hid.h
index ee1ffc5e19c9..31b9d299ef6c 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -756,6 +756,10 @@ u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
756struct hid_device *hid_allocate_device(void); 756struct hid_device *hid_allocate_device(void);
757struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id); 757struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
758int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size); 758int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
759struct hid_report *hid_validate_values(struct hid_device *hid,
760 unsigned int type, unsigned int id,
761 unsigned int field_index,
762 unsigned int report_counts);
759int hid_open_report(struct hid_device *device); 763int hid_open_report(struct hid_device *device);
760int hid_check_keys_pressed(struct hid_device *hid); 764int hid_check_keys_pressed(struct hid_device *hid);
761int hid_connect(struct hid_device *hid, unsigned int connect_mask); 765int hid_connect(struct hid_device *hid, unsigned int connect_mask);
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index a5b598a79bec..7c1e1ebc0e23 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1391,8 +1391,8 @@ struct ieee80211_vht_operation {
1391#define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 1391#define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
1392#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 1392#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
1393#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 1393#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
1394#define IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX 0x00006000 1394#define IEEE80211_VHT_CAP_BEAMFORMEE_STS_MAX 0x0000e000
1395#define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX 0x00030000 1395#define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX 0x00070000
1396#define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000 1396#define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
1397#define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000 1397#define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
1398#define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000 1398#define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ca645a01d37a..0fbbc7aa02cb 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -533,6 +533,7 @@ int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn, struct page **pages,
533 533
534struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); 534struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
535unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); 535unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
536unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable);
536unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn); 537unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn);
537void kvm_release_page_clean(struct page *page); 538void kvm_release_page_clean(struct page *page);
538void kvm_release_page_dirty(struct page *page); 539void kvm_release_page_dirty(struct page *page);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 041b42a305f6..3de49aca4519 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -950,14 +950,14 @@ struct netdev_phys_port_id {
950 * multiple net devices on single physical port. 950 * multiple net devices on single physical port.
951 * 951 *
952 * void (*ndo_add_vxlan_port)(struct net_device *dev, 952 * void (*ndo_add_vxlan_port)(struct net_device *dev,
953 * sa_family_t sa_family, __u16 port); 953 * sa_family_t sa_family, __be16 port);
954 * Called by vxlan to notiy a driver about the UDP port and socket 954 * Called by vxlan to notiy a driver about the UDP port and socket
955 * address family that vxlan is listnening to. It is called only when 955 * address family that vxlan is listnening to. It is called only when
956 * a new port starts listening. The operation is protected by the 956 * a new port starts listening. The operation is protected by the
957 * vxlan_net->sock_lock. 957 * vxlan_net->sock_lock.
958 * 958 *
959 * void (*ndo_del_vxlan_port)(struct net_device *dev, 959 * void (*ndo_del_vxlan_port)(struct net_device *dev,
960 * sa_family_t sa_family, __u16 port); 960 * sa_family_t sa_family, __be16 port);
961 * Called by vxlan to notify the driver about a UDP port and socket 961 * Called by vxlan to notify the driver about a UDP port and socket
962 * address family that vxlan is not listening to anymore. The operation 962 * address family that vxlan is not listening to anymore. The operation
963 * is protected by the vxlan_net->sock_lock. 963 * is protected by the vxlan_net->sock_lock.
@@ -1093,10 +1093,10 @@ struct net_device_ops {
1093 struct netdev_phys_port_id *ppid); 1093 struct netdev_phys_port_id *ppid);
1094 void (*ndo_add_vxlan_port)(struct net_device *dev, 1094 void (*ndo_add_vxlan_port)(struct net_device *dev,
1095 sa_family_t sa_family, 1095 sa_family_t sa_family,
1096 __u16 port); 1096 __be16 port);
1097 void (*ndo_del_vxlan_port)(struct net_device *dev, 1097 void (*ndo_del_vxlan_port)(struct net_device *dev,
1098 sa_family_t sa_family, 1098 sa_family_t sa_family,
1099 __u16 port); 1099 __be16 port);
1100}; 1100};
1101 1101
1102/* 1102/*
diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
index d80e2753847c..9ac9fbde7b61 100644
--- a/include/linux/netfilter/ipset/ip_set.h
+++ b/include/linux/netfilter/ipset/ip_set.h
@@ -296,10 +296,12 @@ ip_set_eexist(int ret, u32 flags)
296 296
297/* Match elements marked with nomatch */ 297/* Match elements marked with nomatch */
298static inline bool 298static inline bool
299ip_set_enomatch(int ret, u32 flags, enum ipset_adt adt) 299ip_set_enomatch(int ret, u32 flags, enum ipset_adt adt, struct ip_set *set)
300{ 300{
301 return adt == IPSET_TEST && 301 return adt == IPSET_TEST &&
302 ret == -ENOTEMPTY && ((flags >> 16) & IPSET_FLAG_NOMATCH); 302 (set->type->features & IPSET_TYPE_NOMATCH) &&
303 ((flags >> 16) & IPSET_FLAG_NOMATCH) &&
304 (ret > 0 || ret == -ENOTEMPTY);
303} 305}
304 306
305/* Check the NLA_F_NET_BYTEORDER flag */ 307/* Check the NLA_F_NET_BYTEORDER flag */
diff --git a/include/linux/timex.h b/include/linux/timex.h
index b3726e61368e..dd3edd7dfc94 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -141,6 +141,7 @@ extern int do_adjtimex(struct timex *);
141extern void hardpps(const struct timespec *, const struct timespec *); 141extern void hardpps(const struct timespec *, const struct timespec *);
142 142
143int read_current_timer(unsigned long *timer_val); 143int read_current_timer(unsigned long *timer_val);
144void ntp_notify_cmos_timer(void);
144 145
145/* The clock frequency of the i8253/i8254 PIT */ 146/* The clock frequency of the i8253/i8254 PIT */
146#define PIT_TICK_RATE 1193182ul 147#define PIT_TICK_RATE 1193182ul
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 10d43d8c7037..5fd510675cfa 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -197,8 +197,8 @@ static inline bool bdaddr_type_is_le(__u8 type)
197 return false; 197 return false;
198} 198}
199 199
200#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} }) 200#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
201#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) 201#define BDADDR_NONE (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
202 202
203/* Copy, swap, convert BD Address */ 203/* Copy, swap, convert BD Address */
204static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2) 204static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
@@ -249,6 +249,7 @@ int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
249uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait); 249uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
250int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 250int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
251int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); 251int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
252int bt_sock_wait_ready(struct sock *sk, unsigned long flags);
252 253
253void bt_accept_enqueue(struct sock *parent, struct sock *sk); 254void bt_accept_enqueue(struct sock *parent, struct sock *sk);
254void bt_accept_unlink(struct sock *sk); 255void bt_accept_unlink(struct sock *sk);
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index aaeaf0938ec0..b90eec5e9c06 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -35,6 +35,8 @@
35 35
36#define HCI_MAX_AMP_ASSOC_SIZE 672 36#define HCI_MAX_AMP_ASSOC_SIZE 672
37 37
38#define HCI_MAX_CSB_DATA_SIZE 252
39
38/* HCI dev events */ 40/* HCI dev events */
39#define HCI_DEV_REG 1 41#define HCI_DEV_REG 1
40#define HCI_DEV_UNREG 2 42#define HCI_DEV_UNREG 2
@@ -104,11 +106,13 @@ enum {
104enum { 106enum {
105 HCI_SETUP, 107 HCI_SETUP,
106 HCI_AUTO_OFF, 108 HCI_AUTO_OFF,
109 HCI_RFKILLED,
107 HCI_MGMT, 110 HCI_MGMT,
108 HCI_PAIRABLE, 111 HCI_PAIRABLE,
109 HCI_SERVICE_CACHE, 112 HCI_SERVICE_CACHE,
110 HCI_DEBUG_KEYS, 113 HCI_DEBUG_KEYS,
111 HCI_UNREGISTER, 114 HCI_UNREGISTER,
115 HCI_USER_CHANNEL,
112 116
113 HCI_LE_SCAN, 117 HCI_LE_SCAN,
114 HCI_SSP_ENABLED, 118 HCI_SSP_ENABLED,
@@ -120,6 +124,7 @@ enum {
120 HCI_LINK_SECURITY, 124 HCI_LINK_SECURITY,
121 HCI_PERIODIC_INQ, 125 HCI_PERIODIC_INQ,
122 HCI_FAST_CONNECTABLE, 126 HCI_FAST_CONNECTABLE,
127 HCI_BREDR_ENABLED,
123}; 128};
124 129
125/* A mask for the flags that are supposed to remain when a reset happens 130/* A mask for the flags that are supposed to remain when a reset happens
@@ -623,6 +628,24 @@ struct hci_rp_logical_link_cancel {
623 __u8 flow_spec_id; 628 __u8 flow_spec_id;
624} __packed; 629} __packed;
625 630
631#define HCI_OP_SET_CSB 0x0441
632struct hci_cp_set_csb {
633 __u8 enable;
634 __u8 lt_addr;
635 __u8 lpo_allowed;
636 __le16 packet_type;
637 __le16 interval_min;
638 __le16 interval_max;
639 __le16 csb_sv_tout;
640} __packed;
641struct hci_rp_set_csb {
642 __u8 status;
643 __u8 lt_addr;
644 __le16 interval;
645} __packed;
646
647#define HCI_OP_START_SYNC_TRAIN 0x0443
648
626#define HCI_OP_SNIFF_MODE 0x0803 649#define HCI_OP_SNIFF_MODE 0x0803
627struct hci_cp_sniff_mode { 650struct hci_cp_sniff_mode {
628 __le16 handle; 651 __le16 handle;
@@ -693,9 +716,6 @@ struct hci_cp_sniff_subrate {
693} __packed; 716} __packed;
694 717
695#define HCI_OP_SET_EVENT_MASK 0x0c01 718#define HCI_OP_SET_EVENT_MASK 0x0c01
696struct hci_cp_set_event_mask {
697 __u8 mask[8];
698} __packed;
699 719
700#define HCI_OP_RESET 0x0c03 720#define HCI_OP_RESET 0x0c03
701 721
@@ -825,6 +845,8 @@ struct hci_rp_read_inq_rsp_tx_power {
825 __s8 tx_power; 845 __s8 tx_power;
826} __packed; 846} __packed;
827 847
848#define HCI_OP_SET_EVENT_MASK_PAGE_2 0x0c63
849
828#define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66 850#define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
829struct hci_rp_read_flow_control_mode { 851struct hci_rp_read_flow_control_mode {
830 __u8 status; 852 __u8 status;
@@ -837,6 +859,50 @@ struct hci_cp_write_le_host_supported {
837 __u8 simul; 859 __u8 simul;
838} __packed; 860} __packed;
839 861
862#define HCI_OP_SET_RESERVED_LT_ADDR 0x0c74
863struct hci_cp_set_reserved_lt_addr {
864 __u8 lt_addr;
865} __packed;
866struct hci_rp_set_reserved_lt_addr {
867 __u8 status;
868 __u8 lt_addr;
869} __packed;
870
871#define HCI_OP_DELETE_RESERVED_LT_ADDR 0x0c75
872struct hci_cp_delete_reserved_lt_addr {
873 __u8 lt_addr;
874} __packed;
875struct hci_rp_delete_reserved_lt_addr {
876 __u8 status;
877 __u8 lt_addr;
878} __packed;
879
880#define HCI_OP_SET_CSB_DATA 0x0c76
881struct hci_cp_set_csb_data {
882 __u8 lt_addr;
883 __u8 fragment;
884 __u8 data_length;
885 __u8 data[HCI_MAX_CSB_DATA_SIZE];
886} __packed;
887struct hci_rp_set_csb_data {
888 __u8 status;
889 __u8 lt_addr;
890} __packed;
891
892#define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
893
894#define HCI_OP_WRITE_SYNC_TRAIN_PARAMS 0x0c78
895struct hci_cp_write_sync_train_params {
896 __le16 interval_min;
897 __le16 interval_max;
898 __le32 sync_train_tout;
899 __u8 service_data;
900} __packed;
901struct hci_rp_write_sync_train_params {
902 __u8 status;
903 __le16 sync_train_int;
904} __packed;
905
840#define HCI_OP_READ_LOCAL_VERSION 0x1001 906#define HCI_OP_READ_LOCAL_VERSION 0x1001
841struct hci_rp_read_local_version { 907struct hci_rp_read_local_version {
842 __u8 status; 908 __u8 status;
@@ -974,6 +1040,8 @@ struct hci_rp_le_read_local_features {
974 __u8 features[8]; 1040 __u8 features[8];
975} __packed; 1041} __packed;
976 1042
1043#define HCI_OP_LE_SET_RANDOM_ADDR 0x2005
1044
977#define HCI_OP_LE_READ_ADV_TX_POWER 0x2007 1045#define HCI_OP_LE_READ_ADV_TX_POWER 0x2007
978struct hci_rp_le_read_adv_tx_power { 1046struct hci_rp_le_read_adv_tx_power {
979 __u8 status; 1047 __u8 status;
@@ -1437,6 +1505,13 @@ struct hci_ev_num_comp_blocks {
1437 struct hci_comp_blocks_info handles[0]; 1505 struct hci_comp_blocks_info handles[0];
1438} __packed; 1506} __packed;
1439 1507
1508#define HCI_EV_SYNC_TRAIN_COMPLETE 0x4F
1509struct hci_ev_sync_train_complete {
1510 __u8 status;
1511} __packed;
1512
1513#define HCI_EV_SLAVE_PAGE_RESP_TIMEOUT 0x54
1514
1440/* Low energy meta events */ 1515/* Low energy meta events */
1441#define LE_CONN_ROLE_MASTER 0x00 1516#define LE_CONN_ROLE_MASTER 0x00
1442 1517
@@ -1570,6 +1645,7 @@ struct sockaddr_hci {
1570#define HCI_DEV_NONE 0xffff 1645#define HCI_DEV_NONE 0xffff
1571 1646
1572#define HCI_CHANNEL_RAW 0 1647#define HCI_CHANNEL_RAW 0
1648#define HCI_CHANNEL_USER 1
1573#define HCI_CHANNEL_MONITOR 2 1649#define HCI_CHANNEL_MONITOR 2
1574#define HCI_CHANNEL_CONTROL 3 1650#define HCI_CHANNEL_CONTROL 3
1575 1651
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3ede820d328f..e09c30577b3a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -140,6 +140,7 @@ struct hci_dev {
140 __u8 bus; 140 __u8 bus;
141 __u8 dev_type; 141 __u8 dev_type;
142 bdaddr_t bdaddr; 142 bdaddr_t bdaddr;
143 bdaddr_t static_addr;
143 __u8 dev_name[HCI_MAX_NAME_LENGTH]; 144 __u8 dev_name[HCI_MAX_NAME_LENGTH];
144 __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; 145 __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH];
145 __u8 eir[HCI_MAX_EIR_LENGTH]; 146 __u8 eir[HCI_MAX_EIR_LENGTH];
@@ -1168,7 +1169,6 @@ int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
1168int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); 1169int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
1169int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, 1170int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
1170 u8 *randomizer, u8 status); 1171 u8 *randomizer, u8 status);
1171int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status);
1172int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1172int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1173 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, 1173 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name,
1174 u8 ssp, u8 *eir, u16 eir_len); 1174 u8 ssp, u8 *eir, u16 eir_len);
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 1a966afbbfa8..f141b5f6e4f1 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -564,6 +564,7 @@ struct l2cap_conn {
564 564
565 __u32 feat_mask; 565 __u32 feat_mask;
566 __u8 fixed_chan_mask; 566 __u8 fixed_chan_mask;
567 bool hs_enabled;
567 568
568 __u8 info_state; 569 __u8 info_state;
569 __u8 info_ident; 570 __u8 info_ident;
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 9944c3e68c5d..2ad433bb9a2e 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -93,6 +93,7 @@ struct mgmt_rp_read_index_list {
93#define MGMT_SETTING_BREDR 0x00000080 93#define MGMT_SETTING_BREDR 0x00000080
94#define MGMT_SETTING_HS 0x00000100 94#define MGMT_SETTING_HS 0x00000100
95#define MGMT_SETTING_LE 0x00000200 95#define MGMT_SETTING_LE 0x00000200
96#define MGMT_SETTING_ADVERTISING 0x00000400
96 97
97#define MGMT_OP_READ_INFO 0x0004 98#define MGMT_OP_READ_INFO 0x0004
98#define MGMT_READ_INFO_SIZE 0 99#define MGMT_READ_INFO_SIZE 0
@@ -351,6 +352,16 @@ struct mgmt_cp_set_device_id {
351} __packed; 352} __packed;
352#define MGMT_SET_DEVICE_ID_SIZE 8 353#define MGMT_SET_DEVICE_ID_SIZE 8
353 354
355#define MGMT_OP_SET_ADVERTISING 0x0029
356
357#define MGMT_OP_SET_BREDR 0x002A
358
359#define MGMT_OP_SET_STATIC_ADDRESS 0x002B
360struct mgmt_cp_set_static_address {
361 bdaddr_t bdaddr;
362} __packed;
363#define MGMT_SET_STATIC_ADDRESS_SIZE 6
364
354#define MGMT_EV_CMD_COMPLETE 0x0001 365#define MGMT_EV_CMD_COMPLETE 0x0001
355struct mgmt_ev_cmd_complete { 366struct mgmt_ev_cmd_complete {
356 __le16 opcode; 367 __le16 opcode;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index cb710913d5c8..45f6bf591104 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -437,6 +437,15 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
437 u32 prohibited_flags); 437 u32 prohibited_flags);
438 438
439/** 439/**
440 * cfg80211_chandef_dfs_required - checks if radar detection is required
441 * @wiphy: the wiphy to validate against
442 * @chandef: the channel definition to check
443 * Return: 1 if radar detection is required, 0 if it is not, < 0 on error
444 */
445int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
446 const struct cfg80211_chan_def *chandef);
447
448/**
440 * ieee80211_chandef_rate_flags - returns rate flags for a channel 449 * ieee80211_chandef_rate_flags - returns rate flags for a channel
441 * 450 *
442 * In some channel types, not all rates may be used - for example CCK 451 * In some channel types, not all rates may be used - for example CCK
diff --git a/include/net/ip.h b/include/net/ip.h
index 48f55979d842..5e5268807a1c 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -264,9 +264,11 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
264 264
265extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); 265extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
266 266
267static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk) 267static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk)
268{ 268{
269 if (iph->frag_off & htons(IP_DF)) { 269 struct iphdr *iph = ip_hdr(skb);
270
271 if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
270 /* This is only to work around buggy Windows95/2000 272 /* This is only to work around buggy Windows95/2000
271 * VJ compression implementations. If the ID field 273 * VJ compression implementations. If the ID field
272 * does not change, they drop every other packet in 274 * does not change, they drop every other packet in
@@ -278,9 +280,11 @@ static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, str
278 __ip_select_ident(iph, dst, 0); 280 __ip_select_ident(iph, dst, 0);
279} 281}
280 282
281static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more) 283static inline void ip_select_ident_more(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk, int more)
282{ 284{
283 if (iph->frag_off & htons(IP_DF)) { 285 struct iphdr *iph = ip_hdr(skb);
286
287 if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
284 if (sk && inet_sk(sk)->inet_daddr) { 288 if (sk && inet_sk(sk)->inet_daddr) {
285 iph->id = htons(inet_sk(sk)->inet_id); 289 iph->id = htons(inet_sk(sk)->inet_id);
286 inet_sk(sk)->inet_id += 1 + more; 290 inet_sk(sk)->inet_id += 1 + more;
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index cc6035f1a2f1..f386c480e134 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -829,6 +829,15 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
829 * @RX_FLAG_STBC_MASK: STBC 2 bit bitmask. 1 - Nss=1, 2 - Nss=2, 3 - Nss=3 829 * @RX_FLAG_STBC_MASK: STBC 2 bit bitmask. 1 - Nss=1, 2 - Nss=2, 3 - Nss=3
830 * @RX_FLAG_10MHZ: 10 MHz (half channel) was used 830 * @RX_FLAG_10MHZ: 10 MHz (half channel) was used
831 * @RX_FLAG_5MHZ: 5 MHz (quarter channel) was used 831 * @RX_FLAG_5MHZ: 5 MHz (quarter channel) was used
832 * @RX_FLAG_AMSDU_MORE: Some drivers may prefer to report separate A-MSDU
833 * subframes instead of a one huge frame for performance reasons.
834 * All, but the last MSDU from an A-MSDU should have this flag set. E.g.
835 * if an A-MSDU has 3 frames, the first 2 must have the flag set, while
836 * the 3rd (last) one must not have this flag set. The flag is used to
837 * deal with retransmission/duplication recovery properly since A-MSDU
838 * subframes share the same sequence number. Reported subframes can be
839 * either regular MSDU or singly A-MSDUs. Subframes must not be
840 * interleaved with other frames.
832 */ 841 */
833enum mac80211_rx_flags { 842enum mac80211_rx_flags {
834 RX_FLAG_MMIC_ERROR = BIT(0), 843 RX_FLAG_MMIC_ERROR = BIT(0),
@@ -859,6 +868,7 @@ enum mac80211_rx_flags {
859 RX_FLAG_STBC_MASK = BIT(26) | BIT(27), 868 RX_FLAG_STBC_MASK = BIT(26) | BIT(27),
860 RX_FLAG_10MHZ = BIT(28), 869 RX_FLAG_10MHZ = BIT(28),
861 RX_FLAG_5MHZ = BIT(29), 870 RX_FLAG_5MHZ = BIT(29),
871 RX_FLAG_AMSDU_MORE = BIT(30),
862}; 872};
863 873
864#define RX_FLAG_STBC_SHIFT 26 874#define RX_FLAG_STBC_SHIFT 26
@@ -1492,6 +1502,11 @@ struct ieee80211_tx_control {
1492 * 1502 *
1493 * @IEEE80211_HW_TIMING_BEACON_ONLY: Use sync timing from beacon frames 1503 * @IEEE80211_HW_TIMING_BEACON_ONLY: Use sync timing from beacon frames
1494 * only, to allow getting TBTT of a DTIM beacon. 1504 * only, to allow getting TBTT of a DTIM beacon.
1505 *
1506 * @IEEE80211_HW_CHANCTX_STA_CSA: Support 802.11h based channel-switch (CSA)
1507 * for a single active channel while using channel contexts. When support
1508 * is not enabled the default action is to disconnect when getting the
1509 * CSA frame.
1495 */ 1510 */
1496enum ieee80211_hw_flags { 1511enum ieee80211_hw_flags {
1497 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, 1512 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
@@ -1522,6 +1537,7 @@ enum ieee80211_hw_flags {
1522 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25, 1537 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
1523 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26, 1538 IEEE80211_HW_TIMING_BEACON_ONLY = 1<<26,
1524 IEEE80211_HW_SUPPORTS_HT_CCK_RATES = 1<<27, 1539 IEEE80211_HW_SUPPORTS_HT_CCK_RATES = 1<<27,
1540 IEEE80211_HW_CHANCTX_STA_CSA = 1<<28,
1525}; 1541};
1526 1542
1527/** 1543/**
@@ -2666,6 +2682,10 @@ enum ieee80211_roc_type {
2666 * zero using ieee80211_csa_is_complete() after the beacon has been 2682 * zero using ieee80211_csa_is_complete() after the beacon has been
2667 * transmitted and then call ieee80211_csa_finish(). 2683 * transmitted and then call ieee80211_csa_finish().
2668 * 2684 *
2685 * @join_ibss: Join an IBSS (on an IBSS interface); this is called after all
2686 * information in bss_conf is set up and the beacon can be retrieved. A
2687 * channel context is bound before this is called.
2688 * @leave_ibss: Leave the IBSS again.
2669 */ 2689 */
2670struct ieee80211_ops { 2690struct ieee80211_ops {
2671 void (*tx)(struct ieee80211_hw *hw, 2691 void (*tx)(struct ieee80211_hw *hw,
@@ -2857,6 +2877,9 @@ struct ieee80211_ops {
2857 void (*channel_switch_beacon)(struct ieee80211_hw *hw, 2877 void (*channel_switch_beacon)(struct ieee80211_hw *hw,
2858 struct ieee80211_vif *vif, 2878 struct ieee80211_vif *vif,
2859 struct cfg80211_chan_def *chandef); 2879 struct cfg80211_chan_def *chandef);
2880
2881 int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2882 void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2860}; 2883};
2861 2884
2862/** 2885/**
@@ -3920,6 +3943,25 @@ void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
3920 void *data); 3943 void *data);
3921 3944
3922/** 3945/**
3946 * ieee80211_iterate_active_interfaces_rtnl - iterate active interfaces
3947 *
3948 * This function iterates over the interfaces associated with a given
3949 * hardware that are currently active and calls the callback for them.
3950 * This version can only be used while holding the RTNL.
3951 *
3952 * @hw: the hardware struct of which the interfaces should be iterated over
3953 * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
3954 * @iterator: the iterator function to call, cannot sleep
3955 * @data: first argument of the iterator function
3956 */
3957void ieee80211_iterate_active_interfaces_rtnl(struct ieee80211_hw *hw,
3958 u32 iter_flags,
3959 void (*iterator)(void *data,
3960 u8 *mac,
3961 struct ieee80211_vif *vif),
3962 void *data);
3963
3964/**
3923 * ieee80211_queue_work - add work onto the mac80211 workqueue 3965 * ieee80211_queue_work - add work onto the mac80211 workqueue
3924 * 3966 *
3925 * Drivers and mac80211 use this to add work onto the mac80211 workqueue. 3967 * Drivers and mac80211 use this to add work onto the mac80211 workqueue.
diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h
index ff95434e50ca..88a1d4060d52 100644
--- a/include/net/netfilter/nf_conntrack_extend.h
+++ b/include/net/netfilter/nf_conntrack_extend.h
@@ -86,7 +86,7 @@ static inline void nf_ct_ext_destroy(struct nf_conn *ct)
86static inline void nf_ct_ext_free(struct nf_conn *ct) 86static inline void nf_ct_ext_free(struct nf_conn *ct)
87{ 87{
88 if (ct->ext) 88 if (ct->ext)
89 kfree(ct->ext); 89 kfree_rcu(ct->ext, rcu);
90} 90}
91 91
92/* Add this type, returns pointer to data or NULL. */ 92/* Add this type, returns pointer to data or NULL. */
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index ca1d90bcb74d..40a1fb807396 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -324,7 +324,7 @@ struct perf_event_attr {
324#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64) 324#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
325#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5) 325#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5)
326#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *) 326#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
327#define PERF_EVENT_IOC_ID _IOR('$', 7, u64 *) 327#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
328 328
329enum perf_event_ioc_flags { 329enum perf_event_ioc_flags {
330 PERF_IOC_FLAG_GROUP = 1U << 0, 330 PERF_IOC_FLAG_GROUP = 1U << 0,
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index e076bddd4c66..196559994f7c 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -124,7 +124,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
124 SEQ_printf(m, " "); 124 SEQ_printf(m, " ");
125 125
126 SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ", 126 SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
127 p->comm, p->pid, 127 p->comm, task_pid_nr(p),
128 SPLIT_NS(p->se.vruntime), 128 SPLIT_NS(p->se.vruntime),
129 (long long)(p->nvcsw + p->nivcsw), 129 (long long)(p->nvcsw + p->nivcsw),
130 p->prio); 130 p->prio);
@@ -289,7 +289,7 @@ do { \
289 P(nr_load_updates); 289 P(nr_load_updates);
290 P(nr_uninterruptible); 290 P(nr_uninterruptible);
291 PN(next_balance); 291 PN(next_balance);
292 P(curr->pid); 292 SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr)));
293 PN(clock); 293 PN(clock);
294 P(cpu_load[0]); 294 P(cpu_load[0]);
295 P(cpu_load[1]); 295 P(cpu_load[1]);
@@ -492,7 +492,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
492{ 492{
493 unsigned long nr_switches; 493 unsigned long nr_switches;
494 494
495 SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid, 495 SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr(p),
496 get_nr_threads(p)); 496 get_nr_threads(p));
497 SEQ_printf(m, 497 SEQ_printf(m,
498 "---------------------------------------------------------" 498 "---------------------------------------------------------"
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9b3fe1cd8f40..11cd13667359 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5928,11 +5928,15 @@ static void task_fork_fair(struct task_struct *p)
5928 cfs_rq = task_cfs_rq(current); 5928 cfs_rq = task_cfs_rq(current);
5929 curr = cfs_rq->curr; 5929 curr = cfs_rq->curr;
5930 5930
5931 if (unlikely(task_cpu(p) != this_cpu)) { 5931 /*
5932 rcu_read_lock(); 5932 * Not only the cpu but also the task_group of the parent might have
5933 __set_task_cpu(p, this_cpu); 5933 * been changed after parent->se.parent,cfs_rq were copied to
5934 rcu_read_unlock(); 5934 * child->se.parent,cfs_rq. So call __set_task_cpu() to make those
5935 } 5935 * of child point to valid ones.
5936 */
5937 rcu_read_lock();
5938 __set_task_cpu(p, this_cpu);
5939 rcu_read_unlock();
5936 5940
5937 update_curr(cfs_rq); 5941 update_curr(cfs_rq);
5938 5942
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 5aef494fc8b4..c7edee71bce8 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -104,8 +104,9 @@ static inline void sched_info_queued(struct task_struct *t)
104} 104}
105 105
106/* 106/*
107 * Called when a process ceases being the active-running process, either 107 * Called when a process ceases being the active-running process involuntarily
108 * voluntarily or involuntarily. Now we can calculate how long we ran. 108 * due, typically, to expiring its time slice (this may also be called when
109 * switching to the idle task). Now we can calculate how long we ran.
109 * Also, if the process is still in the TASK_RUNNING state, call 110 * Also, if the process is still in the TASK_RUNNING state, call
110 * sched_info_queued() to mark that it has now again started waiting on 111 * sched_info_queued() to mark that it has now again started waiting on
111 * the runqueue. 112 * the runqueue.
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 8f5b3b98577b..bb2215174f05 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -516,13 +516,13 @@ static void sync_cmos_clock(struct work_struct *work)
516 schedule_delayed_work(&sync_cmos_work, timespec_to_jiffies(&next)); 516 schedule_delayed_work(&sync_cmos_work, timespec_to_jiffies(&next));
517} 517}
518 518
519static void notify_cmos_timer(void) 519void ntp_notify_cmos_timer(void)
520{ 520{
521 schedule_delayed_work(&sync_cmos_work, 0); 521 schedule_delayed_work(&sync_cmos_work, 0);
522} 522}
523 523
524#else 524#else
525static inline void notify_cmos_timer(void) { } 525void ntp_notify_cmos_timer(void) { }
526#endif 526#endif
527 527
528 528
@@ -687,8 +687,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai)
687 if (!(time_status & STA_NANO)) 687 if (!(time_status & STA_NANO))
688 txc->time.tv_usec /= NSEC_PER_USEC; 688 txc->time.tv_usec /= NSEC_PER_USEC;
689 689
690 notify_cmos_timer();
691
692 return result; 690 return result;
693} 691}
694 692
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 48b9fffabdc2..947ba25a95a0 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1703,6 +1703,8 @@ int do_adjtimex(struct timex *txc)
1703 write_seqcount_end(&timekeeper_seq); 1703 write_seqcount_end(&timekeeper_seq);
1704 raw_spin_unlock_irqrestore(&timekeeper_lock, flags); 1704 raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
1705 1705
1706 ntp_notify_cmos_timer();
1707
1706 return ret; 1708 return ret;
1707} 1709}
1708 1710
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 4493913f0d5c..813db4e64602 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -168,6 +168,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
168 case ETH_P_8021Q: 168 case ETH_P_8021Q:
169 vhdr = (struct vlan_ethhdr *)skb->data; 169 vhdr = (struct vlan_ethhdr *)skb->data;
170 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 170 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
171 vid |= BATADV_VLAN_HAS_TAG;
171 172
172 if (vhdr->h_vlan_encapsulated_proto != ethertype) 173 if (vhdr->h_vlan_encapsulated_proto != ethertype)
173 break; 174 break;
@@ -331,6 +332,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
331 case ETH_P_8021Q: 332 case ETH_P_8021Q:
332 vhdr = (struct vlan_ethhdr *)skb->data; 333 vhdr = (struct vlan_ethhdr *)skb->data;
333 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 334 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
335 vid |= BATADV_VLAN_HAS_TAG;
334 336
335 if (vhdr->h_vlan_encapsulated_proto != ethertype) 337 if (vhdr->h_vlan_encapsulated_proto != ethertype)
336 break; 338 break;
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile
index dea6a287daca..6a791e73e39d 100644
--- a/net/bluetooth/Makefile
+++ b/net/bluetooth/Makefile
@@ -11,3 +11,5 @@ obj-$(CONFIG_BT_HIDP) += hidp/
11bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ 11bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \
12 hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \ 12 hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \
13 a2mp.o amp.o 13 a2mp.o amp.o
14
15subdir-ccflags-y += -D__CHECK_ENDIAN__
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 9096137c889c..e6e1278dca89 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -490,6 +490,7 @@ int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
490} 490}
491EXPORT_SYMBOL(bt_sock_ioctl); 491EXPORT_SYMBOL(bt_sock_ioctl);
492 492
493/* This function expects the sk lock to be held when called */
493int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) 494int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
494{ 495{
495 DECLARE_WAITQUEUE(wait, current); 496 DECLARE_WAITQUEUE(wait, current);
@@ -525,6 +526,46 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
525} 526}
526EXPORT_SYMBOL(bt_sock_wait_state); 527EXPORT_SYMBOL(bt_sock_wait_state);
527 528
529/* This function expects the sk lock to be held when called */
530int bt_sock_wait_ready(struct sock *sk, unsigned long flags)
531{
532 DECLARE_WAITQUEUE(wait, current);
533 unsigned long timeo;
534 int err = 0;
535
536 BT_DBG("sk %p", sk);
537
538 timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
539
540 add_wait_queue(sk_sleep(sk), &wait);
541 set_current_state(TASK_INTERRUPTIBLE);
542 while (test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags)) {
543 if (!timeo) {
544 err = -EAGAIN;
545 break;
546 }
547
548 if (signal_pending(current)) {
549 err = sock_intr_errno(timeo);
550 break;
551 }
552
553 release_sock(sk);
554 timeo = schedule_timeout(timeo);
555 lock_sock(sk);
556 set_current_state(TASK_INTERRUPTIBLE);
557
558 err = sock_error(sk);
559 if (err)
560 break;
561 }
562 __set_current_state(TASK_RUNNING);
563 remove_wait_queue(sk_sleep(sk), &wait);
564
565 return err;
566}
567EXPORT_SYMBOL(bt_sock_wait_ready);
568
528#ifdef CONFIG_PROC_FS 569#ifdef CONFIG_PROC_FS
529struct bt_seq_state { 570struct bt_seq_state {
530 struct bt_sock_list *l; 571 struct bt_sock_list *l;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index f0817121ec5e..514148b7a66b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -518,6 +518,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
518 list_for_each_entry(d, &hci_dev_list, list) { 518 list_for_each_entry(d, &hci_dev_list, list) {
519 if (!test_bit(HCI_UP, &d->flags) || 519 if (!test_bit(HCI_UP, &d->flags) ||
520 test_bit(HCI_RAW, &d->flags) || 520 test_bit(HCI_RAW, &d->flags) ||
521 test_bit(HCI_USER_CHANNEL, &d->dev_flags) ||
521 d->dev_type != HCI_BREDR) 522 d->dev_type != HCI_BREDR)
522 continue; 523 continue;
523 524
@@ -580,6 +581,9 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
580{ 581{
581 struct hci_conn *acl; 582 struct hci_conn *acl;
582 583
584 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
585 return ERR_PTR(-ENOTSUPP);
586
583 acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 587 acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
584 if (!acl) { 588 if (!acl) {
585 acl = hci_conn_add(hdev, ACL_LINK, dst); 589 acl = hci_conn_add(hdev, ACL_LINK, dst);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 634debab4d54..82dbdc6a7e9e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -519,6 +519,8 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt)
519 519
520 if (lmp_bredr_capable(hdev)) 520 if (lmp_bredr_capable(hdev))
521 bredr_setup(req); 521 bredr_setup(req);
522 else
523 clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
522 524
523 if (lmp_le_capable(hdev)) 525 if (lmp_le_capable(hdev))
524 le_setup(req); 526 le_setup(req);
@@ -607,6 +609,34 @@ static void hci_set_le_support(struct hci_request *req)
607 &cp); 609 &cp);
608} 610}
609 611
612static void hci_set_event_mask_page_2(struct hci_request *req)
613{
614 struct hci_dev *hdev = req->hdev;
615 u8 events[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
616
617 /* If Connectionless Slave Broadcast master role is supported
618 * enable all necessary events for it.
619 */
620 if (hdev->features[2][0] & 0x01) {
621 events[1] |= 0x40; /* Triggered Clock Capture */
622 events[1] |= 0x80; /* Synchronization Train Complete */
623 events[2] |= 0x10; /* Slave Page Response Timeout */
624 events[2] |= 0x20; /* CSB Channel Map Change */
625 }
626
627 /* If Connectionless Slave Broadcast slave role is supported
628 * enable all necessary events for it.
629 */
630 if (hdev->features[2][0] & 0x02) {
631 events[2] |= 0x01; /* Synchronization Train Received */
632 events[2] |= 0x02; /* CSB Receive */
633 events[2] |= 0x04; /* CSB Timeout */
634 events[2] |= 0x08; /* Truncated Page Complete */
635 }
636
637 hci_req_add(req, HCI_OP_SET_EVENT_MASK_PAGE_2, sizeof(events), events);
638}
639
610static void hci_init3_req(struct hci_request *req, unsigned long opt) 640static void hci_init3_req(struct hci_request *req, unsigned long opt)
611{ 641{
612 struct hci_dev *hdev = req->hdev; 642 struct hci_dev *hdev = req->hdev;
@@ -648,6 +678,19 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt)
648 } 678 }
649} 679}
650 680
681static void hci_init4_req(struct hci_request *req, unsigned long opt)
682{
683 struct hci_dev *hdev = req->hdev;
684
685 /* Set event mask page 2 if the HCI command for it is supported */
686 if (hdev->commands[22] & 0x04)
687 hci_set_event_mask_page_2(req);
688
689 /* Check for Synchronization Train support */
690 if (hdev->features[2][0] & 0x04)
691 hci_req_add(req, HCI_OP_READ_SYNC_TRAIN_PARAMS, 0, NULL);
692}
693
651static int __hci_init(struct hci_dev *hdev) 694static int __hci_init(struct hci_dev *hdev)
652{ 695{
653 int err; 696 int err;
@@ -667,7 +710,11 @@ static int __hci_init(struct hci_dev *hdev)
667 if (err < 0) 710 if (err < 0)
668 return err; 711 return err;
669 712
670 return __hci_req_sync(hdev, hci_init3_req, 0, HCI_INIT_TIMEOUT); 713 err = __hci_req_sync(hdev, hci_init3_req, 0, HCI_INIT_TIMEOUT);
714 if (err < 0)
715 return err;
716
717 return __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
671} 718}
672 719
673static void hci_scan_req(struct hci_request *req, unsigned long opt) 720static void hci_scan_req(struct hci_request *req, unsigned long opt)
@@ -984,6 +1031,16 @@ int hci_inquiry(void __user *arg)
984 if (!hdev) 1031 if (!hdev)
985 return -ENODEV; 1032 return -ENODEV;
986 1033
1034 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1035 err = -EBUSY;
1036 goto done;
1037 }
1038
1039 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
1040 err = -EOPNOTSUPP;
1041 goto done;
1042 }
1043
987 hci_dev_lock(hdev); 1044 hci_dev_lock(hdev);
988 if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX || 1045 if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX ||
989 inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) { 1046 inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) {
@@ -1051,14 +1108,14 @@ static u8 create_ad(struct hci_dev *hdev, u8 *ptr)
1051 if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) 1108 if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
1052 flags |= LE_AD_GENERAL; 1109 flags |= LE_AD_GENERAL;
1053 1110
1054 if (!lmp_bredr_capable(hdev)) 1111 if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
1112 if (lmp_le_br_capable(hdev))
1113 flags |= LE_AD_SIM_LE_BREDR_CTRL;
1114 if (lmp_host_le_br_capable(hdev))
1115 flags |= LE_AD_SIM_LE_BREDR_HOST;
1116 } else {
1055 flags |= LE_AD_NO_BREDR; 1117 flags |= LE_AD_NO_BREDR;
1056 1118 }
1057 if (lmp_le_br_capable(hdev))
1058 flags |= LE_AD_SIM_LE_BREDR_CTRL;
1059
1060 if (lmp_host_le_br_capable(hdev))
1061 flags |= LE_AD_SIM_LE_BREDR_HOST;
1062 1119
1063 if (flags) { 1120 if (flags) {
1064 BT_DBG("adv flags 0x%02x", flags); 1121 BT_DBG("adv flags 0x%02x", flags);
@@ -1126,17 +1183,10 @@ void hci_update_ad(struct hci_request *req)
1126 hci_req_add(req, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp); 1183 hci_req_add(req, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp);
1127} 1184}
1128 1185
1129/* ---- HCI ioctl helpers ---- */ 1186static int hci_dev_do_open(struct hci_dev *hdev)
1130
1131int hci_dev_open(__u16 dev)
1132{ 1187{
1133 struct hci_dev *hdev;
1134 int ret = 0; 1188 int ret = 0;
1135 1189
1136 hdev = hci_dev_get(dev);
1137 if (!hdev)
1138 return -ENODEV;
1139
1140 BT_DBG("%s %p", hdev->name, hdev); 1190 BT_DBG("%s %p", hdev->name, hdev);
1141 1191
1142 hci_req_lock(hdev); 1192 hci_req_lock(hdev);
@@ -1146,7 +1196,11 @@ int hci_dev_open(__u16 dev)
1146 goto done; 1196 goto done;
1147 } 1197 }
1148 1198
1149 if (hdev->rfkill && rfkill_blocked(hdev->rfkill)) { 1199 /* Check for rfkill but allow the HCI setup stage to proceed
1200 * (which in itself doesn't cause any RF activity).
1201 */
1202 if (test_bit(HCI_RFKILLED, &hdev->dev_flags) &&
1203 !test_bit(HCI_SETUP, &hdev->dev_flags)) {
1150 ret = -ERFKILL; 1204 ret = -ERFKILL;
1151 goto done; 1205 goto done;
1152 } 1206 }
@@ -1168,16 +1222,11 @@ int hci_dev_open(__u16 dev)
1168 ret = hdev->setup(hdev); 1222 ret = hdev->setup(hdev);
1169 1223
1170 if (!ret) { 1224 if (!ret) {
1171 /* Treat all non BR/EDR controllers as raw devices if
1172 * enable_hs is not set.
1173 */
1174 if (hdev->dev_type != HCI_BREDR && !enable_hs)
1175 set_bit(HCI_RAW, &hdev->flags);
1176
1177 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) 1225 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
1178 set_bit(HCI_RAW, &hdev->flags); 1226 set_bit(HCI_RAW, &hdev->flags);
1179 1227
1180 if (!test_bit(HCI_RAW, &hdev->flags)) 1228 if (!test_bit(HCI_RAW, &hdev->flags) &&
1229 !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags))
1181 ret = __hci_init(hdev); 1230 ret = __hci_init(hdev);
1182 } 1231 }
1183 1232
@@ -1188,6 +1237,7 @@ int hci_dev_open(__u16 dev)
1188 set_bit(HCI_UP, &hdev->flags); 1237 set_bit(HCI_UP, &hdev->flags);
1189 hci_notify(hdev, HCI_DEV_UP); 1238 hci_notify(hdev, HCI_DEV_UP);
1190 if (!test_bit(HCI_SETUP, &hdev->dev_flags) && 1239 if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
1240 !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) &&
1191 mgmt_valid_hdev(hdev)) { 1241 mgmt_valid_hdev(hdev)) {
1192 hci_dev_lock(hdev); 1242 hci_dev_lock(hdev);
1193 mgmt_powered(hdev, 1); 1243 mgmt_powered(hdev, 1);
@@ -1216,10 +1266,37 @@ int hci_dev_open(__u16 dev)
1216 1266
1217done: 1267done:
1218 hci_req_unlock(hdev); 1268 hci_req_unlock(hdev);
1219 hci_dev_put(hdev);
1220 return ret; 1269 return ret;
1221} 1270}
1222 1271
1272/* ---- HCI ioctl helpers ---- */
1273
1274int hci_dev_open(__u16 dev)
1275{
1276 struct hci_dev *hdev;
1277 int err;
1278
1279 hdev = hci_dev_get(dev);
1280 if (!hdev)
1281 return -ENODEV;
1282
1283 /* We need to ensure that no other power on/off work is pending
1284 * before proceeding to call hci_dev_do_open. This is
1285 * particularly important if the setup procedure has not yet
1286 * completed.
1287 */
1288 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
1289 cancel_delayed_work(&hdev->power_off);
1290
1291 flush_workqueue(hdev->req_workqueue);
1292
1293 err = hci_dev_do_open(hdev);
1294
1295 hci_dev_put(hdev);
1296
1297 return err;
1298}
1299
1223static int hci_dev_do_close(struct hci_dev *hdev) 1300static int hci_dev_do_close(struct hci_dev *hdev)
1224{ 1301{
1225 BT_DBG("%s %p", hdev->name, hdev); 1302 BT_DBG("%s %p", hdev->name, hdev);
@@ -1324,11 +1401,17 @@ int hci_dev_close(__u16 dev)
1324 if (!hdev) 1401 if (!hdev)
1325 return -ENODEV; 1402 return -ENODEV;
1326 1403
1404 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1405 err = -EBUSY;
1406 goto done;
1407 }
1408
1327 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1409 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
1328 cancel_delayed_work(&hdev->power_off); 1410 cancel_delayed_work(&hdev->power_off);
1329 1411
1330 err = hci_dev_do_close(hdev); 1412 err = hci_dev_do_close(hdev);
1331 1413
1414done:
1332 hci_dev_put(hdev); 1415 hci_dev_put(hdev);
1333 return err; 1416 return err;
1334} 1417}
@@ -1344,8 +1427,15 @@ int hci_dev_reset(__u16 dev)
1344 1427
1345 hci_req_lock(hdev); 1428 hci_req_lock(hdev);
1346 1429
1347 if (!test_bit(HCI_UP, &hdev->flags)) 1430 if (!test_bit(HCI_UP, &hdev->flags)) {
1431 ret = -ENETDOWN;
1432 goto done;
1433 }
1434
1435 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1436 ret = -EBUSY;
1348 goto done; 1437 goto done;
1438 }
1349 1439
1350 /* Drop queues */ 1440 /* Drop queues */
1351 skb_queue_purge(&hdev->rx_q); 1441 skb_queue_purge(&hdev->rx_q);
@@ -1380,10 +1470,15 @@ int hci_dev_reset_stat(__u16 dev)
1380 if (!hdev) 1470 if (!hdev)
1381 return -ENODEV; 1471 return -ENODEV;
1382 1472
1473 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1474 ret = -EBUSY;
1475 goto done;
1476 }
1477
1383 memset(&hdev->stat, 0, sizeof(struct hci_dev_stats)); 1478 memset(&hdev->stat, 0, sizeof(struct hci_dev_stats));
1384 1479
1480done:
1385 hci_dev_put(hdev); 1481 hci_dev_put(hdev);
1386
1387 return ret; 1482 return ret;
1388} 1483}
1389 1484
@@ -1400,6 +1495,16 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
1400 if (!hdev) 1495 if (!hdev)
1401 return -ENODEV; 1496 return -ENODEV;
1402 1497
1498 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1499 err = -EBUSY;
1500 goto done;
1501 }
1502
1503 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
1504 err = -EOPNOTSUPP;
1505 goto done;
1506 }
1507
1403 switch (cmd) { 1508 switch (cmd) {
1404 case HCISETAUTH: 1509 case HCISETAUTH:
1405 err = hci_req_sync(hdev, hci_auth_req, dr.dev_opt, 1510 err = hci_req_sync(hdev, hci_auth_req, dr.dev_opt,
@@ -1458,6 +1563,7 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
1458 break; 1563 break;
1459 } 1564 }
1460 1565
1566done:
1461 hci_dev_put(hdev); 1567 hci_dev_put(hdev);
1462 return err; 1568 return err;
1463} 1569}
@@ -1530,7 +1636,7 @@ int hci_get_dev_info(void __user *arg)
1530 1636
1531 strcpy(di.name, hdev->name); 1637 strcpy(di.name, hdev->name);
1532 di.bdaddr = hdev->bdaddr; 1638 di.bdaddr = hdev->bdaddr;
1533 di.type = (hdev->bus & 0x0f) | (hdev->dev_type << 4); 1639 di.type = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x03) << 4);
1534 di.flags = hdev->flags; 1640 di.flags = hdev->flags;
1535 di.pkt_type = hdev->pkt_type; 1641 di.pkt_type = hdev->pkt_type;
1536 if (lmp_bredr_capable(hdev)) { 1642 if (lmp_bredr_capable(hdev)) {
@@ -1566,10 +1672,16 @@ static int hci_rfkill_set_block(void *data, bool blocked)
1566 1672
1567 BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked); 1673 BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
1568 1674
1569 if (!blocked) 1675 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags))
1570 return 0; 1676 return -EBUSY;
1571 1677
1572 hci_dev_do_close(hdev); 1678 if (blocked) {
1679 set_bit(HCI_RFKILLED, &hdev->dev_flags);
1680 if (!test_bit(HCI_SETUP, &hdev->dev_flags))
1681 hci_dev_do_close(hdev);
1682 } else {
1683 clear_bit(HCI_RFKILLED, &hdev->dev_flags);
1684 }
1573 1685
1574 return 0; 1686 return 0;
1575} 1687}
@@ -1585,15 +1697,19 @@ static void hci_power_on(struct work_struct *work)
1585 1697
1586 BT_DBG("%s", hdev->name); 1698 BT_DBG("%s", hdev->name);
1587 1699
1588 err = hci_dev_open(hdev->id); 1700 err = hci_dev_do_open(hdev);
1589 if (err < 0) { 1701 if (err < 0) {
1590 mgmt_set_powered_failed(hdev, err); 1702 mgmt_set_powered_failed(hdev, err);
1591 return; 1703 return;
1592 } 1704 }
1593 1705
1594 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1706 if (test_bit(HCI_RFKILLED, &hdev->dev_flags)) {
1707 clear_bit(HCI_AUTO_OFF, &hdev->dev_flags);
1708 hci_dev_do_close(hdev);
1709 } else if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
1595 queue_delayed_work(hdev->req_workqueue, &hdev->power_off, 1710 queue_delayed_work(hdev->req_workqueue, &hdev->power_off,
1596 HCI_AUTO_OFF_TIMEOUT); 1711 HCI_AUTO_OFF_TIMEOUT);
1712 }
1597 1713
1598 if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) 1714 if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags))
1599 mgmt_index_added(hdev); 1715 mgmt_index_added(hdev);
@@ -2209,10 +2325,18 @@ int hci_register_dev(struct hci_dev *hdev)
2209 } 2325 }
2210 } 2326 }
2211 2327
2328 if (hdev->rfkill && rfkill_blocked(hdev->rfkill))
2329 set_bit(HCI_RFKILLED, &hdev->dev_flags);
2330
2212 set_bit(HCI_SETUP, &hdev->dev_flags); 2331 set_bit(HCI_SETUP, &hdev->dev_flags);
2213 2332
2214 if (hdev->dev_type != HCI_AMP) 2333 if (hdev->dev_type != HCI_AMP) {
2215 set_bit(HCI_AUTO_OFF, &hdev->dev_flags); 2334 set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
2335 /* Assume BR/EDR support until proven otherwise (such as
2336 * through reading supported features during init.
2337 */
2338 set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
2339 }
2216 2340
2217 write_lock(&hci_dev_list_lock); 2341 write_lock(&hci_dev_list_lock);
2218 list_add(&hdev->list, &hci_dev_list); 2342 list_add(&hdev->list, &hci_dev_list);
@@ -3258,15 +3382,13 @@ static void hci_tx_work(struct work_struct *work)
3258 BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt, 3382 BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt,
3259 hdev->sco_cnt, hdev->le_cnt); 3383 hdev->sco_cnt, hdev->le_cnt);
3260 3384
3261 /* Schedule queues and send stuff to HCI driver */ 3385 if (!test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
3262 3386 /* Schedule queues and send stuff to HCI driver */
3263 hci_sched_acl(hdev); 3387 hci_sched_acl(hdev);
3264 3388 hci_sched_sco(hdev);
3265 hci_sched_sco(hdev); 3389 hci_sched_esco(hdev);
3266 3390 hci_sched_le(hdev);
3267 hci_sched_esco(hdev); 3391 }
3268
3269 hci_sched_le(hdev);
3270 3392
3271 /* Send next queued raw (unknown type) packet */ 3393 /* Send next queued raw (unknown type) packet */
3272 while ((skb = skb_dequeue(&hdev->raw_q))) 3394 while ((skb = skb_dequeue(&hdev->raw_q)))
@@ -3457,7 +3579,8 @@ static void hci_rx_work(struct work_struct *work)
3457 hci_send_to_sock(hdev, skb); 3579 hci_send_to_sock(hdev, skb);
3458 } 3580 }
3459 3581
3460 if (test_bit(HCI_RAW, &hdev->flags)) { 3582 if (test_bit(HCI_RAW, &hdev->flags) ||
3583 test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
3461 kfree_skb(skb); 3584 kfree_skb(skb);
3462 continue; 3585 continue;
3463 } 3586 }
@@ -3512,7 +3635,7 @@ static void hci_cmd_work(struct work_struct *work)
3512 3635
3513 kfree_skb(hdev->sent_cmd); 3636 kfree_skb(hdev->sent_cmd);
3514 3637
3515 hdev->sent_cmd = skb_clone(skb, GFP_ATOMIC); 3638 hdev->sent_cmd = skb_clone(skb, GFP_KERNEL);
3516 if (hdev->sent_cmd) { 3639 if (hdev->sent_cmd) {
3517 atomic_dec(&hdev->cmd_cnt); 3640 atomic_dec(&hdev->cmd_cnt);
3518 hci_send_frame(skb); 3641 hci_send_frame(skb);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 94aab73f89d4..4785ab0795f5 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -297,6 +297,11 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
297 goto done; 297 goto done;
298 } 298 }
299 299
300 /* We need to ensure that we set this back on if someone changed
301 * the scan mode through a raw HCI socket.
302 */
303 set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
304
300 old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); 305 old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
301 old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); 306 old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
302 307
@@ -994,20 +999,20 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev,
994 return; 999 return;
995 1000
996 if (!status) { 1001 if (!status) {
997 if (sent->le) 1002 if (sent->le) {
998 hdev->features[1][0] |= LMP_HOST_LE; 1003 hdev->features[1][0] |= LMP_HOST_LE;
999 else 1004 set_bit(HCI_LE_ENABLED, &hdev->dev_flags);
1005 } else {
1000 hdev->features[1][0] &= ~LMP_HOST_LE; 1006 hdev->features[1][0] &= ~LMP_HOST_LE;
1007 clear_bit(HCI_LE_ENABLED, &hdev->dev_flags);
1008 clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
1009 }
1001 1010
1002 if (sent->simul) 1011 if (sent->simul)
1003 hdev->features[1][0] |= LMP_HOST_LE_BREDR; 1012 hdev->features[1][0] |= LMP_HOST_LE_BREDR;
1004 else 1013 else
1005 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; 1014 hdev->features[1][0] &= ~LMP_HOST_LE_BREDR;
1006 } 1015 }
1007
1008 if (test_bit(HCI_MGMT, &hdev->dev_flags) &&
1009 !test_bit(HCI_INIT, &hdev->flags))
1010 mgmt_le_enable_complete(hdev, sent->le, status);
1011} 1016}
1012 1017
1013static void hci_cc_write_remote_amp_assoc(struct hci_dev *hdev, 1018static void hci_cc_write_remote_amp_assoc(struct hci_dev *hdev,
@@ -3557,7 +3562,11 @@ static void hci_le_ltk_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
3557 cp.handle = cpu_to_le16(conn->handle); 3562 cp.handle = cpu_to_le16(conn->handle);
3558 3563
3559 if (ltk->authenticated) 3564 if (ltk->authenticated)
3560 conn->sec_level = BT_SECURITY_HIGH; 3565 conn->pending_sec_level = BT_SECURITY_HIGH;
3566 else
3567 conn->pending_sec_level = BT_SECURITY_MEDIUM;
3568
3569 conn->enc_key_size = ltk->enc_size;
3561 3570
3562 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); 3571 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
3563 3572
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 9bd7d959e384..579886186c3a 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -66,6 +66,46 @@ static struct bt_sock_list hci_sk_list = {
66 .lock = __RW_LOCK_UNLOCKED(hci_sk_list.lock) 66 .lock = __RW_LOCK_UNLOCKED(hci_sk_list.lock)
67}; 67};
68 68
69static bool is_filtered_packet(struct sock *sk, struct sk_buff *skb)
70{
71 struct hci_filter *flt;
72 int flt_type, flt_event;
73
74 /* Apply filter */
75 flt = &hci_pi(sk)->filter;
76
77 if (bt_cb(skb)->pkt_type == HCI_VENDOR_PKT)
78 flt_type = 0;
79 else
80 flt_type = bt_cb(skb)->pkt_type & HCI_FLT_TYPE_BITS;
81
82 if (!test_bit(flt_type, &flt->type_mask))
83 return true;
84
85 /* Extra filter for event packets only */
86 if (bt_cb(skb)->pkt_type != HCI_EVENT_PKT)
87 return false;
88
89 flt_event = (*(__u8 *)skb->data & HCI_FLT_EVENT_BITS);
90
91 if (!hci_test_bit(flt_event, &flt->event_mask))
92 return true;
93
94 /* Check filter only when opcode is set */
95 if (!flt->opcode)
96 return false;
97
98 if (flt_event == HCI_EV_CMD_COMPLETE &&
99 flt->opcode != get_unaligned((__le16 *)(skb->data + 3)))
100 return true;
101
102 if (flt_event == HCI_EV_CMD_STATUS &&
103 flt->opcode != get_unaligned((__le16 *)(skb->data + 4)))
104 return true;
105
106 return false;
107}
108
69/* Send frame to RAW socket */ 109/* Send frame to RAW socket */
70void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) 110void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
71{ 111{
@@ -77,7 +117,6 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
77 read_lock(&hci_sk_list.lock); 117 read_lock(&hci_sk_list.lock);
78 118
79 sk_for_each(sk, &hci_sk_list.head) { 119 sk_for_each(sk, &hci_sk_list.head) {
80 struct hci_filter *flt;
81 struct sk_buff *nskb; 120 struct sk_buff *nskb;
82 121
83 if (sk->sk_state != BT_BOUND || hci_pi(sk)->hdev != hdev) 122 if (sk->sk_state != BT_BOUND || hci_pi(sk)->hdev != hdev)
@@ -87,31 +126,19 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
87 if (skb->sk == sk) 126 if (skb->sk == sk)
88 continue; 127 continue;
89 128
90 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) 129 if (hci_pi(sk)->channel == HCI_CHANNEL_RAW) {
91 continue; 130 if (is_filtered_packet(sk, skb))
92
93 /* Apply filter */
94 flt = &hci_pi(sk)->filter;
95
96 if (!test_bit((bt_cb(skb)->pkt_type == HCI_VENDOR_PKT) ?
97 0 : (bt_cb(skb)->pkt_type & HCI_FLT_TYPE_BITS),
98 &flt->type_mask))
99 continue;
100
101 if (bt_cb(skb)->pkt_type == HCI_EVENT_PKT) {
102 int evt = (*(__u8 *)skb->data & HCI_FLT_EVENT_BITS);
103
104 if (!hci_test_bit(evt, &flt->event_mask))
105 continue; 131 continue;
106 132 } else if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
107 if (flt->opcode && 133 if (!bt_cb(skb)->incoming)
108 ((evt == HCI_EV_CMD_COMPLETE && 134 continue;
109 flt->opcode != 135 if (bt_cb(skb)->pkt_type != HCI_EVENT_PKT &&
110 get_unaligned((__le16 *)(skb->data + 3))) || 136 bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT &&
111 (evt == HCI_EV_CMD_STATUS && 137 bt_cb(skb)->pkt_type != HCI_SCODATA_PKT)
112 flt->opcode !=
113 get_unaligned((__le16 *)(skb->data + 4)))))
114 continue; 138 continue;
139 } else {
140 /* Don't send frame to other channel types */
141 continue;
115 } 142 }
116 143
117 if (!skb_copy) { 144 if (!skb_copy) {
@@ -426,6 +453,12 @@ static int hci_sock_release(struct socket *sock)
426 bt_sock_unlink(&hci_sk_list, sk); 453 bt_sock_unlink(&hci_sk_list, sk);
427 454
428 if (hdev) { 455 if (hdev) {
456 if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
457 mgmt_index_added(hdev);
458 clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags);
459 hci_dev_close(hdev->id);
460 }
461
429 atomic_dec(&hdev->promisc); 462 atomic_dec(&hdev->promisc);
430 hci_dev_put(hdev); 463 hci_dev_put(hdev);
431 } 464 }
@@ -482,6 +515,9 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
482 if (!hdev) 515 if (!hdev)
483 return -EBADFD; 516 return -EBADFD;
484 517
518 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags))
519 return -EBUSY;
520
485 switch (cmd) { 521 switch (cmd) {
486 case HCISETRAW: 522 case HCISETRAW:
487 if (!capable(CAP_NET_ADMIN)) 523 if (!capable(CAP_NET_ADMIN))
@@ -512,23 +548,32 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
512 if (!capable(CAP_NET_ADMIN)) 548 if (!capable(CAP_NET_ADMIN))
513 return -EPERM; 549 return -EPERM;
514 return hci_sock_blacklist_del(hdev, (void __user *) arg); 550 return hci_sock_blacklist_del(hdev, (void __user *) arg);
515
516 default:
517 if (hdev->ioctl)
518 return hdev->ioctl(hdev, cmd, arg);
519 return -EINVAL;
520 } 551 }
552
553 if (hdev->ioctl)
554 return hdev->ioctl(hdev, cmd, arg);
555
556 return -EINVAL;
521} 557}
522 558
523static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, 559static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
524 unsigned long arg) 560 unsigned long arg)
525{ 561{
526 struct sock *sk = sock->sk;
527 void __user *argp = (void __user *) arg; 562 void __user *argp = (void __user *) arg;
563 struct sock *sk = sock->sk;
528 int err; 564 int err;
529 565
530 BT_DBG("cmd %x arg %lx", cmd, arg); 566 BT_DBG("cmd %x arg %lx", cmd, arg);
531 567
568 lock_sock(sk);
569
570 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
571 err = -EBADFD;
572 goto done;
573 }
574
575 release_sock(sk);
576
532 switch (cmd) { 577 switch (cmd) {
533 case HCIGETDEVLIST: 578 case HCIGETDEVLIST:
534 return hci_get_dev_list(argp); 579 return hci_get_dev_list(argp);
@@ -573,13 +618,15 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
573 618
574 case HCIINQUIRY: 619 case HCIINQUIRY:
575 return hci_inquiry(argp); 620 return hci_inquiry(argp);
576
577 default:
578 lock_sock(sk);
579 err = hci_sock_bound_ioctl(sk, cmd, arg);
580 release_sock(sk);
581 return err;
582 } 621 }
622
623 lock_sock(sk);
624
625 err = hci_sock_bound_ioctl(sk, cmd, arg);
626
627done:
628 release_sock(sk);
629 return err;
583} 630}
584 631
585static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, 632static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
@@ -629,6 +676,56 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
629 hci_pi(sk)->hdev = hdev; 676 hci_pi(sk)->hdev = hdev;
630 break; 677 break;
631 678
679 case HCI_CHANNEL_USER:
680 if (hci_pi(sk)->hdev) {
681 err = -EALREADY;
682 goto done;
683 }
684
685 if (haddr.hci_dev == HCI_DEV_NONE) {
686 err = -EINVAL;
687 goto done;
688 }
689
690 if (!capable(CAP_NET_ADMIN)) {
691 err = -EPERM;
692 goto done;
693 }
694
695 hdev = hci_dev_get(haddr.hci_dev);
696 if (!hdev) {
697 err = -ENODEV;
698 goto done;
699 }
700
701 if (test_bit(HCI_UP, &hdev->flags) ||
702 test_bit(HCI_INIT, &hdev->flags) ||
703 test_bit(HCI_SETUP, &hdev->dev_flags)) {
704 err = -EBUSY;
705 hci_dev_put(hdev);
706 goto done;
707 }
708
709 if (test_and_set_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
710 err = -EUSERS;
711 hci_dev_put(hdev);
712 goto done;
713 }
714
715 mgmt_index_removed(hdev);
716
717 err = hci_dev_open(hdev->id);
718 if (err) {
719 clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags);
720 hci_dev_put(hdev);
721 goto done;
722 }
723
724 atomic_inc(&hdev->promisc);
725
726 hci_pi(sk)->hdev = hdev;
727 break;
728
632 case HCI_CHANNEL_CONTROL: 729 case HCI_CHANNEL_CONTROL:
633 if (haddr.hci_dev != HCI_DEV_NONE) { 730 if (haddr.hci_dev != HCI_DEV_NONE) {
634 err = -EINVAL; 731 err = -EINVAL;
@@ -677,22 +774,30 @@ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
677{ 774{
678 struct sockaddr_hci *haddr = (struct sockaddr_hci *) addr; 775 struct sockaddr_hci *haddr = (struct sockaddr_hci *) addr;
679 struct sock *sk = sock->sk; 776 struct sock *sk = sock->sk;
680 struct hci_dev *hdev = hci_pi(sk)->hdev; 777 struct hci_dev *hdev;
778 int err = 0;
681 779
682 BT_DBG("sock %p sk %p", sock, sk); 780 BT_DBG("sock %p sk %p", sock, sk);
683 781
684 if (!hdev) 782 if (peer)
685 return -EBADFD; 783 return -EOPNOTSUPP;
686 784
687 lock_sock(sk); 785 lock_sock(sk);
688 786
787 hdev = hci_pi(sk)->hdev;
788 if (!hdev) {
789 err = -EBADFD;
790 goto done;
791 }
792
689 *addr_len = sizeof(*haddr); 793 *addr_len = sizeof(*haddr);
690 haddr->hci_family = AF_BLUETOOTH; 794 haddr->hci_family = AF_BLUETOOTH;
691 haddr->hci_dev = hdev->id; 795 haddr->hci_dev = hdev->id;
692 haddr->hci_channel= 0; 796 haddr->hci_channel= hci_pi(sk)->channel;
693 797
798done:
694 release_sock(sk); 799 release_sock(sk);
695 return 0; 800 return err;
696} 801}
697 802
698static void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, 803static void hci_sock_cmsg(struct sock *sk, struct msghdr *msg,
@@ -767,6 +872,7 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
767 case HCI_CHANNEL_RAW: 872 case HCI_CHANNEL_RAW:
768 hci_sock_cmsg(sk, msg, skb); 873 hci_sock_cmsg(sk, msg, skb);
769 break; 874 break;
875 case HCI_CHANNEL_USER:
770 case HCI_CHANNEL_CONTROL: 876 case HCI_CHANNEL_CONTROL:
771 case HCI_CHANNEL_MONITOR: 877 case HCI_CHANNEL_MONITOR:
772 sock_recv_timestamp(msg, sk, skb); 878 sock_recv_timestamp(msg, sk, skb);
@@ -801,6 +907,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
801 907
802 switch (hci_pi(sk)->channel) { 908 switch (hci_pi(sk)->channel) {
803 case HCI_CHANNEL_RAW: 909 case HCI_CHANNEL_RAW:
910 case HCI_CHANNEL_USER:
804 break; 911 break;
805 case HCI_CHANNEL_CONTROL: 912 case HCI_CHANNEL_CONTROL:
806 err = mgmt_control(sk, msg, len); 913 err = mgmt_control(sk, msg, len);
@@ -837,7 +944,8 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
837 skb_pull(skb, 1); 944 skb_pull(skb, 1);
838 skb->dev = (void *) hdev; 945 skb->dev = (void *) hdev;
839 946
840 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { 947 if (hci_pi(sk)->channel == HCI_CHANNEL_RAW &&
948 bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {
841 u16 opcode = get_unaligned_le16(skb->data); 949 u16 opcode = get_unaligned_le16(skb->data);
842 u16 ogf = hci_opcode_ogf(opcode); 950 u16 ogf = hci_opcode_ogf(opcode);
843 u16 ocf = hci_opcode_ocf(opcode); 951 u16 ocf = hci_opcode_ocf(opcode);
@@ -868,6 +976,14 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
868 goto drop; 976 goto drop;
869 } 977 }
870 978
979 if (hci_pi(sk)->channel == HCI_CHANNEL_USER &&
980 bt_cb(skb)->pkt_type != HCI_COMMAND_PKT &&
981 bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT &&
982 bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) {
983 err = -EINVAL;
984 goto drop;
985 }
986
871 skb_queue_tail(&hdev->raw_q, skb); 987 skb_queue_tail(&hdev->raw_q, skb);
872 queue_work(hdev->workqueue, &hdev->tx_work); 988 queue_work(hdev->workqueue, &hdev->tx_work);
873 } 989 }
@@ -895,7 +1011,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
895 lock_sock(sk); 1011 lock_sock(sk);
896 1012
897 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) { 1013 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
898 err = -EINVAL; 1014 err = -EBADFD;
899 goto done; 1015 goto done;
900 } 1016 }
901 1017
@@ -981,7 +1097,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname,
981 lock_sock(sk); 1097 lock_sock(sk);
982 1098
983 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) { 1099 if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
984 err = -EINVAL; 1100 err = -EBADFD;
985 goto done; 1101 goto done;
986 } 1102 }
987 1103
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b3bb7bca8e60..02dba4e6df96 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1016,13 +1016,12 @@ static bool __amp_capable(struct l2cap_chan *chan)
1016{ 1016{
1017 struct l2cap_conn *conn = chan->conn; 1017 struct l2cap_conn *conn = chan->conn;
1018 1018
1019 if (enable_hs && 1019 if (conn->hs_enabled && hci_amp_capable() &&
1020 hci_amp_capable() &&
1021 chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED && 1020 chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED &&
1022 conn->fixed_chan_mask & L2CAP_FC_A2MP) 1021 conn->fixed_chan_mask & L2CAP_FC_A2MP)
1023 return true; 1022 return true;
1024 else 1023
1025 return false; 1024 return false;
1026} 1025}
1027 1026
1028static bool l2cap_check_efs(struct l2cap_chan *chan) 1027static bool l2cap_check_efs(struct l2cap_chan *chan)
@@ -1638,6 +1637,10 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon)
1638 1637
1639 conn->feat_mask = 0; 1638 conn->feat_mask = 0;
1640 1639
1640 if (hcon->type == ACL_LINK)
1641 conn->hs_enabled = test_bit(HCI_HS_ENABLED,
1642 &hcon->hdev->dev_flags);
1643
1641 spin_lock_init(&conn->lock); 1644 spin_lock_init(&conn->lock);
1642 mutex_init(&conn->chan_lock); 1645 mutex_init(&conn->chan_lock);
1643 1646
@@ -3084,14 +3087,14 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask)
3084 } 3087 }
3085} 3088}
3086 3089
3087static inline bool __l2cap_ews_supported(struct l2cap_chan *chan) 3090static inline bool __l2cap_ews_supported(struct l2cap_conn *conn)
3088{ 3091{
3089 return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_WINDOW; 3092 return conn->hs_enabled && conn->feat_mask & L2CAP_FEAT_EXT_WINDOW;
3090} 3093}
3091 3094
3092static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) 3095static inline bool __l2cap_efs_supported(struct l2cap_conn *conn)
3093{ 3096{
3094 return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; 3097 return conn->hs_enabled && conn->feat_mask & L2CAP_FEAT_EXT_FLOW;
3095} 3098}
3096 3099
3097static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan, 3100static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan,
@@ -3135,7 +3138,7 @@ static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan,
3135static inline void l2cap_txwin_setup(struct l2cap_chan *chan) 3138static inline void l2cap_txwin_setup(struct l2cap_chan *chan)
3136{ 3139{
3137 if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && 3140 if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW &&
3138 __l2cap_ews_supported(chan)) { 3141 __l2cap_ews_supported(chan->conn)) {
3139 /* use extended control field */ 3142 /* use extended control field */
3140 set_bit(FLAG_EXT_CTRL, &chan->flags); 3143 set_bit(FLAG_EXT_CTRL, &chan->flags);
3141 chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; 3144 chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW;
@@ -3165,7 +3168,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
3165 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) 3168 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state))
3166 break; 3169 break;
3167 3170
3168 if (__l2cap_efs_supported(chan)) 3171 if (__l2cap_efs_supported(chan->conn))
3169 set_bit(FLAG_EFS_ENABLE, &chan->flags); 3172 set_bit(FLAG_EFS_ENABLE, &chan->flags);
3170 3173
3171 /* fall through */ 3174 /* fall through */
@@ -3317,7 +3320,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
3317 break; 3320 break;
3318 3321
3319 case L2CAP_CONF_EWS: 3322 case L2CAP_CONF_EWS:
3320 if (!enable_hs) 3323 if (!chan->conn->hs_enabled)
3321 return -ECONNREFUSED; 3324 return -ECONNREFUSED;
3322 3325
3323 set_bit(FLAG_EXT_CTRL, &chan->flags); 3326 set_bit(FLAG_EXT_CTRL, &chan->flags);
@@ -3349,7 +3352,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
3349 } 3352 }
3350 3353
3351 if (remote_efs) { 3354 if (remote_efs) {
3352 if (__l2cap_efs_supported(chan)) 3355 if (__l2cap_efs_supported(chan->conn))
3353 set_bit(FLAG_EFS_ENABLE, &chan->flags); 3356 set_bit(FLAG_EFS_ENABLE, &chan->flags);
3354 else 3357 else
3355 return -ECONNREFUSED; 3358 return -ECONNREFUSED;
@@ -3755,6 +3758,13 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
3755 3758
3756 sk = chan->sk; 3759 sk = chan->sk;
3757 3760
3761 /* For certain devices (ex: HID mouse), support for authentication,
3762 * pairing and bonding is optional. For such devices, inorder to avoid
3763 * the ACL alive for too long after L2CAP disconnection, reset the ACL
3764 * disc_timeout back to HCI_DISCONN_TIMEOUT during L2CAP connect.
3765 */
3766 conn->hcon->disc_timeout = HCI_DISCONN_TIMEOUT;
3767
3758 bacpy(&bt_sk(sk)->src, conn->src); 3768 bacpy(&bt_sk(sk)->src, conn->src);
3759 bacpy(&bt_sk(sk)->dst, conn->dst); 3769 bacpy(&bt_sk(sk)->dst, conn->dst);
3760 chan->psm = psm; 3770 chan->psm = psm;
@@ -3884,13 +3894,13 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
3884 if (scid) { 3894 if (scid) {
3885 chan = __l2cap_get_chan_by_scid(conn, scid); 3895 chan = __l2cap_get_chan_by_scid(conn, scid);
3886 if (!chan) { 3896 if (!chan) {
3887 err = -EFAULT; 3897 err = -EBADSLT;
3888 goto unlock; 3898 goto unlock;
3889 } 3899 }
3890 } else { 3900 } else {
3891 chan = __l2cap_get_chan_by_ident(conn, cmd->ident); 3901 chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
3892 if (!chan) { 3902 if (!chan) {
3893 err = -EFAULT; 3903 err = -EBADSLT;
3894 goto unlock; 3904 goto unlock;
3895 } 3905 }
3896 } 3906 }
@@ -3978,7 +3988,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3978 3988
3979 chan = l2cap_get_chan_by_scid(conn, dcid); 3989 chan = l2cap_get_chan_by_scid(conn, dcid);
3980 if (!chan) 3990 if (!chan)
3981 return -ENOENT; 3991 return -EBADSLT;
3982 3992
3983 if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { 3993 if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) {
3984 struct l2cap_cmd_rej_cid rej; 3994 struct l2cap_cmd_rej_cid rej;
@@ -4206,7 +4216,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4206 chan = __l2cap_get_chan_by_scid(conn, dcid); 4216 chan = __l2cap_get_chan_by_scid(conn, dcid);
4207 if (!chan) { 4217 if (!chan) {
4208 mutex_unlock(&conn->chan_lock); 4218 mutex_unlock(&conn->chan_lock);
4209 return 0; 4219 return -EBADSLT;
4210 } 4220 }
4211 4221
4212 l2cap_chan_lock(chan); 4222 l2cap_chan_lock(chan);
@@ -4296,7 +4306,7 @@ static inline int l2cap_information_req(struct l2cap_conn *conn,
4296 if (!disable_ertm) 4306 if (!disable_ertm)
4297 feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING 4307 feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING
4298 | L2CAP_FEAT_FCS; 4308 | L2CAP_FEAT_FCS;
4299 if (enable_hs) 4309 if (conn->hs_enabled)
4300 feat_mask |= L2CAP_FEAT_EXT_FLOW 4310 feat_mask |= L2CAP_FEAT_EXT_FLOW
4301 | L2CAP_FEAT_EXT_WINDOW; 4311 | L2CAP_FEAT_EXT_WINDOW;
4302 4312
@@ -4307,7 +4317,7 @@ static inline int l2cap_information_req(struct l2cap_conn *conn,
4307 u8 buf[12]; 4317 u8 buf[12];
4308 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; 4318 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf;
4309 4319
4310 if (enable_hs) 4320 if (conn->hs_enabled)
4311 l2cap_fixed_chan[0] |= L2CAP_FC_A2MP; 4321 l2cap_fixed_chan[0] |= L2CAP_FC_A2MP;
4312 else 4322 else
4313 l2cap_fixed_chan[0] &= ~L2CAP_FC_A2MP; 4323 l2cap_fixed_chan[0] &= ~L2CAP_FC_A2MP;
@@ -4404,7 +4414,7 @@ static int l2cap_create_channel_req(struct l2cap_conn *conn,
4404 if (cmd_len != sizeof(*req)) 4414 if (cmd_len != sizeof(*req))
4405 return -EPROTO; 4415 return -EPROTO;
4406 4416
4407 if (!enable_hs) 4417 if (!conn->hs_enabled)
4408 return -EINVAL; 4418 return -EINVAL;
4409 4419
4410 psm = le16_to_cpu(req->psm); 4420 psm = le16_to_cpu(req->psm);
@@ -4438,7 +4448,7 @@ static int l2cap_create_channel_req(struct l2cap_conn *conn,
4438 hs_hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, conn->dst); 4448 hs_hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, conn->dst);
4439 if (!hs_hcon) { 4449 if (!hs_hcon) {
4440 hci_dev_put(hdev); 4450 hci_dev_put(hdev);
4441 return -EFAULT; 4451 return -EBADSLT;
4442 } 4452 }
4443 4453
4444 BT_DBG("mgr %p bredr_chan %p hs_hcon %p", mgr, chan, hs_hcon); 4454 BT_DBG("mgr %p bredr_chan %p hs_hcon %p", mgr, chan, hs_hcon);
@@ -4462,7 +4472,7 @@ error:
4462 l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP, 4472 l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP,
4463 sizeof(rsp), &rsp); 4473 sizeof(rsp), &rsp);
4464 4474
4465 return -EFAULT; 4475 return 0;
4466} 4476}
4467 4477
4468static void l2cap_send_move_chan_req(struct l2cap_chan *chan, u8 dest_amp_id) 4478static void l2cap_send_move_chan_req(struct l2cap_chan *chan, u8 dest_amp_id)
@@ -4831,7 +4841,7 @@ static inline int l2cap_move_channel_req(struct l2cap_conn *conn,
4831 4841
4832 BT_DBG("icid 0x%4.4x, dest_amp_id %d", icid, req->dest_amp_id); 4842 BT_DBG("icid 0x%4.4x, dest_amp_id %d", icid, req->dest_amp_id);
4833 4843
4834 if (!enable_hs) 4844 if (!conn->hs_enabled)
4835 return -EINVAL; 4845 return -EINVAL;
4836 4846
4837 chan = l2cap_get_chan_by_dcid(conn, icid); 4847 chan = l2cap_get_chan_by_dcid(conn, icid);
@@ -5212,7 +5222,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5212 5222
5213 case L2CAP_CONN_RSP: 5223 case L2CAP_CONN_RSP:
5214 case L2CAP_CREATE_CHAN_RSP: 5224 case L2CAP_CREATE_CHAN_RSP:
5215 err = l2cap_connect_create_rsp(conn, cmd, cmd_len, data); 5225 l2cap_connect_create_rsp(conn, cmd, cmd_len, data);
5216 break; 5226 break;
5217 5227
5218 case L2CAP_CONF_REQ: 5228 case L2CAP_CONF_REQ:
@@ -5220,7 +5230,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5220 break; 5230 break;
5221 5231
5222 case L2CAP_CONF_RSP: 5232 case L2CAP_CONF_RSP:
5223 err = l2cap_config_rsp(conn, cmd, cmd_len, data); 5233 l2cap_config_rsp(conn, cmd, cmd_len, data);
5224 break; 5234 break;
5225 5235
5226 case L2CAP_DISCONN_REQ: 5236 case L2CAP_DISCONN_REQ:
@@ -5228,7 +5238,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5228 break; 5238 break;
5229 5239
5230 case L2CAP_DISCONN_RSP: 5240 case L2CAP_DISCONN_RSP:
5231 err = l2cap_disconnect_rsp(conn, cmd, cmd_len, data); 5241 l2cap_disconnect_rsp(conn, cmd, cmd_len, data);
5232 break; 5242 break;
5233 5243
5234 case L2CAP_ECHO_REQ: 5244 case L2CAP_ECHO_REQ:
@@ -5243,7 +5253,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5243 break; 5253 break;
5244 5254
5245 case L2CAP_INFO_RSP: 5255 case L2CAP_INFO_RSP:
5246 err = l2cap_information_rsp(conn, cmd, cmd_len, data); 5256 l2cap_information_rsp(conn, cmd, cmd_len, data);
5247 break; 5257 break;
5248 5258
5249 case L2CAP_CREATE_CHAN_REQ: 5259 case L2CAP_CREATE_CHAN_REQ:
@@ -5255,7 +5265,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5255 break; 5265 break;
5256 5266
5257 case L2CAP_MOVE_CHAN_RSP: 5267 case L2CAP_MOVE_CHAN_RSP:
5258 err = l2cap_move_channel_rsp(conn, cmd, cmd_len, data); 5268 l2cap_move_channel_rsp(conn, cmd, cmd_len, data);
5259 break; 5269 break;
5260 5270
5261 case L2CAP_MOVE_CHAN_CFM: 5271 case L2CAP_MOVE_CHAN_CFM:
@@ -5263,7 +5273,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5263 break; 5273 break;
5264 5274
5265 case L2CAP_MOVE_CHAN_CFM_RSP: 5275 case L2CAP_MOVE_CHAN_CFM_RSP:
5266 err = l2cap_move_channel_confirm_rsp(conn, cmd, cmd_len, data); 5276 l2cap_move_channel_confirm_rsp(conn, cmd, cmd_len, data);
5267 break; 5277 break;
5268 5278
5269 default: 5279 default:
@@ -5294,54 +5304,65 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
5294 } 5304 }
5295} 5305}
5296 5306
5307static __le16 l2cap_err_to_reason(int err)
5308{
5309 switch (err) {
5310 case -EBADSLT:
5311 return __constant_cpu_to_le16(L2CAP_REJ_INVALID_CID);
5312 case -EMSGSIZE:
5313 return __constant_cpu_to_le16(L2CAP_REJ_MTU_EXCEEDED);
5314 case -EINVAL:
5315 case -EPROTO:
5316 default:
5317 return __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
5318 }
5319}
5320
5297static inline void l2cap_le_sig_channel(struct l2cap_conn *conn, 5321static inline void l2cap_le_sig_channel(struct l2cap_conn *conn,
5298 struct sk_buff *skb) 5322 struct sk_buff *skb)
5299{ 5323{
5300 u8 *data = skb->data; 5324 struct hci_conn *hcon = conn->hcon;
5301 int len = skb->len; 5325 struct l2cap_cmd_hdr *cmd;
5302 struct l2cap_cmd_hdr cmd; 5326 u16 len;
5303 int err; 5327 int err;
5304 5328
5305 l2cap_raw_recv(conn, skb); 5329 if (hcon->type != LE_LINK)
5330 goto drop;
5306 5331
5307 while (len >= L2CAP_CMD_HDR_SIZE) { 5332 if (skb->len < L2CAP_CMD_HDR_SIZE)
5308 u16 cmd_len; 5333 goto drop;
5309 memcpy(&cmd, data, L2CAP_CMD_HDR_SIZE);
5310 data += L2CAP_CMD_HDR_SIZE;
5311 len -= L2CAP_CMD_HDR_SIZE;
5312 5334
5313 cmd_len = le16_to_cpu(cmd.len); 5335 cmd = (void *) skb->data;
5336 skb_pull(skb, L2CAP_CMD_HDR_SIZE);
5314 5337
5315 BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, 5338 len = le16_to_cpu(cmd->len);
5316 cmd.ident);
5317 5339
5318 if (cmd_len > len || !cmd.ident) { 5340 BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd->code, len, cmd->ident);
5319 BT_DBG("corrupted command");
5320 break;
5321 }
5322 5341
5323 err = l2cap_le_sig_cmd(conn, &cmd, data); 5342 if (len != skb->len || !cmd->ident) {
5324 if (err) { 5343 BT_DBG("corrupted command");
5325 struct l2cap_cmd_rej_unk rej; 5344 goto drop;
5345 }
5326 5346
5327 BT_ERR("Wrong link type (%d)", err); 5347 err = l2cap_le_sig_cmd(conn, cmd, skb->data);
5348 if (err) {
5349 struct l2cap_cmd_rej_unk rej;
5328 5350
5329 /* FIXME: Map err to a valid reason */ 5351 BT_ERR("Wrong link type (%d)", err);
5330 rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
5331 l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ,
5332 sizeof(rej), &rej);
5333 }
5334 5352
5335 data += cmd_len; 5353 rej.reason = l2cap_err_to_reason(err);
5336 len -= cmd_len; 5354 l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ,
5355 sizeof(rej), &rej);
5337 } 5356 }
5338 5357
5358drop:
5339 kfree_skb(skb); 5359 kfree_skb(skb);
5340} 5360}
5341 5361
5342static inline void l2cap_sig_channel(struct l2cap_conn *conn, 5362static inline void l2cap_sig_channel(struct l2cap_conn *conn,
5343 struct sk_buff *skb) 5363 struct sk_buff *skb)
5344{ 5364{
5365 struct hci_conn *hcon = conn->hcon;
5345 u8 *data = skb->data; 5366 u8 *data = skb->data;
5346 int len = skb->len; 5367 int len = skb->len;
5347 struct l2cap_cmd_hdr cmd; 5368 struct l2cap_cmd_hdr cmd;
@@ -5349,6 +5370,9 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
5349 5370
5350 l2cap_raw_recv(conn, skb); 5371 l2cap_raw_recv(conn, skb);
5351 5372
5373 if (hcon->type != ACL_LINK)
5374 goto drop;
5375
5352 while (len >= L2CAP_CMD_HDR_SIZE) { 5376 while (len >= L2CAP_CMD_HDR_SIZE) {
5353 u16 cmd_len; 5377 u16 cmd_len;
5354 memcpy(&cmd, data, L2CAP_CMD_HDR_SIZE); 5378 memcpy(&cmd, data, L2CAP_CMD_HDR_SIZE);
@@ -5371,8 +5395,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
5371 5395
5372 BT_ERR("Wrong link type (%d)", err); 5396 BT_ERR("Wrong link type (%d)", err);
5373 5397
5374 /* FIXME: Map err to a valid reason */ 5398 rej.reason = l2cap_err_to_reason(err);
5375 rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
5376 l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, 5399 l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ,
5377 sizeof(rej), &rej); 5400 sizeof(rej), &rej);
5378 } 5401 }
@@ -5381,6 +5404,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
5381 len -= cmd_len; 5404 len -= cmd_len;
5382 } 5405 }
5383 5406
5407drop:
5384 kfree_skb(skb); 5408 kfree_skb(skb);
5385} 5409}
5386 5410
@@ -5777,7 +5801,7 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,
5777 struct sk_buff *skb, u8 event) 5801 struct sk_buff *skb, u8 event)
5778{ 5802{
5779 int err = 0; 5803 int err = 0;
5780 bool skb_in_use = 0; 5804 bool skb_in_use = false;
5781 5805
5782 BT_DBG("chan %p, control %p, skb %p, event %d", chan, control, skb, 5806 BT_DBG("chan %p, control %p, skb %p, event %d", chan, control, skb,
5783 event); 5807 event);
@@ -5798,7 +5822,7 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,
5798 control->txseq); 5822 control->txseq);
5799 5823
5800 chan->buffer_seq = chan->expected_tx_seq; 5824 chan->buffer_seq = chan->expected_tx_seq;
5801 skb_in_use = 1; 5825 skb_in_use = true;
5802 5826
5803 err = l2cap_reassemble_sdu(chan, skb, control); 5827 err = l2cap_reassemble_sdu(chan, skb, control);
5804 if (err) 5828 if (err)
@@ -5834,7 +5858,7 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,
5834 * current frame is stored for later use. 5858 * current frame is stored for later use.
5835 */ 5859 */
5836 skb_queue_tail(&chan->srej_q, skb); 5860 skb_queue_tail(&chan->srej_q, skb);
5837 skb_in_use = 1; 5861 skb_in_use = true;
5838 BT_DBG("Queued %p (queue len %d)", skb, 5862 BT_DBG("Queued %p (queue len %d)", skb,
5839 skb_queue_len(&chan->srej_q)); 5863 skb_queue_len(&chan->srej_q));
5840 5864
@@ -5912,7 +5936,7 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan,
5912{ 5936{
5913 int err = 0; 5937 int err = 0;
5914 u16 txseq = control->txseq; 5938 u16 txseq = control->txseq;
5915 bool skb_in_use = 0; 5939 bool skb_in_use = false;
5916 5940
5917 BT_DBG("chan %p, control %p, skb %p, event %d", chan, control, skb, 5941 BT_DBG("chan %p, control %p, skb %p, event %d", chan, control, skb,
5918 event); 5942 event);
@@ -5924,7 +5948,7 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan,
5924 /* Keep frame for reassembly later */ 5948 /* Keep frame for reassembly later */
5925 l2cap_pass_to_tx(chan, control); 5949 l2cap_pass_to_tx(chan, control);
5926 skb_queue_tail(&chan->srej_q, skb); 5950 skb_queue_tail(&chan->srej_q, skb);
5927 skb_in_use = 1; 5951 skb_in_use = true;
5928 BT_DBG("Queued %p (queue len %d)", skb, 5952 BT_DBG("Queued %p (queue len %d)", skb,
5929 skb_queue_len(&chan->srej_q)); 5953 skb_queue_len(&chan->srej_q));
5930 5954
@@ -5935,7 +5959,7 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan,
5935 5959
5936 l2cap_pass_to_tx(chan, control); 5960 l2cap_pass_to_tx(chan, control);
5937 skb_queue_tail(&chan->srej_q, skb); 5961 skb_queue_tail(&chan->srej_q, skb);
5938 skb_in_use = 1; 5962 skb_in_use = true;
5939 BT_DBG("Queued %p (queue len %d)", skb, 5963 BT_DBG("Queued %p (queue len %d)", skb,
5940 skb_queue_len(&chan->srej_q)); 5964 skb_queue_len(&chan->srej_q));
5941 5965
@@ -5950,7 +5974,7 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan,
5950 * the missing frames. 5974 * the missing frames.
5951 */ 5975 */
5952 skb_queue_tail(&chan->srej_q, skb); 5976 skb_queue_tail(&chan->srej_q, skb);
5953 skb_in_use = 1; 5977 skb_in_use = true;
5954 BT_DBG("Queued %p (queue len %d)", skb, 5978 BT_DBG("Queued %p (queue len %d)", skb,
5955 skb_queue_len(&chan->srej_q)); 5979 skb_queue_len(&chan->srej_q));
5956 5980
@@ -5964,7 +5988,7 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan,
5964 * SREJ'd frames. 5988 * SREJ'd frames.
5965 */ 5989 */
5966 skb_queue_tail(&chan->srej_q, skb); 5990 skb_queue_tail(&chan->srej_q, skb);
5967 skb_in_use = 1; 5991 skb_in_use = true;
5968 BT_DBG("Queued %p (queue len %d)", skb, 5992 BT_DBG("Queued %p (queue len %d)", skb,
5969 skb_queue_len(&chan->srej_q)); 5993 skb_queue_len(&chan->srej_q));
5970 5994
@@ -6373,8 +6397,12 @@ done:
6373static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, 6397static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm,
6374 struct sk_buff *skb) 6398 struct sk_buff *skb)
6375{ 6399{
6400 struct hci_conn *hcon = conn->hcon;
6376 struct l2cap_chan *chan; 6401 struct l2cap_chan *chan;
6377 6402
6403 if (hcon->type != ACL_LINK)
6404 goto drop;
6405
6378 chan = l2cap_global_chan_by_psm(0, psm, conn->src, conn->dst); 6406 chan = l2cap_global_chan_by_psm(0, psm, conn->src, conn->dst);
6379 if (!chan) 6407 if (!chan)
6380 goto drop; 6408 goto drop;
@@ -6397,8 +6425,12 @@ drop:
6397static void l2cap_att_channel(struct l2cap_conn *conn, 6425static void l2cap_att_channel(struct l2cap_conn *conn,
6398 struct sk_buff *skb) 6426 struct sk_buff *skb)
6399{ 6427{
6428 struct hci_conn *hcon = conn->hcon;
6400 struct l2cap_chan *chan; 6429 struct l2cap_chan *chan;
6401 6430
6431 if (hcon->type != LE_LINK)
6432 goto drop;
6433
6402 chan = l2cap_global_chan_by_scid(BT_CONNECTED, L2CAP_CID_ATT, 6434 chan = l2cap_global_chan_by_scid(BT_CONNECTED, L2CAP_CID_ATT,
6403 conn->src, conn->dst); 6435 conn->src, conn->dst);
6404 if (!chan) 6436 if (!chan)
@@ -6434,9 +6466,6 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
6434 BT_DBG("len %d, cid 0x%4.4x", len, cid); 6466 BT_DBG("len %d, cid 0x%4.4x", len, cid);
6435 6467
6436 switch (cid) { 6468 switch (cid) {
6437 case L2CAP_CID_LE_SIGNALING:
6438 l2cap_le_sig_channel(conn, skb);
6439 break;
6440 case L2CAP_CID_SIGNALING: 6469 case L2CAP_CID_SIGNALING:
6441 l2cap_sig_channel(conn, skb); 6470 l2cap_sig_channel(conn, skb);
6442 break; 6471 break;
@@ -6451,6 +6480,10 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
6451 l2cap_att_channel(conn, skb); 6480 l2cap_att_channel(conn, skb);
6452 break; 6481 break;
6453 6482
6483 case L2CAP_CID_LE_SIGNALING:
6484 l2cap_le_sig_channel(conn, skb);
6485 break;
6486
6454 case L2CAP_CID_SMP: 6487 case L2CAP_CID_SMP:
6455 if (smp_sig_channel(conn, skb)) 6488 if (smp_sig_channel(conn, skb))
6456 l2cap_conn_del(conn->hcon, EACCES); 6489 l2cap_conn_del(conn->hcon, EACCES);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 0098af80b213..9119898ef040 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -445,11 +445,6 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
445 break; 445 break;
446 446
447 case BT_CHANNEL_POLICY: 447 case BT_CHANNEL_POLICY:
448 if (!enable_hs) {
449 err = -ENOPROTOOPT;
450 break;
451 }
452
453 if (put_user(chan->chan_policy, (u32 __user *) optval)) 448 if (put_user(chan->chan_policy, (u32 __user *) optval))
454 err = -EFAULT; 449 err = -EFAULT;
455 break; 450 break;
@@ -720,11 +715,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
720 break; 715 break;
721 716
722 case BT_CHANNEL_POLICY: 717 case BT_CHANNEL_POLICY:
723 if (!enable_hs) {
724 err = -ENOPROTOOPT;
725 break;
726 }
727
728 if (get_user(opt, (u32 __user *) optval)) { 718 if (get_user(opt, (u32 __user *) optval)) {
729 err = -EFAULT; 719 err = -EFAULT;
730 break; 720 break;
@@ -777,6 +767,12 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
777 if (sk->sk_state != BT_CONNECTED) 767 if (sk->sk_state != BT_CONNECTED)
778 return -ENOTCONN; 768 return -ENOTCONN;
779 769
770 lock_sock(sk);
771 err = bt_sock_wait_ready(sk, msg->msg_flags);
772 release_sock(sk);
773 if (err)
774 return err;
775
780 l2cap_chan_lock(chan); 776 l2cap_chan_lock(chan);
781 err = l2cap_chan_send(chan, msg, len, sk->sk_priority); 777 err = l2cap_chan_send(chan, msg, len, sk->sk_priority);
782 l2cap_chan_unlock(chan); 778 l2cap_chan_unlock(chan);
@@ -799,8 +795,8 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
799 pi->chan->state = BT_CONFIG; 795 pi->chan->state = BT_CONFIG;
800 796
801 __l2cap_connect_rsp_defer(pi->chan); 797 __l2cap_connect_rsp_defer(pi->chan);
802 release_sock(sk); 798 err = 0;
803 return 0; 799 goto done;
804 } 800 }
805 801
806 release_sock(sk); 802 release_sock(sk);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fedc5399d465..16125ff918f1 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -32,10 +32,8 @@
32#include <net/bluetooth/mgmt.h> 32#include <net/bluetooth/mgmt.h>
33#include <net/bluetooth/smp.h> 33#include <net/bluetooth/smp.h>
34 34
35bool enable_hs;
36
37#define MGMT_VERSION 1 35#define MGMT_VERSION 1
38#define MGMT_REVISION 3 36#define MGMT_REVISION 4
39 37
40static const u16 mgmt_commands[] = { 38static const u16 mgmt_commands[] = {
41 MGMT_OP_READ_INDEX_LIST, 39 MGMT_OP_READ_INDEX_LIST,
@@ -76,6 +74,9 @@ static const u16 mgmt_commands[] = {
76 MGMT_OP_BLOCK_DEVICE, 74 MGMT_OP_BLOCK_DEVICE,
77 MGMT_OP_UNBLOCK_DEVICE, 75 MGMT_OP_UNBLOCK_DEVICE,
78 MGMT_OP_SET_DEVICE_ID, 76 MGMT_OP_SET_DEVICE_ID,
77 MGMT_OP_SET_ADVERTISING,
78 MGMT_OP_SET_BREDR,
79 MGMT_OP_SET_STATIC_ADDRESS,
79}; 80};
80 81
81static const u16 mgmt_events[] = { 82static const u16 mgmt_events[] = {
@@ -339,6 +340,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
339 if (test_bit(HCI_SETUP, &d->dev_flags)) 340 if (test_bit(HCI_SETUP, &d->dev_flags))
340 continue; 341 continue;
341 342
343 if (test_bit(HCI_USER_CHANNEL, &d->dev_flags))
344 continue;
345
342 if (!mgmt_valid_hdev(d)) 346 if (!mgmt_valid_hdev(d))
343 continue; 347 continue;
344 348
@@ -376,13 +380,13 @@ static u32 get_supported_settings(struct hci_dev *hdev)
376 settings |= MGMT_SETTING_DISCOVERABLE; 380 settings |= MGMT_SETTING_DISCOVERABLE;
377 settings |= MGMT_SETTING_BREDR; 381 settings |= MGMT_SETTING_BREDR;
378 settings |= MGMT_SETTING_LINK_SECURITY; 382 settings |= MGMT_SETTING_LINK_SECURITY;
379 }
380
381 if (enable_hs)
382 settings |= MGMT_SETTING_HS; 383 settings |= MGMT_SETTING_HS;
384 }
383 385
384 if (lmp_le_capable(hdev)) 386 if (lmp_le_capable(hdev)) {
385 settings |= MGMT_SETTING_LE; 387 settings |= MGMT_SETTING_LE;
388 settings |= MGMT_SETTING_ADVERTISING;
389 }
386 390
387 return settings; 391 return settings;
388} 392}
@@ -406,7 +410,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
406 if (test_bit(HCI_PAIRABLE, &hdev->dev_flags)) 410 if (test_bit(HCI_PAIRABLE, &hdev->dev_flags))
407 settings |= MGMT_SETTING_PAIRABLE; 411 settings |= MGMT_SETTING_PAIRABLE;
408 412
409 if (lmp_bredr_capable(hdev)) 413 if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
410 settings |= MGMT_SETTING_BREDR; 414 settings |= MGMT_SETTING_BREDR;
411 415
412 if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) 416 if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
@@ -421,6 +425,9 @@ static u32 get_current_settings(struct hci_dev *hdev)
421 if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags)) 425 if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags))
422 settings |= MGMT_SETTING_HS; 426 settings |= MGMT_SETTING_HS;
423 427
428 if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
429 settings |= MGMT_SETTING_ADVERTISING;
430
424 return settings; 431 return settings;
425} 432}
426 433
@@ -804,6 +811,12 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
804 811
805 hci_dev_lock(hdev); 812 hci_dev_lock(hdev);
806 813
814 if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) {
815 err = cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
816 MGMT_STATUS_BUSY);
817 goto failed;
818 }
819
807 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { 820 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
808 cancel_delayed_work(&hdev->power_off); 821 cancel_delayed_work(&hdev->power_off);
809 822
@@ -820,12 +833,6 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
820 goto failed; 833 goto failed;
821 } 834 }
822 835
823 if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) {
824 err = cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
825 MGMT_STATUS_BUSY);
826 goto failed;
827 }
828
829 cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, hdev, data, len); 836 cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, hdev, data, len);
830 if (!cmd) { 837 if (!cmd) {
831 err = -ENOMEM; 838 err = -ENOMEM;
@@ -883,20 +890,71 @@ static int new_settings(struct hci_dev *hdev, struct sock *skip)
883 return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip); 890 return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip);
884} 891}
885 892
893struct cmd_lookup {
894 struct sock *sk;
895 struct hci_dev *hdev;
896 u8 mgmt_status;
897};
898
899static void settings_rsp(struct pending_cmd *cmd, void *data)
900{
901 struct cmd_lookup *match = data;
902
903 send_settings_rsp(cmd->sk, cmd->opcode, match->hdev);
904
905 list_del(&cmd->list);
906
907 if (match->sk == NULL) {
908 match->sk = cmd->sk;
909 sock_hold(match->sk);
910 }
911
912 mgmt_pending_free(cmd);
913}
914
915static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
916{
917 u8 *status = data;
918
919 cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
920 mgmt_pending_remove(cmd);
921}
922
923static u8 mgmt_bredr_support(struct hci_dev *hdev)
924{
925 if (!lmp_bredr_capable(hdev))
926 return MGMT_STATUS_NOT_SUPPORTED;
927 else if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
928 return MGMT_STATUS_REJECTED;
929 else
930 return MGMT_STATUS_SUCCESS;
931}
932
933static u8 mgmt_le_support(struct hci_dev *hdev)
934{
935 if (!lmp_le_capable(hdev))
936 return MGMT_STATUS_NOT_SUPPORTED;
937 else if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
938 return MGMT_STATUS_REJECTED;
939 else
940 return MGMT_STATUS_SUCCESS;
941}
942
886static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, 943static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
887 u16 len) 944 u16 len)
888{ 945{
889 struct mgmt_cp_set_discoverable *cp = data; 946 struct mgmt_cp_set_discoverable *cp = data;
890 struct pending_cmd *cmd; 947 struct pending_cmd *cmd;
891 u16 timeout; 948 u16 timeout;
892 u8 scan; 949 u8 scan, status;
893 int err; 950 int err;
894 951
895 BT_DBG("request for %s", hdev->name); 952 BT_DBG("request for %s", hdev->name);
896 953
897 if (!lmp_bredr_capable(hdev)) 954 status = mgmt_bredr_support(hdev);
955 if (status)
898 return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, 956 return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
899 MGMT_STATUS_NOT_SUPPORTED); 957 status);
900 958
901 if (cp->val != 0x00 && cp->val != 0x01) 959 if (cp->val != 0x00 && cp->val != 0x01)
902 return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, 960 return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
@@ -1045,14 +1103,15 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
1045 struct mgmt_mode *cp = data; 1103 struct mgmt_mode *cp = data;
1046 struct pending_cmd *cmd; 1104 struct pending_cmd *cmd;
1047 struct hci_request req; 1105 struct hci_request req;
1048 u8 scan; 1106 u8 scan, status;
1049 int err; 1107 int err;
1050 1108
1051 BT_DBG("request for %s", hdev->name); 1109 BT_DBG("request for %s", hdev->name);
1052 1110
1053 if (!lmp_bredr_capable(hdev)) 1111 status = mgmt_bredr_support(hdev);
1112 if (status)
1054 return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, 1113 return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
1055 MGMT_STATUS_NOT_SUPPORTED); 1114 status);
1056 1115
1057 if (cp->val != 0x00 && cp->val != 0x01) 1116 if (cp->val != 0x00 && cp->val != 0x01)
1058 return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, 1117 return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
@@ -1168,14 +1227,15 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
1168{ 1227{
1169 struct mgmt_mode *cp = data; 1228 struct mgmt_mode *cp = data;
1170 struct pending_cmd *cmd; 1229 struct pending_cmd *cmd;
1171 u8 val; 1230 u8 val, status;
1172 int err; 1231 int err;
1173 1232
1174 BT_DBG("request for %s", hdev->name); 1233 BT_DBG("request for %s", hdev->name);
1175 1234
1176 if (!lmp_bredr_capable(hdev)) 1235 status = mgmt_bredr_support(hdev);
1236 if (status)
1177 return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, 1237 return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
1178 MGMT_STATUS_NOT_SUPPORTED); 1238 status);
1179 1239
1180 if (cp->val != 0x00 && cp->val != 0x01) 1240 if (cp->val != 0x00 && cp->val != 0x01)
1181 return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, 1241 return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
@@ -1236,11 +1296,15 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1236{ 1296{
1237 struct mgmt_mode *cp = data; 1297 struct mgmt_mode *cp = data;
1238 struct pending_cmd *cmd; 1298 struct pending_cmd *cmd;
1239 u8 val; 1299 u8 val, status;
1240 int err; 1300 int err;
1241 1301
1242 BT_DBG("request for %s", hdev->name); 1302 BT_DBG("request for %s", hdev->name);
1243 1303
1304 status = mgmt_bredr_support(hdev);
1305 if (status)
1306 return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, status);
1307
1244 if (!lmp_ssp_capable(hdev)) 1308 if (!lmp_ssp_capable(hdev))
1245 return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, 1309 return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1246 MGMT_STATUS_NOT_SUPPORTED); 1310 MGMT_STATUS_NOT_SUPPORTED);
@@ -1302,23 +1366,64 @@ failed:
1302static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) 1366static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1303{ 1367{
1304 struct mgmt_mode *cp = data; 1368 struct mgmt_mode *cp = data;
1369 bool changed;
1370 u8 status;
1371 int err;
1305 1372
1306 BT_DBG("request for %s", hdev->name); 1373 BT_DBG("request for %s", hdev->name);
1307 1374
1308 if (!enable_hs) 1375 status = mgmt_bredr_support(hdev);
1309 return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, 1376 if (status)
1310 MGMT_STATUS_NOT_SUPPORTED); 1377 return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, status);
1311 1378
1312 if (cp->val != 0x00 && cp->val != 0x01) 1379 if (cp->val != 0x00 && cp->val != 0x01)
1313 return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, 1380 return cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
1314 MGMT_STATUS_INVALID_PARAMS); 1381 MGMT_STATUS_INVALID_PARAMS);
1315 1382
1316 if (cp->val) 1383 hci_dev_lock(hdev);
1317 set_bit(HCI_HS_ENABLED, &hdev->dev_flags); 1384
1318 else 1385 if (cp->val) {
1319 clear_bit(HCI_HS_ENABLED, &hdev->dev_flags); 1386 changed = !test_and_set_bit(HCI_HS_ENABLED, &hdev->dev_flags);
1387 } else {
1388 if (hdev_is_powered(hdev)) {
1389 err = cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
1390 MGMT_STATUS_REJECTED);
1391 goto unlock;
1392 }
1393
1394 changed = test_and_clear_bit(HCI_HS_ENABLED, &hdev->dev_flags);
1395 }
1396
1397 err = send_settings_rsp(sk, MGMT_OP_SET_HS, hdev);
1398 if (err < 0)
1399 goto unlock;
1400
1401 if (changed)
1402 err = new_settings(hdev, sk);
1403
1404unlock:
1405 hci_dev_unlock(hdev);
1406 return err;
1407}
1408
1409static void le_enable_complete(struct hci_dev *hdev, u8 status)
1410{
1411 struct cmd_lookup match = { NULL, hdev };
1320 1412
1321 return send_settings_rsp(sk, MGMT_OP_SET_HS, hdev); 1413 if (status) {
1414 u8 mgmt_err = mgmt_status(status);
1415
1416 mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, cmd_status_rsp,
1417 &mgmt_err);
1418 return;
1419 }
1420
1421 mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match);
1422
1423 new_settings(hdev, match.sk);
1424
1425 if (match.sk)
1426 sock_put(match.sk);
1322} 1427}
1323 1428
1324static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) 1429static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
@@ -1326,6 +1431,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1326 struct mgmt_mode *cp = data; 1431 struct mgmt_mode *cp = data;
1327 struct hci_cp_write_le_host_supported hci_cp; 1432 struct hci_cp_write_le_host_supported hci_cp;
1328 struct pending_cmd *cmd; 1433 struct pending_cmd *cmd;
1434 struct hci_request req;
1329 int err; 1435 int err;
1330 u8 val, enabled; 1436 u8 val, enabled;
1331 1437
@@ -1340,7 +1446,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1340 MGMT_STATUS_INVALID_PARAMS); 1446 MGMT_STATUS_INVALID_PARAMS);
1341 1447
1342 /* LE-only devices do not allow toggling LE on/off */ 1448 /* LE-only devices do not allow toggling LE on/off */
1343 if (!lmp_bredr_capable(hdev)) 1449 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
1344 return cmd_status(sk, hdev->id, MGMT_OP_SET_LE, 1450 return cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
1345 MGMT_STATUS_REJECTED); 1451 MGMT_STATUS_REJECTED);
1346 1452
@@ -1357,6 +1463,11 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1357 changed = true; 1463 changed = true;
1358 } 1464 }
1359 1465
1466 if (!val && test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
1467 clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
1468 changed = true;
1469 }
1470
1360 err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); 1471 err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev);
1361 if (err < 0) 1472 if (err < 0)
1362 goto unlock; 1473 goto unlock;
@@ -1367,7 +1478,8 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1367 goto unlock; 1478 goto unlock;
1368 } 1479 }
1369 1480
1370 if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { 1481 if (mgmt_pending_find(MGMT_OP_SET_LE, hdev) ||
1482 mgmt_pending_find(MGMT_OP_SET_ADVERTISING, hdev)) {
1371 err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, 1483 err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
1372 MGMT_STATUS_BUSY); 1484 MGMT_STATUS_BUSY);
1373 goto unlock; 1485 goto unlock;
@@ -1386,8 +1498,15 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1386 hci_cp.simul = lmp_le_br_capable(hdev); 1498 hci_cp.simul = lmp_le_br_capable(hdev);
1387 } 1499 }
1388 1500
1389 err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp), 1501 hci_req_init(&req, hdev);
1390 &hci_cp); 1502
1503 if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags) && !val)
1504 hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(val), &val);
1505
1506 hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp),
1507 &hci_cp);
1508
1509 err = hci_req_run(&req, le_enable_complete);
1391 if (err < 0) 1510 if (err < 0)
1392 mgmt_pending_remove(cmd); 1511 mgmt_pending_remove(cmd);
1393 1512
@@ -1706,6 +1825,12 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
1706 u16 key_count, expected_len; 1825 u16 key_count, expected_len;
1707 int i; 1826 int i;
1708 1827
1828 BT_DBG("request for %s", hdev->name);
1829
1830 if (!lmp_bredr_capable(hdev))
1831 return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
1832 MGMT_STATUS_NOT_SUPPORTED);
1833
1709 key_count = __le16_to_cpu(cp->key_count); 1834 key_count = __le16_to_cpu(cp->key_count);
1710 1835
1711 expected_len = sizeof(*cp) + key_count * 1836 expected_len = sizeof(*cp) + key_count *
@@ -2685,6 +2810,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
2685 struct hci_request req; 2810 struct hci_request req;
2686 /* General inquiry access code (GIAC) */ 2811 /* General inquiry access code (GIAC) */
2687 u8 lap[3] = { 0x33, 0x8b, 0x9e }; 2812 u8 lap[3] = { 0x33, 0x8b, 0x9e };
2813 u8 status;
2688 int err; 2814 int err;
2689 2815
2690 BT_DBG("%s", hdev->name); 2816 BT_DBG("%s", hdev->name);
@@ -2721,9 +2847,10 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
2721 2847
2722 switch (hdev->discovery.type) { 2848 switch (hdev->discovery.type) {
2723 case DISCOV_TYPE_BREDR: 2849 case DISCOV_TYPE_BREDR:
2724 if (!lmp_bredr_capable(hdev)) { 2850 status = mgmt_bredr_support(hdev);
2851 if (status) {
2725 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, 2852 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
2726 MGMT_STATUS_NOT_SUPPORTED); 2853 status);
2727 mgmt_pending_remove(cmd); 2854 mgmt_pending_remove(cmd);
2728 goto failed; 2855 goto failed;
2729 } 2856 }
@@ -2745,15 +2872,16 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
2745 2872
2746 case DISCOV_TYPE_LE: 2873 case DISCOV_TYPE_LE:
2747 case DISCOV_TYPE_INTERLEAVED: 2874 case DISCOV_TYPE_INTERLEAVED:
2748 if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { 2875 status = mgmt_le_support(hdev);
2876 if (status) {
2749 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, 2877 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
2750 MGMT_STATUS_NOT_SUPPORTED); 2878 status);
2751 mgmt_pending_remove(cmd); 2879 mgmt_pending_remove(cmd);
2752 goto failed; 2880 goto failed;
2753 } 2881 }
2754 2882
2755 if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED && 2883 if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED &&
2756 !lmp_bredr_capable(hdev)) { 2884 !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
2757 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, 2885 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
2758 MGMT_STATUS_NOT_SUPPORTED); 2886 MGMT_STATUS_NOT_SUPPORTED);
2759 mgmt_pending_remove(cmd); 2887 mgmt_pending_remove(cmd);
@@ -3065,6 +3193,135 @@ static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
3065 return err; 3193 return err;
3066} 3194}
3067 3195
3196static void set_advertising_complete(struct hci_dev *hdev, u8 status)
3197{
3198 struct cmd_lookup match = { NULL, hdev };
3199
3200 if (status) {
3201 u8 mgmt_err = mgmt_status(status);
3202
3203 mgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev,
3204 cmd_status_rsp, &mgmt_err);
3205 return;
3206 }
3207
3208 mgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev, settings_rsp,
3209 &match);
3210
3211 new_settings(hdev, match.sk);
3212
3213 if (match.sk)
3214 sock_put(match.sk);
3215}
3216
3217static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
3218{
3219 struct mgmt_mode *cp = data;
3220 struct pending_cmd *cmd;
3221 struct hci_request req;
3222 u8 val, enabled, status;
3223 int err;
3224
3225 BT_DBG("request for %s", hdev->name);
3226
3227 status = mgmt_le_support(hdev);
3228 if (status)
3229 return cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
3230 status);
3231
3232 if (cp->val != 0x00 && cp->val != 0x01)
3233 return cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
3234 MGMT_STATUS_INVALID_PARAMS);
3235
3236 hci_dev_lock(hdev);
3237
3238 val = !!cp->val;
3239 enabled = test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
3240
3241 if (!hdev_is_powered(hdev) || val == enabled) {
3242 bool changed = false;
3243
3244 if (val != test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
3245 change_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
3246 changed = true;
3247 }
3248
3249 err = send_settings_rsp(sk, MGMT_OP_SET_ADVERTISING, hdev);
3250 if (err < 0)
3251 goto unlock;
3252
3253 if (changed)
3254 err = new_settings(hdev, sk);
3255
3256 goto unlock;
3257 }
3258
3259 if (mgmt_pending_find(MGMT_OP_SET_ADVERTISING, hdev) ||
3260 mgmt_pending_find(MGMT_OP_SET_LE, hdev)) {
3261 err = cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
3262 MGMT_STATUS_BUSY);
3263 goto unlock;
3264 }
3265
3266 cmd = mgmt_pending_add(sk, MGMT_OP_SET_ADVERTISING, hdev, data, len);
3267 if (!cmd) {
3268 err = -ENOMEM;
3269 goto unlock;
3270 }
3271
3272 hci_req_init(&req, hdev);
3273
3274 hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(val), &val);
3275
3276 err = hci_req_run(&req, set_advertising_complete);
3277 if (err < 0)
3278 mgmt_pending_remove(cmd);
3279
3280unlock:
3281 hci_dev_unlock(hdev);
3282 return err;
3283}
3284
3285static int set_static_address(struct sock *sk, struct hci_dev *hdev,
3286 void *data, u16 len)
3287{
3288 struct mgmt_cp_set_static_address *cp = data;
3289 int err;
3290
3291 BT_DBG("%s", hdev->name);
3292
3293 if (!lmp_le_capable(hdev))
3294 return cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS,
3295 MGMT_STATUS_NOT_SUPPORTED);
3296
3297 if (hdev_is_powered(hdev))
3298 return cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS,
3299 MGMT_STATUS_REJECTED);
3300
3301 if (bacmp(&cp->bdaddr, BDADDR_ANY)) {
3302 if (!bacmp(&cp->bdaddr, BDADDR_NONE))
3303 return cmd_status(sk, hdev->id,
3304 MGMT_OP_SET_STATIC_ADDRESS,
3305 MGMT_STATUS_INVALID_PARAMS);
3306
3307 /* Two most significant bits shall be set */
3308 if ((cp->bdaddr.b[5] & 0xc0) != 0xc0)
3309 return cmd_status(sk, hdev->id,
3310 MGMT_OP_SET_STATIC_ADDRESS,
3311 MGMT_STATUS_INVALID_PARAMS);
3312 }
3313
3314 hci_dev_lock(hdev);
3315
3316 bacpy(&hdev->static_addr, &cp->bdaddr);
3317
3318 err = cmd_complete(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS, 0, NULL, 0);
3319
3320 hci_dev_unlock(hdev);
3321
3322 return err;
3323}
3324
3068static void fast_connectable_complete(struct hci_dev *hdev, u8 status) 3325static void fast_connectable_complete(struct hci_dev *hdev, u8 status)
3069{ 3326{
3070 struct pending_cmd *cmd; 3327 struct pending_cmd *cmd;
@@ -3108,7 +3365,8 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
3108 3365
3109 BT_DBG("%s", hdev->name); 3366 BT_DBG("%s", hdev->name);
3110 3367
3111 if (!lmp_bredr_capable(hdev) || hdev->hci_ver < BLUETOOTH_VER_1_2) 3368 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) ||
3369 hdev->hci_ver < BLUETOOTH_VER_1_2)
3112 return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, 3370 return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
3113 MGMT_STATUS_NOT_SUPPORTED); 3371 MGMT_STATUS_NOT_SUPPORTED);
3114 3372
@@ -3162,6 +3420,121 @@ unlock:
3162 return err; 3420 return err;
3163} 3421}
3164 3422
3423static void set_bredr_complete(struct hci_dev *hdev, u8 status)
3424{
3425 struct pending_cmd *cmd;
3426
3427 BT_DBG("status 0x%02x", status);
3428
3429 hci_dev_lock(hdev);
3430
3431 cmd = mgmt_pending_find(MGMT_OP_SET_BREDR, hdev);
3432 if (!cmd)
3433 goto unlock;
3434
3435 if (status) {
3436 u8 mgmt_err = mgmt_status(status);
3437
3438 /* We need to restore the flag if related HCI commands
3439 * failed.
3440 */
3441 clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
3442
3443 cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
3444 } else {
3445 send_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev);
3446 new_settings(hdev, cmd->sk);
3447 }
3448
3449 mgmt_pending_remove(cmd);
3450
3451unlock:
3452 hci_dev_unlock(hdev);
3453}
3454
3455static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
3456{
3457 struct mgmt_mode *cp = data;
3458 struct pending_cmd *cmd;
3459 struct hci_request req;
3460 int err;
3461
3462 BT_DBG("request for %s", hdev->name);
3463
3464 if (!lmp_bredr_capable(hdev) || !lmp_le_capable(hdev))
3465 return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
3466 MGMT_STATUS_NOT_SUPPORTED);
3467
3468 if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
3469 return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
3470 MGMT_STATUS_REJECTED);
3471
3472 if (cp->val != 0x00 && cp->val != 0x01)
3473 return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
3474 MGMT_STATUS_INVALID_PARAMS);
3475
3476 hci_dev_lock(hdev);
3477
3478 if (cp->val == test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) {
3479 err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev);
3480 goto unlock;
3481 }
3482
3483 if (!hdev_is_powered(hdev)) {
3484 if (!cp->val) {
3485 clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
3486 clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
3487 clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
3488 clear_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
3489 clear_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags);
3490 clear_bit(HCI_HS_ENABLED, &hdev->dev_flags);
3491 }
3492
3493 change_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
3494
3495 err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev);
3496 if (err < 0)
3497 goto unlock;
3498
3499 err = new_settings(hdev, sk);
3500 goto unlock;
3501 }
3502
3503 /* Reject disabling when powered on */
3504 if (!cp->val) {
3505 err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
3506 MGMT_STATUS_REJECTED);
3507 goto unlock;
3508 }
3509
3510 if (mgmt_pending_find(MGMT_OP_SET_BREDR, hdev)) {
3511 err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
3512 MGMT_STATUS_BUSY);
3513 goto unlock;
3514 }
3515
3516 cmd = mgmt_pending_add(sk, MGMT_OP_SET_BREDR, hdev, data, len);
3517 if (!cmd) {
3518 err = -ENOMEM;
3519 goto unlock;
3520 }
3521
3522 /* We need to flip the bit already here so that hci_update_ad
3523 * generates the correct flags.
3524 */
3525 set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
3526
3527 hci_req_init(&req, hdev);
3528 hci_update_ad(&req);
3529 err = hci_req_run(&req, set_bredr_complete);
3530 if (err < 0)
3531 mgmt_pending_remove(cmd);
3532
3533unlock:
3534 hci_dev_unlock(hdev);
3535 return err;
3536}
3537
3165static bool ltk_is_valid(struct mgmt_ltk_info *key) 3538static bool ltk_is_valid(struct mgmt_ltk_info *key)
3166{ 3539{
3167 if (key->authenticated != 0x00 && key->authenticated != 0x01) 3540 if (key->authenticated != 0x00 && key->authenticated != 0x01)
@@ -3180,6 +3553,12 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
3180 u16 key_count, expected_len; 3553 u16 key_count, expected_len;
3181 int i, err; 3554 int i, err;
3182 3555
3556 BT_DBG("request for %s", hdev->name);
3557
3558 if (!lmp_le_capable(hdev))
3559 return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS,
3560 MGMT_STATUS_NOT_SUPPORTED);
3561
3183 key_count = __le16_to_cpu(cp->key_count); 3562 key_count = __le16_to_cpu(cp->key_count);
3184 3563
3185 expected_len = sizeof(*cp) + key_count * 3564 expected_len = sizeof(*cp) + key_count *
@@ -3276,6 +3655,9 @@ static const struct mgmt_handler {
3276 { block_device, false, MGMT_BLOCK_DEVICE_SIZE }, 3655 { block_device, false, MGMT_BLOCK_DEVICE_SIZE },
3277 { unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE }, 3656 { unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE },
3278 { set_device_id, false, MGMT_SET_DEVICE_ID_SIZE }, 3657 { set_device_id, false, MGMT_SET_DEVICE_ID_SIZE },
3658 { set_advertising, false, MGMT_SETTING_SIZE },
3659 { set_bredr, false, MGMT_SETTING_SIZE },
3660 { set_static_address, false, MGMT_SET_STATIC_ADDRESS_SIZE },
3279}; 3661};
3280 3662
3281 3663
@@ -3320,6 +3702,12 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
3320 MGMT_STATUS_INVALID_INDEX); 3702 MGMT_STATUS_INVALID_INDEX);
3321 goto done; 3703 goto done;
3322 } 3704 }
3705
3706 if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
3707 err = cmd_status(sk, index, opcode,
3708 MGMT_STATUS_INVALID_INDEX);
3709 goto done;
3710 }
3323 } 3711 }
3324 3712
3325 if (opcode >= ARRAY_SIZE(mgmt_handlers) || 3713 if (opcode >= ARRAY_SIZE(mgmt_handlers) ||
@@ -3365,14 +3753,6 @@ done:
3365 return err; 3753 return err;
3366} 3754}
3367 3755
3368static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
3369{
3370 u8 *status = data;
3371
3372 cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
3373 mgmt_pending_remove(cmd);
3374}
3375
3376int mgmt_index_added(struct hci_dev *hdev) 3756int mgmt_index_added(struct hci_dev *hdev)
3377{ 3757{
3378 if (!mgmt_valid_hdev(hdev)) 3758 if (!mgmt_valid_hdev(hdev))
@@ -3393,28 +3773,6 @@ int mgmt_index_removed(struct hci_dev *hdev)
3393 return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); 3773 return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
3394} 3774}
3395 3775
3396struct cmd_lookup {
3397 struct sock *sk;
3398 struct hci_dev *hdev;
3399 u8 mgmt_status;
3400};
3401
3402static void settings_rsp(struct pending_cmd *cmd, void *data)
3403{
3404 struct cmd_lookup *match = data;
3405
3406 send_settings_rsp(cmd->sk, cmd->opcode, match->hdev);
3407
3408 list_del(&cmd->list);
3409
3410 if (match->sk == NULL) {
3411 match->sk = cmd->sk;
3412 sock_hold(match->sk);
3413 }
3414
3415 mgmt_pending_free(cmd);
3416}
3417
3418static void set_bredr_scan(struct hci_request *req) 3776static void set_bredr_scan(struct hci_request *req)
3419{ 3777{
3420 struct hci_dev *hdev = req->hdev; 3778 struct hci_dev *hdev = req->hdev;
@@ -3481,6 +3839,22 @@ static int powered_update_hci(struct hci_dev *hdev)
3481 cp.simul != lmp_host_le_br_capable(hdev)) 3839 cp.simul != lmp_host_le_br_capable(hdev))
3482 hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED, 3840 hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED,
3483 sizeof(cp), &cp); 3841 sizeof(cp), &cp);
3842
3843 /* In case BR/EDR was toggled during the AUTO_OFF phase */
3844 hci_update_ad(&req);
3845 }
3846
3847 if (lmp_le_capable(hdev)) {
3848 /* Set random address to static address if configured */
3849 if (bacmp(&hdev->static_addr, BDADDR_ANY))
3850 hci_req_add(&req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
3851 &hdev->static_addr);
3852 }
3853
3854 if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
3855 u8 adv = 0x01;
3856
3857 hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(adv), &adv);
3484 } 3858 }
3485 3859
3486 link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags); 3860 link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
@@ -3489,7 +3863,8 @@ static int powered_update_hci(struct hci_dev *hdev)
3489 sizeof(link_sec), &link_sec); 3863 sizeof(link_sec), &link_sec);
3490 3864
3491 if (lmp_bredr_capable(hdev)) { 3865 if (lmp_bredr_capable(hdev)) {
3492 set_bredr_scan(&req); 3866 if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
3867 set_bredr_scan(&req);
3493 update_class(&req); 3868 update_class(&req);
3494 update_name(&req); 3869 update_name(&req);
3495 update_eir(&req); 3870 update_eir(&req);
@@ -4132,44 +4507,6 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
4132 return err; 4507 return err;
4133} 4508}
4134 4509
4135int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
4136{
4137 struct cmd_lookup match = { NULL, hdev };
4138 bool changed = false;
4139 int err = 0;
4140
4141 if (status) {
4142 u8 mgmt_err = mgmt_status(status);
4143
4144 if (enable && test_and_clear_bit(HCI_LE_ENABLED,
4145 &hdev->dev_flags))
4146 err = new_settings(hdev, NULL);
4147
4148 mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, cmd_status_rsp,
4149 &mgmt_err);
4150
4151 return err;
4152 }
4153
4154 if (enable) {
4155 if (!test_and_set_bit(HCI_LE_ENABLED, &hdev->dev_flags))
4156 changed = true;
4157 } else {
4158 if (test_and_clear_bit(HCI_LE_ENABLED, &hdev->dev_flags))
4159 changed = true;
4160 }
4161
4162 mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match);
4163
4164 if (changed)
4165 err = new_settings(hdev, match.sk);
4166
4167 if (match.sk)
4168 sock_put(match.sk);
4169
4170 return err;
4171}
4172
4173int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 4510int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
4174 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8 4511 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8
4175 ssp, u8 *eir, u16 eir_len) 4512 ssp, u8 *eir, u16 eir_len)
@@ -4286,6 +4623,3 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
4286 return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev), 4623 return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev),
4287 cmd ? cmd->sk : NULL); 4624 cmd ? cmd->sk : NULL);
4288} 4625}
4289
4290module_param(enable_hs, bool, 0644);
4291MODULE_PARM_DESC(enable_hs, "Enable High Speed support");
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 30b3721dc6d7..072938dc527d 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -544,7 +544,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
544 struct sock *sk = sock->sk; 544 struct sock *sk = sock->sk;
545 struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc; 545 struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
546 struct sk_buff *skb; 546 struct sk_buff *skb;
547 int sent = 0; 547 int sent;
548 548
549 if (test_bit(RFCOMM_DEFER_SETUP, &d->flags)) 549 if (test_bit(RFCOMM_DEFER_SETUP, &d->flags))
550 return -ENOTCONN; 550 return -ENOTCONN;
@@ -559,6 +559,10 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
559 559
560 lock_sock(sk); 560 lock_sock(sk);
561 561
562 sent = bt_sock_wait_ready(sk, msg->msg_flags);
563 if (sent)
564 goto done;
565
562 while (len) { 566 while (len) {
563 size_t size = min_t(size_t, len, d->mtu); 567 size_t size = min_t(size_t, len, d->mtu);
564 int err; 568 int err;
@@ -594,6 +598,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
594 len -= size; 598 len -= size;
595 } 599 }
596 600
601done:
597 release_sock(sk); 602 release_sock(sk);
598 603
599 return sent; 604 return sent;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 6d126faf145f..84fcf9fff3ea 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -569,7 +569,6 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
569static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err) 569static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
570{ 570{
571 struct rfcomm_dev *dev = dlc->owner; 571 struct rfcomm_dev *dev = dlc->owner;
572 struct tty_struct *tty;
573 if (!dev) 572 if (!dev)
574 return; 573 return;
575 574
@@ -581,38 +580,8 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
581 DPM_ORDER_DEV_AFTER_PARENT); 580 DPM_ORDER_DEV_AFTER_PARENT);
582 581
583 wake_up_interruptible(&dev->port.open_wait); 582 wake_up_interruptible(&dev->port.open_wait);
584 } else if (dlc->state == BT_CLOSED) { 583 } else if (dlc->state == BT_CLOSED)
585 tty = tty_port_tty_get(&dev->port); 584 tty_port_tty_hangup(&dev->port, false);
586 if (!tty) {
587 if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) {
588 /* Drop DLC lock here to avoid deadlock
589 * 1. rfcomm_dev_get will take rfcomm_dev_lock
590 * but in rfcomm_dev_add there's lock order:
591 * rfcomm_dev_lock -> dlc lock
592 * 2. tty_port_put will deadlock if it's
593 * the last reference
594 *
595 * FIXME: when we release the lock anything
596 * could happen to dev, even its destruction
597 */
598 rfcomm_dlc_unlock(dlc);
599 if (rfcomm_dev_get(dev->id) == NULL) {
600 rfcomm_dlc_lock(dlc);
601 return;
602 }
603
604 if (!test_and_set_bit(RFCOMM_TTY_RELEASED,
605 &dev->flags))
606 tty_port_put(&dev->port);
607
608 tty_port_put(&dev->port);
609 rfcomm_dlc_lock(dlc);
610 }
611 } else {
612 tty_hangup(tty);
613 tty_kref_put(tty);
614 }
615 }
616} 585}
617 586
618static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig) 587static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b5562abdd6e0..884b2081a262 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -847,16 +847,27 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb)
847 847
848int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) 848int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
849{ 849{
850 __u8 code = skb->data[0]; 850 struct hci_conn *hcon = conn->hcon;
851 __u8 reason; 851 __u8 code, reason;
852 int err = 0; 852 int err = 0;
853 853
854 if (hcon->type != LE_LINK) {
855 kfree_skb(skb);
856 return -ENOTSUPP;
857 }
858
859 if (skb->len < 1) {
860 kfree_skb(skb);
861 return -EILSEQ;
862 }
863
854 if (!test_bit(HCI_LE_ENABLED, &conn->hcon->hdev->dev_flags)) { 864 if (!test_bit(HCI_LE_ENABLED, &conn->hcon->hdev->dev_flags)) {
855 err = -ENOTSUPP; 865 err = -ENOTSUPP;
856 reason = SMP_PAIRING_NOTSUPP; 866 reason = SMP_PAIRING_NOTSUPP;
857 goto done; 867 goto done;
858 } 868 }
859 869
870 code = skb->data[0];
860 skb_pull(skb, sizeof(code)); 871 skb_pull(skb, sizeof(code));
861 872
862 /* 873 /*
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index b9259efa636e..e74ddc1c29a8 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -207,7 +207,7 @@ int br_getlink(struct sk_buff *skb, u32 pid, u32 seq,
207 struct net_device *dev, u32 filter_mask) 207 struct net_device *dev, u32 filter_mask)
208{ 208{
209 int err = 0; 209 int err = 0;
210 struct net_bridge_port *port = br_port_get_rcu(dev); 210 struct net_bridge_port *port = br_port_get_rtnl(dev);
211 211
212 /* not a bridge port and */ 212 /* not a bridge port and */
213 if (!port && !(filter_mask & RTEXT_FILTER_BRVLAN)) 213 if (!port && !(filter_mask & RTEXT_FILTER_BRVLAN))
@@ -451,7 +451,7 @@ static size_t br_get_link_af_size(const struct net_device *dev)
451 struct net_port_vlans *pv; 451 struct net_port_vlans *pv;
452 452
453 if (br_port_exists(dev)) 453 if (br_port_exists(dev))
454 pv = nbp_get_vlan_info(br_port_get_rcu(dev)); 454 pv = nbp_get_vlan_info(br_port_get_rtnl(dev));
455 else if (dev->priv_flags & IFF_EBRIDGE) 455 else if (dev->priv_flags & IFF_EBRIDGE)
456 pv = br_get_vlan_info((struct net_bridge *)netdev_priv(dev)); 456 pv = br_get_vlan_info((struct net_bridge *)netdev_priv(dev));
457 else 457 else
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 598cb0b333c6..efb57d911569 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -202,13 +202,10 @@ struct net_bridge_port
202 202
203static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev) 203static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
204{ 204{
205 struct net_bridge_port *port = 205 return rcu_dereference(dev->rx_handler_data);
206 rcu_dereference_rtnl(dev->rx_handler_data);
207
208 return br_port_exists(dev) ? port : NULL;
209} 206}
210 207
211static inline struct net_bridge_port *br_port_get_rtnl(struct net_device *dev) 208static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
212{ 209{
213 return br_port_exists(dev) ? 210 return br_port_exists(dev) ?
214 rtnl_dereference(dev->rx_handler_data) : NULL; 211 rtnl_dereference(dev->rx_handler_data) : NULL;
@@ -746,6 +743,7 @@ extern struct net_bridge_port *br_get_port(struct net_bridge *br,
746extern void br_init_port(struct net_bridge_port *p); 743extern void br_init_port(struct net_bridge_port *p);
747extern void br_become_designated_port(struct net_bridge_port *p); 744extern void br_become_designated_port(struct net_bridge_port *p);
748 745
746extern void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
749extern int br_set_forward_delay(struct net_bridge *br, unsigned long x); 747extern int br_set_forward_delay(struct net_bridge *br, unsigned long x);
750extern int br_set_hello_time(struct net_bridge *br, unsigned long x); 748extern int br_set_hello_time(struct net_bridge *br, unsigned long x);
751extern int br_set_max_age(struct net_bridge *br, unsigned long x); 749extern int br_set_max_age(struct net_bridge *br, unsigned long x);
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
index 1c0a50f13229..3c86f0538cbb 100644
--- a/net/bridge/br_stp.c
+++ b/net/bridge/br_stp.c
@@ -209,7 +209,7 @@ static void br_record_config_information(struct net_bridge_port *p,
209 p->designated_age = jiffies - bpdu->message_age; 209 p->designated_age = jiffies - bpdu->message_age;
210 210
211 mod_timer(&p->message_age_timer, jiffies 211 mod_timer(&p->message_age_timer, jiffies
212 + (p->br->max_age - bpdu->message_age)); 212 + (bpdu->max_age - bpdu->message_age));
213} 213}
214 214
215/* called under bridge lock */ 215/* called under bridge lock */
@@ -544,18 +544,27 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
544 544
545} 545}
546 546
547void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
548{
549 br->bridge_forward_delay = t;
550 if (br_is_root_bridge(br))
551 br->forward_delay = br->bridge_forward_delay;
552}
553
547int br_set_forward_delay(struct net_bridge *br, unsigned long val) 554int br_set_forward_delay(struct net_bridge *br, unsigned long val)
548{ 555{
549 unsigned long t = clock_t_to_jiffies(val); 556 unsigned long t = clock_t_to_jiffies(val);
557 int err = -ERANGE;
550 558
559 spin_lock_bh(&br->lock);
551 if (br->stp_enabled != BR_NO_STP && 560 if (br->stp_enabled != BR_NO_STP &&
552 (t < BR_MIN_FORWARD_DELAY || t > BR_MAX_FORWARD_DELAY)) 561 (t < BR_MIN_FORWARD_DELAY || t > BR_MAX_FORWARD_DELAY))
553 return -ERANGE; 562 goto unlock;
554 563
555 spin_lock_bh(&br->lock); 564 __br_set_forward_delay(br, t);
556 br->bridge_forward_delay = t; 565 err = 0;
557 if (br_is_root_bridge(br)) 566
558 br->forward_delay = br->bridge_forward_delay; 567unlock:
559 spin_unlock_bh(&br->lock); 568 spin_unlock_bh(&br->lock);
560 return 0; 569 return err;
561} 570}
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index d45e760141bb..108084a04671 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -129,6 +129,14 @@ static void br_stp_start(struct net_bridge *br)
129 char *envp[] = { NULL }; 129 char *envp[] = { NULL };
130 130
131 r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC); 131 r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC);
132
133 spin_lock_bh(&br->lock);
134
135 if (br->bridge_forward_delay < BR_MIN_FORWARD_DELAY)
136 __br_set_forward_delay(br, BR_MIN_FORWARD_DELAY);
137 else if (br->bridge_forward_delay < BR_MAX_FORWARD_DELAY)
138 __br_set_forward_delay(br, BR_MAX_FORWARD_DELAY);
139
132 if (r == 0) { 140 if (r == 0) {
133 br->stp_enabled = BR_USER_STP; 141 br->stp_enabled = BR_USER_STP;
134 br_debug(br, "userspace STP started\n"); 142 br_debug(br, "userspace STP started\n");
@@ -137,10 +145,10 @@ static void br_stp_start(struct net_bridge *br)
137 br_debug(br, "using kernel STP\n"); 145 br_debug(br, "using kernel STP\n");
138 146
139 /* To start timers on any ports left in blocking */ 147 /* To start timers on any ports left in blocking */
140 spin_lock_bh(&br->lock);
141 br_port_state_selection(br); 148 br_port_state_selection(br);
142 spin_unlock_bh(&br->lock);
143 } 149 }
150
151 spin_unlock_bh(&br->lock);
144} 152}
145 153
146static void br_stp_stop(struct net_bridge *br) 154static void br_stp_stop(struct net_bridge *br)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 1606f740d6ae..2b4b32aaa893 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2216,6 +2216,17 @@ void ceph_osdc_sync(struct ceph_osd_client *osdc)
2216EXPORT_SYMBOL(ceph_osdc_sync); 2216EXPORT_SYMBOL(ceph_osdc_sync);
2217 2217
2218/* 2218/*
2219 * Call all pending notify callbacks - for use after a watch is
2220 * unregistered, to make sure no more callbacks for it will be invoked
2221 */
2222extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc)
2223{
2224 flush_workqueue(osdc->notify_wq);
2225}
2226EXPORT_SYMBOL(ceph_osdc_flush_notifies);
2227
2228
2229/*
2219 * init, shutdown 2230 * init, shutdown
2220 */ 2231 */
2221int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client) 2232int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 2c637e9a0b27..fc75c9e461b8 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -550,7 +550,7 @@ static void netpoll_neigh_reply(struct sk_buff *skb, struct netpoll_info *npinfo
550 return; 550 return;
551 551
552 proto = ntohs(eth_hdr(skb)->h_proto); 552 proto = ntohs(eth_hdr(skb)->h_proto);
553 if (proto == ETH_P_IP) { 553 if (proto == ETH_P_ARP) {
554 struct arphdr *arp; 554 struct arphdr *arp;
555 unsigned char *arp_ptr; 555 unsigned char *arp_ptr;
556 /* No arp on this interface */ 556 /* No arp on this interface */
@@ -1284,15 +1284,14 @@ EXPORT_SYMBOL_GPL(__netpoll_free_async);
1284 1284
1285void netpoll_cleanup(struct netpoll *np) 1285void netpoll_cleanup(struct netpoll *np)
1286{ 1286{
1287 if (!np->dev)
1288 return;
1289
1290 rtnl_lock(); 1287 rtnl_lock();
1288 if (!np->dev)
1289 goto out;
1291 __netpoll_cleanup(np); 1290 __netpoll_cleanup(np);
1292 rtnl_unlock();
1293
1294 dev_put(np->dev); 1291 dev_put(np->dev);
1295 np->dev = NULL; 1292 np->dev = NULL;
1293out:
1294 rtnl_unlock();
1296} 1295}
1297EXPORT_SYMBOL(netpoll_cleanup); 1296EXPORT_SYMBOL(netpoll_cleanup);
1298 1297
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 9c61f9c02fdb..6cf9f7782ad4 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -135,6 +135,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
135 135
136 if (dst) 136 if (dst)
137 dst->ops->redirect(dst, sk, skb); 137 dst->ops->redirect(dst, sk, skb);
138 goto out;
138 } 139 }
139 140
140 if (type == ICMPV6_PKT_TOOBIG) { 141 if (type == ICMPV6_PKT_TOOBIG) {
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d6c0e64ec97f..dace87f06e5f 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -369,7 +369,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
369 pip->saddr = fl4.saddr; 369 pip->saddr = fl4.saddr;
370 pip->protocol = IPPROTO_IGMP; 370 pip->protocol = IPPROTO_IGMP;
371 pip->tot_len = 0; /* filled in later */ 371 pip->tot_len = 0; /* filled in later */
372 ip_select_ident(pip, &rt->dst, NULL); 372 ip_select_ident(skb, &rt->dst, NULL);
373 ((u8 *)&pip[1])[0] = IPOPT_RA; 373 ((u8 *)&pip[1])[0] = IPOPT_RA;
374 ((u8 *)&pip[1])[1] = 4; 374 ((u8 *)&pip[1])[1] = 4;
375 ((u8 *)&pip[1])[2] = 0; 375 ((u8 *)&pip[1])[2] = 0;
@@ -714,7 +714,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
714 iph->daddr = dst; 714 iph->daddr = dst;
715 iph->saddr = fl4.saddr; 715 iph->saddr = fl4.saddr;
716 iph->protocol = IPPROTO_IGMP; 716 iph->protocol = IPPROTO_IGMP;
717 ip_select_ident(iph, &rt->dst, NULL); 717 ip_select_ident(skb, &rt->dst, NULL);
718 ((u8 *)&iph[1])[0] = IPOPT_RA; 718 ((u8 *)&iph[1])[0] = IPOPT_RA;
719 ((u8 *)&iph[1])[1] = 4; 719 ((u8 *)&iph[1])[1] = 4;
720 ((u8 *)&iph[1])[2] = 0; 720 ((u8 *)&iph[1])[2] = 0;
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 000e3d239d64..33d5537881ed 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -32,8 +32,8 @@
32 * At the moment of writing this notes identifier of IP packets is generated 32 * At the moment of writing this notes identifier of IP packets is generated
33 * to be unpredictable using this code only for packets subjected 33 * to be unpredictable using this code only for packets subjected
34 * (actually or potentially) to defragmentation. I.e. DF packets less than 34 * (actually or potentially) to defragmentation. I.e. DF packets less than
35 * PMTU in size uses a constant ID and do not use this code (see 35 * PMTU in size when local fragmentation is disabled use a constant ID and do
36 * ip_select_ident() in include/net/ip.h). 36 * not use this code (see ip_select_ident() in include/net/ip.h).
37 * 37 *
38 * Route cache entries hold references to our nodes. 38 * Route cache entries hold references to our nodes.
39 * New cache entries get references via lookup by destination IP address in 39 * New cache entries get references via lookup by destination IP address in
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 9ee17e3d11c3..a04d872c54f9 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -148,7 +148,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
148 iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr); 148 iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
149 iph->saddr = saddr; 149 iph->saddr = saddr;
150 iph->protocol = sk->sk_protocol; 150 iph->protocol = sk->sk_protocol;
151 ip_select_ident(iph, &rt->dst, sk); 151 ip_select_ident(skb, &rt->dst, sk);
152 152
153 if (opt && opt->opt.optlen) { 153 if (opt && opt->opt.optlen) {
154 iph->ihl += opt->opt.optlen>>2; 154 iph->ihl += opt->opt.optlen>>2;
@@ -386,7 +386,7 @@ packet_routed:
386 ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0); 386 ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
387 } 387 }
388 388
389 ip_select_ident_more(iph, &rt->dst, sk, 389 ip_select_ident_more(skb, &rt->dst, sk,
390 (skb_shinfo(skb)->gso_segs ?: 1) - 1); 390 (skb_shinfo(skb)->gso_segs ?: 1) - 1);
391 391
392 skb->priority = sk->sk_priority; 392 skb->priority = sk->sk_priority;
@@ -1316,7 +1316,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
1316 else 1316 else
1317 ttl = ip_select_ttl(inet, &rt->dst); 1317 ttl = ip_select_ttl(inet, &rt->dst);
1318 1318
1319 iph = (struct iphdr *)skb->data; 1319 iph = ip_hdr(skb);
1320 iph->version = 4; 1320 iph->version = 4;
1321 iph->ihl = 5; 1321 iph->ihl = 5;
1322 iph->tos = inet->tos; 1322 iph->tos = inet->tos;
@@ -1324,7 +1324,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
1324 iph->ttl = ttl; 1324 iph->ttl = ttl;
1325 iph->protocol = sk->sk_protocol; 1325 iph->protocol = sk->sk_protocol;
1326 ip_copy_addrs(iph, fl4); 1326 ip_copy_addrs(iph, fl4);
1327 ip_select_ident(iph, &rt->dst, sk); 1327 ip_select_ident(skb, &rt->dst, sk);
1328 1328
1329 if (opt) { 1329 if (opt) {
1330 iph->ihl += opt->optlen>>2; 1330 iph->ihl += opt->optlen>>2;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 9ae54b09254f..62212c772a4b 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1658,7 +1658,7 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
1658 iph->protocol = IPPROTO_IPIP; 1658 iph->protocol = IPPROTO_IPIP;
1659 iph->ihl = 5; 1659 iph->ihl = 5;
1660 iph->tot_len = htons(skb->len); 1660 iph->tot_len = htons(skb->len);
1661 ip_select_ident(iph, skb_dst(skb), NULL); 1661 ip_select_ident(skb, skb_dst(skb), NULL);
1662 ip_send_check(iph); 1662 ip_send_check(iph);
1663 1663
1664 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 1664 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index a86c7ae71881..bfec521c717f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -387,7 +387,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
387 iph->check = 0; 387 iph->check = 0;
388 iph->tot_len = htons(length); 388 iph->tot_len = htons(length);
389 if (!iph->id) 389 if (!iph->id)
390 ip_select_ident(iph, &rt->dst, NULL); 390 ip_select_ident(skb, &rt->dst, NULL);
391 391
392 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); 392 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
393 } 393 }
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 4a22f3e715df..52f3c6b971d2 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -502,7 +502,9 @@ reset:
502 * ACKs, wait for troubles. 502 * ACKs, wait for troubles.
503 */ 503 */
504 if (crtt > tp->srtt) { 504 if (crtt > tp->srtt) {
505 inet_csk(sk)->icsk_rto = crtt + max(crtt >> 2, tcp_rto_min(sk)); 505 /* Set RTO like tcp_rtt_estimator(), but from cached RTT. */
506 crtt >>= 3;
507 inet_csk(sk)->icsk_rto = crtt + max(2 * crtt, tcp_rto_min(sk));
506 } else if (tp->srtt == 0) { 508 } else if (tp->srtt == 0) {
507 /* RFC6298: 5.7 We've failed to get a valid RTT sample from 509 /* RFC6298: 5.7 We've failed to get a valid RTT sample from
508 * 3WHS. This is most likely due to retransmission, 510 * 3WHS. This is most likely due to retransmission,
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index eb1dd4d643f2..b5663c37f089 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -117,7 +117,7 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
117 117
118 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ? 118 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
119 0 : (XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF)); 119 0 : (XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF));
120 ip_select_ident(top_iph, dst->child, NULL); 120 ip_select_ident(skb, dst->child, NULL);
121 121
122 top_iph->ttl = ip4_dst_hoplimit(dst->child); 122 top_iph->ttl = ip4_dst_hoplimit(dst->child);
123 123
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 61355f7f4da5..2d8f4829575b 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1656,9 +1656,9 @@ static int ip6_tnl_fill_info(struct sk_buff *skb, const struct net_device *dev)
1656 1656
1657 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || 1657 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
1658 nla_put(skb, IFLA_IPTUN_LOCAL, sizeof(struct in6_addr), 1658 nla_put(skb, IFLA_IPTUN_LOCAL, sizeof(struct in6_addr),
1659 &parm->raddr) ||
1660 nla_put(skb, IFLA_IPTUN_REMOTE, sizeof(struct in6_addr),
1661 &parm->laddr) || 1659 &parm->laddr) ||
1660 nla_put(skb, IFLA_IPTUN_REMOTE, sizeof(struct in6_addr),
1661 &parm->raddr) ||
1662 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->hop_limit) || 1662 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->hop_limit) ||
1663 nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) || 1663 nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) ||
1664 nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) || 1664 nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
diff --git a/net/ipv6/netfilter/nf_nat_proto_icmpv6.c b/net/ipv6/netfilter/nf_nat_proto_icmpv6.c
index 61aaf70f376e..2205e8eeeacf 100644
--- a/net/ipv6/netfilter/nf_nat_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_nat_proto_icmpv6.c
@@ -69,8 +69,8 @@ icmpv6_manip_pkt(struct sk_buff *skb,
69 hdr = (struct icmp6hdr *)(skb->data + hdroff); 69 hdr = (struct icmp6hdr *)(skb->data + hdroff);
70 l3proto->csum_update(skb, iphdroff, &hdr->icmp6_cksum, 70 l3proto->csum_update(skb, iphdroff, &hdr->icmp6_cksum,
71 tuple, maniptype); 71 tuple, maniptype);
72 if (hdr->icmp6_code == ICMPV6_ECHO_REQUEST || 72 if (hdr->icmp6_type == ICMPV6_ECHO_REQUEST ||
73 hdr->icmp6_code == ICMPV6_ECHO_REPLY) { 73 hdr->icmp6_type == ICMPV6_ECHO_REPLY) {
74 inet_proto_csum_replace2(&hdr->icmp6_cksum, skb, 74 inet_proto_csum_replace2(&hdr->icmp6_cksum, skb,
75 hdr->icmp6_identifier, 75 hdr->icmp6_identifier,
76 tuple->src.u.icmp.id, 0); 76 tuple->src.u.icmp.id, 0);
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 2e7855a1b10d..ac28af74a414 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2865,30 +2865,43 @@ void ieee80211_csa_finalize_work(struct work_struct *work)
2865 if (!ieee80211_sdata_running(sdata)) 2865 if (!ieee80211_sdata_running(sdata))
2866 return; 2866 return;
2867 2867
2868 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP))
2869 return;
2870
2871 sdata->radar_required = sdata->csa_radar_required; 2868 sdata->radar_required = sdata->csa_radar_required;
2872 err = ieee80211_vif_change_channel(sdata, &local->csa_chandef, 2869 err = ieee80211_vif_change_channel(sdata, &local->csa_chandef,
2873 &changed); 2870 &changed);
2874 if (WARN_ON(err < 0)) 2871 if (WARN_ON(err < 0))
2875 return; 2872 return;
2876 2873
2877 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon); 2874 if (!local->use_chanctx) {
2878 if (err < 0) 2875 local->_oper_chandef = local->csa_chandef;
2879 return; 2876 ieee80211_hw_config(local, 0);
2877 }
2880 2878
2881 changed |= err; 2879 ieee80211_bss_info_change_notify(sdata, changed);
2882 kfree(sdata->u.ap.next_beacon); 2880
2883 sdata->u.ap.next_beacon = NULL; 2881 switch (sdata->vif.type) {
2882 case NL80211_IFTYPE_AP:
2883 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
2884 if (err < 0)
2885 return;
2886 changed |= err;
2887 kfree(sdata->u.ap.next_beacon);
2888 sdata->u.ap.next_beacon = NULL;
2889
2890 ieee80211_bss_info_change_notify(sdata, err);
2891 break;
2892 case NL80211_IFTYPE_ADHOC:
2893 ieee80211_ibss_finish_csa(sdata);
2894 break;
2895 default:
2896 WARN_ON(1);
2897 return;
2898 }
2884 sdata->vif.csa_active = false; 2899 sdata->vif.csa_active = false;
2885 2900
2886 ieee80211_wake_queues_by_reason(&sdata->local->hw, 2901 ieee80211_wake_queues_by_reason(&sdata->local->hw,
2887 IEEE80211_MAX_QUEUE_MAP, 2902 IEEE80211_MAX_QUEUE_MAP,
2888 IEEE80211_QUEUE_STOP_REASON_CSA); 2903 IEEE80211_QUEUE_STOP_REASON_CSA);
2889 2904
2890 ieee80211_bss_info_change_notify(sdata, changed);
2891
2892 cfg80211_ch_switch_notify(sdata->dev, &local->csa_chandef); 2905 cfg80211_ch_switch_notify(sdata->dev, &local->csa_chandef);
2893} 2906}
2894 2907
@@ -2936,20 +2949,56 @@ static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
2936 if (sdata->vif.csa_active) 2949 if (sdata->vif.csa_active)
2937 return -EBUSY; 2950 return -EBUSY;
2938 2951
2939 /* only handle AP for now. */
2940 switch (sdata->vif.type) { 2952 switch (sdata->vif.type) {
2941 case NL80211_IFTYPE_AP: 2953 case NL80211_IFTYPE_AP:
2954 sdata->csa_counter_offset_beacon =
2955 params->counter_offset_beacon;
2956 sdata->csa_counter_offset_presp = params->counter_offset_presp;
2957 sdata->u.ap.next_beacon =
2958 cfg80211_beacon_dup(&params->beacon_after);
2959 if (!sdata->u.ap.next_beacon)
2960 return -ENOMEM;
2961
2962 err = ieee80211_assign_beacon(sdata, &params->beacon_csa);
2963 if (err < 0) {
2964 kfree(sdata->u.ap.next_beacon);
2965 return err;
2966 }
2967 break;
2968 case NL80211_IFTYPE_ADHOC:
2969 if (!sdata->vif.bss_conf.ibss_joined)
2970 return -EINVAL;
2971
2972 if (params->chandef.width != sdata->u.ibss.chandef.width)
2973 return -EINVAL;
2974
2975 switch (params->chandef.width) {
2976 case NL80211_CHAN_WIDTH_40:
2977 if (cfg80211_get_chandef_type(&params->chandef) !=
2978 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
2979 return -EINVAL;
2980 case NL80211_CHAN_WIDTH_5:
2981 case NL80211_CHAN_WIDTH_10:
2982 case NL80211_CHAN_WIDTH_20_NOHT:
2983 case NL80211_CHAN_WIDTH_20:
2984 break;
2985 default:
2986 return -EINVAL;
2987 }
2988
2989 /* changes into another band are not supported */
2990 if (sdata->u.ibss.chandef.chan->band !=
2991 params->chandef.chan->band)
2992 return -EINVAL;
2993
2994 err = ieee80211_ibss_csa_beacon(sdata, params);
2995 if (err < 0)
2996 return err;
2942 break; 2997 break;
2943 default: 2998 default:
2944 return -EOPNOTSUPP; 2999 return -EOPNOTSUPP;
2945 } 3000 }
2946 3001
2947 sdata->u.ap.next_beacon = cfg80211_beacon_dup(&params->beacon_after);
2948 if (!sdata->u.ap.next_beacon)
2949 return -ENOMEM;
2950
2951 sdata->csa_counter_offset_beacon = params->counter_offset_beacon;
2952 sdata->csa_counter_offset_presp = params->counter_offset_presp;
2953 sdata->csa_radar_required = params->radar_required; 3002 sdata->csa_radar_required = params->radar_required;
2954 3003
2955 if (params->block_tx) 3004 if (params->block_tx)
@@ -2957,10 +3006,6 @@ static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
2957 IEEE80211_MAX_QUEUE_MAP, 3006 IEEE80211_MAX_QUEUE_MAP,
2958 IEEE80211_QUEUE_STOP_REASON_CSA); 3007 IEEE80211_QUEUE_STOP_REASON_CSA);
2959 3008
2960 err = ieee80211_assign_beacon(sdata, &params->beacon_csa);
2961 if (err < 0)
2962 return err;
2963
2964 local->csa_chandef = params->chandef; 3009 local->csa_chandef = params->chandef;
2965 sdata->vif.csa_active = true; 3010 sdata->vif.csa_active = true;
2966 3011
@@ -3014,7 +3059,8 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3014 need_offchan = true; 3059 need_offchan = true;
3015 if (!ieee80211_is_action(mgmt->frame_control) || 3060 if (!ieee80211_is_action(mgmt->frame_control) ||
3016 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC || 3061 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC ||
3017 mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED) 3062 mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED ||
3063 mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT)
3018 break; 3064 break;
3019 rcu_read_lock(); 3065 rcu_read_lock();
3020 sta = sta_info_get(sdata, mgmt->da); 3066 sta = sta_info_get(sdata, mgmt->da);
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 3a4764b2869e..03ba6b5c5373 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -453,11 +453,6 @@ int ieee80211_vif_change_channel(struct ieee80211_sub_if_data *sdata,
453 chanctx_changed |= IEEE80211_CHANCTX_CHANGE_CHANNEL; 453 chanctx_changed |= IEEE80211_CHANCTX_CHANGE_CHANNEL;
454 drv_change_chanctx(local, ctx, chanctx_changed); 454 drv_change_chanctx(local, ctx, chanctx_changed);
455 455
456 if (!local->use_chanctx) {
457 local->_oper_chandef = *chandef;
458 ieee80211_hw_config(local, 0);
459 }
460
461 ieee80211_recalc_chanctx_chantype(local, ctx); 456 ieee80211_recalc_chanctx_chantype(local, ctx);
462 ieee80211_recalc_smps_chanctx(local, ctx); 457 ieee80211_recalc_smps_chanctx(local, ctx);
463 ieee80211_recalc_radar_chanctx(local, ctx); 458 ieee80211_recalc_radar_chanctx(local, ctx);
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index b0e32d628114..5c090e41d9bb 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -103,54 +103,57 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf,
103 if (!buf) 103 if (!buf)
104 return 0; 104 return 0;
105 105
106 sf += snprintf(buf, mxln - sf, "0x%x\n", local->hw.flags); 106 sf += scnprintf(buf, mxln - sf, "0x%x\n", local->hw.flags);
107 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) 107 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
108 sf += snprintf(buf + sf, mxln - sf, "HAS_RATE_CONTROL\n"); 108 sf += scnprintf(buf + sf, mxln - sf, "HAS_RATE_CONTROL\n");
109 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) 109 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
110 sf += snprintf(buf + sf, mxln - sf, "RX_INCLUDES_FCS\n"); 110 sf += scnprintf(buf + sf, mxln - sf, "RX_INCLUDES_FCS\n");
111 if (local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) 111 if (local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING)
112 sf += snprintf(buf + sf, mxln - sf, 112 sf += scnprintf(buf + sf, mxln - sf,
113 "HOST_BCAST_PS_BUFFERING\n"); 113 "HOST_BCAST_PS_BUFFERING\n");
114 if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE) 114 if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)
115 sf += snprintf(buf + sf, mxln - sf, 115 sf += scnprintf(buf + sf, mxln - sf,
116 "2GHZ_SHORT_SLOT_INCAPABLE\n"); 116 "2GHZ_SHORT_SLOT_INCAPABLE\n");
117 if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE) 117 if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)
118 sf += snprintf(buf + sf, mxln - sf, 118 sf += scnprintf(buf + sf, mxln - sf,
119 "2GHZ_SHORT_PREAMBLE_INCAPABLE\n"); 119 "2GHZ_SHORT_PREAMBLE_INCAPABLE\n");
120 if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) 120 if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)
121 sf += snprintf(buf + sf, mxln - sf, "SIGNAL_UNSPEC\n"); 121 sf += scnprintf(buf + sf, mxln - sf, "SIGNAL_UNSPEC\n");
122 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 122 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
123 sf += snprintf(buf + sf, mxln - sf, "SIGNAL_DBM\n"); 123 sf += scnprintf(buf + sf, mxln - sf, "SIGNAL_DBM\n");
124 if (local->hw.flags & IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC) 124 if (local->hw.flags & IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC)
125 sf += snprintf(buf + sf, mxln - sf, "NEED_DTIM_BEFORE_ASSOC\n"); 125 sf += scnprintf(buf + sf, mxln - sf,
126 "NEED_DTIM_BEFORE_ASSOC\n");
126 if (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT) 127 if (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)
127 sf += snprintf(buf + sf, mxln - sf, "SPECTRUM_MGMT\n"); 128 sf += scnprintf(buf + sf, mxln - sf, "SPECTRUM_MGMT\n");
128 if (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION) 129 if (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION)
129 sf += snprintf(buf + sf, mxln - sf, "AMPDU_AGGREGATION\n"); 130 sf += scnprintf(buf + sf, mxln - sf, "AMPDU_AGGREGATION\n");
130 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PS) 131 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PS)
131 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PS\n"); 132 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_PS\n");
132 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) 133 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
133 sf += snprintf(buf + sf, mxln - sf, "PS_NULLFUNC_STACK\n"); 134 sf += scnprintf(buf + sf, mxln - sf, "PS_NULLFUNC_STACK\n");
134 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) 135 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
135 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n"); 136 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n");
136 if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE) 137 if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE)
137 sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n"); 138 sf += scnprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n");
138 if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) 139 if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS)
139 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n"); 140 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n");
140 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) 141 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS)
141 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_SMPS\n"); 142 sf += scnprintf(buf + sf, mxln - sf,
143 "SUPPORTS_DYNAMIC_SMPS\n");
142 if (local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) 144 if (local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)
143 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_UAPSD\n"); 145 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_UAPSD\n");
144 if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) 146 if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
145 sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n"); 147 sf += scnprintf(buf + sf, mxln - sf,
148 "REPORTS_TX_ACK_STATUS\n");
146 if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) 149 if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
147 sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n"); 150 sf += scnprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n");
148 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK) 151 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)
149 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n"); 152 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n");
150 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) 153 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS)
151 sf += snprintf(buf + sf, mxln - sf, "AP_LINK_PS\n"); 154 sf += scnprintf(buf + sf, mxln - sf, "AP_LINK_PS\n");
152 if (local->hw.flags & IEEE80211_HW_TX_AMPDU_SETUP_IN_HW) 155 if (local->hw.flags & IEEE80211_HW_TX_AMPDU_SETUP_IN_HW)
153 sf += snprintf(buf + sf, mxln - sf, "TX_AMPDU_SETUP_IN_HW\n"); 156 sf += scnprintf(buf + sf, mxln - sf, "TX_AMPDU_SETUP_IN_HW\n");
154 157
155 rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 158 rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
156 kfree(buf); 159 kfree(buf);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index b3ea11f3d526..5d03c47c0a4c 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -1085,4 +1085,31 @@ drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata,
1085 } 1085 }
1086} 1086}
1087 1087
1088static inline int drv_join_ibss(struct ieee80211_local *local,
1089 struct ieee80211_sub_if_data *sdata)
1090{
1091 int ret = 0;
1092
1093 might_sleep();
1094 check_sdata_in_driver(sdata);
1095
1096 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1097 if (local->ops->join_ibss)
1098 ret = local->ops->join_ibss(&local->hw, &sdata->vif);
1099 trace_drv_return_int(local, ret);
1100 return ret;
1101}
1102
1103static inline void drv_leave_ibss(struct ieee80211_local *local,
1104 struct ieee80211_sub_if_data *sdata)
1105{
1106 might_sleep();
1107 check_sdata_in_driver(sdata);
1108
1109 trace_drv_leave_ibss(local, sdata);
1110 if (local->ops->leave_ibss)
1111 local->ops->leave_ibss(&local->hw, &sdata->vif);
1112 trace_drv_return_void(local);
1113}
1114
1088#endif /* __MAC80211_DRIVER_OPS */ 1115#endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index a12afe77bb26..21a0b8835cb3 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -39,7 +39,8 @@ ieee80211_ibss_build_presp(struct ieee80211_sub_if_data *sdata,
39 const int beacon_int, const u32 basic_rates, 39 const int beacon_int, const u32 basic_rates,
40 const u16 capability, u64 tsf, 40 const u16 capability, u64 tsf,
41 struct cfg80211_chan_def *chandef, 41 struct cfg80211_chan_def *chandef,
42 bool *have_higher_than_11mbit) 42 bool *have_higher_than_11mbit,
43 struct cfg80211_csa_settings *csa_settings)
43{ 44{
44 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 45 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
45 struct ieee80211_local *local = sdata->local; 46 struct ieee80211_local *local = sdata->local;
@@ -59,6 +60,7 @@ ieee80211_ibss_build_presp(struct ieee80211_sub_if_data *sdata,
59 2 + 8 /* max Supported Rates */ + 60 2 + 8 /* max Supported Rates */ +
60 3 /* max DS params */ + 61 3 /* max DS params */ +
61 4 /* IBSS params */ + 62 4 /* IBSS params */ +
63 5 /* Channel Switch Announcement */ +
62 2 + (IEEE80211_MAX_SUPP_RATES - 8) + 64 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
63 2 + sizeof(struct ieee80211_ht_cap) + 65 2 + sizeof(struct ieee80211_ht_cap) +
64 2 + sizeof(struct ieee80211_ht_operation) + 66 2 + sizeof(struct ieee80211_ht_operation) +
@@ -135,6 +137,16 @@ ieee80211_ibss_build_presp(struct ieee80211_sub_if_data *sdata,
135 *pos++ = 0; 137 *pos++ = 0;
136 *pos++ = 0; 138 *pos++ = 0;
137 139
140 if (csa_settings) {
141 *pos++ = WLAN_EID_CHANNEL_SWITCH;
142 *pos++ = 3;
143 *pos++ = csa_settings->block_tx ? 1 : 0;
144 *pos++ = ieee80211_frequency_to_channel(
145 csa_settings->chandef.chan->center_freq);
146 sdata->csa_counter_offset_beacon = (pos - presp->head);
147 *pos++ = csa_settings->count;
148 }
149
138 /* put the remaining rates in WLAN_EID_EXT_SUPP_RATES */ 150 /* put the remaining rates in WLAN_EID_EXT_SUPP_RATES */
139 if (rates_n > 8) { 151 if (rates_n > 8) {
140 *pos++ = WLAN_EID_EXT_SUPP_RATES; 152 *pos++ = WLAN_EID_EXT_SUPP_RATES;
@@ -217,6 +229,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
217 struct beacon_data *presp; 229 struct beacon_data *presp;
218 enum nl80211_bss_scan_width scan_width; 230 enum nl80211_bss_scan_width scan_width;
219 bool have_higher_than_11mbit; 231 bool have_higher_than_11mbit;
232 int err;
220 233
221 sdata_assert_lock(sdata); 234 sdata_assert_lock(sdata);
222 235
@@ -235,6 +248,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
235 ieee80211_bss_info_change_notify(sdata, 248 ieee80211_bss_info_change_notify(sdata,
236 BSS_CHANGED_IBSS | 249 BSS_CHANGED_IBSS |
237 BSS_CHANGED_BEACON_ENABLED); 250 BSS_CHANGED_BEACON_ENABLED);
251 drv_leave_ibss(local, sdata);
238 } 252 }
239 253
240 presp = rcu_dereference_protected(ifibss->presp, 254 presp = rcu_dereference_protected(ifibss->presp,
@@ -276,7 +290,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
276 290
277 presp = ieee80211_ibss_build_presp(sdata, beacon_int, basic_rates, 291 presp = ieee80211_ibss_build_presp(sdata, beacon_int, basic_rates,
278 capability, tsf, &chandef, 292 capability, tsf, &chandef,
279 &have_higher_than_11mbit); 293 &have_higher_than_11mbit, NULL);
280 if (!presp) 294 if (!presp)
281 return; 295 return;
282 296
@@ -317,11 +331,26 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
317 else 331 else
318 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 332 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
319 333
334 ieee80211_set_wmm_default(sdata, true);
335
320 sdata->vif.bss_conf.ibss_joined = true; 336 sdata->vif.bss_conf.ibss_joined = true;
321 sdata->vif.bss_conf.ibss_creator = creator; 337 sdata->vif.bss_conf.ibss_creator = creator;
322 ieee80211_bss_info_change_notify(sdata, bss_change);
323 338
324 ieee80211_set_wmm_default(sdata, true); 339 err = drv_join_ibss(local, sdata);
340 if (err) {
341 sdata->vif.bss_conf.ibss_joined = false;
342 sdata->vif.bss_conf.ibss_creator = false;
343 sdata->vif.bss_conf.enable_beacon = false;
344 sdata->vif.bss_conf.ssid_len = 0;
345 RCU_INIT_POINTER(ifibss->presp, NULL);
346 kfree_rcu(presp, rcu_head);
347 ieee80211_vif_release_channel(sdata);
348 sdata_info(sdata, "Failed to join IBSS, driver failure: %d\n",
349 err);
350 return;
351 }
352
353 ieee80211_bss_info_change_notify(sdata, bss_change);
325 354
326 ifibss->state = IEEE80211_IBSS_MLME_JOINED; 355 ifibss->state = IEEE80211_IBSS_MLME_JOINED;
327 mod_timer(&ifibss->timer, 356 mod_timer(&ifibss->timer,
@@ -416,6 +445,169 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
416 tsf, false); 445 tsf, false);
417} 446}
418 447
448static int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
449 struct cfg80211_csa_settings *csa_settings)
450{
451 struct sk_buff *skb;
452 struct ieee80211_mgmt *mgmt;
453 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
454 struct ieee80211_local *local = sdata->local;
455 int freq;
456 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.chan_switch) +
457 sizeof(mgmt->u.action.u.chan_switch);
458 u8 *pos;
459
460 skb = dev_alloc_skb(local->tx_headroom + hdr_len +
461 5 + /* channel switch announcement element */
462 3); /* secondary channel offset element */
463 if (!skb)
464 return -1;
465
466 skb_reserve(skb, local->tx_headroom);
467 mgmt = (struct ieee80211_mgmt *)skb_put(skb, hdr_len);
468 memset(mgmt, 0, hdr_len);
469 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
470 IEEE80211_STYPE_ACTION);
471
472 eth_broadcast_addr(mgmt->da);
473 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
474 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN);
475 mgmt->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT;
476 mgmt->u.action.u.chan_switch.action_code = WLAN_ACTION_SPCT_CHL_SWITCH;
477 pos = skb_put(skb, 5);
478 *pos++ = WLAN_EID_CHANNEL_SWITCH; /* EID */
479 *pos++ = 3; /* IE length */
480 *pos++ = csa_settings->block_tx ? 1 : 0; /* CSA mode */
481 freq = csa_settings->chandef.chan->center_freq;
482 *pos++ = ieee80211_frequency_to_channel(freq); /* channel */
483 *pos++ = csa_settings->count; /* count */
484
485 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_40) {
486 enum nl80211_channel_type ch_type;
487
488 skb_put(skb, 3);
489 *pos++ = WLAN_EID_SECONDARY_CHANNEL_OFFSET; /* EID */
490 *pos++ = 1; /* IE length */
491 ch_type = cfg80211_get_chandef_type(&csa_settings->chandef);
492 if (ch_type == NL80211_CHAN_HT40PLUS)
493 *pos++ = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
494 else
495 *pos++ = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
496 }
497
498 ieee80211_tx_skb(sdata, skb);
499 return 0;
500}
501
502int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
503 struct cfg80211_csa_settings *csa_settings)
504{
505 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
506 struct beacon_data *presp, *old_presp;
507 struct cfg80211_bss *cbss;
508 const struct cfg80211_bss_ies *ies;
509 u16 capability;
510 u64 tsf;
511 int ret = 0;
512
513 sdata_assert_lock(sdata);
514
515 capability = WLAN_CAPABILITY_IBSS;
516
517 if (ifibss->privacy)
518 capability |= WLAN_CAPABILITY_PRIVACY;
519
520 cbss = cfg80211_get_bss(sdata->local->hw.wiphy, ifibss->chandef.chan,
521 ifibss->bssid, ifibss->ssid,
522 ifibss->ssid_len, WLAN_CAPABILITY_IBSS |
523 WLAN_CAPABILITY_PRIVACY,
524 capability);
525
526 if (WARN_ON(!cbss)) {
527 ret = -EINVAL;
528 goto out;
529 }
530
531 rcu_read_lock();
532 ies = rcu_dereference(cbss->ies);
533 tsf = ies->tsf;
534 rcu_read_unlock();
535 cfg80211_put_bss(sdata->local->hw.wiphy, cbss);
536
537 old_presp = rcu_dereference_protected(ifibss->presp,
538 lockdep_is_held(&sdata->wdev.mtx));
539
540 presp = ieee80211_ibss_build_presp(sdata,
541 sdata->vif.bss_conf.beacon_int,
542 sdata->vif.bss_conf.basic_rates,
543 capability, tsf, &ifibss->chandef,
544 NULL, csa_settings);
545 if (!presp) {
546 ret = -ENOMEM;
547 goto out;
548 }
549
550 rcu_assign_pointer(ifibss->presp, presp);
551 if (old_presp)
552 kfree_rcu(old_presp, rcu_head);
553
554 /* it might not send the beacon for a while. send an action frame
555 * immediately to announce the channel switch.
556 */
557 if (csa_settings)
558 ieee80211_send_action_csa(sdata, csa_settings);
559
560 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
561 out:
562 return ret;
563}
564
565int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata)
566{
567 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
568 struct cfg80211_bss *cbss;
569 int err;
570 u16 capability;
571
572 sdata_lock(sdata);
573 /* update cfg80211 bss information with the new channel */
574 if (!is_zero_ether_addr(ifibss->bssid)) {
575 capability = WLAN_CAPABILITY_IBSS;
576
577 if (ifibss->privacy)
578 capability |= WLAN_CAPABILITY_PRIVACY;
579
580 cbss = cfg80211_get_bss(sdata->local->hw.wiphy,
581 ifibss->chandef.chan,
582 ifibss->bssid, ifibss->ssid,
583 ifibss->ssid_len, WLAN_CAPABILITY_IBSS |
584 WLAN_CAPABILITY_PRIVACY,
585 capability);
586 /* XXX: should not really modify cfg80211 data */
587 if (cbss) {
588 cbss->channel = sdata->local->csa_chandef.chan;
589 cfg80211_put_bss(sdata->local->hw.wiphy, cbss);
590 }
591 }
592
593 ifibss->chandef = sdata->local->csa_chandef;
594
595 /* generate the beacon */
596 err = ieee80211_ibss_csa_beacon(sdata, NULL);
597 sdata_unlock(sdata);
598 if (err < 0)
599 return err;
600
601 return 0;
602}
603
604void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata)
605{
606 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
607
608 cancel_work_sync(&ifibss->csa_connection_drop_work);
609}
610
419static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta) 611static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta)
420 __acquires(RCU) 612 __acquires(RCU)
421{ 613{
@@ -499,6 +691,295 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
499 return ieee80211_ibss_finish_sta(sta); 691 return ieee80211_ibss_finish_sta(sta);
500} 692}
501 693
694static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata)
695{
696 struct ieee80211_local *local = sdata->local;
697 int active = 0;
698 struct sta_info *sta;
699
700 sdata_assert_lock(sdata);
701
702 rcu_read_lock();
703
704 list_for_each_entry_rcu(sta, &local->sta_list, list) {
705 if (sta->sdata == sdata &&
706 time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL,
707 jiffies)) {
708 active++;
709 break;
710 }
711 }
712
713 rcu_read_unlock();
714
715 return active;
716}
717
718static void ieee80211_ibss_disconnect(struct ieee80211_sub_if_data *sdata)
719{
720 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
721 struct ieee80211_local *local = sdata->local;
722 struct cfg80211_bss *cbss;
723 struct beacon_data *presp;
724 struct sta_info *sta;
725 int active_ibss;
726 u16 capability;
727
728 active_ibss = ieee80211_sta_active_ibss(sdata);
729
730 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) {
731 capability = WLAN_CAPABILITY_IBSS;
732
733 if (ifibss->privacy)
734 capability |= WLAN_CAPABILITY_PRIVACY;
735
736 cbss = cfg80211_get_bss(local->hw.wiphy, ifibss->chandef.chan,
737 ifibss->bssid, ifibss->ssid,
738 ifibss->ssid_len, WLAN_CAPABILITY_IBSS |
739 WLAN_CAPABILITY_PRIVACY,
740 capability);
741
742 if (cbss) {
743 cfg80211_unlink_bss(local->hw.wiphy, cbss);
744 cfg80211_put_bss(sdata->local->hw.wiphy, cbss);
745 }
746 }
747
748 ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
749
750 sta_info_flush(sdata);
751
752 spin_lock_bh(&ifibss->incomplete_lock);
753 while (!list_empty(&ifibss->incomplete_stations)) {
754 sta = list_first_entry(&ifibss->incomplete_stations,
755 struct sta_info, list);
756 list_del(&sta->list);
757 spin_unlock_bh(&ifibss->incomplete_lock);
758
759 sta_info_free(local, sta);
760 spin_lock_bh(&ifibss->incomplete_lock);
761 }
762 spin_unlock_bh(&ifibss->incomplete_lock);
763
764 netif_carrier_off(sdata->dev);
765
766 sdata->vif.bss_conf.ibss_joined = false;
767 sdata->vif.bss_conf.ibss_creator = false;
768 sdata->vif.bss_conf.enable_beacon = false;
769 sdata->vif.bss_conf.ssid_len = 0;
770
771 /* remove beacon */
772 presp = rcu_dereference_protected(ifibss->presp,
773 lockdep_is_held(&sdata->wdev.mtx));
774 RCU_INIT_POINTER(sdata->u.ibss.presp, NULL);
775 if (presp)
776 kfree_rcu(presp, rcu_head);
777
778 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
779 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
780 BSS_CHANGED_IBSS);
781 drv_leave_ibss(local, sdata);
782 ieee80211_vif_release_channel(sdata);
783}
784
785static void ieee80211_csa_connection_drop_work(struct work_struct *work)
786{
787 struct ieee80211_sub_if_data *sdata =
788 container_of(work, struct ieee80211_sub_if_data,
789 u.ibss.csa_connection_drop_work);
790
791 ieee80211_ibss_disconnect(sdata);
792 synchronize_rcu();
793 skb_queue_purge(&sdata->skb_queue);
794
795 /* trigger a scan to find another IBSS network to join */
796 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
797}
798
799static bool
800ieee80211_ibss_process_chanswitch(struct ieee80211_sub_if_data *sdata,
801 struct ieee802_11_elems *elems,
802 bool beacon)
803{
804 struct cfg80211_csa_settings params;
805 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
806 struct ieee80211_chanctx_conf *chanctx_conf;
807 struct ieee80211_chanctx *chanctx;
808 enum nl80211_channel_type ch_type;
809 int err, num_chanctx;
810 u32 sta_flags;
811 u8 mode;
812
813 if (sdata->vif.csa_active)
814 return true;
815
816 if (!sdata->vif.bss_conf.ibss_joined)
817 return false;
818
819 sta_flags = IEEE80211_STA_DISABLE_VHT;
820 switch (ifibss->chandef.width) {
821 case NL80211_CHAN_WIDTH_5:
822 case NL80211_CHAN_WIDTH_10:
823 case NL80211_CHAN_WIDTH_20_NOHT:
824 sta_flags |= IEEE80211_STA_DISABLE_HT;
825 /* fall through */
826 case NL80211_CHAN_WIDTH_20:
827 sta_flags |= IEEE80211_STA_DISABLE_40MHZ;
828 break;
829 default:
830 break;
831 }
832
833 memset(&params, 0, sizeof(params));
834 err = ieee80211_parse_ch_switch_ie(sdata, elems, beacon,
835 ifibss->chandef.chan->band,
836 sta_flags, ifibss->bssid,
837 &params.count, &mode,
838 &params.chandef);
839
840 /* can't switch to destination channel, fail */
841 if (err < 0)
842 goto disconnect;
843
844 /* did not contain a CSA */
845 if (err)
846 return false;
847
848 if (ifibss->chandef.chan->band != params.chandef.chan->band)
849 goto disconnect;
850
851 switch (ifibss->chandef.width) {
852 case NL80211_CHAN_WIDTH_20_NOHT:
853 case NL80211_CHAN_WIDTH_20:
854 case NL80211_CHAN_WIDTH_40:
855 /* keep our current HT mode (HT20/HT40+/HT40-), even if
856 * another mode has been announced. The mode is not adopted
857 * within the beacon while doing CSA and we should therefore
858 * keep the mode which we announce.
859 */
860 ch_type = cfg80211_get_chandef_type(&ifibss->chandef);
861 cfg80211_chandef_create(&params.chandef, params.chandef.chan,
862 ch_type);
863 break;
864 case NL80211_CHAN_WIDTH_5:
865 case NL80211_CHAN_WIDTH_10:
866 if (params.chandef.width != ifibss->chandef.width) {
867 sdata_info(sdata,
868 "IBSS %pM received channel switch from incompatible channel width (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n",
869 ifibss->bssid,
870 params.chandef.chan->center_freq,
871 params.chandef.width,
872 params.chandef.center_freq1,
873 params.chandef.center_freq2);
874 goto disconnect;
875 }
876 break;
877 default:
878 /* should not happen, sta_flags should prevent VHT modes. */
879 WARN_ON(1);
880 goto disconnect;
881 }
882
883 if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, &params.chandef,
884 IEEE80211_CHAN_DISABLED)) {
885 sdata_info(sdata,
886 "IBSS %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n",
887 ifibss->bssid,
888 params.chandef.chan->center_freq,
889 params.chandef.width,
890 params.chandef.center_freq1,
891 params.chandef.center_freq2);
892 goto disconnect;
893 }
894
895 err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy,
896 &params.chandef);
897 if (err < 0)
898 goto disconnect;
899 if (err) {
900 params.radar_required = true;
901
902 /* TODO: IBSS-DFS not (yet) supported, disconnect. */
903 goto disconnect;
904 }
905
906 rcu_read_lock();
907 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
908 if (!chanctx_conf) {
909 rcu_read_unlock();
910 goto disconnect;
911 }
912
913 /* don't handle for multi-VIF cases */
914 chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
915 if (chanctx->refcount > 1) {
916 rcu_read_unlock();
917 goto disconnect;
918 }
919 num_chanctx = 0;
920 list_for_each_entry_rcu(chanctx, &sdata->local->chanctx_list, list)
921 num_chanctx++;
922
923 if (num_chanctx > 1) {
924 rcu_read_unlock();
925 goto disconnect;
926 }
927 rcu_read_unlock();
928
929 /* all checks done, now perform the channel switch. */
930 ibss_dbg(sdata,
931 "received channel switch announcement to go to channel %d MHz\n",
932 params.chandef.chan->center_freq);
933
934 params.block_tx = !!mode;
935
936 ieee80211_ibss_csa_beacon(sdata, &params);
937 sdata->csa_radar_required = params.radar_required;
938
939 if (params.block_tx)
940 ieee80211_stop_queues_by_reason(&sdata->local->hw,
941 IEEE80211_MAX_QUEUE_MAP,
942 IEEE80211_QUEUE_STOP_REASON_CSA);
943
944 sdata->local->csa_chandef = params.chandef;
945 sdata->vif.csa_active = true;
946
947 ieee80211_bss_info_change_notify(sdata, err);
948 drv_channel_switch_beacon(sdata, &params.chandef);
949
950 return true;
951disconnect:
952 ibss_dbg(sdata, "Can't handle channel switch, disconnect\n");
953 ieee80211_queue_work(&sdata->local->hw,
954 &ifibss->csa_connection_drop_work);
955
956 return true;
957}
958
959static void
960ieee80211_rx_mgmt_spectrum_mgmt(struct ieee80211_sub_if_data *sdata,
961 struct ieee80211_mgmt *mgmt, size_t len,
962 struct ieee80211_rx_status *rx_status,
963 struct ieee802_11_elems *elems)
964{
965 int required_len;
966
967 if (len < IEEE80211_MIN_ACTION_SIZE + 1)
968 return;
969
970 /* CSA is the only action we handle for now */
971 if (mgmt->u.action.u.measurement.action_code !=
972 WLAN_ACTION_SPCT_CHL_SWITCH)
973 return;
974
975 required_len = IEEE80211_MIN_ACTION_SIZE +
976 sizeof(mgmt->u.action.u.chan_switch);
977 if (len < required_len)
978 return;
979
980 ieee80211_ibss_process_chanswitch(sdata, elems, false);
981}
982
502static void ieee80211_rx_mgmt_deauth_ibss(struct ieee80211_sub_if_data *sdata, 983static void ieee80211_rx_mgmt_deauth_ibss(struct ieee80211_sub_if_data *sdata,
503 struct ieee80211_mgmt *mgmt, 984 struct ieee80211_mgmt *mgmt,
504 size_t len) 985 size_t len)
@@ -661,10 +1142,6 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
661 1142
662 /* check if we need to merge IBSS */ 1143 /* check if we need to merge IBSS */
663 1144
664 /* we use a fixed BSSID */
665 if (sdata->u.ibss.fixed_bssid)
666 goto put_bss;
667
668 /* not an IBSS */ 1145 /* not an IBSS */
669 if (!(cbss->capability & WLAN_CAPABILITY_IBSS)) 1146 if (!(cbss->capability & WLAN_CAPABILITY_IBSS))
670 goto put_bss; 1147 goto put_bss;
@@ -680,10 +1157,18 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
680 sdata->u.ibss.ssid_len)) 1157 sdata->u.ibss.ssid_len))
681 goto put_bss; 1158 goto put_bss;
682 1159
1160 /* process channel switch */
1161 if (ieee80211_ibss_process_chanswitch(sdata, elems, true))
1162 goto put_bss;
1163
683 /* same BSSID */ 1164 /* same BSSID */
684 if (ether_addr_equal(cbss->bssid, sdata->u.ibss.bssid)) 1165 if (ether_addr_equal(cbss->bssid, sdata->u.ibss.bssid))
685 goto put_bss; 1166 goto put_bss;
686 1167
1168 /* we use a fixed BSSID */
1169 if (sdata->u.ibss.fixed_bssid)
1170 goto put_bss;
1171
687 if (ieee80211_have_rx_timestamp(rx_status)) { 1172 if (ieee80211_have_rx_timestamp(rx_status)) {
688 /* time when timestamp field was received */ 1173 /* time when timestamp field was received */
689 rx_timestamp = 1174 rx_timestamp =
@@ -775,30 +1260,6 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
775 ieee80211_queue_work(&local->hw, &sdata->work); 1260 ieee80211_queue_work(&local->hw, &sdata->work);
776} 1261}
777 1262
778static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata)
779{
780 struct ieee80211_local *local = sdata->local;
781 int active = 0;
782 struct sta_info *sta;
783
784 sdata_assert_lock(sdata);
785
786 rcu_read_lock();
787
788 list_for_each_entry_rcu(sta, &local->sta_list, list) {
789 if (sta->sdata == sdata &&
790 time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL,
791 jiffies)) {
792 active++;
793 break;
794 }
795 }
796
797 rcu_read_unlock();
798
799 return active;
800}
801
802static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata) 1263static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
803{ 1264{
804 struct ieee80211_local *local = sdata->local; 1265 struct ieee80211_local *local = sdata->local;
@@ -1076,6 +1537,8 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1076 struct ieee80211_rx_status *rx_status; 1537 struct ieee80211_rx_status *rx_status;
1077 struct ieee80211_mgmt *mgmt; 1538 struct ieee80211_mgmt *mgmt;
1078 u16 fc; 1539 u16 fc;
1540 struct ieee802_11_elems elems;
1541 int ies_len;
1079 1542
1080 rx_status = IEEE80211_SKB_RXCB(skb); 1543 rx_status = IEEE80211_SKB_RXCB(skb);
1081 mgmt = (struct ieee80211_mgmt *) skb->data; 1544 mgmt = (struct ieee80211_mgmt *) skb->data;
@@ -1101,6 +1564,27 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1101 case IEEE80211_STYPE_DEAUTH: 1564 case IEEE80211_STYPE_DEAUTH:
1102 ieee80211_rx_mgmt_deauth_ibss(sdata, mgmt, skb->len); 1565 ieee80211_rx_mgmt_deauth_ibss(sdata, mgmt, skb->len);
1103 break; 1566 break;
1567 case IEEE80211_STYPE_ACTION:
1568 switch (mgmt->u.action.category) {
1569 case WLAN_CATEGORY_SPECTRUM_MGMT:
1570 ies_len = skb->len -
1571 offsetof(struct ieee80211_mgmt,
1572 u.action.u.chan_switch.variable);
1573
1574 if (ies_len < 0)
1575 break;
1576
1577 ieee802_11_parse_elems(
1578 mgmt->u.action.u.chan_switch.variable,
1579 ies_len, true, &elems);
1580
1581 if (elems.parse_error)
1582 break;
1583
1584 ieee80211_rx_mgmt_spectrum_mgmt(sdata, mgmt, skb->len,
1585 rx_status, &elems);
1586 break;
1587 }
1104 } 1588 }
1105 1589
1106 mgmt_out: 1590 mgmt_out:
@@ -1167,6 +1651,8 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata)
1167 (unsigned long) sdata); 1651 (unsigned long) sdata);
1168 INIT_LIST_HEAD(&ifibss->incomplete_stations); 1652 INIT_LIST_HEAD(&ifibss->incomplete_stations);
1169 spin_lock_init(&ifibss->incomplete_lock); 1653 spin_lock_init(&ifibss->incomplete_lock);
1654 INIT_WORK(&ifibss->csa_connection_drop_work,
1655 ieee80211_csa_connection_drop_work);
1170} 1656}
1171 1657
1172/* scan finished notification */ 1658/* scan finished notification */
@@ -1265,73 +1751,19 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1265int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) 1751int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1266{ 1752{
1267 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1753 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
1268 struct ieee80211_local *local = sdata->local;
1269 struct cfg80211_bss *cbss;
1270 u16 capability;
1271 int active_ibss;
1272 struct sta_info *sta;
1273 struct beacon_data *presp;
1274
1275 active_ibss = ieee80211_sta_active_ibss(sdata);
1276
1277 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) {
1278 capability = WLAN_CAPABILITY_IBSS;
1279
1280 if (ifibss->privacy)
1281 capability |= WLAN_CAPABILITY_PRIVACY;
1282
1283 cbss = cfg80211_get_bss(local->hw.wiphy, ifibss->chandef.chan,
1284 ifibss->bssid, ifibss->ssid,
1285 ifibss->ssid_len, WLAN_CAPABILITY_IBSS |
1286 WLAN_CAPABILITY_PRIVACY,
1287 capability);
1288 1754
1289 if (cbss) { 1755 ieee80211_ibss_disconnect(sdata);
1290 cfg80211_unlink_bss(local->hw.wiphy, cbss);
1291 cfg80211_put_bss(local->hw.wiphy, cbss);
1292 }
1293 }
1294
1295 ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
1296 memset(ifibss->bssid, 0, ETH_ALEN);
1297 ifibss->ssid_len = 0; 1756 ifibss->ssid_len = 0;
1298 1757 memset(ifibss->bssid, 0, ETH_ALEN);
1299 sta_info_flush(sdata);
1300
1301 spin_lock_bh(&ifibss->incomplete_lock);
1302 while (!list_empty(&ifibss->incomplete_stations)) {
1303 sta = list_first_entry(&ifibss->incomplete_stations,
1304 struct sta_info, list);
1305 list_del(&sta->list);
1306 spin_unlock_bh(&ifibss->incomplete_lock);
1307
1308 sta_info_free(local, sta);
1309 spin_lock_bh(&ifibss->incomplete_lock);
1310 }
1311 spin_unlock_bh(&ifibss->incomplete_lock);
1312
1313 netif_carrier_off(sdata->dev);
1314 1758
1315 /* remove beacon */ 1759 /* remove beacon */
1316 kfree(sdata->u.ibss.ie); 1760 kfree(sdata->u.ibss.ie);
1317 presp = rcu_dereference_protected(ifibss->presp,
1318 lockdep_is_held(&sdata->wdev.mtx));
1319 RCU_INIT_POINTER(sdata->u.ibss.presp, NULL);
1320 1761
1321 /* on the next join, re-program HT parameters */ 1762 /* on the next join, re-program HT parameters */
1322 memset(&ifibss->ht_capa, 0, sizeof(ifibss->ht_capa)); 1763 memset(&ifibss->ht_capa, 0, sizeof(ifibss->ht_capa));
1323 memset(&ifibss->ht_capa_mask, 0, sizeof(ifibss->ht_capa_mask)); 1764 memset(&ifibss->ht_capa_mask, 0, sizeof(ifibss->ht_capa_mask));
1324 1765
1325 sdata->vif.bss_conf.ibss_joined = false;
1326 sdata->vif.bss_conf.ibss_creator = false;
1327 sdata->vif.bss_conf.enable_beacon = false;
1328 sdata->vif.bss_conf.ssid_len = 0;
1329 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1330 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
1331 BSS_CHANGED_IBSS);
1332 ieee80211_vif_release_channel(sdata);
1333 synchronize_rcu(); 1766 synchronize_rcu();
1334 kfree(presp);
1335 1767
1336 skb_queue_purge(&sdata->skb_queue); 1768 skb_queue_purge(&sdata->skb_queue);
1337 1769
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index b6186517ec56..3a87c8976a32 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -322,7 +322,6 @@ struct ieee80211_roc_work {
322 322
323/* flags used in struct ieee80211_if_managed.flags */ 323/* flags used in struct ieee80211_if_managed.flags */
324enum ieee80211_sta_flags { 324enum ieee80211_sta_flags {
325 IEEE80211_STA_BEACON_POLL = BIT(0),
326 IEEE80211_STA_CONNECTION_POLL = BIT(1), 325 IEEE80211_STA_CONNECTION_POLL = BIT(1),
327 IEEE80211_STA_CONTROL_PORT = BIT(2), 326 IEEE80211_STA_CONTROL_PORT = BIT(2),
328 IEEE80211_STA_DISABLE_HT = BIT(4), 327 IEEE80211_STA_DISABLE_HT = BIT(4),
@@ -487,6 +486,7 @@ struct ieee80211_if_managed {
487 486
488struct ieee80211_if_ibss { 487struct ieee80211_if_ibss {
489 struct timer_list timer; 488 struct timer_list timer;
489 struct work_struct csa_connection_drop_work;
490 490
491 unsigned long last_scan_completed; 491 unsigned long last_scan_completed;
492 492
@@ -1330,6 +1330,10 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata);
1330void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata); 1330void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata);
1331void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 1331void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1332 struct sk_buff *skb); 1332 struct sk_buff *skb);
1333int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
1334 struct cfg80211_csa_settings *csa_settings);
1335int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
1336void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
1333 1337
1334/* mesh code */ 1338/* mesh code */
1335void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata); 1339void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
@@ -1481,6 +1485,29 @@ void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata,
1481void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, 1485void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1482 struct ieee80211_mgmt *mgmt, 1486 struct ieee80211_mgmt *mgmt,
1483 size_t len); 1487 size_t len);
1488/**
1489 * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1490 * @sdata: the sdata of the interface which has received the frame
1491 * @elems: parsed 802.11 elements received with the frame
1492 * @beacon: indicates if the frame was a beacon or probe response
1493 * @current_band: indicates the current band
1494 * @sta_flags: contains information about own capabilities and restrictions
1495 * to decide which channel switch announcements can be accepted. Only the
1496 * following subset of &enum ieee80211_sta_flags are evaluated:
1497 * %IEEE80211_STA_DISABLE_HT, %IEEE80211_STA_DISABLE_VHT,
1498 * %IEEE80211_STA_DISABLE_40MHZ, %IEEE80211_STA_DISABLE_80P80MHZ,
1499 * %IEEE80211_STA_DISABLE_160MHZ.
1500 * @count: to be filled with the counter until the switch (on success only)
1501 * @bssid: the currently connected bssid (for reporting)
1502 * @mode: to be filled with CSA mode (on success only)
1503 * @new_chandef: to be filled with destination chandef (on success only)
1504 * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1505 */
1506int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
1507 struct ieee802_11_elems *elems, bool beacon,
1508 enum ieee80211_band current_band,
1509 u32 sta_flags, u8 *bssid, u8 *count, u8 *mode,
1510 struct cfg80211_chan_def *new_chandef);
1484 1511
1485/* Suspend/resume and hw reconfiguration */ 1512/* Suspend/resume and hw reconfiguration */
1486int ieee80211_reconfig(struct ieee80211_local *local); 1513int ieee80211_reconfig(struct ieee80211_local *local);
@@ -1654,6 +1681,7 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
1654void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan, 1681void ieee80211_ht_oper_to_chandef(struct ieee80211_channel *control_chan,
1655 const struct ieee80211_ht_operation *ht_oper, 1682 const struct ieee80211_ht_operation *ht_oper,
1656 struct cfg80211_chan_def *chandef); 1683 struct cfg80211_chan_def *chandef);
1684u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c);
1657 1685
1658int __must_check 1686int __must_check
1659ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata, 1687ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index fcecd633514e..e48f103b9ade 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -766,6 +766,10 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
766 if (sdata->vif.type == NL80211_IFTYPE_STATION) 766 if (sdata->vif.type == NL80211_IFTYPE_STATION)
767 ieee80211_mgd_stop(sdata); 767 ieee80211_mgd_stop(sdata);
768 768
769 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
770 ieee80211_ibss_stop(sdata);
771
772
769 /* 773 /*
770 * Remove all stations associated with this interface. 774 * Remove all stations associated with this interface.
771 * 775 *
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 620677e897bd..3e51dd7d98b3 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -879,7 +879,7 @@ ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
879 keyconf->keylen, keyconf->key, 879 keyconf->keylen, keyconf->key,
880 0, NULL); 880 0, NULL);
881 if (IS_ERR(key)) 881 if (IS_ERR(key))
882 return ERR_PTR(PTR_ERR(key)); 882 return ERR_CAST(key);
883 883
884 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) 884 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
885 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; 885 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 86e4ad56b573..91cc8281e266 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -145,66 +145,6 @@ static int ecw2cw(int ecw)
145 return (1 << ecw) - 1; 145 return (1 << ecw) - 1;
146} 146}
147 147
148static u32 chandef_downgrade(struct cfg80211_chan_def *c)
149{
150 u32 ret;
151 int tmp;
152
153 switch (c->width) {
154 case NL80211_CHAN_WIDTH_20:
155 c->width = NL80211_CHAN_WIDTH_20_NOHT;
156 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
157 break;
158 case NL80211_CHAN_WIDTH_40:
159 c->width = NL80211_CHAN_WIDTH_20;
160 c->center_freq1 = c->chan->center_freq;
161 ret = IEEE80211_STA_DISABLE_40MHZ |
162 IEEE80211_STA_DISABLE_VHT;
163 break;
164 case NL80211_CHAN_WIDTH_80:
165 tmp = (30 + c->chan->center_freq - c->center_freq1)/20;
166 /* n_P40 */
167 tmp /= 2;
168 /* freq_P40 */
169 c->center_freq1 = c->center_freq1 - 20 + 40 * tmp;
170 c->width = NL80211_CHAN_WIDTH_40;
171 ret = IEEE80211_STA_DISABLE_VHT;
172 break;
173 case NL80211_CHAN_WIDTH_80P80:
174 c->center_freq2 = 0;
175 c->width = NL80211_CHAN_WIDTH_80;
176 ret = IEEE80211_STA_DISABLE_80P80MHZ |
177 IEEE80211_STA_DISABLE_160MHZ;
178 break;
179 case NL80211_CHAN_WIDTH_160:
180 /* n_P20 */
181 tmp = (70 + c->chan->center_freq - c->center_freq1)/20;
182 /* n_P80 */
183 tmp /= 4;
184 c->center_freq1 = c->center_freq1 - 40 + 80 * tmp;
185 c->width = NL80211_CHAN_WIDTH_80;
186 ret = IEEE80211_STA_DISABLE_80P80MHZ |
187 IEEE80211_STA_DISABLE_160MHZ;
188 break;
189 default:
190 case NL80211_CHAN_WIDTH_20_NOHT:
191 WARN_ON_ONCE(1);
192 c->width = NL80211_CHAN_WIDTH_20_NOHT;
193 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
194 break;
195 case NL80211_CHAN_WIDTH_5:
196 case NL80211_CHAN_WIDTH_10:
197 WARN_ON_ONCE(1);
198 /* keep c->width */
199 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
200 break;
201 }
202
203 WARN_ON_ONCE(!cfg80211_chandef_valid(c));
204
205 return ret;
206}
207
208static u32 148static u32
209ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, 149ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
210 struct ieee80211_supported_band *sband, 150 struct ieee80211_supported_band *sband,
@@ -352,7 +292,7 @@ out:
352 break; 292 break;
353 } 293 }
354 294
355 ret |= chandef_downgrade(chandef); 295 ret |= ieee80211_chandef_downgrade(chandef);
356 } 296 }
357 297
358 if (chandef->width != vht_chandef.width && !tracking) 298 if (chandef->width != vht_chandef.width && !tracking)
@@ -406,13 +346,13 @@ static int ieee80211_config_bw(struct ieee80211_sub_if_data *sdata,
406 */ 346 */
407 if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ && 347 if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ &&
408 chandef.width == NL80211_CHAN_WIDTH_80P80) 348 chandef.width == NL80211_CHAN_WIDTH_80P80)
409 flags |= chandef_downgrade(&chandef); 349 flags |= ieee80211_chandef_downgrade(&chandef);
410 if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ && 350 if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ &&
411 chandef.width == NL80211_CHAN_WIDTH_160) 351 chandef.width == NL80211_CHAN_WIDTH_160)
412 flags |= chandef_downgrade(&chandef); 352 flags |= ieee80211_chandef_downgrade(&chandef);
413 if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ && 353 if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ &&
414 chandef.width > NL80211_CHAN_WIDTH_20) 354 chandef.width > NL80211_CHAN_WIDTH_20)
415 flags |= chandef_downgrade(&chandef); 355 flags |= ieee80211_chandef_downgrade(&chandef);
416 356
417 if (cfg80211_chandef_identical(&chandef, &sdata->vif.bss_conf.chandef)) 357 if (cfg80211_chandef_identical(&chandef, &sdata->vif.bss_conf.chandef))
418 return 0; 358 return 0;
@@ -893,8 +833,7 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
893 if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) 833 if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
894 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 834 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
895 835
896 if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | 836 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)
897 IEEE80211_STA_CONNECTION_POLL))
898 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE; 837 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE;
899 838
900 ieee80211_tx_skb(sdata, skb); 839 ieee80211_tx_skb(sdata, skb);
@@ -937,6 +876,8 @@ static void ieee80211_chswitch_work(struct work_struct *work)
937 container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); 876 container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work);
938 struct ieee80211_local *local = sdata->local; 877 struct ieee80211_local *local = sdata->local;
939 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 878 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
879 u32 changed = 0;
880 int ret;
940 881
941 if (!ieee80211_sdata_running(sdata)) 882 if (!ieee80211_sdata_running(sdata))
942 return; 883 return;
@@ -945,24 +886,39 @@ static void ieee80211_chswitch_work(struct work_struct *work)
945 if (!ifmgd->associated) 886 if (!ifmgd->associated)
946 goto out; 887 goto out;
947 888
948 local->_oper_chandef = local->csa_chandef; 889 ret = ieee80211_vif_change_channel(sdata, &local->csa_chandef,
890 &changed);
891 if (ret) {
892 sdata_info(sdata,
893 "vif channel switch failed, disconnecting\n");
894 ieee80211_queue_work(&sdata->local->hw,
895 &ifmgd->csa_connection_drop_work);
896 goto out;
897 }
949 898
950 if (!local->ops->channel_switch) { 899 if (!local->use_chanctx) {
951 /* call "hw_config" only if doing sw channel switch */ 900 local->_oper_chandef = local->csa_chandef;
952 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 901 /* Call "hw_config" only if doing sw channel switch.
953 } else { 902 * Otherwise update the channel directly
954 /* update the device channel directly */ 903 */
955 local->hw.conf.chandef = local->_oper_chandef; 904 if (!local->ops->channel_switch)
905 ieee80211_hw_config(local, 0);
906 else
907 local->hw.conf.chandef = local->_oper_chandef;
956 } 908 }
957 909
958 /* XXX: shouldn't really modify cfg80211-owned data! */ 910 /* XXX: shouldn't really modify cfg80211-owned data! */
959 ifmgd->associated->channel = local->_oper_chandef.chan; 911 ifmgd->associated->channel = local->csa_chandef.chan;
960 912
961 /* XXX: wait for a beacon first? */ 913 /* XXX: wait for a beacon first? */
962 ieee80211_wake_queues_by_reason(&local->hw, 914 ieee80211_wake_queues_by_reason(&local->hw,
963 IEEE80211_MAX_QUEUE_MAP, 915 IEEE80211_MAX_QUEUE_MAP,
964 IEEE80211_QUEUE_STOP_REASON_CSA); 916 IEEE80211_QUEUE_STOP_REASON_CSA);
917
918 ieee80211_bss_info_change_notify(sdata, changed);
919
965 out: 920 out:
921 sdata->vif.csa_active = false;
966 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; 922 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
967 sdata_unlock(sdata); 923 sdata_unlock(sdata);
968} 924}
@@ -1000,20 +956,12 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1000 struct ieee80211_local *local = sdata->local; 956 struct ieee80211_local *local = sdata->local;
1001 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 957 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1002 struct cfg80211_bss *cbss = ifmgd->associated; 958 struct cfg80211_bss *cbss = ifmgd->associated;
1003 struct ieee80211_bss *bss;
1004 struct ieee80211_chanctx *chanctx; 959 struct ieee80211_chanctx *chanctx;
1005 enum ieee80211_band new_band; 960 enum ieee80211_band current_band;
1006 int new_freq;
1007 u8 new_chan_no;
1008 u8 count; 961 u8 count;
1009 u8 mode; 962 u8 mode;
1010 struct ieee80211_channel *new_chan;
1011 struct cfg80211_chan_def new_chandef = {}; 963 struct cfg80211_chan_def new_chandef = {};
1012 struct cfg80211_chan_def new_vht_chandef = {}; 964 int res;
1013 const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
1014 const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
1015 const struct ieee80211_ht_operation *ht_oper;
1016 int secondary_channel_offset = -1;
1017 965
1018 sdata_assert_lock(sdata); 966 sdata_assert_lock(sdata);
1019 967
@@ -1027,162 +975,23 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1027 if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED) 975 if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED)
1028 return; 976 return;
1029 977
1030 sec_chan_offs = elems->sec_chan_offs; 978 current_band = cbss->channel->band;
1031 wide_bw_chansw_ie = elems->wide_bw_chansw_ie; 979 res = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, current_band,
1032 ht_oper = elems->ht_operation; 980 ifmgd->flags,
1033 981 ifmgd->associated->bssid, &count,
1034 if (ifmgd->flags & (IEEE80211_STA_DISABLE_HT | 982 &mode, &new_chandef);
1035 IEEE80211_STA_DISABLE_40MHZ)) { 983 if (res < 0)
1036 sec_chan_offs = NULL;
1037 wide_bw_chansw_ie = NULL;
1038 /* only used for bandwidth here */
1039 ht_oper = NULL;
1040 }
1041
1042 if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT)
1043 wide_bw_chansw_ie = NULL;
1044
1045 if (elems->ext_chansw_ie) {
1046 if (!ieee80211_operating_class_to_band(
1047 elems->ext_chansw_ie->new_operating_class,
1048 &new_band)) {
1049 sdata_info(sdata,
1050 "cannot understand ECSA IE operating class %d, disconnecting\n",
1051 elems->ext_chansw_ie->new_operating_class);
1052 ieee80211_queue_work(&local->hw,
1053 &ifmgd->csa_connection_drop_work);
1054 }
1055 new_chan_no = elems->ext_chansw_ie->new_ch_num;
1056 count = elems->ext_chansw_ie->count;
1057 mode = elems->ext_chansw_ie->mode;
1058 } else if (elems->ch_switch_ie) {
1059 new_band = cbss->channel->band;
1060 new_chan_no = elems->ch_switch_ie->new_ch_num;
1061 count = elems->ch_switch_ie->count;
1062 mode = elems->ch_switch_ie->mode;
1063 } else {
1064 /* nothing here we understand */
1065 return;
1066 }
1067
1068 bss = (void *)cbss->priv;
1069
1070 new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
1071 new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
1072 if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) {
1073 sdata_info(sdata,
1074 "AP %pM switches to unsupported channel (%d MHz), disconnecting\n",
1075 ifmgd->associated->bssid, new_freq);
1076 ieee80211_queue_work(&local->hw, 984 ieee80211_queue_work(&local->hw,
1077 &ifmgd->csa_connection_drop_work); 985 &ifmgd->csa_connection_drop_work);
986 if (res)
1078 return; 987 return;
1079 }
1080
1081 if (!beacon && sec_chan_offs) {
1082 secondary_channel_offset = sec_chan_offs->sec_chan_offs;
1083 } else if (beacon && ht_oper) {
1084 secondary_channel_offset =
1085 ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
1086 } else if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) {
1087 /*
1088 * If it's not a beacon, HT is enabled and the IE not present,
1089 * it's 20 MHz, 802.11-2012 8.5.2.6:
1090 * This element [the Secondary Channel Offset Element] is
1091 * present when switching to a 40 MHz channel. It may be
1092 * present when switching to a 20 MHz channel (in which
1093 * case the secondary channel offset is set to SCN).
1094 */
1095 secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
1096 }
1097
1098 switch (secondary_channel_offset) {
1099 default:
1100 /* secondary_channel_offset was present but is invalid */
1101 case IEEE80211_HT_PARAM_CHA_SEC_NONE:
1102 cfg80211_chandef_create(&new_chandef, new_chan,
1103 NL80211_CHAN_HT20);
1104 break;
1105 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
1106 cfg80211_chandef_create(&new_chandef, new_chan,
1107 NL80211_CHAN_HT40PLUS);
1108 break;
1109 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
1110 cfg80211_chandef_create(&new_chandef, new_chan,
1111 NL80211_CHAN_HT40MINUS);
1112 break;
1113 case -1:
1114 cfg80211_chandef_create(&new_chandef, new_chan,
1115 NL80211_CHAN_NO_HT);
1116 /* keep width for 5/10 MHz channels */
1117 switch (sdata->vif.bss_conf.chandef.width) {
1118 case NL80211_CHAN_WIDTH_5:
1119 case NL80211_CHAN_WIDTH_10:
1120 new_chandef.width = sdata->vif.bss_conf.chandef.width;
1121 break;
1122 default:
1123 break;
1124 }
1125 break;
1126 }
1127
1128 if (wide_bw_chansw_ie) {
1129 new_vht_chandef.chan = new_chan;
1130 new_vht_chandef.center_freq1 =
1131 ieee80211_channel_to_frequency(
1132 wide_bw_chansw_ie->new_center_freq_seg0,
1133 new_band);
1134
1135 switch (wide_bw_chansw_ie->new_channel_width) {
1136 default:
1137 /* hmmm, ignore VHT and use HT if present */
1138 case IEEE80211_VHT_CHANWIDTH_USE_HT:
1139 new_vht_chandef.chan = NULL;
1140 break;
1141 case IEEE80211_VHT_CHANWIDTH_80MHZ:
1142 new_vht_chandef.width = NL80211_CHAN_WIDTH_80;
1143 break;
1144 case IEEE80211_VHT_CHANWIDTH_160MHZ:
1145 new_vht_chandef.width = NL80211_CHAN_WIDTH_160;
1146 break;
1147 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
1148 /* field is otherwise reserved */
1149 new_vht_chandef.center_freq2 =
1150 ieee80211_channel_to_frequency(
1151 wide_bw_chansw_ie->new_center_freq_seg1,
1152 new_band);
1153 new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
1154 break;
1155 }
1156 if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ &&
1157 new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
1158 chandef_downgrade(&new_vht_chandef);
1159 if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ &&
1160 new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
1161 chandef_downgrade(&new_vht_chandef);
1162 if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ &&
1163 new_vht_chandef.width > NL80211_CHAN_WIDTH_20)
1164 chandef_downgrade(&new_vht_chandef);
1165 }
1166
1167 /* if VHT data is there validate & use it */
1168 if (new_vht_chandef.chan) {
1169 if (!cfg80211_chandef_compatible(&new_vht_chandef,
1170 &new_chandef)) {
1171 sdata_info(sdata,
1172 "AP %pM CSA has inconsistent channel data, disconnecting\n",
1173 ifmgd->associated->bssid);
1174 ieee80211_queue_work(&local->hw,
1175 &ifmgd->csa_connection_drop_work);
1176 return;
1177 }
1178 new_chandef = new_vht_chandef;
1179 }
1180 988
1181 if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef, 989 if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef,
1182 IEEE80211_CHAN_DISABLED)) { 990 IEEE80211_CHAN_DISABLED)) {
1183 sdata_info(sdata, 991 sdata_info(sdata,
1184 "AP %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n", 992 "AP %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n",
1185 ifmgd->associated->bssid, new_freq, 993 ifmgd->associated->bssid,
994 new_chandef.chan->center_freq,
1186 new_chandef.width, new_chandef.center_freq1, 995 new_chandef.width, new_chandef.center_freq1,
1187 new_chandef.center_freq2); 996 new_chandef.center_freq2);
1188 ieee80211_queue_work(&local->hw, 997 ieee80211_queue_work(&local->hw,
@@ -1191,17 +1000,28 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1191 } 1000 }
1192 1001
1193 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; 1002 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
1003 sdata->vif.csa_active = true;
1194 1004
1005 mutex_lock(&local->chanctx_mtx);
1195 if (local->use_chanctx) { 1006 if (local->use_chanctx) {
1196 sdata_info(sdata, 1007 u32 num_chanctx = 0;
1197 "not handling channel switch with channel contexts\n"); 1008 list_for_each_entry(chanctx, &local->chanctx_list, list)
1198 ieee80211_queue_work(&local->hw, 1009 num_chanctx++;
1199 &ifmgd->csa_connection_drop_work); 1010
1200 return; 1011 if (num_chanctx > 1 ||
1012 !(local->hw.flags & IEEE80211_HW_CHANCTX_STA_CSA)) {
1013 sdata_info(sdata,
1014 "not handling chan-switch with channel contexts\n");
1015 ieee80211_queue_work(&local->hw,
1016 &ifmgd->csa_connection_drop_work);
1017 mutex_unlock(&local->chanctx_mtx);
1018 return;
1019 }
1201 } 1020 }
1202 1021
1203 mutex_lock(&local->chanctx_mtx);
1204 if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) { 1022 if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) {
1023 ieee80211_queue_work(&local->hw,
1024 &ifmgd->csa_connection_drop_work);
1205 mutex_unlock(&local->chanctx_mtx); 1025 mutex_unlock(&local->chanctx_mtx);
1206 return; 1026 return;
1207 } 1027 }
@@ -1374,8 +1194,7 @@ static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data *sdata)
1374 if (!mgd->associated) 1194 if (!mgd->associated)
1375 return false; 1195 return false;
1376 1196
1377 if (mgd->flags & (IEEE80211_STA_BEACON_POLL | 1197 if (mgd->flags & IEEE80211_STA_CONNECTION_POLL)
1378 IEEE80211_STA_CONNECTION_POLL))
1379 return false; 1198 return false;
1380 1199
1381 if (!mgd->have_beacon) 1200 if (!mgd->have_beacon)
@@ -1691,8 +1510,7 @@ static void __ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata)
1691{ 1510{
1692 lockdep_assert_held(&sdata->local->mtx); 1511 lockdep_assert_held(&sdata->local->mtx);
1693 1512
1694 sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | 1513 sdata->u.mgd.flags &= ~IEEE80211_STA_CONNECTION_POLL;
1695 IEEE80211_STA_BEACON_POLL);
1696 ieee80211_run_deferred_scan(sdata->local); 1514 ieee80211_run_deferred_scan(sdata->local);
1697} 1515}
1698 1516
@@ -1954,11 +1772,8 @@ static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata)
1954 struct ieee80211_local *local = sdata->local; 1772 struct ieee80211_local *local = sdata->local;
1955 1773
1956 mutex_lock(&local->mtx); 1774 mutex_lock(&local->mtx);
1957 if (!(ifmgd->flags & (IEEE80211_STA_BEACON_POLL | 1775 if (!(ifmgd->flags & IEEE80211_STA_CONNECTION_POLL))
1958 IEEE80211_STA_CONNECTION_POLL))) { 1776 goto out;
1959 mutex_unlock(&local->mtx);
1960 return;
1961 }
1962 1777
1963 __ieee80211_stop_poll(sdata); 1778 __ieee80211_stop_poll(sdata);
1964 1779
@@ -2094,15 +1909,9 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata,
2094 * because otherwise we would reset the timer every time and 1909 * because otherwise we would reset the timer every time and
2095 * never check whether we received a probe response! 1910 * never check whether we received a probe response!
2096 */ 1911 */
2097 if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | 1912 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)
2098 IEEE80211_STA_CONNECTION_POLL))
2099 already = true; 1913 already = true;
2100 1914
2101 if (beacon)
2102 ifmgd->flags |= IEEE80211_STA_BEACON_POLL;
2103 else
2104 ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL;
2105
2106 mutex_unlock(&sdata->local->mtx); 1915 mutex_unlock(&sdata->local->mtx);
2107 1916
2108 if (already) 1917 if (already)
@@ -2174,6 +1983,7 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
2174 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, 1983 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
2175 true, frame_buf); 1984 true, frame_buf);
2176 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; 1985 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
1986 sdata->vif.csa_active = false;
2177 ieee80211_wake_queues_by_reason(&sdata->local->hw, 1987 ieee80211_wake_queues_by_reason(&sdata->local->hw,
2178 IEEE80211_MAX_QUEUE_MAP, 1988 IEEE80211_MAX_QUEUE_MAP,
2179 IEEE80211_QUEUE_STOP_REASON_CSA); 1989 IEEE80211_QUEUE_STOP_REASON_CSA);
@@ -3061,17 +2871,10 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
3061 } 2871 }
3062 } 2872 }
3063 2873
3064 if (ifmgd->flags & IEEE80211_STA_BEACON_POLL) { 2874 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) {
3065 mlme_dbg_ratelimited(sdata, 2875 mlme_dbg_ratelimited(sdata,
3066 "cancelling AP probe due to a received beacon\n"); 2876 "cancelling AP probe due to a received beacon\n");
3067 mutex_lock(&local->mtx); 2877 ieee80211_reset_ap_probe(sdata);
3068 ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL;
3069 ieee80211_run_deferred_scan(local);
3070 mutex_unlock(&local->mtx);
3071
3072 mutex_lock(&local->iflist_mtx);
3073 ieee80211_recalc_ps(local, -1);
3074 mutex_unlock(&local->iflist_mtx);
3075 } 2878 }
3076 2879
3077 /* 2880 /*
@@ -3543,8 +3346,7 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
3543 } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started) 3346 } else if (ifmgd->assoc_data && ifmgd->assoc_data->timeout_started)
3544 run_again(sdata, ifmgd->assoc_data->timeout); 3347 run_again(sdata, ifmgd->assoc_data->timeout);
3545 3348
3546 if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | 3349 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL &&
3547 IEEE80211_STA_CONNECTION_POLL) &&
3548 ifmgd->associated) { 3350 ifmgd->associated) {
3549 u8 bssid[ETH_ALEN]; 3351 u8 bssid[ETH_ALEN];
3550 int max_tries; 3352 int max_tries;
@@ -3876,7 +3678,7 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
3876 return ret; 3678 return ret;
3877 3679
3878 while (ret && chandef.width != NL80211_CHAN_WIDTH_20_NOHT) { 3680 while (ret && chandef.width != NL80211_CHAN_WIDTH_20_NOHT) {
3879 ifmgd->flags |= chandef_downgrade(&chandef); 3681 ifmgd->flags |= ieee80211_chandef_downgrade(&chandef);
3880 ret = ieee80211_vif_use_channel(sdata, &chandef, 3682 ret = ieee80211_vif_use_channel(sdata, &chandef,
3881 IEEE80211_CHANCTX_SHARED); 3683 IEEE80211_CHANCTX_SHARED);
3882 } 3684 }
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 8b5f7ef7c0c9..7fa1b36e6202 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -203,6 +203,15 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
203 memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate)); 203 memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate));
204 mi->max_prob_rate = tmp_prob_rate; 204 mi->max_prob_rate = tmp_prob_rate;
205 205
206#ifdef CONFIG_MAC80211_DEBUGFS
207 /* use fixed index if set */
208 if (mp->fixed_rate_idx != -1) {
209 mi->max_tp_rate[0] = mp->fixed_rate_idx;
210 mi->max_tp_rate[1] = mp->fixed_rate_idx;
211 mi->max_prob_rate = mp->fixed_rate_idx;
212 }
213#endif
214
206 /* Reset update timer */ 215 /* Reset update timer */
207 mi->stats_update = jiffies; 216 mi->stats_update = jiffies;
208 217
@@ -310,6 +319,11 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
310 /* increase sum packet counter */ 319 /* increase sum packet counter */
311 mi->packet_count++; 320 mi->packet_count++;
312 321
322#ifdef CONFIG_MAC80211_DEBUGFS
323 if (mp->fixed_rate_idx != -1)
324 return;
325#endif
326
313 delta = (mi->packet_count * sampling_ratio / 100) - 327 delta = (mi->packet_count * sampling_ratio / 100) -
314 (mi->sample_count + mi->sample_deferred / 2); 328 (mi->sample_count + mi->sample_deferred / 2);
315 329
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 7c323f27ba23..5d60779a0c1b 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -365,6 +365,14 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
365 } 365 }
366 } 366 }
367 367
368#ifdef CONFIG_MAC80211_DEBUGFS
369 /* use fixed index if set */
370 if (mp->fixed_rate_idx != -1) {
371 mi->max_tp_rate = mp->fixed_rate_idx;
372 mi->max_tp_rate2 = mp->fixed_rate_idx;
373 mi->max_prob_rate = mp->fixed_rate_idx;
374 }
375#endif
368 376
369 mi->stats_update = jiffies; 377 mi->stats_update = jiffies;
370} 378}
@@ -774,6 +782,11 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
774 info->flags |= mi->tx_flags; 782 info->flags |= mi->tx_flags;
775 minstrel_ht_check_cck_shortpreamble(mp, mi, txrc->short_preamble); 783 minstrel_ht_check_cck_shortpreamble(mp, mi, txrc->short_preamble);
776 784
785#ifdef CONFIG_MAC80211_DEBUGFS
786 if (mp->fixed_rate_idx != -1)
787 return;
788#endif
789
777 /* Don't use EAPOL frames for sampling on non-mrr hw */ 790 /* Don't use EAPOL frames for sampling on non-mrr hw */
778 if (mp->hw->max_rates == 1 && 791 if (mp->hw->max_rates == 1 &&
779 (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) 792 (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO))
@@ -781,16 +794,6 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
781 else 794 else
782 sample_idx = minstrel_get_sample_rate(mp, mi); 795 sample_idx = minstrel_get_sample_rate(mp, mi);
783 796
784#ifdef CONFIG_MAC80211_DEBUGFS
785 /* use fixed index if set */
786 if (mp->fixed_rate_idx != -1) {
787 mi->max_tp_rate = mp->fixed_rate_idx;
788 mi->max_tp_rate2 = mp->fixed_rate_idx;
789 mi->max_prob_rate = mp->fixed_rate_idx;
790 sample_idx = -1;
791 }
792#endif
793
794 mi->total_packets++; 797 mi->total_packets++;
795 798
796 /* wraparound */ 799 /* wraparound */
diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
index c97a0657c043..6ff134650a84 100644
--- a/net/mac80211/rc80211_pid_debugfs.c
+++ b/net/mac80211/rc80211_pid_debugfs.c
@@ -167,29 +167,29 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
167 * provide large enough buffers. */ 167 * provide large enough buffers. */
168 length = length < RC_PID_PRINT_BUF_SIZE ? 168 length = length < RC_PID_PRINT_BUF_SIZE ?
169 length : RC_PID_PRINT_BUF_SIZE; 169 length : RC_PID_PRINT_BUF_SIZE;
170 p = snprintf(pb, length, "%u %lu ", ev->id, ev->timestamp); 170 p = scnprintf(pb, length, "%u %lu ", ev->id, ev->timestamp);
171 switch (ev->type) { 171 switch (ev->type) {
172 case RC_PID_EVENT_TYPE_TX_STATUS: 172 case RC_PID_EVENT_TYPE_TX_STATUS:
173 p += snprintf(pb + p, length - p, "tx_status %u %u", 173 p += scnprintf(pb + p, length - p, "tx_status %u %u",
174 !(ev->data.flags & IEEE80211_TX_STAT_ACK), 174 !(ev->data.flags & IEEE80211_TX_STAT_ACK),
175 ev->data.tx_status.status.rates[0].idx); 175 ev->data.tx_status.status.rates[0].idx);
176 break; 176 break;
177 case RC_PID_EVENT_TYPE_RATE_CHANGE: 177 case RC_PID_EVENT_TYPE_RATE_CHANGE:
178 p += snprintf(pb + p, length - p, "rate_change %d %d", 178 p += scnprintf(pb + p, length - p, "rate_change %d %d",
179 ev->data.index, ev->data.rate); 179 ev->data.index, ev->data.rate);
180 break; 180 break;
181 case RC_PID_EVENT_TYPE_TX_RATE: 181 case RC_PID_EVENT_TYPE_TX_RATE:
182 p += snprintf(pb + p, length - p, "tx_rate %d %d", 182 p += scnprintf(pb + p, length - p, "tx_rate %d %d",
183 ev->data.index, ev->data.rate); 183 ev->data.index, ev->data.rate);
184 break; 184 break;
185 case RC_PID_EVENT_TYPE_PF_SAMPLE: 185 case RC_PID_EVENT_TYPE_PF_SAMPLE:
186 p += snprintf(pb + p, length - p, 186 p += scnprintf(pb + p, length - p,
187 "pf_sample %d %d %d %d", 187 "pf_sample %d %d %d %d",
188 ev->data.pf_sample, ev->data.prop_err, 188 ev->data.pf_sample, ev->data.prop_err,
189 ev->data.int_err, ev->data.der_err); 189 ev->data.int_err, ev->data.der_err);
190 break; 190 break;
191 } 191 }
192 p += snprintf(pb + p, length - p, "\n"); 192 p += scnprintf(pb + p, length - p, "\n");
193 193
194 spin_unlock_irqrestore(&events->lock, status); 194 spin_unlock_irqrestore(&events->lock, status);
195 195
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 54395d7583ba..f0247a43a75c 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -995,8 +995,9 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
995 rx->sta->num_duplicates++; 995 rx->sta->num_duplicates++;
996 } 996 }
997 return RX_DROP_UNUSABLE; 997 return RX_DROP_UNUSABLE;
998 } else 998 } else if (!(status->flag & RX_FLAG_AMSDU_MORE)) {
999 rx->sta->last_seq_ctrl[rx->seqno_idx] = hdr->seq_ctrl; 999 rx->sta->last_seq_ctrl[rx->seqno_idx] = hdr->seq_ctrl;
1000 }
1000 } 1001 }
1001 1002
1002 if (unlikely(rx->skb->len < 16)) { 1003 if (unlikely(rx->skb->len < 16)) {
@@ -2402,7 +2403,8 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2402 return RX_DROP_UNUSABLE; 2403 return RX_DROP_UNUSABLE;
2403 2404
2404 if (!rx->sta && mgmt->u.action.category != WLAN_CATEGORY_PUBLIC && 2405 if (!rx->sta && mgmt->u.action.category != WLAN_CATEGORY_PUBLIC &&
2405 mgmt->u.action.category != WLAN_CATEGORY_SELF_PROTECTED) 2406 mgmt->u.action.category != WLAN_CATEGORY_SELF_PROTECTED &&
2407 mgmt->u.action.category != WLAN_CATEGORY_SPECTRUM_MGMT)
2406 return RX_DROP_UNUSABLE; 2408 return RX_DROP_UNUSABLE;
2407 2409
2408 if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) 2410 if (!(status->rx_flags & IEEE80211_RX_RA_MATCH))
@@ -2566,31 +2568,46 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2566 2568
2567 goto queue; 2569 goto queue;
2568 case WLAN_CATEGORY_SPECTRUM_MGMT: 2570 case WLAN_CATEGORY_SPECTRUM_MGMT:
2569 if (status->band != IEEE80211_BAND_5GHZ)
2570 break;
2571
2572 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2573 break;
2574
2575 /* verify action_code is present */ 2571 /* verify action_code is present */
2576 if (len < IEEE80211_MIN_ACTION_SIZE + 1) 2572 if (len < IEEE80211_MIN_ACTION_SIZE + 1)
2577 break; 2573 break;
2578 2574
2579 switch (mgmt->u.action.u.measurement.action_code) { 2575 switch (mgmt->u.action.u.measurement.action_code) {
2580 case WLAN_ACTION_SPCT_MSR_REQ: 2576 case WLAN_ACTION_SPCT_MSR_REQ:
2577 if (status->band != IEEE80211_BAND_5GHZ)
2578 break;
2579
2581 if (len < (IEEE80211_MIN_ACTION_SIZE + 2580 if (len < (IEEE80211_MIN_ACTION_SIZE +
2582 sizeof(mgmt->u.action.u.measurement))) 2581 sizeof(mgmt->u.action.u.measurement)))
2583 break; 2582 break;
2583
2584 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2585 break;
2586
2584 ieee80211_process_measurement_req(sdata, mgmt, len); 2587 ieee80211_process_measurement_req(sdata, mgmt, len);
2585 goto handled; 2588 goto handled;
2586 case WLAN_ACTION_SPCT_CHL_SWITCH: 2589 case WLAN_ACTION_SPCT_CHL_SWITCH: {
2587 if (sdata->vif.type != NL80211_IFTYPE_STATION) 2590 u8 *bssid;
2591 if (len < (IEEE80211_MIN_ACTION_SIZE +
2592 sizeof(mgmt->u.action.u.chan_switch)))
2593 break;
2594
2595 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
2596 sdata->vif.type != NL80211_IFTYPE_ADHOC)
2588 break; 2597 break;
2589 2598
2590 if (!ether_addr_equal(mgmt->bssid, sdata->u.mgd.bssid)) 2599 if (sdata->vif.type == NL80211_IFTYPE_STATION)
2600 bssid = sdata->u.mgd.bssid;
2601 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
2602 bssid = sdata->u.ibss.bssid;
2603 else
2604 break;
2605
2606 if (!ether_addr_equal(mgmt->bssid, bssid))
2591 break; 2607 break;
2592 2608
2593 goto queue; 2609 goto queue;
2610 }
2594 } 2611 }
2595 break; 2612 break;
2596 case WLAN_CATEGORY_SA_QUERY: 2613 case WLAN_CATEGORY_SA_QUERY:
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 08afe74b98f4..ecb57b0bf74a 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -391,8 +391,7 @@ static bool ieee80211_can_scan(struct ieee80211_local *local,
391 return false; 391 return false;
392 392
393 if (sdata->vif.type == NL80211_IFTYPE_STATION && 393 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
394 sdata->u.mgd.flags & (IEEE80211_STA_BEACON_POLL | 394 sdata->u.mgd.flags & IEEE80211_STA_CONNECTION_POLL)
395 IEEE80211_STA_CONNECTION_POLL))
396 return false; 395 return false;
397 396
398 return true; 397 return true;
diff --git a/net/mac80211/spectmgmt.c b/net/mac80211/spectmgmt.c
index 578eea3fc04d..921597e279a3 100644
--- a/net/mac80211/spectmgmt.c
+++ b/net/mac80211/spectmgmt.c
@@ -21,6 +21,168 @@
21#include "sta_info.h" 21#include "sta_info.h"
22#include "wme.h" 22#include "wme.h"
23 23
24int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
25 struct ieee802_11_elems *elems, bool beacon,
26 enum ieee80211_band current_band,
27 u32 sta_flags, u8 *bssid, u8 *count, u8 *mode,
28 struct cfg80211_chan_def *new_chandef)
29{
30 enum ieee80211_band new_band;
31 int new_freq;
32 u8 new_chan_no;
33 struct ieee80211_channel *new_chan;
34 struct cfg80211_chan_def new_vht_chandef = {};
35 const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
36 const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
37 const struct ieee80211_ht_operation *ht_oper;
38 int secondary_channel_offset = -1;
39
40 sec_chan_offs = elems->sec_chan_offs;
41 wide_bw_chansw_ie = elems->wide_bw_chansw_ie;
42 ht_oper = elems->ht_operation;
43
44 if (sta_flags & (IEEE80211_STA_DISABLE_HT |
45 IEEE80211_STA_DISABLE_40MHZ)) {
46 sec_chan_offs = NULL;
47 wide_bw_chansw_ie = NULL;
48 /* only used for bandwidth here */
49 ht_oper = NULL;
50 }
51
52 if (sta_flags & IEEE80211_STA_DISABLE_VHT)
53 wide_bw_chansw_ie = NULL;
54
55 if (elems->ext_chansw_ie) {
56 if (!ieee80211_operating_class_to_band(
57 elems->ext_chansw_ie->new_operating_class,
58 &new_band)) {
59 sdata_info(sdata,
60 "cannot understand ECSA IE operating class %d, disconnecting\n",
61 elems->ext_chansw_ie->new_operating_class);
62 return -EINVAL;
63 }
64 new_chan_no = elems->ext_chansw_ie->new_ch_num;
65 *count = elems->ext_chansw_ie->count;
66 *mode = elems->ext_chansw_ie->mode;
67 } else if (elems->ch_switch_ie) {
68 new_band = current_band;
69 new_chan_no = elems->ch_switch_ie->new_ch_num;
70 *count = elems->ch_switch_ie->count;
71 *mode = elems->ch_switch_ie->mode;
72 } else {
73 /* nothing here we understand */
74 return 1;
75 }
76
77 new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
78 new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
79 if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) {
80 sdata_info(sdata,
81 "BSS %pM switches to unsupported channel (%d MHz), disconnecting\n",
82 bssid, new_freq);
83 return -EINVAL;
84 }
85
86 if (!beacon && sec_chan_offs) {
87 secondary_channel_offset = sec_chan_offs->sec_chan_offs;
88 } else if (beacon && ht_oper) {
89 secondary_channel_offset =
90 ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
91 } else if (!(sta_flags & IEEE80211_STA_DISABLE_HT)) {
92 /* If it's not a beacon, HT is enabled and the IE not present,
93 * it's 20 MHz, 802.11-2012 8.5.2.6:
94 * This element [the Secondary Channel Offset Element] is
95 * present when switching to a 40 MHz channel. It may be
96 * present when switching to a 20 MHz channel (in which
97 * case the secondary channel offset is set to SCN).
98 */
99 secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
100 }
101
102 switch (secondary_channel_offset) {
103 default:
104 /* secondary_channel_offset was present but is invalid */
105 case IEEE80211_HT_PARAM_CHA_SEC_NONE:
106 cfg80211_chandef_create(new_chandef, new_chan,
107 NL80211_CHAN_HT20);
108 break;
109 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
110 cfg80211_chandef_create(new_chandef, new_chan,
111 NL80211_CHAN_HT40PLUS);
112 break;
113 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
114 cfg80211_chandef_create(new_chandef, new_chan,
115 NL80211_CHAN_HT40MINUS);
116 break;
117 case -1:
118 cfg80211_chandef_create(new_chandef, new_chan,
119 NL80211_CHAN_NO_HT);
120 /* keep width for 5/10 MHz channels */
121 switch (sdata->vif.bss_conf.chandef.width) {
122 case NL80211_CHAN_WIDTH_5:
123 case NL80211_CHAN_WIDTH_10:
124 new_chandef->width = sdata->vif.bss_conf.chandef.width;
125 break;
126 default:
127 break;
128 }
129 break;
130 }
131
132 if (wide_bw_chansw_ie) {
133 new_vht_chandef.chan = new_chan;
134 new_vht_chandef.center_freq1 =
135 ieee80211_channel_to_frequency(
136 wide_bw_chansw_ie->new_center_freq_seg0,
137 new_band);
138
139 switch (wide_bw_chansw_ie->new_channel_width) {
140 default:
141 /* hmmm, ignore VHT and use HT if present */
142 case IEEE80211_VHT_CHANWIDTH_USE_HT:
143 new_vht_chandef.chan = NULL;
144 break;
145 case IEEE80211_VHT_CHANWIDTH_80MHZ:
146 new_vht_chandef.width = NL80211_CHAN_WIDTH_80;
147 break;
148 case IEEE80211_VHT_CHANWIDTH_160MHZ:
149 new_vht_chandef.width = NL80211_CHAN_WIDTH_160;
150 break;
151 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
152 /* field is otherwise reserved */
153 new_vht_chandef.center_freq2 =
154 ieee80211_channel_to_frequency(
155 wide_bw_chansw_ie->new_center_freq_seg1,
156 new_band);
157 new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80;
158 break;
159 }
160 if (sta_flags & IEEE80211_STA_DISABLE_80P80MHZ &&
161 new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
162 ieee80211_chandef_downgrade(&new_vht_chandef);
163 if (sta_flags & IEEE80211_STA_DISABLE_160MHZ &&
164 new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
165 ieee80211_chandef_downgrade(&new_vht_chandef);
166 if (sta_flags & IEEE80211_STA_DISABLE_40MHZ &&
167 new_vht_chandef.width > NL80211_CHAN_WIDTH_20)
168 ieee80211_chandef_downgrade(&new_vht_chandef);
169 }
170
171 /* if VHT data is there validate & use it */
172 if (new_vht_chandef.chan) {
173 if (!cfg80211_chandef_compatible(&new_vht_chandef,
174 new_chandef)) {
175 sdata_info(sdata,
176 "BSS %pM: CSA has inconsistent channel data, disconnecting\n",
177 bssid);
178 return -EINVAL;
179 }
180 *new_chandef = new_vht_chandef;
181 }
182
183 return 0;
184}
185
24static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata, 186static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata,
25 struct ieee80211_msrment_ie *request_ie, 187 struct ieee80211_msrment_ie *request_ie,
26 const u8 *da, const u8 *bssid, 188 const u8 *da, const u8 *bssid,
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 1aba645882bd..5d62c5804819 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -1475,6 +1475,41 @@ DEFINE_EVENT(local_sdata_evt, drv_ipv6_addr_change,
1475); 1475);
1476#endif 1476#endif
1477 1477
1478TRACE_EVENT(drv_join_ibss,
1479 TP_PROTO(struct ieee80211_local *local,
1480 struct ieee80211_sub_if_data *sdata,
1481 struct ieee80211_bss_conf *info),
1482
1483 TP_ARGS(local, sdata, info),
1484
1485 TP_STRUCT__entry(
1486 LOCAL_ENTRY
1487 VIF_ENTRY
1488 __field(u8, dtimper)
1489 __field(u16, bcnint)
1490 __dynamic_array(u8, ssid, info->ssid_len);
1491 ),
1492
1493 TP_fast_assign(
1494 LOCAL_ASSIGN;
1495 VIF_ASSIGN;
1496 __entry->dtimper = info->dtim_period;
1497 __entry->bcnint = info->beacon_int;
1498 memcpy(__get_dynamic_array(ssid), info->ssid, info->ssid_len);
1499 ),
1500
1501 TP_printk(
1502 LOCAL_PR_FMT VIF_PR_FMT,
1503 LOCAL_PR_ARG, VIF_PR_ARG
1504 )
1505);
1506
1507DEFINE_EVENT(local_sdata_evt, drv_leave_ibss,
1508 TP_PROTO(struct ieee80211_local *local,
1509 struct ieee80211_sub_if_data *sdata),
1510 TP_ARGS(local, sdata)
1511);
1512
1478/* 1513/*
1479 * Tracing for API calls that drivers call. 1514 * Tracing for API calls that drivers call.
1480 */ 1515 */
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 3456c0486b48..4fcbf634b548 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1981,7 +1981,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1981 * EAPOL frames from the local station. 1981 * EAPOL frames from the local station.
1982 */ 1982 */
1983 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && 1983 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) &&
1984 !is_multicast_ether_addr(hdr.addr1) && !authorized && 1984 !multicast && !authorized &&
1985 (cpu_to_be16(ethertype) != sdata->control_port_protocol || 1985 (cpu_to_be16(ethertype) != sdata->control_port_protocol ||
1986 !ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN)))) { 1986 !ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN)))) {
1987#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 1987#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
@@ -2357,15 +2357,31 @@ static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
2357 struct probe_resp *resp; 2357 struct probe_resp *resp;
2358 int counter_offset_beacon = sdata->csa_counter_offset_beacon; 2358 int counter_offset_beacon = sdata->csa_counter_offset_beacon;
2359 int counter_offset_presp = sdata->csa_counter_offset_presp; 2359 int counter_offset_presp = sdata->csa_counter_offset_presp;
2360 u8 *beacon_data;
2361 size_t beacon_data_len;
2362
2363 switch (sdata->vif.type) {
2364 case NL80211_IFTYPE_AP:
2365 beacon_data = beacon->tail;
2366 beacon_data_len = beacon->tail_len;
2367 break;
2368 case NL80211_IFTYPE_ADHOC:
2369 beacon_data = beacon->head;
2370 beacon_data_len = beacon->head_len;
2371 break;
2372 default:
2373 return;
2374 }
2375 if (WARN_ON(counter_offset_beacon >= beacon_data_len))
2376 return;
2360 2377
2361 /* warn if the driver did not check for/react to csa completeness */ 2378 /* warn if the driver did not check for/react to csa completeness */
2362 if (WARN_ON(((u8 *)beacon->tail)[counter_offset_beacon] == 0)) 2379 if (WARN_ON(beacon_data[counter_offset_beacon] == 0))
2363 return; 2380 return;
2364 2381
2365 ((u8 *)beacon->tail)[counter_offset_beacon]--; 2382 beacon_data[counter_offset_beacon]--;
2366 2383
2367 if (sdata->vif.type == NL80211_IFTYPE_AP && 2384 if (sdata->vif.type == NL80211_IFTYPE_AP && counter_offset_presp) {
2368 counter_offset_presp) {
2369 rcu_read_lock(); 2385 rcu_read_lock();
2370 resp = rcu_dereference(sdata->u.ap.probe_resp); 2386 resp = rcu_dereference(sdata->u.ap.probe_resp);
2371 2387
@@ -2400,6 +2416,15 @@ bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
2400 goto out; 2416 goto out;
2401 beacon_data = beacon->tail; 2417 beacon_data = beacon->tail;
2402 beacon_data_len = beacon->tail_len; 2418 beacon_data_len = beacon->tail_len;
2419 } else if (vif->type == NL80211_IFTYPE_ADHOC) {
2420 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
2421
2422 beacon = rcu_dereference(ifibss->presp);
2423 if (!beacon)
2424 goto out;
2425
2426 beacon_data = beacon->head;
2427 beacon_data_len = beacon->head_len;
2403 } else { 2428 } else {
2404 WARN_ON(1); 2429 WARN_ON(1);
2405 goto out; 2430 goto out;
@@ -2484,6 +2509,10 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2484 if (!presp) 2509 if (!presp)
2485 goto out; 2510 goto out;
2486 2511
2512 if (sdata->vif.csa_active)
2513 ieee80211_update_csa(sdata, presp);
2514
2515
2487 skb = dev_alloc_skb(local->tx_headroom + presp->head_len); 2516 skb = dev_alloc_skb(local->tx_headroom + presp->head_len);
2488 if (!skb) 2517 if (!skb)
2489 goto out; 2518 goto out;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index e1b34a18b243..550a6880625d 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -567,18 +567,15 @@ void ieee80211_flush_queues(struct ieee80211_local *local,
567 IEEE80211_QUEUE_STOP_REASON_FLUSH); 567 IEEE80211_QUEUE_STOP_REASON_FLUSH);
568} 568}
569 569
570void ieee80211_iterate_active_interfaces( 570static void __iterate_active_interfaces(struct ieee80211_local *local,
571 struct ieee80211_hw *hw, u32 iter_flags, 571 u32 iter_flags,
572 void (*iterator)(void *data, u8 *mac, 572 void (*iterator)(void *data, u8 *mac,
573 struct ieee80211_vif *vif), 573 struct ieee80211_vif *vif),
574 void *data) 574 void *data)
575{ 575{
576 struct ieee80211_local *local = hw_to_local(hw);
577 struct ieee80211_sub_if_data *sdata; 576 struct ieee80211_sub_if_data *sdata;
578 577
579 mutex_lock(&local->iflist_mtx); 578 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
580
581 list_for_each_entry(sdata, &local->interfaces, list) {
582 switch (sdata->vif.type) { 579 switch (sdata->vif.type) {
583 case NL80211_IFTYPE_MONITOR: 580 case NL80211_IFTYPE_MONITOR:
584 if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE)) 581 if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
@@ -597,13 +594,25 @@ void ieee80211_iterate_active_interfaces(
597 &sdata->vif); 594 &sdata->vif);
598 } 595 }
599 596
600 sdata = rcu_dereference_protected(local->monitor_sdata, 597 sdata = rcu_dereference_check(local->monitor_sdata,
601 lockdep_is_held(&local->iflist_mtx)); 598 lockdep_is_held(&local->iflist_mtx) ||
599 lockdep_rtnl_is_held());
602 if (sdata && 600 if (sdata &&
603 (iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL || 601 (iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL ||
604 sdata->flags & IEEE80211_SDATA_IN_DRIVER)) 602 sdata->flags & IEEE80211_SDATA_IN_DRIVER))
605 iterator(data, sdata->vif.addr, &sdata->vif); 603 iterator(data, sdata->vif.addr, &sdata->vif);
604}
605
606void ieee80211_iterate_active_interfaces(
607 struct ieee80211_hw *hw, u32 iter_flags,
608 void (*iterator)(void *data, u8 *mac,
609 struct ieee80211_vif *vif),
610 void *data)
611{
612 struct ieee80211_local *local = hw_to_local(hw);
606 613
614 mutex_lock(&local->iflist_mtx);
615 __iterate_active_interfaces(local, iter_flags, iterator, data);
607 mutex_unlock(&local->iflist_mtx); 616 mutex_unlock(&local->iflist_mtx);
608} 617}
609EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces); 618EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces);
@@ -615,38 +624,26 @@ void ieee80211_iterate_active_interfaces_atomic(
615 void *data) 624 void *data)
616{ 625{
617 struct ieee80211_local *local = hw_to_local(hw); 626 struct ieee80211_local *local = hw_to_local(hw);
618 struct ieee80211_sub_if_data *sdata;
619 627
620 rcu_read_lock(); 628 rcu_read_lock();
629 __iterate_active_interfaces(local, iter_flags, iterator, data);
630 rcu_read_unlock();
631}
632EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic);
621 633
622 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 634void ieee80211_iterate_active_interfaces_rtnl(
623 switch (sdata->vif.type) { 635 struct ieee80211_hw *hw, u32 iter_flags,
624 case NL80211_IFTYPE_MONITOR: 636 void (*iterator)(void *data, u8 *mac,
625 if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE)) 637 struct ieee80211_vif *vif),
626 continue; 638 void *data)
627 break; 639{
628 case NL80211_IFTYPE_AP_VLAN: 640 struct ieee80211_local *local = hw_to_local(hw);
629 continue;
630 default:
631 break;
632 }
633 if (!(iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL) &&
634 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
635 continue;
636 if (ieee80211_sdata_running(sdata))
637 iterator(data, sdata->vif.addr,
638 &sdata->vif);
639 }
640 641
641 sdata = rcu_dereference(local->monitor_sdata); 642 ASSERT_RTNL();
642 if (sdata &&
643 (iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL ||
644 sdata->flags & IEEE80211_SDATA_IN_DRIVER))
645 iterator(data, sdata->vif.addr, &sdata->vif);
646 643
647 rcu_read_unlock(); 644 __iterate_active_interfaces(local, iter_flags, iterator, data);
648} 645}
649EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic); 646EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_rtnl);
650 647
651/* 648/*
652 * Nothing should have been stuffed into the workqueue during 649 * Nothing should have been stuffed into the workqueue during
@@ -1007,14 +1004,21 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1007 */ 1004 */
1008 enable_qos = (sdata->vif.type != NL80211_IFTYPE_STATION); 1005 enable_qos = (sdata->vif.type != NL80211_IFTYPE_STATION);
1009 1006
1010 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 1007 /* Set defaults according to 802.11-2007 Table 7-37 */
1011 /* Set defaults according to 802.11-2007 Table 7-37 */ 1008 aCWmax = 1023;
1012 aCWmax = 1023; 1009 if (use_11b)
1013 if (use_11b) 1010 aCWmin = 31;
1014 aCWmin = 31; 1011 else
1015 else 1012 aCWmin = 15;
1016 aCWmin = 15; 1013
1014 /* Confiure old 802.11b/g medium access rules. */
1015 qparam.cw_max = aCWmax;
1016 qparam.cw_min = aCWmin;
1017 qparam.txop = 0;
1018 qparam.aifs = 2;
1017 1019
1020 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1021 /* Update if QoS is enabled. */
1018 if (enable_qos) { 1022 if (enable_qos) {
1019 switch (ac) { 1023 switch (ac) {
1020 case IEEE80211_AC_BK: 1024 case IEEE80211_AC_BK:
@@ -1050,12 +1054,6 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1050 qparam.aifs = 2; 1054 qparam.aifs = 2;
1051 break; 1055 break;
1052 } 1056 }
1053 } else {
1054 /* Confiure old 802.11b/g medium access rules. */
1055 qparam.cw_max = aCWmax;
1056 qparam.cw_min = aCWmin;
1057 qparam.txop = 0;
1058 qparam.aifs = 2;
1059 } 1057 }
1060 1058
1061 qparam.uapsd = false; 1059 qparam.uapsd = false;
@@ -1084,8 +1082,8 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1084 struct ieee80211_mgmt *mgmt; 1082 struct ieee80211_mgmt *mgmt;
1085 int err; 1083 int err;
1086 1084
1087 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 1085 /* 24 + 6 = header + auth_algo + auth_transaction + status_code */
1088 sizeof(*mgmt) + 6 + extra_len); 1086 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24 + 6 + extra_len);
1089 if (!skb) 1087 if (!skb)
1090 return; 1088 return;
1091 1089
@@ -2295,3 +2293,63 @@ void ieee80211_radar_detected(struct ieee80211_hw *hw)
2295 ieee80211_queue_work(hw, &local->radar_detected_work); 2293 ieee80211_queue_work(hw, &local->radar_detected_work);
2296} 2294}
2297EXPORT_SYMBOL(ieee80211_radar_detected); 2295EXPORT_SYMBOL(ieee80211_radar_detected);
2296
2297u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c)
2298{
2299 u32 ret;
2300 int tmp;
2301
2302 switch (c->width) {
2303 case NL80211_CHAN_WIDTH_20:
2304 c->width = NL80211_CHAN_WIDTH_20_NOHT;
2305 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
2306 break;
2307 case NL80211_CHAN_WIDTH_40:
2308 c->width = NL80211_CHAN_WIDTH_20;
2309 c->center_freq1 = c->chan->center_freq;
2310 ret = IEEE80211_STA_DISABLE_40MHZ |
2311 IEEE80211_STA_DISABLE_VHT;
2312 break;
2313 case NL80211_CHAN_WIDTH_80:
2314 tmp = (30 + c->chan->center_freq - c->center_freq1)/20;
2315 /* n_P40 */
2316 tmp /= 2;
2317 /* freq_P40 */
2318 c->center_freq1 = c->center_freq1 - 20 + 40 * tmp;
2319 c->width = NL80211_CHAN_WIDTH_40;
2320 ret = IEEE80211_STA_DISABLE_VHT;
2321 break;
2322 case NL80211_CHAN_WIDTH_80P80:
2323 c->center_freq2 = 0;
2324 c->width = NL80211_CHAN_WIDTH_80;
2325 ret = IEEE80211_STA_DISABLE_80P80MHZ |
2326 IEEE80211_STA_DISABLE_160MHZ;
2327 break;
2328 case NL80211_CHAN_WIDTH_160:
2329 /* n_P20 */
2330 tmp = (70 + c->chan->center_freq - c->center_freq1)/20;
2331 /* n_P80 */
2332 tmp /= 4;
2333 c->center_freq1 = c->center_freq1 - 40 + 80 * tmp;
2334 c->width = NL80211_CHAN_WIDTH_80;
2335 ret = IEEE80211_STA_DISABLE_80P80MHZ |
2336 IEEE80211_STA_DISABLE_160MHZ;
2337 break;
2338 default:
2339 case NL80211_CHAN_WIDTH_20_NOHT:
2340 WARN_ON_ONCE(1);
2341 c->width = NL80211_CHAN_WIDTH_20_NOHT;
2342 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
2343 break;
2344 case NL80211_CHAN_WIDTH_5:
2345 case NL80211_CHAN_WIDTH_10:
2346 WARN_ON_ONCE(1);
2347 /* keep c->width */
2348 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
2349 break;
2350 }
2351
2352 WARN_ON_ONCE(!cfg80211_chandef_valid(c));
2353
2354 return ret;
2355}
diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c
index 97c289414e32..de0112785aae 100644
--- a/net/mac80211/vht.c
+++ b/net/mac80211/vht.c
@@ -185,13 +185,13 @@ ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
185 if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE) { 185 if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE) {
186 vht_cap->cap |= cap_info & 186 vht_cap->cap |= cap_info &
187 (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | 187 (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
188 IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX |
189 IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX); 188 IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX);
190 } 189 }
191 190
192 if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) 191 if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)
193 vht_cap->cap |= cap_info & 192 vht_cap->cap |= cap_info &
194 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; 193 (IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
194 IEEE80211_VHT_CAP_BEAMFORMEE_STS_MAX);
195 195
196 if (own_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) 196 if (own_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)
197 vht_cap->cap |= cap_info & 197 vht_cap->cap |= cap_info &
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index f77139007983..f2e30fb31e78 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1052,7 +1052,7 @@ ip_set_swap(struct sock *ctnl, struct sk_buff *skb,
1052 * Not an artificial restriction anymore, as we must prevent 1052 * Not an artificial restriction anymore, as we must prevent
1053 * possible loops created by swapping in setlist type of sets. */ 1053 * possible loops created by swapping in setlist type of sets. */
1054 if (!(from->type->features == to->type->features && 1054 if (!(from->type->features == to->type->features &&
1055 from->type->family == to->type->family)) 1055 from->family == to->family))
1056 return -IPSET_ERR_TYPE_MISMATCH; 1056 return -IPSET_ERR_TYPE_MISMATCH;
1057 1057
1058 strncpy(from_name, from->name, IPSET_MAXNAMELEN); 1058 strncpy(from_name, from->name, IPSET_MAXNAMELEN);
@@ -1489,8 +1489,7 @@ ip_set_utest(struct sock *ctnl, struct sk_buff *skb,
1489 if (ret == -EAGAIN) 1489 if (ret == -EAGAIN)
1490 ret = 1; 1490 ret = 1;
1491 1491
1492 return (ret < 0 && ret != -ENOTEMPTY) ? ret : 1492 return ret > 0 ? 0 : -IPSET_ERR_EXIST;
1493 ret > 0 ? 0 : -IPSET_ERR_EXIST;
1494} 1493}
1495 1494
1496/* Get headed data of a set */ 1495/* Get headed data of a set */
diff --git a/net/netfilter/ipset/ip_set_getport.c b/net/netfilter/ipset/ip_set_getport.c
index 6fdf88ae2353..dac156f819ac 100644
--- a/net/netfilter/ipset/ip_set_getport.c
+++ b/net/netfilter/ipset/ip_set_getport.c
@@ -116,12 +116,12 @@ ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
116{ 116{
117 int protoff; 117 int protoff;
118 u8 nexthdr; 118 u8 nexthdr;
119 __be16 frag_off; 119 __be16 frag_off = 0;
120 120
121 nexthdr = ipv6_hdr(skb)->nexthdr; 121 nexthdr = ipv6_hdr(skb)->nexthdr;
122 protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr, 122 protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
123 &frag_off); 123 &frag_off);
124 if (protoff < 0) 124 if (protoff < 0 || (frag_off & htons(~0x7)) != 0)
125 return false; 125 return false;
126 126
127 return get_port(skb, nexthdr, protoff, src, port, proto); 127 return get_port(skb, nexthdr, protoff, src, port, proto);
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 57beb1762b2d..707bc520d629 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -325,18 +325,22 @@ mtype_add_cidr(struct htype *h, u8 cidr, u8 nets_length)
325static void 325static void
326mtype_del_cidr(struct htype *h, u8 cidr, u8 nets_length) 326mtype_del_cidr(struct htype *h, u8 cidr, u8 nets_length)
327{ 327{
328 u8 i, j; 328 u8 i, j, net_end = nets_length - 1;
329 329
330 for (i = 0; i < nets_length - 1 && h->nets[i].cidr != cidr; i++) 330 for (i = 0; i < nets_length; i++) {
331 ; 331 if (h->nets[i].cidr != cidr)
332 h->nets[i].nets--; 332 continue;
333 333 if (h->nets[i].nets > 1 || i == net_end ||
334 if (h->nets[i].nets != 0) 334 h->nets[i + 1].nets == 0) {
335 return; 335 h->nets[i].nets--;
336 336 return;
337 for (j = i; j < nets_length - 1 && h->nets[j].nets; j++) { 337 }
338 h->nets[j].cidr = h->nets[j + 1].cidr; 338 for (j = i; j < net_end && h->nets[j].nets; j++) {
339 h->nets[j].nets = h->nets[j + 1].nets; 339 h->nets[j].cidr = h->nets[j + 1].cidr;
340 h->nets[j].nets = h->nets[j + 1].nets;
341 }
342 h->nets[j].nets = 0;
343 return;
340 } 344 }
341} 345}
342#endif 346#endif
diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c
index c6a525373be4..f15f3e28b9c3 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c
@@ -260,7 +260,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
260 e.ip = htonl(ip); 260 e.ip = htonl(ip);
261 e.ip2 = htonl(ip2_from & ip_set_hostmask(e.cidr + 1)); 261 e.ip2 = htonl(ip2_from & ip_set_hostmask(e.cidr + 1));
262 ret = adtfn(set, &e, &ext, &ext, flags); 262 ret = adtfn(set, &e, &ext, &ext, flags);
263 return ip_set_enomatch(ret, flags, adt) ? 1 : 263 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
264 ip_set_eexist(ret, flags) ? 0 : ret; 264 ip_set_eexist(ret, flags) ? 0 : ret;
265 } 265 }
266 266
@@ -544,7 +544,7 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
544 544
545 if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) { 545 if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) {
546 ret = adtfn(set, &e, &ext, &ext, flags); 546 ret = adtfn(set, &e, &ext, &ext, flags);
547 return ip_set_enomatch(ret, flags, adt) ? 1 : 547 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
548 ip_set_eexist(ret, flags) ? 0 : ret; 548 ip_set_eexist(ret, flags) ? 0 : ret;
549 } 549 }
550 550
diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c
index da740ceb56ae..223e9f546d0f 100644
--- a/net/netfilter/ipset/ip_set_hash_net.c
+++ b/net/netfilter/ipset/ip_set_hash_net.c
@@ -199,7 +199,7 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[],
199 if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) { 199 if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) {
200 e.ip = htonl(ip & ip_set_hostmask(e.cidr)); 200 e.ip = htonl(ip & ip_set_hostmask(e.cidr));
201 ret = adtfn(set, &e, &ext, &ext, flags); 201 ret = adtfn(set, &e, &ext, &ext, flags);
202 return ip_set_enomatch(ret, flags, adt) ? 1 : 202 return ip_set_enomatch(ret, flags, adt, set) ? -ret:
203 ip_set_eexist(ret, flags) ? 0 : ret; 203 ip_set_eexist(ret, flags) ? 0 : ret;
204 } 204 }
205 205
@@ -396,7 +396,7 @@ hash_net6_uadt(struct ip_set *set, struct nlattr *tb[],
396 396
397 ret = adtfn(set, &e, &ext, &ext, flags); 397 ret = adtfn(set, &e, &ext, &ext, flags);
398 398
399 return ip_set_enomatch(ret, flags, adt) ? 1 : 399 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
400 ip_set_eexist(ret, flags) ? 0 : ret; 400 ip_set_eexist(ret, flags) ? 0 : ret;
401} 401}
402 402
diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c
index 84ae6f6ce624..7d798d5d5cd3 100644
--- a/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -368,7 +368,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
368 if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) { 368 if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) {
369 e.ip = htonl(ip & ip_set_hostmask(e.cidr)); 369 e.ip = htonl(ip & ip_set_hostmask(e.cidr));
370 ret = adtfn(set, &e, &ext, &ext, flags); 370 ret = adtfn(set, &e, &ext, &ext, flags);
371 return ip_set_enomatch(ret, flags, adt) ? 1 : 371 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
372 ip_set_eexist(ret, flags) ? 0 : ret; 372 ip_set_eexist(ret, flags) ? 0 : ret;
373 } 373 }
374 374
@@ -634,7 +634,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
634 634
635 ret = adtfn(set, &e, &ext, &ext, flags); 635 ret = adtfn(set, &e, &ext, &ext, flags);
636 636
637 return ip_set_enomatch(ret, flags, adt) ? 1 : 637 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
638 ip_set_eexist(ret, flags) ? 0 : ret; 638 ip_set_eexist(ret, flags) ? 0 : ret;
639} 639}
640 640
diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c
index 9a0869853be5..09d6690bee6f 100644
--- a/net/netfilter/ipset/ip_set_hash_netport.c
+++ b/net/netfilter/ipset/ip_set_hash_netport.c
@@ -244,7 +244,7 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[],
244 if (adt == IPSET_TEST || !(with_ports || tb[IPSET_ATTR_IP_TO])) { 244 if (adt == IPSET_TEST || !(with_ports || tb[IPSET_ATTR_IP_TO])) {
245 e.ip = htonl(ip & ip_set_hostmask(e.cidr + 1)); 245 e.ip = htonl(ip & ip_set_hostmask(e.cidr + 1));
246 ret = adtfn(set, &e, &ext, &ext, flags); 246 ret = adtfn(set, &e, &ext, &ext, flags);
247 return ip_set_enomatch(ret, flags, adt) ? 1 : 247 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
248 ip_set_eexist(ret, flags) ? 0 : ret; 248 ip_set_eexist(ret, flags) ? 0 : ret;
249 } 249 }
250 250
@@ -489,7 +489,7 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[],
489 489
490 if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) { 490 if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) {
491 ret = adtfn(set, &e, &ext, &ext, flags); 491 ret = adtfn(set, &e, &ext, &ext, flags);
492 return ip_set_enomatch(ret, flags, adt) ? 1 : 492 return ip_set_enomatch(ret, flags, adt, set) ? -ret :
493 ip_set_eexist(ret, flags) ? 0 : ret; 493 ip_set_eexist(ret, flags) ? 0 : ret;
494 } 494 }
495 495
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index b75ff6429a04..c47444e4cf8c 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -883,7 +883,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
883 iph->daddr = cp->daddr.ip; 883 iph->daddr = cp->daddr.ip;
884 iph->saddr = saddr; 884 iph->saddr = saddr;
885 iph->ttl = old_iph->ttl; 885 iph->ttl = old_iph->ttl;
886 ip_select_ident(iph, &rt->dst, NULL); 886 ip_select_ident(skb, &rt->dst, NULL);
887 887
888 /* Another hack: avoid icmp_send in ip_fragment */ 888 /* Another hack: avoid icmp_send in ip_fragment */
889 skb->local_df = 1; 889 skb->local_df = 1;
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index 95a98c8c1da6..ae2e5c11d01a 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -1009,7 +1009,7 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
1009 verdict = NF_DROP; 1009 verdict = NF_DROP;
1010 1010
1011 if (ct) 1011 if (ct)
1012 nfqnl_ct_seq_adjust(skb, ct, ctinfo, diff); 1012 nfqnl_ct_seq_adjust(entry->skb, ct, ctinfo, diff);
1013 } 1013 }
1014 1014
1015 if (nfqa[NFQA_MARK]) 1015 if (nfqa[NFQA_MARK])
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 5f2068679f83..98b69bbecdd9 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -634,8 +634,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
634 break; 634 break;
635 case ICMP_REDIRECT: 635 case ICMP_REDIRECT:
636 sctp_icmp_redirect(sk, transport, skb); 636 sctp_icmp_redirect(sk, transport, skb);
637 err = 0; 637 /* Fall through to out_unlock. */
638 break;
639 default: 638 default:
640 goto out_unlock; 639 goto out_unlock;
641 } 640 }
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index da613ceae28c..e7b2d4fe2b6a 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -183,7 +183,7 @@ static void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
183 break; 183 break;
184 case NDISC_REDIRECT: 184 case NDISC_REDIRECT:
185 sctp_icmp_redirect(sk, transport, skb); 185 sctp_icmp_redirect(sk, transport, skb);
186 break; 186 goto out_unlock;
187 default: 187 default:
188 break; 188 break;
189 } 189 }
@@ -204,44 +204,23 @@ out:
204 in6_dev_put(idev); 204 in6_dev_put(idev);
205} 205}
206 206
207/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
208static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) 207static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
209{ 208{
210 struct sock *sk = skb->sk; 209 struct sock *sk = skb->sk;
211 struct ipv6_pinfo *np = inet6_sk(sk); 210 struct ipv6_pinfo *np = inet6_sk(sk);
212 struct flowi6 fl6; 211 struct flowi6 *fl6 = &transport->fl.u.ip6;
213
214 memset(&fl6, 0, sizeof(fl6));
215
216 fl6.flowi6_proto = sk->sk_protocol;
217
218 /* Fill in the dest address from the route entry passed with the skb
219 * and the source address from the transport.
220 */
221 fl6.daddr = transport->ipaddr.v6.sin6_addr;
222 fl6.saddr = transport->saddr.v6.sin6_addr;
223
224 fl6.flowlabel = np->flow_label;
225 IP6_ECN_flow_xmit(sk, fl6.flowlabel);
226 if (ipv6_addr_type(&fl6.saddr) & IPV6_ADDR_LINKLOCAL)
227 fl6.flowi6_oif = transport->saddr.v6.sin6_scope_id;
228 else
229 fl6.flowi6_oif = sk->sk_bound_dev_if;
230
231 if (np->opt && np->opt->srcrt) {
232 struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
233 fl6.daddr = *rt0->addr;
234 }
235 212
236 pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb, 213 pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
237 skb->len, &fl6.saddr, &fl6.daddr); 214 skb->len, &fl6->saddr, &fl6->daddr);
238 215
239 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS); 216 IP6_ECN_flow_xmit(sk, fl6->flowlabel);
240 217
241 if (!(transport->param_flags & SPP_PMTUD_ENABLE)) 218 if (!(transport->param_flags & SPP_PMTUD_ENABLE))
242 skb->local_df = 1; 219 skb->local_df = 1;
243 220
244 return ip6_xmit(sk, skb, &fl6, np->opt, np->tclass); 221 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
222
223 return ip6_xmit(sk, skb, fl6, np->opt, np->tclass);
245} 224}
246 225
247/* Returns the dst cache entry for the given source and destination ip 226/* Returns the dst cache entry for the given source and destination ip
@@ -254,10 +233,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
254 struct dst_entry *dst = NULL; 233 struct dst_entry *dst = NULL;
255 struct flowi6 *fl6 = &fl->u.ip6; 234 struct flowi6 *fl6 = &fl->u.ip6;
256 struct sctp_bind_addr *bp; 235 struct sctp_bind_addr *bp;
236 struct ipv6_pinfo *np = inet6_sk(sk);
257 struct sctp_sockaddr_entry *laddr; 237 struct sctp_sockaddr_entry *laddr;
258 union sctp_addr *baddr = NULL; 238 union sctp_addr *baddr = NULL;
259 union sctp_addr *daddr = &t->ipaddr; 239 union sctp_addr *daddr = &t->ipaddr;
260 union sctp_addr dst_saddr; 240 union sctp_addr dst_saddr;
241 struct in6_addr *final_p, final;
261 __u8 matchlen = 0; 242 __u8 matchlen = 0;
262 __u8 bmatchlen; 243 __u8 bmatchlen;
263 sctp_scope_t scope; 244 sctp_scope_t scope;
@@ -281,7 +262,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
281 pr_debug("src=%pI6 - ", &fl6->saddr); 262 pr_debug("src=%pI6 - ", &fl6->saddr);
282 } 263 }
283 264
284 dst = ip6_dst_lookup_flow(sk, fl6, NULL, false); 265 final_p = fl6_update_dst(fl6, np->opt, &final);
266 dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
285 if (!asoc || saddr) 267 if (!asoc || saddr)
286 goto out; 268 goto out;
287 269
@@ -333,10 +315,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
333 } 315 }
334 } 316 }
335 rcu_read_unlock(); 317 rcu_read_unlock();
318
336 if (baddr) { 319 if (baddr) {
337 fl6->saddr = baddr->v6.sin6_addr; 320 fl6->saddr = baddr->v6.sin6_addr;
338 fl6->fl6_sport = baddr->v6.sin6_port; 321 fl6->fl6_sport = baddr->v6.sin6_port;
339 dst = ip6_dst_lookup_flow(sk, fl6, NULL, false); 322 final_p = fl6_update_dst(fl6, np->opt, &final);
323 dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
340 } 324 }
341 325
342out: 326out:
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 50f6195c8b70..16f3c3a7b2c1 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -328,6 +328,7 @@ int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
328 return cfg80211_get_chans_dfs_required(wiphy, chandef->center_freq2, 328 return cfg80211_get_chans_dfs_required(wiphy, chandef->center_freq2,
329 width); 329 width);
330} 330}
331EXPORT_SYMBOL(cfg80211_chandef_dfs_required);
331 332
332static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy, 333static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
333 u32 center_freq, u32 bandwidth, 334 u32 center_freq, u32 bandwidth,
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 9ad43c619c54..b43efac4efca 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -382,15 +382,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
382 enum cfg80211_chan_mode chanmode, 382 enum cfg80211_chan_mode chanmode,
383 u8 radar_detect); 383 u8 radar_detect);
384 384
385/**
386 * cfg80211_chandef_dfs_required - checks if radar detection is required
387 * @wiphy: the wiphy to validate against
388 * @chandef: the channel definition to check
389 * Return: 1 if radar detection is required, 0 if it is not, < 0 on error
390 */
391int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
392 const struct cfg80211_chan_def *c);
393
394void cfg80211_set_dfs_state(struct wiphy *wiphy, 385void cfg80211_set_dfs_state(struct wiphy *wiphy,
395 const struct cfg80211_chan_def *chandef, 386 const struct cfg80211_chan_def *chandef,
396 enum nl80211_dfs_state dfs_state); 387 enum nl80211_dfs_state dfs_state);
diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c
index 90d050036624..454157717efa 100644
--- a/net/wireless/debugfs.c
+++ b/net/wireless/debugfs.c
@@ -47,17 +47,19 @@ static int ht_print_chan(struct ieee80211_channel *chan,
47 return 0; 47 return 0;
48 48
49 if (chan->flags & IEEE80211_CHAN_DISABLED) 49 if (chan->flags & IEEE80211_CHAN_DISABLED)
50 return snprintf(buf + offset, 50 return scnprintf(buf + offset,
51 buf_size - offset, 51 buf_size - offset,
52 "%d Disabled\n", 52 "%d Disabled\n",
53 chan->center_freq); 53 chan->center_freq);
54 54
55 return snprintf(buf + offset, 55 return scnprintf(buf + offset,
56 buf_size - offset, 56 buf_size - offset,
57 "%d HT40 %c%c\n", 57 "%d HT40 %c%c\n",
58 chan->center_freq, 58 chan->center_freq,
59 (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) ? ' ' : '-', 59 (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) ?
60 (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) ? ' ' : '+'); 60 ' ' : '-',
61 (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) ?
62 ' ' : '+');
61} 63}
62 64
63static ssize_t ht40allow_map_read(struct file *file, 65static ssize_t ht40allow_map_read(struct file *file,
diff --git a/net/wireless/genregdb.awk b/net/wireless/genregdb.awk
index 9392f8cbb901..42ed274e81f4 100644
--- a/net/wireless/genregdb.awk
+++ b/net/wireless/genregdb.awk
@@ -46,6 +46,12 @@ BEGIN {
46 sub(/:/, "", country) 46 sub(/:/, "", country)
47 printf "static const struct ieee80211_regdomain regdom_%s = {\n", country 47 printf "static const struct ieee80211_regdomain regdom_%s = {\n", country
48 printf "\t.alpha2 = \"%s\",\n", country 48 printf "\t.alpha2 = \"%s\",\n", country
49 if ($NF ~ /DFS-ETSI/)
50 printf "\t.dfs_region = NL80211_DFS_ETSI,\n"
51 else if ($NF ~ /DFS-FCC/)
52 printf "\t.dfs_region = NL80211_DFS_FCC,\n"
53 else if ($NF ~ /DFS-JP/)
54 printf "\t.dfs_region = NL80211_DFS_JP,\n"
49 printf "\t.reg_rules = {\n" 55 printf "\t.reg_rules = {\n"
50 active = 1 56 active = 1
51 regdb = regdb "\t&regdom_" country ",\n" 57 regdb = regdb "\t&regdom_" country ",\n"
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index af8d84a4a5b2..2838206ddad3 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5591,6 +5591,9 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
5591 if (err) 5591 if (err)
5592 return err; 5592 return err;
5593 5593
5594 if (netif_carrier_ok(dev))
5595 return -EBUSY;
5596
5594 if (wdev->cac_started) 5597 if (wdev->cac_started)
5595 return -EBUSY; 5598 return -EBUSY;
5596 5599
@@ -5634,15 +5637,26 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5634 static struct nlattr *csa_attrs[NL80211_ATTR_MAX+1]; 5637 static struct nlattr *csa_attrs[NL80211_ATTR_MAX+1];
5635 u8 radar_detect_width = 0; 5638 u8 radar_detect_width = 0;
5636 int err; 5639 int err;
5640 bool need_new_beacon = false;
5637 5641
5638 if (!rdev->ops->channel_switch || 5642 if (!rdev->ops->channel_switch ||
5639 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) 5643 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
5640 return -EOPNOTSUPP; 5644 return -EOPNOTSUPP;
5641 5645
5642 /* may add IBSS support later */ 5646 switch (dev->ieee80211_ptr->iftype) {
5643 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 5647 case NL80211_IFTYPE_AP:
5644 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 5648 case NL80211_IFTYPE_P2P_GO:
5649 need_new_beacon = true;
5650
5651 /* useless if AP is not running */
5652 if (!wdev->beacon_interval)
5653 return -EINVAL;
5654 break;
5655 case NL80211_IFTYPE_ADHOC:
5656 break;
5657 default:
5645 return -EOPNOTSUPP; 5658 return -EOPNOTSUPP;
5659 }
5646 5660
5647 memset(&params, 0, sizeof(params)); 5661 memset(&params, 0, sizeof(params));
5648 5662
@@ -5651,15 +5665,16 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5651 return -EINVAL; 5665 return -EINVAL;
5652 5666
5653 /* only important for AP, IBSS and mesh create IEs internally */ 5667 /* only important for AP, IBSS and mesh create IEs internally */
5654 if (!info->attrs[NL80211_ATTR_CSA_IES]) 5668 if (need_new_beacon &&
5655 return -EINVAL; 5669 (!info->attrs[NL80211_ATTR_CSA_IES] ||
5656 5670 !info->attrs[NL80211_ATTR_CSA_C_OFF_BEACON]))
5657 /* useless if AP is not running */
5658 if (!wdev->beacon_interval)
5659 return -EINVAL; 5671 return -EINVAL;
5660 5672
5661 params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]); 5673 params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
5662 5674
5675 if (!need_new_beacon)
5676 goto skip_beacons;
5677
5663 err = nl80211_parse_beacon(info->attrs, &params.beacon_after); 5678 err = nl80211_parse_beacon(info->attrs, &params.beacon_after);
5664 if (err) 5679 if (err)
5665 return err; 5680 return err;
@@ -5699,6 +5714,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5699 return -EINVAL; 5714 return -EINVAL;
5700 } 5715 }
5701 5716
5717skip_beacons:
5702 err = nl80211_parse_chandef(rdev, info, &params.chandef); 5718 err = nl80211_parse_chandef(rdev, info, &params.chandef);
5703 if (err) 5719 if (err)
5704 return err; 5720 return err;
@@ -5706,12 +5722,17 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5706 if (!cfg80211_reg_can_beacon(&rdev->wiphy, &params.chandef)) 5722 if (!cfg80211_reg_can_beacon(&rdev->wiphy, &params.chandef))
5707 return -EINVAL; 5723 return -EINVAL;
5708 5724
5709 err = cfg80211_chandef_dfs_required(wdev->wiphy, &params.chandef); 5725 /* DFS channels are only supported for AP/P2P GO ... for now. */
5710 if (err < 0) { 5726 if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP ||
5711 return err; 5727 dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO) {
5712 } else if (err) { 5728 err = cfg80211_chandef_dfs_required(wdev->wiphy,
5713 radar_detect_width = BIT(params.chandef.width); 5729 &params.chandef);
5714 params.radar_required = true; 5730 if (err < 0) {
5731 return err;
5732 } else if (err) {
5733 radar_detect_width = BIT(params.chandef.width);
5734 params.radar_required = true;
5735 }
5715 } 5736 }
5716 5737
5717 err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype, 5738 err = cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
@@ -10740,7 +10761,8 @@ void cfg80211_ch_switch_notify(struct net_device *dev,
10740 wdev_lock(wdev); 10761 wdev_lock(wdev);
10741 10762
10742 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 10763 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
10743 wdev->iftype != NL80211_IFTYPE_P2P_GO)) 10764 wdev->iftype != NL80211_IFTYPE_P2P_GO &&
10765 wdev->iftype != NL80211_IFTYPE_ADHOC))
10744 goto out; 10766 goto out;
10745 10767
10746 wdev->channel = chandef->chan; 10768 wdev->channel = chandef->chan;
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index de06d5d1287f..d62cb1e91475 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -172,11 +172,21 @@ static const struct ieee80211_regdomain world_regdom = {
172 NL80211_RRF_NO_IBSS | 172 NL80211_RRF_NO_IBSS |
173 NL80211_RRF_NO_OFDM), 173 NL80211_RRF_NO_OFDM),
174 /* IEEE 802.11a, channel 36..48 */ 174 /* IEEE 802.11a, channel 36..48 */
175 REG_RULE(5180-10, 5240+10, 80, 6, 20, 175 REG_RULE(5180-10, 5240+10, 160, 6, 20,
176 NL80211_RRF_PASSIVE_SCAN | 176 NL80211_RRF_PASSIVE_SCAN |
177 NL80211_RRF_NO_IBSS), 177 NL80211_RRF_NO_IBSS),
178 178
179 /* NB: 5260 MHz - 5700 MHz requires DFS */ 179 /* IEEE 802.11a, channel 52..64 - DFS required */
180 REG_RULE(5260-10, 5320+10, 160, 6, 20,
181 NL80211_RRF_PASSIVE_SCAN |
182 NL80211_RRF_NO_IBSS |
183 NL80211_RRF_DFS),
184
185 /* IEEE 802.11a, channel 100..144 - DFS required */
186 REG_RULE(5500-10, 5720+10, 160, 6, 20,
187 NL80211_RRF_PASSIVE_SCAN |
188 NL80211_RRF_NO_IBSS |
189 NL80211_RRF_DFS),
180 190
181 /* IEEE 802.11a, channel 149..165 */ 191 /* IEEE 802.11a, channel 149..165 */
182 REG_RULE(5745-10, 5825+10, 80, 6, 20, 192 REG_RULE(5745-10, 5825+10, 80, 6, 20,
diff --git a/net/wireless/util.c b/net/wireless/util.c
index ce090c1c5e4f..3c8be6104ba4 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -10,6 +10,7 @@
10#include <net/cfg80211.h> 10#include <net/cfg80211.h>
11#include <net/ip.h> 11#include <net/ip.h>
12#include <net/dsfield.h> 12#include <net/dsfield.h>
13#include <linux/if_vlan.h>
13#include "core.h" 14#include "core.h"
14#include "rdev-ops.h" 15#include "rdev-ops.h"
15 16
@@ -691,6 +692,7 @@ EXPORT_SYMBOL(ieee80211_amsdu_to_8023s);
691unsigned int cfg80211_classify8021d(struct sk_buff *skb) 692unsigned int cfg80211_classify8021d(struct sk_buff *skb)
692{ 693{
693 unsigned int dscp; 694 unsigned int dscp;
695 unsigned char vlan_priority;
694 696
695 /* skb->priority values from 256->263 are magic values to 697 /* skb->priority values from 256->263 are magic values to
696 * directly indicate a specific 802.1d priority. This is used 698 * directly indicate a specific 802.1d priority. This is used
@@ -700,6 +702,13 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb)
700 if (skb->priority >= 256 && skb->priority <= 263) 702 if (skb->priority >= 256 && skb->priority <= 263)
701 return skb->priority - 256; 703 return skb->priority - 256;
702 704
705 if (vlan_tx_tag_present(skb)) {
706 vlan_priority = (vlan_tx_tag_get(skb) & VLAN_PRIO_MASK)
707 >> VLAN_PRIO_SHIFT;
708 if (vlan_priority > 0)
709 return vlan_priority;
710 }
711
703 switch (skb->protocol) { 712 switch (skb->protocol) {
704 case htons(ETH_P_IP): 713 case htons(ETH_P_IP):
705 dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc; 714 dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index ea475cd03511..8a39dda7a325 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -101,8 +101,11 @@ void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu)
101 typeof(*work), queue); 101 typeof(*work), queue);
102 cancel_work_sync(&work->work); 102 cancel_work_sync(&work->work);
103 list_del(&work->queue); 103 list_del(&work->queue);
104 if (!work->done) /* work was canceled */ 104 if (!work->done) { /* work was canceled */
105 mmdrop(work->mm);
106 kvm_put_kvm(vcpu->kvm); /* == work->vcpu->kvm */
105 kmem_cache_free(async_pf_cache, work); 107 kmem_cache_free(async_pf_cache, work);
108 }
106 } 109 }
107 110
108 spin_lock(&vcpu->async_pf.lock); 111 spin_lock(&vcpu->async_pf.lock);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index bf040c4e02b3..979bff485fb0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1058,11 +1058,15 @@ unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn)
1058EXPORT_SYMBOL_GPL(gfn_to_hva); 1058EXPORT_SYMBOL_GPL(gfn_to_hva);
1059 1059
1060/* 1060/*
1061 * The hva returned by this function is only allowed to be read. 1061 * If writable is set to false, the hva returned by this function is only
1062 * It should pair with kvm_read_hva() or kvm_read_hva_atomic(). 1062 * allowed to be read.
1063 */ 1063 */
1064static unsigned long gfn_to_hva_read(struct kvm *kvm, gfn_t gfn) 1064unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable)
1065{ 1065{
1066 struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn);
1067 if (writable)
1068 *writable = !memslot_is_readonly(slot);
1069
1066 return __gfn_to_hva_many(gfn_to_memslot(kvm, gfn), gfn, NULL, false); 1070 return __gfn_to_hva_many(gfn_to_memslot(kvm, gfn), gfn, NULL, false);
1067} 1071}
1068 1072
@@ -1430,7 +1434,7 @@ int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
1430 int r; 1434 int r;
1431 unsigned long addr; 1435 unsigned long addr;
1432 1436
1433 addr = gfn_to_hva_read(kvm, gfn); 1437 addr = gfn_to_hva_prot(kvm, gfn, NULL);
1434 if (kvm_is_error_hva(addr)) 1438 if (kvm_is_error_hva(addr))
1435 return -EFAULT; 1439 return -EFAULT;
1436 r = kvm_read_hva(data, (void __user *)addr + offset, len); 1440 r = kvm_read_hva(data, (void __user *)addr + offset, len);
@@ -1468,7 +1472,7 @@ int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data,
1468 gfn_t gfn = gpa >> PAGE_SHIFT; 1472 gfn_t gfn = gpa >> PAGE_SHIFT;
1469 int offset = offset_in_page(gpa); 1473 int offset = offset_in_page(gpa);
1470 1474
1471 addr = gfn_to_hva_read(kvm, gfn); 1475 addr = gfn_to_hva_prot(kvm, gfn, NULL);
1472 if (kvm_is_error_hva(addr)) 1476 if (kvm_is_error_hva(addr))
1473 return -EFAULT; 1477 return -EFAULT;
1474 pagefault_disable(); 1478 pagefault_disable();