package/madwifi: refresh madwifi patches
[openwrt/openwrt.git] / package / madwifi / patches / 361-bmiss_handling.patch
1 Improve the beacon miss handling. Instead of just dropping the connection,
2 send a directed probe request to the AP to see if it's still responding.
3 Schedule a software beacon miss timer in this case, which adds a timeout
4 for the APs probe response.
5
6 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
7
8 --- a/net80211/ieee80211_input.c
9 +++ b/net80211/ieee80211_input.c
10 @@ -3400,12 +3400,17 @@ ieee80211_recv_mgmt(struct ieee80211vap
11 }
12
13 /* WDS/Repeater: re-schedule software beacon timer for
14 - * STA. */
15 - if ((vap->iv_state == IEEE80211_S_RUN) &&
16 - (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS)) {
17 - mod_timer(&vap->iv_swbmiss,
18 + * STA. Reset consecutive bmiss counter as well */
19 + IEEE80211_LOCK_IRQ(ic);
20 + if (vap->iv_state == IEEE80211_S_RUN) {
21 + vap->iv_bmiss_count = 0;
22 + if (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS)
23 + mod_timer(&vap->iv_swbmiss,
24 jiffies + vap->iv_swbmiss_period);
25 + else
26 + del_timer(&vap->iv_swbmiss);
27 }
28 + IEEE80211_UNLOCK_IRQ(ic);
29
30 /* If scanning, pass the info to the scan module.
31 * Otherwise, check if it's the right time to do
32 --- a/net80211/ieee80211_proto.c
33 +++ b/net80211/ieee80211_proto.c
34 @@ -1209,6 +1209,8 @@ ieee80211_beacon_miss(struct ieee80211co
35 }
36 /* XXX locking */
37 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
38 + int count;
39 +
40 IEEE80211_DPRINTF(vap,
41 IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
42 "%s\n", "beacon miss");
43 @@ -1221,6 +1223,29 @@ ieee80211_beacon_miss(struct ieee80211co
44 if (vap->iv_opmode != IEEE80211_M_STA ||
45 vap->iv_state != IEEE80211_S_RUN)
46 continue;
47 +
48 + IEEE80211_LOCK_IRQ(ic);
49 + count = vap->iv_bmiss_count++;
50 + if (count) {
51 + /* if the counter was already above zero, reset it
52 + * here, since we're going to do the bmiss handling
53 + * in any case */
54 + vap->iv_bmiss_count = 0;
55 + } else {
56 + /* schedule the software beacon miss timer, it will be
57 + * cancelled, if the probe request is acked */
58 + mod_timer(&vap->iv_swbmiss, jiffies + vap->iv_swbmiss_period);
59 + }
60 + IEEE80211_UNLOCK_IRQ(ic);
61 +
62 + if (!count) {
63 + ieee80211_send_probereq(vap->iv_bss, vap->iv_myaddr,
64 + vap->iv_bss->ni_bssid, vap->iv_bss->ni_bssid,
65 + vap->iv_bss->ni_essid, vap->iv_bss->ni_esslen,
66 + NULL, 0);
67 + continue;
68 + }
69 +
70 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
71 #ifdef ATH_SUPERG_DYNTURBO
72 /*
73 @@ -1621,14 +1646,14 @@ __ieee80211_newstate(struct ieee80211vap
74 }
75
76 /* WDS/Repeater: Start software beacon timer for STA */
77 + vap->iv_swbmiss.function = ieee80211_sta_swbmiss;
78 + vap->iv_swbmiss.data = (unsigned long) vap;
79 + vap->iv_swbmiss_period = IEEE80211_TU_TO_JIFFIES(
80 + vap->iv_ic->ic_bmissthreshold * ni->ni_intval);
81 +
82 if (ostate != IEEE80211_S_RUN &&
83 (vap->iv_opmode == IEEE80211_M_STA &&
84 vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS)) {
85 - vap->iv_swbmiss.function = ieee80211_sta_swbmiss;
86 - vap->iv_swbmiss.data = (unsigned long) vap;
87 - vap->iv_swbmiss_period = IEEE80211_TU_TO_JIFFIES(
88 - vap->iv_ic->ic_bmissthreshold * ni->ni_intval);
89 -
90 mod_timer(&vap->iv_swbmiss, jiffies + vap->iv_swbmiss_period);
91 }
92
93 --- a/net80211/ieee80211_var.h
94 +++ b/net80211/ieee80211_var.h
95 @@ -283,6 +283,7 @@ struct ieee80211vap {
96
97 struct timer_list iv_swbmiss; /* software beacon miss timer */
98 u_int16_t iv_swbmiss_period; /* software beacon miss timer period */
99 + u_int16_t iv_bmiss_count; /* consecutive beacon miss counter */
100 struct ieee80211_nsparams iv_nsparams; /* new state parameters for tasklet for stajoin1 */
101 struct IEEE80211_TQ_STRUCT iv_stajoin1tq; /* tasklet for newstate action called from stajoin1tq */
102 unsigned int iv_nsdone; /* Done with scheduled newstate tasklet */