aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mesh_sync.c
diff options
context:
space:
mode:
authorJavier Cardona <javier@cozybit.com>2012-04-12 17:32:22 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-04-16 14:19:29 -0400
commita802a6eba13282ddd5718f8db9d476e42e84e2ba (patch)
tree3d33cd0424d8c227260a748f35f2d5a4ff43b72c /net/mac80211/mesh_sync.c
parentb6ba82c893c48cfe48a98ee3dc50011832e764bd (diff)
mac80211: Choose a new toffset setpoint if a big tsf jump is detected.
Signed-off-by: Javier Cardona <javier@cozybit.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_sync.c')
-rw-r--r--net/mac80211/mesh_sync.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c
index f78b0139856f..22a5f1e66996 100644
--- a/net/mac80211/mesh_sync.c
+++ b/net/mac80211/mesh_sync.c
@@ -22,7 +22,14 @@
22/* This is not in the standard. It represents a tolerable tbtt drift below 22/* This is not in the standard. It represents a tolerable tbtt drift below
23 * which we do no TSF adjustment. 23 * which we do no TSF adjustment.
24 */ 24 */
25#define TBTT_MINIMUM_ADJUSTMENT 10 25#define TOFFSET_MINIMUM_ADJUSTMENT 10
26
27/* This is not in the standard. It represents the maximum Toffset jump above
28 * which we'll invalidate the Toffset setpoint and choose a new setpoint. This
29 * could be, for instance, in case a neighbor is restarted and its TSF counter
30 * reset.
31 * */
32#define TOFFSET_MAXIMUM_ADJUSTMENT 30000 /* 30 ms */
26 33
27struct sync_method { 34struct sync_method {
28 u8 method; 35 u8 method;
@@ -156,15 +163,22 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
156 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { 163 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
157 s64 t_clockdrift = sta->t_offset_setpoint 164 s64 t_clockdrift = sta->t_offset_setpoint
158 - sta->t_offset; 165 - sta->t_offset;
159 166 msync_dbg("STA %pM : sta->t_offset=%lld, sta->t_offset_setpoint=%lld, t_clockdrift=%lld",
160 msync_dbg("STA %pM : sta->t_offset=%lld,"
161 " sta->t_offset_setpoint=%lld,"
162 " t_clockdrift=%lld",
163 sta->sta.addr, 167 sta->sta.addr,
164 (long long) sta->t_offset, 168 (long long) sta->t_offset,
165 (long long) 169 (long long)
166 sta->t_offset_setpoint, 170 sta->t_offset_setpoint,
167 (long long) t_clockdrift); 171 (long long) t_clockdrift);
172
173 if (t_clockdrift > TOFFSET_MAXIMUM_ADJUSTMENT ||
174 t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) {
175 msync_dbg("STA %pM : t_clockdrift=%lld too large, setpoint reset",
176 sta->sta.addr,
177 (long long) t_clockdrift);
178 clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN);
179 goto no_sync;
180 }
181
168 rcu_read_unlock(); 182 rcu_read_unlock();
169 183
170 spin_lock_bh(&ifmsh->sync_offset_lock); 184 spin_lock_bh(&ifmsh->sync_offset_lock);
@@ -200,7 +214,7 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata)
200 spin_lock_bh(&ifmsh->sync_offset_lock); 214 spin_lock_bh(&ifmsh->sync_offset_lock);
201 215
202 if (ifmsh->sync_offset_clockdrift_max > 216 if (ifmsh->sync_offset_clockdrift_max >
203 TBTT_MINIMUM_ADJUSTMENT) { 217 TOFFSET_MINIMUM_ADJUSTMENT) {
204 /* Since ajusting the tsf here would 218 /* Since ajusting the tsf here would
205 * require a possibly blocking call 219 * require a possibly blocking call
206 * to the driver tsf setter, we punt 220 * to the driver tsf setter, we punt