History log of /linux-master/drivers/net/wireless/ath/ath9k/main.c
Revision Date Author Comments
# 61752ac6 04-Apr-2024 Arnd Bergmann <arnd@arndb.de>

wifi: ath9k: work around memset overflow warning

gcc-9 and some other older versions produce a false-positive warning
for zeroing two fields

In file included from include/linux/string.h:369,
from drivers/net/wireless/ath/ath9k/main.c:18:
In function 'fortify_memset_chk',
inlined from 'ath9k_ps_wakeup' at drivers/net/wireless/ath/ath9k/main.c:140:3:
include/linux/fortify-string.h:462:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
462 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using a struct_group seems to reliably avoid the warning and
not make the code much uglier. The combined memset() should even
save a couple of cpu cycles.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240328135509.3755090-3-arnd@kernel.org


# 0a44dfc0 29-Jan-2024 Johannes Berg <johannes.berg@intel.com>

wifi: mac80211: simplify non-chanctx drivers

There are still surprisingly many non-chanctx drivers, but in
mac80211 that code is a bit awkward. Simplify this by having
those drivers assign 'emulated' ops, so that the mac80211 code
can be more unified between non-chanctx/chanctx drivers. This
cuts the number of places caring about it by about 15, which
are scattered across - now they're fewer and no longer in the
channel context handling.

Link: https://msgid.link/20240129194108.6d0ead50f5cf.I60d093b2fc81ca1853925a4d0ac3a2337d5baa5b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 4fadce88 05-Dec-2023 Hancheng Yang <hyang@freebox.fr>

wifi: ath9k: reset survey of current channel after a scan started

In the `ath_set_channel()` function, we only reset surveys that are not
from the current channel. This leads to the accumulation of survey data for
the current channel indefinitely. This may not be the most optimal
approach, as we want the ACS to rely on the most recent survey.
So reset the survey data for the current channel at the start of each scan.

Signed-off-by: Hancheng Yang <hyang@freebox.fr>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231205170623.3029689-1-hyang@freebox.fr


# 3b86f86d 14-Aug-2023 Arnd Bergmann <arnd@arndb.de>

wifi: ath: remove unused-but-set parameter

This has never been used since the driver was merged, but it now causes
a W=1 warning in recent clang versions

drivers/net/wireless/ath/ath9k/main.c:1566:21: error: parameter 'changed_flags' set but not used [-Werror,-Wunused-but-set-parameter]
drivers/net/wireless/ath/ath9k/htc_drv_main.c:1258:25: error: parameter 'changed_flags' set but not used [-Werror,-Wunused-but-set-parameter]
drivers/net/wireless/ath/ath5k/mac80211-ops.c:367:62: error: parameter 'changed_flags' set but not used [-Werror,-Wunused-but-set-parameter]

Remove the bit manipulation on the otherwise unused parameter.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230814073255.1065242-1-arnd@kernel.org


# 2aa083ac 13-Jun-2023 Dmitry Antipov <dmantipov@yandex.ru>

wifi: ath9k: convert msecs to jiffies where needed

Since 'ieee80211_queue_delayed_work()' expects timeout in
jiffies and not milliseconds, 'msecs_to_jiffies()' should
be used in 'ath_restart_work()' and '__ath9k_flush()'.

Fixes: d63ffc45c5d3 ("ath9k: rename tx_complete_work to hw_check_work")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230613134655.248728-1-dmantipov@yandex.ru


# 75086cc6 09-Jun-2023 Remi Pommarel <repk@triplefau.lt>

wifi: ath9k: Fix possible stall on ath9k_txq_list_has_key()

On EDMA capable hardware, ath9k_txq_list_has_key() can enter infinite
loop if it is called while all txq_fifos have packets that use different
key that the one we are looking for. Fix it by exiting the loop if all
txq_fifos have been checked already.

Because this loop is called under spin_lock_bh() (see ath_txq_lock) it
causes the following rcu stall:

rcu: INFO: rcu_sched self-detected stall on CPU
ath10k_pci 0000:01:00.0: failed to read temperature -11
rcu: 1-....: (5254 ticks this GP) idle=189/1/0x4000000000000002 softirq=8442983/8442984 fqs=2579
(t=5257 jiffies g=17983297 q=334)
Task dump for CPU 1:
task:hostapd state:R running task stack: 0 pid: 297 ppid: 289 flags:0x0000000a
Call trace:
dump_backtrace+0x0/0x170
show_stack+0x1c/0x24
sched_show_task+0x140/0x170
dump_cpu_task+0x48/0x54
rcu_dump_cpu_stacks+0xf0/0x134
rcu_sched_clock_irq+0x8d8/0x9fc
update_process_times+0xa0/0xec
tick_sched_timer+0x5c/0xd0
__hrtimer_run_queues+0x154/0x320
hrtimer_interrupt+0x120/0x2f0
arch_timer_handler_virt+0x38/0x44
handle_percpu_devid_irq+0x9c/0x1e0
handle_domain_irq+0x64/0x90
gic_handle_irq+0x78/0xb0
call_on_irq_stack+0x28/0x38
do_interrupt_handler+0x54/0x5c
el1_interrupt+0x2c/0x4c
el1h_64_irq_handler+0x14/0x1c
el1h_64_irq+0x74/0x78
ath9k_txq_has_key+0x1bc/0x250 [ath9k]
ath9k_set_key+0x1cc/0x3dc [ath9k]
drv_set_key+0x78/0x170
ieee80211_key_replace+0x564/0x6cc
ieee80211_key_link+0x174/0x220
ieee80211_add_key+0x11c/0x300
nl80211_new_key+0x12c/0x330
genl_family_rcv_msg_doit+0xbc/0x11c
genl_rcv_msg+0xd8/0x1c4
netlink_rcv_skb+0x40/0x100
genl_rcv+0x3c/0x50
netlink_unicast+0x1ec/0x2c0
netlink_sendmsg+0x198/0x3c0
____sys_sendmsg+0x210/0x250
___sys_sendmsg+0x78/0xc4
__sys_sendmsg+0x4c/0x90
__arm64_sys_sendmsg+0x28/0x30
invoke_syscall.constprop.0+0x60/0x100
do_el0_svc+0x48/0xd0
el0_svc+0x14/0x50
el0t_64_sync_handler+0xa8/0xb0
el0t_64_sync+0x158/0x15c

This rcu stall is hard to reproduce as is, but changing ATH_TXFIFO_DEPTH
from 8 to 2 makes it reasonably easy to reproduce.

Fixes: ca2848022c12 ("ath9k: Postpone key cache entry deletion for TXQ frames reference it")
Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Tested-by: Nicolas Escande <nico.escande@gmail.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230609093744.1985-1-repk@triplefau.lt


# 727eff4d 03-Jul-2022 Gregory Greenman <gregory.greenman@intel.com>

wifi: mac80211: replace link_id with link_conf in switch/(un)assign_vif_chanctx()

Since mac80211 already has a protected pointer to link_conf,
pass it to the driver to avoid additional RCU locking.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# b3e2130b 24-Jun-2022 Johannes Berg <johannes.berg@intel.com>

wifi: mac80211: change QoS settings API to take link into account

Take the link into account in the QoS settings (EDCA parameters)
APIs.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# b4f85443 30-May-2022 Johannes Berg <johannes.berg@intel.com>

wifi: mac80211: make channel context code MLO-aware

Make the channel context code MLO aware, along with some
functions that it uses, so that the chan.c file is now
MLD-clean and no longer uses deflink/bss_conf/etc.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 7b7090b4 24-May-2022 Johannes Berg <johannes.berg@intel.com>

wifi: mac80211: split bss_info_changed method

Split the bss_info_changed method to vif_cfg_changed and
link_info_changed, with the latter getting a link ID.
Also change the 'changed' parameter to u64 already, we
know we need that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# f276e20b 10-May-2022 Johannes Berg <johannes.berg@intel.com>

wifi: mac80211: move interface config to new struct

We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.

Some adjustments were done with the following spatch:

@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)

@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var

(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 046d2e7c 04-Apr-2022 Sriram R <quic_srirrama@quicinc.com>

mac80211: prepare sta handling for MLO support

Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.

With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.

To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.

For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.

For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.

Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.

Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.

@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@

(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)

@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@

(
si->
- var
+ deflink.var
)

Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 5a6b06f5 04-Apr-2022 Toke Høiland-Jørgensen <toke@redhat.com>

ath9k: Fix usage of driver-private space in tx_info

The ieee80211_tx_info_clear_status() helper also clears the rate counts and
the driver-private part of struct ieee80211_tx_info, so using it breaks
quite a few other things. So back out of using it, and instead define a
ath-internal helper that only clears the area between the
status_driver_data and the rates info. Combined with moving the
ath_frame_info struct to status_driver_data, this avoids clearing anything
we shouldn't be, and so we can keep the existing code for handling the rate
information.

While fixing this I also noticed that the setting of
tx_info->status.rates[tx_rateindex].count on hardware underrun errors was
always immediately overridden by the normal setting of the same fields, so
rearrange the code so that the underrun detection actually takes effect.

The new helper could be generalised to a 'memset_between()' helper, but
leave it as a driver-internal helper for now since this needs to go to
stable.

Cc: stable@vger.kernel.org
Reported-by: Peter Seiderer <ps.report@gmx.net>
Fixes: 037250f0a45c ("ath9k: Properly clear TX status area before reporting to mac80211")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Peter Seiderer <ps.report@gmx.net>
Tested-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220404204800.2681133-1-toke@toke.dk


# 4925642d 05-Oct-2021 Linus Lüssing <ll@simonwunderlich.de>

ath9k: Fix potential interrupt storm on queue reset

In tests with two Lima boards from 8devices (QCA4531 based) on OpenWrt
19.07 we could force a silent restart of a device with no serial
output when we were sending a high amount of UDP traffic (iperf3 at 80
MBit/s in both directions from external hosts, saturating the wifi and
causing a load of about 4.5 to 6) and were then triggering an
ath9k_queue_reset().

Further debugging showed that the restart was caused by the ath79
watchdog. With disabled watchdog we could observe that the device was
constantly going into ath_isr() interrupt handler and was returning
early after the ATH_OP_HW_RESET flag test, without clearing any
interrupts. Even though ath9k_queue_reset() calls
ath9k_hw_kill_interrupts().

With JTAG we could observe the following race condition:

1) ath9k_queue_reset()
...
-> ath9k_hw_kill_interrupts()
-> set_bit(ATH_OP_HW_RESET, &common->op_flags);
...
<- returns

2) ath9k_tasklet()
...
-> ath9k_hw_resume_interrupts()
...
<- returns

3) loops around:
...
handle_int()
-> ath_isr()
...
-> if (test_bit(ATH_OP_HW_RESET,
&common->op_flags))
return IRQ_HANDLED;

x) ath_reset_internal():
=> never reached <=

And in ath_isr() we would typically see the following interrupts /
interrupt causes:

* status: 0x00111030 or 0x00110030
* async_cause: 2 (AR_INTR_MAC_IPQ)
* sync_cause: 0

So the ath9k_tasklet() reenables the ath9k interrupts
through ath9k_hw_resume_interrupts() which ath9k_queue_reset() had just
disabled. And ath_isr() then keeps firing because it returns IRQ_HANDLED
without actually clearing the interrupt.

To fix this IRQ storm also clear/disable the interrupts again when we
are in reset state.

Cc: Sven Eckelmann <sven@narfation.org>
Cc: Simon Wunderlich <sw@simonwunderlich.de>
Cc: Linus Lüssing <linus.luessing@c0d3.blue>
Fixes: 872b5d814f99 ("ath9k: do not access hardware on IRQs during reset")
Signed-off-by: Linus Lüssing <ll@simonwunderlich.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210914192515.9273-3-linus.luessing@c0d3.blue


# 15fae341 18-Jun-2021 Johannes Berg <johannes.berg@intel.com>

mac80211: notify driver on mgd TX completion

We have mgd_prepare_tx(), but sometimes drivers may want/need
to take action when the exchange finishes, whether successfully
or not.

Add a notification to the driver on completion, i.e. call the
new method mgd_complete_tx().

To unify the two scenarios, and to add more information, make
both of them take a struct that has the duration (prepare only),
subtype (both) and success (complete only).

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210618133832.5d94e78f6230.I6dc979606b6f28701b740d7aab725f7853a5a155@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# fb312ac5 31-May-2021 Pali Rohár <pali@kernel.org>

ath9k: Fix kernel NULL pointer dereference during ath_reset_internal()

I got this crash more times during debugging of PCIe controller and crash
happens somehow at the time when PCIe kernel code started link retraining (as
part of ASPM code) when at the same time PCIe link went down and ath9k probably
executed hw reset procedure.

Currently I'm not able to reproduce this issue as it looks like to be
some race condition between link training, ASPM, link down and reset
path. And as always, race conditions which depends on more input
parameters are hard to reproduce as it depends on precise timings.

But it is clear that pointers are zero in this case and should be
properly filled as same code pattern is used in ath9k_stop() function.
Anyway I was able to reproduce this crash by manually triggering ath
reset worker prior putting card up. I created simple patch to export
reset functionality via debugfs and use it to "simulate" of triggering
reset. s proved that NULL-pointer dereference issue is there.

Function ath9k_hw_reset() is dereferencing chan structure pointer, so it
needs to be non-NULL pointer.

Function ath9k_stop() already contains code which sets ah->curchan to valid
non-NULL pointer prior calling ath9k_hw_reset() function.

Add same code pattern also into ath_reset_internal() function to prevent
kernel NULL pointer dereference in ath9k_hw_reset() function.

This change fixes kernel NULL pointer dereference in ath9k_hw_reset() which
is caused by calling ath9k_hw_reset() from ath_reset_internal() with NULL
chan structure.

[ 45.334305] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
[ 45.344417] Mem abort info:
[ 45.347301] ESR = 0x96000005
[ 45.350448] EC = 0x25: DABT (current EL), IL = 32 bits
[ 45.356166] SET = 0, FnV = 0
[ 45.359350] EA = 0, S1PTW = 0
[ 45.362596] Data abort info:
[ 45.365756] ISV = 0, ISS = 0x00000005
[ 45.369735] CM = 0, WnR = 0
[ 45.372814] user pgtable: 4k pages, 39-bit VAs, pgdp=000000000685d000
[ 45.379663] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
[ 45.388856] Internal error: Oops: 96000005 [#1] SMP
[ 45.393897] Modules linked in: ath9k ath9k_common ath9k_hw
[ 45.399574] CPU: 1 PID: 309 Comm: kworker/u4:2 Not tainted 5.12.0-rc2-dirty #785
[ 45.414746] Workqueue: phy0 ath_reset_work [ath9k]
[ 45.419713] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
[ 45.425910] pc : ath9k_hw_reset+0xc4/0x1c48 [ath9k_hw]
[ 45.431234] lr : ath9k_hw_reset+0xc0/0x1c48 [ath9k_hw]
[ 45.436548] sp : ffffffc0118dbca0
[ 45.439961] x29: ffffffc0118dbca0 x28: 0000000000000000
[ 45.445442] x27: ffffff800dee4080 x26: 0000000000000000
[ 45.450923] x25: ffffff800df9b9d8 x24: 0000000000000000
[ 45.456404] x23: ffffffc0115f6000 x22: ffffffc008d0d408
[ 45.461885] x21: ffffff800dee5080 x20: ffffff800df9b9d8
[ 45.467366] x19: 0000000000000000 x18: 0000000000000000
[ 45.472846] x17: 0000000000000000 x16: 0000000000000000
[ 45.478326] x15: 0000000000000010 x14: ffffffffffffffff
[ 45.483807] x13: ffffffc0918db94f x12: ffffffc011498720
[ 45.489289] x11: 0000000000000003 x10: ffffffc0114806e0
[ 45.494770] x9 : ffffffc01014b2ec x8 : 0000000000017fe8
[ 45.500251] x7 : c0000000ffffefff x6 : 0000000000000001
[ 45.505733] x5 : 0000000000000000 x4 : 0000000000000000
[ 45.511213] x3 : 0000000000000000 x2 : ffffff801fece870
[ 45.516693] x1 : ffffffc00eded000 x0 : 000000000000003f
[ 45.522174] Call trace:
[ 45.524695] ath9k_hw_reset+0xc4/0x1c48 [ath9k_hw]
[ 45.529653] ath_reset_internal+0x1a8/0x2b8 [ath9k]
[ 45.534696] ath_reset_work+0x2c/0x40 [ath9k]
[ 45.539198] process_one_work+0x210/0x480
[ 45.543339] worker_thread+0x5c/0x510
[ 45.547115] kthread+0x12c/0x130
[ 45.550445] ret_from_fork+0x10/0x1c
[ 45.554138] Code: 910922c2 9117e021 95ff0398 b4000294 (b9400a61)
[ 45.560430] ---[ end trace 566410ba90b50e8b ]---
[ 45.565193] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[ 45.572282] SMP: stopping secondary CPUs
[ 45.576331] Kernel Offset: disabled
[ 45.579924] CPU features: 0x00040002,0000200c
[ 45.584416] Memory Limit: none
[ 45.587564] Rebooting in 3 seconds..

Signed-off-by: Pali Rohár <pali@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210402122653.24014-1-pali@kernel.org


# ca284802 14-Dec-2020 Jouni Malinen <jouni@codeaurora.org>

ath9k: Postpone key cache entry deletion for TXQ frames reference it

Do not delete a key cache entry that is still being referenced by
pending frames in TXQs. This avoids reuse of the key cache entry while a
frame might still be transmitted using it.

To avoid having to do any additional operations during the main TX path
operations, track pending key cache entries in a new bitmap and check
whether any pending entries can be deleted before every new key
add/remove operation. Also clear any remaining entries when stopping the
interface.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201214172118.18100-6-jouni@codeaurora.org


# 144cd24d 14-Dec-2020 Jouni Malinen <jouni@codeaurora.org>

ath: Modify ath_key_delete() to not need full key entry

tkip_keymap can be used internally to avoid the reference to key->cipher
and with this, only the key index value itself is needed. This allows
ath_key_delete() call to be postponed to be handled after the upper
layer STA and key entry have already been removed. This is needed to
make ath9k key cache management safer.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201214172118.18100-5-jouni@codeaurora.org


# 73488cb2 14-Dec-2020 Jouni Malinen <jouni@codeaurora.org>

ath9k: Clear key cache explicitly on disabling hardware

Now that ath/key.c may not be explicitly clearing keys from the key
cache, clear all key cache entries when disabling hardware to make sure
no keys are left behind beyond this point.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201214172118.18100-3-jouni@codeaurora.org


# f4899218 09-Nov-2020 Johannes Berg <johannes.berg@intel.com>

ath9k: remove WDS code

The ability to reach this code was hidden behind
CONFIG_WIRELESS_WDS, which was just removed. Clean
up the driver accordingly.

Link: https://lore.kernel.org/r/20201109105103.e1d48ee20b0a.I89f8af0d50a02ce16a922fa790d6c1908f31a496@changeid
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# f91a35b4 17-Aug-2020 Allen Pais <allen.lkml@gmail.com>

ath9k: convert tasklets to use new tasklet_setup() API

In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200817090637.26887-3-allen.cryptic@gmail.com


# 4bad3a20 04-Aug-2020 Alexander Wetzel <alexander@wetzel-home.de>

ath9k: add NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 support

The ath9k driver was so far only able to rekey PTK0 keys correctly due
to the best effort queue flush added with commit 62872a9b9a10
("mac80211: Fix PTK rekey freezes and clear text leak").

Add the needed queue flush and set NL80211_EXT_FEATURE_CAN_REPLACE_PTK0
to tell mac80211 that the driver can now rekey PTK0 keys correctly and
no longer needs the best effort flush.

Effectively this prevents mac80211 to warn when rekeying a PTK0 key
only.

Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200804164152.175375-1-alexander@wetzel-home.de


# 221af813 27-Jul-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

ath9k: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200727193520.GA832@embeddedor


# c01c320d 26-Apr-2020 Jouni Malinen <jouni@codeaurora.org>

ath9k: Set RX filter based to allow broadcast Action frame RX

Advertise support for multicast frame registration and update the RX
filter based on the recently added FIF_MCAST_ACTION to allow broadcast
Action frames to be received. This is needed for Device Provisioning
Protocol (DPP) use cases that use broadcast Public Action frames.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200426084733.7889-1-jouni@codeaurora.org


# 968ae2ca 29-Feb-2020 Remi Pommarel <repk@triplefau.lt>

ath9k: Handle txpower changes even when TPC is disabled

When TPC is disabled IEEE80211_CONF_CHANGE_POWER event can be handled to
reconfigure HW's maximum txpower.

This fixes 0dBm txpower setting when user attaches to an interface for
the first time with the following scenario:

ieee80211_do_open()
ath9k_add_interface()
ath9k_set_txpower() /* Set TX power with not yet initialized
sc->hw->conf.power_level */

ieee80211_hw_config() /* Iniatilize sc->hw->conf.power_level and
raise IEEE80211_CONF_CHANGE_POWER */

ath9k_config() /* IEEE80211_CONF_CHANGE_POWER is ignored */

This issue can be reproduced with the following:

$ modprobe -r ath9k
$ modprobe ath9k
$ wpa_supplicant -i wlan0 -c /tmp/wpa.conf &
$ iw dev /* Here TX power is either 0 or 3 depending on RF chain */
$ killall wpa_supplicant
$ iw dev /* TX power goes back to calibrated value and subsequent
calls will be fine */

Fixes: 283dd11994cde ("ath9k: add per-vif TX power capability")
Cc: stable@vger.kernel.org
Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# db6d9e9e 17-Dec-2019 Ben Greear <greearb@candelatech.com>

mac80211: Fix setting txpower to zero

With multiple VIFS ath10k, and probably others, tries to find the
minimum txpower for all vifs and uses that when setting txpower in
the firmware.

If a second vif is added and starts to scan, it's txpower is not
initialized yet and it set to zero.

ath10k had a patch to ignore zero values, but then it is impossible
to actually set txpower to zero.

So, instead initialize the txpower to INT_MIN in mac80211, and let
drivers know that means the power has not been set and so should
be ignored.

This should fix regression in:

commit 88407beb1b1462f706a1950a355fd086e1c450b6
Author: Ryan Hsu <ryanhsu@qca.qualcomm.com>
Date: Tue Dec 13 14:55:19 2016 -0800

ath10k: fix incorrect txpower set by P2P_DEVICE interface

Tested on ath10k 9984 with ath10k-ct firmware.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Link: https://lore.kernel.org/r/20191217183057.24586-1-greearb@candelatech.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 2ce113de 02-Oct-2019 Johannes Berg <johannes.berg@intel.com>

mac80211: simplify TX aggregation start

There really is no need to make drivers call the
ieee80211_start_tx_ba_cb_irqsafe() function and then
schedule the worker if all we want is to set a bit.

Add a new return value (that was previously considered
invalid) to indicate that the driver is immediately
ready for the session, and make drivers use it. The
only drivers that remain different are the Intel ones
as they need to negotiate more with the firmware.

Link: https://lore.kernel.org/r/1570007543-I152912660131cbab2e5d80b4218238c20f8a06e5@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 5db4c4b9 23-Jul-2019 Emmanuel Grumbach <emmanuel.grumbach@intel.com>

mac80211: pass the vif to cancel_remain_on_channel

This low level driver can find it useful to get the vif
when a remain on channel session is cancelled.

iwlwifi will need this soon.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://lore.kernel.org/r/20190723180001.5828-1-emmanuel.grumbach@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 461cf036 19-Oct-2018 Dan Carpenter <dan.carpenter@oracle.com>

ath9k: Fix a locking bug in ath9k_add_interface()

We tried to revert commit d9c52fd17cb4 ("ath9k: fix tx99 with monitor
mode interface") but accidentally missed part of the locking change.

The lock has to be held earlier so that we're holding it when we do
"sc->tx99_vif = vif;" and also there in the current code there is a
stray unlock before we have taken the lock.

Fixes: 6df0580be8bc ("ath9k: add back support for using active monitor interfaces for tx99")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 72569b7b 09-Oct-2018 Arnd Bergmann <arnd@arndb.de>

ath9k: fix RX_STAT_INC() etc macros

A couple of macros that deal with statistics in ath9k rely on the
declaration of the 'sc' variable, which they dereference.

However, when the statistics are disabled, the new instance in
ath_cmn_process_fft() causes a warning for an unused variable:

drivers/net/wireless/ath/ath9k/common-spectral.c: In function 'ath_cmn_process_fft':
drivers/net/wireless/ath/ath9k/common-spectral.c:474:20: error: unused variable 'sc' [-Werror=unused-variable]

It's better if those macros only operate on their arguments instead of
known variable names, and adding a cast to (void) kills off that warning.

Fixes: 03224678c013 ("ath9k: add counters for good and errorneous FFT/spectral frames")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 6df0580b 22-Sep-2018 Felix Fietkau <nbd@nbd.name>

ath9k: add back support for using active monitor interfaces for tx99

Various documented examples on how to set up tx99 with ath9k rely
on setting up a regular monitor interface for setting the channel.
My previous patch "ath9k: fix tx99 with monitor mode interface" made
it possible to set it up this way again. However, it was removing support
for using an active monitor interface, which is required for controlling
the bitrate as well, since the bitrate is not passed down with a regular
monitor interface.

This patch partially reverts the previous one, but keeps support for using
a regular monitor interface to keep documented steps working in cases
where the bitrate does not matter

Fixes: d9c52fd17cb48 ("ath9k: fix tx99 with monitor mode interface")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# d9c52fd1 20-Aug-2018 Felix Fietkau <nbd@nbd.name>

ath9k: fix tx99 with monitor mode interface

Tx99 is typically configured via a monitor mode interface, which does
not get added to the driver as a vif. Since the code currently expects
a configured virtual interface for tx99, enabling tx99 via debugfs fails.
Since the vif is not needed anyway, remove all checks for it.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
[kvalo@codeaurora.org: s/CPTCFG/CONFIG/]
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# fe041deb 18-Jun-2018 Arnd Bergmann <arnd@arndb.de>

ath9k: use timespec64 for tsf_ts

ath9k is the last remaining user of the deprecated getrawmonotonic()
interface. There is nothing wrong with this usage, but migrating
to a timespec64 based interface lets us clean up the old API.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 12b67b0d 25-May-2018 Gustavo A. R. Silva <gustavo@embeddedor.com>

ath9k: mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# d4e36e55 20-Apr-2018 Ilan Peer <ilan.peer@intel.com>

mac80211: Support adding duration for prepare_tx() callback

There are specific cases, such as SAE authentication exchange, that
might require long duration to complete. For such cases, add support
for indicating to the driver the required duration of the prepare_tx()
operation, so the driver would still be able to complete the frame
exchange.

Currently, indicate the duration only for SAE authentication exchange,
as SAE authentication can take up to 2000 msec (as defined in IEEE
P802.11-REVmd D1.0 p. 3504).

As the patch modified the prepare_tx() callback API, also modify
the relevant code in iwlwifi.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# e7881bd5 19-Dec-2017 Johannes Berg <johannes.berg@intel.com>

Revert "mac80211: Add TXQ scheduling API"

This reverts commit e937b8da5a591f141fe41aa48a2e898df9888c95.

Turns out that a new driver (mt76) is coming in through
Kalle's tree, and will conflict with this. It also has some
conflicting requirements, so we'll revisit this later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# e937b8da 30-Oct-2017 Toke Høiland-Jørgensen <toke@toke.dk>

mac80211: Add TXQ scheduling API

This adds an API to mac80211 to handle scheduling of TXQs and changes the
interface between driver and mac80211 for TXQ handling as follows:

- The wake_tx_queue callback interface no longer includes the TXQ. Instead,
the driver is expected to retrieve that from ieee80211_next_txq()

- Two new mac80211 functions are added: ieee80211_next_txq() and
ieee80211_schedule_txq(). The former returns the next TXQ that should be
scheduled, and is how the driver gets a queue to pull packets from. The
latter is called internally by mac80211 to start scheduling a queue, and
the driver is supposed to call it to re-schedule the TXQ after it is
finished pulling packets from it (unless the queue emptied).

The ath9k and ath10k drivers are changed to use the new API.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 7ac76764 24-Oct-2017 Kees Cook <keescook@chromium.org>

ath: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# ba24d63d 18-Sep-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

ath9k: Avoid a potential deadlock

Lockdep warns us that sc_pm_lock and cc_lock can cause a deadlock when
cc_lock is acquired by itself with interrupts enabled. Disable irqs
whenever taking cc_lock to avoid this.

[ 19.094524] kworker/u2:0/5 just changed the state of lock:
[ 19.094578] (&(&sc->sc_pm_lock)->rlock){-.-...}, at: [<f836c00e>] ath_isr+0x15e/0x200 [ath9k]
[ 19.094674] but this lock took another, HARDIRQ-unsafe lock in the past:
[ 19.094731] (&(&common->cc_lock)->rlock){+.-...}
[ 19.094741]

and interrupts could create inverse lock ordering between them.

[ 19.094866]
other info that might help us debug this:
[ 19.094926] Possible interrupt unsafe locking scenario:

[ 19.094985] CPU0 CPU1
[ 19.095036] ---- ----
[ 19.095086] lock(&(&common->cc_lock)->rlock);
[ 19.095197] local_irq_disable();
[ 19.095305] lock(&(&sc->sc_pm_lock)->rlock);
[ 19.095423] lock(&(&common->cc_lock)->rlock);
[ 19.095539] <Interrupt>
[ 19.095636] lock(&(&sc->sc_pm_lock)->rlock);
[ 19.095745]
*** DEADLOCK ***

[ 19.095965] 3 locks held by kworker/u2:0/5:
[ 19.096067] #0: ("%s"wiphy_name(local->hw.wiphy)){.+.+.+}, at: [<c1067f37>] process_one_work+0x127/0x580
[ 19.096260] #1: ((&local->dynamic_ps_enable_work)){+.+...}, at: [<c1067f37>] process_one_work+0x127/0x580
[ 19.096447] #2: (&sc->mutex){+.+...}, at: [<f836b8b0>] ath9k_config+0x30/0x1d0 [ath9k]
[ 19.096639]
the shortest dependencies between 2nd lock and 1st lock:
[ 19.096813] -> (&(&common->cc_lock)->rlock){+.-...} ops: 38 {
[ 19.096816] HARDIRQ-ON-W at:
[ 19.096816] __lock_acquire+0x57e/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock_bh+0x3f/0x50
[ 19.096816] ath_chanctx_set_channel+0xb6/0x2c0 [ath9k]
[ 19.096816] ath9k_config+0xa8/0x1d0 [ath9k]
[ 19.096816] ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[ 19.096816] ieee80211_do_open+0x67a/0x920 [mac80211]
[ 19.096816] ieee80211_open+0x41/0x50 [mac80211]
[ 19.096816] __dev_open+0xab/0x140
[ 19.096816] __dev_change_flags+0x89/0x150
[ 19.096816] dev_change_flags+0x28/0x60
[ 19.096816] do_setlink+0x290/0x890
[ 19.096816] rtnl_newlink+0x7cf/0x8e0
[ 19.096816] rtnetlink_rcv_msg+0xbf/0x1f0
[ 19.096816] netlink_rcv_skb+0xb9/0xe0
[ 19.096816] rtnetlink_rcv+0x1e/0x30
[ 19.096816] netlink_unicast+0x13a/0x2c0
[ 19.096816] netlink_sendmsg+0x290/0x380
[ 19.096816] ___sys_sendmsg+0x1e2/0x280
[ 19.096816] __sys_sendmsg+0x3f/0x80
[ 19.096816] SyS_socketcall+0x58c/0x6b0
[ 19.096816] do_fast_syscall_32+0x96/0x1d0
[ 19.096816] entry_SYSENTER_32+0x4c/0x7b
[ 19.096816] IN-SOFTIRQ-W at:
[ 19.096816] __lock_acquire+0x55a/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock+0x3c/0x50
[ 19.096816] ath_ps_full_sleep+0x24/0x70 [ath9k]
[ 19.096816] call_timer_fn+0xa4/0x300
[ 19.096816] run_timer_softirq+0x1b1/0x560
[ 19.096816] __do_softirq+0xb0/0x430
[ 19.096816] do_softirq_own_stack+0x33/0x40
[ 19.096816] irq_exit+0xad/0xc0
[ 19.096816] smp_apic_timer_interrupt+0x31/0x40
[ 19.096816] apic_timer_interrupt+0x37/0x3c
[ 19.096816] wp_page_copy+0xb8/0x580
[ 19.096816] do_wp_page+0x64/0x420
[ 19.096816] handle_mm_fault+0x430/0x990
[ 19.096816] __do_page_fault+0x18b/0x430
[ 19.096816] do_page_fault+0xb/0x10
[ 19.096816] common_exception+0x62/0x6a
[ 19.096816] INITIAL USE at:
[ 19.096816] __lock_acquire+0x204/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock_bh+0x3f/0x50
[ 19.096816] ath_chanctx_set_channel+0xb6/0x2c0 [ath9k]
[ 19.096816] ath9k_config+0xa8/0x1d0 [ath9k]
[ 19.096816] ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[ 19.096816] ieee80211_do_open+0x67a/0x920 [mac80211]
[ 19.096816] ieee80211_open+0x41/0x50 [mac80211]
[ 19.096816] __dev_open+0xab/0x140
[ 19.096816] __dev_change_flags+0x89/0x150
[ 19.096816] dev_change_flags+0x28/0x60
[ 19.096816] do_setlink+0x290/0x890
[ 19.096816] rtnl_newlink+0x7cf/0x8e0
[ 19.096816] rtnetlink_rcv_msg+0xbf/0x1f0
[ 19.096816] netlink_rcv_skb+0xb9/0xe0
[ 19.096816] rtnetlink_rcv+0x1e/0x30
[ 19.096816] netlink_unicast+0x13a/0x2c0
[ 19.096816] netlink_sendmsg+0x290/0x380
[ 19.096816] ___sys_sendmsg+0x1e2/0x280
[ 19.096816] __sys_sendmsg+0x3f/0x80
[ 19.096816] SyS_socketcall+0x58c/0x6b0
[ 19.096816] do_fast_syscall_32+0x96/0x1d0
[ 19.096816] entry_SYSENTER_32+0x4c/0x7b
[ 19.096816] }
[ 19.096816] ... key at: [<f837b694>] __key.61991+0x0/0xffffc96c [ath9k]
[ 19.096816] ... acquired at:
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock+0x3c/0x50
[ 19.096816] ath9k_ps_wakeup+0x85/0xe0 [ath9k]
[ 19.096816] ath9k_bss_info_changed+0x2a/0x1b0 [ath9k]
[ 19.096816] ieee80211_bss_info_change_notify+0xf3/0x360 [mac80211]
[ 19.096816] ieee80211_recalc_txpower+0x33/0x40 [mac80211]
[ 19.096816] ieee80211_set_tx_power+0x45/0x1d0 [mac80211]
[ 19.096816] cfg80211_wext_siwtxpower+0xd3/0x350 [cfg80211]
[ 19.096816] ioctl_standard_call+0x4e/0x400
[ 19.096816] wext_handle_ioctl+0xf4/0x190
[ 19.096816] dev_ioctl+0xb7/0x630
[ 19.096816] sock_ioctl+0x13e/0x2d0
[ 19.096816] do_vfs_ioctl+0x84/0x750
[ 19.096816] SyS_ioctl+0x34/0x60
[ 19.096816] do_fast_syscall_32+0x96/0x1d0
[ 19.096816] entry_SYSENTER_32+0x4c/0x7b

[ 19.096816] -> (&(&sc->sc_pm_lock)->rlock){-.-...} ops: 597 {
[ 19.096816] IN-HARDIRQ-W at:
[ 19.096816] __lock_acquire+0x6ae/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock_irqsave+0x45/0x60
[ 19.096816] ath_isr+0x15e/0x200 [ath9k]
[ 19.096816] __handle_irq_event_percpu+0x44/0x340
[ 19.096816] handle_irq_event_percpu+0x1d/0x50
[ 19.096816] handle_irq_event+0x32/0x60
[ 19.096816] handle_level_irq+0x81/0x100
[ 19.096816] handle_irq+0x9c/0xd0
[ 19.096816] do_IRQ+0x5c/0x120
[ 19.096816] common_interrupt+0x36/0x3c
[ 19.096816] _raw_spin_unlock_irqrestore+0x57/0x70
[ 19.096816] ath9k_config+0x16a/0x1d0 [ath9k]
[ 19.096816] ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[ 19.096816] ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[ 19.096816] process_one_work+0x1d1/0x580
[ 19.096816] worker_thread+0x31/0x380
[ 19.096816] kthread+0xd9/0x110
[ 19.096816] ret_from_fork+0x19/0x24
[ 19.096816] IN-SOFTIRQ-W at:
[ 19.096816] __lock_acquire+0x55a/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock_irqsave+0x45/0x60
[ 19.096816] ath9k_ps_wakeup+0x24/0xe0 [ath9k]
[ 19.096816] ath9k_tasklet+0x42/0x260 [ath9k]
[ 19.096816] tasklet_action+0x196/0x1e0
[ 19.096816] __do_softirq+0xb0/0x430
[ 19.096816] do_softirq_own_stack+0x33/0x40
[ 19.096816] irq_exit+0xad/0xc0
[ 19.096816] do_IRQ+0x65/0x120
[ 19.096816] common_interrupt+0x36/0x3c
[ 19.096816] get_page_from_freelist+0x20a/0x970
[ 19.096816] __alloc_pages_nodemask+0xca/0xed0
[ 19.096816] __get_free_pages+0x14/0x30
[ 19.096816] pgd_alloc+0x1d/0x160
[ 19.096816] mm_init.isra.47+0x13a/0x1b0
[ 19.096816] copy_process.part.54+0xb55/0x1700
[ 19.096816] _do_fork+0xd4/0x6a0
[ 19.096816] SyS_clone+0x27/0x30
[ 19.096816] do_fast_syscall_32+0x96/0x1d0
[ 19.096816] entry_SYSENTER_32+0x4c/0x7b
[ 19.096816] INITIAL USE at:
[ 19.096816] __lock_acquire+0x204/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock_irqsave+0x45/0x60
[ 19.096816] ath9k_ps_wakeup+0x24/0xe0 [ath9k]
[ 19.096816] ath9k_start+0x29/0x1f0 [ath9k]
[ 19.096816] drv_start+0x71/0x270 [mac80211]
[ 19.096816] ieee80211_do_open+0x31f/0x920 [mac80211]
[ 19.096816] ieee80211_open+0x41/0x50 [mac80211]
[ 19.096816] __dev_open+0xab/0x140
[ 19.096816] __dev_change_flags+0x89/0x150
[ 19.096816] dev_change_flags+0x28/0x60
[ 19.096816] do_setlink+0x290/0x890
[ 19.096816] rtnl_newlink+0x7cf/0x8e0
[ 19.096816] rtnetlink_rcv_msg+0xbf/0x1f0
[ 19.096816] netlink_rcv_skb+0xb9/0xe0
[ 19.096816] rtnetlink_rcv+0x1e/0x30
[ 19.096816] netlink_unicast+0x13a/0x2c0
[ 19.096816] netlink_sendmsg+0x290/0x380
[ 19.096816] ___sys_sendmsg+0x1e2/0x280
[ 19.096816] __sys_sendmsg+0x3f/0x80
[ 19.096816] SyS_socketcall+0x58c/0x6b0
[ 19.096816] do_fast_syscall_32+0x96/0x1d0
[ 19.096816] entry_SYSENTER_32+0x4c/0x7b
[ 19.096816] }
[ 19.096816] ... key at: [<f837b67c>] __key.61994+0x0/0xffffc984 [ath9k]
[ 19.096816] ... acquired at:
[ 19.096816] check_usage_forwards+0x118/0x120
[ 19.096816] mark_lock+0x2e4/0x590
[ 19.096816] __lock_acquire+0x6ae/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] _raw_spin_lock_irqsave+0x45/0x60
[ 19.096816] ath_isr+0x15e/0x200 [ath9k]
[ 19.096816] __handle_irq_event_percpu+0x44/0x340
[ 19.096816] handle_irq_event_percpu+0x1d/0x50
[ 19.096816] handle_irq_event+0x32/0x60
[ 19.096816] handle_level_irq+0x81/0x100
[ 19.096816] handle_irq+0x9c/0xd0
[ 19.096816] do_IRQ+0x5c/0x120
[ 19.096816] common_interrupt+0x36/0x3c
[ 19.096816] _raw_spin_unlock_irqrestore+0x57/0x70
[ 19.096816] ath9k_config+0x16a/0x1d0 [ath9k]
[ 19.096816] ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[ 19.096816] ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[ 19.096816] process_one_work+0x1d1/0x580
[ 19.096816] worker_thread+0x31/0x380
[ 19.096816] kthread+0xd9/0x110
[ 19.096816] ret_from_fork+0x19/0x24

[ 19.096816]
stack backtrace:
[ 19.096816] CPU: 0 PID: 5 Comm: kworker/u2:0 Not tainted 4.13.0-mgm-ovl+ #51
[ 19.096816] Hardware name: FUJITSU SIEMENS LIFEBOOK S6120/FJNB16C, BIOS Version 1.26 05/10/2004
[ 19.096816] Workqueue: phy0 ieee80211_dynamic_ps_enable_work [mac80211]
[ 19.096816] Call Trace:
[ 19.096816] <IRQ>
[ 19.096816] dump_stack+0x16/0x19
[ 19.096816] print_irq_inversion_bug.part.37+0x16c/0x179
[ 19.096816] check_usage_forwards+0x118/0x120
[ 19.096816] ? ret_from_fork+0x19/0x24
[ 19.096816] ? print_shortest_lock_dependencies+0x1a0/0x1a0
[ 19.096816] mark_lock+0x2e4/0x590
[ 19.096816] ? print_shortest_lock_dependencies+0x1a0/0x1a0
[ 19.096816] __lock_acquire+0x6ae/0x1260
[ 19.096816] lock_acquire+0xb1/0x1c0
[ 19.096816] ? ath_isr+0x15e/0x200 [ath9k]
[ 19.096816] _raw_spin_lock_irqsave+0x45/0x60
[ 19.096816] ? ath_isr+0x15e/0x200 [ath9k]
[ 19.096816] ath_isr+0x15e/0x200 [ath9k]
[ 19.096816] __handle_irq_event_percpu+0x44/0x340
[ 19.096816] handle_irq_event_percpu+0x1d/0x50
[ 19.096816] handle_irq_event+0x32/0x60
[ 19.096816] ? handle_nested_irq+0x100/0x100
[ 19.096816] handle_level_irq+0x81/0x100
[ 19.096816] handle_irq+0x9c/0xd0
[ 19.096816] </IRQ>
[ 19.096816] do_IRQ+0x5c/0x120
[ 19.096816] common_interrupt+0x36/0x3c
[ 19.096816] EIP: _raw_spin_unlock_irqrestore+0x57/0x70
[ 19.096816] EFLAGS: 00000286 CPU: 0
[ 19.096816] EAX: f60a3600 EBX: 00000286 ECX: 00000006 EDX: 00000001
[ 19.096816] ESI: f46c9e68 EDI: f46c8620 EBP: f60b5e8c ESP: f60b5e84
[ 19.096816] DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
[ 19.096816] ath9k_config+0x16a/0x1d0 [ath9k]
[ 19.096816] ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[ 19.096816] ? ieee80211_hw_config+0x1db/0x5f0 [mac80211]
[ 19.096816] ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[ 19.096816] ? process_one_work+0x127/0x580
[ 19.096816] ? process_one_work+0x127/0x580
[ 19.096816] process_one_work+0x1d1/0x580
[ 19.096816] ? process_one_work+0x127/0x580
[ 19.096816] worker_thread+0x31/0x380
[ 19.096816] kthread+0xd9/0x110
[ 19.096816] ? process_one_work+0x580/0x580
[ 19.096816] ? kthread_create_on_node+0x30/0x30
[ 19.096816] ret_from_fork+0x19/0x24

Cc: QCA ath9k Development <ath9k-devel@qca.qualcomm.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 50c8cd44 31-Aug-2017 Himanshu Jha <himanshujha199640@gmail.com>

ath9k: remove cast to void pointer

casting to void pointer from any pointer type and vice-versa is done
implicitly and therefore casting is not needed in such a case.

Done using Coccinellle.
Semantic Patch used :

@r@
expression x;
void* e;
type T;
identifier f;
@@

(
*((T *)e)
|
((T *)x)[...]
|
((T *)x)->f
|
- (T *)
e
)


Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# f23cdfb3 27-Jun-2017 Miaoqing Pan <miaoqing@codeaurora.org>

ath9k: Use mutex_lock to avoid potential race in start/stop rng

Move ath9k_rng_stop/ath9k_rng_start pair into critical section,
use mutex_lock to void potential race accessing.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 3a5e969b 02-Feb-2017 Felix Fietkau <nbd@nbd.name>

ath9k: fix race condition in enabling/disabling IRQs

The code currently relies on refcounting to disable IRQs from within the
IRQ handler and re-enabling them again after the tasklet has run.

However, due to race conditions sometimes the IRQ handler might be
called twice, or the tasklet may not run at all (if interrupted in the
middle of a reset).

This can cause nasty imbalances in the irq-disable refcount which will
get the driver permanently stuck until the entire radio has been stopped
and started again (ath_reset will not recover from this).

Instead of using this fragile logic, change the code to ensure that
running the irq handler during tasklet processing is safe, and leave the
refcount untouched.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# d63ffc45 02-Feb-2017 Felix Fietkau <nbd@nbd.name>

ath9k: rename tx_complete_work to hw_check_work

Also include common MAC alive check. This should make the hang checks
more reliable for modes where beacons are not sent and is used as a
starting point for further hang check improvements

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 63fefa05 05-Dec-2016 Toke Høiland-Jørgensen <toke@toke.dk>

ath9k: Introduce airtime fairness scheduling between stations

This reworks the ath9k driver to schedule transmissions to connected
stations in a way that enforces airtime fairness between them. It
accomplishes this by measuring the time spent transmitting to or
receiving from a station at TX and RX completion, and accounting this to
a per-station, per-QoS level airtime deficit. Then, an FQ-CoDel based
deficit scheduler is employed at packet dequeue time, to control which
station gets the next transmission opportunity.

Airtime fairness can significantly improve the efficiency of the network
when station rates vary. The following throughput values are from a
simple three-station test scenario, where two stations operate at the
highest HT20 rate, and one station at the lowest, and the scheduler is
employed at the access point:

Before / After
Fast station 1: 19.17 / 25.09 Mbps
Fast station 2: 19.83 / 25.21 Mbps
Slow station: 2.58 / 1.77 Mbps
Total: 41.58 / 52.07 Mbps

The benefit of airtime fairness goes up the more stations are present.
In a 30-station test with one station artificially limited to 1 Mbps,
we have seen aggregate throughput go from 2.14 to 17.76 Mbps.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 50f08edf 08-Nov-2016 Toke Høiland-Jørgensen <toke@toke.dk>

ath9k: Switch to using mac80211 intermediate software queues.

This switches ath9k over to using the mac80211 intermediate software
queueing mechanism for data packets. It removes the queueing inside the
driver, except for the retry queue, and instead pulls from mac80211 when
a packet is needed. The retry queue is used to store a packet that was
pulled but can't be sent immediately.

The old code path in ath_tx_start that would queue packets has been
removed completely, as has the qlen limit tunables (since there's no
longer a queue in the driver to limit).

The mac80211 intermediate software queues offer significant latency
reductions, and this patch allows ath9k to realise them. The exact gains
from this varies with the test scenario, but in an access point scenario
we have seen latency reductions ranging from 1/3 to as much as an order
of magnitude. We also achieve slightly better aggregation.

Median latency (ping) figures with this patch applied at the access point,
with two high-rate stations and one low-rate station (HT20 5Ghz), running
a Flent rtt_fair_var_up test with one TCP flow and one ping flow going to
each station:

Fast station Slow station
Default pfifo_fast qdisc: 430.4 ms 638.7 ms
fq_codel qdisc on iface: 35.5 ms 211.8 ms
This patch set: 22.4 ms 38.2 ms

Median aggregation sizes over the same test:

Default pfifo_fast qdisc: 9.5 pkts 1.9 pkts
fq_codel qdisc on iface: 11.2 pkts 1.9 pkts
This patch set: 13.9 pkts 1.9 pkts

This patch is based on Tim's original patch set, but reworked quite
thoroughly.

Cc: Tim Shepard <shep@alum.mit.edu>
Cc: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# e34f2ff4 01-Sep-2016 Giedrius Statkevičius <giedrius.statkevicius@gmail.com>

ath9k: bring back direction setting in ath9k_{start_stop}

A regression was introduced in commit id 79d4db1214a ("ath9k: cleanup
led_pin initial") that broken the WLAN status led on my laptop with
AR9287 after suspending and resuming.

Steps to reproduce:
* Suspend (laptop)
* Resume (laptop)
* Observe that the WLAN led no longer turns ON/OFF depending on the
status and is always red

Even though for my case it only needs to be set to OUT in ath9k_start
but for consistency bring back the IN direction setting as well.

Fixes: 79d4db1214a0 ("ath9k: cleanup led_pin initial")
Cc: Miaoqing Pan <miaoqing@codeaurora.org>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: <stable@vger.kernel.org> # 4.7+
Link: https://bugzilla.kernel.org/show_bug.cgi?id=151711
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
[kvalo@qca.qualcomm.com: improve commit log]
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 7711aaf0 19-Aug-2016 Felix Fietkau <nbd@nbd.name>

ath9k: fix using sta->drv_priv before initializing it

A station pointer can be passed to the driver on tx, before it has been
marked as associated. Since ath9k_sta_state was initializing the entry
too late, it resulted in some spurious crashes.

Fixes: df3c6eb34da5 ("ath9k: Use sta_state() callback")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 05860bed 19-Aug-2016 Felix Fietkau <nbd@nbd.name>

ath9k: fix client mode beacon configuration

For pure station mode, iter_data.primary_beacon_vif was used and passed
to ath_beacon_config, but not set to the station vif.
This was causing the following warning:

[ 100.310919] ------------[ cut here ]------------
[ 100.315683] WARNING: CPU: 0 PID: 7 at compat-wireless-2016-06-20/drivers/net/wireless/ath/ath9k/beacon.c:642 ath9k_calculate_summary_state+0x250/0x60c [ath9k]()
[ 100.402028] CPU: 0 PID: 7 Comm: kworker/u2:1 Tainted: G W 4.4.15 #5
[ 100.409676] Workqueue: phy0 ieee80211_ibss_leave [mac80211]
[ 100.415351] Stack : 8736e98c 870b4b20 87a25b54 800a6800 8782a080 80400d63 8039b96c 00000007
[ 100.415351] 803c5edc 87875914 80400000 800a47cc 87a25b54 800a6800 803a0fd8 80400000
[ 100.415351] 00000003 87875914 80400000 80094ae0 87a25b54 8787594c 00000000 801ef308
[ 100.415351] 803ffe70 801ef300 87193d58 87b3a400 87b3ad00 70687930 00000000 00000000
[ 100.415351] 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 100.415351] ...
[ 100.451703] Call Trace:
[ 100.454235] [<800a6800>] vprintk_default+0x24/0x30
[ 100.459110] [<800a47cc>] printk+0x2c/0x38
[ 100.463190] [<800a6800>] vprintk_default+0x24/0x30
[ 100.468072] [<80094ae0>] print_worker_info+0x148/0x174
[ 100.473378] [<801ef308>] serial8250_console_putchar+0x0/0x44
[ 100.479122] [<801ef300>] wait_for_xmitr+0xc4/0xcc
[ 100.484014] [<87193d58>] ieee80211_ibss_leave+0xb90/0x1900 [mac80211]
[ 100.490590] [<80081604>] warn_slowpath_common+0xa0/0xd0
[ 100.495922] [<801a359c>] dump_stack+0x14/0x28
[ 100.500350] [<80071a00>] show_stack+0x50/0x84
[ 100.504784] [<80081604>] warn_slowpath_common+0xa0/0xd0
[ 100.510106] [<87024c60>] ath9k_calculate_summary_state+0x250/0x60c [ath9k]
[ 100.517105] [<800816b8>] warn_slowpath_null+0x18/0x24
[ 100.522256] [<87024c60>] ath9k_calculate_summary_state+0x250/0x60c [ath9k]
[ 100.529273] [<87025418>] ath9k_set_txpower+0x148/0x498 [ath9k]
[ 100.535302] [<871d2c64>] cleanup_module+0xa74/0xd4c [mac80211]
[ 100.541237] [<801ef308>] serial8250_console_putchar+0x0/0x44
[ 100.547042] [<800a5d18>] wake_up_klogd+0x54/0x68
[ 100.551730] [<800a6650>] vprintk_emit+0x404/0x43c
[ 100.556623] [<871b9db8>] ieee80211_sta_rx_notify+0x258/0x32c [mac80211]
[ 100.563475] [<871ba6a4>] ieee80211_sta_rx_queued_mgmt+0x63c/0x734 [mac80211]
[ 100.570693] [<871aa49c>] ieee80211_tx_prepare_skb+0x210/0x230 [mac80211]
[ 100.577609] [<800af5d4>] mod_timer+0x15c/0x190
[ 100.582220] [<871ba8b8>] ieee80211_sta_work+0xfc/0xe1c [mac80211]
[ 100.588539] [<871940b4>] ieee80211_ibss_leave+0xeec/0x1900 [mac80211]
[ 100.595122] [<8009ec84>] dequeue_task_fair+0x44/0x130
[ 100.600281] [<80092a34>] process_one_work+0x1f8/0x334
[ 100.605454] [<80093830>] worker_thread+0x2b4/0x408
[ 100.610317] [<8009357c>] worker_thread+0x0/0x408
[ 100.615019] [<8009357c>] worker_thread+0x0/0x408
[ 100.619705] [<80097b68>] kthread+0xdc/0xe8
[ 100.623886] [<80097a8c>] kthread+0x0/0xe8
[ 100.627961] [<80060878>] ret_from_kernel_thread+0x14/0x1c
[ 100.633448]
[ 100.634956] ---[ end trace aafbe57e9ae6862f ]---

Fixes: cfda2d8e2314 ("ath9k: Fix beacon configuration for addition/removal of interfaces")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 4c51e7db 18-Aug-2016 Bob Copeland <me@bobcopeland.com>

ath9k: fix misleading indent

Fixes smatch warning:

ath9k_vif_iter_set_beacon() warn if statement not indented

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 97f2645f 03-Aug-2016 Masahiro Yamada <yamada.masahiro@socionext.com>

tree-wide: replace config_enabled() with IS_ENABLED()

The use of config_enabled() against config options is ambiguous. In
practical terms, config_enabled() is equivalent to IS_BUILTIN(), but the
author might have used it for the meaning of IS_ENABLED(). Using
IS_ENABLED(), IS_BUILTIN(), IS_MODULE() etc. makes the intention
clearer.

This commit replaces config_enabled() with IS_ENABLED() where possible.
This commit is only touching bool config options.

I noticed two cases where config_enabled() is used against a tristate
option:

- config_enabled(CONFIG_HWMON)
[ drivers/net/wireless/ath/ath10k/thermal.c ]

- config_enabled(CONFIG_BACKLIGHT_CLASS_DEVICE)
[ drivers/gpu/drm/gma500/opregion.c ]

I did not touch them because they should be converted to IS_BUILTIN()
in order to keep the logic, but I was not sure it was the authors'
intention.

Link: http://lkml.kernel.org/r/1465215656-20569-1-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Stas Sergeev <stsp@list.ru>
Cc: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: Joshua Kinard <kumba@gentoo.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: yu-cheng yu <yu-cheng.yu@intel.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Will Drewry <wad@chromium.org>
Cc: Nikolay Martynov <mar.kolya@gmail.com>
Cc: Huacai Chen <chenhc@lemote.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Cc: Rafal Milecki <zajec5@gmail.com>
Cc: James Cowgill <James.Cowgill@imgtec.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Alex Smith <alex.smith@imgtec.com>
Cc: Adam Buchbinder <adam.buchbinder@gmail.com>
Cc: Qais Yousef <qais.yousef@imgtec.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Tony Wu <tung7970@gmail.com>
Cc: Huaitong Han <huaitong.han@intel.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrea Gelmini <andrea.gelmini@gelma.net>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Rabin Vincent <rabin@rab.in>
Cc: "Maciej W. Rozycki" <macro@imgtec.com>
Cc: David Daney <david.daney@cavium.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# cfda2d8e 04-Jul-2016 Benjamin Berg <benjamin.berg@open-mesh.com>

ath9k: Fix beacon configuration for addition/removal of interfaces

This patch fixes some issues with interface reconfiguration. It could
for example happen that an AP interface in beacon slot 0 was removed
leaving an IBSS station in one of the other slots. When this happens
the driver never sends out the beacon as it only tries to send a beacon
from slot 0.

Appart from that the tracking of required changes to the beacon config is
relatively complicated and prone to errors.

The approach taken here is to solve reconfiguration issues is to
reconfigure the beacons when any interface changes. This means that
the complexity of deciding whether an interface change may modify the
beacon configuration is gone. It also means that the beacon config will
be reliably updated when an interface is removed.

The issue that a single non-AP interface might not be in beacon
slot 0 and wouldn't be send out is solved by moving it into the
first slot. The TSF value in hardware is adjusted accordingly so
that the timestamp of the beacons stay consistent.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 11b0ac2e 04-Jul-2016 Benjamin Berg <benjamin.berg@open-mesh.com>

ath9k: Remove some #defined constants to decrease verbosity

The removed ATH9K_SLOT_TIME_X constants simply map the value in microseconds
to the same integer. These constants were not used consistently, so fix the
inconsistency issue by replacing all occurances with the integer equivalent.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 7fde5122 04-Jul-2016 Benjamin Berg <benjamin.berg@open-mesh.com>

ath9k: Expose tsf_adjustment in mac80211 tsf getters and setters.

The ath9k driver modifies the TSF for VIFs for the purpose of sending
beacons in a staggered fashion. This patch exposes this VIF specific
adjustment of the TSF value to mac80211. Without the change the TSF
routines handle the hardware TSF value instead of the actual TSF value as
seen on the air.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 9580cb88 04-Jul-2016 Benjamin Berg <benjamin.berg@open-mesh.com>

ath9k: Handle channel context in get_/set_/reset_tsf

The ath9k TSF handling routines need to be aware of the channel context that
is being modified. With this change the TSF related values that are stored
in each channel context will be correctly tracked and the harware will only
be updated if the modified context is currently the active one.

Without this change the TSF modifications done using these routines would
for example be lost during a hardware reset as done by ath_complete_reset.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 57fbcce3 12-Apr-2016 Johannes Berg <johannes.berg@intel.com>

cfg80211: remove enum ieee80211_band

This enum is already perfectly aliased to enum nl80211_band, and
the only reason for it is that we get IEEE80211_NUM_BANDS out of
it. There's no really good reason to not declare the number of
bands in nl80211 though, so do that and remove the cfg80211 one.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 79d4db12 06-Mar-2016 Miaoqing Pan <miaoqing@codeaurora.org>

ath9k: cleanup led_pin initial

Make ath_init_leds() and ath_deinit_leds() pairs as the only
API to set leds, also removed direction configuration from
ath9k_start() and ath9k_stop(). So the initial is more clear
now.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# b2d70d49 06-Mar-2016 Miaoqing Pan <miaoqing@codeaurora.org>

ath9k: make GPIO API to support both of WMAC and SOC

commit 61b559dea40e ("ath9k: add extra GPIO led support")
added ath9k to support access SOC's GPIOs, but implemented
in a separated API: ath9k_hw_request_gpio().

So this patch make the APIs more common, to support both
of WMAC and SOC GPIOs. The new APIs as below,

void ath9k_hw_gpio_request_in();
void ath9k_hw_gpio_request_out();
void ath9k_hw_gpio_free();

NOTE, the BSP of the SOC chips(AR9340, AR9531, AR9550, AR9561)
should set the corresponding MUX registers correctly.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# b9a9693f 27-Nov-2015 Kalle Valo <Janusz.Dziedzic@tieto.com>

ath9k: request NOA update when chanctx active

Request NOA update when chanctx active, also in case
of STA.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 50ea05ef 30-Dec-2015 Sara Sharon <sarasharon1@gmail.com>

mac80211: pass block ack session timeout to to driver

Currently mac80211 does not inform the driver of the session
block ack timeout when starting a rx aggregation session.
Drivers that manage the reorder buffer need to know this
parameter.
Seeing that there are now too many arguments for the
drv_ampdu_action() function, wrap them inside a structure.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# ed14dc0a 09-Oct-2015 Miaoqing Pan <miaoqing@codeaurora.org>

ath9k: feeding entropy in kernel from ADC capture

This patch is derived from
commit 6301566e0b2d ("ath9k: export HW random number generator"),

We evaluated the entropy of the ADC data on QCA9531, QCA9561, QCA955x,
and AR9340, and it has sufficient quality random data (at least 10 bits
and up to 22 bits of min-entropy for a 32-bit value). We conservatively
assume the min-entropy is 10 bits out of 32 bits. Thus, ATH9K_RNG_BUF_SIZE
is set to 320 (u32) i.e., 1.25 kilobytes of data is inserted to fill up
the pool as soon as the entropy counter becomes 896/4096 (set by random.c).
Since ADC was not designed to be a dedicated HW RNG, we do not want to bind
it to /dev/hwrng framework directly. This patch feeds the entropy directly
from the WiFi driver to the input pool. The ADC register output is only
used as a seed for the Linux entropy pool. No conditioning is needed,
since all the conditioning is performed by the pool itself.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 862a336c 17-Sep-2015 Jan Kaisrlik <kaisrja1@fel.cvut.cz>

ath9k: Add support for OCB mode

The patch adds support for "outside the context of a BSS"(OCB) mode
to ath9k driver and extends debugfs files by OCB ralated information.

This patch was tested on AR9380-AL1A cards.

Signed-off-by: Jan Kaisrlik <kaisrja1@fel.cvut.cz>
Cc: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# e3abc8ff 16-Aug-2015 Emmanuel Grumbach <emmanuel.grumbach@intel.com>

mac80211: allow to transmit A-MSDU within A-MPDU

Advertise the capability to send A-MSDU within A-MPDU
in the AddBA request sent by mac80211. Let the driver
know about the peer's capabilities.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 1738203e 21-Jul-2015 Janusz.Dziedzic@tieto.com <Janusz.Dziedzic@tieto.com>

ath9k: setup rxfilter when offchannel

Setup rxfiler correctly for offchannel ctx.

This fix problem we didn't configure rxfilter, next
didn't receive probe requests and next failed
p2p_find. This was seen when ath9k loaded with
use_chanctx=1

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# f3771c08 21-Jul-2015 Janusz.Dziedzic@tieto.com <Janusz.Dziedzic@tieto.com>

ath9k: setup rxfilter for all chanctx

While mac80211 setup this per HW, set same
rxfilter configuration for all chanctx.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# d83520b7 21-Jul-2015 Janusz.Dziedzic@tieto.com <Janusz.Dziedzic@tieto.com>

ath9k: handle RoC cancel correctly

In case we will get ROC cancel from mac80211 we
should not call ieee80211_remain_on_channel_expired().

In other case I hit such warning on MIPS and
p2p negotiation failed (tested with use_chanctx=1).

ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506632
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: Stopping current chanctx: 2412
ath: phy0: Flush timeout: 200
ath: phy0: ath_chanctx_set_next: Set channel 2412 MHz
ath: phy0: Set channel: 2412 MHz width: 0
ath: phy0: Reset to 2412 MHz, HT40: 0 fastcc: 0
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_TSF_TIMER, state: ATH_CHANCTX_STATE_IDLE
ath: phy0: ath_offchannel_channel_change: offchannel state: ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: ATH_CHANCTX_STATE_IDLE
ath: phy0: Cancel RoC
ath: phy0: RoC aborted
ath: phy0: RoC request on vif: 00:03:7f:4e:a0:cd, type: 1 duration: 500
ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506705
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: ath_offchannel_channel_change: offchannel state: ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: ATH_CHANCTX_STATE_IDLE
------------[ cut here ]------------
WARNING: CPU: 0 PID: 3312 at drivers/net/wireless/ath/ath9k/main.c:2319
Modules linked in: ath9k ath9k_common ath9k_hw ath mac80211 cfg80211

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 360d9bb5 31-Jul-2015 Kalle Valo <kvalo@codeaurora.org>

Revert "ath9k: export HW random number generator"

This reverts commit 6301566e0b2dafa7d6779598621bca867962a0a2. Oleksij Rempel
noticed that the randomness doesn't look to be good enough and Stephan Mueller
commented:

"I would say that the discussed RNG does not seem fit for hooking it up with the
hwrandom framework."

http://lkml.kernel.org/g/3945775.m5HblJPgiO@tauon.atsec.com

So let's the revert the patch until we are sure that we can trust this random
generator.

Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 6301566e 15-Jul-2015 Miaoqing Pan <miaoqing@qca.qualcomm.com>

ath9k: export HW random number generator

We measured the FFT-based entropy in 3 ways, Shannon entropy,
collision entropy, and directly measured min-entropy. Just to
be conservative, we recommend the estimated min-Entropy to be
10 bits per 16-bit value.

Analysis was done by Jacobson,David(djacobso@qti.qualcomm.com).

Signed-off-by: Miaoqing Pan <miaoqing@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 300f77c0 02-Jun-2015 Felix Fietkau <nbd@openwrt.org>

ath9k: fix DMA stop sequence for AR9003+

AR93xx and newer needs to stop rx before tx to avoid getting the DMA
engine or MAC into a stuck state.
This should reduce/fix the occurence of "Failed to stop Tx DMA" logspam.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# df140465 22-Apr-2015 Johannes Berg <johannes.berg@intel.com>

mac80211: remove support for IFF_PROMISC

This support is essentially useless as typically networks are encrypted,
frames will be filtered by hardware, and rate scaling will be done with
the intended recipient in mind. For real monitoring of the network, the
monitor mode support should be used instead.

Removing it removes a lot of corner cases.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 93803b33 02-Mar-2015 Joe Perches <joe@perches.com>

wireless: Use eth_<foo>_addr instead of memset

Use the built-in function instead of memset.

Miscellanea:

Add #include <linux/etherdevice.h> where appropriate
Use ETH_ALEN instead of 6

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 283dd119 17-Feb-2015 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: add per-vif TX power capability

Configure the HW with highest TX power among all vif when HW TPC has been
enabled in order to add support to per-vif TX power capability. Use lowest
configured power among all interfaces when TPC is disabled

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# c4d0975b 30-Jan-2015 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove unused BMISS processing

The various variables tracking bmiss interrupts
are not really used anywhere except in a debug
message. Remove them since they have no functional
purpose.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# e3f31175 14-Jan-2015 Felix Fietkau <nbd@openwrt.org>

ath9k: fix race condition in irq processing during hardware reset

To fix invalid hardware accesses, the commit 872b5d814f99 ("ath9k: do not
access hardware on IRQs during reset") made the irq handler ignore interrupts
emitted after queueing a hardware reset (which disables the IRQ). This left a
small time window for the IRQ to get re-enabled by the tasklet, which caused
IRQ storms. Instead of returning IRQ_NONE when ATH_OP_HW_RESET is set, disable
the IRQ entirely for the duration of the reset.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 872b5d81 30-Nov-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: do not access hardware on IRQs during reset

Instead of killing interrupts during reset when the first one happens,
kill them before issuing the reset.
This fixes an easy to reproduce crash with multiple cards sharing the
same IRQ.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ef739ab6 30-Nov-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: set ATH_OP_INVALID before disabling hardware

Closes another small IRQ handler race

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a344d677 12-Jun-2014 Johannes Berg <johannes.berg@intel.com>

mac80211: allow drivers to support NL80211_SCAN_FLAG_RANDOM_ADDR

Allow drivers to support NL80211_SCAN_FLAG_RANDOM_ADDR with software
based scanning and generate a random MAC address for them for every
scan request with the flag.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 2c3634a8 15-Nov-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Handle failure to send NoA

If for some reason a beacon with a new NoA is
not sent out, then reset the mgd_prepare_tx flag.
Not doing this will result in a situation where
a GO will send a new NoA when it shouldn't.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6185672a 15-Nov-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cancel pending offchannel operations

This patch makes sure that pending roc/scan
operations are cancelled properly when a new
context is assigned/unassigned.

The flush_work() call to flush out any scheduled
channel context work is removed, instead, sc->mutex
is dropped to allow any pending work to get a chance
to complete by the channel scheduler. Also, increase
the timeout to allow a switch to an active GO.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aeeb2065 15-Nov-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix LED configuration

On some x86 platforms, the LED gpio is active high
instead of active low. Identify such cards and modify
the GPIO usage to make sure LED works properly.

Cc: Russell Hu <rhu@qca.qualcomm.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e6510b11 15-Nov-2014 Chun-Yeow Yeoh <yeohchunyeow@gmail.com>

ath9k|ath9k_htc: Seperate the software crypto flag for Tx and Rx

Use the sw_mgmt_crypto_tx flag to trigger the CCMP encryption
for transmitted management frames to be done in software while
the sw_mgmt_crypto_rx flag is used to trigger the CCMP decryption
for received management frames to be done in software.

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4b870c26 12-Nov-2014 Chun-Yeow Yeoh <yeohchunyeow@gmail.com>

ath9k: fix the assignment of hw queues for mesh interface

We need to assign the hw queues for mesh interface. Otherwise,
we are not able to bring up the mesh interface due to the
IEEE80211_INVAL_HW_QUEUE error.

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# daad1660 04-Nov-2014 Ben Greear <greearb@candelatech.com>

ath9k: fix regression in bssidmask calculation

The commit that went into 3.17:

ath9k: Summarize hw state per channel context

Group and set hw state (opmode, primary_sta, beacon conf) per
channel context instead of whole list of vifs. This would allow
each channel context to run in different mode (STA/AP).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

broke multi-vif configuration due to not properly calculating
the bssid mask.

The test case that caught this was:

create wlan0 and sta0-4 (6 total), not sure how much that matters.
associate all 6 (works fine)
disconnect 5 of them, leaving sta0 up
Start trying to bring up the other 5 one at a time. It will
fail, with iw events looking like this (in these logs, several
sta are trying to come up, but symptom is the same with just one)

The patch causing the regression made quite a few changes, but
the part I think caused this particular problem was not
recalculating the bssid mask when adding and removing interfaces.

Re-adding those calls fixes my test case. Fix bad comment
as well.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f00a422c 06-Nov-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move ath9k_spectral_scan_ from main.c to spectral.c

Now we should be ready to make this code common.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 963916df 06-Nov-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: make ath9k_spectral_scan_ do not depend on ath_softc

last preparation before moving ath9k_spectral_scan_ to spectral.c

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ef948da5 06-Nov-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: use ath_common instead of ieee80211_hw in ath9k_spectral_scan_

we don't have here any ieee80211_hw dependencies any way.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 934bdc73 06-Nov-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: use ath_ps_ops in ath9k_spectral_scan_

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 21af25d0 06-Nov-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move spec_config to ath_spec_scan_priv

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8391f601 06-Nov-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move spectral_mode to ath_spec_scan_priv

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d385c5c2 04-Nov-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: add support for reporting tx power to mac80211

Track it per channel context instead of in the softc

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3b580144 25-Oct-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: fix processing RXORN interrupts

The "goto chip_reset" is a bit misleading, because it does not actually
issue a chip reset. Instead it is bypassing processing of other
interrupts and assumes that the tasklet will issue a chip reset.

In the case of RXORN this does not happen, so bypassing processing of
other interrupts will simply allow them to fire again. Even if RXORN
was triggering a reset, it is not critical enough to need the bypass
here.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1e929d3e 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Do not start BA when scanning

mac80211 currently has a race which can be hit
with this sequence:

* Start a scan operation.
* TX BA is initiated by ieee80211_start_tx_ba_session().
* Driver sets up internal state and calls
ieee80211_start_tx_ba_cb_irqsafe().
* mac80211 adds a packet to sdata->skb_queue with
type IEEE80211_SDATA_QUEUE_AGG_START.
* ieee80211_iface_work() doesn't process the
packet because scan is in progress.
* ADDBA response timer expires and the sta/tid is
torn down.
* Driver receives BA stop notification and calls
ieee80211_stop_tx_ba_cb_irqsafe().
* This is also added to the queue by mac80211.
* Now, scan finishes.

At this point, the queued up packets might be processed
if some other operation schedules the sdata work. Since
the tids have been cleaned up already, warnings are hit.

If this doesn't happen, the packets are left in the queue
until the interface is torn down.

Since initiating a BA session when scan is in progress
leads to flaky connections, especially in MCC mode, we
can drop the TX BA request. This improves connectivity
with legacy clients in MCC mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 25f3bc7d 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Improve flush() in mcc mode

The flush timeout in MCC mode is very small, since
we are constrained by the time slice for each
channel context, but since only the HW queues are
flushed when switching contexts, it is acceptable.

Since the SW queues are also emptied in the mac80211 flush()
callback, a larger duration is needed. Add an override
argument to __ath9k_flush() and set it when flush()
is called in MCC mode. This allows the driver to
drain both the SW and HW queues.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 23aab0c2 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix HW scan abort

Instead of using ATH_CHANCTX_EVENT_ASSIGN to abort
a HW scan when a new interface becomes active, use the
mgd_prepare_tx() callback. This allows us to make
sure that the GO's channel becomes operational by
using flush_work().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c6500ea2 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Check for active GO in mgd_prepare_tx()

If a GO interface is active when we receive a
mgd_prepare_tx() call, then we need to send
out a new NoA before switching to a new context.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 62ae1aef 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix address management

Since both the arguments need to satisfy
the alignment requirements of ether_addr_copy(),
use memcpy() in cases where there will be no
big performance benefit and make sure that
ether_addr_copy() calls use properly aligned
arguments.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 91e6ceb3 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Send AUTHORIZED event only for station mode

ATH_CHANCTX_EVENT_AUTHORIZED is required to trigger
the MCC scheduler when a station interface becomes
authorized. But, since the driver gets station state
notifications when the current operating mode is AP
too, make sure that we send ATH_CHANCTX_EVENT_AUTHORIZED
only when the interface is in station mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e2d389b5 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Check for pending frames properly

Pending frames in the driver can be present
either in the HW queues or SW. ath9k_has_pending_frames()
currently checks for the HW queues first and then
checks if any ACs are queued in the driver.

In MCC mode, we need to check the HW queues alone, since
the SW queues are just marked as 'stopped' - they will
be processed in the next context switch. But since we
don't differentiate this now, mention whether we want
to check if there are frames in the SW queues.

* The flush() callback checks both HW and SW queues.
* The tx_frames_pending() callback does the same.
* The call to __ath9k_flush() in MCC mode checks HW queues alone.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2fae0d9f 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use configurable timeout for flush

The timeout value for flushing the TX queues
is hardcoded at 200ms right now. Use a channel
context-specific value instead to allow adjustments
to the timeout in case MCC is enabled.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# eaf04a69 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Disable beacon tasklet during reset

When a chip reset is done, all running timers,
tasklets etc. are stopped but the beacon tasklet
is left running. Fix this.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ae2ff239 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Set ATH_OP_HW_RESET before HW reset

When a HW reset is done, the interrupt tasklet is
disabled before ISRs are disabled in the HW. This
allows a small window where the HW can still generate
interrupts. Since the tasklet is disabled and not killed,
it is not scheduled but deferred for execution at a later
time.

This happens because ATH_OP_HW_RESET is not set when ath_reset()
is called. When the hw_reset_work workqueue is used, this
problem doesn't arise because ATH_OP_HW_RESET is set
and the ISR bails out.

Set ATH_OP_HW_RESET properly in ath_reset() to avoid
this race - all the ath_reset_internal() callers have
been converted to use ath_reset() in the previous patch.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5555c955 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Unify reset API

Instead of having ath_reset_internal() and ath_reset()
as two separate calls to perform a HW reset, have
one function. This makes sure that the behavior will
be the same at all callsites.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b8f9279b 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Enable multi-channel properly

In MCC mode, currently the decision to enable
the multi-channel state machine is done
based on the association status if one of
the interfaces assigned to a context is in
station mode.

This allows the driver to switch to the other
context before the current station is able to
complete the 4-way handshake in case it is
required and this causes problems.

Instead, enable multi-channel mode when the
station moves to the authorized state. This
disallows an early switch to the other channel.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# df3c6eb3 16-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use sta_state() callback

Instead of using the sta_add()/sta_remove() callbacks,
use the sta_state() callback since this gives
more fine-grained control.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 868caae3 21-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Enable HW queue control only for MCC

Enabling HW queue control for normal (non-mcc) mode
causes problems with queue management, resulting
in traffic stall. Since it is mainly required for
fairness in MCC mode, disable it for the general case.

Bug: https://dev.openwrt.org/ticket/18164

Cc: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b18111d9 06-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix crash in MCC mode

When a channel context is removed, the hw_queue_base
is set to -1, this will result in a panic because
ath9k_chanctx_stop_queues() can be called on an interface
that is not assigned to any context yet - for example,
when trying to scan.

Fix this issue by setting the hw_queue_base to zero
when a channel context is removed.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5ba8d9d2 01-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix queue handling for channel contexts

When a full chip reset is done, all the queues
across all VIFs are stopped, but if MCC is enabled,
only the queues of the current context is awakened,
when we complete the reset.

This results in unfairness for the inactive context.
Since frames are queued internally in the driver if
there is a context mismatch, we can awaken all the
queues when coming out of a reset.

The VIF-specific queues are still used in flow control,
to ensure fairness when traffic is high.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b3903153 01-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Pass context to ath9k_chanctx_wake_queues()

Change the ath9k_chanctx_wake_queues() API so
that we can pass the channel context that needs its
queues to be stopped.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4f82eecf 01-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix queue handling in flush()

When draining of the TX queues fails, a
full HW reset is done. ath_reset() makes sure
that the queues in mac80211 are restarted,
so there is no need to wake them up again.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 60913f4d 01-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove duplicate code

ath9k_has_tx_pending() can be used to
check if there are pending frames instead
of having duplicate code.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fc1314c7 01-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix pending frame check

Checking for the queue depth outside of
the TX queue lock is incorrect and in this
case, is not required since it is done inside
ath9k_has_pending_frames().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b7367285 01-Oct-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Check pending frames properly

There is no need to check if the current
channel context has active ACs queued up
if the TX queue is not empty.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2ce73c02 19-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix p2p address management

When multiple channel contexts are enabled, a p2p interface
that is assigned to a context will have an address that
is different from the device mac address, which is used
by wpa_s as the p2p device ID.

Certain frames like provision requests use the device address
and these get dropped since ath9k_calculate_summary_state()
iterates over only the active interfaces in a context and the
device address is not used.

Fix this by adding the device mac address to the bssid mask.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cb35582a 17-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cache BSS information

Using the BSS information stored in mac80211 directly
is racy in certain conditions. For example, in a MCC
setup, if the scheduler is switching channels when
a local deauth is issued, calculation of the opmode/bssid
etc. is incorrect. To avoid this, store the bss params
in the driver and use it.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2ba7d144 18-Sep-2014 Wojciech Dubowik <Wojciech.Dubowik@neratec.com>

ath9k: Fix NULL pointer dereference on early irq

The ah struct might not have been initialized when
interrupt comes so check for it.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 44b47a7d 15-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: initialize ath_node linked list

Initialize neighbor linked list used by dynack to compute ACK timeout
as the maximum STA ACK timeout

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 24a1936b 15-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: enable dynack using set_coverage_class codepath

Enable ACK timeout estimation algorithm if set_coverage_class routine has been
called with negative coverage_class parameter. Dynack is automatically disabled
setting valid value for coverage class

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1030f9fe 14-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix primary station configuration

Assign 'primary_sta' to the active primary station
interface after iterating over the list of interfaces.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# af87dd33 14-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove useless opmode check

The opmode is verified to be NL80211_IFTYPE_STATION
before calling ath9k_set_assoc_state().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4ee26de1 14-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Set offchannel state properly

When switching offchannel, BSS related information
in the HW has to be reset to default values. Add a routine
to do this.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a4027644 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use a subroutine to assign HW queues

Reduces code duplication.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ca529c93 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix interface accounting

Currently, the interface count is maintained globally,
but this causes problems in RX filter calculation.
Make the interface count a per-channel-context variable
to fix this.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fce34430 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX filters in channel contexts

Maintain the RX filter on a per-channel-context
basis and not globally. Not doing so was resulting
in incorrect filter calculation.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 19ec477f 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix ath_startrecv()

Since ath_startrecv() doesn't return an error value,
cleanup the callsites.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9019f646 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX filter calculation

If multiple channel contexts are active, then the opmode
can be different in each context. Since the RX filter is
calculated in ath_startrecv() before switching to the
new opmode, the wrong filters are chosen.

Fix this by calling ath9k_calculate_summary_state() before
the RX module is started.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9bf30ff9 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix panic when adding an AP interface

If a station interface is already assigned to a context
and is active and a second interface of type AP is added,
then beaconing on the new interface has to be begin only
after the BSS_CHANGED_BEACON_ENABLED flag is sent by mac80211
to the driver.

But, since we issue ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL as soon
as a new channel context is added, a switch occurs almost immediately
before BSS_CHANGED_BEACON_ENABLED is received. When a HW reset
is done for the new context, beacons are enabled for the
interface since "enable_beacon" in the BSS config maintained
in mac80211 is true - but the driver hasn't been notified yet.
This causes a panic, since the beacon interval is zero for this
interface and ath9k_cmn_beacon_config_ap() doesn't have a safety check.

Fix this panic by checking if the beacon params has been cached
for this context and use the "enable_beacon" flag maintained
locally in the driver. Also, recalculate the summary data
after the beacon params have been cached when BSS_CHANGED_BEACON_ENABLED
is received.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 602607b6 04-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix beacons for managed mode

If the current opmode is managed, the ATH_OP_BEACONS flag
needs to be set only when there is a primary station interface
and it is associated/active.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a4bcaf55 04-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

mac80211: extend set_coverage_class signature

Extend mac80211 set_coverage_class API in order to enable ACK timeout
estimation algorithm (dynack) passing coverage class equals to -1
to lower drivers. Synchronize set_coverage_class routine signature with
mac80211 function pointer for p54, ath9k, ath9k_htc and ath5k drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 878066e7 26-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add more debug statements for channel context

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9ea3598b 26-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Disable fastcc for channel context mode

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4c7e9aee 24-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix channel context creation

If a new context is being added in addition to the current one,
then send the ASSIGN event to abort a running scan since
the addition of a context is usually followed by VIF
assignment and further operations.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 77843167 23-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix 'offchannel' in ath_softc

Finally move the 'offchannel' instance in ath_softc
inside a CONFIG_ATH9K_CHANNEL_CONTEXT cage. The offchannel
usage in ath9k_calculate_iter_data() is closed off with
an ifdef for now, since the state/opmode calculation is
common for both the channel context mode and the normal mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4b93fd29 23-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix function argument type

ath9k_vif_iter() was earlier used as an iterator
routine when calling a mac80211 utility. This is no
longer the case and hence we can mention the argument
type explicitly.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0e08b5fb 23-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add ath9k_chanctx_wake_queues

Introduce a function that handles queues in channel
context mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 27babf9f 23-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix channel context events

Check if channel context usage is enabled before
calling ath_chanctx_event() from various parts of the
driver. Also, make sure that ath_chanctx_event() is
compiled only when CONFIG_ATH9K_CHANNEL_CONTEXT is
enabled.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e20a854e 23-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cleanup mgd_prepare_tx callback

Rename the callback from ath9k_chanctx_force_active()
to ath9k_mgd_prepare_tx(). Also, move it to main.c and
group it with the other callbacks.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ea22df29 23-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add a routine to tear down channel contexts

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 499afacc 22-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Isolate ath9k_use_chanctx module parameter

This patch ensures that the module parameter "use_chanctx" is
visible only when CONFIG_ATH9K_CHANNEL_CONTEXT is selected.
Also register the channel context callbacks with mac80211 only
when it is explicitly enabled and compile them out of the driver
when CONFIG_ATH9K_CHANNEL_CONTEXT is not selected.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c7dd40c9 22-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Isolate P2P powersave routines

Use CONFIG_ATH9K_CHANNEL_CONTEXT to conditionally
compile P2P-PS code.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2471adff 22-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Move P2P functions to channel.c

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bc81d43a 22-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add debug information

Add a few statements to debug channel context operation.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# dfcbb3e8 22-Aug-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Move channel operations to channel.c

This reduces clutter in main.c

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9198cf4a 26-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Cache beacon config after association

The beacon configurations are not cached properly after the station
associates with AP. Not handling BEACON_INFO, is failing to update
dtim period and also it is causing below warning message.

WARNING: CPU: 1 PID: 0 at drivers/net/wireless/ath/ath9k/recv.c:548
ath_rx_tasklet+0xc89/0xca0 [ath9k]()
Call Trace:
[<c14669c9>] dump_stack+0x48/0x69
[<c104f1a2>] warn_slowpath_common+0x82/0xa0
[<fd38c2f9>] ? ath_rx_tasklet+0xc89/0xca0 [ath9k]
[<fd38c2f9>] ? ath_rx_tasklet+0xc89/0xca0 [ath9k]

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d6067f0e 20-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Fix build error in ath_reset_internal

drivers/net/wireless/ath/ath9k/main.c:299 ath_reset_internal()
error: we previously assumed 'hchan' could be null (see line 293)

Cc: Felix Fietkau <nbd@openwrt.org>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3ad9c386 11-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: use separate HW queue for each channel context

Use seperate tx queue for each AC in each channel context and expose
these information to mac80211 to avoid stopping one channel context
leads to stopping the entire traffic for that AC even on other contexts.

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 42eda115 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Add recovery mechanism for hw TSF timer

Configure the TSF based hardware timer for a channel switch.
Also set up backup software timer, in case the gen timer fails.
This could be caused by a hardware reset.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 73fa2f26 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Add multi-channel scheduling support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6036c284 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Implement mgd_prepare_tx

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ea6ff2de 11-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Store current offchannel duration

Update current offchannel duration during scan or roc request.

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 748299f2 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: switch channel context for beaconing

Add a basic state machine for switch channel context
for beacon transmission.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9a9c4fbc 11-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Summarize hw state per channel context

Group and set hw state (opmode, primary_sta, beacon conf) per
channel context instead of whole list of vifs. This would allow
each channel context to run in different mode (STA/AP).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8d7e09dd 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: save tsf in channel context

Save TSF in channel context for multiple operating channels.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b01459e8 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Move caldata into channel context

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c4dc0d04 11-Jun-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Fetch appropriate operating channel context

Retrieve appropriate operating channel context while switching
between operating and off channels.

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 39305635 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Implement channel context ops

Add channel context operations (add, remove, change, assign and
unassign) to enable support for multiple channels.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 405393cf 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Implement remain-on-channal support

Add remain on channel support in order to enable multi-channel
concurrency.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 78b21949 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Implement hw_scan support

Implement hw_scan support for enabling multi-channel cuncurrency.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c083ce99 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: send powersave frame on channel switch

While leaving from or entering to active channel context, send out
nullfunc frame to inform to the AP about the presence of station.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bff11766 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Add channel context worker thread

The channel context worker is used to switch to next requested
channel context.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0453531e 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Move acq to channel context

Add support to maintain per-channel ACs list.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bc7e1be7 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Move txpower limit to channel context

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fbbcd146 11-Jun-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: Add channel context structure

The channel context structure is defined to enable
multi-channel concurrency support.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 60ccc107 27-May-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Fix deadlock while updating p2p beacon timer

pm_lock is taken twice while syncing HW TSF of p2p vif.
Fix this by taking the lock at caller side.

Cc: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aecdc89f 23-May-2014 Luciano Coelho <luciano.coelho@intel.com>

ath9k/ath10k: remove unnecessary channel_switch_beacon callbacks

The channel_switch_beacon callback is optional, so it doesn't have to
be defined if it's not going to do anything useful with it. Both
ath9k and ath10k define the callback and just returns. This commit
removes them.

Cc: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>


# 4bbf4414 21-May-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k: Handle multiple keys while setting tx filters

The keycache index is used to abort transmission for given station
when it goes to sleep state. But the commit "ath9k_hw: Abort transmission
for sleeping station" is not handling multi-key station. Fix that.

Cc: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08232bf9 19-May-2014 Rajkumar Manoharan <rmanohar@qti.qualcomm.com>

ath9k_hw: Abort transmission for sleeping station

The data transmission to the power save station should be aborted
immediately, whenever the station informs sleep state. Right now
the frames queued into into hardware are being transmitted until
the hardware detects the power save station based excessive retries
of the data frames due to unacknowlegdement. Then remaining frames
are returned with filetered status and might be retried later by
driver or mac80211.

Per WFA certification testing, AP should not send out more than two
frames after processing nullfunc with PM bit set from associated
station. To speed up tx filtering, the pending frames in hardware
queues for given station will be aborted immediately via tx filter
registers. This transmit filters can be ignored if the descriptor
is having invalid destination index or clear destination mask set.

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d463af4a 05-Apr-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: implement p2p client powersave support

Use generic TSF timers to trigger powersave state changes based
information from the P2P NoA attribute.
Opportunistic Powersave is not handled, because the driver does not
support powersave at the moment.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 77be2c54 27-Mar-2014 Emmanuel Grumbach <emmanuel.grumbach@intel.com>

mac80211: add vif to flush call

This will allow the low level driver to make decision based
on the vif such as queues etc...
Since the vif might be NULL, we can't add it to the tracing
functions.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
[fix staging rtl8821ae driver]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# eefa01dd 27-Feb-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move sc_flags to ath_common

we will need it for ath9k_htc, may be other drivers too

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b57ba3b2 25-Feb-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move ath9k_reload_chainmask_settings to common

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# affad456 22-Feb-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: make some hardware reset log messages debug-only

On some chips, baseband watchdog hangs are more common than others, and
the driver has support for handling them.
Interrupts even after a watchdog hang are also quite common, so there's
not much point in spamming the user's logfiles.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 32efb0cc 04-Feb-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move ath9k_process_rssi to common.c

we can reuse this fucntion on ath9k_htc.
Now we will need to use common version last_rssi, so switch
it too.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f7838073 26-Jan-2014 Geert Uytterhoeven <geert@linux-m68k.org>

ath9k: Fix uninitialized variable in ath9k_has_tx_pending()

drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_has_tx_pending’:
drivers/net/wireless/ath/ath9k/main.c:1869: warning: ‘npend’ may be used uninitialized in this function

Introduced by commit 10e2318103f5941aa70c318afe34bc41f1b98529 ("ath9k:
optimize ath9k_flush").

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4effc6fd 20-Jan-2014 Michal Kazior <michal.kazior@tieto.com>

ath9k: prepare for multi-interface CSA support

Soon mac80211 will support multi-interface CSA so
using sc->csa_vif is not an option.

Instead just depend on vif->csa_active. Calling
ieee80211_csa_finish() multiple number of times
should not be an issue.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3b745c7b 20-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix code mistake

The commit "ath9k: Process GTT interrupts" accidentally
had a line that was commented out.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 071aa9a8 13-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Process GTT interrupts

Global Transmission Timeout interrupts are generated by
the HW when transmission of a frame fails - this is done
based on the threshold programmed in the AR_GTXTO register.

Currently, even though the interrupt is enabled for all chips,
it is not handled in the driver. This patch handles GTT events
for AR9003 and above chips, checking if the MAC/BB has hung
after successive GTT interrupts crosses a threshold (5).

This can be enabled for the older chips in the AR9002 family once
appropriate HW hang checks are implemented for them.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9d89cadd 12-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove debug print in ISR

There is no need to do this and we can avoid
an unused variable warning when CONFIG_ATH9K_WOW is
not selected.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1cdbaf0d 12-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add an option for station statistics

Also, rename node_stat to node_aggr.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 78c8a950 27-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix interrupt statistics

Initialize "sync_cause" to zero since commit
"ath9k: move ath9k_debug_sync_cause out of ath9k_hw"
fills it conditionally based on ISR status.
Not doing this results in garbage values in debugfs.

Cc: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b7cc9b97 25-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix "cc_lock" usage

IRQ save/restore is not required for the cycle counters
since they are accessed only from softirq and process context.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0c759977 23-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Process BB watchdog events in the tasklet

Move the BB processing code to the tasklet and avoid
doing it in the ISR, there is no real benefit and this
makes the ISR less heavy.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 415ec61b 23-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove RX Poll

This patch removes the convoluted and hacky method of
monitoring for connectivity. We rely on mac80211's connection
loss logic and doing it in the driver is not necessary.

The HW check for MAC/BB hangs is also simplified, there
is no need to have a separate work instance for it.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6549a860 23-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix baseband watchdog reset

Do a HW reset only for required signatures.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a6bb860b 23-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix baseband watchdog interrupts

Program the required baseband watchdog interrupt
mask to ensure that the correct watchdog interrupts
are raised when the BB is hung for some reason.

Also, use the capability HW_BB_WATCHDOG instead of
relying on other flags.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5b502c86 23-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix max AMPDU size calculation

The maximum A-MPDU size is calculated in ath_tx_aggr_start(),
so there is no need to do it in node_attach() too. Also, make
sure that the correct size is calculated as described in
8.4.2.58.3.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c32e4e51 19-Dec-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: call ath9k_set_tsfadjust from ath9k_beacon_config

Make that function and ath9k_allow_beacon_config static

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6a4d05dc 19-Dec-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: move ath9k_debug_sync_cause out of ath9k_hw

ath9k_hw should not depend on any ath9k data structures like ath_softc

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a35051ce 14-Dec-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: properly preserve TSF across reset

The beacon code previously reset TSF on every configuration call, as
some of the code was not prepared to properly calculate nexttbtt based
on current TSF.

This patch adds a common function for calculating nexttbtt and moves the
TSF reset to driver start.

This should improve AP mode compatibility with various stations that
expect the TSF to not randomly jump due to hardware resets.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c67ce339 14-Dec-2013 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: clean up generic timer code

- Use generic bitops instead of custom hackery
- Move interrupt enable/disable logic from ath9k to ath9k_hw
- Decouple ISR call from btcoex
- Make the overflow callback optional (to prevent IRQ storms)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 657eb17d 27-Nov-2013 Mathy Vanhoef <vanhoefm@gmail.com>

ath9k_htc: properly set MAC address and BSSID mask

Pick the MAC address of the first virtual interface as the new hardware MAC
address. Set BSSID mask according to this MAC address. This fixes CVE-2013-4579.

Signed-off-by: Mathy Vanhoef <vanhoefm@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 10e23181 11-Nov-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: optimize ath9k_flush

Instead of checking the queues in a loop with hardcoded sleep times
inbetween, use a wait queue to trigger queue checks after the tx
processing tasklet has run.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bf3dac5a 11-Nov-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: use a timer to put hardware into full sleep

When operating in client mode, the short period of time between scanning
and associating is often enough to put the hardware through several
FULL-SLEEP <-> AWAKE transitions, each wakeup requiring a reset to fully
recover the hardware.
This is completely unnecessary and can easily be avoided by deferring
the switch to full sleep.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e60001e7 27-Oct-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use CONFIG_ATH9K_WOW

Move the WoW code to wow.c and compile it conditionally
based on CONFIG_ATH9K_WOW.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ef6b19e4 23-Oct-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix TX99 config option usage

Use CONFIG_ATH9K_TX99 to properly enclose the tx99 code
and make sure that it is not compiled as part of the driver
when it is not selected. Move the tx99 code to a new file tx99.c
and also add ATH9K_DEBUGFS as a dependency in Kconfig.

This reduces the module size on platforms like OpenWrt where
ATH9K_DEBUGFS is selected, but TX99 might be disabled.

Cc: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 89f927af 14-Oct-2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>

ath9k: add TX99 support

TX99 support enables Specific Absorption Rate (SAR) testing.
SAR is the unit of measurement for the amount of radio frequency(RF)
absorbed by the body when using a wireless device. The RF
exposure limits used are expressed in the terms of SAR, which is a
measure of the electric and magnetic field strength and power density
for transmitters operating at frequencies from 300 kHz to 100 GHz.

Regulatory bodies around the world require that wireless device
be evaluated to meet the RF exposure limits set forth in the
governmental SAR regulations.

In the examples below, for more bit rate options see the iw TX bitrate
setting documentation:

http://wireless.kernel.org/en/users/Documentation/iw#Modifying_transmit_bitrates

Example usage:

iw phy phy0 interface add moni0 type monitor
ip link set dev moni0 up

iw dev moni0 set channel 36 HT40+
iw set bitrates mcs-5 4

echo 10 > /sys/kernel/debug/ieee80211/phy0/ath9k/tx99_power
echo 1 > /sys/kernel/debug/ieee80211/phy0/ath9k/tx99

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c648ecb0 11-Oct-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: make ath9k_uses_beacons static

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 45c67f6f 11-Oct-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: move channel change code to ath_set_channel

Preparation for adding the scanning state machine to ath9k

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2297f1c7 11-Oct-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: make ath9k_cmn_update_ichannel static

Rework its wrapper function to make it more generic, using it as a
replacement for previous calls to ath9k_cmn_update_ichannel.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ec30326e 05-Oct-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: fix tx queue scheduling after channel changes

Otherwise, if queues are full during a scan, tx scheduling does not
resume after switching back to the home channel.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c6cc47b1 15-Sep-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Handle FATAL interrupts correctly

When a FATAL interrupt is received, a full chip reset is
required, which is done in the main tasklet. But since
the reset routine is scheduled as a work item, make sure
that interrupts are not enabled in the tasklet before the
reset is done.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 19c36160 19-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Enable PLL fix only for AR9340/AR9330

The PLL hang workaround is required only for AR9330 and
AR9340. This issue was first observed on an AP121 and the WAR
is enabled for AR9340 also (DB120 etc.), since it uses a PLL
design identical to AR9330. This is not required for AR9485 and AR9550.

Various bugs have been reported regarding this:

https://bugzilla.redhat.com/show_bug.cgi?id=997217
https://bugzilla.redhat.com/show_bug.cgi?id=994648

Cc: stable@vger.kernel.org
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d074e8d5 14-Aug-2013 Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

ath9k: enable CSA functionality in ath9k

CSA is only enabled for one interface, but the same limitation applies
for mac80211 too. It checks whether the beacon has been sent (different
approaches for non-EDMA-enabled and EDMA-enabled devices), and completes
the channel switch after that.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0671894f 16-Aug-2013 Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

ath9k: use chandef instead of channel_type

To enable support for 5/10 MHz, some internal functions must be
converted from using the (old) channel_type to chandef. This is a good
chance to change all remaining occurences.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f5bde5b8 12-Aug-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: remove ath9k_sta_remove_debugfs

mac80211 uses debugfs_remove_recursive, so there's no need for the
driver to do an explicit cleanup of its sta debugfs entry.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f89d1bc4 06-Aug-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: use software queueing for multicast traffic

Create a per-vif dummy node entry for keeping the multicast software
queues. This helps in setups with a lot of mulitcast traffic that could
otherwise potentially drown out unicast traffic to stations.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 73364b0c 06-Aug-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: prepare queueing code for handling unaggregated traffic

- Allow ath_tx_get_tid_subframe to return non-AMPDU subframes.
- Reset the tid paused state on aggregation stop
- Initialize software queues even when HT is not supported

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 047dc3ac 05-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove ath_ant_comb_update()

During a HW reset, the diversity config is programmed
in the set_board_values() eeprom callback, there is no
need to do it again by calling ath_ant_comb_update().

Fixed antenna support is not fully handled for 1-stream
cards, it can be done later.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 50ac6607 25-Jun-2013 Amitkumar Karwar <akarwar@marvell.com>

cfg80211/nl80211: rename packet pattern related structures and enums

Currently packet patterns and it's enum/structures are used only
for WoWLAN feature. As we intend to reuse them for new feature
packet coalesce, they are renamed in this patch.

Older names are kept for backward compatibility purpose.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>


# 696df785 10-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix noisefloor calibration

The commits,

"ath9k: Fix regression in channelwidth switch at the same channel"
"ath9k: Fix invalid noisefloor reading due to channel update"

attempted to fix noisefloor calibration when a channel switch
happens due to HT20/HT40 bandwidth change. This is causing invalid
readings resulting in messages like:

"ath: phy16: NF[0] (-45) > MAX (-95), correcting to MAX".

This results in an incorrect noise being used initially for reporting
the signal level of received packets, until NF calibration is done
and the history buffer is updated via the ANI timer, which happens
much later.

When a bandwidth change happens, it is appropriate to reset
the internal history data for the channel. Do this correctly in the
reset() routine by checking the "chanmode" variable.

Cc: stable@vger.kernel.org
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 86a22acf 07-Jun-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: implement support for .release_buffered_frames()

This adds support for PS-Poll and U-APSD driver-buffered frames (part of
an aggregation session).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 846e438f 02-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Enable WoW only for AR9462

The only card with which WoW has been tested and verified is
AR9462. Do not enable it for all cards since WoW is really quirky
and needs to be tested properly with each chip.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7ca7c776 07-May-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Do not use local_bh_disable in ampdu_action

This was added during the early conversion of ampdu_action
to a sleeping callback. There is no need to do this - instead,
use the normal mutex that is acquired for all callbacks.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 73900cb0 07-May-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use bitops for scan flag

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cf657a2b 07-May-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove MAC_DEBUG

This option has not been enabled by default in any
distribution, has never been enabled in OpenWrt and no developer
has asked for this information in a bug report.

Dumping pages of random values doesn't help debugging,
remove this option (along with the vmalloc() abuse).

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08c96abd 18-May-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: prevent aggregation session deadlocks

Waiting for all subframes of an existing aggregation session to drain
before allowing mac80211 to start a new one is fragile and deadlocks
caused by this behavior have been observed.

Since mac80211 has proper synchronization for aggregation session
start/stop handling, a better approach to session handling is to simply
allow mac80211 to start a new session at any time. This requires
changing the code to discard any packets outside of the BlockAck window
in the A-MPDU software retry code.

This patch implements the above and also simplifies the code.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 16e23428 16-May-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: fix aggregation stop/flush handling

When aggregation stop is requested, don't run the mac80211 aggregation
stop callback yet, while the session is still blocked.
Also, when aggregation flush is requested, don't run the callback at all.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a6768280 05-May-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix beacon reconfiguration

When a reset or a channel-change happens, for managed mode,
the HW beacon timers have to be programmed after the TSF has
been synchronized. This is handled via the sync flags.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4ef69d03 27-Apr-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: fix key allocation error handling for powersave keys

If no keycache slots are available, ath_key_config can return -ENOSPC.
If the key index is not checked for errors, it can lead to logspam that
looks like this: "ath: wiphy0: keyreset: keycache entry 228 out of range"
This can cause follow-up errors if the invalid keycache index gets
used for tx.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ab11bb28 15-Apr-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: always set common->macaddr to the MAC adress of a virtual interface

In some cases it can be useful to change the MAC address of a virtual
interface to something that's completely different from the EEPROM
stored MAC address. In this case it is a bad idea to use the EEPROM MAC
address for calculating the BSSID mask, as that would make it too wide.

In one case a few devices have been observed to send ACKs for many
packets on the channel not directed at them, which results in a neat
Denial of Service attack on the channel.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 73e4937d 03-Apr-2013 Zefir Kurtisi <zefir.kurtisi@neratec.com>

ath9k: add support for DFS master mode

These are the remaining knobs in ath9k to support DFS:
* mark AR9280 and AR9580 as DFS tested
* synchronize DFS regulatory domain to reg notifyer
* set required RX filter flags for radar detection
* process radar PHY errors at DFS detector
* notify DFS master on radar detection

DFS support requires CONFIG_ATH9K_DFS_CERTIFIED to be set.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f50b1cd3 02-Apr-2013 Robert Shade <robert.shade@gmail.com>

ath9k: Re-enable interrupts after a channel change failure

ath_complete_reset will not be called if ath9k_hw_reset
is unsuccessful, so we need to re-enable intertupts to
balence the previous ath_prepare_reset call. Also schedule a
reset as a best effort method to recover the chip from
whatever state caused the channel change failure.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=55771

Signed-off-by: Robert Shade <robert.shade@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 675a0b04 25-Mar-2013 Karl Beldan <karl.beldan@rivierawaves.com>

mac80211: Use a cfg80211_chan_def in ieee80211_hw_conf_chan

Drivers that don't use chanctxes cannot perform VHT association because
they still use a "backward compatibility" pair of {ieee80211_channel,
nl80211_channel_type} in ieee80211_conf and ieee80211_local.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
[fix kernel-doc]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 39ecc01d 12-Feb-2013 Johannes Berg <johannes.berg@intel.com>

mac80211: pass queue bitmap to flush operation

There are a number of situations in which mac80211 only
really needs to flush queues for one virtual interface,
and in fact during this frames might be transmitted on
other virtual interfaces. Calculate and pass a queue
bitmap to the driver so it knows which queues to flush.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# dd5ee59b 04-Feb-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix ATH9K_HW_CAP_HT usage

There are a few places where the station's HT capabilities
should be checked instead of ATH9K_HW_CAP_HT, which is a global
feature for the driver. Fix this.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 04ccd4a1 23-Jan-2013 Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

ath9k: add debug parameters for spectral scan

Export the various parameters to userspace.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1381559b 20-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: clean up processing of pending tx frames on reset

Dropping packets from aggregation sessions is usually not a good idea, as
it might upset the synchronization of the BlockAck receive window of the
remote node. The use of the retry_tx parameter to reset/tx-drain functions
also seemed a bit arbitrary.
This patch removes this parameter altogether and ensures that pending tx
frames are not dropped for no good reason.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0a62acb1 20-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: stop rx after tx

Completing frame transmission can fail if the rx engine is stopped
prematurely, as the hw might be waiting for an ACK from the other side.
Shutting down tx before rx might make the DMA shutdown more reliable.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fea92cbf 20-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: allow setting arbitrary antenna masks on AR9003+

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4668cce5 14-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: disable the tasklet before taking the PCU lock

Fixes a reported CPU soft lockup where the tasklet tries to acquire the
lock and blocks while ath_prepare_reset (holding the lock) waits for it
to complete.

Cc: stable@vger.kernel.org
Reported-by: Robert Shade <robert.shade@gmail.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4b883f02 09-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: fix rx flush handling

Right now the rx flush is not doing anything useful on AR9003+, as it only
works if the buffers in the rx FIFO have not been purged yet, as is done
by ath_stoprecv.

To fix this, always call ath_flushrecv from within ath_stoprecv before
the FIFO is emptied, but still after the hw receive path has been stopped.

This ensures that frames received (and ACKed by the hardware) shortly before
a reset will be seen by the software, which should improve A-MPDU session
stability.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7fc00a30 09-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: add a better fix for the rx tasklet vs rx flush race

Ensure that the rx tasklet is no longer running when entering the reset path.
Also remove the distinction between flush and no-flush frame processing.
If a frame has been received and ACKed by the hardware, the stack needs to see
it, so that the BA receive window does not go out of sync.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e93d083f 08-Jan-2013 Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

ath9k: add spectral scan feature

Adds the spectral scan feature for ath9k. AR92xx and AR93xx chips
are supported for now. The spectral scan is triggered by configuring
a mode through a debugfs control file. Samples can be gathered via
another relay debugfs file.

Essentially, to try it out:

echo chanscan > /sys/kernel/debug/ieee80211/phy0/ath9k/spectral_scan_ctl
iw dev wlan0 scan
cat /sys/kernel/debug/ieee80211/phy0/ath9k/spectral_scan0 > samples
echo disable > /sys/kernel/debug/ieee80211/phy0/ath9k/spectral_scan_ctl

This feature is still experimental.

The special "chanscan" mode is used to perform spectral scan while
mac80211 is scanning for channels. To allow this,
sw_scan_start/complete() ops have been added.

The patch contains code snippets and information from Zefir Kurtisi and
information provided by Adrian Chadd and Felix Fietkau.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 18b559d5 18-Jul-2012 Johannes Berg <johannes.berg@intel.com>

mac80211: split TX aggregation stop action

When TX aggregation is stopped, there are a few
different cases:
- connection with the peer was dropped
- session stop was requested locally
- session stop was requested by the peer
- connection was dropped while a session is stopping

The behaviour in these cases should be different, if
the connection is dropped then the driver should drop
all frames, otherwise the frames may continue to be
transmitted, aggregated in the case of a locally
requested session stop or unaggregated in the case of
the peer requesting session stop.

Split these different cases so that the driver can
act accordingly; however, treat local and remote stop
the same way and ask the driver to not send frames as
aggregated packets any more.

In the case of connection drop, the stop callback the
driver is otherwise supposed to call is no longer
required.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# a145daf7 28-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Implement sta_add_debugfs/sta_remove_debugfs

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c175db87 28-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Move ethtool functions to debug.c

The ethtool statistics are available only when
CONFIG_ATH9K_DEBUGFS is enabled, move these functions
to debug.c

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 580bdac3 21-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove 'stations' debugfs file

The 'stations' debugfs file has multiple issues. It doesn't scale
to an arbitrary number of associated stations and allocating
64K is not elegant either. Now that changes have been made in
mac80211 to support dynamic creation/deletion of driver-specific
debugfs files on station addition/removal, remove this file and
make use of the mac80211 hooks (which will be done in a sebsequent
patch).

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 78ef731c 21-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix the 'xmit' debugfs file

The 'xmit' debugfs file has become big and unwieldy, fix
multiple issues with its usage:

* Store TX counters/statistics only for the 4 Access Categories.
Use IEEE80211_NUM_ACS instead of ATH9K_NUM_TX_QUEUES.

* Move various utility macros to debug.h, they can be reused
elsewhere.

* Remove tx_complete_poll_work_seen.

* Remove code that accesses various internal queue-specific
variables without any locking whatsoever. HW/SW queue details
will be handled in a subsequent patch.

* Do not print internal values like txq_headidx and txq_headidx.
They were mostly unused anyway, considering code like:
PRX("txq_tailidx: ", txq_headidx);

* Handle 'txprocdesc' for EDMA too.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bea843c7 21-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k/ath9k_htc: Remove WME macros

Use the macros provided by mac80211 and remove redundant
declarations inside the drivers.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ca90ef44 20-Nov-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Process FATAL interrupts at first

FATAL and WATCHDOG interrupts should be processed first followed
by others.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b126b027 11-Nov-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove unused workaround

The workaround for ASPM/L0s is needed only for AR9485 1.0,
which was never sold and is not supported by ath9k.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8b2c9824 06-Nov-2012 Johannes Berg <johannes.berg@intel.com>

mac80211: clarify interface iteration and make it configurable

During hardware restart, all interfaces are iterated even
though they haven't been re-added to the driver, document
this behaviour. The same also happens during resume, which
is even more confusing since all of the interfaces were
previously removed from the driver. Make this optional so
drivers relying on the current behaviour can still use it,
but to let drivers that don't want this behaviour disable
it.

Also convert all API users, keeping the old semantics
except in hwsim, where the new normal ones are desired.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# e82cb03f 12-Oct-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: adjust WLAN and BT concurrent transmission

The simulataneous transmission of both WLAN and BT might cause
increase in power levels. To avoid regulatory violation, WLAN tx
power will be adjusted according to BT power index based on avaliability
of BT scheduling messages. WLAN tx power reduction might affect its
performance. So WLAN tx power is only be lowered when the signal strength
is good enough. Otherwise concurrent tx will be disabled and WLAN uses
it default power levels. Also concurrent tx is disabled whenever WLAN is
moving to off-channel which might be used by BT.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 50072ebc 12-Oct-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Send WLAN channel info to BT

WLAN updates channel bitmap when associated and disassociated. Channel
bitmap will reflect whare are the channels used or affected by WLAN and
BT should avoid using those. Not doing so, could affect BT traffic
as both WLAN and BT is operating on same channel.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 424749c7 10-Oct-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: perform ANI cycle in idle state

As of now the ANI cycle is executed only when the chip is awake.
On idle state case, the station wakes up from network sleep for
beacon reception. Since most of the time, ANI cycle is not syncing
with beacon wakeup, ANI cycle is ignored. Approx 5 mins once, the
calibration is performed. This could affect the connection stability
when the station is idle for long. Even though the OFDM and CCK phy
error rates are too high, ANI is unable to tune its immunity level
as quick enough due to rare execution.

Here the experiment shows that OFDM and CCK levels are at default
even on higher phy error rate.

listenTime=44 OFDM:3 errs=121977/s CCK:2 errs=440818/s ofdm_turn=1

This change ensures that ANI calibration will be exectued atleast
once for every 10 seconds. The below result shows improvements and
immunity levels are adopted quick enough.

listenTime=557 OFDM:4 errs=752/s CCK:4 errs=125/s ofdm_turn=0

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 249ee722 03-Oct-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: use ieee80211_free_txskb

Using ieee80211_free_txskb for tx frames is required, since mac80211 clones
skbs for which socket tx status is requested.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@vger.kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ceb26a60 03-Oct-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: improve suspend/resume reliability

Ensure that drv_start() always returns true, as a failing hw start usually
eventually leads to crashes when there's still a station entry present.
Call a power-on reset after a resume and after a hw reset failure to bring
the hardware back to life again.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 327967cb 04-Sep-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Cleanup add/change_interface callbacks

*Remove all the checks that will be handled by cfg80211
based on the interface combination advertised. For instance,
driver supports at the maximum 8 beaconing interface, while
we advertise maximum 8 beaconing interface in the interface
combination support.

*cfg80211 will take care of not allowing
us to add an interface that is not supported by the
driver, further if the change_interface changes the
old interface to a beaconing interface while we had
reached the max limit of 8 beaconing interface, again
cfg80211 takes care of this stuff!
So remove all these checks.

*Beautify placing PS wrappers in the appropriate
position.

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5686cac5 04-Sep-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Make use of ath_stop_ani wrapper

Additionally it has a neat debug message informing us
that we are stopping the ANI algorithm.

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e548c49e 04-Sep-2012 Johannes Berg <johannes.berg@intel.com>

mac80211: add key flag for management keys

Mark keys that might be used to receive management
frames so drivers can fall back on software crypto
for them if they don't support hardware offload.
As the new flag is only set correctly for RX keys
and the existing IEEE80211_KEY_FLAG_SW_MGMT flag
can only affect TX, also rename the latter to
IEEE80211_KEY_FLAG_SW_MGMT_TX.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# f41a9b3b 08-Aug-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: fix interrupt storms on queued hardware reset

commit b74713d04effbacd3d126ce94cec18742187b6ce
"ath9k: Handle fatal interrupts properly" introduced a race condition, where
IRQs are being left enabled, however the irq handler returns IRQ_HANDLED
while the reset is still queued without addressing the IRQ cause.
This leads to an IRQ storm that prevents the system from even getting to
the reset code.

Fix this by disabling IRQs in the handler without touching intr_ref_cnt.

Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Cc: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 36323f81 23-Jul-2012 Thomas Huehn <thomas@net.t-labs.tu-berlin.de>

mac80211: move TX station pointer and restructure TX

Remove the control.sta pointer from ieee80211_tx_info to free up
sufficient space in the TX skb control buffer for the upcoming
Transmit Power Control (TPC).
Instead, the pointer is now on the stack in a new control struct
that is passed as a function parameter to the drivers' tx method.

Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
Signed-off-by: Alina Friedrichsen <x-alina@gmx.net>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
[reworded commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 124b979b 17-Jul-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Fix race in reset-work usage

Using work_pending() to defer certain operations when
a HW-reset work has been queued is racy since the check
would return false when the work item is actually in
execution. Use SC_OP_HW_RESET instead to fix this race.
Also, unify the reset debug statistics maintenance.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6dcc3444 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Reconfigure VIF state properly

When an interface in AP or P2P-GO mode is removed,
check whether a station interface is already present and
reconfigure the beacon timers etc. properly if it's
associated.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# da0d45f7 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix ANI management

Currently, there are problems with how ANI is handled in
multi-VIF scenarios. This patch addresses them by unifying
the start/stop logic.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2f8e82e8 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Set the TSF adjust value properly

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7e52c8aa 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cleanup beacon queue configuration

Setup the beacon queue parameters after disabling
interrupts. Also, remove the redundant call in conf_tx()
for IBSS mode since the queue would be configured
with the appropriate cwmin/cwmax values when beaconing
is enabled.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aa45fe96 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove is_bslot_active

In the tx_last_beacon() callback, mac80211's beaconing
status can be used instead. The beacon tasklet doesn't require
it because it is disabled when removing a slot.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ef4ad633 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cleanup beacon logic

* The beaconing status routine is not required, since in
multi-VIF cases the HW beacon parameters should not be
re-configured.

* Remove SC_OP_TSF_RESET - when a beaconing interface comes
up the first time, the TSF has to be reset.

* Simplify ath9k_allow_beacon_config().

* Handle setting/clearing the SWBA interrupt properly.

* Remove the TSF mangling in IBSS mode, it is not required.

* General code cleanup.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6c43c090 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Simplify ASSOC handling

Cleanup the messy logic dealing with station association
and disassociation.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# df35d29e 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cleanup interface handling

* Do not set/clear TSF when adding/deleting an interface.
This should be done when the BSS is set up and should also
take into account the existence of other interfaces.

* Set opmode explicitly.

* ANI setup needs to be decided based on multiple interfaces.
This can be done via the bss_info_changed() callback.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 60ca9f87 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k_hw: Cleanup ath9k_hw_set_tsfadjust

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 130ef6e9 17-Jul-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix beacon setup

This patch revamps interface addition and deletion and simplifies
slot allocation. There is no need to setup the beacon buffer
in add/remove interface, remove this and use simple APIs for
assigning/deleting slots.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aa5955c3 15-Jul-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: fix aggregate size limit based on queue TXOP limit

If the aggregate size exceeds the TXOP limit, it leads to lots of unnecessary
hardware and software retries.

The previous 4ms frame limit table was completely undocumented, the commit
that updated it only vaguely referenced and equation from the standard,
but I've been unable to replicate its results.

Fix this by using a formula based on the code in ath_pkt_duration, which is
more likely to be correct for this case.

Reported-by: Dave Täht <dave.taht@gmail.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 531bd079 15-Jul-2012 Felix Fietkau <nbd@openwrt.org>

ath9k/ath9k_htc: fix txop limit handling

In all those years apparently nobody noticed that the txop limit programmed
into the chip was off by a factor of 32 (!), probably because the VI and VO
queues aren't used that much aside from mgmt frames on VO.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5d9c7e3c 15-Jul-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: validate rx antenna settings

Many chips are not able to deal with non-consecutive rx antenna selections
and respond with calibration errors, reset errors, etc.
When an antenna is selected as a tx antenna, also flag it for rx to avoid
chip issues.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b11e640a 10-Jul-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Add WoW related mac80211 callbacks

add suspend/resume/set_wakeup callbacks to the driver

*suspend

- bail out only if all the conditions for configuring WoW.
is fine, currently multivif case is not handled
- check for associated state.
- map wow triggers from user space data.
- add deauth/disassoc pattern and user defined pattern,
for the later a list is maintained.
- store the interrupt mask before suspend, enabled beacon
miss interrupt for WoW.
- configure WoW in the hardware by calling ath9k_hw_wow_enable.

*resume

- restore the interrupts based on the interrupt mask
stored before suspend.
- call ath9k_hw_wow_wakeup to configure/restore the hardware.
- after wow wakeup clear away WoW events and query the
WoW wakeup reason from the status register

*set_wakeup

- to call 'device_set_wakeup_enable' from cfg80211/mac80211
when wow is configured and as per Rafael/Johannnes the
right way to do so rather in the driver suspend/resume
call back

Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Cc: vadivel@qca.qualcomm.com
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c12b6021 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org>

ath9k: enable PLL workaround for AR9550

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08d4df41 01-Jul-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: fix power consumption on network sleep when BTCOEX is enabled

The chip is waken up for every 45ms in btcoex timer cycle to
for sharing the radio between BT and WLAN. Whenever the wlan
interface is in network sleep mode, do not schedule hw timers.
This could reduce power consumption on idle associated state.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b73f3e78 01-Jul-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: fix fullsleep power consumption when BTCOEX is enabled

As soon as the interface brought up, btcoex timer starts running
eventhough the interface is in idle state and WLAN chip is moved
to full sleep mode. There is no point in running btcoex timer when
the wlan interface is in sleep mode and also it might consumes
more power on WLAN idle unassociated state. So lets stop the
btcoex when wlan is idle state.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bf52592f 27-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix compilation breakage

Wrap the MCI-work canceling with CONFIG_ATH9K_BTCOEX_SUPPORT.

Reported-by: Emmanuel Benisty <benisty.e@gmail.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fad29cd2 25-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix lockdep splat

Cancel the MCI work only when MCI is actually enabled.
Fixes this:

[96833.124051] Call Trace:
[96833.124060] [<ffffffff810afaf8>] __lock_acquire+0x1518/0x1e40
[96833.124065] [<ffffffff810ad126>] ? mark_held_locks+0x86/0x110
[96833.124069] [<ffffffff810ad3ad>] ? trace_hardirqs_on+0xd/0x10
[96833.124073] [<ffffffff814464f0>] ? _raw_spin_unlock_irq+0x30/0x70
[96833.124078] [<ffffffff81072968>] ? wait_on_cpu_work+0x98/0xc0
[96833.124082] [<ffffffff810b0a11>] lock_acquire+0xa1/0x150
[96833.124085] [<ffffffff81072990>] ? wait_on_cpu_work+0xc0/0xc0
[96833.124088] [<ffffffff81072990>] ? wait_on_cpu_work+0xc0/0xc0
[96833.124092] [<ffffffff810729e2>] wait_on_work+0x52/0x120
[96833.124095] [<ffffffff81072990>] ? wait_on_cpu_work+0xc0/0xc0
[96833.124099] [<ffffffff81063b3f>] ? del_timer+0x7f/0x110
[96833.124102] [<ffffffff81072c13>] __cancel_work_timer+0x83/0x130
[96833.124106] [<ffffffff81072cf0>] cancel_work_sync+0x10/0x20
[96833.124113] [<ffffffffa065b5cd>] __ath_cancel_work+0x4d/0x60 [ath9k]
[96833.124119] [<ffffffffa065cf28>] ath9k_config+0x458/0x680 [ath9k]
[96833.124125] [<ffffffffa065dd1e>] ? ath9k_flush+0x6e/0x1d0 [ath9k]
[96833.124129] [<ffffffff8144394d>] ? __mutex_unlock_slowpath+0x10d/0x190
[96833.124146] [<ffffffffa056c7b5>] ieee80211_hw_config+0x135/0x2a0 [mac80211]
[96833.124163] [<ffffffffa057ebbb>] ieee80211_do_open+0x67b/0xc50 [mac80211]
[96833.124178] [<ffffffffa057f1fd>] ieee80211_open+0x6d/0x80 [mac80211]
[96833.124183] [<ffffffff8137a44f>] __dev_open+0x9f/0xf0
[96833.124187] [<ffffffff8137a701>] __dev_change_flags+0xa1/0x180
[96833.124190] [<ffffffff8137a898>] dev_change_flags+0x28/0x70
[96833.124195] [<ffffffff813e1179>] devinet_ioctl+0x659/0x780
[96833.124199] [<ffffffff8137aea0>] ? dev_ioctl+0x210/0x6d0
[96833.124203] [<ffffffff813e1db5>] inet_ioctl+0x75/0x90
[96833.124208] [<ffffffff8135e0e0>] sock_do_ioctl+0x30/0x70
[96833.124211] [<ffffffff8135e3dd>] sock_ioctl+0x7d/0x2c0
[96833.124218] [<ffffffff81193c39>] do_vfs_ioctl+0x99/0x580
[96833.124222] [<ffffffff81447415>] ? sysret_check+0x22/0x5d
[96833.124226] [<ffffffff811941b9>] sys_ioctl+0x99/0xa0
[96833.124230] [<ffffffff814473e9>] system_call_fastpath+0x16/0x1b

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 313eb87f 24-Jun-2012 Sven Eckelmann <sven@narfation.org>

ath9k: raise aggregation limit to 64k for HT IBSS

mac80211 adds stations in HT IBSS as soon as a frame comes by,
even if the HT capabilities are not known yet (they are often
received later, e.g. in beacons). So far, ampdu factor/density
are only calculated when the station is initially added.

This patch changes this to update ampdu factor/density settings
when starting a blockack session.

Using this patch, we had performance boosts from 60 to 150 MBit/s
between two 2x2 Atheros devices in 5 GHz HT IBSS mode.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 198823fd 15-Jun-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: remove MIB interrupt support

The new ANI implementation does not need it

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3c7992e3 11-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: defer btcoex scheme update

As btcoex scheme updation might sleep, remove the function call
from tasklet context and queue it up as a separate work.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8389fb3f 10-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: restore power state on set channel failure

Not doing so, could cause imbalance in powersave count.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bcb7ad7b 13-Jun-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Fix softlockup in AR9485

steps to recreate:
load latest ath9k driver with AR9485
stop the network-manager and wpa_supplicant
bring the interface up

Call Trace:
[<ffffffffa0517490>] ? ath_hw_check+0xe0/0xe0 [ath9k]
[<ffffffff812cd1e8>] __const_udelay+0x28/0x30
[<ffffffffa03bae7a>] ar9003_get_pll_sqsum_dvc+0x4a/0x80 [ath9k_hw]
[<ffffffffa05174eb>] ath_hw_pll_work+0x5b/0xe0 [ath9k]
[<ffffffff810744fe>] process_one_work+0x11e/0x470
[<ffffffff8107530f>] worker_thread+0x15f/0x360
[<ffffffff810751b0>] ? manage_workers+0x230/0x230
[<ffffffff81079af3>] kthread+0x93/0xa0
[<ffffffff815fd3a4>] kernel_thread_helper+0x4/0x10
[<ffffffff81079a60>] ? kthread_freezable_should_stop+0x70/0x70
[<ffffffff815fd3a0>] ? gs_change+0x13/0x13

ensure that the PLL-WAR for AR9485/AR9340 is executed only if the STA is
associated (or) IBSS/AP mode had started beaconing. Ideally this WAR
is needed to recover from some rare beacon stuck during stress testing.
Before the STA is associated/IBSS had started beaconing, PLL4(0x1618c)
always seem to have zero even though we had configured PLL3(0x16188) to
query about PLL's locking status. When we keep on polling infinitely PLL4's
8th bit(ie check for PLL locking measurements is done), machine hangs
due to softlockup.

fixes https://bugzilla.redhat.com/show_bug.cgi?id=811142

Reported-by: Rolf Offermanns <rolf.offermanns@gmx.net>
Cc: stable@vger.kernel.org [3.0+]
Tested-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a23415fd 05-Jun-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: remove incompatible IBSS interface check in change_iface

'cfg80211: fix interface combinations' ensures that if an interface
type is not advertised by the driver in any of the interface combinations
(via ieee80211_iface_combination) then it shall be treated as a single
incompatible interface. if there are more than one interfaces present
and changing them to incompatible interface type is not possible.
These checks will be properly handled by cfg80211_change_iface ->
cfg80211_can_change_interface.

this patch is dependent on 'cfg80211: fix interface combinations'

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2031b4c2 05-Jun-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Fix a WARNING on suspend/resume with IBSS

this patch is dependent on the patch "cfg80211: fix interface
combinations"

In ath9k currently we have ADHOC interface as a single incompatible
interface. when drv_add_interface is called during resume we got to
consider number of vifs already present in addition to checking the
drivers 'opmode' information about ADHOC. we incorrectly assume
an ADHOC interface is already present. Then we may miss some driver
specific data for the ADHOC interface after resume.

The above mentioned checks can be removed from the driver,
as the patch 'cfg80211: fix interface combinations' ensures that
if an interface type is not advertised by the driver in any of the
interface combinations(via ieee80211_iface_combination) then it shall
be treated as a single incompatible interface. Fixes the following
warning on suspend/resume with ibss interface.

ath: phy0: Cannot create ADHOC interface when other
interfaces already exist.
WARNING: at net/mac80211/driver-ops.h:12
ieee80211_reconfig+0x1882/0x1ca0 [mac80211]()
Hardware name: 2842RK1
wlan2: Failed check-sdata-in-driver check, flags: 0x0

Call Trace:
[<c01361b2>] warn_slowpath_common+0x72/0xa0
[<f8aaa7c2>] ? ieee80211_reconfig+0x1882/0x1ca0
[mac80211]
[<f8aaa7c2>] ? ieee80211_reconfig+0x1882/0x1ca0
[mac80211]
[<c0136283>] warn_slowpath_fmt+0x33/0x40
[<f8aaa7c2>] ieee80211_reconfig+0x1882/0x1ca0 [mac80211]
[<c06c1d1a>] ? mutex_lock_nested+0x23a/0x2f0
[<f8a95097>] ieee80211_resume+0x27/0x70 [mac80211]
[<fd177edf>] wiphy_resume+0x8f/0xa0 [cfg80211]

Cc: stable@vger.kernel.org
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 196fb860 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Resync beacons properly

After a chip reset, the beacon timers have to re-programmed
correctly for a station in associated state. Use the PS flags
to ensure that this is done after a TSF sync happens, otherwise
the driver ends up using incorrect values for TBTT/DTIM in
powersave mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 07c15a3f 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix powersave locking

The 'ps_flags' is used/accessed in a variety of contexts
and requires proper locking. Use 'sc_pm_lock' appropriately.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b74713d0 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Handle fatal interrupts properly

When a fatal interrupt is received or it is detected that the baseband
has hung, the chip has to be reset immediately. Otherwise, we end up
processing spurious interrupts. Ensure that we bail out properly in
the ISR when the reset work hasn't completed yet.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 781b14a3 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use atomic operations

The 'sc_flags' variable is being used in a number of places
with no locking whatsoever. This patch converts the usage
of sc_flags to atomic ops.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8da07830 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Move LNA code to antenna.c

And use a helper function to setup antennae after a reset.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# af68abad 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix work handling

* Currently, there is no synchronization between the reset
work and the tx-poll work. Fix this and make sure that we
bail out properly if a reset work is in progress.

* Cleanup the PLL WAR and enable it for AR9340 too and
use a helper for restarting work/timers after a reset.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ef1b6cd9 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Group link monitoring logic

Add link.c and move all the link/connection monitoring
code to it.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c9ae6ab4 04-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath: do not update cycle counters with sleep mode

When the chip is waking up from sleep state, the cycle counters
might have incorrect readings. So it is better not to update those
readings with software counters.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4cb54fa3 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove SC_OP_OFFCHANNEL

mac80211's IEEE80211_CONF_OFFCHANNEL can be used directly
to track offchannel state. Also pass the correct boolean
value to ath9k_hw_startpcureceive().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e270e776 04-Jun-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Setup MCI interrupts properly

MCI interrupts have to be enabled only when BTCOEX is
actually in use.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b90bd9d1 15-May-2012 Ben Greear <greearb@candelatech.com>

ath9k: Support ethtool getstats api.

This returns many of the values that formerly could
only be obtained from debugfs. This should be an
improvement when trying to access these counters
programatically. Currently this support is only
enabled when DEBUGFS is enabled because otherwise
these stats are not accumulated.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ceea2a51 24-May-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: stop rx dma before stopping tx

It has been found that active Rx can interfere with stopping tx DMA, which
could result in at least parts of those "Failed to stop Tx DMA!" messages.
Stopping rx before tx should prevent that.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ad128860 23-Apr-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix IDLE Powersave

* PS_WAIT_FOR_TX_ACK is used in network-sleep mode and checking
it for handling IDLE transitions is incorrect. Fix this.

* RX PCU/DMA engines have to be stopped before setting the chip into
full-sleep mode - otherwise the chip becomes mute.

* Make things a bit clear by checking explicitly for network-sleep
mode in the tx() routine and add a couple of debug statements
to aid PS debugging.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ed2578cd 19-Apr-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: simplify beacon configuration for beaconing vifs

As of now beacon configuration is being called multiple times
in bss info change notification. This patch avoids multiple
configuration and make it simpler.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b381fa32 12-Apr-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: optimize the hardware hang check

Since it's only called when beacons are stuck, move it to the SWBA handler
tasklet, to avoid doing redundant checks on every single interrupt.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 75600abf 12-Apr-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: wake up the hardware from full sleep when idle is turned off

The hardware needs a reset to recover from full sleep. Issue this reset
directly in the ath9k_config call that turns off idle, otherwise tx
remains dead until the first channel change after the idle state change

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a5a0bca1 03-Apr-2012 Ben Greear <greearb@candelatech.com>

ath9k: Add tx-failed counter.

This counts any failure during getting packets into
the DMA buffers, including out-of-memory, etc.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 011afa1e 09-Apr-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

Revert "ath9k: fix going to full-sleep on PS idle"

This reverts commit c1afdaff90538ef085b756454f12b29575411214.

Users have reported connection failures in 3.3.1 and suspend/resume
failures in 3.4-rcX. Revert this commit for now - PS IDLE can be
fixed in a clean manner later on.

Cc: stable@vger.kernel.org
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 01e18918 14-Mar-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: recover ar9380 chips from rare stuck state

In the experiment with Azimuth ADEPT-n testbed where the APs transmit
power was reduced to 25% and the signal strength was futher attenuated
by 20dB and induced a path loss of ~7dB, the station was reporting
beacon losses and the following issue were observed.

* rx clear is stuck at low for more than 300ms
* dcu chain and complete state is stuck at one of the hang signature

This patch triggers the hang detection logic that recovers the chip
from any of the above conditions. As the issue was originally reported
in ChromeOs with AR9382 chips, this detection logic is enabled only for
AR9380/2 chips.

Cc: Paul Stewart <pstew@google.com>
Reported-by: Gary Morain <gmorain@google.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a4d6367f 26-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use HW HT capabilites properly

The commit "ath9k: Remove aggregation flags" changed how
nodes were being initialized. Use the HW HT cap bits
to initialize/de-initialize nodes, else we would be
accessing an uninitialized entry during a suspend/resume cycle,
resulting in a panic.

Reported-by: Justin P. Mattock <justinmattock@gmail.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d47a61aa 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix multi-VIF BSS handling

mac80211 provides short preamble information and ERP protection
information on a per-BSS basis, which can be used. Remove flags
stored in the driver, which was incorrect since they were being used
in a global manner.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3d4e20f2 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove aggregation flags

SC_OP_TXAGGR and SC_OP_RXAGGR are not really needed.
The HT capabilities of the station and HW can be used instead.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# caed6579 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k_hw: Cleanup FastChannelChange

The logic to determine whether to use FCC is a bit convoluted.
Use a small helper function to decide whether FCC is to be
used.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bcf6f96e 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove 'other' VIF count

It is not needed and will not be used anyway since
unsupported interfaces are not allowed to be created.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 62450b88 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove unused variables

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bf106e14 14-Mar-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove unnecessary initialization

There is no need to mask out SWBA/BMISS from the
interrupt mask in start().

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c1afdaff 10-Mar-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: fix going to full-sleep on PS idle

The check for PS_WAIT_FOR_TX_ACK was inverted, the hardware should only go
to full sleep if no tx is pending.

Reported-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@vger.kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9f61903c 09-Mar-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: configure bss info at assoc notification

The proper place to configure bss info is at assoc notification. So that
ath9k continues to work if the supirous bssid notification will be
removed in future.

Cc: Johannes Berg <johannes@sipsolutions.net>
Reported-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4286df60 27-Feb-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: do not call ath9k_hw_txprocdesc on AR9003 outside of the tx tasklet

Since AR9003 uses a global tx status queue, processing tx status outside of
the regular tx tasklet is dangerous and messes up hardware/software
synchronization of tx status events.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 56ca0dba 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Process BTCOEX interrupts using a helper

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# df198b17 21-Feb-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use proper start/stop routines for BTCOEX

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0a8a721d 14-Feb-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: remove unnecessary PS wrappers

ath_set_channel is called from ath9k_config which already has proper
PS wrappers

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5ce3df64 14-Feb-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: remove obsolete comments

the corresponding code/logic was removed in
"ath9k: rework power state handling"

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# feced201 30-Jan-2012 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Print the correct channel mode

channelFlags doesn't contain the operating HT mode.
Use IS_CHAN_HT40 to determine if the current channel is
in HT40 mode.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1a19f77f 09-Jan-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Fix regression in channelwidth switch at the same channel

The commit "ath9k: Fix invalid noisefloor reading due to channel update"
preserves the current channel noisefloor readings before updating
channel type at the same channel index. It is also updating the curchan
pointer. As survey updation is also referring curchan pointer to fetch
the appropriate index, which might leads to invalid memory access. This
patch partially reverts the change and stores the noise floor history
buffer before updating channel type w/o updating curchan.

Cc: stable@kernel.org
Cc: Gary Morain <gmorain@google.com>
Cc: Paul Stewart <pstew@google.com>
Reported-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b25bfda3 25-Dec-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Fix kernel panic in AR2427 in AP mode

don't do aggregation related stuff for 'AP mode client power save
handling' if aggregation is not enabled in the driver, otherwise it
will lead to panic because those data structures won't be never
intialized in 'ath_tx_node_init' if aggregation is disabled

EIP is at ath_tx_aggr_wakeup+0x37/0x80 [ath9k]
EAX: e8c09a20 EBX: f2a304e8 ECX: 00000001 EDX: 00000000
ESI: e8c085e0 EDI: f2a304ac EBP: f40e1ca4 ESP: f40e1c8c
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
Process swapper/1 (pid: 0, ti=f40e0000 task=f408e860
task.ti=f40dc000)
Stack:
0001e966 e8c09a20 00000000 f2a304ac e8c085e0 f2a304ac
f40e1cb0 f8186741
f8186700 f40e1d2c f922988d f2a304ac 00000202 00000001
c0b4ba43 00000000
0000000f e8eb75c0 e8c085e0 205b0001 34383220 f2a304ac
f2a30000 00010020
Call Trace:
[<f8186741>] ath9k_sta_notify+0x41/0x50 [ath9k]
[<f8186700>] ? ath9k_get_survey+0x110/0x110 [ath9k]
[<f922988d>] ieee80211_sta_ps_deliver_wakeup+0x9d/0x350
[mac80211]
[<c018dc75>] ? __module_address+0x95/0xb0
[<f92465b3>] ap_sta_ps_end+0x63/0xa0 [mac80211]
[<f9246746>] ieee80211_rx_h_sta_process+0x156/0x2b0
[mac80211]
[<f9247d1e>] ieee80211_rx_handlers+0xce/0x510 [mac80211]
[<c018440b>] ? trace_hardirqs_on+0xb/0x10
[<c056936e>] ? skb_queue_tail+0x3e/0x50
[<f9248271>] ieee80211_prepare_and_rx_handle+0x111/0x750
[mac80211]
[<f9248bf9>] ieee80211_rx+0x349/0xb20 [mac80211]
[<f9248949>] ? ieee80211_rx+0x99/0xb20 [mac80211]
[<f818b0b8>] ath_rx_tasklet+0x818/0x1d00 [ath9k]
[<f8187a75>] ? ath9k_tasklet+0x35/0x1c0 [ath9k]
[<f8187a75>] ? ath9k_tasklet+0x35/0x1c0 [ath9k]
[<f8187b33>] ath9k_tasklet+0xf3/0x1c0 [ath9k]
[<c0151b7e>] tasklet_action+0xbe/0x180

Cc: stable@kernel.org
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Reported-by: Ashwin Mendonca <ashwinloyal@gmail.com>
Tested-by: Ashwin Mendonca <ashwinloyal@gmail.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8a309305 17-Dec-2011 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: make bluetooth coexistence support optional at compile time

Many systems (e.g. embedded systems) do not have wifi modules connected to
bluetooth modules, so bluetooth coexistence is irrelevant there. With the
addition of MCI support, ath9k picked up quite a bit of extra code that
can be compiled out this way.

This patch redefines ATH9K_HW_CAP_MCI and adds an inline wrapper for
querying the bluetooth coexistence scheme, allowing the compiler to
eliminate code that uses it, with only very little use of #ifdef.

On MIPS this reduces the total size for the modules by about 20k.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d2182b69 15-Dec-2011 Joe Perches <joe@perches.com>

ath: Convert ath_dbg(bar, ATH_DBG_<FOO>, to ath_dbg(bar, FOO

Add ATH_DBG_ to macros to shorten the uses and
reduce the line count.

Coalesce ath_dbg formats.
Add missing spaces to coalesced formats.
Add missing newline terminations to ath_dbg formats.
Align ath_dbg arguments where appropriate.
Standardize ath_dbg formats without periods.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5bd5e9a6 07-Dec-2011 Chun-Yeow Yeoh <yeohchunyeow@gmail.com>

ath9k: Support RSN Mesh

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 156369fa 14-Dec-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: reduce the number of unnecessary BAR tx packets

When processing A-MPDU tx status, only send a BAR for the failed packet
with the highest sequence number.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4279425c 02-Dec-2011 Nikolay Martynov <mar.kolya@gmail.com>

ath9k: use config.enable_ani to check if ani should be performed

Currently in ath9k code there is an attempt which is meant to
disable ANI for ar9100 and ar9340. But it doesn't really achieve
this. All it does is disable ANI init and setup (i.e. calls to
ath9k_hw_ani_setup and ath9k_hw_ani_init). Since ath9k_hw_ani_setup is
not called ah->config.ani_poll_interval is never initialized (i.e. it
is always zero) and ath_ani_calibrate always executes ANI procedures
(over uninitialized ANI parameters).
Moreover, ath_ani_calibrate is being called each 1ms because
common->ani.timer is set to zero interval because
ah->config.ani_poll_interval==0 (and thus smallest value of all
intervals). Normally it should not be called this often.
This patch changes the code so config.enable_ani is used to check if
ANI should be performed.
config.enable_ani is initialized to true by default. This patch sets
it to false for ar9100 and ar9340.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 86951359 02-Dec-2011 Nikolay Martynov <mar.kolya@gmail.com>

ath9k: change calibration debug log to output all calibration types

To help debugging write a log entry when long calibration, short
calibration or ANI is performed.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# daa1b6ee 16-Nov-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: cancel all workqueue activity when going idle

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9df0d6a2 16-Nov-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: only drop packets in drv_flush when asked to

Recently more places in mac80211 call drv_flush to ensure proper order
for state changes wrt. powersave, channel changes, etc. On some systems
such calls lead to spurious logspam about failing to stop tx dma, as well
as hardware resets that go along with that.
Instead of dropping packets in a place where it's completely unnecessary,
only do it when drop == true.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c0c11741 16-Nov-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: rework power state handling

Turning off the radio when mac80211 tells the driver that it's idle is not
a good idea, as idle interfaces might still occasionally scan or send packets.
The only time the radio can be safely turned off is when drv_stop has been
called. In the mean time, use sc->ps_idle only to indicate network sleep vs
full sleep.
Move the LED GPIO changes out of the PCI suspend/resume path, the start/stop
functions already take care of that.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c8e8868e 16-Nov-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: always issue a full hw reset after waking up from full-sleep mode

After waking up from full sleep, registers are accessible, but rx/tx
typically fails. A fast channel change will not recover from this, so
ensure that a full-sleep -> wake transition is always followed by a full
reset.

The reason why this hasn't created any serious problems yet is that it's
hidden by the (wrong) behavior of enabling/disabling the radio when the
wiphy idle state changes.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 162d12de 04-Dec-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix check for antenna diversity support

fixes a regression on single-stream chips introduced in
commit 43c3528430bd29f5e52438cad7cf7c0c62bf4583
"ath9k: implement .get_antenna and .set_antenna"

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 19686ddf 29-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: MCI state machine based on MCI interrupt

Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 40dc5392 29-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Add MCI interrupt to interrupt mask

Cc: Wilson Tsao <wtsao@qca.qualcomm.com>
Cc: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7e1e3864 03-Nov-2011 Ben Greear <greearb@candelatech.com>

ath9k: Improve debugfs printout for stations.

Add interface address so it can be mapped to a local
interface. Add max-ampdu and mpdu-density.

Print out the tid->baw_size

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7dc181c2 24-Oct-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Add btcoex profile management support for AR9462

AR9462 chips have the capabilities to provoide bluetooth
profile information. For non-AR9462 btcoex chips, the BT
priority traffic was identified by periodically polling
the respective registers and updated dutycycle, stomptype,
etc. As AR9462 chip offers the BT profile informations,
let us make use of that to update aggregation limit,
dutycycle, stomptype and wieghtages.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 72d874c6 08-Oct-2011 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: make ath9k_hw_set_interrupts use ah->imask by default

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 030d6294 06-Oct-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: keep track of what's triggering hardware resets

Export how many times each of the reset triggers has fired through debugfs.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8a3a3c85 02-Oct-2011 Eliad Peller <eliad@wizery.com>

mac80211: pass vif param to conf_tx() callback

tx params should be configured per interface.
add ieee80211_vif param to the conf_tx callback,
and change all the drivers that use this callback.

The following spatch was used:
@rule1@
struct ieee80211_ops ops;
identifier conf_tx_op;
@@
ops.conf_tx = conf_tx_op;

@rule2@
identifier rule1.conf_tx_op;
identifier hw, queue, params;
@@
conf_tx_op (
- struct ieee80211_hw *hw,
+ struct ieee80211_hw *hw, struct ieee80211_vif *vif,
u16 queue,
const struct ieee80211_tx_queue_params *params) {...}

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 042ec453 29-Sep-2011 Johannes Berg <johannes.berg@intel.com>

mac80211: let drivers inform it about per TID buffered frames

For uAPSD implementation, it is necessary to know on
which ACs frames are buffered. mac80211 obviously
knows about the frames it has buffered itself, but
with aggregation many drivers buffer frames. Thus,
mac80211 needs to be informed about this.

For now, since we don't have APSD in any form, this
will unconditionally set the TIM bit for the station
but later with uAPSD only some ACs might cause the
TIM bit to be set.

ath9k is the only driver using this API and I only
modify it in the most basic way, it won't be able
to implement uAPSD with this yet. But it can't do
that anyway since there's no way to selectively
release frames to the peer yet.

Since drivers will buffer frames per TID, let them
inform mac80211 on a per TID basis, mac80211 will
then sort out the AC mapping itself.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1a8f0d39 22-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix a regression in ath9k_ps_restore

After 'ath9k: optimize ath9k_ps_restore', it would only send the device to
network sleep and not to full sleep anymore, potentially causing more
battery drain.

Reported-by: Vivek Natarajan <nataraja@qca.qualcomm.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 37a41b4a 21-Sep-2011 Eliad Peller <eliad@wizery.com>

mac80211: add ieee80211_vif param to tsf functions

TSF can be kept per vif.
Add ieee80211_vif param to set/get/reset_tsf, and move
the debugfs entries to the per-vif directory.

Update all the drivers that implement these callbacks.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d2c71c20 15-Sep-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Reset caldata on radio enable

Not doing so, the caldata continues to retain older history
values learned on that channel. It is always safer to start
noise floor calibration from the defaults after the assoication.
So this patch resets the nf history buffer when none of the
STA vifs are associated.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c6c539f0 14-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: optimize ath9k_ps_restore

ath_hw_cycle_counters_update only needs to be called if the power state
changes. Most of the time this does not happen, even when ps_usecount
goes down to 0.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3483288c 14-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: ensure that rx is not enabled during a reset

During a reset, rx buffers are flushed after rx has been disabled. To avoid
race conditions, rx needs to stay disabled during the reset, so avoid any
calls to ath9k_hw_rxena in that case.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e3927007 14-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix enabling interrupts after a hardware error interrupt

The interrupt handler increases the interrupt disable refcount, so the
tasklet needs to always call ath9k_hw_enable_interrupts.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 43c35284 02-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: implement .get_antenna and .set_antenna

On MIMO chips this can be used to enable/disable hardware chains, ensuring
that the MCS information is updated accordingly.
On non-MIMO chips with rx diversity (e.g. 9285), this configures the rx
input antenna.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9adcf440 02-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: merge reset related functions

reduces unnecessary code duplication. Also takes the sc_pcu_lock within
ath_reset instead of callsites, which makes it possible to always cancel
all queued work items before the reset, possibly fixing a few race
conditions (work items vs reset) along with it.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 236de514 02-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: always call ath_reset from workqueue context

This makes it much easier to add further rework to avoid race conditions
between reset and other work items.
Move other functions to make ath_reset static.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e8cfe9f8 02-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: move a few functions around

Helps with making ath_reset static in the next commit

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 82b2d334 02-Sep-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: eliminate common->{rx,tx}_chainmask

we already have ah->{rx,tx}chainmask for the same purpose

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6a6b3f3e 08-Sep-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Fix kernel panic on unplugging the device

when the device is yanked out ath_pci_remove starts doing the cleanups,
unregistering the hardware etc. so we should bail out immediately when
we get drv_flush callback from mac80211 when the card is being unplugged.
the panic occurs after we had associated to an AP.

EIP: 0060:[<fb315b00>] EFLAGS: 00010246 CPU: 0
EIP is at ath_reset+0xa0/0x1c0 [ath9k]
EAX: 00000000 EBX: 000697c0 ECX: 00000002 EDX: f3c3ccf0
ESI: 00000000 EDI: 00000000 EBP: f43e7b78 ESP: f43e7b50
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
Process kworker/u:2 (pid: 182, ti=f43e6000 task=f3c3c7c0
task.ti=f43e6000)
Stack:
0000002a 00000000 00000000 003e7b78 0000000f eaaa8500
ffffffea eaaa97c0
eaaaa000 00000001 f43e7ba8 fb315d23 f99e7721 ecece680
eaaac738 eaaa8500
eaaaa020 000000c8 000000c8 00000000 eaaa8d58 eaaa8500
f43e7bd0 fb080b29
Call Trace:
[<fb315d23>] ath9k_flush+0x103/0x170 [ath9k]
[<fb080b29>] __ieee80211_recalc_idle+0x2c9/0x400
[mac80211]
[<fb080c8e>] ieee80211_recalc_idle+0x2e/0x60 [mac80211]
[<fb07aa73>] ieee80211_mgd_deauth+0x173/0x210 [mac80211]
[<fb084559>] ieee80211_deauth+0x19/0x20 [mac80211]
[<f99dda53>] __cfg80211_mlme_deauth+0xf3/0x140
[cfg80211]
[<c0633d00>] ? __mutex_lock_common+0x1f0/0x380
[<f99e1b5d>] __cfg80211_disconnect+0x18d/0x1f0
[cfg80211]
[<f99c8199>] cfg80211_netdev_notifier_call+0x159/0x5c0
[cfg80211]
[<c0608a64>] ? packet_notifier+0x174/0x1f0
[<c0639202>] notifier_call_chain+0x82/0xb0
[<c0170d8f>] raw_notifier_call_chain+0x1f/0x30
[<c053b86c>] call_netdevice_notifiers+0x2c/0x60
[<c0182184>] ? trace_hardirqs_on_caller+0xf4/0x180
[<c053b8ec>] __dev_close_many+0x4c/0xd0
[<c053ba2d>] dev_close_many+0x6d/0xc0
[<c053bb53>] rollback_registered_many+0x93/0x1c0
[<c018221b>] ? trace_hardirqs_on+0xb/0x10
[<c053bc95>] unregister_netdevice_many+0x15/0x50
[<fb07f83b>] ieee80211_remove_interfaces+0x7b/0xb0
[mac80211]
[<fb06a14b>] ieee80211_unregister_hw+0x4b/0x110
[mac80211]
[<fb311a4a>] ath9k_deinit_device+0x3a/0x60 [ath9k]
[<fb31eed6>] ath_pci_remove+0x46/0x90 [ath9k]
[<c03b4ac4>] pci_device_remove+0x44/0x100
[<c043eb54>] __device_release_driver+0x64/0xb0
[<c043ec67>] device_release_driver+0x27/0x40
[<c043deeb>] bus_remove_device+0x7b/0xa0
[<c043c491>] device_del+0xf1/0x180
[<c043c530>] device_unregister+0x10/0x20
[<c03afafe>] pci_stop_bus_device+0x6e/0x80
[<c03afb72>] pci_remove_bus_device+0x12/0xa0
[<c03c2f29>] pciehp_unconfigure_device+0x89/0x180
[<c0181e54>] ? mark_held_locks+0x64/0x100
[<c063390f>] ? __mutex_unlock_slowpath+0xaf/0x140
[<c03c1f84>] pciehp_disable_slot+0x64/0x1b0
[<c03c2850>] pciehp_power_thread+0xd0/0x100
[<c0164ad0>] ? process_one_work+0x100/0x4d0
[<c0164b4c>] process_one_work+0x17c/0x4d0
[<c0164ad0>] ? process_one_work+0x100/0x4d0
[<c03c2780>] ? queue_interrupt_event+0xa0/0xa0
[<c01662bb>] worker_thread+0x13b/0x320
[<c018221b>] ? trace_hardirqs_on+0xb/0x10
[<c0166180>] ? manage_workers+0x1e0/0x1e0
[<c016a654>] kthread+0x84/0x90
[<c016a5d0>] ? __init_kthread_worker+0x60/0x60
[<c063d106>] kernel_thread_helper+0x6/0x10

Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cf3af748 27-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Add debugfs support for mac/baseband samples

This patch keep track of number of samples that includes
DMA debugs registers, PCU observe, CR, channel noise,
cycle conters, noisefloor history buffer and last N number
of tx and rx descriptor status. These samples are grouped
in table manner which dumping in debgufs.

Debugfs file location:
<debugfs_mnt>/ieee80211/phy#/ath9k/samples

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 52c94f41 20-Aug-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Add support for get_stats callback

this useful for debugging and to keep track of success/failure of
frames such as ACK, RTS and FCS error count in a noisy environment

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e338a85e 12-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Fix invalid noisefloor reading due to channel update

While switching b/w HT20/40, the current channel's nf values
are updated into history buffer. Since the current channel's
channel type, channel flag got updated before reading
nf value from hw. This channel type mismatch is causing invalid
readings when hw is on ht20 but getnf tries to read on extn chains.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d77bf3eb 12-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Remove SC_OP_ENABLE_APM

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0682c9b5 12-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Fix rx overrun interrupt storm

Whenever RXEOL is received, both RXORN and RXEOL got cleared
to avoid rx overrun interrupt storm. This was handled only for
edma chips. The same scenario was also observered with AR9280,
doing frequent channel type switch b/w HT20/40 with bidi traffic
that is causing failure to stop rx dma. This patch clears
the RXEOL & RXORN interrupts for all chips.

ath: DMA failed to stop in 10 ms AR_CR=0x00000024 AR_DIAG_SW=0x42000020
DMADBG_7=0x000062c0
ath: Could not stop RX, we could be confusing the DMA engine when we
start RX up
------------[ cut here ]------------
WARNING: at drivers/net/wireless/ath/ath9k/recv.c:532
ath_stoprecv+0x110/0x120 [ath9k]()
Call Trace:
[<ffffffff8104a55a>] warn_slowpath_common+0x7a/0xb0
[<ffffffff8104a5a5>] warn_slowpath_null+0x15/0x20
[<ffffffffa0560380>] ath_stoprecv+0x110/0x120 [ath9k]
[<ffffffffa055e6fa>] ath_reset+0x6a/0x200 [ath9k]

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8b2a3827 24-Aug-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Fix PS wrappers in ath9k_set_coverage_class

this callback is called during suspend/resume and also via iw command.
it configures parameters like sifs, slottime, acktimeout in
ath9k_hw_init_global_settings where few REG_READ, REG_RMW are also done
and hence the need for PS wrappers

Cc: stable@kernel.org
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 69ce674b 05-Aug-2011 Stanislaw Gruszka <sgruszka@redhat.com>

ath9k: do btcoex ASPM disabling at initialization time

Disable ASPM in pci ->probe on upstream (device) and downstream
(PCIe port) component. According to e1000e driver authors this is
required. I did not find that requirement in PCIe spec, but it seems
to be logical for me.

This need to be fixed for CONFIG_PCIEASPM, that will be done later ...

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 84c87dc8 05-Aug-2011 Stanislaw Gruszka <sgruszka@redhat.com>

ath9k: remove ->config_pci_powersave() redundant argument

We always call ->config_pci_powersave() with both restore and power_off
arguments equal to 0 or both equal to 1, so merge them into one
argument.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e8fe7336 05-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Use atomic reference count for interrupt ops

Let us enable/disable interrupts based on reference count.
By doing this we can ensure that interrupts are never be
enabled in the middle of tasklet processing. Instead of
addressing corner cases like "ath9k: avoid enabling interrupts
while processing rx", this approach handles it in generic manner.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b037b693 05-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: do not enable interrupt on set interrupt mask

At preset set_interrupt also enables interrupt after changing
mask. This is not necessary in all cases and also sometime it
breaks the assumption that interrupt was disabled. So let us
enable the interrupt explicity if it was disabled earlier.
This could also avoid unnecessary register ops and also helps
the follow up patch to have global ref count for interrupts ops.

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f749b946 28-Jul-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: use the new channel noise value for signal strength and survey info

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f6b4e4d4 24-Jun-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Fix locking issue during tx completion

The received tx status of aggregated frame without BlockAck may
cause deaf state in AR5416 cards. So the driver does a reset to
recover. When this happens, we release the pcu_lock before doing
a reset as ath_rest acquires pcu_lock. This is ugly and also not
atomic. Fixing this addresses the TX DMA failure also.

ath_tx_complete_aggr can be called from different paths which
takes different variants of spin_lock. This patch also addresses
the following warning.

WARNING: at kernel/timer.c:1011 del_timer_sync+0x4e/0x50()
Call Trace:
<IRQ> [<ffffffff8104be3a>] warn_slowpath_common+0x7a/0xb0
[<ffffffff8104be85>] warn_slowpath_null+0x15/0x20
[<ffffffff8105915e>] del_timer_sync+0x4e/0x50
[<ffffffffa03726be>] ath_reset+0x3e/0x210 [ath9k]
[<ffffffff8135cdaf>] ? _raw_spin_unlock_bh+0x1f/0x30
[<ffffffffa037760a>] ath_tx_complete_aggr.isra.26+0x54a/0xa40 [ath9k]

Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d3af4396 15-Jun-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: remove a redundant call to pcipowersave

during suspend/resume ath9k_stop will always call ath_radio_disable
which will inturn call ath9k_hw_configpcipowersave, so no need to call
it explicitly in ath9k_stop

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d4bb17c4 15-Jun-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Add debug messages to track PAPRD failures

Add few debug messages for some of the possible scenarios
where we can detect PAPRD failures. this will help us to be
sure that we had really enabled PAPRD

Cc: susinder@qca.qualcomm.com
Cc: senthilb@qca.qualcomm.com
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 05c0be2f 25-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Add a debug entry to start/stop ANI

this helps the user to start/stop ANI dynamically.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b942471b 24-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: wake up chip before initializing PAPRD table

In PAPRD table initialization path we do some register read, so
make sure the chip is awake during that. Currently PAPRD is disabled.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2e5ef459 20-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Handle IBSS status changes in BSS_CHANGED_IBSS

Configure ibss node's bss_changes under BSS_CHANGED_IBSS.
And also start/stop ani timer only if the station join/leave
the group.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5595f119 19-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: mark few functions as static

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6d79cb4c 19-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: make ath9k_setpower function as static

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fce041be 18-May-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: unify edma and non-edma tx code, improve tx fifo handling

EDMA based chips (AR9380+) have 8 Tx FIFO slots, which are used to fix the
tx queue start/stop race conditions which have to be worked around for
earlier chips by keeping the last descriptor in the queue. The current code
stores all frames that do not fit onto the 8 FIFO slots in a separate
list. Whenever a FIFO slot is freed up, the next frame (or A-MPDU) from the
pending queue gets moved to that slot.

This process is not only inefficient, but also unnecessary. The code can
be improved visibly by keeping the pending queue fully linked, and moving
the contents of the entire queue to a FIFO slot as it becomes available.

This patch makes the necessary changes for that and also merges some code
that was duplicated for EDMA vs non-EDMA. It changes txq->axq_link to point
to the last descriptor instead of the link pointer, so that
ath9k_hw_set_desc_link can be used, which works on all chips.

With this patch, a small performance increase for non-aggregated traffic
was observed on AR9380 based embedded hardware.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e62ddec9 19-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: remove redundant if check

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a4d86d95 20-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Reset chip on baseband hang

Resetting hardware helps to recover from baseband
hang/panic for AR9003 based chips.

Cc: stable@kernel.org
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ba4903f9 17-May-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: implement .tx_last_beacon()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5b68138e 17-May-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com>

ath9k: Drag the driver to the year 2011

The Times They Are a-Changin'.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 108697c4 13-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: make npending frames check as bool

we are not doing anything by tracking the number of pending frames.
bail out when we first find a pending frame in any one of the 10 queues.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f59a59fe 10-May-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix a regression in PS frame filter handling

Only leave filtering enabled for AP or VLAN interfaces, clear the
destination mask for all other interfaces.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Ben Greear <greearb@candelatech.com>
Tested-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fd5999cf 03-May-2011 Javier Cardona <javier@cozybit.com>

ath9k: fix beaconing for mesh interfaces

Mesh beaconing on ath9k was broken by this commit:

commit 4801416c76a3a355076d6d371c00270dfe332e1c
Author: Ben Greear <greearb@candelatech.com>
Date: Sat Jan 15 19:13:48 2011 +0000

This patch assigns the right opmode when the device is used in mesh
mode.

Reported-by: Fabrice Deyber fabricedeyber@agilemesh.com
Signed-off-by: Javier Cardona <javier@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 729da390 09-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Failed to set default beacon rssi in AP/IBSS mode

This beacon rssi will be used to set noisefloor during ani reset.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4105f807 06-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: process TSF out of range before RX

Processing TSF out of range before RX helps to update beacon
timers so early in the succeeding rx process.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# deb75188 06-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: avoid enabling interrupts while processing rx

The assumsion is that while processing ath9k tasklet,
interrupts were already disabled and it will be enabled
at the completion of ath9k tasklet. But whenever TSFOOR is raised,
the driver configures the beacon timers after having received a
beacon frame from the AP which inturn enables the interrupts.

Cc: stable@kernel.org
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 99aa55b6 06-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Fix a warning due to a queued work during S3 state

during suspend/S3 state drv_flush is called from mac80211 irrespective of
interface count. In ath9k we queue a work in ath9k_flush which we expect
to be cancelled in the drv_stop call back. during suspend process mac80211
calls drv_stop only when the interface count(local->count) is non-zero.
unfortunately when the network manager is enabled, drv_flush is called
while drv_stop is not called as local->count reaches '0'.
So fix this by simply checking for the device presence in the
drv_flush call back in the driver before queueing work or anything else.
this patch fixes the following WARNING

Call Trace:
[<c014c6e2>] warn_slowpath_common+0x72/0xa0
[<fc133f99>] ? ieee80211_can_queue_work+0x39/0x50 [mac80211]
[<fc133f99>] ? ieee80211_can_queue_work+0x39/0x50 [mac80211]
[<c014c75b>] warn_slowpath_fmt+0x2b/0x30
[<fc133f99>] ieee80211_can_queue_work+0x39/0x50 [mac80211]
[<fc134ed1>] ieee80211_queue_delayed_work+0x21/0x50 [mac80211]
[<fc1e5b22>] ath_tx_complete_poll_work+0xb2/0x100 [ath9k]
[<c016399e>] run_workqueue+0x8e/0x150
[<fc1e5a70>] ? ath_tx_complete_poll_work+0x0/0x100 [ath9k]
[<c0163ae4>] worker_thread+0x84/0xe0
[<c0167a60>] ? autoremove_wake_function+0x0/0x50
[<c0163a60>] ? worker_thread+0x0/0xe0
[<c01677d4>] kthread+0x74/0x80
[<c0167760>] ? kthread+0x0/0x80
[<c0104087>] kernel_thread_helper+0x7/0x10
---[ end trace 2aff81010df9215b ]---

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cbe8c735 03-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k_hw: remove aggregation protection mode

when aggregation protection mode is enabled the hardware needs
to send RTS/CTS for each HT frame. Currently its disabled so
remove the unused call backs.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2f6fc351 28-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Fix drain txq failure in flush

While draining the txq in flush, the buffers can be
added into the tx queue by tx_tasklet which leads to
unneccesary chip reset.

This issue was originially found with AR9382 and
running heavy uplink udp traffic with higher bandwidth
and doing frequent bgscan.

Cc: stable@kernel.org
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 92c6f76c 22-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: set beacon related ps flags on bss_info change

Requesting beacon sync up to configure beacon timers properly
in hw, has be done after doing beacon config with default values.
Setting the flags in beacon config is causing the device to not
enter into network sleep on idle state.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b84628eb 22-Apr-2011 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Add power save wrappers and modularize hw_pll handler

We should protect hw_pll handler with power save wrappers and
also modularize hw_pll handler properly for better readability.

Also add a debug message to track chip resets on pll hang condition.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9eab61c2 22-Apr-2011 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: cleanup hw pll work handler

There is no reason why pll work handler should be part of xmit
file. move it to main.c so that reading hw check routines are
all in the same place.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 51513906 22-Apr-2011 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: optimize the usage of power save wrappers.

We need not wake up the chip even before mutex lock is acquired and also
that it is required only if we are going to drain the txq. So place the
wrappers accordingly and this change is also useful when there are no
pending frames in the txq as we do not wake up the chip unnecessarily.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 93ae2dd2 17-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: assign keycache slots to unencrypted stations

Frame filtering relies on having a valid destination index (keycache slot),
to keep track of the destination. Assigning a keycache slot (configured
to unencrypted, with no key data attached) improves powersave handling in
AP mode with no encryption.
The dummy keycache entry for a station is cleared, when a real key gets
added.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5519541d 17-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix powersave frame filtering/buffering in AP mode

This patch fixes a long standing issue of pending packets in the queue being
sent (and retransmitted many times) to sleeping stations.
This was made worse by aggregation through driver-internal retransmitting
of A-MDPU subframes.
Previously the hardware tx filter was cleared unconditionally for every
single packet - with this patch it uses the IEEE80211_TX_CTL_CLEAR_PS_FILT
for unaggregated frames.
A sta_notify driver op is added to stop aggregation for stations when they
enter powersave mode. Subframes stay buffered inside the driver, to ensure
that the BlockAck window keeps a sane state.
Since the driver uses software aggregation, the clearing of the tx filter
needs to be handled by the driver instead of mac80211 for aggregated frames.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f60c49b6 08-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Fix kernel panic on module unload

The commit "ath9k: configure beacons based on hw opmode" introduced
a regression which leads to kernel panic. Failed to stop ani timer
during the driver unload while any of the beaconing vif is running.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 15b91e83 06-Apr-2011 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Implement dev_tx_frames_pending callback.

This function returns true if there is atleast one frame
in any one of the tx queues.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 96f372c9 07-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix missing ath9k_ps_wakeup/ath9k_ps_restore calls

These missing chip wakeups mainly cause crashes on AR5416 cards in MIPS
boards, but have also been reported to cause radio stability issues on
AR9285.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 99e4d43a 04-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: configure beacons based on hw opmode

Current ath9k code does not handle beacon timers on opmode
specific. One such example is that a STA beacon config overwrites
already configured AP vif's beacon timers during scan.

On multi station vif case, configure beacon timers beased
on primary vif selected. This also helps while moving back
to single STA vif from multi STA vifs, where the power save
is enabled and hw has to be reconfigured with proper
beacon and bssid/aid. Otherwise connection poll will be triggered
so frequently due to beacon loss.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4f5ef75b 04-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Handle BSSID/AID for multiple interfaces

As of now bssid/aid is overridden with recently changed vif's
bss config. This may cause improper beacon updation due to
bssid/aid mismatch. On station mode, select an associated
sta vif as primary vif and configure that vif's bss into hw.
Update the primary vif on interface change and bss info change.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 66da4241 04-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Cleanup ath_vif struct

Remove unused bssid from ath_vif and set av_bslot on beacon
alloc/return.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 59575d1c 04-Apr-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: deny new interface addtion on IBSS mode

The present check denies the IBSS interface addtion if we
already have any other vifs. But it fails to deny interface
addition if IBSS was already present.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cfdc9a8b 23-Mar-2011 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Support RSN IBSS

Add support for using RSN IBSS with ath9k. For now, this uses software
crypto for group addressed frames in RSN IBSS, but that may be
optimized in the future by extending the key cache design to support
per-STA RX GTK.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f62d816f 25-Mar-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix a chip wakeup related crash in ath9k_start

When the chip is still asleep when ath9k_start is called,
ath9k_hw_configpcipowersave can trigger a data bus error.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d78f4b3e 23-Mar-2011 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Fix TX queue stuck issue.

commit 86271e460a66003dc1f4cbfd845adafb790b7587 introduced a
regression that caused mac80211 queues in stopped state.

ath_drain_all_txq is called in driver flush which would reset
the stopped flag and the mac80211 queues were never started
after that. iperf traffic is completely stalled due to this issue.

Restart the mac80211 queues in driver flush only if the txqs were
drained.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 86271e46 11-Mar-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix the .flush driver op implementation

This patch simplifies the flush op and reuses ath_drain_all_txq for
flushing out pending frames if necessary. It also uses a global timeout
of 200ms instead of the per-queue 60ms timeout.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0cf55c21 27-Feb-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: use generic mac80211 LED blinking code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08f6c852 25-Feb-2011 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Fix compilation warning.

Initialize txq to avoid this warning:

drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_flush’:
drivers/net/wireless/ath/ath9k/main.c:2138: warning: ‘txq’ may be used uninitialized in this function

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7e3514fd 25-Feb-2011 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Cancel pll_work while disabling radio.

pll_work should be cancelled on full_sleep or it may cause
redundant chip reset.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7bb45683 24-Feb-2011 Johannes Berg <johannes.berg@intel.com>

mac80211: make tx() operation return void

The return value of the tx operation is commonly
misused by drivers, leading to errors. All drivers
will drop frames if they fail to TX the frame, and
they must also properly manage the queues (if they
didn't, mac80211 would already warn).

Removing the ability for drivers to return a BUSY
value also allows significant cleanups of the TX
TX handling code in mac80211.

Note that this also fixes a bug in ath9k_htc, the
old "return -1" there was wrong.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Tested-by: Sedat Dilek <sedat.dilek@googlemail.com> [ath5k]
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> [rt2x00]
Acked-by: Larry Finger <Larry.Finger@lwfinger.net> [b43, rtl8187, rtlwifi]
Acked-by: Luciano Coelho <coelho@ti.com> [wl12xx]
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 69081624 19-Feb-2011 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Implement op_flush()

When op_flush() is called with no drop (drop=false), the driver
tries to tx as many frames as possible in about 100ms on every
hw queue. During this time period frames from sw queue are also
scheduled on to respective hw queue.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0f5cd459 15-Feb-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Fix ath9k prevents CPU to enter C3 states

The DMA latency issue is observed only in Intel pinetrail platforms
but in the driver we had a default PM-QOS value of 55. This caused
unnecessary power consumption and battery drain in other platforms.

Remove the pm-qos thing in the driver code and address the throughput
issue in Intel pinetrail platfroms in user space using any one of
the scripts in below links:

http://www.kernel.org/pub/linux/kernel/people/mcgrof/scripts/cpudmalatency.c
http://johannes.sipsolutions.net/files/netlatency.c.txt

More details can be found in the following bugzilla link:

https://bugzilla.kernel.org/show_bug.cgi?id=27532

This reverts the following commits:

98c316e348bedffa730e6f1e4baeb8a3c3e0f28b
4dc3530df7c0428b41c00399a7ee8c929406d181
10598c124ecabbbfd7522f74de19b8f7d52a1bee

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 014cf3bb 09-Feb-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: disable beaconing before stopping beacon queue

Beaconing should be disabled before stopping beacon queue.
Not doing so could queue up beacons in hw that causes
failure to stop Tx DMA, due to pending frames in hw
and also unnecessary beacon tasklet schedule.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9814f6b3 07-Feb-2011 Steve Brown <sbrown@cortland.com>

ath9k: Remove redundant beacon_interval

The variable appears in both ath_softc and ath_beacon_config.
The struct ath_beacon_config is embedded in ath_softc. The redundant
variable was added by commit id 57c4d7b4c4986037be51476b8e3025d5ba18d8b8.

Signed-off-by: Steve Brown <sbrown@cortland.com>
Reviewed-by: Mohammed Shafi <shafi.ath9k@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 603b3eef 07-Feb-2011 Ben Greear <greearb@candelatech.com>

ath9k: Add debug info for configuring power level.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8c79a610 07-Feb-2011 Ben Greear <greearb@candelatech.com>

ath9k: Print channel-type in chan-change dbg message.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cb8d61de 04-Feb-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: add additional checks for the baseband hang detection

Since even with the latest changes the false positive issue of the baseband
hang check is not fully solved yet, additional checks are needed.
If the baseband hang occurs, the rx_clear signal will be stuck to high, so
we can use the cycle counters to confirm it.
With this patch, a hardware reset is only triggered if the baseband hang
check returned true three times in a row, with a beacon interval between
each check and if the busy time was also 99% or more during the check
intervals.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9cf04dcc 04-Feb-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Fix possible double free of PAPRD skb's

This patch reverts the following commit
ath9k: remove bfs_paprd_timestamp from struct ath_buf_state

Under high interference/noisy environment conditions where PAPRD frames
fails heavily introduces a possibility of double freeing skb's and causes
kernel panic after some time.This patch reverts back to the original approach
of using paprd_timestamp before freeing the PAPRD frame skb's

[ 194.193705] Pid: 0, comm: swapper Tainted: G D WC
2.6.35-22-generic #33-Ubuntu
[ 194.193712] Call Trace:
[ 194.193722] [<c05c6468>] ? printk+0x2d/0x35
[ 194.193732] [<c05c63c3>] panic+0x5a/0xd2
[ 194.193741] [<c05ca3ed>] oops_end+0xcd/0xd0
[ 194.193750] [<c0105f74>] die+0x54/0x80
[ 194.193758] [<c05c9a16>] do_trap+0x96/0xc0
[ 194.193837] [<c0103fb0>] ? do_invalid_op+0x0/0xa0
[ 194.193846] [<c010403b>] do_invalid_op+0x8b/0xa0
[ 194.193856] [<c020bd4c>] ? kfree+0xec/0xf0
[ 194.193866] [<c012ce18>] ? default_spin_lock_flags+0x8/0x10
[ 194.193877] [<c01de47a>] ? free_one_page+0x12a/0x2d0
[ 194.193888] [<c01e04dc>] ? __free_pages+0x1c/0x40
[ 194.193897] [<c05c97a7>] error_code+0x73/0x78
[ 194.193906] [<c020bd4c>] ? kfree+0xec/0xf0
[ 194.193915] [<c04ecdd0>] ? skb_release_data+0x70/0xa0
[ 194.193924] [<c04ecdd0>] skb_release_data+0x70/0xa0
[ 194.193933] [<c04ec997>] __kfree_skb+0x17/0x90
[ 194.193941] [<c04eca31>] consume_skb+0x21/0x40
[ 194.193964] [<f85e0b70>] ieee80211_tx_status+0x760/0x860 [mac80211]
[ 194.193979] [<f85caddf>] ath_tx_complete_buf+0x1bf/0x2c0 [ath9k]
[ 194.193988] [<c05c8b9f>] ? _raw_spin_lock_irqsave+0x2f/0x50
[ 194.193997] [<c04ec40e>] ? skb_queue_tail+0x3e/0x50
[ 194.194010] [<f85cc803>] ath_tx_complete_aggr+0x823/0x940 [ath9k]
[ 194.194021] [<c0108a28>] ? sched_clock+0x8/0x10
[ 194.194030] [<c016bf14>] ? sched_clock_local+0xa4/0x180
[ 194.194040] [<c0139f57>] ? enqueue_sleeper+0x1e7/0x2b0
[ 194.194051] [<c013a194>] ? enqueue_entity+0x174/0x200
[ 194.194064] [<f85ce83d>] ath_tx_edma_tasklet+0x2bd/0x3b0 [ath9k]
[ 194.194074] [<c05c8b9f>] ? _raw_spin_lock_irqsave+0x2f/0x50
[ 194.194088] [<f85c7b9f>] ath9k_tasklet+0x9f/0x190 [ath9k]
[ 194.194097] [<c01505d7>] tasklet_action+0xa7/0xb0
[ 194.194107] [<c015127c>] __do_softirq+0x9c/0x1b0
[ 194.194117] [<c01a7f64>] ? irq_to_desc+0x14/0x20
[ 194.194126] [<c0124fc4>] ? ack_apic_level+0x64/0x1f0
[ 194.194136] [<c01513d5>] do_softirq+0x45/0x50
[ 194.194145] [<c0151545>] irq_exit+0x65/0x70
[ 194.194153] [<c05cf665>] do_IRQ+0x55/0xc0
[ 194.194162] [<c016a6c7>] ? hrtimer_start+0x27/0x30
[ 194.194171] [<c0103630>] common_interrupt+0x30/0x38
[ 194.194181] [<c012c21a>] ? native_safe_halt+0xa/0x10
[ 194.194268] [<c010a2f9>] default_idle+0x49/0xb0
[ 194.194277] [<c0101fcc>] cpu_idle+0x8c/0xd0
[ 194.194286] [<c05b2431>] rest_init+0x71/0x80
[ 194.194295] [<c081981a>] start_kernel+0x36e/0x374
[ 194.194305] [<c08199dd>] ? pass_all_bootoptions+0x0/0xa
[ 194.194314] [<c08190d7>] i386_start_kernel+0xd7/0xdf
[ 194.194364] panic occurred, switching back to text console

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 391bd1c4 01-Feb-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: reserve a beacon slot on beaconing vif addition

The beaconing vif addition is based on max beacon slot
available. So it is better to reserve a beacon slot
on interface addition and let it be configured properly
on bss_info change.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4c89fe95 31-Jan-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: do not access hw registers in FULL SLEEP

The opmode recalculation is accessing hw registers.
When it is called from remove interface callback and
if there are no vifs present then hw is moved to FULL SLEEP
by radio disable. So use power save wrappers before
accessing hw registers in calculating opmode state.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5048e8c3 31-Jan-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: move update tx power to common

move ath_update_txpow to common to remove code duplication
in both ath9k & ath9k_htc.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c344c9cb 31-Jan-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: use common get current channel function

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 47960077 31-Jan-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Fix memory leak due to failed PAPRD frames

free the skb's when the Tx of PAPRD frames fails and also add a debug
message indicating that.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b955fba2 31-Jan-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Fix memory leak due to failed PAPRD frames

free the skb's when the Tx of PAPRD frames fails and also add a debug
message indicating that.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# de87f736 27-Jan-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: use common API to avoid code duplication

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 181fb18d 27-Jan-2011 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Fix a PLL hang issue observed with AR9485.

When this PLL hang issue is seen, both Rx and Tx fail to work.
The sqsum_dvc needs to be below 2000 for a good chip. During
this issue the sqsum_dvc value is beyond 80000 and only a
full reset can solve this problem.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0d95521e 26-Jan-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: use split rx buffers to get rid of order-1 skb allocations

With this change, less CPU time is spent trying to look for consecutive
pages for rx skbs. This also reduces the socket memory required for IP/UDP
reassembly.
Only two buffers per frame are supported. Frames spanning more buffers
will be dropped, but the buffer size is enough to handle the required
AMSDU size.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9ac58615 24-Jan-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fold struct ath_wiphy into struct ath_softc

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7545daf4 24-Jan-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: remove support for virtual wiphys

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 92460412 24-Jan-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: clean up the code that wakes the mac80211 queues

Instead of spreading ath_wake_mac80211_queue() calls over multiple places
in the tx path that process the tx queue for completion, call it only
where the pending frames counter gets decremented, eliminating some
redundant checks.
To prevent queue draining from waking the queues prematurely (e.g. during
a hardware reset), reset the queue stop state when draining all queues,
as the caller in main.c will run ieee80211_wake_queues(hw) anyway.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c7c18060 27-Jan-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Fix power save usage count imbalance on deinit

While unloading the driver, the ps_usecount is incremented
before configuring gpio registers in deinit_device.
But it is failed to restore the ps_usecount after that.
The problem is that the chip is forcibly moved to FULL SLEEP
by radio_disable when mac80211 is reporting as idle
though ps_usecount is not zero.

This patch retores ps_usecount properly and ensures that
the chip is always moved to full sleep only if ps usage
count is zero which also helps in debugging deadbeef on
multivif case. And also fixes the following warning.

ath: DMA failed to stop in 10 ms AR_CR=0xdeadbeef AR_DIAG_SW=0xdeadbeef
ath: Could not stop RX, we could be confusing the DMA engine when we
start RX up
------------[ cut here ]------------
WARNING: at drivers/net/wireless/ath/ath9k/recv.c:536
ath_stoprecv+0xf4/0x100 [ath9k]()

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 203043f5 25-Jan-2011 Stanislaw Gruszka <sgruszka@redhat.com>

ath9k: fix race conditions when stop device

We do not kill any scheduled tasklets when stopping device, that may
cause usage of resources after free. Moreover we enable interrupts
in tasklet function, so we could potentially end with interrupts
enabled when driver is not ready to receive them.

I think patch should fix Ben's kernel crash from:
http://marc.info/?l=linux-wireless&m=129438358921501&w=2

Cc: stable@kernel.org
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7f010c93 10-Jan-2011 Ben Greear <greearb@candelatech.com>

ath9k: Keep track of stations for debugfs.

The stations hold the ath_node, which holds the tid
and other xmit logic structures. In order to debug
stuck xmit logic, we need a way to print out the tid
state for the stations.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 783cd01e 21-Jan-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: add missing ps wakeup/restore calls

There are several places where ath_reset() was called without proper
calls to ath9k_ps_wakeup/ath9k_ps_restore. To fix this, add those calls
directly to ath_reset and drop them from callers where it makes sense.

Also add them to the config callback around ath_update_txpow to fix a
crash that happens when the tx power changed before any vif is brought up.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0b01f030 18-Jan-2011 Johannes Berg <johannes.berg@intel.com>

mac80211: track receiver's aggregation reorder buffer size

The aggregation code currently doesn't implement the
buffer size negotiation. It will always request a max
buffer size (which is fine, if a little pointless, as
the mac80211 code doesn't know and might just use 0
instead), but if the peer requests a smaller size it
isn't possible to honour this request.

In order to fix this, look at the buffer size in the
addBA response frame, keep track of it and pass it to
the driver in the ampdu_action callback when called
with the IEEE80211_AMPDU_TX_OPERATIONAL action. That
way the driver can limit the number of subframes in
aggregates appropriately.

Note that this doesn't fix any drivers apart from the
addition of the new argument -- they all need to be
updated separately to use this variable!

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4801416c 15-Jan-2011 Ben Greear <greearb@candelatech.com>

ath9k: Fix up hardware mode and beacons with multiple vifs.

When using a mixture of AP and Station interfaces,
the hardware mode was using the type of the
last VIF registered. Instead, we should keep track
of the number of different types of vifs and set the
mode accordingly.

In addtion, use the vif type instead of hardware opmode
when dealing with beacons.

Attempt to move some of the common setup code into smaller
methods so we can re-use it when changing vif mode as
well as adding/deleting vifs.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8b3f4616 10-Jan-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: reduce the likelihood of baseband hang check false positives

Since baseband hangs are rare, but the hang check function has a high
false positive rate in some situations, we need to add more reliable
indicators.

In AP mode we can use blocked beacon transmissions as an indicator,
they should be rare enough.

In station mode, we can skip the hang check entirely, since a true
hang will trigger beacon loss detection, and mac80211 will rescan,
which leads to a hw reset that will bring the hardware back to life.

To make this more reliable, we need to skip fast channel changes
if the hardware appears to be stuck.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3e6109c5 05-Jan-2011 John W. Linville <linville@tuxdriver.com>

ath9k: qualify global modparam_nohwcrypt variable

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1186488b 30-Dec-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: fix beacon restart on channel change

Restart the beacon timers only if the beacon
was already configured. Otherwise beacons timers
are restarted unnecessarily in unassociated state too.

Cc: stable@kernel.org
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 52671e43 23-Dec-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: spin_lock_bh is not required within tasklet context.

Disabling BH is not required while running from a tasklet context
and so replace spin_lock_bh with just spin_lock.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6dab55bf 20-Dec-2010 Dan Carpenter <error27@gmail.com>

ath9k: unlock on error path in ath9k_change_interface()

There is a missing unlock when we hit the "No beacon slot available"
error condition.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# afe68d0a 20-Dec-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix aphy / wiphy idle mismatch

ath9k supports its own set of virtual wiphys, and it uses
the mac80211 idle notifications to know when a device needs
to be idle or not. We recently changed ath9k to force idle
on driver stop() and on resume but forgot to take into account
ath9k's own virtual wiphy idle states. These are used internally
by ath9k to check if the device's radio should be powered down
on each idle call. Without this change its possible that the
device could have been forced off but the virtual wiphy idle
was left on.

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d4d5dc3d 18-Dec-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: do not limit the chainmask to 1 for legacy mode

Restricting the chainmask to 1 for legacy mode disables useful features
such as MRC, and it reduces the available transmit power.
I can't think of a good reason to do this in legacy mode, so let's just
get rid of that code.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 45ef6a0b 15-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k_hw: Configure appropriate Tx power when PAPRD fails

Target Tx power available in eeprom is for PAPRD. If PAPRD
fails, paprd scale factor needs to be detected from this
target tx power.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2b7e6bce 15-Dec-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Add comments for making pm-qos as modparam

PM-QOS value can be user specified via module parameter.
This patch adds few comments regarding this in the driver
code.

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4dc3530d 14-Dec-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Make PM-QOS value as user configurable

This patch allows the pm-qos value to be user configurable by making it as
a module parameter.This will help our customers to configure the pm-qos
value according to the effect in throughput due to the DMA latency problem
which was observed in Intel Pinetrail platforms.
The tested value of '55' will be filled as the default
pm-qos-value incase the user does not specifies pm-qos value as a
module parameter.
example usage: sudo modprobe ath9k pmqos=65

Cc: Senthilkumar Balasubramanian <Senthilkumar.Balasubramanian@Atheros.com>
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1bf38661 13-Dec-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: fix PA predistortion training power selection

The EEPROM contains scale factors for the tx power, which define
the range of allowable difference between target power and training
power. If the difference is too big, PA predistortion cannot be used.
For 2.4 GHz there is only one scale factor, for 5 GHz there are
three, depending on the specific frequency range.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7607cbe2 13-Dec-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix PA predistortion thermal measurement handling

To be able to measure the thermal values correctly for PAPRD, we need
to send training frames before setting up the gain table for the measurement,
and then again afterwards for the actual training.

For further improvement, send training frames at MCS0 instead of 54 MBit/s
legacy. That way we can use the No-ACK flag for the transmission, which
speeds up PAPRD training in general, as the hardware won't have to
retransmit and wait for ACK timeout (was previously set to 4 * 6
transmission attempts).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9abbfb27 09-Dec-2010 Sujith Manoharan <Sujith.Manoharan@atheros.com>

ath9k: Use power save wrappers for TSF get/set

The HW has to be awake when accessing registers.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6b3b991d 08-Dec-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Add change_interface callback

Add support to change interface type
without bringing down the interface.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a08e7ade 07-Dec-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix assumptions for idle calls on suspend/resume

mac80211 will notify drivers when to go idle and ath9k
assumed that it would get further notifications for idle
states after a device stop() config call but as per agreed
semantics the idle state of the radio is left up to driver
after mac80211 issues the stop() callback. The driver is
resposnbile for ensuring the device remains idle after
that even between suspend / resume calls.

This fixes suspend/resume when you issue suspend and resume
twice on ath9k when ath9k_stop() was already called. We need
to put the radio to full sleep in order for resume to work
correctly.

What might seem fishy is we are turning the radio off
after resume. The reason why we do this is because we know
we should not have anything enabled after a mac80211 tells
us to stop(), if we resume and never get a start() we won't
get another stop() by mac80211 so to be safe always bring
the 802.11 device with the radio disabled after resume,
this ensures that if we suspend we already have the radio
disabled and only a start() will ever trigger it on.

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c2731b81 07-Dec-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: Fix power save count imbalance on ath_radio_enable()

Upon a failure we never call ath9k_ps_restore() on ath_radio_enable(),
this will throw off the sc->ps_usecount. When the sc->ps_usecount
is > 0 we never put the chip to full sleep. This drains battery,
and will also make the chip fail upon resume with:

ath: Starting driver with initial channel: 5745 MHz
ath: timeout (100000 us) on reg 0x7000: 0xdeadbeef & 0x00000003 != 0x00000000

This would make the chip useless upon resume.

I cannot prove this can happen but in theory it is so best to
avoid this race completely and not have users complain about
a broken device after resume.

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ff9f0b63 07-Dec-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: skip ATH9K_INT_TIM_TIMER when we are idle

We should not be idle when we get the ATH9K_INT_TIM_TIMER,
otherwise its a sign of something broken in our design with
our idle state machine and mac80211. Skip these and WARN once
just in case this is triggerable.

Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8060e169 06-Dec-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Enable extended synch for AR9485 to fix L0s recovery issue

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 226afe68 02-Dec-2010 Joe Perches <joe@perches.com>

ath: Convert ath_print to ath_dbg

Remove ath/debug.h and the includes of these files.
Coalesce long formats.
Correct a few misspellings and missing "\n"s from these logging messages.
Remove unnecessary trailing space before a newline.
Remove ARRAY_SIZE casts, use printf type %zu

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3800276a 02-Dec-2010 Joe Perches <joe@perches.com>

ath: Convert ath_print(.., ATH_DBG_FATAL to ath_err

So these errors are always emitted at KERN_ERR level.
Remove ARRAY_SIZE casts, use printf type %zu

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 884a963f 07-Dec-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: fix beacon resource related race condition

The beacon tasklet is accesssing the bslot info for beacon generation.
Meanwhile the same slot can be freed on interface deletion.
Current the remove_interface disables the beacon alert after freeing the slot.
This may leads to null pointer access.

This patch disables SWBA and kills the beacon tasklet to prevent access
to the slot to be freed. After releasing the slot, swba will be enabled again
upon the availablity of beaconing interfaces.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 080e1a25 05-Dec-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix a DMA related race condition on reset

When ath_drain_all_txq fails to stop DMA, it issues a hw reset. This reset
happens at a very problematic point in time, when the hardware rx path has
not been stopped yet. This could lead to memory corruption, hardware hangs
or other issues.
To fix these issues, simply remove the reset entirely and check the tx DMA
stop status to prevent problems with fast channel changes.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ea066d5a 23-Nov-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Add support for Adaptive Power Management

This feature is to mitigate the problem of certain 3
stream chips that exceed the PCIe power requirements.An EEPROM flag
controls which chips have APM enabled which is basically read from
miscellaneous configuration element of the EEPROM header.

This workaround will reduce power consumption by using 2 Tx chains for
Single and Double stream rates (5 GHz only).All self generated frames
(regardless of rate) are sent on 2 chains when this feature is
enabled(Chip Limitation).

Cc: Paul Shaw <paul.shaw@atheros.com>
Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Tested-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 46047784 26-Nov-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Disable SWBA interrupt on remove_interface

while removing beaconing mode interface, SWBA interrupt
was never disabled when there are no other beaconing interfaces.

Cc: stable@kernel.org
Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 98c316e3 25-Nov-2010 Gabor Juhos <juhosg@openwrt.org>

ath9k: use per-device struct for pm_qos_* operations

The ath9k driver uses a shared pm_qos_request_list structure for all
devices. This causes the following warning if more than one device is
present in the system:

WARNING: at kernel/pm_qos_params.c:234 ath9k_init_device+0x5e8/0x6b0()
pm_qos_add_request() called for already added request
Modules linked in:
Call Trace:
[<802b1cdc>] dump_stack+0x8/0x34
[<8007dd90>] warn_slowpath_common+0x78/0xa4
[<8007de44>] warn_slowpath_fmt+0x2c/0x38
[<801b0828>] ath9k_init_device+0x5e8/0x6b0
[<801bc508>] ath_pci_probe+0x2dc/0x39c
[<80176254>] pci_device_probe+0x64/0xa4
[<8019471c>] driver_probe_device+0xbc/0x188
[<80194854>] __driver_attach+0x6c/0xa4
[<80193e20>] bus_for_each_dev+0x60/0xb0
[<80193580>] bus_add_driver+0xcc/0x268
[<80194c08>] driver_register+0xe0/0x198
[<801764e0>] __pci_register_driver+0x50/0xe0
[<80365f48>] ath9k_init+0x3c/0x6c
[<8006050c>] do_one_initcall+0xfc/0x1d8
[<80355340>] kernel_init+0xd4/0x174
[<800639a4>] kernel_thread_helper+0x10/0x18

---[ end trace 5345fc6f870564a6 ]---

This patch fixes that warning by using a separate pm_qos_request_list
sructure for each device.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 71a3bf3e 14-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: block new AMPDU sessions if SC_OP_TXAGGR is not set

This makes further tx path cleanups easier

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 28d16708 14-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: clean up code duplication around ath_tx_start

Merge initial processing for the CAB queue and regular tx.
Also move ath_tx_cabq() to beacon.c and make it static.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 82259b77 14-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: remove bfs_paprd_timestamp from struct ath_buf_state

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 066dae93 07-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: rework tx queue selection and fix queue stopping/waking

The current ath9k tx queue handling code showed a few issues that could
lead to locking issues, tx stalls due to stopped queues, and maybe even
DMA issues.

The main source of these issues is that in some places the queue is
selected via skb queue mapping in places where this mapping may no
longer be valid. One such place is when data frames are transmitted via
the CAB queue (for powersave buffered frames). This is made even worse
by a lookup WMM AC values from the assigned tx queue (which is
undefined for the CAB queue).

This messed up the pending frame counting, which in turn caused issues
with queues getting stopped, but not woken again.

To fix these issues, this patch removes an unnecessary abstraction
separating a driver internal queue number from the skb queue number
(not to be confused with the hardware queue number).

It seems that this abstraction may have been necessary because of tx
queue preinitialization from the initvals. This patch avoids breakage
here by pushing the software <-> hardware queue mapping to the function
that assigns the tx queues and redefining the WMM AC definitions to
match the numbers used by mac80211 (also affects ath9k_htc).

To ensure consistency wrt. pending frame count tracking, these counters
are moved to the ath_txq struct, updated with the txq lock held, but
only where the tx queue selected by the skb queue map actually matches
the tx queue used by the driver for the frame.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Björn Smedman <bjorn.smedman@venatech.se>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6a6733f2 26-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: content DMA start / stop through the PCU lock

This helps align resets / RX enable & disable / TX stop / start.
Locking around the PCU is important to ensure the hardware doesn't
get stale data when working with DMA'able data.

This is part of a series of patches which fix stopping
TX DMA completley when requested on the driver.
For more details about this issue refer to this thread:

http://marc.info/?l=linux-wireless&m=128629803703756&w=2

Tested-by: Ben Greear <greearb@candelatech.com>
Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4bdd1e97 26-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move the PCU lock to the sc structure

The PCU lock should be used to contend TX DMA as well,
this will be done next.

This is part of a series of patches which fix stopping
TX DMA completley when requested on the driver.
For more details about this issue refer to this thread:

http://marc.info/?l=linux-wireless&m=128629803703756&w=2

Tested-by: Ben Greear <greearb@candelatech.com>
Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9d94674a 26-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: simplify hw reset locking

The new PCU lock is better placed so we can just contend
against that when trying to reset hardware.

This is part of a series of patches which fix stopping
TX DMA completley when requested on the driver.
For more details about this issue refer to this thread:

http://marc.info/?l=linux-wireless&m=128629803703756&w=2

Tested-by: Ben Greear <greearb@candelatech.com>
Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# de40f316 19-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: extend ath9k_hw_set_txpowerlimit to test channel txpower

ath9k_hw_set_txpowerlimit gets an extra boolean parameter that - if set -
causes the rate txpower table and the regulatory limit to be calculated
and stored, without changing hardware registers.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9fa23e17 15-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: optimize/fix ANI RSSI processing

ANI needs the RSSI average only in station mode, and only for tracking
the signal strength of beacons of the AP that it is connected to.
Adjust the code to track on the beacon RSSI, and store the average of that
in the ath_wiphy struct.
With these changes, we can get rid of this extra station lookup in the
rx path, which saves precious CPU cycles.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4df3071e 08-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: optimize interrupt mask changes

OProfile showed that ath9k was spending way too much time in
ath9k_hw_set_interrupts. Since most of the interrupt mask changes only
need to globally enable/disable interrupts, it makes sense to split
this part into separate functions, replacing all calls to
ath9k_hw_set_interrupts(ah, 0) with ath9k_hw_disable_interrupts(ah).

ath9k_hw_set_interrupts(ah, ah->imask) only gets changed to
ath9k_hw_enable_interrupts(ah), whenever ah->imask was not changed
since the point where interrupts were disabled.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fbb078fc 02-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: check old power mode before clearing cycle counters

ath9k_ps_wakeup() clears the cycle counters after waking up the
hardware using ath9k_hw_setpower, however if power save is disabled,
then the counters will contain useful data, which then gets discarded.
Fix this by checking the old power mode before discarding any data.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 10598c12 30-Oct-2010 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Fix a DMA latency issue for Intel Pinetrail platforms.

Throughput was severely affected in Intel Pinetrail platforms
because of a DMA problem in C3 state. This patch fixes this
issue.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
CC: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5f841b41 27-Oct-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Avoid HW opmode overridden on monitor mode changes

The HW opmode is blindly set to monitor type on monitor mode
change notification. This overrides the opmode when one of the
interfaces is still running as non-monitor iftype. So the monitoring
information needs to be maintained seperately.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5e848f78 20-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: lock reset and PCU start/stopping

Apart from locking the start and stop PCU we need
to ensure we also content starting and stopping the PCU
between hardware resets.

This is part of a series that will help resolve the bug:

https://bugzilla.kernel.org/show_bug.cgi?id=14624

For more details about this issue refer to:

http://marc.info/?l=linux-wireless&m=128629803703756&w=2

Cc: stable@kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Tested-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b79b33c4 20-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: rename rxflushlock to pcu_lock

The real way to lock RX is to contend on the PCU
and reset, this will be fixed in the next patch but for
now just do the renames so that the next patch which changes
the locking order is crystal clear.

This is part of a series that will help resolve the bug:

https://bugzilla.kernel.org/show_bug.cgi?id=14624

For more details about this issue refer to:

http://marc.info/?l=linux-wireless&m=128629803703756&w=2

Cc: stable@kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Tested-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fac6b6a0 23-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: resume aggregation immediately after a hardware reset

Since aggregation is usually triggered by tx completion, a hardware
reset (because of beacon stuck, tx hang or baseband hang) can
significantly delay the transmission of the next AMPDU (until the next
tx completion event).
Fix this by rescheduling aggregation after such a reset.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0845735e 20-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix crash in ath_update_survey_stats

If ah->curchan is uninitialized, the channel index is bogus, which leads
to invalid memory access when the cycle counters are updated.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4e990018 13-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: remove sc->cur_rate_table and sc->cur_rate_mode

Set the rate table in the rc module properly based on band and
HT capabilities instead, which was already partially done, but
not for every mode.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 88eac2da 12-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: add missing locking around ath9k_hw_proc_mib_event

ath9k_hw_proc_mib_event updates the cycle counters, so it common->cc_lock
must be acquired.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 898c914a 12-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: do not track cycle counter updates in powersave mode

While the chip is in powersave mode, the cycle counter updates do not
contain useful values. While the chip is in full sleep, the rx_clear
signal stays high, indicating a busy medium.
To ensure sane values, update cycle counters before going into
powersave, and clear them right after switching back to awake.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9c1d8e4a 13-Oct-2010 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Set RX filter for Probe Request based on filter flag

This allows mac80211 to enable receiving of Probe Request frames in
station mode which is needed for P2P.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3430098a 10-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: implement channel utilization stats for survey

Results for the active channel are updated whenever a new survey dump
is requested, the old data is kept to allow multiple processes to
make their own channel utilization averages.
All other channels only contain the data for the last time that the
hardware was on the channel, i.e. the last scan result or other
off-channel activity.
Running a background scan does not clear the data for the active
channel.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b5bfc568 08-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: move the cycle counter tracking to ath

Instead of keeping track of wraparound, clear the counters on every
access and keep separate deltas for ANI and later survey use.
Also moves the function for calculating the 'listen time' for ANI

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 845d708e 05-Oct-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Introduce a wrapper for power save disable.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fbab7390 05-Oct-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: remove unnecessary power save flags.

drv_config callback is called only after the ack for the nullframe
is received and so driver need not do anything special for this.

So remove NULLFUNC_COMPLETED, PS_ENABLED flags and bf_isnullfunc
flags from ath9k as mac80211 already handles them properly.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bfc472bb 04-Oct-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: remove code duplication in phy error counter handling

Split out the PHY error counter update from ath9k_hw_ani_monitor_*, reuse
it in ath9k_hw_proc_mib_event (merged from ath9k_hw_proc_mib_event_old
and ath9k_hw_proc_mib_event_new).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e51f3eff 01-Oct-2010 Bill Jordan <bjordan@rajant.com>

ath9k: add WDS interfaces to ath9k

Enable WDS for the ath9k driver.

Signed-off-by: Bill Jordan <bjordan@rajant.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 39162dbe 29-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: return survey data for all channels instead of just the current one

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0bda6523 29-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: remove the noise floor value in the ani struct

common->ani.noise_floor is now only used for a similar redundant debug
message similar to the one that was removed from ath9k_htc in an earlier
patch. Remove it from ath9k as well now.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4f1a5a4b 29-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: do not return default noise floor values via survey

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9094537c 20-Sep-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix tx struck state with paprd

Paprd needs to be done only on active chains(not for all the chains
that hw can support). The paprd training frames which are sent
for inactive chains would be hanging on the hw queue without
getting transmitted and would make the connection so unstable.
This issue happens only with the hw which supports paprd cal(ar9003).

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 231c3a1f 20-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix an aggregation start related race condition

A new aggregation session start can be issued by mac80211, even when the
cleanup of the previous session has not completed yet. Since the data structure
for the session is not recreated, this could corrupt the block ack window
and lock up the aggregation session. Fix this by delaying the new session
until the old one has been cleaned up.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 48a6a468 16-Sep-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix enabling ANI / tx monitor after bg scan

ath9k's entire logic with SC_OP_SCANNING is incorrect due to the
way mac80211 currently implements the scan complete callback and
we handle it in ath9k. This patch removes the flag completely in
preference for the SC_OP_OFFCHANNEL which is really what we wanted.

The scanning flag was used to ensure we reset ANI to the old values
when we go back to the home channel, but if we are offchannel we
use some defaults. The flag was also used to re-enable the TX monitor.

Without this patch we simply never re-enabled ANI and the TX monitor
after going offchannel. This means that after one background
scan we are prone to noise issues and if we had a TX hang we would
not recover. To get this to work properly we must enable ANI after
we have configured the beacon timers, otherwise hardware acts really
oddly.

This patch has stable fixes which apply down to [2.6.36+], there
*may* be a to fix this on older kernels but requires a bit of
work since this patch relies on the new mac80211 flag
IEEE80211_CONF_OFFCHANNEL which was introduced as of 2.6.36.

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 52b8ac92 16-Sep-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix regression on beacon loss after bgscan

When we return to the home channel we were never reseting our beacon
timers, this was casued by the fact that the scanning flag was still
on even after we returned to our home channel. There are also other
reasons why we would get a reset and if we are not off channel
we always need to resynch our beacon timers, because a reset will
clear them.

This bug is a regression introduced on 2.6.36. The order of the
changes are as follows:

5ee08656 - Sat Jul 31 - ath9k: prevent calibration during off-channel activity
a0daa0e7 - Tue Jul 27 - Revert "mac80211: fix sw scan bracketing"
543708be - Fri Jun 18 - mac80211: fix sw scan bracketing

mcgrof@tux ~/linux-2.6-allstable (git::master)$ git describe \
--contains 5ee0865615f65f84e6ee9174771a6716c29e08e1
v2.6.36-rc1~43^2~34^2~22

mcgrof@tux ~/linux-2.6-allstable (git::master)$ git describe \
--contains a0daa0e7592ada797d6835f11529097aabc27ad2
v2.6.36-rc1~571^2~64^2~13

mcgrof@tux ~/linux-2.6-allstable (git::master)$ git describe \
--contains 543708be320d7df692d24b349ca01a947b340764
v2.6.36-rc1~571^2~107^2~187

So 5ee08656 would have worked if a0daa0e7 was not committed but
it was so this means 5ee08656 was broken since it assumed that
when we were in the channel change routine the scan flag would
be lifted. As it turns out the scan flag will be set when we
are already on the home channel.

For more details refer to:

http://code.google.com/p/chromium-os/issues/detail?id=5715

These issues will need to be considered for our solution on
reshifting the scan complete callback location on mac80211 on
current development kernel work.

This patch has stable fixes which apply down to [2.6.36+]

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8ab2cd09 16-Sep-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix power save race conditions

ath9k has a race on putting the chip into network sleep and
having registers read from hardware. The race occurs because
although ath9k_ps_restore() locks its own callers it makes use
of some variables which get altered in the driver at different
code paths. The variables are the ps_enabled and ps_flags.

This is easily reprodicible in large network environments when
roaming with the wpa_supplicant simple bgscan. You'd get some
0xdeadbeef read out on certain registers such as:

ath: timeout (100000 us) on reg 0x806c: 0xdeadbeef & 0x01f00000 != 0x00000000
ath: RX failed to go idle in 10 ms RXSM=0xdeadbeef

ath: timeout (100000 us) on reg 0x7000: 0xdeadbeef & 0x00000003 != 0x00000000
ath: Chip reset failed

The fix is to protect the ath9k_config(hw, IEEE80211_CONF_CHANGE_PS)
calls with a spin_lock_irqsave() which will disable contendors for
these variables from interrupt context, timers, re-entry from mac80211
on the same callback, and most importantly from ath9k_ps_restore()
which is the only call which will put the device into network sleep.

There are quite a few threads and bug reports on these a few of them are:

https://bugs.launchpad.net/ubuntu/karmic/+source/linux/+bug/407040
http://code.google.com/p/chromium-os/issues/detail?id=5709
http://code.google.com/p/chromium-os/issues/detail?id=5943

Stable fixes apply to [2.6.32+]

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 040e539e 08-Sep-2010 Bruno Randolf <br1@einfach.org>

ath9k: Use common ath key management functions

Use key management functions which have been moved to ath/key.c and remove
ath9k copies of these functions and other now unused definitions.

Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 364734fa 14-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: remove useless hw capability flags

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 31a01645 14-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix BSSID mask calculation

At the time the .add_interface driver op is called, the interface has not
been marked as running yet, so ieee80211_iterate_active_interfaces will
not pass it to the iterator function.
Because of this, the calculated BSSID mask is wrong, which breaks multi-BSS
operation.

Additionally, the current way of comparing all addresses against each other
is pointless, as the hardware only uses the hardware MAC address and the BSSID
mask for matching the destination address, so all the address array
reallocation is completely unnecessary.

This patch simplifies the logic by setting the initial mask bytes to 0xff
and removing all bits in the iterator call that don't match the hardware MAC
address. It also calls the iterator for the vif that was passed to
add_interface()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Tested-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 97359d12 10-Aug-2010 Johannes Berg <johannes.berg@intel.com>

mac80211: use cipher suite selectors

Currently, mac80211 translates the cfg80211
cipher suite selectors into ALG_* values.
That isn't all too useful, and some drivers
benefit from the distinction between WEP40
and WEP104 as well. Therefore, convert it
all to use the cipher suite selectors.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6044474e 02-Aug-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: shorten the calibration interval during strong interference

When the noise floor limits are being bypassed because of strong
interference, sensitivity is also reduced.
In order to recover from this as quickly as possible, trigger a
long periodic calibration every second instead of every 30 seconds,
until the NF median is within limits again. This is especially important
if the interference lasts for a while, since it takes multiple clean
NF calibrations to bring the median back to normal.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1e51b2ff 29-Jul-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add fastcc to debug print for channel change

This helps us debug channel changes better.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 20bd2a09 30-Jul-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: clean up per-channel calibration data

The noise floor history buffer is currently not kept per channel, which
can lead to problems when changing channels from a clean channel to a
noisy one. Also when switching from HT20 to HT40, the noise floor
history buffer is full of measurements, but none of them contain data
for the extension channel, which it needs quite a bit of time to recover
from.

This patch puts all the per-channel calibration data into a single data
structure, and gives the the driver control over whether that is used
per-channel or even not used for some channels.

For ath9k_htc, I decided to keep this per-channel in order to avoid
creating regressions.

For ath9k, the data is kept only for the operating channel, which saves
some space. ath9k_hw takes care of wiping old data when the operating
channel or its channel flags change.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5ee08656 30-Jul-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: prevent calibration during off-channel activity

Previously the software scan callback was used to indicate to the hardware,
when it was safe to calibrate. This didn't really work properly, because it
depends on a specific order of software scan callbacks vs. channel changes.
Also, software scans are not the only thing that triggers off-channel
activity, so it's better to use the newly added indication from mac80211 for
this and not use the software scan callback for anything calibration related.

This fixes at least some of the invalid noise floor readings that I've seen
in AP mode on AR9160

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ddfef792 30-Jul-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix a crash in the PA predistortion apply function

When updating the PAPRD table in hardware, PAPRD itself needs to be
disabled first, otherwise the hardware can throw a data bus error,
which upsets at least some platforms.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 30888338 27-Jul-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove the two wiphys scanning at the same time message

When issuing two consecutive scans you could often end up
getting in the logs:

"ath9k: Two wiphys trying to scan at the same time"

This message is due to a race in mac80211 but addressing
that race requires some more major changes on the driver
and perhaps optimizations on mac80211 like removing the
scan complete callback alltogether. Its too late to address
this this kernel release so supress the complaint and annotate
this needs fixing for later.

Cc: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a3d3da14 20-Jul-2010 John W. Linville <linville@tuxdriver.com>

ath9k: correct sparse identified endian bug in ath_paprd_calibrate

drivers/net/wireless/ath/ath9k/main.c:282:26: warning: incorrect type in assignment (different base types)
drivers/net/wireless/ath/ath9k/main.c:282:26: expected restricted __le16 [usertype] duration_id
drivers/net/wireless/ath/ath9k/main.c:282:26: got int

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 447a42c2 07-Jul-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: fix panic while cleaning up virtaul wifis

num_sec_wiphy means max secondary wifis that the driver can accomudate.
So cancelling wiphy work should be based on the presence of
secondary wifis.

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 982723df 22-Jun-2010 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Fix the LED behaviour in idle unassociated state.

LED should be ON when the radio is put into FULL SLEEP mode during the idle
unassociated state.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 347809fc 01-Jul-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix false positives in the baseband hang check

ath9k_hw_check_alive() occasionally returns false, as the hardware
is still processing data in a specific state. Fix this issue by
repeating the test a few times with longer delay inbetween attempts.
This gets rid of excessive hardware resets that appear frequently on
some AR9132 based devices, but could also happen on AR9280.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Björn Smedman <bjorn.smedman@venatech.se>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 47399f1a 24-Jun-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Wakeup the chip in an appropriate place in ath_paprd_calibrate()

Move ath9k_ps_wakeup() down just before accessing hw registers.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ca369eb4 24-Jun-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix bug in paprd

It is possbile that the transmission of paprd test frame
might not get completed in 100ms if tx is stuck. Freeing
this skb upon timeout in ath_paprd_calibrate() will result
in accessing already freed memory when the associated pending
buffer is drained in txq. This patch fixes this issue.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6c3118e2 23-Jun-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix bug in starting ani

There are few places where ANI is started without checking
if it is right to start. This might lead to a case where ani
timer would be left undeleted and cause improper memory acccess
during module unload. This bug is clearly exposed with
paprd support where the driver detects tx hang and does a
chip reset. During this reset ani is (re)started without checking
if it needs to be started. This would leave a timer scheduled
even after all the resources are freed and cause a panic.

This patch introduces a bit in sc_flags to indicate if ani
needs to be started in sw_scan_start() and ath_reset().
This would fix the following panic. This issue is easily seen
with ar9003 + paprd.

BUG: unable to handle kernel paging request at 0000000000003f38
[<ffffffff81075391>] ? __queue_work+0x41/0x50
[<ffffffff8106afaa>] run_timer_softirq+0x17a/0x370
[<ffffffff81088be8>] ? tick_dev_program_event+0x48/0x110
[<ffffffff81061f69>] __do_softirq+0xb9/0x1f0
[<ffffffff810ba060>] ? handle_IRQ_event+0x50/0x160
[<ffffffff8100af5c>] call_softirq+0x1c/0x30
[<ffffffff8100c9f5>] do_softirq+0x65/0xa0
[<ffffffff81061e25>] irq_exit+0x85/0x90
[<ffffffff8155e095>] do_IRQ+0x75/0xf0
[<ffffffff815570d3>] ret_from_intr+0x0/0x11
<EOI>
[<ffffffff812fd67b>] ? acpi_idle_enter_simple+0xe4/0x119
[<ffffffff812fd674>] ? acpi_idle_enter_simple+0xdd/0x119
[<ffffffff81441c87>] cpuidle_idle_call+0xa7/0x140
[<ffffffff81008da3>] cpu_idle+0xb3/0x110
[<ffffffff81550722>] start_secondary+0x1ee/0x1f5

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9a75c2ff 22-Jun-2010 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Add a module parameter to disable led blinking.

Some vendors require the LED to be ON always irrespective of any
radio activity. Introducing a module parameter to disable blinking,
so that one can choose between always on or led blink during
activity.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9cc3271f 12-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: remove ATH9K_CAP_TXPOW

replace calls that read this capability with accesses to ath9k_hw's
regulatory data.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9f42c2b6 11-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: implement PA predistortion support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ebe297c3 11-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: make ath_get_hal_qnum static

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1d2231e2 11-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: remove duplicate WMM AC definitions

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e36b27af 11-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add new ANI implementation for AR9003

This adds support for ANI for AR9003. The implementation for
ANI for AR9003 is slightly different than the one used for
the older chipset families. It can technically be used for
the older families as well but this is not yet fully tested
so we only enable the new ANI for the AR5008, AR9001 and AR9002
families with a module parameter, force_new_ani.

The old ANI implementation is left intact.

Details of the new ANI implemention:

* ANI adjustment logic is now table driven so that each ANI level
setting is parameterized. This makes adjustments much more
deterministic than the old procedure based logic and allows
adjustments to be made incrementally to several parameters per
level.

* ANI register settings are now relative to INI values; so ANI
param zero level == INI value. Appropriate floor and ceiling
values are obeyed when adjustments are combined with INI values.

* ANI processing is done once per second rather that every 100ms.
The poll interval is now a set upon hardware initialization and
can be picked up by the core driver.

* OFDM error and CCK error processing are made in a round robin
fashion rather than allowing all OFDM adjustments to be made
before CCK adjustments.

* ANI adjusts MRC CCK off in the presence of high CCK errors

* When adjusting spur immunity (SI) and OFDM weak signal detection,
ANI now sets register values for the extension channel too

* When adjusting FIR step (ST), ANI now sets register for FIR step
low too

* FIR step adjustments now allow for an extra level of immunity for
extremely noisy environments

* The old Noise immunity setting (NI), which changes coarse low, size
desired, etc have been removed. Changing these settings could affect
up RIFS RX as well.

* CCK weak signal adjustment is no longer used

* ANI no longer enables phy error interrupts; in all cases phy hw
counting registers are used instead

* The phy error count (overflow) interrupts are also no longer used
for ANI adjustments. All ANI adjustments are made via the polling
routine and no adjustments are possible in the ISR context anymore

* A history settings buffer is now correctly used for each channel;
channel settings are initialized with the defaults but later
changes are restored when returning back to that channel

* When scanning, ANI is disabled settings are returned to (INI) defaults.

* OFDM phy error thresholds are now 400 & 1000 (errors/second units) for
low/high water marks, providing increased stability/hysteresis when
changing levels.

* Similarly CCK phy error thresholds are now 300 & 600 (errors/second)

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 85ad181e 10-Jun-2010 Johannes Berg <johannes.berg@intel.com>

mac80211: allow drivers to sleep in ampdu_action

Allow drivers to sleep, and indicate this in
the documentation. ath9k has some locking I
don't understand, so keep it safe and disable
BHs in it, all other drivers look fine with
the context change.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 84642d6b 01-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix queue stop/start based on the number of pending frames

Because there is a limited number of tx buffers available, once the
queue has been filled to a certain point, ath9k needs to stop accepting
new frames from mac80211. In order to prevent a full WMM queue from
stopping another queue with fewer frames, this patch limits the number
of queued frames to a quarter of the total available tx buffers, minus
some reserved frames to be used for other purposes (e.g. beacons).

Because tx buffers are reserved for frames when they're staged in
software queues as well, the actual queue depth cannot be used for
this, so this patch stores a reference to the tx queue in the ath_buf
struct and keeps track of the total number of pending frames.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1f03baad 25-May-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: use the key handling code from ath9k_common instead of duplicating it

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# fdf76622 17-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix power save with auto sleeping

Rx should not be disabed/disabled when hw supports auto sleeping.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08578b8f 13-May-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: enable the baseband watchdog events for AR9003

This enables the baseband watchdog events for the AR9003
family on ath9k. Upon an a baseband watchdog interrupt we reset
the hardware, this should address corner case conditions where
normal operation can stall. Enable ATH_DBG_RESET to be able
to review details of the bb watchdog interrupt once it happens.
If you're curious how often this happens just grep the debugfs
interrupt file.

Cc: Sam Ng <sam.ng@atheros.com>
Cc: Paul Shaw <paul.shaw@atheros.com>
Cc: Don Breslin <don.breslin@atheros.com>
Cc: Cliff Holden <cliff.holden@atheros.com
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3dc3fc52 24-May-2010 John W. Linville <linville@tuxdriver.com>

Revert "ath9k: Group Key fix for VAPs"

This reverts commit 03ceedea972a82d343fa5c2528b3952fa9e615d5.

This patch was reported to cause a regression in which connectivity is
lost and cannot be reestablished after a suspend/resume cycle.

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a69eee49 24-May-2010 Linus Torvalds <torvalds@linux-foundation.org>

Revert "ath9k: Group Key fix for VAPs"

This reverts commit 03ceedea972a82d343fa5c2528b3952fa9e615d5, since it
breaks resume from suspend-to-ram on Rafael's Acer Ferrari One.
NetworkManager thinks everything is ok, but it can't connect to the AP
to get an IP address after the resume.

In fact, it even breaks resume for non-ath9k chipsets: reverting it also
fixes Rafael's Toshiba Protege R500 with the iwlagn driver. As Johannes
says:

"Indeed, this patch needs to be reverted. That mac80211 change is wrong
and completely unnecessary."

Reported-and-requested-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Daniel Yingqiang Ma <yma.cool@gmail.com>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 62dad5b0 27-Apr-2010 Benoit Papillault <benoit.papillault@free.fr>

ath9k: Added get_survey callback in order to get channel noise

Signed-off-by: Benoit Papillault <benoit.papillault@free.fr>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c9c99e5e 19-Apr-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: check for specific rx stuck conditions and recover from them

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 03ceedea 13-Apr-2010 Daniel Yingqiang Ma <yma.cool@gmail.com>

ath9k: Group Key fix for VAPs

When I set up multiple VAPs with ath9k, I encountered an issue that
the traffic may be lost after a while.

The detailed phenomenon is
1. After a while the clients connected to one of these VAPs will get
into a state that no broadcast/multicast packets can be transfered
successfully while the unicast packets can be transfered normally.
2. Minutes latter the unitcast packets transfer will fail as well,
because the ARP entry is expired and it can't be freshed due to the
broadcast trouble.

It's caused by the group key overwritten and someone discussed this
issue in ath9k-devel maillist before, but haven't work out a fix yet.

I referred the method in madwifi, and made a patch for ath9k.
The method is to set the high bit of the sender(AP)'s address, and
associated that mac and the group key. It requires the hardware
supports multicast frame key search. It seems true for AR9160.

Not sure whether it's the correct way to fix this issue. But it seems
to work in my test. The patch is attached, feel free to revise it.

Signed-off-by: Daniel Yingqiang ma <yma.cool@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e5003249 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Add Tx EDMA support

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b5c80475 15-Apr-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: Add Rx EDMA support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3448f912 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: disable the MIB interrupt if ANI is disabled

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3069168c 31-Mar-2010 Pavel Roskin <proski@gnu.org>

ath9k: move imask from sc to ah

Add ah variable in the functions that didn't have it and used sc->imask.
Replace sc->sc_ah with ah in those functions.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 11446011 06-Apr-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix double calls to ath_radio_enable

With the enable_radio being uninitialized, ath_radio_enable() might be
called twice, which can leave some hardware in an undefined state.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4ca77860 19-Feb-2010 Johannes Berg <johannes@sipsolutions.net>

ath9k: convert to new station add/remove callbacks

This converts ath9k to use the new station
add/remove callbacks instead of using the
old sta_notify callback.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 733da37d 06-Feb-2010 Ming Lei <tom.leiming@gmail.com>

ath9k: fix keycache leak in split tkip case

If split tkip key is used, ath_delete_key should delete
rx key and rx mic key. This patch fixes the leak of hw
keycache in the case.

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3f7c5c10 03-Feb-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Enable TIM timer interrupt only when needed.

The TIM timer interrupt is enabled even before the ACK of nullqos
is received which is unnecessary.

Also clean up the CONF_PS part of config callback properly for
better readability.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f643e51d 29-Jan-2010 Pavel Roskin <proski@gnu.org>

ath: make gcc check format arguments of ath_print(), fix all misuses

Numeric channel is hard to get, so it won't be printed. Replace Mhz
with MHz on the affected lines and add commas as needed.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1dbfd9d4 29-Jan-2010 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Handle full sleep in ps_restore.

IDLE PS (Full Sleep) doesn't work when ifconfig up
is done during Idle unassociated state.
Fix this by restoring FULL SLEEP in ps_restore if CONF_IDLE
is set.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 74401773 19-Jan-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix beacon slot/buffer leak

When cleaning up beacon buffers and slots, ath9k currently checks if
sc->ah->opmode is set to a beacon related mode before cleaning up
buffers.
An unfortunate ordering of interface up/down commands can lead to
sc->ah->opmode being set to monitor mode, while there are AP interfaces
present on the same wiphy.
Always cleaning up beacon buffers if present fixes this issue.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c9f6a656 19-Jan-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: make tx power config changes take effect immediatley

Users wishing to tweak tx power want it to happen immediately,
try to respect that. This was tested by Lorenzo by measuring the
received signal strength from an AP with ath9k and the patch.

Changing the tx power on the AP produced these results:

1) iwconfig wlan0 txpower 20 ---> Rx power -37dbm
2) iwconfig wlan0 txpower 15 ---> Rx power -41dbm
3) iwconfig wlan0 txpower 10 ---> Rx power -45dbm
4) iwconfig wlan0 txpower 5 ---> Rx power -51dbm
5) iwconfig wlan0 txpower 0 ---> Rx power -37dbm

The result with 0 is an anomoly and would need to be
addressed through a separate patch.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Tested-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e239d859 14-Jan-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: implement coverage class support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0005baf4 14-Jan-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: cleanup slot time and ack/cts timeout handling

Previously ath9k left the initialization of slot timing and ACK/CTS
timeout to the mode specific initvals. This does not handle short vs
long slot in 2.4 GHz and uses a rather strange value for the 2.4 GHz
ACK timeout (64 usec).
This patch uses the proper ath9k_hw functions for setting slot time and
timeouts and also implements the switch between short and long slot
time in 2.4 GHz

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 199afd9d 07-Jan-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix monitor mode handling

mac80211 passes appropriate flags indicating whether
monitor mode is being used. Use this to set the HW opmode.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cc9c378a 07-Jan-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix queue handling

The TX queues have to be stopped during an
internal reset. Not handling this would result
in packet loss - fix this.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1b04b930 07-Jan-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Cleanup Powersave flags

sc_flags has slowly become a kitchen sink over time.
Move powersave related flags to a separate variable.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 55624204 07-Jan-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Add new file init.c

Move initialization/de-initialization related
code to this file.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0fca65c1 07-Jan-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Add a new file for GPIO

Move all LED/RFKILL/BTCOEX related code
to gpio.c

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 14acdde6 18-Dec-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: re-enable ps by default for new single chip families

The newer single chip hardware family of chipsets have not been
experiencing issues with power saving set by default with recent
fixes merged (even into stable). The remaining issues are only
reported with AR5416 and since enabling PS by default can increase
power savings considerably best to take advantage of that feature
as this has been tested properly.

For more details on this issue see the bug report:

http://bugzilla.kernel.org/show_bug.cgi?id=14267

We leave AR5416 with PS disabled by default, that seems to require
some more work.

Cc: stable@kernel.org
Cc: Peter Stuge <peter@stuge.se>
Cc: Justin P. Mattock <justinmattock@gmail.com>
Cc: Kristoffer Ericson <kristoffer.ericson@gmail.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1ed32e4f 23-Dec-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: remove struct ieee80211_if_init_conf

All its members (vif, mac_addr, type) are now available
in the vif struct directly, so we can pass that instead
of the conf struct. I generated this patch (except the
mac80211 and header file changes) with this semantic
patch:

@@
identifier conf, fn, hw;
type tp;
@@
tp fn(struct ieee80211_hw *hw,
-struct ieee80211_if_init_conf *conf)
+struct ieee80211_vif *vif)
{
<...
(
-conf->type
+vif->type
|
-conf->mac_addr
+vif->addr
|
-conf->vif
+vif
)
...>
}

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8b685ba9 23-Dec-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: wake hardware during AMPDU TX actions

AMDPDU actions poke hardware for TX operation, as such
we want to turn hardware on for these actions. AMDPU RX operations
do not require hardware on as nothing is done in hardware for
those actions. Without this we cannot guarantee hardware has
been programmed correctly for each AMPDU TX action.

Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5f70a88f 23-Dec-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: wake hardware for interface IBSS/AP/Mesh removal

When we remove a IBSS/AP/Mesh interface we stop DMA
but to do this we should ensure hardware is on. Awaken
the device prior to these calls. This should ensure
DMA is stopped upon suspend and plain device removal.

Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3867cf6a 23-Dec-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: fix suspend by waking device prior to stop

Ensure the device is awake prior to trying to tell hardware
to stop it. Impact of not doing this is we can likely leave
the device in an undefined state likely causing issues with
suspend and resume. This patch ensures harware is where it
should be prior to suspend.

Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b6ce5c33 14-Dec-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix TX poll routine

Disable the TX hang monitoring routine when doing a scan.
Monitoring for a hung situation is not really necessary during
a scan run.

Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 05c78d6d 14-Dec-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Remove ANI lock

Cancel/restart the ANI timer directly.
With this patch, the ANI lock can be removed.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2ab81d4a 14-Dec-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Stop ANI when doing a reset

The MIB counters are disabled when doing a chip reset.
Since ANI depends on the MIB registers for its operation, relying
on the contents of said registers during HW reset results in sub-optimal
performance.

Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a9a29ce6 26-Nov-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: enable 2GHz band only if the device supports it

Currently, the 2GHz band is enabled unconditionally, even if the device
does not support it.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 94db2936 24-Nov-2009 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Ensure a fair beacon distribution in IBSS mode.

Update the beacon queue parameters with best effort queue parameters for
IBSS mode. This reduces the number of beacons generated by ath9k and
ensures a fair beacon distribution when there are multiple IBSS stations.
Also CWmin is quadrupled to achieve the expected percentage of
distribution.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1bc14880 24-Nov-2009 Benoit Papillault <benoit.papillault@free.fr>

ath9k: Proper padding/unpadding for the TX/RX path.

Software padding is done on the TX path and software unpadding is done on the
RX path. This patch corrects the position where the padding occurs. A specific
function computes the pad position and this function is used in the TX and RX
path. This patch has been tested by generating every possible 802.11 frames
with every possible frame_control field and a varying length. This patch is
useful for analyzing non standard 802.11 frames going over the air

Signed-off-by: Benoit Papillault <benoit.papillault@free.fr>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e7824a50 24-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix processing of TX PS null data frames

When mac80211 was telling us to go into Powersave we listened
and immediately turned RX off. This meant hardware would not
see the ACKs from the AP we're associated with and hardware
we'd end up retransmiting the null data frame in a loop
helplessly.

Fix this by keeping track of the transmitted nullfunc frames
and only when we are sure the AP has sent back an ACK do we
go ahead and shut RX off.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Vivek Natarajan <Vivek.Natarajan@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 545750d3 23-Nov-2009 Felix Fietkau <nbd@openwrt.org>

ath9k: properly use the mac80211 rate control api

This patch changes ath9k to pass proper MCS indexes and flags
between the RC and the rest of the driver code.
sc->cur_rate_table remains, as it's used by the RC code internally,
but the rest of the driver code no longer uses it, so a potential
new RC for ath9k would not have to update it.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 18b6c9a2 23-Nov-2009 John W. Linville <linville@tuxdriver.com>

ath9k: set ps_default as false

Copied from original one-line patch here:

http://bugzilla.kernel.org/show_bug.cgi?id=14267#c26

(This is for 2.6.33 and beyond, where the bool was changed to a flag by
"cfg80211: convert bools into flags". -- JWL)

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 54ab040d 23-Nov-2009 John W. Linville <linville@tuxdriver.com>

ath9k: set ps_default as false

Copied from original one-line patch here:

http://bugzilla.kernel.org/show_bug.cgi?id=14267#c26

Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c951ad35 15-Nov-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: convert aggregation to operate on vifs/stas

The entire aggregation code currently operates on the
hw pointer and station addresses, but that needs to
change to make stations purely per-vif; As one step
preparing for that make the aggregation code callable
with the station, or by the combination of virtual
interface and station address.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c6089ccc 15-Nov-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Cleanup bss_info_changed callback

* Remove a code chunk dealing with operating mode changes.
As noted, all such policy changes are to be done in
add_interface.

* Remove pointless check for empty BSSID.
Also, remove mode checks - mac80211 does all the needed checks.

* Handle enabling/disabling beacon transmission properly.

* Handle beacon interval changes for AP mode.
The original code depended on config_interface() to update
the HW TSF. Since that callback has been removed, handle
it properly.

* Remove unneeded code dealing with key/privacy.

* Set the chainmasks to 1x1 for IBSS when the BSSID is set.
This was happening uncondionally before.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7e86c104 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move driver keymap, keymax and splitmic to common

This will make sharing code easier between ath9k and ath9k_htc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3d536acf 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move struct ath_ani to common area

This can be shared between ath9k and ath9k_htc. It will also
help with sharing routine helpers on the RX path.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 68a89116 02-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: pass the ieee80211_hw on radio enable/disable

We use the ieee80211_hw for radio enable/disable but the wrong
structure hw was being used in consideration for virtual wiphys
as each virtual wiphy has its own ieee80211_hw struct.

Just pass the hw struct to ensure we use the right one. This should
fix the hw used and passed for radio enable/disable. This includes
the stoping / starting of the software TX queues so mac80211 doesn't
send us data for a specific virtual wiphy. ath9k already takes care
of pausing virtual wiphys and stopping the respective queues on its
own, but this should handle the idle mac80211 conf calls as well.

Cc: Jouni.Malinen <Jouni.Malinen@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 194b7c13 29-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix listening to idle requests

The way idle configuration detection was implemented as
busted due to the fact that it assumed the ath9k virtual wiphy,
the aphy, would be marked as inactive if it was not used but
it turns out an aphy is always active if its the only wiphy
present. We need to distinguish between aphy activity and
idleness so we now add an idle bool for the aphy and mark
it as such based on the passed IEEE80211_CONF_CHANGE_IDLE
from mac80211.

Previous to all_wiphys_idle would never be true when using
only one device so we never really were using
IEEE80211_CONF_CHANGE_IDLE -- we never turned the radio
off or on upon IEEE80211_CONF_CHANGE_IDLE changes as radio
changes depended on all_wiphys_idle being true either to
turn the radio on or off. Since it was always false for
one device this code was doing nothing.

Cc: Jouni.Malinen <Jouni.Malinen@atheros.com>
Reported-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2da4f01a 26-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k_hw: move mac name and rf name helpers to hw code

These are shared between ath9k and the future ath9k_htc driver.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# af1fc67c 07-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: use right parameter for MODULE_PARM_DESC() for debug

Reported-by: sujith.manoharan@atheros.com
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 536b3a7a 06-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: rename ath_beaconq_setup() to ath9k_hw_beaconq_setup()

And move it to hw code on mac.c where it belongs.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bd96d390 06-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move ath_cleanup() below helpers to avoid forward declarations

This should fix the oops which occurs during module unload
due to the dereferencig of ah upon debugfs exit.

IP: [<46412d6b>] 0x46412d6b
*pde = 00000000
Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
last sysfs file: /sys/class/power_supply/BAT0/energy_full
Modules linked in: ath9k(-) ath9k_hw mac80211 ath cfg80211 <bleh>

Pid: 3112, comm: rmmod Not tainted (2.6.32-rc2-wl #101) 9461DUU
EIP: 0060:[<46412d6b>] EFLAGS: 00010246 CPU: 0
EIP is at 0x46412d6b
EAX: f5870004 EBX: f6700d94 ECX: 00000000 EDX: c14313a7
ESI: f5870000 EDI: fb58ce70 EBP: f6661eb4 ESP: f6661ea8
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmmod (pid: 3112, ti=f6660000 task=f6579380 task.ti=f6660000)
Stack:
fb57e5e5 f5ca5d50 fb58ce70 f6661ebc fb58629a f6661ec8 c11b715e f5ca5da8
<0> f6661ed8 c1223d98 f5ca5da8 f5ca5ddc f6661eec c1223e6f fb58ce70 fb58ce70
<0> c14958a0 f6661f00 c1222edb fb58ce70 fb58ce70 fb58cebc f6661f1c c12243c9
Call Trace:
[<fb57e5e5>] ? ath_cleanup+0x35/0x50 [ath9k]
[<fb58629a>] ? ath_pci_remove+0x1a/0x20 [ath9k]
[<c11b715e>] ? pci_device_remove+0x1e/0x40
[<c1223d98>] ? __device_release_driver+0x58/0xa0
[<c1223e6f>] ? driver_detach+0x8f/0xa0
[<c1222edb>] ? bus_remove_driver+0x7b/0xb0
[<c12243c9>] ? driver_unregister+0x49/0x80
[<c1158cf2>] ? sysfs_remove_file+0x12/0x20
[<c11b73b5>] ? pci_unregister_driver+0x35/0x90
[<fb586172>] ? ath_pci_exit+0x12/0x20 [ath9k]
[<fb5883ec>] ? ath9k_exit+0x10/0x3d [ath9k]
[<c131971d>] ? mutex_unlock+0xd/0x10
[<c1088c0f>] ? sys_delete_module+0x16f/0x220
[<c10e3d5d>] ? do_munmap+0x23d/0x290
[<c11a629c>] ? trace_hardirqs_off_thunk+0xc/0x10
[<c11a628c>] ? trace_hardirqs_on_thunk+0xc/0x10
[<c1003b41>] ? sysenter_exit+0xf/0x1a
[<c1003b08>] ? sysenter_do_call+0x12/0x3c
Code: Bad EIP value.
EIP: [<46412d6b>] 0x46412d6b SS:ESP 0068:f6661ea8
CR2: 0000000046412d6b
---[ end trace 847f3b05ff3dcb19 ]---

Reported-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2568835c 06-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add a helper to clean the core driver upon module unload

The core driver needs to be stopped and then as a last step the
hardware needs to be stopped and its structure free'd. We do this
by moving the core driver cleanup to a new helper ath_clean_core()
and have ath_cleanup() call it. Only as a last step does
ath_cleanup() now free the hw.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7fda1666 06-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add helper to un-init the hw properly

This is used in several places, ensure we do it right in all
callers by using a helper.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 211f5859 06-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: initialize hw prior to debugfs

debugfs uses the hardware for several debugfs files as such the
hardware must be initialized and available prior to its usage. The
same applies to when we free the hw structs -- free debufs file
entries prior to free'ing the hardware.

Reported-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# faa27fae 06-Oct-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move common->debug_mask setting to ath_init_softc()

What this means is we can enable now debug prints without
requiring CONFIG_ATH9K_DEBUG.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bc974f4a 28-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: define a common priv struct

hw code should never use private driver data, but
sometimes we need a backpointer so just stuff it on
the common ath struct.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2ddb5c8b 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: make ath9k_common_ops const

As noted by Jiri.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5bb12791 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: move bus ops to ath_common

This is the last part to make ath9k hw code core driver agnostic.
I believe ath9k_htc can now use use the hw code unmodified.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9680e8a3 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove driver ASSERT, just use BUG_ON()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 25c56eec 14-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove ath9k_ht_macmode

This is used just to determine how to program the MAC,
either for 20 MHz operation of 40 MHz so just use conf_is_ht40()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 43c27613 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: move tx/rx chainmask to ath_common

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c46917bb 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: add common debug printing

ath9k uses this for now, ath9k_htc is expected to re-use this
as well. We lave ath5k as is, but it certainly can also be
converted later.

The ath9k module parameter and debugfs entry is kept.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cd9bf689 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: separate core driver and hw timer code

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b002a4a9 13-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: add ieee80211_hw to ath_common

Make use of it on hw code in ath9k to avoid
using the ath9k ath_softc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 13b81559 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: define shared bssidmask setting

Also make ath5k and ath9k use it, and share register definitions.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9e4bffd2 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros/ath9k: add common read/write ops and port ath9k to use it

In an effort to make hw code driver core agnostic read
and write operations are defined on the ath_common structure.
This patch adds that and makes ath9k use it. This allows
drivers like ath9k_htc to define its own read/write ops and
still rely on the same hw code. This also paves the way for
sharing code between ath9k/ath5k/ath9k_htc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 867633f0 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: Define bus agnostic bluetooth coex prep helper

We disable ASPM when enabling bluetooth coexistance. Disabling
ASPM is a bus specific operation. In the future other buses may
support bluetooth coexistance, an example is USB. To this end
move the current routine which disables ASPM into pci.c, and declare
it the PCI bt_coex_prep() helper. Additionally, since ASPM is
a PCI-Express primitive ensure we don't ever try to muck with ASPM
registers on non PCI-express devices.

This also cleans up hw.c to not include bus specific headers or
utilities.

Cc: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Cc: Stephen Chen <stephen.chen@atheros.com>
Cc: Zhifeng Cai <zhifeng.cai@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 27c51f1a 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move ath_common to ath_hw

This ensures that we can access common on hw related code
independent of the driver core.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1510718d 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros/ath9k: move macaddr, curaid, curbssid and bssidmask to common

These are common amongst ath9k and ath5k, so put them into the
common structure and make ath9k to use it. ar9170 can use macaddr,
and curbssid. We'll change ath5k and ar9170 separately.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f2b2143e 10-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: make ath9k_hw_setbssidmask() and ath9k_hw_write_associd() use ath_hw

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9ecdef4b 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: rename driver core and hw power save helpers

ath9k_hw_setpower_nolock --> ath9k_hw_setpower()
ath9k_hw_setpower() --> ath9k_setpower()

Also change the param for ath9k_setpower() to pass the ath_softc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8c77a569 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move ath9k_hw_setpower() to main.c

And we make it static.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a91d75ae 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move ath9k_ps_wakeup() and ath9k_ps_restore() to main.c

These are driver core helpers.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 21526d57 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move ps helpers onto core driver when reseting tsf

When the TSF is reset power save state is disabled and
then restored. The helpers to disable power save and restore
it use a lock provided by the driver core. Move the callers
of the helpers outside of the hw code.

We reset the TSF when mac80211 tells us and on the beacon.c
helper ath9k_hw_beaconinit() when it is made explicitly required.
Add a helper on beacon.c which will deal with ps awake/restore
if we need to reset the TSF upon ath9k_hw_beaconinit().

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5e197292 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: now move ath9k_hw_btcoex_set_weight() to btcoex.c

After some necessary cleanups we now move ath9k_hw_btcoex_set_weight()
to where it belongs.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 269ad812 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: simplify ath_btcoex_bt_stomp()

The second argument is always the hardware bt coex struct, so
remove it, and rename the function on the path with a ath9k_ prefix.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 766ec4a9 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: rename ath_btcoex_info to ath_btcoex_hw

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 46289e1e 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: rename btcoex_scheme to just scheme

btcoex_scheme is already part of a btcoex struct, its implied
this is btcoex related.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e08a6ace 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move bt_stomp_type to driver core

The bt_stomp_type defines the bt coex weight, it has a one-to-one
mapping. In the future we may want to just use the weight directly.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8c1b3954 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: replaces SC_OP_BTCOEX_ENABLED with a bool

Whether or not bluetooth coex has been enabled is a hardware
state and only the hardware helpers will be able to set this.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 75d7839f 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move driver core helpers to main.c

Keep on btcoex.c only hardware access helpers, move the
driver core specific code to main.c. To accomplish
this we had to split ath_init_btcoex_info() into two parts,
the driver core part -- ath_init_btcoex_timer() and the hw
specific part -- ath9k_hw_init_btcoex_hw_info(). This
highlights how ath_gen_timer is part of the driver core, not
hw related, so stuff that into ath_btcoex struct.

The ath9k_hw_btcoex_init() code is now put inline on
ath_init_softc() through a switch to it easier to follow,
since we did that we can now call ath_tx_get_qnum() from
the main.c instead of btcoex.c

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# af03abec 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move hw specific btcoex info to ath_hw

Since we now access it via the ath_hw declare the ath_hw pointer
at the header of some routines and se it. ath9k.h no longer needs to
access btcoex.h and to adjust for this move ath_btcoex_set_weight()
into btcoex.h and instead give main.c a helper for setting initial
values upon drv_start()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2e20250a 09-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move btcoex core driver info to its own struct

There is some bluetooth coexistance data which is driver
specific, stuff that into its own structure.

Cc: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4d6b228d 07-Sep-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: use ath_hw for DPRINTF() and debug init/exit

DPRINTF() is used in hw specific related code, as such
ensure we don't rely on the private driver core ath_softc
struct when calling it. Drivers can then implement their
own DPRINTF() as they see fit.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e31f7b96 23-Sep-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix RFKILL bugs

This patch fixes 2 issues in RFKILL:

* Calling wiphy_rfkill_stop_polling() in ath9k_stop
would mean that the driver cannot report HW status
when the radio is re-enabled. Move this to ath_detach().

* Calling ath_radio_{enable/disable} without checking the current
state results in ath_radio_enable() being called repeatedly
for every invocation of rfkill_poll(). This is not needed
in any case since wiphy_rfkill_set_hw_state() would call
->stop() if the radio has been disabled.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 93b1b37f 16-Sep-2009 Vivek Natarajan <vnatarajan@atheros.com>

ath9k: Revamp PCIE workarounds

* Disable L1 state ONLY when device is in D3 mode.
* Clear bit 22 of register 0x4004.
* Handle power on/off properly

Not setting the workarounds properly resulted in the
disappearance of the card in certain cases.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aeac355d 09-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Store subsystem id in struct hw_version

This subsystem id will be used later to turn on the btcoex
support.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7b6840ab 07-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Disable ASPM when btcoex is active

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8813262e 02-Sep-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix channelFlags for 2GHZ

CHANNEL_G has to be set for 2GHZ channels since
IS_CHAN_G() checks for this in channelFlags and not in
chanmode. To make things messier, ath9k_hw_process_ini()
checks for CHANNEL_G in chanmode and not in channelFlags.
The supreme, brain-searing fix is to set the
flag in both cases.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7ea310be 02-Sep-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix RX Filter handling for BAR

BAR frames have to be sent to mac80211 only if the
current channel is HT. Also, move the macro to
enum ath9k_rx_filter.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d0bec342 02-Sep-2009 Vivek Natarajan <vivek.natraj@gmail.com>

ath9k: Reconfigure beacon timers after the scan is completed.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ebb8e1d7 01-Sep-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Move generic hw timer intr handler to bottom-half

There is no point handling this in hard irq, move it to
tasklet.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1773912b 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Add Bluetooth Coexistence 3-wire support

This patch adds 3-wire bluetooth coex support for AR9285.
This support can be enabled through btcoex_enable modparam.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 81fa16fb 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Remove hw capability bit meant for btcoex

We don't need a hw cap bit for btcoex anymore as btcoex scheme type
is enough to do this.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 22f25d0d 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Determine btcoex scheme type based on chip version

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f985ad12 26-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Split ath9k_hw_btcoex_enable() into two logical pieces

This function currently does initialization + enable the
btcoex support. Split it into two logical functions which
does the above operations separately. Btcoex initialization
is done during attach time and enabling this feature is done
in start(). Also, add code to disable btcoex support in stop().

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3d832611 20-Aug-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix chainmask selection during scanning

The TX/RX chainmasks were set to 1x1 during scanning.
Configure them properly with the values retrieved from
the EEPROM.

Also, this requires scan_start/scan_end callbacks to be
locked with sc->mutex.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 22e66a4c 19-Aug-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Nuke struct ath9k_node_stats

Other than ns_avgbrssi (Average beacon rssi) no data of
ath9k_node_stats is being used anywhere. Nuke this structure
and move its only useful member to ar5416Anistate. Also cleanup
this redundant data in ath_softc.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 608b88cb 17-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath: move regulatory info into shared common structure

This moves the shared regulatory structure into the
common structure. We will use this ongoing for common
data.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4c483817 17-Aug-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix TX poll cancelling

In ath9k_stop(), tx_complete_work was being cancelled twice.
This patch fixes it. Also, locking sc->mutex should be done
at the beginning.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3ac64bee 17-Aug-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: allow configure_filter callback to sleep

Over time, a whole bunch of drivers have come up
with their own scheme to delay the configure_filter
operation to a workqueue. To be able to simplify
things, allow configure_filter to sleep, and add
a new prepare_multicast callback that drivers that
need the multicast address list implement. This new
callback must be atomic, but most drivers either
don't care or just calculate a hash which can be
done atomically and then uploaded to the hardware
non-atomically.

A cursory look suggests that at76c50x-usb, ar9170,
mwl8k (which is actually very broken now), rt2x00,
wl1251, wl1271 and zd1211 should make use of this
new capability.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08fc5c1b 14-Aug-2009 Vivek Natarajan <vivek.natraj@gmail.com>

ath9k: Enable LEDs for AR9287 chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# eff563cf 12-Aug-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Set HW state properly

This patch fixes a bug in ath9k_stop() where the HW
was not put into FULL_SLEEP state. Not doing so will
cause issues in suspend-resume and the HW will not respond
to chip resets.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1aa8e847 12-Aug-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Remove has_hw_phycounters

PHY counters are available in all chipsets supported
by ath9k. Remove the check.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d15dd3e5 12-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath: add common ath_rxbuf_alloc() and make ath9k use it

Turns out ath5k and ath9k can share the same helper to
allocates RX skbs. We allocate skbs aligned to the cache line
size. This requirement seems to have come from AR5210; when
this was not done it seems sometimes we'd get bogus data. I'm
also told it may have been a performance enhancement
consideration. In the end I can't be sure we can remove this
on new hardware so just keep this and start sharing it through
ath.ko.

Make ath9k start using this, ath5k is next.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# af6a3fc7 08-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: Fix regression on receiving PS poll frames

In the the patch:

ath9k: use new FIF_PSPOLL configure filter

I forgot to add the new FIF_PSPOLL to the supported mask.
Without this we mask out the FIF_PSPOLL flag therefore
we'd ignore it from mac80211.

Cc: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e48e3a2f 24-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: cancel xmit poll work at stop() callback

We forgot to cancel this work at the stop() callback.

------------[ cut here ]------------
WARNING: at net/mac80211/util.c:511 ieee80211_queue_delayed_work+0x3a/0x40 [mac80211]()
Hardware name: 6460DWU
queueing ieee80211 work while going to suspend
Modules linked in: <-- snip -->
Pid: 5124, comm: phy0 Tainted: G W 2.6.31-rc3-wl #4
Call Trace:
[<ffffffffa03adcda>] ? ieee80211_queue_delayed_work+0x3a/0x40 [mac80211]
[<ffffffff810552b8>] warn_slowpath_common+0x78/0xd0
[<ffffffff81055394>] warn_slowpath_fmt+0x64/0x70
[<ffffffff814ed2c9>] ? thread_return+0x3e/0x635
[<ffffffffa03adcda>] ieee80211_queue_delayed_work+0x3a/0x40 [mac80211]
[<ffffffffa0297690>] ath_tx_complete_poll_work+0xc0/0x100 [ath9k]
[<ffffffffa02975d0>] ? ath_tx_complete_poll_work+0x0/0x100 [ath9k]
[<ffffffff81069b68>] worker_thread+0x178/0x260
[<ffffffff8106ecc0>] ? autoremove_wake_function+0x0/0x40
[<ffffffff810699f0>] ? worker_thread+0x0/0x260
[<ffffffff8106e89e>] kthread+0x9e/0xb0
[<ffffffff8101302a>] child_rip+0xa/0x20
[<ffffffff8106e800>] ? kthread+0x0/0xb0
[<ffffffff81013020>] ? child_rip+0x0/0x20

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2f69ffac 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove dangling error check on keycache reset on hw init

The keycache reset will not fail as right above we ensure
to set the sc->keymax to be <= ah->caps.keycache_size. Just remove
this dangling check.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 95fafca2 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: call ath9k_hw_detach() once upon hw init failure

If hw initialization fails (ath9k_hw_init()) on ath_init_softc()
we bail out and call ath9k_hw_detach(). The call ath9k_hw_detach()
is conditional though as ath9k_hw_init() could itself have called
ath9k_hw_detach(). Just describing this is itself a brain twister.
Avoid this nonsense by removing ath9k_hw_detach() from ath9k_hw_init().

Upon hw initialization failure we expect the callers to take care of
the cleanup.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3ce1b1a9 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: set sc->sc_ah to NULL after freeing it

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1e40bcfa 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: distinguish between device initialization and ath_softc init

We re-label the device driver initialization routines from the
ath_softc, the "Software Carrier" fillers. This should make it
clearer what each of these do.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f637cfd6 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: describe hw initialization better

During initialization ath9k tends to use "attach" to when we
initialize hardware due to the fact we used to attach a "HAL".
The notion of a HAL is long gone, so lets just be clear on what
we are doing.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 08e0403a 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove debug message for no memoery on ath_init()

We're now propagating the -ENOMEM error so there is no need to
keep a debug message there now.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 07c10c61 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: pass only one argument to hw attach

The softc is cached and set within the ath_hw struct.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e1e2f93f 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move cache setting of softc ah prior to attach

We do this in case attach and friends try to get back to
ah from the softc somehow.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 8df5d1b7 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move devid cache setting to ath_init()

This lets us trim one argument off of hw initializer routines.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4f3acf81 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move memory allocation of ath_hw to ath_init()

This lets us simplify attach code and arguments passed.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7819ac84 03-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: propagate hw initialization errors

We were never propagating hw initialization errors, lets
do that now and also use -EOPNOTSUPP when device revision is
not supported yet.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 42935eca 29-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

mac80211: redefine usage of the mac80211 workqueue

The mac80211 workqueue exists to enable mac80211 and drivers
to queue their own work on a single threaded workqueue. mac80211
takes care to flush the workqueue during suspend but we never
really had requirements on drivers for how they should use
the workqueue in consideration for suspend.

We extend mac80211 to document how the mac80211 workqueue should
be used, how it should not be used and finally move raw access to
the workqueue to mac80211 only. Drivers and mac80211 use helpers
to queue work onto the mac80211 workqueue:

* ieee80211_queue_work()
* ieee80211_queue_delayed_work()

These helpers will now warn if mac80211 already completed its
suspend cycle and someone is trying to queue work. mac80211
flushes the mac80211 workqueue prior to suspend a few times,
but we haven't taken the care to ensure drivers won't add more
work after suspend. To help with this we add a warning when
someone tries to add work and mac80211 already completed the
suspend cycle.

Drivers should ensure they cancel any work or delayed work
in the mac80211 stop() callback.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c94dbff7 27-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move workqueue cancels to stop callback

We should be cancelling our work at the stop callback since
we are borrowing the mac80211 workqueue for our work. As it
stands mac80211 expects this for suspend purposes.

The ath9k specific virtual wiphy stuff need only be
cancelled only when the we have no secondary virtual wiphys.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 35c95ab9 27-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move cancel_delayed_work_sync() out of ath_deinit_leds()

We do this as we'll be moving the cancel elsewhere later.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9851bad7 27-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: re-order cancelling of work on mac80211 workqueue

ath9k uses the mac80211 workqueue for 4 different types of work:

* Led blink work
* TX hang monitoring work
* internal wiphy schedular work
* channel change work done for internal wiphy schedular

Since the internal wiphy schedular can end up kicking off some
channel channel change work we should first cancel the wiphy
schedular work and then the channel change work.

The TX hang work can be cancelled second since we're going down
anyway.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 35a1e70d 27-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove unused ATH_PCI_VERSION

Our version goes by the kernel release.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 96148326 24-Jul-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: fix race with IEEE80211_CONF_PS checks

There is a small window where the mac80211 changes the IEEE80211_CONF_PS
flag, and then informs the driver about the change. We have a race
condition if we are checking the flag in the same time. Avoid it by
introducing a local variable, and using that instead of checking the
IEEE80211_CONF_PS flag directly.

This fix the problem reported by Luis:
http://article.gmane.org/gmane.linux.kernel.wireless.general/34363

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ac88b6ec 22-Jul-2009 Vivek Natarajan <vivek.natraj@gmail.com>

ath9k: Add support for AR9287 based chipsets.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f83da965 23-Jul-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Cleanup return values

Cleanup aggregation start/stop function interfaces.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9e98ac65 23-Jul-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Remove redundant HT macros

These can be obtained from mac80211.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 95a2b2ef 21-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: do not stop the queues in driver stop

mac80211 will have disabled the queues for us when
needed.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 64839170 14-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: disable radio when all devices are marked idle

This uses the new configuration changes indicated up by
mac80211 when all interfaces are marked idle. We need to do
a little more work as we have our own set of virtual
wiphys within ath9k.

Only when all virtual wiphys are inactive do we allow an idle
state change for a wiphy to trigger disabling the radio.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 04717ccd 14-Jul-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: serialize ath9k_hw_setpower calls

Because ath9k_setpower is called from various contexts, we have to
protect it against concurrent calls.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ebaa2453 14-Jul-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Remove pointless ath9k_ps_restore() in ath_detach()

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 164ace38 14-Jul-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Fix TX hang issue with Atheros chipsets

The hardware doesn't generate interrupts in some cases and so work
around this by monitoring the TX status periodically and reset the
chip if required.

This behavior of the hardware not generating the TX interrupts can
be noticed through ath9k debugfs interrupt statistics when heavy
traffic is being sent from STA to AP. One can easily see this behavior
when the STA is transmitting at a higher rates. The interrupt statistics
in the debugfs interface clearly shows that only RX interrupts alone
being generated and TX being stuck.

TX should be monitored through a timer and reset the chip only when
frames are queued to the hardware but TX interrupts are not generated
for the same even after one second. Also, we shouldn't remove holding
descriptor from AC queue if it happens to be the only descriptor and
schedule TX aggregation regarless of queue depth as it improves
scheduling of AMPDUs from software to hardware queue.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a59b5a5e 14-Jul-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Manipulate and report the correct RSSI

RSSI reported by the RX descriptor requires little manipulation.
Manipulate and report the correct RSSI to the stack. This will
fix the improper signal levels reported by iwconfig iw dev wlanX
station dump. Also the Link Quality reported seems to be varying
(falls to zero also sometimes) when iperf is run from STA to AP.

Also use the default noise floor for now as the one reported
during the caliberation seems to be wrong.

The Signal and Link Quality before this patch (taken while TX is
in progress from STA to AP)

09:59:13.285428037 Link Quality=29/70 Signal level=-81 dBm
09:59:13.410660084 Link Quality=20/70 Signal level=-90 dBm
09:59:13.586864392 Link Quality=21/70 Signal level=-89 dBm
09:59:13.710296281 Link Quality=21/70 Signal level=-89 dBm
09:59:13.821683064 Link Quality=25/70 Signal level=-85 dBm
09:59:13.933402989 Link Quality=24/70 Signal level=-86 dBm
09:59:14.045839276 Link Quality=26/70 Signal level=-84 dBm
09:59:14.193926673 Link Quality=23/70 Signal level=-87 dBm
09:59:14.306230262 Link Quality=31/70 Signal level=-79 dBm
09:59:14.419459667 Link Quality=26/70 Signal level=-84 dBm
09:59:14.530711167 Link Quality=37/70 Signal level=-73 dBm
09:59:14.642593962 Link Quality=29/70 Signal level=-81 dBm
09:59:14.754361169 Link Quality=21/70 Signal level=-89 dBm
09:59:14.866217355 Link Quality=21/70 Signal level=-89 dBm
09:59:14.976963623 Link Quality=28/70 Signal level=-82 dBm
09:59:15.089149809 Link Quality=26/70 Signal level=-84 dBm
09:59:15.205039887 Link Quality=27/70 Signal level=-83 dBm
09:59:15.316368003 Link Quality=23/70 Signal level=-87 dBm
09:59:15.427684036 Link Quality=36/70 Signal level=-74 dBm
09:59:15.539756380 Link Quality=21/70 Signal level=-89 dBm
09:59:15.650549093 Link Quality=22/70 Signal level=-88 dBm
09:59:15.761171672 Link Quality=32/70 Signal level=-78 dBm
09:59:15.872793750 Link Quality=23/70 Signal level=-87 dBm
09:59:15.984421694 Link Quality=22/70 Signal level=-88 dBm
09:59:16.097315093 Link Quality=21/70 Signal level=-89 dBm

The link quality and signal level after this patch (take while
TX is in progress from STA to AP)

17:21:25.627848091 Link Quality=65/70 Signal level=-45 dBm
17:21:25.762805607 Link Quality=65/70 Signal level=-45 dBm
17:21:25.875521888 Link Quality=66/70 Signal level=-44 dBm
17:21:25.987468448 Link Quality=66/70 Signal level=-44 dBm
17:21:26.100628151 Link Quality=66/70 Signal level=-44 dBm
17:21:26.213129671 Link Quality=66/70 Signal level=-44 dBm
17:21:26.324923070 Link Quality=65/70 Signal level=-45 dBm
17:21:26.436831357 Link Quality=65/70 Signal level=-45 dBm
17:21:26.610356973 Link Quality=65/70 Signal level=-45 dBm
17:21:26.723340047 Link Quality=65/70 Signal level=-45 dBm
17:21:26.835715293 Link Quality=64/70 Signal level=-46 dBm
17:21:26.949542748 Link Quality=64/70 Signal level=-46 dBm
17:21:27.062261613 Link Quality=65/70 Signal level=-45 dBm
17:21:27.174511563 Link Quality=64/70 Signal level=-46 dBm
17:21:27.287616232 Link Quality=64/70 Signal level=-46 dBm
17:21:27.400598119 Link Quality=64/70 Signal level=-46 dBm
17:21:27.511381404 Link Quality=64/70 Signal level=-46 dBm
17:21:27.624530421 Link Quality=65/70 Signal level=-45 dBm
17:21:27.737807109 Link Quality=64/70 Signal level=-46 dBm
17:21:27.850861352 Link Quality=65/70 Signal level=-45 dBm
17:21:27.963369436 Link Quality=64/70 Signal level=-46 dBm
17:21:28.076582289 Link Quality=64/70 Signal level=-46 dBm

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# dd190183 14-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: cleanup try count for MRR in rate control

This has no functional change and just cleans up the code
to be more legible and removes a useless variable for
Multi Rate Retry.

For regular frames we use 2 retries for MRR segments [0-2].
For the last MRR segment [3] we use 4.

MRR[0] = 2
MRR[1] = 2
MRR[2] = 2
MRR[3] = 4

Cc: Derek Smithies <derek@indranet.co.nz>
Cc: Chittajit Mitra <Chittajit.Mitra@Atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 140add21 24-Jun-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Handle different TX and RX streams properly.

This patch fixes an issue when the TX and RX streams are different.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e5f0921a 24-Jun-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: race condition in SCANNING state check during ANI calibration

ANI calibration shouldn't be done when we are not on our home channel.
This is already verified. However, it is racy. Fix this by proper
spin locks.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f38faa31 24-Jun-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: stop ani when the STA gets disconnected.

ANI is not required when the STA is disconnected. So stop it and enable
ANI for adhoc and monitor mode.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2664f201 24-Jun-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: remove unnecessary STATION mode check.

Remove unncessary STATION mode check in ath9k_bss_assoc_info() as
it is called only for STATION mode.

Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 38ab422e 17-Jun-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: restore PS mode, before we put the chip into FULL SLEEP state.

We want to put the chip into FULL SLEEP state, when we are disabling the
radio, but the the current code always change it to AWAKE/NETWORK SLEEP.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3989279c 15-Jun-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: restore power mode on error path

The ath9k_ps_{wakeup,restore} calls must be in balance.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3b319aae 13-Jun-2009 Johannes Berg <johannes@sipsolutions.net>

ath9k: port to cfg80211 rfkill

This ports the ath9k rfkill code to the new API offered by
cfg80211 and thus removes a lot of useless stuff.

("With this series a kernel panic, which is a regression, during module
unload disappears." -- Vasanthakumar Thiagarajan <vasanth@atheros.com>

Other patches in the series:

ath9k: Add helper to get ath9k specific current channel
ath9k: Make sure we have current channel in ah_curchan before rf
disable/enable

-- JWL)

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Luis Rodriguez <mcgrof@gmail.com>
Tested-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 159cd468 13-Jun-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Make sure we have current channel in ah_curchan before rf disable/enable

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 82880a7c 13-Jun-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Add helper to get ath9k specific current channel

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 19d337df 02-Jun-2009 Johannes Berg <johannes@sipsolutions.net>

rfkill: rewrite

This patch completely rewrites the rfkill core to address
the following deficiencies:

* all rfkill drivers need to implement polling where necessary
rather than having one central implementation

* updating the rfkill state cannot be done from arbitrary
contexts, forcing drivers to use schedule_work and requiring
lots of code

* rfkill drivers need to keep track of soft/hard blocked
internally -- the core should do this

* the rfkill API has many unexpected quirks, for example being
asymmetric wrt. alloc/free and register/unregister

* rfkill can call back into a driver from within a function the
driver called -- this is prone to deadlocks and generally
should be avoided

* rfkill-input pointlessly is a separate module

* drivers need to #ifdef rfkill functions (unless they want to
depend on or select RFKILL) -- rfkill should provide inlines
that do nothing if it isn't compiled in

* the rfkill structure is not opaque -- drivers need to initialise
it correctly (lots of sanity checking code required) -- instead
force drivers to pass the right variables to rfkill_alloc()

* the documentation is hard to read because it always assumes the
reader is completely clueless and contains way TOO MANY CAPS

* the rfkill code needlessly uses a lot of locks and atomic
operations in locked sections

* fix LED trigger to actually change the LED when the radio state
changes -- this wasn't done before

Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> [thinkpad]
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ccdfeab6 20-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Update Beacon timers based on timestamp from the AP

Some APs seem to drift away from the expected TBTT (timestamp %
beacon_int_in_usec differs quite a bit from zero) which can result in
us waking up way too early to receive a Beacon frame. In order to work
around this, re-configure the Beacon timers after having received a
Beacon frame from the AP (i.e., when we know the offset between the
expected TBTT and the actual time the AP is sending out the Beacon
frame).

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# eeddfd9d 19-May-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: set max default eirp to 20 dBm

This is always discarded anyway but lets just set this to our
safest lowest.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c26c2e57 19-May-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: fix custom regulatory call position

ath_regd_init() needs to be called with the wiphy already
properly set with the bands. Without this the custom regulatory
settings were not taking effect, and the device would get
the default channel settings from ath9k_[25]ghz_chantable.

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# dc8c4585 19-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Set PM field in frame control when in PS mode

mac80211 does not set PM field for normal data frames, so we need to
update that based on the current PS mode when using PS-Poll
(timeout=0) power save mode.

This allows the AP to remain in sync with our PS state. However, there
is still a potential race condition between PS state changes when
multiple TX queues are used and nullfunc and PS-Poll frames use
different queue. That corner case may need to be handled separately by
changing which queue is used either in ath9k or mac80211.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aa68aeaa 19-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Wake up for RX filter changes

We must make sure the chip is awake when changing the RX filter
parameters. This could have caused problems, e.g., when changing the
interface to promiscuous mode while in sleep mode.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 54ce846e 19-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Use TSFOOR interrupt to trigger TSF sync with next Beacon

If the chip complains about TSF sync, make sure we remain awake to
sync with the next Beacon frame. In theory, this should not be needed
since we are currently trying to receive all Beacon frames, anyway,
better have this code ready should we ever change that.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 1ffc1c61 19-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Do not try to calibrate radio when in sleep mode

When the chip is in sleep mode, there is no point trying to calibrate
the radio since it will just results in incorrect values being read
from registers and other potential issues. In addition, if we actually
start processing calibrate, do not allow the chip to be put into sleep
until we have completed the calibration step.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9a23f9ca 19-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Wake up for TX in mac80211 timeout=0 sleep mode

When using timeout=0 (PS-Poll) with mac80211, the driver will need to
wake up for TX requests and remain awake until the TX has been
completed (ACK received or timeout) or until the buffer frame(s) have
been received (in case the TX is for a PS-Poll frame).

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 153e080d 15-May-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Move PS wakeup/restore calls from isr to tasklet

We do not need to do this in ath_isr() and it looks like the modified
version ends up being more stable as far as being able receive beacon
frames is concerned. Furthermore, this reduces need to move between
AWAKE and NETWORK SLEEP states when processing some unrelated
interrupts.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 6b45784f 15-May-2009 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Print hw reset failure status as signed int

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4f0fc7c3 06-May-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: make private driver rate tables const

On x86 this allows us to do the following small savings:
shave off 23 % off of the module's data, and
shave off 6 % off of the module's text.

We save 456 bytes, for those counting.

$ size ath9k.ko
text data bss dec hex filename
250794 3628 1600 256022 3e816 ath9k.ko
$ size ath9k-old.ko
text data bss dec hex filename
239114 15308 1600 256022 3e816 ath9k-old.ko

$ du -b ath9k.ko
4034244 ath9k.ko
$ du -b ath9k-old.ko
4033788 ath9k-old.ko

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2d0ddec5 23-Apr-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: unify config_interface and bss_info_changed

The config_interface method is a little strange, it contains the
BSSID and beacon updates, while bss_info_changed contains most
other BSS information for each interface. This patch removes
config_interface and rolls all the information it previously
passed to drivers into bss_info_changed.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 57c4d7b4 23-Apr-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: clean up beacon interval settings

We currently have two beacon interval configuration knobs:
hw.conf.beacon_int and vif.bss_info.beacon_int. This is
rather confusing, even though the former is used when we
beacon ourselves and the latter when we are associated to
an AP.

This just deprecates the hw.conf.beacon_int setting in favour
of always using vif.bss_info.beacon_int. Since it touches all
the beaconing IBSS code anyway, we can also add support for
the cfg80211 IBSS beacon interval configuration easily.

NOTE: The hw.conf.beacon_int setting is retained for now due
to drivers still using it -- I couldn't untangle all
drivers, some are updated in this patch.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 85efc86e 13-Apr-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: fix propagation of bad EEPROM on regulatory init

When the EEPROM is not in good condition we cannot continue so
we currently bail out but only ath5k is bailing out properly.
Both ath9k and ar9170 were proceeding and if a user were to run
into this they'd see an obscure panic. Lets propagate the error
as intended and make sure we inform the user by lifting the
error message from debug to a kernel error.

Stable note: You can find a port of this page here:

http://bombadil.infradead.org/~mcgrof/patches/ath9k/ath9k-fix-eeprom.patch.txt

Cc: stable@kernel.org
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 379f0440 13-Apr-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Cleanup calibration interface

This patch cleans up the functions dealing with calibration,
using proper return values.
ath9k_hw_per_calibration(), ath9k_hw_calibrate now return bool values
instead of setting error values in the function arguments.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 415f738e 13-Apr-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Initialize ANI timers

The various ANI timers have to be initialized properly when
starting the calibration timer.

Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9c07a777 13-Apr-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Fix bug in scan termination

A full HW reset needs to be done on termination of a scan run.
Not setting SC_OP_FULL_RESET resulted in doing a
fast channel change.

Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d2f5b3a6 13-Apr-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Handle ASPM properly for RFKILL

Radio enable/disable have to handle ASPM state properly.
This patch fixes it.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 203c4805 30-Mar-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

atheros: put atheros wireless drivers into ath/

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>