From 44713c41b7857936322397eb8f75d14b6e913d4b Mon Sep 17 00:00:00 2001 From: Wei Ni Date: Tue, 22 Nov 2011 18:17:43 +0800 Subject: mac80211 & nl80211: add support to abort a scan request on tx This fix comes from: https://gerrit.chromium.org/gerrit/#change,5744 https://gerrit.chromium.org/gerrit/#change,5745 So that it can work with the related wpa_supplicant tool. BUG=895591 Change-Id: Ie81f6d6052bd45dab13c936f9f0c5f4eb277496a Original-Signed-off-by: Wei Ni Signed-off-by: Rhyland Klein Reviewed-on: http://git-master/r/111333 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bharat Nihalani --- net/mac80211/scan.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'net/mac80211/scan.c') diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 6f09eca01112..4aa2cec04f31 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -477,6 +477,7 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local, unsigned long min_beacon_int = 0; struct ieee80211_sub_if_data *sdata; struct ieee80211_channel *next_chan; + enum mac80211_scan_state next_scan_state; /* * check if at least one STA interface is associated, @@ -512,13 +513,21 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local, /* We're currently on operating channel. */ if (next_chan == local->oper_channel) /* We don't need to move off of operating channel. */ - local->next_scan_state = SCAN_SET_CHANNEL; - else + next_scan_state = SCAN_SET_CHANNEL; + else { /* * We do need to leave operating channel, as next - * scan is somewhere else. + * scan is somewhere else, unless + * there is pending traffic and the scan request is + * marked to abort when this happens */ - local->next_scan_state = SCAN_LEAVE_OPER_CHANNEL; + if (associated && !tx_empty && + (local->scan_req->flags & + CFG80211_SCAN_FLAG_TX_ABORT)) + next_scan_state = SCAN_ABORT; + else + next_scan_state = SCAN_LEAVE_OPER_CHANNEL; + } } else { /* * we're currently scanning a different channel, let's @@ -547,12 +556,24 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local, usecs_to_jiffies(min_beacon_int * 1024) * local->hw.conf.listen_interval); - if (associated && ( !tx_empty || bad_latency || - listen_int_exceeded)) - local->next_scan_state = SCAN_ENTER_OPER_CHANNEL; + if (associated && !tx_empty) { + if (unlikely(local->scan_req->flags & + CFG80211_SCAN_FLAG_TX_ABORT)) { + /* + * Scan request is marked to abort when there + * is outbound traffic. Mark state to return + * the operating channel and then abort. This + * happens as soon as possible. + */ + next_scan_state = SCAN_ENTER_OPER_CHANNEL_ABORT; + } else + next_scan_state = SCAN_ENTER_OPER_CHANNEL; + } else if (associated && (bad_latency || listen_int_exceeded)) + next_scan_state = SCAN_ENTER_OPER_CHANNEL; else - local->next_scan_state = SCAN_SET_CHANNEL; + next_scan_state = SCAN_SET_CHANNEL; } + local->next_scan_state = next_scan_state; *next_delay = 0; } @@ -596,8 +617,13 @@ static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *loca */ ieee80211_offchannel_return(local, true, false); - *next_delay = HZ / 5; - local->next_scan_state = SCAN_DECISION; + if (local->next_scan_state == SCAN_ENTER_OPER_CHANNEL) { + *next_delay = HZ / 5; + local->next_scan_state = SCAN_DECISION; + } else { + *next_delay = 0; + local->next_scan_state = SCAN_ABORT; + } } static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, @@ -741,11 +767,15 @@ void ieee80211_scan_work(struct work_struct *work) ieee80211_scan_state_send_probe(local, &next_delay); break; case SCAN_LEAVE_OPER_CHANNEL: + case SCAN_ENTER_OPER_CHANNEL_ABORT: ieee80211_scan_state_leave_oper_channel(local, &next_delay); break; case SCAN_ENTER_OPER_CHANNEL: ieee80211_scan_state_enter_oper_channel(local, &next_delay); break; + case SCAN_ABORT: + aborted = true; + goto out_complete; } } while (next_delay == 0); -- cgit v1.2.3