]> Pileus Git - ~andy/linux/log
~andy/linux
10 years agoath9k: Apply CUS227 specific TX gain values
Sujith Manoharan [Tue, 5 Nov 2013 00:24:59 +0000 (05:54 +0530)]
ath9k: Apply CUS227 specific TX gain values

CUS227, which is an AR9340 based card used in Qualcomm's
Allplay platforms requires a custom TX gain array, based
on the index 7. Add suport for this.

Cc: Michael Larson <mlarson@qce.qualcomm.com>
Cc: Stephen Collmeyer <scollmey@qce.qualcomm.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Remove pcieSerDesWrite
Sujith Manoharan [Tue, 29 Oct 2013 06:22:06 +0000 (11:52 +0530)]
ath9k: Remove pcieSerDesWrite

This HW config option is always set to true and is not needed.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Remove unused AR9462 2.0 initvals
Sujith Manoharan [Tue, 29 Oct 2013 06:10:06 +0000 (11:40 +0530)]
ath9k: Remove unused AR9462 2.0 initvals

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Add SERDES initvals for AR9462 2.1
Sujith Manoharan [Tue, 29 Oct 2013 06:05:31 +0000 (11:35 +0530)]
ath9k: Add SERDES initvals for AR9462 2.1

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Add an initialization routine for WoW
Sujith Manoharan [Mon, 28 Oct 2013 07:31:28 +0000 (13:01 +0530)]
ath9k: Add an initialization routine for WoW

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Use CONFIG_ATH9K_WOW
Sujith Manoharan [Mon, 28 Oct 2013 06:52:04 +0000 (12:22 +0530)]
ath9k: Use CONFIG_ATH9K_WOW

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

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Add a config option for WoW
Sujith Manoharan [Mon, 28 Oct 2013 06:03:19 +0000 (11:33 +0530)]
ath9k: Add a config option for WoW

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Fix wow.c compilation
Sujith Manoharan [Mon, 28 Oct 2013 06:17:43 +0000 (11:47 +0530)]
ath9k: Fix wow.c compilation

The HW routines to set various WoW registers are present
in wow.c. For some reason, it has been compiled as part
of the main ath9k.ko module all this time, when it should
really be part of ath9k_hw.ko. This patch renames the file to
ar9003_wow.ko and adds it to ath9k_hw.ko.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Fix TX99 config option usage
Sujith Manoharan [Thu, 24 Oct 2013 06:34:39 +0000 (12:04 +0530)]
ath9k: Fix TX99 config option usage

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

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

Cc: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Identify Killer Wireless cards
Sujith Manoharan [Wed, 23 Oct 2013 08:56:04 +0000 (14:26 +0530)]
ath9k: Identify Killer Wireless cards

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Add WB335 PCI IDs
Sujith Manoharan [Wed, 23 Oct 2013 08:23:28 +0000 (13:53 +0530)]
ath9k: Add WB335 PCI IDs

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoMerge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
John W. Linville [Mon, 2 Dec 2013 18:20:03 +0000 (13:20 -0500)]
Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211

10 years agobrcmfmac: fix uninitialized warning
Arend van Spriel [Fri, 29 Nov 2013 22:00:31 +0000 (23:00 +0100)]
brcmfmac: fix uninitialized warning

Building brcmfmac for sparc64 gave the following warning:

  CC [M]  drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.o
    bcmsdh_sdmmc.c: In function 'brcmf_sdioh_request_byte':
     bcmsdh_sdmmc.c:89:6: warning: 'err_ret' may be used uninitialized
                          in this function [-Wuninitialized]

Inspecting the code it indeed had a path of execution in
which the return value was used uninitialized. This patch
fixes that code path.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Franky Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agonet: wireless: wcn36xx: fix potential NULL pointer dereference
Michal Nazarewicz [Mon, 2 Dec 2013 13:09:34 +0000 (14:09 +0100)]
net: wireless: wcn36xx: fix potential NULL pointer dereference

If kmalloc fails wcn36xx_smd_rsp_process will attempt to dereference
a NULL pointer.  There might be a better error recovery then just
printing an error, but printing an error message is better then the
current behaviour.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agonet: wireless: ath9k: avoid possible NULL pointer dereference
Michal Nazarewicz [Fri, 29 Nov 2013 17:06:46 +0000 (18:06 +0100)]
net: wireless: ath9k: avoid possible NULL pointer dereference

Code in ath9k_hw_set_clockrate function indicates that ah->curchan
(and thus chan local variable) may be NULL.  If that is indeed the
case, IS_CHAN_HT40(chan) check has to be performed only in branch
where chan is not NULL.  Moving the code under already existing
if condition fixes this issue.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Fix XLNA bias strength
Sujith Manoharan [Tue, 26 Nov 2013 01:51:39 +0000 (07:21 +0530)]
ath9k: Fix XLNA bias strength

The EEPROM parameter to determine whether the bias
strength values for XLNA have to be applied is part
of the miscConfiguration field and not featureEnable.

Cc: stable@vger.kernel.org
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoath9k: Fix QuickDrop usage
Sujith Manoharan [Tue, 26 Nov 2013 01:51:08 +0000 (07:21 +0530)]
ath9k: Fix QuickDrop usage

Bit 5 in the miscConfiguration field of the base EEPROM
header denotes whether QuickDrop is enabled or not. Fix
the incorrect usage of BIT(1) and also make sure that
this is done only for the required chips.

Cc: stable@vger.kernel.org
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agoMerge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwif...
John W. Linville [Mon, 2 Dec 2013 17:57:23 +0000 (12:57 -0500)]
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes

10 years agoath10k: fix multi BSSID with WPA on FW 10.1
Michal Kazior [Mon, 2 Dec 2013 08:06:36 +0000 (09:06 +0100)]
ath10k: fix multi BSSID with WPA on FW 10.1

FW 10.1 seems to require the default key index to
be updated to point to group key after it is
installed. Otherwise Txed frames are corrupted.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agomac80211: fix rx_nss calculation for drivers with hw rc
Michal Kazior [Mon, 2 Dec 2013 10:54:07 +0000 (11:54 +0100)]
mac80211: fix rx_nss calculation for drivers with hw rc

Drivers with hardware rate control were given
sta->rx_nss set to 0. This was because rx_nss
calculation procedure was protected by hw/sw rate
control check.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: check csa wiphy flag in ibss before switching
Simon Wunderlich [Tue, 26 Nov 2013 15:45:18 +0000 (16:45 +0100)]
mac80211: check csa wiphy flag in ibss before switching

When external CSA IEs are received (beacons or action messages), a
channel switch is triggered as well. This should only be allowed on
devices which actually support channel switches, otherwise disconnect.
(For the corresponding userspace invocation, the wiphy flag is checked
in nl80211).

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: disable CSA for all drivers
Simon Wunderlich [Tue, 26 Nov 2013 15:07:26 +0000 (16:07 +0100)]
cfg80211: disable CSA for all drivers

The channel switch announcement code has some major locking problems
which can cause a deadlock in worst case. A series of fixes has been
proposed, but these are non-trivial and need to be tested first.
Therefore disable CSA completely for 3.13.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: don't leak next beacon when csa is aborted
Simon Wunderlich [Thu, 21 Nov 2013 17:19:53 +0000 (18:19 +0100)]
mac80211: don't leak next beacon when csa is aborted

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: don't cancel csa finalize work within stop_ap
Simon Wunderlich [Thu, 21 Nov 2013 17:19:52 +0000 (18:19 +0100)]
mac80211: don't cancel csa finalize work within stop_ap

The current channel switch code has a potential deadlock:
1) * cfg80211_stop_ap acquires wdev-lock
   * ieee80211_stop_ap calls cancel_work_sync for the csa_finalize_work,
     which acquires the associated worker-lock
2) * ieee80211_csa_finalize_work holds the worker-lock when run
   * it calls cfg80211_ch_switch_notify which will claim the wdev-lock,
     and also needs to claim the sdata-lock (which is the same as the
     wdev-lock) to modify the beacons.

It is sufficient to just set the channel switch active to false. If the
worker is running later, it will find the channel switch to not be
active anymore and returns immediately without changing anything.

Canceling the worker is done anyway when the interface goes down
(ieee80211_do_stop).

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211/mac80211/ath6kl: acquire wdev lock outside ch_switch_notify
Simon Wunderlich [Thu, 21 Nov 2013 17:19:51 +0000 (18:19 +0100)]
cfg80211/mac80211/ath6kl: acquire wdev lock outside ch_switch_notify

The channel switch notification should be sent under the
wdev/sdata-lock, preferably in the same moment as the channel change
happens, to avoid races by other callers (e.g. start/stop_ap).
This also adds the previously missing sdata_lock protection in
csa_finalize_work.

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: modify beacon using sdata/wdev-lock, not rtnl lock
Simon Wunderlich [Thu, 21 Nov 2013 17:19:50 +0000 (18:19 +0100)]
mac80211: modify beacon using sdata/wdev-lock, not rtnl lock

The csa finalize worker needs to change the beacon information (for
different modes). These are normally protected under rtnl lock, but the
csa finalize worker is called by drivers and should not acquire the RTNL
lock. Therefore change access protection for beacons to sdata/wdev lock.

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
[fix sdata_dereference]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: protect beacon changing functions with wdev-lock
Simon Wunderlich [Thu, 21 Nov 2013 17:19:49 +0000 (18:19 +0100)]
cfg80211: protect beacon changing functions with wdev-lock

To avoid race conditions in functions which modify the beacon
information, lock these using the wdev lock. This is especially required
to avoid problems for csa handling functions which modify beacons but
can not be called under rtnl lock.

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: mesh: only get tsf if we need it
Bob Copeland [Mon, 18 Nov 2013 22:25:28 +0000 (17:25 -0500)]
mac80211: mesh: only get tsf if we need it

The local TSF timer is used to compute the timing offset between
mesh peers on beacon reception.  However, asking the device for
the TSF is not very accurate, so we prefer to use rx->mactime
if available.  In the latter case, calling drv_get_tsf() just
adds more delay into the RX path, so skip it if we can.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: aggregate mgmt_tx parameters into a struct
Andrei Otcheretianski [Mon, 18 Nov 2013 17:06:49 +0000 (19:06 +0200)]
cfg80211: aggregate mgmt_tx parameters into a struct

Change cfg80211 and mac80211 to use cfg80211_mgmt_tx_params
struct to aggregate parameters for mgmt_tx functions.
This makes the functions' signatures less clumsy and allows
less painful parameters extension.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
[fix all other drivers]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: update ht flag if bss configuration changed
Avri Altman [Mon, 18 Nov 2013 17:06:48 +0000 (19:06 +0200)]
mac80211: update ht flag if bss configuration changed

There's a bug in tracking HT opmode changes in mac80211, it
fails to update the driver when the channel parameters don't
change.

Move the code to do the HT opmode checking independently of
the channel/bandwidth tracking.

Signed-off-by: Avri Altman <avri.altman@intel.com>
[edit commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: remove sta_info_flush() from interface teardown
Johannes Berg [Mon, 18 Nov 2013 17:06:47 +0000 (19:06 +0200)]
mac80211: remove sta_info_flush() from interface teardown

All interface types now properly clean up their stations
using some form of sta_info_flush() themselves, so there's
no need to try it again at teardown. Remove the call to
get rid of the extra delay from the synchronize_net() and
rcu_barrier() calls.

Reported-by: Moshe Benji <moshe.benji@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: Tx frame latency statistics
Matti Gottlieb [Mon, 18 Nov 2013 17:06:45 +0000 (19:06 +0200)]
mac80211: Tx frame latency statistics

Measure TX latency and jitter statistics per station per TID.
These Measurements are disabled by default and can be enabled
via debugfs.

Features included for each station's TID:

1. Keep count of the maximum and average latency of Tx frames.
2. Keep track of many frames arrived in a specific time range
   (need to enable through debugfs and configure the bins ranges)

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211_hwsim: use CLOCK_MONOTONIC_RAW
Johannes Berg [Mon, 18 Nov 2013 16:23:26 +0000 (17:23 +0100)]
mac80211_hwsim: use CLOCK_MONOTONIC_RAW

The beacon timers really shouldn't use any clock that is
subject to adjustments from userspace, particularly not
CLOCK_REALTIME. Use CLOCK_MONOTONIC_RAW instead.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: fix reporting 5/10 MHz support to user space
Felix Fietkau [Sat, 9 Nov 2013 13:57:54 +0000 (14:57 +0100)]
cfg80211: fix reporting 5/10 MHz support to user space

nla_put_flag needs a real nl80211 attribute id, not a wiphy flag bit.
While at it, split 5 and 10 MHz capability flags in case we ever need
to support hardware that can only do one of the two.

Also move the flag settings to the split-only information so we don't
increase the space needed for old userspace.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
[change location of flag setting]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agoath10k: fix Tx status clearing
Michal Kazior [Tue, 26 Nov 2013 13:57:40 +0000 (14:57 +0100)]
ath10k: fix Tx status clearing

Too much of tx info was being cleared. This caused
issues in some setups with tx frame status
reporting.

This should fix some cases of stations not being
able to associate to ath10k AP.

Reported-By: Matti Laakso <malaakso@elisanet.fi>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: allow explicit MSI/MSI-X disabling
Michal Kazior [Mon, 25 Nov 2013 13:06:27 +0000 (14:06 +0100)]
ath10k: allow explicit MSI/MSI-X disabling

This can be useful for testing and debugging.

This introduces new ath10k_pci module parameter
`irq_mode`. By default it is 0, meaning automatic
irq mode (MSI-X as long as both target HW and host
platform supports it). The parameter works on a
best effort basis.

kvalo: fix typo "ayto"

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: re-add support for early fw indication
Michal Kazior [Mon, 25 Nov 2013 13:06:26 +0000 (14:06 +0100)]
ath10k: re-add support for early fw indication

It's possible for FW to panic during early boot.

The patch re-introduces support to detect and
print those crashes.

This introduces an additional irq handler that is
set for the duration of early boot and shutdown.
The handler is then overriden with regular
handlers upon hif start().

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: extract functions for legacy irq handling
Michal Kazior [Mon, 25 Nov 2013 13:06:25 +0000 (14:06 +0100)]
ath10k: extract functions for legacy irq handling

Preparation for code re-use. Also use ioread/write
wrappers.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: defer irq registration until hif start()
Michal Kazior [Mon, 25 Nov 2013 13:06:24 +0000 (14:06 +0100)]
ath10k: defer irq registration until hif start()

It's impossible to rely on disable_irq() and/or CE
interrupt masking with legacy shared interrupts.
Other devices sharing the same irq line may assert
it while ath10k is doing something that requires
no interrupts.

Irq handlers are now registered after all
preparations are complete so spurious/foreign
interrupts won't do any harm. The handlers are
unregistered when no interrupts are required (i.e.
during driver teardown).

This also removes the ability to receive FW early
indication (since interrupts are not registered
until early boot is complete). This is not mission
critical (it's more of a hint that early boot
failed due to unexpected FW crash) and will be
re-added in a follow up patch.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: decouple ath10k_pci_start_ce()
Michal Kazior [Mon, 25 Nov 2013 13:06:23 +0000 (14:06 +0100)]
ath10k: decouple ath10k_pci_start_ce()

The function did a couple of things: it allocated
CE completions, registered CE callbacks and
enabled CE interrupts through HW registers.

This cannot be so. Split the function into one
that allocates CE completions and the other one
that starts off CE operation.

This is required for future legacy shared
interrupt handling.

This also fixes possible memory leak if post rx
failed.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: don't use interrupts for BMI
Michal Kazior [Mon, 25 Nov 2013 13:06:22 +0000 (14:06 +0100)]
ath10k: don't use interrupts for BMI

It's not really necessary for interrupts to be
used for BMI. BMI already assumes there's only one
caller at a time and it works directly with CE.

Make BMI poll for CE completions instead of
waiting for interrupts. This makes disabling
interrupts during early boot possible.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: split up pci irq code
Michal Kazior [Mon, 25 Nov 2013 13:06:21 +0000 (14:06 +0100)]
ath10k: split up pci irq code

Hardware waits until host signals whether it has
chosen MSI(-X) or shared legacy interrupts. It is
not required for the driver to register interrupt
handlers immediately.

This patch prepares the pci irq code for more
changes.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoath10k: don't consume other's shared interrupts
Michal Kazior [Mon, 25 Nov 2013 13:06:20 +0000 (14:06 +0100)]
ath10k: don't consume other's shared interrupts

ath10k assumed all interrupts were directed to it.
This isn't the case for legacy shared interrupts.
ath10k consumed interrupts for other devices.

Check device irq status and return IRQ_NONE when
appropriate.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 years agoiwlwifi: mvm: use a cast to calculate the last seqno from the next one
Luciano Coelho [Tue, 19 Nov 2013 14:05:56 +0000 (16:05 +0200)]
iwlwifi: mvm: use a cast to calculate the last seqno from the next one

If the next seqno returned by the firmware is 0, we return an error
(-16) in the iwl_mvm_get_last_nonqos_seq() function.  This is because
we return an integer and don't use any casting when calculating the
last seqno from the one we received.  Fix this by using a cast to u16
when doing the calculation, so we return 0xfff0, as we should.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: mvm: set seqno also when no keys are set
Luciano Coelho [Tue, 19 Nov 2013 13:38:55 +0000 (15:38 +0200)]
iwlwifi: mvm: set seqno also when no keys are set

In an open BSS, after suspend/resume, we don't set the last seqno
because the iwl_mvm_setup_connection_keep() returns too early.  This
happens because the check to see if we have any keys was returning
immediately, without setting seqno and seqno_valid.  Fix this.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: pcie: stop sending commands to dead firmware
Alexander Bondar [Tue, 5 Nov 2013 15:35:14 +0000 (17:35 +0200)]
iwlwifi: pcie: stop sending commands to dead firmware

If we call ieee80211_hw_restart, it means that the
firmware is in bad condition and will be reset soon.
Since the firmware will be reset, there is no good
reason to keep sending host commands.

Signed-off-by: Alexander Bondar <alexander.bondar@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: bump required firmware API version for 3160/7260
Emmanuel Grumbach [Tue, 19 Nov 2013 20:23:13 +0000 (22:23 +0200)]
iwlwifi: bump required firmware API version for 3160/7260

A new firmware is coming out soon with new APIs.
To make sure that this new firmware won't be loaded on old
driver that don't support it, it's API version has been
updated to 8. In order to be able to load it, bump the API
version to 8.
API version 7 is still supported and will be for another
year or so.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: mvm: don't WARN about unsuccessful time event
Emmanuel Grumbach [Tue, 5 Nov 2013 14:27:59 +0000 (16:27 +0200)]
iwlwifi: mvm: don't WARN about unsuccessful time event

Time event notification can have a failure status even if
the time event was scheduled:
* in START notification, this can happen if the time event
  was scheduled later than the requested apply time.
* in STOP notification, this can happen if the time event
  is truncated.

Even if both happened, the offchannel packets sent during
the remain on channel are very likely to have been sent.
Hence, don't WARN when this happens, but rather print a
discrete line in the kernel log.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
10 years agoiwlwifi: mvm: BT Coex fix another NULL pointer dereference
Emmanuel Grumbach [Mon, 21 Oct 2013 08:03:53 +0000 (11:03 +0300)]
iwlwifi: mvm: BT Coex fix another NULL pointer dereference

This patch is very similar to a previous fix: 22cba0c0852f

When we disassociate, mac80211 removes the station and
then, it sets the bss it unsets the assoc bool in bss_info.

Since the firwmware wants it the opposite (first set the
MAC context as unassoc, and only then, remove the STA of
the API), we have a small period of time in which the STA
in firmware doesn't have a valid ieee80211_sta pointer.
During that time, iwl_mvm_vif->ap_sta_id, is still set
to the STA in firmware that represent the AP.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: mvm: BT Coex - don't enable MULTI_PRIO_LUT
Emmanuel Grumbach [Wed, 13 Nov 2013 12:57:36 +0000 (14:57 +0200)]
iwlwifi: mvm: BT Coex - don't enable MULTI_PRIO_LUT

This feature isn't supported by the firmware (yet).
Note that settingt he values to BT_CFG_CMD is harmless if
the validity bit is clear - so keep the configuration
values in BT_CFG_CMD, but clear the validity bit until thes
feature is enabled in the firmware.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: add new HW - 7265 series
Oren Givon [Tue, 19 Nov 2013 01:48:19 +0000 (03:48 +0200)]
iwlwifi: add new HW - 7265 series

Add new HW IDs and configurations for 7265 series.

Signed-off-by: Oren Givon <oren.givon@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: pcie: fix interrupt coalescing for 7260 / 3160
Emmanuel Grumbach [Mon, 11 Nov 2013 13:23:01 +0000 (15:23 +0200)]
iwlwifi: pcie: fix interrupt coalescing for 7260 / 3160

We changed the timeout for the interrupt coealescing for
calibration, but that wasn't effective since we changed
that value back before loading the firmware. Since
calibrations are notification from firmware and not Rx
packets, this doesn't change anyway - the firmware will
fire an interrupt straight away regardless of the interrupt
coalescing value.
Also, a HW issue has been discovered in 7000 devices series.
The work around is to disable the new interrupt coalescing
timeout feature - do this by setting bit 31 in
CSR_INT_COALESCING.
This has been fixed in 7265 which means that we can't rely
on the device family and must have a hint in the iwl_cfg
structure.

Cc: stable@vger.kernel.org [3.10+]
Fixes: 99cd47142399 ("iwlwifi: add 7000 series device configuration")
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoiwlwifi: mvm: check sta_id/drain values in debugfs
Johannes Berg [Fri, 25 Oct 2013 11:06:06 +0000 (13:06 +0200)]
iwlwifi: mvm: check sta_id/drain values in debugfs

The station ID must be valid, if it's out of range then
the array access may crash. Validate the station ID to
the array length, and also validate the drain value even
if that doesn't matter all that much.

Cc: stable@vger.kernel.org
Fixes: 8ca151b568b6 ("iwlwifi: add the MVM driver")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
10 years agoMerge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
John W. Linville [Mon, 25 Nov 2013 20:47:18 +0000 (15:47 -0500)]
Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211

10 years agomwifiex: fix memory leak issue for ibss join
Ujjal Roy [Thu, 21 Nov 2013 19:08:56 +0000 (11:08 -0800)]
mwifiex: fix memory leak issue for ibss join

For IBSS join if the requested SSID matches current SSID,
it returns without freeing the allocated beacon IE buffer.

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Ujjal Roy <royujjal@gmail.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agobrcmsmac: Fix build dep on LEDS_CLASS
Borislav Petkov [Tue, 19 Nov 2013 10:36:42 +0000 (11:36 +0100)]
brcmsmac: Fix build dep on LEDS_CLASS

When building randconfigs with CONFIG_BCMA_DRIVER_GPIO=y, I get

drivers/built-in.o: In function `brcms_led_unregister':
(.text+0x351aca): undefined reference to `led_classdev_unregister'
drivers/built-in.o: In function `brcms_led_register':
(.text+0x351c65): undefined reference to `led_classdev_register'

during final linking stage because brcmsmac/led.c needs LEDS_CLASS for
registering/deregistering the led device. Select the required symbols.

Cc: Arend van Spriel <arend@broadcom.com>
Cc: "Rafał Miłecki" <zajec5@gmail.com>
Cc: <linux-wireless@vger.kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10 years agomac80211: minstrel_ht: do not sample unsupported rates
Karl Beldan [Mon, 11 Nov 2013 12:10:49 +0000 (13:10 +0100)]
mac80211: minstrel_ht: do not sample unsupported rates

ATM minstrel_ht does not check whether a sampling rate is supported.
Unsupported rates attempts can trigger when there are holes in bitfields
of supported MCSes belonging to the same group (e.g many devices are
MCS32 capable without MCS33->39 capable, also we systematically have a
hole for CCK rates).
Drop any attempts to sample unsupported rates, as suggested by Felix.

This is not a problem in minstrel which fills a per STA sample table
with only supported rates (though only at init).

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: replace print_dfs_region() with reg_dfs_region_str() helper
Luis R. Rodriguez [Wed, 13 Nov 2013 17:54:05 +0000 (18:54 +0100)]
cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper

This lets us later reuse the more generic reg_dfs_region_str().

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: distinguish unset DFS region from unknown
Luis R. Rodriguez [Wed, 13 Nov 2013 17:54:04 +0000 (18:54 +0100)]
cfg80211: distinguish unset DFS region from unknown

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: intersection dfs regions when intersecting regdomains
Luis R. Rodriguez [Wed, 13 Nov 2013 17:54:03 +0000 (18:54 +0100)]
cfg80211: intersection dfs regions when intersecting regdomains

Only allow DFS to be set if the DFS regions agree.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: use enum nl80211_dfs_regions for dfs_region everywhere
Luis R. Rodriguez [Wed, 13 Nov 2013 17:54:02 +0000 (18:54 +0100)]
cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere

u8 was used in some other places, just stick to the enum,
this forces us to express the values that are expected.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: minstrels: spare numerous useless calls to get_random_bytes
Karl Beldan [Wed, 13 Nov 2013 09:54:19 +0000 (10:54 +0100)]
mac80211: minstrels: spare numerous useless calls to get_random_bytes

ATM, only the first array value returned by get_random_bytes is used.
This change moves the call to get_random_bytes from the nested loop it
is in to its parent.
While at it, replace get_random_bytes with prandom_bytes since PRNs are
way enough for the selection process.
After this, minstrel_ht reclaims 80 PR-bytes instead of 640 R-bytes.

minstrels use sample tables to probe different rates in a randomized
manner.
minstrel_ht inits one single sample table upon registration (during
subsys_initcalls) and minstrel uses one per STA addition in minstrel.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: minstrel_ht: replace some occurences of MCS_GROUP_RATES
Karl Beldan [Mon, 11 Nov 2013 12:12:55 +0000 (13:12 +0100)]
mac80211: minstrel_ht: replace some occurences of MCS_GROUP_RATES

Consecutive MCSes in [8*(NSS-1)->8*NSS[ have the same number NSS of
streams (except for MCS32 which is mishandled ATM).
ATM minstrel_ht uses MCS_GROUP_RATES in place of this 8 modulus.
This change replaces such occurences and by doing so allows for different
values of MCS_GROUP_RATES (e.g to cope with VHT MCS8,9).

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: add min required channel definition field
Eliad Peller [Mon, 11 Nov 2013 18:14:01 +0000 (20:14 +0200)]
mac80211: add min required channel definition field

Add a new field to ieee80211_chanctx_conf to indicate
the min required channel configuration.

Tuning to a narrower channel might help reducing
the noise level and saving some power.

The min required channel definition is the max of
all min required channel definitions of the interfaces
bound to this channel context.

In AP mode, use 20MHz when there are no connected station.
When a new station is added/removed, calculate the new max
bandwidth supported by any of the stations (e.g. 80MHz when
80MHz and 40MHz stations are connected).

In other cases, simply use bss_conf.chandef as the
min required chandef.

Notify drivers about changes to this field by calling
drv_change_chanctx with a new CHANGE_MIN_WIDTH notification.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: enable easier manipulation of VHT beamforming caps
Eyal Shapira [Mon, 11 Nov 2013 18:14:00 +0000 (20:14 +0200)]
mac80211: enable easier manipulation of VHT beamforming caps

Introduce shift and mask defines for beamformee STS cap and number
of sounding dimensions cap as these can take any 3 bit value.
While at it also cleanup an unrequired parenthesis.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: move csa_chandef to sdata
Luciano Coelho [Mon, 11 Nov 2013 18:34:54 +0000 (20:34 +0200)]
mac80211: move csa_chandef to sdata

There is no reason why we should have only one channel switch
announcement at a time for a single phy.  When support for channel
switch with multiple contexts and multiple vifs per context is
implemented, we will need the chandef data for each vif.  Move the
csa_chandef structure to sdata to prepare for this.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
[Fixed compilation with mesh]
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: use put_unaligned_le in mesh when necessary
Chun-Yeow Yeoh [Wed, 13 Nov 2013 07:39:12 +0000 (15:39 +0800)]
mac80211: use put_unaligned_le in mesh when necessary

Use put_unaligned_le16 and put_unaligned_le32 for
mesh_path_error_tx and mesh_path_sel_frame_tx.

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: use put_unaligned_le16 in mesh_plink_frame_tx
Chun-Yeow Yeoh [Wed, 13 Nov 2013 07:43:03 +0000 (15:43 +0800)]
mac80211: use put_unaligned_le16 in mesh_plink_frame_tx

Use put_unaligned_le16 in mesh_plink_frame_tx.

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add an option to disable processing country IEs
Luis R. Rodriguez [Mon, 11 Nov 2013 21:15:31 +0000 (22:15 +0100)]
cfg80211: add an option to disable processing country IEs

Certain vendors may want to disable the processing of
country IEs so that they can continue using the regulatory
domain the driver or user has set.  Currently there is no
way to stop the core from processing country IEs, so add
support to the core to ignore country IE hints.

Cc: Mihir Shete <smihir@qti.qualcomm.com>
Cc: Henri Bahini <hbahini@qca.qualcomm.com>
Cc: Tushnim Bhattacharyya <tushnimb@qca.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add flags to define country IE processing rules
Luis R. Rodriguez [Mon, 11 Nov 2013 21:15:30 +0000 (22:15 +0100)]
cfg80211: add flags to define country IE processing rules

802.11 cards may have different country IE parsing behavioural
preferences and vendors may want to support these. These preferences
were managed by the REGULATORY_CUSTOM_REG and the REGULATORY_STRICT_REG
flags and their combination. Instead of using this existing notation,
split out the country IE behavioural preferences as a new flag. This
will allow us to add more customizations easily and make the code more
maintainable.

Cc: Mihir Shete <smihir@qti.qualcomm.com>
Cc: Henri Bahini <hbahini@qca.qualcomm.com>
Cc: Tushnim Bhattacharyya <tushnimb@qca.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
[fix up conflicts]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: move regulatory flags to their own variable
Luis R. Rodriguez [Mon, 11 Nov 2013 21:15:29 +0000 (22:15 +0100)]
cfg80211: move regulatory flags to their own variable

We'll expand this later, this will make it easier to
classify and review what things are related to regulatory
or not.

Coccinelle only missed 4 hits, which I had to do manually,
supplying the SmPL in case of merge conflicts.

@@
struct wiphy *wiphy;
@@
-wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY
+wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG
@@
expression e;
@@
-e->flags |= WIPHY_FLAG_CUSTOM_REGULATORY
+e->regulatory_flags |= REGULATORY_CUSTOM_REG
@@
struct wiphy *wiphy;
@@
-wiphy->flags &= ~WIPHY_FLAG_CUSTOM_REGULATORY
+wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG
@@
struct wiphy *wiphy;
@@
-wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY
+wiphy->regulatory_flags & REGULATORY_CUSTOM_REG

@@
struct wiphy *wiphy;
@@
-wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY
+wiphy->regulatory_flags |= REGULATORY_STRICT_REG
@@
expression e;
@@
-e->flags |= WIPHY_FLAG_STRICT_REGULATORY
+e->regulatory_flags |= REGULATORY_STRICT_REG
@@
struct wiphy *wiphy;
@@
-wiphy->flags &= ~WIPHY_FLAG_STRICT_REGULATORY
+wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG
@@
struct wiphy *wiphy;
@@
-wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY
+wiphy->regulatory_flags & REGULATORY_STRICT_REG

@@
struct wiphy *wiphy;
@@
-wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS
+wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS
@@
expression e;
@@
-e->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS
+e->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS
@@
struct wiphy *wiphy;
@@
-wiphy->flags &= ~WIPHY_FLAG_DISABLE_BEACON_HINTS
+wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS
@@
struct wiphy *wiphy;
@@
-wiphy->flags & WIPHY_FLAG_DISABLE_BEACON_HINTS
+wiphy->regulatory_flags & REGULATORY_DISABLE_BEACON_HINTS

Generated-by: Coccinelle SmPL
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Mihir Shete <smihir@qti.qualcomm.com>
Cc: Henri Bahini <hbahini@qca.qualcomm.com>
Cc: Tushnim Bhattacharyya <tushnimb@qca.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
[fix up whitespace damage, overly long lines]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: use put_unaligned_le16 for precedence value in mesh
Chun-Yeow Yeoh [Tue, 12 Nov 2013 02:31:48 +0000 (10:31 +0800)]
mac80211: use put_unaligned_le16 for precedence value in mesh

use put_unaligned_le16 for precedence value in mesh
channel switch support

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211_hwsim: claim CCK support for HT clients
Karl Beldan [Mon, 11 Nov 2013 12:29:33 +0000 (13:29 +0100)]
mac80211_hwsim: claim CCK support for HT clients

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: rename __set_regdom() to reg_set_rd_country_ie()
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:17 +0000 (09:18 -0800)]
cfg80211: rename __set_regdom() to reg_set_rd_country_ie()

This reflects that case is now completely separated.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: set driver regulatory updates on its own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:16 +0000 (09:18 -0800)]
cfg80211: set driver regulatory updates on its own

This splits up the driver regulatory update on its
own, this helps simplify the reading the case.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: set user regulatory updates on its own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:15 +0000 (09:18 -0800)]
cfg80211: set user regulatory updates on its own

This splits out the user regulatory update on its
own, this helps simplify reading the case.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: set core regulatory updates on its own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:14 +0000 (09:18 -0800)]
cfg80211: set core regulatory updates on its own

This splits up the core regulatory update to be
set on its own helper. This should make it easier
to read exactly what type of requests should be
expected there. In this case its clear that
NL80211_REGDOM_SET_BY_CORE is only used by the
core for updating the world regulatory domain.
This is consistant with the nl80211.h documentation.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
[add warning to default switch case to avoid compiler warning]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: pass the last_request to __set_regdom()
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:13 +0000 (09:18 -0800)]
cfg80211: pass the last_request to __set_regdom()

last_request is RCU protected, since we're getting it
on set_regdom() we might as well pass it to ensure the
same request is being processed, otherwise there is a
small race it could have changed. This makes processing
of the request atomic.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: move core reg_notfier() check to source
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:12 +0000 (09:18 -0800)]
cfg80211: move core reg_notfier() check to source

Drivers that set the WIPHY_FLAG_CUSTOM_REGULATORY skip
the core world regulatory domain updates, but do want
their reg_notifier() called. Move the check for this
closer to the source of the check that detected skipped
was required and while at it add a helper for the notifier
calling. This has no functional changes. This brings together
the place where we call the reg_notifier() will be called.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: allow only the core to request to update the world regdom
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:11 +0000 (09:18 -0800)]
cfg80211: allow only the core to request to update the world regdom

It seems some out of tree drivers were using a regulatory_hint("00")
to trigger off the wiphy regulatory notifier, for those cases just
setting the WIPHY_FLAG_CUSTOM_REGULATORY would suffice to call
the reg_notifier() for a world regulatory domain update. If drivers
find other needs for calling the reg_notifier() a proper implemenation
is preferred.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add helper for calling CRDA
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:10 +0000 (09:18 -0800)]
cfg80211: add helper for calling CRDA

All the regulatory request process routines use the
same pattern.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add helper for kfree'ing and assigning last_request
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:09 +0000 (09:18 -0800)]
cfg80211: add helper for kfree'ing and assigning last_request

This enforces proper RCU APIs accross the code.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add helper for kfree'ing last_request
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:08 +0000 (09:18 -0800)]
cfg80211: add helper for kfree'ing last_request

This is common code, this reduces the chance of making
a mistake of how we free it.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: process non country IE conflicting first
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:07 +0000 (09:18 -0800)]
cfg80211: process non country IE conflicting first

By dealing with non country IE conficts first we can shift
the code that deals with the conflict to the left. This has
no functional changes.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: process country IE regulatory requests on their own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:06 +0000 (09:18 -0800)]
cfg80211: process country IE regulatory requests on their own

This is the last split up of the old unified __regultory_hint()
processing set of functionality, it moves the country IE processing
all on its own. This makes it easier to follow and read what exactly
is going on for the case of processing country IEs.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: process driver regulatory requests on its own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:05 +0000 (09:18 -0800)]
cfg80211: process driver regulatory requests on its own

This makes the code easier to read and follow.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: process user regulatory requests on its own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:04 +0000 (09:18 -0800)]
cfg80211: process user regulatory requests on its own

This makes the code path easier to read and lets us
split out some functionality that is only user specific,
that makes it easier to read the other types of requests.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: processing core regulatory hints on its own
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:03 +0000 (09:18 -0800)]
cfg80211: processing core regulatory hints on its own

This makes the code path easier to read for the core case.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
[add warning to default case in switch to avoid compile warning]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: check regulatory request alpha2 early
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:01 +0000 (09:18 -0800)]
cfg80211: check regulatory request alpha2 early

Currently nl80211 allows userspace to send the kernel
a bogus regulatory domain with at most 32 rules set
and it won't reject it until after its allocated
memory. Let's be smart about it and take advantage
that the last_request is now available under RTNL
and check if the alpha2 matches an expected request
and reject any bogus userspace requests prior to
hitting the memory allocator.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: enforce disabling channels by custom or strict settings
Luis R. Rodriguez [Wed, 6 Nov 2013 16:54:44 +0000 (17:54 +0100)]
cfg80211: enforce disabling channels by custom or strict settings

If a custom regulatory domain is passed and if a rule for a
channel indicates it should be disabled that channel should
always remain disabled as per its documentation and design.

Likewise if WIPHY_FLAG_STRICT_REGULATORY flag is set and a
regulatory_hint() is issued if a channel is disabled that
channel should remain disabled.

Without this change only drivers that set the _orig flags
appropriately on their own would ensure disallowed channels
remaind disabled. This helps drivers save code by relying on
the APIS provided to entrust channels that should not be enabled
be respected by only having to use wiphy_apply_custom_regulatory()
or regulatory_hint() with the WIPHY_FLAG_STRICT_REGULATORY set.

If wiphy_apply_custom_regulatory() is used together with
WIPHY_FLAG_STRICT_REGULATORY and a regulatory_hint() issued
later, the incoming regulatory domain can override previously
set _orig parameters from the initial custom regulatory
setting.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: fix parsing when db.txt ends on a rule
Luis R. Rodriguez [Mon, 28 Oct 2013 02:19:46 +0000 (03:19 +0100)]
cfg80211: fix parsing when db.txt ends on a rule

If genregdb.awk assumes the file will end with an
extra empty line or a comment line. This is could
not be true so just address this.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Acked-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add function helpers to genregdb.awk
Luis R. Rodriguez [Mon, 28 Oct 2013 02:19:45 +0000 (03:19 +0100)]
cfg80211: add function helpers to genregdb.awk

This has no functional change, this just lets us reuse
helpers at a later time.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Acked-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: add generic cipher scheme support
Max Stepanov [Sun, 24 Mar 2013 12:23:27 +0000 (14:23 +0200)]
mac80211: add generic cipher scheme support

This adds generic cipher scheme support to mac80211, such schemes
are fully under control by the driver. On hw registration drivers
may specify additional HW ciphers with a scheme how these ciphers
have to be handled by mac80211 TX/RR. A cipher scheme specifies a
cipher suite value, a size of the security header to be added to
or stripped from frames and how the PN is to be verified on RX.

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: allow beaconing after DFS CAC
Janusz Dziedzic [Wed, 6 Nov 2013 12:55:53 +0000 (13:55 +0100)]
cfg80211: allow beaconing after DFS CAC

Allow beconing after we pass Channel Availability Check (CAC).
Allow non-DFS and DFS channels mix. All DFS channels have to
be in NL80211_DFS_AVAILABLE state (pass CAC).

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211/mac80211: DFS setup chandef for cac event
Janusz Dziedzic [Wed, 6 Nov 2013 12:55:51 +0000 (13:55 +0100)]
cfg80211/mac80211: DFS setup chandef for cac event

To report channel width correctly we have
to send correct channel parameters from
mac80211 when calling cfg80211_cac_event().

This is required in case of using channel width
higher than 20MHz and we have to set correct
dfs channel state after CAC (NL80211_DFS_AVAILABLE).

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Reviewed-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: verify ieee80211_key_replace() arguments
Johannes Berg [Tue, 29 Oct 2013 09:00:08 +0000 (10:00 +0100)]
mac80211: verify ieee80211_key_replace() arguments

There's no code calling ieee80211_key_replace() with both
arguments NULL and it wouldn't make sense, but in the
interest of maintainability add a warning for it. As a
side effect, this also shuts up a smatch warning.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: don't allow drivers to unset NL80211_FEATURE_SCAN_FLUSH
Johannes Berg [Sat, 26 Oct 2013 15:14:38 +0000 (17:14 +0200)]
cfg80211: don't allow drivers to unset NL80211_FEATURE_SCAN_FLUSH

As the flag is entirely implemented in cfg80211, it should
have been a global feature flag (which I believe didn't
exist at the time). However, there's no reason to allow
drivers to unset the flag, so don't allow it and remove
the validation of NL80211_SCAN_FLAG_FLUSH.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add missing break in cfg80211_get_chan_state()
Johannes Berg [Fri, 25 Oct 2013 10:46:44 +0000 (12:46 +0200)]
cfg80211: add missing break in cfg80211_get_chan_state()

Improve readability of the function by adding the break,
there's no functional impact but it's confusing to fall
through.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: remove useless tests for array
Johannes Berg [Fri, 25 Oct 2013 09:31:42 +0000 (11:31 +0200)]
mac80211: remove useless tests for array

Coverity points out that checking assoc_data->ie is
completely useless since it's an array in the struct
and can't be NULL - remove the useless checks.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: clean up mesh local link ID generation
Thomas Pedersen [Tue, 5 Nov 2013 19:17:05 +0000 (11:17 -0800)]
mac80211: clean up mesh local link ID generation

802.11-2012 13.3.1 implicitly limits the mesh local link
ID range to that of AID, since for mesh PS the local link
ID must be indicated in the TIM IE, which only holds
IEEE80211_MAX_AID bits.

Also the code was allowing a local link ID of 0, but this
is not correct since that TIM bit is used for indicating
buffered mcast frames.

Generate a random, unique, link ID from 1 - 2007, and drop
a modulo conversion for the local link ID, but keep it for
the peer link ID in case he chose something > MAX_AID.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>