diff options
Diffstat (limited to 'net/mac80211/mesh_sync.c')
-rw-r--r-- | net/mac80211/mesh_sync.c | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c index aa8d1e437385..05a256b38e24 100644 --- a/net/mac80211/mesh_sync.c +++ b/net/mac80211/mesh_sync.c | |||
@@ -43,7 +43,7 @@ struct sync_method { | |||
43 | static bool mesh_peer_tbtt_adjusting(struct ieee802_11_elems *ie) | 43 | static bool mesh_peer_tbtt_adjusting(struct ieee802_11_elems *ie) |
44 | { | 44 | { |
45 | return (ie->mesh_config->meshconf_cap & | 45 | return (ie->mesh_config->meshconf_cap & |
46 | IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING) != 0; | 46 | IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING) != 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata) | 49 | void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata) |
@@ -112,7 +112,8 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
112 | 112 | ||
113 | if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) { | 113 | if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) { |
114 | clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); | 114 | clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); |
115 | msync_dbg(sdata, "STA %pM : is adjusting TBTT\n", sta->sta.addr); | 115 | msync_dbg(sdata, "STA %pM : is adjusting TBTT\n", |
116 | sta->sta.addr); | ||
116 | goto no_sync; | 117 | goto no_sync; |
117 | } | 118 | } |
118 | 119 | ||
@@ -129,18 +130,15 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
129 | sta->t_offset = t_t - t_r; | 130 | sta->t_offset = t_t - t_r; |
130 | 131 | ||
131 | if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { | 132 | if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { |
132 | s64 t_clockdrift = sta->t_offset_setpoint | 133 | s64 t_clockdrift = sta->t_offset_setpoint - sta->t_offset; |
133 | - sta->t_offset; | ||
134 | msync_dbg(sdata, | 134 | msync_dbg(sdata, |
135 | "STA %pM : sta->t_offset=%lld, sta->t_offset_setpoint=%lld, t_clockdrift=%lld\n", | 135 | "STA %pM : sta->t_offset=%lld, sta->t_offset_setpoint=%lld, t_clockdrift=%lld\n", |
136 | sta->sta.addr, | 136 | sta->sta.addr, (long long) sta->t_offset, |
137 | (long long) sta->t_offset, | 137 | (long long) sta->t_offset_setpoint, |
138 | (long long) | ||
139 | sta->t_offset_setpoint, | ||
140 | (long long) t_clockdrift); | 138 | (long long) t_clockdrift); |
141 | 139 | ||
142 | if (t_clockdrift > TOFFSET_MAXIMUM_ADJUSTMENT || | 140 | if (t_clockdrift > TOFFSET_MAXIMUM_ADJUSTMENT || |
143 | t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) { | 141 | t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) { |
144 | msync_dbg(sdata, | 142 | msync_dbg(sdata, |
145 | "STA %pM : t_clockdrift=%lld too large, setpoint reset\n", | 143 | "STA %pM : t_clockdrift=%lld too large, setpoint reset\n", |
146 | sta->sta.addr, | 144 | sta->sta.addr, |
@@ -149,15 +147,10 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
149 | goto no_sync; | 147 | goto no_sync; |
150 | } | 148 | } |
151 | 149 | ||
152 | rcu_read_unlock(); | ||
153 | |||
154 | spin_lock_bh(&ifmsh->sync_offset_lock); | 150 | spin_lock_bh(&ifmsh->sync_offset_lock); |
155 | if (t_clockdrift > | 151 | if (t_clockdrift > ifmsh->sync_offset_clockdrift_max) |
156 | ifmsh->sync_offset_clockdrift_max) | 152 | ifmsh->sync_offset_clockdrift_max = t_clockdrift; |
157 | ifmsh->sync_offset_clockdrift_max | ||
158 | = t_clockdrift; | ||
159 | spin_unlock_bh(&ifmsh->sync_offset_lock); | 153 | spin_unlock_bh(&ifmsh->sync_offset_lock); |
160 | |||
161 | } else { | 154 | } else { |
162 | sta->t_offset_setpoint = sta->t_offset - TOFFSET_SET_MARGIN; | 155 | sta->t_offset_setpoint = sta->t_offset - TOFFSET_SET_MARGIN; |
163 | set_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); | 156 | set_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); |
@@ -165,9 +158,7 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
165 | "STA %pM : offset was invalid, sta->t_offset=%lld\n", | 158 | "STA %pM : offset was invalid, sta->t_offset=%lld\n", |
166 | sta->sta.addr, | 159 | sta->sta.addr, |
167 | (long long) sta->t_offset); | 160 | (long long) sta->t_offset); |
168 | rcu_read_unlock(); | ||
169 | } | 161 | } |
170 | return; | ||
171 | 162 | ||
172 | no_sync: | 163 | no_sync: |
173 | rcu_read_unlock(); | 164 | rcu_read_unlock(); |
@@ -177,14 +168,12 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata) | |||
177 | { | 168 | { |
178 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 169 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
179 | 170 | ||
180 | WARN_ON(ifmsh->mesh_sp_id | 171 | WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); |
181 | != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); | ||
182 | BUG_ON(!rcu_read_lock_held()); | 172 | BUG_ON(!rcu_read_lock_held()); |
183 | 173 | ||
184 | spin_lock_bh(&ifmsh->sync_offset_lock); | 174 | spin_lock_bh(&ifmsh->sync_offset_lock); |
185 | 175 | ||
186 | if (ifmsh->sync_offset_clockdrift_max > | 176 | if (ifmsh->sync_offset_clockdrift_max > TOFFSET_MINIMUM_ADJUSTMENT) { |
187 | TOFFSET_MINIMUM_ADJUSTMENT) { | ||
188 | /* Since ajusting the tsf here would | 177 | /* Since ajusting the tsf here would |
189 | * require a possibly blocking call | 178 | * require a possibly blocking call |
190 | * to the driver tsf setter, we punt | 179 | * to the driver tsf setter, we punt |
@@ -193,8 +182,7 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata) | |||
193 | msync_dbg(sdata, | 182 | msync_dbg(sdata, |
194 | "TBTT : kicking off TBTT adjustment with clockdrift_max=%lld\n", | 183 | "TBTT : kicking off TBTT adjustment with clockdrift_max=%lld\n", |
195 | ifmsh->sync_offset_clockdrift_max); | 184 | ifmsh->sync_offset_clockdrift_max); |
196 | set_bit(MESH_WORK_DRIFT_ADJUST, | 185 | set_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags); |
197 | &ifmsh->wrkq_flags); | ||
198 | 186 | ||
199 | ifmsh->adjusting_tbtt = true; | 187 | ifmsh->adjusting_tbtt = true; |
200 | } else { | 188 | } else { |
@@ -220,14 +208,11 @@ static const struct sync_method sync_methods[] = { | |||
220 | 208 | ||
221 | const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method) | 209 | const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method) |
222 | { | 210 | { |
223 | const struct ieee80211_mesh_sync_ops *ops = NULL; | 211 | int i; |
224 | u8 i; | ||
225 | 212 | ||
226 | for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) { | 213 | for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) { |
227 | if (sync_methods[i].method == method) { | 214 | if (sync_methods[i].method == method) |
228 | ops = &sync_methods[i].ops; | 215 | return &sync_methods[i].ops; |
229 | break; | ||
230 | } | ||
231 | } | 216 | } |
232 | return ops; | 217 | return NULL; |
233 | } | 218 | } |