31
#define IEEE80211_MAX_NULLFUNC_TRIES 2
32
#define IEEE80211_MAX_PROBE_TRIES 5
31
static int max_nullfunc_tries = 2;
32
module_param(max_nullfunc_tries, int, 0644);
33
MODULE_PARM_DESC(max_nullfunc_tries,
34
"Maximum nullfunc tx tries before disconnecting (reason 4).");
36
static int max_probe_tries = 5;
37
module_param(max_probe_tries, int, 0644);
38
MODULE_PARM_DESC(max_probe_tries,
39
"Maximum probe tries before disconnecting (reason 4).");
35
42
* Beacon loss timeout is calculated as N frames times the
51
58
* a probe request because of beacon loss or for
52
59
* checking the connection still works.
54
#define IEEE80211_PROBE_WAIT (HZ / 2)
61
static int probe_wait_ms = 500;
62
module_param(probe_wait_ms, int, 0644);
63
MODULE_PARM_DESC(probe_wait_ms,
64
"Maximum time(ms) to wait for probe response"
65
" before disconnecting (reason 4).");
57
68
* Weight given to the latest Beacon frame when calculating average signal
79
90
/* no action required */
82
/* caller must call cfg80211_send_rx_auth() */
83
RX_MGMT_CFG80211_AUTH,
85
/* caller must call cfg80211_send_rx_assoc() */
86
RX_MGMT_CFG80211_ASSOC,
88
93
/* caller must call cfg80211_send_deauth() */
89
94
RX_MGMT_CFG80211_DEAUTH,
91
96
/* caller must call cfg80211_send_disassoc() */
92
97
RX_MGMT_CFG80211_DISASSOC,
94
/* caller must tell cfg80211 about internal error */
95
RX_MGMT_CFG80211_ASSOC_ERROR,
174
180
if (!sband->ht_cap.ht_supported)
175
181
enable_ht = false;
177
/* check that channel matches the right operating channel */
178
if (local->hw.conf.channel->center_freq !=
179
ieee80211_channel_to_frequency(hti->control_chan))
184
hti_cfreq = ieee80211_channel_to_frequency(hti->control_chan,
186
/* check that channel matches the right operating channel */
187
if (local->hw.conf.channel->center_freq != hti_cfreq) {
188
/* Some APs mess this up, evidently.
189
* Netgear WNDR3700 sometimes reports 4 higher than
190
* the actual channel, for instance.
193
"%s: Wrong control channel in association"
194
" response: configured center-freq: %d"
195
" hti-cfreq: %d hti->control_chan: %d"
196
" band: %d. Disabling HT.\n",
198
local->hw.conf.channel->center_freq,
199
hti_cfreq, hti->control_chan,
183
206
channel_type = NL80211_CHAN_HT20;
429
452
container_of((void *)bss, struct cfg80211_bss, priv);
430
453
struct ieee80211_channel *new_ch;
431
454
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
432
int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num);
455
int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
456
cbss->channel->band);
434
458
ASSERT_MGD_MTX(ifmgd);
607
static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data *sdata)
609
struct ieee80211_if_managed *mgd = &sdata->u.mgd;
610
struct sta_info *sta = NULL;
616
if (!mgd->associated)
619
if (!mgd->associated->beacon_ies)
622
if (mgd->flags & (IEEE80211_STA_BEACON_POLL |
623
IEEE80211_STA_CONNECTION_POLL))
627
sta = sta_info_get(sdata, mgd->bssid);
629
sta_flags = get_sta_flags(sta);
632
if (!(sta_flags & WLAN_STA_AUTHORIZED))
583
638
/* need to hold RTNL or interface lock */
584
639
void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency)
600
655
list_for_each_entry(sdata, &local->interfaces, list) {
601
656
if (!ieee80211_sdata_running(sdata))
658
if (sdata->vif.type == NL80211_IFTYPE_AP) {
659
/* If an AP vif is found, then disable PS
660
* by setting the count to zero thereby setting
603
666
if (sdata->vif.type != NL80211_IFTYPE_STATION)
609
if (count == 1 && found->u.mgd.powersave &&
610
found->u.mgd.associated &&
611
found->u.mgd.associated->beacon_ies &&
612
!(found->u.mgd.flags & (IEEE80211_STA_BEACON_POLL |
613
IEEE80211_STA_CONNECTION_POLL))) {
672
if (count == 1 && ieee80211_powersave_allowed(found)) {
614
673
struct ieee80211_conf *conf = &local->hw.conf;
615
674
s32 beaconint_us;
699
760
if (local->hw.conf.flags & IEEE80211_CONF_PS)
764
* transmission can be stopped by others which leads to
765
* dynamic_ps_timer expiry. Postpond the ps timer if it
766
* is not the actual idle state.
768
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
769
for (q = 0; q < local->hw.queues; q++) {
770
if (local->queue_stop_reasons[q]) {
771
spin_unlock_irqrestore(&local->queue_stop_reason_lock,
773
mod_timer(&local->dynamic_ps_timer, jiffies +
775
local->hw.conf.dynamic_ps_timeout));
779
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
702
781
if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
703
(!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)))
704
ieee80211_send_nullfunc(local, sdata, 1);
782
(!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED))) {
783
netif_tx_stop_all_queues(sdata->dev);
785
if (drv_tx_frames_pending(local))
786
mod_timer(&local->dynamic_ps_timer, jiffies +
788
local->hw.conf.dynamic_ps_timeout));
790
ieee80211_send_nullfunc(local, sdata, 1);
791
/* Flush to get the tx status of nullfunc frame */
792
drv_flush(local, false);
706
796
if (!((local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) &&
707
797
(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) ||
710
800
local->hw.conf.flags |= IEEE80211_CONF_PS;
711
801
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
804
netif_tx_wake_all_queues(sdata->dev);
715
807
void ieee80211_dynamic_ps_timer(unsigned long data)
1095
1182
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1096
1183
const u8 *ssid;
1097
1184
u8 *dst = ifmgd->associated->bssid;
1098
u8 unicast_limit = max(1, IEEE80211_MAX_PROBE_TRIES - 3);
1185
u8 unicast_limit = max(1, max_probe_tries - 3);
1101
1188
* Try sending broadcast probe requests for the last three
1123
1210
ifmgd->probe_send_count++;
1124
ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT;
1211
ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms);
1125
1212
run_again(ifmgd, ifmgd->probe_timeout);
1223
1310
memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
1225
printk(KERN_DEBUG "Connection to AP %pM lost.\n", bssid);
1312
printk(KERN_DEBUG "%s: Connection to AP %pM lost.\n",
1313
sdata->name, bssid);
1227
1315
ieee80211_set_disassoc(sdata, true, true);
1228
1316
mutex_unlock(&ifmgd->mtx);
1966
2055
memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
1968
2057
if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
1969
max_tries = IEEE80211_MAX_NULLFUNC_TRIES;
2058
max_tries = max_nullfunc_tries;
1971
max_tries = IEEE80211_MAX_PROBE_TRIES;
2060
max_tries = max_probe_tries;
1973
2062
/* ACK received for nullfunc probing frame */
1974
2063
if (!ifmgd->probe_send_count)
1978
2067
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1979
2068
wiphy_debug(local->hw.wiphy,
1980
2069
"%s: No ack for nullfunc frame to"
1981
" AP %pM, try %d\n",
2070
" AP %pM, try %d/%i\n",
1982
2071
sdata->name, bssid,
1983
ifmgd->probe_send_count);
2072
ifmgd->probe_send_count, max_tries);
1985
2074
ieee80211_mgd_probe_ap_send(sdata);
2000
2089
"%s: Failed to send nullfunc to AP %pM"
2001
2090
" after %dms, disconnecting.\n",
2003
bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
2092
bssid, probe_wait_ms);
2005
2094
ieee80211_sta_connection_lost(sdata, bssid);
2006
2095
} else if (ifmgd->probe_send_count < max_tries) {
2007
2096
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
2008
2097
wiphy_debug(local->hw.wiphy,
2009
2098
"%s: No probe response from AP %pM"
2010
" after %dms, try %d\n",
2099
" after %dms, try %d/%i\n",
2012
bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ,
2013
ifmgd->probe_send_count);
2101
bssid, probe_wait_ms,
2102
ifmgd->probe_send_count, max_tries);
2015
2104
ieee80211_mgd_probe_ap_send(sdata);
2022
2111
"%s: No probe response from AP %pM"
2023
2112
" after %dms, disconnecting.\n",
2025
bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
2114
bssid, probe_wait_ms);
2027
2116
ieee80211_sta_connection_lost(sdata, bssid);
2409
2499
memcpy(wk->assoc.prev_bssid, req->prev_bssid, ETH_ALEN);
2411
2501
wk->chan = req->bss->channel;
2502
wk->chan_type = NL80211_CHAN_NO_HT;
2412
2503
wk->sdata = sdata;
2413
2504
wk->done = ieee80211_assoc_done;
2414
2505
if (!bss->dtim_period &&