diff options
Diffstat (limited to 'net/ieee80211/softmac/ieee80211softmac_module.c')
-rw-r--r-- | net/ieee80211/softmac/ieee80211softmac_module.c | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c index 4b2e57d12418..addea1cf73ae 100644 --- a/net/ieee80211/softmac/ieee80211softmac_module.c +++ b/net/ieee80211/softmac/ieee80211softmac_module.c | |||
@@ -44,6 +44,7 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv) | |||
44 | softmac->ieee->handle_assoc_response = ieee80211softmac_handle_assoc_response; | 44 | softmac->ieee->handle_assoc_response = ieee80211softmac_handle_assoc_response; |
45 | softmac->ieee->handle_reassoc_request = ieee80211softmac_handle_reassoc_req; | 45 | softmac->ieee->handle_reassoc_request = ieee80211softmac_handle_reassoc_req; |
46 | softmac->ieee->handle_disassoc = ieee80211softmac_handle_disassoc; | 46 | softmac->ieee->handle_disassoc = ieee80211softmac_handle_disassoc; |
47 | softmac->ieee->handle_beacon = ieee80211softmac_handle_beacon; | ||
47 | softmac->scaninfo = NULL; | 48 | softmac->scaninfo = NULL; |
48 | 49 | ||
49 | softmac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT; | 50 | softmac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT; |
@@ -178,21 +179,14 @@ int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo | |||
178 | return 0; | 179 | return 0; |
179 | } | 180 | } |
180 | 181 | ||
181 | /* Finds the highest rate which is: | 182 | u8 ieee80211softmac_highest_supported_rate(struct ieee80211softmac_device *mac, |
182 | * 1. Present in ri (optionally a basic rate) | ||
183 | * 2. Supported by the device | ||
184 | * 3. Less than or equal to the user-defined rate | ||
185 | */ | ||
186 | static u8 highest_supported_rate(struct ieee80211softmac_device *mac, | ||
187 | struct ieee80211softmac_ratesinfo *ri, int basic_only) | 183 | struct ieee80211softmac_ratesinfo *ri, int basic_only) |
188 | { | 184 | { |
189 | u8 user_rate = mac->txrates.user_rate; | 185 | u8 user_rate = mac->txrates.user_rate; |
190 | int i; | 186 | int i; |
191 | 187 | ||
192 | if (ri->count == 0) { | 188 | if (ri->count == 0) |
193 | dprintk(KERN_ERR PFX "empty ratesinfo?\n"); | ||
194 | return IEEE80211_CCK_RATE_1MB; | 189 | return IEEE80211_CCK_RATE_1MB; |
195 | } | ||
196 | 190 | ||
197 | for (i = ri->count - 1; i >= 0; i--) { | 191 | for (i = ri->count - 1; i >= 0; i--) { |
198 | u8 rate = ri->rates[i]; | 192 | u8 rate = ri->rates[i]; |
@@ -208,36 +202,61 @@ static u8 highest_supported_rate(struct ieee80211softmac_device *mac, | |||
208 | /* If we haven't found a suitable rate by now, just trust the user */ | 202 | /* If we haven't found a suitable rate by now, just trust the user */ |
209 | return user_rate; | 203 | return user_rate; |
210 | } | 204 | } |
205 | EXPORT_SYMBOL_GPL(ieee80211softmac_highest_supported_rate); | ||
206 | |||
207 | void ieee80211softmac_process_erp(struct ieee80211softmac_device *mac, | ||
208 | u8 erp_value) | ||
209 | { | ||
210 | int use_protection; | ||
211 | int short_preamble; | ||
212 | u32 changes = 0; | ||
213 | |||
214 | /* Barker preamble mode */ | ||
215 | short_preamble = ((erp_value & WLAN_ERP_BARKER_PREAMBLE) == 0 | ||
216 | && mac->associnfo.short_preamble_available) ? 1 : 0; | ||
217 | |||
218 | /* Protection needed? */ | ||
219 | use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0; | ||
220 | |||
221 | if (mac->bssinfo.short_preamble != short_preamble) { | ||
222 | changes |= IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE; | ||
223 | mac->bssinfo.short_preamble = short_preamble; | ||
224 | } | ||
225 | |||
226 | if (mac->bssinfo.use_protection != use_protection) { | ||
227 | changes |= IEEE80211SOFTMAC_BSSINFOCHG_PROTECTION; | ||
228 | mac->bssinfo.use_protection = use_protection; | ||
229 | } | ||
230 | |||
231 | if (mac->bssinfo_change && changes) | ||
232 | mac->bssinfo_change(mac->dev, changes); | ||
233 | } | ||
211 | 234 | ||
212 | void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac) | 235 | void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac) |
213 | { | 236 | { |
214 | struct ieee80211softmac_txrates *txrates = &mac->txrates; | 237 | struct ieee80211softmac_txrates *txrates = &mac->txrates; |
215 | struct ieee80211softmac_txrates oldrates; | ||
216 | u32 change = 0; | 238 | u32 change = 0; |
217 | 239 | ||
218 | if (mac->txrates_change) | ||
219 | oldrates = mac->txrates; | ||
220 | |||
221 | change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; | 240 | change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; |
222 | txrates->default_rate = highest_supported_rate(mac, &mac->associnfo.supported_rates, 0); | 241 | txrates->default_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 0); |
223 | 242 | ||
224 | change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK; | 243 | change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK; |
225 | txrates->default_fallback = lower_rate(mac, txrates->default_rate); | 244 | txrates->default_fallback = lower_rate(mac, txrates->default_rate); |
226 | 245 | ||
227 | change |= IEEE80211SOFTMAC_TXRATECHG_MCAST; | 246 | change |= IEEE80211SOFTMAC_TXRATECHG_MCAST; |
228 | txrates->mcast_rate = highest_supported_rate(mac, &mac->associnfo.supported_rates, 1); | 247 | txrates->mcast_rate = ieee80211softmac_highest_supported_rate(mac, &mac->bssinfo.supported_rates, 1); |
229 | 248 | ||
230 | if (mac->txrates_change) | 249 | if (mac->txrates_change) |
231 | mac->txrates_change(mac->dev, change, &oldrates); | 250 | mac->txrates_change(mac->dev, change); |
232 | 251 | ||
233 | } | 252 | } |
234 | 253 | ||
235 | void ieee80211softmac_init_txrates(struct ieee80211softmac_device *mac) | 254 | void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac) |
236 | { | 255 | { |
237 | struct ieee80211_device *ieee = mac->ieee; | 256 | struct ieee80211_device *ieee = mac->ieee; |
238 | u32 change = 0; | 257 | u32 change = 0; |
239 | struct ieee80211softmac_txrates *txrates = &mac->txrates; | 258 | struct ieee80211softmac_txrates *txrates = &mac->txrates; |
240 | struct ieee80211softmac_txrates oldrates; | 259 | struct ieee80211softmac_bss_info *bssinfo = &mac->bssinfo; |
241 | 260 | ||
242 | /* TODO: We need some kind of state machine to lower the default rates | 261 | /* TODO: We need some kind of state machine to lower the default rates |
243 | * if we loose too many packets. | 262 | * if we loose too many packets. |
@@ -245,8 +264,6 @@ void ieee80211softmac_init_txrates(struct ieee80211softmac_device *mac) | |||
245 | /* Change the default txrate to the highest possible value. | 264 | /* Change the default txrate to the highest possible value. |
246 | * The txrate machine will lower it, if it is too high. | 265 | * The txrate machine will lower it, if it is too high. |
247 | */ | 266 | */ |
248 | if (mac->txrates_change) | ||
249 | oldrates = mac->txrates; | ||
250 | /* FIXME: We don't correctly handle backing down to lower | 267 | /* FIXME: We don't correctly handle backing down to lower |
251 | rates, so 801.11g devices start off at 11M for now. People | 268 | rates, so 801.11g devices start off at 11M for now. People |
252 | can manually change it if they really need to, but 11M is | 269 | can manually change it if they really need to, but 11M is |
@@ -272,7 +289,23 @@ void ieee80211softmac_init_txrates(struct ieee80211softmac_device *mac) | |||
272 | change |= IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST; | 289 | change |= IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST; |
273 | 290 | ||
274 | if (mac->txrates_change) | 291 | if (mac->txrates_change) |
275 | mac->txrates_change(mac->dev, change, &oldrates); | 292 | mac->txrates_change(mac->dev, change); |
293 | |||
294 | change = 0; | ||
295 | |||
296 | bssinfo->supported_rates.count = 0; | ||
297 | memset(bssinfo->supported_rates.rates, 0, | ||
298 | sizeof(bssinfo->supported_rates.rates)); | ||
299 | change |= IEEE80211SOFTMAC_BSSINFOCHG_RATES; | ||
300 | |||
301 | bssinfo->short_preamble = 0; | ||
302 | change |= IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE; | ||
303 | |||
304 | bssinfo->use_protection = 0; | ||
305 | change |= IEEE80211SOFTMAC_BSSINFOCHG_PROTECTION; | ||
306 | |||
307 | if (mac->bssinfo_change) | ||
308 | mac->bssinfo_change(mac->dev, change); | ||
276 | 309 | ||
277 | mac->running = 1; | 310 | mac->running = 1; |
278 | } | 311 | } |
@@ -282,7 +315,7 @@ void ieee80211softmac_start(struct net_device *dev) | |||
282 | struct ieee80211softmac_device *mac = ieee80211_priv(dev); | 315 | struct ieee80211softmac_device *mac = ieee80211_priv(dev); |
283 | 316 | ||
284 | ieee80211softmac_start_check_rates(mac); | 317 | ieee80211softmac_start_check_rates(mac); |
285 | ieee80211softmac_init_txrates(mac); | 318 | ieee80211softmac_init_bss(mac); |
286 | } | 319 | } |
287 | EXPORT_SYMBOL_GPL(ieee80211softmac_start); | 320 | EXPORT_SYMBOL_GPL(ieee80211softmac_start); |
288 | 321 | ||
@@ -335,7 +368,6 @@ u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rat | |||
335 | static void ieee80211softmac_add_txrates_badness(struct ieee80211softmac_device *mac, | 368 | static void ieee80211softmac_add_txrates_badness(struct ieee80211softmac_device *mac, |
336 | int amount) | 369 | int amount) |
337 | { | 370 | { |
338 | struct ieee80211softmac_txrates oldrates; | ||
339 | u8 default_rate = mac->txrates.default_rate; | 371 | u8 default_rate = mac->txrates.default_rate; |
340 | u8 default_fallback = mac->txrates.default_fallback; | 372 | u8 default_fallback = mac->txrates.default_fallback; |
341 | u32 changes = 0; | 373 | u32 changes = 0; |
@@ -348,8 +380,6 @@ printk("badness %d\n", mac->txrate_badness); | |||
348 | mac->txrate_badness += amount; | 380 | mac->txrate_badness += amount; |
349 | if (mac->txrate_badness <= -1000) { | 381 | if (mac->txrate_badness <= -1000) { |
350 | /* Very small badness. Try a faster bitrate. */ | 382 | /* Very small badness. Try a faster bitrate. */ |
351 | if (mac->txrates_change) | ||
352 | memcpy(&oldrates, &mac->txrates, sizeof(oldrates)); | ||
353 | default_rate = raise_rate(mac, default_rate); | 383 | default_rate = raise_rate(mac, default_rate); |
354 | changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; | 384 | changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; |
355 | default_fallback = get_fallback_rate(mac, default_rate); | 385 | default_fallback = get_fallback_rate(mac, default_rate); |
@@ -358,8 +388,6 @@ printk("badness %d\n", mac->txrate_badness); | |||
358 | printk("Bitrate raised to %u\n", default_rate); | 388 | printk("Bitrate raised to %u\n", default_rate); |
359 | } else if (mac->txrate_badness >= 10000) { | 389 | } else if (mac->txrate_badness >= 10000) { |
360 | /* Very high badness. Try a slower bitrate. */ | 390 | /* Very high badness. Try a slower bitrate. */ |
361 | if (mac->txrates_change) | ||
362 | memcpy(&oldrates, &mac->txrates, sizeof(oldrates)); | ||
363 | default_rate = lower_rate(mac, default_rate); | 391 | default_rate = lower_rate(mac, default_rate); |
364 | changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; | 392 | changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT; |
365 | default_fallback = get_fallback_rate(mac, default_rate); | 393 | default_fallback = get_fallback_rate(mac, default_rate); |
@@ -372,7 +400,7 @@ printk("Bitrate lowered to %u\n", default_rate); | |||
372 | mac->txrates.default_fallback = default_fallback; | 400 | mac->txrates.default_fallback = default_fallback; |
373 | 401 | ||
374 | if (changes && mac->txrates_change) | 402 | if (changes && mac->txrates_change) |
375 | mac->txrates_change(mac->dev, changes, &oldrates); | 403 | mac->txrates_change(mac->dev, changes); |
376 | } | 404 | } |
377 | 405 | ||
378 | void ieee80211softmac_fragment_lost(struct net_device *dev, | 406 | void ieee80211softmac_fragment_lost(struct net_device *dev, |
@@ -416,7 +444,11 @@ ieee80211softmac_create_network(struct ieee80211softmac_device *mac, | |||
416 | memcpy(&softnet->supported_rates.rates[softnet->supported_rates.count], net->rates_ex, net->rates_ex_len); | 444 | memcpy(&softnet->supported_rates.rates[softnet->supported_rates.count], net->rates_ex, net->rates_ex_len); |
417 | softnet->supported_rates.count += net->rates_ex_len; | 445 | softnet->supported_rates.count += net->rates_ex_len; |
418 | sort(softnet->supported_rates.rates, softnet->supported_rates.count, sizeof(softnet->supported_rates.rates[0]), rate_cmp, NULL); | 446 | sort(softnet->supported_rates.rates, softnet->supported_rates.count, sizeof(softnet->supported_rates.rates[0]), rate_cmp, NULL); |
419 | 447 | ||
448 | /* we save the ERP value because it is needed at association time, and | ||
449 | * many AP's do not include an ERP IE in the association response. */ | ||
450 | softnet->erp_value = net->erp_value; | ||
451 | |||
420 | softnet->capabilities = net->capability; | 452 | softnet->capabilities = net->capability; |
421 | return softnet; | 453 | return softnet; |
422 | } | 454 | } |