2009-12-23 20:15:35 +08:00
|
|
|
/*
|
|
|
|
* mac80211 work implementation
|
|
|
|
*
|
|
|
|
* Copyright 2003-2008, Jouni Malinen <j@w1.fi>
|
|
|
|
* Copyright 2004, Instant802 Networks, Inc.
|
|
|
|
* Copyright 2005, Devicescape Software, Inc.
|
|
|
|
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
|
|
|
|
* Copyright 2007, Michael Wu <flamingice@sourmilk.net>
|
|
|
|
* Copyright 2009, Johannes Berg <johannes@sipsolutions.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/crc32.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-12-23 20:15:35 +08:00
|
|
|
#include <net/mac80211.h>
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
|
|
|
|
#include "ieee80211_i.h"
|
|
|
|
#include "rate.h"
|
2011-07-19 16:39:53 +08:00
|
|
|
#include "driver-ops.h"
|
2009-12-23 20:15:35 +08:00
|
|
|
|
|
|
|
enum work_action {
|
|
|
|
WORK_ACT_NONE,
|
|
|
|
WORK_ACT_TIMEOUT,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* utils */
|
|
|
|
static inline void ASSERT_WORK_MTX(struct ieee80211_local *local)
|
|
|
|
{
|
2010-07-30 22:46:07 +08:00
|
|
|
lockdep_assert_held(&local->mtx);
|
2009-12-23 20:15:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can have multiple work items (and connection probing)
|
|
|
|
* scheduling this timer, but we need to take care to only
|
|
|
|
* reschedule it when it should fire _earlier_ than it was
|
|
|
|
* asked for before, or if it's not pending right now. This
|
|
|
|
* function ensures that. Note that it then is required to
|
|
|
|
* run this function for all timeouts after the first one
|
|
|
|
* has happened -- the work that runs from this timer will
|
|
|
|
* do that.
|
|
|
|
*/
|
|
|
|
static void run_again(struct ieee80211_local *local,
|
|
|
|
unsigned long timeout)
|
|
|
|
{
|
|
|
|
ASSERT_WORK_MTX(local);
|
|
|
|
|
|
|
|
if (!timer_pending(&local->work_timer) ||
|
|
|
|
time_before(timeout, local->work_timer.expires))
|
|
|
|
mod_timer(&local->work_timer, timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void free_work(struct ieee80211_work *wk)
|
|
|
|
{
|
2011-03-18 12:14:15 +08:00
|
|
|
kfree_rcu(wk, rcu_head);
|
2009-12-23 20:15:35 +08:00
|
|
|
}
|
|
|
|
|
2009-12-23 20:15:42 +08:00
|
|
|
static enum work_action __must_check
|
|
|
|
ieee80211_remain_on_channel_timeout(struct ieee80211_work *wk)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* First time we run, do nothing -- the generic code will
|
|
|
|
* have switched to the right channel etc.
|
|
|
|
*/
|
2010-01-25 20:36:36 +08:00
|
|
|
if (!wk->started) {
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->timeout = jiffies + msecs_to_jiffies(wk->remain.duration);
|
2009-12-23 20:15:42 +08:00
|
|
|
|
2009-12-30 20:42:20 +08:00
|
|
|
cfg80211_ready_on_channel(wk->sdata->dev, (unsigned long) wk,
|
|
|
|
wk->chan, wk->chan_type,
|
|
|
|
wk->remain.duration, GFP_KERNEL);
|
2009-12-23 20:15:42 +08:00
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
return WORK_ACT_NONE;
|
2009-12-23 20:15:42 +08:00
|
|
|
}
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
return WORK_ACT_TIMEOUT;
|
2009-12-23 20:15:42 +08:00
|
|
|
}
|
|
|
|
|
2010-11-25 17:02:30 +08:00
|
|
|
static enum work_action __must_check
|
|
|
|
ieee80211_offchannel_tx(struct ieee80211_work *wk)
|
|
|
|
{
|
|
|
|
if (!wk->started) {
|
|
|
|
wk->timeout = jiffies + msecs_to_jiffies(wk->offchan_tx.wait);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* After this, offchan_tx.frame remains but now is no
|
|
|
|
* longer a valid pointer -- we still need it as the
|
2011-10-05 00:27:10 +08:00
|
|
|
* cookie for canceling this work/status matching.
|
2010-11-25 17:02:30 +08:00
|
|
|
*/
|
|
|
|
ieee80211_tx_skb(wk->sdata, wk->offchan_tx.frame);
|
|
|
|
|
|
|
|
return WORK_ACT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return WORK_ACT_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
2009-12-23 20:15:35 +08:00
|
|
|
static void ieee80211_work_timer(unsigned long data)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = (void *) data;
|
|
|
|
|
|
|
|
if (local->quiescing)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ieee80211_queue_work(&local->hw, &local->work_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ieee80211_work_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local =
|
|
|
|
container_of(work, struct ieee80211_local, work_work);
|
|
|
|
struct ieee80211_work *wk, *tmp;
|
|
|
|
LIST_HEAD(free_work);
|
|
|
|
enum work_action rma;
|
2009-12-23 20:15:43 +08:00
|
|
|
bool remain_off_channel = false;
|
2009-12-23 20:15:35 +08:00
|
|
|
|
|
|
|
if (local->scanning)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ieee80211_queue_work() should have picked up most cases,
|
2010-05-18 19:44:54 +08:00
|
|
|
* here we'll pick the rest.
|
2009-12-23 20:15:35 +08:00
|
|
|
*/
|
|
|
|
if (WARN(local->suspended, "work scheduled while going to suspend\n"))
|
|
|
|
return;
|
|
|
|
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_lock(&local->mtx);
|
2009-12-23 20:15:35 +08:00
|
|
|
|
2010-08-05 23:02:38 +08:00
|
|
|
ieee80211_recalc_idle(local);
|
|
|
|
|
2009-12-23 20:15:35 +08:00
|
|
|
list_for_each_entry_safe(wk, tmp, &local->work_list, list) {
|
2010-01-25 20:36:36 +08:00
|
|
|
bool started = wk->started;
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
/* mark work as started if it's on the current off-channel */
|
2010-01-25 20:36:36 +08:00
|
|
|
if (!started && local->tmp_channel &&
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->chan == local->tmp_channel &&
|
|
|
|
wk->chan_type == local->tmp_channel_type) {
|
2010-01-25 20:36:36 +08:00
|
|
|
started = true;
|
2010-01-06 22:30:58 +08:00
|
|
|
wk->timeout = jiffies;
|
2009-12-23 20:15:43 +08:00
|
|
|
}
|
|
|
|
|
2010-01-25 20:36:36 +08:00
|
|
|
if (!started && !local->tmp_channel) {
|
2011-11-29 17:20:02 +08:00
|
|
|
ieee80211_offchannel_stop_vifs(local, true);
|
2011-02-08 05:44:36 +08:00
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
local->tmp_channel = wk->chan;
|
2011-11-29 17:20:02 +08:00
|
|
|
local->tmp_channel_type = wk->chan_type;
|
|
|
|
|
|
|
|
ieee80211_hw_config(local, 0);
|
mac80211: Optimize scans on current operating channel.
This should decrease un-necessary flushes, on/off channel work,
and channel changes in cases where the only scanned channel is
the current operating channel.
* Removes SCAN_OFF_CHANNEL flag, uses SDATA_STATE_OFFCHANNEL
and is-scanning flags instead.
* Add helper method to determine if we are currently configured
for the operating channel.
* Do no blindly go off/on channel in work.c Instead, only call
appropriate on/off code when we really need to change channels.
Always enable offchannel-ps mode when starting work,
and disable it when we are done.
* Consolidate ieee80211_offchannel_stop_station and
ieee80211_offchannel_stop_beaconing, call it
ieee80211_offchannel_stop_vifs instead.
* Accept non-beacon frames when scanning on operating channel.
* Scan state machine optimized to minimize on/off channel
transitions. Also, when going on-channel, go ahead and
re-enable beaconing. We're going to be there for 200ms,
so seems like some useful beaconing could happen.
Always enable offchannel-ps mode when starting software
scan, and disable it when we are done.
* Grab local->mtx earlier in __ieee80211_scan_completed_finish
so that we are protected when calling hw_config(), etc.
* Pass probe-responses up the stack if scanning on local
channel, so that mlme can take a look.
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2011-02-05 03:54:17 +08:00
|
|
|
|
2010-01-25 20:36:36 +08:00
|
|
|
started = true;
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->timeout = jiffies;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't try to work with items that aren't started */
|
2010-01-25 20:36:36 +08:00
|
|
|
if (!started)
|
2009-12-23 20:15:43 +08:00
|
|
|
continue;
|
|
|
|
|
2009-12-23 20:15:35 +08:00
|
|
|
if (time_is_after_jiffies(wk->timeout)) {
|
|
|
|
/*
|
|
|
|
* This work item isn't supposed to be worked on
|
|
|
|
* right now, but take care to adjust the timer
|
|
|
|
* properly.
|
|
|
|
*/
|
|
|
|
run_again(local, wk->timeout);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (wk->type) {
|
|
|
|
default:
|
|
|
|
WARN_ON(1);
|
|
|
|
/* nothing */
|
|
|
|
rma = WORK_ACT_NONE;
|
|
|
|
break;
|
2009-12-23 20:15:42 +08:00
|
|
|
case IEEE80211_WORK_ABORT:
|
|
|
|
rma = WORK_ACT_TIMEOUT;
|
2010-02-26 14:13:41 +08:00
|
|
|
break;
|
2009-12-23 20:15:42 +08:00
|
|
|
case IEEE80211_WORK_REMAIN_ON_CHANNEL:
|
|
|
|
rma = ieee80211_remain_on_channel_timeout(wk);
|
|
|
|
break;
|
2010-11-25 17:02:30 +08:00
|
|
|
case IEEE80211_WORK_OFFCHANNEL_TX:
|
|
|
|
rma = ieee80211_offchannel_tx(wk);
|
|
|
|
break;
|
2009-12-23 20:15:35 +08:00
|
|
|
}
|
|
|
|
|
2010-01-25 20:36:36 +08:00
|
|
|
wk->started = started;
|
|
|
|
|
2009-12-23 20:15:35 +08:00
|
|
|
switch (rma) {
|
|
|
|
case WORK_ACT_NONE:
|
2009-12-23 20:15:43 +08:00
|
|
|
/* might have changed the timeout */
|
|
|
|
run_again(local, wk->timeout);
|
2009-12-23 20:15:35 +08:00
|
|
|
break;
|
|
|
|
case WORK_ACT_TIMEOUT:
|
|
|
|
list_del_rcu(&wk->list);
|
|
|
|
synchronize_rcu();
|
|
|
|
list_add(&wk->list, &free_work);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN(1, "unexpected: %d", rma);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
list_for_each_entry(wk, &local->work_list, list) {
|
|
|
|
if (!wk->started)
|
|
|
|
continue;
|
2011-11-29 17:20:02 +08:00
|
|
|
if (wk->chan != local->tmp_channel ||
|
|
|
|
wk->chan_type != local->tmp_channel_type)
|
2009-12-23 20:15:43 +08:00
|
|
|
continue;
|
|
|
|
remain_off_channel = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!remain_off_channel && local->tmp_channel) {
|
|
|
|
local->tmp_channel = NULL;
|
2011-11-29 17:20:02 +08:00
|
|
|
ieee80211_hw_config(local, 0);
|
mac80211: Optimize scans on current operating channel.
This should decrease un-necessary flushes, on/off channel work,
and channel changes in cases where the only scanned channel is
the current operating channel.
* Removes SCAN_OFF_CHANNEL flag, uses SDATA_STATE_OFFCHANNEL
and is-scanning flags instead.
* Add helper method to determine if we are currently configured
for the operating channel.
* Do no blindly go off/on channel in work.c Instead, only call
appropriate on/off code when we really need to change channels.
Always enable offchannel-ps mode when starting work,
and disable it when we are done.
* Consolidate ieee80211_offchannel_stop_station and
ieee80211_offchannel_stop_beaconing, call it
ieee80211_offchannel_stop_vifs instead.
* Accept non-beacon frames when scanning on operating channel.
* Scan state machine optimized to minimize on/off channel
transitions. Also, when going on-channel, go ahead and
re-enable beaconing. We're going to be there for 200ms,
so seems like some useful beaconing could happen.
Always enable offchannel-ps mode when starting software
scan, and disable it when we are done.
* Grab local->mtx earlier in __ieee80211_scan_completed_finish
so that we are protected when calling hw_config(), etc.
* Pass probe-responses up the stack if scanning on local
channel, so that mlme can take a look.
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2011-02-05 03:54:17 +08:00
|
|
|
|
2011-11-29 17:20:02 +08:00
|
|
|
ieee80211_offchannel_return(local, true);
|
mac80211: Optimize scans on current operating channel.
This should decrease un-necessary flushes, on/off channel work,
and channel changes in cases where the only scanned channel is
the current operating channel.
* Removes SCAN_OFF_CHANNEL flag, uses SDATA_STATE_OFFCHANNEL
and is-scanning flags instead.
* Add helper method to determine if we are currently configured
for the operating channel.
* Do no blindly go off/on channel in work.c Instead, only call
appropriate on/off code when we really need to change channels.
Always enable offchannel-ps mode when starting work,
and disable it when we are done.
* Consolidate ieee80211_offchannel_stop_station and
ieee80211_offchannel_stop_beaconing, call it
ieee80211_offchannel_stop_vifs instead.
* Accept non-beacon frames when scanning on operating channel.
* Scan state machine optimized to minimize on/off channel
transitions. Also, when going on-channel, go ahead and
re-enable beaconing. We're going to be there for 200ms,
so seems like some useful beaconing could happen.
Always enable offchannel-ps mode when starting software
scan, and disable it when we are done.
* Grab local->mtx earlier in __ieee80211_scan_completed_finish
so that we are protected when calling hw_config(), etc.
* Pass probe-responses up the stack if scanning on local
channel, so that mlme can take a look.
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2011-02-05 03:54:17 +08:00
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
/* give connection some time to breathe */
|
|
|
|
run_again(local, jiffies + HZ/2);
|
|
|
|
}
|
|
|
|
|
2010-04-09 18:07:55 +08:00
|
|
|
if (list_empty(&local->work_list) && local->scan_req &&
|
|
|
|
!local->scanning)
|
2009-12-23 20:15:35 +08:00
|
|
|
ieee80211_queue_delayed_work(&local->hw,
|
|
|
|
&local->scan_work,
|
|
|
|
round_jiffies_relative(0));
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
ieee80211_recalc_idle(local);
|
|
|
|
|
2010-08-05 23:02:38 +08:00
|
|
|
mutex_unlock(&local->mtx);
|
|
|
|
|
2009-12-23 20:15:35 +08:00
|
|
|
list_for_each_entry_safe(wk, tmp, &free_work, list) {
|
|
|
|
wk->done(wk, NULL);
|
|
|
|
list_del(&wk->list);
|
|
|
|
kfree(wk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ieee80211_add_work(struct ieee80211_work *wk)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local;
|
|
|
|
|
|
|
|
if (WARN_ON(!wk->chan))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (WARN_ON(!wk->sdata))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (WARN_ON(!wk->done))
|
|
|
|
return;
|
|
|
|
|
2010-01-06 22:30:58 +08:00
|
|
|
if (WARN_ON(!ieee80211_sdata_running(wk->sdata)))
|
|
|
|
return;
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->started = false;
|
2009-12-23 20:15:35 +08:00
|
|
|
|
|
|
|
local = wk->sdata->local;
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_lock(&local->mtx);
|
2009-12-23 20:15:35 +08:00
|
|
|
list_add_tail(&wk->list, &local->work_list);
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_unlock(&local->mtx);
|
2009-12-23 20:15:35 +08:00
|
|
|
|
|
|
|
ieee80211_queue_work(&local->hw, &local->work_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ieee80211_work_init(struct ieee80211_local *local)
|
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&local->work_list);
|
|
|
|
setup_timer(&local->work_timer, ieee80211_work_timer,
|
|
|
|
(unsigned long)local);
|
|
|
|
INIT_WORK(&local->work_work, ieee80211_work_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = sdata->local;
|
2009-12-23 20:15:42 +08:00
|
|
|
struct ieee80211_work *wk;
|
2010-12-13 21:43:51 +08:00
|
|
|
bool cleanup = false;
|
2009-12-23 20:15:35 +08:00
|
|
|
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_lock(&local->mtx);
|
2009-12-23 20:15:42 +08:00
|
|
|
list_for_each_entry(wk, &local->work_list, list) {
|
2009-12-23 20:15:35 +08:00
|
|
|
if (wk->sdata != sdata)
|
|
|
|
continue;
|
2010-12-13 21:43:51 +08:00
|
|
|
cleanup = true;
|
2009-12-23 20:15:42 +08:00
|
|
|
wk->type = IEEE80211_WORK_ABORT;
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->started = true;
|
|
|
|
wk->timeout = jiffies;
|
2009-12-23 20:15:42 +08:00
|
|
|
}
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_unlock(&local->mtx);
|
2009-12-23 20:15:42 +08:00
|
|
|
|
|
|
|
/* run cleanups etc. */
|
2010-12-13 21:43:51 +08:00
|
|
|
if (cleanup)
|
|
|
|
ieee80211_work_work(&local->work_work);
|
2009-12-23 20:15:42 +08:00
|
|
|
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_lock(&local->mtx);
|
2009-12-23 20:15:42 +08:00
|
|
|
list_for_each_entry(wk, &local->work_list, list) {
|
|
|
|
if (wk->sdata != sdata)
|
|
|
|
continue;
|
|
|
|
WARN_ON(1);
|
|
|
|
break;
|
2009-12-23 20:15:35 +08:00
|
|
|
}
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_unlock(&local->mtx);
|
2009-12-23 20:15:35 +08:00
|
|
|
}
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
static enum work_done_result ieee80211_remain_done(struct ieee80211_work *wk,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We are done serving the remain-on-channel command.
|
|
|
|
*/
|
2009-12-30 20:42:20 +08:00
|
|
|
cfg80211_remain_on_channel_expired(wk->sdata->dev, (unsigned long) wk,
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->chan, wk->chan_type,
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
|
|
|
return WORK_DONE_DESTROY;
|
|
|
|
}
|
|
|
|
|
2009-12-23 20:15:42 +08:00
|
|
|
int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata,
|
|
|
|
struct ieee80211_channel *chan,
|
|
|
|
enum nl80211_channel_type channel_type,
|
|
|
|
unsigned int duration, u64 *cookie)
|
|
|
|
{
|
|
|
|
struct ieee80211_work *wk;
|
|
|
|
|
|
|
|
wk = kzalloc(sizeof(*wk), GFP_KERNEL);
|
|
|
|
if (!wk)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
wk->type = IEEE80211_WORK_REMAIN_ON_CHANNEL;
|
|
|
|
wk->chan = chan;
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->chan_type = channel_type;
|
2009-12-23 20:15:42 +08:00
|
|
|
wk->sdata = sdata;
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->done = ieee80211_remain_done;
|
2009-12-23 20:15:42 +08:00
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->remain.duration = duration;
|
2009-12-23 20:15:42 +08:00
|
|
|
|
2009-12-30 20:42:20 +08:00
|
|
|
*cookie = (unsigned long) wk;
|
2009-12-23 20:15:42 +08:00
|
|
|
|
|
|
|
ieee80211_add_work(wk);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_wk_cancel_remain_on_channel(struct ieee80211_sub_if_data *sdata,
|
|
|
|
u64 cookie)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
struct ieee80211_work *wk, *tmp;
|
|
|
|
bool found = false;
|
|
|
|
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_lock(&local->mtx);
|
2009-12-23 20:15:42 +08:00
|
|
|
list_for_each_entry_safe(wk, tmp, &local->work_list, list) {
|
2009-12-30 20:42:20 +08:00
|
|
|
if ((unsigned long) wk == cookie) {
|
2009-12-23 20:15:43 +08:00
|
|
|
wk->timeout = jiffies;
|
2009-12-23 20:15:42 +08:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-07-30 22:46:07 +08:00
|
|
|
mutex_unlock(&local->mtx);
|
2009-12-23 20:15:42 +08:00
|
|
|
|
|
|
|
if (!found)
|
|
|
|
return -ENOENT;
|
|
|
|
|
2009-12-23 20:15:43 +08:00
|
|
|
ieee80211_queue_work(&local->hw, &local->work_work);
|
2009-12-23 20:15:42 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|