Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1 | /* |
Ivo van Doorn | 811aa9c | 2008-02-03 15:42:53 +0100 | [diff] [blame] | 2 | Copyright (C) 2004 - 2008 rt2x00 SourceForge Project |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 3 | <http://rt2x00.serialmonkey.com> |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the |
| 17 | Free Software Foundation, Inc., |
| 18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | Module: rt2x00lib |
| 23 | Abstract: rt2x00 generic device routines. |
| 24 | */ |
| 25 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 26 | #include <linux/kernel.h> |
| 27 | #include <linux/module.h> |
| 28 | |
| 29 | #include "rt2x00.h" |
| 30 | #include "rt2x00lib.h" |
| 31 | |
| 32 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 33 | * Link tuning handlers |
| 34 | */ |
Ivo van Doorn | 53b3f8e | 2008-02-25 23:15:13 +0100 | [diff] [blame] | 35 | void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 36 | { |
Ivo van Doorn | 53b3f8e | 2008-02-25 23:15:13 +0100 | [diff] [blame] | 37 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) |
| 38 | return; |
| 39 | |
| 40 | /* |
| 41 | * Reset link information. |
| 42 | * Both the currently active vgc level as well as |
| 43 | * the link tuner counter should be reset. Resetting |
| 44 | * the counter is important for devices where the |
| 45 | * device should only perform link tuning during the |
| 46 | * first minute after being enabled. |
| 47 | */ |
Ivo van Doorn | 8de8c51 | 2007-10-13 16:26:32 +0200 | [diff] [blame] | 48 | rt2x00dev->link.count = 0; |
| 49 | rt2x00dev->link.vgc_level = 0; |
| 50 | |
Ivo van Doorn | 53b3f8e | 2008-02-25 23:15:13 +0100 | [diff] [blame] | 51 | /* |
| 52 | * Reset the link tuner. |
| 53 | */ |
| 54 | rt2x00dev->ops->lib->reset_tuner(rt2x00dev); |
| 55 | } |
| 56 | |
| 57 | static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev) |
| 58 | { |
| 59 | /* |
| 60 | * Clear all (possibly) pre-existing quality statistics. |
| 61 | */ |
Ivo van Doorn | 8de8c51 | 2007-10-13 16:26:32 +0200 | [diff] [blame] | 62 | memset(&rt2x00dev->link.qual, 0, sizeof(rt2x00dev->link.qual)); |
| 63 | |
| 64 | /* |
| 65 | * The RX and TX percentage should start at 50% |
| 66 | * this will assure we will get at least get some |
| 67 | * decent value when the link tuner starts. |
| 68 | * The value will be dropped and overwritten with |
| 69 | * the correct (measured )value anyway during the |
| 70 | * first run of the link tuner. |
| 71 | */ |
| 72 | rt2x00dev->link.qual.rx_percentage = 50; |
| 73 | rt2x00dev->link.qual.tx_percentage = 50; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 74 | |
Ivo van Doorn | 53b3f8e | 2008-02-25 23:15:13 +0100 | [diff] [blame] | 75 | rt2x00lib_reset_link_tuner(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 76 | |
| 77 | queue_delayed_work(rt2x00dev->hw->workqueue, |
| 78 | &rt2x00dev->link.work, LINK_TUNE_INTERVAL); |
| 79 | } |
| 80 | |
| 81 | static void rt2x00lib_stop_link_tuner(struct rt2x00_dev *rt2x00dev) |
| 82 | { |
Ivo van Doorn | 3e30968 | 2007-09-25 20:56:36 +0200 | [diff] [blame] | 83 | cancel_delayed_work_sync(&rt2x00dev->link.work); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 86 | /* |
| 87 | * Radio control handlers. |
| 88 | */ |
| 89 | int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev) |
| 90 | { |
| 91 | int status; |
| 92 | |
| 93 | /* |
| 94 | * Don't enable the radio twice. |
| 95 | * And check if the hardware button has been disabled. |
| 96 | */ |
| 97 | if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || |
Ivo van Doorn | 81873e9 | 2007-10-06 14:14:06 +0200 | [diff] [blame] | 98 | test_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 99 | return 0; |
| 100 | |
| 101 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 102 | * Initialize all data queues. |
Ivo van Doorn | 837e7f2 | 2008-01-06 23:41:45 +0100 | [diff] [blame] | 103 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 104 | rt2x00queue_init_rx(rt2x00dev); |
| 105 | rt2x00queue_init_tx(rt2x00dev); |
Ivo van Doorn | 837e7f2 | 2008-01-06 23:41:45 +0100 | [diff] [blame] | 106 | |
| 107 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 108 | * Enable radio. |
| 109 | */ |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 110 | status = |
| 111 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_ON); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 112 | if (status) |
| 113 | return status; |
| 114 | |
Ivo van Doorn | 2b08da3 | 2008-06-03 18:58:56 +0200 | [diff] [blame] | 115 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_ON); |
| 116 | |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 117 | rt2x00leds_led_radio(rt2x00dev, true); |
Ivo van Doorn | 61c2b68 | 2008-04-21 19:01:09 +0200 | [diff] [blame] | 118 | rt2x00led_led_activity(rt2x00dev, true); |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 119 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 120 | __set_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags); |
| 121 | |
| 122 | /* |
| 123 | * Enable RX. |
| 124 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 125 | rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * Start the TX queues. |
| 129 | */ |
Johannes Berg | 36d6825 | 2008-05-15 12:55:26 +0200 | [diff] [blame] | 130 | ieee80211_wake_queues(rt2x00dev->hw); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev) |
| 136 | { |
| 137 | if (!__test_and_clear_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) |
| 138 | return; |
| 139 | |
| 140 | /* |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 141 | * Stop all scheduled work. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 142 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 143 | if (work_pending(&rt2x00dev->intf_work)) |
| 144 | cancel_work_sync(&rt2x00dev->intf_work); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 145 | if (work_pending(&rt2x00dev->filter_work)) |
| 146 | cancel_work_sync(&rt2x00dev->filter_work); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 147 | |
| 148 | /* |
| 149 | * Stop the TX queues. |
| 150 | */ |
| 151 | ieee80211_stop_queues(rt2x00dev->hw); |
| 152 | |
| 153 | /* |
| 154 | * Disable RX. |
| 155 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 156 | rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 157 | |
| 158 | /* |
| 159 | * Disable radio. |
| 160 | */ |
| 161 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_OFF); |
Ivo van Doorn | 2b08da3 | 2008-06-03 18:58:56 +0200 | [diff] [blame] | 162 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_OFF); |
Ivo van Doorn | 61c2b68 | 2008-04-21 19:01:09 +0200 | [diff] [blame] | 163 | rt2x00led_led_activity(rt2x00dev, false); |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 164 | rt2x00leds_led_radio(rt2x00dev, false); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 167 | void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 168 | { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 169 | /* |
| 170 | * When we are disabling the RX, we should also stop the link tuner. |
| 171 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 172 | if (state == STATE_RADIO_RX_OFF) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 173 | rt2x00lib_stop_link_tuner(rt2x00dev); |
| 174 | |
| 175 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); |
| 176 | |
| 177 | /* |
| 178 | * When we are enabling the RX, we should also start the link tuner. |
| 179 | */ |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 180 | if (state == STATE_RADIO_RX_ON && |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 181 | (rt2x00dev->intf_ap_count || rt2x00dev->intf_sta_count)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 182 | rt2x00lib_start_link_tuner(rt2x00dev); |
| 183 | } |
| 184 | |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 185 | static void rt2x00lib_evaluate_antenna_sample(struct rt2x00_dev *rt2x00dev) |
| 186 | { |
| 187 | enum antenna rx = rt2x00dev->link.ant.active.rx; |
| 188 | enum antenna tx = rt2x00dev->link.ant.active.tx; |
| 189 | int sample_a = |
| 190 | rt2x00_get_link_ant_rssi_history(&rt2x00dev->link, ANTENNA_A); |
| 191 | int sample_b = |
| 192 | rt2x00_get_link_ant_rssi_history(&rt2x00dev->link, ANTENNA_B); |
| 193 | |
| 194 | /* |
| 195 | * We are done sampling. Now we should evaluate the results. |
| 196 | */ |
| 197 | rt2x00dev->link.ant.flags &= ~ANTENNA_MODE_SAMPLE; |
| 198 | |
| 199 | /* |
| 200 | * During the last period we have sampled the RSSI |
| 201 | * from both antenna's. It now is time to determine |
| 202 | * which antenna demonstrated the best performance. |
| 203 | * When we are already on the antenna with the best |
| 204 | * performance, then there really is nothing for us |
| 205 | * left to do. |
| 206 | */ |
| 207 | if (sample_a == sample_b) |
| 208 | return; |
| 209 | |
Ivo van Doorn | 05253c9 | 2008-02-25 23:15:08 +0100 | [diff] [blame] | 210 | if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) |
| 211 | rx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 212 | |
Ivo van Doorn | 05253c9 | 2008-02-25 23:15:08 +0100 | [diff] [blame] | 213 | if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY) |
| 214 | tx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 215 | |
| 216 | rt2x00lib_config_antenna(rt2x00dev, rx, tx); |
| 217 | } |
| 218 | |
| 219 | static void rt2x00lib_evaluate_antenna_eval(struct rt2x00_dev *rt2x00dev) |
| 220 | { |
| 221 | enum antenna rx = rt2x00dev->link.ant.active.rx; |
| 222 | enum antenna tx = rt2x00dev->link.ant.active.tx; |
| 223 | int rssi_curr = rt2x00_get_link_ant_rssi(&rt2x00dev->link); |
| 224 | int rssi_old = rt2x00_update_ant_rssi(&rt2x00dev->link, rssi_curr); |
| 225 | |
| 226 | /* |
| 227 | * Legacy driver indicates that we should swap antenna's |
| 228 | * when the difference in RSSI is greater that 5. This |
| 229 | * also should be done when the RSSI was actually better |
| 230 | * then the previous sample. |
| 231 | * When the difference exceeds the threshold we should |
| 232 | * sample the rssi from the other antenna to make a valid |
| 233 | * comparison between the 2 antennas. |
| 234 | */ |
Ivo van Doorn | b290d43 | 2008-02-25 23:15:01 +0100 | [diff] [blame] | 235 | if (abs(rssi_curr - rssi_old) < 5) |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 236 | return; |
| 237 | |
| 238 | rt2x00dev->link.ant.flags |= ANTENNA_MODE_SAMPLE; |
| 239 | |
| 240 | if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) |
| 241 | rx = (rx == ANTENNA_A) ? ANTENNA_B : ANTENNA_A; |
| 242 | |
| 243 | if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY) |
| 244 | tx = (tx == ANTENNA_A) ? ANTENNA_B : ANTENNA_A; |
| 245 | |
| 246 | rt2x00lib_config_antenna(rt2x00dev, rx, tx); |
| 247 | } |
| 248 | |
| 249 | static void rt2x00lib_evaluate_antenna(struct rt2x00_dev *rt2x00dev) |
| 250 | { |
| 251 | /* |
| 252 | * Determine if software diversity is enabled for |
| 253 | * either the TX or RX antenna (or both). |
| 254 | * Always perform this check since within the link |
| 255 | * tuner interval the configuration might have changed. |
| 256 | */ |
| 257 | rt2x00dev->link.ant.flags &= ~ANTENNA_RX_DIVERSITY; |
| 258 | rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY; |
| 259 | |
| 260 | if (rt2x00dev->hw->conf.antenna_sel_rx == 0 && |
Ivo van Doorn | b290d43 | 2008-02-25 23:15:01 +0100 | [diff] [blame] | 261 | rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY) |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 262 | rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY; |
| 263 | if (rt2x00dev->hw->conf.antenna_sel_tx == 0 && |
Ivo van Doorn | b290d43 | 2008-02-25 23:15:01 +0100 | [diff] [blame] | 264 | rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY) |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 265 | rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY; |
| 266 | |
| 267 | if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) && |
| 268 | !(rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)) { |
Ivo van Doorn | 05253c9 | 2008-02-25 23:15:08 +0100 | [diff] [blame] | 269 | rt2x00dev->link.ant.flags = 0; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 270 | return; |
| 271 | } |
| 272 | |
| 273 | /* |
| 274 | * If we have only sampled the data over the last period |
| 275 | * we should now harvest the data. Otherwise just evaluate |
| 276 | * the data. The latter should only be performed once |
| 277 | * every 2 seconds. |
| 278 | */ |
| 279 | if (rt2x00dev->link.ant.flags & ANTENNA_MODE_SAMPLE) |
| 280 | rt2x00lib_evaluate_antenna_sample(rt2x00dev); |
| 281 | else if (rt2x00dev->link.count & 1) |
| 282 | rt2x00lib_evaluate_antenna_eval(rt2x00dev); |
| 283 | } |
| 284 | |
| 285 | static void rt2x00lib_update_link_stats(struct link *link, int rssi) |
| 286 | { |
| 287 | int avg_rssi = rssi; |
| 288 | |
| 289 | /* |
| 290 | * Update global RSSI |
| 291 | */ |
| 292 | if (link->qual.avg_rssi) |
| 293 | avg_rssi = MOVING_AVERAGE(link->qual.avg_rssi, rssi, 8); |
| 294 | link->qual.avg_rssi = avg_rssi; |
| 295 | |
| 296 | /* |
| 297 | * Update antenna RSSI |
| 298 | */ |
| 299 | if (link->ant.rssi_ant) |
| 300 | rssi = MOVING_AVERAGE(link->ant.rssi_ant, rssi, 8); |
| 301 | link->ant.rssi_ant = rssi; |
| 302 | } |
| 303 | |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 304 | static void rt2x00lib_precalculate_link_signal(struct link_qual *qual) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 305 | { |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 306 | if (qual->rx_failed || qual->rx_success) |
| 307 | qual->rx_percentage = |
| 308 | (qual->rx_success * 100) / |
| 309 | (qual->rx_failed + qual->rx_success); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 310 | else |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 311 | qual->rx_percentage = 50; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 312 | |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 313 | if (qual->tx_failed || qual->tx_success) |
| 314 | qual->tx_percentage = |
| 315 | (qual->tx_success * 100) / |
| 316 | (qual->tx_failed + qual->tx_success); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 317 | else |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 318 | qual->tx_percentage = 50; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 319 | |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 320 | qual->rx_success = 0; |
| 321 | qual->rx_failed = 0; |
| 322 | qual->tx_success = 0; |
| 323 | qual->tx_failed = 0; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static int rt2x00lib_calculate_link_signal(struct rt2x00_dev *rt2x00dev, |
| 327 | int rssi) |
| 328 | { |
| 329 | int rssi_percentage = 0; |
| 330 | int signal; |
| 331 | |
| 332 | /* |
| 333 | * We need a positive value for the RSSI. |
| 334 | */ |
| 335 | if (rssi < 0) |
| 336 | rssi += rt2x00dev->rssi_offset; |
| 337 | |
| 338 | /* |
| 339 | * Calculate the different percentages, |
| 340 | * which will be used for the signal. |
| 341 | */ |
| 342 | if (rt2x00dev->rssi_offset) |
| 343 | rssi_percentage = (rssi * 100) / rt2x00dev->rssi_offset; |
| 344 | |
| 345 | /* |
| 346 | * Add the individual percentages and use the WEIGHT |
| 347 | * defines to calculate the current link signal. |
| 348 | */ |
| 349 | signal = ((WEIGHT_RSSI * rssi_percentage) + |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 350 | (WEIGHT_TX * rt2x00dev->link.qual.tx_percentage) + |
| 351 | (WEIGHT_RX * rt2x00dev->link.qual.rx_percentage)) / 100; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 352 | |
| 353 | return (signal > 100) ? 100 : signal; |
| 354 | } |
| 355 | |
| 356 | static void rt2x00lib_link_tuner(struct work_struct *work) |
| 357 | { |
| 358 | struct rt2x00_dev *rt2x00dev = |
| 359 | container_of(work, struct rt2x00_dev, link.work.work); |
| 360 | |
| 361 | /* |
Ivo van Doorn | 25ab002 | 2007-09-25 20:57:04 +0200 | [diff] [blame] | 362 | * When the radio is shutting down we should |
| 363 | * immediately cease all link tuning. |
| 364 | */ |
| 365 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) |
| 366 | return; |
| 367 | |
| 368 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 369 | * Update statistics. |
| 370 | */ |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 371 | rt2x00dev->ops->lib->link_stats(rt2x00dev, &rt2x00dev->link.qual); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 372 | rt2x00dev->low_level_stats.dot11FCSErrorCount += |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 373 | rt2x00dev->link.qual.rx_failed; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 374 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 375 | /* |
| 376 | * Only perform the link tuning when Link tuning |
| 377 | * has been enabled (This could have been disabled from the EEPROM). |
| 378 | */ |
| 379 | if (!test_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags)) |
| 380 | rt2x00dev->ops->lib->link_tuner(rt2x00dev); |
| 381 | |
| 382 | /* |
Ivo van Doorn | 725d99d | 2007-09-25 20:53:20 +0200 | [diff] [blame] | 383 | * Precalculate a portion of the link signal which is |
| 384 | * in based on the tx/rx success/failure counters. |
| 385 | */ |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 386 | rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual); |
Ivo van Doorn | 725d99d | 2007-09-25 20:53:20 +0200 | [diff] [blame] | 387 | |
| 388 | /* |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 389 | * Send a signal to the led to update the led signal strength. |
| 390 | */ |
| 391 | rt2x00leds_led_quality(rt2x00dev, rt2x00dev->link.qual.avg_rssi); |
| 392 | |
| 393 | /* |
Ivo van Doorn | 53b3f8e | 2008-02-25 23:15:13 +0100 | [diff] [blame] | 394 | * Evaluate antenna setup, make this the last step since this could |
| 395 | * possibly reset some statistics. |
| 396 | */ |
| 397 | rt2x00lib_evaluate_antenna(rt2x00dev); |
| 398 | |
| 399 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 400 | * Increase tuner counter, and reschedule the next link tuner run. |
| 401 | */ |
| 402 | rt2x00dev->link.count++; |
| 403 | queue_delayed_work(rt2x00dev->hw->workqueue, &rt2x00dev->link.work, |
| 404 | LINK_TUNE_INTERVAL); |
| 405 | } |
| 406 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 407 | static void rt2x00lib_packetfilter_scheduled(struct work_struct *work) |
| 408 | { |
| 409 | struct rt2x00_dev *rt2x00dev = |
| 410 | container_of(work, struct rt2x00_dev, filter_work); |
Ivo van Doorn | 5886d0d | 2007-10-06 14:13:38 +0200 | [diff] [blame] | 411 | |
Ivo van Doorn | 133adf0 | 2008-04-04 00:01:43 +0200 | [diff] [blame] | 412 | rt2x00dev->ops->lib->config_filter(rt2x00dev, rt2x00dev->packet_filter); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 413 | } |
| 414 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 415 | static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, |
| 416 | struct ieee80211_vif *vif) |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 417 | { |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 418 | struct rt2x00_dev *rt2x00dev = data; |
| 419 | struct rt2x00_intf *intf = vif_to_intf(vif); |
| 420 | struct sk_buff *skb; |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 421 | struct ieee80211_bss_conf conf; |
| 422 | int delayed_flags; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 423 | |
| 424 | /* |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 425 | * Copy all data we need during this action under the protection |
| 426 | * of a spinlock. Otherwise race conditions might occur which results |
| 427 | * into an invalid configuration. |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 428 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 429 | spin_lock(&intf->lock); |
| 430 | |
| 431 | memcpy(&conf, &intf->conf, sizeof(conf)); |
| 432 | delayed_flags = intf->delayed_flags; |
| 433 | intf->delayed_flags = 0; |
| 434 | |
| 435 | spin_unlock(&intf->lock); |
| 436 | |
| 437 | if (delayed_flags & DELAYED_UPDATE_BEACON) { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 438 | skb = ieee80211_beacon_get(rt2x00dev->hw, vif); |
| 439 | if (skb && |
| 440 | rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, skb)) |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 441 | dev_kfree_skb(skb); |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 442 | } |
| 443 | |
Ivo van Doorn | 7281037 | 2008-03-09 22:46:18 +0100 | [diff] [blame] | 444 | if (delayed_flags & DELAYED_CONFIG_ERP) |
| 445 | rt2x00lib_config_erp(rt2x00dev, intf, &intf->conf); |
Ivo van Doorn | a2e1d52 | 2008-03-31 15:53:44 +0200 | [diff] [blame] | 446 | |
| 447 | if (delayed_flags & DELAYED_LED_ASSOC) |
| 448 | rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated); |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | static void rt2x00lib_intf_scheduled(struct work_struct *work) |
| 452 | { |
| 453 | struct rt2x00_dev *rt2x00dev = |
| 454 | container_of(work, struct rt2x00_dev, intf_work); |
| 455 | |
| 456 | /* |
| 457 | * Iterate over each interface and perform the |
| 458 | * requested configurations. |
| 459 | */ |
| 460 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, |
| 461 | rt2x00lib_intf_scheduled_iter, |
| 462 | rt2x00dev); |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 463 | } |
| 464 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 465 | /* |
| 466 | * Interrupt context handlers. |
| 467 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 468 | static void rt2x00lib_beacondone_iter(void *data, u8 *mac, |
| 469 | struct ieee80211_vif *vif) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 470 | { |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 471 | struct rt2x00_intf *intf = vif_to_intf(vif); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 472 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 473 | if (vif->type != IEEE80211_IF_TYPE_AP && |
| 474 | vif->type != IEEE80211_IF_TYPE_IBSS) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 475 | return; |
| 476 | |
Gertjan van Wingerde | c95edf5 | 2008-06-16 19:55:18 +0200 | [diff] [blame] | 477 | /* |
| 478 | * Clean up the beacon skb. |
| 479 | */ |
| 480 | dev_kfree_skb_irq(intf->beacon->skb); |
| 481 | intf->beacon->skb = NULL; |
| 482 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 483 | spin_lock(&intf->lock); |
| 484 | intf->delayed_flags |= DELAYED_UPDATE_BEACON; |
| 485 | spin_unlock(&intf->lock); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev) |
| 489 | { |
| 490 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) |
| 491 | return; |
| 492 | |
Ivo van Doorn | 633257d | 2008-05-23 18:14:02 +0200 | [diff] [blame] | 493 | ieee80211_iterate_active_interfaces_atomic(rt2x00dev->hw, |
| 494 | rt2x00lib_beacondone_iter, |
| 495 | rt2x00dev); |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 496 | |
| 497 | queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 498 | } |
| 499 | EXPORT_SYMBOL_GPL(rt2x00lib_beacondone); |
| 500 | |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 501 | void rt2x00lib_txdone(struct queue_entry *entry, |
| 502 | struct txdone_entry_desc *txdesc) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 503 | { |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 504 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 505 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); |
| 506 | |
| 507 | /* |
| 508 | * Send frame to debugfs immediately, after this call is completed |
| 509 | * we are going to overwrite the skb->cb array. |
| 510 | */ |
| 511 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry->skb); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 512 | |
| 513 | /* |
| 514 | * Update TX statistics. |
| 515 | */ |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 516 | rt2x00dev->link.qual.tx_success += |
| 517 | test_bit(TXDONE_SUCCESS, &txdesc->flags); |
| 518 | rt2x00dev->link.qual.tx_failed += |
John W. Linville | cb14cb7 | 2008-06-10 09:06:52 -0400 | [diff] [blame] | 519 | test_bit(TXDONE_FAILURE, &txdesc->flags); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 520 | |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 521 | /* |
| 522 | * Initialize TX status |
| 523 | */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 524 | memset(&tx_info->status, 0, sizeof(tx_info->status)); |
| 525 | tx_info->status.ack_signal = 0; |
| 526 | tx_info->status.excessive_retries = |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 527 | test_bit(TXDONE_EXCESSIVE_RETRY, &txdesc->flags); |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 528 | tx_info->status.retry_count = txdesc->retry; |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 529 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 530 | if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 531 | if (test_bit(TXDONE_SUCCESS, &txdesc->flags)) |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 532 | tx_info->flags |= IEEE80211_TX_STAT_ACK; |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 533 | else if (test_bit(TXDONE_FAILURE, &txdesc->flags)) |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 534 | rt2x00dev->low_level_stats.dot11ACKFailureCount++; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 535 | } |
| 536 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 537 | if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 538 | if (test_bit(TXDONE_SUCCESS, &txdesc->flags)) |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 539 | rt2x00dev->low_level_stats.dot11RTSSuccessCount++; |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 540 | else if (test_bit(TXDONE_FAILURE, &txdesc->flags)) |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 541 | rt2x00dev->low_level_stats.dot11RTSFailureCount++; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | /* |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 545 | * Only send the status report to mac80211 when TX status was |
| 546 | * requested by it. If this was a extra frame coming through |
| 547 | * a mac80211 library call (RTS/CTS) then we should not send the |
| 548 | * status report back. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 549 | */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 550 | if (tx_info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) |
| 551 | ieee80211_tx_status_irqsafe(rt2x00dev->hw, entry->skb); |
Ivo van Doorn | baf26a7 | 2008-02-17 17:32:08 +0100 | [diff] [blame] | 552 | else |
Ivo van Doorn | fb55f4d1 | 2008-05-10 13:42:06 +0200 | [diff] [blame] | 553 | dev_kfree_skb_irq(entry->skb); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 554 | entry->skb = NULL; |
| 555 | } |
| 556 | EXPORT_SYMBOL_GPL(rt2x00lib_txdone); |
| 557 | |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 558 | void rt2x00lib_rxdone(struct queue_entry *entry, |
| 559 | struct rxdone_entry_desc *rxdesc) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 560 | { |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 561 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 562 | struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 563 | unsigned int header_size = ieee80211_get_hdrlen_from_skb(entry->skb); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 564 | struct ieee80211_supported_band *sband; |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 565 | struct ieee80211_hdr *hdr; |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 566 | const struct rt2x00_rate *rate; |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 567 | unsigned int align; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 568 | unsigned int i; |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 569 | int idx = -1; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 570 | |
| 571 | /* |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 572 | * The data behind the ieee80211 header must be |
Gertjan van Wingerde | a9f853d | 2008-06-07 16:57:09 +0200 | [diff] [blame] | 573 | * aligned on a 4 byte boundary. |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 574 | */ |
Gertjan van Wingerde | a9f853d | 2008-06-07 16:57:09 +0200 | [diff] [blame] | 575 | align = ((unsigned long)(entry->skb->data + header_size)) & 3; |
Gertjan van Wingerde | 239c249 | 2008-06-06 22:54:12 +0200 | [diff] [blame] | 576 | |
| 577 | if (align) { |
| 578 | skb_push(entry->skb, align); |
| 579 | /* Move entire frame in 1 command */ |
| 580 | memmove(entry->skb->data, entry->skb->data + align, |
| 581 | rxdesc->size); |
| 582 | } |
| 583 | |
| 584 | /* Update data pointers, trim buffer to correct size */ |
| 585 | skb_trim(entry->skb, rxdesc->size); |
| 586 | |
| 587 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 588 | * Update RX statistics. |
| 589 | */ |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 590 | sband = &rt2x00dev->bands[rt2x00dev->curr_band]; |
| 591 | for (i = 0; i < sband->n_bitrates; i++) { |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 592 | rate = rt2x00_get_rate(sband->bitrates[i].hw_value); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 593 | |
Ivo van Doorn | 19d30e0 | 2008-03-15 21:38:07 +0100 | [diff] [blame] | 594 | if (((rxdesc->dev_flags & RXDONE_SIGNAL_PLCP) && |
| 595 | (rate->plcp == rxdesc->signal)) || |
| 596 | (!(rxdesc->dev_flags & RXDONE_SIGNAL_PLCP) && |
| 597 | (rate->bitrate == rxdesc->signal))) { |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 598 | idx = i; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 599 | break; |
| 600 | } |
| 601 | } |
| 602 | |
Ivo van Doorn | 866a050 | 2008-03-25 14:12:45 +0100 | [diff] [blame] | 603 | if (idx < 0) { |
| 604 | WARNING(rt2x00dev, "Frame received with unrecognized signal," |
| 605 | "signal=0x%.2x, plcp=%d.\n", rxdesc->signal, |
| 606 | !!(rxdesc->dev_flags & RXDONE_SIGNAL_PLCP)); |
| 607 | idx = 0; |
| 608 | } |
| 609 | |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 610 | /* |
Ivo van Doorn | 7e56d38 | 2008-01-06 23:41:28 +0100 | [diff] [blame] | 611 | * Only update link status if this is a beacon frame carrying our bssid. |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 612 | */ |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 613 | hdr = (struct ieee80211_hdr *)entry->skb->data; |
Ivo van Doorn | ac10446 | 2008-06-16 19:54:57 +0200 | [diff] [blame] | 614 | if (ieee80211_is_beacon(hdr->frame_control) && |
| 615 | (rxdesc->dev_flags & RXDONE_MY_BSS)) |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 616 | rt2x00lib_update_link_stats(&rt2x00dev->link, rxdesc->rssi); |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 617 | |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 618 | rt2x00dev->link.qual.rx_success++; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 619 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 620 | rx_status->rate_idx = idx; |
Bruno Randolf | 566bfe5 | 2008-05-08 19:15:40 +0200 | [diff] [blame] | 621 | rx_status->qual = |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 622 | rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi); |
Bruno Randolf | 566bfe5 | 2008-05-08 19:15:40 +0200 | [diff] [blame] | 623 | rx_status->signal = rxdesc->rssi; |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 624 | rx_status->flag = rxdesc->flags; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 625 | rx_status->antenna = rt2x00dev->link.ant.active.rx; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 626 | |
| 627 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 628 | * Send frame to mac80211 & debugfs. |
| 629 | * mac80211 will clean up the skb structure. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 630 | */ |
Ivo van Doorn | 5a6e599 | 2008-05-10 13:41:32 +0200 | [diff] [blame] | 631 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb); |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 632 | ieee80211_rx_irqsafe(rt2x00dev->hw, entry->skb, rx_status); |
| 633 | entry->skb = NULL; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 634 | } |
| 635 | EXPORT_SYMBOL_GPL(rt2x00lib_rxdone); |
| 636 | |
| 637 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 638 | * Driver initialization handlers. |
| 639 | */ |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 640 | const struct rt2x00_rate rt2x00_supported_rates[12] = { |
| 641 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 642 | .flags = DEV_RATE_CCK | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 643 | .bitrate = 10, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 644 | .ratemask = BIT(0), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 645 | .plcp = 0x00, |
| 646 | }, |
| 647 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 648 | .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 649 | .bitrate = 20, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 650 | .ratemask = BIT(1), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 651 | .plcp = 0x01, |
| 652 | }, |
| 653 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 654 | .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 655 | .bitrate = 55, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 656 | .ratemask = BIT(2), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 657 | .plcp = 0x02, |
| 658 | }, |
| 659 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 660 | .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 661 | .bitrate = 110, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 662 | .ratemask = BIT(3), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 663 | .plcp = 0x03, |
| 664 | }, |
| 665 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 666 | .flags = DEV_RATE_OFDM | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 667 | .bitrate = 60, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 668 | .ratemask = BIT(4), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 669 | .plcp = 0x0b, |
| 670 | }, |
| 671 | { |
| 672 | .flags = DEV_RATE_OFDM, |
| 673 | .bitrate = 90, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 674 | .ratemask = BIT(5), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 675 | .plcp = 0x0f, |
| 676 | }, |
| 677 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 678 | .flags = DEV_RATE_OFDM | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 679 | .bitrate = 120, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 680 | .ratemask = BIT(6), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 681 | .plcp = 0x0a, |
| 682 | }, |
| 683 | { |
| 684 | .flags = DEV_RATE_OFDM, |
| 685 | .bitrate = 180, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 686 | .ratemask = BIT(7), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 687 | .plcp = 0x0e, |
| 688 | }, |
| 689 | { |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 690 | .flags = DEV_RATE_OFDM | DEV_RATE_BASIC, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 691 | .bitrate = 240, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 692 | .ratemask = BIT(8), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 693 | .plcp = 0x09, |
| 694 | }, |
| 695 | { |
| 696 | .flags = DEV_RATE_OFDM, |
| 697 | .bitrate = 360, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 698 | .ratemask = BIT(9), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 699 | .plcp = 0x0d, |
| 700 | }, |
| 701 | { |
| 702 | .flags = DEV_RATE_OFDM, |
| 703 | .bitrate = 480, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 704 | .ratemask = BIT(10), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 705 | .plcp = 0x08, |
| 706 | }, |
| 707 | { |
| 708 | .flags = DEV_RATE_OFDM, |
| 709 | .bitrate = 540, |
Ivo van Doorn | aa77672 | 2008-03-09 22:48:08 +0100 | [diff] [blame] | 710 | .ratemask = BIT(11), |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 711 | .plcp = 0x0c, |
| 712 | }, |
| 713 | }; |
| 714 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 715 | static void rt2x00lib_channel(struct ieee80211_channel *entry, |
| 716 | const int channel, const int tx_power, |
| 717 | const int value) |
| 718 | { |
Ivo van Doorn | f2a3c7f | 2008-02-03 15:52:45 +0100 | [diff] [blame] | 719 | entry->center_freq = ieee80211_channel_to_frequency(channel); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 720 | entry->hw_value = value; |
| 721 | entry->max_power = tx_power; |
| 722 | entry->max_antenna_gain = 0xff; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | static void rt2x00lib_rate(struct ieee80211_rate *entry, |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 726 | const u16 index, const struct rt2x00_rate *rate) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 727 | { |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 728 | entry->flags = 0; |
| 729 | entry->bitrate = rate->bitrate; |
| 730 | entry->hw_value = rt2x00_create_rate_hw_value(index, 0); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 731 | entry->hw_value_short = entry->hw_value; |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 732 | |
| 733 | if (rate->flags & DEV_RATE_SHORT_PREAMBLE) { |
| 734 | entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE; |
| 735 | entry->hw_value_short |= rt2x00_create_rate_hw_value(index, 1); |
| 736 | } |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, |
| 740 | struct hw_mode_spec *spec) |
| 741 | { |
| 742 | struct ieee80211_hw *hw = rt2x00dev->hw; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 743 | struct ieee80211_channel *channels; |
| 744 | struct ieee80211_rate *rates; |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 745 | unsigned int num_rates; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 746 | unsigned int i; |
| 747 | unsigned char tx_power; |
| 748 | |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 749 | num_rates = 0; |
| 750 | if (spec->supported_rates & SUPPORT_RATE_CCK) |
| 751 | num_rates += 4; |
| 752 | if (spec->supported_rates & SUPPORT_RATE_OFDM) |
| 753 | num_rates += 8; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 754 | |
| 755 | channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); |
| 756 | if (!channels) |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 757 | return -ENOMEM; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 758 | |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 759 | rates = kzalloc(sizeof(*rates) * num_rates, GFP_KERNEL); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 760 | if (!rates) |
| 761 | goto exit_free_channels; |
| 762 | |
| 763 | /* |
| 764 | * Initialize Rate list. |
| 765 | */ |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 766 | for (i = 0; i < num_rates; i++) |
Ivo van Doorn | 8f5fa7f | 2008-02-03 15:54:34 +0100 | [diff] [blame] | 767 | rt2x00lib_rate(&rates[i], i, rt2x00_get_rate(i)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 768 | |
| 769 | /* |
| 770 | * Initialize Channel list. |
| 771 | */ |
| 772 | for (i = 0; i < spec->num_channels; i++) { |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 773 | if (spec->channels[i].channel <= 14) { |
| 774 | if (spec->tx_power_bg) |
| 775 | tx_power = spec->tx_power_bg[i]; |
| 776 | else |
| 777 | tx_power = spec->tx_power_default; |
| 778 | } else { |
| 779 | if (spec->tx_power_a) |
| 780 | tx_power = spec->tx_power_a[i]; |
| 781 | else |
| 782 | tx_power = spec->tx_power_default; |
| 783 | } |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 784 | |
| 785 | rt2x00lib_channel(&channels[i], |
| 786 | spec->channels[i].channel, tx_power, i); |
| 787 | } |
| 788 | |
| 789 | /* |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 790 | * Intitialize 802.11b, 802.11g |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 791 | * Rates: CCK, OFDM. |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 792 | * Channels: 2.4 GHz |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 793 | */ |
Gertjan van Wingerde | 47ac268 | 2008-02-17 17:35:55 +0100 | [diff] [blame] | 794 | if (spec->supported_bands & SUPPORT_BAND_2GHZ) { |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 795 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_channels = 14; |
| 796 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_bitrates = num_rates; |
| 797 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].channels = channels; |
| 798 | rt2x00dev->bands[IEEE80211_BAND_2GHZ].bitrates = rates; |
| 799 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 800 | &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | /* |
| 804 | * Intitialize 802.11a |
| 805 | * Rates: OFDM. |
| 806 | * Channels: OFDM, UNII, HiperLAN2. |
| 807 | */ |
Gertjan van Wingerde | 47ac268 | 2008-02-17 17:35:55 +0100 | [diff] [blame] | 808 | if (spec->supported_bands & SUPPORT_BAND_5GHZ) { |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 809 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_channels = |
| 810 | spec->num_channels - 14; |
| 811 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_bitrates = |
| 812 | num_rates - 4; |
| 813 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].channels = &channels[14]; |
| 814 | rt2x00dev->bands[IEEE80211_BAND_5GHZ].bitrates = &rates[4]; |
| 815 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 816 | &rt2x00dev->bands[IEEE80211_BAND_5GHZ]; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 817 | } |
| 818 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 819 | return 0; |
| 820 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 821 | exit_free_channels: |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 822 | kfree(channels); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 823 | ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); |
| 824 | return -ENOMEM; |
| 825 | } |
| 826 | |
| 827 | static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev) |
| 828 | { |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 829 | if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 830 | ieee80211_unregister_hw(rt2x00dev->hw); |
| 831 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 832 | if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) { |
| 833 | kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels); |
| 834 | kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates); |
| 835 | rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; |
| 836 | rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 837 | } |
| 838 | } |
| 839 | |
| 840 | static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev) |
| 841 | { |
| 842 | struct hw_mode_spec *spec = &rt2x00dev->spec; |
| 843 | int status; |
| 844 | |
| 845 | /* |
| 846 | * Initialize HW modes. |
| 847 | */ |
| 848 | status = rt2x00lib_probe_hw_modes(rt2x00dev, spec); |
| 849 | if (status) |
| 850 | return status; |
| 851 | |
| 852 | /* |
Gertjan van Wingerde | 61448f8 | 2008-05-10 13:43:33 +0200 | [diff] [blame] | 853 | * Initialize HW fields. |
| 854 | */ |
| 855 | rt2x00dev->hw->queues = rt2x00dev->ops->tx_queues; |
| 856 | |
| 857 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 858 | * Register HW. |
| 859 | */ |
| 860 | status = ieee80211_register_hw(rt2x00dev->hw); |
| 861 | if (status) { |
| 862 | rt2x00lib_remove_hw(rt2x00dev); |
| 863 | return status; |
| 864 | } |
| 865 | |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 866 | __set_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 867 | |
| 868 | return 0; |
| 869 | } |
| 870 | |
| 871 | /* |
| 872 | * Initialization/uninitialization handlers. |
| 873 | */ |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 874 | static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 875 | { |
| 876 | if (!__test_and_clear_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) |
| 877 | return; |
| 878 | |
| 879 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 880 | * Unregister extra components. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 881 | */ |
| 882 | rt2x00rfkill_unregister(rt2x00dev); |
| 883 | |
| 884 | /* |
| 885 | * Allow the HW to uninitialize. |
| 886 | */ |
| 887 | rt2x00dev->ops->lib->uninitialize(rt2x00dev); |
| 888 | |
| 889 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 890 | * Free allocated queue entries. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 891 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 892 | rt2x00queue_uninitialize(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 893 | } |
| 894 | |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 895 | static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 896 | { |
| 897 | int status; |
| 898 | |
| 899 | if (test_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) |
| 900 | return 0; |
| 901 | |
| 902 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 903 | * Allocate all queue entries. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 904 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 905 | status = rt2x00queue_initialize(rt2x00dev); |
| 906 | if (status) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 907 | return status; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 908 | |
| 909 | /* |
| 910 | * Initialize the device. |
| 911 | */ |
| 912 | status = rt2x00dev->ops->lib->initialize(rt2x00dev); |
Ivo van Doorn | ed49998 | 2008-05-05 17:23:47 +0200 | [diff] [blame] | 913 | if (status) { |
| 914 | rt2x00queue_uninitialize(rt2x00dev); |
| 915 | return status; |
| 916 | } |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 917 | |
| 918 | __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); |
| 919 | |
| 920 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 921 | * Register the extra components. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 922 | */ |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 923 | rt2x00rfkill_register(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 924 | |
| 925 | return 0; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 926 | } |
| 927 | |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 928 | int rt2x00lib_start(struct rt2x00_dev *rt2x00dev) |
| 929 | { |
| 930 | int retval; |
| 931 | |
| 932 | if (test_bit(DEVICE_STARTED, &rt2x00dev->flags)) |
| 933 | return 0; |
| 934 | |
| 935 | /* |
| 936 | * If this is the first interface which is added, |
| 937 | * we should load the firmware now. |
| 938 | */ |
Ivo van Doorn | 9404ef3 | 2008-02-03 15:48:38 +0100 | [diff] [blame] | 939 | retval = rt2x00lib_load_firmware(rt2x00dev); |
| 940 | if (retval) |
| 941 | return retval; |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 942 | |
| 943 | /* |
| 944 | * Initialize the device. |
| 945 | */ |
| 946 | retval = rt2x00lib_initialize(rt2x00dev); |
| 947 | if (retval) |
| 948 | return retval; |
| 949 | |
| 950 | /* |
| 951 | * Enable radio. |
| 952 | */ |
| 953 | retval = rt2x00lib_enable_radio(rt2x00dev); |
| 954 | if (retval) { |
| 955 | rt2x00lib_uninitialize(rt2x00dev); |
| 956 | return retval; |
| 957 | } |
| 958 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 959 | rt2x00dev->intf_ap_count = 0; |
| 960 | rt2x00dev->intf_sta_count = 0; |
| 961 | rt2x00dev->intf_associated = 0; |
| 962 | |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 963 | __set_bit(DEVICE_STARTED, &rt2x00dev->flags); |
| 964 | |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev) |
| 969 | { |
| 970 | if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags)) |
| 971 | return; |
| 972 | |
| 973 | /* |
| 974 | * Perhaps we can add something smarter here, |
| 975 | * but for now just disabling the radio should do. |
| 976 | */ |
| 977 | rt2x00lib_disable_radio(rt2x00dev); |
| 978 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 979 | rt2x00dev->intf_ap_count = 0; |
| 980 | rt2x00dev->intf_sta_count = 0; |
| 981 | rt2x00dev->intf_associated = 0; |
| 982 | |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 983 | __clear_bit(DEVICE_STARTED, &rt2x00dev->flags); |
| 984 | } |
| 985 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 986 | /* |
| 987 | * driver allocation handlers. |
| 988 | */ |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 989 | int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) |
| 990 | { |
| 991 | int retval = -ENOMEM; |
| 992 | |
| 993 | /* |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 994 | * Make room for rt2x00_intf inside the per-interface |
| 995 | * structure ieee80211_vif. |
| 996 | */ |
| 997 | rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf); |
| 998 | |
| 999 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1000 | * Let the driver probe the device to detect the capabilities. |
| 1001 | */ |
| 1002 | retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev); |
| 1003 | if (retval) { |
| 1004 | ERROR(rt2x00dev, "Failed to allocate device.\n"); |
| 1005 | goto exit; |
| 1006 | } |
| 1007 | |
| 1008 | /* |
| 1009 | * Initialize configuration work. |
| 1010 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 1011 | INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 1012 | INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1013 | INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner); |
| 1014 | |
| 1015 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1016 | * Allocate queue array. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1017 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1018 | retval = rt2x00queue_allocate(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1019 | if (retval) |
| 1020 | goto exit; |
| 1021 | |
| 1022 | /* |
| 1023 | * Initialize ieee80211 structure. |
| 1024 | */ |
| 1025 | retval = rt2x00lib_probe_hw(rt2x00dev); |
| 1026 | if (retval) { |
| 1027 | ERROR(rt2x00dev, "Failed to initialize hw.\n"); |
| 1028 | goto exit; |
| 1029 | } |
| 1030 | |
| 1031 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1032 | * Register extra components. |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1033 | */ |
| 1034 | rt2x00leds_register(rt2x00dev); |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1035 | rt2x00rfkill_allocate(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1036 | rt2x00debug_register(rt2x00dev); |
| 1037 | |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1038 | __set_bit(DEVICE_PRESENT, &rt2x00dev->flags); |
| 1039 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1040 | return 0; |
| 1041 | |
| 1042 | exit: |
| 1043 | rt2x00lib_remove_dev(rt2x00dev); |
| 1044 | |
| 1045 | return retval; |
| 1046 | } |
| 1047 | EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev); |
| 1048 | |
| 1049 | void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) |
| 1050 | { |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1051 | __clear_bit(DEVICE_PRESENT, &rt2x00dev->flags); |
| 1052 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1053 | /* |
| 1054 | * Disable radio. |
| 1055 | */ |
| 1056 | rt2x00lib_disable_radio(rt2x00dev); |
| 1057 | |
| 1058 | /* |
| 1059 | * Uninitialize device. |
| 1060 | */ |
| 1061 | rt2x00lib_uninitialize(rt2x00dev); |
| 1062 | |
| 1063 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1064 | * Free extra components |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1065 | */ |
| 1066 | rt2x00debug_deregister(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1067 | rt2x00rfkill_free(rt2x00dev); |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1068 | rt2x00leds_unregister(rt2x00dev); |
| 1069 | |
| 1070 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1071 | * Free ieee80211_hw memory. |
| 1072 | */ |
| 1073 | rt2x00lib_remove_hw(rt2x00dev); |
| 1074 | |
| 1075 | /* |
| 1076 | * Free firmware image. |
| 1077 | */ |
| 1078 | rt2x00lib_free_firmware(rt2x00dev); |
| 1079 | |
| 1080 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1081 | * Free queue structures. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1082 | */ |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 1083 | rt2x00queue_free(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1084 | } |
| 1085 | EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); |
| 1086 | |
| 1087 | /* |
| 1088 | * Device state handlers |
| 1089 | */ |
| 1090 | #ifdef CONFIG_PM |
| 1091 | int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state) |
| 1092 | { |
| 1093 | int retval; |
| 1094 | |
| 1095 | NOTICE(rt2x00dev, "Going to sleep.\n"); |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1096 | __clear_bit(DEVICE_PRESENT, &rt2x00dev->flags); |
| 1097 | |
| 1098 | /* |
| 1099 | * Only continue if mac80211 has open interfaces. |
| 1100 | */ |
| 1101 | if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags)) |
| 1102 | goto exit; |
Ivo van Doorn | 6d7f987 | 2007-10-06 14:12:42 +0200 | [diff] [blame] | 1103 | __set_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1104 | |
| 1105 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1106 | * Disable radio. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1107 | */ |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 1108 | rt2x00lib_stop(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1109 | rt2x00lib_uninitialize(rt2x00dev); |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1110 | |
| 1111 | /* |
| 1112 | * Suspend/disable extra components. |
| 1113 | */ |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1114 | rt2x00leds_suspend(rt2x00dev); |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1115 | rt2x00rfkill_suspend(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1116 | rt2x00debug_deregister(rt2x00dev); |
| 1117 | |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1118 | exit: |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1119 | /* |
Ivo van Doorn | 9896322 | 2008-03-27 17:15:24 +0100 | [diff] [blame] | 1120 | * Set device mode to sleep for power management, |
| 1121 | * on some hardware this call seems to consistently fail. |
| 1122 | * From the specifications it is hard to tell why it fails, |
| 1123 | * and if this is a "bad thing". |
| 1124 | * Overall it is safe to just ignore the failure and |
| 1125 | * continue suspending. The only downside is that the |
| 1126 | * device will not be in optimal power save mode, but with |
| 1127 | * the radio and the other components already disabled the |
| 1128 | * device is as good as disabled. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1129 | */ |
| 1130 | retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP); |
| 1131 | if (retval) |
Ivo van Doorn | 9896322 | 2008-03-27 17:15:24 +0100 | [diff] [blame] | 1132 | WARNING(rt2x00dev, "Device failed to enter sleep state, " |
| 1133 | "continue suspending.\n"); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1134 | |
| 1135 | return 0; |
| 1136 | } |
| 1137 | EXPORT_SYMBOL_GPL(rt2x00lib_suspend); |
| 1138 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 1139 | static void rt2x00lib_resume_intf(void *data, u8 *mac, |
| 1140 | struct ieee80211_vif *vif) |
| 1141 | { |
| 1142 | struct rt2x00_dev *rt2x00dev = data; |
| 1143 | struct rt2x00_intf *intf = vif_to_intf(vif); |
| 1144 | |
| 1145 | spin_lock(&intf->lock); |
| 1146 | |
| 1147 | rt2x00lib_config_intf(rt2x00dev, intf, |
| 1148 | vif->type, intf->mac, intf->bssid); |
| 1149 | |
| 1150 | |
| 1151 | /* |
| 1152 | * Master or Ad-hoc mode require a new beacon update. |
| 1153 | */ |
| 1154 | if (vif->type == IEEE80211_IF_TYPE_AP || |
| 1155 | vif->type == IEEE80211_IF_TYPE_IBSS) |
| 1156 | intf->delayed_flags |= DELAYED_UPDATE_BEACON; |
| 1157 | |
| 1158 | spin_unlock(&intf->lock); |
| 1159 | } |
| 1160 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1161 | int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) |
| 1162 | { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1163 | int retval; |
| 1164 | |
| 1165 | NOTICE(rt2x00dev, "Waking up.\n"); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1166 | |
| 1167 | /* |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1168 | * Restore/enable extra components. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1169 | */ |
| 1170 | rt2x00debug_register(rt2x00dev); |
Ivo van Doorn | 1682fe6 | 2008-03-13 15:38:03 +0100 | [diff] [blame] | 1171 | rt2x00rfkill_resume(rt2x00dev); |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 1172 | rt2x00leds_resume(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1173 | |
| 1174 | /* |
Ivo van Doorn | 6d7f987 | 2007-10-06 14:12:42 +0200 | [diff] [blame] | 1175 | * Only continue if mac80211 had open interfaces. |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1176 | */ |
Ivo van Doorn | 6d7f987 | 2007-10-06 14:12:42 +0200 | [diff] [blame] | 1177 | if (!__test_and_clear_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags)) |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1178 | return 0; |
| 1179 | |
| 1180 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1181 | * Reinitialize device and all active interfaces. |
| 1182 | */ |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 1183 | retval = rt2x00lib_start(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1184 | if (retval) |
| 1185 | goto exit; |
| 1186 | |
| 1187 | /* |
| 1188 | * Reconfigure device. |
| 1189 | */ |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1190 | rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, 1); |
| 1191 | if (!rt2x00dev->hw->conf.radio_enabled) |
| 1192 | rt2x00lib_disable_radio(rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1193 | |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 1194 | /* |
| 1195 | * Iterator over each active interface to |
| 1196 | * reconfigure the hardware. |
| 1197 | */ |
| 1198 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, |
| 1199 | rt2x00lib_resume_intf, rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1200 | |
| 1201 | /* |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 1202 | * We are ready again to receive requests from mac80211. |
| 1203 | */ |
| 1204 | __set_bit(DEVICE_PRESENT, &rt2x00dev->flags); |
| 1205 | |
| 1206 | /* |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1207 | * It is possible that during that mac80211 has attempted |
| 1208 | * to send frames while we were suspending or resuming. |
| 1209 | * In that case we have disabled the TX queue and should |
| 1210 | * now enable it again |
| 1211 | */ |
Johannes Berg | 36d6825 | 2008-05-15 12:55:26 +0200 | [diff] [blame] | 1212 | ieee80211_wake_queues(rt2x00dev->hw); |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 1213 | |
| 1214 | /* |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 1215 | * During interface iteration we might have changed the |
| 1216 | * delayed_flags, time to handles the event by calling |
| 1217 | * the work handler directly. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1218 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 1219 | rt2x00lib_intf_scheduled(&rt2x00dev->intf_work); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1220 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1221 | return 0; |
| 1222 | |
| 1223 | exit: |
| 1224 | rt2x00lib_disable_radio(rt2x00dev); |
| 1225 | rt2x00lib_uninitialize(rt2x00dev); |
| 1226 | rt2x00debug_deregister(rt2x00dev); |
| 1227 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1228 | return retval; |
| 1229 | } |
| 1230 | EXPORT_SYMBOL_GPL(rt2x00lib_resume); |
| 1231 | #endif /* CONFIG_PM */ |
| 1232 | |
| 1233 | /* |
| 1234 | * rt2x00lib module information. |
| 1235 | */ |
| 1236 | MODULE_AUTHOR(DRV_PROJECT); |
| 1237 | MODULE_VERSION(DRV_VERSION); |
| 1238 | MODULE_DESCRIPTION("rt2x00 library"); |
| 1239 | MODULE_LICENSE("GPL"); |