aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c73
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00reg.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c6
8 files changed, 71 insertions, 42 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index d6cba138c7ab..c69f85ed7669 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -960,8 +960,12 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev,
960 rt2400pci_disable_radio(rt2x00dev); 960 rt2400pci_disable_radio(rt2x00dev);
961 break; 961 break;
962 case STATE_RADIO_RX_ON: 962 case STATE_RADIO_RX_ON:
963 case STATE_RADIO_RX_ON_LINK:
964 rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
965 break;
963 case STATE_RADIO_RX_OFF: 966 case STATE_RADIO_RX_OFF:
964 rt2400pci_toggle_rx(rt2x00dev, state); 967 case STATE_RADIO_RX_OFF_LINK:
968 rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
965 break; 969 break;
966 case STATE_DEEP_SLEEP: 970 case STATE_DEEP_SLEEP:
967 case STATE_SLEEP: 971 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index e874fdcae204..91e87b53374f 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1112,8 +1112,12 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1112 rt2500pci_disable_radio(rt2x00dev); 1112 rt2500pci_disable_radio(rt2x00dev);
1113 break; 1113 break;
1114 case STATE_RADIO_RX_ON: 1114 case STATE_RADIO_RX_ON:
1115 case STATE_RADIO_RX_ON_LINK:
1116 rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1117 break;
1115 case STATE_RADIO_RX_OFF: 1118 case STATE_RADIO_RX_OFF:
1116 rt2500pci_toggle_rx(rt2x00dev, state); 1119 case STATE_RADIO_RX_OFF_LINK:
1120 rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1117 break; 1121 break;
1118 case STATE_DEEP_SLEEP: 1122 case STATE_DEEP_SLEEP:
1119 case STATE_SLEEP: 1123 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 4ca9730e5e92..638c3d243108 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1001,8 +1001,12 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1001 rt2500usb_disable_radio(rt2x00dev); 1001 rt2500usb_disable_radio(rt2x00dev);
1002 break; 1002 break;
1003 case STATE_RADIO_RX_ON: 1003 case STATE_RADIO_RX_ON:
1004 case STATE_RADIO_RX_ON_LINK:
1005 rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1006 break;
1004 case STATE_RADIO_RX_OFF: 1007 case STATE_RADIO_RX_OFF:
1005 rt2500usb_toggle_rx(rt2x00dev, state); 1008 case STATE_RADIO_RX_OFF_LINK:
1009 rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1006 break; 1010 break;
1007 case STATE_DEEP_SLEEP: 1011 case STATE_DEEP_SLEEP:
1008 case STATE_SLEEP: 1012 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 72cfe00c1ed7..07adc576db49 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -97,12 +97,16 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
97 libconf.ant.rx = rx; 97 libconf.ant.rx = rx;
98 libconf.ant.tx = tx; 98 libconf.ant.tx = tx;
99 99
100 if (rx == rt2x00dev->link.ant.active.rx &&
101 tx == rt2x00dev->link.ant.active.tx)
102 return;
103
100 /* 104 /*
101 * Antenna setup changes require the RX to be disabled, 105 * Antenna setup changes require the RX to be disabled,
102 * else the changes will be ignored by the device. 106 * else the changes will be ignored by the device.
103 */ 107 */
104 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 108 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
105 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 109 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF_LINK);
106 110
107 /* 111 /*
108 * Write new antenna setup to device and reset the link tuner. 112 * Write new antenna setup to device and reset the link tuner.
@@ -116,7 +120,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
116 rt2x00dev->link.ant.active.tx = libconf.ant.tx; 120 rt2x00dev->link.ant.active.tx = libconf.ant.tx;
117 121
118 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 122 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
119 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 123 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK);
120} 124}
121 125
122void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, 126void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index c4be2ac4d7a4..0d51f478bcdf 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -61,11 +61,33 @@ EXPORT_SYMBOL_GPL(rt2x00lib_get_ring);
61/* 61/*
62 * Link tuning handlers 62 * Link tuning handlers
63 */ 63 */
64static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev) 64void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev)
65{ 65{
66 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
67 return;
68
69 /*
70 * Reset link information.
71 * Both the currently active vgc level as well as
72 * the link tuner counter should be reset. Resetting
73 * the counter is important for devices where the
74 * device should only perform link tuning during the
75 * first minute after being enabled.
76 */
66 rt2x00dev->link.count = 0; 77 rt2x00dev->link.count = 0;
67 rt2x00dev->link.vgc_level = 0; 78 rt2x00dev->link.vgc_level = 0;
68 79
80 /*
81 * Reset the link tuner.
82 */
83 rt2x00dev->ops->lib->reset_tuner(rt2x00dev);
84}
85
86static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev)
87{
88 /*
89 * Clear all (possibly) pre-existing quality statistics.
90 */
69 memset(&rt2x00dev->link.qual, 0, sizeof(rt2x00dev->link.qual)); 91 memset(&rt2x00dev->link.qual, 0, sizeof(rt2x00dev->link.qual));
70 92
71 /* 93 /*
@@ -79,10 +101,7 @@ static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev)
79 rt2x00dev->link.qual.rx_percentage = 50; 101 rt2x00dev->link.qual.rx_percentage = 50;
80 rt2x00dev->link.qual.tx_percentage = 50; 102 rt2x00dev->link.qual.tx_percentage = 50;
81 103
82 /* 104 rt2x00lib_reset_link_tuner(rt2x00dev);
83 * Reset the link tuner.
84 */
85 rt2x00dev->ops->lib->reset_tuner(rt2x00dev);
86 105
87 queue_delayed_work(rt2x00dev->hw->workqueue, 106 queue_delayed_work(rt2x00dev->hw->workqueue,
88 &rt2x00dev->link.work, LINK_TUNE_INTERVAL); 107 &rt2x00dev->link.work, LINK_TUNE_INTERVAL);
@@ -93,15 +112,6 @@ static void rt2x00lib_stop_link_tuner(struct rt2x00_dev *rt2x00dev)
93 cancel_delayed_work_sync(&rt2x00dev->link.work); 112 cancel_delayed_work_sync(&rt2x00dev->link.work);
94} 113}
95 114
96void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev)
97{
98 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
99 return;
100
101 rt2x00lib_stop_link_tuner(rt2x00dev);
102 rt2x00lib_start_link_tuner(rt2x00dev);
103}
104
105/* 115/*
106 * Ring initialization 116 * Ring initialization
107 */ 117 */
@@ -260,19 +270,11 @@ static void rt2x00lib_evaluate_antenna_sample(struct rt2x00_dev *rt2x00dev)
260 if (sample_a == sample_b) 270 if (sample_a == sample_b)
261 return; 271 return;
262 272
263 if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) { 273 if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY)
264 if (sample_a > sample_b && rx == ANTENNA_B) 274 rx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B;
265 rx = ANTENNA_A;
266 else if (rx == ANTENNA_A)
267 rx = ANTENNA_B;
268 }
269 275
270 if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY) { 276 if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)
271 if (sample_a > sample_b && tx == ANTENNA_B) 277 tx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B;
272 tx = ANTENNA_A;
273 else if (tx == ANTENNA_A)
274 tx = ANTENNA_B;
275 }
276 278
277 rt2x00lib_config_antenna(rt2x00dev, rx, tx); 279 rt2x00lib_config_antenna(rt2x00dev, rx, tx);
278} 280}
@@ -293,7 +295,7 @@ static void rt2x00lib_evaluate_antenna_eval(struct rt2x00_dev *rt2x00dev)
293 * sample the rssi from the other antenna to make a valid 295 * sample the rssi from the other antenna to make a valid
294 * comparison between the 2 antennas. 296 * comparison between the 2 antennas.
295 */ 297 */
296 if ((rssi_curr - rssi_old) > -5 || (rssi_curr - rssi_old) < 5) 298 if (abs(rssi_curr - rssi_old) < 5)
297 return; 299 return;
298 300
299 rt2x00dev->link.ant.flags |= ANTENNA_MODE_SAMPLE; 301 rt2x00dev->link.ant.flags |= ANTENNA_MODE_SAMPLE;
@@ -319,15 +321,15 @@ static void rt2x00lib_evaluate_antenna(struct rt2x00_dev *rt2x00dev)
319 rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY; 321 rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY;
320 322
321 if (rt2x00dev->hw->conf.antenna_sel_rx == 0 && 323 if (rt2x00dev->hw->conf.antenna_sel_rx == 0 &&
322 rt2x00dev->default_ant.rx != ANTENNA_SW_DIVERSITY) 324 rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
323 rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY; 325 rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY;
324 if (rt2x00dev->hw->conf.antenna_sel_tx == 0 && 326 if (rt2x00dev->hw->conf.antenna_sel_tx == 0 &&
325 rt2x00dev->default_ant.tx != ANTENNA_SW_DIVERSITY) 327 rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
326 rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY; 328 rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY;
327 329
328 if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) && 330 if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) &&
329 !(rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)) { 331 !(rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)) {
330 rt2x00dev->link.ant.flags &= ~ANTENNA_MODE_SAMPLE; 332 rt2x00dev->link.ant.flags = 0;
331 return; 333 return;
332 } 334 }
333 335
@@ -441,17 +443,18 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
441 rt2x00dev->ops->lib->link_tuner(rt2x00dev); 443 rt2x00dev->ops->lib->link_tuner(rt2x00dev);
442 444
443 /* 445 /*
444 * Evaluate antenna setup.
445 */
446 rt2x00lib_evaluate_antenna(rt2x00dev);
447
448 /*
449 * Precalculate a portion of the link signal which is 446 * Precalculate a portion of the link signal which is
450 * in based on the tx/rx success/failure counters. 447 * in based on the tx/rx success/failure counters.
451 */ 448 */
452 rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual); 449 rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual);
453 450
454 /* 451 /*
452 * Evaluate antenna setup, make this the last step since this could
453 * possibly reset some statistics.
454 */
455 rt2x00lib_evaluate_antenna(rt2x00dev);
456
457 /*
455 * Increase tuner counter, and reschedule the next link tuner run. 458 * Increase tuner counter, and reschedule the next link tuner run.
456 */ 459 */
457 rt2x00dev->link.count++; 460 rt2x00dev->link.count++;
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
index 838421216da0..b1915dc7dda1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00reg.h
+++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
@@ -85,6 +85,8 @@ enum dev_state {
85 STATE_RADIO_OFF, 85 STATE_RADIO_OFF,
86 STATE_RADIO_RX_ON, 86 STATE_RADIO_RX_ON,
87 STATE_RADIO_RX_OFF, 87 STATE_RADIO_RX_OFF,
88 STATE_RADIO_RX_ON_LINK,
89 STATE_RADIO_RX_OFF_LINK,
88 STATE_RADIO_IRQ_ON, 90 STATE_RADIO_IRQ_ON,
89 STATE_RADIO_IRQ_OFF, 91 STATE_RADIO_IRQ_OFF,
90}; 92};
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index b31f0c26c32b..e808db98f2f5 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1482,8 +1482,12 @@ static int rt61pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1482 rt61pci_disable_radio(rt2x00dev); 1482 rt61pci_disable_radio(rt2x00dev);
1483 break; 1483 break;
1484 case STATE_RADIO_RX_ON: 1484 case STATE_RADIO_RX_ON:
1485 case STATE_RADIO_RX_ON_LINK:
1486 rt61pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1487 break;
1485 case STATE_RADIO_RX_OFF: 1488 case STATE_RADIO_RX_OFF:
1486 rt61pci_toggle_rx(rt2x00dev, state); 1489 case STATE_RADIO_RX_OFF_LINK:
1490 rt61pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1487 break; 1491 break;
1488 case STATE_DEEP_SLEEP: 1492 case STATE_DEEP_SLEEP:
1489 case STATE_SLEEP: 1493 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 4d576ab3e7f9..4fac2d414d84 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1208,8 +1208,12 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1208 rt73usb_disable_radio(rt2x00dev); 1208 rt73usb_disable_radio(rt2x00dev);
1209 break; 1209 break;
1210 case STATE_RADIO_RX_ON: 1210 case STATE_RADIO_RX_ON:
1211 case STATE_RADIO_RX_ON_LINK:
1212 rt73usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1213 break;
1211 case STATE_RADIO_RX_OFF: 1214 case STATE_RADIO_RX_OFF:
1212 rt73usb_toggle_rx(rt2x00dev, state); 1215 case STATE_RADIO_RX_OFF_LINK:
1216 rt73usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1213 break; 1217 break;
1214 case STATE_DEEP_SLEEP: 1218 case STATE_DEEP_SLEEP:
1215 case STATE_SLEEP: 1219 case STATE_SLEEP: