aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00link.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00link.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00link.c78
1 files changed, 54 insertions, 24 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00link.c b/drivers/net/wireless/rt2x00/rt2x00link.c
index 666cef3f8472..ea10b0068f82 100644
--- a/drivers/net/wireless/rt2x00/rt2x00link.c
+++ b/drivers/net/wireless/rt2x00/rt2x00link.c
@@ -67,7 +67,7 @@
67 (__avg).avg_weight ? \ 67 (__avg).avg_weight ? \
68 ((((__avg).avg_weight * ((AVG_SAMPLES) - 1)) + \ 68 ((((__avg).avg_weight * ((AVG_SAMPLES) - 1)) + \
69 ((__val) * (AVG_FACTOR))) / \ 69 ((__val) * (AVG_FACTOR))) / \
70 (AVG_SAMPLES) ) : \ 70 (AVG_SAMPLES)) : \
71 ((__val) * (AVG_FACTOR)); \ 71 ((__val) * (AVG_FACTOR)); \
72 __new.avg = __new.avg_weight / (AVG_FACTOR); \ 72 __new.avg = __new.avg_weight / (AVG_FACTOR); \
73 __new; \ 73 __new; \
@@ -188,31 +188,17 @@ static void rt2x00lib_antenna_diversity_eval(struct rt2x00_dev *rt2x00dev)
188static bool rt2x00lib_antenna_diversity(struct rt2x00_dev *rt2x00dev) 188static bool rt2x00lib_antenna_diversity(struct rt2x00_dev *rt2x00dev)
189{ 189{
190 struct link_ant *ant = &rt2x00dev->link.ant; 190 struct link_ant *ant = &rt2x00dev->link.ant;
191 unsigned int flags = ant->flags;
192 191
193 /* 192 /*
194 * Determine if software diversity is enabled for 193 * Determine if software diversity is enabled for
195 * either the TX or RX antenna (or both). 194 * either the TX or RX antenna (or both).
196 * Always perform this check since within the link
197 * tuner interval the configuration might have changed.
198 */ 195 */
199 flags &= ~ANTENNA_RX_DIVERSITY;
200 flags &= ~ANTENNA_TX_DIVERSITY;
201
202 if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
203 flags |= ANTENNA_RX_DIVERSITY;
204 if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
205 flags |= ANTENNA_TX_DIVERSITY;
206
207 if (!(ant->flags & ANTENNA_RX_DIVERSITY) && 196 if (!(ant->flags & ANTENNA_RX_DIVERSITY) &&
208 !(ant->flags & ANTENNA_TX_DIVERSITY)) { 197 !(ant->flags & ANTENNA_TX_DIVERSITY)) {
209 ant->flags = 0; 198 ant->flags = 0;
210 return true; 199 return true;
211 } 200 }
212 201
213 /* Update flags */
214 ant->flags = flags;
215
216 /* 202 /*
217 * If we have only sampled the data over the last period 203 * If we have only sampled the data over the last period
218 * we should now harvest the data. Otherwise just evaluate 204 * we should now harvest the data. Otherwise just evaluate
@@ -240,6 +226,12 @@ void rt2x00link_update_stats(struct rt2x00_dev *rt2x00dev,
240 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 226 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
241 227
242 /* 228 /*
229 * No need to update the stats for !=STA interfaces
230 */
231 if (!rt2x00dev->intf_sta_count)
232 return;
233
234 /*
243 * Frame was received successfully since non-succesfull 235 * Frame was received successfully since non-succesfull
244 * frames would have been dropped by the hardware. 236 * frames would have been dropped by the hardware.
245 */ 237 */
@@ -281,7 +273,7 @@ void rt2x00link_start_tuner(struct rt2x00_dev *rt2x00dev)
281 /** 273 /**
282 * While scanning, link tuning is disabled. By default 274 * While scanning, link tuning is disabled. By default
283 * the most sensitive settings will be used to make sure 275 * the most sensitive settings will be used to make sure
284 * that all beacons and probe responses will be recieved 276 * that all beacons and probe responses will be received
285 * during the scan. 277 * during the scan.
286 */ 278 */
287 if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) 279 if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags))
@@ -381,7 +373,7 @@ static void rt2x00link_tuner(struct work_struct *work)
381 * do not support link tuning at all, while other devices can disable 373 * do not support link tuning at all, while other devices can disable
382 * the feature from the EEPROM. 374 * the feature from the EEPROM.
383 */ 375 */
384 if (test_bit(DRIVER_SUPPORT_LINK_TUNING, &rt2x00dev->flags)) 376 if (test_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags))
385 rt2x00dev->ops->lib->link_tuner(rt2x00dev, qual, link->count); 377 rt2x00dev->ops->lib->link_tuner(rt2x00dev, qual, link->count);
386 378
387 /* 379 /*
@@ -411,12 +403,11 @@ void rt2x00link_start_watchdog(struct rt2x00_dev *rt2x00dev)
411{ 403{
412 struct link *link = &rt2x00dev->link; 404 struct link *link = &rt2x00dev->link;
413 405
414 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) || 406 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
415 !test_bit(DRIVER_SUPPORT_WATCHDOG, &rt2x00dev->flags)) 407 rt2x00dev->ops->lib->watchdog)
416 return; 408 ieee80211_queue_delayed_work(rt2x00dev->hw,
417 409 &link->watchdog_work,
418 ieee80211_queue_delayed_work(rt2x00dev->hw, 410 WATCHDOG_INTERVAL);
419 &link->watchdog_work, WATCHDOG_INTERVAL);
420} 411}
421 412
422void rt2x00link_stop_watchdog(struct rt2x00_dev *rt2x00dev) 413void rt2x00link_stop_watchdog(struct rt2x00_dev *rt2x00dev)
@@ -441,11 +432,50 @@ static void rt2x00link_watchdog(struct work_struct *work)
441 432
442 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) 433 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
443 ieee80211_queue_delayed_work(rt2x00dev->hw, 434 ieee80211_queue_delayed_work(rt2x00dev->hw,
444 &link->watchdog_work, WATCHDOG_INTERVAL); 435 &link->watchdog_work,
436 WATCHDOG_INTERVAL);
437}
438
439void rt2x00link_start_agc(struct rt2x00_dev *rt2x00dev)
440{
441 struct link *link = &rt2x00dev->link;
442
443 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
444 rt2x00dev->ops->lib->gain_calibration)
445 ieee80211_queue_delayed_work(rt2x00dev->hw,
446 &link->agc_work,
447 AGC_INTERVAL);
448}
449
450void rt2x00link_stop_agc(struct rt2x00_dev *rt2x00dev)
451{
452 cancel_delayed_work_sync(&rt2x00dev->link.agc_work);
453}
454
455static void rt2x00link_agc(struct work_struct *work)
456{
457 struct rt2x00_dev *rt2x00dev =
458 container_of(work, struct rt2x00_dev, link.agc_work.work);
459 struct link *link = &rt2x00dev->link;
460
461 /*
462 * When the radio is shutting down we should
463 * immediately cease the watchdog monitoring.
464 */
465 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
466 return;
467
468 rt2x00dev->ops->lib->gain_calibration(rt2x00dev);
469
470 if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
471 ieee80211_queue_delayed_work(rt2x00dev->hw,
472 &link->agc_work,
473 AGC_INTERVAL);
445} 474}
446 475
447void rt2x00link_register(struct rt2x00_dev *rt2x00dev) 476void rt2x00link_register(struct rt2x00_dev *rt2x00dev)
448{ 477{
478 INIT_DELAYED_WORK(&rt2x00dev->link.agc_work, rt2x00link_agc);
449 INIT_DELAYED_WORK(&rt2x00dev->link.watchdog_work, rt2x00link_watchdog); 479 INIT_DELAYED_WORK(&rt2x00dev->link.watchdog_work, rt2x00link_watchdog);
450 INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00link_tuner); 480 INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00link_tuner);
451} 481}