aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/block/queue-sysfs.txt10
-rw-r--r--MAINTAINERS10
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/mach-exynos4/Makefile1
-rw-r--r--arch/arm/mach-s3c64xx/Makefile4
-rw-r--r--arch/arm/mach-s5pv210/Makefile1
-rw-r--r--block/blk-core.c11
-rw-r--r--block/blk-ioc.c40
-rw-r--r--block/blk-lib.c5
-rw-r--r--block/blk-softirq.c11
-rw-r--r--block/blk-sysfs.c13
-rw-r--r--block/blk-throttle.c8
-rw-r--r--block/bsg.c18
-rw-r--r--block/cfq-iosched.c152
-rw-r--r--block/compat_ioctl.c14
-rw-r--r--block/deadline-iosched.c4
-rw-r--r--block/elevator.c7
-rw-r--r--block/genhd.c28
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/acard-ahci.c27
-rw-r--r--drivers/ata/ahci.c122
-rw-r--r--drivers/ata/ahci.h1
-rw-r--r--drivers/ata/ata_generic.c5
-rw-r--r--drivers/ata/ata_piix.c44
-rw-r--r--drivers/ata/libahci.c152
-rw-r--r--drivers/ata/libata-acpi.c66
-rw-r--r--drivers/ata/libata-core.c400
-rw-r--r--drivers/ata/libata-eh.c154
-rw-r--r--drivers/ata/libata-pmp.c123
-rw-r--r--drivers/ata/libata-scsi.c22
-rw-r--r--drivers/ata/libata-sff.c53
-rw-r--r--drivers/ata/pata_acpi.c8
-rw-r--r--drivers/ata/pata_ali.c8
-rw-r--r--drivers/ata/pata_amd.c8
-rw-r--r--drivers/ata/pata_artop.c5
-rw-r--r--drivers/ata/pata_atp867x.c13
-rw-r--r--drivers/ata/pata_bf54x.c4
-rw-r--r--drivers/ata/pata_cs5520.c3
-rw-r--r--drivers/ata/pata_efar.c5
-rw-r--r--drivers/ata/pata_hpt3x3.c4
-rw-r--r--drivers/ata/pata_icside.c4
-rw-r--r--drivers/ata/pata_it8213.c5
-rw-r--r--drivers/ata/pata_it821x.c16
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c4
-rw-r--r--drivers/ata/pata_legacy.c2
-rw-r--r--drivers/ata/pata_macio.c10
-rw-r--r--drivers/ata/pata_mpiix.c4
-rw-r--r--drivers/ata/pata_netcell.c5
-rw-r--r--drivers/ata/pata_ns87410.c2
-rw-r--r--drivers/ata/pata_ns87415.c5
-rw-r--r--drivers/ata/pata_octeon_cf.c8
-rw-r--r--drivers/ata/pata_oldpiix.c5
-rw-r--r--drivers/ata/pata_opti.c4
-rw-r--r--drivers/ata/pata_optidma.c4
-rw-r--r--drivers/ata/pata_pcmcia.c5
-rw-r--r--drivers/ata/pata_pdc2027x.c6
-rw-r--r--drivers/ata/pata_platform.c2
-rw-r--r--drivers/ata/pata_radisys.c5
-rw-r--r--drivers/ata/pata_rdc.c5
-rw-r--r--drivers/ata/pata_rz1000.c4
-rw-r--r--drivers/ata/pata_samsung_cf.c2
-rw-r--r--drivers/ata/pata_scc.c8
-rw-r--r--drivers/ata/pata_sch.c5
-rw-r--r--drivers/ata/pata_sil680.c4
-rw-r--r--drivers/ata/pata_sis.c5
-rw-r--r--drivers/ata/pata_sl82c105.c6
-rw-r--r--drivers/ata/pata_triflex.c4
-rw-r--r--drivers/ata/pata_via.c8
-rw-r--r--drivers/ata/pdc_adma.c10
-rw-r--r--drivers/ata/sata_dwc_460ex.c21
-rw-r--r--drivers/ata/sata_fsl.c43
-rw-r--r--drivers/ata/sata_inic162x.c31
-rw-r--r--drivers/ata/sata_mv.c94
-rw-r--r--drivers/ata/sata_nv.c79
-rw-r--r--drivers/ata/sata_promise.c6
-rw-r--r--drivers/ata/sata_qstor.c13
-rw-r--r--drivers/ata/sata_sil.c21
-rw-r--r--drivers/ata/sata_sil24.c43
-rw-r--r--drivers/ata/sata_sis.c26
-rw-r--r--drivers/ata/sata_svw.c4
-rw-r--r--drivers/ata/sata_sx4.c4
-rw-r--r--drivers/ata/sata_uli.c4
-rw-r--r--drivers/ata/sata_via.c42
-rw-r--r--drivers/ata/sata_vsc.c9
-rw-r--r--drivers/bcma/core.c72
-rw-r--r--drivers/bcma/driver_chipcommon.c14
-rw-r--r--drivers/bcma/driver_pci.c2
-rw-r--r--drivers/bcma/sprom.c14
-rw-r--r--drivers/block/cciss.h2
-rw-r--r--drivers/block/xen-blkback/blkback.c37
-rw-r--r--drivers/cpufreq/Kconfig5
-rw-r--r--drivers/cpufreq/Kconfig.arm32
-rw-r--r--drivers/cpufreq/Makefile8
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c2
-rw-r--r--drivers/cpufreq/exynos4210-cpufreq.c (renamed from arch/arm/mach-exynos4/cpufreq.c)9
-rw-r--r--drivers/cpufreq/s3c64xx-cpufreq.c (renamed from arch/arm/mach-s3c64xx/cpufreq.c)11
-rw-r--r--drivers/cpufreq/s5pv210-cpufreq.c (renamed from arch/arm/mach-s5pv210/cpufreq.c)210
-rw-r--r--drivers/net/bna/bfa_cee.c65
-rw-r--r--drivers/net/bna/bfa_cee.h3
-rw-r--r--drivers/net/bna/bfa_cs.h (renamed from drivers/net/bna/bfa_sm.h)78
-rw-r--r--drivers/net/bna/bfa_defs.h5
-rw-r--r--drivers/net/bna/bfa_defs_mfg_comm.h20
-rw-r--r--drivers/net/bna/bfa_defs_status.h134
-rw-r--r--drivers/net/bna/bfa_ioc.c157
-rw-r--r--drivers/net/bna/bfa_ioc.h51
-rw-r--r--drivers/net/bna/bfa_wc.h69
-rw-r--r--drivers/net/bna/bfi.h20
-rw-r--r--drivers/net/bna/bna.h18
-rw-r--r--drivers/net/bna/bna_ctrl.c45
-rw-r--r--drivers/net/bna/bna_hw.h92
-rw-r--r--drivers/net/bna/bna_txrx.c44
-rw-r--r--drivers/net/bna/bna_types.h58
-rw-r--r--drivers/net/bna/bnad.c65
-rw-r--r--drivers/net/bna/bnad.h27
-rw-r--r--drivers/net/bna/bnad_ethtool.c2
-rw-r--r--drivers/net/bna/cna.h2
-rw-r--r--drivers/net/bnx2x/bnx2x_dcb.c39
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c134
-rw-r--r--drivers/net/can/c_can/c_can.c1
-rw-r--r--drivers/net/can/c_can/c_can_platform.c1
-rw-r--r--drivers/net/igb/igb_main.c1
-rw-r--r--drivers/net/qlge/qlge_main.c1
-rw-r--r--drivers/net/r8169.c7
-rw-r--r--drivers/net/via-velocity.c1
-rw-r--r--drivers/net/wan/sbni.c5
-rw-r--r--drivers/net/wireless/ath/ath5k/ahb.c44
-rw-r--r--drivers/net/wireless/ath/ath5k/ani.c84
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h272
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c31
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c1138
-rw-r--r--drivers/net/wireless/ath/ath5k/base.h205
-rw-r--r--drivers/net/wireless/ath/ath5k/caps.c45
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c218
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.h21
-rw-r--r--drivers/net/wireless/ath/ath5k/desc.c10
-rw-r--r--drivers/net/wireless/ath/ath5k/dma.c12
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/initvals.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c68
-rw-r--r--drivers/net/wireless/ath/ath5k/mac80211-ops.c257
-rw-r--r--drivers/net/wireless/ath/ath5k/pci.c38
-rw-r--r--drivers/net/wireless/ath/ath5k/pcu.c24
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c41
-rw-r--r--drivers/net/wireless/ath/ath5k/qcu.c9
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c44
-rw-r--r--drivers/net/wireless/ath/ath5k/rfkill.c65
-rw-r--r--drivers/net/wireless/ath/ath5k/sysfs.c32
-rw-r--r--drivers/net/wireless/ath/ath5k/trace.h12
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/btcoex.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_4k.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_9287.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_def.c12
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_debug.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c53
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h23
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c4
-rw-r--r--drivers/net/wireless/ath/carl9170/carl9170.h10
-rw-r--r--drivers/net/wireless/ath/carl9170/cmd.h4
-rw-r--r--drivers/net/wireless/ath/carl9170/debug.c2
-rw-r--r--drivers/net/wireless/ath/carl9170/fwdesc.h3
-rw-r--r--drivers/net/wireless/ath/carl9170/hw.h41
-rw-r--r--drivers/net/wireless/ath/carl9170/led.c2
-rw-r--r--drivers/net/wireless/ath/carl9170/mac.c129
-rw-r--r--drivers/net/wireless/ath/carl9170/main.c2
-rw-r--r--drivers/net/wireless/ath/carl9170/phy.c6
-rw-r--r--drivers/net/wireless/ath/carl9170/tx.c290
-rw-r--r--drivers/net/wireless/ath/key.c7
-rw-r--r--drivers/net/wireless/b43/b43.h7
-rw-r--r--drivers/net/wireless/b43/bus.c27
-rw-r--r--drivers/net/wireless/b43/dma.c27
-rw-r--r--drivers/net/wireless/b43/dma.h4
-rw-r--r--drivers/net/wireless/b43/main.c106
-rw-r--r--drivers/net/wireless/b43/phy_ht.c21
-rw-r--r--drivers/net/wireless/b43/phy_n.c4
-rw-r--r--drivers/net/wireless/b43/radio_2059.c9
-rw-r--r--drivers/net/wireless/b43legacy/b43legacy.h2
-rw-r--r--drivers/net/wireless/b43legacy/dma.c7
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-2000.c46
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c58
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c65
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c210
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ict.c306
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c504
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c115
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-sta.c376
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c411
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c179
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c1240
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h65
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-bus.h (renamed from drivers/net/wireless/iwlwifi/iwl-pci.h)70
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h180
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c87
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h197
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c271
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-pci.c101
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h82
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c212
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sv-open.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-int-pcie.h82
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c979
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c (renamed from drivers/net/wireless/iwlwifi/iwl-tx.c)484
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.c643
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h154
-rw-r--r--drivers/net/wireless/libertas/dev.h2
-rw-r--r--drivers/net/wireless/libertas/main.c2
-rw-r--r--drivers/net/wireless/libertas/mesh.c972
-rw-r--r--drivers/net/wireless/libertas/mesh.h31
-rw-r--r--drivers/net/wireless/libertas/tx.c2
-rw-r--r--drivers/net/wireless/mwifiex/debugfs.c33
-rw-r--r--drivers/net/wireless/mwifiex/ioctl.h1
-rw-r--r--drivers/net/wireless/mwifiex/main.h1
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c5
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c14
-rw-r--r--drivers/net/wireless/mwifiex/wmm.c2
-rw-r--r--drivers/net/wireless/mwl8k.c6
-rw-r--r--drivers/net/wireless/orinoco/airport.c9
-rw-r--r--drivers/net/wireless/orinoco/cfg.c6
-rw-r--r--drivers/net/wireless/orinoco/fw.c7
-rw-r--r--drivers/net/wireless/orinoco/fw.h2
-rw-r--r--drivers/net/wireless/orinoco/hermes.c40
-rw-r--r--drivers/net/wireless/orinoco/hermes.h37
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.c8
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.h12
-rw-r--r--drivers/net/wireless/orinoco/hw.c48
-rw-r--r--drivers/net/wireless/orinoco/hw.h2
-rw-r--r--drivers/net/wireless/orinoco/main.c46
-rw-r--r--drivers/net/wireless/orinoco/mic.c8
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h16
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c6
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c3
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c4
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c6
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_usb.c23
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c10
-rw-r--r--drivers/net/wireless/orinoco/wext.c14
-rw-r--r--drivers/net/wireless/rtlwifi/base.c20
-rw-r--r--drivers/net/wireless/rtlwifi/cam.c8
-rw-r--r--drivers/net/wireless/rtlwifi/core.c6
-rw-r--r--drivers/net/wireless/rtlwifi/debug.h5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.c69
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/mac.c11
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/hw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c8
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.c12
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.c5
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/rf.c4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c6
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c12
-rw-r--r--drivers/ssb/main.c5
-rw-r--r--drivers/staging/gma500/psb_intel_display.c2
-rw-r--r--fs/block_dev.c23
-rw-r--r--fs/compat_ioctl.c5
-rw-r--r--fs/partitions/check.c12
-rw-r--r--fs/reiserfs/journal.c13
-rw-r--r--fs/super.c4
-rw-r--r--include/asm-generic/iomap.h8
-rw-r--r--include/linux/bcma/bcma.h21
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h13
-rw-r--r--include/linux/bcma/bcma_regs.h27
-rw-r--r--include/linux/blkdev.h27
-rw-r--r--include/linux/elevator.h2
-rw-r--r--include/linux/fd.h22
-rw-r--r--include/linux/fs.h4
-rw-r--r--include/linux/genhd.h2
-rw-r--r--include/linux/ieee80211.h37
-rw-r--r--include/linux/init_task.h1
-rw-r--r--include/linux/iocontext.h14
-rw-r--r--include/linux/libata.h68
-rw-r--r--include/linux/nl80211.h33
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/ssb/ssb.h2
-rw-r--r--include/net/cfg80211.h33
-rw-r--r--include/net/mac80211.h60
-rw-r--r--kernel/exit.c1
-rw-r--r--kernel/fork.c1
-rw-r--r--mm/backing-dev.c2
-rw-r--r--net/bridge/br_if.c2
-rw-r--r--net/bridge/br_netlink.c2
-rw-r--r--net/bridge/br_private.h1
-rw-r--r--net/bridge/br_private_stp.h3
-rw-r--r--net/bridge/br_stp.c31
-rw-r--r--net/bridge/br_stp_bpdu.c15
-rw-r--r--net/bridge/br_stp_if.c3
-rw-r--r--net/bridge/br_stp_timer.c1
-rw-r--r--net/core/link_watch.c2
-rw-r--r--net/ipv4/gre.c21
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/route.c2
-rw-r--r--net/mac80211/agg-rx.c10
-rw-r--r--net/mac80211/cfg.c4
-rw-r--r--net/mac80211/driver-ops.h31
-rw-r--r--net/mac80211/driver-trace.h43
-rw-r--r--net/mac80211/ieee80211_i.h7
-rw-r--r--net/mac80211/key.c2
-rw-r--r--net/mac80211/mlme.c30
-rw-r--r--net/mac80211/pm.c3
-rw-r--r--net/mac80211/scan.c6
-rw-r--r--net/mac80211/tkip.c11
-rw-r--r--net/mac80211/util.c71
-rw-r--r--net/mac80211/work.c28
-rw-r--r--net/wireless/core.c7
-rw-r--r--net/wireless/core.h4
-rw-r--r--net/wireless/nl80211.c109
-rw-r--r--net/wireless/scan.c4
-rw-r--r--net/wireless/util.c38
328 files changed, 9263 insertions, 7893 deletions
diff --git a/Documentation/block/queue-sysfs.txt b/Documentation/block/queue-sysfs.txt
index f65274081c8d..d8147b336c35 100644
--- a/Documentation/block/queue-sysfs.txt
+++ b/Documentation/block/queue-sysfs.txt
@@ -45,9 +45,13 @@ device.
45 45
46rq_affinity (RW) 46rq_affinity (RW)
47---------------- 47----------------
48If this option is enabled, the block layer will migrate request completions 48If this option is '1', the block layer will migrate request completions to the
49to the CPU that originally submitted the request. For some workloads 49cpu "group" that originally submitted the request. For some workloads this
50this provides a significant reduction in CPU cycles due to caching effects. 50provides a significant reduction in CPU cycles due to caching effects.
51
52For storage configurations that need to maximize distribution of completion
53processing setting this option to '2' forces the completion to run on the
54requesting cpu (bypassing the "group" aggregation logic).
51 55
52scheduler (RW) 56scheduler (RW)
53-------------- 57--------------
diff --git a/MAINTAINERS b/MAINTAINERS
index 43392c9ef4c3..39d8822c3dae 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4106,6 +4106,12 @@ S: Maintained
4106F: drivers/net/mv643xx_eth.* 4106F: drivers/net/mv643xx_eth.*
4107F: include/linux/mv643xx.h 4107F: include/linux/mv643xx.h
4108 4108
4109MARVELL MWIFIEX WIRELESS DRIVER
4110M: Bing Zhao <bzhao@marvell.com>
4111L: linux-wireless@vger.kernel.org
4112S: Maintained
4113F: drivers/net/wireless/mwifiex/
4114
4109MARVELL MWL8K WIRELESS DRIVER 4115MARVELL MWL8K WIRELESS DRIVER
4110M: Lennert Buytenhek <buytenh@wantstofly.org> 4116M: Lennert Buytenhek <buytenh@wantstofly.org>
4111L: linux-wireless@vger.kernel.org 4117L: linux-wireless@vger.kernel.org
@@ -6972,9 +6978,9 @@ S: Maintained
6972F: drivers/input/misc/wistron_btns.c 6978F: drivers/input/misc/wistron_btns.c
6973 6979
6974WL1251 WIRELESS DRIVER 6980WL1251 WIRELESS DRIVER
6975M: Kalle Valo <kvalo@adurom.com> 6981M: Luciano Coelho <coelho@ti.com>
6976L: linux-wireless@vger.kernel.org 6982L: linux-wireless@vger.kernel.org
6977W: http://wireless.kernel.org 6983W: http://wireless.kernel.org/en/users/Drivers/wl1251
6978T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-testing.git 6984T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-testing.git
6979S: Maintained 6985S: Maintained
6980F: drivers/net/wireless/wl1251/* 6986F: drivers/net/wireless/wl1251/*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1478c6171b00..83a7aa2ca57a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1895,10 +1895,6 @@ config CPU_FREQ_PXA
1895 default y 1895 default y
1896 select CPU_FREQ_DEFAULT_GOV_USERSPACE 1896 select CPU_FREQ_DEFAULT_GOV_USERSPACE
1897 1897
1898config CPU_FREQ_S3C64XX
1899 bool "CPUfreq support for Samsung S3C64XX CPUs"
1900 depends on CPU_FREQ && CPU_S3C6410
1901
1902config CPU_FREQ_S3C 1898config CPU_FREQ_S3C
1903 bool 1899 bool
1904 help 1900 help
diff --git a/arch/arm/mach-exynos4/Makefile b/arch/arm/mach-exynos4/Makefile
index 60fe5ecf3599..1366995d8c2c 100644
--- a/arch/arm/mach-exynos4/Makefile
+++ b/arch/arm/mach-exynos4/Makefile
@@ -15,7 +15,6 @@ obj- :=
15obj-$(CONFIG_CPU_EXYNOS4210) += cpu.o init.o clock.o irq-combiner.o 15obj-$(CONFIG_CPU_EXYNOS4210) += cpu.o init.o clock.o irq-combiner.o
16obj-$(CONFIG_CPU_EXYNOS4210) += setup-i2c0.o irq-eint.o dma.o 16obj-$(CONFIG_CPU_EXYNOS4210) += setup-i2c0.o irq-eint.o dma.o
17obj-$(CONFIG_PM) += pm.o sleep.o 17obj-$(CONFIG_PM) += pm.o sleep.o
18obj-$(CONFIG_CPU_FREQ) += cpufreq.o
19obj-$(CONFIG_CPU_IDLE) += cpuidle.o 18obj-$(CONFIG_CPU_IDLE) += cpuidle.o
20 19
21obj-$(CONFIG_SMP) += platsmp.o headsmp.o 20obj-$(CONFIG_SMP) += platsmp.o headsmp.o
diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile
index 4657363f0674..f5a7144a052f 100644
--- a/arch/arm/mach-s3c64xx/Makefile
+++ b/arch/arm/mach-s3c64xx/Makefile
@@ -23,10 +23,6 @@ obj-$(CONFIG_CPU_S3C6410) += s3c6410.o
23obj-y += irq.o 23obj-y += irq.o
24obj-y += irq-eint.o 24obj-y += irq-eint.o
25 25
26# CPU frequency scaling
27
28obj-$(CONFIG_CPU_FREQ_S3C64XX) += cpufreq.o
29
30# DMA support 26# DMA support
31 27
32obj-$(CONFIG_S3C64XX_DMA) += dma.o 28obj-$(CONFIG_S3C64XX_DMA) += dma.o
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile
index 50907aca006c..599a3c0e8f6c 100644
--- a/arch/arm/mach-s5pv210/Makefile
+++ b/arch/arm/mach-s5pv210/Makefile
@@ -15,7 +15,6 @@ obj- :=
15obj-$(CONFIG_CPU_S5PV210) += cpu.o init.o clock.o dma.o 15obj-$(CONFIG_CPU_S5PV210) += cpu.o init.o clock.o dma.o
16obj-$(CONFIG_CPU_S5PV210) += setup-i2c0.o 16obj-$(CONFIG_CPU_S5PV210) += setup-i2c0.o
17obj-$(CONFIG_S5PV210_PM) += pm.o sleep.o 17obj-$(CONFIG_S5PV210_PM) += pm.o sleep.o
18obj-$(CONFIG_CPU_FREQ) += cpufreq.o
19 18
20# machine support 19# machine support
21 20
diff --git a/block/blk-core.c b/block/blk-core.c
index 1d49e1c7c905..f8cb09951830 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1282,10 +1282,8 @@ get_rq:
1282 init_request_from_bio(req, bio); 1282 init_request_from_bio(req, bio);
1283 1283
1284 if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) || 1284 if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) ||
1285 bio_flagged(bio, BIO_CPU_AFFINE)) { 1285 bio_flagged(bio, BIO_CPU_AFFINE))
1286 req->cpu = blk_cpu_to_group(get_cpu()); 1286 req->cpu = smp_processor_id();
1287 put_cpu();
1288 }
1289 1287
1290 plug = current->plug; 1288 plug = current->plug;
1291 if (plug) { 1289 if (plug) {
@@ -1305,7 +1303,10 @@ get_rq:
1305 plug->should_sort = 1; 1303 plug->should_sort = 1;
1306 } 1304 }
1307 list_add_tail(&req->queuelist, &plug->list); 1305 list_add_tail(&req->queuelist, &plug->list);
1306 plug->count++;
1308 drive_stat_acct(req, 1); 1307 drive_stat_acct(req, 1);
1308 if (plug->count >= BLK_MAX_REQUEST_COUNT)
1309 blk_flush_plug_list(plug, false);
1309 } else { 1310 } else {
1310 spin_lock_irq(q->queue_lock); 1311 spin_lock_irq(q->queue_lock);
1311 add_acct_request(q, req, where); 1312 add_acct_request(q, req, where);
@@ -2629,6 +2630,7 @@ void blk_start_plug(struct blk_plug *plug)
2629 INIT_LIST_HEAD(&plug->list); 2630 INIT_LIST_HEAD(&plug->list);
2630 INIT_LIST_HEAD(&plug->cb_list); 2631 INIT_LIST_HEAD(&plug->cb_list);
2631 plug->should_sort = 0; 2632 plug->should_sort = 0;
2633 plug->count = 0;
2632 2634
2633 /* 2635 /*
2634 * If this is a nested plug, don't actually assign it. It will be 2636 * If this is a nested plug, don't actually assign it. It will be
@@ -2712,6 +2714,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
2712 return; 2714 return;
2713 2715
2714 list_splice_init(&plug->list, &list); 2716 list_splice_init(&plug->list, &list);
2717 plug->count = 0;
2715 2718
2716 if (plug->should_sort) { 2719 if (plug->should_sort) {
2717 list_sort(NULL, &list, plug_rq_cmp); 2720 list_sort(NULL, &list, plug_rq_cmp);
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 342eae9b0d3c..6f9bbd978653 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -82,26 +82,26 @@ void exit_io_context(struct task_struct *task)
82 82
83struct io_context *alloc_io_context(gfp_t gfp_flags, int node) 83struct io_context *alloc_io_context(gfp_t gfp_flags, int node)
84{ 84{
85 struct io_context *ret; 85 struct io_context *ioc;
86 86
87 ret = kmem_cache_alloc_node(iocontext_cachep, gfp_flags, node); 87 ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags, node);
88 if (ret) { 88 if (ioc) {
89 atomic_long_set(&ret->refcount, 1); 89 atomic_long_set(&ioc->refcount, 1);
90 atomic_set(&ret->nr_tasks, 1); 90 atomic_set(&ioc->nr_tasks, 1);
91 spin_lock_init(&ret->lock); 91 spin_lock_init(&ioc->lock);
92 ret->ioprio_changed = 0; 92 ioc->ioprio_changed = 0;
93 ret->ioprio = 0; 93 ioc->ioprio = 0;
94 ret->last_waited = 0; /* doesn't matter... */ 94 ioc->last_waited = 0; /* doesn't matter... */
95 ret->nr_batch_requests = 0; /* because this is 0 */ 95 ioc->nr_batch_requests = 0; /* because this is 0 */
96 INIT_RADIX_TREE(&ret->radix_root, GFP_ATOMIC | __GFP_HIGH); 96 INIT_RADIX_TREE(&ioc->radix_root, GFP_ATOMIC | __GFP_HIGH);
97 INIT_HLIST_HEAD(&ret->cic_list); 97 INIT_HLIST_HEAD(&ioc->cic_list);
98 ret->ioc_data = NULL; 98 ioc->ioc_data = NULL;
99#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) 99#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
100 ret->cgroup_changed = 0; 100 ioc->cgroup_changed = 0;
101#endif 101#endif
102 } 102 }
103 103
104 return ret; 104 return ioc;
105} 105}
106 106
107/* 107/*
@@ -139,19 +139,19 @@ struct io_context *current_io_context(gfp_t gfp_flags, int node)
139 */ 139 */
140struct io_context *get_io_context(gfp_t gfp_flags, int node) 140struct io_context *get_io_context(gfp_t gfp_flags, int node)
141{ 141{
142 struct io_context *ret = NULL; 142 struct io_context *ioc = NULL;
143 143
144 /* 144 /*
145 * Check for unlikely race with exiting task. ioc ref count is 145 * Check for unlikely race with exiting task. ioc ref count is
146 * zero when ioc is being detached. 146 * zero when ioc is being detached.
147 */ 147 */
148 do { 148 do {
149 ret = current_io_context(gfp_flags, node); 149 ioc = current_io_context(gfp_flags, node);
150 if (unlikely(!ret)) 150 if (unlikely(!ioc))
151 break; 151 break;
152 } while (!atomic_long_inc_not_zero(&ret->refcount)); 152 } while (!atomic_long_inc_not_zero(&ioc->refcount));
153 153
154 return ret; 154 return ioc;
155} 155}
156EXPORT_SYMBOL(get_io_context); 156EXPORT_SYMBOL(get_io_context);
157 157
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 78e627e2581d..2b461b496a78 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -59,7 +59,10 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
59 * granularity 59 * granularity
60 */ 60 */
61 max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9); 61 max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9);
62 if (q->limits.discard_granularity) { 62 if (unlikely(!max_discard_sectors)) {
63 /* Avoid infinite loop below. Being cautious never hurts. */
64 return -EOPNOTSUPP;
65 } else if (q->limits.discard_granularity) {
63 unsigned int disc_sects = q->limits.discard_granularity >> 9; 66 unsigned int disc_sects = q->limits.discard_granularity >> 9;
64 67
65 max_discard_sectors &= ~(disc_sects - 1); 68 max_discard_sectors &= ~(disc_sects - 1);
diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index ee9c21602228..475fab809a80 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -103,22 +103,25 @@ static struct notifier_block __cpuinitdata blk_cpu_notifier = {
103 103
104void __blk_complete_request(struct request *req) 104void __blk_complete_request(struct request *req)
105{ 105{
106 int ccpu, cpu, group_cpu = NR_CPUS;
106 struct request_queue *q = req->q; 107 struct request_queue *q = req->q;
107 unsigned long flags; 108 unsigned long flags;
108 int ccpu, cpu, group_cpu;
109 109
110 BUG_ON(!q->softirq_done_fn); 110 BUG_ON(!q->softirq_done_fn);
111 111
112 local_irq_save(flags); 112 local_irq_save(flags);
113 cpu = smp_processor_id(); 113 cpu = smp_processor_id();
114 group_cpu = blk_cpu_to_group(cpu);
115 114
116 /* 115 /*
117 * Select completion CPU 116 * Select completion CPU
118 */ 117 */
119 if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) && req->cpu != -1) 118 if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) && req->cpu != -1) {
120 ccpu = req->cpu; 119 ccpu = req->cpu;
121 else 120 if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags)) {
121 ccpu = blk_cpu_to_group(ccpu);
122 group_cpu = blk_cpu_to_group(cpu);
123 }
124 } else
122 ccpu = cpu; 125 ccpu = cpu;
123 126
124 if (ccpu == cpu || ccpu == group_cpu) { 127 if (ccpu == cpu || ccpu == group_cpu) {
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index d935bd859c87..0ee17b5e7fb6 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -244,8 +244,9 @@ static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
244static ssize_t queue_rq_affinity_show(struct request_queue *q, char *page) 244static ssize_t queue_rq_affinity_show(struct request_queue *q, char *page)
245{ 245{
246 bool set = test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags); 246 bool set = test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags);
247 bool force = test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags);
247 248
248 return queue_var_show(set, page); 249 return queue_var_show(set << force, page);
249} 250}
250 251
251static ssize_t 252static ssize_t
@@ -257,10 +258,14 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
257 258
258 ret = queue_var_store(&val, page, count); 259 ret = queue_var_store(&val, page, count);
259 spin_lock_irq(q->queue_lock); 260 spin_lock_irq(q->queue_lock);
260 if (val) 261 if (val) {
261 queue_flag_set(QUEUE_FLAG_SAME_COMP, q); 262 queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
262 else 263 if (val == 2)
263 queue_flag_clear(QUEUE_FLAG_SAME_COMP, q); 264 queue_flag_set(QUEUE_FLAG_SAME_FORCE, q);
265 } else {
266 queue_flag_clear(QUEUE_FLAG_SAME_COMP, q);
267 queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
268 }
264 spin_unlock_irq(q->queue_lock); 269 spin_unlock_irq(q->queue_lock);
265#endif 270#endif
266 return ret; 271 return ret;
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 3689f833afdc..f6a794120505 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -142,9 +142,9 @@ static inline struct throtl_grp *tg_of_blkg(struct blkio_group *blkg)
142 return NULL; 142 return NULL;
143} 143}
144 144
145static inline int total_nr_queued(struct throtl_data *td) 145static inline unsigned int total_nr_queued(struct throtl_data *td)
146{ 146{
147 return (td->nr_queued[0] + td->nr_queued[1]); 147 return td->nr_queued[0] + td->nr_queued[1];
148} 148}
149 149
150static inline struct throtl_grp *throtl_ref_get_tg(struct throtl_grp *tg) 150static inline struct throtl_grp *throtl_ref_get_tg(struct throtl_grp *tg)
@@ -927,7 +927,7 @@ static int throtl_dispatch(struct request_queue *q)
927 927
928 bio_list_init(&bio_list_on_stack); 928 bio_list_init(&bio_list_on_stack);
929 929
930 throtl_log(td, "dispatch nr_queued=%d read=%u write=%u", 930 throtl_log(td, "dispatch nr_queued=%u read=%u write=%u",
931 total_nr_queued(td), td->nr_queued[READ], 931 total_nr_queued(td), td->nr_queued[READ],
932 td->nr_queued[WRITE]); 932 td->nr_queued[WRITE]);
933 933
@@ -970,7 +970,7 @@ throtl_schedule_delayed_work(struct throtl_data *td, unsigned long delay)
970 struct delayed_work *dwork = &td->throtl_work; 970 struct delayed_work *dwork = &td->throtl_work;
971 971
972 /* schedule work if limits changed even if no bio is queued */ 972 /* schedule work if limits changed even if no bio is queued */
973 if (total_nr_queued(td) > 0 || td->limits_changed) { 973 if (total_nr_queued(td) || td->limits_changed) {
974 /* 974 /*
975 * We might have a work scheduled to be executed in future. 975 * We might have a work scheduled to be executed in future.
976 * Cancel that and schedule a new one. 976 * Cancel that and schedule a new one.
diff --git a/block/bsg.c b/block/bsg.c
index 0c8b64a16484..702f1316bb8f 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -182,7 +182,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
182 return -ENOMEM; 182 return -ENOMEM;
183 } 183 }
184 184
185 if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request, 185 if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
186 hdr->request_len)) 186 hdr->request_len))
187 return -EFAULT; 187 return -EFAULT;
188 188
@@ -249,7 +249,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
249 struct request *rq, *next_rq = NULL; 249 struct request *rq, *next_rq = NULL;
250 int ret, rw; 250 int ret, rw;
251 unsigned int dxfer_len; 251 unsigned int dxfer_len;
252 void *dxferp = NULL; 252 void __user *dxferp = NULL;
253 struct bsg_class_device *bcd = &q->bsg_dev; 253 struct bsg_class_device *bcd = &q->bsg_dev;
254 254
255 /* if the LLD has been removed then the bsg_unregister_queue will 255 /* if the LLD has been removed then the bsg_unregister_queue will
@@ -291,7 +291,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
291 rq->next_rq = next_rq; 291 rq->next_rq = next_rq;
292 next_rq->cmd_type = rq->cmd_type; 292 next_rq->cmd_type = rq->cmd_type;
293 293
294 dxferp = (void*)(unsigned long)hdr->din_xferp; 294 dxferp = (void __user *)(unsigned long)hdr->din_xferp;
295 ret = blk_rq_map_user(q, next_rq, NULL, dxferp, 295 ret = blk_rq_map_user(q, next_rq, NULL, dxferp,
296 hdr->din_xfer_len, GFP_KERNEL); 296 hdr->din_xfer_len, GFP_KERNEL);
297 if (ret) 297 if (ret)
@@ -300,10 +300,10 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
300 300
301 if (hdr->dout_xfer_len) { 301 if (hdr->dout_xfer_len) {
302 dxfer_len = hdr->dout_xfer_len; 302 dxfer_len = hdr->dout_xfer_len;
303 dxferp = (void*)(unsigned long)hdr->dout_xferp; 303 dxferp = (void __user *)(unsigned long)hdr->dout_xferp;
304 } else if (hdr->din_xfer_len) { 304 } else if (hdr->din_xfer_len) {
305 dxfer_len = hdr->din_xfer_len; 305 dxfer_len = hdr->din_xfer_len;
306 dxferp = (void*)(unsigned long)hdr->din_xferp; 306 dxferp = (void __user *)(unsigned long)hdr->din_xferp;
307 } else 307 } else
308 dxfer_len = 0; 308 dxfer_len = 0;
309 309
@@ -445,7 +445,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
445 int len = min_t(unsigned int, hdr->max_response_len, 445 int len = min_t(unsigned int, hdr->max_response_len,
446 rq->sense_len); 446 rq->sense_len);
447 447
448 ret = copy_to_user((void*)(unsigned long)hdr->response, 448 ret = copy_to_user((void __user *)(unsigned long)hdr->response,
449 rq->sense, len); 449 rq->sense, len);
450 if (!ret) 450 if (!ret)
451 hdr->response_len = len; 451 hdr->response_len = len;
@@ -606,7 +606,7 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
606 ret = __bsg_read(buf, count, bd, NULL, &bytes_read); 606 ret = __bsg_read(buf, count, bd, NULL, &bytes_read);
607 *ppos = bytes_read; 607 *ppos = bytes_read;
608 608
609 if (!bytes_read || (bytes_read && err_block_err(ret))) 609 if (!bytes_read || err_block_err(ret))
610 bytes_read = ret; 610 bytes_read = ret;
611 611
612 return bytes_read; 612 return bytes_read;
@@ -686,7 +686,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
686 /* 686 /*
687 * return bytes written on non-fatal errors 687 * return bytes written on non-fatal errors
688 */ 688 */
689 if (!bytes_written || (bytes_written && err_block_err(ret))) 689 if (!bytes_written || err_block_err(ret))
690 bytes_written = ret; 690 bytes_written = ret;
691 691
692 dprintk("%s: returning %Zd\n", bd->name, bytes_written); 692 dprintk("%s: returning %Zd\n", bd->name, bytes_written);
@@ -878,7 +878,7 @@ static unsigned int bsg_poll(struct file *file, poll_table *wait)
878 spin_lock_irq(&bd->lock); 878 spin_lock_irq(&bd->lock);
879 if (!list_empty(&bd->done_list)) 879 if (!list_empty(&bd->done_list))
880 mask |= POLLIN | POLLRDNORM; 880 mask |= POLLIN | POLLRDNORM;
881 if (bd->queued_cmds >= bd->max_queue) 881 if (bd->queued_cmds < bd->max_queue)
882 mask |= POLLOUT; 882 mask |= POLLOUT;
883 spin_unlock_irq(&bd->lock); 883 spin_unlock_irq(&bd->lock);
884 884
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index ae21919f15e1..1f96ad6254f1 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -87,9 +87,10 @@ struct cfq_rb_root {
87 unsigned count; 87 unsigned count;
88 unsigned total_weight; 88 unsigned total_weight;
89 u64 min_vdisktime; 89 u64 min_vdisktime;
90 struct cfq_ttime ttime;
90}; 91};
91#define CFQ_RB_ROOT (struct cfq_rb_root) { .rb = RB_ROOT, .left = NULL, \ 92#define CFQ_RB_ROOT (struct cfq_rb_root) { .rb = RB_ROOT, \
92 .count = 0, .min_vdisktime = 0, } 93 .ttime = {.last_end_request = jiffies,},}
93 94
94/* 95/*
95 * Per process-grouping structure 96 * Per process-grouping structure
@@ -129,14 +130,12 @@ struct cfq_queue {
129 unsigned long slice_end; 130 unsigned long slice_end;
130 long slice_resid; 131 long slice_resid;
131 132
132 /* pending metadata requests */
133 int meta_pending;
134 /* number of requests that are on the dispatch list or inside driver */ 133 /* number of requests that are on the dispatch list or inside driver */
135 int dispatched; 134 int dispatched;
136 135
137 /* io prio of this group */ 136 /* io prio of this group */
138 unsigned short ioprio, org_ioprio; 137 unsigned short ioprio, org_ioprio;
139 unsigned short ioprio_class, org_ioprio_class; 138 unsigned short ioprio_class;
140 139
141 pid_t pid; 140 pid_t pid;
142 141
@@ -212,6 +211,7 @@ struct cfq_group {
212#endif 211#endif
213 /* number of requests that are on the dispatch list or inside driver */ 212 /* number of requests that are on the dispatch list or inside driver */
214 int dispatched; 213 int dispatched;
214 struct cfq_ttime ttime;
215}; 215};
216 216
217/* 217/*
@@ -393,6 +393,18 @@ CFQ_CFQQ_FNS(wait_busy);
393 j++, st = i < IDLE_WORKLOAD ? \ 393 j++, st = i < IDLE_WORKLOAD ? \
394 &cfqg->service_trees[i][j]: NULL) \ 394 &cfqg->service_trees[i][j]: NULL) \
395 395
396static inline bool cfq_io_thinktime_big(struct cfq_data *cfqd,
397 struct cfq_ttime *ttime, bool group_idle)
398{
399 unsigned long slice;
400 if (!sample_valid(ttime->ttime_samples))
401 return false;
402 if (group_idle)
403 slice = cfqd->cfq_group_idle;
404 else
405 slice = cfqd->cfq_slice_idle;
406 return ttime->ttime_mean > slice;
407}
396 408
397static inline bool iops_mode(struct cfq_data *cfqd) 409static inline bool iops_mode(struct cfq_data *cfqd)
398{ 410{
@@ -670,9 +682,6 @@ cfq_choose_req(struct cfq_data *cfqd, struct request *rq1, struct request *rq2,
670 if (rq_is_sync(rq1) != rq_is_sync(rq2)) 682 if (rq_is_sync(rq1) != rq_is_sync(rq2))
671 return rq_is_sync(rq1) ? rq1 : rq2; 683 return rq_is_sync(rq1) ? rq1 : rq2;
672 684
673 if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_META)
674 return rq1->cmd_flags & REQ_META ? rq1 : rq2;
675
676 s1 = blk_rq_pos(rq1); 685 s1 = blk_rq_pos(rq1);
677 s2 = blk_rq_pos(rq2); 686 s2 = blk_rq_pos(rq2);
678 687
@@ -1005,8 +1014,8 @@ static inline struct cfq_group *cfqg_of_blkg(struct blkio_group *blkg)
1005 return NULL; 1014 return NULL;
1006} 1015}
1007 1016
1008void cfq_update_blkio_group_weight(void *key, struct blkio_group *blkg, 1017static void cfq_update_blkio_group_weight(void *key, struct blkio_group *blkg,
1009 unsigned int weight) 1018 unsigned int weight)
1010{ 1019{
1011 struct cfq_group *cfqg = cfqg_of_blkg(blkg); 1020 struct cfq_group *cfqg = cfqg_of_blkg(blkg);
1012 cfqg->new_weight = weight; 1021 cfqg->new_weight = weight;
@@ -1059,6 +1068,8 @@ static struct cfq_group * cfq_alloc_cfqg(struct cfq_data *cfqd)
1059 *st = CFQ_RB_ROOT; 1068 *st = CFQ_RB_ROOT;
1060 RB_CLEAR_NODE(&cfqg->rb_node); 1069 RB_CLEAR_NODE(&cfqg->rb_node);
1061 1070
1071 cfqg->ttime.last_end_request = jiffies;
1072
1062 /* 1073 /*
1063 * Take the initial reference that will be released on destroy 1074 * Take the initial reference that will be released on destroy
1064 * This can be thought of a joint reference by cgroup and 1075 * This can be thought of a joint reference by cgroup and
@@ -1235,7 +1246,7 @@ static void cfq_release_cfq_groups(struct cfq_data *cfqd)
1235 * it should not be NULL as even if elevator was exiting, cgroup deltion 1246 * it should not be NULL as even if elevator was exiting, cgroup deltion
1236 * path got to it first. 1247 * path got to it first.
1237 */ 1248 */
1238void cfq_unlink_blkio_group(void *key, struct blkio_group *blkg) 1249static void cfq_unlink_blkio_group(void *key, struct blkio_group *blkg)
1239{ 1250{
1240 unsigned long flags; 1251 unsigned long flags;
1241 struct cfq_data *cfqd = key; 1252 struct cfq_data *cfqd = key;
@@ -1502,16 +1513,11 @@ static void cfq_add_rq_rb(struct request *rq)
1502{ 1513{
1503 struct cfq_queue *cfqq = RQ_CFQQ(rq); 1514 struct cfq_queue *cfqq = RQ_CFQQ(rq);
1504 struct cfq_data *cfqd = cfqq->cfqd; 1515 struct cfq_data *cfqd = cfqq->cfqd;
1505 struct request *__alias, *prev; 1516 struct request *prev;
1506 1517
1507 cfqq->queued[rq_is_sync(rq)]++; 1518 cfqq->queued[rq_is_sync(rq)]++;
1508 1519
1509 /* 1520 elv_rb_add(&cfqq->sort_list, rq);
1510 * looks a little odd, but the first insert might return an alias.
1511 * if that happens, put the alias on the dispatch list
1512 */
1513 while ((__alias = elv_rb_add(&cfqq->sort_list, rq)) != NULL)
1514 cfq_dispatch_insert(cfqd->queue, __alias);
1515 1521
1516 if (!cfq_cfqq_on_rr(cfqq)) 1522 if (!cfq_cfqq_on_rr(cfqq))
1517 cfq_add_cfqq_rr(cfqd, cfqq); 1523 cfq_add_cfqq_rr(cfqd, cfqq);
@@ -1598,10 +1604,6 @@ static void cfq_remove_request(struct request *rq)
1598 cfqq->cfqd->rq_queued--; 1604 cfqq->cfqd->rq_queued--;
1599 cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg, 1605 cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg,
1600 rq_data_dir(rq), rq_is_sync(rq)); 1606 rq_data_dir(rq), rq_is_sync(rq));
1601 if (rq->cmd_flags & REQ_META) {
1602 WARN_ON(!cfqq->meta_pending);
1603 cfqq->meta_pending--;
1604 }
1605} 1607}
1606 1608
1607static int cfq_merge(struct request_queue *q, struct request **req, 1609static int cfq_merge(struct request_queue *q, struct request **req,
@@ -1969,7 +1971,8 @@ static bool cfq_should_idle(struct cfq_data *cfqd, struct cfq_queue *cfqq)
1969 * Otherwise, we do only if they are the last ones 1971 * Otherwise, we do only if they are the last ones
1970 * in their service tree. 1972 * in their service tree.
1971 */ 1973 */
1972 if (service_tree->count == 1 && cfq_cfqq_sync(cfqq)) 1974 if (service_tree->count == 1 && cfq_cfqq_sync(cfqq) &&
1975 !cfq_io_thinktime_big(cfqd, &service_tree->ttime, false))
1973 return true; 1976 return true;
1974 cfq_log_cfqq(cfqd, cfqq, "Not idling. st->count:%d", 1977 cfq_log_cfqq(cfqd, cfqq, "Not idling. st->count:%d",
1975 service_tree->count); 1978 service_tree->count);
@@ -2022,10 +2025,10 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd)
2022 * slice, then don't idle. This avoids overrunning the allotted 2025 * slice, then don't idle. This avoids overrunning the allotted
2023 * time slice. 2026 * time slice.
2024 */ 2027 */
2025 if (sample_valid(cic->ttime_samples) && 2028 if (sample_valid(cic->ttime.ttime_samples) &&
2026 (cfqq->slice_end - jiffies < cic->ttime_mean)) { 2029 (cfqq->slice_end - jiffies < cic->ttime.ttime_mean)) {
2027 cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%lu", 2030 cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%lu",
2028 cic->ttime_mean); 2031 cic->ttime.ttime_mean);
2029 return; 2032 return;
2030 } 2033 }
2031 2034
@@ -2381,8 +2384,9 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
2381 * this group, wait for requests to complete. 2384 * this group, wait for requests to complete.
2382 */ 2385 */
2383check_group_idle: 2386check_group_idle:
2384 if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq == 1 2387 if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq == 1 &&
2385 && cfqq->cfqg->dispatched) { 2388 cfqq->cfqg->dispatched &&
2389 !cfq_io_thinktime_big(cfqd, &cfqq->cfqg->ttime, true)) {
2386 cfqq = NULL; 2390 cfqq = NULL;
2387 goto keep_queue; 2391 goto keep_queue;
2388 } 2392 }
@@ -2833,7 +2837,7 @@ cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
2833 cic = kmem_cache_alloc_node(cfq_ioc_pool, gfp_mask | __GFP_ZERO, 2837 cic = kmem_cache_alloc_node(cfq_ioc_pool, gfp_mask | __GFP_ZERO,
2834 cfqd->queue->node); 2838 cfqd->queue->node);
2835 if (cic) { 2839 if (cic) {
2836 cic->last_end_request = jiffies; 2840 cic->ttime.last_end_request = jiffies;
2837 INIT_LIST_HEAD(&cic->queue_list); 2841 INIT_LIST_HEAD(&cic->queue_list);
2838 INIT_HLIST_NODE(&cic->cic_list); 2842 INIT_HLIST_NODE(&cic->cic_list);
2839 cic->dtor = cfq_free_io_context; 2843 cic->dtor = cfq_free_io_context;
@@ -2883,7 +2887,6 @@ static void cfq_init_prio_data(struct cfq_queue *cfqq, struct io_context *ioc)
2883 * elevate the priority of this queue 2887 * elevate the priority of this queue
2884 */ 2888 */
2885 cfqq->org_ioprio = cfqq->ioprio; 2889 cfqq->org_ioprio = cfqq->ioprio;
2886 cfqq->org_ioprio_class = cfqq->ioprio_class;
2887 cfq_clear_cfqq_prio_changed(cfqq); 2890 cfq_clear_cfqq_prio_changed(cfqq);
2888} 2891}
2889 2892
@@ -3221,14 +3224,28 @@ err:
3221} 3224}
3222 3225
3223static void 3226static void
3224cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_io_context *cic) 3227__cfq_update_io_thinktime(struct cfq_ttime *ttime, unsigned long slice_idle)
3225{ 3228{
3226 unsigned long elapsed = jiffies - cic->last_end_request; 3229 unsigned long elapsed = jiffies - ttime->last_end_request;
3227 unsigned long ttime = min(elapsed, 2UL * cfqd->cfq_slice_idle); 3230 elapsed = min(elapsed, 2UL * slice_idle);
3228 3231
3229 cic->ttime_samples = (7*cic->ttime_samples + 256) / 8; 3232 ttime->ttime_samples = (7*ttime->ttime_samples + 256) / 8;
3230 cic->ttime_total = (7*cic->ttime_total + 256*ttime) / 8; 3233 ttime->ttime_total = (7*ttime->ttime_total + 256*elapsed) / 8;
3231 cic->ttime_mean = (cic->ttime_total + 128) / cic->ttime_samples; 3234 ttime->ttime_mean = (ttime->ttime_total + 128) / ttime->ttime_samples;
3235}
3236
3237static void
3238cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_queue *cfqq,
3239 struct cfq_io_context *cic)
3240{
3241 if (cfq_cfqq_sync(cfqq)) {
3242 __cfq_update_io_thinktime(&cic->ttime, cfqd->cfq_slice_idle);
3243 __cfq_update_io_thinktime(&cfqq->service_tree->ttime,
3244 cfqd->cfq_slice_idle);
3245 }
3246#ifdef CONFIG_CFQ_GROUP_IOSCHED
3247 __cfq_update_io_thinktime(&cfqq->cfqg->ttime, cfqd->cfq_group_idle);
3248#endif
3232} 3249}
3233 3250
3234static void 3251static void
@@ -3277,8 +3294,8 @@ cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq,
3277 else if (!atomic_read(&cic->ioc->nr_tasks) || !cfqd->cfq_slice_idle || 3294 else if (!atomic_read(&cic->ioc->nr_tasks) || !cfqd->cfq_slice_idle ||
3278 (!cfq_cfqq_deep(cfqq) && CFQQ_SEEKY(cfqq))) 3295 (!cfq_cfqq_deep(cfqq) && CFQQ_SEEKY(cfqq)))
3279 enable_idle = 0; 3296 enable_idle = 0;
3280 else if (sample_valid(cic->ttime_samples)) { 3297 else if (sample_valid(cic->ttime.ttime_samples)) {
3281 if (cic->ttime_mean > cfqd->cfq_slice_idle) 3298 if (cic->ttime.ttime_mean > cfqd->cfq_slice_idle)
3282 enable_idle = 0; 3299 enable_idle = 0;
3283 else 3300 else
3284 enable_idle = 1; 3301 enable_idle = 1;
@@ -3340,13 +3357,6 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
3340 return true; 3357 return true;
3341 3358
3342 /* 3359 /*
3343 * So both queues are sync. Let the new request get disk time if
3344 * it's a metadata request and the current queue is doing regular IO.
3345 */
3346 if ((rq->cmd_flags & REQ_META) && !cfqq->meta_pending)
3347 return true;
3348
3349 /*
3350 * Allow an RT request to pre-empt an ongoing non-RT cfqq timeslice. 3360 * Allow an RT request to pre-empt an ongoing non-RT cfqq timeslice.
3351 */ 3361 */
3352 if (cfq_class_rt(new_cfqq) && !cfq_class_rt(cfqq)) 3362 if (cfq_class_rt(new_cfqq) && !cfq_class_rt(cfqq))
@@ -3410,10 +3420,8 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
3410 struct cfq_io_context *cic = RQ_CIC(rq); 3420 struct cfq_io_context *cic = RQ_CIC(rq);
3411 3421
3412 cfqd->rq_queued++; 3422 cfqd->rq_queued++;
3413 if (rq->cmd_flags & REQ_META)
3414 cfqq->meta_pending++;
3415 3423
3416 cfq_update_io_thinktime(cfqd, cic); 3424 cfq_update_io_thinktime(cfqd, cfqq, cic);
3417 cfq_update_io_seektime(cfqd, cfqq, rq); 3425 cfq_update_io_seektime(cfqd, cfqq, rq);
3418 cfq_update_idle_window(cfqd, cfqq, cic); 3426 cfq_update_idle_window(cfqd, cfqq, cic);
3419 3427
@@ -3520,12 +3528,16 @@ static bool cfq_should_wait_busy(struct cfq_data *cfqd, struct cfq_queue *cfqq)
3520 if (cfqq->cfqg->nr_cfqq > 1) 3528 if (cfqq->cfqg->nr_cfqq > 1)
3521 return false; 3529 return false;
3522 3530
3531 /* the only queue in the group, but think time is big */
3532 if (cfq_io_thinktime_big(cfqd, &cfqq->cfqg->ttime, true))
3533 return false;
3534
3523 if (cfq_slice_used(cfqq)) 3535 if (cfq_slice_used(cfqq))
3524 return true; 3536 return true;
3525 3537
3526 /* if slice left is less than think time, wait busy */ 3538 /* if slice left is less than think time, wait busy */
3527 if (cic && sample_valid(cic->ttime_samples) 3539 if (cic && sample_valid(cic->ttime.ttime_samples)
3528 && (cfqq->slice_end - jiffies < cic->ttime_mean)) 3540 && (cfqq->slice_end - jiffies < cic->ttime.ttime_mean))
3529 return true; 3541 return true;
3530 3542
3531 /* 3543 /*
@@ -3566,11 +3578,24 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
3566 cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--; 3578 cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--;
3567 3579
3568 if (sync) { 3580 if (sync) {
3569 RQ_CIC(rq)->last_end_request = now; 3581 struct cfq_rb_root *service_tree;
3582
3583 RQ_CIC(rq)->ttime.last_end_request = now;
3584
3585 if (cfq_cfqq_on_rr(cfqq))
3586 service_tree = cfqq->service_tree;
3587 else
3588 service_tree = service_tree_for(cfqq->cfqg,
3589 cfqq_prio(cfqq), cfqq_type(cfqq));
3590 service_tree->ttime.last_end_request = now;
3570 if (!time_after(rq->start_time + cfqd->cfq_fifo_expire[1], now)) 3591 if (!time_after(rq->start_time + cfqd->cfq_fifo_expire[1], now))
3571 cfqd->last_delayed_sync = now; 3592 cfqd->last_delayed_sync = now;
3572 } 3593 }
3573 3594
3595#ifdef CONFIG_CFQ_GROUP_IOSCHED
3596 cfqq->cfqg->ttime.last_end_request = now;
3597#endif
3598
3574 /* 3599 /*
3575 * If this is the active queue, check if it needs to be expired, 3600 * If this is the active queue, check if it needs to be expired,
3576 * or if we want to idle in case it has no pending requests. 3601 * or if we want to idle in case it has no pending requests.
@@ -3616,30 +3641,6 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
3616 cfq_schedule_dispatch(cfqd); 3641 cfq_schedule_dispatch(cfqd);
3617} 3642}
3618 3643
3619/*
3620 * we temporarily boost lower priority queues if they are holding fs exclusive
3621 * resources. they are boosted to normal prio (CLASS_BE/4)
3622 */
3623static void cfq_prio_boost(struct cfq_queue *cfqq)
3624{
3625 if (has_fs_excl()) {
3626 /*
3627 * boost idle prio on transactions that would lock out other
3628 * users of the filesystem
3629 */
3630 if (cfq_class_idle(cfqq))
3631 cfqq->ioprio_class = IOPRIO_CLASS_BE;
3632 if (cfqq->ioprio > IOPRIO_NORM)
3633 cfqq->ioprio = IOPRIO_NORM;
3634 } else {
3635 /*
3636 * unboost the queue (if needed)
3637 */
3638 cfqq->ioprio_class = cfqq->org_ioprio_class;
3639 cfqq->ioprio = cfqq->org_ioprio;
3640 }
3641}
3642
3643static inline int __cfq_may_queue(struct cfq_queue *cfqq) 3644static inline int __cfq_may_queue(struct cfq_queue *cfqq)
3644{ 3645{
3645 if (cfq_cfqq_wait_request(cfqq) && !cfq_cfqq_must_alloc_slice(cfqq)) { 3646 if (cfq_cfqq_wait_request(cfqq) && !cfq_cfqq_must_alloc_slice(cfqq)) {
@@ -3670,7 +3671,6 @@ static int cfq_may_queue(struct request_queue *q, int rw)
3670 cfqq = cic_to_cfqq(cic, rw_is_sync(rw)); 3671 cfqq = cic_to_cfqq(cic, rw_is_sync(rw));
3671 if (cfqq) { 3672 if (cfqq) {
3672 cfq_init_prio_data(cfqq, cic->ioc); 3673 cfq_init_prio_data(cfqq, cic->ioc);
3673 cfq_prio_boost(cfqq);
3674 3674
3675 return __cfq_may_queue(cfqq); 3675 return __cfq_may_queue(cfqq);
3676 } 3676 }
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index cc3eb78e333a..7b725020823c 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -208,19 +208,6 @@ static int compat_blkpg_ioctl(struct block_device *bdev, fmode_t mode,
208#define BLKBSZSET_32 _IOW(0x12, 113, int) 208#define BLKBSZSET_32 _IOW(0x12, 113, int)
209#define BLKGETSIZE64_32 _IOR(0x12, 114, int) 209#define BLKGETSIZE64_32 _IOR(0x12, 114, int)
210 210
211struct compat_floppy_struct {
212 compat_uint_t size;
213 compat_uint_t sect;
214 compat_uint_t head;
215 compat_uint_t track;
216 compat_uint_t stretch;
217 unsigned char gap;
218 unsigned char rate;
219 unsigned char spec1;
220 unsigned char fmt_gap;
221 const compat_caddr_t name;
222};
223
224struct compat_floppy_drive_params { 211struct compat_floppy_drive_params {
225 char cmos; 212 char cmos;
226 compat_ulong_t max_dtr; 213 compat_ulong_t max_dtr;
@@ -288,7 +275,6 @@ struct compat_floppy_write_errors {
288 275
289#define FDSETPRM32 _IOW(2, 0x42, struct compat_floppy_struct) 276#define FDSETPRM32 _IOW(2, 0x42, struct compat_floppy_struct)
290#define FDDEFPRM32 _IOW(2, 0x43, struct compat_floppy_struct) 277#define FDDEFPRM32 _IOW(2, 0x43, struct compat_floppy_struct)
291#define FDGETPRM32 _IOR(2, 0x04, struct compat_floppy_struct)
292#define FDSETDRVPRM32 _IOW(2, 0x90, struct compat_floppy_drive_params) 278#define FDSETDRVPRM32 _IOW(2, 0x90, struct compat_floppy_drive_params)
293#define FDGETDRVPRM32 _IOR(2, 0x11, struct compat_floppy_drive_params) 279#define FDGETDRVPRM32 _IOR(2, 0x11, struct compat_floppy_drive_params)
294#define FDGETDRVSTAT32 _IOR(2, 0x12, struct compat_floppy_drive_struct) 280#define FDGETDRVSTAT32 _IOR(2, 0x12, struct compat_floppy_drive_struct)
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 5139c0ea1864..c644137d9cd6 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -77,10 +77,8 @@ static void
77deadline_add_rq_rb(struct deadline_data *dd, struct request *rq) 77deadline_add_rq_rb(struct deadline_data *dd, struct request *rq)
78{ 78{
79 struct rb_root *root = deadline_rb_root(dd, rq); 79 struct rb_root *root = deadline_rb_root(dd, rq);
80 struct request *__alias;
81 80
82 while (unlikely(__alias = elv_rb_add(root, rq))) 81 elv_rb_add(root, rq);
83 deadline_move_request(dd, __alias);
84} 82}
85 83
86static inline void 84static inline void
diff --git a/block/elevator.c b/block/elevator.c
index b0b38ce0dcb6..a3b64bc71d88 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -353,7 +353,7 @@ static struct request *elv_rqhash_find(struct request_queue *q, sector_t offset)
353 * RB-tree support functions for inserting/lookup/removal of requests 353 * RB-tree support functions for inserting/lookup/removal of requests
354 * in a sorted RB tree. 354 * in a sorted RB tree.
355 */ 355 */
356struct request *elv_rb_add(struct rb_root *root, struct request *rq) 356void elv_rb_add(struct rb_root *root, struct request *rq)
357{ 357{
358 struct rb_node **p = &root->rb_node; 358 struct rb_node **p = &root->rb_node;
359 struct rb_node *parent = NULL; 359 struct rb_node *parent = NULL;
@@ -365,15 +365,12 @@ struct request *elv_rb_add(struct rb_root *root, struct request *rq)
365 365
366 if (blk_rq_pos(rq) < blk_rq_pos(__rq)) 366 if (blk_rq_pos(rq) < blk_rq_pos(__rq))
367 p = &(*p)->rb_left; 367 p = &(*p)->rb_left;
368 else if (blk_rq_pos(rq) > blk_rq_pos(__rq)) 368 else if (blk_rq_pos(rq) >= blk_rq_pos(__rq))
369 p = &(*p)->rb_right; 369 p = &(*p)->rb_right;
370 else
371 return __rq;
372 } 370 }
373 371
374 rb_link_node(&rq->rb_node, parent, p); 372 rb_link_node(&rq->rb_node, parent, p);
375 rb_insert_color(&rq->rb_node, root); 373 rb_insert_color(&rq->rb_node, root);
376 return NULL;
377} 374}
378EXPORT_SYMBOL(elv_rb_add); 375EXPORT_SYMBOL(elv_rb_add);
379 376
diff --git a/block/genhd.c b/block/genhd.c
index 6024b82e3209..5cb51c55f6d8 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -602,7 +602,7 @@ void add_disk(struct gendisk *disk)
602 disk->major = MAJOR(devt); 602 disk->major = MAJOR(devt);
603 disk->first_minor = MINOR(devt); 603 disk->first_minor = MINOR(devt);
604 604
605 /* Register BDI before referencing it from bdev */ 605 /* Register BDI before referencing it from bdev */
606 bdi = &disk->queue->backing_dev_info; 606 bdi = &disk->queue->backing_dev_info;
607 bdi_register_dev(bdi, disk_devt(disk)); 607 bdi_register_dev(bdi, disk_devt(disk));
608 608
@@ -1140,7 +1140,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
1140 "wsect wuse running use aveq" 1140 "wsect wuse running use aveq"
1141 "\n\n"); 1141 "\n\n");
1142 */ 1142 */
1143 1143
1144 disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0); 1144 disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
1145 while ((hd = disk_part_iter_next(&piter))) { 1145 while ((hd = disk_part_iter_next(&piter))) {
1146 cpu = part_stat_lock(); 1146 cpu = part_stat_lock();
@@ -1164,7 +1164,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
1164 ); 1164 );
1165 } 1165 }
1166 disk_part_iter_exit(&piter); 1166 disk_part_iter_exit(&piter);
1167 1167
1168 return 0; 1168 return 0;
1169} 1169}
1170 1170
@@ -1492,30 +1492,32 @@ void disk_unblock_events(struct gendisk *disk)
1492} 1492}
1493 1493
1494/** 1494/**
1495 * disk_check_events - schedule immediate event checking 1495 * disk_flush_events - schedule immediate event checking and flushing
1496 * @disk: disk to check events for 1496 * @disk: disk to check and flush events for
1497 * @mask: events to flush
1497 * 1498 *
1498 * Schedule immediate event checking on @disk if not blocked. 1499 * Schedule immediate event checking on @disk if not blocked. Events in
1500 * @mask are scheduled to be cleared from the driver. Note that this
1501 * doesn't clear the events from @disk->ev.
1499 * 1502 *
1500 * CONTEXT: 1503 * CONTEXT:
1501 * Don't care. Safe to call from irq context. 1504 * If @mask is non-zero must be called with bdev->bd_mutex held.
1502 */ 1505 */
1503void disk_check_events(struct gendisk *disk) 1506void disk_flush_events(struct gendisk *disk, unsigned int mask)
1504{ 1507{
1505 struct disk_events *ev = disk->ev; 1508 struct disk_events *ev = disk->ev;
1506 unsigned long flags;
1507 1509
1508 if (!ev) 1510 if (!ev)
1509 return; 1511 return;
1510 1512
1511 spin_lock_irqsave(&ev->lock, flags); 1513 spin_lock_irq(&ev->lock);
1514 ev->clearing |= mask;
1512 if (!ev->block) { 1515 if (!ev->block) {
1513 cancel_delayed_work(&ev->dwork); 1516 cancel_delayed_work(&ev->dwork);
1514 queue_delayed_work(system_nrt_wq, &ev->dwork, 0); 1517 queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
1515 } 1518 }
1516 spin_unlock_irqrestore(&ev->lock, flags); 1519 spin_unlock_irq(&ev->lock);
1517} 1520}
1518EXPORT_SYMBOL_GPL(disk_check_events);
1519 1521
1520/** 1522/**
1521 * disk_clear_events - synchronously check, clear and return pending events 1523 * disk_clear_events - synchronously check, clear and return pending events
@@ -1705,7 +1707,7 @@ static int disk_events_set_dfl_poll_msecs(const char *val,
1705 mutex_lock(&disk_events_mutex); 1707 mutex_lock(&disk_events_mutex);
1706 1708
1707 list_for_each_entry(ev, &disk_events, node) 1709 list_for_each_entry(ev, &disk_events, node)
1708 disk_check_events(ev->disk); 1710 disk_flush_events(ev->disk, 0);
1709 1711
1710 mutex_unlock(&disk_events_mutex); 1712 mutex_unlock(&disk_events_mutex);
1711 1713
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 75afa75a515e..ca3e6be44a04 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -313,6 +313,7 @@ config PATA_AMD
313 313
314config PATA_ARASAN_CF 314config PATA_ARASAN_CF
315 tristate "ARASAN CompactFlash PATA Controller Support" 315 tristate "ARASAN CompactFlash PATA Controller Support"
316 depends on DMADEVICES
316 select DMA_ENGINE 317 select DMA_ENGINE
317 help 318 help
318 Say Y here to support the ARASAN CompactFlash PATA controller 319 Say Y here to support the ARASAN CompactFlash PATA controller
diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c
index ae22be4157b5..3bc8c79bf2c7 100644
--- a/drivers/ata/acard-ahci.c
+++ b/drivers/ata/acard-ahci.c
@@ -135,8 +135,8 @@ static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg
135 135
136 if (mesg.event & PM_EVENT_SUSPEND && 136 if (mesg.event & PM_EVENT_SUSPEND &&
137 hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { 137 hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
138 dev_printk(KERN_ERR, &pdev->dev, 138 dev_err(&pdev->dev,
139 "BIOS update required for suspend/resume\n"); 139 "BIOS update required for suspend/resume\n");
140 return -EIO; 140 return -EIO;
141 } 141 }
142 142
@@ -187,7 +187,7 @@ static int acard_ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
187 if (rc) { 187 if (rc) {
188 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 188 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
189 if (rc) { 189 if (rc) {
190 dev_printk(KERN_ERR, &pdev->dev, 190 dev_err(&pdev->dev,
191 "64-bit DMA enable failed\n"); 191 "64-bit DMA enable failed\n");
192 return rc; 192 return rc;
193 } 193 }
@@ -195,14 +195,13 @@ static int acard_ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
195 } else { 195 } else {
196 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 196 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
197 if (rc) { 197 if (rc) {
198 dev_printk(KERN_ERR, &pdev->dev, 198 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
199 "32-bit DMA enable failed\n");
200 return rc; 199 return rc;
201 } 200 }
202 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 201 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
203 if (rc) { 202 if (rc) {
204 dev_printk(KERN_ERR, &pdev->dev, 203 dev_err(&pdev->dev,
205 "32-bit consistent DMA enable failed\n"); 204 "32-bit consistent DMA enable failed\n");
206 return rc; 205 return rc;
207 } 206 }
208 } 207 }
@@ -343,14 +342,12 @@ static int acard_ahci_port_start(struct ata_port *ap)
343 if (cmd & PORT_CMD_FBSCP) 342 if (cmd & PORT_CMD_FBSCP)
344 pp->fbs_supported = true; 343 pp->fbs_supported = true;
345 else if (hpriv->flags & AHCI_HFLAG_YES_FBS) { 344 else if (hpriv->flags & AHCI_HFLAG_YES_FBS) {
346 dev_printk(KERN_INFO, dev, 345 dev_info(dev, "port %d can do FBS, forcing FBSCP\n",
347 "port %d can do FBS, forcing FBSCP\n", 346 ap->port_no);
348 ap->port_no);
349 pp->fbs_supported = true; 347 pp->fbs_supported = true;
350 } else 348 } else
351 dev_printk(KERN_WARNING, dev, 349 dev_warn(dev, "port %d is not capable of FBS\n",
352 "port %d is not capable of FBS\n", 350 ap->port_no);
353 ap->port_no);
354 } 351 }
355 352
356 if (pp->fbs_supported) { 353 if (pp->fbs_supported) {
@@ -406,7 +403,6 @@ static int acard_ahci_port_start(struct ata_port *ap)
406 403
407static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 404static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
408{ 405{
409 static int printed_version;
410 unsigned int board_id = ent->driver_data; 406 unsigned int board_id = ent->driver_data;
411 struct ata_port_info pi = acard_ahci_port_info[board_id]; 407 struct ata_port_info pi = acard_ahci_port_info[board_id];
412 const struct ata_port_info *ppi[] = { &pi, NULL }; 408 const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -419,8 +415,7 @@ static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id
419 415
420 WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS); 416 WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS);
421 417
422 if (!printed_version++) 418 ata_print_version_once(&pdev->dev, DRV_VERSION);
423 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
424 419
425 /* acquire resources */ 420 /* acquire resources */
426 rc = pcim_enable_device(pdev); 421 rc = pcim_enable_device(pdev);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 71afe0371311..fb7b90b05922 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -79,8 +79,6 @@ enum board_ids {
79}; 79};
80 80
81static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 81static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
82static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
83 unsigned long deadline);
84static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, 82static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
85 unsigned long deadline); 83 unsigned long deadline);
86static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, 84static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
@@ -104,12 +102,6 @@ static struct ata_port_operations ahci_p5wdh_ops = {
104 .hardreset = ahci_p5wdh_hardreset, 102 .hardreset = ahci_p5wdh_hardreset,
105}; 103};
106 104
107static struct ata_port_operations ahci_sb600_ops = {
108 .inherits = &ahci_ops,
109 .softreset = ahci_sb600_softreset,
110 .pmp_softreset = ahci_sb600_softreset,
111};
112
113#define AHCI_HFLAGS(flags) .private_data = (void *)(flags) 105#define AHCI_HFLAGS(flags) .private_data = (void *)(flags)
114 106
115static const struct ata_port_info ahci_port_info[] = { 107static const struct ata_port_info ahci_port_info[] = {
@@ -188,7 +180,7 @@ static const struct ata_port_info ahci_port_info[] = {
188 .flags = AHCI_FLAG_COMMON, 180 .flags = AHCI_FLAG_COMMON,
189 .pio_mask = ATA_PIO4, 181 .pio_mask = ATA_PIO4,
190 .udma_mask = ATA_UDMA6, 182 .udma_mask = ATA_UDMA6,
191 .port_ops = &ahci_sb600_ops, 183 .port_ops = &ahci_pmp_retry_srst_ops,
192 }, 184 },
193 [board_ahci_sb700] = /* for SB700 and SB800 */ 185 [board_ahci_sb700] = /* for SB700 and SB800 */
194 { 186 {
@@ -196,7 +188,7 @@ static const struct ata_port_info ahci_port_info[] = {
196 .flags = AHCI_FLAG_COMMON, 188 .flags = AHCI_FLAG_COMMON,
197 .pio_mask = ATA_PIO4, 189 .pio_mask = ATA_PIO4,
198 .udma_mask = ATA_UDMA6, 190 .udma_mask = ATA_UDMA6,
199 .port_ops = &ahci_sb600_ops, 191 .port_ops = &ahci_pmp_retry_srst_ops,
200 }, 192 },
201 [board_ahci_vt8251] = 193 [board_ahci_vt8251] =
202 { 194 {
@@ -267,6 +259,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
267 { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */ 259 { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
268 { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */ 260 { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
269 { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */ 261 { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */
262 { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
270 263
271 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 264 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
272 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 265 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -502,55 +495,6 @@ static void ahci_pci_init_controller(struct ata_host *host)
502 ahci_init_controller(host); 495 ahci_init_controller(host);
503} 496}
504 497
505static int ahci_sb600_check_ready(struct ata_link *link)
506{
507 void __iomem *port_mmio = ahci_port_base(link->ap);
508 u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
509 u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
510
511 /*
512 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
513 * which can save timeout delay.
514 */
515 if (irq_status & PORT_IRQ_BAD_PMP)
516 return -EIO;
517
518 return ata_check_ready(status);
519}
520
521static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
522 unsigned long deadline)
523{
524 struct ata_port *ap = link->ap;
525 void __iomem *port_mmio = ahci_port_base(ap);
526 int pmp = sata_srst_pmp(link);
527 int rc;
528 u32 irq_sts;
529
530 DPRINTK("ENTER\n");
531
532 rc = ahci_do_softreset(link, class, pmp, deadline,
533 ahci_sb600_check_ready);
534
535 /*
536 * Soft reset fails on some ATI chips with IPMS set when PMP
537 * is enabled but SATA HDD/ODD is connected to SATA port,
538 * do soft reset again to port 0.
539 */
540 if (rc == -EIO) {
541 irq_sts = readl(port_mmio + PORT_IRQ_STAT);
542 if (irq_sts & PORT_IRQ_BAD_PMP) {
543 ata_link_printk(link, KERN_WARNING,
544 "applying SB600 PMP SRST workaround "
545 "and retrying\n");
546 rc = ahci_do_softreset(link, class, 0, deadline,
547 ahci_check_ready);
548 }
549 }
550
551 return rc;
552}
553
554static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, 498static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
555 unsigned long deadline) 499 unsigned long deadline)
556{ 500{
@@ -629,8 +573,8 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
629 573
630 if (mesg.event & PM_EVENT_SUSPEND && 574 if (mesg.event & PM_EVENT_SUSPEND &&
631 hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { 575 hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
632 dev_printk(KERN_ERR, &pdev->dev, 576 dev_err(&pdev->dev,
633 "BIOS update required for suspend/resume\n"); 577 "BIOS update required for suspend/resume\n");
634 return -EIO; 578 return -EIO;
635 } 579 }
636 580
@@ -681,22 +625,21 @@ static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
681 if (rc) { 625 if (rc) {
682 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 626 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
683 if (rc) { 627 if (rc) {
684 dev_printk(KERN_ERR, &pdev->dev, 628 dev_err(&pdev->dev,
685 "64-bit DMA enable failed\n"); 629 "64-bit DMA enable failed\n");
686 return rc; 630 return rc;
687 } 631 }
688 } 632 }
689 } else { 633 } else {
690 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 634 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
691 if (rc) { 635 if (rc) {
692 dev_printk(KERN_ERR, &pdev->dev, 636 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
693 "32-bit DMA enable failed\n");
694 return rc; 637 return rc;
695 } 638 }
696 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 639 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
697 if (rc) { 640 if (rc) {
698 dev_printk(KERN_ERR, &pdev->dev, 641 dev_err(&pdev->dev,
699 "32-bit consistent DMA enable failed\n"); 642 "32-bit consistent DMA enable failed\n");
700 return rc; 643 return rc;
701 } 644 }
702 } 645 }
@@ -759,8 +702,8 @@ static void ahci_p5wdh_workaround(struct ata_host *host)
759 dmi_check_system(sysids)) { 702 dmi_check_system(sysids)) {
760 struct ata_port *ap = host->ports[1]; 703 struct ata_port *ap = host->ports[1];
761 704
762 dev_printk(KERN_INFO, &pdev->dev, "enabling ASUS P5W DH " 705 dev_info(&pdev->dev,
763 "Deluxe on-board SIMG4726 workaround\n"); 706 "enabling ASUS P5W DH Deluxe on-board SIMG4726 workaround\n");
764 707
765 ap->ops = &ahci_p5wdh_ops; 708 ap->ops = &ahci_p5wdh_ops;
766 ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA; 709 ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA;
@@ -811,6 +754,18 @@ static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
811 DMI_MATCH(DMI_BOARD_NAME, "MS-7376"), 754 DMI_MATCH(DMI_BOARD_NAME, "MS-7376"),
812 }, 755 },
813 }, 756 },
757 /*
758 * All BIOS versions for the Asus M3A support 64bit DMA.
759 * (all release versions from 0301 to 1206 were tested)
760 */
761 {
762 .ident = "ASUS M3A",
763 .matches = {
764 DMI_MATCH(DMI_BOARD_VENDOR,
765 "ASUSTeK Computer INC."),
766 DMI_MATCH(DMI_BOARD_NAME, "M3A"),
767 },
768 },
814 { } 769 { }
815 }; 770 };
816 const struct dmi_system_id *match; 771 const struct dmi_system_id *match;
@@ -831,14 +786,14 @@ static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
831 if (strcmp(buf, match->driver_data) >= 0) 786 if (strcmp(buf, match->driver_data) >= 0)
832 goto enable_64bit; 787 goto enable_64bit;
833 else { 788 else {
834 dev_printk(KERN_WARNING, &pdev->dev, "%s: BIOS too old, " 789 dev_warn(&pdev->dev,
835 "forcing 32bit DMA, update BIOS\n", match->ident); 790 "%s: BIOS too old, forcing 32bit DMA, update BIOS\n",
791 match->ident);
836 return false; 792 return false;
837 } 793 }
838 794
839enable_64bit: 795enable_64bit:
840 dev_printk(KERN_WARNING, &pdev->dev, "%s: enabling 64bit DMA\n", 796 dev_warn(&pdev->dev, "%s: enabling 64bit DMA\n", match->ident);
841 match->ident);
842 return true; 797 return true;
843} 798}
844 799
@@ -1041,9 +996,8 @@ static void ahci_gtf_filter_workaround(struct ata_host *host)
1041 return; 996 return;
1042 997
1043 filter = (unsigned long)dmi->driver_data; 998 filter = (unsigned long)dmi->driver_data;
1044 dev_printk(KERN_INFO, host->dev, 999 dev_info(host->dev, "applying extra ACPI _GTF filter 0x%x for %s\n",
1045 "applying extra ACPI _GTF filter 0x%x for %s\n", 1000 filter, dmi->ident);
1046 filter, dmi->ident);
1047 1001
1048 for (i = 0; i < host->n_ports; i++) { 1002 for (i = 0; i < host->n_ports; i++) {
1049 struct ata_port *ap = host->ports[i]; 1003 struct ata_port *ap = host->ports[i];
@@ -1062,7 +1016,6 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
1062 1016
1063static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1017static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1064{ 1018{
1065 static int printed_version;
1066 unsigned int board_id = ent->driver_data; 1019 unsigned int board_id = ent->driver_data;
1067 struct ata_port_info pi = ahci_port_info[board_id]; 1020 struct ata_port_info pi = ahci_port_info[board_id];
1068 const struct ata_port_info *ppi[] = { &pi, NULL }; 1021 const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -1075,8 +1028,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1075 1028
1076 WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS); 1029 WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS);
1077 1030
1078 if (!printed_version++) 1031 ata_print_version_once(&pdev->dev, DRV_VERSION);
1079 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1080 1032
1081 /* The AHCI driver can only drive the SATA ports, the PATA driver 1033 /* The AHCI driver can only drive the SATA ports, the PATA driver
1082 can drive them all so if both drivers are selected make sure 1034 can drive them all so if both drivers are selected make sure
@@ -1099,8 +1051,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1099 * that for SAS drives they're out of luck. 1051 * that for SAS drives they're out of luck.
1100 */ 1052 */
1101 if (pdev->vendor == PCI_VENDOR_ID_PROMISE) 1053 if (pdev->vendor == PCI_VENDOR_ID_PROMISE)
1102 dev_printk(KERN_INFO, &pdev->dev, "PDC42819 " 1054 dev_info(&pdev->dev,
1103 "can only drive SATA devices with this driver\n"); 1055 "PDC42819 can only drive SATA devices with this driver\n");
1104 1056
1105 /* acquire resources */ 1057 /* acquire resources */
1106 rc = pcim_enable_device(pdev); 1058 rc = pcim_enable_device(pdev);
@@ -1126,8 +1078,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1126 */ 1078 */
1127 pci_read_config_byte(pdev, ICH_MAP, &map); 1079 pci_read_config_byte(pdev, ICH_MAP, &map);
1128 if (map & 0x3) { 1080 if (map & 0x3) {
1129 dev_printk(KERN_INFO, &pdev->dev, "controller is in " 1081 dev_info(&pdev->dev,
1130 "combined mode, can't enable AHCI mode\n"); 1082 "controller is in combined mode, can't enable AHCI mode\n");
1131 return -ENODEV; 1083 return -ENODEV;
1132 } 1084 }
1133 } 1085 }
@@ -1184,8 +1136,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1184 1136
1185 if (ahci_broken_suspend(pdev)) { 1137 if (ahci_broken_suspend(pdev)) {
1186 hpriv->flags |= AHCI_HFLAG_NO_SUSPEND; 1138 hpriv->flags |= AHCI_HFLAG_NO_SUSPEND;
1187 dev_printk(KERN_WARNING, &pdev->dev, 1139 dev_warn(&pdev->dev,
1188 "BIOS update required for suspend/resume\n"); 1140 "BIOS update required for suspend/resume\n");
1189 } 1141 }
1190 1142
1191 if (ahci_broken_online(pdev)) { 1143 if (ahci_broken_online(pdev)) {
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 12c5282e7fca..b1750007c8dc 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -312,6 +312,7 @@ extern struct device_attribute *ahci_sdev_attrs[];
312 .sdev_attrs = ahci_sdev_attrs 312 .sdev_attrs = ahci_sdev_attrs
313 313
314extern struct ata_port_operations ahci_ops; 314extern struct ata_port_operations ahci_ops;
315extern struct ata_port_operations ahci_pmp_retry_srst_ops;
315 316
316void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, 317void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
317 u32 opts); 318 u32 opts);
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 721d38bfa339..7df56ec31819 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -81,14 +81,13 @@ static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
81 xfer_mask |= ata_xfer_mode2mask(XFER_MW_DMA_0); 81 xfer_mask |= ata_xfer_mode2mask(XFER_MW_DMA_0);
82 } 82 }
83 83
84 ata_dev_printk(dev, KERN_INFO, "configured for %s\n", 84 ata_dev_info(dev, "configured for %s\n", name);
85 name);
86 85
87 dev->xfer_mode = ata_xfer_mask2mode(xfer_mask); 86 dev->xfer_mode = ata_xfer_mask2mode(xfer_mask);
88 dev->xfer_shift = ata_xfer_mode2shift(dev->xfer_mode); 87 dev->xfer_shift = ata_xfer_mode2shift(dev->xfer_mode);
89 dev->flags &= ~ATA_DFLAG_PIO; 88 dev->flags &= ~ATA_DFLAG_PIO;
90 } else { 89 } else {
91 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); 90 ata_dev_info(dev, "configured for PIO\n");
92 dev->xfer_mode = XFER_PIO_0; 91 dev->xfer_mode = XFER_PIO_0;
93 dev->xfer_shift = ATA_SHIFT_PIO; 92 dev->xfer_shift = ATA_SHIFT_PIO;
94 dev->flags |= ATA_DFLAG_PIO; 93 dev->flags |= ATA_DFLAG_PIO;
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 6f6e7718b05c..43107e9415da 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1225,8 +1225,9 @@ static int piix_pci_device_resume(struct pci_dev *pdev)
1225 */ 1225 */
1226 rc = pci_reenable_device(pdev); 1226 rc = pci_reenable_device(pdev);
1227 if (rc) 1227 if (rc)
1228 dev_printk(KERN_ERR, &pdev->dev, "failed to enable " 1228 dev_err(&pdev->dev,
1229 "device after resume (%d)\n", rc); 1229 "failed to enable device after resume (%d)\n",
1230 rc);
1230 } else 1231 } else
1231 rc = ata_pci_device_do_resume(pdev); 1232 rc = ata_pci_device_do_resume(pdev);
1232 1233
@@ -1303,9 +1304,11 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
1303 no_piix_dma = 2; 1304 no_piix_dma = 2;
1304 } 1305 }
1305 if (no_piix_dma) 1306 if (no_piix_dma)
1306 dev_printk(KERN_WARNING, &ata_dev->dev, "450NX errata present, disabling IDE DMA.\n"); 1307 dev_warn(&ata_dev->dev,
1307 if (no_piix_dma == 2) 1308 "450NX errata present, disabling IDE DMA%s\n",
1308 dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n"); 1309 no_piix_dma == 2 ? " - a BIOS update may resolve this"
1310 : "");
1311
1309 return no_piix_dma; 1312 return no_piix_dma;
1310} 1313}
1311 1314
@@ -1338,37 +1341,36 @@ static const int *__devinit piix_init_sata_map(struct pci_dev *pdev,
1338 1341
1339 map = map_db->map[map_value & map_db->mask]; 1342 map = map_db->map[map_value & map_db->mask];
1340 1343
1341 dev_printk(KERN_INFO, &pdev->dev, "MAP ["); 1344 dev_info(&pdev->dev, "MAP [");
1342 for (i = 0; i < 4; i++) { 1345 for (i = 0; i < 4; i++) {
1343 switch (map[i]) { 1346 switch (map[i]) {
1344 case RV: 1347 case RV:
1345 invalid_map = 1; 1348 invalid_map = 1;
1346 printk(" XX"); 1349 pr_cont(" XX");
1347 break; 1350 break;
1348 1351
1349 case NA: 1352 case NA:
1350 printk(" --"); 1353 pr_cont(" --");
1351 break; 1354 break;
1352 1355
1353 case IDE: 1356 case IDE:
1354 WARN_ON((i & 1) || map[i + 1] != IDE); 1357 WARN_ON((i & 1) || map[i + 1] != IDE);
1355 pinfo[i / 2] = piix_port_info[ich_pata_100]; 1358 pinfo[i / 2] = piix_port_info[ich_pata_100];
1356 i++; 1359 i++;
1357 printk(" IDE IDE"); 1360 pr_cont(" IDE IDE");
1358 break; 1361 break;
1359 1362
1360 default: 1363 default:
1361 printk(" P%d", map[i]); 1364 pr_cont(" P%d", map[i]);
1362 if (i & 1) 1365 if (i & 1)
1363 pinfo[i / 2].flags |= ATA_FLAG_SLAVE_POSS; 1366 pinfo[i / 2].flags |= ATA_FLAG_SLAVE_POSS;
1364 break; 1367 break;
1365 } 1368 }
1366 } 1369 }
1367 printk(" ]\n"); 1370 pr_cont(" ]\n");
1368 1371
1369 if (invalid_map) 1372 if (invalid_map)
1370 dev_printk(KERN_ERR, &pdev->dev, 1373 dev_err(&pdev->dev, "invalid MAP value %u\n", map_value);
1371 "invalid MAP value %u\n", map_value);
1372 1374
1373 return map; 1375 return map;
1374} 1376}
@@ -1398,8 +1400,8 @@ static bool piix_no_sidpr(struct ata_host *host)
1398 if (pdev->vendor == PCI_VENDOR_ID_INTEL && pdev->device == 0x2920 && 1400 if (pdev->vendor == PCI_VENDOR_ID_INTEL && pdev->device == 0x2920 &&
1399 pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG && 1401 pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG &&
1400 pdev->subsystem_device == 0xb049) { 1402 pdev->subsystem_device == 0xb049) {
1401 dev_printk(KERN_WARNING, host->dev, 1403 dev_warn(host->dev,
1402 "Samsung DB-P70 detected, disabling SIDPR\n"); 1404 "Samsung DB-P70 detected, disabling SIDPR\n");
1403 return true; 1405 return true;
1404 } 1406 }
1405 1407
@@ -1451,8 +1453,8 @@ static int __devinit piix_init_sidpr(struct ata_host *host)
1451 piix_sidpr_scr_read(link0, SCR_CONTROL, &scontrol); 1453 piix_sidpr_scr_read(link0, SCR_CONTROL, &scontrol);
1452 1454
1453 if ((scontrol & 0xf00) != 0x300) { 1455 if ((scontrol & 0xf00) != 0x300) {
1454 dev_printk(KERN_INFO, host->dev, "SCR access via " 1456 dev_info(host->dev,
1455 "SIDPR is available but doesn't work\n"); 1457 "SCR access via SIDPR is available but doesn't work\n");
1456 return 0; 1458 return 0;
1457 } 1459 }
1458 } 1460 }
@@ -1501,8 +1503,7 @@ static void piix_iocfg_bit18_quirk(struct ata_host *host)
1501 * affected systems. 1503 * affected systems.
1502 */ 1504 */
1503 if (hpriv->saved_iocfg & (1 << 18)) { 1505 if (hpriv->saved_iocfg & (1 << 18)) {
1504 dev_printk(KERN_INFO, &pdev->dev, 1506 dev_info(&pdev->dev, "applying IOCFG bit18 quirk\n");
1505 "applying IOCFG bit18 quirk\n");
1506 pci_write_config_dword(pdev, PIIX_IOCFG, 1507 pci_write_config_dword(pdev, PIIX_IOCFG,
1507 hpriv->saved_iocfg & ~(1 << 18)); 1508 hpriv->saved_iocfg & ~(1 << 18));
1508 } 1509 }
@@ -1561,7 +1562,6 @@ static bool piix_broken_system_poweroff(struct pci_dev *pdev)
1561static int __devinit piix_init_one(struct pci_dev *pdev, 1562static int __devinit piix_init_one(struct pci_dev *pdev,
1562 const struct pci_device_id *ent) 1563 const struct pci_device_id *ent)
1563{ 1564{
1564 static int printed_version;
1565 struct device *dev = &pdev->dev; 1565 struct device *dev = &pdev->dev;
1566 struct ata_port_info port_info[2]; 1566 struct ata_port_info port_info[2];
1567 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; 1567 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
@@ -1571,9 +1571,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1571 struct piix_host_priv *hpriv; 1571 struct piix_host_priv *hpriv;
1572 int rc; 1572 int rc;
1573 1573
1574 if (!printed_version++) 1574 ata_print_version_once(&pdev->dev, DRV_VERSION);
1575 dev_printk(KERN_DEBUG, &pdev->dev,
1576 "version " DRV_VERSION "\n");
1577 1575
1578 /* no hotplugging support for later devices (FIXME) */ 1576 /* no hotplugging support for later devices (FIXME) */
1579 if (!in_module_init && ent->driver_data >= ich5_sata) 1577 if (!in_module_init && ent->driver_data >= ich5_sata)
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 41223c7f0206..3c92dbd751e0 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -82,6 +82,8 @@ static void ahci_pmp_attach(struct ata_port *ap);
82static void ahci_pmp_detach(struct ata_port *ap); 82static void ahci_pmp_detach(struct ata_port *ap);
83static int ahci_softreset(struct ata_link *link, unsigned int *class, 83static int ahci_softreset(struct ata_link *link, unsigned int *class,
84 unsigned long deadline); 84 unsigned long deadline);
85static int ahci_pmp_retry_softreset(struct ata_link *link, unsigned int *class,
86 unsigned long deadline);
85static int ahci_hardreset(struct ata_link *link, unsigned int *class, 87static int ahci_hardreset(struct ata_link *link, unsigned int *class,
86 unsigned long deadline); 88 unsigned long deadline);
87static void ahci_postreset(struct ata_link *link, unsigned int *class); 89static void ahci_postreset(struct ata_link *link, unsigned int *class);
@@ -178,6 +180,12 @@ struct ata_port_operations ahci_ops = {
178}; 180};
179EXPORT_SYMBOL_GPL(ahci_ops); 181EXPORT_SYMBOL_GPL(ahci_ops);
180 182
183struct ata_port_operations ahci_pmp_retry_srst_ops = {
184 .inherits = &ahci_ops,
185 .softreset = ahci_pmp_retry_softreset,
186};
187EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops);
188
181int ahci_em_messages = 1; 189int ahci_em_messages = 1;
182EXPORT_SYMBOL_GPL(ahci_em_messages); 190EXPORT_SYMBOL_GPL(ahci_em_messages);
183module_param(ahci_em_messages, int, 0444); 191module_param(ahci_em_messages, int, 0444);
@@ -286,10 +294,10 @@ static ssize_t ahci_read_em_buffer(struct device *dev,
286 /* the count should not be larger than PAGE_SIZE */ 294 /* the count should not be larger than PAGE_SIZE */
287 if (count > PAGE_SIZE) { 295 if (count > PAGE_SIZE) {
288 if (printk_ratelimit()) 296 if (printk_ratelimit())
289 ata_port_printk(ap, KERN_WARNING, 297 ata_port_warn(ap,
290 "EM read buffer size too large: " 298 "EM read buffer size too large: "
291 "buffer size %u, page size %lu\n", 299 "buffer size %u, page size %lu\n",
292 hpriv->em_buf_sz, PAGE_SIZE); 300 hpriv->em_buf_sz, PAGE_SIZE);
293 count = PAGE_SIZE; 301 count = PAGE_SIZE;
294 } 302 }
295 303
@@ -410,51 +418,46 @@ void ahci_save_initial_config(struct device *dev,
410 418
411 /* some chips have errata preventing 64bit use */ 419 /* some chips have errata preventing 64bit use */
412 if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) { 420 if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) {
413 dev_printk(KERN_INFO, dev, 421 dev_info(dev, "controller can't do 64bit DMA, forcing 32bit\n");
414 "controller can't do 64bit DMA, forcing 32bit\n");
415 cap &= ~HOST_CAP_64; 422 cap &= ~HOST_CAP_64;
416 } 423 }
417 424
418 if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) { 425 if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) {
419 dev_printk(KERN_INFO, dev, 426 dev_info(dev, "controller can't do NCQ, turning off CAP_NCQ\n");
420 "controller can't do NCQ, turning off CAP_NCQ\n");
421 cap &= ~HOST_CAP_NCQ; 427 cap &= ~HOST_CAP_NCQ;
422 } 428 }
423 429
424 if (!(cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_YES_NCQ)) { 430 if (!(cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_YES_NCQ)) {
425 dev_printk(KERN_INFO, dev, 431 dev_info(dev, "controller can do NCQ, turning on CAP_NCQ\n");
426 "controller can do NCQ, turning on CAP_NCQ\n");
427 cap |= HOST_CAP_NCQ; 432 cap |= HOST_CAP_NCQ;
428 } 433 }
429 434
430 if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { 435 if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
431 dev_printk(KERN_INFO, dev, 436 dev_info(dev, "controller can't do PMP, turning off CAP_PMP\n");
432 "controller can't do PMP, turning off CAP_PMP\n");
433 cap &= ~HOST_CAP_PMP; 437 cap &= ~HOST_CAP_PMP;
434 } 438 }
435 439
436 if ((cap & HOST_CAP_SNTF) && (hpriv->flags & AHCI_HFLAG_NO_SNTF)) { 440 if ((cap & HOST_CAP_SNTF) && (hpriv->flags & AHCI_HFLAG_NO_SNTF)) {
437 dev_printk(KERN_INFO, dev, 441 dev_info(dev,
438 "controller can't do SNTF, turning off CAP_SNTF\n"); 442 "controller can't do SNTF, turning off CAP_SNTF\n");
439 cap &= ~HOST_CAP_SNTF; 443 cap &= ~HOST_CAP_SNTF;
440 } 444 }
441 445
442 if (!(cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_YES_FBS)) { 446 if (!(cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_YES_FBS)) {
443 dev_printk(KERN_INFO, dev, 447 dev_info(dev, "controller can do FBS, turning on CAP_FBS\n");
444 "controller can do FBS, turning on CAP_FBS\n");
445 cap |= HOST_CAP_FBS; 448 cap |= HOST_CAP_FBS;
446 } 449 }
447 450
448 if (force_port_map && port_map != force_port_map) { 451 if (force_port_map && port_map != force_port_map) {
449 dev_printk(KERN_INFO, dev, "forcing port_map 0x%x -> 0x%x\n", 452 dev_info(dev, "forcing port_map 0x%x -> 0x%x\n",
450 port_map, force_port_map); 453 port_map, force_port_map);
451 port_map = force_port_map; 454 port_map = force_port_map;
452 } 455 }
453 456
454 if (mask_port_map) { 457 if (mask_port_map) {
455 dev_printk(KERN_WARNING, dev, "masking port_map 0x%x -> 0x%x\n", 458 dev_warn(dev, "masking port_map 0x%x -> 0x%x\n",
456 port_map, 459 port_map,
457 port_map & mask_port_map); 460 port_map & mask_port_map);
458 port_map &= mask_port_map; 461 port_map &= mask_port_map;
459 } 462 }
460 463
@@ -470,10 +473,9 @@ void ahci_save_initial_config(struct device *dev,
470 * port_map and let it be generated from n_ports. 473 * port_map and let it be generated from n_ports.
471 */ 474 */
472 if (map_ports > ahci_nr_ports(cap)) { 475 if (map_ports > ahci_nr_ports(cap)) {
473 dev_printk(KERN_WARNING, dev, 476 dev_warn(dev,
474 "implemented port map (0x%x) contains more " 477 "implemented port map (0x%x) contains more ports than nr_ports (%u), using nr_ports\n",
475 "ports than nr_ports (%u), using nr_ports\n", 478 port_map, ahci_nr_ports(cap));
476 port_map, ahci_nr_ports(cap));
477 port_map = 0; 479 port_map = 0;
478 } 480 }
479 } 481 }
@@ -481,8 +483,7 @@ void ahci_save_initial_config(struct device *dev,
481 /* fabricate port_map from cap.nr_ports */ 483 /* fabricate port_map from cap.nr_ports */
482 if (!port_map) { 484 if (!port_map) {
483 port_map = (1 << ahci_nr_ports(cap)) - 1; 485 port_map = (1 << ahci_nr_ports(cap)) - 1;
484 dev_printk(KERN_WARNING, dev, 486 dev_warn(dev, "forcing PORTS_IMPL to 0x%x\n", port_map);
485 "forcing PORTS_IMPL to 0x%x\n", port_map);
486 487
487 /* write the fixed up value to the PI register */ 488 /* write the fixed up value to the PI register */
488 hpriv->saved_port_map = port_map; 489 hpriv->saved_port_map = port_map;
@@ -822,8 +823,8 @@ int ahci_reset_controller(struct ata_host *host)
822 HOST_RESET, 10, 1000); 823 HOST_RESET, 10, 1000);
823 824
824 if (tmp & HOST_RESET) { 825 if (tmp & HOST_RESET) {
825 dev_printk(KERN_ERR, host->dev, 826 dev_err(host->dev, "controller reset failed (0x%x)\n",
826 "controller reset failed (0x%x)\n", tmp); 827 tmp);
827 return -EIO; 828 return -EIO;
828 } 829 }
829 830
@@ -835,8 +836,7 @@ int ahci_reset_controller(struct ata_host *host)
835 */ 836 */
836 ahci_restore_initial_config(host); 837 ahci_restore_initial_config(host);
837 } else 838 } else
838 dev_printk(KERN_INFO, host->dev, 839 dev_info(host->dev, "skipping global host reset\n");
839 "skipping global host reset\n");
840 840
841 return 0; 841 return 0;
842} 842}
@@ -1132,8 +1132,8 @@ static void ahci_dev_config(struct ata_device *dev)
1132 1132
1133 if (hpriv->flags & AHCI_HFLAG_SECT255) { 1133 if (hpriv->flags & AHCI_HFLAG_SECT255) {
1134 dev->max_sectors = 255; 1134 dev->max_sectors = 255;
1135 ata_dev_printk(dev, KERN_INFO, 1135 ata_dev_info(dev,
1136 "SB600 AHCI: limiting to 255 sectors per cmd\n"); 1136 "SB600 AHCI: limiting to 255 sectors per cmd\n");
1137 } 1137 }
1138} 1138}
1139 1139
@@ -1257,8 +1257,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1257 /* prepare for SRST (AHCI-1.1 10.4.1) */ 1257 /* prepare for SRST (AHCI-1.1 10.4.1) */
1258 rc = ahci_kick_engine(ap); 1258 rc = ahci_kick_engine(ap);
1259 if (rc && rc != -EOPNOTSUPP) 1259 if (rc && rc != -EOPNOTSUPP)
1260 ata_link_printk(link, KERN_WARNING, 1260 ata_link_warn(link, "failed to reset engine (errno=%d)\n", rc);
1261 "failed to reset engine (errno=%d)\n", rc);
1262 1261
1263 ata_tf_init(link->device, &tf); 1262 ata_tf_init(link->device, &tf);
1264 1263
@@ -1291,8 +1290,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1291 * be trusted. Treat device readiness timeout as link 1290 * be trusted. Treat device readiness timeout as link
1292 * offline. 1291 * offline.
1293 */ 1292 */
1294 ata_link_printk(link, KERN_INFO, 1293 ata_link_info(link, "device not ready, treating as offline\n");
1295 "device not ready, treating as offline\n");
1296 *class = ATA_DEV_NONE; 1294 *class = ATA_DEV_NONE;
1297 } else if (rc) { 1295 } else if (rc) {
1298 /* link occupied, -ENODEV too is an error */ 1296 /* link occupied, -ENODEV too is an error */
@@ -1305,7 +1303,7 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1305 return 0; 1303 return 0;
1306 1304
1307 fail: 1305 fail:
1308 ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason); 1306 ata_link_err(link, "softreset failed (%s)\n", reason);
1309 return rc; 1307 return rc;
1310} 1308}
1311 1309
@@ -1329,6 +1327,55 @@ static int ahci_softreset(struct ata_link *link, unsigned int *class,
1329} 1327}
1330EXPORT_SYMBOL_GPL(ahci_do_softreset); 1328EXPORT_SYMBOL_GPL(ahci_do_softreset);
1331 1329
1330static int ahci_bad_pmp_check_ready(struct ata_link *link)
1331{
1332 void __iomem *port_mmio = ahci_port_base(link->ap);
1333 u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
1334 u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
1335
1336 /*
1337 * There is no need to check TFDATA if BAD PMP is found due to HW bug,
1338 * which can save timeout delay.
1339 */
1340 if (irq_status & PORT_IRQ_BAD_PMP)
1341 return -EIO;
1342
1343 return ata_check_ready(status);
1344}
1345
1346int ahci_pmp_retry_softreset(struct ata_link *link, unsigned int *class,
1347 unsigned long deadline)
1348{
1349 struct ata_port *ap = link->ap;
1350 void __iomem *port_mmio = ahci_port_base(ap);
1351 int pmp = sata_srst_pmp(link);
1352 int rc;
1353 u32 irq_sts;
1354
1355 DPRINTK("ENTER\n");
1356
1357 rc = ahci_do_softreset(link, class, pmp, deadline,
1358 ahci_bad_pmp_check_ready);
1359
1360 /*
1361 * Soft reset fails with IPMS set when PMP is enabled but
1362 * SATA HDD/ODD is connected to SATA port, do soft reset
1363 * again to port 0.
1364 */
1365 if (rc == -EIO) {
1366 irq_sts = readl(port_mmio + PORT_IRQ_STAT);
1367 if (irq_sts & PORT_IRQ_BAD_PMP) {
1368 ata_link_printk(link, KERN_WARNING,
1369 "applying PMP SRST workaround "
1370 "and retrying\n");
1371 rc = ahci_do_softreset(link, class, 0, deadline,
1372 ahci_check_ready);
1373 }
1374 }
1375
1376 return rc;
1377}
1378
1332static int ahci_hardreset(struct ata_link *link, unsigned int *class, 1379static int ahci_hardreset(struct ata_link *link, unsigned int *class,
1333 unsigned long deadline) 1380 unsigned long deadline)
1334{ 1381{
@@ -1474,8 +1521,7 @@ static void ahci_fbs_dec_intr(struct ata_port *ap)
1474 } 1521 }
1475 1522
1476 if (fbs & PORT_FBS_DEC) 1523 if (fbs & PORT_FBS_DEC)
1477 dev_printk(KERN_ERR, ap->host->dev, 1524 dev_err(ap->host->dev, "failed to clear device error\n");
1478 "failed to clear device error\n");
1479} 1525}
1480 1526
1481static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) 1527static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
@@ -1713,8 +1759,8 @@ irqreturn_t ahci_interrupt(int irq, void *dev_instance)
1713 } else { 1759 } else {
1714 VPRINTK("port %u (no irq)\n", i); 1760 VPRINTK("port %u (no irq)\n", i);
1715 if (ata_ratelimit()) 1761 if (ata_ratelimit())
1716 dev_printk(KERN_WARNING, host->dev, 1762 dev_warn(host->dev,
1717 "interrupt on disabled port %u\n", i); 1763 "interrupt on disabled port %u\n", i);
1718 } 1764 }
1719 1765
1720 handled = 1; 1766 handled = 1;
@@ -1865,11 +1911,11 @@ static void ahci_enable_fbs(struct ata_port *ap)
1865 writel(fbs | PORT_FBS_EN, port_mmio + PORT_FBS); 1911 writel(fbs | PORT_FBS_EN, port_mmio + PORT_FBS);
1866 fbs = readl(port_mmio + PORT_FBS); 1912 fbs = readl(port_mmio + PORT_FBS);
1867 if (fbs & PORT_FBS_EN) { 1913 if (fbs & PORT_FBS_EN) {
1868 dev_printk(KERN_INFO, ap->host->dev, "FBS is enabled.\n"); 1914 dev_info(ap->host->dev, "FBS is enabled\n");
1869 pp->fbs_enabled = true; 1915 pp->fbs_enabled = true;
1870 pp->fbs_last_dev = -1; /* initialization */ 1916 pp->fbs_last_dev = -1; /* initialization */
1871 } else 1917 } else
1872 dev_printk(KERN_ERR, ap->host->dev, "Failed to enable FBS\n"); 1918 dev_err(ap->host->dev, "Failed to enable FBS\n");
1873 1919
1874 ahci_start_engine(ap); 1920 ahci_start_engine(ap);
1875} 1921}
@@ -1897,9 +1943,9 @@ static void ahci_disable_fbs(struct ata_port *ap)
1897 writel(fbs & ~PORT_FBS_EN, port_mmio + PORT_FBS); 1943 writel(fbs & ~PORT_FBS_EN, port_mmio + PORT_FBS);
1898 fbs = readl(port_mmio + PORT_FBS); 1944 fbs = readl(port_mmio + PORT_FBS);
1899 if (fbs & PORT_FBS_EN) 1945 if (fbs & PORT_FBS_EN)
1900 dev_printk(KERN_ERR, ap->host->dev, "Failed to disable FBS\n"); 1946 dev_err(ap->host->dev, "Failed to disable FBS\n");
1901 else { 1947 else {
1902 dev_printk(KERN_INFO, ap->host->dev, "FBS is disabled.\n"); 1948 dev_info(ap->host->dev, "FBS is disabled\n");
1903 pp->fbs_enabled = false; 1949 pp->fbs_enabled = false;
1904 } 1950 }
1905 1951
@@ -1975,7 +2021,7 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
1975 if (rc == 0) 2021 if (rc == 0)
1976 ahci_power_down(ap); 2022 ahci_power_down(ap);
1977 else { 2023 else {
1978 ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc); 2024 ata_port_err(ap, "%s (%d)\n", emsg, rc);
1979 ahci_start_port(ap); 2025 ahci_start_port(ap);
1980 } 2026 }
1981 2027
@@ -2003,14 +2049,12 @@ static int ahci_port_start(struct ata_port *ap)
2003 if (cmd & PORT_CMD_FBSCP) 2049 if (cmd & PORT_CMD_FBSCP)
2004 pp->fbs_supported = true; 2050 pp->fbs_supported = true;
2005 else if (hpriv->flags & AHCI_HFLAG_YES_FBS) { 2051 else if (hpriv->flags & AHCI_HFLAG_YES_FBS) {
2006 dev_printk(KERN_INFO, dev, 2052 dev_info(dev, "port %d can do FBS, forcing FBSCP\n",
2007 "port %d can do FBS, forcing FBSCP\n", 2053 ap->port_no);
2008 ap->port_no);
2009 pp->fbs_supported = true; 2054 pp->fbs_supported = true;
2010 } else 2055 } else
2011 dev_printk(KERN_WARNING, dev, 2056 dev_warn(dev, "port %d is not capable of FBS\n",
2012 "port %d is not capable of FBS\n", 2057 ap->port_no);
2013 ap->port_no);
2014 } 2058 }
2015 2059
2016 if (pp->fbs_supported) { 2060 if (pp->fbs_supported) {
@@ -2072,7 +2116,7 @@ static void ahci_port_stop(struct ata_port *ap)
2072 /* de-initialize port */ 2116 /* de-initialize port */
2073 rc = ahci_deinit_port(ap, &emsg); 2117 rc = ahci_deinit_port(ap, &emsg);
2074 if (rc) 2118 if (rc)
2075 ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc); 2119 ata_port_warn(ap, "%s (%d)\n", emsg, rc);
2076} 2120}
2077 2121
2078void ahci_print_info(struct ata_host *host, const char *scc_s) 2122void ahci_print_info(struct ata_host *host, const char *scc_s)
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index a791b8ce6294..e0a5b555cee1 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -332,25 +332,22 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
332 332
333 rc = -EINVAL; 333 rc = -EINVAL;
334 if (ACPI_FAILURE(status)) { 334 if (ACPI_FAILURE(status)) {
335 ata_port_printk(ap, KERN_ERR, 335 ata_port_err(ap, "ACPI get timing mode failed (AE 0x%x)\n",
336 "ACPI get timing mode failed (AE 0x%x)\n", 336 status);
337 status);
338 goto out_free; 337 goto out_free;
339 } 338 }
340 339
341 out_obj = output.pointer; 340 out_obj = output.pointer;
342 if (out_obj->type != ACPI_TYPE_BUFFER) { 341 if (out_obj->type != ACPI_TYPE_BUFFER) {
343 ata_port_printk(ap, KERN_WARNING, 342 ata_port_warn(ap, "_GTM returned unexpected object type 0x%x\n",
344 "_GTM returned unexpected object type 0x%x\n", 343 out_obj->type);
345 out_obj->type);
346 344
347 goto out_free; 345 goto out_free;
348 } 346 }
349 347
350 if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) { 348 if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) {
351 ata_port_printk(ap, KERN_ERR, 349 ata_port_err(ap, "_GTM returned invalid length %d\n",
352 "_GTM returned invalid length %d\n", 350 out_obj->buffer.length);
353 out_obj->buffer.length);
354 goto out_free; 351 goto out_free;
355 } 352 }
356 353
@@ -402,8 +399,8 @@ int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm)
402 if (status == AE_NOT_FOUND) 399 if (status == AE_NOT_FOUND)
403 return -ENOENT; 400 return -ENOENT;
404 if (ACPI_FAILURE(status)) { 401 if (ACPI_FAILURE(status)) {
405 ata_port_printk(ap, KERN_ERR, 402 ata_port_err(ap, "ACPI set timing mode failed (status=0x%x)\n",
406 "ACPI set timing mode failed (status=0x%x)\n", status); 403 status);
407 return -EINVAL; 404 return -EINVAL;
408 } 405 }
409 return 0; 406 return 0;
@@ -450,8 +447,8 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
450 output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ 447 output.pointer = NULL; /* ACPI-CA sets this; save/free it later */
451 448
452 if (ata_msg_probe(ap)) 449 if (ata_msg_probe(ap))
453 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 450 ata_dev_dbg(dev, "%s: ENTER: port#: %d\n",
454 __func__, ap->port_no); 451 __func__, ap->port_no);
455 452
456 /* _GTF has no input parameters */ 453 /* _GTF has no input parameters */
457 status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); 454 status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output);
@@ -459,9 +456,8 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
459 456
460 if (ACPI_FAILURE(status)) { 457 if (ACPI_FAILURE(status)) {
461 if (status != AE_NOT_FOUND) { 458 if (status != AE_NOT_FOUND) {
462 ata_dev_printk(dev, KERN_WARNING, 459 ata_dev_warn(dev, "_GTF evaluation failed (AE 0x%x)\n",
463 "_GTF evaluation failed (AE 0x%x)\n", 460 status);
464 status);
465 rc = -EINVAL; 461 rc = -EINVAL;
466 } 462 }
467 goto out_free; 463 goto out_free;
@@ -469,27 +465,24 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
469 465
470 if (!output.length || !output.pointer) { 466 if (!output.length || !output.pointer) {
471 if (ata_msg_probe(ap)) 467 if (ata_msg_probe(ap))
472 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " 468 ata_dev_dbg(dev, "%s: Run _GTF: length or ptr is NULL (0x%llx, 0x%p)\n",
473 "length or ptr is NULL (0x%llx, 0x%p)\n", 469 __func__,
474 __func__, 470 (unsigned long long)output.length,
475 (unsigned long long)output.length, 471 output.pointer);
476 output.pointer);
477 rc = -EINVAL; 472 rc = -EINVAL;
478 goto out_free; 473 goto out_free;
479 } 474 }
480 475
481 if (out_obj->type != ACPI_TYPE_BUFFER) { 476 if (out_obj->type != ACPI_TYPE_BUFFER) {
482 ata_dev_printk(dev, KERN_WARNING, 477 ata_dev_warn(dev, "_GTF unexpected object type 0x%x\n",
483 "_GTF unexpected object type 0x%x\n", 478 out_obj->type);
484 out_obj->type);
485 rc = -EINVAL; 479 rc = -EINVAL;
486 goto out_free; 480 goto out_free;
487 } 481 }
488 482
489 if (out_obj->buffer.length % REGS_PER_GTF) { 483 if (out_obj->buffer.length % REGS_PER_GTF) {
490 ata_dev_printk(dev, KERN_WARNING, 484 ata_dev_warn(dev, "unexpected _GTF length (%d)\n",
491 "unexpected _GTF length (%d)\n", 485 out_obj->buffer.length);
492 out_obj->buffer.length);
493 rc = -EINVAL; 486 rc = -EINVAL;
494 goto out_free; 487 goto out_free;
495 } 488 }
@@ -499,9 +492,8 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
499 if (gtf) { 492 if (gtf) {
500 *gtf = (void *)out_obj->buffer.pointer; 493 *gtf = (void *)out_obj->buffer.pointer;
501 if (ata_msg_probe(ap)) 494 if (ata_msg_probe(ap))
502 ata_dev_printk(dev, KERN_DEBUG, 495 ata_dev_dbg(dev, "%s: returning gtf=%p, gtf_count=%d\n",
503 "%s: returning gtf=%p, gtf_count=%d\n", 496 __func__, *gtf, rc);
504 __func__, *gtf, rc);
505 } 497 }
506 return rc; 498 return rc;
507 499
@@ -811,8 +803,8 @@ static int ata_acpi_push_id(struct ata_device *dev)
811 union acpi_object in_params[1]; 803 union acpi_object in_params[1];
812 804
813 if (ata_msg_probe(ap)) 805 if (ata_msg_probe(ap))
814 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", 806 ata_dev_dbg(dev, "%s: ix = %d, port#: %d\n",
815 __func__, dev->devno, ap->port_no); 807 __func__, dev->devno, ap->port_no);
816 808
817 /* Give the drive Identify data to the drive via the _SDD method */ 809 /* Give the drive Identify data to the drive via the _SDD method */
818 /* _SDD: set up input parameters */ 810 /* _SDD: set up input parameters */
@@ -832,8 +824,7 @@ static int ata_acpi_push_id(struct ata_device *dev)
832 return -ENOENT; 824 return -ENOENT;
833 825
834 if (ACPI_FAILURE(status)) { 826 if (ACPI_FAILURE(status)) {
835 ata_dev_printk(dev, KERN_WARNING, 827 ata_dev_warn(dev, "ACPI _SDD failed (AE 0x%x)\n", status);
836 "ACPI _SDD failed (AE 0x%x)\n", status);
837 return -EIO; 828 return -EIO;
838 } 829 }
839 830
@@ -983,8 +974,8 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
983 if (nr_executed) { 974 if (nr_executed) {
984 rc = ata_dev_reread_id(dev, 0); 975 rc = ata_dev_reread_id(dev, 0);
985 if (rc < 0) { 976 if (rc < 0) {
986 ata_dev_printk(dev, KERN_ERR, "failed to IDENTIFY " 977 ata_dev_err(dev,
987 "after ACPI commands\n"); 978 "failed to IDENTIFY after ACPI commands\n");
988 return rc; 979 return rc;
989 } 980 }
990 } 981 }
@@ -1002,8 +993,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev)
1002 return rc; 993 return rc;
1003 } 994 }
1004 995
1005 ata_dev_printk(dev, KERN_WARNING, 996 ata_dev_warn(dev, "ACPI: failed the second time, disabled\n");
1006 "ACPI: failed the second time, disabled\n");
1007 dev->acpi_handle = NULL; 997 dev->acpi_handle = NULL;
1008 998
1009 /* We can safely continue if no _GTF command has been executed 999 /* We can safely continue if no _GTF command has been executed
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 000d03ae6653..4a3a5ae7bb45 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -335,8 +335,7 @@ void ata_force_cbl(struct ata_port *ap)
335 continue; 335 continue;
336 336
337 ap->cbl = fe->param.cbl; 337 ap->cbl = fe->param.cbl;
338 ata_port_printk(ap, KERN_NOTICE, 338 ata_port_notice(ap, "FORCE: cable set to %s\n", fe->param.name);
339 "FORCE: cable set to %s\n", fe->param.name);
340 return; 339 return;
341 } 340 }
342} 341}
@@ -378,8 +377,7 @@ static void ata_force_link_limits(struct ata_link *link)
378 /* only honor the first spd limit */ 377 /* only honor the first spd limit */
379 if (!did_spd && fe->param.spd_limit) { 378 if (!did_spd && fe->param.spd_limit) {
380 link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1; 379 link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1;
381 ata_link_printk(link, KERN_NOTICE, 380 ata_link_notice(link, "FORCE: PHY spd limit set to %s\n",
382 "FORCE: PHY spd limit set to %s\n",
383 fe->param.name); 381 fe->param.name);
384 did_spd = true; 382 did_spd = true;
385 } 383 }
@@ -387,7 +385,7 @@ static void ata_force_link_limits(struct ata_link *link)
387 /* let lflags stack */ 385 /* let lflags stack */
388 if (fe->param.lflags) { 386 if (fe->param.lflags) {
389 link->flags |= fe->param.lflags; 387 link->flags |= fe->param.lflags;
390 ata_link_printk(link, KERN_NOTICE, 388 ata_link_notice(link,
391 "FORCE: link flag 0x%x forced -> 0x%x\n", 389 "FORCE: link flag 0x%x forced -> 0x%x\n",
392 fe->param.lflags, link->flags); 390 fe->param.lflags, link->flags);
393 } 391 }
@@ -442,8 +440,8 @@ static void ata_force_xfermask(struct ata_device *dev)
442 dev->pio_mask = pio_mask; 440 dev->pio_mask = pio_mask;
443 } 441 }
444 442
445 ata_dev_printk(dev, KERN_NOTICE, 443 ata_dev_notice(dev, "FORCE: xfer_mask set to %s\n",
446 "FORCE: xfer_mask set to %s\n", fe->param.name); 444 fe->param.name);
447 return; 445 return;
448 } 446 }
449} 447}
@@ -486,8 +484,8 @@ static void ata_force_horkage(struct ata_device *dev)
486 dev->horkage |= fe->param.horkage_on; 484 dev->horkage |= fe->param.horkage_on;
487 dev->horkage &= ~fe->param.horkage_off; 485 dev->horkage &= ~fe->param.horkage_off;
488 486
489 ata_dev_printk(dev, KERN_NOTICE, 487 ata_dev_notice(dev, "FORCE: horkage modified (%s)\n",
490 "FORCE: horkage modified (%s)\n", fe->param.name); 488 fe->param.name);
491 } 489 }
492} 490}
493 491
@@ -711,8 +709,8 @@ u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
711 sect = tf->lbal; 709 sect = tf->lbal;
712 710
713 if (!sect) { 711 if (!sect) {
714 ata_dev_printk(dev, KERN_WARNING, "device reported " 712 ata_dev_warn(dev,
715 "invalid CHS sector 0\n"); 713 "device reported invalid CHS sector 0\n");
716 sect = 1; /* oh well */ 714 sect = 1; /* oh well */
717 } 715 }
718 716
@@ -1230,8 +1228,9 @@ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors)
1230 1228
1231 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1229 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1232 if (err_mask) { 1230 if (err_mask) {
1233 ata_dev_printk(dev, KERN_WARNING, "failed to read native " 1231 ata_dev_warn(dev,
1234 "max address (err_mask=0x%x)\n", err_mask); 1232 "failed to read native max address (err_mask=0x%x)\n",
1233 err_mask);
1235 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED)) 1234 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED))
1236 return -EACCES; 1235 return -EACCES;
1237 return -EIO; 1236 return -EIO;
@@ -1292,8 +1291,9 @@ static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors)
1292 1291
1293 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1292 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
1294 if (err_mask) { 1293 if (err_mask) {
1295 ata_dev_printk(dev, KERN_WARNING, "failed to set " 1294 ata_dev_warn(dev,
1296 "max address (err_mask=0x%x)\n", err_mask); 1295 "failed to set max address (err_mask=0x%x)\n",
1296 err_mask);
1297 if (err_mask == AC_ERR_DEV && 1297 if (err_mask == AC_ERR_DEV &&
1298 (tf.feature & (ATA_ABORTED | ATA_IDNF))) 1298 (tf.feature & (ATA_ABORTED | ATA_IDNF)))
1299 return -EACCES; 1299 return -EACCES;
@@ -1336,8 +1336,8 @@ static int ata_hpa_resize(struct ata_device *dev)
1336 * be unlocked, skip HPA resizing. 1336 * be unlocked, skip HPA resizing.
1337 */ 1337 */
1338 if (rc == -EACCES || !unlock_hpa) { 1338 if (rc == -EACCES || !unlock_hpa) {
1339 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1339 ata_dev_warn(dev,
1340 "broken, skipping HPA handling\n"); 1340 "HPA support seems broken, skipping HPA handling\n");
1341 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1341 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1342 1342
1343 /* we can continue if device aborted the command */ 1343 /* we can continue if device aborted the command */
@@ -1355,14 +1355,13 @@ static int ata_hpa_resize(struct ata_device *dev)
1355 return 0; 1355 return 0;
1356 1356
1357 if (native_sectors > sectors) 1357 if (native_sectors > sectors)
1358 ata_dev_printk(dev, KERN_INFO, 1358 ata_dev_info(dev,
1359 "HPA detected: current %llu, native %llu\n", 1359 "HPA detected: current %llu, native %llu\n",
1360 (unsigned long long)sectors, 1360 (unsigned long long)sectors,
1361 (unsigned long long)native_sectors); 1361 (unsigned long long)native_sectors);
1362 else if (native_sectors < sectors) 1362 else if (native_sectors < sectors)
1363 ata_dev_printk(dev, KERN_WARNING, 1363 ata_dev_warn(dev,
1364 "native sectors (%llu) is smaller than " 1364 "native sectors (%llu) is smaller than sectors (%llu)\n",
1365 "sectors (%llu)\n",
1366 (unsigned long long)native_sectors, 1365 (unsigned long long)native_sectors,
1367 (unsigned long long)sectors); 1366 (unsigned long long)sectors);
1368 return 0; 1367 return 0;
@@ -1372,10 +1371,10 @@ static int ata_hpa_resize(struct ata_device *dev)
1372 rc = ata_set_max_sectors(dev, native_sectors); 1371 rc = ata_set_max_sectors(dev, native_sectors);
1373 if (rc == -EACCES) { 1372 if (rc == -EACCES) {
1374 /* if device aborted the command, skip HPA resizing */ 1373 /* if device aborted the command, skip HPA resizing */
1375 ata_dev_printk(dev, KERN_WARNING, "device aborted resize " 1374 ata_dev_warn(dev,
1376 "(%llu -> %llu), skipping HPA handling\n", 1375 "device aborted resize (%llu -> %llu), skipping HPA handling\n",
1377 (unsigned long long)sectors, 1376 (unsigned long long)sectors,
1378 (unsigned long long)native_sectors); 1377 (unsigned long long)native_sectors);
1379 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1378 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1380 return 0; 1379 return 0;
1381 } else if (rc) 1380 } else if (rc)
@@ -1384,14 +1383,14 @@ static int ata_hpa_resize(struct ata_device *dev)
1384 /* re-read IDENTIFY data */ 1383 /* re-read IDENTIFY data */
1385 rc = ata_dev_reread_id(dev, 0); 1384 rc = ata_dev_reread_id(dev, 0);
1386 if (rc) { 1385 if (rc) {
1387 ata_dev_printk(dev, KERN_ERR, "failed to re-read IDENTIFY " 1386 ata_dev_err(dev,
1388 "data after HPA resizing\n"); 1387 "failed to re-read IDENTIFY data after HPA resizing\n");
1389 return rc; 1388 return rc;
1390 } 1389 }
1391 1390
1392 if (print_info) { 1391 if (print_info) {
1393 u64 new_sectors = ata_id_n_sectors(dev->id); 1392 u64 new_sectors = ata_id_n_sectors(dev->id);
1394 ata_dev_printk(dev, KERN_INFO, 1393 ata_dev_info(dev,
1395 "HPA unlocked: %llu -> %llu, native %llu\n", 1394 "HPA unlocked: %llu -> %llu, native %llu\n",
1396 (unsigned long long)sectors, 1395 (unsigned long long)sectors,
1397 (unsigned long long)new_sectors, 1396 (unsigned long long)new_sectors,
@@ -1655,8 +1654,8 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
1655 ata_qc_complete(qc); 1654 ata_qc_complete(qc);
1656 1655
1657 if (ata_msg_warn(ap)) 1656 if (ata_msg_warn(ap))
1658 ata_dev_printk(dev, KERN_WARNING, 1657 ata_dev_warn(dev, "qc timeout (cmd 0x%x)\n",
1659 "qc timeout (cmd 0x%x)\n", command); 1658 command);
1660 } 1659 }
1661 1660
1662 spin_unlock_irqrestore(ap->lock, flags); 1661 spin_unlock_irqrestore(ap->lock, flags);
@@ -1870,7 +1869,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1870 int rc; 1869 int rc;
1871 1870
1872 if (ata_msg_ctl(ap)) 1871 if (ata_msg_ctl(ap))
1873 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 1872 ata_dev_dbg(dev, "%s: ENTER\n", __func__);
1874 1873
1875retry: 1874retry:
1876 ata_tf_init(dev, &tf); 1875 ata_tf_init(dev, &tf);
@@ -1909,14 +1908,13 @@ retry:
1909 1908
1910 if (err_mask) { 1909 if (err_mask) {
1911 if (err_mask & AC_ERR_NODEV_HINT) { 1910 if (err_mask & AC_ERR_NODEV_HINT) {
1912 ata_dev_printk(dev, KERN_DEBUG, 1911 ata_dev_dbg(dev, "NODEV after polling detection\n");
1913 "NODEV after polling detection\n");
1914 return -ENOENT; 1912 return -ENOENT;
1915 } 1913 }
1916 1914
1917 if (is_semb) { 1915 if (is_semb) {
1918 ata_dev_printk(dev, KERN_INFO, "IDENTIFY failed on " 1916 ata_dev_info(dev,
1919 "device w/ SEMB sig, disabled\n"); 1917 "IDENTIFY failed on device w/ SEMB sig, disabled\n");
1920 /* SEMB is not supported yet */ 1918 /* SEMB is not supported yet */
1921 *p_class = ATA_DEV_SEMB_UNSUP; 1919 *p_class = ATA_DEV_SEMB_UNSUP;
1922 return 0; 1920 return 0;
@@ -1942,8 +1940,8 @@ retry:
1942 * both flavors of IDENTIFYs which happens 1940 * both flavors of IDENTIFYs which happens
1943 * sometimes with phantom devices. 1941 * sometimes with phantom devices.
1944 */ 1942 */
1945 ata_dev_printk(dev, KERN_DEBUG, 1943 ata_dev_dbg(dev,
1946 "both IDENTIFYs aborted, assuming NODEV\n"); 1944 "both IDENTIFYs aborted, assuming NODEV\n");
1947 return -ENOENT; 1945 return -ENOENT;
1948 } 1946 }
1949 1947
@@ -1953,9 +1951,9 @@ retry:
1953 } 1951 }
1954 1952
1955 if (dev->horkage & ATA_HORKAGE_DUMP_ID) { 1953 if (dev->horkage & ATA_HORKAGE_DUMP_ID) {
1956 ata_dev_printk(dev, KERN_DEBUG, "dumping IDENTIFY data, " 1954 ata_dev_dbg(dev, "dumping IDENTIFY data, "
1957 "class=%d may_fallback=%d tried_spinup=%d\n", 1955 "class=%d may_fallback=%d tried_spinup=%d\n",
1958 class, may_fallback, tried_spinup); 1956 class, may_fallback, tried_spinup);
1959 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 1957 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET,
1960 16, 2, id, ATA_ID_WORDS * sizeof(*id), true); 1958 16, 2, id, ATA_ID_WORDS * sizeof(*id), true);
1961 } 1959 }
@@ -2034,8 +2032,8 @@ retry:
2034 2032
2035 err_out: 2033 err_out:
2036 if (ata_msg_warn(ap)) 2034 if (ata_msg_warn(ap))
2037 ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY " 2035 ata_dev_warn(dev, "failed to IDENTIFY (%s, err_mask=0x%x)\n",
2038 "(%s, err_mask=0x%x)\n", reason, err_mask); 2036 reason, err_mask);
2039 return rc; 2037 return rc;
2040} 2038}
2041 2039
@@ -2065,9 +2063,8 @@ static int ata_do_link_spd_horkage(struct ata_device *dev)
2065 * guaranteed by setting sata_spd_limit to target_limit above. 2063 * guaranteed by setting sata_spd_limit to target_limit above.
2066 */ 2064 */
2067 if (plink->sata_spd > target) { 2065 if (plink->sata_spd > target) {
2068 ata_dev_printk(dev, KERN_INFO, 2066 ata_dev_info(dev, "applying link speed limit horkage to %s\n",
2069 "applying link speed limit horkage to %s\n", 2067 sata_spd_string(target));
2070 sata_spd_string(target));
2071 return -EAGAIN; 2068 return -EAGAIN;
2072 } 2069 }
2073 return 0; 2070 return 0;
@@ -2110,8 +2107,9 @@ static int ata_dev_config_ncq(struct ata_device *dev,
2110 err_mask = ata_dev_set_feature(dev, SETFEATURES_SATA_ENABLE, 2107 err_mask = ata_dev_set_feature(dev, SETFEATURES_SATA_ENABLE,
2111 SATA_FPDMA_AA); 2108 SATA_FPDMA_AA);
2112 if (err_mask) { 2109 if (err_mask) {
2113 ata_dev_printk(dev, KERN_ERR, "failed to enable AA" 2110 ata_dev_err(dev,
2114 "(error_mask=0x%x)\n", err_mask); 2111 "failed to enable AA (error_mask=0x%x)\n",
2112 err_mask);
2115 if (err_mask != AC_ERR_DEV) { 2113 if (err_mask != AC_ERR_DEV) {
2116 dev->horkage |= ATA_HORKAGE_BROKEN_FPDMA_AA; 2114 dev->horkage |= ATA_HORKAGE_BROKEN_FPDMA_AA;
2117 return -EIO; 2115 return -EIO;
@@ -2154,31 +2152,28 @@ int ata_dev_configure(struct ata_device *dev)
2154 int rc; 2152 int rc;
2155 2153
2156 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 2154 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
2157 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", 2155 ata_dev_info(dev, "%s: ENTER/EXIT -- nodev\n", __func__);
2158 __func__);
2159 return 0; 2156 return 0;
2160 } 2157 }
2161 2158
2162 if (ata_msg_probe(ap)) 2159 if (ata_msg_probe(ap))
2163 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__); 2160 ata_dev_dbg(dev, "%s: ENTER\n", __func__);
2164 2161
2165 /* set horkage */ 2162 /* set horkage */
2166 dev->horkage |= ata_dev_blacklisted(dev); 2163 dev->horkage |= ata_dev_blacklisted(dev);
2167 ata_force_horkage(dev); 2164 ata_force_horkage(dev);
2168 2165
2169 if (dev->horkage & ATA_HORKAGE_DISABLE) { 2166 if (dev->horkage & ATA_HORKAGE_DISABLE) {
2170 ata_dev_printk(dev, KERN_INFO, 2167 ata_dev_info(dev, "unsupported device, disabling\n");
2171 "unsupported device, disabling\n");
2172 ata_dev_disable(dev); 2168 ata_dev_disable(dev);
2173 return 0; 2169 return 0;
2174 } 2170 }
2175 2171
2176 if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) && 2172 if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) &&
2177 dev->class == ATA_DEV_ATAPI) { 2173 dev->class == ATA_DEV_ATAPI) {
2178 ata_dev_printk(dev, KERN_WARNING, 2174 ata_dev_warn(dev, "WARNING: ATAPI is %s, device ignored\n",
2179 "WARNING: ATAPI is %s, device ignored.\n", 2175 atapi_enabled ? "not supported with this driver"
2180 atapi_enabled ? "not supported with this driver" 2176 : "disabled");
2181 : "disabled");
2182 ata_dev_disable(dev); 2177 ata_dev_disable(dev);
2183 return 0; 2178 return 0;
2184 } 2179 }
@@ -2199,12 +2194,12 @@ int ata_dev_configure(struct ata_device *dev)
2199 2194
2200 /* print device capabilities */ 2195 /* print device capabilities */
2201 if (ata_msg_probe(ap)) 2196 if (ata_msg_probe(ap))
2202 ata_dev_printk(dev, KERN_DEBUG, 2197 ata_dev_dbg(dev,
2203 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " 2198 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x "
2204 "85:%04x 86:%04x 87:%04x 88:%04x\n", 2199 "85:%04x 86:%04x 87:%04x 88:%04x\n",
2205 __func__, 2200 __func__,
2206 id[49], id[82], id[83], id[84], 2201 id[49], id[82], id[83], id[84],
2207 id[85], id[86], id[87], id[88]); 2202 id[85], id[86], id[87], id[88]);
2208 2203
2209 /* initialize to-be-configured parameters */ 2204 /* initialize to-be-configured parameters */
2210 dev->flags &= ~ATA_DFLAG_CFG_MASK; 2205 dev->flags &= ~ATA_DFLAG_CFG_MASK;
@@ -2238,17 +2233,15 @@ int ata_dev_configure(struct ata_device *dev)
2238 if (ata_id_is_cfa(id)) { 2233 if (ata_id_is_cfa(id)) {
2239 /* CPRM may make this media unusable */ 2234 /* CPRM may make this media unusable */
2240 if (id[ATA_ID_CFA_KEY_MGMT] & 1) 2235 if (id[ATA_ID_CFA_KEY_MGMT] & 1)
2241 ata_dev_printk(dev, KERN_WARNING, 2236 ata_dev_warn(dev,
2242 "supports DRM functions and may " 2237 "supports DRM functions and may not be fully accessible\n");
2243 "not be fully accessible.\n");
2244 snprintf(revbuf, 7, "CFA"); 2238 snprintf(revbuf, 7, "CFA");
2245 } else { 2239 } else {
2246 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); 2240 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
2247 /* Warn the user if the device has TPM extensions */ 2241 /* Warn the user if the device has TPM extensions */
2248 if (ata_id_has_tpm(id)) 2242 if (ata_id_has_tpm(id))
2249 ata_dev_printk(dev, KERN_WARNING, 2243 ata_dev_warn(dev,
2250 "supports DRM functions and may " 2244 "supports DRM functions and may not be fully accessible\n");
2251 "not be fully accessible.\n");
2252 } 2245 }
2253 2246
2254 dev->n_sectors = ata_id_n_sectors(id); 2247 dev->n_sectors = ata_id_n_sectors(id);
@@ -2285,12 +2278,11 @@ int ata_dev_configure(struct ata_device *dev)
2285 2278
2286 /* print device info to dmesg */ 2279 /* print device info to dmesg */
2287 if (ata_msg_drv(ap) && print_info) { 2280 if (ata_msg_drv(ap) && print_info) {
2288 ata_dev_printk(dev, KERN_INFO, 2281 ata_dev_info(dev, "%s: %s, %s, max %s\n",
2289 "%s: %s, %s, max %s\n", 2282 revbuf, modelbuf, fwrevbuf,
2290 revbuf, modelbuf, fwrevbuf, 2283 ata_mode_string(xfer_mask));
2291 ata_mode_string(xfer_mask)); 2284 ata_dev_info(dev,
2292 ata_dev_printk(dev, KERN_INFO, 2285 "%llu sectors, multi %u: %s %s\n",
2293 "%Lu sectors, multi %u: %s %s\n",
2294 (unsigned long long)dev->n_sectors, 2286 (unsigned long long)dev->n_sectors,
2295 dev->multi_count, lba_desc, ncq_desc); 2287 dev->multi_count, lba_desc, ncq_desc);
2296 } 2288 }
@@ -2311,15 +2303,14 @@ int ata_dev_configure(struct ata_device *dev)
2311 2303
2312 /* print device info to dmesg */ 2304 /* print device info to dmesg */
2313 if (ata_msg_drv(ap) && print_info) { 2305 if (ata_msg_drv(ap) && print_info) {
2314 ata_dev_printk(dev, KERN_INFO, 2306 ata_dev_info(dev, "%s: %s, %s, max %s\n",
2315 "%s: %s, %s, max %s\n", 2307 revbuf, modelbuf, fwrevbuf,
2316 revbuf, modelbuf, fwrevbuf, 2308 ata_mode_string(xfer_mask));
2317 ata_mode_string(xfer_mask)); 2309 ata_dev_info(dev,
2318 ata_dev_printk(dev, KERN_INFO, 2310 "%llu sectors, multi %u, CHS %u/%u/%u\n",
2319 "%Lu sectors, multi %u, CHS %u/%u/%u\n", 2311 (unsigned long long)dev->n_sectors,
2320 (unsigned long long)dev->n_sectors, 2312 dev->multi_count, dev->cylinders,
2321 dev->multi_count, dev->cylinders, 2313 dev->heads, dev->sectors);
2322 dev->heads, dev->sectors);
2323 } 2314 }
2324 } 2315 }
2325 2316
@@ -2336,8 +2327,7 @@ int ata_dev_configure(struct ata_device *dev)
2336 rc = atapi_cdb_len(id); 2327 rc = atapi_cdb_len(id);
2337 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { 2328 if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
2338 if (ata_msg_warn(ap)) 2329 if (ata_msg_warn(ap))
2339 ata_dev_printk(dev, KERN_WARNING, 2330 ata_dev_warn(dev, "unsupported CDB len\n");
2340 "unsupported CDB len\n");
2341 rc = -EINVAL; 2331 rc = -EINVAL;
2342 goto err_out_nosup; 2332 goto err_out_nosup;
2343 } 2333 }
@@ -2358,9 +2348,9 @@ int ata_dev_configure(struct ata_device *dev)
2358 err_mask = ata_dev_set_feature(dev, 2348 err_mask = ata_dev_set_feature(dev,
2359 SETFEATURES_SATA_ENABLE, SATA_AN); 2349 SETFEATURES_SATA_ENABLE, SATA_AN);
2360 if (err_mask) 2350 if (err_mask)
2361 ata_dev_printk(dev, KERN_ERR, 2351 ata_dev_err(dev,
2362 "failed to enable ATAPI AN " 2352 "failed to enable ATAPI AN (err_mask=0x%x)\n",
2363 "(err_mask=0x%x)\n", err_mask); 2353 err_mask);
2364 else { 2354 else {
2365 dev->flags |= ATA_DFLAG_AN; 2355 dev->flags |= ATA_DFLAG_AN;
2366 atapi_an_string = ", ATAPI AN"; 2356 atapi_an_string = ", ATAPI AN";
@@ -2379,12 +2369,12 @@ int ata_dev_configure(struct ata_device *dev)
2379 2369
2380 /* print device info to dmesg */ 2370 /* print device info to dmesg */
2381 if (ata_msg_drv(ap) && print_info) 2371 if (ata_msg_drv(ap) && print_info)
2382 ata_dev_printk(dev, KERN_INFO, 2372 ata_dev_info(dev,
2383 "ATAPI: %s, %s, max %s%s%s%s\n", 2373 "ATAPI: %s, %s, max %s%s%s%s\n",
2384 modelbuf, fwrevbuf, 2374 modelbuf, fwrevbuf,
2385 ata_mode_string(xfer_mask), 2375 ata_mode_string(xfer_mask),
2386 cdb_intr_string, atapi_an_string, 2376 cdb_intr_string, atapi_an_string,
2387 dma_dir_string); 2377 dma_dir_string);
2388 } 2378 }
2389 2379
2390 /* determine max_sectors */ 2380 /* determine max_sectors */
@@ -2396,8 +2386,7 @@ int ata_dev_configure(struct ata_device *dev)
2396 200 sectors */ 2386 200 sectors */
2397 if (ata_dev_knobble(dev)) { 2387 if (ata_dev_knobble(dev)) {
2398 if (ata_msg_drv(ap) && print_info) 2388 if (ata_msg_drv(ap) && print_info)
2399 ata_dev_printk(dev, KERN_INFO, 2389 ata_dev_info(dev, "applying bridge limits\n");
2400 "applying bridge limits\n");
2401 dev->udma_mask &= ATA_UDMA5; 2390 dev->udma_mask &= ATA_UDMA5;
2402 dev->max_sectors = ATA_MAX_SECTORS; 2391 dev->max_sectors = ATA_MAX_SECTORS;
2403 } 2392 }
@@ -2423,26 +2412,23 @@ int ata_dev_configure(struct ata_device *dev)
2423 bugs */ 2412 bugs */
2424 2413
2425 if (print_info) { 2414 if (print_info) {
2426 ata_dev_printk(dev, KERN_WARNING, 2415 ata_dev_warn(dev,
2427"Drive reports diagnostics failure. This may indicate a drive\n"); 2416"Drive reports diagnostics failure. This may indicate a drive\n");
2428 ata_dev_printk(dev, KERN_WARNING, 2417 ata_dev_warn(dev,
2429"fault or invalid emulation. Contact drive vendor for information.\n"); 2418"fault or invalid emulation. Contact drive vendor for information.\n");
2430 } 2419 }
2431 } 2420 }
2432 2421
2433 if ((dev->horkage & ATA_HORKAGE_FIRMWARE_WARN) && print_info) { 2422 if ((dev->horkage & ATA_HORKAGE_FIRMWARE_WARN) && print_info) {
2434 ata_dev_printk(dev, KERN_WARNING, "WARNING: device requires " 2423 ata_dev_warn(dev, "WARNING: device requires firmware update to be fully functional\n");
2435 "firmware update to be fully functional.\n"); 2424 ata_dev_warn(dev, " contact the vendor or visit http://ata.wiki.kernel.org\n");
2436 ata_dev_printk(dev, KERN_WARNING, " contact the vendor "
2437 "or visit http://ata.wiki.kernel.org.\n");
2438 } 2425 }
2439 2426
2440 return 0; 2427 return 0;
2441 2428
2442err_out_nosup: 2429err_out_nosup:
2443 if (ata_msg_probe(ap)) 2430 if (ata_msg_probe(ap))
2444 ata_dev_printk(dev, KERN_DEBUG, 2431 ata_dev_dbg(dev, "%s: EXIT, err\n", __func__);
2445 "%s: EXIT, err\n", __func__);
2446 return rc; 2432 return rc;
2447} 2433}
2448 2434
@@ -2663,13 +2649,11 @@ static void sata_print_link_status(struct ata_link *link)
2663 2649
2664 if (ata_phys_link_online(link)) { 2650 if (ata_phys_link_online(link)) {
2665 tmp = (sstatus >> 4) & 0xf; 2651 tmp = (sstatus >> 4) & 0xf;
2666 ata_link_printk(link, KERN_INFO, 2652 ata_link_info(link, "SATA link up %s (SStatus %X SControl %X)\n",
2667 "SATA link up %s (SStatus %X SControl %X)\n", 2653 sata_spd_string(tmp), sstatus, scontrol);
2668 sata_spd_string(tmp), sstatus, scontrol);
2669 } else { 2654 } else {
2670 ata_link_printk(link, KERN_INFO, 2655 ata_link_info(link, "SATA link down (SStatus %X SControl %X)\n",
2671 "SATA link down (SStatus %X SControl %X)\n", 2656 sstatus, scontrol);
2672 sstatus, scontrol);
2673 } 2657 }
2674} 2658}
2675 2659
@@ -2758,8 +2742,8 @@ int sata_down_spd_limit(struct ata_link *link, u32 spd_limit)
2758 2742
2759 link->sata_spd_limit = mask; 2743 link->sata_spd_limit = mask;
2760 2744
2761 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n", 2745 ata_link_warn(link, "limiting SATA link speed to %s\n",
2762 sata_spd_string(fls(mask))); 2746 sata_spd_string(fls(mask)));
2763 2747
2764 return 0; 2748 return 0;
2765} 2749}
@@ -3136,8 +3120,7 @@ int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel)
3136 snprintf(buf, sizeof(buf), "%s", 3120 snprintf(buf, sizeof(buf), "%s",
3137 ata_mode_string(xfer_mask)); 3121 ata_mode_string(xfer_mask));
3138 3122
3139 ata_dev_printk(dev, KERN_WARNING, 3123 ata_dev_warn(dev, "limiting speed to %s\n", buf);
3140 "limiting speed to %s\n", buf);
3141 } 3124 }
3142 3125
3143 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, 3126 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask,
@@ -3164,9 +3147,9 @@ static int ata_dev_set_mode(struct ata_device *dev)
3164 dev_err_whine = " (SET_XFERMODE skipped)"; 3147 dev_err_whine = " (SET_XFERMODE skipped)";
3165 else { 3148 else {
3166 if (nosetxfer) 3149 if (nosetxfer)
3167 ata_dev_printk(dev, KERN_WARNING, 3150 ata_dev_warn(dev,
3168 "NOSETXFER but PATA detected - can't " 3151 "NOSETXFER but PATA detected - can't "
3169 "skip SETXFER, might malfunction\n"); 3152 "skip SETXFER, might malfunction\n");
3170 err_mask = ata_dev_set_xfermode(dev); 3153 err_mask = ata_dev_set_xfermode(dev);
3171 } 3154 }
3172 3155
@@ -3216,15 +3199,14 @@ static int ata_dev_set_mode(struct ata_device *dev)
3216 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", 3199 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
3217 dev->xfer_shift, (int)dev->xfer_mode); 3200 dev->xfer_shift, (int)dev->xfer_mode);
3218 3201
3219 ata_dev_printk(dev, KERN_INFO, "configured for %s%s\n", 3202 ata_dev_info(dev, "configured for %s%s\n",
3220 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)), 3203 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)),
3221 dev_err_whine); 3204 dev_err_whine);
3222 3205
3223 return 0; 3206 return 0;
3224 3207
3225 fail: 3208 fail:
3226 ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " 3209 ata_dev_err(dev, "failed to set xfermode (err_mask=0x%x)\n", err_mask);
3227 "(err_mask=0x%x)\n", err_mask);
3228 return -EIO; 3210 return -EIO;
3229} 3211}
3230 3212
@@ -3286,7 +3268,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
3286 /* step 2: always set host PIO timings */ 3268 /* step 2: always set host PIO timings */
3287 ata_for_each_dev(dev, link, ENABLED) { 3269 ata_for_each_dev(dev, link, ENABLED) {
3288 if (dev->pio_mode == 0xff) { 3270 if (dev->pio_mode == 0xff) {
3289 ata_dev_printk(dev, KERN_WARNING, "no PIO support\n"); 3271 ata_dev_warn(dev, "no PIO support\n");
3290 rc = -EINVAL; 3272 rc = -EINVAL;
3291 goto out; 3273 goto out;
3292 } 3274 }
@@ -3404,7 +3386,7 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline,
3404 3386
3405 if (!warned && time_after(now, start + 5 * HZ) && 3387 if (!warned && time_after(now, start + 5 * HZ) &&
3406 (deadline - now > 3 * HZ)) { 3388 (deadline - now > 3 * HZ)) {
3407 ata_link_printk(link, KERN_WARNING, 3389 ata_link_warn(link,
3408 "link is slow to respond, please be patient " 3390 "link is slow to respond, please be patient "
3409 "(ready=%d)\n", tmp); 3391 "(ready=%d)\n", tmp);
3410 warned = 1; 3392 warned = 1;
@@ -3552,16 +3534,14 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
3552 } while ((scontrol & 0xf0f) != 0x300 && --tries); 3534 } while ((scontrol & 0xf0f) != 0x300 && --tries);
3553 3535
3554 if ((scontrol & 0xf0f) != 0x300) { 3536 if ((scontrol & 0xf0f) != 0x300) {
3555 ata_link_printk(link, KERN_ERR, 3537 ata_link_warn(link, "failed to resume link (SControl %X)\n",
3556 "failed to resume link (SControl %X)\n", 3538 scontrol);
3557 scontrol);
3558 return 0; 3539 return 0;
3559 } 3540 }
3560 3541
3561 if (tries < ATA_LINK_RESUME_TRIES) 3542 if (tries < ATA_LINK_RESUME_TRIES)
3562 ata_link_printk(link, KERN_WARNING, 3543 ata_link_warn(link, "link resume succeeded after %d retries\n",
3563 "link resume succeeded after %d retries\n", 3544 ATA_LINK_RESUME_TRIES - tries);
3564 ATA_LINK_RESUME_TRIES - tries);
3565 3545
3566 if ((rc = sata_link_debounce(link, params, deadline))) 3546 if ((rc = sata_link_debounce(link, params, deadline)))
3567 return rc; 3547 return rc;
@@ -3678,8 +3658,9 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3678 rc = sata_link_resume(link, timing, deadline); 3658 rc = sata_link_resume(link, timing, deadline);
3679 /* whine about phy resume failure but proceed */ 3659 /* whine about phy resume failure but proceed */
3680 if (rc && rc != -EOPNOTSUPP) 3660 if (rc && rc != -EOPNOTSUPP)
3681 ata_link_printk(link, KERN_WARNING, "failed to resume " 3661 ata_link_warn(link,
3682 "link for reset (errno=%d)\n", rc); 3662 "failed to resume link for reset (errno=%d)\n",
3663 rc);
3683 } 3664 }
3684 3665
3685 /* no point in trying softreset on offline link */ 3666 /* no point in trying softreset on offline link */
@@ -3795,8 +3776,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3795 /* online is set iff link is online && reset succeeded */ 3776 /* online is set iff link is online && reset succeeded */
3796 if (online) 3777 if (online)
3797 *online = false; 3778 *online = false;
3798 ata_link_printk(link, KERN_ERR, 3779 ata_link_err(link, "COMRESET failed (errno=%d)\n", rc);
3799 "COMRESET failed (errno=%d)\n", rc);
3800 } 3780 }
3801 DPRINTK("EXIT, rc=%d\n", rc); 3781 DPRINTK("EXIT, rc=%d\n", rc);
3802 return rc; 3782 return rc;
@@ -3880,8 +3860,8 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3880 unsigned char serial[2][ATA_ID_SERNO_LEN + 1]; 3860 unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
3881 3861
3882 if (dev->class != new_class) { 3862 if (dev->class != new_class) {
3883 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n", 3863 ata_dev_info(dev, "class mismatch %d != %d\n",
3884 dev->class, new_class); 3864 dev->class, new_class);
3885 return 0; 3865 return 0;
3886 } 3866 }
3887 3867
@@ -3891,14 +3871,14 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3891 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1])); 3871 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
3892 3872
3893 if (strcmp(model[0], model[1])) { 3873 if (strcmp(model[0], model[1])) {
3894 ata_dev_printk(dev, KERN_INFO, "model number mismatch " 3874 ata_dev_info(dev, "model number mismatch '%s' != '%s'\n",
3895 "'%s' != '%s'\n", model[0], model[1]); 3875 model[0], model[1]);
3896 return 0; 3876 return 0;
3897 } 3877 }
3898 3878
3899 if (strcmp(serial[0], serial[1])) { 3879 if (strcmp(serial[0], serial[1])) {
3900 ata_dev_printk(dev, KERN_INFO, "serial number mismatch " 3880 ata_dev_info(dev, "serial number mismatch '%s' != '%s'\n",
3901 "'%s' != '%s'\n", serial[0], serial[1]); 3881 serial[0], serial[1]);
3902 return 0; 3882 return 0;
3903 } 3883 }
3904 3884
@@ -3968,8 +3948,8 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
3968 new_class != ATA_DEV_ATA && 3948 new_class != ATA_DEV_ATA &&
3969 new_class != ATA_DEV_ATAPI && 3949 new_class != ATA_DEV_ATAPI &&
3970 new_class != ATA_DEV_SEMB) { 3950 new_class != ATA_DEV_SEMB) {
3971 ata_dev_printk(dev, KERN_INFO, "class mismatch %u != %u\n", 3951 ata_dev_info(dev, "class mismatch %u != %u\n",
3972 dev->class, new_class); 3952 dev->class, new_class);
3973 rc = -ENODEV; 3953 rc = -ENODEV;
3974 goto fail; 3954 goto fail;
3975 } 3955 }
@@ -3990,9 +3970,9 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
3990 return 0; 3970 return 0;
3991 3971
3992 /* n_sectors has changed */ 3972 /* n_sectors has changed */
3993 ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch %llu != %llu\n", 3973 ata_dev_warn(dev, "n_sectors mismatch %llu != %llu\n",
3994 (unsigned long long)n_sectors, 3974 (unsigned long long)n_sectors,
3995 (unsigned long long)dev->n_sectors); 3975 (unsigned long long)dev->n_sectors);
3996 3976
3997 /* 3977 /*
3998 * Something could have caused HPA to be unlocked 3978 * Something could have caused HPA to be unlocked
@@ -4001,9 +3981,9 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4001 */ 3981 */
4002 if (dev->n_native_sectors == n_native_sectors && 3982 if (dev->n_native_sectors == n_native_sectors &&
4003 dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) { 3983 dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) {
4004 ata_dev_printk(dev, KERN_WARNING, 3984 ata_dev_warn(dev,
4005 "new n_sectors matches native, probably " 3985 "new n_sectors matches native, probably "
4006 "late HPA unlock, n_sectors updated\n"); 3986 "late HPA unlock, n_sectors updated\n");
4007 /* use the larger n_sectors */ 3987 /* use the larger n_sectors */
4008 return 0; 3988 return 0;
4009 } 3989 }
@@ -4017,9 +3997,9 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4017 if (dev->n_native_sectors == n_native_sectors && 3997 if (dev->n_native_sectors == n_native_sectors &&
4018 dev->n_sectors < n_sectors && n_sectors == n_native_sectors && 3998 dev->n_sectors < n_sectors && n_sectors == n_native_sectors &&
4019 !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) { 3999 !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) {
4020 ata_dev_printk(dev, KERN_WARNING, 4000 ata_dev_warn(dev,
4021 "old n_sectors matches native, probably " 4001 "old n_sectors matches native, probably "
4022 "late HPA lock, will try to unlock HPA\n"); 4002 "late HPA lock, will try to unlock HPA\n");
4023 /* try unlocking HPA */ 4003 /* try unlocking HPA */
4024 dev->flags |= ATA_DFLAG_UNLOCK_HPA; 4004 dev->flags |= ATA_DFLAG_UNLOCK_HPA;
4025 rc = -EIO; 4005 rc = -EIO;
@@ -4030,7 +4010,7 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4030 dev->n_native_sectors = n_native_sectors; 4010 dev->n_native_sectors = n_native_sectors;
4031 dev->n_sectors = n_sectors; 4011 dev->n_sectors = n_sectors;
4032 fail: 4012 fail:
4033 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); 4013 ata_dev_err(dev, "revalidation failed (errno=%d)\n", rc);
4034 return rc; 4014 return rc;
4035} 4015}
4036 4016
@@ -4358,15 +4338,15 @@ static void ata_dev_xfermask(struct ata_device *dev)
4358 4338
4359 if (ata_dma_blacklisted(dev)) { 4339 if (ata_dma_blacklisted(dev)) {
4360 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 4340 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
4361 ata_dev_printk(dev, KERN_WARNING, 4341 ata_dev_warn(dev,
4362 "device is on DMA blacklist, disabling DMA\n"); 4342 "device is on DMA blacklist, disabling DMA\n");
4363 } 4343 }
4364 4344
4365 if ((host->flags & ATA_HOST_SIMPLEX) && 4345 if ((host->flags & ATA_HOST_SIMPLEX) &&
4366 host->simplex_claimed && host->simplex_claimed != ap) { 4346 host->simplex_claimed && host->simplex_claimed != ap) {
4367 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 4347 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
4368 ata_dev_printk(dev, KERN_WARNING, "simplex DMA is claimed by " 4348 ata_dev_warn(dev,
4369 "other device, disabling DMA\n"); 4349 "simplex DMA is claimed by other device, disabling DMA\n");
4370 } 4350 }
4371 4351
4372 if (ap->flags & ATA_FLAG_NO_IORDY) 4352 if (ap->flags & ATA_FLAG_NO_IORDY)
@@ -4386,8 +4366,8 @@ static void ata_dev_xfermask(struct ata_device *dev)
4386 if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA)) 4366 if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA))
4387 /* UDMA/44 or higher would be available */ 4367 /* UDMA/44 or higher would be available */
4388 if (cable_is_40wire(ap)) { 4368 if (cable_is_40wire(ap)) {
4389 ata_dev_printk(dev, KERN_WARNING, 4369 ata_dev_warn(dev,
4390 "limited to UDMA/33 due to 40-wire cable\n"); 4370 "limited to UDMA/33 due to 40-wire cable\n");
4391 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); 4371 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
4392 } 4372 }
4393 4373
@@ -4954,8 +4934,8 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
4954 done_mask = ap->qc_active ^ qc_active; 4934 done_mask = ap->qc_active ^ qc_active;
4955 4935
4956 if (unlikely(done_mask & qc_active)) { 4936 if (unlikely(done_mask & qc_active)) {
4957 ata_port_printk(ap, KERN_ERR, "illegal qc_active transition " 4937 ata_port_err(ap, "illegal qc_active transition (%08x->%08x)\n",
4958 "(%08x->%08x)\n", ap->qc_active, qc_active); 4938 ap->qc_active, qc_active);
4959 return -EINVAL; 4939 return -EINVAL;
4960 } 4940 }
4961 4941
@@ -5847,9 +5827,9 @@ int ata_host_start(struct ata_host *host)
5847 rc = ap->ops->port_start(ap); 5827 rc = ap->ops->port_start(ap);
5848 if (rc) { 5828 if (rc) {
5849 if (rc != -ENODEV) 5829 if (rc != -ENODEV)
5850 dev_printk(KERN_ERR, host->dev, 5830 dev_err(host->dev,
5851 "failed to start port %d " 5831 "failed to start port %d (errno=%d)\n",
5852 "(errno=%d)\n", i, rc); 5832 i, rc);
5853 goto err_out; 5833 goto err_out;
5854 } 5834 }
5855 } 5835 }
@@ -5971,8 +5951,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
5971 5951
5972 /* host must have been started */ 5952 /* host must have been started */
5973 if (!(host->flags & ATA_HOST_STARTED)) { 5953 if (!(host->flags & ATA_HOST_STARTED)) {
5974 dev_printk(KERN_ERR, host->dev, 5954 dev_err(host->dev, "BUG: trying to register unstarted host\n");
5975 "BUG: trying to register unstarted host\n");
5976 WARN_ON(1); 5955 WARN_ON(1);
5977 return -EINVAL; 5956 return -EINVAL;
5978 } 5957 }
@@ -6023,14 +6002,13 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6023 ap->udma_mask); 6002 ap->udma_mask);
6024 6003
6025 if (!ata_port_is_dummy(ap)) { 6004 if (!ata_port_is_dummy(ap)) {
6026 ata_port_printk(ap, KERN_INFO, 6005 ata_port_info(ap, "%cATA max %s %s\n",
6027 "%cATA max %s %s\n", 6006 (ap->flags & ATA_FLAG_SATA) ? 'S' : 'P',
6028 (ap->flags & ATA_FLAG_SATA) ? 'S' : 'P', 6007 ata_mode_string(xfer_mask),
6029 ata_mode_string(xfer_mask), 6008 ap->link.eh_info.desc);
6030 ap->link.eh_info.desc);
6031 ata_ehi_clear_desc(&ap->link.eh_info); 6009 ata_ehi_clear_desc(&ap->link.eh_info);
6032 } else 6010 } else
6033 ata_port_printk(ap, KERN_INFO, "DUMMY\n"); 6011 ata_port_info(ap, "DUMMY\n");
6034 } 6012 }
6035 6013
6036 /* perform each probe asynchronously */ 6014 /* perform each probe asynchronously */
@@ -6242,8 +6220,8 @@ int ata_pci_device_do_resume(struct pci_dev *pdev)
6242 6220
6243 rc = pcim_enable_device(pdev); 6221 rc = pcim_enable_device(pdev);
6244 if (rc) { 6222 if (rc) {
6245 dev_printk(KERN_ERR, &pdev->dev, 6223 dev_err(&pdev->dev,
6246 "failed to enable device after resume (%d)\n", rc); 6224 "failed to enable device after resume (%d)\n", rc);
6247 return rc; 6225 return rc;
6248 } 6226 }
6249 6227
@@ -6600,6 +6578,82 @@ const struct ata_port_info ata_dummy_port_info = {
6600}; 6578};
6601 6579
6602/* 6580/*
6581 * Utility print functions
6582 */
6583int ata_port_printk(const struct ata_port *ap, const char *level,
6584 const char *fmt, ...)
6585{
6586 struct va_format vaf;
6587 va_list args;
6588 int r;
6589
6590 va_start(args, fmt);
6591
6592 vaf.fmt = fmt;
6593 vaf.va = &args;
6594
6595 r = printk("%sata%u: %pV", level, ap->print_id, &vaf);
6596
6597 va_end(args);
6598
6599 return r;
6600}
6601EXPORT_SYMBOL(ata_port_printk);
6602
6603int ata_link_printk(const struct ata_link *link, const char *level,
6604 const char *fmt, ...)
6605{
6606 struct va_format vaf;
6607 va_list args;
6608 int r;
6609
6610 va_start(args, fmt);
6611
6612 vaf.fmt = fmt;
6613 vaf.va = &args;
6614
6615 if (sata_pmp_attached(link->ap) || link->ap->slave_link)
6616 r = printk("%sata%u.%02u: %pV",
6617 level, link->ap->print_id, link->pmp, &vaf);
6618 else
6619 r = printk("%sata%u: %pV",
6620 level, link->ap->print_id, &vaf);
6621
6622 va_end(args);
6623
6624 return r;
6625}
6626EXPORT_SYMBOL(ata_link_printk);
6627
6628int ata_dev_printk(const struct ata_device *dev, const char *level,
6629 const char *fmt, ...)
6630{
6631 struct va_format vaf;
6632 va_list args;
6633 int r;
6634
6635 va_start(args, fmt);
6636
6637 vaf.fmt = fmt;
6638 vaf.va = &args;
6639
6640 r = printk("%sata%u.%02u: %pV",
6641 level, dev->link->ap->print_id, dev->link->pmp + dev->devno,
6642 &vaf);
6643
6644 va_end(args);
6645
6646 return r;
6647}
6648EXPORT_SYMBOL(ata_dev_printk);
6649
6650void ata_print_version(const struct device *dev, const char *version)
6651{
6652 dev_printk(KERN_DEBUG, dev, "version %s\n", version);
6653}
6654EXPORT_SYMBOL(ata_print_version);
6655
6656/*
6603 * libata is essentially a library of internal helper functions for 6657 * libata is essentially a library of internal helper functions for
6604 * low-level ATA host controller drivers. As such, the API/ABI is 6658 * low-level ATA host controller drivers. As such, the API/ABI is
6605 * likely to change as new drivers are added and updated. 6659 * likely to change as new drivers are added and updated.
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 7f099d6e4e0b..ed16fbedaabd 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -782,8 +782,9 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
782 spin_unlock_irqrestore(ap->lock, flags); 782 spin_unlock_irqrestore(ap->lock, flags);
783 goto repeat; 783 goto repeat;
784 } 784 }
785 ata_port_printk(ap, KERN_ERR, "EH pending after %d " 785 ata_port_err(ap,
786 "tries, giving up\n", ATA_EH_MAX_TRIES); 786 "EH pending after %d tries, giving up\n",
787 ATA_EH_MAX_TRIES);
787 ap->pflags &= ~ATA_PFLAG_EH_PENDING; 788 ap->pflags &= ~ATA_PFLAG_EH_PENDING;
788 } 789 }
789 790
@@ -816,7 +817,7 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
816 schedule_delayed_work(&ap->hotplug_task, 0); 817 schedule_delayed_work(&ap->hotplug_task, 0);
817 818
818 if (ap->pflags & ATA_PFLAG_RECOVERED) 819 if (ap->pflags & ATA_PFLAG_RECOVERED)
819 ata_port_printk(ap, KERN_INFO, "EH complete\n"); 820 ata_port_info(ap, "EH complete\n");
820 821
821 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); 822 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED);
822 823
@@ -1310,7 +1311,7 @@ void ata_dev_disable(struct ata_device *dev)
1310 return; 1311 return;
1311 1312
1312 if (ata_msg_drv(dev->link->ap)) 1313 if (ata_msg_drv(dev->link->ap))
1313 ata_dev_printk(dev, KERN_WARNING, "disabled\n"); 1314 ata_dev_warn(dev, "disabled\n");
1314 ata_acpi_on_disable(dev); 1315 ata_acpi_on_disable(dev);
1315 ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET); 1316 ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET);
1316 dev->class++; 1317 dev->class++;
@@ -1515,8 +1516,8 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
1515 for (i = 0; i < ATA_SECT_SIZE; i++) 1516 for (i = 0; i < ATA_SECT_SIZE; i++)
1516 csum += buf[i]; 1517 csum += buf[i];
1517 if (csum) 1518 if (csum)
1518 ata_dev_printk(dev, KERN_WARNING, 1519 ata_dev_warn(dev, "invalid checksum 0x%x on log page 10h\n",
1519 "invalid checksum 0x%x on log page 10h\n", csum); 1520 csum);
1520 1521
1521 if (buf[0] & 0x80) 1522 if (buf[0] & 0x80)
1522 return -ENOENT; 1523 return -ENOENT;
@@ -1716,14 +1717,14 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
1716 memset(&tf, 0, sizeof(tf)); 1717 memset(&tf, 0, sizeof(tf));
1717 rc = ata_eh_read_log_10h(dev, &tag, &tf); 1718 rc = ata_eh_read_log_10h(dev, &tag, &tf);
1718 if (rc) { 1719 if (rc) {
1719 ata_link_printk(link, KERN_ERR, "failed to read log page 10h " 1720 ata_link_err(link, "failed to read log page 10h (errno=%d)\n",
1720 "(errno=%d)\n", rc); 1721 rc);
1721 return; 1722 return;
1722 } 1723 }
1723 1724
1724 if (!(link->sactive & (1 << tag))) { 1725 if (!(link->sactive & (1 << tag))) {
1725 ata_link_printk(link, KERN_ERR, "log page 10h reported " 1726 ata_link_err(link, "log page 10h reported inactive tag %d\n",
1726 "inactive tag %d\n", tag); 1727 tag);
1727 return; 1728 return;
1728 } 1729 }
1729 1730
@@ -1988,8 +1989,7 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev,
1988 (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ | 1989 (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ |
1989 ATA_DFLAG_NCQ_OFF)) == ATA_DFLAG_NCQ) { 1990 ATA_DFLAG_NCQ_OFF)) == ATA_DFLAG_NCQ) {
1990 dev->flags |= ATA_DFLAG_NCQ_OFF; 1991 dev->flags |= ATA_DFLAG_NCQ_OFF;
1991 ata_dev_printk(dev, KERN_WARNING, 1992 ata_dev_warn(dev, "NCQ disabled due to excessive errors\n");
1992 "NCQ disabled due to excessive errors\n");
1993 goto done; 1993 goto done;
1994 } 1994 }
1995 1995
@@ -2374,24 +2374,24 @@ static void ata_eh_link_report(struct ata_link *link)
2374 ap->eh_tries); 2374 ap->eh_tries);
2375 2375
2376 if (ehc->i.dev) { 2376 if (ehc->i.dev) {
2377 ata_dev_printk(ehc->i.dev, KERN_ERR, "exception Emask 0x%x " 2377 ata_dev_err(ehc->i.dev, "exception Emask 0x%x "
2378 "SAct 0x%x SErr 0x%x action 0x%x%s%s\n", 2378 "SAct 0x%x SErr 0x%x action 0x%x%s%s\n",
2379 ehc->i.err_mask, link->sactive, ehc->i.serror, 2379 ehc->i.err_mask, link->sactive, ehc->i.serror,
2380 ehc->i.action, frozen, tries_buf); 2380 ehc->i.action, frozen, tries_buf);
2381 if (desc) 2381 if (desc)
2382 ata_dev_printk(ehc->i.dev, KERN_ERR, "%s\n", desc); 2382 ata_dev_err(ehc->i.dev, "%s\n", desc);
2383 } else { 2383 } else {
2384 ata_link_printk(link, KERN_ERR, "exception Emask 0x%x " 2384 ata_link_err(link, "exception Emask 0x%x "
2385 "SAct 0x%x SErr 0x%x action 0x%x%s%s\n", 2385 "SAct 0x%x SErr 0x%x action 0x%x%s%s\n",
2386 ehc->i.err_mask, link->sactive, ehc->i.serror, 2386 ehc->i.err_mask, link->sactive, ehc->i.serror,
2387 ehc->i.action, frozen, tries_buf); 2387 ehc->i.action, frozen, tries_buf);
2388 if (desc) 2388 if (desc)
2389 ata_link_printk(link, KERN_ERR, "%s\n", desc); 2389 ata_link_err(link, "%s\n", desc);
2390 } 2390 }
2391 2391
2392#ifdef CONFIG_ATA_VERBOSE_ERROR 2392#ifdef CONFIG_ATA_VERBOSE_ERROR
2393 if (ehc->i.serror) 2393 if (ehc->i.serror)
2394 ata_link_printk(link, KERN_ERR, 2394 ata_link_err(link,
2395 "SError: { %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}\n", 2395 "SError: { %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}\n",
2396 ehc->i.serror & SERR_DATA_RECOVERED ? "RecovData " : "", 2396 ehc->i.serror & SERR_DATA_RECOVERED ? "RecovData " : "",
2397 ehc->i.serror & SERR_COMM_RECOVERED ? "RecovComm " : "", 2397 ehc->i.serror & SERR_COMM_RECOVERED ? "RecovComm " : "",
@@ -2456,11 +2456,11 @@ static void ata_eh_link_report(struct ata_link *link)
2456 } else { 2456 } else {
2457 const char *descr = ata_get_cmd_descript(cmd->command); 2457 const char *descr = ata_get_cmd_descript(cmd->command);
2458 if (descr) 2458 if (descr)
2459 ata_dev_printk(qc->dev, KERN_ERR, 2459 ata_dev_err(qc->dev, "failed command: %s\n",
2460 "failed command: %s\n", descr); 2460 descr);
2461 } 2461 }
2462 2462
2463 ata_dev_printk(qc->dev, KERN_ERR, 2463 ata_dev_err(qc->dev,
2464 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " 2464 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
2465 "tag %d%s\n %s" 2465 "tag %d%s\n %s"
2466 "res %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " 2466 "res %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
@@ -2481,11 +2481,9 @@ static void ata_eh_link_report(struct ata_link *link)
2481 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | 2481 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
2482 ATA_ERR)) { 2482 ATA_ERR)) {
2483 if (res->command & ATA_BUSY) 2483 if (res->command & ATA_BUSY)
2484 ata_dev_printk(qc->dev, KERN_ERR, 2484 ata_dev_err(qc->dev, "status: { Busy }\n");
2485 "status: { Busy }\n");
2486 else 2485 else
2487 ata_dev_printk(qc->dev, KERN_ERR, 2486 ata_dev_err(qc->dev, "status: { %s%s%s%s}\n",
2488 "status: { %s%s%s%s}\n",
2489 res->command & ATA_DRDY ? "DRDY " : "", 2487 res->command & ATA_DRDY ? "DRDY " : "",
2490 res->command & ATA_DF ? "DF " : "", 2488 res->command & ATA_DF ? "DF " : "",
2491 res->command & ATA_DRQ ? "DRQ " : "", 2489 res->command & ATA_DRQ ? "DRQ " : "",
@@ -2495,8 +2493,7 @@ static void ata_eh_link_report(struct ata_link *link)
2495 if (cmd->command != ATA_CMD_PACKET && 2493 if (cmd->command != ATA_CMD_PACKET &&
2496 (res->feature & (ATA_ICRC | ATA_UNC | ATA_IDNF | 2494 (res->feature & (ATA_ICRC | ATA_UNC | ATA_IDNF |
2497 ATA_ABORTED))) 2495 ATA_ABORTED)))
2498 ata_dev_printk(qc->dev, KERN_ERR, 2496 ata_dev_err(qc->dev, "error: { %s%s%s%s}\n",
2499 "error: { %s%s%s%s}\n",
2500 res->feature & ATA_ICRC ? "ICRC " : "", 2497 res->feature & ATA_ICRC ? "ICRC " : "",
2501 res->feature & ATA_UNC ? "UNC " : "", 2498 res->feature & ATA_UNC ? "UNC " : "",
2502 res->feature & ATA_IDNF ? "IDNF " : "", 2499 res->feature & ATA_IDNF ? "IDNF " : "",
@@ -2650,8 +2647,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
2650 2647
2651 if (rc) { 2648 if (rc) {
2652 if (rc == -ENOENT) { 2649 if (rc == -ENOENT) {
2653 ata_link_printk(link, KERN_DEBUG, 2650 ata_link_dbg(link, "port disabled--ignoring\n");
2654 "port disabled. ignoring.\n");
2655 ehc->i.action &= ~ATA_EH_RESET; 2651 ehc->i.action &= ~ATA_EH_RESET;
2656 2652
2657 ata_for_each_dev(dev, link, ALL) 2653 ata_for_each_dev(dev, link, ALL)
@@ -2659,8 +2655,9 @@ int ata_eh_reset(struct ata_link *link, int classify,
2659 2655
2660 rc = 0; 2656 rc = 0;
2661 } else 2657 } else
2662 ata_link_printk(link, KERN_ERR, 2658 ata_link_err(link,
2663 "prereset failed (errno=%d)\n", rc); 2659 "prereset failed (errno=%d)\n",
2660 rc);
2664 goto out; 2661 goto out;
2665 } 2662 }
2666 2663
@@ -2689,8 +2686,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2689 2686
2690 if (reset) { 2687 if (reset) {
2691 if (verbose) 2688 if (verbose)
2692 ata_link_printk(link, KERN_INFO, "%s resetting link\n", 2689 ata_link_info(link, "%s resetting link\n",
2693 reset == softreset ? "soft" : "hard"); 2690 reset == softreset ? "soft" : "hard");
2694 2691
2695 /* mark that this EH session started with reset */ 2692 /* mark that this EH session started with reset */
2696 ehc->last_reset = jiffies; 2693 ehc->last_reset = jiffies;
@@ -2710,8 +2707,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
2710 int tmp; 2707 int tmp;
2711 2708
2712 if (verbose) 2709 if (verbose)
2713 ata_link_printk(slave, KERN_INFO, 2710 ata_link_info(slave, "hard resetting link\n");
2714 "hard resetting link\n");
2715 2711
2716 ata_eh_about_to_do(slave, NULL, ATA_EH_RESET); 2712 ata_eh_about_to_do(slave, NULL, ATA_EH_RESET);
2717 tmp = ata_do_reset(slave, reset, classes, deadline, 2713 tmp = ata_do_reset(slave, reset, classes, deadline,
@@ -2734,9 +2730,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2734 reset = softreset; 2730 reset = softreset;
2735 2731
2736 if (!reset) { 2732 if (!reset) {
2737 ata_link_printk(link, KERN_ERR, 2733 ata_link_err(link,
2738 "follow-up softreset required " 2734 "follow-up softreset required but no softreset available\n");
2739 "but no softreset available\n");
2740 failed_link = link; 2735 failed_link = link;
2741 rc = -EINVAL; 2736 rc = -EINVAL;
2742 goto fail; 2737 goto fail;
@@ -2751,8 +2746,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2751 } 2746 }
2752 } else { 2747 } else {
2753 if (verbose) 2748 if (verbose)
2754 ata_link_printk(link, KERN_INFO, "no reset method " 2749 ata_link_info(link,
2755 "available, skipping reset\n"); 2750 "no reset method available, skipping reset\n");
2756 if (!(lflags & ATA_LFLAG_ASSUME_CLASS)) 2751 if (!(lflags & ATA_LFLAG_ASSUME_CLASS))
2757 lflags |= ATA_LFLAG_ASSUME_ATA; 2752 lflags |= ATA_LFLAG_ASSUME_ATA;
2758 } 2753 }
@@ -2830,36 +2825,35 @@ int ata_eh_reset(struct ata_link *link, int classify,
2830 ata_for_each_dev(dev, link, ALL) { 2825 ata_for_each_dev(dev, link, ALL) {
2831 if (ata_phys_link_online(ata_dev_phys_link(dev))) { 2826 if (ata_phys_link_online(ata_dev_phys_link(dev))) {
2832 if (classes[dev->devno] == ATA_DEV_UNKNOWN) { 2827 if (classes[dev->devno] == ATA_DEV_UNKNOWN) {
2833 ata_dev_printk(dev, KERN_DEBUG, "link online " 2828 ata_dev_dbg(dev, "link online but device misclassified\n");
2834 "but device misclassifed\n");
2835 classes[dev->devno] = ATA_DEV_NONE; 2829 classes[dev->devno] = ATA_DEV_NONE;
2836 nr_unknown++; 2830 nr_unknown++;
2837 } 2831 }
2838 } else if (ata_phys_link_offline(ata_dev_phys_link(dev))) { 2832 } else if (ata_phys_link_offline(ata_dev_phys_link(dev))) {
2839 if (ata_class_enabled(classes[dev->devno])) 2833 if (ata_class_enabled(classes[dev->devno]))
2840 ata_dev_printk(dev, KERN_DEBUG, "link offline, " 2834 ata_dev_dbg(dev,
2841 "clearing class %d to NONE\n", 2835 "link offline, clearing class %d to NONE\n",
2842 classes[dev->devno]); 2836 classes[dev->devno]);
2843 classes[dev->devno] = ATA_DEV_NONE; 2837 classes[dev->devno] = ATA_DEV_NONE;
2844 } else if (classes[dev->devno] == ATA_DEV_UNKNOWN) { 2838 } else if (classes[dev->devno] == ATA_DEV_UNKNOWN) {
2845 ata_dev_printk(dev, KERN_DEBUG, "link status unknown, " 2839 ata_dev_dbg(dev,
2846 "clearing UNKNOWN to NONE\n"); 2840 "link status unknown, clearing UNKNOWN to NONE\n");
2847 classes[dev->devno] = ATA_DEV_NONE; 2841 classes[dev->devno] = ATA_DEV_NONE;
2848 } 2842 }
2849 } 2843 }
2850 2844
2851 if (classify && nr_unknown) { 2845 if (classify && nr_unknown) {
2852 if (try < max_tries) { 2846 if (try < max_tries) {
2853 ata_link_printk(link, KERN_WARNING, "link online but " 2847 ata_link_warn(link,
2854 "%d devices misclassified, retrying\n", 2848 "link online but %d devices misclassified, retrying\n",
2855 nr_unknown); 2849 nr_unknown);
2856 failed_link = link; 2850 failed_link = link;
2857 rc = -EAGAIN; 2851 rc = -EAGAIN;
2858 goto fail; 2852 goto fail;
2859 } 2853 }
2860 ata_link_printk(link, KERN_WARNING, 2854 ata_link_warn(link,
2861 "link online but %d devices misclassified, " 2855 "link online but %d devices misclassified, "
2862 "device detection might fail\n", nr_unknown); 2856 "device detection might fail\n", nr_unknown);
2863 } 2857 }
2864 2858
2865 /* reset successful, schedule revalidation */ 2859 /* reset successful, schedule revalidation */
@@ -2889,14 +2883,23 @@ int ata_eh_reset(struct ata_link *link, int classify,
2889 sata_scr_read(link, SCR_STATUS, &sstatus)) 2883 sata_scr_read(link, SCR_STATUS, &sstatus))
2890 rc = -ERESTART; 2884 rc = -ERESTART;
2891 2885
2892 if (rc == -ERESTART || try >= max_tries) 2886 if (rc == -ERESTART || try >= max_tries) {
2887 /*
2888 * Thaw host port even if reset failed, so that the port
2889 * can be retried on the next phy event. This risks
2890 * repeated EH runs but seems to be a better tradeoff than
2891 * shutting down a port after a botched hotplug attempt.
2892 */
2893 if (ata_is_host_link(link))
2894 ata_eh_thaw_port(ap);
2893 goto out; 2895 goto out;
2896 }
2894 2897
2895 now = jiffies; 2898 now = jiffies;
2896 if (time_before(now, deadline)) { 2899 if (time_before(now, deadline)) {
2897 unsigned long delta = deadline - now; 2900 unsigned long delta = deadline - now;
2898 2901
2899 ata_link_printk(failed_link, KERN_WARNING, 2902 ata_link_warn(failed_link,
2900 "reset failed (errno=%d), retrying in %u secs\n", 2903 "reset failed (errno=%d), retrying in %u secs\n",
2901 rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); 2904 rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000));
2902 2905
@@ -2987,7 +2990,7 @@ static void ata_eh_park_issue_cmd(struct ata_device *dev, int park)
2987 tf.protocol |= ATA_PROT_NODATA; 2990 tf.protocol |= ATA_PROT_NODATA;
2988 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 2991 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
2989 if (park && (err_mask || tf.lbal != 0xc4)) { 2992 if (park && (err_mask || tf.lbal != 0xc4)) {
2990 ata_dev_printk(dev, KERN_ERR, "head unload failed!\n"); 2993 ata_dev_err(dev, "head unload failed!\n");
2991 ehc->unloaded_mask &= ~(1 << dev->devno); 2994 ehc->unloaded_mask &= ~(1 << dev->devno);
2992 } 2995 }
2993} 2996}
@@ -3198,8 +3201,9 @@ static int atapi_eh_clear_ua(struct ata_device *dev)
3198 3201
3199 err_mask = atapi_eh_tur(dev, &sense_key); 3202 err_mask = atapi_eh_tur(dev, &sense_key);
3200 if (err_mask != 0 && err_mask != AC_ERR_DEV) { 3203 if (err_mask != 0 && err_mask != AC_ERR_DEV) {
3201 ata_dev_printk(dev, KERN_WARNING, "TEST_UNIT_READY " 3204 ata_dev_warn(dev,
3202 "failed (err_mask=0x%x)\n", err_mask); 3205 "TEST_UNIT_READY failed (err_mask=0x%x)\n",
3206 err_mask);
3203 return -EIO; 3207 return -EIO;
3204 } 3208 }
3205 3209
@@ -3208,14 +3212,14 @@ static int atapi_eh_clear_ua(struct ata_device *dev)
3208 3212
3209 err_mask = atapi_eh_request_sense(dev, sense_buffer, sense_key); 3213 err_mask = atapi_eh_request_sense(dev, sense_buffer, sense_key);
3210 if (err_mask) { 3214 if (err_mask) {
3211 ata_dev_printk(dev, KERN_WARNING, "failed to clear " 3215 ata_dev_warn(dev, "failed to clear "
3212 "UNIT ATTENTION (err_mask=0x%x)\n", err_mask); 3216 "UNIT ATTENTION (err_mask=0x%x)\n", err_mask);
3213 return -EIO; 3217 return -EIO;
3214 } 3218 }
3215 } 3219 }
3216 3220
3217 ata_dev_printk(dev, KERN_WARNING, 3221 ata_dev_warn(dev, "UNIT ATTENTION persists after %d tries\n",
3218 "UNIT ATTENTION persists after %d tries\n", ATA_EH_UA_TRIES); 3222 ATA_EH_UA_TRIES);
3219 3223
3220 return 0; 3224 return 0;
3221} 3225}
@@ -3266,7 +3270,7 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
3266 tf.flags |= ATA_TFLAG_DEVICE; 3270 tf.flags |= ATA_TFLAG_DEVICE;
3267 tf.protocol = ATA_PROT_NODATA; 3271 tf.protocol = ATA_PROT_NODATA;
3268 3272
3269 ata_dev_printk(dev, KERN_WARNING, "retrying FLUSH 0x%x Emask 0x%x\n", 3273 ata_dev_warn(dev, "retrying FLUSH 0x%x Emask 0x%x\n",
3270 tf.command, qc->err_mask); 3274 tf.command, qc->err_mask);
3271 3275
3272 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 3276 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
@@ -3281,7 +3285,7 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
3281 */ 3285 */
3282 qc->scsicmd->allowed = max(qc->scsicmd->allowed, 1); 3286 qc->scsicmd->allowed = max(qc->scsicmd->allowed, 1);
3283 } else { 3287 } else {
3284 ata_dev_printk(dev, KERN_WARNING, "FLUSH failed Emask 0x%x\n", 3288 ata_dev_warn(dev, "FLUSH failed Emask 0x%x\n",
3285 err_mask); 3289 err_mask);
3286 rc = -EIO; 3290 rc = -EIO;
3287 3291
@@ -3355,9 +3359,9 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3355 err_mask = ata_dev_set_feature(dev, 3359 err_mask = ata_dev_set_feature(dev,
3356 SETFEATURES_SATA_DISABLE, SATA_DIPM); 3360 SETFEATURES_SATA_DISABLE, SATA_DIPM);
3357 if (err_mask && err_mask != AC_ERR_DEV) { 3361 if (err_mask && err_mask != AC_ERR_DEV) {
3358 ata_dev_printk(dev, KERN_WARNING, 3362 ata_dev_warn(dev,
3359 "failed to disable DIPM, Emask 0x%x\n", 3363 "failed to disable DIPM, Emask 0x%x\n",
3360 err_mask); 3364 err_mask);
3361 rc = -EIO; 3365 rc = -EIO;
3362 goto fail; 3366 goto fail;
3363 } 3367 }
@@ -3399,7 +3403,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3399 err_mask = ata_dev_set_feature(dev, 3403 err_mask = ata_dev_set_feature(dev,
3400 SETFEATURES_SATA_ENABLE, SATA_DIPM); 3404 SETFEATURES_SATA_ENABLE, SATA_DIPM);
3401 if (err_mask && err_mask != AC_ERR_DEV) { 3405 if (err_mask && err_mask != AC_ERR_DEV) {
3402 ata_dev_printk(dev, KERN_WARNING, 3406 ata_dev_warn(dev,
3403 "failed to enable DIPM, Emask 0x%x\n", 3407 "failed to enable DIPM, Emask 0x%x\n",
3404 err_mask); 3408 err_mask);
3405 rc = -EIO; 3409 rc = -EIO;
@@ -3418,8 +3422,7 @@ fail:
3418 3422
3419 /* if no device or only one more chance is left, disable LPM */ 3423 /* if no device or only one more chance is left, disable LPM */
3420 if (!dev || ehc->tries[dev->devno] <= 2) { 3424 if (!dev || ehc->tries[dev->devno] <= 2) {
3421 ata_link_printk(link, KERN_WARNING, 3425 ata_link_warn(link, "disabling LPM on the link\n");
3422 "disabling LPM on the link\n");
3423 link->flags |= ATA_LFLAG_NO_LPM; 3426 link->flags |= ATA_LFLAG_NO_LPM;
3424 } 3427 }
3425 if (r_failed_dev) 3428 if (r_failed_dev)
@@ -3690,8 +3693,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
3690 rc = ata_eh_reset(link, ata_link_nr_vacant(link), 3693 rc = ata_eh_reset(link, ata_link_nr_vacant(link),
3691 prereset, softreset, hardreset, postreset); 3694 prereset, softreset, hardreset, postreset);
3692 if (rc) { 3695 if (rc) {
3693 ata_link_printk(link, KERN_ERR, 3696 ata_link_err(link, "reset failed, giving up\n");
3694 "reset failed, giving up\n");
3695 goto out; 3697 goto out;
3696 } 3698 }
3697 } 3699 }
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index f06b7ea590d3..3eb2b816eb2a 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -147,8 +147,8 @@ int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val)
147 147
148 err_mask = sata_pmp_read(link, reg, r_val); 148 err_mask = sata_pmp_read(link, reg, r_val);
149 if (err_mask) { 149 if (err_mask) {
150 ata_link_printk(link, KERN_WARNING, "failed to read SCR %d " 150 ata_link_warn(link, "failed to read SCR %d (Emask=0x%x)\n",
151 "(Emask=0x%x)\n", reg, err_mask); 151 reg, err_mask);
152 return -EIO; 152 return -EIO;
153 } 153 }
154 return 0; 154 return 0;
@@ -178,8 +178,8 @@ int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val)
178 178
179 err_mask = sata_pmp_write(link, reg, val); 179 err_mask = sata_pmp_write(link, reg, val);
180 if (err_mask) { 180 if (err_mask) {
181 ata_link_printk(link, KERN_WARNING, "failed to write SCR %d " 181 ata_link_warn(link, "failed to write SCR %d (Emask=0x%x)\n",
182 "(Emask=0x%x)\n", reg, err_mask); 182 reg, err_mask);
183 return -EIO; 183 return -EIO;
184 } 184 }
185 return 0; 185 return 0;
@@ -231,8 +231,8 @@ static int sata_pmp_read_gscr(struct ata_device *dev, u32 *gscr)
231 231
232 err_mask = sata_pmp_read(dev->link, reg, &gscr[reg]); 232 err_mask = sata_pmp_read(dev->link, reg, &gscr[reg]);
233 if (err_mask) { 233 if (err_mask) {
234 ata_dev_printk(dev, KERN_ERR, "failed to read PMP " 234 ata_dev_err(dev, "failed to read PMP GSCR[%d] (Emask=0x%x)\n",
235 "GSCR[%d] (Emask=0x%x)\n", reg, err_mask); 235 reg, err_mask);
236 return -EIO; 236 return -EIO;
237 } 237 }
238 } 238 }
@@ -311,26 +311,25 @@ static int sata_pmp_configure(struct ata_device *dev, int print_info)
311 } 311 }
312 312
313 if (print_info) { 313 if (print_info) {
314 ata_dev_printk(dev, KERN_INFO, "Port Multiplier %s, " 314 ata_dev_info(dev, "Port Multiplier %s, "
315 "0x%04x:0x%04x r%d, %d ports, feat 0x%x/0x%x\n", 315 "0x%04x:0x%04x r%d, %d ports, feat 0x%x/0x%x\n",
316 sata_pmp_spec_rev_str(gscr), vendor, devid, 316 sata_pmp_spec_rev_str(gscr), vendor, devid,
317 sata_pmp_gscr_rev(gscr), 317 sata_pmp_gscr_rev(gscr),
318 nr_ports, gscr[SATA_PMP_GSCR_FEAT_EN], 318 nr_ports, gscr[SATA_PMP_GSCR_FEAT_EN],
319 gscr[SATA_PMP_GSCR_FEAT]); 319 gscr[SATA_PMP_GSCR_FEAT]);
320 320
321 if (!(dev->flags & ATA_DFLAG_AN)) 321 if (!(dev->flags & ATA_DFLAG_AN))
322 ata_dev_printk(dev, KERN_INFO, 322 ata_dev_info(dev,
323 "Asynchronous notification not supported, " 323 "Asynchronous notification not supported, "
324 "hotplug won't\n work on fan-out " 324 "hotplug won't work on fan-out ports. Use warm-plug instead.\n");
325 "ports. Use warm-plug instead.\n");
326 } 325 }
327 326
328 return 0; 327 return 0;
329 328
330 fail: 329 fail:
331 ata_dev_printk(dev, KERN_ERR, 330 ata_dev_err(dev,
332 "failed to configure Port Multiplier (%s, Emask=0x%x)\n", 331 "failed to configure Port Multiplier (%s, Emask=0x%x)\n",
333 reason, err_mask); 332 reason, err_mask);
334 return rc; 333 return rc;
335} 334}
336 335
@@ -485,20 +484,17 @@ int sata_pmp_attach(struct ata_device *dev)
485 484
486 /* is it hanging off the right place? */ 485 /* is it hanging off the right place? */
487 if (!sata_pmp_supported(ap)) { 486 if (!sata_pmp_supported(ap)) {
488 ata_dev_printk(dev, KERN_ERR, 487 ata_dev_err(dev, "host does not support Port Multiplier\n");
489 "host does not support Port Multiplier\n");
490 return -EINVAL; 488 return -EINVAL;
491 } 489 }
492 490
493 if (!ata_is_host_link(link)) { 491 if (!ata_is_host_link(link)) {
494 ata_dev_printk(dev, KERN_ERR, 492 ata_dev_err(dev, "Port Multipliers cannot be nested\n");
495 "Port Multipliers cannot be nested\n");
496 return -EINVAL; 493 return -EINVAL;
497 } 494 }
498 495
499 if (dev->devno) { 496 if (dev->devno) {
500 ata_dev_printk(dev, KERN_ERR, 497 ata_dev_err(dev, "Port Multiplier must be the first device\n");
501 "Port Multiplier must be the first device\n");
502 return -EINVAL; 498 return -EINVAL;
503 } 499 }
504 500
@@ -517,8 +513,7 @@ int sata_pmp_attach(struct ata_device *dev)
517 513
518 rc = sata_pmp_init_links(ap, sata_pmp_gscr_ports(dev->gscr)); 514 rc = sata_pmp_init_links(ap, sata_pmp_gscr_ports(dev->gscr));
519 if (rc) { 515 if (rc) {
520 ata_dev_printk(dev, KERN_INFO, 516 ata_dev_info(dev, "failed to initialize PMP links\n");
521 "failed to initialize PMP links\n");
522 goto fail; 517 goto fail;
523 } 518 }
524 519
@@ -562,7 +557,7 @@ static void sata_pmp_detach(struct ata_device *dev)
562 struct ata_link *tlink; 557 struct ata_link *tlink;
563 unsigned long flags; 558 unsigned long flags;
564 559
565 ata_dev_printk(dev, KERN_INFO, "Port Multiplier detaching\n"); 560 ata_dev_info(dev, "Port Multiplier detaching\n");
566 561
567 WARN_ON(!ata_is_host_link(link) || dev->devno || 562 WARN_ON(!ata_is_host_link(link) || dev->devno ||
568 link->pmp != SATA_PMP_CTRL_PORT); 563 link->pmp != SATA_PMP_CTRL_PORT);
@@ -609,23 +604,23 @@ static int sata_pmp_same_pmp(struct ata_device *dev, const u32 *new_gscr)
609 new_nr_ports = sata_pmp_gscr_ports(new_gscr); 604 new_nr_ports = sata_pmp_gscr_ports(new_gscr);
610 605
611 if (old_vendor != new_vendor) { 606 if (old_vendor != new_vendor) {
612 ata_dev_printk(dev, KERN_INFO, "Port Multiplier " 607 ata_dev_info(dev,
613 "vendor mismatch '0x%x' != '0x%x'\n", 608 "Port Multiplier vendor mismatch '0x%x' != '0x%x'\n",
614 old_vendor, new_vendor); 609 old_vendor, new_vendor);
615 return 0; 610 return 0;
616 } 611 }
617 612
618 if (old_devid != new_devid) { 613 if (old_devid != new_devid) {
619 ata_dev_printk(dev, KERN_INFO, "Port Multiplier " 614 ata_dev_info(dev,
620 "device ID mismatch '0x%x' != '0x%x'\n", 615 "Port Multiplier device ID mismatch '0x%x' != '0x%x'\n",
621 old_devid, new_devid); 616 old_devid, new_devid);
622 return 0; 617 return 0;
623 } 618 }
624 619
625 if (old_nr_ports != new_nr_ports) { 620 if (old_nr_ports != new_nr_ports) {
626 ata_dev_printk(dev, KERN_INFO, "Port Multiplier " 621 ata_dev_info(dev,
627 "nr_ports mismatch '0x%x' != '0x%x'\n", 622 "Port Multiplier nr_ports mismatch '0x%x' != '0x%x'\n",
628 old_nr_ports, new_nr_ports); 623 old_nr_ports, new_nr_ports);
629 return 0; 624 return 0;
630 } 625 }
631 626
@@ -691,8 +686,7 @@ static int sata_pmp_revalidate(struct ata_device *dev, unsigned int new_class)
691 return 0; 686 return 0;
692 687
693 fail: 688 fail:
694 ata_dev_printk(dev, KERN_ERR, 689 ata_dev_err(dev, "PMP revalidation failed (errno=%d)\n", rc);
695 "PMP revalidation failed (errno=%d)\n", rc);
696 DPRINTK("EXIT, rc=%d\n", rc); 690 DPRINTK("EXIT, rc=%d\n", rc);
697 return rc; 691 return rc;
698} 692}
@@ -716,13 +710,14 @@ static int sata_pmp_revalidate_quick(struct ata_device *dev)
716 710
717 err_mask = sata_pmp_read(dev->link, SATA_PMP_GSCR_PROD_ID, &prod_id); 711 err_mask = sata_pmp_read(dev->link, SATA_PMP_GSCR_PROD_ID, &prod_id);
718 if (err_mask) { 712 if (err_mask) {
719 ata_dev_printk(dev, KERN_ERR, "failed to read PMP product ID " 713 ata_dev_err(dev,
720 "(Emask=0x%x)\n", err_mask); 714 "failed to read PMP product ID (Emask=0x%x)\n",
715 err_mask);
721 return -EIO; 716 return -EIO;
722 } 717 }
723 718
724 if (prod_id != dev->gscr[SATA_PMP_GSCR_PROD_ID]) { 719 if (prod_id != dev->gscr[SATA_PMP_GSCR_PROD_ID]) {
725 ata_dev_printk(dev, KERN_ERR, "PMP product ID mismatch\n"); 720 ata_dev_err(dev, "PMP product ID mismatch\n");
726 /* something weird is going on, request full PMP recovery */ 721 /* something weird is going on, request full PMP recovery */
727 return -EIO; 722 return -EIO;
728 } 723 }
@@ -777,8 +772,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
777 rc = ata_eh_reset(link, 0, prereset, softreset, hardreset, 772 rc = ata_eh_reset(link, 0, prereset, softreset, hardreset,
778 postreset); 773 postreset);
779 if (rc) { 774 if (rc) {
780 ata_link_printk(link, KERN_ERR, 775 ata_link_err(link, "failed to reset PMP, giving up\n");
781 "failed to reset PMP, giving up\n");
782 goto fail; 776 goto fail;
783 } 777 }
784 778
@@ -819,9 +813,9 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
819 ehc->i.action |= ATA_EH_RESET; 813 ehc->i.action |= ATA_EH_RESET;
820 goto retry; 814 goto retry;
821 } else { 815 } else {
822 ata_dev_printk(dev, KERN_ERR, "failed to recover PMP " 816 ata_dev_err(dev,
823 "after %d tries, giving up\n", 817 "failed to recover PMP after %d tries, giving up\n",
824 ATA_EH_PMP_TRIES); 818 ATA_EH_PMP_TRIES);
825 goto fail; 819 goto fail;
826 } 820 }
827 } 821 }
@@ -867,8 +861,9 @@ static int sata_pmp_eh_handle_disabled_links(struct ata_port *ap)
867 /* unconditionally clear SError.N */ 861 /* unconditionally clear SError.N */
868 rc = sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG); 862 rc = sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG);
869 if (rc) { 863 if (rc) {
870 ata_link_printk(link, KERN_ERR, "failed to clear " 864 ata_link_err(link,
871 "SError.N (errno=%d)\n", rc); 865 "failed to clear SError.N (errno=%d)\n",
866 rc);
872 return rc; 867 return rc;
873 } 868 }
874 869
@@ -890,7 +885,7 @@ static int sata_pmp_handle_link_fail(struct ata_link *link, int *link_tries)
890 885
891 /* disable this link */ 886 /* disable this link */
892 if (!(link->flags & ATA_LFLAG_DISABLED)) { 887 if (!(link->flags & ATA_LFLAG_DISABLED)) {
893 ata_link_printk(link, KERN_WARNING, 888 ata_link_warn(link,
894 "failed to recover link after %d tries, disabling\n", 889 "failed to recover link after %d tries, disabling\n",
895 ATA_EH_PMP_LINK_TRIES); 890 ATA_EH_PMP_LINK_TRIES);
896 891
@@ -974,7 +969,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
974 err_mask = sata_pmp_write(pmp_link, SATA_PMP_GSCR_FEAT_EN, 969 err_mask = sata_pmp_write(pmp_link, SATA_PMP_GSCR_FEAT_EN,
975 gscr[SATA_PMP_GSCR_FEAT_EN]); 970 gscr[SATA_PMP_GSCR_FEAT_EN]);
976 if (err_mask) { 971 if (err_mask) {
977 ata_link_printk(pmp_link, KERN_WARNING, 972 ata_link_warn(pmp_link,
978 "failed to disable NOTIFY (err_mask=0x%x)\n", 973 "failed to disable NOTIFY (err_mask=0x%x)\n",
979 err_mask); 974 err_mask);
980 goto pmp_fail; 975 goto pmp_fail;
@@ -1018,8 +1013,9 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
1018 err_mask = sata_pmp_write(pmp_link, SATA_PMP_GSCR_FEAT_EN, 1013 err_mask = sata_pmp_write(pmp_link, SATA_PMP_GSCR_FEAT_EN,
1019 gscr[SATA_PMP_GSCR_FEAT_EN]); 1014 gscr[SATA_PMP_GSCR_FEAT_EN]);
1020 if (err_mask) { 1015 if (err_mask) {
1021 ata_dev_printk(pmp_dev, KERN_ERR, "failed to write " 1016 ata_dev_err(pmp_dev,
1022 "PMP_FEAT_EN (Emask=0x%x)\n", err_mask); 1017 "failed to write PMP_FEAT_EN (Emask=0x%x)\n",
1018 err_mask);
1023 rc = -EIO; 1019 rc = -EIO;
1024 goto pmp_fail; 1020 goto pmp_fail;
1025 } 1021 }
@@ -1028,8 +1024,9 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
1028 /* check GSCR_ERROR */ 1024 /* check GSCR_ERROR */
1029 err_mask = sata_pmp_read(pmp_link, SATA_PMP_GSCR_ERROR, &gscr_error); 1025 err_mask = sata_pmp_read(pmp_link, SATA_PMP_GSCR_ERROR, &gscr_error);
1030 if (err_mask) { 1026 if (err_mask) {
1031 ata_dev_printk(pmp_dev, KERN_ERR, "failed to read " 1027 ata_dev_err(pmp_dev,
1032 "PMP_GSCR_ERROR (Emask=0x%x)\n", err_mask); 1028 "failed to read PMP_GSCR_ERROR (Emask=0x%x)\n",
1029 err_mask);
1033 rc = -EIO; 1030 rc = -EIO;
1034 goto pmp_fail; 1031 goto pmp_fail;
1035 } 1032 }
@@ -1043,17 +1040,16 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
1043 ata_ehi_hotplugged(&link->eh_context.i); 1040 ata_ehi_hotplugged(&link->eh_context.i);
1044 cnt++; 1041 cnt++;
1045 } else { 1042 } else {
1046 ata_link_printk(link, KERN_WARNING, 1043 ata_link_warn(link,
1047 "PHY status changed but maxed out on retries, " 1044 "PHY status changed but maxed out on retries, giving up\n");
1048 "giving up\n"); 1045 ata_link_warn(link,
1049 ata_link_printk(link, KERN_WARNING, 1046 "Manually issue scan to resume this link\n");
1050 "Manully issue scan to resume this link\n");
1051 } 1047 }
1052 } 1048 }
1053 1049
1054 if (cnt) { 1050 if (cnt) {
1055 ata_port_printk(ap, KERN_INFO, "PMP SError.N set for some " 1051 ata_port_info(ap,
1056 "ports, repeating recovery\n"); 1052 "PMP SError.N set for some ports, repeating recovery\n");
1057 goto retry; 1053 goto retry;
1058 } 1054 }
1059 1055
@@ -1081,9 +1077,8 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
1081 goto retry; 1077 goto retry;
1082 } 1078 }
1083 1079
1084 ata_port_printk(ap, KERN_ERR, 1080 ata_port_err(ap, "failed to recover PMP after %d tries, giving up\n",
1085 "failed to recover PMP after %d tries, giving up\n", 1081 ATA_EH_PMP_TRIES);
1086 ATA_EH_PMP_TRIES);
1087 sata_pmp_detach(pmp_dev); 1082 sata_pmp_detach(pmp_dev);
1088 ata_dev_disable(pmp_dev); 1083 ata_dev_disable(pmp_dev);
1089 1084
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 927f968e99d9..46d087f08607 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1108,8 +1108,7 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1108 /* configure draining */ 1108 /* configure draining */
1109 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL); 1109 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL);
1110 if (!buf) { 1110 if (!buf) {
1111 ata_dev_printk(dev, KERN_ERR, 1111 ata_dev_err(dev, "drain buffer allocation failed\n");
1112 "drain buffer allocation failed\n");
1113 return -ENOMEM; 1112 return -ENOMEM;
1114 } 1113 }
1115 1114
@@ -1127,7 +1126,7 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1127 * IDENTIFY_PACKET is executed as ATA_PROT_PIO. 1126 * IDENTIFY_PACKET is executed as ATA_PROT_PIO.
1128 */ 1127 */
1129 if (sdev->sector_size > PAGE_SIZE) 1128 if (sdev->sector_size > PAGE_SIZE)
1130 ata_dev_printk(dev, KERN_WARNING, 1129 ata_dev_warn(dev,
1131 "sector_size=%u > PAGE_SIZE, PIO may malfunction\n", 1130 "sector_size=%u > PAGE_SIZE, PIO may malfunction\n",
1132 sdev->sector_size); 1131 sdev->sector_size);
1133 1132
@@ -1784,8 +1783,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1784 if (cmd->sc_data_direction == DMA_FROM_DEVICE || 1783 if (cmd->sc_data_direction == DMA_FROM_DEVICE ||
1785 cmd->sc_data_direction == DMA_TO_DEVICE) { 1784 cmd->sc_data_direction == DMA_TO_DEVICE) {
1786 if (unlikely(scsi_bufflen(cmd) < 1)) { 1785 if (unlikely(scsi_bufflen(cmd) < 1)) {
1787 ata_dev_printk(dev, KERN_WARNING, 1786 ata_dev_warn(dev, "WARNING: zero len r/w req\n");
1788 "WARNING: zero len r/w req\n");
1789 goto err_did; 1787 goto err_did;
1790 } 1788 }
1791 1789
@@ -2969,9 +2967,8 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2969 * with the cached multi_count of libata 2967 * with the cached multi_count of libata
2970 */ 2968 */
2971 if (multi_count != dev->multi_count) 2969 if (multi_count != dev->multi_count)
2972 ata_dev_printk(dev, KERN_WARNING, 2970 ata_dev_warn(dev, "invalid multi_count %u ignored\n",
2973 "invalid multi_count %u ignored\n", 2971 multi_count);
2974 multi_count);
2975 } 2972 }
2976 2973
2977 /* 2974 /*
@@ -3466,9 +3463,8 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
3466 goto repeat; 3463 goto repeat;
3467 } 3464 }
3468 3465
3469 ata_port_printk(ap, KERN_ERR, "WARNING: synchronous SCSI scan " 3466 ata_port_err(ap,
3470 "failed without making any progress,\n" 3467 "WARNING: synchronous SCSI scan failed without making any progress, switching to async\n");
3471 " switching to async\n");
3472 } 3468 }
3473 3469
3474 queue_delayed_work(system_long_wq, &ap->hotplug_task, 3470 queue_delayed_work(system_long_wq, &ap->hotplug_task,
@@ -3550,8 +3546,8 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
3550 mutex_unlock(&ap->scsi_host->scan_mutex); 3546 mutex_unlock(&ap->scsi_host->scan_mutex);
3551 3547
3552 if (sdev) { 3548 if (sdev) {
3553 ata_dev_printk(dev, KERN_INFO, "detaching (SCSI %s)\n", 3549 ata_dev_info(dev, "detaching (SCSI %s)\n",
3554 dev_name(&sdev->sdev_gendev)); 3550 dev_name(&sdev->sdev_gendev));
3555 3551
3556 scsi_remove_device(sdev); 3552 scsi_remove_device(sdev);
3557 scsi_device_put(sdev); 3553 scsi_device_put(sdev);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index b1b926c55a72..c24127dd6ef2 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -227,9 +227,9 @@ int ata_sff_busy_sleep(struct ata_port *ap,
227 } 227 }
228 228
229 if (status != 0xff && (status & ATA_BUSY)) 229 if (status != 0xff && (status & ATA_BUSY))
230 ata_port_printk(ap, KERN_WARNING, 230 ata_port_warn(ap,
231 "port is slow to respond, please be patient " 231 "port is slow to respond, please be patient (Status 0x%x)\n",
232 "(Status 0x%x)\n", status); 232 status);
233 233
234 timeout = ata_deadline(timer_start, tmout); 234 timeout = ata_deadline(timer_start, tmout);
235 while (status != 0xff && (status & ATA_BUSY) && 235 while (status != 0xff && (status & ATA_BUSY) &&
@@ -242,9 +242,9 @@ int ata_sff_busy_sleep(struct ata_port *ap,
242 return -ENODEV; 242 return -ENODEV;
243 243
244 if (status & ATA_BUSY) { 244 if (status & ATA_BUSY) {
245 ata_port_printk(ap, KERN_ERR, "port failed to respond " 245 ata_port_err(ap,
246 "(%lu secs, Status 0x%x)\n", 246 "port failed to respond (%lu secs, Status 0x%x)\n",
247 DIV_ROUND_UP(tmout, 1000), status); 247 DIV_ROUND_UP(tmout, 1000), status);
248 return -EBUSY; 248 return -EBUSY;
249 } 249 }
250 250
@@ -350,8 +350,8 @@ static void ata_dev_select(struct ata_port *ap, unsigned int device,
350 unsigned int wait, unsigned int can_sleep) 350 unsigned int wait, unsigned int can_sleep)
351{ 351{
352 if (ata_msg_probe(ap)) 352 if (ata_msg_probe(ap))
353 ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, " 353 ata_port_info(ap, "ata_dev_select: ENTER, device %u, wait %u\n",
354 "device %u, wait %u\n", device, wait); 354 device, wait);
355 355
356 if (wait) 356 if (wait)
357 ata_wait_idle(ap); 357 ata_wait_idle(ap);
@@ -1333,9 +1333,10 @@ void ata_sff_flush_pio_task(struct ata_port *ap)
1333 1333
1334 cancel_delayed_work_sync(&ap->sff_pio_task); 1334 cancel_delayed_work_sync(&ap->sff_pio_task);
1335 ap->hsm_task_state = HSM_ST_IDLE; 1335 ap->hsm_task_state = HSM_ST_IDLE;
1336 ap->sff_pio_task_link = NULL;
1336 1337
1337 if (ata_msg_ctl(ap)) 1338 if (ata_msg_ctl(ap))
1338 ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __func__); 1339 ata_port_dbg(ap, "%s: EXIT\n", __func__);
1339} 1340}
1340 1341
1341static void ata_sff_pio_task(struct work_struct *work) 1342static void ata_sff_pio_task(struct work_struct *work)
@@ -1513,7 +1514,7 @@ static unsigned int ata_sff_idle_irq(struct ata_port *ap)
1513 ap->ops->sff_check_status(ap); 1514 ap->ops->sff_check_status(ap);
1514 if (ap->ops->sff_irq_clear) 1515 if (ap->ops->sff_irq_clear)
1515 ap->ops->sff_irq_clear(ap); 1516 ap->ops->sff_irq_clear(ap);
1516 ata_port_printk(ap, KERN_WARNING, "irq trap\n"); 1517 ata_port_warn(ap, "irq trap\n");
1517 return 1; 1518 return 1;
1518 } 1519 }
1519#endif 1520#endif
@@ -1711,7 +1712,7 @@ void ata_sff_lost_interrupt(struct ata_port *ap)
1711 1712
1712 /* There was a command running, we are no longer busy and we have 1713 /* There was a command running, we are no longer busy and we have
1713 no interrupt. */ 1714 no interrupt. */
1714 ata_port_printk(ap, KERN_WARNING, "lost interrupt (Status 0x%x)\n", 1715 ata_port_warn(ap, "lost interrupt (Status 0x%x)\n",
1715 status); 1716 status);
1716 /* Run the host interrupt logic as if the interrupt had not been 1717 /* Run the host interrupt logic as if the interrupt had not been
1717 lost */ 1718 lost */
@@ -1798,8 +1799,9 @@ int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
1798 if (!ata_link_offline(link)) { 1799 if (!ata_link_offline(link)) {
1799 rc = ata_sff_wait_ready(link, deadline); 1800 rc = ata_sff_wait_ready(link, deadline);
1800 if (rc && rc != -ENODEV) { 1801 if (rc && rc != -ENODEV) {
1801 ata_link_printk(link, KERN_WARNING, "device not ready " 1802 ata_link_warn(link,
1802 "(errno=%d), forcing hardreset\n", rc); 1803 "device not ready (errno=%d), forcing hardreset\n",
1804 rc);
1803 ehc->i.action |= ATA_EH_HARDRESET; 1805 ehc->i.action |= ATA_EH_HARDRESET;
1804 } 1806 }
1805 } 1807 }
@@ -2056,7 +2058,7 @@ int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
2056 rc = ata_bus_softreset(ap, devmask, deadline); 2058 rc = ata_bus_softreset(ap, devmask, deadline);
2057 /* if link is occupied, -ENODEV too is an error */ 2059 /* if link is occupied, -ENODEV too is an error */
2058 if (rc && (rc != -ENODEV || sata_scr_valid(link))) { 2060 if (rc && (rc != -ENODEV || sata_scr_valid(link))) {
2059 ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc); 2061 ata_link_err(link, "SRST failed (errno=%d)\n", rc);
2060 return rc; 2062 return rc;
2061 } 2063 }
2062 2064
@@ -2170,8 +2172,7 @@ void ata_sff_drain_fifo(struct ata_queued_cmd *qc)
2170 2172
2171 /* Can become DEBUG later */ 2173 /* Can become DEBUG later */
2172 if (count) 2174 if (count)
2173 ata_port_printk(ap, KERN_DEBUG, 2175 ata_port_dbg(ap, "drained %d bytes to clear DRQ\n", count);
2174 "drained %d bytes to clear DRQ.\n", count);
2175 2176
2176} 2177}
2177EXPORT_SYMBOL_GPL(ata_sff_drain_fifo); 2178EXPORT_SYMBOL_GPL(ata_sff_drain_fifo);
@@ -2316,9 +2317,9 @@ int ata_pci_sff_init_host(struct ata_host *host)
2316 rc = pcim_iomap_regions(pdev, 0x3 << base, 2317 rc = pcim_iomap_regions(pdev, 0x3 << base,
2317 dev_driver_string(gdev)); 2318 dev_driver_string(gdev));
2318 if (rc) { 2319 if (rc) {
2319 dev_printk(KERN_WARNING, gdev, 2320 dev_warn(gdev,
2320 "failed to request/iomap BARs for port %d " 2321 "failed to request/iomap BARs for port %d (errno=%d)\n",
2321 "(errno=%d)\n", i, rc); 2322 i, rc);
2322 if (rc == -EBUSY) 2323 if (rc == -EBUSY)
2323 pcim_pin_device(pdev); 2324 pcim_pin_device(pdev);
2324 ap->ops = &ata_dummy_port_ops; 2325 ap->ops = &ata_dummy_port_ops;
@@ -2340,7 +2341,7 @@ int ata_pci_sff_init_host(struct ata_host *host)
2340 } 2341 }
2341 2342
2342 if (!mask) { 2343 if (!mask) {
2343 dev_printk(KERN_ERR, gdev, "no available native port\n"); 2344 dev_err(gdev, "no available native port\n");
2344 return -ENODEV; 2345 return -ENODEV;
2345 } 2346 }
2346 2347
@@ -2375,8 +2376,7 @@ int ata_pci_sff_prepare_host(struct pci_dev *pdev,
2375 2376
2376 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2); 2377 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
2377 if (!host) { 2378 if (!host) {
2378 dev_printk(KERN_ERR, &pdev->dev, 2379 dev_err(&pdev->dev, "failed to allocate ATA host\n");
2379 "failed to allocate ATA host\n");
2380 rc = -ENOMEM; 2380 rc = -ENOMEM;
2381 goto err_out; 2381 goto err_out;
2382 } 2382 }
@@ -2542,8 +2542,7 @@ int ata_pci_sff_init_one(struct pci_dev *pdev,
2542 2542
2543 pi = ata_sff_find_valid_pi(ppi); 2543 pi = ata_sff_find_valid_pi(ppi);
2544 if (!pi) { 2544 if (!pi) {
2545 dev_printk(KERN_ERR, &pdev->dev, 2545 dev_err(&pdev->dev, "no valid port_info specified\n");
2546 "no valid port_info specified\n");
2547 return -EINVAL; 2546 return -EINVAL;
2548 } 2547 }
2549 2548
@@ -3164,8 +3163,7 @@ static void ata_bmdma_nodma(struct ata_host *host, const char *reason)
3164{ 3163{
3165 int i; 3164 int i;
3166 3165
3167 dev_printk(KERN_ERR, host->dev, "BMDMA: %s, falling back to PIO\n", 3166 dev_err(host->dev, "BMDMA: %s, falling back to PIO\n", reason);
3168 reason);
3169 3167
3170 for (i = 0; i < 2; i++) { 3168 for (i = 0; i < 2; i++) {
3171 host->ports[i]->mwdma_mask = 0; 3169 host->ports[i]->mwdma_mask = 0;
@@ -3297,8 +3295,7 @@ int ata_pci_bmdma_init_one(struct pci_dev *pdev,
3297 3295
3298 pi = ata_sff_find_valid_pi(ppi); 3296 pi = ata_sff_find_valid_pi(ppi);
3299 if (!pi) { 3297 if (!pi) {
3300 dev_printk(KERN_ERR, &pdev->dev, 3298 dev_err(&pdev->dev, "no valid port_info specified\n");
3301 "no valid port_info specified\n");
3302 return -EINVAL; 3299 return -EINVAL;
3303 } 3300 }
3304 3301
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index 91949d997555..54145edf50e8 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -195,8 +195,6 @@ static int pacpi_port_start(struct ata_port *ap)
195 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 195 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
196 struct pata_acpi *acpi; 196 struct pata_acpi *acpi;
197 197
198 int ret;
199
200 if (ap->acpi_handle == NULL) 198 if (ap->acpi_handle == NULL)
201 return -ENODEV; 199 return -ENODEV;
202 200
@@ -205,11 +203,7 @@ static int pacpi_port_start(struct ata_port *ap)
205 return -ENOMEM; 203 return -ENOMEM;
206 acpi->mask[0] = pacpi_discover_modes(ap, &ap->link.device[0]); 204 acpi->mask[0] = pacpi_discover_modes(ap, &ap->link.device[0]);
207 acpi->mask[1] = pacpi_discover_modes(ap, &ap->link.device[1]); 205 acpi->mask[1] = pacpi_discover_modes(ap, &ap->link.device[1]);
208 ret = ata_bmdma_port_start(ap); 206 return ata_bmdma_port_start(ap);
209 if (ret < 0)
210 return ret;
211
212 return ret;
213} 207}
214 208
215static struct scsi_host_template pacpi_sht = { 209static struct scsi_host_template pacpi_sht = {
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 794ec6e3275d..cadd67998bac 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -287,10 +287,10 @@ static void ali_warn_atapi_dma(struct ata_device *adev)
287 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; 287 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
288 288
289 if (print_info && adev->class == ATA_DEV_ATAPI && !ali_atapi_dma) { 289 if (print_info && adev->class == ATA_DEV_ATAPI && !ali_atapi_dma) {
290 ata_dev_printk(adev, KERN_WARNING, 290 ata_dev_warn(adev,
291 "WARNING: ATAPI DMA disabled for reliability issues. It can be enabled\n"); 291 "WARNING: ATAPI DMA disabled for reliability issues. It can be enabled\n");
292 ata_dev_printk(adev, KERN_WARNING, 292 ata_dev_warn(adev,
293 "WARNING: via pata_ali.atapi_dma modparam or corresponding sysfs node.\n"); 293 "WARNING: via pata_ali.atapi_dma modparam or corresponding sysfs node.\n");
294 } 294 }
295} 295}
296 296
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index b0975a5ad8c4..dc6b5dae0463 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -60,7 +60,7 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
60 UT = T / 2; 60 UT = T / 2;
61 61
62 if (ata_timing_compute(adev, speed, &at, T, UT) < 0) { 62 if (ata_timing_compute(adev, speed, &at, T, UT) < 0) {
63 dev_printk(KERN_ERR, &pdev->dev, "unknown mode %d.\n", speed); 63 dev_err(&pdev->dev, "unknown mode %d\n", speed);
64 return; 64 return;
65 } 65 }
66 66
@@ -311,7 +311,7 @@ static unsigned long nv_mode_filter(struct ata_device *dev,
311 cable detection result */ 311 cable detection result */
312 limit |= ata_pack_xfermask(ATA_PIO4, ATA_MWDMA2, ATA_UDMA2); 312 limit |= ata_pack_xfermask(ATA_PIO4, ATA_MWDMA2, ATA_UDMA2);
313 313
314 ata_port_printk(ap, KERN_DEBUG, "nv_mode_filter: 0x%lx&0x%lx->0x%lx, " 314 ata_port_dbg(ap, "nv_mode_filter: 0x%lx&0x%lx->0x%lx, "
315 "BIOS=0x%lx (0x%x) ACPI=0x%lx%s\n", 315 "BIOS=0x%lx (0x%x) ACPI=0x%lx%s\n",
316 xfer_mask, limit, xfer_mask & limit, bios_limit, 316 xfer_mask, limit, xfer_mask & limit, bios_limit,
317 saved_udma, acpi_limit, acpi_str); 317 saved_udma, acpi_limit, acpi_str);
@@ -530,14 +530,12 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
530 } 530 }
531 }; 531 };
532 const struct ata_port_info *ppi[] = { NULL, NULL }; 532 const struct ata_port_info *ppi[] = { NULL, NULL };
533 static int printed_version;
534 int type = id->driver_data; 533 int type = id->driver_data;
535 void *hpriv = NULL; 534 void *hpriv = NULL;
536 u8 fifo; 535 u8 fifo;
537 int rc; 536 int rc;
538 537
539 if (!printed_version++) 538 ata_print_version_once(&pdev->dev, DRV_VERSION);
540 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
541 539
542 rc = pcim_enable_device(pdev); 540 rc = pcim_enable_device(pdev);
543 if (rc) 541 if (rc)
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 2215632e4b31..78a93b690959 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -346,7 +346,6 @@ static struct ata_port_operations artop6260_ops = {
346 346
347static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 347static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
348{ 348{
349 static int printed_version;
350 static const struct ata_port_info info_6210 = { 349 static const struct ata_port_info info_6210 = {
351 .flags = ATA_FLAG_SLAVE_POSS, 350 .flags = ATA_FLAG_SLAVE_POSS,
352 .pio_mask = ATA_PIO4, 351 .pio_mask = ATA_PIO4,
@@ -378,9 +377,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
378 const struct ata_port_info *ppi[] = { NULL, NULL }; 377 const struct ata_port_info *ppi[] = { NULL, NULL };
379 int rc; 378 int rc;
380 379
381 if (!printed_version++) 380 ata_print_version_once(&pdev->dev, DRV_VERSION);
382 dev_printk(KERN_DEBUG, &pdev->dev,
383 "version " DRV_VERSION "\n");
384 381
385 rc = pcim_enable_device(pdev); 382 rc = pcim_enable_device(pdev);
386 if (rc) 383 if (rc)
diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c
index 95295935dd95..3cfabb262af2 100644
--- a/drivers/ata/pata_atp867x.c
+++ b/drivers/ata/pata_atp867x.c
@@ -470,7 +470,7 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)
470 } 470 }
471 471
472 if (!mask) { 472 if (!mask) {
473 dev_printk(KERN_ERR, gdev, "no available native port\n"); 473 dev_err(gdev, "no available native port\n");
474 return -ENODEV; 474 return -ENODEV;
475 } 475 }
476 476
@@ -487,7 +487,6 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)
487static int atp867x_init_one(struct pci_dev *pdev, 487static int atp867x_init_one(struct pci_dev *pdev,
488 const struct pci_device_id *id) 488 const struct pci_device_id *id)
489{ 489{
490 static int printed_version;
491 static const struct ata_port_info info_867x = { 490 static const struct ata_port_info info_867x = {
492 .flags = ATA_FLAG_SLAVE_POSS, 491 .flags = ATA_FLAG_SLAVE_POSS,
493 .pio_mask = ATA_PIO4, 492 .pio_mask = ATA_PIO4,
@@ -499,8 +498,7 @@ static int atp867x_init_one(struct pci_dev *pdev,
499 const struct ata_port_info *ppi[] = { &info_867x, NULL }; 498 const struct ata_port_info *ppi[] = { &info_867x, NULL };
500 int rc; 499 int rc;
501 500
502 if (!printed_version++) 501 ata_print_version_once(&pdev->dev, DRV_VERSION);
503 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
504 502
505 rc = pcim_enable_device(pdev); 503 rc = pcim_enable_device(pdev);
506 if (rc) 504 if (rc)
@@ -511,15 +509,14 @@ static int atp867x_init_one(struct pci_dev *pdev,
511 509
512 host = ata_host_alloc_pinfo(&pdev->dev, ppi, ATP867X_NUM_PORTS); 510 host = ata_host_alloc_pinfo(&pdev->dev, ppi, ATP867X_NUM_PORTS);
513 if (!host) { 511 if (!host) {
514 dev_printk(KERN_ERR, &pdev->dev, 512 dev_err(&pdev->dev, "failed to allocate ATA host\n");
515 "failed to allocate ATA host\n");
516 rc = -ENOMEM; 513 rc = -ENOMEM;
517 goto err_out; 514 goto err_out;
518 } 515 }
519 516
520 rc = atp867x_ata_pci_sff_init_host(host); 517 rc = atp867x_ata_pci_sff_init_host(host);
521 if (rc) { 518 if (rc) {
522 dev_printk(KERN_ERR, &pdev->dev, "failed to init host\n"); 519 dev_err(&pdev->dev, "failed to init host\n");
523 goto err_out; 520 goto err_out;
524 } 521 }
525 522
@@ -528,7 +525,7 @@ static int atp867x_init_one(struct pci_dev *pdev,
528 rc = ata_host_activate(host, pdev->irq, ata_bmdma_interrupt, 525 rc = ata_host_activate(host, pdev->irq, ata_bmdma_interrupt,
529 IRQF_SHARED, &atp867x_sht); 526 IRQF_SHARED, &atp867x_sht);
530 if (rc) 527 if (rc)
531 dev_printk(KERN_ERR, &pdev->dev, "failed to activate host\n"); 528 dev_err(&pdev->dev, "failed to activate host\n");
532 529
533err_out: 530err_out:
534 return rc; 531 return rc;
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index ea64967000ff..bd987bb082eb 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1129,7 +1129,7 @@ static int bfin_softreset(struct ata_link *link, unsigned int *classes,
1129 /* issue bus reset */ 1129 /* issue bus reset */
1130 err_mask = bfin_bus_softreset(ap, devmask); 1130 err_mask = bfin_bus_softreset(ap, devmask);
1131 if (err_mask) { 1131 if (err_mask) {
1132 ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n", 1132 ata_port_err(ap, "SRST failed (err_mask=0x%x)\n",
1133 err_mask); 1133 err_mask);
1134 return -EIO; 1134 return -EIO;
1135 } 1135 }
@@ -1382,7 +1382,7 @@ idle_irq:
1382#ifdef ATA_IRQ_TRAP 1382#ifdef ATA_IRQ_TRAP
1383 if ((ap->stats.idle_irq % 1000) == 0) { 1383 if ((ap->stats.idle_irq % 1000) == 0) {
1384 ap->ops->irq_ack(ap, 0); /* debug trap */ 1384 ap->ops->irq_ack(ap, 0); /* debug trap */
1385 ata_port_printk(ap, KERN_WARNING, "irq trap\n"); 1385 ata_port_warn(ap, "irq trap\n");
1386 return 1; 1386 return 1;
1387 } 1387 }
1388#endif 1388#endif
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index e3254fcff0f1..9ddcddc66a20 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -149,8 +149,7 @@ static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_devi
149 ppi[1] = &pi; 149 ppi[1] = &pi;
150 150
151 if ((pcicfg & 0x40) == 0) { 151 if ((pcicfg & 0x40) == 0) {
152 dev_printk(KERN_WARNING, &pdev->dev, 152 dev_warn(&pdev->dev, "DMA mode disabled. Enabling.\n");
153 "DMA mode disabled. Enabling.\n");
154 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40); 153 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
155 } 154 }
156 155
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index a08834758ea2..aca47e4e29ea 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -263,7 +263,6 @@ static struct ata_port_operations efar_ops = {
263 263
264static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 264static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
265{ 265{
266 static int printed_version;
267 static const struct ata_port_info info = { 266 static const struct ata_port_info info = {
268 .flags = ATA_FLAG_SLAVE_POSS, 267 .flags = ATA_FLAG_SLAVE_POSS,
269 .pio_mask = ATA_PIO4, 268 .pio_mask = ATA_PIO4,
@@ -273,9 +272,7 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
273 }; 272 };
274 const struct ata_port_info *ppi[] = { &info, &info }; 273 const struct ata_port_info *ppi[] = { &info, &info };
275 274
276 if (!printed_version++) 275 ata_print_version_once(&pdev->dev, DRV_VERSION);
277 dev_printk(KERN_DEBUG, &pdev->dev,
278 "version " DRV_VERSION "\n");
279 276
280 return ata_pci_bmdma_init_one(pdev, ppi, &efar_sht, NULL, 277 return ata_pci_bmdma_init_one(pdev, ppi, &efar_sht, NULL,
281 ATA_HOST_PARALLEL_SCAN); 278 ATA_HOST_PARALLEL_SCAN);
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index 24d7df81546b..b3042dab08bb 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -185,7 +185,6 @@ static void hpt3x3_init_chipset(struct pci_dev *dev)
185 185
186static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 186static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
187{ 187{
188 static int printed_version;
189 static const struct ata_port_info info = { 188 static const struct ata_port_info info = {
190 .flags = ATA_FLAG_SLAVE_POSS, 189 .flags = ATA_FLAG_SLAVE_POSS,
191 .pio_mask = ATA_PIO4, 190 .pio_mask = ATA_PIO4,
@@ -206,8 +205,7 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
206 205
207 hpt3x3_init_chipset(pdev); 206 hpt3x3_init_chipset(pdev);
208 207
209 if (!printed_version++) 208 ata_print_version_once(&pdev->dev, DRV_VERSION);
210 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
211 209
212 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2); 210 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
213 if (!host) 211 if (!host)
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c
index 9f2889fe43b2..52e7e7b8c74f 100644
--- a/drivers/ata/pata_icside.c
+++ b/drivers/ata/pata_icside.c
@@ -210,8 +210,8 @@ static void pata_icside_set_dmamode(struct ata_port *ap, struct ata_device *adev
210 else 210 else
211 iomd_type = 'A', cycle = 562; 211 iomd_type = 'A', cycle = 562;
212 212
213 ata_dev_printk(adev, KERN_INFO, "timings: act %dns rec %dns cyc %dns (%c)\n", 213 ata_dev_info(adev, "timings: act %dns rec %dns cyc %dns (%c)\n",
214 t.active, t.recover, t.cycle, iomd_type); 214 t.active, t.recover, t.cycle, iomd_type);
215 215
216 state->port[ap->port_no].speed[adev->devno] = cycle; 216 state->port[ap->port_no].speed[adev->devno] = cycle;
217} 217}
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index 4d142a2ab8fd..998af0e629b1 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -258,7 +258,6 @@ static struct ata_port_operations it8213_ops = {
258 258
259static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 259static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
260{ 260{
261 static int printed_version;
262 static const struct ata_port_info info = { 261 static const struct ata_port_info info = {
263 .flags = ATA_FLAG_SLAVE_POSS, 262 .flags = ATA_FLAG_SLAVE_POSS,
264 .pio_mask = ATA_PIO4, 263 .pio_mask = ATA_PIO4,
@@ -269,9 +268,7 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
269 /* Current IT8213 stuff is single port */ 268 /* Current IT8213 stuff is single port */
270 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; 269 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
271 270
272 if (!printed_version++) 271 ata_print_version_once(&pdev->dev, DRV_VERSION);
273 dev_printk(KERN_DEBUG, &pdev->dev,
274 "version " DRV_VERSION "\n");
275 272
276 return ata_pci_bmdma_init_one(pdev, ppi, &it8213_sht, NULL, 0); 273 return ata_pci_bmdma_init_one(pdev, ppi, &it8213_sht, NULL, 0);
277} 274}
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 2d15f2548a10..62c5d00abd2e 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -473,12 +473,12 @@ static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unus
473 /* We do need the right mode information for DMA or PIO 473 /* We do need the right mode information for DMA or PIO
474 and this comes from the current configuration flags */ 474 and this comes from the current configuration flags */
475 if (ata_id_has_dma(dev->id)) { 475 if (ata_id_has_dma(dev->id)) {
476 ata_dev_printk(dev, KERN_INFO, "configured for DMA\n"); 476 ata_dev_info(dev, "configured for DMA\n");
477 dev->xfer_mode = XFER_MW_DMA_0; 477 dev->xfer_mode = XFER_MW_DMA_0;
478 dev->xfer_shift = ATA_SHIFT_MWDMA; 478 dev->xfer_shift = ATA_SHIFT_MWDMA;
479 dev->flags &= ~ATA_DFLAG_PIO; 479 dev->flags &= ~ATA_DFLAG_PIO;
480 } else { 480 } else {
481 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); 481 ata_dev_info(dev, "configured for PIO\n");
482 dev->xfer_mode = XFER_PIO_0; 482 dev->xfer_mode = XFER_PIO_0;
483 dev->xfer_shift = ATA_SHIFT_PIO; 483 dev->xfer_shift = ATA_SHIFT_PIO;
484 dev->flags |= ATA_DFLAG_PIO; 484 dev->flags |= ATA_DFLAG_PIO;
@@ -508,12 +508,12 @@ static void it821x_dev_config(struct ata_device *adev)
508 508
509 if (strstr(model_num, "Integrated Technology Express")) { 509 if (strstr(model_num, "Integrated Technology Express")) {
510 /* RAID mode */ 510 /* RAID mode */
511 ata_dev_printk(adev, KERN_INFO, "%sRAID%d volume", 511 ata_dev_info(adev, "%sRAID%d volume",
512 adev->id[147]?"Bootable ":"", 512 adev->id[147] ? "Bootable " : "",
513 adev->id[129]); 513 adev->id[129]);
514 if (adev->id[129] != 1) 514 if (adev->id[129] != 1)
515 printk("(%dK stripe)", adev->id[146]); 515 pr_cont("(%dK stripe)", adev->id[146]);
516 printk(".\n"); 516 pr_cont("\n");
517 } 517 }
518 /* This is a controller firmware triggered funny, don't 518 /* This is a controller firmware triggered funny, don't
519 report the drive faulty! */ 519 report the drive faulty! */
@@ -610,7 +610,7 @@ static void it821x_display_disk(int n, u8 *buf)
610 char *cbl = "(40 wire cable)"; 610 char *cbl = "(40 wire cable)";
611 611
612 static const char *types[5] = { 612 static const char *types[5] = {
613 "RAID0", "RAID1" "RAID 0+1", "JBOD", "DISK" 613 "RAID0", "RAID1", "RAID 0+1", "JBOD", "DISK"
614 }; 614 };
615 615
616 if (buf[52] > 4) /* No Disk */ 616 if (buf[52] > 4) /* No Disk */
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index f6b3f995f58a..15b64311fe0a 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_link *link, struct ata_device **error)
31 struct ata_device *dev; 31 struct ata_device *dev;
32 32
33 ata_for_each_dev(dev, link, ENABLED) { 33 ata_for_each_dev(dev, link, ENABLED) {
34 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); 34 ata_dev_info(dev, "configured for PIO0\n");
35 dev->pio_mode = XFER_PIO_0; 35 dev->pio_mode = XFER_PIO_0;
36 dev->xfer_mode = XFER_PIO_0; 36 dev->xfer_mode = XFER_PIO_0;
37 dev->xfer_shift = ATA_SHIFT_PIO; 37 dev->xfer_shift = ATA_SHIFT_PIO;
@@ -181,7 +181,7 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
181 181
182 ixp4xx_setup_port(ap, data, cs0->start, cs1->start); 182 ixp4xx_setup_port(ap, data, cs0->start, cs1->start);
183 183
184 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 184 ata_print_version_once(&pdev->dev, DRV_VERSION);
185 185
186 /* activate host */ 186 /* activate host */
187 return ata_host_activate(host, irq, ata_sff_interrupt, 0, &ixp4xx_sht); 187 return ata_host_activate(host, irq, ata_sff_interrupt, 0, &ixp4xx_sht);
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 6bd9425ba5ab..d960f8e9e8b1 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -213,7 +213,7 @@ static int legacy_set_mode(struct ata_link *link, struct ata_device **unused)
213 struct ata_device *dev; 213 struct ata_device *dev;
214 214
215 ata_for_each_dev(dev, link, ENABLED) { 215 ata_for_each_dev(dev, link, ENABLED) {
216 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); 216 ata_dev_info(dev, "configured for PIO\n");
217 dev->pio_mode = XFER_PIO_0; 217 dev->pio_mode = XFER_PIO_0;
218 dev->xfer_mode = XFER_PIO_0; 218 dev->xfer_mode = XFER_PIO_0;
219 dev->xfer_shift = ATA_SHIFT_PIO; 219 dev->xfer_shift = ATA_SHIFT_PIO;
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 46f589edccdb..b057e3fa44bc 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -772,8 +772,9 @@ static void pata_macio_reset_hw(struct pata_macio_priv *priv, int resume)
772 pci_restore_state(priv->pdev); 772 pci_restore_state(priv->pdev);
773 rc = pcim_enable_device(priv->pdev); 773 rc = pcim_enable_device(priv->pdev);
774 if (rc) 774 if (rc)
775 dev_printk(KERN_ERR, &priv->pdev->dev, 775 dev_err(&priv->pdev->dev,
776 "Failed to enable device after resume (%d)\n", rc); 776 "Failed to enable device after resume (%d)\n",
777 rc);
777 else 778 else
778 pci_set_master(priv->pdev); 779 pci_set_master(priv->pdev);
779 } 780 }
@@ -812,7 +813,7 @@ static int pata_macio_slave_config(struct scsi_device *sdev)
812 blk_queue_update_dma_pad(sdev->request_queue, 31); 813 blk_queue_update_dma_pad(sdev->request_queue, 31);
813 814
814 /* Tell the world about it */ 815 /* Tell the world about it */
815 ata_dev_printk(dev, KERN_INFO, "OHare alignment limits applied\n"); 816 ata_dev_info(dev, "OHare alignment limits applied\n");
816 return 0; 817 return 0;
817 } 818 }
818 819
@@ -838,8 +839,7 @@ static int pata_macio_slave_config(struct scsi_device *sdev)
838 cmd | PCI_COMMAND_INVALIDATE); 839 cmd | PCI_COMMAND_INVALIDATE);
839 840
840 /* Tell the world about it */ 841 /* Tell the world about it */
841 ata_dev_printk(dev, KERN_INFO, 842 ata_dev_info(dev, "K2/Shasta alignment limits applied\n");
842 "K2/Shasta alignment limits applied\n");
843 } 843 }
844 844
845 return 0; 845 return 0;
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index d8d9c5807740..9dc16df84191 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -152,15 +152,13 @@ static struct ata_port_operations mpiix_port_ops = {
152static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) 152static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
153{ 153{
154 /* Single threaded by the PCI probe logic */ 154 /* Single threaded by the PCI probe logic */
155 static int printed_version;
156 struct ata_host *host; 155 struct ata_host *host;
157 struct ata_port *ap; 156 struct ata_port *ap;
158 void __iomem *cmd_addr, *ctl_addr; 157 void __iomem *cmd_addr, *ctl_addr;
159 u16 idetim; 158 u16 idetim;
160 int cmd, ctl, irq; 159 int cmd, ctl, irq;
161 160
162 if (!printed_version++) 161 ata_print_version_once(&dev->dev, DRV_VERSION);
163 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
164 162
165 host = ata_host_alloc(&dev->dev, 1); 163 host = ata_host_alloc(&dev->dev, 1);
166 if (!host) 164 if (!host)
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index 3eb921c746a1..9979a43bc596 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -57,7 +57,6 @@ static struct ata_port_operations netcell_ops = {
57 57
58static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 58static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
59{ 59{
60 static int printed_version;
61 static const struct ata_port_info info = { 60 static const struct ata_port_info info = {
62 .flags = ATA_FLAG_SLAVE_POSS, 61 .flags = ATA_FLAG_SLAVE_POSS,
63 /* Actually we don't really care about these as the 62 /* Actually we don't really care about these as the
@@ -70,9 +69,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
70 const struct ata_port_info *port_info[] = { &info, NULL }; 69 const struct ata_port_info *port_info[] = { &info, NULL };
71 int rc; 70 int rc;
72 71
73 if (!printed_version++) 72 ata_print_version_once(&pdev->dev, DRV_VERSION);
74 dev_printk(KERN_DEBUG, &pdev->dev,
75 "version " DRV_VERSION "\n");
76 73
77 rc = pcim_enable_device(pdev); 74 rc = pcim_enable_device(pdev);
78 if (rc) 75 if (rc)
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index 2110863bb3db..31d5986537a3 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -86,7 +86,7 @@ static void ns87410_set_piomode(struct ata_port *ap, struct ata_device *adev)
86 idefr &= ~0x04; 86 idefr &= ~0x04;
87 87
88 if (ata_timing_compute(adev, adev->pio_mode, &at, 30303, 1) < 0) { 88 if (ata_timing_compute(adev, adev->pio_mode, &at, 30303, 1) < 0) {
89 dev_printk(KERN_ERR, &pdev->dev, "unknown mode %d.\n", adev->pio_mode); 89 dev_err(&pdev->dev, "unknown mode %d\n", adev->pio_mode);
90 return; 90 return;
91 } 91 }
92 92
diff --git a/drivers/ata/pata_ns87415.c b/drivers/ata/pata_ns87415.c
index 605f198f958c..f1d517bc5b49 100644
--- a/drivers/ata/pata_ns87415.c
+++ b/drivers/ata/pata_ns87415.c
@@ -350,7 +350,6 @@ static void ns87415_fixup(struct pci_dev *pdev)
350 350
351static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 351static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
352{ 352{
353 static int printed_version;
354 static const struct ata_port_info info = { 353 static const struct ata_port_info info = {
355 .flags = ATA_FLAG_SLAVE_POSS, 354 .flags = ATA_FLAG_SLAVE_POSS,
356 .pio_mask = ATA_PIO4, 355 .pio_mask = ATA_PIO4,
@@ -370,9 +369,7 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
370 if (PCI_SLOT(pdev->devfn) == 0x0E) 369 if (PCI_SLOT(pdev->devfn) == 0x0E)
371 ppi[0] = &info87560; 370 ppi[0] = &info87560;
372#endif 371#endif
373 if (!printed_version++) 372 ata_print_version_once(&pdev->dev, DRV_VERSION);
374 dev_printk(KERN_DEBUG, &pdev->dev,
375 "version " DRV_VERSION "\n");
376 373
377 rc = pcim_enable_device(pdev); 374 rc = pcim_enable_device(pdev);
378 if (rc) 375 if (rc)
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index 220ddc90608f..1d61d5d278fa 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -405,7 +405,7 @@ static int octeon_cf_softreset16(struct ata_link *link, unsigned int *classes,
405 405
406 rc = ata_sff_wait_after_reset(link, 1, deadline); 406 rc = ata_sff_wait_after_reset(link, 1, deadline);
407 if (rc) { 407 if (rc) {
408 ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc); 408 ata_link_err(link, "SRST failed (errno=%d)\n", rc);
409 return rc; 409 return rc;
410 } 410 }
411 411
@@ -807,6 +807,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
807 irq_handler_t irq_handler = NULL; 807 irq_handler_t irq_handler = NULL;
808 void __iomem *base; 808 void __iomem *base;
809 struct octeon_cf_port *cf_port; 809 struct octeon_cf_port *cf_port;
810 char version[32];
810 811
811 res_cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 812 res_cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
812 813
@@ -905,10 +906,11 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
905 ata_port_desc(ap, "cmd %p ctl %p", base, ap->ioaddr.ctl_addr); 906 ata_port_desc(ap, "cmd %p ctl %p", base, ap->ioaddr.ctl_addr);
906 907
907 908
908 dev_info(&pdev->dev, "version " DRV_VERSION" %d bit%s.\n", 909 snprintf(version, sizeof(version), "%s %d bit%s",
910 DRV_VERSION,
909 (ocd->is16bit) ? 16 : 8, 911 (ocd->is16bit) ? 16 : 8,
910 (cs1) ? ", True IDE" : ""); 912 (cs1) ? ", True IDE" : "");
911 913 ata_print_version_once(&pdev->dev, version);
912 914
913 return ata_host_activate(host, irq, irq_handler, 0, &octeon_cf_sht); 915 return ata_host_activate(host, irq, irq_handler, 0, &octeon_cf_sht);
914 916
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index b811c1636204..98cdf50e4065 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -235,7 +235,6 @@ static struct ata_port_operations oldpiix_pata_ops = {
235 235
236static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 236static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
237{ 237{
238 static int printed_version;
239 static const struct ata_port_info info = { 238 static const struct ata_port_info info = {
240 .flags = ATA_FLAG_SLAVE_POSS, 239 .flags = ATA_FLAG_SLAVE_POSS,
241 .pio_mask = ATA_PIO4, 240 .pio_mask = ATA_PIO4,
@@ -244,9 +243,7 @@ static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *e
244 }; 243 };
245 const struct ata_port_info *ppi[] = { &info, NULL }; 244 const struct ata_port_info *ppi[] = { &info, NULL };
246 245
247 if (!printed_version++) 246 ata_print_version_once(&pdev->dev, DRV_VERSION);
248 dev_printk(KERN_DEBUG, &pdev->dev,
249 "version " DRV_VERSION "\n");
250 247
251 return ata_pci_bmdma_init_one(pdev, ppi, &oldpiix_sht, NULL, 0); 248 return ata_pci_bmdma_init_one(pdev, ppi, &oldpiix_sht, NULL, 0);
252} 249}
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index 00c5a02a94fc..accc033faf77 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -167,10 +167,8 @@ static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
167 .port_ops = &opti_port_ops 167 .port_ops = &opti_port_ops
168 }; 168 };
169 const struct ata_port_info *ppi[] = { &info, NULL }; 169 const struct ata_port_info *ppi[] = { &info, NULL };
170 static int printed_version;
171 170
172 if (!printed_version++) 171 ata_print_version_once(&dev->dev, DRV_VERSION);
173 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
174 172
175 return ata_pci_sff_init_one(dev, ppi, &opti_sht, NULL, 0); 173 return ata_pci_sff_init_one(dev, ppi, &opti_sht, NULL, 0);
176} 174}
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 0852cd07de08..77cb91408632 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -411,11 +411,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
411 .port_ops = &optiplus_port_ops 411 .port_ops = &optiplus_port_ops
412 }; 412 };
413 const struct ata_port_info *ppi[] = { &info_82c700, NULL }; 413 const struct ata_port_info *ppi[] = { &info_82c700, NULL };
414 static int printed_version;
415 int rc; 414 int rc;
416 415
417 if (!printed_version++) 416 ata_print_version_once(&dev->dev, DRV_VERSION);
418 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
419 417
420 rc = pcim_enable_device(dev); 418 rc = pcim_enable_device(dev);
421 if (rc) 419 if (rc)
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 021abe6d8527..a808ba03bd7f 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -68,7 +68,7 @@ static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_d
68 the same vendor - check serial */ 68 the same vendor - check serial */
69 if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO, 69 if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO,
70 ATA_ID_SERNO_LEN) == 0 && master->id[ATA_ID_SERNO] >> 8) { 70 ATA_ID_SERNO_LEN) == 0 && master->id[ATA_ID_SERNO] >> 8) {
71 ata_dev_printk(slave, KERN_WARNING, "is a ghost device, ignoring.\n"); 71 ata_dev_warn(slave, "is a ghost device, ignoring\n");
72 ata_dev_disable(slave); 72 ata_dev_disable(slave);
73 } 73 }
74 } 74 }
@@ -142,8 +142,7 @@ static void pcmcia_8bit_drain_fifo(struct ata_queued_cmd *qc)
142 ioread8(ap->ioaddr.data_addr); 142 ioread8(ap->ioaddr.data_addr);
143 143
144 if (count) 144 if (count)
145 ata_port_printk(ap, KERN_WARNING, "drained %d bytes to clear DRQ.\n", 145 ata_port_warn(ap, "drained %d bytes to clear DRQ\n", count);
146 count);
147 146
148} 147}
149 148
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 9765ace16921..b1511f38b0e8 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -655,7 +655,7 @@ static int pdc_hardware_init(struct ata_host *host, unsigned int board_idx)
655 */ 655 */
656 pll_clock = pdc_detect_pll_input_clock(host); 656 pll_clock = pdc_detect_pll_input_clock(host);
657 657
658 dev_printk(KERN_INFO, host->dev, "PLL input clock %ld kHz\n", pll_clock/1000); 658 dev_info(host->dev, "PLL input clock %ld kHz\n", pll_clock/1000);
659 659
660 /* Adjust PLL control register */ 660 /* Adjust PLL control register */
661 pdc_adjust_pll(host, pll_clock, board_idx); 661 pdc_adjust_pll(host, pll_clock, board_idx);
@@ -697,7 +697,6 @@ static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
697 */ 697 */
698static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 698static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
699{ 699{
700 static int printed_version;
701 static const unsigned long cmd_offset[] = { 0x17c0, 0x15c0 }; 700 static const unsigned long cmd_offset[] = { 0x17c0, 0x15c0 };
702 static const unsigned long bmdma_offset[] = { 0x1000, 0x1008 }; 701 static const unsigned long bmdma_offset[] = { 0x1000, 0x1008 };
703 unsigned int board_idx = (unsigned int) ent->driver_data; 702 unsigned int board_idx = (unsigned int) ent->driver_data;
@@ -707,8 +706,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
707 void __iomem *mmio_base; 706 void __iomem *mmio_base;
708 int i, rc; 707 int i, rc;
709 708
710 if (!printed_version++) 709 ata_print_version_once(&pdev->dev, DRV_VERSION);
711 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
712 710
713 /* alloc host */ 711 /* alloc host */
714 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2); 712 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 50400fa120fe..2067308f683f 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -39,7 +39,7 @@ static int pata_platform_set_mode(struct ata_link *link, struct ata_device **unu
39 dev->pio_mode = dev->xfer_mode = XFER_PIO_0; 39 dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
40 dev->xfer_shift = ATA_SHIFT_PIO; 40 dev->xfer_shift = ATA_SHIFT_PIO;
41 dev->flags |= ATA_DFLAG_PIO; 41 dev->flags |= ATA_DFLAG_PIO;
42 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); 42 ata_dev_info(dev, "configured for PIO\n");
43 } 43 }
44 return 0; 44 return 0;
45} 45}
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 8574b31f1773..b2d3a2bb4e60 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -213,7 +213,6 @@ static struct ata_port_operations radisys_pata_ops = {
213 213
214static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 214static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
215{ 215{
216 static int printed_version;
217 static const struct ata_port_info info = { 216 static const struct ata_port_info info = {
218 .flags = ATA_FLAG_SLAVE_POSS, 217 .flags = ATA_FLAG_SLAVE_POSS,
219 .pio_mask = ATA_PIO4, 218 .pio_mask = ATA_PIO4,
@@ -223,9 +222,7 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e
223 }; 222 };
224 const struct ata_port_info *ppi[] = { &info, NULL }; 223 const struct ata_port_info *ppi[] = { &info, NULL };
225 224
226 if (!printed_version++) 225 ata_print_version_once(&pdev->dev, DRV_VERSION);
227 dev_printk(KERN_DEBUG, &pdev->dev,
228 "version " DRV_VERSION "\n");
229 226
230 return ata_pci_bmdma_init_one(pdev, ppi, &radisys_sht, NULL, 0); 227 return ata_pci_bmdma_init_one(pdev, ppi, &radisys_sht, NULL, 0);
231} 228}
diff --git a/drivers/ata/pata_rdc.c b/drivers/ata/pata_rdc.c
index 5fbe9b166c69..4d318f86ae86 100644
--- a/drivers/ata/pata_rdc.c
+++ b/drivers/ata/pata_rdc.c
@@ -312,7 +312,6 @@ static struct scsi_host_template rdc_sht = {
312static int __devinit rdc_init_one(struct pci_dev *pdev, 312static int __devinit rdc_init_one(struct pci_dev *pdev,
313 const struct pci_device_id *ent) 313 const struct pci_device_id *ent)
314{ 314{
315 static int printed_version;
316 struct device *dev = &pdev->dev; 315 struct device *dev = &pdev->dev;
317 struct ata_port_info port_info[2]; 316 struct ata_port_info port_info[2];
318 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; 317 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
@@ -321,9 +320,7 @@ static int __devinit rdc_init_one(struct pci_dev *pdev,
321 struct rdc_host_priv *hpriv; 320 struct rdc_host_priv *hpriv;
322 int rc; 321 int rc;
323 322
324 if (!printed_version++) 323 ata_print_version_once(&pdev->dev, DRV_VERSION);
325 dev_printk(KERN_DEBUG, &pdev->dev,
326 "version " DRV_VERSION "\n");
327 324
328 port_info[0] = rdc_port_info; 325 port_info[0] = rdc_port_info;
329 port_info[1] = rdc_port_info; 326 port_info[1] = rdc_port_info;
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 4d04471794b6..aca321e1e6a2 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -44,7 +44,7 @@ static int rz1000_set_mode(struct ata_link *link, struct ata_device **unused)
44 dev->xfer_mode = XFER_PIO_0; 44 dev->xfer_mode = XFER_PIO_0;
45 dev->xfer_shift = ATA_SHIFT_PIO; 45 dev->xfer_shift = ATA_SHIFT_PIO;
46 dev->flags |= ATA_DFLAG_PIO; 46 dev->flags |= ATA_DFLAG_PIO;
47 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); 47 ata_dev_info(dev, "configured for PIO\n");
48 } 48 }
49 return 0; 49 return 0;
50} 50}
@@ -92,7 +92,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
92 }; 92 };
93 const struct ata_port_info *ppi[] = { &info, NULL }; 93 const struct ata_port_info *ppi[] = { &info, NULL };
94 94
95 printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 95 ata_print_version_once(&pdev->dev, DRV_VERSION);
96 96
97 if (rz1000_fifo_disable(pdev) == 0) 97 if (rz1000_fifo_disable(pdev) == 0)
98 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL, 0); 98 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL, 0);
diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c
index c446ae6055a3..1b372c297195 100644
--- a/drivers/ata/pata_samsung_cf.c
+++ b/drivers/ata/pata_samsung_cf.c
@@ -376,7 +376,7 @@ static int pata_s3c_softreset(struct ata_link *link, unsigned int *classes,
376 rc = pata_s3c_bus_softreset(ap, deadline); 376 rc = pata_s3c_bus_softreset(ap, deadline);
377 /* if link is occupied, -ENODEV too is an error */ 377 /* if link is occupied, -ENODEV too is an error */
378 if (rc && rc != -ENODEV) { 378 if (rc && rc != -ENODEV) {
379 ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc); 379 ata_link_err(link, "SRST failed (errno=%d)\n", rc);
380 return rc; 380 return rc;
381 } 381 }
382 382
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index 88ea9b677b47..eb748e327143 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -637,8 +637,7 @@ static int scc_softreset(struct ata_link *link, unsigned int *classes,
637 DPRINTK("about to softreset, devmask=%x\n", devmask); 637 DPRINTK("about to softreset, devmask=%x\n", devmask);
638 err_mask = scc_bus_softreset(ap, devmask, deadline); 638 err_mask = scc_bus_softreset(ap, devmask, deadline);
639 if (err_mask) { 639 if (err_mask) {
640 ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n", 640 ata_port_err(ap, "SRST failed (err_mask=0x%x)\n", err_mask);
641 err_mask);
642 return -EIO; 641 return -EIO;
643 } 642 }
644 643
@@ -1072,15 +1071,12 @@ static int scc_host_init(struct ata_host *host)
1072 1071
1073static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1072static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1074{ 1073{
1075 static int printed_version;
1076 unsigned int board_idx = (unsigned int) ent->driver_data; 1074 unsigned int board_idx = (unsigned int) ent->driver_data;
1077 const struct ata_port_info *ppi[] = { &scc_port_info[board_idx], NULL }; 1075 const struct ata_port_info *ppi[] = { &scc_port_info[board_idx], NULL };
1078 struct ata_host *host; 1076 struct ata_host *host;
1079 int rc; 1077 int rc;
1080 1078
1081 if (!printed_version++) 1079 ata_print_version_once(&pdev->dev, DRV_VERSION);
1082 dev_printk(KERN_DEBUG, &pdev->dev,
1083 "version " DRV_VERSION "\n");
1084 1080
1085 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 1); 1081 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 1);
1086 if (!host) 1082 if (!host)
diff --git a/drivers/ata/pata_sch.c b/drivers/ata/pata_sch.c
index e97b32f03a6e..7c78b9993627 100644
--- a/drivers/ata/pata_sch.c
+++ b/drivers/ata/pata_sch.c
@@ -172,12 +172,9 @@ static void sch_set_dmamode(struct ata_port *ap, struct ata_device *adev)
172static int __devinit sch_init_one(struct pci_dev *pdev, 172static int __devinit sch_init_one(struct pci_dev *pdev,
173 const struct pci_device_id *ent) 173 const struct pci_device_id *ent)
174{ 174{
175 static int printed_version;
176 const struct ata_port_info *ppi[] = { &sch_port_info, NULL }; 175 const struct ata_port_info *ppi[] = { &sch_port_info, NULL };
177 176
178 if (!printed_version++) 177 ata_print_version_once(&pdev->dev, DRV_VERSION);
179 dev_printk(KERN_DEBUG, &pdev->dev,
180 "version " DRV_VERSION "\n");
181 178
182 return ata_pci_bmdma_init_one(pdev, ppi, &sch_sht, NULL, 0); 179 return ata_pci_bmdma_init_one(pdev, ppi, &sch_sht, NULL, 0);
183} 180}
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 118787caa93f..31f759b0ab71 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -327,13 +327,11 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
327 .port_ops = &sil680_port_ops 327 .port_ops = &sil680_port_ops
328 }; 328 };
329 const struct ata_port_info *ppi[] = { &info, NULL }; 329 const struct ata_port_info *ppi[] = { &info, NULL };
330 static int printed_version;
331 struct ata_host *host; 330 struct ata_host *host;
332 void __iomem *mmio_base; 331 void __iomem *mmio_base;
333 int rc, try_mmio; 332 int rc, try_mmio;
334 333
335 if (!printed_version++) 334 ata_print_version_once(&pdev->dev, DRV_VERSION);
336 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
337 335
338 rc = pcim_enable_device(pdev); 336 rc = pcim_enable_device(pdev);
339 if (rc) 337 if (rc)
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index be08ff92db17..533f2aefab87 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -681,7 +681,6 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
681 681
682static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 682static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
683{ 683{
684 static int printed_version;
685 const struct ata_port_info *ppi[] = { NULL, NULL }; 684 const struct ata_port_info *ppi[] = { NULL, NULL };
686 struct pci_dev *host = NULL; 685 struct pci_dev *host = NULL;
687 struct sis_chipset *chipset = NULL; 686 struct sis_chipset *chipset = NULL;
@@ -735,9 +734,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
735 0x0, &sis_info100 734 0x0, &sis_info100
736 }; 735 };
737 736
738 if (!printed_version++) 737 ata_print_version_once(&pdev->dev, DRV_VERSION);
739 dev_printk(KERN_DEBUG, &pdev->dev,
740 "version " DRV_VERSION "\n");
741 738
742 rc = pcim_enable_device(pdev); 739 rc = pcim_enable_device(pdev);
743 if (rc) 740 if (rc)
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 7f5d020ed56c..c06ce8ced566 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -317,9 +317,11 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
317 rev = sl82c105_bridge_revision(dev); 317 rev = sl82c105_bridge_revision(dev);
318 318
319 if (rev == -1) 319 if (rev == -1)
320 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); 320 dev_warn(&dev->dev,
321 "pata_sl82c105: Unable to find bridge, disabling DMA\n");
321 else if (rev <= 5) 322 else if (rev <= 5)
322 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); 323 dev_warn(&dev->dev,
324 "pata_sl82c105: Early bridge revision, no DMA available\n");
323 else 325 else
324 ppi[0] = &info_dma; 326 ppi[0] = &info_dma;
325 327
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index b3e0c9432283..28da1c6becf1 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -196,10 +196,8 @@ static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
196 .port_ops = &triflex_port_ops 196 .port_ops = &triflex_port_ops
197 }; 197 };
198 const struct ata_port_info *ppi[] = { &info, NULL }; 198 const struct ata_port_info *ppi[] = { &info, NULL };
199 static int printed_version;
200 199
201 if (!printed_version++) 200 ata_print_version_once(&dev->dev, DRV_VERSION);
202 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
203 201
204 return ata_pci_bmdma_init_one(dev, ppi, &triflex_sht, NULL, 0); 202 return ata_pci_bmdma_init_one(dev, ppi, &triflex_sht, NULL, 0);
205} 203}
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index ac8d7d97e408..65e4be6be220 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -350,8 +350,8 @@ static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask)
350 if (config->id == PCI_DEVICE_ID_VIA_82C586_0) { 350 if (config->id == PCI_DEVICE_ID_VIA_82C586_0) {
351 ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 351 ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
352 if (strcmp(model_num, "TS64GSSD25-M") == 0) { 352 if (strcmp(model_num, "TS64GSSD25-M") == 0) {
353 ata_dev_printk(dev, KERN_WARNING, 353 ata_dev_warn(dev,
354 "disabling UDMA mode due to reported lockups with this device.\n"); 354 "disabling UDMA mode due to reported lockups with this device\n");
355 mask &= ~ ATA_MASK_UDMA; 355 mask &= ~ ATA_MASK_UDMA;
356 } 356 }
357 } 357 }
@@ -551,14 +551,12 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
551 const struct ata_port_info *ppi[] = { NULL, NULL }; 551 const struct ata_port_info *ppi[] = { NULL, NULL };
552 struct pci_dev *isa; 552 struct pci_dev *isa;
553 const struct via_isa_bridge *config; 553 const struct via_isa_bridge *config;
554 static int printed_version;
555 u8 enable; 554 u8 enable;
556 u32 timing; 555 u32 timing;
557 unsigned long flags = id->driver_data; 556 unsigned long flags = id->driver_data;
558 int rc; 557 int rc;
559 558
560 if (!printed_version++) 559 ata_print_version_once(&pdev->dev, DRV_VERSION);
561 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
562 560
563 rc = pcim_enable_device(pdev); 561 rc = pcim_enable_device(pdev);
564 if (rc) 562 if (rc)
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index 1111712b3d7d..04911d52f59d 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -596,14 +596,12 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
596 596
597 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 597 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
598 if (rc) { 598 if (rc) {
599 dev_printk(KERN_ERR, &pdev->dev, 599 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
600 "32-bit DMA enable failed\n");
601 return rc; 600 return rc;
602 } 601 }
603 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 602 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
604 if (rc) { 603 if (rc) {
605 dev_printk(KERN_ERR, &pdev->dev, 604 dev_err(&pdev->dev, "32-bit consistent DMA enable failed\n");
606 "32-bit consistent DMA enable failed\n");
607 return rc; 605 return rc;
608 } 606 }
609 return 0; 607 return 0;
@@ -612,15 +610,13 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
612static int adma_ata_init_one(struct pci_dev *pdev, 610static int adma_ata_init_one(struct pci_dev *pdev,
613 const struct pci_device_id *ent) 611 const struct pci_device_id *ent)
614{ 612{
615 static int printed_version;
616 unsigned int board_idx = (unsigned int) ent->driver_data; 613 unsigned int board_idx = (unsigned int) ent->driver_data;
617 const struct ata_port_info *ppi[] = { &adma_port_info[board_idx], NULL }; 614 const struct ata_port_info *ppi[] = { &adma_port_info[board_idx], NULL };
618 struct ata_host *host; 615 struct ata_host *host;
619 void __iomem *mmio_base; 616 void __iomem *mmio_base;
620 int rc, port_no; 617 int rc, port_no;
621 618
622 if (!printed_version++) 619 ata_print_version_once(&pdev->dev, DRV_VERSION);
623 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
624 620
625 /* alloc host */ 621 /* alloc host */
626 host = ata_host_alloc_pinfo(&pdev->dev, ppi, ADMA_PORTS); 622 host = ata_host_alloc_pinfo(&pdev->dev, ppi, ADMA_PORTS);
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index dc88a39e7db8..b02c4ffa4db0 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -766,11 +766,15 @@ static int dma_dwc_xfer_setup(struct scatterlist *sg, int num_elems,
766static void dma_dwc_exit(struct sata_dwc_device *hsdev) 766static void dma_dwc_exit(struct sata_dwc_device *hsdev)
767{ 767{
768 dev_dbg(host_pvt.dwc_dev, "%s:\n", __func__); 768 dev_dbg(host_pvt.dwc_dev, "%s:\n", __func__);
769 if (host_pvt.sata_dma_regs) 769 if (host_pvt.sata_dma_regs) {
770 iounmap(host_pvt.sata_dma_regs); 770 iounmap(host_pvt.sata_dma_regs);
771 host_pvt.sata_dma_regs = NULL;
772 }
771 773
772 if (hsdev->irq_dma) 774 if (hsdev->irq_dma) {
773 free_irq(hsdev->irq_dma, hsdev); 775 free_irq(hsdev->irq_dma, hsdev);
776 hsdev->irq_dma = 0;
777 }
774} 778}
775 779
776/* 780/*
@@ -1642,7 +1646,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1642 if (hsdev == NULL) { 1646 if (hsdev == NULL) {
1643 dev_err(&ofdev->dev, "kmalloc failed for hsdev\n"); 1647 dev_err(&ofdev->dev, "kmalloc failed for hsdev\n");
1644 err = -ENOMEM; 1648 err = -ENOMEM;
1645 goto error_out; 1649 goto error;
1646 } 1650 }
1647 memset(hsdev, 0, sizeof(*hsdev)); 1651 memset(hsdev, 0, sizeof(*hsdev));
1648 1652
@@ -1652,7 +1656,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1652 dev_err(&ofdev->dev, "ioremap failed for SATA register" 1656 dev_err(&ofdev->dev, "ioremap failed for SATA register"
1653 " address\n"); 1657 " address\n");
1654 err = -ENODEV; 1658 err = -ENODEV;
1655 goto error_out; 1659 goto error_kmalloc;
1656 } 1660 }
1657 hsdev->reg_base = base; 1661 hsdev->reg_base = base;
1658 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); 1662 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
@@ -1665,7 +1669,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1665 if (!host) { 1669 if (!host) {
1666 dev_err(&ofdev->dev, "ata_host_alloc_pinfo failed\n"); 1670 dev_err(&ofdev->dev, "ata_host_alloc_pinfo failed\n");
1667 err = -ENOMEM; 1671 err = -ENOMEM;
1668 goto error_out; 1672 goto error_iomap;
1669 } 1673 }
1670 1674
1671 host->private_data = hsdev; 1675 host->private_data = hsdev;
@@ -1733,8 +1737,11 @@ error_out:
1733 /* Free SATA DMA resources */ 1737 /* Free SATA DMA resources */
1734 dma_dwc_exit(hsdev); 1738 dma_dwc_exit(hsdev);
1735 1739
1736 if (base) 1740error_iomap:
1737 iounmap(base); 1741 iounmap(base);
1742error_kmalloc:
1743 kfree(hsdev);
1744error:
1738 return err; 1745 return err;
1739} 1746}
1740 1747
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 35a71d875d0e..78ae7b67b09e 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -346,12 +346,11 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
346 346
347 /* warn if each s/g element is not dword aligned */ 347 /* warn if each s/g element is not dword aligned */
348 if (sg_addr & 0x03) 348 if (sg_addr & 0x03)
349 ata_port_printk(qc->ap, KERN_ERR, 349 ata_port_err(qc->ap, "s/g addr unaligned : 0x%llx\n",
350 "s/g addr unaligned : 0x%llx\n", 350 (unsigned long long)sg_addr);
351 (unsigned long long)sg_addr);
352 if (sg_len & 0x03) 351 if (sg_len & 0x03)
353 ata_port_printk(qc->ap, KERN_ERR, 352 ata_port_err(qc->ap, "s/g len unaligned : 0x%x\n",
354 "s/g len unaligned : 0x%x\n", sg_len); 353 sg_len);
355 354
356 if (num_prde == (SATA_FSL_MAX_PRD_DIRECT - 1) && 355 if (num_prde == (SATA_FSL_MAX_PRD_DIRECT - 1) &&
357 sg_next(sg) != NULL) { 356 sg_next(sg) != NULL) {
@@ -661,8 +660,7 @@ static int sata_fsl_port_start(struct ata_port *ap)
661 sata_fsl_scr_write(&ap->link, SCR_CONTROL, temp); 660 sata_fsl_scr_write(&ap->link, SCR_CONTROL, temp);
662 661
663 sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp); 662 sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
664 dev_printk(KERN_WARNING, dev, "scr_control, speed limited to %x\n", 663 dev_warn(dev, "scr_control, speed limited to %x\n", temp);
665 temp);
666#endif 664#endif
667 665
668 return 0; 666 return 0;
@@ -740,8 +738,7 @@ try_offline_again:
740 1, 500); 738 1, 500);
741 739
742 if (temp & ONLINE) { 740 if (temp & ONLINE) {
743 ata_port_printk(ap, KERN_ERR, 741 ata_port_err(ap, "Hardreset failed, not off-lined %d\n", i);
744 "Hardreset failed, not off-lined %d\n", i);
745 742
746 /* 743 /*
747 * Try to offline controller atleast twice 744 * Try to offline controller atleast twice
@@ -777,8 +774,7 @@ try_offline_again:
777 temp = ata_wait_register(ap, hcr_base + HSTATUS, ONLINE, 0, 1, 500); 774 temp = ata_wait_register(ap, hcr_base + HSTATUS, ONLINE, 0, 1, 500);
778 775
779 if (!(temp & ONLINE)) { 776 if (!(temp & ONLINE)) {
780 ata_port_printk(ap, KERN_ERR, 777 ata_port_err(ap, "Hardreset failed, not on-lined\n");
781 "Hardreset failed, not on-lined\n");
782 goto err; 778 goto err;
783 } 779 }
784 780
@@ -794,9 +790,8 @@ try_offline_again:
794 790
795 temp = ata_wait_register(ap, hcr_base + HSTATUS, 0xFF, 0, 1, 500); 791 temp = ata_wait_register(ap, hcr_base + HSTATUS, 0xFF, 0, 1, 500);
796 if ((!(temp & 0x10)) || ata_link_offline(link)) { 792 if ((!(temp & 0x10)) || ata_link_offline(link)) {
797 ata_port_printk(ap, KERN_WARNING, 793 ata_port_warn(ap, "No Device OR PHYRDY change,Hstatus = 0x%x\n",
798 "No Device OR PHYRDY change,Hstatus = 0x%x\n", 794 ioread32(hcr_base + HSTATUS));
799 ioread32(hcr_base + HSTATUS));
800 *class = ATA_DEV_NONE; 795 *class = ATA_DEV_NONE;
801 return 0; 796 return 0;
802 } 797 }
@@ -809,13 +804,12 @@ try_offline_again:
809 500, jiffies_to_msecs(deadline - start_jiffies)); 804 500, jiffies_to_msecs(deadline - start_jiffies));
810 805
811 if ((temp & 0xFF) != 0x18) { 806 if ((temp & 0xFF) != 0x18) {
812 ata_port_printk(ap, KERN_WARNING, "No Signature Update\n"); 807 ata_port_warn(ap, "No Signature Update\n");
813 *class = ATA_DEV_NONE; 808 *class = ATA_DEV_NONE;
814 goto do_followup_srst; 809 goto do_followup_srst;
815 } else { 810 } else {
816 ata_port_printk(ap, KERN_INFO, 811 ata_port_info(ap, "Signature Update detected @ %d msecs\n",
817 "Signature Update detected @ %d msecs\n", 812 jiffies_to_msecs(jiffies - start_jiffies));
818 jiffies_to_msecs(jiffies - start_jiffies));
819 *class = sata_fsl_dev_classify(ap); 813 *class = sata_fsl_dev_classify(ap);
820 return 0; 814 return 0;
821 } 815 }
@@ -890,7 +884,7 @@ static int sata_fsl_softreset(struct ata_link *link, unsigned int *class,
890 884
891 temp = ata_wait_register(ap, CQ + hcr_base, 0x1, 0x1, 1, 5000); 885 temp = ata_wait_register(ap, CQ + hcr_base, 0x1, 0x1, 1, 5000);
892 if (temp & 0x1) { 886 if (temp & 0x1) {
893 ata_port_printk(ap, KERN_WARNING, "ATA_SRST issue failed\n"); 887 ata_port_warn(ap, "ATA_SRST issue failed\n");
894 888
895 DPRINTK("Softreset@5000,CQ=0x%x,CA=0x%x,CC=0x%x\n", 889 DPRINTK("Softreset@5000,CQ=0x%x,CA=0x%x,CC=0x%x\n",
896 ioread32(CQ + hcr_base), 890 ioread32(CQ + hcr_base),
@@ -1202,8 +1196,7 @@ static irqreturn_t sata_fsl_interrupt(int irq, void *dev_instance)
1202 if (ap) { 1196 if (ap) {
1203 sata_fsl_host_intr(ap); 1197 sata_fsl_host_intr(ap);
1204 } else { 1198 } else {
1205 dev_printk(KERN_WARNING, host->dev, 1199 dev_warn(host->dev, "interrupt on disabled port 0\n");
1206 "interrupt on disabled port 0\n");
1207 } 1200 }
1208 1201
1209 iowrite32(interrupt_enables, hcr_base + HSTATUS); 1202 iowrite32(interrupt_enables, hcr_base + HSTATUS);
@@ -1317,8 +1310,7 @@ static int sata_fsl_probe(struct platform_device *ofdev)
1317 struct ata_port_info pi = sata_fsl_port_info[0]; 1310 struct ata_port_info pi = sata_fsl_port_info[0];
1318 const struct ata_port_info *ppi[] = { &pi, NULL }; 1311 const struct ata_port_info *ppi[] = { &pi, NULL };
1319 1312
1320 dev_printk(KERN_INFO, &ofdev->dev, 1313 dev_info(&ofdev->dev, "Sata FSL Platform/CSB Driver init\n");
1321 "Sata FSL Platform/CSB Driver init\n");
1322 1314
1323 hcr_base = of_iomap(ofdev->dev.of_node, 0); 1315 hcr_base = of_iomap(ofdev->dev.of_node, 0);
1324 if (!hcr_base) 1316 if (!hcr_base)
@@ -1347,7 +1339,7 @@ static int sata_fsl_probe(struct platform_device *ofdev)
1347 1339
1348 irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); 1340 irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
1349 if (irq < 0) { 1341 if (irq < 0) {
1350 dev_printk(KERN_ERR, &ofdev->dev, "invalid irq from platform\n"); 1342 dev_err(&ofdev->dev, "invalid irq from platform\n");
1351 goto error_exit_with_cleanup; 1343 goto error_exit_with_cleanup;
1352 } 1344 }
1353 host_priv->irq = irq; 1345 host_priv->irq = irq;
@@ -1422,8 +1414,7 @@ static int sata_fsl_resume(struct platform_device *op)
1422 1414
1423 ret = sata_fsl_init_controller(host); 1415 ret = sata_fsl_init_controller(host);
1424 if (ret) { 1416 if (ret) {
1425 dev_printk(KERN_ERR, &op->dev, 1417 dev_err(&op->dev, "Error initializing hardware\n");
1426 "Error initialize hardware\n");
1427 return ret; 1418 return ret;
1428 } 1419 }
1429 1420
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 83a44471b189..5c7d70c03bf0 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -396,9 +396,8 @@ static void inic_host_intr(struct ata_port *ap)
396 } 396 }
397 397
398 spurious: 398 spurious:
399 ata_port_printk(ap, KERN_WARNING, "unhandled interrupt: " 399 ata_port_warn(ap, "unhandled interrupt: cmd=0x%x irq_stat=0x%x idma_stat=0x%x\n",
400 "cmd=0x%x irq_stat=0x%x idma_stat=0x%x\n", 400 qc ? qc->tf.command : 0xff, irq_stat, idma_stat);
401 qc ? qc->tf.command : 0xff, irq_stat, idma_stat);
402} 401}
403 402
404static irqreturn_t inic_interrupt(int irq, void *dev_instance) 403static irqreturn_t inic_interrupt(int irq, void *dev_instance)
@@ -619,8 +618,9 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
619 618
620 rc = sata_link_resume(link, timing, deadline); 619 rc = sata_link_resume(link, timing, deadline);
621 if (rc) { 620 if (rc) {
622 ata_link_printk(link, KERN_WARNING, "failed to resume " 621 ata_link_warn(link,
623 "link after reset (errno=%d)\n", rc); 622 "failed to resume link after reset (errno=%d)\n",
623 rc);
624 return rc; 624 return rc;
625 } 625 }
626 626
@@ -632,8 +632,9 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
632 rc = ata_wait_after_reset(link, deadline, inic_check_ready); 632 rc = ata_wait_after_reset(link, deadline, inic_check_ready);
633 /* link occupied, -ENODEV too is an error */ 633 /* link occupied, -ENODEV too is an error */
634 if (rc) { 634 if (rc) {
635 ata_link_printk(link, KERN_WARNING, "device not ready " 635 ata_link_warn(link,
636 "after hardreset (errno=%d)\n", rc); 636 "device not ready after hardreset (errno=%d)\n",
637 rc);
637 return rc; 638 return rc;
638 } 639 }
639 640
@@ -799,7 +800,6 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
799 800
800static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 801static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
801{ 802{
802 static int printed_version;
803 const struct ata_port_info *ppi[] = { &inic_port_info, NULL }; 803 const struct ata_port_info *ppi[] = { &inic_port_info, NULL };
804 struct ata_host *host; 804 struct ata_host *host;
805 struct inic_host_priv *hpriv; 805 struct inic_host_priv *hpriv;
@@ -807,8 +807,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
807 int mmio_bar; 807 int mmio_bar;
808 int i, rc; 808 int i, rc;
809 809
810 if (!printed_version++) 810 ata_print_version_once(&pdev->dev, DRV_VERSION);
811 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
812 811
813 /* alloc host */ 812 /* alloc host */
814 host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS); 813 host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS);
@@ -847,15 +846,13 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
847 /* Set dma_mask. This devices doesn't support 64bit addressing. */ 846 /* Set dma_mask. This devices doesn't support 64bit addressing. */
848 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 847 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
849 if (rc) { 848 if (rc) {
850 dev_printk(KERN_ERR, &pdev->dev, 849 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
851 "32-bit DMA enable failed\n");
852 return rc; 850 return rc;
853 } 851 }
854 852
855 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 853 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
856 if (rc) { 854 if (rc) {
857 dev_printk(KERN_ERR, &pdev->dev, 855 dev_err(&pdev->dev, "32-bit consistent DMA enable failed\n");
858 "32-bit consistent DMA enable failed\n");
859 return rc; 856 return rc;
860 } 857 }
861 858
@@ -866,15 +863,13 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
866 */ 863 */
867 rc = pci_set_dma_max_seg_size(pdev, 65536 - 512); 864 rc = pci_set_dma_max_seg_size(pdev, 65536 - 512);
868 if (rc) { 865 if (rc) {
869 dev_printk(KERN_ERR, &pdev->dev, 866 dev_err(&pdev->dev, "failed to set the maximum segment size\n");
870 "failed to set the maximum segment size.\n");
871 return rc; 867 return rc;
872 } 868 }
873 869
874 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl); 870 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl);
875 if (rc) { 871 if (rc) {
876 dev_printk(KERN_ERR, &pdev->dev, 872 dev_err(&pdev->dev, "failed to initialize controller\n");
877 "failed to initialize controller\n");
878 return rc; 873 return rc;
879 } 874 }
880 875
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index b52c0519ad0b..4b6b2090784b 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -1190,7 +1190,7 @@ static void mv_wait_for_edma_empty_idle(struct ata_port *ap)
1190 break; 1190 break;
1191 udelay(per_loop); 1191 udelay(per_loop);
1192 } 1192 }
1193 /* ata_port_printk(ap, KERN_INFO, "%s: %u+ usecs\n", __func__, i); */ 1193 /* ata_port_info(ap, "%s: %u+ usecs\n", __func__, i); */
1194} 1194}
1195 1195
1196/** 1196/**
@@ -1228,7 +1228,7 @@ static int mv_stop_edma(struct ata_port *ap)
1228 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; 1228 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN;
1229 mv_wait_for_edma_empty_idle(ap); 1229 mv_wait_for_edma_empty_idle(ap);
1230 if (mv_stop_edma_engine(port_mmio)) { 1230 if (mv_stop_edma_engine(port_mmio)) {
1231 ata_port_printk(ap, KERN_ERR, "Unable to stop eDMA\n"); 1231 ata_port_err(ap, "Unable to stop eDMA\n");
1232 err = -EIO; 1232 err = -EIO;
1233 } 1233 }
1234 mv_edma_cfg(ap, 0, 0); 1234 mv_edma_cfg(ap, 0, 0);
@@ -1382,7 +1382,7 @@ static void mv6_dev_config(struct ata_device *adev)
1382 if (adev->flags & ATA_DFLAG_NCQ) { 1382 if (adev->flags & ATA_DFLAG_NCQ) {
1383 if (sata_pmp_attached(adev->link->ap)) { 1383 if (sata_pmp_attached(adev->link->ap)) {
1384 adev->flags &= ~ATA_DFLAG_NCQ; 1384 adev->flags &= ~ATA_DFLAG_NCQ;
1385 ata_dev_printk(adev, KERN_INFO, 1385 ata_dev_info(adev,
1386 "NCQ disabled for command-based switching\n"); 1386 "NCQ disabled for command-based switching\n");
1387 } 1387 }
1388 } 1388 }
@@ -2225,9 +2225,8 @@ static unsigned int mv_send_fis(struct ata_port *ap, u32 *fis, int nwords)
2225 2225
2226 /* See if it worked */ 2226 /* See if it worked */
2227 if ((ifstat & 0x3000) != 0x1000) { 2227 if ((ifstat & 0x3000) != 0x1000) {
2228 ata_port_printk(ap, KERN_WARNING, 2228 ata_port_warn(ap, "%s transmission error, ifstat=%08x\n",
2229 "%s transmission error, ifstat=%08x\n", 2229 __func__, ifstat);
2230 __func__, ifstat);
2231 return AC_ERR_OTHER; 2230 return AC_ERR_OTHER;
2232 } 2231 }
2233 return 0; 2232 return 0;
@@ -2342,9 +2341,9 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
2342 */ 2341 */
2343 if (limit_warnings > 0 && (qc->nbytes / qc->sect_size) > 1) { 2342 if (limit_warnings > 0 && (qc->nbytes / qc->sect_size) > 1) {
2344 --limit_warnings; 2343 --limit_warnings;
2345 ata_link_printk(qc->dev->link, KERN_WARNING, DRV_NAME 2344 ata_link_warn(qc->dev->link, DRV_NAME
2346 ": attempting PIO w/multiple DRQ: " 2345 ": attempting PIO w/multiple DRQ: "
2347 "this may fail due to h/w errata\n"); 2346 "this may fail due to h/w errata\n");
2348 } 2347 }
2349 /* drop through */ 2348 /* drop through */
2350 case ATA_PROT_NODATA: 2349 case ATA_PROT_NODATA:
@@ -2499,20 +2498,20 @@ static int mv_handle_fbs_ncq_dev_err(struct ata_port *ap)
2499 } 2498 }
2500 failed_links = hweight16(new_map); 2499 failed_links = hweight16(new_map);
2501 2500
2502 ata_port_printk(ap, KERN_INFO, "%s: pmp_map=%04x qc_map=%04x " 2501 ata_port_info(ap,
2503 "failed_links=%d nr_active_links=%d\n", 2502 "%s: pmp_map=%04x qc_map=%04x failed_links=%d nr_active_links=%d\n",
2504 __func__, pp->delayed_eh_pmp_map, 2503 __func__, pp->delayed_eh_pmp_map,
2505 ap->qc_active, failed_links, 2504 ap->qc_active, failed_links,
2506 ap->nr_active_links); 2505 ap->nr_active_links);
2507 2506
2508 if (ap->nr_active_links <= failed_links && mv_req_q_empty(ap)) { 2507 if (ap->nr_active_links <= failed_links && mv_req_q_empty(ap)) {
2509 mv_process_crpb_entries(ap, pp); 2508 mv_process_crpb_entries(ap, pp);
2510 mv_stop_edma(ap); 2509 mv_stop_edma(ap);
2511 mv_eh_freeze(ap); 2510 mv_eh_freeze(ap);
2512 ata_port_printk(ap, KERN_INFO, "%s: done\n", __func__); 2511 ata_port_info(ap, "%s: done\n", __func__);
2513 return 1; /* handled */ 2512 return 1; /* handled */
2514 } 2513 }
2515 ata_port_printk(ap, KERN_INFO, "%s: waiting\n", __func__); 2514 ata_port_info(ap, "%s: waiting\n", __func__);
2516 return 1; /* handled */ 2515 return 1; /* handled */
2517} 2516}
2518 2517
@@ -2554,9 +2553,8 @@ static int mv_handle_dev_err(struct ata_port *ap, u32 edma_err_cause)
2554 * and we cannot handle it here. 2553 * and we cannot handle it here.
2555 */ 2554 */
2556 if (edma_err_cause & EDMA_ERR_SELF_DIS) { 2555 if (edma_err_cause & EDMA_ERR_SELF_DIS) {
2557 ata_port_printk(ap, KERN_WARNING, 2556 ata_port_warn(ap, "%s: err_cause=0x%x pp_flags=0x%x\n",
2558 "%s: err_cause=0x%x pp_flags=0x%x\n", 2557 __func__, edma_err_cause, pp->pp_flags);
2559 __func__, edma_err_cause, pp->pp_flags);
2560 return 0; /* not handled */ 2558 return 0; /* not handled */
2561 } 2559 }
2562 return mv_handle_fbs_ncq_dev_err(ap); 2560 return mv_handle_fbs_ncq_dev_err(ap);
@@ -2567,9 +2565,8 @@ static int mv_handle_dev_err(struct ata_port *ap, u32 edma_err_cause)
2567 * and we cannot handle it here. 2565 * and we cannot handle it here.
2568 */ 2566 */
2569 if (!(edma_err_cause & EDMA_ERR_SELF_DIS)) { 2567 if (!(edma_err_cause & EDMA_ERR_SELF_DIS)) {
2570 ata_port_printk(ap, KERN_WARNING, 2568 ata_port_warn(ap, "%s: err_cause=0x%x pp_flags=0x%x\n",
2571 "%s: err_cause=0x%x pp_flags=0x%x\n", 2569 __func__, edma_err_cause, pp->pp_flags);
2572 __func__, edma_err_cause, pp->pp_flags);
2573 return 0; /* not handled */ 2570 return 0; /* not handled */
2574 } 2571 }
2575 return mv_handle_fbs_non_ncq_dev_err(ap); 2572 return mv_handle_fbs_non_ncq_dev_err(ap);
@@ -2930,8 +2927,7 @@ static int mv_pci_error(struct ata_host *host, void __iomem *mmio)
2930 2927
2931 err_cause = readl(mmio + hpriv->irq_cause_offset); 2928 err_cause = readl(mmio + hpriv->irq_cause_offset);
2932 2929
2933 dev_printk(KERN_ERR, host->dev, "PCI ERROR; PCI IRQ cause=0x%08x\n", 2930 dev_err(host->dev, "PCI ERROR; PCI IRQ cause=0x%08x\n", err_cause);
2934 err_cause);
2935 2931
2936 DPRINTK("All regs @ PCI error\n"); 2932 DPRINTK("All regs @ PCI error\n");
2937 mv_dump_all_regs(mmio, -1, to_pci_dev(host->dev)); 2933 mv_dump_all_regs(mmio, -1, to_pci_dev(host->dev));
@@ -3760,8 +3756,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
3760 hp_flags |= MV_HP_ERRATA_50XXB2; 3756 hp_flags |= MV_HP_ERRATA_50XXB2;
3761 break; 3757 break;
3762 default: 3758 default:
3763 dev_printk(KERN_WARNING, &pdev->dev, 3759 dev_warn(&pdev->dev,
3764 "Applying 50XXB2 workarounds to unknown rev\n"); 3760 "Applying 50XXB2 workarounds to unknown rev\n");
3765 hp_flags |= MV_HP_ERRATA_50XXB2; 3761 hp_flags |= MV_HP_ERRATA_50XXB2;
3766 break; 3762 break;
3767 } 3763 }
@@ -3780,8 +3776,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
3780 hp_flags |= MV_HP_ERRATA_50XXB2; 3776 hp_flags |= MV_HP_ERRATA_50XXB2;
3781 break; 3777 break;
3782 default: 3778 default:
3783 dev_printk(KERN_WARNING, &pdev->dev, 3779 dev_warn(&pdev->dev,
3784 "Applying B2 workarounds to unknown rev\n"); 3780 "Applying B2 workarounds to unknown rev\n");
3785 hp_flags |= MV_HP_ERRATA_50XXB2; 3781 hp_flags |= MV_HP_ERRATA_50XXB2;
3786 break; 3782 break;
3787 } 3783 }
@@ -3801,8 +3797,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
3801 hp_flags |= MV_HP_ERRATA_60X1C0; 3797 hp_flags |= MV_HP_ERRATA_60X1C0;
3802 break; 3798 break;
3803 default: 3799 default:
3804 dev_printk(KERN_WARNING, &pdev->dev, 3800 dev_warn(&pdev->dev,
3805 "Applying B2 workarounds to unknown rev\n"); 3801 "Applying B2 workarounds to unknown rev\n");
3806 hp_flags |= MV_HP_ERRATA_60X1B2; 3802 hp_flags |= MV_HP_ERRATA_60X1B2;
3807 break; 3803 break;
3808 } 3804 }
@@ -3851,8 +3847,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
3851 hp_flags |= MV_HP_ERRATA_60X1C0; 3847 hp_flags |= MV_HP_ERRATA_60X1C0;
3852 break; 3848 break;
3853 default: 3849 default:
3854 dev_printk(KERN_WARNING, &pdev->dev, 3850 dev_warn(&pdev->dev,
3855 "Applying 60X1C0 workarounds to unknown rev\n"); 3851 "Applying 60X1C0 workarounds to unknown rev\n");
3856 hp_flags |= MV_HP_ERRATA_60X1C0; 3852 hp_flags |= MV_HP_ERRATA_60X1C0;
3857 break; 3853 break;
3858 } 3854 }
@@ -3867,8 +3863,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
3867 break; 3863 break;
3868 3864
3869 default: 3865 default:
3870 dev_printk(KERN_ERR, host->dev, 3866 dev_err(host->dev, "BUG: invalid board index %u\n", board_idx);
3871 "BUG: invalid board index %u\n", board_idx);
3872 return 1; 3867 return 1;
3873 } 3868 }
3874 3869
@@ -4023,7 +4018,6 @@ static void mv_conf_mbus_windows(struct mv_host_priv *hpriv,
4023 */ 4018 */
4024static int mv_platform_probe(struct platform_device *pdev) 4019static int mv_platform_probe(struct platform_device *pdev)
4025{ 4020{
4026 static int printed_version;
4027 const struct mv_sata_platform_data *mv_platform_data; 4021 const struct mv_sata_platform_data *mv_platform_data;
4028 const struct ata_port_info *ppi[] = 4022 const struct ata_port_info *ppi[] =
4029 { &mv_port_info[chip_soc], NULL }; 4023 { &mv_port_info[chip_soc], NULL };
@@ -4032,8 +4026,7 @@ static int mv_platform_probe(struct platform_device *pdev)
4032 struct resource *res; 4026 struct resource *res;
4033 int n_ports, rc; 4027 int n_ports, rc;
4034 4028
4035 if (!printed_version++) 4029 ata_print_version_once(&pdev->dev, DRV_VERSION);
4036 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
4037 4030
4038 /* 4031 /*
4039 * Simple resource validation .. 4032 * Simple resource validation ..
@@ -4091,9 +4084,8 @@ static int mv_platform_probe(struct platform_device *pdev)
4091 if (rc) 4084 if (rc)
4092 goto err; 4085 goto err;
4093 4086
4094 dev_printk(KERN_INFO, &pdev->dev, 4087 dev_info(&pdev->dev, "slots %u ports %d\n",
4095 "slots %u ports %d\n", (unsigned)MV_MAX_Q_DEPTH, 4088 (unsigned)MV_MAX_Q_DEPTH, host->n_ports);
4096 host->n_ports);
4097 4089
4098 return ata_host_activate(host, platform_get_irq(pdev, 0), mv_interrupt, 4090 return ata_host_activate(host, platform_get_irq(pdev, 0), mv_interrupt,
4099 IRQF_SHARED, &mv6_sht); 4091 IRQF_SHARED, &mv6_sht);
@@ -4217,22 +4209,21 @@ static int pci_go_64(struct pci_dev *pdev)
4217 if (rc) { 4209 if (rc) {
4218 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 4210 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
4219 if (rc) { 4211 if (rc) {
4220 dev_printk(KERN_ERR, &pdev->dev, 4212 dev_err(&pdev->dev,
4221 "64-bit DMA enable failed\n"); 4213 "64-bit DMA enable failed\n");
4222 return rc; 4214 return rc;
4223 } 4215 }
4224 } 4216 }
4225 } else { 4217 } else {
4226 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 4218 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
4227 if (rc) { 4219 if (rc) {
4228 dev_printk(KERN_ERR, &pdev->dev, 4220 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
4229 "32-bit DMA enable failed\n");
4230 return rc; 4221 return rc;
4231 } 4222 }
4232 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 4223 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
4233 if (rc) { 4224 if (rc) {
4234 dev_printk(KERN_ERR, &pdev->dev, 4225 dev_err(&pdev->dev,
4235 "32-bit consistent DMA enable failed\n"); 4226 "32-bit consistent DMA enable failed\n");
4236 return rc; 4227 return rc;
4237 } 4228 }
4238 } 4229 }
@@ -4276,10 +4267,9 @@ static void mv_print_info(struct ata_host *host)
4276 else 4267 else
4277 gen = "?"; 4268 gen = "?";
4278 4269
4279 dev_printk(KERN_INFO, &pdev->dev, 4270 dev_info(&pdev->dev, "Gen-%s %u slots %u ports %s mode IRQ via %s\n",
4280 "Gen-%s %u slots %u ports %s mode IRQ via %s\n", 4271 gen, (unsigned)MV_MAX_Q_DEPTH, host->n_ports,
4281 gen, (unsigned)MV_MAX_Q_DEPTH, host->n_ports, 4272 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
4282 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
4283} 4273}
4284 4274
4285/** 4275/**
@@ -4293,15 +4283,13 @@ static void mv_print_info(struct ata_host *host)
4293static int mv_pci_init_one(struct pci_dev *pdev, 4283static int mv_pci_init_one(struct pci_dev *pdev,
4294 const struct pci_device_id *ent) 4284 const struct pci_device_id *ent)
4295{ 4285{
4296 static int printed_version;
4297 unsigned int board_idx = (unsigned int)ent->driver_data; 4286 unsigned int board_idx = (unsigned int)ent->driver_data;
4298 const struct ata_port_info *ppi[] = { &mv_port_info[board_idx], NULL }; 4287 const struct ata_port_info *ppi[] = { &mv_port_info[board_idx], NULL };
4299 struct ata_host *host; 4288 struct ata_host *host;
4300 struct mv_host_priv *hpriv; 4289 struct mv_host_priv *hpriv;
4301 int n_ports, port, rc; 4290 int n_ports, port, rc;
4302 4291
4303 if (!printed_version++) 4292 ata_print_version_once(&pdev->dev, DRV_VERSION);
4304 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
4305 4293
4306 /* allocate host */ 4294 /* allocate host */
4307 n_ports = mv_get_hc_count(ppi[0]->flags) * MV_PORTS_PER_HC; 4295 n_ports = mv_get_hc_count(ppi[0]->flags) * MV_PORTS_PER_HC;
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index f173ef3bfc10..e0bc9646a38e 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -620,9 +620,8 @@ static void nv_adma_register_mode(struct ata_port *ap)
620 count++; 620 count++;
621 } 621 }
622 if (count == 20) 622 if (count == 20)
623 ata_port_printk(ap, KERN_WARNING, 623 ata_port_warn(ap, "timeout waiting for ADMA IDLE, stat=0x%hx\n",
624 "timeout waiting for ADMA IDLE, stat=0x%hx\n", 624 status);
625 status);
626 625
627 tmp = readw(mmio + NV_ADMA_CTL); 626 tmp = readw(mmio + NV_ADMA_CTL);
628 writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL); 627 writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
@@ -635,9 +634,9 @@ static void nv_adma_register_mode(struct ata_port *ap)
635 count++; 634 count++;
636 } 635 }
637 if (count == 20) 636 if (count == 20)
638 ata_port_printk(ap, KERN_WARNING, 637 ata_port_warn(ap,
639 "timeout waiting for ADMA LEGACY, stat=0x%hx\n", 638 "timeout waiting for ADMA LEGACY, stat=0x%hx\n",
640 status); 639 status);
641 640
642 pp->flags |= NV_ADMA_PORT_REGISTER_MODE; 641 pp->flags |= NV_ADMA_PORT_REGISTER_MODE;
643} 642}
@@ -665,7 +664,7 @@ static void nv_adma_mode(struct ata_port *ap)
665 count++; 664 count++;
666 } 665 }
667 if (count == 20) 666 if (count == 20)
668 ata_port_printk(ap, KERN_WARNING, 667 ata_port_warn(ap,
669 "timeout waiting for ADMA LEGACY clear and IDLE, stat=0x%hx\n", 668 "timeout waiting for ADMA LEGACY clear and IDLE, stat=0x%hx\n",
670 status); 669 status);
671 670
@@ -772,10 +771,10 @@ static int nv_adma_slave_config(struct scsi_device *sdev)
772 771
773 blk_queue_segment_boundary(sdev->request_queue, segment_boundary); 772 blk_queue_segment_boundary(sdev->request_queue, segment_boundary);
774 blk_queue_max_segments(sdev->request_queue, sg_tablesize); 773 blk_queue_max_segments(sdev->request_queue, sg_tablesize);
775 ata_port_printk(ap, KERN_INFO, 774 ata_port_info(ap,
776 "DMA mask 0x%llX, segment boundary 0x%lX, hw segs %hu\n", 775 "DMA mask 0x%llX, segment boundary 0x%lX, hw segs %hu\n",
777 (unsigned long long)*ap->host->dev->dma_mask, 776 (unsigned long long)*ap->host->dev->dma_mask,
778 segment_boundary, sg_tablesize); 777 segment_boundary, sg_tablesize);
779 778
780 spin_unlock_irqrestore(ap->lock, flags); 779 spin_unlock_irqrestore(ap->lock, flags);
781 780
@@ -1443,8 +1442,7 @@ static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc)
1443 existing commands. */ 1442 existing commands. */
1444 if (unlikely(qc->tf.protocol == ATA_PROT_NCQ && 1443 if (unlikely(qc->tf.protocol == ATA_PROT_NCQ &&
1445 (qc->flags & ATA_QCFLAG_RESULT_TF))) { 1444 (qc->flags & ATA_QCFLAG_RESULT_TF))) {
1446 ata_dev_printk(qc->dev, KERN_ERR, 1445 ata_dev_err(qc->dev, "NCQ w/ RESULT_TF not allowed\n");
1447 "NCQ w/ RESULT_TF not allowed\n");
1448 return AC_ERR_SYSTEM; 1446 return AC_ERR_SYSTEM;
1449 } 1447 }
1450 1448
@@ -1581,15 +1579,15 @@ static int nv_hardreset(struct ata_link *link, unsigned int *class,
1581 int rc; 1579 int rc;
1582 1580
1583 if (!(ehc->i.flags & ATA_EHI_QUIET)) 1581 if (!(ehc->i.flags & ATA_EHI_QUIET))
1584 ata_link_printk(link, KERN_INFO, "nv: skipping " 1582 ata_link_info(link,
1585 "hardreset on occupied port\n"); 1583 "nv: skipping hardreset on occupied port\n");
1586 1584
1587 /* make sure the link is online */ 1585 /* make sure the link is online */
1588 rc = sata_link_resume(link, timing, deadline); 1586 rc = sata_link_resume(link, timing, deadline);
1589 /* whine about phy resume failure but proceed */ 1587 /* whine about phy resume failure but proceed */
1590 if (rc && rc != -EOPNOTSUPP) 1588 if (rc && rc != -EOPNOTSUPP)
1591 ata_link_printk(link, KERN_WARNING, "failed to resume " 1589 ata_link_warn(link, "failed to resume link (errno=%d)\n",
1592 "link (errno=%d)\n", rc); 1590 rc);
1593 } 1591 }
1594 1592
1595 /* device signature acquisition is unreliable */ 1593 /* device signature acquisition is unreliable */
@@ -1686,7 +1684,7 @@ static void nv_adma_error_handler(struct ata_port *ap)
1686 u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); 1684 u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT);
1687 u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); 1685 u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX);
1688 1686
1689 ata_port_printk(ap, KERN_ERR, 1687 ata_port_err(ap,
1690 "EH in ADMA mode, notifier 0x%X " 1688 "EH in ADMA mode, notifier 0x%X "
1691 "notifier_error 0x%X gen_ctl 0x%X status 0x%X " 1689 "notifier_error 0x%X gen_ctl 0x%X status 0x%X "
1692 "next cpb count 0x%X next cpb idx 0x%x\n", 1690 "next cpb count 0x%X next cpb idx 0x%x\n",
@@ -1697,7 +1695,7 @@ static void nv_adma_error_handler(struct ata_port *ap)
1697 struct nv_adma_cpb *cpb = &pp->cpb[i]; 1695 struct nv_adma_cpb *cpb = &pp->cpb[i];
1698 if ((ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || 1696 if ((ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) ||
1699 ap->link.sactive & (1 << i)) 1697 ap->link.sactive & (1 << i))
1700 ata_port_printk(ap, KERN_ERR, 1698 ata_port_err(ap,
1701 "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", 1699 "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n",
1702 i, cpb->ctl_flags, cpb->resp_flags); 1700 i, cpb->ctl_flags, cpb->resp_flags);
1703 } 1701 }
@@ -1799,23 +1797,22 @@ static void nv_swncq_ncq_stop(struct ata_port *ap)
1799 u32 sactive; 1797 u32 sactive;
1800 u32 done_mask; 1798 u32 done_mask;
1801 1799
1802 ata_port_printk(ap, KERN_ERR, 1800 ata_port_err(ap, "EH in SWNCQ mode,QC:qc_active 0x%X sactive 0x%X\n",
1803 "EH in SWNCQ mode,QC:qc_active 0x%X sactive 0x%X\n", 1801 ap->qc_active, ap->link.sactive);
1804 ap->qc_active, ap->link.sactive); 1802 ata_port_err(ap,
1805 ata_port_printk(ap, KERN_ERR,
1806 "SWNCQ:qc_active 0x%X defer_bits 0x%X last_issue_tag 0x%x\n " 1803 "SWNCQ:qc_active 0x%X defer_bits 0x%X last_issue_tag 0x%x\n "
1807 "dhfis 0x%X dmafis 0x%X sdbfis 0x%X\n", 1804 "dhfis 0x%X dmafis 0x%X sdbfis 0x%X\n",
1808 pp->qc_active, pp->defer_queue.defer_bits, pp->last_issue_tag, 1805 pp->qc_active, pp->defer_queue.defer_bits, pp->last_issue_tag,
1809 pp->dhfis_bits, pp->dmafis_bits, pp->sdbfis_bits); 1806 pp->dhfis_bits, pp->dmafis_bits, pp->sdbfis_bits);
1810 1807
1811 ata_port_printk(ap, KERN_ERR, "ATA_REG 0x%X ERR_REG 0x%X\n", 1808 ata_port_err(ap, "ATA_REG 0x%X ERR_REG 0x%X\n",
1812 ap->ops->sff_check_status(ap), 1809 ap->ops->sff_check_status(ap),
1813 ioread8(ap->ioaddr.error_addr)); 1810 ioread8(ap->ioaddr.error_addr));
1814 1811
1815 sactive = readl(pp->sactive_block); 1812 sactive = readl(pp->sactive_block);
1816 done_mask = pp->qc_active ^ sactive; 1813 done_mask = pp->qc_active ^ sactive;
1817 1814
1818 ata_port_printk(ap, KERN_ERR, "tag : dhfis dmafis sdbfis sacitve\n"); 1815 ata_port_err(ap, "tag : dhfis dmafis sdbfis sactive\n");
1819 for (i = 0; i < ATA_MAX_QUEUE; i++) { 1816 for (i = 0; i < ATA_MAX_QUEUE; i++) {
1820 u8 err = 0; 1817 u8 err = 0;
1821 if (pp->qc_active & (1 << i)) 1818 if (pp->qc_active & (1 << i))
@@ -1825,13 +1822,13 @@ static void nv_swncq_ncq_stop(struct ata_port *ap)
1825 else 1822 else
1826 continue; 1823 continue;
1827 1824
1828 ata_port_printk(ap, KERN_ERR, 1825 ata_port_err(ap,
1829 "tag 0x%x: %01x %01x %01x %01x %s\n", i, 1826 "tag 0x%x: %01x %01x %01x %01x %s\n", i,
1830 (pp->dhfis_bits >> i) & 0x1, 1827 (pp->dhfis_bits >> i) & 0x1,
1831 (pp->dmafis_bits >> i) & 0x1, 1828 (pp->dmafis_bits >> i) & 0x1,
1832 (pp->sdbfis_bits >> i) & 0x1, 1829 (pp->sdbfis_bits >> i) & 0x1,
1833 (sactive >> i) & 0x1, 1830 (sactive >> i) & 0x1,
1834 (err ? "error! tag doesn't exit" : " ")); 1831 (err ? "error! tag doesn't exit" : " "));
1835 } 1832 }
1836 1833
1837 nv_swncq_pp_reinit(ap); 1834 nv_swncq_pp_reinit(ap);
@@ -1956,8 +1953,8 @@ static int nv_swncq_slave_config(struct scsi_device *sdev)
1956 1953
1957 if (strncmp(model_num, "Maxtor", 6) == 0) { 1954 if (strncmp(model_num, "Maxtor", 6) == 0) {
1958 ata_scsi_change_queue_depth(sdev, 1, SCSI_QDEPTH_DEFAULT); 1955 ata_scsi_change_queue_depth(sdev, 1, SCSI_QDEPTH_DEFAULT);
1959 ata_dev_printk(dev, KERN_NOTICE, 1956 ata_dev_notice(dev, "Disabling SWNCQ mode (depth %x)\n",
1960 "Disabling SWNCQ mode (depth %x)\n", sdev->queue_depth); 1957 sdev->queue_depth);
1961 } 1958 }
1962 1959
1963 return rc; 1960 return rc;
@@ -2356,7 +2353,6 @@ static irqreturn_t nv_swncq_interrupt(int irq, void *dev_instance)
2356 2353
2357static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 2354static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2358{ 2355{
2359 static int printed_version;
2360 const struct ata_port_info *ppi[] = { NULL, NULL }; 2356 const struct ata_port_info *ppi[] = { NULL, NULL };
2361 struct nv_pi_priv *ipriv; 2357 struct nv_pi_priv *ipriv;
2362 struct ata_host *host; 2358 struct ata_host *host;
@@ -2373,8 +2369,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2373 if (pci_resource_start(pdev, bar) == 0) 2369 if (pci_resource_start(pdev, bar) == 0)
2374 return -ENODEV; 2370 return -ENODEV;
2375 2371
2376 if (!printed_version++) 2372 ata_print_version_once(&pdev->dev, DRV_VERSION);
2377 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
2378 2373
2379 rc = pcim_enable_device(pdev); 2374 rc = pcim_enable_device(pdev);
2380 if (rc) 2375 if (rc)
@@ -2382,10 +2377,10 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2382 2377
2383 /* determine type and allocate host */ 2378 /* determine type and allocate host */
2384 if (type == CK804 && adma_enabled) { 2379 if (type == CK804 && adma_enabled) {
2385 dev_printk(KERN_NOTICE, &pdev->dev, "Using ADMA mode\n"); 2380 dev_notice(&pdev->dev, "Using ADMA mode\n");
2386 type = ADMA; 2381 type = ADMA;
2387 } else if (type == MCP5x && swncq_enabled) { 2382 } else if (type == MCP5x && swncq_enabled) {
2388 dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ mode\n"); 2383 dev_notice(&pdev->dev, "Using SWNCQ mode\n");
2389 type = SWNCQ; 2384 type = SWNCQ;
2390 } 2385 }
2391 2386
@@ -2429,7 +2424,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2429 nv_swncq_host_init(host); 2424 nv_swncq_host_init(host);
2430 2425
2431 if (msi_enabled) { 2426 if (msi_enabled) {
2432 dev_printk(KERN_NOTICE, &pdev->dev, "Using MSI\n"); 2427 dev_notice(&pdev->dev, "Using MSI\n");
2433 pci_enable_msi(pdev); 2428 pci_enable_msi(pdev);
2434 } 2429 }
2435 2430
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index a004b1e0ea6d..000fcc99e01d 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -1179,7 +1179,6 @@ static void pdc_host_init(struct ata_host *host)
1179static int pdc_ata_init_one(struct pci_dev *pdev, 1179static int pdc_ata_init_one(struct pci_dev *pdev,
1180 const struct pci_device_id *ent) 1180 const struct pci_device_id *ent)
1181{ 1181{
1182 static int printed_version;
1183 const struct ata_port_info *pi = &pdc_port_info[ent->driver_data]; 1182 const struct ata_port_info *pi = &pdc_port_info[ent->driver_data];
1184 const struct ata_port_info *ppi[PDC_MAX_PORTS]; 1183 const struct ata_port_info *ppi[PDC_MAX_PORTS];
1185 struct ata_host *host; 1184 struct ata_host *host;
@@ -1187,8 +1186,7 @@ static int pdc_ata_init_one(struct pci_dev *pdev,
1187 int n_ports, i, rc; 1186 int n_ports, i, rc;
1188 int is_sataii_tx4; 1187 int is_sataii_tx4;
1189 1188
1190 if (!printed_version++) 1189 ata_print_version_once(&pdev->dev, DRV_VERSION);
1191 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1192 1190
1193 /* enable and acquire resources */ 1191 /* enable and acquire resources */
1194 rc = pcim_enable_device(pdev); 1192 rc = pcim_enable_device(pdev);
@@ -1217,7 +1215,7 @@ static int pdc_ata_init_one(struct pci_dev *pdev,
1217 1215
1218 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); 1216 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
1219 if (!host) { 1217 if (!host) {
1220 dev_printk(KERN_ERR, &pdev->dev, "failed to allocate host\n"); 1218 dev_err(&pdev->dev, "failed to allocate host\n");
1221 return -ENOMEM; 1219 return -ENOMEM;
1222 } 1220 }
1223 host->iomap = pcim_iomap_table(pdev); 1221 host->iomap = pcim_iomap_table(pdev);
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index c5603265fa58..9d1a47bb21b3 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -563,21 +563,20 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
563 if (rc) { 563 if (rc) {
564 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 564 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
565 if (rc) { 565 if (rc) {
566 dev_printk(KERN_ERR, &pdev->dev, 566 dev_err(&pdev->dev,
567 "64-bit DMA enable failed\n"); 567 "64-bit DMA enable failed\n");
568 return rc; 568 return rc;
569 } 569 }
570 } 570 }
571 } else { 571 } else {
572 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 572 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
573 if (rc) { 573 if (rc) {
574 dev_printk(KERN_ERR, &pdev->dev, 574 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
575 "32-bit DMA enable failed\n");
576 return rc; 575 return rc;
577 } 576 }
578 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 577 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
579 if (rc) { 578 if (rc) {
580 dev_printk(KERN_ERR, &pdev->dev, 579 dev_err(&pdev->dev,
581 "32-bit consistent DMA enable failed\n"); 580 "32-bit consistent DMA enable failed\n");
582 return rc; 581 return rc;
583 } 582 }
@@ -588,14 +587,12 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
588static int qs_ata_init_one(struct pci_dev *pdev, 587static int qs_ata_init_one(struct pci_dev *pdev,
589 const struct pci_device_id *ent) 588 const struct pci_device_id *ent)
590{ 589{
591 static int printed_version;
592 unsigned int board_idx = (unsigned int) ent->driver_data; 590 unsigned int board_idx = (unsigned int) ent->driver_data;
593 const struct ata_port_info *ppi[] = { &qs_port_info[board_idx], NULL }; 591 const struct ata_port_info *ppi[] = { &qs_port_info[board_idx], NULL };
594 struct ata_host *host; 592 struct ata_host *host;
595 int rc, port_no; 593 int rc, port_no;
596 594
597 if (!printed_version++) 595 ata_print_version_once(&pdev->dev, DRV_VERSION);
598 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
599 596
600 /* alloc host */ 597 /* alloc host */
601 host = ata_host_alloc_pinfo(&pdev->dev, ppi, QS_PORTS); 598 host = ata_host_alloc_pinfo(&pdev->dev, ppi, QS_PORTS);
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index b42edaaf3a53..98c1d780f552 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -643,8 +643,8 @@ static void sil_dev_config(struct ata_device *dev)
643 ((ap->flags & SIL_FLAG_MOD15WRITE) && 643 ((ap->flags & SIL_FLAG_MOD15WRITE) &&
644 (quirks & SIL_QUIRK_MOD15WRITE))) { 644 (quirks & SIL_QUIRK_MOD15WRITE))) {
645 if (print_info) 645 if (print_info)
646 ata_dev_printk(dev, KERN_INFO, "applying Seagate " 646 ata_dev_info(dev,
647 "errata fix (mod15write workaround)\n"); 647 "applying Seagate errata fix (mod15write workaround)\n");
648 dev->max_sectors = 15; 648 dev->max_sectors = 15;
649 return; 649 return;
650 } 650 }
@@ -652,8 +652,8 @@ static void sil_dev_config(struct ata_device *dev)
652 /* limit to udma5 */ 652 /* limit to udma5 */
653 if (quirks & SIL_QUIRK_UDMA5MAX) { 653 if (quirks & SIL_QUIRK_UDMA5MAX) {
654 if (print_info) 654 if (print_info)
655 ata_dev_printk(dev, KERN_INFO, "applying Maxtor " 655 ata_dev_info(dev, "applying Maxtor errata fix %s\n",
656 "errata fix %s\n", model_num); 656 model_num);
657 dev->udma_mask &= ATA_UDMA5; 657 dev->udma_mask &= ATA_UDMA5;
658 return; 658 return;
659 } 659 }
@@ -676,8 +676,8 @@ static void sil_init_controller(struct ata_host *host)
676 writew(cls << 8 | cls, 676 writew(cls << 8 | cls,
677 mmio_base + sil_port[i].fifo_cfg); 677 mmio_base + sil_port[i].fifo_cfg);
678 } else 678 } else
679 dev_printk(KERN_WARNING, &pdev->dev, 679 dev_warn(&pdev->dev,
680 "cache line size not set. Driver may not function\n"); 680 "cache line size not set. Driver may not function\n");
681 681
682 /* Apply R_ERR on DMA activate FIS errata workaround */ 682 /* Apply R_ERR on DMA activate FIS errata workaround */
683 if (host->ports[0]->flags & SIL_FLAG_RERR_ON_DMA_ACT) { 683 if (host->ports[0]->flags & SIL_FLAG_RERR_ON_DMA_ACT) {
@@ -688,9 +688,8 @@ static void sil_init_controller(struct ata_host *host)
688 if ((tmp & 0x3) != 0x01) 688 if ((tmp & 0x3) != 0x01)
689 continue; 689 continue;
690 if (!cnt) 690 if (!cnt)
691 dev_printk(KERN_INFO, &pdev->dev, 691 dev_info(&pdev->dev,
692 "Applying R_ERR on DMA activate " 692 "Applying R_ERR on DMA activate FIS errata fix\n");
693 "FIS errata fix\n");
694 writel(tmp & ~0x3, mmio_base + sil_port[i].sfis_cfg); 693 writel(tmp & ~0x3, mmio_base + sil_port[i].sfis_cfg);
695 cnt++; 694 cnt++;
696 } 695 }
@@ -733,7 +732,6 @@ static bool sil_broken_system_poweroff(struct pci_dev *pdev)
733 732
734static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 733static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
735{ 734{
736 static int printed_version;
737 int board_id = ent->driver_data; 735 int board_id = ent->driver_data;
738 struct ata_port_info pi = sil_port_info[board_id]; 736 struct ata_port_info pi = sil_port_info[board_id];
739 const struct ata_port_info *ppi[] = { &pi, NULL }; 737 const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -742,8 +740,7 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
742 int n_ports, rc; 740 int n_ports, rc;
743 unsigned int i; 741 unsigned int i;
744 742
745 if (!printed_version++) 743 ata_print_version_once(&pdev->dev, DRV_VERSION);
746 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
747 744
748 /* allocate host */ 745 /* allocate host */
749 n_ports = 2; 746 n_ports = 2;
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 06c564e55051..55470f337e51 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -694,7 +694,7 @@ static int sil24_softreset(struct ata_link *link, unsigned int *class,
694 return 0; 694 return 0;
695 695
696 err: 696 err:
697 ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason); 697 ata_link_err(link, "softreset failed (%s)\n", reason);
698 return -EIO; 698 return -EIO;
699} 699}
700 700
@@ -714,8 +714,8 @@ static int sil24_hardreset(struct ata_link *link, unsigned int *class,
714 * This happens often after PM DMA CS errata. 714 * This happens often after PM DMA CS errata.
715 */ 715 */
716 if (pp->do_port_rst) { 716 if (pp->do_port_rst) {
717 ata_port_printk(ap, KERN_WARNING, "controller in dubious " 717 ata_port_warn(ap,
718 "state, performing PORT_RST\n"); 718 "controller in dubious state, performing PORT_RST\n");
719 719
720 writel(PORT_CS_PORT_RST, port + PORT_CTRL_STAT); 720 writel(PORT_CS_PORT_RST, port + PORT_CTRL_STAT);
721 ata_msleep(ap, 10); 721 ata_msleep(ap, 10);
@@ -773,7 +773,7 @@ static int sil24_hardreset(struct ata_link *link, unsigned int *class,
773 goto retry; 773 goto retry;
774 } 774 }
775 775
776 ata_link_printk(link, KERN_ERR, "hardreset failed (%s)\n", reason); 776 ata_link_err(link, "hardreset failed (%s)\n", reason);
777 return -EIO; 777 return -EIO;
778} 778}
779 779
@@ -925,7 +925,7 @@ static void sil24_pmp_attach(struct ata_port *ap)
925 925
926 if (sata_pmp_gscr_vendor(gscr) == 0x11ab && 926 if (sata_pmp_gscr_vendor(gscr) == 0x11ab &&
927 sata_pmp_gscr_devid(gscr) == 0x4140) { 927 sata_pmp_gscr_devid(gscr) == 0x4140) {
928 ata_port_printk(ap, KERN_INFO, 928 ata_port_info(ap,
929 "disabling NCQ support due to sil24-mv4140 quirk\n"); 929 "disabling NCQ support due to sil24-mv4140 quirk\n");
930 ap->flags &= ~ATA_FLAG_NCQ; 930 ap->flags &= ~ATA_FLAG_NCQ;
931 } 931 }
@@ -946,8 +946,7 @@ static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class,
946 946
947 rc = sil24_init_port(link->ap); 947 rc = sil24_init_port(link->ap);
948 if (rc) { 948 if (rc) {
949 ata_link_printk(link, KERN_ERR, 949 ata_link_err(link, "hardreset failed (port not ready)\n");
950 "hardreset failed (port not ready)\n");
951 return rc; 950 return rc;
952 } 951 }
953 952
@@ -1141,8 +1140,8 @@ static inline void sil24_host_intr(struct ata_port *ap)
1141 1140
1142 /* spurious interrupts are expected if PCIX_IRQ_WOC */ 1141 /* spurious interrupts are expected if PCIX_IRQ_WOC */
1143 if (!(ap->flags & SIL24_FLAG_PCIX_IRQ_WOC) && ata_ratelimit()) 1142 if (!(ap->flags & SIL24_FLAG_PCIX_IRQ_WOC) && ata_ratelimit())
1144 ata_port_printk(ap, KERN_INFO, "spurious interrupt " 1143 ata_port_info(ap,
1145 "(slot_stat 0x%x active_tag %d sactive 0x%x)\n", 1144 "spurious interrupt (slot_stat 0x%x active_tag %d sactive 0x%x)\n",
1146 slot_stat, ap->link.active_tag, ap->link.sactive); 1145 slot_stat, ap->link.active_tag, ap->link.sactive);
1147} 1146}
1148 1147
@@ -1256,8 +1255,8 @@ static void sil24_init_controller(struct ata_host *host)
1256 PORT_CS_PORT_RST, 1255 PORT_CS_PORT_RST,
1257 PORT_CS_PORT_RST, 10, 100); 1256 PORT_CS_PORT_RST, 10, 100);
1258 if (tmp & PORT_CS_PORT_RST) 1257 if (tmp & PORT_CS_PORT_RST)
1259 dev_printk(KERN_ERR, host->dev, 1258 dev_err(host->dev,
1260 "failed to clear port RST\n"); 1259 "failed to clear port RST\n");
1261 } 1260 }
1262 1261
1263 /* configure port */ 1262 /* configure port */
@@ -1271,7 +1270,6 @@ static void sil24_init_controller(struct ata_host *host)
1271static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1270static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1272{ 1271{
1273 extern int __MARKER__sil24_cmd_block_is_sized_wrongly; 1272 extern int __MARKER__sil24_cmd_block_is_sized_wrongly;
1274 static int printed_version;
1275 struct ata_port_info pi = sil24_port_info[ent->driver_data]; 1273 struct ata_port_info pi = sil24_port_info[ent->driver_data];
1276 const struct ata_port_info *ppi[] = { &pi, NULL }; 1274 const struct ata_port_info *ppi[] = { &pi, NULL };
1277 void __iomem * const *iomap; 1275 void __iomem * const *iomap;
@@ -1283,8 +1281,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1283 if (sizeof(union sil24_cmd_block) != PAGE_SIZE) 1281 if (sizeof(union sil24_cmd_block) != PAGE_SIZE)
1284 __MARKER__sil24_cmd_block_is_sized_wrongly = 1; 1282 __MARKER__sil24_cmd_block_is_sized_wrongly = 1;
1285 1283
1286 if (!printed_version++) 1284 ata_print_version_once(&pdev->dev, DRV_VERSION);
1287 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1288 1285
1289 /* acquire resources */ 1286 /* acquire resources */
1290 rc = pcim_enable_device(pdev); 1287 rc = pcim_enable_device(pdev);
@@ -1302,9 +1299,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1302 if (pi.flags & SIL24_FLAG_PCIX_IRQ_WOC) { 1299 if (pi.flags & SIL24_FLAG_PCIX_IRQ_WOC) {
1303 tmp = readl(iomap[SIL24_HOST_BAR] + HOST_CTRL); 1300 tmp = readl(iomap[SIL24_HOST_BAR] + HOST_CTRL);
1304 if (tmp & (HOST_CTRL_TRDY | HOST_CTRL_STOP | HOST_CTRL_DEVSEL)) 1301 if (tmp & (HOST_CTRL_TRDY | HOST_CTRL_STOP | HOST_CTRL_DEVSEL))
1305 dev_printk(KERN_INFO, &pdev->dev, 1302 dev_info(&pdev->dev,
1306 "Applying completion IRQ loss on PCI-X " 1303 "Applying completion IRQ loss on PCI-X errata fix\n");
1307 "errata fix\n");
1308 else 1304 else
1309 pi.flags &= ~SIL24_FLAG_PCIX_IRQ_WOC; 1305 pi.flags &= ~SIL24_FLAG_PCIX_IRQ_WOC;
1310 } 1306 }
@@ -1322,22 +1318,21 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1322 if (rc) { 1318 if (rc) {
1323 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 1319 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
1324 if (rc) { 1320 if (rc) {
1325 dev_printk(KERN_ERR, &pdev->dev, 1321 dev_err(&pdev->dev,
1326 "64-bit DMA enable failed\n"); 1322 "64-bit DMA enable failed\n");
1327 return rc; 1323 return rc;
1328 } 1324 }
1329 } 1325 }
1330 } else { 1326 } else {
1331 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 1327 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1332 if (rc) { 1328 if (rc) {
1333 dev_printk(KERN_ERR, &pdev->dev, 1329 dev_err(&pdev->dev, "32-bit DMA enable failed\n");
1334 "32-bit DMA enable failed\n");
1335 return rc; 1330 return rc;
1336 } 1331 }
1337 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 1332 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
1338 if (rc) { 1333 if (rc) {
1339 dev_printk(KERN_ERR, &pdev->dev, 1334 dev_err(&pdev->dev,
1340 "32-bit consistent DMA enable failed\n"); 1335 "32-bit consistent DMA enable failed\n");
1341 return rc; 1336 return rc;
1342 } 1337 }
1343 } 1338 }
@@ -1350,7 +1345,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1350 sil24_init_controller(host); 1345 sil24_init_controller(host);
1351 1346
1352 if (sata_sil24_msi && !pci_enable_msi(pdev)) { 1347 if (sata_sil24_msi && !pci_enable_msi(pdev)) {
1353 dev_printk(KERN_INFO, &pdev->dev, "Using MSI\n"); 1348 dev_info(&pdev->dev, "Using MSI\n");
1354 pci_intx(pdev, 0); 1349 pci_intx(pdev, 0);
1355 } 1350 }
1356 1351
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index cdcc13e9cf51..447d9c05fb5a 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -193,7 +193,6 @@ static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
193 193
194static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 194static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
195{ 195{
196 static int printed_version;
197 struct ata_port_info pi = sis_port_info; 196 struct ata_port_info pi = sis_port_info;
198 const struct ata_port_info *ppi[] = { &pi, &pi }; 197 const struct ata_port_info *ppi[] = { &pi, &pi };
199 struct ata_host *host; 198 struct ata_host *host;
@@ -202,8 +201,7 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
202 u8 port2_start = 0x20; 201 u8 port2_start = 0x20;
203 int i, rc; 202 int i, rc;
204 203
205 if (!printed_version++) 204 ata_print_version_once(&pdev->dev, DRV_VERSION);
206 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
207 205
208 rc = pcim_enable_device(pdev); 206 rc = pcim_enable_device(pdev);
209 if (rc) 207 if (rc)
@@ -241,12 +239,12 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
241 break; 239 break;
242 } 240 }
243 if ((pmr & SIS_PMR_COMBINED) == 0) { 241 if ((pmr & SIS_PMR_COMBINED) == 0) {
244 dev_printk(KERN_INFO, &pdev->dev, 242 dev_info(&pdev->dev,
245 "Detected SiS 180/181/964 chipset in SATA mode\n"); 243 "Detected SiS 180/181/964 chipset in SATA mode\n");
246 port2_start = 64; 244 port2_start = 64;
247 } else { 245 } else {
248 dev_printk(KERN_INFO, &pdev->dev, 246 dev_info(&pdev->dev,
249 "Detected SiS 180/181 chipset in combined mode\n"); 247 "Detected SiS 180/181 chipset in combined mode\n");
250 port2_start = 0; 248 port2_start = 0;
251 pi.flags |= ATA_FLAG_SLAVE_POSS; 249 pi.flags |= ATA_FLAG_SLAVE_POSS;
252 } 250 }
@@ -256,24 +254,22 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
256 case 0x0183: 254 case 0x0183:
257 pci_read_config_dword(pdev, 0x6C, &val); 255 pci_read_config_dword(pdev, 0x6C, &val);
258 if (val & (1L << 31)) { 256 if (val & (1L << 31)) {
259 dev_printk(KERN_INFO, &pdev->dev, 257 dev_info(&pdev->dev, "Detected SiS 182/965 chipset\n");
260 "Detected SiS 182/965 chipset\n");
261 pi.flags |= ATA_FLAG_SLAVE_POSS; 258 pi.flags |= ATA_FLAG_SLAVE_POSS;
262 } else { 259 } else {
263 dev_printk(KERN_INFO, &pdev->dev, 260 dev_info(&pdev->dev, "Detected SiS 182/965L chipset\n");
264 "Detected SiS 182/965L chipset\n");
265 } 261 }
266 break; 262 break;
267 263
268 case 0x1182: 264 case 0x1182:
269 dev_printk(KERN_INFO, &pdev->dev, 265 dev_info(&pdev->dev,
270 "Detected SiS 1182/966/680 SATA controller\n"); 266 "Detected SiS 1182/966/680 SATA controller\n");
271 pi.flags |= ATA_FLAG_SLAVE_POSS; 267 pi.flags |= ATA_FLAG_SLAVE_POSS;
272 break; 268 break;
273 269
274 case 0x1183: 270 case 0x1183:
275 dev_printk(KERN_INFO, &pdev->dev, 271 dev_info(&pdev->dev,
276 "Detected SiS 1183/966/966L/968/680 controller in PATA mode\n"); 272 "Detected SiS 1183/966/966L/968/680 controller in PATA mode\n");
277 ppi[0] = &sis_info133_for_sata; 273 ppi[0] = &sis_info133_for_sata;
278 ppi[1] = &sis_info133_for_sata; 274 ppi[1] = &sis_info133_for_sata;
279 break; 275 break;
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 35eabcf34568..c646118943ff 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -414,15 +414,13 @@ static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
414 414
415static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 415static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
416{ 416{
417 static int printed_version;
418 const struct ata_port_info *ppi[] = 417 const struct ata_port_info *ppi[] =
419 { &k2_port_info[ent->driver_data], NULL }; 418 { &k2_port_info[ent->driver_data], NULL };
420 struct ata_host *host; 419 struct ata_host *host;
421 void __iomem *mmio_base; 420 void __iomem *mmio_base;
422 int n_ports, i, rc, bar_pos; 421 int n_ports, i, rc, bar_pos;
423 422
424 if (!printed_version++) 423 ata_print_version_once(&pdev->dev, DRV_VERSION);
425 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
426 424
427 /* allocate host */ 425 /* allocate host */
428 n_ports = 4; 426 n_ports = 4;
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index 8fd3b7252bda..cdaebbe3d184 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -1440,15 +1440,13 @@ static void pdc_20621_init(struct ata_host *host)
1440static int pdc_sata_init_one(struct pci_dev *pdev, 1440static int pdc_sata_init_one(struct pci_dev *pdev,
1441 const struct pci_device_id *ent) 1441 const struct pci_device_id *ent)
1442{ 1442{
1443 static int printed_version;
1444 const struct ata_port_info *ppi[] = 1443 const struct ata_port_info *ppi[] =
1445 { &pdc_port_info[ent->driver_data], NULL }; 1444 { &pdc_port_info[ent->driver_data], NULL };
1446 struct ata_host *host; 1445 struct ata_host *host;
1447 struct pdc_host_priv *hpriv; 1446 struct pdc_host_priv *hpriv;
1448 int i, rc; 1447 int i, rc;
1449 1448
1450 if (!printed_version++) 1449 ata_print_version_once(&pdev->dev, DRV_VERSION);
1451 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1452 1450
1453 /* allocate host */ 1451 /* allocate host */
1454 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 4); 1452 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 4);
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index 235be717a713..b54ebfcdda32 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -145,7 +145,6 @@ static int uli_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
145 145
146static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 146static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
147{ 147{
148 static int printed_version;
149 const struct ata_port_info *ppi[] = { &uli_port_info, NULL }; 148 const struct ata_port_info *ppi[] = { &uli_port_info, NULL };
150 unsigned int board_idx = (unsigned int) ent->driver_data; 149 unsigned int board_idx = (unsigned int) ent->driver_data;
151 struct ata_host *host; 150 struct ata_host *host;
@@ -154,8 +153,7 @@ static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
154 struct ata_ioports *ioaddr; 153 struct ata_ioports *ioaddr;
155 int n_ports, rc; 154 int n_ports, rc;
156 155
157 if (!printed_version++) 156 ata_print_version_once(&pdev->dev, DRV_VERSION);
158 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
159 157
160 rc = pcim_enable_device(pdev); 158 rc = pcim_enable_device(pdev);
161 if (rc) 159 if (rc)
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 54434db15b12..f93e43b0ccd8 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -360,9 +360,9 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline)
360 360
361 online = (sstatus & 0xf) == 0x3; 361 online = (sstatus & 0xf) == 0x3;
362 362
363 ata_port_printk(ap, KERN_INFO, 363 ata_port_info(ap,
364 "SATA link %s 1.5 Gbps (SStatus %X SControl %X)\n", 364 "SATA link %s 1.5 Gbps (SStatus %X SControl %X)\n",
365 online ? "up" : "down", sstatus, scontrol); 365 online ? "up" : "down", sstatus, scontrol);
366 366
367 /* SStatus is read one more time */ 367 /* SStatus is read one more time */
368 svia_scr_read(link, SCR_STATUS, &sstatus); 368 svia_scr_read(link, SCR_STATUS, &sstatus);
@@ -469,7 +469,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
469 469
470 rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME); 470 rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME);
471 if (rc) { 471 if (rc) {
472 dev_printk(KERN_ERR, &pdev->dev, "failed to iomap PCI BAR 5\n"); 472 dev_err(&pdev->dev, "failed to iomap PCI BAR 5\n");
473 return rc; 473 return rc;
474 } 474 }
475 475
@@ -488,14 +488,14 @@ static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
488 488
489 *r_host = host = ata_host_alloc_pinfo(&pdev->dev, ppi, ARRAY_SIZE(ppi)); 489 *r_host = host = ata_host_alloc_pinfo(&pdev->dev, ppi, ARRAY_SIZE(ppi));
490 if (!host) { 490 if (!host) {
491 dev_printk(KERN_ERR, &pdev->dev, "failed to allocate host\n"); 491 dev_err(&pdev->dev, "failed to allocate host\n");
492 return -ENOMEM; 492 return -ENOMEM;
493 } 493 }
494 494
495 rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME); 495 rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME);
496 if (rc) { 496 if (rc) {
497 dev_printk(KERN_ERR, &pdev->dev, "failed to request/iomap " 497 dev_err(&pdev->dev, "failed to request/iomap PCI BARs (errno=%d)\n",
498 "PCI BARs (errno=%d)\n", rc); 498 rc);
499 return rc; 499 return rc;
500 } 500 }
501 host->iomap = pcim_iomap_table(pdev); 501 host->iomap = pcim_iomap_table(pdev);
@@ -526,7 +526,7 @@ static int vt8251_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
526 526
527 rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME); 527 rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME);
528 if (rc) { 528 if (rc) {
529 dev_printk(KERN_ERR, &pdev->dev, "failed to iomap PCI BAR 5\n"); 529 dev_err(&pdev->dev, "failed to iomap PCI BAR 5\n");
530 return rc; 530 return rc;
531 } 531 }
532 532
@@ -542,15 +542,14 @@ static void svia_configure(struct pci_dev *pdev, int board_id)
542 u8 tmp8; 542 u8 tmp8;
543 543
544 pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); 544 pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8);
545 dev_printk(KERN_INFO, &pdev->dev, "routed to hard irq line %d\n", 545 dev_info(&pdev->dev, "routed to hard irq line %d\n",
546 (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); 546 (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f);
547 547
548 /* make sure SATA channels are enabled */ 548 /* make sure SATA channels are enabled */
549 pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); 549 pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8);
550 if ((tmp8 & ALL_PORTS) != ALL_PORTS) { 550 if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
551 dev_printk(KERN_DEBUG, &pdev->dev, 551 dev_dbg(&pdev->dev, "enabling SATA channels (0x%x)\n",
552 "enabling SATA channels (0x%x)\n", 552 (int)tmp8);
553 (int) tmp8);
554 tmp8 |= ALL_PORTS; 553 tmp8 |= ALL_PORTS;
555 pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); 554 pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8);
556 } 555 }
@@ -558,9 +557,8 @@ static void svia_configure(struct pci_dev *pdev, int board_id)
558 /* make sure interrupts for each channel sent to us */ 557 /* make sure interrupts for each channel sent to us */
559 pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); 558 pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8);
560 if ((tmp8 & ALL_PORTS) != ALL_PORTS) { 559 if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
561 dev_printk(KERN_DEBUG, &pdev->dev, 560 dev_dbg(&pdev->dev, "enabling SATA channel interrupts (0x%x)\n",
562 "enabling SATA channel interrupts (0x%x)\n", 561 (int) tmp8);
563 (int) tmp8);
564 tmp8 |= ALL_PORTS; 562 tmp8 |= ALL_PORTS;
565 pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); 563 pci_write_config_byte(pdev, SATA_INT_GATE, tmp8);
566 } 564 }
@@ -568,9 +566,9 @@ static void svia_configure(struct pci_dev *pdev, int board_id)
568 /* make sure native mode is enabled */ 566 /* make sure native mode is enabled */
569 pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); 567 pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8);
570 if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { 568 if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) {
571 dev_printk(KERN_DEBUG, &pdev->dev, 569 dev_dbg(&pdev->dev,
572 "enabling SATA channel native mode (0x%x)\n", 570 "enabling SATA channel native mode (0x%x)\n",
573 (int) tmp8); 571 (int) tmp8);
574 tmp8 |= NATIVE_MODE_ALL; 572 tmp8 |= NATIVE_MODE_ALL;
575 pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); 573 pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8);
576 } 574 }
@@ -606,15 +604,13 @@ static void svia_configure(struct pci_dev *pdev, int board_id)
606 604
607static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 605static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
608{ 606{
609 static int printed_version;
610 unsigned int i; 607 unsigned int i;
611 int rc; 608 int rc;
612 struct ata_host *host = NULL; 609 struct ata_host *host = NULL;
613 int board_id = (int) ent->driver_data; 610 int board_id = (int) ent->driver_data;
614 const unsigned *bar_sizes; 611 const unsigned *bar_sizes;
615 612
616 if (!printed_version++) 613 ata_print_version_once(&pdev->dev, DRV_VERSION);
617 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
618 614
619 rc = pcim_enable_device(pdev); 615 rc = pcim_enable_device(pdev);
620 if (rc) 616 if (rc)
@@ -628,7 +624,7 @@ static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
628 for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++) 624 for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++)
629 if ((pci_resource_start(pdev, i) == 0) || 625 if ((pci_resource_start(pdev, i) == 0) ||
630 (pci_resource_len(pdev, i) < bar_sizes[i])) { 626 (pci_resource_len(pdev, i) < bar_sizes[i])) {
631 dev_printk(KERN_ERR, &pdev->dev, 627 dev_err(&pdev->dev,
632 "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n", 628 "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n",
633 i, 629 i,
634 (unsigned long long)pci_resource_start(pdev, i), 630 (unsigned long long)pci_resource_start(pdev, i),
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c
index 7c987371136e..6135a5288695 100644
--- a/drivers/ata/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -273,9 +273,8 @@ static irqreturn_t vsc_sata_interrupt(int irq, void *dev_instance)
273 273
274 if (unlikely(status == 0xffffffff || status == 0)) { 274 if (unlikely(status == 0xffffffff || status == 0)) {
275 if (status) 275 if (status)
276 dev_printk(KERN_ERR, host->dev, 276 dev_err(host->dev,
277 ": IRQ status == 0xffffffff, " 277 ": IRQ status == 0xffffffff, PCI fault or device removal?\n");
278 "PCI fault or device removal?\n");
279 goto out; 278 goto out;
280 } 279 }
281 280
@@ -347,14 +346,12 @@ static int __devinit vsc_sata_init_one(struct pci_dev *pdev,
347 .port_ops = &vsc_sata_ops, 346 .port_ops = &vsc_sata_ops,
348 }; 347 };
349 const struct ata_port_info *ppi[] = { &pi, NULL }; 348 const struct ata_port_info *ppi[] = { &pi, NULL };
350 static int printed_version;
351 struct ata_host *host; 349 struct ata_host *host;
352 void __iomem *mmio_base; 350 void __iomem *mmio_base;
353 int i, rc; 351 int i, rc;
354 u8 cls; 352 u8 cls;
355 353
356 if (!printed_version++) 354 ata_print_version_once(&pdev->dev, DRV_VERSION);
357 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
358 355
359 /* allocate host */ 356 /* allocate host */
360 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 4); 357 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 4);
diff --git a/drivers/bcma/core.c b/drivers/bcma/core.c
index 1ec7d4528dd0..4a04a49cc06d 100644
--- a/drivers/bcma/core.c
+++ b/drivers/bcma/core.c
@@ -50,3 +50,75 @@ int bcma_core_enable(struct bcma_device *core, u32 flags)
50 return 0; 50 return 0;
51} 51}
52EXPORT_SYMBOL_GPL(bcma_core_enable); 52EXPORT_SYMBOL_GPL(bcma_core_enable);
53
54void bcma_core_set_clockmode(struct bcma_device *core,
55 enum bcma_clkmode clkmode)
56{
57 u16 i;
58
59 WARN_ON(core->id.id != BCMA_CORE_CHIPCOMMON &&
60 core->id.id != BCMA_CORE_PCIE &&
61 core->id.id != BCMA_CORE_80211);
62
63 switch (clkmode) {
64 case BCMA_CLKMODE_FAST:
65 bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
66 udelay(64);
67 for (i = 0; i < 1500; i++) {
68 if (bcma_read32(core, BCMA_CLKCTLST) &
69 BCMA_CLKCTLST_HAVEHT) {
70 i = 0;
71 break;
72 }
73 udelay(10);
74 }
75 if (i)
76 pr_err("HT force timeout\n");
77 break;
78 case BCMA_CLKMODE_DYNAMIC:
79 pr_warn("Dynamic clockmode not supported yet!\n");
80 break;
81 }
82}
83EXPORT_SYMBOL_GPL(bcma_core_set_clockmode);
84
85void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status, bool on)
86{
87 u16 i;
88
89 WARN_ON(req & ~BCMA_CLKCTLST_EXTRESREQ);
90 WARN_ON(status & ~BCMA_CLKCTLST_EXTRESST);
91
92 if (on) {
93 bcma_set32(core, BCMA_CLKCTLST, req);
94 for (i = 0; i < 10000; i++) {
95 if ((bcma_read32(core, BCMA_CLKCTLST) & status) ==
96 status) {
97 i = 0;
98 break;
99 }
100 udelay(10);
101 }
102 if (i)
103 pr_err("PLL enable timeout\n");
104 } else {
105 pr_warn("Disabling PLL not supported yet!\n");
106 }
107}
108EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
109
110u32 bcma_core_dma_translation(struct bcma_device *core)
111{
112 switch (core->bus->hosttype) {
113 case BCMA_HOSTTYPE_PCI:
114 if (bcma_aread32(core, BCMA_IOST) & BCMA_IOST_DMA64)
115 return BCMA_DMA_TRANSLATION_DMA64_CMT;
116 else
117 return BCMA_DMA_TRANSLATION_DMA32_CMT;
118 default:
119 pr_err("DMA translation unknown for host %d\n",
120 core->bus->hosttype);
121 }
122 return BCMA_DMA_TRANSLATION_NONE;
123}
124EXPORT_SYMBOL(bcma_core_dma_translation);
diff --git a/drivers/bcma/driver_chipcommon.c b/drivers/bcma/driver_chipcommon.c
index 606102256b44..fb543024df2f 100644
--- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/driver_chipcommon.c
@@ -23,6 +23,9 @@ static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
23 23
24void bcma_core_chipcommon_init(struct bcma_drv_cc *cc) 24void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
25{ 25{
26 u32 leddc_on = 10;
27 u32 leddc_off = 90;
28
26 if (cc->core->id.rev >= 11) 29 if (cc->core->id.rev >= 11)
27 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT); 30 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
28 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP); 31 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
@@ -38,6 +41,17 @@ void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
38 bcma_pmu_init(cc); 41 bcma_pmu_init(cc);
39 if (cc->capabilities & BCMA_CC_CAP_PCTL) 42 if (cc->capabilities & BCMA_CC_CAP_PCTL)
40 pr_err("Power control not implemented!\n"); 43 pr_err("Power control not implemented!\n");
44
45 if (cc->core->id.rev >= 16) {
46 if (cc->core->bus->sprom.leddc_on_time &&
47 cc->core->bus->sprom.leddc_off_time) {
48 leddc_on = cc->core->bus->sprom.leddc_on_time;
49 leddc_off = cc->core->bus->sprom.leddc_off_time;
50 }
51 bcma_cc_write32(cc, BCMA_CC_GPIOTIMER,
52 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
53 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
54 }
41} 55}
42 56
43/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */ 57/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index dc6f34ac96a0..745d26491291 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -172,8 +172,10 @@ static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
172 chipid_top != 0x5300) 172 chipid_top != 0x5300)
173 return false; 173 return false;
174 174
175#ifdef CONFIG_SSB_DRIVER_PCICORE
175 if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI) 176 if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
176 return false; 177 return false;
178#endif /* CONFIG_SSB_DRIVER_PCICORE */
177 179
178#if 0 180#if 0
179 /* TODO: on BCMA we use address from EROM instead of magic formula */ 181 /* TODO: on BCMA we use address from EROM instead of magic formula */
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index 8e8d5cf32e12..8b5b7856abe3 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -20,12 +20,12 @@
20 * R/W ops. 20 * R/W ops.
21 **************************************************/ 21 **************************************************/
22 22
23static void bcma_sprom_read(struct bcma_bus *bus, u16 *sprom) 23static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
24{ 24{
25 int i; 25 int i;
26 for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++) 26 for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
27 sprom[i] = bcma_read16(bus->drv_cc.core, 27 sprom[i] = bcma_read16(bus->drv_cc.core,
28 BCMA_CC_SPROM + (i * 2)); 28 offset + (i * 2));
29} 29}
30 30
31/************************************************** 31/**************************************************
@@ -112,7 +112,7 @@ static int bcma_sprom_valid(const u16 *sprom)
112 return err; 112 return err;
113 113
114 revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV; 114 revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
115 if (revision != 8) { 115 if (revision != 8 && revision != 9) {
116 pr_err("Unsupported SPROM revision: %d\n", revision); 116 pr_err("Unsupported SPROM revision: %d\n", revision);
117 return -ENOENT; 117 return -ENOENT;
118 } 118 }
@@ -137,6 +137,7 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
137 137
138int bcma_sprom_get(struct bcma_bus *bus) 138int bcma_sprom_get(struct bcma_bus *bus)
139{ 139{
140 u16 offset;
140 u16 *sprom; 141 u16 *sprom;
141 int err = 0; 142 int err = 0;
142 143
@@ -151,7 +152,12 @@ int bcma_sprom_get(struct bcma_bus *bus)
151 if (!sprom) 152 if (!sprom)
152 return -ENOMEM; 153 return -ENOMEM;
153 154
154 bcma_sprom_read(bus, sprom); 155 /* Most cards have SPROM moved by additional offset 0x30 (48 dwords).
156 * According to brcm80211 this applies to cards with PCIe rev >= 6
157 * TODO: understand this condition and use it */
158 offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM :
159 BCMA_CC_SPROM_PCIE6;
160 bcma_sprom_read(bus, offset, sprom);
155 161
156 err = bcma_sprom_valid(sprom); 162 err = bcma_sprom_valid(sprom);
157 if (err) 163 if (err)
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 16b4d58d84dd..c049548e68b7 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -223,7 +223,7 @@ static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c)
223 h->ctlr, c->busaddr); 223 h->ctlr, c->busaddr);
224#endif /* CCISS_DEBUG */ 224#endif /* CCISS_DEBUG */
225 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); 225 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
226 readl(h->vaddr + SA5_REQUEST_PORT_OFFSET); 226 readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
227 h->commands_outstanding++; 227 h->commands_outstanding++;
228 if ( h->commands_outstanding > h->max_outstanding) 228 if ( h->commands_outstanding > h->max_outstanding)
229 h->max_outstanding = h->commands_outstanding; 229 h->max_outstanding = h->commands_outstanding;
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 5cf2993a8338..2330a9ad5e95 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -458,7 +458,8 @@ static void end_block_io_op(struct bio *bio, int error)
458 * (which has the sectors we want, number of them, grant references, etc), 458 * (which has the sectors we want, number of them, grant references, etc),
459 * and transmute it to the block API to hand it over to the proper block disk. 459 * and transmute it to the block API to hand it over to the proper block disk.
460 */ 460 */
461static int do_block_io_op(struct xen_blkif *blkif) 461static int
462__do_block_io_op(struct xen_blkif *blkif)
462{ 463{
463 union blkif_back_rings *blk_rings = &blkif->blk_rings; 464 union blkif_back_rings *blk_rings = &blkif->blk_rings;
464 struct blkif_request req; 465 struct blkif_request req;
@@ -515,6 +516,23 @@ static int do_block_io_op(struct xen_blkif *blkif)
515 return more_to_do; 516 return more_to_do;
516} 517}
517 518
519static int
520do_block_io_op(struct xen_blkif *blkif)
521{
522 union blkif_back_rings *blk_rings = &blkif->blk_rings;
523 int more_to_do;
524
525 do {
526 more_to_do = __do_block_io_op(blkif);
527 if (more_to_do)
528 break;
529
530 RING_FINAL_CHECK_FOR_REQUESTS(&blk_rings->common, more_to_do);
531 } while (more_to_do);
532
533 return more_to_do;
534}
535
518/* 536/*
519 * Transmutation of the 'struct blkif_request' to a proper 'struct bio' 537 * Transmutation of the 'struct blkif_request' to a proper 'struct bio'
520 * and call the 'submit_bio' to pass it to the underlying storage. 538 * and call the 'submit_bio' to pass it to the underlying storage.
@@ -700,7 +718,6 @@ static void make_response(struct xen_blkif *blkif, u64 id,
700 struct blkif_response resp; 718 struct blkif_response resp;
701 unsigned long flags; 719 unsigned long flags;
702 union blkif_back_rings *blk_rings = &blkif->blk_rings; 720 union blkif_back_rings *blk_rings = &blkif->blk_rings;
703 int more_to_do = 0;
704 int notify; 721 int notify;
705 722
706 resp.id = id; 723 resp.id = id;
@@ -727,22 +744,7 @@ static void make_response(struct xen_blkif *blkif, u64 id,
727 } 744 }
728 blk_rings->common.rsp_prod_pvt++; 745 blk_rings->common.rsp_prod_pvt++;
729 RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify); 746 RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify);
730 if (blk_rings->common.rsp_prod_pvt == blk_rings->common.req_cons) {
731 /*
732 * Tail check for pending requests. Allows frontend to avoid
733 * notifications if requests are already in flight (lower
734 * overheads and promotes batching).
735 */
736 RING_FINAL_CHECK_FOR_REQUESTS(&blk_rings->common, more_to_do);
737
738 } else if (RING_HAS_UNCONSUMED_REQUESTS(&blk_rings->common)) {
739 more_to_do = 1;
740 }
741
742 spin_unlock_irqrestore(&blkif->blk_ring_lock, flags); 747 spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
743
744 if (more_to_do)
745 blkif_notify_work(blkif);
746 if (notify) 748 if (notify)
747 notify_remote_via_irq(blkif->irq); 749 notify_remote_via_irq(blkif->irq);
748} 750}
@@ -824,3 +826,4 @@ static int __init xen_blkif_init(void)
824module_init(xen_blkif_init); 826module_init(xen_blkif_init);
825 827
826MODULE_LICENSE("Dual BSD/GPL"); 828MODULE_LICENSE("Dual BSD/GPL");
829MODULE_ALIAS("xen-backend:vbd");
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 9fb84853d8e3..e898215b88af 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -184,5 +184,10 @@ depends on X86
184source "drivers/cpufreq/Kconfig.x86" 184source "drivers/cpufreq/Kconfig.x86"
185endmenu 185endmenu
186 186
187menu "ARM CPU frequency scaling drivers"
188depends on ARM
189source "drivers/cpufreq/Kconfig.arm"
190endmenu
191
187endif 192endif
188endmenu 193endmenu
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
new file mode 100644
index 000000000000..72a0044c1baa
--- /dev/null
+++ b/drivers/cpufreq/Kconfig.arm
@@ -0,0 +1,32 @@
1#
2# ARM CPU Frequency scaling drivers
3#
4
5config ARM_S3C64XX_CPUFREQ
6 bool "Samsung S3C64XX"
7 depends on CPU_S3C6410
8 default y
9 help
10 This adds the CPUFreq driver for Samsung S3C6410 SoC.
11
12 If in doubt, say N.
13
14config ARM_S5PV210_CPUFREQ
15 bool "Samsung S5PV210 and S5PC110"
16 depends on CPU_S5PV210
17 default y
18 help
19 This adds the CPUFreq driver for Samsung S5PV210 and
20 S5PC110 SoCs.
21
22 If in doubt, say N.
23
24config ARM_EXYNOS4210_CPUFREQ
25 bool "Samsung EXYNOS4210"
26 depends on CPU_EXYNOS4210
27 default y
28 help
29 This adds the CPUFreq driver for Samsung EXYNOS4210
30 SoC (S5PV310 or S5PC210).
31
32 If in doubt, say N.
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index e2fc2d21fa61..ab75e573c69f 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o
13# CPUfreq cross-arch helpers 13# CPUfreq cross-arch helpers
14obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o 14obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o
15 15
16##################################################################################d 16##################################################################################
17# x86 drivers. 17# x86 drivers.
18# Link order matters. K8 is preferred to ACPI because of firmware bugs in early 18# Link order matters. K8 is preferred to ACPI because of firmware bugs in early
19# K8 systems. ACPI is preferred to all other hardware-specific drivers. 19# K8 systems. ACPI is preferred to all other hardware-specific drivers.
@@ -37,7 +37,9 @@ obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
37obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o 37obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
38obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o 38obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o
39 39
40##################################################################################d 40##################################################################################
41
42# ARM SoC drivers 41# ARM SoC drivers
43obj-$(CONFIG_UX500_SOC_DB8500) += db8500-cpufreq.o 42obj-$(CONFIG_UX500_SOC_DB8500) += db8500-cpufreq.o
43obj-$(CONFIG_ARM_S3C64XX_CPUFREQ) += s3c64xx-cpufreq.o
44obj-$(CONFIG_ARM_S5PV210_CPUFREQ) += s5pv210-cpufreq.o
45obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 596d5dd32f41..56c6c6b4eb4d 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -655,7 +655,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
655 acpi_processor_notify_smm(THIS_MODULE); 655 acpi_processor_notify_smm(THIS_MODULE);
656 656
657 /* Check for APERF/MPERF support in hardware */ 657 /* Check for APERF/MPERF support in hardware */
658 if (cpu_has(c, X86_FEATURE_APERFMPERF)) 658 if (boot_cpu_has(X86_FEATURE_APERFMPERF))
659 acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf; 659 acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
660 660
661 pr_debug("CPU%u - ACPI performance management activated.\n", cpu); 661 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
diff --git a/arch/arm/mach-exynos4/cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index a1bd258f0c4d..b7c3a84c4cfa 100644
--- a/arch/arm/mach-exynos4/cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -1,5 +1,4 @@
1/* linux/arch/arm/mach-exynos4/cpufreq.c 1/*
2 *
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. 2 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com 3 * http://www.samsung.com
5 * 4 *
@@ -192,17 +191,17 @@ static unsigned int exynos4_apll_pms_table[CPUFREQ_LEVEL_END] = {
192 ((200 << 16) | (6 << 8) | 4), 191 ((200 << 16) | (6 << 8) | 4),
193}; 192};
194 193
195int exynos4_verify_speed(struct cpufreq_policy *policy) 194static int exynos4_verify_speed(struct cpufreq_policy *policy)
196{ 195{
197 return cpufreq_frequency_table_verify(policy, exynos4_freq_table); 196 return cpufreq_frequency_table_verify(policy, exynos4_freq_table);
198} 197}
199 198
200unsigned int exynos4_getspeed(unsigned int cpu) 199static unsigned int exynos4_getspeed(unsigned int cpu)
201{ 200{
202 return clk_get_rate(cpu_clk) / 1000; 201 return clk_get_rate(cpu_clk) / 1000;
203} 202}
204 203
205void exynos4_set_clkdiv(unsigned int div_index) 204static void exynos4_set_clkdiv(unsigned int div_index)
206{ 205{
207 unsigned int tmp; 206 unsigned int tmp;
208 207
diff --git a/arch/arm/mach-s3c64xx/cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index 4375b97588b8..b8d1d205e1ef 100644
--- a/arch/arm/mach-s3c64xx/cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -1,5 +1,4 @@
1/* linux/arch/arm/plat-s3c64xx/cpufreq.c 1/*
2 *
3 * Copyright 2009 Wolfson Microelectronics plc 2 * Copyright 2009 Wolfson Microelectronics plc
4 * 3 *
5 * S3C64xx CPUfreq Support 4 * S3C64xx CPUfreq Support
@@ -32,11 +31,14 @@ static struct s3c64xx_dvfs s3c64xx_dvfs_table[] = {
32 [1] = { 1050000, 1150000 }, 31 [1] = { 1050000, 1150000 },
33 [2] = { 1100000, 1150000 }, 32 [2] = { 1100000, 1150000 },
34 [3] = { 1200000, 1350000 }, 33 [3] = { 1200000, 1350000 },
34 [4] = { 1300000, 1350000 },
35}; 35};
36 36
37static struct cpufreq_frequency_table s3c64xx_freq_table[] = { 37static struct cpufreq_frequency_table s3c64xx_freq_table[] = {
38 { 0, 66000 }, 38 { 0, 66000 },
39 { 0, 100000 },
39 { 0, 133000 }, 40 { 0, 133000 },
41 { 1, 200000 },
40 { 1, 222000 }, 42 { 1, 222000 },
41 { 1, 266000 }, 43 { 1, 266000 },
42 { 2, 333000 }, 44 { 2, 333000 },
@@ -44,6 +46,7 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = {
44 { 2, 532000 }, 46 { 2, 532000 },
45 { 2, 533000 }, 47 { 2, 533000 },
46 { 3, 667000 }, 48 { 3, 667000 },
49 { 4, 800000 },
47 { 0, CPUFREQ_TABLE_END }, 50 { 0, CPUFREQ_TABLE_END },
48}; 51};
49#endif 52#endif
@@ -111,6 +114,8 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
111 goto err; 114 goto err;
112 } 115 }
113 116
117 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
118
114#ifdef CONFIG_REGULATOR 119#ifdef CONFIG_REGULATOR
115 if (vddarm && freqs.new < freqs.old) { 120 if (vddarm && freqs.new < freqs.old) {
116 ret = regulator_set_voltage(vddarm, 121 ret = regulator_set_voltage(vddarm,
@@ -124,8 +129,6 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
124 } 129 }
125#endif 130#endif
126 131
127 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
128
129 pr_debug("cpufreq: Set actual frequency %lukHz\n", 132 pr_debug("cpufreq: Set actual frequency %lukHz\n",
130 clk_get_rate(armclk) / 1000); 133 clk_get_rate(armclk) / 1000);
131 134
diff --git a/arch/arm/mach-s5pv210/cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 153af8b359ec..a484aaea9809 100644
--- a/arch/arm/mach-s5pv210/cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -1,5 +1,4 @@
1/* linux/arch/arm/mach-s5pv210/cpufreq.c 1/*
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd. 2 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com 3 * http://www.samsung.com
5 * 4 *
@@ -17,6 +16,9 @@
17#include <linux/clk.h> 16#include <linux/clk.h>
18#include <linux/io.h> 17#include <linux/io.h>
19#include <linux/cpufreq.h> 18#include <linux/cpufreq.h>
19#include <linux/reboot.h>
20#include <linux/regulator/consumer.h>
21#include <linux/suspend.h>
20 22
21#include <mach/map.h> 23#include <mach/map.h>
22#include <mach/regs-clock.h> 24#include <mach/regs-clock.h>
@@ -25,11 +27,27 @@ static struct clk *cpu_clk;
25static struct clk *dmc0_clk; 27static struct clk *dmc0_clk;
26static struct clk *dmc1_clk; 28static struct clk *dmc1_clk;
27static struct cpufreq_freqs freqs; 29static struct cpufreq_freqs freqs;
30static DEFINE_MUTEX(set_freq_lock);
28 31
29/* APLL M,P,S values for 1G/800Mhz */ 32/* APLL M,P,S values for 1G/800Mhz */
30#define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1) 33#define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1)
31#define APLL_VAL_800 ((1 << 31) | (100 << 16) | (3 << 8) | 1) 34#define APLL_VAL_800 ((1 << 31) | (100 << 16) | (3 << 8) | 1)
32 35
36/* Use 800MHz when entering sleep mode */
37#define SLEEP_FREQ (800 * 1000)
38
39/*
40 * relation has an additional symantics other than the standard of cpufreq
41 * DISALBE_FURTHER_CPUFREQ: disable further access to target
42 * ENABLE_FURTUER_CPUFREQ: enable access to target
43 */
44enum cpufreq_access {
45 DISABLE_FURTHER_CPUFREQ = 0x10,
46 ENABLE_FURTHER_CPUFREQ = 0x20,
47};
48
49static bool no_cpufreq_access;
50
33/* 51/*
34 * DRAM configurations to calculate refresh counter for changing 52 * DRAM configurations to calculate refresh counter for changing
35 * frequency of memory. 53 * frequency of memory.
@@ -66,6 +84,40 @@ static struct cpufreq_frequency_table s5pv210_freq_table[] = {
66 {0, CPUFREQ_TABLE_END}, 84 {0, CPUFREQ_TABLE_END},
67}; 85};
68 86
87static struct regulator *arm_regulator;
88static struct regulator *int_regulator;
89
90struct s5pv210_dvs_conf {
91 int arm_volt; /* uV */
92 int int_volt; /* uV */
93};
94
95static const int arm_volt_max = 1350000;
96static const int int_volt_max = 1250000;
97
98static struct s5pv210_dvs_conf dvs_conf[] = {
99 [L0] = {
100 .arm_volt = 1250000,
101 .int_volt = 1100000,
102 },
103 [L1] = {
104 .arm_volt = 1200000,
105 .int_volt = 1100000,
106 },
107 [L2] = {
108 .arm_volt = 1050000,
109 .int_volt = 1100000,
110 },
111 [L3] = {
112 .arm_volt = 950000,
113 .int_volt = 1100000,
114 },
115 [L4] = {
116 .arm_volt = 950000,
117 .int_volt = 1000000,
118 },
119};
120
69static u32 clkdiv_val[5][11] = { 121static u32 clkdiv_val[5][11] = {
70 /* 122 /*
71 * Clock divider value for following 123 * Clock divider value for following
@@ -122,7 +174,7 @@ static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq)
122 __raw_writel(tmp1, reg); 174 __raw_writel(tmp1, reg);
123} 175}
124 176
125int s5pv210_verify_speed(struct cpufreq_policy *policy) 177static int s5pv210_verify_speed(struct cpufreq_policy *policy)
126{ 178{
127 if (policy->cpu) 179 if (policy->cpu)
128 return -EINVAL; 180 return -EINVAL;
@@ -130,7 +182,7 @@ int s5pv210_verify_speed(struct cpufreq_policy *policy)
130 return cpufreq_frequency_table_verify(policy, s5pv210_freq_table); 182 return cpufreq_frequency_table_verify(policy, s5pv210_freq_table);
131} 183}
132 184
133unsigned int s5pv210_getspeed(unsigned int cpu) 185static unsigned int s5pv210_getspeed(unsigned int cpu)
134{ 186{
135 if (cpu) 187 if (cpu)
136 return 0; 188 return 0;
@@ -146,30 +198,66 @@ static int s5pv210_target(struct cpufreq_policy *policy,
146 unsigned int index, priv_index; 198 unsigned int index, priv_index;
147 unsigned int pll_changing = 0; 199 unsigned int pll_changing = 0;
148 unsigned int bus_speed_changing = 0; 200 unsigned int bus_speed_changing = 0;
201 int arm_volt, int_volt;
202 int ret = 0;
203
204 mutex_lock(&set_freq_lock);
205
206 if (relation & ENABLE_FURTHER_CPUFREQ)
207 no_cpufreq_access = false;
208
209 if (no_cpufreq_access) {
210#ifdef CONFIG_PM_VERBOSE
211 pr_err("%s:%d denied access to %s as it is disabled"
212 "temporarily\n", __FILE__, __LINE__, __func__);
213#endif
214 ret = -EINVAL;
215 goto exit;
216 }
217
218 if (relation & DISABLE_FURTHER_CPUFREQ)
219 no_cpufreq_access = true;
220
221 relation &= ~(ENABLE_FURTHER_CPUFREQ | DISABLE_FURTHER_CPUFREQ);
149 222
150 freqs.old = s5pv210_getspeed(0); 223 freqs.old = s5pv210_getspeed(0);
151 224
152 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, 225 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
153 target_freq, relation, &index)) 226 target_freq, relation, &index)) {
154 return -EINVAL; 227 ret = -EINVAL;
228 goto exit;
229 }
155 230
156 freqs.new = s5pv210_freq_table[index].frequency; 231 freqs.new = s5pv210_freq_table[index].frequency;
157 freqs.cpu = 0; 232 freqs.cpu = 0;
158 233
159 if (freqs.new == freqs.old) 234 if (freqs.new == freqs.old)
160 return 0; 235 goto exit;
161 236
162 /* Finding current running level index */ 237 /* Finding current running level index */
163 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, 238 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
164 freqs.old, relation, &priv_index)) 239 freqs.old, relation, &priv_index)) {
165 return -EINVAL; 240 ret = -EINVAL;
241 goto exit;
242 }
166 243
167 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 244 arm_volt = dvs_conf[index].arm_volt;
245 int_volt = dvs_conf[index].int_volt;
168 246
169 if (freqs.new > freqs.old) { 247 if (freqs.new > freqs.old) {
170 /* Voltage up: will be implemented */ 248 ret = regulator_set_voltage(arm_regulator,
249 arm_volt, arm_volt_max);
250 if (ret)
251 goto exit;
252
253 ret = regulator_set_voltage(int_regulator,
254 int_volt, int_volt_max);
255 if (ret)
256 goto exit;
171 } 257 }
172 258
259 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
260
173 /* Check if there need to change PLL */ 261 /* Check if there need to change PLL */
174 if ((index == L0) || (priv_index == L0)) 262 if ((index == L0) || (priv_index == L0))
175 pll_changing = 1; 263 pll_changing = 1;
@@ -380,15 +468,21 @@ static int s5pv210_target(struct cpufreq_policy *policy,
380 } 468 }
381 } 469 }
382 470
471 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
472
383 if (freqs.new < freqs.old) { 473 if (freqs.new < freqs.old) {
384 /* Voltage down: will be implemented */ 474 regulator_set_voltage(int_regulator,
385 } 475 int_volt, int_volt_max);
386 476
387 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 477 regulator_set_voltage(arm_regulator,
478 arm_volt, arm_volt_max);
479 }
388 480
389 printk(KERN_DEBUG "Perf changed[L%d]\n", index); 481 printk(KERN_DEBUG "Perf changed[L%d]\n", index);
390 482
391 return 0; 483exit:
484 mutex_unlock(&set_freq_lock);
485 return ret;
392} 486}
393 487
394#ifdef CONFIG_PM 488#ifdef CONFIG_PM
@@ -416,6 +510,7 @@ static int check_mem_type(void __iomem *dmc_reg)
416static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) 510static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
417{ 511{
418 unsigned long mem_type; 512 unsigned long mem_type;
513 int ret;
419 514
420 cpu_clk = clk_get(NULL, "armclk"); 515 cpu_clk = clk_get(NULL, "armclk");
421 if (IS_ERR(cpu_clk)) 516 if (IS_ERR(cpu_clk))
@@ -423,19 +518,20 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
423 518
424 dmc0_clk = clk_get(NULL, "sclk_dmc0"); 519 dmc0_clk = clk_get(NULL, "sclk_dmc0");
425 if (IS_ERR(dmc0_clk)) { 520 if (IS_ERR(dmc0_clk)) {
426 clk_put(cpu_clk); 521 ret = PTR_ERR(dmc0_clk);
427 return PTR_ERR(dmc0_clk); 522 goto out_dmc0;
428 } 523 }
429 524
430 dmc1_clk = clk_get(NULL, "hclk_msys"); 525 dmc1_clk = clk_get(NULL, "hclk_msys");
431 if (IS_ERR(dmc1_clk)) { 526 if (IS_ERR(dmc1_clk)) {
432 clk_put(dmc0_clk); 527 ret = PTR_ERR(dmc1_clk);
433 clk_put(cpu_clk); 528 goto out_dmc1;
434 return PTR_ERR(dmc1_clk);
435 } 529 }
436 530
437 if (policy->cpu != 0) 531 if (policy->cpu != 0) {
438 return -EINVAL; 532 ret = -EINVAL;
533 goto out_dmc1;
534 }
439 535
440 /* 536 /*
441 * check_mem_type : This driver only support LPDDR & LPDDR2. 537 * check_mem_type : This driver only support LPDDR & LPDDR2.
@@ -445,7 +541,8 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
445 541
446 if ((mem_type != LPDDR) && (mem_type != LPDDR2)) { 542 if ((mem_type != LPDDR) && (mem_type != LPDDR2)) {
447 printk(KERN_ERR "CPUFreq doesn't support this memory type\n"); 543 printk(KERN_ERR "CPUFreq doesn't support this memory type\n");
448 return -EINVAL; 544 ret = -EINVAL;
545 goto out_dmc1;
449 } 546 }
450 547
451 /* Find current refresh counter and frequency each DMC */ 548 /* Find current refresh counter and frequency each DMC */
@@ -462,6 +559,49 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
462 policy->cpuinfo.transition_latency = 40000; 559 policy->cpuinfo.transition_latency = 40000;
463 560
464 return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table); 561 return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table);
562
563out_dmc1:
564 clk_put(dmc0_clk);
565out_dmc0:
566 clk_put(cpu_clk);
567 return ret;
568}
569
570static int s5pv210_cpufreq_notifier_event(struct notifier_block *this,
571 unsigned long event, void *ptr)
572{
573 int ret;
574
575 switch (event) {
576 case PM_SUSPEND_PREPARE:
577 ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
578 DISABLE_FURTHER_CPUFREQ);
579 if (ret < 0)
580 return NOTIFY_BAD;
581
582 return NOTIFY_OK;
583 case PM_POST_RESTORE:
584 case PM_POST_SUSPEND:
585 cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
586 ENABLE_FURTHER_CPUFREQ);
587
588 return NOTIFY_OK;
589 }
590
591 return NOTIFY_DONE;
592}
593
594static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
595 unsigned long event, void *ptr)
596{
597 int ret;
598
599 ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
600 DISABLE_FURTHER_CPUFREQ);
601 if (ret < 0)
602 return NOTIFY_BAD;
603
604 return NOTIFY_DONE;
465} 605}
466 606
467static struct cpufreq_driver s5pv210_driver = { 607static struct cpufreq_driver s5pv210_driver = {
@@ -477,8 +617,32 @@ static struct cpufreq_driver s5pv210_driver = {
477#endif 617#endif
478}; 618};
479 619
620static struct notifier_block s5pv210_cpufreq_notifier = {
621 .notifier_call = s5pv210_cpufreq_notifier_event,
622};
623
624static struct notifier_block s5pv210_cpufreq_reboot_notifier = {
625 .notifier_call = s5pv210_cpufreq_reboot_notifier_event,
626};
627
480static int __init s5pv210_cpufreq_init(void) 628static int __init s5pv210_cpufreq_init(void)
481{ 629{
630 arm_regulator = regulator_get(NULL, "vddarm");
631 if (IS_ERR(arm_regulator)) {
632 pr_err("failed to get regulator vddarm");
633 return PTR_ERR(arm_regulator);
634 }
635
636 int_regulator = regulator_get(NULL, "vddint");
637 if (IS_ERR(int_regulator)) {
638 pr_err("failed to get regulator vddint");
639 regulator_put(arm_regulator);
640 return PTR_ERR(int_regulator);
641 }
642
643 register_pm_notifier(&s5pv210_cpufreq_notifier);
644 register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier);
645
482 return cpufreq_register_driver(&s5pv210_driver); 646 return cpufreq_register_driver(&s5pv210_driver);
483} 647}
484 648
diff --git a/drivers/net/bna/bfa_cee.c b/drivers/net/bna/bfa_cee.c
index dcfbf08bcf43..39e5ab9fde59 100644
--- a/drivers/net/bna/bfa_cee.c
+++ b/drivers/net/bna/bfa_cee.c
@@ -223,44 +223,56 @@ bfa_cee_isr(void *cbarg, struct bfi_mbmsg *m)
223} 223}
224 224
225/** 225/**
226 * bfa_cee_hbfail() 226 * bfa_cee_notify()
227 * 227 *
228 * @brief CEE module heart-beat failure handler. 228 * @brief CEE module heart-beat failure handler.
229 * @brief CEE module IOC event handler.
229 * 230 *
230 * @param[in] Pointer to the CEE module data structure. 231 * @param[in] IOC event type
231 * 232 *
232 * @return void 233 * @return void
233 */ 234 */
234 235
235static void 236static void
236bfa_cee_hbfail(void *arg) 237bfa_cee_notify(void *arg, enum bfa_ioc_event event)
237{ 238{
238 struct bfa_cee *cee; 239 struct bfa_cee *cee;
239 cee = arg; 240 cee = (struct bfa_cee *) arg;
240 241
241 if (cee->get_attr_pending == true) { 242 switch (event) {
242 cee->get_attr_status = BFA_STATUS_FAILED; 243 case BFA_IOC_E_DISABLED:
243 cee->get_attr_pending = false; 244 case BFA_IOC_E_FAILED:
244 if (cee->cbfn.get_attr_cbfn) { 245 if (cee->get_attr_pending == true) {
245 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, 246 cee->get_attr_status = BFA_STATUS_FAILED;
246 BFA_STATUS_FAILED); 247 cee->get_attr_pending = false;
248 if (cee->cbfn.get_attr_cbfn) {
249 cee->cbfn.get_attr_cbfn(
250 cee->cbfn.get_attr_cbarg,
251 BFA_STATUS_FAILED);
252 }
247 } 253 }
248 } 254 if (cee->get_stats_pending == true) {
249 if (cee->get_stats_pending == true) { 255 cee->get_stats_status = BFA_STATUS_FAILED;
250 cee->get_stats_status = BFA_STATUS_FAILED; 256 cee->get_stats_pending = false;
251 cee->get_stats_pending = false; 257 if (cee->cbfn.get_stats_cbfn) {
252 if (cee->cbfn.get_stats_cbfn) { 258 cee->cbfn.get_stats_cbfn(
253 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, 259 cee->cbfn.get_stats_cbarg,
254 BFA_STATUS_FAILED); 260 BFA_STATUS_FAILED);
261 }
255 } 262 }
256 } 263 if (cee->reset_stats_pending == true) {
257 if (cee->reset_stats_pending == true) { 264 cee->reset_stats_status = BFA_STATUS_FAILED;
258 cee->reset_stats_status = BFA_STATUS_FAILED; 265 cee->reset_stats_pending = false;
259 cee->reset_stats_pending = false; 266 if (cee->cbfn.reset_stats_cbfn) {
260 if (cee->cbfn.reset_stats_cbfn) { 267 cee->cbfn.reset_stats_cbfn(
261 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, 268 cee->cbfn.reset_stats_cbarg,
262 BFA_STATUS_FAILED); 269 BFA_STATUS_FAILED);
270 }
263 } 271 }
272 break;
273
274 default:
275 break;
264 } 276 }
265} 277}
266 278
@@ -286,6 +298,7 @@ bfa_nw_cee_attach(struct bfa_cee *cee, struct bfa_ioc *ioc,
286 cee->ioc = ioc; 298 cee->ioc = ioc;
287 299
288 bfa_nw_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee); 300 bfa_nw_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
289 bfa_ioc_hbfail_init(&cee->hbfail, bfa_cee_hbfail, cee); 301 bfa_q_qe_init(&cee->ioc_notify);
290 bfa_nw_ioc_hbfail_register(cee->ioc, &cee->hbfail); 302 bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
303 bfa_nw_ioc_notify_register(cee->ioc, &cee->ioc_notify);
291} 304}
diff --git a/drivers/net/bna/bfa_cee.h b/drivers/net/bna/bfa_cee.h
index 20543d15b64f..58d54e98d595 100644
--- a/drivers/net/bna/bfa_cee.h
+++ b/drivers/net/bna/bfa_cee.h
@@ -25,7 +25,6 @@
25typedef void (*bfa_cee_get_attr_cbfn_t) (void *dev, enum bfa_status status); 25typedef void (*bfa_cee_get_attr_cbfn_t) (void *dev, enum bfa_status status);
26typedef void (*bfa_cee_get_stats_cbfn_t) (void *dev, enum bfa_status status); 26typedef void (*bfa_cee_get_stats_cbfn_t) (void *dev, enum bfa_status status);
27typedef void (*bfa_cee_reset_stats_cbfn_t) (void *dev, enum bfa_status status); 27typedef void (*bfa_cee_reset_stats_cbfn_t) (void *dev, enum bfa_status status);
28typedef void (*bfa_cee_hbfail_cbfn_t) (void *dev, enum bfa_status status);
29 28
30struct bfa_cee_cbfn { 29struct bfa_cee_cbfn {
31 bfa_cee_get_attr_cbfn_t get_attr_cbfn; 30 bfa_cee_get_attr_cbfn_t get_attr_cbfn;
@@ -45,7 +44,7 @@ struct bfa_cee {
45 enum bfa_status get_stats_status; 44 enum bfa_status get_stats_status;
46 enum bfa_status reset_stats_status; 45 enum bfa_status reset_stats_status;
47 struct bfa_cee_cbfn cbfn; 46 struct bfa_cee_cbfn cbfn;
48 struct bfa_ioc_hbfail_notify hbfail; 47 struct bfa_ioc_notify ioc_notify;
49 struct bfa_cee_attr *attr; 48 struct bfa_cee_attr *attr;
50 struct bfa_cee_stats *stats; 49 struct bfa_cee_stats *stats;
51 struct bfa_dma attr_dma; 50 struct bfa_dma attr_dma;
diff --git a/drivers/net/bna/bfa_sm.h b/drivers/net/bna/bfa_cs.h
index 46462c49b6f9..3da1a946ccdd 100644
--- a/drivers/net/bna/bfa_sm.h
+++ b/drivers/net/bna/bfa_cs.h
@@ -11,20 +11,24 @@
11 * General Public License for more details. 11 * General Public License for more details.
12 */ 12 */
13/* 13/*
14 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. 14 * Copyright (c) 2005-2011 Brocade Communications Systems, Inc.
15 * All rights reserved 15 * All rights reserved
16 * www.brocade.com 16 * www.brocade.com
17 */ 17 */
18 18
19/** 19/**
20 * @file bfasm.h State machine defines 20 * @file bfa_cs.h BFA common services
21 */ 21 */
22 22
23#ifndef __BFA_SM_H__ 23#ifndef __BFA_CS_H__
24#define __BFA_SM_H__ 24#define __BFA_CS_H__
25 25
26#include "cna.h" 26#include "cna.h"
27 27
28/**
29 * @ BFA state machine interfaces
30 */
31
28typedef void (*bfa_sm_t)(void *sm, int event); 32typedef void (*bfa_sm_t)(void *sm, int event);
29 33
30/** 34/**
@@ -33,7 +37,7 @@ typedef void (*bfa_sm_t)(void *sm, int event);
33 * otype - object type, eg. struct bfa_ioc 37 * otype - object type, eg. struct bfa_ioc
34 * etype - object type, eg. enum ioc_event 38 * etype - object type, eg. enum ioc_event
35 */ 39 */
36#define bfa_sm_state_decl(oc, st, otype, etype) \ 40#define bfa_sm_state_decl(oc, st, otype, etype) \
37 static void oc ## _sm_ ## st(otype * fsm, etype event) 41 static void oc ## _sm_ ## st(otype * fsm, etype event)
38 42
39#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state)) 43#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state))
@@ -49,7 +53,7 @@ struct bfa_sm_table {
49 int state; /*!< state machine encoding */ 53 int state; /*!< state machine encoding */
50 char *name; /*!< state name for display */ 54 char *name; /*!< state name for display */
51}; 55};
52#define BFA_SM(_sm) ((bfa_sm_t)(_sm)) 56#define BFA_SM(_sm) ((bfa_sm_t)(_sm))
53 57
54/** 58/**
55 * State machine with entry actions. 59 * State machine with entry actions.
@@ -62,18 +66,18 @@ typedef void (*bfa_fsm_t)(void *fsm, int event);
62 * otype - object type, eg. struct bfa_ioc 66 * otype - object type, eg. struct bfa_ioc
63 * etype - object type, eg. enum ioc_event 67 * etype - object type, eg. enum ioc_event
64 */ 68 */
65#define bfa_fsm_state_decl(oc, st, otype, etype) \ 69#define bfa_fsm_state_decl(oc, st, otype, etype) \
66 static void oc ## _sm_ ## st(otype * fsm, etype event); \ 70 static void oc ## _sm_ ## st(otype * fsm, etype event); \
67 static void oc ## _sm_ ## st ## _entry(otype * fsm) 71 static void oc ## _sm_ ## st ## _entry(otype * fsm)
68 72
69#define bfa_fsm_set_state(_fsm, _state) do { \ 73#define bfa_fsm_set_state(_fsm, _state) do { \
70 (_fsm)->fsm = (bfa_fsm_t)(_state); \ 74 (_fsm)->fsm = (bfa_fsm_t)(_state); \
71 _state ## _entry(_fsm); \ 75 _state ## _entry(_fsm); \
72} while (0) 76} while (0)
73 77
74#define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event))) 78#define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event)))
75#define bfa_fsm_get_state(_fsm) ((_fsm)->fsm) 79#define bfa_fsm_get_state(_fsm) ((_fsm)->fsm)
76#define bfa_fsm_cmp_state(_fsm, _state) \ 80#define bfa_fsm_cmp_state(_fsm, _state) \
77 ((_fsm)->fsm == (bfa_fsm_t)(_state)) 81 ((_fsm)->fsm == (bfa_fsm_t)(_state))
78 82
79static inline int 83static inline int
@@ -85,4 +89,52 @@ bfa_sm_to_state(const struct bfa_sm_table *smt, bfa_sm_t sm)
85 i++; 89 i++;
86 return smt[i].state; 90 return smt[i].state;
87} 91}
88#endif 92
93/**
94 * @ Generic wait counter.
95 */
96
97typedef void (*bfa_wc_resume_t) (void *cbarg);
98
99struct bfa_wc {
100 bfa_wc_resume_t wc_resume;
101 void *wc_cbarg;
102 int wc_count;
103};
104
105static inline void
106bfa_wc_up(struct bfa_wc *wc)
107{
108 wc->wc_count++;
109}
110
111static inline void
112bfa_wc_down(struct bfa_wc *wc)
113{
114 wc->wc_count--;
115 if (wc->wc_count == 0)
116 wc->wc_resume(wc->wc_cbarg);
117}
118
119/**
120 * Initialize a waiting counter.
121 */
122static inline void
123bfa_wc_init(struct bfa_wc *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
124{
125 wc->wc_resume = wc_resume;
126 wc->wc_cbarg = wc_cbarg;
127 wc->wc_count = 0;
128 bfa_wc_up(wc);
129}
130
131/**
132 * Wait for counter to reach zero
133 */
134static inline void
135bfa_wc_wait(struct bfa_wc *wc)
136{
137 bfa_wc_down(wc);
138}
139
140#endif /* __BFA_CS_H__ */
diff --git a/drivers/net/bna/bfa_defs.h b/drivers/net/bna/bfa_defs.h
index 2ea0dfe1cedc..b080b3698f48 100644
--- a/drivers/net/bna/bfa_defs.h
+++ b/drivers/net/bna/bfa_defs.h
@@ -80,7 +80,7 @@ struct bfa_adapter_attr {
80 80
81enum { 81enum {
82 BFA_IOC_DRIVER_LEN = 16, 82 BFA_IOC_DRIVER_LEN = 16,
83 BFA_IOC_CHIP_REV_LEN = 8, 83 BFA_IOC_CHIP_REV_LEN = 8,
84}; 84};
85 85
86/** 86/**
@@ -153,6 +153,7 @@ struct bfa_ioc_drv_stats {
153 u32 enable_reqs; 153 u32 enable_reqs;
154 u32 disable_replies; 154 u32 disable_replies;
155 u32 enable_replies; 155 u32 enable_replies;
156 u32 rsvd;
156}; 157};
157 158
158/** 159/**
@@ -174,7 +175,7 @@ enum bfa_ioc_type {
174 */ 175 */
175struct bfa_ioc_attr { 176struct bfa_ioc_attr {
176 enum bfa_ioc_type ioc_type; 177 enum bfa_ioc_type ioc_type;
177 enum bfa_ioc_state state; /*!< IOC state */ 178 enum bfa_ioc_state state; /*!< IOC state */
178 struct bfa_adapter_attr adapter_attr; /*!< HBA attributes */ 179 struct bfa_adapter_attr adapter_attr; /*!< HBA attributes */
179 struct bfa_ioc_driver_attr driver_attr; /*!< driver attr */ 180 struct bfa_ioc_driver_attr driver_attr; /*!< driver attr */
180 struct bfa_ioc_pci_attr pci_attr; 181 struct bfa_ioc_pci_attr pci_attr;
diff --git a/drivers/net/bna/bfa_defs_mfg_comm.h b/drivers/net/bna/bfa_defs_mfg_comm.h
index fdd677618361..885ef3afdd4e 100644
--- a/drivers/net/bna/bfa_defs_mfg_comm.h
+++ b/drivers/net/bna/bfa_defs_mfg_comm.h
@@ -192,14 +192,14 @@ do { \
192 * VPD vendor tag 192 * VPD vendor tag
193 */ 193 */
194enum { 194enum {
195 BFA_MFG_VPD_UNKNOWN = 0, /*!< vendor unknown */ 195 BFA_MFG_VPD_UNKNOWN = 0, /*!< vendor unknown */
196 BFA_MFG_VPD_IBM = 1, /*!< vendor IBM */ 196 BFA_MFG_VPD_IBM = 1, /*!< vendor IBM */
197 BFA_MFG_VPD_HP = 2, /*!< vendor HP */ 197 BFA_MFG_VPD_HP = 2, /*!< vendor HP */
198 BFA_MFG_VPD_DELL = 3, /*!< vendor DELL */ 198 BFA_MFG_VPD_DELL = 3, /*!< vendor DELL */
199 BFA_MFG_VPD_PCI_IBM = 0x08, /*!< PCI VPD IBM */ 199 BFA_MFG_VPD_PCI_IBM = 0x08, /*!< PCI VPD IBM */
200 BFA_MFG_VPD_PCI_HP = 0x10, /*!< PCI VPD HP */ 200 BFA_MFG_VPD_PCI_HP = 0x10, /*!< PCI VPD HP */
201 BFA_MFG_VPD_PCI_DELL = 0x20, /*!< PCI VPD DELL */ 201 BFA_MFG_VPD_PCI_DELL = 0x20, /*!< PCI VPD DELL */
202 BFA_MFG_VPD_PCI_BRCD = 0xf8, /*!< PCI VPD Brocade */ 202 BFA_MFG_VPD_PCI_BRCD = 0xf8, /*!< PCI VPD Brocade */
203}; 203};
204 204
205/** 205/**
@@ -212,8 +212,8 @@ struct bfa_mfg_vpd {
212 u8 vpd_sig[3]; /*!< characters 'V', 'P', 'D' */ 212 u8 vpd_sig[3]; /*!< characters 'V', 'P', 'D' */
213 u8 chksum; /*!< u8 checksum */ 213 u8 chksum; /*!< u8 checksum */
214 u8 vendor; /*!< vendor */ 214 u8 vendor; /*!< vendor */
215 u8 len; /*!< vpd data length excluding header */ 215 u8 len; /*!< vpd data length excluding header */
216 u8 rsv; 216 u8 rsv;
217 u8 data[BFA_MFG_VPD_LEN]; /*!< vpd data */ 217 u8 data[BFA_MFG_VPD_LEN]; /*!< vpd data */
218}; 218};
219 219
diff --git a/drivers/net/bna/bfa_defs_status.h b/drivers/net/bna/bfa_defs_status.h
index af951126375c..7c5fe6c2e80e 100644
--- a/drivers/net/bna/bfa_defs_status.h
+++ b/drivers/net/bna/bfa_defs_status.h
@@ -25,95 +25,95 @@
25 * comments are supported 25 * comments are supported
26 */ 26 */
27enum bfa_status { 27enum bfa_status {
28 BFA_STATUS_OK = 0, 28 BFA_STATUS_OK = 0,
29 BFA_STATUS_FAILED = 1, 29 BFA_STATUS_FAILED = 1,
30 BFA_STATUS_EINVAL = 2, 30 BFA_STATUS_EINVAL = 2,
31 BFA_STATUS_ENOMEM = 3, 31 BFA_STATUS_ENOMEM = 3,
32 BFA_STATUS_ENOSYS = 4, 32 BFA_STATUS_ENOSYS = 4,
33 BFA_STATUS_ETIMER = 5, 33 BFA_STATUS_ETIMER = 5,
34 BFA_STATUS_EPROTOCOL = 6, 34 BFA_STATUS_EPROTOCOL = 6,
35 BFA_STATUS_ENOFCPORTS = 7, 35 BFA_STATUS_ENOFCPORTS = 7,
36 BFA_STATUS_NOFLASH = 8, 36 BFA_STATUS_NOFLASH = 8,
37 BFA_STATUS_BADFLASH = 9, 37 BFA_STATUS_BADFLASH = 9,
38 BFA_STATUS_SFP_UNSUPP = 10, 38 BFA_STATUS_SFP_UNSUPP = 10,
39 BFA_STATUS_UNKNOWN_VFID = 11, 39 BFA_STATUS_UNKNOWN_VFID = 11,
40 BFA_STATUS_DATACORRUPTED = 12, 40 BFA_STATUS_DATACORRUPTED = 12,
41 BFA_STATUS_DEVBUSY = 13, 41 BFA_STATUS_DEVBUSY = 13,
42 BFA_STATUS_ABORTED = 14, 42 BFA_STATUS_ABORTED = 14,
43 BFA_STATUS_NODEV = 15, 43 BFA_STATUS_NODEV = 15,
44 BFA_STATUS_HDMA_FAILED = 16, 44 BFA_STATUS_HDMA_FAILED = 16,
45 BFA_STATUS_FLASH_BAD_LEN = 17, 45 BFA_STATUS_FLASH_BAD_LEN = 17,
46 BFA_STATUS_UNKNOWN_LWWN = 18, 46 BFA_STATUS_UNKNOWN_LWWN = 18,
47 BFA_STATUS_UNKNOWN_RWWN = 19, 47 BFA_STATUS_UNKNOWN_RWWN = 19,
48 BFA_STATUS_FCPT_LS_RJT = 20, 48 BFA_STATUS_FCPT_LS_RJT = 20,
49 BFA_STATUS_VPORT_EXISTS = 21, 49 BFA_STATUS_VPORT_EXISTS = 21,
50 BFA_STATUS_VPORT_MAX = 22, 50 BFA_STATUS_VPORT_MAX = 22,
51 BFA_STATUS_UNSUPP_SPEED = 23, 51 BFA_STATUS_UNSUPP_SPEED = 23,
52 BFA_STATUS_INVLD_DFSZ = 24, 52 BFA_STATUS_INVLD_DFSZ = 24,
53 BFA_STATUS_CNFG_FAILED = 25, 53 BFA_STATUS_CNFG_FAILED = 25,
54 BFA_STATUS_CMD_NOTSUPP = 26, 54 BFA_STATUS_CMD_NOTSUPP = 26,
55 BFA_STATUS_NO_ADAPTER = 27, 55 BFA_STATUS_NO_ADAPTER = 27,
56 BFA_STATUS_LINKDOWN = 28, 56 BFA_STATUS_LINKDOWN = 28,
57 BFA_STATUS_FABRIC_RJT = 29, 57 BFA_STATUS_FABRIC_RJT = 29,
58 BFA_STATUS_UNKNOWN_VWWN = 30, 58 BFA_STATUS_UNKNOWN_VWWN = 30,
59 BFA_STATUS_NSLOGIN_FAILED = 31, 59 BFA_STATUS_NSLOGIN_FAILED = 31,
60 BFA_STATUS_NO_RPORTS = 32, 60 BFA_STATUS_NO_RPORTS = 32,
61 BFA_STATUS_NSQUERY_FAILED = 33, 61 BFA_STATUS_NSQUERY_FAILED = 33,
62 BFA_STATUS_PORT_OFFLINE = 34, 62 BFA_STATUS_PORT_OFFLINE = 34,
63 BFA_STATUS_RPORT_OFFLINE = 35, 63 BFA_STATUS_RPORT_OFFLINE = 35,
64 BFA_STATUS_TGTOPEN_FAILED = 36, 64 BFA_STATUS_TGTOPEN_FAILED = 36,
65 BFA_STATUS_BAD_LUNS = 37, 65 BFA_STATUS_BAD_LUNS = 37,
66 BFA_STATUS_IO_FAILURE = 38, 66 BFA_STATUS_IO_FAILURE = 38,
67 BFA_STATUS_NO_FABRIC = 39, 67 BFA_STATUS_NO_FABRIC = 39,
68 BFA_STATUS_EBADF = 40, 68 BFA_STATUS_EBADF = 40,
69 BFA_STATUS_EINTR = 41, 69 BFA_STATUS_EINTR = 41,
70 BFA_STATUS_EIO = 42, 70 BFA_STATUS_EIO = 42,
71 BFA_STATUS_ENOTTY = 43, 71 BFA_STATUS_ENOTTY = 43,
72 BFA_STATUS_ENXIO = 44, 72 BFA_STATUS_ENXIO = 44,
73 BFA_STATUS_EFOPEN = 45, 73 BFA_STATUS_EFOPEN = 45,
74 BFA_STATUS_VPORT_WWN_BP = 46, 74 BFA_STATUS_VPORT_WWN_BP = 46,
75 BFA_STATUS_PORT_NOT_DISABLED = 47, 75 BFA_STATUS_PORT_NOT_DISABLED = 47,
76 BFA_STATUS_BADFRMHDR = 48, 76 BFA_STATUS_BADFRMHDR = 48,
77 BFA_STATUS_BADFRMSZ = 49, 77 BFA_STATUS_BADFRMSZ = 49,
78 BFA_STATUS_MISSINGFRM = 50, 78 BFA_STATUS_MISSINGFRM = 50,
79 BFA_STATUS_LINKTIMEOUT = 51, 79 BFA_STATUS_LINKTIMEOUT = 51,
80 BFA_STATUS_NO_FCPIM_NEXUS = 52, 80 BFA_STATUS_NO_FCPIM_NEXUS = 52,
81 BFA_STATUS_CHECKSUM_FAIL = 53, 81 BFA_STATUS_CHECKSUM_FAIL = 53,
82 BFA_STATUS_GZME_FAILED = 54, 82 BFA_STATUS_GZME_FAILED = 54,
83 BFA_STATUS_SCSISTART_REQD = 55, 83 BFA_STATUS_SCSISTART_REQD = 55,
84 BFA_STATUS_IOC_FAILURE = 56, 84 BFA_STATUS_IOC_FAILURE = 56,
85 BFA_STATUS_INVALID_WWN = 57, 85 BFA_STATUS_INVALID_WWN = 57,
86 BFA_STATUS_MISMATCH = 58, 86 BFA_STATUS_MISMATCH = 58,
87 BFA_STATUS_IOC_ENABLED = 59, 87 BFA_STATUS_IOC_ENABLED = 59,
88 BFA_STATUS_ADAPTER_ENABLED = 60, 88 BFA_STATUS_ADAPTER_ENABLED = 60,
89 BFA_STATUS_IOC_NON_OP = 61, 89 BFA_STATUS_IOC_NON_OP = 61,
90 BFA_STATUS_ADDR_MAP_FAILURE = 62, 90 BFA_STATUS_ADDR_MAP_FAILURE = 62,
91 BFA_STATUS_SAME_NAME = 63, 91 BFA_STATUS_SAME_NAME = 63,
92 BFA_STATUS_PENDING = 64, 92 BFA_STATUS_PENDING = 64,
93 BFA_STATUS_8G_SPD = 65, 93 BFA_STATUS_8G_SPD = 65,
94 BFA_STATUS_4G_SPD = 66, 94 BFA_STATUS_4G_SPD = 66,
95 BFA_STATUS_AD_IS_ENABLE = 67, 95 BFA_STATUS_AD_IS_ENABLE = 67,
96 BFA_STATUS_EINVAL_TOV = 68, 96 BFA_STATUS_EINVAL_TOV = 68,
97 BFA_STATUS_EINVAL_QDEPTH = 69, 97 BFA_STATUS_EINVAL_QDEPTH = 69,
98 BFA_STATUS_VERSION_FAIL = 70, 98 BFA_STATUS_VERSION_FAIL = 70,
99 BFA_STATUS_DIAG_BUSY = 71, 99 BFA_STATUS_DIAG_BUSY = 71,
100 BFA_STATUS_BEACON_ON = 72, 100 BFA_STATUS_BEACON_ON = 72,
101 BFA_STATUS_BEACON_OFF = 73, 101 BFA_STATUS_BEACON_OFF = 73,
102 BFA_STATUS_LBEACON_ON = 74, 102 BFA_STATUS_LBEACON_ON = 74,
103 BFA_STATUS_LBEACON_OFF = 75, 103 BFA_STATUS_LBEACON_OFF = 75,
104 BFA_STATUS_PORT_NOT_INITED = 76, 104 BFA_STATUS_PORT_NOT_INITED = 76,
105 BFA_STATUS_RPSC_ENABLED = 77, 105 BFA_STATUS_RPSC_ENABLED = 77,
106 BFA_STATUS_ENOFSAVE = 78, 106 BFA_STATUS_ENOFSAVE = 78,
107 BFA_STATUS_BAD_FILE = 79, 107 BFA_STATUS_BAD_FILE = 79,
108 BFA_STATUS_RLIM_EN = 80, 108 BFA_STATUS_RLIM_EN = 80,
109 BFA_STATUS_RLIM_DIS = 81, 109 BFA_STATUS_RLIM_DIS = 81,
110 BFA_STATUS_IOC_DISABLED = 82, 110 BFA_STATUS_IOC_DISABLED = 82,
111 BFA_STATUS_ADAPTER_DISABLED = 83, 111 BFA_STATUS_ADAPTER_DISABLED = 83,
112 BFA_STATUS_BIOS_DISABLED = 84, 112 BFA_STATUS_BIOS_DISABLED = 84,
113 BFA_STATUS_AUTH_ENABLED = 85, 113 BFA_STATUS_AUTH_ENABLED = 85,
114 BFA_STATUS_AUTH_DISABLED = 86, 114 BFA_STATUS_AUTH_DISABLED = 86,
115 BFA_STATUS_ERROR_TRL_ENABLED = 87, 115 BFA_STATUS_ERROR_TRL_ENABLED = 87,
116 BFA_STATUS_ERROR_QOS_ENABLED = 88, 116 BFA_STATUS_ERROR_QOS_ENABLED = 88,
117 BFA_STATUS_NO_SFP_DEV = 89, 117 BFA_STATUS_NO_SFP_DEV = 89,
118 BFA_STATUS_MEMTEST_FAILED = 90, 118 BFA_STATUS_MEMTEST_FAILED = 90,
119 BFA_STATUS_INVALID_DEVID = 91, 119 BFA_STATUS_INVALID_DEVID = 91,
@@ -190,7 +190,7 @@ enum bfa_status {
190 BFA_STATUS_FLASH_CKFAIL = 162, 190 BFA_STATUS_FLASH_CKFAIL = 162,
191 BFA_STATUS_TRUNK_UNSUPP = 163, 191 BFA_STATUS_TRUNK_UNSUPP = 163,
192 BFA_STATUS_TRUNK_ENABLED = 164, 192 BFA_STATUS_TRUNK_ENABLED = 164,
193 BFA_STATUS_TRUNK_DISABLED = 165, 193 BFA_STATUS_TRUNK_DISABLED = 165,
194 BFA_STATUS_TRUNK_ERROR_TRL_ENABLED = 166, 194 BFA_STATUS_TRUNK_ERROR_TRL_ENABLED = 166,
195 BFA_STATUS_BOOT_CODE_UPDATED = 167, 195 BFA_STATUS_BOOT_CODE_UPDATED = 167,
196 BFA_STATUS_BOOT_VERSION = 168, 196 BFA_STATUS_BOOT_VERSION = 168,
@@ -198,8 +198,8 @@ enum bfa_status {
198 BFA_STATUS_INVALID_CARDTYPE = 170, 198 BFA_STATUS_INVALID_CARDTYPE = 170,
199 BFA_STATUS_NO_TOPOLOGY_FOR_CNA = 171, 199 BFA_STATUS_NO_TOPOLOGY_FOR_CNA = 171,
200 BFA_STATUS_IM_VLAN_OVER_TEAM_DELETE_FAILED = 172, 200 BFA_STATUS_IM_VLAN_OVER_TEAM_DELETE_FAILED = 172,
201 BFA_STATUS_ETHBOOT_ENABLED = 173, 201 BFA_STATUS_ETHBOOT_ENABLED = 173,
202 BFA_STATUS_ETHBOOT_DISABLED = 174, 202 BFA_STATUS_ETHBOOT_DISABLED = 174,
203 BFA_STATUS_IOPROFILE_OFF = 175, 203 BFA_STATUS_IOPROFILE_OFF = 175,
204 BFA_STATUS_NO_PORT_INSTANCE = 176, 204 BFA_STATUS_NO_PORT_INSTANCE = 176,
205 BFA_STATUS_BOOT_CODE_TIMEDOUT = 177, 205 BFA_STATUS_BOOT_CODE_TIMEDOUT = 177,
diff --git a/drivers/net/bna/bfa_ioc.c b/drivers/net/bna/bfa_ioc.c
index fcb9bb3169e0..126b0aac9f94 100644
--- a/drivers/net/bna/bfa_ioc.c
+++ b/drivers/net/bna/bfa_ioc.c
@@ -58,6 +58,7 @@ static bool bfa_nw_auto_recover = true;
58/* 58/*
59 * forward declarations 59 * forward declarations
60 */ 60 */
61static void bfa_ioc_hw_sem_init(struct bfa_ioc *ioc);
61static void bfa_ioc_hw_sem_get(struct bfa_ioc *ioc); 62static void bfa_ioc_hw_sem_get(struct bfa_ioc *ioc);
62static void bfa_ioc_hw_sem_get_cancel(struct bfa_ioc *ioc); 63static void bfa_ioc_hw_sem_get_cancel(struct bfa_ioc *ioc);
63static void bfa_ioc_hwinit(struct bfa_ioc *ioc, bool force); 64static void bfa_ioc_hwinit(struct bfa_ioc *ioc, bool force);
@@ -68,9 +69,10 @@ static void bfa_ioc_hb_monitor(struct bfa_ioc *ioc);
68static void bfa_ioc_hb_stop(struct bfa_ioc *ioc); 69static void bfa_ioc_hb_stop(struct bfa_ioc *ioc);
69static void bfa_ioc_reset(struct bfa_ioc *ioc, bool force); 70static void bfa_ioc_reset(struct bfa_ioc *ioc, bool force);
70static void bfa_ioc_mbox_poll(struct bfa_ioc *ioc); 71static void bfa_ioc_mbox_poll(struct bfa_ioc *ioc);
71static void bfa_ioc_mbox_hbfail(struct bfa_ioc *ioc); 72static void bfa_ioc_mbox_flush(struct bfa_ioc *ioc);
72static void bfa_ioc_recover(struct bfa_ioc *ioc); 73static void bfa_ioc_recover(struct bfa_ioc *ioc);
73static void bfa_ioc_check_attr_wwns(struct bfa_ioc *ioc); 74static void bfa_ioc_check_attr_wwns(struct bfa_ioc *ioc);
75static void bfa_ioc_event_notify(struct bfa_ioc *, enum bfa_ioc_event);
74static void bfa_ioc_disable_comp(struct bfa_ioc *ioc); 76static void bfa_ioc_disable_comp(struct bfa_ioc *ioc);
75static void bfa_ioc_lpu_stop(struct bfa_ioc *ioc); 77static void bfa_ioc_lpu_stop(struct bfa_ioc *ioc);
76static void bfa_ioc_fail_notify(struct bfa_ioc *ioc); 78static void bfa_ioc_fail_notify(struct bfa_ioc *ioc);
@@ -107,7 +109,7 @@ enum ioc_event {
107 IOC_E_FWRSP_GETATTR = 6, /*!< IOC get attribute response */ 109 IOC_E_FWRSP_GETATTR = 6, /*!< IOC get attribute response */
108 IOC_E_DISABLED = 7, /*!< f/w disabled */ 110 IOC_E_DISABLED = 7, /*!< f/w disabled */
109 IOC_E_INITFAILED = 8, /*!< failure notice by iocpf sm */ 111 IOC_E_INITFAILED = 8, /*!< failure notice by iocpf sm */
110 IOC_E_PFAILED = 9, /*!< failure notice by iocpf sm */ 112 IOC_E_PFFAILED = 9, /*!< failure notice by iocpf sm */
111 IOC_E_HBFAIL = 10, /*!< heartbeat failure */ 113 IOC_E_HBFAIL = 10, /*!< heartbeat failure */
112 IOC_E_HWERROR = 11, /*!< hardware error interrupt */ 114 IOC_E_HWERROR = 11, /*!< hardware error interrupt */
113 IOC_E_TIMEOUT = 12, /*!< timeout */ 115 IOC_E_TIMEOUT = 12, /*!< timeout */
@@ -156,7 +158,7 @@ enum iocpf_event {
156 IOCPF_E_ENABLE = 1, /*!< IOCPF enable request */ 158 IOCPF_E_ENABLE = 1, /*!< IOCPF enable request */
157 IOCPF_E_DISABLE = 2, /*!< IOCPF disable request */ 159 IOCPF_E_DISABLE = 2, /*!< IOCPF disable request */
158 IOCPF_E_STOP = 3, /*!< stop on driver detach */ 160 IOCPF_E_STOP = 3, /*!< stop on driver detach */
159 IOCPF_E_FWREADY = 4, /*!< f/w initialization done */ 161 IOCPF_E_FWREADY = 4, /*!< f/w initialization done */
160 IOCPF_E_FWRSP_ENABLE = 5, /*!< enable f/w response */ 162 IOCPF_E_FWRSP_ENABLE = 5, /*!< enable f/w response */
161 IOCPF_E_FWRSP_DISABLE = 6, /*!< disable f/w response */ 163 IOCPF_E_FWRSP_DISABLE = 6, /*!< disable f/w response */
162 IOCPF_E_FAIL = 7, /*!< failure notice by ioc sm */ 164 IOCPF_E_FAIL = 7, /*!< failure notice by ioc sm */
@@ -239,7 +241,7 @@ bfa_ioc_sm_uninit(struct bfa_ioc *ioc, enum ioc_event event)
239 break; 241 break;
240 242
241 default: 243 default:
242 bfa_sm_fault(ioc, event); 244 bfa_sm_fault(event);
243 } 245 }
244} 246}
245 247
@@ -272,7 +274,7 @@ bfa_ioc_sm_reset(struct bfa_ioc *ioc, enum ioc_event event)
272 break; 274 break;
273 275
274 default: 276 default:
275 bfa_sm_fault(ioc, event); 277 bfa_sm_fault(event);
276 } 278 }
277} 279}
278 280
@@ -294,12 +296,12 @@ bfa_ioc_sm_enabling(struct bfa_ioc *ioc, enum ioc_event event)
294 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); 296 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
295 break; 297 break;
296 298
297 case IOC_E_PFAILED: 299 case IOC_E_PFFAILED:
298 /* !!! fall through !!! */ 300 /* !!! fall through !!! */
299 case IOC_E_HWERROR: 301 case IOC_E_HWERROR:
300 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 302 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
301 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry); 303 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
302 if (event != IOC_E_PFAILED) 304 if (event != IOC_E_PFFAILED)
303 bfa_iocpf_initfail(ioc); 305 bfa_iocpf_initfail(ioc);
304 break; 306 break;
305 307
@@ -316,7 +318,7 @@ bfa_ioc_sm_enabling(struct bfa_ioc *ioc, enum ioc_event event)
316 break; 318 break;
317 319
318 default: 320 default:
319 bfa_sm_fault(ioc, event); 321 bfa_sm_fault(event);
320 } 322 }
321} 323}
322 324
@@ -344,14 +346,14 @@ bfa_ioc_sm_getattr(struct bfa_ioc *ioc, enum ioc_event event)
344 bfa_fsm_set_state(ioc, bfa_ioc_sm_op); 346 bfa_fsm_set_state(ioc, bfa_ioc_sm_op);
345 break; 347 break;
346 348
347 case IOC_E_PFAILED: 349 case IOC_E_PFFAILED:
348 case IOC_E_HWERROR: 350 case IOC_E_HWERROR:
349 del_timer(&ioc->ioc_timer); 351 del_timer(&ioc->ioc_timer);
350 /* fall through */ 352 /* fall through */
351 case IOC_E_TIMEOUT: 353 case IOC_E_TIMEOUT:
352 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 354 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
353 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry); 355 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
354 if (event != IOC_E_PFAILED) 356 if (event != IOC_E_PFFAILED)
355 bfa_iocpf_getattrfail(ioc); 357 bfa_iocpf_getattrfail(ioc);
356 break; 358 break;
357 359
@@ -364,7 +366,7 @@ bfa_ioc_sm_getattr(struct bfa_ioc *ioc, enum ioc_event event)
364 break; 366 break;
365 367
366 default: 368 default:
367 bfa_sm_fault(ioc, event); 369 bfa_sm_fault(event);
368 } 370 }
369} 371}
370 372
@@ -387,7 +389,7 @@ bfa_ioc_sm_op(struct bfa_ioc *ioc, enum ioc_event event)
387 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling); 389 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
388 break; 390 break;
389 391
390 case IOC_E_PFAILED: 392 case IOC_E_PFFAILED:
391 case IOC_E_HWERROR: 393 case IOC_E_HWERROR:
392 bfa_ioc_hb_stop(ioc); 394 bfa_ioc_hb_stop(ioc);
393 /* !!! fall through !!! */ 395 /* !!! fall through !!! */
@@ -398,12 +400,12 @@ bfa_ioc_sm_op(struct bfa_ioc *ioc, enum ioc_event event)
398 else 400 else
399 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail); 401 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
400 402
401 if (event != IOC_E_PFAILED) 403 if (event != IOC_E_PFFAILED)
402 bfa_iocpf_fail(ioc); 404 bfa_iocpf_fail(ioc);
403 break; 405 break;
404 406
405 default: 407 default:
406 bfa_sm_fault(ioc, event); 408 bfa_sm_fault(event);
407 } 409 }
408} 410}
409 411
@@ -434,7 +436,7 @@ bfa_ioc_sm_disabling(struct bfa_ioc *ioc, enum ioc_event event)
434 break; 436 break;
435 437
436 default: 438 default:
437 bfa_sm_fault(ioc, event); 439 bfa_sm_fault(event);
438 } 440 }
439} 441}
440 442
@@ -465,7 +467,7 @@ bfa_ioc_sm_disabled(struct bfa_ioc *ioc, enum ioc_event event)
465 break; 467 break;
466 468
467 default: 469 default:
468 bfa_sm_fault(ioc, event); 470 bfa_sm_fault(event);
469 } 471 }
470} 472}
471 473
@@ -485,13 +487,13 @@ bfa_ioc_sm_fail_retry(struct bfa_ioc *ioc, enum ioc_event event)
485 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); 487 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
486 break; 488 break;
487 489
488 case IOC_E_PFAILED: 490 case IOC_E_PFFAILED:
489 case IOC_E_HWERROR: 491 case IOC_E_HWERROR:
490 /** 492 /**
491 * Initialization retry failed. 493 * Initialization retry failed.
492 */ 494 */
493 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 495 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
494 if (event != IOC_E_PFAILED) 496 if (event != IOC_E_PFFAILED)
495 bfa_iocpf_initfail(ioc); 497 bfa_iocpf_initfail(ioc);
496 break; 498 break;
497 499
@@ -512,7 +514,7 @@ bfa_ioc_sm_fail_retry(struct bfa_ioc *ioc, enum ioc_event event)
512 break; 514 break;
513 515
514 default: 516 default:
515 bfa_sm_fault(ioc, event); 517 bfa_sm_fault(event);
516 } 518 }
517} 519}
518 520
@@ -546,7 +548,7 @@ bfa_ioc_sm_fail(struct bfa_ioc *ioc, enum ioc_event event)
546 break; 548 break;
547 549
548 default: 550 default:
549 bfa_sm_fault(ioc, event); 551 bfa_sm_fault(event);
550 } 552 }
551} 553}
552 554
@@ -579,7 +581,7 @@ bfa_iocpf_sm_reset(struct bfa_iocpf *iocpf, enum iocpf_event event)
579 break; 581 break;
580 582
581 default: 583 default:
582 bfa_sm_fault(iocpf->ioc, event); 584 bfa_sm_fault(event);
583 } 585 }
584} 586}
585 587
@@ -589,6 +591,7 @@ bfa_iocpf_sm_reset(struct bfa_iocpf *iocpf, enum iocpf_event event)
589static void 591static void
590bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf *iocpf) 592bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf *iocpf)
591{ 593{
594 bfa_ioc_hw_sem_init(iocpf->ioc);
592 bfa_ioc_hw_sem_get(iocpf->ioc); 595 bfa_ioc_hw_sem_get(iocpf->ioc);
593} 596}
594 597
@@ -631,7 +634,7 @@ bfa_iocpf_sm_fwcheck(struct bfa_iocpf *iocpf, enum iocpf_event event)
631 break; 634 break;
632 635
633 default: 636 default:
634 bfa_sm_fault(ioc, event); 637 bfa_sm_fault(event);
635 } 638 }
636} 639}
637 640
@@ -675,7 +678,7 @@ bfa_iocpf_sm_mismatch(struct bfa_iocpf *iocpf, enum iocpf_event event)
675 break; 678 break;
676 679
677 default: 680 default:
678 bfa_sm_fault(ioc, event); 681 bfa_sm_fault(event);
679 } 682 }
680} 683}
681 684
@@ -714,7 +717,7 @@ bfa_iocpf_sm_semwait(struct bfa_iocpf *iocpf, enum iocpf_event event)
714 break; 717 break;
715 718
716 default: 719 default:
717 bfa_sm_fault(ioc, event); 720 bfa_sm_fault(event);
718 } 721 }
719} 722}
720 723
@@ -762,7 +765,7 @@ bfa_iocpf_sm_hwinit(struct bfa_iocpf *iocpf, enum iocpf_event event)
762 break; 765 break;
763 766
764 default: 767 default:
765 bfa_sm_fault(ioc, event); 768 bfa_sm_fault(event);
766 } 769 }
767} 770}
768 771
@@ -813,7 +816,7 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf *iocpf, enum iocpf_event event)
813 break; 816 break;
814 817
815 default: 818 default:
816 bfa_sm_fault(ioc, event); 819 bfa_sm_fault(event);
817 } 820 }
818} 821}
819 822
@@ -856,7 +859,7 @@ bfa_iocpf_sm_ready(struct bfa_iocpf *iocpf, enum iocpf_event event)
856 break; 859 break;
857 860
858 default: 861 default:
859 bfa_sm_fault(ioc, event); 862 bfa_sm_fault(event);
860 } 863 }
861} 864}
862 865
@@ -898,7 +901,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf *iocpf, enum iocpf_event event)
898 break; 901 break;
899 902
900 default: 903 default:
901 bfa_sm_fault(ioc, event); 904 bfa_sm_fault(event);
902 } 905 }
903} 906}
904 907
@@ -927,7 +930,7 @@ bfa_iocpf_sm_disabling_sync(struct bfa_iocpf *iocpf, enum iocpf_event event)
927 break; 930 break;
928 931
929 default: 932 default:
930 bfa_sm_fault(ioc, event); 933 bfa_sm_fault(event);
931 } 934 }
932} 935}
933 936
@@ -937,6 +940,7 @@ bfa_iocpf_sm_disabling_sync(struct bfa_iocpf *iocpf, enum iocpf_event event)
937static void 940static void
938bfa_iocpf_sm_disabled_entry(struct bfa_iocpf *iocpf) 941bfa_iocpf_sm_disabled_entry(struct bfa_iocpf *iocpf)
939{ 942{
943 bfa_ioc_mbox_flush(iocpf->ioc);
940 bfa_ioc_pf_disabled(iocpf->ioc); 944 bfa_ioc_pf_disabled(iocpf->ioc);
941} 945}
942 946
@@ -957,7 +961,7 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf *iocpf, enum iocpf_event event)
957 break; 961 break;
958 962
959 default: 963 default:
960 bfa_sm_fault(ioc, event); 964 bfa_sm_fault(event);
961 } 965 }
962} 966}
963 967
@@ -1009,7 +1013,7 @@ bfa_iocpf_sm_initfail_sync(struct bfa_iocpf *iocpf, enum iocpf_event event)
1009 break; 1013 break;
1010 1014
1011 default: 1015 default:
1012 bfa_sm_fault(ioc, event); 1016 bfa_sm_fault(event);
1013 } 1017 }
1014} 1018}
1015 1019
@@ -1038,7 +1042,7 @@ bfa_iocpf_sm_initfail(struct bfa_iocpf *iocpf, enum iocpf_event event)
1038 break; 1042 break;
1039 1043
1040 default: 1044 default:
1041 bfa_sm_fault(ioc, event); 1045 bfa_sm_fault(event);
1042 } 1046 }
1043} 1047}
1044 1048
@@ -1053,7 +1057,7 @@ bfa_iocpf_sm_fail_sync_entry(struct bfa_iocpf *iocpf)
1053 /** 1057 /**
1054 * Flush any queued up mailbox requests. 1058 * Flush any queued up mailbox requests.
1055 */ 1059 */
1056 bfa_ioc_mbox_hbfail(iocpf->ioc); 1060 bfa_ioc_mbox_flush(iocpf->ioc);
1057 bfa_ioc_hw_sem_get(iocpf->ioc); 1061 bfa_ioc_hw_sem_get(iocpf->ioc);
1058} 1062}
1059 1063
@@ -1093,7 +1097,7 @@ bfa_iocpf_sm_fail_sync(struct bfa_iocpf *iocpf, enum iocpf_event event)
1093 break; 1097 break;
1094 1098
1095 default: 1099 default:
1096 bfa_sm_fault(ioc, event); 1100 bfa_sm_fault(event);
1097 } 1101 }
1098} 1102}
1099 1103
@@ -1115,7 +1119,7 @@ bfa_iocpf_sm_fail(struct bfa_iocpf *iocpf, enum iocpf_event event)
1115 break; 1119 break;
1116 1120
1117 default: 1121 default:
1118 bfa_sm_fault(iocpf->ioc, event); 1122 bfa_sm_fault(event);
1119 } 1123 }
1120} 1124}
1121 1125
@@ -1123,23 +1127,28 @@ bfa_iocpf_sm_fail(struct bfa_iocpf *iocpf, enum iocpf_event event)
1123 * BFA IOC private functions 1127 * BFA IOC private functions
1124 */ 1128 */
1125 1129
1130/**
1131 * Notify common modules registered for notification.
1132 */
1126static void 1133static void
1127bfa_ioc_disable_comp(struct bfa_ioc *ioc) 1134bfa_ioc_event_notify(struct bfa_ioc *ioc, enum bfa_ioc_event event)
1128{ 1135{
1136 struct bfa_ioc_notify *notify;
1129 struct list_head *qe; 1137 struct list_head *qe;
1130 struct bfa_ioc_hbfail_notify *notify;
1131
1132 ioc->cbfn->disable_cbfn(ioc->bfa);
1133 1138
1134 /** 1139 list_for_each(qe, &ioc->notify_q) {
1135 * Notify common modules registered for notification. 1140 notify = (struct bfa_ioc_notify *)qe;
1136 */ 1141 notify->cbfn(notify->cbarg, event);
1137 list_for_each(qe, &ioc->hb_notify_q) {
1138 notify = (struct bfa_ioc_hbfail_notify *) qe;
1139 notify->cbfn(notify->cbarg);
1140 } 1142 }
1141} 1143}
1142 1144
1145static void
1146bfa_ioc_disable_comp(struct bfa_ioc *ioc)
1147{
1148 ioc->cbfn->disable_cbfn(ioc->bfa);
1149 bfa_ioc_event_notify(ioc, BFA_IOC_E_DISABLED);
1150}
1151
1143bool 1152bool
1144bfa_nw_ioc_sem_get(void __iomem *sem_reg) 1153bfa_nw_ioc_sem_get(void __iomem *sem_reg)
1145{ 1154{
@@ -1169,6 +1178,29 @@ bfa_nw_ioc_sem_release(void __iomem *sem_reg)
1169} 1178}
1170 1179
1171static void 1180static void
1181bfa_ioc_hw_sem_init(struct bfa_ioc *ioc)
1182{
1183 struct bfi_ioc_image_hdr fwhdr;
1184 u32 fwstate = readl(ioc->ioc_regs.ioc_fwstate);
1185
1186 if (fwstate == BFI_IOC_UNINIT)
1187 return;
1188
1189 bfa_nw_ioc_fwver_get(ioc, &fwhdr);
1190
1191 if (swab32(fwhdr.exec) == BFI_FWBOOT_TYPE_NORMAL)
1192 return;
1193
1194 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
1195
1196 /*
1197 * Try to lock and then unlock the semaphore.
1198 */
1199 readl(ioc->ioc_regs.ioc_sem_reg);
1200 writel(1, ioc->ioc_regs.ioc_sem_reg);
1201}
1202
1203static void
1172bfa_ioc_hw_sem_get(struct bfa_ioc *ioc) 1204bfa_ioc_hw_sem_get(struct bfa_ioc *ioc)
1173{ 1205{
1174 u32 r32; 1206 u32 r32;
@@ -1638,7 +1670,7 @@ bfa_ioc_mbox_poll(struct bfa_ioc *ioc)
1638 * Cleanup any pending requests. 1670 * Cleanup any pending requests.
1639 */ 1671 */
1640static void 1672static void
1641bfa_ioc_mbox_hbfail(struct bfa_ioc *ioc) 1673bfa_ioc_mbox_flush(struct bfa_ioc *ioc)
1642{ 1674{
1643 struct bfa_ioc_mbox_mod *mod = &ioc->mbox_mod; 1675 struct bfa_ioc_mbox_mod *mod = &ioc->mbox_mod;
1644 struct bfa_mbox_cmd *cmd; 1676 struct bfa_mbox_cmd *cmd;
@@ -1650,17 +1682,11 @@ bfa_ioc_mbox_hbfail(struct bfa_ioc *ioc)
1650static void 1682static void
1651bfa_ioc_fail_notify(struct bfa_ioc *ioc) 1683bfa_ioc_fail_notify(struct bfa_ioc *ioc)
1652{ 1684{
1653 struct list_head *qe;
1654 struct bfa_ioc_hbfail_notify *notify;
1655
1656 /** 1685 /**
1657 * Notify driver and common modules registered for notification. 1686 * Notify driver and common modules registered for notification.
1658 */ 1687 */
1659 ioc->cbfn->hbfail_cbfn(ioc->bfa); 1688 ioc->cbfn->hbfail_cbfn(ioc->bfa);
1660 list_for_each(qe, &ioc->hb_notify_q) { 1689 bfa_ioc_event_notify(ioc, BFA_IOC_E_FAILED);
1661 notify = (struct bfa_ioc_hbfail_notify *) qe;
1662 notify->cbfn(notify->cbarg);
1663 }
1664} 1690}
1665 1691
1666static void 1692static void
@@ -1684,7 +1710,7 @@ bfa_ioc_pf_initfailed(struct bfa_ioc *ioc)
1684static void 1710static void
1685bfa_ioc_pf_failed(struct bfa_ioc *ioc) 1711bfa_ioc_pf_failed(struct bfa_ioc *ioc)
1686{ 1712{
1687 bfa_fsm_send_event(ioc, IOC_E_PFAILED); 1713 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
1688} 1714}
1689 1715
1690static void 1716static void
@@ -1839,7 +1865,7 @@ bfa_nw_ioc_attach(struct bfa_ioc *ioc, void *bfa, struct bfa_ioc_cbfn *cbfn)
1839 ioc->iocpf.ioc = ioc; 1865 ioc->iocpf.ioc = ioc;
1840 1866
1841 bfa_ioc_mbox_attach(ioc); 1867 bfa_ioc_mbox_attach(ioc);
1842 INIT_LIST_HEAD(&ioc->hb_notify_q); 1868 INIT_LIST_HEAD(&ioc->notify_q);
1843 1869
1844 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); 1870 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
1845 bfa_fsm_send_event(ioc, IOC_E_RESET); 1871 bfa_fsm_send_event(ioc, IOC_E_RESET);
@@ -1969,6 +1995,8 @@ bfa_nw_ioc_mbox_queue(struct bfa_ioc *ioc, struct bfa_mbox_cmd *cmd)
1969 * mailbox is free -- queue command to firmware 1995 * mailbox is free -- queue command to firmware
1970 */ 1996 */
1971 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg)); 1997 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
1998
1999 return;
1972} 2000}
1973 2001
1974/** 2002/**
@@ -2001,18 +2029,30 @@ bfa_nw_ioc_mbox_isr(struct bfa_ioc *ioc)
2001void 2029void
2002bfa_nw_ioc_error_isr(struct bfa_ioc *ioc) 2030bfa_nw_ioc_error_isr(struct bfa_ioc *ioc)
2003{ 2031{
2032 bfa_ioc_stats(ioc, ioc_hbfails);
2033 bfa_ioc_stats_hb_count(ioc, ioc->hb_count);
2004 bfa_fsm_send_event(ioc, IOC_E_HWERROR); 2034 bfa_fsm_send_event(ioc, IOC_E_HWERROR);
2005} 2035}
2006 2036
2007/** 2037/**
2038 * return true if IOC is disabled
2039 */
2040bool
2041bfa_nw_ioc_is_disabled(struct bfa_ioc *ioc)
2042{
2043 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabling) ||
2044 bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled);
2045}
2046
2047/**
2008 * Add to IOC heartbeat failure notification queue. To be used by common 2048 * Add to IOC heartbeat failure notification queue. To be used by common
2009 * modules such as cee, port, diag. 2049 * modules such as cee, port, diag.
2010 */ 2050 */
2011void 2051void
2012bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc, 2052bfa_nw_ioc_notify_register(struct bfa_ioc *ioc,
2013 struct bfa_ioc_hbfail_notify *notify) 2053 struct bfa_ioc_notify *notify)
2014{ 2054{
2015 list_add_tail(&notify->qe, &ioc->hb_notify_q); 2055 list_add_tail(&notify->qe, &ioc->notify_q);
2016} 2056}
2017 2057
2018#define BFA_MFG_NAME "Brocade" 2058#define BFA_MFG_NAME "Brocade"
@@ -2217,6 +2257,7 @@ bfa_ioc_recover(struct bfa_ioc *ioc)
2217{ 2257{
2218 pr_crit("Heart Beat of IOC has failed\n"); 2258 pr_crit("Heart Beat of IOC has failed\n");
2219 bfa_ioc_stats(ioc, ioc_hbfails); 2259 bfa_ioc_stats(ioc, ioc_hbfails);
2260 bfa_ioc_stats_hb_count(ioc, ioc->hb_count);
2220 bfa_fsm_send_event(ioc, IOC_E_HBFAIL); 2261 bfa_fsm_send_event(ioc, IOC_E_HBFAIL);
2221} 2262}
2222 2263
diff --git a/drivers/net/bna/bfa_ioc.h b/drivers/net/bna/bfa_ioc.h
index bd48abee781f..bda866ba6e90 100644
--- a/drivers/net/bna/bfa_ioc.h
+++ b/drivers/net/bna/bfa_ioc.h
@@ -19,7 +19,7 @@
19#ifndef __BFA_IOC_H__ 19#ifndef __BFA_IOC_H__
20#define __BFA_IOC_H__ 20#define __BFA_IOC_H__
21 21
22#include "bfa_sm.h" 22#include "bfa_cs.h"
23#include "bfi.h" 23#include "bfi.h"
24#include "cna.h" 24#include "cna.h"
25 25
@@ -97,9 +97,12 @@ struct bfa_ioc_regs {
97/** 97/**
98 * IOC Mailbox structures 98 * IOC Mailbox structures
99 */ 99 */
100typedef void (*bfa_mbox_cmd_cbfn_t)(void *cbarg);
100struct bfa_mbox_cmd { 101struct bfa_mbox_cmd {
101 struct list_head qe; 102 struct list_head qe;
102 u32 msg[BFI_IOC_MSGSZ]; 103 bfa_mbox_cmd_cbfn_t cbfn;
104 void *cbarg;
105 u32 msg[BFI_IOC_MSGSZ];
103}; 106};
104 107
105/** 108/**
@@ -130,6 +133,23 @@ struct bfa_ioc_cbfn {
130}; 133};
131 134
132/** 135/**
136 * IOC event notification mechanism.
137 */
138enum bfa_ioc_event {
139 BFA_IOC_E_ENABLED = 1,
140 BFA_IOC_E_DISABLED = 2,
141 BFA_IOC_E_FAILED = 3,
142};
143
144typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event);
145
146struct bfa_ioc_notify {
147 struct list_head qe;
148 bfa_ioc_notify_cbfn_t cbfn;
149 void *cbarg;
150};
151
152/**
133 * Heartbeat failure notification queue element. 153 * Heartbeat failure notification queue element.
134 */ 154 */
135struct bfa_ioc_hbfail_notify { 155struct bfa_ioc_hbfail_notify {
@@ -141,7 +161,7 @@ struct bfa_ioc_hbfail_notify {
141/** 161/**
142 * Initialize a heartbeat failure notification structure 162 * Initialize a heartbeat failure notification structure
143 */ 163 */
144#define bfa_ioc_hbfail_init(__notify, __cbfn, __cbarg) do { \ 164#define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do { \
145 (__notify)->cbfn = (__cbfn); \ 165 (__notify)->cbfn = (__cbfn); \
146 (__notify)->cbarg = (__cbarg); \ 166 (__notify)->cbarg = (__cbarg); \
147} while (0) 167} while (0)
@@ -155,25 +175,25 @@ struct bfa_iocpf {
155 175
156struct bfa_ioc { 176struct bfa_ioc {
157 bfa_fsm_t fsm; 177 bfa_fsm_t fsm;
158 struct bfa *bfa; 178 struct bfa *bfa;
159 struct bfa_pcidev pcidev; 179 struct bfa_pcidev pcidev;
160 struct timer_list ioc_timer; 180 struct timer_list ioc_timer;
161 struct timer_list iocpf_timer; 181 struct timer_list iocpf_timer;
162 struct timer_list sem_timer; 182 struct timer_list sem_timer;
163 struct timer_list hb_timer; 183 struct timer_list hb_timer;
164 u32 hb_count; 184 u32 hb_count;
165 struct list_head hb_notify_q; 185 struct list_head notify_q;
166 void *dbg_fwsave; 186 void *dbg_fwsave;
167 int dbg_fwsave_len; 187 int dbg_fwsave_len;
168 bool dbg_fwsave_once; 188 bool dbg_fwsave_once;
169 enum bfi_mclass ioc_mc; 189 enum bfi_mclass ioc_mc;
170 struct bfa_ioc_regs ioc_regs; 190 struct bfa_ioc_regs ioc_regs;
171 struct bfa_ioc_drv_stats stats; 191 struct bfa_ioc_drv_stats stats;
172 bool fcmode; 192 bool fcmode;
173 bool ctdev; 193 bool ctdev;
174 bool cna; 194 bool cna;
175 bool pllinit; 195 bool pllinit;
176 bool stats_busy; /*!< outstanding stats */ 196 bool stats_busy; /*!< outstanding stats */
177 u8 port_id; 197 u8 port_id;
178 198
179 struct bfa_dma attr_dma; 199 struct bfa_dma attr_dma;
@@ -217,9 +237,11 @@ struct bfa_ioc_hwif {
217 BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop) 237 BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop)
218 238
219#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++) 239#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++)
240#define bfa_ioc_stats_hb_count(_ioc, _hb_count) \
241 ((_ioc)->stats.hb_count = (_hb_count))
220#define BFA_IOC_FWIMG_MINSZ (16 * 1024) 242#define BFA_IOC_FWIMG_MINSZ (16 * 1024)
221#define BFA_IOC_FWIMG_TYPE(__ioc) \ 243#define BFA_IOC_FWIMG_TYPE(__ioc) \
222 (((__ioc)->ctdev) ? \ 244 (((__ioc)->ctdev) ? \
223 (((__ioc)->fcmode) ? BFI_IMAGE_CT_FC : BFI_IMAGE_CT_CNA) : \ 245 (((__ioc)->fcmode) ? BFI_IMAGE_CT_FC : BFI_IMAGE_CT_CNA) : \
224 BFI_IMAGE_CB_FC) 246 BFI_IMAGE_CB_FC)
225#define BFA_IOC_FW_SMEM_SIZE(__ioc) \ 247#define BFA_IOC_FW_SMEM_SIZE(__ioc) \
@@ -263,9 +285,10 @@ void bfa_nw_ioc_enable(struct bfa_ioc *ioc);
263void bfa_nw_ioc_disable(struct bfa_ioc *ioc); 285void bfa_nw_ioc_disable(struct bfa_ioc *ioc);
264 286
265void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc); 287void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc);
288bool bfa_nw_ioc_is_disabled(struct bfa_ioc *ioc);
266void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr); 289void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr);
267void bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc, 290void bfa_nw_ioc_notify_register(struct bfa_ioc *ioc,
268 struct bfa_ioc_hbfail_notify *notify); 291 struct bfa_ioc_notify *notify);
269bool bfa_nw_ioc_sem_get(void __iomem *sem_reg); 292bool bfa_nw_ioc_sem_get(void __iomem *sem_reg);
270void bfa_nw_ioc_sem_release(void __iomem *sem_reg); 293void bfa_nw_ioc_sem_release(void __iomem *sem_reg);
271void bfa_nw_ioc_hw_sem_release(struct bfa_ioc *ioc); 294void bfa_nw_ioc_hw_sem_release(struct bfa_ioc *ioc);
diff --git a/drivers/net/bna/bfa_wc.h b/drivers/net/bna/bfa_wc.h
deleted file mode 100644
index d0e4caee67b0..000000000000
--- a/drivers/net/bna/bfa_wc.h
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Linux network driver for Brocade Converged Network Adapter.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License (GPL) Version 2 as
6 * published by the Free Software Foundation
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. See the GNU
11 * General Public License for more details.
12 */
13/*
14 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
15 * All rights reserved
16 * www.brocade.com
17 */
18
19/**
20 * @file bfa_wc.h Generic wait counter.
21 */
22
23#ifndef __BFA_WC_H__
24#define __BFA_WC_H__
25
26typedef void (*bfa_wc_resume_t) (void *cbarg);
27
28struct bfa_wc {
29 bfa_wc_resume_t wc_resume;
30 void *wc_cbarg;
31 int wc_count;
32};
33
34static inline void
35bfa_wc_up(struct bfa_wc *wc)
36{
37 wc->wc_count++;
38}
39
40static inline void
41bfa_wc_down(struct bfa_wc *wc)
42{
43 wc->wc_count--;
44 if (wc->wc_count == 0)
45 wc->wc_resume(wc->wc_cbarg);
46}
47
48/**
49 * Initialize a waiting counter.
50 */
51static inline void
52bfa_wc_init(struct bfa_wc *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
53{
54 wc->wc_resume = wc_resume;
55 wc->wc_cbarg = wc_cbarg;
56 wc->wc_count = 0;
57 bfa_wc_up(wc);
58}
59
60/**
61 * Wait for counter to reach zero
62 */
63static inline void
64bfa_wc_wait(struct bfa_wc *wc)
65{
66 bfa_wc_down(wc);
67}
68
69#endif
diff --git a/drivers/net/bna/bfi.h b/drivers/net/bna/bfi.h
index 6050379526f7..088211c2724f 100644
--- a/drivers/net/bna/bfi.h
+++ b/drivers/net/bna/bfi.h
@@ -51,13 +51,13 @@ struct bfi_mhdr {
51}; 51};
52 52
53#define bfi_h2i_set(_mh, _mc, _op, _lpuid) do { \ 53#define bfi_h2i_set(_mh, _mc, _op, _lpuid) do { \
54 (_mh).msg_class = (_mc); \ 54 (_mh).msg_class = (_mc); \
55 (_mh).msg_id = (_op); \ 55 (_mh).msg_id = (_op); \
56 (_mh).mtag.h2i.lpu_id = (_lpuid); \ 56 (_mh).mtag.h2i.lpu_id = (_lpuid); \
57} while (0) 57} while (0)
58 58
59#define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \ 59#define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \
60 (_mh).msg_class = (_mc); \ 60 (_mh).msg_class = (_mc); \
61 (_mh).msg_id = (_op); \ 61 (_mh).msg_id = (_op); \
62 (_mh).mtag.i2htok = (_i2htok); \ 62 (_mh).mtag.i2htok = (_i2htok); \
63} while (0) 63} while (0)
@@ -66,7 +66,7 @@ struct bfi_mhdr {
66 * Message opcodes: 0-127 to firmware, 128-255 to host 66 * Message opcodes: 0-127 to firmware, 128-255 to host
67 */ 67 */
68#define BFI_I2H_OPCODE_BASE 128 68#define BFI_I2H_OPCODE_BASE 128
69#define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE) 69#define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
70 70
71/** 71/**
72 **************************************************************************** 72 ****************************************************************************
@@ -186,7 +186,7 @@ enum bfi_mclass {
186#define BFI_BOOT_TYPE_OFF 8 186#define BFI_BOOT_TYPE_OFF 8
187#define BFI_BOOT_LOADER_OFF 12 187#define BFI_BOOT_LOADER_OFF 12
188 188
189#define BFI_BOOT_TYPE_NORMAL 0 189#define BFI_BOOT_TYPE_NORMAL 0
190#define BFI_BOOT_TYPE_FLASH 1 190#define BFI_BOOT_TYPE_FLASH 1
191#define BFI_BOOT_TYPE_MEMTEST 2 191#define BFI_BOOT_TYPE_MEMTEST 2
192 192
@@ -211,9 +211,9 @@ enum bfi_ioc_h2i_msgs {
211 211
212enum bfi_ioc_i2h_msgs { 212enum bfi_ioc_i2h_msgs {
213 BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1), 213 BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
214 BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2), 214 BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
215 BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3), 215 BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
216 BFI_IOC_I2H_READY_EVENT = BFA_I2HM(4), 216 BFI_IOC_I2H_READY_EVENT = BFA_I2HM(4),
217 BFI_IOC_I2H_HBEAT = BFA_I2HM(5), 217 BFI_IOC_I2H_HBEAT = BFA_I2HM(5),
218}; 218};
219 219
@@ -289,6 +289,12 @@ struct bfi_ioc_image_hdr {
289 u32 md5sum[BFI_IOC_MD5SUM_SZ]; 289 u32 md5sum[BFI_IOC_MD5SUM_SZ];
290}; 290};
291 291
292enum bfi_fwboot_type {
293 BFI_FWBOOT_TYPE_NORMAL = 0,
294 BFI_FWBOOT_TYPE_FLASH = 1,
295 BFI_FWBOOT_TYPE_MEMTEST = 2,
296};
297
292/** 298/**
293 * BFI_IOC_I2H_READY_EVENT message 299 * BFI_IOC_I2H_READY_EVENT message
294 */ 300 */
diff --git a/drivers/net/bna/bna.h b/drivers/net/bna/bna.h
index a287f89b0289..21e9155d6e56 100644
--- a/drivers/net/bna/bna.h
+++ b/drivers/net/bna/bna.h
@@ -13,7 +13,7 @@
13#ifndef __BNA_H__ 13#ifndef __BNA_H__
14#define __BNA_H__ 14#define __BNA_H__
15 15
16#include "bfa_wc.h" 16#include "bfa_cs.h"
17#include "bfa_ioc.h" 17#include "bfa_ioc.h"
18#include "cna.h" 18#include "cna.h"
19#include "bfi_ll.h" 19#include "bfi_ll.h"
@@ -88,7 +88,7 @@ do { \
88} while (0) 88} while (0)
89 89
90#define containing_rec(addr, type, field) \ 90#define containing_rec(addr, type, field) \
91 ((type *)((unsigned char *)(addr) - \ 91 ((type *)((unsigned char *)(addr) - \
92 (unsigned char *)(&((type *)0)->field))) 92 (unsigned char *)(&((type *)0)->field)))
93 93
94#define BNA_TXQ_WI_NEEDED(_vectors) (((_vectors) + 3) >> 2) 94#define BNA_TXQ_WI_NEEDED(_vectors) (((_vectors) + 3) >> 2)
@@ -101,8 +101,8 @@ do { \
101{ \ 101{ \
102 unsigned int page_index; /* index within a page */ \ 102 unsigned int page_index; /* index within a page */ \
103 void *page_addr; \ 103 void *page_addr; \
104 page_index = (_qe_idx) & (BNA_TXQ_PAGE_INDEX_MAX - 1); \ 104 page_index = (_qe_idx) & (BNA_TXQ_PAGE_INDEX_MAX - 1); \
105 (_qe_ptr_range) = (BNA_TXQ_PAGE_INDEX_MAX - page_index); \ 105 (_qe_ptr_range) = (BNA_TXQ_PAGE_INDEX_MAX - page_index); \
106 page_addr = (_qpt_ptr)[((_qe_idx) >> BNA_TXQ_PAGE_INDEX_MAX_SHIFT)];\ 106 page_addr = (_qpt_ptr)[((_qe_idx) >> BNA_TXQ_PAGE_INDEX_MAX_SHIFT)];\
107 (_qe_ptr) = &((struct bna_txq_entry *)(page_addr))[page_index]; \ 107 (_qe_ptr) = &((struct bna_txq_entry *)(page_addr))[page_index]; \
108} 108}
@@ -166,25 +166,25 @@ do { \
166 (((_q_ptr)->q.producer_index + (_num)) & \ 166 (((_q_ptr)->q.producer_index + (_num)) & \
167 ((_q_ptr)->q.q_depth - 1)) 167 ((_q_ptr)->q.q_depth - 1))
168 168
169#define BNA_Q_CI_ADD(_q_ptr, _num) \ 169#define BNA_Q_CI_ADD(_q_ptr, _num) \
170 (_q_ptr)->q.consumer_index = \ 170 (_q_ptr)->q.consumer_index = \
171 (((_q_ptr)->q.consumer_index + (_num)) \ 171 (((_q_ptr)->q.consumer_index + (_num)) \
172 & ((_q_ptr)->q.q_depth - 1)) 172 & ((_q_ptr)->q.q_depth - 1))
173 173
174#define BNA_Q_FREE_COUNT(_q_ptr) \ 174#define BNA_Q_FREE_COUNT(_q_ptr) \
175 (BNA_QE_FREE_CNT(&((_q_ptr)->q), (_q_ptr)->q.q_depth)) 175 (BNA_QE_FREE_CNT(&((_q_ptr)->q), (_q_ptr)->q.q_depth))
176 176
177#define BNA_Q_IN_USE_COUNT(_q_ptr) \ 177#define BNA_Q_IN_USE_COUNT(_q_ptr) \
178 (BNA_QE_IN_USE_CNT(&(_q_ptr)->q, (_q_ptr)->q.q_depth)) 178 (BNA_QE_IN_USE_CNT(&(_q_ptr)->q, (_q_ptr)->q.q_depth))
179 179
180/* These macros build the data portion of the TxQ/RxQ doorbell */ 180/* These macros build the data portion of the TxQ/RxQ doorbell */
181#define BNA_DOORBELL_Q_PRD_IDX(_pi) (0x80000000 | (_pi)) 181#define BNA_DOORBELL_Q_PRD_IDX(_pi) (0x80000000 | (_pi))
182#define BNA_DOORBELL_Q_STOP (0x40000000) 182#define BNA_DOORBELL_Q_STOP (0x40000000)
183 183
184/* These macros build the data portion of the IB doorbell */ 184/* These macros build the data portion of the IB doorbell */
185#define BNA_DOORBELL_IB_INT_ACK(_timeout, _events) \ 185#define BNA_DOORBELL_IB_INT_ACK(_timeout, _events) \
186 (0x80000000 | ((_timeout) << 16) | (_events)) 186 (0x80000000 | ((_timeout) << 16) | (_events))
187#define BNA_DOORBELL_IB_INT_DISABLE (0x40000000) 187#define BNA_DOORBELL_IB_INT_DISABLE (0x40000000)
188 188
189/* Set the coalescing timer for the given ib */ 189/* Set the coalescing timer for the given ib */
190#define bna_ib_coalescing_timer_set(_i_dbell, _cls_timer) \ 190#define bna_ib_coalescing_timer_set(_i_dbell, _cls_timer) \
diff --git a/drivers/net/bna/bna_ctrl.c b/drivers/net/bna/bna_ctrl.c
index 53b14169e363..cb2594c564dc 100644
--- a/drivers/net/bna/bna_ctrl.c
+++ b/drivers/net/bna/bna_ctrl.c
@@ -16,8 +16,7 @@
16 * www.brocade.com 16 * www.brocade.com
17 */ 17 */
18#include "bna.h" 18#include "bna.h"
19#include "bfa_sm.h" 19#include "bfa_cs.h"
20#include "bfa_wc.h"
21 20
22static void bna_device_cb_port_stopped(void *arg, enum bna_cb_status status); 21static void bna_device_cb_port_stopped(void *arg, enum bna_cb_status status);
23 22
@@ -380,7 +379,7 @@ bna_llport_sm_stopped(struct bna_llport *llport,
380 break; 379 break;
381 380
382 default: 381 default:
383 bfa_sm_fault(llport->bna, event); 382 bfa_sm_fault(event);
384 } 383 }
385} 384}
386 385
@@ -409,7 +408,7 @@ bna_llport_sm_down(struct bna_llport *llport,
409 break; 408 break;
410 409
411 default: 410 default:
412 bfa_sm_fault(llport->bna, event); 411 bfa_sm_fault(event);
413 } 412 }
414} 413}
415 414
@@ -455,7 +454,7 @@ bna_llport_sm_up_resp_wait(struct bna_llport *llport,
455 break; 454 break;
456 455
457 default: 456 default:
458 bfa_sm_fault(llport->bna, event); 457 bfa_sm_fault(event);
459 } 458 }
460} 459}
461 460
@@ -497,7 +496,7 @@ bna_llport_sm_down_resp_wait(struct bna_llport *llport,
497 break; 496 break;
498 497
499 default: 498 default:
500 bfa_sm_fault(llport->bna, event); 499 bfa_sm_fault(event);
501 } 500 }
502} 501}
503 502
@@ -526,7 +525,7 @@ bna_llport_sm_up(struct bna_llport *llport,
526 break; 525 break;
527 526
528 default: 527 default:
529 bfa_sm_fault(llport->bna, event); 528 bfa_sm_fault(event);
530 } 529 }
531} 530}
532 531
@@ -563,7 +562,7 @@ bna_llport_sm_last_resp_wait(struct bna_llport *llport,
563 break; 562 break;
564 563
565 default: 564 default:
566 bfa_sm_fault(llport->bna, event); 565 bfa_sm_fault(event);
567 } 566 }
568} 567}
569 568
@@ -916,7 +915,7 @@ bna_port_sm_stopped(struct bna_port *port, enum bna_port_event event)
916 break; 915 break;
917 916
918 default: 917 default:
919 bfa_sm_fault(port->bna, event); 918 bfa_sm_fault(event);
920 } 919 }
921} 920}
922 921
@@ -956,7 +955,7 @@ bna_port_sm_mtu_init_wait(struct bna_port *port, enum bna_port_event event)
956 break; 955 break;
957 956
958 default: 957 default:
959 bfa_sm_fault(port->bna, event); 958 bfa_sm_fault(event);
960 } 959 }
961} 960}
962 961
@@ -1001,7 +1000,7 @@ bna_port_sm_pause_init_wait(struct bna_port *port,
1001 break; 1000 break;
1002 1001
1003 default: 1002 default:
1004 bfa_sm_fault(port->bna, event); 1003 bfa_sm_fault(event);
1005 } 1004 }
1006} 1005}
1007 1006
@@ -1022,7 +1021,7 @@ bna_port_sm_last_resp_wait(struct bna_port *port,
1022 break; 1021 break;
1023 1022
1024 default: 1023 default:
1025 bfa_sm_fault(port->bna, event); 1024 bfa_sm_fault(event);
1026 } 1025 }
1027} 1026}
1028 1027
@@ -1061,7 +1060,7 @@ bna_port_sm_started(struct bna_port *port,
1061 break; 1060 break;
1062 1061
1063 default: 1062 default:
1064 bfa_sm_fault(port->bna, event); 1063 bfa_sm_fault(event);
1065 } 1064 }
1066} 1065}
1067 1066
@@ -1086,7 +1085,7 @@ bna_port_sm_pause_cfg_wait(struct bna_port *port,
1086 break; 1085 break;
1087 1086
1088 default: 1087 default:
1089 bfa_sm_fault(port->bna, event); 1088 bfa_sm_fault(event);
1090 } 1089 }
1091} 1090}
1092 1091
@@ -1111,7 +1110,7 @@ bna_port_sm_rx_stop_wait(struct bna_port *port,
1111 break; 1110 break;
1112 1111
1113 default: 1112 default:
1114 bfa_sm_fault(port->bna, event); 1113 bfa_sm_fault(event);
1115 } 1114 }
1116} 1115}
1117 1116
@@ -1136,7 +1135,7 @@ bna_port_sm_mtu_cfg_wait(struct bna_port *port, enum bna_port_event event)
1136 break; 1135 break;
1137 1136
1138 default: 1137 default:
1139 bfa_sm_fault(port->bna, event); 1138 bfa_sm_fault(event);
1140 } 1139 }
1141} 1140}
1142 1141
@@ -1161,7 +1160,7 @@ bna_port_sm_chld_stop_wait(struct bna_port *port,
1161 break; 1160 break;
1162 1161
1163 default: 1162 default:
1164 bfa_sm_fault(port->bna, event); 1163 bfa_sm_fault(event);
1165 } 1164 }
1166} 1165}
1167 1166
@@ -1472,7 +1471,7 @@ bna_device_sm_stopped(struct bna_device *device,
1472 break; 1471 break;
1473 1472
1474 default: 1473 default:
1475 bfa_sm_fault(device->bna, event); 1474 bfa_sm_fault(event);
1476 } 1475 }
1477} 1476}
1478 1477
@@ -1512,7 +1511,7 @@ bna_device_sm_ioc_ready_wait(struct bna_device *device,
1512 break; 1511 break;
1513 1512
1514 default: 1513 default:
1515 bfa_sm_fault(device->bna, event); 1514 bfa_sm_fault(event);
1516 } 1515 }
1517} 1516}
1518 1517
@@ -1542,7 +1541,7 @@ bna_device_sm_ready(struct bna_device *device, enum bna_device_event event)
1542 break; 1541 break;
1543 1542
1544 default: 1543 default:
1545 bfa_sm_fault(device->bna, event); 1544 bfa_sm_fault(event);
1546 } 1545 }
1547} 1546}
1548 1547
@@ -1568,7 +1567,7 @@ bna_device_sm_port_stop_wait(struct bna_device *device,
1568 break; 1567 break;
1569 1568
1570 default: 1569 default:
1571 bfa_sm_fault(device->bna, event); 1570 bfa_sm_fault(event);
1572 } 1571 }
1573} 1572}
1574 1573
@@ -1589,7 +1588,7 @@ bna_device_sm_ioc_disable_wait(struct bna_device *device,
1589 break; 1588 break;
1590 1589
1591 default: 1590 default:
1592 bfa_sm_fault(device->bna, event); 1591 bfa_sm_fault(event);
1593 } 1592 }
1594} 1593}
1595 1594
@@ -1622,7 +1621,7 @@ bna_device_sm_failed(struct bna_device *device,
1622 break; 1621 break;
1623 1622
1624 default: 1623 default:
1625 bfa_sm_fault(device->bna, event); 1624 bfa_sm_fault(event);
1626 } 1625 }
1627} 1626}
1628 1627
diff --git a/drivers/net/bna/bna_hw.h b/drivers/net/bna/bna_hw.h
index 6cb89692f5c1..cad233da843a 100644
--- a/drivers/net/bna/bna_hw.h
+++ b/drivers/net/bna/bna_hw.h
@@ -67,7 +67,7 @@ static struct bna_ibidx_pool name[BFI_IBIDX_TOTAL_POOLS] = \
67 67
68/** 68/**
69 * There are 2 free RIT segment pools: 69 * There are 2 free RIT segment pools:
70 * Pool1: 192 segments of 1 RIT entry each 70 * Pool1: 192 segments of 1 RIT entry each
71 * Pool2: 1 segment of 64 RIT entry 71 * Pool2: 1 segment of 64 RIT entry
72 */ 72 */
73#define BFI_RIT_SEG_POOL1_SIZE 192 73#define BFI_RIT_SEG_POOL1_SIZE 192
@@ -357,14 +357,14 @@ static struct bna_ritseg_pool_cfg name[BFI_RIT_SEG_TOTAL_POOLS] = \
357 * To clear set the value to 0. 357 * To clear set the value to 0.
358 * Range : 0x20 to 0x5c 358 * Range : 0x20 to 0x5c
359 */ 359 */
360#define PSS_SEM_LOCK_REG(_num) \ 360#define PSS_SEM_LOCK_REG(_num) \
361 (PSS_BLK_REG_ADDR + 0x020 + ((_num) << 2)) 361 (PSS_BLK_REG_ADDR + 0x020 + ((_num) << 2))
362 362
363/** 363/**
364 * PSS Semaphore Status Registers, 364 * PSS Semaphore Status Registers,
365 * corresponding to the lock registers above 365 * corresponding to the lock registers above
366 */ 366 */
367#define PSS_SEM_STATUS_REG(_num) \ 367#define PSS_SEM_STATUS_REG(_num) \
368 (PSS_BLK_REG_ADDR + 0x060 + ((_num) << 2)) 368 (PSS_BLK_REG_ADDR + 0x060 + ((_num) << 2))
369 369
370/** 370/**
@@ -1044,7 +1044,7 @@ static struct bna_ritseg_pool_cfg name[BFI_RIT_SEG_TOTAL_POOLS] = \
1044 __LPU12HOST_MBOX1_STATUS_BITS)) 1044 __LPU12HOST_MBOX1_STATUS_BITS))
1045 1045
1046#define BNA_IS_MBOX_INTR(_intr_status) \ 1046#define BNA_IS_MBOX_INTR(_intr_status) \
1047 ((_intr_status) & \ 1047 ((_intr_status) & \
1048 (__LPU02HOST_MBOX0_STATUS_BITS | \ 1048 (__LPU02HOST_MBOX0_STATUS_BITS | \
1049 __LPU02HOST_MBOX1_STATUS_BITS | \ 1049 __LPU02HOST_MBOX1_STATUS_BITS | \
1050 __LPU12HOST_MBOX0_STATUS_BITS | \ 1050 __LPU12HOST_MBOX0_STATUS_BITS | \
@@ -1070,11 +1070,11 @@ static struct bna_ritseg_pool_cfg name[BFI_RIT_SEG_TOTAL_POOLS] = \
1070 __HALT_MASK_BITS) 1070 __HALT_MASK_BITS)
1071 1071
1072#define BNA_IS_ERR_INTR(_intr_status) \ 1072#define BNA_IS_ERR_INTR(_intr_status) \
1073 ((_intr_status) & \ 1073 ((_intr_status) & \
1074 (__EMC_ERROR_STATUS_BITS | \ 1074 (__EMC_ERROR_STATUS_BITS | \
1075 __LPU0_ERROR_STATUS_BITS | \ 1075 __LPU0_ERROR_STATUS_BITS | \
1076 __LPU1_ERROR_STATUS_BITS | \ 1076 __LPU1_ERROR_STATUS_BITS | \
1077 __PSS_ERROR_STATUS_BITS | \ 1077 __PSS_ERROR_STATUS_BITS | \
1078 __HALT_STATUS_BITS)) 1078 __HALT_STATUS_BITS))
1079 1079
1080#define BNA_IS_MBOX_ERR_INTR(_intr_status) \ 1080#define BNA_IS_MBOX_ERR_INTR(_intr_status) \
@@ -1087,9 +1087,9 @@ static struct bna_ritseg_pool_cfg name[BFI_RIT_SEG_TOTAL_POOLS] = \
1087#define BNA_INTR_STATUS_MBOX_CLR(_intr_status) \ 1087#define BNA_INTR_STATUS_MBOX_CLR(_intr_status) \
1088do { \ 1088do { \
1089 (_intr_status) &= ~(__LPU02HOST_MBOX0_STATUS_BITS | \ 1089 (_intr_status) &= ~(__LPU02HOST_MBOX0_STATUS_BITS | \
1090 __LPU02HOST_MBOX1_STATUS_BITS | \ 1090 __LPU02HOST_MBOX1_STATUS_BITS | \
1091 __LPU12HOST_MBOX0_STATUS_BITS | \ 1091 __LPU12HOST_MBOX0_STATUS_BITS | \
1092 __LPU12HOST_MBOX1_STATUS_BITS); \ 1092 __LPU12HOST_MBOX1_STATUS_BITS); \
1093} while (0) 1093} while (0)
1094 1094
1095#define BNA_INTR_STATUS_ERR_CLR(_intr_status) \ 1095#define BNA_INTR_STATUS_ERR_CLR(_intr_status) \
@@ -1107,7 +1107,7 @@ do { \
1107 writel(0xffffffff, (_bna)->regs.fn_int_mask);\ 1107 writel(0xffffffff, (_bna)->regs.fn_int_mask);\
1108} 1108}
1109 1109
1110#define bna_intx_enable(bna, new_mask) \ 1110#define bna_intx_enable(bna, new_mask) \
1111 writel((new_mask), (bna)->regs.fn_int_mask) 1111 writel((new_mask), (bna)->regs.fn_int_mask)
1112 1112
1113#define bna_mbox_intr_disable(bna) \ 1113#define bna_mbox_intr_disable(bna) \
@@ -1179,18 +1179,18 @@ do {\
1179#define BNA_DOORBELL_IB_INT_DISABLE (0x40000000) 1179#define BNA_DOORBELL_IB_INT_DISABLE (0x40000000)
1180 1180
1181/* TxQ Entry Opcodes */ 1181/* TxQ Entry Opcodes */
1182#define BNA_TXQ_WI_SEND (0x402) /* Single Frame Transmission */ 1182#define BNA_TXQ_WI_SEND (0x402) /* Single Frame Transmission */
1183#define BNA_TXQ_WI_SEND_LSO (0x403) /* Multi-Frame Transmission */ 1183#define BNA_TXQ_WI_SEND_LSO (0x403) /* Multi-Frame Transmission */
1184#define BNA_TXQ_WI_EXTENSION (0x104) /* Extension WI */ 1184#define BNA_TXQ_WI_EXTENSION (0x104) /* Extension WI */
1185 1185
1186/* TxQ Entry Control Flags */ 1186/* TxQ Entry Control Flags */
1187#define BNA_TXQ_WI_CF_FCOE_CRC (1 << 8) 1187#define BNA_TXQ_WI_CF_FCOE_CRC (1 << 8)
1188#define BNA_TXQ_WI_CF_IPID_MODE (1 << 5) 1188#define BNA_TXQ_WI_CF_IPID_MODE (1 << 5)
1189#define BNA_TXQ_WI_CF_INS_PRIO (1 << 4) 1189#define BNA_TXQ_WI_CF_INS_PRIO (1 << 4)
1190#define BNA_TXQ_WI_CF_INS_VLAN (1 << 3) 1190#define BNA_TXQ_WI_CF_INS_VLAN (1 << 3)
1191#define BNA_TXQ_WI_CF_UDP_CKSUM (1 << 2) 1191#define BNA_TXQ_WI_CF_UDP_CKSUM (1 << 2)
1192#define BNA_TXQ_WI_CF_TCP_CKSUM (1 << 1) 1192#define BNA_TXQ_WI_CF_TCP_CKSUM (1 << 1)
1193#define BNA_TXQ_WI_CF_IP_CKSUM (1 << 0) 1193#define BNA_TXQ_WI_CF_IP_CKSUM (1 << 0)
1194 1194
1195#define BNA_TXQ_WI_L4_HDR_N_OFFSET(_hdr_size, _offset) \ 1195#define BNA_TXQ_WI_L4_HDR_N_OFFSET(_hdr_size, _offset) \
1196 (((_hdr_size) << 10) | ((_offset) & 0x3FF)) 1196 (((_hdr_size) << 10) | ((_offset) & 0x3FF))
@@ -1199,30 +1199,30 @@ do {\
1199 * Completion Q defines 1199 * Completion Q defines
1200 */ 1200 */
1201/* CQ Entry Flags */ 1201/* CQ Entry Flags */
1202#define BNA_CQ_EF_MAC_ERROR (1 << 0) 1202#define BNA_CQ_EF_MAC_ERROR (1 << 0)
1203#define BNA_CQ_EF_FCS_ERROR (1 << 1) 1203#define BNA_CQ_EF_FCS_ERROR (1 << 1)
1204#define BNA_CQ_EF_TOO_LONG (1 << 2) 1204#define BNA_CQ_EF_TOO_LONG (1 << 2)
1205#define BNA_CQ_EF_FC_CRC_OK (1 << 3) 1205#define BNA_CQ_EF_FC_CRC_OK (1 << 3)
1206 1206
1207#define BNA_CQ_EF_RSVD1 (1 << 4) 1207#define BNA_CQ_EF_RSVD1 (1 << 4)
1208#define BNA_CQ_EF_L4_CKSUM_OK (1 << 5) 1208#define BNA_CQ_EF_L4_CKSUM_OK (1 << 5)
1209#define BNA_CQ_EF_L3_CKSUM_OK (1 << 6) 1209#define BNA_CQ_EF_L3_CKSUM_OK (1 << 6)
1210#define BNA_CQ_EF_HDS_HEADER (1 << 7) 1210#define BNA_CQ_EF_HDS_HEADER (1 << 7)
1211 1211
1212#define BNA_CQ_EF_UDP (1 << 8) 1212#define BNA_CQ_EF_UDP (1 << 8)
1213#define BNA_CQ_EF_TCP (1 << 9) 1213#define BNA_CQ_EF_TCP (1 << 9)
1214#define BNA_CQ_EF_IP_OPTIONS (1 << 10) 1214#define BNA_CQ_EF_IP_OPTIONS (1 << 10)
1215#define BNA_CQ_EF_IPV6 (1 << 11) 1215#define BNA_CQ_EF_IPV6 (1 << 11)
1216 1216
1217#define BNA_CQ_EF_IPV4 (1 << 12) 1217#define BNA_CQ_EF_IPV4 (1 << 12)
1218#define BNA_CQ_EF_VLAN (1 << 13) 1218#define BNA_CQ_EF_VLAN (1 << 13)
1219#define BNA_CQ_EF_RSS (1 << 14) 1219#define BNA_CQ_EF_RSS (1 << 14)
1220#define BNA_CQ_EF_RSVD2 (1 << 15) 1220#define BNA_CQ_EF_RSVD2 (1 << 15)
1221 1221
1222#define BNA_CQ_EF_MCAST_MATCH (1 << 16) 1222#define BNA_CQ_EF_MCAST_MATCH (1 << 16)
1223#define BNA_CQ_EF_MCAST (1 << 17) 1223#define BNA_CQ_EF_MCAST (1 << 17)
1224#define BNA_CQ_EF_BCAST (1 << 18) 1224#define BNA_CQ_EF_BCAST (1 << 18)
1225#define BNA_CQ_EF_REMOTE (1 << 19) 1225#define BNA_CQ_EF_REMOTE (1 << 19)
1226 1226
1227#define BNA_CQ_EF_LOCAL (1 << 20) 1227#define BNA_CQ_EF_LOCAL (1 << 20)
1228 1228
@@ -1257,10 +1257,10 @@ enum ib_flags {
1257}; 1257};
1258 1258
1259enum rss_hash_type { 1259enum rss_hash_type {
1260 BFI_RSS_T_V4_TCP = (1 << 11), 1260 BFI_RSS_T_V4_TCP = (1 << 11),
1261 BFI_RSS_T_V4_IP = (1 << 10), 1261 BFI_RSS_T_V4_IP = (1 << 10),
1262 BFI_RSS_T_V6_TCP = (1 << 9), 1262 BFI_RSS_T_V6_TCP = (1 << 9),
1263 BFI_RSS_T_V6_IP = (1 << 8) 1263 BFI_RSS_T_V6_IP = (1 << 8)
1264}; 1264};
1265enum hds_header_type { 1265enum hds_header_type {
1266 BNA_HDS_T_V4_TCP = (1 << 11), 1266 BNA_HDS_T_V4_TCP = (1 << 11),
@@ -1298,7 +1298,7 @@ struct bna_txq_mem {
1298 u32 reserved2; 1298 u32 reserved2;
1299 u32 pg_cnt_n_prd_ptr; /* 31:16->total page count */ 1299 u32 pg_cnt_n_prd_ptr; /* 31:16->total page count */
1300 /* 15:0 ->producer pointer (index?) */ 1300 /* 15:0 ->producer pointer (index?) */
1301 u32 entry_n_pg_size; /* 31:16->entry size */ 1301 u32 entry_n_pg_size; /* 31:16->entry size */
1302 /* 15:0 ->page size */ 1302 /* 15:0 ->page size */
1303 u32 int_blk_n_cns_ptr; /* 31:24->Int Blk Id; */ 1303 u32 int_blk_n_cns_ptr; /* 31:24->Int Blk Id; */
1304 /* 23:16->Int Blk Offset */ 1304 /* 23:16->Int Blk Offset */
@@ -1326,7 +1326,7 @@ struct bna_rxq_mem {
1326 u32 sg_n_cq_n_cns_ptr; /* 31:28->reserved; 27:24->sg count */ 1326 u32 sg_n_cq_n_cns_ptr; /* 31:28->reserved; 27:24->sg count */
1327 /* 23:16->CQ; */ 1327 /* 23:16->CQ; */
1328 /* 15:0->consumer pointer(index?) */ 1328 /* 15:0->consumer pointer(index?) */
1329 u32 buf_sz_n_q_state; /* 31:16->buffer size; 15:0-> Q state */ 1329 u32 buf_sz_n_q_state; /* 31:16->buffer size; 15:0-> Q state */
1330 u32 next_qid; /* 17:10->next QId */ 1330 u32 next_qid; /* 17:10->next QId */
1331 u32 reserved3; 1331 u32 reserved3;
1332 u32 reserved4[4]; 1332 u32 reserved4[4];
@@ -1426,8 +1426,8 @@ struct bna_dma_addr {
1426}; 1426};
1427 1427
1428struct bna_txq_wi_vector { 1428struct bna_txq_wi_vector {
1429 u16 reserved; 1429 u16 reserved;
1430 u16 length; /* Only 14 LSB are valid */ 1430 u16 length; /* Only 14 LSB are valid */
1431 struct bna_dma_addr host_addr; /* Tx-Buf DMA addr */ 1431 struct bna_dma_addr host_addr; /* Tx-Buf DMA addr */
1432}; 1432};
1433 1433
@@ -1465,7 +1465,7 @@ struct bna_txq_entry {
1465 } hdr; 1465 } hdr;
1466 struct bna_txq_wi_vector vector[4]; 1466 struct bna_txq_wi_vector vector[4];
1467}; 1467};
1468#define wi_hdr hdr.wi 1468#define wi_hdr hdr.wi
1469#define wi_ext_hdr hdr.wi_ext 1469#define wi_ext_hdr hdr.wi_ext
1470 1470
1471/* RxQ Entry Structure */ 1471/* RxQ Entry Structure */
diff --git a/drivers/net/bna/bna_txrx.c b/drivers/net/bna/bna_txrx.c
index 380085cc3088..f0983c832447 100644
--- a/drivers/net/bna/bna_txrx.c
+++ b/drivers/net/bna/bna_txrx.c
@@ -16,7 +16,7 @@
16 * www.brocade.com 16 * www.brocade.com
17 */ 17 */
18#include "bna.h" 18#include "bna.h"
19#include "bfa_sm.h" 19#include "bfa_cs.h"
20#include "bfi.h" 20#include "bfi.h"
21 21
22/** 22/**
@@ -569,7 +569,7 @@ bna_rxf_sm_stopped(struct bna_rxf *rxf, enum bna_rxf_event event)
569 break; 569 break;
570 570
571 default: 571 default:
572 bfa_sm_fault(rxf->rx->bna, event); 572 bfa_sm_fault(event);
573 } 573 }
574} 574}
575 575
@@ -627,7 +627,7 @@ bna_rxf_sm_start_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
627 break; 627 break;
628 628
629 default: 629 default:
630 bfa_sm_fault(rxf->rx->bna, event); 630 bfa_sm_fault(event);
631 } 631 }
632} 632}
633 633
@@ -678,7 +678,7 @@ bna_rxf_sm_cam_fltr_mod_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
678 break; 678 break;
679 679
680 default: 680 default:
681 bfa_sm_fault(rxf->rx->bna, event); 681 bfa_sm_fault(event);
682 } 682 }
683} 683}
684 684
@@ -724,7 +724,7 @@ bna_rxf_sm_started(struct bna_rxf *rxf, enum bna_rxf_event event)
724 break; 724 break;
725 725
726 default: 726 default:
727 bfa_sm_fault(rxf->rx->bna, event); 727 bfa_sm_fault(event);
728 } 728 }
729} 729}
730 730
@@ -734,7 +734,7 @@ bna_rxf_sm_cam_fltr_clr_wait_entry(struct bna_rxf *rxf)
734 /** 734 /**
735 * Note: Do not add rxf_clear_packet_filter here. 735 * Note: Do not add rxf_clear_packet_filter here.
736 * It will overstep mbox when this transition happens: 736 * It will overstep mbox when this transition happens:
737 * cam_fltr_mod_wait -> cam_fltr_clr_wait on RXF_E_STOP event 737 * cam_fltr_mod_wait -> cam_fltr_clr_wait on RXF_E_STOP event
738 */ 738 */
739} 739}
740 740
@@ -761,7 +761,7 @@ bna_rxf_sm_cam_fltr_clr_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
761 break; 761 break;
762 762
763 default: 763 default:
764 bfa_sm_fault(rxf->rx->bna, event); 764 bfa_sm_fault(event);
765 } 765 }
766} 766}
767 767
@@ -771,7 +771,7 @@ bna_rxf_sm_stop_wait_entry(struct bna_rxf *rxf)
771 /** 771 /**
772 * NOTE: Do not add rxf_disable here. 772 * NOTE: Do not add rxf_disable here.
773 * It will overstep mbox when this transition happens: 773 * It will overstep mbox when this transition happens:
774 * start_wait -> stop_wait on RXF_E_STOP event 774 * start_wait -> stop_wait on RXF_E_STOP event
775 */ 775 */
776} 776}
777 777
@@ -815,7 +815,7 @@ bna_rxf_sm_stop_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
815 break; 815 break;
816 816
817 default: 817 default:
818 bfa_sm_fault(rxf->rx->bna, event); 818 bfa_sm_fault(event);
819 } 819 }
820} 820}
821 821
@@ -851,7 +851,7 @@ bna_rxf_sm_pause_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
851 * any other event during these states 851 * any other event during these states
852 */ 852 */
853 default: 853 default:
854 bfa_sm_fault(rxf->rx->bna, event); 854 bfa_sm_fault(event);
855 } 855 }
856} 856}
857 857
@@ -887,7 +887,7 @@ bna_rxf_sm_resume_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
887 * any other event during these states 887 * any other event during these states
888 */ 888 */
889 default: 889 default:
890 bfa_sm_fault(rxf->rx->bna, event); 890 bfa_sm_fault(event);
891 } 891 }
892} 892}
893 893
@@ -907,7 +907,7 @@ bna_rxf_sm_stat_clr_wait(struct bna_rxf *rxf, enum bna_rxf_event event)
907 break; 907 break;
908 908
909 default: 909 default:
910 bfa_sm_fault(rxf->rx->bna, event); 910 bfa_sm_fault(event);
911 } 911 }
912} 912}
913 913
@@ -1898,7 +1898,7 @@ static void bna_rx_sm_stopped(struct bna_rx *rx,
1898 /* no-op */ 1898 /* no-op */
1899 break; 1899 break;
1900 default: 1900 default:
1901 bfa_sm_fault(rx->bna, event); 1901 bfa_sm_fault(event);
1902 break; 1902 break;
1903 } 1903 }
1904 1904
@@ -1946,7 +1946,7 @@ static void bna_rx_sm_rxf_start_wait(struct bna_rx *rx,
1946 bfa_fsm_set_state(rx, bna_rx_sm_started); 1946 bfa_fsm_set_state(rx, bna_rx_sm_started);
1947 break; 1947 break;
1948 default: 1948 default:
1949 bfa_sm_fault(rx->bna, event); 1949 bfa_sm_fault(event);
1950 break; 1950 break;
1951 } 1951 }
1952} 1952}
@@ -1981,7 +1981,7 @@ bna_rx_sm_started(struct bna_rx *rx, enum bna_rx_event event)
1981 bfa_fsm_set_state(rx, bna_rx_sm_rxf_stop_wait); 1981 bfa_fsm_set_state(rx, bna_rx_sm_rxf_stop_wait);
1982 break; 1982 break;
1983 default: 1983 default:
1984 bfa_sm_fault(rx->bna, event); 1984 bfa_sm_fault(event);
1985 break; 1985 break;
1986 } 1986 }
1987} 1987}
@@ -2011,7 +2011,7 @@ bna_rx_sm_rxf_stop_wait(struct bna_rx *rx, enum bna_rx_event event)
2011 bna_rxf_fail(&rx->rxf); 2011 bna_rxf_fail(&rx->rxf);
2012 break; 2012 break;
2013 default: 2013 default:
2014 bfa_sm_fault(rx->bna, event); 2014 bfa_sm_fault(event);
2015 break; 2015 break;
2016 } 2016 }
2017 2017
@@ -2064,7 +2064,7 @@ bna_rx_sm_rxq_stop_wait(struct bna_rx *rx, enum bna_rx_event event)
2064 bfa_fsm_set_state(rx, bna_rx_sm_stopped); 2064 bfa_fsm_set_state(rx, bna_rx_sm_stopped);
2065 break; 2065 break;
2066 default: 2066 default:
2067 bfa_sm_fault(rx->bna, event); 2067 bfa_sm_fault(event);
2068 break; 2068 break;
2069 } 2069 }
2070} 2070}
@@ -3216,7 +3216,7 @@ bna_tx_sm_stopped(struct bna_tx *tx, enum bna_tx_event event)
3216 break; 3216 break;
3217 3217
3218 default: 3218 default:
3219 bfa_sm_fault(tx->bna, event); 3219 bfa_sm_fault(event);
3220 } 3220 }
3221} 3221}
3222 3222
@@ -3261,7 +3261,7 @@ bna_tx_sm_started(struct bna_tx *tx, enum bna_tx_event event)
3261 break; 3261 break;
3262 3262
3263 default: 3263 default:
3264 bfa_sm_fault(tx->bna, event); 3264 bfa_sm_fault(event);
3265 } 3265 }
3266} 3266}
3267 3267
@@ -3294,7 +3294,7 @@ bna_tx_sm_txq_stop_wait(struct bna_tx *tx, enum bna_tx_event event)
3294 break; 3294 break;
3295 3295
3296 default: 3296 default:
3297 bfa_sm_fault(tx->bna, event); 3297 bfa_sm_fault(event);
3298 } 3298 }
3299} 3299}
3300 3300
@@ -3335,7 +3335,7 @@ bna_tx_sm_prio_stop_wait(struct bna_tx *tx, enum bna_tx_event event)
3335 break; 3335 break;
3336 3336
3337 default: 3337 default:
3338 bfa_sm_fault(tx->bna, event); 3338 bfa_sm_fault(event);
3339 } 3339 }
3340} 3340}
3341 3341
@@ -3355,7 +3355,7 @@ bna_tx_sm_stat_clr_wait(struct bna_tx *tx, enum bna_tx_event event)
3355 break; 3355 break;
3356 3356
3357 default: 3357 default:
3358 bfa_sm_fault(tx->bna, event); 3358 bfa_sm_fault(event);
3359 } 3359 }
3360} 3360}
3361 3361
diff --git a/drivers/net/bna/bna_types.h b/drivers/net/bna/bna_types.h
index b9c134f7ad31..2f89cb235248 100644
--- a/drivers/net/bna/bna_types.h
+++ b/drivers/net/bna/bna_types.h
@@ -50,12 +50,12 @@ enum bna_status {
50}; 50};
51 51
52enum bna_cleanup_type { 52enum bna_cleanup_type {
53 BNA_HARD_CLEANUP = 0, 53 BNA_HARD_CLEANUP = 0,
54 BNA_SOFT_CLEANUP = 1 54 BNA_SOFT_CLEANUP = 1
55}; 55};
56 56
57enum bna_cb_status { 57enum bna_cb_status {
58 BNA_CB_SUCCESS = 0, 58 BNA_CB_SUCCESS = 0,
59 BNA_CB_FAIL = 1, 59 BNA_CB_FAIL = 1,
60 BNA_CB_INTERRUPT = 2, 60 BNA_CB_INTERRUPT = 2,
61 BNA_CB_BUSY = 3, 61 BNA_CB_BUSY = 3,
@@ -72,8 +72,8 @@ enum bna_res_type {
72}; 72};
73 73
74enum bna_mem_type { 74enum bna_mem_type {
75 BNA_MEM_T_KVA = 1, 75 BNA_MEM_T_KVA = 1,
76 BNA_MEM_T_DMA = 2 76 BNA_MEM_T_DMA = 2
77}; 77};
78 78
79enum bna_intr_type { 79enum bna_intr_type {
@@ -82,10 +82,10 @@ enum bna_intr_type {
82}; 82};
83 83
84enum bna_res_req_type { 84enum bna_res_req_type {
85 BNA_RES_MEM_T_COM = 0, 85 BNA_RES_MEM_T_COM = 0,
86 BNA_RES_MEM_T_ATTR = 1, 86 BNA_RES_MEM_T_ATTR = 1,
87 BNA_RES_MEM_T_FWTRC = 2, 87 BNA_RES_MEM_T_FWTRC = 2,
88 BNA_RES_MEM_T_STATS = 3, 88 BNA_RES_MEM_T_STATS = 3,
89 BNA_RES_MEM_T_SWSTATS = 4, 89 BNA_RES_MEM_T_SWSTATS = 4,
90 BNA_RES_MEM_T_IBIDX = 5, 90 BNA_RES_MEM_T_IBIDX = 5,
91 BNA_RES_MEM_T_IB_ARRAY = 6, 91 BNA_RES_MEM_T_IB_ARRAY = 6,
@@ -107,9 +107,9 @@ enum bna_res_req_type {
107enum bna_tx_res_req_type { 107enum bna_tx_res_req_type {
108 BNA_TX_RES_MEM_T_TCB = 0, 108 BNA_TX_RES_MEM_T_TCB = 0,
109 BNA_TX_RES_MEM_T_UNMAPQ = 1, 109 BNA_TX_RES_MEM_T_UNMAPQ = 1,
110 BNA_TX_RES_MEM_T_QPT = 2, 110 BNA_TX_RES_MEM_T_QPT = 2,
111 BNA_TX_RES_MEM_T_SWQPT = 3, 111 BNA_TX_RES_MEM_T_SWQPT = 3,
112 BNA_TX_RES_MEM_T_PAGE = 4, 112 BNA_TX_RES_MEM_T_PAGE = 4,
113 BNA_TX_RES_INTR_T_TXCMPL = 5, 113 BNA_TX_RES_INTR_T_TXCMPL = 5,
114 BNA_TX_RES_T_MAX, 114 BNA_TX_RES_T_MAX,
115}; 115};
@@ -158,14 +158,14 @@ enum bna_rx_type {
158}; 158};
159 159
160enum bna_rxp_type { 160enum bna_rxp_type {
161 BNA_RXP_SINGLE = 1, 161 BNA_RXP_SINGLE = 1,
162 BNA_RXP_SLR = 2, 162 BNA_RXP_SLR = 2,
163 BNA_RXP_HDS = 3 163 BNA_RXP_HDS = 3
164}; 164};
165 165
166enum bna_rxmode { 166enum bna_rxmode {
167 BNA_RXMODE_PROMISC = 1, 167 BNA_RXMODE_PROMISC = 1,
168 BNA_RXMODE_ALLMULTI = 2 168 BNA_RXMODE_ALLMULTI = 2
169}; 169};
170 170
171enum bna_rx_event { 171enum bna_rx_event {
@@ -202,7 +202,7 @@ enum bna_rxf_oper_state {
202}; 202};
203 203
204enum bna_rxf_flags { 204enum bna_rxf_flags {
205 BNA_RXF_FL_STOP_PENDING = 0x01, 205 BNA_RXF_FL_STOP_PENDING = 0x01,
206 BNA_RXF_FL_FAILED = 0x02, 206 BNA_RXF_FL_FAILED = 0x02,
207 BNA_RXF_FL_RSS_CONFIG_PENDING = 0x04, 207 BNA_RXF_FL_RSS_CONFIG_PENDING = 0x04,
208 BNA_RXF_FL_OPERSTATE_CHANGED = 0x08, 208 BNA_RXF_FL_OPERSTATE_CHANGED = 0x08,
@@ -244,11 +244,11 @@ enum bna_port_type {
244enum bna_link_status { 244enum bna_link_status {
245 BNA_LINK_DOWN = 0, 245 BNA_LINK_DOWN = 0,
246 BNA_LINK_UP = 1, 246 BNA_LINK_UP = 1,
247 BNA_CEE_UP = 2 247 BNA_CEE_UP = 2
248}; 248};
249 249
250enum bna_llport_flags { 250enum bna_llport_flags {
251 BNA_LLPORT_F_ADMIN_UP = 1, 251 BNA_LLPORT_F_ADMIN_UP = 1,
252 BNA_LLPORT_F_PORT_ENABLED = 2, 252 BNA_LLPORT_F_PORT_ENABLED = 2,
253 BNA_LLPORT_F_RX_STARTED = 4 253 BNA_LLPORT_F_RX_STARTED = 4
254}; 254};
@@ -304,7 +304,7 @@ struct bna_mem_descr {
304struct bna_mem_info { 304struct bna_mem_info {
305 enum bna_mem_type mem_type; 305 enum bna_mem_type mem_type;
306 u32 len; 306 u32 len;
307 u32 num; 307 u32 num;
308 u32 align_sz; /* 0/1 = no alignment */ 308 u32 align_sz; /* 0/1 = no alignment */
309 struct bna_mem_descr *mdl; 309 struct bna_mem_descr *mdl;
310 void *cookie; /* For bnad to unmap dma later */ 310 void *cookie; /* For bnad to unmap dma later */
@@ -371,10 +371,10 @@ struct bna_mbox_qe {
371 struct list_head qe; 371 struct list_head qe;
372 372
373 struct bfa_mbox_cmd cmd; 373 struct bfa_mbox_cmd cmd;
374 u32 cmd_len; 374 u32 cmd_len;
375 /* Callback for port, tx, rx, rxf */ 375 /* Callback for port, tx, rx, rxf */
376 void (*cbfn)(void *arg, int status); 376 void (*cbfn)(void *arg, int status);
377 void *cbarg; 377 void *cbarg;
378}; 378};
379 379
380struct bna_mbox_mod { 380struct bna_mbox_mod {
@@ -480,7 +480,7 @@ struct bna_ib_dbell {
480 480
481/* Interrupt timer configuration */ 481/* Interrupt timer configuration */
482struct bna_ib_config { 482struct bna_ib_config {
483 u8 coalescing_timeo; /* Unit is 5usec. */ 483 u8 coalescing_timeo; /* Unit is 5usec. */
484 484
485 int interpkt_count; 485 int interpkt_count;
486 int interpkt_timeo; 486 int interpkt_timeo;
@@ -576,8 +576,8 @@ struct bna_txq {
576 576
577 struct bna_tx *tx; 577 struct bna_tx *tx;
578 578
579 u64 tx_packets; 579 u64 tx_packets;
580 u64 tx_bytes; 580 u64 tx_bytes;
581}; 581};
582 582
583/* TxF structure (hardware Tx Function) */ 583/* TxF structure (hardware Tx Function) */
@@ -739,10 +739,10 @@ struct bna_rxq {
739 struct bna_rxp *rxp; 739 struct bna_rxp *rxp;
740 struct bna_rx *rx; 740 struct bna_rx *rx;
741 741
742 u64 rx_packets; 742 u64 rx_packets;
743 u64 rx_bytes; 743 u64 rx_bytes;
744 u64 rx_packets_with_error; 744 u64 rx_packets_with_error;
745 u64 rxbuf_alloc_failed; 745 u64 rxbuf_alloc_failed;
746}; 746};
747 747
748/* RxQ pair */ 748/* RxQ pair */
@@ -902,7 +902,7 @@ struct bna_rxf {
902 * callback for: 902 * callback for:
903 * bna_rxf_ucast_set() 903 * bna_rxf_ucast_set()
904 * bna_rxf_{ucast/mcast}_add(), 904 * bna_rxf_{ucast/mcast}_add(),
905 * bna_rxf_{ucast/mcast}_del(), 905 * bna_rxf_{ucast/mcast}_del(),
906 * bna_rxf_mode_set() 906 * bna_rxf_mode_set()
907 */ 907 */
908 void (*cam_fltr_cbfn)(struct bnad *bnad, struct bna_rx *rx, 908 void (*cam_fltr_cbfn)(struct bnad *bnad, struct bna_rx *rx,
diff --git a/drivers/net/bna/bnad.c b/drivers/net/bna/bnad.c
index c89c9b28cb7d..8e35b2596f93 100644
--- a/drivers/net/bna/bnad.c
+++ b/drivers/net/bna/bnad.c
@@ -25,7 +25,6 @@
25#include <linux/if_ether.h> 25#include <linux/if_ether.h>
26#include <linux/ip.h> 26#include <linux/ip.h>
27#include <linux/prefetch.h> 27#include <linux/prefetch.h>
28#include <linux/if_vlan.h>
29 28
30#include "bnad.h" 29#include "bnad.h"
31#include "bna.h" 30#include "bna.h"
@@ -60,7 +59,7 @@ static const u8 bnad_bcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
60 59
61#define BNAD_GET_MBOX_IRQ(_bnad) \ 60#define BNAD_GET_MBOX_IRQ(_bnad) \
62 (((_bnad)->cfg_flags & BNAD_CF_MSIX) ? \ 61 (((_bnad)->cfg_flags & BNAD_CF_MSIX) ? \
63 ((_bnad)->msix_table[(_bnad)->msix_num - 1].vector) : \ 62 ((_bnad)->msix_table[BNAD_MAILBOX_MSIX_INDEX].vector) : \
64 ((_bnad)->pcidev->irq)) 63 ((_bnad)->pcidev->irq))
65 64
66#define BNAD_FILL_UNMAPQ_MEM_REQ(_res_info, _num, _depth) \ 65#define BNAD_FILL_UNMAPQ_MEM_REQ(_res_info, _num, _depth) \
@@ -112,10 +111,10 @@ static void
112bnad_free_all_txbufs(struct bnad *bnad, 111bnad_free_all_txbufs(struct bnad *bnad,
113 struct bna_tcb *tcb) 112 struct bna_tcb *tcb)
114{ 113{
115 u32 unmap_cons; 114 u32 unmap_cons;
116 struct bnad_unmap_q *unmap_q = tcb->unmap_q; 115 struct bnad_unmap_q *unmap_q = tcb->unmap_q;
117 struct bnad_skb_unmap *unmap_array; 116 struct bnad_skb_unmap *unmap_array;
118 struct sk_buff *skb = NULL; 117 struct sk_buff *skb = NULL;
119 int i; 118 int i;
120 119
121 unmap_array = unmap_q->unmap_array; 120 unmap_array = unmap_q->unmap_array;
@@ -165,11 +164,11 @@ static u32
165bnad_free_txbufs(struct bnad *bnad, 164bnad_free_txbufs(struct bnad *bnad,
166 struct bna_tcb *tcb) 165 struct bna_tcb *tcb)
167{ 166{
168 u32 sent_packets = 0, sent_bytes = 0; 167 u32 sent_packets = 0, sent_bytes = 0;
169 u16 wis, unmap_cons, updated_hw_cons; 168 u16 wis, unmap_cons, updated_hw_cons;
170 struct bnad_unmap_q *unmap_q = tcb->unmap_q; 169 struct bnad_unmap_q *unmap_q = tcb->unmap_q;
171 struct bnad_skb_unmap *unmap_array; 170 struct bnad_skb_unmap *unmap_array;
172 struct sk_buff *skb; 171 struct sk_buff *skb;
173 int i; 172 int i;
174 173
175 /* 174 /*
@@ -247,7 +246,7 @@ bnad_tx_free_tasklet(unsigned long bnad_ptr)
247{ 246{
248 struct bnad *bnad = (struct bnad *)bnad_ptr; 247 struct bnad *bnad = (struct bnad *)bnad_ptr;
249 struct bna_tcb *tcb; 248 struct bna_tcb *tcb;
250 u32 acked = 0; 249 u32 acked = 0;
251 int i, j; 250 int i, j;
252 251
253 for (i = 0; i < bnad->num_tx; i++) { 252 for (i = 0; i < bnad->num_tx; i++) {
@@ -1102,10 +1101,10 @@ static int
1102bnad_mbox_irq_alloc(struct bnad *bnad, 1101bnad_mbox_irq_alloc(struct bnad *bnad,
1103 struct bna_intr_info *intr_info) 1102 struct bna_intr_info *intr_info)
1104{ 1103{
1105 int err = 0; 1104 int err = 0;
1106 unsigned long irq_flags, flags; 1105 unsigned long irq_flags, flags;
1107 u32 irq; 1106 u32 irq;
1108 irq_handler_t irq_handler; 1107 irq_handler_t irq_handler;
1109 1108
1110 /* Mbox should use only 1 vector */ 1109 /* Mbox should use only 1 vector */
1111 1110
@@ -1116,17 +1115,17 @@ bnad_mbox_irq_alloc(struct bnad *bnad,
1116 spin_lock_irqsave(&bnad->bna_lock, flags); 1115 spin_lock_irqsave(&bnad->bna_lock, flags);
1117 if (bnad->cfg_flags & BNAD_CF_MSIX) { 1116 if (bnad->cfg_flags & BNAD_CF_MSIX) {
1118 irq_handler = (irq_handler_t)bnad_msix_mbox_handler; 1117 irq_handler = (irq_handler_t)bnad_msix_mbox_handler;
1119 irq = bnad->msix_table[bnad->msix_num - 1].vector; 1118 irq = bnad->msix_table[BNAD_MAILBOX_MSIX_INDEX].vector;
1120 irq_flags = 0; 1119 irq_flags = 0;
1121 intr_info->intr_type = BNA_INTR_T_MSIX; 1120 intr_info->intr_type = BNA_INTR_T_MSIX;
1122 intr_info->idl[0].vector = bnad->msix_num - 1; 1121 intr_info->idl[0].vector = BNAD_MAILBOX_MSIX_INDEX;
1123 } else { 1122 } else {
1124 irq_handler = (irq_handler_t)bnad_isr; 1123 irq_handler = (irq_handler_t)bnad_isr;
1125 irq = bnad->pcidev->irq; 1124 irq = bnad->pcidev->irq;
1126 irq_flags = IRQF_SHARED; 1125 irq_flags = IRQF_SHARED;
1127 intr_info->intr_type = BNA_INTR_T_INTX; 1126 intr_info->intr_type = BNA_INTR_T_INTX;
1128 /* intr_info->idl.vector = 0 ? */
1129 } 1127 }
1128
1130 spin_unlock_irqrestore(&bnad->bna_lock, flags); 1129 spin_unlock_irqrestore(&bnad->bna_lock, flags);
1131 sprintf(bnad->mbox_irq_name, "%s", BNAD_NAME); 1130 sprintf(bnad->mbox_irq_name, "%s", BNAD_NAME);
1132 1131
@@ -1179,11 +1178,12 @@ bnad_txrx_irq_alloc(struct bnad *bnad, enum bnad_intr_source src,
1179 1178
1180 switch (src) { 1179 switch (src) {
1181 case BNAD_INTR_TX: 1180 case BNAD_INTR_TX:
1182 vector_start = txrx_id; 1181 vector_start = BNAD_MAILBOX_MSIX_VECTORS + txrx_id;
1183 break; 1182 break;
1184 1183
1185 case BNAD_INTR_RX: 1184 case BNAD_INTR_RX:
1186 vector_start = bnad->num_tx * bnad->num_txq_per_tx + 1185 vector_start = BNAD_MAILBOX_MSIX_VECTORS +
1186 (bnad->num_tx * bnad->num_txq_per_tx) +
1187 txrx_id; 1187 txrx_id;
1188 break; 1188 break;
1189 1189
@@ -1204,11 +1204,11 @@ bnad_txrx_irq_alloc(struct bnad *bnad, enum bnad_intr_source src,
1204 1204
1205 switch (src) { 1205 switch (src) {
1206 case BNAD_INTR_TX: 1206 case BNAD_INTR_TX:
1207 intr_info->idl[0].vector = 0x1; /* Bit mask : Tx IB */ 1207 intr_info->idl[0].vector = BNAD_INTX_TX_IB_BITMASK;
1208 break; 1208 break;
1209 1209
1210 case BNAD_INTR_RX: 1210 case BNAD_INTR_RX:
1211 intr_info->idl[0].vector = 0x2; /* Bit mask : Rx IB */ 1211 intr_info->idl[0].vector = BNAD_INTX_RX_IB_BITMASK;
1212 break; 1212 break;
1213 } 1213 }
1214 } 1214 }
@@ -1447,7 +1447,7 @@ bnad_iocpf_sem_timeout(unsigned long data)
1447/* 1447/*
1448 * All timer routines use bnad->bna_lock to protect against 1448 * All timer routines use bnad->bna_lock to protect against
1449 * the following race, which may occur in case of no locking: 1449 * the following race, which may occur in case of no locking:
1450 * Time CPU m CPU n 1450 * Time CPU m CPU n
1451 * 0 1 = test_bit 1451 * 0 1 = test_bit
1452 * 1 clear_bit 1452 * 1 clear_bit
1453 * 2 del_timer_sync 1453 * 2 del_timer_sync
@@ -1912,7 +1912,7 @@ void
1912bnad_rx_coalescing_timeo_set(struct bnad *bnad) 1912bnad_rx_coalescing_timeo_set(struct bnad *bnad)
1913{ 1913{
1914 struct bnad_rx_info *rx_info; 1914 struct bnad_rx_info *rx_info;
1915 int i; 1915 int i;
1916 1916
1917 for (i = 0; i < bnad->num_rx; i++) { 1917 for (i = 0; i < bnad->num_rx; i++) {
1918 rx_info = &bnad->rx_info[i]; 1918 rx_info = &bnad->rx_info[i];
@@ -2075,7 +2075,7 @@ bnad_mbox_irq_sync(struct bnad *bnad)
2075 2075
2076 spin_lock_irqsave(&bnad->bna_lock, flags); 2076 spin_lock_irqsave(&bnad->bna_lock, flags);
2077 if (bnad->cfg_flags & BNAD_CF_MSIX) 2077 if (bnad->cfg_flags & BNAD_CF_MSIX)
2078 irq = bnad->msix_table[bnad->msix_num - 1].vector; 2078 irq = bnad->msix_table[BNAD_MAILBOX_MSIX_INDEX].vector;
2079 else 2079 else
2080 irq = bnad->pcidev->irq; 2080 irq = bnad->pcidev->irq;
2081 spin_unlock_irqrestore(&bnad->bna_lock, flags); 2081 spin_unlock_irqrestore(&bnad->bna_lock, flags);
@@ -2426,18 +2426,18 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
2426{ 2426{
2427 struct bnad *bnad = netdev_priv(netdev); 2427 struct bnad *bnad = netdev_priv(netdev);
2428 2428
2429 u16 txq_prod, vlan_tag = 0; 2429 u16 txq_prod, vlan_tag = 0;
2430 u32 unmap_prod, wis, wis_used, wi_range; 2430 u32 unmap_prod, wis, wis_used, wi_range;
2431 u32 vectors, vect_id, i, acked; 2431 u32 vectors, vect_id, i, acked;
2432 u32 tx_id; 2432 u32 tx_id;
2433 int err; 2433 int err;
2434 2434
2435 struct bnad_tx_info *tx_info; 2435 struct bnad_tx_info *tx_info;
2436 struct bna_tcb *tcb; 2436 struct bna_tcb *tcb;
2437 struct bnad_unmap_q *unmap_q; 2437 struct bnad_unmap_q *unmap_q;
2438 dma_addr_t dma_addr; 2438 dma_addr_t dma_addr;
2439 struct bna_txq_entry *txqent; 2439 struct bna_txq_entry *txqent;
2440 bna_txq_wi_ctrl_flag_t flags; 2440 bna_txq_wi_ctrl_flag_t flags;
2441 2441
2442 if (unlikely 2442 if (unlikely
2443 (skb->len <= ETH_HLEN || skb->len > BFI_TX_MAX_DATA_PER_PKT)) { 2443 (skb->len <= ETH_HLEN || skb->len > BFI_TX_MAX_DATA_PER_PKT)) {
@@ -3033,8 +3033,8 @@ static int __devinit
3033bnad_pci_probe(struct pci_dev *pdev, 3033bnad_pci_probe(struct pci_dev *pdev,
3034 const struct pci_device_id *pcidev_id) 3034 const struct pci_device_id *pcidev_id)
3035{ 3035{
3036 bool using_dac = false; 3036 bool using_dac = false;
3037 int err; 3037 int err;
3038 struct bnad *bnad; 3038 struct bnad *bnad;
3039 struct bna *bna; 3039 struct bna *bna;
3040 struct net_device *netdev; 3040 struct net_device *netdev;
@@ -3066,7 +3066,7 @@ bnad_pci_probe(struct pci_dev *pdev,
3066 3066
3067 /* 3067 /*
3068 * PCI initialization 3068 * PCI initialization
3069 * Output : using_dac = 1 for 64 bit DMA 3069 * Output : using_dac = 1 for 64 bit DMA
3070 * = 0 for 32 bit DMA 3070 * = 0 for 32 bit DMA
3071 */ 3071 */
3072 err = bnad_pci_init(bnad, pdev, &using_dac); 3072 err = bnad_pci_init(bnad, pdev, &using_dac);
@@ -3209,7 +3209,7 @@ bnad_pci_remove(struct pci_dev *pdev)
3209 free_netdev(netdev); 3209 free_netdev(netdev);
3210} 3210}
3211 3211
3212static const struct pci_device_id bnad_pci_id_table[] = { 3212static DEFINE_PCI_DEVICE_TABLE(bnad_pci_id_table) = {
3213 { 3213 {
3214 PCI_DEVICE(PCI_VENDOR_ID_BROCADE, 3214 PCI_DEVICE(PCI_VENDOR_ID_BROCADE,
3215 PCI_DEVICE_ID_BROCADE_CT), 3215 PCI_DEVICE_ID_BROCADE_CT),
@@ -3232,7 +3232,8 @@ bnad_module_init(void)
3232{ 3232{
3233 int err; 3233 int err;
3234 3234
3235 pr_info("Brocade 10G Ethernet driver\n"); 3235 pr_info("Brocade 10G Ethernet driver - version: %s\n",
3236 BNAD_VERSION);
3236 3237
3237 bfa_nw_ioc_auto_recover(bnad_ioc_auto_recover); 3238 bfa_nw_ioc_auto_recover(bnad_ioc_auto_recover);
3238 3239
diff --git a/drivers/net/bna/bnad.h b/drivers/net/bna/bnad.h
index 7aa550b6182d..458eb30371b5 100644
--- a/drivers/net/bna/bnad.h
+++ b/drivers/net/bna/bnad.h
@@ -68,10 +68,13 @@ struct bnad_rx_ctrl {
68 68
69#define BNAD_VERSION "2.3.2.3" 69#define BNAD_VERSION "2.3.2.3"
70 70
71#define BNAD_MAILBOX_MSIX_INDEX 0
71#define BNAD_MAILBOX_MSIX_VECTORS 1 72#define BNAD_MAILBOX_MSIX_VECTORS 1
73#define BNAD_INTX_TX_IB_BITMASK 0x1
74#define BNAD_INTX_RX_IB_BITMASK 0x2
72 75
73#define BNAD_STATS_TIMER_FREQ 1000 /* in msecs */ 76#define BNAD_STATS_TIMER_FREQ 1000 /* in msecs */
74#define BNAD_DIM_TIMER_FREQ 1000 /* in msecs */ 77#define BNAD_DIM_TIMER_FREQ 1000 /* in msecs */
75 78
76#define BNAD_MAX_Q_DEPTH 0x10000 79#define BNAD_MAX_Q_DEPTH 0x10000
77#define BNAD_MIN_Q_DEPTH 0x200 80#define BNAD_MIN_Q_DEPTH 0x200
@@ -102,12 +105,12 @@ enum bnad_intr_source {
102 105
103enum bnad_link_state { 106enum bnad_link_state {
104 BNAD_LS_DOWN = 0, 107 BNAD_LS_DOWN = 0,
105 BNAD_LS_UP = 1 108 BNAD_LS_UP = 1
106}; 109};
107 110
108struct bnad_completion { 111struct bnad_completion {
109 struct completion ioc_comp; 112 struct completion ioc_comp;
110 struct completion ucast_comp; 113 struct completion ucast_comp;
111 struct completion mcast_comp; 114 struct completion mcast_comp;
112 struct completion tx_comp; 115 struct completion tx_comp;
113 struct completion rx_comp; 116 struct completion rx_comp;
@@ -125,7 +128,7 @@ struct bnad_completion {
125 128
126/* Tx Rx Control Stats */ 129/* Tx Rx Control Stats */
127struct bnad_drv_stats { 130struct bnad_drv_stats {
128 u64 netif_queue_stop; 131 u64 netif_queue_stop;
129 u64 netif_queue_wakeup; 132 u64 netif_queue_wakeup;
130 u64 netif_queue_stopped; 133 u64 netif_queue_stopped;
131 u64 tso4; 134 u64 tso4;
@@ -188,7 +191,7 @@ struct bnad_skb_unmap {
188struct bnad_unmap_q { 191struct bnad_unmap_q {
189 u32 producer_index; 192 u32 producer_index;
190 u32 consumer_index; 193 u32 consumer_index;
191 u32 q_depth; 194 u32 q_depth;
192 /* This should be the last one */ 195 /* This should be the last one */
193 struct bnad_skb_unmap unmap_array[1]; 196 struct bnad_skb_unmap unmap_array[1];
194}; 197};
@@ -211,7 +214,7 @@ struct bnad_unmap_q {
211#define BNAD_RF_RX_SHUTDOWN_DELAYED 7 214#define BNAD_RF_RX_SHUTDOWN_DELAYED 7
212 215
213struct bnad { 216struct bnad {
214 struct net_device *netdev; 217 struct net_device *netdev;
215 218
216 /* Data path */ 219 /* Data path */
217 struct bnad_tx_info tx_info[BNAD_MAX_TXS]; 220 struct bnad_tx_info tx_info[BNAD_MAX_TXS];
@@ -245,7 +248,7 @@ struct bnad {
245 u32 cfg_flags; 248 u32 cfg_flags;
246 unsigned long run_flags; 249 unsigned long run_flags;
247 250
248 struct pci_dev *pcidev; 251 struct pci_dev *pcidev;
249 u64 mmio_start; 252 u64 mmio_start;
250 u64 mmio_len; 253 u64 mmio_len;
251 254
@@ -278,7 +281,7 @@ struct bnad {
278 struct bnad_diag *diag; 281 struct bnad_diag *diag;
279 282
280 char adapter_name[BNAD_NAME_LEN]; 283 char adapter_name[BNAD_NAME_LEN];
281 char port_name[BNAD_NAME_LEN]; 284 char port_name[BNAD_NAME_LEN];
282 char mbox_irq_name[BNAD_NAME_LEN]; 285 char mbox_irq_name[BNAD_NAME_LEN];
283}; 286};
284 287
@@ -286,7 +289,7 @@ struct bnad {
286 * EXTERN VARIABLES 289 * EXTERN VARIABLES
287 */ 290 */
288extern struct firmware *bfi_fw; 291extern struct firmware *bfi_fw;
289extern u32 bnad_rxqs_per_cq; 292extern u32 bnad_rxqs_per_cq;
290 293
291/* 294/*
292 * EXTERN PROTOTYPES 295 * EXTERN PROTOTYPES
@@ -332,7 +335,7 @@ extern void bnad_netdev_hwstats_fill(struct bnad *bnad,
332} 335}
333 336
334#define bnad_dim_timer_running(_bnad) \ 337#define bnad_dim_timer_running(_bnad) \
335 (((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED) && \ 338 (((_bnad)->cfg_flags & BNAD_CF_DIM_ENABLED) && \
336 (test_bit(BNAD_RF_DIM_TIMER_RUNNING, &((_bnad)->run_flags)))) 339 (test_bit(BNAD_RF_DIM_TIMER_RUNNING, &((_bnad)->run_flags))))
337 340
338#endif /* __BNAD_H__ */ 341#endif /* __BNAD_H__ */
diff --git a/drivers/net/bna/bnad_ethtool.c b/drivers/net/bna/bnad_ethtool.c
index 3330cd78da2c..fea07f19a5db 100644
--- a/drivers/net/bna/bnad_ethtool.c
+++ b/drivers/net/bna/bnad_ethtool.c
@@ -295,7 +295,7 @@ get_regs(struct bnad *bnad, u32 * regs)
295 u32 reg_addr; 295 u32 reg_addr;
296 unsigned long flags; 296 unsigned long flags;
297 297
298#define BNAD_GET_REG(addr) \ 298#define BNAD_GET_REG(addr) \
299do { \ 299do { \
300 if (regs) \ 300 if (regs) \
301 regs[num++] = readl(bnad->bar0 + (addr)); \ 301 regs[num++] = readl(bnad->bar0 + (addr)); \
diff --git a/drivers/net/bna/cna.h b/drivers/net/bna/cna.h
index 01b4af733021..a679e038747b 100644
--- a/drivers/net/bna/cna.h
+++ b/drivers/net/bna/cna.h
@@ -33,7 +33,7 @@
33 33
34#include <linux/list.h> 34#include <linux/list.h>
35 35
36#define bfa_sm_fault(__mod, __event) do { \ 36#define bfa_sm_fault(__event) do { \
37 pr_err("SM Assertion failure: %s: %d: event = %d", __FILE__, __LINE__, \ 37 pr_err("SM Assertion failure: %s: %d: event = %d", __FILE__, __LINE__, \
38 __event); \ 38 __event); \
39} while (0) 39} while (0)
diff --git a/drivers/net/bnx2x/bnx2x_dcb.c b/drivers/net/bnx2x/bnx2x_dcb.c
index d028794a2298..a4ea35f6a456 100644
--- a/drivers/net/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/bnx2x/bnx2x_dcb.c
@@ -19,15 +19,13 @@
19#include <linux/netdevice.h> 19#include <linux/netdevice.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/rtnetlink.h>
23#include <net/dcbnl.h>
22 24
23#include "bnx2x.h" 25#include "bnx2x.h"
24#include "bnx2x_cmn.h" 26#include "bnx2x_cmn.h"
25#include "bnx2x_dcb.h" 27#include "bnx2x_dcb.h"
26 28
27#ifdef BCM_DCBNL
28#include <linux/rtnetlink.h>
29#endif
30
31/* forward declarations of dcbx related functions */ 29/* forward declarations of dcbx related functions */
32static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp); 30static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
33static void bnx2x_pfc_set_pfc(struct bnx2x *bp); 31static void bnx2x_pfc_set_pfc(struct bnx2x *bp);
@@ -333,6 +331,32 @@ static void bnx2x_dcbx_get_pfc_feature(struct bnx2x *bp,
333 } 331 }
334} 332}
335 333
334/* maps unmapped priorities to to the same COS as L2 */
335static void bnx2x_dcbx_map_nw(struct bnx2x *bp)
336{
337 int i;
338 u32 unmapped = (1 << MAX_PFC_PRIORITIES) - 1; /* all ones */
339 u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority;
340 u32 nw_prio = 1 << ttp[LLFC_TRAFFIC_TYPE_NW];
341 struct bnx2x_dcbx_cos_params *cos_params =
342 bp->dcbx_port_params.ets.cos_params;
343
344 /* get unmapped priorities by clearing mapped bits */
345 for (i = 0; i < LLFC_DRIVER_TRAFFIC_TYPE_MAX; i++)
346 unmapped &= ~(1 << ttp[i]);
347
348 /* find cos for nw prio and extend it with unmapped */
349 for (i = 0; i < ARRAY_SIZE(bp->dcbx_port_params.ets.cos_params); i++) {
350 if (cos_params[i].pri_bitmask & nw_prio) {
351 /* extend the bitmask with unmapped */
352 DP(NETIF_MSG_LINK,
353 "cos %d extended with 0x%08x", i, unmapped);
354 cos_params[i].pri_bitmask |= unmapped;
355 break;
356 }
357 }
358}
359
336static void bnx2x_get_dcbx_drv_param(struct bnx2x *bp, 360static void bnx2x_get_dcbx_drv_param(struct bnx2x *bp,
337 struct dcbx_features *features, 361 struct dcbx_features *features,
338 u32 error) 362 u32 error)
@@ -342,6 +366,8 @@ static void bnx2x_get_dcbx_drv_param(struct bnx2x *bp,
342 bnx2x_dcbx_get_pfc_feature(bp, &features->pfc, error); 366 bnx2x_dcbx_get_pfc_feature(bp, &features->pfc, error);
343 367
344 bnx2x_dcbx_get_ets_feature(bp, &features->ets, error); 368 bnx2x_dcbx_get_ets_feature(bp, &features->ets, error);
369
370 bnx2x_dcbx_map_nw(bp);
345} 371}
346 372
347#define DCBX_LOCAL_MIB_MAX_TRY_READ (100) 373#define DCBX_LOCAL_MIB_MAX_TRY_READ (100)
@@ -682,6 +708,8 @@ static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp)
682 if (bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask 708 if (bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask
683 & (1 << prio)) { 709 & (1 << prio)) {
684 bp->prio_to_cos[prio] = cos; 710 bp->prio_to_cos[prio] = cos;
711 DP(NETIF_MSG_LINK,
712 "tx_mapping %d --> %d\n", prio, cos);
685 } 713 }
686 } 714 }
687 } 715 }
@@ -749,7 +777,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
749 DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); 777 DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n");
750 bnx2x_fw_command(bp, DRV_MSG_CODE_DCBX_PMF_DRV_OK, 0); 778 bnx2x_fw_command(bp, DRV_MSG_CODE_DCBX_PMF_DRV_OK, 0);
751#ifdef BCM_DCBNL 779#ifdef BCM_DCBNL
752 /** 780 /*
753 * Send a notification for the new negotiated parameters 781 * Send a notification for the new negotiated parameters
754 */ 782 */
755 dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0); 783 dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0);
@@ -1732,7 +1760,6 @@ static void bnx2x_dcbx_fill_cos_params(struct bnx2x *bp,
1732 pri_join_mask, 1760 pri_join_mask,
1733 num_of_dif_pri); 1761 num_of_dif_pri);
1734 1762
1735
1736 for (i = 0; i < cos_data.num_of_cos ; i++) { 1763 for (i = 0; i < cos_data.num_of_cos ; i++) {
1737 struct bnx2x_dcbx_cos_params *p = 1764 struct bnx2x_dcbx_cos_params *p =
1738 &bp->dcbx_port_params.ets.cos_params[i]; 1765 &bp->dcbx_port_params.ets.cos_params[i];
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index e1ec1a302474..150709111548 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -1671,11 +1671,12 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe)
1671 1671
1672 switch (command) { 1672 switch (command) {
1673 case (RAMROD_CMD_ID_ETH_CLIENT_UPDATE): 1673 case (RAMROD_CMD_ID_ETH_CLIENT_UPDATE):
1674 DP(NETIF_MSG_IFUP, "got UPDATE ramrod. CID %d\n", cid); 1674 DP(BNX2X_MSG_SP, "got UPDATE ramrod. CID %d\n", cid);
1675 drv_cmd = BNX2X_Q_CMD_UPDATE; 1675 drv_cmd = BNX2X_Q_CMD_UPDATE;
1676 break; 1676 break;
1677
1677 case (RAMROD_CMD_ID_ETH_CLIENT_SETUP): 1678 case (RAMROD_CMD_ID_ETH_CLIENT_SETUP):
1678 DP(NETIF_MSG_IFUP, "got MULTI[%d] setup ramrod\n", cid); 1679 DP(BNX2X_MSG_SP, "got MULTI[%d] setup ramrod\n", cid);
1679 drv_cmd = BNX2X_Q_CMD_SETUP; 1680 drv_cmd = BNX2X_Q_CMD_SETUP;
1680 break; 1681 break;
1681 1682
@@ -1685,17 +1686,17 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe)
1685 break; 1686 break;
1686 1687
1687 case (RAMROD_CMD_ID_ETH_HALT): 1688 case (RAMROD_CMD_ID_ETH_HALT):
1688 DP(NETIF_MSG_IFDOWN, "got MULTI[%d] halt ramrod\n", cid); 1689 DP(BNX2X_MSG_SP, "got MULTI[%d] halt ramrod\n", cid);
1689 drv_cmd = BNX2X_Q_CMD_HALT; 1690 drv_cmd = BNX2X_Q_CMD_HALT;
1690 break; 1691 break;
1691 1692
1692 case (RAMROD_CMD_ID_ETH_TERMINATE): 1693 case (RAMROD_CMD_ID_ETH_TERMINATE):
1693 DP(NETIF_MSG_IFDOWN, "got MULTI[%d] teminate ramrod\n", cid); 1694 DP(BNX2X_MSG_SP, "got MULTI[%d] teminate ramrod\n", cid);
1694 drv_cmd = BNX2X_Q_CMD_TERMINATE; 1695 drv_cmd = BNX2X_Q_CMD_TERMINATE;
1695 break; 1696 break;
1696 1697
1697 case (RAMROD_CMD_ID_ETH_EMPTY): 1698 case (RAMROD_CMD_ID_ETH_EMPTY):
1698 DP(NETIF_MSG_IFDOWN, "got MULTI[%d] empty ramrod\n", cid); 1699 DP(BNX2X_MSG_SP, "got MULTI[%d] empty ramrod\n", cid);
1699 drv_cmd = BNX2X_Q_CMD_EMPTY; 1700 drv_cmd = BNX2X_Q_CMD_EMPTY;
1700 break; 1701 break;
1701 1702
@@ -1725,6 +1726,8 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe)
1725 /* push the change in bp->spq_left and towards the memory */ 1726 /* push the change in bp->spq_left and towards the memory */
1726 smp_mb__after_atomic_inc(); 1727 smp_mb__after_atomic_inc();
1727 1728
1729 DP(BNX2X_MSG_SP, "bp->cq_spq_left %x\n", atomic_read(&bp->cq_spq_left));
1730
1728 return; 1731 return;
1729} 1732}
1730 1733
@@ -2151,10 +2154,12 @@ u8 bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode)
2151 u8 rc; 2154 u8 rc;
2152 int cfx_idx = bnx2x_get_link_cfg_idx(bp); 2155 int cfx_idx = bnx2x_get_link_cfg_idx(bp);
2153 u16 req_line_speed = bp->link_params.req_line_speed[cfx_idx]; 2156 u16 req_line_speed = bp->link_params.req_line_speed[cfx_idx];
2154 /* Initialize link parameters structure variables */ 2157 /*
2155 /* It is recommended to turn off RX FC for jumbo frames 2158 * Initialize link parameters structure variables
2156 for better performance */ 2159 * It is recommended to turn off RX FC for jumbo frames
2157 if ((CHIP_IS_E1x(bp)) && (bp->dev->mtu > 5000)) 2160 * for better performance
2161 */
2162 if (CHIP_IS_E1x(bp) && (bp->dev->mtu > 5000))
2158 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_TX; 2163 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_TX;
2159 else 2164 else
2160 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH; 2165 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH;
@@ -2162,8 +2167,18 @@ u8 bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode)
2162 bnx2x_acquire_phy_lock(bp); 2167 bnx2x_acquire_phy_lock(bp);
2163 2168
2164 if (load_mode == LOAD_DIAG) { 2169 if (load_mode == LOAD_DIAG) {
2165 bp->link_params.loopback_mode = LOOPBACK_XGXS; 2170 struct link_params *lp = &bp->link_params;
2166 bp->link_params.req_line_speed[cfx_idx] = SPEED_10000; 2171 lp->loopback_mode = LOOPBACK_XGXS;
2172 /* do PHY loopback at 10G speed, if possible */
2173 if (lp->req_line_speed[cfx_idx] < SPEED_10000) {
2174 if (lp->speed_cap_mask[cfx_idx] &
2175 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)
2176 lp->req_line_speed[cfx_idx] =
2177 SPEED_10000;
2178 else
2179 lp->req_line_speed[cfx_idx] =
2180 SPEED_1000;
2181 }
2167 } 2182 }
2168 2183
2169 rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars); 2184 rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars);
@@ -3077,26 +3092,23 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
3077 spe->data.update_data_addr.hi = cpu_to_le32(data_hi); 3092 spe->data.update_data_addr.hi = cpu_to_le32(data_hi);
3078 spe->data.update_data_addr.lo = cpu_to_le32(data_lo); 3093 spe->data.update_data_addr.lo = cpu_to_le32(data_lo);
3079 3094
3080 /* stats ramrod has it's own slot on the spq */ 3095 /*
3081 if (command != RAMROD_CMD_ID_COMMON_STAT_QUERY) { 3096 * It's ok if the actual decrement is issued towards the memory
3082 /* 3097 * somewhere between the spin_lock and spin_unlock. Thus no
3083 * It's ok if the actual decrement is issued towards the memory 3098 * more explict memory barrier is needed.
3084 * somewhere between the spin_lock and spin_unlock. Thus no 3099 */
3085 * more explict memory barrier is needed. 3100 if (common)
3086 */ 3101 atomic_dec(&bp->eq_spq_left);
3087 if (common) 3102 else
3088 atomic_dec(&bp->eq_spq_left); 3103 atomic_dec(&bp->cq_spq_left);
3089 else
3090 atomic_dec(&bp->cq_spq_left);
3091 }
3092 3104
3093 3105
3094 DP(BNX2X_MSG_SP/*NETIF_MSG_TIMER*/, 3106 DP(BNX2X_MSG_SP/*NETIF_MSG_TIMER*/,
3095 "SPQE[%x] (%x:%x) command %d hw_cid %x data (%x:%x) " 3107 "SPQE[%x] (%x:%x) (cmd, common?) (%d,%d) hw_cid %x data (%x:%x) "
3096 "type(0x%x) left (ETH, COMMON) (%x,%x)\n", 3108 "type(0x%x) left (CQ, EQ) (%x,%x)\n",
3097 bp->spq_prod_idx, (u32)U64_HI(bp->spq_mapping), 3109 bp->spq_prod_idx, (u32)U64_HI(bp->spq_mapping),
3098 (u32)(U64_LO(bp->spq_mapping) + 3110 (u32)(U64_LO(bp->spq_mapping) +
3099 (void *)bp->spq_prod_bd - (void *)bp->spq), command, 3111 (void *)bp->spq_prod_bd - (void *)bp->spq), command, common,
3100 HW_CID(bp, cid), data_hi, data_lo, type, 3112 HW_CID(bp, cid), data_hi, data_lo, type,
3101 atomic_read(&bp->cq_spq_left), atomic_read(&bp->eq_spq_left)); 3113 atomic_read(&bp->cq_spq_left), atomic_read(&bp->eq_spq_left));
3102 3114
@@ -3453,6 +3465,7 @@ static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn)
3453 } else if (attn & BNX2X_MC_ASSERT_BITS) { 3465 } else if (attn & BNX2X_MC_ASSERT_BITS) {
3454 3466
3455 BNX2X_ERR("MC assert!\n"); 3467 BNX2X_ERR("MC assert!\n");
3468 bnx2x_mc_assert(bp);
3456 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_10, 0); 3469 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_10, 0);
3457 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_9, 0); 3470 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_9, 0);
3458 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_8, 0); 3471 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_8, 0);
@@ -4412,7 +4425,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4412 sw_cons = bp->eq_cons; 4425 sw_cons = bp->eq_cons;
4413 sw_prod = bp->eq_prod; 4426 sw_prod = bp->eq_prod;
4414 4427
4415 DP(BNX2X_MSG_SP, "EQ: hw_cons %u sw_cons %u bp->cq_spq_left %u\n", 4428 DP(BNX2X_MSG_SP, "EQ: hw_cons %u sw_cons %u bp->eq_spq_left %x\n",
4416 hw_cons, sw_cons, atomic_read(&bp->eq_spq_left)); 4429 hw_cons, sw_cons, atomic_read(&bp->eq_spq_left));
4417 4430
4418 for (; sw_cons != hw_cons; 4431 for (; sw_cons != hw_cons;
@@ -4431,7 +4444,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4431 DP(NETIF_MSG_TIMER, "got statistics comp event %d\n", 4444 DP(NETIF_MSG_TIMER, "got statistics comp event %d\n",
4432 bp->stats_comp++); 4445 bp->stats_comp++);
4433 /* nothing to do with stats comp */ 4446 /* nothing to do with stats comp */
4434 continue; 4447 goto next_spqe;
4435 4448
4436 case EVENT_RING_OPCODE_CFC_DEL: 4449 case EVENT_RING_OPCODE_CFC_DEL:
4437 /* handle according to cid range */ 4450 /* handle according to cid range */
@@ -4439,7 +4452,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4439 * we may want to verify here that the bp state is 4452 * we may want to verify here that the bp state is
4440 * HALTING 4453 * HALTING
4441 */ 4454 */
4442 DP(NETIF_MSG_IFDOWN, 4455 DP(BNX2X_MSG_SP,
4443 "got delete ramrod for MULTI[%d]\n", cid); 4456 "got delete ramrod for MULTI[%d]\n", cid);
4444#ifdef BCM_CNIC 4457#ifdef BCM_CNIC
4445 if (!bnx2x_cnic_handle_cfc_del(bp, cid, elem)) 4458 if (!bnx2x_cnic_handle_cfc_del(bp, cid, elem))
@@ -4455,7 +4468,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4455 goto next_spqe; 4468 goto next_spqe;
4456 4469
4457 case EVENT_RING_OPCODE_STOP_TRAFFIC: 4470 case EVENT_RING_OPCODE_STOP_TRAFFIC:
4458 DP(NETIF_MSG_IFUP, "got STOP TRAFFIC\n"); 4471 DP(BNX2X_MSG_SP, "got STOP TRAFFIC\n");
4459 if (f_obj->complete_cmd(bp, f_obj, 4472 if (f_obj->complete_cmd(bp, f_obj,
4460 BNX2X_F_CMD_TX_STOP)) 4473 BNX2X_F_CMD_TX_STOP))
4461 break; 4474 break;
@@ -4463,21 +4476,21 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4463 goto next_spqe; 4476 goto next_spqe;
4464 4477
4465 case EVENT_RING_OPCODE_START_TRAFFIC: 4478 case EVENT_RING_OPCODE_START_TRAFFIC:
4466 DP(NETIF_MSG_IFUP, "got START TRAFFIC\n"); 4479 DP(BNX2X_MSG_SP, "got START TRAFFIC\n");
4467 if (f_obj->complete_cmd(bp, f_obj, 4480 if (f_obj->complete_cmd(bp, f_obj,
4468 BNX2X_F_CMD_TX_START)) 4481 BNX2X_F_CMD_TX_START))
4469 break; 4482 break;
4470 bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_RELEASED); 4483 bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_RELEASED);
4471 goto next_spqe; 4484 goto next_spqe;
4472 case EVENT_RING_OPCODE_FUNCTION_START: 4485 case EVENT_RING_OPCODE_FUNCTION_START:
4473 DP(NETIF_MSG_IFUP, "got FUNC_START ramrod\n"); 4486 DP(BNX2X_MSG_SP, "got FUNC_START ramrod\n");
4474 if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_START)) 4487 if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_START))
4475 break; 4488 break;
4476 4489
4477 goto next_spqe; 4490 goto next_spqe;
4478 4491
4479 case EVENT_RING_OPCODE_FUNCTION_STOP: 4492 case EVENT_RING_OPCODE_FUNCTION_STOP:
4480 DP(NETIF_MSG_IFDOWN, "got FUNC_STOP ramrod\n"); 4493 DP(BNX2X_MSG_SP, "got FUNC_STOP ramrod\n");
4481 if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_STOP)) 4494 if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_STOP))
4482 break; 4495 break;
4483 4496
@@ -4491,7 +4504,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4491 BNX2X_STATE_OPENING_WAIT4_PORT): 4504 BNX2X_STATE_OPENING_WAIT4_PORT):
4492 cid = elem->message.data.eth_event.echo & 4505 cid = elem->message.data.eth_event.echo &
4493 BNX2X_SWCID_MASK; 4506 BNX2X_SWCID_MASK;
4494 DP(NETIF_MSG_IFUP, "got RSS_UPDATE ramrod. CID %d\n", 4507 DP(BNX2X_MSG_SP, "got RSS_UPDATE ramrod. CID %d\n",
4495 cid); 4508 cid);
4496 rss_raw->clear_pending(rss_raw); 4509 rss_raw->clear_pending(rss_raw);
4497 break; 4510 break;
@@ -4506,7 +4519,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4506 BNX2X_STATE_DIAG): 4519 BNX2X_STATE_DIAG):
4507 case (EVENT_RING_OPCODE_CLASSIFICATION_RULES | 4520 case (EVENT_RING_OPCODE_CLASSIFICATION_RULES |
4508 BNX2X_STATE_CLOSING_WAIT4_HALT): 4521 BNX2X_STATE_CLOSING_WAIT4_HALT):
4509 DP(NETIF_MSG_IFUP, "got (un)set mac ramrod\n"); 4522 DP(BNX2X_MSG_SP, "got (un)set mac ramrod\n");
4510 bnx2x_handle_classification_eqe(bp, elem); 4523 bnx2x_handle_classification_eqe(bp, elem);
4511 break; 4524 break;
4512 4525
@@ -4516,7 +4529,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4516 BNX2X_STATE_DIAG): 4529 BNX2X_STATE_DIAG):
4517 case (EVENT_RING_OPCODE_MULTICAST_RULES | 4530 case (EVENT_RING_OPCODE_MULTICAST_RULES |
4518 BNX2X_STATE_CLOSING_WAIT4_HALT): 4531 BNX2X_STATE_CLOSING_WAIT4_HALT):
4519 DP(NETIF_MSG_IFUP, "got mcast ramrod\n"); 4532 DP(BNX2X_MSG_SP, "got mcast ramrod\n");
4520 bnx2x_handle_mcast_eqe(bp); 4533 bnx2x_handle_mcast_eqe(bp);
4521 break; 4534 break;
4522 4535
@@ -4526,7 +4539,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
4526 BNX2X_STATE_DIAG): 4539 BNX2X_STATE_DIAG):
4527 case (EVENT_RING_OPCODE_FILTERS_RULES | 4540 case (EVENT_RING_OPCODE_FILTERS_RULES |
4528 BNX2X_STATE_CLOSING_WAIT4_HALT): 4541 BNX2X_STATE_CLOSING_WAIT4_HALT):
4529 DP(NETIF_MSG_IFUP, "got rx_mode ramrod\n"); 4542 DP(BNX2X_MSG_SP, "got rx_mode ramrod\n");
4530 bnx2x_handle_rx_mode_eqe(bp); 4543 bnx2x_handle_rx_mode_eqe(bp);
4531 break; 4544 break;
4532 default: 4545 default:
@@ -5639,7 +5652,7 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
5639 int r_order, w_order; 5652 int r_order, w_order;
5640 5653
5641 pci_read_config_word(bp->pdev, 5654 pci_read_config_word(bp->pdev,
5642 bp->pdev->pcie_cap + PCI_EXP_DEVCTL, &devctl); 5655 pci_pcie_cap(bp->pdev) + PCI_EXP_DEVCTL, &devctl);
5643 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl); 5656 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
5644 w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); 5657 w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
5645 if (bp->mrrs == -1) 5658 if (bp->mrrs == -1)
@@ -8400,31 +8413,45 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
8400 if (!netif_running(bp->dev)) 8413 if (!netif_running(bp->dev))
8401 goto sp_rtnl_exit; 8414 goto sp_rtnl_exit;
8402 8415
8403 if (test_and_clear_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state))
8404 bnx2x_setup_tc(bp->dev, bp->dcbx_port_params.ets.num_of_cos);
8405
8406 /* if stop on error is defined no recovery flows should be executed */ 8416 /* if stop on error is defined no recovery flows should be executed */
8407#ifdef BNX2X_STOP_ON_ERROR 8417#ifdef BNX2X_STOP_ON_ERROR
8408 BNX2X_ERR("recovery flow called but STOP_ON_ERROR defined " 8418 BNX2X_ERR("recovery flow called but STOP_ON_ERROR defined "
8409 "so reset not done to allow debug dump,\n" 8419 "so reset not done to allow debug dump,\n"
8410 "you will need to reboot when done\n"); 8420 "you will need to reboot when done\n");
8411 goto sp_rtnl_exit; 8421 goto sp_rtnl_not_reset;
8412#endif 8422#endif
8413 8423
8414 if (unlikely(bp->recovery_state != BNX2X_RECOVERY_DONE)) { 8424 if (unlikely(bp->recovery_state != BNX2X_RECOVERY_DONE)) {
8415 /* 8425 /*
8416 * Clear TX_TIMEOUT bit as we are going to reset the function 8426 * Clear all pending SP commands as we are going to reset the
8417 * anyway. 8427 * function anyway.
8418 */ 8428 */
8419 smp_mb__before_clear_bit(); 8429 bp->sp_rtnl_state = 0;
8420 clear_bit(BNX2X_SP_RTNL_TX_TIMEOUT, &bp->sp_rtnl_state); 8430 smp_mb();
8421 smp_mb__after_clear_bit(); 8431
8422 bnx2x_parity_recover(bp); 8432 bnx2x_parity_recover(bp);
8423 } else if (test_and_clear_bit(BNX2X_SP_RTNL_TX_TIMEOUT, 8433
8424 &bp->sp_rtnl_state)){ 8434 goto sp_rtnl_exit;
8435 }
8436
8437 if (test_and_clear_bit(BNX2X_SP_RTNL_TX_TIMEOUT, &bp->sp_rtnl_state)) {
8438 /*
8439 * Clear all pending SP commands as we are going to reset the
8440 * function anyway.
8441 */
8442 bp->sp_rtnl_state = 0;
8443 smp_mb();
8444
8425 bnx2x_nic_unload(bp, UNLOAD_NORMAL); 8445 bnx2x_nic_unload(bp, UNLOAD_NORMAL);
8426 bnx2x_nic_load(bp, LOAD_NORMAL); 8446 bnx2x_nic_load(bp, LOAD_NORMAL);
8447
8448 goto sp_rtnl_exit;
8427 } 8449 }
8450#ifdef BNX2X_STOP_ON_ERROR
8451sp_rtnl_not_reset:
8452#endif
8453 if (test_and_clear_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state))
8454 bnx2x_setup_tc(bp->dev, bp->dcbx_port_params.ets.num_of_cos);
8428 8455
8429sp_rtnl_exit: 8456sp_rtnl_exit:
8430 rtnl_unlock(); 8457 rtnl_unlock();
@@ -10229,11 +10256,14 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10229 REG_WR(bp, PXP2_REG_PGL_ADDR_90_F0 + BP_PORT(bp)*16, 0); 10256 REG_WR(bp, PXP2_REG_PGL_ADDR_90_F0 + BP_PORT(bp)*16, 0);
10230 REG_WR(bp, PXP2_REG_PGL_ADDR_94_F0 + BP_PORT(bp)*16, 0); 10257 REG_WR(bp, PXP2_REG_PGL_ADDR_94_F0 + BP_PORT(bp)*16, 0);
10231 10258
10232 /** 10259 /*
10233 * Enable internal target-read (in case we are probed after PF FLR). 10260 * Enable internal target-read (in case we are probed after PF FLR).
10234 * Must be done prior to any BAR read access 10261 * Must be done prior to any BAR read access. Only for 57712 and up
10235 */ 10262 */
10236 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); 10263 if (board_type != BCM57710 &&
10264 board_type != BCM57711 &&
10265 board_type != BCM57711E)
10266 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1);
10237 10267
10238 /* Reset the load counter */ 10268 /* Reset the load counter */
10239 bnx2x_clear_load_cnt(bp); 10269 bnx2x_clear_load_cnt(bp);
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 80adc83f796a..536bda072a16 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -33,7 +33,6 @@
33#include <linux/if_arp.h> 33#include <linux/if_arp.h>
34#include <linux/if_ether.h> 34#include <linux/if_ether.h>
35#include <linux/list.h> 35#include <linux/list.h>
36#include <linux/delay.h>
37#include <linux/io.h> 36#include <linux/io.h>
38 37
39#include <linux/can.h> 38#include <linux/can.h>
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 0e300cf840b9..0b5c6f8bdd34 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -27,7 +27,6 @@
27#include <linux/if_arp.h> 27#include <linux/if_arp.h>
28#include <linux/if_ether.h> 28#include <linux/if_ether.h>
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/delay.h>
31#include <linux/io.h> 30#include <linux/io.h>
32#include <linux/platform_device.h> 31#include <linux/platform_device.h>
33#include <linux/clk.h> 32#include <linux/clk.h>
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index cb8c6bbbf0d2..dc599059512a 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -47,7 +47,6 @@
47#include <linux/if_ether.h> 47#include <linux/if_ether.h>
48#include <linux/aer.h> 48#include <linux/aer.h>
49#include <linux/prefetch.h> 49#include <linux/prefetch.h>
50#include <linux/if_vlan.h>
51#ifdef CONFIG_IGB_DCA 50#ifdef CONFIG_IGB_DCA
52#include <linux/dca.h> 51#include <linux/dca.h>
53#endif 52#endif
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 743e3ec729c2..f07e96ec8843 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -36,7 +36,6 @@
36#include <linux/ethtool.h> 36#include <linux/ethtool.h>
37#include <linux/if_vlan.h> 37#include <linux/if_vlan.h>
38#include <linux/skbuff.h> 38#include <linux/skbuff.h>
39#include <linux/if_vlan.h>
40#include <linux/delay.h> 39#include <linux/delay.h>
41#include <linux/mm.h> 40#include <linux/mm.h>
42#include <linux/vmalloc.h> 41#include <linux/vmalloc.h>
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 40bcb82d9116..4e2d1448093c 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -2160,12 +2160,9 @@ static void rtl8169sb_hw_phy_config(struct rtl8169_private *tp)
2160static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp) 2160static void rtl8169scd_hw_phy_config_quirk(struct rtl8169_private *tp)
2161{ 2161{
2162 struct pci_dev *pdev = tp->pci_dev; 2162 struct pci_dev *pdev = tp->pci_dev;
2163 u16 vendor_id, device_id;
2164 2163
2165 pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &vendor_id); 2164 if ((pdev->subsystem_vendor != PCI_VENDOR_ID_GIGABYTE) ||
2166 pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &device_id); 2165 (pdev->subsystem_device != 0xe000))
2167
2168 if ((vendor_id != PCI_VENDOR_ID_GIGABYTE) || (device_id != 0xe000))
2169 return; 2166 return;
2170 2167
2171 rtl_writephy(tp, 0x1f, 0x0001); 2168 rtl_writephy(tp, 0x1f, 0x0001);
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index a9aa4a3fbfbe..deb1eca13c9f 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -77,7 +77,6 @@
77#include <linux/udp.h> 77#include <linux/udp.h>
78#include <linux/crc-ccitt.h> 78#include <linux/crc-ccitt.h>
79#include <linux/crc32.h> 79#include <linux/crc32.h>
80#include <linux/if_vlan.h>
81 80
82#include "via-velocity.h" 81#include "via-velocity.h"
83 82
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 40e95facdb6c..86127bcc9f7a 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -303,7 +303,6 @@ sbni_pci_probe( struct net_device *dev )
303 != NULL ) { 303 != NULL ) {
304 int pci_irq_line; 304 int pci_irq_line;
305 unsigned long pci_ioaddr; 305 unsigned long pci_ioaddr;
306 u16 subsys;
307 306
308 if( pdev->vendor != SBNI_PCI_VENDOR && 307 if( pdev->vendor != SBNI_PCI_VENDOR &&
309 pdev->device != SBNI_PCI_DEVICE ) 308 pdev->device != SBNI_PCI_DEVICE )
@@ -314,9 +313,7 @@ sbni_pci_probe( struct net_device *dev )
314 313
315 /* Avoid already found cards from previous calls */ 314 /* Avoid already found cards from previous calls */
316 if( !request_region( pci_ioaddr, SBNI_IO_EXTENT, dev->name ) ) { 315 if( !request_region( pci_ioaddr, SBNI_IO_EXTENT, dev->name ) ) {
317 pci_read_config_word( pdev, PCI_SUBSYSTEM_ID, &subsys ); 316 if (pdev->subsystem_device != 2)
318
319 if (subsys != 2)
320 continue; 317 continue;
321 318
322 /* Dual adapter is present */ 319 /* Dual adapter is present */
diff --git a/drivers/net/wireless/ath/ath5k/ahb.c b/drivers/net/wireless/ath/ath5k/ahb.c
index ba682a0b2dd8..9f69a4c9a3f3 100644
--- a/drivers/net/wireless/ath/ath5k/ahb.c
+++ b/drivers/net/wireless/ath/ath5k/ahb.c
@@ -35,8 +35,8 @@ static void ath5k_ahb_read_cachesize(struct ath_common *common, int *csz)
35static bool 35static bool
36ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data) 36ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
37{ 37{
38 struct ath5k_softc *sc = common->priv; 38 struct ath5k_hw *ah = common->priv;
39 struct platform_device *pdev = to_platform_device(sc->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 = pdev->dev.platform_data;
41 u16 *eeprom, *eeprom_end; 41 u16 *eeprom, *eeprom_end;
42 42
@@ -56,8 +56,7 @@ ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
56 56
57int ath5k_hw_read_srev(struct ath5k_hw *ah) 57int ath5k_hw_read_srev(struct ath5k_hw *ah)
58{ 58{
59 struct ath5k_softc *sc = ah->ah_sc; 59 struct platform_device *pdev = to_platform_device(ah->dev);
60 struct platform_device *pdev = to_platform_device(sc->dev);
61 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 60 struct ar231x_board_config *bcfg = pdev->dev.platform_data;
62 ah->ah_mac_srev = bcfg->devid; 61 ah->ah_mac_srev = bcfg->devid;
63 return 0; 62 return 0;
@@ -65,12 +64,11 @@ int ath5k_hw_read_srev(struct ath5k_hw *ah)
65 64
66static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac) 65static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
67{ 66{
68 struct ath5k_softc *sc = ah->ah_sc; 67 struct platform_device *pdev = to_platform_device(ah->dev);
69 struct platform_device *pdev = to_platform_device(sc->dev);
70 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 68 struct ar231x_board_config *bcfg = pdev->dev.platform_data;
71 u8 *cfg_mac; 69 u8 *cfg_mac;
72 70
73 if (to_platform_device(sc->dev)->id == 0) 71 if (to_platform_device(ah->dev)->id == 0)
74 cfg_mac = bcfg->config->wlan0_mac; 72 cfg_mac = bcfg->config->wlan0_mac;
75 else 73 else
76 cfg_mac = bcfg->config->wlan1_mac; 74 cfg_mac = bcfg->config->wlan1_mac;
@@ -90,7 +88,7 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {
90static int ath_ahb_probe(struct platform_device *pdev) 88static int ath_ahb_probe(struct platform_device *pdev)
91{ 89{
92 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 90 struct ar231x_board_config *bcfg = pdev->dev.platform_data;
93 struct ath5k_softc *sc; 91 struct ath5k_hw *ah;
94 struct ieee80211_hw *hw; 92 struct ieee80211_hw *hw;
95 struct resource *res; 93 struct resource *res;
96 void __iomem *mem; 94 void __iomem *mem;
@@ -127,19 +125,19 @@ static int ath_ahb_probe(struct platform_device *pdev)
127 125
128 irq = res->start; 126 irq = res->start;
129 127
130 hw = ieee80211_alloc_hw(sizeof(struct ath5k_softc), &ath5k_hw_ops); 128 hw = ieee80211_alloc_hw(sizeof(struct ath5k_hw), &ath5k_hw_ops);
131 if (hw == NULL) { 129 if (hw == NULL) {
132 dev_err(&pdev->dev, "no memory for ieee80211_hw\n"); 130 dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
133 ret = -ENOMEM; 131 ret = -ENOMEM;
134 goto err_out; 132 goto err_out;
135 } 133 }
136 134
137 sc = hw->priv; 135 ah = hw->priv;
138 sc->hw = hw; 136 ah->hw = hw;
139 sc->dev = &pdev->dev; 137 ah->dev = &pdev->dev;
140 sc->iobase = mem; 138 ah->iobase = mem;
141 sc->irq = irq; 139 ah->irq = irq;
142 sc->devid = bcfg->devid; 140 ah->devid = bcfg->devid;
143 141
144 if (bcfg->devid >= AR5K_SREV_AR2315_R6) { 142 if (bcfg->devid >= AR5K_SREV_AR2315_R6) {
145 /* Enable WMAC AHB arbitration */ 143 /* Enable WMAC AHB arbitration */
@@ -155,7 +153,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
155 /* Enable WMAC DMA access (assuming 5312 or 231x*/ 153 /* Enable WMAC DMA access (assuming 5312 or 231x*/
156 /* TODO: check other platforms */ 154 /* TODO: check other platforms */
157 reg = __raw_readl((void __iomem *) AR5K_AR5312_ENABLE); 155 reg = __raw_readl((void __iomem *) AR5K_AR5312_ENABLE);
158 if (to_platform_device(sc->dev)->id == 0) 156 if (to_platform_device(ah->dev)->id == 0)
159 reg |= AR5K_AR5312_ENABLE_WLAN0; 157 reg |= AR5K_AR5312_ENABLE_WLAN0;
160 else 158 else
161 reg |= AR5K_AR5312_ENABLE_WLAN1; 159 reg |= AR5K_AR5312_ENABLE_WLAN1;
@@ -166,13 +164,13 @@ static int ath_ahb_probe(struct platform_device *pdev)
166 * used as pass-through. Disable 2 GHz support in the 164 * used as pass-through. Disable 2 GHz support in the
167 * driver for it 165 * driver for it
168 */ 166 */
169 if (to_platform_device(sc->dev)->id == 0 && 167 if (to_platform_device(ah->dev)->id == 0 &&
170 (bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) == 168 (bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) ==
171 (BD_WLAN1 | BD_WLAN0)) 169 (BD_WLAN1 | BD_WLAN0))
172 __set_bit(ATH_STAT_2G_DISABLED, sc->status); 170 __set_bit(ATH_STAT_2G_DISABLED, ah->status);
173 } 171 }
174 172
175 ret = ath5k_init_softc(sc, &ath_ahb_bus_ops); 173 ret = ath5k_init_softc(ah, &ath_ahb_bus_ops);
176 if (ret != 0) { 174 if (ret != 0) {
177 dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret); 175 dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
178 ret = -ENODEV; 176 ret = -ENODEV;
@@ -194,13 +192,13 @@ static int ath_ahb_remove(struct platform_device *pdev)
194{ 192{
195 struct ar231x_board_config *bcfg = pdev->dev.platform_data; 193 struct ar231x_board_config *bcfg = pdev->dev.platform_data;
196 struct ieee80211_hw *hw = platform_get_drvdata(pdev); 194 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
197 struct ath5k_softc *sc; 195 struct ath5k_hw *ah;
198 u32 reg; 196 u32 reg;
199 197
200 if (!hw) 198 if (!hw)
201 return 0; 199 return 0;
202 200
203 sc = hw->priv; 201 ah = hw->priv;
204 202
205 if (bcfg->devid >= AR5K_SREV_AR2315_R6) { 203 if (bcfg->devid >= AR5K_SREV_AR2315_R6) {
206 /* Disable WMAC AHB arbitration */ 204 /* Disable WMAC AHB arbitration */
@@ -210,14 +208,14 @@ static int ath_ahb_remove(struct platform_device *pdev)
210 } else { 208 } else {
211 /*Stop DMA access */ 209 /*Stop DMA access */
212 reg = __raw_readl((void __iomem *) AR5K_AR5312_ENABLE); 210 reg = __raw_readl((void __iomem *) AR5K_AR5312_ENABLE);
213 if (to_platform_device(sc->dev)->id == 0) 211 if (to_platform_device(ah->dev)->id == 0)
214 reg &= ~AR5K_AR5312_ENABLE_WLAN0; 212 reg &= ~AR5K_AR5312_ENABLE_WLAN0;
215 else 213 else
216 reg &= ~AR5K_AR5312_ENABLE_WLAN1; 214 reg &= ~AR5K_AR5312_ENABLE_WLAN1;
217 __raw_writel(reg, (void __iomem *) AR5K_AR5312_ENABLE); 215 __raw_writel(reg, (void __iomem *) AR5K_AR5312_ENABLE);
218 } 216 }
219 217
220 ath5k_deinit_softc(sc); 218 ath5k_deinit_softc(ah);
221 platform_set_drvdata(pdev, NULL); 219 platform_set_drvdata(pdev, NULL);
222 ieee80211_free_hw(hw); 220 ieee80211_free_hw(hw);
223 221
diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c
index 2f0b967a6d8e..603ae15f139b 100644
--- a/drivers/net/wireless/ath/ath5k/ani.c
+++ b/drivers/net/wireless/ath/ath5k/ani.c
@@ -74,7 +74,7 @@ ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level)
74 static const s8 fr[] = { -78, -80 }; 74 static const s8 fr[] = { -78, -80 };
75#endif 75#endif
76 if (level < 0 || level >= ARRAY_SIZE(sz)) { 76 if (level < 0 || level >= ARRAY_SIZE(sz)) {
77 ATH5K_ERR(ah->ah_sc, "noise immunity level %d out of range", 77 ATH5K_ERR(ah, "noise immunity level %d out of range",
78 level); 78 level);
79 return; 79 return;
80 } 80 }
@@ -88,8 +88,8 @@ ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level)
88 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_SIG, 88 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_SIG,
89 AR5K_PHY_SIG_FIRPWR, fr[level]); 89 AR5K_PHY_SIG_FIRPWR, fr[level]);
90 90
91 ah->ah_sc->ani_state.noise_imm_level = level; 91 ah->ani_state.noise_imm_level = level;
92 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "new level %d", level); 92 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level);
93} 93}
94 94
95 95
@@ -105,8 +105,8 @@ ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level)
105 static const int val[] = { 2, 4, 6, 8, 10, 12, 14, 16 }; 105 static const int val[] = { 2, 4, 6, 8, 10, 12, 14, 16 };
106 106
107 if (level < 0 || level >= ARRAY_SIZE(val) || 107 if (level < 0 || level >= ARRAY_SIZE(val) ||
108 level > ah->ah_sc->ani_state.max_spur_level) { 108 level > ah->ani_state.max_spur_level) {
109 ATH5K_ERR(ah->ah_sc, "spur immunity level %d out of range", 109 ATH5K_ERR(ah, "spur immunity level %d out of range",
110 level); 110 level);
111 return; 111 return;
112 } 112 }
@@ -114,8 +114,8 @@ ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level)
114 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_OFDM_SELFCORR, 114 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_OFDM_SELFCORR,
115 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1, val[level]); 115 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1, val[level]);
116 116
117 ah->ah_sc->ani_state.spur_level = level; 117 ah->ani_state.spur_level = level;
118 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "new level %d", level); 118 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level);
119} 119}
120 120
121 121
@@ -130,15 +130,15 @@ ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level)
130 static const int val[] = { 0, 4, 8 }; 130 static const int val[] = { 0, 4, 8 };
131 131
132 if (level < 0 || level >= ARRAY_SIZE(val)) { 132 if (level < 0 || level >= ARRAY_SIZE(val)) {
133 ATH5K_ERR(ah->ah_sc, "firstep level %d out of range", level); 133 ATH5K_ERR(ah, "firstep level %d out of range", level);
134 return; 134 return;
135 } 135 }
136 136
137 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_SIG, 137 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_SIG,
138 AR5K_PHY_SIG_FIRSTEP, val[level]); 138 AR5K_PHY_SIG_FIRSTEP, val[level]);
139 139
140 ah->ah_sc->ani_state.firstep_level = level; 140 ah->ani_state.firstep_level = level;
141 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "new level %d", level); 141 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level);
142} 142}
143 143
144 144
@@ -178,8 +178,8 @@ ath5k_ani_set_ofdm_weak_signal_detection(struct ath5k_hw *ah, bool on)
178 AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_WEAK_OFDM_LOW_THR, 178 AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_WEAK_OFDM_LOW_THR,
179 AR5K_PHY_WEAK_OFDM_LOW_THR_SELFCOR_EN); 179 AR5K_PHY_WEAK_OFDM_LOW_THR_SELFCOR_EN);
180 180
181 ah->ah_sc->ani_state.ofdm_weak_sig = on; 181 ah->ani_state.ofdm_weak_sig = on;
182 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "turned %s", 182 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "turned %s",
183 on ? "on" : "off"); 183 on ? "on" : "off");
184} 184}
185 185
@@ -195,8 +195,8 @@ ath5k_ani_set_cck_weak_signal_detection(struct ath5k_hw *ah, bool on)
195 static const int val[] = { 8, 6 }; 195 static const int val[] = { 8, 6 };
196 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_CCK_CROSSCORR, 196 AR5K_REG_WRITE_BITS(ah, AR5K_PHY_CCK_CROSSCORR,
197 AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR, val[on]); 197 AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR, val[on]);
198 ah->ah_sc->ani_state.cck_weak_sig = on; 198 ah->ani_state.cck_weak_sig = on;
199 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "turned %s", 199 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "turned %s",
200 on ? "on" : "off"); 200 on ? "on" : "off");
201} 201}
202 202
@@ -218,7 +218,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
218{ 218{
219 int rssi = ewma_read(&ah->ah_beacon_rssi_avg); 219 int rssi = ewma_read(&ah->ah_beacon_rssi_avg);
220 220
221 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "raise immunity (%s)", 221 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "raise immunity (%s)",
222 ofdm_trigger ? "ODFM" : "CCK"); 222 ofdm_trigger ? "ODFM" : "CCK");
223 223
224 /* first: raise noise immunity */ 224 /* first: raise noise immunity */
@@ -229,13 +229,13 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
229 229
230 /* only OFDM: raise spur immunity level */ 230 /* only OFDM: raise spur immunity level */
231 if (ofdm_trigger && 231 if (ofdm_trigger &&
232 as->spur_level < ah->ah_sc->ani_state.max_spur_level) { 232 as->spur_level < ah->ani_state.max_spur_level) {
233 ath5k_ani_set_spur_immunity_level(ah, as->spur_level + 1); 233 ath5k_ani_set_spur_immunity_level(ah, as->spur_level + 1);
234 return; 234 return;
235 } 235 }
236 236
237 /* AP mode */ 237 /* AP mode */
238 if (ah->ah_sc->opmode == NL80211_IFTYPE_AP) { 238 if (ah->opmode == NL80211_IFTYPE_AP) {
239 if (as->firstep_level < ATH5K_ANI_MAX_FIRSTEP_LVL) 239 if (as->firstep_level < ATH5K_ANI_MAX_FIRSTEP_LVL)
240 ath5k_ani_set_firstep_level(ah, as->firstep_level + 1); 240 ath5k_ani_set_firstep_level(ah, as->firstep_level + 1);
241 return; 241 return;
@@ -248,7 +248,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
248 * don't shut out a remote node by raising immunity too high. */ 248 * don't shut out a remote node by raising immunity too high. */
249 249
250 if (rssi > ATH5K_ANI_RSSI_THR_HIGH) { 250 if (rssi > ATH5K_ANI_RSSI_THR_HIGH) {
251 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 251 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
252 "beacon RSSI high"); 252 "beacon RSSI high");
253 /* only OFDM: beacon RSSI is high, we can disable ODFM weak 253 /* only OFDM: beacon RSSI is high, we can disable ODFM weak
254 * signal detection */ 254 * signal detection */
@@ -265,7 +265,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
265 } else if (rssi > ATH5K_ANI_RSSI_THR_LOW) { 265 } else if (rssi > ATH5K_ANI_RSSI_THR_LOW) {
266 /* beacon RSSI in mid range, we need OFDM weak signal detect, 266 /* beacon RSSI in mid range, we need OFDM weak signal detect,
267 * but can raise firstep level */ 267 * but can raise firstep level */
268 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 268 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
269 "beacon RSSI mid"); 269 "beacon RSSI mid");
270 if (ofdm_trigger && as->ofdm_weak_sig == false) 270 if (ofdm_trigger && as->ofdm_weak_sig == false)
271 ath5k_ani_set_ofdm_weak_signal_detection(ah, true); 271 ath5k_ani_set_ofdm_weak_signal_detection(ah, true);
@@ -275,7 +275,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
275 } else if (ah->ah_current_channel->band == IEEE80211_BAND_2GHZ) { 275 } else if (ah->ah_current_channel->band == IEEE80211_BAND_2GHZ) {
276 /* beacon RSSI is low. in B/G mode turn of OFDM weak signal 276 /* beacon RSSI is low. in B/G mode turn of OFDM weak signal
277 * detect and zero firstep level to maximize CCK sensitivity */ 277 * detect and zero firstep level to maximize CCK sensitivity */
278 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 278 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
279 "beacon RSSI low, 2GHz"); 279 "beacon RSSI low, 2GHz");
280 if (ofdm_trigger && as->ofdm_weak_sig == true) 280 if (ofdm_trigger && as->ofdm_weak_sig == true)
281 ath5k_ani_set_ofdm_weak_signal_detection(ah, false); 281 ath5k_ani_set_ofdm_weak_signal_detection(ah, false);
@@ -303,9 +303,9 @@ ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as)
303{ 303{
304 int rssi = ewma_read(&ah->ah_beacon_rssi_avg); 304 int rssi = ewma_read(&ah->ah_beacon_rssi_avg);
305 305
306 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "lower immunity"); 306 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "lower immunity");
307 307
308 if (ah->ah_sc->opmode == NL80211_IFTYPE_AP) { 308 if (ah->opmode == NL80211_IFTYPE_AP) {
309 /* AP mode */ 309 /* AP mode */
310 if (as->firstep_level > 0) { 310 if (as->firstep_level > 0) {
311 ath5k_ani_set_firstep_level(ah, as->firstep_level - 1); 311 ath5k_ani_set_firstep_level(ah, as->firstep_level - 1);
@@ -464,7 +464,7 @@ ath5k_ani_period_restart(struct ath5k_hw *ah, struct ath5k_ani_state *as)
464void 464void
465ath5k_ani_calibration(struct ath5k_hw *ah) 465ath5k_ani_calibration(struct ath5k_hw *ah)
466{ 466{
467 struct ath5k_ani_state *as = &ah->ah_sc->ani_state; 467 struct ath5k_ani_state *as = &ah->ani_state;
468 int listen, ofdm_high, ofdm_low, cck_high, cck_low; 468 int listen, ofdm_high, ofdm_low, cck_high, cck_low;
469 469
470 /* get listen time since last call and add it to the counter because we 470 /* get listen time since last call and add it to the counter because we
@@ -483,9 +483,9 @@ ath5k_ani_calibration(struct ath5k_hw *ah)
483 ofdm_low = as->listen_time * ATH5K_ANI_OFDM_TRIG_LOW / 1000; 483 ofdm_low = as->listen_time * ATH5K_ANI_OFDM_TRIG_LOW / 1000;
484 cck_low = as->listen_time * ATH5K_ANI_CCK_TRIG_LOW / 1000; 484 cck_low = as->listen_time * ATH5K_ANI_CCK_TRIG_LOW / 1000;
485 485
486 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 486 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
487 "listen %d (now %d)", as->listen_time, listen); 487 "listen %d (now %d)", as->listen_time, listen);
488 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 488 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
489 "check high ofdm %d/%d cck %d/%d", 489 "check high ofdm %d/%d cck %d/%d",
490 as->ofdm_errors, ofdm_high, as->cck_errors, cck_high); 490 as->ofdm_errors, ofdm_high, as->cck_errors, cck_high);
491 491
@@ -498,7 +498,7 @@ ath5k_ani_calibration(struct ath5k_hw *ah)
498 } else if (as->listen_time > 5 * ATH5K_ANI_LISTEN_PERIOD) { 498 } else if (as->listen_time > 5 * ATH5K_ANI_LISTEN_PERIOD) {
499 /* If more than 5 (TODO: why 5?) periods have passed and we got 499 /* If more than 5 (TODO: why 5?) periods have passed and we got
500 * relatively little errors we can try to lower immunity */ 500 * relatively little errors we can try to lower immunity */
501 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 501 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
502 "check low ofdm %d/%d cck %d/%d", 502 "check low ofdm %d/%d cck %d/%d",
503 as->ofdm_errors, ofdm_low, as->cck_errors, cck_low); 503 as->ofdm_errors, ofdm_low, as->cck_errors, cck_low);
504 504
@@ -525,7 +525,7 @@ ath5k_ani_calibration(struct ath5k_hw *ah)
525void 525void
526ath5k_ani_mib_intr(struct ath5k_hw *ah) 526ath5k_ani_mib_intr(struct ath5k_hw *ah)
527{ 527{
528 struct ath5k_ani_state *as = &ah->ah_sc->ani_state; 528 struct ath5k_ani_state *as = &ah->ani_state;
529 529
530 /* nothing to do here if HW does not have PHY error counters - they 530 /* nothing to do here if HW does not have PHY error counters - they
531 * can't be the reason for the MIB interrupt then */ 531 * can't be the reason for the MIB interrupt then */
@@ -536,7 +536,7 @@ ath5k_ani_mib_intr(struct ath5k_hw *ah)
536 ath5k_hw_reg_write(ah, 0, AR5K_OFDM_FIL_CNT); 536 ath5k_hw_reg_write(ah, 0, AR5K_OFDM_FIL_CNT);
537 ath5k_hw_reg_write(ah, 0, AR5K_CCK_FIL_CNT); 537 ath5k_hw_reg_write(ah, 0, AR5K_CCK_FIL_CNT);
538 538
539 if (ah->ah_sc->ani_state.ani_mode != ATH5K_ANI_MODE_AUTO) 539 if (ah->ani_state.ani_mode != ATH5K_ANI_MODE_AUTO)
540 return; 540 return;
541 541
542 /* If one of the errors triggered, we can get a superfluous second 542 /* If one of the errors triggered, we can get a superfluous second
@@ -547,7 +547,7 @@ ath5k_ani_mib_intr(struct ath5k_hw *ah)
547 547
548 if (as->ofdm_errors > ATH5K_ANI_OFDM_TRIG_HIGH || 548 if (as->ofdm_errors > ATH5K_ANI_OFDM_TRIG_HIGH ||
549 as->cck_errors > ATH5K_ANI_CCK_TRIG_HIGH) 549 as->cck_errors > ATH5K_ANI_CCK_TRIG_HIGH)
550 tasklet_schedule(&ah->ah_sc->ani_tasklet); 550 tasklet_schedule(&ah->ani_tasklet);
551} 551}
552 552
553 553
@@ -561,16 +561,16 @@ void
561ath5k_ani_phy_error_report(struct ath5k_hw *ah, 561ath5k_ani_phy_error_report(struct ath5k_hw *ah,
562 enum ath5k_phy_error_code phyerr) 562 enum ath5k_phy_error_code phyerr)
563{ 563{
564 struct ath5k_ani_state *as = &ah->ah_sc->ani_state; 564 struct ath5k_ani_state *as = &ah->ani_state;
565 565
566 if (phyerr == AR5K_RX_PHY_ERROR_OFDM_TIMING) { 566 if (phyerr == AR5K_RX_PHY_ERROR_OFDM_TIMING) {
567 as->ofdm_errors++; 567 as->ofdm_errors++;
568 if (as->ofdm_errors > ATH5K_ANI_OFDM_TRIG_HIGH) 568 if (as->ofdm_errors > ATH5K_ANI_OFDM_TRIG_HIGH)
569 tasklet_schedule(&ah->ah_sc->ani_tasklet); 569 tasklet_schedule(&ah->ani_tasklet);
570 } else if (phyerr == AR5K_RX_PHY_ERROR_CCK_TIMING) { 570 } else if (phyerr == AR5K_RX_PHY_ERROR_CCK_TIMING) {
571 as->cck_errors++; 571 as->cck_errors++;
572 if (as->cck_errors > ATH5K_ANI_CCK_TRIG_HIGH) 572 if (as->cck_errors > ATH5K_ANI_CCK_TRIG_HIGH)
573 tasklet_schedule(&ah->ah_sc->ani_tasklet); 573 tasklet_schedule(&ah->ani_tasklet);
574 } 574 }
575} 575}
576 576
@@ -631,24 +631,24 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode)
631 return; 631 return;
632 632
633 if (mode < ATH5K_ANI_MODE_OFF || mode > ATH5K_ANI_MODE_AUTO) { 633 if (mode < ATH5K_ANI_MODE_OFF || mode > ATH5K_ANI_MODE_AUTO) {
634 ATH5K_ERR(ah->ah_sc, "ANI mode %d out of range", mode); 634 ATH5K_ERR(ah, "ANI mode %d out of range", mode);
635 return; 635 return;
636 } 636 }
637 637
638 /* clear old state information */ 638 /* clear old state information */
639 memset(&ah->ah_sc->ani_state, 0, sizeof(ah->ah_sc->ani_state)); 639 memset(&ah->ani_state, 0, sizeof(ah->ani_state));
640 640
641 /* older hardware has more spur levels than newer */ 641 /* older hardware has more spur levels than newer */
642 if (ah->ah_mac_srev < AR5K_SREV_AR2414) 642 if (ah->ah_mac_srev < AR5K_SREV_AR2414)
643 ah->ah_sc->ani_state.max_spur_level = 7; 643 ah->ani_state.max_spur_level = 7;
644 else 644 else
645 ah->ah_sc->ani_state.max_spur_level = 2; 645 ah->ani_state.max_spur_level = 2;
646 646
647 /* initial values for our ani parameters */ 647 /* initial values for our ani parameters */
648 if (mode == ATH5K_ANI_MODE_OFF) { 648 if (mode == ATH5K_ANI_MODE_OFF) {
649 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "ANI off\n"); 649 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "ANI off\n");
650 } else if (mode == ATH5K_ANI_MODE_MANUAL_LOW) { 650 } else if (mode == ATH5K_ANI_MODE_MANUAL_LOW) {
651 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 651 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
652 "ANI manual low -> high sensitivity\n"); 652 "ANI manual low -> high sensitivity\n");
653 ath5k_ani_set_noise_immunity_level(ah, 0); 653 ath5k_ani_set_noise_immunity_level(ah, 0);
654 ath5k_ani_set_spur_immunity_level(ah, 0); 654 ath5k_ani_set_spur_immunity_level(ah, 0);
@@ -656,17 +656,17 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode)
656 ath5k_ani_set_ofdm_weak_signal_detection(ah, true); 656 ath5k_ani_set_ofdm_weak_signal_detection(ah, true);
657 ath5k_ani_set_cck_weak_signal_detection(ah, true); 657 ath5k_ani_set_cck_weak_signal_detection(ah, true);
658 } else if (mode == ATH5K_ANI_MODE_MANUAL_HIGH) { 658 } else if (mode == ATH5K_ANI_MODE_MANUAL_HIGH) {
659 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, 659 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI,
660 "ANI manual high -> low sensitivity\n"); 660 "ANI manual high -> low sensitivity\n");
661 ath5k_ani_set_noise_immunity_level(ah, 661 ath5k_ani_set_noise_immunity_level(ah,
662 ATH5K_ANI_MAX_NOISE_IMM_LVL); 662 ATH5K_ANI_MAX_NOISE_IMM_LVL);
663 ath5k_ani_set_spur_immunity_level(ah, 663 ath5k_ani_set_spur_immunity_level(ah,
664 ah->ah_sc->ani_state.max_spur_level); 664 ah->ani_state.max_spur_level);
665 ath5k_ani_set_firstep_level(ah, ATH5K_ANI_MAX_FIRSTEP_LVL); 665 ath5k_ani_set_firstep_level(ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
666 ath5k_ani_set_ofdm_weak_signal_detection(ah, false); 666 ath5k_ani_set_ofdm_weak_signal_detection(ah, false);
667 ath5k_ani_set_cck_weak_signal_detection(ah, false); 667 ath5k_ani_set_cck_weak_signal_detection(ah, false);
668 } else if (mode == ATH5K_ANI_MODE_AUTO) { 668 } else if (mode == ATH5K_ANI_MODE_AUTO) {
669 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "ANI auto\n"); 669 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "ANI auto\n");
670 ath5k_ani_set_noise_immunity_level(ah, 0); 670 ath5k_ani_set_noise_immunity_level(ah, 0);
671 ath5k_ani_set_spur_immunity_level(ah, 0); 671 ath5k_ani_set_spur_immunity_level(ah, 0);
672 ath5k_ani_set_firstep_level(ah, 0); 672 ath5k_ani_set_firstep_level(ah, 0);
@@ -692,7 +692,7 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode)
692 ~AR5K_RX_FILTER_PHYERR); 692 ~AR5K_RX_FILTER_PHYERR);
693 } 693 }
694 694
695 ah->ah_sc->ani_state.ani_mode = mode; 695 ah->ani_state.ani_mode = mode;
696} 696}
697 697
698 698
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 8ff17941bb28..277d5cbe0068 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -24,8 +24,10 @@
24#define CHAN_DEBUG 0 24#define CHAN_DEBUG 0
25 25
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/interrupt.h>
27#include <linux/types.h> 28#include <linux/types.h>
28#include <linux/average.h> 29#include <linux/average.h>
30#include <linux/leds.h>
29#include <net/mac80211.h> 31#include <net/mac80211.h>
30 32
31/* RX/TX descriptor hw structs 33/* RX/TX descriptor hw structs
@@ -36,7 +38,9 @@
36 * TODO: Make a more generic struct (eg. add more stuff to ath5k_capabilities) 38 * TODO: Make a more generic struct (eg. add more stuff to ath5k_capabilities)
37 * and clean up common bits, then introduce set/get functions in eeprom.c */ 39 * and clean up common bits, then introduce set/get functions in eeprom.c */
38#include "eeprom.h" 40#include "eeprom.h"
41#include "debug.h"
39#include "../ath.h" 42#include "../ath.h"
43#include "ani.h"
40 44
41/* PCI IDs */ 45/* PCI IDs */
42#define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007 /* AR5210 */ 46#define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007 /* AR5210 */
@@ -538,6 +542,27 @@ enum ath5k_tx_queue_id {
538#define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x2000 /* Enable hw compression -not implemented-*/ 542#define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x2000 /* Enable hw compression -not implemented-*/
539 543
540/* 544/*
545 * Data transmit queue state. One of these exists for each
546 * hardware transmit queue. Packets sent to us from above
547 * are assigned to queues based on their priority. Not all
548 * devices support a complete set of hardware transmit queues.
549 * For those devices the array sc_ac2q will map multiple
550 * priorities to fewer hardware queues (typically all to one
551 * hardware queue).
552 */
553struct ath5k_txq {
554 unsigned int qnum; /* hardware q number */
555 u32 *link; /* link ptr in last TX desc */
556 struct list_head q; /* transmit queue */
557 spinlock_t lock; /* lock on q and link */
558 bool setup;
559 int txq_len; /* number of queued buffers */
560 int txq_max; /* max allowed num of queued buffers */
561 bool txq_poll_mark;
562 unsigned int txq_stuck; /* informational counter */
563};
564
565/*
541 * A struct to hold tx queue's parameters 566 * A struct to hold tx queue's parameters
542 */ 567 */
543struct ath5k_txq_info { 568struct ath5k_txq_info {
@@ -947,35 +972,6 @@ enum ath5k_power_mode {
947#define AR5K_SOFTLED_ON 0 972#define AR5K_SOFTLED_ON 0
948#define AR5K_SOFTLED_OFF 1 973#define AR5K_SOFTLED_OFF 1
949 974
950/*
951 * Chipset capabilities -see ath5k_hw_get_capability-
952 * get_capability function is not yet fully implemented
953 * in ath5k so most of these don't work yet...
954 * TODO: Implement these & merge with _TUNE_ stuff above
955 */
956enum ath5k_capability_type {
957 AR5K_CAP_REG_DMN = 0, /* Used to get current reg. domain id */
958 AR5K_CAP_TKIP_MIC = 2, /* Can handle TKIP MIC in hardware */
959 AR5K_CAP_TKIP_SPLIT = 3, /* TKIP uses split keys */
960 AR5K_CAP_PHYCOUNTERS = 4, /* PHY error counters */
961 AR5K_CAP_DIVERSITY = 5, /* Supports fast diversity */
962 AR5K_CAP_NUM_TXQUEUES = 6, /* Used to get max number of hw txqueues */
963 AR5K_CAP_VEOL = 7, /* Supports virtual EOL */
964 AR5K_CAP_COMPRESSION = 8, /* Supports compression */
965 AR5K_CAP_BURST = 9, /* Supports packet bursting */
966 AR5K_CAP_FASTFRAME = 10, /* Supports fast frames */
967 AR5K_CAP_TXPOW = 11, /* Used to get global tx power limit */
968 AR5K_CAP_TPC = 12, /* Can do per-packet tx power control (needed for 802.11a) */
969 AR5K_CAP_BSSIDMASK = 13, /* Supports bssid mask */
970 AR5K_CAP_MCAST_KEYSRCH = 14, /* Supports multicast key search */
971 AR5K_CAP_TSF_ADJUST = 15, /* Supports beacon tsf adjust */
972 AR5K_CAP_XR = 16, /* Supports XR mode */
973 AR5K_CAP_WME_TKIPMIC = 17, /* Supports TKIP MIC when using WMM */
974 AR5K_CAP_CHAN_HALFRATE = 18, /* Supports half rate channels */
975 AR5K_CAP_CHAN_QUARTERRATE = 19, /* Supports quarter rate channels */
976 AR5K_CAP_RFSILENT = 20, /* Supports RFsilent */
977};
978
979 975
980/* XXX: we *may* move cap_range stuff to struct wiphy */ 976/* XXX: we *may* move cap_range stuff to struct wiphy */
981struct ath5k_capabilities { 977struct ath5k_capabilities {
@@ -1027,9 +1023,66 @@ struct ath5k_avg_val {
1027 int avg_weight; 1023 int avg_weight;
1028}; 1024};
1029 1025
1030/***************************************\ 1026#define ATH5K_LED_MAX_NAME_LEN 31
1031 HARDWARE ABSTRACTION LAYER STRUCTURE 1027
1032\***************************************/ 1028/*
1029 * State for LED triggers
1030 */
1031struct ath5k_led {
1032 char name[ATH5K_LED_MAX_NAME_LEN + 1]; /* name of the LED in sysfs */
1033 struct ath5k_hw *ah; /* driver state */
1034 struct led_classdev led_dev; /* led classdev */
1035};
1036
1037/* Rfkill */
1038struct ath5k_rfkill {
1039 /* GPIO PIN for rfkill */
1040 u16 gpio;
1041 /* polarity of rfkill GPIO PIN */
1042 bool polarity;
1043 /* RFKILL toggle tasklet */
1044 struct tasklet_struct toggleq;
1045};
1046
1047/* statistics */
1048struct ath5k_statistics {
1049 /* antenna use */
1050 unsigned int antenna_rx[5]; /* frames count per antenna RX */
1051 unsigned int antenna_tx[5]; /* frames count per antenna TX */
1052
1053 /* frame errors */
1054 unsigned int rx_all_count; /* all RX frames, including errors */
1055 unsigned int tx_all_count; /* all TX frames, including errors */
1056 unsigned int rx_bytes_count; /* all RX bytes, including errored pkts
1057 * and the MAC headers for each packet
1058 */
1059 unsigned int tx_bytes_count; /* all TX bytes, including errored pkts
1060 * and the MAC headers and padding for
1061 * each packet.
1062 */
1063 unsigned int rxerr_crc;
1064 unsigned int rxerr_phy;
1065 unsigned int rxerr_phy_code[32];
1066 unsigned int rxerr_fifo;
1067 unsigned int rxerr_decrypt;
1068 unsigned int rxerr_mic;
1069 unsigned int rxerr_proc;
1070 unsigned int rxerr_jumbo;
1071 unsigned int txerr_retry;
1072 unsigned int txerr_fifo;
1073 unsigned int txerr_filt;
1074
1075 /* MIB counters */
1076 unsigned int ack_fail;
1077 unsigned int rts_fail;
1078 unsigned int rts_ok;
1079 unsigned int fcs_error;
1080 unsigned int beacons;
1081
1082 unsigned int mib_intr;
1083 unsigned int rxorn_intr;
1084 unsigned int rxeol_intr;
1085};
1033 1086
1034/* 1087/*
1035 * Misc defines 1088 * Misc defines
@@ -1038,12 +1091,114 @@ struct ath5k_avg_val {
1038#define AR5K_MAX_GPIO 10 1091#define AR5K_MAX_GPIO 10
1039#define AR5K_MAX_RF_BANKS 8 1092#define AR5K_MAX_RF_BANKS 8
1040 1093
1041/* TODO: Clean up and merge with ath5k_softc */ 1094#if CHAN_DEBUG
1095#define ATH_CHAN_MAX (26 + 26 + 26 + 200 + 200)
1096#else
1097#define ATH_CHAN_MAX (14 + 14 + 14 + 252 + 20)
1098#endif
1099
1100#define ATH_RXBUF 40 /* number of RX buffers */
1101#define ATH_TXBUF 200 /* number of TX buffers */
1102#define ATH_BCBUF 4 /* number of beacon buffers */
1103#define ATH5K_TXQ_LEN_MAX (ATH_TXBUF / 4) /* bufs per queue */
1104#define ATH5K_TXQ_LEN_LOW (ATH5K_TXQ_LEN_MAX / 2) /* low mark */
1105
1106/* Driver state associated with an instance of a device */
1042struct ath5k_hw { 1107struct ath5k_hw {
1043 struct ath_common common; 1108 struct ath_common common;
1044 1109
1045 struct ath5k_softc *ah_sc; 1110 struct pci_dev *pdev;
1046 void __iomem *ah_iobase; 1111 struct device *dev; /* for dma mapping */
1112 int irq;
1113 u16 devid;
1114 void __iomem *iobase; /* address of the device */
1115 struct mutex lock; /* dev-level lock */
1116 struct ieee80211_hw *hw; /* IEEE 802.11 common */
1117 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
1118 struct ieee80211_channel channels[ATH_CHAN_MAX];
1119 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
1120 s8 rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
1121 enum nl80211_iftype opmode;
1122
1123#ifdef CONFIG_ATH5K_DEBUG
1124 struct ath5k_dbg_info debug; /* debug info */
1125#endif /* CONFIG_ATH5K_DEBUG */
1126
1127 struct ath5k_buf *bufptr; /* allocated buffer ptr */
1128 struct ath5k_desc *desc; /* TX/RX descriptors */
1129 dma_addr_t desc_daddr; /* DMA (physical) address */
1130 size_t desc_len; /* size of TX/RX descriptors */
1131
1132 DECLARE_BITMAP(status, 6);
1133#define ATH_STAT_INVALID 0 /* disable hardware accesses */
1134#define ATH_STAT_MRRETRY 1 /* multi-rate retry support */
1135#define ATH_STAT_PROMISC 2
1136#define ATH_STAT_LEDSOFT 3 /* enable LED gpio status */
1137#define ATH_STAT_STARTED 4 /* opened & irqs enabled */
1138#define ATH_STAT_2G_DISABLED 5 /* multiband radio without 2G */
1139
1140 unsigned int filter_flags; /* HW flags, AR5K_RX_FILTER_* */
1141 struct ieee80211_channel *curchan; /* current h/w channel */
1142
1143 u16 nvifs;
1144
1145 enum ath5k_int imask; /* interrupt mask copy */
1146
1147 spinlock_t irqlock;
1148 bool rx_pending; /* rx tasklet pending */
1149 bool tx_pending; /* tx tasklet pending */
1150
1151 u8 lladdr[ETH_ALEN];
1152 u8 bssidmask[ETH_ALEN];
1153
1154 unsigned int led_pin, /* GPIO pin for driving LED */
1155 led_on; /* pin setting for LED on */
1156
1157 struct work_struct reset_work; /* deferred chip reset */
1158
1159 unsigned int rxbufsize; /* rx size based on mtu */
1160 struct list_head rxbuf; /* receive buffer */
1161 spinlock_t rxbuflock;
1162 u32 *rxlink; /* link ptr in last RX desc */
1163 struct tasklet_struct rxtq; /* rx intr tasklet */
1164 struct ath5k_led rx_led; /* rx led */
1165
1166 struct list_head txbuf; /* transmit buffer */
1167 spinlock_t txbuflock;
1168 unsigned int txbuf_len; /* buf count in txbuf list */
1169 struct ath5k_txq txqs[AR5K_NUM_TX_QUEUES]; /* tx queues */
1170 struct tasklet_struct txtq; /* tx intr tasklet */
1171 struct ath5k_led tx_led; /* tx led */
1172
1173 struct ath5k_rfkill rf_kill;
1174
1175 struct tasklet_struct calib; /* calibration tasklet */
1176
1177 spinlock_t block; /* protects beacon */
1178 struct tasklet_struct beacontq; /* beacon intr tasklet */
1179 struct list_head bcbuf; /* beacon buffer */
1180 struct ieee80211_vif *bslot[ATH_BCBUF];
1181 u16 num_ap_vifs;
1182 u16 num_adhoc_vifs;
1183 unsigned int bhalq, /* SW q for outgoing beacons */
1184 bmisscount, /* missed beacon transmits */
1185 bintval, /* beacon interval in TU */
1186 bsent;
1187 unsigned int nexttbtt; /* next beacon time in TU */
1188 struct ath5k_txq *cabq; /* content after beacon */
1189
1190 int power_level; /* Requested tx power in dBm */
1191 bool assoc; /* associate state */
1192 bool enable_beacon; /* true if beacons are on */
1193
1194 struct ath5k_statistics stats;
1195
1196 struct ath5k_ani_state ani_state;
1197 struct tasklet_struct ani_tasklet; /* ANI calibration */
1198
1199 struct delayed_work tx_complete_work;
1200
1201 struct survey_info survey; /* collected survey info */
1047 1202
1048 enum ath5k_int ah_imr; 1203 enum ath5k_int ah_imr;
1049 1204
@@ -1172,43 +1327,43 @@ struct ath_bus_ops {
1172extern const struct ieee80211_ops ath5k_hw_ops; 1327extern const struct ieee80211_ops ath5k_hw_ops;
1173 1328
1174/* Initialization and detach functions */ 1329/* Initialization and detach functions */
1175int ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops); 1330int ath5k_init_softc(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops);
1176void ath5k_deinit_softc(struct ath5k_softc *sc); 1331void ath5k_deinit_softc(struct ath5k_hw *ah);
1177int ath5k_hw_init(struct ath5k_softc *sc); 1332int ath5k_hw_init(struct ath5k_hw *ah);
1178void ath5k_hw_deinit(struct ath5k_hw *ah); 1333void ath5k_hw_deinit(struct ath5k_hw *ah);
1179 1334
1180int ath5k_sysfs_register(struct ath5k_softc *sc); 1335int ath5k_sysfs_register(struct ath5k_hw *ah);
1181void ath5k_sysfs_unregister(struct ath5k_softc *sc); 1336void ath5k_sysfs_unregister(struct ath5k_hw *ah);
1182 1337
1183/* base.c */ 1338/* base.c */
1184struct ath5k_buf; 1339struct ath5k_buf;
1185struct ath5k_txq; 1340struct ath5k_txq;
1186 1341
1187void ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable); 1342void ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable);
1188bool ath5k_any_vif_assoc(struct ath5k_softc *sc); 1343bool ath5k_any_vif_assoc(struct ath5k_hw *ah);
1189void ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, 1344void ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
1190 struct ath5k_txq *txq); 1345 struct ath5k_txq *txq);
1191int ath5k_init_hw(struct ath5k_softc *sc); 1346int ath5k_start(struct ieee80211_hw *hw);
1192int ath5k_stop_hw(struct ath5k_softc *sc); 1347void ath5k_stop(struct ieee80211_hw *hw);
1193void ath5k_mode_setup(struct ath5k_softc *sc, struct ieee80211_vif *vif); 1348void ath5k_mode_setup(struct ath5k_hw *ah, struct ieee80211_vif *vif);
1194void ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc, 1349void ath5k_update_bssid_mask_and_opmode(struct ath5k_hw *ah,
1195 struct ieee80211_vif *vif); 1350 struct ieee80211_vif *vif);
1196int ath5k_chan_set(struct ath5k_softc *sc, struct ieee80211_channel *chan); 1351int ath5k_chan_set(struct ath5k_hw *ah, struct ieee80211_channel *chan);
1197void ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf); 1352void ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf);
1198int ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif); 1353int ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
1199void ath5k_beacon_config(struct ath5k_softc *sc); 1354void ath5k_beacon_config(struct ath5k_hw *ah);
1200void ath5k_txbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf); 1355void ath5k_txbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf);
1201void ath5k_rxbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf); 1356void ath5k_rxbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf);
1202 1357
1203/*Chip id helper functions */ 1358/*Chip id helper functions */
1204const char *ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val); 1359const char *ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val);
1205int ath5k_hw_read_srev(struct ath5k_hw *ah); 1360int ath5k_hw_read_srev(struct ath5k_hw *ah);
1206 1361
1207/* LED functions */ 1362/* LED functions */
1208int ath5k_init_leds(struct ath5k_softc *sc); 1363int ath5k_init_leds(struct ath5k_hw *ah);
1209void ath5k_led_enable(struct ath5k_softc *sc); 1364void ath5k_led_enable(struct ath5k_hw *ah);
1210void ath5k_led_off(struct ath5k_softc *sc); 1365void ath5k_led_off(struct ath5k_hw *ah);
1211void ath5k_unregister_leds(struct ath5k_softc *sc); 1366void ath5k_unregister_leds(struct ath5k_hw *ah);
1212 1367
1213 1368
1214/* Reset Functions */ 1369/* Reset Functions */
@@ -1322,9 +1477,6 @@ void ath5k_rfkill_hw_stop(struct ath5k_hw *ah);
1322 1477
1323/* Misc functions TODO: Cleanup */ 1478/* Misc functions TODO: Cleanup */
1324int ath5k_hw_set_capabilities(struct ath5k_hw *ah); 1479int ath5k_hw_set_capabilities(struct ath5k_hw *ah);
1325int ath5k_hw_get_capability(struct ath5k_hw *ah,
1326 enum ath5k_capability_type cap_type, u32 capability,
1327 u32 *result);
1328int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id); 1480int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id);
1329int ath5k_hw_disable_pspoll(struct ath5k_hw *ah); 1481int ath5k_hw_disable_pspoll(struct ath5k_hw *ah);
1330 1482
@@ -1384,7 +1536,7 @@ static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
1384 (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6))) 1536 (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6)))
1385 return AR5K_AR2315_PCI_BASE + reg; 1537 return AR5K_AR2315_PCI_BASE + reg;
1386 1538
1387 return ah->ah_iobase + reg; 1539 return ah->iobase + reg;
1388} 1540}
1389 1541
1390static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) 1542static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
@@ -1401,12 +1553,12 @@ static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
1401 1553
1402static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) 1554static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
1403{ 1555{
1404 return ioread32(ah->ah_iobase + reg); 1556 return ioread32(ah->iobase + reg);
1405} 1557}
1406 1558
1407static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) 1559static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
1408{ 1560{
1409 iowrite32(val, ah->ah_iobase + reg); 1561 iowrite32(val, ah->iobase + reg);
1410} 1562}
1411 1563
1412#endif 1564#endif
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 14dc52e4b50a..f8a6b380d96d 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -59,7 +59,7 @@ static int ath5k_hw_post(struct ath5k_hw *ah)
59 cur_val = ath5k_hw_reg_read(ah, cur_reg); 59 cur_val = ath5k_hw_reg_read(ah, cur_reg);
60 60
61 if (cur_val != var_pattern) { 61 if (cur_val != var_pattern) {
62 ATH5K_ERR(ah->ah_sc, "POST Failed !!!\n"); 62 ATH5K_ERR(ah, "POST Failed !!!\n");
63 return -EAGAIN; 63 return -EAGAIN;
64 } 64 }
65 65
@@ -74,7 +74,7 @@ static int ath5k_hw_post(struct ath5k_hw *ah)
74 cur_val = ath5k_hw_reg_read(ah, cur_reg); 74 cur_val = ath5k_hw_reg_read(ah, cur_reg);
75 75
76 if (cur_val != var_pattern) { 76 if (cur_val != var_pattern) {
77 ATH5K_ERR(ah->ah_sc, "POST Failed !!!\n"); 77 ATH5K_ERR(ah, "POST Failed !!!\n");
78 return -EAGAIN; 78 return -EAGAIN;
79 } 79 }
80 80
@@ -95,19 +95,18 @@ static int ath5k_hw_post(struct ath5k_hw *ah)
95/** 95/**
96 * ath5k_hw_init - Check if hw is supported and init the needed structs 96 * ath5k_hw_init - Check if hw is supported and init the needed structs
97 * 97 *
98 * @sc: The &struct ath5k_softc we got from the driver's init_softc function 98 * @ah: The &struct ath5k_hw we got from the driver's init_softc function
99 * 99 *
100 * Check if the device is supported, perform a POST and initialize the needed 100 * Check if the device is supported, perform a POST and initialize the needed
101 * structs. Returns -ENOMEM if we don't have memory for the needed structs, 101 * structs. Returns -ENOMEM if we don't have memory for the needed structs,
102 * -ENODEV if the device is not supported or prints an error msg if something 102 * -ENODEV if the device is not supported or prints an error msg if something
103 * else went wrong. 103 * else went wrong.
104 */ 104 */
105int ath5k_hw_init(struct ath5k_softc *sc) 105int ath5k_hw_init(struct ath5k_hw *ah)
106{ 106{
107 static const u8 zero_mac[ETH_ALEN] = { }; 107 static const u8 zero_mac[ETH_ALEN] = { };
108 struct ath5k_hw *ah = sc->ah;
109 struct ath_common *common = ath5k_hw_common(ah); 108 struct ath_common *common = ath5k_hw_common(ah);
110 struct pci_dev *pdev = sc->pdev; 109 struct pci_dev *pdev = ah->pdev;
111 struct ath5k_eeprom_info *ee; 110 struct ath5k_eeprom_info *ee;
112 int ret; 111 int ret;
113 u32 srev; 112 u32 srev;
@@ -123,8 +122,8 @@ int ath5k_hw_init(struct ath5k_softc *sc)
123 ah->ah_retry_long = AR5K_INIT_RETRY_LONG; 122 ah->ah_retry_long = AR5K_INIT_RETRY_LONG;
124 ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT; 123 ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT;
125 ah->ah_noise_floor = -95; /* until first NF calibration is run */ 124 ah->ah_noise_floor = -95; /* until first NF calibration is run */
126 sc->ani_state.ani_mode = ATH5K_ANI_MODE_AUTO; 125 ah->ani_state.ani_mode = ATH5K_ANI_MODE_AUTO;
127 ah->ah_current_channel = &sc->channels[0]; 126 ah->ah_current_channel = &ah->channels[0];
128 127
129 /* 128 /*
130 * Find the mac version 129 * Find the mac version
@@ -237,7 +236,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
237 ah->ah_single_chip = true; 236 ah->ah_single_chip = true;
238 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2413; 237 ah->ah_radio_5ghz_revision = AR5K_SREV_RAD_2413;
239 } else { 238 } else {
240 ATH5K_ERR(sc, "Couldn't identify radio revision.\n"); 239 ATH5K_ERR(ah, "Couldn't identify radio revision.\n");
241 ret = -ENODEV; 240 ret = -ENODEV;
242 goto err; 241 goto err;
243 } 242 }
@@ -246,7 +245,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
246 245
247 /* Return on unsupported chips (unsupported eeprom etc) */ 246 /* Return on unsupported chips (unsupported eeprom etc) */
248 if ((srev >= AR5K_SREV_AR5416) && (srev < AR5K_SREV_AR2425)) { 247 if ((srev >= AR5K_SREV_AR5416) && (srev < AR5K_SREV_AR2425)) {
249 ATH5K_ERR(sc, "Device not yet supported.\n"); 248 ATH5K_ERR(ah, "Device not yet supported.\n");
250 ret = -ENODEV; 249 ret = -ENODEV;
251 goto err; 250 goto err;
252 } 251 }
@@ -268,7 +267,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
268 */ 267 */
269 ret = ath5k_eeprom_init(ah); 268 ret = ath5k_eeprom_init(ah);
270 if (ret) { 269 if (ret) {
271 ATH5K_ERR(sc, "unable to init EEPROM\n"); 270 ATH5K_ERR(ah, "unable to init EEPROM\n");
272 goto err; 271 goto err;
273 } 272 }
274 273
@@ -309,17 +308,17 @@ int ath5k_hw_init(struct ath5k_softc *sc)
309 /* Get misc capabilities */ 308 /* Get misc capabilities */
310 ret = ath5k_hw_set_capabilities(ah); 309 ret = ath5k_hw_set_capabilities(ah);
311 if (ret) { 310 if (ret) {
312 ATH5K_ERR(sc, "unable to get device capabilities\n"); 311 ATH5K_ERR(ah, "unable to get device capabilities\n");
313 goto err; 312 goto err;
314 } 313 }
315 314
316 if (test_bit(ATH_STAT_2G_DISABLED, sc->status)) { 315 if (test_bit(ATH_STAT_2G_DISABLED, ah->status)) {
317 __clear_bit(AR5K_MODE_11B, ah->ah_capabilities.cap_mode); 316 __clear_bit(AR5K_MODE_11B, ah->ah_capabilities.cap_mode);
318 __clear_bit(AR5K_MODE_11G, ah->ah_capabilities.cap_mode); 317 __clear_bit(AR5K_MODE_11G, ah->ah_capabilities.cap_mode);
319 } 318 }
320 319
321 /* Crypto settings */ 320 /* Crypto settings */
322 common->keymax = (sc->ah->ah_version == AR5K_AR5210 ? 321 common->keymax = (ah->ah_version == AR5K_AR5210 ?
323 AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211); 322 AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211);
324 323
325 if (srev >= AR5K_SREV_AR5212_V4 && 324 if (srev >= AR5K_SREV_AR5212_V4 &&
@@ -339,7 +338,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
339 /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */ 338 /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
340 memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN); 339 memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN);
341 ath5k_hw_set_bssid(ah); 340 ath5k_hw_set_bssid(ah);
342 ath5k_hw_set_opmode(ah, sc->opmode); 341 ath5k_hw_set_opmode(ah, ah->opmode);
343 342
344 ath5k_hw_rfgain_opt_init(ah); 343 ath5k_hw_rfgain_opt_init(ah);
345 344
@@ -360,7 +359,7 @@ err:
360 */ 359 */
361void ath5k_hw_deinit(struct ath5k_hw *ah) 360void ath5k_hw_deinit(struct ath5k_hw *ah)
362{ 361{
363 __set_bit(ATH_STAT_INVALID, ah->ah_sc->status); 362 __set_bit(ATH_STAT_INVALID, ah->status);
364 363
365 if (ah->ah_rf_banks != NULL) 364 if (ah->ah_rf_banks != NULL)
366 kfree(ah->ah_rf_banks); 365 kfree(ah->ah_rf_banks);
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index dce848f76d7c..f54dff44ed50 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -86,7 +86,7 @@ MODULE_SUPPORTED_DEVICE("Atheros 5xxx WLAN cards");
86MODULE_LICENSE("Dual BSD/GPL"); 86MODULE_LICENSE("Dual BSD/GPL");
87 87
88static int ath5k_init(struct ieee80211_hw *hw); 88static int ath5k_init(struct ieee80211_hw *hw);
89static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan, 89static int ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan,
90 bool skip_pcu); 90 bool skip_pcu);
91 91
92/* Known SREVs */ 92/* Known SREVs */
@@ -238,8 +238,8 @@ static const struct ath_ops ath5k_common_ops = {
238static int ath5k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) 238static int ath5k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
239{ 239{
240 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); 240 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
241 struct ath5k_softc *sc = hw->priv; 241 struct ath5k_hw *ah = hw->priv;
242 struct ath_regulatory *regulatory = ath5k_hw_regulatory(sc->ah); 242 struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah);
243 243
244 return ath_reg_notifier_apply(wiphy, request, regulatory); 244 return ath_reg_notifier_apply(wiphy, request, regulatory);
245} 245}
@@ -289,7 +289,7 @@ ath5k_setup_channels(struct ath5k_hw *ah, struct ieee80211_channel *channels,
289 band = IEEE80211_BAND_2GHZ; 289 band = IEEE80211_BAND_2GHZ;
290 break; 290 break;
291 default: 291 default:
292 ATH5K_WARN(ah->ah_sc, "bad mode, not copying channels\n"); 292 ATH5K_WARN(ah, "bad mode, not copying channels\n");
293 return 0; 293 return 0;
294 } 294 }
295 295
@@ -327,51 +327,50 @@ ath5k_setup_channels(struct ath5k_hw *ah, struct ieee80211_channel *channels,
327} 327}
328 328
329static void 329static void
330ath5k_setup_rate_idx(struct ath5k_softc *sc, struct ieee80211_supported_band *b) 330ath5k_setup_rate_idx(struct ath5k_hw *ah, struct ieee80211_supported_band *b)
331{ 331{
332 u8 i; 332 u8 i;
333 333
334 for (i = 0; i < AR5K_MAX_RATES; i++) 334 for (i = 0; i < AR5K_MAX_RATES; i++)
335 sc->rate_idx[b->band][i] = -1; 335 ah->rate_idx[b->band][i] = -1;
336 336
337 for (i = 0; i < b->n_bitrates; i++) { 337 for (i = 0; i < b->n_bitrates; i++) {
338 sc->rate_idx[b->band][b->bitrates[i].hw_value] = i; 338 ah->rate_idx[b->band][b->bitrates[i].hw_value] = i;
339 if (b->bitrates[i].hw_value_short) 339 if (b->bitrates[i].hw_value_short)
340 sc->rate_idx[b->band][b->bitrates[i].hw_value_short] = i; 340 ah->rate_idx[b->band][b->bitrates[i].hw_value_short] = i;
341 } 341 }
342} 342}
343 343
344static int 344static int
345ath5k_setup_bands(struct ieee80211_hw *hw) 345ath5k_setup_bands(struct ieee80211_hw *hw)
346{ 346{
347 struct ath5k_softc *sc = hw->priv; 347 struct ath5k_hw *ah = hw->priv;
348 struct ath5k_hw *ah = sc->ah;
349 struct ieee80211_supported_band *sband; 348 struct ieee80211_supported_band *sband;
350 int max_c, count_c = 0; 349 int max_c, count_c = 0;
351 int i; 350 int i;
352 351
353 BUILD_BUG_ON(ARRAY_SIZE(sc->sbands) < IEEE80211_NUM_BANDS); 352 BUILD_BUG_ON(ARRAY_SIZE(ah->sbands) < IEEE80211_NUM_BANDS);
354 max_c = ARRAY_SIZE(sc->channels); 353 max_c = ARRAY_SIZE(ah->channels);
355 354
356 /* 2GHz band */ 355 /* 2GHz band */
357 sband = &sc->sbands[IEEE80211_BAND_2GHZ]; 356 sband = &ah->sbands[IEEE80211_BAND_2GHZ];
358 sband->band = IEEE80211_BAND_2GHZ; 357 sband->band = IEEE80211_BAND_2GHZ;
359 sband->bitrates = &sc->rates[IEEE80211_BAND_2GHZ][0]; 358 sband->bitrates = &ah->rates[IEEE80211_BAND_2GHZ][0];
360 359
361 if (test_bit(AR5K_MODE_11G, sc->ah->ah_capabilities.cap_mode)) { 360 if (test_bit(AR5K_MODE_11G, ah->ah_capabilities.cap_mode)) {
362 /* G mode */ 361 /* G mode */
363 memcpy(sband->bitrates, &ath5k_rates[0], 362 memcpy(sband->bitrates, &ath5k_rates[0],
364 sizeof(struct ieee80211_rate) * 12); 363 sizeof(struct ieee80211_rate) * 12);
365 sband->n_bitrates = 12; 364 sband->n_bitrates = 12;
366 365
367 sband->channels = sc->channels; 366 sband->channels = ah->channels;
368 sband->n_channels = ath5k_setup_channels(ah, sband->channels, 367 sband->n_channels = ath5k_setup_channels(ah, sband->channels,
369 AR5K_MODE_11G, max_c); 368 AR5K_MODE_11G, max_c);
370 369
371 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband; 370 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband;
372 count_c = sband->n_channels; 371 count_c = sband->n_channels;
373 max_c -= count_c; 372 max_c -= count_c;
374 } else if (test_bit(AR5K_MODE_11B, sc->ah->ah_capabilities.cap_mode)) { 373 } else if (test_bit(AR5K_MODE_11B, ah->ah_capabilities.cap_mode)) {
375 /* B mode */ 374 /* B mode */
376 memcpy(sband->bitrates, &ath5k_rates[0], 375 memcpy(sband->bitrates, &ath5k_rates[0],
377 sizeof(struct ieee80211_rate) * 4); 376 sizeof(struct ieee80211_rate) * 4);
@@ -390,7 +389,7 @@ ath5k_setup_bands(struct ieee80211_hw *hw)
390 } 389 }
391 } 390 }
392 391
393 sband->channels = sc->channels; 392 sband->channels = ah->channels;
394 sband->n_channels = ath5k_setup_channels(ah, sband->channels, 393 sband->n_channels = ath5k_setup_channels(ah, sband->channels,
395 AR5K_MODE_11B, max_c); 394 AR5K_MODE_11B, max_c);
396 395
@@ -398,27 +397,27 @@ ath5k_setup_bands(struct ieee80211_hw *hw)
398 count_c = sband->n_channels; 397 count_c = sband->n_channels;
399 max_c -= count_c; 398 max_c -= count_c;
400 } 399 }
401 ath5k_setup_rate_idx(sc, sband); 400 ath5k_setup_rate_idx(ah, sband);
402 401
403 /* 5GHz band, A mode */ 402 /* 5GHz band, A mode */
404 if (test_bit(AR5K_MODE_11A, sc->ah->ah_capabilities.cap_mode)) { 403 if (test_bit(AR5K_MODE_11A, ah->ah_capabilities.cap_mode)) {
405 sband = &sc->sbands[IEEE80211_BAND_5GHZ]; 404 sband = &ah->sbands[IEEE80211_BAND_5GHZ];
406 sband->band = IEEE80211_BAND_5GHZ; 405 sband->band = IEEE80211_BAND_5GHZ;
407 sband->bitrates = &sc->rates[IEEE80211_BAND_5GHZ][0]; 406 sband->bitrates = &ah->rates[IEEE80211_BAND_5GHZ][0];
408 407
409 memcpy(sband->bitrates, &ath5k_rates[4], 408 memcpy(sband->bitrates, &ath5k_rates[4],
410 sizeof(struct ieee80211_rate) * 8); 409 sizeof(struct ieee80211_rate) * 8);
411 sband->n_bitrates = 8; 410 sband->n_bitrates = 8;
412 411
413 sband->channels = &sc->channels[count_c]; 412 sband->channels = &ah->channels[count_c];
414 sband->n_channels = ath5k_setup_channels(ah, sband->channels, 413 sband->n_channels = ath5k_setup_channels(ah, sband->channels,
415 AR5K_MODE_11A, max_c); 414 AR5K_MODE_11A, max_c);
416 415
417 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband; 416 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband;
418 } 417 }
419 ath5k_setup_rate_idx(sc, sband); 418 ath5k_setup_rate_idx(ah, sband);
420 419
421 ath5k_debug_dump_bands(sc); 420 ath5k_debug_dump_bands(ah);
422 421
423 return 0; 422 return 0;
424} 423}
@@ -428,14 +427,14 @@ ath5k_setup_bands(struct ieee80211_hw *hw)
428 * To accomplish this we must first cleanup any pending DMA, 427 * To accomplish this we must first cleanup any pending DMA,
429 * then restart stuff after a la ath5k_init. 428 * then restart stuff after a la ath5k_init.
430 * 429 *
431 * Called with sc->lock. 430 * Called with ah->lock.
432 */ 431 */
433int 432int
434ath5k_chan_set(struct ath5k_softc *sc, struct ieee80211_channel *chan) 433ath5k_chan_set(struct ath5k_hw *ah, struct ieee80211_channel *chan)
435{ 434{
436 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 435 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
437 "channel set, resetting (%u -> %u MHz)\n", 436 "channel set, resetting (%u -> %u MHz)\n",
438 sc->curchan->center_freq, chan->center_freq); 437 ah->curchan->center_freq, chan->center_freq);
439 438
440 /* 439 /*
441 * To switch channels clear any pending DMA operations; 440 * To switch channels clear any pending DMA operations;
@@ -443,7 +442,7 @@ ath5k_chan_set(struct ath5k_softc *sc, struct ieee80211_channel *chan)
443 * hardware at the new frequency, and then re-enable 442 * hardware at the new frequency, and then re-enable
444 * the relevant bits of the h/w. 443 * the relevant bits of the h/w.
445 */ 444 */
446 return ath5k_reset(sc, chan, true); 445 return ath5k_reset(ah, chan, true);
447} 446}
448 447
449void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) 448void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
@@ -487,10 +486,10 @@ void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
487} 486}
488 487
489void 488void
490ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc, 489ath5k_update_bssid_mask_and_opmode(struct ath5k_hw *ah,
491 struct ieee80211_vif *vif) 490 struct ieee80211_vif *vif)
492{ 491{
493 struct ath_common *common = ath5k_hw_common(sc->ah); 492 struct ath_common *common = ath5k_hw_common(ah);
494 struct ath5k_vif_iter_data iter_data; 493 struct ath5k_vif_iter_data iter_data;
495 u32 rfilt; 494 u32 rfilt;
496 495
@@ -509,24 +508,24 @@ ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc,
509 ath5k_vif_iter(&iter_data, vif->addr, vif); 508 ath5k_vif_iter(&iter_data, vif->addr, vif);
510 509
511 /* Get list of all active MAC addresses */ 510 /* Get list of all active MAC addresses */
512 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath5k_vif_iter, 511 ieee80211_iterate_active_interfaces_atomic(ah->hw, ath5k_vif_iter,
513 &iter_data); 512 &iter_data);
514 memcpy(sc->bssidmask, iter_data.mask, ETH_ALEN); 513 memcpy(ah->bssidmask, iter_data.mask, ETH_ALEN);
515 514
516 sc->opmode = iter_data.opmode; 515 ah->opmode = iter_data.opmode;
517 if (sc->opmode == NL80211_IFTYPE_UNSPECIFIED) 516 if (ah->opmode == NL80211_IFTYPE_UNSPECIFIED)
518 /* Nothing active, default to station mode */ 517 /* Nothing active, default to station mode */
519 sc->opmode = NL80211_IFTYPE_STATION; 518 ah->opmode = NL80211_IFTYPE_STATION;
520 519
521 ath5k_hw_set_opmode(sc->ah, sc->opmode); 520 ath5k_hw_set_opmode(ah, ah->opmode);
522 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "mode setup opmode %d (%s)\n", 521 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "mode setup opmode %d (%s)\n",
523 sc->opmode, ath_opmode_to_string(sc->opmode)); 522 ah->opmode, ath_opmode_to_string(ah->opmode));
524 523
525 if (iter_data.need_set_hw_addr && iter_data.found_active) 524 if (iter_data.need_set_hw_addr && iter_data.found_active)
526 ath5k_hw_set_lladdr(sc->ah, iter_data.active_mac); 525 ath5k_hw_set_lladdr(ah, iter_data.active_mac);
527 526
528 if (ath5k_hw_hasbssidmask(sc->ah)) 527 if (ath5k_hw_hasbssidmask(ah))
529 ath5k_hw_set_bssid_mask(sc->ah, sc->bssidmask); 528 ath5k_hw_set_bssid_mask(ah, ah->bssidmask);
530 529
531 /* Set up RX Filter */ 530 /* Set up RX Filter */
532 if (iter_data.n_stas > 1) { 531 if (iter_data.n_stas > 1) {
@@ -534,16 +533,16 @@ ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc,
534 * different APs, ARPs are not received (most of the time?) 533 * different APs, ARPs are not received (most of the time?)
535 * Enabling PROMISC appears to fix that problem. 534 * Enabling PROMISC appears to fix that problem.
536 */ 535 */
537 sc->filter_flags |= AR5K_RX_FILTER_PROM; 536 ah->filter_flags |= AR5K_RX_FILTER_PROM;
538 } 537 }
539 538
540 rfilt = sc->filter_flags; 539 rfilt = ah->filter_flags;
541 ath5k_hw_set_rx_filter(sc->ah, rfilt); 540 ath5k_hw_set_rx_filter(ah, rfilt);
542 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "RX filter 0x%x\n", rfilt); 541 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "RX filter 0x%x\n", rfilt);
543} 542}
544 543
545static inline int 544static inline int
546ath5k_hw_to_driver_rix(struct ath5k_softc *sc, int hw_rix) 545ath5k_hw_to_driver_rix(struct ath5k_hw *ah, int hw_rix)
547{ 546{
548 int rix; 547 int rix;
549 548
@@ -552,7 +551,7 @@ ath5k_hw_to_driver_rix(struct ath5k_softc *sc, int hw_rix)
552 "hw_rix out of bounds: %x\n", hw_rix)) 551 "hw_rix out of bounds: %x\n", hw_rix))
553 return 0; 552 return 0;
554 553
555 rix = sc->rate_idx[sc->curchan->band][hw_rix]; 554 rix = ah->rate_idx[ah->curchan->band][hw_rix];
556 if (WARN(rix < 0, "invalid hw_rix: %x\n", hw_rix)) 555 if (WARN(rix < 0, "invalid hw_rix: %x\n", hw_rix))
557 rix = 0; 556 rix = 0;
558 557
@@ -564,9 +563,9 @@ ath5k_hw_to_driver_rix(struct ath5k_softc *sc, int hw_rix)
564\***************/ 563\***************/
565 564
566static 565static
567struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr) 566struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_hw *ah, dma_addr_t *skb_addr)
568{ 567{
569 struct ath_common *common = ath5k_hw_common(sc->ah); 568 struct ath_common *common = ath5k_hw_common(ah);
570 struct sk_buff *skb; 569 struct sk_buff *skb;
571 570
572 /* 571 /*
@@ -578,17 +577,17 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)
578 GFP_ATOMIC); 577 GFP_ATOMIC);
579 578
580 if (!skb) { 579 if (!skb) {
581 ATH5K_ERR(sc, "can't alloc skbuff of size %u\n", 580 ATH5K_ERR(ah, "can't alloc skbuff of size %u\n",
582 common->rx_bufsize); 581 common->rx_bufsize);
583 return NULL; 582 return NULL;
584 } 583 }
585 584
586 *skb_addr = dma_map_single(sc->dev, 585 *skb_addr = dma_map_single(ah->dev,
587 skb->data, common->rx_bufsize, 586 skb->data, common->rx_bufsize,
588 DMA_FROM_DEVICE); 587 DMA_FROM_DEVICE);
589 588
590 if (unlikely(dma_mapping_error(sc->dev, *skb_addr))) { 589 if (unlikely(dma_mapping_error(ah->dev, *skb_addr))) {
591 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__); 590 ATH5K_ERR(ah, "%s: DMA mapping failed\n", __func__);
592 dev_kfree_skb(skb); 591 dev_kfree_skb(skb);
593 return NULL; 592 return NULL;
594 } 593 }
@@ -596,15 +595,14 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)
596} 595}
597 596
598static int 597static int
599ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) 598ath5k_rxbuf_setup(struct ath5k_hw *ah, struct ath5k_buf *bf)
600{ 599{
601 struct ath5k_hw *ah = sc->ah;
602 struct sk_buff *skb = bf->skb; 600 struct sk_buff *skb = bf->skb;
603 struct ath5k_desc *ds; 601 struct ath5k_desc *ds;
604 int ret; 602 int ret;
605 603
606 if (!skb) { 604 if (!skb) {
607 skb = ath5k_rx_skb_alloc(sc, &bf->skbaddr); 605 skb = ath5k_rx_skb_alloc(ah, &bf->skbaddr);
608 if (!skb) 606 if (!skb)
609 return -ENOMEM; 607 return -ENOMEM;
610 bf->skb = skb; 608 bf->skb = skb;
@@ -630,13 +628,13 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
630 ds->ds_data = bf->skbaddr; 628 ds->ds_data = bf->skbaddr;
631 ret = ath5k_hw_setup_rx_desc(ah, ds, ah->common.rx_bufsize, 0); 629 ret = ath5k_hw_setup_rx_desc(ah, ds, ah->common.rx_bufsize, 0);
632 if (ret) { 630 if (ret) {
633 ATH5K_ERR(sc, "%s: could not setup RX desc\n", __func__); 631 ATH5K_ERR(ah, "%s: could not setup RX desc\n", __func__);
634 return ret; 632 return ret;
635 } 633 }
636 634
637 if (sc->rxlink != NULL) 635 if (ah->rxlink != NULL)
638 *sc->rxlink = bf->daddr; 636 *ah->rxlink = bf->daddr;
639 sc->rxlink = &ds->ds_link; 637 ah->rxlink = &ds->ds_link;
640 return 0; 638 return 0;
641} 639}
642 640
@@ -664,10 +662,9 @@ static enum ath5k_pkt_type get_hw_packet_type(struct sk_buff *skb)
664} 662}
665 663
666static int 664static int
667ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, 665ath5k_txbuf_setup(struct ath5k_hw *ah, struct ath5k_buf *bf,
668 struct ath5k_txq *txq, int padsize) 666 struct ath5k_txq *txq, int padsize)
669{ 667{
670 struct ath5k_hw *ah = sc->ah;
671 struct ath5k_desc *ds = bf->desc; 668 struct ath5k_desc *ds = bf->desc;
672 struct sk_buff *skb = bf->skb; 669 struct sk_buff *skb = bf->skb;
673 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 670 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -683,10 +680,10 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
683 flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK; 680 flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;
684 681
685 /* XXX endianness */ 682 /* XXX endianness */
686 bf->skbaddr = dma_map_single(sc->dev, skb->data, skb->len, 683 bf->skbaddr = dma_map_single(ah->dev, skb->data, skb->len,
687 DMA_TO_DEVICE); 684 DMA_TO_DEVICE);
688 685
689 rate = ieee80211_get_tx_rate(sc->hw, info); 686 rate = ieee80211_get_tx_rate(ah->hw, info);
690 if (!rate) { 687 if (!rate) {
691 ret = -EINVAL; 688 ret = -EINVAL;
692 goto err_unmap; 689 goto err_unmap;
@@ -710,20 +707,20 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
710 } 707 }
711 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) { 708 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
712 flags |= AR5K_TXDESC_RTSENA; 709 flags |= AR5K_TXDESC_RTSENA;
713 cts_rate = ieee80211_get_rts_cts_rate(sc->hw, info)->hw_value; 710 cts_rate = ieee80211_get_rts_cts_rate(ah->hw, info)->hw_value;
714 duration = le16_to_cpu(ieee80211_rts_duration(sc->hw, 711 duration = le16_to_cpu(ieee80211_rts_duration(ah->hw,
715 info->control.vif, pktlen, info)); 712 info->control.vif, pktlen, info));
716 } 713 }
717 if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { 714 if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
718 flags |= AR5K_TXDESC_CTSENA; 715 flags |= AR5K_TXDESC_CTSENA;
719 cts_rate = ieee80211_get_rts_cts_rate(sc->hw, info)->hw_value; 716 cts_rate = ieee80211_get_rts_cts_rate(ah->hw, info)->hw_value;
720 duration = le16_to_cpu(ieee80211_ctstoself_duration(sc->hw, 717 duration = le16_to_cpu(ieee80211_ctstoself_duration(ah->hw,
721 info->control.vif, pktlen, info)); 718 info->control.vif, pktlen, info));
722 } 719 }
723 ret = ah->ah_setup_tx_desc(ah, ds, pktlen, 720 ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
724 ieee80211_get_hdrlen_from_skb(skb), padsize, 721 ieee80211_get_hdrlen_from_skb(skb), padsize,
725 get_hw_packet_type(skb), 722 get_hw_packet_type(skb),
726 (sc->power_level * 2), 723 (ah->power_level * 2),
727 hw_rate, 724 hw_rate,
728 info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags, 725 info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
729 cts_rate, duration); 726 cts_rate, duration);
@@ -733,7 +730,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
733 memset(mrr_rate, 0, sizeof(mrr_rate)); 730 memset(mrr_rate, 0, sizeof(mrr_rate));
734 memset(mrr_tries, 0, sizeof(mrr_tries)); 731 memset(mrr_tries, 0, sizeof(mrr_tries));
735 for (i = 0; i < 3; i++) { 732 for (i = 0; i < 3; i++) {
736 rate = ieee80211_get_alt_retry_rate(sc->hw, info, i); 733 rate = ieee80211_get_alt_retry_rate(ah->hw, info, i);
737 if (!rate) 734 if (!rate)
738 break; 735 break;
739 736
@@ -764,7 +761,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
764 761
765 return 0; 762 return 0;
766err_unmap: 763err_unmap:
767 dma_unmap_single(sc->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE); 764 dma_unmap_single(ah->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE);
768 return ret; 765 return ret;
769} 766}
770 767
@@ -773,7 +770,7 @@ err_unmap:
773\*******************/ 770\*******************/
774 771
775static int 772static int
776ath5k_desc_alloc(struct ath5k_softc *sc) 773ath5k_desc_alloc(struct ath5k_hw *ah)
777{ 774{
778 struct ath5k_desc *ds; 775 struct ath5k_desc *ds;
779 struct ath5k_buf *bf; 776 struct ath5k_buf *bf;
@@ -782,68 +779,68 @@ ath5k_desc_alloc(struct ath5k_softc *sc)
782 int ret; 779 int ret;
783 780
784 /* allocate descriptors */ 781 /* allocate descriptors */
785 sc->desc_len = sizeof(struct ath5k_desc) * 782 ah->desc_len = sizeof(struct ath5k_desc) *
786 (ATH_TXBUF + ATH_RXBUF + ATH_BCBUF + 1); 783 (ATH_TXBUF + ATH_RXBUF + ATH_BCBUF + 1);
787 784
788 sc->desc = dma_alloc_coherent(sc->dev, sc->desc_len, 785 ah->desc = dma_alloc_coherent(ah->dev, ah->desc_len,
789 &sc->desc_daddr, GFP_KERNEL); 786 &ah->desc_daddr, GFP_KERNEL);
790 if (sc->desc == NULL) { 787 if (ah->desc == NULL) {
791 ATH5K_ERR(sc, "can't allocate descriptors\n"); 788 ATH5K_ERR(ah, "can't allocate descriptors\n");
792 ret = -ENOMEM; 789 ret = -ENOMEM;
793 goto err; 790 goto err;
794 } 791 }
795 ds = sc->desc; 792 ds = ah->desc;
796 da = sc->desc_daddr; 793 da = ah->desc_daddr;
797 ATH5K_DBG(sc, ATH5K_DEBUG_ANY, "DMA map: %p (%zu) -> %llx\n", 794 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, "DMA map: %p (%zu) -> %llx\n",
798 ds, sc->desc_len, (unsigned long long)sc->desc_daddr); 795 ds, ah->desc_len, (unsigned long long)ah->desc_daddr);
799 796
800 bf = kcalloc(1 + ATH_TXBUF + ATH_RXBUF + ATH_BCBUF, 797 bf = kcalloc(1 + ATH_TXBUF + ATH_RXBUF + ATH_BCBUF,
801 sizeof(struct ath5k_buf), GFP_KERNEL); 798 sizeof(struct ath5k_buf), GFP_KERNEL);
802 if (bf == NULL) { 799 if (bf == NULL) {
803 ATH5K_ERR(sc, "can't allocate bufptr\n"); 800 ATH5K_ERR(ah, "can't allocate bufptr\n");
804 ret = -ENOMEM; 801 ret = -ENOMEM;
805 goto err_free; 802 goto err_free;
806 } 803 }
807 sc->bufptr = bf; 804 ah->bufptr = bf;
808 805
809 INIT_LIST_HEAD(&sc->rxbuf); 806 INIT_LIST_HEAD(&ah->rxbuf);
810 for (i = 0; i < ATH_RXBUF; i++, bf++, ds++, da += sizeof(*ds)) { 807 for (i = 0; i < ATH_RXBUF; i++, bf++, ds++, da += sizeof(*ds)) {
811 bf->desc = ds; 808 bf->desc = ds;
812 bf->daddr = da; 809 bf->daddr = da;
813 list_add_tail(&bf->list, &sc->rxbuf); 810 list_add_tail(&bf->list, &ah->rxbuf);
814 } 811 }
815 812
816 INIT_LIST_HEAD(&sc->txbuf); 813 INIT_LIST_HEAD(&ah->txbuf);
817 sc->txbuf_len = ATH_TXBUF; 814 ah->txbuf_len = ATH_TXBUF;
818 for (i = 0; i < ATH_TXBUF; i++, bf++, ds++, da += sizeof(*ds)) { 815 for (i = 0; i < ATH_TXBUF; i++, bf++, ds++, da += sizeof(*ds)) {
819 bf->desc = ds; 816 bf->desc = ds;
820 bf->daddr = da; 817 bf->daddr = da;
821 list_add_tail(&bf->list, &sc->txbuf); 818 list_add_tail(&bf->list, &ah->txbuf);
822 } 819 }
823 820
824 /* beacon buffers */ 821 /* beacon buffers */
825 INIT_LIST_HEAD(&sc->bcbuf); 822 INIT_LIST_HEAD(&ah->bcbuf);
826 for (i = 0; i < ATH_BCBUF; i++, bf++, ds++, da += sizeof(*ds)) { 823 for (i = 0; i < ATH_BCBUF; i++, bf++, ds++, da += sizeof(*ds)) {
827 bf->desc = ds; 824 bf->desc = ds;
828 bf->daddr = da; 825 bf->daddr = da;
829 list_add_tail(&bf->list, &sc->bcbuf); 826 list_add_tail(&bf->list, &ah->bcbuf);
830 } 827 }
831 828
832 return 0; 829 return 0;
833err_free: 830err_free:
834 dma_free_coherent(sc->dev, sc->desc_len, sc->desc, sc->desc_daddr); 831 dma_free_coherent(ah->dev, ah->desc_len, ah->desc, ah->desc_daddr);
835err: 832err:
836 sc->desc = NULL; 833 ah->desc = NULL;
837 return ret; 834 return ret;
838} 835}
839 836
840void 837void
841ath5k_txbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf) 838ath5k_txbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf)
842{ 839{
843 BUG_ON(!bf); 840 BUG_ON(!bf);
844 if (!bf->skb) 841 if (!bf->skb)
845 return; 842 return;
846 dma_unmap_single(sc->dev, bf->skbaddr, bf->skb->len, 843 dma_unmap_single(ah->dev, bf->skbaddr, bf->skb->len,
847 DMA_TO_DEVICE); 844 DMA_TO_DEVICE);
848 dev_kfree_skb_any(bf->skb); 845 dev_kfree_skb_any(bf->skb);
849 bf->skb = NULL; 846 bf->skb = NULL;
@@ -852,15 +849,14 @@ ath5k_txbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf)
852} 849}
853 850
854void 851void
855ath5k_rxbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf) 852ath5k_rxbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf)
856{ 853{
857 struct ath5k_hw *ah = sc->ah;
858 struct ath_common *common = ath5k_hw_common(ah); 854 struct ath_common *common = ath5k_hw_common(ah);
859 855
860 BUG_ON(!bf); 856 BUG_ON(!bf);
861 if (!bf->skb) 857 if (!bf->skb)
862 return; 858 return;
863 dma_unmap_single(sc->dev, bf->skbaddr, common->rx_bufsize, 859 dma_unmap_single(ah->dev, bf->skbaddr, common->rx_bufsize,
864 DMA_FROM_DEVICE); 860 DMA_FROM_DEVICE);
865 dev_kfree_skb_any(bf->skb); 861 dev_kfree_skb_any(bf->skb);
866 bf->skb = NULL; 862 bf->skb = NULL;
@@ -869,24 +865,24 @@ ath5k_rxbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf)
869} 865}
870 866
871static void 867static void
872ath5k_desc_free(struct ath5k_softc *sc) 868ath5k_desc_free(struct ath5k_hw *ah)
873{ 869{
874 struct ath5k_buf *bf; 870 struct ath5k_buf *bf;
875 871
876 list_for_each_entry(bf, &sc->txbuf, list) 872 list_for_each_entry(bf, &ah->txbuf, list)
877 ath5k_txbuf_free_skb(sc, bf); 873 ath5k_txbuf_free_skb(ah, bf);
878 list_for_each_entry(bf, &sc->rxbuf, list) 874 list_for_each_entry(bf, &ah->rxbuf, list)
879 ath5k_rxbuf_free_skb(sc, bf); 875 ath5k_rxbuf_free_skb(ah, bf);
880 list_for_each_entry(bf, &sc->bcbuf, list) 876 list_for_each_entry(bf, &ah->bcbuf, list)
881 ath5k_txbuf_free_skb(sc, bf); 877 ath5k_txbuf_free_skb(ah, bf);
882 878
883 /* Free memory associated with all descriptors */ 879 /* Free memory associated with all descriptors */
884 dma_free_coherent(sc->dev, sc->desc_len, sc->desc, sc->desc_daddr); 880 dma_free_coherent(ah->dev, ah->desc_len, ah->desc, ah->desc_daddr);
885 sc->desc = NULL; 881 ah->desc = NULL;
886 sc->desc_daddr = 0; 882 ah->desc_daddr = 0;
887 883
888 kfree(sc->bufptr); 884 kfree(ah->bufptr);
889 sc->bufptr = NULL; 885 ah->bufptr = NULL;
890} 886}
891 887
892 888
@@ -895,10 +891,9 @@ ath5k_desc_free(struct ath5k_softc *sc)
895\**************/ 891\**************/
896 892
897static struct ath5k_txq * 893static struct ath5k_txq *
898ath5k_txq_setup(struct ath5k_softc *sc, 894ath5k_txq_setup(struct ath5k_hw *ah,
899 int qtype, int subtype) 895 int qtype, int subtype)
900{ 896{
901 struct ath5k_hw *ah = sc->ah;
902 struct ath5k_txq *txq; 897 struct ath5k_txq *txq;
903 struct ath5k_txq_info qi = { 898 struct ath5k_txq_info qi = {
904 .tqi_subtype = subtype, 899 .tqi_subtype = subtype,
@@ -932,13 +927,13 @@ ath5k_txq_setup(struct ath5k_softc *sc,
932 */ 927 */
933 return ERR_PTR(qnum); 928 return ERR_PTR(qnum);
934 } 929 }
935 if (qnum >= ARRAY_SIZE(sc->txqs)) { 930 if (qnum >= ARRAY_SIZE(ah->txqs)) {
936 ATH5K_ERR(sc, "hw qnum %u out of range, max %tu!\n", 931 ATH5K_ERR(ah, "hw qnum %u out of range, max %tu!\n",
937 qnum, ARRAY_SIZE(sc->txqs)); 932 qnum, ARRAY_SIZE(ah->txqs));
938 ath5k_hw_release_tx_queue(ah, qnum); 933 ath5k_hw_release_tx_queue(ah, qnum);
939 return ERR_PTR(-EINVAL); 934 return ERR_PTR(-EINVAL);
940 } 935 }
941 txq = &sc->txqs[qnum]; 936 txq = &ah->txqs[qnum];
942 if (!txq->setup) { 937 if (!txq->setup) {
943 txq->qnum = qnum; 938 txq->qnum = qnum;
944 txq->link = NULL; 939 txq->link = NULL;
@@ -950,7 +945,7 @@ ath5k_txq_setup(struct ath5k_softc *sc,
950 txq->txq_poll_mark = false; 945 txq->txq_poll_mark = false;
951 txq->txq_stuck = 0; 946 txq->txq_stuck = 0;
952 } 947 }
953 return &sc->txqs[qnum]; 948 return &ah->txqs[qnum];
954} 949}
955 950
956static int 951static int
@@ -970,18 +965,17 @@ ath5k_beaconq_setup(struct ath5k_hw *ah)
970} 965}
971 966
972static int 967static int
973ath5k_beaconq_config(struct ath5k_softc *sc) 968ath5k_beaconq_config(struct ath5k_hw *ah)
974{ 969{
975 struct ath5k_hw *ah = sc->ah;
976 struct ath5k_txq_info qi; 970 struct ath5k_txq_info qi;
977 int ret; 971 int ret;
978 972
979 ret = ath5k_hw_get_tx_queueprops(ah, sc->bhalq, &qi); 973 ret = ath5k_hw_get_tx_queueprops(ah, ah->bhalq, &qi);
980 if (ret) 974 if (ret)
981 goto err; 975 goto err;
982 976
983 if (sc->opmode == NL80211_IFTYPE_AP || 977 if (ah->opmode == NL80211_IFTYPE_AP ||
984 sc->opmode == NL80211_IFTYPE_MESH_POINT) { 978 ah->opmode == NL80211_IFTYPE_MESH_POINT) {
985 /* 979 /*
986 * Always burst out beacon and CAB traffic 980 * Always burst out beacon and CAB traffic
987 * (aifs = cwmin = cwmax = 0) 981 * (aifs = cwmin = cwmax = 0)
@@ -989,7 +983,7 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
989 qi.tqi_aifs = 0; 983 qi.tqi_aifs = 0;
990 qi.tqi_cw_min = 0; 984 qi.tqi_cw_min = 0;
991 qi.tqi_cw_max = 0; 985 qi.tqi_cw_max = 0;
992 } else if (sc->opmode == NL80211_IFTYPE_ADHOC) { 986 } else if (ah->opmode == NL80211_IFTYPE_ADHOC) {
993 /* 987 /*
994 * Adhoc mode; backoff between 0 and (2 * cw_min). 988 * Adhoc mode; backoff between 0 and (2 * cw_min).
995 */ 989 */
@@ -998,17 +992,17 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
998 qi.tqi_cw_max = 2 * AR5K_TUNE_CWMIN; 992 qi.tqi_cw_max = 2 * AR5K_TUNE_CWMIN;
999 } 993 }
1000 994
1001 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 995 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON,
1002 "beacon queueprops tqi_aifs:%d tqi_cw_min:%d tqi_cw_max:%d\n", 996 "beacon queueprops tqi_aifs:%d tqi_cw_min:%d tqi_cw_max:%d\n",
1003 qi.tqi_aifs, qi.tqi_cw_min, qi.tqi_cw_max); 997 qi.tqi_aifs, qi.tqi_cw_min, qi.tqi_cw_max);
1004 998
1005 ret = ath5k_hw_set_tx_queueprops(ah, sc->bhalq, &qi); 999 ret = ath5k_hw_set_tx_queueprops(ah, ah->bhalq, &qi);
1006 if (ret) { 1000 if (ret) {
1007 ATH5K_ERR(sc, "%s: unable to update parameters for beacon " 1001 ATH5K_ERR(ah, "%s: unable to update parameters for beacon "
1008 "hardware queue!\n", __func__); 1002 "hardware queue!\n", __func__);
1009 goto err; 1003 goto err;
1010 } 1004 }
1011 ret = ath5k_hw_reset_tx_queue(ah, sc->bhalq); /* push to h/w */ 1005 ret = ath5k_hw_reset_tx_queue(ah, ah->bhalq); /* push to h/w */
1012 if (ret) 1006 if (ret)
1013 goto err; 1007 goto err;
1014 1008
@@ -1017,7 +1011,7 @@ ath5k_beaconq_config(struct ath5k_softc *sc)
1017 if (ret) 1011 if (ret)
1018 goto err; 1012 goto err;
1019 1013
1020 qi.tqi_ready_time = (sc->bintval * 80) / 100; 1014 qi.tqi_ready_time = (ah->bintval * 80) / 100;
1021 ret = ath5k_hw_set_tx_queueprops(ah, AR5K_TX_QUEUE_ID_CAB, &qi); 1015 ret = ath5k_hw_set_tx_queueprops(ah, AR5K_TX_QUEUE_ID_CAB, &qi);
1022 if (ret) 1016 if (ret)
1023 goto err; 1017 goto err;
@@ -1030,7 +1024,7 @@ err:
1030/** 1024/**
1031 * ath5k_drain_tx_buffs - Empty tx buffers 1025 * ath5k_drain_tx_buffs - Empty tx buffers
1032 * 1026 *
1033 * @sc The &struct ath5k_softc 1027 * @ah The &struct ath5k_hw
1034 * 1028 *
1035 * Empty tx buffers from all queues in preparation 1029 * Empty tx buffers from all queues in preparation
1036 * of a reset or during shutdown. 1030 * of a reset or during shutdown.
@@ -1039,26 +1033,26 @@ err:
1039 * we do not need to block ath5k_tx_tasklet 1033 * we do not need to block ath5k_tx_tasklet
1040 */ 1034 */
1041static void 1035static void
1042ath5k_drain_tx_buffs(struct ath5k_softc *sc) 1036ath5k_drain_tx_buffs(struct ath5k_hw *ah)
1043{ 1037{
1044 struct ath5k_txq *txq; 1038 struct ath5k_txq *txq;
1045 struct ath5k_buf *bf, *bf0; 1039 struct ath5k_buf *bf, *bf0;
1046 int i; 1040 int i;
1047 1041
1048 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) { 1042 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) {
1049 if (sc->txqs[i].setup) { 1043 if (ah->txqs[i].setup) {
1050 txq = &sc->txqs[i]; 1044 txq = &ah->txqs[i];
1051 spin_lock_bh(&txq->lock); 1045 spin_lock_bh(&txq->lock);
1052 list_for_each_entry_safe(bf, bf0, &txq->q, list) { 1046 list_for_each_entry_safe(bf, bf0, &txq->q, list) {
1053 ath5k_debug_printtxbuf(sc, bf); 1047 ath5k_debug_printtxbuf(ah, bf);
1054 1048
1055 ath5k_txbuf_free_skb(sc, bf); 1049 ath5k_txbuf_free_skb(ah, bf);
1056 1050
1057 spin_lock_bh(&sc->txbuflock); 1051 spin_lock_bh(&ah->txbuflock);
1058 list_move_tail(&bf->list, &sc->txbuf); 1052 list_move_tail(&bf->list, &ah->txbuf);
1059 sc->txbuf_len++; 1053 ah->txbuf_len++;
1060 txq->txq_len--; 1054 txq->txq_len--;
1061 spin_unlock_bh(&sc->txbuflock); 1055 spin_unlock_bh(&ah->txbuflock);
1062 } 1056 }
1063 txq->link = NULL; 1057 txq->link = NULL;
1064 txq->txq_poll_mark = false; 1058 txq->txq_poll_mark = false;
@@ -1068,14 +1062,14 @@ ath5k_drain_tx_buffs(struct ath5k_softc *sc)
1068} 1062}
1069 1063
1070static void 1064static void
1071ath5k_txq_release(struct ath5k_softc *sc) 1065ath5k_txq_release(struct ath5k_hw *ah)
1072{ 1066{
1073 struct ath5k_txq *txq = sc->txqs; 1067 struct ath5k_txq *txq = ah->txqs;
1074 unsigned int i; 1068 unsigned int i;
1075 1069
1076 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++, txq++) 1070 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++, txq++)
1077 if (txq->setup) { 1071 if (txq->setup) {
1078 ath5k_hw_release_tx_queue(sc->ah, txq->qnum); 1072 ath5k_hw_release_tx_queue(ah, txq->qnum);
1079 txq->setup = false; 1073 txq->setup = false;
1080 } 1074 }
1081} 1075}
@@ -1089,33 +1083,32 @@ ath5k_txq_release(struct ath5k_softc *sc)
1089 * Enable the receive h/w following a reset. 1083 * Enable the receive h/w following a reset.
1090 */ 1084 */
1091static int 1085static int
1092ath5k_rx_start(struct ath5k_softc *sc) 1086ath5k_rx_start(struct ath5k_hw *ah)
1093{ 1087{
1094 struct ath5k_hw *ah = sc->ah;
1095 struct ath_common *common = ath5k_hw_common(ah); 1088 struct ath_common *common = ath5k_hw_common(ah);
1096 struct ath5k_buf *bf; 1089 struct ath5k_buf *bf;
1097 int ret; 1090 int ret;
1098 1091
1099 common->rx_bufsize = roundup(IEEE80211_MAX_FRAME_LEN, common->cachelsz); 1092 common->rx_bufsize = roundup(IEEE80211_MAX_FRAME_LEN, common->cachelsz);
1100 1093
1101 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "cachelsz %u rx_bufsize %u\n", 1094 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "cachelsz %u rx_bufsize %u\n",
1102 common->cachelsz, common->rx_bufsize); 1095 common->cachelsz, common->rx_bufsize);
1103 1096
1104 spin_lock_bh(&sc->rxbuflock); 1097 spin_lock_bh(&ah->rxbuflock);
1105 sc->rxlink = NULL; 1098 ah->rxlink = NULL;
1106 list_for_each_entry(bf, &sc->rxbuf, list) { 1099 list_for_each_entry(bf, &ah->rxbuf, list) {
1107 ret = ath5k_rxbuf_setup(sc, bf); 1100 ret = ath5k_rxbuf_setup(ah, bf);
1108 if (ret != 0) { 1101 if (ret != 0) {
1109 spin_unlock_bh(&sc->rxbuflock); 1102 spin_unlock_bh(&ah->rxbuflock);
1110 goto err; 1103 goto err;
1111 } 1104 }
1112 } 1105 }
1113 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list); 1106 bf = list_first_entry(&ah->rxbuf, struct ath5k_buf, list);
1114 ath5k_hw_set_rxdp(ah, bf->daddr); 1107 ath5k_hw_set_rxdp(ah, bf->daddr);
1115 spin_unlock_bh(&sc->rxbuflock); 1108 spin_unlock_bh(&ah->rxbuflock);
1116 1109
1117 ath5k_hw_start_rx_dma(ah); /* enable recv descriptors */ 1110 ath5k_hw_start_rx_dma(ah); /* enable recv descriptors */
1118 ath5k_update_bssid_mask_and_opmode(sc, NULL); /* set filters, etc. */ 1111 ath5k_update_bssid_mask_and_opmode(ah, NULL); /* set filters, etc. */
1119 ath5k_hw_start_rx_pcu(ah); /* re-enable PCU/DMA engine */ 1112 ath5k_hw_start_rx_pcu(ah); /* re-enable PCU/DMA engine */
1120 1113
1121 return 0; 1114 return 0;
@@ -1131,21 +1124,19 @@ err:
1131 * does. 1124 * does.
1132 */ 1125 */
1133static void 1126static void
1134ath5k_rx_stop(struct ath5k_softc *sc) 1127ath5k_rx_stop(struct ath5k_hw *ah)
1135{ 1128{
1136 struct ath5k_hw *ah = sc->ah;
1137 1129
1138 ath5k_hw_set_rx_filter(ah, 0); /* clear recv filter */ 1130 ath5k_hw_set_rx_filter(ah, 0); /* clear recv filter */
1139 ath5k_hw_stop_rx_pcu(ah); /* disable PCU */ 1131 ath5k_hw_stop_rx_pcu(ah); /* disable PCU */
1140 1132
1141 ath5k_debug_printrxbuffs(sc, ah); 1133 ath5k_debug_printrxbuffs(ah);
1142} 1134}
1143 1135
1144static unsigned int 1136static unsigned int
1145ath5k_rx_decrypted(struct ath5k_softc *sc, struct sk_buff *skb, 1137ath5k_rx_decrypted(struct ath5k_hw *ah, struct sk_buff *skb,
1146 struct ath5k_rx_status *rs) 1138 struct ath5k_rx_status *rs)
1147{ 1139{
1148 struct ath5k_hw *ah = sc->ah;
1149 struct ath_common *common = ath5k_hw_common(ah); 1140 struct ath_common *common = ath5k_hw_common(ah);
1150 struct ieee80211_hdr *hdr = (void *)skb->data; 1141 struct ieee80211_hdr *hdr = (void *)skb->data;
1151 unsigned int keyix, hlen; 1142 unsigned int keyix, hlen;
@@ -1172,10 +1163,10 @@ ath5k_rx_decrypted(struct ath5k_softc *sc, struct sk_buff *skb,
1172 1163
1173 1164
1174static void 1165static void
1175ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb, 1166ath5k_check_ibss_tsf(struct ath5k_hw *ah, struct sk_buff *skb,
1176 struct ieee80211_rx_status *rxs) 1167 struct ieee80211_rx_status *rxs)
1177{ 1168{
1178 struct ath_common *common = ath5k_hw_common(sc->ah); 1169 struct ath_common *common = ath5k_hw_common(ah);
1179 u64 tsf, bc_tstamp; 1170 u64 tsf, bc_tstamp;
1180 u32 hw_tu; 1171 u32 hw_tu;
1181 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; 1172 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
@@ -1188,11 +1179,11 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,
1188 * have updated the local TSF. We have to work around various 1179 * have updated the local TSF. We have to work around various
1189 * hardware bugs, though... 1180 * hardware bugs, though...
1190 */ 1181 */
1191 tsf = ath5k_hw_get_tsf64(sc->ah); 1182 tsf = ath5k_hw_get_tsf64(ah);
1192 bc_tstamp = le64_to_cpu(mgmt->u.beacon.timestamp); 1183 bc_tstamp = le64_to_cpu(mgmt->u.beacon.timestamp);
1193 hw_tu = TSF_TO_TU(tsf); 1184 hw_tu = TSF_TO_TU(tsf);
1194 1185
1195 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 1186 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
1196 "beacon %llx mactime %llx (diff %lld) tsf now %llx\n", 1187 "beacon %llx mactime %llx (diff %lld) tsf now %llx\n",
1197 (unsigned long long)bc_tstamp, 1188 (unsigned long long)bc_tstamp,
1198 (unsigned long long)rxs->mactime, 1189 (unsigned long long)rxs->mactime,
@@ -1211,7 +1202,7 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,
1211 * received, not like mac80211 which defines it at the start. 1202 * received, not like mac80211 which defines it at the start.
1212 */ 1203 */
1213 if (bc_tstamp > rxs->mactime) { 1204 if (bc_tstamp > rxs->mactime) {
1214 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 1205 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
1215 "fixing mactime from %llx to %llx\n", 1206 "fixing mactime from %llx to %llx\n",
1216 (unsigned long long)rxs->mactime, 1207 (unsigned long long)rxs->mactime,
1217 (unsigned long long)tsf); 1208 (unsigned long long)tsf);
@@ -1224,25 +1215,24 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,
1224 * beacons. This also takes care of synchronizing beacon sending 1215 * beacons. This also takes care of synchronizing beacon sending
1225 * times with other stations. 1216 * times with other stations.
1226 */ 1217 */
1227 if (hw_tu >= sc->nexttbtt) 1218 if (hw_tu >= ah->nexttbtt)
1228 ath5k_beacon_update_timers(sc, bc_tstamp); 1219 ath5k_beacon_update_timers(ah, bc_tstamp);
1229 1220
1230 /* Check if the beacon timers are still correct, because a TSF 1221 /* Check if the beacon timers are still correct, because a TSF
1231 * update might have created a window between them - for a 1222 * update might have created a window between them - for a
1232 * longer description see the comment of this function: */ 1223 * longer description see the comment of this function: */
1233 if (!ath5k_hw_check_beacon_timers(sc->ah, sc->bintval)) { 1224 if (!ath5k_hw_check_beacon_timers(ah, ah->bintval)) {
1234 ath5k_beacon_update_timers(sc, bc_tstamp); 1225 ath5k_beacon_update_timers(ah, bc_tstamp);
1235 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 1226 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
1236 "fixed beacon timers after beacon receive\n"); 1227 "fixed beacon timers after beacon receive\n");
1237 } 1228 }
1238 } 1229 }
1239} 1230}
1240 1231
1241static void 1232static void
1242ath5k_update_beacon_rssi(struct ath5k_softc *sc, struct sk_buff *skb, int rssi) 1233ath5k_update_beacon_rssi(struct ath5k_hw *ah, struct sk_buff *skb, int rssi)
1243{ 1234{
1244 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; 1235 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
1245 struct ath5k_hw *ah = sc->ah;
1246 struct ath_common *common = ath5k_hw_common(ah); 1236 struct ath_common *common = ath5k_hw_common(ah);
1247 1237
1248 /* only beacons from our BSSID */ 1238 /* only beacons from our BSSID */
@@ -1324,7 +1314,7 @@ static int ath5k_remove_padding(struct sk_buff *skb)
1324} 1314}
1325 1315
1326static void 1316static void
1327ath5k_receive_frame(struct ath5k_softc *sc, struct sk_buff *skb, 1317ath5k_receive_frame(struct ath5k_hw *ah, struct sk_buff *skb,
1328 struct ath5k_rx_status *rs) 1318 struct ath5k_rx_status *rs)
1329{ 1319{
1330 struct ieee80211_rx_status *rxs; 1320 struct ieee80211_rx_status *rxs;
@@ -1357,37 +1347,37 @@ ath5k_receive_frame(struct ath5k_softc *sc, struct sk_buff *skb,
1357 * impossible to comply to that. This affects IBSS merge only 1347 * impossible to comply to that. This affects IBSS merge only
1358 * right now, so it's not too bad... 1348 * right now, so it's not too bad...
1359 */ 1349 */
1360 rxs->mactime = ath5k_extend_tsf(sc->ah, rs->rs_tstamp); 1350 rxs->mactime = ath5k_extend_tsf(ah, rs->rs_tstamp);
1361 rxs->flag |= RX_FLAG_MACTIME_MPDU; 1351 rxs->flag |= RX_FLAG_MACTIME_MPDU;
1362 1352
1363 rxs->freq = sc->curchan->center_freq; 1353 rxs->freq = ah->curchan->center_freq;
1364 rxs->band = sc->curchan->band; 1354 rxs->band = ah->curchan->band;
1365 1355
1366 rxs->signal = sc->ah->ah_noise_floor + rs->rs_rssi; 1356 rxs->signal = ah->ah_noise_floor + rs->rs_rssi;
1367 1357
1368 rxs->antenna = rs->rs_antenna; 1358 rxs->antenna = rs->rs_antenna;
1369 1359
1370 if (rs->rs_antenna > 0 && rs->rs_antenna < 5) 1360 if (rs->rs_antenna > 0 && rs->rs_antenna < 5)
1371 sc->stats.antenna_rx[rs->rs_antenna]++; 1361 ah->stats.antenna_rx[rs->rs_antenna]++;
1372 else 1362 else
1373 sc->stats.antenna_rx[0]++; /* invalid */ 1363 ah->stats.antenna_rx[0]++; /* invalid */
1374 1364
1375 rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs->rs_rate); 1365 rxs->rate_idx = ath5k_hw_to_driver_rix(ah, rs->rs_rate);
1376 rxs->flag |= ath5k_rx_decrypted(sc, skb, rs); 1366 rxs->flag |= ath5k_rx_decrypted(ah, skb, rs);
1377 1367
1378 if (rxs->rate_idx >= 0 && rs->rs_rate == 1368 if (rxs->rate_idx >= 0 && rs->rs_rate ==
1379 sc->sbands[sc->curchan->band].bitrates[rxs->rate_idx].hw_value_short) 1369 ah->sbands[ah->curchan->band].bitrates[rxs->rate_idx].hw_value_short)
1380 rxs->flag |= RX_FLAG_SHORTPRE; 1370 rxs->flag |= RX_FLAG_SHORTPRE;
1381 1371
1382 trace_ath5k_rx(sc, skb); 1372 trace_ath5k_rx(ah, skb);
1383 1373
1384 ath5k_update_beacon_rssi(sc, skb, rs->rs_rssi); 1374 ath5k_update_beacon_rssi(ah, skb, rs->rs_rssi);
1385 1375
1386 /* check beacons in IBSS mode */ 1376 /* check beacons in IBSS mode */
1387 if (sc->opmode == NL80211_IFTYPE_ADHOC) 1377 if (ah->opmode == NL80211_IFTYPE_ADHOC)
1388 ath5k_check_ibss_tsf(sc, skb, rxs); 1378 ath5k_check_ibss_tsf(ah, skb, rxs);
1389 1379
1390 ieee80211_rx(sc->hw, skb); 1380 ieee80211_rx(ah->hw, skb);
1391} 1381}
1392 1382
1393/** ath5k_frame_receive_ok() - Do we want to receive this frame or not? 1383/** ath5k_frame_receive_ok() - Do we want to receive this frame or not?
@@ -1396,20 +1386,20 @@ ath5k_receive_frame(struct ath5k_softc *sc, struct sk_buff *skb,
1396 * statistics. Return true if we want this frame, false if not. 1386 * statistics. Return true if we want this frame, false if not.
1397 */ 1387 */
1398static bool 1388static bool
1399ath5k_receive_frame_ok(struct ath5k_softc *sc, struct ath5k_rx_status *rs) 1389ath5k_receive_frame_ok(struct ath5k_hw *ah, struct ath5k_rx_status *rs)
1400{ 1390{
1401 sc->stats.rx_all_count++; 1391 ah->stats.rx_all_count++;
1402 sc->stats.rx_bytes_count += rs->rs_datalen; 1392 ah->stats.rx_bytes_count += rs->rs_datalen;
1403 1393
1404 if (unlikely(rs->rs_status)) { 1394 if (unlikely(rs->rs_status)) {
1405 if (rs->rs_status & AR5K_RXERR_CRC) 1395 if (rs->rs_status & AR5K_RXERR_CRC)
1406 sc->stats.rxerr_crc++; 1396 ah->stats.rxerr_crc++;
1407 if (rs->rs_status & AR5K_RXERR_FIFO) 1397 if (rs->rs_status & AR5K_RXERR_FIFO)
1408 sc->stats.rxerr_fifo++; 1398 ah->stats.rxerr_fifo++;
1409 if (rs->rs_status & AR5K_RXERR_PHY) { 1399 if (rs->rs_status & AR5K_RXERR_PHY) {
1410 sc->stats.rxerr_phy++; 1400 ah->stats.rxerr_phy++;
1411 if (rs->rs_phyerr > 0 && rs->rs_phyerr < 32) 1401 if (rs->rs_phyerr > 0 && rs->rs_phyerr < 32)
1412 sc->stats.rxerr_phy_code[rs->rs_phyerr]++; 1402 ah->stats.rxerr_phy_code[rs->rs_phyerr]++;
1413 return false; 1403 return false;
1414 } 1404 }
1415 if (rs->rs_status & AR5K_RXERR_DECRYPT) { 1405 if (rs->rs_status & AR5K_RXERR_DECRYPT) {
@@ -1423,13 +1413,13 @@ ath5k_receive_frame_ok(struct ath5k_softc *sc, struct ath5k_rx_status *rs)
1423 * 1413 *
1424 * XXX do key cache faulting 1414 * XXX do key cache faulting
1425 */ 1415 */
1426 sc->stats.rxerr_decrypt++; 1416 ah->stats.rxerr_decrypt++;
1427 if (rs->rs_keyix == AR5K_RXKEYIX_INVALID && 1417 if (rs->rs_keyix == AR5K_RXKEYIX_INVALID &&
1428 !(rs->rs_status & AR5K_RXERR_CRC)) 1418 !(rs->rs_status & AR5K_RXERR_CRC))
1429 return true; 1419 return true;
1430 } 1420 }
1431 if (rs->rs_status & AR5K_RXERR_MIC) { 1421 if (rs->rs_status & AR5K_RXERR_MIC) {
1432 sc->stats.rxerr_mic++; 1422 ah->stats.rxerr_mic++;
1433 return true; 1423 return true;
1434 } 1424 }
1435 1425
@@ -1439,26 +1429,26 @@ ath5k_receive_frame_ok(struct ath5k_softc *sc, struct ath5k_rx_status *rs)
1439 } 1429 }
1440 1430
1441 if (unlikely(rs->rs_more)) { 1431 if (unlikely(rs->rs_more)) {
1442 sc->stats.rxerr_jumbo++; 1432 ah->stats.rxerr_jumbo++;
1443 return false; 1433 return false;
1444 } 1434 }
1445 return true; 1435 return true;
1446} 1436}
1447 1437
1448static void 1438static void
1449ath5k_set_current_imask(struct ath5k_softc *sc) 1439ath5k_set_current_imask(struct ath5k_hw *ah)
1450{ 1440{
1451 enum ath5k_int imask; 1441 enum ath5k_int imask;
1452 unsigned long flags; 1442 unsigned long flags;
1453 1443
1454 spin_lock_irqsave(&sc->irqlock, flags); 1444 spin_lock_irqsave(&ah->irqlock, flags);
1455 imask = sc->imask; 1445 imask = ah->imask;
1456 if (sc->rx_pending) 1446 if (ah->rx_pending)
1457 imask &= ~AR5K_INT_RX_ALL; 1447 imask &= ~AR5K_INT_RX_ALL;
1458 if (sc->tx_pending) 1448 if (ah->tx_pending)
1459 imask &= ~AR5K_INT_TX_ALL; 1449 imask &= ~AR5K_INT_TX_ALL;
1460 ath5k_hw_set_imr(sc->ah, imask); 1450 ath5k_hw_set_imr(ah, imask);
1461 spin_unlock_irqrestore(&sc->irqlock, flags); 1451 spin_unlock_irqrestore(&ah->irqlock, flags);
1462} 1452}
1463 1453
1464static void 1454static void
@@ -1467,39 +1457,38 @@ ath5k_tasklet_rx(unsigned long data)
1467 struct ath5k_rx_status rs = {}; 1457 struct ath5k_rx_status rs = {};
1468 struct sk_buff *skb, *next_skb; 1458 struct sk_buff *skb, *next_skb;
1469 dma_addr_t next_skb_addr; 1459 dma_addr_t next_skb_addr;
1470 struct ath5k_softc *sc = (void *)data; 1460 struct ath5k_hw *ah = (void *)data;
1471 struct ath5k_hw *ah = sc->ah;
1472 struct ath_common *common = ath5k_hw_common(ah); 1461 struct ath_common *common = ath5k_hw_common(ah);
1473 struct ath5k_buf *bf; 1462 struct ath5k_buf *bf;
1474 struct ath5k_desc *ds; 1463 struct ath5k_desc *ds;
1475 int ret; 1464 int ret;
1476 1465
1477 spin_lock(&sc->rxbuflock); 1466 spin_lock(&ah->rxbuflock);
1478 if (list_empty(&sc->rxbuf)) { 1467 if (list_empty(&ah->rxbuf)) {
1479 ATH5K_WARN(sc, "empty rx buf pool\n"); 1468 ATH5K_WARN(ah, "empty rx buf pool\n");
1480 goto unlock; 1469 goto unlock;
1481 } 1470 }
1482 do { 1471 do {
1483 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list); 1472 bf = list_first_entry(&ah->rxbuf, struct ath5k_buf, list);
1484 BUG_ON(bf->skb == NULL); 1473 BUG_ON(bf->skb == NULL);
1485 skb = bf->skb; 1474 skb = bf->skb;
1486 ds = bf->desc; 1475 ds = bf->desc;
1487 1476
1488 /* bail if HW is still using self-linked descriptor */ 1477 /* bail if HW is still using self-linked descriptor */
1489 if (ath5k_hw_get_rxdp(sc->ah) == bf->daddr) 1478 if (ath5k_hw_get_rxdp(ah) == bf->daddr)
1490 break; 1479 break;
1491 1480
1492 ret = sc->ah->ah_proc_rx_desc(sc->ah, ds, &rs); 1481 ret = ah->ah_proc_rx_desc(ah, ds, &rs);
1493 if (unlikely(ret == -EINPROGRESS)) 1482 if (unlikely(ret == -EINPROGRESS))
1494 break; 1483 break;
1495 else if (unlikely(ret)) { 1484 else if (unlikely(ret)) {
1496 ATH5K_ERR(sc, "error in processing rx descriptor\n"); 1485 ATH5K_ERR(ah, "error in processing rx descriptor\n");
1497 sc->stats.rxerr_proc++; 1486 ah->stats.rxerr_proc++;
1498 break; 1487 break;
1499 } 1488 }
1500 1489
1501 if (ath5k_receive_frame_ok(sc, &rs)) { 1490 if (ath5k_receive_frame_ok(ah, &rs)) {
1502 next_skb = ath5k_rx_skb_alloc(sc, &next_skb_addr); 1491 next_skb = ath5k_rx_skb_alloc(ah, &next_skb_addr);
1503 1492
1504 /* 1493 /*
1505 * If we can't replace bf->skb with a new skb under 1494 * If we can't replace bf->skb with a new skb under
@@ -1508,24 +1497,24 @@ ath5k_tasklet_rx(unsigned long data)
1508 if (!next_skb) 1497 if (!next_skb)
1509 goto next; 1498 goto next;
1510 1499
1511 dma_unmap_single(sc->dev, bf->skbaddr, 1500 dma_unmap_single(ah->dev, bf->skbaddr,
1512 common->rx_bufsize, 1501 common->rx_bufsize,
1513 DMA_FROM_DEVICE); 1502 DMA_FROM_DEVICE);
1514 1503
1515 skb_put(skb, rs.rs_datalen); 1504 skb_put(skb, rs.rs_datalen);
1516 1505
1517 ath5k_receive_frame(sc, skb, &rs); 1506 ath5k_receive_frame(ah, skb, &rs);
1518 1507
1519 bf->skb = next_skb; 1508 bf->skb = next_skb;
1520 bf->skbaddr = next_skb_addr; 1509 bf->skbaddr = next_skb_addr;
1521 } 1510 }
1522next: 1511next:
1523 list_move_tail(&bf->list, &sc->rxbuf); 1512 list_move_tail(&bf->list, &ah->rxbuf);
1524 } while (ath5k_rxbuf_setup(sc, bf) == 0); 1513 } while (ath5k_rxbuf_setup(ah, bf) == 0);
1525unlock: 1514unlock:
1526 spin_unlock(&sc->rxbuflock); 1515 spin_unlock(&ah->rxbuflock);
1527 sc->rx_pending = false; 1516 ah->rx_pending = false;
1528 ath5k_set_current_imask(sc); 1517 ath5k_set_current_imask(ah);
1529} 1518}
1530 1519
1531 1520
@@ -1537,12 +1526,12 @@ void
1537ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, 1526ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
1538 struct ath5k_txq *txq) 1527 struct ath5k_txq *txq)
1539{ 1528{
1540 struct ath5k_softc *sc = hw->priv; 1529 struct ath5k_hw *ah = hw->priv;
1541 struct ath5k_buf *bf; 1530 struct ath5k_buf *bf;
1542 unsigned long flags; 1531 unsigned long flags;
1543 int padsize; 1532 int padsize;
1544 1533
1545 trace_ath5k_tx(sc, skb, txq); 1534 trace_ath5k_tx(ah, skb, txq);
1546 1535
1547 /* 1536 /*
1548 * The hardware expects the header padded to 4 byte boundaries. 1537 * The hardware expects the header padded to 4 byte boundaries.
@@ -1550,7 +1539,7 @@ ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
1550 */ 1539 */
1551 padsize = ath5k_add_padding(skb); 1540 padsize = ath5k_add_padding(skb);
1552 if (padsize < 0) { 1541 if (padsize < 0) {
1553 ATH5K_ERR(sc, "tx hdrlen not %%4: not enough" 1542 ATH5K_ERR(ah, "tx hdrlen not %%4: not enough"
1554 " headroom to pad"); 1543 " headroom to pad");
1555 goto drop_packet; 1544 goto drop_packet;
1556 } 1545 }
@@ -1559,28 +1548,28 @@ ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
1559 txq->qnum <= AR5K_TX_QUEUE_ID_DATA_MAX) 1548 txq->qnum <= AR5K_TX_QUEUE_ID_DATA_MAX)
1560 ieee80211_stop_queue(hw, txq->qnum); 1549 ieee80211_stop_queue(hw, txq->qnum);
1561 1550
1562 spin_lock_irqsave(&sc->txbuflock, flags); 1551 spin_lock_irqsave(&ah->txbuflock, flags);
1563 if (list_empty(&sc->txbuf)) { 1552 if (list_empty(&ah->txbuf)) {
1564 ATH5K_ERR(sc, "no further txbuf available, dropping packet\n"); 1553 ATH5K_ERR(ah, "no further txbuf available, dropping packet\n");
1565 spin_unlock_irqrestore(&sc->txbuflock, flags); 1554 spin_unlock_irqrestore(&ah->txbuflock, flags);
1566 ieee80211_stop_queues(hw); 1555 ieee80211_stop_queues(hw);
1567 goto drop_packet; 1556 goto drop_packet;
1568 } 1557 }
1569 bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list); 1558 bf = list_first_entry(&ah->txbuf, struct ath5k_buf, list);
1570 list_del(&bf->list); 1559 list_del(&bf->list);
1571 sc->txbuf_len--; 1560 ah->txbuf_len--;
1572 if (list_empty(&sc->txbuf)) 1561 if (list_empty(&ah->txbuf))
1573 ieee80211_stop_queues(hw); 1562 ieee80211_stop_queues(hw);
1574 spin_unlock_irqrestore(&sc->txbuflock, flags); 1563 spin_unlock_irqrestore(&ah->txbuflock, flags);
1575 1564
1576 bf->skb = skb; 1565 bf->skb = skb;
1577 1566
1578 if (ath5k_txbuf_setup(sc, bf, txq, padsize)) { 1567 if (ath5k_txbuf_setup(ah, bf, txq, padsize)) {
1579 bf->skb = NULL; 1568 bf->skb = NULL;
1580 spin_lock_irqsave(&sc->txbuflock, flags); 1569 spin_lock_irqsave(&ah->txbuflock, flags);
1581 list_add_tail(&bf->list, &sc->txbuf); 1570 list_add_tail(&bf->list, &ah->txbuf);
1582 sc->txbuf_len++; 1571 ah->txbuf_len++;
1583 spin_unlock_irqrestore(&sc->txbuflock, flags); 1572 spin_unlock_irqrestore(&ah->txbuflock, flags);
1584 goto drop_packet; 1573 goto drop_packet;
1585 } 1574 }
1586 return; 1575 return;
@@ -1590,15 +1579,15 @@ drop_packet:
1590} 1579}
1591 1580
1592static void 1581static void
1593ath5k_tx_frame_completed(struct ath5k_softc *sc, struct sk_buff *skb, 1582ath5k_tx_frame_completed(struct ath5k_hw *ah, struct sk_buff *skb,
1594 struct ath5k_txq *txq, struct ath5k_tx_status *ts) 1583 struct ath5k_txq *txq, struct ath5k_tx_status *ts)
1595{ 1584{
1596 struct ieee80211_tx_info *info; 1585 struct ieee80211_tx_info *info;
1597 u8 tries[3]; 1586 u8 tries[3];
1598 int i; 1587 int i;
1599 1588
1600 sc->stats.tx_all_count++; 1589 ah->stats.tx_all_count++;
1601 sc->stats.tx_bytes_count += skb->len; 1590 ah->stats.tx_bytes_count += skb->len;
1602 info = IEEE80211_SKB_CB(skb); 1591 info = IEEE80211_SKB_CB(skb);
1603 1592
1604 tries[0] = info->status.rates[0].count; 1593 tries[0] = info->status.rates[0].count;
@@ -1618,15 +1607,15 @@ ath5k_tx_frame_completed(struct ath5k_softc *sc, struct sk_buff *skb,
1618 info->status.rates[ts->ts_final_idx + 1].idx = -1; 1607 info->status.rates[ts->ts_final_idx + 1].idx = -1;
1619 1608
1620 if (unlikely(ts->ts_status)) { 1609 if (unlikely(ts->ts_status)) {
1621 sc->stats.ack_fail++; 1610 ah->stats.ack_fail++;
1622 if (ts->ts_status & AR5K_TXERR_FILT) { 1611 if (ts->ts_status & AR5K_TXERR_FILT) {
1623 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 1612 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
1624 sc->stats.txerr_filt++; 1613 ah->stats.txerr_filt++;
1625 } 1614 }
1626 if (ts->ts_status & AR5K_TXERR_XRETRY) 1615 if (ts->ts_status & AR5K_TXERR_XRETRY)
1627 sc->stats.txerr_retry++; 1616 ah->stats.txerr_retry++;
1628 if (ts->ts_status & AR5K_TXERR_FIFO) 1617 if (ts->ts_status & AR5K_TXERR_FIFO)
1629 sc->stats.txerr_fifo++; 1618 ah->stats.txerr_fifo++;
1630 } else { 1619 } else {
1631 info->flags |= IEEE80211_TX_STAT_ACK; 1620 info->flags |= IEEE80211_TX_STAT_ACK;
1632 info->status.ack_signal = ts->ts_rssi; 1621 info->status.ack_signal = ts->ts_rssi;
@@ -1642,16 +1631,16 @@ ath5k_tx_frame_completed(struct ath5k_softc *sc, struct sk_buff *skb,
1642 ath5k_remove_padding(skb); 1631 ath5k_remove_padding(skb);
1643 1632
1644 if (ts->ts_antenna > 0 && ts->ts_antenna < 5) 1633 if (ts->ts_antenna > 0 && ts->ts_antenna < 5)
1645 sc->stats.antenna_tx[ts->ts_antenna]++; 1634 ah->stats.antenna_tx[ts->ts_antenna]++;
1646 else 1635 else
1647 sc->stats.antenna_tx[0]++; /* invalid */ 1636 ah->stats.antenna_tx[0]++; /* invalid */
1648 1637
1649 trace_ath5k_tx_complete(sc, skb, txq, ts); 1638 trace_ath5k_tx_complete(ah, skb, txq, ts);
1650 ieee80211_tx_status(sc->hw, skb); 1639 ieee80211_tx_status(ah->hw, skb);
1651} 1640}
1652 1641
1653static void 1642static void
1654ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq) 1643ath5k_tx_processq(struct ath5k_hw *ah, struct ath5k_txq *txq)
1655{ 1644{
1656 struct ath5k_tx_status ts = {}; 1645 struct ath5k_tx_status ts = {};
1657 struct ath5k_buf *bf, *bf0; 1646 struct ath5k_buf *bf, *bf0;
@@ -1668,11 +1657,11 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
1668 if (bf->skb != NULL) { 1657 if (bf->skb != NULL) {
1669 ds = bf->desc; 1658 ds = bf->desc;
1670 1659
1671 ret = sc->ah->ah_proc_tx_desc(sc->ah, ds, &ts); 1660 ret = ah->ah_proc_tx_desc(ah, ds, &ts);
1672 if (unlikely(ret == -EINPROGRESS)) 1661 if (unlikely(ret == -EINPROGRESS))
1673 break; 1662 break;
1674 else if (unlikely(ret)) { 1663 else if (unlikely(ret)) {
1675 ATH5K_ERR(sc, 1664 ATH5K_ERR(ah,
1676 "error %d while processing " 1665 "error %d while processing "
1677 "queue %u\n", ret, txq->qnum); 1666 "queue %u\n", ret, txq->qnum);
1678 break; 1667 break;
@@ -1681,9 +1670,9 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
1681 skb = bf->skb; 1670 skb = bf->skb;
1682 bf->skb = NULL; 1671 bf->skb = NULL;
1683 1672
1684 dma_unmap_single(sc->dev, bf->skbaddr, skb->len, 1673 dma_unmap_single(ah->dev, bf->skbaddr, skb->len,
1685 DMA_TO_DEVICE); 1674 DMA_TO_DEVICE);
1686 ath5k_tx_frame_completed(sc, skb, txq, &ts); 1675 ath5k_tx_frame_completed(ah, skb, txq, &ts);
1687 } 1676 }
1688 1677
1689 /* 1678 /*
@@ -1692,31 +1681,31 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
1692 * host memory and moved on. 1681 * host memory and moved on.
1693 * Always keep the last descriptor to avoid HW races... 1682 * Always keep the last descriptor to avoid HW races...
1694 */ 1683 */
1695 if (ath5k_hw_get_txdp(sc->ah, txq->qnum) != bf->daddr) { 1684 if (ath5k_hw_get_txdp(ah, txq->qnum) != bf->daddr) {
1696 spin_lock(&sc->txbuflock); 1685 spin_lock(&ah->txbuflock);
1697 list_move_tail(&bf->list, &sc->txbuf); 1686 list_move_tail(&bf->list, &ah->txbuf);
1698 sc->txbuf_len++; 1687 ah->txbuf_len++;
1699 txq->txq_len--; 1688 txq->txq_len--;
1700 spin_unlock(&sc->txbuflock); 1689 spin_unlock(&ah->txbuflock);
1701 } 1690 }
1702 } 1691 }
1703 spin_unlock(&txq->lock); 1692 spin_unlock(&txq->lock);
1704 if (txq->txq_len < ATH5K_TXQ_LEN_LOW && txq->qnum < 4) 1693 if (txq->txq_len < ATH5K_TXQ_LEN_LOW && txq->qnum < 4)
1705 ieee80211_wake_queue(sc->hw, txq->qnum); 1694 ieee80211_wake_queue(ah->hw, txq->qnum);
1706} 1695}
1707 1696
1708static void 1697static void
1709ath5k_tasklet_tx(unsigned long data) 1698ath5k_tasklet_tx(unsigned long data)
1710{ 1699{
1711 int i; 1700 int i;
1712 struct ath5k_softc *sc = (void *)data; 1701 struct ath5k_hw *ah = (void *)data;
1713 1702
1714 for (i = 0; i < AR5K_NUM_TX_QUEUES; i++) 1703 for (i = 0; i < AR5K_NUM_TX_QUEUES; i++)
1715 if (sc->txqs[i].setup && (sc->ah->ah_txq_isr & BIT(i))) 1704 if (ah->txqs[i].setup && (ah->ah_txq_isr & BIT(i)))
1716 ath5k_tx_processq(sc, &sc->txqs[i]); 1705 ath5k_tx_processq(ah, &ah->txqs[i]);
1717 1706
1718 sc->tx_pending = false; 1707 ah->tx_pending = false;
1719 ath5k_set_current_imask(sc); 1708 ath5k_set_current_imask(ah);
1720} 1709}
1721 1710
1722 1711
@@ -1728,25 +1717,24 @@ ath5k_tasklet_tx(unsigned long data)
1728 * Setup the beacon frame for transmit. 1717 * Setup the beacon frame for transmit.
1729 */ 1718 */
1730static int 1719static int
1731ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) 1720ath5k_beacon_setup(struct ath5k_hw *ah, struct ath5k_buf *bf)
1732{ 1721{
1733 struct sk_buff *skb = bf->skb; 1722 struct sk_buff *skb = bf->skb;
1734 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1723 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1735 struct ath5k_hw *ah = sc->ah;
1736 struct ath5k_desc *ds; 1724 struct ath5k_desc *ds;
1737 int ret = 0; 1725 int ret = 0;
1738 u8 antenna; 1726 u8 antenna;
1739 u32 flags; 1727 u32 flags;
1740 const int padsize = 0; 1728 const int padsize = 0;
1741 1729
1742 bf->skbaddr = dma_map_single(sc->dev, skb->data, skb->len, 1730 bf->skbaddr = dma_map_single(ah->dev, skb->data, skb->len,
1743 DMA_TO_DEVICE); 1731 DMA_TO_DEVICE);
1744 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] " 1732 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] "
1745 "skbaddr %llx\n", skb, skb->data, skb->len, 1733 "skbaddr %llx\n", skb, skb->data, skb->len,
1746 (unsigned long long)bf->skbaddr); 1734 (unsigned long long)bf->skbaddr);
1747 1735
1748 if (dma_mapping_error(sc->dev, bf->skbaddr)) { 1736 if (dma_mapping_error(ah->dev, bf->skbaddr)) {
1749 ATH5K_ERR(sc, "beacon DMA mapping failed\n"); 1737 ATH5K_ERR(ah, "beacon DMA mapping failed\n");
1750 return -EIO; 1738 return -EIO;
1751 } 1739 }
1752 1740
@@ -1754,7 +1742,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1754 antenna = ah->ah_tx_ant; 1742 antenna = ah->ah_tx_ant;
1755 1743
1756 flags = AR5K_TXDESC_NOACK; 1744 flags = AR5K_TXDESC_NOACK;
1757 if (sc->opmode == NL80211_IFTYPE_ADHOC && ath5k_hw_hasveol(ah)) { 1745 if (ah->opmode == NL80211_IFTYPE_ADHOC && ath5k_hw_hasveol(ah)) {
1758 ds->ds_link = bf->daddr; /* self-linked */ 1746 ds->ds_link = bf->daddr; /* self-linked */
1759 flags |= AR5K_TXDESC_VEOL; 1747 flags |= AR5K_TXDESC_VEOL;
1760 } else 1748 } else
@@ -1779,7 +1767,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1779 * on all of them. 1767 * on all of them.
1780 */ 1768 */
1781 if (ah->ah_ant_mode == AR5K_ANTMODE_SECTOR_AP) 1769 if (ah->ah_ant_mode == AR5K_ANTMODE_SECTOR_AP)
1782 antenna = sc->bsent & 4 ? 2 : 1; 1770 antenna = ah->bsent & 4 ? 2 : 1;
1783 1771
1784 1772
1785 /* FIXME: If we are in g mode and rate is a CCK rate 1773 /* FIXME: If we are in g mode and rate is a CCK rate
@@ -1788,8 +1776,8 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1788 ds->ds_data = bf->skbaddr; 1776 ds->ds_data = bf->skbaddr;
1789 ret = ah->ah_setup_tx_desc(ah, ds, skb->len, 1777 ret = ah->ah_setup_tx_desc(ah, ds, skb->len,
1790 ieee80211_get_hdrlen_from_skb(skb), padsize, 1778 ieee80211_get_hdrlen_from_skb(skb), padsize,
1791 AR5K_PKT_TYPE_BEACON, (sc->power_level * 2), 1779 AR5K_PKT_TYPE_BEACON, (ah->power_level * 2),
1792 ieee80211_get_tx_rate(sc->hw, info)->hw_value, 1780 ieee80211_get_tx_rate(ah->hw, info)->hw_value,
1793 1, AR5K_TXKEYIX_INVALID, 1781 1, AR5K_TXKEYIX_INVALID,
1794 antenna, flags, 0, 0); 1782 antenna, flags, 0, 0);
1795 if (ret) 1783 if (ret)
@@ -1797,7 +1785,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1797 1785
1798 return 0; 1786 return 0;
1799err_unmap: 1787err_unmap:
1800 dma_unmap_single(sc->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE); 1788 dma_unmap_single(ah->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE);
1801 return ret; 1789 return ret;
1802} 1790}
1803 1791
@@ -1812,7 +1800,7 @@ int
1812ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 1800ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1813{ 1801{
1814 int ret; 1802 int ret;
1815 struct ath5k_softc *sc = hw->priv; 1803 struct ath5k_hw *ah = hw->priv;
1816 struct ath5k_vif *avf = (void *)vif->drv_priv; 1804 struct ath5k_vif *avf = (void *)vif->drv_priv;
1817 struct sk_buff *skb; 1805 struct sk_buff *skb;
1818 1806
@@ -1828,9 +1816,9 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1828 goto out; 1816 goto out;
1829 } 1817 }
1830 1818
1831 ath5k_txbuf_free_skb(sc, avf->bbuf); 1819 ath5k_txbuf_free_skb(ah, avf->bbuf);
1832 avf->bbuf->skb = skb; 1820 avf->bbuf->skb = skb;
1833 ret = ath5k_beacon_setup(sc, avf->bbuf); 1821 ret = ath5k_beacon_setup(ah, avf->bbuf);
1834 if (ret) 1822 if (ret)
1835 avf->bbuf->skb = NULL; 1823 avf->bbuf->skb = NULL;
1836out: 1824out:
@@ -1846,15 +1834,14 @@ out:
1846 * or user context from ath5k_beacon_config. 1834 * or user context from ath5k_beacon_config.
1847 */ 1835 */
1848static void 1836static void
1849ath5k_beacon_send(struct ath5k_softc *sc) 1837ath5k_beacon_send(struct ath5k_hw *ah)
1850{ 1838{
1851 struct ath5k_hw *ah = sc->ah;
1852 struct ieee80211_vif *vif; 1839 struct ieee80211_vif *vif;
1853 struct ath5k_vif *avf; 1840 struct ath5k_vif *avf;
1854 struct ath5k_buf *bf; 1841 struct ath5k_buf *bf;
1855 struct sk_buff *skb; 1842 struct sk_buff *skb;
1856 1843
1857 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "in beacon_send\n"); 1844 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, "in beacon_send\n");
1858 1845
1859 /* 1846 /*
1860 * Check if the previous beacon has gone out. If 1847 * Check if the previous beacon has gone out. If
@@ -1863,47 +1850,47 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1863 * indicate a problem and should not occur. If we 1850 * indicate a problem and should not occur. If we
1864 * miss too many consecutive beacons reset the device. 1851 * miss too many consecutive beacons reset the device.
1865 */ 1852 */
1866 if (unlikely(ath5k_hw_num_tx_pending(ah, sc->bhalq) != 0)) { 1853 if (unlikely(ath5k_hw_num_tx_pending(ah, ah->bhalq) != 0)) {
1867 sc->bmisscount++; 1854 ah->bmisscount++;
1868 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 1855 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON,
1869 "missed %u consecutive beacons\n", sc->bmisscount); 1856 "missed %u consecutive beacons\n", ah->bmisscount);
1870 if (sc->bmisscount > 10) { /* NB: 10 is a guess */ 1857 if (ah->bmisscount > 10) { /* NB: 10 is a guess */
1871 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 1858 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON,
1872 "stuck beacon time (%u missed)\n", 1859 "stuck beacon time (%u missed)\n",
1873 sc->bmisscount); 1860 ah->bmisscount);
1874 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 1861 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
1875 "stuck beacon, resetting\n"); 1862 "stuck beacon, resetting\n");
1876 ieee80211_queue_work(sc->hw, &sc->reset_work); 1863 ieee80211_queue_work(ah->hw, &ah->reset_work);
1877 } 1864 }
1878 return; 1865 return;
1879 } 1866 }
1880 if (unlikely(sc->bmisscount != 0)) { 1867 if (unlikely(ah->bmisscount != 0)) {
1881 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 1868 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON,
1882 "resume beacon xmit after %u misses\n", 1869 "resume beacon xmit after %u misses\n",
1883 sc->bmisscount); 1870 ah->bmisscount);
1884 sc->bmisscount = 0; 1871 ah->bmisscount = 0;
1885 } 1872 }
1886 1873
1887 if ((sc->opmode == NL80211_IFTYPE_AP && sc->num_ap_vifs > 1) || 1874 if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs > 1) ||
1888 sc->opmode == NL80211_IFTYPE_MESH_POINT) { 1875 ah->opmode == NL80211_IFTYPE_MESH_POINT) {
1889 u64 tsf = ath5k_hw_get_tsf64(ah); 1876 u64 tsf = ath5k_hw_get_tsf64(ah);
1890 u32 tsftu = TSF_TO_TU(tsf); 1877 u32 tsftu = TSF_TO_TU(tsf);
1891 int slot = ((tsftu % sc->bintval) * ATH_BCBUF) / sc->bintval; 1878 int slot = ((tsftu % ah->bintval) * ATH_BCBUF) / ah->bintval;
1892 vif = sc->bslot[(slot + 1) % ATH_BCBUF]; 1879 vif = ah->bslot[(slot + 1) % ATH_BCBUF];
1893 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 1880 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON,
1894 "tsf %llx tsftu %x intval %u slot %u vif %p\n", 1881 "tsf %llx tsftu %x intval %u slot %u vif %p\n",
1895 (unsigned long long)tsf, tsftu, sc->bintval, slot, vif); 1882 (unsigned long long)tsf, tsftu, ah->bintval, slot, vif);
1896 } else /* only one interface */ 1883 } else /* only one interface */
1897 vif = sc->bslot[0]; 1884 vif = ah->bslot[0];
1898 1885
1899 if (!vif) 1886 if (!vif)
1900 return; 1887 return;
1901 1888
1902 avf = (void *)vif->drv_priv; 1889 avf = (void *)vif->drv_priv;
1903 bf = avf->bbuf; 1890 bf = avf->bbuf;
1904 if (unlikely(bf->skb == NULL || sc->opmode == NL80211_IFTYPE_STATION || 1891 if (unlikely(bf->skb == NULL || ah->opmode == NL80211_IFTYPE_STATION ||
1905 sc->opmode == NL80211_IFTYPE_MONITOR)) { 1892 ah->opmode == NL80211_IFTYPE_MONITOR)) {
1906 ATH5K_WARN(sc, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL); 1893 ATH5K_WARN(ah, "bf=%p bf_skb=%p\n", bf, bf ? bf->skb : NULL);
1907 return; 1894 return;
1908 } 1895 }
1909 1896
@@ -1912,40 +1899,40 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1912 * This should never fail since we check above that no frames 1899 * This should never fail since we check above that no frames
1913 * are still pending on the queue. 1900 * are still pending on the queue.
1914 */ 1901 */
1915 if (unlikely(ath5k_hw_stop_beacon_queue(ah, sc->bhalq))) { 1902 if (unlikely(ath5k_hw_stop_beacon_queue(ah, ah->bhalq))) {
1916 ATH5K_WARN(sc, "beacon queue %u didn't start/stop ?\n", sc->bhalq); 1903 ATH5K_WARN(ah, "beacon queue %u didn't start/stop ?\n", ah->bhalq);
1917 /* NB: hw still stops DMA, so proceed */ 1904 /* NB: hw still stops DMA, so proceed */
1918 } 1905 }
1919 1906
1920 /* refresh the beacon for AP or MESH mode */ 1907 /* refresh the beacon for AP or MESH mode */
1921 if (sc->opmode == NL80211_IFTYPE_AP || 1908 if (ah->opmode == NL80211_IFTYPE_AP ||
1922 sc->opmode == NL80211_IFTYPE_MESH_POINT) 1909 ah->opmode == NL80211_IFTYPE_MESH_POINT)
1923 ath5k_beacon_update(sc->hw, vif); 1910 ath5k_beacon_update(ah->hw, vif);
1924 1911
1925 trace_ath5k_tx(sc, bf->skb, &sc->txqs[sc->bhalq]); 1912 trace_ath5k_tx(ah, bf->skb, &ah->txqs[ah->bhalq]);
1926 1913
1927 ath5k_hw_set_txdp(ah, sc->bhalq, bf->daddr); 1914 ath5k_hw_set_txdp(ah, ah->bhalq, bf->daddr);
1928 ath5k_hw_start_tx_dma(ah, sc->bhalq); 1915 ath5k_hw_start_tx_dma(ah, ah->bhalq);
1929 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "TXDP[%u] = %llx (%p)\n", 1916 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, "TXDP[%u] = %llx (%p)\n",
1930 sc->bhalq, (unsigned long long)bf->daddr, bf->desc); 1917 ah->bhalq, (unsigned long long)bf->daddr, bf->desc);
1931 1918
1932 skb = ieee80211_get_buffered_bc(sc->hw, vif); 1919 skb = ieee80211_get_buffered_bc(ah->hw, vif);
1933 while (skb) { 1920 while (skb) {
1934 ath5k_tx_queue(sc->hw, skb, sc->cabq); 1921 ath5k_tx_queue(ah->hw, skb, ah->cabq);
1935 1922
1936 if (sc->cabq->txq_len >= sc->cabq->txq_max) 1923 if (ah->cabq->txq_len >= ah->cabq->txq_max)
1937 break; 1924 break;
1938 1925
1939 skb = ieee80211_get_buffered_bc(sc->hw, vif); 1926 skb = ieee80211_get_buffered_bc(ah->hw, vif);
1940 } 1927 }
1941 1928
1942 sc->bsent++; 1929 ah->bsent++;
1943} 1930}
1944 1931
1945/** 1932/**
1946 * ath5k_beacon_update_timers - update beacon timers 1933 * ath5k_beacon_update_timers - update beacon timers
1947 * 1934 *
1948 * @sc: struct ath5k_softc pointer we are operating on 1935 * @ah: struct ath5k_hw pointer we are operating on
1949 * @bc_tsf: the timestamp of the beacon. 0 to reset the TSF. -1 to perform a 1936 * @bc_tsf: the timestamp of the beacon. 0 to reset the TSF. -1 to perform a
1950 * beacon timer update based on the current HW TSF. 1937 * beacon timer update based on the current HW TSF.
1951 * 1938 *
@@ -1959,17 +1946,16 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1959 * function to have it all together in one place. 1946 * function to have it all together in one place.
1960 */ 1947 */
1961void 1948void
1962ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf) 1949ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf)
1963{ 1950{
1964 struct ath5k_hw *ah = sc->ah;
1965 u32 nexttbtt, intval, hw_tu, bc_tu; 1951 u32 nexttbtt, intval, hw_tu, bc_tu;
1966 u64 hw_tsf; 1952 u64 hw_tsf;
1967 1953
1968 intval = sc->bintval & AR5K_BEACON_PERIOD; 1954 intval = ah->bintval & AR5K_BEACON_PERIOD;
1969 if (sc->opmode == NL80211_IFTYPE_AP && sc->num_ap_vifs > 1) { 1955 if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs > 1) {
1970 intval /= ATH_BCBUF; /* staggered multi-bss beacons */ 1956 intval /= ATH_BCBUF; /* staggered multi-bss beacons */
1971 if (intval < 15) 1957 if (intval < 15)
1972 ATH5K_WARN(sc, "intval %u is too low, min 15\n", 1958 ATH5K_WARN(ah, "intval %u is too low, min 15\n",
1973 intval); 1959 intval);
1974 } 1960 }
1975 if (WARN_ON(!intval)) 1961 if (WARN_ON(!intval))
@@ -2008,7 +1994,7 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
2008 * automatically update the TSF and then we need to reconfigure 1994 * automatically update the TSF and then we need to reconfigure
2009 * the timers. 1995 * the timers.
2010 */ 1996 */
2011 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 1997 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
2012 "need to wait for HW TSF sync\n"); 1998 "need to wait for HW TSF sync\n");
2013 return; 1999 return;
2014 } else { 2000 } else {
@@ -2023,7 +2009,7 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
2023 } 2009 }
2024#undef FUDGE 2010#undef FUDGE
2025 2011
2026 sc->nexttbtt = nexttbtt; 2012 ah->nexttbtt = nexttbtt;
2027 2013
2028 intval |= AR5K_BEACON_ENA; 2014 intval |= AR5K_BEACON_ENA;
2029 ath5k_hw_init_beacon(ah, nexttbtt, intval); 2015 ath5k_hw_init_beacon(ah, nexttbtt, intval);
@@ -2033,20 +2019,20 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
2033 * of this function 2019 * of this function
2034 */ 2020 */
2035 if (bc_tsf == -1) 2021 if (bc_tsf == -1)
2036 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 2022 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
2037 "reconfigured timers based on HW TSF\n"); 2023 "reconfigured timers based on HW TSF\n");
2038 else if (bc_tsf == 0) 2024 else if (bc_tsf == 0)
2039 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 2025 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
2040 "reset HW TSF and timers\n"); 2026 "reset HW TSF and timers\n");
2041 else 2027 else
2042 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 2028 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
2043 "updated timers based on beacon TSF\n"); 2029 "updated timers based on beacon TSF\n");
2044 2030
2045 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 2031 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON,
2046 "bc_tsf %llx hw_tsf %llx bc_tu %u hw_tu %u nexttbtt %u\n", 2032 "bc_tsf %llx hw_tsf %llx bc_tu %u hw_tu %u nexttbtt %u\n",
2047 (unsigned long long) bc_tsf, 2033 (unsigned long long) bc_tsf,
2048 (unsigned long long) hw_tsf, bc_tu, hw_tu, nexttbtt); 2034 (unsigned long long) hw_tsf, bc_tu, hw_tu, nexttbtt);
2049 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "intval %u %s %s\n", 2035 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, "intval %u %s %s\n",
2050 intval & AR5K_BEACON_PERIOD, 2036 intval & AR5K_BEACON_PERIOD,
2051 intval & AR5K_BEACON_ENA ? "AR5K_BEACON_ENA" : "", 2037 intval & AR5K_BEACON_ENA ? "AR5K_BEACON_ENA" : "",
2052 intval & AR5K_BEACON_RESET_TSF ? "AR5K_BEACON_RESET_TSF" : ""); 2038 intval & AR5K_BEACON_RESET_TSF ? "AR5K_BEACON_RESET_TSF" : "");
@@ -2055,22 +2041,21 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
2055/** 2041/**
2056 * ath5k_beacon_config - Configure the beacon queues and interrupts 2042 * ath5k_beacon_config - Configure the beacon queues and interrupts
2057 * 2043 *
2058 * @sc: struct ath5k_softc pointer we are operating on 2044 * @ah: struct ath5k_hw pointer we are operating on
2059 * 2045 *
2060 * In IBSS mode we use a self-linked tx descriptor if possible. We enable SWBA 2046 * In IBSS mode we use a self-linked tx descriptor if possible. We enable SWBA
2061 * interrupts to detect TSF updates only. 2047 * interrupts to detect TSF updates only.
2062 */ 2048 */
2063void 2049void
2064ath5k_beacon_config(struct ath5k_softc *sc) 2050ath5k_beacon_config(struct ath5k_hw *ah)
2065{ 2051{
2066 struct ath5k_hw *ah = sc->ah;
2067 unsigned long flags; 2052 unsigned long flags;
2068 2053
2069 spin_lock_irqsave(&sc->block, flags); 2054 spin_lock_irqsave(&ah->block, flags);
2070 sc->bmisscount = 0; 2055 ah->bmisscount = 0;
2071 sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA); 2056 ah->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA);
2072 2057
2073 if (sc->enable_beacon) { 2058 if (ah->enable_beacon) {
2074 /* 2059 /*
2075 * In IBSS mode we use a self-linked tx descriptor and let the 2060 * In IBSS mode we use a self-linked tx descriptor and let the
2076 * hardware send the beacons automatically. We have to load it 2061 * hardware send the beacons automatically. We have to load it
@@ -2078,27 +2063,27 @@ ath5k_beacon_config(struct ath5k_softc *sc)
2078 * We use the SWBA interrupt only to keep track of the beacon 2063 * We use the SWBA interrupt only to keep track of the beacon
2079 * timers in order to detect automatic TSF updates. 2064 * timers in order to detect automatic TSF updates.
2080 */ 2065 */
2081 ath5k_beaconq_config(sc); 2066 ath5k_beaconq_config(ah);
2082 2067
2083 sc->imask |= AR5K_INT_SWBA; 2068 ah->imask |= AR5K_INT_SWBA;
2084 2069
2085 if (sc->opmode == NL80211_IFTYPE_ADHOC) { 2070 if (ah->opmode == NL80211_IFTYPE_ADHOC) {
2086 if (ath5k_hw_hasveol(ah)) 2071 if (ath5k_hw_hasveol(ah))
2087 ath5k_beacon_send(sc); 2072 ath5k_beacon_send(ah);
2088 } else 2073 } else
2089 ath5k_beacon_update_timers(sc, -1); 2074 ath5k_beacon_update_timers(ah, -1);
2090 } else { 2075 } else {
2091 ath5k_hw_stop_beacon_queue(sc->ah, sc->bhalq); 2076 ath5k_hw_stop_beacon_queue(ah, ah->bhalq);
2092 } 2077 }
2093 2078
2094 ath5k_hw_set_imr(ah, sc->imask); 2079 ath5k_hw_set_imr(ah, ah->imask);
2095 mmiowb(); 2080 mmiowb();
2096 spin_unlock_irqrestore(&sc->block, flags); 2081 spin_unlock_irqrestore(&ah->block, flags);
2097} 2082}
2098 2083
2099static void ath5k_tasklet_beacon(unsigned long data) 2084static void ath5k_tasklet_beacon(unsigned long data)
2100{ 2085{
2101 struct ath5k_softc *sc = (struct ath5k_softc *) data; 2086 struct ath5k_hw *ah = (struct ath5k_hw *) data;
2102 2087
2103 /* 2088 /*
2104 * Software beacon alert--time to send a beacon. 2089 * Software beacon alert--time to send a beacon.
@@ -2108,20 +2093,20 @@ static void ath5k_tasklet_beacon(unsigned long data)
2108 * transmission time) in order to detect whether 2093 * transmission time) in order to detect whether
2109 * automatic TSF updates happened. 2094 * automatic TSF updates happened.
2110 */ 2095 */
2111 if (sc->opmode == NL80211_IFTYPE_ADHOC) { 2096 if (ah->opmode == NL80211_IFTYPE_ADHOC) {
2112 /* XXX: only if VEOL supported */ 2097 /* XXX: only if VEOL supported */
2113 u64 tsf = ath5k_hw_get_tsf64(sc->ah); 2098 u64 tsf = ath5k_hw_get_tsf64(ah);
2114 sc->nexttbtt += sc->bintval; 2099 ah->nexttbtt += ah->bintval;
2115 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 2100 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON,
2116 "SWBA nexttbtt: %x hw_tu: %x " 2101 "SWBA nexttbtt: %x hw_tu: %x "
2117 "TSF: %llx\n", 2102 "TSF: %llx\n",
2118 sc->nexttbtt, 2103 ah->nexttbtt,
2119 TSF_TO_TU(tsf), 2104 TSF_TO_TU(tsf),
2120 (unsigned long long) tsf); 2105 (unsigned long long) tsf);
2121 } else { 2106 } else {
2122 spin_lock(&sc->block); 2107 spin_lock(&ah->block);
2123 ath5k_beacon_send(sc); 2108 ath5k_beacon_send(ah);
2124 spin_unlock(&sc->block); 2109 spin_unlock(&ah->block);
2125 } 2110 }
2126} 2111}
2127 2112
@@ -2138,12 +2123,12 @@ ath5k_intr_calibration_poll(struct ath5k_hw *ah)
2138 /* run ANI only when full calibration is not active */ 2123 /* run ANI only when full calibration is not active */
2139 ah->ah_cal_next_ani = jiffies + 2124 ah->ah_cal_next_ani = jiffies +
2140 msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_ANI); 2125 msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_ANI);
2141 tasklet_schedule(&ah->ah_sc->ani_tasklet); 2126 tasklet_schedule(&ah->ani_tasklet);
2142 2127
2143 } else if (time_is_before_eq_jiffies(ah->ah_cal_next_full)) { 2128 } else if (time_is_before_eq_jiffies(ah->ah_cal_next_full)) {
2144 ah->ah_cal_next_full = jiffies + 2129 ah->ah_cal_next_full = jiffies +
2145 msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_FULL); 2130 msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_FULL);
2146 tasklet_schedule(&ah->ah_sc->calib); 2131 tasklet_schedule(&ah->calib);
2147 } 2132 }
2148 /* we could use SWI to generate enough interrupts to meet our 2133 /* we could use SWI to generate enough interrupts to meet our
2149 * calibration interval requirements, if necessary: 2134 * calibration interval requirements, if necessary:
@@ -2151,44 +2136,43 @@ ath5k_intr_calibration_poll(struct ath5k_hw *ah)
2151} 2136}
2152 2137
2153static void 2138static void
2154ath5k_schedule_rx(struct ath5k_softc *sc) 2139ath5k_schedule_rx(struct ath5k_hw *ah)
2155{ 2140{
2156 sc->rx_pending = true; 2141 ah->rx_pending = true;
2157 tasklet_schedule(&sc->rxtq); 2142 tasklet_schedule(&ah->rxtq);
2158} 2143}
2159 2144
2160static void 2145static void
2161ath5k_schedule_tx(struct ath5k_softc *sc) 2146ath5k_schedule_tx(struct ath5k_hw *ah)
2162{ 2147{
2163 sc->tx_pending = true; 2148 ah->tx_pending = true;
2164 tasklet_schedule(&sc->txtq); 2149 tasklet_schedule(&ah->txtq);
2165} 2150}
2166 2151
2167static irqreturn_t 2152static irqreturn_t
2168ath5k_intr(int irq, void *dev_id) 2153ath5k_intr(int irq, void *dev_id)
2169{ 2154{
2170 struct ath5k_softc *sc = dev_id; 2155 struct ath5k_hw *ah = dev_id;
2171 struct ath5k_hw *ah = sc->ah;
2172 enum ath5k_int status; 2156 enum ath5k_int status;
2173 unsigned int counter = 1000; 2157 unsigned int counter = 1000;
2174 2158
2175 if (unlikely(test_bit(ATH_STAT_INVALID, sc->status) || 2159 if (unlikely(test_bit(ATH_STAT_INVALID, ah->status) ||
2176 ((ath5k_get_bus_type(ah) != ATH_AHB) && 2160 ((ath5k_get_bus_type(ah) != ATH_AHB) &&
2177 !ath5k_hw_is_intr_pending(ah)))) 2161 !ath5k_hw_is_intr_pending(ah))))
2178 return IRQ_NONE; 2162 return IRQ_NONE;
2179 2163
2180 do { 2164 do {
2181 ath5k_hw_get_isr(ah, &status); /* NB: clears IRQ too */ 2165 ath5k_hw_get_isr(ah, &status); /* NB: clears IRQ too */
2182 ATH5K_DBG(sc, ATH5K_DEBUG_INTR, "status 0x%x/0x%x\n", 2166 ATH5K_DBG(ah, ATH5K_DEBUG_INTR, "status 0x%x/0x%x\n",
2183 status, sc->imask); 2167 status, ah->imask);
2184 if (unlikely(status & AR5K_INT_FATAL)) { 2168 if (unlikely(status & AR5K_INT_FATAL)) {
2185 /* 2169 /*
2186 * Fatal errors are unrecoverable. 2170 * Fatal errors are unrecoverable.
2187 * Typically these are caused by DMA errors. 2171 * Typically these are caused by DMA errors.
2188 */ 2172 */
2189 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 2173 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
2190 "fatal int, resetting\n"); 2174 "fatal int, resetting\n");
2191 ieee80211_queue_work(sc->hw, &sc->reset_work); 2175 ieee80211_queue_work(ah->hw, &ah->reset_work);
2192 } else if (unlikely(status & AR5K_INT_RXORN)) { 2176 } else if (unlikely(status & AR5K_INT_RXORN)) {
2193 /* 2177 /*
2194 * Receive buffers are full. Either the bus is busy or 2178 * Receive buffers are full. Either the bus is busy or
@@ -2199,16 +2183,16 @@ ath5k_intr(int irq, void *dev_id)
2199 * We don't know exactly which versions need a reset - 2183 * We don't know exactly which versions need a reset -
2200 * this guess is copied from the HAL. 2184 * this guess is copied from the HAL.
2201 */ 2185 */
2202 sc->stats.rxorn_intr++; 2186 ah->stats.rxorn_intr++;
2203 if (ah->ah_mac_srev < AR5K_SREV_AR5212) { 2187 if (ah->ah_mac_srev < AR5K_SREV_AR5212) {
2204 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 2188 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
2205 "rx overrun, resetting\n"); 2189 "rx overrun, resetting\n");
2206 ieee80211_queue_work(sc->hw, &sc->reset_work); 2190 ieee80211_queue_work(ah->hw, &ah->reset_work);
2207 } else 2191 } else
2208 ath5k_schedule_rx(sc); 2192 ath5k_schedule_rx(ah);
2209 } else { 2193 } else {
2210 if (status & AR5K_INT_SWBA) 2194 if (status & AR5K_INT_SWBA)
2211 tasklet_hi_schedule(&sc->beacontq); 2195 tasklet_hi_schedule(&ah->beacontq);
2212 2196
2213 if (status & AR5K_INT_RXEOL) { 2197 if (status & AR5K_INT_RXEOL) {
2214 /* 2198 /*
@@ -2216,27 +2200,27 @@ ath5k_intr(int irq, void *dev_id)
2216 * RXE bit is written, but it doesn't work at 2200 * RXE bit is written, but it doesn't work at
2217 * least on older hardware revs. 2201 * least on older hardware revs.
2218 */ 2202 */
2219 sc->stats.rxeol_intr++; 2203 ah->stats.rxeol_intr++;
2220 } 2204 }
2221 if (status & AR5K_INT_TXURN) { 2205 if (status & AR5K_INT_TXURN) {
2222 /* bump tx trigger level */ 2206 /* bump tx trigger level */
2223 ath5k_hw_update_tx_triglevel(ah, true); 2207 ath5k_hw_update_tx_triglevel(ah, true);
2224 } 2208 }
2225 if (status & (AR5K_INT_RXOK | AR5K_INT_RXERR)) 2209 if (status & (AR5K_INT_RXOK | AR5K_INT_RXERR))
2226 ath5k_schedule_rx(sc); 2210 ath5k_schedule_rx(ah);
2227 if (status & (AR5K_INT_TXOK | AR5K_INT_TXDESC 2211 if (status & (AR5K_INT_TXOK | AR5K_INT_TXDESC
2228 | AR5K_INT_TXERR | AR5K_INT_TXEOL)) 2212 | AR5K_INT_TXERR | AR5K_INT_TXEOL))
2229 ath5k_schedule_tx(sc); 2213 ath5k_schedule_tx(ah);
2230 if (status & AR5K_INT_BMISS) { 2214 if (status & AR5K_INT_BMISS) {
2231 /* TODO */ 2215 /* TODO */
2232 } 2216 }
2233 if (status & AR5K_INT_MIB) { 2217 if (status & AR5K_INT_MIB) {
2234 sc->stats.mib_intr++; 2218 ah->stats.mib_intr++;
2235 ath5k_hw_update_mib_counters(ah); 2219 ath5k_hw_update_mib_counters(ah);
2236 ath5k_ani_mib_intr(ah); 2220 ath5k_ani_mib_intr(ah);
2237 } 2221 }
2238 if (status & AR5K_INT_GPIO) 2222 if (status & AR5K_INT_GPIO)
2239 tasklet_schedule(&sc->rf_kill.toggleq); 2223 tasklet_schedule(&ah->rf_kill.toggleq);
2240 2224
2241 } 2225 }
2242 2226
@@ -2245,11 +2229,11 @@ ath5k_intr(int irq, void *dev_id)
2245 2229
2246 } while (ath5k_hw_is_intr_pending(ah) && --counter > 0); 2230 } while (ath5k_hw_is_intr_pending(ah) && --counter > 0);
2247 2231
2248 if (sc->rx_pending || sc->tx_pending) 2232 if (ah->rx_pending || ah->tx_pending)
2249 ath5k_set_current_imask(sc); 2233 ath5k_set_current_imask(ah);
2250 2234
2251 if (unlikely(!counter)) 2235 if (unlikely(!counter))
2252 ATH5K_WARN(sc, "too many interrupts, giving up for now\n"); 2236 ATH5K_WARN(ah, "too many interrupts, giving up for now\n");
2253 2237
2254 ath5k_intr_calibration_poll(ah); 2238 ath5k_intr_calibration_poll(ah);
2255 2239
@@ -2263,28 +2247,27 @@ ath5k_intr(int irq, void *dev_id)
2263static void 2247static void
2264ath5k_tasklet_calibrate(unsigned long data) 2248ath5k_tasklet_calibrate(unsigned long data)
2265{ 2249{
2266 struct ath5k_softc *sc = (void *)data; 2250 struct ath5k_hw *ah = (void *)data;
2267 struct ath5k_hw *ah = sc->ah;
2268 2251
2269 /* Only full calibration for now */ 2252 /* Only full calibration for now */
2270 ah->ah_cal_mask |= AR5K_CALIBRATION_FULL; 2253 ah->ah_cal_mask |= AR5K_CALIBRATION_FULL;
2271 2254
2272 ATH5K_DBG(sc, ATH5K_DEBUG_CALIBRATE, "channel %u/%x\n", 2255 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE, "channel %u/%x\n",
2273 ieee80211_frequency_to_channel(sc->curchan->center_freq), 2256 ieee80211_frequency_to_channel(ah->curchan->center_freq),
2274 sc->curchan->hw_value); 2257 ah->curchan->hw_value);
2275 2258
2276 if (ath5k_hw_gainf_calibrate(ah) == AR5K_RFGAIN_NEED_CHANGE) { 2259 if (ath5k_hw_gainf_calibrate(ah) == AR5K_RFGAIN_NEED_CHANGE) {
2277 /* 2260 /*
2278 * Rfgain is out of bounds, reset the chip 2261 * Rfgain is out of bounds, reset the chip
2279 * to load new gain values. 2262 * to load new gain values.
2280 */ 2263 */
2281 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "calibration, resetting\n"); 2264 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "calibration, resetting\n");
2282 ieee80211_queue_work(sc->hw, &sc->reset_work); 2265 ieee80211_queue_work(ah->hw, &ah->reset_work);
2283 } 2266 }
2284 if (ath5k_hw_phy_calibrate(ah, sc->curchan)) 2267 if (ath5k_hw_phy_calibrate(ah, ah->curchan))
2285 ATH5K_ERR(sc, "calibration of channel %u failed\n", 2268 ATH5K_ERR(ah, "calibration of channel %u failed\n",
2286 ieee80211_frequency_to_channel( 2269 ieee80211_frequency_to_channel(
2287 sc->curchan->center_freq)); 2270 ah->curchan->center_freq));
2288 2271
2289 /* Noise floor calibration interrupts rx/tx path while I/Q calibration 2272 /* Noise floor calibration interrupts rx/tx path while I/Q calibration
2290 * doesn't. 2273 * doesn't.
@@ -2303,8 +2286,7 @@ ath5k_tasklet_calibrate(unsigned long data)
2303static void 2286static void
2304ath5k_tasklet_ani(unsigned long data) 2287ath5k_tasklet_ani(unsigned long data)
2305{ 2288{
2306 struct ath5k_softc *sc = (void *)data; 2289 struct ath5k_hw *ah = (void *)data;
2307 struct ath5k_hw *ah = sc->ah;
2308 2290
2309 ah->ah_cal_mask |= AR5K_CALIBRATION_ANI; 2291 ah->ah_cal_mask |= AR5K_CALIBRATION_ANI;
2310 ath5k_ani_calibration(ah); 2292 ath5k_ani_calibration(ah);
@@ -2315,21 +2297,21 @@ ath5k_tasklet_ani(unsigned long data)
2315static void 2297static void
2316ath5k_tx_complete_poll_work(struct work_struct *work) 2298ath5k_tx_complete_poll_work(struct work_struct *work)
2317{ 2299{
2318 struct ath5k_softc *sc = container_of(work, struct ath5k_softc, 2300 struct ath5k_hw *ah = container_of(work, struct ath5k_hw,
2319 tx_complete_work.work); 2301 tx_complete_work.work);
2320 struct ath5k_txq *txq; 2302 struct ath5k_txq *txq;
2321 int i; 2303 int i;
2322 bool needreset = false; 2304 bool needreset = false;
2323 2305
2324 mutex_lock(&sc->lock); 2306 mutex_lock(&ah->lock);
2325 2307
2326 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) { 2308 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) {
2327 if (sc->txqs[i].setup) { 2309 if (ah->txqs[i].setup) {
2328 txq = &sc->txqs[i]; 2310 txq = &ah->txqs[i];
2329 spin_lock_bh(&txq->lock); 2311 spin_lock_bh(&txq->lock);
2330 if (txq->txq_len > 1) { 2312 if (txq->txq_len > 1) {
2331 if (txq->txq_poll_mark) { 2313 if (txq->txq_poll_mark) {
2332 ATH5K_DBG(sc, ATH5K_DEBUG_XMIT, 2314 ATH5K_DBG(ah, ATH5K_DEBUG_XMIT,
2333 "TX queue stuck %d\n", 2315 "TX queue stuck %d\n",
2334 txq->qnum); 2316 txq->qnum);
2335 needreset = true; 2317 needreset = true;
@@ -2345,14 +2327,14 @@ ath5k_tx_complete_poll_work(struct work_struct *work)
2345 } 2327 }
2346 2328
2347 if (needreset) { 2329 if (needreset) {
2348 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 2330 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
2349 "TX queues stuck, resetting\n"); 2331 "TX queues stuck, resetting\n");
2350 ath5k_reset(sc, NULL, true); 2332 ath5k_reset(ah, NULL, true);
2351 } 2333 }
2352 2334
2353 mutex_unlock(&sc->lock); 2335 mutex_unlock(&ah->lock);
2354 2336
2355 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 2337 ieee80211_queue_delayed_work(ah->hw, &ah->tx_complete_work,
2356 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT)); 2338 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT));
2357} 2339}
2358 2340
@@ -2362,15 +2344,15 @@ ath5k_tx_complete_poll_work(struct work_struct *work)
2362\*************************/ 2344\*************************/
2363 2345
2364int __devinit 2346int __devinit
2365ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops) 2347ath5k_init_softc(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
2366{ 2348{
2367 struct ieee80211_hw *hw = sc->hw; 2349 struct ieee80211_hw *hw = ah->hw;
2368 struct ath_common *common; 2350 struct ath_common *common;
2369 int ret; 2351 int ret;
2370 int csz; 2352 int csz;
2371 2353
2372 /* Initialize driver private data */ 2354 /* Initialize driver private data */
2373 SET_IEEE80211_DEV(hw, sc->dev); 2355 SET_IEEE80211_DEV(hw, ah->dev);
2374 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 2356 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
2375 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 2357 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
2376 IEEE80211_HW_SIGNAL_DBM | 2358 IEEE80211_HW_SIGNAL_DBM |
@@ -2393,39 +2375,29 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2393 * Mark the device as detached to avoid processing 2375 * Mark the device as detached to avoid processing
2394 * interrupts until setup is complete. 2376 * interrupts until setup is complete.
2395 */ 2377 */
2396 __set_bit(ATH_STAT_INVALID, sc->status); 2378 __set_bit(ATH_STAT_INVALID, ah->status);
2397 2379
2398 sc->opmode = NL80211_IFTYPE_STATION; 2380 ah->opmode = NL80211_IFTYPE_STATION;
2399 sc->bintval = 1000; 2381 ah->bintval = 1000;
2400 mutex_init(&sc->lock); 2382 mutex_init(&ah->lock);
2401 spin_lock_init(&sc->rxbuflock); 2383 spin_lock_init(&ah->rxbuflock);
2402 spin_lock_init(&sc->txbuflock); 2384 spin_lock_init(&ah->txbuflock);
2403 spin_lock_init(&sc->block); 2385 spin_lock_init(&ah->block);
2404 spin_lock_init(&sc->irqlock); 2386 spin_lock_init(&ah->irqlock);
2405 2387
2406 /* Setup interrupt handler */ 2388 /* Setup interrupt handler */
2407 ret = request_irq(sc->irq, ath5k_intr, IRQF_SHARED, "ath", sc); 2389 ret = request_irq(ah->irq, ath5k_intr, IRQF_SHARED, "ath", ah);
2408 if (ret) { 2390 if (ret) {
2409 ATH5K_ERR(sc, "request_irq failed\n"); 2391 ATH5K_ERR(ah, "request_irq failed\n");
2410 goto err; 2392 goto err;
2411 } 2393 }
2412 2394
2413 /* If we passed the test, malloc an ath5k_hw struct */ 2395 common = ath5k_hw_common(ah);
2414 sc->ah = kzalloc(sizeof(struct ath5k_hw), GFP_KERNEL);
2415 if (!sc->ah) {
2416 ret = -ENOMEM;
2417 ATH5K_ERR(sc, "out of memory\n");
2418 goto err_irq;
2419 }
2420
2421 sc->ah->ah_sc = sc;
2422 sc->ah->ah_iobase = sc->iobase;
2423 common = ath5k_hw_common(sc->ah);
2424 common->ops = &ath5k_common_ops; 2396 common->ops = &ath5k_common_ops;
2425 common->bus_ops = bus_ops; 2397 common->bus_ops = bus_ops;
2426 common->ah = sc->ah; 2398 common->ah = ah;
2427 common->hw = hw; 2399 common->hw = hw;
2428 common->priv = sc; 2400 common->priv = ah;
2429 common->clockrate = 40; 2401 common->clockrate = 40;
2430 2402
2431 /* 2403 /*
@@ -2438,12 +2410,12 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2438 spin_lock_init(&common->cc_lock); 2410 spin_lock_init(&common->cc_lock);
2439 2411
2440 /* Initialize device */ 2412 /* Initialize device */
2441 ret = ath5k_hw_init(sc); 2413 ret = ath5k_hw_init(ah);
2442 if (ret) 2414 if (ret)
2443 goto err_free_ah; 2415 goto err_irq;
2444 2416
2445 /* set up multi-rate retry capabilities */ 2417 /* set up multi-rate retry capabilities */
2446 if (sc->ah->ah_version == AR5K_AR5212) { 2418 if (ah->ah_version == AR5K_AR5212) {
2447 hw->max_rates = 4; 2419 hw->max_rates = 4;
2448 hw->max_rate_tries = max(AR5K_INIT_RETRY_SHORT, 2420 hw->max_rate_tries = max(AR5K_INIT_RETRY_SHORT,
2449 AR5K_INIT_RETRY_LONG); 2421 AR5K_INIT_RETRY_LONG);
@@ -2456,77 +2428,74 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
2456 if (ret) 2428 if (ret)
2457 goto err_ah; 2429 goto err_ah;
2458 2430
2459 ATH5K_INFO(sc, "Atheros AR%s chip found (MAC: 0x%x, PHY: 0x%x)\n", 2431 ATH5K_INFO(ah, "Atheros AR%s chip found (MAC: 0x%x, PHY: 0x%x)\n",
2460 ath5k_chip_name(AR5K_VERSION_MAC, sc->ah->ah_mac_srev), 2432 ath5k_chip_name(AR5K_VERSION_MAC, ah->ah_mac_srev),
2461 sc->ah->ah_mac_srev, 2433 ah->ah_mac_srev,
2462 sc->ah->ah_phy_revision); 2434 ah->ah_phy_revision);
2463 2435
2464 if (!sc->ah->ah_single_chip) { 2436 if (!ah->ah_single_chip) {
2465 /* Single chip radio (!RF5111) */ 2437 /* Single chip radio (!RF5111) */
2466 if (sc->ah->ah_radio_5ghz_revision && 2438 if (ah->ah_radio_5ghz_revision &&
2467 !sc->ah->ah_radio_2ghz_revision) { 2439 !ah->ah_radio_2ghz_revision) {
2468 /* No 5GHz support -> report 2GHz radio */ 2440 /* No 5GHz support -> report 2GHz radio */
2469 if (!test_bit(AR5K_MODE_11A, 2441 if (!test_bit(AR5K_MODE_11A,
2470 sc->ah->ah_capabilities.cap_mode)) { 2442 ah->ah_capabilities.cap_mode)) {
2471 ATH5K_INFO(sc, "RF%s 2GHz radio found (0x%x)\n", 2443 ATH5K_INFO(ah, "RF%s 2GHz radio found (0x%x)\n",
2472 ath5k_chip_name(AR5K_VERSION_RAD, 2444 ath5k_chip_name(AR5K_VERSION_RAD,
2473 sc->ah->ah_radio_5ghz_revision), 2445 ah->ah_radio_5ghz_revision),
2474 sc->ah->ah_radio_5ghz_revision); 2446 ah->ah_radio_5ghz_revision);
2475 /* No 2GHz support (5110 and some 2447 /* No 2GHz support (5110 and some
2476 * 5GHz only cards) -> report 5GHz radio */ 2448 * 5GHz only cards) -> report 5GHz radio */
2477 } else if (!test_bit(AR5K_MODE_11B, 2449 } else if (!test_bit(AR5K_MODE_11B,
2478 sc->ah->ah_capabilities.cap_mode)) { 2450 ah->ah_capabilities.cap_mode)) {
2479 ATH5K_INFO(sc, "RF%s 5GHz radio found (0x%x)\n", 2451 ATH5K_INFO(ah, "RF%s 5GHz radio found (0x%x)\n",
2480 ath5k_chip_name(AR5K_VERSION_RAD, 2452 ath5k_chip_name(AR5K_VERSION_RAD,
2481 sc->ah->ah_radio_5ghz_revision), 2453 ah->ah_radio_5ghz_revision),
2482 sc->ah->ah_radio_5ghz_revision); 2454 ah->ah_radio_5ghz_revision);
2483 /* Multiband radio */ 2455 /* Multiband radio */
2484 } else { 2456 } else {
2485 ATH5K_INFO(sc, "RF%s multiband radio found" 2457 ATH5K_INFO(ah, "RF%s multiband radio found"
2486 " (0x%x)\n", 2458 " (0x%x)\n",
2487 ath5k_chip_name(AR5K_VERSION_RAD, 2459 ath5k_chip_name(AR5K_VERSION_RAD,
2488 sc->ah->ah_radio_5ghz_revision), 2460 ah->ah_radio_5ghz_revision),
2489 sc->ah->ah_radio_5ghz_revision); 2461 ah->ah_radio_5ghz_revision);
2490 } 2462 }
2491 } 2463 }
2492 /* Multi chip radio (RF5111 - RF2111) -> 2464 /* Multi chip radio (RF5111 - RF2111) ->
2493 * report both 2GHz/5GHz radios */ 2465 * report both 2GHz/5GHz radios */
2494 else if (sc->ah->ah_radio_5ghz_revision && 2466 else if (ah->ah_radio_5ghz_revision &&
2495 sc->ah->ah_radio_2ghz_revision) { 2467 ah->ah_radio_2ghz_revision) {
2496 ATH5K_INFO(sc, "RF%s 5GHz radio found (0x%x)\n", 2468 ATH5K_INFO(ah, "RF%s 5GHz radio found (0x%x)\n",
2497 ath5k_chip_name(AR5K_VERSION_RAD, 2469 ath5k_chip_name(AR5K_VERSION_RAD,
2498 sc->ah->ah_radio_5ghz_revision), 2470 ah->ah_radio_5ghz_revision),
2499 sc->ah->ah_radio_5ghz_revision); 2471 ah->ah_radio_5ghz_revision);
2500 ATH5K_INFO(sc, "RF%s 2GHz radio found (0x%x)\n", 2472 ATH5K_INFO(ah, "RF%s 2GHz radio found (0x%x)\n",
2501 ath5k_chip_name(AR5K_VERSION_RAD, 2473 ath5k_chip_name(AR5K_VERSION_RAD,
2502 sc->ah->ah_radio_2ghz_revision), 2474 ah->ah_radio_2ghz_revision),
2503 sc->ah->ah_radio_2ghz_revision); 2475 ah->ah_radio_2ghz_revision);
2504 } 2476 }
2505 } 2477 }
2506 2478
2507 ath5k_debug_init_device(sc); 2479 ath5k_debug_init_device(ah);
2508 2480
2509 /* ready to process interrupts */ 2481 /* ready to process interrupts */
2510 __clear_bit(ATH_STAT_INVALID, sc->status); 2482 __clear_bit(ATH_STAT_INVALID, ah->status);
2511 2483
2512 return 0; 2484 return 0;
2513err_ah: 2485err_ah:
2514 ath5k_hw_deinit(sc->ah); 2486 ath5k_hw_deinit(ah);
2515err_free_ah:
2516 kfree(sc->ah);
2517err_irq: 2487err_irq:
2518 free_irq(sc->irq, sc); 2488 free_irq(ah->irq, ah);
2519err: 2489err:
2520 return ret; 2490 return ret;
2521} 2491}
2522 2492
2523static int 2493static int
2524ath5k_stop_locked(struct ath5k_softc *sc) 2494ath5k_stop_locked(struct ath5k_hw *ah)
2525{ 2495{
2526 struct ath5k_hw *ah = sc->ah;
2527 2496
2528 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "invalid %u\n", 2497 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "invalid %u\n",
2529 test_bit(ATH_STAT_INVALID, sc->status)); 2498 test_bit(ATH_STAT_INVALID, ah->status));
2530 2499
2531 /* 2500 /*
2532 * Shutdown the hardware and driver: 2501 * Shutdown the hardware and driver:
@@ -2543,37 +2512,36 @@ ath5k_stop_locked(struct ath5k_softc *sc)
2543 * Note that some of this work is not possible if the 2512 * Note that some of this work is not possible if the
2544 * hardware is gone (invalid). 2513 * hardware is gone (invalid).
2545 */ 2514 */
2546 ieee80211_stop_queues(sc->hw); 2515 ieee80211_stop_queues(ah->hw);
2547 2516
2548 if (!test_bit(ATH_STAT_INVALID, sc->status)) { 2517 if (!test_bit(ATH_STAT_INVALID, ah->status)) {
2549 ath5k_led_off(sc); 2518 ath5k_led_off(ah);
2550 ath5k_hw_set_imr(ah, 0); 2519 ath5k_hw_set_imr(ah, 0);
2551 synchronize_irq(sc->irq); 2520 synchronize_irq(ah->irq);
2552 ath5k_rx_stop(sc); 2521 ath5k_rx_stop(ah);
2553 ath5k_hw_dma_stop(ah); 2522 ath5k_hw_dma_stop(ah);
2554 ath5k_drain_tx_buffs(sc); 2523 ath5k_drain_tx_buffs(ah);
2555 ath5k_hw_phy_disable(ah); 2524 ath5k_hw_phy_disable(ah);
2556 } 2525 }
2557 2526
2558 return 0; 2527 return 0;
2559} 2528}
2560 2529
2561int 2530int ath5k_start(struct ieee80211_hw *hw)
2562ath5k_init_hw(struct ath5k_softc *sc)
2563{ 2531{
2564 struct ath5k_hw *ah = sc->ah; 2532 struct ath5k_hw *ah = hw->priv;
2565 struct ath_common *common = ath5k_hw_common(ah); 2533 struct ath_common *common = ath5k_hw_common(ah);
2566 int ret, i; 2534 int ret, i;
2567 2535
2568 mutex_lock(&sc->lock); 2536 mutex_lock(&ah->lock);
2569 2537
2570 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "mode %d\n", sc->opmode); 2538 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "mode %d\n", ah->opmode);
2571 2539
2572 /* 2540 /*
2573 * Stop anything previously setup. This is safe 2541 * Stop anything previously setup. This is safe
2574 * no matter this is the first time through or not. 2542 * no matter this is the first time through or not.
2575 */ 2543 */
2576 ath5k_stop_locked(sc); 2544 ath5k_stop_locked(ah);
2577 2545
2578 /* 2546 /*
2579 * The basic interface to setting the hardware in a good 2547 * The basic interface to setting the hardware in a good
@@ -2582,12 +2550,12 @@ ath5k_init_hw(struct ath5k_softc *sc)
2582 * be followed by initialization of the appropriate bits 2550 * be followed by initialization of the appropriate bits
2583 * and then setup of the interrupt mask. 2551 * and then setup of the interrupt mask.
2584 */ 2552 */
2585 sc->curchan = sc->hw->conf.channel; 2553 ah->curchan = ah->hw->conf.channel;
2586 sc->imask = AR5K_INT_RXOK | AR5K_INT_RXERR | AR5K_INT_RXEOL | 2554 ah->imask = AR5K_INT_RXOK | AR5K_INT_RXERR | AR5K_INT_RXEOL |
2587 AR5K_INT_RXORN | AR5K_INT_TXDESC | AR5K_INT_TXEOL | 2555 AR5K_INT_RXORN | AR5K_INT_TXDESC | AR5K_INT_TXEOL |
2588 AR5K_INT_FATAL | AR5K_INT_GLOBAL | AR5K_INT_MIB; 2556 AR5K_INT_FATAL | AR5K_INT_GLOBAL | AR5K_INT_MIB;
2589 2557
2590 ret = ath5k_reset(sc, NULL, false); 2558 ret = ath5k_reset(ah, NULL, false);
2591 if (ret) 2559 if (ret)
2592 goto done; 2560 goto done;
2593 2561
@@ -2604,29 +2572,29 @@ ath5k_init_hw(struct ath5k_softc *sc)
2604 * rate */ 2572 * rate */
2605 ah->ah_ack_bitrate_high = true; 2573 ah->ah_ack_bitrate_high = true;
2606 2574
2607 for (i = 0; i < ARRAY_SIZE(sc->bslot); i++) 2575 for (i = 0; i < ARRAY_SIZE(ah->bslot); i++)
2608 sc->bslot[i] = NULL; 2576 ah->bslot[i] = NULL;
2609 2577
2610 ret = 0; 2578 ret = 0;
2611done: 2579done:
2612 mmiowb(); 2580 mmiowb();
2613 mutex_unlock(&sc->lock); 2581 mutex_unlock(&ah->lock);
2614 2582
2615 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 2583 ieee80211_queue_delayed_work(ah->hw, &ah->tx_complete_work,
2616 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT)); 2584 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT));
2617 2585
2618 return ret; 2586 return ret;
2619} 2587}
2620 2588
2621static void ath5k_stop_tasklets(struct ath5k_softc *sc) 2589static void ath5k_stop_tasklets(struct ath5k_hw *ah)
2622{ 2590{
2623 sc->rx_pending = false; 2591 ah->rx_pending = false;
2624 sc->tx_pending = false; 2592 ah->tx_pending = false;
2625 tasklet_kill(&sc->rxtq); 2593 tasklet_kill(&ah->rxtq);
2626 tasklet_kill(&sc->txtq); 2594 tasklet_kill(&ah->txtq);
2627 tasklet_kill(&sc->calib); 2595 tasklet_kill(&ah->calib);
2628 tasklet_kill(&sc->beacontq); 2596 tasklet_kill(&ah->beacontq);
2629 tasklet_kill(&sc->ani_tasklet); 2597 tasklet_kill(&ah->ani_tasklet);
2630} 2598}
2631 2599
2632/* 2600/*
@@ -2635,14 +2603,14 @@ static void ath5k_stop_tasklets(struct ath5k_softc *sc)
2635 * if another thread does a system call and the thread doing the 2603 * if another thread does a system call and the thread doing the
2636 * stop is preempted). 2604 * stop is preempted).
2637 */ 2605 */
2638int 2606void ath5k_stop(struct ieee80211_hw *hw)
2639ath5k_stop_hw(struct ath5k_softc *sc)
2640{ 2607{
2608 struct ath5k_hw *ah = hw->priv;
2641 int ret; 2609 int ret;
2642 2610
2643 mutex_lock(&sc->lock); 2611 mutex_lock(&ah->lock);
2644 ret = ath5k_stop_locked(sc); 2612 ret = ath5k_stop_locked(ah);
2645 if (ret == 0 && !test_bit(ATH_STAT_INVALID, sc->status)) { 2613 if (ret == 0 && !test_bit(ATH_STAT_INVALID, ah->status)) {
2646 /* 2614 /*
2647 * Don't set the card in full sleep mode! 2615 * Don't set the card in full sleep mode!
2648 * 2616 *
@@ -2663,69 +2631,66 @@ ath5k_stop_hw(struct ath5k_softc *sc)
2663 * and Sam's HAL do anyway). Instead Perform a full reset 2631 * and Sam's HAL do anyway). Instead Perform a full reset
2664 * on the device (same as initial state after attach) and 2632 * on the device (same as initial state after attach) and
2665 * leave it idle (keep MAC/BB on warm reset) */ 2633 * leave it idle (keep MAC/BB on warm reset) */
2666 ret = ath5k_hw_on_hold(sc->ah); 2634 ret = ath5k_hw_on_hold(ah);
2667 2635
2668 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, 2636 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
2669 "putting device to sleep\n"); 2637 "putting device to sleep\n");
2670 } 2638 }
2671 2639
2672 mmiowb(); 2640 mmiowb();
2673 mutex_unlock(&sc->lock); 2641 mutex_unlock(&ah->lock);
2674
2675 ath5k_stop_tasklets(sc);
2676 2642
2677 cancel_delayed_work_sync(&sc->tx_complete_work); 2643 ath5k_stop_tasklets(ah);
2678 2644
2679 ath5k_rfkill_hw_stop(sc->ah); 2645 cancel_delayed_work_sync(&ah->tx_complete_work);
2680 2646
2681 return ret; 2647 ath5k_rfkill_hw_stop(ah);
2682} 2648}
2683 2649
2684/* 2650/*
2685 * Reset the hardware. If chan is not NULL, then also pause rx/tx 2651 * Reset the hardware. If chan is not NULL, then also pause rx/tx
2686 * and change to the given channel. 2652 * and change to the given channel.
2687 * 2653 *
2688 * This should be called with sc->lock. 2654 * This should be called with ah->lock.
2689 */ 2655 */
2690static int 2656static int
2691ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan, 2657ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan,
2692 bool skip_pcu) 2658 bool skip_pcu)
2693{ 2659{
2694 struct ath5k_hw *ah = sc->ah;
2695 struct ath_common *common = ath5k_hw_common(ah); 2660 struct ath_common *common = ath5k_hw_common(ah);
2696 int ret, ani_mode; 2661 int ret, ani_mode;
2697 bool fast; 2662 bool fast;
2698 2663
2699 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "resetting\n"); 2664 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "resetting\n");
2700 2665
2701 ath5k_hw_set_imr(ah, 0); 2666 ath5k_hw_set_imr(ah, 0);
2702 synchronize_irq(sc->irq); 2667 synchronize_irq(ah->irq);
2703 ath5k_stop_tasklets(sc); 2668 ath5k_stop_tasklets(ah);
2704 2669
2705 /* Save ani mode and disable ANI during 2670 /* Save ani mode and disable ANI during
2706 * reset. If we don't we might get false 2671 * reset. If we don't we might get false
2707 * PHY error interrupts. */ 2672 * PHY error interrupts. */
2708 ani_mode = ah->ah_sc->ani_state.ani_mode; 2673 ani_mode = ah->ani_state.ani_mode;
2709 ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF); 2674 ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF);
2710 2675
2711 /* We are going to empty hw queues 2676 /* We are going to empty hw queues
2712 * so we should also free any remaining 2677 * so we should also free any remaining
2713 * tx buffers */ 2678 * tx buffers */
2714 ath5k_drain_tx_buffs(sc); 2679 ath5k_drain_tx_buffs(ah);
2715 if (chan) 2680 if (chan)
2716 sc->curchan = chan; 2681 ah->curchan = chan;
2717 2682
2718 fast = ((chan != NULL) && modparam_fastchanswitch) ? 1 : 0; 2683 fast = ((chan != NULL) && modparam_fastchanswitch) ? 1 : 0;
2719 2684
2720 ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, fast, skip_pcu); 2685 ret = ath5k_hw_reset(ah, ah->opmode, ah->curchan, fast, skip_pcu);
2721 if (ret) { 2686 if (ret) {
2722 ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret); 2687 ATH5K_ERR(ah, "can't reset hardware (%d)\n", ret);
2723 goto err; 2688 goto err;
2724 } 2689 }
2725 2690
2726 ret = ath5k_rx_start(sc); 2691 ret = ath5k_rx_start(ah);
2727 if (ret) { 2692 if (ret) {
2728 ATH5K_ERR(sc, "can't start recv logic\n"); 2693 ATH5K_ERR(ah, "can't start recv logic\n");
2729 goto err; 2694 goto err;
2730 } 2695 }
2731 2696
@@ -2737,7 +2702,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan,
2737 ewma_init(&ah->ah_beacon_rssi_avg, 1024, 8); 2702 ewma_init(&ah->ah_beacon_rssi_avg, 1024, 8);
2738 2703
2739 /* clear survey data and cycle counters */ 2704 /* clear survey data and cycle counters */
2740 memset(&sc->survey, 0, sizeof(sc->survey)); 2705 memset(&ah->survey, 0, sizeof(ah->survey));
2741 spin_lock_bh(&common->cc_lock); 2706 spin_lock_bh(&common->cc_lock);
2742 ath_hw_cycle_counters_update(common); 2707 ath_hw_cycle_counters_update(common);
2743 memset(&common->cc_survey, 0, sizeof(common->cc_survey)); 2708 memset(&common->cc_survey, 0, sizeof(common->cc_survey));
@@ -2753,12 +2718,12 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan,
2753 * 2718 *
2754 * XXX needed? 2719 * XXX needed?
2755 */ 2720 */
2756/* ath5k_chan_change(sc, c); */ 2721/* ath5k_chan_change(ah, c); */
2757 2722
2758 ath5k_beacon_config(sc); 2723 ath5k_beacon_config(ah);
2759 /* intrs are enabled by ath5k_beacon_config */ 2724 /* intrs are enabled by ath5k_beacon_config */
2760 2725
2761 ieee80211_wake_queues(sc->hw); 2726 ieee80211_wake_queues(ah->hw);
2762 2727
2763 return 0; 2728 return 0;
2764err: 2729err:
@@ -2767,20 +2732,19 @@ err:
2767 2732
2768static void ath5k_reset_work(struct work_struct *work) 2733static void ath5k_reset_work(struct work_struct *work)
2769{ 2734{
2770 struct ath5k_softc *sc = container_of(work, struct ath5k_softc, 2735 struct ath5k_hw *ah = container_of(work, struct ath5k_hw,
2771 reset_work); 2736 reset_work);
2772 2737
2773 mutex_lock(&sc->lock); 2738 mutex_lock(&ah->lock);
2774 ath5k_reset(sc, NULL, true); 2739 ath5k_reset(ah, NULL, true);
2775 mutex_unlock(&sc->lock); 2740 mutex_unlock(&ah->lock);
2776} 2741}
2777 2742
2778static int __devinit 2743static int __devinit
2779ath5k_init(struct ieee80211_hw *hw) 2744ath5k_init(struct ieee80211_hw *hw)
2780{ 2745{
2781 2746
2782 struct ath5k_softc *sc = hw->priv; 2747 struct ath5k_hw *ah = hw->priv;
2783 struct ath5k_hw *ah = sc->ah;
2784 struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah); 2748 struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah);
2785 struct ath5k_txq *txq; 2749 struct ath5k_txq *txq;
2786 u8 mac[ETH_ALEN] = {}; 2750 u8 mac[ETH_ALEN] = {};
@@ -2799,7 +2763,7 @@ ath5k_init(struct ieee80211_hw *hw)
2799 if (ret < 0) 2763 if (ret < 0)
2800 goto err; 2764 goto err;
2801 if (ret > 0) 2765 if (ret > 0)
2802 __set_bit(ATH_STAT_MRRETRY, sc->status); 2766 __set_bit(ATH_STAT_MRRETRY, ah->status);
2803 2767
2804 /* 2768 /*
2805 * Collect the channel list. The 802.11 layer 2769 * Collect the channel list. The 802.11 layer
@@ -2809,16 +2773,16 @@ ath5k_init(struct ieee80211_hw *hw)
2809 */ 2773 */
2810 ret = ath5k_setup_bands(hw); 2774 ret = ath5k_setup_bands(hw);
2811 if (ret) { 2775 if (ret) {
2812 ATH5K_ERR(sc, "can't get channels\n"); 2776 ATH5K_ERR(ah, "can't get channels\n");
2813 goto err; 2777 goto err;
2814 } 2778 }
2815 2779
2816 /* 2780 /*
2817 * Allocate tx+rx descriptors and populate the lists. 2781 * Allocate tx+rx descriptors and populate the lists.
2818 */ 2782 */
2819 ret = ath5k_desc_alloc(sc); 2783 ret = ath5k_desc_alloc(ah);
2820 if (ret) { 2784 if (ret) {
2821 ATH5K_ERR(sc, "can't allocate descriptors\n"); 2785 ATH5K_ERR(ah, "can't allocate descriptors\n");
2822 goto err; 2786 goto err;
2823 } 2787 }
2824 2788
@@ -2830,14 +2794,14 @@ ath5k_init(struct ieee80211_hw *hw)
2830 */ 2794 */
2831 ret = ath5k_beaconq_setup(ah); 2795 ret = ath5k_beaconq_setup(ah);
2832 if (ret < 0) { 2796 if (ret < 0) {
2833 ATH5K_ERR(sc, "can't setup a beacon xmit queue\n"); 2797 ATH5K_ERR(ah, "can't setup a beacon xmit queue\n");
2834 goto err_desc; 2798 goto err_desc;
2835 } 2799 }
2836 sc->bhalq = ret; 2800 ah->bhalq = ret;
2837 sc->cabq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_CAB, 0); 2801 ah->cabq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_CAB, 0);
2838 if (IS_ERR(sc->cabq)) { 2802 if (IS_ERR(ah->cabq)) {
2839 ATH5K_ERR(sc, "can't setup cab queue\n"); 2803 ATH5K_ERR(ah, "can't setup cab queue\n");
2840 ret = PTR_ERR(sc->cabq); 2804 ret = PTR_ERR(ah->cabq);
2841 goto err_bhal; 2805 goto err_bhal;
2842 } 2806 }
2843 2807
@@ -2846,97 +2810,97 @@ ath5k_init(struct ieee80211_hw *hw)
2846 if (ah->ah_capabilities.cap_queues.q_tx_num >= 6) { 2810 if (ah->ah_capabilities.cap_queues.q_tx_num >= 6) {
2847 /* This order matches mac80211's queue priority, so we can 2811 /* This order matches mac80211's queue priority, so we can
2848 * directly use the mac80211 queue number without any mapping */ 2812 * directly use the mac80211 queue number without any mapping */
2849 txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_VO); 2813 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_VO);
2850 if (IS_ERR(txq)) { 2814 if (IS_ERR(txq)) {
2851 ATH5K_ERR(sc, "can't setup xmit queue\n"); 2815 ATH5K_ERR(ah, "can't setup xmit queue\n");
2852 ret = PTR_ERR(txq); 2816 ret = PTR_ERR(txq);
2853 goto err_queues; 2817 goto err_queues;
2854 } 2818 }
2855 txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_VI); 2819 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_VI);
2856 if (IS_ERR(txq)) { 2820 if (IS_ERR(txq)) {
2857 ATH5K_ERR(sc, "can't setup xmit queue\n"); 2821 ATH5K_ERR(ah, "can't setup xmit queue\n");
2858 ret = PTR_ERR(txq); 2822 ret = PTR_ERR(txq);
2859 goto err_queues; 2823 goto err_queues;
2860 } 2824 }
2861 txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BE); 2825 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BE);
2862 if (IS_ERR(txq)) { 2826 if (IS_ERR(txq)) {
2863 ATH5K_ERR(sc, "can't setup xmit queue\n"); 2827 ATH5K_ERR(ah, "can't setup xmit queue\n");
2864 ret = PTR_ERR(txq); 2828 ret = PTR_ERR(txq);
2865 goto err_queues; 2829 goto err_queues;
2866 } 2830 }
2867 txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BK); 2831 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BK);
2868 if (IS_ERR(txq)) { 2832 if (IS_ERR(txq)) {
2869 ATH5K_ERR(sc, "can't setup xmit queue\n"); 2833 ATH5K_ERR(ah, "can't setup xmit queue\n");
2870 ret = PTR_ERR(txq); 2834 ret = PTR_ERR(txq);
2871 goto err_queues; 2835 goto err_queues;
2872 } 2836 }
2873 hw->queues = 4; 2837 hw->queues = 4;
2874 } else { 2838 } else {
2875 /* older hardware (5210) can only support one data queue */ 2839 /* older hardware (5210) can only support one data queue */
2876 txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BE); 2840 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BE);
2877 if (IS_ERR(txq)) { 2841 if (IS_ERR(txq)) {
2878 ATH5K_ERR(sc, "can't setup xmit queue\n"); 2842 ATH5K_ERR(ah, "can't setup xmit queue\n");
2879 ret = PTR_ERR(txq); 2843 ret = PTR_ERR(txq);
2880 goto err_queues; 2844 goto err_queues;
2881 } 2845 }
2882 hw->queues = 1; 2846 hw->queues = 1;
2883 } 2847 }
2884 2848
2885 tasklet_init(&sc->rxtq, ath5k_tasklet_rx, (unsigned long)sc); 2849 tasklet_init(&ah->rxtq, ath5k_tasklet_rx, (unsigned long)ah);
2886 tasklet_init(&sc->txtq, ath5k_tasklet_tx, (unsigned long)sc); 2850 tasklet_init(&ah->txtq, ath5k_tasklet_tx, (unsigned long)ah);
2887 tasklet_init(&sc->calib, ath5k_tasklet_calibrate, (unsigned long)sc); 2851 tasklet_init(&ah->calib, ath5k_tasklet_calibrate, (unsigned long)ah);
2888 tasklet_init(&sc->beacontq, ath5k_tasklet_beacon, (unsigned long)sc); 2852 tasklet_init(&ah->beacontq, ath5k_tasklet_beacon, (unsigned long)ah);
2889 tasklet_init(&sc->ani_tasklet, ath5k_tasklet_ani, (unsigned long)sc); 2853 tasklet_init(&ah->ani_tasklet, ath5k_tasklet_ani, (unsigned long)ah);
2890 2854
2891 INIT_WORK(&sc->reset_work, ath5k_reset_work); 2855 INIT_WORK(&ah->reset_work, ath5k_reset_work);
2892 INIT_DELAYED_WORK(&sc->tx_complete_work, ath5k_tx_complete_poll_work); 2856 INIT_DELAYED_WORK(&ah->tx_complete_work, ath5k_tx_complete_poll_work);
2893 2857
2894 ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac); 2858 ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac);
2895 if (ret) { 2859 if (ret) {
2896 ATH5K_ERR(sc, "unable to read address from EEPROM\n"); 2860 ATH5K_ERR(ah, "unable to read address from EEPROM\n");
2897 goto err_queues; 2861 goto err_queues;
2898 } 2862 }
2899 2863
2900 SET_IEEE80211_PERM_ADDR(hw, mac); 2864 SET_IEEE80211_PERM_ADDR(hw, mac);
2901 memcpy(&sc->lladdr, mac, ETH_ALEN); 2865 memcpy(&ah->lladdr, mac, ETH_ALEN);
2902 /* All MAC address bits matter for ACKs */ 2866 /* All MAC address bits matter for ACKs */
2903 ath5k_update_bssid_mask_and_opmode(sc, NULL); 2867 ath5k_update_bssid_mask_and_opmode(ah, NULL);
2904 2868
2905 regulatory->current_rd = ah->ah_capabilities.cap_eeprom.ee_regdomain; 2869 regulatory->current_rd = ah->ah_capabilities.cap_eeprom.ee_regdomain;
2906 ret = ath_regd_init(regulatory, hw->wiphy, ath5k_reg_notifier); 2870 ret = ath_regd_init(regulatory, hw->wiphy, ath5k_reg_notifier);
2907 if (ret) { 2871 if (ret) {
2908 ATH5K_ERR(sc, "can't initialize regulatory system\n"); 2872 ATH5K_ERR(ah, "can't initialize regulatory system\n");
2909 goto err_queues; 2873 goto err_queues;
2910 } 2874 }
2911 2875
2912 ret = ieee80211_register_hw(hw); 2876 ret = ieee80211_register_hw(hw);
2913 if (ret) { 2877 if (ret) {
2914 ATH5K_ERR(sc, "can't register ieee80211 hw\n"); 2878 ATH5K_ERR(ah, "can't register ieee80211 hw\n");
2915 goto err_queues; 2879 goto err_queues;
2916 } 2880 }
2917 2881
2918 if (!ath_is_world_regd(regulatory)) 2882 if (!ath_is_world_regd(regulatory))
2919 regulatory_hint(hw->wiphy, regulatory->alpha2); 2883 regulatory_hint(hw->wiphy, regulatory->alpha2);
2920 2884
2921 ath5k_init_leds(sc); 2885 ath5k_init_leds(ah);
2922 2886
2923 ath5k_sysfs_register(sc); 2887 ath5k_sysfs_register(ah);
2924 2888
2925 return 0; 2889 return 0;
2926err_queues: 2890err_queues:
2927 ath5k_txq_release(sc); 2891 ath5k_txq_release(ah);
2928err_bhal: 2892err_bhal:
2929 ath5k_hw_release_tx_queue(ah, sc->bhalq); 2893 ath5k_hw_release_tx_queue(ah, ah->bhalq);
2930err_desc: 2894err_desc:
2931 ath5k_desc_free(sc); 2895 ath5k_desc_free(ah);
2932err: 2896err:
2933 return ret; 2897 return ret;
2934} 2898}
2935 2899
2936void 2900void
2937ath5k_deinit_softc(struct ath5k_softc *sc) 2901ath5k_deinit_softc(struct ath5k_hw *ah)
2938{ 2902{
2939 struct ieee80211_hw *hw = sc->hw; 2903 struct ieee80211_hw *hw = ah->hw;
2940 2904
2941 /* 2905 /*
2942 * NB: the order of these is important: 2906 * NB: the order of these is important:
@@ -2952,24 +2916,23 @@ ath5k_deinit_softc(struct ath5k_softc *sc)
2952 * Other than that, it's straightforward... 2916 * Other than that, it's straightforward...
2953 */ 2917 */
2954 ieee80211_unregister_hw(hw); 2918 ieee80211_unregister_hw(hw);
2955 ath5k_desc_free(sc); 2919 ath5k_desc_free(ah);
2956 ath5k_txq_release(sc); 2920 ath5k_txq_release(ah);
2957 ath5k_hw_release_tx_queue(sc->ah, sc->bhalq); 2921 ath5k_hw_release_tx_queue(ah, ah->bhalq);
2958 ath5k_unregister_leds(sc); 2922 ath5k_unregister_leds(ah);
2959 2923
2960 ath5k_sysfs_unregister(sc); 2924 ath5k_sysfs_unregister(ah);
2961 /* 2925 /*
2962 * NB: can't reclaim these until after ieee80211_ifdetach 2926 * NB: can't reclaim these until after ieee80211_ifdetach
2963 * returns because we'll get called back to reclaim node 2927 * returns because we'll get called back to reclaim node
2964 * state and potentially want to use them. 2928 * state and potentially want to use them.
2965 */ 2929 */
2966 ath5k_hw_deinit(sc->ah); 2930 ath5k_hw_deinit(ah);
2967 kfree(sc->ah); 2931 free_irq(ah->irq, ah);
2968 free_irq(sc->irq, sc);
2969} 2932}
2970 2933
2971bool 2934bool
2972ath5k_any_vif_assoc(struct ath5k_softc *sc) 2935ath5k_any_vif_assoc(struct ath5k_hw *ah)
2973{ 2936{
2974 struct ath5k_vif_iter_data iter_data; 2937 struct ath5k_vif_iter_data iter_data;
2975 iter_data.hw_macaddr = NULL; 2938 iter_data.hw_macaddr = NULL;
@@ -2977,7 +2940,7 @@ ath5k_any_vif_assoc(struct ath5k_softc *sc)
2977 iter_data.need_set_hw_addr = false; 2940 iter_data.need_set_hw_addr = false;
2978 iter_data.found_active = true; 2941 iter_data.found_active = true;
2979 2942
2980 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath5k_vif_iter, 2943 ieee80211_iterate_active_interfaces_atomic(ah->hw, ath5k_vif_iter,
2981 &iter_data); 2944 &iter_data);
2982 return iter_data.any_assoc; 2945 return iter_data.any_assoc;
2983} 2946}
@@ -2985,8 +2948,7 @@ ath5k_any_vif_assoc(struct ath5k_softc *sc)
2985void 2948void
2986ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable) 2949ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable)
2987{ 2950{
2988 struct ath5k_softc *sc = hw->priv; 2951 struct ath5k_hw *ah = hw->priv;
2989 struct ath5k_hw *ah = sc->ah;
2990 u32 rfilt; 2952 u32 rfilt;
2991 rfilt = ath5k_hw_get_rx_filter(ah); 2953 rfilt = ath5k_hw_get_rx_filter(ah);
2992 if (enable) 2954 if (enable)
@@ -2994,5 +2956,5 @@ ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable)
2994 else 2956 else
2995 rfilt &= ~AR5K_RX_FILTER_BEACON; 2957 rfilt &= ~AR5K_RX_FILTER_BEACON;
2996 ath5k_hw_set_rx_filter(ah, rfilt); 2958 ath5k_hw_set_rx_filter(ah, rfilt);
2997 sc->filter_flags = rfilt; 2959 ah->filter_flags = rfilt;
2998} 2960}
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 0a98777b9373..a81f28d5bddc 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -45,23 +45,13 @@
45#include <linux/list.h> 45#include <linux/list.h>
46#include <linux/wireless.h> 46#include <linux/wireless.h>
47#include <linux/if_ether.h> 47#include <linux/if_ether.h>
48#include <linux/leds.h>
49#include <linux/rfkill.h> 48#include <linux/rfkill.h>
50#include <linux/workqueue.h> 49#include <linux/workqueue.h>
51 50
52#include "ath5k.h" 51#include "ath5k.h"
53#include "debug.h"
54#include "ani.h"
55
56#include "../regd.h" 52#include "../regd.h"
57#include "../ath.h" 53#include "../ath.h"
58 54
59#define ATH_RXBUF 40 /* number of RX buffers */
60#define ATH_TXBUF 200 /* number of TX buffers */
61#define ATH_BCBUF 4 /* number of beacon buffers */
62#define ATH5K_TXQ_LEN_MAX (ATH_TXBUF / 4) /* bufs per queue */
63#define ATH5K_TXQ_LEN_LOW (ATH5K_TXQ_LEN_MAX / 2) /* low mark */
64
65struct ath5k_buf { 55struct ath5k_buf {
66 struct list_head list; 56 struct list_head list;
67 struct ath5k_desc *desc; /* virtual addr of desc */ 57 struct ath5k_desc *desc; /* virtual addr of desc */
@@ -70,94 +60,6 @@ struct ath5k_buf {
70 dma_addr_t skbaddr;/* physical addr of skb data */ 60 dma_addr_t skbaddr;/* physical addr of skb data */
71}; 61};
72 62
73/*
74 * Data transmit queue state. One of these exists for each
75 * hardware transmit queue. Packets sent to us from above
76 * are assigned to queues based on their priority. Not all
77 * devices support a complete set of hardware transmit queues.
78 * For those devices the array sc_ac2q will map multiple
79 * priorities to fewer hardware queues (typically all to one
80 * hardware queue).
81 */
82struct ath5k_txq {
83 unsigned int qnum; /* hardware q number */
84 u32 *link; /* link ptr in last TX desc */
85 struct list_head q; /* transmit queue */
86 spinlock_t lock; /* lock on q and link */
87 bool setup;
88 int txq_len; /* number of queued buffers */
89 int txq_max; /* max allowed num of queued buffers */
90 bool txq_poll_mark;
91 unsigned int txq_stuck; /* informational counter */
92};
93
94#define ATH5K_LED_MAX_NAME_LEN 31
95
96/*
97 * State for LED triggers
98 */
99struct ath5k_led {
100 char name[ATH5K_LED_MAX_NAME_LEN + 1]; /* name of the LED in sysfs */
101 struct ath5k_softc *sc; /* driver state */
102 struct led_classdev led_dev; /* led classdev */
103};
104
105/* Rfkill */
106struct ath5k_rfkill {
107 /* GPIO PIN for rfkill */
108 u16 gpio;
109 /* polarity of rfkill GPIO PIN */
110 bool polarity;
111 /* RFKILL toggle tasklet */
112 struct tasklet_struct toggleq;
113};
114
115/* statistics */
116struct ath5k_statistics {
117 /* antenna use */
118 unsigned int antenna_rx[5]; /* frames count per antenna RX */
119 unsigned int antenna_tx[5]; /* frames count per antenna TX */
120
121 /* frame errors */
122 unsigned int rx_all_count; /* all RX frames, including errors */
123 unsigned int tx_all_count; /* all TX frames, including errors */
124 unsigned int rx_bytes_count; /* all RX bytes, including errored pkts
125 * and the MAC headers for each packet
126 */
127 unsigned int tx_bytes_count; /* all TX bytes, including errored pkts
128 * and the MAC headers and padding for
129 * each packet.
130 */
131 unsigned int rxerr_crc;
132 unsigned int rxerr_phy;
133 unsigned int rxerr_phy_code[32];
134 unsigned int rxerr_fifo;
135 unsigned int rxerr_decrypt;
136 unsigned int rxerr_mic;
137 unsigned int rxerr_proc;
138 unsigned int rxerr_jumbo;
139 unsigned int txerr_retry;
140 unsigned int txerr_fifo;
141 unsigned int txerr_filt;
142
143 /* MIB counters */
144 unsigned int ack_fail;
145 unsigned int rts_fail;
146 unsigned int rts_ok;
147 unsigned int fcs_error;
148 unsigned int beacons;
149
150 unsigned int mib_intr;
151 unsigned int rxorn_intr;
152 unsigned int rxeol_intr;
153};
154
155#if CHAN_DEBUG
156#define ATH_CHAN_MAX (26 + 26 + 26 + 200 + 200)
157#else
158#define ATH_CHAN_MAX (14 + 14 + 14 + 252 + 20)
159#endif
160
161struct ath5k_vif { 63struct ath5k_vif {
162 bool assoc; /* are we associated or not */ 64 bool assoc; /* are we associated or not */
163 enum nl80211_iftype opmode; 65 enum nl80211_iftype opmode;
@@ -166,104 +68,6 @@ struct ath5k_vif {
166 u8 lladdr[ETH_ALEN]; 68 u8 lladdr[ETH_ALEN];
167}; 69};
168 70
169/* Software Carrier, keeps track of the driver state
170 * associated with an instance of a device */
171struct ath5k_softc {
172 struct pci_dev *pdev;
173 struct device *dev; /* for dma mapping */
174 int irq;
175 u16 devid;
176 void __iomem *iobase; /* address of the device */
177 struct mutex lock; /* dev-level lock */
178 struct ieee80211_hw *hw; /* IEEE 802.11 common */
179 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
180 struct ieee80211_channel channels[ATH_CHAN_MAX];
181 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
182 s8 rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
183 enum nl80211_iftype opmode;
184 struct ath5k_hw *ah; /* Atheros HW */
185
186#ifdef CONFIG_ATH5K_DEBUG
187 struct ath5k_dbg_info debug; /* debug info */
188#endif /* CONFIG_ATH5K_DEBUG */
189
190 struct ath5k_buf *bufptr; /* allocated buffer ptr */
191 struct ath5k_desc *desc; /* TX/RX descriptors */
192 dma_addr_t desc_daddr; /* DMA (physical) address */
193 size_t desc_len; /* size of TX/RX descriptors */
194
195 DECLARE_BITMAP(status, 6);
196#define ATH_STAT_INVALID 0 /* disable hardware accesses */
197#define ATH_STAT_MRRETRY 1 /* multi-rate retry support */
198#define ATH_STAT_PROMISC 2
199#define ATH_STAT_LEDSOFT 3 /* enable LED gpio status */
200#define ATH_STAT_STARTED 4 /* opened & irqs enabled */
201#define ATH_STAT_2G_DISABLED 5 /* multiband radio without 2G */
202
203 unsigned int filter_flags; /* HW flags, AR5K_RX_FILTER_* */
204 struct ieee80211_channel *curchan; /* current h/w channel */
205
206 u16 nvifs;
207
208 enum ath5k_int imask; /* interrupt mask copy */
209
210 spinlock_t irqlock;
211 bool rx_pending; /* rx tasklet pending */
212 bool tx_pending; /* tx tasklet pending */
213
214 u8 lladdr[ETH_ALEN];
215 u8 bssidmask[ETH_ALEN];
216
217 unsigned int led_pin, /* GPIO pin for driving LED */
218 led_on; /* pin setting for LED on */
219
220 struct work_struct reset_work; /* deferred chip reset */
221
222 unsigned int rxbufsize; /* rx size based on mtu */
223 struct list_head rxbuf; /* receive buffer */
224 spinlock_t rxbuflock;
225 u32 *rxlink; /* link ptr in last RX desc */
226 struct tasklet_struct rxtq; /* rx intr tasklet */
227 struct ath5k_led rx_led; /* rx led */
228
229 struct list_head txbuf; /* transmit buffer */
230 spinlock_t txbuflock;
231 unsigned int txbuf_len; /* buf count in txbuf list */
232 struct ath5k_txq txqs[AR5K_NUM_TX_QUEUES]; /* tx queues */
233 struct tasklet_struct txtq; /* tx intr tasklet */
234 struct ath5k_led tx_led; /* tx led */
235
236 struct ath5k_rfkill rf_kill;
237
238 struct tasklet_struct calib; /* calibration tasklet */
239
240 spinlock_t block; /* protects beacon */
241 struct tasklet_struct beacontq; /* beacon intr tasklet */
242 struct list_head bcbuf; /* beacon buffer */
243 struct ieee80211_vif *bslot[ATH_BCBUF];
244 u16 num_ap_vifs;
245 u16 num_adhoc_vifs;
246 unsigned int bhalq, /* SW q for outgoing beacons */
247 bmisscount, /* missed beacon transmits */
248 bintval, /* beacon interval in TU */
249 bsent;
250 unsigned int nexttbtt; /* next beacon time in TU */
251 struct ath5k_txq *cabq; /* content after beacon */
252
253 int power_level; /* Requested tx power in dBm */
254 bool assoc; /* associate state */
255 bool enable_beacon; /* true if beacons are on */
256
257 struct ath5k_statistics stats;
258
259 struct ath5k_ani_state ani_state;
260 struct tasklet_struct ani_tasklet; /* ANI calibration */
261
262 struct delayed_work tx_complete_work;
263
264 struct survey_info survey; /* collected survey info */
265};
266
267struct ath5k_vif_iter_data { 71struct ath5k_vif_iter_data {
268 const u8 *hw_macaddr; 72 const u8 *hw_macaddr;
269 u8 mask[ETH_ALEN]; 73 u8 mask[ETH_ALEN];
@@ -277,9 +81,10 @@ struct ath5k_vif_iter_data {
277void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif); 81void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif);
278 82
279 83
280#define ath5k_hw_hasbssidmask(_ah) \ 84/* Check whether BSSID mask is supported */
281 (ath5k_hw_get_capability(_ah, AR5K_CAP_BSSIDMASK, 0, NULL) == 0) 85#define ath5k_hw_hasbssidmask(_ah) (ah->ah_version == AR5K_AR5212)
282#define ath5k_hw_hasveol(_ah) \ 86
283 (ath5k_hw_get_capability(_ah, AR5K_CAP_VEOL, 0, NULL) == 0) 87/* Check whether virtual EOL is supported */
88#define ath5k_hw_hasveol(_ah) (ah->ah_version != AR5K_AR5210)
284 89
285#endif 90#endif
diff --git a/drivers/net/wireless/ath/ath5k/caps.c b/drivers/net/wireless/ath/ath5k/caps.c
index c752982aec05..eefe670e28a7 100644
--- a/drivers/net/wireless/ath/ath5k/caps.c
+++ b/drivers/net/wireless/ath/ath5k/caps.c
@@ -112,51 +112,6 @@ int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
112 return 0; 112 return 0;
113} 113}
114 114
115/* Main function used by the driver part to check caps */
116int ath5k_hw_get_capability(struct ath5k_hw *ah,
117 enum ath5k_capability_type cap_type,
118 u32 capability, u32 *result)
119{
120 switch (cap_type) {
121 case AR5K_CAP_NUM_TXQUEUES:
122 if (result) {
123 if (ah->ah_version == AR5K_AR5210)
124 *result = AR5K_NUM_TX_QUEUES_NOQCU;
125 else
126 *result = AR5K_NUM_TX_QUEUES;
127 goto yes;
128 }
129 case AR5K_CAP_VEOL:
130 goto yes;
131 case AR5K_CAP_COMPRESSION:
132 if (ah->ah_version == AR5K_AR5212)
133 goto yes;
134 else
135 goto no;
136 case AR5K_CAP_BURST:
137 goto yes;
138 case AR5K_CAP_TPC:
139 goto yes;
140 case AR5K_CAP_BSSIDMASK:
141 if (ah->ah_version == AR5K_AR5212)
142 goto yes;
143 else
144 goto no;
145 case AR5K_CAP_XR:
146 if (ah->ah_version == AR5K_AR5212)
147 goto yes;
148 else
149 goto no;
150 default:
151 goto no;
152 }
153
154no:
155 return -EINVAL;
156yes:
157 return 0;
158}
159
160/* 115/*
161 * TODO: Following functions should be part of a new function 116 * TODO: Following functions should be part of a new function
162 * set_capability 117 * set_capability
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 4edca7072d53..ccca724de173 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -157,10 +157,10 @@ static void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
157 157
158static int reg_show(struct seq_file *seq, void *p) 158static int reg_show(struct seq_file *seq, void *p)
159{ 159{
160 struct ath5k_softc *sc = seq->private; 160 struct ath5k_hw *ah = seq->private;
161 struct reg *r = p; 161 struct reg *r = p;
162 seq_printf(seq, "%-25s0x%08x\n", r->name, 162 seq_printf(seq, "%-25s0x%08x\n", r->name,
163 ath5k_hw_reg_read(sc->ah, r->addr)); 163 ath5k_hw_reg_read(ah, r->addr));
164 return 0; 164 return 0;
165} 165}
166 166
@@ -197,42 +197,41 @@ static const struct file_operations fops_registers = {
197static ssize_t read_file_beacon(struct file *file, char __user *user_buf, 197static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
198 size_t count, loff_t *ppos) 198 size_t count, loff_t *ppos)
199{ 199{
200 struct ath5k_softc *sc = file->private_data; 200 struct ath5k_hw *ah = file->private_data;
201 struct ath5k_hw *ah = sc->ah;
202 char buf[500]; 201 char buf[500];
203 unsigned int len = 0; 202 unsigned int len = 0;
204 unsigned int v; 203 unsigned int v;
205 u64 tsf; 204 u64 tsf;
206 205
207 v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON); 206 v = ath5k_hw_reg_read(ah, AR5K_BEACON);
208 len += snprintf(buf + len, sizeof(buf) - len, 207 len += snprintf(buf + len, sizeof(buf) - len,
209 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n", 208 "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
210 "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD, 209 "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
211 (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S); 210 (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
212 211
213 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n", 212 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n",
214 "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP)); 213 "AR5K_LAST_TSTP", ath5k_hw_reg_read(ah, AR5K_LAST_TSTP));
215 214
216 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n\n", 215 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n\n",
217 "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT)); 216 "AR5K_BEACON_CNT", ath5k_hw_reg_read(ah, AR5K_BEACON_CNT));
218 217
219 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0); 218 v = ath5k_hw_reg_read(ah, AR5K_TIMER0);
220 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n", 219 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
221 "AR5K_TIMER0 (TBTT)", v, v); 220 "AR5K_TIMER0 (TBTT)", v, v);
222 221
223 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1); 222 v = ath5k_hw_reg_read(ah, AR5K_TIMER1);
224 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n", 223 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
225 "AR5K_TIMER1 (DMA)", v, v >> 3); 224 "AR5K_TIMER1 (DMA)", v, v >> 3);
226 225
227 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2); 226 v = ath5k_hw_reg_read(ah, AR5K_TIMER2);
228 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n", 227 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
229 "AR5K_TIMER2 (SWBA)", v, v >> 3); 228 "AR5K_TIMER2 (SWBA)", v, v >> 3);
230 229
231 v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3); 230 v = ath5k_hw_reg_read(ah, AR5K_TIMER3);
232 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n", 231 len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
233 "AR5K_TIMER3 (ATIM)", v, v); 232 "AR5K_TIMER3 (ATIM)", v, v);
234 233
235 tsf = ath5k_hw_get_tsf64(sc->ah); 234 tsf = ath5k_hw_get_tsf64(ah);
236 len += snprintf(buf + len, sizeof(buf) - len, 235 len += snprintf(buf + len, sizeof(buf) - len,
237 "TSF\t\t0x%016llx\tTU: %08x\n", 236 "TSF\t\t0x%016llx\tTU: %08x\n",
238 (unsigned long long)tsf, TSF_TO_TU(tsf)); 237 (unsigned long long)tsf, TSF_TO_TU(tsf));
@@ -247,8 +246,7 @@ static ssize_t write_file_beacon(struct file *file,
247 const char __user *userbuf, 246 const char __user *userbuf,
248 size_t count, loff_t *ppos) 247 size_t count, loff_t *ppos)
249{ 248{
250 struct ath5k_softc *sc = file->private_data; 249 struct ath5k_hw *ah = file->private_data;
251 struct ath5k_hw *ah = sc->ah;
252 char buf[20]; 250 char buf[20];
253 251
254 if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) 252 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
@@ -279,9 +277,9 @@ static ssize_t write_file_reset(struct file *file,
279 const char __user *userbuf, 277 const char __user *userbuf,
280 size_t count, loff_t *ppos) 278 size_t count, loff_t *ppos)
281{ 279{
282 struct ath5k_softc *sc = file->private_data; 280 struct ath5k_hw *ah = file->private_data;
283 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "debug file triggered reset\n"); 281 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
284 ieee80211_queue_work(sc->hw, &sc->reset_work); 282 ieee80211_queue_work(ah->hw, &ah->reset_work);
285 return count; 283 return count;
286} 284}
287 285
@@ -318,23 +316,23 @@ static const struct {
318static ssize_t read_file_debug(struct file *file, char __user *user_buf, 316static ssize_t read_file_debug(struct file *file, char __user *user_buf,
319 size_t count, loff_t *ppos) 317 size_t count, loff_t *ppos)
320{ 318{
321 struct ath5k_softc *sc = file->private_data; 319 struct ath5k_hw *ah = file->private_data;
322 char buf[700]; 320 char buf[700];
323 unsigned int len = 0; 321 unsigned int len = 0;
324 unsigned int i; 322 unsigned int i;
325 323
326 len += snprintf(buf + len, sizeof(buf) - len, 324 len += snprintf(buf + len, sizeof(buf) - len,
327 "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level); 325 "DEBUG LEVEL: 0x%08x\n\n", ah->debug.level);
328 326
329 for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) { 327 for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
330 len += snprintf(buf + len, sizeof(buf) - len, 328 len += snprintf(buf + len, sizeof(buf) - len,
331 "%10s %c 0x%08x - %s\n", dbg_info[i].name, 329 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
332 sc->debug.level & dbg_info[i].level ? '+' : ' ', 330 ah->debug.level & dbg_info[i].level ? '+' : ' ',
333 dbg_info[i].level, dbg_info[i].desc); 331 dbg_info[i].level, dbg_info[i].desc);
334 } 332 }
335 len += snprintf(buf + len, sizeof(buf) - len, 333 len += snprintf(buf + len, sizeof(buf) - len,
336 "%10s %c 0x%08x - %s\n", dbg_info[i].name, 334 "%10s %c 0x%08x - %s\n", dbg_info[i].name,
337 sc->debug.level == dbg_info[i].level ? '+' : ' ', 335 ah->debug.level == dbg_info[i].level ? '+' : ' ',
338 dbg_info[i].level, dbg_info[i].desc); 336 dbg_info[i].level, dbg_info[i].desc);
339 337
340 if (len > sizeof(buf)) 338 if (len > sizeof(buf))
@@ -347,7 +345,7 @@ static ssize_t write_file_debug(struct file *file,
347 const char __user *userbuf, 345 const char __user *userbuf,
348 size_t count, loff_t *ppos) 346 size_t count, loff_t *ppos)
349{ 347{
350 struct ath5k_softc *sc = file->private_data; 348 struct ath5k_hw *ah = file->private_data;
351 unsigned int i; 349 unsigned int i;
352 char buf[20]; 350 char buf[20];
353 351
@@ -357,7 +355,7 @@ static ssize_t write_file_debug(struct file *file,
357 for (i = 0; i < ARRAY_SIZE(dbg_info); i++) { 355 for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
358 if (strncmp(buf, dbg_info[i].name, 356 if (strncmp(buf, dbg_info[i].name,
359 strlen(dbg_info[i].name)) == 0) { 357 strlen(dbg_info[i].name)) == 0) {
360 sc->debug.level ^= dbg_info[i].level; /* toggle bit */ 358 ah->debug.level ^= dbg_info[i].level; /* toggle bit */
361 break; 359 break;
362 } 360 }
363 } 361 }
@@ -378,33 +376,33 @@ static const struct file_operations fops_debug = {
378static ssize_t read_file_antenna(struct file *file, char __user *user_buf, 376static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
379 size_t count, loff_t *ppos) 377 size_t count, loff_t *ppos)
380{ 378{
381 struct ath5k_softc *sc = file->private_data; 379 struct ath5k_hw *ah = file->private_data;
382 char buf[700]; 380 char buf[700];
383 unsigned int len = 0; 381 unsigned int len = 0;
384 unsigned int i; 382 unsigned int i;
385 unsigned int v; 383 unsigned int v;
386 384
387 len += snprintf(buf + len, sizeof(buf) - len, "antenna mode\t%d\n", 385 len += snprintf(buf + len, sizeof(buf) - len, "antenna mode\t%d\n",
388 sc->ah->ah_ant_mode); 386 ah->ah_ant_mode);
389 len += snprintf(buf + len, sizeof(buf) - len, "default antenna\t%d\n", 387 len += snprintf(buf + len, sizeof(buf) - len, "default antenna\t%d\n",
390 sc->ah->ah_def_ant); 388 ah->ah_def_ant);
391 len += snprintf(buf + len, sizeof(buf) - len, "tx antenna\t%d\n", 389 len += snprintf(buf + len, sizeof(buf) - len, "tx antenna\t%d\n",
392 sc->ah->ah_tx_ant); 390 ah->ah_tx_ant);
393 391
394 len += snprintf(buf + len, sizeof(buf) - len, "\nANTENNA\t\tRX\tTX\n"); 392 len += snprintf(buf + len, sizeof(buf) - len, "\nANTENNA\t\tRX\tTX\n");
395 for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) { 393 for (i = 1; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
396 len += snprintf(buf + len, sizeof(buf) - len, 394 len += snprintf(buf + len, sizeof(buf) - len,
397 "[antenna %d]\t%d\t%d\n", 395 "[antenna %d]\t%d\t%d\n",
398 i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]); 396 i, ah->stats.antenna_rx[i], ah->stats.antenna_tx[i]);
399 } 397 }
400 len += snprintf(buf + len, sizeof(buf) - len, "[invalid]\t%d\t%d\n", 398 len += snprintf(buf + len, sizeof(buf) - len, "[invalid]\t%d\t%d\n",
401 sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]); 399 ah->stats.antenna_rx[0], ah->stats.antenna_tx[0]);
402 400
403 v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA); 401 v = ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA);
404 len += snprintf(buf + len, sizeof(buf) - len, 402 len += snprintf(buf + len, sizeof(buf) - len,
405 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v); 403 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
406 404
407 v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1); 405 v = ath5k_hw_reg_read(ah, AR5K_STA_ID1);
408 len += snprintf(buf + len, sizeof(buf) - len, 406 len += snprintf(buf + len, sizeof(buf) - len,
409 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n", 407 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
410 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0); 408 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
@@ -418,25 +416,25 @@ static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
418 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n", 416 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
419 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0); 417 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
420 418
421 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL); 419 v = ath5k_hw_reg_read(ah, AR5K_PHY_AGCCTL);
422 len += snprintf(buf + len, sizeof(buf) - len, 420 len += snprintf(buf + len, sizeof(buf) - len,
423 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n", 421 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
424 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0); 422 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
425 423
426 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART); 424 v = ath5k_hw_reg_read(ah, AR5K_PHY_RESTART);
427 len += snprintf(buf + len, sizeof(buf) - len, 425 len += snprintf(buf + len, sizeof(buf) - len,
428 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n", 426 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
429 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S); 427 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
430 428
431 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV); 429 v = ath5k_hw_reg_read(ah, AR5K_PHY_FAST_ANT_DIV);
432 len += snprintf(buf + len, sizeof(buf) - len, 430 len += snprintf(buf + len, sizeof(buf) - len,
433 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n", 431 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
434 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0); 432 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
435 433
436 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_0); 434 v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
437 len += snprintf(buf + len, sizeof(buf) - len, 435 len += snprintf(buf + len, sizeof(buf) - len,
438 "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v); 436 "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
439 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_1); 437 v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
440 len += snprintf(buf + len, sizeof(buf) - len, 438 len += snprintf(buf + len, sizeof(buf) - len,
441 "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v); 439 "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
442 440
@@ -450,7 +448,7 @@ static ssize_t write_file_antenna(struct file *file,
450 const char __user *userbuf, 448 const char __user *userbuf,
451 size_t count, loff_t *ppos) 449 size_t count, loff_t *ppos)
452{ 450{
453 struct ath5k_softc *sc = file->private_data; 451 struct ath5k_hw *ah = file->private_data;
454 unsigned int i; 452 unsigned int i;
455 char buf[20]; 453 char buf[20];
456 454
@@ -458,18 +456,18 @@ static ssize_t write_file_antenna(struct file *file,
458 return -EFAULT; 456 return -EFAULT;
459 457
460 if (strncmp(buf, "diversity", 9) == 0) { 458 if (strncmp(buf, "diversity", 9) == 0) {
461 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT); 459 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
462 printk(KERN_INFO "ath5k debug: enable diversity\n"); 460 printk(KERN_INFO "ath5k debug: enable diversity\n");
463 } else if (strncmp(buf, "fixed-a", 7) == 0) { 461 } else if (strncmp(buf, "fixed-a", 7) == 0) {
464 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A); 462 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_A);
465 printk(KERN_INFO "ath5k debugfs: fixed antenna A\n"); 463 printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
466 } else if (strncmp(buf, "fixed-b", 7) == 0) { 464 } else if (strncmp(buf, "fixed-b", 7) == 0) {
467 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B); 465 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_B);
468 printk(KERN_INFO "ath5k debug: fixed antenna B\n"); 466 printk(KERN_INFO "ath5k debug: fixed antenna B\n");
469 } else if (strncmp(buf, "clear", 5) == 0) { 467 } else if (strncmp(buf, "clear", 5) == 0) {
470 for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) { 468 for (i = 0; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
471 sc->stats.antenna_rx[i] = 0; 469 ah->stats.antenna_rx[i] = 0;
472 sc->stats.antenna_tx[i] = 0; 470 ah->stats.antenna_tx[i] = 0;
473 } 471 }
474 printk(KERN_INFO "ath5k debug: cleared antenna stats\n"); 472 printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
475 } 473 }
@@ -489,13 +487,13 @@ static const struct file_operations fops_antenna = {
489static ssize_t read_file_misc(struct file *file, char __user *user_buf, 487static ssize_t read_file_misc(struct file *file, char __user *user_buf,
490 size_t count, loff_t *ppos) 488 size_t count, loff_t *ppos)
491{ 489{
492 struct ath5k_softc *sc = file->private_data; 490 struct ath5k_hw *ah = file->private_data;
493 char buf[700]; 491 char buf[700];
494 unsigned int len = 0; 492 unsigned int len = 0;
495 u32 filt = ath5k_hw_get_rx_filter(sc->ah); 493 u32 filt = ath5k_hw_get_rx_filter(ah);
496 494
497 len += snprintf(buf + len, sizeof(buf) - len, "bssid-mask: %pM\n", 495 len += snprintf(buf + len, sizeof(buf) - len, "bssid-mask: %pM\n",
498 sc->bssidmask); 496 ah->bssidmask);
499 len += snprintf(buf + len, sizeof(buf) - len, "filter-flags: 0x%x ", 497 len += snprintf(buf + len, sizeof(buf) - len, "filter-flags: 0x%x ",
500 filt); 498 filt);
501 if (filt & AR5K_RX_FILTER_UCAST) 499 if (filt & AR5K_RX_FILTER_UCAST)
@@ -524,7 +522,7 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
524 len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5211"); 522 len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5211");
525 523
526 len += snprintf(buf + len, sizeof(buf) - len, "\nopmode: %s (%d)\n", 524 len += snprintf(buf + len, sizeof(buf) - len, "\nopmode: %s (%d)\n",
527 ath_opmode_to_string(sc->opmode), sc->opmode); 525 ath_opmode_to_string(ah->opmode), ah->opmode);
528 526
529 if (len > sizeof(buf)) 527 if (len > sizeof(buf))
530 len = sizeof(buf); 528 len = sizeof(buf);
@@ -544,8 +542,8 @@ static const struct file_operations fops_misc = {
544static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf, 542static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
545 size_t count, loff_t *ppos) 543 size_t count, loff_t *ppos)
546{ 544{
547 struct ath5k_softc *sc = file->private_data; 545 struct ath5k_hw *ah = file->private_data;
548 struct ath5k_statistics *st = &sc->stats; 546 struct ath5k_statistics *st = &ah->stats;
549 char buf[700]; 547 char buf[700];
550 unsigned int len = 0; 548 unsigned int len = 0;
551 int i; 549 int i;
@@ -621,8 +619,8 @@ static ssize_t write_file_frameerrors(struct file *file,
621 const char __user *userbuf, 619 const char __user *userbuf,
622 size_t count, loff_t *ppos) 620 size_t count, loff_t *ppos)
623{ 621{
624 struct ath5k_softc *sc = file->private_data; 622 struct ath5k_hw *ah = file->private_data;
625 struct ath5k_statistics *st = &sc->stats; 623 struct ath5k_statistics *st = &ah->stats;
626 char buf[20]; 624 char buf[20];
627 625
628 if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) 626 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
@@ -660,16 +658,16 @@ static const struct file_operations fops_frameerrors = {
660static ssize_t read_file_ani(struct file *file, char __user *user_buf, 658static ssize_t read_file_ani(struct file *file, char __user *user_buf,
661 size_t count, loff_t *ppos) 659 size_t count, loff_t *ppos)
662{ 660{
663 struct ath5k_softc *sc = file->private_data; 661 struct ath5k_hw *ah = file->private_data;
664 struct ath5k_statistics *st = &sc->stats; 662 struct ath5k_statistics *st = &ah->stats;
665 struct ath5k_ani_state *as = &sc->ani_state; 663 struct ath5k_ani_state *as = &ah->ani_state;
666 664
667 char buf[700]; 665 char buf[700];
668 unsigned int len = 0; 666 unsigned int len = 0;
669 667
670 len += snprintf(buf + len, sizeof(buf) - len, 668 len += snprintf(buf + len, sizeof(buf) - len,
671 "HW has PHY error counters:\t%s\n", 669 "HW has PHY error counters:\t%s\n",
672 sc->ah->ah_capabilities.cap_has_phyerr_counters ? 670 ah->ah_capabilities.cap_has_phyerr_counters ?
673 "yes" : "no"); 671 "yes" : "no");
674 len += snprintf(buf + len, sizeof(buf) - len, 672 len += snprintf(buf + len, sizeof(buf) - len,
675 "HW max spur immunity level:\t%d\n", 673 "HW max spur immunity level:\t%d\n",
@@ -718,7 +716,7 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
718 st->mib_intr); 716 st->mib_intr);
719 len += snprintf(buf + len, sizeof(buf) - len, 717 len += snprintf(buf + len, sizeof(buf) - len,
720 "beacon RSSI average:\t%d\n", 718 "beacon RSSI average:\t%d\n",
721 (int)ewma_read(&sc->ah->ah_beacon_rssi_avg)); 719 (int)ewma_read(&ah->ah_beacon_rssi_avg));
722 720
723#define CC_PRINT(_struct, _field) \ 721#define CC_PRINT(_struct, _field) \
724 _struct._field, \ 722 _struct._field, \
@@ -750,14 +748,14 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
750 as->sum_cck_errors); 748 as->sum_cck_errors);
751 len += snprintf(buf + len, sizeof(buf) - len, 749 len += snprintf(buf + len, sizeof(buf) - len,
752 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n", 750 "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
753 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1), 751 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT1),
754 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - 752 ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
755 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1))); 753 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT1)));
756 len += snprintf(buf + len, sizeof(buf) - len, 754 len += snprintf(buf + len, sizeof(buf) - len,
757 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n", 755 "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
758 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2), 756 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT2),
759 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - 757 ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
760 ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2))); 758 ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT2)));
761 759
762 if (len > sizeof(buf)) 760 if (len > sizeof(buf))
763 len = sizeof(buf); 761 len = sizeof(buf);
@@ -769,42 +767,42 @@ static ssize_t write_file_ani(struct file *file,
769 const char __user *userbuf, 767 const char __user *userbuf,
770 size_t count, loff_t *ppos) 768 size_t count, loff_t *ppos)
771{ 769{
772 struct ath5k_softc *sc = file->private_data; 770 struct ath5k_hw *ah = file->private_data;
773 char buf[20]; 771 char buf[20];
774 772
775 if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) 773 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
776 return -EFAULT; 774 return -EFAULT;
777 775
778 if (strncmp(buf, "sens-low", 8) == 0) { 776 if (strncmp(buf, "sens-low", 8) == 0) {
779 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_HIGH); 777 ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_HIGH);
780 } else if (strncmp(buf, "sens-high", 9) == 0) { 778 } else if (strncmp(buf, "sens-high", 9) == 0) {
781 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_LOW); 779 ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_LOW);
782 } else if (strncmp(buf, "ani-off", 7) == 0) { 780 } else if (strncmp(buf, "ani-off", 7) == 0) {
783 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_OFF); 781 ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF);
784 } else if (strncmp(buf, "ani-on", 6) == 0) { 782 } else if (strncmp(buf, "ani-on", 6) == 0) {
785 ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_AUTO); 783 ath5k_ani_init(ah, ATH5K_ANI_MODE_AUTO);
786 } else if (strncmp(buf, "noise-low", 9) == 0) { 784 } else if (strncmp(buf, "noise-low", 9) == 0) {
787 ath5k_ani_set_noise_immunity_level(sc->ah, 0); 785 ath5k_ani_set_noise_immunity_level(ah, 0);
788 } else if (strncmp(buf, "noise-high", 10) == 0) { 786 } else if (strncmp(buf, "noise-high", 10) == 0) {
789 ath5k_ani_set_noise_immunity_level(sc->ah, 787 ath5k_ani_set_noise_immunity_level(ah,
790 ATH5K_ANI_MAX_NOISE_IMM_LVL); 788 ATH5K_ANI_MAX_NOISE_IMM_LVL);
791 } else if (strncmp(buf, "spur-low", 8) == 0) { 789 } else if (strncmp(buf, "spur-low", 8) == 0) {
792 ath5k_ani_set_spur_immunity_level(sc->ah, 0); 790 ath5k_ani_set_spur_immunity_level(ah, 0);
793 } else if (strncmp(buf, "spur-high", 9) == 0) { 791 } else if (strncmp(buf, "spur-high", 9) == 0) {
794 ath5k_ani_set_spur_immunity_level(sc->ah, 792 ath5k_ani_set_spur_immunity_level(ah,
795 sc->ani_state.max_spur_level); 793 ah->ani_state.max_spur_level);
796 } else if (strncmp(buf, "fir-low", 7) == 0) { 794 } else if (strncmp(buf, "fir-low", 7) == 0) {
797 ath5k_ani_set_firstep_level(sc->ah, 0); 795 ath5k_ani_set_firstep_level(ah, 0);
798 } else if (strncmp(buf, "fir-high", 8) == 0) { 796 } else if (strncmp(buf, "fir-high", 8) == 0) {
799 ath5k_ani_set_firstep_level(sc->ah, ATH5K_ANI_MAX_FIRSTEP_LVL); 797 ath5k_ani_set_firstep_level(ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
800 } else if (strncmp(buf, "ofdm-off", 8) == 0) { 798 } else if (strncmp(buf, "ofdm-off", 8) == 0) {
801 ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, false); 799 ath5k_ani_set_ofdm_weak_signal_detection(ah, false);
802 } else if (strncmp(buf, "ofdm-on", 7) == 0) { 800 } else if (strncmp(buf, "ofdm-on", 7) == 0) {
803 ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, true); 801 ath5k_ani_set_ofdm_weak_signal_detection(ah, true);
804 } else if (strncmp(buf, "cck-off", 7) == 0) { 802 } else if (strncmp(buf, "cck-off", 7) == 0) {
805 ath5k_ani_set_cck_weak_signal_detection(sc->ah, false); 803 ath5k_ani_set_cck_weak_signal_detection(ah, false);
806 } else if (strncmp(buf, "cck-on", 6) == 0) { 804 } else if (strncmp(buf, "cck-on", 6) == 0) {
807 ath5k_ani_set_cck_weak_signal_detection(sc->ah, true); 805 ath5k_ani_set_cck_weak_signal_detection(ah, true);
808 } 806 }
809 return count; 807 return count;
810} 808}
@@ -823,7 +821,7 @@ static const struct file_operations fops_ani = {
823static ssize_t read_file_queue(struct file *file, char __user *user_buf, 821static ssize_t read_file_queue(struct file *file, char __user *user_buf,
824 size_t count, loff_t *ppos) 822 size_t count, loff_t *ppos)
825{ 823{
826 struct ath5k_softc *sc = file->private_data; 824 struct ath5k_hw *ah = file->private_data;
827 char buf[700]; 825 char buf[700];
828 unsigned int len = 0; 826 unsigned int len = 0;
829 827
@@ -832,10 +830,10 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
832 int i, n; 830 int i, n;
833 831
834 len += snprintf(buf + len, sizeof(buf) - len, 832 len += snprintf(buf + len, sizeof(buf) - len,
835 "available txbuffers: %d\n", sc->txbuf_len); 833 "available txbuffers: %d\n", ah->txbuf_len);
836 834
837 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) { 835 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) {
838 txq = &sc->txqs[i]; 836 txq = &ah->txqs[i];
839 837
840 len += snprintf(buf + len, sizeof(buf) - len, 838 len += snprintf(buf + len, sizeof(buf) - len,
841 "%02d: %ssetup\n", i, txq->setup ? "" : "not "); 839 "%02d: %ssetup\n", i, txq->setup ? "" : "not ");
@@ -865,16 +863,16 @@ static ssize_t write_file_queue(struct file *file,
865 const char __user *userbuf, 863 const char __user *userbuf,
866 size_t count, loff_t *ppos) 864 size_t count, loff_t *ppos)
867{ 865{
868 struct ath5k_softc *sc = file->private_data; 866 struct ath5k_hw *ah = file->private_data;
869 char buf[20]; 867 char buf[20];
870 868
871 if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) 869 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
872 return -EFAULT; 870 return -EFAULT;
873 871
874 if (strncmp(buf, "start", 5) == 0) 872 if (strncmp(buf, "start", 5) == 0)
875 ieee80211_wake_queues(sc->hw); 873 ieee80211_wake_queues(ah->hw);
876 else if (strncmp(buf, "stop", 4) == 0) 874 else if (strncmp(buf, "stop", 4) == 0)
877 ieee80211_stop_queues(sc->hw); 875 ieee80211_stop_queues(ah->hw);
878 876
879 return count; 877 return count;
880} 878}
@@ -890,57 +888,57 @@ static const struct file_operations fops_queue = {
890 888
891 889
892void 890void
893ath5k_debug_init_device(struct ath5k_softc *sc) 891ath5k_debug_init_device(struct ath5k_hw *ah)
894{ 892{
895 struct dentry *phydir; 893 struct dentry *phydir;
896 894
897 sc->debug.level = ath5k_debug; 895 ah->debug.level = ath5k_debug;
898 896
899 phydir = debugfs_create_dir("ath5k", sc->hw->wiphy->debugfsdir); 897 phydir = debugfs_create_dir("ath5k", ah->hw->wiphy->debugfsdir);
900 if (!phydir) 898 if (!phydir)
901 return; 899 return;
902 900
903 debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, sc, 901 debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, ah,
904 &fops_debug); 902 &fops_debug);
905 903
906 debugfs_create_file("registers", S_IRUSR, phydir, sc, &fops_registers); 904 debugfs_create_file("registers", S_IRUSR, phydir, ah, &fops_registers);
907 905
908 debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, sc, 906 debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
909 &fops_beacon); 907 &fops_beacon);
910 908
911 debugfs_create_file("reset", S_IWUSR, phydir, sc, &fops_reset); 909 debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
912 910
913 debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, sc, 911 debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
914 &fops_antenna); 912 &fops_antenna);
915 913
916 debugfs_create_file("misc", S_IRUSR, phydir, sc, &fops_misc); 914 debugfs_create_file("misc", S_IRUSR, phydir, ah, &fops_misc);
917 915
918 debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, sc, 916 debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, ah,
919 &fops_frameerrors); 917 &fops_frameerrors);
920 918
921 debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, sc, &fops_ani); 919 debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, ah, &fops_ani);
922 920
923 debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, sc, 921 debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, ah,
924 &fops_queue); 922 &fops_queue);
925 923
926 debugfs_create_bool("32khz_clock", S_IWUSR | S_IRUSR, phydir, 924 debugfs_create_bool("32khz_clock", S_IWUSR | S_IRUSR, phydir,
927 &sc->ah->ah_use_32khz_clock); 925 &ah->ah_use_32khz_clock);
928} 926}
929 927
930/* functions used in other places */ 928/* functions used in other places */
931 929
932void 930void
933ath5k_debug_dump_bands(struct ath5k_softc *sc) 931ath5k_debug_dump_bands(struct ath5k_hw *ah)
934{ 932{
935 unsigned int b, i; 933 unsigned int b, i;
936 934
937 if (likely(!(sc->debug.level & ATH5K_DEBUG_DUMPBANDS))) 935 if (likely(!(ah->debug.level & ATH5K_DEBUG_DUMPBANDS)))
938 return; 936 return;
939 937
940 BUG_ON(!sc->sbands); 938 BUG_ON(!ah->sbands);
941 939
942 for (b = 0; b < IEEE80211_NUM_BANDS; b++) { 940 for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
943 struct ieee80211_supported_band *band = &sc->sbands[b]; 941 struct ieee80211_supported_band *band = &ah->sbands[b];
944 char bname[6]; 942 char bname[6];
945 switch (band->band) { 943 switch (band->band) {
946 case IEEE80211_BAND_2GHZ: 944 case IEEE80211_BAND_2GHZ:
@@ -990,41 +988,41 @@ ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
990} 988}
991 989
992void 990void
993ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah) 991ath5k_debug_printrxbuffs(struct ath5k_hw *ah)
994{ 992{
995 struct ath5k_desc *ds; 993 struct ath5k_desc *ds;
996 struct ath5k_buf *bf; 994 struct ath5k_buf *bf;
997 struct ath5k_rx_status rs = {}; 995 struct ath5k_rx_status rs = {};
998 int status; 996 int status;
999 997
1000 if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC))) 998 if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
1001 return; 999 return;
1002 1000
1003 printk(KERN_DEBUG "rxdp %x, rxlink %p\n", 1001 printk(KERN_DEBUG "rxdp %x, rxlink %p\n",
1004 ath5k_hw_get_rxdp(ah), sc->rxlink); 1002 ath5k_hw_get_rxdp(ah), ah->rxlink);
1005 1003
1006 spin_lock_bh(&sc->rxbuflock); 1004 spin_lock_bh(&ah->rxbuflock);
1007 list_for_each_entry(bf, &sc->rxbuf, list) { 1005 list_for_each_entry(bf, &ah->rxbuf, list) {
1008 ds = bf->desc; 1006 ds = bf->desc;
1009 status = ah->ah_proc_rx_desc(ah, ds, &rs); 1007 status = ah->ah_proc_rx_desc(ah, ds, &rs);
1010 if (!status) 1008 if (!status)
1011 ath5k_debug_printrxbuf(bf, status == 0, &rs); 1009 ath5k_debug_printrxbuf(bf, status == 0, &rs);
1012 } 1010 }
1013 spin_unlock_bh(&sc->rxbuflock); 1011 spin_unlock_bh(&ah->rxbuflock);
1014} 1012}
1015 1013
1016void 1014void
1017ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf) 1015ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf)
1018{ 1016{
1019 struct ath5k_desc *ds = bf->desc; 1017 struct ath5k_desc *ds = bf->desc;
1020 struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212; 1018 struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
1021 struct ath5k_tx_status ts = {}; 1019 struct ath5k_tx_status ts = {};
1022 int done; 1020 int done;
1023 1021
1024 if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC))) 1022 if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
1025 return; 1023 return;
1026 1024
1027 done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts); 1025 done = ah->ah_proc_tx_desc(ah, bf->desc, &ts);
1028 1026
1029 printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x " 1027 printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
1030 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link, 1028 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
diff --git a/drivers/net/wireless/ath/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h
index 193dd2d4ea3c..7f37df3125fd 100644
--- a/drivers/net/wireless/ath/ath5k/debug.h
+++ b/drivers/net/wireless/ath/ath5k/debug.h
@@ -61,7 +61,6 @@
61#ifndef _ATH5K_DEBUG_H 61#ifndef _ATH5K_DEBUG_H
62#define _ATH5K_DEBUG_H 62#define _ATH5K_DEBUG_H
63 63
64struct ath5k_softc;
65struct ath5k_hw; 64struct ath5k_hw;
66struct sk_buff; 65struct sk_buff;
67struct ath5k_buf; 66struct ath5k_buf;
@@ -127,39 +126,39 @@ enum ath5k_debug_level {
127 } while (0) 126 } while (0)
128 127
129void 128void
130ath5k_debug_init_device(struct ath5k_softc *sc); 129ath5k_debug_init_device(struct ath5k_hw *ah);
131 130
132void 131void
133ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah); 132ath5k_debug_printrxbuffs(struct ath5k_hw *ah);
134 133
135void 134void
136ath5k_debug_dump_bands(struct ath5k_softc *sc); 135ath5k_debug_dump_bands(struct ath5k_hw *ah);
137 136
138void 137void
139ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf); 138ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf);
140 139
141#else /* no debugging */ 140#else /* no debugging */
142 141
143#include <linux/compiler.h> 142#include <linux/compiler.h>
144 143
145static inline void __attribute__ ((format (printf, 3, 4))) 144static inline void __attribute__ ((format (printf, 3, 4)))
146ATH5K_DBG(struct ath5k_softc *sc, unsigned int m, const char *fmt, ...) {} 145ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {}
147 146
148static inline void __attribute__ ((format (printf, 3, 4))) 147static inline void __attribute__ ((format (printf, 3, 4)))
149ATH5K_DBG_UNLIMIT(struct ath5k_softc *sc, unsigned int m, const char *fmt, ...) 148ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...)
150{} 149{}
151 150
152static inline void 151static inline void
153ath5k_debug_init_device(struct ath5k_softc *sc) {} 152ath5k_debug_init_device(struct ath5k_hw *ah) {}
154 153
155static inline void 154static inline void
156ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah) {} 155ath5k_debug_printrxbuffs(struct ath5k_hw *ah) {}
157 156
158static inline void 157static inline void
159ath5k_debug_dump_bands(struct ath5k_softc *sc) {} 158ath5k_debug_dump_bands(struct ath5k_hw *ah) {}
160 159
161static inline void 160static inline void
162ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf) {} 161ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf) {}
163 162
164#endif /* ifdef CONFIG_ATH5K_DEBUG */ 163#endif /* ifdef CONFIG_ATH5K_DEBUG */
165 164
diff --git a/drivers/net/wireless/ath/ath5k/desc.c b/drivers/net/wireless/ath/ath5k/desc.c
index f82383b3ed30..846535f59efc 100644
--- a/drivers/net/wireless/ath/ath5k/desc.c
+++ b/drivers/net/wireless/ath/ath5k/desc.c
@@ -55,12 +55,12 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
55 * noise on the channel, so it is important to avoid this. 55 * noise on the channel, so it is important to avoid this.
56 */ 56 */
57 if (unlikely(tx_tries0 == 0)) { 57 if (unlikely(tx_tries0 == 0)) {
58 ATH5K_ERR(ah->ah_sc, "zero retries\n"); 58 ATH5K_ERR(ah, "zero retries\n");
59 WARN_ON(1); 59 WARN_ON(1);
60 return -EINVAL; 60 return -EINVAL;
61 } 61 }
62 if (unlikely(tx_rate0 == 0)) { 62 if (unlikely(tx_rate0 == 0)) {
63 ATH5K_ERR(ah->ah_sc, "zero rate\n"); 63 ATH5K_ERR(ah, "zero rate\n");
64 WARN_ON(1); 64 WARN_ON(1);
65 return -EINVAL; 65 return -EINVAL;
66 } 66 }
@@ -203,12 +203,12 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
203 * noise on the channel, so it is important to avoid this. 203 * noise on the channel, so it is important to avoid this.
204 */ 204 */
205 if (unlikely(tx_tries0 == 0)) { 205 if (unlikely(tx_tries0 == 0)) {
206 ATH5K_ERR(ah->ah_sc, "zero retries\n"); 206 ATH5K_ERR(ah, "zero retries\n");
207 WARN_ON(1); 207 WARN_ON(1);
208 return -EINVAL; 208 return -EINVAL;
209 } 209 }
210 if (unlikely(tx_rate0 == 0)) { 210 if (unlikely(tx_rate0 == 0)) {
211 ATH5K_ERR(ah->ah_sc, "zero rate\n"); 211 ATH5K_ERR(ah, "zero rate\n");
212 WARN_ON(1); 212 WARN_ON(1);
213 return -EINVAL; 213 return -EINVAL;
214 } 214 }
@@ -316,7 +316,7 @@ ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
316 if (unlikely((tx_rate1 == 0 && tx_tries1 != 0) || 316 if (unlikely((tx_rate1 == 0 && tx_tries1 != 0) ||
317 (tx_rate2 == 0 && tx_tries2 != 0) || 317 (tx_rate2 == 0 && tx_tries2 != 0) ||
318 (tx_rate3 == 0 && tx_tries3 != 0))) { 318 (tx_rate3 == 0 && tx_tries3 != 0))) {
319 ATH5K_ERR(ah->ah_sc, "zero rate\n"); 319 ATH5K_ERR(ah, "zero rate\n");
320 WARN_ON(1); 320 WARN_ON(1);
321 return -EINVAL; 321 return -EINVAL;
322 } 322 }
diff --git a/drivers/net/wireless/ath/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c
index b788ecfbdaf6..0d5d4033f12a 100644
--- a/drivers/net/wireless/ath/ath5k/dma.c
+++ b/drivers/net/wireless/ath/ath5k/dma.c
@@ -73,7 +73,7 @@ static int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah)
73 udelay(100); 73 udelay(100);
74 74
75 if (!i) 75 if (!i)
76 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_DMA, 76 ATH5K_DBG(ah, ATH5K_DEBUG_DMA,
77 "failed to stop RX DMA !\n"); 77 "failed to stop RX DMA !\n");
78 78
79 return i ? 0 : -EBUSY; 79 return i ? 0 : -EBUSY;
@@ -100,7 +100,7 @@ u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah)
100int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) 100int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr)
101{ 101{
102 if (ath5k_hw_reg_read(ah, AR5K_CR) & AR5K_CR_RXE) { 102 if (ath5k_hw_reg_read(ah, AR5K_CR) & AR5K_CR_RXE) {
103 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_DMA, 103 ATH5K_DBG(ah, ATH5K_DEBUG_DMA,
104 "tried to set RXDP while rx was active !\n"); 104 "tried to set RXDP while rx was active !\n");
105 return -EIO; 105 return -EIO;
106 } 106 }
@@ -243,7 +243,7 @@ static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue)
243 udelay(100); 243 udelay(100);
244 244
245 if (AR5K_REG_READ_Q(ah, AR5K_QCU_TXE, queue)) 245 if (AR5K_REG_READ_Q(ah, AR5K_QCU_TXE, queue))
246 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_DMA, 246 ATH5K_DBG(ah, ATH5K_DEBUG_DMA,
247 "queue %i didn't stop !\n", queue); 247 "queue %i didn't stop !\n", queue);
248 248
249 /* Check for pending frames */ 249 /* Check for pending frames */
@@ -295,7 +295,7 @@ static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue)
295 AR5K_DIAG_SW_CHANNEL_IDLE_HIGH); 295 AR5K_DIAG_SW_CHANNEL_IDLE_HIGH);
296 296
297 if (pending) 297 if (pending)
298 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_DMA, 298 ATH5K_DBG(ah, ATH5K_DEBUG_DMA,
299 "quiet mechanism didn't work q:%i !\n", 299 "quiet mechanism didn't work q:%i !\n",
300 queue); 300 queue);
301 } 301 }
@@ -309,7 +309,7 @@ static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue)
309 /* Clear register */ 309 /* Clear register */
310 ath5k_hw_reg_write(ah, 0, AR5K_QCU_TXD); 310 ath5k_hw_reg_write(ah, 0, AR5K_QCU_TXD);
311 if (pending) { 311 if (pending) {
312 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_DMA, 312 ATH5K_DBG(ah, ATH5K_DEBUG_DMA,
313 "tx dma didn't stop (q:%i, frm:%i) !\n", 313 "tx dma didn't stop (q:%i, frm:%i) !\n",
314 queue, pending); 314 queue, pending);
315 return -EBUSY; 315 return -EBUSY;
@@ -333,7 +333,7 @@ int ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue)
333 int ret; 333 int ret;
334 ret = ath5k_hw_stop_tx_dma(ah, queue); 334 ret = ath5k_hw_stop_tx_dma(ah, queue);
335 if (ret) { 335 if (ret) {
336 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_DMA, 336 ATH5K_DBG(ah, ATH5K_DEBUG_DMA,
337 "beacon queue didn't stop !\n"); 337 "beacon queue didn't stop !\n");
338 return -EIO; 338 return -EIO;
339 } 339 }
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index d9e605e37007..9068b9165265 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -105,7 +105,7 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
105 * big still, waiting on a better value. 105 * big still, waiting on a better value.
106 */ 106 */
107 if (eep_max > (3 * AR5K_EEPROM_INFO_MAX)) { 107 if (eep_max > (3 * AR5K_EEPROM_INFO_MAX)) {
108 ATH5K_ERR(ah->ah_sc, "Invalid max custom EEPROM size: " 108 ATH5K_ERR(ah, "Invalid max custom EEPROM size: "
109 "%d (0x%04x) max expected: %d (0x%04x)\n", 109 "%d (0x%04x) max expected: %d (0x%04x)\n",
110 eep_max, eep_max, 110 eep_max, eep_max,
111 3 * AR5K_EEPROM_INFO_MAX, 111 3 * AR5K_EEPROM_INFO_MAX,
@@ -119,7 +119,7 @@ ath5k_eeprom_init_header(struct ath5k_hw *ah)
119 cksum ^= val; 119 cksum ^= val;
120 } 120 }
121 if (cksum != AR5K_EEPROM_INFO_CKSUM) { 121 if (cksum != AR5K_EEPROM_INFO_CKSUM) {
122 ATH5K_ERR(ah->ah_sc, "Invalid EEPROM " 122 ATH5K_ERR(ah, "Invalid EEPROM "
123 "checksum: 0x%04x eep_max: 0x%04x (%s)\n", 123 "checksum: 0x%04x eep_max: 0x%04x (%s)\n",
124 cksum, eep_max, 124 cksum, eep_max,
125 eep_max == AR5K_EEPROM_INFO_MAX ? 125 eep_max == AR5K_EEPROM_INFO_MAX ?
diff --git a/drivers/net/wireless/ath/ath5k/initvals.c b/drivers/net/wireless/ath/ath5k/initvals.c
index 855d1af3e710..5ab607f40e0e 100644
--- a/drivers/net/wireless/ath/ath5k/initvals.c
+++ b/drivers/net/wireless/ath/ath5k/initvals.c
@@ -1542,7 +1542,7 @@ int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu)
1542 1542
1543 /* AR5K_MODE_11B */ 1543 /* AR5K_MODE_11B */
1544 if (mode > 2) { 1544 if (mode > 2) {
1545 ATH5K_ERR(ah->ah_sc, 1545 ATH5K_ERR(ah,
1546 "unsupported channel mode: %d\n", mode); 1546 "unsupported channel mode: %d\n", mode);
1547 return -EINVAL; 1547 return -EINVAL;
1548 } 1548 }
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index 127bfbd35172..8c17a00f7dad 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -86,26 +86,26 @@ static DEFINE_PCI_DEVICE_TABLE(ath5k_led_devices) = {
86 { } 86 { }
87}; 87};
88 88
89void ath5k_led_enable(struct ath5k_softc *sc) 89void ath5k_led_enable(struct ath5k_hw *ah)
90{ 90{
91 if (test_bit(ATH_STAT_LEDSOFT, sc->status)) { 91 if (test_bit(ATH_STAT_LEDSOFT, ah->status)) {
92 ath5k_hw_set_gpio_output(sc->ah, sc->led_pin); 92 ath5k_hw_set_gpio_output(ah, ah->led_pin);
93 ath5k_led_off(sc); 93 ath5k_led_off(ah);
94 } 94 }
95} 95}
96 96
97static void ath5k_led_on(struct ath5k_softc *sc) 97static void ath5k_led_on(struct ath5k_hw *ah)
98{ 98{
99 if (!test_bit(ATH_STAT_LEDSOFT, sc->status)) 99 if (!test_bit(ATH_STAT_LEDSOFT, ah->status))
100 return; 100 return;
101 ath5k_hw_set_gpio(sc->ah, sc->led_pin, sc->led_on); 101 ath5k_hw_set_gpio(ah, ah->led_pin, ah->led_on);
102} 102}
103 103
104void ath5k_led_off(struct ath5k_softc *sc) 104void ath5k_led_off(struct ath5k_hw *ah)
105{ 105{
106 if (!test_bit(ATH_STAT_LEDSOFT, sc->status)) 106 if (!test_bit(ATH_STAT_LEDSOFT, ah->status))
107 return; 107 return;
108 ath5k_hw_set_gpio(sc->ah, sc->led_pin, !sc->led_on); 108 ath5k_hw_set_gpio(ah, ah->led_pin, !ah->led_on);
109} 109}
110 110
111static void 111static void
@@ -116,27 +116,27 @@ ath5k_led_brightness_set(struct led_classdev *led_dev,
116 led_dev); 116 led_dev);
117 117
118 if (brightness == LED_OFF) 118 if (brightness == LED_OFF)
119 ath5k_led_off(led->sc); 119 ath5k_led_off(led->ah);
120 else 120 else
121 ath5k_led_on(led->sc); 121 ath5k_led_on(led->ah);
122} 122}
123 123
124static int 124static int
125ath5k_register_led(struct ath5k_softc *sc, struct ath5k_led *led, 125ath5k_register_led(struct ath5k_hw *ah, struct ath5k_led *led,
126 const char *name, char *trigger) 126 const char *name, char *trigger)
127{ 127{
128 int err; 128 int err;
129 129
130 led->sc = sc; 130 led->ah = ah;
131 strncpy(led->name, name, sizeof(led->name)); 131 strncpy(led->name, name, sizeof(led->name));
132 led->led_dev.name = led->name; 132 led->led_dev.name = led->name;
133 led->led_dev.default_trigger = trigger; 133 led->led_dev.default_trigger = trigger;
134 led->led_dev.brightness_set = ath5k_led_brightness_set; 134 led->led_dev.brightness_set = ath5k_led_brightness_set;
135 135
136 err = led_classdev_register(sc->dev, &led->led_dev); 136 err = led_classdev_register(ah->dev, &led->led_dev);
137 if (err) { 137 if (err) {
138 ATH5K_WARN(sc, "could not register LED %s\n", name); 138 ATH5K_WARN(ah, "could not register LED %s\n", name);
139 led->sc = NULL; 139 led->ah = NULL;
140 } 140 }
141 return err; 141 return err;
142} 142}
@@ -144,30 +144,30 @@ ath5k_register_led(struct ath5k_softc *sc, struct ath5k_led *led,
144static void 144static void
145ath5k_unregister_led(struct ath5k_led *led) 145ath5k_unregister_led(struct ath5k_led *led)
146{ 146{
147 if (!led->sc) 147 if (!led->ah)
148 return; 148 return;
149 led_classdev_unregister(&led->led_dev); 149 led_classdev_unregister(&led->led_dev);
150 ath5k_led_off(led->sc); 150 ath5k_led_off(led->ah);
151 led->sc = NULL; 151 led->ah = NULL;
152} 152}
153 153
154void ath5k_unregister_leds(struct ath5k_softc *sc) 154void ath5k_unregister_leds(struct ath5k_hw *ah)
155{ 155{
156 ath5k_unregister_led(&sc->rx_led); 156 ath5k_unregister_led(&ah->rx_led);
157 ath5k_unregister_led(&sc->tx_led); 157 ath5k_unregister_led(&ah->tx_led);
158} 158}
159 159
160int __devinit ath5k_init_leds(struct ath5k_softc *sc) 160int __devinit ath5k_init_leds(struct ath5k_hw *ah)
161{ 161{
162 int ret = 0; 162 int ret = 0;
163 struct ieee80211_hw *hw = sc->hw; 163 struct ieee80211_hw *hw = ah->hw;
164#ifndef CONFIG_ATHEROS_AR231X 164#ifndef CONFIG_ATHEROS_AR231X
165 struct pci_dev *pdev = sc->pdev; 165 struct pci_dev *pdev = ah->pdev;
166#endif 166#endif
167 char name[ATH5K_LED_MAX_NAME_LEN + 1]; 167 char name[ATH5K_LED_MAX_NAME_LEN + 1];
168 const struct pci_device_id *match; 168 const struct pci_device_id *match;
169 169
170 if (!sc->pdev) 170 if (!ah->pdev)
171 return 0; 171 return 0;
172 172
173#ifdef CONFIG_ATHEROS_AR231X 173#ifdef CONFIG_ATHEROS_AR231X
@@ -176,24 +176,24 @@ int __devinit ath5k_init_leds(struct ath5k_softc *sc)
176 match = pci_match_id(&ath5k_led_devices[0], pdev); 176 match = pci_match_id(&ath5k_led_devices[0], pdev);
177#endif 177#endif
178 if (match) { 178 if (match) {
179 __set_bit(ATH_STAT_LEDSOFT, sc->status); 179 __set_bit(ATH_STAT_LEDSOFT, ah->status);
180 sc->led_pin = ATH_PIN(match->driver_data); 180 ah->led_pin = ATH_PIN(match->driver_data);
181 sc->led_on = ATH_POLARITY(match->driver_data); 181 ah->led_on = ATH_POLARITY(match->driver_data);
182 } 182 }
183 183
184 if (!test_bit(ATH_STAT_LEDSOFT, sc->status)) 184 if (!test_bit(ATH_STAT_LEDSOFT, ah->status))
185 goto out; 185 goto out;
186 186
187 ath5k_led_enable(sc); 187 ath5k_led_enable(ah);
188 188
189 snprintf(name, sizeof(name), "ath5k-%s::rx", wiphy_name(hw->wiphy)); 189 snprintf(name, sizeof(name), "ath5k-%s::rx", wiphy_name(hw->wiphy));
190 ret = ath5k_register_led(sc, &sc->rx_led, name, 190 ret = ath5k_register_led(ah, &ah->rx_led, name,
191 ieee80211_get_rx_led_name(hw)); 191 ieee80211_get_rx_led_name(hw));
192 if (ret) 192 if (ret)
193 goto out; 193 goto out;
194 194
195 snprintf(name, sizeof(name), "ath5k-%s::tx", wiphy_name(hw->wiphy)); 195 snprintf(name, sizeof(name), "ath5k-%s::tx", wiphy_name(hw->wiphy));
196 ret = ath5k_register_led(sc, &sc->tx_led, name, 196 ret = ath5k_register_led(ah, &ah->tx_led, name,
197 ieee80211_get_tx_led_name(hw)); 197 ieee80211_get_tx_led_name(hw));
198out: 198out:
199 return ret; 199 return ret;
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
index 0d5ab3428be5..2a715ca0c5e4 100644
--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
@@ -53,44 +53,30 @@
53static void 53static void
54ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 54ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
55{ 55{
56 struct ath5k_softc *sc = hw->priv; 56 struct ath5k_hw *ah = hw->priv;
57 u16 qnum = skb_get_queue_mapping(skb); 57 u16 qnum = skb_get_queue_mapping(skb);
58 58
59 if (WARN_ON(qnum >= sc->ah->ah_capabilities.cap_queues.q_tx_num)) { 59 if (WARN_ON(qnum >= ah->ah_capabilities.cap_queues.q_tx_num)) {
60 dev_kfree_skb_any(skb); 60 dev_kfree_skb_any(skb);
61 return; 61 return;
62 } 62 }
63 63
64 ath5k_tx_queue(hw, skb, &sc->txqs[qnum]); 64 ath5k_tx_queue(hw, skb, &ah->txqs[qnum]);
65}
66
67
68static int
69ath5k_start(struct ieee80211_hw *hw)
70{
71 return ath5k_init_hw(hw->priv);
72}
73
74
75static void
76ath5k_stop(struct ieee80211_hw *hw)
77{
78 ath5k_stop_hw(hw->priv);
79} 65}
80 66
81 67
82static int 68static int
83ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 69ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
84{ 70{
85 struct ath5k_softc *sc = hw->priv; 71 struct ath5k_hw *ah = hw->priv;
86 int ret; 72 int ret;
87 struct ath5k_vif *avf = (void *)vif->drv_priv; 73 struct ath5k_vif *avf = (void *)vif->drv_priv;
88 74
89 mutex_lock(&sc->lock); 75 mutex_lock(&ah->lock);
90 76
91 if ((vif->type == NL80211_IFTYPE_AP || 77 if ((vif->type == NL80211_IFTYPE_AP ||
92 vif->type == NL80211_IFTYPE_ADHOC) 78 vif->type == NL80211_IFTYPE_ADHOC)
93 && (sc->num_ap_vifs + sc->num_adhoc_vifs) >= ATH_BCBUF) { 79 && (ah->num_ap_vifs + ah->num_adhoc_vifs) >= ATH_BCBUF) {
94 ret = -ELNRNG; 80 ret = -ELNRNG;
95 goto end; 81 goto end;
96 } 82 }
@@ -100,9 +86,9 @@ ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
100 * We would need to operate the HW in ad-hoc mode to allow TSF updates 86 * We would need to operate the HW in ad-hoc mode to allow TSF updates
101 * for the IBSS, but this breaks with additional AP or STA interfaces 87 * for the IBSS, but this breaks with additional AP or STA interfaces
102 * at the moment. */ 88 * at the moment. */
103 if (sc->num_adhoc_vifs || 89 if (ah->num_adhoc_vifs ||
104 (sc->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) { 90 (ah->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
105 ATH5K_ERR(sc, "Only one single ad-hoc interface is allowed.\n"); 91 ATH5K_ERR(ah, "Only one single ad-hoc interface is allowed.\n");
106 ret = -ELNRNG; 92 ret = -ELNRNG;
107 goto end; 93 goto end;
108 } 94 }
@@ -119,8 +105,8 @@ ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
119 goto end; 105 goto end;
120 } 106 }
121 107
122 sc->nvifs++; 108 ah->nvifs++;
123 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "add interface mode %d\n", avf->opmode); 109 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "add interface mode %d\n", avf->opmode);
124 110
125 /* Assign the vap/adhoc to a beacon xmit slot. */ 111 /* Assign the vap/adhoc to a beacon xmit slot. */
126 if ((avf->opmode == NL80211_IFTYPE_AP) || 112 if ((avf->opmode == NL80211_IFTYPE_AP) ||
@@ -128,38 +114,38 @@ ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
128 (avf->opmode == NL80211_IFTYPE_MESH_POINT)) { 114 (avf->opmode == NL80211_IFTYPE_MESH_POINT)) {
129 int slot; 115 int slot;
130 116
131 WARN_ON(list_empty(&sc->bcbuf)); 117 WARN_ON(list_empty(&ah->bcbuf));
132 avf->bbuf = list_first_entry(&sc->bcbuf, struct ath5k_buf, 118 avf->bbuf = list_first_entry(&ah->bcbuf, struct ath5k_buf,
133 list); 119 list);
134 list_del(&avf->bbuf->list); 120 list_del(&avf->bbuf->list);
135 121
136 avf->bslot = 0; 122 avf->bslot = 0;
137 for (slot = 0; slot < ATH_BCBUF; slot++) { 123 for (slot = 0; slot < ATH_BCBUF; slot++) {
138 if (!sc->bslot[slot]) { 124 if (!ah->bslot[slot]) {
139 avf->bslot = slot; 125 avf->bslot = slot;
140 break; 126 break;
141 } 127 }
142 } 128 }
143 BUG_ON(sc->bslot[avf->bslot] != NULL); 129 BUG_ON(ah->bslot[avf->bslot] != NULL);
144 sc->bslot[avf->bslot] = vif; 130 ah->bslot[avf->bslot] = vif;
145 if (avf->opmode == NL80211_IFTYPE_AP) 131 if (avf->opmode == NL80211_IFTYPE_AP)
146 sc->num_ap_vifs++; 132 ah->num_ap_vifs++;
147 else if (avf->opmode == NL80211_IFTYPE_ADHOC) 133 else if (avf->opmode == NL80211_IFTYPE_ADHOC)
148 sc->num_adhoc_vifs++; 134 ah->num_adhoc_vifs++;
149 } 135 }
150 136
151 /* Any MAC address is fine, all others are included through the 137 /* Any MAC address is fine, all others are included through the
152 * filter. 138 * filter.
153 */ 139 */
154 memcpy(&sc->lladdr, vif->addr, ETH_ALEN); 140 memcpy(&ah->lladdr, vif->addr, ETH_ALEN);
155 ath5k_hw_set_lladdr(sc->ah, vif->addr); 141 ath5k_hw_set_lladdr(ah, vif->addr);
156 142
157 memcpy(&avf->lladdr, vif->addr, ETH_ALEN); 143 memcpy(&avf->lladdr, vif->addr, ETH_ALEN);
158 144
159 ath5k_update_bssid_mask_and_opmode(sc, vif); 145 ath5k_update_bssid_mask_and_opmode(ah, vif);
160 ret = 0; 146 ret = 0;
161end: 147end:
162 mutex_unlock(&sc->lock); 148 mutex_unlock(&ah->lock);
163 return ret; 149 return ret;
164} 150}
165 151
@@ -168,31 +154,31 @@ static void
168ath5k_remove_interface(struct ieee80211_hw *hw, 154ath5k_remove_interface(struct ieee80211_hw *hw,
169 struct ieee80211_vif *vif) 155 struct ieee80211_vif *vif)
170{ 156{
171 struct ath5k_softc *sc = hw->priv; 157 struct ath5k_hw *ah = hw->priv;
172 struct ath5k_vif *avf = (void *)vif->drv_priv; 158 struct ath5k_vif *avf = (void *)vif->drv_priv;
173 unsigned int i; 159 unsigned int i;
174 160
175 mutex_lock(&sc->lock); 161 mutex_lock(&ah->lock);
176 sc->nvifs--; 162 ah->nvifs--;
177 163
178 if (avf->bbuf) { 164 if (avf->bbuf) {
179 ath5k_txbuf_free_skb(sc, avf->bbuf); 165 ath5k_txbuf_free_skb(ah, avf->bbuf);
180 list_add_tail(&avf->bbuf->list, &sc->bcbuf); 166 list_add_tail(&avf->bbuf->list, &ah->bcbuf);
181 for (i = 0; i < ATH_BCBUF; i++) { 167 for (i = 0; i < ATH_BCBUF; i++) {
182 if (sc->bslot[i] == vif) { 168 if (ah->bslot[i] == vif) {
183 sc->bslot[i] = NULL; 169 ah->bslot[i] = NULL;
184 break; 170 break;
185 } 171 }
186 } 172 }
187 avf->bbuf = NULL; 173 avf->bbuf = NULL;
188 } 174 }
189 if (avf->opmode == NL80211_IFTYPE_AP) 175 if (avf->opmode == NL80211_IFTYPE_AP)
190 sc->num_ap_vifs--; 176 ah->num_ap_vifs--;
191 else if (avf->opmode == NL80211_IFTYPE_ADHOC) 177 else if (avf->opmode == NL80211_IFTYPE_ADHOC)
192 sc->num_adhoc_vifs--; 178 ah->num_adhoc_vifs--;
193 179
194 ath5k_update_bssid_mask_and_opmode(sc, NULL); 180 ath5k_update_bssid_mask_and_opmode(ah, NULL);
195 mutex_unlock(&sc->lock); 181 mutex_unlock(&ah->lock);
196} 182}
197 183
198 184
@@ -202,23 +188,22 @@ ath5k_remove_interface(struct ieee80211_hw *hw,
202static int 188static int
203ath5k_config(struct ieee80211_hw *hw, u32 changed) 189ath5k_config(struct ieee80211_hw *hw, u32 changed)
204{ 190{
205 struct ath5k_softc *sc = hw->priv; 191 struct ath5k_hw *ah = hw->priv;
206 struct ath5k_hw *ah = sc->ah;
207 struct ieee80211_conf *conf = &hw->conf; 192 struct ieee80211_conf *conf = &hw->conf;
208 int ret = 0; 193 int ret = 0;
209 int i; 194 int i;
210 195
211 mutex_lock(&sc->lock); 196 mutex_lock(&ah->lock);
212 197
213 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 198 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
214 ret = ath5k_chan_set(sc, conf->channel); 199 ret = ath5k_chan_set(ah, conf->channel);
215 if (ret < 0) 200 if (ret < 0)
216 goto unlock; 201 goto unlock;
217 } 202 }
218 203
219 if ((changed & IEEE80211_CONF_CHANGE_POWER) && 204 if ((changed & IEEE80211_CONF_CHANGE_POWER) &&
220 (sc->power_level != conf->power_level)) { 205 (ah->power_level != conf->power_level)) {
221 sc->power_level = conf->power_level; 206 ah->power_level = conf->power_level;
222 207
223 /* Half dB steps */ 208 /* Half dB steps */
224 ath5k_hw_set_txpower_limit(ah, (conf->power_level * 2)); 209 ath5k_hw_set_txpower_limit(ah, (conf->power_level * 2));
@@ -252,7 +237,7 @@ ath5k_config(struct ieee80211_hw *hw, u32 changed)
252 ath5k_hw_set_antenna_mode(ah, ah->ah_ant_mode); 237 ath5k_hw_set_antenna_mode(ah, ah->ah_ant_mode);
253 238
254unlock: 239unlock:
255 mutex_unlock(&sc->lock); 240 mutex_unlock(&ah->lock);
256 return ret; 241 return ret;
257} 242}
258 243
@@ -262,12 +247,11 @@ ath5k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
262 struct ieee80211_bss_conf *bss_conf, u32 changes) 247 struct ieee80211_bss_conf *bss_conf, u32 changes)
263{ 248{
264 struct ath5k_vif *avf = (void *)vif->drv_priv; 249 struct ath5k_vif *avf = (void *)vif->drv_priv;
265 struct ath5k_softc *sc = hw->priv; 250 struct ath5k_hw *ah = hw->priv;
266 struct ath5k_hw *ah = sc->ah;
267 struct ath_common *common = ath5k_hw_common(ah); 251 struct ath_common *common = ath5k_hw_common(ah);
268 unsigned long flags; 252 unsigned long flags;
269 253
270 mutex_lock(&sc->lock); 254 mutex_lock(&ah->lock);
271 255
272 if (changes & BSS_CHANGED_BSSID) { 256 if (changes & BSS_CHANGED_BSSID) {
273 /* Cache for later use during resets */ 257 /* Cache for later use during resets */
@@ -278,7 +262,7 @@ ath5k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
278 } 262 }
279 263
280 if (changes & BSS_CHANGED_BEACON_INT) 264 if (changes & BSS_CHANGED_BEACON_INT)
281 sc->bintval = bss_conf->beacon_int; 265 ah->bintval = bss_conf->beacon_int;
282 266
283 if (changes & BSS_CHANGED_ERP_SLOT) { 267 if (changes & BSS_CHANGED_ERP_SLOT) {
284 int slot_time; 268 int slot_time;
@@ -292,16 +276,16 @@ ath5k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
292 if (changes & BSS_CHANGED_ASSOC) { 276 if (changes & BSS_CHANGED_ASSOC) {
293 avf->assoc = bss_conf->assoc; 277 avf->assoc = bss_conf->assoc;
294 if (bss_conf->assoc) 278 if (bss_conf->assoc)
295 sc->assoc = bss_conf->assoc; 279 ah->assoc = bss_conf->assoc;
296 else 280 else
297 sc->assoc = ath5k_any_vif_assoc(sc); 281 ah->assoc = ath5k_any_vif_assoc(ah);
298 282
299 if (sc->opmode == NL80211_IFTYPE_STATION) 283 if (ah->opmode == NL80211_IFTYPE_STATION)
300 ath5k_set_beacon_filter(hw, sc->assoc); 284 ath5k_set_beacon_filter(hw, ah->assoc);
301 ath5k_hw_set_ledstate(sc->ah, sc->assoc ? 285 ath5k_hw_set_ledstate(ah, ah->assoc ?
302 AR5K_LED_ASSOC : AR5K_LED_INIT); 286 AR5K_LED_ASSOC : AR5K_LED_INIT);
303 if (bss_conf->assoc) { 287 if (bss_conf->assoc) {
304 ATH5K_DBG(sc, ATH5K_DEBUG_ANY, 288 ATH5K_DBG(ah, ATH5K_DEBUG_ANY,
305 "Bss Info ASSOC %d, bssid: %pM\n", 289 "Bss Info ASSOC %d, bssid: %pM\n",
306 bss_conf->aid, common->curbssid); 290 bss_conf->aid, common->curbssid);
307 common->curaid = bss_conf->aid; 291 common->curaid = bss_conf->aid;
@@ -311,19 +295,19 @@ ath5k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
311 } 295 }
312 296
313 if (changes & BSS_CHANGED_BEACON) { 297 if (changes & BSS_CHANGED_BEACON) {
314 spin_lock_irqsave(&sc->block, flags); 298 spin_lock_irqsave(&ah->block, flags);
315 ath5k_beacon_update(hw, vif); 299 ath5k_beacon_update(hw, vif);
316 spin_unlock_irqrestore(&sc->block, flags); 300 spin_unlock_irqrestore(&ah->block, flags);
317 } 301 }
318 302
319 if (changes & BSS_CHANGED_BEACON_ENABLED) 303 if (changes & BSS_CHANGED_BEACON_ENABLED)
320 sc->enable_beacon = bss_conf->enable_beacon; 304 ah->enable_beacon = bss_conf->enable_beacon;
321 305
322 if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED | 306 if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED |
323 BSS_CHANGED_BEACON_INT)) 307 BSS_CHANGED_BEACON_INT))
324 ath5k_beacon_config(sc); 308 ath5k_beacon_config(ah);
325 309
326 mutex_unlock(&sc->lock); 310 mutex_unlock(&ah->lock);
327} 311}
328 312
329 313
@@ -384,12 +368,11 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
384 FIF_PLCPFAIL | FIF_CONTROL | FIF_OTHER_BSS | \ 368 FIF_PLCPFAIL | FIF_CONTROL | FIF_OTHER_BSS | \
385 FIF_BCN_PRBRESP_PROMISC) 369 FIF_BCN_PRBRESP_PROMISC)
386 370
387 struct ath5k_softc *sc = hw->priv; 371 struct ath5k_hw *ah = hw->priv;
388 struct ath5k_hw *ah = sc->ah;
389 u32 mfilt[2], rfilt; 372 u32 mfilt[2], rfilt;
390 struct ath5k_vif_iter_data iter_data; /* to count STA interfaces */ 373 struct ath5k_vif_iter_data iter_data; /* to count STA interfaces */
391 374
392 mutex_lock(&sc->lock); 375 mutex_lock(&ah->lock);
393 376
394 mfilt[0] = multicast; 377 mfilt[0] = multicast;
395 mfilt[1] = multicast >> 32; 378 mfilt[1] = multicast >> 32;
@@ -407,12 +390,12 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
407 390
408 if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) { 391 if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) {
409 if (*new_flags & FIF_PROMISC_IN_BSS) 392 if (*new_flags & FIF_PROMISC_IN_BSS)
410 __set_bit(ATH_STAT_PROMISC, sc->status); 393 __set_bit(ATH_STAT_PROMISC, ah->status);
411 else 394 else
412 __clear_bit(ATH_STAT_PROMISC, sc->status); 395 __clear_bit(ATH_STAT_PROMISC, ah->status);
413 } 396 }
414 397
415 if (test_bit(ATH_STAT_PROMISC, sc->status)) 398 if (test_bit(ATH_STAT_PROMISC, ah->status))
416 rfilt |= AR5K_RX_FILTER_PROM; 399 rfilt |= AR5K_RX_FILTER_PROM;
417 400
418 /* Note, AR5K_RX_FILTER_MCAST is already enabled */ 401 /* Note, AR5K_RX_FILTER_MCAST is already enabled */
@@ -427,7 +410,7 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
427 410
428 /* FIF_BCN_PRBRESP_PROMISC really means to enable beacons 411 /* FIF_BCN_PRBRESP_PROMISC really means to enable beacons
429 * and probes for any BSSID */ 412 * and probes for any BSSID */
430 if ((*new_flags & FIF_BCN_PRBRESP_PROMISC) || (sc->nvifs > 1)) 413 if ((*new_flags & FIF_BCN_PRBRESP_PROMISC) || (ah->nvifs > 1))
431 rfilt |= AR5K_RX_FILTER_BEACON; 414 rfilt |= AR5K_RX_FILTER_BEACON;
432 415
433 /* FIF_CONTROL doc says that if FIF_PROMISC_IN_BSS is not 416 /* FIF_CONTROL doc says that if FIF_PROMISC_IN_BSS is not
@@ -442,7 +425,7 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
442 425
443 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */ 426 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */
444 427
445 switch (sc->opmode) { 428 switch (ah->opmode) {
446 case NL80211_IFTYPE_MESH_POINT: 429 case NL80211_IFTYPE_MESH_POINT:
447 rfilt |= AR5K_RX_FILTER_CONTROL | 430 rfilt |= AR5K_RX_FILTER_CONTROL |
448 AR5K_RX_FILTER_BEACON | 431 AR5K_RX_FILTER_BEACON |
@@ -455,7 +438,7 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
455 AR5K_RX_FILTER_BEACON; 438 AR5K_RX_FILTER_BEACON;
456 break; 439 break;
457 case NL80211_IFTYPE_STATION: 440 case NL80211_IFTYPE_STATION:
458 if (sc->assoc) 441 if (ah->assoc)
459 rfilt |= AR5K_RX_FILTER_BEACON; 442 rfilt |= AR5K_RX_FILTER_BEACON;
460 default: 443 default:
461 break; 444 break;
@@ -464,7 +447,7 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
464 iter_data.hw_macaddr = NULL; 447 iter_data.hw_macaddr = NULL;
465 iter_data.n_stas = 0; 448 iter_data.n_stas = 0;
466 iter_data.need_set_hw_addr = false; 449 iter_data.need_set_hw_addr = false;
467 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath5k_vif_iter, 450 ieee80211_iterate_active_interfaces_atomic(ah->hw, ath5k_vif_iter,
468 &iter_data); 451 &iter_data);
469 452
470 /* Set up RX Filter */ 453 /* Set up RX Filter */
@@ -483,9 +466,9 @@ ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
483 ath5k_hw_set_mcast_filter(ah, mfilt[0], mfilt[1]); 466 ath5k_hw_set_mcast_filter(ah, mfilt[0], mfilt[1]);
484 /* Set the cached hw filter flags, this will later actually 467 /* Set the cached hw filter flags, this will later actually
485 * be set in HW */ 468 * be set in HW */
486 sc->filter_flags = rfilt; 469 ah->filter_flags = rfilt;
487 470
488 mutex_unlock(&sc->lock); 471 mutex_unlock(&ah->lock);
489} 472}
490 473
491 474
@@ -494,8 +477,7 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
494 struct ieee80211_vif *vif, struct ieee80211_sta *sta, 477 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
495 struct ieee80211_key_conf *key) 478 struct ieee80211_key_conf *key)
496{ 479{
497 struct ath5k_softc *sc = hw->priv; 480 struct ath5k_hw *ah = hw->priv;
498 struct ath5k_hw *ah = sc->ah;
499 struct ath_common *common = ath5k_hw_common(ah); 481 struct ath_common *common = ath5k_hw_common(ah);
500 int ret = 0; 482 int ret = 0;
501 483
@@ -516,7 +498,7 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
516 return -EINVAL; 498 return -EINVAL;
517 } 499 }
518 500
519 mutex_lock(&sc->lock); 501 mutex_lock(&ah->lock);
520 502
521 switch (cmd) { 503 switch (cmd) {
522 case SET_KEY: 504 case SET_KEY:
@@ -540,7 +522,7 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
540 } 522 }
541 523
542 mmiowb(); 524 mmiowb();
543 mutex_unlock(&sc->lock); 525 mutex_unlock(&ah->lock);
544 return ret; 526 return ret;
545} 527}
546 528
@@ -548,17 +530,17 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
548static void 530static void
549ath5k_sw_scan_start(struct ieee80211_hw *hw) 531ath5k_sw_scan_start(struct ieee80211_hw *hw)
550{ 532{
551 struct ath5k_softc *sc = hw->priv; 533 struct ath5k_hw *ah = hw->priv;
552 if (!sc->assoc) 534 if (!ah->assoc)
553 ath5k_hw_set_ledstate(sc->ah, AR5K_LED_SCAN); 535 ath5k_hw_set_ledstate(ah, AR5K_LED_SCAN);
554} 536}
555 537
556 538
557static void 539static void
558ath5k_sw_scan_complete(struct ieee80211_hw *hw) 540ath5k_sw_scan_complete(struct ieee80211_hw *hw)
559{ 541{
560 struct ath5k_softc *sc = hw->priv; 542 struct ath5k_hw *ah = hw->priv;
561 ath5k_hw_set_ledstate(sc->ah, sc->assoc ? 543 ath5k_hw_set_ledstate(ah, ah->assoc ?
562 AR5K_LED_ASSOC : AR5K_LED_INIT); 544 AR5K_LED_ASSOC : AR5K_LED_INIT);
563} 545}
564 546
@@ -567,15 +549,15 @@ static int
567ath5k_get_stats(struct ieee80211_hw *hw, 549ath5k_get_stats(struct ieee80211_hw *hw,
568 struct ieee80211_low_level_stats *stats) 550 struct ieee80211_low_level_stats *stats)
569{ 551{
570 struct ath5k_softc *sc = hw->priv; 552 struct ath5k_hw *ah = hw->priv;
571 553
572 /* Force update */ 554 /* Force update */
573 ath5k_hw_update_mib_counters(sc->ah); 555 ath5k_hw_update_mib_counters(ah);
574 556
575 stats->dot11ACKFailureCount = sc->stats.ack_fail; 557 stats->dot11ACKFailureCount = ah->stats.ack_fail;
576 stats->dot11RTSFailureCount = sc->stats.rts_fail; 558 stats->dot11RTSFailureCount = ah->stats.rts_fail;
577 stats->dot11RTSSuccessCount = sc->stats.rts_ok; 559 stats->dot11RTSSuccessCount = ah->stats.rts_ok;
578 stats->dot11FCSErrorCount = sc->stats.fcs_error; 560 stats->dot11FCSErrorCount = ah->stats.fcs_error;
579 561
580 return 0; 562 return 0;
581} 563}
@@ -585,15 +567,14 @@ static int
585ath5k_conf_tx(struct ieee80211_hw *hw, u16 queue, 567ath5k_conf_tx(struct ieee80211_hw *hw, u16 queue,
586 const struct ieee80211_tx_queue_params *params) 568 const struct ieee80211_tx_queue_params *params)
587{ 569{
588 struct ath5k_softc *sc = hw->priv; 570 struct ath5k_hw *ah = hw->priv;
589 struct ath5k_hw *ah = sc->ah;
590 struct ath5k_txq_info qi; 571 struct ath5k_txq_info qi;
591 int ret = 0; 572 int ret = 0;
592 573
593 if (queue >= ah->ah_capabilities.cap_queues.q_tx_num) 574 if (queue >= ah->ah_capabilities.cap_queues.q_tx_num)
594 return 0; 575 return 0;
595 576
596 mutex_lock(&sc->lock); 577 mutex_lock(&ah->lock);
597 578
598 ath5k_hw_get_tx_queueprops(ah, queue, &qi); 579 ath5k_hw_get_tx_queueprops(ah, queue, &qi);
599 580
@@ -602,20 +583,20 @@ ath5k_conf_tx(struct ieee80211_hw *hw, u16 queue,
602 qi.tqi_cw_max = params->cw_max; 583 qi.tqi_cw_max = params->cw_max;
603 qi.tqi_burst_time = params->txop; 584 qi.tqi_burst_time = params->txop;
604 585
605 ATH5K_DBG(sc, ATH5K_DEBUG_ANY, 586 ATH5K_DBG(ah, ATH5K_DEBUG_ANY,
606 "Configure tx [queue %d], " 587 "Configure tx [queue %d], "
607 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n", 588 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
608 queue, params->aifs, params->cw_min, 589 queue, params->aifs, params->cw_min,
609 params->cw_max, params->txop); 590 params->cw_max, params->txop);
610 591
611 if (ath5k_hw_set_tx_queueprops(ah, queue, &qi)) { 592 if (ath5k_hw_set_tx_queueprops(ah, queue, &qi)) {
612 ATH5K_ERR(sc, 593 ATH5K_ERR(ah,
613 "Unable to update hardware queue %u!\n", queue); 594 "Unable to update hardware queue %u!\n", queue);
614 ret = -EIO; 595 ret = -EIO;
615 } else 596 } else
616 ath5k_hw_reset_tx_queue(ah, queue); 597 ath5k_hw_reset_tx_queue(ah, queue);
617 598
618 mutex_unlock(&sc->lock); 599 mutex_unlock(&ah->lock);
619 600
620 return ret; 601 return ret;
621} 602}
@@ -624,43 +605,43 @@ ath5k_conf_tx(struct ieee80211_hw *hw, u16 queue,
624static u64 605static u64
625ath5k_get_tsf(struct ieee80211_hw *hw) 606ath5k_get_tsf(struct ieee80211_hw *hw)
626{ 607{
627 struct ath5k_softc *sc = hw->priv; 608 struct ath5k_hw *ah = hw->priv;
628 609
629 return ath5k_hw_get_tsf64(sc->ah); 610 return ath5k_hw_get_tsf64(ah);
630} 611}
631 612
632 613
633static void 614static void
634ath5k_set_tsf(struct ieee80211_hw *hw, u64 tsf) 615ath5k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
635{ 616{
636 struct ath5k_softc *sc = hw->priv; 617 struct ath5k_hw *ah = hw->priv;
637 618
638 ath5k_hw_set_tsf64(sc->ah, tsf); 619 ath5k_hw_set_tsf64(ah, tsf);
639} 620}
640 621
641 622
642static void 623static void
643ath5k_reset_tsf(struct ieee80211_hw *hw) 624ath5k_reset_tsf(struct ieee80211_hw *hw)
644{ 625{
645 struct ath5k_softc *sc = hw->priv; 626 struct ath5k_hw *ah = hw->priv;
646 627
647 /* 628 /*
648 * in IBSS mode we need to update the beacon timers too. 629 * in IBSS mode we need to update the beacon timers too.
649 * this will also reset the TSF if we call it with 0 630 * this will also reset the TSF if we call it with 0
650 */ 631 */
651 if (sc->opmode == NL80211_IFTYPE_ADHOC) 632 if (ah->opmode == NL80211_IFTYPE_ADHOC)
652 ath5k_beacon_update_timers(sc, 0); 633 ath5k_beacon_update_timers(ah, 0);
653 else 634 else
654 ath5k_hw_reset_tsf(sc->ah); 635 ath5k_hw_reset_tsf(ah);
655} 636}
656 637
657 638
658static int 639static int
659ath5k_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey) 640ath5k_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey)
660{ 641{
661 struct ath5k_softc *sc = hw->priv; 642 struct ath5k_hw *ah = hw->priv;
662 struct ieee80211_conf *conf = &hw->conf; 643 struct ieee80211_conf *conf = &hw->conf;
663 struct ath_common *common = ath5k_hw_common(sc->ah); 644 struct ath_common *common = ath5k_hw_common(ah);
664 struct ath_cycle_counters *cc = &common->cc_survey; 645 struct ath_cycle_counters *cc = &common->cc_survey;
665 unsigned int div = common->clockrate * 1000; 646 unsigned int div = common->clockrate * 1000;
666 647
@@ -670,18 +651,18 @@ ath5k_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey)
670 spin_lock_bh(&common->cc_lock); 651 spin_lock_bh(&common->cc_lock);
671 ath_hw_cycle_counters_update(common); 652 ath_hw_cycle_counters_update(common);
672 if (cc->cycles > 0) { 653 if (cc->cycles > 0) {
673 sc->survey.channel_time += cc->cycles / div; 654 ah->survey.channel_time += cc->cycles / div;
674 sc->survey.channel_time_busy += cc->rx_busy / div; 655 ah->survey.channel_time_busy += cc->rx_busy / div;
675 sc->survey.channel_time_rx += cc->rx_frame / div; 656 ah->survey.channel_time_rx += cc->rx_frame / div;
676 sc->survey.channel_time_tx += cc->tx_frame / div; 657 ah->survey.channel_time_tx += cc->tx_frame / div;
677 } 658 }
678 memset(cc, 0, sizeof(*cc)); 659 memset(cc, 0, sizeof(*cc));
679 spin_unlock_bh(&common->cc_lock); 660 spin_unlock_bh(&common->cc_lock);
680 661
681 memcpy(survey, &sc->survey, sizeof(*survey)); 662 memcpy(survey, &ah->survey, sizeof(*survey));
682 663
683 survey->channel = conf->channel; 664 survey->channel = conf->channel;
684 survey->noise = sc->ah->ah_noise_floor; 665 survey->noise = ah->ah_noise_floor;
685 survey->filled = SURVEY_INFO_NOISE_DBM | 666 survey->filled = SURVEY_INFO_NOISE_DBM |
686 SURVEY_INFO_CHANNEL_TIME | 667 SURVEY_INFO_CHANNEL_TIME |
687 SURVEY_INFO_CHANNEL_TIME_BUSY | 668 SURVEY_INFO_CHANNEL_TIME_BUSY |
@@ -705,25 +686,25 @@ ath5k_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey)
705static void 686static void
706ath5k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) 687ath5k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
707{ 688{
708 struct ath5k_softc *sc = hw->priv; 689 struct ath5k_hw *ah = hw->priv;
709 690
710 mutex_lock(&sc->lock); 691 mutex_lock(&ah->lock);
711 ath5k_hw_set_coverage_class(sc->ah, coverage_class); 692 ath5k_hw_set_coverage_class(ah, coverage_class);
712 mutex_unlock(&sc->lock); 693 mutex_unlock(&ah->lock);
713} 694}
714 695
715 696
716static int 697static int
717ath5k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) 698ath5k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
718{ 699{
719 struct ath5k_softc *sc = hw->priv; 700 struct ath5k_hw *ah = hw->priv;
720 701
721 if (tx_ant == 1 && rx_ant == 1) 702 if (tx_ant == 1 && rx_ant == 1)
722 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A); 703 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_A);
723 else if (tx_ant == 2 && rx_ant == 2) 704 else if (tx_ant == 2 && rx_ant == 2)
724 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B); 705 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_B);
725 else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3) 706 else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3)
726 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT); 707 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
727 else 708 else
728 return -EINVAL; 709 return -EINVAL;
729 return 0; 710 return 0;
@@ -733,9 +714,9 @@ ath5k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
733static int 714static int
734ath5k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) 715ath5k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
735{ 716{
736 struct ath5k_softc *sc = hw->priv; 717 struct ath5k_hw *ah = hw->priv;
737 718
738 switch (sc->ah->ah_ant_mode) { 719 switch (ah->ah_ant_mode) {
739 case AR5K_ANTMODE_FIXED_A: 720 case AR5K_ANTMODE_FIXED_A:
740 *tx_ant = 1; *rx_ant = 1; break; 721 *tx_ant = 1; *rx_ant = 1; break;
741 case AR5K_ANTMODE_FIXED_B: 722 case AR5K_ANTMODE_FIXED_B:
@@ -750,9 +731,9 @@ ath5k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
750static void ath5k_get_ringparam(struct ieee80211_hw *hw, 731static void ath5k_get_ringparam(struct ieee80211_hw *hw,
751 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) 732 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
752{ 733{
753 struct ath5k_softc *sc = hw->priv; 734 struct ath5k_hw *ah = hw->priv;
754 735
755 *tx = sc->txqs[AR5K_TX_QUEUE_ID_DATA_MIN].txq_max; 736 *tx = ah->txqs[AR5K_TX_QUEUE_ID_DATA_MIN].txq_max;
756 737
757 *tx_max = ATH5K_TXQ_LEN_MAX; 738 *tx_max = ATH5K_TXQ_LEN_MAX;
758 *rx = *rx_max = ATH_RXBUF; 739 *rx = *rx_max = ATH_RXBUF;
@@ -761,7 +742,7 @@ static void ath5k_get_ringparam(struct ieee80211_hw *hw,
761 742
762static int ath5k_set_ringparam(struct ieee80211_hw *hw, u32 tx, u32 rx) 743static int ath5k_set_ringparam(struct ieee80211_hw *hw, u32 tx, u32 rx)
763{ 744{
764 struct ath5k_softc *sc = hw->priv; 745 struct ath5k_hw *ah = hw->priv;
765 u16 qnum; 746 u16 qnum;
766 747
767 /* only support setting tx ring size for now */ 748 /* only support setting tx ring size for now */
@@ -772,16 +753,16 @@ static int ath5k_set_ringparam(struct ieee80211_hw *hw, u32 tx, u32 rx)
772 if (!tx || tx > ATH5K_TXQ_LEN_MAX) 753 if (!tx || tx > ATH5K_TXQ_LEN_MAX)
773 return -EINVAL; 754 return -EINVAL;
774 755
775 for (qnum = 0; qnum < ARRAY_SIZE(sc->txqs); qnum++) { 756 for (qnum = 0; qnum < ARRAY_SIZE(ah->txqs); qnum++) {
776 if (!sc->txqs[qnum].setup) 757 if (!ah->txqs[qnum].setup)
777 continue; 758 continue;
778 if (sc->txqs[qnum].qnum < AR5K_TX_QUEUE_ID_DATA_MIN || 759 if (ah->txqs[qnum].qnum < AR5K_TX_QUEUE_ID_DATA_MIN ||
779 sc->txqs[qnum].qnum > AR5K_TX_QUEUE_ID_DATA_MAX) 760 ah->txqs[qnum].qnum > AR5K_TX_QUEUE_ID_DATA_MAX)
780 continue; 761 continue;
781 762
782 sc->txqs[qnum].txq_max = tx; 763 ah->txqs[qnum].txq_max = tx;
783 if (sc->txqs[qnum].txq_len >= sc->txqs[qnum].txq_max) 764 if (ah->txqs[qnum].txq_len >= ah->txqs[qnum].txq_max)
784 ieee80211_stop_queue(hw, sc->txqs[qnum].qnum); 765 ieee80211_stop_queue(hw, ah->txqs[qnum].qnum);
785 } 766 }
786 767
787 return 0; 768 return 0;
diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c
index aac5b7831948..eaf79b49341e 100644
--- a/drivers/net/wireless/ath/ath5k/pci.c
+++ b/drivers/net/wireless/ath/ath5k/pci.c
@@ -51,10 +51,10 @@ MODULE_DEVICE_TABLE(pci, ath5k_pci_id_table);
51/* return bus cachesize in 4B word units */ 51/* return bus cachesize in 4B word units */
52static void ath5k_pci_read_cachesize(struct ath_common *common, int *csz) 52static void ath5k_pci_read_cachesize(struct ath_common *common, int *csz)
53{ 53{
54 struct ath5k_softc *sc = (struct ath5k_softc *) common->priv; 54 struct ath5k_hw *ah = (struct ath5k_hw *) common->priv;
55 u8 u8tmp; 55 u8 u8tmp;
56 56
57 pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, &u8tmp); 57 pci_read_config_byte(ah->pdev, PCI_CACHE_LINE_SIZE, &u8tmp);
58 *csz = (int)u8tmp; 58 *csz = (int)u8tmp;
59 59
60 /* 60 /*
@@ -156,7 +156,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
156 const struct pci_device_id *id) 156 const struct pci_device_id *id)
157{ 157{
158 void __iomem *mem; 158 void __iomem *mem;
159 struct ath5k_softc *sc; 159 struct ath5k_hw *ah;
160 struct ieee80211_hw *hw; 160 struct ieee80211_hw *hw;
161 int ret; 161 int ret;
162 u8 csz; 162 u8 csz;
@@ -243,7 +243,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
243 * Allocate hw (mac80211 main struct) 243 * Allocate hw (mac80211 main struct)
244 * and hw->priv (driver private data) 244 * and hw->priv (driver private data)
245 */ 245 */
246 hw = ieee80211_alloc_hw(sizeof(*sc), &ath5k_hw_ops); 246 hw = ieee80211_alloc_hw(sizeof(*ah), &ath5k_hw_ops);
247 if (hw == NULL) { 247 if (hw == NULL) {
248 dev_err(&pdev->dev, "cannot allocate ieee80211_hw\n"); 248 dev_err(&pdev->dev, "cannot allocate ieee80211_hw\n");
249 ret = -ENOMEM; 249 ret = -ENOMEM;
@@ -252,16 +252,16 @@ ath5k_pci_probe(struct pci_dev *pdev,
252 252
253 dev_info(&pdev->dev, "registered as '%s'\n", wiphy_name(hw->wiphy)); 253 dev_info(&pdev->dev, "registered as '%s'\n", wiphy_name(hw->wiphy));
254 254
255 sc = hw->priv; 255 ah = hw->priv;
256 sc->hw = hw; 256 ah->hw = hw;
257 sc->pdev = pdev; 257 ah->pdev = pdev;
258 sc->dev = &pdev->dev; 258 ah->dev = &pdev->dev;
259 sc->irq = pdev->irq; 259 ah->irq = pdev->irq;
260 sc->devid = id->device; 260 ah->devid = id->device;
261 sc->iobase = mem; /* So we can unmap it on detach */ 261 ah->iobase = mem; /* So we can unmap it on detach */
262 262
263 /* Initialize */ 263 /* Initialize */
264 ret = ath5k_init_softc(sc, &ath_pci_bus_ops); 264 ret = ath5k_init_softc(ah, &ath_pci_bus_ops);
265 if (ret) 265 if (ret)
266 goto err_free; 266 goto err_free;
267 267
@@ -285,10 +285,10 @@ static void __devexit
285ath5k_pci_remove(struct pci_dev *pdev) 285ath5k_pci_remove(struct pci_dev *pdev)
286{ 286{
287 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 287 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
288 struct ath5k_softc *sc = hw->priv; 288 struct ath5k_hw *ah = hw->priv;
289 289
290 ath5k_deinit_softc(sc); 290 ath5k_deinit_softc(ah);
291 pci_iounmap(pdev, sc->iobase); 291 pci_iounmap(pdev, ah->iobase);
292 pci_release_region(pdev, 0); 292 pci_release_region(pdev, 0);
293 pci_disable_device(pdev); 293 pci_disable_device(pdev);
294 ieee80211_free_hw(hw); 294 ieee80211_free_hw(hw);
@@ -299,9 +299,9 @@ static int ath5k_pci_suspend(struct device *dev)
299{ 299{
300 struct pci_dev *pdev = to_pci_dev(dev); 300 struct pci_dev *pdev = to_pci_dev(dev);
301 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 301 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
302 struct ath5k_softc *sc = hw->priv; 302 struct ath5k_hw *ah = hw->priv;
303 303
304 ath5k_led_off(sc); 304 ath5k_led_off(ah);
305 return 0; 305 return 0;
306} 306}
307 307
@@ -309,7 +309,7 @@ static int ath5k_pci_resume(struct device *dev)
309{ 309{
310 struct pci_dev *pdev = to_pci_dev(dev); 310 struct pci_dev *pdev = to_pci_dev(dev);
311 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 311 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
312 struct ath5k_softc *sc = hw->priv; 312 struct ath5k_hw *ah = hw->priv;
313 313
314 /* 314 /*
315 * Suspend/Resume resets the PCI configuration space, so we have to 315 * Suspend/Resume resets the PCI configuration space, so we have to
@@ -318,7 +318,7 @@ static int ath5k_pci_resume(struct device *dev)
318 */ 318 */
319 pci_write_config_byte(pdev, 0x41, 0); 319 pci_write_config_byte(pdev, 0x41, 0);
320 320
321 ath5k_led_enable(sc); 321 ath5k_led_enable(ah);
322 return 0; 322 return 0;
323} 323}
324 324
diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c
index 618ee54d5fe5..067313845060 100644
--- a/drivers/net/wireless/ath/ath5k/pcu.c
+++ b/drivers/net/wireless/ath/ath5k/pcu.c
@@ -77,14 +77,13 @@ static const unsigned int ack_rates_high[] =
77int ath5k_hw_get_frame_duration(struct ath5k_hw *ah, 77int ath5k_hw_get_frame_duration(struct ath5k_hw *ah,
78 int len, struct ieee80211_rate *rate, bool shortpre) 78 int len, struct ieee80211_rate *rate, bool shortpre)
79{ 79{
80 struct ath5k_softc *sc = ah->ah_sc;
81 int sifs, preamble, plcp_bits, sym_time; 80 int sifs, preamble, plcp_bits, sym_time;
82 int bitrate, bits, symbols, symbol_bits; 81 int bitrate, bits, symbols, symbol_bits;
83 int dur; 82 int dur;
84 83
85 /* Fallback */ 84 /* Fallback */
86 if (!ah->ah_bwmode) { 85 if (!ah->ah_bwmode) {
87 __le16 raw_dur = ieee80211_generic_frame_duration(sc->hw, 86 __le16 raw_dur = ieee80211_generic_frame_duration(ah->hw,
88 NULL, len, rate); 87 NULL, len, rate);
89 88
90 /* subtract difference between long and short preamble */ 89 /* subtract difference between long and short preamble */
@@ -205,7 +204,7 @@ unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah)
205 */ 204 */
206void ath5k_hw_update_mib_counters(struct ath5k_hw *ah) 205void ath5k_hw_update_mib_counters(struct ath5k_hw *ah)
207{ 206{
208 struct ath5k_statistics *stats = &ah->ah_sc->stats; 207 struct ath5k_statistics *stats = &ah->stats;
209 208
210 /* Read-And-Clear */ 209 /* Read-And-Clear */
211 stats->ack_fail += ath5k_hw_reg_read(ah, AR5K_ACK_FAIL); 210 stats->ack_fail += ath5k_hw_reg_read(ah, AR5K_ACK_FAIL);
@@ -240,25 +239,24 @@ void ath5k_hw_update_mib_counters(struct ath5k_hw *ah)
240 */ 239 */
241static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah) 240static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah)
242{ 241{
243 struct ath5k_softc *sc = ah->ah_sc;
244 struct ieee80211_rate *rate; 242 struct ieee80211_rate *rate;
245 unsigned int i; 243 unsigned int i;
246 /* 802.11g covers both OFDM and CCK */ 244 /* 802.11g covers both OFDM and CCK */
247 u8 band = IEEE80211_BAND_2GHZ; 245 u8 band = IEEE80211_BAND_2GHZ;
248 246
249 /* Write rate duration table */ 247 /* Write rate duration table */
250 for (i = 0; i < sc->sbands[band].n_bitrates; i++) { 248 for (i = 0; i < ah->sbands[band].n_bitrates; i++) {
251 u32 reg; 249 u32 reg;
252 u16 tx_time; 250 u16 tx_time;
253 251
254 if (ah->ah_ack_bitrate_high) 252 if (ah->ah_ack_bitrate_high)
255 rate = &sc->sbands[band].bitrates[ack_rates_high[i]]; 253 rate = &ah->sbands[band].bitrates[ack_rates_high[i]];
256 /* CCK -> 1Mb */ 254 /* CCK -> 1Mb */
257 else if (i < 4) 255 else if (i < 4)
258 rate = &sc->sbands[band].bitrates[0]; 256 rate = &ah->sbands[band].bitrates[0];
259 /* OFDM -> 6Mb */ 257 /* OFDM -> 6Mb */
260 else 258 else
261 rate = &sc->sbands[band].bitrates[4]; 259 rate = &ah->sbands[band].bitrates[4];
262 260
263 /* Set ACK timeout */ 261 /* Set ACK timeout */
264 reg = AR5K_RATE_DUR(rate->hw_value); 262 reg = AR5K_RATE_DUR(rate->hw_value);
@@ -586,7 +584,7 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
586 /* 584 /*
587 * Set the additional timers by mode 585 * Set the additional timers by mode
588 */ 586 */
589 switch (ah->ah_sc->opmode) { 587 switch (ah->opmode) {
590 case NL80211_IFTYPE_MONITOR: 588 case NL80211_IFTYPE_MONITOR:
591 case NL80211_IFTYPE_STATION: 589 case NL80211_IFTYPE_STATION:
592 /* In STA mode timer1 is used as next wakeup 590 /* In STA mode timer1 is used as next wakeup
@@ -623,8 +621,8 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
623 * Set the beacon register and enable all timers. 621 * Set the beacon register and enable all timers.
624 */ 622 */
625 /* When in AP or Mesh Point mode zero timer0 to start TSF */ 623 /* When in AP or Mesh Point mode zero timer0 to start TSF */
626 if (ah->ah_sc->opmode == NL80211_IFTYPE_AP || 624 if (ah->opmode == NL80211_IFTYPE_AP ||
627 ah->ah_sc->opmode == NL80211_IFTYPE_MESH_POINT) 625 ah->opmode == NL80211_IFTYPE_MESH_POINT)
628 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0); 626 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
629 627
630 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0); 628 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
@@ -814,7 +812,7 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode)
814 struct ath_common *common = ath5k_hw_common(ah); 812 struct ath_common *common = ath5k_hw_common(ah);
815 u32 pcu_reg, beacon_reg, low_id, high_id; 813 u32 pcu_reg, beacon_reg, low_id, high_id;
816 814
817 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_MODE, "mode %d\n", op_mode); 815 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "mode %d\n", op_mode);
818 816
819 /* Preserve rest settings */ 817 /* Preserve rest settings */
820 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000; 818 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
@@ -890,7 +888,7 @@ void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
890 * XXX: rethink this after new mode changes to 888 * XXX: rethink this after new mode changes to
891 * mac80211 are integrated */ 889 * mac80211 are integrated */
892 if (ah->ah_version == AR5K_AR5212 && 890 if (ah->ah_version == AR5K_AR5212 &&
893 ah->ah_sc->nvifs) 891 ah->nvifs)
894 ath5k_hw_write_rate_duration(ah); 892 ath5k_hw_write_rate_duration(ah);
895 893
896 /* Set RSSI/BRSSI thresholds 894 /* Set RSSI/BRSSI thresholds
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index dd2b417729ba..81e465e70175 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <asm/unaligned.h>
25 26
26#include "ath5k.h" 27#include "ath5k.h"
27#include "reg.h" 28#include "reg.h"
@@ -561,7 +562,7 @@ static s8 ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah)
561 } 562 }
562 563
563done: 564done:
564 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 565 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE,
565 "ret %d, gain step %u, current gain %u, target gain %u\n", 566 "ret %d, gain step %u, current gain %u, target gain %u\n",
566 ret, ah->ah_gain.g_step_idx, ah->ah_gain.g_current, 567 ret, ah->ah_gain.g_step_idx, ah->ah_gain.g_current,
567 ah->ah_gain.g_target); 568 ah->ah_gain.g_target);
@@ -773,7 +774,7 @@ static int ath5k_hw_rfregs_init(struct ath5k_hw *ah,
773 ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size, 774 ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
774 GFP_KERNEL); 775 GFP_KERNEL);
775 if (ah->ah_rf_banks == NULL) { 776 if (ah->ah_rf_banks == NULL) {
776 ATH5K_ERR(ah->ah_sc, "out of memory\n"); 777 ATH5K_ERR(ah, "out of memory\n");
777 return -ENOMEM; 778 return -ENOMEM;
778 } 779 }
779 } 780 }
@@ -783,7 +784,7 @@ static int ath5k_hw_rfregs_init(struct ath5k_hw *ah,
783 784
784 for (i = 0; i < ah->ah_rf_banks_size; i++) { 785 for (i = 0; i < ah->ah_rf_banks_size; i++) {
785 if (ini_rfb[i].rfb_bank >= AR5K_MAX_RF_BANKS) { 786 if (ini_rfb[i].rfb_bank >= AR5K_MAX_RF_BANKS) {
786 ATH5K_ERR(ah->ah_sc, "invalid bank\n"); 787 ATH5K_ERR(ah, "invalid bank\n");
787 return -EINVAL; 788 return -EINVAL;
788 } 789 }
789 790
@@ -1268,7 +1269,7 @@ static int ath5k_hw_channel(struct ath5k_hw *ah,
1268 * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok() 1269 * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok()
1269 * of the band by that */ 1270 * of the band by that */
1270 if (!ath5k_channel_ok(ah, channel->center_freq, channel->hw_value)) { 1271 if (!ath5k_channel_ok(ah, channel->center_freq, channel->hw_value)) {
1271 ATH5K_ERR(ah->ah_sc, 1272 ATH5K_ERR(ah,
1272 "channel frequency (%u MHz) out of supported " 1273 "channel frequency (%u MHz) out of supported "
1273 "band range\n", 1274 "band range\n",
1274 channel->center_freq); 1275 channel->center_freq);
@@ -1356,7 +1357,7 @@ static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
1356 } 1357 }
1357 } 1358 }
1358 for (i = 0; i < ATH5K_NF_CAL_HIST_MAX; i++) { 1359 for (i = 0; i < ATH5K_NF_CAL_HIST_MAX; i++) {
1359 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1360 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE,
1360 "cal %d:%d\n", i, sort[i]); 1361 "cal %d:%d\n", i, sort[i]);
1361 } 1362 }
1362 return sort[(ATH5K_NF_CAL_HIST_MAX - 1) / 2]; 1363 return sort[(ATH5K_NF_CAL_HIST_MAX - 1) / 2];
@@ -1382,7 +1383,7 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah)
1382 1383
1383 /* keep last value if calibration hasn't completed */ 1384 /* keep last value if calibration hasn't completed */
1384 if (ath5k_hw_reg_read(ah, AR5K_PHY_AGCCTL) & AR5K_PHY_AGCCTL_NF) { 1385 if (ath5k_hw_reg_read(ah, AR5K_PHY_AGCCTL) & AR5K_PHY_AGCCTL_NF) {
1385 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1386 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE,
1386 "NF did not complete in calibration window\n"); 1387 "NF did not complete in calibration window\n");
1387 1388
1388 return; 1389 return;
@@ -1395,7 +1396,7 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah)
1395 threshold = ee->ee_noise_floor_thr[ee_mode]; 1396 threshold = ee->ee_noise_floor_thr[ee_mode];
1396 1397
1397 if (nf > threshold) { 1398 if (nf > threshold) {
1398 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1399 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE,
1399 "noise floor failure detected; " 1400 "noise floor failure detected; "
1400 "read %d, threshold %d\n", 1401 "read %d, threshold %d\n",
1401 nf, threshold); 1402 nf, threshold);
@@ -1432,7 +1433,7 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah)
1432 1433
1433 ah->ah_noise_floor = nf; 1434 ah->ah_noise_floor = nf;
1434 1435
1435 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1436 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE,
1436 "noise floor calibrated: %d\n", nf); 1437 "noise floor calibrated: %d\n", nf);
1437} 1438}
1438 1439
@@ -1520,7 +1521,7 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah,
1520 ath5k_hw_reg_write(ah, phy_sat, AR5K_PHY_ADCSAT); 1521 ath5k_hw_reg_write(ah, phy_sat, AR5K_PHY_ADCSAT);
1521 1522
1522 if (ret) { 1523 if (ret) {
1523 ATH5K_ERR(ah->ah_sc, "calibration timeout (%uMHz)\n", 1524 ATH5K_ERR(ah, "calibration timeout (%uMHz)\n",
1524 channel->center_freq); 1525 channel->center_freq);
1525 return ret; 1526 return ret;
1526 } 1527 }
@@ -1555,7 +1556,7 @@ ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah)
1555 iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR); 1556 iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR);
1556 i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I); 1557 i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I);
1557 q_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_Q); 1558 q_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_Q);
1558 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1559 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_CALIBRATE,
1559 "iq_corr:%x i_pwr:%x q_pwr:%x", iq_corr, i_pwr, q_pwr); 1560 "iq_corr:%x i_pwr:%x q_pwr:%x", iq_corr, i_pwr, q_pwr);
1560 if (i_pwr && q_pwr) 1561 if (i_pwr && q_pwr)
1561 break; 1562 break;
@@ -1581,7 +1582,7 @@ ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah)
1581 q_coff = (i_pwr / q_coffd) - 128; 1582 q_coff = (i_pwr / q_coffd) - 128;
1582 q_coff = clamp(q_coff, -16, 15); /* signed 5 bit */ 1583 q_coff = clamp(q_coff, -16, 15); /* signed 5 bit */
1583 1584
1584 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_CALIBRATE, 1585 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_CALIBRATE,
1585 "new I:%d Q:%d (i_coffd:%x q_coffd:%x)", 1586 "new I:%d Q:%d (i_coffd:%x q_coffd:%x)",
1586 i_coff, q_coff, i_coffd, q_coffd); 1587 i_coff, q_coff, i_coffd, q_coffd);
1587 1588
@@ -1966,7 +1967,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1966 1967
1967 ee_mode = ath5k_eeprom_mode_from_channel(channel); 1968 ee_mode = ath5k_eeprom_mode_from_channel(channel);
1968 if (ee_mode < 0) { 1969 if (ee_mode < 0) {
1969 ATH5K_ERR(ah->ah_sc, 1970 ATH5K_ERR(ah,
1970 "invalid channel: %d\n", channel->center_freq); 1971 "invalid channel: %d\n", channel->center_freq);
1971 return; 1972 return;
1972 } 1973 }
@@ -2794,12 +2795,8 @@ ath5k_write_pwr_to_pdadc_table(struct ath5k_hw *ah, u8 ee_mode)
2794 * Write TX power values 2795 * Write TX power values
2795 */ 2796 */
2796 for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) { 2797 for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) {
2797 ath5k_hw_reg_write(ah, 2798 u32 val = get_unaligned_le32(&pdadc_out[4 * i]);
2798 ((pdadc_out[4 * i + 0] & 0xff) << 0) | 2799 ath5k_hw_reg_write(ah, val, AR5K_PHY_PDADC_TXPOWER(i));
2799 ((pdadc_out[4 * i + 1] & 0xff) << 8) |
2800 ((pdadc_out[4 * i + 2] & 0xff) << 16) |
2801 ((pdadc_out[4 * i + 3] & 0xff) << 24),
2802 AR5K_PHY_PDADC_TXPOWER(i));
2803 } 2800 }
2804} 2801}
2805 2802
@@ -3122,13 +3119,13 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3122 int ret; 3119 int ret;
3123 3120
3124 if (txpower > AR5K_TUNE_MAX_TXPOWER) { 3121 if (txpower > AR5K_TUNE_MAX_TXPOWER) {
3125 ATH5K_ERR(ah->ah_sc, "invalid tx power: %u\n", txpower); 3122 ATH5K_ERR(ah, "invalid tx power: %u\n", txpower);
3126 return -EINVAL; 3123 return -EINVAL;
3127 } 3124 }
3128 3125
3129 ee_mode = ath5k_eeprom_mode_from_channel(channel); 3126 ee_mode = ath5k_eeprom_mode_from_channel(channel);
3130 if (ee_mode < 0) { 3127 if (ee_mode < 0) {
3131 ATH5K_ERR(ah->ah_sc, 3128 ATH5K_ERR(ah,
3132 "invalid channel: %d\n", channel->center_freq); 3129 "invalid channel: %d\n", channel->center_freq);
3133 return -EINVAL; 3130 return -EINVAL;
3134 } 3131 }
@@ -3229,7 +3226,7 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3229 3226
3230int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) 3227int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
3231{ 3228{
3232 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER, 3229 ATH5K_DBG(ah, ATH5K_DEBUG_TXPOWER,
3233 "changing txpower to %d\n", txpower); 3230 "changing txpower to %d\n", txpower);
3234 3231
3235 return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower); 3232 return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower);
@@ -3440,7 +3437,7 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
3440 * during ath5k_phy_calibrate) */ 3437 * during ath5k_phy_calibrate) */
3441 if (ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL, 3438 if (ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL,
3442 AR5K_PHY_AGCCTL_CAL, 0, false)) { 3439 AR5K_PHY_AGCCTL_CAL, 0, false)) {
3443 ATH5K_ERR(ah->ah_sc, "gain calibration timeout (%uMHz)\n", 3440 ATH5K_ERR(ah, "gain calibration timeout (%uMHz)\n",
3444 channel->center_freq); 3441 channel->center_freq);
3445 } 3442 }
3446 3443
diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c
index b18c5021aac3..65f10398999e 100644
--- a/drivers/net/wireless/ath/ath5k/qcu.c
+++ b/drivers/net/wireless/ath/ath5k/qcu.c
@@ -187,7 +187,7 @@ int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type,
187 break; 187 break;
188 case AR5K_TX_QUEUE_XR_DATA: 188 case AR5K_TX_QUEUE_XR_DATA:
189 if (ah->ah_version != AR5K_AR5212) 189 if (ah->ah_version != AR5K_AR5212)
190 ATH5K_ERR(ah->ah_sc, 190 ATH5K_ERR(ah,
191 "XR data queues only supported in" 191 "XR data queues only supported in"
192 " 5212!\n"); 192 " 5212!\n");
193 queue = AR5K_TX_QUEUE_ID_XR_DATA; 193 queue = AR5K_TX_QUEUE_ID_XR_DATA;
@@ -510,7 +510,6 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue)
510int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time) 510int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time)
511{ 511{
512 struct ieee80211_channel *channel = ah->ah_current_channel; 512 struct ieee80211_channel *channel = ah->ah_current_channel;
513 struct ath5k_softc *sc = ah->ah_sc;
514 struct ieee80211_rate *rate; 513 struct ieee80211_rate *rate;
515 u32 ack_tx_time, eifs, eifs_clock, sifs, sifs_clock; 514 u32 ack_tx_time, eifs, eifs_clock, sifs, sifs_clock;
516 u32 slot_time_clock = ath5k_hw_htoclock(ah, slot_time); 515 u32 slot_time_clock = ath5k_hw_htoclock(ah, slot_time);
@@ -546,9 +545,9 @@ int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time)
546 * Also we have different lowest rate for 802.11a 545 * Also we have different lowest rate for 802.11a
547 */ 546 */
548 if (channel->hw_value & CHANNEL_5GHZ) 547 if (channel->hw_value & CHANNEL_5GHZ)
549 rate = &sc->sbands[IEEE80211_BAND_5GHZ].bitrates[0]; 548 rate = &ah->sbands[IEEE80211_BAND_5GHZ].bitrates[0];
550 else 549 else
551 rate = &sc->sbands[IEEE80211_BAND_2GHZ].bitrates[0]; 550 rate = &ah->sbands[IEEE80211_BAND_2GHZ].bitrates[0];
552 551
553 ack_tx_time = ath5k_hw_get_frame_duration(ah, 10, rate, false); 552 ack_tx_time = ath5k_hw_get_frame_duration(ah, 10, rate, false);
554 553
@@ -622,7 +621,7 @@ int ath5k_hw_init_queues(struct ath5k_hw *ah)
622 for (i = 0; i < ah->ah_capabilities.cap_queues.q_tx_num; i++) { 621 for (i = 0; i < ah->ah_capabilities.cap_queues.q_tx_num; i++) {
623 ret = ath5k_hw_reset_tx_queue(ah, i); 622 ret = ath5k_hw_reset_tx_queue(ah, i);
624 if (ret) { 623 if (ret) {
625 ATH5K_ERR(ah->ah_sc, 624 ATH5K_ERR(ah,
626 "failed to reset TX queue #%d\n", i); 625 "failed to reset TX queue #%d\n", i);
627 return ret; 626 return ret;
628 } 627 }
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index 9f9c2ad3ca66..0686c5d8d56e 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -390,7 +390,7 @@ static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags)
390 u32 val = 0; 390 u32 val = 0;
391 391
392 /* ah->ah_mac_srev is not available at this point yet */ 392 /* ah->ah_mac_srev is not available at this point yet */
393 if (ah->ah_sc->devid >= AR5K_SREV_AR2315_R6) { 393 if (ah->devid >= AR5K_SREV_AR2315_R6) {
394 reg = (u32 __iomem *) AR5K_AR2315_RESET; 394 reg = (u32 __iomem *) AR5K_AR2315_RESET;
395 if (mask & AR5K_RESET_CTL_PCU) 395 if (mask & AR5K_RESET_CTL_PCU)
396 val |= AR5K_AR2315_RESET_WMAC; 396 val |= AR5K_AR2315_RESET_WMAC;
@@ -398,7 +398,7 @@ static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags)
398 val |= AR5K_AR2315_RESET_BB_WARM; 398 val |= AR5K_AR2315_RESET_BB_WARM;
399 } else { 399 } else {
400 reg = (u32 __iomem *) AR5K_AR5312_RESET; 400 reg = (u32 __iomem *) AR5K_AR5312_RESET;
401 if (to_platform_device(ah->ah_sc->dev)->id == 0) { 401 if (to_platform_device(ah->dev)->id == 0) {
402 if (mask & AR5K_RESET_CTL_PCU) 402 if (mask & AR5K_RESET_CTL_PCU)
403 val |= AR5K_AR5312_RESET_WMAC0; 403 val |= AR5K_AR5312_RESET_WMAC0;
404 if (mask & AR5K_RESET_CTL_BASEBAND) 404 if (mask & AR5K_RESET_CTL_BASEBAND)
@@ -530,7 +530,7 @@ commit:
530 */ 530 */
531int ath5k_hw_on_hold(struct ath5k_hw *ah) 531int ath5k_hw_on_hold(struct ath5k_hw *ah)
532{ 532{
533 struct pci_dev *pdev = ah->ah_sc->pdev; 533 struct pci_dev *pdev = ah->pdev;
534 u32 bus_flags; 534 u32 bus_flags;
535 int ret; 535 int ret;
536 536
@@ -540,7 +540,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah)
540 /* Make sure device is awake */ 540 /* Make sure device is awake */
541 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 541 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0);
542 if (ret) { 542 if (ret) {
543 ATH5K_ERR(ah->ah_sc, "failed to wakeup the MAC Chip\n"); 543 ATH5K_ERR(ah, "failed to wakeup the MAC Chip\n");
544 return ret; 544 return ret;
545 } 545 }
546 546
@@ -565,14 +565,14 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah)
565 } 565 }
566 566
567 if (ret) { 567 if (ret) {
568 ATH5K_ERR(ah->ah_sc, "failed to put device on warm reset\n"); 568 ATH5K_ERR(ah, "failed to put device on warm reset\n");
569 return -EIO; 569 return -EIO;
570 } 570 }
571 571
572 /* ...wakeup again!*/ 572 /* ...wakeup again!*/
573 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 573 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0);
574 if (ret) { 574 if (ret) {
575 ATH5K_ERR(ah->ah_sc, "failed to put device on hold\n"); 575 ATH5K_ERR(ah, "failed to put device on hold\n");
576 return ret; 576 return ret;
577 } 577 }
578 578
@@ -584,7 +584,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah)
584 */ 584 */
585int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial) 585int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
586{ 586{
587 struct pci_dev *pdev = ah->ah_sc->pdev; 587 struct pci_dev *pdev = ah->pdev;
588 u32 turbo, mode, clock, bus_flags; 588 u32 turbo, mode, clock, bus_flags;
589 int ret; 589 int ret;
590 590
@@ -596,7 +596,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
596 /* Wakeup the device */ 596 /* Wakeup the device */
597 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 597 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0);
598 if (ret) { 598 if (ret) {
599 ATH5K_ERR(ah->ah_sc, "failed to wakeup the MAC Chip\n"); 599 ATH5K_ERR(ah, "failed to wakeup the MAC Chip\n");
600 return ret; 600 return ret;
601 } 601 }
602 } 602 }
@@ -626,14 +626,14 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
626 } 626 }
627 627
628 if (ret) { 628 if (ret) {
629 ATH5K_ERR(ah->ah_sc, "failed to reset the MAC Chip\n"); 629 ATH5K_ERR(ah, "failed to reset the MAC Chip\n");
630 return -EIO; 630 return -EIO;
631 } 631 }
632 632
633 /* ...wakeup again!...*/ 633 /* ...wakeup again!...*/
634 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 634 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0);
635 if (ret) { 635 if (ret) {
636 ATH5K_ERR(ah->ah_sc, "failed to resume the MAC Chip\n"); 636 ATH5K_ERR(ah, "failed to resume the MAC Chip\n");
637 return ret; 637 return ret;
638 } 638 }
639 639
@@ -646,7 +646,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
646 ret = ath5k_hw_nic_reset(ah, 0); 646 ret = ath5k_hw_nic_reset(ah, 0);
647 647
648 if (ret) { 648 if (ret) {
649 ATH5K_ERR(ah->ah_sc, "failed to warm reset the MAC Chip\n"); 649 ATH5K_ERR(ah, "failed to warm reset the MAC Chip\n");
650 return -EIO; 650 return -EIO;
651 } 651 }
652 652
@@ -687,7 +687,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
687 else 687 else
688 mode |= AR5K_PHY_MODE_MOD_DYN; 688 mode |= AR5K_PHY_MODE_MOD_DYN;
689 } else { 689 } else {
690 ATH5K_ERR(ah->ah_sc, 690 ATH5K_ERR(ah,
691 "invalid radio modulation mode\n"); 691 "invalid radio modulation mode\n");
692 return -EINVAL; 692 return -EINVAL;
693 } 693 }
@@ -703,12 +703,12 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
703 if (flags & CHANNEL_OFDM) 703 if (flags & CHANNEL_OFDM)
704 mode |= AR5K_PHY_MODE_MOD_OFDM; 704 mode |= AR5K_PHY_MODE_MOD_OFDM;
705 else { 705 else {
706 ATH5K_ERR(ah->ah_sc, 706 ATH5K_ERR(ah,
707 "invalid radio modulation mode\n"); 707 "invalid radio modulation mode\n");
708 return -EINVAL; 708 return -EINVAL;
709 } 709 }
710 } else { 710 } else {
711 ATH5K_ERR(ah->ah_sc, "invalid radio frequency mode\n"); 711 ATH5K_ERR(ah, "invalid radio frequency mode\n");
712 return -EINVAL; 712 return -EINVAL;
713 } 713 }
714 714
@@ -1076,7 +1076,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1076 /* RF Bus grant won't work if we have pending 1076 /* RF Bus grant won't work if we have pending
1077 * frames */ 1077 * frames */
1078 if (ret && fast) { 1078 if (ret && fast) {
1079 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_RESET, 1079 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
1080 "DMA didn't stop, falling back to normal reset\n"); 1080 "DMA didn't stop, falling back to normal reset\n");
1081 fast = 0; 1081 fast = 0;
1082 /* Non fatal, just continue with 1082 /* Non fatal, just continue with
@@ -1091,7 +1091,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1091 case CHANNEL_G: 1091 case CHANNEL_G:
1092 1092
1093 if (ah->ah_version <= AR5K_AR5211) { 1093 if (ah->ah_version <= AR5K_AR5211) {
1094 ATH5K_ERR(ah->ah_sc, 1094 ATH5K_ERR(ah,
1095 "G mode not available on 5210/5211"); 1095 "G mode not available on 5210/5211");
1096 return -EINVAL; 1096 return -EINVAL;
1097 } 1097 }
@@ -1101,7 +1101,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1101 case CHANNEL_B: 1101 case CHANNEL_B:
1102 1102
1103 if (ah->ah_version < AR5K_AR5211) { 1103 if (ah->ah_version < AR5K_AR5211) {
1104 ATH5K_ERR(ah->ah_sc, 1104 ATH5K_ERR(ah,
1105 "B mode not available on 5210"); 1105 "B mode not available on 5210");
1106 return -EINVAL; 1106 return -EINVAL;
1107 } 1107 }
@@ -1110,14 +1110,14 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1110 break; 1110 break;
1111 case CHANNEL_XR: 1111 case CHANNEL_XR:
1112 if (ah->ah_version == AR5K_AR5211) { 1112 if (ah->ah_version == AR5K_AR5211) {
1113 ATH5K_ERR(ah->ah_sc, 1113 ATH5K_ERR(ah,
1114 "XR mode not available on 5211"); 1114 "XR mode not available on 5211");
1115 return -EINVAL; 1115 return -EINVAL;
1116 } 1116 }
1117 mode = AR5K_MODE_XR; 1117 mode = AR5K_MODE_XR;
1118 break; 1118 break;
1119 default: 1119 default:
1120 ATH5K_ERR(ah->ah_sc, 1120 ATH5K_ERR(ah,
1121 "invalid channel: %d\n", channel->center_freq); 1121 "invalid channel: %d\n", channel->center_freq);
1122 return -EINVAL; 1122 return -EINVAL;
1123 } 1123 }
@@ -1129,13 +1129,13 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1129 if (fast) { 1129 if (fast) {
1130 ret = ath5k_hw_phy_init(ah, channel, mode, true); 1130 ret = ath5k_hw_phy_init(ah, channel, mode, true);
1131 if (ret) { 1131 if (ret) {
1132 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_RESET, 1132 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
1133 "fast chan change failed, falling back to normal reset\n"); 1133 "fast chan change failed, falling back to normal reset\n");
1134 /* Non fatal, can happen eg. 1134 /* Non fatal, can happen eg.
1135 * on mode change */ 1135 * on mode change */
1136 ret = 0; 1136 ret = 0;
1137 } else { 1137 } else {
1138 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_RESET, 1138 ATH5K_DBG(ah, ATH5K_DEBUG_RESET,
1139 "fast chan change successful\n"); 1139 "fast chan change successful\n");
1140 return 0; 1140 return 0;
1141 } 1141 }
@@ -1268,7 +1268,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1268 */ 1268 */
1269 ret = ath5k_hw_phy_init(ah, channel, mode, false); 1269 ret = ath5k_hw_phy_init(ah, channel, mode, false);
1270 if (ret) { 1270 if (ret) {
1271 ATH5K_ERR(ah->ah_sc, 1271 ATH5K_ERR(ah,
1272 "failed to initialize PHY (%i) !\n", ret); 1272 "failed to initialize PHY (%i) !\n", ret);
1273 return ret; 1273 return ret;
1274 } 1274 }
diff --git a/drivers/net/wireless/ath/ath5k/rfkill.c b/drivers/net/wireless/ath/ath5k/rfkill.c
index 41a877b73fce..945fc9f21e76 100644
--- a/drivers/net/wireless/ath/ath5k/rfkill.c
+++ b/drivers/net/wireless/ath/ath5k/rfkill.c
@@ -36,86 +36,81 @@
36#include "base.h" 36#include "base.h"
37 37
38 38
39static inline void ath5k_rfkill_disable(struct ath5k_softc *sc) 39static inline void ath5k_rfkill_disable(struct ath5k_hw *ah)
40{ 40{
41 ATH5K_DBG(sc, ATH5K_DEBUG_ANY, "rfkill disable (gpio:%d polarity:%d)\n", 41 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, "rfkill disable (gpio:%d polarity:%d)\n",
42 sc->rf_kill.gpio, sc->rf_kill.polarity); 42 ah->rf_kill.gpio, ah->rf_kill.polarity);
43 ath5k_hw_set_gpio_output(sc->ah, sc->rf_kill.gpio); 43 ath5k_hw_set_gpio_output(ah, ah->rf_kill.gpio);
44 ath5k_hw_set_gpio(sc->ah, sc->rf_kill.gpio, !sc->rf_kill.polarity); 44 ath5k_hw_set_gpio(ah, ah->rf_kill.gpio, !ah->rf_kill.polarity);
45} 45}
46 46
47 47
48static inline void ath5k_rfkill_enable(struct ath5k_softc *sc) 48static inline void ath5k_rfkill_enable(struct ath5k_hw *ah)
49{ 49{
50 ATH5K_DBG(sc, ATH5K_DEBUG_ANY, "rfkill enable (gpio:%d polarity:%d)\n", 50 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, "rfkill enable (gpio:%d polarity:%d)\n",
51 sc->rf_kill.gpio, sc->rf_kill.polarity); 51 ah->rf_kill.gpio, ah->rf_kill.polarity);
52 ath5k_hw_set_gpio_output(sc->ah, sc->rf_kill.gpio); 52 ath5k_hw_set_gpio_output(ah, ah->rf_kill.gpio);
53 ath5k_hw_set_gpio(sc->ah, sc->rf_kill.gpio, sc->rf_kill.polarity); 53 ath5k_hw_set_gpio(ah, ah->rf_kill.gpio, ah->rf_kill.polarity);
54} 54}
55 55
56static inline void ath5k_rfkill_set_intr(struct ath5k_softc *sc, bool enable) 56static inline void ath5k_rfkill_set_intr(struct ath5k_hw *ah, bool enable)
57{ 57{
58 struct ath5k_hw *ah = sc->ah;
59 u32 curval; 58 u32 curval;
60 59
61 ath5k_hw_set_gpio_input(ah, sc->rf_kill.gpio); 60 ath5k_hw_set_gpio_input(ah, ah->rf_kill.gpio);
62 curval = ath5k_hw_get_gpio(ah, sc->rf_kill.gpio); 61 curval = ath5k_hw_get_gpio(ah, ah->rf_kill.gpio);
63 ath5k_hw_set_gpio_intr(ah, sc->rf_kill.gpio, enable ? 62 ath5k_hw_set_gpio_intr(ah, ah->rf_kill.gpio, enable ?
64 !!curval : !curval); 63 !!curval : !curval);
65} 64}
66 65
67static bool 66static bool
68ath5k_is_rfkill_set(struct ath5k_softc *sc) 67ath5k_is_rfkill_set(struct ath5k_hw *ah)
69{ 68{
70 /* configuring GPIO for input for some reason disables rfkill */ 69 /* configuring GPIO for input for some reason disables rfkill */
71 /*ath5k_hw_set_gpio_input(sc->ah, sc->rf_kill.gpio);*/ 70 /*ath5k_hw_set_gpio_input(ah, ah->rf_kill.gpio);*/
72 return ath5k_hw_get_gpio(sc->ah, sc->rf_kill.gpio) == 71 return ath5k_hw_get_gpio(ah, ah->rf_kill.gpio) ==
73 sc->rf_kill.polarity; 72 ah->rf_kill.polarity;
74} 73}
75 74
76static void 75static void
77ath5k_tasklet_rfkill_toggle(unsigned long data) 76ath5k_tasklet_rfkill_toggle(unsigned long data)
78{ 77{
79 struct ath5k_softc *sc = (void *)data; 78 struct ath5k_hw *ah = (void *)data;
80 bool blocked; 79 bool blocked;
81 80
82 blocked = ath5k_is_rfkill_set(sc); 81 blocked = ath5k_is_rfkill_set(ah);
83 wiphy_rfkill_set_hw_state(sc->hw->wiphy, blocked); 82 wiphy_rfkill_set_hw_state(ah->hw->wiphy, blocked);
84} 83}
85 84
86 85
87void 86void
88ath5k_rfkill_hw_start(struct ath5k_hw *ah) 87ath5k_rfkill_hw_start(struct ath5k_hw *ah)
89{ 88{
90 struct ath5k_softc *sc = ah->ah_sc;
91
92 /* read rfkill GPIO configuration from EEPROM header */ 89 /* read rfkill GPIO configuration from EEPROM header */
93 sc->rf_kill.gpio = ah->ah_capabilities.cap_eeprom.ee_rfkill_pin; 90 ah->rf_kill.gpio = ah->ah_capabilities.cap_eeprom.ee_rfkill_pin;
94 sc->rf_kill.polarity = ah->ah_capabilities.cap_eeprom.ee_rfkill_pol; 91 ah->rf_kill.polarity = ah->ah_capabilities.cap_eeprom.ee_rfkill_pol;
95 92
96 tasklet_init(&sc->rf_kill.toggleq, ath5k_tasklet_rfkill_toggle, 93 tasklet_init(&ah->rf_kill.toggleq, ath5k_tasklet_rfkill_toggle,
97 (unsigned long)sc); 94 (unsigned long)ah);
98 95
99 ath5k_rfkill_disable(sc); 96 ath5k_rfkill_disable(ah);
100 97
101 /* enable interrupt for rfkill switch */ 98 /* enable interrupt for rfkill switch */
102 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header)) 99 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
103 ath5k_rfkill_set_intr(sc, true); 100 ath5k_rfkill_set_intr(ah, true);
104} 101}
105 102
106 103
107void 104void
108ath5k_rfkill_hw_stop(struct ath5k_hw *ah) 105ath5k_rfkill_hw_stop(struct ath5k_hw *ah)
109{ 106{
110 struct ath5k_softc *sc = ah->ah_sc;
111
112 /* disable interrupt for rfkill switch */ 107 /* disable interrupt for rfkill switch */
113 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header)) 108 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
114 ath5k_rfkill_set_intr(sc, false); 109 ath5k_rfkill_set_intr(ah, false);
115 110
116 tasklet_kill(&sc->rf_kill.toggleq); 111 tasklet_kill(&ah->rf_kill.toggleq);
117 112
118 /* enable RFKILL when stopping HW so Wifi LED is turned off */ 113 /* enable RFKILL when stopping HW so Wifi LED is turned off */
119 ath5k_rfkill_enable(sc); 114 ath5k_rfkill_enable(ah);
120} 115}
121 116
diff --git a/drivers/net/wireless/ath/ath5k/sysfs.c b/drivers/net/wireless/ath/ath5k/sysfs.c
index d8ad0e45e1c4..0244a36ba958 100644
--- a/drivers/net/wireless/ath/ath5k/sysfs.c
+++ b/drivers/net/wireless/ath/ath5k/sysfs.c
@@ -11,7 +11,7 @@ static ssize_t ath5k_attr_show_##name(struct device *dev, \
11 char *buf) \ 11 char *buf) \
12{ \ 12{ \
13 struct ieee80211_hw *hw = dev_get_drvdata(dev); \ 13 struct ieee80211_hw *hw = dev_get_drvdata(dev); \
14 struct ath5k_softc *sc = hw->priv; \ 14 struct ath5k_hw *ah = hw->priv; \
15 return snprintf(buf, PAGE_SIZE, "%d\n", get); \ 15 return snprintf(buf, PAGE_SIZE, "%d\n", get); \
16} \ 16} \
17 \ 17 \
@@ -20,13 +20,13 @@ static ssize_t ath5k_attr_store_##name(struct device *dev, \
20 const char *buf, size_t count) \ 20 const char *buf, size_t count) \
21{ \ 21{ \
22 struct ieee80211_hw *hw = dev_get_drvdata(dev); \ 22 struct ieee80211_hw *hw = dev_get_drvdata(dev); \
23 struct ath5k_softc *sc = hw->priv; \ 23 struct ath5k_hw *ah = hw->priv; \
24 int val, ret; \ 24 int val, ret; \
25 \ 25 \
26 ret = kstrtoint(buf, 10, &val); \ 26 ret = kstrtoint(buf, 10, &val); \
27 if (ret < 0) \ 27 if (ret < 0) \
28 return ret; \ 28 return ret; \
29 set(sc->ah, val); \ 29 set(ah, val); \
30 return count; \ 30 return count; \
31} \ 31} \
32static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, \ 32static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, \
@@ -38,25 +38,25 @@ static ssize_t ath5k_attr_show_##name(struct device *dev, \
38 char *buf) \ 38 char *buf) \
39{ \ 39{ \
40 struct ieee80211_hw *hw = dev_get_drvdata(dev); \ 40 struct ieee80211_hw *hw = dev_get_drvdata(dev); \
41 struct ath5k_softc *sc = hw->priv; \ 41 struct ath5k_hw *ah = hw->priv; \
42 return snprintf(buf, PAGE_SIZE, "%d\n", get); \ 42 return snprintf(buf, PAGE_SIZE, "%d\n", get); \
43} \ 43} \
44static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL) 44static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL)
45 45
46/*** ANI ***/ 46/*** ANI ***/
47 47
48SIMPLE_SHOW_STORE(ani_mode, sc->ani_state.ani_mode, ath5k_ani_init); 48SIMPLE_SHOW_STORE(ani_mode, ah->ani_state.ani_mode, ath5k_ani_init);
49SIMPLE_SHOW_STORE(noise_immunity_level, sc->ani_state.noise_imm_level, 49SIMPLE_SHOW_STORE(noise_immunity_level, ah->ani_state.noise_imm_level,
50 ath5k_ani_set_noise_immunity_level); 50 ath5k_ani_set_noise_immunity_level);
51SIMPLE_SHOW_STORE(spur_level, sc->ani_state.spur_level, 51SIMPLE_SHOW_STORE(spur_level, ah->ani_state.spur_level,
52 ath5k_ani_set_spur_immunity_level); 52 ath5k_ani_set_spur_immunity_level);
53SIMPLE_SHOW_STORE(firstep_level, sc->ani_state.firstep_level, 53SIMPLE_SHOW_STORE(firstep_level, ah->ani_state.firstep_level,
54 ath5k_ani_set_firstep_level); 54 ath5k_ani_set_firstep_level);
55SIMPLE_SHOW_STORE(ofdm_weak_signal_detection, sc->ani_state.ofdm_weak_sig, 55SIMPLE_SHOW_STORE(ofdm_weak_signal_detection, ah->ani_state.ofdm_weak_sig,
56 ath5k_ani_set_ofdm_weak_signal_detection); 56 ath5k_ani_set_ofdm_weak_signal_detection);
57SIMPLE_SHOW_STORE(cck_weak_signal_detection, sc->ani_state.cck_weak_sig, 57SIMPLE_SHOW_STORE(cck_weak_signal_detection, ah->ani_state.cck_weak_sig,
58 ath5k_ani_set_cck_weak_signal_detection); 58 ath5k_ani_set_cck_weak_signal_detection);
59SIMPLE_SHOW(spur_level_max, sc->ani_state.max_spur_level); 59SIMPLE_SHOW(spur_level_max, ah->ani_state.max_spur_level);
60 60
61static ssize_t ath5k_attr_show_noise_immunity_level_max(struct device *dev, 61static ssize_t ath5k_attr_show_noise_immunity_level_max(struct device *dev,
62 struct device_attribute *attr, 62 struct device_attribute *attr,
@@ -98,14 +98,14 @@ static struct attribute_group ath5k_attribute_group_ani = {
98/*** register / unregister ***/ 98/*** register / unregister ***/
99 99
100int 100int
101ath5k_sysfs_register(struct ath5k_softc *sc) 101ath5k_sysfs_register(struct ath5k_hw *ah)
102{ 102{
103 struct device *dev = sc->dev; 103 struct device *dev = ah->dev;
104 int err; 104 int err;
105 105
106 err = sysfs_create_group(&dev->kobj, &ath5k_attribute_group_ani); 106 err = sysfs_create_group(&dev->kobj, &ath5k_attribute_group_ani);
107 if (err) { 107 if (err) {
108 ATH5K_ERR(sc, "failed to create sysfs group\n"); 108 ATH5K_ERR(ah, "failed to create sysfs group\n");
109 return err; 109 return err;
110 } 110 }
111 111
@@ -113,9 +113,9 @@ ath5k_sysfs_register(struct ath5k_softc *sc)
113} 113}
114 114
115void 115void
116ath5k_sysfs_unregister(struct ath5k_softc *sc) 116ath5k_sysfs_unregister(struct ath5k_hw *ah)
117{ 117{
118 struct device *dev = sc->dev; 118 struct device *dev = ah->dev;
119 119
120 sysfs_remove_group(&dev->kobj, &ath5k_attribute_group_ani); 120 sysfs_remove_group(&dev->kobj, &ath5k_attribute_group_ani);
121} 121}
diff --git a/drivers/net/wireless/ath/ath5k/trace.h b/drivers/net/wireless/ath/ath5k/trace.h
index 235e0768ce1d..c741c871f4e9 100644
--- a/drivers/net/wireless/ath/ath5k/trace.h
+++ b/drivers/net/wireless/ath/ath5k/trace.h
@@ -16,10 +16,10 @@ struct sk_buff;
16#define TRACE_SYSTEM ath5k 16#define TRACE_SYSTEM ath5k
17 17
18TRACE_EVENT(ath5k_rx, 18TRACE_EVENT(ath5k_rx,
19 TP_PROTO(struct ath5k_softc *priv, struct sk_buff *skb), 19 TP_PROTO(struct ath5k_hw *priv, struct sk_buff *skb),
20 TP_ARGS(priv, skb), 20 TP_ARGS(priv, skb),
21 TP_STRUCT__entry( 21 TP_STRUCT__entry(
22 __field(struct ath5k_softc *, priv) 22 __field(struct ath5k_hw *, priv)
23 __field(unsigned long, skbaddr) 23 __field(unsigned long, skbaddr)
24 __dynamic_array(u8, frame, skb->len) 24 __dynamic_array(u8, frame, skb->len)
25 ), 25 ),
@@ -34,13 +34,13 @@ TRACE_EVENT(ath5k_rx,
34); 34);
35 35
36TRACE_EVENT(ath5k_tx, 36TRACE_EVENT(ath5k_tx,
37 TP_PROTO(struct ath5k_softc *priv, struct sk_buff *skb, 37 TP_PROTO(struct ath5k_hw *priv, struct sk_buff *skb,
38 struct ath5k_txq *q), 38 struct ath5k_txq *q),
39 39
40 TP_ARGS(priv, skb, q), 40 TP_ARGS(priv, skb, q),
41 41
42 TP_STRUCT__entry( 42 TP_STRUCT__entry(
43 __field(struct ath5k_softc *, priv) 43 __field(struct ath5k_hw *, priv)
44 __field(unsigned long, skbaddr) 44 __field(unsigned long, skbaddr)
45 __field(u8, qnum) 45 __field(u8, qnum)
46 __dynamic_array(u8, frame, skb->len) 46 __dynamic_array(u8, frame, skb->len)
@@ -60,13 +60,13 @@ TRACE_EVENT(ath5k_tx,
60); 60);
61 61
62TRACE_EVENT(ath5k_tx_complete, 62TRACE_EVENT(ath5k_tx_complete,
63 TP_PROTO(struct ath5k_softc *priv, struct sk_buff *skb, 63 TP_PROTO(struct ath5k_hw *priv, struct sk_buff *skb,
64 struct ath5k_txq *q, struct ath5k_tx_status *ts), 64 struct ath5k_txq *q, struct ath5k_tx_status *ts),
65 65
66 TP_ARGS(priv, skb, q, ts), 66 TP_ARGS(priv, skb, q, ts),
67 67
68 TP_STRUCT__entry( 68 TP_STRUCT__entry(
69 __field(struct ath5k_softc *, priv) 69 __field(struct ath5k_hw *, priv)
70 __field(unsigned long, skbaddr) 70 __field(unsigned long, skbaddr)
71 __field(u8, qnum) 71 __field(u8, qnum)
72 __field(u8, ts_status) 72 __field(u8, ts_status)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 1d09f22fee4d..d109c25417f4 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -14,6 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <asm/unaligned.h>
17#include "hw.h" 18#include "hw.h"
18#include "ar9003_phy.h" 19#include "ar9003_phy.h"
19#include "ar9003_eeprom.h" 20#include "ar9003_eeprom.h"
@@ -3006,11 +3007,11 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
3006 3007
3007 switch (param) { 3008 switch (param) {
3008 case EEP_MAC_LSW: 3009 case EEP_MAC_LSW:
3009 return eep->macAddr[0] << 8 | eep->macAddr[1]; 3010 return get_unaligned_be16(eep->macAddr);
3010 case EEP_MAC_MID: 3011 case EEP_MAC_MID:
3011 return eep->macAddr[2] << 8 | eep->macAddr[3]; 3012 return get_unaligned_be16(eep->macAddr + 2);
3012 case EEP_MAC_MSW: 3013 case EEP_MAC_MSW:
3013 return eep->macAddr[4] << 8 | eep->macAddr[5]; 3014 return get_unaligned_be16(eep->macAddr + 4);
3014 case EEP_REG_0: 3015 case EEP_REG_0:
3015 return le16_to_cpu(pBase->regDmn[0]); 3016 return le16_to_cpu(pBase->regDmn[0]);
3016 case EEP_REG_1: 3017 case EEP_REG_1:
@@ -3038,7 +3039,7 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
3038 case EEP_CHAIN_MASK_REDUCE: 3039 case EEP_CHAIN_MASK_REDUCE:
3039 return (pBase->miscConfiguration >> 0x3) & 0x1; 3040 return (pBase->miscConfiguration >> 0x3) & 0x1;
3040 case EEP_ANT_DIV_CTL1: 3041 case EEP_ANT_DIV_CTL1:
3041 return le32_to_cpu(eep->base_ext1.ant_div_control); 3042 return eep->base_ext1.ant_div_control;
3042 default: 3043 default:
3043 return 0; 3044 return 0;
3044 } 3045 }
@@ -3380,8 +3381,7 @@ found:
3380 osize = length; 3381 osize = length;
3381 read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN); 3382 read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
3382 checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length); 3383 checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length);
3383 mchecksum = word[COMP_HDR_LEN + osize] | 3384 mchecksum = get_unaligned_le16(&word[COMP_HDR_LEN + osize]);
3384 (word[COMP_HDR_LEN + osize + 1] << 8);
3385 ath_dbg(common, ATH_DBG_EEPROM, 3385 ath_dbg(common, ATH_DBG_EEPROM,
3386 "checksum %x %x\n", checksum, mchecksum); 3386 "checksum %x %x\n", checksum, mchecksum);
3387 if (checksum == mchecksum) { 3387 if (checksum == mchecksum) {
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c
index 41ce0b139886..6635c377dc00 100644
--- a/drivers/net/wireless/ath/ath9k/btcoex.c
+++ b/drivers/net/wireless/ath/ath9k/btcoex.c
@@ -50,7 +50,7 @@ void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum)
50 .bt_first_slot_time = 5, 50 .bt_first_slot_time = 5,
51 .bt_hold_rx_clear = true, 51 .bt_hold_rx_clear = true,
52 }; 52 };
53 u32 i; 53 u32 i, idx;
54 bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity; 54 bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity;
55 55
56 if (AR_SREV_9300_20_OR_LATER(ah)) 56 if (AR_SREV_9300_20_OR_LATER(ah))
@@ -73,8 +73,10 @@ void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum)
73 SM(ATH_BTCOEX_BMISS_THRESH, AR_BT_BCN_MISS_THRESH) | 73 SM(ATH_BTCOEX_BMISS_THRESH, AR_BT_BCN_MISS_THRESH) |
74 AR_BT_DISABLE_BT_ANT; 74 AR_BT_DISABLE_BT_ANT;
75 75
76 for (i = 0; i < 32; i++) 76 for (i = 0; i < 32; i++) {
77 ah->hw_gen_timers.gen_timer_index[(debruijn32 << i) >> 27] = i; 77 idx = (debruijn32 << i) >> 27;
78 ah->hw_gen_timers.gen_timer_index[idx] = i;
79 }
78} 80}
79EXPORT_SYMBOL(ath9k_hw_init_btcoex_hw); 81EXPORT_SYMBOL(ath9k_hw_init_btcoex_hw);
80 82
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 22d3a26e684d..d1eb89611ff7 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -749,7 +749,6 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
749 char *buf; 749 char *buf;
750 unsigned int len = 0, size = 8000; 750 unsigned int len = 0, size = 8000;
751 ssize_t retval = 0; 751 ssize_t retval = 0;
752 const char *tmp;
753 unsigned int reg; 752 unsigned int reg;
754 struct ath9k_vif_iter_data iter_data; 753 struct ath9k_vif_iter_data iter_data;
755 754
@@ -759,31 +758,14 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
759 if (buf == NULL) 758 if (buf == NULL)
760 return -ENOMEM; 759 return -ENOMEM;
761 760
762 switch (sc->sc_ah->opmode) {
763 case NL80211_IFTYPE_ADHOC:
764 tmp = "ADHOC";
765 break;
766 case NL80211_IFTYPE_MESH_POINT:
767 tmp = "MESH";
768 break;
769 case NL80211_IFTYPE_AP:
770 tmp = "AP";
771 break;
772 case NL80211_IFTYPE_STATION:
773 tmp = "STATION";
774 break;
775 default:
776 tmp = "???";
777 break;
778 }
779
780 ath9k_ps_wakeup(sc); 761 ath9k_ps_wakeup(sc);
781 len += snprintf(buf + len, size - len, 762 len += snprintf(buf + len, size - len,
782 "curbssid: %pM\n" 763 "curbssid: %pM\n"
783 "OP-Mode: %s(%i)\n" 764 "OP-Mode: %s(%i)\n"
784 "Beacon-Timer-Register: 0x%x\n", 765 "Beacon-Timer-Register: 0x%x\n",
785 common->curbssid, 766 common->curbssid,
786 tmp, (int)(sc->sc_ah->opmode), 767 ath_opmode_to_string(sc->sc_ah->opmode),
768 (int)(sc->sc_ah->opmode),
787 REG_READ(ah, AR_BEACON_PERIOD)); 769 REG_READ(ah, AR_BEACON_PERIOD));
788 770
789 reg = REG_READ(ah, AR_TIMER_MODE); 771 reg = REG_READ(ah, AR_TIMER_MODE);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
index 5b1e894f3d67..47cc95086e6e 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
@@ -14,6 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <asm/unaligned.h>
17#include "hw.h" 18#include "hw.h"
18#include "ar9002_phy.h" 19#include "ar9002_phy.h"
19 20
@@ -203,11 +204,11 @@ static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah,
203 case EEP_NFTHRESH_2: 204 case EEP_NFTHRESH_2:
204 return pModal->noiseFloorThreshCh[0]; 205 return pModal->noiseFloorThreshCh[0];
205 case EEP_MAC_LSW: 206 case EEP_MAC_LSW:
206 return pBase->macAddr[0] << 8 | pBase->macAddr[1]; 207 return get_unaligned_be16(pBase->macAddr);
207 case EEP_MAC_MID: 208 case EEP_MAC_MID:
208 return pBase->macAddr[2] << 8 | pBase->macAddr[3]; 209 return get_unaligned_be16(pBase->macAddr + 2);
209 case EEP_MAC_MSW: 210 case EEP_MAC_MSW:
210 return pBase->macAddr[4] << 8 | pBase->macAddr[5]; 211 return get_unaligned_be16(pBase->macAddr + 4);
211 case EEP_REG_0: 212 case EEP_REG_0:
212 return pBase->regDmn[0]; 213 return pBase->regDmn[0];
213 case EEP_REG_1: 214 case EEP_REG_1:
@@ -331,10 +332,7 @@ static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
331 332
332 regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset; 333 regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset;
333 for (j = 0; j < 32; j++) { 334 for (j = 0; j < 32; j++) {
334 reg32 = ((pdadcValues[4 * j + 0] & 0xFF) << 0) | 335 reg32 = get_unaligned_le32(&pdadcValues[4 * j]);
335 ((pdadcValues[4 * j + 1] & 0xFF) << 8) |
336 ((pdadcValues[4 * j + 2] & 0xFF) << 16)|
337 ((pdadcValues[4 * j + 3] & 0xFF) << 24);
338 REG_WRITE(ah, regOffset, reg32); 336 REG_WRITE(ah, regOffset, reg32);
339 337
340 ath_dbg(common, ATH_DBG_EEPROM, 338 ath_dbg(common, ATH_DBG_EEPROM,
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 343fc9f946db..d6f6b192f450 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -14,6 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <asm/unaligned.h>
17#include "hw.h" 18#include "hw.h"
18#include "ar9002_phy.h" 19#include "ar9002_phy.h"
19 20
@@ -195,11 +196,11 @@ static u32 ath9k_hw_ar9287_get_eeprom(struct ath_hw *ah,
195 case EEP_NFTHRESH_2: 196 case EEP_NFTHRESH_2:
196 return pModal->noiseFloorThreshCh[0]; 197 return pModal->noiseFloorThreshCh[0];
197 case EEP_MAC_LSW: 198 case EEP_MAC_LSW:
198 return pBase->macAddr[0] << 8 | pBase->macAddr[1]; 199 return get_unaligned_be16(pBase->macAddr);
199 case EEP_MAC_MID: 200 case EEP_MAC_MID:
200 return pBase->macAddr[2] << 8 | pBase->macAddr[3]; 201 return get_unaligned_be16(pBase->macAddr + 2);
201 case EEP_MAC_MSW: 202 case EEP_MAC_MSW:
202 return pBase->macAddr[4] << 8 | pBase->macAddr[5]; 203 return get_unaligned_be16(pBase->macAddr + 4);
203 case EEP_REG_0: 204 case EEP_REG_0:
204 return pBase->regDmn[0]; 205 return pBase->regDmn[0];
205 case EEP_REG_1: 206 case EEP_REG_1:
@@ -434,10 +435,7 @@ static void ath9k_hw_set_ar9287_power_cal_table(struct ath_hw *ah,
434 (672 << 2) + regChainOffset; 435 (672 << 2) + regChainOffset;
435 436
436 for (j = 0; j < 32; j++) { 437 for (j = 0; j < 32; j++) {
437 reg32 = ((pdadcValues[4*j + 0] & 0xFF) << 0) 438 reg32 = get_unaligned_le32(&pdadcValues[4 * j]);
438 | ((pdadcValues[4*j + 1] & 0xFF) << 8)
439 | ((pdadcValues[4*j + 2] & 0xFF) << 16)
440 | ((pdadcValues[4*j + 3] & 0xFF) << 24);
441 439
442 REG_WRITE(ah, regOffset, reg32); 440 REG_WRITE(ah, regOffset, reg32);
443 regOffset += 4; 441 regOffset += 4;
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index 17f0a6806207..b9540a992616 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -14,6 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <asm/unaligned.h>
17#include "hw.h" 18#include "hw.h"
18#include "ar9002_phy.h" 19#include "ar9002_phy.h"
19 20
@@ -276,11 +277,11 @@ static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah,
276 case EEP_NFTHRESH_2: 277 case EEP_NFTHRESH_2:
277 return pModal[1].noiseFloorThreshCh[0]; 278 return pModal[1].noiseFloorThreshCh[0];
278 case EEP_MAC_LSW: 279 case EEP_MAC_LSW:
279 return pBase->macAddr[0] << 8 | pBase->macAddr[1]; 280 return get_unaligned_be16(pBase->macAddr);
280 case EEP_MAC_MID: 281 case EEP_MAC_MID:
281 return pBase->macAddr[2] << 8 | pBase->macAddr[3]; 282 return get_unaligned_be16(pBase->macAddr + 2);
282 case EEP_MAC_MSW: 283 case EEP_MAC_MSW:
283 return pBase->macAddr[4] << 8 | pBase->macAddr[5]; 284 return get_unaligned_be16(pBase->macAddr + 4);
284 case EEP_REG_0: 285 case EEP_REG_0:
285 return pBase->regDmn[0]; 286 return pBase->regDmn[0];
286 case EEP_REG_1: 287 case EEP_REG_1:
@@ -831,10 +832,7 @@ static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
831 832
832 regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset; 833 regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset;
833 for (j = 0; j < 32; j++) { 834 for (j = 0; j < 32; j++) {
834 reg32 = ((pdadcValues[4 * j + 0] & 0xFF) << 0) | 835 reg32 = get_unaligned_le32(&pdadcValues[4 * j]);
835 ((pdadcValues[4 * j + 1] & 0xFF) << 8) |
836 ((pdadcValues[4 * j + 2] & 0xFF) << 16)|
837 ((pdadcValues[4 * j + 3] & 0xFF) << 24);
838 REG_WRITE(ah, regOffset, reg32); 836 REG_WRITE(ah, regOffset, reg32);
839 837
840 ath_dbg(common, ATH_DBG_EEPROM, 838 ath_dbg(common, ATH_DBG_EEPROM,
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 8028fe90f666..d3f4a59cd456 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -14,6 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <asm/unaligned.h>
17#include "htc.h" 18#include "htc.h"
18 19
19/* identify firmware images */ 20/* identify firmware images */
@@ -129,12 +130,14 @@ static int hif_usb_send_regout(struct hif_device_usb *hif_dev,
129static void hif_usb_mgmt_cb(struct urb *urb) 130static void hif_usb_mgmt_cb(struct urb *urb)
130{ 131{
131 struct cmd_buf *cmd = (struct cmd_buf *)urb->context; 132 struct cmd_buf *cmd = (struct cmd_buf *)urb->context;
132 struct hif_device_usb *hif_dev = cmd->hif_dev; 133 struct hif_device_usb *hif_dev;
133 bool txok = true; 134 bool txok = true;
134 135
135 if (!cmd || !cmd->skb || !cmd->hif_dev) 136 if (!cmd || !cmd->skb || !cmd->hif_dev)
136 return; 137 return;
137 138
139 hif_dev = cmd->hif_dev;
140
138 switch (urb->status) { 141 switch (urb->status) {
139 case 0: 142 case 0:
140 break; 143 break;
@@ -557,8 +560,8 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
557 560
558 ptr = (u8 *) skb->data; 561 ptr = (u8 *) skb->data;
559 562
560 pkt_len = ptr[index] + (ptr[index+1] << 8); 563 pkt_len = get_unaligned_le16(ptr + index);
561 pkt_tag = ptr[index+2] + (ptr[index+3] << 8); 564 pkt_tag = get_unaligned_le16(ptr + index + 2);
562 565
563 if (pkt_tag != ATH_USB_RX_STREAM_MODE_TAG) { 566 if (pkt_tag != ATH_USB_RX_STREAM_MODE_TAG) {
564 RX_STAT_INC(skb_dropped); 567 RX_STAT_INC(skb_dropped);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
index aa48b3abbc48..d3ff33c71aa5 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -623,11 +623,8 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
623 pBase9287->openLoopPwrCntl); 623 pBase9287->openLoopPwrCntl);
624 } 624 }
625 625
626 len += snprintf(buf + len, size - len, 626 len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
627 "%20s : %02X:%02X:%02X:%02X:%02X:%02X\n", 627 pBase->macAddr);
628 "MacAddress",
629 pBase->macAddr[0], pBase->macAddr[1], pBase->macAddr[2],
630 pBase->macAddr[3], pBase->macAddr[4], pBase->macAddr[5]);
631 if (len > size) 628 if (len > size)
632 len = size; 629 len = size;
633 630
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 2a5f908d8037..8006ce0c7357 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1997,12 +1997,22 @@ EXPORT_SYMBOL(ath9k_hw_set_sta_beacon_timers);
1997/* HW Capabilities */ 1997/* HW Capabilities */
1998/*******************/ 1998/*******************/
1999 1999
2000static u8 fixup_chainmask(u8 chip_chainmask, u8 eeprom_chainmask)
2001{
2002 eeprom_chainmask &= chip_chainmask;
2003 if (eeprom_chainmask)
2004 return eeprom_chainmask;
2005 else
2006 return chip_chainmask;
2007}
2008
2000int ath9k_hw_fill_cap_info(struct ath_hw *ah) 2009int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2001{ 2010{
2002 struct ath9k_hw_capabilities *pCap = &ah->caps; 2011 struct ath9k_hw_capabilities *pCap = &ah->caps;
2003 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); 2012 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
2004 struct ath_common *common = ath9k_hw_common(ah); 2013 struct ath_common *common = ath9k_hw_common(ah);
2005 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; 2014 struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
2015 unsigned int chip_chainmask;
2006 2016
2007 u16 eeval; 2017 u16 eeval;
2008 u8 ant_div_ctl1, tx_chainmask, rx_chainmask; 2018 u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
@@ -2039,6 +2049,15 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2039 if (eeval & AR5416_OPFLAGS_11G) 2049 if (eeval & AR5416_OPFLAGS_11G)
2040 pCap->hw_caps |= ATH9K_HW_CAP_2GHZ; 2050 pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
2041 2051
2052 if (AR_SREV_9485(ah) || AR_SREV_9285(ah) || AR_SREV_9330(ah))
2053 chip_chainmask = 1;
2054 else if (!AR_SREV_9280_20_OR_LATER(ah))
2055 chip_chainmask = 7;
2056 else if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9340(ah))
2057 chip_chainmask = 3;
2058 else
2059 chip_chainmask = 7;
2060
2042 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK); 2061 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
2043 /* 2062 /*
2044 * For AR9271 we will temporarilly uses the rx chainmax as read from 2063 * For AR9271 we will temporarilly uses the rx chainmax as read from
@@ -2055,6 +2074,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
2055 /* Use rx_chainmask from EEPROM. */ 2074 /* Use rx_chainmask from EEPROM. */
2056 pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK); 2075 pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
2057 2076
2077 pCap->tx_chainmask = fixup_chainmask(chip_chainmask, pCap->tx_chainmask);
2078 pCap->rx_chainmask = fixup_chainmask(chip_chainmask, pCap->rx_chainmask);
2079
2058 ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA; 2080 ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
2059 2081
2060 /* enable key search for every frame in an aggregate */ 2082 /* enable key search for every frame in an aggregate */
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index b855fe1adc39..ac5107172f94 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -197,6 +197,19 @@ static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)
197 return val; 197 return val;
198} 198}
199 199
200static unsigned int __ath9k_reg_rmw(struct ath_softc *sc, u32 reg_offset,
201 u32 set, u32 clr)
202{
203 u32 val;
204
205 val = ioread32(sc->mem + reg_offset);
206 val &= ~clr;
207 val |= set;
208 iowrite32(val, sc->mem + reg_offset);
209
210 return val;
211}
212
200static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 clr) 213static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 clr)
201{ 214{
202 struct ath_hw *ah = (struct ath_hw *) hw_priv; 215 struct ath_hw *ah = (struct ath_hw *) hw_priv;
@@ -205,16 +218,12 @@ static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 cl
205 unsigned long uninitialized_var(flags); 218 unsigned long uninitialized_var(flags);
206 u32 val; 219 u32 val;
207 220
208 if (ah->config.serialize_regmode == SER_REG_MODE_ON) 221 if (ah->config.serialize_regmode == SER_REG_MODE_ON) {
209 spin_lock_irqsave(&sc->sc_serial_rw, flags); 222 spin_lock_irqsave(&sc->sc_serial_rw, flags);
210 223 val = __ath9k_reg_rmw(sc, reg_offset, set, clr);
211 val = ioread32(sc->mem + reg_offset);
212 val &= ~clr;
213 val |= set;
214 iowrite32(val, sc->mem + reg_offset);
215
216 if (ah->config.serialize_regmode == SER_REG_MODE_ON)
217 spin_unlock_irqrestore(&sc->sc_serial_rw, flags); 224 spin_unlock_irqrestore(&sc->sc_serial_rw, flags);
225 } else
226 val = __ath9k_reg_rmw(sc, reg_offset, set, clr);
218 227
219 return val; 228 return val;
220} 229}
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 70dc8ecdad4d..9a4850154fb2 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -815,16 +815,19 @@ static bool ath9k_rx_accept(struct ath_common *common,
815 struct ath_rx_status *rx_stats, 815 struct ath_rx_status *rx_stats,
816 bool *decrypt_error) 816 bool *decrypt_error)
817{ 817{
818#define is_mc_or_valid_tkip_keyix ((is_mc || \ 818 bool is_mc, is_valid_tkip, strip_mic, mic_error;
819 (rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID && \
820 test_bit(rx_stats->rs_keyix, common->tkip_keymap))))
821
822 struct ath_hw *ah = common->ah; 819 struct ath_hw *ah = common->ah;
823 __le16 fc; 820 __le16 fc;
824 u8 rx_status_len = ah->caps.rx_status_len; 821 u8 rx_status_len = ah->caps.rx_status_len;
825 822
826 fc = hdr->frame_control; 823 fc = hdr->frame_control;
827 824
825 is_mc = !!is_multicast_ether_addr(hdr->addr1);
826 is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
827 test_bit(rx_stats->rs_keyix, common->tkip_keymap);
828 strip_mic = is_valid_tkip && !(rx_stats->rs_status &
829 (ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC));
830
828 if (!rx_stats->rs_datalen) 831 if (!rx_stats->rs_datalen)
829 return false; 832 return false;
830 /* 833 /*
@@ -839,6 +842,11 @@ static bool ath9k_rx_accept(struct ath_common *common,
839 if (rx_stats->rs_more) 842 if (rx_stats->rs_more)
840 return true; 843 return true;
841 844
845 mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
846 !ieee80211_has_morefrags(fc) &&
847 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
848 (rx_stats->rs_status & ATH9K_RXERR_MIC);
849
842 /* 850 /*
843 * The rx_stats->rs_status will not be set until the end of the 851 * The rx_stats->rs_status will not be set until the end of the
844 * chained descriptors so it can be ignored if rs_more is set. The 852 * chained descriptors so it can be ignored if rs_more is set. The
@@ -846,30 +854,18 @@ static bool ath9k_rx_accept(struct ath_common *common,
846 * descriptors. 854 * descriptors.
847 */ 855 */
848 if (rx_stats->rs_status != 0) { 856 if (rx_stats->rs_status != 0) {
849 if (rx_stats->rs_status & ATH9K_RXERR_CRC) 857 if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
850 rxs->flag |= RX_FLAG_FAILED_FCS_CRC; 858 rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
859 mic_error = false;
860 }
851 if (rx_stats->rs_status & ATH9K_RXERR_PHY) 861 if (rx_stats->rs_status & ATH9K_RXERR_PHY)
852 return false; 862 return false;
853 863
854 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) { 864 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
855 *decrypt_error = true; 865 *decrypt_error = true;
856 } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) { 866 mic_error = false;
857 bool is_mc;
858 /*
859 * The MIC error bit is only valid if the frame
860 * is not a control frame or fragment, and it was
861 * decrypted using a valid TKIP key.
862 */
863 is_mc = !!is_multicast_ether_addr(hdr->addr1);
864
865 if (!ieee80211_is_ctl(fc) &&
866 !ieee80211_has_morefrags(fc) &&
867 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
868 is_mc_or_valid_tkip_keyix)
869 rxs->flag |= RX_FLAG_MMIC_ERROR;
870 else
871 rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
872 } 867 }
868
873 /* 869 /*
874 * Reject error frames with the exception of 870 * Reject error frames with the exception of
875 * decryption and MIC failures. For monitor mode, 871 * decryption and MIC failures. For monitor mode,
@@ -887,6 +883,18 @@ static bool ath9k_rx_accept(struct ath_common *common,
887 } 883 }
888 } 884 }
889 } 885 }
886
887 /*
888 * For unicast frames the MIC error bit can have false positives,
889 * so all MIC error reports need to be validated in software.
890 * False negatives are not common, so skip software verification
891 * if the hardware considers the MIC valid.
892 */
893 if (strip_mic)
894 rxs->flag |= RX_FLAG_MMIC_STRIPPED;
895 else if (is_mc && mic_error)
896 rxs->flag |= RX_FLAG_MMIC_ERROR;
897
890 return true; 898 return true;
891} 899}
892 900
@@ -1939,6 +1947,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1939 sc->rx.rxotherant = 0; 1947 sc->rx.rxotherant = 0;
1940 } 1948 }
1941 1949
1950 if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
1951 skb_trim(skb, skb->len - 8);
1952
1942 spin_lock_irqsave(&sc->sc_pm_lock, flags); 1953 spin_lock_irqsave(&sc->sc_pm_lock, flags);
1943 1954
1944 if ((sc->ps_flags & (PS_WAIT_FOR_BEACON | 1955 if ((sc->ps_flags & (PS_WAIT_FOR_BEACON |
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 759b72cca3cc..fa4c0bbce6b9 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -1873,29 +1873,6 @@ enum {
1873#define AR_RATE_DURATION(_n) (AR_RATE_DURATION_0 + ((_n)<<2)) 1873#define AR_RATE_DURATION(_n) (AR_RATE_DURATION_0 + ((_n)<<2))
1874 1874
1875 1875
1876#define AR_KEYTABLE_0 0x8800
1877#define AR_KEYTABLE(_n) (AR_KEYTABLE_0 + ((_n)*32))
1878#define AR_KEY_CACHE_SIZE 128
1879#define AR_RSVD_KEYTABLE_ENTRIES 4
1880#define AR_KEY_TYPE 0x00000007
1881#define AR_KEYTABLE_TYPE_40 0x00000000
1882#define AR_KEYTABLE_TYPE_104 0x00000001
1883#define AR_KEYTABLE_TYPE_128 0x00000003
1884#define AR_KEYTABLE_TYPE_TKIP 0x00000004
1885#define AR_KEYTABLE_TYPE_AES 0x00000005
1886#define AR_KEYTABLE_TYPE_CCM 0x00000006
1887#define AR_KEYTABLE_TYPE_CLR 0x00000007
1888#define AR_KEYTABLE_ANT 0x00000008
1889#define AR_KEYTABLE_VALID 0x00008000
1890#define AR_KEYTABLE_KEY0(_n) (AR_KEYTABLE(_n) + 0)
1891#define AR_KEYTABLE_KEY1(_n) (AR_KEYTABLE(_n) + 4)
1892#define AR_KEYTABLE_KEY2(_n) (AR_KEYTABLE(_n) + 8)
1893#define AR_KEYTABLE_KEY3(_n) (AR_KEYTABLE(_n) + 12)
1894#define AR_KEYTABLE_KEY4(_n) (AR_KEYTABLE(_n) + 16)
1895#define AR_KEYTABLE_TYPE(_n) (AR_KEYTABLE(_n) + 20)
1896#define AR_KEYTABLE_MAC0(_n) (AR_KEYTABLE(_n) + 24)
1897#define AR_KEYTABLE_MAC1(_n) (AR_KEYTABLE(_n) + 28)
1898
1899#define AR9271_CORE_CLOCK 117 /* clock to 117Mhz */ 1876#define AR9271_CORE_CLOCK 117 /* clock to 117Mhz */
1900#define AR9271_TARGET_BAUD_RATE 19200 /* 115200 */ 1877#define AR9271_TARGET_BAUD_RATE 19200 /* 115200 */
1901 1878
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 6eb58b16ab06..cc595712f518 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1148,6 +1148,8 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf)
1148 1148
1149static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq, 1149static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq,
1150 struct list_head *list, bool retry_tx) 1150 struct list_head *list, bool retry_tx)
1151 __releases(txq->axq_lock)
1152 __acquires(txq->axq_lock)
1151{ 1153{
1152 struct ath_buf *bf, *lastbf; 1154 struct ath_buf *bf, *lastbf;
1153 struct list_head bf_head; 1155 struct list_head bf_head;
@@ -2036,6 +2038,8 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
2036static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, 2038static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
2037 struct ath_tx_status *ts, struct ath_buf *bf, 2039 struct ath_tx_status *ts, struct ath_buf *bf,
2038 struct list_head *bf_head) 2040 struct list_head *bf_head)
2041 __releases(txq->axq_lock)
2042 __acquires(txq->axq_lock)
2039{ 2043{
2040 int txok; 2044 int txok;
2041 2045
diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
index f9a4655ea0b8..c5427a72a1e2 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -177,7 +177,7 @@ struct carl9170_tx_queue_stats {
177 177
178struct carl9170_vif { 178struct carl9170_vif {
179 unsigned int id; 179 unsigned int id;
180 struct ieee80211_vif *vif; 180 struct ieee80211_vif __rcu *vif;
181}; 181};
182 182
183struct carl9170_vif_info { 183struct carl9170_vif_info {
@@ -311,7 +311,7 @@ struct ar9170 {
311 spinlock_t beacon_lock; 311 spinlock_t beacon_lock;
312 unsigned int global_pretbtt; 312 unsigned int global_pretbtt;
313 unsigned int global_beacon_int; 313 unsigned int global_beacon_int;
314 struct carl9170_vif_info *beacon_iter; 314 struct carl9170_vif_info __rcu *beacon_iter;
315 unsigned int beacon_enabled; 315 unsigned int beacon_enabled;
316 316
317 /* cryptographic engine */ 317 /* cryptographic engine */
@@ -389,7 +389,7 @@ struct ar9170 {
389 /* tx ampdu */ 389 /* tx ampdu */
390 struct work_struct ampdu_work; 390 struct work_struct ampdu_work;
391 spinlock_t tx_ampdu_list_lock; 391 spinlock_t tx_ampdu_list_lock;
392 struct carl9170_sta_tid *tx_ampdu_iter; 392 struct carl9170_sta_tid __rcu *tx_ampdu_iter;
393 struct list_head tx_ampdu_list; 393 struct list_head tx_ampdu_list;
394 atomic_t tx_ampdu_upload; 394 atomic_t tx_ampdu_upload;
395 atomic_t tx_ampdu_scheduler; 395 atomic_t tx_ampdu_scheduler;
@@ -456,7 +456,7 @@ struct carl9170_sta_info {
456 bool sleeping; 456 bool sleeping;
457 atomic_t pending_frames; 457 atomic_t pending_frames;
458 unsigned int ampdu_max_len; 458 unsigned int ampdu_max_len;
459 struct carl9170_sta_tid *agg[CARL9170_NUM_TID]; 459 struct carl9170_sta_tid __rcu *agg[CARL9170_NUM_TID];
460 struct carl9170_ba_stats stats[CARL9170_NUM_TID]; 460 struct carl9170_ba_stats stats[CARL9170_NUM_TID];
461}; 461};
462 462
@@ -532,7 +532,6 @@ int carl9170_set_ampdu_settings(struct ar9170 *ar);
532int carl9170_set_slot_time(struct ar9170 *ar); 532int carl9170_set_slot_time(struct ar9170 *ar);
533int carl9170_set_mac_rates(struct ar9170 *ar); 533int carl9170_set_mac_rates(struct ar9170 *ar);
534int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry); 534int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry);
535int carl9170_update_beacon(struct ar9170 *ar, const bool submit);
536int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac, 535int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac,
537 const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen); 536 const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen);
538int carl9170_disable_key(struct ar9170 *ar, const u8 id); 537int carl9170_disable_key(struct ar9170 *ar, const u8 id);
@@ -553,6 +552,7 @@ void carl9170_tx_drop(struct ar9170 *ar, struct sk_buff *skb);
553void carl9170_tx_scheduler(struct ar9170 *ar); 552void carl9170_tx_scheduler(struct ar9170 *ar);
554void carl9170_tx_get_skb(struct sk_buff *skb); 553void carl9170_tx_get_skb(struct sk_buff *skb);
555int carl9170_tx_put_skb(struct sk_buff *skb); 554int carl9170_tx_put_skb(struct sk_buff *skb);
555int carl9170_update_beacon(struct ar9170 *ar, const bool submit);
556 556
557/* LEDs */ 557/* LEDs */
558#ifdef CONFIG_CARL9170_LEDS 558#ifdef CONFIG_CARL9170_LEDS
diff --git a/drivers/net/wireless/ath/carl9170/cmd.h b/drivers/net/wireless/ath/carl9170/cmd.h
index 568174c71b94..d5f95bdc75c1 100644
--- a/drivers/net/wireless/ath/carl9170/cmd.h
+++ b/drivers/net/wireless/ath/carl9170/cmd.h
@@ -87,7 +87,7 @@ do { \
87 __ar->cmd_buf[2 * __nreg + 1] = cpu_to_le32(r); \ 87 __ar->cmd_buf[2 * __nreg + 1] = cpu_to_le32(r); \
88 __ar->cmd_buf[2 * __nreg + 2] = cpu_to_le32(v); \ 88 __ar->cmd_buf[2 * __nreg + 2] = cpu_to_le32(v); \
89 __nreg++; \ 89 __nreg++; \
90 if ((__nreg >= PAYLOAD_MAX/2)) { \ 90 if ((__nreg >= PAYLOAD_MAX / 2)) { \
91 if (IS_ACCEPTING_CMD(__ar)) \ 91 if (IS_ACCEPTING_CMD(__ar)) \
92 __err = carl9170_exec_cmd(__ar, \ 92 __err = carl9170_exec_cmd(__ar, \
93 CARL9170_CMD_WREG, 8 * __nreg, \ 93 CARL9170_CMD_WREG, 8 * __nreg, \
@@ -160,7 +160,7 @@ do { \
160} while (0) 160} while (0)
161 161
162#define carl9170_async_regwrite_finish() do { \ 162#define carl9170_async_regwrite_finish() do { \
163__async_regwrite_out : \ 163__async_regwrite_out: \
164 if (__cmd != NULL && __err == 0) \ 164 if (__cmd != NULL && __err == 0) \
165 carl9170_async_regwrite_flush(); \ 165 carl9170_async_regwrite_flush(); \
166 kfree(__cmd); \ 166 kfree(__cmd); \
diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
index 0ac1124c2a0b..de57f90e1d5f 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -695,7 +695,7 @@ static char *carl9170_debugfs_bug_read(struct ar9170 *ar, char *buf,
695} 695}
696__DEBUGFS_DECLARE_RW_FILE(bug, 400, CARL9170_STOPPED); 696__DEBUGFS_DECLARE_RW_FILE(bug, 400, CARL9170_STOPPED);
697 697
698static const char *erp_modes[] = { 698static const char *const erp_modes[] = {
699 [CARL9170_ERP_INVALID] = "INVALID", 699 [CARL9170_ERP_INVALID] = "INVALID",
700 [CARL9170_ERP_AUTO] = "Automatic", 700 [CARL9170_ERP_AUTO] = "Automatic",
701 [CARL9170_ERP_MAC80211] = "Set by MAC80211", 701 [CARL9170_ERP_MAC80211] = "Set by MAC80211",
diff --git a/drivers/net/wireless/ath/carl9170/fwdesc.h b/drivers/net/wireless/ath/carl9170/fwdesc.h
index 7ba62bb77054..6d9c0891ce7f 100644
--- a/drivers/net/wireless/ath/carl9170/fwdesc.h
+++ b/drivers/net/wireless/ath/carl9170/fwdesc.h
@@ -75,6 +75,9 @@ enum carl9170fw_feature_list {
75 /* Firmware supports PSM in the 5GHZ Band */ 75 /* Firmware supports PSM in the 5GHZ Band */
76 CARL9170FW_FIXED_5GHZ_PSM, 76 CARL9170FW_FIXED_5GHZ_PSM,
77 77
78 /* HW (ANI, CCA, MIB) tally counters */
79 CARL9170FW_HW_COUNTERS,
80
78 /* KEEP LAST */ 81 /* KEEP LAST */
79 __CARL9170FW_FEATURE_NUM 82 __CARL9170FW_FEATURE_NUM
80}; 83};
diff --git a/drivers/net/wireless/ath/carl9170/hw.h b/drivers/net/wireless/ath/carl9170/hw.h
index 261f89351070..fa834c1460f0 100644
--- a/drivers/net/wireless/ath/carl9170/hw.h
+++ b/drivers/net/wireless/ath/carl9170/hw.h
@@ -174,6 +174,7 @@
174#define AR9170_MAC_SNIFFER_ENABLE_PROMISC BIT(0) 174#define AR9170_MAC_SNIFFER_ENABLE_PROMISC BIT(0)
175#define AR9170_MAC_SNIFFER_DEFAULTS 0x02000000 175#define AR9170_MAC_SNIFFER_DEFAULTS 0x02000000
176#define AR9170_MAC_REG_ENCRYPTION (AR9170_MAC_REG_BASE + 0x678) 176#define AR9170_MAC_REG_ENCRYPTION (AR9170_MAC_REG_BASE + 0x678)
177#define AR9170_MAC_ENCRYPTION_MGMT_RX_SOFTWARE BIT(2)
177#define AR9170_MAC_ENCRYPTION_RX_SOFTWARE BIT(3) 178#define AR9170_MAC_ENCRYPTION_RX_SOFTWARE BIT(3)
178#define AR9170_MAC_ENCRYPTION_DEFAULTS 0x70 179#define AR9170_MAC_ENCRYPTION_DEFAULTS 0x70
179 180
@@ -222,6 +223,12 @@
222#define AR9170_MAC_REG_TX_BLOCKACKS (AR9170_MAC_REG_BASE + 0x6c0) 223#define AR9170_MAC_REG_TX_BLOCKACKS (AR9170_MAC_REG_BASE + 0x6c0)
223#define AR9170_MAC_REG_NAV_COUNT (AR9170_MAC_REG_BASE + 0x6c4) 224#define AR9170_MAC_REG_NAV_COUNT (AR9170_MAC_REG_BASE + 0x6c4)
224#define AR9170_MAC_REG_BACKOFF_STATUS (AR9170_MAC_REG_BASE + 0x6c8) 225#define AR9170_MAC_REG_BACKOFF_STATUS (AR9170_MAC_REG_BASE + 0x6c8)
226#define AR9170_MAC_BACKOFF_CCA BIT(24)
227#define AR9170_MAC_BACKOFF_TX_PEX BIT(25)
228#define AR9170_MAC_BACKOFF_RX_PE BIT(26)
229#define AR9170_MAC_BACKOFF_MD_READY BIT(27)
230#define AR9170_MAC_BACKOFF_TX_PE BIT(28)
231
225#define AR9170_MAC_REG_TX_RETRY (AR9170_MAC_REG_BASE + 0x6cc) 232#define AR9170_MAC_REG_TX_RETRY (AR9170_MAC_REG_BASE + 0x6cc)
226 233
227#define AR9170_MAC_REG_TX_COMPLETE (AR9170_MAC_REG_BASE + 0x6d4) 234#define AR9170_MAC_REG_TX_COMPLETE (AR9170_MAC_REG_BASE + 0x6d4)
@@ -388,10 +395,40 @@
388 395
389#define AR9170_MAC_REG_BCN_CURR_ADDR (AR9170_MAC_REG_BASE + 0xd98) 396#define AR9170_MAC_REG_BCN_CURR_ADDR (AR9170_MAC_REG_BASE + 0xd98)
390#define AR9170_MAC_REG_BCN_COUNT (AR9170_MAC_REG_BASE + 0xd9c) 397#define AR9170_MAC_REG_BCN_COUNT (AR9170_MAC_REG_BASE + 0xd9c)
391
392
393#define AR9170_MAC_REG_BCN_HT1 (AR9170_MAC_REG_BASE + 0xda0) 398#define AR9170_MAC_REG_BCN_HT1 (AR9170_MAC_REG_BASE + 0xda0)
399#define AR9170_MAC_BCN_HT1_HT_EN BIT(0)
400#define AR9170_MAC_BCN_HT1_GF_PMB BIT(1)
401#define AR9170_MAC_BCN_HT1_SP_EXP BIT(2)
402#define AR9170_MAC_BCN_HT1_TX_BF BIT(3)
403#define AR9170_MAC_BCN_HT1_PWR_CTRL_S 4
404#define AR9170_MAC_BCN_HT1_PWR_CTRL 0x70
405#define AR9170_MAC_BCN_HT1_TX_ANT1 BIT(7)
406#define AR9170_MAC_BCN_HT1_TX_ANT0 BIT(8)
407#define AR9170_MAC_BCN_HT1_NUM_LFT_S 9
408#define AR9170_MAC_BCN_HT1_NUM_LFT 0x600
409#define AR9170_MAC_BCN_HT1_BWC_20M_EXT BIT(16)
410#define AR9170_MAC_BCN_HT1_BWC_40M_SHARED BIT(17)
411#define AR9170_MAC_BCN_HT1_BWC_40M_DUP (BIT(16) | BIT(17))
412#define AR9170_MAC_BCN_HT1_BF_MCS_S 18
413#define AR9170_MAC_BCN_HT1_BF_MCS 0x1c0000
414#define AR9170_MAC_BCN_HT1_TPC_S 21
415#define AR9170_MAC_BCN_HT1_TPC 0x7e00000
416#define AR9170_MAC_BCN_HT1_CHAIN_MASK_S 27
417#define AR9170_MAC_BCN_HT1_CHAIN_MASK 0x38000000
418
394#define AR9170_MAC_REG_BCN_HT2 (AR9170_MAC_REG_BASE + 0xda4) 419#define AR9170_MAC_REG_BCN_HT2 (AR9170_MAC_REG_BASE + 0xda4)
420#define AR9170_MAC_BCN_HT2_MCS_S 0
421#define AR9170_MAC_BCN_HT2_MCS 0x7f
422#define AR9170_MAC_BCN_HT2_BW40 BIT(8)
423#define AR9170_MAC_BCN_HT2_SMOOTHING BIT(9)
424#define AR9170_MAC_BCN_HT2_SS BIT(10)
425#define AR9170_MAC_BCN_HT2_NSS BIT(11)
426#define AR9170_MAC_BCN_HT2_STBC_S 12
427#define AR9170_MAC_BCN_HT2_STBC 0x3000
428#define AR9170_MAC_BCN_HT2_ADV_COD BIT(14)
429#define AR9170_MAC_BCN_HT2_SGI BIT(15)
430#define AR9170_MAC_BCN_HT2_LEN_S 16
431#define AR9170_MAC_BCN_HT2_LEN 0xffff0000
395 432
396#define AR9170_MAC_REG_DMA_TXQX_ADDR_CURR (AR9170_MAC_REG_BASE + 0xdc0) 433#define AR9170_MAC_REG_DMA_TXQX_ADDR_CURR (AR9170_MAC_REG_BASE + 0xdc0)
397 434
diff --git a/drivers/net/wireless/ath/carl9170/led.c b/drivers/net/wireless/ath/carl9170/led.c
index 4bb2cbd8bd9b..78dadc797558 100644
--- a/drivers/net/wireless/ath/carl9170/led.c
+++ b/drivers/net/wireless/ath/carl9170/led.c
@@ -118,7 +118,7 @@ static void carl9170_led_set_brightness(struct led_classdev *led,
118 } 118 }
119 119
120 if (likely(IS_ACCEPTING_CMD(ar) && arl->toggled)) 120 if (likely(IS_ACCEPTING_CMD(ar) && arl->toggled))
121 ieee80211_queue_delayed_work(ar->hw, &ar->led_work, HZ/10); 121 ieee80211_queue_delayed_work(ar->hw, &ar->led_work, HZ / 10);
122} 122}
123 123
124static int carl9170_led_register_led(struct ar9170 *ar, int i, char *name, 124static int carl9170_led_register_led(struct ar9170 *ar, int i, char *name,
diff --git a/drivers/net/wireless/ath/carl9170/mac.c b/drivers/net/wireless/ath/carl9170/mac.c
index 385cf508479b..dfda91970995 100644
--- a/drivers/net/wireless/ath/carl9170/mac.c
+++ b/drivers/net/wireless/ath/carl9170/mac.c
@@ -455,135 +455,6 @@ int carl9170_set_beacon_timers(struct ar9170 *ar)
455 return carl9170_regwrite_result(); 455 return carl9170_regwrite_result();
456} 456}
457 457
458int carl9170_update_beacon(struct ar9170 *ar, const bool submit)
459{
460 struct sk_buff *skb = NULL;
461 struct carl9170_vif_info *cvif;
462 struct ieee80211_tx_info *txinfo;
463 __le32 *data, *old = NULL;
464 u32 word, off, addr, len;
465 int i = 0, err = 0;
466
467 rcu_read_lock();
468 cvif = rcu_dereference(ar->beacon_iter);
469retry:
470 if (ar->vifs == 0 || !cvif)
471 goto out_unlock;
472
473 list_for_each_entry_continue_rcu(cvif, &ar->vif_list, list) {
474 if (cvif->active && cvif->enable_beacon)
475 goto found;
476 }
477
478 if (!ar->beacon_enabled || i++)
479 goto out_unlock;
480
481 goto retry;
482
483found:
484 rcu_assign_pointer(ar->beacon_iter, cvif);
485
486 skb = ieee80211_beacon_get_tim(ar->hw, carl9170_get_vif(cvif),
487 NULL, NULL);
488
489 if (!skb) {
490 err = -ENOMEM;
491 goto err_free;
492 }
493
494 txinfo = IEEE80211_SKB_CB(skb);
495 if (txinfo->control.rates[0].flags & IEEE80211_TX_RC_MCS) {
496 err = -EINVAL;
497 goto err_free;
498 }
499
500 spin_lock_bh(&ar->beacon_lock);
501 data = (__le32 *)skb->data;
502 if (cvif->beacon)
503 old = (__le32 *)cvif->beacon->data;
504
505 off = cvif->id * AR9170_MAC_BCN_LENGTH_MAX;
506 addr = ar->fw.beacon_addr + off;
507 len = roundup(skb->len + FCS_LEN, 4);
508
509 if ((off + len) > ar->fw.beacon_max_len) {
510 if (net_ratelimit()) {
511 wiphy_err(ar->hw->wiphy, "beacon does not "
512 "fit into device memory!\n");
513 }
514 err = -EINVAL;
515 goto err_unlock;
516 }
517
518 if (len > AR9170_MAC_BCN_LENGTH_MAX) {
519 if (net_ratelimit()) {
520 wiphy_err(ar->hw->wiphy, "no support for beacons "
521 "bigger than %d (yours:%d).\n",
522 AR9170_MAC_BCN_LENGTH_MAX, len);
523 }
524
525 err = -EMSGSIZE;
526 goto err_unlock;
527 }
528
529 i = txinfo->control.rates[0].idx;
530 if (txinfo->band != IEEE80211_BAND_2GHZ)
531 i += 4;
532
533 word = __carl9170_ratetable[i].hw_value & 0xf;
534 if (i < 4)
535 word |= ((skb->len + FCS_LEN) << (3 + 16)) + 0x0400;
536 else
537 word |= ((skb->len + FCS_LEN) << 16) + 0x0010;
538
539 carl9170_async_regwrite_begin(ar);
540 carl9170_async_regwrite(AR9170_MAC_REG_BCN_PLCP, word);
541
542 for (i = 0; i < DIV_ROUND_UP(skb->len, 4); i++) {
543 /*
544 * XXX: This accesses beyond skb data for up
545 * to the last 3 bytes!!
546 */
547
548 if (old && (data[i] == old[i]))
549 continue;
550
551 word = le32_to_cpu(data[i]);
552 carl9170_async_regwrite(addr + 4 * i, word);
553 }
554 carl9170_async_regwrite_finish();
555
556 dev_kfree_skb_any(cvif->beacon);
557 cvif->beacon = NULL;
558
559 err = carl9170_async_regwrite_result();
560 if (!err)
561 cvif->beacon = skb;
562 spin_unlock_bh(&ar->beacon_lock);
563 if (err)
564 goto err_free;
565
566 if (submit) {
567 err = carl9170_bcn_ctrl(ar, cvif->id,
568 CARL9170_BCN_CTRL_CAB_TRIGGER,
569 addr, skb->len + FCS_LEN);
570
571 if (err)
572 goto err_free;
573 }
574out_unlock:
575 rcu_read_unlock();
576 return 0;
577
578err_unlock:
579 spin_unlock_bh(&ar->beacon_lock);
580
581err_free:
582 rcu_read_unlock();
583 dev_kfree_skb_any(skb);
584 return err;
585}
586
587int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac, 458int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac,
588 const u8 ktype, const u8 keyidx, const u8 *keydata, 459 const u8 ktype, const u8 keyidx, const u8 *keydata,
589 const int keylen) 460 const int keylen)
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index a61cf6781d5e..0122930b14c7 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1630,7 +1630,7 @@ static int carl9170_read_eeprom(struct ar9170 *ar)
1630 BUILD_BUG_ON(sizeof(ar->eeprom) % RB); 1630 BUILD_BUG_ON(sizeof(ar->eeprom) % RB);
1631#endif 1631#endif
1632 1632
1633 for (i = 0; i < sizeof(ar->eeprom)/RB; i++) { 1633 for (i = 0; i < sizeof(ar->eeprom) / RB; i++) {
1634 for (j = 0; j < RW; j++) 1634 for (j = 0; j < RW; j++)
1635 offsets[j] = cpu_to_le32(AR9170_EEPROM_START + 1635 offsets[j] = cpu_to_le32(AR9170_EEPROM_START +
1636 RB * i + 4 * j); 1636 RB * i + 4 * j);
diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c
index da1ab962ee48..aa147a9120b6 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -1098,7 +1098,7 @@ static u8 carl9170_interpolate_u8(u8 x, u8 x1, u8 y1, u8 x2, u8 y2)
1098 * Isn't it just DIV_ROUND_UP(y, 1<<SHIFT)? 1098 * Isn't it just DIV_ROUND_UP(y, 1<<SHIFT)?
1099 * Can we rely on the compiler to optimise away the div? 1099 * Can we rely on the compiler to optimise away the div?
1100 */ 1100 */
1101 return (y >> SHIFT) + ((y & (1<<(SHIFT-1))) >> (SHIFT - 1)); 1101 return (y >> SHIFT) + ((y & (1 << (SHIFT - 1))) >> (SHIFT - 1));
1102#undef SHIFT 1102#undef SHIFT
1103} 1103}
1104 1104
@@ -1379,7 +1379,7 @@ static void carl9170_calc_ctl(struct ar9170 *ar, u32 freq, enum carl9170_bw bw)
1379 1379
1380 modes[i].max_power = 1380 modes[i].max_power =
1381 carl9170_get_max_edge_power(ar, 1381 carl9170_get_max_edge_power(ar,
1382 freq+f_off, EDGES(ctl_idx, 1)); 1382 freq + f_off, EDGES(ctl_idx, 1));
1383 1383
1384 /* 1384 /*
1385 * TODO: check if the regulatory max. power is 1385 * TODO: check if the regulatory max. power is
@@ -1441,7 +1441,7 @@ static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq,
1441 if (freq < 3000) 1441 if (freq < 3000)
1442 f = freq - 2300; 1442 f = freq - 2300;
1443 else 1443 else
1444 f = (freq - 4800)/5; 1444 f = (freq - 4800) / 5;
1445 1445
1446 /* 1446 /*
1447 * cycle through the various modes 1447 * cycle through the various modes
diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c
index e94084fcf6f5..d20946939cd8 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -661,11 +661,67 @@ void carl9170_tx_process_status(struct ar9170 *ar,
661 } 661 }
662} 662}
663 663
664static void carl9170_tx_rate_tpc_chains(struct ar9170 *ar,
665 struct ieee80211_tx_info *info, struct ieee80211_tx_rate *txrate,
666 unsigned int *phyrate, unsigned int *tpc, unsigned int *chains)
667{
668 struct ieee80211_rate *rate = NULL;
669 u8 *txpower;
670 unsigned int idx;
671
672 idx = txrate->idx;
673 *tpc = 0;
674 *phyrate = 0;
675
676 if (txrate->flags & IEEE80211_TX_RC_MCS) {
677 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
678 /* +1 dBm for HT40 */
679 *tpc += 2;
680
681 if (info->band == IEEE80211_BAND_2GHZ)
682 txpower = ar->power_2G_ht40;
683 else
684 txpower = ar->power_5G_ht40;
685 } else {
686 if (info->band == IEEE80211_BAND_2GHZ)
687 txpower = ar->power_2G_ht20;
688 else
689 txpower = ar->power_5G_ht20;
690 }
691
692 *phyrate = txrate->idx;
693 *tpc += txpower[idx & 7];
694 } else {
695 if (info->band == IEEE80211_BAND_2GHZ) {
696 if (idx < 4)
697 txpower = ar->power_2G_cck;
698 else
699 txpower = ar->power_2G_ofdm;
700 } else {
701 txpower = ar->power_5G_leg;
702 idx += 4;
703 }
704
705 rate = &__carl9170_ratetable[idx];
706 *tpc += txpower[(rate->hw_value & 0x30) >> 4];
707 *phyrate = rate->hw_value & 0xf;
708 }
709
710 if (ar->eeprom.tx_mask == 1) {
711 *chains = AR9170_TX_PHY_TXCHAIN_1;
712 } else {
713 if (!(txrate->flags & IEEE80211_TX_RC_MCS) &&
714 rate && rate->bitrate >= 360)
715 *chains = AR9170_TX_PHY_TXCHAIN_1;
716 else
717 *chains = AR9170_TX_PHY_TXCHAIN_2;
718 }
719}
720
664static __le32 carl9170_tx_physet(struct ar9170 *ar, 721static __le32 carl9170_tx_physet(struct ar9170 *ar,
665 struct ieee80211_tx_info *info, struct ieee80211_tx_rate *txrate) 722 struct ieee80211_tx_info *info, struct ieee80211_tx_rate *txrate)
666{ 723{
667 struct ieee80211_rate *rate = NULL; 724 unsigned int power = 0, chains = 0, phyrate = 0;
668 u32 power, chains;
669 __le32 tmp; 725 __le32 tmp;
670 726
671 tmp = cpu_to_le32(0); 727 tmp = cpu_to_le32(0);
@@ -682,35 +738,12 @@ static __le32 carl9170_tx_physet(struct ar9170 *ar,
682 tmp |= cpu_to_le32(AR9170_TX_PHY_SHORT_GI); 738 tmp |= cpu_to_le32(AR9170_TX_PHY_SHORT_GI);
683 739
684 if (txrate->flags & IEEE80211_TX_RC_MCS) { 740 if (txrate->flags & IEEE80211_TX_RC_MCS) {
685 u32 r = txrate->idx; 741 SET_VAL(AR9170_TX_PHY_MCS, phyrate, txrate->idx);
686 u8 *txpower;
687 742
688 /* heavy clip control */ 743 /* heavy clip control */
689 tmp |= cpu_to_le32((r & 0x7) << 744 tmp |= cpu_to_le32((txrate->idx & 0x7) <<
690 AR9170_TX_PHY_TX_HEAVY_CLIP_S); 745 AR9170_TX_PHY_TX_HEAVY_CLIP_S);
691 746
692 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
693 if (info->band == IEEE80211_BAND_5GHZ)
694 txpower = ar->power_5G_ht40;
695 else
696 txpower = ar->power_2G_ht40;
697 } else {
698 if (info->band == IEEE80211_BAND_5GHZ)
699 txpower = ar->power_5G_ht20;
700 else
701 txpower = ar->power_2G_ht20;
702 }
703
704 power = txpower[r & 7];
705
706 /* +1 dBm for HT40 */
707 if (txrate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
708 power += 2;
709
710 r <<= AR9170_TX_PHY_MCS_S;
711 BUG_ON(r & ~AR9170_TX_PHY_MCS);
712
713 tmp |= cpu_to_le32(r & AR9170_TX_PHY_MCS);
714 tmp |= cpu_to_le32(AR9170_TX_PHY_MOD_HT); 747 tmp |= cpu_to_le32(AR9170_TX_PHY_MOD_HT);
715 748
716 /* 749 /*
@@ -720,34 +753,15 @@ static __le32 carl9170_tx_physet(struct ar9170 *ar,
720 * tmp |= cpu_to_le32(AR9170_TX_PHY_GREENFIELD); 753 * tmp |= cpu_to_le32(AR9170_TX_PHY_GREENFIELD);
721 */ 754 */
722 } else { 755 } else {
723 u8 *txpower; 756 if (info->band == IEEE80211_BAND_2GHZ) {
724 u32 mod; 757 if (txrate->idx <= AR9170_TX_PHY_RATE_CCK_11M)
725 u32 phyrate; 758 tmp |= cpu_to_le32(AR9170_TX_PHY_MOD_CCK);
726 u8 idx = txrate->idx; 759 else
727 760 tmp |= cpu_to_le32(AR9170_TX_PHY_MOD_OFDM);
728 if (info->band != IEEE80211_BAND_2GHZ) {
729 idx += 4;
730 txpower = ar->power_5G_leg;
731 mod = AR9170_TX_PHY_MOD_OFDM;
732 } else { 761 } else {
733 if (idx < 4) { 762 tmp |= cpu_to_le32(AR9170_TX_PHY_MOD_OFDM);
734 txpower = ar->power_2G_cck;
735 mod = AR9170_TX_PHY_MOD_CCK;
736 } else {
737 mod = AR9170_TX_PHY_MOD_OFDM;
738 txpower = ar->power_2G_ofdm;
739 }
740 } 763 }
741 764
742 rate = &__carl9170_ratetable[idx];
743
744 phyrate = rate->hw_value & 0xF;
745 power = txpower[(rate->hw_value & 0x30) >> 4];
746 phyrate <<= AR9170_TX_PHY_MCS_S;
747
748 tmp |= cpu_to_le32(mod);
749 tmp |= cpu_to_le32(phyrate);
750
751 /* 765 /*
752 * short preamble seems to be broken too. 766 * short preamble seems to be broken too.
753 * 767 *
@@ -755,23 +769,12 @@ static __le32 carl9170_tx_physet(struct ar9170 *ar,
755 * tmp |= cpu_to_le32(AR9170_TX_PHY_SHORT_PREAMBLE); 769 * tmp |= cpu_to_le32(AR9170_TX_PHY_SHORT_PREAMBLE);
756 */ 770 */
757 } 771 }
758 power <<= AR9170_TX_PHY_TX_PWR_S; 772 carl9170_tx_rate_tpc_chains(ar, info, txrate,
759 power &= AR9170_TX_PHY_TX_PWR; 773 &phyrate, &power, &chains);
760 tmp |= cpu_to_le32(power);
761
762 /* set TX chains */
763 if (ar->eeprom.tx_mask == 1) {
764 chains = AR9170_TX_PHY_TXCHAIN_1;
765 } else {
766 chains = AR9170_TX_PHY_TXCHAIN_2;
767
768 /* >= 36M legacy OFDM - use only one chain */
769 if (rate && rate->bitrate >= 360 &&
770 !(txrate->flags & IEEE80211_TX_RC_MCS))
771 chains = AR9170_TX_PHY_TXCHAIN_1;
772 }
773 tmp |= cpu_to_le32(chains << AR9170_TX_PHY_TXCHAIN_S);
774 774
775 tmp |= cpu_to_le32(SET_CONSTVAL(AR9170_TX_PHY_MCS, phyrate));
776 tmp |= cpu_to_le32(SET_CONSTVAL(AR9170_TX_PHY_TX_PWR, power));
777 tmp |= cpu_to_le32(SET_CONSTVAL(AR9170_TX_PHY_TXCHAIN, chains));
775 return tmp; 778 return tmp;
776} 779}
777 780
@@ -1438,3 +1441,154 @@ void carl9170_tx_scheduler(struct ar9170 *ar)
1438 if (ar->tx_schedule) 1441 if (ar->tx_schedule)
1439 carl9170_tx(ar); 1442 carl9170_tx(ar);
1440} 1443}
1444
1445int carl9170_update_beacon(struct ar9170 *ar, const bool submit)
1446{
1447 struct sk_buff *skb = NULL;
1448 struct carl9170_vif_info *cvif;
1449 struct ieee80211_tx_info *txinfo;
1450 struct ieee80211_tx_rate *rate;
1451 __le32 *data, *old = NULL;
1452 unsigned int plcp, power, chains;
1453 u32 word, ht1, off, addr, len;
1454 int i = 0, err = 0;
1455
1456 rcu_read_lock();
1457 cvif = rcu_dereference(ar->beacon_iter);
1458retry:
1459 if (ar->vifs == 0 || !cvif)
1460 goto out_unlock;
1461
1462 list_for_each_entry_continue_rcu(cvif, &ar->vif_list, list) {
1463 if (cvif->active && cvif->enable_beacon)
1464 goto found;
1465 }
1466
1467 if (!ar->beacon_enabled || i++)
1468 goto out_unlock;
1469
1470 goto retry;
1471
1472found:
1473 rcu_assign_pointer(ar->beacon_iter, cvif);
1474
1475 skb = ieee80211_beacon_get_tim(ar->hw, carl9170_get_vif(cvif),
1476 NULL, NULL);
1477
1478 if (!skb) {
1479 err = -ENOMEM;
1480 goto err_free;
1481 }
1482
1483 txinfo = IEEE80211_SKB_CB(skb);
1484 spin_lock_bh(&ar->beacon_lock);
1485 data = (__le32 *)skb->data;
1486 if (cvif->beacon)
1487 old = (__le32 *)cvif->beacon->data;
1488
1489 off = cvif->id * AR9170_MAC_BCN_LENGTH_MAX;
1490 addr = ar->fw.beacon_addr + off;
1491 len = roundup(skb->len + FCS_LEN, 4);
1492
1493 if ((off + len) > ar->fw.beacon_max_len) {
1494 if (net_ratelimit()) {
1495 wiphy_err(ar->hw->wiphy, "beacon does not "
1496 "fit into device memory!\n");
1497 }
1498 err = -EINVAL;
1499 goto err_unlock;
1500 }
1501
1502 if (len > AR9170_MAC_BCN_LENGTH_MAX) {
1503 if (net_ratelimit()) {
1504 wiphy_err(ar->hw->wiphy, "no support for beacons "
1505 "bigger than %d (yours:%d).\n",
1506 AR9170_MAC_BCN_LENGTH_MAX, len);
1507 }
1508
1509 err = -EMSGSIZE;
1510 goto err_unlock;
1511 }
1512
1513 ht1 = AR9170_MAC_BCN_HT1_TX_ANT0;
1514 rate = &txinfo->control.rates[0];
1515 carl9170_tx_rate_tpc_chains(ar, txinfo, rate, &plcp, &power, &chains);
1516 if (!(txinfo->control.rates[0].flags & IEEE80211_TX_RC_MCS)) {
1517 if (plcp <= AR9170_TX_PHY_RATE_CCK_11M)
1518 plcp |= ((skb->len + FCS_LEN) << (3 + 16)) + 0x0400;
1519 else
1520 plcp |= ((skb->len + FCS_LEN) << 16) + 0x0010;
1521 } else {
1522 ht1 |= AR9170_MAC_BCN_HT1_HT_EN;
1523 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
1524 plcp |= AR9170_MAC_BCN_HT2_SGI;
1525
1526 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
1527 ht1 |= AR9170_MAC_BCN_HT1_BWC_40M_SHARED;
1528 plcp |= AR9170_MAC_BCN_HT2_BW40;
1529 }
1530 if (rate->flags & IEEE80211_TX_RC_DUP_DATA) {
1531 ht1 |= AR9170_MAC_BCN_HT1_BWC_40M_DUP;
1532 plcp |= AR9170_MAC_BCN_HT2_BW40;
1533 }
1534
1535 SET_VAL(AR9170_MAC_BCN_HT2_LEN, plcp, skb->len + FCS_LEN);
1536 }
1537
1538 SET_VAL(AR9170_MAC_BCN_HT1_PWR_CTRL, ht1, 7);
1539 SET_VAL(AR9170_MAC_BCN_HT1_TPC, ht1, power);
1540 SET_VAL(AR9170_MAC_BCN_HT1_CHAIN_MASK, ht1, chains);
1541 if (chains == AR9170_TX_PHY_TXCHAIN_2)
1542 ht1 |= AR9170_MAC_BCN_HT1_TX_ANT1;
1543
1544 carl9170_async_regwrite_begin(ar);
1545 carl9170_async_regwrite(AR9170_MAC_REG_BCN_HT1, ht1);
1546 if (!(txinfo->control.rates[0].flags & IEEE80211_TX_RC_MCS))
1547 carl9170_async_regwrite(AR9170_MAC_REG_BCN_PLCP, plcp);
1548 else
1549 carl9170_async_regwrite(AR9170_MAC_REG_BCN_HT2, plcp);
1550
1551 for (i = 0; i < DIV_ROUND_UP(skb->len, 4); i++) {
1552 /*
1553 * XXX: This accesses beyond skb data for up
1554 * to the last 3 bytes!!
1555 */
1556
1557 if (old && (data[i] == old[i]))
1558 continue;
1559
1560 word = le32_to_cpu(data[i]);
1561 carl9170_async_regwrite(addr + 4 * i, word);
1562 }
1563 carl9170_async_regwrite_finish();
1564
1565 dev_kfree_skb_any(cvif->beacon);
1566 cvif->beacon = NULL;
1567
1568 err = carl9170_async_regwrite_result();
1569 if (!err)
1570 cvif->beacon = skb;
1571 spin_unlock_bh(&ar->beacon_lock);
1572 if (err)
1573 goto err_free;
1574
1575 if (submit) {
1576 err = carl9170_bcn_ctrl(ar, cvif->id,
1577 CARL9170_BCN_CTRL_CAB_TRIGGER,
1578 addr, skb->len + FCS_LEN);
1579
1580 if (err)
1581 goto err_free;
1582 }
1583out_unlock:
1584 rcu_read_unlock();
1585 return 0;
1586
1587err_unlock:
1588 spin_unlock_bh(&ar->beacon_lock);
1589
1590err_free:
1591 rcu_read_unlock();
1592 dev_kfree_skb_any(skb);
1593 return err;
1594}
diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c
index a61ef3d6d89c..17b0efd86f9a 100644
--- a/drivers/net/wireless/ath/key.c
+++ b/drivers/net/wireless/ath/key.c
@@ -105,11 +105,8 @@ static bool ath_hw_keysetmac(struct ath_common *common,
105 if (mac[0] & 0x01) 105 if (mac[0] & 0x01)
106 unicast_flag = 0; 106 unicast_flag = 0;
107 107
108 macHi = (mac[5] << 8) | mac[4]; 108 macLo = get_unaligned_le32(mac);
109 macLo = (mac[3] << 24) | 109 macHi = get_unaligned_le16(mac + 4);
110 (mac[2] << 16) |
111 (mac[1] << 8) |
112 mac[0];
113 macLo >>= 1; 110 macLo >>= 1;
114 macLo |= (macHi & 1) << 31; 111 macLo |= (macHi & 1) << 31;
115 macHi >>= 1; 112 macHi >>= 1;
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 08a28270bbb3..c818b0bc88ec 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -433,6 +433,12 @@ enum {
433#define B43_BCMA_IOCTL_PHY_BW_40MHZ 0x00000080 /* 40 MHz bandwidth, 160 MHz PHY */ 433#define B43_BCMA_IOCTL_PHY_BW_40MHZ 0x00000080 /* 40 MHz bandwidth, 160 MHz PHY */
434#define B43_BCMA_IOCTL_GMODE 0x00002000 /* G Mode Enable */ 434#define B43_BCMA_IOCTL_GMODE 0x00002000 /* G Mode Enable */
435 435
436/* BCMA 802.11 core specific IO status (BCMA_IOST) flags */
437#define B43_BCMA_IOST_2G_PHY 0x00000001 /* 2.4G capable phy */
438#define B43_BCMA_IOST_5G_PHY 0x00000002 /* 5G capable phy */
439#define B43_BCMA_IOST_FASTCLKA 0x00000004 /* Fast Clock Available */
440#define B43_BCMA_IOST_DUALB_PHY 0x00000008 /* Dualband phy */
441
436/* 802.11 core specific TM State Low (SSB_TMSLOW) flags */ 442/* 802.11 core specific TM State Low (SSB_TMSLOW) flags */
437#define B43_TMSLOW_GMODE 0x20000000 /* G Mode Enable */ 443#define B43_TMSLOW_GMODE 0x20000000 /* G Mode Enable */
438#define B43_TMSLOW_PHY_BANDWIDTH 0x00C00000 /* PHY band width and clock speed mask (N-PHY only) */ 444#define B43_TMSLOW_PHY_BANDWIDTH 0x00C00000 /* PHY band width and clock speed mask (N-PHY only) */
@@ -588,6 +594,7 @@ struct b43_dma {
588 struct b43_dmaring *rx_ring; 594 struct b43_dmaring *rx_ring;
589 595
590 u32 translation; /* Routing bits */ 596 u32 translation; /* Routing bits */
597 bool parity; /* Check for parity */
591}; 598};
592 599
593struct b43_pio_txqueue; 600struct b43_pio_txqueue;
diff --git a/drivers/net/wireless/b43/bus.c b/drivers/net/wireless/b43/bus.c
index a5e61a9fb539..64c3f65ff8c0 100644
--- a/drivers/net/wireless/b43/bus.c
+++ b/drivers/net/wireless/b43/bus.c
@@ -126,55 +126,52 @@ struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core)
126 126
127/* SSB */ 127/* SSB */
128#ifdef CONFIG_B43_SSB 128#ifdef CONFIG_B43_SSB
129static inline int b43_bus_ssb_bus_may_powerdown(struct b43_bus_dev *dev) 129static int b43_bus_ssb_bus_may_powerdown(struct b43_bus_dev *dev)
130{ 130{
131 return ssb_bus_may_powerdown(dev->sdev->bus); 131 return ssb_bus_may_powerdown(dev->sdev->bus);
132} 132}
133static inline int b43_bus_ssb_bus_powerup(struct b43_bus_dev *dev, 133static int b43_bus_ssb_bus_powerup(struct b43_bus_dev *dev,
134 bool dynamic_pctl) 134 bool dynamic_pctl)
135{ 135{
136 return ssb_bus_powerup(dev->sdev->bus, dynamic_pctl); 136 return ssb_bus_powerup(dev->sdev->bus, dynamic_pctl);
137} 137}
138static inline int b43_bus_ssb_device_is_enabled(struct b43_bus_dev *dev) 138static int b43_bus_ssb_device_is_enabled(struct b43_bus_dev *dev)
139{ 139{
140 return ssb_device_is_enabled(dev->sdev); 140 return ssb_device_is_enabled(dev->sdev);
141} 141}
142static inline void b43_bus_ssb_device_enable(struct b43_bus_dev *dev, 142static void b43_bus_ssb_device_enable(struct b43_bus_dev *dev,
143 u32 core_specific_flags) 143 u32 core_specific_flags)
144{ 144{
145 ssb_device_enable(dev->sdev, core_specific_flags); 145 ssb_device_enable(dev->sdev, core_specific_flags);
146} 146}
147static inline void b43_bus_ssb_device_disable(struct b43_bus_dev *dev, 147static void b43_bus_ssb_device_disable(struct b43_bus_dev *dev,
148 u32 core_specific_flags) 148 u32 core_specific_flags)
149{ 149{
150 ssb_device_disable(dev->sdev, core_specific_flags); 150 ssb_device_disable(dev->sdev, core_specific_flags);
151} 151}
152 152
153static inline u16 b43_bus_ssb_read16(struct b43_bus_dev *dev, u16 offset) 153static u16 b43_bus_ssb_read16(struct b43_bus_dev *dev, u16 offset)
154{ 154{
155 return ssb_read16(dev->sdev, offset); 155 return ssb_read16(dev->sdev, offset);
156} 156}
157static inline u32 b43_bus_ssb_read32(struct b43_bus_dev *dev, u16 offset) 157static u32 b43_bus_ssb_read32(struct b43_bus_dev *dev, u16 offset)
158{ 158{
159 return ssb_read32(dev->sdev, offset); 159 return ssb_read32(dev->sdev, offset);
160} 160}
161static inline 161static void b43_bus_ssb_write16(struct b43_bus_dev *dev, u16 offset, u16 value)
162void b43_bus_ssb_write16(struct b43_bus_dev *dev, u16 offset, u16 value)
163{ 162{
164 ssb_write16(dev->sdev, offset, value); 163 ssb_write16(dev->sdev, offset, value);
165} 164}
166static inline 165static void b43_bus_ssb_write32(struct b43_bus_dev *dev, u16 offset, u32 value)
167void b43_bus_ssb_write32(struct b43_bus_dev *dev, u16 offset, u32 value)
168{ 166{
169 ssb_write32(dev->sdev, offset, value); 167 ssb_write32(dev->sdev, offset, value);
170} 168}
171static inline 169static void b43_bus_ssb_block_read(struct b43_bus_dev *dev, void *buffer,
172void b43_bus_ssb_block_read(struct b43_bus_dev *dev, void *buffer, 170 size_t count, u16 offset, u8 reg_width)
173 size_t count, u16 offset, u8 reg_width)
174{ 171{
175 ssb_block_read(dev->sdev, buffer, count, offset, reg_width); 172 ssb_block_read(dev->sdev, buffer, count, offset, reg_width);
176} 173}
177static inline 174static
178void b43_bus_ssb_block_write(struct b43_bus_dev *dev, const void *buffer, 175void b43_bus_ssb_block_write(struct b43_bus_dev *dev, const void *buffer,
179 size_t count, u16 offset, u8 reg_width) 176 size_t count, u16 offset, u8 reg_width)
180{ 177{
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index ce572aebeffd..0953ce1ac1b0 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -174,7 +174,7 @@ static void op64_fill_descriptor(struct b43_dmaring *ring,
174 addrhi = (((u64) dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK); 174 addrhi = (((u64) dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK);
175 addrext = (((u64) dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK) 175 addrext = (((u64) dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK)
176 >> SSB_DMA_TRANSLATION_SHIFT; 176 >> SSB_DMA_TRANSLATION_SHIFT;
177 addrhi |= (ring->dev->dma.translation << 1); 177 addrhi |= ring->dev->dma.translation;
178 if (slot == ring->nr_slots - 1) 178 if (slot == ring->nr_slots - 1)
179 ctl0 |= B43_DMA64_DCTL0_DTABLEEND; 179 ctl0 |= B43_DMA64_DCTL0_DTABLEEND;
180 if (start) 180 if (start)
@@ -659,6 +659,7 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
659 u32 value; 659 u32 value;
660 u32 addrext; 660 u32 addrext;
661 u32 trans = ring->dev->dma.translation; 661 u32 trans = ring->dev->dma.translation;
662 bool parity = ring->dev->dma.parity;
662 663
663 if (ring->tx) { 664 if (ring->tx) {
664 if (ring->type == B43_DMA_64BIT) { 665 if (ring->type == B43_DMA_64BIT) {
@@ -669,13 +670,15 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
669 value = B43_DMA64_TXENABLE; 670 value = B43_DMA64_TXENABLE;
670 value |= (addrext << B43_DMA64_TXADDREXT_SHIFT) 671 value |= (addrext << B43_DMA64_TXADDREXT_SHIFT)
671 & B43_DMA64_TXADDREXT_MASK; 672 & B43_DMA64_TXADDREXT_MASK;
673 if (!parity)
674 value |= B43_DMA64_TXPARITYDISABLE;
672 b43_dma_write(ring, B43_DMA64_TXCTL, value); 675 b43_dma_write(ring, B43_DMA64_TXCTL, value);
673 b43_dma_write(ring, B43_DMA64_TXRINGLO, 676 b43_dma_write(ring, B43_DMA64_TXRINGLO,
674 (ringbase & 0xFFFFFFFF)); 677 (ringbase & 0xFFFFFFFF));
675 b43_dma_write(ring, B43_DMA64_TXRINGHI, 678 b43_dma_write(ring, B43_DMA64_TXRINGHI,
676 ((ringbase >> 32) & 679 ((ringbase >> 32) &
677 ~SSB_DMA_TRANSLATION_MASK) 680 ~SSB_DMA_TRANSLATION_MASK)
678 | (trans << 1)); 681 | trans);
679 } else { 682 } else {
680 u32 ringbase = (u32) (ring->dmabase); 683 u32 ringbase = (u32) (ring->dmabase);
681 684
@@ -684,6 +687,8 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
684 value = B43_DMA32_TXENABLE; 687 value = B43_DMA32_TXENABLE;
685 value |= (addrext << B43_DMA32_TXADDREXT_SHIFT) 688 value |= (addrext << B43_DMA32_TXADDREXT_SHIFT)
686 & B43_DMA32_TXADDREXT_MASK; 689 & B43_DMA32_TXADDREXT_MASK;
690 if (!parity)
691 value |= B43_DMA32_TXPARITYDISABLE;
687 b43_dma_write(ring, B43_DMA32_TXCTL, value); 692 b43_dma_write(ring, B43_DMA32_TXCTL, value);
688 b43_dma_write(ring, B43_DMA32_TXRING, 693 b43_dma_write(ring, B43_DMA32_TXRING,
689 (ringbase & ~SSB_DMA_TRANSLATION_MASK) 694 (ringbase & ~SSB_DMA_TRANSLATION_MASK)
@@ -702,13 +707,15 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
702 value |= B43_DMA64_RXENABLE; 707 value |= B43_DMA64_RXENABLE;
703 value |= (addrext << B43_DMA64_RXADDREXT_SHIFT) 708 value |= (addrext << B43_DMA64_RXADDREXT_SHIFT)
704 & B43_DMA64_RXADDREXT_MASK; 709 & B43_DMA64_RXADDREXT_MASK;
710 if (!parity)
711 value |= B43_DMA64_RXPARITYDISABLE;
705 b43_dma_write(ring, B43_DMA64_RXCTL, value); 712 b43_dma_write(ring, B43_DMA64_RXCTL, value);
706 b43_dma_write(ring, B43_DMA64_RXRINGLO, 713 b43_dma_write(ring, B43_DMA64_RXRINGLO,
707 (ringbase & 0xFFFFFFFF)); 714 (ringbase & 0xFFFFFFFF));
708 b43_dma_write(ring, B43_DMA64_RXRINGHI, 715 b43_dma_write(ring, B43_DMA64_RXRINGHI,
709 ((ringbase >> 32) & 716 ((ringbase >> 32) &
710 ~SSB_DMA_TRANSLATION_MASK) 717 ~SSB_DMA_TRANSLATION_MASK)
711 | (trans << 1)); 718 | trans);
712 b43_dma_write(ring, B43_DMA64_RXINDEX, ring->nr_slots * 719 b43_dma_write(ring, B43_DMA64_RXINDEX, ring->nr_slots *
713 sizeof(struct b43_dmadesc64)); 720 sizeof(struct b43_dmadesc64));
714 } else { 721 } else {
@@ -720,6 +727,8 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
720 value |= B43_DMA32_RXENABLE; 727 value |= B43_DMA32_RXENABLE;
721 value |= (addrext << B43_DMA32_RXADDREXT_SHIFT) 728 value |= (addrext << B43_DMA32_RXADDREXT_SHIFT)
722 & B43_DMA32_RXADDREXT_MASK; 729 & B43_DMA32_RXADDREXT_MASK;
730 if (!parity)
731 value |= B43_DMA32_RXPARITYDISABLE;
723 b43_dma_write(ring, B43_DMA32_RXCTL, value); 732 b43_dma_write(ring, B43_DMA32_RXCTL, value);
724 b43_dma_write(ring, B43_DMA32_RXRING, 733 b43_dma_write(ring, B43_DMA32_RXRING,
725 (ringbase & ~SSB_DMA_TRANSLATION_MASK) 734 (ringbase & ~SSB_DMA_TRANSLATION_MASK)
@@ -1057,6 +1066,11 @@ int b43_dma_init(struct b43_wldev *dev)
1057 return err; 1066 return err;
1058 1067
1059 switch (dev->dev->bus_type) { 1068 switch (dev->dev->bus_type) {
1069#ifdef CONFIG_B43_BCMA
1070 case B43_BUS_BCMA:
1071 dma->translation = bcma_core_dma_translation(dev->dev->bdev);
1072 break;
1073#endif
1060#ifdef CONFIG_B43_SSB 1074#ifdef CONFIG_B43_SSB
1061 case B43_BUS_SSB: 1075 case B43_BUS_SSB:
1062 dma->translation = ssb_dma_translation(dev->dev->sdev); 1076 dma->translation = ssb_dma_translation(dev->dev->sdev);
@@ -1064,6 +1078,13 @@ int b43_dma_init(struct b43_wldev *dev)
1064#endif 1078#endif
1065 } 1079 }
1066 1080
1081 dma->parity = true;
1082#ifdef CONFIG_B43_BCMA
1083 /* TODO: find out which SSB devices need disabling parity */
1084 if (dev->dev->bus_type == B43_BUS_BCMA)
1085 dma->parity = false;
1086#endif
1087
1067 err = -ENOMEM; 1088 err = -ENOMEM;
1068 /* setup TX DMA channels. */ 1089 /* setup TX DMA channels. */
1069 dma->tx_ring_AC_BK = b43_setup_dmaring(dev, 0, 1, type); 1090 dma->tx_ring_AC_BK = b43_setup_dmaring(dev, 0, 1, type);
diff --git a/drivers/net/wireless/b43/dma.h b/drivers/net/wireless/b43/dma.h
index e8a80a1251bf..cdf87094efe8 100644
--- a/drivers/net/wireless/b43/dma.h
+++ b/drivers/net/wireless/b43/dma.h
@@ -20,6 +20,7 @@
20#define B43_DMA32_TXSUSPEND 0x00000002 20#define B43_DMA32_TXSUSPEND 0x00000002
21#define B43_DMA32_TXLOOPBACK 0x00000004 21#define B43_DMA32_TXLOOPBACK 0x00000004
22#define B43_DMA32_TXFLUSH 0x00000010 22#define B43_DMA32_TXFLUSH 0x00000010
23#define B43_DMA32_TXPARITYDISABLE 0x00000800
23#define B43_DMA32_TXADDREXT_MASK 0x00030000 24#define B43_DMA32_TXADDREXT_MASK 0x00030000
24#define B43_DMA32_TXADDREXT_SHIFT 16 25#define B43_DMA32_TXADDREXT_SHIFT 16
25#define B43_DMA32_TXRING 0x04 26#define B43_DMA32_TXRING 0x04
@@ -44,6 +45,7 @@
44#define B43_DMA32_RXFROFF_MASK 0x000000FE 45#define B43_DMA32_RXFROFF_MASK 0x000000FE
45#define B43_DMA32_RXFROFF_SHIFT 1 46#define B43_DMA32_RXFROFF_SHIFT 1
46#define B43_DMA32_RXDIRECTFIFO 0x00000100 47#define B43_DMA32_RXDIRECTFIFO 0x00000100
48#define B43_DMA32_RXPARITYDISABLE 0x00000800
47#define B43_DMA32_RXADDREXT_MASK 0x00030000 49#define B43_DMA32_RXADDREXT_MASK 0x00030000
48#define B43_DMA32_RXADDREXT_SHIFT 16 50#define B43_DMA32_RXADDREXT_SHIFT 16
49#define B43_DMA32_RXRING 0x14 51#define B43_DMA32_RXRING 0x14
@@ -84,6 +86,7 @@ struct b43_dmadesc32 {
84#define B43_DMA64_TXSUSPEND 0x00000002 86#define B43_DMA64_TXSUSPEND 0x00000002
85#define B43_DMA64_TXLOOPBACK 0x00000004 87#define B43_DMA64_TXLOOPBACK 0x00000004
86#define B43_DMA64_TXFLUSH 0x00000010 88#define B43_DMA64_TXFLUSH 0x00000010
89#define B43_DMA64_TXPARITYDISABLE 0x00000800
87#define B43_DMA64_TXADDREXT_MASK 0x00030000 90#define B43_DMA64_TXADDREXT_MASK 0x00030000
88#define B43_DMA64_TXADDREXT_SHIFT 16 91#define B43_DMA64_TXADDREXT_SHIFT 16
89#define B43_DMA64_TXINDEX 0x04 92#define B43_DMA64_TXINDEX 0x04
@@ -111,6 +114,7 @@ struct b43_dmadesc32 {
111#define B43_DMA64_RXFROFF_MASK 0x000000FE 114#define B43_DMA64_RXFROFF_MASK 0x000000FE
112#define B43_DMA64_RXFROFF_SHIFT 1 115#define B43_DMA64_RXFROFF_SHIFT 1
113#define B43_DMA64_RXDIRECTFIFO 0x00000100 116#define B43_DMA64_RXDIRECTFIFO 0x00000100
117#define B43_DMA64_RXPARITYDISABLE 0x00000800
114#define B43_DMA64_RXADDREXT_MASK 0x00030000 118#define B43_DMA64_RXADDREXT_MASK 0x00030000
115#define B43_DMA64_RXADDREXT_SHIFT 16 119#define B43_DMA64_RXADDREXT_SHIFT 16
116#define B43_DMA64_RXINDEX 0x24 120#define B43_DMA64_RXINDEX 0x24
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 092dd9318869..73fbf0358f96 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1156,17 +1156,37 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags)
1156} 1156}
1157 1157
1158#ifdef CONFIG_B43_BCMA 1158#ifdef CONFIG_B43_BCMA
1159static void b43_bcma_wireless_core_reset(struct b43_wldev *dev, bool gmode) 1159static void b43_bcma_phy_reset(struct b43_wldev *dev)
1160{ 1160{
1161 u32 flags = 0; 1161 u32 flags;
1162 1162
1163 if (gmode) 1163 /* Put PHY into reset */
1164 flags = B43_BCMA_IOCTL_GMODE; 1164 flags = bcma_aread32(dev->dev->bdev, BCMA_IOCTL);
1165 flags |= B43_BCMA_IOCTL_PHY_CLKEN; 1165 flags |= B43_BCMA_IOCTL_PHY_RESET;
1166 flags |= B43_BCMA_IOCTL_PHY_BW_20MHZ; /* Make 20 MHz def */ 1166 flags |= B43_BCMA_IOCTL_PHY_BW_20MHZ; /* Make 20 MHz def */
1167 b43_device_enable(dev, flags); 1167 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, flags);
1168 udelay(2);
1169
1170 /* Take PHY out of reset */
1171 flags = bcma_aread32(dev->dev->bdev, BCMA_IOCTL);
1172 flags &= ~B43_BCMA_IOCTL_PHY_RESET;
1173 flags |= BCMA_IOCTL_FGC;
1174 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, flags);
1175 udelay(1);
1168 1176
1169 /* TODO: reset PHY */ 1177 /* Do not force clock anymore */
1178 flags = bcma_aread32(dev->dev->bdev, BCMA_IOCTL);
1179 flags &= ~BCMA_IOCTL_FGC;
1180 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, flags);
1181 udelay(1);
1182}
1183
1184static void b43_bcma_wireless_core_reset(struct b43_wldev *dev, bool gmode)
1185{
1186 b43_device_enable(dev, B43_BCMA_IOCTL_PHY_CLKEN);
1187 bcma_core_set_clockmode(dev->dev->bdev, BCMA_CLKMODE_FAST);
1188 b43_bcma_phy_reset(dev);
1189 bcma_core_pll_ctl(dev->dev->bdev, 0x300, 0x3000000, true);
1170} 1190}
1171#endif 1191#endif
1172 1192
@@ -2814,12 +2834,12 @@ void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on)
2814 switch (dev->dev->bus_type) { 2834 switch (dev->dev->bus_type) {
2815#ifdef CONFIG_B43_BCMA 2835#ifdef CONFIG_B43_BCMA
2816 case B43_BUS_BCMA: 2836 case B43_BUS_BCMA:
2817 tmp = bcma_read32(dev->dev->bdev, BCMA_IOCTL); 2837 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL);
2818 if (on) 2838 if (on)
2819 tmp |= B43_BCMA_IOCTL_MACPHYCLKEN; 2839 tmp |= B43_BCMA_IOCTL_MACPHYCLKEN;
2820 else 2840 else
2821 tmp &= ~B43_BCMA_IOCTL_MACPHYCLKEN; 2841 tmp &= ~B43_BCMA_IOCTL_MACPHYCLKEN;
2822 bcma_write32(dev->dev->bdev, BCMA_IOCTL, tmp); 2842 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp);
2823 break; 2843 break;
2824#endif 2844#endif
2825#ifdef CONFIG_B43_SSB 2845#ifdef CONFIG_B43_SSB
@@ -4948,6 +4968,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4948 struct b43_wl *wl = dev->wl; 4968 struct b43_wl *wl = dev->wl;
4949 struct pci_dev *pdev = NULL; 4969 struct pci_dev *pdev = NULL;
4950 int err; 4970 int err;
4971 u32 tmp;
4951 bool have_2ghz_phy = 0, have_5ghz_phy = 0; 4972 bool have_2ghz_phy = 0, have_5ghz_phy = 0;
4952 4973
4953 /* Do NOT do any device initialization here. 4974 /* Do NOT do any device initialization here.
@@ -4973,17 +4994,17 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4973 switch (dev->dev->bus_type) { 4994 switch (dev->dev->bus_type) {
4974#ifdef CONFIG_B43_BCMA 4995#ifdef CONFIG_B43_BCMA
4975 case B43_BUS_BCMA: 4996 case B43_BUS_BCMA:
4976 /* FIXME */ 4997 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOST);
4977 have_2ghz_phy = 1; 4998 have_2ghz_phy = !!(tmp & B43_BCMA_IOST_2G_PHY);
4978 have_5ghz_phy = 0; 4999 have_5ghz_phy = !!(tmp & B43_BCMA_IOST_5G_PHY);
4979 break; 5000 break;
4980#endif 5001#endif
4981#ifdef CONFIG_B43_SSB 5002#ifdef CONFIG_B43_SSB
4982 case B43_BUS_SSB: 5003 case B43_BUS_SSB:
4983 if (dev->dev->core_rev >= 5) { 5004 if (dev->dev->core_rev >= 5) {
4984 u32 tmshigh = ssb_read32(dev->dev->sdev, SSB_TMSHIGH); 5005 tmp = ssb_read32(dev->dev->sdev, SSB_TMSHIGH);
4985 have_2ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_2GHZ_PHY); 5006 have_2ghz_phy = !!(tmp & B43_TMSHIGH_HAVE_2GHZ_PHY);
4986 have_5ghz_phy = !!(tmshigh & B43_TMSHIGH_HAVE_5GHZ_PHY); 5007 have_5ghz_phy = !!(tmp & B43_TMSHIGH_HAVE_5GHZ_PHY);
4987 } else 5008 } else
4988 B43_WARN_ON(1); 5009 B43_WARN_ON(1);
4989 break; 5010 break;
@@ -5164,6 +5185,7 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev)
5164 struct ssb_sprom *sprom = dev->bus_sprom; 5185 struct ssb_sprom *sprom = dev->bus_sprom;
5165 struct ieee80211_hw *hw; 5186 struct ieee80211_hw *hw;
5166 struct b43_wl *wl; 5187 struct b43_wl *wl;
5188 char chip_name[6];
5167 5189
5168 hw = ieee80211_alloc_hw(sizeof(*wl), &b43_hw_ops); 5190 hw = ieee80211_alloc_hw(sizeof(*wl), &b43_hw_ops);
5169 if (!hw) { 5191 if (!hw) {
@@ -5202,8 +5224,10 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev)
5202 INIT_WORK(&wl->tx_work, b43_tx_work); 5224 INIT_WORK(&wl->tx_work, b43_tx_work);
5203 skb_queue_head_init(&wl->tx_queue); 5225 skb_queue_head_init(&wl->tx_queue);
5204 5226
5205 b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n", 5227 snprintf(chip_name, ARRAY_SIZE(chip_name),
5206 dev->chip_id, dev->core_rev); 5228 (dev->chip_id > 0x9999) ? "%d" : "%04X", dev->chip_id);
5229 b43info(wl, "Broadcom %s WLAN found (core revision %u)\n", chip_name,
5230 dev->core_rev);
5207 return wl; 5231 return wl;
5208} 5232}
5209 5233
@@ -5211,19 +5235,59 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev)
5211static int b43_bcma_probe(struct bcma_device *core) 5235static int b43_bcma_probe(struct bcma_device *core)
5212{ 5236{
5213 struct b43_bus_dev *dev; 5237 struct b43_bus_dev *dev;
5238 struct b43_wl *wl;
5239 int err;
5214 5240
5215 dev = b43_bus_dev_bcma_init(core); 5241 dev = b43_bus_dev_bcma_init(core);
5216 if (!dev) 5242 if (!dev)
5217 return -ENODEV; 5243 return -ENODEV;
5218 5244
5219 b43err(NULL, "BCMA is not supported yet!"); 5245 wl = b43_wireless_init(dev);
5220 kfree(dev); 5246 if (IS_ERR(wl)) {
5221 return -EOPNOTSUPP; 5247 err = PTR_ERR(wl);
5248 goto bcma_out;
5249 }
5250
5251 err = b43_one_core_attach(dev, wl);
5252 if (err)
5253 goto bcma_err_wireless_exit;
5254
5255 err = ieee80211_register_hw(wl->hw);
5256 if (err)
5257 goto bcma_err_one_core_detach;
5258 b43_leds_register(wl->current_dev);
5259
5260bcma_out:
5261 return err;
5262
5263bcma_err_one_core_detach:
5264 b43_one_core_detach(dev);
5265bcma_err_wireless_exit:
5266 ieee80211_free_hw(wl->hw);
5267 return err;
5222} 5268}
5223 5269
5224static void b43_bcma_remove(struct bcma_device *core) 5270static void b43_bcma_remove(struct bcma_device *core)
5225{ 5271{
5226 /* TODO */ 5272 struct b43_wldev *wldev = bcma_get_drvdata(core);
5273 struct b43_wl *wl = wldev->wl;
5274
5275 /* We must cancel any work here before unregistering from ieee80211,
5276 * as the ieee80211 unreg will destroy the workqueue. */
5277 cancel_work_sync(&wldev->restart_work);
5278
5279 /* Restore the queues count before unregistering, because firmware detect
5280 * might have modified it. Restoring is important, so the networking
5281 * stack can properly free resources. */
5282 wl->hw->queues = wl->mac80211_initially_registered_queues;
5283 b43_leds_stop(wldev);
5284 ieee80211_unregister_hw(wl->hw);
5285
5286 b43_one_core_detach(wldev->dev);
5287
5288 b43_leds_unregister(wl);
5289
5290 ieee80211_free_hw(wl->hw);
5227} 5291}
5228 5292
5229static struct bcma_driver b43_bcma_driver = { 5293static struct bcma_driver b43_bcma_driver = {
diff --git a/drivers/net/wireless/b43/phy_ht.c b/drivers/net/wireless/b43/phy_ht.c
index 29821036badf..7c40919651a7 100644
--- a/drivers/net/wireless/b43/phy_ht.c
+++ b/drivers/net/wireless/b43/phy_ht.c
@@ -148,7 +148,7 @@ static void b43_radio_2059_init(struct b43_wldev *dev)
148 b43_radio_mask(dev, 0x17F, ~0x1); 148 b43_radio_mask(dev, 0x17F, ~0x1);
149 } 149 }
150 150
151 b43_radio_mask(dev, 0x11, 0x0008); 151 b43_radio_mask(dev, 0x11, ~0x0008);
152} 152}
153 153
154/************************************************** 154/**************************************************
@@ -276,18 +276,25 @@ static void b43_phy_ht_op_software_rfkill(struct b43_wldev *dev,
276 if (b43_read32(dev, B43_MMIO_MACCTL) & B43_MACCTL_ENABLED) 276 if (b43_read32(dev, B43_MMIO_MACCTL) & B43_MACCTL_ENABLED)
277 b43err(dev->wl, "MAC not suspended\n"); 277 b43err(dev->wl, "MAC not suspended\n");
278 278
279 /* In the following PHY ops we copy wl's dummy behaviour.
280 * TODO: Find out if reads (currently hidden in masks/masksets) are
281 * needed and replace following ops with just writes or w&r.
282 * Note: B43_PHY_HT_RF_CTL1 register is tricky, wrong operation can
283 * cause delayed (!) machine lock up. */
279 if (blocked) { 284 if (blocked) {
280 b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, ~0); 285 b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, 0);
281 } else { 286 } else {
282 b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, ~0); 287 b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, 0);
283 b43_phy_maskset(dev, B43_PHY_HT_RF_CTL1, ~0, 0x1); 288 b43_phy_maskset(dev, B43_PHY_HT_RF_CTL1, 0, 0x1);
284 b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, ~0); 289 b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, 0);
285 b43_phy_maskset(dev, B43_PHY_HT_RF_CTL1, ~0, 0x2); 290 b43_phy_maskset(dev, B43_PHY_HT_RF_CTL1, 0, 0x2);
286 291
287 if (dev->phy.radio_ver == 0x2059) 292 if (dev->phy.radio_ver == 0x2059)
288 b43_radio_2059_init(dev); 293 b43_radio_2059_init(dev);
289 else 294 else
290 B43_WARN_ON(1); 295 B43_WARN_ON(1);
296
297 b43_switch_channel(dev, dev->phy.channel);
291 } 298 }
292} 299}
293 300
@@ -329,7 +336,7 @@ static int b43_phy_ht_op_switch_channel(struct b43_wldev *dev,
329static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev) 336static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
330{ 337{
331 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 338 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
332 return 1; 339 return 11;
333 return 36; 340 return 36;
334} 341}
335 342
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 95c28f584ed9..1ae1e84cb4d1 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -611,12 +611,12 @@ static void b43_nphy_bmac_clock_fgc(struct b43_wldev *dev, bool force)
611 switch (dev->dev->bus_type) { 611 switch (dev->dev->bus_type) {
612#ifdef CONFIG_B43_BCMA 612#ifdef CONFIG_B43_BCMA
613 case B43_BUS_BCMA: 613 case B43_BUS_BCMA:
614 tmp = bcma_read32(dev->dev->bdev, BCMA_IOCTL); 614 tmp = bcma_aread32(dev->dev->bdev, BCMA_IOCTL);
615 if (force) 615 if (force)
616 tmp |= BCMA_IOCTL_FGC; 616 tmp |= BCMA_IOCTL_FGC;
617 else 617 else
618 tmp &= ~BCMA_IOCTL_FGC; 618 tmp &= ~BCMA_IOCTL_FGC;
619 bcma_write32(dev->dev->bdev, BCMA_IOCTL, tmp); 619 bcma_awrite32(dev->dev->bdev, BCMA_IOCTL, tmp);
620 break; 620 break;
621#endif 621#endif
622#ifdef CONFIG_B43_SSB 622#ifdef CONFIG_B43_SSB
diff --git a/drivers/net/wireless/b43/radio_2059.c b/drivers/net/wireless/b43/radio_2059.c
index 23dea4ba8219..f029f6e1f5d1 100644
--- a/drivers/net/wireless/b43/radio_2059.c
+++ b/drivers/net/wireless/b43/radio_2059.c
@@ -161,5 +161,14 @@ static const struct b43_phy_ht_channeltab_e_radio2059 b43_phy_ht_channeltab_radi
161const struct b43_phy_ht_channeltab_e_radio2059 161const struct b43_phy_ht_channeltab_e_radio2059
162*b43_phy_ht_get_channeltab_e_r2059(struct b43_wldev *dev, u16 freq) 162*b43_phy_ht_get_channeltab_e_r2059(struct b43_wldev *dev, u16 freq)
163{ 163{
164 const struct b43_phy_ht_channeltab_e_radio2059 *e;
165 unsigned int i;
166
167 e = b43_phy_ht_channeltab_radio2059;
168 for (i = 0; i < ARRAY_SIZE(b43_phy_ht_channeltab_radio2059); i++, e++) {
169 if (e->freq == freq)
170 return e;
171 }
172
164 return NULL; 173 return NULL;
165} 174}
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h
index 23583be1ee0b..17a130d18dc9 100644
--- a/drivers/net/wireless/b43legacy/b43legacy.h
+++ b/drivers/net/wireless/b43legacy/b43legacy.h
@@ -532,6 +532,8 @@ struct b43legacy_dma {
532 532
533 struct b43legacy_dmaring *rx_ring0; 533 struct b43legacy_dmaring *rx_ring0;
534 struct b43legacy_dmaring *rx_ring3; /* only on core.rev < 5 */ 534 struct b43legacy_dmaring *rx_ring3; /* only on core.rev < 5 */
535
536 u32 translation; /* Routing bits */
535}; 537};
536 538
537/* Data structures for PIO transmission, per 80211 core. */ 539/* Data structures for PIO transmission, per 80211 core. */
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index c33934ad6cd2..704ee62101bd 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -73,7 +73,7 @@ static void op32_fill_descriptor(struct b43legacy_dmaring *ring,
73 addr = (u32)(dmaaddr & ~SSB_DMA_TRANSLATION_MASK); 73 addr = (u32)(dmaaddr & ~SSB_DMA_TRANSLATION_MASK);
74 addrext = (u32)(dmaaddr & SSB_DMA_TRANSLATION_MASK) 74 addrext = (u32)(dmaaddr & SSB_DMA_TRANSLATION_MASK)
75 >> SSB_DMA_TRANSLATION_SHIFT; 75 >> SSB_DMA_TRANSLATION_SHIFT;
76 addr |= ssb_dma_translation(ring->dev->dev); 76 addr |= ring->dev->dma.translation;
77 ctl = (bufsize - ring->frameoffset) 77 ctl = (bufsize - ring->frameoffset)
78 & B43legacy_DMA32_DCTL_BYTECNT; 78 & B43legacy_DMA32_DCTL_BYTECNT;
79 if (slot == ring->nr_slots - 1) 79 if (slot == ring->nr_slots - 1)
@@ -175,7 +175,7 @@ static void op64_fill_descriptor(struct b43legacy_dmaring *ring,
175 addrhi = (((u64)dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK); 175 addrhi = (((u64)dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK);
176 addrext = (((u64)dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK) 176 addrext = (((u64)dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK)
177 >> SSB_DMA_TRANSLATION_SHIFT; 177 >> SSB_DMA_TRANSLATION_SHIFT;
178 addrhi |= ssb_dma_translation(ring->dev->dev); 178 addrhi |= ring->dev->dma.translation;
179 if (slot == ring->nr_slots - 1) 179 if (slot == ring->nr_slots - 1)
180 ctl0 |= B43legacy_DMA64_DCTL0_DTABLEEND; 180 ctl0 |= B43legacy_DMA64_DCTL0_DTABLEEND;
181 if (start) 181 if (start)
@@ -709,7 +709,7 @@ static int dmacontroller_setup(struct b43legacy_dmaring *ring)
709 int err = 0; 709 int err = 0;
710 u32 value; 710 u32 value;
711 u32 addrext; 711 u32 addrext;
712 u32 trans = ssb_dma_translation(ring->dev->dev); 712 u32 trans = ring->dev->dma.translation;
713 713
714 if (ring->tx) { 714 if (ring->tx) {
715 if (ring->type == B43legacy_DMA_64BIT) { 715 if (ring->type == B43legacy_DMA_64BIT) {
@@ -1093,6 +1093,7 @@ int b43legacy_dma_init(struct b43legacy_wldev *dev)
1093 return -EOPNOTSUPP; 1093 return -EOPNOTSUPP;
1094#endif 1094#endif
1095 } 1095 }
1096 dma->translation = ssb_dma_translation(dev->dev);
1096 1097
1097 err = -ENOMEM; 1098 err = -ENOMEM;
1098 /* setup TX DMA channels. */ 1099 /* setup TX DMA channels. */
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 19150398a248..48ab9142af38 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -5,16 +5,16 @@ iwlagn-objs += iwl-agn-ucode.o iwl-agn-tx.o
5iwlagn-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o 5iwlagn-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o
6iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o 6iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o
7 7
8iwlagn-objs += iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o 8iwlagn-objs += iwl-core.o iwl-eeprom.o iwl-power.o
9iwlagn-objs += iwl-rx.o iwl-tx.o iwl-sta.o 9iwlagn-objs += iwl-rx.o iwl-sta.o
10iwlagn-objs += iwl-scan.o iwl-led.o 10iwlagn-objs += iwl-scan.o iwl-led.o
11iwlagn-objs += iwl-agn-rxon.o iwl-agn-hcmd.o iwl-agn-ict.o 11iwlagn-objs += iwl-agn-rxon.o
12iwlagn-objs += iwl-5000.o 12iwlagn-objs += iwl-5000.o
13iwlagn-objs += iwl-6000.o 13iwlagn-objs += iwl-6000.o
14iwlagn-objs += iwl-1000.o 14iwlagn-objs += iwl-1000.o
15iwlagn-objs += iwl-2000.o 15iwlagn-objs += iwl-2000.o
16iwlagn-objs += iwl-pci.o 16iwlagn-objs += iwl-pci.o
17iwlagn-objs += iwl-trans.o 17iwlagn-objs += iwl-trans.o iwl-trans-rx-pcie.o iwl-trans-tx-pcie.o
18 18
19iwlagn-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o 19iwlagn-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o
20iwlagn-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o 20iwlagn-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 2f56b343e869..01b49eb8c8ec 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -168,9 +168,6 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
168 168
169static struct iwl_lib_ops iwl1000_lib = { 169static struct iwl_lib_ops iwl1000_lib = {
170 .set_hw_params = iwl1000_hw_set_hw_params, 170 .set_hw_params = iwl1000_hw_set_hw_params,
171 .rx_handler_setup = iwlagn_rx_handler_setup,
172 .setup_deferred_work = iwlagn_setup_deferred_work,
173 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
174 .nic_config = iwl1000_nic_config, 171 .nic_config = iwl1000_nic_config,
175 .eeprom_ops = { 172 .eeprom_ops = {
176 .regulatory_bands = { 173 .regulatory_bands = {
@@ -186,10 +183,6 @@ static struct iwl_lib_ops iwl1000_lib = {
186 .temperature = iwlagn_temperature, 183 .temperature = iwlagn_temperature,
187}; 184};
188 185
189static const struct iwl_ops iwl1000_ops = {
190 .lib = &iwl1000_lib,
191};
192
193static struct iwl_base_params iwl1000_base_params = { 186static struct iwl_base_params iwl1000_base_params = {
194 .num_of_queues = IWLAGN_NUM_QUEUES, 187 .num_of_queues = IWLAGN_NUM_QUEUES,
195 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, 188 .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
@@ -217,7 +210,7 @@ static struct iwl_ht_params iwl1000_ht_params = {
217 .ucode_api_min = IWL1000_UCODE_API_MIN, \ 210 .ucode_api_min = IWL1000_UCODE_API_MIN, \
218 .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \ 211 .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
219 .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \ 212 .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
220 .ops = &iwl1000_ops, \ 213 .lib = &iwl1000_lib, \
221 .base_params = &iwl1000_base_params, \ 214 .base_params = &iwl1000_base_params, \
222 .led_mode = IWL_LED_BLINK 215 .led_mode = IWL_LED_BLINK
223 216
@@ -238,7 +231,7 @@ struct iwl_cfg iwl1000_bg_cfg = {
238 .ucode_api_min = IWL100_UCODE_API_MIN, \ 231 .ucode_api_min = IWL100_UCODE_API_MIN, \
239 .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \ 232 .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \
240 .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \ 233 .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \
241 .ops = &iwl1000_ops, \ 234 .lib = &iwl1000_lib, \
242 .base_params = &iwl1000_base_params, \ 235 .base_params = &iwl1000_base_params, \
243 .led_mode = IWL_LED_RF_STATE, \ 236 .led_mode = IWL_LED_RF_STATE, \
244 .rx_with_siso_diversity = true 237 .rx_with_siso_diversity = true
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
index 32ac8654b79a..0e13f0bb2e17 100644
--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
@@ -85,9 +85,6 @@ static void iwl2000_nic_config(struct iwl_priv *priv)
85 if (priv->cfg->iq_invert) 85 if (priv->cfg->iq_invert)
86 iwl_set_bit(priv, CSR_GP_DRIVER_REG, 86 iwl_set_bit(priv, CSR_GP_DRIVER_REG,
87 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER); 87 CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
88
89 if (priv->cfg->disable_otp_refresh)
90 iwl_write_prph(priv, APMG_ANALOG_SVR_REG, 0x80000010);
91} 88}
92 89
93static struct iwl_sensitivity_ranges iwl2000_sensitivity = { 90static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
@@ -156,7 +153,7 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
156 BIT(IWL_CALIB_TX_IQ) | 153 BIT(IWL_CALIB_TX_IQ) |
157 BIT(IWL_CALIB_BASE_BAND); 154 BIT(IWL_CALIB_BASE_BAND);
158 if (priv->cfg->need_dc_calib) 155 if (priv->cfg->need_dc_calib)
159 priv->hw_params.calib_rt_cfg |= BIT(IWL_CALIB_CFG_DC_IDX); 156 priv->hw_params.calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
160 if (priv->cfg->need_temp_offset_calib) 157 if (priv->cfg->need_temp_offset_calib)
161 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET); 158 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
162 159
@@ -167,9 +164,6 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
167 164
168static struct iwl_lib_ops iwl2000_lib = { 165static struct iwl_lib_ops iwl2000_lib = {
169 .set_hw_params = iwl2000_hw_set_hw_params, 166 .set_hw_params = iwl2000_hw_set_hw_params,
170 .rx_handler_setup = iwlagn_rx_handler_setup,
171 .setup_deferred_work = iwlagn_setup_deferred_work,
172 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
173 .nic_config = iwl2000_nic_config, 167 .nic_config = iwl2000_nic_config,
174 .eeprom_ops = { 168 .eeprom_ops = {
175 .regulatory_bands = { 169 .regulatory_bands = {
@@ -188,10 +182,9 @@ static struct iwl_lib_ops iwl2000_lib = {
188 182
189static struct iwl_lib_ops iwl2030_lib = { 183static struct iwl_lib_ops iwl2030_lib = {
190 .set_hw_params = iwl2000_hw_set_hw_params, 184 .set_hw_params = iwl2000_hw_set_hw_params,
191 .rx_handler_setup = iwlagn_bt_rx_handler_setup, 185 .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
192 .setup_deferred_work = iwlagn_bt_setup_deferred_work, 186 .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
193 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work, 187 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
194 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
195 .nic_config = iwl2000_nic_config, 188 .nic_config = iwl2000_nic_config,
196 .eeprom_ops = { 189 .eeprom_ops = {
197 .regulatory_bands = { 190 .regulatory_bands = {
@@ -208,22 +201,6 @@ static struct iwl_lib_ops iwl2030_lib = {
208 .temperature = iwlagn_temperature, 201 .temperature = iwlagn_temperature,
209}; 202};
210 203
211static const struct iwl_ops iwl2000_ops = {
212 .lib = &iwl2000_lib,
213};
214
215static const struct iwl_ops iwl2030_ops = {
216 .lib = &iwl2030_lib,
217};
218
219static const struct iwl_ops iwl105_ops = {
220 .lib = &iwl2000_lib,
221};
222
223static const struct iwl_ops iwl135_ops = {
224 .lib = &iwl2030_lib,
225};
226
227static struct iwl_base_params iwl2000_base_params = { 204static struct iwl_base_params iwl2000_base_params = {
228 .eeprom_size = OTP_LOW_IMAGE_SIZE, 205 .eeprom_size = OTP_LOW_IMAGE_SIZE,
229 .num_of_queues = IWLAGN_NUM_QUEUES, 206 .num_of_queues = IWLAGN_NUM_QUEUES,
@@ -282,13 +259,12 @@ static struct iwl_bt_params iwl2030_bt_params = {
282 .ucode_api_min = IWL2000_UCODE_API_MIN, \ 259 .ucode_api_min = IWL2000_UCODE_API_MIN, \
283 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ 260 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
284 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ 261 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
285 .ops = &iwl2000_ops, \ 262 .lib = &iwl2000_lib, \
286 .base_params = &iwl2000_base_params, \ 263 .base_params = &iwl2000_base_params, \
287 .need_dc_calib = true, \ 264 .need_dc_calib = true, \
288 .need_temp_offset_calib = true, \ 265 .need_temp_offset_calib = true, \
289 .led_mode = IWL_LED_RF_STATE, \ 266 .led_mode = IWL_LED_RF_STATE, \
290 .iq_invert = true, \ 267 .iq_invert = true \
291 .disable_otp_refresh = true \
292 268
293struct iwl_cfg iwl2000_2bgn_cfg = { 269struct iwl_cfg iwl2000_2bgn_cfg = {
294 .name = "2000 Series 2x2 BGN", 270 .name = "2000 Series 2x2 BGN",
@@ -307,7 +283,7 @@ struct iwl_cfg iwl2000_2bg_cfg = {
307 .ucode_api_min = IWL2030_UCODE_API_MIN, \ 283 .ucode_api_min = IWL2030_UCODE_API_MIN, \
308 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ 284 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
309 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ 285 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
310 .ops = &iwl2030_ops, \ 286 .lib = &iwl2030_lib, \
311 .base_params = &iwl2030_base_params, \ 287 .base_params = &iwl2030_base_params, \
312 .bt_params = &iwl2030_bt_params, \ 288 .bt_params = &iwl2030_bt_params, \
313 .need_dc_calib = true, \ 289 .need_dc_calib = true, \
@@ -333,13 +309,14 @@ struct iwl_cfg iwl2030_2bg_cfg = {
333 .ucode_api_min = IWL105_UCODE_API_MIN, \ 309 .ucode_api_min = IWL105_UCODE_API_MIN, \
334 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ 310 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
335 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ 311 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
336 .ops = &iwl105_ops, \ 312 .lib = &iwl2000_lib, \
337 .base_params = &iwl2000_base_params, \ 313 .base_params = &iwl2000_base_params, \
338 .need_dc_calib = true, \ 314 .need_dc_calib = true, \
339 .need_temp_offset_calib = true, \ 315 .need_temp_offset_calib = true, \
340 .led_mode = IWL_LED_RF_STATE, \ 316 .led_mode = IWL_LED_RF_STATE, \
341 .adv_pm = true, \ 317 .adv_pm = true, \
342 .rx_with_siso_diversity = true \ 318 .rx_with_siso_diversity = true, \
319 .iq_invert = true \
343 320
344struct iwl_cfg iwl105_bg_cfg = { 321struct iwl_cfg iwl105_bg_cfg = {
345 .name = "105 Series 1x1 BG", 322 .name = "105 Series 1x1 BG",
@@ -358,14 +335,15 @@ struct iwl_cfg iwl105_bgn_cfg = {
358 .ucode_api_min = IWL135_UCODE_API_MIN, \ 335 .ucode_api_min = IWL135_UCODE_API_MIN, \
359 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ 336 .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \
360 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ 337 .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \
361 .ops = &iwl135_ops, \ 338 .lib = &iwl2030_lib, \
362 .base_params = &iwl2030_base_params, \ 339 .base_params = &iwl2030_base_params, \
363 .bt_params = &iwl2030_bt_params, \ 340 .bt_params = &iwl2030_bt_params, \
364 .need_dc_calib = true, \ 341 .need_dc_calib = true, \
365 .need_temp_offset_calib = true, \ 342 .need_temp_offset_calib = true, \
366 .led_mode = IWL_LED_RF_STATE, \ 343 .led_mode = IWL_LED_RF_STATE, \
367 .adv_pm = true, \ 344 .adv_pm = true, \
368 .rx_with_siso_diversity = true \ 345 .rx_with_siso_diversity = true, \
346 .iq_invert = true \
369 347
370struct iwl_cfg iwl135_bg_cfg = { 348struct iwl_cfg iwl135_bg_cfg = {
371 .name = "135 Series 1x1 BG/BT", 349 .name = "135 Series 1x1 BG/BT",
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 556489302da3..3eeb12ebe6e9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -315,14 +315,11 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
315 return -EFAULT; 315 return -EFAULT;
316 } 316 }
317 317
318 return trans_send_cmd(priv, &hcmd); 318 return trans_send_cmd(&priv->trans, &hcmd);
319} 319}
320 320
321static struct iwl_lib_ops iwl5000_lib = { 321static struct iwl_lib_ops iwl5000_lib = {
322 .set_hw_params = iwl5000_hw_set_hw_params, 322 .set_hw_params = iwl5000_hw_set_hw_params,
323 .rx_handler_setup = iwlagn_rx_handler_setup,
324 .setup_deferred_work = iwlagn_setup_deferred_work,
325 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
326 .set_channel_switch = iwl5000_hw_channel_switch, 323 .set_channel_switch = iwl5000_hw_channel_switch,
327 .nic_config = iwl5000_nic_config, 324 .nic_config = iwl5000_nic_config,
328 .eeprom_ops = { 325 .eeprom_ops = {
@@ -341,9 +338,6 @@ static struct iwl_lib_ops iwl5000_lib = {
341 338
342static struct iwl_lib_ops iwl5150_lib = { 339static struct iwl_lib_ops iwl5150_lib = {
343 .set_hw_params = iwl5150_hw_set_hw_params, 340 .set_hw_params = iwl5150_hw_set_hw_params,
344 .rx_handler_setup = iwlagn_rx_handler_setup,
345 .setup_deferred_work = iwlagn_setup_deferred_work,
346 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
347 .set_channel_switch = iwl5000_hw_channel_switch, 341 .set_channel_switch = iwl5000_hw_channel_switch,
348 .nic_config = iwl5000_nic_config, 342 .nic_config = iwl5000_nic_config,
349 .eeprom_ops = { 343 .eeprom_ops = {
@@ -360,14 +354,6 @@ static struct iwl_lib_ops iwl5150_lib = {
360 .temperature = iwl5150_temperature, 354 .temperature = iwl5150_temperature,
361}; 355};
362 356
363static const struct iwl_ops iwl5000_ops = {
364 .lib = &iwl5000_lib,
365};
366
367static const struct iwl_ops iwl5150_ops = {
368 .lib = &iwl5150_lib,
369};
370
371static struct iwl_base_params iwl5000_base_params = { 357static struct iwl_base_params iwl5000_base_params = {
372 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE, 358 .eeprom_size = IWLAGN_EEPROM_IMG_SIZE,
373 .num_of_queues = IWLAGN_NUM_QUEUES, 359 .num_of_queues = IWLAGN_NUM_QUEUES,
@@ -390,7 +376,7 @@ static struct iwl_ht_params iwl5000_ht_params = {
390 .ucode_api_min = IWL5000_UCODE_API_MIN, \ 376 .ucode_api_min = IWL5000_UCODE_API_MIN, \
391 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, \ 377 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, \
392 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, \ 378 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, \
393 .ops = &iwl5000_ops, \ 379 .lib = &iwl5000_lib, \
394 .base_params = &iwl5000_base_params, \ 380 .base_params = &iwl5000_base_params, \
395 .led_mode = IWL_LED_BLINK 381 .led_mode = IWL_LED_BLINK
396 382
@@ -433,7 +419,7 @@ struct iwl_cfg iwl5350_agn_cfg = {
433 .ucode_api_min = IWL5000_UCODE_API_MIN, 419 .ucode_api_min = IWL5000_UCODE_API_MIN,
434 .eeprom_ver = EEPROM_5050_EEPROM_VERSION, 420 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
435 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, 421 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
436 .ops = &iwl5000_ops, 422 .lib = &iwl5000_lib,
437 .base_params = &iwl5000_base_params, 423 .base_params = &iwl5000_base_params,
438 .ht_params = &iwl5000_ht_params, 424 .ht_params = &iwl5000_ht_params,
439 .led_mode = IWL_LED_BLINK, 425 .led_mode = IWL_LED_BLINK,
@@ -446,7 +432,7 @@ struct iwl_cfg iwl5350_agn_cfg = {
446 .ucode_api_min = IWL5150_UCODE_API_MIN, \ 432 .ucode_api_min = IWL5150_UCODE_API_MIN, \
447 .eeprom_ver = EEPROM_5050_EEPROM_VERSION, \ 433 .eeprom_ver = EEPROM_5050_EEPROM_VERSION, \
448 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, \ 434 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, \
449 .ops = &iwl5150_ops, \ 435 .lib = &iwl5150_lib, \
450 .base_params = &iwl5000_base_params, \ 436 .base_params = &iwl5000_base_params, \
451 .need_dc_calib = true, \ 437 .need_dc_calib = true, \
452 .led_mode = IWL_LED_BLINK, \ 438 .led_mode = IWL_LED_BLINK, \
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 80f1ef61a3d5..973d1972e8cc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -106,10 +106,8 @@ static void iwl6000_nic_config(struct iwl_priv *priv)
106 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA); 106 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
107 } 107 }
108 /* do additional nic configuration if needed */ 108 /* do additional nic configuration if needed */
109 if (priv->cfg->ops->nic && 109 if (priv->cfg->additional_nic_config)
110 priv->cfg->ops->nic->additional_nic_config) { 110 priv->cfg->additional_nic_config(priv);
111 priv->cfg->ops->nic->additional_nic_config(priv);
112 }
113} 111}
114 112
115static struct iwl_sensitivity_ranges iwl6000_sensitivity = { 113static struct iwl_sensitivity_ranges iwl6000_sensitivity = {
@@ -178,7 +176,7 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
178 BIT(IWL_CALIB_TX_IQ) | 176 BIT(IWL_CALIB_TX_IQ) |
179 BIT(IWL_CALIB_BASE_BAND); 177 BIT(IWL_CALIB_BASE_BAND);
180 if (priv->cfg->need_dc_calib) 178 if (priv->cfg->need_dc_calib)
181 priv->hw_params.calib_rt_cfg |= BIT(IWL_CALIB_CFG_DC_IDX); 179 priv->hw_params.calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
182 if (priv->cfg->need_temp_offset_calib) 180 if (priv->cfg->need_temp_offset_calib)
183 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET); 181 priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
184 182
@@ -255,14 +253,11 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
255 return -EFAULT; 253 return -EFAULT;
256 } 254 }
257 255
258 return trans_send_cmd(priv, &hcmd); 256 return trans_send_cmd(&priv->trans, &hcmd);
259} 257}
260 258
261static struct iwl_lib_ops iwl6000_lib = { 259static struct iwl_lib_ops iwl6000_lib = {
262 .set_hw_params = iwl6000_hw_set_hw_params, 260 .set_hw_params = iwl6000_hw_set_hw_params,
263 .rx_handler_setup = iwlagn_rx_handler_setup,
264 .setup_deferred_work = iwlagn_setup_deferred_work,
265 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
266 .set_channel_switch = iwl6000_hw_channel_switch, 261 .set_channel_switch = iwl6000_hw_channel_switch,
267 .nic_config = iwl6000_nic_config, 262 .nic_config = iwl6000_nic_config,
268 .eeprom_ops = { 263 .eeprom_ops = {
@@ -282,10 +277,9 @@ static struct iwl_lib_ops iwl6000_lib = {
282 277
283static struct iwl_lib_ops iwl6030_lib = { 278static struct iwl_lib_ops iwl6030_lib = {
284 .set_hw_params = iwl6000_hw_set_hw_params, 279 .set_hw_params = iwl6000_hw_set_hw_params,
285 .rx_handler_setup = iwlagn_bt_rx_handler_setup, 280 .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
286 .setup_deferred_work = iwlagn_bt_setup_deferred_work, 281 .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
287 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work, 282 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
288 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
289 .set_channel_switch = iwl6000_hw_channel_switch, 283 .set_channel_switch = iwl6000_hw_channel_switch,
290 .nic_config = iwl6000_nic_config, 284 .nic_config = iwl6000_nic_config,
291 .eeprom_ops = { 285 .eeprom_ops = {
@@ -303,32 +297,6 @@ static struct iwl_lib_ops iwl6030_lib = {
303 .temperature = iwlagn_temperature, 297 .temperature = iwlagn_temperature,
304}; 298};
305 299
306static struct iwl_nic_ops iwl6050_nic_ops = {
307 .additional_nic_config = &iwl6050_additional_nic_config,
308};
309
310static struct iwl_nic_ops iwl6150_nic_ops = {
311 .additional_nic_config = &iwl6150_additional_nic_config,
312};
313
314static const struct iwl_ops iwl6000_ops = {
315 .lib = &iwl6000_lib,
316};
317
318static const struct iwl_ops iwl6050_ops = {
319 .lib = &iwl6000_lib,
320 .nic = &iwl6050_nic_ops,
321};
322
323static const struct iwl_ops iwl6150_ops = {
324 .lib = &iwl6000_lib,
325 .nic = &iwl6150_nic_ops,
326};
327
328static const struct iwl_ops iwl6030_ops = {
329 .lib = &iwl6030_lib,
330};
331
332static struct iwl_base_params iwl6000_base_params = { 300static struct iwl_base_params iwl6000_base_params = {
333 .eeprom_size = OTP_LOW_IMAGE_SIZE, 301 .eeprom_size = OTP_LOW_IMAGE_SIZE,
334 .num_of_queues = IWLAGN_NUM_QUEUES, 302 .num_of_queues = IWLAGN_NUM_QUEUES,
@@ -402,7 +370,7 @@ static struct iwl_bt_params iwl6000_bt_params = {
402 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \ 370 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
403 .eeprom_ver = EEPROM_6005_EEPROM_VERSION, \ 371 .eeprom_ver = EEPROM_6005_EEPROM_VERSION, \
404 .eeprom_calib_ver = EEPROM_6005_TX_POWER_VERSION, \ 372 .eeprom_calib_ver = EEPROM_6005_TX_POWER_VERSION, \
405 .ops = &iwl6000_ops, \ 373 .lib = &iwl6000_lib, \
406 .base_params = &iwl6000_g2_base_params, \ 374 .base_params = &iwl6000_g2_base_params, \
407 .need_dc_calib = true, \ 375 .need_dc_calib = true, \
408 .need_temp_offset_calib = true, \ 376 .need_temp_offset_calib = true, \
@@ -430,7 +398,7 @@ struct iwl_cfg iwl6005_2bg_cfg = {
430 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \ 398 .ucode_api_min = IWL6000G2_UCODE_API_MIN, \
431 .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \ 399 .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \
432 .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \ 400 .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \
433 .ops = &iwl6030_ops, \ 401 .lib = &iwl6030_lib, \
434 .base_params = &iwl6000_g2_base_params, \ 402 .base_params = &iwl6000_g2_base_params, \
435 .bt_params = &iwl6000_bt_params, \ 403 .bt_params = &iwl6000_bt_params, \
436 .need_dc_calib = true, \ 404 .need_dc_calib = true, \
@@ -511,7 +479,7 @@ struct iwl_cfg iwl130_bg_cfg = {
511 .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \ 479 .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \
512 .eeprom_ver = EEPROM_6000_EEPROM_VERSION, \ 480 .eeprom_ver = EEPROM_6000_EEPROM_VERSION, \
513 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, \ 481 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, \
514 .ops = &iwl6000_ops, \ 482 .lib = &iwl6000_lib, \
515 .base_params = &iwl6000_base_params, \ 483 .base_params = &iwl6000_base_params, \
516 .pa_type = IWL_PA_INTERNAL, \ 484 .pa_type = IWL_PA_INTERNAL, \
517 .led_mode = IWL_LED_BLINK 485 .led_mode = IWL_LED_BLINK
@@ -538,7 +506,8 @@ struct iwl_cfg iwl6000i_2bg_cfg = {
538 .ucode_api_min = IWL6050_UCODE_API_MIN, \ 506 .ucode_api_min = IWL6050_UCODE_API_MIN, \
539 .valid_tx_ant = ANT_AB, /* .cfg overwrite */ \ 507 .valid_tx_ant = ANT_AB, /* .cfg overwrite */ \
540 .valid_rx_ant = ANT_AB, /* .cfg overwrite */ \ 508 .valid_rx_ant = ANT_AB, /* .cfg overwrite */ \
541 .ops = &iwl6050_ops, \ 509 .lib = &iwl6000_lib, \
510 .additional_nic_config = iwl6050_additional_nic_config, \
542 .eeprom_ver = EEPROM_6050_EEPROM_VERSION, \ 511 .eeprom_ver = EEPROM_6050_EEPROM_VERSION, \
543 .eeprom_calib_ver = EEPROM_6050_TX_POWER_VERSION, \ 512 .eeprom_calib_ver = EEPROM_6050_TX_POWER_VERSION, \
544 .base_params = &iwl6050_base_params, \ 513 .base_params = &iwl6050_base_params, \
@@ -561,7 +530,8 @@ struct iwl_cfg iwl6050_2abg_cfg = {
561 .fw_name_pre = IWL6050_FW_PRE, \ 530 .fw_name_pre = IWL6050_FW_PRE, \
562 .ucode_api_max = IWL6050_UCODE_API_MAX, \ 531 .ucode_api_max = IWL6050_UCODE_API_MAX, \
563 .ucode_api_min = IWL6050_UCODE_API_MIN, \ 532 .ucode_api_min = IWL6050_UCODE_API_MIN, \
564 .ops = &iwl6150_ops, \ 533 .lib = &iwl6000_lib, \
534 .additional_nic_config = iwl6150_additional_nic_config, \
565 .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \ 535 .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \
566 .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \ 536 .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \
567 .base_params = &iwl6050_base_params, \ 537 .base_params = &iwl6050_base_params, \
@@ -587,7 +557,7 @@ struct iwl_cfg iwl6000_3agn_cfg = {
587 .ucode_api_min = IWL6000_UCODE_API_MIN, 557 .ucode_api_min = IWL6000_UCODE_API_MIN,
588 .eeprom_ver = EEPROM_6000_EEPROM_VERSION, 558 .eeprom_ver = EEPROM_6000_EEPROM_VERSION,
589 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, 559 .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION,
590 .ops = &iwl6000_ops, 560 .lib = &iwl6000_lib,
591 .base_params = &iwl6000_base_params, 561 .base_params = &iwl6000_base_params,
592 .ht_params = &iwl6000_ht_params, 562 .ht_params = &iwl6000_ht_params,
593 .need_dc_calib = true, 563 .need_dc_calib = true,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 02c7c65ee86a..72d6297602b8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -98,7 +98,7 @@ int iwl_send_calib_results(struct iwl_priv *priv)
98 hcmd.len[0] = priv->calib_results[i].buf_len; 98 hcmd.len[0] = priv->calib_results[i].buf_len;
99 hcmd.data[0] = priv->calib_results[i].buf; 99 hcmd.data[0] = priv->calib_results[i].buf;
100 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; 100 hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
101 ret = trans_send_cmd(priv, &hcmd); 101 ret = trans_send_cmd(&priv->trans, &hcmd);
102 if (ret) { 102 if (ret) {
103 IWL_ERR(priv, "Error %d iteration %d\n", 103 IWL_ERR(priv, "Error %d iteration %d\n",
104 ret, i); 104 ret, i);
@@ -484,7 +484,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
484 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), 484 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]),
485 sizeof(u16)*HD_TABLE_SIZE); 485 sizeof(u16)*HD_TABLE_SIZE);
486 486
487 return trans_send_cmd(priv, &cmd_out); 487 return trans_send_cmd(&priv->trans, &cmd_out);
488} 488}
489 489
490/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ 490/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */
@@ -548,7 +548,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv)
548 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]), 548 &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]),
549 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES); 549 sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES);
550 550
551 return trans_send_cmd(priv, &cmd_out); 551 return trans_send_cmd(&priv->trans, &cmd_out);
552} 552}
553 553
554void iwl_init_sensitivity(struct iwl_priv *priv) 554void iwl_init_sensitivity(struct iwl_priv *priv)
@@ -840,6 +840,65 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
840 active_chains); 840 active_chains);
841} 841}
842 842
843static void iwlagn_gain_computation(struct iwl_priv *priv,
844 u32 average_noise[NUM_RX_CHAINS],
845 u16 min_average_noise_antenna_i,
846 u32 min_average_noise,
847 u8 default_chain)
848{
849 int i;
850 s32 delta_g;
851 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
852
853 /*
854 * Find Gain Code for the chains based on "default chain"
855 */
856 for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) {
857 if ((data->disconn_array[i])) {
858 data->delta_gain_code[i] = 0;
859 continue;
860 }
861
862 delta_g = (priv->cfg->base_params->chain_noise_scale *
863 ((s32)average_noise[default_chain] -
864 (s32)average_noise[i])) / 1500;
865
866 /* bound gain by 2 bits value max, 3rd bit is sign */
867 data->delta_gain_code[i] =
868 min(abs(delta_g),
869 (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
870
871 if (delta_g < 0)
872 /*
873 * set negative sign ...
874 * note to Intel developers: This is uCode API format,
875 * not the format of any internal device registers.
876 * Do not change this format for e.g. 6050 or similar
877 * devices. Change format only if more resolution
878 * (i.e. more than 2 bits magnitude) is needed.
879 */
880 data->delta_gain_code[i] |= (1 << 2);
881 }
882
883 IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n",
884 data->delta_gain_code[1], data->delta_gain_code[2]);
885
886 if (!data->radio_write) {
887 struct iwl_calib_chain_noise_gain_cmd cmd;
888
889 memset(&cmd, 0, sizeof(cmd));
890
891 iwl_set_calib_hdr(&cmd.hdr,
892 priv->phy_calib_chain_noise_gain_cmd);
893 cmd.delta_gain_1 = data->delta_gain_code[1];
894 cmd.delta_gain_2 = data->delta_gain_code[2];
895 trans_send_cmd_pdu(&priv->trans, REPLY_PHY_CALIBRATION_CMD,
896 CMD_ASYNC, sizeof(cmd), &cmd);
897
898 data->radio_write = 1;
899 data->state = IWL_CHAIN_NOISE_CALIBRATED;
900 }
901}
843 902
844/* 903/*
845 * Accumulate 16 beacons of signal and noise statistics for each of 904 * Accumulate 16 beacons of signal and noise statistics for each of
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
deleted file mode 100644
index f0f5f5eada75..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/sched.h>
34
35#include "iwl-dev.h"
36#include "iwl-core.h"
37#include "iwl-io.h"
38#include "iwl-agn.h"
39#include "iwl-trans.h"
40
41int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
42{
43 struct iwl_tx_ant_config_cmd tx_ant_cmd = {
44 .valid = cpu_to_le32(valid_tx_ant),
45 };
46
47 if (IWL_UCODE_API(priv->ucode_ver) > 1) {
48 IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
49 return trans_send_cmd_pdu(priv,
50 TX_ANT_CONFIGURATION_CMD,
51 CMD_SYNC,
52 sizeof(struct iwl_tx_ant_config_cmd),
53 &tx_ant_cmd);
54 } else {
55 IWL_DEBUG_HC(priv, "TX_ANT_CONFIGURATION_CMD not supported\n");
56 return -EOPNOTSUPP;
57 }
58}
59
60void iwlagn_gain_computation(struct iwl_priv *priv,
61 u32 average_noise[NUM_RX_CHAINS],
62 u16 min_average_noise_antenna_i,
63 u32 min_average_noise,
64 u8 default_chain)
65{
66 int i;
67 s32 delta_g;
68 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
69
70 /*
71 * Find Gain Code for the chains based on "default chain"
72 */
73 for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) {
74 if ((data->disconn_array[i])) {
75 data->delta_gain_code[i] = 0;
76 continue;
77 }
78
79 delta_g = (priv->cfg->base_params->chain_noise_scale *
80 ((s32)average_noise[default_chain] -
81 (s32)average_noise[i])) / 1500;
82
83 /* bound gain by 2 bits value max, 3rd bit is sign */
84 data->delta_gain_code[i] =
85 min(abs(delta_g), (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
86
87 if (delta_g < 0)
88 /*
89 * set negative sign ...
90 * note to Intel developers: This is uCode API format,
91 * not the format of any internal device registers.
92 * Do not change this format for e.g. 6050 or similar
93 * devices. Change format only if more resolution
94 * (i.e. more than 2 bits magnitude) is needed.
95 */
96 data->delta_gain_code[i] |= (1 << 2);
97 }
98
99 IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n",
100 data->delta_gain_code[1], data->delta_gain_code[2]);
101
102 if (!data->radio_write) {
103 struct iwl_calib_chain_noise_gain_cmd cmd;
104
105 memset(&cmd, 0, sizeof(cmd));
106
107 iwl_set_calib_hdr(&cmd.hdr,
108 priv->_agn.phy_calib_chain_noise_gain_cmd);
109 cmd.delta_gain_1 = data->delta_gain_code[1];
110 cmd.delta_gain_2 = data->delta_gain_code[2];
111 trans_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
112 CMD_ASYNC, sizeof(cmd), &cmd);
113
114 data->radio_write = 1;
115 data->state = IWL_CHAIN_NOISE_CALIBRATED;
116 }
117}
118
119int iwlagn_set_pan_params(struct iwl_priv *priv)
120{
121 struct iwl_wipan_params_cmd cmd;
122 struct iwl_rxon_context *ctx_bss, *ctx_pan;
123 int slot0 = 300, slot1 = 0;
124 int ret;
125
126 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS))
127 return 0;
128
129 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
130
131 lockdep_assert_held(&priv->mutex);
132
133 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
134 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
135
136 /*
137 * If the PAN context is inactive, then we don't need
138 * to update the PAN parameters, the last thing we'll
139 * have done before it goes inactive is making the PAN
140 * parameters be WLAN-only.
141 */
142 if (!ctx_pan->is_active)
143 return 0;
144
145 memset(&cmd, 0, sizeof(cmd));
146
147 /* only 2 slots are currently allowed */
148 cmd.num_slots = 2;
149
150 cmd.slots[0].type = 0; /* BSS */
151 cmd.slots[1].type = 1; /* PAN */
152
153 if (priv->_agn.hw_roc_channel) {
154 /* both contexts must be used for this to happen */
155 slot1 = priv->_agn.hw_roc_duration;
156 slot0 = IWL_MIN_SLOT_TIME;
157 } else if (ctx_bss->vif && ctx_pan->vif) {
158 int bcnint = ctx_pan->vif->bss_conf.beacon_int;
159 int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1;
160
161 /* should be set, but seems unused?? */
162 cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE);
163
164 if (ctx_pan->vif->type == NL80211_IFTYPE_AP &&
165 bcnint &&
166 bcnint != ctx_bss->vif->bss_conf.beacon_int) {
167 IWL_ERR(priv,
168 "beacon intervals don't match (%d, %d)\n",
169 ctx_bss->vif->bss_conf.beacon_int,
170 ctx_pan->vif->bss_conf.beacon_int);
171 } else
172 bcnint = max_t(int, bcnint,
173 ctx_bss->vif->bss_conf.beacon_int);
174 if (!bcnint)
175 bcnint = DEFAULT_BEACON_INTERVAL;
176 slot0 = bcnint / 2;
177 slot1 = bcnint - slot0;
178
179 if (test_bit(STATUS_SCAN_HW, &priv->status) ||
180 (!ctx_bss->vif->bss_conf.idle &&
181 !ctx_bss->vif->bss_conf.assoc)) {
182 slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME;
183 slot1 = IWL_MIN_SLOT_TIME;
184 } else if (!ctx_pan->vif->bss_conf.idle &&
185 !ctx_pan->vif->bss_conf.assoc) {
186 slot1 = bcnint * 3 - IWL_MIN_SLOT_TIME;
187 slot0 = IWL_MIN_SLOT_TIME;
188 }
189 } else if (ctx_pan->vif) {
190 slot0 = 0;
191 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
192 ctx_pan->vif->bss_conf.beacon_int;
193 slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1);
194
195 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
196 slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME;
197 slot1 = IWL_MIN_SLOT_TIME;
198 }
199 }
200
201 cmd.slots[0].width = cpu_to_le16(slot0);
202 cmd.slots[1].width = cpu_to_le16(slot1);
203
204 ret = trans_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC,
205 sizeof(cmd), &cmd);
206 if (ret)
207 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
208
209 return ret;
210}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ict.c b/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
deleted file mode 100644
index f1b40ec1c873..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
+++ /dev/null
@@ -1,306 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/etherdevice.h>
32#include <linux/sched.h>
33#include <linux/gfp.h>
34#include <net/mac80211.h>
35
36#include "iwl-dev.h"
37#include "iwl-core.h"
38#include "iwl-agn.h"
39#include "iwl-helpers.h"
40
41#define ICT_COUNT (PAGE_SIZE/sizeof(u32))
42
43/* Free dram table */
44void iwl_free_isr_ict(struct iwl_priv *priv)
45{
46 if (priv->_agn.ict_tbl_vir) {
47 dma_free_coherent(priv->bus.dev,
48 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
49 priv->_agn.ict_tbl_vir,
50 priv->_agn.ict_tbl_dma);
51 priv->_agn.ict_tbl_vir = NULL;
52 }
53}
54
55
56/* allocate dram shared table it is a PAGE_SIZE aligned
57 * also reset all data related to ICT table interrupt.
58 */
59int iwl_alloc_isr_ict(struct iwl_priv *priv)
60{
61
62 /* allocate shrared data table */
63 priv->_agn.ict_tbl_vir =
64 dma_alloc_coherent(priv->bus.dev,
65 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
66 &priv->_agn.ict_tbl_dma, GFP_KERNEL);
67 if (!priv->_agn.ict_tbl_vir)
68 return -ENOMEM;
69
70 /* align table to PAGE_SIZE boundary */
71 priv->_agn.aligned_ict_tbl_dma = ALIGN(priv->_agn.ict_tbl_dma, PAGE_SIZE);
72
73 IWL_DEBUG_ISR(priv, "ict dma addr %Lx dma aligned %Lx diff %d\n",
74 (unsigned long long)priv->_agn.ict_tbl_dma,
75 (unsigned long long)priv->_agn.aligned_ict_tbl_dma,
76 (int)(priv->_agn.aligned_ict_tbl_dma - priv->_agn.ict_tbl_dma));
77
78 priv->_agn.ict_tbl = priv->_agn.ict_tbl_vir +
79 (priv->_agn.aligned_ict_tbl_dma - priv->_agn.ict_tbl_dma);
80
81 IWL_DEBUG_ISR(priv, "ict vir addr %p vir aligned %p diff %d\n",
82 priv->_agn.ict_tbl, priv->_agn.ict_tbl_vir,
83 (int)(priv->_agn.aligned_ict_tbl_dma - priv->_agn.ict_tbl_dma));
84
85 /* reset table and index to all 0 */
86 memset(priv->_agn.ict_tbl_vir,0, (sizeof(u32) * ICT_COUNT) + PAGE_SIZE);
87 priv->_agn.ict_index = 0;
88
89 /* add periodic RX interrupt */
90 priv->inta_mask |= CSR_INT_BIT_RX_PERIODIC;
91 return 0;
92}
93
94/* Device is going up inform it about using ICT interrupt table,
95 * also we need to tell the driver to start using ICT interrupt.
96 */
97int iwl_reset_ict(struct iwl_priv *priv)
98{
99 u32 val;
100 unsigned long flags;
101
102 if (!priv->_agn.ict_tbl_vir)
103 return 0;
104
105 spin_lock_irqsave(&priv->lock, flags);
106 iwl_disable_interrupts(priv);
107
108 memset(&priv->_agn.ict_tbl[0], 0, sizeof(u32) * ICT_COUNT);
109
110 val = priv->_agn.aligned_ict_tbl_dma >> PAGE_SHIFT;
111
112 val |= CSR_DRAM_INT_TBL_ENABLE;
113 val |= CSR_DRAM_INIT_TBL_WRAP_CHECK;
114
115 IWL_DEBUG_ISR(priv, "CSR_DRAM_INT_TBL_REG =0x%X "
116 "aligned dma address %Lx\n",
117 val, (unsigned long long)priv->_agn.aligned_ict_tbl_dma);
118
119 iwl_write32(priv, CSR_DRAM_INT_TBL_REG, val);
120 priv->_agn.use_ict = true;
121 priv->_agn.ict_index = 0;
122 iwl_write32(priv, CSR_INT, priv->inta_mask);
123 iwl_enable_interrupts(priv);
124 spin_unlock_irqrestore(&priv->lock, flags);
125
126 return 0;
127}
128
129/* Device is going down disable ict interrupt usage */
130void iwl_disable_ict(struct iwl_priv *priv)
131{
132 unsigned long flags;
133
134 spin_lock_irqsave(&priv->lock, flags);
135 priv->_agn.use_ict = false;
136 spin_unlock_irqrestore(&priv->lock, flags);
137}
138
139static irqreturn_t iwl_isr(int irq, void *data)
140{
141 struct iwl_priv *priv = data;
142 u32 inta, inta_mask;
143 unsigned long flags;
144#ifdef CONFIG_IWLWIFI_DEBUG
145 u32 inta_fh;
146#endif
147 if (!priv)
148 return IRQ_NONE;
149
150 spin_lock_irqsave(&priv->lock, flags);
151
152 /* Disable (but don't clear!) interrupts here to avoid
153 * back-to-back ISRs and sporadic interrupts from our NIC.
154 * If we have something to service, the tasklet will re-enable ints.
155 * If we *don't* have something, we'll re-enable before leaving here. */
156 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
157 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
158
159 /* Discover which interrupts are active/pending */
160 inta = iwl_read32(priv, CSR_INT);
161
162 /* Ignore interrupt if there's nothing in NIC to service.
163 * This may be due to IRQ shared with another device,
164 * or due to sporadic interrupts thrown from our NIC. */
165 if (!inta) {
166 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
167 goto none;
168 }
169
170 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
171 /* Hardware disappeared. It might have already raised
172 * an interrupt */
173 IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
174 goto unplugged;
175 }
176
177#ifdef CONFIG_IWLWIFI_DEBUG
178 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
179 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
180 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, "
181 "fh 0x%08x\n", inta, inta_mask, inta_fh);
182 }
183#endif
184
185 priv->_agn.inta |= inta;
186 /* iwl_irq_tasklet() will service interrupts and re-enable them */
187 if (likely(inta))
188 tasklet_schedule(&priv->irq_tasklet);
189 else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta)
190 iwl_enable_interrupts(priv);
191
192 unplugged:
193 spin_unlock_irqrestore(&priv->lock, flags);
194 return IRQ_HANDLED;
195
196 none:
197 /* re-enable interrupts here since we don't have anything to service. */
198 /* only Re-enable if disabled by irq and no schedules tasklet. */
199 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta)
200 iwl_enable_interrupts(priv);
201
202 spin_unlock_irqrestore(&priv->lock, flags);
203 return IRQ_NONE;
204}
205
206/* interrupt handler using ict table, with this interrupt driver will
207 * stop using INTA register to get device's interrupt, reading this register
208 * is expensive, device will write interrupts in ICT dram table, increment
209 * index then will fire interrupt to driver, driver will OR all ICT table
210 * entries from current index up to table entry with 0 value. the result is
211 * the interrupt we need to service, driver will set the entries back to 0 and
212 * set index.
213 */
214irqreturn_t iwl_isr_ict(int irq, void *data)
215{
216 struct iwl_priv *priv = data;
217 u32 inta, inta_mask;
218 u32 val = 0;
219 unsigned long flags;
220
221 if (!priv)
222 return IRQ_NONE;
223
224 /* dram interrupt table not set yet,
225 * use legacy interrupt.
226 */
227 if (!priv->_agn.use_ict)
228 return iwl_isr(irq, data);
229
230 spin_lock_irqsave(&priv->lock, flags);
231
232 /* Disable (but don't clear!) interrupts here to avoid
233 * back-to-back ISRs and sporadic interrupts from our NIC.
234 * If we have something to service, the tasklet will re-enable ints.
235 * If we *don't* have something, we'll re-enable before leaving here.
236 */
237 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
238 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
239
240
241 /* Ignore interrupt if there's nothing in NIC to service.
242 * This may be due to IRQ shared with another device,
243 * or due to sporadic interrupts thrown from our NIC. */
244 if (!priv->_agn.ict_tbl[priv->_agn.ict_index]) {
245 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
246 goto none;
247 }
248
249 /* read all entries that not 0 start with ict_index */
250 while (priv->_agn.ict_tbl[priv->_agn.ict_index]) {
251
252 val |= le32_to_cpu(priv->_agn.ict_tbl[priv->_agn.ict_index]);
253 IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n",
254 priv->_agn.ict_index,
255 le32_to_cpu(priv->_agn.ict_tbl[priv->_agn.ict_index]));
256 priv->_agn.ict_tbl[priv->_agn.ict_index] = 0;
257 priv->_agn.ict_index = iwl_queue_inc_wrap(priv->_agn.ict_index,
258 ICT_COUNT);
259
260 }
261
262 /* We should not get this value, just ignore it. */
263 if (val == 0xffffffff)
264 val = 0;
265
266 /*
267 * this is a w/a for a h/w bug. the h/w bug may cause the Rx bit
268 * (bit 15 before shifting it to 31) to clear when using interrupt
269 * coalescing. fortunately, bits 18 and 19 stay set when this happens
270 * so we use them to decide on the real state of the Rx bit.
271 * In order words, bit 15 is set if bit 18 or bit 19 are set.
272 */
273 if (val & 0xC0000)
274 val |= 0x8000;
275
276 inta = (0xff & val) | ((0xff00 & val) << 16);
277 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x ict 0x%08x\n",
278 inta, inta_mask, val);
279
280 inta &= priv->inta_mask;
281 priv->_agn.inta |= inta;
282
283 /* iwl_irq_tasklet() will service interrupts and re-enable them */
284 if (likely(inta))
285 tasklet_schedule(&priv->irq_tasklet);
286 else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta) {
287 /* Allow interrupt if was disabled by this handler and
288 * no tasklet was schedules, We should not enable interrupt,
289 * tasklet will enable it.
290 */
291 iwl_enable_interrupts(priv);
292 }
293
294 spin_unlock_irqrestore(&priv->lock, flags);
295 return IRQ_HANDLED;
296
297 none:
298 /* re-enable interrupts here since we don't have anything to service.
299 * only Re-enable if disabled by irq.
300 */
301 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta)
302 iwl_enable_interrupts(priv);
303
304 spin_unlock_irqrestore(&priv->lock, flags);
305 return IRQ_NONE;
306}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index eb2be0d30483..3bee0f119bcd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -53,73 +53,73 @@ static void iwlagn_count_tx_err_status(struct iwl_priv *priv, u16 status)
53 53
54 switch (status) { 54 switch (status) {
55 case TX_STATUS_POSTPONE_DELAY: 55 case TX_STATUS_POSTPONE_DELAY:
56 priv->_agn.reply_tx_stats.pp_delay++; 56 priv->reply_tx_stats.pp_delay++;
57 break; 57 break;
58 case TX_STATUS_POSTPONE_FEW_BYTES: 58 case TX_STATUS_POSTPONE_FEW_BYTES:
59 priv->_agn.reply_tx_stats.pp_few_bytes++; 59 priv->reply_tx_stats.pp_few_bytes++;
60 break; 60 break;
61 case TX_STATUS_POSTPONE_BT_PRIO: 61 case TX_STATUS_POSTPONE_BT_PRIO:
62 priv->_agn.reply_tx_stats.pp_bt_prio++; 62 priv->reply_tx_stats.pp_bt_prio++;
63 break; 63 break;
64 case TX_STATUS_POSTPONE_QUIET_PERIOD: 64 case TX_STATUS_POSTPONE_QUIET_PERIOD:
65 priv->_agn.reply_tx_stats.pp_quiet_period++; 65 priv->reply_tx_stats.pp_quiet_period++;
66 break; 66 break;
67 case TX_STATUS_POSTPONE_CALC_TTAK: 67 case TX_STATUS_POSTPONE_CALC_TTAK:
68 priv->_agn.reply_tx_stats.pp_calc_ttak++; 68 priv->reply_tx_stats.pp_calc_ttak++;
69 break; 69 break;
70 case TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY: 70 case TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY:
71 priv->_agn.reply_tx_stats.int_crossed_retry++; 71 priv->reply_tx_stats.int_crossed_retry++;
72 break; 72 break;
73 case TX_STATUS_FAIL_SHORT_LIMIT: 73 case TX_STATUS_FAIL_SHORT_LIMIT:
74 priv->_agn.reply_tx_stats.short_limit++; 74 priv->reply_tx_stats.short_limit++;
75 break; 75 break;
76 case TX_STATUS_FAIL_LONG_LIMIT: 76 case TX_STATUS_FAIL_LONG_LIMIT:
77 priv->_agn.reply_tx_stats.long_limit++; 77 priv->reply_tx_stats.long_limit++;
78 break; 78 break;
79 case TX_STATUS_FAIL_FIFO_UNDERRUN: 79 case TX_STATUS_FAIL_FIFO_UNDERRUN:
80 priv->_agn.reply_tx_stats.fifo_underrun++; 80 priv->reply_tx_stats.fifo_underrun++;
81 break; 81 break;
82 case TX_STATUS_FAIL_DRAIN_FLOW: 82 case TX_STATUS_FAIL_DRAIN_FLOW:
83 priv->_agn.reply_tx_stats.drain_flow++; 83 priv->reply_tx_stats.drain_flow++;
84 break; 84 break;
85 case TX_STATUS_FAIL_RFKILL_FLUSH: 85 case TX_STATUS_FAIL_RFKILL_FLUSH:
86 priv->_agn.reply_tx_stats.rfkill_flush++; 86 priv->reply_tx_stats.rfkill_flush++;
87 break; 87 break;
88 case TX_STATUS_FAIL_LIFE_EXPIRE: 88 case TX_STATUS_FAIL_LIFE_EXPIRE:
89 priv->_agn.reply_tx_stats.life_expire++; 89 priv->reply_tx_stats.life_expire++;
90 break; 90 break;
91 case TX_STATUS_FAIL_DEST_PS: 91 case TX_STATUS_FAIL_DEST_PS:
92 priv->_agn.reply_tx_stats.dest_ps++; 92 priv->reply_tx_stats.dest_ps++;
93 break; 93 break;
94 case TX_STATUS_FAIL_HOST_ABORTED: 94 case TX_STATUS_FAIL_HOST_ABORTED:
95 priv->_agn.reply_tx_stats.host_abort++; 95 priv->reply_tx_stats.host_abort++;
96 break; 96 break;
97 case TX_STATUS_FAIL_BT_RETRY: 97 case TX_STATUS_FAIL_BT_RETRY:
98 priv->_agn.reply_tx_stats.bt_retry++; 98 priv->reply_tx_stats.bt_retry++;
99 break; 99 break;
100 case TX_STATUS_FAIL_STA_INVALID: 100 case TX_STATUS_FAIL_STA_INVALID:
101 priv->_agn.reply_tx_stats.sta_invalid++; 101 priv->reply_tx_stats.sta_invalid++;
102 break; 102 break;
103 case TX_STATUS_FAIL_FRAG_DROPPED: 103 case TX_STATUS_FAIL_FRAG_DROPPED:
104 priv->_agn.reply_tx_stats.frag_drop++; 104 priv->reply_tx_stats.frag_drop++;
105 break; 105 break;
106 case TX_STATUS_FAIL_TID_DISABLE: 106 case TX_STATUS_FAIL_TID_DISABLE:
107 priv->_agn.reply_tx_stats.tid_disable++; 107 priv->reply_tx_stats.tid_disable++;
108 break; 108 break;
109 case TX_STATUS_FAIL_FIFO_FLUSHED: 109 case TX_STATUS_FAIL_FIFO_FLUSHED:
110 priv->_agn.reply_tx_stats.fifo_flush++; 110 priv->reply_tx_stats.fifo_flush++;
111 break; 111 break;
112 case TX_STATUS_FAIL_INSUFFICIENT_CF_POLL: 112 case TX_STATUS_FAIL_INSUFFICIENT_CF_POLL:
113 priv->_agn.reply_tx_stats.insuff_cf_poll++; 113 priv->reply_tx_stats.insuff_cf_poll++;
114 break; 114 break;
115 case TX_STATUS_FAIL_PASSIVE_NO_RX: 115 case TX_STATUS_FAIL_PASSIVE_NO_RX:
116 priv->_agn.reply_tx_stats.fail_hw_drop++; 116 priv->reply_tx_stats.fail_hw_drop++;
117 break; 117 break;
118 case TX_STATUS_FAIL_NO_BEACON_ON_RADAR: 118 case TX_STATUS_FAIL_NO_BEACON_ON_RADAR:
119 priv->_agn.reply_tx_stats.sta_color_mismatch++; 119 priv->reply_tx_stats.sta_color_mismatch++;
120 break; 120 break;
121 default: 121 default:
122 priv->_agn.reply_tx_stats.unknown++; 122 priv->reply_tx_stats.unknown++;
123 break; 123 break;
124 } 124 }
125} 125}
@@ -130,43 +130,43 @@ static void iwlagn_count_agg_tx_err_status(struct iwl_priv *priv, u16 status)
130 130
131 switch (status) { 131 switch (status) {
132 case AGG_TX_STATE_UNDERRUN_MSK: 132 case AGG_TX_STATE_UNDERRUN_MSK:
133 priv->_agn.reply_agg_tx_stats.underrun++; 133 priv->reply_agg_tx_stats.underrun++;
134 break; 134 break;
135 case AGG_TX_STATE_BT_PRIO_MSK: 135 case AGG_TX_STATE_BT_PRIO_MSK:
136 priv->_agn.reply_agg_tx_stats.bt_prio++; 136 priv->reply_agg_tx_stats.bt_prio++;
137 break; 137 break;
138 case AGG_TX_STATE_FEW_BYTES_MSK: 138 case AGG_TX_STATE_FEW_BYTES_MSK:
139 priv->_agn.reply_agg_tx_stats.few_bytes++; 139 priv->reply_agg_tx_stats.few_bytes++;
140 break; 140 break;
141 case AGG_TX_STATE_ABORT_MSK: 141 case AGG_TX_STATE_ABORT_MSK:
142 priv->_agn.reply_agg_tx_stats.abort++; 142 priv->reply_agg_tx_stats.abort++;
143 break; 143 break;
144 case AGG_TX_STATE_LAST_SENT_TTL_MSK: 144 case AGG_TX_STATE_LAST_SENT_TTL_MSK:
145 priv->_agn.reply_agg_tx_stats.last_sent_ttl++; 145 priv->reply_agg_tx_stats.last_sent_ttl++;
146 break; 146 break;
147 case AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK: 147 case AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK:
148 priv->_agn.reply_agg_tx_stats.last_sent_try++; 148 priv->reply_agg_tx_stats.last_sent_try++;
149 break; 149 break;
150 case AGG_TX_STATE_LAST_SENT_BT_KILL_MSK: 150 case AGG_TX_STATE_LAST_SENT_BT_KILL_MSK:
151 priv->_agn.reply_agg_tx_stats.last_sent_bt_kill++; 151 priv->reply_agg_tx_stats.last_sent_bt_kill++;
152 break; 152 break;
153 case AGG_TX_STATE_SCD_QUERY_MSK: 153 case AGG_TX_STATE_SCD_QUERY_MSK:
154 priv->_agn.reply_agg_tx_stats.scd_query++; 154 priv->reply_agg_tx_stats.scd_query++;
155 break; 155 break;
156 case AGG_TX_STATE_TEST_BAD_CRC32_MSK: 156 case AGG_TX_STATE_TEST_BAD_CRC32_MSK:
157 priv->_agn.reply_agg_tx_stats.bad_crc32++; 157 priv->reply_agg_tx_stats.bad_crc32++;
158 break; 158 break;
159 case AGG_TX_STATE_RESPONSE_MSK: 159 case AGG_TX_STATE_RESPONSE_MSK:
160 priv->_agn.reply_agg_tx_stats.response++; 160 priv->reply_agg_tx_stats.response++;
161 break; 161 break;
162 case AGG_TX_STATE_DUMP_TX_MSK: 162 case AGG_TX_STATE_DUMP_TX_MSK:
163 priv->_agn.reply_agg_tx_stats.dump_tx++; 163 priv->reply_agg_tx_stats.dump_tx++;
164 break; 164 break;
165 case AGG_TX_STATE_DELAY_TX_MSK: 165 case AGG_TX_STATE_DELAY_TX_MSK:
166 priv->_agn.reply_agg_tx_stats.delay_tx++; 166 priv->reply_agg_tx_stats.delay_tx++;
167 break; 167 break;
168 default: 168 default:
169 priv->_agn.reply_agg_tx_stats.unknown++; 169 priv->reply_agg_tx_stats.unknown++;
170 break; 170 break;
171 } 171 }
172} 172}
@@ -391,8 +391,7 @@ void iwl_check_abort_status(struct iwl_priv *priv,
391 } 391 }
392} 392}
393 393
394static void iwlagn_rx_reply_tx(struct iwl_priv *priv, 394void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
395 struct iwl_rx_mem_buffer *rxb)
396{ 395{
397 struct iwl_rx_packet *pkt = rxb_addr(rxb); 396 struct iwl_rx_packet *pkt = rxb_addr(rxb);
398 u16 sequence = le16_to_cpu(pkt->hdr.sequence); 397 u16 sequence = le16_to_cpu(pkt->hdr.sequence);
@@ -401,6 +400,7 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
401 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 400 struct iwl_tx_queue *txq = &priv->txq[txq_id];
402 struct ieee80211_tx_info *info; 401 struct ieee80211_tx_info *info;
403 struct iwlagn_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 402 struct iwlagn_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
403 struct ieee80211_hdr *hdr;
404 struct iwl_tx_info *txb; 404 struct iwl_tx_info *txb;
405 u32 status = le16_to_cpu(tx_resp->status.status); 405 u32 status = le16_to_cpu(tx_resp->status.status);
406 int tid; 406 int tid;
@@ -427,6 +427,11 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
427 IWLAGN_TX_RES_RA_POS; 427 IWLAGN_TX_RES_RA_POS;
428 428
429 spin_lock_irqsave(&priv->sta_lock, flags); 429 spin_lock_irqsave(&priv->sta_lock, flags);
430
431 hdr = (void *)txb->skb->data;
432 if (!ieee80211_is_data_qos(hdr->frame_control))
433 priv->last_seq_ctl = tx_resp->seq_ctl;
434
430 if (txq->sched_retry) { 435 if (txq->sched_retry) {
431 const u32 scd_ssn = iwlagn_get_scd_ssn(tx_resp); 436 const u32 scd_ssn = iwlagn_get_scd_ssn(tx_resp);
432 struct iwl_ht_agg *agg; 437 struct iwl_ht_agg *agg;
@@ -479,27 +484,6 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
479 spin_unlock_irqrestore(&priv->sta_lock, flags); 484 spin_unlock_irqrestore(&priv->sta_lock, flags);
480} 485}
481 486
482void iwlagn_rx_handler_setup(struct iwl_priv *priv)
483{
484 /* init calibration handlers */
485 priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
486 iwlagn_rx_calib_result;
487 priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx;
488
489 /* set up notification wait support */
490 spin_lock_init(&priv->_agn.notif_wait_lock);
491 INIT_LIST_HEAD(&priv->_agn.notif_waits);
492 init_waitqueue_head(&priv->_agn.notif_waitq);
493}
494
495void iwlagn_setup_deferred_work(struct iwl_priv *priv)
496{
497 /*
498 * nothing need to be done here anymore
499 * still keep for future use if needed
500 */
501}
502
503int iwlagn_hw_valid_rtc_data_addr(u32 addr) 487int iwlagn_hw_valid_rtc_data_addr(u32 addr)
504{ 488{
505 return (addr >= IWLAGN_RTC_DATA_LOWER_BOUND) && 489 return (addr >= IWLAGN_RTC_DATA_LOWER_BOUND) &&
@@ -541,7 +525,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
541 else 525 else
542 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD; 526 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
543 527
544 return trans_send_cmd_pdu(priv, tx_ant_cfg_cmd, CMD_SYNC, 528 return trans_send_cmd_pdu(&priv->trans, tx_ant_cfg_cmd, CMD_SYNC,
545 sizeof(tx_power_cmd), &tx_power_cmd); 529 sizeof(tx_power_cmd), &tx_power_cmd);
546} 530}
547 531
@@ -628,283 +612,6 @@ struct iwl_mod_params iwlagn_mod_params = {
628 /* the rest are 0 by default */ 612 /* the rest are 0 by default */
629}; 613};
630 614
631int iwlagn_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
632{
633 u32 rb_size;
634 const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */
635 u32 rb_timeout = 0; /* FIXME: RX_RB_TIMEOUT for all devices? */
636
637 rb_timeout = RX_RB_TIMEOUT;
638
639 if (iwlagn_mod_params.amsdu_size_8K)
640 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K;
641 else
642 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K;
643
644 /* Stop Rx DMA */
645 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
646
647 /* Reset driver's Rx queue write index */
648 iwl_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0);
649
650 /* Tell device where to find RBD circular buffer in DRAM */
651 iwl_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG,
652 (u32)(rxq->bd_dma >> 8));
653
654 /* Tell device where in DRAM to update its Rx status */
655 iwl_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG,
656 rxq->rb_stts_dma >> 4);
657
658 /* Enable Rx DMA
659 * FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set because of HW bug in
660 * the credit mechanism in 5000 HW RX FIFO
661 * Direct rx interrupts to hosts
662 * Rx buffer size 4 or 8k
663 * RB timeout 0x10
664 * 256 RBDs
665 */
666 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG,
667 FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL |
668 FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY |
669 FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL |
670 FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK |
671 rb_size|
672 (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)|
673 (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS));
674
675 /* Set interrupt coalescing timer to default (2048 usecs) */
676 iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF);
677
678 return 0;
679}
680
681static void iwlagn_set_pwr_vmain(struct iwl_priv *priv)
682{
683/*
684 * (for documentation purposes)
685 * to set power to V_AUX, do:
686
687 if (pci_pme_capable(priv->pci_dev, PCI_D3cold))
688 iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
689 APMG_PS_CTRL_VAL_PWR_SRC_VAUX,
690 ~APMG_PS_CTRL_MSK_PWR_SRC);
691 */
692
693 iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
694 APMG_PS_CTRL_VAL_PWR_SRC_VMAIN,
695 ~APMG_PS_CTRL_MSK_PWR_SRC);
696}
697
698int iwlagn_hw_nic_init(struct iwl_priv *priv)
699{
700 unsigned long flags;
701 struct iwl_rx_queue *rxq = &priv->rxq;
702
703 /* nic_init */
704 spin_lock_irqsave(&priv->lock, flags);
705 iwl_apm_init(priv);
706
707 /* Set interrupt coalescing calibration timer to default (512 usecs) */
708 iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF);
709
710 spin_unlock_irqrestore(&priv->lock, flags);
711
712 iwlagn_set_pwr_vmain(priv);
713
714 priv->cfg->ops->lib->nic_config(priv);
715
716 /* Allocate the RX queue, or reset if it is already allocated */
717 trans_rx_init(priv);
718
719 iwlagn_rx_replenish(priv);
720
721 iwlagn_rx_init(priv, rxq);
722
723 spin_lock_irqsave(&priv->lock, flags);
724
725 rxq->need_update = 1;
726 iwl_rx_queue_update_write_ptr(priv, rxq);
727
728 spin_unlock_irqrestore(&priv->lock, flags);
729
730 /* Allocate or reset and init all Tx and Command queues */
731 if (trans_tx_init(priv))
732 return -ENOMEM;
733
734 if (priv->cfg->base_params->shadow_reg_enable) {
735 /* enable shadow regs in HW */
736 iwl_set_bit(priv, CSR_MAC_SHADOW_REG_CTRL,
737 0x800FFFFF);
738 }
739
740 set_bit(STATUS_INIT, &priv->status);
741
742 return 0;
743}
744
745/**
746 * iwlagn_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
747 */
748static inline __le32 iwlagn_dma_addr2rbd_ptr(struct iwl_priv *priv,
749 dma_addr_t dma_addr)
750{
751 return cpu_to_le32((u32)(dma_addr >> 8));
752}
753
754/**
755 * iwlagn_rx_queue_restock - refill RX queue from pre-allocated pool
756 *
757 * If there are slots in the RX queue that need to be restocked,
758 * and we have free pre-allocated buffers, fill the ranks as much
759 * as we can, pulling from rx_free.
760 *
761 * This moves the 'write' index forward to catch up with 'processed', and
762 * also updates the memory address in the firmware to reference the new
763 * target buffer.
764 */
765void iwlagn_rx_queue_restock(struct iwl_priv *priv)
766{
767 struct iwl_rx_queue *rxq = &priv->rxq;
768 struct list_head *element;
769 struct iwl_rx_mem_buffer *rxb;
770 unsigned long flags;
771
772 spin_lock_irqsave(&rxq->lock, flags);
773 while ((iwl_rx_queue_space(rxq) > 0) && (rxq->free_count)) {
774 /* The overwritten rxb must be a used one */
775 rxb = rxq->queue[rxq->write];
776 BUG_ON(rxb && rxb->page);
777
778 /* Get next free Rx buffer, remove from free list */
779 element = rxq->rx_free.next;
780 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
781 list_del(element);
782
783 /* Point to Rx buffer via next RBD in circular buffer */
784 rxq->bd[rxq->write] = iwlagn_dma_addr2rbd_ptr(priv,
785 rxb->page_dma);
786 rxq->queue[rxq->write] = rxb;
787 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK;
788 rxq->free_count--;
789 }
790 spin_unlock_irqrestore(&rxq->lock, flags);
791 /* If the pre-allocated buffer pool is dropping low, schedule to
792 * refill it */
793 if (rxq->free_count <= RX_LOW_WATERMARK)
794 queue_work(priv->workqueue, &priv->rx_replenish);
795
796
797 /* If we've added more space for the firmware to place data, tell it.
798 * Increment device's write pointer in multiples of 8. */
799 if (rxq->write_actual != (rxq->write & ~0x7)) {
800 spin_lock_irqsave(&rxq->lock, flags);
801 rxq->need_update = 1;
802 spin_unlock_irqrestore(&rxq->lock, flags);
803 iwl_rx_queue_update_write_ptr(priv, rxq);
804 }
805}
806
807/**
808 * iwlagn_rx_replenish - Move all used packet from rx_used to rx_free
809 *
810 * When moving to rx_free an SKB is allocated for the slot.
811 *
812 * Also restock the Rx queue via iwl_rx_queue_restock.
813 * This is called as a scheduled work item (except for during initialization)
814 */
815void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority)
816{
817 struct iwl_rx_queue *rxq = &priv->rxq;
818 struct list_head *element;
819 struct iwl_rx_mem_buffer *rxb;
820 struct page *page;
821 unsigned long flags;
822 gfp_t gfp_mask = priority;
823
824 while (1) {
825 spin_lock_irqsave(&rxq->lock, flags);
826 if (list_empty(&rxq->rx_used)) {
827 spin_unlock_irqrestore(&rxq->lock, flags);
828 return;
829 }
830 spin_unlock_irqrestore(&rxq->lock, flags);
831
832 if (rxq->free_count > RX_LOW_WATERMARK)
833 gfp_mask |= __GFP_NOWARN;
834
835 if (priv->hw_params.rx_page_order > 0)
836 gfp_mask |= __GFP_COMP;
837
838 /* Alloc a new receive buffer */
839 page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order);
840 if (!page) {
841 if (net_ratelimit())
842 IWL_DEBUG_INFO(priv, "alloc_pages failed, "
843 "order: %d\n",
844 priv->hw_params.rx_page_order);
845
846 if ((rxq->free_count <= RX_LOW_WATERMARK) &&
847 net_ratelimit())
848 IWL_CRIT(priv, "Failed to alloc_pages with %s. Only %u free buffers remaining.\n",
849 priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL",
850 rxq->free_count);
851 /* We don't reschedule replenish work here -- we will
852 * call the restock method and if it still needs
853 * more buffers it will schedule replenish */
854 return;
855 }
856
857 spin_lock_irqsave(&rxq->lock, flags);
858
859 if (list_empty(&rxq->rx_used)) {
860 spin_unlock_irqrestore(&rxq->lock, flags);
861 __free_pages(page, priv->hw_params.rx_page_order);
862 return;
863 }
864 element = rxq->rx_used.next;
865 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
866 list_del(element);
867
868 spin_unlock_irqrestore(&rxq->lock, flags);
869
870 BUG_ON(rxb->page);
871 rxb->page = page;
872 /* Get physical address of the RB */
873 rxb->page_dma = dma_map_page(priv->bus.dev, page, 0,
874 PAGE_SIZE << priv->hw_params.rx_page_order,
875 DMA_FROM_DEVICE);
876 /* dma address must be no more than 36 bits */
877 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36));
878 /* and also 256 byte aligned! */
879 BUG_ON(rxb->page_dma & DMA_BIT_MASK(8));
880
881 spin_lock_irqsave(&rxq->lock, flags);
882
883 list_add_tail(&rxb->list, &rxq->rx_free);
884 rxq->free_count++;
885
886 spin_unlock_irqrestore(&rxq->lock, flags);
887 }
888}
889
890void iwlagn_rx_replenish(struct iwl_priv *priv)
891{
892 unsigned long flags;
893
894 iwlagn_rx_allocate(priv, GFP_KERNEL);
895
896 spin_lock_irqsave(&priv->lock, flags);
897 iwlagn_rx_queue_restock(priv);
898 spin_unlock_irqrestore(&priv->lock, flags);
899}
900
901void iwlagn_rx_replenish_now(struct iwl_priv *priv)
902{
903 iwlagn_rx_allocate(priv, GFP_ATOMIC);
904
905 iwlagn_rx_queue_restock(priv);
906}
907
908int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) 615int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band)
909{ 616{
910 int idx = 0; 617 int idx = 0;
@@ -1048,7 +755,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1048 755
1049static int iwl_fill_offch_tx(struct iwl_priv *priv, void *data, size_t maxlen) 756static int iwl_fill_offch_tx(struct iwl_priv *priv, void *data, size_t maxlen)
1050{ 757{
1051 struct sk_buff *skb = priv->_agn.offchan_tx_skb; 758 struct sk_buff *skb = priv->offchan_tx_skb;
1052 759
1053 if (skb->len < maxlen) 760 if (skb->len < maxlen)
1054 maxlen = skb->len; 761 maxlen = skb->len;
@@ -1134,7 +841,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1134 } else if (priv->scan_type == IWL_SCAN_OFFCH_TX) { 841 } else if (priv->scan_type == IWL_SCAN_OFFCH_TX) {
1135 scan->suspend_time = 0; 842 scan->suspend_time = 0;
1136 scan->max_out_time = 843 scan->max_out_time =
1137 cpu_to_le32(1024 * priv->_agn.offchan_tx_timeout); 844 cpu_to_le32(1024 * priv->offchan_tx_timeout);
1138 } 845 }
1139 846
1140 switch (priv->scan_type) { 847 switch (priv->scan_type) {
@@ -1322,9 +1029,9 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1322 scan_ch = (void *)&scan->data[cmd_len]; 1029 scan_ch = (void *)&scan->data[cmd_len];
1323 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; 1030 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
1324 scan_ch->channel = 1031 scan_ch->channel =
1325 cpu_to_le16(priv->_agn.offchan_tx_chan->hw_value); 1032 cpu_to_le16(priv->offchan_tx_chan->hw_value);
1326 scan_ch->active_dwell = 1033 scan_ch->active_dwell =
1327 cpu_to_le16(priv->_agn.offchan_tx_timeout); 1034 cpu_to_le16(priv->offchan_tx_timeout);
1328 scan_ch->passive_dwell = 0; 1035 scan_ch->passive_dwell = 0;
1329 1036
1330 /* Set txpower levels to defaults */ 1037 /* Set txpower levels to defaults */
@@ -1334,7 +1041,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1334 * power level: 1041 * power level:
1335 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; 1042 * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3;
1336 */ 1043 */
1337 if (priv->_agn.offchan_tx_chan->band == IEEE80211_BAND_5GHZ) 1044 if (priv->offchan_tx_chan->band == IEEE80211_BAND_5GHZ)
1338 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; 1045 scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3;
1339 else 1046 else
1340 scan_ch->tx_gain = ((1 << 5) | (5 << 3)); 1047 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
@@ -1360,7 +1067,7 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1360 if (ret) 1067 if (ret)
1361 return ret; 1068 return ret;
1362 1069
1363 ret = trans_send_cmd(priv, &cmd); 1070 ret = trans_send_cmd(&priv->trans, &cmd);
1364 if (ret) { 1071 if (ret) {
1365 clear_bit(STATUS_SCAN_HW, &priv->status); 1072 clear_bit(STATUS_SCAN_HW, &priv->status);
1366 iwlagn_set_pan_params(priv); 1073 iwlagn_set_pan_params(priv);
@@ -1466,7 +1173,7 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
1466 flush_cmd.fifo_control); 1173 flush_cmd.fifo_control);
1467 flush_cmd.flush_control = cpu_to_le16(flush_control); 1174 flush_cmd.flush_control = cpu_to_le16(flush_control);
1468 1175
1469 return trans_send_cmd(priv, &cmd); 1176 return trans_send_cmd(&priv->trans, &cmd);
1470} 1177}
1471 1178
1472void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control) 1179void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control)
@@ -1660,12 +1367,12 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
1660 if (priv->cfg->bt_params->bt_session_2) { 1367 if (priv->cfg->bt_params->bt_session_2) {
1661 memcpy(&bt_cmd_2000.basic, &basic, 1368 memcpy(&bt_cmd_2000.basic, &basic,
1662 sizeof(basic)); 1369 sizeof(basic));
1663 ret = trans_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1370 ret = trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
1664 CMD_SYNC, sizeof(bt_cmd_2000), &bt_cmd_2000); 1371 CMD_SYNC, sizeof(bt_cmd_2000), &bt_cmd_2000);
1665 } else { 1372 } else {
1666 memcpy(&bt_cmd_6000.basic, &basic, 1373 memcpy(&bt_cmd_6000.basic, &basic,
1667 sizeof(basic)); 1374 sizeof(basic));
1668 ret = trans_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1375 ret = trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
1669 CMD_SYNC, sizeof(bt_cmd_6000), &bt_cmd_6000); 1376 CMD_SYNC, sizeof(bt_cmd_6000), &bt_cmd_6000);
1670 } 1377 }
1671 if (ret) 1378 if (ret)
@@ -1986,15 +1693,12 @@ void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
1986 1693
1987void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv) 1694void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv)
1988{ 1695{
1989 iwlagn_rx_handler_setup(priv);
1990 priv->rx_handlers[REPLY_BT_COEX_PROFILE_NOTIF] = 1696 priv->rx_handlers[REPLY_BT_COEX_PROFILE_NOTIF] =
1991 iwlagn_bt_coex_profile_notif; 1697 iwlagn_bt_coex_profile_notif;
1992} 1698}
1993 1699
1994void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv) 1700void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv)
1995{ 1701{
1996 iwlagn_setup_deferred_work(priv);
1997
1998 INIT_WORK(&priv->bt_traffic_change_work, 1702 INIT_WORK(&priv->bt_traffic_change_work,
1999 iwlagn_bt_traffic_change_work); 1703 iwlagn_bt_traffic_change_work);
2000} 1704}
@@ -2306,9 +2010,9 @@ void iwlagn_init_notification_wait(struct iwl_priv *priv,
2306 wait_entry->triggered = false; 2010 wait_entry->triggered = false;
2307 wait_entry->aborted = false; 2011 wait_entry->aborted = false;
2308 2012
2309 spin_lock_bh(&priv->_agn.notif_wait_lock); 2013 spin_lock_bh(&priv->notif_wait_lock);
2310 list_add(&wait_entry->list, &priv->_agn.notif_waits); 2014 list_add(&wait_entry->list, &priv->notif_waits);
2311 spin_unlock_bh(&priv->_agn.notif_wait_lock); 2015 spin_unlock_bh(&priv->notif_wait_lock);
2312} 2016}
2313 2017
2314int iwlagn_wait_notification(struct iwl_priv *priv, 2018int iwlagn_wait_notification(struct iwl_priv *priv,
@@ -2317,13 +2021,13 @@ int iwlagn_wait_notification(struct iwl_priv *priv,
2317{ 2021{
2318 int ret; 2022 int ret;
2319 2023
2320 ret = wait_event_timeout(priv->_agn.notif_waitq, 2024 ret = wait_event_timeout(priv->notif_waitq,
2321 wait_entry->triggered || wait_entry->aborted, 2025 wait_entry->triggered || wait_entry->aborted,
2322 timeout); 2026 timeout);
2323 2027
2324 spin_lock_bh(&priv->_agn.notif_wait_lock); 2028 spin_lock_bh(&priv->notif_wait_lock);
2325 list_del(&wait_entry->list); 2029 list_del(&wait_entry->list);
2326 spin_unlock_bh(&priv->_agn.notif_wait_lock); 2030 spin_unlock_bh(&priv->notif_wait_lock);
2327 2031
2328 if (wait_entry->aborted) 2032 if (wait_entry->aborted)
2329 return -EIO; 2033 return -EIO;
@@ -2337,93 +2041,7 @@ int iwlagn_wait_notification(struct iwl_priv *priv,
2337void iwlagn_remove_notification(struct iwl_priv *priv, 2041void iwlagn_remove_notification(struct iwl_priv *priv,
2338 struct iwl_notification_wait *wait_entry) 2042 struct iwl_notification_wait *wait_entry)
2339{ 2043{
2340 spin_lock_bh(&priv->_agn.notif_wait_lock); 2044 spin_lock_bh(&priv->notif_wait_lock);
2341 list_del(&wait_entry->list); 2045 list_del(&wait_entry->list);
2342 spin_unlock_bh(&priv->_agn.notif_wait_lock); 2046 spin_unlock_bh(&priv->notif_wait_lock);
2343}
2344
2345int iwlagn_start_device(struct iwl_priv *priv)
2346{
2347 int ret;
2348
2349 if ((priv->cfg->sku & EEPROM_SKU_CAP_AMT_ENABLE) &&
2350 iwl_prepare_card_hw(priv)) {
2351 IWL_WARN(priv, "Exit HW not ready\n");
2352 return -EIO;
2353 }
2354
2355 /* If platform's RF_KILL switch is NOT set to KILL */
2356 if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
2357 clear_bit(STATUS_RF_KILL_HW, &priv->status);
2358 else
2359 set_bit(STATUS_RF_KILL_HW, &priv->status);
2360
2361 if (iwl_is_rfkill(priv)) {
2362 wiphy_rfkill_set_hw_state(priv->hw->wiphy, true);
2363 iwl_enable_interrupts(priv);
2364 return -ERFKILL;
2365 }
2366
2367 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
2368
2369 ret = iwlagn_hw_nic_init(priv);
2370 if (ret) {
2371 IWL_ERR(priv, "Unable to init nic\n");
2372 return ret;
2373 }
2374
2375 /* make sure rfkill handshake bits are cleared */
2376 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
2377 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
2378 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
2379
2380 /* clear (again), then enable host interrupts */
2381 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
2382 iwl_enable_interrupts(priv);
2383
2384 /* really make sure rfkill handshake bits are cleared */
2385 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
2386 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
2387
2388 return 0;
2389}
2390
2391void iwlagn_stop_device(struct iwl_priv *priv)
2392{
2393 unsigned long flags;
2394
2395 /* stop and reset the on-board processor */
2396 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
2397
2398 /* tell the device to stop sending interrupts */
2399 spin_lock_irqsave(&priv->lock, flags);
2400 iwl_disable_interrupts(priv);
2401 spin_unlock_irqrestore(&priv->lock, flags);
2402 iwl_synchronize_irq(priv);
2403
2404 /* device going down, Stop using ICT table */
2405 iwl_disable_ict(priv);
2406
2407 /*
2408 * If a HW restart happens during firmware loading,
2409 * then the firmware loading might call this function
2410 * and later it might be called again due to the
2411 * restart. So don't process again if the device is
2412 * already dead.
2413 */
2414 if (test_bit(STATUS_DEVICE_ENABLED, &priv->status)) {
2415 trans_tx_stop(priv);
2416 trans_rx_stop(priv);
2417
2418 /* Power-down device's busmaster DMA clocks */
2419 iwl_write_prph(priv, APMG_CLK_DIS_REG,
2420 APMG_CLK_VAL_DMA_CLK_RQT);
2421 udelay(5);
2422 }
2423
2424 /* Make sure (redundant) we've released our request to stay awake */
2425 iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
2426
2427 /* Stop the device, and put it in low power state */
2428 iwl_apm_stop(priv);
2429} 2047}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index ebcd13bc10d9..3789ff4bf53b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -354,9 +354,11 @@ static void rs_program_fix_rate(struct iwl_priv *priv,
354 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 354 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
355 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 355 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
356 356
357#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
357 /* testmode has higher priority to overwirte the fixed rate */ 358 /* testmode has higher priority to overwirte the fixed rate */
358 if (priv->tm_fixed_rate) 359 if (priv->tm_fixed_rate)
359 lq_sta->dbg_fixed_rate = priv->tm_fixed_rate; 360 lq_sta->dbg_fixed_rate = priv->tm_fixed_rate;
361#endif
360 362
361 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", 363 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n",
362 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); 364 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate);
@@ -1080,7 +1082,8 @@ done:
1080 /* See if there's a better rate or modulation mode to try. */ 1082 /* See if there's a better rate or modulation mode to try. */
1081 if (sta && sta->supp_rates[sband->band]) 1083 if (sta && sta->supp_rates[sband->band])
1082 rs_rate_scale_perform(priv, skb, sta, lq_sta); 1084 rs_rate_scale_perform(priv, skb, sta, lq_sta);
1083#ifdef CONFIG_MAC80211_DEBUGFS 1085
1086#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_IWLWIFI_DEVICE_SVTOOL)
1084 if ((priv->tm_fixed_rate) && 1087 if ((priv->tm_fixed_rate) &&
1085 (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate)) 1088 (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate))
1086 rs_program_fix_rate(priv, lq_sta); 1089 rs_program_fix_rate(priv, lq_sta);
@@ -2904,8 +2907,9 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i
2904 if (sband->band == IEEE80211_BAND_5GHZ) 2907 if (sband->band == IEEE80211_BAND_5GHZ)
2905 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2908 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
2906 lq_sta->is_agg = 0; 2909 lq_sta->is_agg = 0;
2907 2910#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
2908 priv->tm_fixed_rate = 0; 2911 priv->tm_fixed_rate = 0;
2912#endif
2909#ifdef CONFIG_MAC80211_DEBUGFS 2913#ifdef CONFIG_MAC80211_DEBUGFS
2910 lq_sta->dbg_fixed_rate = 0; 2914 lq_sta->dbg_fixed_rate = 0;
2911#endif 2915#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index dc64f2515357..d42ef1763a71 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -40,7 +40,7 @@ static int iwlagn_disable_bss(struct iwl_priv *priv,
40 int ret; 40 int ret;
41 41
42 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 42 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
43 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd, 43 ret = trans_send_cmd_pdu(&priv->trans, ctx->rxon_cmd,
44 CMD_SYNC, sizeof(*send), send); 44 CMD_SYNC, sizeof(*send), send);
45 45
46 send->filter_flags = old_filter; 46 send->filter_flags = old_filter;
@@ -66,7 +66,7 @@ static int iwlagn_disable_pan(struct iwl_priv *priv,
66 66
67 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 67 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
68 send->dev_type = RXON_DEV_TYPE_P2P; 68 send->dev_type = RXON_DEV_TYPE_P2P;
69 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd, 69 ret = trans_send_cmd_pdu(&priv->trans, ctx->rxon_cmd,
70 CMD_SYNC, sizeof(*send), send); 70 CMD_SYNC, sizeof(*send), send);
71 71
72 send->filter_flags = old_filter; 72 send->filter_flags = old_filter;
@@ -92,7 +92,7 @@ static int iwlagn_disconn_pan(struct iwl_priv *priv,
92 int ret; 92 int ret;
93 93
94 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 94 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
95 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, 95 ret = trans_send_cmd_pdu(&priv->trans, ctx->rxon_cmd, CMD_SYNC,
96 sizeof(*send), send); 96 sizeof(*send), send);
97 97
98 send->filter_flags = old_filter; 98 send->filter_flags = old_filter;
@@ -121,7 +121,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv,
121 ctx->qos_data.qos_active, 121 ctx->qos_data.qos_active,
122 ctx->qos_data.def_qos_parm.qos_flags); 122 ctx->qos_data.def_qos_parm.qos_flags);
123 123
124 ret = trans_send_cmd_pdu(priv, ctx->qos_cmd, CMD_SYNC, 124 ret = trans_send_cmd_pdu(&priv->trans, ctx->qos_cmd, CMD_SYNC,
125 sizeof(struct iwl_qosparam_cmd), 125 sizeof(struct iwl_qosparam_cmd),
126 &ctx->qos_data.def_qos_parm); 126 &ctx->qos_data.def_qos_parm);
127 if (ret) 127 if (ret)
@@ -180,7 +180,7 @@ static int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
180 ctx->staging.ofdm_ht_triple_stream_basic_rates; 180 ctx->staging.ofdm_ht_triple_stream_basic_rates;
181 rxon_assoc.acquisition_data = ctx->staging.acquisition_data; 181 rxon_assoc.acquisition_data = ctx->staging.acquisition_data;
182 182
183 ret = trans_send_cmd_pdu(priv, ctx->rxon_assoc_cmd, 183 ret = trans_send_cmd_pdu(&priv->trans, ctx->rxon_assoc_cmd,
184 CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc); 184 CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc);
185 return ret; 185 return ret;
186} 186}
@@ -266,7 +266,7 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
266 * Associated RXON doesn't clear the station table in uCode, 266 * Associated RXON doesn't clear the station table in uCode,
267 * so we don't need to restore stations etc. after this. 267 * so we don't need to restore stations etc. after this.
268 */ 268 */
269 ret = trans_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, 269 ret = trans_send_cmd_pdu(&priv->trans, ctx->rxon_cmd, CMD_SYNC,
270 sizeof(struct iwl_rxon_cmd), &ctx->staging); 270 sizeof(struct iwl_rxon_cmd), &ctx->staging);
271 if (ret) { 271 if (ret) {
272 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); 272 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
@@ -303,6 +303,98 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
303 return 0; 303 return 0;
304} 304}
305 305
306int iwlagn_set_pan_params(struct iwl_priv *priv)
307{
308 struct iwl_wipan_params_cmd cmd;
309 struct iwl_rxon_context *ctx_bss, *ctx_pan;
310 int slot0 = 300, slot1 = 0;
311 int ret;
312
313 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS))
314 return 0;
315
316 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
317
318 lockdep_assert_held(&priv->mutex);
319
320 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
321 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
322
323 /*
324 * If the PAN context is inactive, then we don't need
325 * to update the PAN parameters, the last thing we'll
326 * have done before it goes inactive is making the PAN
327 * parameters be WLAN-only.
328 */
329 if (!ctx_pan->is_active)
330 return 0;
331
332 memset(&cmd, 0, sizeof(cmd));
333
334 /* only 2 slots are currently allowed */
335 cmd.num_slots = 2;
336
337 cmd.slots[0].type = 0; /* BSS */
338 cmd.slots[1].type = 1; /* PAN */
339
340 if (priv->hw_roc_channel) {
341 /* both contexts must be used for this to happen */
342 slot1 = priv->hw_roc_duration;
343 slot0 = IWL_MIN_SLOT_TIME;
344 } else if (ctx_bss->vif && ctx_pan->vif) {
345 int bcnint = ctx_pan->beacon_int;
346 int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1;
347
348 /* should be set, but seems unused?? */
349 cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE);
350
351 if (ctx_pan->vif->type == NL80211_IFTYPE_AP &&
352 bcnint &&
353 bcnint != ctx_bss->beacon_int) {
354 IWL_ERR(priv,
355 "beacon intervals don't match (%d, %d)\n",
356 ctx_bss->beacon_int, ctx_pan->beacon_int);
357 } else
358 bcnint = max_t(int, bcnint,
359 ctx_bss->beacon_int);
360 if (!bcnint)
361 bcnint = DEFAULT_BEACON_INTERVAL;
362 slot0 = bcnint / 2;
363 slot1 = bcnint - slot0;
364
365 if (test_bit(STATUS_SCAN_HW, &priv->status) ||
366 (!ctx_bss->vif->bss_conf.idle &&
367 !ctx_bss->vif->bss_conf.assoc)) {
368 slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME;
369 slot1 = IWL_MIN_SLOT_TIME;
370 } else if (!ctx_pan->vif->bss_conf.idle &&
371 !ctx_pan->vif->bss_conf.assoc) {
372 slot1 = bcnint * 3 - IWL_MIN_SLOT_TIME;
373 slot0 = IWL_MIN_SLOT_TIME;
374 }
375 } else if (ctx_pan->vif) {
376 slot0 = 0;
377 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
378 ctx_pan->beacon_int;
379 slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1);
380
381 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
382 slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME;
383 slot1 = IWL_MIN_SLOT_TIME;
384 }
385 }
386
387 cmd.slots[0].width = cpu_to_le16(slot0);
388 cmd.slots[1].width = cpu_to_le16(slot1);
389
390 ret = trans_send_cmd_pdu(&priv->trans, REPLY_WIPAN_PARAMS, CMD_SYNC,
391 sizeof(cmd), &cmd);
392 if (ret)
393 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
394
395 return ret;
396}
397
306/** 398/**
307 * iwlagn_commit_rxon - commit staging_rxon to hardware 399 * iwlagn_commit_rxon - commit staging_rxon to hardware
308 * 400 *
@@ -345,8 +437,8 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
345 /* always get timestamp with Rx frame */ 437 /* always get timestamp with Rx frame */
346 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; 438 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
347 439
348 if (ctx->ctxid == IWL_RXON_CTX_PAN && priv->_agn.hw_roc_channel) { 440 if (ctx->ctxid == IWL_RXON_CTX_PAN && priv->hw_roc_channel) {
349 struct ieee80211_channel *chan = priv->_agn.hw_roc_channel; 441 struct ieee80211_channel *chan = priv->hw_roc_channel;
350 442
351 iwl_set_rxon_channel(priv, chan, ctx); 443 iwl_set_rxon_channel(priv, chan, ctx);
352 iwl_set_flags_for_band(priv, ctx, chan->band, NULL); 444 iwl_set_flags_for_band(priv, ctx, chan->band, NULL);
@@ -694,8 +786,8 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
694 786
695 memset(&cmd, 0, sizeof(cmd)); 787 memset(&cmd, 0, sizeof(cmd));
696 iwl_set_calib_hdr(&cmd.hdr, 788 iwl_set_calib_hdr(&cmd.hdr,
697 priv->_agn.phy_calib_chain_noise_reset_cmd); 789 priv->phy_calib_chain_noise_reset_cmd);
698 ret = trans_send_cmd_pdu(priv, 790 ret = trans_send_cmd_pdu(&priv->trans,
699 REPLY_PHY_CALIBRATION_CMD, 791 REPLY_PHY_CALIBRATION_CMD,
700 CMD_SYNC, sizeof(cmd), &cmd); 792 CMD_SYNC, sizeof(cmd), &cmd);
701 if (ret) 793 if (ret)
@@ -762,6 +854,9 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
762 iwl_wake_any_queue(priv, ctx); 854 iwl_wake_any_queue(priv, ctx);
763 } 855 }
764 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 856 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
857
858 if (ctx->ctxid == IWL_RXON_CTX_BSS)
859 priv->have_rekey_data = false;
765 } 860 }
766 861
767 iwlagn_bt_coex_rssi_monitor(priv); 862 iwlagn_bt_coex_rssi_monitor(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
index 001622c06526..37e624095e40 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
@@ -139,6 +139,14 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx
139 return 0; 139 return 0;
140} 140}
141 141
142/*
143 * static WEP keys
144 *
145 * For each context, the device has a table of 4 static WEP keys
146 * (one for each key index) that is updated with the following
147 * commands.
148 */
149
142static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, 150static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv,
143 struct iwl_rxon_context *ctx, 151 struct iwl_rxon_context *ctx,
144 bool send_if_empty) 152 bool send_if_empty)
@@ -181,7 +189,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv,
181 cmd.len[0] = cmd_size; 189 cmd.len[0] = cmd_size;
182 190
183 if (not_empty || send_if_empty) 191 if (not_empty || send_if_empty)
184 return trans_send_cmd(priv, &cmd); 192 return trans_send_cmd(&priv->trans, &cmd);
185 else 193 else
186 return 0; 194 return 0;
187} 195}
@@ -232,9 +240,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
232 return -EINVAL; 240 return -EINVAL;
233 } 241 }
234 242
235 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; 243 keyconf->hw_key_idx = IWLAGN_HW_KEY_DEFAULT;
236 keyconf->hw_key_idx = HW_KEY_DEFAULT;
237 priv->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher;
238 244
239 ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; 245 ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
240 memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, 246 memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key,
@@ -247,166 +253,117 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
247 return ret; 253 return ret;
248} 254}
249 255
250static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv, 256/*
251 struct iwl_rxon_context *ctx, 257 * dynamic (per-station) keys
252 struct ieee80211_key_conf *keyconf, 258 *
253 u8 sta_id) 259 * The dynamic keys are a little more complicated. The device has
254{ 260 * a key cache of up to STA_KEY_MAX_NUM/STA_KEY_MAX_NUM_PAN keys.
255 unsigned long flags; 261 * These are linked to stations by a table that contains an index
256 __le16 key_flags = 0; 262 * into the key table for each station/key index/{mcast,unicast},
257 struct iwl_addsta_cmd sta_cmd; 263 * i.e. it's basically an array of pointers like this:
258 264 * key_offset_t key_mapping[NUM_STATIONS][4][2];
259 lockdep_assert_held(&priv->mutex); 265 * (it really works differently, but you can think of it as such)
260 266 *
261 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; 267 * The key uploading and linking happens in the same command, the
262 268 * add station command with STA_MODIFY_KEY_MASK.
263 key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); 269 */
264 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
265 key_flags &= ~STA_KEY_FLG_INVALID;
266
267 if (keyconf->keylen == WEP_KEY_LEN_128)
268 key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
269
270 if (sta_id == ctx->bcast_sta_id)
271 key_flags |= STA_KEY_MULTICAST_MSK;
272
273 spin_lock_irqsave(&priv->sta_lock, flags);
274
275 priv->stations[sta_id].keyinfo.cipher = keyconf->cipher;
276 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
277 priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx;
278
279 memcpy(priv->stations[sta_id].keyinfo.key,
280 keyconf->key, keyconf->keylen);
281
282 memcpy(&priv->stations[sta_id].sta.key.key[3],
283 keyconf->key, keyconf->keylen);
284
285 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
286 == STA_KEY_FLG_NO_ENC)
287 priv->stations[sta_id].sta.key.key_offset =
288 iwl_get_free_ucode_key_index(priv);
289 /* else, we are overriding an existing key => no need to allocated room
290 * in uCode. */
291 270
292 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, 271static u8 iwlagn_key_sta_id(struct iwl_priv *priv,
293 "no space for a new key"); 272 struct ieee80211_vif *vif,
273 struct ieee80211_sta *sta)
274{
275 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
276 u8 sta_id = IWL_INVALID_STATION;
294 277
295 priv->stations[sta_id].sta.key.key_flags = key_flags; 278 if (sta)
296 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 279 sta_id = iwl_sta_id(sta);
297 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
298 280
299 memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd)); 281 /*
300 spin_unlock_irqrestore(&priv->sta_lock, flags); 282 * The device expects GTKs for station interfaces to be
283 * installed as GTKs for the AP station. If we have no
284 * station ID, then use the ap_sta_id in that case.
285 */
286 if (!sta && vif && vif_priv->ctx) {
287 switch (vif->type) {
288 case NL80211_IFTYPE_STATION:
289 sta_id = vif_priv->ctx->ap_sta_id;
290 break;
291 default:
292 /*
293 * In all other cases, the key will be
294 * used either for TX only or is bound
295 * to a station already.
296 */
297 break;
298 }
299 }
301 300
302 return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); 301 return sta_id;
303} 302}
304 303
305static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv, 304static int iwlagn_send_sta_key(struct iwl_priv *priv,
306 struct iwl_rxon_context *ctx, 305 struct ieee80211_key_conf *keyconf,
307 struct ieee80211_key_conf *keyconf, 306 u8 sta_id, u32 tkip_iv32, u16 *tkip_p1k,
308 u8 sta_id) 307 u32 cmd_flags)
309{ 308{
310 unsigned long flags; 309 unsigned long flags;
311 __le16 key_flags = 0; 310 __le16 key_flags;
312 struct iwl_addsta_cmd sta_cmd; 311 struct iwl_addsta_cmd sta_cmd;
313 312 int i;
314 lockdep_assert_held(&priv->mutex);
315
316 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
317 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
318 key_flags &= ~STA_KEY_FLG_INVALID;
319
320 if (sta_id == ctx->bcast_sta_id)
321 key_flags |= STA_KEY_MULTICAST_MSK;
322
323 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
324 313
325 spin_lock_irqsave(&priv->sta_lock, flags); 314 spin_lock_irqsave(&priv->sta_lock, flags);
326 priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; 315 memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd));
327 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
328
329 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key,
330 keyconf->keylen);
331
332 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key,
333 keyconf->keylen);
334
335 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
336 == STA_KEY_FLG_NO_ENC)
337 priv->stations[sta_id].sta.key.key_offset =
338 iwl_get_free_ucode_key_index(priv);
339 /* else, we are overriding an existing key => no need to allocated room
340 * in uCode. */
341
342 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
343 "no space for a new key");
344
345 priv->stations[sta_id].sta.key.key_flags = key_flags;
346 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
347 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
348
349 memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd));
350 spin_unlock_irqrestore(&priv->sta_lock, flags); 316 spin_unlock_irqrestore(&priv->sta_lock, flags);
351 317
352 return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); 318 key_flags = cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
353} 319 key_flags |= STA_KEY_FLG_MAP_KEY_MSK;
354
355static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
356 struct iwl_rxon_context *ctx,
357 struct ieee80211_key_conf *keyconf,
358 u8 sta_id)
359{
360 unsigned long flags;
361 int ret = 0;
362 __le16 key_flags = 0;
363 320
364 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); 321 switch (keyconf->cipher) {
365 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); 322 case WLAN_CIPHER_SUITE_CCMP:
366 key_flags &= ~STA_KEY_FLG_INVALID; 323 key_flags |= STA_KEY_FLG_CCMP;
324 memcpy(sta_cmd.key.key, keyconf->key, keyconf->keylen);
325 break;
326 case WLAN_CIPHER_SUITE_TKIP:
327 key_flags |= STA_KEY_FLG_TKIP;
328 sta_cmd.key.tkip_rx_tsc_byte2 = tkip_iv32;
329 for (i = 0; i < 5; i++)
330 sta_cmd.key.tkip_rx_ttak[i] = cpu_to_le16(tkip_p1k[i]);
331 memcpy(sta_cmd.key.key, keyconf->key, keyconf->keylen);
332 break;
333 case WLAN_CIPHER_SUITE_WEP104:
334 key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
335 /* fall through */
336 case WLAN_CIPHER_SUITE_WEP40:
337 key_flags |= STA_KEY_FLG_WEP;
338 memcpy(&sta_cmd.key.key[3], keyconf->key, keyconf->keylen);
339 break;
340 default:
341 WARN_ON(1);
342 return -EINVAL;
343 }
367 344
368 if (sta_id == ctx->bcast_sta_id) 345 if (!(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE))
369 key_flags |= STA_KEY_MULTICAST_MSK; 346 key_flags |= STA_KEY_MULTICAST_MSK;
370 347
371 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 348 /* key pointer (offset) */
372 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; 349 sta_cmd.key.key_offset = keyconf->hw_key_idx;
373 350
374 spin_lock_irqsave(&priv->sta_lock, flags); 351 sta_cmd.key.key_flags = key_flags;
375 352 sta_cmd.mode = STA_CONTROL_MODIFY_MSK;
376 priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; 353 sta_cmd.sta.modify_mask = STA_MODIFY_KEY_MASK;
377 priv->stations[sta_id].keyinfo.keylen = 16;
378
379 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
380 == STA_KEY_FLG_NO_ENC)
381 priv->stations[sta_id].sta.key.key_offset =
382 iwl_get_free_ucode_key_index(priv);
383 /* else, we are overriding an existing key => no need to allocated room
384 * in uCode. */
385
386 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
387 "no space for a new key");
388
389 priv->stations[sta_id].sta.key.key_flags = key_flags;
390 354
391 355 return iwl_send_add_sta(priv, &sta_cmd, cmd_flags);
392 /* This copy is acutally not needed: we get the key with each TX */
393 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
394
395 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16);
396
397 spin_unlock_irqrestore(&priv->sta_lock, flags);
398
399 return ret;
400} 356}
401 357
402void iwl_update_tkip_key(struct iwl_priv *priv, 358void iwl_update_tkip_key(struct iwl_priv *priv,
403 struct iwl_rxon_context *ctx, 359 struct ieee80211_vif *vif,
404 struct ieee80211_key_conf *keyconf, 360 struct ieee80211_key_conf *keyconf,
405 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) 361 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key)
406{ 362{
407 u8 sta_id; 363 u8 sta_id = iwlagn_key_sta_id(priv, vif, sta);
408 unsigned long flags; 364
409 int i; 365 if (sta_id == IWL_INVALID_STATION)
366 return;
410 367
411 if (iwl_scan_cancel(priv)) { 368 if (iwl_scan_cancel(priv)) {
412 /* cancel scan failed, just live w/ bad key and rely 369 /* cancel scan failed, just live w/ bad key and rely
@@ -414,121 +371,110 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
414 return; 371 return;
415 } 372 }
416 373
417 sta_id = iwl_sta_id_or_broadcast(priv, ctx, sta); 374 iwlagn_send_sta_key(priv, keyconf, sta_id,
418 if (sta_id == IWL_INVALID_STATION) 375 iv32, phase1key, CMD_ASYNC);
419 return;
420
421 spin_lock_irqsave(&priv->sta_lock, flags);
422
423 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
424
425 for (i = 0; i < 5; i++)
426 priv->stations[sta_id].sta.key.tkip_rx_ttak[i] =
427 cpu_to_le16(phase1key[i]);
428
429 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
430 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
431
432 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
433
434 spin_unlock_irqrestore(&priv->sta_lock, flags);
435
436} 376}
437 377
438int iwl_remove_dynamic_key(struct iwl_priv *priv, 378int iwl_remove_dynamic_key(struct iwl_priv *priv,
439 struct iwl_rxon_context *ctx, 379 struct iwl_rxon_context *ctx,
440 struct ieee80211_key_conf *keyconf, 380 struct ieee80211_key_conf *keyconf,
441 u8 sta_id) 381 struct ieee80211_sta *sta)
442{ 382{
443 unsigned long flags; 383 unsigned long flags;
444 u16 key_flags;
445 u8 keyidx;
446 struct iwl_addsta_cmd sta_cmd; 384 struct iwl_addsta_cmd sta_cmd;
385 u8 sta_id = iwlagn_key_sta_id(priv, ctx->vif, sta);
386
387 /* if station isn't there, neither is the key */
388 if (sta_id == IWL_INVALID_STATION)
389 return -ENOENT;
390
391 spin_lock_irqsave(&priv->sta_lock, flags);
392 memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd));
393 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE))
394 sta_id = IWL_INVALID_STATION;
395 spin_unlock_irqrestore(&priv->sta_lock, flags);
396
397 if (sta_id == IWL_INVALID_STATION)
398 return 0;
447 399
448 lockdep_assert_held(&priv->mutex); 400 lockdep_assert_held(&priv->mutex);
449 401
450 ctx->key_mapping_keys--; 402 ctx->key_mapping_keys--;
451 403
452 spin_lock_irqsave(&priv->sta_lock, flags);
453 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags);
454 keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3;
455
456 IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", 404 IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n",
457 keyconf->keyidx, sta_id); 405 keyconf->keyidx, sta_id);
458 406
459 if (keyconf->keyidx != keyidx) { 407 if (!test_and_clear_bit(keyconf->hw_key_idx, &priv->ucode_key_table))
460 /* We need to remove a key with index different that the one 408 IWL_ERR(priv, "offset %d not used in uCode key table.\n",
461 * in the uCode. This means that the key we need to remove has 409 keyconf->hw_key_idx);
462 * been replaced by another one with different index.
463 * Don't do anything and return ok
464 */
465 spin_unlock_irqrestore(&priv->sta_lock, flags);
466 return 0;
467 }
468
469 if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) {
470 IWL_WARN(priv, "Removing wrong key %d 0x%x\n",
471 keyconf->keyidx, key_flags);
472 spin_unlock_irqrestore(&priv->sta_lock, flags);
473 return 0;
474 }
475 410
476 if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset, 411 sta_cmd.key.key_flags = STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID;
477 &priv->ucode_key_table)) 412 sta_cmd.key.key_offset = WEP_INVALID_OFFSET;
478 IWL_ERR(priv, "index %d not used in uCode key table.\n", 413 sta_cmd.sta.modify_mask = STA_MODIFY_KEY_MASK;
479 priv->stations[sta_id].sta.key.key_offset); 414 sta_cmd.mode = STA_CONTROL_MODIFY_MSK;
480 memset(&priv->stations[sta_id].keyinfo, 0,
481 sizeof(struct iwl_hw_key));
482 memset(&priv->stations[sta_id].sta.key, 0,
483 sizeof(struct iwl_keyinfo));
484 priv->stations[sta_id].sta.key.key_flags =
485 STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID;
486 priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET;
487 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
488 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
489
490 if (iwl_is_rfkill(priv)) {
491 IWL_DEBUG_WEP(priv, "Not sending REPLY_ADD_STA command because RFKILL enabled.\n");
492 spin_unlock_irqrestore(&priv->sta_lock, flags);
493 return 0;
494 }
495 memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd));
496 spin_unlock_irqrestore(&priv->sta_lock, flags);
497 415
498 return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); 416 return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
499} 417}
500 418
501int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 419int iwl_set_dynamic_key(struct iwl_priv *priv,
502 struct ieee80211_key_conf *keyconf, u8 sta_id) 420 struct iwl_rxon_context *ctx,
421 struct ieee80211_key_conf *keyconf,
422 struct ieee80211_sta *sta)
503{ 423{
424 struct ieee80211_key_seq seq;
425 u16 p1k[5];
504 int ret; 426 int ret;
427 u8 sta_id = iwlagn_key_sta_id(priv, ctx->vif, sta);
428 const u8 *addr;
429
430 if (sta_id == IWL_INVALID_STATION)
431 return -EINVAL;
505 432
506 lockdep_assert_held(&priv->mutex); 433 lockdep_assert_held(&priv->mutex);
507 434
435 keyconf->hw_key_idx = iwl_get_free_ucode_key_offset(priv);
436 if (keyconf->hw_key_idx == WEP_INVALID_OFFSET)
437 return -ENOSPC;
438
508 ctx->key_mapping_keys++; 439 ctx->key_mapping_keys++;
509 keyconf->hw_key_idx = HW_KEY_DYNAMIC;
510 440
511 switch (keyconf->cipher) { 441 switch (keyconf->cipher) {
512 case WLAN_CIPHER_SUITE_CCMP:
513 ret = iwl_set_ccmp_dynamic_key_info(priv, ctx, keyconf, sta_id);
514 break;
515 case WLAN_CIPHER_SUITE_TKIP: 442 case WLAN_CIPHER_SUITE_TKIP:
516 ret = iwl_set_tkip_dynamic_key_info(priv, ctx, keyconf, sta_id); 443 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
444 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
445
446 if (sta)
447 addr = sta->addr;
448 else /* station mode case only */
449 addr = ctx->active.bssid_addr;
450
451 /* pre-fill phase 1 key into device cache */
452 ieee80211_get_key_rx_seq(keyconf, 0, &seq);
453 ieee80211_get_tkip_rx_p1k(keyconf, addr, seq.tkip.iv32, p1k);
454 ret = iwlagn_send_sta_key(priv, keyconf, sta_id,
455 seq.tkip.iv32, p1k, CMD_SYNC);
517 break; 456 break;
457 case WLAN_CIPHER_SUITE_CCMP:
458 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
459 /* fall through */
518 case WLAN_CIPHER_SUITE_WEP40: 460 case WLAN_CIPHER_SUITE_WEP40:
519 case WLAN_CIPHER_SUITE_WEP104: 461 case WLAN_CIPHER_SUITE_WEP104:
520 ret = iwl_set_wep_dynamic_key_info(priv, ctx, keyconf, sta_id); 462 ret = iwlagn_send_sta_key(priv, keyconf, sta_id,
463 0, NULL, CMD_SYNC);
521 break; 464 break;
522 default: 465 default:
523 IWL_ERR(priv, 466 IWL_ERR(priv, "Unknown cipher %x\n", keyconf->cipher);
524 "Unknown alg: %s cipher = %x\n", __func__,
525 keyconf->cipher);
526 ret = -EINVAL; 467 ret = -EINVAL;
527 } 468 }
528 469
529 IWL_DEBUG_WEP(priv, "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", 470 if (ret) {
471 ctx->key_mapping_keys--;
472 clear_bit(keyconf->hw_key_idx, &priv->ucode_key_table);
473 }
474
475 IWL_DEBUG_WEP(priv, "Set dynamic key: cipher=%x len=%d idx=%d sta=%pM ret=%d\n",
530 keyconf->cipher, keyconf->keylen, keyconf->keyidx, 476 keyconf->cipher, keyconf->keylen, keyconf->keyidx,
531 sta_id, ret); 477 sta ? sta->addr : NULL, ret);
532 478
533 return ret; 479 return ret;
534} 480}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 7d3aad83e0d6..53bb59ee719d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -39,6 +39,7 @@
39#include "iwl-helpers.h" 39#include "iwl-helpers.h"
40#include "iwl-agn-hw.h" 40#include "iwl-agn-hw.h"
41#include "iwl-agn.h" 41#include "iwl-agn.h"
42#include "iwl-trans.h"
42 43
43/* 44/*
44 * mac80211 queues, ACs, hardware queues, FIFOs. 45 * mac80211 queues, ACs, hardware queues, FIFOs.
@@ -95,132 +96,8 @@ static inline int get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid)
95 return -EINVAL; 96 return -EINVAL;
96} 97}
97 98
98/** 99static int iwlagn_txq_agg_enable(struct iwl_priv *priv, int txq_id, int sta_id,
99 * iwlagn_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array 100 int tid)
100 */
101static void iwlagn_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
102 struct iwl_tx_queue *txq,
103 u16 byte_cnt)
104{
105 struct iwlagn_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
106 int write_ptr = txq->q.write_ptr;
107 int txq_id = txq->q.id;
108 u8 sec_ctl = 0;
109 u8 sta_id = 0;
110 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
111 __le16 bc_ent;
112
113 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
114
115 sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
116 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
117
118 switch (sec_ctl & TX_CMD_SEC_MSK) {
119 case TX_CMD_SEC_CCM:
120 len += CCMP_MIC_LEN;
121 break;
122 case TX_CMD_SEC_TKIP:
123 len += TKIP_ICV_LEN;
124 break;
125 case TX_CMD_SEC_WEP:
126 len += WEP_IV_LEN + WEP_ICV_LEN;
127 break;
128 }
129
130 bc_ent = cpu_to_le16((len & 0xFFF) | (sta_id << 12));
131
132 scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
133
134 if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
135 scd_bc_tbl[txq_id].
136 tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
137}
138
139static void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
140 struct iwl_tx_queue *txq)
141{
142 struct iwlagn_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
143 int txq_id = txq->q.id;
144 int read_ptr = txq->q.read_ptr;
145 u8 sta_id = 0;
146 __le16 bc_ent;
147
148 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
149
150 if (txq_id != priv->cmd_queue)
151 sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
152
153 bc_ent = cpu_to_le16(1 | (sta_id << 12));
154 scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent;
155
156 if (read_ptr < TFD_QUEUE_SIZE_BC_DUP)
157 scd_bc_tbl[txq_id].
158 tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = bc_ent;
159}
160
161static int iwlagn_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
162 u16 txq_id)
163{
164 u32 tbl_dw_addr;
165 u32 tbl_dw;
166 u16 scd_q2ratid;
167
168 scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
169
170 tbl_dw_addr = priv->scd_base_addr +
171 IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
172
173 tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
174
175 if (txq_id & 0x1)
176 tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
177 else
178 tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
179
180 iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
181
182 return 0;
183}
184
185static void iwlagn_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
186{
187 /* Simply stop the queue, but don't change any configuration;
188 * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
189 iwl_write_prph(priv,
190 IWLAGN_SCD_QUEUE_STATUS_BITS(txq_id),
191 (0 << IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
192 (1 << IWLAGN_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
193}
194
195void iwlagn_set_wr_ptrs(struct iwl_priv *priv,
196 int txq_id, u32 index)
197{
198 iwl_write_direct32(priv, HBUS_TARG_WRPTR,
199 (index & 0xff) | (txq_id << 8));
200 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_RDPTR(txq_id), index);
201}
202
203void iwlagn_tx_queue_set_status(struct iwl_priv *priv,
204 struct iwl_tx_queue *txq,
205 int tx_fifo_id, int scd_retry)
206{
207 int txq_id = txq->q.id;
208 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
209
210 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_STATUS_BITS(txq_id),
211 (active << IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
212 (tx_fifo_id << IWLAGN_SCD_QUEUE_STTS_REG_POS_TXF) |
213 (1 << IWLAGN_SCD_QUEUE_STTS_REG_POS_WSL) |
214 IWLAGN_SCD_QUEUE_STTS_REG_MSK);
215
216 txq->sched_retry = scd_retry;
217
218 IWL_DEBUG_INFO(priv, "%s %s Queue %d on FIFO %d\n",
219 active ? "Activate" : "Deactivate",
220 scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id);
221}
222
223static int iwlagn_txq_agg_enable(struct iwl_priv *priv, int txq_id, int sta_id, int tid)
224{ 101{
225 if ((IWLAGN_FIRST_AMPDU_QUEUE > txq_id) || 102 if ((IWLAGN_FIRST_AMPDU_QUEUE > txq_id) ||
226 (IWLAGN_FIRST_AMPDU_QUEUE + 103 (IWLAGN_FIRST_AMPDU_QUEUE +
@@ -237,108 +114,6 @@ static int iwlagn_txq_agg_enable(struct iwl_priv *priv, int txq_id, int sta_id,
237 return iwl_sta_tx_modify_enable_tid(priv, sta_id, tid); 114 return iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
238} 115}
239 116
240void iwlagn_txq_agg_queue_setup(struct iwl_priv *priv,
241 struct ieee80211_sta *sta,
242 int tid, int frame_limit)
243{
244 int sta_id, tx_fifo, txq_id, ssn_idx;
245 u16 ra_tid;
246 unsigned long flags;
247 struct iwl_tid_data *tid_data;
248
249 sta_id = iwl_sta_id(sta);
250 if (WARN_ON(sta_id == IWL_INVALID_STATION))
251 return;
252 if (WARN_ON(tid >= MAX_TID_COUNT))
253 return;
254
255 spin_lock_irqsave(&priv->sta_lock, flags);
256 tid_data = &priv->stations[sta_id].tid[tid];
257 ssn_idx = SEQ_TO_SN(tid_data->seq_number);
258 txq_id = tid_data->agg.txq_id;
259 tx_fifo = tid_data->agg.tx_fifo;
260 spin_unlock_irqrestore(&priv->sta_lock, flags);
261
262 ra_tid = BUILD_RAxTID(sta_id, tid);
263
264 spin_lock_irqsave(&priv->lock, flags);
265
266 /* Stop this Tx queue before configuring it */
267 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
268
269 /* Map receiver-address / traffic-ID to this queue */
270 iwlagn_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
271
272 /* Set this queue as a chain-building queue */
273 iwl_set_bits_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL, (1<<txq_id));
274
275 /* enable aggregations for the queue */
276 iwl_set_bits_prph(priv, IWLAGN_SCD_AGGR_SEL, (1<<txq_id));
277
278 /* Place first TFD at index corresponding to start sequence number.
279 * Assumes that ssn_idx is valid (!= 0xFFF) */
280 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
281 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
282 iwlagn_set_wr_ptrs(priv, txq_id, ssn_idx);
283
284 /* Set up Tx window size and frame limit for this queue */
285 iwl_write_targ_mem(priv, priv->scd_base_addr +
286 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
287 sizeof(u32),
288 ((frame_limit <<
289 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
290 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
291 ((frame_limit <<
292 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
293 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
294
295 iwl_set_bits_prph(priv, IWLAGN_SCD_INTERRUPT_MASK, (1 << txq_id));
296
297 /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
298 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
299
300 spin_unlock_irqrestore(&priv->lock, flags);
301}
302
303static int iwlagn_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
304 u16 ssn_idx, u8 tx_fifo)
305{
306 if ((IWLAGN_FIRST_AMPDU_QUEUE > txq_id) ||
307 (IWLAGN_FIRST_AMPDU_QUEUE +
308 priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) {
309 IWL_ERR(priv,
310 "queue number out of range: %d, must be %d to %d\n",
311 txq_id, IWLAGN_FIRST_AMPDU_QUEUE,
312 IWLAGN_FIRST_AMPDU_QUEUE +
313 priv->cfg->base_params->num_of_ampdu_queues - 1);
314 return -EINVAL;
315 }
316
317 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
318
319 iwl_clear_bits_prph(priv, IWLAGN_SCD_AGGR_SEL, (1 << txq_id));
320
321 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
322 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
323 /* supposes that ssn_idx is valid (!= 0xFFF) */
324 iwlagn_set_wr_ptrs(priv, txq_id, ssn_idx);
325
326 iwl_clear_bits_prph(priv, IWLAGN_SCD_INTERRUPT_MASK, (1 << txq_id));
327 iwl_txq_ctx_deactivate(priv, txq_id);
328 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
329
330 return 0;
331}
332
333/*
334 * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
335 * must be called under priv->lock and mac access
336 */
337void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask)
338{
339 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask);
340}
341
342static void iwlagn_tx_cmd_protection(struct iwl_priv *priv, 117static void iwlagn_tx_cmd_protection(struct iwl_priv *priv,
343 struct ieee80211_tx_info *info, 118 struct ieee80211_tx_info *info,
344 __le16 fc, __le32 *tx_flags) 119 __le16 fc, __le32 *tx_flags)
@@ -363,19 +138,15 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
363 __le32 tx_flags = tx_cmd->tx_flags; 138 __le32 tx_flags = tx_cmd->tx_flags;
364 139
365 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 140 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
366 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { 141
142 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
367 tx_flags |= TX_CMD_FLG_ACK_MSK; 143 tx_flags |= TX_CMD_FLG_ACK_MSK;
368 if (ieee80211_is_mgmt(fc)) 144 else
369 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 145 tx_flags &= ~TX_CMD_FLG_ACK_MSK;
370 if (ieee80211_is_probe_resp(fc) &&
371 !(le16_to_cpu(hdr->seq_ctrl) & 0xf))
372 tx_flags |= TX_CMD_FLG_TSF_MSK;
373 } else {
374 tx_flags &= (~TX_CMD_FLG_ACK_MSK);
375 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
376 }
377 146
378 if (ieee80211_is_back_req(fc)) 147 if (ieee80211_is_probe_resp(fc))
148 tx_flags |= TX_CMD_FLG_TSF_MSK;
149 else if (ieee80211_is_back_req(fc))
379 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; 150 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK;
380 else if (info->band == IEEE80211_BAND_2GHZ && 151 else if (info->band == IEEE80211_BAND_2GHZ &&
381 priv->cfg->bt_params && 152 priv->cfg->bt_params &&
@@ -446,6 +217,7 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
446 if (ieee80211_is_data(fc)) { 217 if (ieee80211_is_data(fc)) {
447 tx_cmd->initial_rate_index = 0; 218 tx_cmd->initial_rate_index = 0;
448 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; 219 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;
220#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
449 if (priv->tm_fixed_rate) { 221 if (priv->tm_fixed_rate) {
450 /* 222 /*
451 * rate overwrite by testmode 223 * rate overwrite by testmode
@@ -456,6 +228,7 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
456 memcpy(&tx_cmd->rate_n_flags, &priv->tm_fixed_rate, 228 memcpy(&tx_cmd->rate_n_flags, &priv->tm_fixed_rate,
457 sizeof(tx_cmd->rate_n_flags)); 229 sizeof(tx_cmd->rate_n_flags));
458 } 230 }
231#endif
459 return; 232 return;
460 } 233 }
461 234
@@ -547,26 +320,17 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
547{ 320{
548 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 321 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
549 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 322 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
550 struct ieee80211_sta *sta = info->control.sta;
551 struct iwl_station_priv *sta_priv = NULL; 323 struct iwl_station_priv *sta_priv = NULL;
552 struct iwl_tx_queue *txq;
553 struct iwl_queue *q;
554 struct iwl_device_cmd *out_cmd;
555 struct iwl_cmd_meta *out_meta;
556 struct iwl_tx_cmd *tx_cmd;
557 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 324 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
325 struct iwl_tx_cmd *tx_cmd;
558 int txq_id; 326 int txq_id;
559 dma_addr_t phys_addr = 0; 327
560 dma_addr_t txcmd_phys;
561 dma_addr_t scratch_phys;
562 u16 len, firstlen, secondlen;
563 u16 seq_number = 0; 328 u16 seq_number = 0;
564 __le16 fc; 329 __le16 fc;
565 u8 hdr_len; 330 u8 hdr_len;
331 u16 len;
566 u8 sta_id; 332 u8 sta_id;
567 u8 wait_write_ptr = 0;
568 u8 tid = 0; 333 u8 tid = 0;
569 u8 *qc = NULL;
570 unsigned long flags; 334 unsigned long flags;
571 bool is_agg = false; 335 bool is_agg = false;
572 336
@@ -614,8 +378,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
614 378
615 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); 379 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
616 380
617 if (sta) 381 if (info->control.sta)
618 sta_priv = (void *)sta->drv_priv; 382 sta_priv = (void *)info->control.sta->drv_priv;
619 383
620 if (sta_priv && sta_priv->asleep && 384 if (sta_priv && sta_priv->asleep &&
621 (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)) { 385 (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)) {
@@ -650,6 +414,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
650 spin_lock(&priv->sta_lock); 414 spin_lock(&priv->sta_lock);
651 415
652 if (ieee80211_is_data_qos(fc)) { 416 if (ieee80211_is_data_qos(fc)) {
417 u8 *qc = NULL;
653 qc = ieee80211_get_qos_ctl(hdr); 418 qc = ieee80211_get_qos_ctl(hdr);
654 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; 419 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
655 420
@@ -670,38 +435,13 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
670 } 435 }
671 } 436 }
672 437
673 txq = &priv->txq[txq_id]; 438 tx_cmd = trans_get_tx_cmd(&priv->trans, txq_id);
674 q = &txq->q; 439 if (unlikely(!tx_cmd))
675
676 if (unlikely(iwl_queue_space(q) < q->high_mark))
677 goto drop_unlock_sta; 440 goto drop_unlock_sta;
678 441
679 /* Set up driver data for this TFD */
680 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
681 txq->txb[q->write_ptr].skb = skb;
682 txq->txb[q->write_ptr].ctx = ctx;
683
684 /* Set up first empty entry in queue's array of Tx/cmd buffers */
685 out_cmd = txq->cmd[q->write_ptr];
686 out_meta = &txq->meta[q->write_ptr];
687 tx_cmd = &out_cmd->cmd.tx;
688 memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr));
689 memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd));
690
691 /*
692 * Set up the Tx-command (not MAC!) header.
693 * Store the chosen Tx queue and TFD index within the sequence field;
694 * after Tx, uCode's Tx response will return this value so driver can
695 * locate the frame within the tx queue and do post-tx processing.
696 */
697 out_cmd->hdr.cmd = REPLY_TX;
698 out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
699 INDEX_TO_SEQ(q->write_ptr)));
700
701 /* Copy MAC header from skb into command buffer */ 442 /* Copy MAC header from skb into command buffer */
702 memcpy(tx_cmd->hdr, hdr, hdr_len); 443 memcpy(tx_cmd->hdr, hdr, hdr_len);
703 444
704
705 /* Total # bytes to be transmitted */ 445 /* Total # bytes to be transmitted */
706 len = (u16)skb->len; 446 len = (u16)skb->len;
707 tx_cmd->len = cpu_to_le16(len); 447 tx_cmd->len = cpu_to_le16(len);
@@ -716,54 +456,9 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
716 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc); 456 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc);
717 457
718 iwl_update_stats(priv, true, fc, len); 458 iwl_update_stats(priv, true, fc, len);
719 /*
720 * Use the first empty entry in this queue's command buffer array
721 * to contain the Tx command and MAC header concatenated together
722 * (payload data will be in another buffer).
723 * Size of this varies, due to varying MAC header length.
724 * If end is not dword aligned, we'll have 2 extra bytes at the end
725 * of the MAC header (device reads on dword boundaries).
726 * We'll tell device about this padding later.
727 */
728 len = sizeof(struct iwl_tx_cmd) +
729 sizeof(struct iwl_cmd_header) + hdr_len;
730 firstlen = (len + 3) & ~3;
731
732 /* Tell NIC about any 2-byte padding after MAC header */
733 if (firstlen != len)
734 tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK;
735
736 /* Physical address of this Tx command's header (not MAC header!),
737 * within command buffer array. */
738 txcmd_phys = dma_map_single(priv->bus.dev,
739 &out_cmd->hdr, firstlen,
740 DMA_BIDIRECTIONAL);
741 if (unlikely(dma_mapping_error(priv->bus.dev, txcmd_phys)))
742 goto drop_unlock_sta;
743 dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
744 dma_unmap_len_set(out_meta, len, firstlen);
745
746 if (!ieee80211_has_morefrags(hdr->frame_control)) {
747 txq->need_update = 1;
748 } else {
749 wait_write_ptr = 1;
750 txq->need_update = 0;
751 }
752 459
753 /* Set up TFD's 2nd entry to point directly to remainder of skb, 460 if (trans_tx(&priv->trans, skb, tx_cmd, txq_id, fc, is_agg, ctx))
754 * if any (802.11 null frames have no payload). */ 461 goto drop_unlock_sta;
755 secondlen = skb->len - hdr_len;
756 if (secondlen > 0) {
757 phys_addr = dma_map_single(priv->bus.dev, skb->data + hdr_len,
758 secondlen, DMA_TO_DEVICE);
759 if (unlikely(dma_mapping_error(priv->bus.dev, phys_addr))) {
760 dma_unmap_single(priv->bus.dev,
761 dma_unmap_addr(out_meta, mapping),
762 dma_unmap_len(out_meta, len),
763 DMA_BIDIRECTIONAL);
764 goto drop_unlock_sta;
765 }
766 }
767 462
768 if (ieee80211_is_data_qos(fc)) { 463 if (ieee80211_is_data_qos(fc)) {
769 priv->stations[sta_id].tid[tid].tfds_in_queue++; 464 priv->stations[sta_id].tid[tid].tfds_in_queue++;
@@ -772,55 +467,9 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
772 } 467 }
773 468
774 spin_unlock(&priv->sta_lock); 469 spin_unlock(&priv->sta_lock);
775
776 /* Attach buffers to TFD */
777 iwlagn_txq_attach_buf_to_tfd(priv, txq, txcmd_phys, firstlen, 1);
778 if (secondlen > 0)
779 iwlagn_txq_attach_buf_to_tfd(priv, txq, phys_addr,
780 secondlen, 0);
781
782 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
783 offsetof(struct iwl_tx_cmd, scratch);
784
785 /* take back ownership of DMA buffer to enable update */
786 dma_sync_single_for_cpu(priv->bus.dev, txcmd_phys, firstlen,
787 DMA_BIDIRECTIONAL);
788 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
789 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
790
791 IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n",
792 le16_to_cpu(out_cmd->hdr.sequence));
793 IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags));
794 iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd));
795 iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len);
796
797 /* Set up entry for this TFD in Tx byte-count array */
798 if (info->flags & IEEE80211_TX_CTL_AMPDU)
799 iwlagn_txq_update_byte_cnt_tbl(priv, txq,
800 le16_to_cpu(tx_cmd->len));
801
802 dma_sync_single_for_device(priv->bus.dev, txcmd_phys, firstlen,
803 DMA_BIDIRECTIONAL);
804
805 trace_iwlwifi_dev_tx(priv,
806 &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],
807 sizeof(struct iwl_tfd),
808 &out_cmd->hdr, firstlen,
809 skb->data + hdr_len, secondlen);
810
811 /* Tell device the write index *just past* this latest filled TFD */
812 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
813 iwl_txq_update_write_ptr(priv, txq);
814 spin_unlock_irqrestore(&priv->lock, flags); 470 spin_unlock_irqrestore(&priv->lock, flags);
815 471
816 /* 472 /*
817 * At this point the frame is "transmitted" successfully
818 * and we will get a TX status notification eventually,
819 * regardless of the value of ret. "ret" only indicates
820 * whether or not we should update the write pointer.
821 */
822
823 /*
824 * Avoid atomic ops if it isn't an associated client. 473 * Avoid atomic ops if it isn't an associated client.
825 * Also, if this is a packet for aggregation, don't 474 * Also, if this is a packet for aggregation, don't
826 * increase the counter because the ucode will stop 475 * increase the counter because the ucode will stop
@@ -830,17 +479,6 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
830 if (sta_priv && sta_priv->client && !is_agg) 479 if (sta_priv && sta_priv->client && !is_agg)
831 atomic_inc(&sta_priv->pending_frames); 480 atomic_inc(&sta_priv->pending_frames);
832 481
833 if ((iwl_queue_space(q) < q->high_mark) && priv->mac80211_registered) {
834 if (wait_write_ptr) {
835 spin_lock_irqsave(&priv->lock, flags);
836 txq->need_update = 1;
837 iwl_txq_update_write_ptr(priv, txq);
838 spin_unlock_irqrestore(&priv->lock, flags);
839 } else {
840 iwl_stop_queue(priv, txq);
841 }
842 }
843
844 return 0; 482 return 0;
845 483
846drop_unlock_sta: 484drop_unlock_sta:
@@ -997,7 +635,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
997 * to deactivate the uCode queue, just return "success" to allow 635 * to deactivate the uCode queue, just return "success" to allow
998 * mac80211 to clean up it own data. 636 * mac80211 to clean up it own data.
999 */ 637 */
1000 iwlagn_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); 638 trans_txq_agg_disable(&priv->trans, txq_id, ssn, tx_fifo_id);
1001 spin_unlock_irqrestore(&priv->lock, flags); 639 spin_unlock_irqrestore(&priv->lock, flags);
1002 640
1003 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); 641 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
@@ -1026,7 +664,8 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
1026 u16 ssn = SEQ_TO_SN(tid_data->seq_number); 664 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
1027 int tx_fifo = get_fifo_from_tid(ctx, tid); 665 int tx_fifo = get_fifo_from_tid(ctx, tid);
1028 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n"); 666 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n");
1029 iwlagn_txq_agg_disable(priv, txq_id, ssn, tx_fifo); 667 trans_txq_agg_disable(&priv->trans, txq_id,
668 ssn, tx_fifo);
1030 tid_data->agg.state = IWL_AGG_OFF; 669 tid_data->agg.state = IWL_AGG_OFF;
1031 ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); 670 ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
1032 } 671 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 06304a681ed3..a895a099d086 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -41,38 +41,6 @@
41#include "iwl-agn-calib.h" 41#include "iwl-agn-calib.h"
42#include "iwl-trans.h" 42#include "iwl-trans.h"
43 43
44#define IWL_AC_UNSET -1
45
46struct queue_to_fifo_ac {
47 s8 fifo, ac;
48};
49
50static const struct queue_to_fifo_ac iwlagn_default_queue_to_tx_fifo[] = {
51 { IWL_TX_FIFO_VO, IEEE80211_AC_VO, },
52 { IWL_TX_FIFO_VI, IEEE80211_AC_VI, },
53 { IWL_TX_FIFO_BE, IEEE80211_AC_BE, },
54 { IWL_TX_FIFO_BK, IEEE80211_AC_BK, },
55 { IWLAGN_CMD_FIFO_NUM, IWL_AC_UNSET, },
56 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
57 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
58 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
59 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
60 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
61};
62
63static const struct queue_to_fifo_ac iwlagn_ipan_queue_to_tx_fifo[] = {
64 { IWL_TX_FIFO_VO, IEEE80211_AC_VO, },
65 { IWL_TX_FIFO_VI, IEEE80211_AC_VI, },
66 { IWL_TX_FIFO_BE, IEEE80211_AC_BE, },
67 { IWL_TX_FIFO_BK, IEEE80211_AC_BK, },
68 { IWL_TX_FIFO_BK_IPAN, IEEE80211_AC_BK, },
69 { IWL_TX_FIFO_BE_IPAN, IEEE80211_AC_BE, },
70 { IWL_TX_FIFO_VI_IPAN, IEEE80211_AC_VI, },
71 { IWL_TX_FIFO_VO_IPAN, IEEE80211_AC_VO, },
72 { IWL_TX_FIFO_BE_IPAN, 2, },
73 { IWLAGN_CMD_FIFO_NUM, IWL_AC_UNSET, },
74};
75
76static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { 44static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
77 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, 45 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP,
78 0, COEX_UNASSOC_IDLE_FLAGS}, 46 0, COEX_UNASSOC_IDLE_FLAGS},
@@ -199,12 +167,12 @@ static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv)
199 167
200 memset(&cmd, 0, sizeof(cmd)); 168 memset(&cmd, 0, sizeof(cmd));
201 iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); 169 iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD);
202 cmd.radio_sensor_offset = le16_to_cpu(offset_calib[1]); 170 memcpy(&cmd.radio_sensor_offset, offset_calib, sizeof(offset_calib));
203 if (!(cmd.radio_sensor_offset)) 171 if (!(cmd.radio_sensor_offset))
204 cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; 172 cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET;
205 173
206 IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", 174 IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n",
207 cmd.radio_sensor_offset); 175 le16_to_cpu(cmd.radio_sensor_offset));
208 return iwl_calib_set(&priv->calib_results[IWL_CALIB_TEMP_OFFSET], 176 return iwl_calib_set(&priv->calib_results[IWL_CALIB_TEMP_OFFSET],
209 (u8 *)&cmd, sizeof(cmd)); 177 (u8 *)&cmd, sizeof(cmd));
210} 178}
@@ -222,9 +190,10 @@ static int iwlagn_send_calib_cfg(struct iwl_priv *priv)
222 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; 190 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
223 calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL; 191 calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL;
224 calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; 192 calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL;
225 calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL; 193 calib_cfg_cmd.ucd_calib_cfg.flags =
194 IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK;
226 195
227 return trans_send_cmd(priv, &cmd); 196 return trans_send_cmd(&priv->trans, &cmd);
228} 197}
229 198
230void iwlagn_rx_calib_result(struct iwl_priv *priv, 199void iwlagn_rx_calib_result(struct iwl_priv *priv,
@@ -322,7 +291,7 @@ static int iwlagn_send_wimax_coex(struct iwl_priv *priv)
322 /* coexistence is disabled */ 291 /* coexistence is disabled */
323 memset(&coex_cmd, 0, sizeof(coex_cmd)); 292 memset(&coex_cmd, 0, sizeof(coex_cmd));
324 } 293 }
325 return trans_send_cmd_pdu(priv, 294 return trans_send_cmd_pdu(&priv->trans,
326 COEX_PRIORITY_TABLE_CMD, CMD_SYNC, 295 COEX_PRIORITY_TABLE_CMD, CMD_SYNC,
327 sizeof(coex_cmd), &coex_cmd); 296 sizeof(coex_cmd), &coex_cmd);
328} 297}
@@ -355,7 +324,7 @@ void iwlagn_send_prio_tbl(struct iwl_priv *priv)
355 324
356 memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, 325 memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl,
357 sizeof(iwlagn_bt_prio_tbl)); 326 sizeof(iwlagn_bt_prio_tbl));
358 if (trans_send_cmd_pdu(priv, 327 if (trans_send_cmd_pdu(&priv->trans,
359 REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, 328 REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC,
360 sizeof(prio_tbl_cmd), &prio_tbl_cmd)) 329 sizeof(prio_tbl_cmd), &prio_tbl_cmd))
361 IWL_ERR(priv, "failed to send BT prio tbl command\n"); 330 IWL_ERR(priv, "failed to send BT prio tbl command\n");
@@ -368,7 +337,7 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
368 337
369 env_cmd.action = action; 338 env_cmd.action = action;
370 env_cmd.type = type; 339 env_cmd.type = type;
371 ret = trans_send_cmd_pdu(priv, 340 ret = trans_send_cmd_pdu(&priv->trans,
372 REPLY_BT_COEX_PROT_ENV, CMD_SYNC, 341 REPLY_BT_COEX_PROT_ENV, CMD_SYNC,
373 sizeof(env_cmd), &env_cmd); 342 sizeof(env_cmd), &env_cmd);
374 if (ret) 343 if (ret)
@@ -379,111 +348,9 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
379 348
380static int iwlagn_alive_notify(struct iwl_priv *priv) 349static int iwlagn_alive_notify(struct iwl_priv *priv)
381{ 350{
382 const struct queue_to_fifo_ac *queue_to_fifo;
383 struct iwl_rxon_context *ctx;
384 u32 a;
385 unsigned long flags;
386 int i, chan;
387 u32 reg_val;
388 int ret; 351 int ret;
389 352
390 spin_lock_irqsave(&priv->lock, flags); 353 trans_tx_start(&priv->trans);
391
392 priv->scd_base_addr = iwl_read_prph(priv, IWLAGN_SCD_SRAM_BASE_ADDR);
393 a = priv->scd_base_addr + IWLAGN_SCD_CONTEXT_MEM_LOWER_BOUND;
394 /* reset conext data memory */
395 for (; a < priv->scd_base_addr + IWLAGN_SCD_CONTEXT_MEM_UPPER_BOUND;
396 a += 4)
397 iwl_write_targ_mem(priv, a, 0);
398 /* reset tx status memory */
399 for (; a < priv->scd_base_addr + IWLAGN_SCD_TX_STTS_MEM_UPPER_BOUND;
400 a += 4)
401 iwl_write_targ_mem(priv, a, 0);
402 for (; a < priv->scd_base_addr +
403 IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
404 iwl_write_targ_mem(priv, a, 0);
405
406 iwl_write_prph(priv, IWLAGN_SCD_DRAM_BASE_ADDR,
407 priv->scd_bc_tbls.dma >> 10);
408
409 /* Enable DMA channel */
410 for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++)
411 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
412 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
413 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
414
415 /* Update FH chicken bits */
416 reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
417 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
418 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
419
420 iwl_write_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL,
421 IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv));
422 iwl_write_prph(priv, IWLAGN_SCD_AGGR_SEL, 0);
423
424 /* initiate the queues */
425 for (i = 0; i < priv->hw_params.max_txq_num; i++) {
426 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_RDPTR(i), 0);
427 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
428 iwl_write_targ_mem(priv, priv->scd_base_addr +
429 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(i), 0);
430 iwl_write_targ_mem(priv, priv->scd_base_addr +
431 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(i) +
432 sizeof(u32),
433 ((SCD_WIN_SIZE <<
434 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
435 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
436 ((SCD_FRAME_LIMIT <<
437 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
438 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
439 }
440
441 iwl_write_prph(priv, IWLAGN_SCD_INTERRUPT_MASK,
442 IWL_MASK(0, priv->hw_params.max_txq_num));
443
444 /* Activate all Tx DMA/FIFO channels */
445 iwlagn_txq_set_sched(priv, IWL_MASK(0, 7));
446
447 /* map queues to FIFOs */
448 if (priv->valid_contexts != BIT(IWL_RXON_CTX_BSS))
449 queue_to_fifo = iwlagn_ipan_queue_to_tx_fifo;
450 else
451 queue_to_fifo = iwlagn_default_queue_to_tx_fifo;
452
453 iwlagn_set_wr_ptrs(priv, priv->cmd_queue, 0);
454
455 /* make sure all queue are not stopped */
456 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
457 for (i = 0; i < 4; i++)
458 atomic_set(&priv->queue_stop_count[i], 0);
459 for_each_context(priv, ctx)
460 ctx->last_tx_rejected = false;
461
462 /* reset to 0 to enable all the queue first */
463 priv->txq_ctx_active_msk = 0;
464
465 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo) != 10);
466 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_ipan_queue_to_tx_fifo) != 10);
467
468 for (i = 0; i < 10; i++) {
469 int fifo = queue_to_fifo[i].fifo;
470 int ac = queue_to_fifo[i].ac;
471
472 iwl_txq_ctx_activate(priv, i);
473
474 if (fifo == IWL_TX_FIFO_UNUSED)
475 continue;
476
477 if (ac != IWL_AC_UNSET)
478 iwl_set_swq_id(&priv->txq[i], ac, i);
479 iwlagn_tx_queue_set_status(priv, &priv->txq[i], fifo, 0);
480 }
481
482 spin_unlock_irqrestore(&priv->lock, flags);
483
484 /* Enable L1-Active */
485 iwl_clear_bits_prph(priv, APMG_PCIDEV_STT_REG,
486 APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
487 354
488 ret = iwlagn_send_wimax_coex(priv); 355 ret = iwlagn_send_wimax_coex(priv);
489 if (ret) 356 if (ret)
@@ -611,7 +478,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
611 int ret; 478 int ret;
612 enum iwlagn_ucode_type old_type; 479 enum iwlagn_ucode_type old_type;
613 480
614 ret = iwlagn_start_device(priv); 481 ret = trans_start_device(&priv->trans);
615 if (ret) 482 if (ret)
616 return ret; 483 return ret;
617 484
@@ -628,8 +495,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
628 return ret; 495 return ret;
629 } 496 }
630 497
631 /* Remove all resets to allow NIC to operate */ 498 trans_kick_nic(&priv->trans);
632 iwl_write32(priv, CSR_RESET, 0);
633 499
634 /* 500 /*
635 * Some things may run in the background now, but we 501 * Some things may run in the background now, but we
@@ -647,14 +513,21 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
647 return -EIO; 513 return -EIO;
648 } 514 }
649 515
650 ret = iwl_verify_ucode(priv, image); 516 /*
651 if (ret) { 517 * This step takes a long time (60-80ms!!) and
652 priv->ucode_type = old_type; 518 * WoWLAN image should be loaded quickly, so
653 return ret; 519 * skip it for WoWLAN.
654 } 520 */
521 if (ucode_type != IWL_UCODE_WOWLAN) {
522 ret = iwl_verify_ucode(priv, image);
523 if (ret) {
524 priv->ucode_type = old_type;
525 return ret;
526 }
655 527
656 /* delay a bit to give rfkill time to run */ 528 /* delay a bit to give rfkill time to run */
657 msleep(5); 529 msleep(5);
530 }
658 531
659 ret = iwlagn_alive_notify(priv); 532 ret = iwlagn_alive_notify(priv);
660 if (ret) { 533 if (ret) {
@@ -707,6 +580,6 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv)
707 iwlagn_remove_notification(priv, &calib_wait); 580 iwlagn_remove_notification(priv, &calib_wait);
708 out: 581 out:
709 /* Whatever happened, stop the device */ 582 /* Whatever happened, stop the device */
710 iwlagn_stop_device(priv); 583 trans_stop_device(&priv->trans);
711 return ret; 584 return ret;
712} 585}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 38a1e4f58829..b0ae4de7f083 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -26,9 +26,6 @@
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/kernel.h> 29#include <linux/kernel.h>
33#include <linux/module.h> 30#include <linux/module.h>
34#include <linux/init.h> 31#include <linux/init.h>
@@ -55,7 +52,7 @@
55#include "iwl-sta.h" 52#include "iwl-sta.h"
56#include "iwl-agn-calib.h" 53#include "iwl-agn-calib.h"
57#include "iwl-agn.h" 54#include "iwl-agn.h"
58#include "iwl-pci.h" 55#include "iwl-bus.h"
59#include "iwl-trans.h" 56#include "iwl-trans.h"
60 57
61/****************************************************************************** 58/******************************************************************************
@@ -206,7 +203,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
206 cmd.data[1] = priv->beacon_skb->data; 203 cmd.data[1] = priv->beacon_skb->data;
207 cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY; 204 cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY;
208 205
209 return trans_send_cmd(priv, &cmd); 206 return trans_send_cmd(&priv->trans, &cmd);
210} 207}
211 208
212static void iwl_bg_beacon_update(struct work_struct *work) 209static void iwl_bg_beacon_update(struct work_struct *work)
@@ -375,7 +372,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv)
375 u32 next_entry; /* index of next entry to be written by uCode */ 372 u32 next_entry; /* index of next entry to be written by uCode */
376 373
377 base = priv->device_pointers.error_event_table; 374 base = priv->device_pointers.error_event_table;
378 if (priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { 375 if (iwlagn_hw_valid_rtc_data_addr(base)) {
379 capacity = iwl_read_targ_mem(priv, base); 376 capacity = iwl_read_targ_mem(priv, base);
380 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); 377 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
381 mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32))); 378 mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32)));
@@ -457,380 +454,6 @@ static void iwl_bg_tx_flush(struct work_struct *work)
457 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); 454 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
458} 455}
459 456
460/**
461 * iwl_rx_handle - Main entry function for receiving responses from uCode
462 *
463 * Uses the priv->rx_handlers callback function array to invoke
464 * the appropriate handlers, including command responses,
465 * frame-received notifications, and other notifications.
466 */
467static void iwl_rx_handle(struct iwl_priv *priv)
468{
469 struct iwl_rx_mem_buffer *rxb;
470 struct iwl_rx_packet *pkt;
471 struct iwl_rx_queue *rxq = &priv->rxq;
472 u32 r, i;
473 int reclaim;
474 unsigned long flags;
475 u8 fill_rx = 0;
476 u32 count = 8;
477 int total_empty;
478
479 /* uCode's read index (stored in shared DRAM) indicates the last Rx
480 * buffer that the driver may process (last buffer filled by ucode). */
481 r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF;
482 i = rxq->read;
483
484 /* Rx interrupt, but nothing sent from uCode */
485 if (i == r)
486 IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i);
487
488 /* calculate total frames need to be restock after handling RX */
489 total_empty = r - rxq->write_actual;
490 if (total_empty < 0)
491 total_empty += RX_QUEUE_SIZE;
492
493 if (total_empty > (RX_QUEUE_SIZE / 2))
494 fill_rx = 1;
495
496 while (i != r) {
497 int len;
498
499 rxb = rxq->queue[i];
500
501 /* If an RXB doesn't have a Rx queue slot associated with it,
502 * then a bug has been introduced in the queue refilling
503 * routines -- catch it here */
504 if (WARN_ON(rxb == NULL)) {
505 i = (i + 1) & RX_QUEUE_MASK;
506 continue;
507 }
508
509 rxq->queue[i] = NULL;
510
511 dma_unmap_page(priv->bus.dev, rxb->page_dma,
512 PAGE_SIZE << priv->hw_params.rx_page_order,
513 DMA_FROM_DEVICE);
514 pkt = rxb_addr(rxb);
515
516 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
517 len += sizeof(u32); /* account for status word */
518 trace_iwlwifi_dev_rx(priv, pkt, len);
519
520 /* Reclaim a command buffer only if this packet is a response
521 * to a (driver-originated) command.
522 * If the packet (e.g. Rx frame) originated from uCode,
523 * there is no command buffer to reclaim.
524 * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
525 * but apparently a few don't get set; catch them here. */
526 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
527 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
528 (pkt->hdr.cmd != REPLY_RX) &&
529 (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) &&
530 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
531 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
532 (pkt->hdr.cmd != REPLY_TX);
533
534 /*
535 * Do the notification wait before RX handlers so
536 * even if the RX handler consumes the RXB we have
537 * access to it in the notification wait entry.
538 */
539 if (!list_empty(&priv->_agn.notif_waits)) {
540 struct iwl_notification_wait *w;
541
542 spin_lock(&priv->_agn.notif_wait_lock);
543 list_for_each_entry(w, &priv->_agn.notif_waits, list) {
544 if (w->cmd == pkt->hdr.cmd) {
545 w->triggered = true;
546 if (w->fn)
547 w->fn(priv, pkt, w->fn_data);
548 }
549 }
550 spin_unlock(&priv->_agn.notif_wait_lock);
551
552 wake_up_all(&priv->_agn.notif_waitq);
553 }
554 if (priv->pre_rx_handler)
555 priv->pre_rx_handler(priv, rxb);
556
557 /* Based on type of command response or notification,
558 * handle those that need handling via function in
559 * rx_handlers table. See iwl_setup_rx_handlers() */
560 if (priv->rx_handlers[pkt->hdr.cmd]) {
561 IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r,
562 i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
563 priv->isr_stats.rx_handlers[pkt->hdr.cmd]++;
564 priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
565 } else {
566 /* No handling needed */
567 IWL_DEBUG_RX(priv,
568 "r %d i %d No handler needed for %s, 0x%02x\n",
569 r, i, get_cmd_string(pkt->hdr.cmd),
570 pkt->hdr.cmd);
571 }
572
573 /*
574 * XXX: After here, we should always check rxb->page
575 * against NULL before touching it or its virtual
576 * memory (pkt). Because some rx_handler might have
577 * already taken or freed the pages.
578 */
579
580 if (reclaim) {
581 /* Invoke any callbacks, transfer the buffer to caller,
582 * and fire off the (possibly) blocking
583 * trans_send_cmd()
584 * as we reclaim the driver command queue */
585 if (rxb->page)
586 iwl_tx_cmd_complete(priv, rxb);
587 else
588 IWL_WARN(priv, "Claim null rxb?\n");
589 }
590
591 /* Reuse the page if possible. For notification packets and
592 * SKBs that fail to Rx correctly, add them back into the
593 * rx_free list for reuse later. */
594 spin_lock_irqsave(&rxq->lock, flags);
595 if (rxb->page != NULL) {
596 rxb->page_dma = dma_map_page(priv->bus.dev, rxb->page,
597 0, PAGE_SIZE << priv->hw_params.rx_page_order,
598 DMA_FROM_DEVICE);
599 list_add_tail(&rxb->list, &rxq->rx_free);
600 rxq->free_count++;
601 } else
602 list_add_tail(&rxb->list, &rxq->rx_used);
603
604 spin_unlock_irqrestore(&rxq->lock, flags);
605
606 i = (i + 1) & RX_QUEUE_MASK;
607 /* If there are a lot of unused frames,
608 * restock the Rx queue so ucode wont assert. */
609 if (fill_rx) {
610 count++;
611 if (count >= 8) {
612 rxq->read = i;
613 iwlagn_rx_replenish_now(priv);
614 count = 0;
615 }
616 }
617 }
618
619 /* Backtrack one entry */
620 rxq->read = i;
621 if (fill_rx)
622 iwlagn_rx_replenish_now(priv);
623 else
624 iwlagn_rx_queue_restock(priv);
625}
626
627/* tasklet for iwlagn interrupt */
628static void iwl_irq_tasklet(struct iwl_priv *priv)
629{
630 u32 inta = 0;
631 u32 handled = 0;
632 unsigned long flags;
633 u32 i;
634#ifdef CONFIG_IWLWIFI_DEBUG
635 u32 inta_mask;
636#endif
637
638 spin_lock_irqsave(&priv->lock, flags);
639
640 /* Ack/clear/reset pending uCode interrupts.
641 * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
642 */
643 /* There is a hardware bug in the interrupt mask function that some
644 * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if
645 * they are disabled in the CSR_INT_MASK register. Furthermore the
646 * ICT interrupt handling mechanism has another bug that might cause
647 * these unmasked interrupts fail to be detected. We workaround the
648 * hardware bugs here by ACKing all the possible interrupts so that
649 * interrupt coalescing can still be achieved.
650 */
651 iwl_write32(priv, CSR_INT, priv->_agn.inta | ~priv->inta_mask);
652
653 inta = priv->_agn.inta;
654
655#ifdef CONFIG_IWLWIFI_DEBUG
656 if (iwl_get_debug_level(priv) & IWL_DL_ISR) {
657 /* just for debug */
658 inta_mask = iwl_read32(priv, CSR_INT_MASK);
659 IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x\n ",
660 inta, inta_mask);
661 }
662#endif
663
664 spin_unlock_irqrestore(&priv->lock, flags);
665
666 /* saved interrupt in inta variable now we can reset priv->_agn.inta */
667 priv->_agn.inta = 0;
668
669 /* Now service all interrupt bits discovered above. */
670 if (inta & CSR_INT_BIT_HW_ERR) {
671 IWL_ERR(priv, "Hardware error detected. Restarting.\n");
672
673 /* Tell the device to stop sending interrupts */
674 iwl_disable_interrupts(priv);
675
676 priv->isr_stats.hw++;
677 iwl_irq_handle_error(priv);
678
679 handled |= CSR_INT_BIT_HW_ERR;
680
681 return;
682 }
683
684#ifdef CONFIG_IWLWIFI_DEBUG
685 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
686 /* NIC fires this, but we don't use it, redundant with WAKEUP */
687 if (inta & CSR_INT_BIT_SCD) {
688 IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
689 "the frame/frames.\n");
690 priv->isr_stats.sch++;
691 }
692
693 /* Alive notification via Rx interrupt will do the real work */
694 if (inta & CSR_INT_BIT_ALIVE) {
695 IWL_DEBUG_ISR(priv, "Alive interrupt\n");
696 priv->isr_stats.alive++;
697 }
698 }
699#endif
700 /* Safely ignore these bits for debug checks below */
701 inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
702
703 /* HW RF KILL switch toggled */
704 if (inta & CSR_INT_BIT_RF_KILL) {
705 int hw_rf_kill = 0;
706 if (!(iwl_read32(priv, CSR_GP_CNTRL) &
707 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
708 hw_rf_kill = 1;
709
710 IWL_WARN(priv, "RF_KILL bit toggled to %s.\n",
711 hw_rf_kill ? "disable radio" : "enable radio");
712
713 priv->isr_stats.rfkill++;
714
715 /* driver only loads ucode once setting the interface up.
716 * the driver allows loading the ucode even if the radio
717 * is killed. Hence update the killswitch state here. The
718 * rfkill handler will care about restarting if needed.
719 */
720 if (!test_bit(STATUS_ALIVE, &priv->status)) {
721 if (hw_rf_kill)
722 set_bit(STATUS_RF_KILL_HW, &priv->status);
723 else
724 clear_bit(STATUS_RF_KILL_HW, &priv->status);
725 wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rf_kill);
726 }
727
728 handled |= CSR_INT_BIT_RF_KILL;
729 }
730
731 /* Chip got too hot and stopped itself */
732 if (inta & CSR_INT_BIT_CT_KILL) {
733 IWL_ERR(priv, "Microcode CT kill error detected.\n");
734 priv->isr_stats.ctkill++;
735 handled |= CSR_INT_BIT_CT_KILL;
736 }
737
738 /* Error detected by uCode */
739 if (inta & CSR_INT_BIT_SW_ERR) {
740 IWL_ERR(priv, "Microcode SW error detected. "
741 " Restarting 0x%X.\n", inta);
742 priv->isr_stats.sw++;
743 iwl_irq_handle_error(priv);
744 handled |= CSR_INT_BIT_SW_ERR;
745 }
746
747 /* uCode wakes up after power-down sleep */
748 if (inta & CSR_INT_BIT_WAKEUP) {
749 IWL_DEBUG_ISR(priv, "Wakeup interrupt\n");
750 iwl_rx_queue_update_write_ptr(priv, &priv->rxq);
751 for (i = 0; i < priv->hw_params.max_txq_num; i++)
752 iwl_txq_update_write_ptr(priv, &priv->txq[i]);
753
754 priv->isr_stats.wakeup++;
755
756 handled |= CSR_INT_BIT_WAKEUP;
757 }
758
759 /* All uCode command responses, including Tx command responses,
760 * Rx "responses" (frame-received notification), and other
761 * notifications from uCode come through here*/
762 if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX |
763 CSR_INT_BIT_RX_PERIODIC)) {
764 IWL_DEBUG_ISR(priv, "Rx interrupt\n");
765 if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
766 handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
767 iwl_write32(priv, CSR_FH_INT_STATUS,
768 CSR_FH_INT_RX_MASK);
769 }
770 if (inta & CSR_INT_BIT_RX_PERIODIC) {
771 handled |= CSR_INT_BIT_RX_PERIODIC;
772 iwl_write32(priv, CSR_INT, CSR_INT_BIT_RX_PERIODIC);
773 }
774 /* Sending RX interrupt require many steps to be done in the
775 * the device:
776 * 1- write interrupt to current index in ICT table.
777 * 2- dma RX frame.
778 * 3- update RX shared data to indicate last write index.
779 * 4- send interrupt.
780 * This could lead to RX race, driver could receive RX interrupt
781 * but the shared data changes does not reflect this;
782 * periodic interrupt will detect any dangling Rx activity.
783 */
784
785 /* Disable periodic interrupt; we use it as just a one-shot. */
786 iwl_write8(priv, CSR_INT_PERIODIC_REG,
787 CSR_INT_PERIODIC_DIS);
788 iwl_rx_handle(priv);
789
790 /*
791 * Enable periodic interrupt in 8 msec only if we received
792 * real RX interrupt (instead of just periodic int), to catch
793 * any dangling Rx interrupt. If it was just the periodic
794 * interrupt, there was no dangling Rx activity, and no need
795 * to extend the periodic interrupt; one-shot is enough.
796 */
797 if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX))
798 iwl_write8(priv, CSR_INT_PERIODIC_REG,
799 CSR_INT_PERIODIC_ENA);
800
801 priv->isr_stats.rx++;
802 }
803
804 /* This "Tx" DMA channel is used only for loading uCode */
805 if (inta & CSR_INT_BIT_FH_TX) {
806 iwl_write32(priv, CSR_FH_INT_STATUS, CSR_FH_INT_TX_MASK);
807 IWL_DEBUG_ISR(priv, "uCode load interrupt\n");
808 priv->isr_stats.tx++;
809 handled |= CSR_INT_BIT_FH_TX;
810 /* Wake up uCode load routine, now that load is complete */
811 priv->ucode_write_complete = 1;
812 wake_up_interruptible(&priv->wait_command_queue);
813 }
814
815 if (inta & ~handled) {
816 IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
817 priv->isr_stats.unhandled++;
818 }
819
820 if (inta & ~(priv->inta_mask)) {
821 IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n",
822 inta & ~priv->inta_mask);
823 }
824
825 /* Re-enable all interrupts */
826 /* only Re-enable if disabled by irq */
827 if (test_bit(STATUS_INT_ENABLED, &priv->status))
828 iwl_enable_interrupts(priv);
829 /* Re-enable RF_KILL if it occurred */
830 else if (handled & CSR_INT_BIT_RF_KILL)
831 iwl_enable_rfkill_int(priv);
832}
833
834/***************************************************************************** 457/*****************************************************************************
835 * 458 *
836 * sysfs attributes 459 * sysfs attributes
@@ -954,7 +577,7 @@ static struct attribute_group iwl_attribute_group = {
954static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc) 577static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc)
955{ 578{
956 if (desc->v_addr) 579 if (desc->v_addr)
957 dma_free_coherent(priv->bus.dev, desc->len, 580 dma_free_coherent(priv->bus->dev, desc->len,
958 desc->v_addr, desc->p_addr); 581 desc->v_addr, desc->p_addr);
959 desc->v_addr = NULL; 582 desc->v_addr = NULL;
960 desc->len = 0; 583 desc->len = 0;
@@ -970,6 +593,7 @@ static void iwl_dealloc_ucode(struct iwl_priv *priv)
970{ 593{
971 iwl_free_fw_img(priv, &priv->ucode_rt); 594 iwl_free_fw_img(priv, &priv->ucode_rt);
972 iwl_free_fw_img(priv, &priv->ucode_init); 595 iwl_free_fw_img(priv, &priv->ucode_init);
596 iwl_free_fw_img(priv, &priv->ucode_wowlan);
973} 597}
974 598
975static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc, 599static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc,
@@ -980,7 +604,7 @@ static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc,
980 return -EINVAL; 604 return -EINVAL;
981 } 605 }
982 606
983 desc->v_addr = dma_alloc_coherent(priv->bus.dev, len, 607 desc->v_addr = dma_alloc_coherent(priv->bus->dev, len,
984 &desc->p_addr, GFP_KERNEL); 608 &desc->p_addr, GFP_KERNEL);
985 if (!desc->v_addr) 609 if (!desc->v_addr)
986 return -ENOMEM; 610 return -ENOMEM;
@@ -1034,13 +658,14 @@ static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
1034 priv->firmware_name); 658 priv->firmware_name);
1035 659
1036 return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, 660 return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name,
1037 priv->bus.dev, 661 priv->bus->dev,
1038 GFP_KERNEL, priv, iwl_ucode_callback); 662 GFP_KERNEL, priv, iwl_ucode_callback);
1039} 663}
1040 664
1041struct iwlagn_firmware_pieces { 665struct iwlagn_firmware_pieces {
1042 const void *inst, *data, *init, *init_data; 666 const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data;
1043 size_t inst_size, data_size, init_size, init_data_size; 667 size_t inst_size, data_size, init_size, init_data_size,
668 wowlan_inst_size, wowlan_data_size;
1044 669
1045 u32 build; 670 u32 build;
1046 671
@@ -1279,6 +904,14 @@ static int iwlagn_load_firmware(struct iwl_priv *priv,
1279 goto invalid_tlv_len; 904 goto invalid_tlv_len;
1280 priv->enhance_sensitivity_table = true; 905 priv->enhance_sensitivity_table = true;
1281 break; 906 break;
907 case IWL_UCODE_TLV_WOWLAN_INST:
908 pieces->wowlan_inst = tlv_data;
909 pieces->wowlan_inst_size = tlv_len;
910 break;
911 case IWL_UCODE_TLV_WOWLAN_DATA:
912 pieces->wowlan_data = tlv_data;
913 pieces->wowlan_data_size = tlv_len;
914 break;
1282 case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: 915 case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE:
1283 if (tlv_len != sizeof(u32)) 916 if (tlv_len != sizeof(u32))
1284 goto invalid_tlv_len; 917 goto invalid_tlv_len;
@@ -1473,6 +1106,18 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1473 goto err_pci_alloc; 1106 goto err_pci_alloc;
1474 } 1107 }
1475 1108
1109 /* WoWLAN instructions and data */
1110 if (pieces.wowlan_inst_size && pieces.wowlan_data_size) {
1111 if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.code,
1112 pieces.wowlan_inst,
1113 pieces.wowlan_inst_size))
1114 goto err_pci_alloc;
1115 if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.data,
1116 pieces.wowlan_data,
1117 pieces.wowlan_data_size))
1118 goto err_pci_alloc;
1119 }
1120
1476 /* Now that we can no longer fail, copy information */ 1121 /* Now that we can no longer fail, copy information */
1477 1122
1478 /* 1123 /*
@@ -1480,20 +1125,20 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1480 * for each event, which is of mode 1 (including timestamp) for all 1125 * for each event, which is of mode 1 (including timestamp) for all
1481 * new microcodes that include this information. 1126 * new microcodes that include this information.
1482 */ 1127 */
1483 priv->_agn.init_evtlog_ptr = pieces.init_evtlog_ptr; 1128 priv->init_evtlog_ptr = pieces.init_evtlog_ptr;
1484 if (pieces.init_evtlog_size) 1129 if (pieces.init_evtlog_size)
1485 priv->_agn.init_evtlog_size = (pieces.init_evtlog_size - 16)/12; 1130 priv->init_evtlog_size = (pieces.init_evtlog_size - 16)/12;
1486 else 1131 else
1487 priv->_agn.init_evtlog_size = 1132 priv->init_evtlog_size =
1488 priv->cfg->base_params->max_event_log_size; 1133 priv->cfg->base_params->max_event_log_size;
1489 priv->_agn.init_errlog_ptr = pieces.init_errlog_ptr; 1134 priv->init_errlog_ptr = pieces.init_errlog_ptr;
1490 priv->_agn.inst_evtlog_ptr = pieces.inst_evtlog_ptr; 1135 priv->inst_evtlog_ptr = pieces.inst_evtlog_ptr;
1491 if (pieces.inst_evtlog_size) 1136 if (pieces.inst_evtlog_size)
1492 priv->_agn.inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; 1137 priv->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12;
1493 else 1138 else
1494 priv->_agn.inst_evtlog_size = 1139 priv->inst_evtlog_size =
1495 priv->cfg->base_params->max_event_log_size; 1140 priv->cfg->base_params->max_event_log_size;
1496 priv->_agn.inst_errlog_ptr = pieces.inst_errlog_ptr; 1141 priv->inst_errlog_ptr = pieces.inst_errlog_ptr;
1497 1142
1498 priv->new_scan_threshold_behaviour = 1143 priv->new_scan_threshold_behaviour =
1499 !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); 1144 !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN);
@@ -1519,9 +1164,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1519 ucode_capa.standard_phy_calibration_size = 1164 ucode_capa.standard_phy_calibration_size =
1520 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; 1165 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE;
1521 1166
1522 priv->_agn.phy_calib_chain_noise_reset_cmd = 1167 priv->phy_calib_chain_noise_reset_cmd =
1523 ucode_capa.standard_phy_calibration_size; 1168 ucode_capa.standard_phy_calibration_size;
1524 priv->_agn.phy_calib_chain_noise_gain_cmd = 1169 priv->phy_calib_chain_noise_gain_cmd =
1525 ucode_capa.standard_phy_calibration_size + 1; 1170 ucode_capa.standard_phy_calibration_size + 1;
1526 1171
1527 /************************************************** 1172 /**************************************************
@@ -1537,7 +1182,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1537 if (err) 1182 if (err)
1538 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); 1183 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
1539 1184
1540 err = sysfs_create_group(&(priv->bus.dev->kobj), 1185 err = sysfs_create_group(&(priv->bus->dev->kobj),
1541 &iwl_attribute_group); 1186 &iwl_attribute_group);
1542 if (err) { 1187 if (err) {
1543 IWL_ERR(priv, "failed to create sysfs device attributes\n"); 1188 IWL_ERR(priv, "failed to create sysfs device attributes\n");
@@ -1546,7 +1191,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1546 1191
1547 /* We have our copies now, allow OS release its copies */ 1192 /* We have our copies now, allow OS release its copies */
1548 release_firmware(ucode_raw); 1193 release_firmware(ucode_raw);
1549 complete(&priv->_agn.firmware_loading_complete); 1194 complete(&priv->firmware_loading_complete);
1550 return; 1195 return;
1551 1196
1552 try_again: 1197 try_again:
@@ -1560,8 +1205,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1560 IWL_ERR(priv, "failed to allocate pci memory\n"); 1205 IWL_ERR(priv, "failed to allocate pci memory\n");
1561 iwl_dealloc_ucode(priv); 1206 iwl_dealloc_ucode(priv);
1562 out_unbind: 1207 out_unbind:
1563 complete(&priv->_agn.firmware_loading_complete); 1208 complete(&priv->firmware_loading_complete);
1564 device_release_driver(priv->bus.dev); 1209 device_release_driver(priv->bus->dev);
1565 release_firmware(ucode_raw); 1210 release_firmware(ucode_raw);
1566} 1211}
1567 1212
@@ -1642,13 +1287,13 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
1642 base = priv->device_pointers.error_event_table; 1287 base = priv->device_pointers.error_event_table;
1643 if (priv->ucode_type == IWL_UCODE_INIT) { 1288 if (priv->ucode_type == IWL_UCODE_INIT) {
1644 if (!base) 1289 if (!base)
1645 base = priv->_agn.init_errlog_ptr; 1290 base = priv->init_errlog_ptr;
1646 } else { 1291 } else {
1647 if (!base) 1292 if (!base)
1648 base = priv->_agn.inst_errlog_ptr; 1293 base = priv->inst_errlog_ptr;
1649 } 1294 }
1650 1295
1651 if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { 1296 if (!iwlagn_hw_valid_rtc_data_addr(base)) {
1652 IWL_ERR(priv, 1297 IWL_ERR(priv,
1653 "Not valid error log pointer 0x%08X for %s uCode\n", 1298 "Not valid error log pointer 0x%08X for %s uCode\n",
1654 base, 1299 base,
@@ -1718,10 +1363,10 @@ static int iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
1718 base = priv->device_pointers.log_event_table; 1363 base = priv->device_pointers.log_event_table;
1719 if (priv->ucode_type == IWL_UCODE_INIT) { 1364 if (priv->ucode_type == IWL_UCODE_INIT) {
1720 if (!base) 1365 if (!base)
1721 base = priv->_agn.init_evtlog_ptr; 1366 base = priv->init_evtlog_ptr;
1722 } else { 1367 } else {
1723 if (!base) 1368 if (!base)
1724 base = priv->_agn.inst_evtlog_ptr; 1369 base = priv->inst_evtlog_ptr;
1725 } 1370 }
1726 1371
1727 if (mode == 0) 1372 if (mode == 0)
@@ -1830,16 +1475,16 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
1830 1475
1831 base = priv->device_pointers.log_event_table; 1476 base = priv->device_pointers.log_event_table;
1832 if (priv->ucode_type == IWL_UCODE_INIT) { 1477 if (priv->ucode_type == IWL_UCODE_INIT) {
1833 logsize = priv->_agn.init_evtlog_size; 1478 logsize = priv->init_evtlog_size;
1834 if (!base) 1479 if (!base)
1835 base = priv->_agn.init_evtlog_ptr; 1480 base = priv->init_evtlog_ptr;
1836 } else { 1481 } else {
1837 logsize = priv->_agn.inst_evtlog_size; 1482 logsize = priv->inst_evtlog_size;
1838 if (!base) 1483 if (!base)
1839 base = priv->_agn.inst_evtlog_ptr; 1484 base = priv->inst_evtlog_ptr;
1840 } 1485 }
1841 1486
1842 if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { 1487 if (!iwlagn_hw_valid_rtc_data_addr(base)) {
1843 IWL_ERR(priv, 1488 IWL_ERR(priv,
1844 "Invalid event log pointer 0x%08X for %s uCode\n", 1489 "Invalid event log pointer 0x%08X for %s uCode\n",
1845 base, 1490 base,
@@ -1942,7 +1587,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1942 adv_cmd.critical_temperature_exit = 1587 adv_cmd.critical_temperature_exit =
1943 cpu_to_le32(priv->hw_params.ct_kill_exit_threshold); 1588 cpu_to_le32(priv->hw_params.ct_kill_exit_threshold);
1944 1589
1945 ret = trans_send_cmd_pdu(priv, 1590 ret = trans_send_cmd_pdu(&priv->trans,
1946 REPLY_CT_KILL_CONFIG_CMD, 1591 REPLY_CT_KILL_CONFIG_CMD,
1947 CMD_SYNC, sizeof(adv_cmd), &adv_cmd); 1592 CMD_SYNC, sizeof(adv_cmd), &adv_cmd);
1948 if (ret) 1593 if (ret)
@@ -1958,7 +1603,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1958 cmd.critical_temperature_R = 1603 cmd.critical_temperature_R =
1959 cpu_to_le32(priv->hw_params.ct_kill_threshold); 1604 cpu_to_le32(priv->hw_params.ct_kill_threshold);
1960 1605
1961 ret = trans_send_cmd_pdu(priv, 1606 ret = trans_send_cmd_pdu(&priv->trans,
1962 REPLY_CT_KILL_CONFIG_CMD, 1607 REPLY_CT_KILL_CONFIG_CMD,
1963 CMD_SYNC, sizeof(cmd), &cmd); 1608 CMD_SYNC, sizeof(cmd), &cmd);
1964 if (ret) 1609 if (ret)
@@ -1984,10 +1629,29 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg)
1984 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; 1629 calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL;
1985 calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg); 1630 calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg);
1986 1631
1987 return trans_send_cmd(priv, &cmd); 1632 return trans_send_cmd(&priv->trans, &cmd);
1988} 1633}
1989 1634
1990 1635
1636static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
1637{
1638 struct iwl_tx_ant_config_cmd tx_ant_cmd = {
1639 .valid = cpu_to_le32(valid_tx_ant),
1640 };
1641
1642 if (IWL_UCODE_API(priv->ucode_ver) > 1) {
1643 IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
1644 return trans_send_cmd_pdu(&priv->trans,
1645 TX_ANT_CONFIGURATION_CMD,
1646 CMD_SYNC,
1647 sizeof(struct iwl_tx_ant_config_cmd),
1648 &tx_ant_cmd);
1649 } else {
1650 IWL_DEBUG_HC(priv, "TX_ANT_CONFIGURATION_CMD not supported\n");
1651 return -EOPNOTSUPP;
1652 }
1653}
1654
1991/** 1655/**
1992 * iwl_alive_start - called after REPLY_ALIVE notification received 1656 * iwl_alive_start - called after REPLY_ALIVE notification received
1993 * from protocol/runtime uCode (initialization uCode's 1657 * from protocol/runtime uCode (initialization uCode's
@@ -1998,6 +1662,7 @@ int iwl_alive_start(struct iwl_priv *priv)
1998 int ret = 0; 1662 int ret = 0;
1999 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1663 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2000 1664
1665 /*TODO: this should go to the transport layer */
2001 iwl_reset_ict(priv); 1666 iwl_reset_ict(priv);
2002 1667
2003 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); 1668 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
@@ -2055,7 +1720,7 @@ int iwl_alive_start(struct iwl_priv *priv)
2055 /* Configure Tx antenna selection based on H/W config */ 1720 /* Configure Tx antenna selection based on H/W config */
2056 iwlagn_send_tx_ant_config(priv, priv->cfg->valid_tx_ant); 1721 iwlagn_send_tx_ant_config(priv, priv->cfg->valid_tx_ant);
2057 1722
2058 if (iwl_is_associated_ctx(ctx)) { 1723 if (iwl_is_associated_ctx(ctx) && !priv->wowlan) {
2059 struct iwl_rxon_cmd *active_rxon = 1724 struct iwl_rxon_cmd *active_rxon =
2060 (struct iwl_rxon_cmd *)&ctx->active; 1725 (struct iwl_rxon_cmd *)&ctx->active;
2061 /* apply any changes in staging */ 1726 /* apply any changes in staging */
@@ -2070,7 +1735,10 @@ int iwl_alive_start(struct iwl_priv *priv)
2070 iwlagn_set_rxon_chain(priv, ctx); 1735 iwlagn_set_rxon_chain(priv, ctx);
2071 } 1736 }
2072 1737
2073 iwl_reset_run_time_calib(priv); 1738 if (!priv->wowlan) {
1739 /* WoWLAN ucode will not reply in the same way, skip it */
1740 iwl_reset_run_time_calib(priv);
1741 }
2074 1742
2075 set_bit(STATUS_READY, &priv->status); 1743 set_bit(STATUS_READY, &priv->status);
2076 1744
@@ -2137,7 +1805,7 @@ static void __iwl_down(struct iwl_priv *priv)
2137 test_bit(STATUS_EXIT_PENDING, &priv->status) << 1805 test_bit(STATUS_EXIT_PENDING, &priv->status) <<
2138 STATUS_EXIT_PENDING; 1806 STATUS_EXIT_PENDING;
2139 1807
2140 iwlagn_stop_device(priv); 1808 trans_stop_device(&priv->trans);
2141 1809
2142 dev_kfree_skb(priv->beacon_skb); 1810 dev_kfree_skb(priv->beacon_skb);
2143 priv->beacon_skb = NULL; 1811 priv->beacon_skb = NULL;
@@ -2152,55 +1820,6 @@ static void iwl_down(struct iwl_priv *priv)
2152 iwl_cancel_deferred_work(priv); 1820 iwl_cancel_deferred_work(priv);
2153} 1821}
2154 1822
2155#define HW_READY_TIMEOUT (50)
2156
2157/* Note: returns poll_bit return value, which is >= 0 if success */
2158static int iwl_set_hw_ready(struct iwl_priv *priv)
2159{
2160 int ret;
2161
2162 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
2163 CSR_HW_IF_CONFIG_REG_BIT_NIC_READY);
2164
2165 /* See if we got it */
2166 ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
2167 CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
2168 CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
2169 HW_READY_TIMEOUT);
2170
2171 IWL_DEBUG_INFO(priv, "hardware%s ready\n", ret < 0 ? " not" : "");
2172 return ret;
2173}
2174
2175/* Note: returns standard 0/-ERROR code */
2176int iwl_prepare_card_hw(struct iwl_priv *priv)
2177{
2178 int ret;
2179
2180 IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter\n");
2181
2182 ret = iwl_set_hw_ready(priv);
2183 if (ret >= 0)
2184 return 0;
2185
2186 /* If HW is not ready, prepare the conditions to check again */
2187 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
2188 CSR_HW_IF_CONFIG_REG_PREPARE);
2189
2190 ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
2191 ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE,
2192 CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000);
2193
2194 if (ret < 0)
2195 return ret;
2196
2197 /* HW should be ready by now, check again. */
2198 ret = iwl_set_hw_ready(priv);
2199 if (ret >= 0)
2200 return 0;
2201 return ret;
2202}
2203
2204#define MAX_HW_RESTARTS 5 1823#define MAX_HW_RESTARTS 5
2205 1824
2206static int __iwl_up(struct iwl_priv *priv) 1825static int __iwl_up(struct iwl_priv *priv)
@@ -2336,19 +1955,6 @@ static void iwl_bg_restart(struct work_struct *data)
2336 } 1955 }
2337} 1956}
2338 1957
2339static void iwl_bg_rx_replenish(struct work_struct *data)
2340{
2341 struct iwl_priv *priv =
2342 container_of(data, struct iwl_priv, rx_replenish);
2343
2344 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2345 return;
2346
2347 mutex_lock(&priv->mutex);
2348 iwlagn_rx_replenish(priv);
2349 mutex_unlock(&priv->mutex);
2350}
2351
2352static int iwl_mac_offchannel_tx(struct ieee80211_hw *hw, struct sk_buff *skb, 1958static int iwl_mac_offchannel_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
2353 struct ieee80211_channel *chan, 1959 struct ieee80211_channel *chan,
2354 enum nl80211_channel_type channel_type, 1960 enum nl80211_channel_type channel_type,
@@ -2383,7 +1989,7 @@ static int iwl_mac_offchannel_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
2383 1989
2384 /* TODO: queue up if scanning? */ 1990 /* TODO: queue up if scanning? */
2385 if (test_bit(STATUS_SCANNING, &priv->status) || 1991 if (test_bit(STATUS_SCANNING, &priv->status) ||
2386 priv->_agn.offchan_tx_skb) { 1992 priv->offchan_tx_skb) {
2387 ret = -EBUSY; 1993 ret = -EBUSY;
2388 goto out; 1994 goto out;
2389 } 1995 }
@@ -2397,14 +2003,14 @@ static int iwl_mac_offchannel_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
2397 goto out; 2003 goto out;
2398 } 2004 }
2399 2005
2400 priv->_agn.offchan_tx_skb = skb; 2006 priv->offchan_tx_skb = skb;
2401 priv->_agn.offchan_tx_timeout = wait; 2007 priv->offchan_tx_timeout = wait;
2402 priv->_agn.offchan_tx_chan = chan; 2008 priv->offchan_tx_chan = chan;
2403 2009
2404 ret = iwl_scan_initiate(priv, priv->contexts[IWL_RXON_CTX_PAN].vif, 2010 ret = iwl_scan_initiate(priv, priv->contexts[IWL_RXON_CTX_PAN].vif,
2405 IWL_SCAN_OFFCH_TX, chan->band); 2011 IWL_SCAN_OFFCH_TX, chan->band);
2406 if (ret) 2012 if (ret)
2407 priv->_agn.offchan_tx_skb = NULL; 2013 priv->offchan_tx_skb = NULL;
2408 out: 2014 out:
2409 mutex_unlock(&priv->mutex); 2015 mutex_unlock(&priv->mutex);
2410 free: 2016 free:
@@ -2421,12 +2027,12 @@ static int iwl_mac_offchannel_tx_cancel_wait(struct ieee80211_hw *hw)
2421 2027
2422 mutex_lock(&priv->mutex); 2028 mutex_lock(&priv->mutex);
2423 2029
2424 if (!priv->_agn.offchan_tx_skb) { 2030 if (!priv->offchan_tx_skb) {
2425 ret = -EINVAL; 2031 ret = -EINVAL;
2426 goto unlock; 2032 goto unlock;
2427 } 2033 }
2428 2034
2429 priv->_agn.offchan_tx_skb = NULL; 2035 priv->offchan_tx_skb = NULL;
2430 2036
2431 ret = iwl_scan_cancel_timeout(priv, 200); 2037 ret = iwl_scan_cancel_timeout(priv, 200);
2432 if (ret) 2038 if (ret)
@@ -2572,6 +2178,23 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
2572 WIPHY_FLAG_DISABLE_BEACON_HINTS | 2178 WIPHY_FLAG_DISABLE_BEACON_HINTS |
2573 WIPHY_FLAG_IBSS_RSN; 2179 WIPHY_FLAG_IBSS_RSN;
2574 2180
2181 if (priv->ucode_wowlan.code.len && device_can_wakeup(priv->bus->dev)) {
2182 hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT |
2183 WIPHY_WOWLAN_DISCONNECT |
2184 WIPHY_WOWLAN_EAP_IDENTITY_REQ |
2185 WIPHY_WOWLAN_RFKILL_RELEASE;
2186 if (!iwlagn_mod_params.sw_crypto)
2187 hw->wiphy->wowlan.flags |=
2188 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
2189 WIPHY_WOWLAN_GTK_REKEY_FAILURE;
2190
2191 hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS;
2192 hw->wiphy->wowlan.pattern_min_len =
2193 IWLAGN_WOWLAN_MIN_PATTERN_LEN;
2194 hw->wiphy->wowlan.pattern_max_len =
2195 IWLAGN_WOWLAN_MAX_PATTERN_LEN;
2196 }
2197
2575 if (iwlagn_mod_params.power_save) 2198 if (iwlagn_mod_params.power_save)
2576 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; 2199 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
2577 else 2200 else
@@ -2656,6 +2279,471 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw)
2656 IWL_DEBUG_MAC80211(priv, "leave\n"); 2279 IWL_DEBUG_MAC80211(priv, "leave\n");
2657} 2280}
2658 2281
2282#ifdef CONFIG_PM
2283static int iwlagn_send_patterns(struct iwl_priv *priv,
2284 struct cfg80211_wowlan *wowlan)
2285{
2286 struct iwlagn_wowlan_patterns_cmd *pattern_cmd;
2287 struct iwl_host_cmd cmd = {
2288 .id = REPLY_WOWLAN_PATTERNS,
2289 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
2290 .flags = CMD_SYNC,
2291 };
2292 int i, err;
2293
2294 if (!wowlan->n_patterns)
2295 return 0;
2296
2297 cmd.len[0] = sizeof(*pattern_cmd) +
2298 wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern);
2299
2300 pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
2301 if (!pattern_cmd)
2302 return -ENOMEM;
2303
2304 pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns);
2305
2306 for (i = 0; i < wowlan->n_patterns; i++) {
2307 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
2308
2309 memcpy(&pattern_cmd->patterns[i].mask,
2310 wowlan->patterns[i].mask, mask_len);
2311 memcpy(&pattern_cmd->patterns[i].pattern,
2312 wowlan->patterns[i].pattern,
2313 wowlan->patterns[i].pattern_len);
2314 pattern_cmd->patterns[i].mask_size = mask_len;
2315 pattern_cmd->patterns[i].pattern_size =
2316 wowlan->patterns[i].pattern_len;
2317 }
2318
2319 cmd.data[0] = pattern_cmd;
2320 err = trans_send_cmd(&priv->trans, &cmd);
2321 kfree(pattern_cmd);
2322 return err;
2323}
2324#endif
2325
2326static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw,
2327 struct ieee80211_vif *vif,
2328 struct cfg80211_gtk_rekey_data *data)
2329{
2330 struct iwl_priv *priv = hw->priv;
2331
2332 if (iwlagn_mod_params.sw_crypto)
2333 return;
2334
2335 mutex_lock(&priv->mutex);
2336
2337 if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif)
2338 goto out;
2339
2340 memcpy(priv->kek, data->kek, NL80211_KEK_LEN);
2341 memcpy(priv->kck, data->kck, NL80211_KCK_LEN);
2342 priv->replay_ctr = cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr));
2343 priv->have_rekey_data = true;
2344
2345 out:
2346 mutex_unlock(&priv->mutex);
2347}
2348
2349struct wowlan_key_data {
2350 struct iwl_rxon_context *ctx;
2351 struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc;
2352 struct iwlagn_wowlan_tkip_params_cmd *tkip;
2353 const u8 *bssid;
2354 bool error, use_rsc_tsc, use_tkip;
2355};
2356
2357#ifdef CONFIG_PM
2358static void iwlagn_convert_p1k(u16 *p1k, __le16 *out)
2359{
2360 int i;
2361
2362 for (i = 0; i < IWLAGN_P1K_SIZE; i++)
2363 out[i] = cpu_to_le16(p1k[i]);
2364}
2365
2366static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
2367 struct ieee80211_vif *vif,
2368 struct ieee80211_sta *sta,
2369 struct ieee80211_key_conf *key,
2370 void *_data)
2371{
2372 struct iwl_priv *priv = hw->priv;
2373 struct wowlan_key_data *data = _data;
2374 struct iwl_rxon_context *ctx = data->ctx;
2375 struct aes_sc *aes_sc, *aes_tx_sc = NULL;
2376 struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL;
2377 struct iwlagn_p1k_cache *rx_p1ks;
2378 u8 *rx_mic_key;
2379 struct ieee80211_key_seq seq;
2380 u32 cur_rx_iv32 = 0;
2381 u16 p1k[IWLAGN_P1K_SIZE];
2382 int ret, i;
2383
2384 mutex_lock(&priv->mutex);
2385
2386 if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
2387 key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
2388 !sta && !ctx->key_mapping_keys)
2389 ret = iwl_set_default_wep_key(priv, ctx, key);
2390 else
2391 ret = iwl_set_dynamic_key(priv, ctx, key, sta);
2392
2393 if (ret) {
2394 IWL_ERR(priv, "Error setting key during suspend!\n");
2395 data->error = true;
2396 }
2397
2398 switch (key->cipher) {
2399 case WLAN_CIPHER_SUITE_TKIP:
2400 if (sta) {
2401 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
2402 tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
2403
2404 rx_p1ks = data->tkip->rx_uni;
2405
2406 ieee80211_get_key_tx_seq(key, &seq);
2407 tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16);
2408 tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32);
2409
2410 ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
2411 iwlagn_convert_p1k(p1k, data->tkip->tx.p1k);
2412
2413 memcpy(data->tkip->mic_keys.tx,
2414 &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
2415 IWLAGN_MIC_KEY_SIZE);
2416
2417 rx_mic_key = data->tkip->mic_keys.rx_unicast;
2418 } else {
2419 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc;
2420 rx_p1ks = data->tkip->rx_multi;
2421 rx_mic_key = data->tkip->mic_keys.rx_mcast;
2422 }
2423
2424 /*
2425 * For non-QoS this relies on the fact that both the uCode and
2426 * mac80211 use TID 0 (as they need to to avoid replay attacks)
2427 * for checking the IV in the frames.
2428 */
2429 for (i = 0; i < IWLAGN_NUM_RSC; i++) {
2430 ieee80211_get_key_rx_seq(key, i, &seq);
2431 tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16);
2432 tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32);
2433 /* wrapping isn't allowed, AP must rekey */
2434 if (seq.tkip.iv32 > cur_rx_iv32)
2435 cur_rx_iv32 = seq.tkip.iv32;
2436 }
2437
2438 ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k);
2439 iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k);
2440 ieee80211_get_tkip_rx_p1k(key, data->bssid,
2441 cur_rx_iv32 + 1, p1k);
2442 iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k);
2443
2444 memcpy(rx_mic_key,
2445 &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
2446 IWLAGN_MIC_KEY_SIZE);
2447
2448 data->use_tkip = true;
2449 data->use_rsc_tsc = true;
2450 break;
2451 case WLAN_CIPHER_SUITE_CCMP:
2452 if (sta) {
2453 u8 *pn = seq.ccmp.pn;
2454
2455 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
2456 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
2457
2458 ieee80211_get_key_tx_seq(key, &seq);
2459 aes_tx_sc->pn = cpu_to_le64(
2460 (u64)pn[5] |
2461 ((u64)pn[4] << 8) |
2462 ((u64)pn[3] << 16) |
2463 ((u64)pn[2] << 24) |
2464 ((u64)pn[1] << 32) |
2465 ((u64)pn[0] << 40));
2466 } else
2467 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
2468
2469 /*
2470 * For non-QoS this relies on the fact that both the uCode and
2471 * mac80211 use TID 0 for checking the IV in the frames.
2472 */
2473 for (i = 0; i < IWLAGN_NUM_RSC; i++) {
2474 u8 *pn = seq.ccmp.pn;
2475
2476 ieee80211_get_key_rx_seq(key, i, &seq);
2477 aes_sc->pn = cpu_to_le64(
2478 (u64)pn[5] |
2479 ((u64)pn[4] << 8) |
2480 ((u64)pn[3] << 16) |
2481 ((u64)pn[2] << 24) |
2482 ((u64)pn[1] << 32) |
2483 ((u64)pn[0] << 40));
2484 }
2485 data->use_rsc_tsc = true;
2486 break;
2487 }
2488
2489 mutex_unlock(&priv->mutex);
2490}
2491
2492static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
2493 struct cfg80211_wowlan *wowlan)
2494{
2495 struct iwl_priv *priv = hw->priv;
2496 struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd;
2497 struct iwl_rxon_cmd rxon;
2498 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2499 struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd;
2500 struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {};
2501 struct wowlan_key_data key_data = {
2502 .ctx = ctx,
2503 .bssid = ctx->active.bssid_addr,
2504 .use_rsc_tsc = false,
2505 .tkip = &tkip_cmd,
2506 .use_tkip = false,
2507 };
2508 int ret, i;
2509 u16 seq;
2510
2511 if (WARN_ON(!wowlan))
2512 return -EINVAL;
2513
2514 mutex_lock(&priv->mutex);
2515
2516 /* Don't attempt WoWLAN when not associated, tear down instead. */
2517 if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION ||
2518 !iwl_is_associated_ctx(ctx)) {
2519 ret = 1;
2520 goto out;
2521 }
2522
2523 key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL);
2524 if (!key_data.rsc_tsc) {
2525 ret = -ENOMEM;
2526 goto out;
2527 }
2528
2529 memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd));
2530
2531 /*
2532 * We know the last used seqno, and the uCode expects to know that
2533 * one, it will increment before TX.
2534 */
2535 seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ;
2536 wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq);
2537
2538 /*
2539 * For QoS counters, we store the one to use next, so subtract 0x10
2540 * since the uCode will add 0x10 before using the value.
2541 */
2542 for (i = 0; i < 8; i++) {
2543 seq = priv->stations[IWL_AP_ID].tid[i].seq_number;
2544 seq -= 0x10;
2545 wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq);
2546 }
2547
2548 if (wowlan->disconnect)
2549 wakeup_filter_cmd.enabled |=
2550 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS |
2551 IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE);
2552 if (wowlan->magic_pkt)
2553 wakeup_filter_cmd.enabled |=
2554 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET);
2555 if (wowlan->gtk_rekey_failure)
2556 wakeup_filter_cmd.enabled |=
2557 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL);
2558 if (wowlan->eap_identity_req)
2559 wakeup_filter_cmd.enabled |=
2560 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ);
2561 if (wowlan->four_way_handshake)
2562 wakeup_filter_cmd.enabled |=
2563 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE);
2564 if (wowlan->rfkill_release)
2565 wakeup_filter_cmd.enabled |=
2566 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_RFKILL);
2567 if (wowlan->n_patterns)
2568 wakeup_filter_cmd.enabled |=
2569 cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH);
2570
2571 iwl_scan_cancel_timeout(priv, 200);
2572
2573 memcpy(&rxon, &ctx->active, sizeof(rxon));
2574
2575 trans_stop_device(&priv->trans);
2576
2577 priv->wowlan = true;
2578
2579 ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_wowlan,
2580 IWL_UCODE_WOWLAN);
2581 if (ret)
2582 goto error;
2583
2584 /* now configure WoWLAN ucode */
2585 ret = iwl_alive_start(priv);
2586 if (ret)
2587 goto error;
2588
2589 memcpy(&ctx->staging, &rxon, sizeof(rxon));
2590 ret = iwlagn_commit_rxon(priv, ctx);
2591 if (ret)
2592 goto error;
2593
2594 ret = iwl_power_update_mode(priv, true);
2595 if (ret)
2596 goto error;
2597
2598 if (!iwlagn_mod_params.sw_crypto) {
2599 /* mark all keys clear */
2600 priv->ucode_key_table = 0;
2601 ctx->key_mapping_keys = 0;
2602
2603 /*
2604 * This needs to be unlocked due to lock ordering
2605 * constraints. Since we're in the suspend path
2606 * that isn't really a problem though.
2607 */
2608 mutex_unlock(&priv->mutex);
2609 ieee80211_iter_keys(priv->hw, ctx->vif,
2610 iwlagn_wowlan_program_keys,
2611 &key_data);
2612 mutex_lock(&priv->mutex);
2613 if (key_data.error) {
2614 ret = -EIO;
2615 goto error;
2616 }
2617
2618 if (key_data.use_rsc_tsc) {
2619 struct iwl_host_cmd rsc_tsc_cmd = {
2620 .id = REPLY_WOWLAN_TSC_RSC_PARAMS,
2621 .flags = CMD_SYNC,
2622 .data[0] = key_data.rsc_tsc,
2623 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
2624 .len[0] = sizeof(*key_data.rsc_tsc),
2625 };
2626
2627 ret = trans_send_cmd(&priv->trans, &rsc_tsc_cmd);
2628 if (ret)
2629 goto error;
2630 }
2631
2632 if (key_data.use_tkip) {
2633 ret = trans_send_cmd_pdu(&priv->trans,
2634 REPLY_WOWLAN_TKIP_PARAMS,
2635 CMD_SYNC, sizeof(tkip_cmd),
2636 &tkip_cmd);
2637 if (ret)
2638 goto error;
2639 }
2640
2641 if (priv->have_rekey_data) {
2642 memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd));
2643 memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN);
2644 kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN);
2645 memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN);
2646 kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
2647 kek_kck_cmd.replay_ctr = priv->replay_ctr;
2648
2649 ret = trans_send_cmd_pdu(&priv->trans,
2650 REPLY_WOWLAN_KEK_KCK_MATERIAL,
2651 CMD_SYNC, sizeof(kek_kck_cmd),
2652 &kek_kck_cmd);
2653 if (ret)
2654 goto error;
2655 }
2656 }
2657
2658 ret = trans_send_cmd_pdu(&priv->trans, REPLY_WOWLAN_WAKEUP_FILTER,
2659 CMD_SYNC, sizeof(wakeup_filter_cmd),
2660 &wakeup_filter_cmd);
2661 if (ret)
2662 goto error;
2663
2664 ret = iwlagn_send_patterns(priv, wowlan);
2665 if (ret)
2666 goto error;
2667
2668 device_set_wakeup_enable(priv->bus->dev, true);
2669
2670 /* Now let the ucode operate on its own */
2671 iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
2672 CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
2673
2674 goto out;
2675
2676 error:
2677 priv->wowlan = false;
2678 iwlagn_prepare_restart(priv);
2679 ieee80211_restart_hw(priv->hw);
2680 out:
2681 mutex_unlock(&priv->mutex);
2682 kfree(key_data.rsc_tsc);
2683 return ret;
2684}
2685
2686static int iwlagn_mac_resume(struct ieee80211_hw *hw)
2687{
2688 struct iwl_priv *priv = hw->priv;
2689 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2690 struct ieee80211_vif *vif;
2691 unsigned long flags;
2692 u32 base, status = 0xffffffff;
2693 int ret = -EIO;
2694
2695 mutex_lock(&priv->mutex);
2696
2697 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
2698 CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
2699
2700 base = priv->device_pointers.error_event_table;
2701 if (iwlagn_hw_valid_rtc_data_addr(base)) {
2702 spin_lock_irqsave(&priv->reg_lock, flags);
2703 ret = iwl_grab_nic_access_silent(priv);
2704 if (ret == 0) {
2705 iwl_write32(priv, HBUS_TARG_MEM_RADDR, base);
2706 status = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
2707 iwl_release_nic_access(priv);
2708 }
2709 spin_unlock_irqrestore(&priv->reg_lock, flags);
2710
2711#ifdef CONFIG_IWLWIFI_DEBUGFS
2712 if (ret == 0) {
2713 if (!priv->wowlan_sram)
2714 priv->wowlan_sram =
2715 kzalloc(priv->ucode_wowlan.data.len,
2716 GFP_KERNEL);
2717
2718 if (priv->wowlan_sram)
2719 _iwl_read_targ_mem_words(
2720 priv, 0x800000, priv->wowlan_sram,
2721 priv->ucode_wowlan.data.len / 4);
2722 }
2723#endif
2724 }
2725
2726 /* we'll clear ctx->vif during iwlagn_prepare_restart() */
2727 vif = ctx->vif;
2728
2729 priv->wowlan = false;
2730
2731 device_set_wakeup_enable(priv->bus->dev, false);
2732
2733 iwlagn_prepare_restart(priv);
2734
2735 memset((void *)&ctx->active, 0, sizeof(ctx->active));
2736 iwl_connection_init_rx_config(priv, ctx);
2737 iwlagn_set_rxon_chain(priv, ctx);
2738
2739 mutex_unlock(&priv->mutex);
2740
2741 ieee80211_resume_disconnect(vif);
2742
2743 return 1;
2744}
2745#endif
2746
2659static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 2747static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2660{ 2748{
2661 struct iwl_priv *priv = hw->priv; 2749 struct iwl_priv *priv = hw->priv;
@@ -2678,14 +2766,8 @@ static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw,
2678 u32 iv32, u16 *phase1key) 2766 u32 iv32, u16 *phase1key)
2679{ 2767{
2680 struct iwl_priv *priv = hw->priv; 2768 struct iwl_priv *priv = hw->priv;
2681 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
2682
2683 IWL_DEBUG_MAC80211(priv, "enter\n");
2684 2769
2685 iwl_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, 2770 iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key);
2686 iv32, phase1key);
2687
2688 IWL_DEBUG_MAC80211(priv, "leave\n");
2689} 2771}
2690 2772
2691static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 2773static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -2697,7 +2779,6 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2697 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 2779 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
2698 struct iwl_rxon_context *ctx = vif_priv->ctx; 2780 struct iwl_rxon_context *ctx = vif_priv->ctx;
2699 int ret; 2781 int ret;
2700 u8 sta_id;
2701 bool is_default_wep_key = false; 2782 bool is_default_wep_key = false;
2702 2783
2703 IWL_DEBUG_MAC80211(priv, "enter\n"); 2784 IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -2708,20 +2789,27 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2708 } 2789 }
2709 2790
2710 /* 2791 /*
2711 * To support IBSS RSN, don't program group keys in IBSS, the 2792 * We could program these keys into the hardware as well, but we
2712 * hardware will then not attempt to decrypt the frames. 2793 * don't expect much multicast traffic in IBSS and having keys
2794 * for more stations is probably more useful.
2795 *
2796 * Mark key TX-only and return 0.
2713 */ 2797 */
2714 if (vif->type == NL80211_IFTYPE_ADHOC && 2798 if (vif->type == NL80211_IFTYPE_ADHOC &&
2715 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) 2799 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
2716 return -EOPNOTSUPP; 2800 key->hw_key_idx = WEP_INVALID_OFFSET;
2801 return 0;
2802 }
2717 2803
2718 sta_id = iwl_sta_id_or_broadcast(priv, vif_priv->ctx, sta); 2804 /* If they key was TX-only, accept deletion */
2719 if (sta_id == IWL_INVALID_STATION) 2805 if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET)
2720 return -EINVAL; 2806 return 0;
2721 2807
2722 mutex_lock(&priv->mutex); 2808 mutex_lock(&priv->mutex);
2723 iwl_scan_cancel_timeout(priv, 100); 2809 iwl_scan_cancel_timeout(priv, 100);
2724 2810
2811 BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT);
2812
2725 /* 2813 /*
2726 * If we are getting WEP group key and we didn't receive any key mapping 2814 * If we are getting WEP group key and we didn't receive any key mapping
2727 * so far, we are in legacy wep mode (group key only), otherwise we are 2815 * so far, we are in legacy wep mode (group key only), otherwise we are
@@ -2729,22 +2817,30 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2729 * In legacy wep mode, we use another host command to the uCode. 2817 * In legacy wep mode, we use another host command to the uCode.
2730 */ 2818 */
2731 if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || 2819 if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
2732 key->cipher == WLAN_CIPHER_SUITE_WEP104) && 2820 key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) {
2733 !sta) {
2734 if (cmd == SET_KEY) 2821 if (cmd == SET_KEY)
2735 is_default_wep_key = !ctx->key_mapping_keys; 2822 is_default_wep_key = !ctx->key_mapping_keys;
2736 else 2823 else
2737 is_default_wep_key = 2824 is_default_wep_key =
2738 (key->hw_key_idx == HW_KEY_DEFAULT); 2825 key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT;
2739 } 2826 }
2740 2827
2828
2741 switch (cmd) { 2829 switch (cmd) {
2742 case SET_KEY: 2830 case SET_KEY:
2743 if (is_default_wep_key) 2831 if (is_default_wep_key) {
2744 ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); 2832 ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key);
2745 else 2833 break;
2746 ret = iwl_set_dynamic_key(priv, vif_priv->ctx, 2834 }
2747 key, sta_id); 2835 ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta);
2836 if (ret) {
2837 /*
2838 * can't add key for RX, but we don't need it
2839 * in the device for TX so still return 0
2840 */
2841 ret = 0;
2842 key->hw_key_idx = WEP_INVALID_OFFSET;
2843 }
2748 2844
2749 IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); 2845 IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n");
2750 break; 2846 break;
@@ -2752,7 +2848,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2752 if (is_default_wep_key) 2848 if (is_default_wep_key)
2753 ret = iwl_remove_default_wep_key(priv, ctx, key); 2849 ret = iwl_remove_default_wep_key(priv, ctx, key);
2754 else 2850 else
2755 ret = iwl_remove_dynamic_key(priv, ctx, key, sta_id); 2851 ret = iwl_remove_dynamic_key(priv, ctx, key, sta);
2756 2852
2757 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); 2853 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n");
2758 break; 2854 break;
@@ -2799,18 +2895,18 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
2799 IWL_DEBUG_HT(priv, "start Tx\n"); 2895 IWL_DEBUG_HT(priv, "start Tx\n");
2800 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); 2896 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
2801 if (ret == 0) { 2897 if (ret == 0) {
2802 priv->_agn.agg_tids_count++; 2898 priv->agg_tids_count++;
2803 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n", 2899 IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
2804 priv->_agn.agg_tids_count); 2900 priv->agg_tids_count);
2805 } 2901 }
2806 break; 2902 break;
2807 case IEEE80211_AMPDU_TX_STOP: 2903 case IEEE80211_AMPDU_TX_STOP:
2808 IWL_DEBUG_HT(priv, "stop Tx\n"); 2904 IWL_DEBUG_HT(priv, "stop Tx\n");
2809 ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); 2905 ret = iwlagn_tx_agg_stop(priv, vif, sta, tid);
2810 if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) { 2906 if ((ret == 0) && (priv->agg_tids_count > 0)) {
2811 priv->_agn.agg_tids_count--; 2907 priv->agg_tids_count--;
2812 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n", 2908 IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
2813 priv->_agn.agg_tids_count); 2909 priv->agg_tids_count);
2814 } 2910 }
2815 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2911 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2816 ret = 0; 2912 ret = 0;
@@ -2828,7 +2924,8 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
2828 case IEEE80211_AMPDU_TX_OPERATIONAL: 2924 case IEEE80211_AMPDU_TX_OPERATIONAL:
2829 buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); 2925 buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF);
2830 2926
2831 iwlagn_txq_agg_queue_setup(priv, sta, tid, buf_size); 2927 trans_txq_agg_setup(&priv->trans, iwl_sta_id(sta), tid,
2928 buf_size);
2832 2929
2833 /* 2930 /*
2834 * If the limit is 0, then it wasn't initialised yet, 2931 * If the limit is 0, then it wasn't initialised yet,
@@ -2954,7 +3051,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
2954 if (!iwl_is_associated_ctx(ctx)) 3051 if (!iwl_is_associated_ctx(ctx))
2955 goto out; 3052 goto out;
2956 3053
2957 if (!priv->cfg->ops->lib->set_channel_switch) 3054 if (!priv->cfg->lib->set_channel_switch)
2958 goto out; 3055 goto out;
2959 3056
2960 ch = channel->hw_value; 3057 ch = channel->hw_value;
@@ -3006,7 +3103,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
3006 */ 3103 */
3007 set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); 3104 set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
3008 priv->switch_channel = cpu_to_le16(ch); 3105 priv->switch_channel = cpu_to_le16(ch);
3009 if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) { 3106 if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) {
3010 clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); 3107 clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
3011 priv->switch_channel = 0; 3108 priv->switch_channel = 0;
3012 ieee80211_chswitch_done(ctx->vif, false); 3109 ieee80211_chswitch_done(ctx->vif, false);
@@ -3116,7 +3213,7 @@ static void iwlagn_disable_roc(struct iwl_priv *priv)
3116 iwl_set_rxon_channel(priv, chan, ctx); 3213 iwl_set_rxon_channel(priv, chan, ctx);
3117 iwl_set_flags_for_band(priv, ctx, chan->band, NULL); 3214 iwl_set_flags_for_band(priv, ctx, chan->band, NULL);
3118 3215
3119 priv->_agn.hw_roc_channel = NULL; 3216 priv->hw_roc_channel = NULL;
3120 3217
3121 iwlagn_commit_rxon(priv, ctx); 3218 iwlagn_commit_rxon(priv, ctx);
3122 3219
@@ -3126,7 +3223,7 @@ static void iwlagn_disable_roc(struct iwl_priv *priv)
3126static void iwlagn_bg_roc_done(struct work_struct *work) 3223static void iwlagn_bg_roc_done(struct work_struct *work)
3127{ 3224{
3128 struct iwl_priv *priv = container_of(work, struct iwl_priv, 3225 struct iwl_priv *priv = container_of(work, struct iwl_priv,
3129 _agn.hw_roc_work.work); 3226 hw_roc_work.work);
3130 3227
3131 mutex_lock(&priv->mutex); 3228 mutex_lock(&priv->mutex);
3132 ieee80211_remain_on_channel_expired(priv->hw); 3229 ieee80211_remain_on_channel_expired(priv->hw);
@@ -3158,11 +3255,11 @@ static int iwl_mac_remain_on_channel(struct ieee80211_hw *hw,
3158 } 3255 }
3159 3256
3160 priv->contexts[IWL_RXON_CTX_PAN].is_active = true; 3257 priv->contexts[IWL_RXON_CTX_PAN].is_active = true;
3161 priv->_agn.hw_roc_channel = channel; 3258 priv->hw_roc_channel = channel;
3162 priv->_agn.hw_roc_chantype = channel_type; 3259 priv->hw_roc_chantype = channel_type;
3163 priv->_agn.hw_roc_duration = DIV_ROUND_UP(duration * 1000, 1024); 3260 priv->hw_roc_duration = DIV_ROUND_UP(duration * 1000, 1024);
3164 iwlagn_commit_rxon(priv, &priv->contexts[IWL_RXON_CTX_PAN]); 3261 iwlagn_commit_rxon(priv, &priv->contexts[IWL_RXON_CTX_PAN]);
3165 queue_delayed_work(priv->workqueue, &priv->_agn.hw_roc_work, 3262 queue_delayed_work(priv->workqueue, &priv->hw_roc_work,
3166 msecs_to_jiffies(duration + 20)); 3263 msecs_to_jiffies(duration + 20));
3167 3264
3168 msleep(IWL_MIN_SLOT_TIME); /* TU is almost ms */ 3265 msleep(IWL_MIN_SLOT_TIME); /* TU is almost ms */
@@ -3181,7 +3278,7 @@ static int iwl_mac_cancel_remain_on_channel(struct ieee80211_hw *hw)
3181 if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN))) 3278 if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN)))
3182 return -EOPNOTSUPP; 3279 return -EOPNOTSUPP;
3183 3280
3184 cancel_delayed_work_sync(&priv->_agn.hw_roc_work); 3281 cancel_delayed_work_sync(&priv->hw_roc_work);
3185 3282
3186 mutex_lock(&priv->mutex); 3283 mutex_lock(&priv->mutex);
3187 iwlagn_disable_roc(priv); 3284 iwlagn_disable_roc(priv);
@@ -3203,18 +3300,17 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
3203 init_waitqueue_head(&priv->wait_command_queue); 3300 init_waitqueue_head(&priv->wait_command_queue);
3204 3301
3205 INIT_WORK(&priv->restart, iwl_bg_restart); 3302 INIT_WORK(&priv->restart, iwl_bg_restart);
3206 INIT_WORK(&priv->rx_replenish, iwl_bg_rx_replenish);
3207 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); 3303 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update);
3208 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); 3304 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work);
3209 INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); 3305 INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush);
3210 INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency); 3306 INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency);
3211 INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config); 3307 INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config);
3212 INIT_DELAYED_WORK(&priv->_agn.hw_roc_work, iwlagn_bg_roc_done); 3308 INIT_DELAYED_WORK(&priv->hw_roc_work, iwlagn_bg_roc_done);
3213 3309
3214 iwl_setup_scan_deferred_work(priv); 3310 iwl_setup_scan_deferred_work(priv);
3215 3311
3216 if (priv->cfg->ops->lib->setup_deferred_work) 3312 if (priv->cfg->lib->bt_setup_deferred_work)
3217 priv->cfg->ops->lib->setup_deferred_work(priv); 3313 priv->cfg->lib->bt_setup_deferred_work(priv);
3218 3314
3219 init_timer(&priv->statistics_periodic); 3315 init_timer(&priv->statistics_periodic);
3220 priv->statistics_periodic.data = (unsigned long)priv; 3316 priv->statistics_periodic.data = (unsigned long)priv;
@@ -3227,15 +3323,12 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
3227 init_timer(&priv->watchdog); 3323 init_timer(&priv->watchdog);
3228 priv->watchdog.data = (unsigned long)priv; 3324 priv->watchdog.data = (unsigned long)priv;
3229 priv->watchdog.function = iwl_bg_watchdog; 3325 priv->watchdog.function = iwl_bg_watchdog;
3230
3231 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
3232 iwl_irq_tasklet, (unsigned long)priv);
3233} 3326}
3234 3327
3235static void iwl_cancel_deferred_work(struct iwl_priv *priv) 3328static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3236{ 3329{
3237 if (priv->cfg->ops->lib->cancel_deferred_work) 3330 if (priv->cfg->lib->cancel_deferred_work)
3238 priv->cfg->ops->lib->cancel_deferred_work(priv); 3331 priv->cfg->lib->cancel_deferred_work(priv);
3239 3332
3240 cancel_work_sync(&priv->run_time_calib_work); 3333 cancel_work_sync(&priv->run_time_calib_work);
3241 cancel_work_sync(&priv->beacon_update); 3334 cancel_work_sync(&priv->beacon_update);
@@ -3286,7 +3379,7 @@ static int iwl_init_drv(struct iwl_priv *priv)
3286 priv->iw_mode = NL80211_IFTYPE_STATION; 3379 priv->iw_mode = NL80211_IFTYPE_STATION;
3287 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; 3380 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
3288 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 3381 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3289 priv->_agn.agg_tids_count = 0; 3382 priv->agg_tids_count = 0;
3290 3383
3291 /* initialize force reset */ 3384 /* initialize force reset */
3292 priv->force_reset[IWL_RF_RESET].reset_duration = 3385 priv->force_reset[IWL_RF_RESET].reset_duration =
@@ -3340,6 +3433,9 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
3340 iwl_free_channel_map(priv); 3433 iwl_free_channel_map(priv);
3341 kfree(priv->scan_cmd); 3434 kfree(priv->scan_cmd);
3342 kfree(priv->beacon_cmd); 3435 kfree(priv->beacon_cmd);
3436#ifdef CONFIG_IWLWIFI_DEBUGFS
3437 kfree(priv->wowlan_sram);
3438#endif
3343} 3439}
3344 3440
3345static void iwl_mac_rssi_callback(struct ieee80211_hw *hw, 3441static void iwl_mac_rssi_callback(struct ieee80211_hw *hw,
@@ -3369,6 +3465,10 @@ struct ieee80211_ops iwlagn_hw_ops = {
3369 .tx = iwlagn_mac_tx, 3465 .tx = iwlagn_mac_tx,
3370 .start = iwlagn_mac_start, 3466 .start = iwlagn_mac_start,
3371 .stop = iwlagn_mac_stop, 3467 .stop = iwlagn_mac_stop,
3468#ifdef CONFIG_PM
3469 .suspend = iwlagn_mac_suspend,
3470 .resume = iwlagn_mac_resume,
3471#endif
3372 .add_interface = iwl_mac_add_interface, 3472 .add_interface = iwl_mac_add_interface,
3373 .remove_interface = iwl_mac_remove_interface, 3473 .remove_interface = iwl_mac_remove_interface,
3374 .change_interface = iwl_mac_change_interface, 3474 .change_interface = iwl_mac_change_interface,
@@ -3376,6 +3476,7 @@ struct ieee80211_ops iwlagn_hw_ops = {
3376 .configure_filter = iwlagn_configure_filter, 3476 .configure_filter = iwlagn_configure_filter,
3377 .set_key = iwlagn_mac_set_key, 3477 .set_key = iwlagn_mac_set_key,
3378 .update_tkip_key = iwlagn_mac_update_tkip_key, 3478 .update_tkip_key = iwlagn_mac_update_tkip_key,
3479 .set_rekey_data = iwlagn_mac_set_rekey_data,
3379 .conf_tx = iwl_mac_conf_tx, 3480 .conf_tx = iwl_mac_conf_tx,
3380 .bss_info_changed = iwlagn_bss_info_changed, 3481 .bss_info_changed = iwlagn_bss_info_changed,
3381 .ampdu_action = iwlagn_mac_ampdu_action, 3482 .ampdu_action = iwlagn_mac_ampdu_action,
@@ -3415,7 +3516,7 @@ static int iwl_set_hw_params(struct iwl_priv *priv)
3415 priv->cfg->sku &= ~EEPROM_SKU_CAP_11N_ENABLE; 3516 priv->cfg->sku &= ~EEPROM_SKU_CAP_11N_ENABLE;
3416 3517
3417 /* Device-specific setup */ 3518 /* Device-specific setup */
3418 return priv->cfg->ops->lib->set_hw_params(priv); 3519 return priv->cfg->lib->set_hw_params(priv);
3419} 3520}
3420 3521
3421static const u8 iwlagn_bss_ac_to_fifo[] = { 3522static const u8 iwlagn_bss_ac_to_fifo[] = {
@@ -3521,8 +3622,7 @@ static void iwl_init_context(struct iwl_priv *priv)
3521 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 3622 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
3522} 3623}
3523 3624
3524int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, 3625int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
3525 struct iwl_cfg *cfg)
3526{ 3626{
3527 int err = 0; 3627 int err = 0;
3528 struct iwl_priv *priv; 3628 struct iwl_priv *priv;
@@ -3540,19 +3640,12 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3540 } 3640 }
3541 3641
3542 priv = hw->priv; 3642 priv = hw->priv;
3543 3643 priv->bus = bus;
3544 priv->bus.priv = priv; 3644 bus_set_drv_data(priv->bus, priv);
3545 priv->bus.bus_specific = bus_specific;
3546 priv->bus.ops = bus_ops;
3547 priv->bus.irq = priv->bus.ops->get_irq(&priv->bus);
3548 priv->bus.ops->set_drv_data(&priv->bus, priv);
3549 priv->bus.dev = priv->bus.ops->get_dev(&priv->bus);
3550
3551 iwl_trans_register(&priv->trans);
3552 3645
3553 /* At this point both hw and priv are allocated. */ 3646 /* At this point both hw and priv are allocated. */
3554 3647
3555 SET_IEEE80211_DEV(hw, priv->bus.dev); 3648 SET_IEEE80211_DEV(hw, priv->bus->dev);
3556 3649
3557 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); 3650 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
3558 priv->cfg = cfg; 3651 priv->cfg = cfg;
@@ -3571,7 +3664,6 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3571 if (iwl_alloc_traffic_mem(priv)) 3664 if (iwl_alloc_traffic_mem(priv))
3572 IWL_ERR(priv, "Not enough memory to generate traffic log\n"); 3665 IWL_ERR(priv, "Not enough memory to generate traffic log\n");
3573 3666
3574
3575 /* these spin locks will be used in apm_ops.init and EEPROM access 3667 /* these spin locks will be used in apm_ops.init and EEPROM access
3576 * we should init now 3668 * we should init now
3577 */ 3669 */
@@ -3592,10 +3684,14 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3592 IWL_INFO(priv, "Detected %s, REV=0x%X\n", 3684 IWL_INFO(priv, "Detected %s, REV=0x%X\n",
3593 priv->cfg->name, hw_rev); 3685 priv->cfg->name, hw_rev);
3594 3686
3595 if (iwl_prepare_card_hw(priv)) { 3687 err = iwl_trans_register(&priv->trans, priv);
3688 if (err)
3689 goto out_free_traffic_mem;
3690
3691 if (trans_prepare_card_hw(&priv->trans)) {
3596 err = -EIO; 3692 err = -EIO;
3597 IWL_WARN(priv, "Failed, HW not ready\n"); 3693 IWL_WARN(priv, "Failed, HW not ready\n");
3598 goto out_free_traffic_mem; 3694 goto out_free_trans;
3599 } 3695 }
3600 3696
3601 /***************** 3697 /*****************
@@ -3605,7 +3701,7 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3605 err = iwl_eeprom_init(priv, hw_rev); 3701 err = iwl_eeprom_init(priv, hw_rev);
3606 if (err) { 3702 if (err) {
3607 IWL_ERR(priv, "Unable to init EEPROM\n"); 3703 IWL_ERR(priv, "Unable to init EEPROM\n");
3608 goto out_free_traffic_mem; 3704 goto out_free_trans;
3609 } 3705 }
3610 err = iwl_eeprom_check_version(priv); 3706 err = iwl_eeprom_check_version(priv);
3611 if (err) 3707 if (err)
@@ -3652,15 +3748,6 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3652 /******************** 3748 /********************
3653 * 7. Setup services 3749 * 7. Setup services
3654 ********************/ 3750 ********************/
3655 iwl_alloc_isr_ict(priv);
3656
3657 err = request_irq(priv->bus.irq, iwl_isr_ict, IRQF_SHARED,
3658 DRV_NAME, priv);
3659 if (err) {
3660 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->bus.irq);
3661 goto out_uninit_drv;
3662 }
3663
3664 iwl_setup_deferred_work(priv); 3751 iwl_setup_deferred_work(priv);
3665 iwl_setup_rx_handlers(priv); 3752 iwl_setup_rx_handlers(priv);
3666 iwl_testmode_init(priv); 3753 iwl_testmode_init(priv);
@@ -3683,7 +3770,7 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3683 iwl_power_initialize(priv); 3770 iwl_power_initialize(priv);
3684 iwl_tt_initialize(priv); 3771 iwl_tt_initialize(priv);
3685 3772
3686 init_completion(&priv->_agn.firmware_loading_complete); 3773 init_completion(&priv->firmware_loading_complete);
3687 3774
3688 err = iwl_request_firmware(priv, true); 3775 err = iwl_request_firmware(priv, true);
3689 if (err) 3776 if (err)
@@ -3691,19 +3778,18 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3691 3778
3692 return 0; 3779 return 0;
3693 3780
3694 out_destroy_workqueue: 3781out_destroy_workqueue:
3695 destroy_workqueue(priv->workqueue); 3782 destroy_workqueue(priv->workqueue);
3696 priv->workqueue = NULL; 3783 priv->workqueue = NULL;
3697 free_irq(priv->bus.irq, priv);
3698 iwl_free_isr_ict(priv);
3699 out_uninit_drv:
3700 iwl_uninit_drv(priv); 3784 iwl_uninit_drv(priv);
3701 out_free_eeprom: 3785out_free_eeprom:
3702 iwl_eeprom_free(priv); 3786 iwl_eeprom_free(priv);
3703 out_free_traffic_mem: 3787out_free_trans:
3788 trans_free(&priv->trans);
3789out_free_traffic_mem:
3704 iwl_free_traffic_mem(priv); 3790 iwl_free_traffic_mem(priv);
3705 ieee80211_free_hw(priv->hw); 3791 ieee80211_free_hw(priv->hw);
3706 out: 3792out:
3707 return err; 3793 return err;
3708} 3794}
3709 3795
@@ -3711,12 +3797,12 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3711{ 3797{
3712 unsigned long flags; 3798 unsigned long flags;
3713 3799
3714 wait_for_completion(&priv->_agn.firmware_loading_complete); 3800 wait_for_completion(&priv->firmware_loading_complete);
3715 3801
3716 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); 3802 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
3717 3803
3718 iwl_dbgfs_unregister(priv); 3804 iwl_dbgfs_unregister(priv);
3719 sysfs_remove_group(&priv->bus.dev->kobj, 3805 sysfs_remove_group(&priv->bus->dev->kobj,
3720 &iwl_attribute_group); 3806 &iwl_attribute_group);
3721 3807
3722 /* ieee80211_unregister_hw call wil cause iwl_mac_stop to 3808 /* ieee80211_unregister_hw call wil cause iwl_mac_stop to
@@ -3745,16 +3831,15 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3745 iwl_disable_interrupts(priv); 3831 iwl_disable_interrupts(priv);
3746 spin_unlock_irqrestore(&priv->lock, flags); 3832 spin_unlock_irqrestore(&priv->lock, flags);
3747 3833
3748 iwl_synchronize_irq(priv); 3834 trans_sync_irq(&priv->trans);
3749 3835
3750 iwl_dealloc_ucode(priv); 3836 iwl_dealloc_ucode(priv);
3751 3837
3752 trans_rx_free(priv); 3838 trans_rx_free(&priv->trans);
3753 trans_tx_free(priv); 3839 trans_tx_free(&priv->trans);
3754 3840
3755 iwl_eeprom_free(priv); 3841 iwl_eeprom_free(priv);
3756 3842
3757
3758 /*netif_stop_queue(dev); */ 3843 /*netif_stop_queue(dev); */
3759 flush_workqueue(priv->workqueue); 3844 flush_workqueue(priv->workqueue);
3760 3845
@@ -3765,12 +3850,11 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3765 priv->workqueue = NULL; 3850 priv->workqueue = NULL;
3766 iwl_free_traffic_mem(priv); 3851 iwl_free_traffic_mem(priv);
3767 3852
3768 free_irq(priv->bus.irq, priv); 3853 trans_free(&priv->trans);
3769 priv->bus.ops->set_drv_data(&priv->bus, NULL);
3770 3854
3771 iwl_uninit_drv(priv); 3855 bus_set_drv_data(priv->bus, NULL);
3772 3856
3773 iwl_free_isr_ict(priv); 3857 iwl_uninit_drv(priv);
3774 3858
3775 dev_kfree_skb(priv->beacon_skb); 3859 dev_kfree_skb(priv->beacon_skb);
3776 3860
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 5f58b44bb2a0..d941c4c98e4b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -113,18 +113,6 @@ extern struct iwl_mod_params iwlagn_mod_params;
113extern struct ieee80211_ops iwlagn_hw_ops; 113extern struct ieee80211_ops iwlagn_hw_ops;
114 114
115int iwl_reset_ict(struct iwl_priv *priv); 115int iwl_reset_ict(struct iwl_priv *priv);
116void iwl_disable_ict(struct iwl_priv *priv);
117int iwl_alloc_isr_ict(struct iwl_priv *priv);
118void iwl_free_isr_ict(struct iwl_priv *priv);
119irqreturn_t iwl_isr_ict(int irq, void *data);
120
121/* call this function to flush any scheduled tasklet */
122static inline void iwl_synchronize_irq(struct iwl_priv *priv)
123{
124 /* wait to make sure we flush pending tasklet*/
125 synchronize_irq(priv->bus.irq);
126 tasklet_kill(&priv->irq_tasklet);
127}
128 116
129static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) 117static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd)
130{ 118{
@@ -134,22 +122,12 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd)
134 hdr->data_valid = 1; 122 hdr->data_valid = 1;
135} 123}
136 124
137int iwl_prepare_card_hw(struct iwl_priv *priv);
138
139int iwlagn_start_device(struct iwl_priv *priv);
140void iwlagn_stop_device(struct iwl_priv *priv);
141
142/* tx queue */ 125/* tx queue */
143void iwlagn_set_wr_ptrs(struct iwl_priv *priv,
144 int txq_id, u32 index);
145void iwlagn_tx_queue_set_status(struct iwl_priv *priv,
146 struct iwl_tx_queue *txq,
147 int tx_fifo_id, int scd_retry);
148void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask);
149void iwl_free_tfds_in_queue(struct iwl_priv *priv, 126void iwl_free_tfds_in_queue(struct iwl_priv *priv,
150 int sta_id, int tid, int freed); 127 int sta_id, int tid, int freed);
151 128
152/* RXON */ 129/* RXON */
130int iwlagn_set_pan_params(struct iwl_priv *priv);
153int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 131int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
154void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 132void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
155int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed); 133int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed);
@@ -171,32 +149,24 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv,
171/* lib */ 149/* lib */
172void iwl_check_abort_status(struct iwl_priv *priv, 150void iwl_check_abort_status(struct iwl_priv *priv,
173 u8 frame_count, u32 status); 151 u8 frame_count, u32 status);
174void iwlagn_rx_handler_setup(struct iwl_priv *priv);
175void iwlagn_setup_deferred_work(struct iwl_priv *priv);
176int iwlagn_hw_valid_rtc_data_addr(u32 addr); 152int iwlagn_hw_valid_rtc_data_addr(u32 addr);
177int iwlagn_send_tx_power(struct iwl_priv *priv); 153int iwlagn_send_tx_power(struct iwl_priv *priv);
178void iwlagn_temperature(struct iwl_priv *priv); 154void iwlagn_temperature(struct iwl_priv *priv);
179u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); 155u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv);
180int iwlagn_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
181int iwlagn_hw_nic_init(struct iwl_priv *priv);
182int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv); 156int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv);
183int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); 157int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control);
184void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); 158void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control);
159int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
185 160
186/* rx */ 161/* rx */
187void iwlagn_rx_queue_restock(struct iwl_priv *priv);
188void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority);
189void iwlagn_rx_replenish(struct iwl_priv *priv);
190void iwlagn_rx_replenish_now(struct iwl_priv *priv);
191int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); 162int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
192void iwl_setup_rx_handlers(struct iwl_priv *priv); 163void iwl_setup_rx_handlers(struct iwl_priv *priv);
164void iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
165
193 166
194/* tx */ 167/* tx */
195void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq, 168void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq,
196 int index); 169 int index);
197int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv,
198 struct iwl_tx_queue *txq,
199 dma_addr_t addr, u16 len, u8 reset);
200void iwlagn_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, 170void iwlagn_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
201 struct ieee80211_tx_info *info); 171 struct ieee80211_tx_info *info);
202int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); 172int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb);
@@ -204,13 +174,11 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
204 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 174 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
205int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, 175int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
206 struct ieee80211_sta *sta, u16 tid); 176 struct ieee80211_sta *sta, u16 tid);
207void iwlagn_txq_agg_queue_setup(struct iwl_priv *priv,
208 struct ieee80211_sta *sta,
209 int tid, int frame_limit);
210int iwlagn_txq_check_empty(struct iwl_priv *priv, 177int iwlagn_txq_check_empty(struct iwl_priv *priv,
211 int sta_id, u8 tid, int txq_id); 178 int sta_id, u8 tid, int txq_id);
212void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, 179void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
213 struct iwl_rx_mem_buffer *rxb); 180 struct iwl_rx_mem_buffer *rxb);
181void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
214int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); 182int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
215 183
216static inline u32 iwl_tx_status_to_mac80211(u32 status) 184static inline u32 iwl_tx_status_to_mac80211(u32 status)
@@ -246,17 +214,6 @@ void iwlagn_post_scan(struct iwl_priv *priv);
246int iwlagn_manage_ibss_station(struct iwl_priv *priv, 214int iwlagn_manage_ibss_station(struct iwl_priv *priv,
247 struct ieee80211_vif *vif, bool add); 215 struct ieee80211_vif *vif, bool add);
248 216
249/* hcmd */
250int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant);
251int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
252int iwlagn_set_pan_params(struct iwl_priv *priv);
253void iwlagn_gain_computation(struct iwl_priv *priv,
254 u32 average_noise[NUM_RX_CHAINS],
255 u16 min_average_noise_antenna_i,
256 u32 min_average_noise,
257 u8 default_chain);
258
259
260/* bt coex */ 217/* bt coex */
261void iwlagn_send_advance_bt_config(struct iwl_priv *priv); 218void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
262void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, 219void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
@@ -289,11 +246,13 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
289int iwl_restore_default_wep_keys(struct iwl_priv *priv, 246int iwl_restore_default_wep_keys(struct iwl_priv *priv,
290 struct iwl_rxon_context *ctx); 247 struct iwl_rxon_context *ctx);
291int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 248int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
292 struct ieee80211_key_conf *key, u8 sta_id); 249 struct ieee80211_key_conf *key,
250 struct ieee80211_sta *sta);
293int iwl_remove_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 251int iwl_remove_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
294 struct ieee80211_key_conf *key, u8 sta_id); 252 struct ieee80211_key_conf *key,
253 struct ieee80211_sta *sta);
295void iwl_update_tkip_key(struct iwl_priv *priv, 254void iwl_update_tkip_key(struct iwl_priv *priv,
296 struct iwl_rxon_context *ctx, 255 struct ieee80211_vif *vif,
297 struct ieee80211_key_conf *keyconf, 256 struct ieee80211_key_conf *keyconf,
298 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); 257 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
299int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid); 258int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid);
@@ -379,8 +338,4 @@ void iwl_testmode_cleanup(struct iwl_priv *priv)
379} 338}
380#endif 339#endif
381 340
382int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
383 struct iwl_cfg *cfg);
384void __devexit iwl_remove(struct iwl_priv * priv);
385
386#endif /* __iwl_agn_h__ */ 341#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.h b/drivers/net/wireless/iwlwifi/iwl-bus.h
index 9396c7c8d6a4..f3ee1c0c004c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.h
+++ b/drivers/net/wireless/iwlwifi/iwl-bus.h
@@ -63,6 +63,76 @@
63#ifndef __iwl_pci_h__ 63#ifndef __iwl_pci_h__
64#define __iwl_pci_h__ 64#define __iwl_pci_h__
65 65
66struct iwl_bus;
67
68/**
69 * struct iwl_bus_ops - bus specific operations
70 * @get_pm_support: must returns true if the bus can go to sleep
71 * @apm_config: will be called during the config of the APM configuration
72 * @set_drv_data: set the drv_data pointer to the bus layer
73 * @get_hw_id: prints the hw_id in the provided buffer
74 * @write8: write a byte to register at offset ofs
75 * @write32: write a dword to register at offset ofs
76 * @wread32: read a dword at register at offset ofs
77 */
78struct iwl_bus_ops {
79 bool (*get_pm_support)(struct iwl_bus *bus);
80 void (*apm_config)(struct iwl_bus *bus);
81 void (*set_drv_data)(struct iwl_bus *bus, void *drv_data);
82 void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len);
83 void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
84 void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
85 u32 (*read32)(struct iwl_bus *bus, u32 ofs);
86};
87
88struct iwl_bus {
89 /* Common data to all buses */
90 void *drv_data; /* driver's context */
91 struct device *dev;
92 struct iwl_bus_ops *ops;
93
94 unsigned int irq;
95
96 /* pointer to bus specific struct */
97 /*Ensure that this pointer will always be aligned to sizeof pointer */
98 char bus_specific[0] __attribute__((__aligned__(sizeof(void *))));
99};
100
101static inline bool bus_get_pm_support(struct iwl_bus *bus)
102{
103 return bus->ops->get_pm_support(bus);
104}
105
106static inline void bus_apm_config(struct iwl_bus *bus)
107{
108 bus->ops->apm_config(bus);
109}
110
111static inline void bus_set_drv_data(struct iwl_bus *bus, void *drv_data)
112{
113 bus->ops->set_drv_data(bus, drv_data);
114}
115
116static inline void bus_get_hw_id(struct iwl_bus *bus, char buf[], int buf_len)
117{
118 bus->ops->get_hw_id(bus, buf, buf_len);
119}
120
121static inline void bus_write8(struct iwl_bus *bus, u32 ofs, u8 val)
122{
123 bus->ops->write8(bus, ofs, val);
124}
125
126static inline void bus_write32(struct iwl_bus *bus, u32 ofs, u32 val)
127{
128 bus->ops->write32(bus, ofs, val);
129}
130
131static inline u32 bus_read32(struct iwl_bus *bus, u32 ofs)
132{
133 return bus->ops->read32(bus, ofs);
134}
135
66int __must_check iwl_pci_register_driver(void); 136int __must_check iwl_pci_register_driver(void);
67void iwl_pci_unregister_driver(void); 137void iwl_pci_unregister_driver(void);
68 138
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index ee2563777e8d..5769ca5cebca 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -188,6 +188,13 @@ enum {
188 REPLY_WIPAN_NOA_NOTIFICATION = 0xbc, 188 REPLY_WIPAN_NOA_NOTIFICATION = 0xbc,
189 REPLY_WIPAN_DEACTIVATION_COMPLETE = 0xbd, 189 REPLY_WIPAN_DEACTIVATION_COMPLETE = 0xbd,
190 190
191 REPLY_WOWLAN_PATTERNS = 0xe0,
192 REPLY_WOWLAN_WAKEUP_FILTER = 0xe1,
193 REPLY_WOWLAN_TSC_RSC_PARAMS = 0xe2,
194 REPLY_WOWLAN_TKIP_PARAMS = 0xe3,
195 REPLY_WOWLAN_KEK_KCK_MATERIAL = 0xe4,
196 REPLY_WOWLAN_GET_STATUS = 0xe5,
197
191 REPLY_MAX = 0xff 198 REPLY_MAX = 0xff
192}; 199};
193 200
@@ -832,6 +839,8 @@ struct iwl_qosparam_cmd {
832#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000) 839#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
833#define STA_KEY_MAX_NUM 8 840#define STA_KEY_MAX_NUM 8
834#define STA_KEY_MAX_NUM_PAN 16 841#define STA_KEY_MAX_NUM_PAN 16
842/* must not match WEP_INVALID_OFFSET */
843#define IWLAGN_HW_KEY_DEFAULT 0xfe
835 844
836/* Flags indicate whether to modify vs. don't change various station params */ 845/* Flags indicate whether to modify vs. don't change various station params */
837#define STA_MODIFY_KEY_MASK 0x01 846#define STA_MODIFY_KEY_MASK 0x01
@@ -3155,7 +3164,6 @@ struct iwl_enhance_sensitivity_cmd {
3155/* The default calibrate table size if not specified by firmware */ 3164/* The default calibrate table size if not specified by firmware */
3156#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 3165#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18
3157enum { 3166enum {
3158 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3159 IWL_PHY_CALIBRATE_DC_CMD = 8, 3167 IWL_PHY_CALIBRATE_DC_CMD = 8,
3160 IWL_PHY_CALIBRATE_LO_CMD = 9, 3168 IWL_PHY_CALIBRATE_LO_CMD = 9,
3161 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11, 3169 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
@@ -3168,22 +3176,36 @@ enum {
3168 3176
3169#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253) 3177#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
3170 3178
3171#define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
3172
3173/* This enum defines the bitmap of various calibrations to enable in both 3179/* This enum defines the bitmap of various calibrations to enable in both
3174 * init ucode and runtime ucode through CALIBRATION_CFG_CMD. 3180 * init ucode and runtime ucode through CALIBRATION_CFG_CMD.
3175 */ 3181 */
3176enum iwl_ucode_calib_cfg { 3182enum iwl_ucode_calib_cfg {
3177 IWL_CALIB_CFG_RX_BB_IDX, 3183 IWL_CALIB_CFG_RX_BB_IDX = BIT(0),
3178 IWL_CALIB_CFG_DC_IDX, 3184 IWL_CALIB_CFG_DC_IDX = BIT(1),
3179 IWL_CALIB_CFG_TX_IQ_IDX, 3185 IWL_CALIB_CFG_LO_IDX = BIT(2),
3180 IWL_CALIB_CFG_RX_IQ_IDX, 3186 IWL_CALIB_CFG_TX_IQ_IDX = BIT(3),
3181 IWL_CALIB_CFG_NOISE_IDX, 3187 IWL_CALIB_CFG_RX_IQ_IDX = BIT(4),
3182 IWL_CALIB_CFG_CRYSTAL_IDX, 3188 IWL_CALIB_CFG_NOISE_IDX = BIT(5),
3183 IWL_CALIB_CFG_TEMPERATURE_IDX, 3189 IWL_CALIB_CFG_CRYSTAL_IDX = BIT(6),
3184 IWL_CALIB_CFG_PAPD_IDX, 3190 IWL_CALIB_CFG_TEMPERATURE_IDX = BIT(7),
3191 IWL_CALIB_CFG_PAPD_IDX = BIT(8),
3192 IWL_CALIB_CFG_SENSITIVITY_IDX = BIT(9),
3193 IWL_CALIB_CFG_TX_PWR_IDX = BIT(10),
3185}; 3194};
3186 3195
3196#define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(IWL_CALIB_CFG_RX_BB_IDX | \
3197 IWL_CALIB_CFG_DC_IDX | \
3198 IWL_CALIB_CFG_LO_IDX | \
3199 IWL_CALIB_CFG_TX_IQ_IDX | \
3200 IWL_CALIB_CFG_RX_IQ_IDX | \
3201 IWL_CALIB_CFG_NOISE_IDX | \
3202 IWL_CALIB_CFG_CRYSTAL_IDX | \
3203 IWL_CALIB_CFG_TEMPERATURE_IDX | \
3204 IWL_CALIB_CFG_PAPD_IDX | \
3205 IWL_CALIB_CFG_SENSITIVITY_IDX | \
3206 IWL_CALIB_CFG_TX_PWR_IDX)
3207
3208#define IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK cpu_to_le32(BIT(0))
3187 3209
3188struct iwl_calib_cfg_elmnt_s { 3210struct iwl_calib_cfg_elmnt_s {
3189 __le32 is_enable; 3211 __le32 is_enable;
@@ -3217,15 +3239,6 @@ struct iwl_calib_cmd {
3217 u8 data[0]; 3239 u8 data[0];
3218} __packed; 3240} __packed;
3219 3241
3220/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
3221struct iwl_calib_diff_gain_cmd {
3222 struct iwl_calib_hdr hdr;
3223 s8 diff_gain_a; /* see above */
3224 s8 diff_gain_b;
3225 s8 diff_gain_c;
3226 u8 reserved1;
3227} __packed;
3228
3229struct iwl_calib_xtal_freq_cmd { 3242struct iwl_calib_xtal_freq_cmd {
3230 struct iwl_calib_hdr hdr; 3243 struct iwl_calib_hdr hdr;
3231 u8 cap_pin1; 3244 u8 cap_pin1;
@@ -3233,11 +3246,11 @@ struct iwl_calib_xtal_freq_cmd {
3233 u8 pad[2]; 3246 u8 pad[2];
3234} __packed; 3247} __packed;
3235 3248
3236#define DEFAULT_RADIO_SENSOR_OFFSET 2700 3249#define DEFAULT_RADIO_SENSOR_OFFSET cpu_to_le16(2700)
3237struct iwl_calib_temperature_offset_cmd { 3250struct iwl_calib_temperature_offset_cmd {
3238 struct iwl_calib_hdr hdr; 3251 struct iwl_calib_hdr hdr;
3239 s16 radio_sensor_offset; 3252 __le16 radio_sensor_offset;
3240 s16 reserved; 3253 __le16 reserved;
3241} __packed; 3254} __packed;
3242 3255
3243/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */ 3256/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
@@ -3758,6 +3771,127 @@ struct iwl_bt_coex_prot_env_cmd {
3758 u8 reserved[2]; 3771 u8 reserved[2];
3759} __attribute__((packed)); 3772} __attribute__((packed));
3760 3773
3774/*
3775 * REPLY_WOWLAN_PATTERNS
3776 */
3777#define IWLAGN_WOWLAN_MIN_PATTERN_LEN 16
3778#define IWLAGN_WOWLAN_MAX_PATTERN_LEN 128
3779
3780struct iwlagn_wowlan_pattern {
3781 u8 mask[IWLAGN_WOWLAN_MAX_PATTERN_LEN / 8];
3782 u8 pattern[IWLAGN_WOWLAN_MAX_PATTERN_LEN];
3783 u8 mask_size;
3784 u8 pattern_size;
3785 __le16 reserved;
3786} __packed;
3787
3788#define IWLAGN_WOWLAN_MAX_PATTERNS 20
3789
3790struct iwlagn_wowlan_patterns_cmd {
3791 __le32 n_patterns;
3792 struct iwlagn_wowlan_pattern patterns[];
3793} __packed;
3794
3795/*
3796 * REPLY_WOWLAN_WAKEUP_FILTER
3797 */
3798enum iwlagn_wowlan_wakeup_filters {
3799 IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET = BIT(0),
3800 IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH = BIT(1),
3801 IWLAGN_WOWLAN_WAKEUP_BEACON_MISS = BIT(2),
3802 IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE = BIT(3),
3803 IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL = BIT(4),
3804 IWLAGN_WOWLAN_WAKEUP_RFKILL = BIT(5),
3805 IWLAGN_WOWLAN_WAKEUP_UCODE_ERROR = BIT(6),
3806 IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(7),
3807 IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(8),
3808 IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(9),
3809 IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(10),
3810};
3811
3812struct iwlagn_wowlan_wakeup_filter_cmd {
3813 __le32 enabled;
3814 __le16 non_qos_seq;
3815 u8 min_sleep_seconds;
3816 u8 reserved;
3817 __le16 qos_seq[8];
3818};
3819
3820/*
3821 * REPLY_WOWLAN_TSC_RSC_PARAMS
3822 */
3823#define IWLAGN_NUM_RSC 16
3824
3825struct tkip_sc {
3826 __le16 iv16;
3827 __le16 pad;
3828 __le32 iv32;
3829} __packed;
3830
3831struct iwlagn_tkip_rsc_tsc {
3832 struct tkip_sc unicast_rsc[IWLAGN_NUM_RSC];
3833 struct tkip_sc multicast_rsc[IWLAGN_NUM_RSC];
3834 struct tkip_sc tsc;
3835} __packed;
3836
3837struct aes_sc {
3838 __le64 pn;
3839} __packed;
3840
3841struct iwlagn_aes_rsc_tsc {
3842 struct aes_sc unicast_rsc[IWLAGN_NUM_RSC];
3843 struct aes_sc multicast_rsc[IWLAGN_NUM_RSC];
3844 struct aes_sc tsc;
3845} __packed;
3846
3847union iwlagn_all_tsc_rsc {
3848 struct iwlagn_tkip_rsc_tsc tkip;
3849 struct iwlagn_aes_rsc_tsc aes;
3850};
3851
3852struct iwlagn_wowlan_rsc_tsc_params_cmd {
3853 union iwlagn_all_tsc_rsc all_tsc_rsc;
3854} __packed;
3855
3856/*
3857 * REPLY_WOWLAN_TKIP_PARAMS
3858 */
3859#define IWLAGN_MIC_KEY_SIZE 8
3860#define IWLAGN_P1K_SIZE 5
3861struct iwlagn_mic_keys {
3862 u8 tx[IWLAGN_MIC_KEY_SIZE];
3863 u8 rx_unicast[IWLAGN_MIC_KEY_SIZE];
3864 u8 rx_mcast[IWLAGN_MIC_KEY_SIZE];
3865} __packed;
3866
3867struct iwlagn_p1k_cache {
3868 __le16 p1k[IWLAGN_P1K_SIZE];
3869} __packed;
3870
3871#define IWLAGN_NUM_RX_P1K_CACHE 2
3872
3873struct iwlagn_wowlan_tkip_params_cmd {
3874 struct iwlagn_mic_keys mic_keys;
3875 struct iwlagn_p1k_cache tx;
3876 struct iwlagn_p1k_cache rx_uni[IWLAGN_NUM_RX_P1K_CACHE];
3877 struct iwlagn_p1k_cache rx_multi[IWLAGN_NUM_RX_P1K_CACHE];
3878} __packed;
3879
3880/*
3881 * REPLY_WOWLAN_KEK_KCK_MATERIAL
3882 */
3883
3884#define IWLAGN_KCK_MAX_SIZE 32
3885#define IWLAGN_KEK_MAX_SIZE 32
3886
3887struct iwlagn_wowlan_kek_kck_material_cmd {
3888 u8 kck[IWLAGN_KCK_MAX_SIZE];
3889 u8 kek[IWLAGN_KEK_MAX_SIZE];
3890 __le16 kck_len;
3891 __le16 kek_len;
3892 __le64 replay_ctr;
3893} __packed;
3894
3761/****************************************************************************** 3895/******************************************************************************
3762 * (13) 3896 * (13)
3763 * Union of all expected notifications/responses: 3897 * Union of all expected notifications/responses:
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index fa3d5bacbde2..cf376f62b2f6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -211,7 +211,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
211 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && 211 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
212 priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) { 212 priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) {
213 char buf[32]; 213 char buf[32];
214 priv->bus.ops->get_hw_id(&priv->bus, buf, sizeof(buf)); 214 bus_get_hw_id(priv->bus, buf, sizeof(buf));
215 IWL_INFO(priv, "Incorrectly detected BG card as ABG. " 215 IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
216 "Please send your %s to maintainer.\n", buf); 216 "Please send your %s to maintainer.\n", buf);
217 priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; 217 priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ;
@@ -363,6 +363,8 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
363 ctx->timing.beacon_interval = cpu_to_le16(beacon_int); 363 ctx->timing.beacon_interval = cpu_to_le16(beacon_int);
364 } 364 }
365 365
366 ctx->beacon_int = beacon_int;
367
366 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ 368 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
367 interval_tm = beacon_int * TIME_UNIT; 369 interval_tm = beacon_int * TIME_UNIT;
368 rem = do_div(tsf, interval_tm); 370 rem = do_div(tsf, interval_tm);
@@ -376,7 +378,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
376 le32_to_cpu(ctx->timing.beacon_init_val), 378 le32_to_cpu(ctx->timing.beacon_init_val),
377 le16_to_cpu(ctx->timing.atim_window)); 379 le16_to_cpu(ctx->timing.atim_window));
378 380
379 return trans_send_cmd_pdu(priv, ctx->rxon_timing_cmd, 381 return trans_send_cmd_pdu(&priv->trans, ctx->rxon_timing_cmd,
380 CMD_SYNC, sizeof(ctx->timing), &ctx->timing); 382 CMD_SYNC, sizeof(ctx->timing), &ctx->timing);
381} 383}
382 384
@@ -840,12 +842,12 @@ static void iwlagn_abort_notification_waits(struct iwl_priv *priv)
840 unsigned long flags; 842 unsigned long flags;
841 struct iwl_notification_wait *wait_entry; 843 struct iwl_notification_wait *wait_entry;
842 844
843 spin_lock_irqsave(&priv->_agn.notif_wait_lock, flags); 845 spin_lock_irqsave(&priv->notif_wait_lock, flags);
844 list_for_each_entry(wait_entry, &priv->_agn.notif_waits, list) 846 list_for_each_entry(wait_entry, &priv->notif_waits, list)
845 wait_entry->aborted = true; 847 wait_entry->aborted = true;
846 spin_unlock_irqrestore(&priv->_agn.notif_wait_lock, flags); 848 spin_unlock_irqrestore(&priv->notif_wait_lock, flags);
847 849
848 wake_up_all(&priv->_agn.notif_waitq); 850 wake_up_all(&priv->notif_waitq);
849} 851}
850 852
851void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) 853void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
@@ -1012,7 +1014,7 @@ int iwl_apm_init(struct iwl_priv *priv)
1012 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1014 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1013 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); 1015 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
1014 1016
1015 priv->bus.ops->apm_config(&priv->bus); 1017 bus_apm_config(priv->bus);
1016 1018
1017 /* Configure analog phase-lock-loop before activating to D0A */ 1019 /* Configure analog phase-lock-loop before activating to D0A */
1018 if (priv->cfg->base_params->pll_cfg_val) 1020 if (priv->cfg->base_params->pll_cfg_val)
@@ -1132,7 +1134,7 @@ void iwl_send_bt_config(struct iwl_priv *priv)
1132 IWL_DEBUG_INFO(priv, "BT coex %s\n", 1134 IWL_DEBUG_INFO(priv, "BT coex %s\n",
1133 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); 1135 (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active");
1134 1136
1135 if (trans_send_cmd_pdu(priv, REPLY_BT_CONFIG, 1137 if (trans_send_cmd_pdu(&priv->trans, REPLY_BT_CONFIG,
1136 CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd)) 1138 CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd))
1137 IWL_ERR(priv, "failed to send BT Coex Config\n"); 1139 IWL_ERR(priv, "failed to send BT Coex Config\n");
1138} 1140}
@@ -1145,12 +1147,12 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
1145 }; 1147 };
1146 1148
1147 if (flags & CMD_ASYNC) 1149 if (flags & CMD_ASYNC)
1148 return trans_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, 1150 return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD,
1149 CMD_ASYNC, 1151 CMD_ASYNC,
1150 sizeof(struct iwl_statistics_cmd), 1152 sizeof(struct iwl_statistics_cmd),
1151 &statistics_cmd); 1153 &statistics_cmd);
1152 else 1154 else
1153 return trans_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, 1155 return trans_send_cmd_pdu(&priv->trans, REPLY_STATISTICS_CMD,
1154 CMD_SYNC, 1156 CMD_SYNC,
1155 sizeof(struct iwl_statistics_cmd), 1157 sizeof(struct iwl_statistics_cmd),
1156 &statistics_cmd); 1158 &statistics_cmd);
@@ -1903,8 +1905,12 @@ int iwl_suspend(struct iwl_priv *priv)
1903 * first but since iwl_mac_stop() has no knowledge of who the caller is, 1905 * first but since iwl_mac_stop() has no knowledge of who the caller is,
1904 * it will not call apm_ops.stop() to stop the DMA operation. 1906 * it will not call apm_ops.stop() to stop the DMA operation.
1905 * Calling apm_ops.stop here to make sure we stop the DMA. 1907 * Calling apm_ops.stop here to make sure we stop the DMA.
1908 *
1909 * But of course ... if we have configured WoWLAN then we did other
1910 * things already :-)
1906 */ 1911 */
1907 iwl_apm_stop(priv); 1912 if (!priv->wowlan)
1913 iwl_apm_stop(priv);
1908 1914
1909 return 0; 1915 return 0;
1910} 1916}
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 692c30cb2fac..3e6bb734dcb7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -83,14 +83,12 @@ struct iwl_cmd;
83struct iwl_lib_ops { 83struct iwl_lib_ops {
84 /* set hw dependent parameters */ 84 /* set hw dependent parameters */
85 int (*set_hw_params)(struct iwl_priv *priv); 85 int (*set_hw_params)(struct iwl_priv *priv);
86 /* setup Rx handler */ 86 /* setup BT Rx handler */
87 void (*rx_handler_setup)(struct iwl_priv *priv); 87 void (*bt_rx_handler_setup)(struct iwl_priv *priv);
88 /* setup deferred work */ 88 /* setup BT related deferred work */
89 void (*setup_deferred_work)(struct iwl_priv *priv); 89 void (*bt_setup_deferred_work)(struct iwl_priv *priv);
90 /* cancel deferred work */ 90 /* cancel deferred work */
91 void (*cancel_deferred_work)(struct iwl_priv *priv); 91 void (*cancel_deferred_work)(struct iwl_priv *priv);
92 /* check validity of rtc data address */
93 int (*is_valid_rtc_data_addr)(u32 addr);
94 int (*set_channel_switch)(struct iwl_priv *priv, 92 int (*set_channel_switch)(struct iwl_priv *priv,
95 struct ieee80211_channel_switch *ch_switch); 93 struct ieee80211_channel_switch *ch_switch);
96 /* device specific configuration */ 94 /* device specific configuration */
@@ -103,16 +101,6 @@ struct iwl_lib_ops {
103 void (*temperature)(struct iwl_priv *priv); 101 void (*temperature)(struct iwl_priv *priv);
104}; 102};
105 103
106/* NIC specific ops */
107struct iwl_nic_ops {
108 void (*additional_nic_config)(struct iwl_priv *priv);
109};
110
111struct iwl_ops {
112 const struct iwl_lib_ops *lib;
113 const struct iwl_nic_ops *nic;
114};
115
116struct iwl_mod_params { 104struct iwl_mod_params {
117 int sw_crypto; /* def: 0 = using hardware encryption */ 105 int sw_crypto; /* def: 0 = using hardware encryption */
118 int num_of_queues; /* def: HW dependent */ 106 int num_of_queues; /* def: HW dependent */
@@ -199,11 +187,22 @@ struct iwl_ht_params {
199 187
200/** 188/**
201 * struct iwl_cfg 189 * struct iwl_cfg
190 * @name: Offical name of the device
202 * @fw_name_pre: Firmware filename prefix. The api version and extension 191 * @fw_name_pre: Firmware filename prefix. The api version and extension
203 * (.ucode) will be added to filename before loading from disk. The 192 * (.ucode) will be added to filename before loading from disk. The
204 * filename is constructed as fw_name_pre<api>.ucode. 193 * filename is constructed as fw_name_pre<api>.ucode.
205 * @ucode_api_max: Highest version of uCode API supported by driver. 194 * @ucode_api_max: Highest version of uCode API supported by driver.
206 * @ucode_api_min: Lowest version of uCode API supported by driver. 195 * @ucode_api_min: Lowest version of uCode API supported by driver.
196 * @valid_tx_ant: valid transmit antenna
197 * @valid_rx_ant: valid receive antenna
198 * @sku: sku information from EEPROM
199 * @eeprom_ver: EEPROM version
200 * @eeprom_calib_ver: EEPROM calibration version
201 * @lib: pointer to the lib ops
202 * @additional_nic_config: additional nic configuration
203 * @base_params: pointer to basic parameters
204 * @ht_params: point to ht patameters
205 * @bt_params: pointer to bt parameters
207 * @pa_type: used by 6000 series only to identify the type of Power Amplifier 206 * @pa_type: used by 6000 series only to identify the type of Power Amplifier
208 * @need_dc_calib: need to perform init dc calibration 207 * @need_dc_calib: need to perform init dc calibration
209 * @need_temp_offset_calib: need to perform temperature offset calibration 208 * @need_temp_offset_calib: need to perform temperature offset calibration
@@ -213,7 +212,6 @@ struct iwl_ht_params {
213 * @rx_with_siso_diversity: 1x1 device with rx antenna diversity 212 * @rx_with_siso_diversity: 1x1 device with rx antenna diversity
214 * @internal_wimax_coex: internal wifi/wimax combo device 213 * @internal_wimax_coex: internal wifi/wimax combo device
215 * @iq_invert: I/Q inversion 214 * @iq_invert: I/Q inversion
216 * @disable_otp_refresh: disable OTP refresh current limit
217 * 215 *
218 * We enable the driver to be backward compatible wrt API version. The 216 * We enable the driver to be backward compatible wrt API version. The
219 * driver specifies which APIs it supports (with @ucode_api_max being the 217 * driver specifies which APIs it supports (with @ucode_api_max being the
@@ -230,11 +228,7 @@ struct iwl_ht_params {
230 * } 228 * }
231 * 229 *
232 * The ideal usage of this infrastructure is to treat a new ucode API 230 * The ideal usage of this infrastructure is to treat a new ucode API
233 * release as a new hardware revision. That is, through utilizing the 231 * release as a new hardware revision.
234 * iwl_hcmd_utils_ops etc. we accommodate different command structures
235 * and flows between hardware versions (4965/5000) as well as their API
236 * versions.
237 *
238 */ 232 */
239struct iwl_cfg { 233struct iwl_cfg {
240 /* params specific to an individual device within a device family */ 234 /* params specific to an individual device within a device family */
@@ -247,7 +241,8 @@ struct iwl_cfg {
247 u16 sku; 241 u16 sku;
248 u16 eeprom_ver; 242 u16 eeprom_ver;
249 u16 eeprom_calib_ver; 243 u16 eeprom_calib_ver;
250 const struct iwl_ops *ops; 244 const struct iwl_lib_ops *lib;
245 void (*additional_nic_config)(struct iwl_priv *priv);
251 /* params not likely to change within a device family */ 246 /* params not likely to change within a device family */
252 struct iwl_base_params *base_params; 247 struct iwl_base_params *base_params;
253 /* params likely to change within a device family */ 248 /* params likely to change within a device family */
@@ -262,7 +257,6 @@ struct iwl_cfg {
262 const bool rx_with_siso_diversity; 257 const bool rx_with_siso_diversity;
263 const bool internal_wimax_coex; 258 const bool internal_wimax_coex;
264 const bool iq_invert; 259 const bool iq_invert;
265 const bool disable_otp_refresh;
266}; 260};
267 261
268/*************************** 262/***************************
@@ -340,21 +334,8 @@ static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
340/***************************************************** 334/*****************************************************
341* RX 335* RX
342******************************************************/ 336******************************************************/
343void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
344 struct iwl_rx_queue *q);
345int iwl_rx_queue_space(const struct iwl_rx_queue *q);
346void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
347
348void iwl_chswitch_done(struct iwl_priv *priv, bool is_success); 337void iwl_chswitch_done(struct iwl_priv *priv, bool is_success);
349 338
350/* TX helpers */
351
352/*****************************************************
353* TX
354******************************************************/
355void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
356int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
357 int count, int slots_num, u32 id);
358void iwl_setup_watchdog(struct iwl_priv *priv); 339void iwl_setup_watchdog(struct iwl_priv *priv);
359/***************************************************** 340/*****************************************************
360 * TX power 341 * TX power
@@ -405,12 +386,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
405 *****************************************************/ 386 *****************************************************/
406 387
407const char *get_cmd_string(u8 cmd); 388const char *get_cmd_string(u8 cmd);
408int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
409int __must_check iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags,
410 u16 len, const void *data);
411
412int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
413
414void iwl_bg_watchdog(unsigned long data); 389void iwl_bg_watchdog(unsigned long data);
415u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval); 390u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval);
416__le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, 391__le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
@@ -421,6 +396,9 @@ int iwl_suspend(struct iwl_priv *priv);
421int iwl_resume(struct iwl_priv *priv); 396int iwl_resume(struct iwl_priv *priv);
422#endif /* !CONFIG_PM */ 397#endif /* !CONFIG_PM */
423 398
399int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg);
400void __devexit iwl_remove(struct iwl_priv * priv);
401
424/***************************************************** 402/*****************************************************
425* Error Handling Debugging 403* Error Handling Debugging
426******************************************************/ 404******************************************************/
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 5ab90ba7a024..d6dbb0423045 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -351,6 +351,7 @@
351#define CSR_UCODE_SW_BIT_RFKILL (0x00000002) 351#define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
352#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004) 352#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
353#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008) 353#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
354#define CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE (0x00000020)
354 355
355/* GP Driver */ 356/* GP Driver */
356#define CSR_GP_DRIVER_REG_BIT_RADIO_SKU_MSK (0x00000003) 357#define CSR_GP_DRIVER_REG_BIT_RADIO_SKU_MSK (0x00000003)
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index eb95d1a37487..f9a407e40aff 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -32,10 +32,10 @@
32struct iwl_priv; 32struct iwl_priv;
33extern u32 iwl_debug_level; 33extern u32 iwl_debug_level;
34 34
35#define IWL_ERR(p, f, a...) dev_err(p->bus.ops->get_dev(&p->bus), f, ## a) 35#define IWL_ERR(p, f, a...) dev_err(p->bus->dev, f, ## a)
36#define IWL_WARN(p, f, a...) dev_warn(p->bus.ops->get_dev(&p->bus), f, ## a) 36#define IWL_WARN(p, f, a...) dev_warn(p->bus->dev, f, ## a)
37#define IWL_INFO(p, f, a...) dev_info(p->bus.ops->get_dev(&p->bus), f, ## a) 37#define IWL_INFO(p, f, a...) dev_info(p->bus->dev, f, ## a)
38#define IWL_CRIT(p, f, a...) dev_crit(p->bus.ops->get_dev(&p->bus), f, ## a) 38#define IWL_CRIT(p, f, a...) dev_crit(p->bus->dev, f, ## a)
39 39
40#define iwl_print_hex_error(priv, p, len) \ 40#define iwl_print_hex_error(priv, p, len) \
41do { \ 41do { \
@@ -78,8 +78,6 @@ static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
78#ifdef CONFIG_IWLWIFI_DEBUGFS 78#ifdef CONFIG_IWLWIFI_DEBUGFS
79int iwl_dbgfs_register(struct iwl_priv *priv, const char *name); 79int iwl_dbgfs_register(struct iwl_priv *priv, const char *name);
80void iwl_dbgfs_unregister(struct iwl_priv *priv); 80void iwl_dbgfs_unregister(struct iwl_priv *priv);
81extern int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
82 int bufsz);
83#else 81#else
84static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) 82static inline int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
85{ 83{
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 6f9ebae8ca06..ec1485b2d3fe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -322,6 +322,19 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
322 return count; 322 return count;
323} 323}
324 324
325static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
326 char __user *user_buf,
327 size_t count, loff_t *ppos)
328{
329 struct iwl_priv *priv = file->private_data;
330
331 if (!priv->wowlan_sram)
332 return -ENODATA;
333
334 return simple_read_from_buffer(user_buf, count, ppos,
335 priv->wowlan_sram,
336 priv->ucode_wowlan.data.len);
337}
325static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, 338static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
326 size_t count, loff_t *ppos) 339 size_t count, loff_t *ppos)
327{ 340{
@@ -856,6 +869,7 @@ static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
856} 869}
857 870
858DEBUGFS_READ_WRITE_FILE_OPS(sram); 871DEBUGFS_READ_WRITE_FILE_OPS(sram);
872DEBUGFS_READ_FILE_OPS(wowlan_sram);
859DEBUGFS_READ_WRITE_FILE_OPS(log_event); 873DEBUGFS_READ_WRITE_FILE_OPS(log_event);
860DEBUGFS_READ_FILE_OPS(nvm); 874DEBUGFS_READ_FILE_OPS(nvm);
861DEBUGFS_READ_FILE_OPS(stations); 875DEBUGFS_READ_FILE_OPS(stations);
@@ -1915,121 +1929,121 @@ static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1915 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n"); 1929 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1916 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n", 1930 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1917 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY), 1931 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
1918 priv->_agn.reply_tx_stats.pp_delay); 1932 priv->reply_tx_stats.pp_delay);
1919 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1933 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1920 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES), 1934 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
1921 priv->_agn.reply_tx_stats.pp_few_bytes); 1935 priv->reply_tx_stats.pp_few_bytes);
1922 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1936 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1923 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO), 1937 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
1924 priv->_agn.reply_tx_stats.pp_bt_prio); 1938 priv->reply_tx_stats.pp_bt_prio);
1925 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1939 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1926 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD), 1940 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
1927 priv->_agn.reply_tx_stats.pp_quiet_period); 1941 priv->reply_tx_stats.pp_quiet_period);
1928 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1942 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1929 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK), 1943 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
1930 priv->_agn.reply_tx_stats.pp_calc_ttak); 1944 priv->reply_tx_stats.pp_calc_ttak);
1931 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1945 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1932 iwl_get_tx_fail_reason( 1946 iwl_get_tx_fail_reason(
1933 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY), 1947 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
1934 priv->_agn.reply_tx_stats.int_crossed_retry); 1948 priv->reply_tx_stats.int_crossed_retry);
1935 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1949 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1936 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT), 1950 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
1937 priv->_agn.reply_tx_stats.short_limit); 1951 priv->reply_tx_stats.short_limit);
1938 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1952 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1939 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT), 1953 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
1940 priv->_agn.reply_tx_stats.long_limit); 1954 priv->reply_tx_stats.long_limit);
1941 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1955 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1942 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN), 1956 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
1943 priv->_agn.reply_tx_stats.fifo_underrun); 1957 priv->reply_tx_stats.fifo_underrun);
1944 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1958 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1945 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW), 1959 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
1946 priv->_agn.reply_tx_stats.drain_flow); 1960 priv->reply_tx_stats.drain_flow);
1947 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1961 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1948 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH), 1962 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
1949 priv->_agn.reply_tx_stats.rfkill_flush); 1963 priv->reply_tx_stats.rfkill_flush);
1950 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1964 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1951 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE), 1965 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
1952 priv->_agn.reply_tx_stats.life_expire); 1966 priv->reply_tx_stats.life_expire);
1953 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1967 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1954 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS), 1968 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
1955 priv->_agn.reply_tx_stats.dest_ps); 1969 priv->reply_tx_stats.dest_ps);
1956 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1970 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1957 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED), 1971 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
1958 priv->_agn.reply_tx_stats.host_abort); 1972 priv->reply_tx_stats.host_abort);
1959 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1973 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1960 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY), 1974 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
1961 priv->_agn.reply_tx_stats.pp_delay); 1975 priv->reply_tx_stats.pp_delay);
1962 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1976 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1963 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID), 1977 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
1964 priv->_agn.reply_tx_stats.sta_invalid); 1978 priv->reply_tx_stats.sta_invalid);
1965 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1979 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1966 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED), 1980 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
1967 priv->_agn.reply_tx_stats.frag_drop); 1981 priv->reply_tx_stats.frag_drop);
1968 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1982 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1969 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE), 1983 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
1970 priv->_agn.reply_tx_stats.tid_disable); 1984 priv->reply_tx_stats.tid_disable);
1971 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1985 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1972 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED), 1986 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
1973 priv->_agn.reply_tx_stats.fifo_flush); 1987 priv->reply_tx_stats.fifo_flush);
1974 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1988 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1975 iwl_get_tx_fail_reason( 1989 iwl_get_tx_fail_reason(
1976 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL), 1990 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
1977 priv->_agn.reply_tx_stats.insuff_cf_poll); 1991 priv->reply_tx_stats.insuff_cf_poll);
1978 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1992 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1979 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX), 1993 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
1980 priv->_agn.reply_tx_stats.fail_hw_drop); 1994 priv->reply_tx_stats.fail_hw_drop);
1981 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1995 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1982 iwl_get_tx_fail_reason( 1996 iwl_get_tx_fail_reason(
1983 TX_STATUS_FAIL_NO_BEACON_ON_RADAR), 1997 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
1984 priv->_agn.reply_tx_stats.sta_color_mismatch); 1998 priv->reply_tx_stats.sta_color_mismatch);
1985 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", 1999 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1986 priv->_agn.reply_tx_stats.unknown); 2000 priv->reply_tx_stats.unknown);
1987 2001
1988 pos += scnprintf(buf + pos, bufsz - pos, 2002 pos += scnprintf(buf + pos, bufsz - pos,
1989 "\nStatistics_Agg_TX_Error:\n"); 2003 "\nStatistics_Agg_TX_Error:\n");
1990 2004
1991 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2005 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1992 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK), 2006 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
1993 priv->_agn.reply_agg_tx_stats.underrun); 2007 priv->reply_agg_tx_stats.underrun);
1994 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2008 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1995 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK), 2009 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
1996 priv->_agn.reply_agg_tx_stats.bt_prio); 2010 priv->reply_agg_tx_stats.bt_prio);
1997 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2011 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1998 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK), 2012 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
1999 priv->_agn.reply_agg_tx_stats.few_bytes); 2013 priv->reply_agg_tx_stats.few_bytes);
2000 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2014 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
2001 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK), 2015 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
2002 priv->_agn.reply_agg_tx_stats.abort); 2016 priv->reply_agg_tx_stats.abort);
2003 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 2017 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
2004 iwl_get_agg_tx_fail_reason( 2018 iwl_get_agg_tx_fail_reason(
2005 AGG_TX_STATE_LAST_SENT_TTL_MSK), 2019 AGG_TX_STATE_LAST_SENT_TTL_MSK),
2006 priv->_agn.reply_agg_tx_stats.last_sent_ttl); 2020 priv->reply_agg_tx_stats.last_sent_ttl);
2007 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 2021 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
2008 iwl_get_agg_tx_fail_reason( 2022 iwl_get_agg_tx_fail_reason(
2009 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK), 2023 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
2010 priv->_agn.reply_agg_tx_stats.last_sent_try); 2024 priv->reply_agg_tx_stats.last_sent_try);
2011 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 2025 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
2012 iwl_get_agg_tx_fail_reason( 2026 iwl_get_agg_tx_fail_reason(
2013 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK), 2027 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
2014 priv->_agn.reply_agg_tx_stats.last_sent_bt_kill); 2028 priv->reply_agg_tx_stats.last_sent_bt_kill);
2015 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2029 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
2016 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK), 2030 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
2017 priv->_agn.reply_agg_tx_stats.scd_query); 2031 priv->reply_agg_tx_stats.scd_query);
2018 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 2032 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
2019 iwl_get_agg_tx_fail_reason( 2033 iwl_get_agg_tx_fail_reason(
2020 AGG_TX_STATE_TEST_BAD_CRC32_MSK), 2034 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
2021 priv->_agn.reply_agg_tx_stats.bad_crc32); 2035 priv->reply_agg_tx_stats.bad_crc32);
2022 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2036 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
2023 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK), 2037 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
2024 priv->_agn.reply_agg_tx_stats.response); 2038 priv->reply_agg_tx_stats.response);
2025 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2039 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
2026 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK), 2040 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
2027 priv->_agn.reply_agg_tx_stats.dump_tx); 2041 priv->reply_agg_tx_stats.dump_tx);
2028 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 2042 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
2029 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK), 2043 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
2030 priv->_agn.reply_agg_tx_stats.delay_tx); 2044 priv->reply_agg_tx_stats.delay_tx);
2031 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", 2045 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
2032 priv->_agn.reply_agg_tx_stats.unknown); 2046 priv->reply_agg_tx_stats.unknown);
2033 2047
2034 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2048 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2035 kfree(buf); 2049 kfree(buf);
@@ -2667,6 +2681,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2667 2681
2668 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); 2682 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2669 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); 2683 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
2684 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
2670 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR); 2685 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
2671 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); 2686 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2672 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); 2687 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 424c45c43f5b..6c9790cac8d0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -48,6 +48,8 @@
48#include "iwl-power.h" 48#include "iwl-power.h"
49#include "iwl-agn-rs.h" 49#include "iwl-agn-rs.h"
50#include "iwl-agn-tt.h" 50#include "iwl-agn-tt.h"
51#include "iwl-bus.h"
52#include "iwl-trans.h"
51 53
52#define DRV_NAME "iwlagn" 54#define DRV_NAME "iwlagn"
53 55
@@ -396,13 +398,6 @@ struct iwl_tid_data {
396 struct iwl_ht_agg agg; 398 struct iwl_ht_agg agg;
397}; 399};
398 400
399struct iwl_hw_key {
400 u32 cipher;
401 int keylen;
402 u8 keyidx;
403 u8 key[32];
404};
405
406union iwl_ht_rate_supp { 401union iwl_ht_rate_supp {
407 u16 rates; 402 u16 rates;
408 struct { 403 struct {
@@ -455,7 +450,6 @@ struct iwl_station_entry {
455 struct iwl_addsta_cmd sta; 450 struct iwl_addsta_cmd sta;
456 struct iwl_tid_data tid[MAX_TID_COUNT]; 451 struct iwl_tid_data tid[MAX_TID_COUNT];
457 u8 used, ctxid; 452 u8 used, ctxid;
458 struct iwl_hw_key keyinfo;
459 struct iwl_link_quality_cmd *lq; 453 struct iwl_link_quality_cmd *lq;
460}; 454};
461 455
@@ -558,7 +552,8 @@ enum iwl_ucode_tlv_type {
558 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13, 552 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
559 IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14, 553 IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
560 IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15, 554 IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
561 /* 16 and 17 reserved for future use */ 555 IWL_UCODE_TLV_WOWLAN_INST = 16,
556 IWL_UCODE_TLV_WOWLAN_DATA = 17,
562 IWL_UCODE_TLV_FLAGS = 18, 557 IWL_UCODE_TLV_FLAGS = 18,
563}; 558};
564 559
@@ -1158,6 +1153,8 @@ struct iwl_rxon_context {
1158 1153
1159 __le32 station_flags; 1154 __le32 station_flags;
1160 1155
1156 int beacon_int;
1157
1161 struct { 1158 struct {
1162 bool non_gf_sta_present; 1159 bool non_gf_sta_present;
1163 u8 protection; 1160 u8 protection;
@@ -1193,77 +1190,6 @@ struct iwl_testmode_trace {
1193}; 1190};
1194#endif 1191#endif
1195 1192
1196struct iwl_bus;
1197
1198/**
1199 * struct iwl_bus_ops - bus specific operations
1200
1201 * @get_pm_support: must returns true if the bus can go to sleep
1202 * @apm_config: will be called during the config of the APM configuration
1203 * @set_drv_data: set the priv pointer to the bus layer
1204 * @get_dev: returns the device struct
1205 * @get_irq: returns the irq number
1206 * @get_hw_id: prints the hw_id in the provided buffer
1207 * @write8: write a byte to register at offset ofs
1208 * @write32: write a dword to register at offset ofs
1209 * @wread32: read a dword at register at offset ofs
1210 */
1211struct iwl_bus_ops {
1212 bool (*get_pm_support)(struct iwl_bus *bus);
1213 void (*apm_config)(struct iwl_bus *bus);
1214 void (*set_drv_data)(struct iwl_bus *bus, void *priv);
1215 struct device *(*get_dev)(const struct iwl_bus *bus);
1216 unsigned int (*get_irq)(const struct iwl_bus *bus);
1217 void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len);
1218 void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
1219 void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
1220 u32 (*read32)(struct iwl_bus *bus, u32 ofs);
1221};
1222
1223struct iwl_bus {
1224 /* pointer to bus specific struct */
1225 void *bus_specific;
1226
1227 /* Common data to all buses */
1228 struct iwl_priv *priv; /* driver's context */
1229 struct device *dev;
1230 struct iwl_bus_ops *ops;
1231 unsigned int irq;
1232};
1233
1234struct iwl_trans;
1235
1236/**
1237 * struct iwl_trans_ops - transport specific operations
1238
1239 * @rx_init: inits the rx memory, allocate it if needed
1240 * @rx_stop: stop the rx
1241 * @rx_free: frees the rx memory
1242 * @tx_init:inits the tx memory, allocate if needed
1243 * @tx_stop: stop the tx
1244 * @tx_free: frees the tx memory
1245 * @send_cmd:send a host command
1246 * @send_cmd_pdu:send a host command: flags can be CMD_*
1247 */
1248struct iwl_trans_ops {
1249 int (*rx_init)(struct iwl_priv *priv);
1250 int (*rx_stop)(struct iwl_priv *priv);
1251 void (*rx_free)(struct iwl_priv *priv);
1252
1253 int (*tx_init)(struct iwl_priv *priv);
1254 int (*tx_stop)(struct iwl_priv *priv);
1255 void (*tx_free)(struct iwl_priv *priv);
1256
1257 int (*send_cmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
1258
1259 int (*send_cmd_pdu)(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
1260 const void *data);
1261};
1262
1263struct iwl_trans {
1264 const struct iwl_trans_ops *ops;
1265};
1266
1267/* uCode ownership */ 1193/* uCode ownership */
1268#define IWL_OWNERSHIP_DRIVER 0 1194#define IWL_OWNERSHIP_DRIVER 0
1269#define IWL_OWNERSHIP_TM 1 1195#define IWL_OWNERSHIP_TM 1
@@ -1335,7 +1261,7 @@ struct iwl_priv {
1335 spinlock_t reg_lock; /* protect hw register access */ 1261 spinlock_t reg_lock; /* protect hw register access */
1336 struct mutex mutex; 1262 struct mutex mutex;
1337 1263
1338 struct iwl_bus bus; /* bus specific data */ 1264 struct iwl_bus *bus; /* bus specific data */
1339 struct iwl_trans trans; 1265 struct iwl_trans trans;
1340 1266
1341 /* microcode/device supports multiple contexts */ 1267 /* microcode/device supports multiple contexts */
@@ -1362,6 +1288,7 @@ struct iwl_priv {
1362 1288
1363 struct fw_img ucode_rt; 1289 struct fw_img ucode_rt;
1364 struct fw_img ucode_init; 1290 struct fw_img ucode_init;
1291 struct fw_img ucode_wowlan;
1365 1292
1366 enum iwlagn_ucode_type ucode_type; 1293 enum iwlagn_ucode_type ucode_type;
1367 u8 ucode_write_complete; /* the image write is complete */ 1294 u8 ucode_write_complete; /* the image write is complete */
@@ -1434,6 +1361,8 @@ struct iwl_priv {
1434 1361
1435 u8 mac80211_registered; 1362 u8 mac80211_registered;
1436 1363
1364 bool wowlan;
1365
1437 /* eeprom -- this is in the card's little endian byte order */ 1366 /* eeprom -- this is in the card's little endian byte order */
1438 u8 *eeprom; 1367 u8 *eeprom;
1439 int nvm_device_type; 1368 int nvm_device_type;
@@ -1469,56 +1398,54 @@ struct iwl_priv {
1469 } accum_stats, delta_stats, max_delta_stats; 1398 } accum_stats, delta_stats, max_delta_stats;
1470#endif 1399#endif
1471 1400
1472 struct { 1401 /* INT ICT Table */
1473 /* INT ICT Table */ 1402 __le32 *ict_tbl;
1474 __le32 *ict_tbl; 1403 void *ict_tbl_vir;
1475 void *ict_tbl_vir; 1404 dma_addr_t ict_tbl_dma;
1476 dma_addr_t ict_tbl_dma; 1405 dma_addr_t aligned_ict_tbl_dma;
1477 dma_addr_t aligned_ict_tbl_dma; 1406 int ict_index;
1478 int ict_index; 1407 u32 inta;
1479 u32 inta; 1408 bool use_ict;
1480 bool use_ict; 1409 /*
1481 /* 1410 * reporting the number of tids has AGG on. 0 means
1482 * reporting the number of tids has AGG on. 0 means 1411 * no AGGREGATION
1483 * no AGGREGATION 1412 */
1484 */ 1413 u8 agg_tids_count;
1485 u8 agg_tids_count; 1414
1486 1415 struct iwl_rx_phy_res last_phy_res;
1487 struct iwl_rx_phy_res last_phy_res; 1416 bool last_phy_res_valid;
1488 bool last_phy_res_valid; 1417
1489 1418 struct completion firmware_loading_complete;
1490 struct completion firmware_loading_complete; 1419
1491 1420 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
1492 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; 1421 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
1493 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; 1422
1494 1423 /*
1495 /* 1424 * chain noise reset and gain commands are the
1496 * chain noise reset and gain commands are the 1425 * two extra calibration commands follows the standard
1497 * two extra calibration commands follows the standard 1426 * phy calibration commands
1498 * phy calibration commands 1427 */
1499 */ 1428 u8 phy_calib_chain_noise_reset_cmd;
1500 u8 phy_calib_chain_noise_reset_cmd; 1429 u8 phy_calib_chain_noise_gain_cmd;
1501 u8 phy_calib_chain_noise_gain_cmd; 1430
1502 1431 /* counts reply_tx error */
1503 /* counts reply_tx error */ 1432 struct reply_tx_error_statistics reply_tx_stats;
1504 struct reply_tx_error_statistics reply_tx_stats; 1433 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
1505 struct reply_agg_tx_error_statistics reply_agg_tx_stats; 1434 /* notification wait support */
1506 /* notification wait support */ 1435 struct list_head notif_waits;
1507 struct list_head notif_waits; 1436 spinlock_t notif_wait_lock;
1508 spinlock_t notif_wait_lock; 1437 wait_queue_head_t notif_waitq;
1509 wait_queue_head_t notif_waitq; 1438
1510 1439 /* remain-on-channel offload support */
1511 /* remain-on-channel offload support */ 1440 struct ieee80211_channel *hw_roc_channel;
1512 struct ieee80211_channel *hw_roc_channel; 1441 struct delayed_work hw_roc_work;
1513 struct delayed_work hw_roc_work; 1442 enum nl80211_channel_type hw_roc_chantype;
1514 enum nl80211_channel_type hw_roc_chantype; 1443 int hw_roc_duration;
1515 int hw_roc_duration; 1444 bool hw_roc_setup;
1516 bool hw_roc_setup; 1445
1517 1446 struct sk_buff *offchan_tx_skb;
1518 struct sk_buff *offchan_tx_skb; 1447 int offchan_tx_timeout;
1519 int offchan_tx_timeout; 1448 struct ieee80211_channel *offchan_tx_chan;
1520 struct ieee80211_channel *offchan_tx_chan;
1521 } _agn;
1522 1449
1523 /* bt coex */ 1450 /* bt coex */
1524 u8 bt_enable_flag; 1451 u8 bt_enable_flag;
@@ -1588,6 +1515,7 @@ struct iwl_priv {
1588 struct dentry *debugfs_dir; 1515 struct dentry *debugfs_dir;
1589 u32 dbgfs_sram_offset, dbgfs_sram_len; 1516 u32 dbgfs_sram_offset, dbgfs_sram_len;
1590 bool disable_ht40; 1517 bool disable_ht40;
1518 void *wowlan_sram;
1591#endif /* CONFIG_IWLWIFI_DEBUGFS */ 1519#endif /* CONFIG_IWLWIFI_DEBUGFS */
1592 1520
1593 struct work_struct txpower_work; 1521 struct work_struct txpower_work;
@@ -1605,9 +1533,14 @@ struct iwl_priv {
1605 bool led_registered; 1533 bool led_registered;
1606#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL 1534#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
1607 struct iwl_testmode_trace testmode_trace; 1535 struct iwl_testmode_trace testmode_trace;
1608#endif
1609 u32 tm_fixed_rate; 1536 u32 tm_fixed_rate;
1537#endif
1610 1538
1539 /* WoWLAN GTK rekey data */
1540 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
1541 __le64 replay_ctr;
1542 __le16 last_seq_ctl;
1543 bool have_rekey_data;
1611}; /*iwl_priv */ 1544}; /*iwl_priv */
1612 1545
1613static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id) 1546static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index eee97bcf9802..19d31a5e32e5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -543,7 +543,7 @@ static void iwl_init_band_reference(const struct iwl_priv *priv,
543 const struct iwl_eeprom_channel **eeprom_ch_info, 543 const struct iwl_eeprom_channel **eeprom_ch_info,
544 const u8 **eeprom_ch_index) 544 const u8 **eeprom_ch_index)
545{ 545{
546 u32 offset = priv->cfg->ops->lib-> 546 u32 offset = priv->cfg->lib->
547 eeprom_ops.regulatory_bands[eep_band - 1]; 547 eeprom_ops.regulatory_bands[eep_band - 1];
548 switch (eep_band) { 548 switch (eep_band) {
549 case 1: /* 2.4GHz band */ 549 case 1: /* 2.4GHz band */
@@ -749,9 +749,9 @@ int iwl_init_channel_map(struct iwl_priv *priv)
749 } 749 }
750 750
751 /* Check if we do have HT40 channels */ 751 /* Check if we do have HT40 channels */
752 if (priv->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == 752 if (priv->cfg->lib->eeprom_ops.regulatory_bands[5] ==
753 EEPROM_REGULATORY_BAND_NO_HT40 && 753 EEPROM_REGULATORY_BAND_NO_HT40 &&
754 priv->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == 754 priv->cfg->lib->eeprom_ops.regulatory_bands[6] ==
755 EEPROM_REGULATORY_BAND_NO_HT40) 755 EEPROM_REGULATORY_BAND_NO_HT40)
756 return 0; 756 return 0;
757 757
@@ -787,8 +787,8 @@ int iwl_init_channel_map(struct iwl_priv *priv)
787 * driver need to process addition information 787 * driver need to process addition information
788 * to determine the max channel tx power limits 788 * to determine the max channel tx power limits
789 */ 789 */
790 if (priv->cfg->ops->lib->eeprom_ops.update_enhanced_txpower) 790 if (priv->cfg->lib->eeprom_ops.update_enhanced_txpower)
791 priv->cfg->ops->lib->eeprom_ops.update_enhanced_txpower(priv); 791 priv->cfg->lib->eeprom_ops.update_enhanced_txpower(priv);
792 792
793 return 0; 793 return 0;
794} 794}
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
deleted file mode 100644
index 6cff8c165ce9..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ /dev/null
@@ -1,271 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/sched.h>
32#include <net/mac80211.h>
33
34#include "iwl-dev.h" /* FIXME: remove */
35#include "iwl-debug.h"
36#include "iwl-eeprom.h"
37#include "iwl-core.h"
38
39
40const char *get_cmd_string(u8 cmd)
41{
42 switch (cmd) {
43 IWL_CMD(REPLY_ALIVE);
44 IWL_CMD(REPLY_ERROR);
45 IWL_CMD(REPLY_RXON);
46 IWL_CMD(REPLY_RXON_ASSOC);
47 IWL_CMD(REPLY_QOS_PARAM);
48 IWL_CMD(REPLY_RXON_TIMING);
49 IWL_CMD(REPLY_ADD_STA);
50 IWL_CMD(REPLY_REMOVE_STA);
51 IWL_CMD(REPLY_REMOVE_ALL_STA);
52 IWL_CMD(REPLY_TXFIFO_FLUSH);
53 IWL_CMD(REPLY_WEPKEY);
54 IWL_CMD(REPLY_TX);
55 IWL_CMD(REPLY_LEDS_CMD);
56 IWL_CMD(REPLY_TX_LINK_QUALITY_CMD);
57 IWL_CMD(COEX_PRIORITY_TABLE_CMD);
58 IWL_CMD(COEX_MEDIUM_NOTIFICATION);
59 IWL_CMD(COEX_EVENT_CMD);
60 IWL_CMD(REPLY_QUIET_CMD);
61 IWL_CMD(REPLY_CHANNEL_SWITCH);
62 IWL_CMD(CHANNEL_SWITCH_NOTIFICATION);
63 IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD);
64 IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION);
65 IWL_CMD(POWER_TABLE_CMD);
66 IWL_CMD(PM_SLEEP_NOTIFICATION);
67 IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC);
68 IWL_CMD(REPLY_SCAN_CMD);
69 IWL_CMD(REPLY_SCAN_ABORT_CMD);
70 IWL_CMD(SCAN_START_NOTIFICATION);
71 IWL_CMD(SCAN_RESULTS_NOTIFICATION);
72 IWL_CMD(SCAN_COMPLETE_NOTIFICATION);
73 IWL_CMD(BEACON_NOTIFICATION);
74 IWL_CMD(REPLY_TX_BEACON);
75 IWL_CMD(WHO_IS_AWAKE_NOTIFICATION);
76 IWL_CMD(QUIET_NOTIFICATION);
77 IWL_CMD(REPLY_TX_PWR_TABLE_CMD);
78 IWL_CMD(MEASURE_ABORT_NOTIFICATION);
79 IWL_CMD(REPLY_BT_CONFIG);
80 IWL_CMD(REPLY_STATISTICS_CMD);
81 IWL_CMD(STATISTICS_NOTIFICATION);
82 IWL_CMD(REPLY_CARD_STATE_CMD);
83 IWL_CMD(CARD_STATE_NOTIFICATION);
84 IWL_CMD(MISSED_BEACONS_NOTIFICATION);
85 IWL_CMD(REPLY_CT_KILL_CONFIG_CMD);
86 IWL_CMD(SENSITIVITY_CMD);
87 IWL_CMD(REPLY_PHY_CALIBRATION_CMD);
88 IWL_CMD(REPLY_RX_PHY_CMD);
89 IWL_CMD(REPLY_RX_MPDU_CMD);
90 IWL_CMD(REPLY_RX);
91 IWL_CMD(REPLY_COMPRESSED_BA);
92 IWL_CMD(CALIBRATION_CFG_CMD);
93 IWL_CMD(CALIBRATION_RES_NOTIFICATION);
94 IWL_CMD(CALIBRATION_COMPLETE_NOTIFICATION);
95 IWL_CMD(REPLY_TX_POWER_DBM_CMD);
96 IWL_CMD(TEMPERATURE_NOTIFICATION);
97 IWL_CMD(TX_ANT_CONFIGURATION_CMD);
98 IWL_CMD(REPLY_BT_COEX_PROFILE_NOTIF);
99 IWL_CMD(REPLY_BT_COEX_PRIO_TABLE);
100 IWL_CMD(REPLY_BT_COEX_PROT_ENV);
101 IWL_CMD(REPLY_WIPAN_PARAMS);
102 IWL_CMD(REPLY_WIPAN_RXON);
103 IWL_CMD(REPLY_WIPAN_RXON_TIMING);
104 IWL_CMD(REPLY_WIPAN_RXON_ASSOC);
105 IWL_CMD(REPLY_WIPAN_QOS_PARAM);
106 IWL_CMD(REPLY_WIPAN_WEPKEY);
107 IWL_CMD(REPLY_WIPAN_P2P_CHANNEL_SWITCH);
108 IWL_CMD(REPLY_WIPAN_NOA_NOTIFICATION);
109 IWL_CMD(REPLY_WIPAN_DEACTIVATION_COMPLETE);
110 default:
111 return "UNKNOWN";
112
113 }
114}
115
116#define HOST_COMPLETE_TIMEOUT (2 * HZ)
117
118static void iwl_generic_cmd_callback(struct iwl_priv *priv,
119 struct iwl_device_cmd *cmd,
120 struct iwl_rx_packet *pkt)
121{
122 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
123 IWL_ERR(priv, "Bad return from %s (0x%08X)\n",
124 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
125 return;
126 }
127
128#ifdef CONFIG_IWLWIFI_DEBUG
129 switch (cmd->hdr.cmd) {
130 case REPLY_TX_LINK_QUALITY_CMD:
131 case SENSITIVITY_CMD:
132 IWL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n",
133 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
134 break;
135 default:
136 IWL_DEBUG_HC(priv, "back from %s (0x%08X)\n",
137 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
138 }
139#endif
140}
141
142static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
143{
144 int ret;
145
146 /* An asynchronous command can not expect an SKB to be set. */
147 if (WARN_ON(cmd->flags & CMD_WANT_SKB))
148 return -EINVAL;
149
150 /* Assign a generic callback if one is not provided */
151 if (!cmd->callback)
152 cmd->callback = iwl_generic_cmd_callback;
153
154 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
155 return -EBUSY;
156
157 ret = iwl_enqueue_hcmd(priv, cmd);
158 if (ret < 0) {
159 IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n",
160 get_cmd_string(cmd->id), ret);
161 return ret;
162 }
163 return 0;
164}
165
166static int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
167{
168 int cmd_idx;
169 int ret;
170
171 lockdep_assert_held(&priv->mutex);
172
173 /* A synchronous command can not have a callback set. */
174 if (WARN_ON(cmd->callback))
175 return -EINVAL;
176
177 IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
178 get_cmd_string(cmd->id));
179
180 set_bit(STATUS_HCMD_ACTIVE, &priv->status);
181 IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n",
182 get_cmd_string(cmd->id));
183
184 cmd_idx = iwl_enqueue_hcmd(priv, cmd);
185 if (cmd_idx < 0) {
186 ret = cmd_idx;
187 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
188 IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n",
189 get_cmd_string(cmd->id), ret);
190 return ret;
191 }
192
193 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
194 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
195 HOST_COMPLETE_TIMEOUT);
196 if (!ret) {
197 if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) {
198 IWL_ERR(priv,
199 "Error sending %s: time out after %dms.\n",
200 get_cmd_string(cmd->id),
201 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
202
203 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
204 IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n",
205 get_cmd_string(cmd->id));
206 ret = -ETIMEDOUT;
207 goto cancel;
208 }
209 }
210
211 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
212 IWL_ERR(priv, "Command %s aborted: RF KILL Switch\n",
213 get_cmd_string(cmd->id));
214 ret = -ECANCELED;
215 goto fail;
216 }
217 if (test_bit(STATUS_FW_ERROR, &priv->status)) {
218 IWL_ERR(priv, "Command %s failed: FW Error\n",
219 get_cmd_string(cmd->id));
220 ret = -EIO;
221 goto fail;
222 }
223 if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) {
224 IWL_ERR(priv, "Error: Response NULL in '%s'\n",
225 get_cmd_string(cmd->id));
226 ret = -EIO;
227 goto cancel;
228 }
229
230 return 0;
231
232cancel:
233 if (cmd->flags & CMD_WANT_SKB) {
234 /*
235 * Cancel the CMD_WANT_SKB flag for the cmd in the
236 * TX cmd queue. Otherwise in case the cmd comes
237 * in later, it will possibly set an invalid
238 * address (cmd->meta.source).
239 */
240 priv->txq[priv->cmd_queue].meta[cmd_idx].flags &=
241 ~CMD_WANT_SKB;
242 }
243fail:
244 if (cmd->reply_page) {
245 iwl_free_pages(priv, cmd->reply_page);
246 cmd->reply_page = 0;
247 }
248
249 return ret;
250}
251
252int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
253{
254 if (cmd->flags & CMD_ASYNC)
255 return iwl_send_cmd_async(priv, cmd);
256
257 return iwl_send_cmd_sync(priv, cmd);
258}
259
260int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
261 const void *data)
262{
263 struct iwl_host_cmd cmd = {
264 .id = id,
265 .len = { len, },
266 .data = { data, },
267 .flags = flags,
268 };
269
270 return iwl_send_cmd(priv, &cmd);
271}
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index c56eae74c3cd..19a093101122 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -34,22 +34,23 @@
34#include "iwl-dev.h" 34#include "iwl-dev.h"
35#include "iwl-debug.h" 35#include "iwl-debug.h"
36#include "iwl-devtrace.h" 36#include "iwl-devtrace.h"
37#include "iwl-bus.h"
37 38
38static inline void iwl_write8(struct iwl_priv *priv, u32 ofs, u8 val) 39static inline void iwl_write8(struct iwl_priv *priv, u32 ofs, u8 val)
39{ 40{
40 trace_iwlwifi_dev_iowrite8(priv, ofs, val); 41 trace_iwlwifi_dev_iowrite8(priv, ofs, val);
41 priv->bus.ops->write8(&priv->bus, ofs, val); 42 bus_write8(priv->bus, ofs, val);
42} 43}
43 44
44static inline void iwl_write32(struct iwl_priv *priv, u32 ofs, u32 val) 45static inline void iwl_write32(struct iwl_priv *priv, u32 ofs, u32 val)
45{ 46{
46 trace_iwlwifi_dev_iowrite32(priv, ofs, val); 47 trace_iwlwifi_dev_iowrite32(priv, ofs, val);
47 priv->bus.ops->write32(&priv->bus, ofs, val); 48 bus_write32(priv->bus, ofs, val);
48} 49}
49 50
50static inline u32 iwl_read32(struct iwl_priv *priv, u32 ofs) 51static inline u32 iwl_read32(struct iwl_priv *priv, u32 ofs)
51{ 52{
52 u32 val = priv->bus.ops->read32(&priv->bus, ofs); 53 u32 val = bus_read32(priv->bus, ofs);
53 trace_iwlwifi_dev_ioread32(priv, ofs, val); 54 trace_iwlwifi_dev_ioread32(priv, ofs, val);
54 return val; 55 return val;
55} 56}
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 60e4169f25e1..a67ae56d5464 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -112,7 +112,7 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
112 if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) 112 if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
113 iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); 113 iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
114 114
115 return trans_send_cmd(priv, &cmd); 115 return trans_send_cmd(&priv->trans, &cmd);
116} 116}
117 117
118/* Set led pattern command */ 118/* Set led pattern command */
@@ -203,7 +203,7 @@ void iwl_leds_init(struct iwl_priv *priv)
203 break; 203 break;
204 } 204 }
205 205
206 ret = led_classdev_register(priv->bus.dev, 206 ret = led_classdev_register(priv->bus->dev,
207 &priv->led); 207 &priv->led);
208 if (ret) { 208 if (ret) {
209 kfree(priv->led.name); 209 kfree(priv->led.name);
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index 74911348a2ee..fb7e436b40c7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -63,11 +63,10 @@
63#include <linux/pci.h> 63#include <linux/pci.h>
64#include <linux/pci-aspm.h> 64#include <linux/pci-aspm.h>
65 65
66#include "iwl-pci.h" 66#include "iwl-bus.h"
67#include "iwl-agn.h" 67#include "iwl-agn.h"
68#include "iwl-core.h" 68#include "iwl-core.h"
69#include "iwl-io.h" 69#include "iwl-io.h"
70#include "iwl-trans.h"
71 70
72/* PCI registers */ 71/* PCI registers */
73#define PCI_CFG_RETRY_TIMEOUT 0x041 72#define PCI_CFG_RETRY_TIMEOUT 0x041
@@ -121,30 +120,20 @@ static void iwl_pci_apm_config(struct iwl_bus *bus)
121 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == 120 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
122 PCI_CFG_LINK_CTRL_VAL_L1_EN) { 121 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
123 /* L1-ASPM enabled; disable(!) L0S */ 122 /* L1-ASPM enabled; disable(!) L0S */
124 iwl_set_bit(bus->priv, CSR_GIO_REG, 123 iwl_set_bit(bus->drv_data, CSR_GIO_REG,
125 CSR_GIO_REG_VAL_L0S_ENABLED); 124 CSR_GIO_REG_VAL_L0S_ENABLED);
126 IWL_DEBUG_POWER(bus->priv, "L1 Enabled; Disabling L0S\n"); 125 dev_printk(KERN_INFO, bus->dev, "L1 Enabled; Disabling L0S\n");
127 } else { 126 } else {
128 /* L1-ASPM disabled; enable(!) L0S */ 127 /* L1-ASPM disabled; enable(!) L0S */
129 iwl_clear_bit(bus->priv, CSR_GIO_REG, 128 iwl_clear_bit(bus->drv_data, CSR_GIO_REG,
130 CSR_GIO_REG_VAL_L0S_ENABLED); 129 CSR_GIO_REG_VAL_L0S_ENABLED);
131 IWL_DEBUG_POWER(bus->priv, "L1 Disabled; Enabling L0S\n"); 130 dev_printk(KERN_INFO, bus->dev, "L1 Disabled; Enabling L0S\n");
132 } 131 }
133} 132}
134 133
135static void iwl_pci_set_drv_data(struct iwl_bus *bus, void *drv_priv) 134static void iwl_pci_set_drv_data(struct iwl_bus *bus, void *drv_data)
136{ 135{
137 pci_set_drvdata(IWL_BUS_GET_PCI_DEV(bus), drv_priv); 136 bus->drv_data = drv_data;
138}
139
140static struct device *iwl_pci_get_dev(const struct iwl_bus *bus)
141{
142 return &(IWL_BUS_GET_PCI_DEV(bus)->dev);
143}
144
145static unsigned int iwl_pci_get_irq(const struct iwl_bus *bus)
146{
147 return IWL_BUS_GET_PCI_DEV(bus)->irq;
148} 137}
149 138
150static void iwl_pci_get_hw_id(struct iwl_bus *bus, char buf[], 139static void iwl_pci_get_hw_id(struct iwl_bus *bus, char buf[],
@@ -176,8 +165,6 @@ static struct iwl_bus_ops pci_ops = {
176 .get_pm_support = iwl_pci_is_pm_supported, 165 .get_pm_support = iwl_pci_is_pm_supported,
177 .apm_config = iwl_pci_apm_config, 166 .apm_config = iwl_pci_apm_config,
178 .set_drv_data = iwl_pci_set_drv_data, 167 .set_drv_data = iwl_pci_set_drv_data,
179 .get_dev = iwl_pci_get_dev,
180 .get_irq = iwl_pci_get_irq,
181 .get_hw_id = iwl_pci_get_hw_id, 168 .get_hw_id = iwl_pci_get_hw_id,
182 .write8 = iwl_pci_write8, 169 .write8 = iwl_pci_write8,
183 .write32 = iwl_pci_write32, 170 .write32 = iwl_pci_write32,
@@ -383,18 +370,21 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
383static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 370static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
384{ 371{
385 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 372 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
386 struct iwl_pci_bus *bus; 373 struct iwl_bus *bus;
374 struct iwl_pci_bus *pci_bus;
387 u16 pci_cmd; 375 u16 pci_cmd;
388 int err; 376 int err;
389 377
390 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 378 bus = kzalloc(sizeof(*bus) + sizeof(*pci_bus), GFP_KERNEL);
391 if (!bus) { 379 if (!bus) {
392 pr_err("Couldn't allocate iwl_pci_bus"); 380 dev_printk(KERN_ERR, &pdev->dev,
381 "Couldn't allocate iwl_pci_bus");
393 err = -ENOMEM; 382 err = -ENOMEM;
394 goto out_no_pci; 383 goto out_no_pci;
395 } 384 }
396 385
397 bus->pci_dev = pdev; 386 pci_bus = IWL_BUS_GET_PCI_BUS(bus);
387 pci_bus->pci_dev = pdev;
398 388
399 /* W/A - seems to solve weird behavior. We need to remove this if we 389 /* W/A - seems to solve weird behavior. We need to remove this if we
400 * don't want to stay in L1 all the time. This wastes a lot of power */ 390 * don't want to stay in L1 all the time. This wastes a lot of power */
@@ -418,29 +408,33 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
418 DMA_BIT_MASK(32)); 408 DMA_BIT_MASK(32));
419 /* both attempts failed: */ 409 /* both attempts failed: */
420 if (err) { 410 if (err) {
421 pr_err("No suitable DMA available.\n"); 411 dev_printk(KERN_ERR, bus->dev,
412 "No suitable DMA available.\n");
422 goto out_pci_disable_device; 413 goto out_pci_disable_device;
423 } 414 }
424 } 415 }
425 416
426 err = pci_request_regions(pdev, DRV_NAME); 417 err = pci_request_regions(pdev, DRV_NAME);
427 if (err) { 418 if (err) {
428 pr_err("pci_request_regions failed"); 419 dev_printk(KERN_ERR, bus->dev, "pci_request_regions failed");
429 goto out_pci_disable_device; 420 goto out_pci_disable_device;
430 } 421 }
431 422
432 bus->hw_base = pci_iomap(pdev, 0, 0); 423 pci_bus->hw_base = pci_iomap(pdev, 0, 0);
433 if (!bus->hw_base) { 424 if (!pci_bus->hw_base) {
434 pr_err("pci_iomap failed"); 425 dev_printk(KERN_ERR, bus->dev, "pci_iomap failed");
435 err = -ENODEV; 426 err = -ENODEV;
436 goto out_pci_release_regions; 427 goto out_pci_release_regions;
437 } 428 }
438 429
439 pr_info("pci_resource_len = 0x%08llx\n", 430 dev_printk(KERN_INFO, &pdev->dev,
431 "pci_resource_len = 0x%08llx\n",
440 (unsigned long long) pci_resource_len(pdev, 0)); 432 (unsigned long long) pci_resource_len(pdev, 0));
441 pr_info("pci_resource_base = %p\n", bus->hw_base); 433 dev_printk(KERN_INFO, &pdev->dev,
434 "pci_resource_base = %p\n", pci_bus->hw_base);
442 435
443 pr_info("HW Revision ID = 0x%X\n", pdev->revision); 436 dev_printk(KERN_INFO, &pdev->dev,
437 "HW Revision ID = 0x%X\n", pdev->revision);
444 438
445 /* We disable the RETRY_TIMEOUT register (0x41) to keep 439 /* We disable the RETRY_TIMEOUT register (0x41) to keep
446 * PCI Tx retries from interfering with C3 CPU state */ 440 * PCI Tx retries from interfering with C3 CPU state */
@@ -448,7 +442,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
448 442
449 err = pci_enable_msi(pdev); 443 err = pci_enable_msi(pdev);
450 if (err) { 444 if (err) {
451 pr_err("pci_enable_msi failed"); 445 dev_printk(KERN_ERR, &pdev->dev, "pci_enable_msi failed");
452 goto out_iounmap; 446 goto out_iounmap;
453 } 447 }
454 448
@@ -460,7 +454,13 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
460 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); 454 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
461 } 455 }
462 456
463 err = iwl_probe((void *) bus, &pci_ops, cfg); 457 pci_set_drvdata(pdev, bus);
458
459 bus->dev = &pdev->dev;
460 bus->irq = pdev->irq;
461 bus->ops = &pci_ops;
462
463 err = iwl_probe(bus, cfg);
464 if (err) 464 if (err)
465 goto out_disable_msi; 465 goto out_disable_msi;
466 return 0; 466 return 0;
@@ -468,7 +468,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
468out_disable_msi: 468out_disable_msi:
469 pci_disable_msi(pdev); 469 pci_disable_msi(pdev);
470out_iounmap: 470out_iounmap:
471 pci_iounmap(pdev, bus->hw_base); 471 pci_iounmap(pdev, pci_bus->hw_base);
472out_pci_release_regions: 472out_pci_release_regions:
473 pci_set_drvdata(pdev, NULL); 473 pci_set_drvdata(pdev, NULL);
474 pci_release_regions(pdev); 474 pci_release_regions(pdev);
@@ -479,9 +479,9 @@ out_no_pci:
479 return err; 479 return err;
480} 480}
481 481
482static void iwl_pci_down(void *bus) 482static void iwl_pci_down(struct iwl_bus *bus)
483{ 483{
484 struct iwl_pci_bus *pci_bus = (struct iwl_pci_bus *) bus; 484 struct iwl_pci_bus *pci_bus = (struct iwl_pci_bus *) bus->bus_specific;
485 485
486 pci_disable_msi(pci_bus->pci_dev); 486 pci_disable_msi(pci_bus->pci_dev);
487 pci_iounmap(pci_bus->pci_dev, pci_bus->hw_base); 487 pci_iounmap(pci_bus->pci_dev, pci_bus->hw_base);
@@ -489,17 +489,16 @@ static void iwl_pci_down(void *bus)
489 pci_disable_device(pci_bus->pci_dev); 489 pci_disable_device(pci_bus->pci_dev);
490 pci_set_drvdata(pci_bus->pci_dev, NULL); 490 pci_set_drvdata(pci_bus->pci_dev, NULL);
491 491
492 kfree(pci_bus); 492 kfree(bus);
493} 493}
494 494
495static void __devexit iwl_pci_remove(struct pci_dev *pdev) 495static void __devexit iwl_pci_remove(struct pci_dev *pdev)
496{ 496{
497 struct iwl_priv *priv = pci_get_drvdata(pdev); 497 struct iwl_bus *bus = pci_get_drvdata(pdev);
498 void *bus_specific = priv->bus.bus_specific;
499 498
500 iwl_remove(priv); 499 iwl_remove(bus->drv_data);
501 500
502 iwl_pci_down(bus_specific); 501 iwl_pci_down(bus);
503} 502}
504 503
505#ifdef CONFIG_PM 504#ifdef CONFIG_PM
@@ -507,15 +506,25 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
507static int iwl_pci_suspend(struct device *device) 506static int iwl_pci_suspend(struct device *device)
508{ 507{
509 struct pci_dev *pdev = to_pci_dev(device); 508 struct pci_dev *pdev = to_pci_dev(device);
510 struct iwl_priv *priv = pci_get_drvdata(pdev); 509 struct iwl_bus *bus = pci_get_drvdata(pdev);
510
511 /* Before you put code here, think about WoWLAN. You cannot check here
512 * whether WoWLAN is enabled or not, and your code will run even if
513 * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx.
514 */
511 515
512 return iwl_suspend(priv); 516 return iwl_suspend(bus->drv_data);
513} 517}
514 518
515static int iwl_pci_resume(struct device *device) 519static int iwl_pci_resume(struct device *device)
516{ 520{
517 struct pci_dev *pdev = to_pci_dev(device); 521 struct pci_dev *pdev = to_pci_dev(device);
518 struct iwl_priv *priv = pci_get_drvdata(pdev); 522 struct iwl_bus *bus = pci_get_drvdata(pdev);
523
524 /* Before you put code here, think about WoWLAN. You cannot check here
525 * whether WoWLAN is enabled or not, and your code will run even if
526 * WoWLAN is enabled - the NIC may be alive.
527 */
519 528
520 /* 529 /*
521 * We disable the RETRY_TIMEOUT register (0x41) to keep 530 * We disable the RETRY_TIMEOUT register (0x41) to keep
@@ -523,7 +532,7 @@ static int iwl_pci_resume(struct device *device)
523 */ 532 */
524 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); 533 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
525 534
526 return iwl_resume(priv); 535 return iwl_resume(bus->drv_data);
527} 536}
528 537
529static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume); 538static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 64ff40ae1026..3ec619c6881c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -335,7 +335,7 @@ static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
335 le32_to_cpu(cmd->sleep_interval[3]), 335 le32_to_cpu(cmd->sleep_interval[3]),
336 le32_to_cpu(cmd->sleep_interval[4])); 336 le32_to_cpu(cmd->sleep_interval[4]));
337 337
338 return trans_send_cmd_pdu(priv, POWER_TABLE_CMD, CMD_SYNC, 338 return trans_send_cmd_pdu(&priv->trans, POWER_TABLE_CMD, CMD_SYNC,
339 sizeof(struct iwl_powertable_cmd), cmd); 339 sizeof(struct iwl_powertable_cmd), cmd);
340} 340}
341 341
@@ -347,7 +347,9 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
347 347
348 dtimper = priv->hw->conf.ps_dtim_period ?: 1; 348 dtimper = priv->hw->conf.ps_dtim_period ?: 1;
349 349
350 if (priv->hw->conf.flags & IEEE80211_CONF_IDLE) 350 if (priv->wowlan)
351 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
352 else if (priv->hw->conf.flags & IEEE80211_CONF_IDLE)
351 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20); 353 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
352 else if (iwl_tt_is_low_power_state(priv)) { 354 else if (iwl_tt_is_low_power_state(priv)) {
353 /* in thermal throttling low power state */ 355 /* in thermal throttling low power state */
@@ -432,7 +434,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
432/* initialize to default */ 434/* initialize to default */
433void iwl_power_initialize(struct iwl_priv *priv) 435void iwl_power_initialize(struct iwl_priv *priv)
434{ 436{
435 priv->power_data.bus_pm = priv->bus.ops->get_pm_support(&priv->bus); 437 priv->power_data.bus_pm = bus_get_pm_support(priv->bus);
436 438
437 priv->power_data.debug_sleep_level_override = -1; 439 priv->power_data.debug_sleep_level_override = -1;
438 440
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index 1cc0ed1f488c..2f267b8aabbb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -178,61 +178,61 @@
178#define SCD_WIN_SIZE 64 178#define SCD_WIN_SIZE 64
179#define SCD_FRAME_LIMIT 64 179#define SCD_FRAME_LIMIT 64
180 180
181#define IWL_SCD_TXFIFO_POS_TID (0) 181#define SCD_TXFIFO_POS_TID (0)
182#define IWL_SCD_TXFIFO_POS_RA (4) 182#define SCD_TXFIFO_POS_RA (4)
183#define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) 183#define SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
184 184
185/* agn SCD */ 185/* agn SCD */
186#define IWLAGN_SCD_QUEUE_STTS_REG_POS_TXF (0) 186#define SCD_QUEUE_STTS_REG_POS_TXF (0)
187#define IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE (3) 187#define SCD_QUEUE_STTS_REG_POS_ACTIVE (3)
188#define IWLAGN_SCD_QUEUE_STTS_REG_POS_WSL (4) 188#define SCD_QUEUE_STTS_REG_POS_WSL (4)
189#define IWLAGN_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (19) 189#define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (19)
190#define IWLAGN_SCD_QUEUE_STTS_REG_MSK (0x00FF0000) 190#define SCD_QUEUE_STTS_REG_MSK (0x00FF0000)
191 191
192#define IWLAGN_SCD_QUEUE_CTX_REG1_CREDIT_POS (8) 192#define SCD_QUEUE_CTX_REG1_CREDIT_POS (8)
193#define IWLAGN_SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00) 193#define SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00)
194#define IWLAGN_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24) 194#define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24)
195#define IWLAGN_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000) 195#define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000)
196#define IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS (0) 196#define SCD_QUEUE_CTX_REG2_WIN_SIZE_POS (0)
197#define IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK (0x0000007F) 197#define SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK (0x0000007F)
198#define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) 198#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
199#define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) 199#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
200 200
201/* Context Data */ 201/* Context Data */
202#define IWLAGN_SCD_CONTEXT_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x600) 202#define SCD_CONTEXT_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x600)
203#define IWLAGN_SCD_CONTEXT_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x6A0) 203#define SCD_CONTEXT_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x6A0)
204 204
205/* Tx status */ 205/* Tx status */
206#define IWLAGN_SCD_TX_STTS_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x6A0) 206#define SCD_TX_STTS_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x6A0)
207#define IWLAGN_SCD_TX_STTS_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x7E0) 207#define SCD_TX_STTS_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x7E0)
208 208
209/* Translation Data */ 209/* Translation Data */
210#define IWLAGN_SCD_TRANS_TBL_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x7E0) 210#define SCD_TRANS_TBL_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x7E0)
211#define IWLAGN_SCD_TRANS_TBL_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x808) 211#define SCD_TRANS_TBL_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x808)
212 212
213#define IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(x)\ 213#define SCD_CONTEXT_QUEUE_OFFSET(x)\
214 (IWLAGN_SCD_CONTEXT_MEM_LOWER_BOUND + ((x) * 8)) 214 (SCD_CONTEXT_MEM_LOWER_BOUND + ((x) * 8))
215 215
216#define IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ 216#define SCD_TRANS_TBL_OFFSET_QUEUE(x) \
217 ((IWLAGN_SCD_TRANS_TBL_MEM_LOWER_BOUND + ((x) * 2)) & 0xfffc) 217 ((SCD_TRANS_TBL_MEM_LOWER_BOUND + ((x) * 2)) & 0xfffc)
218 218
219#define IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv) \ 219#define SCD_QUEUECHAIN_SEL_ALL(priv) \
220 (((1<<(priv)->hw_params.max_txq_num) - 1) &\ 220 (((1<<(priv)->hw_params.max_txq_num) - 1) &\
221 (~(1<<(priv)->cmd_queue))) 221 (~(1<<(priv)->cmd_queue)))
222 222
223#define IWLAGN_SCD_BASE (PRPH_BASE + 0xa02c00) 223#define SCD_BASE (PRPH_BASE + 0xa02c00)
224 224
225#define IWLAGN_SCD_SRAM_BASE_ADDR (IWLAGN_SCD_BASE + 0x0) 225#define SCD_SRAM_BASE_ADDR (SCD_BASE + 0x0)
226#define IWLAGN_SCD_DRAM_BASE_ADDR (IWLAGN_SCD_BASE + 0x8) 226#define SCD_DRAM_BASE_ADDR (SCD_BASE + 0x8)
227#define IWLAGN_SCD_AIT (IWLAGN_SCD_BASE + 0x0c) 227#define SCD_AIT (SCD_BASE + 0x0c)
228#define IWLAGN_SCD_TXFACT (IWLAGN_SCD_BASE + 0x10) 228#define SCD_TXFACT (SCD_BASE + 0x10)
229#define IWLAGN_SCD_ACTIVE (IWLAGN_SCD_BASE + 0x14) 229#define SCD_ACTIVE (SCD_BASE + 0x14)
230#define IWLAGN_SCD_QUEUE_WRPTR(x) (IWLAGN_SCD_BASE + 0x18 + (x) * 4) 230#define SCD_QUEUE_WRPTR(x) (SCD_BASE + 0x18 + (x) * 4)
231#define IWLAGN_SCD_QUEUE_RDPTR(x) (IWLAGN_SCD_BASE + 0x68 + (x) * 4) 231#define SCD_QUEUE_RDPTR(x) (SCD_BASE + 0x68 + (x) * 4)
232#define IWLAGN_SCD_QUEUECHAIN_SEL (IWLAGN_SCD_BASE + 0xe8) 232#define SCD_QUEUECHAIN_SEL (SCD_BASE + 0xe8)
233#define IWLAGN_SCD_AGGR_SEL (IWLAGN_SCD_BASE + 0x248) 233#define SCD_AGGR_SEL (SCD_BASE + 0x248)
234#define IWLAGN_SCD_INTERRUPT_MASK (IWLAGN_SCD_BASE + 0x108) 234#define SCD_INTERRUPT_MASK (SCD_BASE + 0x108)
235#define IWLAGN_SCD_QUEUE_STATUS_BITS(x) (IWLAGN_SCD_BASE + 0x10c + (x) * 4) 235#define SCD_QUEUE_STATUS_BITS(x) (SCD_BASE + 0x10c + (x) * 4)
236 236
237/*********************** END TX SCHEDULER *************************************/ 237/*********************** END TX SCHEDULER *************************************/
238 238
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index f3f3efe38ce2..8e314003b63a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -41,142 +41,6 @@
41#include "iwl-agn-calib.h" 41#include "iwl-agn-calib.h"
42#include "iwl-agn.h" 42#include "iwl-agn.h"
43 43
44/******************************************************************************
45 *
46 * RX path functions
47 *
48 ******************************************************************************/
49
50/*
51 * Rx theory of operation
52 *
53 * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs),
54 * each of which point to Receive Buffers to be filled by the NIC. These get
55 * used not only for Rx frames, but for any command response or notification
56 * from the NIC. The driver and NIC manage the Rx buffers by means
57 * of indexes into the circular buffer.
58 *
59 * Rx Queue Indexes
60 * The host/firmware share two index registers for managing the Rx buffers.
61 *
62 * The READ index maps to the first position that the firmware may be writing
63 * to -- the driver can read up to (but not including) this position and get
64 * good data.
65 * The READ index is managed by the firmware once the card is enabled.
66 *
67 * The WRITE index maps to the last position the driver has read from -- the
68 * position preceding WRITE is the last slot the firmware can place a packet.
69 *
70 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
71 * WRITE = READ.
72 *
73 * During initialization, the host sets up the READ queue position to the first
74 * INDEX position, and WRITE to the last (READ - 1 wrapped)
75 *
76 * When the firmware places a packet in a buffer, it will advance the READ index
77 * and fire the RX interrupt. The driver can then query the READ index and
78 * process as many packets as possible, moving the WRITE index forward as it
79 * resets the Rx queue buffers with new memory.
80 *
81 * The management in the driver is as follows:
82 * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When
83 * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
84 * to replenish the iwl->rxq->rx_free.
85 * + In iwl_rx_replenish (scheduled) if 'processed' != 'read' then the
86 * iwl->rxq is replenished and the READ INDEX is updated (updating the
87 * 'processed' and 'read' driver indexes as well)
88 * + A received packet is processed and handed to the kernel network stack,
89 * detached from the iwl->rxq. The driver 'processed' index is updated.
90 * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free
91 * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ
92 * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there
93 * were enough free buffers and RX_STALLED is set it is cleared.
94 *
95 *
96 * Driver sequence:
97 *
98 * iwl_rx_queue_alloc() Allocates rx_free
99 * iwl_rx_replenish() Replenishes rx_free list from rx_used, and calls
100 * iwl_rx_queue_restock
101 * iwl_rx_queue_restock() Moves available buffers from rx_free into Rx
102 * queue, updates firmware pointers, and updates
103 * the WRITE index. If insufficient rx_free buffers
104 * are available, schedules iwl_rx_replenish
105 *
106 * -- enable interrupts --
107 * ISR - iwl_rx() Detach iwl_rx_mem_buffers from pool up to the
108 * READ INDEX, detaching the SKB from the pool.
109 * Moves the packet buffer from queue to rx_used.
110 * Calls iwl_rx_queue_restock to refill any empty
111 * slots.
112 * ...
113 *
114 */
115
116/**
117 * iwl_rx_queue_space - Return number of free slots available in queue.
118 */
119int iwl_rx_queue_space(const struct iwl_rx_queue *q)
120{
121 int s = q->read - q->write;
122 if (s <= 0)
123 s += RX_QUEUE_SIZE;
124 /* keep some buffer to not confuse full and empty queue */
125 s -= 2;
126 if (s < 0)
127 s = 0;
128 return s;
129}
130
131/**
132 * iwl_rx_queue_update_write_ptr - Update the write pointer for the RX queue
133 */
134void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q)
135{
136 unsigned long flags;
137 u32 reg;
138
139 spin_lock_irqsave(&q->lock, flags);
140
141 if (q->need_update == 0)
142 goto exit_unlock;
143
144 if (priv->cfg->base_params->shadow_reg_enable) {
145 /* shadow register enabled */
146 /* Device expects a multiple of 8 */
147 q->write_actual = (q->write & ~0x7);
148 iwl_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write_actual);
149 } else {
150 /* If power-saving is in use, make sure device is awake */
151 if (test_bit(STATUS_POWER_PMI, &priv->status)) {
152 reg = iwl_read32(priv, CSR_UCODE_DRV_GP1);
153
154 if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
155 IWL_DEBUG_INFO(priv,
156 "Rx queue requesting wakeup,"
157 " GP1 = 0x%x\n", reg);
158 iwl_set_bit(priv, CSR_GP_CNTRL,
159 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
160 goto exit_unlock;
161 }
162
163 q->write_actual = (q->write & ~0x7);
164 iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
165 q->write_actual);
166
167 /* Else device is assumed to be awake */
168 } else {
169 /* Device expects a multiple of 8 */
170 q->write_actual = (q->write & ~0x7);
171 iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
172 q->write_actual);
173 }
174 }
175 q->need_update = 0;
176
177 exit_unlock:
178 spin_unlock_irqrestore(&q->lock, flags);
179}
180 44
181/****************************************************************************** 45/******************************************************************************
182 * 46 *
@@ -306,7 +170,7 @@ static bool iwl_good_ack_health(struct iwl_priv *priv,
306 int actual_delta, expected_delta, ba_timeout_delta; 170 int actual_delta, expected_delta, ba_timeout_delta;
307 struct statistics_tx *old; 171 struct statistics_tx *old;
308 172
309 if (priv->_agn.agg_tids_count) 173 if (priv->agg_tids_count)
310 return true; 174 return true;
311 175
312 old = &priv->statistics.tx; 176 old = &priv->statistics.tx;
@@ -624,8 +488,8 @@ static void iwl_rx_statistics(struct iwl_priv *priv,
624 iwl_rx_calc_noise(priv); 488 iwl_rx_calc_noise(priv);
625 queue_work(priv->workqueue, &priv->run_time_calib_work); 489 queue_work(priv->workqueue, &priv->run_time_calib_work);
626 } 490 }
627 if (priv->cfg->ops->lib->temperature && change) 491 if (priv->cfg->lib->temperature && change)
628 priv->cfg->ops->lib->temperature(priv); 492 priv->cfg->lib->temperature(priv);
629} 493}
630 494
631static void iwl_rx_reply_statistics(struct iwl_priv *priv, 495static void iwl_rx_reply_statistics(struct iwl_priv *priv,
@@ -728,8 +592,8 @@ static void iwl_rx_reply_rx_phy(struct iwl_priv *priv,
728{ 592{
729 struct iwl_rx_packet *pkt = rxb_addr(rxb); 593 struct iwl_rx_packet *pkt = rxb_addr(rxb);
730 594
731 priv->_agn.last_phy_res_valid = true; 595 priv->last_phy_res_valid = true;
732 memcpy(&priv->_agn.last_phy_res, pkt->u.raw, 596 memcpy(&priv->last_phy_res, pkt->u.raw,
733 sizeof(struct iwl_rx_phy_res)); 597 sizeof(struct iwl_rx_phy_res));
734} 598}
735 599
@@ -977,11 +841,11 @@ static void iwl_rx_reply_rx(struct iwl_priv *priv,
977 phy_res->cfg_phy_cnt + len); 841 phy_res->cfg_phy_cnt + len);
978 ampdu_status = le32_to_cpu(rx_pkt_status); 842 ampdu_status = le32_to_cpu(rx_pkt_status);
979 } else { 843 } else {
980 if (!priv->_agn.last_phy_res_valid) { 844 if (!priv->last_phy_res_valid) {
981 IWL_ERR(priv, "MPDU frame without cached PHY data\n"); 845 IWL_ERR(priv, "MPDU frame without cached PHY data\n");
982 return; 846 return;
983 } 847 }
984 phy_res = &priv->_agn.last_phy_res; 848 phy_res = &priv->last_phy_res;
985 amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw; 849 amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw;
986 header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); 850 header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu));
987 len = le16_to_cpu(amsdu->byte_count); 851 len = le16_to_cpu(amsdu->byte_count);
@@ -1102,6 +966,64 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv)
1102 /* block ack */ 966 /* block ack */
1103 handlers[REPLY_COMPRESSED_BA] = iwlagn_rx_reply_compressed_ba; 967 handlers[REPLY_COMPRESSED_BA] = iwlagn_rx_reply_compressed_ba;
1104 968
1105 /* Set up hardware specific Rx handlers */ 969 /* init calibration handlers */
1106 priv->cfg->ops->lib->rx_handler_setup(priv); 970 priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] =
971 iwlagn_rx_calib_result;
972 priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx;
973
974 /* set up notification wait support */
975 spin_lock_init(&priv->notif_wait_lock);
976 INIT_LIST_HEAD(&priv->notif_waits);
977 init_waitqueue_head(&priv->notif_waitq);
978
979 /* Set up BT Rx handlers */
980 if (priv->cfg->lib->bt_rx_handler_setup)
981 priv->cfg->lib->bt_rx_handler_setup(priv);
982
983}
984
985void iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
986{
987 struct iwl_rx_packet *pkt = rxb_addr(rxb);
988
989 /*
990 * Do the notification wait before RX handlers so
991 * even if the RX handler consumes the RXB we have
992 * access to it in the notification wait entry.
993 */
994 if (!list_empty(&priv->notif_waits)) {
995 struct iwl_notification_wait *w;
996
997 spin_lock(&priv->notif_wait_lock);
998 list_for_each_entry(w, &priv->notif_waits, list) {
999 if (w->cmd != pkt->hdr.cmd)
1000 continue;
1001 IWL_DEBUG_RX(priv,
1002 "Notif: %s, 0x%02x - wake the callers up\n",
1003 get_cmd_string(pkt->hdr.cmd),
1004 pkt->hdr.cmd);
1005 w->triggered = true;
1006 if (w->fn)
1007 w->fn(priv, pkt, w->fn_data);
1008 }
1009 spin_unlock(&priv->notif_wait_lock);
1010
1011 wake_up_all(&priv->notif_waitq);
1012 }
1013
1014 if (priv->pre_rx_handler)
1015 priv->pre_rx_handler(priv, rxb);
1016
1017 /* Based on type of command response or notification,
1018 * handle those that need handling via function in
1019 * rx_handlers table. See iwl_setup_rx_handlers() */
1020 if (priv->rx_handlers[pkt->hdr.cmd]) {
1021 priv->isr_stats.rx_handlers[pkt->hdr.cmd]++;
1022 priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
1023 } else {
1024 /* No handling needed */
1025 IWL_DEBUG_RX(priv,
1026 "No handler needed for %s, 0x%02x\n",
1027 get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
1028 }
1107} 1029}
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index f6ebe29eb790..dd6937e97055 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -75,7 +75,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
75 test_bit(STATUS_EXIT_PENDING, &priv->status)) 75 test_bit(STATUS_EXIT_PENDING, &priv->status))
76 return -EIO; 76 return -EIO;
77 77
78 ret = trans_send_cmd(priv, &cmd); 78 ret = trans_send_cmd(&priv->trans, &cmd);
79 if (ret) 79 if (ret)
80 return ret; 80 return ret;
81 81
@@ -565,10 +565,10 @@ static void iwl_bg_scan_completed(struct work_struct *work)
565 goto out_settings; 565 goto out_settings;
566 } 566 }
567 567
568 if (priv->scan_type == IWL_SCAN_OFFCH_TX && priv->_agn.offchan_tx_skb) { 568 if (priv->scan_type == IWL_SCAN_OFFCH_TX && priv->offchan_tx_skb) {
569 ieee80211_tx_status_irqsafe(priv->hw, 569 ieee80211_tx_status_irqsafe(priv->hw,
570 priv->_agn.offchan_tx_skb); 570 priv->offchan_tx_skb);
571 priv->_agn.offchan_tx_skb = NULL; 571 priv->offchan_tx_skb = NULL;
572 } 572 }
573 573
574 if (priv->scan_type != IWL_SCAN_NORMAL && !aborted) { 574 if (priv->scan_type != IWL_SCAN_NORMAL && !aborted) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 65386e575b1c..1ef3b7106ad5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -168,7 +168,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
168 } 168 }
169 169
170 cmd.len[0] = iwlagn_build_addsta_hcmd(sta, data); 170 cmd.len[0] = iwlagn_build_addsta_hcmd(sta, data);
171 ret = trans_send_cmd(priv, &cmd); 171 ret = trans_send_cmd(&priv->trans, &cmd);
172 172
173 if (ret || (flags & CMD_ASYNC)) 173 if (ret || (flags & CMD_ASYNC))
174 return ret; 174 return ret;
@@ -424,7 +424,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
424 424
425 cmd.flags |= CMD_WANT_SKB; 425 cmd.flags |= CMD_WANT_SKB;
426 426
427 ret = trans_send_cmd(priv, &cmd); 427 ret = trans_send_cmd(&priv->trans, &cmd);
428 428
429 if (ret) 429 if (ret)
430 return ret; 430 return ret;
@@ -669,7 +669,7 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
669 iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); 669 iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true);
670} 670}
671 671
672int iwl_get_free_ucode_key_index(struct iwl_priv *priv) 672int iwl_get_free_ucode_key_offset(struct iwl_priv *priv)
673{ 673{
674 int i; 674 int i;
675 675
@@ -793,7 +793,7 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
793 return -EINVAL; 793 return -EINVAL;
794 794
795 if (is_lq_table_valid(priv, ctx, lq)) 795 if (is_lq_table_valid(priv, ctx, lq))
796 ret = trans_send_cmd(priv, &cmd); 796 ret = trans_send_cmd(&priv->trans, &cmd);
797 else 797 else
798 ret = -EINVAL; 798 ret = -EINVAL;
799 799
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index ff64027ff4cb..9a6768d66851 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -31,9 +31,6 @@
31 31
32#include "iwl-dev.h" 32#include "iwl-dev.h"
33 33
34#define HW_KEY_DYNAMIC 0
35#define HW_KEY_DEFAULT 1
36
37#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ 34#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
38#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ 35#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
39#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of 36#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of
@@ -47,7 +44,7 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
47void iwl_clear_ucode_stations(struct iwl_priv *priv, 44void iwl_clear_ucode_stations(struct iwl_priv *priv,
48 struct iwl_rxon_context *ctx); 45 struct iwl_rxon_context *ctx);
49void iwl_dealloc_bcast_stations(struct iwl_priv *priv); 46void iwl_dealloc_bcast_stations(struct iwl_priv *priv);
50int iwl_get_free_ucode_key_index(struct iwl_priv *priv); 47int iwl_get_free_ucode_key_offset(struct iwl_priv *priv);
51int iwl_send_add_sta(struct iwl_priv *priv, 48int iwl_send_add_sta(struct iwl_priv *priv,
52 struct iwl_addsta_cmd *sta, u8 flags); 49 struct iwl_addsta_cmd *sta, u8 flags);
53int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 50int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c
index 77ed1c295da4..b11f60de4f1e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c
@@ -181,12 +181,10 @@ void iwl_testmode_init(struct iwl_priv *priv)
181 181
182static void iwl_trace_cleanup(struct iwl_priv *priv) 182static void iwl_trace_cleanup(struct iwl_priv *priv)
183{ 183{
184 struct device *dev = priv->bus.dev;
185
186 if (priv->testmode_trace.trace_enabled) { 184 if (priv->testmode_trace.trace_enabled) {
187 if (priv->testmode_trace.cpu_addr && 185 if (priv->testmode_trace.cpu_addr &&
188 priv->testmode_trace.dma_addr) 186 priv->testmode_trace.dma_addr)
189 dma_free_coherent(dev, 187 dma_free_coherent(priv->bus->dev,
190 priv->testmode_trace.total_size, 188 priv->testmode_trace.total_size,
191 priv->testmode_trace.cpu_addr, 189 priv->testmode_trace.cpu_addr,
192 priv->testmode_trace.dma_addr); 190 priv->testmode_trace.dma_addr);
@@ -241,7 +239,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
241 IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," 239 IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x,"
242 " len %d\n", cmd.id, cmd.flags, cmd.len[0]); 240 " len %d\n", cmd.id, cmd.flags, cmd.len[0]);
243 /* ok, let's submit the command to ucode */ 241 /* ok, let's submit the command to ucode */
244 return trans_send_cmd(priv, &cmd); 242 return trans_send_cmd(&priv->trans, &cmd);
245} 243}
246 244
247 245
@@ -407,7 +405,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
407 405
408 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: 406 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
409 iwl_testmode_cfg_init_calib(priv); 407 iwl_testmode_cfg_init_calib(priv);
410 iwlagn_stop_device(priv); 408 trans_stop_device(&priv->trans);
411 break; 409 break;
412 410
413 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: 411 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
@@ -486,7 +484,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb)
486 struct iwl_priv *priv = hw->priv; 484 struct iwl_priv *priv = hw->priv;
487 struct sk_buff *skb; 485 struct sk_buff *skb;
488 int status = 0; 486 int status = 0;
489 struct device *dev = priv->bus.dev; 487 struct device *dev = priv->bus->dev;
490 488
491 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 489 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
492 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: 490 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-int-pcie.h b/drivers/net/wireless/iwlwifi/iwl-trans-int-pcie.h
new file mode 100644
index 000000000000..b79330d84185
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-int-pcie.h
@@ -0,0 +1,82 @@
1/******************************************************************************
2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4 *
5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29#ifndef __iwl_trans_int_pcie_h__
30#define __iwl_trans_int_pcie_h__
31
32/*This file includes the declaration that are internal to the
33 * trans_pcie layer */
34
35/*****************************************************
36* RX
37******************************************************/
38void iwl_bg_rx_replenish(struct work_struct *data);
39void iwl_irq_tasklet(struct iwl_priv *priv);
40void iwlagn_rx_replenish(struct iwl_priv *priv);
41void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
42 struct iwl_rx_queue *q);
43
44/*****************************************************
45* ICT
46******************************************************/
47int iwl_reset_ict(struct iwl_priv *priv);
48void iwl_disable_ict(struct iwl_priv *priv);
49int iwl_alloc_isr_ict(struct iwl_priv *priv);
50void iwl_free_isr_ict(struct iwl_priv *priv);
51irqreturn_t iwl_isr_ict(int irq, void *data);
52
53
54/*****************************************************
55* TX / HCMD
56******************************************************/
57void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
58void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq,
59 int index);
60int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv,
61 struct iwl_tx_queue *txq,
62 dma_addr_t addr, u16 len, u8 reset);
63int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
64 int count, int slots_num, u32 id);
65int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
66int __must_check iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags,
67 u16 len, const void *data);
68void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
69void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
70 struct iwl_tx_queue *txq,
71 u16 byte_cnt);
72int iwl_trans_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
73 u16 ssn_idx, u8 tx_fifo);
74void iwl_trans_set_wr_ptrs(struct iwl_priv *priv,
75 int txq_id, u32 index);
76void iwl_trans_tx_queue_set_status(struct iwl_priv *priv,
77 struct iwl_tx_queue *txq,
78 int tx_fifo_id, int scd_retry);
79void iwl_trans_txq_agg_setup(struct iwl_priv *priv, int sta_id, int tid,
80 int frame_limit);
81
82#endif /* __iwl_trans_int_pcie_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
new file mode 100644
index 000000000000..474860290404
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
@@ -0,0 +1,979 @@
1/******************************************************************************
2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4 *
5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 *
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29#include <linux/sched.h>
30#include <linux/wait.h>
31#include <linux/gfp.h>
32
33#include "iwl-dev.h"
34#include "iwl-agn.h"
35#include "iwl-core.h"
36#include "iwl-io.h"
37#include "iwl-helpers.h"
38#include "iwl-trans-int-pcie.h"
39
40/******************************************************************************
41 *
42 * RX path functions
43 *
44 ******************************************************************************/
45
46/*
47 * Rx theory of operation
48 *
49 * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs),
50 * each of which point to Receive Buffers to be filled by the NIC. These get
51 * used not only for Rx frames, but for any command response or notification
52 * from the NIC. The driver and NIC manage the Rx buffers by means
53 * of indexes into the circular buffer.
54 *
55 * Rx Queue Indexes
56 * The host/firmware share two index registers for managing the Rx buffers.
57 *
58 * The READ index maps to the first position that the firmware may be writing
59 * to -- the driver can read up to (but not including) this position and get
60 * good data.
61 * The READ index is managed by the firmware once the card is enabled.
62 *
63 * The WRITE index maps to the last position the driver has read from -- the
64 * position preceding WRITE is the last slot the firmware can place a packet.
65 *
66 * The queue is empty (no good data) if WRITE = READ - 1, and is full if
67 * WRITE = READ.
68 *
69 * During initialization, the host sets up the READ queue position to the first
70 * INDEX position, and WRITE to the last (READ - 1 wrapped)
71 *
72 * When the firmware places a packet in a buffer, it will advance the READ index
73 * and fire the RX interrupt. The driver can then query the READ index and
74 * process as many packets as possible, moving the WRITE index forward as it
75 * resets the Rx queue buffers with new memory.
76 *
77 * The management in the driver is as follows:
78 * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When
79 * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
80 * to replenish the iwl->rxq->rx_free.
81 * + In iwl_rx_replenish (scheduled) if 'processed' != 'read' then the
82 * iwl->rxq is replenished and the READ INDEX is updated (updating the
83 * 'processed' and 'read' driver indexes as well)
84 * + A received packet is processed and handed to the kernel network stack,
85 * detached from the iwl->rxq. The driver 'processed' index is updated.
86 * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free
87 * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ
88 * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there
89 * were enough free buffers and RX_STALLED is set it is cleared.
90 *
91 *
92 * Driver sequence:
93 *
94 * iwl_rx_queue_alloc() Allocates rx_free
95 * iwl_rx_replenish() Replenishes rx_free list from rx_used, and calls
96 * iwl_rx_queue_restock
97 * iwl_rx_queue_restock() Moves available buffers from rx_free into Rx
98 * queue, updates firmware pointers, and updates
99 * the WRITE index. If insufficient rx_free buffers
100 * are available, schedules iwl_rx_replenish
101 *
102 * -- enable interrupts --
103 * ISR - iwl_rx() Detach iwl_rx_mem_buffers from pool up to the
104 * READ INDEX, detaching the SKB from the pool.
105 * Moves the packet buffer from queue to rx_used.
106 * Calls iwl_rx_queue_restock to refill any empty
107 * slots.
108 * ...
109 *
110 */
111
112/**
113 * iwl_rx_queue_space - Return number of free slots available in queue.
114 */
115static int iwl_rx_queue_space(const struct iwl_rx_queue *q)
116{
117 int s = q->read - q->write;
118 if (s <= 0)
119 s += RX_QUEUE_SIZE;
120 /* keep some buffer to not confuse full and empty queue */
121 s -= 2;
122 if (s < 0)
123 s = 0;
124 return s;
125}
126
127/**
128 * iwl_rx_queue_update_write_ptr - Update the write pointer for the RX queue
129 */
130void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
131 struct iwl_rx_queue *q)
132{
133 unsigned long flags;
134 u32 reg;
135
136 spin_lock_irqsave(&q->lock, flags);
137
138 if (q->need_update == 0)
139 goto exit_unlock;
140
141 if (priv->cfg->base_params->shadow_reg_enable) {
142 /* shadow register enabled */
143 /* Device expects a multiple of 8 */
144 q->write_actual = (q->write & ~0x7);
145 iwl_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write_actual);
146 } else {
147 /* If power-saving is in use, make sure device is awake */
148 if (test_bit(STATUS_POWER_PMI, &priv->status)) {
149 reg = iwl_read32(priv, CSR_UCODE_DRV_GP1);
150
151 if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
152 IWL_DEBUG_INFO(priv,
153 "Rx queue requesting wakeup,"
154 " GP1 = 0x%x\n", reg);
155 iwl_set_bit(priv, CSR_GP_CNTRL,
156 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
157 goto exit_unlock;
158 }
159
160 q->write_actual = (q->write & ~0x7);
161 iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
162 q->write_actual);
163
164 /* Else device is assumed to be awake */
165 } else {
166 /* Device expects a multiple of 8 */
167 q->write_actual = (q->write & ~0x7);
168 iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
169 q->write_actual);
170 }
171 }
172 q->need_update = 0;
173
174 exit_unlock:
175 spin_unlock_irqrestore(&q->lock, flags);
176}
177
178/**
179 * iwlagn_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr
180 */
181static inline __le32 iwlagn_dma_addr2rbd_ptr(struct iwl_priv *priv,
182 dma_addr_t dma_addr)
183{
184 return cpu_to_le32((u32)(dma_addr >> 8));
185}
186
187/**
188 * iwlagn_rx_queue_restock - refill RX queue from pre-allocated pool
189 *
190 * If there are slots in the RX queue that need to be restocked,
191 * and we have free pre-allocated buffers, fill the ranks as much
192 * as we can, pulling from rx_free.
193 *
194 * This moves the 'write' index forward to catch up with 'processed', and
195 * also updates the memory address in the firmware to reference the new
196 * target buffer.
197 */
198static void iwlagn_rx_queue_restock(struct iwl_priv *priv)
199{
200 struct iwl_rx_queue *rxq = &priv->rxq;
201 struct list_head *element;
202 struct iwl_rx_mem_buffer *rxb;
203 unsigned long flags;
204
205 spin_lock_irqsave(&rxq->lock, flags);
206 while ((iwl_rx_queue_space(rxq) > 0) && (rxq->free_count)) {
207 /* The overwritten rxb must be a used one */
208 rxb = rxq->queue[rxq->write];
209 BUG_ON(rxb && rxb->page);
210
211 /* Get next free Rx buffer, remove from free list */
212 element = rxq->rx_free.next;
213 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
214 list_del(element);
215
216 /* Point to Rx buffer via next RBD in circular buffer */
217 rxq->bd[rxq->write] = iwlagn_dma_addr2rbd_ptr(priv,
218 rxb->page_dma);
219 rxq->queue[rxq->write] = rxb;
220 rxq->write = (rxq->write + 1) & RX_QUEUE_MASK;
221 rxq->free_count--;
222 }
223 spin_unlock_irqrestore(&rxq->lock, flags);
224 /* If the pre-allocated buffer pool is dropping low, schedule to
225 * refill it */
226 if (rxq->free_count <= RX_LOW_WATERMARK)
227 queue_work(priv->workqueue, &priv->rx_replenish);
228
229
230 /* If we've added more space for the firmware to place data, tell it.
231 * Increment device's write pointer in multiples of 8. */
232 if (rxq->write_actual != (rxq->write & ~0x7)) {
233 spin_lock_irqsave(&rxq->lock, flags);
234 rxq->need_update = 1;
235 spin_unlock_irqrestore(&rxq->lock, flags);
236 iwl_rx_queue_update_write_ptr(priv, rxq);
237 }
238}
239
240/**
241 * iwlagn_rx_replenish - Move all used packet from rx_used to rx_free
242 *
243 * When moving to rx_free an SKB is allocated for the slot.
244 *
245 * Also restock the Rx queue via iwl_rx_queue_restock.
246 * This is called as a scheduled work item (except for during initialization)
247 */
248static void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority)
249{
250 struct iwl_rx_queue *rxq = &priv->rxq;
251 struct list_head *element;
252 struct iwl_rx_mem_buffer *rxb;
253 struct page *page;
254 unsigned long flags;
255 gfp_t gfp_mask = priority;
256
257 while (1) {
258 spin_lock_irqsave(&rxq->lock, flags);
259 if (list_empty(&rxq->rx_used)) {
260 spin_unlock_irqrestore(&rxq->lock, flags);
261 return;
262 }
263 spin_unlock_irqrestore(&rxq->lock, flags);
264
265 if (rxq->free_count > RX_LOW_WATERMARK)
266 gfp_mask |= __GFP_NOWARN;
267
268 if (priv->hw_params.rx_page_order > 0)
269 gfp_mask |= __GFP_COMP;
270
271 /* Alloc a new receive buffer */
272 page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order);
273 if (!page) {
274 if (net_ratelimit())
275 IWL_DEBUG_INFO(priv, "alloc_pages failed, "
276 "order: %d\n",
277 priv->hw_params.rx_page_order);
278
279 if ((rxq->free_count <= RX_LOW_WATERMARK) &&
280 net_ratelimit())
281 IWL_CRIT(priv, "Failed to alloc_pages with %s."
282 "Only %u free buffers remaining.\n",
283 priority == GFP_ATOMIC ?
284 "GFP_ATOMIC" : "GFP_KERNEL",
285 rxq->free_count);
286 /* We don't reschedule replenish work here -- we will
287 * call the restock method and if it still needs
288 * more buffers it will schedule replenish */
289 return;
290 }
291
292 spin_lock_irqsave(&rxq->lock, flags);
293
294 if (list_empty(&rxq->rx_used)) {
295 spin_unlock_irqrestore(&rxq->lock, flags);
296 __free_pages(page, priv->hw_params.rx_page_order);
297 return;
298 }
299 element = rxq->rx_used.next;
300 rxb = list_entry(element, struct iwl_rx_mem_buffer, list);
301 list_del(element);
302
303 spin_unlock_irqrestore(&rxq->lock, flags);
304
305 BUG_ON(rxb->page);
306 rxb->page = page;
307 /* Get physical address of the RB */
308 rxb->page_dma = dma_map_page(priv->bus->dev, page, 0,
309 PAGE_SIZE << priv->hw_params.rx_page_order,
310 DMA_FROM_DEVICE);
311 /* dma address must be no more than 36 bits */
312 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36));
313 /* and also 256 byte aligned! */
314 BUG_ON(rxb->page_dma & DMA_BIT_MASK(8));
315
316 spin_lock_irqsave(&rxq->lock, flags);
317
318 list_add_tail(&rxb->list, &rxq->rx_free);
319 rxq->free_count++;
320
321 spin_unlock_irqrestore(&rxq->lock, flags);
322 }
323}
324
325void iwlagn_rx_replenish(struct iwl_priv *priv)
326{
327 unsigned long flags;
328
329 iwlagn_rx_allocate(priv, GFP_KERNEL);
330
331 spin_lock_irqsave(&priv->lock, flags);
332 iwlagn_rx_queue_restock(priv);
333 spin_unlock_irqrestore(&priv->lock, flags);
334}
335
336static void iwlagn_rx_replenish_now(struct iwl_priv *priv)
337{
338 iwlagn_rx_allocate(priv, GFP_ATOMIC);
339
340 iwlagn_rx_queue_restock(priv);
341}
342
343void iwl_bg_rx_replenish(struct work_struct *data)
344{
345 struct iwl_priv *priv =
346 container_of(data, struct iwl_priv, rx_replenish);
347
348 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
349 return;
350
351 mutex_lock(&priv->mutex);
352 iwlagn_rx_replenish(priv);
353 mutex_unlock(&priv->mutex);
354}
355
356/**
357 * iwl_rx_handle - Main entry function for receiving responses from uCode
358 *
359 * Uses the priv->rx_handlers callback function array to invoke
360 * the appropriate handlers, including command responses,
361 * frame-received notifications, and other notifications.
362 */
363static void iwl_rx_handle(struct iwl_priv *priv)
364{
365 struct iwl_rx_mem_buffer *rxb;
366 struct iwl_rx_packet *pkt;
367 struct iwl_rx_queue *rxq = &priv->rxq;
368 u32 r, i;
369 int reclaim;
370 unsigned long flags;
371 u8 fill_rx = 0;
372 u32 count = 8;
373 int total_empty;
374
375 /* uCode's read index (stored in shared DRAM) indicates the last Rx
376 * buffer that the driver may process (last buffer filled by ucode). */
377 r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF;
378 i = rxq->read;
379
380 /* Rx interrupt, but nothing sent from uCode */
381 if (i == r)
382 IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i);
383
384 /* calculate total frames need to be restock after handling RX */
385 total_empty = r - rxq->write_actual;
386 if (total_empty < 0)
387 total_empty += RX_QUEUE_SIZE;
388
389 if (total_empty > (RX_QUEUE_SIZE / 2))
390 fill_rx = 1;
391
392 while (i != r) {
393 int len;
394
395 rxb = rxq->queue[i];
396
397 /* If an RXB doesn't have a Rx queue slot associated with it,
398 * then a bug has been introduced in the queue refilling
399 * routines -- catch it here */
400 if (WARN_ON(rxb == NULL)) {
401 i = (i + 1) & RX_QUEUE_MASK;
402 continue;
403 }
404
405 rxq->queue[i] = NULL;
406
407 dma_unmap_page(priv->bus->dev, rxb->page_dma,
408 PAGE_SIZE << priv->hw_params.rx_page_order,
409 DMA_FROM_DEVICE);
410 pkt = rxb_addr(rxb);
411
412 IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r,
413 i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
414
415 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
416 len += sizeof(u32); /* account for status word */
417 trace_iwlwifi_dev_rx(priv, pkt, len);
418
419 /* Reclaim a command buffer only if this packet is a response
420 * to a (driver-originated) command.
421 * If the packet (e.g. Rx frame) originated from uCode,
422 * there is no command buffer to reclaim.
423 * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
424 * but apparently a few don't get set; catch them here. */
425 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
426 (pkt->hdr.cmd != REPLY_RX_PHY_CMD) &&
427 (pkt->hdr.cmd != REPLY_RX) &&
428 (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) &&
429 (pkt->hdr.cmd != REPLY_COMPRESSED_BA) &&
430 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
431 (pkt->hdr.cmd != REPLY_TX);
432
433 iwl_rx_dispatch(priv, rxb);
434
435 /*
436 * XXX: After here, we should always check rxb->page
437 * against NULL before touching it or its virtual
438 * memory (pkt). Because some rx_handler might have
439 * already taken or freed the pages.
440 */
441
442 if (reclaim) {
443 /* Invoke any callbacks, transfer the buffer to caller,
444 * and fire off the (possibly) blocking
445 * trans_send_cmd()
446 * as we reclaim the driver command queue */
447 if (rxb->page)
448 iwl_tx_cmd_complete(priv, rxb);
449 else
450 IWL_WARN(priv, "Claim null rxb?\n");
451 }
452
453 /* Reuse the page if possible. For notification packets and
454 * SKBs that fail to Rx correctly, add them back into the
455 * rx_free list for reuse later. */
456 spin_lock_irqsave(&rxq->lock, flags);
457 if (rxb->page != NULL) {
458 rxb->page_dma = dma_map_page(priv->bus->dev, rxb->page,
459 0, PAGE_SIZE << priv->hw_params.rx_page_order,
460 DMA_FROM_DEVICE);
461 list_add_tail(&rxb->list, &rxq->rx_free);
462 rxq->free_count++;
463 } else
464 list_add_tail(&rxb->list, &rxq->rx_used);
465
466 spin_unlock_irqrestore(&rxq->lock, flags);
467
468 i = (i + 1) & RX_QUEUE_MASK;
469 /* If there are a lot of unused frames,
470 * restock the Rx queue so ucode wont assert. */
471 if (fill_rx) {
472 count++;
473 if (count >= 8) {
474 rxq->read = i;
475 iwlagn_rx_replenish_now(priv);
476 count = 0;
477 }
478 }
479 }
480
481 /* Backtrack one entry */
482 rxq->read = i;
483 if (fill_rx)
484 iwlagn_rx_replenish_now(priv);
485 else
486 iwlagn_rx_queue_restock(priv);
487}
488
489/* tasklet for iwlagn interrupt */
490void iwl_irq_tasklet(struct iwl_priv *priv)
491{
492 u32 inta = 0;
493 u32 handled = 0;
494 unsigned long flags;
495 u32 i;
496#ifdef CONFIG_IWLWIFI_DEBUG
497 u32 inta_mask;
498#endif
499
500 spin_lock_irqsave(&priv->lock, flags);
501
502 /* Ack/clear/reset pending uCode interrupts.
503 * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
504 */
505 /* There is a hardware bug in the interrupt mask function that some
506 * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if
507 * they are disabled in the CSR_INT_MASK register. Furthermore the
508 * ICT interrupt handling mechanism has another bug that might cause
509 * these unmasked interrupts fail to be detected. We workaround the
510 * hardware bugs here by ACKing all the possible interrupts so that
511 * interrupt coalescing can still be achieved.
512 */
513 iwl_write32(priv, CSR_INT, priv->inta | ~priv->inta_mask);
514
515 inta = priv->inta;
516
517#ifdef CONFIG_IWLWIFI_DEBUG
518 if (iwl_get_debug_level(priv) & IWL_DL_ISR) {
519 /* just for debug */
520 inta_mask = iwl_read32(priv, CSR_INT_MASK);
521 IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x\n ",
522 inta, inta_mask);
523 }
524#endif
525
526 spin_unlock_irqrestore(&priv->lock, flags);
527
528 /* saved interrupt in inta variable now we can reset priv->inta */
529 priv->inta = 0;
530
531 /* Now service all interrupt bits discovered above. */
532 if (inta & CSR_INT_BIT_HW_ERR) {
533 IWL_ERR(priv, "Hardware error detected. Restarting.\n");
534
535 /* Tell the device to stop sending interrupts */
536 iwl_disable_interrupts(priv);
537
538 priv->isr_stats.hw++;
539 iwl_irq_handle_error(priv);
540
541 handled |= CSR_INT_BIT_HW_ERR;
542
543 return;
544 }
545
546#ifdef CONFIG_IWLWIFI_DEBUG
547 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
548 /* NIC fires this, but we don't use it, redundant with WAKEUP */
549 if (inta & CSR_INT_BIT_SCD) {
550 IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
551 "the frame/frames.\n");
552 priv->isr_stats.sch++;
553 }
554
555 /* Alive notification via Rx interrupt will do the real work */
556 if (inta & CSR_INT_BIT_ALIVE) {
557 IWL_DEBUG_ISR(priv, "Alive interrupt\n");
558 priv->isr_stats.alive++;
559 }
560 }
561#endif
562 /* Safely ignore these bits for debug checks below */
563 inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
564
565 /* HW RF KILL switch toggled */
566 if (inta & CSR_INT_BIT_RF_KILL) {
567 int hw_rf_kill = 0;
568 if (!(iwl_read32(priv, CSR_GP_CNTRL) &
569 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
570 hw_rf_kill = 1;
571
572 IWL_WARN(priv, "RF_KILL bit toggled to %s.\n",
573 hw_rf_kill ? "disable radio" : "enable radio");
574
575 priv->isr_stats.rfkill++;
576
577 /* driver only loads ucode once setting the interface up.
578 * the driver allows loading the ucode even if the radio
579 * is killed. Hence update the killswitch state here. The
580 * rfkill handler will care about restarting if needed.
581 */
582 if (!test_bit(STATUS_ALIVE, &priv->status)) {
583 if (hw_rf_kill)
584 set_bit(STATUS_RF_KILL_HW, &priv->status);
585 else
586 clear_bit(STATUS_RF_KILL_HW, &priv->status);
587 wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rf_kill);
588 }
589
590 handled |= CSR_INT_BIT_RF_KILL;
591 }
592
593 /* Chip got too hot and stopped itself */
594 if (inta & CSR_INT_BIT_CT_KILL) {
595 IWL_ERR(priv, "Microcode CT kill error detected.\n");
596 priv->isr_stats.ctkill++;
597 handled |= CSR_INT_BIT_CT_KILL;
598 }
599
600 /* Error detected by uCode */
601 if (inta & CSR_INT_BIT_SW_ERR) {
602 IWL_ERR(priv, "Microcode SW error detected. "
603 " Restarting 0x%X.\n", inta);
604 priv->isr_stats.sw++;
605 iwl_irq_handle_error(priv);
606 handled |= CSR_INT_BIT_SW_ERR;
607 }
608
609 /* uCode wakes up after power-down sleep */
610 if (inta & CSR_INT_BIT_WAKEUP) {
611 IWL_DEBUG_ISR(priv, "Wakeup interrupt\n");
612 iwl_rx_queue_update_write_ptr(priv, &priv->rxq);
613 for (i = 0; i < priv->hw_params.max_txq_num; i++)
614 iwl_txq_update_write_ptr(priv, &priv->txq[i]);
615
616 priv->isr_stats.wakeup++;
617
618 handled |= CSR_INT_BIT_WAKEUP;
619 }
620
621 /* All uCode command responses, including Tx command responses,
622 * Rx "responses" (frame-received notification), and other
623 * notifications from uCode come through here*/
624 if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX |
625 CSR_INT_BIT_RX_PERIODIC)) {
626 IWL_DEBUG_ISR(priv, "Rx interrupt\n");
627 if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) {
628 handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX);
629 iwl_write32(priv, CSR_FH_INT_STATUS,
630 CSR_FH_INT_RX_MASK);
631 }
632 if (inta & CSR_INT_BIT_RX_PERIODIC) {
633 handled |= CSR_INT_BIT_RX_PERIODIC;
634 iwl_write32(priv, CSR_INT, CSR_INT_BIT_RX_PERIODIC);
635 }
636 /* Sending RX interrupt require many steps to be done in the
637 * the device:
638 * 1- write interrupt to current index in ICT table.
639 * 2- dma RX frame.
640 * 3- update RX shared data to indicate last write index.
641 * 4- send interrupt.
642 * This could lead to RX race, driver could receive RX interrupt
643 * but the shared data changes does not reflect this;
644 * periodic interrupt will detect any dangling Rx activity.
645 */
646
647 /* Disable periodic interrupt; we use it as just a one-shot. */
648 iwl_write8(priv, CSR_INT_PERIODIC_REG,
649 CSR_INT_PERIODIC_DIS);
650 iwl_rx_handle(priv);
651
652 /*
653 * Enable periodic interrupt in 8 msec only if we received
654 * real RX interrupt (instead of just periodic int), to catch
655 * any dangling Rx interrupt. If it was just the periodic
656 * interrupt, there was no dangling Rx activity, and no need
657 * to extend the periodic interrupt; one-shot is enough.
658 */
659 if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX))
660 iwl_write8(priv, CSR_INT_PERIODIC_REG,
661 CSR_INT_PERIODIC_ENA);
662
663 priv->isr_stats.rx++;
664 }
665
666 /* This "Tx" DMA channel is used only for loading uCode */
667 if (inta & CSR_INT_BIT_FH_TX) {
668 iwl_write32(priv, CSR_FH_INT_STATUS, CSR_FH_INT_TX_MASK);
669 IWL_DEBUG_ISR(priv, "uCode load interrupt\n");
670 priv->isr_stats.tx++;
671 handled |= CSR_INT_BIT_FH_TX;
672 /* Wake up uCode load routine, now that load is complete */
673 priv->ucode_write_complete = 1;
674 wake_up_interruptible(&priv->wait_command_queue);
675 }
676
677 if (inta & ~handled) {
678 IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled);
679 priv->isr_stats.unhandled++;
680 }
681
682 if (inta & ~(priv->inta_mask)) {
683 IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n",
684 inta & ~priv->inta_mask);
685 }
686
687 /* Re-enable all interrupts */
688 /* only Re-enable if disabled by irq */
689 if (test_bit(STATUS_INT_ENABLED, &priv->status))
690 iwl_enable_interrupts(priv);
691 /* Re-enable RF_KILL if it occurred */
692 else if (handled & CSR_INT_BIT_RF_KILL)
693 iwl_enable_rfkill_int(priv);
694}
695
696/******************************************************************************
697 *
698 * ICT functions
699 *
700 ******************************************************************************/
701#define ICT_COUNT (PAGE_SIZE/sizeof(u32))
702
703/* Free dram table */
704void iwl_free_isr_ict(struct iwl_priv *priv)
705{
706 if (priv->ict_tbl_vir) {
707 dma_free_coherent(priv->bus->dev,
708 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
709 priv->ict_tbl_vir,
710 priv->ict_tbl_dma);
711 priv->ict_tbl_vir = NULL;
712 memset(&priv->ict_tbl_dma, 0,
713 sizeof(priv->ict_tbl_dma));
714 memset(&priv->aligned_ict_tbl_dma, 0,
715 sizeof(priv->aligned_ict_tbl_dma));
716 }
717}
718
719
720/* allocate dram shared table it is a PAGE_SIZE aligned
721 * also reset all data related to ICT table interrupt.
722 */
723int iwl_alloc_isr_ict(struct iwl_priv *priv)
724{
725
726 /* allocate shrared data table */
727 priv->ict_tbl_vir =
728 dma_alloc_coherent(priv->bus->dev,
729 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
730 &priv->ict_tbl_dma, GFP_KERNEL);
731 if (!priv->ict_tbl_vir)
732 return -ENOMEM;
733
734 /* align table to PAGE_SIZE boundary */
735 priv->aligned_ict_tbl_dma =
736 ALIGN(priv->ict_tbl_dma, PAGE_SIZE);
737
738 IWL_DEBUG_ISR(priv, "ict dma addr %Lx dma aligned %Lx diff %d\n",
739 (unsigned long long)priv->ict_tbl_dma,
740 (unsigned long long)priv->aligned_ict_tbl_dma,
741 (int)(priv->aligned_ict_tbl_dma -
742 priv->ict_tbl_dma));
743
744 priv->ict_tbl = priv->ict_tbl_vir +
745 (priv->aligned_ict_tbl_dma -
746 priv->ict_tbl_dma);
747
748 IWL_DEBUG_ISR(priv, "ict vir addr %p vir aligned %p diff %d\n",
749 priv->ict_tbl, priv->ict_tbl_vir,
750 (int)(priv->aligned_ict_tbl_dma -
751 priv->ict_tbl_dma));
752
753 /* reset table and index to all 0 */
754 memset(priv->ict_tbl_vir, 0,
755 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE);
756 priv->ict_index = 0;
757
758 /* add periodic RX interrupt */
759 priv->inta_mask |= CSR_INT_BIT_RX_PERIODIC;
760 return 0;
761}
762
763/* Device is going up inform it about using ICT interrupt table,
764 * also we need to tell the driver to start using ICT interrupt.
765 */
766int iwl_reset_ict(struct iwl_priv *priv)
767{
768 u32 val;
769 unsigned long flags;
770
771 if (!priv->ict_tbl_vir)
772 return 0;
773
774 spin_lock_irqsave(&priv->lock, flags);
775 iwl_disable_interrupts(priv);
776
777 memset(&priv->ict_tbl[0], 0, sizeof(u32) * ICT_COUNT);
778
779 val = priv->aligned_ict_tbl_dma >> PAGE_SHIFT;
780
781 val |= CSR_DRAM_INT_TBL_ENABLE;
782 val |= CSR_DRAM_INIT_TBL_WRAP_CHECK;
783
784 IWL_DEBUG_ISR(priv, "CSR_DRAM_INT_TBL_REG =0x%X "
785 "aligned dma address %Lx\n",
786 val,
787 (unsigned long long)priv->aligned_ict_tbl_dma);
788
789 iwl_write32(priv, CSR_DRAM_INT_TBL_REG, val);
790 priv->use_ict = true;
791 priv->ict_index = 0;
792 iwl_write32(priv, CSR_INT, priv->inta_mask);
793 iwl_enable_interrupts(priv);
794 spin_unlock_irqrestore(&priv->lock, flags);
795
796 return 0;
797}
798
799/* Device is going down disable ict interrupt usage */
800void iwl_disable_ict(struct iwl_priv *priv)
801{
802 unsigned long flags;
803
804 spin_lock_irqsave(&priv->lock, flags);
805 priv->use_ict = false;
806 spin_unlock_irqrestore(&priv->lock, flags);
807}
808
809static irqreturn_t iwl_isr(int irq, void *data)
810{
811 struct iwl_priv *priv = data;
812 u32 inta, inta_mask;
813 unsigned long flags;
814#ifdef CONFIG_IWLWIFI_DEBUG
815 u32 inta_fh;
816#endif
817 if (!priv)
818 return IRQ_NONE;
819
820 spin_lock_irqsave(&priv->lock, flags);
821
822 /* Disable (but don't clear!) interrupts here to avoid
823 * back-to-back ISRs and sporadic interrupts from our NIC.
824 * If we have something to service, the tasklet will re-enable ints.
825 * If we *don't* have something, we'll re-enable before leaving here. */
826 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
827 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
828
829 /* Discover which interrupts are active/pending */
830 inta = iwl_read32(priv, CSR_INT);
831
832 /* Ignore interrupt if there's nothing in NIC to service.
833 * This may be due to IRQ shared with another device,
834 * or due to sporadic interrupts thrown from our NIC. */
835 if (!inta) {
836 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
837 goto none;
838 }
839
840 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
841 /* Hardware disappeared. It might have already raised
842 * an interrupt */
843 IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
844 goto unplugged;
845 }
846
847#ifdef CONFIG_IWLWIFI_DEBUG
848 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
849 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
850 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, "
851 "fh 0x%08x\n", inta, inta_mask, inta_fh);
852 }
853#endif
854
855 priv->inta |= inta;
856 /* iwl_irq_tasklet() will service interrupts and re-enable them */
857 if (likely(inta))
858 tasklet_schedule(&priv->irq_tasklet);
859 else if (test_bit(STATUS_INT_ENABLED, &priv->status) &&
860 !priv->inta)
861 iwl_enable_interrupts(priv);
862
863 unplugged:
864 spin_unlock_irqrestore(&priv->lock, flags);
865 return IRQ_HANDLED;
866
867 none:
868 /* re-enable interrupts here since we don't have anything to service. */
869 /* only Re-enable if disabled by irq and no schedules tasklet. */
870 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
871 iwl_enable_interrupts(priv);
872
873 spin_unlock_irqrestore(&priv->lock, flags);
874 return IRQ_NONE;
875}
876
877/* interrupt handler using ict table, with this interrupt driver will
878 * stop using INTA register to get device's interrupt, reading this register
879 * is expensive, device will write interrupts in ICT dram table, increment
880 * index then will fire interrupt to driver, driver will OR all ICT table
881 * entries from current index up to table entry with 0 value. the result is
882 * the interrupt we need to service, driver will set the entries back to 0 and
883 * set index.
884 */
885irqreturn_t iwl_isr_ict(int irq, void *data)
886{
887 struct iwl_priv *priv = data;
888 u32 inta, inta_mask;
889 u32 val = 0;
890 unsigned long flags;
891
892 if (!priv)
893 return IRQ_NONE;
894
895 /* dram interrupt table not set yet,
896 * use legacy interrupt.
897 */
898 if (!priv->use_ict)
899 return iwl_isr(irq, data);
900
901 spin_lock_irqsave(&priv->lock, flags);
902
903 /* Disable (but don't clear!) interrupts here to avoid
904 * back-to-back ISRs and sporadic interrupts from our NIC.
905 * If we have something to service, the tasklet will re-enable ints.
906 * If we *don't* have something, we'll re-enable before leaving here.
907 */
908 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
909 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
910
911
912 /* Ignore interrupt if there's nothing in NIC to service.
913 * This may be due to IRQ shared with another device,
914 * or due to sporadic interrupts thrown from our NIC. */
915 if (!priv->ict_tbl[priv->ict_index]) {
916 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
917 goto none;
918 }
919
920 /* read all entries that not 0 start with ict_index */
921 while (priv->ict_tbl[priv->ict_index]) {
922
923 val |= le32_to_cpu(priv->ict_tbl[priv->ict_index]);
924 IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n",
925 priv->ict_index,
926 le32_to_cpu(
927 priv->ict_tbl[priv->ict_index]));
928 priv->ict_tbl[priv->ict_index] = 0;
929 priv->ict_index = iwl_queue_inc_wrap(priv->ict_index,
930 ICT_COUNT);
931
932 }
933
934 /* We should not get this value, just ignore it. */
935 if (val == 0xffffffff)
936 val = 0;
937
938 /*
939 * this is a w/a for a h/w bug. the h/w bug may cause the Rx bit
940 * (bit 15 before shifting it to 31) to clear when using interrupt
941 * coalescing. fortunately, bits 18 and 19 stay set when this happens
942 * so we use them to decide on the real state of the Rx bit.
943 * In order words, bit 15 is set if bit 18 or bit 19 are set.
944 */
945 if (val & 0xC0000)
946 val |= 0x8000;
947
948 inta = (0xff & val) | ((0xff00 & val) << 16);
949 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x ict 0x%08x\n",
950 inta, inta_mask, val);
951
952 inta &= priv->inta_mask;
953 priv->inta |= inta;
954
955 /* iwl_irq_tasklet() will service interrupts and re-enable them */
956 if (likely(inta))
957 tasklet_schedule(&priv->irq_tasklet);
958 else if (test_bit(STATUS_INT_ENABLED, &priv->status) &&
959 !priv->inta) {
960 /* Allow interrupt if was disabled by this handler and
961 * no tasklet was schedules, We should not enable interrupt,
962 * tasklet will enable it.
963 */
964 iwl_enable_interrupts(priv);
965 }
966
967 spin_unlock_irqrestore(&priv->lock, flags);
968 return IRQ_HANDLED;
969
970 none:
971 /* re-enable interrupts here since we don't have anything to service.
972 * only Re-enable if disabled by irq.
973 */
974 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
975 iwl_enable_interrupts(priv);
976
977 spin_unlock_irqrestore(&priv->lock, flags);
978 return IRQ_NONE;
979}
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
index 9b07e07f1689..a6b2b1db0b1d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
@@ -26,18 +26,58 @@
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29
30#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
31#include <linux/sched.h>
32#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/sched.h>
33#include <net/mac80211.h> 32#include <net/mac80211.h>
34#include "iwl-eeprom.h" 33
35#include "iwl-agn.h" 34#include "iwl-agn.h"
36#include "iwl-dev.h" 35#include "iwl-dev.h"
37#include "iwl-core.h" 36#include "iwl-core.h"
38#include "iwl-sta.h"
39#include "iwl-io.h" 37#include "iwl-io.h"
40#include "iwl-helpers.h" 38#include "iwl-helpers.h"
39#include "iwl-trans-int-pcie.h"
40
41/**
42 * iwl_trans_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
43 */
44void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
45 struct iwl_tx_queue *txq,
46 u16 byte_cnt)
47{
48 struct iwlagn_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
49 int write_ptr = txq->q.write_ptr;
50 int txq_id = txq->q.id;
51 u8 sec_ctl = 0;
52 u8 sta_id = 0;
53 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
54 __le16 bc_ent;
55
56 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
57
58 sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
59 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
60
61 switch (sec_ctl & TX_CMD_SEC_MSK) {
62 case TX_CMD_SEC_CCM:
63 len += CCMP_MIC_LEN;
64 break;
65 case TX_CMD_SEC_TKIP:
66 len += TKIP_ICV_LEN;
67 break;
68 case TX_CMD_SEC_WEP:
69 len += WEP_IV_LEN + WEP_ICV_LEN;
70 break;
71 }
72
73 bc_ent = cpu_to_le16((len & 0xFFF) | (sta_id << 12));
74
75 scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
76
77 if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
78 scd_bc_tbl[txq_id].
79 tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
80}
41 81
42/** 82/**
43 * iwl_txq_update_write_ptr - Send new write index to hardware 83 * iwl_txq_update_write_ptr - Send new write index to hardware
@@ -126,7 +166,7 @@ static inline u8 iwl_tfd_get_num_tbs(struct iwl_tfd *tfd)
126} 166}
127 167
128static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta, 168static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta,
129 struct iwl_tfd *tfd, enum dma_data_direction dma_dir) 169 struct iwl_tfd *tfd, enum dma_data_direction dma_dir)
130{ 170{
131 int i; 171 int i;
132 int num_tbs; 172 int num_tbs;
@@ -142,14 +182,14 @@ static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta,
142 182
143 /* Unmap tx_cmd */ 183 /* Unmap tx_cmd */
144 if (num_tbs) 184 if (num_tbs)
145 dma_unmap_single(priv->bus.dev, 185 dma_unmap_single(priv->bus->dev,
146 dma_unmap_addr(meta, mapping), 186 dma_unmap_addr(meta, mapping),
147 dma_unmap_len(meta, len), 187 dma_unmap_len(meta, len),
148 DMA_BIDIRECTIONAL); 188 DMA_BIDIRECTIONAL);
149 189
150 /* Unmap chunks, if any. */ 190 /* Unmap chunks, if any. */
151 for (i = 1; i < num_tbs; i++) 191 for (i = 1; i < num_tbs; i++)
152 dma_unmap_single(priv->bus.dev, iwl_tfd_tb_get_addr(tfd, i), 192 dma_unmap_single(priv->bus->dev, iwl_tfd_tb_get_addr(tfd, i),
153 iwl_tfd_tb_get_len(tfd, i), dma_dir); 193 iwl_tfd_tb_get_len(tfd, i), dma_dir);
154} 194}
155 195
@@ -292,6 +332,187 @@ int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
292 return 0; 332 return 0;
293} 333}
294 334
335/*TODO: this functions should NOT be exported from trans module - export it
336 * until the reclaim flow will be brought to the transport module too.
337 * Add a declaration to make sparse happy */
338void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
339 struct iwl_tx_queue *txq);
340
341void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
342 struct iwl_tx_queue *txq)
343{
344 struct iwlagn_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
345 int txq_id = txq->q.id;
346 int read_ptr = txq->q.read_ptr;
347 u8 sta_id = 0;
348 __le16 bc_ent;
349
350 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
351
352 if (txq_id != priv->cmd_queue)
353 sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
354
355 bc_ent = cpu_to_le16(1 | (sta_id << 12));
356 scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent;
357
358 if (read_ptr < TFD_QUEUE_SIZE_BC_DUP)
359 scd_bc_tbl[txq_id].
360 tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = bc_ent;
361}
362
363static int iwlagn_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
364 u16 txq_id)
365{
366 u32 tbl_dw_addr;
367 u32 tbl_dw;
368 u16 scd_q2ratid;
369
370 scd_q2ratid = ra_tid & SCD_QUEUE_RA_TID_MAP_RATID_MSK;
371
372 tbl_dw_addr = priv->scd_base_addr +
373 SCD_TRANS_TBL_OFFSET_QUEUE(txq_id);
374
375 tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
376
377 if (txq_id & 0x1)
378 tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
379 else
380 tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
381
382 iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
383
384 return 0;
385}
386
387static void iwlagn_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
388{
389 /* Simply stop the queue, but don't change any configuration;
390 * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
391 iwl_write_prph(priv,
392 SCD_QUEUE_STATUS_BITS(txq_id),
393 (0 << SCD_QUEUE_STTS_REG_POS_ACTIVE)|
394 (1 << SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
395}
396
397void iwl_trans_set_wr_ptrs(struct iwl_priv *priv,
398 int txq_id, u32 index)
399{
400 iwl_write_direct32(priv, HBUS_TARG_WRPTR,
401 (index & 0xff) | (txq_id << 8));
402 iwl_write_prph(priv, SCD_QUEUE_RDPTR(txq_id), index);
403}
404
405void iwl_trans_tx_queue_set_status(struct iwl_priv *priv,
406 struct iwl_tx_queue *txq,
407 int tx_fifo_id, int scd_retry)
408{
409 int txq_id = txq->q.id;
410 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
411
412 iwl_write_prph(priv, SCD_QUEUE_STATUS_BITS(txq_id),
413 (active << SCD_QUEUE_STTS_REG_POS_ACTIVE) |
414 (tx_fifo_id << SCD_QUEUE_STTS_REG_POS_TXF) |
415 (1 << SCD_QUEUE_STTS_REG_POS_WSL) |
416 SCD_QUEUE_STTS_REG_MSK);
417
418 txq->sched_retry = scd_retry;
419
420 IWL_DEBUG_INFO(priv, "%s %s Queue %d on FIFO %d\n",
421 active ? "Activate" : "Deactivate",
422 scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id);
423}
424
425void iwl_trans_txq_agg_setup(struct iwl_priv *priv, int sta_id, int tid,
426 int frame_limit)
427{
428 int tx_fifo, txq_id, ssn_idx;
429 u16 ra_tid;
430 unsigned long flags;
431 struct iwl_tid_data *tid_data;
432
433 if (WARN_ON(sta_id == IWL_INVALID_STATION))
434 return;
435 if (WARN_ON(tid >= MAX_TID_COUNT))
436 return;
437
438 spin_lock_irqsave(&priv->sta_lock, flags);
439 tid_data = &priv->stations[sta_id].tid[tid];
440 ssn_idx = SEQ_TO_SN(tid_data->seq_number);
441 txq_id = tid_data->agg.txq_id;
442 tx_fifo = tid_data->agg.tx_fifo;
443 spin_unlock_irqrestore(&priv->sta_lock, flags);
444
445 ra_tid = BUILD_RAxTID(sta_id, tid);
446
447 spin_lock_irqsave(&priv->lock, flags);
448
449 /* Stop this Tx queue before configuring it */
450 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
451
452 /* Map receiver-address / traffic-ID to this queue */
453 iwlagn_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
454
455 /* Set this queue as a chain-building queue */
456 iwl_set_bits_prph(priv, SCD_QUEUECHAIN_SEL, (1<<txq_id));
457
458 /* enable aggregations for the queue */
459 iwl_set_bits_prph(priv, SCD_AGGR_SEL, (1<<txq_id));
460
461 /* Place first TFD at index corresponding to start sequence number.
462 * Assumes that ssn_idx is valid (!= 0xFFF) */
463 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
464 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
465 iwl_trans_set_wr_ptrs(priv, txq_id, ssn_idx);
466
467 /* Set up Tx window size and frame limit for this queue */
468 iwl_write_targ_mem(priv, priv->scd_base_addr +
469 SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
470 sizeof(u32),
471 ((frame_limit <<
472 SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
473 SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
474 ((frame_limit <<
475 SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
476 SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
477
478 iwl_set_bits_prph(priv, SCD_INTERRUPT_MASK, (1 << txq_id));
479
480 /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
481 iwl_trans_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
482
483 spin_unlock_irqrestore(&priv->lock, flags);
484}
485
486int iwl_trans_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
487 u16 ssn_idx, u8 tx_fifo)
488{
489 if ((IWLAGN_FIRST_AMPDU_QUEUE > txq_id) ||
490 (IWLAGN_FIRST_AMPDU_QUEUE +
491 priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) {
492 IWL_ERR(priv,
493 "queue number out of range: %d, must be %d to %d\n",
494 txq_id, IWLAGN_FIRST_AMPDU_QUEUE,
495 IWLAGN_FIRST_AMPDU_QUEUE +
496 priv->cfg->base_params->num_of_ampdu_queues - 1);
497 return -EINVAL;
498 }
499
500 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
501
502 iwl_clear_bits_prph(priv, SCD_AGGR_SEL, (1 << txq_id));
503
504 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
505 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
506 /* supposes that ssn_idx is valid (!= 0xFFF) */
507 iwl_trans_set_wr_ptrs(priv, txq_id, ssn_idx);
508
509 iwl_clear_bits_prph(priv, SCD_INTERRUPT_MASK, (1 << txq_id));
510 iwl_txq_ctx_deactivate(priv, txq_id);
511 iwl_trans_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
512
513 return 0;
514}
515
295/*************** HOST COMMAND QUEUE FUNCTIONS *****/ 516/*************** HOST COMMAND QUEUE FUNCTIONS *****/
296 517
297/** 518/**
@@ -303,7 +524,7 @@ int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
303 * failed. On success, it turns the index (> 0) of command in the 524 * failed. On success, it turns the index (> 0) of command in the
304 * command queue. 525 * command queue.
305 */ 526 */
306int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) 527static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
307{ 528{
308 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; 529 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
309 struct iwl_queue *q = &txq->q; 530 struct iwl_queue *q = &txq->q;
@@ -419,9 +640,9 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
419 le16_to_cpu(out_cmd->hdr.sequence), cmd_size, 640 le16_to_cpu(out_cmd->hdr.sequence), cmd_size,
420 q->write_ptr, idx, priv->cmd_queue); 641 q->write_ptr, idx, priv->cmd_queue);
421 642
422 phys_addr = dma_map_single(priv->bus.dev, &out_cmd->hdr, copy_size, 643 phys_addr = dma_map_single(priv->bus->dev, &out_cmd->hdr, copy_size,
423 DMA_BIDIRECTIONAL); 644 DMA_BIDIRECTIONAL);
424 if (unlikely(dma_mapping_error(priv->bus.dev, phys_addr))) { 645 if (unlikely(dma_mapping_error(priv->bus->dev, phys_addr))) {
425 idx = -ENOMEM; 646 idx = -ENOMEM;
426 goto out; 647 goto out;
427 } 648 }
@@ -441,9 +662,9 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
441 continue; 662 continue;
442 if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) 663 if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY))
443 continue; 664 continue;
444 phys_addr = dma_map_single(priv->bus.dev, (void *)cmd->data[i], 665 phys_addr = dma_map_single(priv->bus->dev, (void *)cmd->data[i],
445 cmd->len[i], DMA_BIDIRECTIONAL); 666 cmd->len[i], DMA_BIDIRECTIONAL);
446 if (dma_mapping_error(priv->bus.dev, phys_addr)) { 667 if (dma_mapping_error(priv->bus->dev, phys_addr)) {
447 iwlagn_unmap_tfd(priv, out_meta, 668 iwlagn_unmap_tfd(priv, out_meta,
448 &txq->tfds[q->write_ptr], 669 &txq->tfds[q->write_ptr],
449 DMA_BIDIRECTIONAL); 670 DMA_BIDIRECTIONAL);
@@ -574,3 +795,242 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
574 795
575 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 796 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
576} 797}
798
799const char *get_cmd_string(u8 cmd)
800{
801 switch (cmd) {
802 IWL_CMD(REPLY_ALIVE);
803 IWL_CMD(REPLY_ERROR);
804 IWL_CMD(REPLY_RXON);
805 IWL_CMD(REPLY_RXON_ASSOC);
806 IWL_CMD(REPLY_QOS_PARAM);
807 IWL_CMD(REPLY_RXON_TIMING);
808 IWL_CMD(REPLY_ADD_STA);
809 IWL_CMD(REPLY_REMOVE_STA);
810 IWL_CMD(REPLY_REMOVE_ALL_STA);
811 IWL_CMD(REPLY_TXFIFO_FLUSH);
812 IWL_CMD(REPLY_WEPKEY);
813 IWL_CMD(REPLY_TX);
814 IWL_CMD(REPLY_LEDS_CMD);
815 IWL_CMD(REPLY_TX_LINK_QUALITY_CMD);
816 IWL_CMD(COEX_PRIORITY_TABLE_CMD);
817 IWL_CMD(COEX_MEDIUM_NOTIFICATION);
818 IWL_CMD(COEX_EVENT_CMD);
819 IWL_CMD(REPLY_QUIET_CMD);
820 IWL_CMD(REPLY_CHANNEL_SWITCH);
821 IWL_CMD(CHANNEL_SWITCH_NOTIFICATION);
822 IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD);
823 IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION);
824 IWL_CMD(POWER_TABLE_CMD);
825 IWL_CMD(PM_SLEEP_NOTIFICATION);
826 IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC);
827 IWL_CMD(REPLY_SCAN_CMD);
828 IWL_CMD(REPLY_SCAN_ABORT_CMD);
829 IWL_CMD(SCAN_START_NOTIFICATION);
830 IWL_CMD(SCAN_RESULTS_NOTIFICATION);
831 IWL_CMD(SCAN_COMPLETE_NOTIFICATION);
832 IWL_CMD(BEACON_NOTIFICATION);
833 IWL_CMD(REPLY_TX_BEACON);
834 IWL_CMD(WHO_IS_AWAKE_NOTIFICATION);
835 IWL_CMD(QUIET_NOTIFICATION);
836 IWL_CMD(REPLY_TX_PWR_TABLE_CMD);
837 IWL_CMD(MEASURE_ABORT_NOTIFICATION);
838 IWL_CMD(REPLY_BT_CONFIG);
839 IWL_CMD(REPLY_STATISTICS_CMD);
840 IWL_CMD(STATISTICS_NOTIFICATION);
841 IWL_CMD(REPLY_CARD_STATE_CMD);
842 IWL_CMD(CARD_STATE_NOTIFICATION);
843 IWL_CMD(MISSED_BEACONS_NOTIFICATION);
844 IWL_CMD(REPLY_CT_KILL_CONFIG_CMD);
845 IWL_CMD(SENSITIVITY_CMD);
846 IWL_CMD(REPLY_PHY_CALIBRATION_CMD);
847 IWL_CMD(REPLY_RX_PHY_CMD);
848 IWL_CMD(REPLY_RX_MPDU_CMD);
849 IWL_CMD(REPLY_RX);
850 IWL_CMD(REPLY_COMPRESSED_BA);
851 IWL_CMD(CALIBRATION_CFG_CMD);
852 IWL_CMD(CALIBRATION_RES_NOTIFICATION);
853 IWL_CMD(CALIBRATION_COMPLETE_NOTIFICATION);
854 IWL_CMD(REPLY_TX_POWER_DBM_CMD);
855 IWL_CMD(TEMPERATURE_NOTIFICATION);
856 IWL_CMD(TX_ANT_CONFIGURATION_CMD);
857 IWL_CMD(REPLY_BT_COEX_PROFILE_NOTIF);
858 IWL_CMD(REPLY_BT_COEX_PRIO_TABLE);
859 IWL_CMD(REPLY_BT_COEX_PROT_ENV);
860 IWL_CMD(REPLY_WIPAN_PARAMS);
861 IWL_CMD(REPLY_WIPAN_RXON);
862 IWL_CMD(REPLY_WIPAN_RXON_TIMING);
863 IWL_CMD(REPLY_WIPAN_RXON_ASSOC);
864 IWL_CMD(REPLY_WIPAN_QOS_PARAM);
865 IWL_CMD(REPLY_WIPAN_WEPKEY);
866 IWL_CMD(REPLY_WIPAN_P2P_CHANNEL_SWITCH);
867 IWL_CMD(REPLY_WIPAN_NOA_NOTIFICATION);
868 IWL_CMD(REPLY_WIPAN_DEACTIVATION_COMPLETE);
869 IWL_CMD(REPLY_WOWLAN_PATTERNS);
870 IWL_CMD(REPLY_WOWLAN_WAKEUP_FILTER);
871 IWL_CMD(REPLY_WOWLAN_TSC_RSC_PARAMS);
872 IWL_CMD(REPLY_WOWLAN_TKIP_PARAMS);
873 IWL_CMD(REPLY_WOWLAN_KEK_KCK_MATERIAL);
874 IWL_CMD(REPLY_WOWLAN_GET_STATUS);
875 default:
876 return "UNKNOWN";
877
878 }
879}
880
881#define HOST_COMPLETE_TIMEOUT (2 * HZ)
882
883static void iwl_generic_cmd_callback(struct iwl_priv *priv,
884 struct iwl_device_cmd *cmd,
885 struct iwl_rx_packet *pkt)
886{
887 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
888 IWL_ERR(priv, "Bad return from %s (0x%08X)\n",
889 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
890 return;
891 }
892
893#ifdef CONFIG_IWLWIFI_DEBUG
894 switch (cmd->hdr.cmd) {
895 case REPLY_TX_LINK_QUALITY_CMD:
896 case SENSITIVITY_CMD:
897 IWL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n",
898 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
899 break;
900 default:
901 IWL_DEBUG_HC(priv, "back from %s (0x%08X)\n",
902 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
903 }
904#endif
905}
906
907static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
908{
909 int ret;
910
911 /* An asynchronous command can not expect an SKB to be set. */
912 if (WARN_ON(cmd->flags & CMD_WANT_SKB))
913 return -EINVAL;
914
915 /* Assign a generic callback if one is not provided */
916 if (!cmd->callback)
917 cmd->callback = iwl_generic_cmd_callback;
918
919 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
920 return -EBUSY;
921
922 ret = iwl_enqueue_hcmd(priv, cmd);
923 if (ret < 0) {
924 IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n",
925 get_cmd_string(cmd->id), ret);
926 return ret;
927 }
928 return 0;
929}
930
931static int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
932{
933 int cmd_idx;
934 int ret;
935
936 lockdep_assert_held(&priv->mutex);
937
938 /* A synchronous command can not have a callback set. */
939 if (WARN_ON(cmd->callback))
940 return -EINVAL;
941
942 IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
943 get_cmd_string(cmd->id));
944
945 set_bit(STATUS_HCMD_ACTIVE, &priv->status);
946 IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n",
947 get_cmd_string(cmd->id));
948
949 cmd_idx = iwl_enqueue_hcmd(priv, cmd);
950 if (cmd_idx < 0) {
951 ret = cmd_idx;
952 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
953 IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n",
954 get_cmd_string(cmd->id), ret);
955 return ret;
956 }
957
958 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
959 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
960 HOST_COMPLETE_TIMEOUT);
961 if (!ret) {
962 if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) {
963 IWL_ERR(priv,
964 "Error sending %s: time out after %dms.\n",
965 get_cmd_string(cmd->id),
966 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT));
967
968 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
969 IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command"
970 "%s\n", get_cmd_string(cmd->id));
971 ret = -ETIMEDOUT;
972 goto cancel;
973 }
974 }
975
976 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
977 IWL_ERR(priv, "Command %s aborted: RF KILL Switch\n",
978 get_cmd_string(cmd->id));
979 ret = -ECANCELED;
980 goto fail;
981 }
982 if (test_bit(STATUS_FW_ERROR, &priv->status)) {
983 IWL_ERR(priv, "Command %s failed: FW Error\n",
984 get_cmd_string(cmd->id));
985 ret = -EIO;
986 goto fail;
987 }
988 if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) {
989 IWL_ERR(priv, "Error: Response NULL in '%s'\n",
990 get_cmd_string(cmd->id));
991 ret = -EIO;
992 goto cancel;
993 }
994
995 return 0;
996
997cancel:
998 if (cmd->flags & CMD_WANT_SKB) {
999 /*
1000 * Cancel the CMD_WANT_SKB flag for the cmd in the
1001 * TX cmd queue. Otherwise in case the cmd comes
1002 * in later, it will possibly set an invalid
1003 * address (cmd->meta.source).
1004 */
1005 priv->txq[priv->cmd_queue].meta[cmd_idx].flags &=
1006 ~CMD_WANT_SKB;
1007 }
1008fail:
1009 if (cmd->reply_page) {
1010 iwl_free_pages(priv, cmd->reply_page);
1011 cmd->reply_page = 0;
1012 }
1013
1014 return ret;
1015}
1016
1017int iwl_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1018{
1019 if (cmd->flags & CMD_ASYNC)
1020 return iwl_send_cmd_async(priv, cmd);
1021
1022 return iwl_send_cmd_sync(priv, cmd);
1023}
1024
1025int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
1026 const void *data)
1027{
1028 struct iwl_host_cmd cmd = {
1029 .id = id,
1030 .len = { len, },
1031 .data = { data, },
1032 .flags = flags,
1033 };
1034
1035 return iwl_send_cmd(priv, &cmd);
1036}
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c
index d760857c8636..41f0de914008 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.c
@@ -64,6 +64,7 @@
64#include "iwl-trans.h" 64#include "iwl-trans.h"
65#include "iwl-core.h" 65#include "iwl-core.h"
66#include "iwl-helpers.h" 66#include "iwl-helpers.h"
67#include "iwl-trans-int-pcie.h"
67/*TODO remove uneeded includes when the transport layer tx_free will be here */ 68/*TODO remove uneeded includes when the transport layer tx_free will be here */
68#include "iwl-agn.h" 69#include "iwl-agn.h"
69#include "iwl-core.h" 70#include "iwl-core.h"
@@ -71,7 +72,7 @@
71static int iwl_trans_rx_alloc(struct iwl_priv *priv) 72static int iwl_trans_rx_alloc(struct iwl_priv *priv)
72{ 73{
73 struct iwl_rx_queue *rxq = &priv->rxq; 74 struct iwl_rx_queue *rxq = &priv->rxq;
74 struct device *dev = priv->bus.dev; 75 struct device *dev = priv->bus->dev;
75 76
76 memset(&priv->rxq, 0, sizeof(priv->rxq)); 77 memset(&priv->rxq, 0, sizeof(priv->rxq));
77 78
@@ -117,7 +118,7 @@ static void iwl_trans_rxq_free_rx_bufs(struct iwl_priv *priv)
117 /* In the reset function, these buffers may have been allocated 118 /* In the reset function, these buffers may have been allocated
118 * to an SKB, so we need to unmap and free potential storage */ 119 * to an SKB, so we need to unmap and free potential storage */
119 if (rxq->pool[i].page != NULL) { 120 if (rxq->pool[i].page != NULL) {
120 dma_unmap_page(priv->bus.dev, rxq->pool[i].page_dma, 121 dma_unmap_page(priv->bus->dev, rxq->pool[i].page_dma,
121 PAGE_SIZE << priv->hw_params.rx_page_order, 122 PAGE_SIZE << priv->hw_params.rx_page_order,
122 DMA_FROM_DEVICE); 123 DMA_FROM_DEVICE);
123 __iwl_free_pages(priv, rxq->pool[i].page); 124 __iwl_free_pages(priv, rxq->pool[i].page);
@@ -127,7 +128,56 @@ static void iwl_trans_rxq_free_rx_bufs(struct iwl_priv *priv)
127 } 128 }
128} 129}
129 130
130static int iwl_trans_rx_init(struct iwl_priv *priv) 131static void iwl_trans_rx_hw_init(struct iwl_priv *priv,
132 struct iwl_rx_queue *rxq)
133{
134 u32 rb_size;
135 const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */
136 u32 rb_timeout = 0; /* FIXME: RX_RB_TIMEOUT for all devices? */
137
138 rb_timeout = RX_RB_TIMEOUT;
139
140 if (iwlagn_mod_params.amsdu_size_8K)
141 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K;
142 else
143 rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K;
144
145 /* Stop Rx DMA */
146 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
147
148 /* Reset driver's Rx queue write index */
149 iwl_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0);
150
151 /* Tell device where to find RBD circular buffer in DRAM */
152 iwl_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG,
153 (u32)(rxq->bd_dma >> 8));
154
155 /* Tell device where in DRAM to update its Rx status */
156 iwl_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG,
157 rxq->rb_stts_dma >> 4);
158
159 /* Enable Rx DMA
160 * FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set because of HW bug in
161 * the credit mechanism in 5000 HW RX FIFO
162 * Direct rx interrupts to hosts
163 * Rx buffer size 4 or 8k
164 * RB timeout 0x10
165 * 256 RBDs
166 */
167 iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG,
168 FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL |
169 FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY |
170 FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL |
171 FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK |
172 rb_size|
173 (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)|
174 (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS));
175
176 /* Set interrupt coalescing timer to default (2048 usecs) */
177 iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF);
178}
179
180static int iwl_rx_init(struct iwl_priv *priv)
131{ 181{
132 struct iwl_rx_queue *rxq = &priv->rxq; 182 struct iwl_rx_queue *rxq = &priv->rxq;
133 int i, err; 183 int i, err;
@@ -155,6 +205,15 @@ static int iwl_trans_rx_init(struct iwl_priv *priv)
155 rxq->free_count = 0; 205 rxq->free_count = 0;
156 spin_unlock_irqrestore(&rxq->lock, flags); 206 spin_unlock_irqrestore(&rxq->lock, flags);
157 207
208 iwlagn_rx_replenish(priv);
209
210 iwl_trans_rx_hw_init(priv, rxq);
211
212 spin_lock_irqsave(&priv->lock, flags);
213 rxq->need_update = 1;
214 iwl_rx_queue_update_write_ptr(priv, rxq);
215 spin_unlock_irqrestore(&priv->lock, flags);
216
158 return 0; 217 return 0;
159} 218}
160 219
@@ -174,13 +233,13 @@ static void iwl_trans_rx_free(struct iwl_priv *priv)
174 iwl_trans_rxq_free_rx_bufs(priv); 233 iwl_trans_rxq_free_rx_bufs(priv);
175 spin_unlock_irqrestore(&rxq->lock, flags); 234 spin_unlock_irqrestore(&rxq->lock, flags);
176 235
177 dma_free_coherent(priv->bus.dev, sizeof(__le32) * RX_QUEUE_SIZE, 236 dma_free_coherent(priv->bus->dev, sizeof(__le32) * RX_QUEUE_SIZE,
178 rxq->bd, rxq->bd_dma); 237 rxq->bd, rxq->bd_dma);
179 memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma)); 238 memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma));
180 rxq->bd = NULL; 239 rxq->bd = NULL;
181 240
182 if (rxq->rb_stts) 241 if (rxq->rb_stts)
183 dma_free_coherent(priv->bus.dev, 242 dma_free_coherent(priv->bus->dev,
184 sizeof(struct iwl_rb_status), 243 sizeof(struct iwl_rb_status),
185 rxq->rb_stts, rxq->rb_stts_dma); 244 rxq->rb_stts, rxq->rb_stts_dma);
186 else 245 else
@@ -204,7 +263,7 @@ static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv,
204 if (WARN_ON(ptr->addr)) 263 if (WARN_ON(ptr->addr))
205 return -EINVAL; 264 return -EINVAL;
206 265
207 ptr->addr = dma_alloc_coherent(priv->bus.dev, size, 266 ptr->addr = dma_alloc_coherent(priv->bus->dev, size,
208 &ptr->dma, GFP_KERNEL); 267 &ptr->dma, GFP_KERNEL);
209 if (!ptr->addr) 268 if (!ptr->addr)
210 return -ENOMEM; 269 return -ENOMEM;
@@ -218,7 +277,7 @@ static inline void iwlagn_free_dma_ptr(struct iwl_priv *priv,
218 if (unlikely(!ptr->addr)) 277 if (unlikely(!ptr->addr))
219 return; 278 return;
220 279
221 dma_free_coherent(priv->bus.dev, ptr->size, ptr->addr, ptr->dma); 280 dma_free_coherent(priv->bus->dev, ptr->size, ptr->addr, ptr->dma);
222 memset(ptr, 0, sizeof(*ptr)); 281 memset(ptr, 0, sizeof(*ptr));
223} 282}
224 283
@@ -265,7 +324,7 @@ static int iwl_trans_txq_alloc(struct iwl_priv *priv, struct iwl_tx_queue *txq,
265 324
266 /* Circular buffer of transmit frame descriptors (TFDs), 325 /* Circular buffer of transmit frame descriptors (TFDs),
267 * shared with device */ 326 * shared with device */
268 txq->tfds = dma_alloc_coherent(priv->bus.dev, tfd_sz, &txq->q.dma_addr, 327 txq->tfds = dma_alloc_coherent(priv->bus->dev, tfd_sz, &txq->q.dma_addr,
269 GFP_KERNEL); 328 GFP_KERNEL);
270 if (!txq->tfds) { 329 if (!txq->tfds) {
271 IWL_ERR(priv, "dma_alloc_coherent(%zd) failed\n", tfd_sz); 330 IWL_ERR(priv, "dma_alloc_coherent(%zd) failed\n", tfd_sz);
@@ -356,7 +415,7 @@ static void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id)
356static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) 415static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
357{ 416{
358 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 417 struct iwl_tx_queue *txq = &priv->txq[txq_id];
359 struct device *dev = priv->bus.dev; 418 struct device *dev = priv->bus->dev;
360 int i; 419 int i;
361 if (WARN_ON(!txq)) 420 if (WARN_ON(!txq))
362 return; 421 return;
@@ -467,11 +526,11 @@ static int iwl_trans_tx_alloc(struct iwl_priv *priv)
467 return 0; 526 return 0;
468 527
469error: 528error:
470 trans_tx_free(priv); 529 trans_tx_free(&priv->trans);
471 530
472 return ret; 531 return ret;
473} 532}
474static int iwl_trans_tx_init(struct iwl_priv *priv) 533static int iwl_tx_init(struct iwl_priv *priv)
475{ 534{
476 int ret; 535 int ret;
477 int txq_id, slots_num; 536 int txq_id, slots_num;
@@ -488,7 +547,7 @@ static int iwl_trans_tx_init(struct iwl_priv *priv)
488 spin_lock_irqsave(&priv->lock, flags); 547 spin_lock_irqsave(&priv->lock, flags);
489 548
490 /* Turn off all Tx DMA fifos */ 549 /* Turn off all Tx DMA fifos */
491 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, 0); 550 iwl_write_prph(priv, SCD_TXFACT, 0);
492 551
493 /* Tell NIC where to find the "keep warm" buffer */ 552 /* Tell NIC where to find the "keep warm" buffer */
494 iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); 553 iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4);
@@ -511,10 +570,308 @@ static int iwl_trans_tx_init(struct iwl_priv *priv)
511error: 570error:
512 /*Upon error, free only if we allocated something */ 571 /*Upon error, free only if we allocated something */
513 if (alloc) 572 if (alloc)
514 trans_tx_free(priv); 573 trans_tx_free(&priv->trans);
574 return ret;
575}
576
577static void iwl_set_pwr_vmain(struct iwl_priv *priv)
578{
579/*
580 * (for documentation purposes)
581 * to set power to V_AUX, do:
582
583 if (pci_pme_capable(priv->pci_dev, PCI_D3cold))
584 iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
585 APMG_PS_CTRL_VAL_PWR_SRC_VAUX,
586 ~APMG_PS_CTRL_MSK_PWR_SRC);
587 */
588
589 iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
590 APMG_PS_CTRL_VAL_PWR_SRC_VMAIN,
591 ~APMG_PS_CTRL_MSK_PWR_SRC);
592}
593
594static int iwl_nic_init(struct iwl_priv *priv)
595{
596 unsigned long flags;
597
598 /* nic_init */
599 spin_lock_irqsave(&priv->lock, flags);
600 iwl_apm_init(priv);
601
602 /* Set interrupt coalescing calibration timer to default (512 usecs) */
603 iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF);
604
605 spin_unlock_irqrestore(&priv->lock, flags);
606
607 iwl_set_pwr_vmain(priv);
608
609 priv->cfg->lib->nic_config(priv);
610
611 /* Allocate the RX queue, or reset if it is already allocated */
612 iwl_rx_init(priv);
613
614 /* Allocate or reset and init all Tx and Command queues */
615 if (iwl_tx_init(priv))
616 return -ENOMEM;
617
618 if (priv->cfg->base_params->shadow_reg_enable) {
619 /* enable shadow regs in HW */
620 iwl_set_bit(priv, CSR_MAC_SHADOW_REG_CTRL,
621 0x800FFFFF);
622 }
623
624 set_bit(STATUS_INIT, &priv->status);
625
626 return 0;
627}
628
629#define HW_READY_TIMEOUT (50)
630
631/* Note: returns poll_bit return value, which is >= 0 if success */
632static int iwl_set_hw_ready(struct iwl_priv *priv)
633{
634 int ret;
635
636 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
637 CSR_HW_IF_CONFIG_REG_BIT_NIC_READY);
638
639 /* See if we got it */
640 ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
641 CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
642 CSR_HW_IF_CONFIG_REG_BIT_NIC_READY,
643 HW_READY_TIMEOUT);
644
645 IWL_DEBUG_INFO(priv, "hardware%s ready\n", ret < 0 ? " not" : "");
646 return ret;
647}
648
649/* Note: returns standard 0/-ERROR code */
650static int iwl_trans_prepare_card_hw(struct iwl_priv *priv)
651{
652 int ret;
653
654 IWL_DEBUG_INFO(priv, "iwl_trans_prepare_card_hw enter\n");
655
656 ret = iwl_set_hw_ready(priv);
657 if (ret >= 0)
658 return 0;
659
660 /* If HW is not ready, prepare the conditions to check again */
661 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
662 CSR_HW_IF_CONFIG_REG_PREPARE);
663
664 ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
665 ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE,
666 CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000);
667
668 if (ret < 0)
669 return ret;
670
671 /* HW should be ready by now, check again. */
672 ret = iwl_set_hw_ready(priv);
673 if (ret >= 0)
674 return 0;
515 return ret; 675 return ret;
516} 676}
517 677
678static int iwl_trans_start_device(struct iwl_priv *priv)
679{
680 int ret;
681
682 priv->ucode_owner = IWL_OWNERSHIP_DRIVER;
683
684 if ((priv->cfg->sku & EEPROM_SKU_CAP_AMT_ENABLE) &&
685 iwl_trans_prepare_card_hw(priv)) {
686 IWL_WARN(priv, "Exit HW not ready\n");
687 return -EIO;
688 }
689
690 /* If platform's RF_KILL switch is NOT set to KILL */
691 if (iwl_read32(priv, CSR_GP_CNTRL) &
692 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
693 clear_bit(STATUS_RF_KILL_HW, &priv->status);
694 else
695 set_bit(STATUS_RF_KILL_HW, &priv->status);
696
697 if (iwl_is_rfkill(priv)) {
698 wiphy_rfkill_set_hw_state(priv->hw->wiphy, true);
699 iwl_enable_interrupts(priv);
700 return -ERFKILL;
701 }
702
703 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
704
705 ret = iwl_nic_init(priv);
706 if (ret) {
707 IWL_ERR(priv, "Unable to init nic\n");
708 return ret;
709 }
710
711 /* make sure rfkill handshake bits are cleared */
712 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
713 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
714 CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
715
716 /* clear (again), then enable host interrupts */
717 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
718 iwl_enable_interrupts(priv);
719
720 /* really make sure rfkill handshake bits are cleared */
721 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
722 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
723
724 return 0;
725}
726
727/*
728 * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
729 * must be called under priv->lock and mac access
730 */
731static void iwl_trans_txq_set_sched(struct iwl_priv *priv, u32 mask)
732{
733 iwl_write_prph(priv, SCD_TXFACT, mask);
734}
735
736#define IWL_AC_UNSET -1
737
738struct queue_to_fifo_ac {
739 s8 fifo, ac;
740};
741
742static const struct queue_to_fifo_ac iwlagn_default_queue_to_tx_fifo[] = {
743 { IWL_TX_FIFO_VO, IEEE80211_AC_VO, },
744 { IWL_TX_FIFO_VI, IEEE80211_AC_VI, },
745 { IWL_TX_FIFO_BE, IEEE80211_AC_BE, },
746 { IWL_TX_FIFO_BK, IEEE80211_AC_BK, },
747 { IWLAGN_CMD_FIFO_NUM, IWL_AC_UNSET, },
748 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
749 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
750 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
751 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
752 { IWL_TX_FIFO_UNUSED, IWL_AC_UNSET, },
753};
754
755static const struct queue_to_fifo_ac iwlagn_ipan_queue_to_tx_fifo[] = {
756 { IWL_TX_FIFO_VO, IEEE80211_AC_VO, },
757 { IWL_TX_FIFO_VI, IEEE80211_AC_VI, },
758 { IWL_TX_FIFO_BE, IEEE80211_AC_BE, },
759 { IWL_TX_FIFO_BK, IEEE80211_AC_BK, },
760 { IWL_TX_FIFO_BK_IPAN, IEEE80211_AC_BK, },
761 { IWL_TX_FIFO_BE_IPAN, IEEE80211_AC_BE, },
762 { IWL_TX_FIFO_VI_IPAN, IEEE80211_AC_VI, },
763 { IWL_TX_FIFO_VO_IPAN, IEEE80211_AC_VO, },
764 { IWL_TX_FIFO_BE_IPAN, 2, },
765 { IWLAGN_CMD_FIFO_NUM, IWL_AC_UNSET, },
766};
767static void iwl_trans_tx_start(struct iwl_priv *priv)
768{
769 const struct queue_to_fifo_ac *queue_to_fifo;
770 struct iwl_rxon_context *ctx;
771 u32 a;
772 unsigned long flags;
773 int i, chan;
774 u32 reg_val;
775
776 spin_lock_irqsave(&priv->lock, flags);
777
778 priv->scd_base_addr = iwl_read_prph(priv, SCD_SRAM_BASE_ADDR);
779 a = priv->scd_base_addr + SCD_CONTEXT_MEM_LOWER_BOUND;
780 /* reset conext data memory */
781 for (; a < priv->scd_base_addr + SCD_CONTEXT_MEM_UPPER_BOUND;
782 a += 4)
783 iwl_write_targ_mem(priv, a, 0);
784 /* reset tx status memory */
785 for (; a < priv->scd_base_addr + SCD_TX_STTS_MEM_UPPER_BOUND;
786 a += 4)
787 iwl_write_targ_mem(priv, a, 0);
788 for (; a < priv->scd_base_addr +
789 SCD_TRANS_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4)
790 iwl_write_targ_mem(priv, a, 0);
791
792 iwl_write_prph(priv, SCD_DRAM_BASE_ADDR,
793 priv->scd_bc_tbls.dma >> 10);
794
795 /* Enable DMA channel */
796 for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++)
797 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
798 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
799 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
800
801 /* Update FH chicken bits */
802 reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
803 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
804 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
805
806 iwl_write_prph(priv, SCD_QUEUECHAIN_SEL,
807 SCD_QUEUECHAIN_SEL_ALL(priv));
808 iwl_write_prph(priv, SCD_AGGR_SEL, 0);
809
810 /* initiate the queues */
811 for (i = 0; i < priv->hw_params.max_txq_num; i++) {
812 iwl_write_prph(priv, SCD_QUEUE_RDPTR(i), 0);
813 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8));
814 iwl_write_targ_mem(priv, priv->scd_base_addr +
815 SCD_CONTEXT_QUEUE_OFFSET(i), 0);
816 iwl_write_targ_mem(priv, priv->scd_base_addr +
817 SCD_CONTEXT_QUEUE_OFFSET(i) +
818 sizeof(u32),
819 ((SCD_WIN_SIZE <<
820 SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
821 SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
822 ((SCD_FRAME_LIMIT <<
823 SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
824 SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
825 }
826
827 iwl_write_prph(priv, SCD_INTERRUPT_MASK,
828 IWL_MASK(0, priv->hw_params.max_txq_num));
829
830 /* Activate all Tx DMA/FIFO channels */
831 iwl_trans_txq_set_sched(priv, IWL_MASK(0, 7));
832
833 /* map queues to FIFOs */
834 if (priv->valid_contexts != BIT(IWL_RXON_CTX_BSS))
835 queue_to_fifo = iwlagn_ipan_queue_to_tx_fifo;
836 else
837 queue_to_fifo = iwlagn_default_queue_to_tx_fifo;
838
839 iwl_trans_set_wr_ptrs(priv, priv->cmd_queue, 0);
840
841 /* make sure all queue are not stopped */
842 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
843 for (i = 0; i < 4; i++)
844 atomic_set(&priv->queue_stop_count[i], 0);
845 for_each_context(priv, ctx)
846 ctx->last_tx_rejected = false;
847
848 /* reset to 0 to enable all the queue first */
849 priv->txq_ctx_active_msk = 0;
850
851 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo) != 10);
852 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_ipan_queue_to_tx_fifo) != 10);
853
854 for (i = 0; i < 10; i++) {
855 int fifo = queue_to_fifo[i].fifo;
856 int ac = queue_to_fifo[i].ac;
857
858 iwl_txq_ctx_activate(priv, i);
859
860 if (fifo == IWL_TX_FIFO_UNUSED)
861 continue;
862
863 if (ac != IWL_AC_UNSET)
864 iwl_set_swq_id(&priv->txq[i], ac, i);
865 iwl_trans_tx_queue_set_status(priv, &priv->txq[i], fifo, 0);
866 }
867
868 spin_unlock_irqrestore(&priv->lock, flags);
869
870 /* Enable L1-Active */
871 iwl_clear_bits_prph(priv, APMG_PCIDEV_STT_REG,
872 APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
873}
874
518/** 875/**
519 * iwlagn_txq_ctx_stop - Stop all Tx DMA channels 876 * iwlagn_txq_ctx_stop - Stop all Tx DMA channels
520 */ 877 */
@@ -526,7 +883,7 @@ static int iwl_trans_tx_stop(struct iwl_priv *priv)
526 /* Turn off all Tx DMA fifos */ 883 /* Turn off all Tx DMA fifos */
527 spin_lock_irqsave(&priv->lock, flags); 884 spin_lock_irqsave(&priv->lock, flags);
528 885
529 iwlagn_txq_set_sched(priv, 0); 886 iwl_trans_txq_set_sched(priv, 0);
530 887
531 /* Stop each Tx DMA channel, and wait for it to be idle */ 888 /* Stop each Tx DMA channel, and wait for it to be idle */
532 for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) { 889 for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) {
@@ -552,20 +909,264 @@ static int iwl_trans_tx_stop(struct iwl_priv *priv)
552 return 0; 909 return 0;
553} 910}
554 911
912static void iwl_trans_stop_device(struct iwl_priv *priv)
913{
914 unsigned long flags;
915
916 /* stop and reset the on-board processor */
917 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
918
919 /* tell the device to stop sending interrupts */
920 spin_lock_irqsave(&priv->lock, flags);
921 iwl_disable_interrupts(priv);
922 spin_unlock_irqrestore(&priv->lock, flags);
923 trans_sync_irq(&priv->trans);
924
925 /* device going down, Stop using ICT table */
926 iwl_disable_ict(priv);
927
928 /*
929 * If a HW restart happens during firmware loading,
930 * then the firmware loading might call this function
931 * and later it might be called again due to the
932 * restart. So don't process again if the device is
933 * already dead.
934 */
935 if (test_bit(STATUS_DEVICE_ENABLED, &priv->status)) {
936 iwl_trans_tx_stop(priv);
937 iwl_trans_rx_stop(priv);
938
939 /* Power-down device's busmaster DMA clocks */
940 iwl_write_prph(priv, APMG_CLK_DIS_REG,
941 APMG_CLK_VAL_DMA_CLK_RQT);
942 udelay(5);
943 }
944
945 /* Make sure (redundant) we've released our request to stay awake */
946 iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
947
948 /* Stop the device, and put it in low power state */
949 iwl_apm_stop(priv);
950}
951
952static struct iwl_tx_cmd *iwl_trans_get_tx_cmd(struct iwl_priv *priv,
953 int txq_id)
954{
955 struct iwl_tx_queue *txq = &priv->txq[txq_id];
956 struct iwl_queue *q = &txq->q;
957 struct iwl_device_cmd *dev_cmd;
958
959 if (unlikely(iwl_queue_space(q) < q->high_mark))
960 return NULL;
961
962 /*
963 * Set up the Tx-command (not MAC!) header.
964 * Store the chosen Tx queue and TFD index within the sequence field;
965 * after Tx, uCode's Tx response will return this value so driver can
966 * locate the frame within the tx queue and do post-tx processing.
967 */
968 dev_cmd = txq->cmd[q->write_ptr];
969 memset(dev_cmd, 0, sizeof(*dev_cmd));
970 dev_cmd->hdr.cmd = REPLY_TX;
971 dev_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
972 INDEX_TO_SEQ(q->write_ptr)));
973 return &dev_cmd->cmd.tx;
974}
975
976static int iwl_trans_tx(struct iwl_priv *priv, struct sk_buff *skb,
977 struct iwl_tx_cmd *tx_cmd, int txq_id, __le16 fc, bool ampdu,
978 struct iwl_rxon_context *ctx)
979{
980 struct iwl_tx_queue *txq = &priv->txq[txq_id];
981 struct iwl_queue *q = &txq->q;
982 struct iwl_device_cmd *dev_cmd = txq->cmd[q->write_ptr];
983 struct iwl_cmd_meta *out_meta;
984
985 dma_addr_t phys_addr = 0;
986 dma_addr_t txcmd_phys;
987 dma_addr_t scratch_phys;
988 u16 len, firstlen, secondlen;
989 u8 wait_write_ptr = 0;
990 u8 hdr_len = ieee80211_hdrlen(fc);
991
992 /* Set up driver data for this TFD */
993 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
994 txq->txb[q->write_ptr].skb = skb;
995 txq->txb[q->write_ptr].ctx = ctx;
996
997 /* Set up first empty entry in queue's array of Tx/cmd buffers */
998 out_meta = &txq->meta[q->write_ptr];
999
1000 /*
1001 * Use the first empty entry in this queue's command buffer array
1002 * to contain the Tx command and MAC header concatenated together
1003 * (payload data will be in another buffer).
1004 * Size of this varies, due to varying MAC header length.
1005 * If end is not dword aligned, we'll have 2 extra bytes at the end
1006 * of the MAC header (device reads on dword boundaries).
1007 * We'll tell device about this padding later.
1008 */
1009 len = sizeof(struct iwl_tx_cmd) +
1010 sizeof(struct iwl_cmd_header) + hdr_len;
1011 firstlen = (len + 3) & ~3;
1012
1013 /* Tell NIC about any 2-byte padding after MAC header */
1014 if (firstlen != len)
1015 tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK;
1016
1017 /* Physical address of this Tx command's header (not MAC header!),
1018 * within command buffer array. */
1019 txcmd_phys = dma_map_single(priv->bus->dev,
1020 &dev_cmd->hdr, firstlen,
1021 DMA_BIDIRECTIONAL);
1022 if (unlikely(dma_mapping_error(priv->bus->dev, txcmd_phys)))
1023 return -1;
1024 dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
1025 dma_unmap_len_set(out_meta, len, firstlen);
1026
1027 if (!ieee80211_has_morefrags(fc)) {
1028 txq->need_update = 1;
1029 } else {
1030 wait_write_ptr = 1;
1031 txq->need_update = 0;
1032 }
1033
1034 /* Set up TFD's 2nd entry to point directly to remainder of skb,
1035 * if any (802.11 null frames have no payload). */
1036 secondlen = skb->len - hdr_len;
1037 if (secondlen > 0) {
1038 phys_addr = dma_map_single(priv->bus->dev, skb->data + hdr_len,
1039 secondlen, DMA_TO_DEVICE);
1040 if (unlikely(dma_mapping_error(priv->bus->dev, phys_addr))) {
1041 dma_unmap_single(priv->bus->dev,
1042 dma_unmap_addr(out_meta, mapping),
1043 dma_unmap_len(out_meta, len),
1044 DMA_BIDIRECTIONAL);
1045 return -1;
1046 }
1047 }
1048
1049 /* Attach buffers to TFD */
1050 iwlagn_txq_attach_buf_to_tfd(priv, txq, txcmd_phys, firstlen, 1);
1051 if (secondlen > 0)
1052 iwlagn_txq_attach_buf_to_tfd(priv, txq, phys_addr,
1053 secondlen, 0);
1054
1055 scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
1056 offsetof(struct iwl_tx_cmd, scratch);
1057
1058 /* take back ownership of DMA buffer to enable update */
1059 dma_sync_single_for_cpu(priv->bus->dev, txcmd_phys, firstlen,
1060 DMA_BIDIRECTIONAL);
1061 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
1062 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
1063
1064 IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n",
1065 le16_to_cpu(dev_cmd->hdr.sequence));
1066 IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags));
1067 iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd));
1068 iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len);
1069
1070 /* Set up entry for this TFD in Tx byte-count array */
1071 if (ampdu)
1072 iwl_trans_txq_update_byte_cnt_tbl(priv, txq,
1073 le16_to_cpu(tx_cmd->len));
1074
1075 dma_sync_single_for_device(priv->bus->dev, txcmd_phys, firstlen,
1076 DMA_BIDIRECTIONAL);
1077
1078 trace_iwlwifi_dev_tx(priv,
1079 &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],
1080 sizeof(struct iwl_tfd),
1081 &dev_cmd->hdr, firstlen,
1082 skb->data + hdr_len, secondlen);
1083
1084 /* Tell device the write index *just past* this latest filled TFD */
1085 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
1086 iwl_txq_update_write_ptr(priv, txq);
1087
1088 /*
1089 * At this point the frame is "transmitted" successfully
1090 * and we will get a TX status notification eventually,
1091 * regardless of the value of ret. "ret" only indicates
1092 * whether or not we should update the write pointer.
1093 */
1094 if ((iwl_queue_space(q) < q->high_mark) && priv->mac80211_registered) {
1095 if (wait_write_ptr) {
1096 txq->need_update = 1;
1097 iwl_txq_update_write_ptr(priv, txq);
1098 } else {
1099 iwl_stop_queue(priv, txq);
1100 }
1101 }
1102 return 0;
1103}
1104
1105static void iwl_trans_kick_nic(struct iwl_priv *priv)
1106{
1107 /* Remove all resets to allow NIC to operate */
1108 iwl_write32(priv, CSR_RESET, 0);
1109}
1110
1111static void iwl_trans_sync_irq(struct iwl_priv *priv)
1112{
1113 /* wait to make sure we flush pending tasklet*/
1114 synchronize_irq(priv->bus->irq);
1115 tasklet_kill(&priv->irq_tasklet);
1116}
1117
1118static void iwl_trans_free(struct iwl_priv *priv)
1119{
1120 free_irq(priv->bus->irq, priv);
1121 iwl_free_isr_ict(priv);
1122}
1123
555static const struct iwl_trans_ops trans_ops = { 1124static const struct iwl_trans_ops trans_ops = {
556 .rx_init = iwl_trans_rx_init, 1125 .start_device = iwl_trans_start_device,
557 .rx_stop = iwl_trans_rx_stop, 1126 .prepare_card_hw = iwl_trans_prepare_card_hw,
558 .rx_free = iwl_trans_rx_free, 1127 .stop_device = iwl_trans_stop_device,
559 1128
560 .tx_init = iwl_trans_tx_init, 1129 .tx_start = iwl_trans_tx_start,
561 .tx_stop = iwl_trans_tx_stop, 1130
1131 .rx_free = iwl_trans_rx_free,
562 .tx_free = iwl_trans_tx_free, 1132 .tx_free = iwl_trans_tx_free,
563 1133
564 .send_cmd = iwl_send_cmd, 1134 .send_cmd = iwl_send_cmd,
565 .send_cmd_pdu = iwl_send_cmd_pdu, 1135 .send_cmd_pdu = iwl_send_cmd_pdu,
1136
1137 .get_tx_cmd = iwl_trans_get_tx_cmd,
1138 .tx = iwl_trans_tx,
1139
1140 .txq_agg_disable = iwl_trans_txq_agg_disable,
1141 .txq_agg_setup = iwl_trans_txq_agg_setup,
1142
1143 .kick_nic = iwl_trans_kick_nic,
1144
1145 .sync_irq = iwl_trans_sync_irq,
1146 .free = iwl_trans_free,
566}; 1147};
567 1148
568void iwl_trans_register(struct iwl_trans *trans) 1149int iwl_trans_register(struct iwl_trans *trans, struct iwl_priv *priv)
569{ 1150{
570 trans->ops = &trans_ops; 1151 int err;
1152
1153 priv->trans.ops = &trans_ops;
1154 priv->trans.priv = priv;
1155
1156 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
1157 iwl_irq_tasklet, (unsigned long)priv);
1158
1159 iwl_alloc_isr_ict(priv);
1160
1161 err = request_irq(priv->bus->irq, iwl_isr_ict, IRQF_SHARED,
1162 DRV_NAME, priv);
1163 if (err) {
1164 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->bus->irq);
1165 iwl_free_isr_ict(priv);
1166 return err;
1167 }
1168
1169 INIT_WORK(&priv->rx_replenish, iwl_bg_rx_replenish);
1170
1171 return 0;
571} 1172}
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index 111acca07d75..7993aa7ae668 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -60,46 +60,166 @@
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 * 61 *
62 *****************************************************************************/ 62 *****************************************************************************/
63static inline int trans_rx_init(struct iwl_priv *priv) 63#ifndef __iwl_trans_h__
64#define __iwl_trans_h__
65
66 /*This file includes the declaration that are exported from the transport
67 * layer */
68
69struct iwl_priv;
70struct iwl_rxon_context;
71struct iwl_host_cmd;
72
73/**
74 * struct iwl_trans_ops - transport specific operations
75 * @start_device: allocates and inits all the resources for the transport
76 * layer.
77 * @prepare_card_hw: claim the ownership on the HW. Will be called during
78 * probe.
79 * @tx_start: starts and configures all the Tx fifo - usually done once the fw
80 * is alive.
81 * @stop_device:stops the whole device (embedded CPU put to reset)
82 * @rx_free: frees the rx memory
83 * @tx_free: frees the tx memory
84 * @send_cmd:send a host command
85 * @send_cmd_pdu:send a host command: flags can be CMD_*
86 * @get_tx_cmd: returns a pointer to a new Tx cmd for the upper layer use
87 * @tx: send an skb
88 * @txq_agg_setup: setup a tx queue for AMPDU - will be called once the HW is
89 * ready and a successful ADDBA response has been received.
90 * @txq_agg_disable: de-configure a Tx queue to send AMPDUs
91 * @kick_nic: remove the RESET from the embedded CPU and let it run
92 * @sync_irq: the upper layer will typically disable interrupt and call this
93 * handler. After this handler returns, it is guaranteed that all
94 * the ISR / tasklet etc... have finished running and the transport
95 * layer shall not pass any Rx.
96 * @free: release all the ressource for the transport layer itself such as
97 * irq, tasklet etc...
98 */
99struct iwl_trans_ops {
100
101 int (*start_device)(struct iwl_priv *priv);
102 int (*prepare_card_hw)(struct iwl_priv *priv);
103 void (*stop_device)(struct iwl_priv *priv);
104 void (*tx_start)(struct iwl_priv *priv);
105 void (*tx_free)(struct iwl_priv *priv);
106 void (*rx_free)(struct iwl_priv *priv);
107
108 int (*send_cmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
109
110 int (*send_cmd_pdu)(struct iwl_priv *priv, u8 id, u32 flags, u16 len,
111 const void *data);
112 struct iwl_tx_cmd * (*get_tx_cmd)(struct iwl_priv *priv, int txq_id);
113 int (*tx)(struct iwl_priv *priv, struct sk_buff *skb,
114 struct iwl_tx_cmd *tx_cmd, int txq_id, __le16 fc, bool ampdu,
115 struct iwl_rxon_context *ctx);
116
117 int (*txq_agg_disable)(struct iwl_priv *priv, u16 txq_id,
118 u16 ssn_idx, u8 tx_fifo);
119 void (*txq_agg_setup)(struct iwl_priv *priv, int sta_id, int tid,
120 int frame_limit);
121
122 void (*kick_nic)(struct iwl_priv *priv);
123
124 void (*sync_irq)(struct iwl_priv *priv);
125 void (*free)(struct iwl_priv *priv);
126};
127
128struct iwl_trans {
129 const struct iwl_trans_ops *ops;
130 struct iwl_priv *priv;
131};
132
133static inline int trans_start_device(struct iwl_trans *trans)
64{ 134{
65 return priv->trans.ops->rx_init(priv); 135 return trans->ops->start_device(trans->priv);
66} 136}
67 137
68static inline int trans_rx_stop(struct iwl_priv *priv) 138static inline int trans_prepare_card_hw(struct iwl_trans *trans)
69{ 139{
70 return priv->trans.ops->rx_stop(priv); 140 return trans->ops->prepare_card_hw(trans->priv);
71} 141}
72 142
73static inline void trans_rx_free(struct iwl_priv *priv) 143static inline void trans_stop_device(struct iwl_trans *trans)
74{ 144{
75 priv->trans.ops->rx_free(priv); 145 trans->ops->stop_device(trans->priv);
76} 146}
77 147
78static inline int trans_tx_init(struct iwl_priv *priv) 148static inline void trans_tx_start(struct iwl_trans *trans)
79{ 149{
80 return priv->trans.ops->tx_init(priv); 150 trans->ops->tx_start(trans->priv);
81} 151}
82 152
83static inline int trans_tx_stop(struct iwl_priv *priv) 153static inline void trans_rx_free(struct iwl_trans *trans)
84{ 154{
85 return priv->trans.ops->tx_stop(priv); 155 trans->ops->rx_free(trans->priv);
86} 156}
87 157
88static inline void trans_tx_free(struct iwl_priv *priv) 158static inline void trans_tx_free(struct iwl_trans *trans)
89{ 159{
90 priv->trans.ops->tx_free(priv); 160 trans->ops->tx_free(trans->priv);
91} 161}
92 162
93static inline int trans_send_cmd(struct iwl_priv *priv, 163static inline int trans_send_cmd(struct iwl_trans *trans,
94 struct iwl_host_cmd *cmd) 164 struct iwl_host_cmd *cmd)
95{ 165{
96 return priv->trans.ops->send_cmd(priv, cmd); 166 return trans->ops->send_cmd(trans->priv, cmd);
97} 167}
98 168
99static inline int trans_send_cmd_pdu(struct iwl_priv *priv, u8 id, u32 flags, 169static inline int trans_send_cmd_pdu(struct iwl_trans *trans, u8 id, u32 flags,
100 u16 len, const void *data) 170 u16 len, const void *data)
101{ 171{
102 return priv->trans.ops->send_cmd_pdu(priv, id, flags, len, data); 172 return trans->ops->send_cmd_pdu(trans->priv, id, flags, len, data);
173}
174
175static inline struct iwl_tx_cmd *trans_get_tx_cmd(struct iwl_trans *trans,
176 int txq_id)
177{
178 return trans->ops->get_tx_cmd(trans->priv, txq_id);
103} 179}
104 180
105void iwl_trans_register(struct iwl_trans *trans); 181static inline int trans_tx(struct iwl_trans *trans, struct sk_buff *skb,
182 struct iwl_tx_cmd *tx_cmd, int txq_id, __le16 fc, bool ampdu,
183 struct iwl_rxon_context *ctx)
184{
185 return trans->ops->tx(trans->priv, skb, tx_cmd, txq_id, fc, ampdu, ctx);
186}
187
188static inline int trans_txq_agg_disable(struct iwl_trans *trans, u16 txq_id,
189 u16 ssn_idx, u8 tx_fifo)
190{
191 return trans->ops->txq_agg_disable(trans->priv, txq_id,
192 ssn_idx, tx_fifo);
193}
194
195static inline void trans_txq_agg_setup(struct iwl_trans *trans, int sta_id,
196 int tid, int frame_limit)
197{
198 trans->ops->txq_agg_setup(trans->priv, sta_id, tid, frame_limit);
199}
200
201static inline void trans_kick_nic(struct iwl_trans *trans)
202{
203 trans->ops->kick_nic(trans->priv);
204}
205
206static inline void trans_sync_irq(struct iwl_trans *trans)
207{
208 trans->ops->sync_irq(trans->priv);
209}
210
211static inline void trans_free(struct iwl_trans *trans)
212{
213 trans->ops->free(trans->priv);
214}
215
216int iwl_trans_register(struct iwl_trans *trans, struct iwl_priv *priv);
217
218/*TODO: this functions should NOT be exported from trans module - export it
219 * until the reclaim flow will be brought to the transport module too */
220
221struct iwl_tx_queue;
222void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
223 struct iwl_tx_queue *txq);
224
225#endif /* __iwl_trans_h__ */
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 76d018beebf4..adb3490e3cf5 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -44,9 +44,7 @@ struct lbs_private {
44 /* Mesh */ 44 /* Mesh */
45 struct net_device *mesh_dev; /* Virtual device */ 45 struct net_device *mesh_dev; /* Virtual device */
46#ifdef CONFIG_LIBERTAS_MESH 46#ifdef CONFIG_LIBERTAS_MESH
47 u32 mesh_connect_status;
48 struct lbs_mesh_stats mstats; 47 struct lbs_mesh_stats mstats;
49 int mesh_open;
50 uint16_t mesh_tlv; 48 uint16_t mesh_tlv;
51 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1]; 49 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
52 u8 mesh_ssid_len; 50 u8 mesh_ssid_len;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index c79aac4b1dae..94652c5a25de 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -512,7 +512,7 @@ static int lbs_thread(void *data)
512 if (priv->connect_status == LBS_CONNECTED) 512 if (priv->connect_status == LBS_CONNECTED)
513 netif_wake_queue(priv->dev); 513 netif_wake_queue(priv->dev);
514 if (priv->mesh_dev && 514 if (priv->mesh_dev &&
515 lbs_mesh_connected(priv)) 515 netif_running(priv->mesh_dev))
516 netif_wake_queue(priv->mesh_dev); 516 netif_wake_queue(priv->mesh_dev);
517 } 517 }
518 } 518 }
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index 7969d104189d..be72c08ea2a7 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -15,6 +15,121 @@
15#include "cmd.h" 15#include "cmd.h"
16 16
17 17
18static int lbs_add_mesh(struct lbs_private *priv);
19
20/***************************************************************************
21 * Mesh command handling
22 */
23
24static int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action,
25 struct cmd_ds_mesh_access *cmd)
26{
27 int ret;
28
29 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
30
31 cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS);
32 cmd->hdr.size = cpu_to_le16(sizeof(*cmd));
33 cmd->hdr.result = 0;
34
35 cmd->action = cpu_to_le16(cmd_action);
36
37 ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd);
38
39 lbs_deb_leave(LBS_DEB_CMD);
40 return ret;
41}
42
43static int __lbs_mesh_config_send(struct lbs_private *priv,
44 struct cmd_ds_mesh_config *cmd,
45 uint16_t action, uint16_t type)
46{
47 int ret;
48 u16 command = CMD_MESH_CONFIG_OLD;
49
50 lbs_deb_enter(LBS_DEB_CMD);
51
52 /*
53 * Command id is 0xac for v10 FW along with mesh interface
54 * id in bits 14-13-12.
55 */
56 if (priv->mesh_tlv == TLV_TYPE_MESH_ID)
57 command = CMD_MESH_CONFIG |
58 (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET);
59
60 cmd->hdr.command = cpu_to_le16(command);
61 cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config));
62 cmd->hdr.result = 0;
63
64 cmd->type = cpu_to_le16(type);
65 cmd->action = cpu_to_le16(action);
66
67 ret = lbs_cmd_with_response(priv, command, cmd);
68
69 lbs_deb_leave(LBS_DEB_CMD);
70 return ret;
71}
72
73static int lbs_mesh_config_send(struct lbs_private *priv,
74 struct cmd_ds_mesh_config *cmd,
75 uint16_t action, uint16_t type)
76{
77 int ret;
78
79 if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG))
80 return -EOPNOTSUPP;
81
82 ret = __lbs_mesh_config_send(priv, cmd, action, type);
83 return ret;
84}
85
86/* This function is the CMD_MESH_CONFIG legacy function. It only handles the
87 * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG
88 * are all handled by preparing a struct cmd_ds_mesh_config and passing it to
89 * lbs_mesh_config_send.
90 */
91static int lbs_mesh_config(struct lbs_private *priv, uint16_t action,
92 uint16_t chan)
93{
94 struct cmd_ds_mesh_config cmd;
95 struct mrvl_meshie *ie;
96 DECLARE_SSID_BUF(ssid);
97
98 memset(&cmd, 0, sizeof(cmd));
99 cmd.channel = cpu_to_le16(chan);
100 ie = (struct mrvl_meshie *)cmd.data;
101
102 switch (action) {
103 case CMD_ACT_MESH_CONFIG_START:
104 ie->id = WLAN_EID_GENERIC;
105 ie->val.oui[0] = 0x00;
106 ie->val.oui[1] = 0x50;
107 ie->val.oui[2] = 0x43;
108 ie->val.type = MARVELL_MESH_IE_TYPE;
109 ie->val.subtype = MARVELL_MESH_IE_SUBTYPE;
110 ie->val.version = MARVELL_MESH_IE_VERSION;
111 ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP;
112 ie->val.active_metric_id = MARVELL_MESH_METRIC_ID;
113 ie->val.mesh_capability = MARVELL_MESH_CAPABILITY;
114 ie->val.mesh_id_len = priv->mesh_ssid_len;
115 memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len);
116 ie->len = sizeof(struct mrvl_meshie_val) -
117 IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len;
118 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val));
119 break;
120 case CMD_ACT_MESH_CONFIG_STOP:
121 break;
122 default:
123 return -1;
124 }
125 lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n",
126 action, priv->mesh_tlv, chan,
127 print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len));
128
129 return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
130}
131
132
18/*************************************************************************** 133/***************************************************************************
19 * Mesh sysfs support 134 * Mesh sysfs support
20 */ 135 */
@@ -155,17 +270,11 @@ static ssize_t lbs_mesh_set(struct device *dev,
155{ 270{
156 struct lbs_private *priv = to_net_dev(dev)->ml_priv; 271 struct lbs_private *priv = to_net_dev(dev)->ml_priv;
157 int enable; 272 int enable;
158 int ret, action = CMD_ACT_MESH_CONFIG_STOP;
159 273
160 sscanf(buf, "%x", &enable); 274 sscanf(buf, "%x", &enable);
161 enable = !!enable; 275 enable = !!enable;
162 if (enable == !!priv->mesh_dev) 276 if (enable == !!priv->mesh_dev)
163 return count; 277 return count;
164 if (enable)
165 action = CMD_ACT_MESH_CONFIG_START;
166 ret = lbs_mesh_config(priv, action, priv->channel);
167 if (ret)
168 return ret;
169 278
170 if (enable) 279 if (enable)
171 lbs_add_mesh(priv); 280 lbs_add_mesh(priv);
@@ -200,582 +309,11 @@ static struct attribute *lbs_mesh_sysfs_entries[] = {
200 NULL, 309 NULL,
201}; 310};
202 311
203static struct attribute_group lbs_mesh_attr_group = { 312static const struct attribute_group lbs_mesh_attr_group = {
204 .attrs = lbs_mesh_sysfs_entries, 313 .attrs = lbs_mesh_sysfs_entries,
205}; 314};
206 315
207 316
208
209/***************************************************************************
210 * Initializing and starting, stopping mesh
211 */
212
213/*
214 * Check mesh FW version and appropriately send the mesh start
215 * command
216 */
217int lbs_init_mesh(struct lbs_private *priv)
218{
219 struct net_device *dev = priv->dev;
220 int ret = 0;
221
222 lbs_deb_enter(LBS_DEB_MESH);
223
224 priv->mesh_connect_status = LBS_DISCONNECTED;
225
226 /* Determine mesh_fw_ver from fwrelease and fwcapinfo */
227 /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
228 /* 5.110.22 have mesh command with 0xa3 command id */
229 /* 10.0.0.p0 FW brings in mesh config command with different id */
230 /* Check FW version MSB and initialize mesh_fw_ver */
231 if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5) {
232 /* Enable mesh, if supported, and work out which TLV it uses.
233 0x100 + 291 is an unofficial value used in 5.110.20.pXX
234 0x100 + 37 is the official value used in 5.110.21.pXX
235 but we check them in that order because 20.pXX doesn't
236 give an error -- it just silently fails. */
237
238 /* 5.110.20.pXX firmware will fail the command if the channel
239 doesn't match the existing channel. But only if the TLV
240 is correct. If the channel is wrong, _BOTH_ versions will
241 give an error to 0x100+291, and allow 0x100+37 to succeed.
242 It's just that 5.110.20.pXX will not have done anything
243 useful */
244
245 priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID;
246 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
247 priv->channel)) {
248 priv->mesh_tlv = TLV_TYPE_MESH_ID;
249 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
250 priv->channel))
251 priv->mesh_tlv = 0;
252 }
253 } else
254 if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
255 (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK)) {
256 /* 10.0.0.pXX new firmwares should succeed with TLV
257 * 0x100+37; Do not invoke command with old TLV.
258 */
259 priv->mesh_tlv = TLV_TYPE_MESH_ID;
260 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
261 priv->channel))
262 priv->mesh_tlv = 0;
263 }
264
265
266 if (priv->mesh_tlv) {
267 sprintf(priv->mesh_ssid, "mesh");
268 priv->mesh_ssid_len = 4;
269
270 lbs_add_mesh(priv);
271
272 if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
273 netdev_err(dev, "cannot register lbs_mesh attribute\n");
274
275 ret = 1;
276 }
277
278 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
279 return ret;
280}
281
282
283int lbs_deinit_mesh(struct lbs_private *priv)
284{
285 struct net_device *dev = priv->dev;
286 int ret = 0;
287
288 lbs_deb_enter(LBS_DEB_MESH);
289
290 if (priv->mesh_tlv) {
291 device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
292 ret = 1;
293 }
294
295 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
296 return ret;
297}
298
299
300/**
301 * lbs_mesh_stop - close the mshX interface
302 *
303 * @dev: A pointer to &net_device structure
304 * returns: 0
305 */
306static int lbs_mesh_stop(struct net_device *dev)
307{
308 struct lbs_private *priv = dev->ml_priv;
309
310 lbs_deb_enter(LBS_DEB_MESH);
311 spin_lock_irq(&priv->driver_lock);
312
313 priv->mesh_open = 0;
314 priv->mesh_connect_status = LBS_DISCONNECTED;
315
316 netif_stop_queue(dev);
317 netif_carrier_off(dev);
318
319 spin_unlock_irq(&priv->driver_lock);
320
321 schedule_work(&priv->mcast_work);
322
323 lbs_deb_leave(LBS_DEB_MESH);
324 return 0;
325}
326
327/**
328 * lbs_mesh_dev_open - open the mshX interface
329 *
330 * @dev: A pointer to &net_device structure
331 * returns: 0 or -EBUSY if monitor mode active
332 */
333static int lbs_mesh_dev_open(struct net_device *dev)
334{
335 struct lbs_private *priv = dev->ml_priv;
336 int ret = 0;
337
338 lbs_deb_enter(LBS_DEB_NET);
339
340 spin_lock_irq(&priv->driver_lock);
341
342 if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) {
343 ret = -EBUSY;
344 goto out;
345 }
346
347 priv->mesh_open = 1;
348 priv->mesh_connect_status = LBS_CONNECTED;
349 netif_carrier_on(dev);
350
351 if (!priv->tx_pending_len)
352 netif_wake_queue(dev);
353 out:
354
355 spin_unlock_irq(&priv->driver_lock);
356 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
357 return ret;
358}
359
360static const struct net_device_ops mesh_netdev_ops = {
361 .ndo_open = lbs_mesh_dev_open,
362 .ndo_stop = lbs_mesh_stop,
363 .ndo_start_xmit = lbs_hard_start_xmit,
364 .ndo_set_mac_address = lbs_set_mac_address,
365 .ndo_set_multicast_list = lbs_set_multicast_list,
366};
367
368/**
369 * lbs_add_mesh - add mshX interface
370 *
371 * @priv: A pointer to the &struct lbs_private structure
372 * returns: 0 if successful, -X otherwise
373 */
374int lbs_add_mesh(struct lbs_private *priv)
375{
376 struct net_device *mesh_dev = NULL;
377 int ret = 0;
378
379 lbs_deb_enter(LBS_DEB_MESH);
380
381 /* Allocate a virtual mesh device */
382 mesh_dev = alloc_netdev(0, "msh%d", ether_setup);
383 if (!mesh_dev) {
384 lbs_deb_mesh("init mshX device failed\n");
385 ret = -ENOMEM;
386 goto done;
387 }
388 mesh_dev->ml_priv = priv;
389 priv->mesh_dev = mesh_dev;
390
391 mesh_dev->netdev_ops = &mesh_netdev_ops;
392 mesh_dev->ethtool_ops = &lbs_ethtool_ops;
393 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, ETH_ALEN);
394
395 SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
396
397 mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
398 /* Register virtual mesh interface */
399 ret = register_netdev(mesh_dev);
400 if (ret) {
401 pr_err("cannot register mshX virtual interface\n");
402 goto err_free;
403 }
404
405 ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
406 if (ret)
407 goto err_unregister;
408
409 lbs_persist_config_init(mesh_dev);
410
411 /* Everything successful */
412 ret = 0;
413 goto done;
414
415err_unregister:
416 unregister_netdev(mesh_dev);
417
418err_free:
419 free_netdev(mesh_dev);
420
421done:
422 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
423 return ret;
424}
425
426void lbs_remove_mesh(struct lbs_private *priv)
427{
428 struct net_device *mesh_dev;
429
430 mesh_dev = priv->mesh_dev;
431 if (!mesh_dev)
432 return;
433
434 lbs_deb_enter(LBS_DEB_MESH);
435 netif_stop_queue(mesh_dev);
436 netif_carrier_off(mesh_dev);
437 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
438 lbs_persist_config_remove(mesh_dev);
439 unregister_netdev(mesh_dev);
440 priv->mesh_dev = NULL;
441 free_netdev(mesh_dev);
442 lbs_deb_leave(LBS_DEB_MESH);
443}
444
445
446
447/***************************************************************************
448 * Sending and receiving
449 */
450struct net_device *lbs_mesh_set_dev(struct lbs_private *priv,
451 struct net_device *dev, struct rxpd *rxpd)
452{
453 if (priv->mesh_dev) {
454 if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID) {
455 if (rxpd->rx_control & RxPD_MESH_FRAME)
456 dev = priv->mesh_dev;
457 } else if (priv->mesh_tlv == TLV_TYPE_MESH_ID) {
458 if (rxpd->u.bss.bss_num == MESH_IFACE_ID)
459 dev = priv->mesh_dev;
460 }
461 }
462 return dev;
463}
464
465
466void lbs_mesh_set_txpd(struct lbs_private *priv,
467 struct net_device *dev, struct txpd *txpd)
468{
469 if (dev == priv->mesh_dev) {
470 if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID)
471 txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
472 else if (priv->mesh_tlv == TLV_TYPE_MESH_ID)
473 txpd->u.bss.bss_num = MESH_IFACE_ID;
474 }
475}
476
477
478/***************************************************************************
479 * Mesh command handling
480 */
481
482/**
483 * lbs_mesh_bt_add_del - Add or delete Mesh Blinding Table entries
484 *
485 * @priv: A pointer to &struct lbs_private structure
486 * @add: TRUE to add the entry, FALSE to delete it
487 * @addr1: Destination address to blind or unblind
488 *
489 * returns: 0 on success, error on failure
490 */
491int lbs_mesh_bt_add_del(struct lbs_private *priv, bool add, u8 *addr1)
492{
493 struct cmd_ds_bt_access cmd;
494 int ret = 0;
495
496 lbs_deb_enter(LBS_DEB_CMD);
497
498 BUG_ON(addr1 == NULL);
499
500 memset(&cmd, 0, sizeof(cmd));
501 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
502 memcpy(cmd.addr1, addr1, ETH_ALEN);
503 if (add) {
504 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_ADD);
505 lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr",
506 addr1, ETH_ALEN);
507 } else {
508 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_DEL);
509 lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr",
510 addr1, ETH_ALEN);
511 }
512
513 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
514
515 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
516 return ret;
517}
518
519/**
520 * lbs_mesh_bt_reset - Reset/clear the mesh blinding table
521 *
522 * @priv: A pointer to &struct lbs_private structure
523 *
524 * returns: 0 on success, error on failure
525 */
526int lbs_mesh_bt_reset(struct lbs_private *priv)
527{
528 struct cmd_ds_bt_access cmd;
529 int ret = 0;
530
531 lbs_deb_enter(LBS_DEB_CMD);
532
533 memset(&cmd, 0, sizeof(cmd));
534 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
535 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_RESET);
536
537 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
538
539 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
540 return ret;
541}
542
543/**
544 * lbs_mesh_bt_get_inverted - Gets the inverted status of the mesh
545 * blinding table
546 *
547 * Normally the firmware "blinds" or ignores traffic from mesh nodes in the
548 * table, but an inverted table allows *only* traffic from nodes listed in
549 * the table.
550 *
551 * @priv: A pointer to &struct lbs_private structure
552 * @inverted: On success, TRUE if the blinding table is inverted,
553 * FALSE if it is not inverted
554 *
555 * returns: 0 on success, error on failure
556 */
557int lbs_mesh_bt_get_inverted(struct lbs_private *priv, bool *inverted)
558{
559 struct cmd_ds_bt_access cmd;
560 int ret = 0;
561
562 lbs_deb_enter(LBS_DEB_CMD);
563
564 BUG_ON(inverted == NULL);
565
566 memset(&cmd, 0, sizeof(cmd));
567 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
568 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_GET_INVERT);
569
570 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
571 if (ret == 0)
572 *inverted = !!cmd.id;
573
574 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
575 return ret;
576}
577
578/**
579 * lbs_mesh_bt_set_inverted - Sets the inverted status of the mesh
580 * blinding table
581 *
582 * Normally the firmware "blinds" or ignores traffic from mesh nodes in the
583 * table, but an inverted table allows *only* traffic from nodes listed in
584 * the table.
585 *
586 * @priv: A pointer to &struct lbs_private structure
587 * @inverted: TRUE to invert the blinding table (only traffic from
588 * listed nodes allowed), FALSE to return it
589 * to normal state (listed nodes ignored)
590 *
591 * returns: 0 on success, error on failure
592 */
593int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted)
594{
595 struct cmd_ds_bt_access cmd;
596 int ret = 0;
597
598 lbs_deb_enter(LBS_DEB_CMD);
599
600 memset(&cmd, 0, sizeof(cmd));
601 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
602 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_SET_INVERT);
603 cmd.id = cpu_to_le32(!!inverted);
604
605 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
606
607 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
608 return ret;
609}
610
611/**
612 * lbs_mesh_bt_get_entry - List an entry in the mesh blinding table
613 *
614 * @priv: A pointer to &struct lbs_private structure
615 * @id: The ID of the entry to list
616 * @addr1: MAC address associated with the table entry
617 *
618 * returns: 0 on success, error on failure
619 */
620int lbs_mesh_bt_get_entry(struct lbs_private *priv, u32 id, u8 *addr1)
621{
622 struct cmd_ds_bt_access cmd;
623 int ret = 0;
624
625 lbs_deb_enter(LBS_DEB_CMD);
626
627 BUG_ON(addr1 == NULL);
628
629 memset(&cmd, 0, sizeof(cmd));
630 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
631 cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_SET_INVERT);
632 cmd.id = cpu_to_le32(id);
633
634 ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd);
635 if (ret == 0)
636 memcpy(addr1, cmd.addr1, sizeof(cmd.addr1));
637
638 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
639 return ret;
640}
641
642/**
643 * lbs_cmd_fwt_access - Access the mesh forwarding table
644 *
645 * @priv: A pointer to &struct lbs_private structure
646 * @cmd_action: The forwarding table action to perform
647 * @cmd: The pre-filled FWT_ACCESS command
648 *
649 * returns: 0 on success and 'cmd' will be filled with the
650 * firmware's response
651 */
652int lbs_cmd_fwt_access(struct lbs_private *priv, u16 cmd_action,
653 struct cmd_ds_fwt_access *cmd)
654{
655 int ret;
656
657 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
658
659 cmd->hdr.command = cpu_to_le16(CMD_FWT_ACCESS);
660 cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access));
661 cmd->hdr.result = 0;
662 cmd->action = cpu_to_le16(cmd_action);
663
664 ret = lbs_cmd_with_response(priv, CMD_FWT_ACCESS, cmd);
665
666 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
667 return 0;
668}
669
670int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action,
671 struct cmd_ds_mesh_access *cmd)
672{
673 int ret;
674
675 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
676
677 cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS);
678 cmd->hdr.size = cpu_to_le16(sizeof(*cmd));
679 cmd->hdr.result = 0;
680
681 cmd->action = cpu_to_le16(cmd_action);
682
683 ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd);
684
685 lbs_deb_leave(LBS_DEB_CMD);
686 return ret;
687}
688
689static int __lbs_mesh_config_send(struct lbs_private *priv,
690 struct cmd_ds_mesh_config *cmd,
691 uint16_t action, uint16_t type)
692{
693 int ret;
694 u16 command = CMD_MESH_CONFIG_OLD;
695
696 lbs_deb_enter(LBS_DEB_CMD);
697
698 /*
699 * Command id is 0xac for v10 FW along with mesh interface
700 * id in bits 14-13-12.
701 */
702 if (priv->mesh_tlv == TLV_TYPE_MESH_ID)
703 command = CMD_MESH_CONFIG |
704 (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET);
705
706 cmd->hdr.command = cpu_to_le16(command);
707 cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config));
708 cmd->hdr.result = 0;
709
710 cmd->type = cpu_to_le16(type);
711 cmd->action = cpu_to_le16(action);
712
713 ret = lbs_cmd_with_response(priv, command, cmd);
714
715 lbs_deb_leave(LBS_DEB_CMD);
716 return ret;
717}
718
719int lbs_mesh_config_send(struct lbs_private *priv,
720 struct cmd_ds_mesh_config *cmd,
721 uint16_t action, uint16_t type)
722{
723 int ret;
724
725 if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG))
726 return -EOPNOTSUPP;
727
728 ret = __lbs_mesh_config_send(priv, cmd, action, type);
729 return ret;
730}
731
732/* This function is the CMD_MESH_CONFIG legacy function. It only handles the
733 * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG
734 * are all handled by preparing a struct cmd_ds_mesh_config and passing it to
735 * lbs_mesh_config_send.
736 */
737int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
738{
739 struct cmd_ds_mesh_config cmd;
740 struct mrvl_meshie *ie;
741 DECLARE_SSID_BUF(ssid);
742
743 memset(&cmd, 0, sizeof(cmd));
744 cmd.channel = cpu_to_le16(chan);
745 ie = (struct mrvl_meshie *)cmd.data;
746
747 switch (action) {
748 case CMD_ACT_MESH_CONFIG_START:
749 ie->id = WLAN_EID_GENERIC;
750 ie->val.oui[0] = 0x00;
751 ie->val.oui[1] = 0x50;
752 ie->val.oui[2] = 0x43;
753 ie->val.type = MARVELL_MESH_IE_TYPE;
754 ie->val.subtype = MARVELL_MESH_IE_SUBTYPE;
755 ie->val.version = MARVELL_MESH_IE_VERSION;
756 ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP;
757 ie->val.active_metric_id = MARVELL_MESH_METRIC_ID;
758 ie->val.mesh_capability = MARVELL_MESH_CAPABILITY;
759 ie->val.mesh_id_len = priv->mesh_ssid_len;
760 memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len);
761 ie->len = sizeof(struct mrvl_meshie_val) -
762 IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len;
763 cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val));
764 break;
765 case CMD_ACT_MESH_CONFIG_STOP:
766 break;
767 default:
768 return -1;
769 }
770 lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n",
771 action, priv->mesh_tlv, chan,
772 print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len));
773
774 return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
775}
776
777
778
779/*************************************************************************** 317/***************************************************************************
780 * Persistent configuration support 318 * Persistent configuration support
781 */ 319 */
@@ -1232,7 +770,7 @@ static struct attribute *boot_opts_attrs[] = {
1232 NULL 770 NULL
1233}; 771};
1234 772
1235static struct attribute_group boot_opts_group = { 773static const struct attribute_group boot_opts_group = {
1236 .name = "boot_options", 774 .name = "boot_options",
1237 .attrs = boot_opts_attrs, 775 .attrs = boot_opts_attrs,
1238}; 776};
@@ -1245,31 +783,299 @@ static struct attribute *mesh_ie_attrs[] = {
1245 NULL 783 NULL
1246}; 784};
1247 785
1248static struct attribute_group mesh_ie_group = { 786static const struct attribute_group mesh_ie_group = {
1249 .name = "mesh_ie", 787 .name = "mesh_ie",
1250 .attrs = mesh_ie_attrs, 788 .attrs = mesh_ie_attrs,
1251}; 789};
1252 790
1253void lbs_persist_config_init(struct net_device *dev) 791static void lbs_persist_config_init(struct net_device *dev)
1254{ 792{
1255 int ret; 793 int ret;
1256 ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group); 794 ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group);
1257 ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group); 795 ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group);
1258} 796}
1259 797
1260void lbs_persist_config_remove(struct net_device *dev) 798static void lbs_persist_config_remove(struct net_device *dev)
1261{ 799{
1262 sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group); 800 sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group);
1263 sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group); 801 sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group);
1264} 802}
1265 803
1266 804
805/***************************************************************************
806 * Initializing and starting, stopping mesh
807 */
808
809/*
810 * Check mesh FW version and appropriately send the mesh start
811 * command
812 */
813int lbs_init_mesh(struct lbs_private *priv)
814{
815 struct net_device *dev = priv->dev;
816 int ret = 0;
817
818 lbs_deb_enter(LBS_DEB_MESH);
819
820 /* Determine mesh_fw_ver from fwrelease and fwcapinfo */
821 /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
822 /* 5.110.22 have mesh command with 0xa3 command id */
823 /* 10.0.0.p0 FW brings in mesh config command with different id */
824 /* Check FW version MSB and initialize mesh_fw_ver */
825 if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5) {
826 /* Enable mesh, if supported, and work out which TLV it uses.
827 0x100 + 291 is an unofficial value used in 5.110.20.pXX
828 0x100 + 37 is the official value used in 5.110.21.pXX
829 but we check them in that order because 20.pXX doesn't
830 give an error -- it just silently fails. */
831
832 /* 5.110.20.pXX firmware will fail the command if the channel
833 doesn't match the existing channel. But only if the TLV
834 is correct. If the channel is wrong, _BOTH_ versions will
835 give an error to 0x100+291, and allow 0x100+37 to succeed.
836 It's just that 5.110.20.pXX will not have done anything
837 useful */
838
839 priv->mesh_tlv = TLV_TYPE_OLD_MESH_ID;
840 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
841 priv->channel)) {
842 priv->mesh_tlv = TLV_TYPE_MESH_ID;
843 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
844 priv->channel))
845 priv->mesh_tlv = 0;
846 }
847 } else
848 if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
849 (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK)) {
850 /* 10.0.0.pXX new firmwares should succeed with TLV
851 * 0x100+37; Do not invoke command with old TLV.
852 */
853 priv->mesh_tlv = TLV_TYPE_MESH_ID;
854 if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
855 priv->channel))
856 priv->mesh_tlv = 0;
857 }
858
859 /* Stop meshing until interface is brought up */
860 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, priv->channel);
861
862 if (priv->mesh_tlv) {
863 sprintf(priv->mesh_ssid, "mesh");
864 priv->mesh_ssid_len = 4;
865
866 lbs_add_mesh(priv);
867
868 if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
869 netdev_err(dev, "cannot register lbs_mesh attribute\n");
870
871 ret = 1;
872 }
873
874 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
875 return ret;
876}
877
878
879int lbs_deinit_mesh(struct lbs_private *priv)
880{
881 struct net_device *dev = priv->dev;
882 int ret = 0;
883
884 lbs_deb_enter(LBS_DEB_MESH);
885
886 if (priv->mesh_tlv) {
887 device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
888 ret = 1;
889 }
890
891 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
892 return ret;
893}
894
895
896/**
897 * lbs_mesh_stop - close the mshX interface
898 *
899 * @dev: A pointer to &net_device structure
900 * returns: 0
901 */
902static int lbs_mesh_stop(struct net_device *dev)
903{
904 struct lbs_private *priv = dev->ml_priv;
905
906 lbs_deb_enter(LBS_DEB_MESH);
907 lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, priv->channel);
908
909 spin_lock_irq(&priv->driver_lock);
910
911 netif_stop_queue(dev);
912 netif_carrier_off(dev);
913
914 spin_unlock_irq(&priv->driver_lock);
915
916 schedule_work(&priv->mcast_work);
917
918 lbs_deb_leave(LBS_DEB_MESH);
919 return 0;
920}
921
922/**
923 * lbs_mesh_dev_open - open the mshX interface
924 *
925 * @dev: A pointer to &net_device structure
926 * returns: 0 or -EBUSY if monitor mode active
927 */
928static int lbs_mesh_dev_open(struct net_device *dev)
929{
930 struct lbs_private *priv = dev->ml_priv;
931 int ret = 0;
932
933 lbs_deb_enter(LBS_DEB_NET);
934
935 spin_lock_irq(&priv->driver_lock);
936
937 if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) {
938 ret = -EBUSY;
939 spin_unlock_irq(&priv->driver_lock);
940 goto out;
941 }
942
943 netif_carrier_on(dev);
944
945 if (!priv->tx_pending_len)
946 netif_wake_queue(dev);
947
948 spin_unlock_irq(&priv->driver_lock);
949
950 ret = lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, priv->channel);
951
952out:
953 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
954 return ret;
955}
956
957static const struct net_device_ops mesh_netdev_ops = {
958 .ndo_open = lbs_mesh_dev_open,
959 .ndo_stop = lbs_mesh_stop,
960 .ndo_start_xmit = lbs_hard_start_xmit,
961 .ndo_set_mac_address = lbs_set_mac_address,
962 .ndo_set_multicast_list = lbs_set_multicast_list,
963};
964
965/**
966 * lbs_add_mesh - add mshX interface
967 *
968 * @priv: A pointer to the &struct lbs_private structure
969 * returns: 0 if successful, -X otherwise
970 */
971static int lbs_add_mesh(struct lbs_private *priv)
972{
973 struct net_device *mesh_dev = NULL;
974 int ret = 0;
975
976 lbs_deb_enter(LBS_DEB_MESH);
977
978 /* Allocate a virtual mesh device */
979 mesh_dev = alloc_netdev(0, "msh%d", ether_setup);
980 if (!mesh_dev) {
981 lbs_deb_mesh("init mshX device failed\n");
982 ret = -ENOMEM;
983 goto done;
984 }
985 mesh_dev->ml_priv = priv;
986 priv->mesh_dev = mesh_dev;
987
988 mesh_dev->netdev_ops = &mesh_netdev_ops;
989 mesh_dev->ethtool_ops = &lbs_ethtool_ops;
990 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, ETH_ALEN);
991
992 SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
993
994 mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
995 /* Register virtual mesh interface */
996 ret = register_netdev(mesh_dev);
997 if (ret) {
998 pr_err("cannot register mshX virtual interface\n");
999 goto err_free;
1000 }
1001
1002 ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
1003 if (ret)
1004 goto err_unregister;
1005
1006 lbs_persist_config_init(mesh_dev);
1007
1008 /* Everything successful */
1009 ret = 0;
1010 goto done;
1011
1012err_unregister:
1013 unregister_netdev(mesh_dev);
1014
1015err_free:
1016 free_netdev(mesh_dev);
1017
1018done:
1019 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
1020 return ret;
1021}
1022
1023void lbs_remove_mesh(struct lbs_private *priv)
1024{
1025 struct net_device *mesh_dev;
1026
1027 mesh_dev = priv->mesh_dev;
1028 if (!mesh_dev)
1029 return;
1030
1031 lbs_deb_enter(LBS_DEB_MESH);
1032 netif_stop_queue(mesh_dev);
1033 netif_carrier_off(mesh_dev);
1034 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
1035 lbs_persist_config_remove(mesh_dev);
1036 unregister_netdev(mesh_dev);
1037 priv->mesh_dev = NULL;
1038 free_netdev(mesh_dev);
1039 lbs_deb_leave(LBS_DEB_MESH);
1040}
1041
1042
1043/***************************************************************************
1044 * Sending and receiving
1045 */
1046struct net_device *lbs_mesh_set_dev(struct lbs_private *priv,
1047 struct net_device *dev, struct rxpd *rxpd)
1048{
1049 if (priv->mesh_dev) {
1050 if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID) {
1051 if (rxpd->rx_control & RxPD_MESH_FRAME)
1052 dev = priv->mesh_dev;
1053 } else if (priv->mesh_tlv == TLV_TYPE_MESH_ID) {
1054 if (rxpd->u.bss.bss_num == MESH_IFACE_ID)
1055 dev = priv->mesh_dev;
1056 }
1057 }
1058 return dev;
1059}
1060
1061
1062void lbs_mesh_set_txpd(struct lbs_private *priv,
1063 struct net_device *dev, struct txpd *txpd)
1064{
1065 if (dev == priv->mesh_dev) {
1066 if (priv->mesh_tlv == TLV_TYPE_OLD_MESH_ID)
1067 txpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME);
1068 else if (priv->mesh_tlv == TLV_TYPE_MESH_ID)
1069 txpd->u.bss.bss_num = MESH_IFACE_ID;
1070 }
1071}
1072
1267 1073
1268/*************************************************************************** 1074/***************************************************************************
1269 * Ethtool related 1075 * Ethtool related
1270 */ 1076 */
1271 1077
1272static const char *mesh_stat_strings[] = { 1078static const char * const mesh_stat_strings[] = {
1273 "drop_duplicate_bcast", 1079 "drop_duplicate_bcast",
1274 "drop_ttl_zero", 1080 "drop_ttl_zero",
1275 "drop_no_fwd_route", 1081 "drop_no_fwd_route",
diff --git a/drivers/net/wireless/libertas/mesh.h b/drivers/net/wireless/libertas/mesh.h
index ee95c73ed5f4..50144913f2ab 100644
--- a/drivers/net/wireless/libertas/mesh.h
+++ b/drivers/net/wireless/libertas/mesh.h
@@ -31,7 +31,6 @@ struct lbs_private;
31int lbs_init_mesh(struct lbs_private *priv); 31int lbs_init_mesh(struct lbs_private *priv);
32int lbs_deinit_mesh(struct lbs_private *priv); 32int lbs_deinit_mesh(struct lbs_private *priv);
33 33
34int lbs_add_mesh(struct lbs_private *priv);
35void lbs_remove_mesh(struct lbs_private *priv); 34void lbs_remove_mesh(struct lbs_private *priv);
36 35
37 36
@@ -52,29 +51,6 @@ struct cmd_ds_command;
52struct cmd_ds_mesh_access; 51struct cmd_ds_mesh_access;
53struct cmd_ds_mesh_config; 52struct cmd_ds_mesh_config;
54 53
55int lbs_mesh_bt_add_del(struct lbs_private *priv, bool add, u8 *addr1);
56int lbs_mesh_bt_reset(struct lbs_private *priv);
57int lbs_mesh_bt_get_inverted(struct lbs_private *priv, bool *inverted);
58int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted);
59int lbs_mesh_bt_get_entry(struct lbs_private *priv, u32 id, u8 *addr1);
60
61int lbs_cmd_fwt_access(struct lbs_private *priv, u16 cmd_action,
62 struct cmd_ds_fwt_access *cmd);
63
64int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action,
65 struct cmd_ds_mesh_access *cmd);
66int lbs_mesh_config_send(struct lbs_private *priv,
67 struct cmd_ds_mesh_config *cmd,
68 uint16_t action, uint16_t type);
69int lbs_mesh_config(struct lbs_private *priv, uint16_t enable, uint16_t chan);
70
71
72
73/* Persistent configuration */
74
75void lbs_persist_config_init(struct net_device *net);
76void lbs_persist_config_remove(struct net_device *net);
77
78 54
79/* Ethtool statistics */ 55/* Ethtool statistics */
80 56
@@ -87,11 +63,6 @@ void lbs_mesh_ethtool_get_strings(struct net_device *dev,
87 uint32_t stringset, uint8_t *s); 63 uint32_t stringset, uint8_t *s);
88 64
89 65
90/* Accessors */
91
92#define lbs_mesh_open(priv) (priv->mesh_open)
93#define lbs_mesh_connected(priv) (priv->mesh_connect_status == LBS_CONNECTED)
94
95#else 66#else
96 67
97#define lbs_init_mesh(priv) 68#define lbs_init_mesh(priv)
@@ -101,8 +72,6 @@ void lbs_mesh_ethtool_get_strings(struct net_device *dev,
101#define lbs_mesh_set_dev(priv, dev, rxpd) (dev) 72#define lbs_mesh_set_dev(priv, dev, rxpd) (dev)
102#define lbs_mesh_set_txpd(priv, dev, txpd) 73#define lbs_mesh_set_txpd(priv, dev, txpd)
103#define lbs_mesh_config(priv, enable, chan) 74#define lbs_mesh_config(priv, enable, chan)
104#define lbs_mesh_open(priv) (0)
105#define lbs_mesh_connected(priv) (0)
106 75
107#endif 76#endif
108 77
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index f19495b178f6..a6e85134cfe1 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -199,7 +199,7 @@ void lbs_send_tx_feedback(struct lbs_private *priv, u32 try_count)
199 if (priv->connect_status == LBS_CONNECTED) 199 if (priv->connect_status == LBS_CONNECTED)
200 netif_wake_queue(priv->dev); 200 netif_wake_queue(priv->dev);
201 201
202 if (priv->mesh_dev && lbs_mesh_connected(priv)) 202 if (priv->mesh_dev && netif_running(priv->mesh_dev))
203 netif_wake_queue(priv->mesh_dev); 203 netif_wake_queue(priv->mesh_dev);
204} 204}
205EXPORT_SYMBOL_GPL(lbs_send_tx_feedback); 205EXPORT_SYMBOL_GPL(lbs_send_tx_feedback);
diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
index 1bcf9eaa107d..d26a78b6b3c4 100644
--- a/drivers/net/wireless/mwifiex/debugfs.c
+++ b/drivers/net/wireless/mwifiex/debugfs.c
@@ -216,28 +216,19 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
216 p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]); 216 p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
217 p += sprintf(p, "media_state=\"%s\"\n", 217 p += sprintf(p, "media_state=\"%s\"\n",
218 (!priv->media_connected ? "Disconnected" : "Connected")); 218 (!priv->media_connected ? "Disconnected" : "Connected"));
219 p += sprintf(p, "mac_address=\"%02x:%02x:%02x:%02x:%02x:%02x\"\n", 219 p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);
220 netdev->dev_addr[0], netdev->dev_addr[1],
221 netdev->dev_addr[2], netdev->dev_addr[3],
222 netdev->dev_addr[4], netdev->dev_addr[5]);
223 220
224 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) { 221 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) {
225 p += sprintf(p, "multicast_count=\"%d\"\n", 222 p += sprintf(p, "multicast_count=\"%d\"\n",
226 netdev_mc_count(netdev)); 223 netdev_mc_count(netdev));
227 p += sprintf(p, "essid=\"%s\"\n", info.ssid.ssid); 224 p += sprintf(p, "essid=\"%s\"\n", info.ssid.ssid);
228 p += sprintf(p, "bssid=\"%02x:%02x:%02x:%02x:%02x:%02x\"\n", 225 p += sprintf(p, "bssid=\"%pM\"\n", info.bssid);
229 info.bssid[0], info.bssid[1],
230 info.bssid[2], info.bssid[3],
231 info.bssid[4], info.bssid[5]);
232 p += sprintf(p, "channel=\"%d\"\n", (int) info.bss_chan); 226 p += sprintf(p, "channel=\"%d\"\n", (int) info.bss_chan);
233 p += sprintf(p, "region_code = \"%02x\"\n", info.region_code); 227 p += sprintf(p, "region_code = \"%02x\"\n", info.region_code);
234 228
235 netdev_for_each_mc_addr(ha, netdev) 229 netdev_for_each_mc_addr(ha, netdev)
236 p += sprintf(p, "multicast_address[%d]=" 230 p += sprintf(p, "multicast_address[%d]=\"%pM\"\n",
237 "\"%02x:%02x:%02x:%02x:%02x:%02x\"\n", i++, 231 i++, ha->addr);
238 ha->addr[0], ha->addr[1],
239 ha->addr[2], ha->addr[3],
240 ha->addr[4], ha->addr[5]);
241 } 232 }
242 233
243 p += sprintf(p, "num_tx_bytes = %lu\n", priv->stats.tx_bytes); 234 p += sprintf(p, "num_tx_bytes = %lu\n", priv->stats.tx_bytes);
@@ -451,26 +442,18 @@ mwifiex_debug_read(struct file *file, char __user *ubuf,
451 if (info.tx_tbl_num) { 442 if (info.tx_tbl_num) {
452 p += sprintf(p, "Tx BA stream table:\n"); 443 p += sprintf(p, "Tx BA stream table:\n");
453 for (i = 0; i < info.tx_tbl_num; i++) 444 for (i = 0; i < info.tx_tbl_num; i++)
454 p += sprintf(p, "tid = %d, " 445 p += sprintf(p, "tid = %d, ra = %pM\n",
455 "ra = %02x:%02x:%02x:%02x:%02x:%02x\n", 446 info.tx_tbl[i].tid, info.tx_tbl[i].ra);
456 info.tx_tbl[i].tid, info.tx_tbl[i].ra[0],
457 info.tx_tbl[i].ra[1], info.tx_tbl[i].ra[2],
458 info.tx_tbl[i].ra[3], info.tx_tbl[i].ra[4],
459 info.tx_tbl[i].ra[5]);
460 } 447 }
461 448
462 if (info.rx_tbl_num) { 449 if (info.rx_tbl_num) {
463 p += sprintf(p, "Rx reorder table:\n"); 450 p += sprintf(p, "Rx reorder table:\n");
464 for (i = 0; i < info.rx_tbl_num; i++) { 451 for (i = 0; i < info.rx_tbl_num; i++) {
465 452 p += sprintf(p, "tid = %d, ta = %pM, "
466 p += sprintf(p, "tid = %d, "
467 "ta = %02x:%02x:%02x:%02x:%02x:%02x, "
468 "start_win = %d, " 453 "start_win = %d, "
469 "win_size = %d, buffer: ", 454 "win_size = %d, buffer: ",
470 info.rx_tbl[i].tid, 455 info.rx_tbl[i].tid,
471 info.rx_tbl[i].ta[0], info.rx_tbl[i].ta[1], 456 info.rx_tbl[i].ta,
472 info.rx_tbl[i].ta[2], info.rx_tbl[i].ta[3],
473 info.rx_tbl[i].ta[4], info.rx_tbl[i].ta[5],
474 info.rx_tbl[i].start_win, 457 info.rx_tbl[i].start_win,
475 info.rx_tbl[i].win_size); 458 info.rx_tbl[i].win_size);
476 459
diff --git a/drivers/net/wireless/mwifiex/ioctl.h b/drivers/net/wireless/mwifiex/ioctl.h
index 7c1c5ee40eb9..f6bcc868562f 100644
--- a/drivers/net/wireless/mwifiex/ioctl.h
+++ b/drivers/net/wireless/mwifiex/ioctl.h
@@ -249,6 +249,7 @@ struct mwifiex_ds_hs_cfg {
249}; 249};
250 250
251#define DEEP_SLEEP_ON 1 251#define DEEP_SLEEP_ON 1
252#define DEEP_SLEEP_OFF 0
252#define DEEP_SLEEP_IDLE_TIME 100 253#define DEEP_SLEEP_IDLE_TIME 100
253#define PS_MODE_AUTO 1 254#define PS_MODE_AUTO 1
254 255
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 03691c02a6e8..2215c3c97354 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -929,6 +929,7 @@ int mwifiex_set_hs_params(struct mwifiex_private *priv,
929 struct mwifiex_ds_hs_cfg *hscfg); 929 struct mwifiex_ds_hs_cfg *hscfg);
930int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type); 930int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
931int mwifiex_enable_hs(struct mwifiex_adapter *adapter); 931int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
932int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
932int mwifiex_get_signal_info(struct mwifiex_private *priv, 933int mwifiex_get_signal_info(struct mwifiex_private *priv,
933 struct mwifiex_ds_get_signal *signal); 934 struct mwifiex_ds_get_signal *signal);
934int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, 935int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index 711fa689a95c..82098ac483b8 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -133,6 +133,9 @@ mwifiex_sdio_remove(struct sdio_func *func)
133 adapter->priv[i]->media_connected) 133 adapter->priv[i]->media_connected)
134 mwifiex_deauthenticate(adapter->priv[i], NULL); 134 mwifiex_deauthenticate(adapter->priv[i], NULL);
135 135
136 mwifiex_disable_auto_ds(mwifiex_get_priv(adapter,
137 MWIFIEX_BSS_ROLE_ANY));
138
136 mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, 139 mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter,
137 MWIFIEX_BSS_ROLE_ANY), 140 MWIFIEX_BSS_ROLE_ANY),
138 MWIFIEX_FUNC_SHUTDOWN); 141 MWIFIEX_FUNC_SHUTDOWN);
@@ -1319,7 +1322,7 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter,
1319 if (!(card->mp_wr_bitmap & 1322 if (!(card->mp_wr_bitmap &
1320 (1 << card->curr_wr_port)) 1323 (1 << card->curr_wr_port))
1321 || !MP_TX_AGGR_BUF_HAS_ROOM( 1324 || !MP_TX_AGGR_BUF_HAS_ROOM(
1322 card, next_pkt_len)) 1325 card, pkt_len + next_pkt_len))
1323 f_send_aggr_buf = 1; 1326 f_send_aggr_buf = 1;
1324 } else { 1327 } else {
1325 /* No room in Aggr buf, send it */ 1328 /* No room in Aggr buf, send it */
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index d05907d05039..c34ff8c4f4f8 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -487,6 +487,20 @@ int mwifiex_set_radio_band_cfg(struct mwifiex_private *priv,
487} 487}
488 488
489/* 489/*
490 * The function disables auto deep sleep mode.
491 */
492int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
493{
494 struct mwifiex_ds_auto_ds auto_ds;
495
496 auto_ds.auto_ds = DEEP_SLEEP_OFF;
497
498 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
499 DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds);
500}
501EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
502
503/*
490 * IOCTL request handler to set/get active channel. 504 * IOCTL request handler to set/get active channel.
491 * 505 *
492 * This function performs validity checking on channel/frequency 506 * This function performs validity checking on channel/frequency
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index 67b2d0b78c71..69e260b41711 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -634,6 +634,8 @@ mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter,
634 ra_list = NULL; 634 ra_list = NULL;
635 } else { 635 } else {
636 memcpy(ra, skb->data, ETH_ALEN); 636 memcpy(ra, skb->data, ETH_ALEN);
637 if (ra[0] & 0x01)
638 memset(ra, 0xff, ETH_ALEN);
637 ra_list = mwifiex_wmm_get_queue_raptr(priv, tid_down, ra); 639 ra_list = mwifiex_wmm_get_queue_raptr(priv, tid_down, ra);
638 } 640 }
639 641
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index d633edbd9796..da36dbf8d871 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -1892,9 +1892,9 @@ mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb)
1892 1892
1893 txpriority = index; 1893 txpriority = index;
1894 1894
1895 if (ieee80211_is_data_qos(wh->frame_control) && 1895 if (priv->ap_fw && sta && sta->ht_cap.ht_supported
1896 skb->protocol != cpu_to_be16(ETH_P_PAE) && 1896 && skb->protocol != cpu_to_be16(ETH_P_PAE)
1897 sta->ht_cap.ht_supported && priv->ap_fw) { 1897 && ieee80211_is_data_qos(wh->frame_control)) {
1898 tid = qos & 0xf; 1898 tid = qos & 0xf;
1899 mwl8k_tx_count_packet(sta, tid); 1899 mwl8k_tx_count_packet(sta, tid);
1900 spin_lock(&priv->stream_lock); 1900 spin_lock(&priv->stream_lock);
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c
index 4a0a0e5265c9..0ca8b1455cd9 100644
--- a/drivers/net/wireless/orinoco/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
@@ -150,7 +150,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
150 struct orinoco_private *priv; 150 struct orinoco_private *priv;
151 struct airport *card; 151 struct airport *card;
152 unsigned long phys_addr; 152 unsigned long phys_addr;
153 hermes_t *hw; 153 struct hermes *hw;
154 154
155 if (macio_resource_count(mdev) < 1 || macio_irq_count(mdev) < 1) { 155 if (macio_resource_count(mdev) < 1 || macio_irq_count(mdev) < 1) {
156 printk(KERN_ERR PFX "Wrong interrupt/addresses in OF tree\n"); 156 printk(KERN_ERR PFX "Wrong interrupt/addresses in OF tree\n");
@@ -228,10 +228,9 @@ MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
228MODULE_DESCRIPTION("Driver for the Apple Airport wireless card."); 228MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
229MODULE_LICENSE("Dual MPL/GPL"); 229MODULE_LICENSE("Dual MPL/GPL");
230 230
231static struct of_device_id airport_match[] = 231static struct of_device_id airport_match[] = {
232{
233 { 232 {
234 .name = "radio", 233 .name = "radio",
235 }, 234 },
236 {}, 235 {},
237}; 236};
@@ -240,7 +239,7 @@ MODULE_DEVICE_TABLE(of, airport_match);
240 239
241static struct macio_driver airport_driver = { 240static struct macio_driver airport_driver = {
242 .driver = { 241 .driver = {
243 .name = DRIVER_NAME, 242 .name = DRIVER_NAME,
244 .owner = THIS_MODULE, 243 .owner = THIS_MODULE,
245 .of_match_table = airport_match, 244 .of_match_table = airport_match,
246 }, 245 },
diff --git a/drivers/net/wireless/orinoco/cfg.c b/drivers/net/wireless/orinoco/cfg.c
index 736bbb9bd1d0..f7b15b8934fa 100644
--- a/drivers/net/wireless/orinoco/cfg.c
+++ b/drivers/net/wireless/orinoco/cfg.c
@@ -59,7 +59,7 @@ int orinoco_wiphy_register(struct wiphy *wiphy)
59 for (i = 0; i < NUM_CHANNELS; i++) { 59 for (i = 0; i < NUM_CHANNELS; i++) {
60 if (priv->channel_mask & (1 << i)) { 60 if (priv->channel_mask & (1 << i)) {
61 priv->channels[i].center_freq = 61 priv->channels[i].center_freq =
62 ieee80211_dsss_chan_to_freq(i+1); 62 ieee80211_dsss_chan_to_freq(i + 1);
63 channels++; 63 channels++;
64 } 64 }
65 } 65 }
@@ -182,7 +182,7 @@ static int orinoco_set_channel(struct wiphy *wiphy,
182 channel = ieee80211_freq_to_dsss_chan(chan->center_freq); 182 channel = ieee80211_freq_to_dsss_chan(chan->center_freq);
183 183
184 if ((channel < 1) || (channel > NUM_CHANNELS) || 184 if ((channel < 1) || (channel > NUM_CHANNELS) ||
185 !(priv->channel_mask & (1 << (channel-1)))) 185 !(priv->channel_mask & (1 << (channel - 1))))
186 return -EINVAL; 186 return -EINVAL;
187 187
188 if (orinoco_lock(priv, &flags) != 0) 188 if (orinoco_lock(priv, &flags) != 0)
@@ -191,7 +191,7 @@ static int orinoco_set_channel(struct wiphy *wiphy,
191 priv->channel = channel; 191 priv->channel = channel;
192 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 192 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
193 /* Fast channel change - no commit if successful */ 193 /* Fast channel change - no commit if successful */
194 hermes_t *hw = &priv->hw; 194 struct hermes *hw = &priv->hw;
195 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST | 195 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
196 HERMES_TEST_SET_CHANNEL, 196 HERMES_TEST_SET_CHANNEL,
197 channel, NULL); 197 channel, NULL);
diff --git a/drivers/net/wireless/orinoco/fw.c b/drivers/net/wireless/orinoco/fw.c
index 259d75853984..527cf5333db5 100644
--- a/drivers/net/wireless/orinoco/fw.c
+++ b/drivers/net/wireless/orinoco/fw.c
@@ -100,7 +100,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
100 /* Plug Data Area (PDA) */ 100 /* Plug Data Area (PDA) */
101 __le16 *pda; 101 __le16 *pda;
102 102
103 hermes_t *hw = &priv->hw; 103 struct hermes *hw = &priv->hw;
104 const struct firmware *fw_entry; 104 const struct firmware *fw_entry;
105 const struct orinoco_fw_header *hdr; 105 const struct orinoco_fw_header *hdr;
106 const unsigned char *first_block; 106 const unsigned char *first_block;
@@ -205,7 +205,7 @@ symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw,
205 const unsigned char *image, const void *end, 205 const unsigned char *image, const void *end,
206 int secondary) 206 int secondary)
207{ 207{
208 hermes_t *hw = &priv->hw; 208 struct hermes *hw = &priv->hw;
209 int ret = 0; 209 int ret = 0;
210 const unsigned char *ptr; 210 const unsigned char *ptr;
211 const unsigned char *first_block; 211 const unsigned char *first_block;
@@ -322,9 +322,8 @@ symbol_dl_firmware(struct orinoco_private *priv,
322 fw_entry->data + fw_entry->size, 1); 322 fw_entry->data + fw_entry->size, 1);
323 if (!orinoco_cached_fw_get(priv, false)) 323 if (!orinoco_cached_fw_get(priv, false))
324 release_firmware(fw_entry); 324 release_firmware(fw_entry);
325 if (ret) { 325 if (ret)
326 dev_err(dev, "Secondary firmware download failed\n"); 326 dev_err(dev, "Secondary firmware download failed\n");
327 }
328 327
329 return ret; 328 return ret;
330} 329}
diff --git a/drivers/net/wireless/orinoco/fw.h b/drivers/net/wireless/orinoco/fw.h
index 89fc26d25b06..aca63e3c4b5b 100644
--- a/drivers/net/wireless/orinoco/fw.h
+++ b/drivers/net/wireless/orinoco/fw.h
@@ -14,7 +14,7 @@ int orinoco_download(struct orinoco_private *priv);
14void orinoco_cache_fw(struct orinoco_private *priv, int ap); 14void orinoco_cache_fw(struct orinoco_private *priv, int ap);
15void orinoco_uncache_fw(struct orinoco_private *priv); 15void orinoco_uncache_fw(struct orinoco_private *priv);
16#else 16#else
17#define orinoco_cache_fw(priv, ap) do { } while(0) 17#define orinoco_cache_fw(priv, ap) do { } while (0)
18#define orinoco_uncache_fw(priv) do { } while (0) 18#define orinoco_uncache_fw(priv) do { } while (0)
19#endif 19#endif
20 20
diff --git a/drivers/net/wireless/orinoco/hermes.c b/drivers/net/wireless/orinoco/hermes.c
index 6c6a23e08df6..75c15bc7b34c 100644
--- a/drivers/net/wireless/orinoco/hermes.c
+++ b/drivers/net/wireless/orinoco/hermes.c
@@ -103,7 +103,7 @@ static const struct hermes_ops hermes_ops_local;
103 103
104 Callable from any context. 104 Callable from any context.
105*/ 105*/
106static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0, 106static int hermes_issue_cmd(struct hermes *hw, u16 cmd, u16 param0,
107 u16 param1, u16 param2) 107 u16 param1, u16 param2)
108{ 108{
109 int k = CMD_BUSY_TIMEOUT; 109 int k = CMD_BUSY_TIMEOUT;
@@ -132,7 +132,7 @@ static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0,
132 */ 132 */
133 133
134/* For doing cmds that wipe the magic constant in SWSUPPORT0 */ 134/* For doing cmds that wipe the magic constant in SWSUPPORT0 */
135static int hermes_doicmd_wait(hermes_t *hw, u16 cmd, 135static int hermes_doicmd_wait(struct hermes *hw, u16 cmd,
136 u16 parm0, u16 parm1, u16 parm2, 136 u16 parm0, u16 parm1, u16 parm2,
137 struct hermes_response *resp) 137 struct hermes_response *resp)
138{ 138{
@@ -185,7 +185,8 @@ out:
185 return err; 185 return err;
186} 186}
187 187
188void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing) 188void hermes_struct_init(struct hermes *hw, void __iomem *address,
189 int reg_spacing)
189{ 190{
190 hw->iobase = address; 191 hw->iobase = address;
191 hw->reg_spacing = reg_spacing; 192 hw->reg_spacing = reg_spacing;
@@ -195,7 +196,7 @@ void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
195} 196}
196EXPORT_SYMBOL(hermes_struct_init); 197EXPORT_SYMBOL(hermes_struct_init);
197 198
198static int hermes_init(hermes_t *hw) 199static int hermes_init(struct hermes *hw)
199{ 200{
200 u16 reg; 201 u16 reg;
201 int err = 0; 202 int err = 0;
@@ -249,7 +250,7 @@ static int hermes_init(hermes_t *hw)
249 * > 0 on error returned by the firmware 250 * > 0 on error returned by the firmware
250 * 251 *
251 * Callable from any context, but locking is your problem. */ 252 * Callable from any context, but locking is your problem. */
252static int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0, 253static int hermes_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
253 struct hermes_response *resp) 254 struct hermes_response *resp)
254{ 255{
255 int err; 256 int err;
@@ -313,7 +314,7 @@ static int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
313 return err; 314 return err;
314} 315}
315 316
316static int hermes_allocate(hermes_t *hw, u16 size, u16 *fid) 317static int hermes_allocate(struct hermes *hw, u16 size, u16 *fid)
317{ 318{
318 int err = 0; 319 int err = 0;
319 int k; 320 int k;
@@ -363,7 +364,7 @@ static int hermes_allocate(hermes_t *hw, u16 size, u16 *fid)
363 * from firmware 364 * from firmware
364 * 365 *
365 * Callable from any context */ 366 * Callable from any context */
366static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset) 367static int hermes_bap_seek(struct hermes *hw, int bap, u16 id, u16 offset)
367{ 368{
368 int sreg = bap ? HERMES_SELECT1 : HERMES_SELECT0; 369 int sreg = bap ? HERMES_SELECT1 : HERMES_SELECT0;
369 int oreg = bap ? HERMES_OFFSET1 : HERMES_OFFSET0; 370 int oreg = bap ? HERMES_OFFSET1 : HERMES_OFFSET0;
@@ -422,7 +423,7 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
422 * 0 on success 423 * 0 on success
423 * > 0 on error from firmware 424 * > 0 on error from firmware
424 */ 425 */
425static int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len, 426static int hermes_bap_pread(struct hermes *hw, int bap, void *buf, int len,
426 u16 id, u16 offset) 427 u16 id, u16 offset)
427{ 428{
428 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 429 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -436,7 +437,7 @@ static int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
436 goto out; 437 goto out;
437 438
438 /* Actually do the transfer */ 439 /* Actually do the transfer */
439 hermes_read_words(hw, dreg, buf, len/2); 440 hermes_read_words(hw, dreg, buf, len / 2);
440 441
441 out: 442 out:
442 return err; 443 return err;
@@ -450,8 +451,8 @@ static int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
450 * 0 on success 451 * 0 on success
451 * > 0 on error from firmware 452 * > 0 on error from firmware
452 */ 453 */
453static int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, 454static int hermes_bap_pwrite(struct hermes *hw, int bap, const void *buf,
454 u16 id, u16 offset) 455 int len, u16 id, u16 offset)
455{ 456{
456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 457 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
457 int err = 0; 458 int err = 0;
@@ -478,8 +479,8 @@ static int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
478 * practice. 479 * practice.
479 * 480 *
480 * Callable from user or bh context. */ 481 * Callable from user or bh context. */
481static int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize, 482static int hermes_read_ltv(struct hermes *hw, int bap, u16 rid,
482 u16 *length, void *buf) 483 unsigned bufsize, u16 *length, void *buf)
483{ 484{
484 int err = 0; 485 int err = 0;
485 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 486 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -523,7 +524,7 @@ static int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
523 return 0; 524 return 0;
524} 525}
525 526
526static int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 527static int hermes_write_ltv(struct hermes *hw, int bap, u16 rid,
527 u16 length, const void *value) 528 u16 length, const void *value)
528{ 529{
529 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 530 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -553,14 +554,14 @@ static int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
553/*** Hermes AUX control ***/ 554/*** Hermes AUX control ***/
554 555
555static inline void 556static inline void
556hermes_aux_setaddr(hermes_t *hw, u32 addr) 557hermes_aux_setaddr(struct hermes *hw, u32 addr)
557{ 558{
558 hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7)); 559 hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7));
559 hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F)); 560 hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F));
560} 561}
561 562
562static inline int 563static inline int
563hermes_aux_control(hermes_t *hw, int enabled) 564hermes_aux_control(struct hermes *hw, int enabled)
564{ 565{
565 int desired_state = enabled ? HERMES_AUX_ENABLED : HERMES_AUX_DISABLED; 566 int desired_state = enabled ? HERMES_AUX_ENABLED : HERMES_AUX_DISABLED;
566 int action = enabled ? HERMES_AUX_ENABLE : HERMES_AUX_DISABLE; 567 int action = enabled ? HERMES_AUX_ENABLE : HERMES_AUX_DISABLE;
@@ -594,7 +595,7 @@ hermes_aux_control(hermes_t *hw, int enabled)
594 * wl_lkm Agere fw does 595 * wl_lkm Agere fw does
595 * Don't know about intersil 596 * Don't know about intersil
596 */ 597 */
597static int hermesi_program_init(hermes_t *hw, u32 offset) 598static int hermesi_program_init(struct hermes *hw, u32 offset)
598{ 599{
599 int err; 600 int err;
600 601
@@ -643,7 +644,7 @@ static int hermesi_program_init(hermes_t *hw, u32 offset)
643 * wl_lkm Agere fw does 644 * wl_lkm Agere fw does
644 * Don't know about intersil 645 * Don't know about intersil
645 */ 646 */
646static int hermesi_program_end(hermes_t *hw) 647static int hermesi_program_end(struct hermes *hw)
647{ 648{
648 struct hermes_response resp; 649 struct hermes_response resp;
649 int rc = 0; 650 int rc = 0;
@@ -684,7 +685,8 @@ static int hermes_program_bytes(struct hermes *hw, const char *data,
684} 685}
685 686
686/* Read PDA from the adapter */ 687/* Read PDA from the adapter */
687static int hermes_read_pda(hermes_t *hw, __le16 *pda, u32 pda_addr, u16 pda_len) 688static int hermes_read_pda(struct hermes *hw, __le16 *pda, u32 pda_addr,
689 u16 pda_len)
688{ 690{
689 int ret; 691 int ret;
690 u16 pda_size; 692 u16 pda_size;
diff --git a/drivers/net/wireless/orinoco/hermes.h b/drivers/net/wireless/orinoco/hermes.h
index d9f18c11682a..28a42448d329 100644
--- a/drivers/net/wireless/orinoco/hermes.h
+++ b/drivers/net/wireless/orinoco/hermes.h
@@ -28,7 +28,7 @@
28 * 28 *
29 * As a module of low level hardware access routines, there is no 29 * As a module of low level hardware access routines, there is no
30 * locking. Users of this module should ensure that they serialize 30 * locking. Users of this module should ensure that they serialize
31 * access to the hermes_t structure, and to the hardware 31 * access to the hermes structure, and to the hardware
32*/ 32*/
33 33
34#include <linux/if_ether.h> 34#include <linux/if_ether.h>
@@ -43,7 +43,7 @@
43#define HERMES_BAP_DATALEN_MAX (4096) 43#define HERMES_BAP_DATALEN_MAX (4096)
44#define HERMES_BAP_OFFSET_MAX (4096) 44#define HERMES_BAP_OFFSET_MAX (4096)
45#define HERMES_PORTID_MAX (7) 45#define HERMES_PORTID_MAX (7)
46#define HERMES_NUMPORTS_MAX (HERMES_PORTID_MAX+1) 46#define HERMES_NUMPORTS_MAX (HERMES_PORTID_MAX + 1)
47#define HERMES_PDR_LEN_MAX (260) /* in bytes, from EK */ 47#define HERMES_PDR_LEN_MAX (260) /* in bytes, from EK */
48#define HERMES_PDA_RECS_MAX (200) /* a guess */ 48#define HERMES_PDA_RECS_MAX (200) /* a guess */
49#define HERMES_PDA_LEN_MAX (1024) /* in bytes, from EK */ 49#define HERMES_PDA_LEN_MAX (1024) /* in bytes, from EK */
@@ -148,7 +148,7 @@
148#define HERMES_CMD_WRITEMIF (0x0031) 148#define HERMES_CMD_WRITEMIF (0x0031)
149 149
150/*--- Debugging Commands -----------------------------*/ 150/*--- Debugging Commands -----------------------------*/
151#define HERMES_CMD_TEST (0x0038) 151#define HERMES_CMD_TEST (0x0038)
152 152
153 153
154/* Test command arguments */ 154/* Test command arguments */
@@ -178,8 +178,8 @@
178 178
179#define HERMES_DESCRIPTOR_OFFSET 0 179#define HERMES_DESCRIPTOR_OFFSET 0
180#define HERMES_802_11_OFFSET (14) 180#define HERMES_802_11_OFFSET (14)
181#define HERMES_802_3_OFFSET (14+32) 181#define HERMES_802_3_OFFSET (14 + 32)
182#define HERMES_802_2_OFFSET (14+32+14) 182#define HERMES_802_2_OFFSET (14 + 32 + 14)
183#define HERMES_TXCNTL2_OFFSET (HERMES_802_3_OFFSET - 2) 183#define HERMES_TXCNTL2_OFFSET (HERMES_802_3_OFFSET - 2)
184 184
185#define HERMES_RXSTAT_ERR (0x0003) 185#define HERMES_RXSTAT_ERR (0x0003)
@@ -406,7 +406,7 @@ struct hermes_ops {
406}; 406};
407 407
408/* Basic control structure */ 408/* Basic control structure */
409typedef struct hermes { 409struct hermes {
410 void __iomem *iobase; 410 void __iomem *iobase;
411 int reg_spacing; 411 int reg_spacing;
412#define HERMES_16BIT_REGSPACING 0 412#define HERMES_16BIT_REGSPACING 0
@@ -415,7 +415,7 @@ typedef struct hermes {
415 bool eeprom_pda; 415 bool eeprom_pda;
416 const struct hermes_ops *ops; 416 const struct hermes_ops *ops;
417 void *priv; 417 void *priv;
418} hermes_t; 418};
419 419
420/* Register access convenience macros */ 420/* Register access convenience macros */
421#define hermes_read_reg(hw, off) \ 421#define hermes_read_reg(hw, off) \
@@ -427,28 +427,29 @@ typedef struct hermes {
427 hermes_write_reg((hw), HERMES_##name, (val)) 427 hermes_write_reg((hw), HERMES_##name, (val))
428 428
429/* Function prototypes */ 429/* Function prototypes */
430void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing); 430void hermes_struct_init(struct hermes *hw, void __iomem *address,
431 int reg_spacing);
431 432
432/* Inline functions */ 433/* Inline functions */
433 434
434static inline int hermes_present(hermes_t *hw) 435static inline int hermes_present(struct hermes *hw)
435{ 436{
436 return hermes_read_regn(hw, SWSUPPORT0) == HERMES_MAGIC; 437 return hermes_read_regn(hw, SWSUPPORT0) == HERMES_MAGIC;
437} 438}
438 439
439static inline void hermes_set_irqmask(hermes_t *hw, u16 events) 440static inline void hermes_set_irqmask(struct hermes *hw, u16 events)
440{ 441{
441 hw->inten = events; 442 hw->inten = events;
442 hermes_write_regn(hw, INTEN, events); 443 hermes_write_regn(hw, INTEN, events);
443} 444}
444 445
445static inline int hermes_enable_port(hermes_t *hw, int port) 446static inline int hermes_enable_port(struct hermes *hw, int port)
446{ 447{
447 return hw->ops->cmd_wait(hw, HERMES_CMD_ENABLE | (port << 8), 448 return hw->ops->cmd_wait(hw, HERMES_CMD_ENABLE | (port << 8),
448 0, NULL); 449 0, NULL);
449} 450}
450 451
451static inline int hermes_disable_port(hermes_t *hw, int port) 452static inline int hermes_disable_port(struct hermes *hw, int port)
452{ 453{
453 return hw->ops->cmd_wait(hw, HERMES_CMD_DISABLE | (port << 8), 454 return hw->ops->cmd_wait(hw, HERMES_CMD_DISABLE | (port << 8),
454 0, NULL); 455 0, NULL);
@@ -456,13 +457,13 @@ static inline int hermes_disable_port(hermes_t *hw, int port)
456 457
457/* Initiate an INQUIRE command (tallies or scan). The result will come as an 458/* Initiate an INQUIRE command (tallies or scan). The result will come as an
458 * information frame in __orinoco_ev_info() */ 459 * information frame in __orinoco_ev_info() */
459static inline int hermes_inquire(hermes_t *hw, u16 rid) 460static inline int hermes_inquire(struct hermes *hw, u16 rid)
460{ 461{
461 return hw->ops->cmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL); 462 return hw->ops->cmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL);
462} 463}
463 464
464#define HERMES_BYTES_TO_RECLEN(n) ((((n)+1)/2) + 1) 465#define HERMES_BYTES_TO_RECLEN(n) ((((n) + 1) / 2) + 1)
465#define HERMES_RECLEN_TO_BYTES(n) (((n)-1) * 2) 466#define HERMES_RECLEN_TO_BYTES(n) (((n) - 1) * 2)
466 467
467/* Note that for the next two, the count is in 16-bit words, not bytes */ 468/* Note that for the next two, the count is in 16-bit words, not bytes */
468static inline void hermes_read_words(struct hermes *hw, int off, 469static inline void hermes_read_words(struct hermes *hw, int off,
@@ -498,7 +499,8 @@ static inline void hermes_clear_words(struct hermes *hw, int off,
498 (hw->ops->write_ltv((hw), (bap), (rid), \ 499 (hw->ops->write_ltv((hw), (bap), (rid), \
499 HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf))) 500 HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf)))
500 501
501static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word) 502static inline int hermes_read_wordrec(struct hermes *hw, int bap, u16 rid,
503 u16 *word)
502{ 504{
503 __le16 rec; 505 __le16 rec;
504 int err; 506 int err;
@@ -508,7 +510,8 @@ static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word)
508 return err; 510 return err;
509} 511}
510 512
511static inline int hermes_write_wordrec(hermes_t *hw, int bap, u16 rid, u16 word) 513static inline int hermes_write_wordrec(struct hermes *hw, int bap, u16 rid,
514 u16 word)
512{ 515{
513 __le16 rec = cpu_to_le16(word); 516 __le16 rec = cpu_to_le16(word);
514 return HERMES_WRITE_RECORD(hw, bap, rid, &rec); 517 return HERMES_WRITE_RECORD(hw, bap, rid, &rec);
diff --git a/drivers/net/wireless/orinoco/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c
index 2b2b9a1a979c..4a10b7aca043 100644
--- a/drivers/net/wireless/orinoco/hermes_dld.c
+++ b/drivers/net/wireless/orinoco/hermes_dld.c
@@ -193,7 +193,7 @@ hermes_find_pdi(const struct pdi *first_pdi, u32 record_id, const void *end)
193 193
194/* Process one Plug Data Item - find corresponding PDR and plug it */ 194/* Process one Plug Data Item - find corresponding PDR and plug it */
195static int 195static int
196hermes_plug_pdi(hermes_t *hw, const struct pdr *first_pdr, 196hermes_plug_pdi(struct hermes *hw, const struct pdr *first_pdr,
197 const struct pdi *pdi, const void *pdr_end) 197 const struct pdi *pdi, const void *pdr_end)
198{ 198{
199 const struct pdr *pdr; 199 const struct pdr *pdr;
@@ -220,7 +220,7 @@ hermes_plug_pdi(hermes_t *hw, const struct pdr *first_pdr,
220 * Attempt to write every records that is in the specified pda 220 * Attempt to write every records that is in the specified pda
221 * which also has a valid production data record for the firmware. 221 * which also has a valid production data record for the firmware.
222 */ 222 */
223int hermes_apply_pda(hermes_t *hw, 223int hermes_apply_pda(struct hermes *hw,
224 const char *first_pdr, 224 const char *first_pdr,
225 const void *pdr_end, 225 const void *pdr_end,
226 const __le16 *pda, 226 const __le16 *pda,
@@ -274,7 +274,7 @@ hermes_blocks_length(const char *first_block, const void *end)
274/*** Hermes programming ***/ 274/*** Hermes programming ***/
275 275
276/* Program the data blocks */ 276/* Program the data blocks */
277int hermes_program(hermes_t *hw, const char *first_block, const void *end) 277int hermes_program(struct hermes *hw, const char *first_block, const void *end)
278{ 278{
279 const struct dblock *blk; 279 const struct dblock *blk;
280 u32 blkaddr; 280 u32 blkaddr;
@@ -387,7 +387,7 @@ DEFINE_DEFAULT_PDR(0x0161, 256,
387 * 387 *
388 * For certain records, use defaults if they are not found in pda. 388 * For certain records, use defaults if they are not found in pda.
389 */ 389 */
390int hermes_apply_pda_with_defaults(hermes_t *hw, 390int hermes_apply_pda_with_defaults(struct hermes *hw,
391 const char *first_pdr, 391 const char *first_pdr,
392 const void *pdr_end, 392 const void *pdr_end,
393 const __le16 *pda, 393 const __le16 *pda,
diff --git a/drivers/net/wireless/orinoco/hermes_dld.h b/drivers/net/wireless/orinoco/hermes_dld.h
index 583a5bcf9175..b5377e232c63 100644
--- a/drivers/net/wireless/orinoco/hermes_dld.h
+++ b/drivers/net/wireless/orinoco/hermes_dld.h
@@ -27,21 +27,21 @@
27 27
28#include "hermes.h" 28#include "hermes.h"
29 29
30int hermesi_program_init(hermes_t *hw, u32 offset); 30int hermesi_program_init(struct hermes *hw, u32 offset);
31int hermesi_program_end(hermes_t *hw); 31int hermesi_program_end(struct hermes *hw);
32int hermes_program(hermes_t *hw, const char *first_block, const void *end); 32int hermes_program(struct hermes *hw, const char *first_block, const void *end);
33 33
34int hermes_read_pda(hermes_t *hw, 34int hermes_read_pda(struct hermes *hw,
35 __le16 *pda, 35 __le16 *pda,
36 u32 pda_addr, 36 u32 pda_addr,
37 u16 pda_len, 37 u16 pda_len,
38 int use_eeprom); 38 int use_eeprom);
39int hermes_apply_pda(hermes_t *hw, 39int hermes_apply_pda(struct hermes *hw,
40 const char *first_pdr, 40 const char *first_pdr,
41 const void *pdr_end, 41 const void *pdr_end,
42 const __le16 *pda, 42 const __le16 *pda,
43 const void *pda_end); 43 const void *pda_end);
44int hermes_apply_pda_with_defaults(hermes_t *hw, 44int hermes_apply_pda_with_defaults(struct hermes *hw,
45 const char *first_pdr, 45 const char *first_pdr,
46 const void *pdr_end, 46 const void *pdr_end,
47 const __le16 *pda, 47 const __le16 *pda,
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index 3c7877a7c31c..c09c8437c0b8 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -47,7 +47,7 @@ struct comp_id {
47 u16 id, variant, major, minor; 47 u16 id, variant, major, minor;
48} __packed; 48} __packed;
49 49
50static inline fwtype_t determine_firmware_type(struct comp_id *nic_id) 50static inline enum fwtype determine_firmware_type(struct comp_id *nic_id)
51{ 51{
52 if (nic_id->id < 0x8000) 52 if (nic_id->id < 0x8000)
53 return FIRMWARE_TYPE_AGERE; 53 return FIRMWARE_TYPE_AGERE;
@@ -71,11 +71,11 @@ int determine_fw_capabilities(struct orinoco_private *priv,
71 u32 *hw_ver) 71 u32 *hw_ver)
72{ 72{
73 struct device *dev = priv->dev; 73 struct device *dev = priv->dev;
74 hermes_t *hw = &priv->hw; 74 struct hermes *hw = &priv->hw;
75 int err; 75 int err;
76 struct comp_id nic_id, sta_id; 76 struct comp_id nic_id, sta_id;
77 unsigned int firmver; 77 unsigned int firmver;
78 char tmp[SYMBOL_MAX_VER_LEN+1] __attribute__((aligned(2))); 78 char tmp[SYMBOL_MAX_VER_LEN + 1] __attribute__((aligned(2)));
79 79
80 /* Get the hardware version */ 80 /* Get the hardware version */
81 err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id); 81 err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id);
@@ -280,7 +280,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
280{ 280{
281 struct device *dev = priv->dev; 281 struct device *dev = priv->dev;
282 struct hermes_idstring nickbuf; 282 struct hermes_idstring nickbuf;
283 hermes_t *hw = &priv->hw; 283 struct hermes *hw = &priv->hw;
284 int len; 284 int len;
285 int err; 285 int err;
286 u16 reclen; 286 u16 reclen;
@@ -458,7 +458,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
458{ 458{
459 struct net_device *dev = priv->ndev; 459 struct net_device *dev = priv->ndev;
460 struct wireless_dev *wdev = netdev_priv(dev); 460 struct wireless_dev *wdev = netdev_priv(dev);
461 hermes_t *hw = &priv->hw; 461 struct hermes *hw = &priv->hw;
462 int err; 462 int err;
463 struct hermes_idstring idbuf; 463 struct hermes_idstring idbuf;
464 464
@@ -529,7 +529,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
529 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val)); 529 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val));
530 /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */ 530 /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */
531 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID, 531 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID,
532 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), 532 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid) + 2),
533 &idbuf); 533 &idbuf);
534 if (err) { 534 if (err) {
535 printk(KERN_ERR "%s: Error %d setting OWNSSID\n", 535 printk(KERN_ERR "%s: Error %d setting OWNSSID\n",
@@ -537,7 +537,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
537 return err; 537 return err;
538 } 538 }
539 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID, 539 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID,
540 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), 540 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid) + 2),
541 &idbuf); 541 &idbuf);
542 if (err) { 542 if (err) {
543 printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n", 543 printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n",
@@ -549,7 +549,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
549 idbuf.len = cpu_to_le16(strlen(priv->nick)); 549 idbuf.len = cpu_to_le16(strlen(priv->nick));
550 memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val)); 550 memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val));
551 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, 551 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
552 HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2), 552 HERMES_BYTES_TO_RECLEN(strlen(priv->nick) + 2),
553 &idbuf); 553 &idbuf);
554 if (err) { 554 if (err) {
555 printk(KERN_ERR "%s: Error %d setting nickname\n", 555 printk(KERN_ERR "%s: Error %d setting nickname\n",
@@ -689,7 +689,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
689/* Get tsc from the firmware */ 689/* Get tsc from the firmware */
690int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc) 690int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc)
691{ 691{
692 hermes_t *hw = &priv->hw; 692 struct hermes *hw = &priv->hw;
693 int err = 0; 693 int err = 0;
694 u8 tsc_arr[4][ORINOCO_SEQ_LEN]; 694 u8 tsc_arr[4][ORINOCO_SEQ_LEN];
695 695
@@ -706,7 +706,7 @@ int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc)
706 706
707int __orinoco_hw_set_bitrate(struct orinoco_private *priv) 707int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
708{ 708{
709 hermes_t *hw = &priv->hw; 709 struct hermes *hw = &priv->hw;
710 int ratemode = priv->bitratemode; 710 int ratemode = priv->bitratemode;
711 int err = 0; 711 int err = 0;
712 712
@@ -737,7 +737,7 @@ int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
737 737
738int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate) 738int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate)
739{ 739{
740 hermes_t *hw = &priv->hw; 740 struct hermes *hw = &priv->hw;
741 int i; 741 int i;
742 int err = 0; 742 int err = 0;
743 u16 val; 743 u16 val;
@@ -786,7 +786,7 @@ int __orinoco_hw_set_wap(struct orinoco_private *priv)
786{ 786{
787 int roaming_flag; 787 int roaming_flag;
788 int err = 0; 788 int err = 0;
789 hermes_t *hw = &priv->hw; 789 struct hermes *hw = &priv->hw;
790 790
791 switch (priv->firmware_type) { 791 switch (priv->firmware_type) {
792 case FIRMWARE_TYPE_AGERE: 792 case FIRMWARE_TYPE_AGERE:
@@ -818,7 +818,7 @@ int __orinoco_hw_set_wap(struct orinoco_private *priv)
818 * which is needed for 802.1x implementations. */ 818 * which is needed for 802.1x implementations. */
819int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv) 819int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv)
820{ 820{
821 hermes_t *hw = &priv->hw; 821 struct hermes *hw = &priv->hw;
822 int err = 0; 822 int err = 0;
823 int i; 823 int i;
824 824
@@ -902,7 +902,7 @@ int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv)
902 902
903int __orinoco_hw_setup_enc(struct orinoco_private *priv) 903int __orinoco_hw_setup_enc(struct orinoco_private *priv)
904{ 904{
905 hermes_t *hw = &priv->hw; 905 struct hermes *hw = &priv->hw;
906 int err = 0; 906 int err = 0;
907 int master_wep_flag; 907 int master_wep_flag;
908 int auth_flag; 908 int auth_flag;
@@ -999,7 +999,7 @@ int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
999 u8 rx_mic[MIC_KEYLEN]; 999 u8 rx_mic[MIC_KEYLEN];
1000 u8 tsc[ORINOCO_SEQ_LEN]; 1000 u8 tsc[ORINOCO_SEQ_LEN];
1001 } __packed buf; 1001 } __packed buf;
1002 hermes_t *hw = &priv->hw; 1002 struct hermes *hw = &priv->hw;
1003 int ret; 1003 int ret;
1004 int err; 1004 int err;
1005 int k; 1005 int k;
@@ -1052,7 +1052,7 @@ int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
1052 1052
1053int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx) 1053int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx)
1054{ 1054{
1055 hermes_t *hw = &priv->hw; 1055 struct hermes *hw = &priv->hw;
1056 int err; 1056 int err;
1057 1057
1058 err = hermes_write_wordrec(hw, USER_BAP, 1058 err = hermes_write_wordrec(hw, USER_BAP,
@@ -1068,7 +1068,7 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
1068 struct net_device *dev, 1068 struct net_device *dev,
1069 int mc_count, int promisc) 1069 int mc_count, int promisc)
1070{ 1070{
1071 hermes_t *hw = &priv->hw; 1071 struct hermes *hw = &priv->hw;
1072 int err = 0; 1072 int err = 0;
1073 1073
1074 if (promisc != priv->promiscuous) { 1074 if (promisc != priv->promiscuous) {
@@ -1111,9 +1111,9 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
1111 1111
1112/* Return : < 0 -> error code ; >= 0 -> length */ 1112/* Return : < 0 -> error code ; >= 0 -> length */
1113int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, 1113int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
1114 char buf[IW_ESSID_MAX_SIZE+1]) 1114 char buf[IW_ESSID_MAX_SIZE + 1])
1115{ 1115{
1116 hermes_t *hw = &priv->hw; 1116 struct hermes *hw = &priv->hw;
1117 int err = 0; 1117 int err = 0;
1118 struct hermes_idstring essidbuf; 1118 struct hermes_idstring essidbuf;
1119 char *p = (char *)(&essidbuf.val); 1119 char *p = (char *)(&essidbuf.val);
@@ -1166,7 +1166,7 @@ int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
1166 1166
1167int orinoco_hw_get_freq(struct orinoco_private *priv) 1167int orinoco_hw_get_freq(struct orinoco_private *priv)
1168{ 1168{
1169 hermes_t *hw = &priv->hw; 1169 struct hermes *hw = &priv->hw;
1170 int err = 0; 1170 int err = 0;
1171 u16 channel; 1171 u16 channel;
1172 int freq = 0; 1172 int freq = 0;
@@ -1206,7 +1206,7 @@ int orinoco_hw_get_freq(struct orinoco_private *priv)
1206int orinoco_hw_get_bitratelist(struct orinoco_private *priv, 1206int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
1207 int *numrates, s32 *rates, int max) 1207 int *numrates, s32 *rates, int max)
1208{ 1208{
1209 hermes_t *hw = &priv->hw; 1209 struct hermes *hw = &priv->hw;
1210 struct hermes_idstring list; 1210 struct hermes_idstring list;
1211 unsigned char *p = (unsigned char *)&list.val; 1211 unsigned char *p = (unsigned char *)&list.val;
1212 int err = 0; 1212 int err = 0;
@@ -1238,7 +1238,7 @@ int orinoco_hw_trigger_scan(struct orinoco_private *priv,
1238 const struct cfg80211_ssid *ssid) 1238 const struct cfg80211_ssid *ssid)
1239{ 1239{
1240 struct net_device *dev = priv->ndev; 1240 struct net_device *dev = priv->ndev;
1241 hermes_t *hw = &priv->hw; 1241 struct hermes *hw = &priv->hw;
1242 unsigned long flags; 1242 unsigned long flags;
1243 int err = 0; 1243 int err = 0;
1244 1244
@@ -1323,7 +1323,7 @@ int orinoco_hw_trigger_scan(struct orinoco_private *priv,
1323int orinoco_hw_disassociate(struct orinoco_private *priv, 1323int orinoco_hw_disassociate(struct orinoco_private *priv,
1324 u8 *addr, u16 reason_code) 1324 u8 *addr, u16 reason_code)
1325{ 1325{
1326 hermes_t *hw = &priv->hw; 1326 struct hermes *hw = &priv->hw;
1327 int err; 1327 int err;
1328 1328
1329 struct { 1329 struct {
@@ -1346,7 +1346,7 @@ int orinoco_hw_disassociate(struct orinoco_private *priv,
1346int orinoco_hw_get_current_bssid(struct orinoco_private *priv, 1346int orinoco_hw_get_current_bssid(struct orinoco_private *priv,
1347 u8 *addr) 1347 u8 *addr)
1348{ 1348{
1349 hermes_t *hw = &priv->hw; 1349 struct hermes *hw = &priv->hw;
1350 int err; 1350 int err;
1351 1351
1352 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID, 1352 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
diff --git a/drivers/net/wireless/orinoco/hw.h b/drivers/net/wireless/orinoco/hw.h
index 97af71e79950..8f6831f4e328 100644
--- a/drivers/net/wireless/orinoco/hw.h
+++ b/drivers/net/wireless/orinoco/hw.h
@@ -45,7 +45,7 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
45 struct net_device *dev, 45 struct net_device *dev,
46 int mc_count, int promisc); 46 int mc_count, int promisc);
47int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, 47int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
48 char buf[IW_ESSID_MAX_SIZE+1]); 48 char buf[IW_ESSID_MAX_SIZE + 1]);
49int orinoco_hw_get_freq(struct orinoco_private *priv); 49int orinoco_hw_get_freq(struct orinoco_private *priv);
50int orinoco_hw_get_bitratelist(struct orinoco_private *priv, 50int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
51 int *numrates, s32 *rates, int max); 51 int *numrates, s32 *rates, int max);
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index b0f233f1100e..ef7efe839bb8 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -4,7 +4,7 @@
4 * adaptors, with Lucent/Agere, Intersil or Symbol firmware. 4 * adaptors, with Lucent/Agere, Intersil or Symbol firmware.
5 * 5 *
6 * Current maintainers (as of 29 September 2003) are: 6 * Current maintainers (as of 29 September 2003) are:
7 * Pavel Roskin <proski AT gnu.org> 7 * Pavel Roskin <proski AT gnu.org>
8 * and David Gibson <hermes AT gibson.dropbear.id.au> 8 * and David Gibson <hermes AT gibson.dropbear.id.au>
9 * 9 *
10 * (C) Copyright David Gibson, IBM Corporation 2001-2003. 10 * (C) Copyright David Gibson, IBM Corporation 2001-2003.
@@ -146,10 +146,10 @@ static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
146#define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD) 146#define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD)
147 147
148#define MAX_IRQLOOPS_PER_IRQ 10 148#define MAX_IRQLOOPS_PER_IRQ 10
149#define MAX_IRQLOOPS_PER_JIFFY (20000/HZ) /* Based on a guestimate of 149#define MAX_IRQLOOPS_PER_JIFFY (20000 / HZ) /* Based on a guestimate of
150 * how many events the 150 * how many events the
151 * device could 151 * device could
152 * legitimately generate */ 152 * legitimately generate */
153 153
154#define DUMMY_FID 0xFFFF 154#define DUMMY_FID 0xFFFF
155 155
@@ -157,7 +157,7 @@ static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
157 HERMES_MAX_MULTICAST : 0)*/ 157 HERMES_MAX_MULTICAST : 0)*/
158#define MAX_MULTICAST(priv) (HERMES_MAX_MULTICAST) 158#define MAX_MULTICAST(priv) (HERMES_MAX_MULTICAST)
159 159
160#define ORINOCO_INTEN (HERMES_EV_RX | HERMES_EV_ALLOC \ 160#define ORINOCO_INTEN (HERMES_EV_RX | HERMES_EV_ALLOC \
161 | HERMES_EV_TX | HERMES_EV_TXEXC \ 161 | HERMES_EV_TX | HERMES_EV_TXEXC \
162 | HERMES_EV_WTERR | HERMES_EV_INFO \ 162 | HERMES_EV_WTERR | HERMES_EV_INFO \
163 | HERMES_EV_INFDROP) 163 | HERMES_EV_INFDROP)
@@ -437,12 +437,12 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
437{ 437{
438 struct orinoco_private *priv = ndev_priv(dev); 438 struct orinoco_private *priv = ndev_priv(dev);
439 struct net_device_stats *stats = &priv->stats; 439 struct net_device_stats *stats = &priv->stats;
440 hermes_t *hw = &priv->hw; 440 struct hermes *hw = &priv->hw;
441 int err = 0; 441 int err = 0;
442 u16 txfid = priv->txfid; 442 u16 txfid = priv->txfid;
443 int tx_control; 443 int tx_control;
444 unsigned long flags; 444 unsigned long flags;
445 u8 mic_buf[MICHAEL_MIC_LEN+1]; 445 u8 mic_buf[MICHAEL_MIC_LEN + 1];
446 446
447 if (!netif_running(dev)) { 447 if (!netif_running(dev)) {
448 printk(KERN_ERR "%s: Tx on stopped device!\n", 448 printk(KERN_ERR "%s: Tx on stopped device!\n",
@@ -579,7 +579,7 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
579 return NETDEV_TX_BUSY; 579 return NETDEV_TX_BUSY;
580} 580}
581 581
582static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw) 582static void __orinoco_ev_alloc(struct net_device *dev, struct hermes *hw)
583{ 583{
584 struct orinoco_private *priv = ndev_priv(dev); 584 struct orinoco_private *priv = ndev_priv(dev);
585 u16 fid = hermes_read_regn(hw, ALLOCFID); 585 u16 fid = hermes_read_regn(hw, ALLOCFID);
@@ -594,7 +594,7 @@ static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
594 hermes_write_regn(hw, ALLOCFID, DUMMY_FID); 594 hermes_write_regn(hw, ALLOCFID, DUMMY_FID);
595} 595}
596 596
597static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw) 597static void __orinoco_ev_tx(struct net_device *dev, struct hermes *hw)
598{ 598{
599 struct orinoco_private *priv = ndev_priv(dev); 599 struct orinoco_private *priv = ndev_priv(dev);
600 struct net_device_stats *stats = &priv->stats; 600 struct net_device_stats *stats = &priv->stats;
@@ -606,7 +606,7 @@ static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)
606 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID); 606 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
607} 607}
608 608
609static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw) 609static void __orinoco_ev_txexc(struct net_device *dev, struct hermes *hw)
610{ 610{
611 struct orinoco_private *priv = ndev_priv(dev); 611 struct orinoco_private *priv = ndev_priv(dev);
612 struct net_device_stats *stats = &priv->stats; 612 struct net_device_stats *stats = &priv->stats;
@@ -753,7 +753,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
753 struct sk_buff *skb; 753 struct sk_buff *skb;
754 struct orinoco_private *priv = ndev_priv(dev); 754 struct orinoco_private *priv = ndev_priv(dev);
755 struct net_device_stats *stats = &priv->stats; 755 struct net_device_stats *stats = &priv->stats;
756 hermes_t *hw = &priv->hw; 756 struct hermes *hw = &priv->hw;
757 757
758 len = le16_to_cpu(desc->data_len); 758 len = le16_to_cpu(desc->data_len);
759 759
@@ -840,7 +840,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
840 stats->rx_dropped++; 840 stats->rx_dropped++;
841} 841}
842 842
843void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) 843void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw)
844{ 844{
845 struct orinoco_private *priv = ndev_priv(dev); 845 struct orinoco_private *priv = ndev_priv(dev);
846 struct net_device_stats *stats = &priv->stats; 846 struct net_device_stats *stats = &priv->stats;
@@ -918,7 +918,7 @@ void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
918 32bit boundary, plus 1 byte so we can read in odd length 918 32bit boundary, plus 1 byte so we can read in odd length
919 packets from the card, which has an IO granularity of 16 919 packets from the card, which has an IO granularity of 16
920 bits */ 920 bits */
921 skb = dev_alloc_skb(length+ETH_HLEN+2+1); 921 skb = dev_alloc_skb(length + ETH_HLEN + 2 + 1);
922 if (!skb) { 922 if (!skb) {
923 printk(KERN_WARNING "%s: Can't allocate skb for Rx\n", 923 printk(KERN_WARNING "%s: Can't allocate skb for Rx\n",
924 dev->name); 924 dev->name);
@@ -1402,7 +1402,7 @@ static void orinoco_process_scan_results(struct work_struct *work)
1402 spin_unlock_irqrestore(&priv->scan_lock, flags); 1402 spin_unlock_irqrestore(&priv->scan_lock, flags);
1403} 1403}
1404 1404
1405void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) 1405void __orinoco_ev_info(struct net_device *dev, struct hermes *hw)
1406{ 1406{
1407 struct orinoco_private *priv = ndev_priv(dev); 1407 struct orinoco_private *priv = ndev_priv(dev);
1408 u16 infofid; 1408 u16 infofid;
@@ -1620,7 +1620,7 @@ void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1620} 1620}
1621EXPORT_SYMBOL(__orinoco_ev_info); 1621EXPORT_SYMBOL(__orinoco_ev_info);
1622 1622
1623static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw) 1623static void __orinoco_ev_infdrop(struct net_device *dev, struct hermes *hw)
1624{ 1624{
1625 if (net_ratelimit()) 1625 if (net_ratelimit())
1626 printk(KERN_DEBUG "%s: Information frame lost.\n", dev->name); 1626 printk(KERN_DEBUG "%s: Information frame lost.\n", dev->name);
@@ -1831,7 +1831,7 @@ static int __orinoco_commit(struct orinoco_private *priv)
1831int orinoco_commit(struct orinoco_private *priv) 1831int orinoco_commit(struct orinoco_private *priv)
1832{ 1832{
1833 struct net_device *dev = priv->ndev; 1833 struct net_device *dev = priv->ndev;
1834 hermes_t *hw = &priv->hw; 1834 struct hermes *hw = &priv->hw;
1835 int err; 1835 int err;
1836 1836
1837 if (priv->broken_disableport) { 1837 if (priv->broken_disableport) {
@@ -1874,12 +1874,12 @@ int orinoco_commit(struct orinoco_private *priv)
1874/* Interrupt handler */ 1874/* Interrupt handler */
1875/********************************************************************/ 1875/********************************************************************/
1876 1876
1877static void __orinoco_ev_tick(struct net_device *dev, hermes_t *hw) 1877static void __orinoco_ev_tick(struct net_device *dev, struct hermes *hw)
1878{ 1878{
1879 printk(KERN_DEBUG "%s: TICK\n", dev->name); 1879 printk(KERN_DEBUG "%s: TICK\n", dev->name);
1880} 1880}
1881 1881
1882static void __orinoco_ev_wterr(struct net_device *dev, hermes_t *hw) 1882static void __orinoco_ev_wterr(struct net_device *dev, struct hermes *hw)
1883{ 1883{
1884 /* This seems to happen a fair bit under load, but ignoring it 1884 /* This seems to happen a fair bit under load, but ignoring it
1885 seems to work fine...*/ 1885 seems to work fine...*/
@@ -1891,7 +1891,7 @@ irqreturn_t orinoco_interrupt(int irq, void *dev_id)
1891{ 1891{
1892 struct orinoco_private *priv = dev_id; 1892 struct orinoco_private *priv = dev_id;
1893 struct net_device *dev = priv->ndev; 1893 struct net_device *dev = priv->ndev;
1894 hermes_t *hw = &priv->hw; 1894 struct hermes *hw = &priv->hw;
1895 int count = MAX_IRQLOOPS_PER_IRQ; 1895 int count = MAX_IRQLOOPS_PER_IRQ;
1896 u16 evstat, events; 1896 u16 evstat, events;
1897 /* These are used to detect a runaway interrupt situation. 1897 /* These are used to detect a runaway interrupt situation.
@@ -2017,8 +2017,8 @@ static void orinoco_unregister_pm_notifier(struct orinoco_private *priv)
2017 unregister_pm_notifier(&priv->pm_notifier); 2017 unregister_pm_notifier(&priv->pm_notifier);
2018} 2018}
2019#else /* !PM_SLEEP || HERMES_CACHE_FW_ON_INIT */ 2019#else /* !PM_SLEEP || HERMES_CACHE_FW_ON_INIT */
2020#define orinoco_register_pm_notifier(priv) do { } while(0) 2020#define orinoco_register_pm_notifier(priv) do { } while (0)
2021#define orinoco_unregister_pm_notifier(priv) do { } while(0) 2021#define orinoco_unregister_pm_notifier(priv) do { } while (0)
2022#endif 2022#endif
2023 2023
2024/********************************************************************/ 2024/********************************************************************/
@@ -2029,7 +2029,7 @@ int orinoco_init(struct orinoco_private *priv)
2029{ 2029{
2030 struct device *dev = priv->dev; 2030 struct device *dev = priv->dev;
2031 struct wiphy *wiphy = priv_to_wiphy(priv); 2031 struct wiphy *wiphy = priv_to_wiphy(priv);
2032 hermes_t *hw = &priv->hw; 2032 struct hermes *hw = &priv->hw;
2033 int err = 0; 2033 int err = 0;
2034 2034
2035 /* No need to lock, the hw_unavailable flag is already set in 2035 /* No need to lock, the hw_unavailable flag is already set in
diff --git a/drivers/net/wireless/orinoco/mic.c b/drivers/net/wireless/orinoco/mic.c
index c03e7f54d1b8..fce4a843e656 100644
--- a/drivers/net/wireless/orinoco/mic.c
+++ b/drivers/net/wireless/orinoco/mic.c
@@ -59,10 +59,10 @@ int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key,
59 /* Copy header into buffer. We need the padding on the end zeroed */ 59 /* Copy header into buffer. We need the padding on the end zeroed */
60 memcpy(&hdr[0], da, ETH_ALEN); 60 memcpy(&hdr[0], da, ETH_ALEN);
61 memcpy(&hdr[ETH_ALEN], sa, ETH_ALEN); 61 memcpy(&hdr[ETH_ALEN], sa, ETH_ALEN);
62 hdr[ETH_ALEN*2] = priority; 62 hdr[ETH_ALEN * 2] = priority;
63 hdr[ETH_ALEN*2+1] = 0; 63 hdr[ETH_ALEN * 2 + 1] = 0;
64 hdr[ETH_ALEN*2+2] = 0; 64 hdr[ETH_ALEN * 2 + 2] = 0;
65 hdr[ETH_ALEN*2+3] = 0; 65 hdr[ETH_ALEN * 2 + 3] = 0;
66 66
67 /* Use scatter gather to MIC header and data in one go */ 67 /* Use scatter gather to MIC header and data in one go */
68 sg_init_table(sg, 2); 68 sg_init_table(sg, 2);
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 255710ef082a..3bb936b9558c 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -49,11 +49,11 @@ enum orinoco_alg {
49 ORINOCO_ALG_TKIP 49 ORINOCO_ALG_TKIP
50}; 50};
51 51
52typedef enum { 52enum fwtype {
53 FIRMWARE_TYPE_AGERE, 53 FIRMWARE_TYPE_AGERE,
54 FIRMWARE_TYPE_INTERSIL, 54 FIRMWARE_TYPE_INTERSIL,
55 FIRMWARE_TYPE_SYMBOL 55 FIRMWARE_TYPE_SYMBOL
56} fwtype_t; 56};
57 57
58struct firmware; 58struct firmware;
59 59
@@ -88,11 +88,11 @@ struct orinoco_private {
88 struct iw_statistics wstats; 88 struct iw_statistics wstats;
89 89
90 /* Hardware control variables */ 90 /* Hardware control variables */
91 hermes_t hw; 91 struct hermes hw;
92 u16 txfid; 92 u16 txfid;
93 93
94 /* Capabilities of the hardware/firmware */ 94 /* Capabilities of the hardware/firmware */
95 fwtype_t firmware_type; 95 enum fwtype firmware_type;
96 int ibss_port; 96 int ibss_port;
97 int nicbuf_size; 97 int nicbuf_size;
98 u16 channel_mask; 98 u16 channel_mask;
@@ -122,8 +122,8 @@ struct orinoco_private {
122 struct key_params keys[ORINOCO_MAX_KEYS]; 122 struct key_params keys[ORINOCO_MAX_KEYS];
123 123
124 int bitratemode; 124 int bitratemode;
125 char nick[IW_ESSID_MAX_SIZE+1]; 125 char nick[IW_ESSID_MAX_SIZE + 1];
126 char desired_essid[IW_ESSID_MAX_SIZE+1]; 126 char desired_essid[IW_ESSID_MAX_SIZE + 1];
127 char desired_bssid[ETH_ALEN]; 127 char desired_bssid[ETH_ALEN];
128 int bssid_fixed; 128 int bssid_fixed;
129 u16 frag_thresh, mwo_robust; 129 u16 frag_thresh, mwo_robust;
@@ -197,8 +197,8 @@ extern int orinoco_up(struct orinoco_private *priv);
197extern void orinoco_down(struct orinoco_private *priv); 197extern void orinoco_down(struct orinoco_private *priv);
198extern irqreturn_t orinoco_interrupt(int irq, void *dev_id); 198extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
199 199
200extern void __orinoco_ev_info(struct net_device *dev, hermes_t *hw); 200extern void __orinoco_ev_info(struct net_device *dev, struct hermes *hw);
201extern void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw); 201extern void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw);
202 202
203int orinoco_process_xmit_skb(struct sk_buff *skb, 203int orinoco_process_xmit_skb(struct sk_buff *skb,
204 struct net_device *dev, 204 struct net_device *dev,
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 88e3c0ebcaad..3f7fc4a0b43d 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -65,7 +65,7 @@ static void orinoco_cs_release(struct pcmcia_device *link);
65static void orinoco_cs_detach(struct pcmcia_device *p_dev); 65static void orinoco_cs_detach(struct pcmcia_device *p_dev);
66 66
67/********************************************************************/ 67/********************************************************************/
68/* Device methods */ 68/* Device methods */
69/********************************************************************/ 69/********************************************************************/
70 70
71static int 71static int
@@ -89,7 +89,7 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
89} 89}
90 90
91/********************************************************************/ 91/********************************************************************/
92/* PCMCIA stuff */ 92/* PCMCIA stuff */
93/********************************************************************/ 93/********************************************************************/
94 94
95static int 95static int
@@ -134,7 +134,7 @@ static int
134orinoco_cs_config(struct pcmcia_device *link) 134orinoco_cs_config(struct pcmcia_device *link)
135{ 135{
136 struct orinoco_private *priv = link->priv; 136 struct orinoco_private *priv = link->priv;
137 hermes_t *hw = &priv->hw; 137 struct hermes *hw = &priv->hw;
138 int ret; 138 int ret;
139 void __iomem *mem; 139 void __iomem *mem;
140 140
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index bc3ea0b67a4f..326396b313a6 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -296,8 +296,7 @@ static struct pci_driver orinoco_nortel_driver = {
296static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION 296static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
297 " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)"; 297 " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)";
298MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>"); 298MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>");
299MODULE_DESCRIPTION 299MODULE_DESCRIPTION("Driver for wireless LAN cards using the Nortel PCI bridge");
300 ("Driver for wireless LAN cards using the Nortel PCI bridge");
301MODULE_LICENSE("Dual MPL/GPL"); 300MODULE_LICENSE("Dual MPL/GPL");
302 301
303static int __init orinoco_nortel_init(void) 302static int __init orinoco_nortel_init(void)
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index 468197f86673..6058c66b844e 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -6,7 +6,7 @@
6 * hermes registers, as well as the COR register. 6 * hermes registers, as well as the COR register.
7 * 7 *
8 * Current maintainers are: 8 * Current maintainers are:
9 * Pavel Roskin <proski AT gnu.org> 9 * Pavel Roskin <proski AT gnu.org>
10 * and David Gibson <hermes AT gibson.dropbear.id.au> 10 * and David Gibson <hermes AT gibson.dropbear.id.au>
11 * 11 *
12 * Some of this code is borrowed from orinoco_plx.c 12 * Some of this code is borrowed from orinoco_plx.c
@@ -81,7 +81,7 @@
81 */ 81 */
82static int orinoco_pci_cor_reset(struct orinoco_private *priv) 82static int orinoco_pci_cor_reset(struct orinoco_private *priv)
83{ 83{
84 hermes_t *hw = &priv->hw; 84 struct hermes *hw = &priv->hw;
85 unsigned long timeout; 85 unsigned long timeout;
86 u16 reg; 86 u16 reg;
87 87
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index 9358f4d2307b..2bac8248a991 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -4,7 +4,7 @@
4 * but are connected to the PCI bus by a PLX9052. 4 * but are connected to the PCI bus by a PLX9052.
5 * 5 *
6 * Current maintainers are: 6 * Current maintainers are:
7 * Pavel Roskin <proski AT gnu.org> 7 * Pavel Roskin <proski AT gnu.org>
8 * and David Gibson <hermes AT gibson.dropbear.id.au> 8 * and David Gibson <hermes AT gibson.dropbear.id.au>
9 * 9 *
10 * (C) Copyright David Gibson, IBM Corp. 2001-2003. 10 * (C) Copyright David Gibson, IBM Corp. 2001-2003.
@@ -102,14 +102,14 @@
102#define PLX_RESET_TIME (500) /* milliseconds */ 102#define PLX_RESET_TIME (500) /* milliseconds */
103 103
104#define PLX_INTCSR 0x4c /* Interrupt Control & Status Register */ 104#define PLX_INTCSR 0x4c /* Interrupt Control & Status Register */
105#define PLX_INTCSR_INTEN (1<<6) /* Interrupt Enable bit */ 105#define PLX_INTCSR_INTEN (1 << 6) /* Interrupt Enable bit */
106 106
107/* 107/*
108 * Do a soft reset of the card using the Configuration Option Register 108 * Do a soft reset of the card using the Configuration Option Register
109 */ 109 */
110static int orinoco_plx_cor_reset(struct orinoco_private *priv) 110static int orinoco_plx_cor_reset(struct orinoco_private *priv)
111{ 111{
112 hermes_t *hw = &priv->hw; 112 struct hermes *hw = &priv->hw;
113 struct orinoco_pci_card *card = priv->card; 113 struct orinoco_pci_card *card = priv->card;
114 unsigned long timeout; 114 unsigned long timeout;
115 u16 reg; 115 u16 reg;
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index 784605f0af15..93159d68ec93 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -59,7 +59,7 @@
59 */ 59 */
60static int orinoco_tmd_cor_reset(struct orinoco_private *priv) 60static int orinoco_tmd_cor_reset(struct orinoco_private *priv)
61{ 61{
62 hermes_t *hw = &priv->hw; 62 struct hermes *hw = &priv->hw;
63 struct orinoco_pci_card *card = priv->card; 63 struct orinoco_pci_card *card = priv->card;
64 unsigned long timeout; 64 unsigned long timeout;
65 u16 reg; 65 u16 reg;
diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
index b9aedf18a046..811e87f8a349 100644
--- a/drivers/net/wireless/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -199,7 +199,7 @@ MODULE_FIRMWARE("orinoco_ezusb_fw");
199#define EZUSB_FRAME_DATA 1 199#define EZUSB_FRAME_DATA 1
200#define EZUSB_FRAME_CONTROL 2 200#define EZUSB_FRAME_CONTROL 2
201 201
202#define DEF_TIMEOUT (3*HZ) 202#define DEF_TIMEOUT (3 * HZ)
203 203
204#define BULK_BUF_SIZE 2048 204#define BULK_BUF_SIZE 2048
205 205
@@ -959,7 +959,7 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv,
959 return retval; 959 return retval;
960} 960}
961 961
962static int ezusb_write_ltv(hermes_t *hw, int bap, u16 rid, 962static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid,
963 u16 length, const void *data) 963 u16 length, const void *data)
964{ 964{
965 struct ezusb_priv *upriv = hw->priv; 965 struct ezusb_priv *upriv = hw->priv;
@@ -989,7 +989,7 @@ static int ezusb_write_ltv(hermes_t *hw, int bap, u16 rid,
989 NULL, 0, NULL); 989 NULL, 0, NULL);
990} 990}
991 991
992static int ezusb_read_ltv(hermes_t *hw, int bap, u16 rid, 992static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid,
993 unsigned bufsize, u16 *length, void *buf) 993 unsigned bufsize, u16 *length, void *buf)
994{ 994{
995 struct ezusb_priv *upriv = hw->priv; 995 struct ezusb_priv *upriv = hw->priv;
@@ -1006,7 +1006,7 @@ static int ezusb_read_ltv(hermes_t *hw, int bap, u16 rid,
1006 buf, bufsize, length); 1006 buf, bufsize, length);
1007} 1007}
1008 1008
1009static int ezusb_doicmd_wait(hermes_t *hw, u16 cmd, u16 parm0, u16 parm1, 1009static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1,
1010 u16 parm2, struct hermes_response *resp) 1010 u16 parm2, struct hermes_response *resp)
1011{ 1011{
1012 struct ezusb_priv *upriv = hw->priv; 1012 struct ezusb_priv *upriv = hw->priv;
@@ -1028,7 +1028,7 @@ static int ezusb_doicmd_wait(hermes_t *hw, u16 cmd, u16 parm0, u16 parm1,
1028 EZUSB_FRAME_CONTROL, NULL, 0, NULL); 1028 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1029} 1029}
1030 1030
1031static int ezusb_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0, 1031static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
1032 struct hermes_response *resp) 1032 struct hermes_response *resp)
1033{ 1033{
1034 struct ezusb_priv *upriv = hw->priv; 1034 struct ezusb_priv *upriv = hw->priv;
@@ -1196,7 +1196,7 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
1196 struct orinoco_private *priv = ndev_priv(dev); 1196 struct orinoco_private *priv = ndev_priv(dev);
1197 struct net_device_stats *stats = &priv->stats; 1197 struct net_device_stats *stats = &priv->stats;
1198 struct ezusb_priv *upriv = priv->card; 1198 struct ezusb_priv *upriv = priv->card;
1199 u8 mic[MICHAEL_MIC_LEN+1]; 1199 u8 mic[MICHAEL_MIC_LEN + 1];
1200 int err = 0; 1200 int err = 0;
1201 int tx_control; 1201 int tx_control;
1202 unsigned long flags; 1202 unsigned long flags;
@@ -1356,7 +1356,7 @@ static int ezusb_hard_reset(struct orinoco_private *priv)
1356} 1356}
1357 1357
1358 1358
1359static int ezusb_init(hermes_t *hw) 1359static int ezusb_init(struct hermes *hw)
1360{ 1360{
1361 struct ezusb_priv *upriv = hw->priv; 1361 struct ezusb_priv *upriv = hw->priv;
1362 int retval; 1362 int retval;
@@ -1438,7 +1438,7 @@ static void ezusb_bulk_in_callback(struct urb *urb)
1438 } else if (upriv->dev) { 1438 } else if (upriv->dev) {
1439 struct net_device *dev = upriv->dev; 1439 struct net_device *dev = upriv->dev;
1440 struct orinoco_private *priv = ndev_priv(dev); 1440 struct orinoco_private *priv = ndev_priv(dev);
1441 hermes_t *hw = &priv->hw; 1441 struct hermes *hw = &priv->hw;
1442 1442
1443 if (hermes_rid == EZUSB_RID_RX) { 1443 if (hermes_rid == EZUSB_RID_RX) {
1444 __orinoco_ev_rx(dev, hw); 1444 __orinoco_ev_rx(dev, hw);
@@ -1575,7 +1575,7 @@ static int ezusb_probe(struct usb_interface *interface,
1575{ 1575{
1576 struct usb_device *udev = interface_to_usbdev(interface); 1576 struct usb_device *udev = interface_to_usbdev(interface);
1577 struct orinoco_private *priv; 1577 struct orinoco_private *priv;
1578 hermes_t *hw; 1578 struct hermes *hw;
1579 struct ezusb_priv *upriv = NULL; 1579 struct ezusb_priv *upriv = NULL;
1580 struct usb_interface_descriptor *iface_desc; 1580 struct usb_interface_descriptor *iface_desc;
1581 struct usb_endpoint_descriptor *ep; 1581 struct usb_endpoint_descriptor *ep;
@@ -1757,7 +1757,7 @@ static struct usb_driver orinoco_driver = {
1757/* Can't be declared "const" or the whole __initdata section will 1757/* Can't be declared "const" or the whole __initdata section will
1758 * become const */ 1758 * become const */
1759static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION 1759static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
1760 " (Manuel Estrada Sainz)"; 1760 " (Manuel Estrada Sainz)";
1761 1761
1762static int __init ezusb_module_init(void) 1762static int __init ezusb_module_init(void)
1763{ 1763{
@@ -1787,6 +1787,5 @@ module_init(ezusb_module_init);
1787module_exit(ezusb_module_exit); 1787module_exit(ezusb_module_exit);
1788 1788
1789MODULE_AUTHOR("Manuel Estrada Sainz"); 1789MODULE_AUTHOR("Manuel Estrada Sainz");
1790MODULE_DESCRIPTION 1790MODULE_DESCRIPTION("Driver for Orinoco wireless LAN cards using EZUSB bridge");
1791 ("Driver for Orinoco wireless LAN cards using EZUSB bridge");
1792MODULE_LICENSE("Dual MPL/GPL"); 1791MODULE_LICENSE("Dual MPL/GPL");
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 81f3673d31d4..6e28ee4e9c52 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -11,9 +11,9 @@
11 * 11 *
12 * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org> 12 * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org>
13 * Portions based on orinoco_cs.c: 13 * Portions based on orinoco_cs.c:
14 * Copyright (C) David Gibson, Linuxcare Australia 14 * Copyright (C) David Gibson, Linuxcare Australia
15 * Portions based on Spectrum24tDnld.c from original spectrum24 driver: 15 * Portions based on Spectrum24tDnld.c from original spectrum24 driver:
16 * Copyright (C) Symbol Technologies. 16 * Copyright (C) Symbol Technologies.
17 * 17 *
18 * See copyright notice in file main.c. 18 * See copyright notice in file main.c.
19 */ 19 */
@@ -125,7 +125,7 @@ failed:
125} 125}
126 126
127/********************************************************************/ 127/********************************************************************/
128/* Device methods */ 128/* Device methods */
129/********************************************************************/ 129/********************************************************************/
130 130
131static int 131static int
@@ -150,7 +150,7 @@ spectrum_cs_stop_firmware(struct orinoco_private *priv, int idle)
150} 150}
151 151
152/********************************************************************/ 152/********************************************************************/
153/* PCMCIA stuff */ 153/* PCMCIA stuff */
154/********************************************************************/ 154/********************************************************************/
155 155
156static int 156static int
@@ -197,7 +197,7 @@ static int
197spectrum_cs_config(struct pcmcia_device *link) 197spectrum_cs_config(struct pcmcia_device *link)
198{ 198{
199 struct orinoco_private *priv = link->priv; 199 struct orinoco_private *priv = link->priv;
200 hermes_t *hw = &priv->hw; 200 struct hermes *hw = &priv->hw;
201 int ret; 201 int ret;
202 void __iomem *mem; 202 void __iomem *mem;
203 203
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index e793679e2e19..bbb9beb206b1 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -87,7 +87,7 @@ nomem:
87static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) 87static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
88{ 88{
89 struct orinoco_private *priv = ndev_priv(dev); 89 struct orinoco_private *priv = ndev_priv(dev);
90 hermes_t *hw = &priv->hw; 90 struct hermes *hw = &priv->hw;
91 struct iw_statistics *wstats = &priv->wstats; 91 struct iw_statistics *wstats = &priv->wstats;
92 int err; 92 int err;
93 unsigned long flags; 93 unsigned long flags;
@@ -448,7 +448,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
448 } 448 }
449 449
450 if ((chan < 1) || (chan > NUM_CHANNELS) || 450 if ((chan < 1) || (chan > NUM_CHANNELS) ||
451 !(priv->channel_mask & (1 << (chan-1)))) 451 !(priv->channel_mask & (1 << (chan - 1))))
452 return -EINVAL; 452 return -EINVAL;
453 453
454 if (orinoco_lock(priv, &flags) != 0) 454 if (orinoco_lock(priv, &flags) != 0)
@@ -457,7 +457,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
457 priv->channel = chan; 457 priv->channel = chan;
458 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 458 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
459 /* Fast channel change - no commit if successful */ 459 /* Fast channel change - no commit if successful */
460 hermes_t *hw = &priv->hw; 460 struct hermes *hw = &priv->hw;
461 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST | 461 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
462 HERMES_TEST_SET_CHANNEL, 462 HERMES_TEST_SET_CHANNEL,
463 chan, NULL); 463 chan, NULL);
@@ -492,7 +492,7 @@ static int orinoco_ioctl_getsens(struct net_device *dev,
492 char *extra) 492 char *extra)
493{ 493{
494 struct orinoco_private *priv = ndev_priv(dev); 494 struct orinoco_private *priv = ndev_priv(dev);
495 hermes_t *hw = &priv->hw; 495 struct hermes *hw = &priv->hw;
496 u16 val; 496 u16 val;
497 int err; 497 int err;
498 unsigned long flags; 498 unsigned long flags;
@@ -668,7 +668,7 @@ static int orinoco_ioctl_getpower(struct net_device *dev,
668 char *extra) 668 char *extra)
669{ 669{
670 struct orinoco_private *priv = ndev_priv(dev); 670 struct orinoco_private *priv = ndev_priv(dev);
671 hermes_t *hw = &priv->hw; 671 struct hermes *hw = &priv->hw;
672 int err = 0; 672 int err = 0;
673 u16 enable, period, timeout, mcast; 673 u16 enable, period, timeout, mcast;
674 unsigned long flags; 674 unsigned long flags;
@@ -873,7 +873,7 @@ static int orinoco_ioctl_set_auth(struct net_device *dev,
873 union iwreq_data *wrqu, char *extra) 873 union iwreq_data *wrqu, char *extra)
874{ 874{
875 struct orinoco_private *priv = ndev_priv(dev); 875 struct orinoco_private *priv = ndev_priv(dev);
876 hermes_t *hw = &priv->hw; 876 struct hermes *hw = &priv->hw;
877 struct iw_param *param = &wrqu->param; 877 struct iw_param *param = &wrqu->param;
878 unsigned long flags; 878 unsigned long flags;
879 int ret = -EINPROGRESS; 879 int ret = -EINPROGRESS;
@@ -1269,7 +1269,7 @@ static int orinoco_ioctl_getrid(struct net_device *dev,
1269 char *extra) 1269 char *extra)
1270{ 1270{
1271 struct orinoco_private *priv = ndev_priv(dev); 1271 struct orinoco_private *priv = ndev_priv(dev);
1272 hermes_t *hw = &priv->hw; 1272 struct hermes *hw = &priv->hw;
1273 int rid = data->flags; 1273 int rid = data->flags;
1274 u16 length; 1274 u16 length;
1275 int err; 1275 int err;
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index bc13533a5418..0b598db38da9 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include <linux/ip.h> 32#include <linux/ip.h>
31#include "wifi.h" 33#include "wifi.h"
32#include "rc.h" 34#include "rc.h"
@@ -397,8 +399,8 @@ void rtl_init_rfkill(struct ieee80211_hw *hw)
397 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid); 399 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
398 400
399 if (valid) { 401 if (valid) {
400 printk(KERN_INFO "rtlwifi: wireless switch is %s\n", 402 pr_info("wireless switch is %s\n",
401 rtlpriv->rfkill.rfkill_state ? "on" : "off"); 403 rtlpriv->rfkill.rfkill_state ? "on" : "off");
402 404
403 rtlpriv->rfkill.rfkill_state = radio_state; 405 rtlpriv->rfkill.rfkill_state = radio_state;
404 406
@@ -756,18 +758,17 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
756 return false; 758 return false;
757 759
758 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 760 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
759 ("%s ACT_ADDBAREQ From :" MAC_FMT "\n", 761 ("%s ACT_ADDBAREQ From :%pM\n",
760 is_tx ? "Tx" : "Rx", MAC_ARG(hdr->addr2))); 762 is_tx ? "Tx" : "Rx", hdr->addr2));
761 break; 763 break;
762 case ACT_ADDBARSP: 764 case ACT_ADDBARSP:
763 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 765 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
764 ("%s ACT_ADDBARSP From :" MAC_FMT "\n", 766 ("%s ACT_ADDBARSP From :%pM\n",
765 is_tx ? "Tx" : "Rx", MAC_ARG(hdr->addr2))); 767 is_tx ? "Tx" : "Rx", hdr->addr2));
766 break; 768 break;
767 case ACT_DELBA: 769 case ACT_DELBA:
768 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 770 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
769 ("ACT_ADDBADEL From :" MAC_FMT "\n", 771 ("ACT_ADDBADEL From :%pM\n", hdr->addr2));
770 MAC_ARG(hdr->addr2)));
771 break; 772 break;
772 } 773 }
773 break; 774 break;
@@ -1402,8 +1403,7 @@ MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
1402static int __init rtl_core_module_init(void) 1403static int __init rtl_core_module_init(void)
1403{ 1404{
1404 if (rtl_rate_control_register()) 1405 if (rtl_rate_control_register())
1405 printk(KERN_ERR "rtlwifi: Unable to register rtl_rc," 1406 pr_err("Unable to register rtl_rc, use default RC !!\n");
1406 "use default RC !!\n");
1407 1407
1408 return 0; 1408 return 0;
1409} 1409}
diff --git a/drivers/net/wireless/rtlwifi/cam.c b/drivers/net/wireless/rtlwifi/cam.c
index 7295af0536b7..7babb6acd957 100644
--- a/drivers/net/wireless/rtlwifi/cam.c
+++ b/drivers/net/wireless/rtlwifi/cam.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include "wifi.h" 32#include "wifi.h"
31#include "cam.h" 33#include "cam.h"
32 34
@@ -131,9 +133,9 @@ u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
131 133
132 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 134 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
133 ("EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, " 135 ("EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, "
134 "ulUseDK=%x MacAddr" MAC_FMT "\n", 136 "ulUseDK=%x MacAddr %pM\n",
135 ul_entry_idx, ul_key_id, ul_enc_alg, 137 ul_entry_idx, ul_key_id, ul_enc_alg,
136 ul_default_key, MAC_ARG(mac_addr))); 138 ul_default_key, mac_addr));
137 139
138 if (ul_key_id == TOTAL_CAM_ENTRY) { 140 if (ul_key_id == TOTAL_CAM_ENTRY) {
139 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 141 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
@@ -347,7 +349,7 @@ void rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr)
347 /* Remove from HW Security CAM */ 349 /* Remove from HW Security CAM */
348 memset(rtlpriv->sec.hwsec_cam_sta_addr[i], 0, ETH_ALEN); 350 memset(rtlpriv->sec.hwsec_cam_sta_addr[i], 0, ETH_ALEN);
349 rtlpriv->sec.hwsec_cam_bitmap &= ~(BIT(0) << i); 351 rtlpriv->sec.hwsec_cam_bitmap &= ~(BIT(0) << i);
350 printk(KERN_INFO "&&&&&&&&&del entry %d\n", i); 352 pr_info("&&&&&&&&&del entry %d\n", i);
351 } 353 }
352 } 354 }
353 return; 355 return;
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index 03ce69660b26..1bdc1aa305c0 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.c
@@ -456,7 +456,7 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw,
456 sta_entry->wireless_mode = WIRELESS_MODE_G; 456 sta_entry->wireless_mode = WIRELESS_MODE_G;
457 457
458 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 458 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
459 ("Add sta addr is "MAC_FMT"\n", MAC_ARG(sta->addr))); 459 ("Add sta addr is %pM\n", sta->addr));
460 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); 460 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
461 } 461 }
462 return 0; 462 return 0;
@@ -469,7 +469,7 @@ static int rtl_op_sta_remove(struct ieee80211_hw *hw,
469 struct rtl_sta_info *sta_entry; 469 struct rtl_sta_info *sta_entry;
470 if (sta) { 470 if (sta) {
471 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 471 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
472 ("Remove sta addr is "MAC_FMT"\n", MAC_ARG(sta->addr))); 472 ("Remove sta addr is %pM\n", sta->addr));
473 sta_entry = (struct rtl_sta_info *) sta->drv_priv; 473 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
474 sta_entry->wireless_mode = 0; 474 sta_entry->wireless_mode = 0;
475 sta_entry->ratr_index = 0; 475 sta_entry->ratr_index = 0;
@@ -678,7 +678,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
678 (u8 *) bss_conf->bssid); 678 (u8 *) bss_conf->bssid);
679 679
680 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 680 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
681 (MAC_FMT "\n", MAC_ARG(bss_conf->bssid))); 681 ("%pM\n", bss_conf->bssid));
682 682
683 mac->vendor = PEER_UNKNOWN; 683 mac->vendor = PEER_UNKNOWN;
684 memcpy(mac->bssid, bss_conf->bssid, 6); 684 memcpy(mac->bssid, bss_conf->bssid, 6);
diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h
index e4aa8687408c..160dd0685213 100644
--- a/drivers/net/wireless/rtlwifi/debug.h
+++ b/drivers/net/wireless/rtlwifi/debug.h
@@ -204,10 +204,5 @@ enum dbgp_flag_e {
204 } \ 204 } \
205 } while (0); 205 } while (0);
206 206
207#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
208#define MAC_ARG(x) \
209 ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2],\
210 ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5]
211
212void rtl_dbgp_flag_init(struct ieee80211_hw *hw); 207void rtl_dbgp_flag_init(struct ieee80211_hw *hw);
213#endif 208#endif
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
index f9f2370e9256..49a064bdbce6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include <linux/firmware.h> 32#include <linux/firmware.h>
31#include "../wifi.h" 33#include "../wifi.h"
32#include "../pci.h" 34#include "../pci.h"
@@ -224,8 +226,7 @@ int rtl92c_download_fw(struct ieee80211_hw *hw)
224 u32 fwsize; 226 u32 fwsize;
225 enum version_8192c version = rtlhal->version; 227 enum version_8192c version = rtlhal->version;
226 228
227 printk(KERN_INFO "rtl8192c: Loading firmware file %s\n", 229 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
228 rtlpriv->cfg->fw_name);
229 if (!rtlhal->pfirmware) 230 if (!rtlhal->pfirmware)
230 return 1; 231 return 1;
231 232
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index 9e2a9e34a699..a3deaefa788c 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -1592,7 +1592,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
1592 } 1592 }
1593 1593
1594 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1594 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1595 (MAC_FMT "\n", MAC_ARG(rtlefuse->dev_addr))); 1595 ("%pM\n", rtlefuse->dev_addr));
1596 1596
1597 _rtl92ce_read_txpower_info_from_hwpg(hw, 1597 _rtl92ce_read_txpower_info_from_hwpg(hw,
1598 rtlefuse->autoload_failflag, 1598 rtlefuse->autoload_failflag,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
index 2b34764fbf73..814c05df51e8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include "../wifi.h" 32#include "../wifi.h"
31#include "../efuse.h" 33#include "../efuse.h"
32#include "../base.h" 34#include "../base.h"
@@ -337,7 +339,7 @@ static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents)
337 rtlefuse->board_type = boardType; 339 rtlefuse->board_type = boardType;
338 if (IS_HIGHT_PA(rtlefuse->board_type)) 340 if (IS_HIGHT_PA(rtlefuse->board_type))
339 rtlefuse->external_pa = 1; 341 rtlefuse->external_pa = 1;
340 printk(KERN_INFO "rtl8192cu: Board Type %x\n", rtlefuse->board_type); 342 pr_info("Board Type %x\n", rtlefuse->board_type);
341 343
342#ifdef CONFIG_ANTENNA_DIVERSITY 344#ifdef CONFIG_ANTENNA_DIVERSITY
343 /* Antenna Diversity setting. */ 345 /* Antenna Diversity setting. */
@@ -346,8 +348,7 @@ static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents)
346 else 348 else
347 rtl_efuse->antenna_cfg = registry_par->antdiv_cfg; /* 0:OFF, */ 349 rtl_efuse->antenna_cfg = registry_par->antdiv_cfg; /* 0:OFF, */
348 350
349 printk(KERN_INFO "rtl8192cu: Antenna Config %x\n", 351 pr_info("Antenna Config %x\n", rtl_efuse->antenna_cfg);
350 rtl_efuse->antenna_cfg);
351#endif 352#endif
352} 353}
353 354
@@ -384,71 +385,57 @@ static void _update_bt_param(_adapter *padapter)
384 pbtpriv->bBTNonTrafficModeSet = _FALSE; 385 pbtpriv->bBTNonTrafficModeSet = _FALSE;
385 pbtpriv->CurrentState = 0; 386 pbtpriv->CurrentState = 0;
386 pbtpriv->PreviousState = 0; 387 pbtpriv->PreviousState = 0;
387 printk(KERN_INFO "rtl8192cu: BT Coexistance = %s\n", 388 pr_info("BT Coexistance = %s\n",
388 (pbtpriv->BT_Coexist == _TRUE) ? "enable" : "disable"); 389 (pbtpriv->BT_Coexist == _TRUE) ? "enable" : "disable");
389 if (pbtpriv->BT_Coexist) { 390 if (pbtpriv->BT_Coexist) {
390 if (pbtpriv->BT_Ant_Num == Ant_x2) 391 if (pbtpriv->BT_Ant_Num == Ant_x2)
391 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 392 pr_info("BlueTooth BT_Ant_Num = Antx2\n");
392 "Ant_Num = Antx2\n");
393 else if (pbtpriv->BT_Ant_Num == Ant_x1) 393 else if (pbtpriv->BT_Ant_Num == Ant_x1)
394 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 394 pr_info("BlueTooth BT_Ant_Num = Antx1\n");
395 "Ant_Num = Antx1\n");
396 switch (pbtpriv->BT_CoexistType) { 395 switch (pbtpriv->BT_CoexistType) {
397 case BT_2Wire: 396 case BT_2Wire:
398 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 397 pr_info("BlueTooth BT_CoexistType = BT_2Wire\n");
399 "CoexistType = BT_2Wire\n");
400 break; 398 break;
401 case BT_ISSC_3Wire: 399 case BT_ISSC_3Wire:
402 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 400 pr_info("BlueTooth BT_CoexistType = BT_ISSC_3Wire\n");
403 "CoexistType = BT_ISSC_3Wire\n");
404 break; 401 break;
405 case BT_Accel: 402 case BT_Accel:
406 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 403 pr_info("BlueTooth BT_CoexistType = BT_Accel\n");
407 "CoexistType = BT_Accel\n");
408 break; 404 break;
409 case BT_CSR_BC4: 405 case BT_CSR_BC4:
410 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 406 pr_info("BlueTooth BT_CoexistType = BT_CSR_BC4\n");
411 "CoexistType = BT_CSR_BC4\n");
412 break; 407 break;
413 case BT_CSR_BC8: 408 case BT_CSR_BC8:
414 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 409 pr_info("BlueTooth BT_CoexistType = BT_CSR_BC8\n");
415 "CoexistType = BT_CSR_BC8\n");
416 break; 410 break;
417 case BT_RTL8756: 411 case BT_RTL8756:
418 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 412 pr_info("BlueTooth BT_CoexistType = BT_RTL8756\n");
419 "CoexistType = BT_RTL8756\n");
420 break; 413 break;
421 default: 414 default:
422 printk(KERN_INFO "rtl8192cu: BlueTooth BT_" 415 pr_info("BlueTooth BT_CoexistType = Unknown\n");
423 "CoexistType = Unknown\n");
424 break; 416 break;
425 } 417 }
426 printk(KERN_INFO "rtl8192cu: BlueTooth BT_Ant_isolation = %d\n", 418 pr_info("BlueTooth BT_Ant_isolation = %d\n",
427 pbtpriv->BT_Ant_isolation); 419 pbtpriv->BT_Ant_isolation);
428 switch (pbtpriv->BT_Service) { 420 switch (pbtpriv->BT_Service) {
429 case BT_OtherAction: 421 case BT_OtherAction:
430 printk(KERN_INFO "rtl8192cu: BlueTooth BT_Service = " 422 pr_info("BlueTooth BT_Service = BT_OtherAction\n");
431 "BT_OtherAction\n");
432 break; 423 break;
433 case BT_SCO: 424 case BT_SCO:
434 printk(KERN_INFO "rtl8192cu: BlueTooth BT_Service = " 425 pr_info("BlueTooth BT_Service = BT_SCO\n");
435 "BT_SCO\n");
436 break; 426 break;
437 case BT_Busy: 427 case BT_Busy:
438 printk(KERN_INFO "rtl8192cu: BlueTooth BT_Service = " 428 pr_info("BlueTooth BT_Service = BT_Busy\n");
439 "BT_Busy\n");
440 break; 429 break;
441 case BT_OtherBusy: 430 case BT_OtherBusy:
442 printk(KERN_INFO "rtl8192cu: BlueTooth BT_Service = " 431 pr_info("BlueTooth BT_Service = BT_OtherBusy\n");
443 "BT_OtherBusy\n");
444 break; 432 break;
445 default: 433 default:
446 printk(KERN_INFO "rtl8192cu: BlueTooth BT_Service = " 434 pr_info("BlueTooth BT_Service = BT_Idle\n");
447 "BT_Idle\n");
448 break; 435 break;
449 } 436 }
450 printk(KERN_INFO "rtl8192cu: BT_RadioSharedType = 0x%x\n", 437 pr_info("BT_RadioSharedType = 0x%x\n",
451 pbtpriv->BT_RadioSharedType); 438 pbtpriv->BT_RadioSharedType);
452 } 439 }
453} 440}
454 441
@@ -526,7 +513,7 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
526 usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i]; 513 usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
527 *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; 514 *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
528 } 515 }
529 printk(KERN_INFO "rtl8192cu: MAC address: %pM\n", rtlefuse->dev_addr); 516 pr_info("MAC address: %pM\n", rtlefuse->dev_addr);
530 _rtl92cu_read_txpower_info_from_hwpg(hw, 517 _rtl92cu_read_txpower_info_from_hwpg(hw,
531 rtlefuse->autoload_failflag, hwinfo); 518 rtlefuse->autoload_failflag, hwinfo);
532 rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID]; 519 rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
@@ -665,7 +652,7 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw)
665 rtl_write_word(rtlpriv, REG_APS_FSMCO, value16); 652 rtl_write_word(rtlpriv, REG_APS_FSMCO, value16);
666 do { 653 do {
667 if (!(rtl_read_word(rtlpriv, REG_APS_FSMCO) & APFM_ONMAC)) { 654 if (!(rtl_read_word(rtlpriv, REG_APS_FSMCO) & APFM_ONMAC)) {
668 printk(KERN_INFO "rtl8192cu: MAC auto ON okay!\n"); 655 pr_info("MAC auto ON okay!\n");
669 break; 656 break;
670 } 657 }
671 if (pollingCount++ > 100) { 658 if (pollingCount++ > 100) {
@@ -819,7 +806,7 @@ static void _rtl92cu_init_chipN_one_out_ep_priority(struct ieee80211_hw *hw,
819 } 806 }
820 _rtl92c_init_chipN_reg_priority(hw, value, value, value, value, 807 _rtl92c_init_chipN_reg_priority(hw, value, value, value, value,
821 value, value); 808 value, value);
822 printk(KERN_INFO "rtl8192cu: Tx queue select: 0x%02x\n", queue_sel); 809 pr_info("Tx queue select: 0x%02x\n", queue_sel);
823} 810}
824 811
825static void _rtl92cu_init_chipN_two_out_ep_priority(struct ieee80211_hw *hw, 812static void _rtl92cu_init_chipN_two_out_ep_priority(struct ieee80211_hw *hw,
@@ -863,7 +850,7 @@ static void _rtl92cu_init_chipN_two_out_ep_priority(struct ieee80211_hw *hw,
863 hiQ = valueHi; 850 hiQ = valueHi;
864 } 851 }
865 _rtl92c_init_chipN_reg_priority(hw, beQ, bkQ, viQ, voQ, mgtQ, hiQ); 852 _rtl92c_init_chipN_reg_priority(hw, beQ, bkQ, viQ, voQ, mgtQ, hiQ);
866 printk(KERN_INFO "rtl8192cu: Tx queue select: 0x%02x\n", queue_sel); 853 pr_info("Tx queue select: 0x%02x\n", queue_sel);
867} 854}
868 855
869static void _rtl92cu_init_chipN_three_out_ep_priority(struct ieee80211_hw *hw, 856static void _rtl92cu_init_chipN_three_out_ep_priority(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index a90c09b42390..194fc693c1fa 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -26,6 +26,9 @@
26 * Larry Finger <Larry.Finger@lwfinger.net> 26 * Larry Finger <Larry.Finger@lwfinger.net>
27 * 27 *
28****************************************************************************/ 28****************************************************************************/
29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
29#include <linux/module.h> 32#include <linux/module.h>
30 33
31#include "../wifi.h" 34#include "../wifi.h"
@@ -213,14 +216,14 @@ bool rtl92c_init_llt_table(struct ieee80211_hw *hw, u32 boundary)
213 for (i = 0; i < (boundary - 1); i++) { 216 for (i = 0; i < (boundary - 1); i++) {
214 rst = rtl92c_llt_write(hw, i , i + 1); 217 rst = rtl92c_llt_write(hw, i , i + 1);
215 if (true != rst) { 218 if (true != rst) {
216 printk(KERN_ERR "===> %s #1 fail\n", __func__); 219 pr_err("===> %s #1 fail\n", __func__);
217 return rst; 220 return rst;
218 } 221 }
219 } 222 }
220 /* end of list */ 223 /* end of list */
221 rst = rtl92c_llt_write(hw, (boundary - 1), 0xFF); 224 rst = rtl92c_llt_write(hw, (boundary - 1), 0xFF);
222 if (true != rst) { 225 if (true != rst) {
223 printk(KERN_ERR "===> %s #2 fail\n", __func__); 226 pr_err("===> %s #2 fail\n", __func__);
224 return rst; 227 return rst;
225 } 228 }
226 /* Make the other pages as ring buffer 229 /* Make the other pages as ring buffer
@@ -231,14 +234,14 @@ bool rtl92c_init_llt_table(struct ieee80211_hw *hw, u32 boundary)
231 for (i = boundary; i < LLT_LAST_ENTRY_OF_TX_PKT_BUFFER; i++) { 234 for (i = boundary; i < LLT_LAST_ENTRY_OF_TX_PKT_BUFFER; i++) {
232 rst = rtl92c_llt_write(hw, i, (i + 1)); 235 rst = rtl92c_llt_write(hw, i, (i + 1));
233 if (true != rst) { 236 if (true != rst) {
234 printk(KERN_ERR "===> %s #3 fail\n", __func__); 237 pr_err("===> %s #3 fail\n", __func__);
235 return rst; 238 return rst;
236 } 239 }
237 } 240 }
238 /* Let last entry point to the start entry of ring buffer */ 241 /* Let last entry point to the start entry of ring buffer */
239 rst = rtl92c_llt_write(hw, LLT_LAST_ENTRY_OF_TX_PKT_BUFFER, boundary); 242 rst = rtl92c_llt_write(hw, LLT_LAST_ENTRY_OF_TX_PKT_BUFFER, boundary);
240 if (true != rst) { 243 if (true != rst) {
241 printk(KERN_ERR "===> %s #4 fail\n", __func__); 244 pr_err("===> %s #4 fail\n", __func__);
242 return rst; 245 return rst;
243 } 246 }
244 return rst; 247 return rst;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
index 5a65bea4cb8f..0073cf106af2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
@@ -1829,7 +1829,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
1829 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, 1829 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR,
1830 rtlefuse->dev_addr); 1830 rtlefuse->dev_addr);
1831 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1831 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1832 (MAC_FMT "\n", MAC_ARG(rtlefuse->dev_addr))); 1832 ("%pM\n", rtlefuse->dev_addr));
1833 _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo); 1833 _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo);
1834 1834
1835 /* Read Channel Plan */ 1835 /* Read Channel Plan */
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index 08837744f6f1..351765df517d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
31 33
32#include "../wifi.h" 34#include "../wifi.h"
@@ -170,10 +172,8 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
170 } 172 }
171 173
172 if (!header_print) { 174 if (!header_print) {
173 printk(KERN_INFO "rtl8192de: Driver for Realtek RTL8192DE" 175 pr_info("Driver for Realtek RTL8192DE WLAN interface\n");
174 " WLAN interface"); 176 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
175 printk(KERN_INFO "rtl8192de: Loading firmware file %s\n",
176 rtlpriv->cfg->fw_name);
177 header_print++; 177 header_print++;
178 } 178 }
179 /* request fw */ 179 /* request fw */
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
index b1d0213dc60e..d59f66cb7768 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include "../wifi.h" 32#include "../wifi.h"
31#include "../efuse.h" 33#include "../efuse.h"
32#include "../base.h" 34#include "../base.h"
@@ -465,8 +467,7 @@ static u8 _rtl92ce_halset_sysclk(struct ieee80211_hw *hw, u8 data)
465 if ((tmpvalue & BIT(6))) 467 if ((tmpvalue & BIT(6)))
466 break; 468 break;
467 469
468 printk(KERN_ERR "wait for BIT(6) return value %x\n", 470 pr_err("wait for BIT(6) return value %x\n", tmpvalue);
469 tmpvalue);
470 if (waitcount == 0) 471 if (waitcount == 0)
471 break; 472 break;
472 473
@@ -1255,8 +1256,7 @@ static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
1255 if ((tmp & BIT(6))) 1256 if ((tmp & BIT(6)))
1256 break; 1257 break;
1257 1258
1258 printk(KERN_ERR "wait for BIT(6) return value %x\n", 1259 pr_err("wait for BIT(6) return value %x\n", tmp);
1259 tmp);
1260 1260
1261 if (waitcnt == 0) 1261 if (waitcnt == 0)
1262 break; 1262 break;
@@ -1315,7 +1315,7 @@ static void _rtl92s_phy_set_rfhalt(struct ieee80211_hw *hw)
1315 if (u1btmp & BIT(7)) { 1315 if (u1btmp & BIT(7)) {
1316 u1btmp &= ~(BIT(6) | BIT(7)); 1316 u1btmp &= ~(BIT(6) | BIT(7));
1317 if (!_rtl92s_set_sysclk(hw, u1btmp)) { 1317 if (!_rtl92s_set_sysclk(hw, u1btmp)) {
1318 printk(KERN_ERR "Switch ctrl path fail\n"); 1318 pr_err("Switch ctrl path fail\n");
1319 return; 1319 return;
1320 } 1320 }
1321 } 1321 }
@@ -1682,7 +1682,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1682 rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]); 1682 rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]);
1683 1683
1684 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1684 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1685 (MAC_FMT "\n", MAC_ARG(rtlefuse->dev_addr))); 1685 ("%pM\n", rtlefuse->dev_addr));
1686 1686
1687 /* Get Tx Power Level by Channel */ 1687 /* Get Tx Power Level by Channel */
1688 /* Read Tx power of Channel 1 ~ 14 from EEPROM. */ 1688 /* Read Tx power of Channel 1 ~ 14 from EEPROM. */
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
index 81a5aa4370cf..f27171af979c 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include "../wifi.h" 32#include "../wifi.h"
31#include "../pci.h" 33#include "../pci.h"
32#include "../ps.h" 34#include "../ps.h"
@@ -1016,8 +1018,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw)
1016 rtstatus = _rtl92s_phy_config_bb(hw, BASEBAND_CONFIG_AGC_TAB); 1018 rtstatus = _rtl92s_phy_config_bb(hw, BASEBAND_CONFIG_AGC_TAB);
1017 1019
1018 if (rtstatus != true) { 1020 if (rtstatus != true) {
1019 printk(KERN_ERR "_rtl92s_phy_bb_config_parafile(): " 1021 pr_err("%s(): AGC Table Fail\n", __func__);
1020 "AGC Table Fail\n");
1021 goto phy_BB8190_Config_ParaFile_Fail; 1022 goto phy_BB8190_Config_ParaFile_Fail;
1022 } 1023 }
1023 1024
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
index c6e3a4ca42f9..0ad50fe44aa2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include "../wifi.h" 32#include "../wifi.h"
31#include "reg.h" 33#include "reg.h"
32#include "def.h" 34#include "def.h"
@@ -507,7 +509,7 @@ bool rtl92s_phy_rf6052_config(struct ieee80211_hw *hw)
507 } 509 }
508 510
509 if (rtstatus != true) { 511 if (rtstatus != true) {
510 printk(KERN_ERR "Radio[%d] Fail!!", rfpath); 512 pr_err("Radio[%d] Fail!!\n", rfpath);
511 goto fail; 513 goto fail;
512 } 514 }
513 515
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index 1c6cb1d7d660..3876078a63de 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -27,6 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
31 33
32#include "../wifi.h" 34#include "../wifi.h"
@@ -183,8 +185,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
183 return 1; 185 return 1;
184 } 186 }
185 187
186 printk(KERN_INFO "rtl8192se: Driver for Realtek RTL8192SE/RTL8191SE\n" 188 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n"
187 " Loading firmware %s\n", rtlpriv->cfg->fw_name); 189 "Loading firmware %s\n", rtlpriv->cfg->fw_name);
188 /* request fw */ 190 /* request fw */
189 err = request_firmware(&firmware, rtlpriv->cfg->fw_name, 191 err = request_firmware(&firmware, rtlpriv->cfg->fw_name,
190 rtlpriv->io.dev); 192 rtlpriv->io.dev);
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index a9367eba1ea7..8b1cef0ffde6 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -24,6 +24,9 @@
24 * Hsinchu 300, Taiwan. 24 * Hsinchu 300, Taiwan.
25 * 25 *
26 *****************************************************************************/ 26 *****************************************************************************/
27
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29
27#include <linux/usb.h> 30#include <linux/usb.h>
28#include "core.h" 31#include "core.h"
29#include "wifi.h" 32#include "wifi.h"
@@ -104,9 +107,8 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request,
104 pdata, len, 0); /* max. timeout */ 107 pdata, len, 0); /* max. timeout */
105 108
106 if (status < 0) 109 if (status < 0)
107 printk(KERN_ERR "reg 0x%x, usbctrl_vendorreq TimeOut! " 110 pr_err("reg 0x%x, usbctrl_vendorreq TimeOut! status:0x%x value=0x%x\n",
108 "status:0x%x value=0x%x\n", value, status, 111 value, status, *(u32 *)pdata);
109 *(u32 *)pdata);
110 return status; 112 return status;
111} 113}
112 114
@@ -316,7 +318,7 @@ static int _rtl_usb_init_rx(struct ieee80211_hw *hw)
316 rtlusb->usb_rx_segregate_hdl = 318 rtlusb->usb_rx_segregate_hdl =
317 rtlpriv->cfg->usb_interface_cfg->usb_rx_segregate_hdl; 319 rtlpriv->cfg->usb_interface_cfg->usb_rx_segregate_hdl;
318 320
319 printk(KERN_INFO "rtl8192cu: rx_max_size %d, rx_urb_num %d, in_ep %d\n", 321 pr_info("rx_max_size %d, rx_urb_num %d, in_ep %d\n",
320 rtlusb->rx_max_size, rtlusb->rx_urb_num, rtlusb->in_ep); 322 rtlusb->rx_max_size, rtlusb->rx_urb_num, rtlusb->in_ep);
321 init_usb_anchor(&rtlusb->rx_submitted); 323 init_usb_anchor(&rtlusb->rx_submitted);
322 return 0; 324 return 0;
@@ -580,7 +582,7 @@ static void _rtl_rx_completed(struct urb *_urb)
580 } else{ 582 } else{
581 /* TO DO */ 583 /* TO DO */
582 _rtl_rx_pre_process(hw, skb); 584 _rtl_rx_pre_process(hw, skb);
583 printk(KERN_ERR "rtlwifi: rx agg not supported\n"); 585 pr_err("rx agg not supported\n");
584 } 586 }
585 goto resubmit; 587 goto resubmit;
586 } 588 }
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 57b7b6460896..6ec6e099fe04 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -1266,7 +1266,10 @@ u32 ssb_dma_translation(struct ssb_device *dev)
1266 case SSB_BUSTYPE_SSB: 1266 case SSB_BUSTYPE_SSB:
1267 return 0; 1267 return 0;
1268 case SSB_BUSTYPE_PCI: 1268 case SSB_BUSTYPE_PCI:
1269 return SSB_PCI_DMA; 1269 if (ssb_read32(dev, SSB_TMSHIGH) & SSB_TMSHIGH_DMA64)
1270 return SSB_PCIE_DMA_H32;
1271 else
1272 return SSB_PCI_DMA;
1270 default: 1273 default:
1271 __ssb_dma_not_implemented(dev); 1274 __ssb_dma_not_implemented(dev);
1272 } 1275 }
diff --git a/drivers/staging/gma500/psb_intel_display.c b/drivers/staging/gma500/psb_intel_display.c
index 4f47d09d65de..09e378d5ddcb 100644
--- a/drivers/staging/gma500/psb_intel_display.c
+++ b/drivers/staging/gma500/psb_intel_display.c
@@ -331,7 +331,7 @@ static bool psb_intel_find_best_PLL(struct drm_crtc *crtc, int target,
331void psb_intel_wait_for_vblank(struct drm_device *dev) 331void psb_intel_wait_for_vblank(struct drm_device *dev)
332{ 332{
333 /* Wait for 20ms, i.e. one cycle at 50hz. */ 333 /* Wait for 20ms, i.e. one cycle at 50hz. */
334 udelay(20000); 334 mdelay(20);
335} 335}
336 336
337int psb_intel_pipe_set_base(struct drm_crtc *crtc, 337int psb_intel_pipe_set_base(struct drm_crtc *crtc,
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9fb0b15331d3..c62fb84944d5 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1448,6 +1448,8 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
1448 1448
1449int blkdev_put(struct block_device *bdev, fmode_t mode) 1449int blkdev_put(struct block_device *bdev, fmode_t mode)
1450{ 1450{
1451 mutex_lock(&bdev->bd_mutex);
1452
1451 if (mode & FMODE_EXCL) { 1453 if (mode & FMODE_EXCL) {
1452 bool bdev_free; 1454 bool bdev_free;
1453 1455
@@ -1456,7 +1458,6 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
1456 * are protected with bdev_lock. bd_mutex is to 1458 * are protected with bdev_lock. bd_mutex is to
1457 * synchronize disk_holder unlinking. 1459 * synchronize disk_holder unlinking.
1458 */ 1460 */
1459 mutex_lock(&bdev->bd_mutex);
1460 spin_lock(&bdev_lock); 1461 spin_lock(&bdev_lock);
1461 1462
1462 WARN_ON_ONCE(--bdev->bd_holders < 0); 1463 WARN_ON_ONCE(--bdev->bd_holders < 0);
@@ -1474,17 +1475,21 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
1474 * If this was the last claim, remove holder link and 1475 * If this was the last claim, remove holder link and
1475 * unblock evpoll if it was a write holder. 1476 * unblock evpoll if it was a write holder.
1476 */ 1477 */
1477 if (bdev_free) { 1478 if (bdev_free && bdev->bd_write_holder) {
1478 if (bdev->bd_write_holder) { 1479 disk_unblock_events(bdev->bd_disk);
1479 disk_unblock_events(bdev->bd_disk); 1480 bdev->bd_write_holder = false;
1480 disk_check_events(bdev->bd_disk);
1481 bdev->bd_write_holder = false;
1482 }
1483 } 1481 }
1484
1485 mutex_unlock(&bdev->bd_mutex);
1486 } 1482 }
1487 1483
1484 /*
1485 * Trigger event checking and tell drivers to flush MEDIA_CHANGE
1486 * event. This is to ensure detection of media removal commanded
1487 * from userland - e.g. eject(1).
1488 */
1489 disk_flush_events(bdev->bd_disk, DISK_EVENT_MEDIA_CHANGE);
1490
1491 mutex_unlock(&bdev->bd_mutex);
1492
1488 return __blkdev_put(bdev, mode, 0); 1493 return __blkdev_put(bdev, mode, 0);
1489} 1494}
1490EXPORT_SYMBOL(blkdev_put); 1495EXPORT_SYMBOL(blkdev_put);
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 61abb638b4bf..8be086e9abe4 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -68,6 +68,8 @@
68 68
69#ifdef CONFIG_BLOCK 69#ifdef CONFIG_BLOCK
70#include <linux/loop.h> 70#include <linux/loop.h>
71#include <linux/cdrom.h>
72#include <linux/fd.h>
71#include <scsi/scsi.h> 73#include <scsi/scsi.h>
72#include <scsi/scsi_ioctl.h> 74#include <scsi/scsi_ioctl.h>
73#include <scsi/sg.h> 75#include <scsi/sg.h>
@@ -944,6 +946,9 @@ COMPATIBLE_IOCTL(FIOQSIZE)
944IGNORE_IOCTL(LOOP_CLR_FD) 946IGNORE_IOCTL(LOOP_CLR_FD)
945/* md calls this on random blockdevs */ 947/* md calls this on random blockdevs */
946IGNORE_IOCTL(RAID_VERSION) 948IGNORE_IOCTL(RAID_VERSION)
949/* qemu/qemu-img might call these two on plain files for probing */
950IGNORE_IOCTL(CDROM_DRIVE_STATUS)
951IGNORE_IOCTL(FDGETPRM32)
947/* SG stuff */ 952/* SG stuff */
948COMPATIBLE_IOCTL(SG_SET_TIMEOUT) 953COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
949COMPATIBLE_IOCTL(SG_GET_TIMEOUT) 954COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index d545e97d99c3..e3c63d1c5e13 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -237,22 +237,22 @@ ssize_t part_size_show(struct device *dev,
237 return sprintf(buf, "%llu\n",(unsigned long long)p->nr_sects); 237 return sprintf(buf, "%llu\n",(unsigned long long)p->nr_sects);
238} 238}
239 239
240ssize_t part_ro_show(struct device *dev, 240static ssize_t part_ro_show(struct device *dev,
241 struct device_attribute *attr, char *buf) 241 struct device_attribute *attr, char *buf)
242{ 242{
243 struct hd_struct *p = dev_to_part(dev); 243 struct hd_struct *p = dev_to_part(dev);
244 return sprintf(buf, "%d\n", p->policy ? 1 : 0); 244 return sprintf(buf, "%d\n", p->policy ? 1 : 0);
245} 245}
246 246
247ssize_t part_alignment_offset_show(struct device *dev, 247static ssize_t part_alignment_offset_show(struct device *dev,
248 struct device_attribute *attr, char *buf) 248 struct device_attribute *attr, char *buf)
249{ 249{
250 struct hd_struct *p = dev_to_part(dev); 250 struct hd_struct *p = dev_to_part(dev);
251 return sprintf(buf, "%llu\n", (unsigned long long)p->alignment_offset); 251 return sprintf(buf, "%llu\n", (unsigned long long)p->alignment_offset);
252} 252}
253 253
254ssize_t part_discard_alignment_show(struct device *dev, 254static ssize_t part_discard_alignment_show(struct device *dev,
255 struct device_attribute *attr, char *buf) 255 struct device_attribute *attr, char *buf)
256{ 256{
257 struct hd_struct *p = dev_to_part(dev); 257 struct hd_struct *p = dev_to_part(dev);
258 return sprintf(buf, "%u\n", p->discard_alignment); 258 return sprintf(buf, "%u\n", p->discard_alignment);
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index c5e82ece7c6c..a159ba5a35e7 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -678,23 +678,19 @@ struct buffer_chunk {
678static void write_chunk(struct buffer_chunk *chunk) 678static void write_chunk(struct buffer_chunk *chunk)
679{ 679{
680 int i; 680 int i;
681 get_fs_excl();
682 for (i = 0; i < chunk->nr; i++) { 681 for (i = 0; i < chunk->nr; i++) {
683 submit_logged_buffer(chunk->bh[i]); 682 submit_logged_buffer(chunk->bh[i]);
684 } 683 }
685 chunk->nr = 0; 684 chunk->nr = 0;
686 put_fs_excl();
687} 685}
688 686
689static void write_ordered_chunk(struct buffer_chunk *chunk) 687static void write_ordered_chunk(struct buffer_chunk *chunk)
690{ 688{
691 int i; 689 int i;
692 get_fs_excl();
693 for (i = 0; i < chunk->nr; i++) { 690 for (i = 0; i < chunk->nr; i++) {
694 submit_ordered_buffer(chunk->bh[i]); 691 submit_ordered_buffer(chunk->bh[i]);
695 } 692 }
696 chunk->nr = 0; 693 chunk->nr = 0;
697 put_fs_excl();
698} 694}
699 695
700static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh, 696static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh,
@@ -986,8 +982,6 @@ static int flush_commit_list(struct super_block *s,
986 return 0; 982 return 0;
987 } 983 }
988 984
989 get_fs_excl();
990
991 /* before we can put our commit blocks on disk, we have to make sure everyone older than 985 /* before we can put our commit blocks on disk, we have to make sure everyone older than
992 ** us is on disk too 986 ** us is on disk too
993 */ 987 */
@@ -1145,7 +1139,6 @@ static int flush_commit_list(struct super_block *s,
1145 if (retval) 1139 if (retval)
1146 reiserfs_abort(s, retval, "Journal write error in %s", 1140 reiserfs_abort(s, retval, "Journal write error in %s",
1147 __func__); 1141 __func__);
1148 put_fs_excl();
1149 return retval; 1142 return retval;
1150} 1143}
1151 1144
@@ -1374,8 +1367,6 @@ static int flush_journal_list(struct super_block *s,
1374 return 0; 1367 return 0;
1375 } 1368 }
1376 1369
1377 get_fs_excl();
1378
1379 /* if all the work is already done, get out of here */ 1370 /* if all the work is already done, get out of here */
1380 if (atomic_read(&(jl->j_nonzerolen)) <= 0 && 1371 if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
1381 atomic_read(&(jl->j_commit_left)) <= 0) { 1372 atomic_read(&(jl->j_commit_left)) <= 0) {
@@ -1597,7 +1588,6 @@ static int flush_journal_list(struct super_block *s,
1597 put_journal_list(s, jl); 1588 put_journal_list(s, jl);
1598 if (flushall) 1589 if (flushall)
1599 mutex_unlock(&journal->j_flush_mutex); 1590 mutex_unlock(&journal->j_flush_mutex);
1600 put_fs_excl();
1601 return err; 1591 return err;
1602} 1592}
1603 1593
@@ -3108,7 +3098,6 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
3108 th->t_trans_id = journal->j_trans_id; 3098 th->t_trans_id = journal->j_trans_id;
3109 unlock_journal(sb); 3099 unlock_journal(sb);
3110 INIT_LIST_HEAD(&th->t_list); 3100 INIT_LIST_HEAD(&th->t_list);
3111 get_fs_excl();
3112 return 0; 3101 return 0;
3113 3102
3114 out_fail: 3103 out_fail:
@@ -3964,7 +3953,6 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
3964 flush = flags & FLUSH_ALL; 3953 flush = flags & FLUSH_ALL;
3965 wait_on_commit = flags & WAIT; 3954 wait_on_commit = flags & WAIT;
3966 3955
3967 put_fs_excl();
3968 current->journal_info = th->t_handle_save; 3956 current->journal_info = th->t_handle_save;
3969 reiserfs_check_lock_depth(sb, "journal end"); 3957 reiserfs_check_lock_depth(sb, "journal end");
3970 if (journal->j_len == 0) { 3958 if (journal->j_len == 0) {
@@ -4316,4 +4304,3 @@ void reiserfs_abort_journal(struct super_block *sb, int errno)
4316 dump_stack(); 4304 dump_stack();
4317#endif 4305#endif
4318} 4306}
4319
diff --git a/fs/super.c b/fs/super.c
index 7943f04cb3a9..3f56a269a4f4 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -351,13 +351,11 @@ bool grab_super_passive(struct super_block *sb)
351 */ 351 */
352void lock_super(struct super_block * sb) 352void lock_super(struct super_block * sb)
353{ 353{
354 get_fs_excl();
355 mutex_lock(&sb->s_lock); 354 mutex_lock(&sb->s_lock);
356} 355}
357 356
358void unlock_super(struct super_block * sb) 357void unlock_super(struct super_block * sb)
359{ 358{
360 put_fs_excl();
361 mutex_unlock(&sb->s_lock); 359 mutex_unlock(&sb->s_lock);
362} 360}
363 361
@@ -385,7 +383,6 @@ void generic_shutdown_super(struct super_block *sb)
385 if (sb->s_root) { 383 if (sb->s_root) {
386 shrink_dcache_for_umount(sb); 384 shrink_dcache_for_umount(sb);
387 sync_filesystem(sb); 385 sync_filesystem(sb);
388 get_fs_excl();
389 sb->s_flags &= ~MS_ACTIVE; 386 sb->s_flags &= ~MS_ACTIVE;
390 387
391 fsnotify_unmount_inodes(&sb->s_inodes); 388 fsnotify_unmount_inodes(&sb->s_inodes);
@@ -400,7 +397,6 @@ void generic_shutdown_super(struct super_block *sb)
400 "Self-destruct in 5 seconds. Have a nice day...\n", 397 "Self-destruct in 5 seconds. Have a nice day...\n",
401 sb->s_id); 398 sb->s_id);
402 } 399 }
403 put_fs_excl();
404 } 400 }
405 spin_lock(&sb_lock); 401 spin_lock(&sb_lock);
406 /* should be initialized for __put_super_and_need_restart() */ 402 /* should be initialized for __put_super_and_need_restart() */
diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h
index c74ef2c6e633..98dcd76ce836 100644
--- a/include/asm-generic/iomap.h
+++ b/include/asm-generic/iomap.h
@@ -71,6 +71,14 @@ extern void ioport_unmap(void __iomem *);
71struct pci_dev; 71struct pci_dev;
72extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); 72extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
73extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 73extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
74#else
75struct pci_dev;
76static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
77{
78 return NULL;
79}
80static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
81{ }
74#endif 82#endif
75 83
76#endif 84#endif
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 3895aeb494a3..8c96654bef16 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -25,6 +25,11 @@ struct bcma_chipinfo {
25 u8 pkg; 25 u8 pkg;
26}; 26};
27 27
28enum bcma_clkmode {
29 BCMA_CLKMODE_FAST,
30 BCMA_CLKMODE_DYNAMIC,
31};
32
28struct bcma_host_ops { 33struct bcma_host_ops {
29 u8 (*read8)(struct bcma_device *core, u16 offset); 34 u8 (*read8)(struct bcma_device *core, u16 offset);
30 u16 (*read16)(struct bcma_device *core, u16 offset); 35 u16 (*read16)(struct bcma_device *core, u16 offset);
@@ -243,8 +248,24 @@ void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
243 core->bus->ops->awrite32(core, offset, value); 248 core->bus->ops->awrite32(core, offset, value);
244} 249}
245 250
251#define bcma_mask32(cc, offset, mask) \
252 bcma_write32(cc, offset, bcma_read32(cc, offset) & (mask))
253#define bcma_set32(cc, offset, set) \
254 bcma_write32(cc, offset, bcma_read32(cc, offset) | (set))
255#define bcma_maskset32(cc, offset, mask, set) \
256 bcma_write32(cc, offset, (bcma_read32(cc, offset) & (mask)) | (set))
257
246extern bool bcma_core_is_enabled(struct bcma_device *core); 258extern bool bcma_core_is_enabled(struct bcma_device *core);
247extern void bcma_core_disable(struct bcma_device *core, u32 flags); 259extern void bcma_core_disable(struct bcma_device *core, u32 flags);
248extern int bcma_core_enable(struct bcma_device *core, u32 flags); 260extern int bcma_core_enable(struct bcma_device *core, u32 flags);
261extern void bcma_core_set_clockmode(struct bcma_device *core,
262 enum bcma_clkmode clkmode);
263extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
264 bool on);
265#define BCMA_DMA_TRANSLATION_MASK 0xC0000000
266#define BCMA_DMA_TRANSLATION_NONE 0x00000000
267#define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
268#define BCMA_DMA_TRANSLATION_DMA64_CMT 0x80000000 /* Client Mode Translation for 64-bit DMA */
269extern u32 bcma_core_dma_translation(struct bcma_device *core);
249 270
250#endif /* LINUX_BCMA_H_ */ 271#endif /* LINUX_BCMA_H_ */
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 9c5b69fc985a..a0f684615ae5 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -179,15 +179,7 @@
179#define BCMA_CC_PROG_WAITCNT 0x0124 179#define BCMA_CC_PROG_WAITCNT 0x0124
180#define BCMA_CC_FLASH_CFG 0x0128 180#define BCMA_CC_FLASH_CFG 0x0128
181#define BCMA_CC_FLASH_WAITCNT 0x012C 181#define BCMA_CC_FLASH_WAITCNT 0x012C
182#define BCMA_CC_CLKCTLST 0x01E0 /* Clock control and status (rev >= 20) */ 182/* 0x1E0 is defined as shared BCMA_CLKCTLST */
183#define BCMA_CC_CLKCTLST_FORCEALP 0x00000001 /* Force ALP request */
184#define BCMA_CC_CLKCTLST_FORCEHT 0x00000002 /* Force HT request */
185#define BCMA_CC_CLKCTLST_FORCEILP 0x00000004 /* Force ILP request */
186#define BCMA_CC_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
187#define BCMA_CC_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
188#define BCMA_CC_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
189#define BCMA_CC_CLKCTLST_HAVEHT 0x00010000 /* HT available */
190#define BCMA_CC_CLKCTLST_HAVEALP 0x00020000 /* APL available */
191#define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */ 183#define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
192#define BCMA_CC_UART0_DATA 0x0300 184#define BCMA_CC_UART0_DATA 0x0300
193#define BCMA_CC_UART0_IMR 0x0304 185#define BCMA_CC_UART0_IMR 0x0304
@@ -244,7 +236,8 @@
244#define BCMA_CC_REGCTL_DATA 0x065C 236#define BCMA_CC_REGCTL_DATA 0x065C
245#define BCMA_CC_PLLCTL_ADDR 0x0660 237#define BCMA_CC_PLLCTL_ADDR 0x0660
246#define BCMA_CC_PLLCTL_DATA 0x0664 238#define BCMA_CC_PLLCTL_DATA 0x0664
247#define BCMA_CC_SPROM 0x0830 /* SPROM beginning */ 239#define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
240#define BCMA_CC_SPROM_PCIE6 0x0830 /* SPROM beginning on PCIe rev >= 6 */
248 241
249/* Data for the PMU, if available. 242/* Data for the PMU, if available.
250 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU) 243 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h
index f82d88a960ce..9faae2ae02e8 100644
--- a/include/linux/bcma/bcma_regs.h
+++ b/include/linux/bcma/bcma_regs.h
@@ -1,13 +1,38 @@
1#ifndef LINUX_BCMA_REGS_H_ 1#ifndef LINUX_BCMA_REGS_H_
2#define LINUX_BCMA_REGS_H_ 2#define LINUX_BCMA_REGS_H_
3 3
4/* Some single registers are shared between many cores */
5/* BCMA_CLKCTLST: ChipCommon (rev >= 20), PCIe, 80211 */
6#define BCMA_CLKCTLST 0x01E0 /* Clock control and status */
7#define BCMA_CLKCTLST_FORCEALP 0x00000001 /* Force ALP request */
8#define BCMA_CLKCTLST_FORCEHT 0x00000002 /* Force HT request */
9#define BCMA_CLKCTLST_FORCEILP 0x00000004 /* Force ILP request */
10#define BCMA_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
11#define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
12#define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
13#define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
14#define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
15#define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
16#define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
17#define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
18#define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
19/* Is there any BCM4328 on BCMA bus? */
20#define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
21#define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
22
4/* Agent registers (common for every core) */ 23/* Agent registers (common for every core) */
5#define BCMA_IOCTL 0x0408 24#define BCMA_IOCTL 0x0408 /* IO control */
6#define BCMA_IOCTL_CLK 0x0001 25#define BCMA_IOCTL_CLK 0x0001
7#define BCMA_IOCTL_FGC 0x0002 26#define BCMA_IOCTL_FGC 0x0002
8#define BCMA_IOCTL_CORE_BITS 0x3FFC 27#define BCMA_IOCTL_CORE_BITS 0x3FFC
9#define BCMA_IOCTL_PME_EN 0x4000 28#define BCMA_IOCTL_PME_EN 0x4000
10#define BCMA_IOCTL_BIST_EN 0x8000 29#define BCMA_IOCTL_BIST_EN 0x8000
30#define BCMA_IOST 0x0500 /* IO status */
31#define BCMA_IOST_CORE_BITS 0x0FFF
32#define BCMA_IOST_DMA64 0x1000
33#define BCMA_IOST_GATED_CLK 0x2000
34#define BCMA_IOST_BIST_ERROR 0x4000
35#define BCMA_IOST_BIST_DONE 0x8000
11#define BCMA_RESET_CTL 0x0800 36#define BCMA_RESET_CTL 0x0800
12#define BCMA_RESET_CTL_RESET 0x0001 37#define BCMA_RESET_CTL_RESET 0x0001
13 38
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1a23722e8878..0e67c45b3bc9 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -73,7 +73,7 @@ enum rq_cmd_type_bits {
73 73
74/* 74/*
75 * try to put the fields that are referenced together in the same cacheline. 75 * try to put the fields that are referenced together in the same cacheline.
76 * if you modify this structure, be sure to check block/blk-core.c:rq_init() 76 * if you modify this structure, be sure to check block/blk-core.c:blk_rq_init()
77 * as well! 77 * as well!
78 */ 78 */
79struct request { 79struct request {
@@ -260,8 +260,7 @@ struct queue_limits {
260 unsigned char discard_zeroes_data; 260 unsigned char discard_zeroes_data;
261}; 261};
262 262
263struct request_queue 263struct request_queue {
264{
265 /* 264 /*
266 * Together with queue_head for cacheline sharing 265 * Together with queue_head for cacheline sharing
267 */ 266 */
@@ -304,14 +303,14 @@ struct request_queue
304 void *queuedata; 303 void *queuedata;
305 304
306 /* 305 /*
307 * queue needs bounce pages for pages above this limit 306 * various queue flags, see QUEUE_* below
308 */ 307 */
309 gfp_t bounce_gfp; 308 unsigned long queue_flags;
310 309
311 /* 310 /*
312 * various queue flags, see QUEUE_* below 311 * queue needs bounce pages for pages above this limit
313 */ 312 */
314 unsigned long queue_flags; 313 gfp_t bounce_gfp;
315 314
316 /* 315 /*
317 * protects queue structures from reentrancy. ->__queue_lock should 316 * protects queue structures from reentrancy. ->__queue_lock should
@@ -334,8 +333,8 @@ struct request_queue
334 unsigned int nr_congestion_off; 333 unsigned int nr_congestion_off;
335 unsigned int nr_batching; 334 unsigned int nr_batching;
336 335
337 void *dma_drain_buffer;
338 unsigned int dma_drain_size; 336 unsigned int dma_drain_size;
337 void *dma_drain_buffer;
339 unsigned int dma_pad_mask; 338 unsigned int dma_pad_mask;
340 unsigned int dma_alignment; 339 unsigned int dma_alignment;
341 340
@@ -393,7 +392,7 @@ struct request_queue
393#define QUEUE_FLAG_ELVSWITCH 6 /* don't use elevator, just do FIFO */ 392#define QUEUE_FLAG_ELVSWITCH 6 /* don't use elevator, just do FIFO */
394#define QUEUE_FLAG_BIDI 7 /* queue supports bidi requests */ 393#define QUEUE_FLAG_BIDI 7 /* queue supports bidi requests */
395#define QUEUE_FLAG_NOMERGES 8 /* disable merge attempts */ 394#define QUEUE_FLAG_NOMERGES 8 /* disable merge attempts */
396#define QUEUE_FLAG_SAME_COMP 9 /* force complete on same CPU */ 395#define QUEUE_FLAG_SAME_COMP 9 /* complete on same CPU-group */
397#define QUEUE_FLAG_FAIL_IO 10 /* fake timeout */ 396#define QUEUE_FLAG_FAIL_IO 10 /* fake timeout */
398#define QUEUE_FLAG_STACKABLE 11 /* supports request stacking */ 397#define QUEUE_FLAG_STACKABLE 11 /* supports request stacking */
399#define QUEUE_FLAG_NONROT 12 /* non-rotational device (SSD) */ 398#define QUEUE_FLAG_NONROT 12 /* non-rotational device (SSD) */
@@ -403,6 +402,7 @@ struct request_queue
403#define QUEUE_FLAG_NOXMERGES 15 /* No extended merges */ 402#define QUEUE_FLAG_NOXMERGES 15 /* No extended merges */
404#define QUEUE_FLAG_ADD_RANDOM 16 /* Contributes to random pool */ 403#define QUEUE_FLAG_ADD_RANDOM 16 /* Contributes to random pool */
405#define QUEUE_FLAG_SECDISCARD 17 /* supports SECDISCARD */ 404#define QUEUE_FLAG_SECDISCARD 17 /* supports SECDISCARD */
405#define QUEUE_FLAG_SAME_FORCE 18 /* force complete on same CPU */
406 406
407#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 407#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
408 (1 << QUEUE_FLAG_STACKABLE) | \ 408 (1 << QUEUE_FLAG_STACKABLE) | \
@@ -857,12 +857,21 @@ struct request_queue *blk_alloc_queue(gfp_t);
857struct request_queue *blk_alloc_queue_node(gfp_t, int); 857struct request_queue *blk_alloc_queue_node(gfp_t, int);
858extern void blk_put_queue(struct request_queue *); 858extern void blk_put_queue(struct request_queue *);
859 859
860/*
861 * Note: Code in between changing the blk_plug list/cb_list or element of such
862 * lists is preemptable, but such code can't do sleep (or be very careful),
863 * otherwise data is corrupted. For details, please check schedule() where
864 * blk_schedule_flush_plug() is called.
865 */
860struct blk_plug { 866struct blk_plug {
861 unsigned long magic; 867 unsigned long magic;
862 struct list_head list; 868 struct list_head list;
863 struct list_head cb_list; 869 struct list_head cb_list;
864 unsigned int should_sort; 870 unsigned int should_sort;
871 unsigned int count;
865}; 872};
873#define BLK_MAX_REQUEST_COUNT 16
874
866struct blk_plug_cb { 875struct blk_plug_cb {
867 struct list_head list; 876 struct list_head list;
868 void (*callback)(struct blk_plug_cb *); 877 void (*callback)(struct blk_plug_cb *);
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 21a8ebf2dc3a..d800d5142184 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -146,7 +146,7 @@ extern struct request *elv_rb_latter_request(struct request_queue *, struct requ
146/* 146/*
147 * rb support functions. 147 * rb support functions.
148 */ 148 */
149extern struct request *elv_rb_add(struct rb_root *, struct request *); 149extern void elv_rb_add(struct rb_root *, struct request *);
150extern void elv_rb_del(struct rb_root *, struct request *); 150extern void elv_rb_del(struct rb_root *, struct request *);
151extern struct request *elv_rb_find(struct rb_root *, sector_t); 151extern struct request *elv_rb_find(struct rb_root *, sector_t);
152 152
diff --git a/include/linux/fd.h b/include/linux/fd.h
index f5d194af07a8..72202b1b9a6a 100644
--- a/include/linux/fd.h
+++ b/include/linux/fd.h
@@ -377,4 +377,26 @@ struct floppy_raw_cmd {
377#define FDEJECT _IO(2, 0x5a) 377#define FDEJECT _IO(2, 0x5a)
378/* eject the disk */ 378/* eject the disk */
379 379
380
381#ifdef __KERNEL__
382#ifdef CONFIG_COMPAT
383#include <linux/compat.h>
384
385struct compat_floppy_struct {
386 compat_uint_t size;
387 compat_uint_t sect;
388 compat_uint_t head;
389 compat_uint_t track;
390 compat_uint_t stretch;
391 unsigned char gap;
392 unsigned char rate;
393 unsigned char spec1;
394 unsigned char fmt_gap;
395 const compat_caddr_t name;
396};
397
398#define FDGETPRM32 _IOR(2, 0x04, struct compat_floppy_struct)
399#endif
400#endif
401
380#endif 402#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b224dc468a23..0c35d6e767d9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1469,10 +1469,6 @@ enum {
1469#define vfs_check_frozen(sb, level) \ 1469#define vfs_check_frozen(sb, level) \
1470 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) 1470 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level)))
1471 1471
1472#define get_fs_excl() atomic_inc(&current->fs_excl)
1473#define put_fs_excl() atomic_dec(&current->fs_excl)
1474#define has_fs_excl() atomic_read(&current->fs_excl)
1475
1476/* 1472/*
1477 * until VFS tracks user namespaces for inodes, just make all files 1473 * until VFS tracks user namespaces for inodes, just make all files
1478 * belong to init_user_ns 1474 * belong to init_user_ns
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 300d7582006e..02fa4697a0e5 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -420,7 +420,7 @@ static inline int get_disk_ro(struct gendisk *disk)
420 420
421extern void disk_block_events(struct gendisk *disk); 421extern void disk_block_events(struct gendisk *disk);
422extern void disk_unblock_events(struct gendisk *disk); 422extern void disk_unblock_events(struct gendisk *disk);
423extern void disk_check_events(struct gendisk *disk); 423extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
424extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask); 424extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
425 425
426/* drivers/char/random.c */ 426/* drivers/char/random.c */
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index a26108e4d924..54c878960872 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1453,6 +1453,43 @@ enum ieee80211_sa_query_action {
1453 1453
1454#define WLAN_PMKID_LEN 16 1454#define WLAN_PMKID_LEN 16
1455 1455
1456/*
1457 * WMM/802.11e Tspec Element
1458 */
1459#define IEEE80211_WMM_IE_TSPEC_TID_MASK 0x0F
1460#define IEEE80211_WMM_IE_TSPEC_TID_SHIFT 1
1461
1462enum ieee80211_tspec_status_code {
1463 IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED = 0,
1464 IEEE80211_TSPEC_STATUS_ADDTS_INVAL_PARAMS = 0x1,
1465};
1466
1467struct ieee80211_tspec_ie {
1468 u8 element_id;
1469 u8 len;
1470 u8 oui[3];
1471 u8 oui_type;
1472 u8 oui_subtype;
1473 u8 version;
1474 __le16 tsinfo;
1475 u8 tsinfo_resvd;
1476 __le16 nominal_msdu;
1477 __le16 max_msdu;
1478 __le32 min_service_int;
1479 __le32 max_service_int;
1480 __le32 inactivity_int;
1481 __le32 suspension_int;
1482 __le32 service_start_time;
1483 __le32 min_data_rate;
1484 __le32 mean_data_rate;
1485 __le32 peak_data_rate;
1486 __le32 max_burst_size;
1487 __le32 delay_bound;
1488 __le32 min_phy_rate;
1489 __le16 sba;
1490 __le16 medium_time;
1491} __packed;
1492
1456/** 1493/**
1457 * ieee80211_get_qos_ctl - get pointer to qos control bytes 1494 * ieee80211_get_qos_ctl - get pointer to qos control bytes
1458 * @hdr: the frame 1495 * @hdr: the frame
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 580f70c02391..d14e058aaeed 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -176,7 +176,6 @@ extern struct cred init_cred;
176 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ 176 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
177 .journal_info = NULL, \ 177 .journal_info = NULL, \
178 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ 178 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
179 .fs_excl = ATOMIC_INIT(0), \
180 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ 179 .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
181 .timer_slack_ns = 50000, /* 50 usec default slack */ \ 180 .timer_slack_ns = 50000, /* 50 usec default slack */ \
182 .pids = { \ 181 .pids = { \
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h
index b2eee896dcbc..5037a0ad2312 100644
--- a/include/linux/iocontext.h
+++ b/include/linux/iocontext.h
@@ -5,6 +5,14 @@
5#include <linux/rcupdate.h> 5#include <linux/rcupdate.h>
6 6
7struct cfq_queue; 7struct cfq_queue;
8struct cfq_ttime {
9 unsigned long last_end_request;
10
11 unsigned long ttime_total;
12 unsigned long ttime_samples;
13 unsigned long ttime_mean;
14};
15
8struct cfq_io_context { 16struct cfq_io_context {
9 void *key; 17 void *key;
10 18
@@ -12,11 +20,7 @@ struct cfq_io_context {
12 20
13 struct io_context *ioc; 21 struct io_context *ioc;
14 22
15 unsigned long last_end_request; 23 struct cfq_ttime ttime;
16
17 unsigned long ttime_total;
18 unsigned long ttime_samples;
19 unsigned long ttime_mean;
20 24
21 struct list_head queue_list; 25 struct list_head queue_list;
22 struct hlist_node cic_list; 26 struct hlist_node cic_list;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 5a9926b34072..efd6f9800762 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -74,6 +74,16 @@
74 74
75#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __func__, ## args) 75#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __func__, ## args)
76 76
77#define ata_print_version_once(dev, version) \
78({ \
79 static bool __print_once; \
80 \
81 if (!__print_once) { \
82 __print_once = true; \
83 ata_print_version(dev, version); \
84 } \
85})
86
77/* NEW: debug levels */ 87/* NEW: debug levels */
78#define HAVE_LIBATA_MSG 1 88#define HAVE_LIBATA_MSG 1
79 89
@@ -1244,20 +1254,50 @@ static inline int sata_srst_pmp(struct ata_link *link)
1244/* 1254/*
1245 * printk helpers 1255 * printk helpers
1246 */ 1256 */
1247#define ata_port_printk(ap, lv, fmt, args...) \ 1257__attribute__((format (printf, 3, 4)))
1248 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1258int ata_port_printk(const struct ata_port *ap, const char *level,
1249 1259 const char *fmt, ...);
1250#define ata_link_printk(link, lv, fmt, args...) do { \ 1260__attribute__((format (printf, 3, 4)))
1251 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \ 1261int ata_link_printk(const struct ata_link *link, const char *level,
1252 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1262 const char *fmt, ...);
1253 (link)->pmp , ##args); \ 1263__attribute__((format (printf, 3, 4)))
1254 else \ 1264int ata_dev_printk(const struct ata_device *dev, const char *level,
1255 printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \ 1265 const char *fmt, ...);
1256 } while(0) 1266
1257 1267#define ata_port_err(ap, fmt, ...) \
1258#define ata_dev_printk(dev, lv, fmt, args...) \ 1268 ata_port_printk(ap, KERN_ERR, fmt, ##__VA_ARGS__)
1259 printk("%sata%u.%02u: "fmt, lv, (dev)->link->ap->print_id, \ 1269#define ata_port_warn(ap, fmt, ...) \
1260 (dev)->link->pmp + (dev)->devno , ##args) 1270 ata_port_printk(ap, KERN_WARNING, fmt, ##__VA_ARGS__)
1271#define ata_port_notice(ap, fmt, ...) \
1272 ata_port_printk(ap, KERN_NOTICE, fmt, ##__VA_ARGS__)
1273#define ata_port_info(ap, fmt, ...) \
1274 ata_port_printk(ap, KERN_INFO, fmt, ##__VA_ARGS__)
1275#define ata_port_dbg(ap, fmt, ...) \
1276 ata_port_printk(ap, KERN_DEBUG, fmt, ##__VA_ARGS__)
1277
1278#define ata_link_err(link, fmt, ...) \
1279 ata_link_printk(link, KERN_ERR, fmt, ##__VA_ARGS__)
1280#define ata_link_warn(link, fmt, ...) \
1281 ata_link_printk(link, KERN_WARNING, fmt, ##__VA_ARGS__)
1282#define ata_link_notice(link, fmt, ...) \
1283 ata_link_printk(link, KERN_NOTICE, fmt, ##__VA_ARGS__)
1284#define ata_link_info(link, fmt, ...) \
1285 ata_link_printk(link, KERN_INFO, fmt, ##__VA_ARGS__)
1286#define ata_link_dbg(link, fmt, ...) \
1287 ata_link_printk(link, KERN_DEBUG, fmt, ##__VA_ARGS__)
1288
1289#define ata_dev_err(dev, fmt, ...) \
1290 ata_dev_printk(dev, KERN_ERR, fmt, ##__VA_ARGS__)
1291#define ata_dev_warn(dev, fmt, ...) \
1292 ata_dev_printk(dev, KERN_WARNING, fmt, ##__VA_ARGS__)
1293#define ata_dev_notice(dev, fmt, ...) \
1294 ata_dev_printk(dev, KERN_NOTICE, fmt, ##__VA_ARGS__)
1295#define ata_dev_info(dev, fmt, ...) \
1296 ata_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__)
1297#define ata_dev_dbg(dev, fmt, ...) \
1298 ata_dev_printk(dev, KERN_DEBUG, fmt, ##__VA_ARGS__)
1299
1300void ata_print_version(const struct device *dev, const char *version);
1261 1301
1262/* 1302/*
1263 * ata_eh_info helpers 1303 * ata_eh_info helpers
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 8cb025a00094..e4da76c9e4d9 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -756,8 +756,12 @@ enum nl80211_commands {
756 * 756 *
757 * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with 757 * @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with
758 * a single scan request, a wiphy attribute. 758 * a single scan request, a wiphy attribute.
759 * @NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS: number of SSIDs you can
760 * scan with a single scheduled scan request, a wiphy attribute.
759 * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements 761 * @NL80211_ATTR_MAX_SCAN_IE_LEN: maximum length of information elements
760 * that can be added to a scan request 762 * that can be added to a scan request
763 * @NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN: maximum length of information
764 * elements that can be added to a scheduled scan request
761 * 765 *
762 * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz) 766 * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
763 * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive 767 * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
@@ -989,8 +993,8 @@ enum nl80211_commands {
989 * driving the peer link management state machine. 993 * driving the peer link management state machine.
990 * @NL80211_MESH_SETUP_USERSPACE_AMPE must be enabled. 994 * @NL80211_MESH_SETUP_USERSPACE_AMPE must be enabled.
991 * 995 *
992 * @NL80211_ATTR_WOWLAN_SUPPORTED: indicates, as part of the wiphy capabilities, 996 * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy
993 * the supported WoWLAN triggers 997 * capabilities, the supported WoWLAN triggers
994 * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to 998 * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
995 * indicate which WoW triggers should be enabled. This is also 999 * indicate which WoW triggers should be enabled. This is also
996 * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN 1000 * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
@@ -1010,6 +1014,11 @@ enum nl80211_commands {
1010 * @%NL80211_ATTR_REKEY_DATA: nested attribute containing the information 1014 * @%NL80211_ATTR_REKEY_DATA: nested attribute containing the information
1011 * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data. 1015 * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data.
1012 * 1016 *
1017 * @NL80211_ATTR_SCAN_SUPP_RATES: rates per to be advertised as supported in scan,
1018 * nested array attribute containing an entry for each band, with the entry
1019 * being a list of supported rates as defined by IEEE 802.11 7.3.2.2 but
1020 * without the length restriction (at most %NL80211_MAX_SUPP_RATES).
1021 *
1013 * @NL80211_ATTR_MAX: highest attribute number currently defined 1022 * @NL80211_ATTR_MAX: highest attribute number currently defined
1014 * @__NL80211_ATTR_AFTER_LAST: internal use 1023 * @__NL80211_ATTR_AFTER_LAST: internal use
1015 */ 1024 */
@@ -1210,6 +1219,11 @@ enum nl80211_attrs {
1210 1219
1211 NL80211_ATTR_REKEY_DATA, 1220 NL80211_ATTR_REKEY_DATA,
1212 1221
1222 NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
1223 NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
1224
1225 NL80211_ATTR_SCAN_SUPP_RATES,
1226
1213 /* add attributes here, update the policy in nl80211.c */ 1227 /* add attributes here, update the policy in nl80211.c */
1214 1228
1215 __NL80211_ATTR_AFTER_LAST, 1229 __NL80211_ATTR_AFTER_LAST,
@@ -2255,6 +2269,16 @@ struct nl80211_wowlan_pattern_support {
2255 * 2269 *
2256 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute 2270 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
2257 * carrying a &struct nl80211_wowlan_pattern_support. 2271 * carrying a &struct nl80211_wowlan_pattern_support.
2272 * @NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED: Not a real trigger, and cannot be
2273 * used when setting, used only to indicate that GTK rekeying is supported
2274 * by the device (flag)
2275 * @NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE: wake up on GTK rekey failure (if
2276 * done by the device) (flag)
2277 * @NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST: wake up on EAP Identity Request
2278 * packet (flag)
2279 * @NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE: wake up on 4-way handshake (flag)
2280 * @NL80211_WOWLAN_TRIG_RFKILL_RELEASE: wake up when rfkill is released
2281 * (on devices that have rfkill in the device) (flag)
2258 * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers 2282 * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
2259 * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number 2283 * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
2260 */ 2284 */
@@ -2264,6 +2288,11 @@ enum nl80211_wowlan_triggers {
2264 NL80211_WOWLAN_TRIG_DISCONNECT, 2288 NL80211_WOWLAN_TRIG_DISCONNECT,
2265 NL80211_WOWLAN_TRIG_MAGIC_PKT, 2289 NL80211_WOWLAN_TRIG_MAGIC_PKT,
2266 NL80211_WOWLAN_TRIG_PKT_PATTERN, 2290 NL80211_WOWLAN_TRIG_PKT_PATTERN,
2291 NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED,
2292 NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE,
2293 NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST,
2294 NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE,
2295 NL80211_WOWLAN_TRIG_RFKILL_RELEASE,
2267 2296
2268 /* keep last */ 2297 /* keep last */
2269 NUM_NL80211_WOWLAN_TRIG, 2298 NUM_NL80211_WOWLAN_TRIG,
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ed766add9b23..20b03bf94748 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1512,7 +1512,6 @@ struct task_struct {
1512 short il_next; 1512 short il_next;
1513 short pref_node_fork; 1513 short pref_node_fork;
1514#endif 1514#endif
1515 atomic_t fs_excl; /* holding fs exclusive resources */
1516 struct rcu_head rcu; 1515 struct rcu_head rcu;
1517 1516
1518 /* 1517 /*
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index b0928c10111b..8623217f84d0 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -27,6 +27,8 @@ struct ssb_sprom {
27 u8 et1mdcport; /* MDIO for enet1 */ 27 u8 et1mdcport; /* MDIO for enet1 */
28 u8 board_rev; /* Board revision number from SPROM. */ 28 u8 board_rev; /* Board revision number from SPROM. */
29 u8 country_code; /* Country Code */ 29 u8 country_code; /* Country Code */
30 u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */
31 u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
30 u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */ 32 u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
31 u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */ 33 u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
32 u16 pa0b0; 34 u16 pa0b0;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5390e3245a1a..d17f47fc9e31 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -777,6 +777,7 @@ struct cfg80211_ssid {
777 * @n_channels: total number of channels to scan 777 * @n_channels: total number of channels to scan
778 * @ie: optional information element(s) to add into Probe Request or %NULL 778 * @ie: optional information element(s) to add into Probe Request or %NULL
779 * @ie_len: length of ie in octets 779 * @ie_len: length of ie in octets
780 * @rates: bitmap of rates to advertise for each band
780 * @wiphy: the wiphy this was for 781 * @wiphy: the wiphy this was for
781 * @dev: the interface 782 * @dev: the interface
782 * @aborted: (internal) scan request was notified as aborted 783 * @aborted: (internal) scan request was notified as aborted
@@ -788,6 +789,8 @@ struct cfg80211_scan_request {
788 const u8 *ie; 789 const u8 *ie;
789 size_t ie_len; 790 size_t ie_len;
790 791
792 u32 rates[IEEE80211_NUM_BANDS];
793
791 /* internal */ 794 /* internal */
792 struct wiphy *wiphy; 795 struct wiphy *wiphy;
793 struct net_device *dev; 796 struct net_device *dev;
@@ -1146,9 +1149,15 @@ struct cfg80211_wowlan_trig_pkt_pattern {
1146 * @magic_pkt: wake up on receiving magic packet 1149 * @magic_pkt: wake up on receiving magic packet
1147 * @patterns: wake up on receiving packet matching a pattern 1150 * @patterns: wake up on receiving packet matching a pattern
1148 * @n_patterns: number of patterns 1151 * @n_patterns: number of patterns
1152 * @gtk_rekey_failure: wake up on GTK rekey failure
1153 * @eap_identity_req: wake up on EAP identity request packet
1154 * @four_way_handshake: wake up on 4-way handshake
1155 * @rfkill_release: wake up when rfkill is released
1149 */ 1156 */
1150struct cfg80211_wowlan { 1157struct cfg80211_wowlan {
1151 bool any, disconnect, magic_pkt; 1158 bool any, disconnect, magic_pkt, gtk_rekey_failure,
1159 eap_identity_req, four_way_handshake,
1160 rfkill_release;
1152 struct cfg80211_wowlan_trig_pkt_pattern *patterns; 1161 struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1153 int n_patterns; 1162 int n_patterns;
1154}; 1163};
@@ -1673,11 +1682,21 @@ struct ieee80211_txrx_stypes {
1673 * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet 1682 * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
1674 * (see nl80211.h) 1683 * (see nl80211.h)
1675 * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect 1684 * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
1685 * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
1686 * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
1687 * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
1688 * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
1689 * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
1676 */ 1690 */
1677enum wiphy_wowlan_support_flags { 1691enum wiphy_wowlan_support_flags {
1678 WIPHY_WOWLAN_ANY = BIT(0), 1692 WIPHY_WOWLAN_ANY = BIT(0),
1679 WIPHY_WOWLAN_MAGIC_PKT = BIT(1), 1693 WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
1680 WIPHY_WOWLAN_DISCONNECT = BIT(2), 1694 WIPHY_WOWLAN_DISCONNECT = BIT(2),
1695 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
1696 WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
1697 WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
1698 WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
1699 WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
1681}; 1700};
1682 1701
1683/** 1702/**
@@ -1742,9 +1761,13 @@ struct wiphy_wowlan_support {
1742 * this variable determines its size 1761 * this variable determines its size
1743 * @max_scan_ssids: maximum number of SSIDs the device can scan for in 1762 * @max_scan_ssids: maximum number of SSIDs the device can scan for in
1744 * any given scan 1763 * any given scan
1764 * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
1765 * for in any given scheduled scan
1745 * @max_scan_ie_len: maximum length of user-controlled IEs device can 1766 * @max_scan_ie_len: maximum length of user-controlled IEs device can
1746 * add to probe request frames transmitted during a scan, must not 1767 * add to probe request frames transmitted during a scan, must not
1747 * include fixed IEs like supported rates 1768 * include fixed IEs like supported rates
1769 * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
1770 * scans
1748 * @coverage_class: current coverage class 1771 * @coverage_class: current coverage class
1749 * @fw_version: firmware version for ethtool reporting 1772 * @fw_version: firmware version for ethtool reporting
1750 * @hw_version: hardware version for ethtool reporting 1773 * @hw_version: hardware version for ethtool reporting
@@ -1796,7 +1819,9 @@ struct wiphy {
1796 1819
1797 int bss_priv_size; 1820 int bss_priv_size;
1798 u8 max_scan_ssids; 1821 u8 max_scan_ssids;
1822 u8 max_sched_scan_ssids;
1799 u16 max_scan_ie_len; 1823 u16 max_scan_ie_len;
1824 u16 max_sched_scan_ie_len;
1800 1825
1801 int n_cipher_suites; 1826 int n_cipher_suites;
1802 const u32 *cipher_suites; 1827 const u32 *cipher_suites;
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ea2c8c36477c..9259e97864d7 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1586,6 +1586,20 @@ enum ieee80211_ampdu_mlme_action {
1586}; 1586};
1587 1587
1588/** 1588/**
1589 * enum ieee80211_tx_sync_type - TX sync type
1590 * @IEEE80211_TX_SYNC_AUTH: sync TX for authentication
1591 * (and possibly also before direct probe)
1592 * @IEEE80211_TX_SYNC_ASSOC: sync TX for association
1593 * @IEEE80211_TX_SYNC_ACTION: sync TX for action frame
1594 * (not implemented yet)
1595 */
1596enum ieee80211_tx_sync_type {
1597 IEEE80211_TX_SYNC_AUTH,
1598 IEEE80211_TX_SYNC_ASSOC,
1599 IEEE80211_TX_SYNC_ACTION,
1600};
1601
1602/**
1589 * struct ieee80211_ops - callbacks from mac80211 to the driver 1603 * struct ieee80211_ops - callbacks from mac80211 to the driver
1590 * 1604 *
1591 * This structure contains various callbacks that the driver may 1605 * This structure contains various callbacks that the driver may
@@ -1674,6 +1688,26 @@ enum ieee80211_ampdu_mlme_action {
1674 * of the bss parameters has changed when a call is made. The callback 1688 * of the bss parameters has changed when a call is made. The callback
1675 * can sleep. 1689 * can sleep.
1676 * 1690 *
1691 * @tx_sync: Called before a frame is sent to an AP/GO. In the GO case, the
1692 * driver should sync with the GO's powersaving so the device doesn't
1693 * transmit the frame while the GO is asleep. In the regular AP case
1694 * it may be used by drivers for devices implementing other restrictions
1695 * on talking to APs, e.g. due to regulatory enforcement or just HW
1696 * restrictions.
1697 * This function is called for every authentication, association and
1698 * action frame separately since applications might attempt to auth
1699 * with multiple APs before chosing one to associate to. If it returns
1700 * an error, the corresponding authentication, association or frame
1701 * transmission is aborted and reported as having failed. It is always
1702 * called after tuning to the correct channel.
1703 * The callback might be called multiple times before @finish_tx_sync
1704 * (but @finish_tx_sync will be called once for each) but in practice
1705 * this is unlikely to happen. It can also refuse in that case if the
1706 * driver cannot handle that situation.
1707 * This callback can sleep.
1708 * @finish_tx_sync: Called as a counterpart to @tx_sync, unless that returned
1709 * an error. This callback can sleep.
1710 *
1677 * @prepare_multicast: Prepare for multicast filter configuration. 1711 * @prepare_multicast: Prepare for multicast filter configuration.
1678 * This callback is optional, and its return value is passed 1712 * This callback is optional, and its return value is passed
1679 * to configure_filter(). This callback must be atomic. 1713 * to configure_filter(). This callback must be atomic.
@@ -1901,6 +1935,14 @@ struct ieee80211_ops {
1901 struct ieee80211_vif *vif, 1935 struct ieee80211_vif *vif,
1902 struct ieee80211_bss_conf *info, 1936 struct ieee80211_bss_conf *info,
1903 u32 changed); 1937 u32 changed);
1938
1939 int (*tx_sync)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1940 const u8 *bssid, enum ieee80211_tx_sync_type type);
1941 void (*finish_tx_sync)(struct ieee80211_hw *hw,
1942 struct ieee80211_vif *vif,
1943 const u8 *bssid,
1944 enum ieee80211_tx_sync_type type);
1945
1904 u64 (*prepare_multicast)(struct ieee80211_hw *hw, 1946 u64 (*prepare_multicast)(struct ieee80211_hw *hw,
1905 struct netdev_hw_addr_list *mc_list); 1947 struct netdev_hw_addr_list *mc_list);
1906 void (*configure_filter)(struct ieee80211_hw *hw, 1948 void (*configure_filter)(struct ieee80211_hw *hw,
@@ -2613,6 +2655,20 @@ static inline void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
2613} 2655}
2614 2656
2615/** 2657/**
2658 * ieee80211_get_tkip_rx_p1k - get a TKIP phase 1 key for RX
2659 *
2660 * This function returns the TKIP phase 1 key for the given IV32
2661 * and transmitter address.
2662 *
2663 * @keyconf: the parameter passed with the set key
2664 * @ta: TA that will be used with the key
2665 * @iv32: IV32 to get the P1K for
2666 * @p1k: a buffer to which the key will be written, as 5 u16 values
2667 */
2668void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
2669 const u8 *ta, u32 iv32, u16 *p1k);
2670
2671/**
2616 * ieee80211_get_tkip_p2k - get a TKIP phase 2 key 2672 * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
2617 * 2673 *
2618 * This function computes the TKIP RC4 key for the IV values 2674 * This function computes the TKIP RC4 key for the IV values
@@ -2973,6 +3029,10 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
2973 * needs reprogramming of the keys during suspend. Note that due 3029 * needs reprogramming of the keys during suspend. Note that due
2974 * to locking reasons, it is also only safe to call this at few 3030 * to locking reasons, it is also only safe to call this at few
2975 * spots since it must hold the RTNL and be able to sleep. 3031 * spots since it must hold the RTNL and be able to sleep.
3032 *
3033 * The order in which the keys are iterated matches the order
3034 * in which they were originally installed and handed to the
3035 * set_key callback.
2976 */ 3036 */
2977void ieee80211_iter_keys(struct ieee80211_hw *hw, 3037void ieee80211_iter_keys(struct ieee80211_hw *hw,
2978 struct ieee80211_vif *vif, 3038 struct ieee80211_vif *vif,
diff --git a/kernel/exit.c b/kernel/exit.c
index 73bb192a3d32..12ea415c6435 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -898,7 +898,6 @@ NORET_TYPE void do_exit(long code)
898 898
899 profile_task_exit(tsk); 899 profile_task_exit(tsk);
900 900
901 WARN_ON(atomic_read(&tsk->fs_excl));
902 WARN_ON(blk_needs_flush_plug(tsk)); 901 WARN_ON(blk_needs_flush_plug(tsk));
903 902
904 if (unlikely(in_interrupt())) 903 if (unlikely(in_interrupt()))
diff --git a/kernel/fork.c b/kernel/fork.c
index aeae5b11b62e..17bf7c8d6511 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -290,7 +290,6 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
290 290
291 /* One for us, one for whoever does the "release_task()" (usually parent) */ 291 /* One for us, one for whoever does the "release_task()" (usually parent) */
292 atomic_set(&tsk->usage,2); 292 atomic_set(&tsk->usage,2);
293 atomic_set(&tsk->fs_excl, 0);
294#ifdef CONFIG_BLK_DEV_IO_TRACE 293#ifdef CONFIG_BLK_DEV_IO_TRACE
295 tsk->btrace_seq = 0; 294 tsk->btrace_seq = 0;
296#endif 295#endif
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index f032e6e1e09a..2ef0dc9e7f39 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -505,7 +505,7 @@ static void bdi_remove_from_list(struct backing_dev_info *bdi)
505 list_del_rcu(&bdi->bdi_list); 505 list_del_rcu(&bdi->bdi_list);
506 spin_unlock_bh(&bdi_lock); 506 spin_unlock_bh(&bdi_lock);
507 507
508 synchronize_rcu(); 508 synchronize_rcu_expedited();
509} 509}
510 510
511int bdi_register(struct backing_dev_info *bdi, struct device *parent, 511int bdi_register(struct backing_dev_info *bdi, struct device *parent,
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 1bacca4cb676..3176e2e13d9b 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -388,7 +388,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
388 br_ifinfo_notify(RTM_NEWLINK, p); 388 br_ifinfo_notify(RTM_NEWLINK, p);
389 389
390 if (changed_addr) 390 if (changed_addr)
391 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); 391 call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);
392 392
393 dev_set_mtu(br->dev, br_min_mtu(br)); 393 dev_set_mtu(br->dev, br_min_mtu(br));
394 394
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 6814083a92f4..5b1ed1ba9aa7 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -188,6 +188,8 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
188 188
189 p->state = new_state; 189 p->state = new_state;
190 br_log_state(p); 190 br_log_state(p);
191 br_ifinfo_notify(RTM_NEWLINK, p);
192
191 return 0; 193 return 0;
192} 194}
193 195
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 54578f274d85..78cc364997d9 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -124,6 +124,7 @@ struct net_bridge_port
124 bridge_id designated_bridge; 124 bridge_id designated_bridge;
125 u32 path_cost; 125 u32 path_cost;
126 u32 designated_cost; 126 u32 designated_cost;
127 unsigned long designated_age;
127 128
128 struct timer_list forward_delay_timer; 129 struct timer_list forward_delay_timer;
129 struct timer_list hold_timer; 130 struct timer_list hold_timer;
diff --git a/net/bridge/br_private_stp.h b/net/bridge/br_private_stp.h
index 642ef47a867e..05ed9bc7e426 100644
--- a/net/bridge/br_private_stp.h
+++ b/net/bridge/br_private_stp.h
@@ -56,7 +56,8 @@ extern void br_become_root_bridge(struct net_bridge *br);
56extern void br_config_bpdu_generation(struct net_bridge *); 56extern void br_config_bpdu_generation(struct net_bridge *);
57extern void br_configuration_update(struct net_bridge *); 57extern void br_configuration_update(struct net_bridge *);
58extern void br_port_state_selection(struct net_bridge *); 58extern void br_port_state_selection(struct net_bridge *);
59extern void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu); 59extern void br_received_config_bpdu(struct net_bridge_port *p,
60 const struct br_config_bpdu *bpdu);
60extern void br_received_tcn_bpdu(struct net_bridge_port *p); 61extern void br_received_tcn_bpdu(struct net_bridge_port *p);
61extern void br_transmit_config(struct net_bridge_port *p); 62extern void br_transmit_config(struct net_bridge_port *p);
62extern void br_transmit_tcn(struct net_bridge *br); 63extern void br_transmit_tcn(struct net_bridge *br);
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
index bb4383e84de9..ad0a3f7cf6cc 100644
--- a/net/bridge/br_stp.c
+++ b/net/bridge/br_stp.c
@@ -109,7 +109,6 @@ static void br_root_selection(struct net_bridge *br)
109 list_for_each_entry(p, &br->port_list, list) { 109 list_for_each_entry(p, &br->port_list, list) {
110 if (br_should_become_root_port(p, root_port)) 110 if (br_should_become_root_port(p, root_port))
111 root_port = p->port_no; 111 root_port = p->port_no;
112
113 } 112 }
114 113
115 br->root_port = root_port; 114 br->root_port = root_port;
@@ -145,7 +144,6 @@ void br_transmit_config(struct net_bridge_port *p)
145 struct br_config_bpdu bpdu; 144 struct br_config_bpdu bpdu;
146 struct net_bridge *br; 145 struct net_bridge *br;
147 146
148
149 if (timer_pending(&p->hold_timer)) { 147 if (timer_pending(&p->hold_timer)) {
150 p->config_pending = 1; 148 p->config_pending = 1;
151 return; 149 return;
@@ -164,8 +162,7 @@ void br_transmit_config(struct net_bridge_port *p)
164 else { 162 else {
165 struct net_bridge_port *root 163 struct net_bridge_port *root
166 = br_get_port(br, br->root_port); 164 = br_get_port(br, br->root_port);
167 bpdu.message_age = br->max_age 165 bpdu.message_age = (jiffies - root->designated_age)
168 - (root->message_age_timer.expires - jiffies)
169 + MESSAGE_AGE_INCR; 166 + MESSAGE_AGE_INCR;
170 } 167 }
171 bpdu.max_age = br->max_age; 168 bpdu.max_age = br->max_age;
@@ -182,20 +179,21 @@ void br_transmit_config(struct net_bridge_port *p)
182} 179}
183 180
184/* called under bridge lock */ 181/* called under bridge lock */
185static inline void br_record_config_information(struct net_bridge_port *p, 182static void br_record_config_information(struct net_bridge_port *p,
186 const struct br_config_bpdu *bpdu) 183 const struct br_config_bpdu *bpdu)
187{ 184{
188 p->designated_root = bpdu->root; 185 p->designated_root = bpdu->root;
189 p->designated_cost = bpdu->root_path_cost; 186 p->designated_cost = bpdu->root_path_cost;
190 p->designated_bridge = bpdu->bridge_id; 187 p->designated_bridge = bpdu->bridge_id;
191 p->designated_port = bpdu->port_id; 188 p->designated_port = bpdu->port_id;
189 p->designated_age = jiffies + bpdu->message_age;
192 190
193 mod_timer(&p->message_age_timer, jiffies 191 mod_timer(&p->message_age_timer, jiffies
194 + (p->br->max_age - bpdu->message_age)); 192 + (p->br->max_age - bpdu->message_age));
195} 193}
196 194
197/* called under bridge lock */ 195/* called under bridge lock */
198static inline void br_record_config_timeout_values(struct net_bridge *br, 196static void br_record_config_timeout_values(struct net_bridge *br,
199 const struct br_config_bpdu *bpdu) 197 const struct br_config_bpdu *bpdu)
200{ 198{
201 br->max_age = bpdu->max_age; 199 br->max_age = bpdu->max_age;
@@ -254,7 +252,8 @@ static void br_designated_port_selection(struct net_bridge *br)
254} 252}
255 253
256/* called under bridge lock */ 254/* called under bridge lock */
257static int br_supersedes_port_info(struct net_bridge_port *p, struct br_config_bpdu *bpdu) 255static int br_supersedes_port_info(const struct net_bridge_port *p,
256 const struct br_config_bpdu *bpdu)
258{ 257{
259 int t; 258 int t;
260 259
@@ -285,7 +284,7 @@ static int br_supersedes_port_info(struct net_bridge_port *p, struct br_config_b
285} 284}
286 285
287/* called under bridge lock */ 286/* called under bridge lock */
288static inline void br_topology_change_acknowledged(struct net_bridge *br) 287static void br_topology_change_acknowledged(struct net_bridge *br)
289{ 288{
290 br->topology_change_detected = 0; 289 br->topology_change_detected = 0;
291 del_timer(&br->tcn_timer); 290 del_timer(&br->tcn_timer);
@@ -327,7 +326,7 @@ void br_config_bpdu_generation(struct net_bridge *br)
327} 326}
328 327
329/* called under bridge lock */ 328/* called under bridge lock */
330static inline void br_reply(struct net_bridge_port *p) 329static void br_reply(struct net_bridge_port *p)
331{ 330{
332 br_transmit_config(p); 331 br_transmit_config(p);
333} 332}
@@ -363,6 +362,8 @@ static void br_make_blocking(struct net_bridge_port *p)
363 362
364 p->state = BR_STATE_BLOCKING; 363 p->state = BR_STATE_BLOCKING;
365 br_log_state(p); 364 br_log_state(p);
365 br_ifinfo_notify(RTM_NEWLINK, p);
366
366 del_timer(&p->forward_delay_timer); 367 del_timer(&p->forward_delay_timer);
367 } 368 }
368} 369}
@@ -379,15 +380,14 @@ static void br_make_forwarding(struct net_bridge_port *p)
379 p->state = BR_STATE_FORWARDING; 380 p->state = BR_STATE_FORWARDING;
380 br_topology_change_detection(br); 381 br_topology_change_detection(br);
381 del_timer(&p->forward_delay_timer); 382 del_timer(&p->forward_delay_timer);
382 } 383 } else if (br->stp_enabled == BR_KERNEL_STP)
383 else if (br->stp_enabled == BR_KERNEL_STP)
384 p->state = BR_STATE_LISTENING; 384 p->state = BR_STATE_LISTENING;
385 else 385 else
386 p->state = BR_STATE_LEARNING; 386 p->state = BR_STATE_LEARNING;
387 387
388 br_multicast_enable_port(p); 388 br_multicast_enable_port(p);
389
390 br_log_state(p); 389 br_log_state(p);
390 br_ifinfo_notify(RTM_NEWLINK, p);
391 391
392 if (br->forward_delay != 0) 392 if (br->forward_delay != 0)
393 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); 393 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay);
@@ -431,14 +431,15 @@ void br_port_state_selection(struct net_bridge *br)
431} 431}
432 432
433/* called under bridge lock */ 433/* called under bridge lock */
434static inline void br_topology_change_acknowledge(struct net_bridge_port *p) 434static void br_topology_change_acknowledge(struct net_bridge_port *p)
435{ 435{
436 p->topology_change_ack = 1; 436 p->topology_change_ack = 1;
437 br_transmit_config(p); 437 br_transmit_config(p);
438} 438}
439 439
440/* called under bridge lock */ 440/* called under bridge lock */
441void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *bpdu) 441void br_received_config_bpdu(struct net_bridge_port *p,
442 const struct br_config_bpdu *bpdu)
442{ 443{
443 struct net_bridge *br; 444 struct net_bridge *br;
444 int was_root; 445 int was_root;
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 289646ec9b7b..e16aade51ae0 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -210,10 +210,19 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
210 bpdu.hello_time = br_get_ticks(buf+28); 210 bpdu.hello_time = br_get_ticks(buf+28);
211 bpdu.forward_delay = br_get_ticks(buf+30); 211 bpdu.forward_delay = br_get_ticks(buf+30);
212 212
213 br_received_config_bpdu(p, &bpdu); 213 if (bpdu.message_age > bpdu.max_age) {
214 } 214 if (net_ratelimit())
215 br_notice(p->br,
216 "port %u config from %pM"
217 " (message_age %ul > max_age %ul)\n",
218 p->port_no,
219 eth_hdr(skb)->h_source,
220 bpdu.message_age, bpdu.max_age);
221 goto out;
222 }
215 223
216 else if (buf[0] == BPDU_TYPE_TCN) { 224 br_received_config_bpdu(p, &bpdu);
225 } else if (buf[0] == BPDU_TYPE_TCN) {
217 br_received_tcn_bpdu(p); 226 br_received_tcn_bpdu(p);
218 } 227 }
219 out: 228 out:
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 6f615b8192f4..10eda3cd1d71 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -88,6 +88,7 @@ void br_stp_enable_port(struct net_bridge_port *p)
88 br_init_port(p); 88 br_init_port(p);
89 br_port_state_selection(p->br); 89 br_port_state_selection(p->br);
90 br_log_state(p); 90 br_log_state(p);
91 br_ifinfo_notify(RTM_NEWLINK, p);
91} 92}
92 93
93/* called under bridge lock */ 94/* called under bridge lock */
@@ -104,6 +105,8 @@ void br_stp_disable_port(struct net_bridge_port *p)
104 p->topology_change_ack = 0; 105 p->topology_change_ack = 0;
105 p->config_pending = 0; 106 p->config_pending = 0;
106 107
108 br_ifinfo_notify(RTM_NEWLINK, p);
109
107 del_timer(&p->message_age_timer); 110 del_timer(&p->message_age_timer);
108 del_timer(&p->forward_delay_timer); 111 del_timer(&p->forward_delay_timer);
109 del_timer(&p->hold_timer); 112 del_timer(&p->hold_timer);
diff --git a/net/bridge/br_stp_timer.c b/net/bridge/br_stp_timer.c
index 3e965140051e..58de2a0f9975 100644
--- a/net/bridge/br_stp_timer.c
+++ b/net/bridge/br_stp_timer.c
@@ -97,6 +97,7 @@ static void br_forward_delay_timer_expired(unsigned long arg)
97 netif_carrier_on(br->dev); 97 netif_carrier_on(br->dev);
98 } 98 }
99 br_log_state(p); 99 br_log_state(p);
100 br_ifinfo_notify(RTM_NEWLINK, p);
100 spin_unlock(&br->lock); 101 spin_unlock(&br->lock);
101} 102}
102 103
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index a7b342131869..357bd4ee4baa 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -126,7 +126,7 @@ static void linkwatch_schedule_work(int urgent)
126 return; 126 return;
127 127
128 /* It's already running which is good enough. */ 128 /* It's already running which is good enough. */
129 if (!cancel_delayed_work(&linkwatch_work)) 129 if (!__cancel_delayed_work(&linkwatch_work))
130 return; 130 return;
131 131
132 /* Otherwise we reschedule it again for immediate execution. */ 132 /* Otherwise we reschedule it again for immediate execution. */
diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
index 9dbe10875fbd..dbfc21de3479 100644
--- a/net/ipv4/gre.c
+++ b/net/ipv4/gre.c
@@ -15,6 +15,7 @@
15#include <linux/kmod.h> 15#include <linux/kmod.h>
16#include <linux/skbuff.h> 16#include <linux/skbuff.h>
17#include <linux/in.h> 17#include <linux/in.h>
18#include <linux/ip.h>
18#include <linux/netdevice.h> 19#include <linux/netdevice.h>
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20#include <net/protocol.h> 21#include <net/protocol.h>
@@ -96,27 +97,17 @@ drop:
96static void gre_err(struct sk_buff *skb, u32 info) 97static void gre_err(struct sk_buff *skb, u32 info)
97{ 98{
98 const struct gre_protocol *proto; 99 const struct gre_protocol *proto;
99 u8 ver; 100 const struct iphdr *iph = (const struct iphdr *)skb->data;
100 101 u8 ver = skb->data[(iph->ihl<<2) + 1]&0x7f;
101 if (!pskb_may_pull(skb, 12))
102 goto drop;
103 102
104 ver = skb->data[1]&0x7f;
105 if (ver >= GREPROTO_MAX) 103 if (ver >= GREPROTO_MAX)
106 goto drop; 104 return;
107 105
108 rcu_read_lock(); 106 rcu_read_lock();
109 proto = rcu_dereference(gre_proto[ver]); 107 proto = rcu_dereference(gre_proto[ver]);
110 if (!proto || !proto->err_handler) 108 if (proto && proto->err_handler)
111 goto drop_unlock; 109 proto->err_handler(skb, info);
112 proto->err_handler(skb, info);
113 rcu_read_unlock();
114 return;
115
116drop_unlock:
117 rcu_read_unlock(); 110 rcu_read_unlock();
118drop:
119 kfree_skb(skb);
120} 111}
121 112
122static const struct net_protocol net_gre_protocol = { 113static const struct net_protocol net_gre_protocol = {
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index aae2bd8cd924..58e879157976 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1796,7 +1796,7 @@ static struct mr_table *ipmr_rt_fib_lookup(struct net *net, struct sk_buff *skb)
1796 struct flowi4 fl4 = { 1796 struct flowi4 fl4 = {
1797 .daddr = iph->daddr, 1797 .daddr = iph->daddr,
1798 .saddr = iph->saddr, 1798 .saddr = iph->saddr,
1799 .flowi4_tos = iph->tos, 1799 .flowi4_tos = RT_TOS(iph->tos),
1800 .flowi4_oif = rt->rt_oif, 1800 .flowi4_oif = rt->rt_oif,
1801 .flowi4_iif = rt->rt_iif, 1801 .flowi4_iif = rt->rt_iif,
1802 .flowi4_mark = rt->rt_mark, 1802 .flowi4_mark = rt->rt_mark,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 33137307d52a..1730689f560e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1740,7 +1740,7 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt)
1740 memset(&fl4, 0, sizeof(fl4)); 1740 memset(&fl4, 0, sizeof(fl4));
1741 fl4.daddr = iph->daddr; 1741 fl4.daddr = iph->daddr;
1742 fl4.saddr = iph->saddr; 1742 fl4.saddr = iph->saddr;
1743 fl4.flowi4_tos = iph->tos; 1743 fl4.flowi4_tos = RT_TOS(iph->tos);
1744 fl4.flowi4_oif = rt->dst.dev->ifindex; 1744 fl4.flowi4_oif = rt->dst.dev->ifindex;
1745 fl4.flowi4_iif = skb->dev->ifindex; 1745 fl4.flowi4_iif = skb->dev->ifindex;
1746 fl4.flowi4_mark = skb->mark; 1746 fl4.flowi4_mark = skb->mark;
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c
index ebadb9ac9a7e..fd1aaf2a4a6c 100644
--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -104,14 +104,22 @@ void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap,
104 const u8 *addr) 104 const u8 *addr)
105{ 105{
106 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 106 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
107 struct sta_info *sta = sta_info_get(sdata, addr); 107 struct sta_info *sta;
108 int i; 108 int i;
109 109
110 rcu_read_lock();
111 sta = sta_info_get(sdata, addr);
112 if (!sta) {
113 rcu_read_unlock();
114 return;
115 }
116
110 for (i = 0; i < STA_TID_NUM; i++) 117 for (i = 0; i < STA_TID_NUM; i++)
111 if (ba_rx_bitmap & BIT(i)) 118 if (ba_rx_bitmap & BIT(i))
112 set_bit(i, sta->ampdu_mlme.tid_rx_stop_requested); 119 set_bit(i, sta->ampdu_mlme.tid_rx_stop_requested);
113 120
114 ieee80211_queue_work(&sta->local->hw, &sta->ampdu_mlme.work); 121 ieee80211_queue_work(&sta->local->hw, &sta->ampdu_mlme.work);
122 rcu_read_unlock();
115} 123}
116EXPORT_SYMBOL(ieee80211_stop_rx_ba_session); 124EXPORT_SYMBOL(ieee80211_stop_rx_ba_session);
117 125
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index bfc36e904764..3d1b091d9b2e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1255,6 +1255,10 @@ static int ieee80211_set_txq_params(struct wiphy *wiphy,
1255 */ 1255 */
1256 p.uapsd = false; 1256 p.uapsd = false;
1257 1257
1258 if (params->queue >= local->hw.queues)
1259 return -EINVAL;
1260
1261 local->tx_conf[params->queue] = p;
1258 if (drv_conf_tx(local, params->queue, &p)) { 1262 if (drv_conf_tx(local, params->queue, &p)) {
1259 wiphy_debug(local->hw.wiphy, 1263 wiphy_debug(local->hw.wiphy,
1260 "failed to set TX queue parameters for queue %d\n", 1264 "failed to set TX queue parameters for queue %d\n",
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index b2d6bba44054..1425380983f7 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -130,6 +130,37 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
130 trace_drv_return_void(local); 130 trace_drv_return_void(local);
131} 131}
132 132
133static inline int drv_tx_sync(struct ieee80211_local *local,
134 struct ieee80211_sub_if_data *sdata,
135 const u8 *bssid,
136 enum ieee80211_tx_sync_type type)
137{
138 int ret = 0;
139
140 might_sleep();
141
142 trace_drv_tx_sync(local, sdata, bssid, type);
143 if (local->ops->tx_sync)
144 ret = local->ops->tx_sync(&local->hw, &sdata->vif,
145 bssid, type);
146 trace_drv_return_int(local, ret);
147 return ret;
148}
149
150static inline void drv_finish_tx_sync(struct ieee80211_local *local,
151 struct ieee80211_sub_if_data *sdata,
152 const u8 *bssid,
153 enum ieee80211_tx_sync_type type)
154{
155 might_sleep();
156
157 trace_drv_finish_tx_sync(local, sdata, bssid, type);
158 if (local->ops->finish_tx_sync)
159 local->ops->finish_tx_sync(&local->hw, &sdata->vif,
160 bssid, type);
161 trace_drv_return_void(local);
162}
163
133static inline u64 drv_prepare_multicast(struct ieee80211_local *local, 164static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
134 struct netdev_hw_addr_list *mc_list) 165 struct netdev_hw_addr_list *mc_list)
135{ 166{
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h
index 4470f6e8b845..f47b00dc7afd 100644
--- a/net/mac80211/driver-trace.h
+++ b/net/mac80211/driver-trace.h
@@ -319,6 +319,49 @@ TRACE_EVENT(drv_bss_info_changed,
319 ) 319 )
320); 320);
321 321
322DECLARE_EVENT_CLASS(tx_sync_evt,
323 TP_PROTO(struct ieee80211_local *local,
324 struct ieee80211_sub_if_data *sdata,
325 const u8 *bssid,
326 enum ieee80211_tx_sync_type type),
327 TP_ARGS(local, sdata, bssid, type),
328
329 TP_STRUCT__entry(
330 LOCAL_ENTRY
331 VIF_ENTRY
332 __array(char, bssid, ETH_ALEN)
333 __field(u32, sync_type)
334 ),
335
336 TP_fast_assign(
337 LOCAL_ASSIGN;
338 VIF_ASSIGN;
339 memcpy(__entry->bssid, bssid, ETH_ALEN);
340 __entry->sync_type = type;
341 ),
342
343 TP_printk(
344 LOCAL_PR_FMT VIF_PR_FMT " bssid:%pM type:%d",
345 LOCAL_PR_ARG, VIF_PR_ARG, __entry->bssid, __entry->sync_type
346 )
347);
348
349DEFINE_EVENT(tx_sync_evt, drv_tx_sync,
350 TP_PROTO(struct ieee80211_local *local,
351 struct ieee80211_sub_if_data *sdata,
352 const u8 *bssid,
353 enum ieee80211_tx_sync_type type),
354 TP_ARGS(local, sdata, bssid, type)
355);
356
357DEFINE_EVENT(tx_sync_evt, drv_finish_tx_sync,
358 TP_PROTO(struct ieee80211_local *local,
359 struct ieee80211_sub_if_data *sdata,
360 const u8 *bssid,
361 enum ieee80211_tx_sync_type type),
362 TP_ARGS(local, sdata, bssid, type)
363);
364
322TRACE_EVENT(drv_prepare_multicast, 365TRACE_EVENT(drv_prepare_multicast,
323 TP_PROTO(struct ieee80211_local *local, int mc_count), 366 TP_PROTO(struct ieee80211_local *local, int mc_count),
324 367
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index dda0d1ab34f3..400c09bea639 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -323,6 +323,7 @@ struct ieee80211_work {
323 u8 key[WLAN_KEY_LEN_WEP104]; 323 u8 key[WLAN_KEY_LEN_WEP104];
324 u8 key_len, key_idx; 324 u8 key_len, key_idx;
325 bool privacy; 325 bool privacy;
326 bool synced;
326 } probe_auth; 327 } probe_auth;
327 struct { 328 struct {
328 struct cfg80211_bss *bss; 329 struct cfg80211_bss *bss;
@@ -336,6 +337,7 @@ struct ieee80211_work {
336 u8 ssid_len; 337 u8 ssid_len;
337 u8 supp_rates_len; 338 u8 supp_rates_len;
338 bool wmm_used, use_11n, uapsd_used; 339 bool wmm_used, use_11n, uapsd_used;
340 bool synced;
339 } assoc; 341 } assoc;
340 struct { 342 struct {
341 u32 duration; 343 u32 duration;
@@ -746,6 +748,7 @@ struct ieee80211_local {
746 struct workqueue_struct *workqueue; 748 struct workqueue_struct *workqueue;
747 749
748 unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES]; 750 unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
751 struct ieee80211_tx_queue_params tx_conf[IEEE80211_MAX_QUEUES];
749 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ 752 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
750 spinlock_t queue_stop_reason_lock; 753 spinlock_t queue_stop_reason_lock;
751 754
@@ -1376,14 +1379,14 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1376 enum ieee80211_band band, u32 rate_mask, 1379 enum ieee80211_band band, u32 rate_mask,
1377 u8 channel); 1380 u8 channel);
1378struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 1381struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1379 u8 *dst, 1382 u8 *dst, u32 ratemask,
1380 const u8 *ssid, size_t ssid_len, 1383 const u8 *ssid, size_t ssid_len,
1381 const u8 *ie, size_t ie_len, 1384 const u8 *ie, size_t ie_len,
1382 bool directed); 1385 bool directed);
1383void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 1386void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1384 const u8 *ssid, size_t ssid_len, 1387 const u8 *ssid, size_t ssid_len,
1385 const u8 *ie, size_t ie_len, 1388 const u8 *ie, size_t ie_len,
1386 bool directed); 1389 u32 ratemask, bool directed);
1387 1390
1388void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 1391void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
1389 const size_t supp_rates_len, 1392 const size_t supp_rates_len,
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 739bee13e813..5150c6d11b57 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -278,7 +278,7 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
278 bool defunikey, defmultikey, defmgmtkey; 278 bool defunikey, defmultikey, defmgmtkey;
279 279
280 if (new) 280 if (new)
281 list_add(&new->list, &sdata->key_list); 281 list_add_tail(&new->list, &sdata->key_list);
282 282
283 if (sta && pairwise) { 283 if (sta && pairwise) {
284 rcu_assign_pointer(sta->ptk, new); 284 rcu_assign_pointer(sta->ptk, new);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index c99237cd4b98..d6470c7fd6ce 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -917,6 +917,7 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
917 params.aifs, params.cw_min, params.cw_max, 917 params.aifs, params.cw_min, params.cw_max,
918 params.txop, params.uapsd); 918 params.txop, params.uapsd);
919#endif 919#endif
920 local->tx_conf[queue] = params;
920 if (drv_conf_tx(local, queue, &params)) 921 if (drv_conf_tx(local, queue, &params))
921 wiphy_debug(local->hw.wiphy, 922 wiphy_debug(local->hw.wiphy,
922 "failed to set TX queue parameters for queue %d\n", 923 "failed to set TX queue parameters for queue %d\n",
@@ -1219,7 +1220,7 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
1219 } else { 1220 } else {
1220 ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); 1221 ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
1221 ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0, 1222 ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0,
1222 true); 1223 (u32) -1, true);
1223 } 1224 }
1224 1225
1225 ifmgd->probe_send_count++; 1226 ifmgd->probe_send_count++;
@@ -1304,7 +1305,8 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
1304 1305
1305 ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); 1306 ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
1306 skb = ieee80211_build_probe_req(sdata, ifmgd->associated->bssid, 1307 skb = ieee80211_build_probe_req(sdata, ifmgd->associated->bssid,
1307 ssid + 2, ssid[1], NULL, 0, true); 1308 (u32) -1, ssid + 2, ssid[1],
1309 NULL, 0, true);
1308 1310
1309 return skb; 1311 return skb;
1310} 1312}
@@ -2333,14 +2335,16 @@ static enum work_done_result
2333ieee80211_probe_auth_done(struct ieee80211_work *wk, 2335ieee80211_probe_auth_done(struct ieee80211_work *wk,
2334 struct sk_buff *skb) 2336 struct sk_buff *skb)
2335{ 2337{
2338 struct ieee80211_local *local = wk->sdata->local;
2339
2336 if (!skb) { 2340 if (!skb) {
2337 cfg80211_send_auth_timeout(wk->sdata->dev, wk->filter_ta); 2341 cfg80211_send_auth_timeout(wk->sdata->dev, wk->filter_ta);
2338 return WORK_DONE_DESTROY; 2342 goto destroy;
2339 } 2343 }
2340 2344
2341 if (wk->type == IEEE80211_WORK_AUTH) { 2345 if (wk->type == IEEE80211_WORK_AUTH) {
2342 cfg80211_send_rx_auth(wk->sdata->dev, skb->data, skb->len); 2346 cfg80211_send_rx_auth(wk->sdata->dev, skb->data, skb->len);
2343 return WORK_DONE_DESTROY; 2347 goto destroy;
2344 } 2348 }
2345 2349
2346 mutex_lock(&wk->sdata->u.mgd.mtx); 2350 mutex_lock(&wk->sdata->u.mgd.mtx);
@@ -2350,6 +2354,12 @@ ieee80211_probe_auth_done(struct ieee80211_work *wk,
2350 wk->type = IEEE80211_WORK_AUTH; 2354 wk->type = IEEE80211_WORK_AUTH;
2351 wk->probe_auth.tries = 0; 2355 wk->probe_auth.tries = 0;
2352 return WORK_DONE_REQUEUE; 2356 return WORK_DONE_REQUEUE;
2357 destroy:
2358 if (wk->probe_auth.synced)
2359 drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
2360 IEEE80211_TX_SYNC_AUTH);
2361
2362 return WORK_DONE_DESTROY;
2353} 2363}
2354 2364
2355int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, 2365int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
@@ -2422,6 +2432,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
2422static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, 2432static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
2423 struct sk_buff *skb) 2433 struct sk_buff *skb)
2424{ 2434{
2435 struct ieee80211_local *local = wk->sdata->local;
2425 struct ieee80211_mgmt *mgmt; 2436 struct ieee80211_mgmt *mgmt;
2426 struct ieee80211_rx_status *rx_status; 2437 struct ieee80211_rx_status *rx_status;
2427 struct ieee802_11_elems elems; 2438 struct ieee802_11_elems elems;
@@ -2429,7 +2440,7 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
2429 2440
2430 if (!skb) { 2441 if (!skb) {
2431 cfg80211_send_assoc_timeout(wk->sdata->dev, wk->filter_ta); 2442 cfg80211_send_assoc_timeout(wk->sdata->dev, wk->filter_ta);
2432 return WORK_DONE_DESTROY; 2443 goto destroy;
2433 } 2444 }
2434 2445
2435 if (wk->type == IEEE80211_WORK_ASSOC_BEACON_WAIT) { 2446 if (wk->type == IEEE80211_WORK_ASSOC_BEACON_WAIT) {
@@ -2449,6 +2460,10 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
2449 status = le16_to_cpu(mgmt->u.assoc_resp.status_code); 2460 status = le16_to_cpu(mgmt->u.assoc_resp.status_code);
2450 2461
2451 if (status == WLAN_STATUS_SUCCESS) { 2462 if (status == WLAN_STATUS_SUCCESS) {
2463 if (wk->assoc.synced)
2464 drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
2465 IEEE80211_TX_SYNC_ASSOC);
2466
2452 mutex_lock(&wk->sdata->u.mgd.mtx); 2467 mutex_lock(&wk->sdata->u.mgd.mtx);
2453 if (!ieee80211_assoc_success(wk, mgmt, skb->len)) { 2468 if (!ieee80211_assoc_success(wk, mgmt, skb->len)) {
2454 mutex_unlock(&wk->sdata->u.mgd.mtx); 2469 mutex_unlock(&wk->sdata->u.mgd.mtx);
@@ -2462,6 +2477,11 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
2462 } 2477 }
2463 2478
2464 cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len); 2479 cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len);
2480 destroy:
2481 if (wk->assoc.synced)
2482 drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
2483 IEEE80211_TX_SYNC_ASSOC);
2484
2465 return WORK_DONE_DESTROY; 2485 return WORK_DONE_DESTROY;
2466} 2486}
2467 2487
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
index f87e993e713b..6326d3439861 100644
--- a/net/mac80211/pm.c
+++ b/net/mac80211/pm.c
@@ -34,6 +34,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
34 struct ieee80211_sub_if_data *sdata; 34 struct ieee80211_sub_if_data *sdata;
35 struct sta_info *sta; 35 struct sta_info *sta;
36 36
37 if (!local->open_count)
38 goto suspend;
39
37 ieee80211_scan_cancel(local); 40 ieee80211_scan_cancel(local);
38 41
39 if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) { 42 if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 08a45ac3d6f8..6f09eca01112 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -228,7 +228,6 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
228static bool ieee80211_prep_hw_scan(struct ieee80211_local *local) 228static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
229{ 229{
230 struct cfg80211_scan_request *req = local->scan_req; 230 struct cfg80211_scan_request *req = local->scan_req;
231 struct ieee80211_sub_if_data *sdata = local->scan_sdata;
232 enum ieee80211_band band; 231 enum ieee80211_band band;
233 int i, ielen, n_chans; 232 int i, ielen, n_chans;
234 233
@@ -253,7 +252,7 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
253 252
254 ielen = ieee80211_build_preq_ies(local, (u8 *)local->hw_scan_req->ie, 253 ielen = ieee80211_build_preq_ies(local, (u8 *)local->hw_scan_req->ie,
255 req->ie, req->ie_len, band, 254 req->ie, req->ie_len, band,
256 sdata->rc_rateidx_mask[band], 0); 255 req->rates[band], 0);
257 local->hw_scan_req->ie_len = ielen; 256 local->hw_scan_req->ie_len = ielen;
258 257
259 return true; 258 return true;
@@ -653,6 +652,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
653{ 652{
654 int i; 653 int i;
655 struct ieee80211_sub_if_data *sdata = local->scan_sdata; 654 struct ieee80211_sub_if_data *sdata = local->scan_sdata;
655 enum ieee80211_band band = local->hw.conf.channel->band;
656 656
657 for (i = 0; i < local->scan_req->n_ssids; i++) 657 for (i = 0; i < local->scan_req->n_ssids; i++)
658 ieee80211_send_probe_req( 658 ieee80211_send_probe_req(
@@ -660,7 +660,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
660 local->scan_req->ssids[i].ssid, 660 local->scan_req->ssids[i].ssid,
661 local->scan_req->ssids[i].ssid_len, 661 local->scan_req->ssids[i].ssid_len,
662 local->scan_req->ie, local->scan_req->ie_len, 662 local->scan_req->ie, local->scan_req->ie_len,
663 false); 663 local->scan_req->rates[band], false);
664 664
665 /* 665 /*
666 * After sending probe requests, wait for probe responses 666 * After sending probe requests, wait for probe responses
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
index cc79e697cdb2..f49d00a4c7fd 100644
--- a/net/mac80211/tkip.c
+++ b/net/mac80211/tkip.c
@@ -185,6 +185,17 @@ void ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *keyconf,
185} 185}
186EXPORT_SYMBOL(ieee80211_get_tkip_p1k_iv); 186EXPORT_SYMBOL(ieee80211_get_tkip_p1k_iv);
187 187
188void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
189 const u8 *ta, u32 iv32, u16 *p1k)
190{
191 const u8 *tk = &keyconf->key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY];
192 struct tkip_ctx ctx;
193
194 tkip_mixing_phase1(tk, &ctx, ta, iv32);
195 memcpy(p1k, ctx.p1k, sizeof(ctx.p1k));
196}
197EXPORT_SYMBOL(ieee80211_get_tkip_rx_p1k);
198
188void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf, 199void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
189 struct sk_buff *skb, u8 *p2k) 200 struct sk_buff *skb, u8 *p2k)
190{ 201{
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 5bfb80cba634..ddeb1b998383 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -799,6 +799,7 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata)
799 799
800 qparam.uapsd = false; 800 qparam.uapsd = false;
801 801
802 local->tx_conf[queue] = qparam;
802 drv_conf_tx(local, queue, &qparam); 803 drv_conf_tx(local, queue, &qparam);
803 } 804 }
804 805
@@ -1016,7 +1017,7 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1016} 1017}
1017 1018
1018struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 1019struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1019 u8 *dst, 1020 u8 *dst, u32 ratemask,
1020 const u8 *ssid, size_t ssid_len, 1021 const u8 *ssid, size_t ssid_len,
1021 const u8 *ie, size_t ie_len, 1022 const u8 *ie, size_t ie_len,
1022 bool directed) 1023 bool directed)
@@ -1049,9 +1050,7 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1049 1050
1050 buf_len = ieee80211_build_preq_ies(local, buf, ie, ie_len, 1051 buf_len = ieee80211_build_preq_ies(local, buf, ie, ie_len,
1051 local->hw.conf.channel->band, 1052 local->hw.conf.channel->band,
1052 sdata->rc_rateidx_mask 1053 ratemask, chan);
1053 [local->hw.conf.channel->band],
1054 chan);
1055 1054
1056 skb = ieee80211_probereq_get(&local->hw, &sdata->vif, 1055 skb = ieee80211_probereq_get(&local->hw, &sdata->vif,
1057 ssid, ssid_len, 1056 ssid, ssid_len,
@@ -1072,12 +1071,12 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
1072void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 1071void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1073 const u8 *ssid, size_t ssid_len, 1072 const u8 *ssid, size_t ssid_len,
1074 const u8 *ie, size_t ie_len, 1073 const u8 *ie, size_t ie_len,
1075 bool directed) 1074 u32 ratemask, bool directed)
1076{ 1075{
1077 struct sk_buff *skb; 1076 struct sk_buff *skb;
1078 1077
1079 skb = ieee80211_build_probe_req(sdata, dst, ssid, ssid_len, ie, ie_len, 1078 skb = ieee80211_build_probe_req(sdata, dst, ratemask, ssid, ssid_len,
1080 directed); 1079 ie, ie_len, directed);
1081 if (skb) 1080 if (skb)
1082 ieee80211_tx_skb(sdata, skb); 1081 ieee80211_tx_skb(sdata, skb);
1083} 1082}
@@ -1134,7 +1133,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1134 struct ieee80211_hw *hw = &local->hw; 1133 struct ieee80211_hw *hw = &local->hw;
1135 struct ieee80211_sub_if_data *sdata; 1134 struct ieee80211_sub_if_data *sdata;
1136 struct sta_info *sta; 1135 struct sta_info *sta;
1137 int res; 1136 int res, i;
1138 1137
1139#ifdef CONFIG_PM 1138#ifdef CONFIG_PM
1140 if (local->suspended) 1139 if (local->suspended)
@@ -1157,27 +1156,37 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1157 } 1156 }
1158#endif 1157#endif
1159 1158
1160 /* restart hardware */ 1159 /* setup fragmentation threshold */
1161 if (local->open_count) { 1160 drv_set_frag_threshold(local, hw->wiphy->frag_threshold);
1162 /* 1161
1163 * Upon resume hardware can sometimes be goofy due to 1162 /* setup RTS threshold */
1164 * various platform / driver / bus issues, so restarting 1163 drv_set_rts_threshold(local, hw->wiphy->rts_threshold);
1165 * the device may at times not work immediately. Propagate 1164
1166 * the error. 1165 /* reset coverage class */
1167 */ 1166 drv_set_coverage_class(local, hw->wiphy->coverage_class);
1168 res = drv_start(local); 1167
1169 if (res) { 1168 /* everything else happens only if HW was up & running */
1170 WARN(local->suspended, "Hardware became unavailable " 1169 if (!local->open_count)
1171 "upon resume. This could be a software issue " 1170 goto wake_up;
1172 "prior to suspend or a hardware issue.\n");
1173 return res;
1174 }
1175 1171
1176 ieee80211_led_radio(local, true); 1172 /*
1177 ieee80211_mod_tpt_led_trig(local, 1173 * Upon resume hardware can sometimes be goofy due to
1178 IEEE80211_TPT_LEDTRIG_FL_RADIO, 0); 1174 * various platform / driver / bus issues, so restarting
1175 * the device may at times not work immediately. Propagate
1176 * the error.
1177 */
1178 res = drv_start(local);
1179 if (res) {
1180 WARN(local->suspended, "Hardware became unavailable "
1181 "upon resume. This could be a software issue "
1182 "prior to suspend or a hardware issue.\n");
1183 return res;
1179 } 1184 }
1180 1185
1186 ieee80211_led_radio(local, true);
1187 ieee80211_mod_tpt_led_trig(local,
1188 IEEE80211_TPT_LEDTRIG_FL_RADIO, 0);
1189
1181 /* add interfaces */ 1190 /* add interfaces */
1182 list_for_each_entry(sdata, &local->interfaces, list) { 1191 list_for_each_entry(sdata, &local->interfaces, list) {
1183 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && 1192 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
@@ -1201,11 +1210,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1201 } 1210 }
1202 mutex_unlock(&local->sta_mtx); 1211 mutex_unlock(&local->sta_mtx);
1203 1212
1204 /* setup fragmentation threshold */ 1213 /* reconfigure tx conf */
1205 drv_set_frag_threshold(local, hw->wiphy->frag_threshold); 1214 for (i = 0; i < hw->queues; i++)
1206 1215 drv_conf_tx(local, i, &local->tx_conf[i]);
1207 /* setup RTS threshold */
1208 drv_set_rts_threshold(local, hw->wiphy->rts_threshold);
1209 1216
1210 /* reconfigure hardware */ 1217 /* reconfigure hardware */
1211 ieee80211_hw_config(local, ~0); 1218 ieee80211_hw_config(local, ~0);
@@ -1287,9 +1294,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1287 if (ieee80211_sdata_running(sdata)) 1294 if (ieee80211_sdata_running(sdata))
1288 ieee80211_enable_keys(sdata); 1295 ieee80211_enable_keys(sdata);
1289 1296
1290#ifdef CONFIG_PM
1291 wake_up: 1297 wake_up:
1292#endif
1293 ieee80211_wake_queues_by_reason(hw, 1298 ieee80211_wake_queues_by_reason(hw,
1294 IEEE80211_QUEUE_STOP_REASON_SUSPEND); 1299 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
1295 1300
diff --git a/net/mac80211/work.c b/net/mac80211/work.c
index edf8583280c9..380b9a7462b6 100644
--- a/net/mac80211/work.c
+++ b/net/mac80211/work.c
@@ -25,6 +25,7 @@
25 25
26#include "ieee80211_i.h" 26#include "ieee80211_i.h"
27#include "rate.h" 27#include "rate.h"
28#include "driver-ops.h"
28 29
29#define IEEE80211_AUTH_TIMEOUT (HZ / 5) 30#define IEEE80211_AUTH_TIMEOUT (HZ / 5)
30#define IEEE80211_AUTH_MAX_TRIES 3 31#define IEEE80211_AUTH_MAX_TRIES 3
@@ -427,6 +428,14 @@ ieee80211_direct_probe(struct ieee80211_work *wk)
427 struct ieee80211_sub_if_data *sdata = wk->sdata; 428 struct ieee80211_sub_if_data *sdata = wk->sdata;
428 struct ieee80211_local *local = sdata->local; 429 struct ieee80211_local *local = sdata->local;
429 430
431 if (!wk->probe_auth.synced) {
432 int ret = drv_tx_sync(local, sdata, wk->filter_ta,
433 IEEE80211_TX_SYNC_AUTH);
434 if (ret)
435 return WORK_ACT_TIMEOUT;
436 }
437 wk->probe_auth.synced = true;
438
430 wk->probe_auth.tries++; 439 wk->probe_auth.tries++;
431 if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { 440 if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) {
432 printk(KERN_DEBUG "%s: direct probe to %pM timed out\n", 441 printk(KERN_DEBUG "%s: direct probe to %pM timed out\n",
@@ -450,7 +459,8 @@ ieee80211_direct_probe(struct ieee80211_work *wk)
450 * will not answer to direct packet in unassociated state. 459 * will not answer to direct packet in unassociated state.
451 */ 460 */
452 ieee80211_send_probe_req(sdata, NULL, wk->probe_auth.ssid, 461 ieee80211_send_probe_req(sdata, NULL, wk->probe_auth.ssid,
453 wk->probe_auth.ssid_len, NULL, 0, true); 462 wk->probe_auth.ssid_len, NULL, 0,
463 (u32) -1, true);
454 464
455 wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; 465 wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
456 run_again(local, wk->timeout); 466 run_again(local, wk->timeout);
@@ -465,6 +475,14 @@ ieee80211_authenticate(struct ieee80211_work *wk)
465 struct ieee80211_sub_if_data *sdata = wk->sdata; 475 struct ieee80211_sub_if_data *sdata = wk->sdata;
466 struct ieee80211_local *local = sdata->local; 476 struct ieee80211_local *local = sdata->local;
467 477
478 if (!wk->probe_auth.synced) {
479 int ret = drv_tx_sync(local, sdata, wk->filter_ta,
480 IEEE80211_TX_SYNC_AUTH);
481 if (ret)
482 return WORK_ACT_TIMEOUT;
483 }
484 wk->probe_auth.synced = true;
485
468 wk->probe_auth.tries++; 486 wk->probe_auth.tries++;
469 if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { 487 if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) {
470 printk(KERN_DEBUG "%s: authentication with %pM" 488 printk(KERN_DEBUG "%s: authentication with %pM"
@@ -498,6 +516,14 @@ ieee80211_associate(struct ieee80211_work *wk)
498 struct ieee80211_sub_if_data *sdata = wk->sdata; 516 struct ieee80211_sub_if_data *sdata = wk->sdata;
499 struct ieee80211_local *local = sdata->local; 517 struct ieee80211_local *local = sdata->local;
500 518
519 if (!wk->assoc.synced) {
520 int ret = drv_tx_sync(local, sdata, wk->filter_ta,
521 IEEE80211_TX_SYNC_ASSOC);
522 if (ret)
523 return WORK_ACT_TIMEOUT;
524 }
525 wk->assoc.synced = true;
526
501 wk->assoc.tries++; 527 wk->assoc.tries++;
502 if (wk->assoc.tries > IEEE80211_ASSOC_MAX_TRIES) { 528 if (wk->assoc.tries > IEEE80211_ASSOC_MAX_TRIES) {
503 printk(KERN_DEBUG "%s: association with %pM" 529 printk(KERN_DEBUG "%s: association with %pM"
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 880dbe2e6f94..645437cfc464 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -488,6 +488,10 @@ int wiphy_register(struct wiphy *wiphy)
488 int i; 488 int i;
489 u16 ifmodes = wiphy->interface_modes; 489 u16 ifmodes = wiphy->interface_modes;
490 490
491 if (WARN_ON((wiphy->wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) &&
492 !(wiphy->wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY)))
493 return -EINVAL;
494
491 if (WARN_ON(wiphy->addresses && !wiphy->n_addresses)) 495 if (WARN_ON(wiphy->addresses && !wiphy->n_addresses))
492 return -EINVAL; 496 return -EINVAL;
493 497
@@ -918,7 +922,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
918 * Configure power management to the driver here so that its 922 * Configure power management to the driver here so that its
919 * correctly set also after interface type changes etc. 923 * correctly set also after interface type changes etc.
920 */ 924 */
921 if (wdev->iftype == NL80211_IFTYPE_STATION && 925 if ((wdev->iftype == NL80211_IFTYPE_STATION ||
926 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
922 rdev->ops->set_power_mgmt) 927 rdev->ops->set_power_mgmt)
923 if (rdev->ops->set_power_mgmt(wdev->wiphy, dev, 928 if (rdev->ops->set_power_mgmt(wdev->wiphy, dev,
924 wdev->ps, 929 wdev->ps,
diff --git a/net/wireless/core.h b/net/wireless/core.h
index a570ff9214ec..8672e028022f 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -447,6 +447,10 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
447 447
448u16 cfg80211_calculate_bitrate(struct rate_info *rate); 448u16 cfg80211_calculate_bitrate(struct rate_info *rate);
449 449
450int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
451 const u8 *rates, unsigned int n_rates,
452 u32 *mask);
453
450int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, 454int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
451 u32 beacon_int); 455 u32 beacon_int);
452 456
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6a82c898f831..28d2aa109bee 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -177,6 +177,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
177 [NL80211_ATTR_STA_PLINK_STATE] = { .type = NLA_U8 }, 177 [NL80211_ATTR_STA_PLINK_STATE] = { .type = NLA_U8 },
178 [NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 }, 178 [NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 },
179 [NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED }, 179 [NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED },
180 [NL80211_ATTR_SCAN_SUPP_RATES] = { .type = NLA_NESTED },
180}; 181};
181 182
182/* policy for the key attributes */ 183/* policy for the key attributes */
@@ -205,6 +206,10 @@ nl80211_wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = {
205 [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG }, 206 [NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG },
206 [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG }, 207 [NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG },
207 [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .type = NLA_NESTED }, 208 [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .type = NLA_NESTED },
209 [NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG },
210 [NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG },
211 [NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG },
212 [NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG },
208}; 213};
209 214
210/* policy for GTK rekey offload attributes */ 215/* policy for GTK rekey offload attributes */
@@ -692,8 +697,12 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
692 dev->wiphy.coverage_class); 697 dev->wiphy.coverage_class);
693 NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, 698 NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
694 dev->wiphy.max_scan_ssids); 699 dev->wiphy.max_scan_ssids);
700 NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
701 dev->wiphy.max_sched_scan_ssids);
695 NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, 702 NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN,
696 dev->wiphy.max_scan_ie_len); 703 dev->wiphy.max_scan_ie_len);
704 NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
705 dev->wiphy.max_sched_scan_ie_len);
697 706
698 if (dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) 707 if (dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)
699 NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_IBSS_RSN); 708 NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_IBSS_RSN);
@@ -929,6 +938,16 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
929 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT); 938 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT);
930 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) 939 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT)
931 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); 940 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT);
941 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY)
942 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED);
943 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE)
944 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE);
945 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ)
946 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST);
947 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE)
948 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE);
949 if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE)
950 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE);
932 if (dev->wiphy.wowlan.n_patterns) { 951 if (dev->wiphy.wowlan.n_patterns) {
933 struct nl80211_wowlan_pattern_support pat = { 952 struct nl80211_wowlan_pattern_support pat = {
934 .max_patterns = dev->wiphy.wowlan.n_patterns, 953 .max_patterns = dev->wiphy.wowlan.n_patterns,
@@ -3306,7 +3325,6 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
3306 struct nlattr *attr; 3325 struct nlattr *attr;
3307 struct wiphy *wiphy; 3326 struct wiphy *wiphy;
3308 int err, tmp, n_ssids = 0, n_channels, i; 3327 int err, tmp, n_ssids = 0, n_channels, i;
3309 enum ieee80211_band band;
3310 size_t ie_len; 3328 size_t ie_len;
3311 3329
3312 if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) 3330 if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
@@ -3326,6 +3344,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
3326 if (!n_channels) 3344 if (!n_channels)
3327 return -EINVAL; 3345 return -EINVAL;
3328 } else { 3346 } else {
3347 enum ieee80211_band band;
3329 n_channels = 0; 3348 n_channels = 0;
3330 3349
3331 for (band = 0; band < IEEE80211_NUM_BANDS; band++) 3350 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
@@ -3386,6 +3405,8 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
3386 i++; 3405 i++;
3387 } 3406 }
3388 } else { 3407 } else {
3408 enum ieee80211_band band;
3409
3389 /* all channels */ 3410 /* all channels */
3390 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 3411 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
3391 int j; 3412 int j;
@@ -3432,6 +3453,30 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
3432 request->ie_len); 3453 request->ie_len);
3433 } 3454 }
3434 3455
3456 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
3457 if (wiphy->bands[i])
3458 request->rates[i] =
3459 (1 << wiphy->bands[i]->n_bitrates) - 1;
3460
3461 if (info->attrs[NL80211_ATTR_SCAN_SUPP_RATES]) {
3462 nla_for_each_nested(attr,
3463 info->attrs[NL80211_ATTR_SCAN_SUPP_RATES],
3464 tmp) {
3465 enum ieee80211_band band = nla_type(attr);
3466
3467 if (band < 0 || band > IEEE80211_NUM_BANDS) {
3468 err = -EINVAL;
3469 goto out_free;
3470 }
3471 err = ieee80211_get_ratemask(wiphy->bands[band],
3472 nla_data(attr),
3473 nla_len(attr),
3474 &request->rates[band]);
3475 if (err)
3476 goto out_free;
3477 }
3478 }
3479
3435 request->dev = dev; 3480 request->dev = dev;
3436 request->wiphy = &rdev->wiphy; 3481 request->wiphy = &rdev->wiphy;
3437 3482
@@ -3497,7 +3542,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
3497 tmp) 3542 tmp)
3498 n_ssids++; 3543 n_ssids++;
3499 3544
3500 if (n_ssids > wiphy->max_scan_ssids) 3545 if (n_ssids > wiphy->max_sched_scan_ssids)
3501 return -EINVAL; 3546 return -EINVAL;
3502 3547
3503 if (info->attrs[NL80211_ATTR_IE]) 3548 if (info->attrs[NL80211_ATTR_IE])
@@ -3505,7 +3550,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
3505 else 3550 else
3506 ie_len = 0; 3551 ie_len = 0;
3507 3552
3508 if (ie_len > wiphy->max_scan_ie_len) 3553 if (ie_len > wiphy->max_sched_scan_ie_len)
3509 return -EINVAL; 3554 return -EINVAL;
3510 3555
3511 mutex_lock(&rdev->sched_scan_mtx); 3556 mutex_lock(&rdev->sched_scan_mtx);
@@ -4318,25 +4363,12 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
4318 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); 4363 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
4319 struct ieee80211_supported_band *sband = 4364 struct ieee80211_supported_band *sband =
4320 wiphy->bands[ibss.channel->band]; 4365 wiphy->bands[ibss.channel->band];
4321 int i, j; 4366 int err;
4322 4367
4323 if (n_rates == 0) 4368 err = ieee80211_get_ratemask(sband, rates, n_rates,
4324 return -EINVAL; 4369 &ibss.basic_rates);
4325 4370 if (err)
4326 for (i = 0; i < n_rates; i++) { 4371 return err;
4327 int rate = (rates[i] & 0x7f) * 5;
4328 bool found = false;
4329
4330 for (j = 0; j < sband->n_bitrates; j++) {
4331 if (sband->bitrates[j].bitrate == rate) {
4332 found = true;
4333 ibss.basic_rates |= BIT(j);
4334 break;
4335 }
4336 }
4337 if (!found)
4338 return -EINVAL;
4339 }
4340 } 4372 }
4341 4373
4342 if (info->attrs[NL80211_ATTR_MCAST_RATE] && 4374 if (info->attrs[NL80211_ATTR_MCAST_RATE] &&
@@ -5272,6 +5304,14 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info)
5272 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT); 5304 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT);
5273 if (rdev->wowlan->magic_pkt) 5305 if (rdev->wowlan->magic_pkt)
5274 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); 5306 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT);
5307 if (rdev->wowlan->gtk_rekey_failure)
5308 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE);
5309 if (rdev->wowlan->eap_identity_req)
5310 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST);
5311 if (rdev->wowlan->four_way_handshake)
5312 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE);
5313 if (rdev->wowlan->rfkill_release)
5314 NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE);
5275 if (rdev->wowlan->n_patterns) { 5315 if (rdev->wowlan->n_patterns) {
5276 struct nlattr *nl_pats, *nl_pat; 5316 struct nlattr *nl_pats, *nl_pat;
5277 int i, pat_len; 5317 int i, pat_len;
@@ -5348,6 +5388,33 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
5348 new_triggers.magic_pkt = true; 5388 new_triggers.magic_pkt = true;
5349 } 5389 }
5350 5390
5391 if (tb[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED])
5392 return -EINVAL;
5393
5394 if (tb[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) {
5395 if (!(wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE))
5396 return -EINVAL;
5397 new_triggers.gtk_rekey_failure = true;
5398 }
5399
5400 if (tb[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) {
5401 if (!(wowlan->flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ))
5402 return -EINVAL;
5403 new_triggers.eap_identity_req = true;
5404 }
5405
5406 if (tb[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) {
5407 if (!(wowlan->flags & WIPHY_WOWLAN_4WAY_HANDSHAKE))
5408 return -EINVAL;
5409 new_triggers.four_way_handshake = true;
5410 }
5411
5412 if (tb[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) {
5413 if (!(wowlan->flags & WIPHY_WOWLAN_RFKILL_RELEASE))
5414 return -EINVAL;
5415 new_triggers.rfkill_release = true;
5416 }
5417
5351 if (tb[NL80211_WOWLAN_TRIG_PKT_PATTERN]) { 5418 if (tb[NL80211_WOWLAN_TRIG_PKT_PATTERN]) {
5352 struct nlattr *pat; 5419 struct nlattr *pat;
5353 int n_patterns = 0; 5420 int n_patterns = 0;
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 1c4672e35144..2936cb809152 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -862,6 +862,10 @@ int cfg80211_wext_siwscan(struct net_device *dev,
862 creq->n_ssids = 0; 862 creq->n_ssids = 0;
863 } 863 }
864 864
865 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
866 if (wiphy->bands[i])
867 creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1;
868
865 rdev->scan_req = creq; 869 rdev->scan_req = creq;
866 err = rdev->ops->scan(wiphy, dev, creq); 870 err = rdev->ops->scan(wiphy, dev, creq);
867 if (err) { 871 if (err) {
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 4d7b83fbc32f..be75a3a0424e 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1006,3 +1006,41 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
1006 1006
1007 return -EBUSY; 1007 return -EBUSY;
1008} 1008}
1009
1010int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
1011 const u8 *rates, unsigned int n_rates,
1012 u32 *mask)
1013{
1014 int i, j;
1015
1016 if (!sband)
1017 return -EINVAL;
1018
1019 if (n_rates == 0 || n_rates > NL80211_MAX_SUPP_RATES)
1020 return -EINVAL;
1021
1022 *mask = 0;
1023
1024 for (i = 0; i < n_rates; i++) {
1025 int rate = (rates[i] & 0x7f) * 5;
1026 bool found = false;
1027
1028 for (j = 0; j < sband->n_bitrates; j++) {
1029 if (sband->bitrates[j].bitrate == rate) {
1030 found = true;
1031 *mask |= BIT(j);
1032 break;
1033 }
1034 }
1035 if (!found)
1036 return -EINVAL;
1037 }
1038
1039 /*
1040 * mask must have at least one bit set here since we
1041 * didn't accept a 0-length rates array nor allowed
1042 * entries in the array that didn't exist
1043 */
1044
1045 return 0;
1046}