huge madwifi update (work in progress, disabled by default, compiles but breaks at...
[librecmc/librecmc.git] / package / madwifi / patches-r3776 / 326-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 Index: madwifi-trunk-r3776/net80211/ieee80211_input.c
9 ===================================================================
10 --- madwifi-trunk-r3776.orig/net80211/ieee80211_input.c 2008-07-17 04:03:07.000000000 +0200
11 +++ madwifi-trunk-r3776/net80211/ieee80211_input.c      2008-07-17 04:06:33.000000000 +0200
12 @@ -3369,12 +3369,17 @@
13                         }
14  
15                         /* WDS/Repeater: re-schedule software beacon timer for 
16 -                        * STA. */
17 -                       if ((vap->iv_state == IEEE80211_S_RUN) &&
18 -                           (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS)) {
19 -                               mod_timer(&vap->iv_swbmiss, 
20 +                        * STA. Reset consecutive bmiss counter as well */
21 +                       IEEE80211_LOCK_IRQ(ic);
22 +                       if (vap->iv_state == IEEE80211_S_RUN) {
23 +                               vap->iv_bmiss_count = 0;
24 +                               if (vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS)
25 +                                       mod_timer(&vap->iv_swbmiss,
26                                                 jiffies + vap->iv_swbmiss_period);
27 +                               else
28 +                                       del_timer(&vap->iv_swbmiss);
29                         }
30 +                       IEEE80211_UNLOCK_IRQ(ic);
31  
32                         /* If scanning, pass the info to the scan module.
33                          * Otherwise, check if it's the right time to do
34 Index: madwifi-trunk-r3776/net80211/ieee80211_proto.c
35 ===================================================================
36 --- madwifi-trunk-r3776.orig/net80211/ieee80211_proto.c 2008-07-17 04:06:18.000000000 +0200
37 +++ madwifi-trunk-r3776/net80211/ieee80211_proto.c      2008-07-17 04:06:33.000000000 +0200
38 @@ -1213,6 +1213,8 @@
39         }
40         /* XXX locking */
41         TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
42 +               int count;
43 +
44                 IEEE80211_DPRINTF(vap,
45                         IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG,
46                         "%s\n", "beacon miss");
47 @@ -1225,6 +1227,29 @@
48                 if (vap->iv_opmode != IEEE80211_M_STA ||
49                     vap->iv_state != IEEE80211_S_RUN)
50                         continue;
51 +
52 +               IEEE80211_LOCK_IRQ(ic);
53 +               count = vap->iv_bmiss_count++;
54 +               if (count) {
55 +                       /* if the counter was already above zero, reset it
56 +                        * here, since we're going to do the bmiss handling
57 +                        * in any case */
58 +                       vap->iv_bmiss_count = 0;
59 +               } else {
60 +                       /* schedule the software beacon miss timer, it will be
61 +                        * cancelled, if the probe request is acked */
62 +                       mod_timer(&vap->iv_swbmiss, jiffies + vap->iv_swbmiss_period);
63 +               }
64 +               IEEE80211_UNLOCK_IRQ(ic);
65 +
66 +               if (!count) {
67 +                       ieee80211_send_probereq(vap->iv_bss, vap->iv_myaddr,
68 +                               vap->iv_bss->ni_bssid, vap->iv_bss->ni_bssid,
69 +                               vap->iv_bss->ni_essid, vap->iv_bss->ni_esslen,
70 +                               NULL, 0);
71 +                       continue;
72 +               }
73 +
74                 if (ic->ic_roaming == IEEE80211_ROAMING_AUTO) {
75  #ifdef ATH_SUPERG_DYNTURBO
76                         /* 
77 @@ -1621,14 +1646,14 @@
78                 }
79  
80                 /* WDS/Repeater: Start software beacon timer for STA */
81 +               vap->iv_swbmiss.function = ieee80211_sta_swbmiss;
82 +               vap->iv_swbmiss.data = (unsigned long) vap;
83 +               vap->iv_swbmiss_period = IEEE80211_TU_TO_JIFFIES(
84 +                       vap->iv_ic->ic_bmissthreshold * ni->ni_intval);
85 +
86                 if (ostate != IEEE80211_S_RUN &&
87                     (vap->iv_opmode == IEEE80211_M_STA &&
88                      vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS)) {
89 -                       vap->iv_swbmiss.function = ieee80211_sta_swbmiss;
90 -                       vap->iv_swbmiss.data = (unsigned long) vap;
91 -                       vap->iv_swbmiss_period = IEEE80211_TU_TO_JIFFIES(
92 -                               vap->iv_ic->ic_bmissthreshold * ni->ni_intval);
93 -
94                         mod_timer(&vap->iv_swbmiss, jiffies + vap->iv_swbmiss_period);
95                 }
96  
97 Index: madwifi-trunk-r3776/net80211/ieee80211_var.h
98 ===================================================================
99 --- madwifi-trunk-r3776.orig/net80211/ieee80211_var.h   2008-07-17 04:03:07.000000000 +0200
100 +++ madwifi-trunk-r3776/net80211/ieee80211_var.h        2008-07-17 04:06:33.000000000 +0200
101 @@ -292,6 +292,7 @@
102  
103         struct timer_list iv_swbmiss;                   /* software beacon miss timer */
104         u_int16_t iv_swbmiss_period;                    /* software beacon miss timer period */
105 +       u_int16_t iv_bmiss_count;                       /* consecutive beacon miss counter */
106         struct ieee80211_nsparams iv_nsparams;          /* new state parameters for tasklet for stajoin1 */
107         struct IEEE80211_TQ_STRUCT iv_stajoin1tq;       /* tasklet for newstate action called from stajoin1tq */
108         unsigned int iv_nsdone;                         /* Done with scheduled newstate tasklet */