profile/common/kernel-common.git
10 years agomac80211: fix nested sdata lock for IBSS/CSA
Simon Wunderlich [Thu, 5 Dec 2013 18:54:43 +0000 (19:54 +0100)]
mac80211: fix nested sdata lock for IBSS/CSA

This fixes a regression introduced by my patch "mac80211: don't cancel
csa finalize work within stop_ap", which added sdata locks to
ieee80211_csa_finalize_work() without removing the locking for
ieee80211_ibss_finish_csa(), which is called by the former, resulting
in a deadlock due to nested locking.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: don't "leak" uncompleted scans
Eliad Peller [Thu, 5 Dec 2013 16:30:17 +0000 (18:30 +0200)]
cfg80211: don't "leak" uncompleted scans

___cfg80211_scan_done() can be called in some cases
(e.g. on NETDEV_DOWN) before the low level driver
notified scan completion (which is indicated by
passing leak=true).

Clearing rdev->scan_req in this case is buggy, as
scan_done_wk might have already being queued/running
(and can't be flushed as it takes rtnl()).

If a new scan will be requested at this stage, the
scan_done_wk will try freeing it (instead of the
previous scan), and this will later result in
a use after free.

Simply remove the "leak" option, and replace it with
a standard WARN_ON.

An example backtrace after such crash:
Unable to handle kernel paging request at virtual address fffffee5
pgd = c0004000
[fffffee5] *pgd=9fdf6821, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] SMP ARM
PC is at cfg80211_scan_done+0x28/0xc4 [cfg80211]
LR is at __ieee80211_scan_completed+0xe4/0x2dc [mac80211]
[<bf0077b0>] (cfg80211_scan_done+0x28/0xc4 [cfg80211])
[<bf0973d4>] (__ieee80211_scan_completed+0xe4/0x2dc [mac80211])
[<bf0982cc>] (ieee80211_scan_work+0x94/0x4f0 [mac80211])
[<c005fd10>] (process_one_work+0x1b0/0x4a8)
[<c0060404>] (worker_thread+0x138/0x37c)
[<c0066d70>] (kthread+0xa4/0xb0)

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: start_next_roc only if scan was actually running
Eliad Peller [Thu, 5 Dec 2013 09:21:28 +0000 (11:21 +0200)]
mac80211: start_next_roc only if scan was actually running

On scan completion we try start any pending roc.

However, if scan was just pending (and not actually started)
there is no point in trying to start the roc, as it might
have started already.

This solves the following warning:
WARNING: CPU: 0 PID: 3552 at net/mac80211/offchannel.c:269 ieee80211_start_next_roc+0x164/0x204 [mac80211]()
[<c001cd38>] (unwind_backtrace+0x0/0xf0)
[<c00181d0>] (show_stack+0x10/0x14)
[<c05c0d8c>] (dump_stack+0x78/0x94)
[<c0047c08>] (warn_slowpath_common+0x68/0x8c)
[<c0047c48>] (warn_slowpath_null+0x1c/0x24)
[<bf4d6660>] (ieee80211_start_next_roc+0x164/0x204 [mac80211])
[<bf4d5a74>] (ieee80211_scan_cancel+0xe8/0x190 [mac80211])
[<bf4df970>] (ieee80211_do_stop+0x63c/0x79c [mac80211])
[<bf4dfae0>] (ieee80211_stop+0x10/0x18 [mac80211])
[<c0504d84>] (__dev_close_many+0x84/0xcc)
[<c0504df4>] (__dev_close+0x28/0x3c)
[<c0509708>] (__dev_change_flags+0x78/0x144)
[<c0509854>] (dev_change_flags+0x10/0x48)
[<c055fe3c>] (devinet_ioctl+0x614/0x6d0)
[<c04f22a0>] (sock_ioctl+0x5c/0x2a4)
[<c0124eb4>] (do_vfs_ioctl+0x7c/0x5d8)
[<c012547c>] (SyS_ioctl+0x6c/0x7c)

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: determine completed scan type by defined ops
Eliad Peller [Thu, 5 Dec 2013 09:21:27 +0000 (11:21 +0200)]
mac80211: determine completed scan type by defined ops

In some cases, determining the completed scan type was
done by testing the SCAN_HW_SCANNING flag.

However, this doesn't take care for the case in which
the hw scan was requested, but hasn't started yet (e.g.
due to active remain_on_channel).

Replace this test by checking whether ops->hw_scan is
defined.

This solves the following warning:

WARNING: CPU: 0 PID: 3552 at net/mac80211/offchannel.c:156 __ieee80211_scan_completed+0x1b4/0x2dc [mac80211]()
[<c001cd38>] (unwind_backtrace+0x0/0xf0)
[<c00181d0>] (show_stack+0x10/0x14)
[<c05c0d8c>] (dump_stack+0x78/0x94)
[<c0047c08>] (warn_slowpath_common+0x68/0x8c)
[<c0047c48>] (warn_slowpath_null+0x1c/0x24)
[<bf4d4504>] (__ieee80211_scan_completed+0x1b4/0x2dc [mac80211])
[<bf4d5a74>] (ieee80211_scan_cancel+0xe8/0x190 [mac80211])
[<bf4df970>] (ieee80211_do_stop+0x63c/0x79c [mac80211])
[<bf4dfae0>] (ieee80211_stop+0x10/0x18 [mac80211])
[<c0504d84>] (__dev_close_many+0x84/0xcc)
[<c0504df4>] (__dev_close+0x28/0x3c)
[<c0509708>] (__dev_change_flags+0x78/0x144)
[<c0509854>] (dev_change_flags+0x10/0x48)
[<c055fe3c>] (devinet_ioctl+0x614/0x6d0)
[<c04f22a0>] (sock_ioctl+0x5c/0x2a4)
[<c0124eb4>] (do_vfs_ioctl+0x7c/0x5d8)
[<c012547c>] (SyS_ioctl+0x6c/0x7c)

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: stop sched scan only when needed
Barak Bercovitz [Thu, 5 Dec 2013 09:21:26 +0000 (11:21 +0200)]
cfg80211: stop sched scan only when needed

cfg80211_leave stops sched scan when any station vif
is leaving. Add an explicit check and call it only
when the relevant vif (the one we scan on) is leaving.

Signed-off-by: Barak Bercovitz <barak@wizery.com>
[Eliad - changed the commit message a bit]
Signed-off-by: Eliad Peller <eliad@wizery.com>
[Johannes - add ASSERT_RTNL since that protects the pointer]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: in bitrate_mask, rename mcs to ht_mcs
Janusz Dziedzic [Thu, 5 Dec 2013 09:02:15 +0000 (10:02 +0100)]
cfg80211: in bitrate_mask, rename mcs to ht_mcs

Rename NL80211_TXRATE_MCS to NL80211_TXRATE_HT and also
rename mcs to ht_mcs in struct cfg80211_bitrate_mask.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
[reword commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agonl80211: allow setting bitrate mask back to default
Janusz Dziedzic [Thu, 5 Dec 2013 09:02:14 +0000 (10:02 +0100)]
nl80211: allow setting bitrate mask back to default

Allow setting the bitrate masks back to default by
omitting the NL80211_ATTR_TX_RATES attribute.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
[rephrase commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: warn if unhashing station fails
Johannes Berg [Wed, 4 Dec 2013 19:25:27 +0000 (20:25 +0100)]
mac80211: warn if unhashing station fails

This shouldn't be happening, so warn if it does, since we'd
then leak a station entry.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: neaten ieee80211_deliver_skb
Johannes Berg [Wed, 4 Dec 2013 08:16:31 +0000 (09:16 +0100)]
mac80211: neaten ieee80211_deliver_skb

Remove the unnecessary duplicate test of "if (skb) {"
when !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.

Remove now unnecessary __maybe_unused, neaten comment
Remove unnecessary parenthesis around align cast.
Substitute reference to deprecated compare_ether_addr
with ether_addr_equal (in the comment.)

Signed-off-by: Joe Perches <joe@perches.com>
[edit commit log slightly]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agonl80211: allow the use of DFS channel in mesh
Chun-Yeow Yeoh [Mon, 2 Dec 2013 08:05:49 +0000 (16:05 +0800)]
nl80211: allow the use of DFS channel in mesh

This permits the use of DFS channel once the CAC is conducted and
no radar is detected.

Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agonl80211: vendor command support
Johannes Berg [Wed, 13 Nov 2013 12:37:47 +0000 (13:37 +0100)]
nl80211: vendor command support

Add support for vendor-specific commands to nl80211. This is
intended to be used for really vendor-specific functionality
that can't be implemented in a generic fashion for any reason.
It's *NOT* intended to be used for any normal/generic feature
or any optimisations that could be implemented across drivers.

Currently, only vendor commands (with replies) are supported,
no dump operations or vendor-specific notifications.

Also add a function wdev_to_ieee80211_vif() to mac80211 which
is needed for mac80211-based drivers wanting to implement any
vendor commands.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agonl80211: don't clear bitrate_mask twice
Janusz Dziedzic [Tue, 3 Dec 2013 08:50:44 +0000 (09:50 +0100)]
nl80211: don't clear bitrate_mask twice

Don't clear cfg80211_bitrate_mask twice in
nl80211_set_tx_bitrate_mask() function.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: remove duplicate code
Eliad Peller [Tue, 3 Dec 2013 13:02:15 +0000 (15:02 +0200)]
mac80211: remove duplicate code

The same code appears just a few lines below.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: DFS check dfs_region before usage
Luis R. Rodriguez [Mon, 25 Nov 2013 19:56:10 +0000 (20:56 +0100)]
cfg80211: DFS check dfs_region before usage

Check the DFS region before channel availability check.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: add reg_get_dfs_region()
Luis R. Rodriguez [Mon, 25 Nov 2013 19:56:09 +0000 (20:56 +0100)]
cfg80211: add reg_get_dfs_region()

This can be used outside of the regulatory context for any checks
on the DFS region. The central cfg80211 dfs_region is always used
and if it does not match with the wiphy a debug print is issued.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agonl80211/cfg80211: Set Operating Mode Notification
Marek Kwaczynski [Tue, 3 Dec 2013 09:04:59 +0000 (10:04 +0100)]
nl80211/cfg80211: Set Operating Mode Notification

This attribute is needed for setting Operating Mode Notification
in AP mode from User Space. This functionality is required when
User Space received Assoc Request contains Operation Mode
Notification element.

Signed-off-by: Marek Kwaczynski <marek.kwaczynski@tieto.com>
[fix typos, nl80211 documentation]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: move align variable to remove __maybe_unused
Johannes Berg [Mon, 2 Dec 2013 18:22:17 +0000 (19:22 +0100)]
mac80211: move align variable to remove __maybe_unused

There's no reason for the variable to not be inside
the #ifdef, move it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agoRevert "mac80211: add driver callback for per-interface multicast filter"
Johannes Berg [Tue, 3 Dec 2013 12:21:36 +0000 (13:21 +0100)]
Revert "mac80211: add driver callback for per-interface multicast filter"

This reverts commit 488b366a452934141959384c7a1b52b22d6154ef.

The code isn't used by anyone, and the Intel driver isn't planning
to use it either right now.

Signed-off-by: Johannes Berg <johannes.berg@intel.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: 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 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>
10 years agomac80211: factor out plink event gathering
Thomas Pedersen [Tue, 5 Nov 2013 19:17:03 +0000 (11:17 -0800)]
mac80211: factor out plink event gathering

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: factor out peering FSM
Thomas Pedersen [Tue, 5 Nov 2013 19:17:02 +0000 (11:17 -0800)]
mac80211: factor out peering FSM

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
[fix some indentation, squash llid assignment]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: assign sta plid early
Thomas Pedersen [Tue, 5 Nov 2013 19:17:01 +0000 (11:17 -0800)]
mac80211: assign sta plid early

If we store the peer link ID right after initializing a
new neighbor, there is no need to do it later in the
peering FSM.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: consolidate rcu unlocks in plink frame rx
Thomas Pedersen [Tue, 5 Nov 2013 19:17:00 +0000 (11:17 -0800)]
mac80211: consolidate rcu unlocks in plink frame rx

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: factor peering frame processing into own function
Thomas Pedersen [Tue, 5 Nov 2013 19:16:59 +0000 (11:16 -0800)]
mac80211: factor peering frame processing into own function

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: remove unused mesh_mgmt_ies_add() prototype
Bob Copeland [Tue, 5 Nov 2013 19:16:58 +0000 (11:16 -0800)]
mac80211: remove unused mesh_mgmt_ies_add() prototype

Said function was removed some time ago.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: return -ENOMEM in mesh_plink_frame_tx
Bob Copeland [Tue, 5 Nov 2013 19:16:57 +0000 (11:16 -0800)]
mac80211: return -ENOMEM in mesh_plink_frame_tx

All other paths return an error code, do the same here.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: mesh_plink: don't ignore holding timer
Bob Copeland [Tue, 5 Nov 2013 19:16:56 +0000 (11:16 -0800)]
mac80211: mesh_plink: don't ignore holding timer

The ignore_plink_timer flag is set when doing mod_timer() if
the timer was not previously active.  This is to avoid executing
the timeout if del_timer() was subsequently called.  However,
del_timer() only happens if we are moving to ESTAB state or
get a close frame while in HOLDING.

We cannot leave HOLDING and re-enter ESTAB unless we receive a
close frame (in which case ignore_plink_timer is already set) or
if the timeout expires, so there actually isn't a case where
this is needed on mod_timer().

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: mesh_plink: collapse the two switch statements together
Bob Copeland [Tue, 5 Nov 2013 19:16:55 +0000 (11:16 -0800)]
mac80211: mesh_plink: collapse the two switch statements together

The matches_local check can just be done when looking at the
individual action types.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: mesh: rewrite rssi_threshold_check in C
Bob Copeland [Tue, 5 Nov 2013 19:16:54 +0000 (11:16 -0800)]
mac80211: mesh: rewrite rssi_threshold_check in C

Use C instead of cpp for type checking.  Also swap the arguments
into the usual sdata -> sta order.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: mesh_plink: group basic fitness checks
Bob Copeland [Tue, 5 Nov 2013 19:16:53 +0000 (11:16 -0800)]
mac80211: mesh_plink: group basic fitness checks

The initial frame checks differ depending on whether this is
a new peer or not, but they were all intermixed with sta checks
as necessary.  Group them together so the two cases are clearer.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: mesh: factor out common plink close/estab code
Bob Copeland [Tue, 5 Nov 2013 19:16:52 +0000 (11:16 -0800)]
mac80211: mesh: factor out common plink close/estab code

Reject and accepted close events always put the host in the
holding state and compute a reason code based only on the
current state.  Likewise on establish we always do the same
setup.  Put these in functions to save some duplicated code.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: hold sta->lock across plink switch statements
Bob Copeland [Tue, 5 Nov 2013 19:16:51 +0000 (11:16 -0800)]
mac80211: hold sta->lock across plink switch statements

Rather than unlock at the end of each case, do it once after
all is said and done.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: consolidate calls to plink_frame_tx
Thomas Pedersen [Tue, 5 Nov 2013 19:16:50 +0000 (11:16 -0800)]
mac80211: consolidate calls to plink_frame_tx

Do all frame transfers in one place at the end of the
big switch statements.  sta->plid and sta->reason can
be passed in any case, since they are only used for
the frames that need them.  Remove assignments to locals
for values already stored in the sta structure.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: fix off-by-one in llid check.
Bob Copeland [Tue, 5 Nov 2013 19:16:49 +0000 (11:16 -0800)]
mac80211: fix off-by-one in llid check.

According to IEEE 802.11-2012 (8.4.2.104), no peering
management element exists with length 7. This code is checking
to see if llid is present to ignore close frames with different
llid, which would be IEs with length 8.

Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: remove second argument from reg_process_hint()
Luis R. Rodriguez [Tue, 5 Nov 2013 17:18:02 +0000 (09:18 -0800)]
cfg80211: remove second argument from reg_process_hint()

The iniator is already available to us, so use it.

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

wiphy_apply_custom_regulatory() implies WIPHY_FLAG_CUSTOM_REGULATORY
but we never enforced it, do that now and warn if the driver
didn't set it. All drivers should be following this today already.

Having WIPHY_FLAG_CUSTOM_REGULATORY does not however mean you will
use wiphy_apply_custom_regulatory() though, you may have your own
_orig value set up tools / helpers. The intel drivers are examples
of this type of driver.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: DFS check chandef usable before CAC
Janusz Dziedzic [Tue, 5 Nov 2013 13:48:48 +0000 (14:48 +0100)]
cfg80211: DFS check chandef usable before CAC

Check chandef we get in CAC request is usable for CAC.
All channels have to be DFS channels. Allow DFS_USABLE
and DFS_AVAILABLE channels mix. At least one channel
has to be DFS_USABLE (require CAC).

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 agocfg80211: add helper functions for start/end freq
Janusz Dziedzic [Tue, 5 Nov 2013 13:48:47 +0000 (14:48 +0100)]
cfg80211: add helper functions for start/end freq

Add helper fuctions for start/end freq.

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_hwsim: VHT add 160MHz width support
Janusz Dziedzic [Tue, 5 Nov 2013 12:03:54 +0000 (13:03 +0100)]
mac80211_hwsim: VHT add 160MHz width support

Add 160MHz width support. This could be
usefull for testing VHT160 DFS functionality.
This could be also usefull in the future when
DFS and non-DFS channels could be mixed.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211_hwsim: Add iface comb for DFS
Janusz Dziedzic [Tue, 5 Nov 2013 12:03:53 +0000 (13:03 +0100)]
mac80211_hwsim: Add iface comb for DFS

Add iface combination that will allow DFS
support. Add also debugfs dfs_simulate_radar
file that can be used to simulate radar event.
This could be useful for mac80211/cfg80211/
regulatory/hostap code testing without real HW.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211_hwsim: use debugfs_remove_recursive
Janusz Dziedzic [Fri, 1 Nov 2013 19:35:58 +0000 (20:35 +0100)]
mac80211_hwsim: use debugfs_remove_recursive

Use debugfs_remove_recursive. That avoids the need
for the new dentry pointers and extra debugfs_remove
calls.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agomac80211: do not compute offset from ssn in Rx AMPDU reordering buffer
Karl Beldan [Thu, 24 Oct 2013 13:53:32 +0000 (15:53 +0200)]
mac80211: do not compute offset from ssn in Rx AMPDU reordering buffer

Currently, frames that go into the reordering buffer are stored at
index ieee80211_sn_sub(sn, tid_rx->ssn) % tid_rx->buf_size.

The offset calculation to the starting sequence number (SSN) is
useless and just adds overhead so simply use sn % tid_rx->buf_size.

This means the reordering buffer will start to be filled somewhere
in the middle (at SSN % buf_size) and continue to get used from
there, but there's no reason to start from the beginning.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
[rewrite commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agocfg80211: consolidate passive-scan and no-ibss flags
Luis R. Rodriguez [Mon, 21 Oct 2013 17:22:25 +0000 (19:22 +0200)]
cfg80211: consolidate passive-scan and no-ibss flags

These two flags are used for the same purpose, just
combine them into a no-ir flag to annotate no initiating
radiation is allowed.

Old userspace sending either flag will have it treated as
the no-ir flag. To be considerate to older userspace we
also send both the no-ir flag and the old no-ibss flags.
Newer userspace will have to be aware of older kernels.

Update all places in the tree using these flags with the
following semantic patch:

@@
@@
-NL80211_RRF_PASSIVE_SCAN
+NL80211_RRF_NO_IR
@@
@@
-NL80211_RRF_NO_IBSS
+NL80211_RRF_NO_IR
@@
@@
-IEEE80211_CHAN_PASSIVE_SCAN
+IEEE80211_CHAN_NO_IR
@@
@@
-IEEE80211_CHAN_NO_IBSS
+IEEE80211_CHAN_NO_IR
@@
@@
-NL80211_RRF_NO_IR | NL80211_RRF_NO_IR
+NL80211_RRF_NO_IR
@@
@@
-IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_IR
+IEEE80211_CHAN_NO_IR
@@
@@
-(NL80211_RRF_NO_IR)
+NL80211_RRF_NO_IR
@@
@@
-(IEEE80211_CHAN_NO_IR)
+IEEE80211_CHAN_NO_IR

Along with some hand-optimisations in documentation, to
remove duplicates and to fix some indentation.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
[do all the driver updates in one go]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
10 years agonl80211: better document NL80211_CMD_TDLS_MGMT
Arik Nemtsov [Thu, 31 Oct 2013 12:54:35 +0000 (14:54 +0200)]
nl80211: better document NL80211_CMD_TDLS_MGMT

This command has different semantics depending on the action code sent.
Document this fact and detail the supported action codes.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>