History log of /linux-master/drivers/net/wireless/ath/ath9k/recv.c
Revision Date Author Comments
# 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


# df5c4150 11-Jun-2019 Zefir Kurtisi <zefir.kurtisi@neratec.com>

ath9k: correctly handle short radar pulses

In commit 3c0efb745a17 ("ath9k: discard undersized packets")
the lower bound of RX packets was set to 10 (min ACK size) to
filter those that would otherwise be treated as invalid at
mac80211.

Alas, short radar pulses are reported as PHY_ERROR frames
with length set to 3. Therefore their detection stopped
working after that commit.

NOTE: ath9k drivers built thereafter will not pass DFS
certification.

This extends the criteria for short packets to explicitly
handle PHY_ERROR frames.

Fixes: 3c0efb745a17 ("ath9k: discard undersized packets")
Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 03af21d6 24-Feb-2019 YueHaibing <yuehaibing@huawei.com>

ath9k: remove set but not used variable 'acq'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/ath/ath9k/recv.c: In function 'ath_rx_count_airtime':
drivers/net/wireless/ath/ath9k/recv.c:1010:18: warning:
variable 'acq' set but not used [-Wunused-but-set-variable]

It's not used after 89cea7493a34 ("ath9k: Switch to mac80211 TXQ scheduling
and airtime APIs"). Also remove related variables.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 89cea749 11-Feb-2019 Toke Høiland-Jørgensen <toke@toke.dk>

ath9k: Switch to mac80211 TXQ scheduling and airtime APIs

This moves the ath9k driver to use the mac80211 TXQ scheduling and
airtime accounting APIs, removing the corresponding state tracking
inside the driver.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
[rmanohar@codeaurora.org: fixed checkpatch error and warnings]
Signed-off-by: Rajkumar Manoharan <rmanohar@codeaurora.org>
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>


# 3c0efb74 21-Jan-2018 Felix Fietkau <nbd@nbd.name>

ath9k: discard undersized packets

Sometimes the hardware will push small packets that trigger a WARN_ON
in mac80211. Discard them early to avoid this issue.

Reported-by: Stijn Tintel <stijn@linux-ipv6.be>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 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>


# da6a4352 25-Apr-2017 Johannes Berg <johannes.berg@intel.com>

mac80211: separate encoding/bandwidth from flags

We currently use a lot of flags that are mutually incompatible,
separate this out into actual encoding and bandwidth enum values.

Much of this again done with spatch, with manual post-editing,
mostly to add the switch statements and get rid of the conversions.

@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_80MHZ
+status->bw = RATE_INFO_BW_80
@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_40MHZ
+status->bw = RATE_INFO_BW_40
@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_20MHZ
+status->bw = RATE_INFO_BW_20
@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_160MHZ
+status->bw = RATE_INFO_BW_160
@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_5MHZ
+status->bw = RATE_INFO_BW_5
@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_10MHZ
+status->bw = RATE_INFO_BW_10

@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_VHT
+status->encoding = RX_ENC_VHT
@@
expression status;
@@
-status->enc_flags |= RX_ENC_FLAG_HT
+status->encoding = RX_ENC_HT
@@
expression status;
@@
-status.enc_flags |= RX_ENC_FLAG_VHT
+status.encoding = RX_ENC_VHT
@@
expression status;
@@
-status.enc_flags |= RX_ENC_FLAG_HT
+status.encoding = RX_ENC_HT

@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_HT)
+(status->encoding == RX_ENC_HT)
@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_VHT)
+(status->encoding == RX_ENC_VHT)

@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_5MHZ)
+(status->bw == RATE_INFO_BW_5)
@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_10MHZ)
+(status->bw == RATE_INFO_BW_10)
@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_40MHZ)
+(status->bw == RATE_INFO_BW_40)
@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_80MHZ)
+(status->bw == RATE_INFO_BW_80)
@@
expression status;
@@
-(status->enc_flags & RX_ENC_FLAG_160MHZ)
+(status->bw == RATE_INFO_BW_160)

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


# 7fdd69c5 26-Apr-2017 Johannes Berg <johannes.berg@intel.com>

mac80211: clean up rate encoding bits in RX status

In preparation for adding support for HE rates, clean up
the driver report encoding for rate/bandwidth reporting
on RX frames.

Much of this patch was done with the following spatch:

@@
expression status;
@@
-status->flag & (RX_FLAG_HT | RX_FLAG_VHT)
+status->enc_flags & (RX_ENC_FLAG_HT | RX_ENC_FLAG_VHT)

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_SHORTPRE
+status->enc_flags op RX_ENC_FLAG_SHORTPRE
@@
expression status;
@@
-status->flag & RX_FLAG_SHORTPRE
+status->enc_flags & RX_ENC_FLAG_SHORTPRE

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_HT
+status->enc_flags op RX_ENC_FLAG_HT
@@
expression status;
@@
-status->flag & RX_FLAG_HT
+status->enc_flags & RX_ENC_FLAG_HT

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_40MHZ
+status->enc_flags op RX_ENC_FLAG_40MHZ
@@
expression status;
@@
-status->flag & RX_FLAG_40MHZ
+status->enc_flags & RX_ENC_FLAG_40MHZ

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_SHORT_GI
+status->enc_flags op RX_ENC_FLAG_SHORT_GI
@@
expression status;
@@
-status->flag & RX_FLAG_SHORT_GI
+status->enc_flags & RX_ENC_FLAG_SHORT_GI

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_HT_GF
+status->enc_flags op RX_ENC_FLAG_HT_GF
@@
expression status;
@@
-status->flag & RX_FLAG_HT_GF
+status->enc_flags & RX_ENC_FLAG_HT_GF

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_VHT
+status->enc_flags op RX_ENC_FLAG_VHT
@@
expression status;
@@
-status->flag & RX_FLAG_VHT
+status->enc_flags & RX_ENC_FLAG_VHT

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_STBC_MASK
+status->enc_flags op RX_ENC_FLAG_STBC_MASK
@@
expression status;
@@
-status->flag & RX_FLAG_STBC_MASK
+status->enc_flags & RX_ENC_FLAG_STBC_MASK

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_LDPC
+status->enc_flags op RX_ENC_FLAG_LDPC
@@
expression status;
@@
-status->flag & RX_FLAG_LDPC
+status->enc_flags & RX_ENC_FLAG_LDPC

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_10MHZ
+status->enc_flags op RX_ENC_FLAG_10MHZ
@@
expression status;
@@
-status->flag & RX_FLAG_10MHZ
+status->enc_flags & RX_ENC_FLAG_10MHZ

@@
assignment operator op;
expression status;
@@
-status->flag op RX_FLAG_5MHZ
+status->enc_flags op RX_ENC_FLAG_5MHZ
@@
expression status;
@@
-status->flag & RX_FLAG_5MHZ
+status->enc_flags & RX_ENC_FLAG_5MHZ

@@
assignment operator op;
expression status;
@@
-status->vht_flag op RX_VHT_FLAG_80MHZ
+status->enc_flags op RX_ENC_FLAG_80MHZ
@@
expression status;
@@
-status->vht_flag & RX_VHT_FLAG_80MHZ
+status->enc_flags & RX_ENC_FLAG_80MHZ

@@
assignment operator op;
expression status;
@@
-status->vht_flag op RX_VHT_FLAG_160MHZ
+status->enc_flags op RX_ENC_FLAG_160MHZ
@@
expression status;
@@
-status->vht_flag & RX_VHT_FLAG_160MHZ
+status->enc_flags & RX_ENC_FLAG_160MHZ

@@
assignment operator op;
expression status;
@@
-status->vht_flag op RX_VHT_FLAG_BF
+status->enc_flags op RX_ENC_FLAG_BF
@@
expression status;
@@
-status->vht_flag & RX_VHT_FLAG_BF
+status->enc_flags & RX_ENC_FLAG_BF

@@
assignment operator op;
expression status, STBC;
@@
-status->flag op STBC << RX_FLAG_STBC_SHIFT
+status->enc_flags op STBC << RX_ENC_FLAG_STBC_SHIFT

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_SHORTPRE
+status.enc_flags op RX_ENC_FLAG_SHORTPRE
@@
expression status;
@@
-status.flag & RX_FLAG_SHORTPRE
+status.enc_flags & RX_ENC_FLAG_SHORTPRE

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_HT
+status.enc_flags op RX_ENC_FLAG_HT
@@
expression status;
@@
-status.flag & RX_FLAG_HT
+status.enc_flags & RX_ENC_FLAG_HT

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_40MHZ
+status.enc_flags op RX_ENC_FLAG_40MHZ
@@
expression status;
@@
-status.flag & RX_FLAG_40MHZ
+status.enc_flags & RX_ENC_FLAG_40MHZ

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_SHORT_GI
+status.enc_flags op RX_ENC_FLAG_SHORT_GI
@@
expression status;
@@
-status.flag & RX_FLAG_SHORT_GI
+status.enc_flags & RX_ENC_FLAG_SHORT_GI

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_HT_GF
+status.enc_flags op RX_ENC_FLAG_HT_GF
@@
expression status;
@@
-status.flag & RX_FLAG_HT_GF
+status.enc_flags & RX_ENC_FLAG_HT_GF

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_VHT
+status.enc_flags op RX_ENC_FLAG_VHT
@@
expression status;
@@
-status.flag & RX_FLAG_VHT
+status.enc_flags & RX_ENC_FLAG_VHT

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_STBC_MASK
+status.enc_flags op RX_ENC_FLAG_STBC_MASK
@@
expression status;
@@
-status.flag & RX_FLAG_STBC_MASK
+status.enc_flags & RX_ENC_FLAG_STBC_MASK

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_LDPC
+status.enc_flags op RX_ENC_FLAG_LDPC
@@
expression status;
@@
-status.flag & RX_FLAG_LDPC
+status.enc_flags & RX_ENC_FLAG_LDPC

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_10MHZ
+status.enc_flags op RX_ENC_FLAG_10MHZ
@@
expression status;
@@
-status.flag & RX_FLAG_10MHZ
+status.enc_flags & RX_ENC_FLAG_10MHZ

@@
assignment operator op;
expression status;
@@
-status.flag op RX_FLAG_5MHZ
+status.enc_flags op RX_ENC_FLAG_5MHZ
@@
expression status;
@@
-status.flag & RX_FLAG_5MHZ
+status.enc_flags & RX_ENC_FLAG_5MHZ

@@
assignment operator op;
expression status;
@@
-status.vht_flag op RX_VHT_FLAG_80MHZ
+status.enc_flags op RX_ENC_FLAG_80MHZ
@@
expression status;
@@
-status.vht_flag & RX_VHT_FLAG_80MHZ
+status.enc_flags & RX_ENC_FLAG_80MHZ

@@
assignment operator op;
expression status;
@@
-status.vht_flag op RX_VHT_FLAG_160MHZ
+status.enc_flags op RX_ENC_FLAG_160MHZ
@@
expression status;
@@
-status.vht_flag & RX_VHT_FLAG_160MHZ
+status.enc_flags & RX_ENC_FLAG_160MHZ

@@
assignment operator op;
expression status;
@@
-status.vht_flag op RX_VHT_FLAG_BF
+status.enc_flags op RX_ENC_FLAG_BF
@@
expression status;
@@
-status.vht_flag & RX_VHT_FLAG_BF
+status.enc_flags & RX_ENC_FLAG_BF

@@
assignment operator op;
expression status, STBC;
@@
-status.flag op STBC << RX_FLAG_STBC_SHIFT
+status.enc_flags op STBC << RX_ENC_FLAG_STBC_SHIFT

@@
@@
-RX_FLAG_STBC_SHIFT
+RX_ENC_FLAG_STBC_SHIFT

Signed-off-by: Johannes Berg <johannes.berg@intel.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>


# 87fedb97 25-Nov-2016 Zefir Kurtisi <zefir.kurtisi@neratec.com>

ath9k: feed only active spectral / dfs-detector

Radar pulse and spectral scan reports are provided by the HW
with the ATH9K_RXERR_PHY flag set. Those are forwarded to
the dfs-detector and spectral module for further processing.

For some older chips, the pre-conditions checked in those
modules are ambiguous, since ATH9K_PHYERR_RADAR is used to
tag both types. As a result, spectral frames are fed into
the dfs-detector and vice versa.

This could lead to a false radar detection on a non-DFS
channel (which is uncritical), but more relevant it causes
useless CPU load for processing invalid frames.

This commit ensures that the dfs-detector and spectral
collector are only fed when they are active.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.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>


# f0b2c30a 19-Aug-2015 Miaoqing Pan <miaoqing@qca.qualcomm.com>

ath9k: fix AR_RX_FILTER for ar9462/ar9565 when rx stopped

When rx stopped, AR_RX_FILTER should be cleared, but in
ath9k_hw_setrxfilter(), ATH9K_RX_FILTER_CONTROL_WRAPPER will always
be set for ar9462/ar9565.

Fix this by moving the code in ath9k_hw_setrxfilter() to
ath_calcrxfilter().

Signed-off-by: Miaoqing Pan <miaoqing@qca.qualcomm.com>
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>


# e60ac9c7 02-Jul-2015 Felix Fietkau <nbd@openwrt.org>

ath9k: make DMA stop related messages debug-only

A long time ago, ath9k had issues during reset where the DMA engine
would stay active and could potentially corrupt memory.
To debug those issues, the driver would print warnings whenever they
occur.

Nowadays, these issues are gone and the primary cause of these messages
is if the MAC is stuck during reset or busy processing a long
transmission. This is fairly harmless, yet these messages continue to
worry users.

To reduce the number of bogus bug reports, turn these messages into
debug messages and count their occurence in the "reset" debugfs file.

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>


# ede6a5e7 18-Dec-2014 Miaoqing Pan <miaoqing@qca.qualcomm.com>

ath9k: Add QCA956x HW support

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


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

ath9k: move spectral.* to common-spectral.*

and rename exports from ath9k_spectral_* to ath9k_cmn_spectral_*

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


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

ath9k: remove all struct ath_softc dependencies from spectral code

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


# 853854d6 15-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix build error

This happens when CONFIG_ATH9K_CHANNEL_CONTEXT is
not enabled.

../drivers/net/wireless/ath/ath9k/recv.c: In function ‘ath_rx_ps_beacon’:
../drivers/net/wireless/ath/ath9k/recv.c:553:27: error: ‘struct ath_softc’ has no member named ‘offchannel’
if (sc->cur_chan == &sc->offchannel.chan)
^
../scripts/Makefile.build:257: recipe for target 'drivers/net/wireless/ath/ath9k/recv.o' failed
make[10]: *** [drivers/net/wireless/ath/ath9k/recv.o] Error 1
../scripts/Makefile.build:404: recipe for target 'drivers/net/wireless/ath/ath9k' failed
make[9]: *** [drivers/net/wireless/ath/ath9k] Error 2

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


# 35c273ea 15-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: enable control frame reception

Set control frame bit in rx filter if dynack processing has been activated
in order to enable ACK frame reception

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


# 982e0395 15-Sep-2014 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: add sampling methods for (tx|rx) timestamp

Add sampling methods for ACK RX timestamp in ath_rx_tasklet() and for TX frame
timestamp in ath_tx_complete_aggr() and in ath_tx_process_buffer(). These
samples will be used in dynack processing for ACK timeout estimation

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


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

ath9k: Remove unnecessary tbtt assignment

The next_tbtt variable in the scheduler is needed only
for GO/AP mode operation and is always read from the
NEXT_TBTT_TIMER in the HW. There is no need to store
the timestamp for received beacons.

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


# 48bf43fa 11-Sep-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix beacon processing in offchannel

When interfaces of different types are present
in a context and an offchannel request is received
on a STA interface, we end up trying to process
beacons received when we are offchannel. This hits
the below warning since offchannel will not have proper
beacon parameters.

Fix this by not processing beacons received when we
are offchannel.

------------[ cut here ]------------
WARNING: CPU: 1 PID: 0 at ../drivers/net/wireless/ath/ath9k/recv.c:552 ath_rx_tasklet+0xf8f/0x1020 [ath9k]()
CPU: 1 PID: 0 Comm: swapper/1 Tainted: G O 3.17.0-rc4-wl-debug #16
Hardware name: LENOVO 28427ZQ/INVALID, BIOS 6JET58WW (1.16 ) 09/17/2009
0000000000000000 15916787056abba3 ffff88013b603d08 ffffffff8156af94
ffff88013b603d50 ffff88013b603d40 ffffffff81070dbd ffff8800a84bb300
ffff8800b05db358 ffff8800a84cc578 ffff8800a84bb300 ffff8800b05daa40
Call Trace:
<IRQ> [<ffffffff8156af94>] dump_stack+0x4d/0x6f
[<ffffffff81070dbd>] warn_slowpath_common+0x7d/0xa0
[<ffffffff81070e3c>] warn_slowpath_fmt+0x5c/0x80
[<ffffffff81572143>] ? _raw_spin_lock_irqsave+0x83/0xa0
[<ffffffffa09d04a6>] ? ath_rx_tasklet+0x9f6/0x1020 [ath9k]
[<ffffffffa09d0a3f>] ath_rx_tasklet+0xf8f/0x1020 [ath9k]
[<ffffffffa09cd4f4>] ath9k_tasklet+0xf4/0x310 [ath9k]
[<ffffffff81075a97>] tasklet_action+0xe7/0xf0
[<ffffffff8107508a>] __do_softirq+0x12a/0x340
[<ffffffff8107544e>] irq_exit+0x9e/0xc0
[<ffffffff81575e56>] do_IRQ+0x56/0xe0
[<ffffffff81573c72>] common_interrupt+0x72/0x72
<EOI> [<ffffffff81421037>] ? cpuidle_enter_state+0x67/0x1a0
[<ffffffff81421257>] cpuidle_enter+0x17/0x20
[<ffffffff810b3ebe>] cpu_startup_entry+0x3ce/0x420
[<ffffffff81048563>] start_secondary+0x233/0x2c0
---[ end trace f15c3e33ba78d840 ]---
------------[ cut here ]------------

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>


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

ath9k: Fix COMP_BAR filter

ATH9K_RX_FILTER_COMP_BAR is used to receive BAR
completion frames and is set if the current channel
is HT. When channel contexts are enabled, instead of using
the mac80211 helpers, check if the current channel
definition is HT.

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>


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

ath9k: Add wrappers for beacon events

Using these wrappers allows us to move the 'sched'
variable in ath_softc inside CONFIG_ATH9K_CHANNEL_CONTEXT.

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>


# 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>


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

ath9k: Adjust AP beacon tsf based on station context

In multi channel context (AP + STA case), adjust the TSF time of
the AP chanctx to keep its beacons at half beacon interval offset
relative to the STA chanctx.

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>


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

ath9k: Move beacon config to channel context

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>


# 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>


# 7dd74f5f 23-May-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: avoid passing buffers to the hardware during flush

The commit "ath9k: fix possible hang on flush" changed the receive code
to always link rx descriptors of processed frames, even when flushing.
In some cases, this leads to flushed rx buffers being passed to the
hardware while rx is already stopped.

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


# 76c93983 30-Apr-2014 Ben Greear <greearb@candelatech.com>

ath9k: Prevent divide-by-zero upon bad beacon_interval.

A similar patch fixed crashes seen on an ath9k system
when testing against a broken ath10k AP. This patch
is slightly less protective, but probably will do the
job and is less redundant.

Signed-off-by: Ben Greear <greearb@candelatech.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>


# c82552c5 21-Apr-2014 Tim Harvey <tharvey@gateworks.com>

ath9k: add a recv budget

Implement a recv budget so that in cases of high traffic we still allow other
taskets to get processed.

Without this, we can encounter a host of issues during high wireless traffic
reception depending on system load including rcu stall's detected (ARM),
soft lockups, failure to service critical tasks such as watchdog resets,
and triggering of the tx stuck tasklet.

The same thing was proposed previously by Ben:
http://www.spinics.net/lists/linux-wireless/msg112891.html

The only difference here is that I make sure only processed packets are counted
in the budget by checking at the end of the rx loop.

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


# 3a758134 21-Apr-2014 Tim Harvey <tharvey@gateworks.com>

ath9k: fix possible hang on flush

If a flush is requested, make sure to clear the descriptor once we've
processed it.

This resolves a hang that will occur if all RX descriptors are full when a
flush is requested.

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


# b7b146c9 24-Feb-2014 Felix Fietkau <nbd@openwrt.org>

ath9k: fix invalid descriptor discarding

Only set sc->rx.discard_next to rx_stats->rs_more when actually
discarding the current descriptor.

Also, fix a detection of broken descriptors:
First the code checks if the current descriptor is not done.
Then it checks if the next descriptor is done.
Add a check that afterwards checks the first descriptor again, because
it might have been completed in the mean time.

This fixes a regression introduced in
commit 723e711356b5a8a95728a890e254e8b0d47b55cf
"ath9k: fix handling of broken descriptors"

Cc: stable@vger.kernel.org
Reported-by: Marco André Dinis <marcoandredinis@gmail.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5a078fcb 04-Feb-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move ath9k_rx_skb_postprocess to common.c

and rename it to ath9k_cmn_rx_skb_postprocess. We will use it
on ath9k_htc.

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


# 6438696e 04-Feb-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: move ath9k_rx_accept to common.c

we can reuse it on ath9k_htc

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


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

ath9k: move ath9k_process_rate to common.c

we can reuse this function in ath9k_htc

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
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>


# 1cc47a5b 15-Jan-2014 Oleksij Rempel <linux@rempel-privat.de>

ath9k: use ath_is_mybeacon

This patch will also change behavior of rx_beacons statistic.
Instead of collecting all received beacons, it will collect only
ours. This, IMO make more sense, since for troubleshooting we will
need to know count of our beacons, or both.

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


# 350e2dcb 12-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add a debugfs file "node_recv"

This would be useful when debugging RX performance issues.

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


# ff9a93f2 08-Jan-2014 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use correct channel for RX packets

Accessing the current channel definition in mac80211
when processing RX packets is problematic because it
could have been updated when a scan is issued. Since a
channel change involves flushing the existing packets
in the RX queue before a chip-reset is done, they would
be processed using the wrong band/channel information.

To avoid this, use the current channel information
maintained in the driver.

Cc: stable@vger.kernel.org
Reported-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2c323058 30-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Add hardware support for QCA9531

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


# 36ddf203 30-Dec-2013 Julia Lawall <Julia.Lawall@lip6.fr>

ath9k: use ether_addr_equal_64bits

Ether_addr_equal_64bits is more efficient than ether_addr_equal, and can be
used when each argument is an array within a structure that contains at
least two bytes of data beyond the array.

The structures involved are:
ieee80211_hdr defined in include/linux/ieee80211.h
ath_common defined in drivers/net/wireless/ath/ath.h

This was done using Coccinelle (http://coccinelle.lip6.fr/).

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
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>


# f65c0825 17-Dec-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Cleanup spectral scan code

* Move definitions to spectral.h
* Move processing/debug code to spectral.c

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


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

ath9k: add support for reporting per-chain signal strength

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
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>


# e07f01e4 11-Oct-2013 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: add HT40 spectral scan capability

Add spectral scan feature on HT40 channels for ath9k. This patch extends
previous capability added by Simon Wunderlich

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Reviewed-by: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
Tested-by: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


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

ath9k: use a separate data structure for rx buffers

There's no shared code for handling both rx and tx buffers, and tx
buffers require a lot more metadata than rx buffers.
Using a separate data structure for rx reduces memory usage and improves
cache footprint.

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


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

ath9k: Fix regression in LNA diversity

The commit "ath9k: Optimize LNA check" tried
to use the "rs_firstaggr" flag to optimize the LNA
combining algorithm when processing subframes in
an A-MPDU. This doesn't appear to work well in practice,
so revert it and use the old method of relying on
"rs_moreaggr".

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


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

ath9k: report 5/10 MHz channels

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>


# 5d07cca2 14-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use lockless variant to initialize RX fifo

Since the rx_fifo queue is accessed only using the various
lockless SKB queue routines, there is no need to initialize
the lock and __skb_queue_head_init() can be used.

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


# c3124df7 14-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Optimize LNA check

The documentation for antenna diversity says:

"The decision of diversity is done at 802.11 preamble. So, for
11G/11B, for every MAC packet hardware will do a decision. But in
11N with aggregation, the decision is made only at the preamble and
all other MPDUs will use the same LNA as the first MPDU."

Make use of rs_firstaggr to avoid needlessly scanning for LNA
changes.

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


# e3acd13d 14-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Handle invalid RSSI

The combined RSSI can be invalid which is indicated by
the value -128. Use RX_FLAG_NO_SIGNAL_VAL for such cases.

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


# ea3ef101 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove unused function argument

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


# 7c5c73cd 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix error condition for corrupt descriptors

In case a descriptor has the "done" bit clear and the
next descriptor has it set, we drop both of them. If
the packet that is received after these two packets
is dropped for some reason, "discard_next" will not cleared.
Fix this.

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


# b0925595 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Handle corrupt descriptors properly

The MIC/PHYERR/CRC error bits are valid only for
the last desc. for chained packets. Check this early
in the preprocess() routine and bail out.

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


# eb5f952c 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Move the RX poll check to preprocess()

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


# 6f38482e 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX beacon processing

Make sure that chained descriptors are handled correctly
before the packet is parsed to determine if it is a beacon.

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


# a5525d9c 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX packet counter

Handle chained descriptors and increment the RX counter
only for valid packets. Since this is used only by MCI,
use CONFIG_ATH9K_BTCOEX_SUPPORT.

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


# 5e85a32a 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX debug statistics

The various error bits that ath_debug_stat_rx()
checks are valid only for the last descriptor for
a chained packet, handle this correctly.

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


# 6b87d71c 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix PHY error processing

Parse the PHY error details only for the last fragment
in case descriptors are chained.

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


# 3105b672 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Reorder some functions

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


# e0dd1a96 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix TSF processing

There is no need to calculate the mactime for chained
descriptor packets, so make sure that this is done
only for the last fragment of valid packets.

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


# 4a470647 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX crypto processing

The keymiss events are valid only in the last descriptor
of a packet. Fix this by making sure that we return
early in case of chained descriptors.

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


# 5871d2d7 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Discard invalid frames early

Frames with invalid or zero length can be discarded
early, there is no need to check the crypto bits.

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


# 0cab329d 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix phy error handling for DFS

Since the DFS code appears to process the phy errors
ATH9K_PHYERR_RADAR and ATH9K_PHYERR_FALSE_RADAR_EXT,
check for the correct phyerr status in the main RX
tasklet routine.

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


# f6307dda 13-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use a subroutine to check for "mybeacon"

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


# e96542e5 10-Aug-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: fix rx descriptor related race condition

Similar to a race condition that exists in the tx path, the hardware
might re-read the 'next' pointer of a descriptor of the last completed
frame. This only affects non-EDMA (pre-AR93xx) devices.

To deal with this race, defer clearing and re-linking a completed rx
descriptor until the next one has been processed.

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


# 16fe28e9 06-Aug-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Run the LNA combining algorithm properly

The LNA combining algorithm has to be run for cards
that support the required diversity features, make
sure that that correct conditions are met before
enabing this algorithm.

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


# 74a97755 02-Jun-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Return early for invalid rates

Process and update the internal RSSI average, which
is used by ANI, after verifying that the received
frame has valid rate information.

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


# ab276103 23-May-2013 Oleksij Rempel <linux@rempel-privat.de>

ath9k: remove useless flag conversation.

some flags used only outside of ath9k - In this case we can use
"enum mac80211_rx_flags" and pass it upstream without extra
conversation.

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


# 176f0e84 22-Apr-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix RX DMA mapping

After the commit "ath9k: improve dma map failure handling", the
wrong buffer was DMA-unmapped, introducing warnings like the one below.
This patch fixes the issue.

WARNING: at /home/sujith/dev/wireless-testing/lib/dma-debug.c:986 check_sync+0x4bc/0x580()
Hardware name: LIFEBOOK AH531
ath9k 0000:02:00.0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x00000000d9012800] [size=48 bytes]
Pid: 86, comm: kworker/u:5 Tainted: G W O 3.9.0-rc8-wl-debug #106
Call Trace:
[<ffffffff810410c0>] warn_slowpath_common+0x70/0xa0
[<ffffffff8104113c>] warn_slowpath_fmt+0x4c/0x50
[<ffffffff8125432c>] check_sync+0x4bc/0x580
[<ffffffff8109e5f7>] ? trace_hardirqs_on_caller+0xa7/0x190
[<ffffffff8109e6ed>] ? trace_hardirqs_on+0xd/0x10
[<ffffffff81254488>] debug_dma_sync_single_for_device+0x48/0x50
[<ffffffffa0a53825>] ? ath9k_iowrite32+0x35/0x90 [ath9k]
[<ffffffff812512f0>] ? swiotlb_tbl_sync_single+0x50/0x90
[<ffffffff81251350>] ? swiotlb_sync_single+0x20/0x30
[<ffffffff8125137f>] ? swiotlb_sync_single_for_device+0xf/0x20
[<ffffffffa0a58baf>] ath_rx_edma_buf_link+0xef/0x140 [ath9k]
[<ffffffffa0a58c4e>] ath_rx_addbuffer_edma+0x4e/0x90 [ath9k]
[<ffffffffa0a59c51>] ath_startrecv+0xf1/0x120 [ath9k]
[<ffffffffa0a550e0>] ath_complete_reset+0x20/0x130 [ath9k]
[<ffffffffa0a5790d>] ath_reset_internal+0x10d/0x210 [ath9k]
[<ffffffffa0a5878c>] ath9k_config+0x47c/0x7b0 [ath9k]
[<ffffffffa06d4978>] ieee80211_hw_config+0x88/0x3f0 [mac80211]
[<ffffffffa06d4a3f>] ? ieee80211_hw_config+0x14f/0x3f0 [mac80211]
[<ffffffffa06dbed1>] __ieee80211_scan_completed+0xc1/0x440 [mac80211]
[<ffffffffa06dd002>] ieee80211_scan_work+0x82/0x440 [mac80211]
[<ffffffff810606a3>] process_one_work+0x1e3/0x530
[<ffffffff81060641>] ? process_one_work+0x181/0x530
[<ffffffff8106163f>] worker_thread+0x10f/0x3c0
[<ffffffff81061530>] ? manage_workers+0x330/0x330
[<ffffffff810665da>] kthread+0xea/0xf0
[<ffffffff810664f0>] ? kthread_create_on_node+0x140/0x140
[<ffffffff8146085c>] ret_from_fork+0x7c/0xb0
[<ffffffff810664f0>] ? kthread_create_on_node+0x140/0x140

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


# 07236bf3 22-Apr-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Use lockless variants for the RX fifo queue

The RX fifo can be accessed from the common tasklet or it can
be reaped/cleaned when RX is stopped, which is done when doing
a reset or channel change - this happens in process context.

Since it is ensured that there are no pending tasklets when
stopping RX and cleaning the FIFO, there is no need to use
SKB queue functions which take internal locks.

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


# e87f3d53 22-Apr-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Reduce deep indentation

The EDMA case is handled first, so the else condition
can be removed.

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


# 7a897203 22-Apr-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Remove unused argument "size"

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


# 3747c3ee 07-Apr-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: detect more kinds of invalid descriptors

If AR_CRCErr, AR_PHYErr, AR_DecryptCRCErr or AR_MichaelErr is indicated
in the rx status word, but AR_RxFrameOK is also set, the descriptor
contents are typically invalid. This can show up as a warning about
invalid MCS rates in a frame. Even with those checks in place, a
descriptor with invalid MCS rates can still sometimes make it through to
the driver (mostly on older hardware like AR91xx).

Detect such errors in the last descriptor of a frame and discard the
whole frame if present.

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


# 723e7113 07-Apr-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: fix handling of broken descriptors

As the comment in ath_get_next_rx_buf indicates, if a descriptor with
the done bit set follows one with the done bit cleared, both descriptors
should be discarded, however the driver is not doing that yet.

To fix this, use the rs->rs_more flag as an indicator that the following
frame should be discarded. This also helps with the split buffer case:
if the first part of the frame is discarded, the following parts need to
be discarded as well, since they contain no valid header or usable data.

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


# 2e1cd495 07-Apr-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: improve dma map failure handling

Instead of leaving the buffer without skb and breaking out of the loop
(which could leak the rx buffer), use the common error path.

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


# c60c9929 07-Apr-2013 Felix Fietkau <nbd@openwrt.org>

ath9k_common: remove ath9k_cmn_padpos

It is equivalent to ieee80211_hdrlen

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>


# 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>


# 1a6404a1 04-Feb-2013 Sujith Manoharan <c_manoha@qca.qualcomm.com>

ath9k: Fix IBSS joiner mode

On joining an existing IBSS network, beaconing has to start
only after a TSF sync has happened by receiving a beacon from
the BSS. In creator mode, beaconing can start immediately after
a HW reset has been done.

Now that mac80211 notifies the driver of the mode type (creator/joiner)
via ieee80211_bss_conf->ibss_creator, make use of it to properly setup
the HW beacon timers.

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


# 12824374 31-Jan-2013 Sven Eckelmann <sven@narfation.org>

ath9k: Fix sparse __CHECK_ENDIAN__ for spectral code

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ab2e2fc8 31-Jan-2013 Sven Eckelmann <sven@narfation.org>

ath9k: Only add fix_rssi_inv_only when spectral code is used

The code is only used when ATH9K_DEBUGFS is activated and causes build warnings
when it is still compiled without user.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bd2ffe14 31-Jan-2013 Sven Eckelmann <sven@narfation.org>

ath9k: Only process fft samples when ATH9K_DEBUGFS is enabled

The code can only be used when ATH9k_DEBUGFS is enabled an not when ATH_DEBUG
is activated. Still enabling it would cause build failures.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 21fbbca3 30-Jan-2013 Christian Lamparter <chunkeey@googlemail.com>

ath9k: report A-MPDU status

The ath9k hardware reports whenever an frame was part
of an A-MPDU. MAC80211 already provides the necessary
API to pass this additional information along to
whomever needs it.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4ab0b0aa 23-Jan-2013 Sven Eckelmann <sven@open-mesh.com>

ath9k: Update spectral scan output data

The sample data received through the spectral scan can be either in big or
little endian byteorder. This information isn't stored in the output file.
Therefore it is not possible for the analyzer software to find the correct byte
order.

It is relative common to get the data from a low end AP in big endian mode and
transfer it to another computer in little endian mode to analyze it. Therefore,
it would be better to store it in network (big endian) byte order.

The extension of the 8 bit bins for each bin to 16 bit is not necessary. This
operation can be done in userspace or on a different machine. Instead the
max_exp defining the amount of shifting required for each bin is exported to
userspace.

The change of the output format requires a change of the type in the sample
tlv to allow the userspace program to correctly detect the bin format.

Reported-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
[siwu@hrz.tu-chemnitz.de: squashed patches, update commit message, rebase, fix endianess bug]
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>


# 9b99e665 23-Jan-2013 Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

ath9k: drop spectral packets after processing them

Spectral packets are "bogus" packets and should not be further evaluated
by the RX path.

Statistics are added to keep track of these packets.

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>


# 463e3ed3 14-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: remove sc->rx.rxbuflock to fix a deadlock

The commit "ath9k: fix rx flush handling" added a deadlock that happens
because ath_rx_tasklet is called in a section that has already taken the
rx buffer lock.

It seems that the only purpose of the rxbuflock was a band-aid fix to the
reset vs rx tasklet race, which has been properly fixed in the commit
"ath9k: add a better fix for the rx tasklet vs rx flush race".

Now that the fix is in, we can safely remove the lock to avoid such issues.

Cc: stable@vger.kernel.org
Reported-by: Sujith Manoharan <c_manoha@qca.qualcomm.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>


# a3dc48e8 09-Jan-2013 Felix Fietkau <nbd@openwrt.org>

ath9k: do not link receive buffers during flush

On AR9300 the rx FIFO needs to be empty during reset to ensure that no
further DMA activity is generated, otherwise it might lead to memory
corruption issues.

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>


# b81950b1 12-Dec-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: use the devres API for allocations/mappings

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 96d21371 10-Dec-2012 Thomas Pedersen <thomas@cozybit.com>

ath9k: RX timestamp is reported at end of frame

Accurate RX timestamp reporting is important for proper IBSS merging,
mesh synchronization, and MCCA scheduling. Namely, knowing where the TSF
is recorded is needed to sync with the beacon timestamp field.

Tested with AR9280.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f4bda337 13-Nov-2012 Thomas Pedersen <thomas@cozybit.com>

mac80211: support RX_FLAG_MACTIME_END

Allow drivers to indicate their mactime is at RX completion and adjust
for this in mac80211. Also rename the existing RX_FLAG_MACTIME_MPDU to
RX_FLAG_MACTIME_START to clarify its intent. Based on similar code by
Johannes Berg.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
[fix docs, atheros drivers]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# be41b052 08-Oct-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Ensure we set FTP_STOMP_LOW weight when WLAN is idle

When WLAN is idle ensure we downgrade to FTP_STOMP_LOW weight
(from STOMP_LOW) to provide more bandwidth for BT FTP profile.
WLAN's idleness can be estimated by taking into account of the
rx data packets and just ignore beacons, qos nullfunc etc.

Also update bt_wait_time even if the chip is in NETWORK SLEEP
mode. This should help BT throughput when WLAN is idle.

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# a549459c 25-Sep-2012 Thomas Wagner <Thomas.Wagner@hs-rm.de>

ath9k: Fix rx filtering issue for older chips

We need to have the promiscuous mode enabled for older
chipsets so that the olderchips hardware does not
filters out some valid/necessary frames that need
to be sent to mac80211. Fix this by enabling promiscus
mode for all the chipsets whose macversion <= AR9160
chipsets. This should fix
https://bugzilla.kernel.org/show_bug.cgi?id=45591

shafi: made the fix generic by having the frame filtering
disabled for chipsets older than AR9280.

Cc: Javier Cardona <javier@cozybit.com>
Signed-off-by: Thomas Wagner <Thomas.Wagner@hs-rm.de>
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e1352fde 10-Aug-2012 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>

ath9k: fix decrypt_error initialization in ath_rx_tasklet()

ath_rx_tasklet() calls ath9k_rx_skb_preprocess() and ath9k_rx_skb_postprocess()
in a loop over the received frames. The decrypt_error flag is
initialized to false
just outside ath_rx_tasklet() loop. ath9k_rx_accept(), called by
ath9k_rx_skb_preprocess(),
only sets decrypt_error to true and never to false.
Then ath_rx_tasklet() calls ath9k_rx_skb_postprocess() and passes
decrypt_error to it.
So, after a decryption error, in ath9k_rx_skb_postprocess(), we can
have a leftover value
from another processed frame. In that case, the frame will not be marked with
RX_FLAG_DECRYPTED even if it is decrypted correctly.
When using CCMP encryption this issue can lead to connection stuck
because of CCMP
PN corruption and a waste of CPU time since mac80211 tries to decrypt an already
deciphered frame with ieee80211_aes_ccm_decrypt.
Fix the issue initializing decrypt_error flag at the begging of the
ath_rx_tasklet() loop.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: <stable@kernel.org>
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>


# b3d7aa43 03-Jul-2012 Gabor Juhos <juhosg@openwrt.org>

ath9k: set 4ADDRESS bit in RX filter 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>


# 6bb51c70 27-Jun-2012 Tom Hughes <tom@compton.nu>

ath9k: fix panic caused by returning a descriptor we have queued for reuse

Commit 3a2923e83c introduced a bug when a corrupt descriptor
is encountered - although the following descriptor is discarded
and returned to the queue for reuse the associated frame is
also returned for processing. This leads to a panic:

BUG: unable to handle kernel NULL pointer dereference at 000000000000003a
IP: [<ffffffffa02599a5>] ath_rx_tasklet+0x165/0x1b00 [ath9k]
Call Trace:
<IRQ>
[<ffffffff812d7fa0>] ? map_single+0x60/0x60
[<ffffffffa028f044>] ? ath9k_ioread32+0x34/0x90 [ath9k]
[<ffffffffa0292eec>] athk9k_tasklet+0xdc/0x160 [ath9k]
[<ffffffff8105e133>] tasklet_action+0x63/0xd0
[<ffffffff8105dbc0>] __do_softirq+0xc0/0x1e0
[<ffffffff8101a873>] ? native_sched_clock+0x13/0x80
[<ffffffff815f9d5c>] call_softirq+0x1c/0x30
[<ffffffff810151f5>] do_softirq+0x75/0xb0
[<ffffffff8105df95>] irq_exit+0xb5/0xc0
[<ffffffff815fa5b3>] do_IRQ+0x63/0xe0
[<ffffffff815f0cea>] common_interrupt+0x6a/0x6a
<EOI>
[<ffffffff8131840a>] ? intel_idle+0xea/0x150
[<ffffffff813183eb>] ? intel_idle+0xcb/0x150
[<ffffffff814a1db9>] cpuidle_enter+0x19/0x20
[<ffffffff814a23d9>] cpuidle_idle_call+0xa9/0x240
[<ffffffff8101c4bf>] cpu_idle+0xaf/0x120
[<ffffffff815cda8e>] rest_init+0x72/0x74
[<ffffffff81cf4c1a>] start_kernel+0x3b7/0x3c4
[<ffffffff81cf4662>] ? repair_env_string+0x5e/0x5e
[<ffffffff81cf4346>] x86_64_start_reservations+0x131/0x135
[<ffffffff81cf444a>] x86_64_start_kernel+0x100/0x10f

Making sure bf is cleared to NULL in this case restores the
old behaviour.

Signed-off-by: Tom Hughes <tom@compton.nu>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# bed3d9c0 23-Jun-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: fix dynamic WEP related regression

commit 7a532fe7131216a02c81a6c1b1f8632da1195a58
ath9k_hw: fix interpretation of the rx KeyMiss flag

This commit used the rx key miss indication to detect packets that were
passed from the hardware without being decrypted, however it seems that
this bit is not only undefined in the static WEP case, but also for
dynamically allocated WEP keys. This caused a regression when using
WEP-LEAP.

This patch fixes the regression by keeping track of which key indexes
refer to CCMP keys and only using the key miss indication for those.

Reported-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@vger.kernel.org
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>


# 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>


# 6995fb80 04-Jun-2012 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: improve BT FTP/PAN performance

When BT FTP/PAN transmits while WLAN is idle, the one of 9462 chain
often picks up BT's tx signal and starts receiving. If the current
weight is set to be higher than BT tx, BT tx will be aborted and this
also degrades BT performance. Hence lower WLAN rx priority in this
case only when there are no WLAN traffic.

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>


# 2e42e474 09-May-2012 Joe Perches <joe@perches.com>

drivers/net: Convert compare_ether_addr to ether_addr_equal

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

Done via cocci script:

$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)

@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)

@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)

@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)

@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)

@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)

@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)

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


# 2a5783b8 20-Apr-2012 Michael Liang <mliang@qca.qualcomm.com>

ath9k: don't strip mic on non-encrypted frames in tkip

Fix the following bug: in tkip mode, qos-null ps on/off packets
are dropped due to incorrect packet length so that ath9k softap
can't handle powersave state transition of peer STA correctly.

Signed-off-by: Michael Liang <mliang@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 990e08a0 17-Apr-2012 Ben Greear <greearb@candelatech.com>

ath9k: Fix compile warnings when DEBUGFS is disabled.

This fixes two compile warnings, and removes a useless
cast when assigning the 'sc' variable.

Reported-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 15072189 03-Apr-2012 Ben Greear <greearb@candelatech.com>

ath9k: Add more recv stats.

This adds counters in various places that can drop packets on
rx without otherwise incrementing a counter. It also counts
some non-error cases, such as becons and fragments received.

Should help with figuring out where packets are (and are not)
dropped.

Signed-off-by: Ben Greear <greearb@candelatech.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>


# b5447ff9 15-Mar-2012 Eric Dumazet <eric.dumazet@gmail.com>

ath9k: fix a memory leak in ath_rx_tasklet()

commit 0d95521ea7 (ath9k: use split rx buffers to get rid of order-1 skb
allocations) added in memory leak in error path.

sc->rx.frag should be cleared after the pskb_expand_head() call, or else
we jump to requeue_drop_frag and leak an skb.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jouni Malinen <jouni@qca.qualcomm.com>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: Trond Wuellner <trond@chromium.org>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Paul Stewart <pstew@chromium.org>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ffb1c56a 09-Mar-2012 Ashok Nagarajan <ashok@cozybit.com>

ath9k: Fix mactime from being clobbered in rx_status

mactime was being overwritten by the function ath9k_rx_skb_preprocess. Fixed by
memsetting rx_status in ath_rx_tasklet.

Signed-off-by: Ashok Nagarajan <ashok@cozybit.com>
Signed-off-by: Javier Cardona <javier@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2ef16755 03-Mar-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: fix signal strength reporting issues

On A-MPDU frames, the hardware only reports valid signal strength data for
the last subframe. The driver also mangled rx_stats->rs_rssi using the
ATH_EP_RND macro in a way that may make sense for ANI, but definitely
not for reporting to mac80211.
This patch changes the code to calculate the signal strength from the rssi
directly instead of taking the average value, and flag everything but
the last subframe in an A-MPDU to tell mac80211 to ignore the signal strength
entirely, fixing signal strength fluctuation issues reported by various
users.

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


# 3a2923e8 03-Mar-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: get rid of double queueing of rx frames on EDMA

Process rx status directly instead of separating the completion test from
the actual rx status processing.

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


# 6a01f0c0 28-Feb-2012 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: make use of list_for_each_entry_safe

this does the same thing as the previous code

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f88373fa 05-Feb-2012 Felix Fietkau <nbd@openwrt.org>

ath9k: fix a WEP crypto related regression

commit b4a82a0 "ath9k_hw: fix interpretation of the rx KeyMiss flag"
fixed the interpretation of the KeyMiss flag for keycache based lookups,
however WEP encryption uses a static index, so KeyMiss is always asserted
for it, even though frames are decrypted properly.
Fix this by clearing the ATH9K_RXERR_KEYMISS flag if no keycache based
lookup was performed.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@vger.kernel.org
Reported-by: Laurent Bonnans <bonnans.l@gmail.com>
Reported-by: Jurica Vukadin <u.ra604@googlemail.com>
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>


# 356cb55d 07-Dec-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: validate for non-zero BSSID

before concluding that the recieved beacon is for us, let us make sure
that the BSSID is non-zero. when I configured ad-hoc mode as creator and
left it for some time without joining I found we recieved few frames whose
BSSID is zero, which we concluded wrongly as 'my_beacons'

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 7468722b 30-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: minor cleanup

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# eb840a80 29-Nov-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: change the default antenna settings based on diversity

change the AR_DEF_ANTENNA register settings i.e setting default antenna
setting only for antenna diversity enabled chipsets. no point in
doing this for MIMO chipsets

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 83c76570 16-Nov-2011 Zefir Kurtisi <zefir.kurtisi@neratec.com>

ath9k: trivial: reorder rx_tasklet processing

DFS events are reported as PHY errors and need to be processed
with a correct timestamp set before ath9k_skb_preprocess() is
called and the frame is possibly dropped.

This patch puts the rxs->mactime calculation before the skb
is preprocessed to prepare for DFS event reporting.

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


# ec205999 08-Oct-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: only send FCS-fail packets to mac80211 if requested

Prevents lots of broken frames from showing up on monitor interfaces
by default.

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


# 846d9363 08-Oct-2011 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: fix a regression in key miss handling

The commit "ath9k_hw: Fix incorrect key_miss handling" changed the code
to only report key miss errors if a MIC error wasn't reported.
When checking the flags in that order in the MAC code, it might miss some
real events, because the value of the MIC error flag is undefined under
some conditions.

The primary issue addressed by the previous commit is making sure that
MIC errors are properly reported on the STA side. This can be fixed in
a better way by adding a separate rx status flag for key miss and
ignoring it for multicast frames.

This fix slightly improves stability in AP mode on some older hardware,
like AR9132.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
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>


# ac06697c 08-Oct-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: disable unnecessary PHY error reporting

PHY errors relevant for ANI are always tracked by hardware counters, the
bits that allow them to pass through the rx filter are independent of that.
Enabling PHY errors in the rx filter often creates lots of useless DMA traffic
and might be responsible for some of the rx dma stop failure warnings.

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


# f73c604c 26-Sep-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Remove redundant my beacon check at ath_rx_ps_beacon

Make use of the rx status's is_mybeacon in order to avoid
redundant memcmp.

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


# ba542385 23-Sep-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: Fix a dma warning/memory leak

proper dma_unmapping and freeing of skb's has to be done in the rx
cleanup for EDMA chipsets when the device is unloaded and this also
seems to address the following warning which shows up occasionally when
the device is unloaded

Call Trace:
[<c0148cd2>] warn_slowpath_common+0x72/0xa0
[<c03b669c>] ? dma_debug_device_change+0x19c/0x200
[<c03b669c>] ? dma_debug_device_change+0x19c/0x200
[<c0148da3>] warn_slowpath_fmt+0x33/0x40
[<c03b669c>] dma_debug_device_change+0x19c/0x200
[<c0657f12>] notifier_call_chain+0x82/0xb0
[<c0171370>] __blocking_notifier_call_chain+0x60/0x90
[<c01713bf>] blocking_notifier_call_chain+0x1f/0x30
[<c044f594>] __device_release_driver+0xa4/0xc0
[<c044f647>] driver_detach+0x97/0xa0
[<c044e65c>] bus_remove_driver+0x6c/0xe0
[<c029af0b>] ? sysfs_addrm_finish+0x4b/0x60
[<c0450109>] driver_unregister+0x49/0x80
[<c0299f54>] ? sysfs_remove_file+0x14/0x20
[<c03c3ab2>] pci_unregister_driver+0x32/0x80
[<f92c2162>] ath_pci_exit+0x12/0x20 [ath9k]
[<f92c8467>] ath9k_exit+0x17/0x36 [ath9k]
[<c06523cd>] ? mutex_unlock+0xd/0x10
[<c018e27f>] sys_delete_module+0x13f/0x200
[<c02139bb>] ? sys_munmap+0x4b/0x60
[<c06547c5>] ? restore_all+0xf/0xf
[<c0657a20>] ? spurious_fault+0xe0/0xe0
[<c01832f4>] ? trace_hardirqs_on_caller+0xf4/0x180
[<c065b863>] sysenter_do_call+0x12/0x38
---[ end trace 16e1c1521c06bcf9 ]---
Mapped at:
[<c03b7938>] debug_dma_map_page+0x48/0x120
[<f92ba3e8>] ath_rx_init+0x3f8/0x4b0 [ath9k]
[<f92b5ae4>] ath9k_init_device+0x4c4/0x7b0 [ath9k]
[<f92c2813>] ath_pci_probe+0x263/0x330 [ath9k]

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
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>


# 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>


# 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>


# 9976f62e 25-Aug-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: use appropriate debug mask

in the Rx path of the driver it would be better to use ATH_DBG_ANY
rather than ATH_DBG_XMIT for printing debug messages

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 152e585d 19-Aug-2011 Bill Jordan <bjordan@rajant.com>

ath9k: fix MGMT packets when using TKIP

Prevent 8 bytes from being truncated from MGMT packets
when using TKIP.

Signed-off-by: Bill Jordan <bjordan@rajant.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 3de21116 12-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Remove unused argument tsf from ath9k_hw_rxprocdesc

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


# 29ab0b36 12-Aug-2011 Rajkumar Manoharan <rmanohar@qca.qualcomm.com>

ath9k: Re-enable RXOEL interrupt after processing rx buffers

Once RXEOL was disabled, it never be enabled again. This patch
re-enables rxeol at the end of rx tasklet.

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


# 6a6767b0 10-Aug-2011 Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>

ath9k: remove obselete comments

the comments are obselete as the virtual wiphy support was removed from
the driver

Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.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>


# 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>


# 66760eac 13-Jul-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: improve reliability of MIC error detection

For unicast the hardware sometimes reports MIC errors even though the
frame that it received actually contains a valid MIC - on some chips this
can happen frequently enough to trigger TKIP countermeasures.
Fix this issue by not reporting MIC errors for unicast frames with a
valid key, letting mac80211 validate the MIC instead.

Additionally, strip the MIC for all frames that the hardware considers
valid to avoid wasting CPU cycles re-validating it.

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


# e7ef5bc0 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org>

ath9k: add fast_div_bias configuration for diversity group 1

The patch adds the missing configuration code for diversity
group 1.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 223c5a87 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org>

ath9k: remove superfluous parentheses

Also remove two empty lines.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 66ce235a 21-Jun-2011 Gabor Juhos <juhosg@openwrt.org>

ath9k: add a missing case statement to ath_ant_div_comb_alt_check

The 'ar9003_hw_antdiv_comb_conf_get' function sets div_group to 2
however that value is not used in 'ath_ant_div_comb_alt_check'.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b7f080cf 16-Jun-2011 Alexey Dobriyan <adobriyan@gmail.com>

net: remove mm.h inclusion from netdevice.h

Remove linux/mm.h inclusion from netdevice.h -- it's unused (I've checked manually).

To prevent mm.h inclusion via other channels also extract "enum dma_data_direction"
definition into separate header. This tiny piece is what gluing netdevice.h with mm.h
via "netdevice.h => dmaengine.h => dma-mapping.h => scatterlist.h => mm.h".
Removal of mm.h from scatterlist.h was tried and was found not feasible
on most archs, so the link was cutoff earlier.

Hope people are OK with tiny include file.

Note, that mm_types.h is still dragged in, but it is a separate story.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 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>


# 21e8ee6d 13-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: make sure main_rssi is positive

some times the rssi control descriptor for the main antenna may be
negative like that of alternate antenna, hence before incrementing
packet counts/rssi of main/alternate antenna make sure both main_rssi
and alt_rssi are positive only. this avoids wrong selection of antenna
due to diversity

Cc: Gabriel Tseng <Gabriel.Tseng@Atheros.com>
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>


# 3e9a212a 13-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: configure fast_div_bias based on diversity group

configure fast diversity bias based on the antenna diversity group and
based on main/alt LNA configurations. also configure main antenna and
alternate antenna to gain-table 0 for diversity group 2(AR9485)

Cc: Gabriel Tseng <Gabriel.Tseng@Atheros.com>
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>


# b85c5734 13-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Implement an API to swap main/ALT LNA's

for the diversity group 2(AR9485) we swap the LNA's of main/ALT antenna
based on alternate antenna's rssi average in comparision with main
antenna's rssi, while for AR9285(antenna diversity group 0)we still
follow the older method of looking at the packet count in alternate
antenna

Cc: Gabriel Tseng <Gabriel.Tseng@Atheros.com>
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>


# 8afbcc8b 13-May-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k_hw: define antenna diversity group

AR9285 belongs to diversity group 0 and AR9485 belongs to diversity
group 2. Based on the diversity group we configure certain antenna
diversity paramaters such as lna1_lna2_delta and fast diversity
bias values. For AR9485 we have some gain table parameter which
selects the gain table 0/1 for main and alternate antenna

Cc: Gabriel Tseng <Gabriel.Tseng@Atheros.com>
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>


# 2b892a98 09-May-2011 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Fix rssi update in ad-hoc mode

The average beacon rssi which will be used by ani is not updated
in adhoc mode.

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>


# cedc7e3d 22-Apr-2011 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: remove the unlikely check for autosleep

newer chipsets support auto sleep feature, so remove the
unlikely check which does not seems to help anything

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0ff2b5c0 19-Apr-2011 Sujith Manoharan <Sujith.Manoharan@atheros.com>

ath9k: Fix warnings from -Wunused-but-set-variable

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


# 2232d31b 14-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix the return value of ath_stoprecv

The patch 'ath9k_hw: fix stopping rx DMA during resets' added code to detect
a condition where rx DMA was stopped, but the MAC failed to enter the idle
state. This condition requires a hardware reset, however the return value
of ath_stoprecv was 'true' in that case, which allowed it to skip the reset
when issuing a fast channel change.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Paul Stewart <pstew@google.com>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 95294973 07-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix too early enabling of rx during ath_startrecv()

rx should only be enabled after enough rx buffers have been given to the
hardware, however ath_rx_buf_link was calling ath9k_hw_rxena after every
single added buffer.
Fix this by calling ath9k_hw_rxena directly from the rx tasklet after
completion instead.

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


# 264bbec8 07-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: fix PS-Poll reception on AR9160 and earlier

I can't find any valid reason for not setting the ATH9K_RX_FILTER_PSPOLL
flag on older hardware and neither the documentation nor the reference
code mention any reason for excluding older hardware here.

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


# 5882da02 08-Apr-2011 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: fix stopping rx DMA during resets

During PHY errors, the MAC can sometimes fail to enter an idle state on older
hardware (before AR9380) after an rx stop has been requested.

This typically shows up in the kernel log with messages like these:

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:504 ath_stoprecv+0xcc/0xf0 [ath9k]()
Call Trace:
[<8023f0e8>] dump_stack+0x8/0x34
[<80075050>] warn_slowpath_common+0x78/0xa4
[<80075094>] warn_slowpath_null+0x18/0x24
[<80d66d60>] ath_stoprecv+0xcc/0xf0 [ath9k]
[<80d642cc>] ath_set_channel+0xbc/0x270 [ath9k]
[<80d65254>] ath_radio_disable+0x4a4/0x7fc [ath9k]

When this happens, the state that the MAC enters is easy to identify and
does not result in bogus DMA traffic, however to ensure a working state
after a channel change, the hardware should still be reset.

This patch adds detection for this specific MAC state, after which the above
warnings completely disappear in my tests.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
Cc: Kyungwan Nam <Kyungwan.Nam@Atheros.com>
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>


# 2e286947 08-Mar-2011 Felix Fietkau <nbd@openwrt.org>

ath9k: remove support for the FIF_PROMISC_IN_BSS filter flag

The hardware rx filter flag triggered by FIF_PROMISC_IN_BSS is overly broad
and covers even frames with PHY errors. When this flag is enabled, this message
shows up frequently during scanning or hardware resets:

ath: Could not stop RX, we could be confusing the DMA engine when we start RX up

Since promiscuous mode is usually not particularly useful, yet enabled by
default by bridging (either used normally in 4-addr mode, or with hacks
for various virtualization software), we should sacrifice it for better
reliability during normal operation.

This patch leaves it enabled if there are active monitor mode interfaces, since
it's very useful for debugging.

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


# 6ebacbb7 23-Feb-2011 Johannes Berg <johannes.berg@intel.com>

mac80211: rename RX_FLAG_TSFT

The flag isn't very descriptive -- the intention
is that the driver provides a TSF timestamp at
the beginning of the MPDU -- make that clearer
by renaming the flag to RX_FLAG_MACTIME_MPDU.

Signed-off-by: Johannes Berg <johannes.berg@intel.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>


# 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>


# d584747b 20-Dec-2010 Rajkumar Manoharan <rmanoharan@atheros.com>

ath9k: Fix warnings on card removal

The recently added warning message on power change failure
is not needed on device removal.

ath: Failed to wakeup in 500us
------------[ cut here ]------------
WARNING: at drivers/net/wireless/ath/ath9k/hw.c:1618
ath9k_hw_setpower+0x61f/0x630 [ath9k_hw]()
Hardware name: 64756D6
Pid: 540, comm: kworker/u:3 Not tainted 2.6.37-rc6-wl #37
Call Trace:
[<ffffffff810501aa>] warn_slowpath_common+0x7a/0xb0
[<ffffffffa056e280>] ? ath9k_iowrite32+0x0/0x90 [ath9k]
[<ffffffff810501f5>] warn_slowpath_null+0x15/0x20
[<ffffffffa05226ef>] ath9k_hw_setpower+0x61f/0x630 [ath9k_hw]
[<ffffffffa05700e5>] ath9k_ps_wakeup+0x85/0xd0 [ath9k]
[<ffffffffa0570685>] ath9k_configure_filter+0x25/0x80 [ath9k]
[<ffffffffa04dde43>] ieee80211_configure_filter+0x133/0x190 [mac80211]
[<ffffffffa04ee502>] ieee80211_do_stop+0x132/0x540 [mac80211]
[<ffffffff813466ff>] ? _raw_spin_unlock_bh+0x1f/0x30
[<ffffffff812b6923>] ? dev_deactivate+0x1c3/0x1e0
[<ffffffffa04ee925>] ieee80211_stop+0x15/0x20 [mac80211]
[<ffffffff8129d1b6>] __dev_close+0x56/0x90

Signed-off-by: Rajkumar Manoharan <rmanoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cae6b74d 07-Dec-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Remove dead code in recv.c

The structure struct ieee80211_rx_status *rxs is no longer needed to be
passed to ath_rx_send_to_mac80211 function

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# aaef24b4 07-Dec-2010 Mohammed Shafi Shajakhan <mshajakhan@atheros.com>

ath9k: Properly use unlikely check macro

AUTOSLEEP feature is enabled only for AR9271 and AR9003 version
chipsets.So unlikely macro should be used only to check whether
auto-sleep feature is enabled

Signed-off-by: Mohammed Shafi Shajakhan <mshajakhan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d7fd1b50 06-Dec-2010 Ben Greear <greearb@candelatech.com>

ath9k: Make DMA warning in ath_stoprecv WARN_ON_ONCE.

This decreases spammage in the log. A single line message
will still be printed, so users can be aware that problem
exists.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Acked-by: Luis R. Rodriguez <lrodriguez@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>


# 38852b20 06-Dec-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Fix STA disconnect issue due to received MIC failed bcast frames

AR_RxKeyIdxValid will not be set for bcast/mcast frames and so relying
this status for MIC failed frames is buggy.

Due to this, MIC failure events for broadcast frames are not sent to
supplicant resulted in AP disconnecting the STA.

Able to pass Wifi Test case 5.2.18 with this fix.

Cc: Stable <stable@kernel.org> (2.6.36+)
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d89197c7 02-Dec-2010 John W. Linville <linville@tuxdriver.com>

Revert "ath9k: Fix STA disconnect issue due to received MIC failed bcast frames"

This reverts commit 916448e77f6bcaaa7f13c3de0c3851783ae2bfd0.

"As far as I can tell, either of these patches breaks multiple VIF
scenarios. I'm not sure exactly why, but I had to revert this to
get any of my interfaces to associate."
-- Ben Greear <greearb@candelatech.com>

http://marc.info/?l=linux-wireless&m=129123368719339&w=2

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


# 916448e7 30-Nov-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Fix STA disconnect issue due to received MIC failed bcast frames

AR_RxKeyIdxValid will not be set for bcast/mcast frames and so relying
this status for MIC failed frames is buggy.

Due to this, MIC failure events for broadcast frames are not sent to
supplicant resulted in AP disconnecting the STA.

Able to pass Wifi Test case 5.2.18 with this fix.

Cc: Stable <stable@kernel.org> (2.6.36+)
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d47844a0 19-Nov-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix timeout on stopping rx dma

It seems that using ath9k_hw_stoppcurecv to stop rx dma is not enough.
When it's time to stop DMA, the PCU is still busy, so the rx enable
bit never clears.
Using ath9k_hw_abortpcurecv helps with getting rx stopped much faster,
with this change, I cannot reproduce the rx stop related WARN_ON anymore.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org
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>


# 78a7685e 20-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add a debug warning when we cannot stop RX

We have seen several DMA races when we race against
stopping and starting the PCU. I suspect that when
we cannot stop the PCU we may hit some of these same
races so warn against them for now but only when
debugging (CONFIG_ATH_DEBUG) is enabled.

If you run into this warning and are a developer,
please fix the cause of the warning. The potential
here, although I cannot prove yet, is that the DMA
engine can be confused and start writing to a buffer
that was already DMA'd before and at least the kernel
assumes is not being accessed by hardware anymore.

Cc: Ben Greear <greearb@candelatech.com>
Cc: Kyungwan Nam <kyungwan.nam@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
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>


# 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>


# 7583c550 20-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add locking for starting the PCU on RX

There was some locking for starting some parts of
RX but not for starting the PCU. Include this otherwise
we can content against stopping the PCU.

This can potentially lead to races against different
buffers on the PCU which can lead to to the DMA RX
engine writing to buffers which are already freed.

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>


# 1e450285 20-Oct-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: add locking for stopping RX

ath9k locks for starting RX but not for stopping RX. We could
potentially run into a situation where tried to stop RX
but immediately started RX. This allows for races on the
the RX engine deciding what buffer we last left off on
and could potentially cause ath9k to DMA into already
free'd memory or in the worst case at a later time to
already given memory to other drivers.

Fix this by locking stopping RX.

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>


# 6cf9e995 14-Oct-2010 Ben Greear <greearb@candelatech.com>

ath9k: Null out references to stale pointers.

This doesn't fix any problem that I'm aware of, but should
make it harder to add use-after-free type bugs in the
future.

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


# c1739eb3 14-Oct-2010 Ben Greear <greearb@candelatech.com>

ath9k: Remove bf_dmacontext.

The bf_dmacontext seems to be totally useless and duplicated
by bf_buf_addr. Remove it entirely, use bf_buf_addr in its
place.

Signed-off-by: Ben Greear <greearb@candelatech.com>
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>


# 686b9cb9 23-Sep-2010 Ben Greear <greearb@candelatech.com>

mac80211/ath9k: Support AMPDU with multiple VIFs.

The old ieee80211_find_sta_by_hw method didn't properly
find VIFS when there was more than one per AP. This caused
AMPDU logic in ath9k to get the wrong VIF when trying to
account for transmitted SKBs.

This patch changes ieee80211_find_sta_by_hw to take a
localaddr argument to distinguish between VIFs with the
same AP but different local addresses. The method name
is changed to ieee80211_find_sta_by_ifaddr.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# e17f83ea 21-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: simplify revision checks for AR9285

Since AR9285 v1.0 and v1.1 were never sold (and the initvals removed),
its revision checks can be simplified similar to AR9280

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


# 7a37081e 21-Sep-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: simplify revision checks for AR9280

Since AR9280 v1.0 was never sold (and the initvals removed), v1.0 specific
revision checks can be removed and the 'v2.0 or later' check can be
simplified to a check for AR9280 or later.

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


# 3fac6dfd 16-Sep-2010 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: fix regression which prevents chip sleep after CAB data

The patch:

commit 293dc5dfdbcc16cde06e40a688394cc8ab083e48
Author: Gabor Juhos <juhosg@openwrt.org>
Date: Fri Jun 19 12:17:48 2009 +0200

ath9k: remove ath_rx_ps_back_to_sleep helper

This helper only clears the SC_OP_WAIT_FOR_{BEACON,CAB} flags.
Remove it and clear these flags directly in the approptiate
places instead.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

introduced a regression which forgot to lift the beacon flag
after we received all broadcast and multicast data. This meant
we never went to sleep consuming about ~650mW on idle. This pretty
much broke power save completely.

This patch has fixes for stable kernels [2.6.32+].

Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Sameer Nanda <snanda@google.com>
Cc: Gabor Juhos <juhosg@openwrt.org>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
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>


# 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>


# 9bad82b8 15-Sep-2010 John W. Linville <linville@tuxdriver.com>

ath9k: make ath_ant_div_conf_fast_divbias static

CHECK drivers/net/wireless/ath/ath9k/recv.c
drivers/net/wireless/ath/ath9k/recv.c:1341:6: warning: symbol 'ath_ant_div_conf_fast_divbias' was not declared. Should it be static?

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


# cfda6695 14-Sep-2010 Ben Greear <greearb@candelatech.com>

ath9k: calcrxfilter should take multiple VIFs into account.

When there is more than one VIF, listen for all beacons
and ensure ATH9K_RX_FILTER_MCAST_BCAST_ALL is set.

Signed-off-by: Ben Greear <greearb@candelatech.com>
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>


# 102885a5 02-Sep-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Implement an algorithm for Antenna diversity and combining

This algorithm chooses the best main and alt lna out of
LNA1, LNA2, LNA1+LNA2 and LNA1-LNA2 to improve rx for single
chain chips(AR9285). This would greatly improve rx when there
is only one antenna is connected with AR9285.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 56363dde 28-Aug-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix spurious MIC failure reports

According to the hardware documentation, the MIC failure bit is only
valid if the frame was decrypted using a valid TKIP key and is not a
fragment.
In some setups I've seen hardware-reported MIC failures on an AP that
was configured for CCMP only, so it's clear that additional checks are
necessary.

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


# c8f3b721 02-Aug-2010 Jan Friedrich <jft@dev2day.de>

ath9k: fix erased ieee80211_rx_status.mactime

ath9k_rx_skb_preprocess nulls rxs and the mactime is never set again -
mactime is always 0. This causes problems in IBSS mode.

ieee80211_rx_bss_info uses mactime to decide if an IBSS merge is needed.
Without this patch the merge is triggered by each beacon received.

This can be recognized by the "beacon TSF higher than local TSF - IBSS
merge with BSSID" log message accompanying each beacon.

This problem was not completely fixed in commit
a6d2055b02dde1067075795274672720baadd3ca and is not a stable kernel fix.
It is solely intended for wireless-testing.

Signed-off-by: Jan Friedrich <jft@dev2day.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f792af25 14-May-2010 Ming Lei <tom.leiming@gmail.com>

ath9k: fix dma direction for map/unmap in ath_rx_tasklet

For edma, we should use DMA_BIDIRECTIONAL, or else use
DMA_FROM_DEVICE.

This is found to address "BUG at arch/x86/mm/physaddr.c:5"
as described here:

http://lkml.org/lkml/2010/7/14/21

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 96d159d0 11-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k_hw: remove a useless function for setting the mac address

ath9k_hw_setmac() only copies the mac address it is called with into
common->macaddr, yet in all call sites, the supplied mac address pointer
is already common->macaddr.

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


# a6d2055b 11-Jun-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: fix extending the rx timestamp with the hardware TSF

AR5416 and all newer chipsets use a 32 bit rx timestamp, so there
is no need to keep the 15 bit timestamp extending logic around.

This patch removes ath9k_hw_extend_tsf (replaced by a call to
ath9k_hw_gettsf64), and reduces the frequency of TSF reads, which
can improve performance in some cases.

This change also has the side effect of making rx timestamps
more accurate.

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


# 40346b66 11-Jun-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k_hw: inform ANI calibration when scanning

The new ANI implementation will use this to skip ANI
calibration upon a scan. This cannot be ported to the
older ANI implementation unless default ANI values from
the ANI are also used upon a scan. This is essentially
what one of the things thenew ANI does.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ce9426d1 15-May-2010 Ming Lei <tom.leiming@gmail.com>

ath9k: fix dma sync in rx path

If buffer is to be accessed by cpu after dma is over, but
between dma mapping and dma unmapping, we should use
dma_sync_single_for_cpu to sync the buffer between cpu with
device. And dma_sync_single_for_device is used to let
device gain the buffer again.

v2: Felix pointed out dma_sync_single_for_device is needed to return
buffer to device if an unsuccessful status bit check is found.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b7b1b512 20-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix bug in validating received data length for edma

The rx status length should also be taken into account while
validating the length of a received frame.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5c6dd921 20-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix bug in accessing skb->data of rx frame for edma

Skip the rx status portion in skb->data before accessing ieee80211
frame header.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9f167f64 20-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Clean up few function parameters in recv.c

ath9k_rx_skb_preprocess() needs only ieee80211 frame header,
pass only frame headers instead of skb to that function. Also
remove ineffective frame dump in ath9k_process_rate().

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d435700f 20-May-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Move ath9k specific RX code to driver

This patch relocates RX processing code from the
common module to ath9k. This reduces the size
of the common module which is also used by ath9k_htc.

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


# 56824223 14-May-2010 Ming Lei <tom.leiming@gmail.com>

ath9k: fix dma direction for map/unmap in ath_rx_tasklet

For edma, we should use DMA_BIDIRECTIONAL, or else use
DMA_FROM_DEVICE.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# ededf1f8 23-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix rx of mcast/bcast frames in PS mode with auto sleep

The functionality to keep the device awake until it is done with
the rx of any mcast/bcast frames which are pending on AP should
also be added to the hardwares which support auto sleep feature.
This patch fixes frequent failures in ARP resolution when it is
initiated by the other end. Currently auto sleep is enabled only
for ar9003 in ath9k.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b29e7eb4 10-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Remove unused rx_edma in ath_rx_addbuffer_edma()

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 083e3e8d 10-May-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Fix bug in handling rx frames with invalid descriptor content

Don't send them for further processing.

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 4adfcded 15-Apr-2010 Vasanthakumar Thiagarajan <vasanth@atheros.com>

ath9k: Setup appropriate tx desc for regular dma and edma

Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b622a720 15-Apr-2010 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k_hw: move AR9002 mac ops to its own file

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>


# 29bffa96 29-Mar-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: allocate tx and rx status information on stack

ath_tx_status and ath_rx_status data are only necessary for a short
time, until they have been processed and converted into mac80211 data
structures.
Because of that, it makes no sense to keep them tied to the DMA
descriptor, that only wastes precious memory.
This patch allocates the data on stack in the functions that call the
conversion functions from ath9k_hw.

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


# 8e6f5aa2 29-Mar-2010 Felix Fietkau <nbd@openwrt.org>

ath9k: split out access to rx status information

This patch passes in a pointer to the ath_rx_status data structure for
functions that need it, instead of letting them grab it directly from
the ath_desc struct. This is useful for making it possible to allocate
the intermediate rx status data separately.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
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>


# 1395d3f0 07-Jan-2010 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Add debugfs file for RX errors

This file can be used to track frame reception errors.
PHY error counts are also added.

Location: ath9k/phy#/recv

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>


# db86f07e 05-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k_common: add new module to share 802.11n driver helpers

ath9k and ath9k_htc share a lot of common hardware characteristics.
They only differ in that ath9k_htc works with a target CPU and ath9k
works directly with the hardware. ath9k_htc will do *some* things in
the firmware, but a lot of others on the host.

The common 802.11n hardware code is already shared through the ath9k_hw
module. Common helpers amongst all Atheros drivers can use the ath module,
this includes ath5k and ar9170 as users. But there is some common driver
specific helpers which are not exactly hardware code which ath9k and
ath9k_htc can share. We'll be using ath9k_common for this to avoid
bloating the ath module and the common 802.11n hardware module ath9k_hw.

We start by sharing skb pre and post processing in preparation for a hand
off to mac80211.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# c9b14170 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move RX skb post processing to a helper

Use a helper for the RX skb post processing,
ath9k_rx_skb_postprocess().

Signed-off-by: Luis R. Rodriguez <lrodriguez@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>


# 1e875e9f 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: rename ath_rx_prepare() to ath9k_rx_skb_preprocess()

And change the return value to something more obvious.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 2c74aa4d 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move the max rx buffer size check to ath9k_rx_accept()

While at it flip the order, seems easier to read and also
add some better description as to why we do this check.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cc861f74 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath: move the rx bufsize to common to share with ath5k/ath9k

This will also be used by ath9k_htc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 0a45da76 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move the rx_stats->rs_datalen check to ath9k_rx_accept()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 5ca42627 04-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: avoid the copy skb->cb on every RX'd skb

The skb->cb (control buffer, 48 bytes) is available to the skb
upon skb allocation. You can fill it up imediately after skb
allocation. ath9k was copying onto the skb->cb the data from the
processed skb for mac80211 from a stack struct ieee80211_rx_status
structure. This is unnecessary, instead use the skb->cb for the
rx status immediately after the skb becomes available and DMA
synched.

Additionally, avoid the copy of the skb->cb also for virtual wiphys
as skb_copy() will copy over the skb->cb for us as well.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# dbfc22df 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move rssi processing into a helper

This moves all the RX processing of RSSI into a helper,
ath_rx_prepare(). ath_rx_prepare() should now be really
easy to read and follow.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 21b22738 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move qual processing into a helper

This moves the qual computing into a small helper,
ath9k_compute_qual()

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9878841e 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move rate descriptor reading into a helper

ath9k_process_rate() now does all the rx status processing to
read the rate the hardware passed and translate it to whatever
mac80211 wants.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 14077f5b 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: remove temp variable ratecode from ath_rx_prepare()

Its just a distraction when reading the code, instead use the
rx_stats->rs_rate directly.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 207e9685 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: move RX check code into helper ath9k_rx_accept()

This does sanity checking on the skb and RX status descriptor
prior to processing.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 712c13a8 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: use the ieee80211_hw to get to an sband on ath_rx_prepare()

No need to use the private driver structure to get to an sband.
This will make it easier to share this code with ath9k_htc.

With the sc gone we can now just pass the common structure to
ath_rx_prepare().

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>


# 30cbd422 03-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k_hw: move ath_extend_tsf() to hw code to share as ath9k_hw_extend_tsf()

This will be shared between ath9k and ath9k_htc.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 26ab2645 02-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: do not pass the entire descriptor to ath_rx_prepare()

Its not needed, so just pass the hardware RX status.
We'll be simplfying ath_rx_prepare() with code we can share
between ath9k and ath9k_htc. This will help make that code
easier to read and manage.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# cee71d6c 02-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: use the passed ieee80211_hw on ath_rx_prepare()

this now uses the proper hw which should mean finding the
right sta when using ath9k virtual wiphy stuff. Only
advantage I see here is getting the rssi properly updated
so the 'fix' itself isn't that great, but at least this
is correct.

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>


# b4afffc0 02-Nov-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: simpify RX by calling ath_get_virt_hw() once

ath_get_virt_hw() is required on RX to determine for which virtual
wiphy an skb came in for. Instead of searching for the hw twice do
it only once.

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>


# 5ed176e1 04-Nov-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: make ieee80211_find_sta per virtual interface

Since we have a TODO item to make all station
management dependent on virtual interfaces, I
figured I'd start with pushing such a change
to drivers before more drivers start using the
ieee80211_find_sta() API with a hw pointer and
cause us grief later on.

For now continue exporting the old API in form
of ieee80211_find_sta_by_hw(), but discourage
its use strongly.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 66afad01 18-Sep-2009 Senthil Balasubramanian <senthilkumar@atheros.com>

ath9k: Allow PSPOLL only when the interface is configured in AP mode

Signed-off-by: Senthil Balasubramanian <senthilkumar@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>


# 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>


# 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>


# 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>


# 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>


# 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>


# 5eb6ba83 20-Aug-2009 Javier Cardona <javier@cozybit.com>

ath9k: Add support FIF_OTHER_BSS filtering mode.

Support for FIF_OTHER_BSS was missing. This patch adds support for this
filtering mode which in turn resolves a problem where mesh interfaces would not
receive broadcast traffic.

Signed-off-by: Javier Cardona <javier@cozybit.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>


# 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>


# 5e32b1ed 06-Aug-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Update beacon RSSI

ANI uses the beacon RSSI for its operation.
Update this properly.

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


# 87b5bee8 06-Aug-2009 Sujith <Sujith.Manoharan@atheros.com>

ath9k: Remove unneeded assignment of protocol field

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


# 63b08b8d 04-Aug-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: use new FIF_PSPOLL configure filter

We used to set pspoll filter on ath9k on AP mode but
we no longer need this mode specific check as mac80211
now does the check for us and informs us when we should
enable pspoll through FIF_PSPOLL.

Cc: Igor Perminov <igor.perminov@inbox.ru>
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>


# 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>


# 7d5ca3b8 19-Jun-2009 Luis R. Rodriguez <lrodriguez@atheros.com>

ath9k: differentiate quality reporting between legacy and HT configurations

We were not differentiating quality between legacy and HT
configurations. We change this to consider the differences.

New theory for reporting quality:

At a hardware RSSI of 45 you will be able to use MCS 7 reliably.
At a hardware RSSI of 45 you will be able to use MCS 15 reliably.
At a hardware RSSI of 35 you should be able use 54 Mbps reliably.

MCS 7 is the highets MCS index usable by a 1-stream device.
MCS 15 is the highest MCS index usable by a 2-stream device.

All ath9k devices are either 1-stream or 2-stream.

How many bars you see is derived from the qual reporting.

A more elaborate scheme can be used here but it requires tables
of SNR/throughput for each possible mode used. For the MCS table
you can refer to the wireless wiki:

http://wireless.kernel.org/en/developers/Documentation/ieee80211/802.11n

This should fix this bug report:

http://bugzilla.kernel.org/show_bug.cgi?id=13537

Cc: Janath.Peiris@atheros.com
Cc: Matt.Smith@atheros.com
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 293dc5df 18-Jun-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: remove ath_rx_ps_back_to_sleep helper

This helper only clears the SC_OP_WAIT_FOR_{BEACON,CAB} flags.
Remove it and clear these flags directly in the approptiate
places instead.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# b7351a00 18-Jun-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: remove unnecessary clearing of SC_OP_WAIT_{BEACON,CAB} flags

All SC_OP_WAIT_* flags will be cleared in 'ath9k_conf' when PS mode
is disabled, so we don't have to clear it here.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f1d58c25 17-Jun-2009 Johannes Berg <johannes@sipsolutions.net>

mac80211: push rx status into skb->cb

Within mac80211, we often need to copy the rx status into
skb->cb. This is wasteful, as drivers could be building it
in there to start with. This patch changes the API so that
drivers are expected to pass the RX status in skb->cb, now
accessible as IEEE80211_SKB_RXCB(skb). It also updates all
drivers to pass the rx status in there, but only by making
them memcpy() it into place before the call to the receive
function (ieee80211_rx(_irqsafe)). Each driver can now be
optimised on its own schedule.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 58f5fffd 17-Jun-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: wait for beacon frame along with CAB

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# f0e9a860 15-Jun-2009 Gabor Juhos <juhosg@openwrt.org>

ath9k: process rx packet if we are waiting for CAB

If we are in PS mode, we have to process the received frame if
the SC_OP_WAIT_FOR_CAB bit is set.

Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
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>


# 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>


# cc65965c 14-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Fix PS mode operation to receive buffered broadcast/multicast frames

The previous implementation was moving back to NETWORK SLEEP state
immediately after receiving a Beacon frame. This means that we are
unlikely to receive all the buffered broadcast/multicast frames that
would be sent after DTIM Beacon frames. Fix this by parsing the Beacon
frame and remaining awake, if needed, to receive the buffered
broadcast/multicast frames. The last buffered frame will trigger the
move back into NETWORK SLEEP state.

If the last broadcast/multicast frame is not received properly (or if
the AP fails to send it), the next Beacon frame will work as a backup
trigger for returning into NETWORK SLEEP.

A new debug type, PS (debug=0x800 module parameter), is added to make
it easier to debug potential power save issues in the
future. Currently, this is only used for the Beacon frame and buffered
broadcast/multicast receiving.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 9d64a3cf 14-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Clean up RX processing a bit

This makes use of the local fc variable in bit more places and uses a
common helper macro. The part of RX process that delivers skb's to
mac80211 is moved to a separate function in preparation for future
changes that will need to do this from two places. The modifications
here should not result in any functional changes.

Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# d8959fbf 14-May-2009 Jouni Malinen <jouni.malinen@atheros.com>

ath9k: Fix a check for multicast address for virtual wiphy

The broadcast bit is in the first, not the last octet..

Signed-off-by: Jouni Malinen <jouni.malinen@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>